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
feat: enable new defaults for API mutations, observer, memory, PDF viewer
Emre Sokulluc89b90ca2bd3
diff --git a/docs/architecture.md b/docs/architecture.mdindex 890e0beaa..a19648442 100644--- a/docs/architecture.md+++ b/docs/architecture.md@@ -654,7 +654,7 @@ same local store from the side panel. Settings -> Profile provides enable,auto-learn, edit, delete, clear, export, and import controls for Chrome andFirefox.-Optional auto-learning is off by default. After successful `chat`,+Auto-learning is enabled by default. After successful `chat`,`chat_stream`, or `continue` completion, the background script queues a smallextractor job with only the latest user text, final assistant text, currentmemory list, mode, and success state. The response path does not await this@@ -866,9 +866,9 @@ Three independent detectors run after every tool call:2. **Coordinate click** β 5px-bucketed. Nudge at 5 same-bucket clicks. Stop at 8.3. **Navigation** β snapshot URL before click/navigate/iframe_click, compare after.-When the opt-in API mutation observer is enabled and a repeated `click` /+When the API mutation observer is enabled and a repeated `click` /`click_ax` loop is detected, `_detectApiShortcut()` checks the per-tab-webRequest buffer populated by `background.js`. The observer is off by default.+webRequest buffer populated by `background.js`. The observer is on by default.If each repeated click produced the same exact URL + HTTP method within a3-second window, the loop warning includes a `fetch_url({url, method})`suggestion. For replayable XHR/fetch mutations, the observer also keeps boundeddiff --git a/docs/privacy-and-data-flow.md b/docs/privacy-and-data-flow.mdindex 6d4c39bba..e624c9e59 100644--- a/docs/privacy-and-data-flow.md+++ b/docs/privacy-and-data-flow.md@@ -374,8 +374,8 @@ The only outbound HTTP requests are:7. **Encrypted Cloud Sync calls** to `https://api.webbrain.one/v1/sync` (only after a subscriber explicitly enables sync; vault content is encrypted before upload)8. **Slash-driven tab/screen recording** creates no outbound traffic (the .webm is saved to the Downloads folder via `chrome.downloads.download`)-The opt-in `webRequest` API shortcut observer is off by default and does not-create outbound requests; when enabled, it observes replay metadata for requests+The `webRequest` API shortcut observer is on by default and does not+create outbound requests; it observes replay metadata for requeststhe page already made so repeated UI mutations can be diagnosed.### Bundled Skillsdiff --git a/docs/security-model.md b/docs/security-model.mdindex a15d90cab..0a3eecf11 100644--- a/docs/security-model.md+++ b/docs/security-model.md@@ -34,7 +34,7 @@ see Firefox Differences below.)|---|---|---|| `<all_urls>` | Content script injection anywhere β the agent can read and interact with any page the user visits | The user must explicitly switch to an action mode (Act or Dev) before clicks/types/navigation. Ask mode is read-only. General browser-tab creation, enumeration, activation, and run retargeting are not exposed as model-callable tools. The one OTP-skill-gated Mid/Full reader internally selects an already-open supported mailbox and returns only bounded service-matching content; it exposes no tab catalog. Candidate inspection is read-only, while opening a selected message requires Act/Dev and mailbox-host click permission because it may mark mail read. Its disposable inactive clone consumes exact message continuations to completion or fails closed. || `debugger` | CDP access provides trusted events and full DOM/network control on any tab | The debugger is attached only to the target tab while a CDP-backed run or mode-scoped Dev diagnostics own it. Run cleanup closes run-scoped WebMCP state and detaches unless Dev diagnostics remain active; conversation cleanup and tab removal drain all owners and detach. |-| `webRequest` | Can observe XHR/fetch metadata for requests made by the active page | API mutation observer is off by default; when enabled, it keeps only a bounded in-memory per-tab buffer for repeated-click shortcut hints and opaque same-origin replay. |+| `webRequest` | Can observe XHR/fetch metadata for requests made by the active page | API mutation observer is on by default; it keeps only a bounded in-memory per-tab buffer for repeated-click shortcut hints and opaque same-origin replay. || `downloads` | Can save files to the user's Downloads folder without prompting | Only the agent's explicit download-capable tool calls (`download_files`, `download_file`, `download_resource_from_page`, `download_social_media`, download-job skill tools) use this, and each is gated by the capability Γ origin permission prompt. || `alarms` | Can wake scheduled jobs in future browser sessions | `schedule_resume` / `schedule_task` are gated; the user-authored `/watch` slash command can also create a page-bound 30β120 second conditional poll. || `offscreen` | An offscreen document can make HTTP requests immune to user CSP, run local inference, or play audio without an open panel | Used for the localhost LLM proxy, the optional endpoint-free WebGPU text and vision providers, tab recording, validated download staging, the local controller bridge, and successful `/watch /beep` tones. The text provider receives the same bounded conversation and allowlisted tool schemas that would be sent to another active provider; dedicated local vision receives only its screenshot/prompt. Model files are downloaded from Hugging Face, while inference stays in the worker. Watch audio receives only a style selector, never page content or an arbitrary URL. |@@ -161,7 +161,7 @@ The primary threat: a malicious page crafts content that, when read by the agentSet per-conversation via the `/allow-api` slash command in the side panel, orpersistently with **Always allow API mutations** under **Settings β General β-Advanced**. The persistent setting is off by default. When either option is+Advanced**. The persistent setting is on by default. When either option isactive, it waives the permission prompt for **write-method network egress only**:- `fetch_url` / `research_url` with `method: POST/PUT/PATCH/DELETE`diff --git a/docs/slash-commands.md b/docs/slash-commands.mdindex 7209ad702..028a9799a 100644--- a/docs/slash-commands.md+++ b/docs/slash-commands.md@@ -90,7 +90,7 @@ is failing. A badge appears while it is active, and it clears on `/reset`.To keep the same policy active across conversations and browser restarts, turnon **Always allow API mutations** under **Settings β General β Advanced**. The-setting is off by default and remains active until you turn it off. `/reset`+setting is on by default and remains active until you turn it off. `/reset`still clears the conversation-only `/allow-api` override, but does not changethe persistent setting.diff --git a/src/chrome/src/background.js b/src/chrome/src/background.jsindex 0123a798c..2a22a6491 100644--- a/src/chrome/src/background.js+++ b/src/chrome/src/background.js@@ -194,12 +194,12 @@ const agent = new Agent(providerManager);agent.setStandaloneOfflineRagService(createOffscreenOfflineRetrievalService());const ALWAYS_ALLOW_API_MUTATIONS_KEY = 'alwaysAllowApiMutations';const alwaysAllowApiMutationsReady = chrome.storage.local- .get({ [ALWAYS_ALLOW_API_MUTATIONS_KEY]: false })+ .get({ [ALWAYS_ALLOW_API_MUTATIONS_KEY]: true }).then((stored) => {- agent.setAlwaysAllowApiMutations(stored[ALWAYS_ALLOW_API_MUTATIONS_KEY] === true);+ agent.setAlwaysAllowApiMutations(stored[ALWAYS_ALLOW_API_MUTATIONS_KEY] !== false);}).catch(() => {- agent.setAlwaysAllowApiMutations(false);+ agent.setAlwaysAllowApiMutations(true);});agent.setConversationScopeChangeListener((tabId, state) => {chrome.runtime.sendMessage({@@ -335,8 +335,8 @@ async function setNativePdfMimeHandlerEnabled(enabled) {}async function syncNativePdfMimeHandlerFromStorage() {- const stored = await chrome.storage.local.get({ [PDF_VIEWER_ENABLED_KEY]: false });- return setNativePdfMimeHandlerEnabled(stored?.[PDF_VIEWER_ENABLED_KEY] === true);+ const stored = await chrome.storage.local.get({ [PDF_VIEWER_ENABLED_KEY]: true });+ return setNativePdfMimeHandlerEnabled(stored?.[PDF_VIEWER_ENABLED_KEY] !== false);}function reportPdfMimeHandlerSyncFailure(error) {@@ -714,12 +714,12 @@ async function isUserMemoryExtractionEnabled() {USER_MEMORY_AUTO_CAPTURE_KEY,]);return stored[USER_MEMORY_ENABLED_KEY] !== false- && stored[USER_MEMORY_AUTO_CAPTURE_KEY] === true;+ && stored[USER_MEMORY_AUTO_CAPTURE_KEY] !== false;}async function isUserMemoryFormCaptureEnabled() {const stored = await chrome.storage.local.get(USER_MEMORY_FORM_CAPTURE_KEY);- return stored[USER_MEMORY_FORM_CAPTURE_KEY] === true;+ return stored[USER_MEMORY_FORM_CAPTURE_KEY] !== false;}async function withUserMemoryExtractionQueueLock(task) {@@ -1178,7 +1178,7 @@ chrome.runtime.onStartup?.addListener(async () => {// Listen for setting changeschrome.storage.onChanged.addListener((changes, areaName) => {if (areaName === 'local' && changes[PDF_VIEWER_ENABLED_KEY]) {- setNativePdfMimeHandlerEnabled(changes[PDF_VIEWER_ENABLED_KEY].newValue === true)+ setNativePdfMimeHandlerEnabled(changes[PDF_VIEWER_ENABLED_KEY].newValue !== false).catch(reportPdfMimeHandlerSyncFailure);}if (changes.wbLocale) {@@ -1204,7 +1204,7 @@ chrome.storage.onChanged.addListener((changes, areaName) => {// wiping the chat history.let refreshPrompts = false;if (changes[ALWAYS_ALLOW_API_MUTATIONS_KEY]) {- agent.setAlwaysAllowApiMutations(changes[ALWAYS_ALLOW_API_MUTATIONS_KEY].newValue === true);+ agent.setAlwaysAllowApiMutations(changes[ALWAYS_ALLOW_API_MUTATIONS_KEY].newValue !== false);refreshPrompts = true;}if (changes.useSiteAdapters) {@@ -1231,7 +1231,7 @@ chrome.storage.onChanged.addListener((changes, areaName) => {});}if (changes[API_MUTATION_OBSERVER_KEY]) {- setApiMutationObserverEnabled(changes[API_MUTATION_OBSERVER_KEY].newValue === true);+ setApiMutationObserverEnabled(changes[API_MUTATION_OBSERVER_KEY].newValue !== false);}if (changes.strictSecretMode) {agent.strictSecretMode = !!changes.strictSecretMode.newValue;@@ -2437,7 +2437,7 @@ chrome.tabs.onRemoved.addListener((tabId) => pdfResponseTabs.delete(tabId));// tokens and form bodies do not get printed into model context.const API_REQUESTS_PER_TAB_LIMIT = 40;const API_MUTATION_OBSERVER_KEY = 'apiMutationObserverEnabled';-const API_MUTATION_OBSERVER_DEFAULT = false;+const API_MUTATION_OBSERVER_DEFAULT = true;const API_REPLAY_BODY_LIMIT = 16000;const apiRequestsByTab = new Map(); // tabId -> [{ url, method, ts, replayRequestId, ... }]const apiRequestReplayById = new Map(); // replayRequestId -> captured same-origin replay options@@ -2581,7 +2581,7 @@ function setApiMutationObserverEnabled(enabled) {async function loadApiMutationObserverSetting() {try {const stored = await chrome.storage.local.get({ [API_MUTATION_OBSERVER_KEY]: API_MUTATION_OBSERVER_DEFAULT });- setApiMutationObserverEnabled(stored[API_MUTATION_OBSERVER_KEY] === true);+ setApiMutationObserverEnabled(stored[API_MUTATION_OBSERVER_KEY] !== false);} catch (e) {setApiMutationObserverEnabled(API_MUTATION_OBSERVER_DEFAULT);}@@ -2965,8 +2965,8 @@ async function handleMessage(msg, sender) {store,records: store.records,enabled: settings[USER_MEMORY_ENABLED_KEY] !== false,- autoCaptureEnabled: settings[USER_MEMORY_AUTO_CAPTURE_KEY] === true,- formCaptureEnabled: settings[USER_MEMORY_FORM_CAPTURE_KEY] === true,+ autoCaptureEnabled: settings[USER_MEMORY_AUTO_CAPTURE_KEY] !== false,+ formCaptureEnabled: settings[USER_MEMORY_FORM_CAPTURE_KEY] !== false,maxPromptChars: normalizeUserMemoryMaxPromptChars(settings[USER_MEMORY_MAX_PROMPT_CHARS_KEY]),};}diff --git a/src/chrome/src/config-transfer.js b/src/chrome/src/config-transfer.jsindex 6981be782..6c469ba01 100644--- a/src/chrome/src/config-transfer.js+++ b/src/chrome/src/config-transfer.js@@ -37,8 +37,9 @@ export const DEFAULT_CONFIG_SETTINGS = Object.freeze({researchEscalationEnabled: false,researchEscalationEngine: 'chatgpt',voiceInputEnabled: true,- alwaysAllowApiMutations: false,- apiMutationObserverEnabled: false,+ alwaysAllowApiMutations: true,+ apiMutationObserverEnabled: true,+ pdfViewerEnabled: true,webMcpEnabled: false,openaiAskStreamingEnabled: true,planBeforeActMode: 'try',@@ -68,8 +69,8 @@ export const DEFAULT_CONFIG_SETTINGS = Object.freeze({profileText: '',[USER_MEMORY_STORAGE_KEY]: { version: 1, records: [] },[USER_MEMORY_ENABLED_KEY]: true,- [USER_MEMORY_AUTO_CAPTURE_KEY]: false,- [USER_MEMORY_FORM_CAPTURE_KEY]: false,+ [USER_MEMORY_AUTO_CAPTURE_KEY]: true,+ [USER_MEMORY_FORM_CAPTURE_KEY]: true,[USER_MEMORY_MAX_PROMPT_CHARS_KEY]: USER_MEMORY_DEFAULT_MAX_PROMPT_CHARS,[CUSTOM_SKILLS_STORAGE_KEY]: [],[DEFAULT_SKILLS_REMOVED_STORAGE_KEY]: [],@@ -93,6 +94,7 @@ const BOOLEAN_KEYS = new Set(['voiceInputEnabled','alwaysAllowApiMutations','apiMutationObserverEnabled',+ 'pdfViewerEnabled','webMcpEnabled','openaiAskStreamingEnabled','planBeforeAct',diff --git a/src/chrome/src/ui/locales/en.js b/src/chrome/src/ui/locales/en.jsindex 605b7c046..29d6b6872 100644--- a/src/chrome/src/ui/locales/en.js+++ b/src/chrome/src/ui/locales/en.js@@ -601,9 +601,9 @@ export default {'st.display.voice_input.label': 'Voice input','st.display.voice_input.desc': 'Let the mic button in the chat input dictate text via your browser\'s speech recognition. On by default in browsers that support it.','st.display.always_allow_api_mutations.label': "Always allow API mutations",- 'st.display.always_allow_api_mutations.desc': "Allow WebBrain to use POST, PUT, PATCH, and DELETE through fetch_url or research_url without requiring /allow-api in each conversation. UI-first guidance and confirmation checks still apply. Off by default.",+ 'st.display.always_allow_api_mutations.desc': "Allow WebBrain to use POST, PUT, PATCH, and DELETE through fetch_url or research_url without requiring /allow-api in each conversation. UI-first guidance and confirmation checks still apply. On by default.",'st.display.api_mutation_observer.label': 'API mutation observer',- 'st.display.api_mutation_observer.desc': 'Observe same-tab XHR/fetch request URLs and methods so WebBrain can detect repeated UI actions and suggest API shortcut patterns. Off by default; enable only while investigating shortcut behavior or latency.',+ 'st.display.api_mutation_observer.desc': 'Observe same-tab XHR/fetch request URLs and methods so WebBrain can detect repeated UI actions and suggest API shortcut patterns. On by default.','st.display.webmcp.label': 'Experimental WebMCP','st.display.webmcp.desc': 'Allow WebBrain to discover and run structured tools exposed by supported Chrome pages. Enabling this adds experimental WebMCP tools and guidance to the model context. Off by default.',// TRANSLATORS: Updated for multi-provider Ask streaming and silent transport fallback.diff --git a/src/chrome/src/ui/pdf-handler.js b/src/chrome/src/ui/pdf-handler.jsindex 38eee0f9c..362b4c511 100644--- a/src/chrome/src/ui/pdf-handler.js+++ b/src/chrome/src/ui/pdf-handler.js@@ -679,8 +679,8 @@ async function initialize() {throw new Error('Chrome PDF MIME handler API is unavailable. Use the explicit WebBrain PDF viewer entry instead.');}if (!explicitViewer) {- const stored = await api.storage.local.get({ [PDF_VIEWER_ENABLED_KEY]: false });- if (stored?.[PDF_VIEWER_ENABLED_KEY] !== true) {+ const stored = await api.storage.local.get({ [PDF_VIEWER_ENABLED_KEY]: true });+ if (stored?.[PDF_VIEWER_ENABLED_KEY] === false) {await fallbackToNative();return;}diff --git a/src/chrome/src/ui/settings.js b/src/chrome/src/ui/settings.jsindex e3176cce7..0f3512704 100644--- a/src/chrome/src/ui/settings.js+++ b/src/chrome/src/ui/settings.js@@ -794,7 +794,7 @@ async function init() {}verboseToggle.checked = stored.verboseMode || false;if (selectionShortcutToggle) selectionShortcutToggle.checked = stored.selectionShortcutEnabled !== false;- if (pdfViewerToggle) pdfViewerToggle.checked = stored.pdfViewerEnabled === true;+ if (pdfViewerToggle) pdfViewerToggle.checked = stored.pdfViewerEnabled !== false;if (autoGroupTabsToggle) autoGroupTabsToggle.checked = stored[AUTO_GROUP_TABS_KEY] !== false;if (helpImproveToggle) helpImproveToggle.checked = stored.helpImproveWebBrain !== false; // on by defaultscreenshotToggle.checked = stored.screenshotFallback ?? true; // on by default@@ -841,8 +841,8 @@ async function init() {siteAdaptersToggle.checked = stored.useSiteAdapters ?? true;if (researchEscalationToggle) researchEscalationToggle.checked = stored.researchEscalationEnabled === true;if (voiceInputToggle) voiceInputToggle.checked = stored.voiceInputEnabled ?? true;- alwaysAllowApiMutationsToggle.checked = stored.alwaysAllowApiMutations === true;- apiMutationObserverToggle.checked = stored.apiMutationObserverEnabled === true;+ alwaysAllowApiMutationsToggle.checked = stored.alwaysAllowApiMutations !== false;+ apiMutationObserverToggle.checked = stored.apiMutationObserverEnabled !== false;if (webMcpToggle) webMcpToggle.checked = stored.webMcpEnabled === true; // off by defaultif (openAIAskStreamingToggle) openAIAskStreamingToggle.checked = stored.openaiAskStreamingEnabled !== false;if (planBeforeActModeSelect) {diff --git a/src/chrome/src/ui/sidepanel.js b/src/chrome/src/ui/sidepanel.jsindex c4bfc348b..11ab1723a 100644--- a/src/chrome/src/ui/sidepanel.js+++ b/src/chrome/src/ui/sidepanel.js@@ -4530,7 +4530,7 @@ async function init() {const stored = await chrome.storage.local.get(['verboseMode', 'alwaysAllowApiMutations']);verboseMode = stored.verboseMode || false;syncProgressDisplayMode();- alwaysAllowApiMutations = stored.alwaysAllowApiMutations === true;+ alwaysAllowApiMutations = stored.alwaysAllowApiMutations !== false;syncApiMutationsAllowedForCurrentTab();// Restore prior conversation for this tab (if any) β survives close/reopen.@@ -4594,7 +4594,7 @@ async function init() {syncProgressDisplayMode();}if (changes.alwaysAllowApiMutations) {- alwaysAllowApiMutations = changes.alwaysAllowApiMutations.newValue === true;+ alwaysAllowApiMutations = changes.alwaysAllowApiMutations.newValue !== false;syncApiMutationsAllowedForCurrentTab();}if (changes.providers || changes.activeProvider) {diff --git a/src/firefox/src/background.js b/src/firefox/src/background.jsindex 874bb4947..0342c139e 100644--- a/src/firefox/src/background.js+++ b/src/firefox/src/background.js@@ -142,12 +142,12 @@ Promise.all([const agent = new Agent(providerManager);const ALWAYS_ALLOW_API_MUTATIONS_KEY = 'alwaysAllowApiMutations';const alwaysAllowApiMutationsReady = browser.storage.local- .get({ [ALWAYS_ALLOW_API_MUTATIONS_KEY]: false })+ .get({ [ALWAYS_ALLOW_API_MUTATIONS_KEY]: true }).then((stored) => {- agent.setAlwaysAllowApiMutations(stored[ALWAYS_ALLOW_API_MUTATIONS_KEY] === true);+ agent.setAlwaysAllowApiMutations(stored[ALWAYS_ALLOW_API_MUTATIONS_KEY] !== false);}).catch(() => {- agent.setAlwaysAllowApiMutations(false);+ agent.setAlwaysAllowApiMutations(true);});agent.setConversationScopeChangeListener((tabId, state) => {browser.runtime.sendMessage({@@ -603,12 +603,12 @@ async function isUserMemoryExtractionEnabled() {USER_MEMORY_AUTO_CAPTURE_KEY,]);return stored[USER_MEMORY_ENABLED_KEY] !== false- && stored[USER_MEMORY_AUTO_CAPTURE_KEY] === true;+ && stored[USER_MEMORY_AUTO_CAPTURE_KEY] !== false;}async function isUserMemoryFormCaptureEnabled() {const stored = await browser.storage.local.get(USER_MEMORY_FORM_CAPTURE_KEY);- return stored[USER_MEMORY_FORM_CAPTURE_KEY] === true;+ return stored[USER_MEMORY_FORM_CAPTURE_KEY] !== false;}async function withUserMemoryExtractionQueueLock(task) {@@ -1066,7 +1066,7 @@ browser.storage.onChanged.addListener((changes) => {}let refreshPrompts = false;if (changes[ALWAYS_ALLOW_API_MUTATIONS_KEY]) {- agent.setAlwaysAllowApiMutations(changes[ALWAYS_ALLOW_API_MUTATIONS_KEY].newValue === true);+ agent.setAlwaysAllowApiMutations(changes[ALWAYS_ALLOW_API_MUTATIONS_KEY].newValue !== false);refreshPrompts = true;}if (changes.useSiteAdapters) {@@ -1083,7 +1083,7 @@ browser.storage.onChanged.addListener((changes) => {refreshPrompts = true;}if (changes[API_MUTATION_OBSERVER_KEY]) {- setApiMutationObserverEnabled(changes[API_MUTATION_OBSERVER_KEY].newValue === true);+ setApiMutationObserverEnabled(changes[API_MUTATION_OBSERVER_KEY].newValue !== false);}if (changes.strictSecretMode) {agent.strictSecretMode = !!changes.strictSecretMode.newValue;@@ -1581,7 +1581,7 @@ browser.webRequest?.onBeforeRequest?.addListener?.(// tokens and form bodies do not get printed into model context.const API_REQUESTS_PER_TAB_LIMIT = 40;const API_MUTATION_OBSERVER_KEY = 'apiMutationObserverEnabled';-const API_MUTATION_OBSERVER_DEFAULT = false;+const API_MUTATION_OBSERVER_DEFAULT = true;const API_REPLAY_BODY_LIMIT = 16000;const apiRequestsByTab = new Map(); // tabId -> [{ url, method, ts, replayRequestId, ... }]const apiRequestReplayById = new Map(); // replayRequestId -> captured same-origin replay options@@ -1725,7 +1725,7 @@ function setApiMutationObserverEnabled(enabled) {async function loadApiMutationObserverSetting() {try {const stored = await browser.storage.local.get({ [API_MUTATION_OBSERVER_KEY]: API_MUTATION_OBSERVER_DEFAULT });- setApiMutationObserverEnabled(stored[API_MUTATION_OBSERVER_KEY] === true);+ setApiMutationObserverEnabled(stored[API_MUTATION_OBSERVER_KEY] !== false);} catch (e) {setApiMutationObserverEnabled(API_MUTATION_OBSERVER_DEFAULT);}@@ -2475,8 +2475,8 @@ async function handleMessage(msg, sender) {store,records: store.records,enabled: settings[USER_MEMORY_ENABLED_KEY] !== false,- autoCaptureEnabled: settings[USER_MEMORY_AUTO_CAPTURE_KEY] === true,- formCaptureEnabled: settings[USER_MEMORY_FORM_CAPTURE_KEY] === true,+ autoCaptureEnabled: settings[USER_MEMORY_AUTO_CAPTURE_KEY] !== false,+ formCaptureEnabled: settings[USER_MEMORY_FORM_CAPTURE_KEY] !== false,maxPromptChars: normalizeUserMemoryMaxPromptChars(settings[USER_MEMORY_MAX_PROMPT_CHARS_KEY]),};}diff --git a/src/firefox/src/config-transfer.js b/src/firefox/src/config-transfer.jsindex 6981be782..6c469ba01 100644--- a/src/firefox/src/config-transfer.js+++ b/src/firefox/src/config-transfer.js@@ -37,8 +37,9 @@ export const DEFAULT_CONFIG_SETTINGS = Object.freeze({researchEscalationEnabled: false,researchEscalationEngine: 'chatgpt',voiceInputEnabled: true,- alwaysAllowApiMutations: false,- apiMutationObserverEnabled: false,+ alwaysAllowApiMutations: true,+ apiMutationObserverEnabled: true,+ pdfViewerEnabled: true,webMcpEnabled: false,openaiAskStreamingEnabled: true,planBeforeActMode: 'try',@@ -68,8 +69,8 @@ export const DEFAULT_CONFIG_SETTINGS = Object.freeze({profileText: '',[USER_MEMORY_STORAGE_KEY]: { version: 1, records: [] },[USER_MEMORY_ENABLED_KEY]: true,- [USER_MEMORY_AUTO_CAPTURE_KEY]: false,- [USER_MEMORY_FORM_CAPTURE_KEY]: false,+ [USER_MEMORY_AUTO_CAPTURE_KEY]: true,+ [USER_MEMORY_FORM_CAPTURE_KEY]: true,[USER_MEMORY_MAX_PROMPT_CHARS_KEY]: USER_MEMORY_DEFAULT_MAX_PROMPT_CHARS,[CUSTOM_SKILLS_STORAGE_KEY]: [],[DEFAULT_SKILLS_REMOVED_STORAGE_KEY]: [],@@ -93,6 +94,7 @@ const BOOLEAN_KEYS = new Set(['voiceInputEnabled','alwaysAllowApiMutations','apiMutationObserverEnabled',+ 'pdfViewerEnabled','webMcpEnabled','openaiAskStreamingEnabled','planBeforeAct',diff --git a/src/firefox/src/ui/locales/en.js b/src/firefox/src/ui/locales/en.jsindex fcfb212d9..1561c62f1 100644--- a/src/firefox/src/ui/locales/en.js+++ b/src/firefox/src/ui/locales/en.js@@ -589,9 +589,9 @@ export default {'st.display.voice_input.label': 'Voice input','st.display.voice_input.desc': 'Let the mic button in the chat input dictate text via your browser\'s speech recognition. On by default in browsers that support it.','st.display.always_allow_api_mutations.label': "Always allow API mutations",- 'st.display.always_allow_api_mutations.desc': "Allow WebBrain to use POST, PUT, PATCH, and DELETE through fetch_url or research_url without requiring /allow-api in each conversation. UI-first guidance and confirmation checks still apply. Off by default.",+ 'st.display.always_allow_api_mutations.desc': "Allow WebBrain to use POST, PUT, PATCH, and DELETE through fetch_url or research_url without requiring /allow-api in each conversation. UI-first guidance and confirmation checks still apply. On by default.",'st.display.api_mutation_observer.label': 'API mutation observer',- 'st.display.api_mutation_observer.desc': 'Observe same-tab XHR/fetch request URLs and methods so WebBrain can detect repeated UI actions and suggest API shortcut patterns. Off by default; enable only while investigating shortcut behavior or latency.',+ 'st.display.api_mutation_observer.desc': 'Observe same-tab XHR/fetch request URLs and methods so WebBrain can detect repeated UI actions and suggest API shortcut patterns. On by default.',// TRANSLATORS: Updated for multi-provider Ask streaming and silent transport fallback.'st.display.openai_ask_streaming.label': 'Stream Ask responses','st.display.openai_ask_streaming.desc': 'Show text as it arrives in Ask mode for supported providers. Interrupted streams show a notice and retry once without streaming; provider/API errors are still shown. Tool calls wait for stream completion; Act, Dev, scheduled, cloud, and Continue runs stay non-streaming. On by default.',diff --git a/src/firefox/src/ui/settings.js b/src/firefox/src/ui/settings.jsindex d97740ea6..2600c11df 100644--- a/src/firefox/src/ui/settings.js+++ b/src/firefox/src/ui/settings.js@@ -610,8 +610,8 @@ async function init() {if (siteAdaptersToggle) siteAdaptersToggle.checked = stored.useSiteAdapters ?? true;if (researchEscalationToggle) researchEscalationToggle.checked = stored.researchEscalationEnabled === true;if (voiceInputToggle) voiceInputToggle.checked = stored.voiceInputEnabled ?? true;- if (alwaysAllowApiMutationsToggle) alwaysAllowApiMutationsToggle.checked = stored.alwaysAllowApiMutations === true;- if (apiMutationObserverToggle) apiMutationObserverToggle.checked = stored.apiMutationObserverEnabled === true;+ if (alwaysAllowApiMutationsToggle) alwaysAllowApiMutationsToggle.checked = stored.alwaysAllowApiMutations !== false;+ if (apiMutationObserverToggle) apiMutationObserverToggle.checked = stored.apiMutationObserverEnabled !== false;if (openAIAskStreamingToggle) openAIAskStreamingToggle.checked = stored.openaiAskStreamingEnabled !== false;if (planBeforeActModeSelect) planBeforeActModeSelect.value = normalizePlanBeforeActMode(stored);if (planReviewModeSelect) planReviewModeSelect.value = normalizePlanReviewMode(stored);diff --git a/src/firefox/src/ui/sidepanel.js b/src/firefox/src/ui/sidepanel.jsindex 8e519207c..624bb4e67 100644--- a/src/firefox/src/ui/sidepanel.js+++ b/src/firefox/src/ui/sidepanel.js@@ -4378,7 +4378,7 @@ async function init() {const stored = await browser.storage.local.get(['verboseMode', 'alwaysAllowApiMutations']);verboseMode = stored.verboseMode || false;syncProgressDisplayMode();- alwaysAllowApiMutations = stored.alwaysAllowApiMutations === true;+ alwaysAllowApiMutations = stored.alwaysAllowApiMutations !== false;syncApiMutationsAllowedForCurrentTab();// Restore prior conversation for this tab (if any) β survives close/reopen.@@ -4440,7 +4440,7 @@ async function init() {syncProgressDisplayMode();}if (changes.alwaysAllowApiMutations) {- alwaysAllowApiMutations = changes.alwaysAllowApiMutations.newValue === true;+ alwaysAllowApiMutations = changes.alwaysAllowApiMutations.newValue !== false;syncApiMutationsAllowedForCurrentTab();}if (changes.providers || changes.activeProvider) {diff --git a/test/pdf-mime-handler-e2e.mjs b/test/pdf-mime-handler-e2e.mjsindex e242a1784..30347fc12 100644--- a/test/pdf-mime-handler-e2e.mjs+++ b/test/pdf-mime-handler-e2e.mjs@@ -307,7 +307,7 @@ async function main() {assert.match(extraction.result?.pages?.[0] || '', /WebBrain PDF MIME handler test/);assert.deepEqual(Buffer.from(extraction.result?._pdfBase64 || '', 'base64'), fixture.pdf);- await waitForNativeHandlerOption(settings, false);+ await waitForNativeHandlerOption(settings, true);// Installation initially registers public MIME handlers as enabled. Allow// the post-registration reconciliation pass to settle before navigating.await settings.waitForTimeout(750);@@ -316,19 +316,10 @@ async function main() {checked: document.getElementById('toggle-pdf-viewer')?.checked,}));assert.equal(initialState.stored.pdfViewerEnabled, undefined, 'Fresh installs must preserve an unset WebBrain PDF setting.');- assert.equal(initialState.checked, false, 'The PDF viewer toggle must render off by default.');-- const disabledRouting = await inspectPdfRouting(context, `${fixture.url}?mode=disabled`, extensionId);- assert.equal(disabledRouting.sawWebBrainHandler, false, `Disabled PDF handling still entered WebBrain: ${disabledRouting.urls.join(', ')}`);- assert.equal(disabledRouting.sawNativeHandler, true, `Disabled PDF handling did not reach Chrome's native viewer: ${disabledRouting.urls.join(', ')}`);-- await setPdfViewerToggle(settings, true);- await waitForNativeHandlerOption(settings, true);- const enabledStored = await settings.evaluate(async () => chrome.storage.local.get('pdfViewerEnabled'));- assert.equal(enabledStored.pdfViewerEnabled, true, 'The enabled toggle was not stored.');+ assert.equal(initialState.checked, true, 'The PDF viewer toggle must render on by default.');- const enabledRouting = await inspectPdfRouting(context, `${fixture.url}?mode=enabled`, extensionId);- assert.equal(enabledRouting.sawWebBrainHandler, true, `Enabled PDF handling did not enter WebBrain: ${enabledRouting.urls.join(', ')}`);+ const enabledByDefaultRouting = await inspectPdfRouting(context, `${fixture.url}?mode=enabled-by-default`, extensionId);+ assert.equal(enabledByDefaultRouting.sawWebBrainHandler, true, `Default PDF handling did not enter WebBrain: ${enabledByDefaultRouting.urls.join(', ')}`);await setPdfViewerToggle(settings, false);await waitForNativeHandlerOption(settings, false);diff --git a/test/pdf-selection.mjs b/test/pdf-selection.mjsindex 5e3102521..bb19e61b7 100644--- a/test/pdf-selection.mjs+++ b/test/pdf-selection.mjs@@ -38,17 +38,17 @@ async function testHandlerUsesChromeStreamAndTextLayer() {assert.match(source, /streamInfo\.embedded/);}-async function testPdfViewerIsOptInWithExplicitAndCapabilityFallbacks() {+async function testPdfViewerDefaultsOnWithExplicitAndCapabilityFallbacks() {const html = await readFile(settingsHtmlPath, 'utf8');const settings = await readFile(settingsJsPath, 'utf8');const source = await readFile(handlerJsPath, 'utf8');const background = await readFile(path.join(root, 'src', 'chrome', 'src', 'background.js'), 'utf8');assert.match(html, /id="toggle-pdf-viewer"/);assert.match(settings, /pdfViewerEnabled/);- assert.match(settings, /stored\.pdfViewerEnabled === true/);+ assert.match(settings, /stored\.pdfViewerEnabled !== false/);assert.match(source, /typeof api\?\.mimeHandler\?\.getStreamInfo === 'function'/);- assert.match(source, /api\.storage\.local\.get\(\{ \[PDF_VIEWER_ENABLED_KEY\]: false \}\)/);- assert.match(source, /if \(stored\?\.\[PDF_VIEWER_ENABLED_KEY\] !== true\)/);+ assert.match(source, /api\.storage\.local\.get\(\{ \[PDF_VIEWER_ENABLED_KEY\]: true \}\)/);+ assert.match(source, /if \(stored\?\.\[PDF_VIEWER_ENABLED_KEY\] === false\)/);assert.match(source, /const explicitViewer = Boolean\(explicitUrl && Number\.isInteger\(explicitTabId\) && explicitTabId >= 0\)/);assert.match(source, /if \(!explicitViewer\)/);assert.match(source, /fallbackToNative\(\);/);@@ -56,7 +56,7 @@ async function testPdfViewerIsOptInWithExplicitAndCapabilityFallbacks() {assert.match(source, /MAX_PDF_PAGES/);assert.match(background, /mimeHandler\?\.setMimeHandlerOptions/);assert.match(background, /syncNativePdfMimeHandlerFromStorage/);- assert.match(background, /changes\[PDF_VIEWER_ENABLED_KEY\]\.newValue === true/);+ assert.match(background, /changes\[PDF_VIEWER_ENABLED_KEY\]\.newValue !== false/);}async function testPdfHandlerProvidesCompleteViewerControls() {@@ -376,7 +376,7 @@ async function testPdfSelectionShortcutRunsInHandlerFrame() {const tests = [['manifest registers a top-level application/pdf handler', testManifestRegistration],['PDF handler consumes Chrome stream info and renders a text layer', testHandlerUsesChromeStreamAndTextLayer],- ['PDF viewer is opt-in with explicit and capability fallbacks', testPdfViewerIsOptInWithExplicitAndCapabilityFallbacks],+ ['PDF viewer defaults on with explicit and capability fallbacks', testPdfViewerDefaultsOnWithExplicitAndCapabilityFallbacks],['PDF handler provides complete viewer controls', testPdfHandlerProvidesCompleteViewerControls],['scanned PDF OCR has a bounded handler/background contract', testScannedPdfOcrContract],['OCR normalization keeps bounded normalized text lines', testOcrNormalizationKeepsOnlyBoundedNormalizedLines],diff --git a/test/run.js b/test/run.jsindex 7c9b677a5..7ae934910 100644--- a/test/run.js+++ b/test/run.js@@ -4278,7 +4278,7 @@ test('user memory browser wiring is mirrored and non-blocking', () => {assert.match(background, /case 'delete_user_memory': \{[\s\S]*userMemoryStore\.delete\(String\(msg\.id \|\| ''\)\)[\s\S]*syncAgentUserMemoryFromStorage/, `${label}: user-facing memory delete should hard-delete records`);assert.doesNotMatch(background, /case 'delete_user_memory': \{[\s\S]*userMemoryStore\.archive\(String\(msg\.id \|\| ''\)\)/, `${label}: user-facing memory delete should not archive plaintext`);assert.match(background, new RegExp(`${runtime}\\.storage\\.local\\.get\\(\\[\\s*USER_MEMORY_ENABLED_KEY,[\\s\\S]*USER_MEMORY_AUTO_CAPTURE_KEY`), `${label}: extraction should read both memory and auto-capture toggles`);- assert.match(background, /async function isUserMemoryExtractionEnabled\(\)[\s\S]*stored\[USER_MEMORY_ENABLED_KEY\] !== false[\s\S]*stored\[USER_MEMORY_AUTO_CAPTURE_KEY\] === true/, `${label}: extraction should be gated by the main memory toggle`);+ assert.match(background, /async function isUserMemoryExtractionEnabled\(\)[\s\S]*stored\[USER_MEMORY_ENABLED_KEY\] !== false[\s\S]*stored\[USER_MEMORY_AUTO_CAPTURE_KEY\] !== false/, `${label}: extraction should be gated by the main memory toggle`);assert.match(background, /if \(!await isUserMemoryExtractionEnabled\(\)\) return \{ queued: false, reason: 'disabled' \};/, `${label}: enqueue should not run when memory is disabled`);assert.match(background, /const formCompletionTurn = sourceContext === 'form_completion';/, `${label}: form-derived memory should be classified before extraction text is built`);assert.match(background, /if \(!await isUserMemoryFormCaptureEnabled\(\)\) \{[\s\S]*return \{ queued: false, reason: 'form_capture_disabled' \};/, `${label}: form-derived memory should be gated by its opt-in setting`);@@ -46614,7 +46614,7 @@ test('settings scopes WebBrain Compass billing button to provider card only', ()}});-test('API mutation observer setting is opt-in and controls the request observer', () => {+test('API mutation observer setting defaults on and controls the request observer', () => {for (const [label, bgRel, settingsRel, htmlRel] of [['chrome', 'src/chrome/src/background.js', 'src/chrome/src/ui/settings.js', 'src/chrome/src/ui/settings.html'],['firefox', 'src/firefox/src/background.js', 'src/firefox/src/ui/settings.js', 'src/firefox/src/ui/settings.html'],@@ -46624,12 +46624,12 @@ test('API mutation observer setting is opt-in and controls the request observer'const html = fs.readFileSync(path.join(ROOT, htmlRel), 'utf8');assert.match(html, /id="toggle-api-mutation-observer"/, `${label}: settings toggle missing`);- assert.doesNotMatch(html, /id="toggle-api-mutation-observer"\s+checked/, `${label}: observer toggle should default off`);+ assert.doesNotMatch(html, /id="toggle-api-mutation-observer"\s+checked/, `${label}: observer toggle state should be set from storage`);assert.match(settings, /apiMutationObserverEnabled/, `${label}: settings should persist observer toggle`);- assert.match(settings, /apiMutationObserverToggle\.checked = stored\.apiMutationObserverEnabled === true/, `${label}: observer should load off by default`);+ assert.match(settings, /apiMutationObserverToggle\.checked = stored\.apiMutationObserverEnabled !== false/, `${label}: observer should load on by default`);assert.match(settings, /apiMutationObserverEnabled:\s*apiMutationObserverToggle\.checked/, `${label}: observer toggle should save storage`);assert.match(bg, /const API_MUTATION_OBSERVER_KEY = 'apiMutationObserverEnabled';/, `${label}: storage key missing`);- assert.match(bg, /const API_MUTATION_OBSERVER_DEFAULT = false;/, `${label}: observer default should be explicit and off`);+ assert.match(bg, /const API_MUTATION_OBSERVER_DEFAULT = true;/, `${label}: observer default should be explicit and on`);assert.match(bg, /function setApiMutationObserverEnabled\(enabled\)/, `${label}: observer gate missing`);assert.doesNotMatch(bg, /(?:chrome|browser)\.webRequest\.onBeforeRequest\.addListener\(/, `${label}: observer should not register unconditionally`);assert.match(bg, /onBeforeRequest\.addListener\(recordApiRequest/, `${label}: observer should register only through the gate`);@@ -46638,17 +46638,17 @@ test('API mutation observer setting is opt-in and controls the request observer'assert.match(bg, /globalThis\.__webbrainApiRequestReplay = apiRequestReplayById/, `${label}: replay store should be available to fetch_url`);assert.match(bg, /onBeforeRequest\.removeListener\(recordApiRequest\)/, `${label}: observer should unregister when disabled`);assert.match(bg, /onBeforeSendHeaders\?\.removeListener\(recordApiRequestHeaders\)/, `${label}: header observer should unregister when disabled`);- assert.match(bg, /storage\.local\.get\(\{ \[API_MUTATION_OBSERVER_KEY\]: API_MUTATION_OBSERVER_DEFAULT \}\)/, `${label}: unset storage should use explicit off default`);- assert.match(bg, /setApiMutationObserverEnabled\(stored\[API_MUTATION_OBSERVER_KEY\] === true\)/, `${label}: only explicit true should enable observer`);+ assert.match(bg, /storage\.local\.get\(\{ \[API_MUTATION_OBSERVER_KEY\]: API_MUTATION_OBSERVER_DEFAULT \}\)/, `${label}: unset storage should use the explicit default`);+ assert.match(bg, /setApiMutationObserverEnabled\(stored\[API_MUTATION_OBSERVER_KEY\] !== false\)/, `${label}: observer should stay on unless explicitly disabled`);assert.match(bg,- /changes\[API_MUTATION_OBSERVER_KEY\][\s\S]*setApiMutationObserverEnabled\(changes\[API_MUTATION_OBSERVER_KEY\]\.newValue === true\)/,+ /changes\[API_MUTATION_OBSERVER_KEY\][\s\S]*setApiMutationObserverEnabled\(changes\[API_MUTATION_OBSERVER_KEY\]\.newValue !== false\)/,`${label}: storage changes should update observer`,);}});-test('persistent API mutation permission is opt-in, portable, and mirrored', () => {+test('persistent API mutation permission defaults on, is portable, and mirrored', () => {for (const [label, bgRel, settingsRel, htmlRel, panelRel, configRel] of [['chrome', 'src/chrome/src/background.js', 'src/chrome/src/ui/settings.js', 'src/chrome/src/ui/settings.html', 'src/chrome/src/ui/sidepanel.js', 'src/chrome/src/config-transfer.js'],['firefox', 'src/firefox/src/background.js', 'src/firefox/src/ui/settings.js', 'src/firefox/src/ui/settings.html', 'src/firefox/src/ui/sidepanel.js', 'src/firefox/src/config-transfer.js'],@@ -46663,16 +46663,16 @@ test('persistent API mutation permission is opt-in, portable, and mirrored', ()assert.match(html, /id="always-allow-api-mutations-label"[^>]*data-i18n="st\.display\.always_allow_api_mutations\.label"/, `${label}: persistent permission label should expose a stable accessible-name target`);assert.match(html, /id="always-allow-api-mutations-desc"[^>]*data-i18n="st\.display\.always_allow_api_mutations\.desc"/, `${label}: persistent permission description should expose a stable accessible-description target`);assert.match(html, /id="toggle-always-allow-api-mutations"[^>]*aria-labelledby="always-allow-api-mutations-label"[^>]*aria-describedby="always-allow-api-mutations-desc"/, `${label}: persistent permission toggle should reference its translated label and description`);- assert.doesNotMatch(html, /id="toggle-always-allow-api-mutations"\s+checked/, `${label}: persistent permission must default off`);- assert.match(settings, /alwaysAllowApiMutationsToggle\.checked = stored\.alwaysAllowApiMutations === true/, `${label}: settings should load only explicit persistent opt-in`);+ assert.doesNotMatch(html, /id="toggle-always-allow-api-mutations"\s+checked/, `${label}: persistent permission state should be set from storage`);+ assert.match(settings, /alwaysAllowApiMutationsToggle\.checked = stored\.alwaysAllowApiMutations !== false/, `${label}: settings should load on by default`);assert.match(settings, /alwaysAllowApiMutations:\s*alwaysAllowApiMutationsToggle\.checked/, `${label}: settings should save the persistent permission`);assert.match(bg, /const ALWAYS_ALLOW_API_MUTATIONS_KEY = 'alwaysAllowApiMutations';/, `${label}: background storage key missing`);- assert.match(bg, /setAlwaysAllowApiMutations\(stored\[ALWAYS_ALLOW_API_MUTATIONS_KEY\] === true\)/, `${label}: background should initialize the Agent from storage`);+ assert.match(bg, /setAlwaysAllowApiMutations\(stored\[ALWAYS_ALLOW_API_MUTATIONS_KEY\] !== false\)/, `${label}: background should initialize the Agent from storage`);assert.match(bg, /await alwaysAllowApiMutationsReady;/, `${label}: first agent runs should wait for persistent permission hydration`);- assert.match(bg, /changes\[ALWAYS_ALLOW_API_MUTATIONS_KEY\][\s\S]*setAlwaysAllowApiMutations\(changes\[ALWAYS_ALLOW_API_MUTATIONS_KEY\]\.newValue === true\)/, `${label}: background should apply live revocation`);- assert.match(panel, /alwaysAllowApiMutations = stored\.alwaysAllowApiMutations === true/, `${label}: side panel should load the persistent authorization state`);+ assert.match(bg, /changes\[ALWAYS_ALLOW_API_MUTATIONS_KEY\][\s\S]*setAlwaysAllowApiMutations\(changes\[ALWAYS_ALLOW_API_MUTATIONS_KEY\]\.newValue !== false\)/, `${label}: background should apply live revocation`);+ assert.match(panel, /alwaysAllowApiMutations = stored\.alwaysAllowApiMutations !== false/, `${label}: side panel should load the persistent authorization state`);assert.match(panel, /alwaysAllowApiMutations \|\| isApiMutationsAllowedForTab\(currentTabId\)/, `${label}: authorization should combine persistent and conversation permission`);- assert.match(config, /alwaysAllowApiMutations:\s*false/, `${label}: config export default should remain off`);+ assert.match(config, /alwaysAllowApiMutations:\s*true/, `${label}: config export default should be on`);assert.match(config, /'alwaysAllowApiMutations'/, `${label}: config import should validate the boolean setting`);}});