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
|
@@ -33,17 +33,27 @@
|
|
|
33
33
|
// credential that survived the peer check — and stays on its route's rules (the MCP git tool, desktop, loop and
|
|
34
34
|
// browser tools; the brain; the Assistant's route gate, asked with the session's pin by the OpenCode plugin and the
|
|
35
35
|
// Codex hook, which checks the session's own token), as do the few routes agents call without a pin
|
|
36
|
-
// (AGENT_OPEN_PREFIXES: the server's stop and restart the CLI asks, the MCP server's tab release,
|
|
37
|
-
// schedules the /synabun skill creates with curl).
|
|
36
|
+
// (AGENT_OPEN_PREFIXES: the server's stop and restart the CLI asks, the MCP server's tab release, the loops and
|
|
37
|
+
// schedules the /synabun skill creates with curl, and OpenCode's requests for a Sabiá model through SynaBun).
|
|
38
38
|
//
|
|
39
39
|
// Never refused by this module: the owner's own browser and the SynaBun app (the peer lookup allows them), this
|
|
40
40
|
// server itself, a request from outside (the tunnel, the invite proxy: the guest rules decide those, and the
|
|
41
|
-
// tunnel's own process would otherwise read as a relay), and
|
|
42
|
-
// rules from before apply
|
|
41
|
+
// tunnel's own process would otherwise read as a relay), and wherever the lookup does not run (another platform than
|
|
42
|
+
// macOS, or SYNABUN_PEER_IDENTITY=off: the rules from before apply, so Windows and Linux work as they always did).
|
|
43
|
+
//
|
|
44
|
+
// A lookup that failed on macOS (lib/peer-identity.js: netstat or ps missing, denied, slow past the cap, unreadable)
|
|
45
|
+
// proves nothing about who is asking, so it holds none of the owner's powers: every request this module covers —
|
|
46
|
+
// the owner's writes (an agent's pinned call and an agent-open route too: a relay can send a pin), the owner's reads,
|
|
47
|
+
// the secret reads, the owner's sockets — is answered 503 PEER_UNAVAILABLE (`retryable` when the lookup timed out,
|
|
48
|
+
// with Retry-After), and /ws/sync stays open, read-only. The app's pages and every other read still load. Two writes
|
|
49
|
+
// keep the rules from before even then (DEGRADED_OPEN_PATHS): the server's restart and stop, which take nothing from
|
|
50
|
+
// the request, are what the desktop app's quit, the uninstaller and the owner's way out (SYNABUN_PEER_IDENTITY=off,
|
|
51
|
+
// then a restart) need, and an agent's tree may call them anyway. A request it should have looked up and has no
|
|
52
|
+
// verdict for (`required`: a server whose lookup runs) is taken as a failed lookup, never as the rules from before.
|
|
43
53
|
|
|
44
54
|
import { readFileSync } from 'node:fs';
|
|
45
55
|
import { AGENT_HEADERS, sendGuardError } from './http-guards.js';
|
|
46
|
-
import { BRAIN_HEADER, PEER_VERDICT } from './peer-identity.js';
|
|
56
|
+
import { BRAIN_HEADER, PEER_VERDICT, failedPeerVerdict, peerAuthority } from './peer-identity.js';
|
|
47
57
|
import { ADMIN_ONLY_PREFIXES, routedForms } from './request-gate.js';
|
|
48
58
|
|
|
49
59
|
const SAFE_METHODS = new Set(['GET', 'HEAD', 'OPTIONS']);
|
|
@@ -59,8 +69,11 @@ export const FEATURE_OPEN_PREFIXES = Object.freeze([
|
|
|
59
69
|
]);
|
|
60
70
|
/** Paths under an open prefix that are not open: the code editor's copies of unsaved buffers (file content). */
|
|
61
71
|
export const NEVER_OPEN_PREFIXES = Object.freeze(['/api/ui-blobs/editor-backups']);
|
|
62
|
-
/** Routes agents call without a pin: an agent's tree may call them as it did (the other peers are still refused).
|
|
63
|
-
|
|
72
|
+
/** Routes agents call without a pin: an agent's tree may call them as it did (the other peers are still refused).
|
|
73
|
+
* `/api/maritaca/opencode/v1/chat/completions` is OpenCode's own request for a Sabiá model (lib/maritaca/opencode-proxy.js,
|
|
74
|
+
* the base URL of the provider block SynaBun writes): OpenCode's serve is an agent's tree and sends no pin, and the
|
|
75
|
+
* route itself takes only a caller that presents the saved Maritaca key. That one path only, nothing else of /api/maritaca. */
|
|
76
|
+
export const AGENT_OPEN_PREFIXES = Object.freeze(['/api/server/', '/api/browser/release', '/api/loop', '/api/schedules', '/api/schedule-groups', '/api/maritaca/opencode/v1/chat/completions']);
|
|
64
77
|
/** The peers whose own calls (pinned, or on an agent-open route) keep their route's rules: an AI agent's process tree,
|
|
65
78
|
* and SynaBun's own MCP server over HTTP (lib/peer-identity.js isSynabunMcpServer), as the stdio one in an agent's tree. */
|
|
66
79
|
export const AGENT_CALL_KINDS = Object.freeze(['agent', 'synabun-mcp']);
|
|
@@ -73,8 +86,14 @@ export const AGENT_CALL_KINDS = Object.freeze(['agent', 'synabun-mcp']);
|
|
|
73
86
|
* it can reach SynaBun at all, and the CLI and the MCP tools read some of them). The hooks' own routes are not here.
|
|
74
87
|
*/
|
|
75
88
|
export const OWNER_READ_PREFIXES = Object.freeze([...ADMIN_ONLY_PREFIXES.filter((prefix) => prefix !== '/api/hook-'), '/api/git']);
|
|
89
|
+
/**
|
|
90
|
+
* The writes a failed lookup does not refuse (the rules from before): the server's restart and stop. They take nothing
|
|
91
|
+
* from the request, an agent's tree may call them anyway, and the desktop app's quit, the uninstaller and the in-app
|
|
92
|
+
* Restart (the way out of a degraded server: SYNABUN_PEER_IDENTITY=off, then a restart) depend on them. Whole paths.
|
|
93
|
+
*/
|
|
94
|
+
export const DEGRADED_OPEN_PATHS = Object.freeze(['/api/server/restart', '/api/server/shutdown']);
|
|
76
95
|
/** The owner's sockets: a terminal, the agent panels, the Assistant, the browser panel. */
|
|
77
|
-
export const OWNER_SOCKET_PREFIXES = Object.freeze(['/ws/terminal/', '/ws/claude-skin', '/ws/codex-skin', '/ws/opencode-v2', '/ws/antigravity', '/ws/assistant/', '/ws/browser/']);
|
|
96
|
+
export const OWNER_SOCKET_PREFIXES = Object.freeze(['/ws/terminal/', '/ws/claude-skin', '/ws/codex-skin', '/ws/opencode-v2', '/ws/antigravity', '/ws/maritaca', '/ws/assistant/', '/ws/browser/']);
|
|
78
97
|
/** Sockets that stay open for the app's pages to draw, read-only for a peer the owner's powers are refused to. */
|
|
79
98
|
export const READ_ONLY_SOCKET_PATHS = Object.freeze(['/ws/sync']);
|
|
80
99
|
|
|
@@ -129,6 +148,29 @@ export function proxyRefusalText(req, refuse) {
|
|
|
129
148
|
return template.replace(/\{(\w+)\}/g, (whole, key) => (params[key] != null ? params[key] : whole));
|
|
130
149
|
}
|
|
131
150
|
|
|
151
|
+
// ── A lookup that failed (macOS): 503 PEER_UNAVAILABLE ───────────────────────
|
|
152
|
+
|
|
153
|
+
/** The code of every answer to a request whose peer could not be identified (lib/peer-identity.js, macOS). */
|
|
154
|
+
export const PEER_UNAVAILABLE = 'PEER_UNAVAILABLE';
|
|
155
|
+
/** Retry-After for it: soon after a timeout or a busy moment, later for a lookup that cannot run at all. */
|
|
156
|
+
export function retryAfterSeconds(down) { return down?.retryable === true ? 2 : 30; }
|
|
157
|
+
/** Why SynaBun did not act as the owner, and what to do (`ownerAuthority.peerUnavailable`), in the request's language. */
|
|
158
|
+
export function peerUnavailableText(req, down) {
|
|
159
|
+
const template = ownerCopy(requestLocale(req)).peerUnavailable;
|
|
160
|
+
const params = { reason: String(down?.reason || 'the lookup failed').slice(0, 160) };
|
|
161
|
+
if (typeof template !== 'string' || !template) return `SynaBun could not check which program sent this (${params.reason}), so it refused to act as the owner. Reload the page to try again.`;
|
|
162
|
+
return template.replace(/\{(\w+)\}/g, (whole, key) => (params[key] != null ? params[key] : whole));
|
|
163
|
+
}
|
|
164
|
+
/** The answer's body: { ok: false, code: 'PEER_UNAVAILABLE', error, retryable, reason }. */
|
|
165
|
+
export function peerUnavailableBody(req, down) {
|
|
166
|
+
return { ok: false, code: PEER_UNAVAILABLE, error: peerUnavailableText(req, down), retryable: down?.retryable === true, reason: String(down?.reason || 'the lookup failed') };
|
|
167
|
+
}
|
|
168
|
+
/** Answer 503 PEER_UNAVAILABLE (never cached, Retry-After). Used by the owner gate, the page secret and the Assistant API. */
|
|
169
|
+
export function sendPeerUnavailable(res, req, down) {
|
|
170
|
+
try { res.setHeader?.('Retry-After', String(retryAfterSeconds(down))); res.setHeader?.('Cache-Control', 'no-store'); } catch { /* headers already sent */ }
|
|
171
|
+
return res.status(503).json(peerUnavailableBody(req, down));
|
|
172
|
+
}
|
|
173
|
+
|
|
132
174
|
/** Does a request say it is an agent's own call (a pin, or a brain credential that survived the peer check)? */
|
|
133
175
|
export function isAgentCall(req) {
|
|
134
176
|
const h = req?.headers || {};
|
|
@@ -136,28 +178,34 @@ export function isAgentCall(req) {
|
|
|
136
178
|
}
|
|
137
179
|
|
|
138
180
|
/**
|
|
139
|
-
* Where an HTTP request stands: `gated` (one of the owner's writes, one of the owner's reads, or a secret read),
|
|
181
|
+
* Where an HTTP request stands: `gated` (one of the owner's writes, one of the owner's reads, or a secret read),
|
|
140
182
|
* `agentOpen` (an agent's tree may call it without a pin: every owner's read but the secret ones, and the
|
|
141
|
-
* AGENT_OPEN_PREFIXES writes)
|
|
183
|
+
* AGENT_OPEN_PREFIXES writes) and `degradedOpen` (a failed lookup does not refuse it: DEGRADED_OPEN_PATHS, every
|
|
184
|
+
* reading of the path one of them). A path with no safe reading is gated.
|
|
142
185
|
*/
|
|
143
186
|
export function restScope(req) {
|
|
144
187
|
const method = String(req?.method || 'GET').toUpperCase();
|
|
145
188
|
const forms = routedForms(String(req?.path ?? req?.url ?? ''));
|
|
146
|
-
if (!forms) return { gated: !SAFE_METHODS.has(method), agentOpen: false, reason: 'no safe reading of the path' };
|
|
189
|
+
if (!forms) return { gated: !SAFE_METHODS.has(method), agentOpen: false, degradedOpen: false, reason: 'no safe reading of the path' };
|
|
147
190
|
if (SAFE_METHODS.has(method)) {
|
|
148
|
-
if (method === 'OPTIONS') return { gated: false, agentOpen: false };
|
|
191
|
+
if (method === 'OPTIONS') return { gated: false, agentOpen: false, degradedOpen: false };
|
|
149
192
|
const reveal = String(req?.query?.reveal || '') === '1';
|
|
150
193
|
if (forms.some((form) => form === '/api/mcp-key' || (reveal && form.startsWith('/api/mcp/env/')))) {
|
|
151
|
-
return { gated: true, agentOpen: false, reason: 'a read that hands out a secret' };
|
|
194
|
+
return { gated: true, agentOpen: false, degradedOpen: false, reason: 'a read that hands out a secret' };
|
|
152
195
|
}
|
|
153
196
|
// (ADMIN_ONLY_PREFIXES are plain prefixes, as lib/request-gate.js reads them)
|
|
154
197
|
const ownerRead = forms.some((form) => OWNER_READ_PREFIXES.some((prefix) => form.startsWith(prefix)));
|
|
155
|
-
return { gated: ownerRead, agentOpen: true, reason: ownerRead ? 'one of the owner\'s reads' : null };
|
|
198
|
+
return { gated: ownerRead, agentOpen: true, degradedOpen: false, reason: ownerRead ? 'one of the owner\'s reads' : null };
|
|
156
199
|
}
|
|
157
|
-
if (!forms.some((form) => under(form, '/api'))) return { gated: false, agentOpen: false };
|
|
200
|
+
if (!forms.some((form) => under(form, '/api'))) return { gated: false, agentOpen: false, degradedOpen: false };
|
|
158
201
|
const open = (form) => FEATURE_OPEN_PREFIXES.some((prefix) => under(form, prefix)) && !NEVER_OPEN_PREFIXES.some((prefix) => under(form, prefix));
|
|
159
|
-
if (forms.every(open)) return { gated: false, agentOpen: false };
|
|
160
|
-
return {
|
|
202
|
+
if (forms.every(open)) return { gated: false, agentOpen: false, degradedOpen: false };
|
|
203
|
+
return {
|
|
204
|
+
gated: true,
|
|
205
|
+
agentOpen: forms.every((form) => AGENT_OPEN_PREFIXES.some((prefix) => under(form, prefix))),
|
|
206
|
+
degradedOpen: forms.every((form) => DEGRADED_OPEN_PATHS.includes(form)),
|
|
207
|
+
reason: 'one of the owner\'s writes',
|
|
208
|
+
};
|
|
161
209
|
}
|
|
162
210
|
|
|
163
211
|
/** Where a socket stands: `owner` (refused to the peers below) or `readOnly` (open, read-only for them). */
|
|
@@ -169,37 +217,63 @@ export function socketScope(pathname) {
|
|
|
169
217
|
}
|
|
170
218
|
|
|
171
219
|
/**
|
|
172
|
-
* The decision for one request whose peer verdict is on it (or not: then only the marker counts).
|
|
220
|
+
* The decision for one request whose peer verdict is on it (or not: then only the marker counts, unless `required`).
|
|
173
221
|
* @param {object} req
|
|
174
|
-
* @param {{ agentOpen?: boolean, fromWorkerBrowser?: (req) => boolean }} o
|
|
175
|
-
*
|
|
176
|
-
*
|
|
222
|
+
* @param {{ agentOpen?: boolean, degradedOpen?: boolean, required?: boolean, fromWorkerBrowser?: (req) => boolean, automationBrowserAllowed?: boolean }} o
|
|
223
|
+
* `required`: the lookup runs on this server (macOS, not off), so a covered request without a verdict was never
|
|
224
|
+
* identified and is taken as a failed lookup; `degradedOpen`: a failed lookup leaves this one to the rules from before;
|
|
225
|
+
* `automationBrowserAllowed`: the owner's setting is on, so the automation browser (marker or peer) is not refused
|
|
226
|
+
* @returns {{ status: 403|503, code: string, error: string, hint?: string, peer?: object, retryable?: boolean, reason?: string } | null}
|
|
227
|
+
* `hint: 'proxy'` (with the relay's kind, pid and name) when the peer carries requests for others: `error` then says
|
|
228
|
+
* what to do, in the request's language; status 503 with code PEER_UNAVAILABLE when the peer could not be identified
|
|
177
229
|
*/
|
|
178
|
-
export function ownerRefusal(req, { agentOpen = false, fromWorkerBrowser = () => false } = {}) {
|
|
230
|
+
export function ownerRefusal(req, { agentOpen = false, degradedOpen = false, required = false, fromWorkerBrowser = () => false, automationBrowserAllowed = false } = {}) {
|
|
231
|
+
// The owner's setting "Let the automation browser act as owner" (lib/automation-browser-owner-access.js): while
|
|
232
|
+
// on, that browser's marker and its peer kind are not refusals. Nothing else is granted by it.
|
|
233
|
+
const granted = automationBrowserAllowed === true;
|
|
179
234
|
let marked = false;
|
|
180
235
|
try { marked = !!fromWorkerBrowser(req); } catch { marked = false; }
|
|
181
|
-
if (marked) return { code: 'WORKER_BROWSER', error: 'SynaBun\'s automation browser cannot act as the owner: it reads SynaBun\'s pages, clicks and screenshots; the owner\'s own settings, files and actions are the owner\'s, from the owner\'s browser or the app.' };
|
|
182
|
-
const
|
|
183
|
-
|
|
184
|
-
if (
|
|
185
|
-
if (
|
|
186
|
-
if (
|
|
187
|
-
|
|
188
|
-
return { code:
|
|
236
|
+
if (marked && !granted) return { status: 403, code: 'WORKER_BROWSER', error: 'SynaBun\'s automation browser cannot act as the owner: it reads SynaBun\'s pages, clicks and screenshots; the owner\'s own settings, files and actions are the owner\'s, from the owner\'s browser or the app.' };
|
|
237
|
+
const verdict = req?.[PEER_VERDICT];
|
|
238
|
+
const auth = verdict == null && required ? peerAuthority(failedPeerVerdict('the request was not identified')) : peerAuthority(verdict);
|
|
239
|
+
if (auth.decision === 'before' || auth.decision === 'allowed') return null;
|
|
240
|
+
if (granted && auth.decision === 'refused' && auth.kind === 'automation-browser') return null;
|
|
241
|
+
if (auth.decision === 'unavailable') {
|
|
242
|
+
if (degradedOpen) return null; // the server's restart and stop: the rules from before (DEGRADED_OPEN_PATHS)
|
|
243
|
+
return { status: 503, code: PEER_UNAVAILABLE, error: peerUnavailableText(req, auth), retryable: auth.retryable, reason: auth.reason };
|
|
244
|
+
}
|
|
245
|
+
if (auth.gone) return { status: 403, code: 'PEER_REFUSED', error: `This is the owner's, and ${auth.why}.` };
|
|
246
|
+
if (AGENT_CALL_KINDS.includes(auth.kind) && (agentOpen || isAgentCall(req))) return null; // an agent's own call: its route's rules
|
|
247
|
+
if (PROXY_REFUSAL_KINDS.includes(auth.kind)) {
|
|
248
|
+
return { status: 403, code: 'PEER_REFUSED', error: proxyRefusalText(req, auth), hint: 'proxy', peer: { kind: auth.kind, pid: auth.pid, name: auth.name } };
|
|
189
249
|
}
|
|
190
|
-
return { code: 'PEER_REFUSED', error: `This is the owner's, from the owner's own browser or the app; this request comes from ${
|
|
250
|
+
return { status: 403, code: 'PEER_REFUSED', error: `This is the owner's, from the owner's own browser or the app; this request comes from ${auth.why}: pid ${auth.pid} (${auth.name}).` };
|
|
191
251
|
}
|
|
192
252
|
|
|
193
253
|
/**
|
|
194
254
|
* @param {object} o
|
|
195
255
|
* @param {() => ({ fromWorkerBrowser(req): boolean } | null)} [o.pageSession] the page session (read at request time)
|
|
196
256
|
* @param {(req) => boolean} [o.isRemote] a request from outside (the tunnel, the invite proxy): the guest rules decide
|
|
197
|
-
* @param {{ lookup(req): Promise<object
|
|
257
|
+
* @param {{ lookup(req): Promise<object>, supported?: boolean }} [o.peer] lib/peer-identity.js (for sockets: no
|
|
258
|
+
* middleware runs for them). `supported` (macOS, not off): a covered request without a verdict, or a socket whose
|
|
259
|
+
* lookup threw, is a failed lookup (503), never the rules from before.
|
|
198
260
|
* @param {(line: string) => void} [o.log]
|
|
261
|
+
* @param {() => boolean} [o.automationBrowserAllowed] the owner's setting (lib/automation-browser-owner-access.js);
|
|
262
|
+
* left out, the page session's `automationBrowserGranted()` is asked, so both read the one value
|
|
199
263
|
*/
|
|
200
|
-
export function createOwnerAuthority({ pageSession = () => null, isRemote = () => false, peer = null, log = () => {} } = {}) {
|
|
264
|
+
export function createOwnerAuthority({ pageSession = () => null, isRemote = () => false, peer = null, log = () => {}, automationBrowserAllowed = null } = {}) {
|
|
201
265
|
const fromWorkerBrowser = (req) => { const s = pageSession(); return typeof s?.fromWorkerBrowser === 'function' ? s.fromWorkerBrowser(req) : false; };
|
|
266
|
+
/** The owner's setting, read at request time: given here, else the page session's own reading; never on a failure. */
|
|
267
|
+
const granted = () => {
|
|
268
|
+
try {
|
|
269
|
+
if (typeof automationBrowserAllowed === 'function') return automationBrowserAllowed() === true;
|
|
270
|
+
const s = pageSession();
|
|
271
|
+
return typeof s?.automationBrowserGranted === 'function' && s.automationBrowserGranted() === true;
|
|
272
|
+
} catch { return false; }
|
|
273
|
+
};
|
|
202
274
|
const remote = (req) => { try { return isRemote(req) === true; } catch { return false; } };
|
|
275
|
+
/** The lookup runs here (macOS, not off): no verdict is no proof. */
|
|
276
|
+
const required = peer?.supported === true;
|
|
203
277
|
const logged = new Map();
|
|
204
278
|
const note = (key, line) => {
|
|
205
279
|
const now = Date.now();
|
|
@@ -216,34 +290,54 @@ export function createOwnerAuthority({ pageSession = () => null, isRemote = () =
|
|
|
216
290
|
}
|
|
217
291
|
|
|
218
292
|
/** Express middleware, mounted after the peer middleware: 403 for a refused request to one of the owner's routes
|
|
219
|
-
* (its writes, its reads, a secret read)
|
|
293
|
+
* (its writes, its reads, a secret read), 503 PEER_UNAVAILABLE (with Retry-After) for one whose peer could not be
|
|
294
|
+
* identified on macOS. */
|
|
220
295
|
function restGate(req, res, next) {
|
|
221
296
|
let scope;
|
|
222
|
-
try { scope = restScope(req); } catch { scope = { gated: true, agentOpen: false }; }
|
|
297
|
+
try { scope = restScope(req); } catch { scope = { gated: true, agentOpen: false, degradedOpen: false }; }
|
|
223
298
|
if (!scope.gated || remote(req)) return next();
|
|
224
|
-
const refused = ownerRefusal(req, { agentOpen: scope.agentOpen, fromWorkerBrowser });
|
|
299
|
+
const refused = ownerRefusal(req, { agentOpen: scope.agentOpen, degradedOpen: scope.degradedOpen, required, fromWorkerBrowser, automationBrowserAllowed: granted() });
|
|
225
300
|
if (!refused) return next();
|
|
226
|
-
note(`${refused.code}:${req[PEER_VERDICT]?.pid || 'marker'}:${String(req.path).slice(0, 80)}`, `[owner-authority] refused ${req.method} ${String(req.path).slice(0, 120)}: ${refused.hint === 'proxy' ? `${req[PEER_VERDICT]?.refuse?.why}: pid ${refused.peer?.pid} (${refused.peer?.name})` : refused.error}`);
|
|
301
|
+
note(`${refused.code}:${req[PEER_VERDICT]?.pid || (refused.code === PEER_UNAVAILABLE ? refused.reason : 'marker')}:${String(req.path).slice(0, 80)}`, `[owner-authority] ${refused.code === PEER_UNAVAILABLE ? 'unavailable (503)' : 'refused'} ${req.method} ${String(req.path).slice(0, 120)}: ${refused.hint === 'proxy' ? `${req[PEER_VERDICT]?.refuse?.why}: pid ${refused.peer?.pid} (${refused.peer?.name})` : refused.code === PEER_UNAVAILABLE ? `the caller could not be identified (${refused.reason})` : refused.error}`);
|
|
302
|
+
if (refused.code === PEER_UNAVAILABLE) return sendPeerUnavailable(res, req, refused);
|
|
227
303
|
if (refused.hint) return res.status(403).json({ ok: false, code: refused.code, error: refused.error, hint: refused.hint, peer: refused.peer });
|
|
228
304
|
return sendGuardError(res, 403, refused.code, refused.error);
|
|
229
305
|
}
|
|
230
306
|
|
|
231
307
|
/**
|
|
232
308
|
* The decision for a WebSocket upgrade (no middleware runs for one): looks the peer up for an owner socket and for
|
|
233
|
-
* /ws/sync. → { refuse: boolean, readOnly: boolean, code?, error? }. Never rejects
|
|
234
|
-
*
|
|
309
|
+
* /ws/sync. → { refuse: boolean, readOnly: boolean, status?: 403|503, code?, error?, retryable? }. Never rejects. A
|
|
310
|
+
* peer that could not be identified on macOS gets no owner socket (status 503) and a read-only /ws/sync; where the
|
|
311
|
+
* lookup does not run, nothing is refused for it.
|
|
235
312
|
*/
|
|
236
313
|
async function checkUpgrade(req, pathname) {
|
|
237
314
|
const scope = socketScope(pathname);
|
|
238
315
|
if ((!scope.owner && !scope.readOnly) || remote(req)) return { refuse: false, readOnly: false };
|
|
239
316
|
if (peer && typeof peer.lookup === 'function' && !req[PEER_VERDICT]) {
|
|
240
|
-
try { req[PEER_VERDICT] = await peer.lookup(req); } catch {
|
|
317
|
+
try { req[PEER_VERDICT] = await peer.lookup(req); } catch (error) {
|
|
318
|
+
// A lookup that threw is a lookup that failed where it runs; elsewhere the rules from before.
|
|
319
|
+
if (required) req[PEER_VERDICT] = failedPeerVerdict(`the lookup failed (${error?.message || error})`);
|
|
320
|
+
}
|
|
241
321
|
}
|
|
242
|
-
const refused = ownerRefusal(req, { agentOpen: false, fromWorkerBrowser });
|
|
322
|
+
const refused = ownerRefusal(req, { agentOpen: false, required, fromWorkerBrowser, automationBrowserAllowed: granted() });
|
|
243
323
|
if (!refused) return { refuse: false, readOnly: false };
|
|
244
|
-
note(`ws:${refused.code}:${req[PEER_VERDICT]?.pid || 'marker'}:${pathname}`, `[owner-authority] ${scope.owner ? 'refused' : 'read-only'} socket ${pathname}: ${refused.error}`);
|
|
324
|
+
note(`ws:${refused.code}:${req[PEER_VERDICT]?.pid || 'marker'}:${pathname}`, `[owner-authority] ${scope.owner ? (refused.code === PEER_UNAVAILABLE ? 'unavailable (503)' : 'refused') : 'read-only'} socket ${pathname}: ${refused.code === PEER_UNAVAILABLE ? `the caller could not be identified (${refused.reason})` : refused.error}`);
|
|
325
|
+
return scope.owner ? { refuse: true, readOnly: false, ...refused } : { refuse: false, readOnly: true, ...refused };
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
/**
|
|
329
|
+
* The decision for an upgrade whose check itself broke (checkUpgrade never rejects; this is the guard for what it
|
|
330
|
+
* cannot foresee, server.js's rejection path): where the lookup runs, as for a failed lookup (an owner socket refused
|
|
331
|
+
* with 503, /ws/sync read-only); elsewhere, and for a request from outside, the rules from before.
|
|
332
|
+
*/
|
|
333
|
+
function upgradeFailed(req, pathname, error) {
|
|
334
|
+
const scope = socketScope(pathname);
|
|
335
|
+
if (!required || (!scope.owner && !scope.readOnly) || remote(req)) return { refuse: false, readOnly: false };
|
|
336
|
+
const reason = `the socket's check failed (${error?.message || error || 'no reason'})`;
|
|
337
|
+
note(`ws-failed:${pathname}`, `[owner-authority] ${scope.owner ? 'unavailable (503)' : 'read-only'} socket ${pathname}: ${reason}`);
|
|
338
|
+
const refused = { status: 503, code: PEER_UNAVAILABLE, error: peerUnavailableText(req, { reason }), retryable: false, reason };
|
|
245
339
|
return scope.owner ? { refuse: true, readOnly: false, ...refused } : { refuse: false, readOnly: true, ...refused };
|
|
246
340
|
}
|
|
247
341
|
|
|
248
|
-
return { needsLookup, restGate, checkUpgrade, restScope, socketScope };
|
|
342
|
+
return { needsLookup, restGate, checkUpgrade, upgradeFailed, restScope, socketScope };
|
|
249
343
|
}
|
|
@@ -40,12 +40,19 @@
|
|
|
40
40
|
// used asks it too: a request from SynaBun's automation browser, a browser started for automation, an agent's
|
|
41
41
|
// process tree or a relay is never handed the secret (the pages, GET /api/page-session, a Studio read's attach) and
|
|
42
42
|
// never counts as the owner (verify), whatever host, port, cookie or marker it carries, and a service worker there
|
|
43
|
-
// gets a worker that takes itself away (serviceWorker).
|
|
43
|
+
// gets a worker that takes itself away (serviceWorker). The verdict is read through peerAuthority(), as the owner gate
|
|
44
|
+
// reads it. A lookup that does not run on this server (another platform, SYNABUN_PEER_IDENTITY=off) leaves the rules
|
|
45
|
+
// above. A lookup that failed on macOS (`peer.supported`) is no proof of who is asking: the page still loads, but
|
|
46
|
+
// without the secret, verify is false, GET /api/page-session and require() answer 503 PEER_UNAVAILABLE (never a 403
|
|
47
|
+
// the page would try to cure: public/shared/page-session.js does not retry it), and the service worker is the one
|
|
48
|
+
// that takes itself away. There, a request that hands out or carries the secret without a verdict on it was never
|
|
49
|
+
// identified, and counts as a failed lookup too.
|
|
44
50
|
|
|
45
51
|
import { randomBytes, timingSafeEqual } from 'node:crypto';
|
|
46
52
|
import { isIP } from 'node:net';
|
|
47
53
|
import { parseCookies } from './http-guards.js';
|
|
48
|
-
import { ipv6Groups, mappedIPv4 } from './peer-identity.js';
|
|
54
|
+
import { PEER_VERDICT, failedPeerVerdict, ipv6Groups, mappedIPv4, peerAuthority } from './peer-identity.js';
|
|
55
|
+
import { sendPeerUnavailable } from './owner-authority.js';
|
|
49
56
|
import { setBrowserNetworkRule, localMarkerPatterns } from './browser-network-guard.js';
|
|
50
57
|
|
|
51
58
|
/** The cookie's name without a port (tests, hosts that pass none); with one it is pageSecretCookieName(port). */
|
|
@@ -153,18 +160,70 @@ self.addEventListener('activate', (event) => { event.waitUntil(self.registration
|
|
|
153
160
|
|
|
154
161
|
/**
|
|
155
162
|
* @param {object} [o]
|
|
156
|
-
* @param {{ refusal(req): string|null }} [o.peer] lib/peer-identity.js
|
|
157
|
-
*
|
|
163
|
+
* @param {{ supported?: boolean, refusal?(req): string|null }} [o.peer] lib/peer-identity.js. Its verdict on the
|
|
164
|
+
* request (req[PEER_VERDICT], read through peerAuthority) decides; `supported` (macOS, not off) makes a missing
|
|
165
|
+
* verdict on a request that hands out or carries the secret a failed lookup. A stand-in without verdicts may answer
|
|
166
|
+
* `refusal(req)` (a sentence: refused).
|
|
167
|
+
* @param {() => boolean} [o.automationBrowserAllowed] the owner's setting (lib/automation-browser-owner-access.js
|
|
168
|
+
* `enabled`): while true, the automation browser (its marker or its peer) is handed the secret and verifies as the
|
|
169
|
+
* owner; the service worker rule and every other refusal stay.
|
|
158
170
|
*/
|
|
159
|
-
export function createPageSession({ secret = null, cookieName = null, port = null, secure = false, isGuest = null, peer = null, networkRule = setBrowserNetworkRule } = {}) {
|
|
171
|
+
export function createPageSession({ secret = null, cookieName = null, port = null, secure = false, isGuest = null, peer = null, networkRule = setBrowserNetworkRule, automationBrowserAllowed = null } = {}) {
|
|
160
172
|
const value = typeof secret === 'string' && secret.length >= 32 ? secret : randomBytes(32).toString('hex');
|
|
161
173
|
const expected = Buffer.from(value);
|
|
162
174
|
const name = typeof cookieName === 'string' && cookieName ? cookieName : pageSecretCookieName(port);
|
|
163
175
|
const guest = (req) => { try { return typeof isGuest === 'function' && isGuest(req) === true; } catch { return true; } };
|
|
164
|
-
/**
|
|
165
|
-
|
|
176
|
+
/**
|
|
177
|
+
* The owner's setting "Let the automation browser act as owner" (lib/automation-browser-owner-access.js), read on
|
|
178
|
+
* every request: while on, the automation browser (its marker, or its peer process) is handed the secret and
|
|
179
|
+
* verifies as the owner. Off, missing or failing: the rules above, exactly. Never a grant for any other refusal.
|
|
180
|
+
*/
|
|
181
|
+
const allowed = () => { try { return typeof automationBrowserAllowed === 'function' && automationBrowserAllowed() === true; } catch { return false; } };
|
|
182
|
+
/** The lookup runs on this server (macOS, not off): where the secret is at stake, no verdict is no proof. */
|
|
183
|
+
const peerRequired = () => { try { return peer?.supported === true; } catch { return true; } };
|
|
184
|
+
/**
|
|
185
|
+
* What the peer lookup says of this request (peerAuthority's decision: before / allowed / refused / unavailable).
|
|
186
|
+
* `secretAtStake`: the request is handed the secret or carries it, so on a server whose lookup runs a missing verdict
|
|
187
|
+
* is a failed lookup. Never throws: on a server whose lookup runs a failure here is a failed lookup too.
|
|
188
|
+
*/
|
|
189
|
+
function peerDecision(req, { secretAtStake = false, grant = true } = {}) {
|
|
190
|
+
if (!peer) return { decision: 'before' };
|
|
191
|
+
let auth;
|
|
192
|
+
try {
|
|
193
|
+
const verdict = req?.[PEER_VERDICT];
|
|
194
|
+
if (verdict != null) auth = peerAuthority(verdict);
|
|
195
|
+
else if (typeof peer.refusal === 'function' && peer.refusal(req)) auth = { decision: 'refused', code: 'PEER_REFUSED', why: String(peer.refusal(req)), pid: null };
|
|
196
|
+
else auth = secretAtStake && peerRequired() ? peerAuthority(failedPeerVerdict('the request was not identified')) : { decision: 'before' };
|
|
197
|
+
} catch (error) {
|
|
198
|
+
auth = peerRequired() ? peerAuthority(failedPeerVerdict(`the lookup failed (${error?.message || error})`)) : { decision: 'before' };
|
|
199
|
+
}
|
|
200
|
+
// The one grant: the automation browser, by its process, while the owner's setting is on (never a peer refused
|
|
201
|
+
// for any other reason, never a failed lookup). `grant: false` asks the rules without it (the service worker).
|
|
202
|
+
if (grant && auth.decision === 'refused' && auth.kind === 'automation-browser' && allowed()) return { decision: 'allowed', granted: 'automation-browser' };
|
|
203
|
+
return auth;
|
|
204
|
+
}
|
|
205
|
+
/** The automation browser's marker counts unless the owner's setting lets that browser act as the owner. */
|
|
206
|
+
const markerHolds = (req, { grant = true } = {}) => hasWorkerMarker(req) && !(grant && allowed());
|
|
207
|
+
const refusedText = (auth) => (auth.gone || auth.pid == null ? auth.why : `${auth.why}: pid ${auth.pid} (${auth.name})`);
|
|
208
|
+
/** Why the peer lookup refuses this request the secret (a sentence), or null (never asked, not looked up here, or
|
|
209
|
+
* allowed). A failed lookup on macOS is a refusal too. */
|
|
210
|
+
const peerRefusal = (req) => {
|
|
211
|
+
const auth = peerDecision(req, { secretAtStake: true });
|
|
212
|
+
if (auth.decision === 'refused') return refusedText(auth);
|
|
213
|
+
if (auth.decision === 'unavailable') return `a request SynaBun could not identify (${auth.reason})`;
|
|
214
|
+
return null;
|
|
215
|
+
};
|
|
216
|
+
/** The request's peer could not be identified on macOS: { code: 'PEER_UNAVAILABLE', retryable, reason }, or null. */
|
|
217
|
+
const peerUnavailable = (req) => {
|
|
218
|
+
const auth = peerDecision(req, { secretAtStake: carriesSecret(req) });
|
|
219
|
+
return auth.decision === 'unavailable' ? auth : null;
|
|
220
|
+
};
|
|
166
221
|
/** A request that may neither be handed the secret nor use it: a marker of the automation browser, or its peer. */
|
|
167
|
-
const heldBack = (req
|
|
222
|
+
const heldBack = (req, { grant = true } = {}) => {
|
|
223
|
+
if (markerHolds(req, { grant })) return true;
|
|
224
|
+
const decision = peerDecision(req, { secretAtStake: true, grant }).decision;
|
|
225
|
+
return decision === 'refused' || decision === 'unavailable';
|
|
226
|
+
};
|
|
168
227
|
|
|
169
228
|
/** The Set-Cookie header value (HttpOnly, SameSite=Strict, the whole site). */
|
|
170
229
|
function cookie() {
|
|
@@ -172,12 +231,13 @@ export function createPageSession({ secret = null, cookieName = null, port = nul
|
|
|
172
231
|
}
|
|
173
232
|
/**
|
|
174
233
|
* Add the cookie to a response (once; a header already there is kept and this one appended). Never to a guest, a
|
|
175
|
-
* request with the automation browser's marker or one whose peer is refused: `req` is the
|
|
176
|
-
* (Express's res.req) unless given, so every caller that hands the page the secret asks the
|
|
234
|
+
* request with the automation browser's marker or one whose peer is refused or could not be identified: `req` is the
|
|
235
|
+
* response's own request (Express's res.req) unless given, so every caller that hands the page the secret asks the
|
|
236
|
+
* same questions (and with no request to ask, a server whose lookup runs hands out nothing).
|
|
177
237
|
*/
|
|
178
238
|
function attach(res, req = res?.req) {
|
|
179
239
|
if (!res || typeof res.getHeader !== 'function' || typeof res.setHeader !== 'function') return;
|
|
180
|
-
if (req
|
|
240
|
+
if (req ? (heldBack(req) || guest(req)) : peerRequired()) return;
|
|
181
241
|
const current = res.getHeader('Set-Cookie');
|
|
182
242
|
const list = current === undefined ? [] : Array.isArray(current) ? [...current] : [String(current)];
|
|
183
243
|
if (list.some((line) => String(line).startsWith(`${name}=`))) return;
|
|
@@ -191,15 +251,27 @@ export function createPageSession({ secret = null, cookieName = null, port = nul
|
|
|
191
251
|
return !!got && got.length === expected.length && timingSafeEqual(got, expected);
|
|
192
252
|
}
|
|
193
253
|
/** Whether a request carries this boot's secret, and neither the automation browser's marker (cookie or header)
|
|
194
|
-
* nor a peer the lookup refuses. */
|
|
254
|
+
* nor a peer the lookup refuses or (on macOS) could not identify. */
|
|
195
255
|
function verify(req) {
|
|
196
|
-
if (
|
|
197
|
-
return
|
|
256
|
+
if (!carriesSecret(req)) return false;
|
|
257
|
+
return !heldBack(req);
|
|
198
258
|
}
|
|
199
|
-
/** Whether a request comes from a tab of SynaBun's automation browser (the marker cookie or the host-proof header)
|
|
259
|
+
/** Whether a request comes from a tab of SynaBun's automation browser (the marker cookie or the host-proof header),
|
|
260
|
+
* whatever the owner's setting says (the owner gate asks the setting itself). */
|
|
200
261
|
function fromWorkerBrowser(req) {
|
|
201
262
|
return hasWorkerMarker(req);
|
|
202
263
|
}
|
|
264
|
+
/**
|
|
265
|
+
* Whether a request is the automation browser's by any sign: its marker, or a peer verdict that names a browser
|
|
266
|
+
* started for automation. Never changed by the owner's setting: this is what refuses that browser the change of
|
|
267
|
+
* the setting itself (PUT /api/assistant/automation-browser-owner-access), on or off.
|
|
268
|
+
*/
|
|
269
|
+
function isAutomationBrowser(req) {
|
|
270
|
+
if (hasWorkerMarker(req)) return true;
|
|
271
|
+
try { return peerAuthority(req?.[PEER_VERDICT]).kind === 'automation-browser'; } catch { return false; }
|
|
272
|
+
}
|
|
273
|
+
/** Whether the owner's setting lets the automation browser act as the owner right now. */
|
|
274
|
+
function automationBrowserGranted() { return allowed(); }
|
|
203
275
|
/**
|
|
204
276
|
* Mark a Playwright browser context as SynaBun's automation browser. Two markers, both HttpOnly / network-level so
|
|
205
277
|
* no page script reads or drops them, and never throws:
|
|
@@ -230,14 +302,23 @@ export function createPageSession({ secret = null, cookieName = null, port = nul
|
|
|
230
302
|
return false;
|
|
231
303
|
}
|
|
232
304
|
}
|
|
233
|
-
/**
|
|
305
|
+
/** Answer 503 PEER_UNAVAILABLE for a request whose peer could not be identified (peerUnavailable(req)). */
|
|
306
|
+
function sendUnavailable(res, req, down = peerUnavailable(req)) {
|
|
307
|
+
return sendPeerUnavailable(res, req, down || { retryable: false, reason: 'the request was not identified' });
|
|
308
|
+
}
|
|
309
|
+
/** Express middleware for an owner write: 403 PAGE_SECRET_REQUIRED without the secret; 503 PEER_UNAVAILABLE when the
|
|
310
|
+
* request's peer could not be identified on macOS (the secret could not be handed out or taken: a reload, not a
|
|
311
|
+
* refresh, is what may cure it). */
|
|
234
312
|
function require(req, res, next) {
|
|
235
313
|
if (verify(req)) return next();
|
|
314
|
+
const down = peerUnavailable(req);
|
|
315
|
+
if (down) return sendUnavailable(res, req, down);
|
|
236
316
|
res.status(403).json({ ok: false, code: 'PAGE_SECRET_REQUIRED', error: 'This change is made from SynaBun\'s own page. Reload the page and try again.' });
|
|
237
317
|
}
|
|
238
318
|
/** Express middleware that sets the cookie on the pages it belongs to (GET only, the app's shells; never a guest's
|
|
239
|
-
* and never a request that carries the automation-browser marker or whose peer is refused
|
|
240
|
-
* automation browser, an agent
|
|
319
|
+
* and never a request that carries the automation-browser marker or whose peer is refused or could not be
|
|
320
|
+
* identified — a marked tab, an automation browser, an agent, a relay or an unknown caller must never be handed the
|
|
321
|
+
* secret). The page itself still loads. */
|
|
241
322
|
function pages(req, res, next) {
|
|
242
323
|
if ((req.method === 'GET' || req.method === 'HEAD') && PAGE_SECRET_PATHS.includes(req.path) && !guest(req) && !heldBack(req)) attach(res, req);
|
|
243
324
|
next();
|
|
@@ -247,29 +328,32 @@ export function createPageSession({ secret = null, cookieName = null, port = nul
|
|
|
247
328
|
* after a restart). Answers { ok: true } with the cookie; a guest gets 403 and no cookie. A tab of SynaBun's
|
|
248
329
|
* automation browser (the marker cookie or the host-proof header) is refused the secret too (403 WORKER_BROWSER),
|
|
249
330
|
* as is a request whose peer process the lookup refuses (403 PEER_REFUSED: an automation browser, an agent's
|
|
250
|
-
* process tree, a relay).
|
|
331
|
+
* process tree, a relay). A request whose peer could not be identified on macOS gets 503 PEER_UNAVAILABLE and no
|
|
332
|
+
* cookie. Never cached.
|
|
251
333
|
*/
|
|
252
334
|
function refresh(req, res) {
|
|
253
335
|
res.setHeader('Cache-Control', 'no-store');
|
|
254
336
|
if (guest(req)) return res.status(403).json({ ok: false, code: 'GUEST_FORBIDDEN', error: 'Available to the owner only.' });
|
|
255
|
-
if (
|
|
256
|
-
const
|
|
257
|
-
if (
|
|
337
|
+
if (markerHolds(req)) return res.status(403).json({ ok: false, code: 'WORKER_BROWSER', error: 'SynaBun\'s automation browser does not hold the owner\'s page secret.' });
|
|
338
|
+
const auth = peerDecision(req, { secretAtStake: true });
|
|
339
|
+
if (auth.decision === 'unavailable') return sendUnavailable(res, req, auth);
|
|
340
|
+
if (auth.decision === 'refused') return res.status(403).json({ ok: false, code: 'PEER_REFUSED', error: `SynaBun hands its page secret to the owner's own browser only; this request comes from ${refusedText(auth)}.` });
|
|
258
341
|
attach(res, req);
|
|
259
342
|
res.json({ ok: true });
|
|
260
343
|
}
|
|
261
344
|
/**
|
|
262
|
-
* Express middleware for GET /sw.js: a browser that may not hold the secret (the automation browser's marker,
|
|
263
|
-
* refused peer) gets SERVICE_WORKER_NOOP, so no service worker answers
|
|
264
|
-
* everyone else falls through to the real public/sw.js.
|
|
345
|
+
* Express middleware for GET /sw.js: a browser that may not hold the secret (the automation browser's marker, a
|
|
346
|
+
* refused peer, or on macOS one that could not be identified) gets SERVICE_WORKER_NOOP, so no service worker answers
|
|
347
|
+
* its requests out of the server's sight; everyone else falls through to the real public/sw.js. The owner's setting
|
|
348
|
+
* that lets the automation browser act as the owner does not reach here: that browser still gets no service worker.
|
|
265
349
|
*/
|
|
266
350
|
function serviceWorker(req, res, next) {
|
|
267
|
-
if ((req.method === 'GET' || req.method === 'HEAD') && req.path === SERVICE_WORKER_PATH && heldBack(req)) {
|
|
351
|
+
if ((req.method === 'GET' || req.method === 'HEAD') && req.path === SERVICE_WORKER_PATH && heldBack(req, { grant: false })) {
|
|
268
352
|
res.setHeader('Cache-Control', 'no-store');
|
|
269
353
|
res.setHeader('Content-Type', 'text/javascript; charset=utf-8');
|
|
270
354
|
return res.end(req.method === 'HEAD' ? undefined : SERVICE_WORKER_NOOP);
|
|
271
355
|
}
|
|
272
356
|
next();
|
|
273
357
|
}
|
|
274
|
-
return { cookieName: name, cookie, attach, carriesSecret, verify, require, pages, refresh, serviceWorker, fromWorkerBrowser, peerRefusal, markWorkerBrowserContext };
|
|
358
|
+
return { cookieName: name, cookie, attach, carriesSecret, verify, require, pages, refresh, serviceWorker, fromWorkerBrowser, isAutomationBrowser, automationBrowserGranted, peerRefusal, peerUnavailable, sendUnavailable, markWorkerBrowserContext };
|
|
275
359
|
}
|