The Open Framework for Building Agents
[1/2] test(eve): drive Web Chat in a browser for HITL conformance (#4222)
Ben Pankowccb19ce83950
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex 9f9991ad9..7c140116f 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -187,6 +187,33 @@ jobs:- name: Build framework fixtures against the workspace eve distrun: pnpm test:framework-fixtures+ test-browser:+ runs-on: ubuntu-latest++ steps:+ - name: Checkout code+ uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1+ with:+ persist-credentials: false++ - name: Setup pnpm+ uses: pnpm/action-setup@0977fd99725f1db4007ccb2928dbb4e90d06cc86 # v6.0.10++ - name: Setup Node.js+ uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0+ with:+ node-version-file: .nvmrc+ cache: "pnpm"++ - name: Install dependencies+ run: pnpm install --frozen-lockfile++ - name: Install Chromium+ run: pnpm --filter eve exec playwright-core install --with-deps chromium-headless-shell++ - name: Run browser tests+ run: pnpm test:browser+test-templates:runs-on: ubuntu-latestdiff --git a/AGENTS.md b/AGENTS.mdindex 3d2a1cb25..2f5a85751 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -59,6 +59,7 @@ pnpm test:unit # unit tests (<3s)pnpm test:integration # integration tests (<10s)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)pnpm test:e2e # fixture-owned eve eval suites (CI only)pnpm test:tui # TUI smoke scripts (not e2e)```diff --git a/package.json b/package.jsonindex 11df9cc53..6fb3419e6 100644--- a/package.json+++ b/package.json@@ -23,6 +23,7 @@"release": "pnpm build && node ./scripts/assert-changeset-publish-packages.mjs && changeset publish","test": "pnpm test:unit && pnpm test:integration","test:e2e": "turbo run test:e2e --concurrency=1",+ "test:browser": "pnpm --filter eve run test:browser","test:framework-fixtures": "pnpm --filter eve run test:framework-fixtures","test:integration": "turbo run test:integration --filter=eve && turbo run test:integration --filter=\"!eve\"","test:scenario": "turbo run test:scenario",diff --git a/packages/eve/package.json b/packages/eve/package.jsonindex e13849a20..1b8ebdcaf 100644--- a/packages/eve/package.json+++ b/packages/eve/package.json@@ -515,6 +515,7 @@"dev": "pnpm run build:compiled && node ./scripts/copy-runtime-assets.mjs && tsc -p tsconfig.dev.json --watch --preserveWatchOutput","prepack": "pnpm run build && node ../../scripts/copy-package-license.mjs .","test": "pnpm run test:unit && pnpm run test:integration",+ "test:browser": "pnpm run build:js && vitest run --config vitest.browser.config.ts","test:framework-fixtures": "pnpm run build:compiled && vitest run --config vitest.framework-fixtures.config.ts","test:integration": "pnpm run build:js && vitest run --config vitest.integration.config.ts","test:scenario": "pnpm run build:compiled && vitest run --config vitest.scenario.config.ts",@@ -590,6 +591,7 @@"microsandbox": "0.5.5","next": "catalog:","picocolors": "catalog:",+ "playwright-core": "1.63.0","react": "catalog:","react-test-renderer": "19.2.6","run": "2.1.2",diff --git a/packages/eve/src/internal/testing/channel-conformance/MATRIX.md b/packages/eve/src/internal/testing/channel-conformance/MATRIX.mdindex 1a1d1c3fb..058e4323e 100644--- a/packages/eve/src/internal/testing/channel-conformance/MATRIX.md+++ b/packages/eve/src/internal/testing/channel-conformance/MATRIX.md@@ -13,62 +13,65 @@ pnpm --filter eve exec vitest run --config vitest.unit.config.ts channel-conform✅ passes · ❌ broken · — not supported-| Rule | `tui` | `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` | `twilio` |-| --- | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: |-| a rendered question shows every option a person can choose | ✅ | ✅ | | ✅ | ✅ | | ✅ | | ✅ | | ✅ | | ✅ | | ✅ | ✅ | ✅ |-| pressing a rendered option answers the pending question with that option | ✅ | ✅ | ✅ | —<sup>[1](#note-1)</sup> | ✅ | ✅ | —<sup>[1](#note-1)</sup> | —<sup>[1](#note-1)</sup> | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | —<sup>[1](#note-1)</sup> | —<sup>[1](#note-1)</sup> | —<sup>[1](#note-1)</sup> |-| a text reply matching an option answers the only pending question | ✅ | ✅ | ✅ | ✅ | —<sup>[2](#note-2)</sup> | —<sup>[2](#note-2)</sup> | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |-| a text reply that matches no option answers the question with the person's words | ✅ | ✅ | ✅ | ✅ | —<sup>[2](#note-2)</sup> | —<sup>[2](#note-2)</sup> | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |-| a text reply answers an open-ended question with the person's words | ✅ | ✅ | ✅ | ✅ | —<sup>[2](#note-2)</sup> | —<sup>[2](#note-2)</sup> | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |-| pressing an option of an answered question sends it to the agent as new input | —<sup>[3](#note-3)</sup> | ✅ | | —<sup>[1](#note-1)</sup> | ✅ | | —<sup>[1](#note-1)</sup> | | ✅ | | ✅ | | ✅ | | —<sup>[1](#note-1)</sup> | —<sup>[1](#note-1)</sup> | —<sup>[1](#note-1)</sup> |-| pressing options of two pending questions answers each with its own option | ✅ | ✅ | | —<sup>[1](#note-1)</sup> | ✅ | | —<sup>[1](#note-1)</sup> | | ✅ | | ✅ | | ✅ | | —<sup>[1](#note-1)</sup> | —<sup>[1](#note-1)</sup> | —<sup>[1](#note-1)</sup> |-| a text reply matching an option does not answer either of two pending questions | ✅ | ✅ | ✅ | ✅ | —<sup>[2](#note-2)</sup> | —<sup>[2](#note-2)</sup> | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |-| a tool approval shows a choice to approve and one to cancel | ✅ | ✅ | | ✅ | ✅ | | ✅ | | ✅ | | ✅ | | ✅ | | ✅ | ✅ | ✅ |-| pressing Approve runs the gated tool | ✅ | ✅ | ✅ | —<sup>[1](#note-1)</sup> | ✅ | ✅ | —<sup>[1](#note-1)</sup> | —<sup>[1](#note-1)</sup> | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | —<sup>[1](#note-1)</sup> | —<sup>[1](#note-1)</sup> | —<sup>[1](#note-1)</sup> |-| pressing Approve twice runs the gated tool once | ✅ | ✅ | | —<sup>[1](#note-1)</sup> | ✅ | | —<sup>[1](#note-1)</sup> | | ✅ | | ✅ | | ✅ | | —<sup>[1](#note-1)</sup> | —<sup>[1](#note-1)</sup> | —<sup>[1](#note-1)</sup> |-| pressing Approve on one of two pending approvals runs only that tool | ✅ | ✅ | | —<sup>[1](#note-1)</sup> | ✅ | | —<sup>[1](#note-1)</sup> | | ✅ | | ✅ | | ✅ | | —<sup>[1](#note-1)</sup> | —<sup>[1](#note-1)</sup> | —<sup>[1](#note-1)</sup> |-| answering an approval and a question pending together settles both | ✅ | ✅ | | —<sup>[1](#note-1)</sup> | ✅ | | —<sup>[1](#note-1)</sup> | | ✅ | | ✅ | | ✅ | | —<sup>[1](#note-1)</sup> | —<sup>[1](#note-1)</sup> | —<sup>[1](#note-1)</sup> |-| pressing Cancel stops the gated tool without running it | ✅ | ✅ | | —<sup>[1](#note-1)</sup> | ✅ | | —<sup>[1](#note-1)</sup> | | ✅ | | ✅ | | ✅ | | —<sup>[1](#note-1)</sup> | —<sup>[1](#note-1)</sup> | —<sup>[1](#note-1)</sup> |-| a text reply of approve runs the gated tool | —<sup>[4](#note-4)</sup> | ✅ | ✅ | ✅ | —<sup>[2](#note-2)</sup> | —<sup>[2](#note-2)</sup> | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |-| a text reply of cancel stops the gated tool without running it | —<sup>[4](#note-4)</sup> | ✅ | ✅ | ✅ | —<sup>[2](#note-2)</sup> | —<sup>[2](#note-2)</sup> | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |-| pressing an option clears the question's buttons | ✅ | ✅ | | —<sup>[1](#note-1)</sup> | ✅ | | —<sup>[1](#note-1)</sup> | | ✅ | | ✅ | | ✅ | | —<sup>[1](#note-1)</sup> | —<sup>[1](#note-1)</sup> | —<sup>[1](#note-1)</sup> |-| answering a question by text clears its buttons | ✅ | ✅ | ✅ | —<sup>[1](#note-1)</sup> | —<sup>[2](#note-2)</sup> | —<sup>[2](#note-2)</sup> | —<sup>[1](#note-1)</sup> | —<sup>[1](#note-1)</sup> | ❌<sup>[5](#note-5)</sup> | ❌<sup>[5](#note-5)</sup> | ✅ | ✅ | ✅ | ✅ | —<sup>[1](#note-1)</sup> | —<sup>[1](#note-1)</sup> | —<sup>[1](#note-1)</sup> |-| pressing an option names who answered on the question | —<sup>[6](#note-6)</sup> | ❌<sup>[7](#note-7)</sup> | | —<sup>[1](#note-1)</sup> | ❌<sup>[7](#note-7)</sup> | | —<sup>[1](#note-1)</sup> | | ✅ | | ❌<sup>[7](#note-7)</sup> | | ❌<sup>[7](#note-7)</sup> | | —<sup>[1](#note-1)</sup> | —<sup>[1](#note-1)</sup> | —<sup>[1](#note-1)</sup> |-| answering a question by text names who answered on the question | —<sup>[6](#note-6)</sup> | ❌<sup>[7](#note-7)</sup> | ❌<sup>[7](#note-7)</sup> | —<sup>[1](#note-1)</sup> | —<sup>[2](#note-2)</sup> | —<sup>[2](#note-2)</sup> | —<sup>[1](#note-1)</sup> | —<sup>[1](#note-1)</sup> | ❌<sup>[5](#note-5)</sup> | ❌<sup>[5](#note-5)</sup> | ❌<sup>[7](#note-7)</sup> | ❌<sup>[7](#note-7)</sup> | ❌<sup>[7](#note-7)</sup> | ❌<sup>[7](#note-7)</sup> | —<sup>[1](#note-1)</sup> | —<sup>[1](#note-1)</sup> | —<sup>[1](#note-1)</sup> |-| pressing Approve clears the approval's buttons | ✅ | ✅ | | —<sup>[1](#note-1)</sup> | ✅ | | —<sup>[1](#note-1)</sup> | | ✅ | | ✅ | | ✅ | | —<sup>[1](#note-1)</sup> | —<sup>[1](#note-1)</sup> | —<sup>[1](#note-1)</sup> |-| approving by text clears the approval's buttons | —<sup>[4](#note-4)</sup> | ✅ | ✅ | —<sup>[1](#note-1)</sup> | —<sup>[2](#note-2)</sup> | —<sup>[2](#note-2)</sup> | —<sup>[1](#note-1)</sup> | —<sup>[1](#note-1)</sup> | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | —<sup>[1](#note-1)</sup> | —<sup>[1](#note-1)</sup> | —<sup>[1](#note-1)</sup> |-| pressing Approve names who approved on the approval | —<sup>[6](#note-6)</sup> | ❌<sup>[7](#note-7)</sup> | | —<sup>[1](#note-1)</sup> | ❌<sup>[7](#note-7)</sup> | | —<sup>[1](#note-1)</sup> | | ✅ | | ✅ | | ❌<sup>[7](#note-7)</sup> | | —<sup>[1](#note-1)</sup> | —<sup>[1](#note-1)</sup> | —<sup>[1](#note-1)</sup> |-| approving by text names who approved on the approval | —<sup>[4](#note-4)</sup> | ❌<sup>[7](#note-7)</sup> | ❌<sup>[7](#note-7)</sup> | —<sup>[1](#note-1)</sup> | —<sup>[2](#note-2)</sup> | —<sup>[2](#note-2)</sup> | —<sup>[1](#note-1)</sup> | —<sup>[1](#note-1)</sup> | ❌<sup>[8](#note-8)</sup> | ❌<sup>[8](#note-8)</sup> | ❌<sup>[7](#note-7)</sup> | ❌<sup>[7](#note-7)</sup> | ❌<sup>[7](#note-7)</sup> | ❌<sup>[7](#note-7)</sup> | —<sup>[1](#note-1)</sup> | —<sup>[1](#note-1)</sup> | —<sup>[1](#note-1)</sup> |-| running out of budget opens budget prompt | ✅ | ✅ | | ✅ | ✅ | | ✅ | | ✅ | | ✅ | | ✅ | | ✅ | ✅ | ✅ |-| pressing approve on budget prompt allows agent to continue | ✅ | ✅ | | —<sup>[1](#note-1)</sup> | ✅ | | —<sup>[1](#note-1)</sup> | | ✅ | | ✅ | | ✅ | | —<sup>[1](#note-1)</sup> | —<sup>[1](#note-1)</sup> | —<sup>[1](#note-1)</sup> |-| reply of approve on budget prompt allows agent to continue | ✅ | ✅ | ✅ | ✅ | —<sup>[2](#note-2)</sup> | —<sup>[2](#note-2)</sup> | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |-| pressing stop on budget prompt halts work, next message asks again | ❌<sup>[9](#note-9)</sup> | ✅ | ✅ | —<sup>[1](#note-1)</sup> | —<sup>[2](#note-2)</sup> | —<sup>[2](#note-2)</sup> | —<sup>[1](#note-1)</sup> | —<sup>[1](#note-1)</sup> | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | —<sup>[1](#note-1)</sup> | —<sup>[1](#note-1)</sup> | —<sup>[1](#note-1)</sup> |-| reply of stop on budget prompt halts work, next message asks again | ❌<sup>[9](#note-9)</sup> | ✅ | ✅ | ✅ | —<sup>[2](#note-2)</sup> | —<sup>[2](#note-2)</sup> | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |-| query sent during budget prompt answered after budget approval | ❌<sup>[10](#note-10)</sup> | ❌<sup>[10](#note-10)</sup> | ❌<sup>[10](#note-10)</sup> | ❌<sup>[10](#note-10)</sup> | —<sup>[2](#note-2)</sup> | —<sup>[2](#note-2)</sup> | ❌<sup>[10](#note-10)</sup> | ❌<sup>[10](#note-10)</sup> | ❌<sup>[10](#note-10)</sup> | ❌<sup>[10](#note-10)</sup> | ❌<sup>[10](#note-10)</sup> | ❌<sup>[10](#note-10)</sup> | ❌<sup>[10](#note-10)</sup> | ❌<sup>[10](#note-10)</sup> | ❌<sup>[10](#note-10)</sup> | ❌<sup>[10](#note-10)</sup> | ❌<sup>[10](#note-10)</sup> |-| a sign-in names the service and shows its sign-in link | ✅ | ❌<sup>[11](#note-11)</sup> | ✅ | ✅ | ❌<sup>[12](#note-12)</sup> | ❌<sup>[12](#note-12)</sup> | ❌<sup>[11](#note-11)</sup> | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | —<sup>[13](#note-13)</sup> | ✅ | ✅ |-| a sign-in shows its confirmation code | ✅ | ❌<sup>[11](#note-11)</sup> | ✅ | ✅ | ❌<sup>[12](#note-12)</sup> | ❌<sup>[12](#note-12)</sup> | ❌<sup>[11](#note-11)</sup> | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | —<sup>[13](#note-13)</sup> | ✅ | ✅ |-| only the person signing in sees the sign-in link and code | —<sup>[14](#note-14)</sup> | ✅ | —<sup>[14](#note-14)</sup> | —<sup>[14](#note-14)</sup> | ✅ | —<sup>[14](#note-14)</sup> | ✅ | —<sup>[14](#note-14)</sup> | ✅ | —<sup>[14](#note-14)</sup> | ❌<sup>[15](#note-15)</sup> | —<sup>[14](#note-14)</sup> | ✅ | —<sup>[14](#note-14)</sup> | ✅ | ❌<sup>[16](#note-16)</sup> | —<sup>[14](#note-14)</sup> |-| a sign-in without a link shows its instructions | ✅ | ❌<sup>[11](#note-11)</sup> | ✅ | ✅ | ❌<sup>[12](#note-12)</sup> | ❌<sup>[12](#note-12)</sup> | ❌<sup>[11](#note-11)</sup> | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌<sup>[12](#note-12)</sup> | ✅ | ✅ |-| after signing in, the agent carries on with the request | ✅ | ✅ | | ✅ | ✅ | | ✅ | | ✅ | | ✅ | | ✅ | | ✅ | ✅ | ✅ |-| completing a sign-in tells the person it succeeded | ✅ | ✅ | ✅ | ✅ | ❌<sup>[12](#note-12)</sup> | ❌<sup>[12](#note-12)</sup> | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌<sup>[12](#note-12)</sup> | ✅ | ✅ |-| message after ignored sign-in gets an answer, signing in late doesn't run | ✅ | ✅ | ✅ | ✅ | —<sup>[2](#note-2)</sup> | —<sup>[2](#note-2)</sup> | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |-| message after ignored sign-in tells user it was cancelled | ✅ | ✅ | ✅ | ✅ | —<sup>[2](#note-2)</sup> | —<sup>[2](#note-2)</sup> | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌<sup>[12](#note-12)</sup> | ✅ | ✅ |+| 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` | `twilio` |+| --- | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: |+| a rendered question shows every option a person can choose | ✅ | ✅ | ✅ | | ✅ | ✅ | | ✅ | | ✅ | | ✅ | | ✅ | | ✅ | ✅ | ✅ |+| pressing a rendered option answers the pending question with that option | ✅ | ✅ | ✅ | ✅ | —<sup>[1](#note-1)</sup> | ✅ | ✅ | —<sup>[1](#note-1)</sup> | —<sup>[1](#note-1)</sup> | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | —<sup>[1](#note-1)</sup> | —<sup>[1](#note-1)</sup> | —<sup>[1](#note-1)</sup> |+| a text reply matching an option answers the only pending question | ✅ | ✅ | ✅ | ✅ | ✅ | —<sup>[2](#note-2)</sup> | —<sup>[2](#note-2)</sup> | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |+| a text reply that matches no option answers the question with the person's words | ✅ | ✅ | ✅ | ✅ | ✅ | —<sup>[2](#note-2)</sup> | —<sup>[2](#note-2)</sup> | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |+| a text reply answers an open-ended question with the person's words | ✅ | ✅ | ✅ | ✅ | ✅ | —<sup>[2](#note-2)</sup> | —<sup>[2](#note-2)</sup> | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |+| pressing an option of an answered question sends it to the agent as new input | —<sup>[3](#note-3)</sup> | —<sup>[4](#note-4)</sup> | ✅ | | —<sup>[1](#note-1)</sup> | ✅ | | —<sup>[1](#note-1)</sup> | | ✅ | | ✅ | | ✅ | | —<sup>[1](#note-1)</sup> | —<sup>[1](#note-1)</sup> | —<sup>[1](#note-1)</sup> |+| pressing options of two pending questions answers each with its own option | ✅ | ❌<sup>[5](#note-5)</sup> | ✅ | | —<sup>[1](#note-1)</sup> | ✅ | | —<sup>[1](#note-1)</sup> | | ✅ | | ✅ | | ✅ | | —<sup>[1](#note-1)</sup> | —<sup>[1](#note-1)</sup> | —<sup>[1](#note-1)</sup> |+| a text reply matching an option does not answer either of two pending questions | ✅ | ✅ | ✅ | ✅ | ✅ | —<sup>[2](#note-2)</sup> | —<sup>[2](#note-2)</sup> | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |+| a tool approval shows a choice to approve and one to cancel | ✅ | ✅ | ✅ | | ✅ | ✅ | | ✅ | | ✅ | | ✅ | | ✅ | | ✅ | ✅ | ✅ |+| pressing Approve runs the gated tool | ✅ | ✅ | ✅ | ✅ | —<sup>[1](#note-1)</sup> | ✅ | ✅ | —<sup>[1](#note-1)</sup> | —<sup>[1](#note-1)</sup> | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | —<sup>[1](#note-1)</sup> | —<sup>[1](#note-1)</sup> | —<sup>[1](#note-1)</sup> |+| pressing Approve twice runs the gated tool once | ✅ | ✅ | ✅ | | —<sup>[1](#note-1)</sup> | ✅ | | —<sup>[1](#note-1)</sup> | | ✅ | | ✅ | | ✅ | | —<sup>[1](#note-1)</sup> | —<sup>[1](#note-1)</sup> | —<sup>[1](#note-1)</sup> |+| pressing Approve on one of two pending approvals runs only that tool | ✅ | ✅ | ✅ | | —<sup>[1](#note-1)</sup> | ✅ | | —<sup>[1](#note-1)</sup> | | ✅ | | ✅ | | ✅ | | —<sup>[1](#note-1)</sup> | —<sup>[1](#note-1)</sup> | —<sup>[1](#note-1)</sup> |+| answering an approval and a question pending together settles both | ✅ | ✅ | ✅ | | —<sup>[1](#note-1)</sup> | ✅ | | —<sup>[1](#note-1)</sup> | | ✅ | | ✅ | | ✅ | | —<sup>[1](#note-1)</sup> | —<sup>[1](#note-1)</sup> | —<sup>[1](#note-1)</sup> |+| pressing Cancel stops the gated tool without running it | ✅ | ✅ | ✅ | | —<sup>[1](#note-1)</sup> | ✅ | | —<sup>[1](#note-1)</sup> | | ✅ | | ✅ | | ✅ | | —<sup>[1](#note-1)</sup> | —<sup>[1](#note-1)</sup> | —<sup>[1](#note-1)</sup> |+| a text reply of approve runs the gated tool | —<sup>[6](#note-6)</sup> | ✅ | ✅ | ✅ | ✅ | —<sup>[2](#note-2)</sup> | —<sup>[2](#note-2)</sup> | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |+| a text reply of cancel stops the gated tool without running it | —<sup>[6](#note-6)</sup> | ✅ | ✅ | ✅ | ✅ | —<sup>[2](#note-2)</sup> | —<sup>[2](#note-2)</sup> | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |+| pressing an option clears the question's buttons | ✅ | ✅ | ✅ | | —<sup>[1](#note-1)</sup> | ✅ | | —<sup>[1](#note-1)</sup> | | ✅ | | ✅ | | ✅ | | —<sup>[1](#note-1)</sup> | —<sup>[1](#note-1)</sup> | —<sup>[1](#note-1)</sup> |+| answering a question by text clears its buttons | ✅ | ✅ | ✅ | ✅ | —<sup>[1](#note-1)</sup> | —<sup>[2](#note-2)</sup> | —<sup>[2](#note-2)</sup> | —<sup>[1](#note-1)</sup> | —<sup>[1](#note-1)</sup> | ❌<sup>[7](#note-7)</sup> | ❌<sup>[7](#note-7)</sup> | ✅ | ✅ | ✅ | ✅ | —<sup>[1](#note-1)</sup> | —<sup>[1](#note-1)</sup> | —<sup>[1](#note-1)</sup> |+| pressing an option names who answered on the question | —<sup>[8](#note-8)</sup> | —<sup>[9](#note-9)</sup> | ❌<sup>[10](#note-10)</sup> | | —<sup>[1](#note-1)</sup> | ❌<sup>[10](#note-10)</sup> | | —<sup>[1](#note-1)</sup> | | ✅ | | ❌<sup>[10](#note-10)</sup> | | ❌<sup>[10](#note-10)</sup> | | —<sup>[1](#note-1)</sup> | —<sup>[1](#note-1)</sup> | —<sup>[1](#note-1)</sup> |+| answering a question by text names who answered on the question | —<sup>[8](#note-8)</sup> | —<sup>[9](#note-9)</sup> | ❌<sup>[10](#note-10)</sup> | ❌<sup>[10](#note-10)</sup> | —<sup>[1](#note-1)</sup> | —<sup>[2](#note-2)</sup> | —<sup>[2](#note-2)</sup> | —<sup>[1](#note-1)</sup> | —<sup>[1](#note-1)</sup> | ❌<sup>[7](#note-7)</sup> | ❌<sup>[7](#note-7)</sup> | ❌<sup>[10](#note-10)</sup> | ❌<sup>[10](#note-10)</sup> | ❌<sup>[10](#note-10)</sup> | ❌<sup>[10](#note-10)</sup> | —<sup>[1](#note-1)</sup> | —<sup>[1](#note-1)</sup> | —<sup>[1](#note-1)</sup> |+| pressing Approve clears the approval's buttons | ✅ | ✅ | ✅ | | —<sup>[1](#note-1)</sup> | ✅ | | —<sup>[1](#note-1)</sup> | | ✅ | | ✅ | | ✅ | | —<sup>[1](#note-1)</sup> | —<sup>[1](#note-1)</sup> | —<sup>[1](#note-1)</sup> |+| approving by text clears the approval's buttons | —<sup>[6](#note-6)</sup> | ✅ | ✅ | ✅ | —<sup>[1](#note-1)</sup> | —<sup>[2](#note-2)</sup> | —<sup>[2](#note-2)</sup> | —<sup>[1](#note-1)</sup> | —<sup>[1](#note-1)</sup> | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | —<sup>[1](#note-1)</sup> | —<sup>[1](#note-1)</sup> | —<sup>[1](#note-1)</sup> |+| pressing Approve names who approved on the approval | —<sup>[8](#note-8)</sup> | —<sup>[9](#note-9)</sup> | ❌<sup>[10](#note-10)</sup> | | —<sup>[1](#note-1)</sup> | ❌<sup>[10](#note-10)</sup> | | —<sup>[1](#note-1)</sup> | | ✅ | | ✅ | | ❌<sup>[10](#note-10)</sup> | | —<sup>[1](#note-1)</sup> | —<sup>[1](#note-1)</sup> | —<sup>[1](#note-1)</sup> |+| approving by text names who approved on the approval | —<sup>[6](#note-6)</sup> | —<sup>[9](#note-9)</sup> | ❌<sup>[10](#note-10)</sup> | ❌<sup>[10](#note-10)</sup> | —<sup>[1](#note-1)</sup> | —<sup>[2](#note-2)</sup> | —<sup>[2](#note-2)</sup> | —<sup>[1](#note-1)</sup> | —<sup>[1](#note-1)</sup> | ❌<sup>[11](#note-11)</sup> | ❌<sup>[11](#note-11)</sup> | ❌<sup>[10](#note-10)</sup> | ❌<sup>[10](#note-10)</sup> | ❌<sup>[10](#note-10)</sup> | ❌<sup>[10](#note-10)</sup> | —<sup>[1](#note-1)</sup> | —<sup>[1](#note-1)</sup> | —<sup>[1](#note-1)</sup> |+| running out of budget opens budget prompt | ✅ | ✅ | ✅ | | ✅ | ✅ | | ✅ | | ✅ | | ✅ | | ✅ | | ✅ | ✅ | ✅ |+| pressing approve on budget prompt allows agent to continue | ✅ | ✅ | ✅ | | —<sup>[1](#note-1)</sup> | ✅ | | —<sup>[1](#note-1)</sup> | | ✅ | | ✅ | | ✅ | | —<sup>[1](#note-1)</sup> | —<sup>[1](#note-1)</sup> | —<sup>[1](#note-1)</sup> |+| reply of approve on budget prompt allows agent to continue | ✅ | ✅ | ✅ | ✅ | ✅ | —<sup>[2](#note-2)</sup> | —<sup>[2](#note-2)</sup> | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |+| pressing stop on budget prompt halts work, next message asks again | ❌<sup>[12](#note-12)</sup> | ❌<sup>[12](#note-12)</sup> | ✅ | ✅ | —<sup>[1](#note-1)</sup> | —<sup>[2](#note-2)</sup> | —<sup>[2](#note-2)</sup> | —<sup>[1](#note-1)</sup> | —<sup>[1](#note-1)</sup> | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | —<sup>[1](#note-1)</sup> | —<sup>[1](#note-1)</sup> | —<sup>[1](#note-1)</sup> |+| reply of stop on budget prompt halts work, next message asks again | ❌<sup>[12](#note-12)</sup> | —<sup>[12](#note-12)</sup> | ✅ | ✅ | ✅ | —<sup>[2](#note-2)</sup> | —<sup>[2](#note-2)</sup> | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |+| query sent during budget prompt answered after budget approval | ❌<sup>[13](#note-13)</sup> | ❌<sup>[13](#note-13)</sup> | ❌<sup>[13](#note-13)</sup> | ❌<sup>[13](#note-13)</sup> | ❌<sup>[13](#note-13)</sup> | —<sup>[2](#note-2)</sup> | —<sup>[2](#note-2)</sup> | ❌<sup>[13](#note-13)</sup> | ❌<sup>[13](#note-13)</sup> | ❌<sup>[13](#note-13)</sup> | ❌<sup>[13](#note-13)</sup> | ❌<sup>[13](#note-13)</sup> | ❌<sup>[13](#note-13)</sup> | ❌<sup>[13](#note-13)</sup> | ❌<sup>[13](#note-13)</sup> | ❌<sup>[13](#note-13)</sup> | ❌<sup>[13](#note-13)</sup> | ❌<sup>[13](#note-13)</sup> |+| a sign-in names the service and shows its sign-in link | ✅ | ✅ | ❌<sup>[14](#note-14)</sup> | ✅ | ✅ | ❌<sup>[15](#note-15)</sup> | ❌<sup>[15](#note-15)</sup> | ❌<sup>[14](#note-14)</sup> | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | —<sup>[16](#note-16)</sup> | ✅ | ✅ |+| a sign-in shows its confirmation code | ✅ | ✅ | ❌<sup>[14](#note-14)</sup> | ✅ | ✅ | ❌<sup>[15](#note-15)</sup> | ❌<sup>[15](#note-15)</sup> | ❌<sup>[14](#note-14)</sup> | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | —<sup>[16](#note-16)</sup> | ✅ | ✅ |+| only the person signing in sees the sign-in link and code | —<sup>[17](#note-17)</sup> | —<sup>[17](#note-17)</sup> | ✅ | —<sup>[17](#note-17)</sup> | —<sup>[17](#note-17)</sup> | ✅ | —<sup>[17](#note-17)</sup> | ✅ | —<sup>[17](#note-17)</sup> | ✅ | —<sup>[17](#note-17)</sup> | ❌<sup>[18](#note-18)</sup> | —<sup>[17](#note-17)</sup> | ✅ | —<sup>[17](#note-17)</sup> | ✅ | ❌<sup>[19](#note-19)</sup> | —<sup>[17](#note-17)</sup> |+| a sign-in without a link shows its instructions | ✅ | ✅ | ❌<sup>[14](#note-14)</sup> | ✅ | ✅ | ❌<sup>[15](#note-15)</sup> | ❌<sup>[15](#note-15)</sup> | ❌<sup>[14](#note-14)</sup> | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌<sup>[15](#note-15)</sup> | ✅ | ✅ |+| after signing in, the agent carries on with the request | ✅ | ✅ | ✅ | | ✅ | ✅ | | ✅ | | ✅ | | ✅ | | ✅ | | ✅ | ✅ | ✅ |+| completing a sign-in tells the person it succeeded | ✅ | ✅ | ✅ | ✅ | ✅ | ❌<sup>[15](#note-15)</sup> | ❌<sup>[15](#note-15)</sup> | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌<sup>[15](#note-15)</sup> | ✅ | ✅ |+| message after ignored sign-in gets an answer, signing in late doesn't run | ✅ | ✅ | ✅ | ✅ | ✅ | —<sup>[2](#note-2)</sup> | —<sup>[2](#note-2)</sup> | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |+| message after ignored sign-in tells user it was cancelled | ✅ | ✅ | ✅ | ✅ | ✅ | —<sup>[2](#note-2)</sup> | —<sup>[2](#note-2)</sup> | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌<sup>[15](#note-15)</sup> | ✅ | ✅ |## Notes1. <a id="note-1"></a>the platform has no buttons a person can press2. <a id="note-2"></a>the platform has no plain-text replies3. <a id="note-3"></a>an answered question's drawer closes, so nothing is left to press-4. <a id="note-4"></a>the approval drawer holds the keyboard; a person answers it with y or n-5. <a id="note-5"></a>only the button interaction handler edits a question; a typed answer leaves it-6. <a id="note-6"></a>one person answers at their own terminal; there's nobody else to tell-7. <a id="note-7"></a>a resolved prompt doesn't say who answered; input.resolved carries no responder-8. <a id="note-8"></a>the card loses its buttons after a typed approval but doesn't say who approved-9. <a id="note-9"></a>a re-raised budget prompt keeps its request id, and eve/client ignores ids it has seen-10. <a id="note-10"></a>eve coalesces the queued reply with the later approve, which then matches no option-11. <a id="note-11"></a>outside a DM the bot says to continue in a direct message but never sends one-12. <a id="note-12"></a>the channel has no default sign-in renderer-13. <a id="note-13"></a>the rule applies only where the conversation is shared or private, and this one is public-14. <a id="note-14"></a>the rule applies only where the conversation is public or shared, and this one is private-15. <a id="note-15"></a>the sign-in prompt, link included, is posted to the whole thread-16. <a id="note-16"></a>the code is in the elicitation body the whole issue sees; who sees the auth signal's link is unverified+4. <a id="note-4"></a>an answered question disables its options, so nothing is left to press+5. <a id="note-5"></a>a tool call's message part holds one input request, so a second ctx.ask on the same call replaces the first+6. <a id="note-6"></a>the approval drawer holds the keyboard; a person answers it with y or n+7. <a id="note-7"></a>only the button interaction handler edits a question; a typed answer leaves it+8. <a id="note-8"></a>one person answers at their own terminal; there's nobody else to tell+9. <a id="note-9"></a>one person answers in their own browser tab; there's nobody else to tell+10. <a id="note-10"></a>a resolved prompt doesn't say who answered; input.resolved carries no responder+11. <a id="note-11"></a>the card loses its buttons after a typed approval but doesn't say who approved+12. <a id="note-12"></a>a re-raised budget prompt keeps its request id, and eve/client ignores ids it has seen+13. <a id="note-13"></a>eve coalesces the queued reply with the later approve, which then matches no option+14. <a id="note-14"></a>outside a DM the bot says to continue in a direct message but never sends one+15. <a id="note-15"></a>the channel has no default sign-in renderer+16. <a id="note-16"></a>the rule applies only where the conversation is shared or private, and this one is public+17. <a id="note-17"></a>the rule applies only where the conversation is public or shared, and this one is private+18. <a id="note-18"></a>the sign-in prompt, link included, is posted to the whole thread+19. <a id="note-19"></a>the code is in the elicitation body the whole issue sees; who sees the auth signal's link is unverifieddiff --git a/packages/eve/src/internal/testing/channel-conformance/conformance.ts b/packages/eve/src/internal/testing/channel-conformance/conformance.tsindex 550cf2117..32cd4d51a 100644--- a/packages/eve/src/internal/testing/channel-conformance/conformance.ts+++ b/packages/eve/src/internal/testing/channel-conformance/conformance.ts@@ -24,6 +24,7 @@ import { teamsDriver } from "#internal/testing/channel-conformance/teams-driver.import { telegramDriver } from "#internal/testing/channel-conformance/telegram-driver.js";import { tuiDriver } from "#internal/testing/channel-conformance/tui-driver.js";import { twilioDriver } from "#internal/testing/channel-conformance/twilio-driver.js";+import { webChatDriver } from "#internal/testing/channel-conformance/web-chat-driver.js";export interface BrokenCell {readonly reason: string;@@ -205,11 +206,13 @@ const TELEGRAM_BROKEN = {const TUI_TYPED_APPROVAL ="the approval drawer holds the keyboard; a person answers it with y or n";const TUI_SINGLE_PERSON = "one person answers at their own terminal; there's nobody else to tell";+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. Each cell is- * one of:+ * the directory whose `hitl-conformance.integration.test.ts` runs it (`web-chat`+ * runs from `test/browser`, since it needs a browser). Each cell is one of:** - must pass;* - not supported: the platform lacks a capability the rule requires, or the@@ -290,6 +293,35 @@ const hitlConformance = {broken: QUEUED_BUDGET_REPLY,},],+ "web-chat": [+ {+ driver: webChatDriver,+ broken: {+ ...QUEUED_BUDGET_REPLY,+ ...budgetPromptNotShown(+ "a re-raised budget prompt keeps its request id, and eve/client ignores ids it has seen",+ "pressing stop on budget prompt halts work, next message asks again",+ ),+ "pressing options of two pending questions answers each with its own option": {+ reason:+ "a tool call's message part holds one input request, so a second ctx.ask on the same call replaces the first",+ symptom:+ /Timed out waiting for (one of the questions \["Which (day|time)|plan_review to return)/u,+ },+ },+ unsupported: {+ "pressing an option of an answered question sends it to the agent as new input":+ "an answered question disables its options, so nothing is left to press",+ // Skipped rather than broken: whether the re-raised prompt shows depends on event timing.+ "reply of stop on budget prompt halts work, next message asks again":+ "a re-raised budget prompt keeps its request id, and eve/client ignores ids it has seen",+ "pressing Approve names who approved on the approval": WEB_CHAT_SINGLE_PERSON,+ "approving by text names who approved on the approval": WEB_CHAT_SINGLE_PERSON,+ "pressing an option names who answered on the question": WEB_CHAT_SINGLE_PERSON,+ "answering a question by text names who answered on the question": WEB_CHAT_SINGLE_PERSON,+ },+ },+ ],} satisfies Record<string, readonly ConformanceChannel[]>;/**@@ -388,12 +420,13 @@ export function renderHitlConformanceMatrix(): string {const nameOf = (entry: ConformanceChannel) => entry.driver().name;const dmOf = (entry: ConformanceChannel) =>all.filter((dm) => dm.dm === true && nameOf(dm) === `${nameOf(entry)}-dm`);- // The TUI, then Chat SDK's bridges, then channels with a DM column, then the- // rest. Each DM column sits right after its channel's shared-thread column.+ // The TUI and web chat, then Chat SDK's bridges, then channels with a DM column,+ // then the rest. Each DM column sits right after its channel's shared-thread column.const group = (entry: ConformanceChannel) => {if (nameOf(entry) === "tui") return 0;- if (nameOf(entry).startsWith("chat-sdk")) return 1;- return dmOf(entry).length > 0 ? 2 : 3;+ if (nameOf(entry) === "web chat") return 1;+ if (nameOf(entry).startsWith("chat-sdk")) return 2;+ return dmOf(entry).length > 0 ? 3 : 4;};const entries = all.filter((entry) => entry.dm !== true)diff --git a/packages/eve/src/internal/testing/channel-conformance/contract.ts b/packages/eve/src/internal/testing/channel-conformance/contract.tsindex 7778b12a5..ccdeca027 100644--- a/packages/eve/src/internal/testing/channel-conformance/contract.ts+++ b/packages/eve/src/internal/testing/channel-conformance/contract.ts@@ -149,14 +149,14 @@ async function approveDeploy(conversation: ChannelConversation, by: Answer) {}/** Once answered, the prompt's message stops offering choices nobody can use anymore. */-function expectButtonsCleared(conversation: ChannelConversation, prompt: string) {- const labels = conversation.shownPrompt(prompt).options.map((option) => option.label);+async function expectButtonsCleared(conversation: ChannelConversation, prompt: string) {+ const labels = (await conversation.shownPrompt(prompt)).options.map((option) => option.label);expect(labels, `the answered prompt still offers ${JSON.stringify(labels)}`).toEqual([]);}/** Once answered, the prompt's message shows everyone in the conversation who answered it. */-function expectResponderNamed(conversation: ChannelConversation, prompt: string) {- const { text } = conversation.shownPrompt(prompt);+async function expectResponderNamed(conversation: ChannelConversation, prompt: string) {+ const { text } = await conversation.shownPrompt(prompt);expect(conversation.personShownAs.some((name) => text.includes(name)),`the answered prompt never names who answered: ${JSON.stringify(text)}`,@@ -198,7 +198,7 @@ async function expectStoppedAndAskedAgain(conversation: ChannelConversation) {// Stopping keeps the session over budget, so the next message asks again.const options = await conversation.waitForQuestion(BUDGET_PROMPT);expect(options.map((option) => option.label).sort()).toEqual(["Approve", "Stop"]);- expect(conversation.replyCount(), "the bot replied after Stop").toBe(0);+ expect(await conversation.replyCount(), "the bot replied after Stop").toBe(0);}const CALENDAR = SIGN_IN_TOOLS.read_calendar;@@ -221,7 +221,9 @@ async function expectSignInToolResult(conversation: ChannelConversation) {async function requestSignIn(conversation: ChannelConversation, message: string) {await conversation.say(message);await conversation.waitForSignIn();- const open = conversation.shownOptions().find((option) => SIGN_IN_OPENERS.test(option.label));+ const open = (await conversation.shownOptions()).find((option) =>+ SIGN_IN_OPENERS.test(option.label),+ );if (open !== undefined) await conversation.press(open);}@@ -451,7 +453,7 @@ export const hitlContract = [requires: ["buttons"],async run(conversation) {await answerSaturday(conversation, "press");- expectButtonsCleared(conversation, PROMPT);+ await expectButtonsCleared(conversation, PROMPT);},},{@@ -461,7 +463,7 @@ export const hitlContract = [variesByConversation: true,async run(conversation) {await answerSaturday(conversation, "text");- expectButtonsCleared(conversation, PROMPT);+ await expectButtonsCleared(conversation, PROMPT);},},{@@ -470,7 +472,7 @@ export const hitlContract = [requires: ["buttons"],async run(conversation) {await answerSaturday(conversation, "press");- expectResponderNamed(conversation, PROMPT);+ await expectResponderNamed(conversation, PROMPT);},},{@@ -480,7 +482,7 @@ export const hitlContract = [variesByConversation: true,async run(conversation) {await answerSaturday(conversation, "text");- expectResponderNamed(conversation, PROMPT);+ await expectResponderNamed(conversation, PROMPT);},},{@@ -489,7 +491,7 @@ export const hitlContract = [requires: ["buttons"],async run(conversation) {await approveDeploy(conversation, "press");- expectButtonsCleared(conversation, APPROVAL_PROMPT);+ await expectButtonsCleared(conversation, APPROVAL_PROMPT);},},{@@ -499,7 +501,7 @@ export const hitlContract = [variesByConversation: true,async run(conversation) {await approveDeploy(conversation, "text");- expectButtonsCleared(conversation, APPROVAL_PROMPT);+ await expectButtonsCleared(conversation, APPROVAL_PROMPT);},},{@@ -508,7 +510,7 @@ export const hitlContract = [requires: ["buttons"],async run(conversation) {await approveDeploy(conversation, "press");- expectResponderNamed(conversation, APPROVAL_PROMPT);+ await expectResponderNamed(conversation, APPROVAL_PROMPT);},},{@@ -518,7 +520,7 @@ export const hitlContract = [variesByConversation: true,async run(conversation) {await approveDeploy(conversation, "text");- expectResponderNamed(conversation, APPROVAL_PROMPT);+ await expectResponderNamed(conversation, APPROVAL_PROMPT);},},{@@ -533,7 +535,7 @@ export const hitlContract = ["Approve","Stop",]);- expect(conversation.replyCount(), "the agent replied before anyone approved").toBe(0);+ expect(await conversation.replyCount(), "the agent replied before anyone approved").toBe(0);},},{@@ -637,7 +639,7 @@ export const hitlContract = [async run(conversation) {await requestSignIn(conversation, READ_CALENDAR);await conversation.waitForRest();- const shared = conversation.sharedText();+ const shared = await conversation.sharedText();expect(shared, "a message everyone sees carried the sign-in link").not.toContain(CALENDAR.url,);diff --git a/packages/eve/src/internal/testing/channel-conformance/harness.ts b/packages/eve/src/internal/testing/channel-conformance/harness.tsindex 42405caed..e8ee2be55 100644--- a/packages/eve/src/internal/testing/channel-conformance/harness.ts+++ b/packages/eve/src/internal/testing/channel-conformance/harness.ts@@ -175,15 +175,15 @@ export interface ChannelConversation {/** Waits until the bot replies to input that carried `text`, however the channel framed it. */waitForReplyTo(text: string): Promise<void>;/** How many test-model replies, plain or reporting a tool result, the bot has shown. */- replyCount(): number;+ replyCount(): Promise<number>;/** Waits for the bot to show a test-model reply, plain or reporting a tool result. */waitForReply(): Promise<void>;/** Waits for the bot to show text matching `pattern`, returning the text that matched. */waitForShown(pattern: string | RegExp): Promise<string>;/** Everything the bot has shown that everyone in the conversation sees, joined. */- sharedText(): string;+ sharedText(): Promise<string>;/** Every choice the bot's messages let a person press now, newest message first. */- shownOptions(): readonly RenderedOption[];+ shownOptions(): Promise<readonly RenderedOption[]>;/** Waits for the turn to hold for a sign-in, however the channel shows it. */waitForSignIn(): Promise<void>;/**@@ -202,7 +202,7 @@ export interface ChannelConversation {* Rules read it once an answer has settled, by which point the bot has had* every chance to update it.*/- shownPrompt(prompt: string): ShownMessage;+ shownPrompt(prompt: string): Promise<ShownMessage>;/** How the person appears in the platform's text, in any form. */readonly personShownAs: readonly string[];runsOf(tool: CountedTool): number;@@ -236,13 +236,13 @@ export interface ClientView {/** The person presses one shown choice. */press(option: RenderedOption): Promise<void>;/** The bot replies the client shows now. */- replies(): readonly string[];+ replies(): readonly string[] | Promise<readonly string[]>;/** The message that asked `prompt` as it stands now; see {@link ChannelConversation.shownPrompt}. */- shownPrompt?(prompt: string): ShownMessage;+ shownPrompt?(prompt: string): ShownMessage | Promise<ShownMessage>;/** How the person appears in the client's text, in any form. */readonly personShownAs?: readonly string[];/** Everything the client shows now that a person can read or open, one entry per message. */- shown(): readonly ShownText[];+ shown(): readonly ShownText[] | Promise<readonly ShownText[]>;/** What the client shows now, for timeout errors. */describe(): string;/** Stops the client and releases anything it holds, such as its event stream. */@@ -678,8 +678,8 @@ async function converse(const replyWait = <T>(label: string, select: (reply: string) => T | undefined) =>wait(label,- () => {- for (const reply of view.replies()) {+ async () => {+ for (const reply of await view.replies()) {const selected = select(reply);if (selected !== undefined) return selected;}@@ -687,9 +687,10 @@ async function converse(},view.describe,);- const replyCount = () =>- view.replies().filter((reply) => isMockReplyTo(reply, "") || reply.startsWith("Used "))- .length;+ const replyCount = async () =>+ (await view.replies()).filter(+ (reply) => isMockReplyTo(reply, "") || reply.startsWith("Used "),+ ).length;let signInsCompleted = 0;const conversation: ChannelConversation = {@@ -727,27 +728,25 @@ async function converse(}),replyCount,waitForReply: async () =>- void (await wait("a reply", () => (replyCount() > 0 ? true : undefined), view.describe)),+ void (await wait(+ "a reply",+ async () => ((await replyCount()) > 0 ? true : undefined),+ view.describe,+ )),waitForShown: (pattern) =>wait(`the bot to show ${String(pattern)}`,- () =>- view- .shown()+ async () =>+ (await view.shown()).map(({ text }) => text).find((text) =>typeof pattern === "string" ? text.includes(pattern) : pattern.test(text),),view.describe,),- shownOptions: () =>- view- .shown()- .toReversed()- .flatMap(({ options }) => options),- sharedText: () =>- view- .shown()+ shownOptions: async () => (await view.shown()).toReversed().flatMap(({ options }) => options),+ sharedText: async () =>+ (await view.shown()).filter((shown) => !shown.onlyPerson).map(({ text }) => text).join("\n"),@@ -773,9 +772,9 @@ async function converse(},runsOf: (tool) => runs[tool],waitForRest: () => waitForRest([...sessions.values()], wait),- shownPrompt(prompt) {+ async shownPrompt(prompt) {if (view.shownPrompt === undefined) throw new Error(`${label} cannot read shown messages.`);- return view.shownPrompt(prompt);+ return await view.shownPrompt(prompt);},personShownAs: view.personShownAs ?? [],};diff --git a/packages/eve/src/internal/testing/channel-conformance/web-chat-driver.ts b/packages/eve/src/internal/testing/channel-conformance/web-chat-driver.tsnew file mode 100644index 000000000..6cc2eb511--- /dev/null+++ b/packages/eve/src/internal/testing/channel-conformance/web-chat-driver.ts@@ -0,0 +1,372 @@+import { execFile } from "node:child_process";+import { cp, mkdir, mkdtemp, readFile, symlink, writeFile } from "node:fs/promises";+import { createServer, type IncomingMessage, type ServerResponse } from "node:http";+import type { AddressInfo } from "node:net";+import { tmpdir } from "node:os";+import { join } from "node:path";+import { fileURLToPath } from "node:url";+import { promisify } from "node:util";++import type { Locator, Page } from "playwright-core";++import type {+ ClientDriver,+ RenderedOption,+ ShownText,+} from "#internal/testing/channel-conformance/harness.js";++/** The Web Chat template `eve integration setup web` installs, as the docs registry ships it. */+const TEMPLATE_ROOT = fileURLToPath(+ new URL("../../../../../../apps/docs/registry/channel/web/", import.meta.url),+);+/** The registry item that lists the template's dependencies, as `eve integration setup web` installs them. */+const REGISTRY_PATH = fileURLToPath(+ new URL("../../../../../../apps/docs/registry.json", import.meta.url),+);+/** Outside the workspace, so the template's pins never touch the workspace lockfile. */+const INSTALL_ROOT = join(tmpdir(), "eve-web-chat-template");+const EVE_SOURCE_ROOT = fileURLToPath(new URL("../../../", import.meta.url));++const ENTRY_ID = "virtual:web-chat-entry";+// Mounts the template's chat the way its `app/page.tsx` does, without Next's server.+const ENTRY_SOURCE = `+import { createElement } from "react";+import { createRoot } from "react-dom/client";+import { AgentChat } from "@/app/_components/agent-chat";+import "@/app/globals.css";+createRoot(document.getElementById("root")).render(createElement(AgentChat));+`;+const PAGE_HTML =+ '<!doctype html><html><head><link rel="stylesheet" href="/app.css"></head><body><div id="root"></div><script type="module" src="/app.js"></script></body></html>';++const COMPOSER_PLACEHOLDER = "Send a message…";++let bundled: Promise<string> | undefined;++/**+ * Drives the Web Chat template's real React page in headless Chromium. The+ * page is the registry's `AgentChat` bundled with Vite and served from a local+ * origin that forwards every other request to the agent, so the browser's+ * `useEveAgent` talks to `eveChannel` exactly as it does behind `withEve()`.+ * It reads only the DOM and acts only through clicks and keys.+ */+export function webChatDriver(): ClientDriver {+ return {+ name: "web chat",+ capabilities: ["buttons", "text-replies"],+ // A browser tab shows only the person using it.+ surface: "private",+ async open(host, wait) {+ const assets = await (bundled ??= bundleTemplate());+ const server = await servePage(host, assets);+ const { chromium } = await import("playwright-core");+ const browser = await chromium.launch();+ const close = async () => {+ await browser.close();+ await server.close();+ };+ const page = await browser.newPage();+ // A card can re-render between reading a button and using it; fail fast and read again.+ page.setDefaultTimeout(2_000);+ const errors: string[] = [];+ page.on("pageerror", (error) => void errors.push(error.message));+ page.on("console", (message) => {+ if (message.type() === "error") errors.push(message.text());+ });+ let seen = "";+ const look = async () => {+ seen = await page+ .locator("body")+ .innerText({ timeout: 1_000 })+ .catch(() => seen);+ };+ const describe = () => `Page errors: ${JSON.stringify(errors)}\nPage text:\n${seen}`;+ const composer = page.getByPlaceholder(COMPOSER_PLACEHOLDER);++ try {+ await page.goto(server.url);+ await wait(+ "the composer",+ async () => {+ await look();+ return (await composer.isEditable()) ? true : undefined;+ },+ describe,+ );+ } catch (error) {+ await close();+ throw error;+ }++ return {+ async say(text) {+ await composer.fill(text);+ await composer.press("Enter");+ },+ waitForQuestion: (prompts) =>+ wait(+ `one of the questions ${JSON.stringify(prompts)}`,+ async () => {+ await look();+ for (const prompt of prompts) {+ const options = await promptOptions(page, prompt).catch(() => undefined);+ if (options !== undefined) return { options, prompt };+ }+ return undefined;+ },+ describe,+ ),+ async press(option) {+ const button = option.handle as Locator;+ // A press on a button that's disabled, or that a re-render removed+ // mid-press, lands nowhere, as it would for a person.+ const pressable =+ (await button.count()) > 0 && (await button.isEnabled().catch(() => false));+ if (pressable) await button.click().catch(() => {});+ },+ async replies() {+ await look();+ // Each assistant text part renders as its own Streamdown block.+ return await page.locator(".is-assistant .size-full").allInnerTexts();+ },+ async shownPrompt(prompt) {+ await look();+ return {+ id: prompt,+ options: (await promptOptions(page, prompt)) ?? [],+ text: seen,+ };+ },+ async shown() {+ await look();+ const shown: ShownText[] = [];+ for (const message of await page.locator(".is-assistant").all()) {+ const links: string[] = [];+ for (const anchor of await message.locator("a[href]").all()) {+ links.push((await anchor.getAttribute("href"))!);+ }+ const text = [await message.innerText(), ...links].join("\n");+ const options = (await readButtons(message.getByRole("button"))) ?? [];+ shown.push({ onlyPerson: true, options, text });+ }+ return shown;+ },+ describe,+ close,+ };+ },+ };+}++/** The choices a question or approval titled `prompt` offers now, if it's open. */+async function promptOptions(page: Page, prompt: string): Promise<RenderedOption[] | undefined> {+ return (+ (await questionOptions(page, prompt)) ??+ (await approvalOptions(page, prompt)) ??+ (await openEndedQuestion(page, prompt))+ );+}++/** An open-ended `ask_question` card: the prompt above a text field while it's open. */+async function openEndedQuestion(page: Page, prompt: string): Promise<[] | undefined> {+ const label = page.locator("p").getByText(prompt, { exact: true }).last();+ if ((await label.count()) === 0) return undefined;+ const field = label.locator("xpath=..").getByRole("textbox", { name: "Answer" });+ return (await field.count()) > 0 && (await field.isEditable()) ? [] : undefined;+}++/** An `ask_question` card: one radio per option while the question is open. */+async function questionOptions(page: Page, prompt: string): Promise<RenderedOption[] | undefined> {+ const group = page.getByRole("radiogroup", { exact: true, name: prompt }).last();+ if ((await group.count()) === 0) return undefined;+ return await readButtons(group.getByRole("radio"));+}++/** A tool approval: the prompt above one button per choice until it's answered. */+async function approvalOptions(page: Page, prompt: string): Promise<RenderedOption[] | undefined> {+ const label = page.locator("p").getByText(prompt, { exact: true }).last();+ if ((await label.count()) === 0) return undefined;+ return await readButtons(label.locator("xpath=..").getByRole("button"));+}++/** The buttons a person can press now, labelled by their first line of text. */+async function readButtons(buttons: Locator): Promise<RenderedOption[] | undefined> {+ const all = await buttons.all();+ if (all.length === 0) return undefined;+ const options: RenderedOption[] = [];+ for (const button of all) {+ if (!(await button.isEnabled())) return undefined;+ const label = (await button.innerText()).split("\n")[0]!.trim();+ options.push({ handle: button, label });+ }+ return options;+}++/**+ * Copies the template into a fresh app root beside the dependencies its+ * registry item lists, the way `eve integration setup web` lays out an app.+ */+async function installTemplate(): Promise<string> {+ const registry = JSON.parse(await readFile(REGISTRY_PATH, "utf8")) as {+ items: { name: string; dependencies?: string[] }[];+ };+ const item = registry.items.find(({ name }) => name === "channel/web");+ if (item?.dependencies === undefined) {+ throw new Error(`${REGISTRY_PATH} has no channel/web item with dependencies.`);+ }+ const dependencies = Object.fromEntries(+ item.dependencies.map((spec) => {+ const at = spec.lastIndexOf("@");+ return at > 0 ? [spec.slice(0, at), spec.slice(at + 1)] : [spec, "latest"];+ }),+ );+ const manifest = `${JSON.stringify({ name: "web-chat-template", private: true, dependencies }, null, 2)}\n`;+ // Written only after an install succeeds, so a failed one is retried.+ const installedPath = join(INSTALL_ROOT, "installed.json");+ if ((await readFile(installedPath, "utf8").catch(() => undefined)) !== manifest) {+ await mkdir(INSTALL_ROOT, { recursive: true });+ await writeFile(join(INSTALL_ROOT, "package.json"), manifest);+ await promisify(execFile)("pnpm", ["install", "--ignore-workspace", "--prefer-offline"], {+ cwd: INSTALL_ROOT,+ });+ await writeFile(installedPath, manifest);+ }+ const appRoot = await mkdtemp(join(tmpdir(), "eve-web-chat-app-"));+ await cp(TEMPLATE_ROOT, appRoot, {+ filter: (source) => !source.slice(TEMPLATE_ROOT.length).startsWith("node_modules"),+ recursive: true,+ });+ await symlink(join(INSTALL_ROOT, "node_modules"), join(appRoot, "node_modules"), "dir");+ return appRoot;+}++async function bundleTemplate(): Promise<string> {+ // Loaded on demand so the other channels' conformance files skip the bundler.+ const { build, defaultClientConditions } = await import("vite");+ const appRoot = await installTemplate();+ const outDir = await mkdtemp(join(tmpdir(), "eve-web-chat-"));+ await build({+ build: {+ copyPublicDir: false,+ minify: false,+ outDir,+ rollupOptions: {+ input: ENTRY_ID,+ output: {+ assetFileNames: ({ names }) =>+ names.some((name) => name.endsWith(".css"))+ ? "app.css"+ : "assets/[name]-[hash][extname]",+ entryFileNames: "app.js",+ },+ // Next reads the template's "use client" directives; a plain bundle doesn't need them.+ onwarn(warning, warn) {+ if (warning.code !== "MODULE_LEVEL_DIRECTIVE") warn(warning);+ },+ },+ },+ configFile: false,+ logLevel: "warn",+ plugins: [+ {+ name: "web-chat-entry",+ resolveId: (id) => (id === ENTRY_ID ? `\0${ENTRY_ID}` : undefined),+ load: (id) => (id === `\0${ENTRY_ID}` ? ENTRY_SOURCE : undefined),+ },+ ],+ resolve: {+ alias: [+ { find: /^@\//u, replacement: `${appRoot}/` },+ // Test the eve source under change, not its last build.+ { find: /^eve\/react$/u, replacement: join(EVE_SOURCE_ROOT, "react/index.ts") },+ ],+ // Resolves eve's `#*.js` imports to `src/*.ts`.+ conditions: [...defaultClientConditions, "eve-source"],+ dedupe: ["react", "react-dom"],+ },+ root: appRoot,+ });+ return outDir;+}++/**+ * Serves the bundled page and forwards everything else to `host` through the+ * global `fetch`, which the harness routes to the eve channel. Response bodies+ * stream through, so the browser sees the session stream as it's written.+ */+async function servePage(host: string, assets: string) {+ const server = createServer((request, response) => {+ void handle(request, response).catch((error: unknown) => {+ if (!response.headersSent) response.writeHead(500);+ response.end(String(error));+ });+ });++ async function handle(request: IncomingMessage, response: ServerResponse) {+ const url = new URL(request.url ?? "/", "http://localhost");+ if (request.method === "GET" && url.pathname === "/") {+ response.writeHead(200, { "content-type": "text/html" }).end(PAGE_HTML);+ return;+ }+ if (request.method === "GET" && /^\/(?:app\.(?:js|css)|assets\/[\w.-]+)$/u.test(url.pathname)) {+ response+ .writeHead(200, { "content-type": contentType(url.pathname) })+ .end(await readFile(join(assets, url.pathname)));+ return;+ }+ const headers = new Headers();+ for (const [name, value] of Object.entries(request.headers)) {+ if (typeof value === "string" && !["connection", "host"].includes(name)) {+ headers.set(name, value);+ }+ }+ const hasBody = request.method !== "GET" && request.method !== "HEAD";+ const upstream = await fetch(new URL(`${url.pathname}${url.search}`, host), {+ body: hasBody ? await readBody(request) : undefined,+ headers,+ method: request.method,+ });+ const responseHeaders = Object.fromEntries(+ [...upstream.headers].filter(+ ([name]) => !["content-length", "transfer-encoding"].includes(name),+ ),+ );+ response.writeHead(upstream.status, responseHeaders);+ if (upstream.body === null) {+ response.end();+ return;+ }+ const reader = upstream.body.getReader();+ // A closed tab releases the session stream it was reading.+ response.on("close", () => void reader.cancel().catch(() => {}));+ for (;;) {+ const { done, value } = await reader.read();+ if (done) break;+ response.write(value);+ }+ response.end();+ }++ await new Promise<void>((resolve) => server.listen(0, "127.0.0.1", resolve));+ const { port } = server.address() as AddressInfo;+ return {+ url: `http://127.0.0.1:${port}/`,+ close: () =>+ new Promise<void>((resolve) => {+ server.closeAllConnections();+ server.close(() => resolve());+ }),+ };+}++async function readBody(request: IncomingMessage): Promise<Buffer> {+ const chunks: Buffer[] = [];+ for await (const chunk of request) chunks.push(chunk as Buffer);+ return Buffer.concat(chunks);+}++function contentType(pathname: string): string {+ if (pathname.endsWith(".js")) return "text/javascript";+ if (pathname.endsWith(".css")) return "text/css";+ return "application/octet-stream";+}diff --git a/packages/eve/test/browser/web-chat-hitl-conformance.test.ts b/packages/eve/test/browser/web-chat-hitl-conformance.test.tsnew file mode 100644index 000000000..80411f78b--- /dev/null+++ b/packages/eve/test/browser/web-chat-hitl-conformance.test.ts@@ -0,0 +1,3 @@+import { describeHitlConformance } from "#internal/testing/channel-conformance/conformance.js";++describeHitlConformance("web-chat");diff --git a/packages/eve/vitest.browser.config.ts b/packages/eve/vitest.browser.config.tsnew file mode 100644index 000000000..554bb370b--- /dev/null+++ b/packages/eve/vitest.browser.config.ts@@ -0,0 +1,36 @@+import { defineConfig } from "vitest/config";++import { workflow } from "./src/internal/testing/workflow-vitest-plugin.js";++/**+ * Browser tests.+ *+ * Drives client templates' real React pages in headless Chromium against an+ * in-memory agent, like the integration tier, but over a real HTTP listener and+ * a real browser. These run in their own CI job, which installs Chromium with+ * `pnpm --filter eve exec playwright-core install chromium-headless-shell`.+ * The first run also installs the Web Chat template's registry dependencies+ * into a temp directory outside the workspace, so it needs the npm registry.+ */+export default defineConfig({+ plugins: [workflow()],+ resolve: {+ alias: [+ {+ find: /^#compiled\/(.+)\.js$/,+ replacement: new URL("./.generated/compiled/$1.js", import.meta.url).pathname,+ },+ {+ find: /^#(.+)\.js$/,+ replacement: new URL("./src/$1.ts", import.meta.url).pathname,+ },+ ],+ },+ test: {+ environment: "node",+ globalSetup: ["./test/setup/clear-workflow-cache.ts"],+ include: ["test/browser/**/*.test.ts"],+ setupFiles: ["./test/setup/mock-ai-gateway.ts"],+ testTimeout: 60_000,+ },+});diff --git a/packages/eve/vitest.unit.config.ts b/packages/eve/vitest.unit.config.tsindex a330cfb56..d0ff5c7d5 100644--- a/packages/eve/vitest.unit.config.ts+++ b/packages/eve/vitest.unit.config.ts@@ -34,6 +34,7 @@ export default defineConfig({"src/**/*.integration.test.ts","src/**/*.scenario.test.ts","test/**/*.integration.test.ts",+ "test/browser/**","test/framework-fixtures/**","test/scenarios/**",],diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex 7b9d6e55f..d11eb254d 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -401,7 +401,7 @@ importers:version: 0.2.1(eve@packages+eve)'@browserbasehq/eve':specifier: ^0.1.0- version: 0.1.0(@cfworker/[email protected])(eve@packages+eve)([email protected])+ version: 0.1.0(@cfworker/[email protected])(eve@packages+eve)([email protected])([email protected])'@chat-adapter/gchat':specifier: 4.41.0@@ -1773,6 +1773,9 @@ importers:picocolors:specifier: 'catalog:'version: 1.1.1+ playwright-core:+ specifier: 1.63.0+ version: 1.63.0react:specifier: 'catalog:'version: 19.2.6@@ -12440,6 +12443,11 @@ packages:resolution: {integrity: sha512-5O9bkbq0APQIkhptyZwp0gUgheCeImGPFo4hvPF2M5xBmgsUYzsUPHCfMye2xyeRE1zvQBKtziaC3jPgnHE1tw==}+ resolution: {integrity: sha512-rYCsBF/M5HjUch52bbtVONEFjv6Xu8sm8h72dNlR5bzIE1fvC/bxgspzkjSfU+MweEMmPM8KJebG6nnyxo5mCg==}+ engines: {node: '>=20'}+ hasBin: true+resolution: {integrity: sha512-Nc3IT5yHzflTfbjgqWcCPpo7DaKy4FnpB0l/zCAW0Tc7jxAiuqSxHasntB3D7887LSrA93kDJ9IXovxJYxyLCA==}engines: {node: '>=4'}@@ -15474,10 +15482,10 @@ snapshots:'@braintree/[email protected]': {}- '@browserbasehq/[email protected](@cfworker/[email protected])(eve@packages+eve)([email protected])':+ '@browserbasehq/[email protected](@cfworker/[email protected])(eve@packages+eve)([email protected])([email protected])':dependencies:'@browserbasehq/sdk': 2.16.0- '@browserbasehq/stagehand': 3.7.0(@cfworker/[email protected])([email protected])([email protected])+ '@browserbasehq/stagehand': 3.7.0(@cfworker/[email protected])([email protected])([email protected])([email protected])eve: link:packages/evezod: 4.4.3transitivePeerDependencies:@@ -15501,7 +15509,7 @@ snapshots:transitivePeerDependencies:- encoding- '@browserbasehq/[email protected](@cfworker/[email protected])([email protected])([email protected])':+ '@browserbasehq/[email protected](@cfworker/[email protected])([email protected])([email protected])([email protected])':dependencies:'@ai-sdk/provider': 2.0.4'@anthropic-ai/sdk': 0.39.0@@ -15535,6 +15543,7 @@ snapshots:bufferutil: 4.1.0chrome-launcher: 1.2.1([email protected])ollama-ai-provider-v2: 1.5.5([email protected])+ playwright-core: 1.63.0transitivePeerDependencies:- '@cfworker/json-schema'- encoding@@ -27634,6 +27643,8 @@ snapshots:transitivePeerDependencies:- react+ [email protected]: {}+