The Open Framework for Building Agents
[1/4] test(eve): add attachment rules to the channel conformance suite (#4359)
Ben Pankowd2890c2acf8e
diff --git a/AGENTS.md b/AGENTS.mdindex 2f5a85751..65605afd7 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -56,7 +56,7 @@ pnpm docs:check # docs frontmatter and nav validationpnpm test # unit + integrationpnpm test:unit # unit tests (<3s)-pnpm test:integration # integration tests (<10s)+pnpm test:integration # integration tests (several minutes; leave the full run to CI)pnpm test:scenario # scenario tests (2–5 min; requires pnpm build first)pnpm test:framework-fixtures # apps/frameworks smoke builds (requires pnpm build first)pnpm test:browser # client templates in headless Chromium (needs playwright-core's chromium-headless-shell)@@ -73,6 +73,13 @@ typo fixes, small code reorganizations, and similar non-behavioral changes canproceed without local integration or scenario runs. CI is always the officialline of defense, and every required check must pass before merge.+Do not run a whole integration or scenario tier, or a whole multi-channel+suite such as the channel conformance suite, locally unless the task+expressly needs it (for example, the user asks, or you are chasing a failure+only the full run reproduces). Scope local runs to the files and test names+your change touches with a path and `-t` filter, and leave the full suites to+CI.+## Agent-ready product principles1. **Docs is priority #1.** Agents read your docs before they ever touch yourdiff --git a/packages/eve/src/cli/dev/tui/conformance.integration.test.ts b/packages/eve/src/cli/dev/tui/conformance.integration.test.tsnew file mode 100644index 000000000..853b138c0--- /dev/null+++ b/packages/eve/src/cli/dev/tui/conformance.integration.test.ts@@ -0,0 +1,3 @@+import { describeChannelConformance } from "#internal/testing/channel-conformance/conformance.js";++describeChannelConformance("tui");diff --git a/packages/eve/src/cli/dev/tui/hitl-conformance.integration.test.ts b/packages/eve/src/cli/dev/tui/hitl-conformance.integration.test.tsdeleted file mode 100644index 2851a1e9e..000000000--- a/packages/eve/src/cli/dev/tui/hitl-conformance.integration.test.ts+++ /dev/null@@ -1,3 +0,0 @@-import { describeHitlConformance } from "#internal/testing/channel-conformance/conformance.js";--describeHitlConformance("tui");diff --git a/packages/eve/src/internal/testing/app-harness.ts b/packages/eve/src/internal/testing/app-harness.tsindex 3cc4910cf..0f629eb7c 100644--- a/packages/eve/src/internal/testing/app-harness.ts+++ b/packages/eve/src/internal/testing/app-harness.ts@@ -8,6 +8,7 @@ import type { CompiledModuleMap } from "#compiler/module-map.js";import type { ProgrammaticAgentModule } from "#compiler/source-graph.js";import type { SessionParent, SessionTurn } from "#context/keys.js";import { installBundledCompiledArtifacts } from "#runtime/loaders/bundled-artifacts.js";+import { createSandboxPreparedArtifactsManifest } from "#shared/sandbox-prepared-artifacts.js";import type { SandboxAccess } from "#sandbox/state.js";import {createRuntimeSession,@@ -120,7 +121,7 @@ export interface TestRuntime {input: unknown,): Promise<unknown>;/**- * Clears the compiled-artifact snapshot and bundle cache on this session.+ * Clears the compiled-artifact snapshot, bundle cache, and sessions' sandboxes.* Tests that re-use a runtime across multiple assertions can call this to* return the session to its initial state.*/@@ -139,34 +140,53 @@ const DEFAULT_AGENT_NAME = "test-agent";*/export const TEST_DEFAULT_MODEL_ID = "openai/gpt-5.4";-const TEST_SANDBOX_PROVIDER = defineSandboxProvider({- name: "eve-test-memory",- environment: () => ({- async prepare() {- return null;- },- async resume(context) {- return createHandle(context.session.id);- },- async start(context) {- return { handle: createHandle(context.session.id), state: null };- },- }),-});+const TEST_SANDBOX_PROVIDER_NAME = "eve-test-memory";-function createHandle(sessionId: string) {- const sandbox = mockSandbox({ id: sessionId });- return {- sandbox: sandbox.session,- async onSessionDelete(options?: import("#shared/sandbox-provider.js").SandboxDeleteOptions) {- await sandbox.access.delete?.(options);- },- async onSessionStop() {},- async onRuntimeShutdown() {},- };+/**+ * An in-memory sandbox provider that keeps each session's sandbox, so a step+ * that resumes it sees what earlier steps wrote, as with a real provider. A+ * staged attachment, say, is read back on the next model call.+ */+function createTestSandboxProvider() {+ const sessionSandboxes = new Map<string, MockSandbox>();++ function createHandle(sessionId: string) {+ let sandbox = sessionSandboxes.get(sessionId);+ if (sandbox === undefined) {+ sandbox = mockSandbox({ id: sessionId });+ sessionSandboxes.set(sessionId, sandbox);+ }+ const opened = sandbox;+ return {+ sandbox: opened.session,+ async onSessionDelete(options?: import("#shared/sandbox-provider.js").SandboxDeleteOptions) {+ sessionSandboxes.delete(sessionId);+ await opened.access.delete?.(options);+ },+ async onSessionStop() {},+ async onRuntimeShutdown() {},+ };+ }++ const provider = defineSandboxProvider({+ name: TEST_SANDBOX_PROVIDER_NAME,+ environment: () => ({+ async prepare() {+ return null;+ },+ async resume(context) {+ return createHandle(context.session.id);+ },+ async start(context) {+ return { handle: createHandle(context.session.id), state: null };+ },+ }),+ });+ return { clear: () => sessionSandboxes.clear(), provider };}export async function createTestRuntime(descriptor: TestAppDescriptor = {}): Promise<TestRuntime> {+ const sandboxes = createTestSandboxProvider();const compileInput: CompileFromMemoryInput = {name: descriptor.agent?.name ?? DEFAULT_AGENT_NAME,model: descriptor.agent?.model ?? TEST_DEFAULT_MODEL_ID,@@ -175,7 +195,7 @@ export async function createTestRuntime(descriptor: TestAppDescriptor = {}): Promodules: [{loadNamespace: async () => {- const environment = TEST_SANDBOX_PROVIDER.environment();+ const environment = sandboxes.provider.environment();return { environment, default: defineSandbox(() => environment.open()) };},logicalPath: "sandbox.ts",@@ -205,7 +225,15 @@ export async function createTestRuntime(descriptor: TestAppDescriptor = {}): Proconst tools = descriptor.tools ?? [];function install(): void {- installBundledCompiledArtifacts({ manifest, moduleMap });+ installBundledCompiledArtifacts({+ manifest,+ moduleMap,+ // What `eve build` would record for the root sandbox, so a session that opens it (to+ // stage an attachment, say) finds a provisioned template.+ sandboxPreparedArtifacts: createSandboxPreparedArtifactsManifest([+ { artifact: null, nodeId: "__root__", providerName: TEST_SANDBOX_PROVIDER_NAME },+ ]),+ });}async function run<T>(fn: () => Promise<T> | T): Promise<T> {@@ -236,6 +264,7 @@ export async function createTestRuntime(descriptor: TestAppDescriptor = {}): Prosession.compiledArtifacts = null;session.bundleCache.clear();session.bundleCacheKeyBySourceKey.clear();+ sandboxes.clear();}async function executeTool(diff --git a/packages/eve/src/internal/testing/channel-conformance/MATRIX.md b/packages/eve/src/internal/testing/channel-conformance/MATRIX.mdindex c851ba4c8..257386f61 100644--- a/packages/eve/src/internal/testing/channel-conformance/MATRIX.md+++ b/packages/eve/src/internal/testing/channel-conformance/MATRIX.md@@ -1,4 +1,4 @@-# HITL conformance matrix+# Channel conformance matrix<!-- Generated from conformance.ts by matrix.test.ts. Do not edit by hand. -->@@ -81,6 +81,15 @@ pnpm --filter eve exec vitest run --config vitest.unit.config.ts channel-conform| another person's rejected press leaves the approval's buttons in place | —<sup>[18](#note-18)</sup> | —<sup>[18](#note-18)</sup> | ✅ | | —<sup>[19](#note-19)</sup> | ✅ | | —<sup>[19](#note-19)</sup> | | ✅ | | ✅ | | ✅ | | —<sup>[19](#note-19)</sup> | —<sup>[19](#note-19)</sup> | —<sup>[19](#note-19)</sup> | —<sup>[19](#note-19)</sup> || another person pressing Approve on an open approval runs the tool | —<sup>[18](#note-18)</sup> | —<sup>[18](#note-18)</sup> | ✅ | | —<sup>[19](#note-19)</sup> | ❌<sup>[17](#note-17)</sup> | | —<sup>[19](#note-19)</sup> | | ✅ | | ✅ | | ✅ | | —<sup>[19](#note-19)</sup> | —<sup>[19](#note-19)</sup> | —<sup>[19](#note-19)</sup> | —<sup>[19](#note-19)</sup> |+## Attachments++| Rule | `tui` | `web chat` | `chat-sdk` | `chat-sdk-dm` | `chat-sdk-text` | `discord` | `discord-dm` | `linq` | `linq-dm` | `slack` | `slack-dm` | `teams` | `teams-dm` | `telegram` | `telegram-dm` | `github` | `linear` | `photon` | `twilio` |+| --- | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: |+| an image a person sends reaches the agent with its bytes and type | —<sup>[20](#note-20)</sup> | —<sup>[20](#note-20)</sup> | ❌<sup>[21](#note-21)</sup> | ❌<sup>[21](#note-21)</sup> | ❌<sup>[21](#note-21)</sup> | ❌<sup>[22](#note-22)</sup> | ❌<sup>[22](#note-22)</sup> | ❌<sup>[21](#note-21)</sup> | ❌<sup>[21](#note-21)</sup> | ✅ | ✅ | ❌<sup>[23](#note-23)</sup> | ❌<sup>[23](#note-23)</sup> | ❌<sup>[24](#note-24)</sup> | ❌<sup>[24](#note-24)</sup> | —<sup>[20](#note-20)</sup> | ✅ | ❌<sup>[25](#note-25)</sup> | ❌<sup>[26](#note-26)</sup> |+| a PDF a person sends reaches the agent with its bytes and type | —<sup>[20](#note-20)</sup> | —<sup>[20](#note-20)</sup> | ❌<sup>[21](#note-21)</sup> | | ❌<sup>[21](#note-21)</sup> | ❌<sup>[22](#note-22)</sup> | | ❌<sup>[21](#note-21)</sup> | | ✅ | | ❌<sup>[23](#note-23)</sup> | | ❌<sup>[24](#note-24)</sup> | | —<sup>[20](#note-20)</sup> | ❌<sup>[27](#note-27)</sup> | ❌<sup>[25](#note-25)</sup> | ❌<sup>[26](#note-26)</sup> |+| a file that can't be downloaded reaches the agent as a note, not a link, and the next message still works | —<sup>[20](#note-20)</sup> | —<sup>[20](#note-20)</sup> | ❌<sup>[21](#note-21)</sup> | | ❌<sup>[21](#note-21)</sup> | ❌<sup>[22](#note-22)</sup> | | ❌<sup>[21](#note-21)</sup> | | ✅ | | ❌<sup>[23](#note-23)</sup> | | ✅ | | —<sup>[20](#note-20)</sup> | ❌<sup>[28](#note-28)</sup> | ❌<sup>[25](#note-25)</sup> | ❌<sup>[26](#note-26)</sup> |+| a file sent earlier in the conversation is still there on a later message | —<sup>[20](#note-20)</sup> | —<sup>[20](#note-20)</sup> | ❌<sup>[21](#note-21)</sup> | | ❌<sup>[21](#note-21)</sup> | —<sup>[29](#note-29)</sup> | | ❌<sup>[21](#note-21)</sup> | | ✅ | | ❌<sup>[23](#note-23)</sup> | | ❌<sup>[24](#note-24)</sup> | | —<sup>[20](#note-20)</sup> | ✅ | ❌<sup>[25](#note-25)</sup> | ❌<sup>[26](#note-26)</sup> |+## Notes1. <a id="note-1"></a>the platform has no buttons a person can press@@ -102,3 +111,13 @@ pnpm --filter eve exec vitest run --config vitest.unit.config.ts channel-conform17. <a id="note-17"></a>a button press responds with `auth: null`, so no one can satisfy a response policy18. <a id="note-18"></a>the platform has no second person who can act19. <a id="note-19"></a>the platform has no second person who can act or buttons a person can press+20. <a id="note-20"></a>the platform has no files a person can send+21. <a id="note-21"></a>the bridge passes each attachment's URL to the model provider, whose download fails (#855, #3419)+22. <a id="note-22"></a>eve reads only the slash command's message option, not its attachment options+23. <a id="note-23"></a>Teams drops files unless files.enabled is set and their host is allowlisted+24. <a id="note-24"></a>#1217: Telegram serves files as application/octet-stream, which wins over their known type+25. <a id="note-25"></a>the iMessage adapter lists each attachment's name and type but no way to download it, so eve drops it+26. <a id="note-26"></a>the channel parses MMS media but never passes it to the agent+27. <a id="note-27"></a>eve reads only uploaded images from Linear; other files stay links in the text+28. <a id="note-28"></a>a Linear upload eve can't download stays a link in the text, with no note+29. <a id="note-29"></a>each slash command starts its own session, so no later message shares one with the filediff --git a/packages/eve/src/internal/testing/channel-conformance/chat-sdk-driver.ts b/packages/eve/src/internal/testing/channel-conformance/chat-sdk-driver.tsindex 999b9b561..fdc147cc9 100644--- a/packages/eve/src/internal/testing/channel-conformance/chat-sdk-driver.ts+++ b/packages/eve/src/internal/testing/channel-conformance/chat-sdk-driver.ts@@ -1,4 +1,5 @@-import { chatSdkChannel } from "#public/channels/chat-sdk/index.js";+// Sends attachments with the text, as Linq and Photon do.+import { chatSdkChannel, messageToUserContent } from "#public/channels/chat-sdk/index.js";import {type Adapter,type AdapterPostableMessage,@@ -19,6 +20,7 @@ import {type Surface,numberedOptions,linkTargets,+ type SentFile,} from "#internal/testing/channel-conformance/harness.js";const ADAPTER = "conformance";@@ -44,7 +46,12 @@ interface CardNode {}type Inbound =- | { readonly kind: "message"; readonly text: string }+ | {+ readonly kind: "message";+ readonly text: string;+ /** Files on the message, as the adapter lists them: a URL to each, not its bytes. */+ readonly files?: readonly Pick<SentFile, "mediaType" | "name">[];+ }| {readonly kind: "action";readonly actionId: string;@@ -89,8 +96,8 @@ export function chatSdkDriver(surface: Exclude<Surface, "public"> = "shared"): C...driver,capabilities:surface === "private"- ? ["buttons", "text-replies"]- : ["another-person", "buttons", "text-replies"],+ ? ["attachments", "buttons", "text-replies"]+ : ["attachments", "another-person", "buttons", "text-replies"],surface,findOptions(call, prompt) {if (!isPost(call)) return undefined;@@ -136,7 +143,7 @@ export function chatSdkTextDriver(): ChannelDriver {});return {...driver,- capabilities: ["text-replies"],+ capabilities: ["attachments", "text-replies"],surface: "private",findOptions(call, prompt) {if (!isPost(call) || typeof call.body !== "string" || !call.body.includes(prompt)) {@@ -196,7 +203,7 @@ function chatSdkDriverWith(input: {});if (dm) {bridge.bot.onDirectMessage(async (thread, message) => {- await bridge.send(message.text, {+ await bridge.send(messageToUserContent(message), {auth: userAuth(message.author.userId),context: [],thread,@@ -207,14 +214,14 @@ function chatSdkDriverWith(input: {// subscribing lets the rest of the thread continue it without one.bridge.bot.onNewMention(async (thread, message) => {await thread.subscribe();- await bridge.send(message.text, {+ await bridge.send(messageToUserContent(message), {auth: userAuth(message.author.userId),context: [],thread,});});bridge.bot.onSubscribedMessage(async (thread, message) => {- await bridge.send(message.text, {+ await bridge.send(messageToUserContent(message), {auth: userAuth(message.author.userId),context: [],thread,@@ -223,7 +230,12 @@ function chatSdkDriverWith(input: {}return bridge.channel;},- message: (text) => inbound({ kind: "message", text }),+ message: (text, files = []) =>+ inbound({+ files: files.map(({ mediaType, name }) => ({ mediaType, name })),+ kind: "message",+ text,+ }),postedText(call: PlatformCall) {if (!isPost(call)) return undefined;const posted = call.body as AdapterPostableMessage;@@ -275,7 +287,7 @@ function fakeAdapter(adapter,threadId,// A person mentions the bot to start a channel thread; Chat routes the rest by subscription.- inboundMessage(threadId, id, body.text, !dm),+ inboundMessage(threadId, id, body.text, !dm, body.files),options,);}@@ -315,9 +327,22 @@ function fakeAdapter(return adapter;}-function inboundMessage(threadId: string, id: string, text: string, isMention = false): Message {+function inboundMessage(+ threadId: string,+ id: string,+ text: string,+ isMention = false,+ files: readonly Pick<SentFile, "mediaType" | "name">[] = [],+): Message {return new Message({- attachments: [],+ attachments: files.map((file) => ({+ mimeType: file.mediaType,+ name: file.name,+ type: file.mediaType.startsWith("image/") ? ("image" as const) : ("file" as const),+ // The AI SDK refuses IP-literal URLs before connecting, so the provider's download+ // fails as it would for a private platform URL, and nothing leaves the machine.+ url: `http://127.0.0.1:9/files/${encodeURIComponent(file.name)}`,+ })),author: PERSON,formatted: parseMarkdown(text),id,diff --git a/packages/eve/src/internal/testing/channel-conformance/conformance.ts b/packages/eve/src/internal/testing/channel-conformance/conformance.tsindex 310637966..cbdd8c2d7 100644--- a/packages/eve/src/internal/testing/channel-conformance/conformance.ts+++ b/packages/eve/src/internal/testing/channel-conformance/conformance.ts@@ -2,9 +2,9 @@ import { describe, expect, it } from "vitest";import {type ContractRule,- type HitlRule,- hitlContract,- hitlContractSections,+ type ContractRuleName,+ channelContract,+ channelContractSections,} from "#internal/testing/channel-conformance/contract.js";import {type ChannelCapability,@@ -52,7 +52,10 @@ const answeredPromptRules = {cleared: "answering a question by text clears its buttons",named: "answering a question by text names who answered on the question",},-} as const satisfies Record<string, { readonly cleared: HitlRule; readonly named: HitlRule }>;+} as const satisfies Record<+ string,+ { readonly cleared: ContractRuleName; readonly named: ContractRuleName }+>;type AnsweredPrompt = keyof typeof answeredPromptRules;@@ -60,7 +63,7 @@ type AnsweredPrompt = keyof typeof answeredPromptRules;function staleAnsweredPrompts(reason: string,groups: readonly AnsweredPrompt[],-): Partial<Record<HitlRule, BrokenCell>> {+): Partial<Record<ContractRuleName, BrokenCell>> {return Object.fromEntries(groups.flatMap((group) => Object.values(answeredPromptRules[group]))@@ -78,7 +81,7 @@ function staleAnsweredPrompts(function unnamedAnsweredPrompts(reason: string,groups: readonly AnsweredPrompt[],-): Partial<Record<HitlRule, BrokenCell>> {+): Partial<Record<ContractRuleName, BrokenCell>> {return Object.fromEntries(groups.map((group) => [answeredPromptRules[group].named,@@ -90,8 +93,8 @@ function unnamedAnsweredPrompts(/** Presses reach a response policy without the presser's identity, so eve refuses them all. */function anonymousPresses(reason: string,- rules: readonly HitlRule[],-): Partial<Record<HitlRule, BrokenCell>> {+ rules: readonly ContractRuleName[],+): Partial<Record<ContractRuleName, BrokenCell>> {return Object.fromEntries(rules.map((rule) => [rule,@@ -107,15 +110,58 @@ interface ConformanceChannel {* whose behavior varies by conversation; the shared column covers the rest.*/readonly dm?: true;- readonly broken?: Partial<Record<HitlRule, BrokenCell>>;+ readonly broken?: Partial<Record<ContractRuleName, BrokenCell>>;/** Rules this client deliberately doesn't offer, with why, beyond what its capabilities rule out. */- readonly unsupported?: Partial<Record<HitlRule, string>>;+ readonly unsupported?: Partial<Record<ContractRuleName, string>>;}+const IMAGE_REACHES_AGENT = "an image a person sends reaches the agent with its bytes and type";+const PDF_REACHES_AGENT = "a PDF a person sends reaches the agent with its bytes and type";+const UNDOWNLOADABLE_FILE =+ "a file that can't be downloaded reaches the agent as a note, not a link, and the next message still works";+const EARLIER_FILE = "a file sent earlier in the conversation is still there on a later message";++/** The agent sees none of the files a person sent. */+function filesNotSeen(+ reason: string,+ ...rules: ContractRuleName[]+): Partial<Record<ContractRuleName, BrokenCell>> {+ return Object.fromEntries(+ rules.map((rule) => [rule, { reason, symptom: /the agent saw \[\]/u }]),+ );+}++/**+ * The Chat SDK bridge hands the model provider each attachment's URL, which it+ * then fails to download. `symptom` is how the failed turn shows on the channel.+ */+function attachmentUrlPassedThrough(+ symptom: RegExp,+): Partial<Record<ContractRuleName, BrokenCell>> {+ return Object.fromEntries(+ [IMAGE_REACHES_AGENT, PDF_REACHES_AGENT, UNDOWNLOADABLE_FILE, EARLIER_FILE].map((rule) => [+ rule,+ {+ reason:+ "the bridge passes each attachment's URL to the model provider, whose download fails (#855, #3419)",+ symptom,+ },+ ]),+ );+}++const ATTACHMENT_URL_PASSED_THROUGH = attachmentUrlPassedThrough(/AI_DownloadError/u);+// Linq posts nothing for a failed turn, so the reply never comes.+const LINQ_ATTACHMENT_URL_PASSED_THROUGH = attachmentUrlPassedThrough(+ /Timed out waiting for (?:the bot to show|a reply to "Alice attached)/u,+);+const SIGN_IN_NOT_SHOWN = /Timed out waiting for the bot to show/u;/** The channel has no default `authorization.required` renderer, so a sign-in shows nothing. */-function noSignInRenderer(...rules: HitlRule[]): Partial<Record<HitlRule, BrokenCell>> {+function noSignInRenderer(+ ...rules: ContractRuleName[]+): Partial<Record<ContractRuleName, BrokenCell>> {return Object.fromEntries(rules.map((rule) => [rule,@@ -137,12 +183,13 @@ const SIGN_IN_ONLY_IN_DMS = Object.fromEntries(symptom: SIGN_IN_NOT_SHOWN,},]),-) satisfies Partial<Record<HitlRule, BrokenCell>>;+) satisfies Partial<Record<ContractRuleName, BrokenCell>>;const UNNAMED_RESPONDER ="a resolved prompt doesn't say who answered; input.resolved carries no responder";const CHAT_SDK_BROKEN = {+ ...ATTACHMENT_URL_PASSED_THROUGH,...unnamedAnsweredPrompts(UNNAMED_RESPONDER, ["approvalPress","approvalText",@@ -168,8 +215,19 @@ const DISCORD_BROKEN = {"a sign-in without a link shows its instructions","completing a sign-in tells the person it succeeded",),+ ...filesNotSeen(+ "eve reads only the slash command's message option, not its attachment options",+ IMAGE_REACHES_AGENT,+ PDF_REACHES_AGENT,+ UNDOWNLOADABLE_FILE,+ ),};+const DISCORD_UNSUPPORTED = {+ "a file sent earlier in the conversation is still there on a later message":+ "each slash command starts its own session, so no later message shares one with the file",+} satisfies Partial<Record<ContractRuleName, string>>;+const SLACK_BROKEN = {...staleAnsweredPrompts("only the button interaction handler edits a question; a typed answer leaves it",@@ -179,11 +237,18 @@ const SLACK_BROKEN = {reason: "the card loses its buttons after a typed approval but doesn't say who approved",symptom: /the answered prompt never names who answered/,},-} satisfies Partial<Record<HitlRule, BrokenCell>>;+} satisfies Partial<Record<ContractRuleName, BrokenCell>>;const TEAMS_BROKEN = {...unnamedAnsweredPrompts(UNNAMED_RESPONDER, ["approvalText", "questionPress", "questionText"]),-} satisfies Partial<Record<HitlRule, BrokenCell>>;+ ...filesNotSeen(+ "Teams drops files unless files.enabled is set and their host is allowlisted",+ IMAGE_REACHES_AGENT,+ PDF_REACHES_AGENT,+ UNDOWNLOADABLE_FILE,+ EARLIER_FILE,+ ),+} satisfies Partial<Record<ContractRuleName, BrokenCell>>;/** The sign-in prompt, link included, goes to the whole thread. */const SIGN_IN_LINK_POSTED_TO_THREAD = {@@ -191,9 +256,15 @@ const SIGN_IN_LINK_POSTED_TO_THREAD = {reason: "the sign-in prompt, link included, is posted to the whole thread",symptom: /a message everyone sees carried the sign-in (link|code)/u,},-} satisfies Partial<Record<HitlRule, BrokenCell>>;+} satisfies Partial<Record<ContractRuleName, BrokenCell>>;const TELEGRAM_BROKEN = {+ ...filesNotSeen(+ "#1217: Telegram serves files as application/octet-stream, which wins over their known type",+ IMAGE_REACHES_AGENT,+ PDF_REACHES_AGENT,+ EARLIER_FILE,+ ),...unnamedAnsweredPrompts(UNNAMED_RESPONDER, ["approvalPress","approvalText",@@ -209,8 +280,8 @@ const WEB_CHAT_SINGLE_PERSON ="one person answers in their own browser tab; there's nobody else to tell";/**- * Every first-party channel's and client's place in the HITL contract, keyed by- * the directory whose `hitl-conformance.integration.test.ts` runs it (`web-chat`+ * Every first-party channel's and client's place in the channel contract, keyed by+ * the directory whose `conformance.integration.test.ts` runs it (`web-chat`* runs from `test/browser`, since it needs a browser). Each cell is one of:** - must pass;@@ -220,14 +291,24 @@ const WEB_CHAT_SINGLE_PERSON =* the rule fails with the recorded `symptom`, so a fix or an unrelated* failure (such as harness breakage) both turn it red.*/-const hitlConformance = {+const channelConformance = {"chat-sdk": [{ driver: chatSdkDriver, broken: { ...CHAT_SDK_BROKEN, ...SIGN_IN_ONLY_IN_DMS } },- { driver: chatSdkTextDriver },+ {+ driver: chatSdkTextDriver,+ broken: { ...ATTACHMENT_URL_PASSED_THROUGH },+ },],"chat-sdk-dm": [{ dm: true, driver: () => chatSdkDriver("private"), broken: CHAT_SDK_BROKEN }],- discord: [{ driver: discordDriver, broken: DISCORD_BROKEN }],- "discord-dm": [{ dm: true, driver: () => discordDriver("private"), broken: DISCORD_BROKEN }],+ discord: [{ driver: discordDriver, broken: DISCORD_BROKEN, unsupported: DISCORD_UNSUPPORTED }],+ "discord-dm": [+ {+ dm: true,+ driver: () => discordDriver("private"),+ broken: DISCORD_BROKEN,+ unsupported: DISCORD_UNSUPPORTED,+ },+ ],github: [{driver: githubDriver,@@ -244,6 +325,14 @@ const hitlConformance = {{driver: linearDriver,broken: {+ ...filesNotSeen(+ "eve reads only uploaded images from Linear; other files stay links in the text",+ PDF_REACHES_AGENT,+ ),+ ...filesNotSeen(+ "a Linear upload eve can't download stays a link in the text, with no note",+ UNDOWNLOADABLE_FILE,+ ),"only the person signing in sees the sign-in link and code": {reason:"the code is in the elicitation body the whole issue sees; who sees the auth signal's link is unverified",@@ -252,9 +341,34 @@ const hitlConformance = {},},],- linq: [{ driver: linqDriver, broken: SIGN_IN_ONLY_IN_DMS }],- "linq-dm": [{ dm: true, driver: () => linqDriver("private") }],- photon: [{ driver: photonDriver }],+ linq: [+ {+ driver: linqDriver,+ broken: {+ ...SIGN_IN_ONLY_IN_DMS,+ ...LINQ_ATTACHMENT_URL_PASSED_THROUGH,+ },+ },+ ],+ "linq-dm": [+ {+ dm: true,+ driver: () => linqDriver("private"),+ broken: { ...LINQ_ATTACHMENT_URL_PASSED_THROUGH },+ },+ ],+ photon: [+ {+ driver: photonDriver,+ broken: filesNotSeen(+ "the iMessage adapter lists each attachment's name and type but no way to download it, so eve drops it",+ IMAGE_REACHES_AGENT,+ PDF_REACHES_AGENT,+ UNDOWNLOADABLE_FILE,+ EARLIER_FILE,+ ),+ },+ ],slack: [{ driver: slackDriver, broken: SLACK_BROKEN }],"slack-dm": [{ dm: true, driver: () => slackDriver("private"), broken: SLACK_BROKEN }],teams: [{ driver: teamsDriver, broken: { ...TEAMS_BROKEN, ...SIGN_IN_LINK_POSTED_TO_THREAD } }],@@ -280,6 +394,15 @@ const hitlConformance = {twilio: [{driver: twilioDriver,+ broken: {+ ...filesNotSeen(+ "the channel parses MMS media but never passes it to the agent",+ IMAGE_REACHES_AGENT,+ PDF_REACHES_AGENT,+ UNDOWNLOADABLE_FILE,+ EARLIER_FILE,+ ),+ },},],"web-chat": [@@ -310,16 +433,17 @@ type Cell =| { readonly kind: "broken"; readonly broken: BrokenCell };const CAPABILITY_NAMES: Record<ChannelCapability, string> = {+ attachments: "files a person can send","another-person": "second person who can act",buttons: "buttons a person can press","text-replies": "plain-text replies",};-function variesByConversation(rule: (typeof hitlContract)[number]): boolean {+function variesByConversation(rule: (typeof channelContract)[number]): boolean {return (rule as ContractRule).variesByConversation === true;}-function cellOf(entry: ConformanceChannel, rule: (typeof hitlContract)[number]): Cell {+function cellOf(entry: ConformanceChannel, rule: (typeof channelContract)[number]): Cell {if (entry.dm === true && !variesByConversation(rule)) {return {kind: "unsupported",@@ -347,16 +471,16 @@ function cellOf(entry: ConformanceChannel, rule: (typeof hitlContract)[number]):}/**- * Declares the HITL contract cells for one channel directory. Each channel gets+ * Declares the channel contract cells for one channel directory. Each channel gets* its own test file because conversations can't overlap within a process, and* separate files let vitest run channels in parallel workers.*/-export function describeHitlConformance(channel: keyof typeof hitlConformance): void {- const entries: readonly ConformanceChannel[] = hitlConformance[channel];+export function describeChannelConformance(channel: keyof typeof channelConformance): void {+ const entries: readonly ConformanceChannel[] = channelConformance[channel];describe.each(entries.map((entry) => ({ entry, name: entry.driver().name })))(- "$name HITL contract",+ "$name channel contract",({ entry }) => {- for (const rule of hitlContract) {+ for (const rule of channelContract) {const cell = cellOf(entry, rule);const { agent } = rule as ContractRule;const run = (options?: { readonly waitTimeoutMs: number }) =>@@ -387,8 +511,8 @@ const MATRIX_SYMBOLS = { broken: "❌", pass: "✅", unsupported: "—" } as con* suite holds each cell to what this table says, so the rendered matrix is* current whenever the suite passes.*/-export function renderHitlConformanceMatrix(): string {- const all = Object.values(hitlConformance).flatMap(+export function renderConformanceMatrix(): string {+ const all = Object.values(channelConformance).flatMap((group): readonly ConformanceChannel[] => group,);const nameOf = (entry: ConformanceChannel) => entry.driver().name;@@ -412,7 +536,7 @@ export function renderHitlConformanceMatrix(): string {// sharing a cause links to the same note. Plain anchors rather than Markdown// footnotes, which GitHub renders with links back up to every citing cell.const notes = new Map<string, number>();- const shown = (entry: ConformanceChannel, rule: (typeof hitlContract)[number]) => {+ const shown = (entry: ConformanceChannel, rule: (typeof channelContract)[number]) => {// A DM column leaves blank what only the shared-thread column runs.if (entry.dm === true && !variesByConversation(rule)) return "";const cell = cellOf(entry, rule);@@ -423,7 +547,7 @@ export function renderHitlConformanceMatrix(): string {return `${MATRIX_SYMBOLS[cell.kind]}<sup>[${index}](#note-${index})</sup>`;};// One table per section, each repeating the column header so it reads on its own.- const tables = hitlContractSections.flatMap((section) => [+ const tables = channelContractSections.flatMap((section) => [`## ${section.title}`,"",row(["Rule", ...entries.map((entry) => `\`${nameOf(entry)}\``)]),@@ -438,7 +562,7 @@ export function renderHitlConformanceMatrix(): string {"",]);return [- "# HITL conformance matrix",+ "# Channel conformance matrix","","<!-- Generated from conformance.ts by matrix.test.ts. Do not edit by hand. -->","",diff --git a/packages/eve/src/internal/testing/channel-conformance/contract.ts b/packages/eve/src/internal/testing/channel-conformance/contract.tsindex 1207736d4..ed1010d05 100644--- a/packages/eve/src/internal/testing/channel-conformance/contract.ts+++ b/packages/eve/src/internal/testing/channel-conformance/contract.ts@@ -1,3 +1,5 @@+import { createHash } from "node:crypto";+import { expect } from "vitest";import {@@ -10,6 +12,7 @@ import {PLAIN_TOOL,type RenderedOption,REQUESTER_GATED_TOOL,+ type SentFile,type Surface,SECOND_GATED_TOOL,SIGN_IN_TOOLS,@@ -217,6 +220,74 @@ async function expectResponderNamed(conversation: ChannelConversation, prompt: s* A one-token input budget lets the model call that crosses it finish, so a* turn that calls a tool is held before the model reads the tool's result.*/+// Neither matches an option, a tool, or a number, so it steers the turn.+const FOLLOW_UP = "Alice asks what is still left to do.";++// The smallest valid JPEG (1x1) and PDF, so a channel's media checks accept them.+const DIAGRAM: SentFile = {+ bytes: Buffer.from(+ "/9j/4AAQSkZJRgABAQEASABIAAD/2wBDAAMCAgICAgMCAgIDAwMDBAYEBAQEBAgGBgUGCQgKCgkICQkKDA8MCgsOCwkJDRENDg8QEBEQCgwSExIQEw8QEBD/yQALCAABAAEBAREA/8wABgAQEAX/2gAIAQEAAD8A0s8g/9k=",+ "base64",+ ),+ mediaType: "image/jpeg",+ name: "diagram.jpg",+};+const REPORT: SentFile = {+ bytes: Buffer.from(+ "%PDF-1.4\n1 0 obj<</Type/Catalog/Pages 2 0 R>>endobj\n2 0 obj<</Type/Pages/Kids[]/Count 0>>endobj\ntrailer<</Root 1 0 R>>\n%%EOF\n",+ ),+ mediaType: "application/pdf",+ name: "report.pdf",+};+const LIST_ATTACHMENTS = "Alice asks to list the attachments.";+// The test model's answer to LIST_ATTACHMENTS: every file part it was given, as JSON.+const ATTACHMENTS_REPLY = /Attachments: (\[.*?\])(?:\s|$)/su;++/**+ * One file the test model saw, as it lists them: bytes and type, a link it was+ * left to fetch, or eve's note for a file it couldn't pass on.+ */+interface SeenFile {+ readonly bytes?: number;+ readonly mediaType?: string;+ readonly note?: string;+ readonly sha256?: string;+ readonly url?: string;+}++/**+ * Asks the agent which files it can see, sending `files` with the question, and+ * reads its answer from the channel's reply. Sending a file with the question+ * keeps the check to one message, which a channel that starts a session per+ * message, such as Discord's slash commands, can still answer.+ */+async function attachmentsSeen(+ conversation: ChannelConversation,+ files?: readonly SentFile[],+): Promise<readonly SeenFile[]> {+ await conversation.say(LIST_ATTACHMENTS, files);+ const shown = await conversation.waitForShown(ATTACHMENTS_REPLY);+ return JSON.parse(ATTACHMENTS_REPLY.exec(shown)![1]!) as SeenFile[];+}++/** What the agent should see for `file`: its exact bytes, with its type. */+function asSeen(file: SentFile): SeenFile {+ return {+ bytes: file.bytes.length,+ mediaType: file.mediaType,+ sha256: createHash("sha256").update(file.bytes).digest("hex").slice(0, 16),+ };+}++/** Sends `file` with a message, then checks the agent sees exactly it. */+async function expectFileReachesAgent(conversation: ChannelConversation, file: SentFile) {+ const seen = await attachmentsSeen(conversation, [file]);+ expect(+ seen.map(({ bytes, mediaType, sha256, url }) => ({ bytes, mediaType, sha256, url })),+ `the agent saw ${JSON.stringify(seen)}`,+ ).toEqual([{ ...asSeen(file), url: undefined }]);+}+const ONE_TOKEN_BUDGET = { limits: { maxInputTokensPerSession: 1 } } as const;const BUDGET_PROMPT ="This session has hit the input-token limit (1) per session. This is a guardrail against " +@@ -830,19 +901,72 @@ const signInRules = [},] as const satisfies readonly ContractRule[];-/** The contract's rules, grouped by the kind of prompt they cover. */-export const hitlContractSections = [+const attachmentRules = [+ {+ rule: "an image a person sends reaches the agent with its bytes and type",+ source: "docs/channels/overview.mdx",+ requires: ["attachments"],+ variesByConversation: true,+ async run(conversation) {+ await expectFileReachesAgent(conversation, DIAGRAM);+ },+ },+ {+ rule: "a PDF a person sends reaches the agent with its bytes and type",+ source: "docs/channels/overview.mdx",+ requires: ["attachments"],+ async run(conversation) {+ await expectFileReachesAgent(conversation, REPORT);+ },+ },+ {+ rule: "a file that can't be downloaded reaches the agent as a note, not a link, and the next message still works",+ source: "#855, #3419",+ requires: ["attachments"],+ async run(conversation) {+ // A link left for the model provider fails again on every later turn (#3419),+ // and with nothing at all the agent can't tell the person their file didn't arrive.+ const seen = await attachmentsSeen(conversation, [{ ...DIAGRAM, downloadable: false }]);+ expect(seen, `the agent saw ${JSON.stringify(seen)}`).toEqual([+ { note: expect.stringMatching(/^Attachment\b/u) },+ ]);+ await conversation.say(FOLLOW_UP);+ await conversation.waitForReplyTo(FOLLOW_UP);+ },+ },+ {+ rule: "a file sent earlier in the conversation is still there on a later message",+ source: "docs/channels/overview.mdx",+ requires: ["attachments"],+ async run(conversation) {+ const text = `Alice attached ${DIAGRAM.name}.`;+ await conversation.say(text, [DIAGRAM]);+ await conversation.waitForReplyTo(text);+ await conversation.say(FOLLOW_UP);+ await conversation.waitForReplyTo(FOLLOW_UP);+ const seen = await attachmentsSeen(conversation);+ expect(+ seen.map(({ bytes, mediaType, sha256 }) => ({ bytes, mediaType, sha256 })),+ `two messages later the agent saw ${JSON.stringify(seen)}`,+ ).toEqual([asSeen(DIAGRAM)]);+ },+ },+] as const satisfies readonly ContractRule[];++/** The contract's rules, grouped by the kind of behavior they cover. */+export const channelContractSections = [{ title: "Questions", rules: questionRules },{ title: "Tool approvals", rules: approvalRules },{ title: "Answered prompts", rules: answeredPromptRules },{ title: "Budget prompts", rules: budgetRules },{ title: "Sign-ins", rules: signInRules },+ { title: "Attachments", rules: attachmentRules },] as const;-export const hitlContract = hitlContractSections.flatMap(- (section): readonly HitlContractRule[] => section.rules,-);+type ChannelContractRule = (typeof channelContractSections)[number]["rules"][number];-type HitlContractRule = (typeof hitlContractSections)[number]["rules"][number];+export const channelContract = channelContractSections.flatMap(+ (section): readonly ChannelContractRule[] => section.rules,+);-export type HitlRule = HitlContractRule["rule"];+export type ContractRuleName = ChannelContractRule["rule"];diff --git a/packages/eve/src/internal/testing/channel-conformance/discord-driver.ts b/packages/eve/src/internal/testing/channel-conformance/discord-driver.tsindex 233502701..9d600a403 100644--- a/packages/eve/src/internal/testing/channel-conformance/discord-driver.ts+++ b/packages/eve/src/internal/testing/channel-conformance/discord-driver.ts@@ -9,6 +9,8 @@ import {type Surface,recordingFetch,linkTargets,+ type SentFile,+ serveFile,} from "#internal/testing/channel-conformance/harness.js";let nextChannel = 0;@@ -55,6 +57,8 @@ export function discordDriver(surface: Exclude<Surface, "public"> = "shared"): Cconst { privateKey, publicKeyHex } = testKeys();let interactionId = 0;let messageId = 0;+ /** Files a person attached, by the signed CDN URL Discord lists each under. */+ const uploads = new Map<string, SentFile>();/** The message each interaction token's `@original` response is, once known. */const originals = new Map<string, string>();@@ -73,9 +77,17 @@ export function discordDriver(surface: Exclude<Surface, "public"> = "shared"): C}async function decode(request: Request): Promise<PlatformCall> {+ const url = new URL(request.url);+ if (url.hostname === "cdn.discordapp.com") {+ return {+ body: {},+ method: `GET ${url.pathname}`,+ response: serveFile(uploads.get(url.href)),+ };+ }const text = await request.text();const body = text === "" ? {} : JSON.parse(text);- const path = new URL(request.url).pathname;+ const path = url.pathname;if (path.endsWith("/typing")) {return { body, method: `POST ${path}`, response: {} };}@@ -114,21 +126,55 @@ export function discordDriver(surface: Exclude<Surface, "public"> = "shared"): Creturn {name: dm ? "discord-dm" : "discord",- capabilities: dm ? ["buttons"] : ["another-person", "buttons"],+ capabilities: dm ? ["attachments", "buttons"] : ["attachments", "another-person", "buttons"],surface,createChannel: (record) =>discordChannel({api: { fetch: recordingFetch(record, decode) },credentials: { applicationId: "APP1", botToken: "bot-token", publicKey: publicKeyHex },}),- message: (text) => {+ message: (text, files = []) => {const id = nextInteraction();+ // Each file rides an attachment option (type 11) whose value names it in `resolved`.+ const attached = files.map((file, index) => {+ const attachmentId = `A_${id}_${index}`;+ const url = `https://cdn.discordapp.com/attachments/${channelId}/${attachmentId}/${file.name}?ex=signed`;+ uploads.set(url, file);+ return {+ attachmentId,+ option: {+ name: index === 0 ? "file" : `file${index + 1}`,+ type: 11,+ value: attachmentId,+ },+ resolved: {+ content_type: file.mediaType,+ filename: file.name,+ id: attachmentId,+ size: file.bytes.length,+ url,+ },+ };+ });return signed(JSON.stringify({...where(),application_id: "APP1",channel_id: channelId,- data: { name: "ask", options: [{ name: "message", type: 3, value: text }] },+ data: {+ name: "ask",+ options: [+ { name: "message", type: 3, value: text },+ ...attached.map(({ option }) => option),+ ],+ ...(attached.length > 0 && {+ resolved: {+ attachments: Object.fromEntries(+ attached.map(({ attachmentId, resolved }) => [attachmentId, resolved]),+ ),+ },+ }),+ },id,token: `tok-${id}`,type: 2,diff --git a/packages/eve/src/internal/testing/channel-conformance/harness.ts b/packages/eve/src/internal/testing/channel-conformance/harness.tsindex d761a77c9..55b1a0f2f 100644--- a/packages/eve/src/internal/testing/channel-conformance/harness.ts+++ b/packages/eve/src/internal/testing/channel-conformance/harness.ts@@ -91,6 +91,8 @@ export function linkTargets(value: unknown): string[] {* capability a driver lacks is skipped for that channel as "not supported".*/export type ChannelCapability =+ /** A person can send a file, such as an image or a PDF, with a message. */+ | "attachments"/** Someone besides the person who started the conversation can act in it. */| "another-person"/** A person can press a rendered choice. */@@ -112,7 +114,7 @@ export type Surface =| "private";/**- * Teaches the HITL conformance suite to speak one channel's platform protocol.+ * Teaches the channel conformance suite to speak one channel's platform protocol.** Drivers translate only between platform wire formats and conversation* actions. They never read session state, so they keep working across changes@@ -130,7 +132,7 @@ export interface ChannelDriver {/** Undoes anything `createChannel` installed outside the channel, such as a global `fetch`. */dispose?(): void;/** A webhook request carrying a person's message. */- message(text: string): Request;+ message(text: string, files?: readonly SentFile[]): Request;/*** The options a person can see in one outbound call that posts the question:* `undefined` when the call isn't the question, `[]` when it shows no options.@@ -162,10 +164,23 @@ export interface ChannelDriver {*/export type Person = "alice" | "bob";+/**+ * A file a person sends, as the platform holds it. A driver serves its bytes+ * from the fake platform the way the real one would, including its download+ * headers, so the channel's real download code runs.+ */+export interface SentFile {+ readonly name: string;+ readonly mediaType: string;+ readonly bytes: Uint8Array;+ /** When false, the platform refuses the download, as it would for a missing scope or a remote file. */+ readonly downloadable?: boolean;+}+/** What a person can do and see in one channel conversation. Contract rules use only this. */export interface ChannelConversation {- /** The person sends a plain-text message. */- say(text: string): Promise<void>;+ /** The person sends a plain-text message, with `files` attached if given. */+ say(text: string, files?: readonly SentFile[]): Promise<void>;/** Waits for the bot to post `prompt` with choices, returning them. */waitForQuestion(prompt: string): Promise<readonly RenderedOption[]>;/**@@ -239,8 +254,8 @@ export interface ClientDriver {/** A running client, as a person sees and uses it. */export interface ClientView {- /** The person sends a plain-text message. */- say(text: string): Promise<void>;+ /** The person sends a plain-text message, with `files` attached if given. */+ say(text: string, files?: readonly SentFile[]): Promise<void>;/*** Waits for the client to show one of `prompts`, returning which one and its* choices. A client may show several pending requests one at a time.@@ -360,6 +375,20 @@ export type ToolOutcome =| { readonly kind: "ran"; readonly output: unknown }| { readonly kind: "denied" };+/**+ * The platform's answer to a download of `file`: its bytes under+ * `contentType` (the platform's header, which can differ from the file's own+ * type), or a refusal when the file isn't downloadable.+ */+export function serveFile(file: SentFile | undefined, contentType = file?.mediaType): Response {+ if (file === undefined || file.downloadable === false) {+ return new Response("Forbidden", { status: 403 });+ }+ return new Response(new Uint8Array(file.bytes), {+ headers: { "content-type": contentType ?? "application/octet-stream" },+ });+}+/** A `fetch` for an HTTP platform API: `decode` turns each request into a call and its answer. */export function recordingFetch(record: (call: PlatformCall) => void,@@ -368,7 +397,8 @@ export function recordingFetch(return async (input, init) => {const call = await decode(new Request(input, init));record(call);- return Response.json(call.response);+ // A file download answers with bytes, not JSON.+ return call.response instanceof Response ? call.response : Response.json(call.response);};}@@ -446,7 +476,7 @@ function webhookView(const promptsFrom = new Map<string, number>();return {- say: (text) => post(driver.message(text)),+ say: (text, files) => post(driver.message(text, files)),press: (option, person) => post(driver.press(option, person)),waitForQuestion: (prompts) =>wait(@@ -585,7 +615,7 @@ async function converse(}const runtime = await createTestRuntime({- agent: { limits: options.limits, name: `${label}-hitl-conformance` },+ agent: { limits: options.limits, name: `${label}-conformance` },modules: [{logicalPath: `tools/${PLAIN_TOOL}.ts`,@@ -745,9 +775,9 @@ async function converse(let signInsCompleted = 0;const conversation: ChannelConversation = {- async say(text) {+ async say(text, files) {await waitForStepsToFinish([...sessions.values()], wait);- await view.say(text);+ await view.say(text, files);},press: (option, person = "alice") => view.press(option, person),async waitForQuestion(prompt) {@@ -1077,7 +1107,7 @@ function matchPath(pattern: string, pathname: string): Record<string, string> |function unsupported(name: string): () => never {return () => {- throw new Error(`The HITL conformance harness does not provide ctx.${name}.`);+ throw new Error(`The channel conformance harness does not provide ctx.${name}.`);};}diff --git a/packages/eve/src/internal/testing/channel-conformance/linear-driver.ts b/packages/eve/src/internal/testing/channel-conformance/linear-driver.tsindex dff6b580e..84ae2963a 100644--- a/packages/eve/src/internal/testing/channel-conformance/linear-driver.ts+++ b/packages/eve/src/internal/testing/channel-conformance/linear-driver.ts@@ -4,6 +4,8 @@ import {type RenderedOption,recordingFetch,linkTargets,+ type SentFile,+ serveFile,} from "#internal/testing/channel-conformance/harness.js";import { linearChannel } from "#public/channels/linear/index.js";import { signLinearWebhookBody } from "#public/channels/linear/verify.js";@@ -41,7 +43,26 @@ export function linearDriver(): ChannelDriver {});}+ /** Files a person uploaded, by the `uploads.linear.app` URL their Markdown links to. */+ const uploads = new Map<string, SentFile>();+ /** A person's words with each file inlined as Linear writes an upload: an image or a link. */+ function withUploads(text: string, files: readonly SentFile[]): string {+ const links = files.map((file) => {+ const url = `https://uploads.linear.app/conformance/${uploads.size + 1}/${file.name}`;+ uploads.set(url, file);+ return `${file.mediaType.startsWith("image/") ? "!" : ""}[${file.name}](${url})`;+ });+ return [text, ...links].join("\n\n");+ }+async function decode(request: Request): Promise<PlatformCall> {+ if (new URL(request.url).hostname === "uploads.linear.app") {+ return {+ body: {},+ method: `GET ${request.url}`,+ response: serveFile(uploads.get(request.url)),+ };+ }const body = JSON.parse(await request.text()) as {readonly query?: string;readonly variables?: unknown;@@ -63,7 +84,7 @@ export function linearDriver(): ChannelDriver {return {name: "linear",- capabilities: ["text-replies"],+ capabilities: ["attachments", "text-replies"],// An agent session lives on an issue the whole workspace can see.surface: "shared",createChannel: (record) =>@@ -71,7 +92,8 @@ export function linearDriver(): ChannelDriver {api: { fetch: recordingFetch(record, decode) },credentials: { accessToken: "linear-token", webhookSecret: SECRET },}),- message: (text) => {+ message: (words, files = []) => {+ const text = withUploads(words, files);if (delivery === 0) {return webhook({action: "created",diff --git a/packages/eve/src/internal/testing/channel-conformance/linq-driver.ts b/packages/eve/src/internal/testing/channel-conformance/linq-driver.tsindex f76c82d15..398d3394e 100644--- a/packages/eve/src/internal/testing/channel-conformance/linq-driver.ts+++ b/packages/eve/src/internal/testing/channel-conformance/linq-driver.ts@@ -7,12 +7,16 @@ import {type Surface,numberedOptions,recordingFetch,+ type SentFile,+ serveFile,} from "#internal/testing/channel-conformance/harness.js";const API_KEY = "linq-conformance-api-key";const SIGNING_KEY = Buffer.from("linq-conformance-signing-key");const SIGNING_SECRET = `whsec_${SIGNING_KEY.toString("base64")}`;const BASE_URL = "https://linq-conformance.invalid/api/partner";+// Stands in for cdn.linqapp.com; `.invalid` never resolves, so nothing that bypasses the fake reaches the network.+const CDN_HOST = "cdn.linq-conformance.invalid";const PERSON = "alice";let nextChat = 0;@@ -35,16 +39,31 @@ export function linqDriver(surface: Exclude<Surface, "public"> = "shared"): Chanlet messageId = 0;let outbound = 0;let restoreFetch: (() => void) | undefined;+ /** Files a person sent, by the permanent CDN URL Linq lists each under. */+ const uploads = new Map<string, SentFile>();- function signedMessage(text: string): Request {+ function signedMessage(text: string, files: readonly SentFile[] = []): Request {messageId += 1;+ // Linq sends each file as a `media` part beside the text.+ const media = files.map((file, index) => {+ const url = `https://${CDN_HOST}/${chatId}/${messageId}-${index}/${file.name}`;+ uploads.set(url, file);+ return {+ filename: file.name,+ id: `media-${messageId}-${index}`,+ mime_type: file.mediaType,+ size_bytes: file.bytes.length,+ type: "media",+ url,+ };+ });const body = JSON.stringify({data: {// Linq's bridge hears every group message; a mention would route past its handler.chat: { id: chatId, is_group: group },direction: "inbound",id: `linq-inbound-${messageId}`,- parts: [{ type: "text", value: text }],+ parts: [{ type: "text", value: text }, ...media],sender_handle: { handle: PERSON, id: PERSON, is_me: false },},event_type: "message.received",@@ -68,12 +87,19 @@ export function linqDriver(surface: Exclude<Surface, "public"> = "shared"): Chanreturn {name: group ? "linq" : "linq-dm",- capabilities: ["text-replies"],+ capabilities: ["attachments", "text-replies"],surface,createChannel(record) {const previousFetch = globalThis.fetch;const fakeFetch = recordingFetch(record, async (request) => {const url = new URL(request.url);+ if (url.hostname === CDN_HOST) {+ return {+ body: {},+ method: `GET ${url.pathname}`,+ response: serveFile(uploads.get(url.href)),+ };+ }const bodyText = await request.text();outbound += 1;const id = `linq-outbound-${outbound}`;@@ -87,7 +113,9 @@ export function linqDriver(surface: Exclude<Surface, "public"> = "shared"): Chan// The adapter accepts no fetch option, so route only its test host globally and preserve other fetches.globalThis.fetch = async (input, init) => {const url = new URL(input instanceof Request ? input.url : input.toString());- if (url.hostname === new URL(BASE_URL).hostname) return fakeFetch(input, init);+ if (url.hostname === new URL(BASE_URL).hostname || url.hostname === CDN_HOST) {+ return fakeFetch(input, init);+ }return previousFetch(input, init);};restoreFetch = () => {diff --git a/packages/eve/src/internal/testing/channel-conformance/matrix.test.ts b/packages/eve/src/internal/testing/channel-conformance/matrix.test.tsindex 1086a6ac7..24e4d6ad9 100644--- a/packages/eve/src/internal/testing/channel-conformance/matrix.test.ts+++ b/packages/eve/src/internal/testing/channel-conformance/matrix.test.ts@@ -1,7 +1,7 @@import { expect, it } from "vitest";-import { renderHitlConformanceMatrix } from "#internal/testing/channel-conformance/conformance.js";+import { renderConformanceMatrix } from "#internal/testing/channel-conformance/conformance.js";it("MATRIX.md shows the conformance table", async () => {- await expect(renderHitlConformanceMatrix()).toMatchFileSnapshot("./MATRIX.md");+ await expect(renderConformanceMatrix()).toMatchFileSnapshot("./MATRIX.md");});diff --git a/packages/eve/src/internal/testing/channel-conformance/photon-driver.ts b/packages/eve/src/internal/testing/channel-conformance/photon-driver.tsindex 1ee96896e..81f36257c 100644--- a/packages/eve/src/internal/testing/channel-conformance/photon-driver.ts+++ b/packages/eve/src/internal/testing/channel-conformance/photon-driver.ts@@ -5,6 +5,7 @@ import { iMessageAdapter } from "#compiled/@photon-ai/chat-adapter-imessage/indeimport {type ChannelDriver,type PlatformCall,+ type SentFile,numberedOptions,} from "#internal/testing/channel-conformance/harness.js";@@ -35,12 +36,31 @@ export function photonDriver(): ChannelDriver {let sequence = 0;let restore: (() => void) | undefined;- function webhook(text: string): Request {+ function webhook(text: string, files: readonly SentFile[] = []): Request {sequence += 1;+ const content =+ files.length === 0+ ? { text, type: "text" }+ : {+ // A message with files arrives as a group: its text, then one attachment per file.+ items: [+ { content: { text, type: "text" } },+ ...files.map((file, index) => ({+ content: {+ id: `photon-attachment-${sequence}-${index}`,+ mimeType: file.mediaType,+ name: file.name,+ size: file.bytes.length,+ type: "attachment",+ },+ })),+ ],+ type: "group",+ };const body = JSON.stringify({event: "messages",message: {- content: { text, type: "text" },+ content,direction: "inbound",id: `photon-inbound-${sequence}`,sender: { id: PERSON },@@ -66,7 +86,7 @@ export function photonDriver(): ChannelDriver {return {name: "photon",- capabilities: ["text-replies"],+ capabilities: ["attachments", "text-replies"],surface: "private",createChannel(record) {async function recordSend(method: string, builder: ContentBuilder) {diff --git a/packages/eve/src/internal/testing/channel-conformance/slack-driver.ts b/packages/eve/src/internal/testing/channel-conformance/slack-driver.tsindex 178a71cf2..79568f80f 100644--- a/packages/eve/src/internal/testing/channel-conformance/slack-driver.ts+++ b/packages/eve/src/internal/testing/channel-conformance/slack-driver.ts@@ -10,6 +10,8 @@ import {type RenderedOption,recordingFetch,linkTargets,+ type SentFile,+ serveFile,} from "#internal/testing/channel-conformance/harness.js";import { decodeSlackApiBody } from "#internal/testing/slack-api-body.js";@@ -90,8 +92,31 @@ export function slackDriver(surface: Exclude<Surface, "public"> = "shared"): Cha});}+ /** Files a person uploaded, by the `url_private` Slack downloads each from. */+ const uploads = new Map<string, SentFile>();+ function slackFile(file: SentFile) {+ const id = `F${uploads.size + 1}`;+ const url = `https://files.slack.com/files-pri/${TEAM}-${id}/${file.name}`;+ uploads.set(url, file);+ return {+ id,+ mimetype: file.mediaType,+ name: file.name,+ size: file.bytes.length,+ url_private: url,+ };+ }+async function decode(request: Request): Promise<PlatformCall> {- const method = new URL(request.url).pathname.split("/").at(-1)!;+ const url = new URL(request.url);+ if (url.hostname === "files.slack.com") {+ return {+ body: {},+ method: `GET ${url.pathname}`,+ response: serveFile(uploads.get(url.href)),+ };+ }+ const method = url.pathname.split("/").at(-1)!;const body = decodeSlackApiBody(await request.text(), request.headers.get("content-type"));const ts = nextTs();return {@@ -112,14 +137,16 @@ export function slackDriver(surface: Exclude<Surface, "public"> = "shared"): Chareturn {name: dm ? "slack-dm" : "slack",- capabilities: dm ? ["buttons", "text-replies"] : ["another-person", "buttons", "text-replies"],+ capabilities: dm+ ? ["attachments", "buttons", "text-replies"]+ : ["attachments", "another-person", "buttons", "text-replies"],surface,createChannel: (record) =>slackChannel({api: { fetch: recordingFetch(record, decode) },credentials: { botToken: "xoxb-conformance", signingSecret: SIGNING_SECRET },}),- message: (text) => {+ message: (text, files = []) => {const ts = threadStarted ? nextTs() : threadTs;const thread = threadStarted ? { thread_ts: threadTs } : {};threadStarted = true;@@ -128,11 +155,18 @@ export function slackDriver(surface: Exclude<Surface, "public"> = "shared"): Chaconst event = dm? { channel_type: "im", text, type: "message" }: { channel_type: "channel", text: `${text}\n<@${BOT}>`, type: "app_mention" };+ // A message with uploads is a `file_share` in a DM; a mention carries its files as is.+ const shared: Record<string, unknown> = {};+ if (files.length > 0) {+ shared.files = files.map(slackFile);+ if (dm) shared.subtype = "file_share";+ }return signed(JSON.stringify({event: {...thread,...event,+ ...shared,channel: CHANNEL,event_ts: ts,ts,diff --git a/packages/eve/src/internal/testing/channel-conformance/teams-driver.ts b/packages/eve/src/internal/testing/channel-conformance/teams-driver.tsindex aa4b90375..1a976ac56 100644--- a/packages/eve/src/internal/testing/channel-conformance/teams-driver.ts+++ b/packages/eve/src/internal/testing/channel-conformance/teams-driver.ts@@ -7,6 +7,8 @@ import {type Surface,recordingFetch,linkTargets,+ type SentFile,+ serveFile,} from "#internal/testing/channel-conformance/harness.js";let nextConversation = 0;@@ -71,6 +73,31 @@ export function teamsDriver(surface: Exclude<Surface, "public"> = "shared"): Cha? { tenant: { id: TENANT } }: { channel: { id: "CHANNEL" }, team: { id: "TEAM" }, tenant: { id: TENANT } };let activityId = 0;+ /** Files a person sent, by the URL Teams lists each under. */+ const uploads = new Map<string, SentFile>();++ /**+ * A person's files as Teams attaches them: an image pasted into the message as+ * a Bot Connector `contentUrl`, and any other file as an upload with a+ * pre-authenticated SharePoint `downloadUrl`.+ */+ function attached(files: readonly SentFile[]): Record<string, unknown>[] {+ return files.map((file) => {+ const id = `${conversationId}-${uploads.size + 1}`.replaceAll(/[^\w-]/gu, "");+ if (file.mediaType.startsWith("image/")) {+ const url = `https://smba.trafficmanager.net/amer/v3/attachments/${id}/views/original`;+ uploads.set(url, file);+ return { contentType: file.mediaType, contentUrl: url, name: file.name };+ }+ const url = `https://contoso.sharepoint.com/personal/alice/${id}/${file.name}?tempauth=signed`;+ uploads.set(url, file);+ return {+ content: { downloadUrl: url, fileType: file.name.split(".").at(-1), uniqueId: id },+ contentType: "application/vnd.microsoft.teams.file.download.info",+ name: file.name,+ };+ });+ }function nextActivityId(): string {activityId += 1;@@ -94,6 +121,20 @@ export function teamsDriver(surface: Exclude<Surface, "public"> = "shared"): Cha}async function decode(request: Request): Promise<PlatformCall> {+ const url = new URL(request.url);+ if (uploads.has(url.href)) {+ // Bot Connector attachments need the bot's token; a SharePoint download URL carries its own.+ const authorized =+ url.hostname !== "smba.trafficmanager.net" ||+ request.headers.get("authorization") === "Bearer test-token";+ return {+ body: {},+ method: `GET ${url.pathname}`,+ response: authorized+ ? serveFile(uploads.get(url.href))+ : new Response("Unauthorized", { status: 401 }),+ };+ }const bodyText = await request.text();const body = bodyText === "" ? {} : JSON.parse(bodyText);const path = new URL(request.url).pathname;@@ -105,20 +146,21 @@ export function teamsDriver(surface: Exclude<Surface, "public"> = "shared"): Chareturn {name: personal ? "teams-dm" : "teams",capabilities: personal- ? ["buttons", "text-replies"]- : ["another-person", "buttons", "text-replies"],+ ? ["attachments", "buttons", "text-replies"]+ : ["attachments", "another-person", "buttons", "text-replies"],surface,createChannel: (record) =>teamsChannel({api: { fetch: recordingFetch(record, decode) },credentials: { tokenProvider: () => "test-token", webhookVerifier: () => true },}),- message: (text) =>+ message: (text, files = []) =>personal- ? activity({ text, type: "message" })+ ? activity({ attachments: attached(files), text, type: "message" }): // In a channel the default policy hears only mentions, so a person mentions the bot// each time, on its own line so the test model's line-based directives still read it.activity({+ attachments: attached(files),entities: [{ mentioned: BOT, text: MENTION, type: "mention" }],text: `${text}\n${MENTION}`,textFormat: "xml",diff --git a/packages/eve/src/internal/testing/channel-conformance/telegram-driver.ts b/packages/eve/src/internal/testing/channel-conformance/telegram-driver.tsindex 3c6c02e8a..783ff6068 100644--- a/packages/eve/src/internal/testing/channel-conformance/telegram-driver.ts+++ b/packages/eve/src/internal/testing/channel-conformance/telegram-driver.ts@@ -7,6 +7,8 @@ import {type Surface,recordingFetch,linkTargets,+ type SentFile,+ serveFile,} from "#internal/testing/channel-conformance/harness.js";const SECRET = "telegram-conformance-secret";@@ -104,9 +106,48 @@ export function telegramDriver(surface: Exclude<Surface, "public"> = "shared"):});}+ /** Files a person sent, by the `file_id` the bot fetches each with. */+ const uploads = new Map<string, SentFile>();+ /** A person's files as Telegram attaches them: an image as a photo, anything else as a document. */+ function attached(files: readonly SentFile[]): Record<string, unknown> {+ const [file] = files;+ if (file === undefined) return {};+ const fileId = `file_${uploads.size + 1}`;+ uploads.set(fileId, file);+ return file.mediaType.startsWith("image/")+ ? { photo: [{ file_id: fileId, file_size: file.bytes.length, height: 1, width: 1 }] }+ : {+ document: {+ file_id: fileId,+ file_name: file.name,+ file_size: file.bytes.length,+ mime_type: file.mediaType,+ },+ };+ }+async function decode(request: Request): Promise<PlatformCall> {- const method = new URL(request.url).pathname.split("/").at(-1)!;+ const url = new URL(request.url);+ // A download from Telegram's file endpoint, `/file/bot<token>/<file_id>`.+ if (url.pathname.startsWith("/file/")) {+ const fileId = url.pathname.split("/").at(-1)!;+ // Telegram serves files as `application/octet-stream`, whatever they are (#1217).+ return {+ body: {},+ method: `GET ${url.pathname}`,+ response: serveFile(uploads.get(fileId), "application/octet-stream"),+ };+ }+ const method = url.pathname.split("/").at(-1)!;const text = await request.text();+ if (method === "getFile") {+ const { file_id } = JSON.parse(text) as { readonly file_id: string };+ return {+ body: { file_id },+ method,+ response: { ok: true, result: { file_id, file_path: file_id } },+ };+ }messageId += 1;if (method === "sendMessage") lastBotMessage = messageId;return {@@ -119,8 +160,8 @@ export function telegramDriver(surface: Exclude<Surface, "public"> = "shared"):return {name: group ? "telegram" : "telegram-dm",capabilities: !group- ? ["buttons", "text-replies"]- : ["another-person", "buttons", "text-replies"],+ ? ["attachments", "buttons", "text-replies"]+ : ["attachments", "another-person", "buttons", "text-replies"],surface,createChannel: (record) =>telegramChannel({@@ -128,16 +169,22 @@ export function telegramDriver(surface: Exclude<Surface, "public"> = "shared"):botUsername: BOT.username,credentials: { botToken: "bot-token", webhookSecretToken: SECRET },}),- message: (text) =>- update({- message: {- chat: CHAT,- date: 0,- from: PERSON,- message_id: 1000 + updateId,- ...addressed(text),- },- }),+ message: (text, files = []) => {+ const message: Record<string, unknown> = {+ chat: CHAT,+ date: 0,+ from: PERSON,+ message_id: 1000 + updateId,+ ...addressed(text),+ };+ if (files.length > 0) {+ // A message with a file carries its words as the file's caption.+ message.caption = message.text;+ delete message.text;+ Object.assign(message, attached(files));+ }+ return update({ message });+ },findOptions(call, prompt) {const body = call.body as MessageBody;if (call.method !== "sendMessage" || body.text?.includes(prompt) !== true) return undefined;diff --git a/packages/eve/src/internal/testing/channel-conformance/twilio-driver.ts b/packages/eve/src/internal/testing/channel-conformance/twilio-driver.tsindex ecbffb6d4..2e5d04d62 100644--- a/packages/eve/src/internal/testing/channel-conformance/twilio-driver.ts+++ b/packages/eve/src/internal/testing/channel-conformance/twilio-driver.ts@@ -5,6 +5,7 @@ import {type PlatformCall,numberedOptions,recordingFetch,+ type SentFile,} from "#internal/testing/channel-conformance/harness.js";const AUTH_TOKEN = "twilio-conformance-secret";@@ -18,13 +19,20 @@ export function twilioDriver(): ChannelDriver {let messageSid = 0;const webhookUrl = "https://agent.example.com/eve/v1/twilio/messages";- function message(text: string): Request {+ function message(text: string, files: readonly SentFile[] = []): Request {messageSid += 1;+ // An MMS lists its media by URL, numbered from zero.+ const media = files.flatMap((file, index) => [+ [`MediaContentType${index}`, file.mediaType],+ [`MediaUrl${index}`, `https://api.twilio.com/media/conformance/${messageSid}/${index}`],+ ]);const params = new URLSearchParams({Body: text,From: PERSON,MessageSid: `SM-conformance-${messageSid}`,+ NumMedia: String(files.length),To: TO,+ ...Object.fromEntries(media),});return new Request(webhookUrl, {body: params,@@ -47,7 +55,7 @@ export function twilioDriver(): ChannelDriver {return {name: "twilio",- capabilities: ["text-replies"],+ capabilities: ["attachments", "text-replies"],surface: "private",createChannel: (record) =>twilioChannel({diff --git a/packages/eve/src/public/channels/chat-sdk/conformance-dm.integration.test.ts b/packages/eve/src/public/channels/chat-sdk/conformance-dm.integration.test.tsnew file mode 100644index 000000000..1d6f00fff--- /dev/null+++ b/packages/eve/src/public/channels/chat-sdk/conformance-dm.integration.test.ts@@ -0,0 +1,3 @@+import { describeChannelConformance } from "#internal/testing/channel-conformance/conformance.js";++describeChannelConformance("chat-sdk-dm");diff --git a/packages/eve/src/public/channels/chat-sdk/conformance.integration.test.ts b/packages/eve/src/public/channels/chat-sdk/conformance.integration.test.tsnew file mode 100644index 000000000..76645756d--- /dev/null+++ b/packages/eve/src/public/channels/chat-sdk/conformance.integration.test.ts@@ -0,0 +1,3 @@+import { describeChannelConformance } from "#internal/testing/channel-conformance/conformance.js";++describeChannelConformance("chat-sdk");diff --git a/packages/eve/src/public/channels/chat-sdk/hitl-conformance-dm.integration.test.ts b/packages/eve/src/public/channels/chat-sdk/hitl-conformance-dm.integration.test.tsdeleted file mode 100644index e880c1d3d..000000000--- a/packages/eve/src/public/channels/chat-sdk/hitl-conformance-dm.integration.test.ts+++ /dev/null@@ -1,3 +0,0 @@-import { describeHitlConformance } from "#internal/testing/channel-conformance/conformance.js";--describeHitlConformance("chat-sdk-dm");diff --git a/packages/eve/src/public/channels/chat-sdk/hitl-conformance.integration.test.ts b/packages/eve/src/public/channels/chat-sdk/hitl-conformance.integration.test.tsdeleted file mode 100644index 429f1a0ed..000000000--- a/packages/eve/src/public/channels/chat-sdk/hitl-conformance.integration.test.ts+++ /dev/null@@ -1,3 +0,0 @@-import { describeHitlConformance } from "#internal/testing/channel-conformance/conformance.js";--describeHitlConformance("chat-sdk");diff --git a/packages/eve/src/public/channels/discord/conformance-dm.integration.test.ts b/packages/eve/src/public/channels/discord/conformance-dm.integration.test.tsnew file mode 100644index 000000000..b8b0fabf4--- /dev/null+++ b/packages/eve/src/public/channels/discord/conformance-dm.integration.test.ts@@ -0,0 +1,3 @@+import { describeChannelConformance } from "#internal/testing/channel-conformance/conformance.js";++describeChannelConformance("discord-dm");diff --git a/packages/eve/src/public/channels/discord/conformance.integration.test.ts b/packages/eve/src/public/channels/discord/conformance.integration.test.tsnew file mode 100644index 000000000..2ae540246--- /dev/null+++ b/packages/eve/src/public/channels/discord/conformance.integration.test.ts@@ -0,0 +1,3 @@+import { describeChannelConformance } from "#internal/testing/channel-conformance/conformance.js";++describeChannelConformance("discord");diff --git a/packages/eve/src/public/channels/discord/hitl-conformance-dm.integration.test.ts b/packages/eve/src/public/channels/discord/hitl-conformance-dm.integration.test.tsdeleted file mode 100644index af54ab402..000000000--- a/packages/eve/src/public/channels/discord/hitl-conformance-dm.integration.test.ts+++ /dev/null@@ -1,3 +0,0 @@-import { describeHitlConformance } from "#internal/testing/channel-conformance/conformance.js";--describeHitlConformance("discord-dm");diff --git a/packages/eve/src/public/channels/discord/hitl-conformance.integration.test.ts b/packages/eve/src/public/channels/discord/hitl-conformance.integration.test.tsdeleted file mode 100644index 3b21ac187..000000000--- a/packages/eve/src/public/channels/discord/hitl-conformance.integration.test.ts+++ /dev/null@@ -1,3 +0,0 @@-import { describeHitlConformance } from "#internal/testing/channel-conformance/conformance.js";--describeHitlConformance("discord");diff --git a/packages/eve/src/public/channels/github/conformance.integration.test.ts b/packages/eve/src/public/channels/github/conformance.integration.test.tsnew file mode 100644index 000000000..5421ca816--- /dev/null+++ b/packages/eve/src/public/channels/github/conformance.integration.test.ts@@ -0,0 +1,3 @@+import { describeChannelConformance } from "#internal/testing/channel-conformance/conformance.js";++describeChannelConformance("github");diff --git a/packages/eve/src/public/channels/github/hitl-conformance.integration.test.ts b/packages/eve/src/public/channels/github/hitl-conformance.integration.test.tsdeleted file mode 100644index ea2ea3887..000000000--- a/packages/eve/src/public/channels/github/hitl-conformance.integration.test.ts+++ /dev/null@@ -1,3 +0,0 @@-import { describeHitlConformance } from "#internal/testing/channel-conformance/conformance.js";--describeHitlConformance("github");diff --git a/packages/eve/src/public/channels/linear/conformance.integration.test.ts b/packages/eve/src/public/channels/linear/conformance.integration.test.tsnew file mode 100644index 000000000..8439cda14--- /dev/null+++ b/packages/eve/src/public/channels/linear/conformance.integration.test.ts@@ -0,0 +1,3 @@+import { describeChannelConformance } from "#internal/testing/channel-conformance/conformance.js";++describeChannelConformance("linear");diff --git a/packages/eve/src/public/channels/linear/hitl-conformance.integration.test.ts b/packages/eve/src/public/channels/linear/hitl-conformance.integration.test.tsdeleted file mode 100644index 287eff5b3..000000000--- a/packages/eve/src/public/channels/linear/hitl-conformance.integration.test.ts+++ /dev/null@@ -1,3 +0,0 @@-import { describeHitlConformance } from "#internal/testing/channel-conformance/conformance.js";--describeHitlConformance("linear");diff --git a/packages/eve/src/public/channels/linq/conformance-dm.integration.test.ts b/packages/eve/src/public/channels/linq/conformance-dm.integration.test.tsnew file mode 100644index 000000000..5a3747162--- /dev/null+++ b/packages/eve/src/public/channels/linq/conformance-dm.integration.test.ts@@ -0,0 +1,3 @@+import { describeChannelConformance } from "#internal/testing/channel-conformance/conformance.js";++describeChannelConformance("linq-dm");diff --git a/packages/eve/src/public/channels/linq/conformance.integration.test.ts b/packages/eve/src/public/channels/linq/conformance.integration.test.tsnew file mode 100644index 000000000..b834885aa--- /dev/null+++ b/packages/eve/src/public/channels/linq/conformance.integration.test.ts@@ -0,0 +1,3 @@+import { describeChannelConformance } from "#internal/testing/channel-conformance/conformance.js";++describeChannelConformance("linq");diff --git a/packages/eve/src/public/channels/linq/hitl-conformance-dm.integration.test.ts b/packages/eve/src/public/channels/linq/hitl-conformance-dm.integration.test.tsdeleted file mode 100644index ed2b482b4..000000000--- a/packages/eve/src/public/channels/linq/hitl-conformance-dm.integration.test.ts+++ /dev/null@@ -1,3 +0,0 @@-import { describeHitlConformance } from "#internal/testing/channel-conformance/conformance.js";--describeHitlConformance("linq-dm");diff --git a/packages/eve/src/public/channels/linq/hitl-conformance.integration.test.ts b/packages/eve/src/public/channels/linq/hitl-conformance.integration.test.tsdeleted file mode 100644index 15407164f..000000000--- a/packages/eve/src/public/channels/linq/hitl-conformance.integration.test.ts+++ /dev/null@@ -1,3 +0,0 @@-import { describeHitlConformance } from "#internal/testing/channel-conformance/conformance.js";--describeHitlConformance("linq");diff --git a/packages/eve/src/public/channels/photon/conformance.integration.test.ts b/packages/eve/src/public/channels/photon/conformance.integration.test.tsnew file mode 100644index 000000000..643bee7be--- /dev/null+++ b/packages/eve/src/public/channels/photon/conformance.integration.test.ts@@ -0,0 +1,3 @@+import { describeChannelConformance } from "#internal/testing/channel-conformance/conformance.js";++describeChannelConformance("photon");diff --git a/packages/eve/src/public/channels/photon/hitl-conformance.integration.test.ts b/packages/eve/src/public/channels/photon/hitl-conformance.integration.test.tsdeleted file mode 100644index 8b5f0292f..000000000--- a/packages/eve/src/public/channels/photon/hitl-conformance.integration.test.ts+++ /dev/null@@ -1,3 +0,0 @@-import { describeHitlConformance } from "#internal/testing/channel-conformance/conformance.js";--describeHitlConformance("photon");diff --git a/packages/eve/src/public/channels/slack/conformance-dm.integration.test.ts b/packages/eve/src/public/channels/slack/conformance-dm.integration.test.tsnew file mode 100644index 000000000..d816aed3f--- /dev/null+++ b/packages/eve/src/public/channels/slack/conformance-dm.integration.test.ts@@ -0,0 +1,3 @@+import { describeChannelConformance } from "#internal/testing/channel-conformance/conformance.js";++describeChannelConformance("slack-dm");diff --git a/packages/eve/src/public/channels/slack/conformance.integration.test.ts b/packages/eve/src/public/channels/slack/conformance.integration.test.tsnew file mode 100644index 000000000..5f70f6fbc--- /dev/null+++ b/packages/eve/src/public/channels/slack/conformance.integration.test.ts@@ -0,0 +1,3 @@+import { describeChannelConformance } from "#internal/testing/channel-conformance/conformance.js";++describeChannelConformance("slack");diff --git a/packages/eve/src/public/channels/slack/hitl-conformance-dm.integration.test.ts b/packages/eve/src/public/channels/slack/hitl-conformance-dm.integration.test.tsdeleted file mode 100644index 554f6c4fe..000000000--- a/packages/eve/src/public/channels/slack/hitl-conformance-dm.integration.test.ts+++ /dev/null@@ -1,3 +0,0 @@-import { describeHitlConformance } from "#internal/testing/channel-conformance/conformance.js";--describeHitlConformance("slack-dm");diff --git a/packages/eve/src/public/channels/slack/hitl-conformance.integration.test.ts b/packages/eve/src/public/channels/slack/hitl-conformance.integration.test.tsdeleted file mode 100644index b57e6f209..000000000--- a/packages/eve/src/public/channels/slack/hitl-conformance.integration.test.ts+++ /dev/null@@ -1,3 +0,0 @@-import { describeHitlConformance } from "#internal/testing/channel-conformance/conformance.js";--describeHitlConformance("slack");diff --git a/packages/eve/src/public/channels/teams/conformance-dm.integration.test.ts b/packages/eve/src/public/channels/teams/conformance-dm.integration.test.tsnew file mode 100644index 000000000..3a7a70961--- /dev/null+++ b/packages/eve/src/public/channels/teams/conformance-dm.integration.test.ts@@ -0,0 +1,3 @@+import { describeChannelConformance } from "#internal/testing/channel-conformance/conformance.js";++describeChannelConformance("teams-dm");diff --git a/packages/eve/src/public/channels/teams/conformance.integration.test.ts b/packages/eve/src/public/channels/teams/conformance.integration.test.tsnew file mode 100644index 000000000..efa1d6081--- /dev/null+++ b/packages/eve/src/public/channels/teams/conformance.integration.test.ts@@ -0,0 +1,3 @@+import { describeChannelConformance } from "#internal/testing/channel-conformance/conformance.js";++describeChannelConformance("teams");diff --git a/packages/eve/src/public/channels/teams/hitl-conformance-dm.integration.test.ts b/packages/eve/src/public/channels/teams/hitl-conformance-dm.integration.test.tsdeleted file mode 100644index bd460bb34..000000000--- a/packages/eve/src/public/channels/teams/hitl-conformance-dm.integration.test.ts+++ /dev/null@@ -1,3 +0,0 @@-import { describeHitlConformance } from "#internal/testing/channel-conformance/conformance.js";--describeHitlConformance("teams-dm");diff --git a/packages/eve/src/public/channels/teams/hitl-conformance.integration.test.ts b/packages/eve/src/public/channels/teams/hitl-conformance.integration.test.tsdeleted file mode 100644index ced259fa7..000000000--- a/packages/eve/src/public/channels/teams/hitl-conformance.integration.test.ts+++ /dev/null@@ -1,3 +0,0 @@-import { describeHitlConformance } from "#internal/testing/channel-conformance/conformance.js";--describeHitlConformance("teams");diff --git a/packages/eve/src/public/channels/telegram/conformance-dm.integration.test.ts b/packages/eve/src/public/channels/telegram/conformance-dm.integration.test.tsnew file mode 100644index 000000000..a140a545c--- /dev/null+++ b/packages/eve/src/public/channels/telegram/conformance-dm.integration.test.ts@@ -0,0 +1,3 @@+import { describeChannelConformance } from "#internal/testing/channel-conformance/conformance.js";++describeChannelConformance("telegram-dm");diff --git a/packages/eve/src/public/channels/telegram/conformance.integration.test.ts b/packages/eve/src/public/channels/telegram/conformance.integration.test.tsnew file mode 100644index 000000000..8c70c03d5--- /dev/null+++ b/packages/eve/src/public/channels/telegram/conformance.integration.test.ts@@ -0,0 +1,3 @@+import { describeChannelConformance } from "#internal/testing/channel-conformance/conformance.js";++describeChannelConformance("telegram");diff --git a/packages/eve/src/public/channels/telegram/hitl-conformance-dm.integration.test.ts b/packages/eve/src/public/channels/telegram/hitl-conformance-dm.integration.test.tsdeleted file mode 100644index 6c5231115..000000000--- a/packages/eve/src/public/channels/telegram/hitl-conformance-dm.integration.test.ts+++ /dev/null@@ -1,3 +0,0 @@-import { describeHitlConformance } from "#internal/testing/channel-conformance/conformance.js";--describeHitlConformance("telegram-dm");diff --git a/packages/eve/src/public/channels/telegram/hitl-conformance.integration.test.ts b/packages/eve/src/public/channels/telegram/hitl-conformance.integration.test.tsdeleted file mode 100644index e66a28253..000000000--- a/packages/eve/src/public/channels/telegram/hitl-conformance.integration.test.ts+++ /dev/null@@ -1,3 +0,0 @@-import { describeHitlConformance } from "#internal/testing/channel-conformance/conformance.js";--describeHitlConformance("telegram");diff --git a/packages/eve/src/public/channels/twilio/conformance.integration.test.ts b/packages/eve/src/public/channels/twilio/conformance.integration.test.tsnew file mode 100644index 000000000..13cfe7c0a--- /dev/null+++ b/packages/eve/src/public/channels/twilio/conformance.integration.test.ts@@ -0,0 +1,3 @@+import { describeChannelConformance } from "#internal/testing/channel-conformance/conformance.js";++describeChannelConformance("twilio");diff --git a/packages/eve/src/public/channels/twilio/hitl-conformance.integration.test.ts b/packages/eve/src/public/channels/twilio/hitl-conformance.integration.test.tsdeleted file mode 100644index c22f7cabf..000000000--- a/packages/eve/src/public/channels/twilio/hitl-conformance.integration.test.ts+++ /dev/null@@ -1,3 +0,0 @@-import { describeHitlConformance } from "#internal/testing/channel-conformance/conformance.js";--describeHitlConformance("twilio");diff --git a/packages/eve/src/runtime/agent/mock-model-adapter.ts b/packages/eve/src/runtime/agent/mock-model-adapter.tsindex 5b2516efe..00533b9c9 100644--- a/packages/eve/src/runtime/agent/mock-model-adapter.ts+++ b/packages/eve/src/runtime/agent/mock-model-adapter.ts@@ -1,3 +1,5 @@+import { createHash } from "node:crypto";+import type { LanguageModel } from "ai";import { MockLanguageModelV3 } from "ai/test";import { z } from "#compiled/zod/index.js";@@ -365,8 +367,14 @@ function createFollowUpToolCallResult(input: {});}+const LIST_ATTACHMENTS_DIRECTIVE = /\blist the attachments\b/iu;+function createAssistantMessage(prompt: BootstrapPrompt): string {const lastUserMessage = getLastUserPromptText(prompt) ?? "Hello from eve";+ // Lets tests see exactly which files reached the model, through a channel's real reply.+ if (LIST_ATTACHMENTS_DIRECTIVE.test(lastUserMessage)) {+ return `Attachments: ${JSON.stringify(listPromptAttachments(prompt))}`;+ }const systemLabels = getSystemPromptLabels(prompt);const systemProbe = resolveSystemProbe(prompt);const fixtureToken = resolveMockFixtureToken(prompt);@@ -695,3 +703,48 @@ function isWeatherPayload(value: unknown): value is {function isRecord(value: unknown): value is Record<string, unknown> {return typeof value === "object" && value !== null && !Array.isArray(value);}++// eve's notes for files it couldn't pass on, such as "Attachment x.pdf could not be retrieved."+const ATTACHMENT_NOTE = /^Attachment\b/u;++/**+ * Every file part in the prompt's user messages, and every note eve left for a+ * file it couldn't pass on, oldest first, as a test can compare them.+ */+function listPromptAttachments(prompt: BootstrapPrompt): readonly Record<string, unknown>[] {+ return prompt.flatMap((message): Record<string, unknown>[] => {+ if (message.role !== "user" || typeof message.content === "string") return [];+ return message.content.flatMap((part): Record<string, unknown>[] => {+ if (typeof part === "string") return [];+ if (part.type === "text") return ATTACHMENT_NOTE.test(part.text) ? [{ note: part.text }] : [];+ if (part.type !== "file") return [];+ const name = part.filename?.split("/").at(-1) ?? null;+ const data = fileData(part.data);+ if (data instanceof URL) return [{ mediaType: part.mediaType, name, url: data.href }];+ if (data === undefined) return [{ mediaType: part.mediaType, name }];+ const bytes = typeof data === "string" ? Buffer.from(data, "base64") : Buffer.from(data);+ return [+ {+ bytes: bytes.length,+ mediaType: part.mediaType,+ name,+ sha256: createHash("sha256").update(bytes).digest("hex").slice(0, 16),+ },+ ];+ });+ });+}++/** A file part's bytes or URL, from either the plain or the tagged (`{ type: "data" }`) shape. */+function fileData(data: unknown): Uint8Array | string | URL | undefined {+ if (typeof data === "string" || data instanceof Uint8Array || data instanceof URL) return data;+ if (typeof data !== "object" || data === null) return undefined;+ const tagged = data as {+ readonly data?: unknown;+ readonly type?: unknown;+ readonly url?: unknown;+ };+ if (tagged.type === "url" && tagged.url instanceof URL) return tagged.url;+ if (tagged.type === "data") return fileData(tagged.data);+ return undefined;+}diff --git a/packages/eve/test/browser/web-chat-conformance.test.ts b/packages/eve/test/browser/web-chat-conformance.test.tsnew file mode 100644index 000000000..d7c62fed3--- /dev/null+++ b/packages/eve/test/browser/web-chat-conformance.test.ts@@ -0,0 +1,3 @@+import { describeChannelConformance } from "#internal/testing/channel-conformance/conformance.js";++describeChannelConformance("web-chat");diff --git a/packages/eve/test/browser/web-chat-hitl-conformance.test.ts b/packages/eve/test/browser/web-chat-hitl-conformance.test.tsdeleted file mode 100644index 80411f78b..000000000--- a/packages/eve/test/browser/web-chat-hitl-conformance.test.ts+++ /dev/null@@ -1,3 +0,0 @@-import { describeHitlConformance } from "#internal/testing/channel-conformance/conformance.js";--describeHitlConformance("web-chat");diff --git a/packages/eve/vitest.integration.config.ts b/packages/eve/vitest.integration.config.tsindex 0f61179cd..b31710bb4 100644--- a/packages/eve/vitest.integration.config.ts+++ b/packages/eve/vitest.integration.config.ts@@ -36,7 +36,7 @@ export default defineConfig({"**/node_modules/**","test/scenarios/**",// Channel conformance checks platform protocol, not the OS, and is slowest on Windows runners.- ...(process.platform === "win32" ? ["**/hitl-conformance*.integration.test.ts"] : []),+ ...(process.platform === "win32" ? ["**/conformance*.integration.test.ts"] : []),],globalSetup: ["./test/setup/clear-workflow-cache.ts"],include: ["src/**/*.integration.test.ts", "test/**/*.integration.test.ts"],