synabun 2.2.1 → 2.3.0
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 +53 -0
- package/README.md +1 -1
- package/docs/whatsapp.md +52 -20
- package/hooks/claude-code/pre-websearch.mjs +4 -1
- package/hooks/claude-code/prompt-submit.mjs +7 -0
- package/lib/mcp-build.js +519 -0
- package/lib/mcp-dist.js +10 -4
- package/lib/release-scan.mjs +23 -10
- package/lib/server-supervisor.js +7 -1
- package/lib/virustotal.mjs +146 -40
- package/mcp-server/dist/http.d.ts +57 -0
- package/mcp-server/dist/http.d.ts.map +1 -1
- package/mcp-server/dist/http.js +128 -18
- 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 +119 -0
- package/mcp-server/dist/services/browser-route-flow.d.ts.map +1 -0
- package/mcp-server/dist/services/browser-route-flow.js +340 -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/embedding-service.d.ts.map +1 -1
- package/mcp-server/dist/services/embedding-service.js +2 -1
- package/mcp-server/dist/services/embedding-service.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 +133 -1
- package/mcp-server/dist/services/neural-interface.d.ts.map +1 -1
- package/mcp-server/dist/services/neural-interface.js +630 -64
- package/mcp-server/dist/services/neural-interface.js.map +1 -1
- package/mcp-server/dist/services/tool-catalog.js +2 -2
- package/mcp-server/dist/services/tool-catalog.js.map +1 -1
- package/mcp-server/dist/tools/agents.d.ts +3 -2
- package/mcp-server/dist/tools/agents.d.ts.map +1 -1
- package/mcp-server/dist/tools/agents.js +6 -4
- package/mcp-server/dist/tools/agents.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 +13 -2
- package/mcp-server/dist/tools/browser-advanced.d.ts.map +1 -1
- package/mcp-server/dist/tools/browser-advanced.js +153 -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/browser-navigate.d.ts +3 -3
- package/mcp-server/dist/tools/browser-navigate.d.ts.map +1 -1
- package/mcp-server/dist/tools/browser-navigate.js +19 -16
- package/mcp-server/dist/tools/browser-navigate.js.map +1 -1
- package/mcp-server/dist/tools/browser-observe.d.ts +2 -1
- package/mcp-server/dist/tools/browser-observe.d.ts.map +1 -1
- package/mcp-server/dist/tools/browser-observe.js +61 -20
- package/mcp-server/dist/tools/browser-observe.js.map +1 -1
- package/mcp-server/dist/tools/morelogin.d.ts +13 -3
- package/mcp-server/dist/tools/morelogin.d.ts.map +1 -1
- package/mcp-server/dist/tools/morelogin.js +82 -19
- 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/dist/tools/youtube/upload.d.ts.map +1 -1
- package/mcp-server/dist/tools/youtube/upload.js +225 -88
- package/mcp-server/dist/tools/youtube/upload.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 +135 -17
- package/mcp-server/src/index.ts +15 -9
- package/mcp-server/src/services/browser-route-flow.ts +403 -0
- package/mcp-server/src/services/desktop-client.ts +2 -2
- package/mcp-server/src/services/embedding-service.ts +2 -1
- package/mcp-server/src/services/identity.ts +80 -4
- package/mcp-server/src/services/neural-interface.ts +648 -73
- package/mcp-server/src/services/tool-catalog.ts +2 -2
- package/mcp-server/src/tools/agents.ts +8 -4
- package/mcp-server/src/tools/bluesky.ts +164 -51
- package/mcp-server/src/tools/browser-advanced.ts +142 -17
- package/mcp-server/src/tools/browser-cheatsheet.ts +3 -0
- package/mcp-server/src/tools/browser-navigate.ts +19 -16
- package/mcp-server/src/tools/browser-observe.ts +62 -20
- package/mcp-server/src/tools/morelogin.ts +82 -19
- package/mcp-server/src/tools/youtube/helpers.ts +2 -2
- package/mcp-server/src/tools/youtube/upload.ts +218 -99
- package/neural-interface/i18n/en.json +655 -123
- package/neural-interface/i18n/pt-BR.json +542 -10
- package/neural-interface/lib/assistant-api.js +90 -23
- package/neural-interface/lib/assistant-brains/claude.js +5 -0
- package/neural-interface/lib/assistant-catalog.js +134 -3
- package/neural-interface/lib/assistant-dispatch.js +97 -1
- package/neural-interface/lib/assistant-persona.js +15 -7
- package/neural-interface/lib/assistant-router.js +6 -4
- package/neural-interface/lib/assistant-runtime.js +18 -1
- package/neural-interface/lib/assistant-task-prompt.js +5 -0
- package/neural-interface/lib/assistant-tools.js +10 -1
- package/neural-interface/lib/automation-approval.js +249 -0
- package/neural-interface/lib/automation-browser-owner-access.js +82 -0
- package/neural-interface/lib/backup-service.js +16 -1
- package/neural-interface/lib/browser-automation-routes.js +84 -0
- package/neural-interface/lib/browser-background-tab.js +72 -3
- package/neural-interface/lib/browser-execution.js +16 -3
- package/neural-interface/lib/browser-extraction.js +106 -45
- package/neural-interface/lib/browser-owner.js +48 -0
- package/neural-interface/lib/browser-profile-choices.js +143 -0
- package/neural-interface/lib/browser-profiles.js +142 -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-tab-recovery.js +153 -0
- package/neural-interface/lib/browser-tool-policy.js +23 -4
- package/neural-interface/lib/browser-wedge-retire.js +64 -0
- package/neural-interface/lib/chromium-on-device-model.js +67 -0
- package/neural-interface/lib/claude-agent-bridge.js +43 -5
- package/neural-interface/lib/claude-background-hold.js +239 -0
- package/neural-interface/lib/claude-model-catalog.js +12 -0
- package/neural-interface/lib/effort-levels.js +28 -2
- package/neural-interface/lib/exec-loop-command.js +8 -0
- package/neural-interface/lib/http-guards.js +11 -6
- package/neural-interface/lib/local-profile-proxy.js +362 -0
- package/neural-interface/lib/local-profiles.js +929 -0
- package/neural-interface/lib/loop-logger.js +31 -5
- package/neural-interface/lib/maritaca/api.js +179 -0
- package/neural-interface/lib/maritaca/attachments.js +44 -0
- package/neural-interface/lib/maritaca/client.js +362 -0
- package/neural-interface/lib/maritaca/key-store.js +122 -0
- package/neural-interface/lib/maritaca/models.js +181 -0
- package/neural-interface/lib/maritaca/modes.js +39 -0
- package/neural-interface/lib/maritaca/opencode-proxy.js +236 -0
- package/neural-interface/lib/maritaca/opencode-stream.js +345 -0
- package/neural-interface/lib/maritaca/opencode.js +218 -0
- package/neural-interface/lib/maritaca/panel-bridge.js +273 -0
- package/neural-interface/lib/maritaca/sessions.js +198 -0
- package/neural-interface/lib/mcp-external-servers.js +37 -10
- package/neural-interface/lib/morelogin-agent-profiles.js +149 -0
- package/neural-interface/lib/morelogin.js +278 -14
- package/neural-interface/lib/native-loop-providers.js +124 -11
- package/neural-interface/lib/native-loop-runtime.js +112 -11
- package/neural-interface/lib/owner-authority.js +137 -43
- package/neural-interface/lib/page-session.js +111 -27
- package/neural-interface/lib/peer-identity.js +263 -43
- package/neural-interface/lib/provider-panel-api-key-auth.js +7 -2
- package/neural-interface/lib/pty-host/core.js +36 -0
- package/neural-interface/lib/pty-host/protocol.js +2 -0
- package/neural-interface/lib/request-gate.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/system-activity.js +1 -1
- package/neural-interface/lib/terminal-token-redaction.js +293 -0
- package/neural-interface/lib/terminal-tokens.js +436 -0
- package/neural-interface/lib/worker-mcp-channel.js +45 -10
- package/neural-interface/package-lock.json +3 -2
- package/neural-interface/package.json +2 -1
- package/neural-interface/public/assets/mascot/README.md +11 -0
- package/neural-interface/public/assets/mascot/ask.gif +0 -0
- package/neural-interface/public/assets/mascot/ask.png +0 -0
- package/neural-interface/public/assets/mascot/blocked.gif +0 -0
- package/neural-interface/public/assets/mascot/blocked.png +0 -0
- package/neural-interface/public/assets/mascot/budget.gif +0 -0
- package/neural-interface/public/assets/mascot/budget.png +0 -0
- package/neural-interface/public/assets/mascot/computer.gif +0 -0
- package/neural-interface/public/assets/mascot/computer.png +0 -0
- package/neural-interface/public/assets/mascot/edit.gif +0 -0
- package/neural-interface/public/assets/mascot/edit.png +0 -0
- package/neural-interface/public/assets/mascot/error.gif +0 -0
- package/neural-interface/public/assets/mascot/error.png +0 -0
- package/neural-interface/public/assets/mascot/hover-attention.gif +0 -0
- package/neural-interface/public/assets/mascot/hover-attention.png +0 -0
- package/neural-interface/public/assets/mascot/idle-hero.gif +0 -0
- package/neural-interface/public/assets/mascot/idle-hero.png +0 -0
- package/neural-interface/public/assets/mascot/idle.gif +0 -0
- package/neural-interface/public/assets/mascot/idle.png +0 -0
- package/neural-interface/public/assets/mascot/manifest.json +254 -0
- package/neural-interface/public/assets/mascot/mcp.gif +0 -0
- package/neural-interface/public/assets/mascot/mcp.png +0 -0
- package/neural-interface/public/assets/mascot/memory.gif +0 -0
- package/neural-interface/public/assets/mascot/memory.png +0 -0
- package/neural-interface/public/assets/mascot/offline.gif +0 -0
- package/neural-interface/public/assets/mascot/offline.png +0 -0
- package/neural-interface/public/assets/mascot/pick.gif +0 -0
- package/neural-interface/public/assets/mascot/pick.png +0 -0
- package/neural-interface/public/assets/mascot/plan.gif +0 -0
- package/neural-interface/public/assets/mascot/plan.png +0 -0
- package/neural-interface/public/assets/mascot/present.gif +0 -0
- package/neural-interface/public/assets/mascot/present.png +0 -0
- package/neural-interface/public/assets/mascot/project.gif +0 -0
- package/neural-interface/public/assets/mascot/project.png +0 -0
- package/neural-interface/public/assets/mascot/read.gif +0 -0
- package/neural-interface/public/assets/mascot/read.png +0 -0
- package/neural-interface/public/assets/mascot/runs.gif +0 -0
- package/neural-interface/public/assets/mascot/runs.png +0 -0
- package/neural-interface/public/assets/mascot/scenes/automation.gif +0 -0
- package/neural-interface/public/assets/mascot/scenes/automation.png +0 -0
- package/neural-interface/public/assets/mascot/scenes/browser.gif +0 -0
- package/neural-interface/public/assets/mascot/scenes/browser.png +0 -0
- package/neural-interface/public/assets/mascot/scenes/code.gif +0 -0
- package/neural-interface/public/assets/mascot/scenes/code.png +0 -0
- package/neural-interface/public/assets/mascot/scenes/complex.gif +0 -0
- package/neural-interface/public/assets/mascot/scenes/complex.png +0 -0
- package/neural-interface/public/assets/mascot/scenes/computer.gif +0 -0
- package/neural-interface/public/assets/mascot/scenes/computer.png +0 -0
- package/neural-interface/public/assets/mascot/scenes/design.gif +0 -0
- package/neural-interface/public/assets/mascot/scenes/design.png +0 -0
- package/neural-interface/public/assets/mascot/scenes/edit.gif +0 -0
- package/neural-interface/public/assets/mascot/scenes/edit.png +0 -0
- package/neural-interface/public/assets/mascot/scenes/generic.gif +0 -0
- package/neural-interface/public/assets/mascot/scenes/generic.png +0 -0
- package/neural-interface/public/assets/mascot/scenes/image_gen.gif +0 -0
- package/neural-interface/public/assets/mascot/scenes/image_gen.png +0 -0
- package/neural-interface/public/assets/mascot/scenes/manifest.json +173 -0
- package/neural-interface/public/assets/mascot/scenes/memory.gif +0 -0
- package/neural-interface/public/assets/mascot/scenes/memory.png +0 -0
- package/neural-interface/public/assets/mascot/scenes/quick.gif +0 -0
- package/neural-interface/public/assets/mascot/scenes/quick.png +0 -0
- package/neural-interface/public/assets/mascot/scenes/read.gif +0 -0
- package/neural-interface/public/assets/mascot/scenes/read.png +0 -0
- package/neural-interface/public/assets/mascot/scenes/research.gif +0 -0
- package/neural-interface/public/assets/mascot/scenes/research.png +0 -0
- package/neural-interface/public/assets/mascot/scenes/review.gif +0 -0
- package/neural-interface/public/assets/mascot/scenes/review.png +0 -0
- package/neural-interface/public/assets/mascot/scenes/search.gif +0 -0
- package/neural-interface/public/assets/mascot/scenes/search.png +0 -0
- package/neural-interface/public/assets/mascot/scenes/shell.gif +0 -0
- package/neural-interface/public/assets/mascot/scenes/shell.png +0 -0
- package/neural-interface/public/assets/mascot/scenes/thinking.gif +0 -0
- package/neural-interface/public/assets/mascot/scenes/thinking.png +0 -0
- package/neural-interface/public/assets/mascot/scenes/video_gen.gif +0 -0
- package/neural-interface/public/assets/mascot/scenes/video_gen.png +0 -0
- package/neural-interface/public/assets/mascot/scenes/web.gif +0 -0
- package/neural-interface/public/assets/mascot/scenes/web.png +0 -0
- package/neural-interface/public/assets/mascot/search.gif +0 -0
- package/neural-interface/public/assets/mascot/search.png +0 -0
- package/neural-interface/public/assets/mascot/shell.gif +0 -0
- package/neural-interface/public/assets/mascot/shell.png +0 -0
- package/neural-interface/public/assets/mascot/skill.gif +0 -0
- package/neural-interface/public/assets/mascot/skill.png +0 -0
- package/neural-interface/public/assets/mascot/sleep.gif +0 -0
- package/neural-interface/public/assets/mascot/sleep.png +0 -0
- package/neural-interface/public/assets/mascot/subagent.gif +0 -0
- package/neural-interface/public/assets/mascot/subagent.png +0 -0
- package/neural-interface/public/assets/mascot/success.gif +0 -0
- package/neural-interface/public/assets/mascot/success.png +0 -0
- package/neural-interface/public/assets/mascot/think.gif +0 -0
- package/neural-interface/public/assets/mascot/think.png +0 -0
- package/neural-interface/public/assets/mascot/wait.gif +0 -0
- package/neural-interface/public/assets/mascot/wait.png +0 -0
- package/neural-interface/public/assets/mascot/watch.gif +0 -0
- package/neural-interface/public/assets/mascot/watch.png +0 -0
- package/neural-interface/public/assets/mascot/web.gif +0 -0
- package/neural-interface/public/assets/mascot/web.png +0 -0
- package/neural-interface/public/onboarding.html +14 -1
- package/neural-interface/public/shared/agent-runtime-options.js +49 -8
- package/neural-interface/public/shared/agy/agy-panel.js +2 -2
- 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 +5 -4
- package/neural-interface/public/shared/assistant/asst-ask-styles.js +8 -8
- package/neural-interface/public/shared/assistant/asst-ask.js +1 -1
- package/neural-interface/public/shared/assistant/asst-brain-picker.js +99 -9
- package/neural-interface/public/shared/assistant/asst-computer.js +47 -2
- package/neural-interface/public/shared/assistant/asst-control.js +1 -1
- package/neural-interface/public/shared/assistant/asst-limit-wait.js +7 -5
- package/neural-interface/public/shared/assistant/asst-panel.js +13 -5
- package/neural-interface/public/shared/assistant/asst-rack-styles.js +4 -4
- package/neural-interface/public/shared/assistant/asst-render.js +16 -10
- package/neural-interface/public/shared/assistant/asst-route-models.js +64 -4
- package/neural-interface/public/shared/assistant/asst-route.js +24 -7
- package/neural-interface/public/shared/assistant/asst-routes-editor.js +154 -39
- package/neural-interface/public/shared/assistant/asst-run-stage.js +3 -3
- package/neural-interface/public/shared/assistant/asst-scene-styles.js +8 -111
- package/neural-interface/public/shared/assistant/asst-scenes.js +46 -318
- package/neural-interface/public/shared/assistant/asst-sidepanel.js +2 -2
- package/neural-interface/public/shared/assistant/asst-state.js +72 -2
- package/neural-interface/public/shared/assistant/asst-styles.js +60 -15
- package/neural-interface/public/shared/automation-approval-view.js +75 -0
- package/neural-interface/public/shared/cdx/cdx-panel.js +2 -2
- 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/context-menu-model.js +2 -0
- package/neural-interface/public/shared/cp/cp-agents.js +8 -0
- package/neural-interface/public/shared/cp/cp-permissions.js +6 -2
- package/neural-interface/public/shared/cp/cp-rehydrate.js +25 -1
- package/neural-interface/public/shared/cp/cp-tasks-model.js +33 -0
- package/neural-interface/public/shared/editor/editor-panel-logic.js +10 -0
- package/neural-interface/public/shared/editor/editor-panel.js +10 -2
- package/neural-interface/public/shared/html-shell.js +30 -22
- package/neural-interface/public/shared/judgments-log-origins.js +29 -0
- package/neural-interface/public/shared/morelogin-profile-choices.js +107 -0
- package/neural-interface/public/shared/morelogin-profile-field.js +186 -0
- package/neural-interface/public/shared/mtc/mtc-client.js +181 -0
- package/neural-interface/public/shared/mtc/mtc-compose.js +40 -0
- package/neural-interface/public/shared/mtc/mtc-copy.js +253 -0
- package/neural-interface/public/shared/mtc/mtc-logic.js +478 -0
- package/neural-interface/public/shared/mtc/mtc-panel.js +1354 -0
- package/neural-interface/public/shared/mtc/mtc-render.js +172 -0
- package/neural-interface/public/shared/mtc/mtc-styles.js +437 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-automation-ownership.js +23 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-events.js +13 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-icons.js +3 -1
- package/neural-interface/public/shared/ocp-v2/ocp-v2-panel.js +10 -4
- package/neural-interface/public/shared/ocp-v2/ocp-v2-render.js +6 -86
- package/neural-interface/public/shared/ocp-v2/ocp-v2-ws.js +5 -2
- package/neural-interface/public/shared/owner-access.js +134 -0
- package/neural-interface/public/shared/owner-authority-view.js +92 -0
- package/neural-interface/public/shared/page-session.js +143 -14
- package/neural-interface/public/shared/poll-backoff.js +59 -0
- package/neural-interface/public/shared/provider-icons.js +3 -0
- package/neural-interface/public/shared/schedules-view.js +7 -0
- package/neural-interface/public/shared/server-back.js +50 -0
- package/neural-interface/public/shared/settings/settings-browser-owner-access.js +72 -0
- package/neural-interface/public/shared/settings/settings-data.js +7 -1
- package/neural-interface/public/shared/settings/settings-ia.js +3 -1
- package/neural-interface/public/shared/settings/settings-kit.js +11 -3
- package/neural-interface/public/shared/settings/settings-local-profiles.js +153 -0
- package/neural-interface/public/shared/settings/settings-maritaca-opencode.js +105 -0
- 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/sidepanel-session-status.js +16 -2
- package/neural-interface/public/shared/state.js +1 -1
- package/neural-interface/public/shared/static-bg-state.js +22 -0
- package/neural-interface/public/shared/styles.css +457 -164
- package/neural-interface/public/shared/synabun-mascot-assets.js +67 -0
- package/neural-interface/public/shared/synabun-mascot.js +136 -12
- package/neural-interface/public/shared/synabun-ticker.js +3 -0
- 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/topright-overflow-logic.js +1 -0
- package/neural-interface/public/shared/ui-automation-approval.js +188 -0
- package/neural-interface/public/shared/ui-automation-studio.js +138 -91
- package/neural-interface/public/shared/ui-claude-panel.js +209 -31
- package/neural-interface/public/shared/ui-judgments.js +37 -10
- package/neural-interface/public/shared/ui-maritaca-panel.js +15 -0
- package/neural-interface/public/shared/ui-navbar.js +23 -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-panels.js +3 -1
- package/neural-interface/public/shared/ui-schedules-studio.js +118 -17
- package/neural-interface/public/shared/ui-scroll-follow.js +3 -0
- package/neural-interface/public/shared/ui-sessions.js +45 -16
- package/neural-interface/public/shared/ui-settings.js +676 -42
- package/neural-interface/public/shared/ui-sidepanel-session-entry.js +8 -2
- package/neural-interface/public/shared/ui-sidepanel-sessions.js +3 -3
- package/neural-interface/public/shared/ui-sidepanel-tray.js +24 -0
- package/neural-interface/public/shared/ui-sidepanel-windows.js +1 -1
- 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/scripts/build-mascot-assets.mjs +30 -0
- package/neural-interface/server.js +2903 -359
- package/npm-shrinkwrap.json +5 -17
- package/package.json +5 -6
- package/postinstall.js +38 -39
- package/setup.js +33 -31
- package/skills/synabun/modules/changelog.md +14 -0
|
@@ -0,0 +1,436 @@
|
|
|
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
|
+
* How many closed MCP sessions stay refused, in a list of their own (oldest first out). Anybody on this computer can
|
|
86
|
+
* open and close MCP sessions, so they never share the ended runs' list: before 2026-11-10 (review b6631e9d, finding
|
|
87
|
+
* 7) 10,000 open-and-close cycles pushed every ended run out of it, and an ended run's id was sayable again.
|
|
88
|
+
*/
|
|
89
|
+
export const REVOKED_SESSIONS_KEPT_MAX = 10_000;
|
|
90
|
+
|
|
91
|
+
/** The shape of the ids the MCP transport mints for its sessions (a random UUID): a bearer for that session. */
|
|
92
|
+
export const MCP_SESSION_ID_SHAPE_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
93
|
+
/**
|
|
94
|
+
* `id` as a log line or a refusal may show it (finding 4 of the re-review of 2026-11-11): an id shaped like an MCP
|
|
95
|
+
* session's (MCP_SESSION_ID_SHAPE_RE) or `isMcpSession` says is one, cut to its first 8 characters and "…" (as
|
|
96
|
+
* mcp-server/src/http.ts sessionLogId); anything else (a run's id, which is nothing without its token) up to 128
|
|
97
|
+
* characters, so a log still finds the run.
|
|
98
|
+
*/
|
|
99
|
+
export function logIdOf(id, isMcpSession = false) {
|
|
100
|
+
const text = String(id ?? '');
|
|
101
|
+
return isMcpSession === true || MCP_SESSION_ID_SHAPE_RE.test(text) ? `${text.slice(0, 8)}…` : text.slice(0, 128);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** A new token. */
|
|
105
|
+
export function mintTerminalToken(random = cryptoRandomBytes) {
|
|
106
|
+
return `sbt_${random(32).toString('base64url')}`;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** `value` as a token, or null (absent, not a string, not shaped like one SynaBun mints). */
|
|
110
|
+
export function sanitizeTerminalToken(value) {
|
|
111
|
+
const text = typeof value === 'string' ? value.trim() : '';
|
|
112
|
+
return TERMINAL_TOKEN_RE.test(text) ? text : null;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/** `value` as a proof of an id: a terminal token, or a brain's launch credential (bind()), else null. */
|
|
116
|
+
export function sanitizeTerminalProof(value) {
|
|
117
|
+
const text = typeof value === 'string' ? value.trim() : '';
|
|
118
|
+
return TERMINAL_TOKEN_RE.test(text) || BRAIN_CREDENTIAL_SHAPE_RE.test(text) ? text : null;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/** 'grace' when the environment says so, else 'strict'. Read at every check. */
|
|
122
|
+
export function terminalTokenMode(env = process.env) {
|
|
123
|
+
return String(env?.[TERMINAL_TOKEN_MODE_ENV] || '').trim().toLowerCase() === 'grace' ? 'grace' : 'strict';
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* How long grace lasts after the server started (SYNABUN_TERMINAL_TOKEN_GRACE_MINUTES), in milliseconds: a positive
|
|
128
|
+
* number of minutes, Infinity for `never`, else (unset, 0, anything unreadable) the 24-hour default.
|
|
129
|
+
*/
|
|
130
|
+
export function terminalTokenGraceWindowMs(env = process.env) {
|
|
131
|
+
const raw = String(env?.[TERMINAL_TOKEN_GRACE_MINUTES_ENV] ?? '').trim().toLowerCase();
|
|
132
|
+
if (raw === 'never') return Infinity;
|
|
133
|
+
const minutes = Number(raw);
|
|
134
|
+
return raw && Number.isFinite(minutes) && minutes > 0 ? minutes * 60_000 : GRACE_DEFAULT_MINUTES * 60_000;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const digestOf = (text) => createHash('sha256').update(String(text)).digest();
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* The refusal of a request that names a run it cannot prove it is: 403 and a code, never the token.
|
|
141
|
+
* @param {'missing'|'invalid'|'revoked'} status
|
|
142
|
+
* @param {string} id the run the request named
|
|
143
|
+
*/
|
|
144
|
+
export function terminalRefusal(status, id) {
|
|
145
|
+
// Finding 4 (re-review of 2026-11-11): the id a request names may be a live Mcp-Session-Id, a bearer for that MCP
|
|
146
|
+
// session. A refusal goes back to the caller that sent it, but it can be copied into a log on its way (a route's
|
|
147
|
+
// catch, a proxy), so an id of that shape is said by its short form here too (logIdOf).
|
|
148
|
+
const run = logIdOf(id);
|
|
149
|
+
if (status === 'missing') {
|
|
150
|
+
return {
|
|
151
|
+
status: 403, code: 'TERMINAL_TOKEN_REQUIRED',
|
|
152
|
+
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.`,
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
if (status === 'revoked') {
|
|
156
|
+
return {
|
|
157
|
+
status: 403, code: 'TERMINAL_TOKEN_INVALID',
|
|
158
|
+
error: `Run ${run} has ended: its terminal token was revoked, and nothing may act as that run any more.`,
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
return {
|
|
162
|
+
status: 403, code: 'TERMINAL_TOKEN_INVALID',
|
|
163
|
+
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.`,
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* @param {{ random?: (n: number) => Buffer, equal?: (a: Buffer, b: Buffer) => boolean, mode?: () => 'strict'|'grace',
|
|
169
|
+
* maxRevoked?: number, log?: (line: string) => void, graceWindowMs?: () => number, now?: () => number,
|
|
170
|
+
* logEveryMs?: number }} [options]
|
|
171
|
+
* `equal` is the constant-time comparison (crypto.timingSafeEqual); tests hand in a counting one. `mode` is what the
|
|
172
|
+
* environment says (read at every check); `graceWindowMs` how long grace may last after the registry was made (the
|
|
173
|
+
* server's start), read at every check too; `now` the clock. `knownSecrets` is told every live proof and every one
|
|
174
|
+
* that stops proving anything (lib/terminal-token-redaction.js: the scrubbers then mask its base64 and hex too).
|
|
175
|
+
* `maxRevokedSessions`: how many closed MCP sessions stay refused, apart from the ended runs. `onEnded(id, kind)` is
|
|
176
|
+
* told every id whose owner ended (revoke() of a run, revokeSession() of an MCP session; never rotate() or retire(),
|
|
177
|
+
* which are a new process or a pause of the same owner): the server forgets what that id held (its MoreLogin
|
|
178
|
+
* profile pin and its saved choice, server.js forgetRunMoreLoginProfile), so nothing outlives its owner.
|
|
179
|
+
*/
|
|
180
|
+
export function createTerminalTokenRegistry({
|
|
181
|
+
random = cryptoRandomBytes,
|
|
182
|
+
equal = timingSafeEqual,
|
|
183
|
+
mode = () => terminalTokenMode(),
|
|
184
|
+
maxRevoked = REVOKED_KEPT_MAX,
|
|
185
|
+
log = () => {},
|
|
186
|
+
graceWindowMs = () => terminalTokenGraceWindowMs(),
|
|
187
|
+
now = Date.now,
|
|
188
|
+
logEveryMs = GRACE_LOG_EVERY_MS,
|
|
189
|
+
knownSecrets = { add: registerKnownSecret, remove: forgetKnownSecret },
|
|
190
|
+
maxRevokedSessions = REVOKED_SESSIONS_KEPT_MAX,
|
|
191
|
+
onEnded = null,
|
|
192
|
+
} = {}) {
|
|
193
|
+
const live = new Map(); // terminal id → { token, digest, kind: 'token' | 'credential' | 'mcp-session' }
|
|
194
|
+
const revoked = new Set(); // ids of ended runs, oldest first
|
|
195
|
+
const revokedSessions = new Set(); // ids of closed MCP sessions, oldest first: never in `revoked` (finding 7)
|
|
196
|
+
const sessionCap = Math.max(1, Number(maxRevokedSessions) || REVOKED_SESSIONS_KEPT_MAX);
|
|
197
|
+
/** Tell the host an id's owner ended (never a reason to fail a revoke). */
|
|
198
|
+
const ended = (id, kind) => { if (typeof onEnded === 'function') { try { onEnded(id, kind); } catch { /* the host's own failure */ } } };
|
|
199
|
+
const graceLog = new Map(); // id → { at, more }: when a grace acceptance was last logged, and how many since
|
|
200
|
+
const cap = Math.max(1, Number(maxRevoked) || REVOKED_KEPT_MAX);
|
|
201
|
+
const startedAt = now();
|
|
202
|
+
let graceExpiryLogged = false;
|
|
203
|
+
const idOf = (value) => (typeof value === 'string' && BROWSER_OWNER_ID_RE.test(value) ? value : null);
|
|
204
|
+
const say = (line) => { try { log(line); } catch { /* a logger's own failure */ } };
|
|
205
|
+
|
|
206
|
+
/** When grace ends (ms since the epoch), or Infinity. */
|
|
207
|
+
function graceEndsAt() {
|
|
208
|
+
let windowMs;
|
|
209
|
+
try { windowMs = Number(graceWindowMs()); } catch { windowMs = GRACE_DEFAULT_MINUTES * 60_000; }
|
|
210
|
+
if (!(windowMs > 0)) windowMs = GRACE_DEFAULT_MINUTES * 60_000;
|
|
211
|
+
return startedAt + windowMs;
|
|
212
|
+
}
|
|
213
|
+
/** What the environment asks for ('grace' | 'strict'). */
|
|
214
|
+
function configuredMode() {
|
|
215
|
+
try { return mode() === 'grace' ? 'grace' : 'strict'; } catch { return 'strict'; }
|
|
216
|
+
}
|
|
217
|
+
/** The mode in force: grace only while the environment asks for it and its window is open. */
|
|
218
|
+
function currentMode() {
|
|
219
|
+
if (configuredMode() !== 'grace') return 'strict';
|
|
220
|
+
if (now() < graceEndsAt()) return 'grace';
|
|
221
|
+
if (!graceExpiryLogged) {
|
|
222
|
+
graceExpiryLogged = true;
|
|
223
|
+
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`);
|
|
224
|
+
}
|
|
225
|
+
return 'strict';
|
|
226
|
+
}
|
|
227
|
+
/** One line per run a minute at most for grace acceptances, with how many more there were since the last one. */
|
|
228
|
+
function noteGrace(terminalId) {
|
|
229
|
+
const id = String(terminalId).slice(0, 128);
|
|
230
|
+
const at = now();
|
|
231
|
+
const seen = graceLog.get(id);
|
|
232
|
+
if (seen && at - seen.at < logEveryMs) { seen.more += 1; return; }
|
|
233
|
+
const more = seen?.more || 0;
|
|
234
|
+
graceLog.delete(id);
|
|
235
|
+
graceLog.set(id, { at, more: 0 });
|
|
236
|
+
while (graceLog.size > cap) graceLog.delete(graceLog.keys().next().value);
|
|
237
|
+
const ends = graceEndsAt();
|
|
238
|
+
say(`[terminal-tokens] grace: run ${logIdOf(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()}` : ''}`);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/** The scrubbers learn a live proof's value and forget a dead one's (never a reason to fail a check). */
|
|
242
|
+
const known = (op, token) => { try { knownSecrets?.[op]?.(token); } catch { /* scrubbing by shape still holds */ } };
|
|
243
|
+
/** Drop `id`'s live proof, and tell the scrubbers (a credential bound to several ids stays known while one holds it). */
|
|
244
|
+
function dropLive(id) {
|
|
245
|
+
const held = live.get(id);
|
|
246
|
+
if (!held) return false;
|
|
247
|
+
live.delete(id);
|
|
248
|
+
if (![...live.values()].some((other) => other.token === held.token)) known('remove', held.token);
|
|
249
|
+
return true;
|
|
250
|
+
}
|
|
251
|
+
function setLive(id, token, kind) {
|
|
252
|
+
revoked.delete(id);
|
|
253
|
+
revokedSessions.delete(id);
|
|
254
|
+
graceLog.delete(id);
|
|
255
|
+
if (live.has(id)) dropLive(id);
|
|
256
|
+
live.set(id, { token, digest: digestOf(token), kind });
|
|
257
|
+
known('add', token);
|
|
258
|
+
return token;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/** The live token of `terminalId`, minted now when it has none (also after a revoke: a run started again). */
|
|
262
|
+
function issue(terminalId) {
|
|
263
|
+
const id = idOf(terminalId);
|
|
264
|
+
if (!id) return null;
|
|
265
|
+
const held = live.get(id);
|
|
266
|
+
if (held) return held.token;
|
|
267
|
+
return setLive(id, mintTerminalToken(random), 'token');
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* A new token for `terminalId` (a run's new process: a resume, a side panel's new CLI or serve): the one it held
|
|
272
|
+
* stops proving anything, and the id is not an ended run's. Returns the new token, or null for an id SynaBun does
|
|
273
|
+
* not mint.
|
|
274
|
+
*/
|
|
275
|
+
function rotate(terminalId) {
|
|
276
|
+
const id = idOf(terminalId);
|
|
277
|
+
if (!id) return null;
|
|
278
|
+
dropLive(id);
|
|
279
|
+
return setLive(id, mintTerminalToken(random), 'token');
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* Make an existing credential the proof of `terminalId`: an Assistant brain's launch credential (`sbb_…`) for the
|
|
284
|
+
* pin its SynaBun MCP names, so the brain proves its id with the one secret it already has. Replaces what the id
|
|
285
|
+
* held. Returns whether it was bound (false for an id or a credential of another shape).
|
|
286
|
+
*/
|
|
287
|
+
function bind(terminalId, credential) {
|
|
288
|
+
const id = idOf(terminalId);
|
|
289
|
+
const proof = sanitizeTerminalProof(credential);
|
|
290
|
+
if (!id || !proof) return false;
|
|
291
|
+
setLive(id, proof, BRAIN_CREDENTIAL_SHAPE_RE.test(proof) ? 'credential' : 'token');
|
|
292
|
+
return true;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* A proof for a plain MCP session of SynaBun's own HTTP MCP endpoint (a CLI window's Claude Code or Codex that SynaBun
|
|
297
|
+
* did not start: its id is the Mcp-Session-Id the endpoint minted at its initialize). Kind 'mcp-session': it makes
|
|
298
|
+
* the session's id verified (nobody else can name it any more, and the browser and MoreLogin routes know it is
|
|
299
|
+
* that session), but it is not a run: moreLoginGate lets it work in a profile of its own (`use`) and never `start`
|
|
300
|
+
* or `use-default` (kindOf). Never replaces a proof an id already holds (a run's token, a brain's credential), and
|
|
301
|
+
* never reopens an ended id. Returns the token, or null.
|
|
302
|
+
*/
|
|
303
|
+
function issueSession(sessionId) {
|
|
304
|
+
const id = idOf(sessionId);
|
|
305
|
+
if (!id || live.has(id) || revoked.has(id) || revokedSessions.has(id)) return null;
|
|
306
|
+
return setLive(id, mintTerminalToken(random), 'mcp-session');
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
/**
|
|
310
|
+
* The MCP session ended: its proof stops working and its id stays refused. Only a proof issueSession gave. The id
|
|
311
|
+
* goes to the closed sessions' own list (revokedSessions), never to the ended runs' (finding 7: see
|
|
312
|
+
* REVOKED_SESSIONS_KEPT_MAX), so no number of sessions opened and closed can make an ended run's id sayable again.
|
|
313
|
+
*/
|
|
314
|
+
function revokeSession(sessionId) {
|
|
315
|
+
const id = idOf(sessionId);
|
|
316
|
+
if (!id || live.get(id)?.kind !== 'mcp-session') return false;
|
|
317
|
+
dropLive(id);
|
|
318
|
+
graceLog.delete(id);
|
|
319
|
+
revokedSessions.delete(id);
|
|
320
|
+
revokedSessions.add(id);
|
|
321
|
+
while (revokedSessions.size > sessionCap) revokedSessions.delete(revokedSessions.values().next().value);
|
|
322
|
+
ended(id, 'mcp-session');
|
|
323
|
+
return true;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
/** What proves `terminalId`: 'token' (a run, a panel), 'credential' (a brain), 'mcp-session', or null. */
|
|
327
|
+
function kindOf(terminalId) {
|
|
328
|
+
return (typeof terminalId === 'string' && live.get(terminalId)?.kind) || null;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
/** The live token of `terminalId`, or null (none issued, or revoked). For a handoff to a process the run starts. */
|
|
332
|
+
function tokenFor(terminalId) {
|
|
333
|
+
const id = idOf(terminalId);
|
|
334
|
+
return id ? live.get(id)?.token || null : null;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
/** The run ended: its token stops working, and its id stays refused. Returns whether it held one. */
|
|
338
|
+
function revoke(terminalId) {
|
|
339
|
+
const id = idOf(terminalId);
|
|
340
|
+
if (!id) return false;
|
|
341
|
+
// An MCP session's proof ends in its own list, whoever asks (revokeSession).
|
|
342
|
+
if (live.get(id)?.kind === 'mcp-session') return revokeSession(id);
|
|
343
|
+
const had = dropLive(id);
|
|
344
|
+
graceLog.delete(id);
|
|
345
|
+
if (had || revoked.has(id)) {
|
|
346
|
+
revoked.delete(id);
|
|
347
|
+
revoked.add(id);
|
|
348
|
+
while (revoked.size > cap) revoked.delete(revoked.values().next().value);
|
|
349
|
+
}
|
|
350
|
+
ended(id, 'run');
|
|
351
|
+
return had;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
/**
|
|
355
|
+
* Refuse `terminalId` from now on although it holds no token here: a run this server knows to have no live process
|
|
356
|
+
* (a dispatched worker a restart suspended, waiting for its resume, which issues a fresh token). Without this such an
|
|
357
|
+
* id would be unregistered, taken as said. Returns whether the id was one SynaBun mints.
|
|
358
|
+
*/
|
|
359
|
+
function retire(terminalId) {
|
|
360
|
+
const id = idOf(terminalId);
|
|
361
|
+
if (!id) return false;
|
|
362
|
+
dropLive(id);
|
|
363
|
+
graceLog.delete(id);
|
|
364
|
+
revoked.delete(id);
|
|
365
|
+
revoked.add(id);
|
|
366
|
+
while (revoked.size > cap) revoked.delete(revoked.values().next().value);
|
|
367
|
+
return true;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
/**
|
|
371
|
+
* 'verified' | 'unregistered' | 'missing' | 'invalid' | 'revoked' for a request naming `terminalId` with `presented`
|
|
372
|
+
* (a token, or for a brain's id its launch credential). The comparison is of the SHA-256 digests with `equal`
|
|
373
|
+
* (timingSafeEqual): its time does not depend on where a guess differs from the proof, and every well-formed guess
|
|
374
|
+
* is compared.
|
|
375
|
+
*/
|
|
376
|
+
function check(terminalId, presented) {
|
|
377
|
+
const id = typeof terminalId === 'string' ? terminalId : '';
|
|
378
|
+
const held = id ? live.get(id) : null;
|
|
379
|
+
const absent = presented === undefined || presented === null || presented === '';
|
|
380
|
+
if (!held) {
|
|
381
|
+
if (id && (revoked.has(id) || revokedSessions.has(id))) return 'revoked';
|
|
382
|
+
return 'unregistered';
|
|
383
|
+
}
|
|
384
|
+
if (absent) return 'missing';
|
|
385
|
+
const proof = sanitizeTerminalProof(presented);
|
|
386
|
+
if (!proof) return 'invalid';
|
|
387
|
+
return equal(digestOf(proof), held.digest) ? 'verified' : 'invalid';
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
/**
|
|
391
|
+
* The decision for one request: `{ status, accepted }`, and for a refusal its `code`, `error` and HTTP `httpStatus`.
|
|
392
|
+
* `grace` lets a registered id without a token through while its window is open (every acceptance logged, a line a
|
|
393
|
+
* minute per run at most); a wrong token or an ended run never.
|
|
394
|
+
*/
|
|
395
|
+
function verdict(terminalId, presented) {
|
|
396
|
+
const status = check(terminalId, presented);
|
|
397
|
+
if (status === 'verified' || status === 'unregistered') return { status, accepted: true };
|
|
398
|
+
if (status === 'missing' && currentMode() === 'grace') {
|
|
399
|
+
noteGrace(terminalId);
|
|
400
|
+
return { status, accepted: true, grace: true };
|
|
401
|
+
}
|
|
402
|
+
const refusal = terminalRefusal(status, terminalId);
|
|
403
|
+
return { status, accepted: false, code: refusal.code, error: refusal.error, httpStatus: refusal.status };
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
return {
|
|
407
|
+
issue,
|
|
408
|
+
rotate,
|
|
409
|
+
bind,
|
|
410
|
+
issueSession,
|
|
411
|
+
revokeSession,
|
|
412
|
+
kindOf,
|
|
413
|
+
tokenFor,
|
|
414
|
+
revoke,
|
|
415
|
+
retire,
|
|
416
|
+
check,
|
|
417
|
+
verdict,
|
|
418
|
+
/** Whether `id` may be used by this request (the in-process MCP server's terminalAuth). */
|
|
419
|
+
accepts: (terminalId, presented) => verdict(terminalId, presented).accepted,
|
|
420
|
+
/** Whether `id` holds a live token (or a bound credential). */
|
|
421
|
+
has: (terminalId) => live.has(terminalId),
|
|
422
|
+
/** Whether `id` is an ended run's. */
|
|
423
|
+
isRevoked: (terminalId) => revoked.has(terminalId) || revokedSessions.has(terminalId),
|
|
424
|
+
/** The mode in force: 'grace' only while the environment asks for it and its window is open. */
|
|
425
|
+
mode: () => currentMode(),
|
|
426
|
+
/** For diagnostics: the mode in force, the one asked for, and when grace ends (an ISO time, or null for never). */
|
|
427
|
+
graceState: () => {
|
|
428
|
+
const ends = graceEndsAt();
|
|
429
|
+
return { mode: currentMode(), configured: configuredMode(), endsAt: Number.isFinite(ends) ? new Date(ends).toISOString() : null };
|
|
430
|
+
},
|
|
431
|
+
/** For tests and diagnostics: how many runs hold a token, how many ended ones are kept. */
|
|
432
|
+
stats: () => ({ live: live.size, revoked: revoked.size }),
|
|
433
|
+
/** For tests and diagnostics: how many closed MCP sessions are kept refused (their own list, never the runs'). */
|
|
434
|
+
sessionStats: () => ({ revokedSessions: revokedSessions.size }),
|
|
435
|
+
};
|
|
436
|
+
}
|
|
@@ -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
|
|
34
|
-
//
|
|
35
|
-
//
|
|
36
|
-
|
|
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
|
|
75
|
-
if (!
|
|
76
|
-
return res.status(403).json({ error: 'The worker channel
|
|
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 =
|
|
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.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "neural-memory-interface",
|
|
9
|
-
"version": "2.
|
|
9
|
+
"version": "2.3.0",
|
|
10
10
|
"hasInstallScript": true,
|
|
11
11
|
"license": "Apache-2.0",
|
|
12
12
|
"dependencies": {
|
|
@@ -52,6 +52,7 @@
|
|
|
52
52
|
"html2canvas": "1.4.1",
|
|
53
53
|
"marked": "14.1.4",
|
|
54
54
|
"mermaid": "11.17.2",
|
|
55
|
+
"sharp": "0.34.5",
|
|
55
56
|
"three": "0.169.0"
|
|
56
57
|
},
|
|
57
58
|
"engines": {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "neural-memory-interface",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"private": true,
|
|
5
5
|
"description": "Private local SynaBun interface for memory visualization and multi-agent workflows",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -69,6 +69,7 @@
|
|
|
69
69
|
"html2canvas": "1.4.1",
|
|
70
70
|
"marked": "14.1.4",
|
|
71
71
|
"mermaid": "11.17.2",
|
|
72
|
+
"sharp": "0.34.5",
|
|
72
73
|
"three": "0.169.0"
|
|
73
74
|
}
|
|
74
75
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Assistant mascot artwork (v2)
|
|
2
|
+
|
|
3
|
+
28 GIFs with matching still PNGs, copied from the approved drawn animations in `.synabun/design/mascot-animations-v2/` (approved 2026-11-11). Each file is the whole character (eyes, smile, hands and props together), 120×120, eight drawn cels at the drawing's own timing.
|
|
4
|
+
|
|
5
|
+
`manifest.json` records every state's source, duration, one-shot flag, frame count, which frame the still is, and size. `shared/synabun-mascot-assets.js` owns the allowlisted URL mapping (`MASCOT_ASSET_VERSION` 2). The rig's `thinking` art ships as `think`. Variants without their own v2 art (subagent-2/3, plan-0/2/3, pick-0/2/3, memory-remember, budget-unlimited) fall back to the base state's file (`MASCOT_ASSET_FALLBACKS`). `idle-hero` is the empty page's rest and `hover-attention` its one-shot on hover. The tray cameo keeps its vector eyes: the drawing is unreadable at 10×7 px.
|
|
6
|
+
|
|
7
|
+
Success, error, blocked, offline and hover-attention play once and hold their last cel; every other state loops. The still PNG is the opening cel, or the held last cel for success, error, blocked and offline.
|
|
8
|
+
|
|
9
|
+
The rig shows the art as one image in the 280×140 box (`ART_BOX`) and never draws its pill eyes, smile or props over it. Gaze, blends and reactions move the image as a whole (`artTransform`: small translate, tilt, clamped scale; never a blink). Inactive, offscreen, hidden, dragged and reduced-motion rigs switch to PNGs. Receipts, station minis, answered cards and quota-wait stills use PNGs without registering a rig.
|
|
10
|
+
|
|
11
|
+
Rebuild from `neural-interface` with `node scripts/build-mascot-assets.mjs`: it keys out the `#0a0a0c` review matte (GIF has one-bit alpha; anti-aliased edges stay matted against the Assistant background, which is that colour), sets the loop flags, writes the stills and the manifest, and removes any other GIF/PNG here. It draws nothing and calls no API.
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|