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
fix: reject invisible safe-first options
Emre Sokulluc9df7a004ee7
diff --git a/src/chrome/src/agent/agent.js b/src/chrome/src/agent/agent.jsindex 2934cbdbf..6728a1757 100644--- a/src/chrome/src/agent/agent.js+++ b/src/chrome/src/agent/agent.js@@ -33853,8 +33853,8 @@ If the user has already named or confirmed this exact recipient, do NOT ask agai}const rawOptions = Array.isArray(args?.options) ? args.options : [];const options = rawOptions- .map(s => String(s).trim().slice(0, 200)).filter(Boolean).slice(0, 4);- const safeFirst = args?.safe_first === true && String(rawOptions[0] || '').trim().length > 0;+ .map(s => String(s).trim().slice(0, 200)).filter(option => /[\p{L}\p{N}\p{P}\p{S}]/u.test(option)).slice(0, 4);+ const safeFirst = args?.safe_first === true && /[\p{L}\p{N}\p{P}\p{S}]/u.test(String(rawOptions[0] || ''));const reason = args?.reason ? String(args.reason).slice(0, 300) : null;const purpose = args?.purpose === 'research_escalation'? 'research_escalation'diff --git a/src/firefox/src/agent/agent.js b/src/firefox/src/agent/agent.jsindex f4cf4b012..04324e6d3 100644--- a/src/firefox/src/agent/agent.js+++ b/src/firefox/src/agent/agent.js@@ -30562,8 +30562,8 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d}const rawOptions = Array.isArray(args?.options) ? args.options : [];const options = rawOptions- .map(s => String(s).trim().slice(0, 200)).filter(Boolean).slice(0, 4);- const safeFirst = args?.safe_first === true && String(rawOptions[0] || '').trim().length > 0;+ .map(s => String(s).trim().slice(0, 200)).filter(option => /[\p{L}\p{N}\p{P}\p{S}]/u.test(option)).slice(0, 4);+ const safeFirst = args?.safe_first === true && /[\p{L}\p{N}\p{P}\p{S}]/u.test(String(rawOptions[0] || ''));const reason = args?.reason ? String(args.reason).slice(0, 300) : null;const purpose = args?.purpose === 'research_escalation'? 'research_escalation'diff --git a/test/run.js b/test/run.jsindex cde4c81d2..1c44bd734 100644--- a/test/run.js+++ b/test/run.js@@ -48809,6 +48809,17 @@ test('clarify result distinguishes waited timeout from user and Instant authorizassert.equal(blankOptionTimeout.authorized, false, `${AgentClass.name}: whitespace-only safe_first option was accepted`);assert.equal(agent._clarificationAuthorizationGuards.get(tabId)?.authorized, false, `${AgentClass.name}: whitespace-only option did not arm a timeout guard`);+ await agent._recordClarificationAuthorization(tabId, 'user');+ const invisibleOptionTimeout = await agent.executeTool(+ tabId,+ 'clarify',+ { question: 'Continue?', options: ['\u200B'], safe_first: true },+ (type, data) => {+ if (type === 'clarify') agent.submitClarifyResponse(tabId, data.clarifyId, '\u200B', 'timeout');+ },+ );+ assert.equal(invisibleOptionTimeout.authorized, false, `${AgentClass.name}: invisible safe_first option was accepted`);+await agent._recordClarificationAuthorization(tabId, 'user');const promotedOptionTimeout = await agent.executeTool(tabId,