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
|
@@ -22,6 +22,17 @@ import { createHash } from 'node:crypto';
|
|
|
22
22
|
import { existsSync } from 'node:fs';
|
|
23
23
|
import { spawn } from 'node:child_process';
|
|
24
24
|
import { registerBrowserNetworkEndpoint } from './browser-network-guard.js';
|
|
25
|
+
import { activeStartCooldown, clearStartCooldown, formatLocalTime, noteStartRefusal } from './morelogin-start-cooldown.js';
|
|
26
|
+
import { clearOutsideClose, outsideCloseError, outsideCloseFor } from './morelogin-outside-close.js';
|
|
27
|
+
export { listStartCooldowns, activeStartCooldown } from './morelogin-start-cooldown.js';
|
|
28
|
+
export { noteOutsideClose, outsideCloseFor, listOutsideCloses, clearOutsideClose, outsideCloseError, outsideCloseUntil } from './morelogin-outside-close.js';
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Who may start a profile closed outside SynaBun (lib/morelogin-outside-close.js) while its mark holds:
|
|
32
|
+
* `'owner'` (the owner's own action that is not Settings' Start: a session the owner's page creates) and
|
|
33
|
+
* `'schedule'` (a new scheduled firing's launch acquisition). Settings' Start is `opts.owner === true`. Nobody else.
|
|
34
|
+
*/
|
|
35
|
+
export const OUTSIDE_CLOSE_LIFTS = Object.freeze(['owner', 'schedule']);
|
|
25
36
|
|
|
26
37
|
export const DEFAULT_MORELOGIN_PORT = 40000;
|
|
27
38
|
// MoreLogin's documented local-API ports. 40000 is the HTTP API SynaBun drives; 15523 is the companion port its
|
|
@@ -140,7 +151,7 @@ const NEVER_CONNECTED_CODES = new Set([
|
|
|
140
151
|
export function _neverConnected(err) {
|
|
141
152
|
for (let e = err, i = 0; e && i < 4; e = e.cause, i++) {
|
|
142
153
|
if (NEVER_CONNECTED_CODES.has(e.code)) return true;
|
|
143
|
-
if (Array.isArray(e.errors) && e.errors.
|
|
154
|
+
if (Array.isArray(e.errors) && e.errors.length && e.errors.every(x => NEVER_CONNECTED_CODES.has(x?.code))) return true;
|
|
144
155
|
}
|
|
145
156
|
return false;
|
|
146
157
|
}
|
|
@@ -161,6 +172,7 @@ async function request(path, body, opts = {}) {
|
|
|
161
172
|
const hosts = [_preferredHost, ...LOOPBACK_HOSTS.filter(h => h !== _preferredHost)];
|
|
162
173
|
let res;
|
|
163
174
|
let lastErr = null;
|
|
175
|
+
const failures = [];
|
|
164
176
|
for (const host of hosts) {
|
|
165
177
|
const left = deadline - Date.now();
|
|
166
178
|
if (left <= 0) break;
|
|
@@ -176,6 +188,7 @@ async function request(path, body, opts = {}) {
|
|
|
176
188
|
break;
|
|
177
189
|
} catch (err) {
|
|
178
190
|
lastErr = err;
|
|
191
|
+
failures.push(err);
|
|
179
192
|
const timedOut = err?.name === 'TimeoutError' || err?.name === 'AbortError';
|
|
180
193
|
const retry = _neverConnected(err) || (timedOut && idempotent);
|
|
181
194
|
if (!retry) break;
|
|
@@ -186,6 +199,10 @@ async function request(path, body, opts = {}) {
|
|
|
186
199
|
const reason = !err ? `no time left of ${budget} ms` : (err?.cause?.code || err?.code || err?.message || err);
|
|
187
200
|
const e = new Error(`MoreLogin API unreachable on :${port} (${reason})`);
|
|
188
201
|
e.code = 'MORELOGIN_UNREACHABLE';
|
|
202
|
+
// A response/abort deadline says nothing about whether a browser is live. Both loopback hosts must have
|
|
203
|
+
// provably never connected (UND_ERR_CONNECT_TIMEOUT is connect-only); even one ambiguous attempt, or a
|
|
204
|
+
// deadline that left a host untested, keeps the OpenCode pre-flight closed.
|
|
205
|
+
e.unavailable = failures.length === hosts.length && failures.every(_neverConnected);
|
|
189
206
|
throw e;
|
|
190
207
|
}
|
|
191
208
|
let json = null;
|
|
@@ -283,6 +300,40 @@ export async function listProfiles(opts = {}) {
|
|
|
283
300
|
return profileRows(data).map(normalizeProfile).filter(p => p.id);
|
|
284
301
|
}
|
|
285
302
|
|
|
303
|
+
/** Complete enumeration for absence decisions. Partial, repeated and changing pages refuse. */
|
|
304
|
+
export async function listCompleteProfiles(opts = {}) {
|
|
305
|
+
const out = [], seen = new Set();
|
|
306
|
+
let total;
|
|
307
|
+
for (let pageNo = 1; pageNo <= 1000; pageNo++) {
|
|
308
|
+
let data;
|
|
309
|
+
// OpenCode can bound the first offline lookup without shortening later pages of a reachable account.
|
|
310
|
+
try { data = await request('/api/env/page', { pageNo, pageSize: 100 },
|
|
311
|
+
pageNo === 1 && opts.firstPageTimeout ? { ...opts, timeout: opts.firstPageTimeout } : opts); }
|
|
312
|
+
catch (error) {
|
|
313
|
+
// A partial live listing is unreadable, never evidence that MoreLogin was absent at pre-flight.
|
|
314
|
+
if (pageNo > 1) error.apiAnswered = true;
|
|
315
|
+
throw error;
|
|
316
|
+
}
|
|
317
|
+
if (!Array.isArray(data) && !PROFILE_LIST_KEYS.some(k => Array.isArray(data?.[k]))) throw shapeError(data);
|
|
318
|
+
const rows = profileRows(data);
|
|
319
|
+
if (data?.total != null && !/^(0|[1-9][0-9]*)$/.test(String(data.total))) throw shapeError(data);
|
|
320
|
+
const count = data?.total == null ? undefined : Number(data.total);
|
|
321
|
+
if (count !== undefined && (!Number.isSafeInteger(count) || count < 0 || (total !== undefined && count !== total))) throw shapeError(data);
|
|
322
|
+
if (pageNo > 1 && count !== total) throw shapeError(data);
|
|
323
|
+
total = count;
|
|
324
|
+
for (const row of rows) {
|
|
325
|
+
if (!row?.id || !['string', 'number'].includes(typeof row.id) || !String(row.id).trim() || /[\u0000-\u001f]/.test(String(row.id))
|
|
326
|
+
|| (typeof row.id === 'number' && !Number.isSafeInteger(row.id)) || seen.has(String(row.id))) throw shapeError(data);
|
|
327
|
+
seen.add(String(row.id)); out.push(normalizeProfile(row));
|
|
328
|
+
}
|
|
329
|
+
if (total !== undefined) {
|
|
330
|
+
if (out.length > total || (!rows.length && out.length < total)) throw shapeError(data);
|
|
331
|
+
if (out.length === total) return out;
|
|
332
|
+
} else if (!rows.length) return out;
|
|
333
|
+
}
|
|
334
|
+
throw shapeError(null);
|
|
335
|
+
}
|
|
336
|
+
|
|
286
337
|
/**
|
|
287
338
|
* Lightweight reachability probe. Never throws — returns {running, count}.
|
|
288
339
|
* `running` means the local API answered at all: an answer that is an HTTP or API
|
|
@@ -447,7 +498,8 @@ export async function profileKernelOf(envId, opts = {}) {
|
|
|
447
498
|
const id = String(envId);
|
|
448
499
|
if (_chromiumProfiles.has(id)) return 'chromium';
|
|
449
500
|
let kernel = null;
|
|
450
|
-
|
|
501
|
+
// `opts.knownStatus`: the status row the caller has just read (startProfile asks it first): not asked again.
|
|
502
|
+
try { kernel = profileKernel(opts.knownStatus !== undefined ? opts.knownStatus : statusRow(await profileStatus(id, opts))); }
|
|
451
503
|
catch { /* unreachable: the start says so itself */ }
|
|
452
504
|
if (!kernel) {
|
|
453
505
|
try { kernel = profileKernel(await profileDetail(id, opts)); } catch { /* a MoreLogin without the call */ }
|
|
@@ -589,24 +641,139 @@ export function notDevToolsError(envId, port, seen = {}) {
|
|
|
589
641
|
return e;
|
|
590
642
|
}
|
|
591
643
|
|
|
644
|
+
/** MoreLogin's answer to a start over its plan's daily start quota ("The daily startup limit is exceeded…"). */
|
|
645
|
+
export const MORELOGIN_DAILY_START_LIMIT = 19124;
|
|
646
|
+
|
|
647
|
+
/** A refusal that names the plan's limits (the daily start quota, or another "upgrade the package" answer). */
|
|
648
|
+
export function isPlanLimitRefusal(apiCode, msg) {
|
|
649
|
+
return Number(apiCode) === MORELOGIN_DAILY_START_LIMIT
|
|
650
|
+
|| /\b(daily|startup|start(?:ing)?)\b[^.]*\blimit\b|\bupgrade (?:the|your) (?:package|plan)\b/i.test(String(msg || ''));
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
/**
|
|
654
|
+
* The error of a start MoreLogin refused (its `/api/env/start` answered a non-zero code and the profile has no
|
|
655
|
+
* debug port either). It carries MoreLogin's own reason, `code` MORELOGIN_START_REFUSED, `apiCode`, and
|
|
656
|
+
* `needsUser` true: retrying, another model or another run hits the same answer until the user acts (a plan limit
|
|
657
|
+
* resets or is raised, the profile is fixed in MoreLogin).
|
|
658
|
+
*/
|
|
659
|
+
export function startRefusedError(envId, err, { resetAt = null, held = false } = {}) {
|
|
660
|
+
const apiCode = err?.apiCode ?? null;
|
|
661
|
+
const reason = String(err?.reason || err?.message || err || 'no reason given').replace(/^MoreLogin API \/api\/env\/start:\s*/, '');
|
|
662
|
+
const planLimit = err?.planLimit ?? isPlanLimitRefusal(apiCode, reason);
|
|
663
|
+
const advice = planLimit
|
|
664
|
+
? 'This is a limit of the MoreLogin plan, not a fault in SynaBun or the profile: starts work again after MoreLogin\'s daily reset or once the plan is upgraded in MoreLogin. Retrying now fails the same way; a profile that is already open does not need a start'
|
|
665
|
+
: 'Retrying fails the same way until this is fixed in MoreLogin';
|
|
666
|
+
// `resetAt` (ms): when MoreLogin's day starts again (lib/morelogin-start-cooldown.js). `held`: this start was not
|
|
667
|
+
// asked of MoreLogin at all, because the refusal is still in force.
|
|
668
|
+
const reset = resetAt
|
|
669
|
+
? `. MoreLogin's daily starts reset at ${formatLocalTime(resetAt)}; ${held ? 'SynaBun did not ask MoreLogin again: until then every start of this profile fails at once' : 'until then SynaBun does not ask MoreLogin to start this profile again'}`
|
|
670
|
+
: '';
|
|
671
|
+
const e = new Error(`MoreLogin refused to start profile ${envId}: ${reason}${apiCode != null ? ` (MoreLogin code ${apiCode})` : ''}. ${advice}${reset}`);
|
|
672
|
+
e.code = 'MORELOGIN_START_REFUSED';
|
|
673
|
+
e.apiCode = apiCode;
|
|
674
|
+
e.planLimit = !!planLimit;
|
|
675
|
+
e.needsUser = true;
|
|
676
|
+
e.reason = reason;
|
|
677
|
+
if (resetAt) e.resetAt = new Date(resetAt).toISOString();
|
|
678
|
+
if (held) e.cooldown = true;
|
|
679
|
+
return e;
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
/** Whether a status row says the profile's browser is up with a DevTools port SynaBun can attach to. */
|
|
683
|
+
function runningWithPort(row) {
|
|
684
|
+
if (!extractDebugPort(row)) return false;
|
|
685
|
+
const state = String(row?.status ?? row?.localStatus ?? '');
|
|
686
|
+
return !/stop|clos|fail|error/i.test(state);
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
// One start per profile at a time: a second caller waits for the first and then looks again (it then finds the
|
|
690
|
+
// profile running and attaches, or finds the refusal held), so two runs never spend two launches on one profile.
|
|
691
|
+
const _startsInFlight = new Map(); // envId → promise
|
|
692
|
+
|
|
592
693
|
/**
|
|
593
|
-
* Start (launch) a profile and return { debugPort, webdriver, kernel, raw }.
|
|
594
|
-
*
|
|
694
|
+
* Start (launch) a profile and return { debugPort, webdriver, kernel, raw, alreadyRunning? }.
|
|
695
|
+
* Asks the status first and attaches to a profile that is already running (`alreadyRunning: true`, no launch
|
|
696
|
+
* spent); recovers the debugPort via status when MoreLogin answers a start with "already running".
|
|
697
|
+
* A start MoreLogin refused for the plan's daily limit is held until MoreLogin's day resets
|
|
698
|
+
* (lib/morelogin-start-cooldown.js): meanwhile every start of that profile fails at once, without asking MoreLogin.
|
|
595
699
|
*
|
|
596
700
|
* `opts.requireCdp` (a start SynaBun will drive, never the Settings Start button): a Firefox-type profile is
|
|
597
701
|
* refused with MORELOGIN_NOT_CHROMIUM before it is started when MoreLogin says what it is up front, and right
|
|
598
702
|
* after the start when only the start's answer says it. It is never closed here: it may be the user's own window.
|
|
703
|
+
*
|
|
704
|
+
* `opts.refuseStart(envId)` (the caller's own reasons not to spend a launch): asked only when a launch would be
|
|
705
|
+
* needed, after the status said the profile is not running; an Error it returns is thrown and MoreLogin is not asked.
|
|
706
|
+
* A running profile is attached to whatever it says. The owner's own Start (`opts.owner`) is never asked it.
|
|
707
|
+
*
|
|
708
|
+
* A profile closed outside SynaBun (lib/morelogin-outside-close.js) is refused here for every caller, with
|
|
709
|
+
* MORELOGIN_CLOSED_OUTSIDE, before MoreLogin is asked, unless `opts.owner` or `opts.allowAfterOutsideClose` is
|
|
710
|
+
* `'owner'` / `'schedule'` (OUTSIDE_CLOSE_LIFTS). `opts.profileLabel(envId, name)` names the profile in the refusal.
|
|
599
711
|
*/
|
|
600
712
|
export async function startProfile(envId, opts = {}) {
|
|
601
|
-
|
|
713
|
+
const id = String(envId);
|
|
714
|
+
for (;;) {
|
|
715
|
+
const running = _startsInFlight.get(id);
|
|
716
|
+
if (!running) break;
|
|
717
|
+
try { await running; } catch { /* its own caller reports it; this one looks again below */ }
|
|
718
|
+
}
|
|
719
|
+
// Reuse before start: MoreLogin spends a launch of the plan's daily quota on every start of a profile that is
|
|
720
|
+
// not running. A running profile with a DevTools port is attached to as it is: no /api/env/start.
|
|
721
|
+
let st = null;
|
|
722
|
+
try { st = await profileStatus(id, opts); }
|
|
723
|
+
catch (err) { if (err?.code === 'MORELOGIN_UNREACHABLE') throw err; }
|
|
724
|
+
const row = statusRow(st);
|
|
725
|
+
if (runningWithPort(row)) {
|
|
726
|
+
const webdriver = row.webdriver || null;
|
|
727
|
+
const kernel = profileKernel({ webdriver });
|
|
728
|
+
if (opts.requireCdp && kernel === 'firefox') {
|
|
729
|
+
throw notChromiumError(id, { started: false, evidence: 'MoreLogin lists it as a Firefox profile' });
|
|
730
|
+
}
|
|
731
|
+
if (kernel === 'chromium') _chromiumProfiles.add(id);
|
|
732
|
+
return { debugPort: extractDebugPort(row), webdriver, kernel, raw: row, alreadyRunning: true };
|
|
733
|
+
}
|
|
734
|
+
// The caller's own reason not to start it: refused before anything else is asked of MoreLogin. Never for the
|
|
735
|
+
// owner's own Start.
|
|
736
|
+
if (opts.owner !== true && typeof opts.refuseStart === 'function') {
|
|
737
|
+
const refusal = opts.refuseStart(id);
|
|
738
|
+
if (refusal) throw refusal;
|
|
739
|
+
}
|
|
740
|
+
// Closed outside SynaBun (lib/morelogin-outside-close.js): no automatic path starts it again, whoever asks (a
|
|
741
|
+
// browser call, a loop's recovery, an agent's start, a script). Only the owner's start and a new scheduled firing go
|
|
742
|
+
// past it; a running profile was attached to above, whatever the mark says.
|
|
743
|
+
if (opts.owner !== true && !OUTSIDE_CLOSE_LIFTS.includes(opts.allowAfterOutsideClose)) {
|
|
744
|
+
const closed = outsideCloseFor(id);
|
|
745
|
+
if (closed) {
|
|
746
|
+
const label = typeof opts.profileLabel === 'function' ? opts.profileLabel(id, closed.name) : null;
|
|
747
|
+
throw outsideCloseError(id, closed, { label: label || null });
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
// MoreLogin refused this profile's start for the plan's daily limit, and its day has not reset yet: fail at once,
|
|
751
|
+
// without asking. The owner's own Start (Settings, `opts.owner`) still asks once: the plan may have been raised.
|
|
752
|
+
const held = opts.owner === true ? null : activeStartCooldown(id);
|
|
753
|
+
if (held) {
|
|
754
|
+
throw startRefusedError(id, { apiCode: held.apiCode, reason: held.reason || 'The daily startup limit is exceeded', planLimit: true }, { resetAt: held.until, held: true });
|
|
755
|
+
}
|
|
756
|
+
// Another start of this profile began while the status was asked: wait for it, then look again.
|
|
757
|
+
if (_startsInFlight.has(id)) return startProfile(id, opts);
|
|
758
|
+
const start = launchProfile(id, { ...opts, knownStatus: row ?? null });
|
|
759
|
+
_startsInFlight.set(id, start);
|
|
760
|
+
try { return await start; }
|
|
761
|
+
finally { if (_startsInFlight.get(id) === start) _startsInFlight.delete(id); }
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
async function launchProfile(envId, { knownStatus, ...opts }) {
|
|
765
|
+
if (opts.requireCdp && await profileKernelOf(envId, { ...opts, knownStatus }) === 'firefox') {
|
|
602
766
|
throw notChromiumError(envId, { evidence: 'MoreLogin lists it as a Firefox profile' });
|
|
603
767
|
}
|
|
604
768
|
let data = null;
|
|
769
|
+
let startErr = null;
|
|
605
770
|
try {
|
|
606
771
|
data = await request('/api/env/start', { envId: String(envId), ...(opts.startArgs || {}) }, opts);
|
|
607
772
|
} catch (err) {
|
|
608
773
|
if (err?.code === 'MORELOGIN_UNREACHABLE' || err?.code === 'MORELOGIN_HTTP' || err?.code === 'MORELOGIN_SHAPE') throw err;
|
|
609
|
-
// MORELOGIN_API (e.g. "already running") → fall through to status recovery.
|
|
774
|
+
// MORELOGIN_API (e.g. "already running") → fall through to status recovery. Kept: when the status has no
|
|
775
|
+
// port either, MoreLogin refused the start, and its own reason is the one to report.
|
|
776
|
+
startErr = err;
|
|
610
777
|
}
|
|
611
778
|
let port = extractDebugPort(data);
|
|
612
779
|
let webdriver = data && data.webdriver;
|
|
@@ -622,8 +789,18 @@ export async function startProfile(envId, opts = {}) {
|
|
|
622
789
|
if (opts.requireCdp && kernel === 'firefox') {
|
|
623
790
|
throw notChromiumError(envId, { started: true, evidence: `its browser is ${webdriver}` });
|
|
624
791
|
}
|
|
792
|
+
if (!port && startErr) {
|
|
793
|
+
const refused = startRefusedError(envId, startErr);
|
|
794
|
+
// The plan's daily limit: remembered until MoreLogin's day resets, so no other run asks again before then.
|
|
795
|
+
const held = noteStartRefusal(envId, refused);
|
|
796
|
+
throw held ? startRefusedError(envId, refused, { resetAt: held.until }) : refused;
|
|
797
|
+
}
|
|
625
798
|
if (!port) throw new Error(`MoreLogin started env ${envId} but returned no debugPort`);
|
|
626
799
|
if (kernel === 'chromium') _chromiumProfiles.add(String(envId));
|
|
800
|
+
// A start that worked: whatever refusal was held for this profile is over (the quota was reset or raised), and so is
|
|
801
|
+
// a close outside SynaBun (the profile runs again).
|
|
802
|
+
clearStartCooldown(envId);
|
|
803
|
+
clearOutsideClose(envId);
|
|
627
804
|
return { debugPort: port, webdriver: webdriver || null, kernel, raw: data };
|
|
628
805
|
}
|
|
629
806
|
|
|
@@ -635,7 +812,13 @@ export async function startProfile(envId, opts = {}) {
|
|
|
635
812
|
* close only this connectOverCDP transport; MoreLogin owns the running browser.
|
|
636
813
|
*/
|
|
637
814
|
export async function attachProfileBrowser(chromium, endpoint, openPage) {
|
|
638
|
-
|
|
815
|
+
let browser;
|
|
816
|
+
try { browser = await chromium.connectOverCDP(endpoint); } catch (error) {
|
|
817
|
+
// The DevTools port answers but the browser holds no profile (its window was closed and its process lives on):
|
|
818
|
+
// said as that, with its own code, never as "open the MoreLogin app".
|
|
819
|
+
if (isWindowlessCdpError(error)) throw windowlessProfileError(null, endpoint, error);
|
|
820
|
+
throw error;
|
|
821
|
+
}
|
|
639
822
|
try {
|
|
640
823
|
const context = browser.contexts()[0];
|
|
641
824
|
if (!context) {
|
|
@@ -652,6 +835,35 @@ export async function attachProfileBrowser(chromium, endpoint, openPage) {
|
|
|
652
835
|
}
|
|
653
836
|
}
|
|
654
837
|
|
|
838
|
+
/**
|
|
839
|
+
* Chromium's answer to Playwright's first command over CDP (Browser.setDownloadBehavior for the default context) when
|
|
840
|
+
* the browser process has no default browser context: "Browser context management is not supported". Seen
|
|
841
|
+
* 2026-11-15 21:13:36 / 21:13:40 for P-4 (2120294461317124096): its window had been closed at 21:13:30.47 (MoreLogin's
|
|
842
|
+
* envkit log: close_click + CloseBrowser), but its kernel process (pid 82177) did not exit and MoreLogin logged no
|
|
843
|
+
* OnCloseBrowser for it, so MoreLogin's status still listed it running on DevTools port 63119 (the same port P-4 was
|
|
844
|
+
* attached on at 21:00:41): the port answered /json/version and the websocket, and the browser had no profile left.
|
|
845
|
+
* Both P-1 and P-4 run the same kernel (chrome_64_154.0): not a kernel difference. At 21:15:46 the same pid opened a
|
|
846
|
+
* window again ("kernel-> start success", no OpenBrowser), and the profile worked as before.
|
|
847
|
+
*/
|
|
848
|
+
export function isWindowlessCdpError(error) {
|
|
849
|
+
return /Browser context management is not supported/i.test(String(error?.message || error || ''));
|
|
850
|
+
}
|
|
851
|
+
|
|
852
|
+
/**
|
|
853
|
+
* The error of a profile MoreLogin lists as running whose browser has no open window or profile (closing, or not
|
|
854
|
+
* fully started). Code MORELOGIN_PROFILE_WINDOWLESS, needsUser: SynaBun did not start it (no launch was spent) and
|
|
855
|
+
* does not close it.
|
|
856
|
+
*/
|
|
857
|
+
export function windowlessProfileError(envId, endpoint, cause = null) {
|
|
858
|
+
const port = (() => { try { return new URL(String(endpoint)).port || null; } catch { return null; } })();
|
|
859
|
+
const e = new Error(`MoreLogin lists ${envId ? `profile ${envId}` : 'the profile'} as running${port ? ` (DevTools port ${port})` : ''}, but its browser has no open window or profile: it was closed and its process did not end, or it is still starting. SynaBun attached to nothing, started nothing (no launch was spent) and closed nothing. Open the profile's window again in MoreLogin, or close it fully there and start it again`);
|
|
860
|
+
e.code = 'MORELOGIN_PROFILE_WINDOWLESS';
|
|
861
|
+
e.needsUser = true;
|
|
862
|
+
if (envId) e.envId = String(envId);
|
|
863
|
+
if (cause) e.cause = cause;
|
|
864
|
+
return e;
|
|
865
|
+
}
|
|
866
|
+
|
|
655
867
|
/** Stop (close) a profile. */
|
|
656
868
|
export async function stopProfile(envId, opts = {}) {
|
|
657
869
|
return request('/api/env/close', { envId: String(envId) }, opts);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isolatedServeFailure } from './opencode-launch-error.js';
|
|
1
2
|
import { retainExternalRefs } from './mcp-external-servers.js';
|
|
2
3
|
import { storedToolList, toolListRecord, readStoredToolListRecord } from './tool-lists.js';
|
|
3
4
|
import { existsSync, mkdirSync, readFileSync, renameSync, unlinkSync, writeFileSync } from 'node:fs';
|
|
@@ -64,6 +65,7 @@ function rawDescriptor(record) {
|
|
|
64
65
|
claimedBy: record.claimedBy || null,
|
|
65
66
|
claimedAt: record.claimedAt || null,
|
|
66
67
|
error: record.error || null,
|
|
68
|
+
...(record.errorCode ? { errorCode: record.errorCode, offenders: record.offenders } : {}),
|
|
67
69
|
version: Number(record.version) || 0,
|
|
68
70
|
// Task-mode (assistant dispatch) fields. Absent/null for classic loops so
|
|
69
71
|
// existing consumers (router, sidepanels, schedules) are unaffected.
|
|
@@ -820,6 +822,11 @@ export class NativeLoopRuntime {
|
|
|
820
822
|
async _drive(record) {
|
|
821
823
|
let failures = 0;
|
|
822
824
|
while (this.isAlive(record.runId)) {
|
|
825
|
+
// Asked to end when its turn ends (finishAfterTurn): stopped here, before another iteration starts.
|
|
826
|
+
if (record.finishAfterTurn) {
|
|
827
|
+
await this.stop(record.runId, record.finishAfterTurn);
|
|
828
|
+
return;
|
|
829
|
+
}
|
|
823
830
|
const state = this._readState(record.runId);
|
|
824
831
|
if (!state || state.active === false) {
|
|
825
832
|
await this.stop(record.runId, state ? 'state_inactive' : 'state_removed');
|
|
@@ -951,12 +958,13 @@ export class NativeLoopRuntime {
|
|
|
951
958
|
clearTimeout(record.timer);
|
|
952
959
|
record.status = status === 'interrupted' ? 'interrupted' : 'failed';
|
|
953
960
|
record.error = errorText(error);
|
|
961
|
+
if (error?.code) { const safe = isolatedServeFailure(error); record.errorCode = safe.code; record.offenders = safe.offenders; }
|
|
954
962
|
record.stoppedReason = reason;
|
|
955
963
|
record.completedAt = iso(this.now());
|
|
956
964
|
if (record._resolveIdentity) { record._resolveIdentity(null); record._resolveIdentity = null; }
|
|
957
965
|
try { record.startupAbortController?.abort(reason); } catch {}
|
|
958
966
|
if (record._cancelStartup) { record._cancelStartup(reason); record._cancelStartup = null; }
|
|
959
|
-
this._writeTerminalState(record, { active: false, pending: false, completedAt: record.completedAt, stoppedReason: reason, error: record.error });
|
|
967
|
+
this._writeTerminalState(record, { active: false, pending: false, completedAt: record.completedAt, stoppedReason: reason, error: record.error, errorCode: record.errorCode, offenders: record.offenders });
|
|
960
968
|
try { await record.adapter?.abort?.(reason); } catch {}
|
|
961
969
|
try { await record.adapter?.dispose?.({ preserveSession: true }); } catch {}
|
|
962
970
|
this._releaseRuntimeRefs(record);
|
|
@@ -999,6 +1007,21 @@ export class NativeLoopRuntime {
|
|
|
999
1007
|
return true;
|
|
1000
1008
|
}
|
|
1001
1009
|
|
|
1010
|
+
/**
|
|
1011
|
+
* A loop that cannot go on (server.js: its MoreLogin profile was closed outside SynaBun and SynaBun does not reopen it
|
|
1012
|
+
* for that loop): it ends with `reason` once its current turn ends, never by starting the next iteration. The turn
|
|
1013
|
+
* under way is not cut short (it reports the refusal it got). A task run (a dispatched run, runMode 'task') is left
|
|
1014
|
+
* alone: its brain decides what comes next. Returns whether the stop was set.
|
|
1015
|
+
*/
|
|
1016
|
+
finishAfterTurn(runId, reason = 'stopped') {
|
|
1017
|
+
const record = this.records.get(runId);
|
|
1018
|
+
if (!record || record.runMode === 'task' || record.stopping || !['starting', 'running'].includes(record.status)) return false;
|
|
1019
|
+
if (record.finishAfterTurn) return true;
|
|
1020
|
+
record.finishAfterTurn = String(reason || 'stopped').slice(0, 64);
|
|
1021
|
+
this.log(runId, 'native:finish-after-turn', `loop ends when its current turn ends (${record.finishAfterTurn})`, { iteration: record.currentIteration || null });
|
|
1022
|
+
return true;
|
|
1023
|
+
}
|
|
1024
|
+
|
|
1002
1025
|
isAlive(runId) {
|
|
1003
1026
|
const record = this.records.get(runId);
|
|
1004
1027
|
if (!record || !['starting', 'running'].includes(record.status)) return false;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
// A throwaway OpenCode build check, before a native context is admitted. MoreLogin's port protection has a
|
|
2
|
+
// 0.0.0.0 bypass (see the live diagnostic): it is additional protection, never permission to expose a new build.
|
|
3
|
+
import { spawn } from 'node:child_process';
|
|
4
|
+
import { createServer } from 'node:net';
|
|
5
|
+
import { mkdtempSync, mkdirSync, writeFileSync, rmSync } from 'node:fs';
|
|
6
|
+
import { tmpdir } from 'node:os';
|
|
7
|
+
import { join } from 'node:path';
|
|
8
|
+
import { serveSpecFor, servePasswordReader } from './opencode-protocol.js';
|
|
9
|
+
import { moreLoginProcessesRunning } from './process-identity.js';
|
|
10
|
+
|
|
11
|
+
/** Strictly parse the observed MoreLogin /api/env/detail response; never retain cookies or other profile data. */
|
|
12
|
+
export function portProtectionOf(detail) {
|
|
13
|
+
const value = detail?.advancedSetting?.port_scan_protection;
|
|
14
|
+
if (!value || ![0, 1].includes(value.switcher) || typeof value.value !== 'string') return null;
|
|
15
|
+
const words = value.value.trim() ? value.value.split(',').map(s => s.trim()) : [];
|
|
16
|
+
if (words.some(s => !/^\d{1,5}$/.test(s) || +s < 1 || +s > 65535)) return null;
|
|
17
|
+
return { enabled: value.switcher === 1, ports: [...new Set(words.map(Number))] };
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// Never copy arbitrary API response text: it can contain profile credentials.
|
|
21
|
+
export function moreLoginFailureDetail(error) {
|
|
22
|
+
if (error?.status === 401 || error?.status === 403 || /auth|sign|unauthor|forbidden/i.test(error?.message || '')) return 'authentication refused';
|
|
23
|
+
if (error?.status === 404 || /not found|not exist/i.test(error?.message || '')) return 'profile not found';
|
|
24
|
+
if (error?.code === 'MORELOGIN_UNREACHABLE') return 'transport unavailable';
|
|
25
|
+
if (error?.code === 'MORELOGIN_SHAPE') return 'malformed API response';
|
|
26
|
+
return 'API request failed';
|
|
27
|
+
}
|
|
28
|
+
function profileError(code, message, envId) {
|
|
29
|
+
return Object.assign(new Error(message), { code, offenders: envId ? [{ envId, reason: code }] : [] });
|
|
30
|
+
}
|
|
31
|
+
export async function reconcilePreflightProfiles(profiles, list, { requested = [], allowUnavailable = false,
|
|
32
|
+
browserProcesses = moreLoginProcessesRunning, log = () => {} } = {}) {
|
|
33
|
+
let live;
|
|
34
|
+
try { live = await list(); } catch (error) {
|
|
35
|
+
// Optional only for starting OpenCode: keep verifying its build/serves without MoreLogin port exclusions.
|
|
36
|
+
// Browser work still requires the API, and native attachment still waits for the serve boundary. Never
|
|
37
|
+
// interpret an answering API (including a partial listing), a reset or an unknown failure as an empty list.
|
|
38
|
+
if (allowUnavailable && error?.code === 'MORELOGIN_UNREACHABLE' && error.unavailable === true && !error.apiAnswered) {
|
|
39
|
+
// Profile windows can outlive the desktop API, including windows SynaBun has never attached to.
|
|
40
|
+
let running = null;
|
|
41
|
+
try { running = await browserProcesses(); } catch { /* unknown: fail closed, without OS/process details */ }
|
|
42
|
+
if (running !== false) throw profileError(running === true ? 'MORELOGIN_BROWSER_RUNNING' : 'MORELOGIN_PROCESS_UNREADABLE',
|
|
43
|
+
running === true ? 'MoreLogin API is unavailable but a MoreLogin process is still running. OpenCode build verification has not started.'
|
|
44
|
+
: 'MoreLogin API is unavailable and browser processes could not be checked. OpenCode build verification has not started.');
|
|
45
|
+
log('MoreLogin local API unavailable (MORELOGIN_UNREACHABLE) and no MoreLogin browser processes found; continuing OpenCode build verification without profile port exclusions. Native browser attachment still requires verified serves.');
|
|
46
|
+
return [];
|
|
47
|
+
}
|
|
48
|
+
throw profileError('MORELOGIN_LIST_UNREADABLE', `MoreLogin profile listing failed: ${moreLoginFailureDetail(error)}. OpenCode build verification has not started.`);
|
|
49
|
+
}
|
|
50
|
+
if (!Array.isArray(live) || live.moreloginError || live.some(p => !p?.id)) throw profileError('MORELOGIN_LIST_UNREADABLE', 'MoreLogin profile listing is malformed or incomplete.');
|
|
51
|
+
const ids = new Set(live.map(p => String(p.id)));
|
|
52
|
+
for (const id of requested) if (!ids.has(String(id))) throw profileError('MORELOGIN_PROFILE_MISSING', `Explicitly requested MoreLogin profile ${id} is missing.`, String(id));
|
|
53
|
+
return profiles.filter(p => { if (ids.has(p.envId)) return true; log(`Skipping stale MoreLogin profile ${p.envId}: absent from the complete live listing.`); return false; });
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export async function preflightExcludedPorts(profiles, readDetail) {
|
|
57
|
+
const ports = new Set();
|
|
58
|
+
for (const profile of profiles) {
|
|
59
|
+
const name = profile.name ? `${profile.name} (${profile.envId})` : profile.envId;
|
|
60
|
+
let policy, detail = 'malformed port protection policy';
|
|
61
|
+
try { policy = portProtectionOf(await readDetail(profile.envId)); } catch (error) { detail = moreLoginFailureDetail(error); }
|
|
62
|
+
if (!policy) throw profileError('MORELOGIN_POLICY_UNREADABLE', `MoreLogin profile ${name}: port protection could not be read from /api/env/detail (${detail}). Check the MoreLogin local API and try again; OpenCode build verification has not started.`, profile.envId);
|
|
63
|
+
if (!policy.enabled) throw new Error(`MoreLogin profile ${name}: Port scan protection is off. Edit profile → Advanced settings → Port scan protection: Enable, then retry OpenCode build verification.`);
|
|
64
|
+
for (const port of policy.ports) ports.add(port);
|
|
65
|
+
}
|
|
66
|
+
return ports;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// The OS reserves a random loopback port until the moment before spawn. A competing process that wins that small
|
|
70
|
+
// release/spawn race cannot pass the boundary's process-bound probe and is never signalled by the pre-flight.
|
|
71
|
+
export async function reservePreflightPort(excluded) {
|
|
72
|
+
for (let attempt = 0; attempt < 128; attempt++) {
|
|
73
|
+
const server = createServer();
|
|
74
|
+
await new Promise((resolve, reject) => { server.once('error', reject); server.listen(0, '127.0.0.1', resolve); });
|
|
75
|
+
const port = server.address().port;
|
|
76
|
+
const release = () => new Promise(resolve => server.close(resolve));
|
|
77
|
+
if (!excluded.has(port)) return { port, release };
|
|
78
|
+
await release();
|
|
79
|
+
}
|
|
80
|
+
throw new Error('No random port outside the MoreLogin allow lists was available for OpenCode build verification');
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** track/verify/stop are the same boundary operations used for normal serves; stop confirms listener removal. */
|
|
84
|
+
export async function runOpencodeBuildPreflight(info, { excludedPorts = new Set(), track, verify, stop,
|
|
85
|
+
spawnProcess = spawn, reservePort = reservePreflightPort, startupMs = 15_000 } = {}) {
|
|
86
|
+
const reservation = await reservePort(excludedPorts);
|
|
87
|
+
let dir, proc, released = false, stopped = true;
|
|
88
|
+
try {
|
|
89
|
+
dir = mkdtempSync(join(tmpdir(), 'synabun-opencode-preflight-'));
|
|
90
|
+
for (const sub of ['home', 'config/opencode', 'data', 'state', 'cache', 'work']) mkdirSync(join(dir, sub), { recursive: true });
|
|
91
|
+
writeFileSync(join(dir, 'config/opencode/opencode.json'), '{"autoupdate":false,"share":"disabled","snapshots":false}');
|
|
92
|
+
const env = { PATH: process.env.PATH, ...(process.env.SystemRoot ? { SystemRoot: process.env.SystemRoot } : {}),
|
|
93
|
+
HOME: join(dir, 'home'), USERPROFILE: join(dir, 'home'), XDG_CONFIG_HOME: join(dir, 'config'),
|
|
94
|
+
XDG_DATA_HOME: join(dir, 'data'), XDG_STATE_HOME: join(dir, 'state'), XDG_CACHE_HOME: join(dir, 'cache'),
|
|
95
|
+
OPENCODE_DISABLE_MODELS_FETCH: '1', OPENCODE_DISABLE_PROJECT_CONFIG: '1', OPENCODE_DISABLE_CLAUDE_CODE: '1', OPENCODE_DISABLE_AUTOUPDATE: '1' };
|
|
96
|
+
const spec = serveSpecFor(reservation.port, { passwordFrom: 'stdout', env });
|
|
97
|
+
await reservation.release(); released = true;
|
|
98
|
+
proc = spawnProcess(info.identity.realpath, spec.args, { cwd: join(dir, 'work'), env: spec.env, stdio: ['ignore', 'pipe', 'pipe'], windowsHide: true });
|
|
99
|
+
track(proc, { ...info, port: reservation.port, safe: true });
|
|
100
|
+
const read = servePasswordReader();
|
|
101
|
+
let password = null, error = null;
|
|
102
|
+
proc.on('error', e => { error = e; });
|
|
103
|
+
proc.stdout?.on('data', chunk => { password = read(chunk) || password; });
|
|
104
|
+
proc.stderr?.resume(); // Drain, never log raw output (it can contain a private password).
|
|
105
|
+
const until = Date.now() + startupMs;
|
|
106
|
+
while (!password && !error && proc.exitCode == null && proc.signalCode == null && Date.now() < until) await new Promise(r => setTimeout(r, 25));
|
|
107
|
+
if (!password) throw new Error(error ? 'OpenCode build verification could not start the executable' : 'OpenCode build verification did not receive a private stdout password');
|
|
108
|
+
return await verify(proc, { pid: proc.pid, password });
|
|
109
|
+
} finally {
|
|
110
|
+
if (!released) await reservation.release();
|
|
111
|
+
if (proc) stopped = await stop(proc);
|
|
112
|
+
// If termination cannot be confirmed, keep its state folder and the boundary's exposure record.
|
|
113
|
+
if (dir && stopped) rmSync(dir, { recursive: true, force: true });
|
|
114
|
+
if (!stopped) throw new Error(`OpenCode build verification could not confirm its throwaway serve stopped on port ${reservation.port}`);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// Launch diagnostics are safe to show in a run; credentials never cross this boundary.
|
|
2
|
+
export function sanitizeLaunchText(value) {
|
|
3
|
+
return String(value || '').replace(/(password|token|secret|api[_ -]?key|authorization)(\s*[=:]\s*|\s+)([^\r\n,;]+)/gi, '$1=[redacted]')
|
|
4
|
+
.replace(/(https?:\/\/)[^\s/@]+:[^\s/@]+@/gi, '$1[redacted]@').slice(0, 2000);
|
|
5
|
+
}
|
|
6
|
+
export function isolatedServeFailure(error) {
|
|
7
|
+
const code = /^[A-Z][A-Z0-9_]{0,80}$/.test(error?.code || '') ? error.code : 'OPENCODE_SERVE_START_FAILED';
|
|
8
|
+
const reason = sanitizeLaunchText(error?.message || 'unknown launch failure');
|
|
9
|
+
const offenders = (Array.isArray(error?.offenders) ? error.offenders : []).map(o => Object.fromEntries(
|
|
10
|
+
['envId', 'reason', 'pid', 'port', 'path', 'version', 'check', 'detail', 'state'].filter(k => o[k] != null).map(k => [k, typeof o[k] === 'number' ? o[k] : sanitizeLaunchText(o[k])])));
|
|
11
|
+
const cause = Object.assign(new Error(reason), { code, offenders });
|
|
12
|
+
return Object.assign(new Error(`OpenCode isolated native serve failed to start: [${code}] ${reason}`, { cause }), { code, offenders });
|
|
13
|
+
}
|