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
|
@@ -29,8 +29,11 @@
|
|
|
29
29
|
// It validates targets against the catalog, remembers per-class preferences,
|
|
30
30
|
// holds un-routed dispatches until the user picks (dispatcher `awaiting_route`)
|
|
31
31
|
// and suggests one-tier escalations when a run fails or reports blocked.
|
|
32
|
-
//
|
|
32
|
+
// Catalog, config and runtime I/O are injected. The split planner checks git before worktree approval.
|
|
33
33
|
|
|
34
|
+
import { routeTaskIdentity } from '../public/shared/assistant/route-identity.js';
|
|
35
|
+
import { planRouteSplit } from './agents/split.js';
|
|
36
|
+
import { normalizeAgentDensity } from './agents/density.js';
|
|
34
37
|
import { randomBytes } from 'node:crypto';
|
|
35
38
|
import { CATALOG_PROVIDERS, TIERS, defaultIsHidden, defaultModelRow, findModel, hiddenModelId, priceText, providerAllHidden, providerEmpty, rowIsHidden, rowMakes } from './assistant-catalog.js';
|
|
36
39
|
import { effectiveRouting, normalizeRouteMode } from './assistant-config.js';
|
|
@@ -92,6 +95,11 @@ export function runContract(taskClass) { return requiredOutput(taskClass) || cla
|
|
|
92
95
|
const TIER_RANK = { small: 0, medium: 1, large: 2 };
|
|
93
96
|
const MAX_ESCALATION_DEPTH = 2;
|
|
94
97
|
const DECIDED_TTL_MS = 60 * 60_000;
|
|
98
|
+
// A queued "do it here" continuation not started after this is delivered once more; still not started after the
|
|
99
|
+
// same again, the brain and the panel are told (maybeContinuation's watchdog).
|
|
100
|
+
export const CONTINUATION_WATCH_MS = 30_000;
|
|
101
|
+
const CONTINUATION_WATCH_S = CONTINUATION_WATCH_MS / 1000;
|
|
102
|
+
const CONTINUATIONS_KEPT = 200;
|
|
95
103
|
|
|
96
104
|
function clip(value, max = 200) {
|
|
97
105
|
const text = String(value ?? '').replace(/\s+/g, ' ').trim();
|
|
@@ -274,12 +282,17 @@ export function describeTarget(target, { catalog = null, brain = {}, brainInfo =
|
|
|
274
282
|
/**
|
|
275
283
|
* `target` with its effort checked against its model (effort-levels.js): an
|
|
276
284
|
* unsupported level becomes the nearest one the model runs, and the change is
|
|
277
|
-
* pushed onto `corrections` as { field: 'effort', from, to, reason: 'effort_unsupported' }.
|
|
285
|
+
* pushed onto `corrections` as { field: 'effort', from, to, reason: 'effort_unsupported' }. Off (`none`) on a
|
|
286
|
+
* Claude model whose thinking cannot be turned off runs at the lowest level, reason 'thinking_always_on', with a
|
|
287
|
+
* text that says so: no route claims "thinking off" while the request carries adaptive thinking.
|
|
278
288
|
*/
|
|
279
289
|
export function effortChecked(target, catalog, corrections = null) {
|
|
280
290
|
if (!target?.effort) return target;
|
|
281
291
|
const { effort, corrected } = normalizeEffort({ provider: target.provider, model: target.model || null, effort: target.effort, catalog });
|
|
282
|
-
if (corrected
|
|
292
|
+
if (corrected?.reason === 'thinking_always_on') {
|
|
293
|
+
corrections?.push({ field: 'effort', from: corrected.from, to: corrected.to, reason: 'thinking_always_on',
|
|
294
|
+
text: `effort none (thinking off) runs as ${corrected.to}: ${target.model || 'this model'} cannot turn its thinking off` });
|
|
295
|
+
} else if (corrected) corrections?.push({ field: 'effort', from: corrected.from, to: corrected.to, reason: 'effort_unsupported' });
|
|
283
296
|
return effort === target.effort ? target : { ...target, effort };
|
|
284
297
|
}
|
|
285
298
|
|
|
@@ -894,7 +907,7 @@ export function routeSides({ options = [], request = {}, defaultOptionId = null
|
|
|
894
907
|
const label = request.taskClassLabel || TASK_CLASS_META[request.taskClass]?.label || 'This task';
|
|
895
908
|
const side = (kind) => {
|
|
896
909
|
if (firstOf(kind)) return { available: true, reason: null, code: null };
|
|
897
|
-
if (kind === 'direct' && request.dispatchOnly) return { available: false, code: 'worker_only', reason: `${label} always runs on a worker.` };
|
|
910
|
+
if (kind === 'direct' && request.dispatchOnly) return { available: false, code: 'worker_only', reason: request.plannedSplit ? 'This task uses the approved worker plan.' : `${label} always runs on a worker.` };
|
|
898
911
|
if (kind === 'direct' && options.some((o) => o.kind === 'dispatch' && o.accountKind === 'direct')) {
|
|
899
912
|
return { available: false, code: 'account_worker', reason: "This conversation's account cannot take it, so it runs on a worker." };
|
|
900
913
|
}
|
|
@@ -1060,6 +1073,7 @@ export function createAssistantRouter({
|
|
|
1060
1073
|
getSession = () => null,
|
|
1061
1074
|
sinks = {},
|
|
1062
1075
|
now = Date.now,
|
|
1076
|
+
continuationTimers = { setTimeout, clearTimeout },
|
|
1063
1077
|
randomId = () => randomBytes(6).toString('hex'),
|
|
1064
1078
|
log = () => {},
|
|
1065
1079
|
clarifier = null,
|
|
@@ -1073,6 +1087,7 @@ export function createAssistantRouter({
|
|
|
1073
1087
|
// routeId → decided route (reusable by agent_dispatch route_id; a remote session's is
|
|
1074
1088
|
// used up by the first dispatch that starts a run: `consumed`).
|
|
1075
1089
|
const decided = new Map();
|
|
1090
|
+
const continuations = new Map();
|
|
1076
1091
|
const stamps = new Map(); // sessionId → last stamp shown to the brain
|
|
1077
1092
|
const lastClosed = new Map(); // routeId → { routeId, settled } of recently closed cards
|
|
1078
1093
|
const call = (name, ...args) => { try { return sinks[name]?.(...args); } catch (error) { log('router:sink-error', `${name}: ${error?.message || error}`); return undefined; } };
|
|
@@ -1144,7 +1159,7 @@ export function createAssistantRouter({
|
|
|
1144
1159
|
};
|
|
1145
1160
|
call('routeEvent', sessionId, 'declined', routeView(route, { catalog: cat, brain, brainInfo }));
|
|
1146
1161
|
return {
|
|
1147
|
-
ok: true, status: 'declined', reason: 'budget_exhausted', dry, routeId, mode, source: 'budget', target: null,
|
|
1162
|
+
ok: true, status: 'declined', reason: 'budget_exhausted', reasonCode: 'budget_exhausted', dry, routeId, mode, source: 'budget', target: null,
|
|
1148
1163
|
remembered: false, continuation: false, corrections: evaluation.corrections || [], runIds: [], expiresAt: null,
|
|
1149
1164
|
budget: compactBudget(sessionId), next: budgetDeclinedText(sessionId, dry),
|
|
1150
1165
|
};
|
|
@@ -1196,13 +1211,16 @@ export function createAssistantRouter({
|
|
|
1196
1211
|
}
|
|
1197
1212
|
function pruneDecided() {
|
|
1198
1213
|
const cutoff = now();
|
|
1199
|
-
|
|
1214
|
+
// A later mailbox turn can revisit an older task. Keep its identity for the live session,
|
|
1215
|
+
// including closed tombstones; TTL only evicts legacy routes or sessions that are gone.
|
|
1216
|
+
for (const [id, route] of decided) if (route.expiresAt < cutoff && (!route.taskId || !getSession(route.sessionId))) decided.delete(id);
|
|
1200
1217
|
}
|
|
1201
1218
|
|
|
1202
1219
|
function routeView(source, { catalog: cat = null, brain = {}, brainInfo = null } = {}) {
|
|
1203
1220
|
const target = source.target ? describeTarget(source.target, { catalog: cat, brain, brainInfo }) : null;
|
|
1204
1221
|
return {
|
|
1205
1222
|
routeId: source.routeId, runIds: [...(source.runIds || [])], taskClass: source.taskClass, taskClassLabel: TASK_CLASS_META[source.taskClass]?.label || source.taskClass,
|
|
1223
|
+
plannedSplit: source.plannedSplit || null, sessionId: source.sessionId || null, taskId: source.taskId || null, taskKey: source.taskKey || '',
|
|
1206
1224
|
summary: source.summary || '', confidence: source.confidence ?? null, reason: source.reason || null,
|
|
1207
1225
|
target, alternatives: (source.alternatives || []).slice(0, 4), decidedBy: source.decidedBy || null, remembered: !!source.remembered,
|
|
1208
1226
|
optionId: source.optionId || null, corrections: source.corrections || [], mode: source.mode || null, status: source.status || null,
|
|
@@ -1217,7 +1235,7 @@ export function createAssistantRouter({
|
|
|
1217
1235
|
|
|
1218
1236
|
function nextText(status, target, { routeId, label } = {}) {
|
|
1219
1237
|
if (status === 'pending') return 'The user has not picked a model yet. End your turn now with one short line saying you are waiting for their choice. Their decision arrives as a [SynaBun Mailbox] route_decided event; do not start the task before it.';
|
|
1220
|
-
if (status === 'declined') return 'The user
|
|
1238
|
+
if (status === 'declined') return label === 'dismissed' ? 'The route card was dismissed. Do not start the task; route again when ready.' : label === 'cancelled' ? 'The user cancelled this route. Do not start the task; ask what they would like instead.' : 'This route was declined by the routing system. Do not start the task; check the route reason.';
|
|
1221
1239
|
// The user wrote something else instead of choosing (cancel 'superseded'): their message is next, so nothing is asked here.
|
|
1222
1240
|
if (status === 'moved_on') return 'The user did not pick a model: they sent a new message instead, which you get next. Nothing was approved, so do not start this task. End your turn now, with no text unless you have a result to report.';
|
|
1223
1241
|
if (status === 'expired' || status === 'cancelled') return 'This route is no longer valid. Do not start the task; ask the user how to proceed.';
|
|
@@ -1225,21 +1243,182 @@ export function createAssistantRouter({
|
|
|
1225
1243
|
if (target.kind === 'dispatch') {
|
|
1226
1244
|
return `Dispatch now with agent_dispatch route_id="${routeId}" (provider ${target.provider}${target.model ? `, model ${target.model}` : ', provider default model'}${target.effort ? `, effort ${target.effort}` : ''}). Do not ask the user again about the model.`;
|
|
1227
1245
|
}
|
|
1228
|
-
if (target.continuation) return `The user chose to run this here on ${label || target.model}. End your turn now with one short line; SynaBun
|
|
1246
|
+
if (target.continuation) return `The user chose to run this here on ${label || target.model}${target.effort ? ` (${effortWord(target.effort)})` : ''}. End your turn now with one short line; SynaBun has queued a continuation on that model and effort; if it has not started within ${CONTINUATION_WATCH_S} seconds it is delivered once more, and you are told if that one does not start either.`;
|
|
1229
1247
|
return 'Proceed here yourself now.';
|
|
1230
1248
|
}
|
|
1231
1249
|
|
|
1232
|
-
/**
|
|
1233
|
-
|
|
1250
|
+
/**
|
|
1251
|
+
* An effort as `model` runs it, for comparing two of them: corrected to a level the model supports
|
|
1252
|
+
* (effort-levels.js normalizeEffort), lower case; none / no setting -> the row's `defaultEffort`
|
|
1253
|
+
* when the catalog names one, else null (the model's default).
|
|
1254
|
+
*/
|
|
1255
|
+
function runEffort(provider, model, effort) {
|
|
1256
|
+
const cat = catalog.peek?.() || null;
|
|
1257
|
+
const kept = normalizeEffort({ provider, model, effort, catalog: cat }).effort;
|
|
1258
|
+
if (kept) return String(kept).toLowerCase();
|
|
1259
|
+
let row = null;
|
|
1260
|
+
try { row = model ? findModel(cat, provider, model)?.row || null : defaultModelRow(cat, provider); } catch { row = null; }
|
|
1261
|
+
return row?.defaultEffort ? String(row.defaultEffort).toLowerCase() : null;
|
|
1262
|
+
}
|
|
1263
|
+
/**
|
|
1264
|
+
* Does a direct `target` ask for another effort than `turn` runs on? A target with no effort (null, Auto /
|
|
1265
|
+
* default, or a model that takes no effort) is the session's own: no. An effort that clamps to the turn's is
|
|
1266
|
+
* the same; Off (`none`) and a level always differ.
|
|
1267
|
+
*/
|
|
1268
|
+
function effortDiffers(target, turn = {}) {
|
|
1269
|
+
if (!target?.effort) return false;
|
|
1270
|
+
const provider = target.provider || turn.provider || null;
|
|
1271
|
+
const model = target.model || turn.model || null;
|
|
1272
|
+
if (!normalizeEffort({ provider, model, effort: target.effort, catalog: catalog.peek?.() || null }).effort) return false;
|
|
1273
|
+
return runEffort(provider, model, target.effort) !== runEffort(provider, model, turn.effort ?? null);
|
|
1274
|
+
}
|
|
1275
|
+
/**
|
|
1276
|
+
* A "do it here" pick hands off to a continuation turn when it switches the model (or provider) away from
|
|
1277
|
+
* `brain`, or asks for another effort than the brain's running turn is on (`turn`, turnBrain: a continuation's
|
|
1278
|
+
* effort, which a turn the CLI starts by itself afterwards keeps). The continuation runs that one task on the
|
|
1279
|
+
* pick; the session's own effort is not changed, so the turns after it are back on it.
|
|
1280
|
+
*/
|
|
1281
|
+
function continuesHere(target, brain, turn = brain) {
|
|
1234
1282
|
if (!target || target.kind !== 'direct') return false;
|
|
1235
|
-
if (String(target.
|
|
1236
|
-
|
|
1283
|
+
if (String(target.provider || brain.provider) !== String(brain.provider)
|
|
1284
|
+
|| String(target.model || brain.model || '') !== String(brain.model || '')) return true;
|
|
1285
|
+
return effortDiffers(target, turn);
|
|
1286
|
+
}
|
|
1287
|
+
/**
|
|
1288
|
+
* Off (`none`) to or from a level is a start-up option of Claude Code: the switch restarts the CLI, which ends
|
|
1289
|
+
* the background work it runs (a background Bash, an agent, a wakeup), so the bridge defers it while there is
|
|
1290
|
+
* any (claude-agent-bridge.js _thinkingDeferred), and a continuation then would not run on the pick. An
|
|
1291
|
+
* effort-only pick that needs that switch while the session reports background work (routerSession
|
|
1292
|
+
* `pendingWork`) carries on in place, as the turn runs; the correction says so, and that the task, routed again
|
|
1293
|
+
* once the work has reported (its task-notification turn), continues on the pick. -> the correction, or null.
|
|
1294
|
+
*/
|
|
1295
|
+
function thinkingWaits(sessionId, target, brain, turn) {
|
|
1296
|
+
if (!target || target.kind !== 'direct') return null;
|
|
1297
|
+
const provider = String(target.provider || brain.provider || '');
|
|
1298
|
+
if (provider !== 'claude-code' || provider !== String(brain.provider || '')) return null;
|
|
1299
|
+
if (String(target.model || brain.model || '') !== String(brain.model || '')) return null;
|
|
1300
|
+
if (!effortDiffers(target, turn) || getSession(sessionId)?.pendingWork !== true) return null;
|
|
1301
|
+
const model = target.model || brain.model || null;
|
|
1302
|
+
const want = runEffort(provider, model, target.effort);
|
|
1303
|
+
const have = runEffort(provider, model, turn.effort ?? null);
|
|
1304
|
+
if ((want === EFFORT_OFF) === (have === EFFORT_OFF)) return null;
|
|
1305
|
+
const off = want === EFFORT_OFF;
|
|
1306
|
+
const asIs = have === EFFORT_OFF ? 'thinking off' : `thinking on${have ? `, ${have}` : ''}`;
|
|
1307
|
+
return {
|
|
1308
|
+
field: 'effort', from: target.effort, to: turn.effort ?? null, reason: 'thinking_waits',
|
|
1309
|
+
text: `${off ? 'thinking off' : `thinking on (${want})`} waits: Claude Code is running background work, and switching thinking ${off ? 'off' : 'on'} restarts it, which would end that work. This carries on here as it runs now (${asIs}); once the background work has reported, route this task again with the same task_key and it continues on ${effortWord(target.effort)}`,
|
|
1310
|
+
};
|
|
1311
|
+
}
|
|
1312
|
+
/** What the brain's running turn is on, from a session snapshot (turnBrain, for a session id). */
|
|
1313
|
+
function turnOf(session, brain = {}) {
|
|
1314
|
+
const turn = session?.turn;
|
|
1315
|
+
return turn && typeof turn === 'object' ? { ...brain, model: turn.model ?? brain.model ?? null, effort: turn.effort ?? null } : brain;
|
|
1316
|
+
}
|
|
1317
|
+
/**
|
|
1318
|
+
* Whether a direct pick queues a continuation now: continuesHere against the running turn (a re-route compares
|
|
1319
|
+
* the model with the turn too), unless its thinking switch waits for background work (thinkingWaits).
|
|
1320
|
+
*/
|
|
1321
|
+
function continuesNow(sessionId, target, brain, { reroute = false } = {}) {
|
|
1322
|
+
const turn = turnBrain(sessionId, brain);
|
|
1323
|
+
const base = reroute ? turn : brain;
|
|
1324
|
+
if (!continuesHere(target, base, turn)) return false;
|
|
1325
|
+
return !thinkingWaits(sessionId, target, base, turn);
|
|
1326
|
+
}
|
|
1327
|
+
// The continuation watchdog. A "do it here" pick queues a continuation in the runtime (continueDirect),
|
|
1328
|
+
// which calls continuationStarted(routeId) once the turn reached the brain. Not started after
|
|
1329
|
+
// CONTINUATION_WATCH_MS: it is delivered once more (the runtime takes a delivery of a continuation it
|
|
1330
|
+
// still holds, queued or on its way, or one that already ran, as done: never a second turn), and only
|
|
1331
|
+
// if that one has not started either, CONTINUATION_WATCH_MS later, the brain and the panel are told.
|
|
1332
|
+
// A retry the runtime refuses (the turn is gone, the session is closing) is told at once. Every timer
|
|
1333
|
+
// ends with the start, the session's end or Stop, a newer task, a newer continuation and shutdown.
|
|
1334
|
+
function stopContinuationWatch(entry) {
|
|
1335
|
+
if (entry?.timer != null) continuationTimers.clearTimeout(entry.timer);
|
|
1336
|
+
if (entry) entry.timer = null;
|
|
1337
|
+
}
|
|
1338
|
+
function closeContinuation(entry) { stopContinuationWatch(entry); entry.closed = true; }
|
|
1339
|
+
function continuationStarted(routeId) {
|
|
1340
|
+
const entry = continuations.get(String(routeId || ''));
|
|
1341
|
+
if (!entry) return;
|
|
1342
|
+
stopContinuationWatch(entry);
|
|
1343
|
+
entry.started = true;
|
|
1344
|
+
}
|
|
1345
|
+
/** The runtime took the continuation (queued it, or holds / ran it already): exactly `true`. */
|
|
1346
|
+
// `reroute`: agent_route asked for the task again in the turn running now, so it is delivered in that turn's
|
|
1347
|
+
// generation; the watchdog's retry keeps the generation the continuation was delivered in.
|
|
1348
|
+
const deliverContinuation = (entry, retry, reroute = false) => call('continueDirect', entry.sessionId,
|
|
1349
|
+
retry || reroute ? { ...entry.payload, ...(retry ? { retry: true } : {}), ...(reroute ? { reroute: true } : {}) } : entry.payload) === true;
|
|
1350
|
+
function reportContinuation(entry, reasonCode, text) {
|
|
1351
|
+
entry.reported = true;
|
|
1352
|
+
call('mailbox', entry.sessionId, { kind: 'route_continuation_delayed', route: entry.source, reasonCode, retried: entry.retries > 0, text });
|
|
1353
|
+
call('routeEvent', entry.sessionId, 'continuation_delayed', { ...entry.source, reasonCode, retried: entry.retries > 0, reason: text });
|
|
1354
|
+
}
|
|
1355
|
+
function armContinuationWatch(entry, fire) {
|
|
1356
|
+
stopContinuationWatch(entry);
|
|
1357
|
+
entry.timer = continuationTimers.setTimeout(() => {
|
|
1358
|
+
entry.timer = null;
|
|
1359
|
+
if (entry.started || entry.closed) return;
|
|
1360
|
+
fire();
|
|
1361
|
+
}, CONTINUATION_WATCH_MS);
|
|
1362
|
+
entry.timer?.unref?.();
|
|
1363
|
+
}
|
|
1364
|
+
function watchContinuation(entry) {
|
|
1365
|
+
entry.reported = false;
|
|
1366
|
+
armContinuationWatch(entry, () => {
|
|
1367
|
+
entry.retries += 1;
|
|
1368
|
+
const delivered = deliverContinuation(entry, true);
|
|
1369
|
+
// (The runtime may answer that it already ran, and say so through continuationStarted meanwhile.)
|
|
1370
|
+
if (entry.started || entry.closed) return;
|
|
1371
|
+
if (!delivered) {
|
|
1372
|
+
reportContinuation(entry, 'continuation_undeliverable', `The approved continuation did not start within ${CONTINUATION_WATCH_S} seconds, and SynaBun's retry could not deliver it (its turn is gone, or the session is stopping). Nothing ran. Route again with the same task_key to retry.`);
|
|
1373
|
+
return;
|
|
1374
|
+
}
|
|
1375
|
+
armContinuationWatch(entry, () => reportContinuation(entry, 'continuation_timeout',
|
|
1376
|
+
`The approved continuation has not started after ${CONTINUATION_WATCH_S * 2} seconds, although SynaBun retried its delivery once at ${CONTINUATION_WATCH_S} seconds. It may still be queued behind a running turn; check the task, and route again with the same task_key to retry.`));
|
|
1377
|
+
});
|
|
1378
|
+
}
|
|
1379
|
+
/**
|
|
1380
|
+
* → whether a continuation is queued for this route (continueDirect), so the answer can say continuation:true.
|
|
1381
|
+
* `reroute`: the task's route was approved in an earlier turn and is asked again in the turn running now (a task
|
|
1382
|
+
* notification, a mailbox turn, the user's next words). It is compared with what that turn runs on (turnBrain), not
|
|
1383
|
+
* with the session's brain: a turn already on the approved model carries the task on in place (false). A
|
|
1384
|
+
* continuation still queued and watched is that one (true); one that already ran is consumed (false). Otherwise it
|
|
1385
|
+
* is delivered again, in the generation of the turn running now (the runtime's `reroute`).
|
|
1386
|
+
*/
|
|
1387
|
+
function maybeContinuation(sessionId, target, brain, source, { reroute = false } = {}) {
|
|
1388
|
+
if (reroute ? (!target || target.kind !== 'direct') : !continuesNow(sessionId, target, brain)) return false;
|
|
1389
|
+
const routeId = String(source.routeId || '');
|
|
1390
|
+
const previous = continuations.get(routeId);
|
|
1391
|
+
if (previous?.started) return false;
|
|
1392
|
+
// Delivered and still watched: the watchdog retries it; nothing is queued twice.
|
|
1393
|
+
if (previous && !previous.reported && !previous.closed) return true;
|
|
1394
|
+
if (reroute && !continuesNow(sessionId, target, brain, { reroute: true })) return false;
|
|
1395
|
+
// A newer continuation of the session replaces the one the runtime holds (one continuation slot): the older stops being watched.
|
|
1396
|
+
for (const [id, other] of continuations) if (id !== routeId && other.sessionId === sessionId && !other.started && !other.closed) closeContinuation(other);
|
|
1397
|
+
const entry = previous || { routeId, sessionId, taskId: source.taskId ?? getSession(sessionId)?.taskId ?? null, payload: { target, route: source, text: source.summary || '' }, source, started: false, closed: false, reported: false, retries: 0, timer: null };
|
|
1398
|
+
entry.closed = false;
|
|
1399
|
+
continuations.delete(routeId);
|
|
1400
|
+
continuations.set(routeId, entry);
|
|
1401
|
+
while (continuations.size > CONTINUATIONS_KEPT) { const [oldest, old] = continuations.entries().next().value; stopContinuationWatch(old); continuations.delete(oldest); }
|
|
1402
|
+
if (!deliverContinuation(entry, !!previous, reroute)) {
|
|
1403
|
+
closeContinuation(entry);
|
|
1404
|
+
throw routeError('ROUTE_CONTINUATION_FAILED', 'The continuation could not be queued. Route again with the same task_key to retry.', 409);
|
|
1405
|
+
}
|
|
1406
|
+
// (A runtime that already ran it says so at once: consumed.)
|
|
1407
|
+
if (entry.started) return false;
|
|
1408
|
+
watchContinuation(entry);
|
|
1237
1409
|
return true;
|
|
1238
1410
|
}
|
|
1239
|
-
/**
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1411
|
+
/**
|
|
1412
|
+
* What the brain's running turn is on: the runtime's `turn` ({ model, effort }: a continuation's model and
|
|
1413
|
+
* effort, which a turn the CLI starts by itself afterwards keeps), else the brain's own. A re-route compares
|
|
1414
|
+
* with this, so a turn already on the approved model and effort carries the task on in place; every pick's
|
|
1415
|
+
* effort is compared with it (continuesHere).
|
|
1416
|
+
*/
|
|
1417
|
+
function turnBrain(sessionId, brain = {}) { return turnOf(getSession(sessionId), brain); }
|
|
1418
|
+
/** The session is closing or has ended (routerSession `closing`): a continuation it refuses can never run. */
|
|
1419
|
+
function sessionClosing(sessionId) {
|
|
1420
|
+
const session = getSession(sessionId);
|
|
1421
|
+
return !session || session.closing === true;
|
|
1243
1422
|
}
|
|
1244
1423
|
|
|
1245
1424
|
function resultFor(status, { routeId, mode, source = null, target = null, card = null, runIds = [], corrections = [], cat = null, brain = {}, brainInfo = null, remembered = false, continuation = false, sessionId = null, switched = null, droppedRuns = [] } = {}) {
|
|
@@ -1261,12 +1440,25 @@ export function createAssistantRouter({
|
|
|
1261
1440
|
: binding ? `The user's saved route for this task class applies (${binding.to}), not your pick (${binding.from}). `
|
|
1262
1441
|
: skipped ? `The saved route for this task class (${skipped.from}) is on a disabled model, so your pick stands. `
|
|
1263
1442
|
: maker ? `Your pick (${maker.from}) cannot make what this task creates, so it runs on ${maker.to}. ` : '';
|
|
1443
|
+
// An effort-only pick whose thinking switch waits for background work (thinkingWaits): said first.
|
|
1444
|
+
const waits = (corrections || []).find((c) => c?.reason === 'thinking_waits');
|
|
1445
|
+
const waitLead = waits && !continuation ? `${waits.text}. ` : '';
|
|
1264
1446
|
const shares = sessionId && budgeted() ? compactBudget(sessionId) : null;
|
|
1447
|
+
const record = decided.get(routeId) || card;
|
|
1448
|
+
const plannedSplit = record?.plannedSplit || null;
|
|
1449
|
+
const flow = plannedSplit?.flow;
|
|
1450
|
+
const splitNext = status === 'approved' && target?.kind === 'dispatch' && plannedSplit
|
|
1451
|
+
? flow === 'team'
|
|
1452
|
+
? `Call agent_team action "plan" with task_class="${record.taskClass}" and these ${plannedSplit.workers} slice titles (${["research", "review"].includes(record.taskClass) ? "read-only: owned_paths []" : "disjoint owned_paths"}), then action "start" with route_id="${routeId}". One approval covers every slice; never route a slice. Wait on its workflow_id, then ${["research", "review"].includes(record.taskClass) ? "synthesize the results; worktrees are cleaned up automatically, no integration or landing" : "verify the integration result"}.`
|
|
1453
|
+
: `Call agent_dispatch with route_id="${routeId}" for one worker. Explain: ${plannedSplit.reason}`
|
|
1454
|
+
: null;
|
|
1265
1455
|
return {
|
|
1266
|
-
ok: true, status, routeId, mode, source, target: described, remembered, continuation,
|
|
1456
|
+
ok: true, status, routeId, mode, source: source || record?.decidedBy || (status === 'expired' ? 'timeout' : status === 'cancelled' ? 'system' : null), reasonCode: record?.reasonCode || (status === 'expired' ? 'expired' : status === 'cancelled' ? 'cancelled' : null), target: described, remembered, continuation,
|
|
1457
|
+
taskClass: record?.taskClass || null, sessionId: sessionId || record?.sessionId || null, taskId: record?.taskId || null, taskKey: record?.taskKey || '',
|
|
1458
|
+
agentDensity: plannedSplit?.density || normalizeAgentDensity(getSession(sessionId || record?.sessionId)?.agentDensity), expectedWorkers: plannedSplit?.workers || 1, plannedSplit, workflowId: record?.workflowId || null,
|
|
1267
1459
|
corrections, runIds, expiresAt: card?.expiresAt ? new Date(card.expiresAt).toISOString() : null,
|
|
1268
1460
|
...(shares ? { budget: shares } : {}),
|
|
1269
|
-
next: `${lead}${status === 'approved' ? kindLead : ''}${nextText(status, described, { routeId, label: described?.label })}`,
|
|
1461
|
+
next: `${waitLead}${lead}${status === 'approved' ? kindLead : ''}${splitNext || nextText(record?.reasonCode === 'moved_on' ? 'moved_on' : status, described, { routeId, label: status === 'declined' ? record?.reasonCode : described?.label })}`,
|
|
1270
1462
|
};
|
|
1271
1463
|
}
|
|
1272
1464
|
|
|
@@ -1291,7 +1483,7 @@ export function createAssistantRouter({
|
|
|
1291
1483
|
};
|
|
1292
1484
|
call('routeEvent', sessionId, 'declined', routeView(route, { catalog: cat, brain, brainInfo }));
|
|
1293
1485
|
return {
|
|
1294
|
-
ok: true, status: 'declined', reason: 'no_capable_model', requires: request.needsOutput, ...(needs ? { needs } : {}), routeId, mode, source: 'rule', target: null,
|
|
1486
|
+
ok: true, status: 'declined', reason: 'no_capable_model', reasonCode: 'no_capable_model', requires: request.needsOutput, ...(needs ? { needs } : {}), routeId, mode, source: 'rule', target: null,
|
|
1295
1487
|
remembered: false, continuation: false, corrections: [], runIds: [], expiresAt: null, next: noMakerText(request),
|
|
1296
1488
|
};
|
|
1297
1489
|
}
|
|
@@ -1310,7 +1502,7 @@ export function createAssistantRouter({
|
|
|
1310
1502
|
if (request.taskClass !== 'computer') return null;
|
|
1311
1503
|
const option = options.find((o) => o.id === defaultOptionId);
|
|
1312
1504
|
if (!option || option.disabled || option.kind !== 'direct' || option.provider !== brain.provider) return null;
|
|
1313
|
-
if (continuesHere({ kind: 'direct', provider: option.provider, model: option.model, effort: option.effort }, brain)) return null;
|
|
1505
|
+
if (continuesHere({ kind: 'direct', provider: option.provider, model: option.model, effort: option.effort }, brain, turnOf(session, brain))) return null;
|
|
1314
1506
|
return { optionId: option.id };
|
|
1315
1507
|
}
|
|
1316
1508
|
|
|
@@ -1340,6 +1532,7 @@ export function createAssistantRouter({
|
|
|
1340
1532
|
const pref = r.preferences?.[request.taskClass];
|
|
1341
1533
|
const card = {
|
|
1342
1534
|
routeId, requestId, sessionId, origin, status: 'pending', mode, workflowId,
|
|
1535
|
+
plannedSplit: request.plannedSplit || null, taskId: request.taskId, taskKey: request.taskKey || '',
|
|
1343
1536
|
taskClass: request.taskClass, summary: request.summary, confidence: request.confidence, needsVision: request.needsVision,
|
|
1344
1537
|
needsOutput: request.needsOutput || null, dispatchOnly: request.dispatchOnly === true, visionOnly: request.visionOnly === true,
|
|
1345
1538
|
reasons: evaluation.reasons, request, options, defaultOptionId, sides, defaults, runIds: new Set(runIds), waiters: new Set(),
|
|
@@ -1354,6 +1547,7 @@ export function createAssistantRouter({
|
|
|
1354
1547
|
request: {
|
|
1355
1548
|
subtype: 'route', kind: 'route', provider: 'synabun', routeId, origin, runIds: [...card.runIds], workflowId, sessionId, mode,
|
|
1356
1549
|
reasons: evaluation.reasons, taskClass: request.taskClass, taskClassLabel: request.taskClassLabel, summary: request.summary,
|
|
1550
|
+
plannedSplit: request.plannedSplit || null, taskId: request.taskId || null, taskKey: request.taskKey || '',
|
|
1357
1551
|
confidence: request.confidence, needsVision: request.needsVision,
|
|
1358
1552
|
// Image / video creation: the medium the model must generate, and no "here" (always a worker).
|
|
1359
1553
|
requires: request.needsOutput || null, dispatchOnly: request.dispatchOnly === true,
|
|
@@ -1401,7 +1595,7 @@ export function createAssistantRouter({
|
|
|
1401
1595
|
byRequest.delete(card.requestId);
|
|
1402
1596
|
cards.delete(card.routeId);
|
|
1403
1597
|
// Why it closed, for a producer that attaches a run a moment too late (bounded).
|
|
1404
|
-
lastClosed.set(card.routeId, { routeId: card.routeId, settled: card.settled || null });
|
|
1598
|
+
lastClosed.set(card.routeId, { routeId: card.routeId, requestId: card.requestId, sessionId: card.sessionId, taskId: card.taskId, taskKey: card.taskKey, mode: card.mode, decidedBy: card.decidedBy, reasonCode: card.reasonCode, settled: card.settled || null });
|
|
1405
1599
|
while (lastClosed.size > 50) lastClosed.delete(lastClosed.keys().next().value);
|
|
1406
1600
|
}
|
|
1407
1601
|
|
|
@@ -1412,15 +1606,18 @@ export function createAssistantRouter({
|
|
|
1412
1606
|
const card = cards.get(routeId);
|
|
1413
1607
|
if (!card || card.status !== 'pending') return;
|
|
1414
1608
|
card.status = reason === 'expired' || reason === 'superseded' ? 'expired' : 'cancelled';
|
|
1609
|
+
card.decidedBy = reason === 'expired' ? 'timeout' : 'system';
|
|
1610
|
+
card.reasonCode = movedOn ? 'moved_on' : reason;
|
|
1415
1611
|
const status = card.status;
|
|
1416
1612
|
for (const runId of card.runIds) call('declineHeld', runId, reason === 'expired' ? 'route_expired' : `route_${reason}`);
|
|
1417
1613
|
call('cancelCard', card.sessionId, card.requestId, reason);
|
|
1418
|
-
const view = routeView({ ...card, status, decidedBy:
|
|
1614
|
+
const view = routeView({ ...card, status, decidedBy: card.decidedBy }, { catalog: catalog.peek?.(), brain: card.brain });
|
|
1419
1615
|
call('routeEvent', card.sessionId, status === 'expired' ? 'expired' : 'cancelled', view);
|
|
1420
1616
|
if ((card.mailboxOnDecision || card.runIds.size) && reason !== 'session_closed' && reason !== 'aborted' && reason !== 'superseded') {
|
|
1421
1617
|
call('mailbox', card.sessionId, { kind: 'route_expired', route: view, runIds: [...card.runIds], text: `Route card for "${card.summary || card.taskClass}" ${status === 'expired' ? 'expired without an answer' : `was cancelled (${reason})`}.` });
|
|
1422
1618
|
}
|
|
1423
1619
|
settle(card, { status, routeId, ...(movedOn ? { movedOn: true } : {}) });
|
|
1620
|
+
if (card.taskId) decided.set(routeId, { ...view, sessionId: card.sessionId, expiresAt: now() + DECIDED_TTL_MS });
|
|
1424
1621
|
closeCard(card);
|
|
1425
1622
|
}
|
|
1426
1623
|
|
|
@@ -1443,13 +1640,17 @@ export function createAssistantRouter({
|
|
|
1443
1640
|
*/
|
|
1444
1641
|
async function propose(args = {}) {
|
|
1445
1642
|
const origin = args.origin || 'agent_route';
|
|
1643
|
+
const taskId = getSession(args.sessionId)?.taskId || null;
|
|
1446
1644
|
try {
|
|
1447
1645
|
const result = await proposeRoute(args);
|
|
1448
1646
|
// The class rides along: a "chat" route must not unlock the gate.
|
|
1449
|
-
if (origin === 'agent_route') call('routed', args.sessionId, result, { taskClass: normalizeRouteRequest(args.body || {}).taskClass });
|
|
1647
|
+
if (origin === 'agent_route') call('routed', args.sessionId, result, { taskClass: result.taskClass || normalizeRouteRequest(args.body || {}).taskClass });
|
|
1450
1648
|
return result;
|
|
1451
1649
|
} catch (error) {
|
|
1452
|
-
if (origin === 'agent_route'
|
|
1650
|
+
if (origin === 'agent_route' && (!taskId || getSession(args.sessionId)?.taskId === taskId)) {
|
|
1651
|
+
if (/^ROUTE_(SPLIT_|PROJECT_|TASK_)/.test(error?.code || '')) call('routed', args.sessionId, { status: 'plan_required', taskId, next: error.message }, { taskClass: normalizeRouteRequest(args.body || {}).taskClass });
|
|
1652
|
+
else call('routeFailed', args.sessionId, error);
|
|
1653
|
+
}
|
|
1453
1654
|
throw error;
|
|
1454
1655
|
}
|
|
1455
1656
|
}
|
|
@@ -1462,18 +1663,84 @@ export function createAssistantRouter({
|
|
|
1462
1663
|
next: `The user has not answered your questions yet (brief ${waiting.briefId}${what}). End your turn now with one short line and route this after the answers arrive (a [SynaBun Mailbox] clarify_answered event, or the user's next message). If this task does not depend on them, call agent_route again with independent:true.`,
|
|
1463
1664
|
};
|
|
1464
1665
|
}
|
|
1666
|
+
function taskIdentity(sessionId, session, body = {}) {
|
|
1667
|
+
const taskKey = body.task_key ?? body.taskKey ?? '';
|
|
1668
|
+
if (typeof taskKey !== 'string' || taskKey.length > 100 || /[\x00-\x1f]/.test(taskKey)) throw routeError('ROUTE_TASK_KEY_INVALID', 'task_key must be at most 100 characters of text.', 400);
|
|
1669
|
+
return { sessionId, taskId: session.taskId || null, taskKey: taskKey.trim() };
|
|
1670
|
+
}
|
|
1671
|
+
function assertCurrentTask(sessionId, taskId) {
|
|
1672
|
+
if (taskId && getSession(sessionId)?.taskId !== taskId) throw routeError('ROUTE_TASK_CHANGED', 'This request has moved on to another task; route the current task.', 409);
|
|
1673
|
+
}
|
|
1674
|
+
/**
|
|
1675
|
+
* The task already has a route (same task id and task_key). `deliver` (agent_route only; a dispatch looking
|
|
1676
|
+
* the route up asks the runtime for nothing): an approved "do it here" route goes through maybeContinuation
|
|
1677
|
+
* as a re-route, so an answer that says continuation:true always has one queued and watched. A turn already
|
|
1678
|
+
* on the approved model (the continuation itself, or a turn the CLI started after it) carries the task on in
|
|
1679
|
+
* place, and a continuation that already ran is consumed: continuation:false, and the gate opens. A refusal
|
|
1680
|
+
* from a session that is closing answers expired (nothing can run there); any other refusal is
|
|
1681
|
+
* ROUTE_CONTINUATION_FAILED, which says to route again.
|
|
1682
|
+
*/
|
|
1683
|
+
function existingTaskResult(request, sessionId, context, { deliver = false } = {}) {
|
|
1684
|
+
const key = routeTaskIdentity(request);
|
|
1685
|
+
if (!key) return null;
|
|
1686
|
+
const card = [...cards.values()].find(c => routeTaskIdentity(c) === key);
|
|
1687
|
+
const prior = card || [...decided.values()].find(c => routeTaskIdentity(c) === key);
|
|
1688
|
+
if (!prior) return null;
|
|
1689
|
+
assertCurrentTask(sessionId, request.taskId);
|
|
1690
|
+
let continuation = false;
|
|
1691
|
+
// A thinking switch that waited is decided again now (the background work may have reported since).
|
|
1692
|
+
let corrections = (prior.corrections || []).filter((c) => c?.reason !== 'thinking_waits');
|
|
1693
|
+
if (prior.status === 'approved' && prior.target) {
|
|
1694
|
+
if (!deliver) continuation = continuesNow(sessionId, prior.target, context.brain, { reroute: true });
|
|
1695
|
+
else {
|
|
1696
|
+
try { continuation = maybeContinuation(sessionId, prior.target, context.brain, prior, { reroute: true }); } catch (error) {
|
|
1697
|
+
if (error?.code !== 'ROUTE_CONTINUATION_FAILED' || !sessionClosing(sessionId)) throw error;
|
|
1698
|
+
// The session is closing or gone: nothing runs, so nothing is promised.
|
|
1699
|
+
log('router:reroute-refused', `${prior.routeId}: the continuation of a re-routed task could not be queued (the session is closing)`);
|
|
1700
|
+
return { ...resultFor('expired', { routeId: prior.routeId, mode: prior.mode, cat: context.cat, brain: context.brain, brainInfo: context.brainInfo, sessionId }), reason: 'superseded' };
|
|
1701
|
+
}
|
|
1702
|
+
}
|
|
1703
|
+
}
|
|
1704
|
+
if (prior.status === 'approved' && prior.target && !continuation) {
|
|
1705
|
+
const waits = thinkingWaits(sessionId, prior.target, turnBrain(sessionId, context.brain), turnBrain(sessionId, context.brain));
|
|
1706
|
+
if (waits) corrections = [...corrections, waits];
|
|
1707
|
+
}
|
|
1708
|
+
return resultFor(prior.status, { routeId: prior.routeId, mode: prior.mode, card, source: prior.decidedBy,
|
|
1709
|
+
target: prior.target, corrections, remembered: prior.remembered,
|
|
1710
|
+
continuation, sessionId, ...context });
|
|
1711
|
+
}
|
|
1712
|
+
// New human requests retire the previous request's pending cards, across every subtask.
|
|
1713
|
+
function expireOtherTasks(sessionId, taskId) {
|
|
1714
|
+
for (const card of [...cards.values()]) if (card.sessionId === sessionId && card.taskId && card.taskId !== taskId) expire(card.routeId, 'superseded', { movedOn: true });
|
|
1715
|
+
// An earlier task's continuation is not watched any more (the runtime dropped it with its generation).
|
|
1716
|
+
for (const entry of continuations.values()) if (entry.sessionId === sessionId && !entry.started && entry.taskId && entry.taskId !== taskId) closeContinuation(entry);
|
|
1717
|
+
}
|
|
1465
1718
|
async function proposeRoute({ sessionId, body = {}, origin = 'agent_route', waitMs = null, signal = null } = {}) {
|
|
1466
1719
|
pruneDecided();
|
|
1467
1720
|
const session = requireSession(sessionId);
|
|
1468
1721
|
const waiting = origin === 'agent_route' ? clarifier?.blocking?.(sessionId, { independent: body.independent === true }) : null;
|
|
1469
1722
|
if (waiting) return clarifyingResult(sessionId, waiting);
|
|
1470
1723
|
const brain = session.brain || {};
|
|
1724
|
+
expireOtherTasks(sessionId, session.latestTaskId || session.taskId);
|
|
1471
1725
|
const cat = await catalogValue();
|
|
1472
1726
|
const brainInfo = brainInfoFor(brain);
|
|
1473
1727
|
const request = normalizeRouteRequest(body, { brain });
|
|
1728
|
+
Object.assign(request, taskIdentity(sessionId, session, body));
|
|
1729
|
+
// The same task routed again (a later turn: a task notification, a mailbox event, the user's next words).
|
|
1730
|
+
const existing = existingTaskResult(request, sessionId, { cat, brain, brainInfo }, { deliver: origin === 'agent_route' });
|
|
1731
|
+
if (existing) return existing;
|
|
1732
|
+
request.plannedSplit = await planRouteSplit(body, session, request.taskClass);
|
|
1733
|
+
request.projectPath = request.plannedSplit?.projectPath || null;
|
|
1734
|
+
if (request.plannedSplit) {
|
|
1735
|
+
request.dispatchOnly = true;
|
|
1736
|
+
request.proposals = request.proposals.map(p => ({ ...p, kind: 'dispatch' }));
|
|
1737
|
+
}
|
|
1474
1738
|
const mode = modeFor(sessionId);
|
|
1475
1739
|
const r = routing();
|
|
1476
1740
|
const evaluation = await evaluateWithBudget(sessionId, { mode, routing: r, request, brain, brainInfo, catalog: cat });
|
|
1741
|
+
const raced = existingTaskResult(request, sessionId, { cat, brain, brainInfo }, { deliver: origin === 'agent_route' });
|
|
1742
|
+
if (raced) return raced;
|
|
1743
|
+
assertCurrentTask(sessionId, request.taskId);
|
|
1477
1744
|
if (evaluation.unavailable === 'budget_exhausted') return budgetDeclinedResult({ sessionId, request, mode, cat, brain, brainInfo, evaluation });
|
|
1478
1745
|
if (evaluation.unavailable) return unavailableResult({ sessionId, request, mode, cat, brain, brainInfo });
|
|
1479
1746
|
if (!evaluation.ask) {
|
|
@@ -1481,21 +1748,25 @@ export function createAssistantRouter({
|
|
|
1481
1748
|
let target = evaluation.auto;
|
|
1482
1749
|
const checked = accountTarget(target, brain, cat, { check: false, select: request.taskClass !== 'chat' });
|
|
1483
1750
|
if (checked.accountError) {
|
|
1484
|
-
const failed = { routeId, sessionId, taskClass: request.taskClass, summary: request.summary, target: checked, status: 'declined', reason: checked.accountError.message, reasonCode: checked.accountError.code, mode };
|
|
1751
|
+
const failed = { routeId, sessionId, taskClass: request.taskClass, summary: request.summary, target: checked, status: 'declined', decidedBy: 'account', reason: checked.accountError.message, reasonCode: checked.accountError.code, mode };
|
|
1485
1752
|
call('routeEvent', sessionId, 'declined', routeView(failed, { catalog: cat, brain, brainInfo }));
|
|
1486
|
-
return { ok: false, status: 'declined', routeId, mode, code: checked.accountError.code, target: describeTarget(checked, { catalog: cat, brain }), next: checked.accountError.message };
|
|
1753
|
+
return { ok: false, status: 'declined', routeId, mode, source: 'account', reasonCode: checked.accountError.code, code: checked.accountError.code, target: describeTarget(checked, { catalog: cat, brain }), next: checked.accountError.message };
|
|
1487
1754
|
}
|
|
1488
1755
|
target = checked;
|
|
1489
1756
|
const decidedBy = evaluation.source === 'remembered' ? 'remembered' : evaluation.source === 'budget' ? 'budget' : 'brain';
|
|
1757
|
+
// Off to or from a level that waits for Claude Code's background work: in place, and the answer says so.
|
|
1758
|
+
const waits = origin === 'agent_route' && request.taskClass !== 'chat' ? thinkingWaits(sessionId, target, brain, turnBrain(sessionId, brain)) : null;
|
|
1490
1759
|
const route = {
|
|
1760
|
+
taskId: request.taskId, taskKey: request.taskKey || '', plannedSplit: request.plannedSplit || null, workflowId: null,
|
|
1491
1761
|
routeId, status: 'approved', sessionId, taskClass: request.taskClass, summary: request.summary, confidence: request.confidence,
|
|
1492
|
-
target, decidedBy, remembered: evaluation.source === 'remembered', corrections: accountCorrections(target, evaluation.corrections), mode,
|
|
1762
|
+
target, decidedBy, remembered: evaluation.source === 'remembered', corrections: [...accountCorrections(target, evaluation.corrections), ...(waits ? [waits] : [])], mode,
|
|
1493
1763
|
reason: request.proposals[0]?.reason || null, runIds: [], expiresAt: now() + DECIDED_TTL_MS,
|
|
1494
1764
|
};
|
|
1495
1765
|
decided.set(routeId, route);
|
|
1496
1766
|
noteBudgetTask(sessionId, request, target);
|
|
1497
1767
|
if (request.taskClass !== 'chat') call('routeEvent', sessionId, 'auto', routeView(route, { catalog: cat, brain, brainInfo }));
|
|
1498
|
-
|
|
1768
|
+
// A chat route is the brain's own turn: it never continues (its effort is the session's).
|
|
1769
|
+
const continuation = origin === 'agent_route' && request.taskClass !== 'chat' ? maybeContinuation(sessionId, target, brain, route) : false;
|
|
1499
1770
|
return resultFor('approved', { routeId, mode, source: evaluation.source, target, corrections: route.corrections, cat, brain, brainInfo, remembered: route.remembered, continuation, sessionId });
|
|
1500
1771
|
}
|
|
1501
1772
|
// The session as it is now (the catalog was awaited since): its computer-use answer decides what the card says.
|
|
@@ -1540,6 +1811,8 @@ export function createAssistantRouter({
|
|
|
1540
1811
|
* the answer came in on; a card of another session is refused (ROUTE_NOT_FOUND).
|
|
1541
1812
|
*/
|
|
1542
1813
|
async function answer(idOrRequestId, response = {}, { origin = 'ui', sessionId = null, authority = null } = {}) {
|
|
1814
|
+
const closed = closedRoute(idOrRequestId, sessionId);
|
|
1815
|
+
if (closed) return { ...resultFor(closed.settled.status, { routeId: closed.routeId, mode: closed.mode, card: closed, sessionId: closed.sessionId }), ...(closed.settled.movedOn ? { reason: 'superseded' } : {}) };
|
|
1543
1816
|
const card = openCard(idOrRequestId, { sessionId });
|
|
1544
1817
|
const routeId = card.routeId;
|
|
1545
1818
|
const cat = await catalogValue();
|
|
@@ -1548,16 +1821,20 @@ export function createAssistantRouter({
|
|
|
1548
1821
|
// decided: an answer in progress never undoes a cancellation or decides a card twice.
|
|
1549
1822
|
if (cards.get(routeId) !== card || card.status !== 'pending') openCard(routeId, { sessionId });
|
|
1550
1823
|
const session = getSession(card.sessionId) || { brain: card.brain };
|
|
1824
|
+
if (card.taskId && session.taskId !== card.taskId) { expire(routeId, 'superseded', { movedOn: true }); throw routeError('ROUTE_TASK_CHANGED', 'This card belongs to an earlier task.', 409); }
|
|
1551
1825
|
const brain = session.brain || card.brain || {};
|
|
1552
1826
|
const brainInfo = brainInfoFor(brain);
|
|
1553
1827
|
const parsed = targetFromAnswer({ card, response, catalog: cat, brain });
|
|
1554
1828
|
if (parsed.declined) {
|
|
1555
1829
|
card.status = 'declined';
|
|
1830
|
+
card.decidedBy = 'user';
|
|
1831
|
+
card.reasonCode = response.reason === 'dismissed' ? 'dismissed' : 'cancelled';
|
|
1556
1832
|
for (const runId of card.runIds) call('declineHeld', runId, 'route_declined');
|
|
1557
1833
|
const view = routeView({ ...card, status: 'declined', decidedBy: 'user' }, { catalog: cat, brain, brainInfo });
|
|
1558
1834
|
call('routeEvent', card.sessionId, 'declined', view);
|
|
1559
1835
|
const result = resultFor('declined', { routeId, mode: card.mode, card, cat, brain, brainInfo, runIds: [...card.runIds] });
|
|
1560
|
-
if (card.mailboxOnDecision && !card.waiters.size) call('mailbox', card.sessionId, { kind: 'route_declined', route: view, runIds: [...card.runIds], text:
|
|
1836
|
+
if (card.mailboxOnDecision && !card.waiters.size) call('mailbox', card.sessionId, { kind: 'route_declined', route: view, runIds: [...card.runIds], text: result.next });
|
|
1837
|
+
if (card.taskId) decided.set(routeId, { ...view, sessionId: card.sessionId, expiresAt: now() + DECIDED_TTL_MS });
|
|
1561
1838
|
settle(card, { status: 'declined', result });
|
|
1562
1839
|
closeCard(card);
|
|
1563
1840
|
return result;
|
|
@@ -1592,11 +1869,21 @@ export function createAssistantRouter({
|
|
|
1592
1869
|
// handed over first. The runtime refuses a pick that turn no longer owns (a
|
|
1593
1870
|
// newer prompt, a Stop or the session closing came after it): then nothing is
|
|
1594
1871
|
// approved or remembered, and the card expires on every host.
|
|
1595
|
-
|
|
1872
|
+
// An effort-only pick continues too: another effort than the brain's running turn is on (continuesNow), unless
|
|
1873
|
+
// its thinking switch waits for Claude Code's background work, which the answer then says (thinkingWaits).
|
|
1874
|
+
const here = keptHere || !card.runIds.size;
|
|
1875
|
+
const continuation = here && continuesNow(card.sessionId, target, brain);
|
|
1876
|
+
const waits = here && !continuation ? thinkingWaits(card.sessionId, target, brain, turnBrain(card.sessionId, brain)) : null;
|
|
1877
|
+
if (waits) corrections.push(waits);
|
|
1596
1878
|
// The decision is claimed here, before the first side effect (the runtime's continuation, the
|
|
1597
1879
|
// held runs, the mailbox): nothing a sink does can close or decide this card again meanwhile.
|
|
1598
1880
|
card.status = 'approved';
|
|
1599
|
-
|
|
1881
|
+
let queued = !continuation;
|
|
1882
|
+
if (continuation) {
|
|
1883
|
+
try { queued = maybeContinuation(card.sessionId, target, brain, { routeId, summary: card.summary, taskClass: card.taskClass, target, decidedBy: 'user', optionId }); }
|
|
1884
|
+
catch { queued = false; }
|
|
1885
|
+
}
|
|
1886
|
+
if (!queued) {
|
|
1600
1887
|
card.status = 'pending';
|
|
1601
1888
|
expire(routeId, 'superseded');
|
|
1602
1889
|
log('router:superseded', `${routeId}: a "do it here" pick after its turn was replaced; nothing approved`);
|
|
@@ -1613,6 +1900,7 @@ export function createAssistantRouter({
|
|
|
1613
1900
|
const heldRuns = keptHere ? [] : [...card.runIds];
|
|
1614
1901
|
const droppedRuns = keptHere ? [...card.runIds] : [];
|
|
1615
1902
|
const route = {
|
|
1903
|
+
taskId: card.taskId, taskKey: card.taskKey || '', plannedSplit: card.plannedSplit || null, workflowId: null,
|
|
1616
1904
|
routeId, status: 'approved', sessionId: card.sessionId, taskClass: card.taskClass, summary: card.summary, confidence: card.confidence,
|
|
1617
1905
|
target, decidedBy: 'user', remembered, optionId, corrections, mode: card.mode, runIds: heldRuns,
|
|
1618
1906
|
reason: card.options.find((o) => o.id === optionId)?.reason || null, alternatives: card.alternatives, expiresAt: now() + DECIDED_TTL_MS,
|
|
@@ -1663,7 +1951,7 @@ export function createAssistantRouter({
|
|
|
1663
1951
|
* dispatcher refuses first gives it back: releaseRoute), a card holds one run,
|
|
1664
1952
|
* and a workflow does not fan out under one card. The desktop keeps both.
|
|
1665
1953
|
*/
|
|
1666
|
-
async function resolveDispatch({ sessionId, spec = {}, origin = 'assistant' } = {}) {
|
|
1954
|
+
async function resolveDispatch({ sessionId, spec = {}, origin = 'assistant', team = null } = {}) {
|
|
1667
1955
|
pruneDecided();
|
|
1668
1956
|
if (origin === 'ui' || !sessionId) return { action: 'start', spec, route: null };
|
|
1669
1957
|
const session = getSession(sessionId);
|
|
@@ -1677,13 +1965,17 @@ export function createAssistantRouter({
|
|
|
1677
1965
|
const remote = session.remote === true;
|
|
1678
1966
|
if (routeId) {
|
|
1679
1967
|
const approved = decided.get(routeId);
|
|
1968
|
+
const bound = approved || cards.get(routeId);
|
|
1969
|
+
if (bound?.sessionId === sessionId && !team) assertCurrentTask(sessionId, bound.taskId);
|
|
1970
|
+
if (bound?.taskId && ['expired', 'cancelled'].includes(bound.status)) throw routeClosedError(lastClosed.get(routeId) || bound);
|
|
1971
|
+
if (bound?.taskId && (bound.status !== 'approved' && bound.status !== 'pending' || bound.consumed)) throw routeError('ROUTE_NOT_APPROVED', 'This task route is closed or already used.', 409);
|
|
1680
1972
|
// The user picked "here" on this route's card: it runs in this conversation, never on a worker
|
|
1681
1973
|
// (a brain's own direct route, or a saved one in Never ask, keeps its old dispatch behaviour).
|
|
1682
1974
|
if (approved && approved.sessionId === sessionId && approved.target?.kind === 'direct' && approved.decidedBy === 'user') {
|
|
1683
1975
|
const where = approved.target.model ? ` on ${approved.target.model}` : '';
|
|
1684
1976
|
throw routeError('ROUTE_IS_DIRECT', `Route ${routeId} was decided by the user to run here, in this conversation${where}, not on a worker. Do the task yourself now; do not dispatch it. If it should go to a worker after all, ask the user, then call agent_route again.`, 409, { routeId, target: approved.target });
|
|
1685
1977
|
}
|
|
1686
|
-
if (approved && approved.sessionId === sessionId && approved.target && !approved.consumed) {
|
|
1978
|
+
if (approved && approved.sessionId === sessionId && approved.target && (approved.plannedSplit || !approved.consumed)) {
|
|
1687
1979
|
// A remote session's route is claimed here, so a second dispatch cannot take it meanwhile.
|
|
1688
1980
|
// `claimed` tells the dispatcher to give it back (releaseRoute) if it refuses the launch
|
|
1689
1981
|
// before a run exists: only the run it starts uses the route up.
|
|
@@ -1708,22 +2000,29 @@ export function createAssistantRouter({
|
|
|
1708
2000
|
}
|
|
1709
2001
|
if (moved.correction) { runTarget = moved.target; budgetCorrection = moved.correction; }
|
|
1710
2002
|
}
|
|
1711
|
-
|
|
2003
|
+
const claim = approved.plannedSplit ? claimSplit(approved, spec, team) : null;
|
|
2004
|
+
if (remote && !approved.plannedSplit) approved.consumed = true;
|
|
1712
2005
|
const applied = { ...spec, provider: runTarget.provider, model: runTarget.model || null, effort: runTarget.effort ?? null, accountId: runTarget.accountId || null, codexAccountId: null, claudeAccountId: null };
|
|
1713
2006
|
const meta = routeMeta(approved, cat, brain, brainInfo);
|
|
1714
2007
|
const route = budgetCorrection ? { ...meta, target: describeTarget(runTarget, { catalog: cat, brain, brainInfo }), corrections: [...(meta.corrections || []), budgetCorrection] } : meta;
|
|
1715
|
-
return { action: 'start', spec: applied, route: { ...route, requested: { provider: spec.provider || null, model: spec.model || null, effort: spec.effort || null } }, ...(remote ? { claimed: true } : {}) };
|
|
2008
|
+
return { action: 'start', spec: applied, route: { ...route, requested: { provider: spec.provider || null, model: spec.model || null, effort: spec.effort || null } }, ...(claim ? { claimed: true, claim } : remote ? { claimed: true } : {}) };
|
|
1716
2009
|
}
|
|
1717
2010
|
const pending = cards.get(routeId);
|
|
2011
|
+
if (pending?.plannedSplit && pending.sessionId === sessionId) throw routeError('ROUTE_NOT_APPROVED', 'Wait for the whole task approval; do not dispatch or route individual workers.', 409, { routeId });
|
|
1718
2012
|
if (pending && pending.sessionId === sessionId && pending.status === 'pending' && !(remote && pending.runIds.size)) {
|
|
1719
2013
|
return { action: 'hold', routeId, spec, route: pendingMeta(pending) };
|
|
1720
2014
|
}
|
|
1721
2015
|
}
|
|
2016
|
+
if (team || spec.workerIndex != null) throw routeError('ROUTE_NOT_APPROVED', 'This split requires its approved route_id; do not route individual workers.', 409);
|
|
1722
2017
|
const request = normalizeRouteRequest({
|
|
1723
2018
|
task_class: spec.taskClass || 'code', confidence: spec.confidence ?? null, summary: spec.title || clip(spec.task, 200),
|
|
1724
2019
|
needs_vision: !!spec.usesComputer,
|
|
1725
2020
|
proposals: [{ kind: 'dispatch', provider: spec.provider || brain.provider, model: spec.model || null, effort: spec.effort || null, accountId: spec.accountId || spec.codexAccountId || spec.claudeAccountId || null }],
|
|
1726
2021
|
}, { brain });
|
|
2022
|
+
Object.assign(request, taskIdentity(sessionId, session, spec));
|
|
2023
|
+
expireOtherTasks(sessionId, session.latestTaskId || request.taskId);
|
|
2024
|
+
const prior = existingTaskResult(request, sessionId, { cat, brain, brainInfo });
|
|
2025
|
+
if (prior && prior.routeId !== routeId) return resolveDispatch({ sessionId, spec: { ...spec, routeId: prior.routeId }, origin, team });
|
|
1727
2026
|
if (!spec.provider) request.proposals[0].provider = brain.provider || 'claude-code';
|
|
1728
2027
|
const evaluation = await evaluateWithBudget(sessionId, { mode, routing: r, request, brain, brainInfo, catalog: cat });
|
|
1729
2028
|
if (evaluation.unavailable === 'budget_exhausted') {
|
|
@@ -1731,6 +2030,9 @@ export function createAssistantRouter({
|
|
|
1731
2030
|
}
|
|
1732
2031
|
if (evaluation.unavailable) throw routeError('NO_CAPABLE_MODEL', noMakerText(request), 409, { requires: request.needsOutput, ...(request.needsOutput ? {} : { needs: 'vision' }), taskClass: request.taskClass });
|
|
1733
2032
|
if (!evaluation.ask) {
|
|
2033
|
+
assertCurrentTask(sessionId, request.taskId);
|
|
2034
|
+
const raced = existingTaskResult(request, sessionId, { cat, brain, brainInfo });
|
|
2035
|
+
if (raced) return resolveDispatch({ sessionId, spec: { ...spec, routeId: raced.routeId }, origin, team });
|
|
1734
2036
|
const t = checkedTarget(evaluation.auto, brain, cat);
|
|
1735
2037
|
noteBudgetTask(sessionId, request, t);
|
|
1736
2038
|
const applied = { ...spec, provider: t.provider, model: t.model || null, effort: t.effort || spec.effort || null, ...(t.accountId ? { accountId: t.accountId, codexAccountId: null, claudeAccountId: null } : {}) };
|
|
@@ -1739,9 +2041,14 @@ export function createAssistantRouter({
|
|
|
1739
2041
|
taskClass: request.taskClass, confidence: request.confidence, target: t, corrections: accountCorrections(t, evaluation.corrections),
|
|
1740
2042
|
remembered: evaluation.source === 'remembered',
|
|
1741
2043
|
};
|
|
2044
|
+
Object.assign(route, taskIdentity(sessionId, session, spec), { summary: request.summary, expiresAt: now() + DECIDED_TTL_MS });
|
|
2045
|
+
if (route.taskId) decided.set(route.routeId, { ...route, status: 'approved', consumed: remote });
|
|
1742
2046
|
return { action: 'start', spec: applied, route: { ...routeMeta(route, cat, brain, brainInfo), requested: { provider: spec.provider || null, model: spec.model || null, effort: spec.effort || null } } };
|
|
1743
2047
|
}
|
|
1744
|
-
|
|
2048
|
+
assertCurrentTask(sessionId, request.taskId);
|
|
2049
|
+
const raced = existingTaskResult(request, sessionId, { cat, brain, brainInfo });
|
|
2050
|
+
if (raced && raced.routeId !== routeId) return resolveDispatch({ sessionId, spec: { ...spec, routeId: raced.routeId }, origin, team });
|
|
2051
|
+
let card = request.taskId ? [...cards.values()].find(c => routeTaskIdentity(c) === routeTaskIdentity(request)) : spec.workflowId && !remote ? [...cards.values()].find((c) => c.sessionId === sessionId && c.status === 'pending' && c.taskId === request.taskId && c.workflowId && c.workflowId === spec.workflowId) : null;
|
|
1745
2052
|
if (!card) {
|
|
1746
2053
|
card = createCard({ sessionId, request, evaluation, brain, brainInfo, cat, mode, origin: 'dispatch', workflowId: spec.workflowId || null });
|
|
1747
2054
|
call('sendCard', sessionId, card.packet);
|
|
@@ -1755,6 +2062,7 @@ export function createAssistantRouter({
|
|
|
1755
2062
|
function routeMeta(route, cat, brain, brainInfo) {
|
|
1756
2063
|
return {
|
|
1757
2064
|
routeId: route.routeId, status: route.status === 'approved' ? 'approved' : route.status, decidedBy: route.decidedBy || null, mode: route.mode || null,
|
|
2065
|
+
plannedSplit: route.plannedSplit || null, taskId: route.taskId || null, taskKey: route.taskKey || '', sessionId: route.sessionId || null,
|
|
1758
2066
|
taskClass: route.taskClass || null, taskClassLabel: TASK_CLASS_META[route.taskClass]?.label || null, confidence: route.confidence ?? null,
|
|
1759
2067
|
target: route.target ? describeTarget(route.target, { catalog: cat, brain, brainInfo }) : null,
|
|
1760
2068
|
corrections: route.corrections || [], remembered: !!route.remembered, decidedAt: new Date(now()).toISOString(),
|
|
@@ -1762,7 +2070,7 @@ export function createAssistantRouter({
|
|
|
1762
2070
|
}
|
|
1763
2071
|
function pendingMeta(card) {
|
|
1764
2072
|
return {
|
|
1765
|
-
routeId: card.routeId, status: 'pending', decidedBy: null, mode: card.mode, taskClass: card.taskClass,
|
|
2073
|
+
routeId: card.routeId, taskId: card.taskId || null, taskKey: card.taskKey || '', sessionId: card.sessionId || null, status: 'pending', decidedBy: null, mode: card.mode, taskClass: card.taskClass,
|
|
1766
2074
|
taskClassLabel: TASK_CLASS_META[card.taskClass]?.label || null, confidence: card.confidence ?? null,
|
|
1767
2075
|
target: null, corrections: [], remembered: false, decidedAt: null,
|
|
1768
2076
|
};
|
|
@@ -1774,8 +2082,33 @@ export function createAssistantRouter({
|
|
|
1774
2082
|
* the route_id gets the route again, so it runs or is refused for the same reason, and never
|
|
1775
2083
|
* falls through to a fresh route of another class.
|
|
1776
2084
|
*/
|
|
1777
|
-
function
|
|
2085
|
+
function claimSplit(route, spec, team) {
|
|
2086
|
+
const split = route.plannedSplit;
|
|
2087
|
+
const mismatch = (text) => { throw routeError('ROUTE_SPLIT_MISMATCH', text, 409, { routeId: route.routeId }); };
|
|
2088
|
+
if (spec.taskClass && spec.taskClass !== route.taskClass) mismatch('Dispatch task_class must match the approved split.');
|
|
2089
|
+
let slot = 1;
|
|
2090
|
+
if (split.flow === 'team') {
|
|
2091
|
+
if (!team?.teamId || !team?.sliceId || spec.workflowId !== `team:${team.teamId}`) mismatch('This route requires agent_team plan → start, not individual dispatches.');
|
|
2092
|
+
if (route.workflowId && route.workflowId !== spec.workflowId) mismatch('This route already belongs to another team.');
|
|
2093
|
+
slot = team.sliceId;
|
|
2094
|
+
} else if (team) mismatch('This task was approved for one worker, not a team.');
|
|
2095
|
+
route.claims ||= new Map();
|
|
2096
|
+
if (route.claims.has(slot) && !team) mismatch('This worker already started. Use agent_send for follow-ups; do not route or dispatch it again.');
|
|
2097
|
+
if (!route.claims.has(slot) && route.claims.size >= split.workers) mismatch('All approved worker slots are assigned.');
|
|
2098
|
+
if (!team && [...route.claims.values()].some(c => c.task === spec.task)) mismatch('Every parallel worker needs a distinct task.');
|
|
2099
|
+
const token = randomBytes(12).toString('hex');
|
|
2100
|
+
const previous = route.claims.get(slot);
|
|
2101
|
+
route.claims.set(slot, { token, task: spec.task });
|
|
2102
|
+
if (team) route.workflowId = spec.workflowId;
|
|
2103
|
+
return { slot, token, previous };
|
|
2104
|
+
}
|
|
2105
|
+
|
|
2106
|
+
function releaseRoute(routeId, claim = null) {
|
|
1778
2107
|
const route = decided.get(String(routeId || ''));
|
|
2108
|
+
if (claim && route?.claims?.get(claim.slot)?.token === claim.token) {
|
|
2109
|
+
if (claim.previous) route.claims.set(claim.slot, claim.previous); else route.claims.delete(claim.slot);
|
|
2110
|
+
return true;
|
|
2111
|
+
}
|
|
1779
2112
|
if (!route?.consumed) return false;
|
|
1780
2113
|
route.consumed = false;
|
|
1781
2114
|
return true;
|
|
@@ -1812,6 +2145,8 @@ export function createAssistantRouter({
|
|
|
1812
2145
|
return true;
|
|
1813
2146
|
}
|
|
1814
2147
|
function cancelForSession(sessionId, reason = 'session_closed', { origins = null } = {}) {
|
|
2148
|
+
// The session closing, its brain going or a Stop: the runtime dropped its continuation; nothing watches it.
|
|
2149
|
+
for (const entry of continuations.values()) if (entry.sessionId === sessionId && !entry.started) closeContinuation(entry);
|
|
1815
2150
|
for (const card of [...cards.values()]) {
|
|
1816
2151
|
if (card.sessionId !== sessionId) continue;
|
|
1817
2152
|
if (origins && !origins.includes(card.origin)) continue;
|
|
@@ -1825,11 +2160,16 @@ export function createAssistantRouter({
|
|
|
1825
2160
|
if (!routeId) return false;
|
|
1826
2161
|
return sessionId === null || sessionId === undefined || cards.get(routeId)?.sessionId === String(sessionId);
|
|
1827
2162
|
}
|
|
2163
|
+
function closedRoute(idOrRequestId, sessionId = null) {
|
|
2164
|
+
const id = String(idOrRequestId);
|
|
2165
|
+
return [...lastClosed.values()].find(c => c.taskId && (c.routeId === id || c.requestId === id)
|
|
2166
|
+
&& (sessionId == null || c.sessionId === String(sessionId)) && ['expired', 'cancelled'].includes(c.settled?.status)) || null;
|
|
2167
|
+
}
|
|
1828
2168
|
function status(routeId) {
|
|
1829
2169
|
const card = cards.get(routeId);
|
|
1830
|
-
if (card) return { routeId, status: card.status, sessionId: card.sessionId, runIds: [...card.runIds], taskClass: card.taskClass, expiresAt: new Date(card.expiresAt).toISOString(), request: card.packet.request };
|
|
2170
|
+
if (card) return { routeId, status: card.status, sessionId: card.sessionId, taskId: card.taskId || null, taskKey: card.taskKey || '', runIds: [...card.runIds], taskClass: card.taskClass, expiresAt: new Date(card.expiresAt).toISOString(), request: card.packet.request };
|
|
1831
2171
|
const route = decided.get(routeId);
|
|
1832
|
-
if (route) return { routeId, status: route.status, sessionId: route.sessionId, runIds: route.runIds || [], taskClass: route.taskClass, target: route.target, decidedBy: route.decidedBy };
|
|
2172
|
+
if (route) return { routeId, status: route.status, sessionId: route.sessionId, taskId: route.taskId || null, taskKey: route.taskKey || '', runIds: route.runIds || [], taskClass: route.taskClass, target: route.target, decidedBy: route.decidedBy, plannedSplit: route.plannedSplit || null, workflowId: route.workflowId || null };
|
|
1833
2173
|
return null;
|
|
1834
2174
|
}
|
|
1835
2175
|
|
|
@@ -1848,16 +2188,18 @@ export function createAssistantRouter({
|
|
|
1848
2188
|
}
|
|
1849
2189
|
|
|
1850
2190
|
function shutdown() {
|
|
2191
|
+
for (const entry of continuations.values()) closeContinuation(entry);
|
|
2192
|
+
continuations.clear();
|
|
1851
2193
|
for (const card of [...cards.values()]) { if (card.timer) clearTimeout(card.timer); settle(card, { status: 'cancelled' }); }
|
|
1852
2194
|
cards.clear();
|
|
1853
2195
|
byRequest.clear();
|
|
1854
2196
|
}
|
|
1855
2197
|
|
|
1856
2198
|
return {
|
|
1857
|
-
propose, answer, resolveDispatch, releaseRoute, holdRuns, cancel, cancelForRun, cancelForSession, pendingCards, owns, status, modeFor, stamp, shutdown,
|
|
2199
|
+
continuationStarted, propose, answer, expireOtherTasks, resolveDispatch, releaseRoute, holdRuns, cancel, cancelForRun, cancelForSession, pendingCards, owns, closedRoute, status, modeFor, stamp, shutdown,
|
|
1858
2200
|
routeClosedError: (routeId) => routeClosedError(lastClosed.get(String(routeId || '')) || { routeId: String(routeId || '') }),
|
|
1859
2201
|
routing, escalationFor: ({ run, depth = 0 }) => escalationFor({ run, catalog: catalog.peek?.() || null, routing: routing(), depth }),
|
|
1860
|
-
_internals: { cards, decided, byRequest },
|
|
2202
|
+
_internals: { cards, decided, byRequest, continuations },
|
|
1861
2203
|
};
|
|
1862
2204
|
}
|
|
1863
2205
|
|