@bastani/atomic 0.9.18 → 0.9.19-alpha.2
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 +100 -0
- package/dist/builtin/intercom/CHANGELOG.md +16 -0
- package/dist/builtin/intercom/README.md +21 -11
- package/dist/builtin/intercom/broker/broker.ts +73 -9
- package/dist/builtin/intercom/broker/client.ts +4 -0
- package/dist/builtin/intercom/broker/framing.ts +5 -2
- package/dist/builtin/intercom/broker/group-membership.ts +4 -2
- package/dist/builtin/intercom/broker/presence-handler.ts +14 -0
- package/dist/builtin/intercom/broker/send-handler.ts +34 -5
- package/dist/builtin/intercom/broker/terminal-questions.ts +29 -0
- package/dist/builtin/intercom/index.bundle.mjs +936 -740
- package/dist/builtin/intercom/package.json +2 -2
- package/dist/builtin/intercom/recipient-purpose.ts +9 -0
- package/dist/builtin/intercom/recoverable-disconnect.ts +2 -3
- package/dist/builtin/intercom/retry-policy.ts +4 -2
- package/dist/builtin/intercom/skills/intercom/SKILL.md +5 -4
- package/dist/builtin/intercom/types.ts +16 -2
- package/dist/builtin/mcp/CHANGELOG.md +6 -0
- package/dist/builtin/mcp/README.md +2 -0
- package/dist/builtin/mcp/index.bundle.mjs +2201 -12000
- package/dist/builtin/mcp/package.json +2 -2
- package/dist/builtin/subagents/CHANGELOG.md +27 -0
- package/dist/builtin/subagents/README.md +33 -12
- package/dist/builtin/subagents/agents/code-simplifier.md +1 -1
- package/dist/builtin/subagents/agents/codebase-analyzer.md +1 -1
- package/dist/builtin/subagents/agents/codebase-locator.md +2 -2
- package/dist/builtin/subagents/agents/codebase-online-researcher.md +1 -1
- package/dist/builtin/subagents/agents/codebase-pattern-finder.md +2 -2
- package/dist/builtin/subagents/agents/codebase-research-analyzer.md +1 -1
- package/dist/builtin/subagents/agents/codebase-research-locator.md +2 -2
- package/dist/builtin/subagents/agents/debugger.md +1 -1
- package/dist/builtin/subagents/agents/worker.md +1 -1
- package/dist/builtin/subagents/package.json +2 -2
- package/dist/builtin/subagents/skills/herdr/LICENSE +201 -0
- package/dist/builtin/subagents/skills/herdr/SKILL.md +202 -0
- package/dist/builtin/subagents/skills/subagent/SKILL.md +14 -10
- package/dist/builtin/subagents/skills/tmux/SKILL.md +1 -1
- package/dist/builtin/subagents/src/extension/index.bundle.mjs +1284 -609
- package/dist/builtin/web-access/index.bundle.mjs +26280 -26274
- package/dist/builtin/web-access/package.json +2 -2
- package/dist/builtin/workflows/CHANGELOG.md +48 -0
- package/dist/builtin/workflows/README.md +1 -1
- package/dist/builtin/workflows/builtin/adversarial-verification.js +5 -7
- package/dist/builtin/workflows/builtin/{chunk-reqr3sr3.js → chunk-1kx4aggw.js} +22 -22
- package/dist/builtin/workflows/builtin/{chunk-42s7sw0b.js → chunk-62v3gg9f.js} +9 -9
- package/dist/builtin/workflows/builtin/{chunk-wgccch41.js → chunk-6w6cvk6b.js} +16 -16
- package/dist/builtin/workflows/builtin/{chunk-zbekjqew.js → chunk-a2kdsqn8.js} +4 -4
- package/dist/builtin/workflows/builtin/{chunk-ze5x3d1r.js → chunk-fg9esgkj.js} +7 -7
- package/dist/builtin/workflows/builtin/{chunk-n8h4yyew.js → chunk-g0csgs7w.js} +11 -11
- package/dist/builtin/workflows/builtin/{chunk-79fjkcvh.js → chunk-hbnwv56f.js} +17 -17
- package/dist/builtin/workflows/builtin/{chunk-ed4jfn5t.js → chunk-mygmtz6e.js} +43 -43
- package/dist/builtin/workflows/builtin/{chunk-7430zyas.js → chunk-p8jjwfg6.js} +1 -1
- package/dist/builtin/workflows/builtin/{chunk-hqpe2cyx.js → chunk-r9qq7xfj.js} +49 -49
- package/dist/builtin/workflows/builtin/{chunk-k3w87x8y.js → chunk-t6x2d78s.js} +10 -10
- package/dist/builtin/workflows/builtin/{chunk-6fqs7c01.js → chunk-z0d03ktm.js} +1 -1
- package/dist/builtin/workflows/builtin/{chunk-b0v2xab1.js → chunk-zggjyg5z.js} +221 -23
- package/dist/builtin/workflows/builtin/classify-and-act.js +5 -6
- package/dist/builtin/workflows/builtin/fan-out-and-synthesize.js +3 -4
- package/dist/builtin/workflows/builtin/generate-and-filter.js +5 -6
- package/dist/builtin/workflows/builtin/goal.js +7 -8
- package/dist/builtin/workflows/builtin/index.js +20 -22
- package/dist/builtin/workflows/builtin/loop-until-done.js +5 -6
- package/dist/builtin/workflows/builtin/open-claude-design.js +3 -3
- package/dist/builtin/workflows/builtin/ralph.js +7 -8
- package/dist/builtin/workflows/builtin/steering-context.js +3 -3
- package/dist/builtin/workflows/builtin/tournament.js +5 -7
- package/dist/builtin/workflows/package.json +2 -2
- package/dist/builtin/workflows/src/extension/index.bundle.mjs +56236 -25199
- package/dist/builtin/workflows/src/index.js +1217 -547
- package/dist/cli/config-selector.js.map +1 -1
- package/dist/cli/startup-ui.d.ts +1 -1
- package/dist/cli/startup-ui.js.map +1 -1
- package/dist/core/agent-session-auto-compaction.d.ts.map +1 -1
- package/dist/core/agent-session-auto-compaction.js +5 -4
- package/dist/core/agent-session-auto-compaction.js.map +1 -1
- package/dist/core/agent-session-bash.d.ts +1 -1
- package/dist/core/agent-session-bash.d.ts.map +1 -1
- package/dist/core/agent-session-bash.js +5 -1
- package/dist/core/agent-session-bash.js.map +1 -1
- package/dist/core/agent-session-compaction.d.ts +1 -1
- package/dist/core/agent-session-compaction.js.map +1 -1
- package/dist/core/agent-session-custom-message-commit.d.ts +1 -1
- package/dist/core/agent-session-custom-message-commit.js.map +1 -1
- package/dist/core/agent-session-delivery-forwarding.d.ts +1 -1
- package/dist/core/agent-session-delivery-forwarding.js.map +1 -1
- package/dist/core/agent-session-events.d.ts.map +1 -1
- package/dist/core/agent-session-events.js +5 -0
- package/dist/core/agent-session-events.js.map +1 -1
- package/dist/core/agent-session-export.d.ts +1 -1
- package/dist/core/agent-session-export.js.map +1 -1
- package/dist/core/agent-session-extension-bindings.d.ts +8 -1
- package/dist/core/agent-session-extension-bindings.d.ts.map +1 -1
- package/dist/core/agent-session-extension-bindings.js +45 -3
- package/dist/core/agent-session-extension-bindings.js.map +1 -1
- package/dist/core/agent-session-message-queue.d.ts +1 -1
- package/dist/core/agent-session-message-queue.js.map +1 -1
- package/dist/core/agent-session-methods.d.ts +14 -7
- package/dist/core/agent-session-methods.d.ts.map +1 -1
- package/dist/core/agent-session-methods.js.map +1 -1
- package/dist/core/agent-session-prompt.d.ts +2 -2
- package/dist/core/agent-session-prompt.d.ts.map +1 -1
- package/dist/core/agent-session-prompt.js +22 -18
- package/dist/core/agent-session-prompt.js.map +1 -1
- package/dist/core/agent-session-runtime-auth.d.ts +1 -1
- package/dist/core/agent-session-runtime-auth.js.map +1 -1
- package/dist/core/agent-session-runtime.d.ts +13 -4
- package/dist/core/agent-session-runtime.d.ts.map +1 -1
- package/dist/core/agent-session-runtime.js +27 -4
- package/dist/core/agent-session-runtime.js.map +1 -1
- package/dist/core/agent-session-services.d.ts +5 -1
- package/dist/core/agent-session-services.d.ts.map +1 -1
- package/dist/core/agent-session-services.js +44 -34
- package/dist/core/agent-session-services.js.map +1 -1
- package/dist/core/agent-session-state.d.ts +1 -1
- package/dist/core/agent-session-state.js.map +1 -1
- package/dist/core/agent-session-tasks.d.ts +9 -0
- package/dist/core/agent-session-tasks.d.ts.map +1 -0
- package/dist/core/agent-session-tasks.js +113 -0
- package/dist/core/agent-session-tasks.js.map +1 -0
- package/dist/core/agent-session-tool-registry.d.ts +1 -0
- package/dist/core/agent-session-tool-registry.d.ts.map +1 -1
- package/dist/core/agent-session-tool-registry.js +30 -5
- package/dist/core/agent-session-tool-registry.js.map +1 -1
- package/dist/core/agent-session-tree.d.ts.map +1 -1
- package/dist/core/agent-session-tree.js +3 -0
- package/dist/core/agent-session-tree.js.map +1 -1
- package/dist/core/agent-session-types.d.ts +2 -2
- package/dist/core/agent-session-types.js.map +1 -1
- package/dist/core/agent-session.d.ts +4 -1
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +7 -1
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/bash-executor.d.ts +1 -1
- package/dist/core/bash-executor.js.map +1 -1
- package/dist/core/export-html/index.js.map +1 -1
- package/dist/core/export-html/tool-renderer.d.ts +1 -1
- package/dist/core/export-html/tool-renderer.js.map +1 -1
- package/dist/core/extension-session-state.js.map +1 -1
- package/dist/core/extensions/agent-events.d.ts +4 -4
- package/dist/core/extensions/agent-events.d.ts.map +1 -1
- package/dist/core/extensions/agent-events.js.map +1 -1
- package/dist/core/extensions/api-types.d.ts +8 -2
- package/dist/core/extensions/api-types.d.ts.map +1 -1
- package/dist/core/extensions/api-types.js.map +1 -1
- package/dist/core/extensions/context-types.d.ts +9 -0
- package/dist/core/extensions/context-types.d.ts.map +1 -1
- package/dist/core/extensions/context-types.js.map +1 -1
- package/dist/core/extensions/event-results.d.ts +1 -1
- package/dist/core/extensions/event-results.js.map +1 -1
- package/dist/core/extensions/event-types.d.ts +2 -1
- package/dist/core/extensions/event-types.d.ts.map +1 -1
- package/dist/core/extensions/event-types.js.map +1 -1
- package/dist/core/extensions/index.d.ts +2 -1
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/loader-api.d.ts +1 -1
- package/dist/core/extensions/loader-api.d.ts.map +1 -1
- package/dist/core/extensions/loader-api.js +7 -0
- package/dist/core/extensions/loader-api.js.map +1 -1
- package/dist/core/extensions/loader-core.d.ts +1 -1
- package/dist/core/extensions/loader-core.js.map +1 -1
- package/dist/core/extensions/loader-discovery.d.ts +1 -1
- package/dist/core/extensions/loader-discovery.js.map +1 -1
- package/dist/core/extensions/loader-runtime.d.ts.map +1 -1
- package/dist/core/extensions/loader-runtime.js +3 -0
- package/dist/core/extensions/loader-runtime.js.map +1 -1
- package/dist/core/extensions/loader.d.ts +1 -1
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/message-types.d.ts +1 -1
- package/dist/core/extensions/message-types.js.map +1 -1
- package/dist/core/extensions/runner-context.d.ts +11 -1
- package/dist/core/extensions/runner-context.d.ts.map +1 -1
- package/dist/core/extensions/runner-context.js +41 -2
- package/dist/core/extensions/runner-context.js.map +1 -1
- package/dist/core/extensions/runner-events.d.ts +1 -1
- package/dist/core/extensions/runner-events.d.ts.map +1 -1
- package/dist/core/extensions/runner-events.js +17 -2
- package/dist/core/extensions/runner-events.js.map +1 -1
- package/dist/core/extensions/runner-ui.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +17 -2
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +68 -18
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/runtime-types.d.ts +4 -1
- package/dist/core/extensions/runtime-types.d.ts.map +1 -1
- package/dist/core/extensions/runtime-types.js.map +1 -1
- package/dist/core/extensions/tool-types.d.ts +1 -1
- package/dist/core/extensions/tool-types.js.map +1 -1
- package/dist/core/extensions/types.d.ts +1 -0
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/extensions/ui-types.d.ts +5 -1
- package/dist/core/extensions/ui-types.d.ts.map +1 -1
- package/dist/core/extensions/ui-types.js.map +1 -1
- package/dist/core/extensions/workflow-activity-hub.d.ts +25 -0
- package/dist/core/extensions/workflow-activity-hub.d.ts.map +1 -0
- package/dist/core/extensions/workflow-activity-hub.js +183 -0
- package/dist/core/extensions/workflow-activity-hub.js.map +1 -0
- package/dist/core/extensions/workflow-events.d.ts +118 -0
- package/dist/core/extensions/workflow-events.d.ts.map +1 -0
- package/dist/core/extensions/workflow-events.js +2 -0
- package/dist/core/extensions/workflow-events.js.map +1 -0
- package/dist/core/footer-data-provider.d.ts +8 -4
- package/dist/core/footer-data-provider.d.ts.map +1 -1
- package/dist/core/footer-data-provider.js +97 -11
- package/dist/core/footer-data-provider.js.map +1 -1
- package/dist/core/index.d.ts +3 -3
- package/dist/core/index.js.map +1 -1
- package/dist/core/keybindings.d.ts +27 -2
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +7 -2
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/mandatory-runtime-tools.d.ts +1 -1
- package/dist/core/mandatory-runtime-tools.js.map +1 -1
- package/dist/core/model-fallback-failures.js +2 -2
- package/dist/core/model-fallback-failures.js.map +1 -1
- package/dist/core/model-registry.d.ts +5 -1
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +8 -0
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/model-resolver-defaults.js +1 -1
- package/dist/core/model-resolver-defaults.js.map +1 -1
- package/dist/core/resource-loader-assets.js.map +1 -1
- package/dist/core/resource-loader-core.d.ts +1 -1
- package/dist/core/resource-loader-core.js.map +1 -1
- package/dist/core/resource-loader-internals.d.ts +2 -2
- package/dist/core/resource-loader-internals.js.map +1 -1
- package/dist/core/resource-loader-reload.d.ts +2 -0
- package/dist/core/resource-loader-reload.d.ts.map +1 -1
- package/dist/core/resource-loader-reload.js +231 -191
- package/dist/core/resource-loader-reload.js.map +1 -1
- package/dist/core/resource-loader-types.d.ts +4 -2
- package/dist/core/resource-loader-types.d.ts.map +1 -1
- package/dist/core/resource-loader-types.js.map +1 -1
- package/dist/core/sdk-exports.d.ts +2 -2
- package/dist/core/sdk-exports.js.map +1 -1
- package/dist/core/sdk-types.d.ts +2 -2
- package/dist/core/sdk-types.js.map +1 -1
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/settings-manager-core.d.ts.map +1 -1
- package/dist/core/settings-manager-core.js +10 -4
- package/dist/core/settings-manager-core.js.map +1 -1
- package/dist/core/settings-storage.d.ts +1 -0
- package/dist/core/settings-storage.d.ts.map +1 -1
- package/dist/core/settings-storage.js +18 -0
- package/dist/core/settings-storage.js.map +1 -1
- package/dist/core/settings-types.d.ts +11 -0
- package/dist/core/settings-types.d.ts.map +1 -1
- package/dist/core/settings-types.js.map +1 -1
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +2 -0
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +5 -6
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tasks/agent-adapter.d.ts +32 -0
- package/dist/core/tasks/agent-adapter.d.ts.map +1 -0
- package/dist/core/tasks/agent-adapter.js +71 -0
- package/dist/core/tasks/agent-adapter.js.map +1 -0
- package/dist/core/tasks/command-output.d.ts +15 -0
- package/dist/core/tasks/command-output.d.ts.map +1 -0
- package/dist/core/tasks/command-output.js +29 -0
- package/dist/core/tasks/command-output.js.map +1 -0
- package/dist/core/tasks/completion-ordering.d.ts +11 -0
- package/dist/core/tasks/completion-ordering.d.ts.map +1 -0
- package/dist/core/tasks/completion-ordering.js +19 -0
- package/dist/core/tasks/completion-ordering.js.map +1 -0
- package/dist/core/tasks/completion.d.ts +36 -0
- package/dist/core/tasks/completion.d.ts.map +1 -0
- package/dist/core/tasks/completion.js +115 -0
- package/dist/core/tasks/completion.js.map +1 -0
- package/dist/core/tasks/contracts.d.ts +404 -0
- package/dist/core/tasks/contracts.d.ts.map +1 -0
- package/dist/core/tasks/contracts.js +2 -0
- package/dist/core/tasks/contracts.js.map +1 -0
- package/dist/core/tasks/execution-scope.d.ts +10 -0
- package/dist/core/tasks/execution-scope.d.ts.map +1 -0
- package/dist/core/tasks/execution-scope.js +27 -0
- package/dist/core/tasks/execution-scope.js.map +1 -0
- package/dist/core/tasks/owner-store.d.ts +53 -0
- package/dist/core/tasks/owner-store.d.ts.map +1 -0
- package/dist/core/tasks/owner-store.js +155 -0
- package/dist/core/tasks/owner-store.js.map +1 -0
- package/dist/core/tasks/supervisor.d.ts +121 -0
- package/dist/core/tasks/supervisor.d.ts.map +1 -0
- package/dist/core/tasks/supervisor.js +916 -0
- package/dist/core/tasks/supervisor.js.map +1 -0
- package/dist/core/tasks/transcript.d.ts +23 -0
- package/dist/core/tasks/transcript.d.ts.map +1 -0
- package/dist/core/tasks/transcript.js +74 -0
- package/dist/core/tasks/transcript.js.map +1 -0
- package/dist/core/tools/ask-user-question/ask-user-question.d.ts +2 -2
- package/dist/core/tools/ask-user-question/ask-user-question.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/ask-user-question.js +8 -4
- package/dist/core/tools/ask-user-question/ask-user-question.js.map +1 -1
- package/dist/core/tools/ask-user-question/state/build-questionnaire.d.ts +1 -1
- package/dist/core/tools/ask-user-question/state/build-questionnaire.js.map +1 -1
- package/dist/core/tools/ask-user-question/state/questionnaire-session.d.ts +1 -1
- package/dist/core/tools/ask-user-question/state/questionnaire-session.js.map +1 -1
- package/dist/core/tools/ask-user-question/view/components/multi-select-view.d.ts +1 -1
- package/dist/core/tools/ask-user-question/view/components/multi-select-view.js.map +1 -1
- package/dist/core/tools/ask-user-question/view/components/preview/markdown-content-cache.d.ts +1 -1
- package/dist/core/tools/ask-user-question/view/components/preview/markdown-content-cache.js.map +1 -1
- package/dist/core/tools/ask-user-question/view/components/preview/preview-block-renderer.d.ts +1 -1
- package/dist/core/tools/ask-user-question/view/components/preview/preview-block-renderer.js.map +1 -1
- package/dist/core/tools/ask-user-question/view/components/submit-picker.d.ts +1 -1
- package/dist/core/tools/ask-user-question/view/components/submit-picker.js.map +1 -1
- package/dist/core/tools/ask-user-question/view/components/tab-bar.d.ts +1 -1
- package/dist/core/tools/ask-user-question/view/components/tab-bar.js.map +1 -1
- package/dist/core/tools/ask-user-question/view/dialog-builder.d.ts +1 -1
- package/dist/core/tools/ask-user-question/view/dialog-builder.js.map +1 -1
- package/dist/core/tools/ask-user-question/view/tab-content-strategy.d.ts +1 -1
- package/dist/core/tools/ask-user-question/view/tab-content-strategy.js.map +1 -1
- package/dist/core/tools/bash-pty-native.d.ts +18 -3
- package/dist/core/tools/bash-pty-native.d.ts.map +1 -1
- package/dist/core/tools/bash-pty-native.js +116 -1
- package/dist/core/tools/bash-pty-native.js.map +1 -1
- package/dist/core/tools/bash.d.ts +11 -4
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +52 -8
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/edit.d.ts.map +1 -1
- package/dist/core/tools/edit.js +1 -2
- package/dist/core/tools/edit.js.map +1 -1
- package/dist/core/tools/find.js.map +1 -1
- package/dist/core/tools/grep.js.map +1 -1
- package/dist/core/tools/index.d.ts +2 -2
- package/dist/core/tools/index.js.map +1 -1
- package/dist/core/tools/ls.js.map +1 -1
- package/dist/core/tools/powershell.d.ts +20 -10
- package/dist/core/tools/powershell.d.ts.map +1 -1
- package/dist/core/tools/powershell.js +32 -7
- package/dist/core/tools/powershell.js.map +1 -1
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js +1 -2
- package/dist/core/tools/read.js.map +1 -1
- package/dist/core/tools/render-utils.d.ts +1 -1
- package/dist/core/tools/render-utils.js.map +1 -1
- package/dist/core/tools/resource-selectors.d.ts.map +1 -1
- package/dist/core/tools/resource-selectors.js +15 -7
- package/dist/core/tools/resource-selectors.js.map +1 -1
- package/dist/core/tools/search.js.map +1 -1
- package/dist/core/tools/todos-render.d.ts +1 -1
- package/dist/core/tools/todos-render.js.map +1 -1
- package/dist/core/tools/write.d.ts.map +1 -1
- package/dist/core/tools/write.js +1 -2
- package/dist/core/tools/write.js.map +1 -1
- package/dist/core/workflow-stage-admission.d.ts +10 -0
- package/dist/core/workflow-stage-admission.d.ts.map +1 -1
- package/dist/core/workflow-stage-admission.js +24 -0
- package/dist/core/workflow-stage-admission.js.map +1 -1
- package/dist/extensions/herdr/activity.d.ts +15 -0
- package/dist/extensions/herdr/activity.d.ts.map +1 -0
- package/dist/extensions/herdr/activity.js +24 -0
- package/dist/extensions/herdr/activity.js.map +1 -0
- package/dist/extensions/herdr/environment.d.ts +7 -0
- package/dist/extensions/herdr/environment.d.ts.map +1 -0
- package/dist/extensions/herdr/environment.js +6 -0
- package/dist/extensions/herdr/environment.js.map +1 -0
- package/dist/extensions/herdr/index.d.ts +9 -0
- package/dist/extensions/herdr/index.d.ts.map +1 -0
- package/dist/extensions/herdr/index.js +225 -0
- package/dist/extensions/herdr/index.js.map +1 -0
- package/dist/extensions/herdr/pane-owner.d.ts +30 -0
- package/dist/extensions/herdr/pane-owner.d.ts.map +1 -0
- package/dist/extensions/herdr/pane-owner.js +111 -0
- package/dist/extensions/herdr/pane-owner.js.map +1 -0
- package/dist/extensions/herdr/transport.d.ts +8 -0
- package/dist/extensions/herdr/transport.d.ts.map +1 -0
- package/dist/extensions/herdr/transport.js +28 -0
- package/dist/extensions/herdr/transport.js.map +1 -0
- package/dist/extensions/index.d.ts.map +1 -1
- package/dist/extensions/index.js +2 -0
- package/dist/extensions/index.js.map +1 -1
- package/dist/extensions/llama/huggingface-ui.d.ts +1 -1
- package/dist/extensions/llama/huggingface-ui.js.map +1 -1
- package/dist/extensions/llama/ui.js.map +1 -1
- package/dist/index-extensions.d.ts +3 -2
- package/dist/index-extensions.d.ts.map +1 -1
- package/dist/index-extensions.js.map +1 -1
- package/dist/index.d.ts +11 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -1
- package/dist/main-session.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +149 -69
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/armin.js.map +1 -1
- package/dist/modes/interactive/components/assistant-message.js.map +1 -1
- package/dist/modes/interactive/components/atomic-banner.d.ts +1 -1
- package/dist/modes/interactive/components/atomic-banner.js.map +1 -1
- package/dist/modes/interactive/components/atomic-working-status.js.map +1 -1
- package/dist/modes/interactive/components/bash-execution.js.map +1 -1
- package/dist/modes/interactive/components/bordered-loader.d.ts +1 -1
- package/dist/modes/interactive/components/bordered-loader.js.map +1 -1
- package/dist/modes/interactive/components/branch-summary-message.js.map +1 -1
- package/dist/modes/interactive/components/chat-message-renderer.d.ts +12 -0
- package/dist/modes/interactive/components/chat-message-renderer.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-message-renderer.js +44 -0
- package/dist/modes/interactive/components/chat-message-renderer.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-actions.d.ts +1 -1
- package/dist/modes/interactive/components/chat-session-host-actions.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-actions.js +43 -8
- package/dist/modes/interactive/components/chat-session-host-actions.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-editor.d.ts +1 -1
- package/dist/modes/interactive/components/chat-session-host-editor.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-events.d.ts +2 -2
- package/dist/modes/interactive/components/chat-session-host-events.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-rendering.d.ts +2 -2
- package/dist/modes/interactive/components/chat-session-host-rendering.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-rendering.js +12 -3
- package/dist/modes/interactive/components/chat-session-host-rendering.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-runtime.d.ts +4 -5
- package/dist/modes/interactive/components/chat-session-host-runtime.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-runtime.js +8 -6
- package/dist/modes/interactive/components/chat-session-host-runtime.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-state.d.ts +7 -2
- package/dist/modes/interactive/components/chat-session-host-state.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-state.js +1 -0
- package/dist/modes/interactive/components/chat-session-host-state.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-terminal-cleanup.d.ts +1 -1
- package/dist/modes/interactive/components/chat-session-host-terminal-cleanup.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-types.d.ts +8 -3
- package/dist/modes/interactive/components/chat-session-host-types.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-types.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-utils.d.ts +1 -1
- package/dist/modes/interactive/components/chat-session-host-utils.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-utils.js +2 -0
- package/dist/modes/interactive/components/chat-session-host-utils.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host.d.ts +17 -2
- package/dist/modes/interactive/components/chat-session-host.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host.js +97 -1
- package/dist/modes/interactive/components/chat-session-host.js.map +1 -1
- package/dist/modes/interactive/components/chat-transcript.d.ts +1 -0
- package/dist/modes/interactive/components/chat-transcript.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-transcript.js +1 -1
- package/dist/modes/interactive/components/chat-transcript.js.map +1 -1
- package/dist/modes/interactive/components/compaction-boundary-message.js.map +1 -1
- package/dist/modes/interactive/components/config-selector-list.js.map +1 -1
- package/dist/modes/interactive/components/config-selector.js.map +1 -1
- package/dist/modes/interactive/components/custom-editor.js.map +1 -1
- package/dist/modes/interactive/components/custom-entry.js.map +1 -1
- package/dist/modes/interactive/components/custom-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-message.js +12 -0
- package/dist/modes/interactive/components/custom-message.js.map +1 -1
- package/dist/modes/interactive/components/daxnuts.js.map +1 -1
- package/dist/modes/interactive/components/diff.js.map +1 -1
- package/dist/modes/interactive/components/dynamic-border.js.map +1 -1
- package/dist/modes/interactive/components/earendil-announcement.js.map +1 -1
- package/dist/modes/interactive/components/extension-editor.js.map +1 -1
- package/dist/modes/interactive/components/extension-input.js.map +1 -1
- package/dist/modes/interactive/components/extension-selector.js.map +1 -1
- package/dist/modes/interactive/components/first-time-setup.d.ts +1 -1
- package/dist/modes/interactive/components/first-time-setup.js.map +1 -1
- package/dist/modes/interactive/components/footer.d.ts +7 -6
- package/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/dist/modes/interactive/components/footer.js +27 -9
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/components/host-input-form-mount.js.map +1 -1
- package/dist/modes/interactive/components/host-input-form.d.ts +1 -1
- package/dist/modes/interactive/components/host-input-form.js.map +1 -1
- package/dist/modes/interactive/components/index.d.ts +2 -2
- package/dist/modes/interactive/components/index.js.map +1 -1
- package/dist/modes/interactive/components/keybinding-hints.js.map +1 -1
- package/dist/modes/interactive/components/login-dialog.js.map +1 -1
- package/dist/modes/interactive/components/mermaid.d.ts +1 -1
- package/dist/modes/interactive/components/mermaid.js.map +1 -1
- package/dist/modes/interactive/components/model-selector.js.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
- package/dist/modes/interactive/components/reserved-bottom-overlay.js.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
- package/dist/modes/interactive/components/session-selector-header.js.map +1 -1
- package/dist/modes/interactive/components/session-selector-list.js.map +1 -1
- package/dist/modes/interactive/components/session-selector.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector-items.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector-submenus.d.ts +1 -1
- package/dist/modes/interactive/components/settings-selector-submenus.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector-types.d.ts +1 -1
- package/dist/modes/interactive/components/settings-selector-types.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/components/show-images-selector.js.map +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.d.ts +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -1
- package/dist/modes/interactive/components/task-completion-message.d.ts +13 -0
- package/dist/modes/interactive/components/task-completion-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/task-completion-message.js +65 -0
- package/dist/modes/interactive/components/task-completion-message.js.map +1 -0
- package/dist/modes/interactive/components/task-detail.d.ts +27 -0
- package/dist/modes/interactive/components/task-detail.d.ts.map +1 -0
- package/dist/modes/interactive/components/task-detail.js +107 -0
- package/dist/modes/interactive/components/task-detail.js.map +1 -0
- package/dist/modes/interactive/components/task-inspector.d.ts +50 -0
- package/dist/modes/interactive/components/task-inspector.d.ts.map +1 -0
- package/dist/modes/interactive/components/task-inspector.js +599 -0
- package/dist/modes/interactive/components/task-inspector.js.map +1 -0
- package/dist/modes/interactive/components/task-list.d.ts +18 -0
- package/dist/modes/interactive/components/task-list.d.ts.map +1 -0
- package/dist/modes/interactive/components/task-list.js +59 -0
- package/dist/modes/interactive/components/task-list.js.map +1 -0
- package/dist/modes/interactive/components/task-live-transcript.d.ts +17 -0
- package/dist/modes/interactive/components/task-live-transcript.d.ts.map +1 -0
- package/dist/modes/interactive/components/task-live-transcript.js +33 -0
- package/dist/modes/interactive/components/task-live-transcript.js.map +1 -0
- package/dist/modes/interactive/components/task-navigation.d.ts +38 -0
- package/dist/modes/interactive/components/task-navigation.d.ts.map +1 -0
- package/dist/modes/interactive/components/task-navigation.js +93 -0
- package/dist/modes/interactive/components/task-navigation.js.map +1 -0
- package/dist/modes/interactive/components/task-row.d.ts +34 -0
- package/dist/modes/interactive/components/task-row.d.ts.map +1 -0
- package/dist/modes/interactive/components/task-row.js +158 -0
- package/dist/modes/interactive/components/task-row.js.map +1 -0
- package/dist/modes/interactive/components/theme-selector.js.map +1 -1
- package/dist/modes/interactive/components/thinking-selector.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/components/transcript-follow-indicator.js.map +1 -1
- package/dist/modes/interactive/components/tree-selector-component.js.map +1 -1
- package/dist/modes/interactive/components/tree-selector-content.js.map +1 -1
- package/dist/modes/interactive/components/tree-selector-help.js.map +1 -1
- package/dist/modes/interactive/components/tree-selector-label-input.js.map +1 -1
- package/dist/modes/interactive/components/tree-selector-list.js.map +1 -1
- package/dist/modes/interactive/components/trust-selector.js.map +1 -1
- package/dist/modes/interactive/components/user-message-selector.js.map +1 -1
- package/dist/modes/interactive/components/user-message.js.map +1 -1
- package/dist/modes/interactive/components/working-status.js.map +1 -1
- package/dist/modes/interactive/interactive-agent-events.js +8 -2
- package/dist/modes/interactive/interactive-agent-events.js.map +1 -1
- package/dist/modes/interactive/interactive-auth-login.js +3 -1
- package/dist/modes/interactive/interactive-auth-login.js.map +1 -1
- package/dist/modes/interactive/interactive-autocomplete.js +9 -30
- package/dist/modes/interactive/interactive-autocomplete.js.map +1 -1
- package/dist/modes/interactive/interactive-deferred-startup.js +2 -1
- package/dist/modes/interactive/interactive-deferred-startup.js.map +1 -1
- package/dist/modes/interactive/interactive-extension-context.js +14 -4
- package/dist/modes/interactive/interactive-extension-context.js.map +1 -1
- package/dist/modes/interactive/interactive-extension-custom-ui.js +52 -4
- package/dist/modes/interactive/interactive-extension-custom-ui.js.map +1 -1
- package/dist/modes/interactive/interactive-extension-runtime.js +1 -0
- package/dist/modes/interactive/interactive-extension-runtime.js.map +1 -1
- package/dist/modes/interactive/interactive-extension-widgets.js +9 -1
- package/dist/modes/interactive/interactive-extension-widgets.js.map +1 -1
- package/dist/modes/interactive/interactive-input-handling.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-input-handling.js +19 -0
- package/dist/modes/interactive/interactive-input-handling.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-base.d.ts +6 -1
- package/dist/modes/interactive/interactive-mode-base.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-base.js +4 -1
- package/dist/modes/interactive/interactive-mode-base.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-deps.d.ts +6 -6
- package/dist/modes/interactive/interactive-mode-deps.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-surface.d.ts +2 -1
- package/dist/modes/interactive/interactive-mode-surface.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-surface.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +1 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +3 -0
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/interactive-process-lifecycle.js +4 -1
- package/dist/modes/interactive/interactive-process-lifecycle.js.map +1 -1
- package/dist/modes/interactive/interactive-render-chat.js +2 -0
- package/dist/modes/interactive/interactive-render-chat.js.map +1 -1
- package/dist/modes/interactive/interactive-session-routing.js +33 -23
- package/dist/modes/interactive/interactive-session-routing.js.map +1 -1
- package/dist/modes/interactive/interactive-session-runtime.js +1 -0
- package/dist/modes/interactive/interactive-session-runtime.js.map +1 -1
- package/dist/modes/interactive/interactive-slash-commands.js.map +1 -1
- package/dist/modes/interactive/interactive-summarization-retry-events.js +2 -2
- package/dist/modes/interactive/interactive-summarization-retry-events.js.map +1 -1
- package/dist/modes/interactive/interactive-task-projection.d.ts +13 -0
- package/dist/modes/interactive/interactive-task-projection.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-task-projection.js +72 -0
- package/dist/modes/interactive/interactive-task-projection.js.map +1 -0
- package/dist/modes/interactive/interactive-tui.js.map +1 -1
- package/dist/modes/interactive/interactive-windows-subshell.d.ts +17 -0
- package/dist/modes/interactive/interactive-windows-subshell.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-windows-subshell.js +92 -0
- package/dist/modes/interactive/interactive-windows-subshell.js.map +1 -0
- package/dist/modes/interactive/skill-command-autocomplete.d.ts +12 -0
- package/dist/modes/interactive/skill-command-autocomplete.d.ts.map +1 -0
- package/dist/modes/interactive/skill-command-autocomplete.js +69 -0
- package/dist/modes/interactive/skill-command-autocomplete.js.map +1 -0
- package/dist/modes/interactive/theme/theme-class.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme-class.js +4 -1
- package/dist/modes/interactive/theme/theme-class.js.map +1 -1
- package/dist/modes/interactive/theme/theme-controller.d.ts +1 -1
- package/dist/modes/interactive/theme/theme-controller.js.map +1 -1
- package/dist/modes/interactive-engine/create-isolated-runtime.d.ts +1 -1
- package/dist/modes/interactive-engine/create-isolated-runtime.js.map +1 -1
- package/dist/modes/interactive-engine/engine-custom-ui.d.ts +5 -9
- package/dist/modes/interactive-engine/engine-custom-ui.d.ts.map +1 -1
- package/dist/modes/interactive-engine/engine-custom-ui.js +14 -5
- package/dist/modes/interactive-engine/engine-custom-ui.js.map +1 -1
- package/dist/modes/interactive-engine/engine-dialog-host.d.ts +2 -2
- package/dist/modes/interactive-engine/engine-dialog-host.js.map +1 -1
- package/dist/modes/interactive-engine/engine-project-trust.d.ts +10 -0
- package/dist/modes/interactive-engine/engine-project-trust.d.ts.map +1 -0
- package/dist/modes/interactive-engine/engine-project-trust.js +28 -0
- package/dist/modes/interactive-engine/engine-project-trust.js.map +1 -0
- package/dist/modes/interactive-engine/engine-render-service.d.ts +1 -1
- package/dist/modes/interactive-engine/engine-render-service.js.map +1 -1
- package/dist/modes/interactive-engine/extension-ui-bridge.d.ts +3 -1
- package/dist/modes/interactive-engine/extension-ui-bridge.d.ts.map +1 -1
- package/dist/modes/interactive-engine/extension-ui-bridge.js +6 -0
- package/dist/modes/interactive-engine/extension-ui-bridge.js.map +1 -1
- package/dist/modes/interactive-engine/input-form-host.d.ts +2 -2
- package/dist/modes/interactive-engine/input-form-host.js.map +1 -1
- package/dist/modes/interactive-engine/isolated-auth.d.ts +1 -1
- package/dist/modes/interactive-engine/isolated-auth.js.map +1 -1
- package/dist/modes/interactive-engine/isolated-runtime.d.ts +5 -2
- package/dist/modes/interactive-engine/isolated-runtime.d.ts.map +1 -1
- package/dist/modes/interactive-engine/isolated-runtime.js +40 -3
- package/dist/modes/interactive-engine/isolated-runtime.js.map +1 -1
- package/dist/modes/interactive-engine/protocol.d.ts +9 -0
- package/dist/modes/interactive-engine/protocol.d.ts.map +1 -1
- package/dist/modes/interactive-engine/protocol.js +8 -0
- package/dist/modes/interactive-engine/protocol.js.map +1 -1
- package/dist/modes/interactive-engine/remote-component.d.ts +2 -2
- package/dist/modes/interactive-engine/remote-component.d.ts.map +1 -1
- package/dist/modes/interactive-engine/remote-component.js +3 -2
- package/dist/modes/interactive-engine/remote-component.js.map +1 -1
- package/dist/modes/interactive-engine/remote-model-catalog.d.ts +1 -1
- package/dist/modes/interactive-engine/remote-model-catalog.js.map +1 -1
- package/dist/modes/interactive-engine/remote-renderer.d.ts +1 -1
- package/dist/modes/interactive-engine/remote-renderer.js.map +1 -1
- package/dist/modes/interactive-engine/session-picker-host.d.ts +2 -2
- package/dist/modes/interactive-engine/session-picker-host.js.map +1 -1
- package/dist/modes/json-event.d.ts +1 -1
- package/dist/modes/json-event.js.map +1 -1
- package/dist/modes/print-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-bash-request-owners.d.ts +2 -2
- package/dist/modes/rpc/rpc-bash-request-owners.js.map +1 -1
- package/dist/modes/rpc/rpc-client-api.d.ts +2 -2
- package/dist/modes/rpc/rpc-client-api.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client-api.js +2 -2
- package/dist/modes/rpc/rpc-client-api.js.map +1 -1
- package/dist/modes/rpc/rpc-client-waits.d.ts +1 -1
- package/dist/modes/rpc/rpc-client-waits.js.map +1 -1
- package/dist/modes/rpc/rpc-client.d.ts +3 -1
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client.js +20 -0
- package/dist/modes/rpc/rpc-client.js.map +1 -1
- package/dist/modes/rpc/rpc-command-handler.d.ts +4 -2
- package/dist/modes/rpc/rpc-command-handler.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-command-handler.js +12 -4
- package/dist/modes/rpc/rpc-command-handler.js.map +1 -1
- package/dist/modes/rpc/rpc-extension-ui.d.ts +1 -1
- package/dist/modes/rpc/rpc-extension-ui.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +11 -2
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-provider-auth.d.ts +1 -1
- package/dist/modes/rpc/rpc-provider-auth.js.map +1 -1
- package/dist/modes/rpc/rpc-session-binding.d.ts +4 -1
- package/dist/modes/rpc/rpc-session-binding.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-session-binding.js +35 -1
- package/dist/modes/rpc/rpc-session-binding.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +13 -1
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/dist/modes/rpc/task-ui-bridge.d.ts +9 -0
- package/dist/modes/rpc/task-ui-bridge.d.ts.map +1 -0
- package/dist/modes/rpc/task-ui-bridge.js +146 -0
- package/dist/modes/rpc/task-ui-bridge.js.map +1 -0
- package/dist/self-update-plan.js.map +1 -1
- package/docs/background-tasks.md +199 -0
- package/docs/compaction.md +2 -0
- package/docs/development.md +3 -1
- package/docs/docs.json +2 -0
- package/docs/environment-variables.md +1 -1
- package/docs/extensions.md +108 -6
- package/docs/herdr.md +106 -0
- package/docs/intercom.md +38 -35
- package/docs/keybindings.md +19 -2
- package/docs/models/evals.md +222 -147
- package/docs/models/model-selection.md +20 -14
- package/docs/models/pareto-efficiency.md +2 -2
- package/docs/providers.md +48 -46
- package/docs/quickstart.md +2 -2
- package/docs/sdk.md +244 -0
- package/docs/settings.md +15 -3
- package/docs/skills.md +23 -1
- package/docs/subagents.md +71 -9
- package/docs/themes.md +4 -0
- package/docs/tools.md +25 -0
- package/docs/tui.md +29 -2
- package/docs/usage.md +4 -0
- package/docs/windows.md +4 -4
- package/docs/workflows/api-reference.md +13 -4
- package/docs/workflows/operations.md +59 -5
- package/docs/workflows/reliable-design.md +35 -4
- package/docs/workflows/verification.md +21 -4
- package/docs/workflows.md +3 -1
- package/npm-shrinkwrap.json +781 -661
- package/package.json +10 -10
- /package/dist/builtin/workflows/builtin/{chunk-cg9tmks0.js → chunk-n1910xc4.js} +0 -0
- /package/dist/builtin/workflows/builtin/{chunk-wpckd35c.js → chunk-rc5ec5xx.js} +0 -0
- /package/dist/builtin/workflows/builtin/{chunk-7at6dnkr.js → chunk-tgt0s5e5.js} +0 -0
- /package/dist/builtin/workflows/builtin/{chunk-bfkmzv9h.js → chunk-xtxcq5tj.js} +0 -0
|
@@ -0,0 +1,916 @@
|
|
|
1
|
+
import { AsyncResource } from "node:async_hooks";
|
|
2
|
+
import { createModuleRequire } from "../../utils/module-require.js";
|
|
3
|
+
import { COMMAND_FOREGROUND_BUDGET_MS } from "./command-output.js";
|
|
4
|
+
export const DEFAULT_AGENT_WAIT_BUDGET_MS = 30000;
|
|
5
|
+
/** These objects are live authority, not DTOs, restart tokens or model arguments. */
|
|
6
|
+
class Capability {
|
|
7
|
+
#live = true;
|
|
8
|
+
toJSON() {
|
|
9
|
+
throw new TypeError(`Task capability is not serializable (${this.#live ? "live" : "closed"})`);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
class HostCapability extends Capability {
|
|
13
|
+
constructor() {
|
|
14
|
+
super(...arguments);
|
|
15
|
+
this.kind = "host";
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
class OwnerCapability extends Capability {
|
|
19
|
+
constructor() {
|
|
20
|
+
super(...arguments);
|
|
21
|
+
this.kind = "owner";
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
class TaskCapability extends Capability {
|
|
25
|
+
constructor() {
|
|
26
|
+
super(...arguments);
|
|
27
|
+
this.kind = "task";
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
class WaitCapability extends Capability {
|
|
31
|
+
constructor() {
|
|
32
|
+
super(...arguments);
|
|
33
|
+
this.kind = "wait";
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
class SubscriptionCapability extends Capability {
|
|
37
|
+
constructor() {
|
|
38
|
+
super(...arguments);
|
|
39
|
+
this.kind = "subscription";
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
class StdinCapability extends Capability {
|
|
43
|
+
constructor() {
|
|
44
|
+
super(...arguments);
|
|
45
|
+
this.kind = "stdin";
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
// Native supervisors share one actor per environment; their JS continuations must too.
|
|
49
|
+
const environment = {
|
|
50
|
+
hosts: new WeakMap(),
|
|
51
|
+
owners: new WeakMap(),
|
|
52
|
+
tasks: new WeakMap(),
|
|
53
|
+
inputs: new WeakMap(),
|
|
54
|
+
waits: new WeakMap(),
|
|
55
|
+
waitRegistry: new Map(),
|
|
56
|
+
ownerIds: new Map(),
|
|
57
|
+
};
|
|
58
|
+
/** Reads only history bound by the admitted runner, never a caller-selected session. */
|
|
59
|
+
export function taskTranscriptSource(task) {
|
|
60
|
+
const state = environment.tasks.get(task);
|
|
61
|
+
if (!state)
|
|
62
|
+
return { ok: false, error: { code: "UnknownTask", message: "Unknown task" } };
|
|
63
|
+
if (!state.transcript)
|
|
64
|
+
return { ok: false, error: { code: "TranscriptUnavailable", message: "Transcript unavailable" } };
|
|
65
|
+
return { ok: true, value: { session: state.transcript, taskId: state.ref.taskId } };
|
|
66
|
+
}
|
|
67
|
+
/** Promise rejections, setup throws and consumer exceptions may be arbitrary JavaScript values. */
|
|
68
|
+
function rejectionMessage(reason) {
|
|
69
|
+
try {
|
|
70
|
+
const message = reason instanceof Error ? reason.message : reason;
|
|
71
|
+
return typeof message === "string" ? message : String(message);
|
|
72
|
+
}
|
|
73
|
+
catch {
|
|
74
|
+
return "Unprintable JavaScript rejection";
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
function mapped(result, convert, codes) {
|
|
78
|
+
if (result.ok)
|
|
79
|
+
return { ok: true, value: convert(result.value) };
|
|
80
|
+
const code = codes.find((candidate) => candidate === result.error.code);
|
|
81
|
+
if (!code)
|
|
82
|
+
throw new Error(`Unexpected native task refusal: ${result.error.code}: ${result.error.message}`);
|
|
83
|
+
return { ok: false, error: { code, message: result.error.message } };
|
|
84
|
+
}
|
|
85
|
+
const ownerErrors = ["ScopeMismatch", "EnvironmentClosing"];
|
|
86
|
+
const startErrors = [
|
|
87
|
+
"OwnerClosing",
|
|
88
|
+
"UnknownAgent",
|
|
89
|
+
"InvalidCwd",
|
|
90
|
+
"DepthExceeded",
|
|
91
|
+
"CapacityExhausted",
|
|
92
|
+
"DispatchGuardBusy",
|
|
93
|
+
"OperationConflict",
|
|
94
|
+
"RunnerUnavailable",
|
|
95
|
+
"SpawnFailed",
|
|
96
|
+
"ContainmentUnavailable",
|
|
97
|
+
];
|
|
98
|
+
const waitErrors = ["UnknownTask", "OwnerClosed", "EnvironmentClosing", "ScopeMismatch", "ObserverCancelled"];
|
|
99
|
+
const reportErrors = ["StaleAttempt", "OwnerClosing", "TaskTerminal", "ReportConflict"];
|
|
100
|
+
const watchErrors = ["OwnerClosed", "StaleGeneration", "EnvironmentClosing"];
|
|
101
|
+
function reference(value) {
|
|
102
|
+
return {
|
|
103
|
+
ownerId: value.ownerId,
|
|
104
|
+
taskId: value.taskId,
|
|
105
|
+
attemptId: value.attemptId,
|
|
106
|
+
generation: value.generation,
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
function cursor(value) {
|
|
110
|
+
return { generation: value.generation, sequence: value.sequence };
|
|
111
|
+
}
|
|
112
|
+
function output(value) {
|
|
113
|
+
return {
|
|
114
|
+
ownerId: value.ownerId,
|
|
115
|
+
taskId: value.taskId,
|
|
116
|
+
artifactId: value.artifactId,
|
|
117
|
+
byteCount: value.byteCount,
|
|
118
|
+
omittedRanges: value.omittedRanges.map(({ start, end }) => ({ start, end })),
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
function taskResult(value) {
|
|
122
|
+
switch (value.kind) {
|
|
123
|
+
case "completed":
|
|
124
|
+
return {
|
|
125
|
+
kind: value.kind,
|
|
126
|
+
output: output(value.output),
|
|
127
|
+
...(value.exitCode === undefined ? {} : { exitCode: value.exitCode }),
|
|
128
|
+
};
|
|
129
|
+
case "failed":
|
|
130
|
+
return {
|
|
131
|
+
kind: value.kind,
|
|
132
|
+
code: value.code,
|
|
133
|
+
message: value.message,
|
|
134
|
+
...(value.output === undefined ? {} : { output: output(value.output) }),
|
|
135
|
+
...(value.exitCode === undefined ? {} : { exitCode: value.exitCode }),
|
|
136
|
+
};
|
|
137
|
+
case "cancelled":
|
|
138
|
+
return {
|
|
139
|
+
kind: value.kind,
|
|
140
|
+
cause: value.cause,
|
|
141
|
+
...(value.output === undefined ? {} : { output: output(value.output) }),
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
function execution(value) {
|
|
146
|
+
return value.kind === "settled" ? { kind: "settled", result: taskResult(value.result) } : value;
|
|
147
|
+
}
|
|
148
|
+
function observation(value) {
|
|
149
|
+
if (value.kind === "foreground")
|
|
150
|
+
return { kind: value.kind, waitId: value.waitId };
|
|
151
|
+
if (value.kind === "none" && (value.reason === "task-settled" || value.reason === "owner-closing"))
|
|
152
|
+
return { kind: value.kind, reason: value.reason };
|
|
153
|
+
const reasons = [
|
|
154
|
+
"explicit",
|
|
155
|
+
"default-background",
|
|
156
|
+
"elapsed",
|
|
157
|
+
"intercom-coordination",
|
|
158
|
+
"input-needed",
|
|
159
|
+
"not-observed",
|
|
160
|
+
"observer-cancelled",
|
|
161
|
+
];
|
|
162
|
+
const reason = reasons.find((reason) => reason === value.reason);
|
|
163
|
+
if (value.kind === "background" && reason)
|
|
164
|
+
return { kind: value.kind, reason };
|
|
165
|
+
throw new Error("Invalid native host observation");
|
|
166
|
+
}
|
|
167
|
+
function record(value) {
|
|
168
|
+
if (value.kind !== "agent" && value.kind !== "command")
|
|
169
|
+
throw new Error(`Invalid native task kind: ${value.kind}`);
|
|
170
|
+
return {
|
|
171
|
+
ref: reference(value.ref),
|
|
172
|
+
launchOperationId: value.launchOperationId,
|
|
173
|
+
...(value.parentTaskId === undefined ? {} : { parentTaskId: value.parentTaskId }),
|
|
174
|
+
...(value.launchGroupId === undefined ? {} : { launchGroupId: value.launchGroupId }),
|
|
175
|
+
launchOrdinal: value.launchOrdinal,
|
|
176
|
+
kind: value.kind,
|
|
177
|
+
title: value.title,
|
|
178
|
+
...(value.agentName === undefined ? {} : { agentName: value.agentName }),
|
|
179
|
+
...(value.model === undefined ? {} : { model: value.model }),
|
|
180
|
+
...(value.thinking === undefined ? {} : { thinking: value.thinking }),
|
|
181
|
+
execution: execution(value.execution),
|
|
182
|
+
observation: observation(value.observation),
|
|
183
|
+
...(value.wasBackground === undefined ? {} : { wasBackground: value.wasBackground }),
|
|
184
|
+
attention: value.attention,
|
|
185
|
+
cleanup: value.cleanup,
|
|
186
|
+
...(value.currentAction === undefined
|
|
187
|
+
? {}
|
|
188
|
+
: { currentAction: { tool: value.currentAction.tool, text: value.currentAction.text } }),
|
|
189
|
+
...(value.metrics === undefined
|
|
190
|
+
? {}
|
|
191
|
+
: {
|
|
192
|
+
metrics: {
|
|
193
|
+
...(value.metrics.elapsedMs === undefined ? {} : { elapsedMs: value.metrics.elapsedMs }),
|
|
194
|
+
...(value.metrics.toolCount === undefined ? {} : { toolCount: value.metrics.toolCount }),
|
|
195
|
+
...(value.metrics.tokenCount === undefined ? {} : { tokenCount: value.metrics.tokenCount }),
|
|
196
|
+
},
|
|
197
|
+
}),
|
|
198
|
+
output: output(value.output),
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
function snapshot(value) {
|
|
202
|
+
if (value.state !== "open" && value.state !== "closing" && value.state !== "closed")
|
|
203
|
+
throw new Error(`Invalid native owner state: ${value.state}`);
|
|
204
|
+
return {
|
|
205
|
+
ownerId: value.ownerId,
|
|
206
|
+
scope: value.scope,
|
|
207
|
+
generation: value.generation,
|
|
208
|
+
state: value.state,
|
|
209
|
+
tasks: value.tasks.map(record),
|
|
210
|
+
cursor: cursor(value.cursor),
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
function activity(value) {
|
|
214
|
+
if (value.change.kind === "attention-set" && value.change.attention.kind === "none")
|
|
215
|
+
throw new Error("Native attention-set cannot clear attention");
|
|
216
|
+
// Native tagged variants are owned wire data; only attention-set has a wider generated declaration.
|
|
217
|
+
return value;
|
|
218
|
+
}
|
|
219
|
+
function payload(value) {
|
|
220
|
+
switch (value.kind) {
|
|
221
|
+
case "task-admitted":
|
|
222
|
+
return { kind: value.kind, task: record(value.task) };
|
|
223
|
+
case "task-started":
|
|
224
|
+
return { kind: value.kind, ref: reference(value.ref) };
|
|
225
|
+
case "wait-started": {
|
|
226
|
+
if (value.observer !== "sdk" && value.observer !== "host")
|
|
227
|
+
throw new Error("Invalid native observer");
|
|
228
|
+
return {
|
|
229
|
+
kind: value.kind,
|
|
230
|
+
ref: reference(value.ref),
|
|
231
|
+
waitId: value.waitId,
|
|
232
|
+
observer: value.observer,
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
case "wait-yielded":
|
|
236
|
+
return { kind: value.kind, ref: reference(value.ref), waitId: value.waitId, reason: value.reason };
|
|
237
|
+
case "host-observation-changed":
|
|
238
|
+
return { kind: value.kind, ref: reference(value.ref), observation: observation(value.observation) };
|
|
239
|
+
case "task-activity":
|
|
240
|
+
return { kind: value.kind, ref: reference(value.ref), activity: activity(value.activity) };
|
|
241
|
+
case "task-cancelling":
|
|
242
|
+
return { kind: value.kind, ref: reference(value.ref), cause: value.cause };
|
|
243
|
+
case "task-settled":
|
|
244
|
+
return {
|
|
245
|
+
kind: value.kind,
|
|
246
|
+
ref: reference(value.ref),
|
|
247
|
+
result: taskResult(value.result),
|
|
248
|
+
completionId: value.completionId,
|
|
249
|
+
};
|
|
250
|
+
case "cleanup-changed":
|
|
251
|
+
return { kind: value.kind, ref: reference(value.ref), cleanup: value.cleanup };
|
|
252
|
+
case "owner-closing":
|
|
253
|
+
case "owner-closed":
|
|
254
|
+
return { kind: value.kind };
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
function event(value) {
|
|
258
|
+
if (value.schemaVersion !== 1)
|
|
259
|
+
throw new Error("Unsupported native task event schema");
|
|
260
|
+
return {
|
|
261
|
+
schemaVersion: 1,
|
|
262
|
+
cursor: cursor(value.cursor),
|
|
263
|
+
ownerId: value.ownerId,
|
|
264
|
+
...(value.taskId === undefined ? {} : { taskId: value.taskId }),
|
|
265
|
+
payload: payload(value.payload),
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
function waitOutcome(value) {
|
|
269
|
+
return value.kind === "settled"
|
|
270
|
+
? { kind: value.kind, taskId: value.taskId, result: taskResult(value.result) }
|
|
271
|
+
: { kind: value.kind, taskId: value.taskId, waitId: value.waitId, reason: value.reason };
|
|
272
|
+
}
|
|
273
|
+
function cancelReceipt(value) {
|
|
274
|
+
if (value.decision !== "already-settled" && value.decision !== "cancellation-requested")
|
|
275
|
+
throw new Error("Invalid cancellation decision");
|
|
276
|
+
return {
|
|
277
|
+
taskId: value.taskId,
|
|
278
|
+
decision: value.decision,
|
|
279
|
+
execution: execution(value.execution),
|
|
280
|
+
cleanup: value.cleanup,
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
function reportReceipt(value) {
|
|
284
|
+
if (value.disposition !== "accepted" && value.disposition !== "duplicate")
|
|
285
|
+
throw new Error("Invalid report disposition");
|
|
286
|
+
return { reportId: value.reportId, cursor: cursor(value.cursor), disposition: value.disposition };
|
|
287
|
+
}
|
|
288
|
+
/** Projection only: native ordering remains the sole lifecycle authority. */
|
|
289
|
+
function applyEvent(current, value) {
|
|
290
|
+
const next = { ...current, tasks: [...current.tasks], cursor: value.cursor };
|
|
291
|
+
const change = value.payload;
|
|
292
|
+
if (change.kind === "owner-closing") {
|
|
293
|
+
next.state = "closing";
|
|
294
|
+
next.tasks = next.tasks.map((task) => task.execution.kind === "settled" ? task : { ...task, attention: { kind: "none" } });
|
|
295
|
+
return next;
|
|
296
|
+
}
|
|
297
|
+
if (change.kind === "owner-closed") {
|
|
298
|
+
next.state = "closed";
|
|
299
|
+
return next;
|
|
300
|
+
}
|
|
301
|
+
if (change.kind === "task-admitted") {
|
|
302
|
+
next.tasks.push(change.task);
|
|
303
|
+
return next;
|
|
304
|
+
}
|
|
305
|
+
const index = next.tasks.findIndex((task) => task.ref.taskId === change.ref.taskId);
|
|
306
|
+
if (index < 0)
|
|
307
|
+
throw new Error("Native delta references a task absent from its snapshot");
|
|
308
|
+
const task = { ...next.tasks[index] };
|
|
309
|
+
next.tasks[index] = task;
|
|
310
|
+
switch (change.kind) {
|
|
311
|
+
case "task-started":
|
|
312
|
+
task.execution = { kind: "running" };
|
|
313
|
+
break;
|
|
314
|
+
case "host-observation-changed":
|
|
315
|
+
task.observation = change.observation;
|
|
316
|
+
if (change.observation.kind === "background" && change.observation.reason !== "not-observed")
|
|
317
|
+
task.wasBackground = true;
|
|
318
|
+
break;
|
|
319
|
+
case "task-cancelling":
|
|
320
|
+
task.execution = { kind: "cancelling", cause: change.cause };
|
|
321
|
+
break;
|
|
322
|
+
case "task-settled":
|
|
323
|
+
task.execution = { kind: "settled", result: change.result };
|
|
324
|
+
task.attention = { kind: "none" };
|
|
325
|
+
if (change.result.output !== undefined)
|
|
326
|
+
task.output = change.result.output;
|
|
327
|
+
break;
|
|
328
|
+
case "cleanup-changed":
|
|
329
|
+
task.cleanup = change.cleanup;
|
|
330
|
+
break;
|
|
331
|
+
case "task-activity": {
|
|
332
|
+
const activity = change.activity.change;
|
|
333
|
+
switch (activity.kind) {
|
|
334
|
+
case "action":
|
|
335
|
+
task.currentAction = { tool: activity.tool, text: activity.text };
|
|
336
|
+
if (task.attention.kind === "no-recent-activity")
|
|
337
|
+
task.attention = { kind: "none" };
|
|
338
|
+
break;
|
|
339
|
+
case "model":
|
|
340
|
+
task.model = activity.model;
|
|
341
|
+
task.thinking = activity.thinking;
|
|
342
|
+
break;
|
|
343
|
+
case "metrics":
|
|
344
|
+
task.metrics = {
|
|
345
|
+
...task.metrics,
|
|
346
|
+
...(activity.elapsedMs === undefined ? {} : { elapsedMs: activity.elapsedMs }),
|
|
347
|
+
...(activity.toolCount === undefined ? {} : { toolCount: activity.toolCount }),
|
|
348
|
+
...(activity.tokenCount === undefined ? {} : { tokenCount: activity.tokenCount }),
|
|
349
|
+
};
|
|
350
|
+
break;
|
|
351
|
+
case "attention-set":
|
|
352
|
+
task.attention = activity.attention;
|
|
353
|
+
break;
|
|
354
|
+
case "attention-clear":
|
|
355
|
+
if (task.attention.kind === "input-needed" && task.attention.requestId === activity.requestId)
|
|
356
|
+
task.attention = { kind: "none" };
|
|
357
|
+
break;
|
|
358
|
+
case "output":
|
|
359
|
+
break;
|
|
360
|
+
}
|
|
361
|
+
break;
|
|
362
|
+
}
|
|
363
|
+
case "wait-started":
|
|
364
|
+
case "wait-yielded":
|
|
365
|
+
break;
|
|
366
|
+
}
|
|
367
|
+
return next;
|
|
368
|
+
}
|
|
369
|
+
/** One bounded wake poll per live subscription, including a journal with no retained event. */
|
|
370
|
+
const RECONCILE_INTERVAL_MS = 25;
|
|
371
|
+
const MAX_PENDING_EVENTS = 64;
|
|
372
|
+
export class TaskSubscription {
|
|
373
|
+
#native;
|
|
374
|
+
#lease;
|
|
375
|
+
#resource;
|
|
376
|
+
#timer;
|
|
377
|
+
#queue;
|
|
378
|
+
#epoch;
|
|
379
|
+
#next;
|
|
380
|
+
#disposed;
|
|
381
|
+
#snapshot;
|
|
382
|
+
#cursor;
|
|
383
|
+
#onDispose;
|
|
384
|
+
#failure;
|
|
385
|
+
constructor(actor, initial, onDispose) {
|
|
386
|
+
this.#resource = new AsyncResource("TaskSubscription");
|
|
387
|
+
this.#queue = [];
|
|
388
|
+
this.#epoch = 0;
|
|
389
|
+
this.#disposed = false;
|
|
390
|
+
/** Reconciliation supplements the RFC snapshot/cursor/iterable contract. */
|
|
391
|
+
this.onReconcile = () => { };
|
|
392
|
+
this.lease = new SubscriptionCapability();
|
|
393
|
+
Object.freeze(this.lease);
|
|
394
|
+
this.#native = actor;
|
|
395
|
+
this.#lease = initial.lease;
|
|
396
|
+
this.#snapshot = snapshot(initial.snapshot);
|
|
397
|
+
this.#cursor = cursor(initial.cursor);
|
|
398
|
+
this.#onDispose = onDispose;
|
|
399
|
+
this.events = {
|
|
400
|
+
[Symbol.asyncIterator]: () => {
|
|
401
|
+
const epoch = this.#epoch;
|
|
402
|
+
return {
|
|
403
|
+
next: () => {
|
|
404
|
+
if (epoch !== this.#epoch)
|
|
405
|
+
return Promise.resolve({ done: true, value: undefined });
|
|
406
|
+
const value = this.#queue.shift();
|
|
407
|
+
if (value)
|
|
408
|
+
return Promise.resolve({ done: false, value });
|
|
409
|
+
if (this.#disposed)
|
|
410
|
+
return Promise.resolve({ done: true, value: undefined });
|
|
411
|
+
if (this.#next)
|
|
412
|
+
return Promise.reject(new Error("Only one pending subscription read is supported"));
|
|
413
|
+
return new Promise((resolve) => {
|
|
414
|
+
this.#next = resolve;
|
|
415
|
+
});
|
|
416
|
+
},
|
|
417
|
+
return: async () => {
|
|
418
|
+
if (epoch === this.#epoch)
|
|
419
|
+
this.dispose();
|
|
420
|
+
return { done: true, value: undefined };
|
|
421
|
+
},
|
|
422
|
+
};
|
|
423
|
+
},
|
|
424
|
+
};
|
|
425
|
+
this.#arm();
|
|
426
|
+
}
|
|
427
|
+
get snapshot() {
|
|
428
|
+
return this.#snapshot;
|
|
429
|
+
}
|
|
430
|
+
get cursor() {
|
|
431
|
+
return this.#cursor;
|
|
432
|
+
}
|
|
433
|
+
/** Consumer exceptions are observable without breaking the native wake or fallback poll. */
|
|
434
|
+
get failure() {
|
|
435
|
+
return this.#failure;
|
|
436
|
+
}
|
|
437
|
+
/** Callback payloads are authentic hints; only the journal/snapshot is authoritative. */
|
|
438
|
+
wake(_hint) {
|
|
439
|
+
this.#resource.runInAsyncScope(() => this.drain());
|
|
440
|
+
}
|
|
441
|
+
#arm() {
|
|
442
|
+
if (this.#disposed || this.#timer)
|
|
443
|
+
return;
|
|
444
|
+
this.#timer = setTimeout(() => {
|
|
445
|
+
this.#timer = undefined;
|
|
446
|
+
this.#resource.runInAsyncScope(() => this.drain());
|
|
447
|
+
this.#arm();
|
|
448
|
+
}, RECONCILE_INTERVAL_MS);
|
|
449
|
+
this.#timer.unref();
|
|
450
|
+
}
|
|
451
|
+
drain() {
|
|
452
|
+
if (this.#disposed)
|
|
453
|
+
return;
|
|
454
|
+
const drained = this.#native.drainOwnerTasks(this.#lease);
|
|
455
|
+
if (!drained.ok) {
|
|
456
|
+
this.dispose();
|
|
457
|
+
return;
|
|
458
|
+
}
|
|
459
|
+
const events = drained.value.events.map(event);
|
|
460
|
+
if (drained.value.snapshot)
|
|
461
|
+
this.#snapshot = snapshot(drained.value.snapshot);
|
|
462
|
+
for (const value of events) {
|
|
463
|
+
if (BigInt(value.cursor.sequence) > BigInt(this.#snapshot.cursor.sequence))
|
|
464
|
+
this.#snapshot = applyEvent(this.#snapshot, value);
|
|
465
|
+
}
|
|
466
|
+
this.#cursor = cursor(drained.value.cursor);
|
|
467
|
+
this.#snapshot = { ...this.#snapshot, cursor: this.#cursor };
|
|
468
|
+
const overflow = this.#queue.length + events.length > MAX_PENDING_EVENTS;
|
|
469
|
+
const reset = drained.value.reset || overflow;
|
|
470
|
+
if (reset) {
|
|
471
|
+
this.#queue = [];
|
|
472
|
+
this.#epoch++;
|
|
473
|
+
// End the old iterator only after publishing the authoritative snapshot/cursor.
|
|
474
|
+
// A new iterator on the same iterable observes subsequent authentic deltas.
|
|
475
|
+
this.#next?.({ done: true, value: undefined });
|
|
476
|
+
this.#next = undefined;
|
|
477
|
+
}
|
|
478
|
+
if (drained.value.snapshot || events.length) {
|
|
479
|
+
try {
|
|
480
|
+
this.#resource.runInAsyncScope(this.onReconcile, undefined, this.#snapshot);
|
|
481
|
+
}
|
|
482
|
+
catch (error) {
|
|
483
|
+
this.#failure = new Error(rejectionMessage(error));
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
if (this.#disposed)
|
|
487
|
+
return;
|
|
488
|
+
if (!reset)
|
|
489
|
+
for (const value of events) {
|
|
490
|
+
if (this.#next) {
|
|
491
|
+
const next = this.#next;
|
|
492
|
+
this.#next = undefined;
|
|
493
|
+
next({ done: false, value });
|
|
494
|
+
}
|
|
495
|
+
else
|
|
496
|
+
this.#queue.push(value);
|
|
497
|
+
}
|
|
498
|
+
if (this.#snapshot.state === "closed")
|
|
499
|
+
this.dispose(false);
|
|
500
|
+
}
|
|
501
|
+
dispose(clear = true) {
|
|
502
|
+
if (this.#disposed)
|
|
503
|
+
return;
|
|
504
|
+
this.#disposed = true;
|
|
505
|
+
if (this.#timer)
|
|
506
|
+
clearTimeout(this.#timer);
|
|
507
|
+
this.#timer = undefined;
|
|
508
|
+
this.#native.disposeSubscription(this.#lease);
|
|
509
|
+
if (clear)
|
|
510
|
+
this.#queue = [];
|
|
511
|
+
this.#next?.({ done: true, value: undefined });
|
|
512
|
+
this.#next = undefined;
|
|
513
|
+
this.#resource.emitDestroy();
|
|
514
|
+
this.#onDispose();
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
export class TaskSupervisor {
|
|
518
|
+
#native = new createModuleRequire(import.meta.url)("@bastani/atomic-natives").TaskSupervisor();
|
|
519
|
+
#hosts = environment.hosts;
|
|
520
|
+
#owners = environment.owners;
|
|
521
|
+
#tasks = environment.tasks;
|
|
522
|
+
#waits = environment.waits;
|
|
523
|
+
#waitRegistry = environment.waitRegistry;
|
|
524
|
+
#ownerIds = environment.ownerIds;
|
|
525
|
+
bindHostSession(binding) {
|
|
526
|
+
const host = new HostCapability();
|
|
527
|
+
Object.freeze(host);
|
|
528
|
+
this.#hosts.set(host, { native: this.#native.bindHostSession(binding.scope), binding });
|
|
529
|
+
return host;
|
|
530
|
+
}
|
|
531
|
+
openTaskOwner(host, scope) {
|
|
532
|
+
const state = this.#host(host);
|
|
533
|
+
return mapped(this.#native.openTaskOwner(state.native, scope), (lease) => {
|
|
534
|
+
const probe = this.#native.watchOwnerTasks(lease, (_hint) => { });
|
|
535
|
+
if (!probe.ok)
|
|
536
|
+
throw new Error(probe.error.message);
|
|
537
|
+
const id = probe.value.snapshot.ownerId;
|
|
538
|
+
this.#native.disposeSubscription(probe.value.lease);
|
|
539
|
+
const existing = this.#ownerIds.get(id);
|
|
540
|
+
if (existing)
|
|
541
|
+
return existing;
|
|
542
|
+
const owner = new OwnerCapability();
|
|
543
|
+
Object.freeze(owner);
|
|
544
|
+
const ownerState = {
|
|
545
|
+
native: lease,
|
|
546
|
+
host: state,
|
|
547
|
+
tasks: new Map(),
|
|
548
|
+
watches: new Set(),
|
|
549
|
+
settledTasks: new Set(),
|
|
550
|
+
};
|
|
551
|
+
this.#owners.set(owner, ownerState);
|
|
552
|
+
this.#ownerIds.set(id, owner);
|
|
553
|
+
const watched = this.watchOwnerTasks(owner);
|
|
554
|
+
if (!watched.ok)
|
|
555
|
+
throw new Error(watched.error.message);
|
|
556
|
+
watched.value.onReconcile = (projection) => {
|
|
557
|
+
if (projection.state === "closed")
|
|
558
|
+
this.#ownerIds.delete(projection.ownerId);
|
|
559
|
+
for (const record of projection.tasks) {
|
|
560
|
+
const cause = record.execution.kind === "cancelling"
|
|
561
|
+
? record.execution.cause
|
|
562
|
+
: projection.state !== "open" && record.cleanup.kind !== "reaped"
|
|
563
|
+
? "owner-close"
|
|
564
|
+
: undefined;
|
|
565
|
+
if (!cause)
|
|
566
|
+
continue;
|
|
567
|
+
const task = this.#owner(owner).tasks.get(record.ref.taskId);
|
|
568
|
+
if (task)
|
|
569
|
+
this.#task(task).controller.abort(cause);
|
|
570
|
+
}
|
|
571
|
+
let failure;
|
|
572
|
+
for (const record of projection.tasks) {
|
|
573
|
+
if (record.execution.kind !== "settled" ||
|
|
574
|
+
ownerState.settledTasks.has(record.ref.taskId) ||
|
|
575
|
+
!state.binding.onTaskSettled)
|
|
576
|
+
continue;
|
|
577
|
+
try {
|
|
578
|
+
// Cancellation settles at cleanup (or while queued), without a runner outcome.
|
|
579
|
+
// Recover its authentic receipt even when the bounded journal has reset.
|
|
580
|
+
const task = this.#native.lookupTask(lease, record.ref.taskId);
|
|
581
|
+
if (!task.ok)
|
|
582
|
+
throw new Error(task.error.message);
|
|
583
|
+
const settled = this.#native.taskSettlement(task.value);
|
|
584
|
+
if (!settled.ok)
|
|
585
|
+
throw new Error(settled.error.message);
|
|
586
|
+
this.#notifyTaskSettled(ownerState, record.ref, settled.value);
|
|
587
|
+
}
|
|
588
|
+
catch (error) {
|
|
589
|
+
failure ??= new Error(rejectionMessage(error));
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
if (failure)
|
|
593
|
+
throw failure;
|
|
594
|
+
};
|
|
595
|
+
watched.value.onReconcile(watched.value.snapshot);
|
|
596
|
+
return owner;
|
|
597
|
+
}, ownerErrors);
|
|
598
|
+
}
|
|
599
|
+
#notifyTaskSettled(state, ref, receipt) {
|
|
600
|
+
if (!state.host.binding.onTaskSettled || state.settledTasks.has(ref.taskId))
|
|
601
|
+
return;
|
|
602
|
+
// Runner outcomes and snapshot recovery share one delivery door. Mark before
|
|
603
|
+
// host code so reentrant drains or callback failures cannot redeliver.
|
|
604
|
+
state.settledTasks.add(ref.taskId);
|
|
605
|
+
state.host.binding.onTaskSettled(ref, {
|
|
606
|
+
taskId: receipt.taskId,
|
|
607
|
+
cursor: cursor(receipt.cursor),
|
|
608
|
+
result: taskResult(receipt.result),
|
|
609
|
+
completionId: receipt.completionId,
|
|
610
|
+
});
|
|
611
|
+
}
|
|
612
|
+
async startCommandTask(owner, intent, operation) {
|
|
613
|
+
const state = this.#owner(owner);
|
|
614
|
+
state.host.binding.authorizeCommandLaunch?.(intent);
|
|
615
|
+
const admitted = mapped(await this.#native.startCommandTask(state.native, intent, operation), (lease) => lease, startErrors);
|
|
616
|
+
if (!admitted.ok)
|
|
617
|
+
return admitted;
|
|
618
|
+
const ref = this.#native.taskReference(admitted.value);
|
|
619
|
+
if (!ref.ok)
|
|
620
|
+
throw new Error(ref.error.message);
|
|
621
|
+
const id = ref.value.taskId;
|
|
622
|
+
const existing = state.tasks.get(id);
|
|
623
|
+
if (existing)
|
|
624
|
+
return { ok: true, value: existing };
|
|
625
|
+
const task = new TaskCapability();
|
|
626
|
+
this.#tasks.set(task, {
|
|
627
|
+
native: admitted.value,
|
|
628
|
+
owner: state,
|
|
629
|
+
ref: reference(ref.value),
|
|
630
|
+
controller: new AbortController(),
|
|
631
|
+
kind: "command",
|
|
632
|
+
});
|
|
633
|
+
state.tasks.set(id, task);
|
|
634
|
+
return { ok: true, value: task };
|
|
635
|
+
}
|
|
636
|
+
taskStdin(task) {
|
|
637
|
+
return mapped(this.#native.taskStdin(this.#task(task).native), (input) => {
|
|
638
|
+
const lease = new StdinCapability();
|
|
639
|
+
environment.inputs.set(lease, input);
|
|
640
|
+
return lease;
|
|
641
|
+
}, ["TaskTerminal", "StdinClosed", "UnknownTask", "OutputUnavailable"]);
|
|
642
|
+
}
|
|
643
|
+
async writeTaskInput(input, operation, data) {
|
|
644
|
+
const lease = environment.inputs.get(input);
|
|
645
|
+
if (!lease)
|
|
646
|
+
throw new TypeError("Foreign stdin capability");
|
|
647
|
+
return mapped(await this.#native.writeTaskInput(lease, operation, data.kind === "bytes" ? { kind: "bytes", bytes: Buffer.from(data.bytes) } : data), (value) => ({
|
|
648
|
+
operationId: value.operationId,
|
|
649
|
+
acceptedBytes: value.acceptedBytes,
|
|
650
|
+
kind: value.kind,
|
|
651
|
+
}), ["TaskTerminal", "StdinClosed", "InputBackpressure", "OperationConflict", "InputDeliveryUnknown"]);
|
|
652
|
+
}
|
|
653
|
+
async readTaskOutput(task, range) {
|
|
654
|
+
return mapped(await this.#native.readTaskOutput(this.#task(task).native, range), (page) => ({
|
|
655
|
+
requested: page.requested,
|
|
656
|
+
chunks: page.chunks.map((chunk) => ({ offsets: chunk.offsets, bytes: new Uint8Array(chunk.bytes) })),
|
|
657
|
+
omittedRanges: page.omittedRanges,
|
|
658
|
+
...(page.nextOffset === undefined ? {} : { nextOffset: page.nextOffset }),
|
|
659
|
+
}), ["UnknownTask", "OutputUnavailable"]);
|
|
660
|
+
}
|
|
661
|
+
async startAgentTask(owner, intent, operation, schedule) {
|
|
662
|
+
const state = this.#owner(owner);
|
|
663
|
+
state.host.binding.authorizeLaunch(intent);
|
|
664
|
+
const admitted = mapped(this.#native.startAgentTask(state.native, intent, operation), (lease) => lease, startErrors);
|
|
665
|
+
if (!admitted.ok)
|
|
666
|
+
return admitted;
|
|
667
|
+
const ref = this.#native.taskReference(admitted.value);
|
|
668
|
+
if (!ref.ok)
|
|
669
|
+
throw new Error(ref.error.message);
|
|
670
|
+
const id = ref.value.taskId;
|
|
671
|
+
const existing = state.tasks.get(id);
|
|
672
|
+
if (existing)
|
|
673
|
+
return { ok: true, value: existing };
|
|
674
|
+
const task = new TaskCapability();
|
|
675
|
+
Object.freeze(task);
|
|
676
|
+
const taskState = {
|
|
677
|
+
native: admitted.value,
|
|
678
|
+
owner: state,
|
|
679
|
+
ref: reference(ref.value),
|
|
680
|
+
controller: new AbortController(),
|
|
681
|
+
};
|
|
682
|
+
this.#tasks.set(task, taskState);
|
|
683
|
+
state.tasks.set(id, task);
|
|
684
|
+
const dispatch = AsyncResource.bind(async () => {
|
|
685
|
+
if (taskState.controller.signal.aborted)
|
|
686
|
+
return;
|
|
687
|
+
const runner = mapped(this.#native.claimTaskRunner(admitted.value), (lease) => lease, startErrors);
|
|
688
|
+
if (!runner.ok)
|
|
689
|
+
throw new Error(`${runner.error.code}: ${runner.error.message}`);
|
|
690
|
+
let execution;
|
|
691
|
+
try {
|
|
692
|
+
execution = state.host.binding.createRunner({
|
|
693
|
+
ref: reference(taskState.ref),
|
|
694
|
+
signal: taskState.controller.signal,
|
|
695
|
+
bindTranscript: (session) => {
|
|
696
|
+
taskState.transcript = session;
|
|
697
|
+
},
|
|
698
|
+
reportActivity: (report) => mapped(this.#native.reportTaskActivity(runner.value, report), reportReceipt, reportErrors),
|
|
699
|
+
}, intent);
|
|
700
|
+
}
|
|
701
|
+
catch (error) {
|
|
702
|
+
const message = rejectionMessage(error);
|
|
703
|
+
execution = {
|
|
704
|
+
result: Promise.resolve({ kind: "failed", code: "SpawnFailed", message }),
|
|
705
|
+
cleanup: Promise.resolve({
|
|
706
|
+
kind: "failed",
|
|
707
|
+
resources: [{ resource: "fake-runner-setup", code: "CleanupUnconfirmed", message }],
|
|
708
|
+
}),
|
|
709
|
+
};
|
|
710
|
+
}
|
|
711
|
+
const outcome = execution.result
|
|
712
|
+
.catch((error) => ({ kind: "failed", code: "RunnerFailed", message: rejectionMessage(error) }))
|
|
713
|
+
.then((result) => {
|
|
714
|
+
return mapped(this.#native.reportRunnerOutcome(runner.value, result), (receipt) => this.#notifyTaskSettled(state, taskState.ref, receipt), reportErrors);
|
|
715
|
+
});
|
|
716
|
+
const cleanup = execution.cleanup.catch((error) => ({
|
|
717
|
+
kind: "failed",
|
|
718
|
+
resources: [{ resource: "fake-runner", code: "CleanupFailed", message: rejectionMessage(error) }],
|
|
719
|
+
}));
|
|
720
|
+
taskState.execution = cleanup.then(async (evidence) => {
|
|
721
|
+
// Natural reaping follows its outcome; cancellation needs only confirmed stop.
|
|
722
|
+
// A result may never arrive after abort, including when cleanup arrived first.
|
|
723
|
+
const signal = taskState.controller.signal;
|
|
724
|
+
let stopped;
|
|
725
|
+
const cancelled = new Promise((resolve) => {
|
|
726
|
+
stopped = () => resolve(undefined);
|
|
727
|
+
if (signal.aborted)
|
|
728
|
+
stopped();
|
|
729
|
+
else
|
|
730
|
+
signal.addEventListener("abort", stopped, { once: true });
|
|
731
|
+
});
|
|
732
|
+
const reported = await Promise.race([outcome, cancelled]).finally(() => {
|
|
733
|
+
signal.removeEventListener("abort", stopped);
|
|
734
|
+
});
|
|
735
|
+
const acknowledged = mapped(this.#native.acknowledgeTaskCleanup(runner.value, evidence), (cleanup) => cleanup, reportErrors);
|
|
736
|
+
if (reported && !reported.ok && !(signal.aborted && reported.error.code === "ReportConflict"))
|
|
737
|
+
return reported;
|
|
738
|
+
return acknowledged;
|
|
739
|
+
});
|
|
740
|
+
await taskState.execution;
|
|
741
|
+
});
|
|
742
|
+
if (schedule)
|
|
743
|
+
schedule(dispatch);
|
|
744
|
+
else
|
|
745
|
+
void dispatch();
|
|
746
|
+
// Setup is complete. Do not await execution; ready terminal microtasks may win observation.
|
|
747
|
+
await Promise.resolve();
|
|
748
|
+
return { ok: true, value: task };
|
|
749
|
+
}
|
|
750
|
+
taskReference(task) {
|
|
751
|
+
return reference(this.#task(task).ref);
|
|
752
|
+
}
|
|
753
|
+
async waitForTask(task, budgetMs, designation) {
|
|
754
|
+
const registered = mapped(this.#native.waitForTask(this.#task(task).native, this.#agentBudget(this.#task(task).owner, budgetMs, this.#task(task).kind === "command"), designation ? this.#host(designation).native : undefined), (lease) => this.#register(lease), waitErrors);
|
|
755
|
+
return registered.ok ? this.observeTaskWait(registered.value) : registered;
|
|
756
|
+
}
|
|
757
|
+
/** Resolve only a task admitted under this live owner; IDs alone confer no authority. */
|
|
758
|
+
lookupTask(owner, taskId) {
|
|
759
|
+
const state = this.#owner(owner);
|
|
760
|
+
const found = mapped(this.#native.lookupTask(state.native, taskId), () => state.tasks.get(taskId), waitErrors);
|
|
761
|
+
if (!found.ok)
|
|
762
|
+
return found;
|
|
763
|
+
if (!found.value)
|
|
764
|
+
return { ok: false, error: { code: "UnknownTask", message: "No agent runner bound to task" } };
|
|
765
|
+
return { ok: true, value: found.value };
|
|
766
|
+
}
|
|
767
|
+
async waitForTaskId(owner, taskId, budgetMs) {
|
|
768
|
+
const found = mapped(this.#native.lookupTask(this.#owner(owner).native, taskId), (lease) => lease, waitErrors);
|
|
769
|
+
if (!found.ok)
|
|
770
|
+
return found;
|
|
771
|
+
const known = this.#owner(owner).tasks.get(taskId);
|
|
772
|
+
const registered = mapped(this.#native.waitForTask(found.value, this.#agentBudget(this.#owner(owner), budgetMs, known !== undefined && this.#task(known).kind === "command")), (lease) => this.#register(lease), waitErrors);
|
|
773
|
+
return registered.ok ? this.observeTaskWait(registered.value) : registered;
|
|
774
|
+
}
|
|
775
|
+
async foregroundTask(task, budgetMs) {
|
|
776
|
+
const state = this.#task(task);
|
|
777
|
+
const errors = ["TaskTerminal", "OwnerClosing", "UnknownTask", "ObserverCancelled"];
|
|
778
|
+
const registered = mapped(this.#native.foregroundTask(state.native, state.owner.host.native, this.#agentBudget(state.owner, budgetMs, state.kind === "command")), (lease) => this.#register(lease), errors);
|
|
779
|
+
return registered.ok
|
|
780
|
+
? mapped(await this.observeTaskWait(registered.value), (outcome) => outcome, errors)
|
|
781
|
+
: registered;
|
|
782
|
+
}
|
|
783
|
+
waitId(wait) {
|
|
784
|
+
return this.#wait(wait).native.waitId;
|
|
785
|
+
}
|
|
786
|
+
findWait(id) {
|
|
787
|
+
return this.#waitRegistry.get(id);
|
|
788
|
+
}
|
|
789
|
+
observeTaskWait(wait) {
|
|
790
|
+
return this.#wait(wait).outcome;
|
|
791
|
+
}
|
|
792
|
+
yieldTaskWait(wait, reason) {
|
|
793
|
+
return mapped(this.#native.yieldTaskWait(this.#wait(wait).native, reason), waitOutcome, [
|
|
794
|
+
"UnknownWait",
|
|
795
|
+
"StaleGeneration",
|
|
796
|
+
"ObserverCancelled",
|
|
797
|
+
]);
|
|
798
|
+
}
|
|
799
|
+
disposeTaskWait(wait) {
|
|
800
|
+
return mapped(this.#native.disposeTaskWait(this.#wait(wait).native), () => undefined, waitErrors);
|
|
801
|
+
}
|
|
802
|
+
async initialObservation(task, policy, onRegistered) {
|
|
803
|
+
const state = this.#task(task);
|
|
804
|
+
policy ??= state.kind === "command" ? { kind: "foreground" } : undefined;
|
|
805
|
+
const registered = mapped(this.#native.waitForTask(state.native, policy?.kind === "foreground"
|
|
806
|
+
? this.#agentBudget(state.owner, policy.budgetMs, state.kind === "command")
|
|
807
|
+
: undefined, state.owner.host.native), (lease) => this.#register(lease), waitErrors);
|
|
808
|
+
if (!registered.ok)
|
|
809
|
+
return registered;
|
|
810
|
+
onRegistered?.(registered.value);
|
|
811
|
+
if (policy?.kind !== "foreground")
|
|
812
|
+
this.yieldTaskWait(registered.value, policy ? "explicit" : "default-background");
|
|
813
|
+
return this.observeTaskWait(registered.value);
|
|
814
|
+
}
|
|
815
|
+
async cancelTask(task, cause) {
|
|
816
|
+
const state = this.#task(task);
|
|
817
|
+
const result = mapped(this.#native.cancelTask(state.native, cause), cancelReceipt, [
|
|
818
|
+
"UnknownTask",
|
|
819
|
+
"CleanupFailed",
|
|
820
|
+
]);
|
|
821
|
+
if (result.ok && result.value.decision === "cancellation-requested")
|
|
822
|
+
state.controller.abort(cause);
|
|
823
|
+
return result;
|
|
824
|
+
}
|
|
825
|
+
async closeTaskOwner(owner, cause) {
|
|
826
|
+
const state = this.#owner(owner);
|
|
827
|
+
const closing = this.#native.closeTaskOwner(state.native, cause);
|
|
828
|
+
for (const task of state.tasks.values())
|
|
829
|
+
this.#task(task).controller.abort("owner-close");
|
|
830
|
+
const result = mapped(await closing, (receipt) => ({
|
|
831
|
+
ownerId: receipt.ownerId,
|
|
832
|
+
state: "closed",
|
|
833
|
+
tasks: receipt.tasks.map(cancelReceipt),
|
|
834
|
+
}), ["CleanupFailed", "EnvironmentClosing"]);
|
|
835
|
+
if (result.ok)
|
|
836
|
+
for (const task of state.tasks.values()) {
|
|
837
|
+
const completed = await this.#task(task).execution;
|
|
838
|
+
if (completed && !completed.ok)
|
|
839
|
+
throw new Error(`Runner protocol failed: ${completed.error.code}: ${completed.error.message}`);
|
|
840
|
+
}
|
|
841
|
+
if (result.ok)
|
|
842
|
+
for (const watch of state.watches) {
|
|
843
|
+
watch.drain();
|
|
844
|
+
watch.dispose(false);
|
|
845
|
+
}
|
|
846
|
+
return result;
|
|
847
|
+
}
|
|
848
|
+
/**
|
|
849
|
+
* The bounded stream carries only authentic deltas. Overflow/native reset publishes
|
|
850
|
+
* snapshot/cursor then ends the current iterator, even with no surviving delta.
|
|
851
|
+
* Reconcile on completion; obtain a new iterator on the same events iterable to
|
|
852
|
+
* continue observing. Apply snapshots first and ignore deltas at/below their cursor.
|
|
853
|
+
* onReconcile is optional; consumer failures never disable the fallback poll.
|
|
854
|
+
*/
|
|
855
|
+
watchOwnerTasks(owner, from) {
|
|
856
|
+
const state = this.#owner(owner);
|
|
857
|
+
let subscription;
|
|
858
|
+
return mapped(this.#native.watchOwnerTasks(state.native, (hint) => subscription?.wake(hint), from), (initial) => {
|
|
859
|
+
subscription = new TaskSubscription(this.#native, initial, () => {
|
|
860
|
+
if (subscription)
|
|
861
|
+
state.watches.delete(subscription);
|
|
862
|
+
});
|
|
863
|
+
state.watches.add(subscription);
|
|
864
|
+
return subscription;
|
|
865
|
+
}, watchErrors);
|
|
866
|
+
}
|
|
867
|
+
#agentBudget(owner, budgetMs, command = false) {
|
|
868
|
+
if (budgetMs !== undefined)
|
|
869
|
+
return budgetMs;
|
|
870
|
+
const configuration = owner.host.binding.tasks?.wait;
|
|
871
|
+
if (configuration?.kind === "until-settled")
|
|
872
|
+
return undefined;
|
|
873
|
+
return command
|
|
874
|
+
? (configuration?.commandBudgetMs ?? COMMAND_FOREGROUND_BUDGET_MS)
|
|
875
|
+
: (configuration?.agentBudgetMs ?? DEFAULT_AGENT_WAIT_BUDGET_MS);
|
|
876
|
+
}
|
|
877
|
+
#register(lease) {
|
|
878
|
+
const wait = new WaitCapability();
|
|
879
|
+
Object.freeze(wait);
|
|
880
|
+
const id = lease.waitId;
|
|
881
|
+
this.#waitRegistry.set(id, wait);
|
|
882
|
+
const outcome = this.#native
|
|
883
|
+
.observeTaskWait(lease)
|
|
884
|
+
.then((result) => mapped(result, waitOutcome, waitErrors))
|
|
885
|
+
.finally(() => {
|
|
886
|
+
this.#waitRegistry.delete(id);
|
|
887
|
+
});
|
|
888
|
+
this.#waits.set(wait, { native: lease, outcome });
|
|
889
|
+
return wait;
|
|
890
|
+
}
|
|
891
|
+
#host(host) {
|
|
892
|
+
const state = this.#hosts.get(host);
|
|
893
|
+
if (!state)
|
|
894
|
+
throw new TypeError("Foreign host capability");
|
|
895
|
+
return state;
|
|
896
|
+
}
|
|
897
|
+
#owner(owner) {
|
|
898
|
+
const state = this.#owners.get(owner);
|
|
899
|
+
if (!state)
|
|
900
|
+
throw new TypeError("Foreign owner capability");
|
|
901
|
+
return state;
|
|
902
|
+
}
|
|
903
|
+
#task(task) {
|
|
904
|
+
const state = this.#tasks.get(task);
|
|
905
|
+
if (!state)
|
|
906
|
+
throw new TypeError("Foreign task capability");
|
|
907
|
+
return state;
|
|
908
|
+
}
|
|
909
|
+
#wait(wait) {
|
|
910
|
+
const state = this.#waits.get(wait);
|
|
911
|
+
if (!state)
|
|
912
|
+
throw new TypeError("Foreign wait capability");
|
|
913
|
+
return state;
|
|
914
|
+
}
|
|
915
|
+
}
|
|
916
|
+
//# sourceMappingURL=supervisor.js.map
|