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.
Files changed (166) hide show
  1. package/CHANGELOG.md +45 -0
  2. package/README.md +1 -1
  3. package/hooks/claude-code/pre-websearch.mjs +4 -1
  4. package/hooks/claude-code/prompt-submit.mjs +7 -0
  5. package/lib/release-scan.mjs +23 -10
  6. package/lib/virustotal.mjs +143 -39
  7. package/mcp-server/dist/http.d.ts +19 -0
  8. package/mcp-server/dist/http.d.ts.map +1 -1
  9. package/mcp-server/dist/http.js +55 -13
  10. package/mcp-server/dist/http.js.map +1 -1
  11. package/mcp-server/dist/index.d.ts.map +1 -1
  12. package/mcp-server/dist/index.js +14 -9
  13. package/mcp-server/dist/index.js.map +1 -1
  14. package/mcp-server/dist/services/browser-route-flow.d.ts +118 -0
  15. package/mcp-server/dist/services/browser-route-flow.d.ts.map +1 -0
  16. package/mcp-server/dist/services/browser-route-flow.js +339 -0
  17. package/mcp-server/dist/services/browser-route-flow.js.map +1 -0
  18. package/mcp-server/dist/services/desktop-client.js +2 -2
  19. package/mcp-server/dist/services/desktop-client.js.map +1 -1
  20. package/mcp-server/dist/services/identity.d.ts +66 -3
  21. package/mcp-server/dist/services/identity.d.ts.map +1 -1
  22. package/mcp-server/dist/services/identity.js +61 -4
  23. package/mcp-server/dist/services/identity.js.map +1 -1
  24. package/mcp-server/dist/services/neural-interface.d.ts +112 -1
  25. package/mcp-server/dist/services/neural-interface.d.ts.map +1 -1
  26. package/mcp-server/dist/services/neural-interface.js +555 -61
  27. package/mcp-server/dist/services/neural-interface.js.map +1 -1
  28. package/mcp-server/dist/tools/bluesky.d.ts +20 -7
  29. package/mcp-server/dist/tools/bluesky.d.ts.map +1 -1
  30. package/mcp-server/dist/tools/bluesky.js +147 -45
  31. package/mcp-server/dist/tools/bluesky.js.map +1 -1
  32. package/mcp-server/dist/tools/browser-advanced.d.ts +11 -2
  33. package/mcp-server/dist/tools/browser-advanced.d.ts.map +1 -1
  34. package/mcp-server/dist/tools/browser-advanced.js +131 -18
  35. package/mcp-server/dist/tools/browser-advanced.js.map +1 -1
  36. package/mcp-server/dist/tools/browser-cheatsheet.d.ts +2 -0
  37. package/mcp-server/dist/tools/browser-cheatsheet.d.ts.map +1 -1
  38. package/mcp-server/dist/tools/browser-cheatsheet.js +3 -0
  39. package/mcp-server/dist/tools/browser-cheatsheet.js.map +1 -1
  40. package/mcp-server/dist/tools/morelogin.d.ts.map +1 -1
  41. package/mcp-server/dist/tools/morelogin.js +4 -2
  42. package/mcp-server/dist/tools/morelogin.js.map +1 -1
  43. package/mcp-server/dist/tools/skill-tools.d.ts +4 -4
  44. package/mcp-server/dist/tools/youtube/helpers.d.ts +1 -0
  45. package/mcp-server/dist/tools/youtube/helpers.d.ts.map +1 -1
  46. package/mcp-server/dist/tools/youtube/helpers.js +1 -1
  47. package/mcp-server/dist/tools/youtube/helpers.js.map +1 -1
  48. package/mcp-server/package-lock.json +2 -2
  49. package/mcp-server/package.json +1 -1
  50. package/mcp-server/src/http.ts +58 -12
  51. package/mcp-server/src/index.ts +15 -9
  52. package/mcp-server/src/services/browser-route-flow.ts +402 -0
  53. package/mcp-server/src/services/desktop-client.ts +2 -2
  54. package/mcp-server/src/services/identity.ts +80 -4
  55. package/mcp-server/src/services/neural-interface.ts +572 -70
  56. package/mcp-server/src/tools/bluesky.ts +164 -51
  57. package/mcp-server/src/tools/browser-advanced.ts +121 -17
  58. package/mcp-server/src/tools/browser-cheatsheet.ts +3 -0
  59. package/mcp-server/src/tools/morelogin.ts +4 -2
  60. package/mcp-server/src/tools/youtube/helpers.ts +2 -2
  61. package/neural-interface/i18n/en.json +27 -0
  62. package/neural-interface/i18n/pt-BR.json +27 -0
  63. package/neural-interface/lib/assistant-api.js +64 -23
  64. package/neural-interface/lib/assistant-brains/codex.js +6 -1
  65. package/neural-interface/lib/assistant-catalog.js +20 -2
  66. package/neural-interface/lib/assistant-dispatch.js +31 -2
  67. package/neural-interface/lib/assistant-persona.js +1 -0
  68. package/neural-interface/lib/assistant-runtime.js +15 -1
  69. package/neural-interface/lib/assistant-tools.js +10 -1
  70. package/neural-interface/lib/browser-automation-routes.js +84 -0
  71. package/neural-interface/lib/browser-execution.js +16 -3
  72. package/neural-interface/lib/browser-owner.js +48 -0
  73. package/neural-interface/lib/browser-session-close.js +84 -0
  74. package/neural-interface/lib/browser-start-handoff.js +202 -0
  75. package/neural-interface/lib/browser-tool-policy.js +21 -4
  76. package/neural-interface/lib/browser-wedge-retire.js +64 -0
  77. package/neural-interface/lib/claude-agent-bridge.js +36 -1
  78. package/neural-interface/lib/claude-background-hold.js +239 -0
  79. package/neural-interface/lib/exec-loop-command.js +8 -0
  80. package/neural-interface/lib/http-guards.js +11 -6
  81. package/neural-interface/lib/loop-logger.js +6 -1
  82. package/neural-interface/lib/mcp-external-servers.js +64 -13
  83. package/neural-interface/lib/native-loop-providers.js +122 -10
  84. package/neural-interface/lib/native-loop-runtime.js +112 -11
  85. package/neural-interface/lib/opencode-native-boundary.js +155 -21
  86. package/neural-interface/lib/owner-authority.js +113 -37
  87. package/neural-interface/lib/page-session.js +81 -23
  88. package/neural-interface/lib/peer-identity.js +311 -47
  89. package/neural-interface/lib/provider-panel-api-key-auth.js +7 -2
  90. package/neural-interface/lib/pty-host/core.js +36 -0
  91. package/neural-interface/lib/pty-host/protocol.js +2 -0
  92. package/neural-interface/lib/skills/api-v2.js +13 -2
  93. package/neural-interface/lib/skills/creation-api.js +3 -1
  94. package/neural-interface/lib/skills/evals-api.js +5 -1
  95. package/neural-interface/lib/social-write-pacing.js +151 -0
  96. package/neural-interface/lib/terminal-token-redaction.js +293 -0
  97. package/neural-interface/lib/terminal-tokens.js +359 -0
  98. package/neural-interface/lib/worker-mcp-channel.js +45 -10
  99. package/neural-interface/package-lock.json +2 -2
  100. package/neural-interface/package.json +1 -1
  101. package/neural-interface/public/shared/agy/agy-render.js +41 -1
  102. package/neural-interface/public/shared/agy/agy-styles.js +5 -0
  103. package/neural-interface/public/shared/api.js +1 -0
  104. package/neural-interface/public/shared/assistant/asst-api.js +14 -2
  105. package/neural-interface/public/shared/assistant/asst-computer.js +73 -4
  106. package/neural-interface/public/shared/assistant/asst-limit-wait.js +3 -1
  107. package/neural-interface/public/shared/assistant/asst-motion-gate.js +80 -0
  108. package/neural-interface/public/shared/assistant/asst-panel.js +8 -4
  109. package/neural-interface/public/shared/assistant/asst-render.js +72 -11
  110. package/neural-interface/public/shared/assistant/asst-scene-styles.js +55 -23
  111. package/neural-interface/public/shared/assistant/asst-scenes.js +225 -79
  112. package/neural-interface/public/shared/assistant/asst-sidepanel-styles.js +4 -4
  113. package/neural-interface/public/shared/assistant/asst-style-cache.js +44 -0
  114. package/neural-interface/public/shared/assistant/asst-styles.js +26 -5
  115. package/neural-interface/public/shared/cdx/cdx-render.js +73 -7
  116. package/neural-interface/public/shared/cdx/cdx-tabs.js +3 -3
  117. package/neural-interface/public/shared/cp/cp-agents.js +8 -0
  118. package/neural-interface/public/shared/cp/cp-permissions.js +18 -2
  119. package/neural-interface/public/shared/cp/cp-rehydrate.js +25 -1
  120. package/neural-interface/public/shared/cp/cp-tasks-model.js +33 -0
  121. package/neural-interface/public/shared/judgments-log-origins.js +29 -0
  122. package/neural-interface/public/shared/loading-teardown.js +34 -0
  123. package/neural-interface/public/shared/ocp-v2/ocp-v2-automation-ownership.js +23 -0
  124. package/neural-interface/public/shared/ocp-v2/ocp-v2-childpanel.js +6 -1
  125. package/neural-interface/public/shared/ocp-v2/ocp-v2-events.js +13 -0
  126. package/neural-interface/public/shared/ocp-v2/ocp-v2-icons.js +3 -1
  127. package/neural-interface/public/shared/ocp-v2/ocp-v2-panel.js +5 -2
  128. package/neural-interface/public/shared/ocp-v2/ocp-v2-render.js +16 -86
  129. package/neural-interface/public/shared/ocp-v2/ocp-v2-send.js +6 -0
  130. package/neural-interface/public/shared/ocp-v2/ocp-v2-styles.js +88 -72
  131. package/neural-interface/public/shared/ocp-v2/ocp-v2-ws.js +5 -2
  132. package/neural-interface/public/shared/owner-access.js +134 -0
  133. package/neural-interface/public/shared/owner-authority-view.js +92 -0
  134. package/neural-interface/public/shared/page-session.js +143 -14
  135. package/neural-interface/public/shared/poll-backoff.js +59 -0
  136. package/neural-interface/public/shared/settings/settings-data.js +6 -1
  137. package/neural-interface/public/shared/settings/settings-kit.js +11 -3
  138. package/neural-interface/public/shared/settings/settings-shell.js +7 -0
  139. package/neural-interface/public/shared/shown-children.js +72 -0
  140. package/neural-interface/public/shared/static-bg-state.js +22 -0
  141. package/neural-interface/public/shared/storage-retry.js +47 -0
  142. package/neural-interface/public/shared/storage.js +25 -4
  143. package/neural-interface/public/shared/styles.css +109 -8
  144. package/neural-interface/public/shared/synabun-mascot.js +27 -8
  145. package/neural-interface/public/shared/synabun-ticker.js +147 -12
  146. package/neural-interface/public/shared/synabun-tools.js +173 -0
  147. package/neural-interface/public/shared/tool-heartbeat.js +43 -0
  148. package/neural-interface/public/shared/tool-list-picker.js +3 -1
  149. package/neural-interface/public/shared/tool-list-view.js +23 -4
  150. package/neural-interface/public/shared/ui-automation-studio.js +8 -1
  151. package/neural-interface/public/shared/ui-claude-panel.js +238 -90
  152. package/neural-interface/public/shared/ui-judgments.js +37 -10
  153. package/neural-interface/public/shared/ui-loading.js +5 -4
  154. package/neural-interface/public/shared/ui-navbar.js +6 -0
  155. package/neural-interface/public/shared/ui-owner-access.js +191 -0
  156. package/neural-interface/public/shared/ui-owner-authority.js +162 -0
  157. package/neural-interface/public/shared/ui-sessions.js +45 -16
  158. package/neural-interface/public/shared/ui-settings.js +86 -15
  159. package/neural-interface/public/shared/ui-terminal.js +15 -7
  160. package/neural-interface/public/shared/ui-tutorial-preview.js +4 -0
  161. package/neural-interface/public/shared/ui-update.js +3 -0
  162. package/neural-interface/public/shared/ui-whiteboard.js +4 -0
  163. package/neural-interface/public/shared/window-keys.js +38 -0
  164. package/neural-interface/server.js +1240 -238
  165. package/npm-shrinkwrap.json +2 -2
  166. package/package.json +1 -1
@@ -0,0 +1,359 @@
1
+ // ── Who a run is: the per-run terminal token (X-Synabun-Terminal-Token) ──
2
+ //
3
+ // Every automation that uses SynaBun's browser names itself in X-Synabun-Terminal (lib/browser-owner.js): a loop's
4
+ // terminal id, a native run's or a dispatched worker's run id, `agent:<uuid>` for an automation-window agent. The
5
+ // header is self-asserted, and its value is no secret (it is in loop files, logs, task text and process
6
+ // environments), so before 2026-11-04 any local process could name another run and recover, move, adopt, drive or
7
+ // close that run's browser tab (review finding 9).
8
+ //
9
+ // The same answer SynaBun already gives the Assistant's brain (assistant-runtime.js mintBrainCredential): a credential
10
+ // minted per launch, kept in memory only, handed to that launch's own MCP server alone, and compared in constant time.
11
+ // Here it is one token per run, minted where the server mints the run's terminal id (issue()), and handed to the
12
+ // run's SynaBun MCP through its environment or an MCP header that names the environment variable (never a file
13
+ // under data/, which every backup holds, and never a command line, which every account of the computer can read):
14
+ //
15
+ // • an automation-window agent: SYNABUN_TERMINAL_TOKEN in the agent CLI's environment, named by the stdio SynaBun
16
+ // entry of its mcp.json (`${SYNABUN_TERMINAL_TOKEN}`, expanded by the CLI);
17
+ // • a Claude Code terminal loop: the PTY's environment, named by the loop's MCP config header;
18
+ // • an exec loop (Codex, OpenCode, Antigravity in a shell): the PTY's environment; Codex forwards it by name
19
+ // (`mcp_servers.SynaBun.env_vars`), OpenCode's loop config names it (`{env:SYNABUN_TERMINAL_TOKEN}`), Antigravity's
20
+ // MCP child inherits it;
21
+ // • a native run (a loop, a schedule, a dispatched worker): NativeLoopRuntime issues it at launch and resume and
22
+ // passes it to the provider as a function (`terminalTokenProvider`, never in the state file);
23
+ // • a sandboxed worker on the worker-only MCP channel: the channel adds it itself, from the run its path token names.
24
+ //
25
+ // The MCP server sends it with X-Synabun-Terminal on every request to the Neural Interface, only for the id it was
26
+ // given for (mcp-server/src/services/identity.ts callerTerminalToken). The server reads both (server.js
27
+ // browserCaller) and decides with verdict():
28
+ //
29
+ // • verified — the id has a proof (a token, or a brain's bound credential) and the request carries it;
30
+ // • unregistered — an id SynaBun gave no proof (an MCP process's own client id, a CLI window's MCP session, the
31
+ // Antigravity panel's agy, a run from before this server started): self-asserted, as before (an id
32
+ // SynaBun minted a proof for can never be claimed this way);
33
+ // • missing — the id has a proof and the request carries none: refused (403 TERMINAL_TOKEN_REQUIRED), unless
34
+ // SYNABUN_TERMINAL_TOKEN_MODE=grace while its window is open (accepted and logged: a stale MCP build);
35
+ // • invalid — a token that is not the id's: refused (403 TERMINAL_TOKEN_INVALID), in every mode;
36
+ // • revoked — the run ended (revoke()), or holds no live process (retire(): a worker waiting for its resume
37
+ // after a restart): refused like an invalid token, in every mode. Kept for the last
38
+ // REVOKED_KEPT_MAX ended runs, so an ended run's id is never reopened to self-assertion.
39
+ //
40
+ // Lifecycle: revoke() at the run's end (server.js endAutomationBrowser, the native runtime's finish, a launch that
41
+ // failed). Nothing is persisted: after a restart the registry is empty; PTY loops and agents end with the server,
42
+ // and a dispatched worker that resumes gets a new token with its new process (the moment its tab and desktop grant
43
+ // are renewed). A token belongs to one process of the run: rotate() gives the run a new one and the old one is
44
+ // nothing from then on (a native run's resume, a side panel's new CLI or serve), and a suspended run holds none.
45
+ //
46
+ // Side panels and Assistant brains (2026-11-04, follow-up to review c0eab425): a Claude Code panel tab, a Codex panel
47
+ // connection and an OpenCode panel serve get a token of their own where their id is minted (rotated with every process
48
+ // they start, revoked when the tab, the connection or the serve ends). An Assistant brain already holds a per-launch
49
+ // credential that only its own SynaBun MCP has (`sbb_…`, assistant-runtime.js mintBrainCredential): bind() makes that
50
+ // credential the proof of the brain's id, so no second secret exists; its MCP presents it in X-Synabun-Terminal-Token
51
+ // like a token (or the server reads X-Synabun-Brain-Token when that header is absent), and it is revoked with the brain.
52
+ // Ids SynaBun does not mint stay unregistered: a CLI window's own MCP session, the Antigravity panel's agy (it runs
53
+ // with the user's own MCP configuration, which names no pin), an MCP process's own client id.
54
+ //
55
+ // Grace (SYNABUN_TERMINAL_TOKEN_MODE=grace): every acceptance of a run's id without its token is logged (one line per
56
+ // run a minute at most, with how many more there were), and grace ends by itself SYNABUN_TERMINAL_TOKEN_GRACE_MINUTES
57
+ // after the server started (24 hours unless set; `never` keeps it while the mode says so), strict from then on.
58
+
59
+ import { createHash, randomBytes as cryptoRandomBytes, timingSafeEqual } from 'node:crypto';
60
+ import { BROWSER_OWNER_ID_RE } from './browser-owner.js';
61
+ import { registerKnownSecret, forgetKnownSecret } from './terminal-token-redaction.js';
62
+ export { TOKEN_PLACEHOLDER, scrubTokenText, containsTokenText, redactTerminalSecrets, createTokenStreamRedactor, encodedSecretForms, registerKnownSecret, forgetKnownSecret } from './terminal-token-redaction.js';
63
+
64
+ /** The request header the MCP server sends the token in. */
65
+ export const TERMINAL_TOKEN_HEADER = 'x-synabun-terminal-token';
66
+ /** The environment variable a run's MCP server reads it from (stdio), or its MCP header names (Claude Code). */
67
+ export const TERMINAL_TOKEN_ENV = 'SYNABUN_TERMINAL_TOKEN';
68
+ /** A token's shape: `sbt_` + 32 random bytes, base64url (256 bits). */
69
+ export const TERMINAL_TOKEN_RE = /^sbt_[A-Za-z0-9_-]{43}$/;
70
+ /** `grace`: a registered id without a token is accepted (logged). Anything else, or nothing, is strict. */
71
+ export const TERMINAL_TOKEN_MODE_ENV = 'SYNABUN_TERMINAL_TOKEN_MODE';
72
+ /** How long grace lasts after the server started, in minutes (a positive number), or `never`. Unset: 24 hours. */
73
+ export const TERMINAL_TOKEN_GRACE_MINUTES_ENV = 'SYNABUN_TERMINAL_TOKEN_GRACE_MINUTES';
74
+ /** Grace's default window. */
75
+ export const GRACE_DEFAULT_MINUTES = 24 * 60;
76
+ /** At most one grace line per run in this long (the acceptances in between are counted in the next line). */
77
+ export const GRACE_LOG_EVERY_MS = 60_000;
78
+ /** An Assistant brain's launch credential (assistant-runtime.js BRAIN_CREDENTIAL_RE): what proves a brain's id. */
79
+ export const BRAIN_CREDENTIAL_SHAPE_RE = /^sbb_[A-Za-z0-9_-]{43}$/;
80
+ /** The header a brain's MCP sends its launch credential in (also read as the proof of its id when no token is sent). */
81
+ export const BRAIN_CREDENTIAL_HEADER = 'x-synabun-brain-token';
82
+ /** How many ended runs stay refused (oldest first out). */
83
+ export const REVOKED_KEPT_MAX = 10_000;
84
+
85
+ /** A new token. */
86
+ export function mintTerminalToken(random = cryptoRandomBytes) {
87
+ return `sbt_${random(32).toString('base64url')}`;
88
+ }
89
+
90
+ /** `value` as a token, or null (absent, not a string, not shaped like one SynaBun mints). */
91
+ export function sanitizeTerminalToken(value) {
92
+ const text = typeof value === 'string' ? value.trim() : '';
93
+ return TERMINAL_TOKEN_RE.test(text) ? text : null;
94
+ }
95
+
96
+ /** `value` as a proof of an id: a terminal token, or a brain's launch credential (bind()), else null. */
97
+ export function sanitizeTerminalProof(value) {
98
+ const text = typeof value === 'string' ? value.trim() : '';
99
+ return TERMINAL_TOKEN_RE.test(text) || BRAIN_CREDENTIAL_SHAPE_RE.test(text) ? text : null;
100
+ }
101
+
102
+ /** 'grace' when the environment says so, else 'strict'. Read at every check. */
103
+ export function terminalTokenMode(env = process.env) {
104
+ return String(env?.[TERMINAL_TOKEN_MODE_ENV] || '').trim().toLowerCase() === 'grace' ? 'grace' : 'strict';
105
+ }
106
+
107
+ /**
108
+ * How long grace lasts after the server started (SYNABUN_TERMINAL_TOKEN_GRACE_MINUTES), in milliseconds: a positive
109
+ * number of minutes, Infinity for `never`, else (unset, 0, anything unreadable) the 24-hour default.
110
+ */
111
+ export function terminalTokenGraceWindowMs(env = process.env) {
112
+ const raw = String(env?.[TERMINAL_TOKEN_GRACE_MINUTES_ENV] ?? '').trim().toLowerCase();
113
+ if (raw === 'never') return Infinity;
114
+ const minutes = Number(raw);
115
+ return raw && Number.isFinite(minutes) && minutes > 0 ? minutes * 60_000 : GRACE_DEFAULT_MINUTES * 60_000;
116
+ }
117
+
118
+ const digestOf = (text) => createHash('sha256').update(String(text)).digest();
119
+
120
+ /**
121
+ * The refusal of a request that names a run it cannot prove it is: 403 and a code, never the token.
122
+ * @param {'missing'|'invalid'|'revoked'} status
123
+ * @param {string} id the run the request named
124
+ */
125
+ export function terminalRefusal(status, id) {
126
+ const run = String(id).slice(0, 128);
127
+ if (status === 'missing') {
128
+ return {
129
+ status: 403, code: 'TERMINAL_TOKEN_REQUIRED',
130
+ error: `This request names run ${run} (X-Synabun-Terminal) without that run's terminal token (X-Synabun-Terminal-Token). SynaBun gives the token to the run's own SynaBun MCP server when it starts the run; another process cannot act as that run. An MCP server built before this check needs \`npm run mcp:build\` and the run started again.`,
131
+ };
132
+ }
133
+ if (status === 'revoked') {
134
+ return {
135
+ status: 403, code: 'TERMINAL_TOKEN_INVALID',
136
+ error: `Run ${run} has ended: its terminal token was revoked, and nothing may act as that run any more.`,
137
+ };
138
+ }
139
+ return {
140
+ status: 403, code: 'TERMINAL_TOKEN_INVALID',
141
+ error: `This request names run ${run} (X-Synabun-Terminal) with a terminal token that is not that run's (X-Synabun-Terminal-Token). Only the run's own SynaBun MCP server can act as it.`,
142
+ };
143
+ }
144
+
145
+ /**
146
+ * @param {{ random?: (n: number) => Buffer, equal?: (a: Buffer, b: Buffer) => boolean, mode?: () => 'strict'|'grace',
147
+ * maxRevoked?: number, log?: (line: string) => void, graceWindowMs?: () => number, now?: () => number,
148
+ * logEveryMs?: number }} [options]
149
+ * `equal` is the constant-time comparison (crypto.timingSafeEqual); tests hand in a counting one. `mode` is what the
150
+ * environment says (read at every check); `graceWindowMs` how long grace may last after the registry was made (the
151
+ * server's start), read at every check too; `now` the clock. `knownSecrets` is told every live proof and every one
152
+ * that stops proving anything (lib/terminal-token-redaction.js: the scrubbers then mask its base64 and hex too).
153
+ */
154
+ export function createTerminalTokenRegistry({
155
+ random = cryptoRandomBytes,
156
+ equal = timingSafeEqual,
157
+ mode = () => terminalTokenMode(),
158
+ maxRevoked = REVOKED_KEPT_MAX,
159
+ log = () => {},
160
+ graceWindowMs = () => terminalTokenGraceWindowMs(),
161
+ now = Date.now,
162
+ logEveryMs = GRACE_LOG_EVERY_MS,
163
+ knownSecrets = { add: registerKnownSecret, remove: forgetKnownSecret },
164
+ } = {}) {
165
+ const live = new Map(); // terminal id → { token, digest, kind: 'token' | 'credential' }
166
+ const revoked = new Set(); // ids of ended runs, oldest first
167
+ const graceLog = new Map(); // id → { at, more }: when a grace acceptance was last logged, and how many since
168
+ const cap = Math.max(1, Number(maxRevoked) || REVOKED_KEPT_MAX);
169
+ const startedAt = now();
170
+ let graceExpiryLogged = false;
171
+ const idOf = (value) => (typeof value === 'string' && BROWSER_OWNER_ID_RE.test(value) ? value : null);
172
+ const say = (line) => { try { log(line); } catch { /* a logger's own failure */ } };
173
+
174
+ /** When grace ends (ms since the epoch), or Infinity. */
175
+ function graceEndsAt() {
176
+ let windowMs;
177
+ try { windowMs = Number(graceWindowMs()); } catch { windowMs = GRACE_DEFAULT_MINUTES * 60_000; }
178
+ if (!(windowMs > 0)) windowMs = GRACE_DEFAULT_MINUTES * 60_000;
179
+ return startedAt + windowMs;
180
+ }
181
+ /** What the environment asks for ('grace' | 'strict'). */
182
+ function configuredMode() {
183
+ try { return mode() === 'grace' ? 'grace' : 'strict'; } catch { return 'strict'; }
184
+ }
185
+ /** The mode in force: grace only while the environment asks for it and its window is open. */
186
+ function currentMode() {
187
+ if (configuredMode() !== 'grace') return 'strict';
188
+ if (now() < graceEndsAt()) return 'grace';
189
+ if (!graceExpiryLogged) {
190
+ graceExpiryLogged = true;
191
+ say(`[terminal-tokens] grace has ended (${TERMINAL_TOKEN_GRACE_MINUTES_ENV}): a run named without its terminal token is refused from now on, as in strict mode`);
192
+ }
193
+ return 'strict';
194
+ }
195
+ /** One line per run a minute at most for grace acceptances, with how many more there were since the last one. */
196
+ function noteGrace(terminalId) {
197
+ const id = String(terminalId).slice(0, 128);
198
+ const at = now();
199
+ const seen = graceLog.get(id);
200
+ if (seen && at - seen.at < logEveryMs) { seen.more += 1; return; }
201
+ const more = seen?.more || 0;
202
+ graceLog.delete(id);
203
+ graceLog.set(id, { at, more: 0 });
204
+ while (graceLog.size > cap) graceLog.delete(graceLog.keys().next().value);
205
+ const ends = graceEndsAt();
206
+ say(`[terminal-tokens] grace: run ${id} was let through without its terminal token (${TERMINAL_TOKEN_MODE_ENV}=grace)${more ? `; ${more} more time${more === 1 ? '' : 's'} since the last line` : ''}${Number.isFinite(ends) ? `; grace ends at ${new Date(ends).toISOString()}` : ''}`);
207
+ }
208
+
209
+ /** The scrubbers learn a live proof's value and forget a dead one's (never a reason to fail a check). */
210
+ const known = (op, token) => { try { knownSecrets?.[op]?.(token); } catch { /* scrubbing by shape still holds */ } };
211
+ /** Drop `id`'s live proof, and tell the scrubbers (a credential bound to several ids stays known while one holds it). */
212
+ function dropLive(id) {
213
+ const held = live.get(id);
214
+ if (!held) return false;
215
+ live.delete(id);
216
+ if (![...live.values()].some((other) => other.token === held.token)) known('remove', held.token);
217
+ return true;
218
+ }
219
+ function setLive(id, token, kind) {
220
+ revoked.delete(id);
221
+ graceLog.delete(id);
222
+ if (live.has(id)) dropLive(id);
223
+ live.set(id, { token, digest: digestOf(token), kind });
224
+ known('add', token);
225
+ return token;
226
+ }
227
+
228
+ /** The live token of `terminalId`, minted now when it has none (also after a revoke: a run started again). */
229
+ function issue(terminalId) {
230
+ const id = idOf(terminalId);
231
+ if (!id) return null;
232
+ const held = live.get(id);
233
+ if (held) return held.token;
234
+ return setLive(id, mintTerminalToken(random), 'token');
235
+ }
236
+
237
+ /**
238
+ * A new token for `terminalId` (a run's new process: a resume, a side panel's new CLI or serve): the one it held
239
+ * stops proving anything, and the id is not an ended run's. Returns the new token, or null for an id SynaBun does
240
+ * not mint.
241
+ */
242
+ function rotate(terminalId) {
243
+ const id = idOf(terminalId);
244
+ if (!id) return null;
245
+ dropLive(id);
246
+ return setLive(id, mintTerminalToken(random), 'token');
247
+ }
248
+
249
+ /**
250
+ * Make an existing credential the proof of `terminalId`: an Assistant brain's launch credential (`sbb_…`) for the
251
+ * pin its SynaBun MCP names, so the brain proves its id with the one secret it already has. Replaces what the id
252
+ * held. Returns whether it was bound (false for an id or a credential of another shape).
253
+ */
254
+ function bind(terminalId, credential) {
255
+ const id = idOf(terminalId);
256
+ const proof = sanitizeTerminalProof(credential);
257
+ if (!id || !proof) return false;
258
+ setLive(id, proof, BRAIN_CREDENTIAL_SHAPE_RE.test(proof) ? 'credential' : 'token');
259
+ return true;
260
+ }
261
+
262
+ /** The live token of `terminalId`, or null (none issued, or revoked). For a handoff to a process the run starts. */
263
+ function tokenFor(terminalId) {
264
+ const id = idOf(terminalId);
265
+ return id ? live.get(id)?.token || null : null;
266
+ }
267
+
268
+ /** The run ended: its token stops working, and its id stays refused. Returns whether it held one. */
269
+ function revoke(terminalId) {
270
+ const id = idOf(terminalId);
271
+ if (!id) return false;
272
+ const had = dropLive(id);
273
+ graceLog.delete(id);
274
+ if (had || revoked.has(id)) {
275
+ revoked.delete(id);
276
+ revoked.add(id);
277
+ while (revoked.size > cap) revoked.delete(revoked.values().next().value);
278
+ }
279
+ return had;
280
+ }
281
+
282
+ /**
283
+ * Refuse `terminalId` from now on although it holds no token here: a run this server knows to have no live process
284
+ * (a dispatched worker a restart suspended, waiting for its resume, which issues a fresh token). Without this such an
285
+ * id would be unregistered, taken as said. Returns whether the id was one SynaBun mints.
286
+ */
287
+ function retire(terminalId) {
288
+ const id = idOf(terminalId);
289
+ if (!id) return false;
290
+ dropLive(id);
291
+ graceLog.delete(id);
292
+ revoked.delete(id);
293
+ revoked.add(id);
294
+ while (revoked.size > cap) revoked.delete(revoked.values().next().value);
295
+ return true;
296
+ }
297
+
298
+ /**
299
+ * 'verified' | 'unregistered' | 'missing' | 'invalid' | 'revoked' for a request naming `terminalId` with `presented`
300
+ * (a token, or for a brain's id its launch credential). The comparison is of the SHA-256 digests with `equal`
301
+ * (timingSafeEqual): its time does not depend on where a guess differs from the proof, and every well-formed guess
302
+ * is compared.
303
+ */
304
+ function check(terminalId, presented) {
305
+ const id = typeof terminalId === 'string' ? terminalId : '';
306
+ const held = id ? live.get(id) : null;
307
+ const absent = presented === undefined || presented === null || presented === '';
308
+ if (!held) {
309
+ if (id && revoked.has(id)) return 'revoked';
310
+ return 'unregistered';
311
+ }
312
+ if (absent) return 'missing';
313
+ const proof = sanitizeTerminalProof(presented);
314
+ if (!proof) return 'invalid';
315
+ return equal(digestOf(proof), held.digest) ? 'verified' : 'invalid';
316
+ }
317
+
318
+ /**
319
+ * The decision for one request: `{ status, accepted }`, and for a refusal its `code`, `error` and HTTP `httpStatus`.
320
+ * `grace` lets a registered id without a token through while its window is open (every acceptance logged, a line a
321
+ * minute per run at most); a wrong token or an ended run never.
322
+ */
323
+ function verdict(terminalId, presented) {
324
+ const status = check(terminalId, presented);
325
+ if (status === 'verified' || status === 'unregistered') return { status, accepted: true };
326
+ if (status === 'missing' && currentMode() === 'grace') {
327
+ noteGrace(terminalId);
328
+ return { status, accepted: true, grace: true };
329
+ }
330
+ const refusal = terminalRefusal(status, terminalId);
331
+ return { status, accepted: false, code: refusal.code, error: refusal.error, httpStatus: refusal.status };
332
+ }
333
+
334
+ return {
335
+ issue,
336
+ rotate,
337
+ bind,
338
+ tokenFor,
339
+ revoke,
340
+ retire,
341
+ check,
342
+ verdict,
343
+ /** Whether `id` may be used by this request (the in-process MCP server's terminalAuth). */
344
+ accepts: (terminalId, presented) => verdict(terminalId, presented).accepted,
345
+ /** Whether `id` holds a live token (or a bound credential). */
346
+ has: (terminalId) => live.has(terminalId),
347
+ /** Whether `id` is an ended run's. */
348
+ isRevoked: (terminalId) => revoked.has(terminalId),
349
+ /** The mode in force: 'grace' only while the environment asks for it and its window is open. */
350
+ mode: () => currentMode(),
351
+ /** For diagnostics: the mode in force, the one asked for, and when grace ends (an ISO time, or null for never). */
352
+ graceState: () => {
353
+ const ends = graceEndsAt();
354
+ return { mode: currentMode(), configured: configuredMode(), endsAt: Number.isFinite(ends) ? new Date(ends).toISOString() : null };
355
+ },
356
+ /** For tests and diagnostics: how many runs hold a token, how many ended ones are kept. */
357
+ stats: () => ({ live: live.size, revoked: revoked.size }),
358
+ };
359
+ }
@@ -28,12 +28,16 @@
28
28
  import express from 'express';
29
29
  import net from 'node:net';
30
30
  import { randomUUID } from 'node:crypto';
31
+ import { isAutomationBrowserRoute } from './browser-automation-routes.js';
31
32
 
32
33
  // The only Neural-Interface API a sandboxed worker's stdio MCP child (OpenCode) may reach through the channel: the
33
- // browser tools, which it drives over HTTP to NEURAL_INTERFACE_URL. Everything else it does (memory) is direct DB
34
- // I/O in its own process and never touches the channel. The owner's API (/api/assistant, /api/page-session, …) is
35
- // NEVER proxied — the channel is not a way back to the control surface.
36
- const PROXY_PREFIXES = Object.freeze(['/browser/', '/browser']);
34
+ // browser routes its browser tools call over HTTP to NEURAL_INTERFACE_URL, exactly (lib/browser-automation-routes.js:
35
+ // the session list, create and close, acquire and release, the page actions on a session). Everything else it does
36
+ // (memory) is direct DB I/O in its own process and never touches the channel. The owner's API (/api/assistant,
37
+ // /api/page-session, …) and the owner's browser routes (the browser settings, the money guard's lift, the CDP
38
+ // endpoints, tab management) are NEVER proxied: the channel is not a way back to the control surface. Until
39
+ // 2026-11-05 it forwarded every /browser/* path with the run's token (review 972afb74, finding 1).
40
+ const BROWSER_PREFIX = '/api/browser';
37
41
 
38
42
  const freePort = () => new Promise((done, fail) => {
39
43
  const s = net.createServer();
@@ -42,18 +46,42 @@ const freePort = () => new Promise((done, fail) => {
42
46
  });
43
47
 
44
48
  // Headers a worker's request to the channel must never carry into the MCP server: owner / brain authority and the
45
- // from-outside markers. The run's routing pins and its own desktop grant are kept.
49
+ // from-outside markers. The run's routing pins and its own desktop grant are kept. A terminal token the worker sends
50
+ // is dropped too: the channel adds its run's own (below), from the run the path token names.
46
51
  const STRIPPED_HEADERS = Object.freeze([
47
52
  'x-synabun-tools', 'x-synabun-brain-token', 'x-synabun-assistant', 'x-synabun-role',
48
53
  'cookie', 'cf-connecting-ip', 'x-forwarded-host', 'x-forwarded-for', 'forwarded',
54
+ 'x-synabun-terminal-token',
49
55
  ]);
50
56
 
57
+ /**
58
+ * The upstream URL for a proxied request (`url`: what follows /w/<token>/api, query included), or null when it is not
59
+ * one of the browser routes an automation may call (lib/browser-automation-routes.js). The path is read as the
60
+ * upstream request will be: a URL parser folds `..`, `%2e%2e` and backslashes, so a path it would change is refused
61
+ * outright, never matched in one spelling and sent in another.
62
+ */
63
+ export function proxiedBrowserRoute(method, url, mainPort) {
64
+ const raw = String(url || '');
65
+ const rawPath = raw.split('?')[0];
66
+ let target;
67
+ try { target = new URL(`/api${raw}`, `http://127.0.0.1:${mainPort}`); } catch { return null; }
68
+ if (target.pathname !== `/api${rawPath}` || target.host !== `127.0.0.1:${mainPort}`) return null;
69
+ if (!target.pathname.startsWith(`${BROWSER_PREFIX}/`)) return null;
70
+ if (!isAutomationBrowserRoute(method, target.pathname.slice(BROWSER_PREFIX.length))) return null;
71
+ return target;
72
+ }
73
+
51
74
  /**
52
75
  * Build the channel. `createMcpRoutes` is the same factory server.js mounts at /mcp (mcp-server/dist/http.js).
76
+ * `terminalToken(runId)` is the run's terminal token (lib/terminal-tokens.js tokenFor), which the channel sends with
77
+ * the run's pin on its MCP path and its browser proxy: the path token already proves the run, and the browser routes
78
+ * take a run's pin only with its token. `terminalAuth` is handed to the channel's MCP routes (as server.js's /mcp).
53
79
  * @returns an object with start/stop/register/unregister/url/port.
54
80
  */
55
- export function createWorkerMcpChannel({ createMcpRoutes, mainPort = null, fetchImpl = globalThis.fetch, log = () => {} } = {}) {
81
+ export function createWorkerMcpChannel({ createMcpRoutes, mainPort = null, fetchImpl = globalThis.fetch, log = () => {}, terminalToken = () => null, terminalAuth = undefined } = {}) {
56
82
  if (typeof createMcpRoutes !== 'function') throw new Error('createWorkerMcpChannel needs createMcpRoutes');
83
+ /** The run's terminal token, or null (none issued; a lookup that failed). */
84
+ const tokenOf = (runId) => { try { const t = terminalToken(runId); return typeof t === 'string' && t ? t : null; } catch { return null; } };
57
85
  const tokenToRun = new Map(); // token → runId
58
86
  const runToToken = new Map(); // runId → token
59
87
  const selections = new Map(); // runId → immutable snapshot, never a request header
@@ -71,18 +99,21 @@ export function createWorkerMcpChannel({ createMcpRoutes, mainPort = null, fetch
71
99
  app.use('/w/:token/api', express.raw({ type: '*/*', limit: '32mb' }), async (req, res) => {
72
100
  const runId = tokenToRun.get(String(req.params.token || ''));
73
101
  if (!runId) return res.status(404).json({ error: 'Unknown worker channel' });
74
- const sub = req.url.split('?')[0]; // after /w/:token/api
75
- if (!PROXY_PREFIXES.some((p) => sub === p || sub.startsWith(p))) {
76
- return res.status(403).json({ error: 'The worker channel proxies the browser API only.' });
102
+ const route = proxiedBrowserRoute(req.method, req.url, mainPort || 1);
103
+ if (!route) {
104
+ return res.status(403).json({ error: 'The worker channel forwards the browser routes of SynaBun\'s browser tools only.', code: 'WORKER_CHANNEL_ROUTE' });
77
105
  }
78
106
  if (!mainPort || typeof fetchImpl !== 'function') return res.status(502).json({ error: 'Worker channel proxy unavailable.' });
79
- const target = `http://127.0.0.1:${mainPort}/api${req.url}`;
107
+ const target = route.href;
80
108
  const headers = { 'content-type': req.get('content-type') || 'application/json' };
81
109
  // The run's own routing travels; authority never does.
82
110
  for (const h of ['x-synabun-browser-session', 'x-synabun-browser-tab', 'x-synabun-project', 'x-synabun-memory-session', 'x-synabun-deadline', 'x-synabun-request-id', 'x-synabun-desktop-grant']) {
83
111
  const v = req.get(h); if (v) headers[h] = v;
84
112
  }
85
113
  headers['x-synabun-terminal'] = runId; // pinned: the worker's own run, never what it claims
114
+ // …with that run's terminal token, which the worker never sends (the path token is its proof here).
115
+ const runToken = tokenOf(runId);
116
+ if (runToken) headers['x-synabun-terminal-token'] = runToken;
86
117
  try {
87
118
  const body = (req.method === 'GET' || req.method === 'HEAD') ? undefined : (Buffer.isBuffer(req.body) && req.body.length ? req.body : undefined);
88
119
  const upstream = await fetchImpl(target, { method: req.method, headers, body });
@@ -99,6 +130,7 @@ export function createWorkerMcpChannel({ createMcpRoutes, mainPort = null, fetch
99
130
 
100
131
  const mcpRouter = createMcpRoutes({
101
132
  selectionFor: (req) => selections.get(req.headers['x-synabun-terminal']) || { groups: [], mode: 'strict' },
133
+ ...(typeof terminalAuth === 'function' ? { terminalAuth } : {}),
102
134
  });
103
135
  // Everything the channel serves is under /w/:token/mcp; the run is pinned from the token and authority is stripped.
104
136
  app.use('/w/:token/mcp', (req, res, next) => {
@@ -106,6 +138,9 @@ export function createWorkerMcpChannel({ createMcpRoutes, mainPort = null, fetch
106
138
  if (!runId) return res.status(404).json({ jsonrpc: '2.0', error: { code: -32001, message: 'Unknown worker channel' }, id: null });
107
139
  req.headers['x-synabun-terminal'] = runId; // the worker's identity is its own run, never what it claims
108
140
  for (const h of STRIPPED_HEADERS) delete req.headers[h];
141
+ // The run's own terminal token, so its tools' browser calls are the run's (the in-process MCP forwards it).
142
+ const runToken = tokenOf(runId);
143
+ if (runToken) req.headers['x-synabun-terminal-token'] = runToken;
109
144
  next();
110
145
  }, mcpRouter);
111
146
  // Nothing else exists on this listener.
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "neural-memory-interface",
3
- "version": "2.2.0",
3
+ "version": "2.2.2",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "neural-memory-interface",
9
- "version": "2.2.0",
9
+ "version": "2.2.2",
10
10
  "hasInstallScript": true,
11
11
  "license": "Apache-2.0",
12
12
  "dependencies": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "neural-memory-interface",
3
- "version": "2.2.0",
3
+ "version": "2.2.2",
4
4
  "private": true,
5
5
  "description": "Private local SynaBun interface for memory visualization and multi-agent workflows",
6
6
  "license": "Apache-2.0",
@@ -17,6 +17,7 @@ import { diffView, DIFF_LIMITS } from './agy-diff.js';
17
17
  import { durationLabel, toolSummary, usageParts, compactNumber } from './agy-events.js';
18
18
  import { relativeToProject } from './agy-commands.js';
19
19
  import { elicitationFields, elicitationUrl } from './agy-options.js';
20
+ import { synabunToolKey, synabunToolLabel, synabunToolSummary } from '../synabun-tools.js';
20
21
 
21
22
  const HTML_ESCAPES = { '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;', '`': '&#96;' };
22
23
  export const esc = (value) => String(value ?? '').replace(/[&<>"'`]/g, (c) => HTML_ESCAPES[c]);
@@ -46,6 +47,29 @@ export const ICONS = Object.freeze({
46
47
  cross: svg('<path d="M6 6l12 12M18 6 6 18"/>', { size: 12, width: 2.5 }),
47
48
  });
48
49
 
50
+ // SynaBun's own tools wear its logo, as in every other panel.
51
+ export const SYNABUN_LOGO = '<img class="agy-synabun-logo" src="logoHD.png" alt="" aria-hidden="true">';
52
+
53
+ /**
54
+ * A SynaBun MCP call of a tool row: { key, args } ('bluesky_post' and the call's own arguments), else null.
55
+ * Antigravity calls an MCP tool through call_mcp_tool { ServerName, ToolName, Arguments }; a name in
56
+ * the prefixed spelling (mcp__SynaBun__x, SynaBun_x) counts too.
57
+ */
58
+ export function synabunCallOf(row) {
59
+ const input = row?.rawInput && typeof row.rawInput === 'object' && !Array.isArray(row.rawInput) ? row.rawInput : {};
60
+ const server = typeof (input.ServerName ?? input.serverName ?? input.server) === 'string' ? (input.ServerName ?? input.serverName ?? input.server) : '';
61
+ const tool = typeof (input.ToolName ?? input.toolName ?? input.tool) === 'string' ? (input.ToolName ?? input.toolName ?? input.tool) : '';
62
+ if (server.trim() && tool.trim()) {
63
+ const key = synabunToolKey(tool, server);
64
+ if (key == null) return null;
65
+ let args = input.Arguments ?? input.arguments ?? {};
66
+ if (typeof args === 'string') { try { args = JSON.parse(args); } catch { args = {}; } }
67
+ return { key, args: args && typeof args === 'object' && !Array.isArray(args) ? args : {} };
68
+ }
69
+ const named = synabunToolKey(row?.name) ?? (/^mcp__/i.test(String(row?.title || '')) ? synabunToolKey(row.title) : null);
70
+ return named != null ? { key: named, args: input } : null;
71
+ }
72
+
49
73
  const KIND_ICON = { read: 'read', edit: 'edit', delete: 'delete', move: 'move', search: 'search', execute: 'execute', think: 'think', fetch: 'fetch', switch_mode: 'switch_mode' };
50
74
 
51
75
  const STATUS_TONE = { pending: 'running', in_progress: 'running', completed: 'success', failed: 'error' };
@@ -152,9 +176,25 @@ export function toolHtml(row, { T, cwd = '', detail = 'standard', opened, closed
152
176
  if (row.rawOutput !== null && row.rawOutput !== undefined) parts.push(`<div class="agy-raw"><div class="agy-raw-label">${esc(T('rawOutput'))}</div>${jsonBlock(row.rawOutput, T)}</div>`);
153
177
  }
154
178
  const body = parts.filter(Boolean).join('');
179
+ const duration = durationLabel(row.startedAt, row.endedAt);
180
+ const statusWordOf = () => (row.status === 'completed' ? T('toolDone') : row.status === 'failed' ? T('toolFailed') : row.status === 'in_progress' ? T('toolRunning') : T('toolPending'));
181
+ // A SynaBun tool: the logo, its friendly name ('Bluesky · Post') and what the call is about.
182
+ const sb = synabunCallOf(row);
183
+ if (sb) {
184
+ return cardHtml({
185
+ cls: `agy-tool agy-tool-synabun status-${esc(row.status)}`,
186
+ icon: SYNABUN_LOGO,
187
+ title: esc(synabunToolLabel(sb.key)),
188
+ titleAttr: `SynaBun · ${sb.key}`,
189
+ subtitle: esc([synabunToolSummary(sb.key, sb.args), duration].filter(Boolean).join(' · ')),
190
+ status: statusPill(statusWordOf(), STATUS_TONE[row.status] === 'success' ? '' : STATUS_TONE[row.status] || ''),
191
+ body,
192
+ open: toolOpen(row, { detail, opened, closed }),
193
+ attrs: ` data-tool="${esc(row.toolCallId)}"`,
194
+ });
195
+ }
155
196
  const summary = toolSummary(row);
156
197
  const shown = row.toolKind === 'execute' ? summary : relativeToProject(cwd, summary);
157
- const duration = durationLabel(row.startedAt, row.endedAt);
158
198
  const kindWord = T(`kind_${KIND_ICON[row.toolKind] ? row.toolKind : 'other'}`);
159
199
  const subtitle = esc([kindWord, row.name && row.name !== kindWord ? row.name : '', duration].filter(Boolean).join(' · '));
160
200
  const statusWord = row.status === 'completed' ? T('toolDone') : row.status === 'failed' ? T('toolFailed') : row.status === 'in_progress' ? T('toolRunning') : T('toolPending');
@@ -39,6 +39,7 @@ export function injectAntigravityStyles() {
39
39
  --agy-link: #9dc3ff;
40
40
  --agy-focus: rgba(255,255,255,0.7);
41
41
  --agy-brand: #669DF6;
42
+ --agy-synabun: #ffd700; /* the style guide accent: SynaBun tools */
42
43
  --agy-radius-sm: 4px;
43
44
  --agy-radius-md: 8px;
44
45
  --agy-radius-lg: 12px;
@@ -272,6 +273,10 @@ export function injectAntigravityStyles() {
272
273
  .agy-request { box-shadow: inset 2px 0 0 var(--agy-warning); }
273
274
  .agy-request .agy-card-title { white-space: normal; overflow-wrap: anywhere; }
274
275
  .agy-request.agy-request-done { box-shadow: none; opacity: 0.7; }
276
+ /* SynaBun tools: the logo and a thin accent at the edge, as in the Codex panel (not a filled box). */
277
+ .agy-tool-synabun { box-shadow: inset 2px 0 0 var(--agy-synabun); }
278
+ .agy-tool-synabun > .agy-card-head > .agy-card-titles > .agy-card-title { color: var(--agy-synabun); }
279
+ .agy-synabun-logo { width: 14px; height: 14px; object-fit: contain; display: block; }
275
280
  .agy-tool-image { max-width: 100%; max-height: 220px; border-radius: var(--agy-radius-sm); object-fit: contain; align-self: flex-start; }
276
281
 
277
282
  /* Buttons inside cards and the setup card: solid for the one primary action, hairline for the rest, red text for denial. */
@@ -775,6 +775,7 @@ export async function stopTunnel() {
775
775
 
776
776
  // ─── Last Session (resume after restart) ──
777
777
 
778
+ /** The sessions to offer for resume: `{ sessions: [] , reason }` when there are none (an older server answered 404). */
778
779
  export async function fetchLastSession() {
779
780
  const r = await fetch('/api/last-session');
780
781
  if (!r.ok) return null;
@@ -98,8 +98,20 @@ export function escalateAssistantRun(runId, target) {
98
98
 
99
99
  // ── Desktop (computer use) ───────────────────
100
100
 
101
- export function getDesktopStatus() {
102
- return jsonFetch('/api/desktop/status');
101
+ /** How long the status check may take before it counts as failed (the tray must never spin forever). */
102
+ export const DESKTOP_STATUS_TIMEOUT_MS = 10_000;
103
+
104
+ export async function getDesktopStatus({ timeoutMs = DESKTOP_STATUS_TIMEOUT_MS } = {}) {
105
+ const ctrl = typeof AbortController === 'function' ? new AbortController() : null;
106
+ const timer = ctrl ? setTimeout(() => ctrl.abort(), timeoutMs) : null;
107
+ try {
108
+ return await jsonFetch('/api/desktop/status', ctrl ? { signal: ctrl.signal } : {});
109
+ } catch (err) {
110
+ if (ctrl?.signal.aborted) throw Object.assign(new Error('The status check timed out'), { code: 'TIMEOUT', timedOut: true });
111
+ throw err;
112
+ } finally {
113
+ if (timer) clearTimeout(timer);
114
+ }
103
115
  }
104
116
 
105
117
  /** step: 'start'|'recheck'|'install_toolchain'|'request_screen'|'request_accessibility'|'open_settings' (+ { pane }). */