synabun 2.3.0 → 2.4.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 +38 -0
- package/README.md +1 -1
- package/browser-extension/content.js +169 -0
- package/browser-extension/engine.js +477 -0
- package/browser-extension/icons/icon-128.png +0 -0
- package/browser-extension/icons/icon-16.png +0 -0
- package/browser-extension/icons/icon-32.png +0 -0
- package/browser-extension/icons/icon-48.png +0 -0
- package/browser-extension/icons/status-off-16.png +0 -0
- package/browser-extension/icons/status-off-32.png +0 -0
- package/browser-extension/icons/status-off-48.png +0 -0
- package/browser-extension/icons/status-on-16.png +0 -0
- package/browser-extension/icons/status-on-32.png +0 -0
- package/browser-extension/icons/status-on-48.png +0 -0
- package/browser-extension/manifest.json +56 -0
- package/browser-extension/popup-strings.js +244 -0
- package/browser-extension/popup-view.js +151 -0
- package/browser-extension/popup.css +165 -0
- package/browser-extension/popup.html +105 -0
- package/browser-extension/popup.js +347 -0
- package/browser-extension/protocol.js +226 -0
- package/browser-extension/service-worker.js +267 -0
- package/browser-extension/setup-content.js +36 -0
- package/browser-extension/tokens.css +326 -0
- package/docs/browser-extension-bridge.md +84 -0
- package/docs/whatsapp.md +1 -1
- package/mcp-server/dist/http.d.ts +2 -0
- package/mcp-server/dist/http.d.ts.map +1 -1
- package/mcp-server/dist/http.js +9 -1
- package/mcp-server/dist/http.js.map +1 -1
- package/mcp-server/dist/index.d.ts +11 -0
- package/mcp-server/dist/index.d.ts.map +1 -1
- package/mcp-server/dist/index.js +38 -3
- package/mcp-server/dist/index.js.map +1 -1
- package/mcp-server/dist/services/browser-route-flow.d.ts +6 -2
- package/mcp-server/dist/services/browser-route-flow.d.ts.map +1 -1
- package/mcp-server/dist/services/browser-route-flow.js +10 -3
- package/mcp-server/dist/services/browser-route-flow.js.map +1 -1
- package/mcp-server/dist/services/codex-config-heal.d.ts.map +1 -1
- package/mcp-server/dist/services/codex-config-heal.js +7 -0
- package/mcp-server/dist/services/codex-config-heal.js.map +1 -1
- package/mcp-server/dist/services/neural-interface.d.ts +94 -3
- package/mcp-server/dist/services/neural-interface.d.ts.map +1 -1
- package/mcp-server/dist/services/neural-interface.js +168 -23
- package/mcp-server/dist/services/neural-interface.js.map +1 -1
- package/mcp-server/dist/services/team-context.d.ts +18 -0
- package/mcp-server/dist/services/team-context.d.ts.map +1 -0
- package/mcp-server/dist/services/team-context.js +29 -0
- package/mcp-server/dist/services/team-context.js.map +1 -0
- package/mcp-server/dist/services/tool-catalog.d.ts +5 -2
- package/mcp-server/dist/services/tool-catalog.d.ts.map +1 -1
- package/mcp-server/dist/services/tool-catalog.js +22 -6
- package/mcp-server/dist/services/tool-catalog.js.map +1 -1
- package/mcp-server/dist/services/tool-list.d.ts.map +1 -1
- package/mcp-server/dist/services/tool-list.js +4 -0
- package/mcp-server/dist/services/tool-list.js.map +1 -1
- package/mcp-server/dist/services/tool-runtime.d.ts +8 -1
- package/mcp-server/dist/services/tool-runtime.d.ts.map +1 -1
- package/mcp-server/dist/services/tool-runtime.js +18 -1
- package/mcp-server/dist/services/tool-runtime.js.map +1 -1
- package/mcp-server/dist/tools/agent-definition.d.ts +133 -0
- package/mcp-server/dist/tools/agent-definition.d.ts.map +1 -0
- package/mcp-server/dist/tools/agent-definition.js +483 -0
- package/mcp-server/dist/tools/agent-definition.js.map +1 -0
- package/mcp-server/dist/tools/agents.d.ts +91 -9
- package/mcp-server/dist/tools/agents.d.ts.map +1 -1
- package/mcp-server/dist/tools/agents.js +161 -20
- package/mcp-server/dist/tools/agents.js.map +1 -1
- package/mcp-server/dist/tools/browser-advanced.d.ts +8 -1
- package/mcp-server/dist/tools/browser-advanced.d.ts.map +1 -1
- package/mcp-server/dist/tools/browser-advanced.js +70 -6
- package/mcp-server/dist/tools/browser-advanced.js.map +1 -1
- package/mcp-server/dist/tools/git-tools.d.ts +4 -2
- package/mcp-server/dist/tools/git-tools.d.ts.map +1 -1
- package/mcp-server/dist/tools/git-tools.js +283 -2
- package/mcp-server/dist/tools/git-tools.js.map +1 -1
- package/mcp-server/dist/tools/morelogin.d.ts +8 -2
- package/mcp-server/dist/tools/morelogin.d.ts.map +1 -1
- package/mcp-server/dist/tools/morelogin.js +22 -5
- package/mcp-server/dist/tools/morelogin.js.map +1 -1
- package/mcp-server/dist/tools/team.d.ts +32 -0
- package/mcp-server/dist/tools/team.d.ts.map +1 -0
- package/mcp-server/dist/tools/team.js +87 -0
- package/mcp-server/dist/tools/team.js.map +1 -0
- package/mcp-server/package-lock.json +2 -2
- package/mcp-server/package.json +1 -1
- package/mcp-server/src/http.ts +9 -1
- package/mcp-server/src/index.ts +34 -4
- package/mcp-server/src/services/browser-route-flow.ts +12 -5
- package/mcp-server/src/services/codex-config-heal.ts +7 -0
- package/mcp-server/src/services/neural-interface.ts +190 -29
- package/mcp-server/src/services/team-context.ts +27 -0
- package/mcp-server/src/services/tool-catalog.ts +26 -8
- package/mcp-server/src/services/tool-list.ts +4 -0
- package/mcp-server/src/services/tool-runtime.ts +21 -2
- package/mcp-server/src/tools/agent-definition.ts +458 -0
- package/mcp-server/src/tools/agents.ts +175 -19
- package/mcp-server/src/tools/browser-advanced.ts +60 -6
- package/mcp-server/src/tools/git-tools.ts +249 -3
- package/mcp-server/src/tools/morelogin.ts +20 -5
- package/mcp-server/src/tools/team.ts +97 -0
- package/neural-interface/i18n/en.json +1174 -47
- package/neural-interface/i18n/pt-BR.json +1174 -47
- package/neural-interface/lib/account-usage.js +1 -1
- package/neural-interface/lib/agents/density.js +101 -0
- package/neural-interface/lib/agents/forge-host.js +223 -0
- package/neural-interface/lib/agents/native-export-targets.js +190 -0
- package/neural-interface/lib/agents/native-export.js +365 -0
- package/neural-interface/lib/agents/registry.js +840 -0
- package/neural-interface/lib/agents/resolve.js +544 -0
- package/neural-interface/lib/agents/schema.js +642 -0
- package/neural-interface/lib/agents/split.js +37 -0
- package/neural-interface/lib/agents-studio-api.js +591 -0
- package/neural-interface/lib/assistant-api.js +76 -7
- package/neural-interface/lib/assistant-catalog.js +2 -0
- package/neural-interface/lib/assistant-continuity.js +49 -0
- package/neural-interface/lib/assistant-dispatch.js +229 -102
- package/neural-interface/lib/assistant-persona.js +105 -8
- package/neural-interface/lib/assistant-route-gate.js +24 -9
- package/neural-interface/lib/assistant-router.js +384 -42
- package/neural-interface/lib/assistant-run-tail.js +151 -0
- package/neural-interface/lib/assistant-run-wait.js +183 -0
- package/neural-interface/lib/assistant-runtime.js +440 -93
- package/neural-interface/lib/assistant-task-prompt.js +11 -2
- package/neural-interface/lib/assistant-usage.js +3 -2
- package/neural-interface/lib/automation-approval.js +2 -2
- package/neural-interface/lib/browser-close-evidence.js +80 -0
- package/neural-interface/lib/browser-default.js +210 -0
- package/neural-interface/lib/browser-extension-adapter.js +255 -0
- package/neural-interface/lib/browser-extension-bridge.js +418 -0
- package/neural-interface/lib/browser-extension-folder.js +116 -0
- package/neural-interface/lib/browser-extension-setup.js +140 -0
- package/neural-interface/lib/browser-profile-choices.js +3 -3
- package/neural-interface/lib/browser-profiles.js +1 -1
- package/neural-interface/lib/browser-tool-policy.js +1 -1
- package/neural-interface/lib/claude-account-links.js +301 -0
- package/neural-interface/lib/claude-accounts.js +45 -20
- package/neural-interface/lib/claude-agent-bridge.js +142 -10
- package/neural-interface/lib/claude-model-catalog.js +6 -0
- package/neural-interface/lib/claude-panel-session.js +33 -0
- package/neural-interface/lib/cli-install-api.js +23 -0
- package/neural-interface/lib/codex-accounts.js +67 -24
- package/neural-interface/lib/coordination/README.md +384 -0
- package/neural-interface/lib/coordination/service.js +563 -0
- package/neural-interface/lib/coordination/store.js +1138 -0
- package/neural-interface/lib/db.js +22 -1
- package/neural-interface/lib/editor-completion-opencode.js +4 -3
- package/neural-interface/lib/effort-levels.js +10 -1
- package/neural-interface/lib/maritaca/opencode-proxy.js +7 -2
- package/neural-interface/lib/maritaca/opencode.js +35 -0
- package/neural-interface/lib/memory-list-page.js +49 -0
- package/neural-interface/lib/memory-list-stamp.js +60 -0
- package/neural-interface/lib/morelogin-outside-close.js +186 -0
- package/neural-interface/lib/morelogin-profile-failures.js +206 -0
- package/neural-interface/lib/morelogin-start-cooldown.js +160 -0
- package/neural-interface/lib/morelogin.js +219 -7
- package/neural-interface/lib/native-loop-runtime.js +24 -1
- package/neural-interface/lib/opencode-build-preflight.js +116 -0
- package/neural-interface/lib/opencode-launch-error.js +13 -0
- package/neural-interface/lib/opencode-native-boundary.js +800 -84
- package/neural-interface/lib/opencode-serve-probe.js +426 -0
- package/neural-interface/lib/opencode-serve-records.js +14 -9
- package/neural-interface/lib/opencode-serve-scan.js +108 -0
- package/neural-interface/lib/page-session.js +1 -1
- package/neural-interface/lib/peer-identity.js +60 -21
- package/neural-interface/lib/process-identity.js +235 -7
- package/neural-interface/lib/request-gate.js +3 -0
- package/neural-interface/lib/screenshot-location.js +33 -0
- package/neural-interface/lib/skills/creation.js +1 -1
- package/neural-interface/lib/skills/known-bridge-digests.json +40 -0
- package/neural-interface/lib/studio-attention.js +56 -0
- package/neural-interface/lib/teams/README.md +382 -0
- package/neural-interface/lib/teams/api.js +287 -0
- package/neural-interface/lib/teams/brief.js +185 -0
- package/neural-interface/lib/teams/claims.js +315 -0
- package/neural-interface/lib/teams/git.js +293 -0
- package/neural-interface/lib/teams/index.js +122 -0
- package/neural-interface/lib/teams/integration.js +580 -0
- package/neural-interface/lib/teams/landing.js +184 -0
- package/neural-interface/lib/teams/recovery.js +256 -0
- package/neural-interface/lib/teams/scheduler.js +1474 -0
- package/neural-interface/lib/teams/schema.js +559 -0
- package/neural-interface/lib/teams/state.js +181 -0
- package/neural-interface/lib/teams/test-runner.js +86 -0
- package/neural-interface/lib/teams/test-sandbox.js +99 -0
- package/neural-interface/lib/teams/worktrees.js +757 -0
- package/neural-interface/lib/tool-permission-choices.js +226 -0
- package/neural-interface/lib/whatsapp/cards.js +24 -10
- package/neural-interface/lib/worker-confinement.js +206 -6
- package/neural-interface/lib/worker-mcp-channel.js +38 -1
- package/neural-interface/package-lock.json +4 -2
- package/neural-interface/package.json +3 -1
- package/neural-interface/public/extension-setup.html +107 -0
- package/neural-interface/public/index.html +52 -12
- package/neural-interface/public/shared/agent-runtime-options.js +3 -1
- package/neural-interface/public/shared/agents/studio/ax-agent-view.js +614 -0
- package/neural-interface/public/shared/agents/studio/ax-api.js +198 -0
- package/neural-interface/public/shared/agents/studio/ax-create-view.js +221 -0
- package/neural-interface/public/shared/agents/studio/ax-diff.js +143 -0
- package/neural-interface/public/shared/agents/studio/ax-editor-view.js +392 -0
- package/neural-interface/public/shared/agents/studio/ax-export-view.js +94 -0
- package/neural-interface/public/shared/agents/studio/ax-form.js +191 -0
- package/neural-interface/public/shared/agents/studio/ax-icons.js +87 -0
- package/neural-interface/public/shared/agents/studio/ax-library-view.js +158 -0
- package/neural-interface/public/shared/agents/studio/ax-library.js +162 -0
- package/neural-interface/public/shared/agents/studio/ax-main.js +712 -0
- package/neural-interface/public/shared/agents/studio/ax-native-export.js +35 -0
- package/neural-interface/public/shared/agents/studio/ax-options.js +198 -0
- package/neural-interface/public/shared/agents/studio/ax-review-view.js +175 -0
- package/neural-interface/public/shared/agents/studio/ax-revisions-view.js +189 -0
- package/neural-interface/public/shared/agents/studio/ax-runs-view.js +202 -0
- package/neural-interface/public/shared/agents/studio/ax-runs.js +82 -0
- package/neural-interface/public/shared/agents/studio/ax-teams-view.js +256 -0
- package/neural-interface/public/shared/agents/studio/ax-teams.js +200 -0
- package/neural-interface/public/shared/agents/studio/ax-templates.js +50 -0
- package/neural-interface/public/shared/agents/studio/ax-ui.js +194 -0
- package/neural-interface/public/shared/agents/studio/ax-views.js +170 -0
- package/neural-interface/public/shared/agy/agy-panel.js +142 -28
- package/neural-interface/public/shared/agy/agy-styles.js +25 -5
- package/neural-interface/public/shared/assistant/asst-account-menu.js +13 -13
- package/neural-interface/public/shared/assistant/asst-ask-styles.js +2 -3
- package/neural-interface/public/shared/assistant/asst-brain-picker.js +91 -9
- package/neural-interface/public/shared/assistant/asst-control.js +3 -0
- package/neural-interface/public/shared/assistant/asst-interaction-hold.js +99 -0
- package/neural-interface/public/shared/assistant/asst-limit-dismissals.js +111 -0
- package/neural-interface/public/shared/assistant/asst-limit-dock.js +37 -3
- package/neural-interface/public/shared/assistant/asst-limit-wait.js +30 -7
- package/neural-interface/public/shared/assistant/asst-panel.js +177 -30
- package/neural-interface/public/shared/assistant/asst-rack-styles.js +15 -8
- package/neural-interface/public/shared/assistant/asst-render.js +36 -6
- package/neural-interface/public/shared/assistant/asst-route.js +78 -12
- package/neural-interface/public/shared/assistant/asst-routes-editor.js +148 -70
- package/neural-interface/public/shared/assistant/asst-roving.js +17 -1
- package/neural-interface/public/shared/assistant/asst-scene-styles.js +7 -2
- package/neural-interface/public/shared/assistant/asst-scenes.js +12 -1
- package/neural-interface/public/shared/assistant/asst-sidepanel.js +12 -2
- package/neural-interface/public/shared/assistant/asst-state.js +66 -1
- package/neural-interface/public/shared/assistant/asst-styles.js +98 -44
- package/neural-interface/public/shared/assistant/route-identity.js +16 -0
- package/neural-interface/public/shared/cdx/cdx-output.js +10 -0
- package/neural-interface/public/shared/cdx/cdx-panel.js +18 -16
- package/neural-interface/public/shared/cdx/cdx-plan.js +3 -2
- package/neural-interface/public/shared/cdx/cdx-render.js +122 -45
- package/neural-interface/public/shared/cdx/cdx-requests.js +4 -4
- package/neural-interface/public/shared/cdx/cdx-styles.js +8 -36
- package/neural-interface/public/shared/cdx/cdx-tabs.js +110 -42
- package/neural-interface/public/shared/claude-panel-lazy.js +12 -0
- package/neural-interface/public/shared/code-copy.js +120 -0
- package/neural-interface/public/shared/constants.js +7 -0
- package/neural-interface/public/shared/context-menu-model.js +1 -0
- package/neural-interface/public/shared/cp/cp-markdown.js +7 -2
- package/neural-interface/public/shared/cp/cp-session-model.js +86 -5
- package/neural-interface/public/shared/cp/cp-session-settings.js +58 -30
- package/neural-interface/public/shared/cp/cp-styles.js +9 -0
- package/neural-interface/public/shared/dom-change-flag.js +66 -0
- package/neural-interface/public/shared/dom-morph.js +124 -0
- package/neural-interface/public/shared/extension-setup/es-page.css +134 -0
- package/neural-interface/public/shared/extension-setup/es-page.js +120 -0
- package/neural-interface/public/shared/extension-setup/es-view.js +100 -0
- package/neural-interface/public/shared/html-shell.js +33 -4
- package/neural-interface/public/shared/i18n.js +14 -1
- package/neural-interface/public/shared/idle-queue.js +78 -0
- package/neural-interface/public/shared/iface-config.js +227 -0
- package/neural-interface/public/shared/lazy-module.js +108 -0
- package/neural-interface/public/shared/memory-list.js +117 -0
- package/neural-interface/public/shared/morelogin-profile-choices.js +1 -1
- package/neural-interface/public/shared/morelogin-profile-field.js +3 -3
- package/neural-interface/public/shared/mtc/mtc-panel.js +3 -1
- package/neural-interface/public/shared/mtc/mtc-styles.js +4 -1
- package/neural-interface/public/shared/ocp-v2/ocp-v2-manager.js +35 -15
- package/neural-interface/public/shared/ocp-v2/ocp-v2-panel.js +77 -23
- package/neural-interface/public/shared/ocp-v2/ocp-v2-projectbar.js +3 -6
- package/neural-interface/public/shared/ocp-v2/ocp-v2-render.js +24 -21
- package/neural-interface/public/shared/ocp-v2/ocp-v2-send-logic.js +16 -5
- package/neural-interface/public/shared/ocp-v2/ocp-v2-sessions-logic.js +16 -2
- package/neural-interface/public/shared/ocp-v2/ocp-v2-styles.js +27 -43
- package/neural-interface/public/shared/ocp-v2/ocp-v2-ws.js +73 -9
- package/neural-interface/public/shared/opencode-verify-view.js +175 -0
- package/neural-interface/public/shared/schedules-view.js +2 -2
- package/neural-interface/public/shared/session-project-items.js +11 -0
- package/neural-interface/public/shared/settings/settings-ai-browser.js +119 -0
- package/neural-interface/public/shared/settings/settings-browser-extension.js +446 -0
- package/neural-interface/public/shared/settings/settings-ia.js +4 -2
- package/neural-interface/public/shared/settings/settings-morelogin-cooldown.js +63 -0
- package/neural-interface/public/shared/settings/settings-tool-permissions.js +70 -0
- package/neural-interface/public/shared/sidepanel-lazy.js +40 -0
- package/neural-interface/public/shared/sidepanel-session-status.js +8 -14
- package/neural-interface/public/shared/sidepanel-shown.js +73 -0
- package/neural-interface/public/shared/storage.js +6 -1
- package/neural-interface/public/shared/studio-attention.js +83 -0
- package/neural-interface/public/shared/styles.css +713 -61
- package/neural-interface/public/shared/term-browser-tabs.js +34 -0
- package/neural-interface/public/shared/transcript-rows.js +334 -0
- package/neural-interface/public/shared/tray-auto-close.js +106 -0
- package/neural-interface/public/shared/ui-agents.js +97 -0
- package/neural-interface/public/shared/ui-antigravity-panel.js +16 -14
- package/neural-interface/public/shared/ui-automation-studio.js +3 -3
- package/neural-interface/public/shared/ui-claude-panel.js +162 -95
- package/neural-interface/public/shared/ui-code-copy.js +256 -0
- package/neural-interface/public/shared/ui-codex-panel.js +14 -10
- package/neural-interface/public/shared/ui-context-menu.js +1 -1
- package/neural-interface/public/shared/ui-file-explorer.js +2 -3
- package/neural-interface/public/shared/ui-games.js +1 -1
- package/neural-interface/public/shared/ui-loading.js +12 -1
- package/neural-interface/public/shared/ui-maritaca-panel.js +12 -11
- package/neural-interface/public/shared/ui-menubar.js +23 -0
- package/neural-interface/public/shared/ui-native-loop-router.js +1 -1
- package/neural-interface/public/shared/ui-navbar.js +15 -9
- package/neural-interface/public/shared/ui-opencode-panel-v2.js +13 -11
- package/neural-interface/public/shared/ui-opencode-verify.js +120 -0
- package/neural-interface/public/shared/ui-schedules-studio.js +3 -3
- package/neural-interface/public/shared/ui-scroll-follow.js +39 -0
- package/neural-interface/public/shared/ui-sessions.js +3 -3
- package/neural-interface/public/shared/ui-settings-entry.js +55 -0
- package/neural-interface/public/shared/ui-settings.js +372 -402
- package/neural-interface/public/shared/ui-sidepanel-layout.js +44 -25
- package/neural-interface/public/shared/ui-sidepanel-session-entry.js +22 -9
- package/neural-interface/public/shared/ui-sidepanel-sessions.js +10 -2
- package/neural-interface/public/shared/ui-sidepanel-tray.js +36 -41
- package/neural-interface/public/shared/ui-sidepanel-windows.js +14 -1
- package/neural-interface/public/shared/ui-styleguide.js +10 -2
- package/neural-interface/public/shared/ui-sync.js +5 -0
- package/neural-interface/public/shared/ui-terminal.js +13 -9
- package/neural-interface/public/shared/ui-tooltip.js +28 -7
- package/neural-interface/public/shared/ui-topright-overflow.js +26 -4
- package/neural-interface/public/shared/ui-tray-columns.js +375 -0
- package/neural-interface/public/shared/ui-whiteboard.js +51 -6
- package/neural-interface/public/shared/ui-worker-end.js +28 -1
- package/neural-interface/public/shared/ui-workspaces.js +13 -0
- package/neural-interface/public/shared/window-keys.js +71 -0
- package/neural-interface/public/variant/2d/main.js +2 -0
- package/neural-interface/public/variant/3d/app.js +620 -0
- package/neural-interface/public/variant/3d/boot-reveal.js +47 -0
- package/neural-interface/public/variant/3d/main.js +21 -544
- package/neural-interface/public/variant/3d/map-controls.js +4 -2
- package/neural-interface/public/vendor/fonts/fonts.css +508 -0
- package/neural-interface/public/vendor/fonts/inter-OFL.txt +93 -0
- package/neural-interface/public/vendor/fonts/inter-cyrillic-ext.woff2 +0 -0
- package/neural-interface/public/vendor/fonts/inter-cyrillic.woff2 +0 -0
- package/neural-interface/public/vendor/fonts/inter-greek-ext.woff2 +0 -0
- package/neural-interface/public/vendor/fonts/inter-greek.woff2 +0 -0
- package/neural-interface/public/vendor/fonts/inter-latin-ext.woff2 +0 -0
- package/neural-interface/public/vendor/fonts/inter-latin.woff2 +0 -0
- package/neural-interface/public/vendor/fonts/inter-vietnamese.woff2 +0 -0
- package/neural-interface/public/vendor/fonts/jetbrains-mono-OFL.txt +93 -0
- package/neural-interface/public/vendor/fonts/jetbrains-mono-cyrillic-ext.woff2 +0 -0
- package/neural-interface/public/vendor/fonts/jetbrains-mono-cyrillic.woff2 +0 -0
- package/neural-interface/public/vendor/fonts/jetbrains-mono-greek.woff2 +0 -0
- package/neural-interface/public/vendor/fonts/jetbrains-mono-latin-ext.woff2 +0 -0
- package/neural-interface/public/vendor/fonts/jetbrains-mono-latin.woff2 +0 -0
- package/neural-interface/public/vendor/fonts/jetbrains-mono-vietnamese.woff2 +0 -0
- package/neural-interface/public/vendor/fonts/manifest.json +142 -0
- package/neural-interface/public/vendor/fonts/space-grotesk-OFL.txt +93 -0
- package/neural-interface/public/vendor/fonts/space-grotesk-latin-ext.woff2 +0 -0
- package/neural-interface/public/vendor/fonts/space-grotesk-latin.woff2 +0 -0
- package/neural-interface/public/vendor/fonts/space-grotesk-vietnamese.woff2 +0 -0
- package/neural-interface/scripts/boot-graph.mjs +270 -0
- package/neural-interface/scripts/vendor-fonts.mjs +124 -0
- package/neural-interface/server.js +1164 -157
- package/npm-shrinkwrap.json +2 -2
- package/package.json +3 -1
- package/skills/agent-forge/SKILL.md +182 -0
- package/skills/agent-forge/evals/evals.json +56 -0
- package/skills/agent-forge/references/definition-fields.md +61 -0
- package/skills/agent-forge/references/examples.md +105 -0
- package/skills/agent-forge/references/instructions.md +51 -0
- package/skills/agent-forge/references/review-and-export.md +84 -0
|
@@ -520,7 +520,7 @@ export function getAllMemories({ includeVectors = false, includeTrash = false }
|
|
|
520
520
|
related_memory_ids, file_checksums, trashed_at, source_session_chunks
|
|
521
521
|
${vectorCol}
|
|
522
522
|
FROM memories ${where}
|
|
523
|
-
ORDER BY created_at DESC
|
|
523
|
+
ORDER BY created_at DESC, id DESC
|
|
524
524
|
`).all();
|
|
525
525
|
|
|
526
526
|
return rows.map(row => {
|
|
@@ -533,6 +533,27 @@ export function getAllMemories({ includeVectors = false, includeTrash = false }
|
|
|
533
533
|
});
|
|
534
534
|
}
|
|
535
535
|
|
|
536
|
+
/**
|
|
537
|
+
* One page of the live memories, in the order of getAllMemories() (newest first; equal times by id, so the pages
|
|
538
|
+
* of an unchanged store are the same every time and never overlap), and how many live memories there are.
|
|
539
|
+
* GET /api/memories?links=false&offset=…&limit=… (the page's progressive memory list) reads only its own rows.
|
|
540
|
+
* @param {{ offset?: number, limit: number }} options
|
|
541
|
+
* @returns {{ rows: Array<object>, total: number }}
|
|
542
|
+
*/
|
|
543
|
+
export function getMemoriesPage({ offset = 0, limit } = {}) {
|
|
544
|
+
const d = getDb();
|
|
545
|
+
const total = d.prepare('SELECT COUNT(*) AS n FROM memories WHERE trashed_at IS NULL').get().n;
|
|
546
|
+
const rows = d.prepare(`
|
|
547
|
+
SELECT id, content, category, subcategory, project, tags, importance, source,
|
|
548
|
+
created_at, updated_at, accessed_at, access_count, related_files,
|
|
549
|
+
related_memory_ids, file_checksums, trashed_at, source_session_chunks
|
|
550
|
+
FROM memories WHERE trashed_at IS NULL
|
|
551
|
+
ORDER BY created_at DESC, id DESC
|
|
552
|
+
LIMIT ? OFFSET ?
|
|
553
|
+
`).all(limit, offset);
|
|
554
|
+
return { rows: rows.map((row) => ({ id: row.id, ...rowToPayload(row) })), total };
|
|
555
|
+
}
|
|
556
|
+
|
|
536
557
|
/**
|
|
537
558
|
* Get all memories with vectors for link computation.
|
|
538
559
|
*/
|
|
@@ -225,7 +225,7 @@ function abortError() {
|
|
|
225
225
|
* in its turn among every serve SynaBun starts (server.js oneOpencodeStartAtATime); by itself when not given
|
|
226
226
|
* @param {number} [deps.exitWaitMs] how long a failed start waits for its process to exit after SIGTERM, and again
|
|
227
227
|
* after SIGKILL, before its turn ends
|
|
228
|
-
* @param {(o: { port: number, proc: object }) => any} [deps.trackServe] told once something answers on the port
|
|
228
|
+
* @param {(o: { port: number, proc: object, password: string | null }) => any} [deps.trackServe] told once something answers on the port (with the password the serve printed, which its runtime check proves it accepts)
|
|
229
229
|
* (server.js keeps the serve on record from its spawn, so that a crash of SynaBun does not leave it running for
|
|
230
230
|
* good); 'foreign' (or a promise of it): what answers is not this start's process but another server that took
|
|
231
231
|
* the port, which is left running while the start ends its own process and tries another port
|
|
@@ -362,7 +362,8 @@ export function createOpencodeCompletionEngine({
|
|
|
362
362
|
// is gone.
|
|
363
363
|
const check = await startOneAtATime(async () => {
|
|
364
364
|
stillWanted();
|
|
365
|
-
|
|
365
|
+
const pendingSpawn = spawnServe({ port, env: completionServeEnvironment(env, { configHome: dataDir }), cwd: workDir, password, passwordFrom });
|
|
366
|
+
started.proc = typeof pendingSpawn?.then === 'function' ? await pendingSpawn : pendingSpawn;
|
|
366
367
|
if (passwordFrom === 'stdout') {
|
|
367
368
|
const readPassword = servePasswordReader();
|
|
368
369
|
started.proc?.stdout?.on('data', chunk => { started.password = readPassword(chunk); });
|
|
@@ -384,7 +385,7 @@ export function createOpencodeCompletionEngine({
|
|
|
384
385
|
if (answer?.ok) {
|
|
385
386
|
// Only this start's own process counts: another server that took the port answers for itself.
|
|
386
387
|
let verdict = null;
|
|
387
|
-
try { verdict = await trackServe({ port, proc: started.proc }); } catch { /* the record is the caller's */ }
|
|
388
|
+
try { verdict = await trackServe({ port, proc: started.proc, password: started.password }); } catch { /* the record is the caller's */ }
|
|
388
389
|
if (verdict === 'foreign') throw Object.assign(new Error(`Another server answers on port ${port}`), { portTaken: true });
|
|
389
390
|
return answer;
|
|
390
391
|
}
|
|
@@ -81,6 +81,9 @@ export function modelEfforts(row) {
|
|
|
81
81
|
*/
|
|
82
82
|
export const EFFORT_OFF = 'none';
|
|
83
83
|
|
|
84
|
+
/** A Claude Code row whose CLI said it cannot run with thinking off (`supportsThinkingOff: false` → row.thinkingOff). */
|
|
85
|
+
export function thinkingAlwaysOn(row) { return !!row && (row.thinkingOff === false || row.supportsThinkingOff === false); }
|
|
86
|
+
|
|
84
87
|
/**
|
|
85
88
|
* Can this provider/row run with thinking off? Codex and OpenCode only when the
|
|
86
89
|
* model lists `none`; Claude Code whenever the model thinks at all (the SDK
|
|
@@ -88,6 +91,9 @@ export const EFFORT_OFF = 'none';
|
|
|
88
91
|
*/
|
|
89
92
|
export function supportsEffortOff(provider, row) {
|
|
90
93
|
const levels = modelEfforts(row);
|
|
94
|
+
// A model whose CLI says its thinking cannot be turned off (thinkingOff false: Opus 5.5 rejects disabled thinking,
|
|
95
|
+
// and the CLI then sends adaptive thinking at whatever effort its settings give): Off is corrected to the lowest level.
|
|
96
|
+
if (provider === 'claude-code' && thinkingAlwaysOn(row)) return false;
|
|
91
97
|
if (provider === 'claude-code') return levels ? levels.some((id) => id.toLowerCase() !== EFFORT_OFF) : !!row;
|
|
92
98
|
if (provider === 'antigravity') return false;
|
|
93
99
|
return !!levels?.some((id) => id.toLowerCase() === EFFORT_OFF);
|
|
@@ -136,7 +142,10 @@ export function normalizeEffort({ provider = null, model = null, effort = null,
|
|
|
136
142
|
// Off on a model that can switch its thinking off stays Off (Claude Code lists no `none`: see supportsEffortOff).
|
|
137
143
|
if (raw.toLowerCase() === EFFORT_OFF && supportsEffortOff(provider, row)) return { effort: EFFORT_OFF, corrected: null };
|
|
138
144
|
const next = clampEffort(raw, levels, { fallback: row?.defaultEffort || null });
|
|
139
|
-
|
|
145
|
+
if (next === raw) return { effort: raw, corrected: null };
|
|
146
|
+
// Off asked of a model that always thinks: it runs at the lowest level, and the correction says why.
|
|
147
|
+
const alwaysOn = raw.toLowerCase() === EFFORT_OFF && provider === 'claude-code' && thinkingAlwaysOn(row);
|
|
148
|
+
return { effort: next, corrected: { from: raw, to: next, ...(alwaysOn ? { reason: 'thinking_always_on' } : {}) } };
|
|
140
149
|
}
|
|
141
150
|
|
|
142
151
|
/** The model's levels for a provider/model pair (null when unknown). */
|
|
@@ -98,7 +98,12 @@ export function createMaritacaOpencodeProxy({ keyStore, upstreamBaseUrl = MARITA
|
|
|
98
98
|
log(line);
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
-
|
|
101
|
+
/**
|
|
102
|
+
* `channel: true` only from the worker-only channel (lib/worker-mcp-channel.js), which has already proved the caller
|
|
103
|
+
* by the run's path token and let only a run whose own configuration routes Maritaca there: a sandboxed worker
|
|
104
|
+
* cannot read the key file, so it presents no key, and the saved key is used as for any other caller.
|
|
105
|
+
*/
|
|
106
|
+
async function handle(req, res, { channel = false } = {}) {
|
|
102
107
|
stats.requests += 1;
|
|
103
108
|
let key;
|
|
104
109
|
try { key = keyStore.readKey(); } catch (error) {
|
|
@@ -106,7 +111,7 @@ export function createMaritacaOpencodeProxy({ keyStore, upstreamBaseUrl = MARITA
|
|
|
106
111
|
return sendError(res, 500, error?.code || 'KEY_UNREADABLE', 'SynaBun could not read its saved Maritaca key. Save it again in the Maritaca panel (the cog).');
|
|
107
112
|
}
|
|
108
113
|
if (!key) { stats.refused += 1; return sendError(res, 401, 'NO_KEY', 'No Maritaca API key is saved in SynaBun. Save one in the Maritaca panel (the cog).'); }
|
|
109
|
-
if (!sameKey(presentedKey(req), key)) {
|
|
114
|
+
if (channel !== true && !sameKey(presentedKey(req), key)) {
|
|
110
115
|
stats.refused += 1;
|
|
111
116
|
return sendError(res, 401, 'KEY_MISMATCH', 'This address takes the Maritaca key SynaBun has saved. Re-sync Maritaca under Settings → OpenCode → Providers.');
|
|
112
117
|
}
|
|
@@ -122,6 +122,41 @@ export function maritacaOpencodeState({ config, keyStatus, keyPath, models = MAR
|
|
|
122
122
|
};
|
|
123
123
|
}
|
|
124
124
|
|
|
125
|
+
/** The path of the Maritaca route on the worker-only channel, under a run's `/w/<token>` base (lib/worker-mcp-channel.js). */
|
|
126
|
+
export const MARITACA_WORKER_CHANNEL_PATH = '/maritaca/v1';
|
|
127
|
+
/**
|
|
128
|
+
* What a sandboxed worker's block holds as its key: not a key. The channel's per-run path token is the caller's proof
|
|
129
|
+
* and the channel uses SynaBun's saved key itself, so nothing secret is written into the run's configuration.
|
|
130
|
+
*/
|
|
131
|
+
export const MARITACA_WORKER_CHANNEL_KEY = 'synabun-worker-channel';
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* A protected worker's OpenCode serve on macOS runs under a Seatbelt profile (lib/worker-sandbox.js) that blocks
|
|
135
|
+
* SynaBun's control port and reads of SynaBun's data home. The block the sync writes needs both: its base URL is this
|
|
136
|
+
* server's route on the control port and its key a {file:…} reference into the data home, so inside the sandbox
|
|
137
|
+
* OpenCode can neither read the key nor connect ("Transport: ECONNRESET", retried until the run is stopped). For such
|
|
138
|
+
* a run the block is pointed at the same proxy on the worker-only channel instead (`channelBase` is the run's
|
|
139
|
+
* `http://127.0.0.1:<port>/w/<token>`), with a placeholder for the key. Only a block that routes through SynaBun
|
|
140
|
+
* (route 'synabun') is changed; anything else is the user's and left as it is. Mutates `config`; returns whether it
|
|
141
|
+
* changed the block.
|
|
142
|
+
*/
|
|
143
|
+
export function maritacaWorkerChannelProvider(config, channelBase) {
|
|
144
|
+
const base = trimUrl(channelBase);
|
|
145
|
+
if (!config || typeof config !== 'object' || !/^http:\/\/127\.0\.0\.1:\d{1,5}\/w\/[A-Za-z0-9]+$/.test(base)) return false;
|
|
146
|
+
for (const section of ['providers', 'provider']) {
|
|
147
|
+
const entry = config[section]?.[MARITACA_OPENCODE_PROVIDER_ID];
|
|
148
|
+
if (!entry || typeof entry !== 'object' || Array.isArray(entry)) continue;
|
|
149
|
+
const settings = entry.settings && typeof entry.settings === 'object' ? entry.settings : null;
|
|
150
|
+
if (!settings || maritacaOpencodeRoute(settings.baseURL) !== 'synabun') return false;
|
|
151
|
+
config[section][MARITACA_OPENCODE_PROVIDER_ID] = {
|
|
152
|
+
...entry,
|
|
153
|
+
settings: { ...settings, baseURL: `${base}${MARITACA_WORKER_CHANNEL_PATH}`, apiKey: MARITACA_WORKER_CHANNEL_KEY },
|
|
154
|
+
};
|
|
155
|
+
return true;
|
|
156
|
+
}
|
|
157
|
+
return false;
|
|
158
|
+
}
|
|
159
|
+
|
|
125
160
|
export function maritacaOpencodeError(code, message, status = 500) {
|
|
126
161
|
return Object.assign(new Error(message), { code, status });
|
|
127
162
|
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// One page of the page's memory list (`GET /api/memories?links=false&offset=…&limit=…`).
|
|
2
|
+
//
|
|
3
|
+
// The 3D page used to fetch every memory in one answer (about 32 MB for 24,000 memories) and parse it in one go. It
|
|
4
|
+
// now asks for pages (public/shared/memory-list.js): the first arrives in a fraction of the time, each parse is a
|
|
5
|
+
// short task, and the server reads only the rows of the page. Without `limit` the route answers as it always did
|
|
6
|
+
// (every memory, the same body and ETag): other callers and a page from before this change are unaffected.
|
|
7
|
+
//
|
|
8
|
+
// A page carries `page.version`, the ETag the whole list would have now: a client that sees two versions across its
|
|
9
|
+
// pages knows the list changed while it read them and starts again. Each page has an ETag of its own (the version
|
|
10
|
+
// plus the page's place), so a reload of an unchanged list is answered `304 Not Modified` page by page.
|
|
11
|
+
|
|
12
|
+
/** The largest page a request may ask for. */
|
|
13
|
+
export const MEMORY_PAGE_MAX = 10_000;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* The page a query asks for: null when it asks for no page (no `limit`), `{ error }` when the numbers are not
|
|
17
|
+
* usable, else `{ offset, limit }` (limit at most MEMORY_PAGE_MAX).
|
|
18
|
+
* @param {Record<string, unknown>} query
|
|
19
|
+
*/
|
|
20
|
+
export function parseMemoryPage(query = {}) {
|
|
21
|
+
const rawLimit = query.limit;
|
|
22
|
+
if (rawLimit === undefined || rawLimit === null || rawLimit === '') return null;
|
|
23
|
+
const asInt = (value) => (typeof value === 'string' && /^\d{1,9}$/.test(value) ? Number(value) : NaN);
|
|
24
|
+
const limit = asInt(rawLimit);
|
|
25
|
+
if (!Number.isInteger(limit) || limit < 1) return { error: 'limit must be a whole number of at least 1' };
|
|
26
|
+
const rawOffset = query.offset;
|
|
27
|
+
const offset = rawOffset === undefined || rawOffset === '' ? 0 : asInt(rawOffset);
|
|
28
|
+
if (!Number.isInteger(offset) || offset < 0) return { error: 'offset must be a whole number of at least 0' };
|
|
29
|
+
return { offset, limit: Math.min(limit, MEMORY_PAGE_MAX) };
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** The ETag part that tells one page from another of the same list. */
|
|
33
|
+
export function pageEtagPart({ offset, limit }) {
|
|
34
|
+
return `page:${offset}:${limit}`;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* The page's description in the answer. `total` counts the stored memories; the bridge's nodes (if any) ride on the
|
|
39
|
+
* last page, after them, as in the unpaged answer.
|
|
40
|
+
*/
|
|
41
|
+
export function describePage({ offset, limit, total, count, version }) {
|
|
42
|
+
const end = offset + limit;
|
|
43
|
+
return { offset, limit, count, total, next: end < total ? end : null, version: version ?? null };
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** Whether this page is the last one, the one that carries what follows the stored memories. */
|
|
47
|
+
export function isLastPage({ offset, limit, total }) {
|
|
48
|
+
return offset + limit >= total;
|
|
49
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// What the page's first memory list (`GET /api/memories?links=false`) depends on, as one short string, and
|
|
2
|
+
// the ETag made from it.
|
|
3
|
+
//
|
|
4
|
+
// The 3D map asks for every memory on every load: about 32 MB of JSON for 24,000 memories. Answering meant
|
|
5
|
+
// reading every row, building every node and serialising all of it, half a second of the server doing
|
|
6
|
+
// nothing else, right when the page also wants its style sheet and four hundred modules; and that was done
|
|
7
|
+
// even when the browser already held the very same answer, because only the finished body said whether it
|
|
8
|
+
// had changed. The stamp says it first, from two small queries: a page that still holds the list gets
|
|
9
|
+
// `304 Not Modified` before a single row is read.
|
|
10
|
+
//
|
|
11
|
+
// The stamp changes whenever the answer would:
|
|
12
|
+
// - `memory_changes` (filled by triggers on the memories table, whoever writes: this server, an MCP server,
|
|
13
|
+
// a hook) has a row for every insert and delete and for every update of a column the list carries, the
|
|
14
|
+
// trash included;
|
|
15
|
+
// - the three columns no trigger watches are read straight from the table: the number of live memories,
|
|
16
|
+
// the sum of access counts and the newest `accessed_at` / `updated_at` (a recall changes those and
|
|
17
|
+
// nothing else).
|
|
18
|
+
// A stamp that cannot be made (an older database, a busy one) is null: the route then answers as it always
|
|
19
|
+
// did.
|
|
20
|
+
|
|
21
|
+
import { createHash } from 'node:crypto';
|
|
22
|
+
|
|
23
|
+
const CHANGE_SEQ = "SELECT COALESCE(MAX(seq), 0) AS seq FROM memory_changes WHERE entity IN ('memories', 'memory_filters')";
|
|
24
|
+
const LIVE_ROWS = "SELECT COUNT(*) AS n, COALESCE(SUM(access_count), 0) AS accesses, COALESCE(MAX(accessed_at), '') AS accessed, "
|
|
25
|
+
+ "COALESCE(MAX(updated_at), '') AS updated FROM memories WHERE trashed_at IS NULL";
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* The stamp of the live memories in `db` (a node:sqlite database), or null when it cannot be read.
|
|
29
|
+
* @param {{ prepare(sql: string): { get(): any } }} db
|
|
30
|
+
*/
|
|
31
|
+
export function memoryListStamp(db) {
|
|
32
|
+
try {
|
|
33
|
+
const { seq } = db.prepare(CHANGE_SEQ).get();
|
|
34
|
+
const row = db.prepare(LIVE_ROWS).get();
|
|
35
|
+
return [seq, row.n, row.accesses, row.accessed, row.updated].join('|');
|
|
36
|
+
} catch {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* The ETag of a memory list: the stamp plus whatever else shapes the answer (the slim form, the bridge's
|
|
43
|
+
* nodes). Weak: it names what the answer is made from, not its bytes. null when any part is unknown.
|
|
44
|
+
* @param {Array<string | number | boolean | null | undefined>} parts
|
|
45
|
+
*/
|
|
46
|
+
export function memoryListEtag(parts) {
|
|
47
|
+
if (!Array.isArray(parts) || !parts.length || parts.some((part) => part === null || part === undefined)) return null;
|
|
48
|
+
return `W/"ml-${createHash('sha1').update(parts.map(String).join('\u0000')).digest('hex').slice(0, 24)}"`;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** Does an `If-None-Match` header name this ETag? Weak comparison (RFC 9110): a `W/` prefix is ignored. */
|
|
52
|
+
export function etagMatches(header, etag) {
|
|
53
|
+
if (!header || !etag) return false;
|
|
54
|
+
const bare = (value) => String(value).trim().replace(/^W\//, '');
|
|
55
|
+
const wanted = bare(etag);
|
|
56
|
+
return String(header).split(',').some((candidate) => {
|
|
57
|
+
const value = candidate.trim();
|
|
58
|
+
return value === '*' || bare(value) === wanted;
|
|
59
|
+
});
|
|
60
|
+
}
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A MoreLogin profile closed outside SynaBun, remembered per profile (2026-11-15, widened the same night).
|
|
3
|
+
*
|
|
4
|
+
* Every start of a profile that is not running spends one of the MoreLogin plan's 20 daily launches
|
|
5
|
+
* (lib/morelogin-start-cooldown.js). When a profile's browser goes away and SynaBun did not close it (server.js: the
|
|
6
|
+
* context's close handler, after lib/browser-close-evidence.js wrote its evidence line), whoever closed it wanted it
|
|
7
|
+
* closed. Before this, SynaBun opened it again at the next browser call: on 2026-11-15 one close of P-1 cost two
|
|
8
|
+
* launches within a minute (loops' recover / create, 21:13:44 and 21:14:34 local), and at 23:01 a close of P-4 that
|
|
9
|
+
* orphaned no loop was undone 26 s later by the same interactive session's next browser_navigate ("a replacement tab
|
|
10
|
+
* … is open"), one more launch.
|
|
11
|
+
*
|
|
12
|
+
* Now the close is remembered for the profile, and NO automatic path starts it again while the mark holds: a browser
|
|
13
|
+
* tool call (browser_navigate, browser_session create, a replacement tab, /api/browser/acquire), a loop's create /
|
|
14
|
+
* recover, a run's morelogin "use" followed by a browser call, a run's or agent's morelogin "start", a script
|
|
15
|
+
* (fetch-deals.mjs): lib/morelogin.js startProfile refuses at once with MORELOGIN_CLOSED_OUTSIDE (409, needsUser),
|
|
16
|
+
* before MoreLogin is asked for a start. Nobody is moved to another profile or browser in its place.
|
|
17
|
+
*
|
|
18
|
+
* What lifts it:
|
|
19
|
+
* - the owner starts it: SynaBun's Start (Settings → Connected tools → MoreLogin, the owner's page; a session the owner's
|
|
20
|
+
* page creates), or the MoreLogin app, after which MoreLogin lists it running with a debug port. Attaching to a
|
|
21
|
+
* running profile is always allowed (it spends nothing) and a successful attach or start clears the mark;
|
|
22
|
+
* - a NEW scheduled run fires (a schedule's or a quick timer's trigger, server.js `schedule:browser`): it may start
|
|
23
|
+
* the profile as usual, subject to the start-limit hold, and its start clears the mark. A recovery or a create of a
|
|
24
|
+
* run already under way is not a firing;
|
|
25
|
+
* - MoreLogin's next daily reset (00:00 UTC after the close): the mark expires there. The reason it exists is the
|
|
26
|
+
* day's launch budget, and a new day has a new budget; a stale mark would otherwise hold a profile shut for good.
|
|
27
|
+
* A new dispatched worker or a new assistant turn does NOT lift it: they are automatic too, and the point is that
|
|
28
|
+
* the person who closed the profile wanted it closed.
|
|
29
|
+
* A close SynaBun made itself (POST /api/morelogin/stop, its own teardown, the OpenCode serve boundary's revocation,
|
|
30
|
+
* which keeps the window: "SynaBun let go of profile") is never recorded here.
|
|
31
|
+
*
|
|
32
|
+
* `owners`: the runs the close orphaned (server.js finishBlockedLoop ends those loops after their turn; the status
|
|
33
|
+
* route counts them). They no longer decide who is held: everybody is.
|
|
34
|
+
*
|
|
35
|
+
* State: in memory and in DATA_HOME/data/morelogin-outside-closes.json (a restart must not forget it), read again
|
|
36
|
+
* whenever the file changed under it (a script in another process sees the server's marks, and the other way round).
|
|
37
|
+
*/
|
|
38
|
+
import { mkdirSync, readFileSync, renameSync, statSync, writeFileSync } from 'node:fs';
|
|
39
|
+
import { dirname, join } from 'node:path';
|
|
40
|
+
import { getDataHome } from '../../lib/paths.js';
|
|
41
|
+
import { formatLocalTime, nextMoreLoginDayReset } from './morelogin-start-cooldown.js';
|
|
42
|
+
|
|
43
|
+
const MAX_ENTRIES = 200;
|
|
44
|
+
const MAX_OWNERS = 100;
|
|
45
|
+
const MAX_NAME = 120;
|
|
46
|
+
|
|
47
|
+
/** Until when a close at `at` holds: MoreLogin's next daily reset (the first 00:00 UTC after it). */
|
|
48
|
+
export function outsideCloseUntil(at) {
|
|
49
|
+
return nextMoreLoginDayReset(at);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** The file the marks live in (read through getDataHome each time: SYNABUN_DATA_HOME decides, tests use a temp one). */
|
|
53
|
+
export function outsideCloseFile() {
|
|
54
|
+
return join(getDataHome(), 'data', 'morelogin-outside-closes.json');
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
let _entries = null; // envId → { envId, at, until, name, sessionId, owners: string[] }
|
|
58
|
+
let _loadedFrom = null;
|
|
59
|
+
let _loadedStamp = null;
|
|
60
|
+
|
|
61
|
+
function fileStamp(file) {
|
|
62
|
+
try { const s = statSync(file); return `${s.size}:${s.mtimeMs}`; } catch { return 'none'; }
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const cleanName = (name) => (typeof name === 'string' && name.trim() ? name.trim().replace(/[\u0000-\u001f"]/g, '').slice(0, MAX_NAME) : null);
|
|
66
|
+
|
|
67
|
+
function load() {
|
|
68
|
+
const file = outsideCloseFile();
|
|
69
|
+
const stamp = fileStamp(file);
|
|
70
|
+
if (_entries && _loadedFrom === file && _loadedStamp === stamp) return _entries;
|
|
71
|
+
_entries = new Map();
|
|
72
|
+
_loadedFrom = file;
|
|
73
|
+
_loadedStamp = stamp;
|
|
74
|
+
try {
|
|
75
|
+
const raw = JSON.parse(readFileSync(file, 'utf8'));
|
|
76
|
+
for (const e of Array.isArray(raw?.closes) ? raw.closes : []) {
|
|
77
|
+
const at = Number(e?.at);
|
|
78
|
+
if (!e?.envId || !Number.isFinite(at)) continue;
|
|
79
|
+
// A mark written before the expiry existed (version 1) holds until the reset after its close, like a new one.
|
|
80
|
+
const until = Number.isFinite(Number(e.until)) && Number(e.until) > at ? Number(e.until) : outsideCloseUntil(at);
|
|
81
|
+
const owners = Array.isArray(e.owners) ? e.owners.filter((o) => typeof o === 'string' && o).slice(0, MAX_OWNERS) : [];
|
|
82
|
+
_entries.set(String(e.envId), {
|
|
83
|
+
envId: String(e.envId), at, until, name: cleanName(e.name),
|
|
84
|
+
sessionId: typeof e.sessionId === 'string' ? e.sessionId.slice(0, 128) : null, owners,
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
} catch { /* none yet, or unreadable: nothing is blocked */ }
|
|
88
|
+
return _entries;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function save() {
|
|
92
|
+
const file = outsideCloseFile();
|
|
93
|
+
try {
|
|
94
|
+
mkdirSync(dirname(file), { recursive: true });
|
|
95
|
+
const tmp = `${file}.${process.pid}.tmp`;
|
|
96
|
+
writeFileSync(tmp, JSON.stringify({ version: 2, closes: [..._entries.values()] }, null, 2) + '\n', { mode: 0o600 });
|
|
97
|
+
renameSync(tmp, file);
|
|
98
|
+
_loadedStamp = fileStamp(file);
|
|
99
|
+
} catch (err) {
|
|
100
|
+
console.warn(`[morelogin] could not save the profiles closed outside SynaBun (${err?.message || err}); they hold in memory until a restart`);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function prune(now) {
|
|
105
|
+
let changed = false;
|
|
106
|
+
for (const [id, e] of load()) if (!(now < e.until)) { _entries.delete(id); changed = true; }
|
|
107
|
+
return changed;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const copy = (e) => ({ ...e, owners: [...e.owners] });
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Note that `envId` (MoreLogin calls it `name`) was closed outside SynaBun, orphaning the runs `owners`. A second
|
|
114
|
+
* close before the mark is lifted adds its runs to the same mark (the newest time, and its expiry, are kept).
|
|
115
|
+
*/
|
|
116
|
+
export function noteOutsideClose(envId, { at = Date.now(), sessionId = null, owners = [], name = null } = {}) {
|
|
117
|
+
if (!envId) return null;
|
|
118
|
+
const entries = load();
|
|
119
|
+
prune(at);
|
|
120
|
+
const id = String(envId);
|
|
121
|
+
const before = entries.get(id);
|
|
122
|
+
const merged = [...new Set([...(before?.owners || []), ...owners.filter((o) => typeof o === 'string' && o)])].slice(-MAX_OWNERS);
|
|
123
|
+
const entry = {
|
|
124
|
+
envId: id, at, until: outsideCloseUntil(at), name: cleanName(name) || before?.name || null,
|
|
125
|
+
sessionId: sessionId ? String(sessionId).slice(0, 128) : null, owners: merged,
|
|
126
|
+
};
|
|
127
|
+
entries.delete(id); // newest last
|
|
128
|
+
entries.set(id, entry);
|
|
129
|
+
while (entries.size > MAX_ENTRIES) entries.delete(entries.keys().next().value);
|
|
130
|
+
save();
|
|
131
|
+
return copy(entry);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* The mark that holds for `envId` now, or null. It holds for every caller (any session, run, agent or script); only
|
|
136
|
+
* the owner's start and a new scheduled firing go past it (lib/morelogin.js startProfile `allowAfterOutsideClose`).
|
|
137
|
+
*/
|
|
138
|
+
export function outsideCloseFor(envId, now = Date.now()) {
|
|
139
|
+
if (!envId) return null;
|
|
140
|
+
// Before the widening the second argument was the run's id: a string is never a time.
|
|
141
|
+
if (typeof now !== 'number') now = Date.now();
|
|
142
|
+
const e = load().get(String(envId));
|
|
143
|
+
if (!e) return null;
|
|
144
|
+
if (!(now < e.until)) { _entries.delete(String(envId)); save(); return null; }
|
|
145
|
+
return copy(e);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/** Every mark that holds now: [{ envId, name, at, until, closedAt, closedLocal, holdUntil, holdUntilLocal, sessionId, owners }]. */
|
|
149
|
+
export function listOutsideCloses(now = Date.now()) {
|
|
150
|
+
if (prune(now)) save();
|
|
151
|
+
return [...load().values()].map((e) => ({
|
|
152
|
+
...copy(e),
|
|
153
|
+
closedAt: new Date(e.at).toISOString(), closedLocal: formatLocalTime(e.at),
|
|
154
|
+
holdUntil: new Date(e.until).toISOString(), holdUntilLocal: formatLocalTime(e.until),
|
|
155
|
+
}));
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/** The profile runs again (attached to, or started by someone allowed to): the mark is over for everybody. */
|
|
159
|
+
export function clearOutsideClose(envId) {
|
|
160
|
+
if (!envId) return false;
|
|
161
|
+
const had = load().delete(String(envId));
|
|
162
|
+
if (had) save();
|
|
163
|
+
return had;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* The refusal of a start of a profile closed outside SynaBun. `label`: how the profile is named (`MoreLogin profile
|
|
168
|
+
* "P-4" (id)`), else the name the mark kept, else its id. Code MORELOGIN_CLOSED_OUTSIDE, status 409, needsUser,
|
|
169
|
+
* closedAt, holdUntil; never retried by SynaBun, never answered with another profile.
|
|
170
|
+
*/
|
|
171
|
+
export function outsideCloseError(envId, entry, { label = null } = {}) {
|
|
172
|
+
const name = label || (entry?.name ? `MoreLogin profile "${entry.name}" (${envId})` : `MoreLogin profile ${envId}`);
|
|
173
|
+
const when = entry?.at ? formatLocalTime(entry.at) : 'an earlier moment';
|
|
174
|
+
const until = entry?.until ? ` SynaBun stops holding it at MoreLogin's daily reset (${formatLocalTime(entry.until)}).` : '';
|
|
175
|
+
const e = new Error(`${name} was closed outside SynaBun at ${when}, and SynaBun will not reopen it by itself: whoever closed it may have wanted it closed, and each start spends one of MoreLogin's daily launches. Nothing was started, and nothing was moved to another profile or browser. To go on, start the profile in MoreLogin or in SynaBun (Settings → Connected tools → MoreLogin → Start): browser calls then attach to it without a new launch. Otherwise wait for its next scheduled run, which starts it as usual.${until} This needs the user, not a retry: report it and stop`);
|
|
176
|
+
e.code = 'MORELOGIN_CLOSED_OUTSIDE';
|
|
177
|
+
e.status = 409;
|
|
178
|
+
e.needsUser = true;
|
|
179
|
+
e.envId = String(envId);
|
|
180
|
+
if (entry?.at) e.closedAt = new Date(entry.at).toISOString();
|
|
181
|
+
if (entry?.until) e.holdUntil = new Date(entry.until).toISOString();
|
|
182
|
+
return e;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/** Forget what is held in memory: the next call reads the file again (what a new process or a reload sees). */
|
|
186
|
+
export function _reloadOutsideClosesForTests() { _entries = null; _loadedFrom = null; }
|