synabun 2.4.2 → 2.4.3
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 +20 -0
- package/README.md +1 -1
- package/docs/browser-extension-bridge.md +23 -3
- package/lib/release-npm-ci.mjs +23 -1
- package/mcp-server/dist/services/neural-interface.js +1 -1
- package/mcp-server/dist/services/neural-interface.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/package-lock.json +5 -5
- package/mcp-server/package.json +1 -1
- package/mcp-server/src/services/neural-interface.ts +1 -1
- package/mcp-server/src/tools/browser-extension-setup.ts +8 -2
- package/neural-interface/i18n/en.json +50 -1
- package/neural-interface/i18n/pt-BR.json +57 -8
- package/neural-interface/lib/assistant-api.js +33 -0
- package/neural-interface/lib/assistant-brains/opencode.js +121 -7
- package/neural-interface/lib/assistant-dispatch.js +26 -2
- package/neural-interface/lib/assistant-envelope.js +40 -0
- package/neural-interface/lib/assistant-runtime.js +95 -10
- package/neural-interface/lib/browser-extension-adapter.js +1 -3
- package/neural-interface/lib/browser-extension-archive.js +149 -0
- package/neural-interface/lib/browser-extension-bridge.js +7 -4
- package/neural-interface/lib/browser-extension-folder.js +596 -76
- package/neural-interface/lib/browser-extension-package.js +200 -0
- package/neural-interface/lib/browser-extension-pin.js +84 -0
- package/neural-interface/lib/browser-extension-pin.json +33 -0
- package/neural-interface/lib/browser-extension-setup.js +105 -18
- package/neural-interface/lib/cli-install.js +23 -3
- package/neural-interface/lib/cli-update-planner.js +67 -4
- package/neural-interface/lib/native-loop-providers.js +10 -1
- package/neural-interface/lib/native-loop-runtime.js +20 -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/terminal-token-redaction.js +83 -0
- 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 +5 -2
- package/neural-interface/public/shared/agy/agy-panel.js +38 -10
- package/neural-interface/public/shared/assistant/asst-api.js +25 -0
- package/neural-interface/public/shared/assistant/asst-panel.js +69 -1
- package/neural-interface/public/shared/assistant/asst-rack-styles.js +23 -0
- package/neural-interface/public/shared/assistant/asst-render.js +138 -6
- 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-styles.js +1 -0
- package/neural-interface/public/shared/cdx/cdx-tabs.js +25 -0
- package/neural-interface/public/shared/extension-setup/es-page.js +10 -4
- package/neural-interface/public/shared/extension-setup/es-view.js +25 -10
- 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 +346 -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 +54 -12
- package/neural-interface/public/shared/shell-stop-view.js +83 -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 +20 -0
- package/neural-interface/public/shared/ui-native-loop-router.js +45 -3
- package/neural-interface/public/shared/ui-scroll-follow.js +4 -0
- package/neural-interface/server.js +249 -35
- 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
- /package/{browser-extension/protocol.js → neural-interface/lib/browser-extension-protocol.js} +0 -0
|
@@ -77,7 +77,7 @@ import { createMarkSettle } from './asst-motion-gate.js';
|
|
|
77
77
|
import {
|
|
78
78
|
closeAssistantSession, dispatchAssistantRun, escalateAssistantRun, focusAssistantRun, getAssistantRun,
|
|
79
79
|
fetchManageCatalog, getAssistantRunResult, getAssistantSession, getAssistantSessionUsage, getRouting, killAllAssistantRuns, removeAssistantRun, clearFinishedAssistantRuns,
|
|
80
|
-
listAssistantSessions, patchAssistantSession, patchHiddenModels, setAdminSandbox, stopAssistantRun, uploadAssistantAttachment,
|
|
80
|
+
listAssistantSessions, patchAssistantSession, patchHiddenModels, setAdminSandbox, stopAssistantRun, uploadAssistantAttachment, readAssistantShellOutput,
|
|
81
81
|
} from './asst-api.js';
|
|
82
82
|
|
|
83
83
|
const ICON_SESSIONS = '<svg viewBox="0 0 24 24"><path d="M3 6h18M3 12h18M3 18h12"/></svg>';
|
|
@@ -534,8 +534,43 @@ export function mountAssistant(viewport, { sessionId, brain, host = {}, session
|
|
|
534
534
|
|| (c.contains('asst-rack') && (row.dataset.state !== 'settled' || c.contains('is-folding')));
|
|
535
535
|
},
|
|
536
536
|
});
|
|
537
|
+
// The shell commands of an OpenCode brain: what they are comes over the socket, what they print is read in
|
|
538
|
+
// pages only while a block shows it (asst-shell-logic.js). Display data, in this tab only. Its modules load with
|
|
539
|
+
// the first command, so a tab of another brain, and the app's first paint, never pay for them.
|
|
540
|
+
let shellTracker = null;
|
|
541
|
+
let shellParts = null; // { logic, block } once loaded
|
|
542
|
+
let shellLoading = null;
|
|
543
|
+
let shellsListed = false; // this server tells commands (it sends the list on every attach)
|
|
544
|
+
let shellPackets = [];
|
|
545
|
+
function applyShellPacket(packet) {
|
|
546
|
+
if (packet.type === 'assistant:shell') shellTracker.apply(packet.shell);
|
|
547
|
+
else shellTracker.applyList(packet.shells);
|
|
548
|
+
}
|
|
549
|
+
function receiveShellPacket(packet) {
|
|
550
|
+
shellsListed = true;
|
|
551
|
+
if (shellTracker) { applyShellPacket(packet); return; }
|
|
552
|
+
if (packet.type === 'assistant:shells' && !packet.shells?.length && !shellLoading) return;
|
|
553
|
+
shellPackets.push(packet);
|
|
554
|
+
shellLoading ||= Promise.all([import('./asst-shell-logic.js'), import('./asst-shell.js')]).then(([logic, block]) => {
|
|
555
|
+
if (destroyed) return;
|
|
556
|
+
shellParts = { logic, block };
|
|
557
|
+
shellTracker = logic.createShellTracker({ read: (args) => readAssistantShellOutput(sessionId, args) });
|
|
558
|
+
shellTracker.onChange((shell) => renderer.noteShell(shell));
|
|
559
|
+
const waiting = shellPackets;
|
|
560
|
+
shellPackets = [];
|
|
561
|
+
for (const held of waiting) applyShellPacket(held);
|
|
562
|
+
}).catch((error) => { shellLoading = null; shellPackets = []; console.warn('[assistant] the terminal block did not load', error); });
|
|
563
|
+
}
|
|
537
564
|
const renderer = createRenderer(transcriptEl, {
|
|
538
565
|
t,
|
|
566
|
+
shells: {
|
|
567
|
+
forCall: (id) => shellTracker?.forCall(id) || null,
|
|
568
|
+
view: (id) => shellTracker?.view(id) || null,
|
|
569
|
+
label: (shell) => shellParts?.logic.shellStateLabel(shell, tt) || '',
|
|
570
|
+
failedLate: (shell) => !!shellParts?.logic.shellFailedLate(shell),
|
|
571
|
+
supported: () => shellsListed,
|
|
572
|
+
terminal: (id, callbacks) => shellParts.block.mountShellTerminal(shellTracker, id, { t: tt, ...callbacks }),
|
|
573
|
+
},
|
|
539
574
|
providerIcon,
|
|
540
575
|
providerColor,
|
|
541
576
|
copy: clipCopy,
|
|
@@ -878,6 +913,11 @@ export function mountAssistant(viewport, { sessionId, brain, host = {}, session
|
|
|
878
913
|
|
|
879
914
|
function handlePacket(packet) {
|
|
880
915
|
if (destroyed || !packet?.type) return;
|
|
916
|
+
// A command's state is live state, never history: it is not one of the packets a reattach counted.
|
|
917
|
+
if (packet.type === 'assistant:shell' || packet.type === 'assistant:shells') {
|
|
918
|
+
if (!packet.sessionId || packet.sessionId === sessionId) receiveShellPacket(packet);
|
|
919
|
+
return;
|
|
920
|
+
}
|
|
881
921
|
if (replay && packet.type !== 'reattach_result') {
|
|
882
922
|
replay.packets.push(packet);
|
|
883
923
|
if ((replay.left -= 1) <= 0) flushReplay();
|
|
@@ -937,11 +977,31 @@ export function mountAssistant(viewport, { sessionId, brain, host = {}, session
|
|
|
937
977
|
if (!st.running) setRunning(true);
|
|
938
978
|
return;
|
|
939
979
|
case 'done':
|
|
980
|
+
renderer.clearStopFailure?.();
|
|
940
981
|
finishTurn({ aborted: false });
|
|
941
982
|
return;
|
|
942
983
|
case 'aborted':
|
|
984
|
+
renderer.clearStopFailure?.();
|
|
943
985
|
finishTurn({ aborted: true });
|
|
944
986
|
return;
|
|
987
|
+
case 'stop_failed':
|
|
988
|
+
// Stop could not end a command in the background: the turn goes on (its Stop button too), and the panel
|
|
989
|
+
// says which and why; from the second failure, "Stop anyway" ends the turn here. (The words load only now.)
|
|
990
|
+
stopView().then((view) => {
|
|
991
|
+
const failure = view?.describeStopFailure(packet, t);
|
|
992
|
+
if (!failure) return;
|
|
993
|
+
renderer.appendStopFailure(failure.message, failure.canForce
|
|
994
|
+
? { forceLabel: view.shellStopText('anyway', {}, t), onForce: () => sock.send({ type: 'abort', force: true }) }
|
|
995
|
+
: {});
|
|
996
|
+
announce(failure.message);
|
|
997
|
+
});
|
|
998
|
+
return;
|
|
999
|
+
case 'stop_abandoned':
|
|
1000
|
+
stopView().then((view) => {
|
|
1001
|
+
const left = view?.describeAbandoned(packet.shells, t);
|
|
1002
|
+
if (left) renderer.appendStatus(left, 'warn');
|
|
1003
|
+
});
|
|
1004
|
+
return;
|
|
945
1005
|
case 'error': {
|
|
946
1006
|
// The server no longer has this session: no error row and no retry loop; the host closes the tab.
|
|
947
1007
|
if (packet.code === 'SESSION_NOT_FOUND') { sessionGone(); return; }
|
|
@@ -1698,6 +1758,13 @@ export function mountAssistant(viewport, { sessionId, brain, host = {}, session
|
|
|
1698
1758
|
}
|
|
1699
1759
|
}
|
|
1700
1760
|
|
|
1761
|
+
// What a Stop that could not end a command says (public/shared/shell-stop-view.js), loaded on its first use.
|
|
1762
|
+
let stopViewLoad = null;
|
|
1763
|
+
function stopView() {
|
|
1764
|
+
stopViewLoad ||= import('../shell-stop-view.js').catch(() => { stopViewLoad = null; return null; });
|
|
1765
|
+
return stopViewLoad;
|
|
1766
|
+
}
|
|
1767
|
+
|
|
1701
1768
|
function abort() {
|
|
1702
1769
|
if (!st.running && !controls.size) return;
|
|
1703
1770
|
sock.send({ type: 'abort' });
|
|
@@ -2460,6 +2527,7 @@ export function mountAssistant(viewport, { sessionId, brain, host = {}, session
|
|
|
2460
2527
|
destroyed = true;
|
|
2461
2528
|
cancelIdleLoad?.();
|
|
2462
2529
|
cancelIdleLoad = null;
|
|
2530
|
+
shellTracker?.destroy();
|
|
2463
2531
|
if (persistTimer) { clearTimeout(persistTimer); persistTimer = null; }
|
|
2464
2532
|
clearTimeout(announceTimer);
|
|
2465
2533
|
if (replay) { clearTimeout(replay.timer); replay = null; }
|
|
@@ -471,6 +471,29 @@ export const RACK_CSS = `
|
|
|
471
471
|
.asst-rack .asst-station[data-kind="computer"]:not(.is-open) .asst-tool-body { display: none; }
|
|
472
472
|
.asst-rack .asst-computer-frame { margin: 4px 0 2px 18px; }
|
|
473
473
|
|
|
474
|
+
/* ── A shell command's live output ──────────────────────────────── */
|
|
475
|
+
.asst-tool[data-shell="running"] > .asst-tool-hdr > .asst-tool-mark { color: var(--rk-gold); }
|
|
476
|
+
.asst-term { min-width: 0; margin-top: 6px; }
|
|
477
|
+
.asst-term-note { display: flex; align-items: center; gap: 8px; min-width: 0; margin-top: 4px; color: var(--rk-text-3); font-size: 11px; line-height: 1.45; }
|
|
478
|
+
.asst-term > .asst-term-note { margin: 0 0 3px; }
|
|
479
|
+
.asst-term-note[hidden] { display: none; }
|
|
480
|
+
.asst-term-note-text { flex: 1 1 auto; min-width: 0; }
|
|
481
|
+
/* One text node, appended to: no wrapping to redo, its layout kept to itself, and the wheel stops at its ends. */
|
|
482
|
+
.asst-rack .asst-tool-section.asst-term-out {
|
|
483
|
+
max-height: 280px;
|
|
484
|
+
overflow: auto;
|
|
485
|
+
overscroll-behavior: contain;
|
|
486
|
+
contain: content;
|
|
487
|
+
white-space: pre;
|
|
488
|
+
overflow-wrap: normal;
|
|
489
|
+
tab-size: 8;
|
|
490
|
+
}
|
|
491
|
+
.asst-rack .asst-tool-section.asst-term-out[hidden] { display: none; }
|
|
492
|
+
.asst-term-foot { display: flex; align-items: center; gap: 4px; min-height: 22px; color: var(--rk-text-3); font-size: 11px; }
|
|
493
|
+
.asst-term-state { flex: 1 1 auto; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
|
|
494
|
+
.asst-term-foot > .asst-copy { margin-left: 0; }
|
|
495
|
+
.asst-term-load, .asst-term-jump { flex: none; margin-top: 0; }
|
|
496
|
+
|
|
474
497
|
.asst-tool-sec + .asst-tool-sec { margin-top: 6px; }
|
|
475
498
|
.asst-tool-sec-head { display: flex; align-items: center; gap: 8px; margin-bottom: 3px; }
|
|
476
499
|
.asst-rack .asst-tool-label { margin: 0; color: var(--rk-text-3); font-size: 11px; letter-spacing: 0; text-transform: none; }
|
|
@@ -499,6 +499,8 @@ const PREVIEW_LINES = 5;
|
|
|
499
499
|
const THINK_PREVIEW_LINES = 10;
|
|
500
500
|
const MAX_DIFF_LINES = 400; // an edit's mini diff draws this many lines; "Show full input" draws the rest
|
|
501
501
|
// The empty state's suggestions (asst-panel.js ids) and the kind each one is about.
|
|
502
|
+
// A tool result that only says its command went on in the background (OpenCode 2.3): none of the output is in it.
|
|
503
|
+
const isBackgroundNotice = (result) => typeof result === 'string' && /^Command moved to the background \(shell ID: /.test(result);
|
|
502
504
|
const SUGGESTION_KINDS = { computer: 'computer', web: 'web', fix: 'edit', skill: 'skill', schedule: 'plan', remember: 'memory' };
|
|
503
505
|
|
|
504
506
|
/**
|
|
@@ -1446,6 +1448,7 @@ export function createRenderer(transcriptEl, hooks = {}) {
|
|
|
1446
1448
|
step.endedAt = nowMs();
|
|
1447
1449
|
step.timed = step.timed && isTimed();
|
|
1448
1450
|
if (step.kind === 'runs') noteAgentResult(text);
|
|
1451
|
+
if (step.shell) applyShellOutcome(step);
|
|
1449
1452
|
refreshStep(step);
|
|
1450
1453
|
if (step.bodyBuilt) fillCallBody(step);
|
|
1451
1454
|
if (step.state === 'error') onFailure(step);
|
|
@@ -1473,9 +1476,89 @@ export function createRenderer(transcriptEl, hooks = {}) {
|
|
|
1473
1476
|
placeStep(rack, step);
|
|
1474
1477
|
if (!muted && turnActive && !step.auto) { turn.calls += 1; turn.last = step; }
|
|
1475
1478
|
if (rack.steps.length === 1 && !muted && turnActive) announce(rack, stepSentence(step, step.state === 'running'));
|
|
1479
|
+
if (step.kind === 'shell') syncShell(step); // its command may be known already (a panel that attached mid-run)
|
|
1476
1480
|
return step;
|
|
1477
1481
|
}
|
|
1478
1482
|
|
|
1483
|
+
// ── A shell call's command (an OpenCode brain: asst-shell-logic.js) ──
|
|
1484
|
+
/** What the runtime says about the call's command: the row's state word, its failure, its terminal block. */
|
|
1485
|
+
function syncShell(step) {
|
|
1486
|
+
const shell = hooks.shells?.forCall?.(step.id) || null;
|
|
1487
|
+
if (!shell) return;
|
|
1488
|
+
const wasRunning = step.shell?.status === 'running';
|
|
1489
|
+
step.shell = shell;
|
|
1490
|
+
if (wasRunning && shell.status !== 'running' && step.state !== 'running') step.endedAt = nowMs();
|
|
1491
|
+
// OpenCode announces a call before its input: the row and the stage read the command from here then.
|
|
1492
|
+
const learned = !commandOf(step.input || {}) && !!shell.command;
|
|
1493
|
+
if (learned) step.input = canonicalToolInput({ ...(step.input || {}), command: shell.command });
|
|
1494
|
+
applyShellOutcome(step);
|
|
1495
|
+
refreshStep(step);
|
|
1496
|
+
if (learned && step.bodyBuilt) fillCallBody(step);
|
|
1497
|
+
// The turn was told over before its command (a Stop): the row settles now, as it would have at the turn's end.
|
|
1498
|
+
if (wasRunning && shell.status !== 'running' && !turnActive) foldShellRows();
|
|
1499
|
+
if (shell.status === 'running' && (shell.waited || turnActive)) openForShell(step);
|
|
1500
|
+
syncTerminal(step);
|
|
1501
|
+
}
|
|
1502
|
+
|
|
1503
|
+
/** A command that failed after its tool call had answered (it went on in the background) fails the call. */
|
|
1504
|
+
function applyShellOutcome(step) {
|
|
1505
|
+
if (step.state !== 'ok' || !hooks.shells?.failedLate?.(step.shell)) return;
|
|
1506
|
+
step.state = 'error';
|
|
1507
|
+
step.code = typeof step.shell.exit === 'number' ? step.shell.exit : null;
|
|
1508
|
+
onFailure(step);
|
|
1509
|
+
}
|
|
1510
|
+
|
|
1511
|
+
/** A running command's output is on screen without a click, unless the reader closed that row. */
|
|
1512
|
+
function openForShell(step) {
|
|
1513
|
+
const { rack, station: st } = step;
|
|
1514
|
+
if (!st || st.userSet || rack.userSet) return;
|
|
1515
|
+
if (!st.open) { st.autoOpened = true; setStationOpen(rack, st, true); }
|
|
1516
|
+
if (!rack.open && !rack.staged) { rack.autoOpened = true; setRackOpen(rack, true); }
|
|
1517
|
+
}
|
|
1518
|
+
|
|
1519
|
+
/** A block exists only while its row is open: a closed row costs no text in the page and no polling. */
|
|
1520
|
+
function syncTerminal(step) {
|
|
1521
|
+
if (!step.shell || !step.station?.open) {
|
|
1522
|
+
if (step.terminal) { step.terminal.dispose(); step.terminal = null; }
|
|
1523
|
+
return;
|
|
1524
|
+
}
|
|
1525
|
+
if (!step.bodyBuilt) buildCallBody(step);
|
|
1526
|
+
else if (!step.terminal) fillCallBody(step);
|
|
1527
|
+
}
|
|
1528
|
+
|
|
1529
|
+
/** The block of a shell call whose row is open (made once; a rebuilt body takes the same one). */
|
|
1530
|
+
function terminalOf(step) {
|
|
1531
|
+
if (!step.shell || !step.station?.open || !hooks.shells?.terminal) return null;
|
|
1532
|
+
step.terminal ||= hooks.shells.terminal(step.shell.id, {
|
|
1533
|
+
onDraw: () => scrollEnd(),
|
|
1534
|
+
onGone: () => { if (step.bodyBuilt) fillCallBody(step); },
|
|
1535
|
+
});
|
|
1536
|
+
return step.terminal;
|
|
1537
|
+
}
|
|
1538
|
+
|
|
1539
|
+
/** The turn ended: rows opened for a command fold again, unless one failed or the model still waits for it. */
|
|
1540
|
+
function foldShellRows() {
|
|
1541
|
+
for (const rack of racks) {
|
|
1542
|
+
for (const st of rack.stations.values()) {
|
|
1543
|
+
if (!st.autoOpened) continue;
|
|
1544
|
+
if (st.userSet || rack.userSet) { st.autoOpened = false; continue; }
|
|
1545
|
+
if (st.steps.some(s => s.shell?.status === 'running' && s.shell.waited)) continue;
|
|
1546
|
+
st.autoOpened = false;
|
|
1547
|
+
if (st.steps.some(s => s.state === 'error')) { if (!rack.open) setRackOpen(rack, true); continue; }
|
|
1548
|
+
setStationOpen(rack, st, false);
|
|
1549
|
+
if (rack.autoOpened) { rack.autoOpened = false; setRackOpen(rack, false); }
|
|
1550
|
+
}
|
|
1551
|
+
}
|
|
1552
|
+
}
|
|
1553
|
+
|
|
1554
|
+
/** The runtime's word on a command changed (asst-panel.js): its call's row follows, wherever it is. */
|
|
1555
|
+
function noteShell(shell) {
|
|
1556
|
+
const step = shell?.callID ? stepsById.get(shell.callID) : null;
|
|
1557
|
+
if (!step || step.type !== 'call' || step.kind !== 'shell') return;
|
|
1558
|
+
syncShell(step);
|
|
1559
|
+
renderRack(step.rack);
|
|
1560
|
+
}
|
|
1561
|
+
|
|
1479
1562
|
/** The final block of a streamed call, or the same block replayed: the step learns its input, nothing is added. */
|
|
1480
1563
|
function updateCall(step, block) {
|
|
1481
1564
|
if (block.name) step.name = block.name;
|
|
@@ -1665,7 +1748,7 @@ export function createRenderer(transcriptEl, hooks = {}) {
|
|
|
1665
1748
|
};
|
|
1666
1749
|
row._rack = rack;
|
|
1667
1750
|
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));
|
|
1751
|
+
rack.receipt.btn.addEventListener('click', () => { rack.userSet = true; setRackOpen(rack, !rack.open); });
|
|
1669
1752
|
row.querySelector('.asst-rack-view').addEventListener('click', (e) => {
|
|
1670
1753
|
const btn = e.target.closest('button[data-view]');
|
|
1671
1754
|
if (btn) setRackView(rack, btn.dataset.view);
|
|
@@ -1673,7 +1756,7 @@ export function createRenderer(transcriptEl, hooks = {}) {
|
|
|
1673
1756
|
rack.ledger.addEventListener('click', (e) => {
|
|
1674
1757
|
const hdr = e.target.closest('.asst-station-hdr');
|
|
1675
1758
|
const owner = hdr ? headers.get(hdr) : null;
|
|
1676
|
-
if (owner?.rack === rack) setStationOpen(rack, owner.st, !owner.st.open);
|
|
1759
|
+
if (owner?.rack === rack) { owner.st.userSet = true; setStationOpen(rack, owner.st, !owner.st.open); }
|
|
1677
1760
|
});
|
|
1678
1761
|
rack.ledger.addEventListener('keydown', (e) => onLedgerKey(rack, e));
|
|
1679
1762
|
rack.stage.subject.addEventListener('click', () => setBubbleOpen(rack, !rack.bubble.open));
|
|
@@ -1712,6 +1795,7 @@ export function createRenderer(transcriptEl, hooks = {}) {
|
|
|
1712
1795
|
st.hdr.setAttribute('aria-expanded', st.open ? 'true' : 'false');
|
|
1713
1796
|
st.log.hidden = !st.open && st.kind !== 'computer';
|
|
1714
1797
|
if (st.open) for (const step of st.steps) buildCallBody(step);
|
|
1798
|
+
for (const step of st.steps) if (step.kind === 'shell') syncTerminal(step);
|
|
1715
1799
|
renderStationFace(rack, st);
|
|
1716
1800
|
}
|
|
1717
1801
|
|
|
@@ -1744,8 +1828,8 @@ export function createRenderer(transcriptEl, hooks = {}) {
|
|
|
1744
1828
|
else if (e.key === 'ArrowUp') next = list[Math.max(0, at - 1)];
|
|
1745
1829
|
else if (e.key === 'Home') next = list[0];
|
|
1746
1830
|
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; }
|
|
1831
|
+
else if (e.key === 'ArrowRight') { e.preventDefault(); owner.st.userSet = true; if (!owner.st.open) setStationOpen(rack, owner.st, true); return; }
|
|
1832
|
+
else if (e.key === 'ArrowLeft') { e.preventDefault(); owner.st.userSet = true; if (owner.st.open) setStationOpen(rack, owner.st, false); return; }
|
|
1749
1833
|
else return;
|
|
1750
1834
|
e.preventDefault();
|
|
1751
1835
|
if (!next) return;
|
|
@@ -2781,8 +2865,12 @@ export function createRenderer(transcriptEl, hooks = {}) {
|
|
|
2781
2865
|
else if (step.state === 'error') state = t('assistant.tool.error', 'error');
|
|
2782
2866
|
else if (step.state === 'neutral') state = t('assistant.rack.state.noMatches', 'no matches');
|
|
2783
2867
|
else if (step.state === 'ok') state = t('assistant.tool.done', 'done');
|
|
2868
|
+
if (step.shell) {
|
|
2869
|
+
state = hooks.shells?.label?.(step.shell) || state;
|
|
2870
|
+
li.dataset.shell = step.shell.status;
|
|
2871
|
+
}
|
|
2784
2872
|
q('.asst-tool-state').textContent = state;
|
|
2785
|
-
q('.asst-tool-time').textContent = step.endedAt && step.timed ? fmtDuration(step.endedAt - step.startedAt, t) : '';
|
|
2873
|
+
q('.asst-tool-time').textContent = step.endedAt && step.timed && step.shell?.status !== 'running' ? fmtDuration(step.endedAt - step.startedAt, t) : '';
|
|
2786
2874
|
}
|
|
2787
2875
|
|
|
2788
2876
|
/** Bodies are built on first expand: a replayed history costs a header per call. */
|
|
@@ -2811,6 +2899,8 @@ export function createRenderer(transcriptEl, hooks = {}) {
|
|
|
2811
2899
|
}
|
|
2812
2900
|
// Keep a Show toggle's keyboard focus across the rebuild below.
|
|
2813
2901
|
const refocus = body.contains(document.activeElement) && document.activeElement.classList.contains('asst-reveal');
|
|
2902
|
+
// The reader's place in a terminal block survives it too (the block goes back in below).
|
|
2903
|
+
const inTerminal = step.terminal?.el.contains(document.activeElement) ? document.activeElement : null;
|
|
2814
2904
|
body.textContent = '';
|
|
2815
2905
|
const input = step.input || {};
|
|
2816
2906
|
const say = sayOf(step);
|
|
@@ -2857,10 +2947,21 @@ export function createRenderer(transcriptEl, hooks = {}) {
|
|
|
2857
2947
|
default:
|
|
2858
2948
|
inputSection(body, step, red);
|
|
2859
2949
|
}
|
|
2860
|
-
|
|
2950
|
+
// A command with a terminal block shows what it printed there; the call's own result is the fallback once
|
|
2951
|
+
// OpenCode no longer has that output.
|
|
2952
|
+
const terminal = step.kind === 'shell' ? terminalOf(step) : null;
|
|
2953
|
+
if (terminal) body.appendChild(terminal.el);
|
|
2954
|
+
const outputGone = !!terminal && !!hooks.shells?.view?.(step.shell.id)?.gone;
|
|
2955
|
+
if (step.result && step.kind !== 'plan' && (!terminal || (outputGone && !isBackgroundNotice(step.result)))) {
|
|
2861
2956
|
const output = hidden ? maskEcho(step.result, hidden, t) : step.result;
|
|
2862
2957
|
section(body, t('assistant.rack.body.output', 'Output'), output, { copy: true });
|
|
2958
|
+
// The result only says the command went on, and nobody can read what it printed any more.
|
|
2959
|
+
if (!terminal && step.kind === 'shell' && hooks.shells?.supported?.() && isBackgroundNotice(step.result)) {
|
|
2960
|
+
body.appendChild(el('div', 'asst-term-note', t('assistant.rack.shell.gone', 'OpenCode no longer keeps the output of this command.')));
|
|
2961
|
+
}
|
|
2863
2962
|
}
|
|
2963
|
+
terminal?.show();
|
|
2964
|
+
inTerminal?.focus({ preventScroll: true });
|
|
2864
2965
|
if (!body.children.length) { body.remove(); return; }
|
|
2865
2966
|
if (refocus) body.querySelector('.asst-reveal')?.focus({ preventScroll: true });
|
|
2866
2967
|
}
|
|
@@ -3068,6 +3169,7 @@ export function createRenderer(transcriptEl, hooks = {}) {
|
|
|
3068
3169
|
rack.clearTimer = 0;
|
|
3069
3170
|
rack.sr.timer = 0;
|
|
3070
3171
|
rack.holdTimer = 0;
|
|
3172
|
+
for (const step of rack.steps) if (step.terminal) { step.terminal.dispose(); step.terminal = null; }
|
|
3071
3173
|
const had = !!rack.rig;
|
|
3072
3174
|
rack.rig?.destroy?.();
|
|
3073
3175
|
rack.rig = null;
|
|
@@ -3173,6 +3275,31 @@ export function createRenderer(transcriptEl, hooks = {}) {
|
|
|
3173
3275
|
return row;
|
|
3174
3276
|
}
|
|
3175
3277
|
|
|
3278
|
+
/**
|
|
3279
|
+
* A Stop that could not end a command in the background (the runtime's `stop_failed`): the reason as an error row,
|
|
3280
|
+
* and from the second failure of the turn a "Stop anyway" button (`onForce`). The row of an earlier failure goes:
|
|
3281
|
+
* one row says what holds now.
|
|
3282
|
+
*/
|
|
3283
|
+
let stopFailureRow = null;
|
|
3284
|
+
function appendStopFailure(text, { forceLabel = '', onForce = null } = {}) {
|
|
3285
|
+
clearStopFailure();
|
|
3286
|
+
const row = appendStatus(text, 'error');
|
|
3287
|
+
if (!row) return null;
|
|
3288
|
+
row.classList.add('asst-stop-failed');
|
|
3289
|
+
if (forceLabel && typeof onForce === 'function') {
|
|
3290
|
+
const button = el('button', 'asst-btn asst-btn-secondary asst-stop-anyway', forceLabel);
|
|
3291
|
+
button.type = 'button';
|
|
3292
|
+
button.addEventListener('click', () => { button.disabled = true; onForce(); });
|
|
3293
|
+
row.appendChild(button);
|
|
3294
|
+
}
|
|
3295
|
+
stopFailureRow = row;
|
|
3296
|
+
return row;
|
|
3297
|
+
}
|
|
3298
|
+
function clearStopFailure() {
|
|
3299
|
+
stopFailureRow?.remove?.();
|
|
3300
|
+
stopFailureRow = null;
|
|
3301
|
+
}
|
|
3302
|
+
|
|
3176
3303
|
function appendDivider(label) {
|
|
3177
3304
|
return append(el('div', 'asst-divider', label || ''));
|
|
3178
3305
|
}
|
|
@@ -4160,6 +4287,7 @@ export function createRenderer(transcriptEl, hooks = {}) {
|
|
|
4160
4287
|
else if (!stage.holdTimer) stage.holdUntil = 0; // a hold already running (the `done` after a result) keeps its time
|
|
4161
4288
|
}
|
|
4162
4289
|
endBursts(rootScope);
|
|
4290
|
+
foldShellRows();
|
|
4163
4291
|
for (const rack of [...racks]) {
|
|
4164
4292
|
const tail = liveTail(rack.scope) === rack;
|
|
4165
4293
|
rack.closed = true;
|
|
@@ -4286,6 +4414,8 @@ export function createRenderer(transcriptEl, hooks = {}) {
|
|
|
4286
4414
|
appendAssistantMarkdown,
|
|
4287
4415
|
appendStatus,
|
|
4288
4416
|
appendError,
|
|
4417
|
+
appendStopFailure,
|
|
4418
|
+
clearStopFailure,
|
|
4289
4419
|
appendDivider,
|
|
4290
4420
|
appendNode,
|
|
4291
4421
|
appendMemoryChips,
|
|
@@ -4320,6 +4450,8 @@ export function createRenderer(transcriptEl, hooks = {}) {
|
|
|
4320
4450
|
forgetSeen: () => { seen.clear(); snapshot = null; },
|
|
4321
4451
|
/** A card waits on the user: `toolUseId` names the call it holds (the newest live stage when unknown); false clears it. */
|
|
4322
4452
|
setWaiting,
|
|
4453
|
+
/** A shell command of the brain changed: its call's row and terminal block follow (asst-shell-logic.js). */
|
|
4454
|
+
noteShell,
|
|
4323
4455
|
/** The session's usage-limit report changed: this turn's waiting card counts to its reset time. */
|
|
4324
4456
|
noteLimit,
|
|
4325
4457
|
/** Dismiss the Assistant's own limit-wait card (a provider switch already decided what follows). */
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
2
|
+
// SynaBun Assistant — the shell commands of an OpenCode brain (no DOM, no socket)
|
|
3
|
+
//
|
|
4
|
+
// The runtime tells a panel which commands the brain's tool calls started and how
|
|
5
|
+
// they ended (`assistant:shell`, `assistant:shells`). What a command printed is
|
|
6
|
+
// never in those packets: it is read in pages over REST, only while a terminal
|
|
7
|
+
// block shows that command, by the same follower and terminal buffer as the
|
|
8
|
+
// OpenCode side panel (ocp-v2-shell-logic.js). Everything here is display data:
|
|
9
|
+
// nothing of it goes to the model, the transcript, a memory or a meter.
|
|
10
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
11
|
+
|
|
12
|
+
import { createShellFollower, formatBytes, shellCardState } from '../ocp-v2/ocp-v2-shell-logic.js';
|
|
13
|
+
|
|
14
|
+
/** How many finished commands keep their read output once no block shows them (the next look reads it again). */
|
|
15
|
+
export const SHELL_KEPT_FINISHED = 12;
|
|
16
|
+
|
|
17
|
+
const GONE_VIEW = Object.freeze({ text: '', from: 0, size: 0, done: true, gone: true, error: '', full: false, capped: false, partial: false });
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* createShellTracker({ read })
|
|
21
|
+
* read({ shellId, cursor, tail, limit }) → { status, data: { output, cursor, size, from } } or { ok: false, status, error }
|
|
22
|
+
* apply / applyList take what the runtime says; open(id) + subscribe(id, fn) follow one command for as long as a
|
|
23
|
+
* block shows it; onChange(fn) hears that a command's state changed.
|
|
24
|
+
*/
|
|
25
|
+
export function createShellTracker({ read, setTimer, clearTimer, kept = SHELL_KEPT_FINISHED } = {}) {
|
|
26
|
+
const shells = new Map(); // shellId → the runtime's view of it
|
|
27
|
+
const byCall = new Map(); // the tool call's id → shellId
|
|
28
|
+
const entries = new Map(); // shellId → { follower, view, usedAt }
|
|
29
|
+
const listeners = new Map(); // shellId → Set of what draws it
|
|
30
|
+
const places = new Map(); // shellId → { follow, top }: where the reader left its block
|
|
31
|
+
const changes = new Set();
|
|
32
|
+
let clock = 0;
|
|
33
|
+
let destroyed = false;
|
|
34
|
+
|
|
35
|
+
const tell = (shellId) => {
|
|
36
|
+
for (const fn of [...(listeners.get(shellId) || [])]) { try { fn(); } catch (err) { console.warn('[asst-shell] draw failed', err); } }
|
|
37
|
+
};
|
|
38
|
+
const changed = (shell) => {
|
|
39
|
+
for (const fn of [...changes]) { try { fn(shell); } catch (err) { console.warn('[asst-shell] update failed', err); } }
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
// Stop removes a command from OpenCode, so its next read is a 404. What was read up to then is what it printed
|
|
43
|
+
// before it was stopped: nothing to apologise for, unless the start of a long output is out of reach.
|
|
44
|
+
const settledView = (shellId, view) => (view.gone && view.text && !view.partial && shells.get(shellId)?.status === 'killed'
|
|
45
|
+
? { ...view, gone: false, done: true }
|
|
46
|
+
: view);
|
|
47
|
+
|
|
48
|
+
function dropEntry(shellId) {
|
|
49
|
+
entries.get(shellId)?.follower?.stop();
|
|
50
|
+
entries.delete(shellId);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** Finished commands nobody looks at keep their text up to `kept`; the oldest goes first. */
|
|
54
|
+
function evict() {
|
|
55
|
+
const idle = [...entries].filter(([id]) => !listeners.get(id)?.size).sort((a, b) => a[1].usedAt - b[1].usedAt);
|
|
56
|
+
while (idle.length > kept) {
|
|
57
|
+
const [id] = idle.shift();
|
|
58
|
+
dropEntry(id);
|
|
59
|
+
places.delete(id);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function apply(shell) {
|
|
64
|
+
if (destroyed || !shell?.id) return;
|
|
65
|
+
const known = shells.get(shell.id);
|
|
66
|
+
// Named again after it was lost (a brain that came back to its serve): it is read afresh.
|
|
67
|
+
if (known?.lost) dropEntry(shell.id);
|
|
68
|
+
shells.set(shell.id, shell);
|
|
69
|
+
if (shell.callID) byCall.set(shell.callID, shell.id);
|
|
70
|
+
if (shell.status !== 'running') entries.get(shell.id)?.follower?.poke();
|
|
71
|
+
tell(shell.id);
|
|
72
|
+
changed(shell);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** The brain no longer has this command (it was replaced, or its serve ended). What was read stays on screen. */
|
|
76
|
+
function lose(shellId) {
|
|
77
|
+
const shell = shells.get(shellId);
|
|
78
|
+
if (!shell || shell.lost) return;
|
|
79
|
+
const next = { ...shell, lost: true, status: shell.status === 'running' ? 'killed' : shell.status };
|
|
80
|
+
shells.set(shellId, next);
|
|
81
|
+
const entry = entries.get(shellId);
|
|
82
|
+
if (entry) {
|
|
83
|
+
entry.follower?.stop();
|
|
84
|
+
entry.follower = null;
|
|
85
|
+
const view = entry.view;
|
|
86
|
+
// Read to its end, the text on screen is the whole output: nothing is missing from it.
|
|
87
|
+
if (!view) entry.view = { ...GONE_VIEW };
|
|
88
|
+
else if (!view.done || view.partial) entry.view = { ...view, done: true, gone: true };
|
|
89
|
+
}
|
|
90
|
+
tell(shellId);
|
|
91
|
+
changed(next);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** The whole list as the runtime knows it now: a command it no longer names is gone. */
|
|
95
|
+
function applyList(list) {
|
|
96
|
+
if (destroyed) return;
|
|
97
|
+
const named = new Set();
|
|
98
|
+
for (const shell of Array.isArray(list) ? list : []) {
|
|
99
|
+
if (!shell?.id) continue;
|
|
100
|
+
named.add(shell.id);
|
|
101
|
+
apply(shell);
|
|
102
|
+
}
|
|
103
|
+
for (const id of [...shells.keys()]) if (!named.has(id)) lose(id);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/** Start reading a command for a block that shows it. */
|
|
107
|
+
function open(shellId) {
|
|
108
|
+
if (destroyed || !shells.has(shellId)) return;
|
|
109
|
+
let entry = entries.get(shellId);
|
|
110
|
+
if (!entry) {
|
|
111
|
+
entry = { follower: null, view: null, usedAt: 0 };
|
|
112
|
+
entries.set(shellId, entry);
|
|
113
|
+
if (shells.get(shellId).lost) entry.view = { ...GONE_VIEW };
|
|
114
|
+
else {
|
|
115
|
+
const mine = entry;
|
|
116
|
+
const options = {
|
|
117
|
+
api: { shellOutput: ({ shellId: id, cursor, tail, limit }) => read({ shellId: id, cursor, tail, limit }) },
|
|
118
|
+
sessionId: 'assistant', shellId,
|
|
119
|
+
isRunning: () => shells.get(shellId)?.status === 'running',
|
|
120
|
+
onUpdate: (view) => { if (entries.get(shellId) === mine) { mine.view = settledView(shellId, view); tell(shellId); } },
|
|
121
|
+
};
|
|
122
|
+
if (setTimer) options.setTimer = setTimer;
|
|
123
|
+
if (clearTimer) options.clearTimer = clearTimer;
|
|
124
|
+
entry.follower = createShellFollower(options);
|
|
125
|
+
entry.follower.start();
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
entry.usedAt = ++clock;
|
|
129
|
+
evict();
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function subscribe(shellId, fn) {
|
|
133
|
+
let set = listeners.get(shellId);
|
|
134
|
+
if (!set) { set = new Set(); listeners.set(shellId, set); }
|
|
135
|
+
set.add(fn);
|
|
136
|
+
return () => {
|
|
137
|
+
set.delete(fn);
|
|
138
|
+
if (set.size) return;
|
|
139
|
+
listeners.delete(shellId);
|
|
140
|
+
// Nobody looks: nothing is polled. A command that ended and was read keeps its text for the next look.
|
|
141
|
+
const entry = entries.get(shellId);
|
|
142
|
+
if (entry?.follower && !entry.follower.isDone()) dropEntry(shellId);
|
|
143
|
+
evict();
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
return {
|
|
148
|
+
apply,
|
|
149
|
+
applyList,
|
|
150
|
+
open,
|
|
151
|
+
subscribe,
|
|
152
|
+
loadAll(shellId) { entries.get(shellId)?.follower?.loadAll(); },
|
|
153
|
+
forCall: (callId) => shells.get(byCall.get(callId)) || null,
|
|
154
|
+
shell: (shellId) => shells.get(shellId) || null,
|
|
155
|
+
view: (shellId) => entries.get(shellId)?.view || null,
|
|
156
|
+
placeOf(shellId) {
|
|
157
|
+
let place = places.get(shellId);
|
|
158
|
+
if (!place) { place = { follow: true, top: 0 }; places.set(shellId, place); }
|
|
159
|
+
return place;
|
|
160
|
+
},
|
|
161
|
+
onChange(fn) { changes.add(fn); return () => changes.delete(fn); },
|
|
162
|
+
/** For tests: which commands are being read now. */
|
|
163
|
+
reading: () => [...entries].filter(([, entry]) => entry.follower && !entry.follower.isDone()).map(([id]) => id),
|
|
164
|
+
destroy() {
|
|
165
|
+
destroyed = true;
|
|
166
|
+
for (const id of [...entries.keys()]) dropEntry(id);
|
|
167
|
+
listeners.clear();
|
|
168
|
+
changes.clear();
|
|
169
|
+
},
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/** The word on a call's row for its command ('' when the call's own state says it). */
|
|
174
|
+
export function shellStateLabel(shell, t) {
|
|
175
|
+
if (!shell) return '';
|
|
176
|
+
if (shell.status === 'running') {
|
|
177
|
+
return shell.background ? t('assistant.rack.shell.background', 'in the background') : t('assistant.rack.shell.running', 'running');
|
|
178
|
+
}
|
|
179
|
+
if (shell.status === 'killed') return t('assistant.rack.shell.stopped', 'stopped');
|
|
180
|
+
if (shell.status === 'timeout') return t('assistant.rack.shell.timedOut', 'timed out');
|
|
181
|
+
if (typeof shell.exit === 'number') return t('assistant.rack.shell.exit', 'exit {code}', { code: shell.exit });
|
|
182
|
+
return '';
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/** A command the model no longer waits for failed after its tool call had already answered. */
|
|
186
|
+
export function shellFailedLate(shell) {
|
|
187
|
+
return shellCardState(shell).status === 'error';
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/** The line above a terminal block when it does not show everything: '' when it does. */
|
|
191
|
+
export function shellNoteText(view, t) {
|
|
192
|
+
if (!view) return '';
|
|
193
|
+
if (view.gone) return t('assistant.rack.shell.gone', 'OpenCode no longer keeps the output of this command.');
|
|
194
|
+
const shown = formatBytes(view.text.length);
|
|
195
|
+
const size = formatBytes(view.size);
|
|
196
|
+
if (view.capped) return t('assistant.rack.shell.capped', 'Showing the last {shown} of {size}: the whole output is too long to show here.', { shown, size });
|
|
197
|
+
if (view.partial) return t('assistant.rack.shell.partial', 'Showing the last {shown} of {size}.', { shown, size });
|
|
198
|
+
return '';
|
|
199
|
+
}
|
|
200
|
+
|