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
verify_form: name the frame host when a path-only urlFilter matches no iframe
Claude201760a72eff
diff --git a/src/chrome/src/agent/agent.js b/src/chrome/src/agent/agent.jsindex bb2933a5d..22a941be0 100644--- a/src/chrome/src/agent/agent.js+++ b/src/chrome/src/agent/agent.js@@ -48068,6 +48068,8 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d.map(item => item?.result ? { frameId: item.frameId, ...item.result } : null).filter(frame => frame && !frame.isTop && frame.frameId !== 0 && frameHostMatches(frame.url, iframeUrlFilter) && frame.url.includes(iframeUrlFilter));const verifiedFrames = matchingFrames.filter(frame => frame.found);+ const noFrameHint = matchingFrames.length ? '' : urlFilterHostHint(iframeUrlFilter,+ observations.map(item => (item?.result && !item.result.isTop && item.frameId !== 0 ? item.result.url : '')));const fields = verifiedFrames.flatMap(frame => frame.fields.map(field => ({...field,frameId: frame.frameId,@@ -48111,6 +48113,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout dtargetChecks,frames: publicFrames,...(matchingFrames.length === 0 ? { error: 'No iframe matched urlFilter' } : {}),+ ...(noFrameHint ? { hint: noFrameHint } : {}),...(matchingFrames.length > 0 && verifiedFrames.length === 0 ? { error: 'No form found in matching iframe(s)' } : {}),...(verifiedFrames.length === 0 ? unavailableHtmlFormVerification('iframe', matchingFrames.length) : {}),};diff --git a/src/chrome/src/agent/tools.js b/src/chrome/src/agent/tools.jsindex 3c1d0409e..0047c2b8a 100644--- a/src/chrome/src/agent/tools.js+++ b/src/chrome/src/agent/tools.js@@ -1271,7 +1271,7 @@ export const AGENT_TOOLS = [},urlFilter: {type: 'string',- description: 'Optional iframe host or URL substring. When supplied, verifies forms inside matching child frames instead of the top document.',+ description: 'Optional iframe host, optionally followed by more of its URL (e.g. "stripe.com"). When supplied, verifies forms inside matching child frames instead of the top document. A file name without its host, such as "embed.html", matches no frame.',},},required: [],diff --git a/src/firefox/src/agent/agent.js b/src/firefox/src/agent/agent.jsindex c7e5ad7ac..642512153 100644--- a/src/firefox/src/agent/agent.js+++ b/src/firefox/src/agent/agent.js@@ -44239,6 +44239,8 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d&& frame.url.includes(iframeUrlFilter)));const verifiedFrames = matchingFrames.filter(frame => frame?.found);+ const noFrameHint = matchingFrames.length ? '' : urlFilterHostHint(iframeUrlFilter,+ navigationFrames.filter(frame => Number(frame?.frameId) !== 0).map(frame => frame?.url));const fields = verifiedFrames.flatMap(frame => frame.fields.map(field => ({...field,frameId: frame.frameId,@@ -44282,6 +44284,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout dtargetChecks,frames: publicFrames,...(matchingFrames.length === 0 ? { error: 'No iframe matched urlFilter' } : {}),+ ...(noFrameHint ? { hint: noFrameHint } : {}),...(matchingFrames.length > 0 && verifiedFrames.length === 0 ? { error: 'No form found in matching iframe(s)' } : {}),...(verifiedFrames.length === 0 ? unavailableHtmlFormVerification('iframe', matchingFrames.length) : {}),};diff --git a/src/firefox/src/agent/tools.js b/src/firefox/src/agent/tools.jsindex 03f5bc53f..55d71d22c 100644--- a/src/firefox/src/agent/tools.js+++ b/src/firefox/src/agent/tools.js@@ -1126,7 +1126,7 @@ export const AGENT_TOOLS = [},urlFilter: {type: 'string',- description: 'Optional iframe host or URL substring. When supplied, verifies forms inside matching child frames instead of the top document.',+ description: 'Optional iframe host, optionally followed by more of its URL (e.g. "stripe.com"). When supplied, verifies forms inside matching child frames instead of the top document. A file name without its host, such as "embed.html", matches no frame.',},},required: [],diff --git a/test/run.js b/test/run.jsindex 1cf2ed4a0..8fc37939d 100644--- a/test/run.js+++ b/test/run.js@@ -112318,6 +112318,43 @@ test('verify_form returns semantic iframe-scoped field evidence', async () => {}});+test('verify_form names the frame host when a path-only urlFilter matches no iframe', async () => {+ const previousChrome = globalThis.chrome;+ const previousBrowser = globalThis.browser;+ const frameUrl = 'https://forms.example/embed/iframe-inner.html';+ const frame = { found: true, url: frameUrl, fieldCount: 1, fields: [{ matchIndex: 0, label: 'Name', value: 'x' }] };+ const expected = 'urlFilter "iframe-inner.html" does not name an iframe host, so no frame matched. '+ + 'Start it with the frame\'s host, for example "forms.example/embed/iframe-inner.html".';+ try {+ globalThis.chrome = {+ tabs: { get: async () => ({ id: 42, url: 'https://host.example/form-page' }) },+ scripting: { executeScript: async () => [{ frameId: 0, result: { found: false, url: 'https://host.example/form-page', isTop: true } },+ { frameId: 7, result: { ...frame, isTop: false } }] },+ };+ const chromeResult = await new AgentCh({}).executeTool(42, 'verify_form', { urlFilter: 'iframe-inner.html' });+ assert.equal(chromeResult.success, false);+ assert.equal(chromeResult.error, 'No iframe matched urlFilter');+ assert.equal(chromeResult.hint, expected);+ globalThis.browser = {+ webNavigation: { getAllFrames: async () => [{ frameId: 0, url: 'https://host.example/form-page' }, { frameId: 7, url: frameUrl }] },+ tabs: { get: async () => ({ id: 42, url: 'https://host.example/form-page' }), executeScript: async () => [frame] },+ };+ const firefoxResult = await new AgentFx({}).executeTool(42, 'verify_form', { urlFilter: 'iframe-inner.html' });+ assert.equal(firefoxResult.error, 'No iframe matched urlFilter');+ assert.equal(firefoxResult.hint, expected);+ for (const build of ['chrome', 'firefox']) {+ const tools = await import(pathToFileURL(path.join(ROOT, `src/${build}/src/agent/tools.js`)).href);+ const schema = tools.AGENT_TOOLS.find(tool => tool.function.name === 'verify_form').function.parameters.properties.urlFilter;+ assert.match(schema.description, /A file name without its host, such as "embed\.html", matches no frame/, `${build}: verify_form schema`);+ }+ } finally {+ if (previousChrome === undefined) delete globalThis.chrome;+ else globalThis.chrome = previousChrome;+ if (previousBrowser === undefined) delete globalThis.browser;+ else globalThis.browser = previousBrowser;+ }+});+test('verify_form checks pending iframe values without exposing raw comparison evidence', async () => {const previousChrome = globalThis.chrome;const previousBrowser = globalThis.browser;