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
Let a verified password entry continue its browser batch
Claudecfe6b2adc6f6
diff --git a/docs/agent-tools.md b/docs/agent-tools.mdindex 92caebac2..cbf88009f 100644--- a/docs/agent-tools.md+++ b/docs/agent-tools.md@@ -165,8 +165,10 @@ Navigation also stops unless only trailing observations remain. Mid's usualsingle-action boundary is suspended inside a batch but still applies after it.Coordinate clicks after an earlier mutation are rejected during validation.-Verified `set_field`/`type_ax`/`type_text` edits to native input and textarea controls can-continue within the same batch using updated evidence for those exact values.+Verified `set_field`/`type_ax`/`type_text` edits to native input and textarea controls,+password fields included, can continue within the same batch using updated+evidence for those exact values, so a login's username, password and button can+run in one batch.Element identities, labels, surrounding form/recipient bindings, other controlvalues and user-interaction checks remain fixed. A sibling call or anotherbatch cannot reuse that exception. Selects, contenteditable editors and clicksdiff --git a/docs/prompt-injection-defense.md b/docs/prompt-injection-defense.mdindex a52454771..0240eabd6 100644--- a/docs/prompt-injection-defense.md+++ b/docs/prompt-injection-defense.md@@ -140,8 +140,10 @@ the first action; neither allowlist membership nor a valid earlier actionauthorizes a later malformed or unavailable tool.The page monitor permits a narrow continuation after verified `set_field`,-`type_ax`, or `type_text` input into a native input/textarea: only the completed control's value-evidence changes, bound to the original snapshot and the same parent batch.+`type_ax`, or `type_text` input into a native input/textarea, password fields+included: only the completed control's value evidence changes, bound to the+original snapshot and the same parent batch. The typed value is compared in the+monitor's isolated world and never leaves it.Node identities, labels, ancestors, form/recipient identity, all other valuesand human-interaction authority remain checked. Other batches and top-levelsibling calls cannot borrow that evidence. No new model snapshot is captureddiff --git a/src/chrome/src/agent/page-feedback.js b/src/chrome/src/agent/page-feedback.jsindex 9bab8449d..0acf3dbbf 100644--- a/src/chrome/src/agent/page-feedback.js+++ b/src/chrome/src/agent/page-feedback.js@@ -1389,7 +1389,8 @@ export const pageFeedbackMethods = {...(typeof response.reason === 'string' && ['target_changed', 'target_unresolved', 'target_ambiguous', 'target_uncovered','focus_changed', 'intervention_changed', 'model_snapshot_invalid', 'model_snapshot_expired','pending_feedback', 'target_hidden', 'target_disabled', 'target_detached', 'parent_changed', 'form_changed',- 'relaxed_grant_expired', 'relaxed_target_changed', 'target_not_actionable'].includes(response.reason) ? { predicate: response.reason } : {}),+ 'relaxed_grant_expired', 'relaxed_target_changed', 'target_not_actionable', 'semantic_binding_changed',+ 'target_hit_changed'].includes(response.reason) ? { predicate: response.reason } : {}),});if (retry && !valid && response.uncertified !== true) this._invalidateMonitoringRetry(tabId, 'target_changed');}diff --git a/src/chrome/src/content/page-monitor.js b/src/chrome/src/content/page-monitor.jsindex 07a1424ea..11023adbd 100644--- a/src/chrome/src/content/page-monitor.js+++ b/src/chrome/src/content/page-monitor.js@@ -1822,8 +1822,11 @@const current = operationBinding(op);if (!inputContinuationBindingMatches(op, current)) return false;const target = op.preparedBinding.target;+ // A password field is a text field here too: its typed value is checked+ // in this realm and never leaves it, so a login's username, password and+ // button can run in one batch.if (target.tagName !== 'TEXTAREA' && !(target.tagName === 'INPUT'- && !['password', 'file', 'hidden', 'checkbox', 'radio', 'button', 'submit', 'reset', 'image'].includes(target.type))) return false;+ && !['file', 'hidden', 'checkbox', 'radio', 'button', 'submit', 'reset', 'image'].includes(target.type))) return false;const originalField = preparedBindingFor(op.preparedBinding).nodes.find(item => item.node === target);const originalValue = originalField && JSON.parse(originalField.value)[12];const expectedValue = params.batchInputClear === true ? params.batchInputText : originalValue + params.batchInputText;diff --git a/src/chrome/src/trace/privacy.js b/src/chrome/src/trace/privacy.jsindex b59a430f3..2ce6f2154 100644--- a/src/chrome/src/trace/privacy.js+++ b/src/chrome/src/trace/privacy.js@@ -80,7 +80,8 @@ const CERTIFICATION_FAILURES = new Set(['owner_unresolved', 'identity_unobservedconst ACTION_PREDICATES = new Set(['target_changed', 'target_unresolved', 'target_ambiguous', 'target_uncovered', 'focus_changed','intervention_changed', 'model_snapshot_invalid', 'model_snapshot_expired', 'pending_feedback','target_hidden', 'target_disabled', 'target_detached', 'parent_changed', 'form_changed',- 'relaxed_grant_expired', 'relaxed_target_changed', 'target_not_actionable']);+ 'relaxed_grant_expired', 'relaxed_target_changed', 'target_not_actionable', 'semantic_binding_changed',+ 'target_hit_changed']);function validationFailureMetadata(value) {if (VALIDATION_FAILURE_CODES.has(value) || PUBLICATION_CONTRACT_CODES.has(value)) return value;diff --git a/src/firefox/src/agent/page-feedback.js b/src/firefox/src/agent/page-feedback.jsindex 9bab8449d..0acf3dbbf 100644--- a/src/firefox/src/agent/page-feedback.js+++ b/src/firefox/src/agent/page-feedback.js@@ -1389,7 +1389,8 @@ export const pageFeedbackMethods = {...(typeof response.reason === 'string' && ['target_changed', 'target_unresolved', 'target_ambiguous', 'target_uncovered','focus_changed', 'intervention_changed', 'model_snapshot_invalid', 'model_snapshot_expired','pending_feedback', 'target_hidden', 'target_disabled', 'target_detached', 'parent_changed', 'form_changed',- 'relaxed_grant_expired', 'relaxed_target_changed', 'target_not_actionable'].includes(response.reason) ? { predicate: response.reason } : {}),+ 'relaxed_grant_expired', 'relaxed_target_changed', 'target_not_actionable', 'semantic_binding_changed',+ 'target_hit_changed'].includes(response.reason) ? { predicate: response.reason } : {}),});if (retry && !valid && response.uncertified !== true) this._invalidateMonitoringRetry(tabId, 'target_changed');}diff --git a/src/firefox/src/content/page-monitor.js b/src/firefox/src/content/page-monitor.jsindex 07a1424ea..11023adbd 100644--- a/src/firefox/src/content/page-monitor.js+++ b/src/firefox/src/content/page-monitor.js@@ -1822,8 +1822,11 @@const current = operationBinding(op);if (!inputContinuationBindingMatches(op, current)) return false;const target = op.preparedBinding.target;+ // A password field is a text field here too: its typed value is checked+ // in this realm and never leaves it, so a login's username, password and+ // button can run in one batch.if (target.tagName !== 'TEXTAREA' && !(target.tagName === 'INPUT'- && !['password', 'file', 'hidden', 'checkbox', 'radio', 'button', 'submit', 'reset', 'image'].includes(target.type))) return false;+ && !['file', 'hidden', 'checkbox', 'radio', 'button', 'submit', 'reset', 'image'].includes(target.type))) return false;const originalField = preparedBindingFor(op.preparedBinding).nodes.find(item => item.node === target);const originalValue = originalField && JSON.parse(originalField.value)[12];const expectedValue = params.batchInputClear === true ? params.batchInputText : originalValue + params.batchInputText;diff --git a/src/firefox/src/trace/privacy.js b/src/firefox/src/trace/privacy.jsindex b59a430f3..2ce6f2154 100644--- a/src/firefox/src/trace/privacy.js+++ b/src/firefox/src/trace/privacy.js@@ -80,7 +80,8 @@ const CERTIFICATION_FAILURES = new Set(['owner_unresolved', 'identity_unobservedconst ACTION_PREDICATES = new Set(['target_changed', 'target_unresolved', 'target_ambiguous', 'target_uncovered', 'focus_changed','intervention_changed', 'model_snapshot_invalid', 'model_snapshot_expired', 'pending_feedback','target_hidden', 'target_disabled', 'target_detached', 'parent_changed', 'form_changed',- 'relaxed_grant_expired', 'relaxed_target_changed', 'target_not_actionable']);+ 'relaxed_grant_expired', 'relaxed_target_changed', 'target_not_actionable', 'semantic_binding_changed',+ 'target_hit_changed']);function validationFailureMetadata(value) {if (VALIDATION_FAILURE_CODES.has(value) || PUBLICATION_CONTRACT_CODES.has(value)) return value;diff --git a/test/browser-batch-feedback.mjs b/test/browser-batch-feedback.mjsindex a9702d61d..9b278d430 100644--- a/test/browser-batch-feedback.mjs+++ b/test/browser-batch-feedback.mjs@@ -8,6 +8,10 @@ const html = `<!doctype html><main><h1>Account details</h1><form aria-label="Acc<label>Name <input id="name" value="Existing "></label><label>Email <input id="email"></label><label>Note <textarea id="note"></textarea></label><button type="button">Save details</button></form></main><aside id="counter">0</aside><button id="human">Human control</button>`;+const loginHtml = `<!doctype html><main><h1>Member area</h1><form aria-label="Member login">+<label>Username <input id="user" autocomplete="username"></label>+<label>Password <input id="pass" type="password" autocomplete="current-password"></label>+<button id="login" type="submit">Log in</button></form></main>`;test('batch feedback and monitor implementations are byte-identical across browsers', async () => {for (const file of ['agent/page-feedback.js', 'content/page-monitor.js']) {@@ -19,9 +23,9 @@ test('batch feedback and monitor implementations are byte-identical across browsfor (const [build, engine] of [['chrome', chromium], ['firefox', firefox]]) {test(`${build}: batched fields carry only verified owned values across original target certificates`, { timeout: 120000 }, async t => {const browser = await engine.launch({ headless: true });- async function fixture() {+ async function fixture(body = html) {const context = await browser.newContext();- await context.route('https://batch.test/**', route => route.fulfill({ contentType: 'text/html', body: html }));+ await context.route('https://batch.test/**', route => route.fulfill({ contentType: 'text/html', body }));await context.addInitScript(RUN => {window.listeners = [];window.chrome = window.browser = { runtime: {@@ -48,9 +52,9 @@ for (const [build, engine] of [['chrome', chromium], ['firefox', firefox]]) {await page.evaluate(async () => { window.snapshot = await send('page_monitor_capture_model', { includeTree: true }); });return { context, page };}- const validate = (page, selector = '#email', batchId = 'parent') => page.evaluate(({ selector, batchId }) => send('page_monitor_validate_model', {- tool: 'set_field', selector, snapshotToken: snapshot.snapshotToken, batchId,- }), { selector, batchId });+ const validate = (page, selector = '#email', batchId = 'parent', tool = 'set_field') => page.evaluate(({ selector, batchId, tool }) => send('page_monitor_validate_model', {+ tool, selector, snapshotToken: snapshot.snapshotToken, batchId,+ }), { selector, batchId, tool });const write = (page, { seal = true, selector = '#name', text = 'Ada', mutation = null, tool = 'set_field', clear = true } = {}) => page.evaluate(async ({ seal, selector, text, mutation, tool, clear }) => {const params = { tool, selector, operationId: `op-${selector}`, batchId: 'parent',expectedModelSnapshot: snapshot.snapshotToken, allowPassiveRebase: true };@@ -111,6 +115,28 @@ for (const [build, engine] of [['chrome', chromium], ['firefox', firefox]]) {assert.equal((await validate(page)).ready, false);} finally { await context.close(); }});+ await t.test('a verified password entry continues to the login button like any text field', async () => {+ const { page, context } = await fixture(loginHtml);+ try {+ const user = await write(page, { selector: '#user', text: 'qa-member' });+ assert.equal(user.finish.batchInputSealed, true, JSON.stringify(user));+ const secret = await write(page, { selector: '#pass', text: 'synthetic-fixture-secret' });+ assert.equal(secret.finish.batchInputSealed, true, JSON.stringify(secret));+ assert.equal((await validate(page, '#login', 'parent', 'click')).ready, true);+ assert.equal((await validate(page, '#login', 'another-batch', 'click')).ready, false);+ } finally { await context.close(); }+ });+ await t.test('a password rewritten after the owned write cannot borrow the continuation', async () => {+ const { page, context } = await fixture(loginHtml);+ try {+ const secret = await write(page, { selector: '#pass', text: 'synthetic-fixture-secret',+ mutation: () => { document.querySelector('#pass').value = 'page-rewritten-secret'; } });+ assert.equal(secret.finish.batchInputSealed, false, JSON.stringify(secret));+ const click = await validate(page, '#login', 'parent', 'click');+ assert.equal(click.ready, false);+ assert.equal(click.reason, 'semantic_binding_changed');+ } finally { await context.close(); }+ });await t.test('a human gesture after the owned write keeps the intervention fence', async () => {const { page, context } = await fixture();try {diff --git a/test/failure-recovery.mjs b/test/failure-recovery.mjsindex 36a276499..34fc978a5 100644--- a/test/failure-recovery.mjs+++ b/test/failure-recovery.mjs@@ -126,6 +126,10 @@ for (const browser of ['chrome', 'firefox']) {assert.equal(metadata.extra.certificationFailure, 'owner_unresolved');assert.equal(metadata.extra.monitoringRelaxed, true);assert.doesNotMatch(JSON.stringify(metadata), /private-token|private-body/);+ // Why a binding changed is a fixed name, kept so a refused click says why.+ for (const predicate of ['semantic_binding_changed', 'target_hit_changed']) {+ assert.equal(projectTraceEventData('note', { note: 'page_action_validation', extra: { status: 'blocked', predicate } }).extra.predicate, predicate);+ }const bad = projectTraceEventData('note', { note: 'page_action_validation', extra: {certificationFailure: 'private-body', predicate: 'private-secret', monitoringRelaxed: 'private-mode', captureMs: 'private-time' } });assert.doesNotMatch(JSON.stringify(bad), /private-body|private-secret|private-mode|private-time/);