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(decisions): accept a decision server elsewhere on the local network
Claude292b8cd6c8e2
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex b3ef39249..fe8ab759f 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -16,6 +16,7 @@ This changelog was generated from the repository Git history and release tags. V- The spinning ring next to "Thinking…" in the side panel is now a small WebBrain brain drawn as a neural circuit: a signal keeps tracing the W, and the brain's outline lights up as it passes. It moves only while WebBrain is working and the panel is visible, follows the light and dark themes, and holds still when your system asks to reduce motion.### Fixed+- Providers → Decision accepts a local decision server on another machine on your network, such as `http://192.168.1.51:8091`. **Load available models** and **Test** used to stop with "Decision endpoints require HTTPS outside localhost." for any address but this computer's. Private addresses (10.x, 172.16–31.x, 192.168.x, Tailscale's 100.64–127.x, link-local, IPv6 unique-local) and `.local`, `.home.arpa` and `.internal` names now work over plain HTTP; public addresses still need HTTPS. In Chrome, decision requests to such a server go through the same offscreen proxy as chat models on your network. Vision and speech endpoints already accepted these addresses.- Act can send a photo or video in an Instagram direct message. Instagram's message box keeps its file input hidden, outside any form, deep in a long conversation, where WebBrain's check that an action still targets what the model saw cannot reach it. Every attachment was refused, even with the exact selector WebBrain itself listed for that input, often right after you had confirmed the recipient on WebBrain's card; the model then sent a link to the picture, or said Instagram blocks attachments. With Strict checks off, an upload to the very input WebBrain listed on that page, named by the selector it gave, now goes through with a note to the model, and the recipient checks still apply. A selector WebBrain did not list is still refused, and so is an input the page re-created after the list under the same selector, until WebBrain lists the page's controls again. When clicking "Add Photo or Video" opens a file chooser, WebBrain now names the input with that same selector, and the Instagram site notes say to attach the file to that input instead of clicking the button, and that a link to a picture is not the picture.- Act can attach images and videos to a post on X again. While the post composer is open at x.com/compose/post, the timeline behind it keeps a second, identical file input, and WebBrain's list of the page's controls gave neither input a selector. After the model's first selector matched both, WebBrain refused every later upload until it saw a selector it could not get, so the run ended at its cost limit with nothing attached. The list now gives every file input a selector that matches only that input, scoped to the open dialog where that is what tells them apart, and marks the dialog's input `inDialog`. The X site notes name the dialog's input, and when no selector can single out an input, WebBrain tells the model to report the upload as blocked instead of retrying.diff --git a/docs/providers-and-models.md b/docs/providers-and-models.mdindex a82c0f8e5..aaf9e3e5a 100644--- a/docs/providers-and-models.md+++ b/docs/providers-and-models.md@@ -126,7 +126,14 @@ evidence goes to the main model.Local [Kev](https://github.com/jaredpalmer/kev) defaults to`http://127.0.0.1:8009`, model `kev-latest`, using `/v1/systemone`. A key is optional-and loopback requests work offline. Custom remote endpoints require HTTPS.+and loopback requests work offline. A server elsewhere on your own network may+also use plain HTTP: private IPv4 (`10/8`, `172.16/12`, `192.168/16`), shared+`100.64/10` (Tailscale), link-local, unique-local IPv6, and `.local`,+`.home.arpa` and `.internal` names (`isPrivateNetworkHost` in+`decision-config.js`). Such a server is not treated as this device: it gets the+credential-redacted texts other routes get and needs the browser to be online.+Chrome sends its requests through the offscreen proxy the LAN chat providers+use. Any other remote endpoint requires HTTPS.Image support follows available model capabilities or the custom override. TestConnection checks typed answers and, when enabled, two independent image-onlyfacts. A successful HTTP response alone does not establish image support.diff --git a/src/chrome/src/agent/decision-config.js b/src/chrome/src/agent/decision-config.jsindex 09c2ea6cc..d584f2b09 100644--- a/src/chrome/src/agent/decision-config.js+++ b/src/chrome/src/agent/decision-config.js@@ -1,4 +1,5 @@import { D1_MODEL_ID, D1_CONSENT_KEY, D1_CONSENT_VERSION } from '../providers/d1-config.js';+import { fetchWithFallback } from '../providers/fetch-with-fallback.js';export const DEFAULT_DECISION_MODEL = 'cloudflare/clef-flash';// Auto (the default) uses a decision model only when one is already on hand,// On uses the configured one for every decision, Off never uses one.@@ -141,6 +142,50 @@ export function materializeLegacyDecisionFeatures(stored = {}) {return values;}+// Hosts on this device. Only these make a configured decision server `local`:+// it answers offline and gets the unredacted texts (completion-runtime.js).+const LOOPBACK_HOSTS = Object.freeze(['localhost', '127.0.0.1', '[::1]']);++function ipv4Octets(host) {+ const octets = /^\d{1,3}(?:\.\d{1,3}){3}$/.test(host) ? host.split('.').map(Number) : null;+ if (octets?.every(n => n <= 255)) return octets;+ // The URL parser writes an IPv4-mapped IPv6 host in hex: ::ffff:c0a8:101.+ const mapped = /^::ffff:([0-9a-f]{1,4}):([0-9a-f]{1,4})$/.exec(host);+ return mapped ? mapped.slice(1).flatMap(part => { const n = parseInt(part, 16); return [n >> 8, n & 255]; }) : null;+}++// Whether a URL hostname stays on this device or the user's own network: the+// loopback, private (RFC 1918), shared (RFC 6598, which Tailscale uses) and+// link-local IPv4 ranges, unique-local and link-local IPv6, and the+// special-use local names. A decision server on another machine on the LAN+// (llama.cpp, vLLM) rarely has a certificate, so these may use plain HTTP.+// Such a server is still not `local`: it gets the texts any other route gets.+export function isPrivateNetworkHost(hostname) {+ const host = String(hostname || '').toLowerCase().replace(/^\[(.*)\]$/, '$1').replace(/\.$/, '');+ if (host === 'localhost' || /\.(?:localhost|local|home\.arpa|internal)$/.test(host)) return true;+ const ipv4 = ipv4Octets(host);+ if (ipv4) {+ const [a, b] = ipv4;+ return a === 127 || a === 10 || (a === 172 && b >= 16 && b <= 31) || (a === 192 && b === 168)+ || (a === 169 && b === 254) || (a === 100 && b >= 64 && b <= 127);+ }+ if (host === '::1') return true;+ const first = host.includes(':') ? parseInt(host.split(':')[0], 16) : NaN;+ return (first & 0xfe00) === 0xfc00 || (first & 0xffc0) === 0xfe80;+}++// Chrome's service worker cannot reach a server elsewhere on the local network+// (Private Network Access), so requests to a decision server there take the+// offscreen proxy the LAN chat providers use. This device and public+// endpoints keep the direct request.+export function decisionFetch(url, options) {+ let host = '';+ try { host = new URL(url).hostname; } catch {}+ return isPrivateNetworkHost(host) && !LOOPBACK_HOSTS.includes(host)+ ? fetchWithFallback(url, options)+ : globalThis.fetch(url, options);+}+// The provider configuration itself. `on` means the user turned decisions on:// only then can an explicit local choice (D1, the chat model) or a configured// key answer; Compass answers whenever it is passed in.@@ -180,8 +225,8 @@ function selectedDecisionConfig(stored, compass, on) {: String(stored.decisionBaseUrl || 'http://127.0.0.1:8009').trim();const url = new URL(baseUrl);if (!['https:', 'http:'].includes(url.protocol) || url.username || url.password || url.search || url.hash) throw new Error('Invalid decision endpoint.');- const loopback = ['localhost', '127.0.0.1', '[::1]'].includes(url.hostname);- if (url.protocol === 'http:' && !loopback) throw new Error('Decision endpoints require HTTPS outside localhost.');+ const loopback = LOOPBACK_HOSTS.includes(url.hostname);+ if (url.protocol === 'http:' && !isPrivateNetworkHost(url.hostname)) throw new Error('Decision endpoints require HTTPS outside localhost and private networks.');const apiKey = String((provider === 'compass' ? compass?.apiKey : provider === 'typesafe' ? stored.typesafeApiKey : provider === 'local' ? stored.decisionLocalApiKey : stored.decisionApiKey) || '').trim();const visionMode = compass ? 'auto' : (stored.decisionVisionMode || 'auto');const rate = (value, fallback) => Number.isFinite(value) && value >= 0 ? value : fallback;@@ -199,7 +244,7 @@ function selectedDecisionConfig(stored, compass, on) {};}-export async function listDecisionModels(config, fetchImpl = globalThis.fetch, signal) {+export async function listDecisionModels(config, fetchImpl = decisionFetch, signal) {if (config.provider === 'webgpu_chat') return [{ id: WEBGPU_CHAT_DECISION_MODEL, name: 'Compass VLD Tiny v5 (in-browser)', supportsVision: true, inputRate: 0, outputRate: 0 }];if (config.provider === 'webgpu_d1') return [{ id: D1_MODEL_ID, name: 'D1 FP16 (experimental, on-device)', supportsVision: true, inputRate: 0, outputRate: 0 }];return withCompletionTimeout(requestSignal => discoverDecisionModels(config, fetchImpl, requestSignal), signal, 5000);@@ -207,7 +252,8 @@ export async function listDecisionModels(config, fetchImpl = globalThis.fetch, sasync function discoverDecisionModels(config, fetchImpl, signal) {const url = config.provider === 'openrouter' ? 'https://openrouter.ai/api/v1/models?output_modalities=decisions' : config.baseUrl + (config.baseUrl.endsWith('/v1') ? '/models' : '/v1/models');- const response = await fetchImpl(url, { credentials: 'omit', redirect: 'error', signal, headers: config.apiKey ? { Authorization: `Bearer ${config.apiKey}` } : {} });+ // An explicit GET: Chrome's offscreen proxy sends a request without a method as POST.+ const response = await fetchImpl(url, { method: 'GET', credentials: 'omit', redirect: 'error', signal, headers: config.apiKey ? { Authorization: `Bearer ${config.apiKey}` } : {} });if (!response.ok) throw new Error(`Model discovery failed with HTTP ${response.status}.`);const body = await response.json();const models = Array.isArray(body) ? body : body.data || body.models || [];diff --git a/src/chrome/src/agent/systemone-judge.js b/src/chrome/src/agent/systemone-judge.jsindex db94c6ae1..9dbf16320 100644--- a/src/chrome/src/agent/systemone-judge.js+++ b/src/chrome/src/agent/systemone-judge.js@@ -6,6 +6,7 @@import { evaluateD1 } from '../providers/d1.js';import { evaluateWebgpuDecision } from '../providers/webgpu-decision.js';+import { decisionFetch } from './decision-config.js';export const SYSTEM_ONE_API_URL = 'https://api.typesafe.ai/v1/systemone';export const SYSTEM_ONE_MODEL = 'jev-1.13.0';@@ -298,7 +299,8 @@ export function shouldDowngradeSuccess(answers, { threshold = SYSTEM_ONE_DEFAULT}export function createSystemOneJudge({- fetchImpl = globalThis.fetch,+ // A decision server on the LAN needs Chrome's offscreen proxy (decision-config.js).+ fetchImpl = decisionFetch,sleep = defaultSleep,// Unset: each provider's own limit. A caller's budget is capped by it.timeoutMs = null,diff --git a/src/chrome/src/offscreen/offscreen.js b/src/chrome/src/offscreen/offscreen.jsindex 10fcd7f3d..64e5f120f 100644--- a/src/chrome/src/offscreen/offscreen.js+++ b/src/chrome/src/offscreen/offscreen.js@@ -171,6 +171,8 @@ chrome.runtime.onConnect.addListener((port) => {method: msg.method || 'POST',headers: msg.headers || {},body,+ ...(msg.redirect ? { redirect: msg.redirect } : {}),+ ...(msg.credentials ? { credentials: msg.credentials } : {}),signal: fetchController.signal,});await cleanupFormData();diff --git a/src/chrome/src/providers/fetch-with-fallback.js b/src/chrome/src/providers/fetch-with-fallback.jsindex a1790f249..ed5ead673 100644--- a/src/chrome/src/providers/fetch-with-fallback.js+++ b/src/chrome/src/providers/fetch-with-fallback.js@@ -378,6 +378,10 @@ async function _fetchViaOffscreenProxy(url, fetchOptions, timeoutMs, callerSignaurl,method: fetchOptions.method || 'POST',headers: fetchOptions.headers || {},+ // Decision requests refuse redirects and send no cookies+ // (decision-config.js); the proxied request keeps both.+ ...(fetchOptions.redirect ? { redirect: fetchOptions.redirect } : {}),+ ...(fetchOptions.credentials ? { credentials: fetchOptions.credentials } : {}),...preparedBody.message,});} catch (e) {diff --git a/src/firefox/src/agent/decision-config.js b/src/firefox/src/agent/decision-config.jsindex 47f8ae752..52bdc5c71 100644--- a/src/firefox/src/agent/decision-config.js+++ b/src/firefox/src/agent/decision-config.js@@ -135,6 +135,44 @@ export function materializeLegacyDecisionFeatures(stored = {}) {return values;}+// Hosts on this device. Only these make a configured decision server `local`:+// it answers offline and gets the unredacted texts (completion-runtime.js).+const LOOPBACK_HOSTS = Object.freeze(['localhost', '127.0.0.1', '[::1]']);++function ipv4Octets(host) {+ const octets = /^\d{1,3}(?:\.\d{1,3}){3}$/.test(host) ? host.split('.').map(Number) : null;+ if (octets?.every(n => n <= 255)) return octets;+ // The URL parser writes an IPv4-mapped IPv6 host in hex: ::ffff:c0a8:101.+ const mapped = /^::ffff:([0-9a-f]{1,4}):([0-9a-f]{1,4})$/.exec(host);+ return mapped ? mapped.slice(1).flatMap(part => { const n = parseInt(part, 16); return [n >> 8, n & 255]; }) : null;+}++// Whether a URL hostname stays on this device or the user's own network: the+// loopback, private (RFC 1918), shared (RFC 6598, which Tailscale uses) and+// link-local IPv4 ranges, unique-local and link-local IPv6, and the+// special-use local names. A decision server on another machine on the LAN+// (llama.cpp, vLLM) rarely has a certificate, so these may use plain HTTP.+// Such a server is still not `local`: it gets the texts any other route gets.+export function isPrivateNetworkHost(hostname) {+ const host = String(hostname || '').toLowerCase().replace(/^\[(.*)\]$/, '$1').replace(/\.$/, '');+ if (host === 'localhost' || /\.(?:localhost|local|home\.arpa|internal)$/.test(host)) return true;+ const ipv4 = ipv4Octets(host);+ if (ipv4) {+ const [a, b] = ipv4;+ return a === 127 || a === 10 || (a === 172 && b >= 16 && b <= 31) || (a === 192 && b === 168)+ || (a === 169 && b === 254) || (a === 100 && b >= 64 && b <= 127);+ }+ if (host === '::1') return true;+ const first = host.includes(':') ? parseInt(host.split(':')[0], 16) : NaN;+ return (first & 0xfe00) === 0xfc00 || (first & 0xffc0) === 0xfe80;+}++// Firefox's background page reaches a decision server on the local network+// directly; Chrome's service worker needs its offscreen proxy for one.+export function decisionFetch(url, options) {+ return globalThis.fetch(url, options);+}+// The provider configuration itself. `on` means the user turned decisions on:// only then can an explicit local choice (D1, the chat model) or a configured// key answer; Compass answers whenever it is passed in.@@ -173,8 +211,8 @@ function selectedDecisionConfig(stored, compass, on) {: String(stored.decisionBaseUrl || 'http://127.0.0.1:8009').trim();const url = new URL(baseUrl);if (!['https:', 'http:'].includes(url.protocol) || url.username || url.password || url.search || url.hash) throw new Error('Invalid decision endpoint.');- const loopback = ['localhost', '127.0.0.1', '[::1]'].includes(url.hostname);- if (url.protocol === 'http:' && !loopback) throw new Error('Decision endpoints require HTTPS outside localhost.');+ const loopback = LOOPBACK_HOSTS.includes(url.hostname);+ if (url.protocol === 'http:' && !isPrivateNetworkHost(url.hostname)) throw new Error('Decision endpoints require HTTPS outside localhost and private networks.');const apiKey = String((provider === 'compass' ? compass?.apiKey : provider === 'typesafe' ? stored.typesafeApiKey : provider === 'local' ? stored.decisionLocalApiKey : stored.decisionApiKey) || '').trim();const visionMode = compass ? 'auto' : (stored.decisionVisionMode || 'auto');const rate = (value, fallback) => Number.isFinite(value) && value >= 0 ? value : fallback;@@ -192,7 +230,7 @@ function selectedDecisionConfig(stored, compass, on) {};}-export async function listDecisionModels(config, fetchImpl = globalThis.fetch, signal) {+export async function listDecisionModels(config, fetchImpl = decisionFetch, signal) {if (config.provider === 'webgpu_chat') return [{ id: WEBGPU_CHAT_DECISION_MODEL, name: 'Compass VLD Tiny v5 (in-browser)', supportsVision: true, inputRate: 0, outputRate: 0 }];if (config.provider === 'webgpu_d1') return [{ id: D1_MODEL_ID, name: 'D1 FP16 (experimental, on-device)', supportsVision: true, inputRate: 0, outputRate: 0 }];return withCompletionTimeout(requestSignal => discoverDecisionModels(config, fetchImpl, requestSignal), signal, 5000);@@ -200,7 +238,8 @@ export async function listDecisionModels(config, fetchImpl = globalThis.fetch, sasync function discoverDecisionModels(config, fetchImpl, signal) {const url = config.provider === 'openrouter' ? 'https://openrouter.ai/api/v1/models?output_modalities=decisions' : config.baseUrl + (config.baseUrl.endsWith('/v1') ? '/models' : '/v1/models');- const response = await fetchImpl(url, { credentials: 'omit', redirect: 'error', signal, headers: config.apiKey ? { Authorization: `Bearer ${config.apiKey}` } : {} });+ // An explicit GET: Chrome's offscreen proxy sends a request without a method as POST.+ const response = await fetchImpl(url, { method: 'GET', credentials: 'omit', redirect: 'error', signal, headers: config.apiKey ? { Authorization: `Bearer ${config.apiKey}` } : {} });if (!response.ok) throw new Error(`Model discovery failed with HTTP ${response.status}.`);const body = await response.json();const models = Array.isArray(body) ? body : body.data || body.models || [];diff --git a/src/firefox/src/agent/systemone-judge.js b/src/firefox/src/agent/systemone-judge.jsindex db94c6ae1..9dbf16320 100644--- a/src/firefox/src/agent/systemone-judge.js+++ b/src/firefox/src/agent/systemone-judge.js@@ -6,6 +6,7 @@import { evaluateD1 } from '../providers/d1.js';import { evaluateWebgpuDecision } from '../providers/webgpu-decision.js';+import { decisionFetch } from './decision-config.js';export const SYSTEM_ONE_API_URL = 'https://api.typesafe.ai/v1/systemone';export const SYSTEM_ONE_MODEL = 'jev-1.13.0';@@ -298,7 +299,8 @@ export function shouldDowngradeSuccess(answers, { threshold = SYSTEM_ONE_DEFAULT}export function createSystemOneJudge({- fetchImpl = globalThis.fetch,+ // A decision server on the LAN needs Chrome's offscreen proxy (decision-config.js).+ fetchImpl = decisionFetch,sleep = defaultSleep,// Unset: each provider's own limit. A caller's budget is capped by it.timeoutMs = null,diff --git a/test/completion-verifier.mjs b/test/completion-verifier.mjsindex 5b0803aad..fb8626be7 100644--- a/test/completion-verifier.mjs+++ b/test/completion-verifier.mjs@@ -22,10 +22,10 @@ for (const build of ['chrome', 'firefox']) {test(`${build}: full and sparse imports reject invalid decision enums and endpoints before persistence`, () => {for (const parser of [transfer.parseConfigImport, transfer.parseConfigPatchImport]) {for (const settings of [{ decisionProvider: 'unknown' }, { decisionVisionMode: 'maybe' }, { decisionProvider: 'local', decisionBaseUrl: 'not a URL' },- { decisionBaseUrl: 'javascript:alert(1)' }, { decisionBaseUrl: 'http://remote.example.com' }, { decisionBaseUrl: 'https://user:[email protected]' }]) {+ { decisionBaseUrl: 'javascript:alert(1)' }, { decisionBaseUrl: 'http://remote.example.com' }, { decisionBaseUrl: 'http://8.8.8.8:8009' }, { decisionBaseUrl: 'https://user:[email protected]' }]) {assert.throws(() => parser(JSON.stringify({ schema: transfer.CONFIG_SCHEMA, settings })), /Invalid value for configuration setting/);}- for (const decisionBaseUrl of ['', 'http://127.0.0.1:8009', 'http://localhost:8009', 'http://[::1]:8009', 'https://example.com/v1']) {+ for (const decisionBaseUrl of ['', 'http://127.0.0.1:8009', 'http://localhost:8009', 'http://[::1]:8009', 'https://example.com/v1', 'http://192.168.1.51:8091', 'http://gpu.local:8009/v1']) {const imported = parser(JSON.stringify({ schema: transfer.CONFIG_SCHEMA, settings: { decisionProvider: 'local', decisionBaseUrl } })).settings;assert.doesNotThrow(() => config.resolveDecisionConfig(imported));}@@ -46,6 +46,68 @@ for (const build of ['chrome', 'firefox']) {const compass = config.resolveDecisionConfig({ decisionProvider: 'local', systemOneDoneEnabled: false }, { baseUrl: 'https://api.webbrain.one/v1' });assert.equal(compass.provider, 'compass'); assert.equal(compass.enabled, true); assert.equal(compass.doneEnabled, true);});+ test(`${build}: a decision server elsewhere on the private network may use plain HTTP but is not this device`, () => {+ for (const decisionBaseUrl of ['http://192.168.1.51:8091/', 'http://10.1.2.3:8009/v1', 'http://172.16.4.2:8009', 'http://172.31.0.9:8009', 'http://100.100.1.2:8009',+ 'http://169.254.1.2:8009', 'http://gpu.local:8009', 'http://gpu.home.arpa:8009', 'http://gpu.internal:8009', 'http://[fd00::5]:8009', 'http://[::ffff:192.168.1.51]:8091']) {+ const selected = config.resolveDecisionConfig({ decisionMode: 'on', decisionProvider: 'local', decisionBaseUrl });+ assert.equal(selected.enabled, true, decisionBaseUrl);+ // Off this device: no offline answers, and the texts other routes get.+ assert.equal(selected.local, false, decisionBaseUrl); assert.equal(selected.config.category, 'cloud', decisionBaseUrl);+ assert.equal(selected.config.inputCostPerMillionUsd, 0, decisionBaseUrl);+ }+ assert.equal(config.resolveDecisionConfig({ decisionProvider: 'local', decisionBaseUrl: 'http://192.168.1.51:8091/' }).url, 'http://192.168.1.51:8091/v1/systemone');+ for (const decisionBaseUrl of ['http://8.8.8.8:8009', 'http://172.32.0.1:8009', 'http://100.128.0.1:8009', 'http://192.0.2.10:8009', 'http://decisions.example.com',+ 'http://gpu.local.example.com', 'http://gpubox:8009', 'http://0.0.0.0:8009', 'http://[2001:db8::1]:8009', 'http://[::ffff:8.8.8.8]:8009']) {+ assert.throws(() => config.resolveDecisionConfig({ decisionProvider: 'local', decisionBaseUrl }), /require HTTPS outside localhost and private networks/, decisionBaseUrl);+ }+ assert.equal(config.resolveDecisionConfig({ decisionProvider: 'local', decisionBaseUrl: 'https://decisions.example.com/v1' }).url, 'https://decisions.example.com/v1/systemone');+ });+ if (build === 'chrome') test('chrome: requests to a LAN decision server take the offscreen proxy and keep their redirect and cookie policy', async () => {+ const previousChrome = globalThis.chrome, previousFetch = globalThis.fetch, previousWarn = console.warn;+ const answer = response(); answer.model = 'kev-latest';+ const direct = [], proxied = [];+ console.warn = () => {};+ // The service worker cannot reach the LAN host (Private Network Access); loopback answers directly.+ globalThis.fetch = async (url, options = {}) => {+ direct.push({ url: String(url), method: options.method || 'GET' });+ if (String(url).startsWith('http://192.168.1.51:8091/')) throw new TypeError('Failed to fetch');+ return new Response(JSON.stringify(answer), { status: 200, headers: { 'Content-Type': 'application/json' } });+ };+ globalThis.chrome = {+ offscreen: { hasDocument: async () => true },+ runtime: { connect() {+ const listeners = [];+ return {+ onMessage: { addListener: fn => listeners.push(fn) }, onDisconnect: { addListener() {} }, disconnect() {},+ postMessage(message) {+ proxied.push(message);+ const body = message.url.endsWith('/v1/models') ? { data: [{ id: 'kev-latest' }] } : answer;+ queueMicrotask(() => [{ type: 'headers', ok: true, status: 200, contentType: 'application/json' }, { type: 'chunk', text: JSON.stringify(body) }, { type: 'done' }]+ .forEach(m => listeners.forEach(fn => fn(m))));+ },+ };+ } },+ };+ try {+ const lan = config.resolveDecisionConfig({ decisionMode: 'on', decisionProvider: 'local', decisionBaseUrl: 'http://192.168.1.51:8091/' });+ assert.deepEqual((await config.listDecisionModels(lan)).map(model => model.id), ['kev-latest']);+ assert.deepEqual(direct, [{ url: 'http://192.168.1.51:8091/v1/models', method: 'GET' }]);+ assert.equal(proxied.length, 1);+ assert.deepEqual({ ...proxied[0], headers: undefined }, { url: 'http://192.168.1.51:8091/v1/models', method: 'GET', redirect: 'error', credentials: 'omit', headers: undefined, body: undefined });+ const client = judge.createSystemOneJudge({ maxRetries: 0 });+ const result = await client.evaluate({ config: lan, state: {}, questions: verifier.completionQuestions() });+ assert.equal(result.model, 'kev-latest');+ // A POST takes one transport: the proxy, never a direct attempt first.+ assert.equal(direct.length, 1); assert.equal(proxied.length, 2);+ assert.equal(proxied[1].url, 'http://192.168.1.51:8091/v1/systemone'); assert.equal(proxied[1].method, 'POST');+ assert.equal(proxied[1].redirect, 'error'); assert.equal(proxied[1].credentials, 'omit');+ await client.evaluate({ config: config.resolveDecisionConfig({ decisionMode: 'on', decisionProvider: 'local' }), state: {}, questions: verifier.completionQuestions() });+ assert.deepEqual(direct.at(-1), { url: 'http://127.0.0.1:8009/v1/systemone', method: 'POST' }); assert.equal(proxied.length, 2);+ } finally {+ globalThis.chrome = previousChrome; globalThis.fetch = previousFetch; console.warn = previousWarn;+ if (previousChrome === undefined) delete globalThis.chrome;+ }+ });test(`${build}: Compass credentials never fall back to saved decision-provider keys`, async () => {const saved = { systemOneEnabled: false, decisionApiKey: 'saved-openrouter-key',typesafeApiKey: 'saved-typesafe-key', decisionLocalApiKey: 'saved-local-key' };