Open-source AI browser agent for Chrome and Firefox (monorepo) π§
JavaScript ai-agentai-agentsai-toolsbrowser-aibrowser-automationbrowser-extensionchrome-aichrome-devtoolschrome-extensionchrome-extensionsfirefox-addonfirefox-addonsfirefox-extensionfirefox-extensionsgemmagemma4minimaxoffline-aioffline-llmqwen
Ask cards: one answer covers one tool call
Barack Sokullu9e4bcdaad358
diff --git a/docs/guards.md b/docs/guards.mdindex 2463fac58..295f3df15 100644--- a/docs/guards.md+++ b/docs/guards.md@@ -78,11 +78,14 @@ When a guard cannot verify a consequential step and its `onCannotDecide` isplain text, at most about 1,500 characters. That text is page content: theside panel renders it with `textContent` only, and it never reaches themodel. When there is nothing to show, the card says to check the page.-- **Answers.** Two fixed values, "Go ahead" (`once`) and "Don't" (`deny`). An- answer covers this one step and the content the user saw: changed content- is asked about again, and a declined step with the same content is not.- When the checks after a "Go ahead" reach another guard's question about the- same action, that card is asked in turn and the first answer stands.+- **Answers.** Two fixed values, "Go ahead" (`once`) and "Don't" (`deny`). A+ "Go ahead" covers one tool call and the content the user saw: every check+ that call runs sees it, and it is spent when the call ends, sent or not, so+ the next attempt (a repeated commit or post included) asks again. Changed+ content is asked about again, and a declined step with the same content is+ not. When the checks after a "Go ahead" reach another guard's question+ about the same action, that card is asked in turn and the first answer+ stands.- **Timeout.** A quality guard's card follows Settings β General: the clarifytimeout (Off waits, Instant answers at once) and "When a question timesout" (`finish` goes ahead, `safe` does not). A hard-class card never timesdiff --git a/src/chrome/src/agent/agent.js b/src/chrome/src/agent/agent.jsindex d56e436b8..35a0d4311 100644--- a/src/chrome/src/agent/agent.js+++ b/src/chrome/src/agent/agent.js@@ -1147,6 +1147,7 @@ export class Agent extends LoopDetector {this.planReviewConfidenceThreshold = PLAN_REVIEW_CONFIDENCE_DEFAULT;this._pendingPlans = new Map(); // tabId β (planId β { resolve, ts })this._planExecutionGuards = new Map(); // tabId β current run's plan-only terminal recovery state+ this._unverifiedStepScopes = new Map(); // tabId β { used: Set } 'once' answers the current tool call relies onthis._continuationExecutionEvidence = new Map(); // tabId β app-owned evidence carried only by continueProcessing()this._continuationResponseLanguagePolicies = new Map(); // tabId -> trusted policy carried only by continueProcessing()// Stale click detection: per-tab last clicked element identity.@@ -2986,7 +2987,8 @@ export class Agent extends LoopDetector {// and the commit asks again.async _refreshGithubUnverifiedEditorApproval(tabId, pageUrl) {const candidate = this._githubUnverifiedEditorCandidate(tabId, pageUrl);- const approval = candidate && this._unverifiedStepApproval(tabId, 'github-commit-evidence-binding', candidate.stepKey);+ const approval = candidate && this._unverifiedStepApproval(tabId, 'github-commit-evidence-binding', candidate.stepKey,+ { peek: true });if (!approval) return;let live = null;try { live = candidate.target ? await this._textMutationValueDigest(tabId, candidate.target) : null; } catch { live = null; }@@ -3346,7 +3348,7 @@ export class Agent extends LoopDetector {// commits at all. When a commit click would be allowed now (the file// and message binding is in place, verified or approved by the user),// the user decides on WebBrain's card, which shows the editor's text.- // One answer covers this one action (_unverifiedStepApproval consume).+ // One answer covers this one tool call (_unverifiedStepApproval).if (inconclusiveSubmitCapable&& this._guardOutcome('github-commit-split-write-required', { decided: false }) === 'ask') {const pageUrl = await this._currentUrl(tabId);@@ -6037,6 +6039,7 @@ export class Agent extends LoopDetector {}_releaseRunEntry(tabId) {+ this._settleUnverifiedStepScope(tabId);const feedbackRun = this._pageFeedbackRuns?.get(tabId);if (feedbackRun?.monitoringRetry && !feedbackRun.monitoringRetry.started) {this._restoreFailureRecoveryStart(tabId, feedbackRun.monitoringRetry.requestId, feedbackRun.onUpdate, feedbackRun.monitoringRetry);@@ -14811,6 +14814,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d}throw error;} finally {+ this._settleUnverifiedStepScope(tabId);// Each child owns its nonce boundary and trusted notes. Never re-wrap.if (parentCalls.length) {const folded = foldBrowserBatchMessages(messages, { repairPending: true });@@ -15088,6 +15092,8 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d}const callState = { index: toolIndex, invoked: false, consequential: false, result: null, dispatchState: null, guardAdvisories: [] };cancellationState.active = callState;+ // The user's 'once' answers this call relies on are spent with it.+ this._beginUnverifiedStepScope(tabId);// Abort check before each tool call.if (this._checkAbort(tabId)) {const value = '[Stopped by user before executing requested tool calls.]';@@ -30387,33 +30393,59 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d/*** The 'once' that covers this guard's step, or null. `contentSha256`, when* given, must be the content the user was shown. A guard whose own refresh- * found the content changed marks the answer stale; `consume` uses up a- * one-step answer, so the next such action is asked about again.+ * found the content changed marks the answer stale. A 'once' covers one+ * tool call: inside a call, every check it runs (again after another+ * guard's card, too) sees the answer, and the answer is spent when the call+ * ends, whether or not the step went out (_settleUnverifiedStepScope), so+ * the next such action, a repeated commit or post included, is asked about+ * again. Outside a call, `consume` spends it now. `peek` only looks.*/- _unverifiedStepApproval(tabId, guardId, stepKey, { contentSha256 = null, consume = false } = {}) {+ _unverifiedStepApproval(tabId, guardId, stepKey, { contentSha256 = null, consume = false, peek = false } = {}) {if (!stepKey) return null;const entry = this._unverifiedStepDecisions(tabId).findLast(item => item.guardId === guardId && item.stepKey === stepKey&& (contentSha256 === null || item.contentSha256 === contentSha256));if (!entry || entry.choice !== 'once' || entry.stale === true || entry.consumed === true) return null;- if (consume) entry.consumed = true;+ if (!peek) this._useUnverifiedStepApproval(tabId, entry, consume);return entry;}+ _useUnverifiedStepApproval(tabId, entry, consume = false) {+ const scope = this._unverifiedStepScopes.get(tabId);+ if (scope) scope.used.add(entry);+ else if (consume) entry.consumed = true;+ }++ // Each tool call of a batch is one scope for the user's 'once' answers:+ // the answers it relied on are spent when the next call starts, when the+ // batch ends, or when the run ends.+ _beginUnverifiedStepScope(tabId) {+ this._settleUnverifiedStepScope(tabId);+ this._unverifiedStepScopes.set(tabId, { used: new Set() });+ }++ _settleUnverifiedStepScope(tabId) {+ const scope = this._unverifiedStepScopes.get(tabId);+ if (!scope) return;+ this._unverifiedStepScopes.delete(tabId);+ for (const entry of scope.used) entry.consumed = true;+ }+/**- * Use up the one-step 'once' for `ask` only while the page still shows the+ * Use the one-step 'once' for `ask` only while the page still shows the* content the user saw on the card: the same target is read again now, and* its text must match the answer's digest and length. The user's latest* answer for the step decides; changed or unreadable content returns- * false, so the caller asks again with what the page holds now.+ * false, so the caller asks again with what the page holds now. The answer+ * is spent with the call that used it (_unverifiedStepApproval).*/async _consumeContentBoundApproval(tabId, ask) {- const approval = this._unverifiedStepApproval(tabId, ask?.guardId, ask?.stepKey);+ const approval = this._unverifiedStepApproval(tabId, ask?.guardId, ask?.stepKey, { peek: true });if (!approval) return false;const reading = await this._unverifiedStepReading(tabId, ask);if (!reading.readable || !approval.contentSha256 || reading.sha256 !== approval.contentSha256|| reading.length !== approval.contentLength) return false;if (approval.consumed === true || approval.stale === true) return false;- approval.consumed = true;+ this._useUnverifiedStepApproval(tabId, approval, true);return true;}diff --git a/src/firefox/src/agent/agent.js b/src/firefox/src/agent/agent.jsindex fc1171a40..4507933d6 100644--- a/src/firefox/src/agent/agent.js+++ b/src/firefox/src/agent/agent.js@@ -805,6 +805,7 @@ export class Agent extends LoopDetector {this.planReviewConfidenceThreshold = PLAN_REVIEW_CONFIDENCE_DEFAULT;this._pendingPlans = new Map();this._planExecutionGuards = new Map(); // tabId β current run's plan-only terminal recovery state+ this._unverifiedStepScopes = new Map(); // tabId β { used: Set } 'once' answers the current tool call relies onthis._continuationExecutionEvidence = new Map(); // tabId β app-owned evidence carried only by continueProcessing()this._continuationResponseLanguagePolicies = new Map(); // tabId -> trusted policy carried only by continueProcessing()// Strict secret-handling mode β see chrome/agent.js for rationale.@@ -2543,7 +2544,8 @@ export class Agent extends LoopDetector {// and the commit asks again.async _refreshGithubUnverifiedEditorApproval(tabId, pageUrl) {const candidate = this._githubUnverifiedEditorCandidate(tabId, pageUrl);- const approval = candidate && this._unverifiedStepApproval(tabId, 'github-commit-evidence-binding', candidate.stepKey);+ const approval = candidate && this._unverifiedStepApproval(tabId, 'github-commit-evidence-binding', candidate.stepKey,+ { peek: true });if (!approval) return;let live = null;try { live = candidate.target ? await this._textMutationValueDigest(tabId, candidate.target) : null; } catch { live = null; }@@ -2903,7 +2905,7 @@ export class Agent extends LoopDetector {// commits at all. When a commit click would be allowed now (the file// and message binding is in place, verified or approved by the user),// the user decides on WebBrain's card, which shows the editor's text.- // One answer covers this one action (_unverifiedStepApproval consume).+ // One answer covers this one tool call (_unverifiedStepApproval).if (inconclusiveSubmitCapable&& this._guardOutcome('github-commit-split-write-required', { decided: false }) === 'ask') {const pageUrl = await this._currentUrl(tabId);@@ -5583,6 +5585,7 @@ export class Agent extends LoopDetector {}_releaseRunEntry(tabId) {+ this._settleUnverifiedStepScope(tabId);const feedbackRun = this._pageFeedbackRuns?.get(tabId);if (feedbackRun?.monitoringRetry && !feedbackRun.monitoringRetry.started) {this._restoreFailureRecoveryStart(tabId, feedbackRun.monitoringRetry.requestId, feedbackRun.onUpdate, feedbackRun.monitoringRetry);@@ -13176,6 +13179,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d}throw error;} finally {+ this._settleUnverifiedStepScope(tabId);// Each child owns its nonce boundary and trusted notes. Never re-wrap.if (parentCalls.length) {const folded = foldBrowserBatchMessages(messages, { repairPending: true });@@ -13449,6 +13453,8 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d}const callState = { index: toolIndex, invoked: false, consequential: false, result: null, dispatchState: null, guardAdvisories: [] };cancellationState.active = callState;+ // The user's 'once' answers this call relies on are spent with it.+ this._beginUnverifiedStepScope(tabId);if (this._checkAbort(tabId)) {const value = '[Stopped by user before executing requested tool calls.]';this._appendSyntheticToolResults(tabId, toolCalls, toolIndex, messages, onUpdate, step, () => ({@@ -27493,33 +27499,59 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d/*** The 'once' that covers this guard's step, or null. `contentSha256`, when* given, must be the content the user was shown. A guard whose own refresh- * found the content changed marks the answer stale; `consume` uses up a- * one-step answer, so the next such action is asked about again.+ * found the content changed marks the answer stale. A 'once' covers one+ * tool call: inside a call, every check it runs (again after another+ * guard's card, too) sees the answer, and the answer is spent when the call+ * ends, whether or not the step went out (_settleUnverifiedStepScope), so+ * the next such action, a repeated commit or post included, is asked about+ * again. Outside a call, `consume` spends it now. `peek` only looks.*/- _unverifiedStepApproval(tabId, guardId, stepKey, { contentSha256 = null, consume = false } = {}) {+ _unverifiedStepApproval(tabId, guardId, stepKey, { contentSha256 = null, consume = false, peek = false } = {}) {if (!stepKey) return null;const entry = this._unverifiedStepDecisions(tabId).findLast(item => item.guardId === guardId && item.stepKey === stepKey&& (contentSha256 === null || item.contentSha256 === contentSha256));if (!entry || entry.choice !== 'once' || entry.stale === true || entry.consumed === true) return null;- if (consume) entry.consumed = true;+ if (!peek) this._useUnverifiedStepApproval(tabId, entry, consume);return entry;}+ _useUnverifiedStepApproval(tabId, entry, consume = false) {+ const scope = this._unverifiedStepScopes.get(tabId);+ if (scope) scope.used.add(entry);+ else if (consume) entry.consumed = true;+ }++ // Each tool call of a batch is one scope for the user's 'once' answers:+ // the answers it relied on are spent when the next call starts, when the+ // batch ends, or when the run ends.+ _beginUnverifiedStepScope(tabId) {+ this._settleUnverifiedStepScope(tabId);+ this._unverifiedStepScopes.set(tabId, { used: new Set() });+ }++ _settleUnverifiedStepScope(tabId) {+ const scope = this._unverifiedStepScopes.get(tabId);+ if (!scope) return;+ this._unverifiedStepScopes.delete(tabId);+ for (const entry of scope.used) entry.consumed = true;+ }+/**- * Use up the one-step 'once' for `ask` only while the page still shows the+ * Use the one-step 'once' for `ask` only while the page still shows the* content the user saw on the card: the same target is read again now, and* its text must match the answer's digest and length. The user's latest* answer for the step decides; changed or unreadable content returns- * false, so the caller asks again with what the page holds now.+ * false, so the caller asks again with what the page holds now. The answer+ * is spent with the call that used it (_unverifiedStepApproval).*/async _consumeContentBoundApproval(tabId, ask) {- const approval = this._unverifiedStepApproval(tabId, ask?.guardId, ask?.stepKey);+ const approval = this._unverifiedStepApproval(tabId, ask?.guardId, ask?.stepKey, { peek: true });if (!approval) return false;const reading = await this._unverifiedStepReading(tabId, ask);if (!reading.readable || !approval.contentSha256 || reading.sha256 !== approval.contentSha256|| reading.length !== approval.contentLength) return false;if (approval.consumed === true || approval.stale === true) return false;- approval.consumed = true;+ this._useUnverifiedStepApproval(tabId, approval, true);return true;}diff --git a/test/guard-ask-cards.mjs b/test/guard-ask-cards.mjsindex 168d07f32..3db0a80b9 100644--- a/test/guard-ask-cards.mjs+++ b/test/guard-ask-cards.mjs@@ -496,6 +496,22 @@ for (const { build, Agent, adapters, Scheduler } of builds) {assert.equal(dispatched.length, 2);});+ test(`${build}: one answer covers one commit call; committing the same text again asks again`, async () => {+ const { agent, tab, provider } = await githubFixture();+ const { dispatched, cards, run } = pipeline(agent, provider, 'once');+ await run(tab, [call('commit-1', 'click_ax', { ref_id: 'ref_7' })]);+ assert.equal(cards.length, 1);+ assert.equal(dispatched.length, 1);+ assert.equal(agent._completionSubmitStates.get(tab).workflowBinding.githubFileCommit.unverifiedApprovalSource, 'user',+ 'the commit that went out carries the answer on its receipt');+ // The editor reads the same as on the card, but the answer was spent with+ // the commit call: a second commit is asked about again.+ await run(tab, [call('commit-2', 'click_ax', { ref_id: 'ref_7' })]);+ assert.equal(cards.length, 2, 'a repeated commit is asked about again');+ assert.equal(cards[1].unverifiedStepConfirmation.content, POST_BODY);+ assert.equal(dispatched.length, 2);+ });+// ββ github-commit-split-write-required βββββββββββββββββββββββββββββββββtest(`${build}: an action that may or may not commit asks when a commit is otherwise allowed`, async () => {for (const strict of [false, true]) {@@ -583,6 +599,25 @@ for (const { build, Agent, adapters, Scheduler } of builds) {{ ...unreadableBlock.unverifiedStepConfirmation, target: null }), false, 'no reading, no approval');});+ test(`${build}: inside one call, a split-write answer holds for every re-run of the call's checks`, async () => {+ const { agent, tab } = await githubFixture();+ const editorTarget = agent._textMutationTarget(tab, 'set_field', { ref_id: 'ref_editor' });+ agent._unverifiedTextWrites.delete(tab);+ agent._verifiedTextReplacements.get(tab).set(editorTarget.key, await agent._verifiedTextReplacementRecord(tab, editorTarget, POST_BODY, EDITOR_META));+ const rerun = () => agent._workflowPreSubmitDispatchBlock(tab, 'execute_js', { code: 'void 0' }, null);+ const cards = [];+ agent._beginUnverifiedStepScope(tab);+ const resolved = await agent._resolveUnverifiedStepConfirmation(tab, await rerun(), (type, data) => {+ if (type === 'clarify') { cards.push(data); agent.submitClarifyResponse(tab, data.clarifyId, 'once', 'option'); }+ }, rerun, []);+ assert.equal(resolved, null);+ assert.equal(await rerun(), null, 'the same call checks again on the same answer');+ assert.equal(await rerun(), null);+ agent._settleUnverifiedStepScope(tab);+ assert.equal(cards.length, 1);+ assert.ok((await rerun()).unverifiedStepConfirmation, 'the next call asks again');+ });+// ββ social-publication-draft-quality βββββββββββββββββββββββββββββββββββ// The user asked to publish; the X composer's draft could not be confirmed// against the contract. The card shows the composer's text; the@@ -651,6 +686,33 @@ for (const { build, Agent, adapters, Scheduler } of builds) {assert.equal((await check()).unverifiedStepConfirmation.text, 'Hell');});+ test(`${build}: a draft answer covers one publish call; publishing the same draft again asks again`, async () => {+ const f = socialFixture();+ const check = () => f.agent._workflowPreSubmitDispatchBlock(f.tab, 'click_ax', { ref_id: 'ref_post' }, f.detected, f.provider);+ const late = async () => f.agent._withoutUnverifiedStepAsk(await f.agent._socialPublicationPreSubmitBlock(f.tab, 'click_ax',+ { ref_id: 'ref_post' }, f.detected, f.provider));+ const cards = [];+ const answer = (type, data) => {+ if (type === 'clarify') { cards.push(data); f.agent.submitClarifyResponse(f.tab, data.clarifyId, 'once', 'option'); }+ };+ // The publish call: its checks and the pipeline's late check see the answer.+ f.agent._beginUnverifiedStepScope(f.tab);+ assert.equal(await f.agent._resolveUnverifiedStepConfirmation(f.tab, await check(), answer, check, []), null);+ assert.equal(await check(), null, 'the call\'s checks run again on the same answer');+ assert.equal(await late(), null);+ f.agent._settleUnverifiedStepScope(f.tab);+ assert.equal(cards.length, 1);+ assert.equal(f.audits.length, 1);+ assert.ok(f.guard.socialPublication.dispatch, 'the audited dispatch keeps its key');+ // The next publish call with the unchanged draft does not reuse the+ // answer, so it cannot skip the card and the audit.+ f.agent._beginUnverifiedStepScope(f.tab);+ const again = await check();+ f.agent._settleUnverifiedStepScope(f.tab);+ assert.equal(again?.noDispatch, true, 'a repeated publish is not let through');+ assert.equal(again.unverifiedStepConfirmation?.guardId, 'social-publication-draft-quality', 'it is asked about again');+ });+test(`${build}: an unobserved account, a wrong reply target, or Strict checks keep the draft refusal without a card`, async () => {const account = socialFixture();delete account.detected.publicationSnapshot.account;@@ -747,6 +809,41 @@ for (const { build, Agent, adapters, Scheduler } of builds) {assert.equal(same.agent._unverifiedStepDecisions(same.tab).find(entry => entry.guardId === draftAsk.guardId)?.stale, true);});+ test(`${build}: an answer its guard spends at check time holds while a second guard's card is asked`, async () => {+ const agent = new Agent({});+ agent._persist = () => {};+ agent.clarifyTimeoutSec = 30;+ const tab = nextTab++;+ agent._taskTokens.set(tab, `task-${tab}`);+ agent._lastAxScopes.set(tab, { documentToken: 'doc', pageUrl: 'https://forms.example/apply' });+ agent._planExecutionGuards.set(tab, { enabled: true, taskKey: 'steered', steeringPriorSubmission: { actionSequence: 3 } });+ const refusal = { success: false, dispatched: false, noDispatch: true, error: 'refused' };+ const second = { guardId: 'social-publication-draft-quality', hard: false, action: 'publish', reason: 'draft_unverified',+ host: 'forms.example', contentLabel: 'composer', text: 'Helo', stepKey: 'second-step' };+ // The call's checks: the real unidentified-control guard (it spends its+ // answer as it checks), then another guard about the same click.+ const checks = async () => agent._steeringPriorSubmissionBlock(tab, 'click_ax', { ref_id: 'ref_9' }, null)+ || (agent._unverifiedStepApproval(tab, second.guardId, second.stepKey) ? null : { ...refusal, unverifiedStepConfirmation: second });+ const cards = [];+ const answer = (type, data) => {+ if (type !== 'clarify') return;+ cards.push(data.unverifiedStepConfirmation.guardId);+ agent.submitClarifyResponse(tab, data.clarifyId, 'once', 'option');+ };+ agent._beginUnverifiedStepScope(tab);+ const advisories = [];+ const resolved = await agent._resolveUnverifiedStepConfirmation(tab, await checks(), answer, checks, advisories);+ agent._settleUnverifiedStepScope(tab);+ assert.equal(resolved, null);+ assert.deepEqual(cards, ['steer-prior-submission-target-unresolved', second.guardId], 'each guard asks once');+ assert.deepEqual(advisories.map(item => item.guard), cards);+ // Both answers were spent with that call: the next one asks again.+ agent._beginUnverifiedStepScope(tab);+ const next = await checks();+ agent._settleUnverifiedStepScope(tab);+ assert.equal(next.unverifiedStepConfirmation.guardId, 'steer-prior-submission-target-unresolved');+ });+// ββ steer-prior-submission-target-unresolved βββββββββββββββββββββββββββtest(`${build}: after a correction, an unidentified control asks instead of refusing`, async () => {for (const strict of [false, true]) {@@ -1000,6 +1097,63 @@ test('chrome: an approved repeat click releases its lock only when it is sent',}});+// Two guards ask about one click (after a correction, an unidentified+// control that is also locked by an earlier unverified click): each card is+// asked once, the click goes out once, and both answers are spent with it.+test('chrome: a click two guards ask about is asked once per guard and sent once', async () => {+ const { Agent } = builds.find(item => item.build === 'chrome');+ const provider = { name: 'lock test', model: 'test', promptTier: 'full', contextWindow: 128000,+ supportsTools: true, supportsVision: false, chat: async () => ({ content: '' }) };+ const agent = new Agent({ getActive: () => provider, getProvider: () => provider, getVisionProvider: async () => null });+ agent.clarifyTimeoutSec = 30;+ agent._persist = () => {};+ agent._persistNow = async () => ({ ok: true });+ const tab = nextTab++;+ agent._taskTokens.set(tab, `task-${tab}`);+ agent._planExecutionGuards.set(tab, { enabled: false, taskKey: `key-${tab}`, steeringPriorSubmission: { actionSequence: 3 } });+ agent._lastAxScopes.set(tab, { documentToken: 'doc-1', pageUrl: 'https://shop.example/cart' });+ agent._currentUrl = async () => 'https://shop.example/cart';+ agent._rememberTaskClickLock(tab, 'doc-1|ref_buy');+ agent._rememberTaskClickLock(tab, 'native-button-pending:doc-1|ref_buy');+ agent._skipPermissionGate = true;+ agent._ensureGateSetting = async () => true;+ for (const name of ['_chromeProtectedPageFailure', '_captchaMutationPreflight', '_messageRecipientGuardBlock',+ '_detectLikelySubmitAction', '_socialPublicationPreSubmitBlock']) agent[name] = async () => null;+ agent._adoptLiveSocialPublishWorkflow = async () => false;+ agent._captureFormValidationState = async () => [];+ agent._waitForFormValidationFailure = async () => null;+ agent._auditRichTextToolbarTarget = async () => {};+ agent._shouldAutoScreenshot = () => false;+ agent._refreshPageFeedbackForCall = async () => false;+ const dispatched = [];+ agent._dispatchClickAxImpl = async (_tab, args, _scope, _binding, _context, _deadline, _upstream, dispatchState) => {+ dispatched.push(args.ref_id);+ dispatchState.started = true;+ return { success: true, dispatched: true, verified: true };+ };+ const cards = [];+ const run = async id => {+ const messages = [];+ await agent._executeToolBatch(tab, [call(id, 'click_ax', { ref_id: 'ref_buy' })], messages, (type, data) => {+ if (type !== 'clarify') return;+ cards.push(data.unverifiedStepConfirmation.guardId);+ setTimeout(() => agent.submitClarifyResponse(tab, data.clarifyId, 'once', 'option'), 10);+ }, provider, null, new Set(['click_ax', 'done']), 1, {});+ return resultFor(messages, id);+ };+ const first = await run('buy-1');+ assert.deepEqual(cards, ['steer-prior-submission-target-unresolved', 'clickax-task-click-lock'], 'each guard asks once');+ assert.equal(first.success, true, JSON.stringify(first));+ assert.deepEqual(dispatched, ['ref_buy'], 'one click');+ assert.deepEqual(first.guardAdvisories.map(item => item.guard).sort(),+ ['clickax-task-click-lock', 'steer-prior-submission-target-unresolved']);+ // The click went out and released its lock; the correction's answer was+ // spent with it, so the next click on the control asks again.+ await run('buy-2');+ assert.deepEqual(cards.slice(2), ['steer-prior-submission-target-unresolved']);+ assert.deepEqual(dispatched, ['ref_buy', 'ref_buy']);+});+// ββ side panel βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββlet chromiumBrowser;before(async () => { chromiumBrowser = await chromium.launch({ headless: true }); });