Skip to content

Qwen3.8-Flash-Next on any consumer hardware: one-click install for Windows / Linux. Strata inference engine, OpenAI/Anthropic API on localhost, optional image input.

C++

Manual mode asks once per chat before the first web search or page; Settings, Tools switch to skip the question (off by default)

Niko122144a56865f5dd
diff --git a/apps/host/server/agent/README.md b/apps/host/server/agent/README.md
index c19972921..58dd4a801 100644
--- a/apps/host/server/agent/README.md
+++ b/apps/host/server/agent/README.md
@@ -57,6 +57,7 @@ The chat's Mode menu is real Harness behaviour. Each turn the page sends the cha
- Manual relies on the gate, so a Manual turn does not start unless the bridge has confirmed the gate is loaded (`/strata-gate` command): without it Manual would be an open sandbox that nobody asks about.
- The gate listens to `tools/pre-execute` (the seam the Harness's own Auto-review layer uses) and returns an `ask` decision; the Harness's approval service then asks, runs the tool only after `allowed-once`, and records the answer. Read-only tools and a short allowlist of look-only shell commands (Get-ChildItem, git status, ...) run unasked; MCP and unknown tools ask.
+- Web search and web pages (`web_search`, `web_fetch`) ask once per chat in Manual, not once per call. The gate asks through the approval service itself (`webDecision`: "The assistant wants to search the web for: ... Search words go to <service>." / "... open the web page ..."), remembers a yes for the chat (a helper agent shares its chat's answer, and two searches started together share one card), and on a no gives the model `WEB_REFUSAL` ("The person did not allow web access ... Go on without it and say so."). Plan and Bypass are unchanged. Settings -> Tools has a switch, "Let the assistant search the web without asking" (off by default, `webWithoutAsking` in `tools-settings.mjs`, passed to the gate as `config.web.skipAsk`), that skips the question in Manual. A scheduled task has nobody at the card, so its web call is answered no unless that switch is on. Tests: `tests/web-ask.test.mjs`.
- The mode is read once per turn; an unknown or missing value is Manual.
## Tools
diff --git a/apps/host/server/agent/plugins/strata-gate.mjs b/apps/host/server/agent/plugins/strata-gate.mjs
index 1b421c7e9..d25d76c05 100644
--- a/apps/host/server/agent/plugins/strata-gate.mjs
+++ b/apps/host/server/agent/plugins/strata-gate.mjs
@@ -41,8 +41,7 @@ export const READ_ONLY_TOOLS = new Set([
'read', 'glob', 'grep', 'read_image', 'working_directory', 'todo_write', 'skill', 'present', 'lsp',
'get_goal', 'create_goal', 'update_goal', 'list_agents', 'list_subagent_models', 'job_list', 'job_output',
'ask_user_question', 'exit_plan_mode',
- // Reading the internet is part of what the app promises; changing nothing here.
- 'web_fetch', 'web_search',
+ // (web_search and web_fetch are not here: the first use in a chat asks, see webDecision.)
// Delegation: the child it starts is governed by this same gate.
'subagent', 'subagent_fork', 'send_message', 'interrupt_agent', 'workflow',
]);
@@ -103,14 +102,37 @@ const clip = (value, max) => {
return text.length > max ? `${text.slice(0, max - 1)}…` : text;
};
+/** The tools that reach the internet. In Manual the first one in a chat asks once; the answer holds for the rest of that chat. */
+export const WEB_TOOLS = new Set(['web_search', 'web_fetch']);
+/** What the model reads when the person says no. Plain words, and it tells the model what to do next. */
+export const WEB_REFUSAL = 'The person did not allow web access, so nothing was searched or opened. Go on without it and say so.';
+
+/**
+ * The question for a web call, in plain words: what is about to leave this computer and where it goes.
+ * @param {{name:string, arguments:any}} exec
+ * @param {{provider?: string}} [options] provider is the search service's name as the person knows it
+ */
+export function webDecision(exec, options = {}) {
+ const tool = String(exec.name ?? '');
+ const args = exec.arguments && typeof exec.arguments === 'object' ? exec.arguments : {};
+ if (tool === 'web_search') {
+ const queries = Array.isArray(args.queries) ? args.queries : [args.query ?? args.q];
+ const words = clip(queries.filter(q => typeof q === 'string' && q.trim()).join('; '), 160);
+ return { kind: 'ask', web: true, reason: `The assistant wants to search the web for: ${words}. Search words go to ${options.provider || 'the search service'}.` };
+ }
+ return { kind: 'ask', web: true, reason: `The assistant wants to open the web page ${clip(args.url, 200)}. The page's site sees the request.` };
+}
+
/**
* The decision for one call in Manual mode, or null when it needs no question.
* @param {{name:string, arguments:any}} exec
- * @returns {{kind:'ask', reason:string}|null}
+ * @param {{provider?: string}} [options]
+ * @returns {{kind:'ask', reason:string, web?:true}|null}
*/
-export function manualDecision(exec) {
+export function manualDecision(exec, options = {}) {
const tool = String(exec.name ?? '');
const args = exec.arguments && typeof exec.arguments === 'object' ? exec.arguments : {};
+ if (WEB_TOOLS.has(tool)) return webDecision(exec, options);
if (READ_ONLY_TOOLS.has(tool)) return null;
if (SHELL_TOOLS.has(tool)) {
if (isReadOnlyShell(args.command)) return null;
@@ -150,7 +172,40 @@ export function planDecision(exec) {
return { kind: 'deny', reason: 'Plan mode only looks and changes nothing, so it cannot use this tool. Switch to Manual or Bypass to use it.' };
}
-export function apply(ctx) {
+/**
+ * @param {object} ctx
+ * @param {{web?: {provider?: string, skipAsk?: boolean}}} [config] `web.provider`: the search service's name for the question;
+ * `web.skipAsk`: the person's switch in Settings -> Tools, "search the web without asking" (off unless they turned it on)
+ */
+export function apply(ctx, config = {}) {
+ const web = config.web ?? {};
+ /** Chats (their first session) where the person said yes to the web. One yes holds for the rest of the chat. */
+ const webAllowed = new Set();
+ /** A question already on the screen for a chat, so two searches started together share one card. */
+ const webAsking = new Map();
+ const chatOf = (session, depth = 0) => {
+ const parentId = session.header?.parentSession;
+ if (session.header?.origin === 'subagent' && parentId && depth < 6) {
+ const parent = ctx.sessions.get(parentId);
+ if (parent) return chatOf(parent, depth + 1);
+ }
+ return session.id;
+ };
+ async function askWeb(exec, gate, agent) {
+ const chat = chatOf(agent.session);
+ let question = webAsking.get(chat);
+ if (!question) {
+ question = ctx.approval.request({ agent, toolName: exec.name, callId: exec.callId, reason: gate.reason, displayReason: { en: gate.reason }, signal: exec.signal });
+ webAsking.set(chat, question);
+ const forget = () => { if (webAsking.get(chat) === question) webAsking.delete(chat); };
+ question.then(forget, forget);
+ }
+ const outcome = await question;
+ if (outcome === 'allowed-once') { webAllowed.add(chat); return null; }
+ if (outcome === 'cancelled') return { kind: 'cancel' };
+ return { kind: 'deny', reason: WEB_REFUSAL };
+ }
+
/** The preset a session is really working under: a child follows the chat that started it. */
const effectivePreset = (session, depth = 0) => {
const parentId = session.header?.parentSession;
@@ -173,8 +228,17 @@ export function apply(ctx) {
}
if (preset === PLAN_PRESET) return planDecision(exec) ?? next();
if (preset !== MANUAL_PRESET) return next();
- const gate = manualDecision(exec);
+ const gate = manualDecision(exec, { provider: web.provider });
if (!gate) return next();
+ if (gate.web) {
+ // The person's switch, or a yes already given in this chat: no question.
+ if (web.skipAsk === true || webAllowed.has(chatOf(agent.session))) return next();
+ // A helper's own approval policy is `never`; it must be `ask` for the question to reach the person.
+ if (agent.session.header?.origin === 'subagent' && ctx.approval.overrideOf(agent.session) !== 'ask') {
+ agent.session.append('approval/policy', { policy: 'ask' });
+ }
+ return (await askWeb(exec, gate, agent)) ?? next();
+ }
// A child's approval policy is pinned to `never` by the Harness; asking is how its request reaches the person.
if (agent.session.header?.origin === 'subagent' && ctx.approval.overrideOf(agent.session) !== 'ask') {
agent.session.append('approval/policy', { policy: 'ask' });
diff --git a/apps/host/server/agent/profile.mjs b/apps/host/server/agent/profile.mjs
index 99d5a5cef..2637b87fa 100644
--- a/apps/host/server/agent/profile.mjs
+++ b/apps/host/server/agent/profile.mjs
@@ -60,8 +60,11 @@ export const SEARCH_PLUGIN = fileURLToPath(new URL('./plugins/strata-search.mjs'
/** The app's own tool server for the tools a person writes (instructions, commands). */
export const CUSTOM_TOOLS_SCRIPT = fileURLToPath(new URL('./custom-tools-mcp.mjs', import.meta.url));
+/** The search service as the person knows it, for the question that comes before the first web search in a chat. */
+const SEARCH_NAMES = Object.freeze({ builtin: 'DuckDuckGo, or Bing when DuckDuckGo is busy', exa: 'Exa', perplexity: 'Perplexity', deepseek: 'DeepSeek' });
+
/** What Settings -> Tools says when nothing was chosen. */
-const NO_TOOLS_SETTINGS = Object.freeze({ off: new Set(), search: { provider: 'builtin', key: '' }, browserEnabled: false, browserPath: null, browserCli: null, servers: {}, hasInstructionTools: false, hasCommandTools: false, toolFile: null });
+const NO_TOOLS_SETTINGS = Object.freeze({ off: new Set(), search: { provider: 'builtin', key: '' }, webWithoutAsking: false, browserEnabled: false, browserPath: null, browserCli: null, servers: {}, hasInstructionTools: false, hasCommandTools: false, toolFile: null });
/**
* The tool servers (MCP) set up for the model in Settings, as Harness client rows. Their tools appear to the agent as
@@ -281,7 +284,8 @@ export function buildProfile({ local = [], connections = [], gate = true, tools
{ id: 'permission', config: { presets: Object.fromEntries(Object.values(MODE_PRESETS).map(({ key, sandbox, approval, name, description }) => [key, { sandbox, approval, name, description }])), defaultPreset: MODE_PRESETS[DEFAULT_MODE].key } },
{ id: 'subagent', config: { maxActiveSubagents: slots > 0 ? Math.max(slots, MIN_LOCAL_HELPERS) : DEFAULT_API_HELPERS } },
// Manual asks before a change runs, so the person sees one Approve/Deny card and nothing has happened yet.
- ...(gate ? [{ insert: [{ id: 'strata-gate', name: GATE_PLUGIN }] }] : []),
+ // Its web question names the search service the person chose (a keyed one only when its key is saved), and the person's switch skips the question.
+ ...(gate ? [{ insert: [{ id: 'strata-gate', name: GATE_PLUGIN, config: { web: { provider: SEARCH_NAMES[keyed ?? 'builtin'], skipAsk: tools.webWithoutAsking === true } } }] }] : []),
// Helper agents on a model the person names: every model the app can reach is allowed, and the plugin makes the choice forgiving (plugins/strata-models.mjs).
...(subagentRoutes.length ? [{ id: 'subagent-model-selection-settings', config: { enabled: true, allowedModels: subagentRoutes.map(r => ({ provider: r.provider, model: r.model })) } }] : []),
...(subagentRoutes.length ? [{ insert: [{ id: 'strata-models', name: MODELS_PLUGIN, config: { routes: subagentRoutes } }] }] : []),
diff --git a/apps/host/server/agent/tools-catalog.mjs b/apps/host/server/agent/tools-catalog.mjs
index 3c97ae149..af2bab650 100644
--- a/apps/host/server/agent/tools-catalog.mjs
+++ b/apps/host/server/agent/tools-catalog.mjs
@@ -12,8 +12,8 @@ export const TOOL_GROUPS = [
{ id: 'files', area: 'computer', name: 'Read and change files', about: 'Lets the assistant read, create and edit files in your chat folder.', asks: true, plugins: ['tool-fs'] },
{ id: 'find', area: 'computer', name: 'Find files and text', about: 'Lets the assistant look for files by name and search inside them. It only reads.', asks: false, plugins: ['tool-fs-search'] },
{ id: 'jobs', area: 'computer', name: 'Long-running jobs', about: 'Lets the assistant start a slow command in the background and check on it later.', asks: true, plugins: ['tool-jobs'] },
- { id: 'fetch', area: 'web', name: 'Open web pages', about: 'Lets the assistant read a web page you point it to.', asks: false, web: 'fetch' },
- { id: 'search', area: 'web', name: 'Search the web', about: 'Lets the assistant search the web when it needs fresh information.', asks: false, web: 'search' },
+ { id: 'fetch', area: 'web', name: 'Open web pages', about: 'Lets the assistant read a web page you point it to.', asks: true, web: 'fetch' },
+ { id: 'search', area: 'web', name: 'Search the web', about: 'Lets the assistant search the web when it needs fresh information.', asks: true, web: 'search' },
{ id: 'helpers', area: 'together', name: 'Helper assistants', about: 'Lets the assistant start helpers that work on parts of a task at the same time.', asks: false, plugins: ['delegation'] },
{ id: 'goals', area: 'together', name: 'Goals', about: 'Lets you give a goal with /goal. The assistant keeps working until it is done.', asks: false, plugins: ['command-goal', 'tool-goal'] },
{ id: 'todo', area: 'together', name: 'To-do list', about: 'Lets the assistant keep a checklist while it works on a big task.', asks: false, plugins: ['tool-todo'] },
diff --git a/apps/host/server/agent/tools-settings.mjs b/apps/host/server/agent/tools-settings.mjs
index 37648f94e..4a919e307 100644
--- a/apps/host/server/agent/tools-settings.mjs
+++ b/apps/host/server/agent/tools-settings.mjs
@@ -32,6 +32,8 @@ function normalize(raw) {
off: [...new Set((Array.isArray(r.off) ? r.off : []).filter(id => GROUP_IDS.includes(id)))],
search: { provider: SEARCH_PROVIDERS.includes(search.provider) ? search.provider : 'builtin', key: typeof search.key === 'string' ? search.key : '' },
browser: { enabled: r.browser?.enabled === true },
+ // Manual mode asks once per chat before the first web search or page. This switch (off unless the person turned it on) skips that question.
+ webWithoutAsking: r.webWithoutAsking === true,
custom: (Array.isArray(r.custom) ? r.custom : []).filter(t => t && NAME.test(t.name ?? '') && KINDS.includes(t.kind)).slice(0, MAX_CUSTOM).map(t => ({
id: String(t.id), name: String(t.name), about: clean(t.about, 300), kind: t.kind, enabled: t.enabled !== false,
instructions: clean(t.instructions, 20000), command: clean(t.command, 2000), address: clean(t.address, 2000),
@@ -106,6 +108,7 @@ export function createAgentTools({ read, write, dataDir, browser = () => ({ foun
return {
groups: TOOL_GROUPS.map(g => ({ id: g.id, name: g.name, about: g.about, area: g.area, asks: g.asks, enabled: !s.off.includes(g.id) })),
search: { provider: s.search.provider, keySet: !!s.search.key },
+ webWithoutAsking: s.webWithoutAsking,
// `found` means the browser tool can run: a browser on this computer AND the tool server in the agent component.
browser: { enabled: s.browser.enabled, found: !!(probe.found && probe.cli), name: probe.name ?? null, ...(probe.found && !probe.cli ? { missing: 'component' } : {}) },
custom: s.custom.map(t => ({
@@ -131,6 +134,7 @@ export function createAgentTools({ read, write, dataDir, browser = () => ({ foun
return {
off: new Set(s.off),
search: s.search,
+ webWithoutAsking: s.webWithoutAsking,
browserEnabled: s.browser.enabled && !!(browser().found && browser().cli),
browserPath: browser().path ?? null,
browserCli: browser().cli ?? null,
@@ -160,6 +164,7 @@ export function createAgentTools({ read, write, dataDir, browser = () => ({ foun
s.search = { ...s.search, key };
}
}
+ if (typeof change?.webWithoutAsking === 'boolean') s.webWithoutAsking = change.webWithoutAsking;
if (change?.browser && typeof change.browser.enabled === 'boolean') s.browser = { enabled: change.browser.enabled };
if (change?.custom) {
for (const [id, on] of Object.entries(change.custom)) {
diff --git a/apps/host/src/components/SettingsTools.tsx b/apps/host/src/components/SettingsTools.tsx
index b6ace950d..7a85c41df 100644
--- a/apps/host/src/components/SettingsTools.tsx
+++ b/apps/host/src/components/SettingsTools.tsx
@@ -35,6 +35,8 @@ export interface CustomTool {
export interface ToolsState {
groups: ToolGroup[];
search: { provider: 'builtin' | 'exa' | 'perplexity' | 'deepseek'; keySet: boolean };
+ /** Skip the once-per-chat question before the first web search or page in Manual mode. Off unless the person turned it on. */
+ webWithoutAsking: boolean;
browser: { enabled: boolean; found: boolean; name: string | null; missing?: 'component' };
custom: CustomTool[];
}
@@ -139,6 +141,9 @@ export function SettingsTools({ preview }: { preview?: ToolsState }) {
<Btn size="sm" disabled={busy || !key.trim()} onClick={() => { void save({ search: { provider: state.search.provider, key: key.trim() } }); setKey(''); pushToast('success', tr('Key saved')); }}>{tr('Save key')}</Btn>
</div>
</Field> : null}
+ <Field label={tr('Let the assistant search the web without asking')} hint={tr('In Manual mode the assistant asks once per chat before it searches the web or opens a web page. Turn this on to skip that question.')}>
+ <button className="st-toggle" role="switch" aria-checked={state.webWithoutAsking} aria-label={tr('Let the assistant search the web without asking')} disabled={busy} onClick={() => void save({ webWithoutAsking: !state.webWithoutAsking })} />
+ </Field>
</div>
</section>
diff --git a/apps/host/src/lib/i18n.ts b/apps/host/src/lib/i18n.ts
index 53c9196f4..320d22135 100644
--- a/apps/host/src/lib/i18n.ts
+++ b/apps/host/src/lib/i18n.ts
@@ -36,7 +36,7 @@ const patterns=Object.entries(english).filter(([,value])=>/\{\d+\}/.test(value))
expression+=escape(value.slice(at));
return{id,slots,pattern:new RegExp('^'+expression+'$'),specificity:value.replace(/\{\d+\}/g,'').length};
}).sort((a,b)=>b.specificity-a.specificity);
-const localizedTemplateSlots:Record<string,number[]>={s2473:[1,2],s0825:[0,1],s2455:[0],s2456:[0]};
+const localizedTemplateSlots:Record<string,number[]>={s2473:[1,2],s0825:[0,1],s2455:[0],s2456:[0],s7400:[1]};
/** Translate interface copy only. Non-string React children pass through unchanged. */
export function tr<T>(value:T,values?:readonly unknown[]):T{
diff --git a/apps/host/src/locales/de.json b/apps/host/src/locales/de.json
index e0c6df114..19fbecc8d 100644
--- a/apps/host/src/locales/de.json
+++ b/apps/host/src/locales/de.json
@@ -3279,5 +3279,10 @@
"s7338": "Es ist kein Modell geladen. Lade zuerst eines unter Modelle.",
"s7339": "Der Assistent startet…",
"s7340": "Der Assistent konnte nicht starten. Versuche es gleich noch einmal.",
- "s7341": "Arbeitet am Ziel…"
+ "s7341": "Arbeitet am Ziel…",
+ "s7400": "Der Assistent möchte im Web suchen nach: {0}. Die Suchbegriffe gehen an {1}.",
+ "s7401": "Der Assistent möchte die Webseite {0} öffnen. Die Seite sieht die Anfrage.",
+ "s7402": "Den Assistenten ohne Nachfrage im Web suchen lassen",
+ "s7403": "Im Modus „Manuell“ fragt der Assistent pro Chat einmal nach, bevor er im Web sucht oder eine Webseite öffnet. Schalte das ein, um die Nachfrage zu überspringen.",
+ "s7404": "DuckDuckGo oder Bing, wenn DuckDuckGo ausgelastet ist"
}
diff --git a/apps/host/src/locales/en.json b/apps/host/src/locales/en.json
index 34b391fd1..14a8850b9 100644
--- a/apps/host/src/locales/en.json
+++ b/apps/host/src/locales/en.json
@@ -3279,5 +3279,10 @@
"s7338": "No model is loaded. Load one in Models first.",
"s7339": "Starting the assistant…",
"s7340": "The assistant could not start. Try again in a moment.",
- "s7341": "Working on the goal…"
+ "s7341": "Working on the goal…",
+ "s7400": "The assistant wants to search the web for: {0}. Search words go to {1}.",
+ "s7401": "The assistant wants to open the web page {0}. The page's site sees the request.",
+ "s7402": "Let the assistant search the web without asking",
+ "s7403": "In Manual mode the assistant asks once per chat before it searches the web or opens a web page. Turn this on to skip that question.",
+ "s7404": "DuckDuckGo, or Bing when DuckDuckGo is busy"
}
diff --git a/apps/host/src/locales/es.json b/apps/host/src/locales/es.json
index 44929bb37..9ed23cc49 100644
--- a/apps/host/src/locales/es.json
+++ b/apps/host/src/locales/es.json
@@ -3279,5 +3279,10 @@
"s7338": "No hay ningún modelo cargado. Carga uno primero en Modelos.",
"s7339": "Iniciando el asistente…",
"s7340": "El asistente no pudo iniciarse. Inténtalo de nuevo en un momento.",
- "s7341": "Trabajando en el objetivo…"
+ "s7341": "Trabajando en el objetivo…",
+ "s7400": "El asistente quiere buscar en la web: {0}. Las palabras de búsqueda se envían a {1}.",
+ "s7401": "El asistente quiere abrir la página web {0}. El sitio de la página ve la solicitud.",
+ "s7402": "Dejar que el asistente busque en la web sin preguntar",
+ "s7403": "En el modo Manual, el asistente pregunta una vez por chat antes de buscar en la web o abrir una página web. Actívalo para omitir esa pregunta.",
+ "s7404": "DuckDuckGo, o Bing cuando DuckDuckGo está ocupado"
}
diff --git a/apps/host/src/locales/ja.json b/apps/host/src/locales/ja.json
index 2d84814ef..39e790f10 100644
--- a/apps/host/src/locales/ja.json
+++ b/apps/host/src/locales/ja.json
@@ -3279,5 +3279,10 @@
"s7338": "モデルが読み込まれていません。先に「モデル」で読み込んでください。",
"s7339": "アシスタントを起動しています…",
"s7340": "アシスタントを起動できませんでした。しばらくしてからもう一度お試しください。",
- "s7341": "目標に取り組んでいます…"
+ "s7341": "目標に取り組んでいます…",
+ "s7400": "アシスタントが次の内容をウェブ検索しようとしています: {0}。検索語は {1} に送られます。",
+ "s7401": "アシスタントがウェブページ {0} を開こうとしています。そのサイトにリクエストが見えます。",
+ "s7402": "確認せずにアシスタントがウェブを検索できるようにする",
+ "s7403": "手動モードでは、アシスタントはウェブ検索やウェブページを開く前に、チャットごとに1回確認します。オンにすると確認を省略します。",
+ "s7404": "DuckDuckGo(混雑時は Bing)"
}
diff --git a/apps/host/src/locales/ko.json b/apps/host/src/locales/ko.json
index 2c431c7d9..a5b76b49d 100644
--- a/apps/host/src/locales/ko.json
+++ b/apps/host/src/locales/ko.json
@@ -3279,5 +3279,10 @@
"s7338": "불러온 모델이 없습니다. 먼저 모델 화면에서 하나를 불러오세요.",
"s7339": "어시스턴트를 시작하는 중…",
"s7340": "어시스턴트를 시작하지 못했습니다. 잠시 후 다시 시도하세요.",
- "s7341": "목표를 진행하는 중…"
+ "s7341": "목표를 진행하는 중…",
+ "s7400": "어시스턴트가 웹에서 다음을 검색하려고 합니다: {0}. 검색어는 {1}(으)로 전송됩니다.",
+ "s7401": "어시스턴트가 웹 페이지 {0}을(를) 열려고 합니다. 해당 사이트에 요청이 표시됩니다.",
+ "s7402": "묻지 않고 어시스턴트가 웹을 검색하도록 허용",
+ "s7403": "수동 모드에서는 어시스턴트가 웹을 검색하거나 웹 페이지를 열기 전에 채팅당 한 번 묻습니다. 켜면 이 질문을 건너뜁니다.",
+ "s7404": "DuckDuckGo, DuckDuckGo가 바쁠 때는 Bing"
}
diff --git a/apps/host/src/locales/pt.json b/apps/host/src/locales/pt.json
index 34f1c7d13..20695c93d 100644
--- a/apps/host/src/locales/pt.json
+++ b/apps/host/src/locales/pt.json
@@ -3279,5 +3279,10 @@
"s7338": "Nenhum modelo está carregado. Carregue um em Modelos primeiro.",
"s7339": "Iniciando o assistente…",
"s7340": "Não foi possível iniciar o assistente. Tente novamente em instantes.",
- "s7341": "Trabalhando no objetivo…"
+ "s7341": "Trabalhando no objetivo…",
+ "s7400": "O assistente quer pesquisar na web: {0}. As palavras da pesquisa vão para {1}.",
+ "s7401": "O assistente quer abrir a página web {0}. O site da página vê a solicitação.",
+ "s7402": "Deixar o assistente pesquisar na web sem perguntar",
+ "s7403": "No modo Manual, o assistente pergunta uma vez por chat antes de pesquisar na web ou abrir uma página web. Ative para pular essa pergunta.",
+ "s7404": "DuckDuckGo, ou Bing quando o DuckDuckGo está ocupado"
}
diff --git a/apps/host/src/locales/ru.json b/apps/host/src/locales/ru.json
index 014ad75d4..52e2b2aa5 100644
--- a/apps/host/src/locales/ru.json
+++ b/apps/host/src/locales/ru.json
@@ -3279,5 +3279,10 @@
"s7338": "Модель не загружена. Сначала загрузите её в разделе «Модели».",
"s7339": "Запуск ассистента…",
"s7340": "Не удалось запустить ассистента. Повторите попытку через минуту.",
- "s7341": "Работа над целью…"
+ "s7341": "Работа над целью…",
+ "s7400": "Ассистент хочет найти в интернете: {0}. Поисковые слова отправляются в {1}.",
+ "s7401": "Ассистент хочет открыть веб-страницу {0}. Сайт страницы увидит этот запрос.",
+ "s7402": "Разрешить ассистенту искать в интернете без вопросов",
+ "s7403": "В ручном режиме ассистент один раз за чат спрашивает, прежде чем искать в интернете или открывать веб-страницу. Включите, чтобы пропускать этот вопрос.",
+ "s7404": "DuckDuckGo или Bing, когда DuckDuckGo занят"
}
diff --git a/apps/host/src/locales/zh.json b/apps/host/src/locales/zh.json
index 245ceed6a..801e0a716 100644
--- a/apps/host/src/locales/zh.json
+++ b/apps/host/src/locales/zh.json
@@ -3279,5 +3279,10 @@
"s7338": "尚未加载模型。请先在“模型”中加载一个。",
"s7339": "正在启动助手…",
"s7340": "助手未能启动。请稍后再试。",
- "s7341": "正在处理目标…"
+ "s7341": "正在处理目标…",
+ "s7400": "助手想在网上搜索:{0}。搜索词会发送给 {1}。",
+ "s7401": "助手想打开网页 {0}。该网站会看到这次请求。",
+ "s7402": "允许助手无需询问即可搜索网页",
+ "s7403": "在手动模式下,助手每个聊天会先询问一次,再搜索网页或打开网页。开启后将跳过这个询问。",
+ "s7404": "DuckDuckGo;DuckDuckGo 繁忙时使用 Bing"
}
diff --git a/apps/host/tests/agent-tools.test.mjs b/apps/host/tests/agent-tools.test.mjs
index b2065e10f..d56f3d548 100644
--- a/apps/host/tests/agent-tools.test.mjs
+++ b/apps/host/tests/agent-tools.test.mjs
@@ -57,7 +57,7 @@ test('the preset: our list is the Harness standard list minus exactly what the a
test('the profile loads the gate by path, sizes helper agents to the engine slots and keeps no secret', () => {
const p = buildProfile({ local: [{ id: 'a', baseUrl: 'http://127.0.0.1:1/v1', modelId: 'm', context: 32768, slots: 2, key: 'sekret-key-123' }] });
const entries = JSON.parse(p.patch.split('\n').slice(1).join('\n'));
- assert.deepEqual(entries.find(e => e.insert)?.insert, [{ id: 'strata-gate', name: GATE_PLUGIN }]);
+ assert.deepEqual(entries.find(e => e.insert)?.insert, [{ id: 'strata-gate', name: GATE_PLUGIN, config: { web: { provider: 'DuckDuckGo, or Bing when DuckDuckGo is busy', skipAsk: false } } }]);
assert.ok(existsSync(GATE_PLUGIN));
assert.equal(entries.find(e => e.id === 'subagent').config.maxActiveSubagents, 4, 'at least the 4 helpers; more only with more slots');
assert.equal(entries.find(e => e.id === 'preset-standard').config.plugins.some(x => x.id === 'tool-schedule'), false);
diff --git a/apps/host/tests/agent-turn-guard.test.mjs b/apps/host/tests/agent-turn-guard.test.mjs
index 27bab7c9a..4f33f171d 100644
--- a/apps/host/tests/agent-turn-guard.test.mjs
+++ b/apps/host/tests/agent-turn-guard.test.mjs
@@ -98,6 +98,8 @@ async function rig(t, options = {}) {
const ws = join(dir, 'ws'); mkdirSync(ws, { recursive: true });
const logs = [];
const bridge = createAgentBridge({ dataDir: dir, localInstances: () => [{ id: 'i', label: 'S', baseUrl: worker.url, modelId: 'scripted-model', context: options.context ?? 32768, slots: 2 }], connections: () => [],
+ // these chats are in Manual and search without a person at the card: the Settings switch that skips the web question is on
+ tools: () => ({ off: new Set(), search: { provider: 'builtin', key: '' }, servers: {}, webWithoutAsking: true }),
env: process.env, startTimeoutMs: 90_000, searchMock: 'limited', log: l => logs.push(l) });
t.after(async () => { await bridge.close(); await worker.close(); try { rmSync(dir, { recursive: true, force: true, maxRetries: 3 }); } catch { /* best effort */ } });
return { worker, bridge, ws, logs, base: (chatId, onFrame) => ({ chatId, workspacePath: ws, mode: 'manual', onFrame }) };
diff --git a/apps/host/tests/web-ask.test.mjs b/apps/host/tests/web-ask.test.mjs
new file mode 100644
index 000000000..31cb1c2fe
--- /dev/null
+++ b/apps/host/tests/web-ask.test.mjs
@@ -0,0 +1,269 @@
+/**
+ * Manual mode asks once per chat before the first web search or web page. Approve holds for the rest of that chat, Deny gives the model a
+ * readable refusal, Plan and Bypass are unchanged, and a switch in Settings -> Tools (off by default) skips the question.
+ *
+ * The gate is plain ESM, so most of this drives its plugin with a pretend Harness context. The bridge-level tests at the end use the real
+ * Harness with a scripted model and skip without STRATA_HARNESS_DIR.
+ */
+import test from 'node:test';
+import assert from 'node:assert/strict';
+import { mkdtempSync, mkdirSync, rmSync } from 'node:fs';
+import { tmpdir } from 'node:os';
+import { join } from 'node:path';
+import { build } from 'esbuild';
+import { apply, manualDecision, planDecision, READ_ONLY_TOOLS, MANUAL_PRESET, PLAN_PRESET, WEB_REFUSAL } from '../server/agent/plugins/strata-gate.mjs';
+import { buildProfile } from '../server/agent/profile.mjs';
+import { createAgentTools } from '../server/agent/tools-settings.mjs';
+import { startScriptedWorker } from './helpers/scripted-worker.mjs';
+import { createAgentBridge } from '../server/agent/agent-bridge.mjs';
+import { createAgentTaskRunner } from '../server/agent/task-run.mjs';
+import { resolveHarness } from '../server/agent/harness-runtime.mjs';
+
+const HARNESS = process.env.STRATA_HARNESS_DIR;
+const skip = !HARNESS || !resolveHarness({ env: process.env }).ok ? 'STRATA_HARNESS_DIR is not set to a built Harness' : false;
+
+const SEARCH = { name: 'web_search', arguments: { queries: ['heat pump prices'] } };
+const FETCH = { name: 'web_fetch', arguments: { url: 'https://example.com/a' } };
+
+// ---------------------------------------------------------------------------------------------- the question
+
+test('the question says what leaves this computer and where it goes', () => {
+ const ask = manualDecision(SEARCH, { provider: 'DuckDuckGo' });
+ assert.equal(ask.kind, 'ask');
+ assert.equal(ask.reason, 'The assistant wants to search the web for: heat pump prices. Search words go to DuckDuckGo.');
+ assert.equal(manualDecision({ name: 'web_search', arguments: { queries: ['a', 'b'] } }, { provider: 'Exa' }).reason, 'The assistant wants to search the web for: a; b. Search words go to Exa.');
+ assert.equal(manualDecision(FETCH).reason, "The assistant wants to open the web page https://example.com/a. The page's site sees the request.");
+ assert.ok(!READ_ONLY_TOOLS.has('web_search') && !READ_ONLY_TOOLS.has('web_fetch'), 'the web is no longer "look only"');
+ // a very long query is cut, not pasted whole into the card
+ assert.ok(manualDecision({ name: 'web_search', arguments: { queries: ['x'.repeat(900)] } }).reason.length < 300);
+});
+
+test('Plan keeps its rules: the web needs no question there', () => {
+ assert.equal(planDecision(SEARCH), null);
+ assert.equal(planDecision(FETCH), null);
+});
+
+// ---------------------------------------------------------------------------------------------- the gate
+
+/** A pretend Harness: enough of the context for the gate. `answers` is what the person says to each question, in order. */
+function rig({ preset = MANUAL_PRESET, answers = ['allowed-once'], config = {} } = {}) {
+ const handlers = [];
+ const sessions = new Map();
+ const asked = [];
+ let policy = new Map();
+ const ctx = {
+ sessions: { get: id => sessions.get(id) },
+ permissionPresets: { current: session => session.preset ?? preset },
+ approval: {
+ overrideOf: session => policy.get(session.id) ?? null,
+ request: async req => { asked.push(req.reason); await new Promise(r => setTimeout(r, 5)); return answers[Math.min(asked.length - 1, answers.length - 1)]; },
+ },
+ on: (event, handler) => { if (event === 'tools/pre-execute') handlers.push(handler); },
+ inject: () => {},
+ };
+ apply(ctx, config);
+ const session = (id, extra = {}) => { const s = { id, header: {}, append: (type, data) => { if (type === 'approval/policy') policy.set(id, data.policy); }, ...extra }; sessions.set(id, s); return s; };
+ const call = async (sessionObj, exec) => {
+ let n = 0;
+ const result = await handlers[0]({ ...exec, callId: `c${++n}${Math.random()}`, agent: { session: sessionObj } }, async () => ({ kind: 'allow' }));
+ return result;
+ };
+ return { ctx, session, call, asked };
+}
+
+test('Manual: the first search asks, Approve lets the rest of that chat search and open pages without asking again', async () => {
+ const r = rig({ config: { web: { provider: 'DuckDuckGo' } } });
+ const chat = r.session('chat-1');
+ const first = await r.call(chat, SEARCH);
+ assert.deepEqual(r.asked, ['The assistant wants to search the web for: heat pump prices. Search words go to DuckDuckGo.']);
+ assert.equal(first.kind, 'allow', 'approved, so the search runs');
+ assert.equal((await r.call(chat, { name: 'web_search', arguments: { queries: ['another'] } })).kind, 'allow');
+ assert.equal((await r.call(chat, FETCH)).kind, 'allow');
+ assert.equal(r.asked.length, 1, 'one question for the chat');
+ // another chat asks for itself
+ await r.call(r.session('chat-2'), SEARCH);
+ assert.equal(r.asked.length, 2);
+});
+
+test('Manual: Deny gives the model a readable refusal, and the next try asks again', async () => {
+ const r = rig({ answers: ['rejected', 'allowed-once'] });
+ const chat = r.session('chat-1');
+ const refused = await r.call(chat, SEARCH);
+ assert.equal(refused.kind, 'deny');
+ assert.equal(refused.reason, WEB_REFUSAL);
+ assert.match(refused.reason, /did not allow web access/);
+ assert.match(refused.reason, /Go on without it and say so/);
+ assert.doesNotMatch(refused.reason, /tool "|web_search/, 'no tool names in what the model reads');
+ assert.equal((await r.call(chat, SEARCH)).kind, 'allow', 'asked again, and this time yes');
+ assert.equal(r.asked.length, 2);
+ // an unavailable approval channel is a refusal too, not a silent allow
+ const none = rig({ answers: ['unavailable'] });
+ assert.equal((await none.call(none.session('c'), SEARCH)).reason, WEB_REFUSAL);
+});
+
+test('two searches started together share one question', async () => {
+ const r = rig();
+ const chat = r.session('chat-1');
+ const [a, b] = await Promise.all([r.call(chat, SEARCH), r.call(chat, { name: 'web_search', arguments: { queries: ['second'] } })]);
+ assert.equal(r.asked.length, 1);
+ assert.equal(a.kind, 'allow'); assert.equal(b.kind, 'allow');
+});
+
+test('a helper agent works under the chat that started it: one yes covers both, and its question can reach the person', async () => {
+ const r = rig();
+ const chat = r.session('chat-1');
+ const helper = r.session('helper-1', { header: { origin: 'subagent', parentSession: 'chat-1' } });
+ assert.equal((await r.call(helper, SEARCH)).kind, 'allow');
+ assert.equal(r.ctx.approval.overrideOf(helper), 'ask', 'the helper is set to ask so the card reaches the person');
+ assert.equal((await r.call(chat, SEARCH)).kind, 'allow');
+ assert.equal(r.asked.length, 1);
+});
+
+test('Bypass never asks, Plan is unchanged, and the Settings switch skips the question in Manual', async () => {
+ const bypass = rig({ preset: 'strata-bypass' });
+ assert.equal((await bypass.call(bypass.session('c'), SEARCH)).kind, 'allow');
+ assert.equal(bypass.asked.length, 0);
+ const plan = rig({ preset: PLAN_PRESET });
+ assert.equal((await plan.call(plan.session('c'), SEARCH)).kind, 'allow');
+ assert.equal(plan.asked.length, 0);
+ const switchedOn = rig({ config: { web: { provider: 'DuckDuckGo', skipAsk: true } } });
+ assert.equal((await switchedOn.call(switchedOn.session('c'), SEARCH)).kind, 'allow');
+ assert.equal(switchedOn.asked.length, 0);
+ // other things still ask with the switch on
+ const write = await switchedOn.call(switchedOn.session('c2'), { name: 'write', arguments: { file_path: 'a.txt' } });
+ assert.equal(write.kind, 'ask');
+});
+
+// ---------------------------------------------------------------------------------------------- the setting and the profile
+
+test('Settings -> Tools: "search the web without asking" is off at first, remembered, and reaches the gate', () => {
+ const dir = mkdtempSync(join(tmpdir(), 'strata-web-ask-'));
+ try {
+ let saved = {};
+ const tools = createAgentTools({ read: () => saved, write: v => { saved = v; }, dataDir: dir });
+ assert.equal(tools.view().webWithoutAsking, false);
+ assert.equal(tools.profileView().webWithoutAsking, false);
+ assert.equal(tools.update({ webWithoutAsking: true }).webWithoutAsking, true);
+ assert.equal(saved.webWithoutAsking, true, 'saved in the settings file');
+ assert.equal(tools.profileView().webWithoutAsking, true);
+ assert.equal(tools.update({ search: { provider: 'exa' } }).webWithoutAsking, true, 'other changes keep it');
+ assert.equal(tools.update({ webWithoutAsking: false }).webWithoutAsking, false);
+ assert.equal(tools.update({ webWithoutAsking: 'yes' }).webWithoutAsking, false, 'only a real on/off counts');
+ } finally { rmSync(dir, { recursive: true, force: true }); }
+});
+
+test('the profile names the search service in the gate\'s question, and carries the switch', () => {
+ const gateOf = tools => JSON.parse(buildProfile({ local: [], tools }).patch.split('\n').slice(1).join('\n')).flatMap(e => e.insert ?? []).find(e => e.id === 'strata-gate').config.web;
+ const base = { off: new Set(), search: { provider: 'builtin', key: '' }, servers: {}, webWithoutAsking: false };
+ assert.deepEqual(gateOf(base), { provider: 'DuckDuckGo, or Bing when DuckDuckGo is busy', skipAsk: false });
+ assert.deepEqual(gateOf({ ...base, search: { provider: 'exa', key: 'k' }, webWithoutAsking: true }), { provider: 'Exa', skipAsk: true });
+ assert.equal(gateOf({ ...base, search: { provider: 'perplexity', key: '' } }).provider, 'DuckDuckGo, or Bing when DuckDuckGo is busy', 'a service without its key is not used, so it is not named');
+});
+
+// ---------------------------------------------------------------------------------------------- the words, in every language
+
+test('the card text and the Settings switch exist in all eight languages', async () => {
+ const compiled = await build({ stdin: { contents: "export * from './src/lib/i18n';", resolveDir: process.cwd() }, bundle: true, write: false, platform: 'node', format: 'esm' });
+ const { tr, setTranslationLanguage } = await import(`data:text/javascript;base64,${Buffer.from(compiled.outputFiles[0].text).toString('base64')}`);
+ const search = manualDecision(SEARCH, { provider: 'DuckDuckGo, or Bing when DuckDuckGo is busy' }).reason;
+ const open = manualDecision(FETCH).reason;
+ const english = [search, open, 'Let the assistant search the web without asking'];
+ for (const language of ['zh', 'ja', 'de', 'es', 'ru', 'pt', 'ko']) {
+ setTranslationLanguage(language);
+ for (const text of english) assert.notEqual(tr(text), text, `${language}: ${text}`);
+ const translated = tr(search);
+ assert.ok(translated.includes('heat pump prices'), `${language}: the person's own words stay as typed`);
+ assert.ok(!translated.includes('Bing when DuckDuckGo is busy'), `${language}: the service's description is translated too`);
+ assert.ok(!/\{\d\}/.test(translated), language);
+ }
+ setTranslationLanguage('en');
+ assert.equal(tr(search), search);
+});
+
+// ---------------------------------------------------------------------------------------------- with the real Harness
+
+async function bridgeRig(t) {
+ const worker = await startScriptedWorker({ chunkDelayMs: 5 });
+ const dir = mkdtempSync(join(tmpdir(), 'strata-webask-'));
+ const ws = join(dir, 'ws'); mkdirSync(ws, { recursive: true });
+ const local = [{ id: 'i', label: 'S', baseUrl: worker.url, modelId: 'scripted-model', context: 32768, slots: 2 }];
+ const make = (tools = () => undefined) => createAgentBridge({ dataDir: dir, localInstances: () => local, connections: () => [], tools, env: process.env, startTimeoutMs: 90_000, searchMock: 'limited' });
+ const bridges = [];
+ t.after(async () => { for (const b of bridges) await b.close(); await worker.close(); try { rmSync(dir, { recursive: true, force: true, maxRetries: 3 }); } catch { /* best effort */ } });
+ const open = tools => { const b = make(tools); bridges.push(b); return b; };
+ const run = (bridge, chatId, message, { mode = 'manual', answer } = {}) => {
+ const frames = [];
+ return bridge.runTurn({
+ chatId, message, workspacePath: ws, mode, onFrame: f => {
+ frames.push(f);
+ if (answer && f.type === 'agent-tool' && f.tool.state === 'proposed') void bridge.approve({ chatId, callId: f.tool.id, decision: answer }).catch(() => {});
+ },
+ }).then(() => frames);
+ };
+ return { open, run, ws, local };
+}
+const searchCards = frames => frames.filter(f => f.type === 'agent-tool' && f.tool.name === 'web_search');
+const stateList = frames => searchCards(frames).map(f => f.tool.state);
+const CALL = 'SCRIPT:call web_search {"queries":["heat pump prices"]}';
+
+test('real Harness, Manual: the first search shows the Approve/Deny card with the plain question, and Approve lets it run', { skip }, async t => {
+ const r = await bridgeRig(t);
+ const bridge = r.open();
+ const asked = [];
+ const frames = [];
+ await bridge.runTurn({
+ chatId: 'w1', message: CALL, workspacePath: r.ws, mode: 'manual',
+ onFrame: f => {
+ frames.push(f);
+ if (f.type === 'agent-tool' && f.tool.state === 'proposed') { asked.push(f.tool.effect); void bridge.approve({ chatId: 'w1', callId: f.tool.id, decision: 'approve' }).catch(() => {}); }
+ },
+ });
+ assert.equal(asked.length, 1);
+ assert.match(asked[0], /^The assistant wants to search the web for: heat pump prices\. Search words go to DuckDuckGo, or Bing when DuckDuckGo is busy\.$/);
+ const last = searchCards(frames).at(-1).tool;
+ assert.equal(last.approved, true);
+ assert.ok(['done', 'error'].includes(last.state), `the search ran (${last.state}); the pretend web is rate limited`);
+ // second search in the same chat: no card
+ const again = await r.run(bridge, 'w1', CALL, { answer: 'deny' });
+ assert.ok(!stateList(again).includes('proposed'), 'no second question in the same chat');
+ assert.ok(!stateList(again).includes('denied'));
+});
+
+test('real Harness, Manual: Deny gives a readable refusal and the search does not run', { skip }, async t => {
+ const r = await bridgeRig(t);
+ const bridge = r.open();
+ const frames = await r.run(bridge, 'w2', CALL, { answer: 'deny' });
+ const states = stateList(frames);
+ assert.ok(states.includes('proposed'), 'it asked');
+ const card = searchCards(frames).at(-1).tool;
+ assert.equal(card.state, 'denied');
+ assert.doesNotMatch(String(card.result ?? ''), /rate limit|limited right now/, 'nothing was searched');
+ assert.equal(frames.at(-1).type, 'done');
+});
+
+test('real Harness: Bypass and Plan do not ask, and the Settings switch skips the question in Manual', { skip }, async t => {
+ const r = await bridgeRig(t);
+ const bridge = r.open();
+ for (const mode of ['bypass', 'plan']) {
+ const frames = await r.run(bridge, `w3-${mode}`, CALL, { mode, answer: 'deny' });
+ assert.ok(!stateList(frames).includes('proposed'), `${mode} did not ask`);
+ }
+ const tools = { off: new Set(), search: { provider: 'builtin', key: '' }, servers: {}, webWithoutAsking: true };
+ const switched = r.open(() => tools);
+ const frames = await r.run(switched, 'w4', CALL, { answer: 'deny' });
+ assert.ok(!stateList(frames).includes('proposed'), 'the switch is on, so no question');
+ assert.ok(searchCards(frames).length > 0);
+});
+
+test('real Harness: a scheduled task in Manual is answered "no" at once, so it cannot search unless the switch is on', { skip }, async t => {
+ const r = await bridgeRig(t);
+ const task = { id: 't1', prompt: CALL, mode: 'manual' };
+ const bridge = r.open();
+ const off = await createAgentTaskRunner({ agent: bridge, choice: () => ({ instanceId: 'i' }), workspace: r.ws })(task);
+ assert.ok(off, 'the task ran');
+ const offCards = JSON.stringify(off);
+ assert.doesNotMatch(offCards, /rate limit|limited right now/, 'no search happened');
+ const tools = { off: new Set(), search: { provider: 'builtin', key: '' }, servers: {}, webWithoutAsking: true };
+ const on = await createAgentTaskRunner({ agent: r.open(() => tools), choice: () => ({ instanceId: 'i' }), workspace: r.ws })({ ...task, id: 't2' });
+ assert.ok(on);
+});