synabun 2.4.2 → 2.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +39 -0
- package/README.md +1 -1
- package/docs/browser-extension-bridge.md +83 -34
- package/lib/release-npm-ci.mjs +23 -1
- package/mcp-server/dist/http.d.ts.map +1 -1
- package/mcp-server/dist/http.js +8 -1
- package/mcp-server/dist/http.js.map +1 -1
- package/mcp-server/dist/services/identity.d.ts +2 -0
- package/mcp-server/dist/services/identity.d.ts.map +1 -1
- package/mcp-server/dist/services/identity.js +4 -0
- package/mcp-server/dist/services/identity.js.map +1 -1
- package/mcp-server/dist/services/memory-client.d.ts +5 -0
- package/mcp-server/dist/services/memory-client.d.ts.map +1 -1
- package/mcp-server/dist/services/memory-client.js +21 -2
- package/mcp-server/dist/services/memory-client.js.map +1 -1
- package/mcp-server/dist/services/memory-writer.d.ts +3 -0
- package/mcp-server/dist/services/memory-writer.d.ts.map +1 -1
- package/mcp-server/dist/services/memory-writer.js +7 -1
- package/mcp-server/dist/services/memory-writer.js.map +1 -1
- package/mcp-server/dist/services/neural-interface.d.ts +11 -1
- package/mcp-server/dist/services/neural-interface.d.ts.map +1 -1
- package/mcp-server/dist/services/neural-interface.js +68 -18
- package/mcp-server/dist/services/neural-interface.js.map +1 -1
- package/mcp-server/dist/services/typesafe-config.d.ts +38 -2
- package/mcp-server/dist/services/typesafe-config.d.ts.map +1 -1
- package/mcp-server/dist/services/typesafe-config.js +260 -8
- package/mcp-server/dist/services/typesafe-config.js.map +1 -1
- package/mcp-server/dist/tools/agent-definition.d.ts +2 -2
- package/mcp-server/dist/tools/agents.d.ts +3 -1
- package/mcp-server/dist/tools/agents.d.ts.map +1 -1
- package/mcp-server/dist/tools/agents.js +11 -6
- package/mcp-server/dist/tools/agents.js.map +1 -1
- package/mcp-server/dist/tools/browser-extension-setup.d.ts.map +1 -1
- package/mcp-server/dist/tools/browser-extension-setup.js +8 -2
- package/mcp-server/dist/tools/browser-extension-setup.js.map +1 -1
- package/mcp-server/dist/tools/browser-observe.d.ts +11 -0
- package/mcp-server/dist/tools/browser-observe.d.ts.map +1 -1
- package/mcp-server/dist/tools/browser-observe.js +113 -27
- package/mcp-server/dist/tools/browser-observe.js.map +1 -1
- package/mcp-server/dist/tools/browser-readers.d.ts +6 -0
- package/mcp-server/dist/tools/browser-readers.d.ts.map +1 -0
- package/mcp-server/dist/tools/browser-readers.js +17 -0
- package/mcp-server/dist/tools/browser-readers.js.map +1 -0
- package/mcp-server/dist/tools/remember.d.ts.map +1 -1
- package/mcp-server/dist/tools/remember.js +6 -2
- package/mcp-server/dist/tools/remember.js.map +1 -1
- package/mcp-server/dist/tools/youtube/analytics.d.ts +4 -0
- package/mcp-server/dist/tools/youtube/analytics.d.ts.map +1 -1
- package/mcp-server/dist/tools/youtube/analytics.js +25 -20
- package/mcp-server/dist/tools/youtube/analytics.js.map +1 -1
- package/mcp-server/dist/tools/youtube/helpers.d.ts +5 -1
- package/mcp-server/dist/tools/youtube/helpers.d.ts.map +1 -1
- package/mcp-server/dist/tools/youtube/helpers.js +7 -3
- package/mcp-server/dist/tools/youtube/helpers.js.map +1 -1
- package/mcp-server/dist/tools/youtube/navigate.d.ts +2 -0
- package/mcp-server/dist/tools/youtube/navigate.d.ts.map +1 -1
- package/mcp-server/dist/tools/youtube/navigate.js +5 -3
- package/mcp-server/dist/tools/youtube/navigate.js.map +1 -1
- package/mcp-server/dist/tools/youtube/playlist.js +2 -2
- package/mcp-server/dist/tools/youtube/playlist.js.map +1 -1
- package/mcp-server/dist/tools/youtube/readers.d.ts +4 -0
- package/mcp-server/dist/tools/youtube/readers.d.ts.map +1 -0
- package/mcp-server/dist/tools/youtube/readers.js +15 -0
- package/mcp-server/dist/tools/youtube/readers.js.map +1 -0
- package/mcp-server/package-lock.json +5 -5
- package/mcp-server/package.json +1 -1
- package/mcp-server/src/http.ts +8 -1
- package/mcp-server/src/services/identity.ts +5 -0
- package/mcp-server/src/services/memory-client.ts +32 -12
- package/mcp-server/src/services/memory-writer.ts +5 -2
- package/mcp-server/src/services/neural-interface.ts +66 -19
- package/mcp-server/src/services/typesafe-config.ts +268 -7
- package/mcp-server/src/tools/agents.ts +12 -6
- package/mcp-server/src/tools/browser-extension-setup.ts +8 -2
- package/mcp-server/src/tools/browser-observe.ts +117 -28
- package/mcp-server/src/tools/browser-readers.ts +19 -0
- package/mcp-server/src/tools/remember.ts +6 -1
- package/mcp-server/src/tools/youtube/analytics.ts +26 -28
- package/mcp-server/src/tools/youtube/helpers.ts +8 -2
- package/mcp-server/src/tools/youtube/navigate.ts +6 -7
- package/mcp-server/src/tools/youtube/playlist.ts +2 -2
- package/mcp-server/src/tools/youtube/readers.ts +15 -0
- package/neural-interface/i18n/en.json +189 -1
- package/neural-interface/i18n/pt-BR.json +196 -8
- package/neural-interface/lib/assistant-api.js +123 -0
- package/neural-interface/lib/assistant-brains/claude.js +10 -0
- package/neural-interface/lib/assistant-brains/opencode.js +121 -7
- package/neural-interface/lib/assistant-dispatch.js +302 -44
- package/neural-interface/lib/assistant-envelope.js +40 -0
- package/neural-interface/lib/assistant-memory.js +3 -1
- package/neural-interface/lib/assistant-persona.js +6 -0
- package/neural-interface/lib/assistant-router.js +18 -8
- package/neural-interface/lib/assistant-runtime.js +182 -11
- package/neural-interface/lib/assistant-task-prompt.js +15 -2
- package/neural-interface/lib/browser-connection-state.js +20 -0
- package/neural-interface/lib/browser-extension-adapter.js +221 -17
- package/neural-interface/lib/browser-extension-archive.js +149 -0
- package/neural-interface/lib/browser-extension-bridge.js +46 -10
- package/neural-interface/lib/browser-extension-folder.js +635 -76
- package/neural-interface/lib/browser-extension-package.js +201 -0
- package/neural-interface/lib/browser-extension-pin.js +84 -0
- package/neural-interface/lib/browser-extension-pin.json +35 -0
- package/{browser-extension/protocol.js → neural-interface/lib/browser-extension-protocol.js} +111 -13
- package/neural-interface/lib/browser-extension-setup.js +108 -19
- package/neural-interface/lib/browser-extension-update.js +104 -0
- package/neural-interface/lib/browser-extraction.js +38 -14
- package/neural-interface/lib/claude-bg-tasks.js +183 -0
- package/neural-interface/lib/claude-history.js +12 -1
- package/neural-interface/lib/cli-install.js +23 -3
- package/neural-interface/lib/cli-update-planner.js +67 -4
- package/neural-interface/lib/confined-fs.js +25 -0
- package/neural-interface/lib/coordination/operations.js +2 -0
- package/neural-interface/lib/db.js +39 -16
- package/neural-interface/lib/editor-completion-opencode.js +2 -2
- package/neural-interface/lib/git-bash/manager.js +28 -3
- package/neural-interface/lib/git-status-runner.js +31 -3
- package/neural-interface/lib/loop-inventory.js +162 -0
- package/neural-interface/lib/loop-stall.js +74 -4
- package/neural-interface/lib/memory-session-capture.js +157 -66
- package/neural-interface/lib/native-loop-providers.js +82 -13
- package/neural-interface/lib/native-loop-runtime.js +23 -2
- package/neural-interface/lib/opencode-protocol.js +4 -2
- package/neural-interface/lib/opencode-shell-read.js +107 -0
- package/neural-interface/lib/opencode-stop-failures.js +40 -0
- package/neural-interface/lib/opencode-turn-release.js +173 -0
- package/neural-interface/lib/opencode-v2-client.js +4 -1
- package/neural-interface/lib/opencode-v2-ws-requests.js +34 -0
- package/neural-interface/lib/opencode2-client.js +341 -6
- package/neural-interface/lib/opencode2-translate.js +161 -4
- package/neural-interface/lib/peer-identity.js +62 -16
- package/neural-interface/lib/session-cache-builder.js +66 -18
- package/neural-interface/lib/session-capture-gate.js +42 -0
- package/neural-interface/lib/session-indexer.js +28 -20
- package/neural-interface/lib/teams/scheduler.js +3 -2
- package/neural-interface/lib/terminal-token-redaction.js +83 -0
- package/neural-interface/lib/ui-blob-api.js +14 -5
- package/neural-interface/lib/ui-blob-store.js +302 -39
- package/neural-interface/lib/whatsapp/bridge.js +52 -6
- package/neural-interface/package-lock.json +5 -5
- package/neural-interface/package.json +1 -1
- package/neural-interface/public/extension-setup.html +6 -2
- package/neural-interface/public/shared/agy/agy-panel.js +38 -10
- package/neural-interface/public/shared/assistant/asst-agents-dock.js +4 -0
- package/neural-interface/public/shared/assistant/asst-api.js +67 -0
- package/neural-interface/public/shared/assistant/asst-composer.js +85 -12
- package/neural-interface/public/shared/assistant/asst-panel.js +354 -11
- package/neural-interface/public/shared/assistant/asst-rack-styles.js +23 -0
- package/neural-interface/public/shared/assistant/asst-render.js +343 -10
- package/neural-interface/public/shared/assistant/asst-scenes.js +12 -0
- package/neural-interface/public/shared/assistant/asst-shell-logic.js +200 -0
- package/neural-interface/public/shared/assistant/asst-shell.js +111 -0
- package/neural-interface/public/shared/assistant/asst-sidepanel.js +18 -1
- package/neural-interface/public/shared/assistant/asst-state.js +241 -2
- package/neural-interface/public/shared/assistant/asst-steer.js +294 -0
- package/neural-interface/public/shared/assistant/asst-styles.js +21 -0
- package/neural-interface/public/shared/bg-tasks/bg-tasks-claude.js +147 -0
- package/neural-interface/public/shared/bg-tasks/bg-tasks-model.js +527 -0
- package/neural-interface/public/shared/bg-tasks/bg-tasks-panel.js +161 -0
- package/neural-interface/public/shared/bg-tasks/bg-tasks-view.js +508 -0
- package/neural-interface/public/shared/browser-extension-updates.js +88 -0
- package/neural-interface/public/shared/cdx/cdx-tabs.js +25 -0
- package/neural-interface/public/shared/cp/cp-bg-tasks.js +130 -0
- package/neural-interface/public/shared/extension-setup/es-page.js +25 -12
- package/neural-interface/public/shared/extension-setup/es-view.js +25 -10
- package/neural-interface/public/shared/extension-update-view.js +34 -0
- package/neural-interface/public/shared/mtc/mtc-panel.js +17 -2
- package/neural-interface/public/shared/ocp-v2/ocp-v2-events.js +5 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-manager.js +1 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-panel.js +34 -2
- package/neural-interface/public/shared/ocp-v2/ocp-v2-rehydrate.js +7 -1
- package/neural-interface/public/shared/ocp-v2/ocp-v2-render.js +26 -1
- package/neural-interface/public/shared/ocp-v2/ocp-v2-send.js +39 -6
- package/neural-interface/public/shared/ocp-v2/ocp-v2-session-actions.js +20 -1
- package/neural-interface/public/shared/ocp-v2/ocp-v2-shell-block.js +165 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-shell-logic.js +350 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-shell.js +108 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-state.js +49 -3
- package/neural-interface/public/shared/ocp-v2/ocp-v2-styles.js +40 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-tools-logic.js +20 -5
- package/neural-interface/public/shared/ocp-v2/ocp-v2-tools.js +7 -1
- package/neural-interface/public/shared/ocp-v2/ocp-v2-ws.js +7 -2
- package/neural-interface/public/shared/settings/settings-browser-extension.js +61 -13
- package/neural-interface/public/shared/settings/settings-extension-update.js +114 -0
- package/neural-interface/public/shared/shell-stop-view.js +83 -0
- package/neural-interface/public/shared/styles.css +4 -0
- package/neural-interface/public/shared/tour/tour-actor.js +14 -3
- package/neural-interface/public/shared/tray-auto-close.js +36 -6
- package/neural-interface/public/shared/ui-claude-panel.js +130 -1
- package/neural-interface/public/shared/ui-native-loop-router.js +45 -3
- package/neural-interface/public/shared/ui-notifications.js +23 -4
- package/neural-interface/public/shared/ui-scroll-follow.js +4 -0
- package/neural-interface/public/shared/ui-settings-entry.js +6 -0
- package/neural-interface/public/shared/ui-tray-columns.js +9 -2
- package/neural-interface/public/shared/worker-end.js +18 -0
- package/neural-interface/scripts/patch-node-pty.mjs +151 -0
- package/neural-interface/scripts/rebuild-pty.js +10 -0
- package/neural-interface/server.js +725 -308
- package/npm-shrinkwrap.json +5 -5
- package/package.json +1 -2
- package/browser-extension/content.js +0 -231
- package/browser-extension/engine.js +0 -658
- package/browser-extension/icons/icon-128.png +0 -0
- package/browser-extension/icons/icon-16.png +0 -0
- package/browser-extension/icons/icon-32.png +0 -0
- package/browser-extension/icons/icon-48.png +0 -0
- package/browser-extension/icons/status-off-16.png +0 -0
- package/browser-extension/icons/status-off-32.png +0 -0
- package/browser-extension/icons/status-off-48.png +0 -0
- package/browser-extension/icons/status-on-16.png +0 -0
- package/browser-extension/icons/status-on-32.png +0 -0
- package/browser-extension/icons/status-on-48.png +0 -0
- package/browser-extension/manifest.json +0 -58
- package/browser-extension/popup-strings.js +0 -250
- package/browser-extension/popup-view.js +0 -151
- package/browser-extension/popup.css +0 -166
- package/browser-extension/popup.html +0 -108
- package/browser-extension/popup.js +0 -359
- package/browser-extension/service-worker.js +0 -283
- package/browser-extension/setup-content.js +0 -36
- package/browser-extension/tokens.css +0 -326
|
@@ -58,6 +58,7 @@ import { STAGE_TIMING, createWorkerStage } from './asst-run-stage.js';
|
|
|
58
58
|
import { SETTLE_FRAMES, createMotionGate } from './asst-motion-gate.js';
|
|
59
59
|
import { createStyleCache } from './asst-style-cache.js';
|
|
60
60
|
import { formatRunTokens } from './asst-usage.js';
|
|
61
|
+
import { canSteerRun, isSteeredEnd, isSteering, steerPromptText, steerTranslator } from './asst-state.js'; // steer's boot part (asst-steer.js loads on demand)
|
|
61
62
|
import { sanitizeHtmlString, sanitizeInto } from './asst-sanitize.js';
|
|
62
63
|
import { decorateCodeBlocks } from '../ui-code-copy.js';
|
|
63
64
|
import { decorateOutput } from '../ui-output.js';
|
|
@@ -129,6 +130,7 @@ const INTERRUPTED_RE = /\b(?:interrupted|aborted|cancell?ed)\b/i;
|
|
|
129
130
|
*/
|
|
130
131
|
export function resultErrorText(ev, t = (_key, fallback) => fallback) {
|
|
131
132
|
if (!ev || (!ev.is_error && !String(ev.subtype || '').startsWith('error'))) return '';
|
|
133
|
+
if (isSteeredEnd(ev)) return ''; // a turn a steer cut is never a failure (asst-steer.js)
|
|
132
134
|
if (String(ev.terminal_reason || '').startsWith('aborted')) return '';
|
|
133
135
|
if (typeof ev.result === 'string' && ev.result.trim()) return ev.result.trim();
|
|
134
136
|
const errors = Array.isArray(ev.errors) ? ev.errors.filter((x) => typeof x === 'string' && x.trim()) : [];
|
|
@@ -167,6 +169,74 @@ function memoryTitle(memory) {
|
|
|
167
169
|
return String(raw || '').replace(/^#+\s*/, '').slice(0, 60) || memory?.id || 'memory';
|
|
168
170
|
}
|
|
169
171
|
|
|
172
|
+
// ── Steer (asst-steer.js) ───────────────────────────────────────────────────
|
|
173
|
+
// A turning arrow: the run goes on, another way.
|
|
174
|
+
const ICON_STEER = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M4 18v-5a5 5 0 0 1 5-5h11"/><path d="m16 4 4 4-4 4"/></svg>';
|
|
175
|
+
const ICON_CLOSE_SMALL = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true"><path d="M18 6 6 18M6 6l12 12"/></svg>';
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* The one-line steer input under a run card: Enter (its form's submit) sends it to the run (onSubmit(runId, text) →
|
|
179
|
+
* truthy when it went), Esc or Cancel closes it; "Write it in the composer" hands the run (and what was typed) to
|
|
180
|
+
* the composer's target chip instead. Focus goes into the input, and back to the card's Steer button when it closes
|
|
181
|
+
* without sending.
|
|
182
|
+
*/
|
|
183
|
+
export function openRunSteerInput(card, { t: pageT = null, locale = null, onSubmit = null, onUseComposer = null } = {}) {
|
|
184
|
+
if (!card) return null;
|
|
185
|
+
const existing = card.querySelector(':scope > .asst-run-steer');
|
|
186
|
+
if (existing) { existing.querySelector('input')?.focus(); return existing; }
|
|
187
|
+
const st8 = steerTranslator(pageT, typeof locale === 'function' ? locale() : locale);
|
|
188
|
+
const box = el('form', 'asst-run-steer');
|
|
189
|
+
box.setAttribute('role', 'group');
|
|
190
|
+
box.setAttribute('aria-label', st8('runSteer'));
|
|
191
|
+
box.innerHTML = `<input type="text" class="asst-run-steer-input" autocomplete="off" spellcheck="true" aria-label="${esc(st8('runSteerPlaceholder'))}" placeholder="${esc(st8('runSteerPlaceholder'))}">`
|
|
192
|
+
+ `<button type="submit" class="asst-btn asst-run-steer-send">${esc(st8('runSteerSend'))}</button>`
|
|
193
|
+
+ (typeof onUseComposer === 'function' ? `<button type="button" class="asst-tb-btn asst-run-steer-composer" aria-label="${esc(st8('useComposer'))}" data-tooltip="${esc(st8('useComposer'))}">${ICON_STEER}</button>` : '')
|
|
194
|
+
+ `<button type="button" class="asst-tb-btn asst-run-steer-cancel" aria-label="${esc(st8('runSteerCancel'))}" data-tooltip="${esc(st8('runSteerCancel'))}">${ICON_CLOSE_SMALL}</button>`;
|
|
195
|
+
const input = box.querySelector('input');
|
|
196
|
+
const close = ({ refocus = true } = {}) => {
|
|
197
|
+
box.remove();
|
|
198
|
+
if (refocus) card.querySelector('[data-action="steer"]')?.focus();
|
|
199
|
+
};
|
|
200
|
+
let sending = false;
|
|
201
|
+
const send = async () => {
|
|
202
|
+
const text = input.value.trim();
|
|
203
|
+
if (!text || sending) return;
|
|
204
|
+
sending = true;
|
|
205
|
+
input.disabled = true;
|
|
206
|
+
let ok = false;
|
|
207
|
+
try { ok = await onSubmit?.(card.dataset.runId, text); } catch { ok = false; }
|
|
208
|
+
sending = false;
|
|
209
|
+
input.disabled = false;
|
|
210
|
+
if (ok) close({ refocus: false });
|
|
211
|
+
else input.focus();
|
|
212
|
+
};
|
|
213
|
+
box.addEventListener('submit', (e) => { e.preventDefault(); send(); });
|
|
214
|
+
// Enter is read here, on the input itself, never left to the form's implicit submission: a handler of the page
|
|
215
|
+
// that cancels Enter (a capture-phase keydown of the document, the panel's) would stop that submission silently.
|
|
216
|
+
input.addEventListener('keydown', (e) => {
|
|
217
|
+
if (e.key !== 'Enter' || e.isComposing || e.keyCode === 229 || e.shiftKey || e.altKey) return;
|
|
218
|
+
e.preventDefault();
|
|
219
|
+
e.stopPropagation();
|
|
220
|
+
send();
|
|
221
|
+
});
|
|
222
|
+
box.addEventListener('keydown', (e) => {
|
|
223
|
+
e.stopPropagation(); // single-letter global keybinds stay out of the input
|
|
224
|
+
if (e.key === 'Escape') { e.preventDefault(); close(); }
|
|
225
|
+
});
|
|
226
|
+
box.addEventListener('click', (e) => e.stopPropagation());
|
|
227
|
+
box.querySelector('.asst-run-steer-cancel').addEventListener('click', () => close());
|
|
228
|
+
box.querySelector('.asst-run-steer-composer')?.addEventListener('click', () => {
|
|
229
|
+
const text = input.value;
|
|
230
|
+
close({ refocus: false });
|
|
231
|
+
onUseComposer(card.dataset.runId, text);
|
|
232
|
+
});
|
|
233
|
+
box._send = send; // tests
|
|
234
|
+
const meta = card.querySelector(':scope > .asst-run-meta');
|
|
235
|
+
if (meta) meta.after(box); else card.appendChild(box);
|
|
236
|
+
input.focus();
|
|
237
|
+
return box;
|
|
238
|
+
}
|
|
239
|
+
|
|
170
240
|
// ── Run cards (shared with the agents dock) ────────────────────────────────
|
|
171
241
|
|
|
172
242
|
/**
|
|
@@ -201,6 +271,11 @@ export function buildRunCard(run, opts = {}) {
|
|
|
201
271
|
};
|
|
202
272
|
mk('focus', t('assistant.run.focus', 'Focus in sidepanel'), '<svg viewBox="0 0 24 24"><path d="M15 3h6v6"/><path d="M10 14 21 3"/><path d="M21 14v5a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5"/></svg>', opts.onFocus);
|
|
203
273
|
mk('read', t('assistant.run.read', 'Read result'), '<svg viewBox="0 0 24 24"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><path d="M14 2v6h6"/><path d="M16 13H8M16 17H8"/></svg>', opts.onRead);
|
|
274
|
+
// Steer: a one-line input under the card, sent to this run (asst-steer.js; only while the run is not over).
|
|
275
|
+
if (typeof opts.onSteer === 'function') {
|
|
276
|
+
const st8 = steerTranslator(opts.t, opts.locale);
|
|
277
|
+
mk('steer', st8('runSteer'), ICON_STEER, () => openRunSteerInput(card, { t: opts.t, locale: opts.locale, onSubmit: opts.onSteer, onUseComposer: opts.onSteerInComposer }));
|
|
278
|
+
}
|
|
204
279
|
mk('stop', t('assistant.run.stop', 'Stop run'), '<svg viewBox="0 0 24 24"><rect x="6" y="6" width="12" height="12" rx="2"/></svg>', opts.onStop);
|
|
205
280
|
// The agents tray only: a finished run can be removed from it.
|
|
206
281
|
if (typeof opts.onRemove === 'function') mk('remove', t('assistant.run.remove', 'Remove from list'), '<svg viewBox="0 0 24 24"><path d="M3 6h18"/><path d="M8 6V4h8v2"/><path d="M19 6l-1 14H6L5 6"/></svg>', opts.onRemove).hidden = true;
|
|
@@ -287,6 +362,14 @@ export function updateRunCard(card, run, opts = {}) {
|
|
|
287
362
|
if (removeBtn) { removeBtn.hidden = !removable; removeBtn.disabled = !removable; }
|
|
288
363
|
const readBtn = card.querySelector('[data-action="read"]');
|
|
289
364
|
if (readBtn) readBtn.disabled = run.status === 'queued';
|
|
365
|
+
const steerBtn = card.querySelector('[data-action="steer"]');
|
|
366
|
+
if (steerBtn) {
|
|
367
|
+
const steerable = canSteerRun(run);
|
|
368
|
+
steerBtn.hidden = !steerable;
|
|
369
|
+
steerBtn.disabled = !steerable;
|
|
370
|
+
if (!steerable) card.querySelector(':scope > .asst-run-steer')?.remove();
|
|
371
|
+
}
|
|
372
|
+
card.classList.toggle('is-steering', isSteering(run));
|
|
290
373
|
|
|
291
374
|
// A provider's usage limit stopped it: the waiting card, whose Retry now stands in for "Retry on" the same model.
|
|
292
375
|
const limitShown = syncRunLimit(card, run, opts, t);
|
|
@@ -499,11 +582,14 @@ const PREVIEW_LINES = 5;
|
|
|
499
582
|
const THINK_PREVIEW_LINES = 10;
|
|
500
583
|
const MAX_DIFF_LINES = 400; // an edit's mini diff draws this many lines; "Show full input" draws the rest
|
|
501
584
|
// The empty state's suggestions (asst-panel.js ids) and the kind each one is about.
|
|
585
|
+
// A tool result that only says its command went on in the background (OpenCode 2.3): none of the output is in it.
|
|
586
|
+
const isBackgroundNotice = (result) => typeof result === 'string' && /^Command moved to the background \(shell ID: /.test(result);
|
|
502
587
|
const SUGGESTION_KINDS = { computer: 'computer', web: 'web', fix: 'edit', skill: 'skill', schedule: 'plan', remember: 'memory' };
|
|
503
588
|
|
|
504
589
|
/**
|
|
505
590
|
* createRenderer(transcriptEl, hooks)
|
|
506
591
|
* hooks: { t, providerIcon(provider), providerColor(provider), onFocusRun, onStopRun, onReadRun, onEscalateRun,
|
|
592
|
+
* onSteerRun(runId, text) → truthy when sent, onSteerRunInComposer(runId, text), locale() (asst-steer.js),
|
|
507
593
|
* onMemoryClick(id), onResult(ev), onInit(ev), onModeChanged(mode), copy(text),
|
|
508
594
|
* emptySuggestions() → [{ id, label, template }], onSuggestion(template),
|
|
509
595
|
* brainLabel() → string, onChangeRoutes(), onRouteEvent(ev) → bool (true = handled by an open card),
|
|
@@ -582,6 +668,16 @@ export function createRenderer(transcriptEl, hooks = {}) {
|
|
|
582
668
|
const askCards = new Set(); // { el, presenter, isOpen(), onChange, seq }
|
|
583
669
|
let askSeq = 0;
|
|
584
670
|
let lastTextRow = null; // the newest root message since the user's last prompt: the one a guess reads
|
|
671
|
+
// Streamed rows a turn's end sealed, by message id: the message they are can still arrive after that end (a steer
|
|
672
|
+
// or a Stop cut the reply; Claude Code sends the cut message late) and then takes the row's place, never the end.
|
|
673
|
+
const sealedRows = new Map();
|
|
674
|
+
// A steer of the brain read from the journal: drawn where its prompt is (after what the cut turn still sent).
|
|
675
|
+
let pendingSteer = null;
|
|
676
|
+
// The journal's own sealedRows (a replay streams nothing): where each message of the turn being read was drawn, by
|
|
677
|
+
// id, and the messages of the turn a steer cut, whose final can still come after the steer's prompt.
|
|
678
|
+
let journalMsgs = new Map();
|
|
679
|
+
let cutMsgs = new Map();
|
|
680
|
+
let lastAssistantRow = null; // what the newest assistant event drew (the journal keeps where each message is)
|
|
585
681
|
|
|
586
682
|
// ── Activity racks ──
|
|
587
683
|
// Every burst of agent work (tool calls, thinking, short narration) is one
|
|
@@ -1172,6 +1268,11 @@ export function createRenderer(transcriptEl, hooks = {}) {
|
|
|
1172
1268
|
if (!s?.row || !s.bodyEl || !s.textBuf.trim()) return;
|
|
1173
1269
|
s.row.classList.remove('streaming');
|
|
1174
1270
|
paintMessage(s.row, s.bodyEl, s.textBuf, { scope });
|
|
1271
|
+
s.row._turnSealed = true; // its turn ended: what is drawn after it belongs below the reply
|
|
1272
|
+
if (s.msgId) {
|
|
1273
|
+
sealedRows.set(s.msgId, { row: s.row, bodyEl: s.bodyEl, scope });
|
|
1274
|
+
while (sealedRows.size > 20) sealedRows.delete(sealedRows.keys().next().value);
|
|
1275
|
+
}
|
|
1175
1276
|
}
|
|
1176
1277
|
|
|
1177
1278
|
/** The stream's text row goes (the final message renders the text again). */
|
|
@@ -1356,14 +1457,31 @@ export function createRenderer(transcriptEl, hooks = {}) {
|
|
|
1356
1457
|
const texts = content.filter(b => b?.type === 'text' && typeof b.text === 'string');
|
|
1357
1458
|
const tools = content.filter(b => b?.type === 'tool_use' && b.name !== 'AskUserQuestion'); // AskUserQuestion: a control card
|
|
1358
1459
|
const ctx = { msgId: message?.id || scope.msgId || null, claude: !!ev?.uuid };
|
|
1460
|
+
// The final message of a reply a turn's end already sealed (a steer cut it): its text goes into that row, where
|
|
1461
|
+
// the reply was, whatever was drawn after it and whatever streams now.
|
|
1462
|
+
const sealed = message?.id && scope.stream?.msgId !== message.id ? sealedRows.get(message.id) : null;
|
|
1463
|
+
if (sealed && sealed.scope === scope && sealed.row.isConnected && texts.length && !tools.length && !thinks.length) {
|
|
1464
|
+
const rawText = texts.map(b => b.text).join('\n');
|
|
1465
|
+
if (rawText.trim()) {
|
|
1466
|
+
sealed.row._text = rawText;
|
|
1467
|
+
paintMessage(sealed.row, sealed.bodyEl, rawText, { scope });
|
|
1468
|
+
(scope.kept ||= new Set()).add(textKey(rawText));
|
|
1469
|
+
}
|
|
1470
|
+
return sealed.row;
|
|
1471
|
+
}
|
|
1359
1472
|
// Text and thinking replace what was streamed for them. A tool-only message
|
|
1360
1473
|
// (Codex/OpenCode send each call mid-stream; the SDK one per block) keeps the
|
|
1361
1474
|
// streamed text as a row and closes it, so later deltas start below.
|
|
1362
1475
|
const s = scope.stream;
|
|
1363
1476
|
const liveText = !!s?.textBuf.trim();
|
|
1364
1477
|
const streamedThink = s?.think || null;
|
|
1478
|
+
// The streamed row's place: the message's text row takes it (rows drawn after it, such as a status, stay below).
|
|
1479
|
+
// A reply whose turn already ended (a steer or a Stop cut it, its final message came late): the message takes the
|
|
1480
|
+
// streamed row's place, above what the end drew ("Interrupted.", the usage line, the steer's notice).
|
|
1481
|
+
let slot = null;
|
|
1365
1482
|
if (s) {
|
|
1366
1483
|
flushStream(scope);
|
|
1484
|
+
if (texts.length && s.row?.isConnected && s.row._turnSealed) slot = s.row.nextElementSibling || null;
|
|
1367
1485
|
if (texts.length) dropStreamText(scope);
|
|
1368
1486
|
else if (s.row) {
|
|
1369
1487
|
s.row.classList.remove('streaming');
|
|
@@ -1392,6 +1510,7 @@ export function createRenderer(transcriptEl, hooks = {}) {
|
|
|
1392
1510
|
foldNarration(rack, null, rawMd.trim());
|
|
1393
1511
|
} else row = textRow(scope, rawMd, ctx);
|
|
1394
1512
|
}
|
|
1513
|
+
if (slot && row && slot.isConnected && slot.parentNode === row.parentNode && slot !== row) slot.before(row);
|
|
1395
1514
|
const fresh = [];
|
|
1396
1515
|
for (const block of tools) {
|
|
1397
1516
|
const known = block.id ? stepsById.get(block.id) : null;
|
|
@@ -1446,6 +1565,7 @@ export function createRenderer(transcriptEl, hooks = {}) {
|
|
|
1446
1565
|
step.endedAt = nowMs();
|
|
1447
1566
|
step.timed = step.timed && isTimed();
|
|
1448
1567
|
if (step.kind === 'runs') noteAgentResult(text);
|
|
1568
|
+
if (step.shell) applyShellOutcome(step);
|
|
1449
1569
|
refreshStep(step);
|
|
1450
1570
|
if (step.bodyBuilt) fillCallBody(step);
|
|
1451
1571
|
if (step.state === 'error') onFailure(step);
|
|
@@ -1473,9 +1593,89 @@ export function createRenderer(transcriptEl, hooks = {}) {
|
|
|
1473
1593
|
placeStep(rack, step);
|
|
1474
1594
|
if (!muted && turnActive && !step.auto) { turn.calls += 1; turn.last = step; }
|
|
1475
1595
|
if (rack.steps.length === 1 && !muted && turnActive) announce(rack, stepSentence(step, step.state === 'running'));
|
|
1596
|
+
if (step.kind === 'shell') syncShell(step); // its command may be known already (a panel that attached mid-run)
|
|
1476
1597
|
return step;
|
|
1477
1598
|
}
|
|
1478
1599
|
|
|
1600
|
+
// ── A shell call's command (an OpenCode brain: asst-shell-logic.js) ──
|
|
1601
|
+
/** What the runtime says about the call's command: the row's state word, its failure, its terminal block. */
|
|
1602
|
+
function syncShell(step) {
|
|
1603
|
+
const shell = hooks.shells?.forCall?.(step.id) || null;
|
|
1604
|
+
if (!shell) return;
|
|
1605
|
+
const wasRunning = step.shell?.status === 'running';
|
|
1606
|
+
step.shell = shell;
|
|
1607
|
+
if (wasRunning && shell.status !== 'running' && step.state !== 'running') step.endedAt = nowMs();
|
|
1608
|
+
// OpenCode announces a call before its input: the row and the stage read the command from here then.
|
|
1609
|
+
const learned = !commandOf(step.input || {}) && !!shell.command;
|
|
1610
|
+
if (learned) step.input = canonicalToolInput({ ...(step.input || {}), command: shell.command });
|
|
1611
|
+
applyShellOutcome(step);
|
|
1612
|
+
refreshStep(step);
|
|
1613
|
+
if (learned && step.bodyBuilt) fillCallBody(step);
|
|
1614
|
+
// The turn was told over before its command (a Stop): the row settles now, as it would have at the turn's end.
|
|
1615
|
+
if (wasRunning && shell.status !== 'running' && !turnActive) foldShellRows();
|
|
1616
|
+
if (shell.status === 'running' && (shell.waited || turnActive)) openForShell(step);
|
|
1617
|
+
syncTerminal(step);
|
|
1618
|
+
}
|
|
1619
|
+
|
|
1620
|
+
/** A command that failed after its tool call had answered (it went on in the background) fails the call. */
|
|
1621
|
+
function applyShellOutcome(step) {
|
|
1622
|
+
if (step.state !== 'ok' || !hooks.shells?.failedLate?.(step.shell)) return;
|
|
1623
|
+
step.state = 'error';
|
|
1624
|
+
step.code = typeof step.shell.exit === 'number' ? step.shell.exit : null;
|
|
1625
|
+
onFailure(step);
|
|
1626
|
+
}
|
|
1627
|
+
|
|
1628
|
+
/** A running command's output is on screen without a click, unless the reader closed that row. */
|
|
1629
|
+
function openForShell(step) {
|
|
1630
|
+
const { rack, station: st } = step;
|
|
1631
|
+
if (!st || st.userSet || rack.userSet) return;
|
|
1632
|
+
if (!st.open) { st.autoOpened = true; setStationOpen(rack, st, true); }
|
|
1633
|
+
if (!rack.open && !rack.staged) { rack.autoOpened = true; setRackOpen(rack, true); }
|
|
1634
|
+
}
|
|
1635
|
+
|
|
1636
|
+
/** A block exists only while its row is open: a closed row costs no text in the page and no polling. */
|
|
1637
|
+
function syncTerminal(step) {
|
|
1638
|
+
if (!step.shell || !step.station?.open) {
|
|
1639
|
+
if (step.terminal) { step.terminal.dispose(); step.terminal = null; }
|
|
1640
|
+
return;
|
|
1641
|
+
}
|
|
1642
|
+
if (!step.bodyBuilt) buildCallBody(step);
|
|
1643
|
+
else if (!step.terminal) fillCallBody(step);
|
|
1644
|
+
}
|
|
1645
|
+
|
|
1646
|
+
/** The block of a shell call whose row is open (made once; a rebuilt body takes the same one). */
|
|
1647
|
+
function terminalOf(step) {
|
|
1648
|
+
if (!step.shell || !step.station?.open || !hooks.shells?.terminal) return null;
|
|
1649
|
+
step.terminal ||= hooks.shells.terminal(step.shell.id, {
|
|
1650
|
+
onDraw: () => scrollEnd(),
|
|
1651
|
+
onGone: () => { if (step.bodyBuilt) fillCallBody(step); },
|
|
1652
|
+
});
|
|
1653
|
+
return step.terminal;
|
|
1654
|
+
}
|
|
1655
|
+
|
|
1656
|
+
/** The turn ended: rows opened for a command fold again, unless one failed or the model still waits for it. */
|
|
1657
|
+
function foldShellRows() {
|
|
1658
|
+
for (const rack of racks) {
|
|
1659
|
+
for (const st of rack.stations.values()) {
|
|
1660
|
+
if (!st.autoOpened) continue;
|
|
1661
|
+
if (st.userSet || rack.userSet) { st.autoOpened = false; continue; }
|
|
1662
|
+
if (st.steps.some(s => s.shell?.status === 'running' && s.shell.waited)) continue;
|
|
1663
|
+
st.autoOpened = false;
|
|
1664
|
+
if (st.steps.some(s => s.state === 'error')) { if (!rack.open) setRackOpen(rack, true); continue; }
|
|
1665
|
+
setStationOpen(rack, st, false);
|
|
1666
|
+
if (rack.autoOpened) { rack.autoOpened = false; setRackOpen(rack, false); }
|
|
1667
|
+
}
|
|
1668
|
+
}
|
|
1669
|
+
}
|
|
1670
|
+
|
|
1671
|
+
/** The runtime's word on a command changed (asst-panel.js): its call's row follows, wherever it is. */
|
|
1672
|
+
function noteShell(shell) {
|
|
1673
|
+
const step = shell?.callID ? stepsById.get(shell.callID) : null;
|
|
1674
|
+
if (!step || step.type !== 'call' || step.kind !== 'shell') return;
|
|
1675
|
+
syncShell(step);
|
|
1676
|
+
renderRack(step.rack);
|
|
1677
|
+
}
|
|
1678
|
+
|
|
1479
1679
|
/** The final block of a streamed call, or the same block replayed: the step learns its input, nothing is added. */
|
|
1480
1680
|
function updateCall(step, block) {
|
|
1481
1681
|
if (block.name) step.name = block.name;
|
|
@@ -1665,7 +1865,7 @@ export function createRenderer(transcriptEl, hooks = {}) {
|
|
|
1665
1865
|
};
|
|
1666
1866
|
row._rack = rack;
|
|
1667
1867
|
motion.watch(row); // its sweep, ticks and scene loop only while it is on screen
|
|
1668
|
-
rack.receipt.btn.addEventListener('click', () => setRackOpen(rack, !rack.open));
|
|
1868
|
+
rack.receipt.btn.addEventListener('click', () => { rack.userSet = true; setRackOpen(rack, !rack.open); });
|
|
1669
1869
|
row.querySelector('.asst-rack-view').addEventListener('click', (e) => {
|
|
1670
1870
|
const btn = e.target.closest('button[data-view]');
|
|
1671
1871
|
if (btn) setRackView(rack, btn.dataset.view);
|
|
@@ -1673,7 +1873,7 @@ export function createRenderer(transcriptEl, hooks = {}) {
|
|
|
1673
1873
|
rack.ledger.addEventListener('click', (e) => {
|
|
1674
1874
|
const hdr = e.target.closest('.asst-station-hdr');
|
|
1675
1875
|
const owner = hdr ? headers.get(hdr) : null;
|
|
1676
|
-
if (owner?.rack === rack) setStationOpen(rack, owner.st, !owner.st.open);
|
|
1876
|
+
if (owner?.rack === rack) { owner.st.userSet = true; setStationOpen(rack, owner.st, !owner.st.open); }
|
|
1677
1877
|
});
|
|
1678
1878
|
rack.ledger.addEventListener('keydown', (e) => onLedgerKey(rack, e));
|
|
1679
1879
|
rack.stage.subject.addEventListener('click', () => setBubbleOpen(rack, !rack.bubble.open));
|
|
@@ -1712,6 +1912,7 @@ export function createRenderer(transcriptEl, hooks = {}) {
|
|
|
1712
1912
|
st.hdr.setAttribute('aria-expanded', st.open ? 'true' : 'false');
|
|
1713
1913
|
st.log.hidden = !st.open && st.kind !== 'computer';
|
|
1714
1914
|
if (st.open) for (const step of st.steps) buildCallBody(step);
|
|
1915
|
+
for (const step of st.steps) if (step.kind === 'shell') syncTerminal(step);
|
|
1715
1916
|
renderStationFace(rack, st);
|
|
1716
1917
|
}
|
|
1717
1918
|
|
|
@@ -1744,8 +1945,8 @@ export function createRenderer(transcriptEl, hooks = {}) {
|
|
|
1744
1945
|
else if (e.key === 'ArrowUp') next = list[Math.max(0, at - 1)];
|
|
1745
1946
|
else if (e.key === 'Home') next = list[0];
|
|
1746
1947
|
else if (e.key === 'End') next = list[list.length - 1];
|
|
1747
|
-
else if (e.key === 'ArrowRight') { e.preventDefault(); if (!owner.st.open) setStationOpen(rack, owner.st, true); return; }
|
|
1748
|
-
else if (e.key === 'ArrowLeft') { e.preventDefault(); if (owner.st.open) setStationOpen(rack, owner.st, false); return; }
|
|
1948
|
+
else if (e.key === 'ArrowRight') { e.preventDefault(); owner.st.userSet = true; if (!owner.st.open) setStationOpen(rack, owner.st, true); return; }
|
|
1949
|
+
else if (e.key === 'ArrowLeft') { e.preventDefault(); owner.st.userSet = true; if (owner.st.open) setStationOpen(rack, owner.st, false); return; }
|
|
1749
1950
|
else return;
|
|
1750
1951
|
e.preventDefault();
|
|
1751
1952
|
if (!next) return;
|
|
@@ -2781,8 +2982,12 @@ export function createRenderer(transcriptEl, hooks = {}) {
|
|
|
2781
2982
|
else if (step.state === 'error') state = t('assistant.tool.error', 'error');
|
|
2782
2983
|
else if (step.state === 'neutral') state = t('assistant.rack.state.noMatches', 'no matches');
|
|
2783
2984
|
else if (step.state === 'ok') state = t('assistant.tool.done', 'done');
|
|
2985
|
+
if (step.shell) {
|
|
2986
|
+
state = hooks.shells?.label?.(step.shell) || state;
|
|
2987
|
+
li.dataset.shell = step.shell.status;
|
|
2988
|
+
}
|
|
2784
2989
|
q('.asst-tool-state').textContent = state;
|
|
2785
|
-
q('.asst-tool-time').textContent = step.endedAt && step.timed ? fmtDuration(step.endedAt - step.startedAt, t) : '';
|
|
2990
|
+
q('.asst-tool-time').textContent = step.endedAt && step.timed && step.shell?.status !== 'running' ? fmtDuration(step.endedAt - step.startedAt, t) : '';
|
|
2786
2991
|
}
|
|
2787
2992
|
|
|
2788
2993
|
/** Bodies are built on first expand: a replayed history costs a header per call. */
|
|
@@ -2811,6 +3016,8 @@ export function createRenderer(transcriptEl, hooks = {}) {
|
|
|
2811
3016
|
}
|
|
2812
3017
|
// Keep a Show toggle's keyboard focus across the rebuild below.
|
|
2813
3018
|
const refocus = body.contains(document.activeElement) && document.activeElement.classList.contains('asst-reveal');
|
|
3019
|
+
// The reader's place in a terminal block survives it too (the block goes back in below).
|
|
3020
|
+
const inTerminal = step.terminal?.el.contains(document.activeElement) ? document.activeElement : null;
|
|
2814
3021
|
body.textContent = '';
|
|
2815
3022
|
const input = step.input || {};
|
|
2816
3023
|
const say = sayOf(step);
|
|
@@ -2857,10 +3064,21 @@ export function createRenderer(transcriptEl, hooks = {}) {
|
|
|
2857
3064
|
default:
|
|
2858
3065
|
inputSection(body, step, red);
|
|
2859
3066
|
}
|
|
2860
|
-
|
|
3067
|
+
// A command with a terminal block shows what it printed there; the call's own result is the fallback once
|
|
3068
|
+
// OpenCode no longer has that output.
|
|
3069
|
+
const terminal = step.kind === 'shell' ? terminalOf(step) : null;
|
|
3070
|
+
if (terminal) body.appendChild(terminal.el);
|
|
3071
|
+
const outputGone = !!terminal && !!hooks.shells?.view?.(step.shell.id)?.gone;
|
|
3072
|
+
if (step.result && step.kind !== 'plan' && (!terminal || (outputGone && !isBackgroundNotice(step.result)))) {
|
|
2861
3073
|
const output = hidden ? maskEcho(step.result, hidden, t) : step.result;
|
|
2862
3074
|
section(body, t('assistant.rack.body.output', 'Output'), output, { copy: true });
|
|
3075
|
+
// The result only says the command went on, and nobody can read what it printed any more.
|
|
3076
|
+
if (!terminal && step.kind === 'shell' && hooks.shells?.supported?.() && isBackgroundNotice(step.result)) {
|
|
3077
|
+
body.appendChild(el('div', 'asst-term-note', t('assistant.rack.shell.gone', 'OpenCode no longer keeps the output of this command.')));
|
|
3078
|
+
}
|
|
2863
3079
|
}
|
|
3080
|
+
terminal?.show();
|
|
3081
|
+
inTerminal?.focus({ preventScroll: true });
|
|
2864
3082
|
if (!body.children.length) { body.remove(); return; }
|
|
2865
3083
|
if (refocus) body.querySelector('.asst-reveal')?.focus({ preventScroll: true });
|
|
2866
3084
|
}
|
|
@@ -3068,6 +3286,7 @@ export function createRenderer(transcriptEl, hooks = {}) {
|
|
|
3068
3286
|
rack.clearTimer = 0;
|
|
3069
3287
|
rack.sr.timer = 0;
|
|
3070
3288
|
rack.holdTimer = 0;
|
|
3289
|
+
for (const step of rack.steps) if (step.terminal) { step.terminal.dispose(); step.terminal = null; }
|
|
3071
3290
|
const had = !!rack.rig;
|
|
3072
3291
|
rack.rig?.destroy?.();
|
|
3073
3292
|
rack.rig = null;
|
|
@@ -3173,6 +3392,31 @@ export function createRenderer(transcriptEl, hooks = {}) {
|
|
|
3173
3392
|
return row;
|
|
3174
3393
|
}
|
|
3175
3394
|
|
|
3395
|
+
/**
|
|
3396
|
+
* A Stop that could not end a command in the background (the runtime's `stop_failed`): the reason as an error row,
|
|
3397
|
+
* and from the second failure of the turn a "Stop anyway" button (`onForce`). The row of an earlier failure goes:
|
|
3398
|
+
* one row says what holds now.
|
|
3399
|
+
*/
|
|
3400
|
+
let stopFailureRow = null;
|
|
3401
|
+
function appendStopFailure(text, { forceLabel = '', onForce = null } = {}) {
|
|
3402
|
+
clearStopFailure();
|
|
3403
|
+
const row = appendStatus(text, 'error');
|
|
3404
|
+
if (!row) return null;
|
|
3405
|
+
row.classList.add('asst-stop-failed');
|
|
3406
|
+
if (forceLabel && typeof onForce === 'function') {
|
|
3407
|
+
const button = el('button', 'asst-btn asst-btn-secondary asst-stop-anyway', forceLabel);
|
|
3408
|
+
button.type = 'button';
|
|
3409
|
+
button.addEventListener('click', () => { button.disabled = true; onForce(); });
|
|
3410
|
+
row.appendChild(button);
|
|
3411
|
+
}
|
|
3412
|
+
stopFailureRow = row;
|
|
3413
|
+
return row;
|
|
3414
|
+
}
|
|
3415
|
+
function clearStopFailure() {
|
|
3416
|
+
stopFailureRow?.remove?.();
|
|
3417
|
+
stopFailureRow = null;
|
|
3418
|
+
}
|
|
3419
|
+
|
|
3176
3420
|
function appendDivider(label) {
|
|
3177
3421
|
return append(el('div', 'asst-divider', label || ''));
|
|
3178
3422
|
}
|
|
@@ -3286,6 +3530,9 @@ export function createRenderer(transcriptEl, hooks = {}) {
|
|
|
3286
3530
|
onStop: hooks.onStopRun,
|
|
3287
3531
|
onRead: hooks.onReadRun,
|
|
3288
3532
|
onEscalate: hooks.onEscalateRun,
|
|
3533
|
+
onSteer: hooks.onSteerRun,
|
|
3534
|
+
onSteerInComposer: hooks.onSteerRunInComposer,
|
|
3535
|
+
locale: hooks.locale,
|
|
3289
3536
|
onLimitWait: (run, limit) => limitDock.set(`run:${run.runId}`, limit ? {
|
|
3290
3537
|
resetsAt: limit.resetsAt || null,
|
|
3291
3538
|
since: Date.parse(limit.detectedAt || run.completedAt || '') || nowMs(),
|
|
@@ -3998,6 +4245,7 @@ export function createRenderer(transcriptEl, hooks = {}) {
|
|
|
3998
4245
|
return true;
|
|
3999
4246
|
case 'assistant': {
|
|
4000
4247
|
const row = ev.message ? renderAssistant(ev.message, scope, ev) : null;
|
|
4248
|
+
lastAssistantRow = row;
|
|
4001
4249
|
if (row && ev.error && row.classList.contains('asst-msg')) { // a synthetic API-error message
|
|
4002
4250
|
row.classList.add('asst-msg-error');
|
|
4003
4251
|
const content = Array.isArray(ev.message.content) ? ev.message.content : [];
|
|
@@ -4081,7 +4329,7 @@ export function createRenderer(transcriptEl, hooks = {}) {
|
|
|
4081
4329
|
if (ev.run) upsertRunCard(ev.run, { result: ev.result ?? null });
|
|
4082
4330
|
return true;
|
|
4083
4331
|
case 'synabun.user_prompt':
|
|
4084
|
-
if ((!silent || replayDraw) && ev.text)
|
|
4332
|
+
if ((!silent || replayDraw) && ev.text) userPrompt(String(ev.text), { origin: ev.origin || null, imageCount: ev.images });
|
|
4085
4333
|
return true;
|
|
4086
4334
|
case 'synabun.error':
|
|
4087
4335
|
appendError(ev.message);
|
|
@@ -4160,6 +4408,7 @@ export function createRenderer(transcriptEl, hooks = {}) {
|
|
|
4160
4408
|
else if (!stage.holdTimer) stage.holdUntil = 0; // a hold already running (the `done` after a result) keeps its time
|
|
4161
4409
|
}
|
|
4162
4410
|
endBursts(rootScope);
|
|
4411
|
+
foldShellRows();
|
|
4163
4412
|
for (const rack of [...racks]) {
|
|
4164
4413
|
const tail = liveTail(rack.scope) === rack;
|
|
4165
4414
|
rack.closed = true;
|
|
@@ -4180,12 +4429,14 @@ export function createRenderer(transcriptEl, hooks = {}) {
|
|
|
4180
4429
|
let firstError = null;
|
|
4181
4430
|
// The replay a reattach sends next repeats part of this window: planReplay leaves it out.
|
|
4182
4431
|
snapshot = { keys: new Set(), at: -Infinity, seq: -Infinity };
|
|
4432
|
+
pendingSteer = null;
|
|
4183
4433
|
for (const entry of list) {
|
|
4184
4434
|
if (!entry || typeof entry !== 'object') continue;
|
|
4185
4435
|
// An entry that cannot be drawn costs that entry, never the rest of the history.
|
|
4186
4436
|
try { renderEntry(entry); } catch (err) { failed += 1; firstError ||= err; }
|
|
4187
4437
|
}
|
|
4188
4438
|
if (failed) console.warn(`[assistant] ${failed} of ${list.length} transcript entries could not be drawn`, firstError);
|
|
4439
|
+
{ const was = muted; muted = true; try { flushPendingSteer(); } finally { muted = was; } }
|
|
4189
4440
|
flushStream(rootScope);
|
|
4190
4441
|
sealStreamRow(rootScope);
|
|
4191
4442
|
if (rootScope.stream?.row) rootScope.stream.row.classList.remove('streaming');
|
|
@@ -4207,20 +4458,96 @@ export function createRenderer(transcriptEl, hooks = {}) {
|
|
|
4207
4458
|
finally { muted = was.muted; clockAt = was.clockAt; }
|
|
4208
4459
|
}
|
|
4209
4460
|
|
|
4461
|
+
/**
|
|
4462
|
+
* A steer read from the journal or a prompt that carries one, drawn as the live view drew it: the cut turn's
|
|
4463
|
+
* "Interrupted.", the break and the notice (hooks.onSteerEntry, the panel's), never the model's [SynaBun Steer] line.
|
|
4464
|
+
*/
|
|
4465
|
+
function drawSteer(steer) {
|
|
4466
|
+
if (!steer) return;
|
|
4467
|
+
try { hooks.onSteerEntry?.(steer); } catch { /* the panel is gone */ }
|
|
4468
|
+
}
|
|
4469
|
+
function flushPendingSteer() {
|
|
4470
|
+
const steer = pendingSteer;
|
|
4471
|
+
pendingSteer = null;
|
|
4472
|
+
drawSteer(steer);
|
|
4473
|
+
}
|
|
4474
|
+
/** A user prompt row, or the steer it is (its words in the notice). */
|
|
4475
|
+
function userPrompt(text, opts = {}) {
|
|
4476
|
+
const steered = steerPromptText(text);
|
|
4477
|
+
if (steered === null) { flushPendingSteer(); appendUser(text, opts); return; }
|
|
4478
|
+
// Live (and in a reattach's replay) the 'steered' packet drew the notice already; from the journal
|
|
4479
|
+
// (renderTranscript) it waits here (pendingSteer).
|
|
4480
|
+
if (!muted || replayDraw) { pendingSteer = null; return; }
|
|
4481
|
+
const steer = pendingSteer || { target: 'brain', text: steered, cut: true };
|
|
4482
|
+
// The cut reply's final message can still follow (Claude Code sends it late): the steer is drawn once it is in.
|
|
4483
|
+
if (cutMsgs.size) { pendingSteer = { ...steer, prompted: true }; return; }
|
|
4484
|
+
pendingSteer = null;
|
|
4485
|
+
drawSteer(steer);
|
|
4486
|
+
}
|
|
4487
|
+
|
|
4488
|
+
/** The message an assistant journal entry carries, or null. */
|
|
4489
|
+
function journalMessage(packet, role) {
|
|
4490
|
+
if (packet.type === 'event') return packet.event?.type === 'assistant' ? packet.event.message || null : null;
|
|
4491
|
+
if (role === 'assistant') return packet.message || (packet.content ? packet : null);
|
|
4492
|
+
return null;
|
|
4493
|
+
}
|
|
4494
|
+
|
|
4495
|
+
/**
|
|
4496
|
+
* A late final of a reply a steer cut, read from the journal: it takes the place of what that message drew (its
|
|
4497
|
+
* partial text row goes, a thinking rack stays above it), as renderAssistant's sealed rows do live.
|
|
4498
|
+
*/
|
|
4499
|
+
function drawCutFinal(msg, draw) {
|
|
4500
|
+
const anchor = cutMsgs.get(msg.id)?.anchor;
|
|
4501
|
+
const row = draw();
|
|
4502
|
+
if (!row || !anchor?.isConnected || row === anchor) return;
|
|
4503
|
+
anchor.after(row);
|
|
4504
|
+
if (anchor._msgId === msg.id && anchor.classList.contains('msg-assistant') && row._text) anchor.remove();
|
|
4505
|
+
// The cut turn's usage / route lines (journaled before this late final; a partial that drew no row anchors on
|
|
4506
|
+
// its own automation row) go under the reply, as live: the panel's steerEntry then puts "Interrupted." above them.
|
|
4507
|
+
const trailing = [];
|
|
4508
|
+
for (let above = row.previousElementSibling; above?.classList.contains('asst-route-line'); above = above.previousElementSibling) trailing.unshift(above);
|
|
4509
|
+
if (trailing.length) row.after(...trailing);
|
|
4510
|
+
cutMsgs.set(msg.id, { anchor: row });
|
|
4511
|
+
}
|
|
4512
|
+
|
|
4210
4513
|
function drawEntry(entry) {
|
|
4211
4514
|
const packet = entry.packet && typeof entry.packet === 'object' ? entry.packet : entry;
|
|
4212
4515
|
const role = packet.role || packet.type;
|
|
4516
|
+
const msg = journalMessage(packet, role);
|
|
4517
|
+
if (msg?.id && cutMsgs.has(msg.id)) { drawCutFinal(msg, () => drawEntryRow(packet, role)); return; }
|
|
4518
|
+
// Anything else after the steer's prompt: the cut turn is over, its steer is drawn first.
|
|
4519
|
+
if (pendingSteer?.prompted) { cutMsgs = new Map(); flushPendingSteer(); }
|
|
4520
|
+
const row = drawEntryRow(packet, role);
|
|
4521
|
+
if (msg?.id) journalMsgs.set(msg.id, { anchor: row || $msgs.lastElementChild || null });
|
|
4522
|
+
}
|
|
4523
|
+
|
|
4524
|
+
/** One journal entry drawn; an assistant message gives back the row it drew. */
|
|
4525
|
+
function drawEntryRow(packet, role) {
|
|
4526
|
+
// A steer (lib/assistant-runtime.js steerBrain, a worker run's 'steered' event): the brain's waits for its prompt,
|
|
4527
|
+
// so what the cut turn still sent is drawn above it; a run's is drawn where it is.
|
|
4528
|
+
if (packet.type === 'steered' || packet.type === 'synabun.steered') {
|
|
4529
|
+
const text = String(packet.text ?? '').trim();
|
|
4530
|
+
if (!text) return;
|
|
4531
|
+
if (packet.target === 'run' || packet.runId) { flushPendingSteer(); drawSteer({ target: 'run', runId: packet.runId || null, title: packet.title || '', text, cut: false }); return; }
|
|
4532
|
+
flushPendingSteer();
|
|
4533
|
+
pendingSteer = { target: 'brain', text, cut: packet.interruptedTurn !== false };
|
|
4534
|
+
cutMsgs = pendingSteer.cut ? journalMsgs : new Map();
|
|
4535
|
+
journalMsgs = new Map();
|
|
4536
|
+
return;
|
|
4537
|
+
}
|
|
4213
4538
|
if (role === 'query' || role === 'user' || role === 'prompt') {
|
|
4214
4539
|
const text = packet.prompt ?? packet.text ?? (typeof packet.content === 'string' ? packet.content : null);
|
|
4215
|
-
if (text != null && !packet.event) {
|
|
4540
|
+
if (text != null && !packet.event) { userPrompt(String(text), { images: Array.isArray(packet.images) ? packet.images : [] }); journalMsgs = new Map(); return; }
|
|
4216
4541
|
}
|
|
4217
4542
|
// The runtime journals the user's prompts only as `synabun.user_prompt` events.
|
|
4218
4543
|
if (packet.type === 'event' && packet.event?.type === 'synabun.user_prompt') {
|
|
4219
|
-
if (packet.event.text)
|
|
4544
|
+
if (packet.event.text) userPrompt(String(packet.event.text), { origin: packet.event.origin || null, imageCount: packet.event.images });
|
|
4545
|
+
journalMsgs = new Map();
|
|
4220
4546
|
return;
|
|
4221
4547
|
}
|
|
4548
|
+
if (packet.type === 'event' && packet.event?.type === 'assistant') { lastAssistantRow = null; handleEvent(packet.event, { silent: true }); return lastAssistantRow; }
|
|
4222
4549
|
if (packet.type === 'event' && packet.event) { handleEvent(packet.event, { silent: true }); return; }
|
|
4223
|
-
if (role === 'assistant' && (packet.message || packet.content))
|
|
4550
|
+
if (role === 'assistant' && (packet.message || packet.content)) return renderAssistant(packet.message || packet);
|
|
4224
4551
|
if (packet.type && handleEvent(packet, { silent: true })) return;
|
|
4225
4552
|
if (role === 'system' && packet.text) appendStatus(packet.text);
|
|
4226
4553
|
}
|
|
@@ -4246,6 +4573,8 @@ export function createRenderer(transcriptEl, hooks = {}) {
|
|
|
4246
4573
|
offers.clear();
|
|
4247
4574
|
dropAsks();
|
|
4248
4575
|
lastTextRow = null;
|
|
4576
|
+
sealedRows.clear();
|
|
4577
|
+
pendingSteer = null;
|
|
4249
4578
|
for (const card of runCards.values()) { try { card._limitWait?.destroy(); } catch { /* gone */ } }
|
|
4250
4579
|
runActivity.clear();
|
|
4251
4580
|
runCards.clear();
|
|
@@ -4286,6 +4615,8 @@ export function createRenderer(transcriptEl, hooks = {}) {
|
|
|
4286
4615
|
appendAssistantMarkdown,
|
|
4287
4616
|
appendStatus,
|
|
4288
4617
|
appendError,
|
|
4618
|
+
appendStopFailure,
|
|
4619
|
+
clearStopFailure,
|
|
4289
4620
|
appendDivider,
|
|
4290
4621
|
appendNode,
|
|
4291
4622
|
appendMemoryChips,
|
|
@@ -4320,6 +4651,8 @@ export function createRenderer(transcriptEl, hooks = {}) {
|
|
|
4320
4651
|
forgetSeen: () => { seen.clear(); snapshot = null; },
|
|
4321
4652
|
/** A card waits on the user: `toolUseId` names the call it holds (the newest live stage when unknown); false clears it. */
|
|
4322
4653
|
setWaiting,
|
|
4654
|
+
/** A shell command of the brain changed: its call's row and terminal block follow (asst-shell-logic.js). */
|
|
4655
|
+
noteShell,
|
|
4323
4656
|
/** The session's usage-limit report changed: this turn's waiting card counts to its reset time. */
|
|
4324
4657
|
noteLimit,
|
|
4325
4658
|
/** Dismiss the Assistant's own limit-wait card (a provider switch already decided what follows). */
|
|
@@ -20,6 +20,10 @@ import { sceneAsset, SCENE_ASSET_KEYS } from '../synabun-mascot-assets.js';
|
|
|
20
20
|
import { isRunIdle, isTerminalRunStatus, runNeedsAttention, runStatusFromState, runTone } from './asst-state.js';
|
|
21
21
|
import { kindOf, parseToolName, sayCall, tFallback, verbText } from './asst-tool-kinds.js';
|
|
22
22
|
import { redactSecrets, safeStepInput } from './asst-redact.js';
|
|
23
|
+
import { isSteering, steerTranslator } from './asst-state.js'; // steer's boot part (asst-steer.js loads on demand)
|
|
24
|
+
|
|
25
|
+
// The steer sentences through the stage's translator (`assistant.steer.*`), else STEER_COPY's own English / Portuguese.
|
|
26
|
+
const steerT = (t) => steerTranslator((key, params) => t(key, '', params) || key, typeof document === 'object' ? document.documentElement?.lang : 'en');
|
|
23
27
|
|
|
24
28
|
/** The scenes: one per task class SynaBun dispatches, and the generic one. */
|
|
25
29
|
export const SCENES = Object.freeze(['quick', 'code', 'complex', 'review', 'research', 'browser', 'computer', 'automation', 'design', 'image_gen', 'video_gen', 'generic']);
|
|
@@ -84,6 +88,8 @@ export function stagePhase(run) {
|
|
|
84
88
|
if (status === 'stopped') return 'stopped';
|
|
85
89
|
if (isTerminalRunStatus(status)) return 'done';
|
|
86
90
|
if (runNeedsAttention(run) || awaitsAnswer({ ...run, status })) return 'waiting';
|
|
91
|
+
// A turn a steer cut is not the end of the work: the stage keeps working until the steer's turn (asst-steer.js).
|
|
92
|
+
if (isSteering(run)) return 'working';
|
|
87
93
|
if (isRunIdle({ ...run, status })) return 'idle';
|
|
88
94
|
if (status === 'queued' || run.queued === true || run.state === 'queued') return 'queued';
|
|
89
95
|
if (status === 'starting' || run.state === 'starting') return 'starting';
|
|
@@ -121,6 +127,8 @@ export function runChip(run, t = tFallback) {
|
|
|
121
127
|
return { tone: 'action', label: t('assistant.run.awaitingRoute', 'waiting for your model choice') };
|
|
122
128
|
}
|
|
123
129
|
if (awaitsAnswer(run)) return { tone: 'action', label: t('assistant.run.waitingInput', 'waiting for your answer') };
|
|
130
|
+
// Steered mid-turn: until its next turn starts (asst-steer.js), never the ended turn's outcome.
|
|
131
|
+
if (isSteering(run)) return { tone: 'running', label: steerT(t)('steeringChip') };
|
|
124
132
|
const tone = runTone(run);
|
|
125
133
|
// A held run whose card the user answered "here": the assistant does it, this worker never started.
|
|
126
134
|
if (run?.completionReason === 'route_here') return { tone, label: t('assistant.run.routedHere', 'not started: done here instead') };
|
|
@@ -365,6 +373,10 @@ export function phaseLine(phase, run, scene, t = tFallback) {
|
|
|
365
373
|
switch (phase) {
|
|
366
374
|
case 'queued': return Number(run?.position) > 0 ? t('assistant.stage.queuedAt', 'Queued · position {n}', { n: run.position }) : t('assistant.stage.queued', 'Queued');
|
|
367
375
|
case 'starting': return t('assistant.stage.starting', 'Starting…');
|
|
376
|
+
case 'working': case 'idle': if (isSteering(run)) return steerT(t)('steering'); break;
|
|
377
|
+
default: break;
|
|
378
|
+
}
|
|
379
|
+
switch (phase) {
|
|
368
380
|
case 'waiting':
|
|
369
381
|
if (run?.state === 'awaiting_route' || run?.route?.status === 'pending' || run?.awaitingRoute) return t('assistant.stage.waitingRoute', 'Waiting for your model choice');
|
|
370
382
|
if (awaitsAnswer(run)) return t('assistant.stage.waitingInput', 'Waiting for your answer');
|