Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(e2e-fixtures): accept the media-type mismatch tail and drop dead test scripts
Alfredo Lopez0e50e4575a47
diff --git a/tests/e2e/fixtures/image-capabilities/provider.mjs b/tests/e2e/fixtures/image-capabilities/provider.mjsindex 842135527..cc6ab178b 100644--- a/tests/e2e/fixtures/image-capabilities/provider.mjs+++ b/tests/e2e/fixtures/image-capabilities/provider.mjs@@ -354,10 +354,13 @@ const ATTACHED_FILE_LINE = /^attached_file: id="([^"\n]+)"[^\n]*$/m/*** The trailing fields of that line (`turnContext.ts`): the byte length the Host- * verified, then the reader. Anchored to the end of the line, so a file name- * that contains the same text cannot supply the value.+ * verified, then the reader, then the optional media-type mismatch tail. The+ * declared type in that tail is written with `quotePromptValue`, a JSON string+ * literal that may contain spaces and escaped quotes. Anchored to the end of the+ * line, so a file name that contains the same text cannot supply the value.*/-const ATTACHED_FILE_BYTES = / bytes=(\S*) reader=\S+$/+const ATTACHED_FILE_BYTES =+ / bytes=(\S*) reader=\S+(?: mismatch=true(?: declared="(?:[^"\\]|\\.)*")? detected=\S+)?$//** A positive decimal integer without leading zeros. */const POSITIVE_DECIMAL = /^[1-9][0-9]*$/diff --git a/tests/e2e/fixtures/image-capabilities/sdk.test.mjs b/tests/e2e/fixtures/image-capabilities/sdk.test.mjsindex d396a40fa..c2c27713e 100644--- a/tests/e2e/fixtures/image-capabilities/sdk.test.mjs+++ b/tests/e2e/fixtures/image-capabilities/sdk.test.mjs@@ -153,3 +153,72 @@ test('the production ZAI serializer and pinned SDK complete an attachment read a},])})++// The Host appends ` mismatch=true[ declared=<quoted>] detected=<type>` to the+// attached_file line when the declared and detected media types disagree+// (turnContext.ts). The declared value is client-supplied, so it is quoted and+// may carry spaces and escaped quotes.+for (const declaredMediaType of ['text/plain', 'text/plain; charset="utf-8"']) {+ test(`the fixture asks to read a mismatched attachment declared as ${declaredMediaType}`, async () => {+ const before = fixture.getEvidence().attempts.length+ const { OpenAICompatibleProvider } = require('./dist/llm/openaiCompatible.js')+ const { buildTurnContextBlock } = require('./dist/core/orchestration/turnContext.js')+ const provider = new OpenAICompatibleProvider(+ {+ id: 'zai',+ baseURL: 'https://api.z.ai/api/coding/paas/v4',+ defaultModel: 'glm-5.3-flash',+ },+ IMAGE_CAPABILITIES_CREDENTIAL,+ 'glm-5.3-flash'+ )++ const attachmentId = 'att-66666666-7777-4888-9999-000000000000'+ const byteLength = 4321+ const block = buildTurnContextBlock({+ date: new Date('2026-09-29T00:00:00.000Z'),+ channel: { type: 'desktop' },+ attachedFiles: [+ {+ attachmentId,+ name: 'report.txt',+ class: 'pdf',+ byteLength,+ reader: 'pdf',+ mismatch: true,+ declaredMediaType,+ detectedMediaType: 'application/pdf',+ },+ ],+ })+ // The Host really wrote the tail this case is about.+ assert.match(block, / mismatch=true declared="[^\n]*" detected=application\/pdf\n/)+ const tools = [+ {+ name: 'clerum__attachment_read',+ description: 'Read an attached file.',+ parameters: { type: 'object', properties: { attachmentId: { type: 'string' } } },+ },+ ]+ const user = { role: 'user', content: `${block}\n\nSummarize the attached file.` }++ const settled = await provider.completeSingleTurnWithTools([user], tools).then(+ value => ({ value }),+ error => ({ error })+ )++ assert.equal(settled.error?.message, undefined)+ assert.deepEqual(appendedRows(before), [+ {+ model: 'glm-5.3-flash',+ imageSha256: null,+ responseKind: 'document-read-requested',+ documentSha256: null,+ documentByteLength: byteLength,+ },+ ])+ assert.equal(settled.value.finish_reason, 'tool_use')+ assert.equal(settled.value.tool_calls?.length, 1)+ assert.deepEqual(settled.value.tool_calls[0].arguments, { attachmentId })+ })+}diff --git a/tests/e2e/fixtures/package-lock.json b/tests/e2e/fixtures/package-lock.jsonindex be94373d4..fd47cc8f4 100644--- a/tests/e2e/fixtures/package-lock.json+++ b/tests/e2e/fixtures/package-lock.json@@ -1,12 +1,12 @@{"name": "@clerum/e2e-test-fixtures",- "version": "1.0.103",+ "version": "1.0.104","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "@clerum/e2e-test-fixtures",- "version": "1.0.103",+ "version": "1.0.104","dependencies": {"@kubernetes/client-node": "^1.0.0"},diff --git a/tests/e2e/fixtures/package.json b/tests/e2e/fixtures/package.jsonindex 29e5fe879..f3b79da39 100644--- a/tests/e2e/fixtures/package.json+++ b/tests/e2e/fixtures/package.json@@ -1,12 +1,10 @@{"name": "@clerum/e2e-test-fixtures",- "version": "1.0.103",+ "version": "1.0.104","description": "E2E test fixtures and utilities for Clerum testing","type": "module","main": "index.ts","scripts": {- "test": "vitest run",- "test:watch": "vitest","lint": "eslint . --ext .ts","typecheck": "tsc --noEmit"},