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
|
@@ -8,8 +8,9 @@ import { config as memoryConfig, detectProject as memoryProject } from '../../mc
|
|
|
8
8
|
import { Codex } from '@openai/codex-sdk';
|
|
9
9
|
import { CodexWorkerAppServer } from './codex-worker-app-server.js';
|
|
10
10
|
import { query as claudeQuery } from '@anthropic-ai/claude-agent-sdk';
|
|
11
|
-
import { CLAUDE_EFFORT_LEVELS } from './claude-model-catalog.js';
|
|
11
|
+
import { CLAUDE_EFFORT_LEVELS, CLAUDE_EFFORT_OFF } from './claude-model-catalog.js';
|
|
12
12
|
import { CLAUDE_NOT_INSTALLED, resolveClaudeSdkExecutable } from './claude-executable.js';
|
|
13
|
+
import { BACKGROUND_HOLD_DEFAULTS, createBackgroundTasks, createTurnHold, resultDeclaresDone } from './claude-background-hold.js';
|
|
13
14
|
import { extractOpenCodeText } from './session-title-generator.js';
|
|
14
15
|
import { withServeEnv } from './opencode-protocol.js';
|
|
15
16
|
import { patchCodexLineSplitting } from './jsonl-lines.js';
|
|
@@ -18,6 +19,7 @@ import { codexReasoningEffort } from './effort-levels.js';
|
|
|
18
19
|
import { spawn as spawnProcess } from 'node:child_process';
|
|
19
20
|
import { codexStreamMedia, collectCodexMedia, openCodeMediaPart, ownCodexImages } from './assistant-media.js';
|
|
20
21
|
import { browserToolDenial } from './browser-tool-policy.js';
|
|
22
|
+
import { TERMINAL_TOKEN_ENV } from './terminal-tokens.js';
|
|
21
23
|
import { CODEX_BROWSER_POLICY_UNTRUSTED_NOTE, codexBrowserPolicyHook } from './assistant-route-gate-codex.js';
|
|
22
24
|
import { codexWindowsSandbox, codexWindowsSandboxConfig } from './agent-sandbox-elevation.js';
|
|
23
25
|
import { DRAFT_DISALLOWED_TOOLS, DRAFT_TOOLS, codexDraftOptions, draftOpenCodeDecision, draftPreToolUseHook, draftToolDecision, openCodeDraftConfig, resolveDraftConfinement } from './skills/draft-confinement.js';
|
|
@@ -88,6 +90,12 @@ function createInputQueue() {
|
|
|
88
90
|
};
|
|
89
91
|
}
|
|
90
92
|
|
|
93
|
+
/**
|
|
94
|
+
* Pushed into a Claude turn that waited for its background work when that work ended and the CLI did not come back
|
|
95
|
+
* to it by itself (lib/claude-background-hold.js): the same turn continues.
|
|
96
|
+
*/
|
|
97
|
+
export const BACKGROUND_RESUME_PROMPT = 'SynaBun: the background work you were waiting for has ended. Continue the task from where you stopped. Do not end your turn to wait for something: start the wait and keep working, or call the tool that does the wait for you.';
|
|
98
|
+
|
|
91
99
|
function asAbortError(reason = 'aborted') {
|
|
92
100
|
const error = new Error(reason);
|
|
93
101
|
error.name = 'AbortError';
|
|
@@ -364,6 +372,8 @@ export async function createCodexNativeLoopAdapter(options = {}) {
|
|
|
364
372
|
CodexClass = Codex,
|
|
365
373
|
extraEnv = {}, permissionPolicy: rawPolicy = 'auto', permissionBroker = null, capability: rawCapability = 'full',
|
|
366
374
|
outputSchema = null, desktopGrantProvider = null, modelContextWindow = null, contextMode = null,
|
|
375
|
+
// The run's terminal token (lib/terminal-tokens.js, NativeLoopRuntime): a function, never in the state file.
|
|
376
|
+
terminalTokenProvider = null,
|
|
367
377
|
// Image creation runs (assistant dispatch): 'image' → each turn returns the images it generated.
|
|
368
378
|
collectMedia = null,
|
|
369
379
|
// Assistant task runs: the browser policy's hook and the run's notes (a function: never in the state file), and
|
|
@@ -435,14 +445,21 @@ export async function createCodexNativeLoopAdapter(options = {}) {
|
|
|
435
445
|
for (const key of Array.isArray(unsetEnv) ? unsetEnv : []) delete inherited[key];
|
|
436
446
|
// A worker never holds a brain's launch credential (the Assistant's own identity) or an owner's page secret.
|
|
437
447
|
delete inherited.SYNABUN_BRAIN_TOKEN;
|
|
448
|
+
// …nor another run's terminal token: only its own, below.
|
|
449
|
+
delete inherited[TERMINAL_TOKEN_ENV];
|
|
438
450
|
// The worker's shell must not inherit the owner's live-data paths (its MCP child gets them through its own
|
|
439
451
|
// config: server.js buildCodexMcpEnv). A worker that boots a temp server or runs the suite stays off the live DB.
|
|
440
452
|
for (const key of LIVE_DATA_ENV) delete inherited[key];
|
|
441
453
|
// The hook reads the run's project and the other projects its test runners may run in (a JSON list) from its env.
|
|
442
454
|
const policyEnv = browserPolicy ? { SYNABUN_BROWSER_POLICY_CWD: cwd || process.cwd(), SYNABUN_BROWSER_POLICY_ROOTS: JSON.stringify(Array.isArray(policyRoots) ? policyRoots : []) } : {};
|
|
443
|
-
|
|
455
|
+
// The run's terminal token (lib/terminal-tokens.js): in the Codex process's environment only, which its SynaBun MCP
|
|
456
|
+
// server takes by name (env_vars). The pins above travel as `-c` values on a command line every account of the
|
|
457
|
+
// computer can read; the token never does. Codex's default shell policy keeps a *TOKEN* variable out of the shell
|
|
458
|
+
// commands it runs. A drafting or evaluation run starts no MCP server, so it gets none.
|
|
459
|
+
const terminalToken = !boxed && typeof terminalTokenProvider === 'function' ? (terminalTokenProvider() || null) : null;
|
|
460
|
+
const env = withServeEnv(stringEnv({ ...inherited, ...pins, CODEX_HOME: codexHome, ...policyEnv, ...stringEnv(extraEnv), ...(terminalToken ? { [TERMINAL_TOKEN_ENV]: terminalToken } : {}) }), evaluated ? evalGitSafetyEnv(evaluated.held.root) : null);
|
|
444
461
|
const config = { ...codexWindowsSandboxConfig(adminSandbox) };
|
|
445
|
-
if (Object.keys(pins).length) config.mcp_servers = { SynaBun: { env: pins, ...(task ? { tool_timeout_sec: Math.ceil((options.questionTimeoutMs || 30 * 60_000) / 1000) + 30 } : {}) } };
|
|
462
|
+
if (Object.keys(pins).length) config.mcp_servers = { SynaBun: { env: pins, ...(terminalToken ? { env_vars: [TERMINAL_TOKEN_ENV] } : {}), ...(task ? { tool_timeout_sec: Math.ceil((options.questionTimeoutMs || 30 * 60_000) / 1000) + 30 } : {}) } };
|
|
446
463
|
if (!boxed) {
|
|
447
464
|
const inventory = externalServerInventory({ provider: 'codex', cwd, codexHome, env, home: env.HOME, dataHome: memoryConfig.dataHome, ...options.externalMcpContext });
|
|
448
465
|
const list = nativeToolSelection(options, 'codex');
|
|
@@ -655,6 +672,8 @@ export async function createClaudeNativeLoopAdapter(options = {}) {
|
|
|
655
672
|
extraEnv = {}, permissionPolicy: rawPolicy = 'auto', permissionBroker = null,
|
|
656
673
|
capability: rawCapability = 'full', maxBudgetUsd = null, outputSchema = null, runMode = 'loop',
|
|
657
674
|
desktopGrantProvider = null,
|
|
675
|
+
// The run's terminal token (lib/terminal-tokens.js, NativeLoopRuntime): a function, never in the state file.
|
|
676
|
+
terminalTokenProvider = null,
|
|
658
677
|
// Inherited variables to remove before extraEnv applies (the Claude account's launch:
|
|
659
678
|
// credentials the server was started with never reach a worker).
|
|
660
679
|
unsetEnv = [],
|
|
@@ -675,6 +694,10 @@ export async function createClaudeNativeLoopAdapter(options = {}) {
|
|
|
675
694
|
// Told the CLI's process once it is spawned ({ pid, startedAt, command }): a run that outlives this server is
|
|
676
695
|
// found by it (the next start ends an orphan before it resumes the session).
|
|
677
696
|
onProcess = null,
|
|
697
|
+
// A turn that ends while a background shell or Monitor it started still runs waits for that work: the CLI
|
|
698
|
+
// comes back by itself when it settles (lib/claude-background-hold.js). false turns it off; an object sets
|
|
699
|
+
// its limits ({ idleMs, resumeGraceMs, followGraceMs }).
|
|
700
|
+
backgroundHold = true,
|
|
678
701
|
} = options;
|
|
679
702
|
const permissionPolicy = normalizePermissionPolicy(rawPolicy);
|
|
680
703
|
const capability = normalizeCapability(rawCapability);
|
|
@@ -696,11 +719,20 @@ export async function createClaudeNativeLoopAdapter(options = {}) {
|
|
|
696
719
|
let alive = true;
|
|
697
720
|
let sessionId = null;
|
|
698
721
|
let activeTurn = null;
|
|
722
|
+
// The session's live background tasks (shells, Monitors, agents): what a turn of this run waits for.
|
|
723
|
+
const bgTasks = createBackgroundTasks();
|
|
724
|
+
const holdLimits = backgroundHold && typeof backgroundHold === 'object' ? { ...BACKGROUND_HOLD_DEFAULTS, ...backgroundHold } : BACKGROUND_HOLD_DEFAULTS;
|
|
699
725
|
const inherited = cleanClaudeEnvironment();
|
|
700
726
|
for (const key of ['SYNABUN_PROFILE', 'SYNABUN_RUNTIME_PROFILE_PATH', 'SYNABUN_TOOLS', 'SYNABUN_TOOLS_PATH']) delete inherited[key];
|
|
701
727
|
for (const key of Array.isArray(unsetEnv) ? unsetEnv : []) delete inherited[key];
|
|
702
728
|
// A worker never holds a brain's launch credential (the Assistant's own identity) or an owner's page secret.
|
|
703
729
|
delete inherited.SYNABUN_BRAIN_TOKEN;
|
|
730
|
+
// …nor another run's terminal token: its own goes in its MCP header (below).
|
|
731
|
+
delete inherited[TERMINAL_TOKEN_ENV];
|
|
732
|
+
// The run's terminal token (lib/terminal-tokens.js): the X-Synabun-Terminal-Token header of its SynaBun MCP entry,
|
|
733
|
+
// which referenceClaudeMap turns into a variable the CLI expands from its own environment (never its argv or a
|
|
734
|
+
// file). A drafting or evaluation run has no MCP server, so it gets none.
|
|
735
|
+
const terminalToken = !held && typeof terminalTokenProvider === 'function' ? (terminalTokenProvider() || null) : null;
|
|
704
736
|
// The worker's shell must not inherit the owner's live-data paths: a Claude worker's MCP is in-process HTTP (it
|
|
705
737
|
// reaches the DB through the Neural Interface, never from this env), so nothing here needs them.
|
|
706
738
|
for (const key of LIVE_DATA_ENV) delete inherited[key];
|
|
@@ -734,6 +766,8 @@ export async function createClaudeNativeLoopAdapter(options = {}) {
|
|
|
734
766
|
'X-Synabun-Browser-Tab': browserTabId,
|
|
735
767
|
// Computer-use workers: the grant unlocks the `computer` MCP group.
|
|
736
768
|
'X-Synabun-Desktop-Grant': typeof desktopGrantProvider === 'function' ? desktopGrantProvider() || undefined : undefined,
|
|
769
|
+
// Proves X-Synabun-Terminal to the browser routes (lib/terminal-tokens.js).
|
|
770
|
+
'X-Synabun-Terminal-Token': terminalToken || undefined,
|
|
737
771
|
});
|
|
738
772
|
// Questions use the broker under every policy, independently of tool approvals.
|
|
739
773
|
// ExitPlanMode stays denied: asking does not need a separate plan turn.
|
|
@@ -864,12 +898,15 @@ export async function createClaudeNativeLoopAdapter(options = {}) {
|
|
|
864
898
|
if (definition.oauth) privateMcpServers[name].oauth = structuredClone(definition.oauth);
|
|
865
899
|
if (definition.headersHelper) privateMcpServers[name].headersHelper = definition.headersHelper;
|
|
866
900
|
}
|
|
867
|
-
//
|
|
868
|
-
|
|
901
|
+
// The external servers' secrets (expanded through the CLI's env), and of SynaBun's own headers its one secret, the
|
|
902
|
+
// run's terminal token: redacted from the run's events and the CLI's stderr.
|
|
903
|
+
externalValues = [...mcpSecretValues(definitions, { env }), ...(terminalToken ? [terminalToken] : [])];
|
|
869
904
|
externalScopeNames = Object.keys(definitions);
|
|
870
905
|
}
|
|
871
906
|
if (model) queryOptions.model = model;
|
|
872
907
|
if (effort && CLAUDE_EFFORT_LEVELS.includes(effort)) queryOptions.effort = effort;
|
|
908
|
+
// Off (the route card's, agent_dispatch effort "none"): no thinking at all, over the user's effortLevel setting.
|
|
909
|
+
else if (effort === CLAUDE_EFFORT_OFF) queryOptions.thinking = { type: 'disabled' };
|
|
873
910
|
// Read-only: with the guard enforced the shell stays, limited to read-only commands by the hook, and only the
|
|
874
911
|
// built-in writers are off the list; otherwise (warn, off) today's list, Bash included.
|
|
875
912
|
if (capability === 'read-only' && !held) queryOptions.disallowedTools = guard?.enforced ? [...CLAUDE_READ_ONLY_WRITE_TOOLS] : [...CLAUDE_READ_ONLY_DISALLOWED_TOOLS];
|
|
@@ -997,6 +1034,56 @@ export async function createClaudeNativeLoopAdapter(options = {}) {
|
|
|
997
1034
|
reportedCostUsd = total;
|
|
998
1035
|
return { costUsd: Number(costUsd.toFixed(8)), totalCostUsd: total };
|
|
999
1036
|
};
|
|
1037
|
+
// ── Background work a turn waits for (lib/claude-background-hold.js) ──
|
|
1038
|
+
const holdEvent = (state, meta) => forwardEvent({
|
|
1039
|
+
type: 'synabun.background_wait',
|
|
1040
|
+
state: state.state,
|
|
1041
|
+
...(state.reason ? { reason: state.reason } : {}),
|
|
1042
|
+
iteration: meta?.iteration,
|
|
1043
|
+
tasks: (state.tasks || []).map((task) => ({ id: task.id, type: task.type, description: task.description })),
|
|
1044
|
+
});
|
|
1045
|
+
const turnHoldFor = (turn, meta) => createTurnHold({
|
|
1046
|
+
tasks: bgTasks,
|
|
1047
|
+
idleMs: holdLimits.idleMs,
|
|
1048
|
+
resumeGraceMs: holdLimits.resumeGraceMs,
|
|
1049
|
+
followGraceMs: holdLimits.followGraceMs,
|
|
1050
|
+
deadlineAt: Number(meta?.deadlineAt) || null,
|
|
1051
|
+
// A dispatched worker that wrote its ## Result block is done, whatever it left running.
|
|
1052
|
+
shouldHold: runMode === 'task' ? (value) => !resultDeclaresDone(value?.text) : () => true,
|
|
1053
|
+
onState: (state) => holdEvent(state, meta),
|
|
1054
|
+
// The work ended and the CLI did not come back by itself: one prompt to continue the same turn.
|
|
1055
|
+
nudge: () => {
|
|
1056
|
+
if (!alive || activeTurn !== turn) return false;
|
|
1057
|
+
forwardEvent({ type: 'synabun.user_prompt', text: BACKGROUND_RESUME_PROMPT, iteration: meta?.iteration, synthetic: 'background-resume' });
|
|
1058
|
+
return input.push({
|
|
1059
|
+
type: 'user',
|
|
1060
|
+
message: { role: 'user', content: [{ type: 'text', text: BACKGROUND_RESUME_PROMPT }] },
|
|
1061
|
+
parent_tool_use_id: null,
|
|
1062
|
+
session_id: sessionId || '',
|
|
1063
|
+
});
|
|
1064
|
+
},
|
|
1065
|
+
// The hold ended by itself (idle, deadline, the CLI never came back): the turn ends with its last result.
|
|
1066
|
+
onRelease: (reason, live) => {
|
|
1067
|
+
if (reason !== 'drained') bgTasks.excuse(live);
|
|
1068
|
+
if (activeTurn !== turn) return;
|
|
1069
|
+
activeTurn = null;
|
|
1070
|
+
turn.resolve({
|
|
1071
|
+
...(turn.hold?.value() || { text: '', usage: null, costUsd: 0, totalCostUsd: reportedCostUsd, result: null, structured: null }),
|
|
1072
|
+
providerSessionId: sessionId,
|
|
1073
|
+
background: { released: reason, tasks: live.map((task) => ({ id: task.id, type: task.type, description: task.description })) },
|
|
1074
|
+
});
|
|
1075
|
+
},
|
|
1076
|
+
});
|
|
1077
|
+
/** The CLI ended (the run's end, or by itself): every task it still ran ended with it. */
|
|
1078
|
+
const endBackgroundTasks = (summary) => {
|
|
1079
|
+
const live = bgTasks.live();
|
|
1080
|
+
bgTasks.clear();
|
|
1081
|
+
if (!live.length) return;
|
|
1082
|
+
for (const task of live) {
|
|
1083
|
+
forwardEvent({ type: 'system', subtype: 'task_notification', task_id: task.id, status: 'stopped', summary, output_file: '', session_id: sessionId || '', synthetic: true });
|
|
1084
|
+
}
|
|
1085
|
+
forwardEvent({ type: 'system', subtype: 'background_tasks_changed', tasks: [], session_id: sessionId || '', synthetic: true });
|
|
1086
|
+
};
|
|
1000
1087
|
let pumpError = null;
|
|
1001
1088
|
const pump = (async () => {
|
|
1002
1089
|
try {
|
|
@@ -1009,12 +1096,12 @@ export async function createClaudeNativeLoopAdapter(options = {}) {
|
|
|
1009
1096
|
onIdentity({ providerSessionId: sessionId });
|
|
1010
1097
|
}
|
|
1011
1098
|
emitEvent(event);
|
|
1099
|
+
bgTasks.apply(event, Date.now());
|
|
1012
1100
|
if (event?.type === 'result' && activeTurn) {
|
|
1013
1101
|
const turn = activeTurn;
|
|
1014
|
-
activeTurn = null;
|
|
1015
1102
|
const cost = turnCost(event);
|
|
1016
1103
|
if (event.subtype === 'success') {
|
|
1017
|
-
|
|
1104
|
+
const value = {
|
|
1018
1105
|
providerSessionId: sessionId,
|
|
1019
1106
|
result: event,
|
|
1020
1107
|
text: typeof event.result === 'string' ? event.result : '',
|
|
@@ -1022,17 +1109,27 @@ export async function createClaudeNativeLoopAdapter(options = {}) {
|
|
|
1022
1109
|
costUsd: cost.costUsd,
|
|
1023
1110
|
totalCostUsd: cost.totalCostUsd,
|
|
1024
1111
|
structured: event.structured_output ?? null,
|
|
1025
|
-
}
|
|
1112
|
+
};
|
|
1113
|
+
// A turn whose background work still runs is not over: the CLI comes back to it by itself.
|
|
1114
|
+
if (turn.hold && turn.hold.onResult(event, value) === 'hold') continue;
|
|
1115
|
+
activeTurn = null;
|
|
1116
|
+
turn.resolve(turn.hold ? { ...turn.hold.value(), providerSessionId: sessionId } : value);
|
|
1026
1117
|
} else {
|
|
1118
|
+
activeTurn = null;
|
|
1119
|
+
const earlier = turn.hold?.value();
|
|
1120
|
+
turn.hold?.cancel();
|
|
1027
1121
|
const error = new Error((event.errors && event.errors[0]) || event.error || event.result || 'Claude turn failed');
|
|
1028
1122
|
error.subtype = event.subtype || null;
|
|
1029
1123
|
if (event.subtype === 'error_max_budget_usd') error.code = 'BUDGET_CAP';
|
|
1030
1124
|
else if (event.subtype === 'error_max_turns') error.code = 'MAX_TURNS';
|
|
1031
|
-
|
|
1125
|
+
// A held turn's earlier results were charged too.
|
|
1126
|
+
error.costUsd = Number(((Number(earlier?.costUsd) || 0) + cost.costUsd).toFixed(8));
|
|
1032
1127
|
error.totalCostUsd = cost.totalCostUsd;
|
|
1033
1128
|
error.usage = event.usage || null;
|
|
1034
1129
|
turn.reject(error);
|
|
1035
1130
|
}
|
|
1131
|
+
} else if (activeTurn?.hold) {
|
|
1132
|
+
activeTurn.hold.onEvent(event);
|
|
1036
1133
|
}
|
|
1037
1134
|
}
|
|
1038
1135
|
} catch (error) {
|
|
@@ -1050,9 +1147,12 @@ export async function createClaudeNativeLoopAdapter(options = {}) {
|
|
|
1050
1147
|
input.close();
|
|
1051
1148
|
if (activeTurn) {
|
|
1052
1149
|
const turn = activeTurn; activeTurn = null;
|
|
1150
|
+
turn.hold?.cancel();
|
|
1053
1151
|
turn.reject(pumpError || new Error('Claude session ended before the turn completed'));
|
|
1054
1152
|
}
|
|
1055
1153
|
}
|
|
1154
|
+
// The CLI is gone, and every background task with it: say so, or a panel shows them running forever.
|
|
1155
|
+
endBackgroundTasks('The Claude Code process of this run ended.');
|
|
1056
1156
|
}
|
|
1057
1157
|
if (pumpError) throw pumpError;
|
|
1058
1158
|
})();
|
|
@@ -1087,7 +1187,9 @@ export async function createClaudeNativeLoopAdapter(options = {}) {
|
|
|
1087
1187
|
event: { type: 'synabun.user_prompt', text: String(prompt || ''), iteration: meta.iteration },
|
|
1088
1188
|
});
|
|
1089
1189
|
return new Promise((resolveTurn, rejectTurn) => {
|
|
1090
|
-
|
|
1190
|
+
const turn = { resolve: resolveTurn, reject: rejectTurn, iteration: meta.iteration, hold: null };
|
|
1191
|
+
if (backgroundHold) turn.hold = turnHoldFor(turn, meta);
|
|
1192
|
+
activeTurn = turn;
|
|
1091
1193
|
const ok = input.push({
|
|
1092
1194
|
type: 'user',
|
|
1093
1195
|
message: { role: 'user', content: [{ type: 'text', text: prompt }] },
|
|
@@ -1096,6 +1198,7 @@ export async function createClaudeNativeLoopAdapter(options = {}) {
|
|
|
1096
1198
|
});
|
|
1097
1199
|
if (!ok) {
|
|
1098
1200
|
activeTurn = null;
|
|
1201
|
+
turn.hold?.cancel();
|
|
1099
1202
|
rejectTurn(new Error('Claude input stream is closed'));
|
|
1100
1203
|
}
|
|
1101
1204
|
});
|
|
@@ -1103,6 +1206,7 @@ export async function createClaudeNativeLoopAdapter(options = {}) {
|
|
|
1103
1206
|
async abort(reason = 'aborted') {
|
|
1104
1207
|
if (activeTurn) {
|
|
1105
1208
|
const turn = activeTurn; activeTurn = null;
|
|
1209
|
+
turn.hold?.cancel();
|
|
1106
1210
|
turn.reject(asAbortError(reason));
|
|
1107
1211
|
}
|
|
1108
1212
|
if (!alive) return true;
|
|
@@ -1120,8 +1224,12 @@ export async function createClaudeNativeLoopAdapter(options = {}) {
|
|
|
1120
1224
|
async dispose(options = {}) {
|
|
1121
1225
|
if (activeTurn) {
|
|
1122
1226
|
const turn = activeTurn; activeTurn = null;
|
|
1227
|
+
turn.hold?.cancel();
|
|
1123
1228
|
turn.reject(asAbortError('disposed'));
|
|
1124
1229
|
}
|
|
1230
|
+
// Closing the query ends the CLI and every background task it runs; the CLI's own notices of that are never
|
|
1231
|
+
// read (the pump stops with the run): the run's viewers are told here.
|
|
1232
|
+
endBackgroundTasks('Stopped when the run ended.');
|
|
1125
1233
|
if (options?.terminate === true) {
|
|
1126
1234
|
terminating = true;
|
|
1127
1235
|
await endProcess(Number(options.graceMs) > 0 ? Number(options.graceMs) : 1500);
|
|
@@ -1673,6 +1781,8 @@ export async function createAntigravityNativeLoopAdapter(options = {}) {
|
|
|
1673
1781
|
permissionPolicy: rawPolicy = 'auto', permissionBroker = null,
|
|
1674
1782
|
capability: rawCapability = 'full', outputSchema = null, runMode = 'loop',
|
|
1675
1783
|
browserSessionId = null, browserTabId = null, desktopGrantProvider = null,
|
|
1784
|
+
// The run's terminal token (lib/terminal-tokens.js, NativeLoopRuntime): a function, never in the state file.
|
|
1785
|
+
terminalTokenProvider = null,
|
|
1676
1786
|
extraEnv = {}, unsetEnv = [], resumeSessionId = null,
|
|
1677
1787
|
confinement = null,
|
|
1678
1788
|
guardMode = WORKER_GUARD_DEFAULT, scratchDir = null, serverPort = null, localPortRange = null,
|
|
@@ -1721,9 +1831,12 @@ export async function createAntigravityNativeLoopAdapter(options = {}) {
|
|
|
1721
1831
|
SYNABUN_BROWSER_TAB: browserTabId,
|
|
1722
1832
|
SYNABUN_TOOLS: runtimeToolsValue(tools.items.includes('all') ? tools.items : [...tools.groups, ...tools.servers]),
|
|
1723
1833
|
SYNABUN_DESKTOP_GRANT: typeof desktopGrantProvider === 'function' ? desktopGrantProvider() || undefined : undefined,
|
|
1834
|
+
// The run's terminal token (lib/terminal-tokens.js): agy's environment only, which its SynaBun MCP child inherits
|
|
1835
|
+
// (the run's home lists the server, not this value).
|
|
1836
|
+
[TERMINAL_TOKEN_ENV]: typeof terminalTokenProvider === 'function' ? terminalTokenProvider() || undefined : undefined,
|
|
1724
1837
|
});
|
|
1725
1838
|
const inherited = { ...process.env };
|
|
1726
|
-
for (const key of ['SYNABUN_PROFILE', 'SYNABUN_RUNTIME_PROFILE_PATH', 'SYNABUN_TOOLS', 'SYNABUN_TOOLS_PATH', 'SYNABUN_TOOL_CATALOG_MODE', 'SYNABUN_ROLE', 'SYNABUN_AGY_POLICY_URL', 'SYNABUN_AGY_POLICY_TOKEN']) delete inherited[key];
|
|
1839
|
+
for (const key of ['SYNABUN_PROFILE', 'SYNABUN_RUNTIME_PROFILE_PATH', 'SYNABUN_TOOLS', 'SYNABUN_TOOLS_PATH', 'SYNABUN_TOOL_CATALOG_MODE', 'SYNABUN_ROLE', 'SYNABUN_AGY_POLICY_URL', 'SYNABUN_AGY_POLICY_TOKEN', TERMINAL_TOKEN_ENV]) delete inherited[key];
|
|
1727
1840
|
for (const key of Array.isArray(unsetEnv) ? unsetEnv : []) delete inherited[key];
|
|
1728
1841
|
delete inherited.SYNABUN_BRAIN_TOKEN;
|
|
1729
1842
|
for (const key of LIVE_DATA_ENV) delete inherited[key];
|
|
@@ -2,6 +2,7 @@ import { retainExternalRefs } from './mcp-external-servers.js';
|
|
|
2
2
|
import { storedToolList, toolListRecord, readStoredToolListRecord } from './tool-lists.js';
|
|
3
3
|
import { existsSync, mkdirSync, readFileSync, renameSync, unlinkSync, writeFileSync } from 'node:fs';
|
|
4
4
|
import { dirname, resolve } from 'node:path';
|
|
5
|
+
import { redactTerminalSecrets, scrubTokenText } from './terminal-token-redaction.js';
|
|
5
6
|
|
|
6
7
|
export const NATIVE_LOOP_PROFILES = new Set(['claude-code', 'codex', 'opencode', 'antigravity']);
|
|
7
8
|
|
|
@@ -13,7 +14,21 @@ function iso(now = Date.now()) {
|
|
|
13
14
|
return new Date(now).toISOString();
|
|
14
15
|
}
|
|
15
16
|
|
|
17
|
+
/**
|
|
18
|
+
* What SynaBun keeps and shows of a run: its descriptor (the ledger, every broadcast, onFinish, getRun). Scrubbed of
|
|
19
|
+
* run secrets (lib/terminal-token-redaction.js): its task, title, error and tool-list error may quote what an agent
|
|
20
|
+
* printed or a provider threw, its token included (review 972afb74, finding 5).
|
|
21
|
+
*/
|
|
16
22
|
function cleanDescriptor(record) {
|
|
23
|
+
return redactTerminalSecrets(rawDescriptor(record));
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** The text of a failure, scrubbed: what a record's `error` and a state file's `lastIterationError` keep. */
|
|
27
|
+
function errorText(error) {
|
|
28
|
+
return scrubTokenText(error?.message || String(error));
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function rawDescriptor(record) {
|
|
17
32
|
return {
|
|
18
33
|
runId: record.runId,
|
|
19
34
|
terminalSessionId: record.runId,
|
|
@@ -87,6 +102,20 @@ function writeJsonAtomic(path, value) {
|
|
|
87
102
|
* Drives unattended native provider conversations while keeping the provider
|
|
88
103
|
* transcript durable and attachable by a sidepanel at any point in the run.
|
|
89
104
|
*/
|
|
105
|
+
/**
|
|
106
|
+
* Wrap an adapter's runTurn so what it resolves with passes through redactTerminalSecrets (lib/terminal-token-redaction.js):
|
|
107
|
+
* the run's result text, a structured answer, anything an agent echoed of its environment. The adapter keeps every
|
|
108
|
+
* other method as it is (it is the factory's own object).
|
|
109
|
+
*/
|
|
110
|
+
function scrubTurnResults(adapter) {
|
|
111
|
+
if (!adapter || typeof adapter.runTurn !== 'function' || adapter.runTurn.__synabunScrubbed) return adapter;
|
|
112
|
+
const runTurn = adapter.runTurn;
|
|
113
|
+
const scrubbed = async function scrubbedRunTurn(...args) { return redactTerminalSecrets(await runTurn.apply(this, args)); };
|
|
114
|
+
Object.defineProperty(scrubbed, '__synabunScrubbed', { value: true });
|
|
115
|
+
try { adapter.runTurn = scrubbed; } catch { /* a frozen adapter keeps its own */ }
|
|
116
|
+
return adapter;
|
|
117
|
+
}
|
|
118
|
+
|
|
90
119
|
export class NativeLoopRuntime {
|
|
91
120
|
constructor({
|
|
92
121
|
stateDir,
|
|
@@ -114,6 +143,10 @@ export class NativeLoopRuntime {
|
|
|
114
143
|
// How long a dispatched worker the restart cut off waits, from this start, for its dispatcher to resume it
|
|
115
144
|
// (or end it) before it ends as interrupted by itself.
|
|
116
145
|
resumeHoldMs = 60_000,
|
|
146
|
+
// The server's terminal tokens (lib/terminal-tokens.js: issue / revoke): a run's token is issued at its launch and
|
|
147
|
+
// its resume, handed to its provider as `terminalTokenProvider` (a function: never in the state file), and revoked
|
|
148
|
+
// when the run finishes. null: runs get none (tests, a runtime without the browser routes).
|
|
149
|
+
terminalTokens = null,
|
|
117
150
|
} = {}) {
|
|
118
151
|
if (!stateDir) throw new Error('NativeLoopRuntime requires stateDir');
|
|
119
152
|
if (typeof buildPrompt !== 'function') throw new Error('NativeLoopRuntime requires buildPrompt');
|
|
@@ -124,8 +157,14 @@ export class NativeLoopRuntime {
|
|
|
124
157
|
this.providerFactories = { ...providerFactories };
|
|
125
158
|
this.buildPrompt = buildPrompt;
|
|
126
159
|
this.onEvent = onEvent;
|
|
127
|
-
this.
|
|
128
|
-
|
|
160
|
+
this.terminalTokens = terminalTokens && typeof terminalTokens.issue === 'function' ? terminalTokens : null;
|
|
161
|
+
// Every end of a run goes through onFinish: its terminal token goes first, so nothing acts as the run once it ended.
|
|
162
|
+
this.onFinish = async (descriptor) => {
|
|
163
|
+
try { if (descriptor?.runId) this.terminalTokens?.revoke?.(descriptor.runId); } catch { /* the end goes on */ }
|
|
164
|
+
return onFinish(descriptor);
|
|
165
|
+
};
|
|
166
|
+
// Every line is scrubbed before the logger gets it (a loop log under data/ is in every backup).
|
|
167
|
+
this.log = (runId, tag, message, meta) => log(runId, tag, scrubTokenText(typeof message === 'string' ? message : String(message ?? '')), meta === undefined ? meta : redactTerminalSecrets(meta));
|
|
129
168
|
this.now = now;
|
|
130
169
|
this.sleep = sleep;
|
|
131
170
|
this.iterationDelayMs = iterationDelayMs;
|
|
@@ -143,6 +182,23 @@ export class NativeLoopRuntime {
|
|
|
143
182
|
this._loadLedger();
|
|
144
183
|
}
|
|
145
184
|
|
|
185
|
+
/**
|
|
186
|
+
* `{ terminalTokenProvider }` for a run's provider (its terminal token, issued now when the run has none yet), or
|
|
187
|
+
* nothing without a registry. A function, so the state file (JSON) never holds the token. `fresh` (a resume): a new
|
|
188
|
+
* token whatever the run held, so a token of the process that ended proves nothing (review c0eab425, finding L5:
|
|
189
|
+
* a resume without a restart used to hand the new process the old token).
|
|
190
|
+
*/
|
|
191
|
+
_terminalTokenFor(runId, { fresh = false } = {}) {
|
|
192
|
+
if (!this.terminalTokens) return {};
|
|
193
|
+
let token = null;
|
|
194
|
+
try {
|
|
195
|
+
token = (fresh && typeof this.terminalTokens.rotate === 'function' ? this.terminalTokens.rotate(runId) : this.terminalTokens.issue(runId)) || null;
|
|
196
|
+
} catch { token = null; }
|
|
197
|
+
// Read when the provider starts a process (an OpenCode serve may restart): the live token, none once revoked.
|
|
198
|
+
const live = typeof this.terminalTokens.tokenFor === 'function' ? () => this.terminalTokens.tokenFor(runId) || null : () => token;
|
|
199
|
+
return token ? { terminalTokenProvider: live } : {};
|
|
200
|
+
}
|
|
201
|
+
|
|
146
202
|
registerProvider(profile, factory) {
|
|
147
203
|
if (typeof factory !== 'function') throw new Error(`Provider factory for ${profile} must be a function`);
|
|
148
204
|
this.providerFactories[profile] = factory;
|
|
@@ -167,7 +223,10 @@ export class NativeLoopRuntime {
|
|
|
167
223
|
}
|
|
168
224
|
|
|
169
225
|
_emitProviderEvent(record, event) {
|
|
170
|
-
|
|
226
|
+
// Every provider's events (Claude Code, Codex, OpenCode, Antigravity) pass here before anything keeps or shows
|
|
227
|
+
// them: a run's terminal token or a brain credential an agent printed (its `env`, `ps -E`) never reaches the run's
|
|
228
|
+
// records, its transcript or a panel (lib/terminal-token-redaction.js).
|
|
229
|
+
const message = { type: 'sidepanel:provider-event', run: cleanDescriptor(record), event: redactTerminalSecrets(event) };
|
|
171
230
|
try { this.onEvent(message); } catch {}
|
|
172
231
|
this._notifyListeners(message);
|
|
173
232
|
}
|
|
@@ -237,6 +296,9 @@ export class NativeLoopRuntime {
|
|
|
237
296
|
record.pendingRequests = [];
|
|
238
297
|
record.stopping = false;
|
|
239
298
|
this.records.set(record.runId, record);
|
|
299
|
+
// No process holds a token of this server for it yet: its id is refused until its resume issues one (never
|
|
300
|
+
// taken as said in the meantime).
|
|
301
|
+
try { this.terminalTokens?.retire?.(record.runId); } catch { /* the hold goes on */ }
|
|
240
302
|
this._hold(record);
|
|
241
303
|
continue;
|
|
242
304
|
}
|
|
@@ -326,7 +388,8 @@ export class NativeLoopRuntime {
|
|
|
326
388
|
|
|
327
389
|
_writeState(runId, state) {
|
|
328
390
|
const { permissionBroker: _broker, ...stored } = state;
|
|
329
|
-
|
|
391
|
+
// Scrubbed before it is written: a state file under data/ is in every backup (its task, its last error).
|
|
392
|
+
writeJsonAtomic(this._statePath(runId), redactTerminalSecrets(toolListRecord(stored, this.toolListOptions())));
|
|
330
393
|
}
|
|
331
394
|
|
|
332
395
|
_writeTerminalState(record, patch) {
|
|
@@ -405,8 +468,10 @@ export class NativeLoopRuntime {
|
|
|
405
468
|
runtimeType: 'native',
|
|
406
469
|
surface: 'sidepanel',
|
|
407
470
|
startedAt,
|
|
471
|
+
...this._terminalTokenFor(runId),
|
|
408
472
|
};
|
|
409
|
-
|
|
473
|
+
// A run that cannot even be written down never starts: nothing may act as it.
|
|
474
|
+
try { this._writeState(runId, nativeState); } catch (error) { try { this.terminalTokens?.revoke?.(runId); } catch {} throw error; }
|
|
410
475
|
const initialClaim = String(claimedBy || '').trim().slice(0, 128);
|
|
411
476
|
|
|
412
477
|
const record = {
|
|
@@ -557,6 +622,8 @@ export class NativeLoopRuntime {
|
|
|
557
622
|
throw cancelled;
|
|
558
623
|
}
|
|
559
624
|
candidateAccepted = true;
|
|
625
|
+
// What a turn returns (its text, its structured answer) is kept as the run's result: scrubbed like its events.
|
|
626
|
+
scrubTurnResults(adapter);
|
|
560
627
|
record.adapter = record.wrapAdapter
|
|
561
628
|
? record.wrapAdapter(adapter, {
|
|
562
629
|
runId,
|
|
@@ -639,8 +706,11 @@ export class NativeLoopRuntime {
|
|
|
639
706
|
startedAt: record.startedAt || state.startedAt || iso(this.now()),
|
|
640
707
|
currentIteration: 0,
|
|
641
708
|
totalIterations,
|
|
709
|
+
// A resume is a new process: a new token (after a restart the registry starts empty anyway; without one, the
|
|
710
|
+
// token the suspended process held is revoked first), handed to the resumed provider through the same function.
|
|
711
|
+
...this._terminalTokenFor(runId, { fresh: true }),
|
|
642
712
|
};
|
|
643
|
-
this._writeState(runId, nativeState);
|
|
713
|
+
try { this._writeState(runId, nativeState); } catch (error) { try { this.terminalTokens?.revoke?.(runId); } catch {} throw error; }
|
|
644
714
|
Object.assign(record, {
|
|
645
715
|
status: 'starting',
|
|
646
716
|
stoppedReason: null,
|
|
@@ -714,7 +784,7 @@ export class NativeLoopRuntime {
|
|
|
714
784
|
record.status = 'interrupted';
|
|
715
785
|
record.stoppedReason = reason || record.suspendReason || 'server_restart';
|
|
716
786
|
record.completedAt = iso(this.now());
|
|
717
|
-
if (error) record.error = String(error);
|
|
787
|
+
if (error) record.error = scrubTokenText(String(error));
|
|
718
788
|
this._writeTerminalState(record, { active: false, pending: false, completedAt: record.completedAt, stoppedReason: record.stoppedReason, ...(error ? { error: record.error } : {}) });
|
|
719
789
|
this._releaseRuntimeRefs(record);
|
|
720
790
|
this._emit('sidepanel:run-stopped', record);
|
|
@@ -739,6 +809,8 @@ export class NativeLoopRuntime {
|
|
|
739
809
|
try { record.startupAbortController?.abort(reason); } catch {}
|
|
740
810
|
if (record._cancelStartup) { record._cancelStartup(reason); record._cancelStartup = null; }
|
|
741
811
|
try { await record.adapter?.dispose?.({ preserveSession: true, terminate: true }); } catch {}
|
|
812
|
+
// A suspended run has no process: nothing may act as it until its resume gives the new process a new token.
|
|
813
|
+
try { this.terminalTokens?.revoke?.(runId); } catch { /* the suspension goes on */ }
|
|
742
814
|
this._releaseRuntimeRefs(record, { turnState: 'suspended' });
|
|
743
815
|
record.stopping = false;
|
|
744
816
|
this._emit('sidepanel:run-updated', record, { reason: 'suspended' });
|
|
@@ -780,7 +852,12 @@ export class NativeLoopRuntime {
|
|
|
780
852
|
|
|
781
853
|
try {
|
|
782
854
|
const prompt = (record.buildPrompt || this.buildPrompt)(nextState, iteration);
|
|
783
|
-
|
|
855
|
+
// A loop's time cap bounds its iteration too: a turn that waits for its background work (a pacing gap)
|
|
856
|
+
// ends with its last result at this moment, and the next pass stops the run with time_cap.
|
|
857
|
+
const deadlineAt = record.runMode !== 'task'
|
|
858
|
+
? new Date(state.startedAt || record.startedAt).getTime() + Math.max(1, Number(state.maxMinutes) || 30) * 60_000
|
|
859
|
+
: null;
|
|
860
|
+
const result = await record.adapter.runTurn(prompt, { iteration, total, ...(deadlineAt ? { deadlineAt } : {}) });
|
|
784
861
|
failures = 0;
|
|
785
862
|
this._setIdentity(record, result || record.adapter.identity?.() || {});
|
|
786
863
|
const fresh = this._readState(record.runId);
|
|
@@ -815,13 +892,13 @@ export class NativeLoopRuntime {
|
|
|
815
892
|
if (failedState) {
|
|
816
893
|
failedState.currentIteration = current;
|
|
817
894
|
delete failedState.runningIteration;
|
|
818
|
-
failedState.lastIterationError =
|
|
895
|
+
failedState.lastIterationError = errorText(error);
|
|
819
896
|
failedState.lastIterationAt = iso(this.now());
|
|
820
897
|
this._writeState(record.runId, failedState);
|
|
821
898
|
}
|
|
822
899
|
record.currentIteration = current;
|
|
823
900
|
this._emit('sidepanel:run-updated', record, { reason: 'iteration-failed', failures });
|
|
824
|
-
this.log(record.runId, 'native:iteration-error',
|
|
901
|
+
this.log(record.runId, 'native:iteration-error', errorText(error), { iteration, failures });
|
|
825
902
|
if (failures >= 3) {
|
|
826
903
|
await this._fail(record, error, 'provider_failures');
|
|
827
904
|
return;
|
|
@@ -873,7 +950,7 @@ export class NativeLoopRuntime {
|
|
|
873
950
|
if (!record || ['completed', 'failed', 'stopped', 'interrupted', 'suspended'].includes(record.status)) return;
|
|
874
951
|
clearTimeout(record.timer);
|
|
875
952
|
record.status = status === 'interrupted' ? 'interrupted' : 'failed';
|
|
876
|
-
record.error =
|
|
953
|
+
record.error = errorText(error);
|
|
877
954
|
record.stoppedReason = reason;
|
|
878
955
|
record.completedAt = iso(this.now());
|
|
879
956
|
if (record._resolveIdentity) { record._resolveIdentity(null); record._resolveIdentity = null; }
|
|
@@ -973,6 +1050,30 @@ export class NativeLoopRuntime {
|
|
|
973
1050
|
return released;
|
|
974
1051
|
}
|
|
975
1052
|
|
|
1053
|
+
/**
|
|
1054
|
+
* The run's browser route moved (server.js noteAutomationBrowserRoute: a recovery, or the run's own
|
|
1055
|
+
* browser_session create): its record and its state file name the new session and tab, so GET
|
|
1056
|
+
* /api/browser/sessions (yourRoute), /api/loop/stop and the panel follow it. No-op for an unknown run, a run that
|
|
1057
|
+
* ended (its end already released its browser and wrote its final state: a late recovery must not rewrite either),
|
|
1058
|
+
* or the same route.
|
|
1059
|
+
*/
|
|
1060
|
+
setBrowserRoute(runId, { browserSessionId = null, browserTabId = null } = {}) {
|
|
1061
|
+
const record = this.records.get(runId);
|
|
1062
|
+
if (!record || !browserSessionId || !LIVE_STATUSES.has(record.status)) return null;
|
|
1063
|
+
const sessionId = String(browserSessionId);
|
|
1064
|
+
const tabId = browserTabId ? String(browserTabId) : null;
|
|
1065
|
+
if (record.browserSessionId === sessionId && (record.browserTabId || null) === tabId) return cleanDescriptor(record);
|
|
1066
|
+
record.browserSessionId = sessionId;
|
|
1067
|
+
record.browserTabId = tabId;
|
|
1068
|
+
try {
|
|
1069
|
+
const state = this._readState(record.runId);
|
|
1070
|
+
if (state) this._writeState(record.runId, { ...state, browserSessionId: sessionId, browserTabId: tabId });
|
|
1071
|
+
} catch (error) {
|
|
1072
|
+
this.log(record.runId, 'native:state-write-error', error?.message || String(error));
|
|
1073
|
+
}
|
|
1074
|
+
return this._emit('sidepanel:run-updated', record, { reason: 'browser-route' });
|
|
1075
|
+
}
|
|
1076
|
+
|
|
976
1077
|
setTools(runId, tools) {
|
|
977
1078
|
const record = this.records.get(runId);
|
|
978
1079
|
if (!record) return null;
|