Skip to content

Open-source AI browser agent for Chrome and Firefox (monorepo) 🧠

WhatsApp: open chat rows and name the control that confirms a contact

Claude635cb71f117f
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0d464510a..65f5413b4 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -16,6 +16,7 @@ This changelog was generated from the repository Git history and release tags. V
- Selecting text on a page now shows a small bar, **Translate | Explain | Proofread | More…**, instead of the single `?` button. Translate, Explain and Proofread answer in a card next to the selection: Translate shows the detected source language, the original text and a target-language picker, and every card has an "Ask a follow-up" box that, once the answer is there, continues in the side panel with the card's answer as context. **More…** opens the same popup the `?` button opened (Summarize, Quiz me, Humanize, a question box and Hide this; Translate, Explain and Proofread are on the bar, so they are not repeated there). A card sends the selected text to your configured model provider, like any other selection action; selections over 4,000 characters go to the side panel instead of a card. A card answer that reaches the model's output limit says it was cut off and offers to continue in the side panel, which picks up from the unfinished text instead of starting over (a side-panel reply that is cut off again says so, including when an OpenAI Responses model reports the limit as an error, in which case the text it wrote is kept and the call still counts toward your cloud-cost allowance), and closing or redoing a card, or reloading or leaving the page, cancels the request it no longer needs. Chrome and Firefox.
### Fixed
+- WhatsApp: sending something to a contact no longer stalls at the chat. Asked to download a video from X and send it to a contact on WhatsApp, WebBrain clicked the contact's chat in the list and nothing happened: WhatsApp's chat rows are grid cells that ignore a click sent by a script, and Chrome's automatic real-mouse retry left grid cells out. A row like that now gets the retry, like any other list row. Once the chat was open, WebBrain blocked every message action until it had confirmed who the chat is with, but it only told the model to read the page again and retry, so the model clicked Attach and the chat row over and over, then gave up. The block now names the exact control to click: the contact name in the chat header, then the Close button of the Contact info panel it opens. Clicking another chat in the list was blocked too, which left no way to reach the right chat. A chat-list row now always opens its chat, and in a request that names the person, the contact check follows the chat WebBrain opens until the check starts, so it confirms that person rather than whichever chat was open; a request for the open chat itself keeps its check on that chat, and one run still confirms one chat. With Lean mode on, WhatsApp Web and Telegram Web also offer `chat_observe` and `chat_send`, which these checks and the plan rely on. Chrome and Firefox; the real-mouse retry is Chrome's.
- Automatic mode: correcting or adding to a request while WebBrain is still reading no longer keeps the task stuck in Ask. When you wrote “download this” and then “and then send it to Defne on WhatsApp!”, WebBrain asked for Act quoting both messages, and the check accepted only words from the latest message, and refused any hand-off after a correction anyway. It answered that you should switch to Act, which the side panel no longer offers. Your corrections now count as your own words, and they carry into the Act run, which applies them before it does anything.
- Chrome: sending a follow-up or a selection action to WebBrain while the side panel is already open no longer closes it. Each side panel now tells the background whether it is on screen, and the background skips re-opening a panel that is already showing and hands it the prompt directly A panel that was open while the background restarted tells the new worker about itself at once instead of after a delay, so a request in that moment does not close it. The same holds for actions chosen on a selection in WebBrain's PDF viewer, where a panel that was closed is opened once rather than twice. A side panel that the browser moves to another window (its tab dragged out) now reports its new window, so an action in that window no longer closes it and an action in the old window opens a panel again. The PDF viewer keeps its own window up to date the same way, so a viewer tab dragged to another window reports where it is now, taking the new window from the tab-attached event rather than from a lookup a quick click could outrun. A card answer whose request is the one to reach the cloud cost allowance now says so under the answer instead of showing it as an ordinary success. The room a card leaves for the prompt in a small context window is now estimated as a worst case (a token per ASCII character, four for anything else), so dense text such as minified code or hashes on a 4k local model is reported as too long for the model instead of being sent a request the backend rejects. Continuing a cut-off Proofread in the side panel no longer asks for the whole corrected version again alongside the request for only the remainder. Continuing a cut-off card answer, or asking a follow-up, in the side panel now sizes the reply to what the model's context window leaves, so a small local model is not sent a request it rejects; when nothing fits it says the selection is too long for the model instead of failing. A card answer is now held to a fixed 64,000-character limit that is enforced when it is produced and when the card receives it, so a follow-up or a continuation carries exactly what the card shows instead of an answer silently shortened by a token-ratio estimate; a longer one is cut and offered to the side panel. A selection too long for the model's context window is reported as an error in the card instead of being offered as a continuation the side panel would refuse as well. Continuing a long cut-off answer on a small-context model now sends the side panel only the end of it, and a follow-up question about a long card answer only the start of it, trimmed to what the model's window leaves beside the selection and the question, instead of the whole text, which left no room to reply and was refused as too long. WebBrain's own system prompt is now counted at the pace of prose rather than the worst case when this is estimated, so a 4k local model can continue or ask a follow-up about a moderately long answer from a short selection. A side-panel reply that reaches the cloud cost allowance (including a cut-off OpenAI Responses reply that is recovered) now says so under the reply instead of leaving the next continuation to fail unexplained.
- Stopping a task while WebBrain was waiting for page navigation to settle now stops it immediately. The pending settle step previously kept waiting and could let the run continue after you chose Stop.
diff --git a/docs/agent-tools.md b/docs/agent-tools.md
index 6075a4aca..6857867d6 100644
--- a/docs/agent-tools.md
+++ b/docs/agent-tools.md
@@ -24,7 +24,8 @@ Tier defaults and resolution rules are documented in
In **lean mode** (Settings → General → Lean mode), an Act run gets 17 of these
tools instead of its tier's set, with the same schemas, and a short prompt; see
-[lean mode](lean-mode.md).
+[lean mode](lean-mode.md). On WhatsApp Web and Telegram Web it also gets
+`chat_observe` and `chat_send`, which the recipient guard there relies on.
## Accessibility read budgets
diff --git a/docs/architecture.md b/docs/architecture.md
index c6dd93c18..f57120390 100644
--- a/docs/architecture.md
+++ b/docs/architecture.md
@@ -1365,7 +1365,7 @@ Jobs are stored in `chrome.storage.local` under the key `wb_scheduled_jobs` as a
110+ adapters inject site-specific guidance into the first user message (and re-inject on navigation to a different matched site). Only ONE adapter fires at a time (`getActiveAdapter(url)` returns the first match). See `docs/site-adapters.md` for how to write one. Each matched adapter emits a content-free `adapter_match` trace note with its identity, revision, and whether notes were injected. High-evidence repeated tasks may additionally expose validated V2 workflow jobs; the planner selects an app-owned ID semantically, the binding is revalidated on the live pre-execution URL, and the executor receives its trusted stages/evidence contract. Required submissions need dispatch plus post-submit observation, while jobs with a trusted complete inventory may require an explicit job-bound complete-coverage marker whose count matches terminal current-task ledger rows.
-Adapters may also expose narrowly scoped runtime policy. Douyin `/chat` is the first `messaging.verifyActiveRecipient` route. The structured planner resolves an anaphoric recipient to `named` only when authentic prior-user context identifies exactly one target; unresolved pronouns clarify, and words that refer back to someone named earlier never mean the open thread. `active_conversation` is reserved for a request that points at the conversation on screen itself instead of naming it ("reply here", "this one", "this user", in any language): the planner never sees the page, so it does not ask who that is. An `active_conversation` planner target must first be pinned to exactly one strong visible header identity, while planning or, where the identity needs the page's own preparation first (Gmail's collapsed reply composer, a native WhatsApp contact drawer), at the first send in the thread open when the run was authorized; ambiguous or missing evidence stops for clarification. Its `recipients` are only the people the same request also names. On a route where a conversation reaches one person, the pinned conversation is the target and stays authorized for the whole task, while each named person is kept as requested (`requestedMessaging`, shown in the reviewed plan) and confirmed on WebBrain's recipient card before the first send to them. Native WhatsApp checks a contact through its drawer once per run, for the first chat the run looks at; once that check is invalidated, as by a change of the chat selection, the observer and the recipient probe report `native_whatsapp_contact_check_spent`, and the agent is told that the chat needs a new request instead of being sent to retry. A chat only hidden for a moment, as behind a modal, is not a spent check. On a recipient-set route such as mail the named people are not added to the pin, since a planner copies names as the user wrote them while a mail composer shows addresses. The pin is the thread's recipients as before: one taken while planning sends a differing set to the card, while one taken at the first send from Gmail's collapsed reply composer is whatever that composer holds then, an existing limit. The first user message's screenshot note is dropped from the planner's copy of the task with the image the planner never receives. Immediately before a send-like click, submitted field, or Enter press, the content script resolves the exact target and a lower-page layout composer, then collects only unique header evidence from the narrow, non-scrollable region above it. Enter or submitted field input in a different editable is conclusively non-message only when structural semantics positively identify a search or navigation field; an alternate reply/forward/split-pane composer remains inconclusive and therefore cannot bypass recipient verification. A distant general control likewise remains inconclusive rather than being declared safe. A semantic conversation row in a separate left rail is conclusively navigation-only, allowing recovery to the requested thread whether or not the short rail currently overflows; nested row buttons, links, and their leaf descendants plus controls outside that structure remain inconclusive. The agent requires exact normalized identity equality and returns a no-dispatch blocker on missing, inconclusive, ambiguous, or mismatched evidence, and protected Enter dispatch permits exactly one keypress per verification. Every authorized `click`, `click_ax`, `set_field({submit:true})`, and composer Enter receives a one-use binding to the exact action target, composer, URL, and identity set. Direct content dispatches and Chrome's trusted CDP mouse/key paths consume and revalidate it immediately before `el.click()`, `mousePressed`, or Enter, after any field reconciliation and combobox delays; protected `click_ax` never issues a second no-progress fallback click. Search-result text, message content, input values, generic page text, failed probes, and edited plans with stale hidden metadata cannot authorize a send. Dispatch-capable tools whose effects cannot be bound to the probed recipient (`iframe_click`, `execute_js`, WebMCP execution, and `upload_file`, whose change event may auto-send) are unavailable on this protected route. Deterministic saved-workflow replay has no planner-owned recipient target, so a workflow with any potentially dispatching step scoped to a protected messaging route stops before page actions and directs the user to run a normal Act task with a named recipient; a per-step check also covers legacy workflows whose scope metadata is incomplete.
+Adapters may also expose narrowly scoped runtime policy. Douyin `/chat` is the first `messaging.verifyActiveRecipient` route. The structured planner resolves an anaphoric recipient to `named` only when authentic prior-user context identifies exactly one target; unresolved pronouns clarify, and words that refer back to someone named earlier never mean the open thread. `active_conversation` is reserved for a request that points at the conversation on screen itself instead of naming it ("reply here", "this one", "this user", in any language): the planner never sees the page, so it does not ask who that is. An `active_conversation` planner target must first be pinned to exactly one strong visible header identity, while planning or, where the identity needs the page's own preparation first (Gmail's collapsed reply composer, a native WhatsApp contact drawer), at the first send in the thread open when the run was authorized; ambiguous or missing evidence stops for clarification. Its `recipients` are only the people the same request also names. On a route where a conversation reaches one person, the pinned conversation is the target and stays authorized for the whole task, while each named person is kept as requested (`requestedMessaging`, shown in the reviewed plan) and confirmed on WebBrain's recipient card before the first send to them. Native WhatsApp checks a contact through its drawer once per run, for the first chat the run looks at, except that a request naming its recipient may first open that person's chat from the chat list: its anchor follows the chat selection until the run arms its check with the guarded contact-name click. Once that check is invalidated, as by a change of the chat selection after it was armed (or at all, in a request for the open chat), the observer and the recipient probe report `native_whatsapp_contact_check_spent`, and the agent is told that the chat needs a new request instead of being sent to retry. Before the check, a blocked message action names the exact contact-name or Close control to click (`nativeWhatsappRepairTarget`). A chat only hidden for a moment, as behind a modal, is not a spent check. On a recipient-set route such as mail the named people are not added to the pin, since a planner copies names as the user wrote them while a mail composer shows addresses. The pin is the thread's recipients as before: one taken while planning sends a differing set to the card, while one taken at the first send from Gmail's collapsed reply composer is whatever that composer holds then, an existing limit. The first user message's screenshot note is dropped from the planner's copy of the task with the image the planner never receives. Immediately before a send-like click, submitted field, or Enter press, the content script resolves the exact target and a lower-page layout composer, then collects only unique header evidence from the narrow, non-scrollable region above it. Enter or submitted field input in a different editable is conclusively non-message only when structural semantics positively identify a search or navigation field; an alternate reply/forward/split-pane composer remains inconclusive and therefore cannot bypass recipient verification. A distant general control likewise remains inconclusive rather than being declared safe. A semantic conversation row in a separate left rail is conclusively navigation-only, allowing recovery to the requested thread whether or not the short rail currently overflows, and a row of WhatsApp's native chat list is navigation-only even while the open chat's contact is unconfirmed; nested row buttons, links, and their leaf descendants plus controls outside that structure remain inconclusive. The agent requires exact normalized identity equality and returns a no-dispatch blocker on missing, inconclusive, ambiguous, or mismatched evidence, and protected Enter dispatch permits exactly one keypress per verification. Every authorized `click`, `click_ax`, `set_field({submit:true})`, and composer Enter receives a one-use binding to the exact action target, composer, URL, and identity set. Direct content dispatches and Chrome's trusted CDP mouse/key paths consume and revalidate it immediately before `el.click()`, `mousePressed`, or Enter, after any field reconciliation and combobox delays; protected `click_ax` never issues a second no-progress fallback click. Search-result text, message content, input values, generic page text, failed probes, and edited plans with stale hidden metadata cannot authorize a send. Dispatch-capable tools whose effects cannot be bound to the probed recipient (`iframe_click`, `execute_js`, WebMCP execution, and `upload_file`, whose change event may auto-send) are unavailable on this protected route. Deterministic saved-workflow replay has no planner-owned recipient target, so a workflow with any potentially dispatching step scoped to a protected messaging route stops before page actions and directs the user to run a normal Act task with a named recipient; a per-step check also covers legacy workflows whose scope metadata is incomplete.
### Accessibility Tree (`accessibility-tree.js`)
diff --git a/docs/lean-mode.md b/docs/lean-mode.md
index a3592a3c0..3b430ae35 100644
--- a/docs/lean-mode.md
+++ b/docs/lean-mode.md
@@ -42,9 +42,9 @@ The list is `LEAN_STRONG_MODEL_RULES` in `lean-mode.js`. That file is identical
## What a lean run gets
-**Tools.** 17 of WebBrain's existing tools, with the same schemas as at the Full tier: `get_accessibility_tree`, `read_page`, `inspect_viewport`, `click_ax`, `click`, `set_field`, `type_ax`, `set_checked`, `type_text`, `press_keys`, `scroll`, `navigate`, `wait_for_stable`, `upload_file`, `calculate`, `clarify` and `done` (`LEAN_TOOL_NAMES` in `tools.js`). `generate_image`, `carousel_navigate`, `gmail_count_results` and the tools of enabled skills are added when they apply, as in a full run; a Compact provider set to On keeps its own `upload_file` contract.
+**Tools.** 17 of WebBrain's existing tools, with the same schemas as at the Full tier: `get_accessibility_tree`, `read_page`, `inspect_viewport`, `click_ax`, `click`, `set_field`, `type_ax`, `set_checked`, `type_text`, `press_keys`, `scroll`, `navigate`, `wait_for_stable`, `upload_file`, `calculate`, `clarify` and `done` (`LEAN_TOOL_NAMES` in `tools.js`). `generate_image`, `carousel_navigate`, `gmail_count_results` and the tools of enabled skills are added when they apply, as in a full run; a Compact provider set to On keeps its own `upload_file` contract. On a native chat client (WhatsApp Web, Telegram Web; `isNativeChatClientUrl` in `adapters.js`) `chat_observe` and `chat_send` are added too (`LEAN_NATIVE_CHAT_TOOL_NAMES`): the recipient guard, which lean mode keeps, confirms a contact and reads the latest messages there through them, and without them its repairs pointed at tools the run did not have.
-Not offered: `browser_batch`, the scratchpad and progress ledger, `fetch_url` and the other fetch, research and download tools, iframe and shadow-DOM tools, `hover` and `drag_drop`, `verify_form`, the chat-workflow tools, scheduling, WebMCP and the CAPTCHA tools. Tabs are not model-callable in WebBrain in any mode. A call to a tool a run does not offer is refused, as in every mode.
+Not offered: `browser_batch`, the scratchpad and progress ledger, `fetch_url` and the other fetch, research and download tools, iframe and shadow-DOM tools, `hover` and `drag_drop`, `verify_form`, the chat-workflow tools (apart from `chat_observe` and `chat_send` on a native chat client), scheduling, WebMCP and the CAPTCHA tools. Tabs are not model-callable in WebBrain in any mode. A call to a tool a run does not offer is refused, as in every mode.
**Prompt.** `SYSTEM_PROMPT_ACT_LEAN`, about 5,900 characters against about 49,000 for the Full Act prompt. It keeps the untrusted-page-content boundary and the prompt-injection rules in full, the hard limits (deleting, paying, sending, publishing, recipients, credentials and one-time codes, CAPTCHAs and other human checks), the sensitive-data guidance and the plan-to-execution rules. It tells the model that WebBrain will not check its typing or its result, so it must read the page again before `done`. The notes for batching, WebMCP, research escalation and the CAPTCHA solver are left out because their tools are.
diff --git a/docs/native-chat-observation.md b/docs/native-chat-observation.md
index 88615f566..44dffbe37 100644
--- a/docs/native-chat-observation.md
+++ b/docs/native-chat-observation.md
@@ -215,6 +215,20 @@ remain the exact original nodes throughout. Pre-existing drawers, stale drawer
responses, same-name row recycling, selection changes and ambiguous phone fields
cannot bind a recipient. Contact names or opaque message IDs alone cannot do so.
+A message action that the recipient probe blocks in a chat whose contact is not
+confirmed yet carries the same exact reference (`nativeWhatsappRepairTarget`,
+`open_contact` or `close_contact`), and the Agent names that control to the
+model instead of telling it to re-read the page and retry. A row of WhatsApp's
+own chat list, clicked on the row itself, opens another chat whatever the open
+chat's state; the row's menu and other nested controls stay guarded. A run
+checks one contact, for its anchor chat: the first chat it looks at, or, in a
+request that names its recipient, the chat that is selected when the run arms
+its check with the guarded contact-name click, so such a request can first open
+the right chat. The probe reports that kind of request
+(`namedRecipientSelection`); a request for the open chat itself, or a target
+already pinned to a verified chat identity, never moves its anchor. Once a check
+is armed, a later selection change spends it.
+
The drawer's close control is its header's one named plain button, whatever
language names it ("Close", "Kapat"); a header with two controls offers none,
and the control must keep the name it had when the guarded click armed it.
@@ -259,6 +273,9 @@ are outside this reader's proved contract.
`test/native-whatsapp-contact.mjs`, `test/whatsapp-chat-completion.mjs` and
`test/whatsapp-chat-restart.mjs` exercise these boundaries in both browser builds.
+`test/whatsapp-chat-selection.mjs` covers the repair reference on a blocked
+message action, chat-list navigation away from an unconfirmed chat, and which
+requests may move the contact check, in both builds.
`test/whatsapp-native-bootstrap.mjs` adds 34 actual-Agent/browser checks for the
generic native composer, precise repair references and wrong or stale targets.
`test/whatsapp-drawer-identity.mjs` adds 56 paired production-reader/browser
diff --git a/package.json b/package.json
index bb48bd8c3..2f1c5e862 100644
--- a/package.json
+++ b/package.json
@@ -64,7 +64,7 @@
"benchmark:relevance": "node scripts/benchmark-offline-relevance.mjs --verbose",
"test:social-contract": "node --test test/social-publish-contract.mjs test/publication-quote-markup.mjs test/publication-prefetch.mjs",
"test:social-contract:dom": "node test/social-publish-contract-dom.mjs",
- "test:runtime-lifecycle": "node test/bot-memory-dom.mjs && node --test test/agent-lifecycle.mjs test/runtime-startup.mjs test/run-ui-scheduled-lifecycle.mjs test/transport-deadlines.mjs test/cdp-worker-restart.mjs test/bot-memory.mjs test/bot-memory-registries.mjs test/bot-memory-cloud-controller.mjs test/cdp-clear-receipt.mjs test/cdp-field-submit-recovery.mjs test/conversation-persistence.mjs test/history-recovery-state.mjs test/history-recovery-scheduler.mjs test/history-recovery-atomic.mjs test/context-live-tool-group.mjs test/integration-races.mjs test/watch-completion-checkpoint.mjs test/runtime-model-identity.mjs test/provider-message-privacy.mjs test/runtime-task-authority.mjs test/planner-repair-authority.mjs test/runtime-progress-continuation.mjs test/chat-resume-chain.mjs test/chat-resume-completion.mjs test/native-chat-execution-ledger.mjs test/chat-send-dispatch-result.mjs test/chat-reply-dedup-race.mjs test/memcode-lifecycle.mjs test/runtime-peer-review.mjs test/read-continuation-schema.mjs test/completion-submit-acknowledgement.mjs test/completion-live-status.mjs test/completion-iframe-submit.mjs test/form-validation-alert-readings.mjs test/control-effect-readings.mjs test/guard-reading-carry-over.mjs test/trusted-retry-readings.mjs test/completion-semantic-commit.mjs test/completion-diagnostics.mjs test/mastodon-publication.mjs test/calculator.mjs test/chat-recovery-protocol.mjs test/chat-pending-reconciliation.mjs test/semantic-page-retry.mjs test/pdf-detection.mjs test/runtime-lifecycle.mjs test/collection-read-progress.mjs test/network-lifecycle.mjs test/text-write-cancellation.mjs test/guard-advisory-writes.mjs test/trusted-field-preparation.mjs test/draftjs-text.mjs test/codemirror-text.mjs test/rich-text-frameworks.mjs test/cdp-managed-text-selection.mjs test/firefox-rich-text-readback.mjs test/contenteditable-beforeinput.mjs test/trusted-field-preparation-ownership.mjs test/typing-preparation-geometry.mjs test/chat-steering.mjs test/lifecycle-steering-restart.mjs test/resource-mutation-guards.mjs test/completion-steering-receipt-authority.mjs test/steering-revision-recovery.mjs test/pending-clarification-hydration.mjs test/clarify-timeout-policy.mjs test/guard-ask-cards.mjs test/permission-steering-wakeup.mjs test/pure-calculation-reply.mjs test/pure-calculation-tools.mjs test/page-feedback.mjs test/page-feedback-progress.mjs test/page-feedback-unbindable-target.mjs test/guard-advisory-actions.mjs test/rich-text-preflight-page-change.mjs test/keyboard-receiver-frame.mjs test/ask-response-scope.mjs test/ask-completion-churn.mjs test/page-feedback-policy.mjs test/research-escalation-page-feedback.mjs test/page-feedback-transport-races.mjs test/page-feedback-recovery.mjs test/telegram-read-preparation-agent.mjs test/media-download-agent-handler.mjs test/code-scanning-url-recipient.mjs test/apocalypse-comm-parsing.mjs test/apocalypse-scalar-decoding.mjs test/bitgpu-chat-security.mjs test/social-media-url-upgrades.mjs test/downloaded-file-saved-bytes.mjs test/downloaded-file-local-probe.mjs test/formless-verification-recovery.mjs test/file-upload-accept.mjs test/file-upload-accept-agent.mjs test/workflow-route-generic-completion.mjs test/release-publication-completion.mjs test/workflow-implicit-metadata.mjs test/workflow-field-readings.mjs test/workflow-field-anchors.mjs test/user-turn-kind.mjs test/follow-up-task-context.mjs test/completion-current-execution-evidence.mjs test/monitor-intervention-contract.mjs test/monitor-owned-geometry.mjs test/monitor-viewport-remainder.mjs test/monitor-scroll-churn.mjs test/monitor-local-attribution.mjs test/monitor-lifecycle-leaks.mjs test/feedback-automatic-churn.mjs test/feedback-navigation-idle.mjs test/feedback-run-boundaries.mjs test/feedback-ask-viewing.mjs test/lifecycle-terminal-done.mjs test/incomplete-completion-recovery.mjs test/guard-advisory-completion.mjs test/guard-policy.mjs test/lean-mode.mjs test/prompt-unverified-pages.mjs test/prompt-missing-values.mjs test/lifecycle-planner-digest.mjs test/lifecycle-vision-fallback.mjs test/guards-control-classification.mjs test/guards-unbound-deletion.mjs test/guards-steering-receipts.mjs && node test/ui-content-lifecycle.mjs && node --test test/native-telegram-chat.mjs test/native-telegram-recipient.mjs test/telegram-native-baseline.mjs test/telegram-native-latest.mjs test/native-chat-pre-enter-draft.mjs test/chat-draft-dispatch-ownership.mjs test/native-telegram-alias-preparation.mjs test/telegram-read-preparation-content.mjs test/queued-composer-ownership.mjs test/onboarding-provider-ready.mjs test/sidepanel-permission-gate-ui.mjs test/workflow-native-targets.mjs test/native-whatsapp-chat.mjs test/native-chat-context-identity.mjs test/native-whatsapp-contact.mjs test/whatsapp-native-bootstrap.mjs test/whatsapp-drawer-identity.mjs test/whatsapp-read-latest.mjs test/whatsapp-read-preparation.mjs test/whatsapp-chat-completion.mjs test/whatsapp-chat-restart.mjs test/chat-goal-lifecycle.mjs test/chat-completion.mjs test/chat-generic-dispatch.mjs test/completion-live-status-browser.mjs test/native-confirmation-visibility.mjs test/read-continuation-browser.mjs test/iframe-preparation-focus.mjs test/contenteditable-literal.mjs test/native-chat-empty-editor.mjs test/native-chat-trusted-clear.mjs test/chat-steering-ui.mjs test/recipient-confirmation-ui.mjs test/assistant-message-visibility-ui.mjs test/history-recovery.mjs test/history-recovery-ui.mjs test/page-monitor-ui.mjs test/x-compose-trusted-typing.mjs test/page-monitor-dialog.mjs test/page-monitor-dialog-native.mjs test/page-monitor-inline-post.mjs test/bluesky-composer-context.mjs test/page-monitor-anchored.mjs test/page-monitor-upload-owner.mjs test/page-monitor-upload-release.mjs test/page-monitor-native-controls.mjs test/page-monitor-native-preparation.mjs test/native-preparation-cold.mjs test/page-monitor-navigation.mjs test/page-monitor-main-owner.mjs test/page-monitor-collateral-controls.mjs test/accessibility-tree-scoped-budget.mjs test/ax-reference-origin.mjs test/page-monitor-decorative-hit.mjs test/social-ui-navigation.mjs test/native-resource-deletion-binding.mjs test/native-mastodon-confirmation.mjs test/dropdown-menu-inventory.mjs test/page-monitor-passive-progress.mjs test/page-monitor-feed-items.mjs test/media-download-binding.mjs test/media-download-capture-integration.mjs test/social-media-downloader-reinjection.mjs test/upload-file-local-state-guidance.mjs && node test/message-recipient-upload.mjs && node test/message-recipient-clarify-binding.mjs && node --test test/message-recipient-whatsapp.mjs test/message-control-readings.mjs && node test/quality/integration-mv3.mjs --full-form && node test/quality/literal-calculate-midrun-mv3.mjs && node test/quality/ask-completion-churn-mv3.mjs && node test/quality/ask-person-activity-mv3.mjs && node test/quality/telegram-cold-preparation-mv3.mjs && node test/quality/native-chat-mv3.mjs && node test/quality/native-chat-presubmit-mv3.mjs && node test/quality/cloud-bot-memory-mv3.mjs && node test/quality/whatsapp-contact-matrix.mjs && node test/quality/pdf-detection-mv3.mjs && node test/quality/download-upload-mv3.mjs && node test/quality/upload-release-binding-mv3.mjs && node test/quality/release-review-world-mv3.mjs && node test/quality/downloaded-file-saved-bytes-mv3.mjs && node test/quality/file-upload-accept-mv3.mjs && node test/quality/bulk-resume-mv3.mjs && node test/quality/literal-frame-mv3.mjs && node test/quality/mastodon-publication-mv3.mjs && node test/quality/mastodon-reply-route-mv3.mjs && node test/quality/mastodon-deletion-mv3.mjs && node test/quality/mastodon-delete-confirmation-mv3.mjs && node test/quality/mastodon-delete-confirmation-mv3.mjs --menu-read && node test/quality/mastodon-delete-confirmation-mv3.mjs --vague && node test/quality/mastodon-delete-after-correction-mv3.mjs && node test/quality/unbound-deletion-mv3.mjs && node test/quality/recipient-clarify-mv3.mjs && node test/quality/open-chat-recipients-mv3.mjs && node test/quality/correction-cross-site-mv3.mjs && node test/quality/anchored-action-mv3.mjs && node test/quality/inline-social-composer-mv3.mjs && node test/quality/x-compose-dialog-mv3.mjs && node test/quality/bluesky-composer-mv3.mjs && node test/quality/dropdown-menu-matrix.mjs && node test/quality/mastodon-deletion-navigation-mv3.mjs && node test/quality/semantic-navigation-matrix.mjs && node test/quality/workflow-replay-mv3.mjs && node test/quality/generative-media-mv3.mjs && node test/quality/cdp-worker-restart-mv3.mjs && node test/quality/steering-worker-restart-mv3.mjs",
+ "test:runtime-lifecycle": "node test/bot-memory-dom.mjs && node --test test/agent-lifecycle.mjs test/runtime-startup.mjs test/run-ui-scheduled-lifecycle.mjs test/transport-deadlines.mjs test/cdp-worker-restart.mjs test/bot-memory.mjs test/bot-memory-registries.mjs test/bot-memory-cloud-controller.mjs test/cdp-clear-receipt.mjs test/cdp-field-submit-recovery.mjs test/conversation-persistence.mjs test/history-recovery-state.mjs test/history-recovery-scheduler.mjs test/history-recovery-atomic.mjs test/context-live-tool-group.mjs test/integration-races.mjs test/watch-completion-checkpoint.mjs test/runtime-model-identity.mjs test/provider-message-privacy.mjs test/runtime-task-authority.mjs test/planner-repair-authority.mjs test/runtime-progress-continuation.mjs test/chat-resume-chain.mjs test/chat-resume-completion.mjs test/native-chat-execution-ledger.mjs test/chat-send-dispatch-result.mjs test/chat-reply-dedup-race.mjs test/memcode-lifecycle.mjs test/runtime-peer-review.mjs test/read-continuation-schema.mjs test/completion-submit-acknowledgement.mjs test/completion-live-status.mjs test/completion-iframe-submit.mjs test/form-validation-alert-readings.mjs test/control-effect-readings.mjs test/guard-reading-carry-over.mjs test/trusted-retry-readings.mjs test/completion-semantic-commit.mjs test/completion-diagnostics.mjs test/mastodon-publication.mjs test/calculator.mjs test/chat-recovery-protocol.mjs test/chat-pending-reconciliation.mjs test/semantic-page-retry.mjs test/pdf-detection.mjs test/runtime-lifecycle.mjs test/collection-read-progress.mjs test/network-lifecycle.mjs test/text-write-cancellation.mjs test/guard-advisory-writes.mjs test/trusted-field-preparation.mjs test/draftjs-text.mjs test/codemirror-text.mjs test/rich-text-frameworks.mjs test/cdp-managed-text-selection.mjs test/firefox-rich-text-readback.mjs test/contenteditable-beforeinput.mjs test/trusted-field-preparation-ownership.mjs test/typing-preparation-geometry.mjs test/chat-steering.mjs test/lifecycle-steering-restart.mjs test/resource-mutation-guards.mjs test/completion-steering-receipt-authority.mjs test/steering-revision-recovery.mjs test/pending-clarification-hydration.mjs test/clarify-timeout-policy.mjs test/guard-ask-cards.mjs test/permission-steering-wakeup.mjs test/pure-calculation-reply.mjs test/pure-calculation-tools.mjs test/page-feedback.mjs test/page-feedback-progress.mjs test/page-feedback-unbindable-target.mjs test/guard-advisory-actions.mjs test/rich-text-preflight-page-change.mjs test/keyboard-receiver-frame.mjs test/ask-response-scope.mjs test/ask-completion-churn.mjs test/page-feedback-policy.mjs test/research-escalation-page-feedback.mjs test/page-feedback-transport-races.mjs test/page-feedback-recovery.mjs test/telegram-read-preparation-agent.mjs test/media-download-agent-handler.mjs test/code-scanning-url-recipient.mjs test/apocalypse-comm-parsing.mjs test/apocalypse-scalar-decoding.mjs test/bitgpu-chat-security.mjs test/social-media-url-upgrades.mjs test/downloaded-file-saved-bytes.mjs test/downloaded-file-local-probe.mjs test/formless-verification-recovery.mjs test/file-upload-accept.mjs test/file-upload-accept-agent.mjs test/workflow-route-generic-completion.mjs test/release-publication-completion.mjs test/workflow-implicit-metadata.mjs test/workflow-field-readings.mjs test/workflow-field-anchors.mjs test/user-turn-kind.mjs test/follow-up-task-context.mjs test/completion-current-execution-evidence.mjs test/monitor-intervention-contract.mjs test/monitor-owned-geometry.mjs test/monitor-viewport-remainder.mjs test/monitor-scroll-churn.mjs test/monitor-local-attribution.mjs test/monitor-lifecycle-leaks.mjs test/feedback-automatic-churn.mjs test/feedback-navigation-idle.mjs test/feedback-run-boundaries.mjs test/feedback-ask-viewing.mjs test/lifecycle-terminal-done.mjs test/incomplete-completion-recovery.mjs test/guard-advisory-completion.mjs test/guard-policy.mjs test/lean-mode.mjs test/prompt-unverified-pages.mjs test/prompt-missing-values.mjs test/lifecycle-planner-digest.mjs test/lifecycle-vision-fallback.mjs test/guards-control-classification.mjs test/guards-unbound-deletion.mjs test/guards-steering-receipts.mjs && node test/ui-content-lifecycle.mjs && node --test test/native-telegram-chat.mjs test/native-telegram-recipient.mjs test/telegram-native-baseline.mjs test/telegram-native-latest.mjs test/native-chat-pre-enter-draft.mjs test/chat-draft-dispatch-ownership.mjs test/native-telegram-alias-preparation.mjs test/telegram-read-preparation-content.mjs test/queued-composer-ownership.mjs test/onboarding-provider-ready.mjs test/sidepanel-permission-gate-ui.mjs test/workflow-native-targets.mjs test/native-whatsapp-chat.mjs test/native-chat-context-identity.mjs test/native-whatsapp-contact.mjs test/whatsapp-chat-selection.mjs test/whatsapp-native-bootstrap.mjs test/whatsapp-drawer-identity.mjs test/whatsapp-read-latest.mjs test/whatsapp-read-preparation.mjs test/whatsapp-chat-completion.mjs test/whatsapp-chat-restart.mjs test/chat-goal-lifecycle.mjs test/chat-completion.mjs test/chat-generic-dispatch.mjs test/completion-live-status-browser.mjs test/native-confirmation-visibility.mjs test/read-continuation-browser.mjs test/iframe-preparation-focus.mjs test/contenteditable-literal.mjs test/native-chat-empty-editor.mjs test/native-chat-trusted-clear.mjs test/chat-steering-ui.mjs test/recipient-confirmation-ui.mjs test/assistant-message-visibility-ui.mjs test/history-recovery.mjs test/history-recovery-ui.mjs test/page-monitor-ui.mjs test/x-compose-trusted-typing.mjs test/page-monitor-dialog.mjs test/page-monitor-dialog-native.mjs test/page-monitor-inline-post.mjs test/bluesky-composer-context.mjs test/page-monitor-anchored.mjs test/page-monitor-upload-owner.mjs test/page-monitor-upload-release.mjs test/page-monitor-native-controls.mjs test/page-monitor-native-preparation.mjs test/native-preparation-cold.mjs test/page-monitor-navigation.mjs test/page-monitor-main-owner.mjs test/page-monitor-collateral-controls.mjs test/accessibility-tree-scoped-budget.mjs test/ax-reference-origin.mjs test/page-monitor-decorative-hit.mjs test/social-ui-navigation.mjs test/native-resource-deletion-binding.mjs test/native-mastodon-confirmation.mjs test/dropdown-menu-inventory.mjs test/page-monitor-passive-progress.mjs test/page-monitor-feed-items.mjs test/media-download-binding.mjs test/media-download-capture-integration.mjs test/social-media-downloader-reinjection.mjs test/upload-file-local-state-guidance.mjs && node test/message-recipient-upload.mjs && node test/message-recipient-clarify-binding.mjs && node --test test/message-recipient-whatsapp.mjs test/message-control-readings.mjs && node test/quality/integration-mv3.mjs --full-form && node test/quality/literal-calculate-midrun-mv3.mjs && node test/quality/ask-completion-churn-mv3.mjs && node test/quality/ask-person-activity-mv3.mjs && node test/quality/telegram-cold-preparation-mv3.mjs && node test/quality/native-chat-mv3.mjs && node test/quality/native-chat-presubmit-mv3.mjs && node test/quality/cloud-bot-memory-mv3.mjs && node test/quality/whatsapp-contact-matrix.mjs && node test/quality/pdf-detection-mv3.mjs && node test/quality/download-upload-mv3.mjs && node test/quality/upload-release-binding-mv3.mjs && node test/quality/release-review-world-mv3.mjs && node test/quality/downloaded-file-saved-bytes-mv3.mjs && node test/quality/file-upload-accept-mv3.mjs && node test/quality/bulk-resume-mv3.mjs && node test/quality/literal-frame-mv3.mjs && node test/quality/mastodon-publication-mv3.mjs && node test/quality/mastodon-reply-route-mv3.mjs && node test/quality/mastodon-deletion-mv3.mjs && node test/quality/mastodon-delete-confirmation-mv3.mjs && node test/quality/mastodon-delete-confirmation-mv3.mjs --menu-read && node test/quality/mastodon-delete-confirmation-mv3.mjs --vague && node test/quality/mastodon-delete-after-correction-mv3.mjs && node test/quality/unbound-deletion-mv3.mjs && node test/quality/recipient-clarify-mv3.mjs && node test/quality/open-chat-recipients-mv3.mjs && node test/quality/correction-cross-site-mv3.mjs && node test/quality/anchored-action-mv3.mjs && node test/quality/inline-social-composer-mv3.mjs && node test/quality/x-compose-dialog-mv3.mjs && node test/quality/bluesky-composer-mv3.mjs && node test/quality/dropdown-menu-matrix.mjs && node test/quality/mastodon-deletion-navigation-mv3.mjs && node test/quality/semantic-navigation-matrix.mjs && node test/quality/workflow-replay-mv3.mjs && node test/quality/generative-media-mv3.mjs && node test/quality/cdp-worker-restart-mv3.mjs && node test/quality/steering-worker-restart-mv3.mjs",
"test:page-feedback": "node --test test/trusted-field-preparation.mjs test/guard-advisory-writes.mjs test/draftjs-text.mjs test/codemirror-text.mjs test/rich-text-frameworks.mjs test/cdp-managed-text-selection.mjs test/firefox-rich-text-readback.mjs test/contenteditable-beforeinput.mjs test/trusted-field-preparation-ownership.mjs test/typing-preparation-geometry.mjs test/pure-calculation-reply.mjs test/pure-calculation-tools.mjs test/page-feedback.mjs test/page-feedback-progress.mjs test/page-feedback-unbindable-target.mjs test/guard-advisory-actions.mjs test/rich-text-preflight-page-change.mjs test/keyboard-receiver-frame.mjs test/ask-response-scope.mjs test/ask-completion-churn.mjs test/page-feedback-policy.mjs test/research-escalation-page-feedback.mjs test/page-feedback-transport-races.mjs test/page-feedback-recovery.mjs test/telegram-read-preparation-agent.mjs test/media-download-agent-handler.mjs test/page-monitor-ui.mjs test/x-compose-trusted-typing.mjs test/page-monitor-dialog.mjs test/page-monitor-dialog-native.mjs test/page-monitor-inline-post.mjs test/bluesky-composer-context.mjs test/page-monitor-anchored.mjs test/page-monitor-upload-owner.mjs test/page-monitor-upload-release.mjs test/page-monitor-native-controls.mjs test/page-monitor-passive-progress.mjs test/page-monitor-feed-items.mjs test/media-download-binding.mjs test/media-download-capture-integration.mjs test/monitor-intervention-contract.mjs test/monitor-owned-geometry.mjs test/monitor-viewport-remainder.mjs test/monitor-scroll-churn.mjs test/monitor-local-attribution.mjs test/monitor-lifecycle-leaks.mjs test/feedback-automatic-churn.mjs test/feedback-navigation-idle.mjs test/feedback-run-boundaries.mjs test/feedback-ask-viewing.mjs test/delivery-click-ax-response-loss.mjs test/delivery-stop-compound.mjs test/delivery-cdp-input.mjs test/delivery-click-locks.mjs test/delivery-native-button-geometry.mjs test/delivery-hover-transition.mjs test/delivery-native-button-route.mjs test/delivery-dispatch-boundary.mjs && node test/message-recipient-upload.mjs && node test/message-recipient-clarify-binding.mjs && node --test test/message-recipient-whatsapp.mjs test/page-feedback-held-time.mjs test/page-monitor-held-observation.mjs",
"test:history-recovery": "node --test test/history-recovery.mjs test/history-recovery-ui.mjs test/history-recovery-state.mjs test/history-recovery-scheduler.mjs test/history-recovery-atomic.mjs test/conversation-persistence.mjs",
"test:chat-steering": "node --test test/chat-steering.mjs test/chat-steering-ui.mjs test/recipient-confirmation-ui.mjs test/lifecycle-steering-latency.mjs test/lifecycle-steering-restart.mjs test/lifecycle-run-ui.mjs test/lifecycle-menu-prompts-held.mjs",
@@ -99,7 +99,7 @@
"test:upload-owner": "node --test test/page-monitor-upload-owner.mjs test/page-monitor-upload-release.mjs",
"test:shard:quick": "npm run test:cms && npm run test:markdown && npm run test:generative-media && npm run test:systemone && npm run test:systemone:fast && node --test test/guard-policy.mjs test/browser-dialogs.mjs test/capsolver-cloud-broker.mjs test/captcha-providers.mjs test/captcha-weighted-fallback.mjs test/captcha-hcaptcha-providers.mjs test/captcha-native-providers.mjs test/captcha-runtime-policy.mjs test/captcha-callback-bridge.mjs test/captcha-bridge-registration.mjs test/captcha-aws-recovery.mjs test/captcha-documented-contracts.mjs test/huggingface-signup-recovery.mjs test/trace-full-export.mjs test/feedback-traces.mjs && npm run test:firefox-bidi && npm run test:billing-notice && npm run test:compass-quota && npm run test:provider-limits && npm run test:provider-catalog && npm run test:provider-instances:ui && npm run test:openrouter-capabilities && npm run test:anthropic && npm run test:browser-batch && npm run test:accessibility-tree-benchmark && npm run test:toolbar-guard && npm run test:cloud-bridge-approval && npm run test:discord && npm run test:pdf-read && npm run test:pdf-selection && npm run test:social-contract && npm run test:safesocial && npm run test:build-unpacked && npm run test:attachment-drop && npm run test:workflow-editor && node --test test/profile-sync-stats.mjs && node --test test/memcode-recall.mjs",
"test:shard:runtime-unit": "node --test test/skill-download-wait.mjs && node --test test/agent-lifecycle.mjs test/runtime-startup.mjs test/run-ui-scheduled-lifecycle.mjs test/transport-deadlines.mjs test/cdp-worker-restart.mjs test/bot-memory.mjs test/bot-memory-click-guard.mjs test/bot-memory-registries.mjs test/bot-memory-cloud-controller.mjs test/cdp-clear-receipt.mjs test/cdp-field-submit-recovery.mjs test/conversation-persistence.mjs test/context-live-tool-group.mjs test/integration-races.mjs test/watch-completion-checkpoint.mjs test/runtime-model-identity.mjs test/provider-message-privacy.mjs test/runtime-task-authority.mjs test/planner-repair-authority.mjs test/runtime-progress-continuation.mjs test/chat-resume-chain.mjs test/chat-resume-completion.mjs test/native-chat-execution-ledger.mjs test/chat-send-dispatch-result.mjs test/chat-reply-dedup-race.mjs test/memcode-lifecycle.mjs test/runtime-peer-review.mjs test/read-continuation-schema.mjs test/completion-submit-acknowledgement.mjs test/completion-live-status.mjs test/completion-iframe-submit.mjs test/form-validation-alert-readings.mjs test/control-effect-readings.mjs test/guard-reading-carry-over.mjs test/trusted-retry-readings.mjs test/completion-semantic-commit.mjs test/completion-diagnostics.mjs test/mastodon-publication.mjs test/calculator.mjs test/chat-recovery-protocol.mjs test/chat-pending-reconciliation.mjs test/semantic-page-retry.mjs test/pdf-detection.mjs test/runtime-lifecycle.mjs test/collection-read-progress.mjs test/network-lifecycle.mjs test/text-write-cancellation.mjs test/guard-advisory-writes.mjs test/trusted-field-preparation.mjs test/draftjs-text.mjs test/codemirror-text.mjs test/rich-text-frameworks.mjs test/cdp-managed-text-selection.mjs test/firefox-rich-text-readback.mjs test/contenteditable-beforeinput.mjs test/trusted-field-preparation-ownership.mjs test/typing-preparation-geometry.mjs test/chat-steering.mjs test/resource-mutation-guards.mjs test/completion-steering-receipt-authority.mjs test/steering-revision-recovery.mjs test/pending-clarification-hydration.mjs test/clarify-timeout-policy.mjs test/guard-ask-cards.mjs test/permission-steering-wakeup.mjs test/pure-calculation-reply.mjs test/pure-calculation-tools.mjs test/page-feedback.mjs test/page-feedback-progress.mjs test/page-feedback-unbindable-target.mjs test/guard-advisory-actions.mjs test/rich-text-preflight-page-change.mjs test/keyboard-receiver-frame.mjs test/ask-response-scope.mjs test/auto-mode.mjs test/model-picker-icon.mjs test/ask-completion-churn.mjs test/page-feedback-policy.mjs test/research-escalation-page-feedback.mjs test/page-feedback-transport-races.mjs test/page-feedback-recovery.mjs test/telegram-read-preparation-agent.mjs test/media-download-agent-handler.mjs test/code-scanning-url-recipient.mjs test/apocalypse-comm-parsing.mjs test/apocalypse-scalar-decoding.mjs test/bitgpu-chat-security.mjs test/social-media-url-upgrades.mjs test/downloaded-file-saved-bytes.mjs test/downloaded-file-local-probe.mjs test/formless-verification-recovery.mjs test/file-upload-accept.mjs test/file-upload-accept-agent.mjs test/workflow-route-generic-completion.mjs test/release-publication-completion.mjs test/workflow-implicit-metadata.mjs test/workflow-field-readings.mjs test/workflow-field-anchors.mjs test/user-turn-kind.mjs test/follow-up-task-context.mjs test/completion-current-execution-evidence.mjs test/video-upload-attachment.mjs test/feedback-automatic-churn.mjs test/feedback-navigation-idle.mjs test/feedback-run-boundaries.mjs test/feedback-ask-viewing.mjs test/lifecycle-terminal-done.mjs test/incomplete-completion-recovery.mjs test/guard-advisory-completion.mjs test/lean-mode.mjs test/prompt-unverified-pages.mjs test/prompt-missing-values.mjs test/lifecycle-planner-digest.mjs test/lifecycle-steering-latency.mjs test/lifecycle-steering-restart.mjs test/lifecycle-vision-fallback.mjs test/delivery-click-locks.mjs test/guards-steering-receipts.mjs test/terminal-user-messages.mjs test/improver-providers.mjs test/improver-providers-agent.mjs test/improver-guards-ledger.mjs test/improver-guards-tools.mjs test/improver-clarify.mjs test/improver-clarify-scheduler.mjs test/improver-misc.mjs test/improver-forms.mjs test/improver-forms-strict-secrets.mjs test/improver-content-press-keys-hint.mjs && npm run test:plan-notifications",
- "test:shard:browser-a": "node --test test/captcha-draft-content.mjs test/captcha-challenge-surfaces.mjs && node test/bot-memory-dom.mjs && node test/bot-memory-click-dom.mjs && node test/ui-content-lifecycle.mjs && node --test test/native-telegram-chat.mjs test/native-telegram-recipient.mjs test/telegram-native-baseline.mjs test/telegram-native-latest.mjs test/native-chat-pre-enter-draft.mjs test/chat-draft-dispatch-ownership.mjs test/native-telegram-alias-preparation.mjs test/telegram-read-preparation-content.mjs test/queued-composer-ownership.mjs test/onboarding-provider-ready.mjs test/sidepanel-permission-gate-ui.mjs test/workflow-native-targets.mjs test/native-whatsapp-chat.mjs test/native-chat-context-identity.mjs test/native-whatsapp-contact.mjs test/whatsapp-native-bootstrap.mjs test/whatsapp-drawer-identity.mjs test/whatsapp-read-latest.mjs test/whatsapp-read-preparation.mjs test/whatsapp-chat-completion.mjs test/whatsapp-chat-restart.mjs test/chat-goal-lifecycle.mjs test/chat-completion.mjs test/chat-generic-dispatch.mjs test/completion-live-status-browser.mjs test/native-confirmation-visibility.mjs test/native-button-preparation.mjs test/read-continuation-browser.mjs test/iframe-preparation-focus.mjs test/contenteditable-literal.mjs test/native-chat-empty-editor.mjs test/native-chat-trusted-clear.mjs test/chat-steering-ui.mjs test/recipient-confirmation-ui.mjs test/assistant-message-visibility-ui.mjs test/page-monitor-ui.mjs test/x-compose-trusted-typing.mjs test/page-monitor-dialog.mjs test/page-monitor-dialog-native.mjs test/page-monitor-inline-post.mjs test/bluesky-composer-context.mjs test/page-monitor-anchored.mjs test/page-monitor-upload-owner.mjs test/page-monitor-upload-release.mjs test/page-monitor-native-controls.mjs test/page-monitor-native-preparation.mjs test/native-preparation-cold.mjs test/page-monitor-navigation.mjs test/page-monitor-main-owner.mjs test/page-monitor-collateral-controls.mjs test/accessibility-tree-scoped-budget.mjs test/ax-reference-origin.mjs test/page-monitor-decorative-hit.mjs test/social-ui-navigation.mjs test/native-resource-deletion-binding.mjs test/native-mastodon-confirmation.mjs test/dropdown-menu-inventory.mjs test/page-monitor-passive-progress.mjs test/page-monitor-feed-items.mjs test/media-download-binding.mjs test/media-download-capture-integration.mjs test/social-media-downloader-reinjection.mjs test/upload-file-local-state-guidance.mjs test/monitor-intervention-contract.mjs test/monitor-owned-geometry.mjs test/monitor-viewport-remainder.mjs test/monitor-scroll-churn.mjs test/monitor-local-attribution.mjs test/monitor-lifecycle-leaks.mjs test/lifecycle-run-ui.mjs test/lifecycle-menu-prompts-held.mjs test/delivery-cdp-input.mjs test/delivery-click-ax-response-loss.mjs test/delivery-native-button-geometry.mjs test/delivery-hover-transition.mjs test/delivery-native-button-route.mjs test/delivery-dispatch-boundary.mjs test/delivery-stop-compound.mjs test/guards-control-classification.mjs test/guards-unbound-deletion.mjs test/submit-probe-readings.mjs test/improver-content-account-chrome.mjs test/improver-content-recipient.mjs test/improver-content-truncated-replacement.mjs test/improver-forms-probe.mjs test/improver-misc-trace-browser.mjs test/page-feedback-held-time.mjs test/page-monitor-held-observation.mjs",
+ "test:shard:browser-a": "node --test test/captcha-draft-content.mjs test/captcha-challenge-surfaces.mjs && node test/bot-memory-dom.mjs && node test/bot-memory-click-dom.mjs && node test/ui-content-lifecycle.mjs && node --test test/native-telegram-chat.mjs test/native-telegram-recipient.mjs test/telegram-native-baseline.mjs test/telegram-native-latest.mjs test/native-chat-pre-enter-draft.mjs test/chat-draft-dispatch-ownership.mjs test/native-telegram-alias-preparation.mjs test/telegram-read-preparation-content.mjs test/queued-composer-ownership.mjs test/onboarding-provider-ready.mjs test/sidepanel-permission-gate-ui.mjs test/workflow-native-targets.mjs test/native-whatsapp-chat.mjs test/native-chat-context-identity.mjs test/native-whatsapp-contact.mjs test/whatsapp-chat-selection.mjs test/whatsapp-native-bootstrap.mjs test/whatsapp-drawer-identity.mjs test/whatsapp-read-latest.mjs test/whatsapp-read-preparation.mjs test/whatsapp-chat-completion.mjs test/whatsapp-chat-restart.mjs test/chat-goal-lifecycle.mjs test/chat-completion.mjs test/chat-generic-dispatch.mjs test/completion-live-status-browser.mjs test/native-confirmation-visibility.mjs test/native-button-preparation.mjs test/read-continuation-browser.mjs test/iframe-preparation-focus.mjs test/contenteditable-literal.mjs test/native-chat-empty-editor.mjs test/native-chat-trusted-clear.mjs test/chat-steering-ui.mjs test/recipient-confirmation-ui.mjs test/assistant-message-visibility-ui.mjs test/page-monitor-ui.mjs test/x-compose-trusted-typing.mjs test/page-monitor-dialog.mjs test/page-monitor-dialog-native.mjs test/page-monitor-inline-post.mjs test/bluesky-composer-context.mjs test/page-monitor-anchored.mjs test/page-monitor-upload-owner.mjs test/page-monitor-upload-release.mjs test/page-monitor-native-controls.mjs test/page-monitor-native-preparation.mjs test/native-preparation-cold.mjs test/page-monitor-navigation.mjs test/page-monitor-main-owner.mjs test/page-monitor-collateral-controls.mjs test/accessibility-tree-scoped-budget.mjs test/ax-reference-origin.mjs test/page-monitor-decorative-hit.mjs test/social-ui-navigation.mjs test/native-resource-deletion-binding.mjs test/native-mastodon-confirmation.mjs test/dropdown-menu-inventory.mjs test/page-monitor-passive-progress.mjs test/page-monitor-feed-items.mjs test/media-download-binding.mjs test/media-download-capture-integration.mjs test/social-media-downloader-reinjection.mjs test/upload-file-local-state-guidance.mjs test/monitor-intervention-contract.mjs test/monitor-owned-geometry.mjs test/monitor-viewport-remainder.mjs test/monitor-scroll-churn.mjs test/monitor-local-attribution.mjs test/monitor-lifecycle-leaks.mjs test/lifecycle-run-ui.mjs test/lifecycle-menu-prompts-held.mjs test/delivery-cdp-input.mjs test/delivery-click-ax-response-loss.mjs test/delivery-native-button-geometry.mjs test/delivery-hover-transition.mjs test/delivery-native-button-route.mjs test/delivery-dispatch-boundary.mjs test/delivery-stop-compound.mjs test/guards-control-classification.mjs test/guards-unbound-deletion.mjs test/submit-probe-readings.mjs test/improver-content-account-chrome.mjs test/improver-content-recipient.mjs test/improver-content-truncated-replacement.mjs test/improver-forms-probe.mjs test/improver-misc-trace-browser.mjs test/page-feedback-held-time.mjs test/page-monitor-held-observation.mjs",
"test:shard:browser-b1": "node test/message-recipient-upload.mjs && node test/message-recipient-clarify-binding.mjs && node --test test/message-recipient-whatsapp.mjs test/message-control-readings.mjs && node test/quality/integration-mv3.mjs --full-form && node test/quality/integration-mv3.mjs --batch && node test/quality/literal-calculate-midrun-mv3.mjs && node test/quality/ask-completion-churn-mv3.mjs && node test/quality/ask-person-activity-mv3.mjs && node test/quality/telegram-cold-preparation-mv3.mjs && node test/quality/native-chat-mv3.mjs && node test/quality/native-chat-presubmit-mv3.mjs && node test/quality/cloud-bot-memory-mv3.mjs",
"test:shard:browser-b2": "node test/quality/whatsapp-contact-matrix.mjs && node test/quality/pdf-detection-mv3.mjs && node test/quality/download-upload-mv3.mjs && node test/quality/upload-release-binding-mv3.mjs && node test/quality/upload-release-binding-mv3.mjs --selector-recovery && node test/quality/upload-release-binding-mv3.mjs --sequential-assets && node test/quality/release-review-world-mv3.mjs && node test/quality/downloaded-file-saved-bytes-mv3.mjs && node test/quality/file-upload-accept-mv3.mjs && node test/quality/bulk-resume-mv3.mjs && node test/quality/shared-action-guards-mv3.mjs && node test/quality/video-upload-attachment-mv3.mjs",
"test:shard:browser-c": "node test/quality/literal-frame-mv3.mjs && node test/quality/mastodon-publication-mv3.mjs && node test/quality/mastodon-reply-route-mv3.mjs && node test/quality/mastodon-deletion-mv3.mjs && node test/quality/mastodon-delete-confirmation-mv3.mjs && node test/quality/mastodon-delete-confirmation-mv3.mjs --menu-read && node test/quality/mastodon-delete-confirmation-mv3.mjs --vague && node test/quality/mastodon-delete-after-correction-mv3.mjs && node test/quality/unbound-deletion-mv3.mjs && node test/quality/recipient-clarify-mv3.mjs && node test/quality/open-chat-recipients-mv3.mjs && node test/quality/correction-cross-site-mv3.mjs && node test/quality/anchored-action-mv3.mjs && node test/quality/inline-social-composer-mv3.mjs && node test/quality/x-compose-dialog-mv3.mjs && node test/quality/bluesky-composer-mv3.mjs && node test/quality/dropdown-menu-matrix.mjs && node test/quality/mastodon-deletion-navigation-mv3.mjs && node test/quality/semantic-navigation-matrix.mjs && node test/quality/workflow-replay-mv3.mjs && node test/quality/generative-media-mv3.mjs && node test/quality/cdp-worker-restart-mv3.mjs && node test/quality/steering-worker-restart-mv3.mjs",
diff --git a/src/chrome/src/agent/adapters.js b/src/chrome/src/agent/adapters.js
index 6f901ad41..317184acf 100644
--- a/src/chrome/src/agent/adapters.js
+++ b/src/chrome/src/agent/adapters.js
@@ -17663,6 +17663,7 @@ const ADAPTERS = [
- First-time setup REQUIRES the user to scan a QR code with their phone's WhatsApp app. The agent CANNOT scan a QR code — if the QR is on screen, surface it to the user and stop. Don't loop waiting for it to disappear.
- Once linked, layout is: conversation list on the LEFT (chats sorted by recency), active conversation on the RIGHT.
- Message input is a contenteditable div at the bottom of the conversation. set_field works; Enter sends by default.
+- Open the recipient's chat first: click_ax its row in the chat list, or search for them. Then, before sending or attaching, confirm the contact: click_ax the contact name in the chat header, and close the Contact info panel it opens with that panel's own Close button. Until then message actions are blocked, and the blocked result names the exact control. One run confirms one chat.
- Emoji picker, attachment button (paperclip), voice-note (mic) sit to the left/right of the input.
- Search at the top of the conversation list searches across all chats (people, group names, message content).
- "Status" tab (eye icon) is a separate stream of ephemeral updates; "Calls" tab shows call history and starts voice/video calls.
@@ -18349,6 +18350,21 @@ export function getMessageRecipientGuardPolicy(url) {
};
}
+/**
+ * Native chat clients whose recipient guard confirms a contact and reads the
+ * latest messages through the chat tools (chat_observe, chat_send). Lean mode
+ * keeps that guard, so it offers those two tools on these pages.
+ */
+export function isNativeChatClientUrl(url) {
+ try {
+ const parsed = new URL(url);
+ return parsed.protocol === 'https:' && (parsed.hostname === 'web.whatsapp.com'
+ || /^(?:web|webk|weba|webz|k)\.telegram\.org$/i.test(parsed.hostname));
+ } catch {
+ return false;
+ }
+}
+
/**
* Get a printable list of all registered adapters (for settings UI / docs).
*/
diff --git a/src/chrome/src/agent/agent.js b/src/chrome/src/agent/agent.js
index be48ed8c4..de6fd090b 100644
--- a/src/chrome/src/agent/agent.js
+++ b/src/chrome/src/agent/agent.js
@@ -65,7 +65,7 @@ import { analyzeMastodonPage, isMastodonPageUrl, mastodonHandoffInstruction, mas
import { PROGRESS_ACTIONS, isProgressActionAllowed, isProgressIntentActive, normalizeProgressAction, normalizeProgressIntent } from './progress-intent.js';
import { classifyCompletionForm, completionDoneBlock, completionPlainFinalBlock, completionPlainFinalPartial, consumeCompletionObservation, consumeCompletionObservationResult, createCompletionInvariantState, didCompletionActionExecute, hasUnconsumedCompletionObservation, hasUnconsumedCompletionObservationResult, isCompletionActionTool, publicationDetailResource, publicationReplyParent, publicationResourceRecordRoot, recordCompletionToolResult } from './completion-invariant.js';
import { cdpClient, isCdpCommandNotSentError } from '../cdp/cdp-client.js';
-import { findLastGmailResultPage, getActiveAdapter, getAdapterWorkflowRouting, getCarouselNavigationPolicy, getCarouselNavigationTarget, getFullPageCapturePolicy, getGmailResultCountPolicy, getGmailResultPageUrl, getMessageRecipientGuardPolicy, isGmailChatRoute, isPublicComposerRoute, parseCarouselSlideCount, parseGmailPaginationRange, resolveAdapterWorkflowJob, UNIVERSAL_PREAMBLE } from './adapters.js';
+import { findLastGmailResultPage, getActiveAdapter, getAdapterWorkflowRouting, getCarouselNavigationPolicy, getCarouselNavigationTarget, getFullPageCapturePolicy, getGmailResultCountPolicy, getGmailResultPageUrl, getMessageRecipientGuardPolicy, isGmailChatRoute, isNativeChatClientUrl, isPublicComposerRoute, parseCarouselSlideCount, parseGmailPaginationRange, resolveAdapterWorkflowJob, UNIVERSAL_PREAMBLE } from './adapters.js';
import { formatAdapterWorkflowExecutionPolicy } from './adapter-workflow.js';
import {
invalidateWorkflowInventoryCompleteness,
@@ -31382,6 +31382,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
supportsRecipientSets: policy.supportsRecipientSets === true,
...(name === 'upload_file' ? { uploadSourceKey } : {}),
...(target?.target_kind === 'named' ? { expectedRecipients: target.recipients } : {}),
+ ...(this._messageTargetNamesRecipient(guard, target) ? { namedRecipientSelection: true } : {}),
});
if (probe?.success === true && probe?.conclusive === true && probe.messageSend === false) {
if (probe.nativeTelegramRepair === true) {
@@ -31710,6 +31711,15 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
// says so, instead of sending the agent to re-read and retry in vain.
const contactCheckSpent = inconclusive && probe?.nativeWhatsappRepairSpent === true
&& probe?.reasonCode === 'native_whatsapp_contact_check_spent' && typeof probe?.error === 'string';
+ // A native WhatsApp chat whose contact this run has not confirmed yet.
+ // The model is told the one control that confirms it, by its exact ref:
+ // "re-read and retry" kept a model clicking Attach and the chat row,
+ // each blocked again, until it gave up without sending.
+ const whatsappContactCheck = inconclusive && !contactCheckSpent
+ && probe?.reasonCode === 'native_whatsapp_contact_binding_required'
+ ? this._nativeWhatsappContactCheckGuidance(probe?.nativeWhatsappRepairTarget,
+ { namedRecipient: this._messageTargetNamesRecipient(guard, target) })
+ : '';
// Human-readable view of who the page actually addresses, so a mismatch
// block can name the exact observed recipient.
const observedRecipientLabel = (() => {
@@ -31733,7 +31743,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
reasonCode: inconclusive
? (probe?.reasonCode || 'message_send_classification_inconclusive')
: (target ? 'active_recipient_unverified' : 'authorized_recipient_missing'),
- error: contactCheckSpent ? String(probe.error || '') : missingLinkedInComposer
+ error: contactCheckSpent ? String(probe.error || '') : whatsappContactCheck ? whatsappContactCheck : missingLinkedInComposer
? (probe?.reasonCode === 'message_commit_without_composer'
? 'Message send blocked: this control commits a message (for example "Send" / "Send without a note") but no active composer or recipient could be verified. Changing click targeting methods will not help. Open the intended conversation so its composer and recipient are visible, or report that the message could not be sent.'
: 'Message send blocked: no message composer is visible, so this send cannot be verified. Changing click targeting methods will not resolve this classification failure. Re-read the page to find a supported navigation or composer-opening control; if none is available, report the blocker instead of repeating the click.')
@@ -31749,6 +31759,39 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
};
}
+ // Whether a request names the person its message is for, so that it may
+ // open that person's WhatsApp chat from the chat list before the contact
+ // check. A request for the open chat itself ("this one"), with or without
+ // people named besides it, and a target already pinned to a verified chat
+ // identity keep the check on the chat that was open.
+ _messageTargetNamesRecipient(guard, target) {
+ const named = normalizeMessageTarget(target);
+ return named?.target_kind === 'named' && named.recipients.length > 0
+ && named.recipients.every(item => !/^whatsapp:/i.test(String(item?.identity || '')))
+ && !(Array.isArray(guard?.activeConversationRecipients) && guard.activeConversationRecipients.length > 0)
+ && !normalizeMessageTarget(guard?.requestedMessaging);
+ }
+
+ // What the model reads when a message action is blocked in a native
+ // WhatsApp chat whose contact the run has not confirmed yet. The page names
+ // the confirming control (the contact name in the chat header, then the
+ // Contact info panel's Close button) as an app-issued ref when it can.
+ _nativeWhatsappContactCheckGuidance(repairTarget, { namedRecipient = false } = {}) {
+ const ref = typeof repairTarget?.ref_id === 'string' && /^ref_[A-Za-z0-9_:-]{1,100}$/.test(repairTarget.ref_id)
+ ? repairTarget.ref_id : '';
+ if (ref && repairTarget.phase === 'close_contact') {
+ return `Message action blocked, nothing was sent: this chat's Contact info panel is still open. Close it with click_ax({ref_id:"${ref}"}), the panel's own Close button, to finish confirming the contact, then retry this action.`;
+ }
+ const confirm = ref && repairTarget.phase === 'open_contact'
+ ? `click_ax({ref_id:"${ref}"}), the contact name in the chat header`
+ : 'click_ax only the contact name in the chat header (read the header with get_accessibility_tree first)';
+ return 'Message action blocked, nothing was sent: on WhatsApp, WebBrain confirms who the open chat is with before any message action in it, and this chat is not confirmed yet. '
+ + (namedRecipient
+ ? 'If this is not the chat of the person the message is for, open their chat from the chat list first; the check applies to the chat that is open. '
+ : '')
+ + `To confirm it, ${confirm}, then close the Contact info panel it opens with that panel's own Close button, and retry this action. The avatar, call, search and menu buttons do not confirm a contact.`;
+ }
+
/**
* What the model reads when a send to an unconfirmed recipient could not be
* put to the user (an unattended run) or was not confirmed. It names both
@@ -54818,6 +54861,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
watchBeep: this.scheduledRunPolicies.get(tabId)?.watch?.beep === true,
carouselNavigation: !!getCarouselNavigationPolicy(await this._currentUrl(tabId)),
gmailResultCounting: !!getGmailResultCountPolicy(await this._currentUrl(tabId)),
+ nativeChatTools: isNativeChatClientUrl(await this._currentUrl(tabId)),
researchEscalationEnabled: this.researchEscalationEnabled,
autoModeEscalation: mode === 'ask' && this._autoModeEscalationTabs.has(tabId),
});
@@ -55111,6 +55155,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
watchBeep: this.scheduledRunPolicies.get(tabId)?.watch?.beep === true,
carouselNavigation: !!getCarouselNavigationPolicy(await this._currentUrl(tabId)),
gmailResultCounting: !!getGmailResultCountPolicy(await this._currentUrl(tabId)),
+ nativeChatTools: isNativeChatClientUrl(await this._currentUrl(tabId)),
researchEscalationEnabled: this.researchEscalationEnabled,
autoModeEscalation: mode === 'ask' && this._autoModeEscalationTabs.has(tabId),
});
@@ -56508,6 +56553,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
watchBeep: this.scheduledRunPolicies.get(tabId)?.watch?.beep === true,
carouselNavigation: !!getCarouselNavigationPolicy(await this._currentUrl(tabId)),
gmailResultCounting: !!getGmailResultCountPolicy(await this._currentUrl(tabId)),
+ nativeChatTools: isNativeChatClientUrl(await this._currentUrl(tabId)),
researchEscalationEnabled: this.researchEscalationEnabled,
});
// Match the non-streaming path: selection-grounded turns are tool-free so
@@ -56626,6 +56672,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
watchBeep: this.scheduledRunPolicies.get(tabId)?.watch?.beep === true,
carouselNavigation: !!getCarouselNavigationPolicy(await this._currentUrl(tabId)),
gmailResultCounting: !!getGmailResultCountPolicy(await this._currentUrl(tabId)),
+ nativeChatTools: isNativeChatClientUrl(await this._currentUrl(tabId)),
researchEscalationEnabled: this.researchEscalationEnabled,
});
tools = this._botMemoryRunTools(tabId, tools);
diff --git a/src/chrome/src/agent/tools.js b/src/chrome/src/agent/tools.js
index d9368dad9..5c1ea405d 100644
--- a/src/chrome/src/agent/tools.js
+++ b/src/chrome/src/agent/tools.js
@@ -1965,7 +1965,8 @@ export function getToolsForMode(mode, opts = {}) {
// A Compact provider keeps its upload_file schema: its permission gate
// accepts only an attachment and a target from upload_file's own discovery.
base = AGENT_TOOLS
- .filter(t => LEAN_TOOL_NAMES.has(t.function.name))
+ .filter(t => LEAN_TOOL_NAMES.has(t.function.name)
+ || (opts.nativeChatTools === true && LEAN_NATIVE_CHAT_TOOL_NAMES.has(t.function.name)))
.map(t => (tier === 'compact' && t.function.name === 'upload_file' ? compactUploadFileTool(t) : t));
} else if (tier === 'compact') {
base = AGENT_TOOLS
@@ -2712,6 +2713,16 @@ export const LEAN_TOOL_NAMES = new Set([
'generate_image', 'carousel_navigate', 'gmail_count_results',
]);
+/**
+ * Chat tools a lean run is also offered on a native chat client (WhatsApp
+ * Web, Telegram Web; `nativeChatTools`, from isNativeChatClientUrl). Lean mode
+ * keeps the recipient guard, which confirms a contact and reads the latest
+ * messages there through chat_observe and sends through chat_send. Without
+ * them its repairs pointed at tools the run did not have, and the planner's
+ * chat_observe/chat_send steps could not run.
+ */
+export const LEAN_NATIVE_CHAT_TOOL_NAMES = new Set(['chat_observe', 'chat_send']);
+
/**
* Lean Act prompt: short, with the hard limits and the prompt-injection
* boundary kept in full. WebBrain runs no quality checks in lean mode, so the
diff --git a/src/chrome/src/content/chat-observation.js b/src/chrome/src/content/chat-observation.js
index 6146452cf..00dce3c9c 100644
--- a/src/chrome/src/content/chat-observation.js
+++ b/src/chrome/src/content/chat-observation.js
@@ -482,6 +482,15 @@
let whatsappPending = null;
let whatsappActive = null;
let whatsappRepairAnchor = null;
+ // The anchor is normally the first chat the run looks at. A run that names
+ // its recipient may first have to open that person's chat from the chat
+ // list: the recipient probe reports that selection, and the anchor then
+ // follows WhatsApp's selection until the run arms its one check (a guarded
+ // header click). A run for the open chat itself ("this one") never moves
+ // its anchor, since that chat is its target. Once a check is armed the
+ // anchor stays with that chat, and a later selection change spends it.
+ let whatsappAnchorFollowsSelection = false;
+ let whatsappCheckArmed = false;
const whatsappRendered = node => {
if (!visible(node)) return false;
for (let current = node, depth = 0; current && depth < 128; current = current.parentElement, depth++) {
@@ -556,6 +565,7 @@
whatsappRestore = restore && typeof restore === 'object' ? restore : null;
if (next !== whatsappOwner) {
invalidateWhatsappBindings(false, true); whatsappRepairAnchor = null; whatsappOwner = next;
+ whatsappAnchorFollowsSelection = false; whatsappCheckArmed = false;
let sameRunSourceChanged = false;
try {
const prior = JSON.parse(whatsappParkedFloor?.owner || 'null'), current = JSON.parse(next || 'null');
@@ -734,22 +744,38 @@
if (!pins || !contains(pins.carrier, target)) return false;
invalidateWhatsappBindings(true, true);
whatsappPending = { pins, owner: whatsappOwner, priorDrawers: new Set(query(document, '[data-testid="chat-info-drawer"]')) };
+ // The run's one check now belongs to this chat.
+ if (whatsappAnchorFollowsSelection) whatsappRepairAnchor = { pins, invalidated: false };
+ whatsappCheckArmed = true; whatsappAnchorFollowsSelection = false;
return true;
};
window.__wb_get_native_whatsapp_repair = () => {
const composers = query(document, '[data-testid="conversation-compose-box-input"][contenteditable="true"][role="textbox"]');
const pins = composers.length === 1 ? whatsappPins(composers[0]) : null;
if (!pins || !whatsappOwner) return null;
- if (!whatsappRepairAnchor) whatsappRepairAnchor = { pins, invalidated: false };
+ if (!whatsappRepairAnchor || (whatsappAnchorFollowsSelection && !whatsappCheckArmed
+ && (whatsappRepairAnchor.invalidated || !sameWhatsappPins(whatsappRepairAnchor.pins)))) {
+ whatsappRepairAnchor = { pins, invalidated: false };
+ }
return !whatsappRepairAnchor.invalidated && sameWhatsappPins(whatsappRepairAnchor.pins) ? pins : null;
};
- // A run checks one contact through its drawer: the anchor is the first
- // chat the run looked at, and once it is invalidated, as when WhatsApp's
- // chat selection changes, no chat can be checked again until the next run
- // (a new owner). True when that is why no check is available. Anchored
- // nodes that are only hidden for now, as behind a modal, do not count.
+ // The recipient probe calls this for a guarded chat-list selection in a run
+ // that names its recipient (see whatsappAnchorFollowsSelection). False once
+ // the run has armed its check, which stays with the chat it armed.
+ window.__wb_native_whatsapp_follow_selection = () => {
+ if (!whatsappObserver || !whatsappOwner || whatsappCheckArmed) return false;
+ whatsappAnchorFollowsSelection = true;
+ return true;
+ };
+ // A run checks one contact through its drawer, for its anchor chat. Once
+ // the anchor is invalidated, as when WhatsApp's chat selection changes
+ // after the check was armed (or, in a run for the open chat, at all), no
+ // chat can be checked again until the next run (a new owner). True when
+ // that is why no check is available. Anchored nodes that are only hidden
+ // for now, as behind a modal, do not count.
window.__wb_native_whatsapp_repair_spent = () => {
if (!whatsappOwner || whatsappRepairAnchor?.invalidated !== true) return false;
+ if (whatsappAnchorFollowsSelection && !whatsappCheckArmed) return false;
const composers = query(document, '[data-testid="conversation-compose-box-input"][contenteditable="true"][role="textbox"]');
return composers.length === 1 && whatsappNativeComposer(composers[0]);
};
@@ -777,6 +803,9 @@
if (typeof ref_id !== 'string' || !/^ref_[A-Za-z0-9_:-]{1,100}$/.test(ref_id)) return null;
return { phase: drawers.length ? 'close_contact' : 'open_contact', ref_id };
};
+ // The recipient probe names this same control to the model when it blocks
+ // a message action in a chat whose contact is not confirmed yet.
+ window.__wb_native_whatsapp_repair_guidance = () => whatsappRepairGuidance();
window.__wb_native_whatsapp_repair_matches = snapshot => {
if (!snapshot || snapshot.owner !== whatsappOwner || !whatsappObserver) return false;
whatsappMutations(whatsappObserver.takeRecords());
@@ -1528,7 +1557,7 @@
// here: the native composer is no longer tied to a checked chat).
if (window.__wb_native_whatsapp_repair_spent()) {
return { success: false, schema: SCHEMA, reason: 'native_whatsapp_contact_check_spent', retryable: false,
- error: 'This run can no longer confirm a WhatsApp contact: its contact check belongs to the first chat it looked at, and WhatsApp\'s chat selection or that chat\'s header changed since. Nothing was sent. Report what was sent and that a message to this chat needs a new request; do not retry it in this run.' };
+ error: 'This run can no longer confirm a WhatsApp contact: its one contact check belongs to the chat it first looked at or started checking, and WhatsApp\'s chat selection or that chat\'s header changed since. Nothing was sent. Report what was sent and that a message to this chat needs a new request; do not retry it in this run.' };
}
if (composer && window.__wb_get_native_whatsapp_repair()?.composer === composer) {
const nativeWhatsappRepair = whatsappRepairGuidance();
diff --git a/src/chrome/src/content/content.js b/src/chrome/src/content/content.js
index 1298092ce..9a1869338 100644
--- a/src/chrome/src/content/content.js
+++ b/src/chrome/src/content/content.js
@@ -1241,7 +1241,10 @@
const unsafeAncestor = el?.parentElement?.closest?.(
'button,a,input,select,textarea,label,form,[role="button"],[role="link"],[onclick],[data-action]'
);
- const safeRole = !role || ['generic', 'listitem', 'row'].includes(role);
+ // A grid cell is the clickable row of a grid-based list. WhatsApp's chat
+ // list is one, and a script-dispatched click on it does not open the
+ // chat, so without the trusted retry the agent could not open a chat.
+ const safeRole = !role || ['generic', 'listitem', 'row', 'gridcell'].includes(role);
let blockedReason = '';
if (isEditable) blockedReason = 'editable targets must not be auto-clicked twice';
else if (tag === 'select') blockedReason = 'native select controls must use keyboard selection';
@@ -7864,6 +7867,19 @@
}
const nativeWhatsappComposer = location.hostname === 'web.whatsapp.com'
&& layoutCandidate?.matches?.('[data-testid="conversation-compose-box-input"][contenteditable="true"][role="textbox"]');
+ // A row of WhatsApp's own chat list (the rows the native contact check
+ // reads), clicked on the row itself and not on its menu, link or
+ // another control nested in it.
+ const nativeWhatsappChatListRow = clicked => {
+ if (!clicked || editable(clicked)) return false;
+ const row = clicked.closest?.('[role="row"]');
+ if (!row || !row.closest?.('[data-testid="chat-list"]') || !visible(row)
+ || row.querySelectorAll('[data-testid="cell-frame-title"]').length !== 1) return false;
+ const nested = clicked.closest?.('a[href],button,input,select,textarea,summary,[contenteditable="true"],'
+ + '[contenteditable=""],[role="button"],[role="link"],[role="menuitem"],[role="checkbox"],[role="radio"],'
+ + '[role="switch"],[role="combobox"],[role="textbox"],[aria-haspopup],[onclick],[data-action]');
+ return !nested || !row.contains(nested);
+ };
if (nativeWhatsappComposer && nativeLayoutContext?.service !== 'whatsapp-self') {
const repair = window.__wb_get_native_whatsapp_repair?.();
if (!observationOnly && tool === 'click_ax' && targetResolved
@@ -7871,16 +7887,35 @@
return { success: true, messageSend: false, conclusive: true, composerAvailable: true,
nativeWhatsappRepair: true, identityCandidates: [] };
}
+ // Opening another chat from the chat list sends nothing, and a request
+ // for a named person may have to leave the chat that was open when it
+ // started. Blocking it until the open chat's contact was confirmed
+ // left the agent no way to reach the right chat. The contact check
+ // then belongs to the chat that ends up open (see
+ // __wb_native_whatsapp_follow_selection).
+ if (!observationOnly && ['click', 'click_ax'].includes(tool) && targetResolved
+ && nativeWhatsappChatListRow(target)) {
+ if (params.bindDispatch === true && params.namedRecipientSelection === true) {
+ window.__wb_native_whatsapp_follow_selection?.();
+ }
+ return { success: true, messageSend: false, conclusive: true, conversationSelection: true,
+ identityCandidates: [] };
+ }
if (nativeLayoutContext?.service !== 'whatsapp') {
// No check left in this run: say so, rather than send the agent
// after a header click that cannot help.
const spent = !repair && window.__wb_native_whatsapp_repair_spent?.() === true;
+ // Otherwise name the exact control that confirms this chat's
+ // contact, so the agent can pass it on instead of "re-read and
+ // retry", which kept a model clicking Attach and the chat row.
+ const repairTarget = !spent && repair ? window.__wb_native_whatsapp_repair_guidance?.() || null : null;
return { success: true, messageSend: observationOnly ? false : null, conclusive: false,
composerAvailable: true, nativeWhatsappRepairAvailable: !!repair,
...(spent ? { nativeWhatsappRepairSpent: true } : {}),
+ ...(repairTarget ? { nativeWhatsappRepairTarget: repairTarget } : {}),
reasonCode: spent ? 'native_whatsapp_contact_check_spent' : 'native_whatsapp_contact_binding_required', identityCandidates: [],
error: spent
- ? 'This run can no longer confirm a WhatsApp contact: its contact check belongs to the first chat it looked at, and WhatsApp\'s chat selection or that chat\'s header changed since. Nothing was sent. Report what was sent and that a message to this chat needs a new request; do not retry it in this run.'
+ ? 'This run can no longer confirm a WhatsApp contact: its one contact check belongs to the chat it first looked at or started checking, and WhatsApp\'s chat selection or that chat\'s header changed since. Nothing was sent. Report what was sent and that a message to this chat needs a new request; do not retry it in this run.'
: 'Native WhatsApp contact identity needs a fresh guarded header click, its contact drawer phone, and closing that same drawer. No message or editor write was authorized.' };
}
}
diff --git a/src/firefox/src/agent/adapters.js b/src/firefox/src/agent/adapters.js
index e722ae5fe..e68c334c4 100644
--- a/src/firefox/src/agent/adapters.js
+++ b/src/firefox/src/agent/adapters.js
@@ -17661,6 +17661,7 @@ const ADAPTERS = [
- First-time setup REQUIRES the user to scan a QR code with their phone's WhatsApp app. The agent CANNOT scan a QR code — if the QR is on screen, surface it to the user and stop. Don't loop waiting for it to disappear.
- Once linked, layout is: conversation list on the LEFT (chats sorted by recency), active conversation on the RIGHT.
- Message input is a contenteditable div at the bottom of the conversation. set_field works; Enter sends by default.
+- Open the recipient's chat first: click_ax its row in the chat list, or search for them. Then, before sending or attaching, confirm the contact: click_ax the contact name in the chat header, and close the Contact info panel it opens with that panel's own Close button. Until then message actions are blocked, and the blocked result names the exact control. One run confirms one chat.
- Emoji picker, attachment button (paperclip), voice-note (mic) sit to the left/right of the input.
- Search at the top of the conversation list searches across all chats (people, group names, message content).
- "Status" tab (eye icon) is a separate stream of ephemeral updates; "Calls" tab shows call history and starts voice/video calls.
@@ -18347,6 +18348,21 @@ export function getMessageRecipientGuardPolicy(url) {
};
}
+/**
+ * Native chat clients whose recipient guard confirms a contact and reads the
+ * latest messages through the chat tools (chat_observe, chat_send). Lean mode
+ * keeps that guard, so it offers those two tools on these pages.
+ */
+export function isNativeChatClientUrl(url) {
+ try {
+ const parsed = new URL(url);
+ return parsed.protocol === 'https:' && (parsed.hostname === 'web.whatsapp.com'
+ || /^(?:web|webk|weba|webz|k)\.telegram\.org$/i.test(parsed.hostname));
+ } catch {
+ return false;
+ }
+}
+
/**
* Get a printable list of all registered adapters (for settings UI / docs).
*/
diff --git a/src/firefox/src/agent/agent.js b/src/firefox/src/agent/agent.js
index 241956fd9..f83211f91 100644
--- a/src/firefox/src/agent/agent.js
+++ b/src/firefox/src/agent/agent.js
@@ -63,7 +63,7 @@ import { buildGithubStargazerProgressItems } from './observers/github-stargazers
import { analyzeMastodonPage, isMastodonPageUrl, mastodonHandoffInstruction, mastodonPageLabels, mastodonProgressGuard, mastodonTaskDomains } from './observers/mastodon.js';
import { PROGRESS_ACTIONS, isProgressActionAllowed, isProgressIntentActive, normalizeProgressAction, normalizeProgressIntent } from './progress-intent.js';
import { classifyCompletionForm, completionDoneBlock, completionPlainFinalBlock, completionPlainFinalPartial, consumeCompletionObservation, consumeCompletionObservationResult, createCompletionInvariantState, didCompletionActionExecute, hasUnconsumedCompletionObservation, hasUnconsumedCompletionObservationResult, isCompletionActionTool, publicationDetailResource, publicationReplyParent, publicationResourceRecordRoot, recordCompletionToolResult } from './completion-invariant.js';
-import { findLastGmailResultPage, getActiveAdapter, getAdapterWorkflowRouting, getCarouselNavigationPolicy, getCarouselNavigationTarget, getGmailResultCountPolicy, getGmailResultPageUrl, getMessageRecipientGuardPolicy, isGmailChatRoute, isPublicComposerRoute, parseCarouselSlideCount, parseGmailPaginationRange, resolveAdapterWorkflowJob, UNIVERSAL_PREAMBLE } from './adapters.js';
+import { findLastGmailResultPage, getActiveAdapter, getAdapterWorkflowRouting, getCarouselNavigationPolicy, getCarouselNavigationTarget, getGmailResultCountPolicy, getGmailResultPageUrl, getMessageRecipientGuardPolicy, isGmailChatRoute, isNativeChatClientUrl, isPublicComposerRoute, parseCarouselSlideCount, parseGmailPaginationRange, resolveAdapterWorkflowJob, UNIVERSAL_PREAMBLE } from './adapters.js';
import { formatAdapterWorkflowExecutionPolicy } from './adapter-workflow.js';
import {
invalidateWorkflowInventoryCompleteness,
@@ -28368,6 +28368,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
supportsRecipientSets: policy.supportsRecipientSets === true,
...(name === 'upload_file' ? { uploadSourceKey } : {}),
...(target?.target_kind === 'named' ? { expectedRecipients: target.recipients } : {}),
+ ...(this._messageTargetNamesRecipient(guard, target) ? { namedRecipientSelection: true } : {}),
});
if (probe?.success === true && probe?.conclusive === true && probe.messageSend === false) {
if (probe.nativeTelegramRepair === true) {
@@ -28697,6 +28698,15 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
// says so, instead of sending the agent to re-read and retry in vain.
const contactCheckSpent = inconclusive && probe?.nativeWhatsappRepairSpent === true
&& probe?.reasonCode === 'native_whatsapp_contact_check_spent' && typeof probe?.error === 'string';
+ // A native WhatsApp chat whose contact this run has not confirmed yet.
+ // The model is told the one control that confirms it, by its exact ref:
+ // "re-read and retry" kept a model clicking Attach and the chat row,
+ // each blocked again, until it gave up without sending.
+ const whatsappContactCheck = inconclusive && !contactCheckSpent
+ && probe?.reasonCode === 'native_whatsapp_contact_binding_required'
+ ? this._nativeWhatsappContactCheckGuidance(probe?.nativeWhatsappRepairTarget,
+ { namedRecipient: this._messageTargetNamesRecipient(guard, target) })
+ : '';
// Human-readable view of who the page actually addresses, so a mismatch
// block can name the exact observed recipient.
const observedRecipientLabel = (() => {
@@ -28720,7 +28730,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
reasonCode: inconclusive
? (probe?.reasonCode || 'message_send_classification_inconclusive')
: (target ? 'active_recipient_unverified' : 'authorized_recipient_missing'),
- error: contactCheckSpent ? String(probe.error || '') : missingLinkedInComposer
+ error: contactCheckSpent ? String(probe.error || '') : whatsappContactCheck ? whatsappContactCheck : missingLinkedInComposer
? (probe?.reasonCode === 'message_commit_without_composer'
? 'Message send blocked: this control commits a message (for example "Send" / "Send without a note") but no active composer or recipient could be verified. Changing click targeting methods will not help. Open the intended conversation so its composer and recipient are visible, or report that the message could not be sent.'
: 'Message send blocked: no message composer is visible, so this send cannot be verified. Changing click targeting methods will not resolve this classification failure. Re-read the page to find a supported navigation or composer-opening control; if none is available, report the blocker instead of repeating the click.')
@@ -28736,6 +28746,39 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
};
}
+ // Whether a request names the person its message is for, so that it may
+ // open that person's WhatsApp chat from the chat list before the contact
+ // check. A request for the open chat itself ("this one"), with or without
+ // people named besides it, and a target already pinned to a verified chat
+ // identity keep the check on the chat that was open.
+ _messageTargetNamesRecipient(guard, target) {
+ const named = normalizeMessageTarget(target);
+ return named?.target_kind === 'named' && named.recipients.length > 0
+ && named.recipients.every(item => !/^whatsapp:/i.test(String(item?.identity || '')))
+ && !(Array.isArray(guard?.activeConversationRecipients) && guard.activeConversationRecipients.length > 0)
+ && !normalizeMessageTarget(guard?.requestedMessaging);
+ }
+
+ // What the model reads when a message action is blocked in a native
+ // WhatsApp chat whose contact the run has not confirmed yet. The page names
+ // the confirming control (the contact name in the chat header, then the
+ // Contact info panel's Close button) as an app-issued ref when it can.
+ _nativeWhatsappContactCheckGuidance(repairTarget, { namedRecipient = false } = {}) {
+ const ref = typeof repairTarget?.ref_id === 'string' && /^ref_[A-Za-z0-9_:-]{1,100}$/.test(repairTarget.ref_id)
+ ? repairTarget.ref_id : '';
+ if (ref && repairTarget.phase === 'close_contact') {
+ return `Message action blocked, nothing was sent: this chat's Contact info panel is still open. Close it with click_ax({ref_id:"${ref}"}), the panel's own Close button, to finish confirming the contact, then retry this action.`;
+ }
+ const confirm = ref && repairTarget.phase === 'open_contact'
+ ? `click_ax({ref_id:"${ref}"}), the contact name in the chat header`
+ : 'click_ax only the contact name in the chat header (read the header with get_accessibility_tree first)';
+ return 'Message action blocked, nothing was sent: on WhatsApp, WebBrain confirms who the open chat is with before any message action in it, and this chat is not confirmed yet. '
+ + (namedRecipient
+ ? 'If this is not the chat of the person the message is for, open their chat from the chat list first; the check applies to the chat that is open. '
+ : '')
+ + `To confirm it, ${confirm}, then close the Contact info panel it opens with that panel's own Close button, and retry this action. The avatar, call, search and menu buttons do not confirm a contact.`;
+ }
+
/**
* What the model reads when a send to an unconfirmed recipient could not be
* put to the user (an unattended run) or was not confirmed. It names both
@@ -46313,6 +46356,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
watchBeep: this.scheduledRunPolicies.get(tabId)?.watch?.beep === true,
carouselNavigation: !!getCarouselNavigationPolicy(await this._currentUrl(tabId)),
gmailResultCounting: !!getGmailResultCountPolicy(await this._currentUrl(tabId)),
+ nativeChatTools: isNativeChatClientUrl(await this._currentUrl(tabId)),
researchEscalationEnabled: this.researchEscalationEnabled,
autoModeEscalation: mode === 'ask' && this._autoModeEscalationTabs.has(tabId),
});
@@ -46591,6 +46635,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
watchBeep: this.scheduledRunPolicies.get(tabId)?.watch?.beep === true,
carouselNavigation: !!getCarouselNavigationPolicy(await this._currentUrl(tabId)),
gmailResultCounting: !!getGmailResultCountPolicy(await this._currentUrl(tabId)),
+ nativeChatTools: isNativeChatClientUrl(await this._currentUrl(tabId)),
researchEscalationEnabled: this.researchEscalationEnabled,
autoModeEscalation: mode === 'ask' && this._autoModeEscalationTabs.has(tabId),
});
@@ -47807,6 +47852,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
watchBeep: this.scheduledRunPolicies.get(tabId)?.watch?.beep === true,
carouselNavigation: !!getCarouselNavigationPolicy(await this._currentUrl(tabId)),
gmailResultCounting: !!getGmailResultCountPolicy(await this._currentUrl(tabId)),
+ nativeChatTools: isNativeChatClientUrl(await this._currentUrl(tabId)),
researchEscalationEnabled: this.researchEscalationEnabled,
});
// Match the non-streaming path: selection-grounded turns are tool-free so
@@ -47921,6 +47967,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
watchBeep: this.scheduledRunPolicies.get(tabId)?.watch?.beep === true,
carouselNavigation: !!getCarouselNavigationPolicy(await this._currentUrl(tabId)),
gmailResultCounting: !!getGmailResultCountPolicy(await this._currentUrl(tabId)),
+ nativeChatTools: isNativeChatClientUrl(await this._currentUrl(tabId)),
researchEscalationEnabled: this.researchEscalationEnabled,
});
tools = this._botMemoryRunTools(tabId, tools);
diff --git a/src/firefox/src/agent/tools.js b/src/firefox/src/agent/tools.js
index e0d2175b0..c4104a3a0 100644
--- a/src/firefox/src/agent/tools.js
+++ b/src/firefox/src/agent/tools.js
@@ -1814,7 +1814,8 @@ export function getToolsForMode(mode, opts = {}) {
// A Compact provider keeps its upload_file schema: its permission gate
// accepts only an attachment and a target from upload_file's own discovery.
base = AGENT_TOOLS
- .filter(t => LEAN_TOOL_NAMES.has(t.function.name))
+ .filter(t => LEAN_TOOL_NAMES.has(t.function.name)
+ || (opts.nativeChatTools === true && LEAN_NATIVE_CHAT_TOOL_NAMES.has(t.function.name)))
.map(t => (tier === 'compact' && t.function.name === 'upload_file' ? compactUploadFileTool(t) : t));
} else if (tier === 'compact') {
base = AGENT_TOOLS
@@ -2471,6 +2472,16 @@ export const LEAN_TOOL_NAMES = new Set([
'generate_image', 'carousel_navigate', 'gmail_count_results',
]);
+/**
+ * Chat tools a lean run is also offered on a native chat client (WhatsApp
+ * Web, Telegram Web; `nativeChatTools`, from isNativeChatClientUrl). Lean mode
+ * keeps the recipient guard, which confirms a contact and reads the latest
+ * messages there through chat_observe and sends through chat_send. Without
+ * them its repairs pointed at tools the run did not have, and the planner's
+ * chat_observe/chat_send steps could not run.
+ */
+export const LEAN_NATIVE_CHAT_TOOL_NAMES = new Set(['chat_observe', 'chat_send']);
+
/**
* Lean Act prompt: short, with the hard limits and the prompt-injection
* boundary kept in full. WebBrain runs no quality checks in lean mode, so the
diff --git a/src/firefox/src/content/chat-observation.js b/src/firefox/src/content/chat-observation.js
index 6146452cf..00dce3c9c 100644
--- a/src/firefox/src/content/chat-observation.js
+++ b/src/firefox/src/content/chat-observation.js
@@ -482,6 +482,15 @@
let whatsappPending = null;
let whatsappActive = null;
let whatsappRepairAnchor = null;
+ // The anchor is normally the first chat the run looks at. A run that names
+ // its recipient may first have to open that person's chat from the chat
+ // list: the recipient probe reports that selection, and the anchor then
+ // follows WhatsApp's selection until the run arms its one check (a guarded
+ // header click). A run for the open chat itself ("this one") never moves
+ // its anchor, since that chat is its target. Once a check is armed the
+ // anchor stays with that chat, and a later selection change spends it.
+ let whatsappAnchorFollowsSelection = false;
+ let whatsappCheckArmed = false;
const whatsappRendered = node => {
if (!visible(node)) return false;
for (let current = node, depth = 0; current && depth < 128; current = current.parentElement, depth++) {
@@ -556,6 +565,7 @@
whatsappRestore = restore && typeof restore === 'object' ? restore : null;
if (next !== whatsappOwner) {
invalidateWhatsappBindings(false, true); whatsappRepairAnchor = null; whatsappOwner = next;
+ whatsappAnchorFollowsSelection = false; whatsappCheckArmed = false;
let sameRunSourceChanged = false;
try {
const prior = JSON.parse(whatsappParkedFloor?.owner || 'null'), current = JSON.parse(next || 'null');
@@ -734,22 +744,38 @@
if (!pins || !contains(pins.carrier, target)) return false;
invalidateWhatsappBindings(true, true);
whatsappPending = { pins, owner: whatsappOwner, priorDrawers: new Set(query(document, '[data-testid="chat-info-drawer"]')) };
+ // The run's one check now belongs to this chat.
+ if (whatsappAnchorFollowsSelection) whatsappRepairAnchor = { pins, invalidated: false };
+ whatsappCheckArmed = true; whatsappAnchorFollowsSelection = false;
return true;
};
window.__wb_get_native_whatsapp_repair = () => {
const composers = query(document, '[data-testid="conversation-compose-box-input"][contenteditable="true"][role="textbox"]');
const pins = composers.length === 1 ? whatsappPins(composers[0]) : null;
if (!pins || !whatsappOwner) return null;
- if (!whatsappRepairAnchor) whatsappRepairAnchor = { pins, invalidated: false };
+ if (!whatsappRepairAnchor || (whatsappAnchorFollowsSelection && !whatsappCheckArmed
+ && (whatsappRepairAnchor.invalidated || !sameWhatsappPins(whatsappRepairAnchor.pins)))) {
+ whatsappRepairAnchor = { pins, invalidated: false };
+ }
return !whatsappRepairAnchor.invalidated && sameWhatsappPins(whatsappRepairAnchor.pins) ? pins : null;
};
- // A run checks one contact through its drawer: the anchor is the first
- // chat the run looked at, and once it is invalidated, as when WhatsApp's
- // chat selection changes, no chat can be checked again until the next run
- // (a new owner). True when that is why no check is available. Anchored
- // nodes that are only hidden for now, as behind a modal, do not count.
+ // The recipient probe calls this for a guarded chat-list selection in a run
+ // that names its recipient (see whatsappAnchorFollowsSelection). False once
+ // the run has armed its check, which stays with the chat it armed.
+ window.__wb_native_whatsapp_follow_selection = () => {
+ if (!whatsappObserver || !whatsappOwner || whatsappCheckArmed) return false;
+ whatsappAnchorFollowsSelection = true;
+ return true;
+ };
+ // A run checks one contact through its drawer, for its anchor chat. Once
+ // the anchor is invalidated, as when WhatsApp's chat selection changes
+ // after the check was armed (or, in a run for the open chat, at all), no
+ // chat can be checked again until the next run (a new owner). True when
+ // that is why no check is available. Anchored nodes that are only hidden
+ // for now, as behind a modal, do not count.
window.__wb_native_whatsapp_repair_spent = () => {
if (!whatsappOwner || whatsappRepairAnchor?.invalidated !== true) return false;
+ if (whatsappAnchorFollowsSelection && !whatsappCheckArmed) return false;
const composers = query(document, '[data-testid="conversation-compose-box-input"][contenteditable="true"][role="textbox"]');
return composers.length === 1 && whatsappNativeComposer(composers[0]);
};
@@ -777,6 +803,9 @@
if (typeof ref_id !== 'string' || !/^ref_[A-Za-z0-9_:-]{1,100}$/.test(ref_id)) return null;
return { phase: drawers.length ? 'close_contact' : 'open_contact', ref_id };
};
+ // The recipient probe names this same control to the model when it blocks
+ // a message action in a chat whose contact is not confirmed yet.
+ window.__wb_native_whatsapp_repair_guidance = () => whatsappRepairGuidance();
window.__wb_native_whatsapp_repair_matches = snapshot => {
if (!snapshot || snapshot.owner !== whatsappOwner || !whatsappObserver) return false;
whatsappMutations(whatsappObserver.takeRecords());
@@ -1528,7 +1557,7 @@
// here: the native composer is no longer tied to a checked chat).
if (window.__wb_native_whatsapp_repair_spent()) {
return { success: false, schema: SCHEMA, reason: 'native_whatsapp_contact_check_spent', retryable: false,
- error: 'This run can no longer confirm a WhatsApp contact: its contact check belongs to the first chat it looked at, and WhatsApp\'s chat selection or that chat\'s header changed since. Nothing was sent. Report what was sent and that a message to this chat needs a new request; do not retry it in this run.' };
+ error: 'This run can no longer confirm a WhatsApp contact: its one contact check belongs to the chat it first looked at or started checking, and WhatsApp\'s chat selection or that chat\'s header changed since. Nothing was sent. Report what was sent and that a message to this chat needs a new request; do not retry it in this run.' };
}
if (composer && window.__wb_get_native_whatsapp_repair()?.composer === composer) {
const nativeWhatsappRepair = whatsappRepairGuidance();
diff --git a/src/firefox/src/content/content.js b/src/firefox/src/content/content.js
index 5173687dc..b7ff9fefe 100644
--- a/src/firefox/src/content/content.js
+++ b/src/firefox/src/content/content.js
@@ -7042,6 +7042,19 @@
}
const nativeWhatsappComposer = location.hostname === 'web.whatsapp.com'
&& layoutCandidate?.matches?.('[data-testid="conversation-compose-box-input"][contenteditable="true"][role="textbox"]');
+ // A row of WhatsApp's own chat list (the rows the native contact check
+ // reads), clicked on the row itself and not on its menu, link or
+ // another control nested in it.
+ const nativeWhatsappChatListRow = clicked => {
+ if (!clicked || editable(clicked)) return false;
+ const row = clicked.closest?.('[role="row"]');
+ if (!row || !row.closest?.('[data-testid="chat-list"]') || !visible(row)
+ || row.querySelectorAll('[data-testid="cell-frame-title"]').length !== 1) return false;
+ const nested = clicked.closest?.('a[href],button,input,select,textarea,summary,[contenteditable="true"],'
+ + '[contenteditable=""],[role="button"],[role="link"],[role="menuitem"],[role="checkbox"],[role="radio"],'
+ + '[role="switch"],[role="combobox"],[role="textbox"],[aria-haspopup],[onclick],[data-action]');
+ return !nested || !row.contains(nested);
+ };
if (nativeWhatsappComposer && nativeLayoutContext?.service !== 'whatsapp-self') {
const repair = window.__wb_get_native_whatsapp_repair?.();
if (!observationOnly && tool === 'click_ax' && targetResolved
@@ -7049,16 +7062,35 @@
return { success: true, messageSend: false, conclusive: true, composerAvailable: true,
nativeWhatsappRepair: true, identityCandidates: [] };
}
+ // Opening another chat from the chat list sends nothing, and a request
+ // for a named person may have to leave the chat that was open when it
+ // started. Blocking it until the open chat's contact was confirmed
+ // left the agent no way to reach the right chat. The contact check
+ // then belongs to the chat that ends up open (see
+ // __wb_native_whatsapp_follow_selection).
+ if (!observationOnly && ['click', 'click_ax'].includes(tool) && targetResolved
+ && nativeWhatsappChatListRow(target)) {
+ if (params.bindDispatch === true && params.namedRecipientSelection === true) {
+ window.__wb_native_whatsapp_follow_selection?.();
+ }
+ return { success: true, messageSend: false, conclusive: true, conversationSelection: true,
+ identityCandidates: [] };
+ }
if (nativeLayoutContext?.service !== 'whatsapp') {
// No check left in this run: say so, rather than send the agent
// after a header click that cannot help.
const spent = !repair && window.__wb_native_whatsapp_repair_spent?.() === true;
+ // Otherwise name the exact control that confirms this chat's
+ // contact, so the agent can pass it on instead of "re-read and
+ // retry", which kept a model clicking Attach and the chat row.
+ const repairTarget = !spent && repair ? window.__wb_native_whatsapp_repair_guidance?.() || null : null;
return { success: true, messageSend: observationOnly ? false : null, conclusive: false,
composerAvailable: true, nativeWhatsappRepairAvailable: !!repair,
...(spent ? { nativeWhatsappRepairSpent: true } : {}),
+ ...(repairTarget ? { nativeWhatsappRepairTarget: repairTarget } : {}),
reasonCode: spent ? 'native_whatsapp_contact_check_spent' : 'native_whatsapp_contact_binding_required', identityCandidates: [],
error: spent
- ? 'This run can no longer confirm a WhatsApp contact: its contact check belongs to the first chat it looked at, and WhatsApp\'s chat selection or that chat\'s header changed since. Nothing was sent. Report what was sent and that a message to this chat needs a new request; do not retry it in this run.'
+ ? 'This run can no longer confirm a WhatsApp contact: its one contact check belongs to the chat it first looked at or started checking, and WhatsApp\'s chat selection or that chat\'s header changed since. Nothing was sent. Report what was sent and that a message to this chat needs a new request; do not retry it in this run.'
: 'Native WhatsApp contact identity needs a fresh guarded header click, its contact drawer phone, and closing that same drawer. No message or editor write was authorized.' };
}
}
diff --git a/test/fixtures/run.mjs b/test/fixtures/run.mjs
index 1689a96ca..8ef019c10 100644
--- a/test/fixtures/run.mjs
+++ b/test/fixtures/run.mjs
@@ -5897,6 +5897,90 @@ test('click_ax: Agent.executeTool keeps synthetic-first behavior and uses truste
}
});
+// From a trace: WhatsApp's chat list rows are grid cells that a
+// script-dispatched click does not open, and the trusted retry skipped every
+// role but generic, listitem and row, so the agent could not open the chat.
+test('click_ax: a grid cell row that ignores the synthetic click gets the trusted CDP retry', async (page) => {
+ await setup(page, 'trusted-click-fallback.html');
+ const tree = await call(page, 'get_accessibility_tree', { filter: 'all', maxDepth: 10, maxChars: 30000 });
+ const content = String(tree?.pageContent || '');
+ const cellMatch = content.match(/gridcell "Grid chat row" \[(ref_\d+)\]/);
+ const selectedMatch = content.match(/gridcell "Selected grid chat row" \[(ref_\d+)\]/);
+ if (!cellMatch || !selectedMatch) throw new Error(`expected the grid chat rows in the AX tree: ${content}`);
+ const eligible = await call(page, 'ax_resolve_rect', { ref_id: cellMatch[1], forClickFallback: true });
+ if (!eligible?.success || eligible.fallbackEligible !== true || eligible.fallbackBlockedReason) {
+ throw new Error(`a grid cell row should be eligible for the trusted retry: ${JSON.stringify(eligible)}`);
+ }
+ const selected = await call(page, 'ax_resolve_rect', { ref_id: selectedMatch[1], forClickFallback: true });
+ if (selected?.fallbackEligible !== false || !/toggle\/selection/.test(selected.fallbackBlockedReason || '')) {
+ throw new Error(`a selected grid cell must stay synthetic-only: ${JSON.stringify(selected)}`);
+ }
+
+ const originalChrome = globalThis.chrome;
+ const originals = { attach: cdpClient.attach, evaluate: cdpClient.evaluate, dispatch: cdpClient.dispatchMouseEvent };
+ const session = await page.context().newCDPSession(page);
+ const dispatched = [];
+ const listener = { addListener() {}, removeListener() {} };
+ globalThis.chrome = {
+ runtime: {},
+ tabs: {
+ async get(tabId) { return { id: tabId, url: page.url(), title: 'Grid chat fixture' }; },
+ async query() { return [{ id: 42, url: page.url() }]; },
+ async sendMessage(_tabId, message) { return call(page, message.action, message.params || {}); },
+ },
+ downloads: { onCreated: listener },
+ webRequest: { onBeforeRequest: listener },
+ scripting: { async executeScript() {} },
+ };
+ try {
+ cdpClient.attach = async () => ({ tabId: 42, attached: true });
+ cdpClient.evaluate = async (_tabId, expression) => ({ result: { value: await page.evaluate(expression) } });
+ cdpClient.dispatchMouseEvent = async (_tabId, type, x, y) => {
+ dispatched.push({ type, x, y });
+ return session.send('Input.dispatchMouseEvent', {
+ type,
+ x,
+ y,
+ button: type === 'mouseMoved' ? 'none' : 'left',
+ buttons: type === 'mousePressed' ? 1 : 0,
+ clickCount: type === 'mouseMoved' ? 0 : 1,
+ });
+ };
+ const agent = new Agent({});
+ agent._isPdfTab = async () => false;
+ agent._currentUrl = async () => page.url();
+ agent._clickAxFinalSettleMs = () => 60;
+ const result = await agent.executeTool(42, 'click_ax', { ref_id: cellMatch[1] });
+ const after = await page.evaluate(() => ({
+ status: document.getElementById('status').textContent,
+ opened: document.getElementById('grid-chat-cell').classList.contains('grid-opened'),
+ events: window.__gridChatEvents,
+ }));
+ if (result?.success !== true || result.fallback !== 'cdp_after_synthetic_no_progress'
+ || result.trusted !== true || result.verified !== true) {
+ throw new Error(`the grid cell row did not get the trusted retry: ${JSON.stringify(result)}`);
+ }
+ if (after.status !== 'grid-opened' || !after.opened) {
+ throw new Error(`the trusted retry did not open the grid chat row: ${JSON.stringify(after)}`);
+ }
+ // One script-dispatched click first, then one real press and click.
+ const sequence = after.events.map(event => `${event.trusted ? 'trusted' : 'synthetic'}:${event.type}`).join(',');
+ if (sequence !== 'synthetic:click,trusted:mousedown,trusted:click') {
+ throw new Error(`unexpected grid row event sequence: ${sequence}`);
+ }
+ if (dispatched.map(event => event.type).join(',') !== 'mouseMoved,mousePressed,mouseReleased') {
+ throw new Error(`unexpected trusted input sequence: ${JSON.stringify(dispatched)}`);
+ }
+ } finally {
+ cdpClient.attach = originals.attach;
+ cdpClient.evaluate = originals.evaluate;
+ cdpClient.dispatchMouseEvent = originals.dispatch;
+ if (originalChrome === undefined) delete globalThis.chrome;
+ else globalThis.chrome = originalChrome;
+ await session.detach();
+ }
+});
+
test('set_checked: Agent.executeTool uses one trusted selector click and then becomes idempotent', async (page) => {
await setup(page, 'trusted-click-fallback.html');
const tree = await call(page, 'get_accessibility_tree', { filter: 'all', maxDepth: 10, maxChars: 30000 });
diff --git a/test/fixtures/trusted-click-fallback.html b/test/fixtures/trusted-click-fallback.html
index 8b351f5ad..b80a4a305 100644
--- a/test/fixtures/trusted-click-fallback.html
+++ b/test/fixtures/trusted-click-fallback.html
@@ -197,11 +197,16 @@
<div id="opacity-row" class="row" role="listitem" tabindex="0">Opacity row</div>
<div id="pointer-row" class="row" role="listitem" tabindex="0" style="pointer-events:none">Pointer disabled row</div>
<div id="zero-row" role="listitem" tabindex="0">Zero row</div>
+ <div id="grid-chat-list" role="grid" aria-label="Grid chat list">
+ <div role="row"><div id="grid-chat-cell" class="row" role="gridcell" tabindex="-1">Grid chat row</div></div>
+ <div role="row"><div id="grid-selected-cell" class="row" role="gridcell" tabindex="-1" aria-selected="true">Selected grid chat row</div></div>
+ </div>
<p id="status">idle</p>
<p id="ambient-status">ambient-idle</p>
<script>
window.__trustedClickEvents = [];
+ window.__gridChatEvents = [];
window.__syntheticClickEvents = [];
window.__trustedCheckboxEvents = [];
window.__frameworkInputEvents = [];
@@ -256,6 +261,18 @@
}, 40);
}
});
+ // A grid chat list row like WhatsApp's: a real press opens it, a
+ // script-dispatched click does nothing.
+ for (const type of ['mousedown', 'click']) {
+ document.getElementById('grid-chat-cell').addEventListener(type, (event) => {
+ window.__gridChatEvents.push({ trusted: event.isTrusted, type: event.type });
+ if (event.isTrusted && event.type === 'mousedown') {
+ event.currentTarget.classList.add('grid-opened');
+ event.currentTarget.setAttribute('aria-current', 'true');
+ document.getElementById('status').textContent = 'grid-opened';
+ }
+ });
+ }
document.getElementById('synthetic-row').addEventListener('click', (event) => {
window.__syntheticClickEvents.push({ trusted: event.isTrusted, type: event.type });
event.currentTarget.classList.add('synthetic-opened');
diff --git a/test/lean-mode.mjs b/test/lean-mode.mjs
index 9bd49eace..7421997fa 100644
--- a/test/lean-mode.mjs
+++ b/test/lean-mode.mjs
@@ -263,6 +263,17 @@ for (const build of ['chrome', 'firefox']) {
const conditional = names(tools.getToolsForMode('act', { tier: 'full', lean: true, imageGenConfigured: true,
carouselNavigation: true, gmailResultCounting: true }));
for (const name of ['generate_image', 'carousel_navigate', 'gmail_count_results']) assert.ok(conditional.includes(name), name);
+ // On a native chat client the recipient guard, which lean mode keeps,
+ // confirms a contact and reads the latest messages through the chat
+ // tools, so a lean run there is offered them, with the Full schemas.
+ const chat = tools.getToolsForMode('act', { tier: 'full', lean: true, nativeChatTools: true });
+ for (const name of ['chat_observe', 'chat_send']) {
+ assert.equal(names(thin).includes(name), false, `${name} is offered off a native chat client`);
+ const tool = chat.find(item => item.function.name === name);
+ assert.ok(tool, `${name} is offered on a native chat client`);
+ assert.equal(JSON.stringify(tool), JSON.stringify(full.find(item => item.function.name === name)));
+ }
+ assert.deepEqual(names(chat).filter(name => !names(thin).includes(name)).sort(), ['chat_observe', 'chat_send']);
const skill = { type: 'function', function: { name: 'read_youtube_transcript', description: 'skill', parameters: { type: 'object', properties: {} } } };
assert.ok(names(tools.getToolsForMode('act', { tier: 'full', lean: true, skillTools: [skill] })).includes('read_youtube_transcript'),
'enabled skills keep their tools');
@@ -483,6 +494,46 @@ for (const build of ['chrome', 'firefox']) {
});
}
+ // From a trace: a lean run on WhatsApp Web had no chat_observe, which the
+ // recipient guard's contact check and latest-message repairs point to, and
+ // the plan's chat_observe/chat_send steps could not run.
+ test(`${build}: a lean run on a native chat client is offered the chat tools its recipient guard uses`, async () => {
+ const adapters = await import(`../src/${build}/src/agent/adapters.js`);
+ for (const [url, offered] of [['https://web.whatsapp.com/', true], ['https://web.telegram.org/k/', true],
+ ['https://webz.telegram.org/', true], ['http://web.whatsapp.com/', false], ['https://whatsapp.com/', false], [PAGE, false]]) {
+ assert.equal(adapters.isNativeChatClientUrl(url), offered, url);
+ }
+ for (const streaming of [false, true]) {
+ for (const [url, offered] of [['https://web.whatsapp.com/', true], [PAGE, false]]) {
+ const tab = nextTab++;
+ const h = runAgent(() => call('finish', 'done', { summary: 'Read.', outcome: 'success' }), { setting: 'on' });
+ h.agent._currentUrl = async () => url;
+ await runLoop(h.agent, tab, streaming, 'Read the open chat.');
+ assert.ok(h.requests.length > 0, 'the run made a model request');
+ for (const name of ['chat_observe', 'chat_send']) {
+ assert.equal(h.requests[0].tools.includes(name), offered, `${streaming ? 'streaming' : 'plain'} ${url}: ${name}`);
+ }
+ assert.ok(h.requests[0].tools.includes('click_ax'), 'the lean core stays');
+ }
+ // A run that navigates to WhatsApp Web gets them from its next turn on.
+ const tab = nextTab++;
+ let url = PAGE;
+ const h = runAgent(n => (n === 1 ? call('go', 'navigate', { url: 'https://web.whatsapp.com/' })
+ : call('finish', 'done', { summary: 'Read.', outcome: 'success' })), { setting: 'on' });
+ h.agent._currentUrl = async () => url;
+ const execute = h.agent._executeToolWithLifecycle;
+ h.agent._executeToolWithLifecycle = async (tabId, name, args, ...rest) => {
+ if (name === 'navigate') url = args.url;
+ return execute(tabId, name, args, ...rest);
+ };
+ await runLoop(h.agent, tab, streaming, 'Open WhatsApp Web and read the open chat.');
+ assert.ok(h.requests.length >= 2, `${streaming ? 'streaming' : 'plain'}: the run took a second turn`);
+ assert.equal(h.requests[0].tools.includes('chat_observe'), false);
+ assert.equal(h.requests[1].tools.includes('chat_observe'), true, `${streaming ? 'streaming' : 'plain'}: the turn after navigating`);
+ assert.equal(h.requests[1].tools.includes('chat_send'), true);
+ }
+ });
+
test(`${build}: a lean run still refuses a tool it does not offer, and still stops at the step limit`, async () => {
const tab = nextTab++;
const h = runAgent(n => (n === 1 ? call('fetch', 'fetch_url', { url: 'https://example.com/' }) : call('save', 'click_ax', { ref_id: 'ref_save' })),
diff --git a/test/run.js b/test/run.js
index 51ccba7f3..ebe4a5616 100644
--- a/test/run.js
+++ b/test/run.js
@@ -113509,7 +113509,74 @@ test('a WhatsApp chat pinned at its first send keeps the person named besides it
const needsDrawer = await dispatch(4);
assert.equal(needsDrawer?.reasonCode, 'native_whatsapp_contact_binding_required');
assert.notEqual(needsDrawer.retryable, false, `${label}: a contact check still available was made final`);
- assert.match(needsDrawer.error, /could not conclusively resolve/);
+ // It says how to confirm the contact instead of "re-read and retry", and
+ // the chat this request points at is not one to leave.
+ assert.doesNotMatch(needsDrawer.error, /could not conclusively resolve/);
+ assert.match(needsDrawer.error, /contact name in the chat header[\s\S]*Contact info panel[\s\S]*Close button/);
+ assert.doesNotMatch(needsDrawer.error, /open their chat from the chat list/);
+ }
+});
+
+// From a trace: in a WhatsApp chat whose contact the run had not confirmed,
+// every message action came back "could not conclusively resolve the target
+// control … re-read the page and retry", so the model clicked Attach and the
+// chat row again until it gave up without sending. The block now names the
+// control that confirms the contact by the ref the page issued, and only a
+// request that names its recipient lets its chat-list selection move the
+// contact check (see test/whatsapp-chat-selection.mjs).
+test('a blocked WhatsApp message action names the control that confirms the contact', async () => {
+ for (const [label, AgentClass] of [['chrome', AgentCh], ['firefox', AgentFx]]) {
+ const agent = new AgentClass({ getVisionProvider: async () => null });
+ const tabId = label === 'chrome' ? 27331 : 27332;
+ const chatUrl = 'https://web.whatsapp.com/';
+ agent._currentUrl = async () => chatUrl;
+ const seen = [];
+ let probe = null;
+ agent._messageRecipientContentProbe = async (_tabId, params) => { seen.push(params); return probe; };
+ const start = messaging => agent._startPlanExecutionGuard(tabId, 'act', { requestKind: 'execute',
+ requiresStateChange: true, requiresSubmission: true, siteWorkflowUrl: chatUrl, messaging });
+ const needsCheck = target => ({ success: true, conclusive: false, messageSend: null, composerAvailable: true,
+ nativeWhatsappRepairAvailable: true, reasonCode: 'native_whatsapp_contact_binding_required', identityCandidates: [],
+ error: 'Native WhatsApp contact identity needs a fresh guarded header click.',
+ ...(target ? { nativeWhatsappRepairTarget: target } : {}) });
+ const attach = () => agent._messageRecipientGuardBlock(tabId, 'click_ax', { ref_id: 'ref_74' }, chatUrl, {});
+
+ start({ target_kind: 'named', recipients: [{ identity: 'Gamze', role: 'to' }] });
+ probe = needsCheck({ phase: 'open_contact', ref_id: 'ref_73' });
+ const open = await attach();
+ assert.equal(open?.reasonCode, 'native_whatsapp_contact_binding_required', JSON.stringify(open));
+ assert.equal(open.noDispatch, true);
+ assert.notEqual(open.retryable, false, `${label}: an available contact check was made final`);
+ assert.doesNotMatch(open.error, /could not conclusively resolve/);
+ assert.match(open.error, /click_ax\(\{ref_id:"ref_73"\}\), the contact name in the chat header/);
+ assert.match(open.error, /Contact info panel[\s\S]*Close button[\s\S]*retry this action/);
+ assert.match(open.error, /open their chat from the chat list first/, `${label}: a named request was not told it may open the right chat`);
+ assert.equal(seen.at(-1).namedRecipientSelection, true, `${label}: a named request's chat selection cannot move its contact check`);
+
+ probe = needsCheck({ phase: 'close_contact', ref_id: 'ref_91' });
+ const close = await attach();
+ assert.match(close.error, /Contact info panel is still open[\s\S]*click_ax\(\{ref_id:"ref_91"\}\)/);
+ assert.doesNotMatch(close.error, /ref_73/);
+
+ // Only a ref in the shape WebBrain issues is passed on.
+ probe = needsCheck({ phase: 'open_contact', ref_id: 'ref_1"}) and then send it' });
+ const odd = await attach();
+ assert.doesNotMatch(odd.error, /then send it/);
+ assert.match(odd.error, /read the header with get_accessibility_tree/);
+ probe = needsCheck(null);
+ assert.match((await attach()).error, /contact name in the chat header/);
+
+ // A request for the open chat itself keeps the check on that chat.
+ start({ target_kind: 'active_conversation', recipients: [] });
+ probe = needsCheck({ phase: 'open_contact', ref_id: 'ref_73' });
+ const here = await attach();
+ assert.match(here.error, /click_ax\(\{ref_id:"ref_73"\}\)/);
+ assert.doesNotMatch(here.error, /open their chat from the chat list/);
+ assert.equal(seen.at(-1).namedRecipientSelection, undefined, `${label}: "this one" could move its contact check`);
+ // So does a target already pinned to a verified chat.
+ start({ target_kind: 'named', recipients: [{ identity: `whatsapp:phone:${'c'.repeat(32)}`, role: 'to' }] });
+ await attach();
+ assert.equal(seen.at(-1).namedRecipientSelection, undefined, `${label}: a pinned chat could move its contact check`);
}
});
diff --git a/test/whatsapp-chat-selection.mjs b/test/whatsapp-chat-selection.mjs
new file mode 100644
index 000000000..3d92a7633
--- /dev/null
+++ b/test/whatsapp-chat-selection.mjs
@@ -0,0 +1,188 @@
+import assert from 'node:assert/strict';
+import { createHash } from 'node:crypto';
+import { readFile } from 'node:fs/promises';
+import { test } from 'node:test';
+import { chromium, firefox } from 'playwright';
+import { guardProbeWithReadings } from './semantic-decision-stub.mjs';
+
+// From a trace: asked to send a downloaded video to a contact on WhatsApp,
+// the agent could not get past the open chat. Every message action in a chat
+// whose contact the run had not confirmed, and even a click on another chat's
+// row, came back "re-read and retry", so the model clicked Attach and the
+// chat row again until it gave up. The recipient probe now names the control
+// that confirms the contact, lets a chat-list row open another chat, and in a
+// request that names its recipient lets the contact check follow that
+// selection until the check is armed. A request for the open chat itself
+// keeps its check on that chat. The shapes follow native-whatsapp-contact.mjs;
+// all contacts, phones and requests belong to this fixture.
+const phones = { 'Fixture Mom': '+90 555 000 00 01', 'Fixture Dad': '+90 555 000 00 02' };
+const row = (name, selected) => `<div role="row"><div role="gridcell"><div aria-selected="${selected}">`
+ + `<span data-testid="cell-frame-title">${name}</span><span>5:04 PM</span></div></div>`
+ + '<button type="button" aria-label="Chat menu">v</button></div>';
+const html = `<!doctype html><style>body{margin:0;font:16px sans-serif}aside{position:absolute;width:280px;left:0;top:0}#main{position:absolute;left:300px;top:0;width:920px;height:790px}header{height:70px;display:flex;gap:12px}button,[role=button]{padding:8px;cursor:pointer}[role=row]{display:flex;gap:6px;padding:6px}[role=gridcell]{width:200px}[data-testid=conversation-panel-messages]{height:600px;overflow:auto}footer{display:flex;gap:20px}[contenteditable]{min-height:36px;width:600px;border:1px solid}[data-testid=chat-info-drawer]{position:fixed;right:0;top:0;width:260px;min-height:790px;background:white;z-index:3}</style>
+<aside data-testid="chat-list">${row('Fixture Mom', true)}${row('Fixture Dad', false)}</aside>
+<div id="main" data-testid="conversation-panel-wrapper"><header data-testid="conversation-header"><div role="button" tabindex="0" data-testid="conversation-info-header"><span data-testid="conversation-info-header-chat-title"><span data-testid="conversation-info-header-chat-title-name">Fixture Mom</span></span></div><button type="button" aria-label="Voice call">Call</button></header>
+<div data-testid="conversation-panel-messages"></div><footer><button type="button" aria-label="Attach">Attach</button><div data-testid="conversation-compose-box-input" contenteditable="true" role="textbox" aria-label="Type a message"></div><button type="button" aria-label="Send">Send</button></footer></div>`;
+
+const DAD_ROW = '[data-testid="chat-list"] [role="row"]:nth-child(2) [role="gridcell"]';
+const DAD_MENU = '[data-testid="chat-list"] [role="row"]:nth-child(2) button';
+const HEADER = '[data-testid="conversation-info-header"]';
+const CLOSE = '[data-testid="chat-info-drawer"] header button';
+const SEND = 'footer [aria-label="Send"]';
+const ATTACH = 'footer [aria-label="Attach"]';
+const phoneId = phone => 'whatsapp:phone:' + createHash('sha256').update(phone.replace(/[ ()-]/g, '')).digest('hex').slice(0, 32);
+
+for (const [build, engine] of [['chrome', chromium], ['firefox', firefox]]) {
+ async function fixture(run) {
+ const browser = await engine.launch({ headless: true });
+ try {
+ const page = await browser.newPage({ viewport: { width: 1280, height: 800 } });
+ await page.route('**/*', route => route.fulfill({ contentType: 'text/html', body: html }));
+ await page.goto('https://web.whatsapp.com/');
+ await page.evaluate(phones => {
+ window.fixtureHandlers = [];
+ const api = { runtime: { getURL: p => p, onMessage: { addListener: fn => fixtureHandlers.push(fn) } } };
+ window.chrome = window.browser = api;
+ // Selecting a chat moves the list's selection and renames the open
+ // chat's header, as WhatsApp does; the composer stays mounted.
+ window.fixtureSelect = name => {
+ for (const node of document.querySelectorAll('[data-testid="chat-list"] [role="row"]')) {
+ const title = node.querySelector('[data-testid="cell-frame-title"]').textContent;
+ node.querySelector('[aria-selected]').setAttribute('aria-selected', String(title === name));
+ }
+ document.querySelector('[data-testid="conversation-info-header-chat-title-name"]').textContent = name;
+ };
+ for (const cell of document.querySelectorAll('[role="gridcell"]')) {
+ cell.addEventListener('click', () => fixtureSelect(cell.querySelector('[data-testid="cell-frame-title"]').textContent));
+ }
+ window.fixtureMenuOpened = 0;
+ for (const menu of document.querySelectorAll('[aria-label="Chat menu"]')) menu.onclick = () => { fixtureMenuOpened++; };
+ document.querySelector('[data-testid="conversation-info-header"]').onclick = () => {
+ const name = document.querySelector('[data-testid="conversation-info-header-chat-title-name"]').textContent;
+ const drawer = document.createElement('div'); drawer.setAttribute('data-testid', 'chat-info-drawer');
+ drawer.innerHTML = '<header><button type="button" aria-label="Close">Close</button></header>'
+ + '<div data-testid="contact-info-header">Contact info</div><span data-testid="contact-info-subtitle selectable-text"></span>'
+ + '<div><span data-testid="selectable-text"><span></span></span></div>';
+ drawer.querySelector('[data-testid="contact-info-subtitle selectable-text"]').textContent = name;
+ drawer.querySelector('[data-testid="selectable-text"] span').textContent = phones[name];
+ drawer.querySelector('button').onclick = () => drawer.remove();
+ document.body.append(drawer);
+ };
+ const message = document.createElement('div'); message.setAttribute('role', 'row');
+ message.innerHTML = '<div data-id="opaque-initial-Z" data-testid="conv-msg-opaque-initial-Z"><div data-testid="msg-container">'
+ + '<div data-pre-plain-text="[12:00, 08/10/2026] Fixture Mom: "><span data-testid="selectable-text">Incoming question one</span></div>'
+ + '<span data-icon="tail-in">◁</span><span data-testid="msg-meta"></span></div></div>';
+ document.querySelector('[data-testid="conversation-panel-messages"]').append(message);
+ }, phones);
+ for (const file of ['rich-text-toolbar-heuristic.js', 'accessibility-tree.js', 'chat-observation.js', 'content.js']) {
+ await page.addScriptTag({ content: await readFile(new URL(`../src/${build}/src/content/${file}`, import.meta.url), 'utf8') });
+ }
+ const owner = JSON.stringify(['owned-run-1', 'tk_aaaaaaaa', 1, 'owned-provider-1', 'owned-model', 'a'.repeat(64),
+ 'resume-task-owned-1', 'b'.repeat(64)]);
+ const call = (action, params = {}) => page.evaluate(message => new Promise(resolve => {
+ for (const handler of fixtureHandlers) handler(message, {}, resolve);
+ }), { target: 'content', action, params });
+ const observe = () => guardProbeWithReadings(params => call('observe_chat', params),
+ { _nativeChatOwner: owner, _nativeChatPendingRestore: null, adapterName: 'generic-messaging' });
+ const refOf = async selector => {
+ await call('get_accessibility_tree', { filter: 'all' });
+ return page.locator(selector).evaluate(node => __wb_ax_ref(node));
+ };
+ // The recipient probe as the agent runs it right before a click: a
+ // request that names its recipient says so (namedRecipientSelection).
+ const probe = async (selector, { named = false } = {}) => guardProbeWithReadings(
+ params => call('probe_message_recipient_guard', params), {
+ tool: 'click_ax', args: { ref_id: await refOf(selector) }, adapterName: 'generic-messaging', bindDispatch: true,
+ _nativeChatOwner: owner,
+ ...(named ? { expectedRecipients: [{ identity: 'Fixture Dad', role: 'to' }], namedRecipientSelection: true } : {}),
+ });
+ const click = async selector => call('click_ax', { ref_id: await refOf(selector), _nativeChatOwner: owner,
+ _nativeChatPendingRestore: null });
+ const confirmContact = async () => {
+ assert.equal((await click(HEADER)).success, true);
+ await page.locator('[data-testid="chat-info-drawer"]').waitFor(); await page.waitForTimeout(30);
+ assert.equal((await click(CLOSE)).success, true);
+ return observe();
+ };
+ await run({ page, observe, probe, click, refOf, confirmContact });
+ } finally { await browser.close(); }
+ }
+
+ test(`${build}: a blocked message action names the contact-name control, then the panel's Close button`, async () => {
+ await fixture(async ({ page, observe, probe, click, refOf }) => {
+ await observe();
+ const send = await probe(SEND);
+ assert.equal(send.reasonCode, 'native_whatsapp_contact_binding_required', JSON.stringify(send));
+ assert.deepEqual(send.nativeWhatsappRepairTarget, { phase: 'open_contact', ref_id: await refOf(HEADER) });
+ assert.equal((await click(HEADER)).success, true);
+ await page.locator('[data-testid="chat-info-drawer"]').waitFor(); await page.waitForTimeout(30);
+ const attach = await probe(ATTACH);
+ assert.equal(attach.reasonCode, 'native_whatsapp_contact_binding_required', JSON.stringify(attach));
+ assert.deepEqual(attach.nativeWhatsappRepairTarget, { phase: 'close_contact', ref_id: await refOf(CLOSE) });
+ assert.equal((await click(CLOSE)).success, true);
+ const bound = await observe();
+ assert.equal(bound.success, true, JSON.stringify(bound));
+ assert.equal(bound.conversationId, phoneId(phones['Fixture Mom']));
+ assert.notEqual((await probe(SEND)).reasonCode, 'native_whatsapp_contact_binding_required');
+ });
+ });
+
+ test(`${build}: another chat's row opens it while the open chat is unconfirmed; the row's own menu stays guarded`, async () => {
+ await fixture(async ({ page, observe, probe }) => {
+ await observe();
+ const row = await probe(DAD_ROW);
+ assert.equal(row.conversationSelection, true, JSON.stringify(row));
+ assert.equal(row.messageSend, false);
+ assert.equal(row.conclusive, true);
+ const menu = await probe(DAD_MENU);
+ assert.notEqual(menu.conversationSelection, true, JSON.stringify(menu));
+ assert.equal(menu.reasonCode, 'native_whatsapp_contact_binding_required', JSON.stringify(menu));
+ assert.equal(await page.evaluate(() => fixtureMenuOpened), 0, 'a probe never clicks');
+ });
+ });
+
+ test(`${build}: a request that names its recipient opens their chat and confirms that contact`, async () => {
+ await fixture(async ({ page, observe, probe, click, refOf, confirmContact }) => {
+ assert.equal((await observe()).reason, 'native_whatsapp_contact_binding_required');
+ assert.equal((await probe(DAD_ROW, { named: true })).conversationSelection, true);
+ assert.equal((await click(DAD_ROW)).success, true);
+ assert.equal(await page.locator('[data-testid="conversation-info-header-chat-title-name"]').textContent(), 'Fixture Dad');
+ const opened = await observe();
+ assert.equal(opened.reason, 'native_whatsapp_contact_binding_required', JSON.stringify(opened));
+ assert.notEqual(opened.retryable, false, 'the opened chat was refused its contact check');
+ const send = await probe(SEND, { named: true });
+ assert.deepEqual(send.nativeWhatsappRepairTarget, { phase: 'open_contact', ref_id: await refOf(HEADER) });
+ const bound = await confirmContact();
+ assert.equal(bound.success, true, JSON.stringify(bound));
+ assert.equal(bound.conversationIdentity, 'Fixture Dad');
+ assert.equal(bound.conversationId, phoneId(phones['Fixture Dad']));
+ });
+ });
+
+ test(`${build}: a request for the open chat keeps its contact check on that chat`, async () => {
+ await fixture(async ({ observe, probe, click }) => {
+ await observe();
+ assert.equal((await probe(DAD_ROW)).conversationSelection, true);
+ assert.equal((await click(DAD_ROW)).success, true);
+ const after = await observe();
+ assert.equal(after.reason, 'native_whatsapp_contact_check_spent', JSON.stringify(after));
+ assert.equal(after.retryable, false);
+ });
+ });
+
+ test(`${build}: once a check is armed, opening another chat spends it even in a named request`, async () => {
+ await fixture(async ({ page, observe, probe, click }) => {
+ await observe();
+ assert.equal((await probe(DAD_ROW, { named: true })).conversationSelection, true);
+ // The check is armed on the open chat, then the panel is closed by hand
+ // (not by the guarded Close), so nothing was confirmed.
+ assert.equal((await click(HEADER)).success, true);
+ await page.locator('[data-testid="chat-info-drawer"]').waitFor();
+ await page.locator('[aria-label="Close"]').click();
+ assert.equal((await probe(DAD_ROW, { named: true })).conversationSelection, true);
+ assert.equal((await click(DAD_ROW)).success, true);
+ const after = await observe();
+ assert.equal(after.reason, 'native_whatsapp_contact_check_spent', JSON.stringify(after));
+ });
+ });
+}