From 04cca3bca8a2a52d73658b4fff4afe6896f4c772 Mon Sep 17 00:00:00 2001 From: Niko1221 Date: Fri, 16 Oct 2026 14:05:21 +0200 Subject: [PATCH] status sentences carry their catalog template and values and exist in 8 languages; goal tools have plain words; per-request thinking count --- apps/host/scripts/agent3-http.mjs | 4 +- apps/host/scripts/slow-proxy.mjs | 23 ++++++++ apps/host/server/agent/agent-bridge.mjs | 4 +- apps/host/server/agent/events.mjs | 15 ++++-- apps/host/server/agent/status.mjs | 70 +++++++++++++++++-------- apps/host/src/locales/de.json | 51 +++++++++++++++++- apps/host/src/locales/en.json | 51 +++++++++++++++++- apps/host/src/locales/es.json | 51 +++++++++++++++++- apps/host/src/locales/ja.json | 51 +++++++++++++++++- apps/host/src/locales/ko.json | 51 +++++++++++++++++- apps/host/src/locales/pt.json | 51 +++++++++++++++++- apps/host/src/locales/ru.json | 51 +++++++++++++++++- apps/host/src/locales/zh.json | 51 +++++++++++++++++- apps/host/tests/agent-status.test.mjs | 17 ++++++ 14 files changed, 502 insertions(+), 39 deletions(-) create mode 100644 apps/host/scripts/slow-proxy.mjs diff --git a/apps/host/scripts/agent3-http.mjs b/apps/host/scripts/agent3-http.mjs index 04163661..e8049216 100644 --- a/apps/host/scripts/agent3-http.mjs +++ b/apps/host/scripts/agent3-http.mjs @@ -26,7 +26,7 @@ const sleep = ms => new Promise(r => setTimeout(r, ms)); async function model() { const providers = await j('/api/model-providers'); - const c = providers.connections[0]; + const c = providers.connections.at(-1); if (!c) throw new Error('no API connection saved: run "connect" first'); return { connectionId: c.id, modelId: c.models[0].id }; } @@ -72,7 +72,7 @@ if (command === 'connect') { } else if (command === 'stream') { const [message, mode = 'bypass'] = rest; const chat = process.env.CHAT ?? `c-${Date.now()}`; - await stream({ sessionId: chat, message, mode, remoteModel: await model(), workspaceId: process.env.WORKSPACE_ID }); + await stream({ sessionId: chat, message, mode, remoteModel: await model(), workspaceId: process.env.WORKSPACE_ID, ...(process.env.PLAIN ? { agent: false } : {}), ...(process.env.THINK ? { thinking: process.env.THINK } : {}) }); } else if (command === 'goal') { const [objective] = rest; const chat = process.env.CHAT ?? `g-${Date.now()}`; diff --git a/apps/host/scripts/slow-proxy.mjs b/apps/host/scripts/slow-proxy.mjs new file mode 100644 index 00000000..c70707da --- /dev/null +++ b/apps/host/scripts/slow-proxy.mjs @@ -0,0 +1,23 @@ +/** + * A slow model for tests: forwards a model server and holds every streamed chunk back, so a fast engine answers like a slow computer. + * TARGET=http://127.0.0.1:18797 PORT=18900 DELAY_MS=200 node scripts/slow-proxy.mjs + * Only streamed (text/event-stream) answers are slowed; everything else passes straight through. + */ +import http from 'node:http'; +import { Transform } from 'node:stream'; + +const target = new URL(process.env.TARGET ?? 'http://127.0.0.1:18797'); +const port = Number(process.env.PORT ?? 18900); +const delay = Number(process.env.DELAY_MS ?? 200); + +http.createServer((req, res) => { + const up = http.request({ host: target.hostname, port: target.port, path: req.url, method: req.method, headers: { ...req.headers, host: target.host } }, answer => { + res.writeHead(answer.statusCode ?? 502, answer.headers); + if (String(answer.headers['content-type'] ?? '').includes('text/event-stream')) { + answer.pipe(new Transform({ transform(chunk, _enc, done) { setTimeout(() => done(null, chunk), delay); } })).pipe(res); + } else answer.pipe(res); + }); + up.on('error', e => { if (!res.headersSent) res.writeHead(502); res.end(String(e.message)); }); + req.pipe(up); + res.on('close', () => up.destroy()); +}).listen(port, '127.0.0.1', () => console.log(`slow model on ${port} (+${delay} ms per streamed chunk) -> ${target.origin}`)); diff --git a/apps/host/server/agent/agent-bridge.mjs b/apps/host/server/agent/agent-bridge.mjs index f97e5abd..a1e18ba3 100644 --- a/apps/host/server/agent/agent-bridge.mjs +++ b/apps/host/server/agent/agent-bridge.mjs @@ -341,7 +341,7 @@ export function createAgentBridge({ dataDir, componentsDir = null, bundledDir = child.lastRow = now; child.rowPending = false; emit(rowFrame(child)); const working = [...turn.children.values()].filter(h => !h.done).length; - if (working && !turn.parentOpen) reporter.set({ phase: 'helpers', code: 'helpers', text: `Helpers are working (${working})…`, args: { n: working } }); + if (working && !turn.parentOpen) reporter.set({ phase: 'helpers', code: 'helpers', text: `Helpers are working (${working})…`, key: 'Helpers are working ({0})…', values: [working], args: { n: working } }); }; function openChild(d) { @@ -448,7 +448,7 @@ export function createAgentBridge({ dataDir, componentsDir = null, bundledDir = const goal = goalObject(view); emit({ type: 'goal', goal }); onGoal(chatId, goal); - if (!final && goal && goal.phase === 'active' && turn.goalRound) reporter.set({ phase: 'goal', code: 'goal-step', text: `Working on the goal, step ${turn.goalRound}`, args: { round: turn.goalRound, max: goal.maxRounds } }); + if (!final && goal && goal.phase === 'active' && turn.goalRound) reporter.set({ phase: 'goal', code: 'goal-step', text: `Working on the goal, step ${turn.goalRound}`, key: 'Working on the goal, step {0}', values: [turn.goalRound], args: { round: turn.goalRound, max: goal.maxRounds } }); } turn.announceGoal = announceGoal; diff --git a/apps/host/server/agent/events.mjs b/apps/host/server/agent/events.mjs index 637b01d1..4bc58407 100644 --- a/apps/host/server/agent/events.mjs +++ b/apps/host/server/agent/events.mjs @@ -7,7 +7,7 @@ * reasoning deltas, usage). */ -import { toolStatusText, TokenCount, fmtTokens } from './status.mjs'; +import { toolUpdate, TokenCount, fmtTokens } from './status.mjs'; import { askFor } from './ask.mjs'; const SHELL = new Set(['pwsh', 'bash', 'job_kill', 'job_output', 'job_list']); @@ -77,6 +77,9 @@ const VERBS = { bash: ['Running a command', 'Ran a command', 'The command failed'], web_fetch: ['Opening a web page', 'Opened a web page', "Couldn't open the web page"], web_search: ['Searching the web', 'Searched the web', "Couldn't search the web"], + create_goal: ['Setting the goal', 'Set the goal', "Couldn't set the goal"], + update_goal: ['Updating the goal', 'Updated the goal', "Couldn't update the goal"], + get_goal: ['Checking the goal', 'Checked the goal', "Couldn't check the goal"], todo_write: ['Updating its to-do list', 'Updated its to-do list', "Couldn't update its to-do list"], present: ['Showing you a result', 'Showed you a result', "Couldn't show the result"], working_directory: ['Checking the folder', 'Checked the folder', "Couldn't check the folder"], @@ -219,7 +222,7 @@ export class TurnProjector { #afterTool() { const id = this.running.at(-1); const card = id ? this.tools.get(id)?.card : null; - if (card) this.#status({ phase: 'tool', code: 'tool', text: toolStatusText(card.name, card.args), args: { tool: card.name, verb: card.verb, target: card.target } }); + if (card) this.#status(toolUpdate('tool', 'tool', card.name, card.args, {}, { args: { tool: card.name, verb: card.verb, target: card.target } })); else this.#status({ phase: 'waiting', code: 'model-working', text: 'Working out the next step…' }); } @@ -269,8 +272,10 @@ export class TurnProjector { } else if (c.type === 'reasoning-delta' && c.text) { this.firstTokenAt ??= Date.now(); this.#produced(f.attemptId, c.text, out); + // The count is for the model's current thinking (each model request starts again from zero), not the whole turn. + if (this.reasoningAttempt !== f.attemptId) { this.reasoning = new TokenCount(); this.reasoningAttempt = f.attemptId; } this.reasoning.add(c.text); - this.#status({ phase: 'thinking', code: 'thinking', text: `Thinking… ${fmtTokens(this.reasoning.tokens)} tokens`, tokens: this.reasoning.tokens, args: { tokens: this.reasoning.tokens } }); + this.#status({ phase: 'thinking', code: 'thinking', text: `Thinking… ${fmtTokens(this.reasoning.tokens)} tokens`, key: 'Thinking… {0} tokens', values: [fmtTokens(this.reasoning.tokens)], tokens: this.reasoning.tokens, args: { tokens: this.reasoning.tokens } }); out.push({ type: 'reasoning', text: c.text }); } else if (c.type === 'tool-call-delta' && c.id) { // The model is writing a tool call. For a big file this is the long silent part: nothing else arrives until it is finished. @@ -284,7 +289,7 @@ export class TurnProjector { const raw = (/"(?:file_path|path|filePath)"\s*:\s*"((?:[^"\\]|\\.)*)"/.exec(call.head) ?? /"url"\s*:\s*"((?:[^"\\]|\\.)*)"/.exec(call.head))?.[1]; let target = raw; try { if (raw !== undefined) target = JSON.parse('"' + raw + '"'); } catch { /* a half-written escape: show it as it is */ } const args = target ? { file_path: target, url: target } : {}; - this.#status({ phase: 'preparing', code: 'preparing-tool', text: toolStatusText(call.name, args, { bytes: call.bytes }), args: { tool: call.name, verb: toolVerb(call.name, 'running'), target: target ?? '', bytes: call.bytes } }); + this.#status(toolUpdate('preparing', 'preparing-tool', call.name, args, { bytes: call.bytes }, { args: { tool: call.name, verb: toolVerb(call.name, 'running'), target: target ?? '', bytes: call.bytes } })); } } else if (c.type === 'usage' && c.usage) { this.usageSeen = true; @@ -317,7 +322,7 @@ export class TurnProjector { this.tools.set(d.callId, { card, calledAt: e.time }); this.composing.delete(d.callId); this.running.push(d.callId); - this.#status({ phase: 'tool', code: 'tool', text: toolStatusText(d.name, args), args: { tool: d.name, verb: card.verb, target: card.target } }); + this.#status(toolUpdate('tool', 'tool', d.name, args, {}, { args: { tool: d.name, verb: card.verb, target: card.target } })); out.push({ type: 'agent-tool', tool: card }); break; } diff --git a/apps/host/server/agent/status.mjs b/apps/host/server/agent/status.mjs index f0fc6a5b..aff00f95 100644 --- a/apps/host/server/agent/status.mjs +++ b/apps/host/server/agent/status.mjs @@ -5,38 +5,63 @@ * new frame on every change of phase or target (at most one per `gapMs`, the newest change wins), and between changes only repeats the * frame to refresh a counter (reasoning tokens, bytes written) every `beatMs`. It never sends the same words twice in a row. * - * { type:'status', seq, phase, code, text, args?, tokens?, elapsedMs } + * { type:'status', seq, phase, code, text, key?, values?, args?, tokens?, elapsedMs } + * `key`/`values` (only when the sentence has a name or a number in it): the catalog template ("Writing {0}…") and its values, for translation. * * phases: starting waiting thinking answering preparing tool approval helpers goal idle (see notes-split-agent3.md) */ -/** The sentence for a tool, in the person's words: what it is doing to what ("Writing pagoda.html…"). */ -export function toolStatusText(name, args = {}, { bytes = 0 } = {}) { +/** Fill the `{0}` slots of a template (the catalog key of a sentence) with values. */ +export const fillTemplate = (key, values = []) => String(key).replace(/\{(\d+)\}/g, (_, i) => String(values[Number(i)] ?? '')); + +/** + * The sentence for a tool, in the person's words: what it is doing to what ("Writing pagoda.html…"), as a catalog template and its values + * so the page can translate it: `{ key: 'Writing {0}…', values: ['pagoda.html'] }`. + */ +export function toolStatus(name, args = {}, { bytes = 0 } = {}) { const base = value => String(value ?? '').split(/[\\/]/).filter(Boolean).pop() ?? ''; const file = base(args.file_path ?? args.path ?? args.filePath); - const size = bytes >= 1500 ? ` (${(bytes / 1024).toFixed(bytes >= 10240 ? 0 : 1)} KB)` : ''; + const kb = bytes >= 1500 ? (bytes / 1024).toFixed(bytes >= 10240 ? 0 : 1) : null; + const act = (verb, noun) => file + ? (kb ? { key: `${verb} {0}… ({1} KB)`, values: [file, kb] } : { key: `${verb} {0}…`, values: [file] }) + : (kb ? { key: `${verb} ${noun}… ({0} KB)`, values: [kb] } : { key: `${verb} ${noun}…`, values: [] }); switch (name) { - case 'write': return file ? `Writing ${file}…${size}` : `Writing a file…${size}`; - case 'edit': return file ? `Changing ${file}…${size}` : `Changing a file…${size}`; - case 'read': return file ? `Reading ${file}…` : 'Reading a file…'; - case 'read_image': return 'Looking at a picture…'; - case 'pwsh': case 'bash': return 'Running a command…'; - case 'glob': case 'grep': return 'Searching your files…'; - case 'web_search': return 'Searching the web…'; - case 'web_fetch': { let host = ''; try { host = new URL(args.url).hostname; } catch { /* partial address */ } return host ? `Opening ${host}…` : 'Opening a web page…'; } - case 'todo_write': return 'Updating its to-do list…'; - case 'skill': return 'Using a saved skill…'; - case 'present': return 'Showing you a result…'; - case 'workflow': return 'Running a multi-step plan…'; - case 'job_list': case 'job_output': case 'job_kill': return 'Checking background tasks…'; + case 'write': return act('Writing', 'a file'); + case 'edit': return act('Changing', 'a file'); + case 'read': return file ? { key: 'Reading {0}…', values: [file] } : { key: 'Reading a file…', values: [] }; + case 'read_image': return { key: 'Looking at a picture…', values: [] }; + case 'pwsh': case 'bash': return { key: 'Running a command…', values: [] }; + case 'glob': case 'grep': return { key: 'Searching your files…', values: [] }; + case 'web_search': return { key: 'Searching the web…', values: [] }; + case 'web_fetch': { let host = ''; try { host = new URL(args.url).hostname; } catch { /* partial address */ } return host ? { key: 'Opening {0}…', values: [host] } : { key: 'Opening a web page…', values: [] }; } + case 'create_goal': return { key: 'Setting the goal…', values: [] }; + case 'update_goal': return { key: 'Updating the goal…', values: [] }; + case 'get_goal': return { key: 'Checking the goal…', values: [] }; + case 'todo_write': return { key: 'Updating its to-do list…', values: [] }; + case 'skill': return { key: 'Using a saved skill…', values: [] }; + case 'present': return { key: 'Showing you a result…', values: [] }; + case 'workflow': return { key: 'Running a multi-step plan…', values: [] }; + case 'job_list': case 'job_output': case 'job_kill': return { key: 'Checking background tasks…', values: [] }; default: - if (name.startsWith('mcp__browser__')) return name.endsWith('navigate') ? (args.url ? `Opening ${args.url}…` : 'Opening a page…') : 'Using the browser…'; - if (name.startsWith('mcp__strata-instructions__')) return 'Reading your instructions…'; - if (name.startsWith('mcp__strata-commands__')) return 'Running your tool…'; - return 'Using a tool…'; + if (name.startsWith('mcp__browser__')) return name.endsWith('navigate') ? (args.url ? { key: 'Opening {0}…', values: [String(args.url)] } : { key: 'Opening a page…', values: [] }) : { key: 'Using the browser…', values: [] }; + if (name.startsWith('mcp__strata-instructions__')) return { key: 'Reading your instructions…', values: [] }; + if (name.startsWith('mcp__strata-commands__')) return { key: 'Running your tool…', values: [] }; + return { key: 'Using a tool…', values: [] }; } } +/** The same, as one English sentence. */ +export function toolStatusText(name, args = {}, options = {}) { + const s = toolStatus(name, args, options); + return fillTemplate(s.key, s.values); +} + +/** A status update (what the reporter takes) for a tool: text, catalog template and values together. */ +export function toolUpdate(phase, code, name, args, options, extra = {}) { + const s = toolStatus(name, args, options); + return { phase, code, text: fillTemplate(s.key, s.values), key: s.key, values: s.values, ...extra }; +} + const COUNTERS = new Set(['tokens', 'bytes']); const keyOf = u => `${u.phase}|${u.code}|${JSON.stringify(Object.fromEntries(Object.entries(u.args ?? {}).filter(([k]) => !COUNTERS.has(k))))}`; @@ -96,6 +121,7 @@ export class StatusReporter { this.lastEmitAt = this.now(); this.emitFrame({ type: 'status', seq: ++this.seq, phase: w.phase, code: w.code, text: w.text, + ...(w.key && w.key !== w.text ? { key: w.key, values: w.values ?? [] } : {}), ...(w.args ? { args: w.args } : {}), ...(w.tokens !== undefined ? { tokens: w.tokens } : {}), elapsedMs: Math.max(0, this.now() - this.phaseStartedAt), }); @@ -122,7 +148,7 @@ export function withPlainStatus(write, options = {}) { const frame = f => { switch (f.type) { case 'start': reporter.set({ phase: 'waiting', code: 'reading-prompt', text: 'Reading your message…' }); break; - case 'reasoning': reasoning.add(f.text ?? ''); reporter.set({ phase: 'thinking', code: 'thinking', text: `Thinking… ${fmtTokens(reasoning.tokens)} tokens`, tokens: reasoning.tokens, args: { tokens: reasoning.tokens } }); break; + case 'reasoning': reasoning.add(f.text ?? ''); reporter.set({ phase: 'thinking', code: 'thinking', text: `Thinking… ${fmtTokens(reasoning.tokens)} tokens`, key: 'Thinking… {0} tokens', values: [fmtTokens(reasoning.tokens)], tokens: reasoning.tokens, args: { tokens: reasoning.tokens } }); break; case 'delta': reporter.set({ phase: 'answering', code: 'answering', text: 'Writing the answer…' }); break; case 'done': case 'error': reporter.clear(); break; default: break; diff --git a/apps/host/src/locales/de.json b/apps/host/src/locales/de.json index 541917aa..64d36b5c 100644 --- a/apps/host/src/locales/de.json +++ b/apps/host/src/locales/de.json @@ -2931,5 +2931,54 @@ "s2933": "Vorher", "s2934": "Nachher", "s2935": "Gespeichert als {0}. Es wird bei jedem Laden dieses Modells verwendet.", - "s2936": "Optimiert und gespeichert" + "s2936": "Optimiert und gespeichert", + "s2937": "Das Ziel wird gesetzt", + "s2938": "Das Ziel gesetzt", + "s2939": "Das Ziel ließ sich nicht setzen", + "s2940": "Das Ziel wird aktualisiert", + "s2941": "Das Ziel aktualisiert", + "s2942": "Das Ziel ließ sich nicht aktualisieren", + "s2943": "Das Ziel wird geprüft", + "s2944": "Das Ziel geprüft", + "s2945": "Das Ziel ließ sich nicht prüfen", + "s2946": "Deine Nachricht wird gelesen…", + "s2947": "Der nächste Schritt wird überlegt…", + "s2948": "Denkt nach… {0} Tokens", + "s2949": "Die Antwort wird geschrieben…", + "s2950": "Wartet auf deine Antwort…", + "s2951": "Helfer arbeiten ({0})…", + "s2952": "Arbeitet am Ziel, Schritt {0}", + "s2953": "{0} wird geschrieben…", + "s2954": "Eine Datei wird geschrieben…", + "s2955": "{0} wird geschrieben… ({1} KB)", + "s2956": "Eine Datei wird geschrieben… ({0} KB)", + "s2957": "{0} wird geändert…", + "s2958": "Eine Datei wird geändert…", + "s2959": "{0} wird geändert… ({1} KB)", + "s2960": "Eine Datei wird geändert… ({0} KB)", + "s2961": "{0} wird gelesen…", + "s2962": "Eine Datei wird gelesen…", + "s2963": "Ein Bild wird angesehen…", + "s2964": "Ein Befehl läuft…", + "s2965": "Deine Dateien werden durchsucht…", + "s2966": "Das Web wird durchsucht…", + "s2967": "{0} wird geöffnet…", + "s2968": "Eine Webseite wird geöffnet…", + "s2969": "Eine Seite wird geöffnet…", + "s2970": "Der Browser wird benutzt…", + "s2971": "Das Ziel wird gesetzt…", + "s2972": "Das Ziel wird aktualisiert…", + "s2973": "Das Ziel wird geprüft…", + "s2974": "Die Aufgabenliste wird aktualisiert…", + "s2975": "Ein gespeicherter Skill wird verwendet…", + "s2976": "Ein Ergebnis wird angezeigt…", + "s2977": "Ein mehrstufiger Plan läuft…", + "s2978": "Hintergrundaufgaben werden geprüft…", + "s2979": "Deine Anweisungen werden gelesen…", + "s2980": "Dein Werkzeug läuft…", + "s2981": "Ein Werkzeug wird benutzt…", + "s2982": "Deine Dateien werden gelesen…", + "s2983": "Eine verbesserte Version wird ausprobiert…", + "s2984": "Das Ergebnis wird geprüft…", + "s2985": "Die beiden Versionen werden verglichen…" } diff --git a/apps/host/src/locales/en.json b/apps/host/src/locales/en.json index a2b79519..8f939bd9 100644 --- a/apps/host/src/locales/en.json +++ b/apps/host/src/locales/en.json @@ -2931,5 +2931,54 @@ "s2933": "Before", "s2934": "After", "s2935": "Saved as {0}. It is used every time you load this model.", - "s2936": "Tuned and saved" + "s2936": "Tuned and saved", + "s2937": "Setting the goal", + "s2938": "Set the goal", + "s2939": "Couldn't set the goal", + "s2940": "Updating the goal", + "s2941": "Updated the goal", + "s2942": "Couldn't update the goal", + "s2943": "Checking the goal", + "s2944": "Checked the goal", + "s2945": "Couldn't check the goal", + "s2946": "Reading your message…", + "s2947": "Working out the next step…", + "s2948": "Thinking… {0} tokens", + "s2949": "Writing the answer…", + "s2950": "Waiting for your answer…", + "s2951": "Helpers are working ({0})…", + "s2952": "Working on the goal, step {0}", + "s2953": "Writing {0}…", + "s2954": "Writing a file…", + "s2955": "Writing {0}… ({1} KB)", + "s2956": "Writing a file… ({0} KB)", + "s2957": "Changing {0}…", + "s2958": "Changing a file…", + "s2959": "Changing {0}… ({1} KB)", + "s2960": "Changing a file… ({0} KB)", + "s2961": "Reading {0}…", + "s2962": "Reading a file…", + "s2963": "Looking at a picture…", + "s2964": "Running a command…", + "s2965": "Searching your files…", + "s2966": "Searching the web…", + "s2967": "Opening {0}…", + "s2968": "Opening a web page…", + "s2969": "Opening a page…", + "s2970": "Using the browser…", + "s2971": "Setting the goal…", + "s2972": "Updating the goal…", + "s2973": "Checking the goal…", + "s2974": "Updating its to-do list…", + "s2975": "Using a saved skill…", + "s2976": "Showing you a result…", + "s2977": "Running a multi-step plan…", + "s2978": "Checking background tasks…", + "s2979": "Reading your instructions…", + "s2980": "Running your tool…", + "s2981": "Using a tool…", + "s2982": "Reading your files…", + "s2983": "Trying an improved version…", + "s2984": "Checking the result…", + "s2985": "Comparing the two versions…" } diff --git a/apps/host/src/locales/es.json b/apps/host/src/locales/es.json index 14682c1b..c6ec9f75 100644 --- a/apps/host/src/locales/es.json +++ b/apps/host/src/locales/es.json @@ -2931,5 +2931,54 @@ "s2933": "Antes", "s2934": "Después", "s2935": "Guardado como {0}. Se usa cada vez que cargas este modelo.", - "s2936": "Ajustado y guardado" + "s2936": "Ajustado y guardado", + "s2937": "Fijando el objetivo", + "s2938": "Fijó el objetivo", + "s2939": "No se pudo fijar el objetivo", + "s2940": "Actualizando el objetivo", + "s2941": "Actualizó el objetivo", + "s2942": "No se pudo actualizar el objetivo", + "s2943": "Comprobando el objetivo", + "s2944": "Comprobó el objetivo", + "s2945": "No se pudo comprobar el objetivo", + "s2946": "Leyendo tu mensaje…", + "s2947": "Pensando en el siguiente paso…", + "s2948": "Pensando… {0} tokens", + "s2949": "Escribiendo la respuesta…", + "s2950": "Esperando tu respuesta…", + "s2951": "Los ayudantes están trabajando ({0})…", + "s2952": "Trabajando en el objetivo, paso {0}", + "s2953": "Escribiendo {0}…", + "s2954": "Escribiendo un archivo…", + "s2955": "Escribiendo {0}… ({1} KB)", + "s2956": "Escribiendo un archivo… ({0} KB)", + "s2957": "Cambiando {0}…", + "s2958": "Cambiando un archivo…", + "s2959": "Cambiando {0}… ({1} KB)", + "s2960": "Cambiando un archivo… ({0} KB)", + "s2961": "Leyendo {0}…", + "s2962": "Leyendo un archivo…", + "s2963": "Mirando una imagen…", + "s2964": "Ejecutando un comando…", + "s2965": "Buscando en tus archivos…", + "s2966": "Buscando en la web…", + "s2967": "Abriendo {0}…", + "s2968": "Abriendo una página web…", + "s2969": "Abriendo una página…", + "s2970": "Usando el navegador…", + "s2971": "Fijando el objetivo…", + "s2972": "Actualizando el objetivo…", + "s2973": "Comprobando el objetivo…", + "s2974": "Actualizando su lista de tareas…", + "s2975": "Usando una habilidad guardada…", + "s2976": "Mostrándote un resultado…", + "s2977": "Ejecutando un plan de varios pasos…", + "s2978": "Comprobando las tareas en segundo plano…", + "s2979": "Leyendo tus instrucciones…", + "s2980": "Ejecutando tu herramienta…", + "s2981": "Usando una herramienta…", + "s2982": "Leyendo tus archivos…", + "s2983": "Probando una versión mejorada…", + "s2984": "Comprobando el resultado…", + "s2985": "Comparando las dos versiones…" } diff --git a/apps/host/src/locales/ja.json b/apps/host/src/locales/ja.json index c2af031a..2bde6030 100644 --- a/apps/host/src/locales/ja.json +++ b/apps/host/src/locales/ja.json @@ -2931,5 +2931,54 @@ "s2933": "変更前", "s2934": "変更後", "s2935": "{0} として保存しました。このモデルを読み込むたびに使われます。", - "s2936": "チューニングして保存しました" + "s2936": "チューニングして保存しました", + "s2937": "ゴールを設定しています", + "s2938": "ゴールを設定しました", + "s2939": "ゴールを設定できませんでした", + "s2940": "ゴールを更新しています", + "s2941": "ゴールを更新しました", + "s2942": "ゴールを更新できませんでした", + "s2943": "ゴールを確認しています", + "s2944": "ゴールを確認しました", + "s2945": "ゴールを確認できませんでした", + "s2946": "メッセージを読んでいます…", + "s2947": "次の手順を考えています…", + "s2948": "考えています… {0} トークン", + "s2949": "回答を書いています…", + "s2950": "あなたの返答を待っています…", + "s2951": "補助役が作業中です({0})…", + "s2952": "ゴールに取り組んでいます(手順 {0})", + "s2953": "{0} を書いています…", + "s2954": "ファイルを書いています…", + "s2955": "{0} を書いています…({1} KB)", + "s2956": "ファイルを書いています…({0} KB)", + "s2957": "{0} を変更しています…", + "s2958": "ファイルを変更しています…", + "s2959": "{0} を変更しています…({1} KB)", + "s2960": "ファイルを変更しています…({0} KB)", + "s2961": "{0} を読んでいます…", + "s2962": "ファイルを読んでいます…", + "s2963": "画像を見ています…", + "s2964": "コマンドを実行しています…", + "s2965": "ファイルを検索しています…", + "s2966": "ウェブを検索しています…", + "s2967": "{0} を開いています…", + "s2968": "ウェブページを開いています…", + "s2969": "ページを開いています…", + "s2970": "ブラウザーを使っています…", + "s2971": "ゴールを設定しています…", + "s2972": "ゴールを更新しています…", + "s2973": "ゴールを確認しています…", + "s2974": "ToDoリストを更新しています…", + "s2975": "保存したスキルを使っています…", + "s2976": "結果を表示しています…", + "s2977": "複数の手順の計画を実行しています…", + "s2978": "バックグラウンドの処理を確認しています…", + "s2979": "あなたの指示を読んでいます…", + "s2980": "あなたのツールを実行しています…", + "s2981": "ツールを使っています…", + "s2982": "ファイルを読んでいます…", + "s2983": "改良版を試しています…", + "s2984": "結果を確認しています…", + "s2985": "2つの版を比較しています…" } diff --git a/apps/host/src/locales/ko.json b/apps/host/src/locales/ko.json index 46716bb9..e49c04cd 100644 --- a/apps/host/src/locales/ko.json +++ b/apps/host/src/locales/ko.json @@ -2931,5 +2931,54 @@ "s2933": "이전", "s2934": "이후", "s2935": "{0}(으)로 저장했습니다. 이 모델을 불러올 때마다 사용됩니다.", - "s2936": "튜닝 후 저장됨" + "s2936": "튜닝 후 저장됨", + "s2937": "목표를 설정하는 중", + "s2938": "목표를 설정했습니다", + "s2939": "목표를 설정할 수 없었습니다", + "s2940": "목표를 업데이트하는 중", + "s2941": "목표를 업데이트했습니다", + "s2942": "목표를 업데이트할 수 없었습니다", + "s2943": "목표를 확인하는 중", + "s2944": "목표를 확인했습니다", + "s2945": "목표를 확인할 수 없었습니다", + "s2946": "메시지를 읽는 중…", + "s2947": "다음 단계를 생각하는 중…", + "s2948": "생각하는 중… {0}토큰", + "s2949": "답변을 작성하는 중…", + "s2950": "답변을 기다리는 중…", + "s2951": "도우미가 작업 중입니다({0})…", + "s2952": "목표를 달성하는 중, {0}단계", + "s2953": "{0} 작성하는 중…", + "s2954": "파일을 작성하는 중…", + "s2955": "{0} 작성하는 중… ({1}KB)", + "s2956": "파일을 작성하는 중… ({0}KB)", + "s2957": "{0} 변경하는 중…", + "s2958": "파일을 변경하는 중…", + "s2959": "{0} 변경하는 중… ({1}KB)", + "s2960": "파일을 변경하는 중… ({0}KB)", + "s2961": "{0} 읽는 중…", + "s2962": "파일을 읽는 중…", + "s2963": "그림을 보는 중…", + "s2964": "명령을 실행하는 중…", + "s2965": "파일을 검색하는 중…", + "s2966": "웹을 검색하는 중…", + "s2967": "{0} 여는 중…", + "s2968": "웹 페이지를 여는 중…", + "s2969": "페이지를 여는 중…", + "s2970": "브라우저를 사용하는 중…", + "s2971": "목표를 설정하는 중…", + "s2972": "목표를 업데이트하는 중…", + "s2973": "목표를 확인하는 중…", + "s2974": "할 일 목록을 업데이트하는 중…", + "s2975": "저장된 스킬을 사용하는 중…", + "s2976": "결과를 보여주는 중…", + "s2977": "여러 단계의 계획을 실행하는 중…", + "s2978": "백그라운드 작업을 확인하는 중…", + "s2979": "내 지침을 읽는 중…", + "s2980": "내 도구를 실행하는 중…", + "s2981": "도구를 사용하는 중…", + "s2982": "파일을 읽는 중…", + "s2983": "개선된 버전을 시도하는 중…", + "s2984": "결과를 확인하는 중…", + "s2985": "두 버전을 비교하는 중…" } diff --git a/apps/host/src/locales/pt.json b/apps/host/src/locales/pt.json index e037ff58..2fb13eaf 100644 --- a/apps/host/src/locales/pt.json +++ b/apps/host/src/locales/pt.json @@ -2931,5 +2931,54 @@ "s2933": "Antes", "s2934": "Depois", "s2935": "Salvo como {0}. É usado toda vez que você carrega este modelo.", - "s2936": "Ajustado e salvo" + "s2936": "Ajustado e salvo", + "s2937": "Definindo a meta", + "s2938": "Definiu a meta", + "s2939": "Não foi possível definir a meta", + "s2940": "Atualizando a meta", + "s2941": "Atualizou a meta", + "s2942": "Não foi possível atualizar a meta", + "s2943": "Verificando a meta", + "s2944": "Verificou a meta", + "s2945": "Não foi possível verificar a meta", + "s2946": "Lendo a sua mensagem…", + "s2947": "Pensando no próximo passo…", + "s2948": "Pensando… {0} tokens", + "s2949": "Escrevendo a resposta…", + "s2950": "Aguardando a sua resposta…", + "s2951": "Os ajudantes estão trabalhando ({0})…", + "s2952": "Trabalhando na meta, etapa {0}", + "s2953": "Escrevendo {0}…", + "s2954": "Escrevendo um arquivo…", + "s2955": "Escrevendo {0}… ({1} KB)", + "s2956": "Escrevendo um arquivo… ({0} KB)", + "s2957": "Alterando {0}…", + "s2958": "Alterando um arquivo…", + "s2959": "Alterando {0}… ({1} KB)", + "s2960": "Alterando um arquivo… ({0} KB)", + "s2961": "Lendo {0}…", + "s2962": "Lendo um arquivo…", + "s2963": "Olhando uma imagem…", + "s2964": "Executando um comando…", + "s2965": "Pesquisando nos seus arquivos…", + "s2966": "Pesquisando na web…", + "s2967": "Abrindo {0}…", + "s2968": "Abrindo uma página da web…", + "s2969": "Abrindo uma página…", + "s2970": "Usando o navegador…", + "s2971": "Definindo a meta…", + "s2972": "Atualizando a meta…", + "s2973": "Verificando a meta…", + "s2974": "Atualizando a lista de tarefas…", + "s2975": "Usando uma habilidade salva…", + "s2976": "Mostrando um resultado…", + "s2977": "Executando um plano de várias etapas…", + "s2978": "Verificando as tarefas em segundo plano…", + "s2979": "Lendo as suas instruções…", + "s2980": "Executando a sua ferramenta…", + "s2981": "Usando uma ferramenta…", + "s2982": "Lendo os seus arquivos…", + "s2983": "Testando uma versão melhorada…", + "s2984": "Verificando o resultado…", + "s2985": "Comparando as duas versões…" } diff --git a/apps/host/src/locales/ru.json b/apps/host/src/locales/ru.json index d7179ab2..72048114 100644 --- a/apps/host/src/locales/ru.json +++ b/apps/host/src/locales/ru.json @@ -2931,5 +2931,54 @@ "s2933": "До", "s2934": "После", "s2935": "Сохранено как {0}. Применяется при каждой загрузке этой модели.", - "s2936": "Настроено и сохранено" + "s2936": "Настроено и сохранено", + "s2937": "Постановка цели", + "s2938": "Цель поставлена", + "s2939": "Не удалось поставить цель", + "s2940": "Обновление цели", + "s2941": "Цель обновлена", + "s2942": "Не удалось обновить цель", + "s2943": "Проверка цели", + "s2944": "Цель проверена", + "s2945": "Не удалось проверить цель", + "s2946": "Чтение вашего сообщения…", + "s2947": "Обдумывание следующего шага…", + "s2948": "Размышление… {0} токенов", + "s2949": "Написание ответа…", + "s2950": "Ожидание вашего ответа…", + "s2951": "Помощники работают ({0})…", + "s2952": "Работа над целью, шаг {0}", + "s2953": "Запись {0}…", + "s2954": "Запись файла…", + "s2955": "Запись {0}… ({1} КБ)", + "s2956": "Запись файла… ({0} КБ)", + "s2957": "Изменение {0}…", + "s2958": "Изменение файла…", + "s2959": "Изменение {0}… ({1} КБ)", + "s2960": "Изменение файла… ({0} КБ)", + "s2961": "Чтение {0}…", + "s2962": "Чтение файла…", + "s2963": "Просмотр изображения…", + "s2964": "Выполнение команды…", + "s2965": "Поиск по вашим файлам…", + "s2966": "Поиск в интернете…", + "s2967": "Открытие {0}…", + "s2968": "Открытие веб-страницы…", + "s2969": "Открытие страницы…", + "s2970": "Использование браузера…", + "s2971": "Постановка цели…", + "s2972": "Обновление цели…", + "s2973": "Проверка цели…", + "s2974": "Обновление списка дел…", + "s2975": "Использование сохранённого навыка…", + "s2976": "Показ результата…", + "s2977": "Выполнение многошагового плана…", + "s2978": "Проверка фоновых задач…", + "s2979": "Чтение ваших инструкций…", + "s2980": "Запуск вашего инструмента…", + "s2981": "Использование инструмента…", + "s2982": "Чтение ваших файлов…", + "s2983": "Пробуется улучшенная версия…", + "s2984": "Проверка результата…", + "s2985": "Сравнение двух версий…" } diff --git a/apps/host/src/locales/zh.json b/apps/host/src/locales/zh.json index 98a5907b..99b60c6c 100644 --- a/apps/host/src/locales/zh.json +++ b/apps/host/src/locales/zh.json @@ -2931,5 +2931,54 @@ "s2933": "之前", "s2934": "之后", "s2935": "已保存为 {0}。每次加载这个模型都会使用它。", - "s2936": "已调优并保存" + "s2936": "已调优并保存", + "s2937": "正在设定目标", + "s2938": "已设定目标", + "s2939": "无法设定目标", + "s2940": "正在更新目标", + "s2941": "已更新目标", + "s2942": "无法更新目标", + "s2943": "正在检查目标", + "s2944": "已检查目标", + "s2945": "无法检查目标", + "s2946": "正在阅读你的消息…", + "s2947": "正在思考下一步…", + "s2948": "思考中… {0} 个词元", + "s2949": "正在撰写回答…", + "s2950": "正在等待你的回答…", + "s2951": "帮手正在工作({0})…", + "s2952": "正在处理目标,第 {0} 步", + "s2953": "正在写入 {0}…", + "s2954": "正在写入文件…", + "s2955": "正在写入 {0}…({1} KB)", + "s2956": "正在写入文件…({0} KB)", + "s2957": "正在修改 {0}…", + "s2958": "正在修改文件…", + "s2959": "正在修改 {0}…({1} KB)", + "s2960": "正在修改文件…({0} KB)", + "s2961": "正在读取 {0}…", + "s2962": "正在读取文件…", + "s2963": "正在查看图片…", + "s2964": "正在运行命令…", + "s2965": "正在搜索你的文件…", + "s2966": "正在搜索网络…", + "s2967": "正在打开 {0}…", + "s2968": "正在打开网页…", + "s2969": "正在打开页面…", + "s2970": "正在使用浏览器…", + "s2971": "正在设定目标…", + "s2972": "正在更新目标…", + "s2973": "正在检查目标…", + "s2974": "正在更新待办清单…", + "s2975": "正在使用已保存的技能…", + "s2976": "正在显示结果…", + "s2977": "正在执行多步骤计划…", + "s2978": "正在检查后台任务…", + "s2979": "正在读取你的说明…", + "s2980": "正在运行你的工具…", + "s2981": "正在使用工具…", + "s2982": "正在读取你的文件…", + "s2983": "正在尝试改进版本…", + "s2984": "正在检查结果…", + "s2985": "正在比较两个版本…" } diff --git a/apps/host/tests/agent-status.test.mjs b/apps/host/tests/agent-status.test.mjs index 36ff0ade..22122516 100644 --- a/apps/host/tests/agent-status.test.mjs +++ b/apps/host/tests/agent-status.test.mjs @@ -11,6 +11,7 @@ test('a tool is described by what it does to what, in the person\'s words', () = assert.equal(toolStatusText('edit', { path: 'notes.md' }), 'Changing notes.md…'); assert.equal(toolStatusText('pwsh', { command: 'Get-ChildItem' }), 'Running a command…'); assert.equal(toolStatusText('web_search', {}), 'Searching the web…'); + assert.equal(toolStatusText('update_goal', {}), 'Updating the goal…'); assert.equal(toolStatusText('web_fetch', { url: 'https://example.com/a' }), 'Opening example.com…'); assert.equal(toolStatusText('mcp__browser__browser_navigate', { url: 'https://example.com' }), 'Opening https://example.com…'); assert.equal(toolStatusText('mcp__strata-commands__x', {}), 'Running your tool…'); @@ -72,6 +73,8 @@ test('projector: thinking counts tokens; composing a file call is "Writing pagod assert.deepEqual([seen.at(-1).phase, seen.at(-1).tokens, seen.at(-1).text], ['thinking', 5, 'Thinking… 5 tokens']); chunk({ type: 'text-delta', text: 'I will build the pagoda HTML file now.' }); assert.equal(seen.at(-1).phase, 'answering'); + chunk({ type: 'reasoning-delta', text: 'again' }, 'a2'); + assert.equal(seen.at(-1).tokens, 1, 'a new model request counts its own thinking from zero'); chunk({ type: 'tool-call-delta', index: 0, id: 'call-1', name: 'write', argumentsDelta: '{"file_path":"C:\\\\work\\\\pagoda.html","content":"' }); assert.deepEqual([seen.at(-1).phase, seen.at(-1).code, seen.at(-1).text], ['preparing', 'preparing-tool', 'Writing pagoda.html…'], 'the stale sentence is replaced the moment the call starts'); assert.equal(seen.at(-1).args.target, 'C:\\work\\pagoda.html'); @@ -148,3 +151,17 @@ test('real Harness: a turn that writes a file says what it is doing, in order, a assert.ok(frames.indexOf(statuses.at(-1)) < frames.findIndex(f => f.type === 'done'), 'cleared before done'); assert.ok(existsSync(join(ws, 'pagoda.html'))); }); + +test('a sentence with a name or a number also carries its catalog template and values, and every status sentence is in the catalog in every language', async () => { + const { readFileSync } = await import('node:fs'); + const catalog = Object.fromEntries(['en', 'de', 'es', 'ja', 'ko', 'pt', 'ru', 'zh'].map(l => [l, JSON.parse(readFileSync(new URL(`../src/locales/${l}.json`, import.meta.url), 'utf8'))])); + const idOf = text => Object.entries(catalog.en).find(([, v]) => v === text)?.[0]; + const p = new TurnProjector(); const seen = []; p.onStatus = u => seen.push(u); + p.consume({ type: 'assistant-stream', frame: { type: 'chunk', attemptId: 'a', chunk: { type: 'tool-call-delta', index: 0, id: 'c', name: 'write', argumentsDelta: '{"file_path":"/w/pagoda.html","content":"' + 'x'.repeat(4000) } } }); + assert.deepEqual([seen.at(-1).key, seen.at(-1).values], ['Writing {0}… ({1} KB)', ['pagoda.html', '3.9']]); + assert.equal(seen.at(-1).text, 'Writing pagoda.html… (3.9 KB)'); + const keys = ['Starting…', 'Reading your message…', 'Working out the next step…', 'Thinking… {0} tokens', 'Writing the answer…', 'Waiting for your answer…', 'Helpers are working ({0})…', 'Working on the goal, step {0}', + 'Writing {0}…', 'Writing a file…', 'Writing {0}… ({1} KB)', 'Writing a file… ({0} KB)', 'Changing {0}…', 'Changing a file…', 'Reading {0}…', 'Reading a file…', 'Running a command…', 'Searching your files…', 'Searching the web…', + 'Opening {0}…', 'Opening a web page…', 'Using the browser…', 'Setting the goal…', 'Updating the goal…', 'Checking the goal…', 'Using a tool…', 'Reading your files…', 'Trying an improved version…', 'Checking the result…', 'Comparing the two versions…']; + for (const key of keys) { const id = idOf(key); assert.ok(id, `${key} is in the catalog`); for (const l of ['de', 'es', 'ja', 'ko', 'pt', 'ru', 'zh']) { assert.ok(catalog[l][id]?.trim(), `${l}: ${key}`); assert.deepEqual((catalog[l][id].match(/\{\d\}/g) ?? []).sort(), (key.match(/\{\d\}/g) ?? []).sort(), `${l} keeps the slots of ${key}`); } } +});