synabun 2.2.1 → 2.2.2
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 +27 -0
- package/README.md +1 -1
- package/hooks/claude-code/pre-websearch.mjs +4 -1
- package/hooks/claude-code/prompt-submit.mjs +7 -0
- package/lib/release-scan.mjs +23 -10
- package/lib/virustotal.mjs +143 -39
- package/mcp-server/dist/http.d.ts +19 -0
- package/mcp-server/dist/http.d.ts.map +1 -1
- package/mcp-server/dist/http.js +55 -13
- package/mcp-server/dist/http.js.map +1 -1
- package/mcp-server/dist/index.d.ts.map +1 -1
- package/mcp-server/dist/index.js +14 -9
- package/mcp-server/dist/index.js.map +1 -1
- package/mcp-server/dist/services/browser-route-flow.d.ts +118 -0
- package/mcp-server/dist/services/browser-route-flow.d.ts.map +1 -0
- package/mcp-server/dist/services/browser-route-flow.js +339 -0
- package/mcp-server/dist/services/browser-route-flow.js.map +1 -0
- package/mcp-server/dist/services/desktop-client.js +2 -2
- package/mcp-server/dist/services/desktop-client.js.map +1 -1
- package/mcp-server/dist/services/identity.d.ts +66 -3
- package/mcp-server/dist/services/identity.d.ts.map +1 -1
- package/mcp-server/dist/services/identity.js +61 -4
- package/mcp-server/dist/services/identity.js.map +1 -1
- package/mcp-server/dist/services/neural-interface.d.ts +112 -1
- package/mcp-server/dist/services/neural-interface.d.ts.map +1 -1
- package/mcp-server/dist/services/neural-interface.js +555 -61
- package/mcp-server/dist/services/neural-interface.js.map +1 -1
- package/mcp-server/dist/tools/bluesky.d.ts +20 -7
- package/mcp-server/dist/tools/bluesky.d.ts.map +1 -1
- package/mcp-server/dist/tools/bluesky.js +147 -45
- package/mcp-server/dist/tools/bluesky.js.map +1 -1
- package/mcp-server/dist/tools/browser-advanced.d.ts +11 -2
- package/mcp-server/dist/tools/browser-advanced.d.ts.map +1 -1
- package/mcp-server/dist/tools/browser-advanced.js +131 -18
- package/mcp-server/dist/tools/browser-advanced.js.map +1 -1
- package/mcp-server/dist/tools/browser-cheatsheet.d.ts +2 -0
- package/mcp-server/dist/tools/browser-cheatsheet.d.ts.map +1 -1
- package/mcp-server/dist/tools/browser-cheatsheet.js +3 -0
- package/mcp-server/dist/tools/browser-cheatsheet.js.map +1 -1
- package/mcp-server/dist/tools/morelogin.d.ts.map +1 -1
- package/mcp-server/dist/tools/morelogin.js +4 -2
- package/mcp-server/dist/tools/morelogin.js.map +1 -1
- package/mcp-server/dist/tools/skill-tools.d.ts +4 -4
- package/mcp-server/dist/tools/youtube/helpers.d.ts +1 -0
- package/mcp-server/dist/tools/youtube/helpers.d.ts.map +1 -1
- package/mcp-server/dist/tools/youtube/helpers.js +1 -1
- package/mcp-server/dist/tools/youtube/helpers.js.map +1 -1
- package/mcp-server/package-lock.json +2 -2
- package/mcp-server/package.json +1 -1
- package/mcp-server/src/http.ts +58 -12
- package/mcp-server/src/index.ts +15 -9
- package/mcp-server/src/services/browser-route-flow.ts +402 -0
- package/mcp-server/src/services/desktop-client.ts +2 -2
- package/mcp-server/src/services/identity.ts +80 -4
- package/mcp-server/src/services/neural-interface.ts +572 -70
- package/mcp-server/src/tools/bluesky.ts +164 -51
- package/mcp-server/src/tools/browser-advanced.ts +121 -17
- package/mcp-server/src/tools/browser-cheatsheet.ts +3 -0
- package/mcp-server/src/tools/morelogin.ts +4 -2
- package/mcp-server/src/tools/youtube/helpers.ts +2 -2
- package/neural-interface/i18n/en.json +24 -0
- package/neural-interface/i18n/pt-BR.json +24 -0
- package/neural-interface/lib/assistant-api.js +64 -23
- package/neural-interface/lib/assistant-catalog.js +20 -2
- package/neural-interface/lib/assistant-dispatch.js +27 -1
- package/neural-interface/lib/assistant-persona.js +1 -0
- package/neural-interface/lib/assistant-runtime.js +15 -1
- package/neural-interface/lib/assistant-tools.js +10 -1
- package/neural-interface/lib/browser-automation-routes.js +84 -0
- package/neural-interface/lib/browser-execution.js +16 -3
- package/neural-interface/lib/browser-owner.js +48 -0
- package/neural-interface/lib/browser-session-close.js +84 -0
- package/neural-interface/lib/browser-start-handoff.js +202 -0
- package/neural-interface/lib/browser-tool-policy.js +21 -4
- package/neural-interface/lib/browser-wedge-retire.js +64 -0
- package/neural-interface/lib/claude-agent-bridge.js +36 -1
- package/neural-interface/lib/claude-background-hold.js +239 -0
- package/neural-interface/lib/exec-loop-command.js +8 -0
- package/neural-interface/lib/http-guards.js +11 -6
- package/neural-interface/lib/loop-logger.js +6 -1
- package/neural-interface/lib/mcp-external-servers.js +37 -10
- package/neural-interface/lib/native-loop-providers.js +121 -10
- package/neural-interface/lib/native-loop-runtime.js +112 -11
- package/neural-interface/lib/owner-authority.js +113 -37
- package/neural-interface/lib/page-session.js +81 -23
- package/neural-interface/lib/peer-identity.js +263 -43
- package/neural-interface/lib/provider-panel-api-key-auth.js +7 -2
- package/neural-interface/lib/pty-host/core.js +36 -0
- package/neural-interface/lib/pty-host/protocol.js +2 -0
- package/neural-interface/lib/skills/api-v2.js +13 -2
- package/neural-interface/lib/skills/creation-api.js +3 -1
- package/neural-interface/lib/skills/evals-api.js +5 -1
- package/neural-interface/lib/social-write-pacing.js +151 -0
- package/neural-interface/lib/terminal-token-redaction.js +293 -0
- package/neural-interface/lib/terminal-tokens.js +359 -0
- package/neural-interface/lib/worker-mcp-channel.js +45 -10
- package/neural-interface/package-lock.json +2 -2
- package/neural-interface/package.json +1 -1
- package/neural-interface/public/shared/agy/agy-render.js +41 -1
- package/neural-interface/public/shared/agy/agy-styles.js +5 -0
- package/neural-interface/public/shared/api.js +1 -0
- package/neural-interface/public/shared/assistant/asst-computer.js +47 -2
- package/neural-interface/public/shared/assistant/asst-limit-wait.js +3 -1
- package/neural-interface/public/shared/assistant/asst-panel.js +7 -3
- package/neural-interface/public/shared/assistant/asst-render.js +10 -4
- package/neural-interface/public/shared/assistant/asst-styles.js +2 -1
- package/neural-interface/public/shared/cdx/cdx-render.js +73 -7
- package/neural-interface/public/shared/cdx/cdx-tabs.js +3 -3
- package/neural-interface/public/shared/cp/cp-agents.js +8 -0
- package/neural-interface/public/shared/cp/cp-permissions.js +6 -2
- package/neural-interface/public/shared/cp/cp-rehydrate.js +25 -1
- package/neural-interface/public/shared/cp/cp-tasks-model.js +33 -0
- package/neural-interface/public/shared/judgments-log-origins.js +29 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-automation-ownership.js +23 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-events.js +13 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-icons.js +3 -1
- package/neural-interface/public/shared/ocp-v2/ocp-v2-panel.js +4 -2
- package/neural-interface/public/shared/ocp-v2/ocp-v2-render.js +6 -86
- package/neural-interface/public/shared/ocp-v2/ocp-v2-ws.js +5 -2
- package/neural-interface/public/shared/owner-access.js +134 -0
- package/neural-interface/public/shared/owner-authority-view.js +92 -0
- package/neural-interface/public/shared/page-session.js +143 -14
- package/neural-interface/public/shared/poll-backoff.js +59 -0
- package/neural-interface/public/shared/settings/settings-data.js +6 -1
- package/neural-interface/public/shared/settings/settings-kit.js +11 -3
- package/neural-interface/public/shared/settings/settings-shell.js +7 -0
- package/neural-interface/public/shared/shown-children.js +72 -0
- package/neural-interface/public/shared/static-bg-state.js +22 -0
- package/neural-interface/public/shared/styles.css +101 -7
- package/neural-interface/public/shared/synabun-tools.js +173 -0
- package/neural-interface/public/shared/tool-heartbeat.js +43 -0
- package/neural-interface/public/shared/tool-list-picker.js +3 -1
- package/neural-interface/public/shared/tool-list-view.js +23 -4
- package/neural-interface/public/shared/ui-automation-studio.js +8 -1
- package/neural-interface/public/shared/ui-claude-panel.js +159 -29
- package/neural-interface/public/shared/ui-judgments.js +37 -10
- package/neural-interface/public/shared/ui-navbar.js +6 -0
- package/neural-interface/public/shared/ui-owner-access.js +191 -0
- package/neural-interface/public/shared/ui-owner-authority.js +162 -0
- package/neural-interface/public/shared/ui-sessions.js +45 -16
- package/neural-interface/public/shared/ui-settings.js +86 -15
- package/neural-interface/public/shared/ui-terminal.js +15 -7
- package/neural-interface/public/shared/ui-tutorial-preview.js +4 -0
- package/neural-interface/public/shared/ui-update.js +3 -0
- package/neural-interface/public/shared/ui-whiteboard.js +4 -0
- package/neural-interface/public/shared/window-keys.js +38 -0
- package/neural-interface/server.js +1160 -205
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
|
@@ -13,6 +13,9 @@
|
|
|
13
13
|
// /api/desktop/frames/<id>/thumb.jpg; `assistant:desktop` activity events.
|
|
14
14
|
|
|
15
15
|
import { desktopSetup, getDesktopStatus, resumeDesktop, stopDesktop } from './asst-api.js';
|
|
16
|
+
import { createPollGate } from '../poll-backoff.js';
|
|
17
|
+
import { refusalOfError } from '../owner-access.js';
|
|
18
|
+
import { OWNER_ACCESS_RESTORED_EVENT } from '../page-session.js';
|
|
16
19
|
|
|
17
20
|
// ── Pure helpers ────────────────────────────────────────────────────────────
|
|
18
21
|
|
|
@@ -291,6 +294,47 @@ const ICON_COMPUTER = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor
|
|
|
291
294
|
const ICON_X = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>';
|
|
292
295
|
const POLL_MS = 3000;
|
|
293
296
|
|
|
297
|
+
// ── The status poll, shared by every tray of the page ──
|
|
298
|
+
// Each Assistant tab has its own tray and timer; through one gate (poll-backoff.js) they send at most one GET
|
|
299
|
+
// /api/desktop/status at a time and one per POLL_MS, wait longer after every failure (exponential, capped at five
|
|
300
|
+
// minutes), and stop altogether on a refusal of the owner's access (403 WORKER_BROWSER and the like: SynaBun's
|
|
301
|
+
// automation browser opened the page) until the page gets the owner's page secret again or becomes visible again.
|
|
302
|
+
// Before 2026-11-05 every tray asked every 3 s whatever the answer: five per 3 s on a refused page.
|
|
303
|
+
export const desktopStatusGate = createPollGate({ baseMs: POLL_MS });
|
|
304
|
+
let _statusInFlight = null;
|
|
305
|
+
let _gateWired = false;
|
|
306
|
+
|
|
307
|
+
function wireStatusGate() {
|
|
308
|
+
if (_gateWired) return;
|
|
309
|
+
_gateWired = true;
|
|
310
|
+
if (typeof window !== 'undefined' && typeof window.addEventListener === 'function') {
|
|
311
|
+
window.addEventListener(OWNER_ACCESS_RESTORED_EVENT, () => desktopStatusGate.resume());
|
|
312
|
+
}
|
|
313
|
+
if (typeof document !== 'undefined' && typeof document.addEventListener === 'function') {
|
|
314
|
+
document.addEventListener('visibilitychange', () => { if (!document.hidden && desktopStatusGate.snapshot().halted) desktopStatusGate.resume(); });
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* GET /api/desktop/status once for every tray and probe that asks at the same time; the answer counts on the shared
|
|
320
|
+
* gate (an answer resets it, a failure backs it off, a refusal of the owner's access halts the timers' polling).
|
|
321
|
+
*/
|
|
322
|
+
export function requestDesktopStatus(request = getDesktopStatus) {
|
|
323
|
+
if (_statusInFlight) return _statusInFlight;
|
|
324
|
+
wireStatusGate();
|
|
325
|
+
desktopStatusGate.begin();
|
|
326
|
+
let sent;
|
|
327
|
+
try { sent = Promise.resolve(request()); } catch (err) { sent = Promise.reject(err); }
|
|
328
|
+
const run = sent.then(
|
|
329
|
+
(status) => { desktopStatusGate.succeed(); return status; },
|
|
330
|
+
(err) => { desktopStatusGate.fail(refusalOfError(err)); throw err; },
|
|
331
|
+
);
|
|
332
|
+
_statusInFlight = run;
|
|
333
|
+
const clear = () => { if (_statusInFlight === run) _statusInFlight = null; };
|
|
334
|
+
run.then(clear, clear);
|
|
335
|
+
return run;
|
|
336
|
+
}
|
|
337
|
+
|
|
294
338
|
/** What a failed status check was: { kind: 'forbidden' | 'timeout' | 'error', message }. */
|
|
295
339
|
export function computerCheckFailure(err) {
|
|
296
340
|
const message = str(err?.message) || 'The status check failed';
|
|
@@ -704,7 +748,7 @@ export function createComputerPanel(hostEl, hooks = {}) {
|
|
|
704
748
|
|
|
705
749
|
async function refresh() {
|
|
706
750
|
try {
|
|
707
|
-
const status = await
|
|
751
|
+
const status = await requestDesktopStatus();
|
|
708
752
|
if (!state.destroyed) applyStatus(status);
|
|
709
753
|
return status;
|
|
710
754
|
} catch (err) {
|
|
@@ -719,7 +763,8 @@ export function createComputerPanel(hostEl, hooks = {}) {
|
|
|
719
763
|
const need = state.view === 'tray' && !state.destroyed;
|
|
720
764
|
if (need && !state.pollTimer) {
|
|
721
765
|
state.pollTimer = setInterval(() => {
|
|
722
|
-
|
|
766
|
+
// The shared gate decides: one request at a time for every tray, a wait after a failure, none on a refusal.
|
|
767
|
+
if (document.hidden || !desktopStatusGate.due()) return;
|
|
723
768
|
refresh().catch(() => {});
|
|
724
769
|
}, POLL_MS);
|
|
725
770
|
} else if (!need && state.pollTimer) {
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
|
|
19
19
|
import * as mascotLib from '../synabun-mascot.js';
|
|
20
20
|
import { isReducedMotion, subscribe } from '../synabun-ticker.js';
|
|
21
|
+
import { syncEmpty } from '../shown-children.js';
|
|
21
22
|
import { limitCountdown, resetMs } from './asst-limit.js';
|
|
22
23
|
|
|
23
24
|
const RING_R = 24;
|
|
@@ -179,6 +180,7 @@ export function createLimitWait(opts = {}) {
|
|
|
179
180
|
retryBtn.textContent = label;
|
|
180
181
|
}
|
|
181
182
|
if (switchBtn) switchBtn.hidden = !(next === 'waiting' || next === 'unknown');
|
|
183
|
+
syncEmpty(actions); // the row goes when none of its buttons shows (data-empty, not a :has())
|
|
182
184
|
if (next === 'waiting') { setPose('sleep'); setRing(limitCountdown({ resetsAt, since }, now).progress || 0); }
|
|
183
185
|
else if (next === 'unknown') { setPose('wait'); setRing(0.18, true); }
|
|
184
186
|
else if (next === 'restored') { setPose(was === 'waiting' ? 'success' : 'idle'); setRing(1); }
|
|
@@ -301,7 +303,7 @@ const CSS = `
|
|
|
301
303
|
.asst-limit-wait-clock.is-text { font-family: inherit; font-size: 13px; color: var(--asst-text-2); letter-spacing: 0; }
|
|
302
304
|
.asst-limit-wait-meta { color: var(--asst-text-3); font-size: 11.5px; overflow-wrap: anywhere; }
|
|
303
305
|
.asst-limit-wait-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
|
|
304
|
-
.asst-limit-wait-actions
|
|
306
|
+
.asst-limit-wait-actions[data-empty] { display: none; }
|
|
305
307
|
.asst-limit-wait-live { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
|
|
306
308
|
.asst-limit-row .asst-msg-content { width: 100%; }
|
|
307
309
|
.asst-run .asst-limit-wait { grid-column: 2 / span 2; margin-top: 8px; padding: 10px 12px; }
|
|
@@ -39,6 +39,7 @@ import { isGuest, hasPermission } from '../ui-sync.js';
|
|
|
39
39
|
import { getWhiteboardElementById } from '../ui-whiteboard.js';
|
|
40
40
|
import { focusNativeLoopRun } from '../ui-native-loop-router.js';
|
|
41
41
|
import { wireFileLinks } from '../ui-file-links.js';
|
|
42
|
+
import { watchEmpty } from '../shown-children.js';
|
|
42
43
|
import { injectAssistantStyles } from './asst-styles.js';
|
|
43
44
|
import { tipsSeen, tourOffered } from '../tour/tour-state.js';
|
|
44
45
|
import { createAssistantSocket } from './asst-ws.js';
|
|
@@ -59,7 +60,7 @@ import { createUsageGauge } from './asst-usage.js';
|
|
|
59
60
|
import { closeMenu, currentMenuAnchor, isMenuOpen, openMenu } from './asst-menu.js';
|
|
60
61
|
import { createRouteModeControl, openModelsManager, openRoutesEditor, refreshModelsManager, renderRouteCard, routeModeLabel } from './asst-route.js';
|
|
61
62
|
import { budgetChipText, budgetSpendText, budgetTone, closeBudgetEditor, createBudgetController, mountBudgetChip, openBudgetEditor } from './asst-budget.js';
|
|
62
|
-
import { computerRemoteView, createComputerPanel, createComputerToggle, normalizeComputerRemote, openFrameLightbox, closeFrameLightbox, requestDesktopStop } from './asst-computer.js';
|
|
63
|
+
import { computerRemoteView, createComputerPanel, createComputerToggle, normalizeComputerRemote, openFrameLightbox, closeFrameLightbox, requestDesktopStatus, requestDesktopStop } from './asst-computer.js';
|
|
63
64
|
import {
|
|
64
65
|
applyLimit, applyLimitPacket, applyUsagePacket, BRAIN_PROVIDERS, brainLabel, createRenameWriter, createTabState, DEFAULT_ROUTE_MODE, deserializeTabState, fmtCost, fmtRunLine, limitExpiresIn, limitNoticeText, modelShortName,
|
|
65
66
|
brainModePatch, isBrainProvider, normalizeBrain, normalizeComputerMode, permissionModeLabel, normalizeRouteMode, normalizeTestDensity, projectLabel, providerMeta, providerShortLabel, readStoredBrain, runFromPayload,
|
|
@@ -67,7 +68,7 @@ import {
|
|
|
67
68
|
} from './asst-state.js';
|
|
68
69
|
import {
|
|
69
70
|
closeAssistantSession, dispatchAssistantRun, escalateAssistantRun, focusAssistantRun, getAssistantRun,
|
|
70
|
-
fetchManageCatalog, getAssistantRunResult, getAssistantSession, getAssistantSessionUsage,
|
|
71
|
+
fetchManageCatalog, getAssistantRunResult, getAssistantSession, getAssistantSessionUsage, getRouting, killAllAssistantRuns, removeAssistantRun, clearFinishedAssistantRuns,
|
|
71
72
|
listAssistantSessions, patchAssistantSession, patchHiddenModels, setAdminSandbox, stopAssistantRun, uploadAssistantAttachment,
|
|
72
73
|
} from './asst-api.js';
|
|
73
74
|
|
|
@@ -230,6 +231,8 @@ export function mountAssistant(viewport, { sessionId, brain, host = {}, session
|
|
|
230
231
|
|
|
231
232
|
const barEl = root.querySelector('.asst-bar');
|
|
232
233
|
const barGroups = Object.fromEntries([...barEl.querySelectorAll('.asst-bar-group')].map((g) => [g.dataset.group, g]));
|
|
234
|
+
// A group none of whose controls shows is hidden through data-empty (shown-children.js), never a :has().
|
|
235
|
+
const barEmpty = watchEmpty(barEl, '.asst-bar-group');
|
|
233
236
|
const costEl = root.querySelector('.asst-cost');
|
|
234
237
|
const bannersEl = root.querySelector('.asst-banners');
|
|
235
238
|
const transcriptEl = root.querySelector('.asst-transcript');
|
|
@@ -1111,7 +1114,7 @@ export function mountAssistant(viewport, { sessionId, brain, host = {}, session
|
|
|
1111
1114
|
}
|
|
1112
1115
|
if (st.features.computer == null && !st.desktopProbe) {
|
|
1113
1116
|
st.desktopProbe = true;
|
|
1114
|
-
|
|
1117
|
+
requestDesktopStatus()
|
|
1115
1118
|
.then((status) => {
|
|
1116
1119
|
st.desktopSupported = status?.supported === true;
|
|
1117
1120
|
st.features.computer = status?.supported === true;
|
|
@@ -2322,6 +2325,7 @@ export function mountAssistant(viewport, { sessionId, brain, host = {}, session
|
|
|
2322
2325
|
dock.destroy();
|
|
2323
2326
|
composer.destroy();
|
|
2324
2327
|
renderer.destroy();
|
|
2328
|
+
barEmpty.disconnect();
|
|
2325
2329
|
barEl.remove(); // it may live in the host's header
|
|
2326
2330
|
root.remove();
|
|
2327
2331
|
if (closeServer) {
|
|
@@ -67,6 +67,8 @@ import { createAskTail } from './asst-ask-tail.js';
|
|
|
67
67
|
import { limitFromText } from './asst-limit.js';
|
|
68
68
|
import { createLimitDock } from './asst-limit-dock.js';
|
|
69
69
|
import { createLimitWait } from './asst-limit-wait.js';
|
|
70
|
+
import { synabunToolKey, synabunToolLabel } from '../synabun-tools.js';
|
|
71
|
+
import { normalizeToolHeartbeat } from '../tool-heartbeat.js';
|
|
70
72
|
|
|
71
73
|
// ── Markdown (lazy marked, the vendored build the sidepanels use too) ───────────────
|
|
72
74
|
let _marked = null;
|
|
@@ -111,9 +113,8 @@ export function mdInto(node, text) {
|
|
|
111
113
|
export const ICON_ASSISTANT = '<svg viewBox="0 0 24 24" fill="currentColor"><rect x="8" y="5.5" width="11" height="5" rx="2.5" transform="rotate(-12 13.5 8)"/><rect x="4.5" y="12.5" width="11" height="5" rx="2.5" transform="rotate(-12 10 15)"/></svg>';
|
|
112
114
|
const ICON_MEMORY = '<svg viewBox="0 0 24 24" fill="currentColor"><rect x="8" y="5.5" width="11" height="5" rx="2.5" transform="rotate(-12 13.5 8)"/><rect x="4.5" y="12.5" width="11" height="5" rx="2.5" transform="rotate(-12 10 15)"/></svg>';
|
|
113
115
|
const ICON_ESCALATE = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 19V5M5 12l7-7 7 7"/></svg>';
|
|
114
|
-
// SynaBun's own MCP tools: Claude/Codex `mcp__SynaBun__x`, OpenCode `SynaBun_x
|
|
115
|
-
|
|
116
|
-
export function synabunToolName(name) { const m = SYNABUN_TOOL_RE.exec(String(name || '')); return m ? m[1] : null; }
|
|
116
|
+
// SynaBun's own MCP tools: Claude/Codex `mcp__SynaBun__x`, OpenCode `SynaBun_x` (synabun-tools.js, every panel's).
|
|
117
|
+
export function synabunToolName(name) { return synabunToolKey(name); }
|
|
117
118
|
const RESULT_ERRORS = { error_max_turns: 'Stopped: the turn limit was reached.', error_max_budget_usd: 'Stopped: the budget cap was reached.', error_during_execution: 'The turn failed.', error_max_structured_output_retries: 'Stopped: structured output kept failing.' };
|
|
118
119
|
const INTERRUPTED_RE = /\b(?:interrupted|aborted|cancell?ed)\b/i;
|
|
119
120
|
|
|
@@ -2509,7 +2510,10 @@ export function createRenderer(transcriptEl, hooks = {}) {
|
|
|
2509
2510
|
function stepTitle(step) {
|
|
2510
2511
|
if (step.type === 'think') return t('assistant.rack.kind.think', 'Thinking');
|
|
2511
2512
|
if (step.kind === 'computer') { const base = computerToolName(step.name) || 'computer'; return t(`assistant.computer.tool.${base}`, COMPUTER_TOOL_TITLES[base] || 'Computer'); }
|
|
2512
|
-
|
|
2513
|
+
// A SynaBun tool by the name every panel gives it ('Bluesky · Post'); any other MCP tool by its words.
|
|
2514
|
+
const sbKey = synabunToolName(step.name);
|
|
2515
|
+
if (sbKey != null) return synabunToolLabel(sbKey);
|
|
2516
|
+
if (step.kind === 'mcp') return toolWords(step.name);
|
|
2513
2517
|
return step.name || 'tool';
|
|
2514
2518
|
}
|
|
2515
2519
|
|
|
@@ -3880,6 +3884,8 @@ export function createRenderer(transcriptEl, hooks = {}) {
|
|
|
3880
3884
|
}
|
|
3881
3885
|
|
|
3882
3886
|
function dispatch(ev, silent) {
|
|
3887
|
+
// A long call's heartbeat names the call as its parent: progress of that call, not a subagent's feed.
|
|
3888
|
+
ev = normalizeToolHeartbeat(ev);
|
|
3883
3889
|
if (ev.type !== 'stream_event') for (const k of idKeys(ev)) markSeen(k); // deltas are never replayed as themselves
|
|
3884
3890
|
const parentId = ev.parent_tool_use_id || ev.message?.parent_tool_use_id || null;
|
|
3885
3891
|
const scope = scopeFor(parentId);
|
|
@@ -288,7 +288,8 @@ export function injectAssistantStyles() {
|
|
|
288
288
|
padding: 4px;
|
|
289
289
|
}
|
|
290
290
|
.asst-bar-group { display: flex; flex: 0 1 auto; align-items: center; gap: 4px; min-width: 0; }
|
|
291
|
-
|
|
291
|
+
/* nothing to show: data-empty is kept by the panel (shown-children.js watchEmpty); never a :has(), see css-has-performance.test.mjs */
|
|
292
|
+
.asst-bar-group:is(:empty, [data-empty]) { display: none; }
|
|
292
293
|
.asst-bar-group + .asst-bar-group::before {
|
|
293
294
|
content: '';
|
|
294
295
|
flex-shrink: 0;
|
|
@@ -20,6 +20,7 @@ import { renderReadableOutput, renderReadableBlock, cleanOutputBlocks, hydrateOu
|
|
|
20
20
|
import { fileLinkTitle, fillFileLinkCopy, isInsideRoots, parseFileLinkTarget, readFileLink } from '../file-links.js';
|
|
21
21
|
import { sanitizeHtmlString } from '../assistant/asst-sanitize.js';
|
|
22
22
|
import { createTextCache } from '../text-cache.js';
|
|
23
|
+
import { isSynabunServer, synabunToolKey, synabunToolLabel, synabunToolSummary } from '../synabun-tools.js';
|
|
23
24
|
export { setCardExpanded } from './cdx-cards.js';
|
|
24
25
|
|
|
25
26
|
// ── Shared context (set by cdx-tabs via setRenderContext) ──
|
|
@@ -1967,8 +1968,71 @@ export function createFoldSection(label, {
|
|
|
1967
1968
|
return { sectionEl: details, bodyEl, labelEl };
|
|
1968
1969
|
}
|
|
1969
1970
|
|
|
1971
|
+
/** A SynaBun call: its server is SynaBun's, or (no server given) its tool name says so. */
|
|
1970
1972
|
export function isSynaBunMcpTool(item) {
|
|
1971
|
-
|
|
1973
|
+
if (String(item?.server || '').trim()) return isSynabunServer(item.server);
|
|
1974
|
+
return synabunToolKey(item?.tool) != null;
|
|
1975
|
+
}
|
|
1976
|
+
|
|
1977
|
+
/** The bare SynaBun tool name of a call (server and tool as the card state keeps them), else null. */
|
|
1978
|
+
function synabunCallKey(server, tool) {
|
|
1979
|
+
return String(server || '').trim() ? synabunToolKey(tool, server) : synabunToolKey(tool);
|
|
1980
|
+
}
|
|
1981
|
+
|
|
1982
|
+
/** An MCP card's title: a SynaBun call by its friendly name ('Bluesky · Post'), any other as server • tool. */
|
|
1983
|
+
export function mcpCardTitle(server, tool) {
|
|
1984
|
+
const key = synabunCallKey(server, tool);
|
|
1985
|
+
if (key != null) return synabunToolLabel(key);
|
|
1986
|
+
return `${server || 'MCP'} • ${tool || 'tool'}`;
|
|
1987
|
+
}
|
|
1988
|
+
|
|
1989
|
+
/**
|
|
1990
|
+
* A SynaBun call's one-line summary from its arguments ('' for any other call). Codex may hand
|
|
1991
|
+
* the arguments over as JSON text; a text that does not parse says nothing.
|
|
1992
|
+
*/
|
|
1993
|
+
export function mcpCallSummary(server, tool, args) {
|
|
1994
|
+
const key = synabunCallKey(server, tool);
|
|
1995
|
+
if (key == null) return '';
|
|
1996
|
+
let input = args;
|
|
1997
|
+
if (typeof input === 'string') {
|
|
1998
|
+
try { input = JSON.parse(input); } catch { input = null; }
|
|
1999
|
+
}
|
|
2000
|
+
return synabunToolSummary(key, input);
|
|
2001
|
+
}
|
|
2002
|
+
|
|
2003
|
+
/**
|
|
2004
|
+
* What an MCP card's head says, from its state alone (no DOM): the title (a SynaBun call by its
|
|
2005
|
+
* friendly name), the subtitle (a SynaBun call's summary before the timing, else the timing or
|
|
2006
|
+
* 'Tool call') and whether it is a SynaBun call.
|
|
2007
|
+
*/
|
|
2008
|
+
export function mcpHeadText(state) {
|
|
2009
|
+
const server = state?.toolServer || '';
|
|
2010
|
+
const tool = state?.toolName || '';
|
|
2011
|
+
const synabun = synabunCallKey(server, tool) != null;
|
|
2012
|
+
const meta = state?.toolSubtitle && state.toolSubtitle !== 'Tool call' ? state.toolSubtitle : '';
|
|
2013
|
+
const summary = synabun ? String(state?.synabunSummary || '') : '';
|
|
2014
|
+
return {
|
|
2015
|
+
title: mcpCardTitle(server, tool),
|
|
2016
|
+
subtitle: summary ? [summary, meta].filter(Boolean).join(' · ') : (meta || 'Tool call'),
|
|
2017
|
+
synabun,
|
|
2018
|
+
};
|
|
2019
|
+
}
|
|
2020
|
+
|
|
2021
|
+
/**
|
|
2022
|
+
* Paints an MCP card's head (title, subtitle, the SynaBun look) from its state. The head shows
|
|
2023
|
+
* while the card is collapsed, so every item update paints it, not only a body flush; a card
|
|
2024
|
+
* made before its item named the server gets the SynaBun look once it does.
|
|
2025
|
+
*/
|
|
2026
|
+
function paintMcpHead(state) {
|
|
2027
|
+
if (!state) return;
|
|
2028
|
+
const head = mcpHeadText(state);
|
|
2029
|
+
if (state.titleEl) state.titleEl.textContent = head.title;
|
|
2030
|
+
if (head.synabun && state.el && !state.el.classList.contains('cxp-card-synabun-tool')) {
|
|
2031
|
+
state.el.classList.add('cxp-card-synabun-tool');
|
|
2032
|
+
const iconEl = state.el.querySelector(':scope > .cxp-card-head > .cxp-card-icon');
|
|
2033
|
+
if (iconEl) iconEl.innerHTML = SYNABUN_LOGO_ICON;
|
|
2034
|
+
}
|
|
2035
|
+
if (state.subtitleEl) state.subtitleEl.textContent = head.subtitle;
|
|
1972
2036
|
}
|
|
1973
2037
|
|
|
1974
2038
|
export function getMcpToolIcon(item) {
|
|
@@ -2091,6 +2155,8 @@ function cacheCollapsedCardState(state, item, itemType) {
|
|
|
2091
2155
|
if (metadata) state.toolSubtitle = metadata;
|
|
2092
2156
|
else if (!state.toolSubtitle) state.toolSubtitle = 'Tool call';
|
|
2093
2157
|
if (hasOwnField(item, 'arguments')) state.argsText = formatStructuredValue(item.arguments);
|
|
2158
|
+
// A SynaBun call says what it is about under its name (the query, the post, the URL).
|
|
2159
|
+
if (hasOwnField(item, 'arguments')) state.synabunSummary = mcpCallSummary(state.toolServer, state.toolName, item.arguments);
|
|
2094
2160
|
if (hasOwnField(item, 'error')) {
|
|
2095
2161
|
state.progressText = item.error
|
|
2096
2162
|
? `Error: ${extractStructuredText(item.error) || formatStructuredValue(item.error)}`
|
|
@@ -2158,8 +2224,7 @@ export function flushCardBody(state) {
|
|
|
2158
2224
|
setOptionalSection(state.outputSectionEl, state.outputEl, state.outputBuf || '');
|
|
2159
2225
|
break;
|
|
2160
2226
|
case 'mcpToolCall':
|
|
2161
|
-
|
|
2162
|
-
if (state.subtitleEl) state.subtitleEl.textContent = state.toolSubtitle || 'Tool call';
|
|
2227
|
+
paintMcpHead(state);
|
|
2163
2228
|
setOptionalSection(state.argsSectionEl, state.argsEl, state.argsText || '');
|
|
2164
2229
|
setOptionalText(state.progressEl, state.progressText || '');
|
|
2165
2230
|
setOptionalSection(state.resultSectionEl, state.resultEl, state.resultText || '');
|
|
@@ -2510,7 +2575,7 @@ export function ensureCommandState(item) {
|
|
|
2510
2575
|
export function ensureToolState(item) {
|
|
2511
2576
|
let state = _ctx.items.get(item.id);
|
|
2512
2577
|
if (state) return state;
|
|
2513
|
-
const card = createCard(item, getMcpToolIcon(item),
|
|
2578
|
+
const card = createCard(item, getMcpToolIcon(item), mcpCardTitle(item.server, item.tool), 'Tool call');
|
|
2514
2579
|
|
|
2515
2580
|
const argsSection = createFoldSection('Arguments', {
|
|
2516
2581
|
className: 'cxp-fold-args',
|
|
@@ -2898,7 +2963,9 @@ export function updateItemFromData(item) {
|
|
|
2898
2963
|
if (itemType === 'mcpToolCall') mountMcpAppCard({ card: state.el, item: state._lastItem,
|
|
2899
2964
|
tab: _ctx.boundTab, request: _ctx.requestForTab, draft: _ctx.setMcpAppDraft });
|
|
2900
2965
|
// Always update head elements (visible even when collapsed)
|
|
2901
|
-
|
|
2966
|
+
// An MCP card's head is its own (friendly title, the call's summary), collapsed or not.
|
|
2967
|
+
if (itemType === 'mcpToolCall') paintMcpHead(state);
|
|
2968
|
+
else if (state.titleEl) {
|
|
2902
2969
|
const h = _ctx.itemHeadline(state._lastItem);
|
|
2903
2970
|
const head = state.preEl ? codexGenericCardHead(state._lastItem, h) : null;
|
|
2904
2971
|
state.titleEl.textContent = head?.title || h.detail || item.type || 'Item';
|
|
@@ -2976,8 +3043,7 @@ export function updateItemFromData(item) {
|
|
|
2976
3043
|
break;
|
|
2977
3044
|
}
|
|
2978
3045
|
case 'mcpToolCall': {
|
|
2979
|
-
state
|
|
2980
|
-
state.subtitleEl.textContent = state.toolSubtitle || 'Tool call';
|
|
3046
|
+
paintMcpHead(state);
|
|
2981
3047
|
state.pillEl.textContent = _ctx.formatStatus(item.status);
|
|
2982
3048
|
setOptionalSection(state.argsSectionEl, state.argsEl, state.argsText || '');
|
|
2983
3049
|
setOptionalText(state.progressEl, state.progressText || '');
|
|
@@ -82,7 +82,7 @@ import {
|
|
|
82
82
|
renderHistory, countRenderableTranscriptNodes, flattenThreadHistoryItems,
|
|
83
83
|
flushCardBody, extractUserText, openChangelogEditorFlow, summarizeCommandExecution,
|
|
84
84
|
normalizeChoiceLabel, isSynaBunChoicePrompt, isChangelogChoiceSet, restoreChangelogButtons,
|
|
85
|
-
renderUserMessageContent, syncMessagePlanActions,
|
|
85
|
+
renderUserMessageContent, syncMessagePlanActions, mcpCardTitle, isSynaBunMcpTool,
|
|
86
86
|
} from './cdx-render.js';
|
|
87
87
|
import {
|
|
88
88
|
setRequestsContext, handleServerRequest, resolveRequestCard, sendServerRequestReply,
|
|
@@ -1948,8 +1948,8 @@ function itemHeadline(item) {
|
|
|
1948
1948
|
}
|
|
1949
1949
|
case 'mcpToolCall':
|
|
1950
1950
|
return {
|
|
1951
|
-
title: `${item.server || 'MCP'} tool call`,
|
|
1952
|
-
detail: cleanPreview(
|
|
1951
|
+
title: isSynaBunMcpTool(item) ? 'SynaBun tool call' : `${item.server || 'MCP'} tool call`,
|
|
1952
|
+
detail: cleanPreview(mcpCardTitle(item.server, item.tool)),
|
|
1953
1953
|
};
|
|
1954
1954
|
case 'fileChange':
|
|
1955
1955
|
return {
|
|
@@ -13,6 +13,9 @@ import { cpCtx } from './cp-ctx.js';
|
|
|
13
13
|
const AGENT_ICON = '<svg viewBox="0 0 24 24" width="13" height="13" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="7" r="3"/><path d="M5 21v-1a5 5 0 0 1 5-5h4a5 5 0 0 1 5 5v1"/><path d="M19 3l1.5 1.5M22 2l-1.5 1.5"/></svg>';
|
|
14
14
|
const MAX_FEED_CHILDREN = 80;
|
|
15
15
|
|
|
16
|
+
// CSS.escape where the page has it; a quote-safe fallback for an id elsewhere (tests).
|
|
17
|
+
const cssEscape = (s) => (typeof CSS !== 'undefined' && CSS.escape ? CSS.escape(String(s)) : String(s).replace(/["\\]/g, '\\$&'));
|
|
18
|
+
|
|
16
19
|
function fmtElapsed(ms) {
|
|
17
20
|
const s = Math.floor(ms / 1000);
|
|
18
21
|
if (s < 60) return `${s}s`;
|
|
@@ -86,6 +89,11 @@ export function ensureAgentScope(tab, parentToolUseId) {
|
|
|
86
89
|
if (!tab.agents) tab.agents = new Map();
|
|
87
90
|
let entry = tab.agents.get(parentToolUseId);
|
|
88
91
|
if (!entry) {
|
|
92
|
+
// A parent that is an ordinary call in this transcript (an MCP tool, Bash) is
|
|
93
|
+
// not a subagent: nothing it sends gets a subagent card (a heartbeat of a long
|
|
94
|
+
// call used to draw one, a purple bar between the tool rows: tool-heartbeat.js).
|
|
95
|
+
const named = tab.messagesEl?.querySelector?.(`.tool-card[data-tool-id="${cssEscape(parentToolUseId)}"]`);
|
|
96
|
+
if (named && !named.classList.contains('cp-agent-card')) return tab;
|
|
89
97
|
// Fallback: synthesize a card at the end of the root feed
|
|
90
98
|
const card = buildAgentCard({ id: parentToolUseId, name: 'Task', input: { description: 'agent' } }, tab);
|
|
91
99
|
const { scrollEnd, activeTab } = cpCtx;
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
import { cpCtx } from './cp-ctx.js';
|
|
9
9
|
import { keepsNothing } from './cp-temporary.js';
|
|
10
10
|
import { buildDiffPreviewEl } from './cp-diff.js';
|
|
11
|
+
import { synabunToolKey, synabunToolLabel } from '../synabun-tools.js';
|
|
11
12
|
import {
|
|
12
13
|
ALL_PERMISSION_MODES, MODE_LABELS, DESTINATIONS, describeSuggestion, alwaysUpdates, permissionContext,
|
|
13
14
|
elicitationFields, collectElicitation, elicitationUrl,
|
|
@@ -125,8 +126,11 @@ export function renderPermissionCard(tab, requestId, req, hooks) {
|
|
|
125
126
|
icon.innerHTML = toolIconSvg(toolName);
|
|
126
127
|
const name = document.createElement('span');
|
|
127
128
|
name.className = 'perm-tool-name';
|
|
128
|
-
name
|
|
129
|
-
|
|
129
|
+
// A SynaBun tool asks in SynaBun's colours, by its friendly name (the full name in the tooltip).
|
|
130
|
+
const sbKey = synabunToolKey(toolName);
|
|
131
|
+
if (sbKey != null) card.classList.add('synabun-perm');
|
|
132
|
+
name.textContent = ctx.displayName || (sbKey != null ? synabunToolLabel(sbKey) : toolName);
|
|
133
|
+
if (ctx.displayName || sbKey != null) name.title = toolName;
|
|
130
134
|
toolLine.append(icon, name);
|
|
131
135
|
card.appendChild(toolLine);
|
|
132
136
|
|
|
@@ -19,12 +19,32 @@ const STALE_ROWS = '.thinking, .msg-permission-prompt, .post-plan-card, .worker-
|
|
|
19
19
|
const STALE_PROMPTS = '.cp-plan-approval-card.active-perm, .perm-card.active-perm, .cp-rewind-confirm';
|
|
20
20
|
const SELF_WIRED_CARDS = '.tool-card.cp-bash-card, .tool-card.cp-diff-card, .tool-card.cp-agent-card';
|
|
21
21
|
|
|
22
|
+
/**
|
|
23
|
+
* The subagent cards of a transcript that name a call another card already shows
|
|
24
|
+
* as an ordinary tool (same `data-tool-id`): the fallback card a heartbeat of that
|
|
25
|
+
* call made, never a subagent. Removed; returns how many.
|
|
26
|
+
*/
|
|
27
|
+
export function dropHeartbeatAgentCards($msgs) {
|
|
28
|
+
if (!$msgs?.querySelectorAll) return 0;
|
|
29
|
+
const plain = new Set();
|
|
30
|
+
for (const card of $msgs.querySelectorAll('.tool-card[data-tool-id]')) {
|
|
31
|
+
if (!card.classList.contains('cp-agent-card')) plain.add(card.dataset.toolId);
|
|
32
|
+
}
|
|
33
|
+
let dropped = 0;
|
|
34
|
+
for (const card of $msgs.querySelectorAll('.tool-card.cp-agent-card[data-tool-id]')) {
|
|
35
|
+
if (!plain.has(card.dataset.toolId)) continue;
|
|
36
|
+
card.remove();
|
|
37
|
+
dropped++;
|
|
38
|
+
}
|
|
39
|
+
return dropped;
|
|
40
|
+
}
|
|
41
|
+
|
|
22
42
|
/**
|
|
23
43
|
* @param hooks.attachRewind (row, uuid) => void
|
|
24
44
|
* @param hooks.wireSubagent (card, agentId) => void
|
|
25
45
|
* @param hooks.loadFullResult (toolUseId) => Promise<string|null>
|
|
26
46
|
* @param hooks.restorePager (note, { start, total }) => void: put a live "Load earlier" in place of the stored note
|
|
27
|
-
* @returns {{ rewinds: number, cards: number, results: number, subagents: number, pagers?: number }}
|
|
47
|
+
* @returns {{ rewinds: number, cards: number, results: number, subagents: number, pagers?: number, heartbeatCards?: number }}
|
|
28
48
|
*/
|
|
29
49
|
export function rehydrateStoredTranscript($msgs, hooks = {}) {
|
|
30
50
|
const report = { rewinds: 0, cards: 0, results: 0, subagents: 0 };
|
|
@@ -36,6 +56,10 @@ export function rehydrateStoredTranscript($msgs, hooks = {}) {
|
|
|
36
56
|
const row = n.closest('.msg');
|
|
37
57
|
(n.classList.contains('cp-rewind-confirm') ? n : (row || n)).remove();
|
|
38
58
|
});
|
|
59
|
+
// 1b. A subagent card stored for an ordinary call: a long call's heartbeat drew one
|
|
60
|
+
// (tool-heartbeat.js), a purple bar between the tool rows. Its id is the call's own.
|
|
61
|
+
const heartbeatCards = dropHeartbeatAgentCards($msgs);
|
|
62
|
+
if (heartbeatCards) report.heartbeatCards = heartbeatCards;
|
|
39
63
|
// 2. Every control is inert until something below gives it a listener again:
|
|
40
64
|
// an answered card, a settled question, an old form must not look clickable.
|
|
41
65
|
$msgs.querySelectorAll('button, input, select, textarea').forEach((node) => { node.disabled = true; });
|
|
@@ -89,6 +89,39 @@ export function reduceTaskEvent(tasks, ev, now = Date.now()) {
|
|
|
89
89
|
|
|
90
90
|
export const isTaskRunning = (task) => !!task && !DONE.has(task.status);
|
|
91
91
|
|
|
92
|
+
/**
|
|
93
|
+
* The CLI process that ran these tasks is gone (an automation run ended, its query closed): nothing of it runs
|
|
94
|
+
* any more, whatever the last event said. A task it never reported the end of would show running forever.
|
|
95
|
+
* @returns how many tasks were ended
|
|
96
|
+
*/
|
|
97
|
+
export function endRunningTasks(tasks, now = Date.now()) {
|
|
98
|
+
if (!(tasks instanceof Map)) return 0;
|
|
99
|
+
let ended = 0;
|
|
100
|
+
for (const task of tasks.values()) {
|
|
101
|
+
if (!isTaskRunning(task)) continue;
|
|
102
|
+
task.status = 'ended';
|
|
103
|
+
task.endedAt = now;
|
|
104
|
+
ended++;
|
|
105
|
+
}
|
|
106
|
+
return ended;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** The status line a run's tab shows while its turn waits for its own background work (synabun.background_wait). */
|
|
110
|
+
export function backgroundWaitLine(ev) {
|
|
111
|
+
const tasks = Array.isArray(ev?.tasks) ? ev.tasks : [];
|
|
112
|
+
const names = tasks.map(t => clip(t?.description || t?.type || 'task', 80)).filter(Boolean);
|
|
113
|
+
const list = names.length ? `: ${names.slice(0, 3).join(', ')}${names.length > 3 ? ` and ${names.length - 3} more` : ''}` : '';
|
|
114
|
+
switch (ev?.state) {
|
|
115
|
+
case 'holding': return `Waiting for ${tasks.length || 'its'} background task${tasks.length === 1 ? '' : 's'} before this turn ends${list}.`;
|
|
116
|
+
case 'nudged': return 'The background work ended and the session did not continue by itself: it was asked to continue.';
|
|
117
|
+
case 'released':
|
|
118
|
+
if (ev.reason === 'idle_timeout') return `Stopped waiting: nothing happened for a long time${list ? ` while${list.slice(1)} still ran` : ''}.`;
|
|
119
|
+
if (ev.reason === 'deadline') return `Stopped waiting: the run reached its time limit${list ? ` with${list.slice(1)} still running` : ''}.`;
|
|
120
|
+
return '';
|
|
121
|
+
default: return '';
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
92
125
|
/**
|
|
93
126
|
* background_tasks_changed lists every live background task. A background task
|
|
94
127
|
* the list once carried and no longer does has ended (its own notification may
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// ═══════════════════════════════════════════
|
|
2
|
+
// SynaBun Neural Interface — the judgment log's origin filter
|
|
3
|
+
// ═══════════════════════════════════════════
|
|
4
|
+
// Which origins the log of Settings → AI decisions can be filtered by (ui-judgments.js draws the list). A server
|
|
5
|
+
// that knows coding-session attribution lists its own (`origins` in GET /api/typesafe/config); an older one sends
|
|
6
|
+
// none, and its log knows `live`, `backfill` and `bench` only. The list follows the latest answer both ways: the
|
|
7
|
+
// tab can open from a kept answer (settings/settings-data.js) and then hear from a server that lists none, and a
|
|
8
|
+
// filter it cannot apply must not stay offered.
|
|
9
|
+
// No DOM: runs under node --test as well.
|
|
10
|
+
|
|
11
|
+
/** What an older server's log can be filtered by: the list the tab offered before servers listed their own. */
|
|
12
|
+
export const LEGACY_LOG_ORIGINS = Object.freeze(['live', 'backfill', 'bench']);
|
|
13
|
+
|
|
14
|
+
/** The origins a config answer lists itself (non-empty strings, in its order); [] for a server that lists none. */
|
|
15
|
+
export function listedLogOrigins(cfg) {
|
|
16
|
+
return Array.isArray(cfg?.origins) ? cfg.origins.filter((o) => typeof o === 'string' && o) : [];
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The origin filter for a config answer: `{ listed, values, key }`. `listed` is whether the server named them,
|
|
21
|
+
* `values` the origins to offer (after "All origins"), `key` what the drawn list is compared by (the same values
|
|
22
|
+
* drawn from the server's list and from the older one look different).
|
|
23
|
+
*/
|
|
24
|
+
export function logOriginFilter(cfg) {
|
|
25
|
+
const own = listedLogOrigins(cfg);
|
|
26
|
+
const listed = own.length > 0;
|
|
27
|
+
const values = listed ? own : [...LEGACY_LOG_ORIGINS];
|
|
28
|
+
return { listed, values, key: `${listed ? 'server' : 'legacy'}:${values.join('|')}` };
|
|
29
|
+
}
|
|
@@ -5,6 +5,28 @@
|
|
|
5
5
|
|
|
6
6
|
const _runBySession = new Map();
|
|
7
7
|
const _registeredListeners = new Set();
|
|
8
|
+
// The automation sessions whose run is live (starting, running, or suspended by a server restart and
|
|
9
|
+
// resumed on the next start): the panel's own book of them (ocp-v2-panel.js `_automationRunning`), kept
|
|
10
|
+
// here so the socket layer can read it without importing the panel.
|
|
11
|
+
const _liveRuns = new Set();
|
|
12
|
+
|
|
13
|
+
/** The set of automation sessions whose run is live. The panel adds and deletes; everyone else reads. */
|
|
14
|
+
export function liveAutomationSessions() {
|
|
15
|
+
return _liveRuns;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* True when the run that drives `sessionId` answers that session's own permission asks by itself: an
|
|
20
|
+
* automation's root session while its run is live. Its native adapter replies to every ask (by the
|
|
21
|
+
* worker's confinement, or "once" when it has none; lib/native-loop-providers.js policyReply), and the
|
|
22
|
+
* asks it hands to a person go to the Assistant's own card. A protected worker's OpenCode rules ask for
|
|
23
|
+
* every shell call, so such an ask is a step of the run, not news. A sub-agent's ask is not answered by
|
|
24
|
+
* the run (the adapter keeps to its own session), and an ended run answers nothing.
|
|
25
|
+
*/
|
|
26
|
+
export function automationRunAnswersAsks(sessionId) {
|
|
27
|
+
const sid = clean(sessionId);
|
|
28
|
+
return !!sid && _runBySession.has(sid) && _liveRuns.has(sid);
|
|
29
|
+
}
|
|
8
30
|
|
|
9
31
|
function clean(value) {
|
|
10
32
|
return String(value || '').trim();
|
|
@@ -29,6 +51,7 @@ export function unregisterAutomationSession(sessionId, runId = null) {
|
|
|
29
51
|
if (!sid || !_runBySession.has(sid)) return false;
|
|
30
52
|
const expectedRunId = runId == null ? null : clean(runId);
|
|
31
53
|
if (expectedRunId != null && _runBySession.get(sid) !== expectedRunId) return false;
|
|
54
|
+
_liveRuns.delete(sid);
|
|
32
55
|
return _runBySession.delete(sid);
|
|
33
56
|
}
|
|
34
57
|
|
|
@@ -62,6 +62,19 @@ export function eventSessionId(ev) {
|
|
|
62
62
|
|
|
63
63
|
export const permissionRequestId = (ev) => String(ev?.requestID || ev?.id || ev?.permissionID || '');
|
|
64
64
|
|
|
65
|
+
/**
|
|
66
|
+
* Whether a new ask is announced to the person (sound, toast, OS banner). A permission ask
|
|
67
|
+
* of a session whose live automation run answers it by itself (`runAnswers(sessionId)`) is
|
|
68
|
+
* not: that run's adapter replies at once, and a protected worker's OpenCode rules ask for
|
|
69
|
+
* every shell call, so announcing it pinged the user after every step of the worker. A
|
|
70
|
+
* question, a sub-agent's ask and everything outside a live run still wait on a person.
|
|
71
|
+
*/
|
|
72
|
+
export function askNotifies(kind, ev, { runAnswers = () => false } = {}) {
|
|
73
|
+
if (kind !== 'permission') return true;
|
|
74
|
+
const owner = eventSessionId(ev);
|
|
75
|
+
return !(owner && runAnswers(owner));
|
|
76
|
+
}
|
|
77
|
+
|
|
65
78
|
// Requests a sub-agent raises have no panel of their own unless its child
|
|
66
79
|
// panel is open; they still have to reach the user.
|
|
67
80
|
const ASKED_EVENTS = new Set(['permission.asked', 'question.asked']);
|
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
// ocp/ tree.
|
|
5
5
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
6
6
|
|
|
7
|
+
import { synabunToolKey } from '../synabun-tools.js';
|
|
8
|
+
|
|
7
9
|
export const TOOL_ICONS = {
|
|
8
10
|
bash: '<svg viewBox="0 0 24 24"><polyline points="4 17 10 11 4 5"/><line x1="12" y1="19" x2="20" y2="19"/></svg>',
|
|
9
11
|
write: '<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"/><polyline points="14 2 14 8 20 8"/></svg>',
|
|
@@ -24,7 +26,7 @@ export const TOOL_ICONS = {
|
|
|
24
26
|
const SYNABUN_ICON = '<img src="logoHD.png" alt="" style="width:14px;height:14px;object-fit:contain;">';
|
|
25
27
|
|
|
26
28
|
export function toolIcon(name) {
|
|
27
|
-
if (name && (name
|
|
29
|
+
if (name && synabunToolKey(name) != null) return SYNABUN_ICON;
|
|
28
30
|
const key = (name || '').toLowerCase().replace(/[^a-z]/g, '');
|
|
29
31
|
return TOOL_ICONS[key] || TOOL_ICONS.bash;
|
|
30
32
|
}
|
|
@@ -59,7 +59,7 @@ import { mountCliBanner } from '../ui-cli-banner.js';
|
|
|
59
59
|
import { backToAssistant, buildWorkerEndCard, endWorkerRunOnClose, forgetWorkerEnd, trackWorkerEnd } from '../ui-worker-end.js';
|
|
60
60
|
import { isDispatchedRun } from '../worker-end.js';
|
|
61
61
|
import {
|
|
62
|
-
registerAutomationSession, unregisterAutomationSession, stopAutomationRun, isAutomationSession,
|
|
62
|
+
registerAutomationSession, unregisterAutomationSession, stopAutomationRun, isAutomationSession, liveAutomationSessions,
|
|
63
63
|
} from './ocp-v2-automation-ownership.js';
|
|
64
64
|
import {
|
|
65
65
|
registerPrimaryPanel, bindPrimarySession, isChildPanelOpen, getVisibleChildPanel, openChildSession,
|
|
@@ -101,7 +101,9 @@ let _tabSessionIds = []; // ordered session IDs that own a tray pill
|
|
|
101
101
|
let _tabPills = new Map(); // sessionId -> pill element
|
|
102
102
|
let _tabInfoCache = new Map(); // sessionId -> last-known session info (title, etc.)
|
|
103
103
|
const _automationRunIds = new Map(); // sessionId -> native loop runId
|
|
104
|
-
|
|
104
|
+
// The sessions whose automation run is live. The ownership module keeps the set, so that the socket layer
|
|
105
|
+
// knows which asks a run answers by itself (automationRunAnswersAsks) and announces none of them.
|
|
106
|
+
const _automationRunning = liveAutomationSessions();
|
|
105
107
|
// sessionId → what a live automation run's turn does ('working', 'waiting' on the user, 'idle' between turns:
|
|
106
108
|
// automationTurnPhase of the run's descriptor): its pill follows the turn, not the run.
|
|
107
109
|
const _automationTurn = new Map();
|