synabun 2.3.1 → 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 +24 -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 +1117 -47
- package/neural-interface/i18n/pt-BR.json +1117 -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-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/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/effort-levels.js +10 -1
- 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 +194 -8
- package/neural-interface/lib/native-loop-runtime.js +20 -0
- package/neural-interface/lib/opencode-build-preflight.js +16 -1
- package/neural-interface/lib/opencode-native-boundary.js +83 -13
- package/neural-interface/lib/opencode-serve-records.js +14 -9
- 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 +68 -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/package-lock.json +2 -2
- package/neural-interface/package.json +1 -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/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 +682 -50
- 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-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 +355 -400
- 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 +1050 -140
- 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
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MoreLogin's daily start quota, remembered per profile (2026-11-15).
|
|
3
|
+
*
|
|
4
|
+
* MoreLogin's plan caps how many profile launches an account makes per day: past it, `/api/env/start` answers code
|
|
5
|
+
* 19124 ("The daily startup limit is exceeded. Please upgrade the package to increase the daily limit."). About 90
|
|
6
|
+
* scheduled runs a day share one profile, and each failed run asked for a start at least twice (strategy 2 of
|
|
7
|
+
* acquireSharedBrowserTab, then the recover / create paths), so the whole afternoon kept asking MoreLogin for starts
|
|
8
|
+
* it had already refused. Once a start of a profile is refused for the plan's limit, SynaBun does not ask MoreLogin to
|
|
9
|
+
* start that profile again until MoreLogin's next day: every start fails at once with the same error
|
|
10
|
+
* (MORELOGIN_START_REFUSED, the same apiCode / planLimit / needsUser) and the reset time.
|
|
11
|
+
*
|
|
12
|
+
* When MoreLogin's day starts, found from MoreLogin's own logs (`~/Library/Application Support/MoreLogin/logs`):
|
|
13
|
+
* every launch is an `envkit.*.log` line "get shop detail:-{"id":"<envId>",…}" (one `main.*.log` "onopensucceedbrower"
|
|
14
|
+
* each). Today's (2026-11-15) first refusal was at 15:02:54 local time (UTC-03:00, 18:02:54 UTC), 33 s after the
|
|
15
|
+
* last launch that worked (15:02:21). Launches counted before it, per candidate day:
|
|
16
|
+
* - local day (UTC-03:00, from 03:00 UTC): 13 today (plus an unlogged stretch 00:00-02:57 local), while the
|
|
17
|
+
* local day 2026-11-14 had 23 launches that all worked: not a cap of 20;
|
|
18
|
+
* - UTC+8 day (from 16:00 UTC, 13:00 local): only 5 launches in the window that refused, while the UTC+8 day before
|
|
19
|
+
* it took 24: ruled out;
|
|
20
|
+
* - UTC day (from 00:00 UTC, 21:00 local): 18 logged today plus the unlogged stretch, and no earlier UTC day above
|
|
21
|
+
* 19 (11-08: 6, 11-09: 2, 11-10: 16, 11-11: 17, 11-12: 5, 11-13: 9, 11-14: 19). MoreLogin's own counter read
|
|
22
|
+
* "5/20" just before the launch of 2026-11-14 03:08:48 local and "6/20" after it: 5 is exactly the count of that
|
|
23
|
+
* UTC day so far (the local day had 4).
|
|
24
|
+
* So the quota is 20 launches per UTC day for the account, and it resets at 00:00 UTC. A launch is spent only when the
|
|
25
|
+
* profile is not running already (startProfile asks the status first and attaches to a running profile).
|
|
26
|
+
*
|
|
27
|
+
* A refusal right after a reset (within RESET_SLACK_MS) holds only RESET_SLACK_MS: MoreLogin's clock may be a little
|
|
28
|
+
* behind ours, and a whole day's wait for that would be wrong.
|
|
29
|
+
*
|
|
30
|
+
* State: in memory, and in DATA_HOME/data/morelogin-start-cooldowns.json (another process, such as fetch-deals.mjs,
|
|
31
|
+
* and the next start of the server read the same). Only a plan-limit refusal is kept; any other refusal is not.
|
|
32
|
+
* The copy in memory is read again whenever the file changed under it (its size or modification time), so a refusal
|
|
33
|
+
* another process noted holds here too, and a save never writes over an entry another process added meanwhile.
|
|
34
|
+
*/
|
|
35
|
+
import { mkdirSync, readFileSync, renameSync, statSync, writeFileSync } from 'node:fs';
|
|
36
|
+
import { dirname, join } from 'node:path';
|
|
37
|
+
import { getDataHome } from '../../lib/paths.js';
|
|
38
|
+
|
|
39
|
+
export const RESET_SLACK_MS = 15 * 60_000;
|
|
40
|
+
const MAX_ENTRIES = 200;
|
|
41
|
+
const DAY_MS = 24 * 60 * 60_000;
|
|
42
|
+
|
|
43
|
+
/** The file the cooldowns live in (read through getDataHome each time: SYNABUN_DATA_HOME decides, tests use a temp one). */
|
|
44
|
+
export function cooldownFile() {
|
|
45
|
+
return join(getDataHome(), 'data', 'morelogin-start-cooldowns.json');
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** The first 00:00 UTC after `at` (ms): when MoreLogin's daily start quota resets. */
|
|
49
|
+
export function nextMoreLoginDayReset(at = Date.now()) {
|
|
50
|
+
return (Math.floor(at / DAY_MS) + 1) * DAY_MS;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** Until when a refusal at `at` holds: the next reset, or RESET_SLACK_MS when the last reset was only just now. */
|
|
54
|
+
export function cooldownUntil(at = Date.now()) {
|
|
55
|
+
const lastReset = Math.floor(at / DAY_MS) * DAY_MS;
|
|
56
|
+
if (at - lastReset < RESET_SLACK_MS) return at + RESET_SLACK_MS;
|
|
57
|
+
return nextMoreLoginDayReset(at);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** A time in the computer's own zone, as people read it: "2026-11-15 21:00 (UTC-03:00)". */
|
|
61
|
+
export function formatLocalTime(ms) {
|
|
62
|
+
const d = new Date(ms);
|
|
63
|
+
const p = (n) => String(n).padStart(2, '0');
|
|
64
|
+
const off = -d.getTimezoneOffset();
|
|
65
|
+
const sign = off >= 0 ? '+' : '-';
|
|
66
|
+
const abs = Math.abs(off);
|
|
67
|
+
return `${d.getFullYear()}-${p(d.getMonth() + 1)}-${p(d.getDate())} ${p(d.getHours())}:${p(d.getMinutes())} (UTC${sign}${p(Math.floor(abs / 60))}:${p(abs % 60)})`;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
let _entries = null; // envId → { envId, since, until, apiCode, reason }
|
|
71
|
+
let _loadedFrom = null;
|
|
72
|
+
let _loadedStamp = null; // the file's size and modification time when it was last read or written here
|
|
73
|
+
|
|
74
|
+
/** What tells one version of the file from the next: 'none' while there is none. */
|
|
75
|
+
function fileStamp(file) {
|
|
76
|
+
try { const s = statSync(file); return `${s.size}:${s.mtimeMs}`; } catch { return 'none'; }
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function load() {
|
|
80
|
+
const file = cooldownFile();
|
|
81
|
+
const stamp = fileStamp(file);
|
|
82
|
+
if (_entries && _loadedFrom === file && _loadedStamp === stamp) return _entries;
|
|
83
|
+
_entries = new Map();
|
|
84
|
+
_loadedFrom = file;
|
|
85
|
+
_loadedStamp = stamp;
|
|
86
|
+
try {
|
|
87
|
+
const raw = JSON.parse(readFileSync(file, 'utf8'));
|
|
88
|
+
for (const e of Array.isArray(raw?.cooldowns) ? raw.cooldowns : []) {
|
|
89
|
+
const until = Number(e?.until);
|
|
90
|
+
if (!e?.envId || !Number.isFinite(until)) continue;
|
|
91
|
+
_entries.set(String(e.envId), {
|
|
92
|
+
envId: String(e.envId), since: Number(e.since) || null, until,
|
|
93
|
+
apiCode: e.apiCode ?? null, reason: typeof e.reason === 'string' ? e.reason.slice(0, 500) : '',
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
} catch { /* none yet, or unreadable: no cooldown (a start is asked, and a refusal writes it again) */ }
|
|
97
|
+
return _entries;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function save() {
|
|
101
|
+
const file = cooldownFile();
|
|
102
|
+
try {
|
|
103
|
+
mkdirSync(dirname(file), { recursive: true });
|
|
104
|
+
const tmp = `${file}.${process.pid}.tmp`;
|
|
105
|
+
writeFileSync(tmp, JSON.stringify({ version: 1, cooldowns: [..._entries.values()] }, null, 2) + '\n', { mode: 0o600 });
|
|
106
|
+
renameSync(tmp, file);
|
|
107
|
+
// What this process wrote is what it holds: not read back on the next call.
|
|
108
|
+
_loadedStamp = fileStamp(file);
|
|
109
|
+
} catch (err) {
|
|
110
|
+
console.warn(`[morelogin] could not save the start cooldowns (${err?.message || err}); they hold in memory until a restart`);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function prune(now) {
|
|
115
|
+
let changed = false;
|
|
116
|
+
for (const [id, e] of load()) if (!(e.until > now)) { _entries.delete(id); changed = true; }
|
|
117
|
+
return changed;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Note a refused start. Kept only for a plan-limit refusal (`err.planLimit`): returns the entry, or null.
|
|
122
|
+
*/
|
|
123
|
+
export function noteStartRefusal(envId, err, now = Date.now()) {
|
|
124
|
+
if (!envId || !err?.planLimit) return null;
|
|
125
|
+
const entries = load();
|
|
126
|
+
prune(now);
|
|
127
|
+
const reason = String(err.reason || err.message || '').slice(0, 500);
|
|
128
|
+
const entry = { envId: String(envId), since: now, until: cooldownUntil(now), apiCode: err.apiCode ?? null, reason };
|
|
129
|
+
entries.delete(entry.envId); // newest last
|
|
130
|
+
entries.set(entry.envId, entry);
|
|
131
|
+
while (entries.size > MAX_ENTRIES) entries.delete(entries.keys().next().value);
|
|
132
|
+
save();
|
|
133
|
+
return { ...entry };
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/** The cooldown that holds for a profile now, or null. */
|
|
137
|
+
export function activeStartCooldown(envId, now = Date.now()) {
|
|
138
|
+
if (!envId) return null;
|
|
139
|
+
const e = load().get(String(envId));
|
|
140
|
+
if (!e) return null;
|
|
141
|
+
if (!(e.until > now)) { _entries.delete(String(envId)); save(); return null; }
|
|
142
|
+
return { ...e };
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/** Every cooldown that holds now: [{ envId, since, until, apiCode, reason, resetAt, resetLocal }]. */
|
|
146
|
+
export function listStartCooldowns(now = Date.now()) {
|
|
147
|
+
if (prune(now)) save();
|
|
148
|
+
return [...load().values()].map((e) => ({ ...e, resetAt: new Date(e.until).toISOString(), resetLocal: formatLocalTime(e.until) }));
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/** End a profile's cooldown (a start that worked: the quota was reset or raised). */
|
|
152
|
+
export function clearStartCooldown(envId) {
|
|
153
|
+
if (!envId) return false;
|
|
154
|
+
const had = load().delete(String(envId));
|
|
155
|
+
if (had) save();
|
|
156
|
+
return had;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/** Forget what is held in memory: the next call reads the file again (what a new process or a reload sees). */
|
|
160
|
+
export function _reloadStartCooldownsForTests() { _entries = null; _loadedFrom = null; }
|
|
@@ -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;
|
|
@@ -288,7 +305,15 @@ export async function listCompleteProfiles(opts = {}) {
|
|
|
288
305
|
const out = [], seen = new Set();
|
|
289
306
|
let total;
|
|
290
307
|
for (let pageNo = 1; pageNo <= 1000; pageNo++) {
|
|
291
|
-
|
|
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
|
+
}
|
|
292
317
|
if (!Array.isArray(data) && !PROFILE_LIST_KEYS.some(k => Array.isArray(data?.[k]))) throw shapeError(data);
|
|
293
318
|
const rows = profileRows(data);
|
|
294
319
|
if (data?.total != null && !/^(0|[1-9][0-9]*)$/.test(String(data.total))) throw shapeError(data);
|
|
@@ -473,7 +498,8 @@ export async function profileKernelOf(envId, opts = {}) {
|
|
|
473
498
|
const id = String(envId);
|
|
474
499
|
if (_chromiumProfiles.has(id)) return 'chromium';
|
|
475
500
|
let kernel = null;
|
|
476
|
-
|
|
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))); }
|
|
477
503
|
catch { /* unreachable: the start says so itself */ }
|
|
478
504
|
if (!kernel) {
|
|
479
505
|
try { kernel = profileKernel(await profileDetail(id, opts)); } catch { /* a MoreLogin without the call */ }
|
|
@@ -615,24 +641,139 @@ export function notDevToolsError(envId, port, seen = {}) {
|
|
|
615
641
|
return e;
|
|
616
642
|
}
|
|
617
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
|
+
|
|
618
693
|
/**
|
|
619
|
-
* Start (launch) a profile and return { debugPort, webdriver, kernel, raw }.
|
|
620
|
-
*
|
|
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.
|
|
621
699
|
*
|
|
622
700
|
* `opts.requireCdp` (a start SynaBun will drive, never the Settings Start button): a Firefox-type profile is
|
|
623
701
|
* refused with MORELOGIN_NOT_CHROMIUM before it is started when MoreLogin says what it is up front, and right
|
|
624
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.
|
|
625
711
|
*/
|
|
626
712
|
export async function startProfile(envId, opts = {}) {
|
|
627
|
-
|
|
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') {
|
|
628
766
|
throw notChromiumError(envId, { evidence: 'MoreLogin lists it as a Firefox profile' });
|
|
629
767
|
}
|
|
630
768
|
let data = null;
|
|
769
|
+
let startErr = null;
|
|
631
770
|
try {
|
|
632
771
|
data = await request('/api/env/start', { envId: String(envId), ...(opts.startArgs || {}) }, opts);
|
|
633
772
|
} catch (err) {
|
|
634
773
|
if (err?.code === 'MORELOGIN_UNREACHABLE' || err?.code === 'MORELOGIN_HTTP' || err?.code === 'MORELOGIN_SHAPE') throw err;
|
|
635
|
-
// 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;
|
|
636
777
|
}
|
|
637
778
|
let port = extractDebugPort(data);
|
|
638
779
|
let webdriver = data && data.webdriver;
|
|
@@ -648,8 +789,18 @@ export async function startProfile(envId, opts = {}) {
|
|
|
648
789
|
if (opts.requireCdp && kernel === 'firefox') {
|
|
649
790
|
throw notChromiumError(envId, { started: true, evidence: `its browser is ${webdriver}` });
|
|
650
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
|
+
}
|
|
651
798
|
if (!port) throw new Error(`MoreLogin started env ${envId} but returned no debugPort`);
|
|
652
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);
|
|
653
804
|
return { debugPort: port, webdriver: webdriver || null, kernel, raw: data };
|
|
654
805
|
}
|
|
655
806
|
|
|
@@ -661,7 +812,13 @@ export async function startProfile(envId, opts = {}) {
|
|
|
661
812
|
* close only this connectOverCDP transport; MoreLogin owns the running browser.
|
|
662
813
|
*/
|
|
663
814
|
export async function attachProfileBrowser(chromium, endpoint, openPage) {
|
|
664
|
-
|
|
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
|
+
}
|
|
665
822
|
try {
|
|
666
823
|
const context = browser.contexts()[0];
|
|
667
824
|
if (!context) {
|
|
@@ -678,6 +835,35 @@ export async function attachProfileBrowser(chromium, endpoint, openPage) {
|
|
|
678
835
|
}
|
|
679
836
|
}
|
|
680
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
|
+
|
|
681
867
|
/** Stop (close) a profile. */
|
|
682
868
|
export async function stopProfile(envId, opts = {}) {
|
|
683
869
|
return request('/api/env/close', { envId: String(envId) }, opts);
|
|
@@ -822,6 +822,11 @@ export class NativeLoopRuntime {
|
|
|
822
822
|
async _drive(record) {
|
|
823
823
|
let failures = 0;
|
|
824
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
|
+
}
|
|
825
830
|
const state = this._readState(record.runId);
|
|
826
831
|
if (!state || state.active === false) {
|
|
827
832
|
await this.stop(record.runId, state ? 'state_inactive' : 'state_removed');
|
|
@@ -1002,6 +1007,21 @@ export class NativeLoopRuntime {
|
|
|
1002
1007
|
return true;
|
|
1003
1008
|
}
|
|
1004
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
|
+
|
|
1005
1025
|
isAlive(runId) {
|
|
1006
1026
|
const record = this.records.get(runId);
|
|
1007
1027
|
if (!record || !['starting', 'running'].includes(record.status)) return false;
|
|
@@ -6,6 +6,7 @@ import { mkdtempSync, mkdirSync, writeFileSync, rmSync } from 'node:fs';
|
|
|
6
6
|
import { tmpdir } from 'node:os';
|
|
7
7
|
import { join } from 'node:path';
|
|
8
8
|
import { serveSpecFor, servePasswordReader } from './opencode-protocol.js';
|
|
9
|
+
import { moreLoginProcessesRunning } from './process-identity.js';
|
|
9
10
|
|
|
10
11
|
/** Strictly parse the observed MoreLogin /api/env/detail response; never retain cookies or other profile data. */
|
|
11
12
|
export function portProtectionOf(detail) {
|
|
@@ -27,9 +28,23 @@ export function moreLoginFailureDetail(error) {
|
|
|
27
28
|
function profileError(code, message, envId) {
|
|
28
29
|
return Object.assign(new Error(message), { code, offenders: envId ? [{ envId, reason: code }] : [] });
|
|
29
30
|
}
|
|
30
|
-
export async function reconcilePreflightProfiles(profiles, list, { requested = [],
|
|
31
|
+
export async function reconcilePreflightProfiles(profiles, list, { requested = [], allowUnavailable = false,
|
|
32
|
+
browserProcesses = moreLoginProcessesRunning, log = () => {} } = {}) {
|
|
31
33
|
let live;
|
|
32
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
|
+
}
|
|
33
48
|
throw profileError('MORELOGIN_LIST_UNREADABLE', `MoreLogin profile listing failed: ${moreLoginFailureDetail(error)}. OpenCode build verification has not started.`);
|
|
34
49
|
}
|
|
35
50
|
if (!Array.isArray(live) || live.moreloginError || live.some(p => !p?.id)) throw profileError('MORELOGIN_LIST_UNREADABLE', 'MoreLogin profile listing is malformed or incomplete.');
|