synabun 2.2.0 → 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 +45 -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 +27 -0
- package/neural-interface/i18n/pt-BR.json +27 -0
- package/neural-interface/lib/assistant-api.js +64 -23
- package/neural-interface/lib/assistant-brains/codex.js +6 -1
- package/neural-interface/lib/assistant-catalog.js +20 -2
- package/neural-interface/lib/assistant-dispatch.js +31 -2
- 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 +64 -13
- package/neural-interface/lib/native-loop-providers.js +122 -10
- package/neural-interface/lib/native-loop-runtime.js +112 -11
- package/neural-interface/lib/opencode-native-boundary.js +155 -21
- 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 +311 -47
- 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-api.js +14 -2
- package/neural-interface/public/shared/assistant/asst-computer.js +73 -4
- package/neural-interface/public/shared/assistant/asst-limit-wait.js +3 -1
- package/neural-interface/public/shared/assistant/asst-motion-gate.js +80 -0
- package/neural-interface/public/shared/assistant/asst-panel.js +8 -4
- package/neural-interface/public/shared/assistant/asst-render.js +72 -11
- package/neural-interface/public/shared/assistant/asst-scene-styles.js +55 -23
- package/neural-interface/public/shared/assistant/asst-scenes.js +225 -79
- package/neural-interface/public/shared/assistant/asst-sidepanel-styles.js +4 -4
- package/neural-interface/public/shared/assistant/asst-style-cache.js +44 -0
- package/neural-interface/public/shared/assistant/asst-styles.js +26 -5
- 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 +18 -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/loading-teardown.js +34 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-automation-ownership.js +23 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-childpanel.js +6 -1
- 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 +5 -2
- package/neural-interface/public/shared/ocp-v2/ocp-v2-render.js +16 -86
- package/neural-interface/public/shared/ocp-v2/ocp-v2-send.js +6 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-styles.js +88 -72
- 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/storage-retry.js +47 -0
- package/neural-interface/public/shared/storage.js +25 -4
- package/neural-interface/public/shared/styles.css +109 -8
- package/neural-interface/public/shared/synabun-mascot.js +27 -8
- package/neural-interface/public/shared/synabun-ticker.js +147 -12
- 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 +238 -90
- package/neural-interface/public/shared/ui-judgments.js +37 -10
- package/neural-interface/public/shared/ui-loading.js +5 -4
- 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 +1240 -238
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// ═══════════════════════════════════════════
|
|
2
|
+
// SynaBun Assistant — computed styles read once
|
|
3
|
+
// ═══════════════════════════════════════════
|
|
4
|
+
// A value the stylesheet decides and the renderer needs on a hot path (the
|
|
5
|
+
// rack's --rk-cut, where a long subject is cut; its bubble line's
|
|
6
|
+
// white-space), read once and kept until the renderer says it may have
|
|
7
|
+
// changed. getComputedStyle() on a frame's path forces a style recalculation
|
|
8
|
+
// of everything the frame dirtied (a rig's SVG, a scene); these values change
|
|
9
|
+
// only when a container query flips, which happens only when the stage's width
|
|
10
|
+
// changes, and the renderer's ResizeObserver sees every such change and calls
|
|
11
|
+
// invalidate().
|
|
12
|
+
//
|
|
13
|
+
// createStyleCache({ read }?) → { get(el, prop), invalidate(el?), reads() }
|
|
14
|
+
//
|
|
15
|
+
// `read(el, prop)` defaults to getComputedStyle(el).getPropertyValue(prop)
|
|
16
|
+
// (trimmed); a read that throws counts as ''. DOM-free: tested in Node.
|
|
17
|
+
|
|
18
|
+
const defaultRead = (el, prop) => globalThis.getComputedStyle(el).getPropertyValue(prop);
|
|
19
|
+
|
|
20
|
+
export function createStyleCache({ read = defaultRead } = {}) {
|
|
21
|
+
let values = new WeakMap(); // element → Map(prop → value)
|
|
22
|
+
let count = 0;
|
|
23
|
+
return {
|
|
24
|
+
/** The element's computed `prop` (a custom property or a longhand), read once until invalidated. */
|
|
25
|
+
get(el, prop) {
|
|
26
|
+
if (!el) return '';
|
|
27
|
+
let props = values.get(el);
|
|
28
|
+
if (!props) { props = new Map(); values.set(el, props); }
|
|
29
|
+
if (props.has(prop)) return props.get(prop);
|
|
30
|
+
count += 1;
|
|
31
|
+
let value = '';
|
|
32
|
+
try { value = String(read(el, prop) ?? '').trim(); } catch { value = ''; }
|
|
33
|
+
props.set(prop, value);
|
|
34
|
+
return value;
|
|
35
|
+
},
|
|
36
|
+
/** Forget one element's values, or every value (no argument). */
|
|
37
|
+
invalidate(el) {
|
|
38
|
+
if (el) values.delete(el);
|
|
39
|
+
else values = new WeakMap();
|
|
40
|
+
},
|
|
41
|
+
/** How many real reads were made (tests, the idle-CPU suite). */
|
|
42
|
+
reads: () => count,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
@@ -252,9 +252,13 @@ export function injectAssistantStyles() {
|
|
|
252
252
|
.asst-count.attention { color: var(--asst-warn); box-shadow: inset 0 0 0 1px var(--asst-pill-warn-ring); }
|
|
253
253
|
/* The running cameo: the mascot's two pill eyes, glancing ±1.2px every 1.4s.
|
|
254
254
|
One form everywhere (the header status, the tray pill, run pills):
|
|
255
|
-
mascotCameoSvg() from synabun-mascot.js, a 10×7 SVG.
|
|
255
|
+
mascotCameoSvg() from synabun-mascot.js, a 10×7 SVG in two spans. The
|
|
256
|
+
glance moves the HTML box around the eyes (.syna-cameo-eyes), along the
|
|
257
|
+
pair's −12° lean (1.2 of the SVG's 10×7 units: 11.738% and 3.564% of the
|
|
258
|
+
box), never a part of the SVG: a box's transform runs on the compositor,
|
|
259
|
+
and a frame the page draws anyway restyles one span and lays nothing out. */
|
|
256
260
|
.syna-cameo { display: inline-block; flex-shrink: 0; overflow: visible; color: var(--asst-brand); }
|
|
257
|
-
.syna-cameo-
|
|
261
|
+
.syna-cameo-eyes { display: block; animation: asst-cameo 2.8s var(--asst-ease-emphasized) infinite; }
|
|
258
262
|
|
|
259
263
|
/* ── Toolbar: flush under the terminal tabs ─────────────────────────
|
|
260
264
|
Edge to edge like the tab bar above it (same hairline), no card and no
|
|
@@ -284,7 +288,8 @@ export function injectAssistantStyles() {
|
|
|
284
288
|
padding: 4px;
|
|
285
289
|
}
|
|
286
290
|
.asst-bar-group { display: flex; flex: 0 1 auto; align-items: center; gap: 4px; min-width: 0; }
|
|
287
|
-
|
|
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; }
|
|
288
293
|
.asst-bar-group + .asst-bar-group::before {
|
|
289
294
|
content: '';
|
|
290
295
|
flex-shrink: 0;
|
|
@@ -1088,6 +1093,8 @@ export function injectAssistantStyles() {
|
|
|
1088
1093
|
border-radius: 50%;
|
|
1089
1094
|
animation: asst-spin .8s linear infinite;
|
|
1090
1095
|
}
|
|
1096
|
+
/* A spinner nobody can see never runs (a hidden holder still restyles a running loop every frame). */
|
|
1097
|
+
[hidden] .asst-spinner, .asst-spinner[hidden], [inert] .asst-spinner { animation: none; }
|
|
1091
1098
|
.asst-computer-activity { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 7px 8px 7px 12px; border-bottom: 1px solid var(--asst-line); }
|
|
1092
1099
|
.asst-live-dot { width: 6px; height: 6px; flex-shrink: 0; border-radius: 50%; background: var(--asst-live); animation: asst-live 1.4s var(--asst-ease-standard) infinite; }
|
|
1093
1100
|
.asst-computer-activity[data-state="paused_user"] .asst-live-dot { background: var(--asst-warn); animation: none; }
|
|
@@ -2063,10 +2070,24 @@ export function injectAssistantStyles() {
|
|
|
2063
2070
|
whole Assistant holds still: the component, its menus and modals, the
|
|
2064
2071
|
sidepanel frame and its header (.asp-*), and the tray pills. */
|
|
2065
2072
|
@keyframes asst-live { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .35; transform: scale(.8); } }
|
|
2066
|
-
@keyframes asst-cameo { 0%, 42% { transform:
|
|
2073
|
+
@keyframes asst-cameo { 0%, 42% { transform: translate(-11.738%, 3.564%); } 50%, 92% { transform: translate(11.738%, -3.564%); } 100% { transform: translate(-11.738%, 3.564%); } }
|
|
2067
2074
|
@keyframes asst-spin { to { transform: rotate(360deg); } }
|
|
2068
2075
|
|
|
2069
|
-
|
|
2076
|
+
/* A moving box gets its layer up front (only where motion is allowed; nothing is promoted under reduced motion). */
|
|
2077
|
+
@media (prefers-reduced-motion: no-preference) {
|
|
2078
|
+
.syna-cameo-eyes { will-change: transform; }
|
|
2079
|
+
}
|
|
2080
|
+
|
|
2081
|
+
body.ui-interacting :is(.asst-live-dot, .asst-spinner, .asst-computer-dot, .syna-cameo-eyes) { animation-play-state: paused !important; }
|
|
2082
|
+
|
|
2083
|
+
/* Off screen, nothing loops. A holder the renderer saw leave the viewport (asst-motion-gate.js marks it
|
|
2084
|
+
data-offscreen: a run card, a rack or a route line scrolled out of its transcript) and a closed side
|
|
2085
|
+
panel (it stays in the page, moved out and faded: .assistant-panel without .open) pause every loop
|
|
2086
|
+
under them; each picks up where it stopped when it is back. Every frame the page draws restyles each
|
|
2087
|
+
running animation, composited or not, so a loop nobody sees is never free. */
|
|
2088
|
+
[data-offscreen], [data-offscreen]::before, [data-offscreen]::after,
|
|
2089
|
+
[data-offscreen] *, [data-offscreen] *::before, [data-offscreen] *::after,
|
|
2090
|
+
.assistant-panel:not(.open) *, .assistant-panel:not(.open) *::before, .assistant-panel:not(.open) *::after { animation-play-state: paused !important; }
|
|
2070
2091
|
body.ui-interacting .asst-route-line[data-live] .asst-route-icon,
|
|
2071
2092
|
body.ui-interacting .asst-route-line[data-live] .asst-route-sweep::after { animation-play-state: paused !important; }
|
|
2072
2093
|
|
|
@@ -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,
|
|
@@ -16,6 +17,16 @@ import {
|
|
|
16
17
|
const ICON_CHECK = '<svg viewBox="0 0 16 16" width="11" height="11" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 8.5l3.5 3.5 6.5-7"/></svg>';
|
|
17
18
|
const ICON_X = '<svg viewBox="0 0 16 16" width="11" height="11" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><line x1="4" y1="4" x2="12" y2="12"/><line x1="12" y1="4" x2="4" y2="12"/></svg>';
|
|
18
19
|
|
|
20
|
+
// A waiting card's spinning border (.cp-spin-ring in ui-claude-panel.js): a box the compositor turns
|
|
21
|
+
// under the ring's mask while the card is .active-perm. The card's first child.
|
|
22
|
+
function spinRing() {
|
|
23
|
+
const ring = document.createElement('span');
|
|
24
|
+
ring.className = 'cp-spin-ring';
|
|
25
|
+
ring.setAttribute('aria-hidden', 'true');
|
|
26
|
+
ring.appendChild(document.createElement('i'));
|
|
27
|
+
return ring;
|
|
28
|
+
}
|
|
29
|
+
|
|
19
30
|
// Modes, rule suggestions and the prompt's context are decided in
|
|
20
31
|
// cp-permission-model.js (DOM-free, tested); this file renders them.
|
|
21
32
|
export const PERMISSION_MODES = ALL_PERMISSION_MODES;
|
|
@@ -100,6 +111,7 @@ export function renderPermissionCard(tab, requestId, req, hooks) {
|
|
|
100
111
|
const card = document.createElement('div');
|
|
101
112
|
card.className = 'perm-card active-perm cp-perm-card';
|
|
102
113
|
card.dataset.requestId = requestId;
|
|
114
|
+
card.appendChild(spinRing());
|
|
103
115
|
if (ctx.toolUseId) card.dataset.toolUseId = ctx.toolUseId;
|
|
104
116
|
|
|
105
117
|
const hdr = document.createElement('div');
|
|
@@ -114,8 +126,11 @@ export function renderPermissionCard(tab, requestId, req, hooks) {
|
|
|
114
126
|
icon.innerHTML = toolIconSvg(toolName);
|
|
115
127
|
const name = document.createElement('span');
|
|
116
128
|
name.className = 'perm-tool-name';
|
|
117
|
-
name
|
|
118
|
-
|
|
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;
|
|
119
134
|
toolLine.append(icon, name);
|
|
120
135
|
card.appendChild(toolLine);
|
|
121
136
|
|
|
@@ -283,6 +298,7 @@ export function renderElicitationCard(tab, requestId, req, hooks) {
|
|
|
283
298
|
const card = document.createElement('div');
|
|
284
299
|
card.className = 'perm-card active-perm cp-perm-card cp-elicit-card';
|
|
285
300
|
card.dataset.requestId = requestId;
|
|
301
|
+
card.appendChild(spinRing());
|
|
286
302
|
if (req.elicitation_id) card.dataset.elicitationId = req.elicitation_id;
|
|
287
303
|
|
|
288
304
|
const hdr = document.createElement('div');
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// SynaBun — taking the loading overlay out of rendering once it has faded (ui-loading.js). No imports, no DOM globals:
|
|
2
|
+
// the element and the timer are handed in (unit-tested under node --test).
|
|
3
|
+
//
|
|
4
|
+
// `hidden` fades the overlay to opacity 0 (0.8 s). A transparent overlay still renders, and its `#loading-text` pulse
|
|
5
|
+
// kept the page drawing 60 frames a second forever. After the fade the overlay also gets `gone` (display: none), which
|
|
6
|
+
// stops every animation inside it; showing it again removes both classes in the same call.
|
|
7
|
+
|
|
8
|
+
export const FADE_MS = 800;
|
|
9
|
+
|
|
10
|
+
/** Fade `el` out, then take it out of rendering. Returns a cancel function. */
|
|
11
|
+
export function concealOverlay(el, { setTimer = setTimeout, clearTimer = clearTimeout, fadeMs = FADE_MS } = {}) {
|
|
12
|
+
if (!el) return () => {};
|
|
13
|
+
el.classList.add('hidden');
|
|
14
|
+
let timer = null;
|
|
15
|
+
const done = () => {
|
|
16
|
+
timer = null;
|
|
17
|
+
el.removeEventListener?.('transitionend', onEnd);
|
|
18
|
+
if (el.classList.contains('hidden')) el.classList.add('gone');
|
|
19
|
+
};
|
|
20
|
+
const onEnd = (event) => { if (!event || event.target === el) { if (timer) clearTimer(timer); done(); } };
|
|
21
|
+
el.addEventListener?.('transitionend', onEnd);
|
|
22
|
+
// A transition that never runs (reduced motion, a background tab, display already none) still ends here.
|
|
23
|
+
timer = setTimer(done, fadeMs + 100);
|
|
24
|
+
el._synabunConceal = () => { if (timer) clearTimer(timer); timer = null; el.removeEventListener?.('transitionend', onEnd); };
|
|
25
|
+
return el._synabunConceal;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** Show `el` again (cancels a pending conceal). */
|
|
29
|
+
export function revealOverlay(el) {
|
|
30
|
+
if (!el) return;
|
|
31
|
+
el._synabunConceal?.();
|
|
32
|
+
el._synabunConceal = null;
|
|
33
|
+
el.classList.remove('gone', 'hidden');
|
|
34
|
+
}
|
|
@@ -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
|
|
|
@@ -517,7 +517,12 @@ export function createChildPanel({
|
|
|
517
517
|
close.setAttribute('data-tooltip', 'Close');
|
|
518
518
|
close.setAttribute('data-tooltip-pos', 'left');
|
|
519
519
|
close.textContent = '×';
|
|
520
|
-
|
|
520
|
+
// The working ring (ocp-v2-styles.js .ocpv2-pill-ring): a box the compositor turns under a mask.
|
|
521
|
+
const ring = document.createElement('span');
|
|
522
|
+
ring.className = 'ocpv2-pill-ring';
|
|
523
|
+
ring.setAttribute('aria-hidden', 'true');
|
|
524
|
+
ring.appendChild(document.createElement('i'));
|
|
525
|
+
pill.append(ring, icon, _pillLabel, _pillBadge, close);
|
|
521
526
|
// A click shows this sub-agent's panel; on the pill of the panel that is
|
|
522
527
|
// on screen it minimizes it (as the main panel's pill does).
|
|
523
528
|
pill.addEventListener('click', (event) => {
|
|
@@ -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();
|
|
@@ -2271,6 +2273,7 @@ function createTabPill(sessionId) {
|
|
|
2271
2273
|
pill.dataset.owner = PANEL_OWNER;
|
|
2272
2274
|
pill.dataset.sessionId = sessionId;
|
|
2273
2275
|
pill.innerHTML = `
|
|
2276
|
+
<span class="ocpv2-pill-ring" aria-hidden="true"><i></i></span>
|
|
2274
2277
|
<span class="term-minimized-pill-icon">${OPENCODE_ICON}</span>
|
|
2275
2278
|
<span class="term-minimized-pill-label">${escapeHtml(tabLabelFor(sessionId))}</span>
|
|
2276
2279
|
<button class="term-minimized-pill-close" data-tooltip="Close" data-tooltip-pos="top">×</button>
|