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
Merge origin/main into feat/memcode-external-recall
Emre Sokullu5de26908cdf8
diff --cc docs/memcode-recall.mdindex 8c9065d33,000000000..684d89211mode 100644,000000..100644--- a/docs/memcode-recall.md+++ b/docs/memcode-recall.md@@@ -1,46 -1,0 +1,46 @@@+# Optional MemCode recall++WebBrain's built-in user memory is local and remains the default. MemCode is an+optional cross-device **read-only** lookup, not a replacement for local memory.+- 1. Open **Settings β Profile β MemCode cross-device recall** and select **Connect++1. Open **Settings β Memory β MemCode cross-device recall** and select **Connect+ MemCode**. WebBrain registers a public OAuth client and opens MemCode's sign-in+ and consent page using the browser's extension-owned redirect and PKCE.+2. After connecting, switch on **Enable MemCode recall**. Connection alone does+ not allow searches. The agent can then call `recall_memcode` with a short query.+3. Switch recall off or **Disconnect** at any time. Disconnect discards local+ credentials, attempts server-side OAuth revocation, and stops future lookups;+ it does not delete memories in MemCode. If revocation cannot be confirmed,+ Settings warns you to revoke the client in your MemCode account.++The query goes directly to the read-only personal search route at+`https://memory.memcode.in/v2/memory/search`, using an OAuth token bound to the+`https://memory.memcode.in` resource. WebBrain supplies its public+`software_id` during dynamic client registration so MemCode can assign+server-side integration attribution when `webbrain` is registered. This is not+proof of client identity by itself; verified attribution requires a separately+registered exact extension redirect. No caller-supplied integration header,+user ID, or API key is used.++Results are bounded and wrapped as untrusted tool output before the model sees+them. Recalled text is data, not a user command or permission to act on a+webpage. WebBrain's existing network permission gate also asks for+permission to contact the fixed MemCode host. Token expiry and network failures+leave local memory usable.++WebBrain requests only the `memory:read` OAuth scope. It never calls a write tool, never+uploads auto-learned preferences, form fields, pages, or transcripts, and never+injects remote recall into the trusted local-memory system prompt. A future+remote-write feature would require a separate exact-text approval UI and tests.++OAuth access and refresh tokens are stored in extension-local storage, like+WebBrain's other provider credentials. They are not included in portable settings+exports or sent to the configured LLM. Search queries and returned memories do+reach MemCode and, when used as tool context, the configured LLM provider.++MemCode's hosted MCP server currently requires both `memory:read` and+`memory:write` for every connection. This first slice uses the direct API+instead so its token truly lacks write permission. For deployment, the+`webbrain` software ID should be registered in MemCode's integration registry.+This PR contains mock-backed protocol tests; a signed-in Chrome and Firefox+smoke test and private dashboard attribution check are release validation steps.diff --cc package.jsonindex 6d4831cdd,d7ac613dc..492c468d6--- a/package.json+++ b/package.json@@@ -5,8 -5,12 +5,12 @@@"private": true,"type": "module","scripts": {- "test": "npm run test:markdown && npm run test:systemone && npm run test:systemone:fast && node --test test/browser-dialogs.mjs && npm run test:firefox-bidi && npm run test:runtime-lifecycle && npm run test:provider-limits && npm run test:accessibility-tree-benchmark && npm run test:toolbar-guard && 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 && node --test test/memcode-recall.mjs && node test/run.js && node test/selection-scope-restoration.mjs && node scripts/benchmark-offline-relevance.mjs && npm run test:security",-"test": "npm run test:cms && npm run test:markdown && npm run test:systemone && npm run test:systemone:fast && node --test 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-aws-recovery.mjs test/captcha-documented-contracts.mjs test/huggingface-signup-recovery.mjs test/trace-full-export.mjs && npm run test:firefox-bidi && npm run test:runtime-lifecycle && npm run test:billing-notice && npm run test:provider-limits && npm run test:openrouter-capabilities && 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/run.js && node test/selection-scope-restoration.mjs && node scripts/benchmark-offline-relevance.mjs && npm run test:security",++"test": "npm run test:cms && npm run test:markdown && npm run test:systemone && npm run test:systemone:fast && node --test 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-aws-recovery.mjs test/captcha-documented-contracts.mjs test/huggingface-signup-recovery.mjs test/trace-full-export.mjs && npm run test:firefox-bidi && npm run test:runtime-lifecycle && npm run test:billing-notice && npm run test:provider-limits && npm run test:openrouter-capabilities && 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 && node test/run.js && node test/selection-scope-restoration.mjs && node scripts/benchmark-offline-relevance.mjs && npm run test:security",+ "test:captcha:ui": "node test/captcha-settings-ui.mjs && node test/captcha-application-ui.mjs",+ "test:captcha:bridge:ui": "node test/captcha-callback-bridge-ui.mjs",+ "test:billing-notice": "node test/billing-payment-notice.mjs","test:provider-limits": "node test/provider-model-limits.mjs",+ "test:openrouter-capabilities": "node --test test/openrouter-model-capabilities.mjs test/muse-tool-choice.mjs","test:markdown": "node --test test/markdown-render.mjs","test:accessibility-tree-benchmark": "node --test test/llm/lib/accessibility-tree-formats.test.mjs && node test/llm/accessibility-tree-benchmark.mjs --no-exact-tokenizer --check","test:attachment-drop": "node test/attachment-drop.mjs",diff --cc src/chrome/manifest.jsonindex 8504b1f52,e0aa59f8c..c983b7f1f--- a/src/chrome/manifest.json+++ b/src/chrome/manifest.json@@@ -11,7 -11,7 +11,8 @@@"tabGroups","scripting","storage",+ "identity",+ "cookies","notifications","webNavigation","webRequest",diff --cc src/chrome/src/agent/permission-gate.jsindex fba7e9303,912ff039d..8c390d1da--- a/src/chrome/src/agent/permission-gate.js+++ b/src/chrome/src/agent/permission-gate.js@@@ -56,7 -58,11 +58,12 @@@ export const CAPABILITY_LABEL =* tool is classified as gated, untrusted-read, or explicitly known-safe.*/export const UNTRUSTED_CONTENT_TOOLS = new Set([+ 'recall_memcode',+ // Discovery can recover a paid answer; solver output and callback failures+ // also contain external data, even when the tool otherwise reads a catalog.+ 'get_captcha_capabilities',+ 'solve_captcha',+ 'apply_captcha_solution','chat_observe','chat_send','read_page',@@@ -560,7 -573,9 +575,10 @@@ function resolveHostAgainst(url, base)*/export function hostForCapability(capability, args, currentUrlOrHost, toolName) {args = args || {};+ if (toolName === 'recall_memcode') return 'memory.memcode.in';+ if (toolName === 'apply_captcha_solution') {+ return normalizeHost(args.frameUrl);+ }if (toolName === 'read_email_verification_message' && capability === Capability.CLICK) {// agent.js supplies this from its opaque inspected-mailbox session only to// the permission check; it never comes from model arguments.diff --cc src/chrome/src/ui/i18n.jsindex bd0bd9b2e,27e6085a6..7f1fe2b76--- a/src/chrome/src/ui/i18n.js+++ b/src/chrome/src/ui/i18n.js@@@ -3,7 -3,7 +3,8 @@@// Works identically in Chrome MV3 and Firefox MV2.import en from './locales/en.js';+import { memcodeEnglish } from './locales/memcode-copy.mjs';+ import { captchaEnglish, captchaTranslations } from './locales/captcha-copy.mjs';import { safeSocialEnglish, safeSocialTranslations } from './locales/safesocial-copy.mjs';import es from './locales/es.js';import fr from './locales/fr.js';diff --cc src/chrome/src/ui/settings.jsindex e09e26f83,bbf9f214a..7e46daa15--- a/src/chrome/src/ui/settings.js+++ b/src/chrome/src/ui/settings.js@@@ -212,15 -209,6 +209,10 @@@ const btnClearUserMemory = document.getconst userMemoryImportText = document.getElementById('user-memory-import-text');const btnImportUserMemory = document.getElementById('btn-import-user-memory');const userMemoryTestResult = document.getElementById('test-user-memory');+const memcodeRecallToggle = document.getElementById('toggle-memcode-recall');+const memcodeConnectButton = document.getElementById('btn-memcode-connect');+const memcodeDisconnectButton = document.getElementById('btn-memcode-disconnect');+const memcodeRecallResult = document.getElementById('test-memcode-recall');- const captchaApiKeyInput = document.getElementById('captcha-api-key');- const btnSaveCaptcha = document.getElementById('btn-save-captcha');- const btnTestCaptcha = document.getElementById('btn-test-captcha');- const btnClearCaptcha = document.getElementById('btn-clear-captcha');- const captchaTestResult = document.getElementById('test-captcha');const systemOneApiKeyInput = document.getElementById('system-one-api-key');const systemOneEnabledToggle = document.getElementById('toggle-system-one');const systemOneWatchToggle = document.getElementById('toggle-system-one-watch');@@@ -937,11 -926,9 +930,10 @@@ async function init()if (profileEnabledToggle) profileEnabledToggle.checked = !!profileStored.profileEnabled;if (profileTextArea) profileTextArea.value = profileStored.profileText || '';await loadUserMemorySettings();+ await loadMemcodeStatus();- // A valid saved key is the CapSolver enable control.- const captchaStored = await chrome.storage.local.get('capsolverApiKey');- if (captchaApiKeyInput) captchaApiKeyInput.value = captchaStored.capsolverApiKey || '';+ // Each provider has independent key, enable state, and fallback weight.+ await initCaptchaSettings(chrome.storage.local, sendToBackground, t);await loadCustomSkills();diff --cc src/firefox/manifest.jsonindex 73ebed283,2a778184f..3eec76ddd--- a/src/firefox/manifest.json+++ b/src/firefox/manifest.json@@@ -10,7 -10,7 +10,8 @@@"webNavigation","webRequest","storage",+ "identity",+ "cookies","unlimitedStorage","tabs","tabGroups",diff --cc src/firefox/src/agent/permission-gate.jsindex f97941267,6d993a061..6f69ccb55--- a/src/firefox/src/agent/permission-gate.js+++ b/src/firefox/src/agent/permission-gate.js@@@ -54,7 -56,11 +56,12 @@@ export const CAPABILITY_LABEL =* tool is classified as gated, untrusted-read, or explicitly known-safe.*/export const UNTRUSTED_CONTENT_TOOLS = new Set([+ 'recall_memcode',+ // Discovery can recover a paid answer; solver output and callback failures+ // also contain external data, even when the tool otherwise reads a catalog.+ 'get_captcha_capabilities',+ 'solve_captcha',+ 'apply_captcha_solution','chat_observe','chat_send','read_page',@@@ -545,7 -558,9 +560,10 @@@ function resolveHostAgainst(url, base)*/export function hostForCapability(capability, args, currentUrlOrHost, toolName) {args = args || {};+ if (toolName === 'recall_memcode') return 'memory.memcode.in';+ if (toolName === 'apply_captcha_solution') {+ return normalizeHost(args.frameUrl);+ }if (toolName === 'read_email_verification_message' && capability === Capability.CLICK) {// agent.js supplies this from its opaque inspected-mailbox session only to// the permission check; it never comes from model arguments.diff --cc src/firefox/src/ui/i18n.jsindex 8a0bcf803,e9b9864be..950a90c57--- a/src/firefox/src/ui/i18n.js+++ b/src/firefox/src/ui/i18n.js@@@ -3,7 -3,7 +3,8 @@@// Works identically in Chrome MV3 and Firefox MV2.import en from './locales/en.js';+import { memcodeEnglish } from './locales/memcode-copy.mjs';+ import { captchaEnglish, captchaTranslations } from './locales/captcha-copy.mjs';import { safeSocialEnglish, safeSocialTranslations } from './locales/safesocial-copy.mjs';import es from './locales/es.js';import fr from './locales/fr.js';@@@ -32,9 -32,10 +33,11 @@@ import { providerGuideEnglish, providerconst DICTS = Object.fromEntries(Object.entries({ en, es, fr, tr, zh, ru, uk, ar, ja, ko, id, th, ms, tl, pl, he, hi, pt, vi, bn, fa, nl, de }).map(([code, dict]) => [code, {...dict,+ ...memcodeEnglish,...providerGuideEnglish,...safeSocialEnglish,+ ...captchaEnglish,+ ...(captchaTranslations[code] || {}),...(safeSocialTranslations[code] || {}),...(providerGuideTranslations[code] || {}),}]));diff --cc src/firefox/src/ui/settings.jsindex 0c9054b95,539530ebc..bca38a7d0--- a/src/firefox/src/ui/settings.js+++ b/src/firefox/src/ui/settings.js@@@ -196,15 -193,6 +193,10 @@@ const btnClearUserMemory = document.getconst userMemoryImportText = document.getElementById('user-memory-import-text');const btnImportUserMemory = document.getElementById('btn-import-user-memory');const userMemoryTestResult = document.getElementById('test-user-memory');+const memcodeRecallToggle = document.getElementById('toggle-memcode-recall');+const memcodeConnectButton = document.getElementById('btn-memcode-connect');+const memcodeDisconnectButton = document.getElementById('btn-memcode-disconnect');+const memcodeRecallResult = document.getElementById('test-memcode-recall');- const captchaApiKeyInput = document.getElementById('captcha-api-key');- const btnSaveCaptcha = document.getElementById('btn-save-captcha');- const btnTestCaptcha = document.getElementById('btn-test-captcha');- const btnClearCaptcha = document.getElementById('btn-clear-captcha');- const captchaTestResult = document.getElementById('test-captcha');const systemOneApiKeyInput = document.getElementById('system-one-api-key');const systemOneEnabledToggle = document.getElementById('toggle-system-one');const systemOneWatchToggle = document.getElementById('toggle-system-one-watch');@@@ -699,11 -688,9 +692,10 @@@ async function init()if (profileEnabledToggle) profileEnabledToggle.checked = !!profileStored.profileEnabled;if (profileTextArea) profileTextArea.value = profileStored.profileText || '';await loadUserMemorySettings();+ await loadMemcodeStatus();- // A valid saved key is the CapSolver enable control.- const captchaStored = await browser.storage.local.get('capsolverApiKey');- if (captchaApiKeyInput) captchaApiKeyInput.value = captchaStored.capsolverApiKey || '';+ // Each provider has independent key, enable state, and fallback weight.+ await initCaptchaSettings(browser.storage.local, sendToBackground, t);await loadCustomSkills();diff --cc test/run.jsindex 0f1ff7979,055c5e14d..fc93d6a98--- a/test/run.js+++ b/test/run.js@@@ -28661,10 -29106,8 +29106,10 @@@ test('getToolsForMode: mode/tier redesi}const researchOptions = { researchEscalationEnabled: true };assert.equal(getTools('act', { tier: 'compact', ...researchOptions }).length, 25, `[${label}] Compact should expose 25 tools after tab-tool removal`);- assert.equal(getTools('act', { tier: 'mid', ...researchOptions }).length, 46, `[${label}] Mid should expose 46 tools after chat workflow addition`);- assert.equal(getTools('act', researchOptions).length, label === 'chrome' ? 53 : 52, `[${label}] Full tool count should include opt-in MemCode recall`);+ assert.equal(getTools('act', { tier: 'mid', ...researchOptions }).length, 48, `[${label}] Mid should expose 48 tools including CAPTCHA discovery and answer application`);- assert.equal(getTools('act', researchOptions).length, label === 'chrome' ? 54 : 53, `[${label}] Full tool count should include the chat workflow tools`);++ assert.equal(getTools('act', researchOptions).length, label === 'chrome' ? 55 : 54, `[${label}] Full tool count should include opt-in MemCode recall and chat workflow tools`);+ assert.equal(ask.includes('recall_memcode'), true, `[${label}] Ask can read connected MemCode memories`);+ assert.equal(compact.includes('recall_memcode'), false, `[${label}] Compact does not expose remote recall`);assert.equal(compact.includes('research_url'), false, `[${label}] Compact must not gain research_url as a tab-tool replacement`);assert.equal(ask.includes('download_resource_from_page'), false, `[${label}] ask must not expose download_resource_from_page`);