@bastani/atomic 0.9.19-alpha.1 → 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 +94 -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 +38 -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 +26654 -25831
- package/dist/builtin/workflows/src/index.js +907 -473
- 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 +1 -1
- 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 +42 -1
- 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
|
@@ -74,17 +74,17 @@ var require_visit = __commonJS(function(exports) {
|
|
|
74
74
|
visit.BREAK = BREAK;
|
|
75
75
|
visit.SKIP = SKIP;
|
|
76
76
|
visit.REMOVE = REMOVE;
|
|
77
|
-
function visit_(key, node, visitor,
|
|
78
|
-
const ctrl = callVisitor(key, node, visitor,
|
|
77
|
+
function visit_(key, node, visitor, path) {
|
|
78
|
+
const ctrl = callVisitor(key, node, visitor, path);
|
|
79
79
|
if (identity.isNode(ctrl) || identity.isPair(ctrl)) {
|
|
80
|
-
replaceNode(key,
|
|
81
|
-
return visit_(key, ctrl, visitor,
|
|
80
|
+
replaceNode(key, path, ctrl);
|
|
81
|
+
return visit_(key, ctrl, visitor, path);
|
|
82
82
|
}
|
|
83
83
|
if (typeof ctrl !== "symbol") {
|
|
84
84
|
if (identity.isCollection(node)) {
|
|
85
|
-
|
|
85
|
+
path = Object.freeze(path.concat(node));
|
|
86
86
|
for (let i = 0;i < node.items.length; ++i) {
|
|
87
|
-
const ci = visit_(i, node.items[i], visitor,
|
|
87
|
+
const ci = visit_(i, node.items[i], visitor, path);
|
|
88
88
|
if (typeof ci === "number")
|
|
89
89
|
i = ci - 1;
|
|
90
90
|
else if (ci === BREAK)
|
|
@@ -95,13 +95,13 @@ var require_visit = __commonJS(function(exports) {
|
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
97
|
} else if (identity.isPair(node)) {
|
|
98
|
-
|
|
99
|
-
const ck = visit_("key", node.key, visitor,
|
|
98
|
+
path = Object.freeze(path.concat(node));
|
|
99
|
+
const ck = visit_("key", node.key, visitor, path);
|
|
100
100
|
if (ck === BREAK)
|
|
101
101
|
return BREAK;
|
|
102
102
|
else if (ck === REMOVE)
|
|
103
103
|
node.key = null;
|
|
104
|
-
const cv = visit_("value", node.value, visitor,
|
|
104
|
+
const cv = visit_("value", node.value, visitor, path);
|
|
105
105
|
if (cv === BREAK)
|
|
106
106
|
return BREAK;
|
|
107
107
|
else if (cv === REMOVE)
|
|
@@ -122,17 +122,17 @@ var require_visit = __commonJS(function(exports) {
|
|
|
122
122
|
visitAsync.BREAK = BREAK;
|
|
123
123
|
visitAsync.SKIP = SKIP;
|
|
124
124
|
visitAsync.REMOVE = REMOVE;
|
|
125
|
-
async function visitAsync_(key, node, visitor,
|
|
126
|
-
const ctrl = await callVisitor(key, node, visitor,
|
|
125
|
+
async function visitAsync_(key, node, visitor, path) {
|
|
126
|
+
const ctrl = await callVisitor(key, node, visitor, path);
|
|
127
127
|
if (identity.isNode(ctrl) || identity.isPair(ctrl)) {
|
|
128
|
-
replaceNode(key,
|
|
129
|
-
return visitAsync_(key, ctrl, visitor,
|
|
128
|
+
replaceNode(key, path, ctrl);
|
|
129
|
+
return visitAsync_(key, ctrl, visitor, path);
|
|
130
130
|
}
|
|
131
131
|
if (typeof ctrl !== "symbol") {
|
|
132
132
|
if (identity.isCollection(node)) {
|
|
133
|
-
|
|
133
|
+
path = Object.freeze(path.concat(node));
|
|
134
134
|
for (let i = 0;i < node.items.length; ++i) {
|
|
135
|
-
const ci = await visitAsync_(i, node.items[i], visitor,
|
|
135
|
+
const ci = await visitAsync_(i, node.items[i], visitor, path);
|
|
136
136
|
if (typeof ci === "number")
|
|
137
137
|
i = ci - 1;
|
|
138
138
|
else if (ci === BREAK)
|
|
@@ -143,13 +143,13 @@ var require_visit = __commonJS(function(exports) {
|
|
|
143
143
|
}
|
|
144
144
|
}
|
|
145
145
|
} else if (identity.isPair(node)) {
|
|
146
|
-
|
|
147
|
-
const ck = await visitAsync_("key", node.key, visitor,
|
|
146
|
+
path = Object.freeze(path.concat(node));
|
|
147
|
+
const ck = await visitAsync_("key", node.key, visitor, path);
|
|
148
148
|
if (ck === BREAK)
|
|
149
149
|
return BREAK;
|
|
150
150
|
else if (ck === REMOVE)
|
|
151
151
|
node.key = null;
|
|
152
|
-
const cv = await visitAsync_("value", node.value, visitor,
|
|
152
|
+
const cv = await visitAsync_("value", node.value, visitor, path);
|
|
153
153
|
if (cv === BREAK)
|
|
154
154
|
return BREAK;
|
|
155
155
|
else if (cv === REMOVE)
|
|
@@ -176,23 +176,23 @@ var require_visit = __commonJS(function(exports) {
|
|
|
176
176
|
}
|
|
177
177
|
return visitor;
|
|
178
178
|
}
|
|
179
|
-
function callVisitor(key, node, visitor,
|
|
179
|
+
function callVisitor(key, node, visitor, path) {
|
|
180
180
|
if (typeof visitor === "function")
|
|
181
|
-
return visitor(key, node,
|
|
181
|
+
return visitor(key, node, path);
|
|
182
182
|
if (identity.isMap(node))
|
|
183
|
-
return visitor.Map?.(key, node,
|
|
183
|
+
return visitor.Map?.(key, node, path);
|
|
184
184
|
if (identity.isSeq(node))
|
|
185
|
-
return visitor.Seq?.(key, node,
|
|
185
|
+
return visitor.Seq?.(key, node, path);
|
|
186
186
|
if (identity.isPair(node))
|
|
187
|
-
return visitor.Pair?.(key, node,
|
|
187
|
+
return visitor.Pair?.(key, node, path);
|
|
188
188
|
if (identity.isScalar(node))
|
|
189
|
-
return visitor.Scalar?.(key, node,
|
|
189
|
+
return visitor.Scalar?.(key, node, path);
|
|
190
190
|
if (identity.isAlias(node))
|
|
191
|
-
return visitor.Alias?.(key, node,
|
|
191
|
+
return visitor.Alias?.(key, node, path);
|
|
192
192
|
return;
|
|
193
193
|
}
|
|
194
|
-
function replaceNode(key,
|
|
195
|
-
const parent =
|
|
194
|
+
function replaceNode(key, path, node) {
|
|
195
|
+
const parent = path[path.length - 1];
|
|
196
196
|
if (identity.isCollection(parent)) {
|
|
197
197
|
parent.items[key] = node;
|
|
198
198
|
} else if (identity.isPair(parent)) {
|
|
@@ -483,8 +483,8 @@ var require_toJS = __commonJS(function(exports) {
|
|
|
483
483
|
return value.toJSON(arg, ctx);
|
|
484
484
|
const data = { aliasCount: 0, count: 1, res: undefined };
|
|
485
485
|
ctx.anchors.set(value, data);
|
|
486
|
-
ctx.onCreate = (
|
|
487
|
-
data.res =
|
|
486
|
+
ctx.onCreate = (res) => {
|
|
487
|
+
data.res = res;
|
|
488
488
|
delete ctx.onCreate;
|
|
489
489
|
};
|
|
490
490
|
const res = value.toJSON(arg, ctx);
|
|
@@ -528,8 +528,8 @@ var require_Node = __commonJS(function(exports) {
|
|
|
528
528
|
};
|
|
529
529
|
const res = toJS.toJS(this, "", ctx);
|
|
530
530
|
if (typeof onAnchor === "function")
|
|
531
|
-
for (const { count, res
|
|
532
|
-
onAnchor(
|
|
531
|
+
for (const { count, res } of ctx.anchors.values())
|
|
532
|
+
onAnchor(res, count);
|
|
533
533
|
return typeof reviver === "function" ? applyReviver.applyReviver(reviver, { "": res }, "", res) : res;
|
|
534
534
|
}
|
|
535
535
|
}
|
|
@@ -583,16 +583,16 @@ var require_Alias = __commonJS(function(exports) {
|
|
|
583
583
|
toJSON(_arg, ctx) {
|
|
584
584
|
if (!ctx)
|
|
585
585
|
return { source: this.source };
|
|
586
|
-
const { anchors
|
|
586
|
+
const { anchors, doc, maxAliasCount } = ctx;
|
|
587
587
|
const source = this.resolve(doc, ctx);
|
|
588
588
|
if (!source) {
|
|
589
589
|
const msg = `Unresolved alias (the anchor must be set before the alias): ${this.source}`;
|
|
590
590
|
throw new ReferenceError(msg);
|
|
591
591
|
}
|
|
592
|
-
let data =
|
|
592
|
+
let data = anchors.get(source);
|
|
593
593
|
if (!data) {
|
|
594
594
|
toJS.toJS(source, null, ctx);
|
|
595
|
-
data =
|
|
595
|
+
data = anchors.get(source);
|
|
596
596
|
}
|
|
597
597
|
if (data?.res === undefined) {
|
|
598
598
|
const msg = "This should not happen: Alias anchor was not resolved?";
|
|
@@ -601,7 +601,7 @@ var require_Alias = __commonJS(function(exports) {
|
|
|
601
601
|
if (maxAliasCount >= 0) {
|
|
602
602
|
data.count += 1;
|
|
603
603
|
if (data.aliasCount === 0)
|
|
604
|
-
data.aliasCount = getAliasCount(doc, source,
|
|
604
|
+
data.aliasCount = getAliasCount(doc, source, anchors);
|
|
605
605
|
if (data.count * data.aliasCount > maxAliasCount) {
|
|
606
606
|
const msg = "Excessive alias count indicates a resource exhaustion attack";
|
|
607
607
|
throw new ReferenceError(msg);
|
|
@@ -623,22 +623,22 @@ var require_Alias = __commonJS(function(exports) {
|
|
|
623
623
|
return src;
|
|
624
624
|
}
|
|
625
625
|
}
|
|
626
|
-
function getAliasCount(doc, node,
|
|
626
|
+
function getAliasCount(doc, node, anchors) {
|
|
627
627
|
if (identity.isAlias(node)) {
|
|
628
628
|
const source = node.resolve(doc);
|
|
629
|
-
const anchor =
|
|
629
|
+
const anchor = anchors && source && anchors.get(source);
|
|
630
630
|
return anchor ? anchor.count * anchor.aliasCount : 0;
|
|
631
631
|
} else if (identity.isCollection(node)) {
|
|
632
632
|
let count = 0;
|
|
633
633
|
for (const item of node.items) {
|
|
634
|
-
const c = getAliasCount(doc, item,
|
|
634
|
+
const c = getAliasCount(doc, item, anchors);
|
|
635
635
|
if (c > count)
|
|
636
636
|
count = c;
|
|
637
637
|
}
|
|
638
638
|
return count;
|
|
639
639
|
} else if (identity.isPair(node)) {
|
|
640
|
-
const kc = getAliasCount(doc, node.key,
|
|
641
|
-
const vc = getAliasCount(doc, node.value,
|
|
640
|
+
const kc = getAliasCount(doc, node.key, anchors);
|
|
641
|
+
const vc = getAliasCount(doc, node.value, anchors);
|
|
642
642
|
return Math.max(kc, vc);
|
|
643
643
|
}
|
|
644
644
|
return 1;
|
|
@@ -723,10 +723,10 @@ var require_createNode = __commonJS(function(exports) {
|
|
|
723
723
|
value = value.toJSON();
|
|
724
724
|
}
|
|
725
725
|
if (!value || typeof value !== "object") {
|
|
726
|
-
const
|
|
726
|
+
const node = new Scalar.Scalar(value);
|
|
727
727
|
if (ref)
|
|
728
|
-
ref.node =
|
|
729
|
-
return
|
|
728
|
+
ref.node = node;
|
|
729
|
+
return node;
|
|
730
730
|
}
|
|
731
731
|
tagObj = value instanceof Map ? schema[identity.MAP] : (Symbol.iterator in Object(value)) ? schema[identity.SEQ] : schema[identity.MAP];
|
|
732
732
|
}
|
|
@@ -751,10 +751,10 @@ var require_Collection = __commonJS(function(exports) {
|
|
|
751
751
|
var createNode = require_createNode();
|
|
752
752
|
var identity = require_identity();
|
|
753
753
|
var Node = require_Node();
|
|
754
|
-
function collectionFromPath(schema,
|
|
754
|
+
function collectionFromPath(schema, path, value) {
|
|
755
755
|
let v = value;
|
|
756
|
-
for (let i =
|
|
757
|
-
const k =
|
|
756
|
+
for (let i = path.length - 1;i >= 0; --i) {
|
|
757
|
+
const k = path[i];
|
|
758
758
|
if (typeof k === "number" && Number.isInteger(k) && k >= 0) {
|
|
759
759
|
const a = [];
|
|
760
760
|
a[k] = v;
|
|
@@ -773,7 +773,7 @@ var require_Collection = __commonJS(function(exports) {
|
|
|
773
773
|
sourceObjects: new Map
|
|
774
774
|
});
|
|
775
775
|
}
|
|
776
|
-
var isEmptyPath = (
|
|
776
|
+
var isEmptyPath = (path) => path == null || typeof path === "object" && !!path[Symbol.iterator]().next().done;
|
|
777
777
|
|
|
778
778
|
class Collection extends Node.NodeBase {
|
|
779
779
|
constructor(type, schema) {
|
|
@@ -794,11 +794,11 @@ var require_Collection = __commonJS(function(exports) {
|
|
|
794
794
|
copy.range = this.range.slice();
|
|
795
795
|
return copy;
|
|
796
796
|
}
|
|
797
|
-
addIn(
|
|
798
|
-
if (isEmptyPath(
|
|
797
|
+
addIn(path, value) {
|
|
798
|
+
if (isEmptyPath(path))
|
|
799
799
|
this.add(value);
|
|
800
800
|
else {
|
|
801
|
-
const [key, ...rest] =
|
|
801
|
+
const [key, ...rest] = path;
|
|
802
802
|
const node = this.get(key, true);
|
|
803
803
|
if (identity.isCollection(node))
|
|
804
804
|
node.addIn(rest, value);
|
|
@@ -808,8 +808,8 @@ var require_Collection = __commonJS(function(exports) {
|
|
|
808
808
|
throw new Error(`Expected YAML collection at ${key}. Remaining path: ${rest}`);
|
|
809
809
|
}
|
|
810
810
|
}
|
|
811
|
-
deleteIn(
|
|
812
|
-
const [key, ...rest] =
|
|
811
|
+
deleteIn(path) {
|
|
812
|
+
const [key, ...rest] = path;
|
|
813
813
|
if (rest.length === 0)
|
|
814
814
|
return this.delete(key);
|
|
815
815
|
const node = this.get(key, true);
|
|
@@ -818,8 +818,8 @@ var require_Collection = __commonJS(function(exports) {
|
|
|
818
818
|
else
|
|
819
819
|
throw new Error(`Expected YAML collection at ${key}. Remaining path: ${rest}`);
|
|
820
820
|
}
|
|
821
|
-
getIn(
|
|
822
|
-
const [key, ...rest] =
|
|
821
|
+
getIn(path, keepScalar) {
|
|
822
|
+
const [key, ...rest] = path;
|
|
823
823
|
const node = this.get(key, true);
|
|
824
824
|
if (rest.length === 0)
|
|
825
825
|
return !keepScalar && identity.isScalar(node) ? node.value : node;
|
|
@@ -834,15 +834,15 @@ var require_Collection = __commonJS(function(exports) {
|
|
|
834
834
|
return n == null || allowScalar && identity.isScalar(n) && n.value == null && !n.commentBefore && !n.comment && !n.tag;
|
|
835
835
|
});
|
|
836
836
|
}
|
|
837
|
-
hasIn(
|
|
838
|
-
const [key, ...rest] =
|
|
837
|
+
hasIn(path) {
|
|
838
|
+
const [key, ...rest] = path;
|
|
839
839
|
if (rest.length === 0)
|
|
840
840
|
return this.has(key);
|
|
841
841
|
const node = this.get(key, true);
|
|
842
842
|
return identity.isCollection(node) ? node.hasIn(rest) : false;
|
|
843
843
|
}
|
|
844
|
-
setIn(
|
|
845
|
-
const [key, ...rest] =
|
|
844
|
+
setIn(path, value) {
|
|
845
|
+
const [key, ...rest] = path;
|
|
846
846
|
if (rest.length === 0) {
|
|
847
847
|
this.set(key, value);
|
|
848
848
|
} else {
|
|
@@ -975,17 +975,17 @@ var require_foldFlowLines = __commonJS(function(exports) {
|
|
|
975
975
|
if (onFold)
|
|
976
976
|
onFold();
|
|
977
977
|
let res = text.slice(0, folds[0]);
|
|
978
|
-
for (let
|
|
979
|
-
const fold = folds[
|
|
980
|
-
const
|
|
978
|
+
for (let i = 0;i < folds.length; ++i) {
|
|
979
|
+
const fold = folds[i];
|
|
980
|
+
const end = folds[i + 1] || text.length;
|
|
981
981
|
if (fold === 0)
|
|
982
982
|
res = `
|
|
983
|
-
${indent}${text.slice(0,
|
|
983
|
+
${indent}${text.slice(0, end)}`;
|
|
984
984
|
else {
|
|
985
985
|
if (mode === FOLD_QUOTED && escapedFolds[fold])
|
|
986
986
|
res += `${text[fold]}\\`;
|
|
987
987
|
res += `
|
|
988
|
-
${indent}${text.slice(fold + 1,
|
|
988
|
+
${indent}${text.slice(fold + 1, end)}`;
|
|
989
989
|
}
|
|
990
990
|
}
|
|
991
991
|
return res;
|
|
@@ -1621,15 +1621,15 @@ var require_merge = __commonJS(function(exports) {
|
|
|
1621
1621
|
if (!identity.isMap(source))
|
|
1622
1622
|
throw new Error("Merge sources must be maps or map aliases");
|
|
1623
1623
|
const srcMap = source.toJSON(null, ctx, Map);
|
|
1624
|
-
for (const [key,
|
|
1624
|
+
for (const [key, value] of srcMap) {
|
|
1625
1625
|
if (map instanceof Map) {
|
|
1626
1626
|
if (!map.has(key))
|
|
1627
|
-
map.set(key,
|
|
1627
|
+
map.set(key, value);
|
|
1628
1628
|
} else if (map instanceof Set) {
|
|
1629
1629
|
map.add(key);
|
|
1630
1630
|
} else if (!Object.prototype.hasOwnProperty.call(map, key)) {
|
|
1631
1631
|
Object.defineProperty(map, key, {
|
|
1632
|
-
value
|
|
1632
|
+
value,
|
|
1633
1633
|
writable: true,
|
|
1634
1634
|
enumerable: true,
|
|
1635
1635
|
configurable: true
|
|
@@ -1752,8 +1752,8 @@ var require_stringifyCollection = __commonJS(function(exports) {
|
|
|
1752
1752
|
var stringifyComment = require_stringifyComment();
|
|
1753
1753
|
function stringifyCollection(collection, ctx, options) {
|
|
1754
1754
|
const flow = ctx.inFlow ?? collection.flow;
|
|
1755
|
-
const
|
|
1756
|
-
return
|
|
1755
|
+
const stringify = flow ? stringifyFlowCollection : stringifyBlockCollection;
|
|
1756
|
+
return stringify(collection, ctx, options);
|
|
1757
1757
|
}
|
|
1758
1758
|
function stringifyBlockCollection({ comment, items }, ctx, { blockItemPrefix, flowChars, itemIndent, onChompKeep, onComment }) {
|
|
1759
1759
|
const { indent, options: { commentString } } = ctx;
|
|
@@ -1762,13 +1762,13 @@ var require_stringifyCollection = __commonJS(function(exports) {
|
|
|
1762
1762
|
const lines = [];
|
|
1763
1763
|
for (let i = 0;i < items.length; ++i) {
|
|
1764
1764
|
const item = items[i];
|
|
1765
|
-
let
|
|
1765
|
+
let comment = null;
|
|
1766
1766
|
if (identity.isNode(item)) {
|
|
1767
1767
|
if (!chompKeep && item.spaceBefore)
|
|
1768
1768
|
lines.push("");
|
|
1769
1769
|
addCommentBefore(ctx, lines, item.commentBefore, chompKeep);
|
|
1770
1770
|
if (item.comment)
|
|
1771
|
-
|
|
1771
|
+
comment = item.comment;
|
|
1772
1772
|
} else if (identity.isPair(item)) {
|
|
1773
1773
|
const ik = identity.isNode(item.key) ? item.key : null;
|
|
1774
1774
|
if (ik) {
|
|
@@ -1778,12 +1778,12 @@ var require_stringifyCollection = __commonJS(function(exports) {
|
|
|
1778
1778
|
}
|
|
1779
1779
|
}
|
|
1780
1780
|
chompKeep = false;
|
|
1781
|
-
let
|
|
1782
|
-
if (
|
|
1783
|
-
|
|
1784
|
-
if (chompKeep &&
|
|
1781
|
+
let str = stringify.stringify(item, itemCtx, () => comment = null, () => chompKeep = true);
|
|
1782
|
+
if (comment)
|
|
1783
|
+
str += stringifyComment.lineComment(str, itemIndent, commentString(comment));
|
|
1784
|
+
if (chompKeep && comment)
|
|
1785
1785
|
chompKeep = false;
|
|
1786
|
-
lines.push(blockItemPrefix +
|
|
1786
|
+
lines.push(blockItemPrefix + str);
|
|
1787
1787
|
}
|
|
1788
1788
|
let str;
|
|
1789
1789
|
if (lines.length === 0) {
|
|
@@ -2033,10 +2033,10 @@ var require_map = __commonJS(function(exports) {
|
|
|
2033
2033
|
default: true,
|
|
2034
2034
|
nodeClass: YAMLMap.YAMLMap,
|
|
2035
2035
|
tag: "tag:yaml.org,2002:map",
|
|
2036
|
-
resolve(
|
|
2037
|
-
if (!identity.isMap(
|
|
2036
|
+
resolve(map, onError) {
|
|
2037
|
+
if (!identity.isMap(map))
|
|
2038
2038
|
onError("Expected a mapping for this tag");
|
|
2039
|
-
return
|
|
2039
|
+
return map;
|
|
2040
2040
|
},
|
|
2041
2041
|
createNode: (schema, obj, ctx) => YAMLMap.YAMLMap.from(schema, obj, ctx)
|
|
2042
2042
|
};
|
|
@@ -2145,10 +2145,10 @@ var require_seq = __commonJS(function(exports) {
|
|
|
2145
2145
|
default: true,
|
|
2146
2146
|
nodeClass: YAMLSeq.YAMLSeq,
|
|
2147
2147
|
tag: "tag:yaml.org,2002:seq",
|
|
2148
|
-
resolve(
|
|
2149
|
-
if (!identity.isSeq(
|
|
2148
|
+
resolve(seq, onError) {
|
|
2149
|
+
if (!identity.isSeq(seq))
|
|
2150
2150
|
onError("Expected a sequence for this tag");
|
|
2151
|
-
return
|
|
2151
|
+
return seq;
|
|
2152
2152
|
},
|
|
2153
2153
|
createNode: (schema, obj, ctx) => YAMLSeq.YAMLSeq.from(schema, obj, ctx)
|
|
2154
2154
|
};
|
|
@@ -2494,8 +2494,8 @@ ${cn.comment}` : item.comment;
|
|
|
2494
2494
|
}
|
|
2495
2495
|
function createPairs(schema, iterable, ctx) {
|
|
2496
2496
|
const { replacer } = ctx;
|
|
2497
|
-
const
|
|
2498
|
-
|
|
2497
|
+
const pairs = new YAMLSeq.YAMLSeq(schema);
|
|
2498
|
+
pairs.tag = "tag:yaml.org,2002:pairs";
|
|
2499
2499
|
let i = 0;
|
|
2500
2500
|
if (iterable && Symbol.iterator in Object(iterable))
|
|
2501
2501
|
for (let it of iterable) {
|
|
@@ -2519,9 +2519,9 @@ ${cn.comment}` : item.comment;
|
|
|
2519
2519
|
} else {
|
|
2520
2520
|
key = it;
|
|
2521
2521
|
}
|
|
2522
|
-
|
|
2522
|
+
pairs.items.push(Pair.createPair(key, value, ctx));
|
|
2523
2523
|
}
|
|
2524
|
-
return
|
|
2524
|
+
return pairs;
|
|
2525
2525
|
}
|
|
2526
2526
|
var pairs = {
|
|
2527
2527
|
collection: "seq",
|
|
@@ -2575,9 +2575,9 @@ var require_omap = __commonJS(function(exports) {
|
|
|
2575
2575
|
}
|
|
2576
2576
|
static from(schema, iterable, ctx) {
|
|
2577
2577
|
const pairs$1 = pairs.createPairs(schema, iterable, ctx);
|
|
2578
|
-
const
|
|
2579
|
-
|
|
2580
|
-
return
|
|
2578
|
+
const omap = new this;
|
|
2579
|
+
omap.items = pairs$1.items;
|
|
2580
|
+
return omap;
|
|
2581
2581
|
}
|
|
2582
2582
|
}
|
|
2583
2583
|
YAMLOMap.tag = "tag:yaml.org,2002:omap";
|
|
@@ -2703,8 +2703,8 @@ var require_int2 = __commonJS(function(exports) {
|
|
|
2703
2703
|
str = `0x${str}`;
|
|
2704
2704
|
break;
|
|
2705
2705
|
}
|
|
2706
|
-
const
|
|
2707
|
-
return sign === "-" ? BigInt(-1) *
|
|
2706
|
+
const n = BigInt(str);
|
|
2707
|
+
return sign === "-" ? BigInt(-1) * n : n;
|
|
2708
2708
|
}
|
|
2709
2709
|
const n = parseInt(str, radix);
|
|
2710
2710
|
return sign === "-" ? -1 * n : n;
|
|
@@ -2808,14 +2808,14 @@ var require_set = __commonJS(function(exports) {
|
|
|
2808
2808
|
}
|
|
2809
2809
|
static from(schema, iterable, ctx) {
|
|
2810
2810
|
const { replacer } = ctx;
|
|
2811
|
-
const
|
|
2811
|
+
const set = new this(schema);
|
|
2812
2812
|
if (iterable && Symbol.iterator in Object(iterable))
|
|
2813
2813
|
for (let value of iterable) {
|
|
2814
2814
|
if (typeof replacer === "function")
|
|
2815
2815
|
value = replacer.call(iterable, value, value);
|
|
2816
|
-
|
|
2816
|
+
set.items.push(Pair.createPair(value, null, ctx));
|
|
2817
2817
|
}
|
|
2818
|
-
return
|
|
2818
|
+
return set;
|
|
2819
2819
|
}
|
|
2820
2820
|
}
|
|
2821
2821
|
YAMLSet.tag = "tag:yaml.org,2002:set";
|
|
@@ -2848,7 +2848,7 @@ var require_timestamp = __commonJS(function(exports) {
|
|
|
2848
2848
|
const sign = str[0];
|
|
2849
2849
|
const parts = sign === "-" || sign === "+" ? str.substring(1) : str;
|
|
2850
2850
|
const num = (n) => asBigInt ? BigInt(n) : Number(n);
|
|
2851
|
-
const res = parts.replace(/_/g, "").split(":").reduce((
|
|
2851
|
+
const res = parts.replace(/_/g, "").split(":").reduce((res, p) => res * num(60) + num(p), num(0));
|
|
2852
2852
|
return sign === "-" ? num(-1) * res : res;
|
|
2853
2853
|
}
|
|
2854
2854
|
function stringifySexagesimal(node) {
|
|
@@ -3039,16 +3039,16 @@ var require_tags = __commonJS(function(exports) {
|
|
|
3039
3039
|
}
|
|
3040
3040
|
if (addMergeTag)
|
|
3041
3041
|
tags = tags.concat(merge.merge);
|
|
3042
|
-
return tags.reduce((
|
|
3042
|
+
return tags.reduce((tags, tag) => {
|
|
3043
3043
|
const tagObj = typeof tag === "string" ? tagsByName[tag] : tag;
|
|
3044
3044
|
if (!tagObj) {
|
|
3045
3045
|
const tagName = JSON.stringify(tag);
|
|
3046
3046
|
const keys = Object.keys(tagsByName).map((key) => JSON.stringify(key)).join(", ");
|
|
3047
3047
|
throw new Error(`Unknown custom tag ${tagName}; use one of ${keys}`);
|
|
3048
3048
|
}
|
|
3049
|
-
if (!
|
|
3050
|
-
|
|
3051
|
-
return
|
|
3049
|
+
if (!tags.includes(tagObj))
|
|
3050
|
+
tags.push(tagObj);
|
|
3051
|
+
return tags;
|
|
3052
3052
|
}, []);
|
|
3053
3053
|
}
|
|
3054
3054
|
exports.coreKnownTags = coreKnownTags;
|
|
@@ -3235,9 +3235,9 @@ var require_Document = __commonJS(function(exports) {
|
|
|
3235
3235
|
if (assertCollection(this.contents))
|
|
3236
3236
|
this.contents.add(value);
|
|
3237
3237
|
}
|
|
3238
|
-
addIn(
|
|
3238
|
+
addIn(path, value) {
|
|
3239
3239
|
if (assertCollection(this.contents))
|
|
3240
|
-
this.contents.addIn(
|
|
3240
|
+
this.contents.addIn(path, value);
|
|
3241
3241
|
}
|
|
3242
3242
|
createAlias(node, name) {
|
|
3243
3243
|
if (!node.anchor) {
|
|
@@ -3286,30 +3286,30 @@ var require_Document = __commonJS(function(exports) {
|
|
|
3286
3286
|
delete(key) {
|
|
3287
3287
|
return assertCollection(this.contents) ? this.contents.delete(key) : false;
|
|
3288
3288
|
}
|
|
3289
|
-
deleteIn(
|
|
3290
|
-
if (Collection.isEmptyPath(
|
|
3289
|
+
deleteIn(path) {
|
|
3290
|
+
if (Collection.isEmptyPath(path)) {
|
|
3291
3291
|
if (this.contents == null)
|
|
3292
3292
|
return false;
|
|
3293
3293
|
this.contents = null;
|
|
3294
3294
|
return true;
|
|
3295
3295
|
}
|
|
3296
|
-
return assertCollection(this.contents) ? this.contents.deleteIn(
|
|
3296
|
+
return assertCollection(this.contents) ? this.contents.deleteIn(path) : false;
|
|
3297
3297
|
}
|
|
3298
3298
|
get(key, keepScalar) {
|
|
3299
3299
|
return identity.isCollection(this.contents) ? this.contents.get(key, keepScalar) : undefined;
|
|
3300
3300
|
}
|
|
3301
|
-
getIn(
|
|
3302
|
-
if (Collection.isEmptyPath(
|
|
3301
|
+
getIn(path, keepScalar) {
|
|
3302
|
+
if (Collection.isEmptyPath(path))
|
|
3303
3303
|
return !keepScalar && identity.isScalar(this.contents) ? this.contents.value : this.contents;
|
|
3304
|
-
return identity.isCollection(this.contents) ? this.contents.getIn(
|
|
3304
|
+
return identity.isCollection(this.contents) ? this.contents.getIn(path, keepScalar) : undefined;
|
|
3305
3305
|
}
|
|
3306
3306
|
has(key) {
|
|
3307
3307
|
return identity.isCollection(this.contents) ? this.contents.has(key) : false;
|
|
3308
3308
|
}
|
|
3309
|
-
hasIn(
|
|
3310
|
-
if (Collection.isEmptyPath(
|
|
3309
|
+
hasIn(path) {
|
|
3310
|
+
if (Collection.isEmptyPath(path))
|
|
3311
3311
|
return this.contents !== undefined;
|
|
3312
|
-
return identity.isCollection(this.contents) ? this.contents.hasIn(
|
|
3312
|
+
return identity.isCollection(this.contents) ? this.contents.hasIn(path) : false;
|
|
3313
3313
|
}
|
|
3314
3314
|
set(key, value) {
|
|
3315
3315
|
if (this.contents == null) {
|
|
@@ -3318,13 +3318,13 @@ var require_Document = __commonJS(function(exports) {
|
|
|
3318
3318
|
this.contents.set(key, value);
|
|
3319
3319
|
}
|
|
3320
3320
|
}
|
|
3321
|
-
setIn(
|
|
3322
|
-
if (Collection.isEmptyPath(
|
|
3321
|
+
setIn(path, value) {
|
|
3322
|
+
if (Collection.isEmptyPath(path)) {
|
|
3323
3323
|
this.contents = value;
|
|
3324
3324
|
} else if (this.contents == null) {
|
|
3325
|
-
this.contents = Collection.collectionFromPath(this.schema, Array.from(
|
|
3325
|
+
this.contents = Collection.collectionFromPath(this.schema, Array.from(path), value);
|
|
3326
3326
|
} else if (assertCollection(this.contents)) {
|
|
3327
|
-
this.contents.setIn(
|
|
3327
|
+
this.contents.setIn(path, value);
|
|
3328
3328
|
}
|
|
3329
3329
|
}
|
|
3330
3330
|
setSchema(version, options = {}) {
|
|
@@ -3375,8 +3375,8 @@ var require_Document = __commonJS(function(exports) {
|
|
|
3375
3375
|
};
|
|
3376
3376
|
const res = toJS.toJS(this.contents, jsonArg ?? "", ctx);
|
|
3377
3377
|
if (typeof onAnchor === "function")
|
|
3378
|
-
for (const { count, res
|
|
3379
|
-
onAnchor(
|
|
3378
|
+
for (const { count, res } of ctx.anchors.values())
|
|
3379
|
+
onAnchor(res, count);
|
|
3380
3380
|
return typeof reviver === "function" ? applyReviver.applyReviver(reviver, { "": res }, "", res) : res;
|
|
3381
3381
|
}
|
|
3382
3382
|
toJSON(jsonArg, onAnchor) {
|
|
@@ -4130,12 +4130,12 @@ var require_resolve_block_scalar = __commonJS(function(exports) {
|
|
|
4130
4130
|
break;
|
|
4131
4131
|
}
|
|
4132
4132
|
if (chompStart === 0) {
|
|
4133
|
-
const
|
|
4133
|
+
const value = header.chomp === "+" && lines.length > 0 ? `
|
|
4134
4134
|
`.repeat(Math.max(1, lines.length - 1)) : "";
|
|
4135
|
-
let
|
|
4135
|
+
let end = start + header.length;
|
|
4136
4136
|
if (scalar.source)
|
|
4137
|
-
|
|
4138
|
-
return { value
|
|
4137
|
+
end += scalar.source.length;
|
|
4138
|
+
return { value, type, comment: header.comment, range: [start, end, end] };
|
|
4139
4139
|
}
|
|
4140
4140
|
let trimIndent = scalar.indent + header.indent;
|
|
4141
4141
|
let offset = scalar.offset + header.length;
|
|
@@ -4584,9 +4584,9 @@ var require_compose_scalar = __commonJS(function(exports) {
|
|
|
4584
4584
|
return schema[identity.SCALAR];
|
|
4585
4585
|
}
|
|
4586
4586
|
function findScalarTagByTest({ atKey, directives, schema }, value, token, onError) {
|
|
4587
|
-
const tag = schema.tags.find((
|
|
4587
|
+
const tag = schema.tags.find((tag) => (tag.default === true || atKey && tag.default === "key") && tag.test?.test(value)) || schema[identity.SCALAR];
|
|
4588
4588
|
if (schema.compat) {
|
|
4589
|
-
const compat = schema.compat.find((
|
|
4589
|
+
const compat = schema.compat.find((tag) => tag.default && tag.test?.test(value)) ?? schema[identity.SCALAR];
|
|
4590
4590
|
if (tag.tag !== compat.tag) {
|
|
4591
4591
|
const ts = directives.tagString(tag.tag);
|
|
4592
4592
|
const cs = directives.tagString(compat.tag);
|
|
@@ -5221,9 +5221,9 @@ var require_cst_visit = __commonJS(function(exports) {
|
|
|
5221
5221
|
visit.BREAK = BREAK;
|
|
5222
5222
|
visit.SKIP = SKIP;
|
|
5223
5223
|
visit.REMOVE = REMOVE;
|
|
5224
|
-
visit.itemAtPath = (cst,
|
|
5224
|
+
visit.itemAtPath = (cst, path) => {
|
|
5225
5225
|
let item = cst;
|
|
5226
|
-
for (const [field, index] of
|
|
5226
|
+
for (const [field, index] of path) {
|
|
5227
5227
|
const tok = item?.[field];
|
|
5228
5228
|
if (tok && "items" in tok) {
|
|
5229
5229
|
item = tok.items[index];
|
|
@@ -5232,23 +5232,23 @@ var require_cst_visit = __commonJS(function(exports) {
|
|
|
5232
5232
|
}
|
|
5233
5233
|
return item;
|
|
5234
5234
|
};
|
|
5235
|
-
visit.parentCollection = (cst,
|
|
5236
|
-
const parent = visit.itemAtPath(cst,
|
|
5237
|
-
const field =
|
|
5235
|
+
visit.parentCollection = (cst, path) => {
|
|
5236
|
+
const parent = visit.itemAtPath(cst, path.slice(0, -1));
|
|
5237
|
+
const field = path[path.length - 1][0];
|
|
5238
5238
|
const coll = parent?.[field];
|
|
5239
5239
|
if (coll && "items" in coll)
|
|
5240
5240
|
return coll;
|
|
5241
5241
|
throw new Error("Parent collection not found");
|
|
5242
5242
|
};
|
|
5243
|
-
function _visit(
|
|
5244
|
-
let ctrl = visitor(item,
|
|
5243
|
+
function _visit(path, item, visitor) {
|
|
5244
|
+
let ctrl = visitor(item, path);
|
|
5245
5245
|
if (typeof ctrl === "symbol")
|
|
5246
5246
|
return ctrl;
|
|
5247
5247
|
for (const field of ["key", "value"]) {
|
|
5248
5248
|
const token = item[field];
|
|
5249
5249
|
if (token && "items" in token) {
|
|
5250
5250
|
for (let i = 0;i < token.items.length; ++i) {
|
|
5251
|
-
const ci = _visit(Object.freeze(
|
|
5251
|
+
const ci = _visit(Object.freeze(path.concat([[field, i]])), token.items[i], visitor);
|
|
5252
5252
|
if (typeof ci === "number")
|
|
5253
5253
|
i = ci - 1;
|
|
5254
5254
|
else if (ci === BREAK)
|
|
@@ -5259,10 +5259,10 @@ var require_cst_visit = __commonJS(function(exports) {
|
|
|
5259
5259
|
}
|
|
5260
5260
|
}
|
|
5261
5261
|
if (typeof ctrl === "function" && field === "key")
|
|
5262
|
-
ctrl = ctrl(item,
|
|
5262
|
+
ctrl = ctrl(item, path);
|
|
5263
5263
|
}
|
|
5264
5264
|
}
|
|
5265
|
-
return typeof ctrl === "function" ? ctrl(item,
|
|
5265
|
+
return typeof ctrl === "function" ? ctrl(item, path) : ctrl;
|
|
5266
5266
|
}
|
|
5267
5267
|
exports.visit = visit;
|
|
5268
5268
|
});
|
|
@@ -5742,18 +5742,18 @@ var require_lexer = __commonJS(function(exports) {
|
|
|
5742
5742
|
let indent = 0;
|
|
5743
5743
|
let ch;
|
|
5744
5744
|
loop:
|
|
5745
|
-
for (let
|
|
5745
|
+
for (let i = this.pos;ch = this.buffer[i]; ++i) {
|
|
5746
5746
|
switch (ch) {
|
|
5747
5747
|
case " ":
|
|
5748
5748
|
indent += 1;
|
|
5749
5749
|
break;
|
|
5750
5750
|
case `
|
|
5751
5751
|
`:
|
|
5752
|
-
nl =
|
|
5752
|
+
nl = i;
|
|
5753
5753
|
indent = 0;
|
|
5754
5754
|
break;
|
|
5755
5755
|
case "\r": {
|
|
5756
|
-
const next = this.buffer[
|
|
5756
|
+
const next = this.buffer[i + 1];
|
|
5757
5757
|
if (!next && !this.atEnd)
|
|
5758
5758
|
return this.setNext("block-scalar");
|
|
5759
5759
|
if (next === `
|
|
@@ -5796,16 +5796,16 @@ var require_lexer = __commonJS(function(exports) {
|
|
|
5796
5796
|
nl = i - 1;
|
|
5797
5797
|
} else if (!this.blockScalarKeep) {
|
|
5798
5798
|
do {
|
|
5799
|
-
let
|
|
5800
|
-
let
|
|
5801
|
-
if (
|
|
5802
|
-
|
|
5803
|
-
const lastChar =
|
|
5804
|
-
while (
|
|
5805
|
-
|
|
5806
|
-
if (
|
|
5807
|
-
` &&
|
|
5808
|
-
nl =
|
|
5799
|
+
let i = nl - 1;
|
|
5800
|
+
let ch = this.buffer[i];
|
|
5801
|
+
if (ch === "\r")
|
|
5802
|
+
ch = this.buffer[--i];
|
|
5803
|
+
const lastChar = i;
|
|
5804
|
+
while (ch === " ")
|
|
5805
|
+
ch = this.buffer[--i];
|
|
5806
|
+
if (ch === `
|
|
5807
|
+
` && i >= this.pos && i + 1 + indent > lastChar)
|
|
5808
|
+
nl = i;
|
|
5809
5809
|
else
|
|
5810
5810
|
break;
|
|
5811
5811
|
} while (true);
|
|
@@ -6492,12 +6492,12 @@ var require_parser = __commonJS(function(exports) {
|
|
|
6492
6492
|
if (includesToken(it.start, "newline")) {
|
|
6493
6493
|
Object.assign(it, { key: null, sep: [this.sourceToken] });
|
|
6494
6494
|
} else {
|
|
6495
|
-
const
|
|
6495
|
+
const start = getFirstKeyStartProps(it.start);
|
|
6496
6496
|
this.stack.push({
|
|
6497
6497
|
type: "block-map",
|
|
6498
6498
|
offset: this.offset,
|
|
6499
6499
|
indent: this.indent,
|
|
6500
|
-
items: [{ start
|
|
6500
|
+
items: [{ start, key: null, sep: [this.sourceToken] }]
|
|
6501
6501
|
});
|
|
6502
6502
|
}
|
|
6503
6503
|
} else if (it.value) {
|
|
@@ -6510,7 +6510,7 @@ var require_parser = __commonJS(function(exports) {
|
|
|
6510
6510
|
items: [{ start, key: null, sep: [this.sourceToken] }]
|
|
6511
6511
|
});
|
|
6512
6512
|
} else if (isFlowToken(it.key) && !includesToken(it.sep, "newline")) {
|
|
6513
|
-
const
|
|
6513
|
+
const start = getFirstKeyStartProps(it.start);
|
|
6514
6514
|
const key = it.key;
|
|
6515
6515
|
const sep = it.sep;
|
|
6516
6516
|
sep.push(this.sourceToken);
|
|
@@ -6520,7 +6520,7 @@ var require_parser = __commonJS(function(exports) {
|
|
|
6520
6520
|
type: "block-map",
|
|
6521
6521
|
offset: this.offset,
|
|
6522
6522
|
indent: this.indent,
|
|
6523
|
-
items: [{ start
|
|
6523
|
+
items: [{ start, key, sep }]
|
|
6524
6524
|
});
|
|
6525
6525
|
} else if (start.length > 0) {
|
|
6526
6526
|
it.sep = it.sep.concat(start, this.sourceToken);
|
|
@@ -6549,14 +6549,14 @@ var require_parser = __commonJS(function(exports) {
|
|
|
6549
6549
|
case "scalar":
|
|
6550
6550
|
case "single-quoted-scalar":
|
|
6551
6551
|
case "double-quoted-scalar": {
|
|
6552
|
-
const
|
|
6552
|
+
const fs = this.flowScalar(this.type);
|
|
6553
6553
|
if (atNextItem || it.value) {
|
|
6554
|
-
map.items.push({ start, key:
|
|
6554
|
+
map.items.push({ start, key: fs, sep: [] });
|
|
6555
6555
|
this.onKeyLine = true;
|
|
6556
6556
|
} else if (it.sep) {
|
|
6557
|
-
this.stack.push(
|
|
6557
|
+
this.stack.push(fs);
|
|
6558
6558
|
} else {
|
|
6559
|
-
Object.assign(it, { key:
|
|
6559
|
+
Object.assign(it, { key: fs, sep: [] });
|
|
6560
6560
|
this.onKeyLine = true;
|
|
6561
6561
|
}
|
|
6562
6562
|
return;
|
|
@@ -6684,13 +6684,13 @@ var require_parser = __commonJS(function(exports) {
|
|
|
6684
6684
|
case "scalar":
|
|
6685
6685
|
case "single-quoted-scalar":
|
|
6686
6686
|
case "double-quoted-scalar": {
|
|
6687
|
-
const
|
|
6687
|
+
const fs = this.flowScalar(this.type);
|
|
6688
6688
|
if (!it || it.value)
|
|
6689
|
-
fc.items.push({ start: [], key:
|
|
6689
|
+
fc.items.push({ start: [], key: fs, sep: [] });
|
|
6690
6690
|
else if (it.sep)
|
|
6691
|
-
this.stack.push(
|
|
6691
|
+
this.stack.push(fs);
|
|
6692
6692
|
else
|
|
6693
|
-
Object.assign(it, { key:
|
|
6693
|
+
Object.assign(it, { key: fs, sep: [] });
|
|
6694
6694
|
return;
|
|
6695
6695
|
}
|
|
6696
6696
|
case "flow-map-end":
|
|
@@ -6864,22 +6864,22 @@ var require_public_api = __commonJS(function(exports) {
|
|
|
6864
6864
|
return { lineCounter: lineCounter$1, prettyErrors };
|
|
6865
6865
|
}
|
|
6866
6866
|
function parseAllDocuments(source, options = {}) {
|
|
6867
|
-
const { lineCounter
|
|
6868
|
-
const parser$1 = new parser.Parser(
|
|
6867
|
+
const { lineCounter, prettyErrors } = parseOptions(options);
|
|
6868
|
+
const parser$1 = new parser.Parser(lineCounter?.addNewLine);
|
|
6869
6869
|
const composer$1 = new composer.Composer(options);
|
|
6870
6870
|
const docs = Array.from(composer$1.compose(parser$1.parse(source)));
|
|
6871
|
-
if (prettyErrors &&
|
|
6871
|
+
if (prettyErrors && lineCounter)
|
|
6872
6872
|
for (const doc of docs) {
|
|
6873
|
-
doc.errors.forEach(errors.prettifyError(source,
|
|
6874
|
-
doc.warnings.forEach(errors.prettifyError(source,
|
|
6873
|
+
doc.errors.forEach(errors.prettifyError(source, lineCounter));
|
|
6874
|
+
doc.warnings.forEach(errors.prettifyError(source, lineCounter));
|
|
6875
6875
|
}
|
|
6876
6876
|
if (docs.length > 0)
|
|
6877
6877
|
return docs;
|
|
6878
6878
|
return Object.assign([], { empty: true }, composer$1.streamInfo());
|
|
6879
6879
|
}
|
|
6880
6880
|
function parseDocument(source, options = {}) {
|
|
6881
|
-
const { lineCounter
|
|
6882
|
-
const parser$1 = new parser.Parser(
|
|
6881
|
+
const { lineCounter, prettyErrors } = parseOptions(options);
|
|
6882
|
+
const parser$1 = new parser.Parser(lineCounter?.addNewLine);
|
|
6883
6883
|
const composer$1 = new composer.Composer(options);
|
|
6884
6884
|
let doc = null;
|
|
6885
6885
|
for (const _doc of composer$1.compose(parser$1.parse(source), true, source.length)) {
|
|
@@ -6890,9 +6890,9 @@ var require_public_api = __commonJS(function(exports) {
|
|
|
6890
6890
|
break;
|
|
6891
6891
|
}
|
|
6892
6892
|
}
|
|
6893
|
-
if (prettyErrors &&
|
|
6894
|
-
doc.errors.forEach(errors.prettifyError(source,
|
|
6895
|
-
doc.warnings.forEach(errors.prettifyError(source,
|
|
6893
|
+
if (prettyErrors && lineCounter) {
|
|
6894
|
+
doc.errors.forEach(errors.prettifyError(source, lineCounter));
|
|
6895
|
+
doc.warnings.forEach(errors.prettifyError(source, lineCounter));
|
|
6896
6896
|
}
|
|
6897
6897
|
return doc;
|
|
6898
6898
|
}
|
|
@@ -6949,16 +6949,16 @@ import * as os8 from "node:os";
|
|
|
6949
6949
|
import * as path23 from "node:path";
|
|
6950
6950
|
import {
|
|
6951
6951
|
APP_NAME as APP_NAME3,
|
|
6952
|
-
keyHintIfBound as
|
|
6952
|
+
keyHintIfBound as keyHintIfBound5
|
|
6953
6953
|
} from "@bastani/atomic";
|
|
6954
6954
|
import {
|
|
6955
6955
|
Box,
|
|
6956
6956
|
Container as Container4,
|
|
6957
6957
|
Spacer as Spacer2,
|
|
6958
|
-
Text as
|
|
6959
|
-
truncateToWidth,
|
|
6960
|
-
visibleWidth as
|
|
6961
|
-
wrapTextWithAnsi
|
|
6958
|
+
Text as Text5,
|
|
6959
|
+
truncateToWidth as truncateToWidth4,
|
|
6960
|
+
visibleWidth as visibleWidth4,
|
|
6961
|
+
wrapTextWithAnsi as wrapTextWithAnsi2
|
|
6962
6962
|
} from "@earendil-works/pi-tui";
|
|
6963
6963
|
|
|
6964
6964
|
// dist/builtin/subagents/src/agents/agent-discovery.ts
|
|
@@ -7234,7 +7234,7 @@ function readSubagentSettings(filePath) {
|
|
|
7234
7234
|
}
|
|
7235
7235
|
function readMergedSubagentSettings(filePaths) {
|
|
7236
7236
|
let settings = EMPTY_SUBAGENT_SETTINGS;
|
|
7237
|
-
let
|
|
7237
|
+
let path = null;
|
|
7238
7238
|
for (let i = filePaths.length - 1;i >= 0; i--) {
|
|
7239
7239
|
const filePath = filePaths[i];
|
|
7240
7240
|
if (!fs2.existsSync(filePath))
|
|
@@ -7244,9 +7244,9 @@ function readMergedSubagentSettings(filePaths) {
|
|
|
7244
7244
|
disableBuiltins: next.disableBuiltins ?? settings.disableBuiltins,
|
|
7245
7245
|
overrides: { ...settings.overrides, ...next.overrides }
|
|
7246
7246
|
};
|
|
7247
|
-
|
|
7247
|
+
path = filePath;
|
|
7248
7248
|
}
|
|
7249
|
-
return { settings, path
|
|
7249
|
+
return { settings, path };
|
|
7250
7250
|
}
|
|
7251
7251
|
function applyBuiltinOverride(agent, override, meta) {
|
|
7252
7252
|
const next = {
|
|
@@ -8169,7 +8169,7 @@ var DEFAULT_INTERCOM_BRIDGE_TEMPLATE = `The inherited thread is reference-only.
|
|
|
8169
8169
|
|
|
8170
8170
|
Use contact_supervisor first. It resolves the supervisor session "{orchestratorTarget}" and run metadata automatically.
|
|
8171
8171
|
- Need a decision, blocked, approval, or product/API/scope ambiguity: contact_supervisor({ reason: "need_decision", message: "<question>" })
|
|
8172
|
-
-
|
|
8172
|
+
- In parallel runs, blocking requests wait here and the supervisor's correlated reply lets this same child continue; siblings keep running. Do not request a replacement launch. A single-child claimed decision/interview instead ends with a dynamic [TASK_CONTEXT] fresh-child handoff; follow the actual tool result.
|
|
8173
8173
|
- Do not ask for clarification when the only conflict is review-only/no-edit versus progress-writing or artifact-writing instructions. Review-only/no-edit wins; leave files unchanged and mention the conflict in your final result only if it matters.
|
|
8174
8174
|
- Meaningful progress or unexpected discoveries that change the plan: contact_supervisor({ reason: "progress_update", message: "UPDATE: <summary>" })
|
|
8175
8175
|
- Generic intercom is lower-level plumbing/fallback only: intercom({ action: "ask", to: "{orchestratorTarget}", message: "<question>" })
|
|
@@ -8483,9 +8483,9 @@ function resolveTempScopeId(options) {
|
|
|
8483
8483
|
if (username)
|
|
8484
8484
|
return `user-${sanitizeTempScopeSegment(username)}`;
|
|
8485
8485
|
} catch {}
|
|
8486
|
-
const
|
|
8487
|
-
if (
|
|
8488
|
-
return `home-${sanitizeTempScopeSegment(
|
|
8486
|
+
const homedir = env.USERPROFILE ?? env.HOME;
|
|
8487
|
+
if (homedir)
|
|
8488
|
+
return `home-${sanitizeTempScopeSegment(homedir)}`;
|
|
8489
8489
|
const resolveHomedir = options && Object.hasOwn(options, "homedir") ? options.homedir : os4.homedir;
|
|
8490
8490
|
try {
|
|
8491
8491
|
const fallbackHomedir = resolveHomedir?.();
|
|
@@ -8504,7 +8504,7 @@ var SLASH_SUBAGENT_STARTED_EVENT = "subagent:slash:started";
|
|
|
8504
8504
|
var SLASH_SUBAGENT_RESPONSE_EVENT = "subagent:slash:response";
|
|
8505
8505
|
var SLASH_SUBAGENT_UPDATE_EVENT = "subagent:slash:update";
|
|
8506
8506
|
var SLASH_SUBAGENT_CANCEL_EVENT = "subagent:slash:cancel";
|
|
8507
|
-
var SUBAGENT_ACTIONS = ["list", "get", "create", "update", "delete", "status", "interrupt"];
|
|
8507
|
+
var SUBAGENT_ACTIONS = ["list", "get", "create", "update", "delete", "status", "interrupt", "wait"];
|
|
8508
8508
|
var DEFAULT_FORK_PREAMBLE = "You are a delegated subagent running from a fork of the parent session. " + "Treat the inherited conversation as reference-only context, not a live thread to continue. " + "Do not continue or answer prior messages as if they are waiting for a reply. " + "Your sole job is to execute the task below and return a focused result for that task using your tools.";
|
|
8509
8509
|
function normalizeTopLevelParallelValue(value) {
|
|
8510
8510
|
const parsed = typeof value === "number" ? value : typeof value === "string" ? Number(value) : NaN;
|
|
@@ -8892,8 +8892,8 @@ function collectInstalledPackageSkillPaths(cwd) {
|
|
|
8892
8892
|
continue;
|
|
8893
8893
|
if (!scopeEntry.isDirectory() && !scopeEntry.isSymbolicLink())
|
|
8894
8894
|
continue;
|
|
8895
|
-
const
|
|
8896
|
-
results.push(...extractSkillPathsFromPackageRoot(
|
|
8895
|
+
const pkgRoot = path7.join(scopeDir, scopeEntry.name);
|
|
8896
|
+
results.push(...extractSkillPathsFromPackageRoot(pkgRoot, dir.source, true));
|
|
8897
8897
|
}
|
|
8898
8898
|
continue;
|
|
8899
8899
|
}
|
|
@@ -10012,9 +10012,12 @@ function handleSubagentControlNotice(input) {
|
|
|
10012
10012
|
}
|
|
10013
10013
|
|
|
10014
10014
|
// dist/builtin/subagents/src/runs/inprocess/runner.ts
|
|
10015
|
+
import { randomUUID } from "node:crypto";
|
|
10015
10016
|
import { appendFileSync as appendFileSync2, existsSync as existsSync10, mkdirSync as mkdirSync4, statSync as statSync4 } from "node:fs";
|
|
10016
10017
|
import { basename as basename2, dirname as dirname7, join as join10, relative as relative2, resolve as resolve6 } from "node:path";
|
|
10017
10018
|
import {
|
|
10019
|
+
applyAssistantMessageDelta,
|
|
10020
|
+
beginStreamingAssistantMessage,
|
|
10018
10021
|
createAgentSession,
|
|
10019
10022
|
DefaultResourceLoader,
|
|
10020
10023
|
getAgentDir as getAgentDir2,
|
|
@@ -10025,6 +10028,7 @@ import {
|
|
|
10025
10028
|
import {
|
|
10026
10029
|
SubagentControl
|
|
10027
10030
|
} from "@bastani/atomic-natives";
|
|
10031
|
+
import { clampThinkingLevel } from "@bastani/pi-ai/compat";
|
|
10028
10032
|
|
|
10029
10033
|
// dist/builtin/subagents/src/shared/artifacts.ts
|
|
10030
10034
|
import * as fs10 from "node:fs";
|
|
@@ -10449,14 +10453,14 @@ function waitForExecutionCapacity(delayMs, signals) {
|
|
|
10449
10453
|
return new Promise((resolveWait) => {
|
|
10450
10454
|
let settled = false;
|
|
10451
10455
|
let timer;
|
|
10452
|
-
const settle = (
|
|
10456
|
+
const settle = (result) => {
|
|
10453
10457
|
if (settled)
|
|
10454
10458
|
return;
|
|
10455
10459
|
settled = true;
|
|
10456
10460
|
clearTimeout(timer);
|
|
10457
10461
|
signals.abort.removeEventListener("abort", onAbort);
|
|
10458
10462
|
signals.interrupt.removeEventListener("abort", onInterrupt);
|
|
10459
|
-
resolveWait(
|
|
10463
|
+
resolveWait(result);
|
|
10460
10464
|
};
|
|
10461
10465
|
const onAbort = () => settle("abort");
|
|
10462
10466
|
const onInterrupt = () => settle("interrupt");
|
|
@@ -10504,10 +10508,10 @@ function createTestSession(sessionManager, spec) {
|
|
|
10504
10508
|
let aborted = false;
|
|
10505
10509
|
let settlePromptAbort;
|
|
10506
10510
|
const messages = [];
|
|
10507
|
-
const promptAbort = new Promise((
|
|
10511
|
+
const promptAbort = new Promise((resolve, reject) => {
|
|
10508
10512
|
settlePromptAbort = () => {
|
|
10509
10513
|
if (testOptions.abortResolvesPrompt)
|
|
10510
|
-
|
|
10514
|
+
resolve("aborted");
|
|
10511
10515
|
else
|
|
10512
10516
|
reject(new Error("aborted"));
|
|
10513
10517
|
};
|
|
@@ -10592,6 +10596,9 @@ function createTestSession(sessionManager, spec) {
|
|
|
10592
10596
|
}
|
|
10593
10597
|
if (testOptions.fallbackBeforeGate)
|
|
10594
10598
|
emitFallback();
|
|
10599
|
+
for (const event of testOptions.beforeGateEvents ?? [])
|
|
10600
|
+
for (const listener of listeners)
|
|
10601
|
+
listener(event);
|
|
10595
10602
|
if (testOptions.promptGate) {
|
|
10596
10603
|
const gateResult = await Promise.race([
|
|
10597
10604
|
testOptions.promptGate.then(() => "released"),
|
|
@@ -10646,7 +10653,7 @@ function createTestSession(sessionManager, spec) {
|
|
|
10646
10653
|
tokens: zeroTokens,
|
|
10647
10654
|
cost: 0
|
|
10648
10655
|
}),
|
|
10649
|
-
dispose: () => {}
|
|
10656
|
+
dispose: testOptions.dispose ?? (() => {})
|
|
10650
10657
|
};
|
|
10651
10658
|
}
|
|
10652
10659
|
function nativeStatus(value) {
|
|
@@ -10655,14 +10662,14 @@ function nativeStatus(value) {
|
|
|
10655
10662
|
function nativeCause(value) {
|
|
10656
10663
|
return value;
|
|
10657
10664
|
}
|
|
10658
|
-
function refusal(
|
|
10659
|
-
if (!
|
|
10665
|
+
function refusal(result) {
|
|
10666
|
+
if (!result.refusal)
|
|
10660
10667
|
return {};
|
|
10661
10668
|
return {
|
|
10662
10669
|
refusal: {
|
|
10663
|
-
kind:
|
|
10664
|
-
reason:
|
|
10665
|
-
...
|
|
10670
|
+
kind: result.refusal.kind,
|
|
10671
|
+
reason: result.refusal.reason,
|
|
10672
|
+
...result.refusal.maxDepth === undefined ? {} : { maxDepth: result.refusal.maxDepth }
|
|
10666
10673
|
}
|
|
10667
10674
|
};
|
|
10668
10675
|
}
|
|
@@ -10701,10 +10708,10 @@ function attemptStatus(termination) {
|
|
|
10701
10708
|
}
|
|
10702
10709
|
function boundedEnvelope(output, artifactPath, maxOutput) {
|
|
10703
10710
|
const config = { ...DEFAULT_MAX_OUTPUT, ...maxOutput };
|
|
10704
|
-
const
|
|
10705
|
-
return
|
|
10711
|
+
const result = truncateOutput(output, config, artifactPath);
|
|
10712
|
+
return result.truncated && artifactPath ? `${result.text}
|
|
10706
10713
|
|
|
10707
|
-
Full output: ${artifactPath}` :
|
|
10714
|
+
Full output: ${artifactPath}` : result.text;
|
|
10708
10715
|
}
|
|
10709
10716
|
function canonicalArtifactPaths(artifactsDir, childPath) {
|
|
10710
10717
|
const prefix = childPath.replaceAll("/", "_");
|
|
@@ -10829,13 +10836,13 @@ class SubagentControlRuntime {
|
|
|
10829
10836
|
const native = this.native.admitChildSession({ taskName: spec.taskName, agentName: spec.agent.name, cwd: spec.cwd }, { path: parent.path, depth: parent.depth });
|
|
10830
10837
|
if (!native.child)
|
|
10831
10838
|
return refusal(native);
|
|
10832
|
-
const
|
|
10839
|
+
const identity = native.child;
|
|
10833
10840
|
const childModePolicy = resolveChildModePolicy(spec);
|
|
10834
|
-
const sessionDir = spec.sessionFile ? dirname7(spec.sessionFile) : sessionDirectory(this.sessionRoot,
|
|
10841
|
+
const sessionDir = spec.sessionFile ? dirname7(spec.sessionFile) : sessionDirectory(this.sessionRoot, identity.path);
|
|
10835
10842
|
mkdirSync4(sessionDir, { recursive: true });
|
|
10836
10843
|
return {
|
|
10837
10844
|
admitted: AdmittedChild.create({
|
|
10838
|
-
identity
|
|
10845
|
+
identity,
|
|
10839
10846
|
spec,
|
|
10840
10847
|
policy: {
|
|
10841
10848
|
...childModePolicy,
|
|
@@ -10849,7 +10856,7 @@ class SubagentControlRuntime {
|
|
|
10849
10856
|
thinkingLevel: spec.thinkingLevel ?? spec.agent.thinking,
|
|
10850
10857
|
intercomGroup: parent.intercomGroup,
|
|
10851
10858
|
intercom: spec.intercom,
|
|
10852
|
-
depth:
|
|
10859
|
+
depth: identity.depth
|
|
10853
10860
|
},
|
|
10854
10861
|
sessionDir,
|
|
10855
10862
|
sessionFile: spec.sessionFile,
|
|
@@ -10857,12 +10864,22 @@ class SubagentControlRuntime {
|
|
|
10857
10864
|
})
|
|
10858
10865
|
};
|
|
10859
10866
|
}
|
|
10860
|
-
async runChildAttempt(admitted, candidate, signals, onModelChange) {
|
|
10867
|
+
async runChildAttempt(admitted, candidate, signals, onModelChange, taskHooks, onCleanup) {
|
|
10861
10868
|
const candidateModelId = modelIdForCandidate(candidate, admitted.policy.model);
|
|
10862
10869
|
const configuredThinking = candidate.thinkingLevel ?? admitted.policy.thinkingLevel;
|
|
10863
10870
|
let effectiveModelId = candidateModelId;
|
|
10864
10871
|
let effectiveThinking = initialThinkingForAttempt(candidateModelId, configuredThinking);
|
|
10865
10872
|
let attemptedModels = candidateModelId ? [candidateModelId] : [];
|
|
10873
|
+
const selectedModel = candidate.model ?? admitted.policy.model;
|
|
10874
|
+
if (selectedModel)
|
|
10875
|
+
taskHooks?.reportActivity({
|
|
10876
|
+
reportId: `${randomUUID()}:admission-model`,
|
|
10877
|
+
change: {
|
|
10878
|
+
kind: "model",
|
|
10879
|
+
model: `${selectedModel.provider}/${selectedModel.id}`,
|
|
10880
|
+
thinking: configuredThinking === undefined ? undefined : clampThinkingLevel(selectedModel, configuredThinking)
|
|
10881
|
+
}
|
|
10882
|
+
});
|
|
10866
10883
|
let guard;
|
|
10867
10884
|
let retryDelayMs = CAPACITY_RETRY_INITIAL_DELAY_MS;
|
|
10868
10885
|
for (;; ) {
|
|
@@ -10914,6 +10931,7 @@ class SubagentControlRuntime {
|
|
|
10914
10931
|
const token = guard.token;
|
|
10915
10932
|
this.attemptTokens.set(admitted.identity.path, token);
|
|
10916
10933
|
let session;
|
|
10934
|
+
const executionEnded = new AbortController;
|
|
10917
10935
|
let activeSessionManager;
|
|
10918
10936
|
let termination;
|
|
10919
10937
|
let terminating;
|
|
@@ -10948,6 +10966,7 @@ class SubagentControlRuntime {
|
|
|
10948
10966
|
mkdirSync4(dirname7(admitted.sessionFile), { recursive: true });
|
|
10949
10967
|
const sessionManager = admitted.sessionFile ? SessionManager.open(admitted.sessionFile, admitted.sessionDir, admitted.policy.cwd) : SessionManager.create(admitted.policy.cwd, admitted.sessionDir, workflow ? { internal: true, workflow } : { internal: true });
|
|
10950
10968
|
activeSessionManager = sessionManager;
|
|
10969
|
+
taskHooks?.bindTranscript?.(sessionManager);
|
|
10951
10970
|
if (workflow)
|
|
10952
10971
|
sessionManager.markSessionInternal(workflow);
|
|
10953
10972
|
let created;
|
|
@@ -10987,7 +11006,7 @@ class SubagentControlRuntime {
|
|
|
10987
11006
|
sessionManager,
|
|
10988
11007
|
settingsManager,
|
|
10989
11008
|
orchestrationContext: admitted.spec.parent?.orchestrationContext,
|
|
10990
|
-
subagentPolicy: admitted.policy,
|
|
11009
|
+
subagentPolicy: { ...admitted.policy, executionEnded: executionEnded.signal },
|
|
10991
11010
|
systemPromptTransform,
|
|
10992
11011
|
initialContextTransform: promptBehavior.initialContextTransform
|
|
10993
11012
|
})).session
|
|
@@ -10995,6 +11014,14 @@ class SubagentControlRuntime {
|
|
|
10995
11014
|
await created.session.extensionRunner.emit({ type: "session_start", reason: "startup" });
|
|
10996
11015
|
}
|
|
10997
11016
|
session = created.session;
|
|
11017
|
+
const transcriptSession = session;
|
|
11018
|
+
let observedStreamingMessage;
|
|
11019
|
+
taskHooks?.bindTranscript?.({
|
|
11020
|
+
getSessionId: () => sessionManager.getSessionId(),
|
|
11021
|
+
getEntries: () => sessionManager.getEntries(),
|
|
11022
|
+
subscribe: (listener) => transcriptSession.subscribe(listener),
|
|
11023
|
+
getStreamingMessage: () => observedStreamingMessage
|
|
11024
|
+
});
|
|
10998
11025
|
const initialModelId = modelIdForSession(session) ?? candidateModelId;
|
|
10999
11026
|
effectiveModelId = initialModelId;
|
|
11000
11027
|
effectiveThinking = thinkingLevelForSession(session) ?? initialThinkingForAttempt(candidateModelId, configuredThinking);
|
|
@@ -11015,10 +11042,11 @@ class SubagentControlRuntime {
|
|
|
11015
11042
|
lastActivityAt: Date.now()
|
|
11016
11043
|
};
|
|
11017
11044
|
const attemptStartedAt = Date.now();
|
|
11045
|
+
const activityPrefix = randomUUID();
|
|
11018
11046
|
let lastProgressEmit = 0;
|
|
11019
11047
|
const emitProgress = (force) => {
|
|
11020
11048
|
const onProgress = admitted.spec.onProgress;
|
|
11021
|
-
if (!onProgress)
|
|
11049
|
+
if (!onProgress && !taskHooks)
|
|
11022
11050
|
return;
|
|
11023
11051
|
const now = Date.now();
|
|
11024
11052
|
if (!force && now - lastProgressEmit < 400)
|
|
@@ -11026,11 +11054,38 @@ class SubagentControlRuntime {
|
|
|
11026
11054
|
lastProgressEmit = now;
|
|
11027
11055
|
progressState.durationMs = now - attemptStartedAt;
|
|
11028
11056
|
progressState.lastActivityAt = now;
|
|
11029
|
-
|
|
11057
|
+
taskHooks?.reportActivity({
|
|
11058
|
+
reportId: `${activityPrefix}:metrics-${++activitySequence}`,
|
|
11059
|
+
change: {
|
|
11060
|
+
kind: "metrics",
|
|
11061
|
+
elapsedMs: progressState.durationMs,
|
|
11062
|
+
toolCount: progressState.toolCount,
|
|
11063
|
+
tokenCount: progressState.tokens
|
|
11064
|
+
}
|
|
11065
|
+
});
|
|
11066
|
+
onProgress?.({ ...progressState, recentTools: [...progressState.recentTools] });
|
|
11030
11067
|
};
|
|
11068
|
+
let activitySequence = 0;
|
|
11069
|
+
const reportModel = () => taskHooks?.reportActivity({
|
|
11070
|
+
reportId: `${activityPrefix}:model-${++activitySequence}`,
|
|
11071
|
+
change: { kind: "model", model: effectiveModelId, thinking: effectiveThinking }
|
|
11072
|
+
});
|
|
11073
|
+
reportModel();
|
|
11031
11074
|
unsubscribe = session.subscribe((event) => {
|
|
11032
11075
|
writeEvent(admitted.spec.artifactJsonlPath, event);
|
|
11076
|
+
if (event.type === "message_start" && event.message.role === "assistant")
|
|
11077
|
+
observedStreamingMessage = beginStreamingAssistantMessage(event.message);
|
|
11078
|
+
else if (event.type === "message_update" && observedStreamingMessage)
|
|
11079
|
+
applyAssistantMessageDelta(observedStreamingMessage, event.assistantMessageEvent);
|
|
11080
|
+
else if (event.type === "message_end" && event.message.role === "assistant")
|
|
11081
|
+
observedStreamingMessage = undefined;
|
|
11033
11082
|
const emission = progressEmissionFor(event.type);
|
|
11083
|
+
if (event.type === "tool_execution_start") {
|
|
11084
|
+
taskHooks?.reportActivity({
|
|
11085
|
+
reportId: `${activityPrefix}:tool-${++activitySequence}`,
|
|
11086
|
+
change: { kind: "action", tool: event.toolName, text: safeArgsPreview(event.args) }
|
|
11087
|
+
});
|
|
11088
|
+
}
|
|
11034
11089
|
if (event.type === "agent_start") {
|
|
11035
11090
|
this.native.publishChildStatus(admitted.identity.path, nativeStatus("running"));
|
|
11036
11091
|
} else if (event.type === "tool_execution_start") {
|
|
@@ -11068,10 +11123,13 @@ class SubagentControlRuntime {
|
|
|
11068
11123
|
effectiveModelId = event.to;
|
|
11069
11124
|
progressState.model = event.to;
|
|
11070
11125
|
onModelChange?.(effectiveModelId, effectiveThinking);
|
|
11126
|
+
reportModel();
|
|
11127
|
+
emitProgress(true);
|
|
11071
11128
|
} else if (event.type === "thinking_level_changed") {
|
|
11072
11129
|
effectiveThinking = event.level;
|
|
11073
11130
|
progressState.thinking = effectiveThinking;
|
|
11074
11131
|
onModelChange?.(effectiveModelId, effectiveThinking);
|
|
11132
|
+
reportModel();
|
|
11075
11133
|
emitProgress(true);
|
|
11076
11134
|
}
|
|
11077
11135
|
});
|
|
@@ -11160,6 +11218,7 @@ class SubagentControlRuntime {
|
|
|
11160
11218
|
...skillReport
|
|
11161
11219
|
};
|
|
11162
11220
|
} finally {
|
|
11221
|
+
executionEnded.abort();
|
|
11163
11222
|
signals.abort.removeEventListener("abort", abortListener);
|
|
11164
11223
|
signals.interrupt.removeEventListener("abort", interruptListener);
|
|
11165
11224
|
try {
|
|
@@ -11168,16 +11227,36 @@ class SubagentControlRuntime {
|
|
|
11168
11227
|
try {
|
|
11169
11228
|
activeSessionManager?.flush();
|
|
11170
11229
|
} catch {}
|
|
11171
|
-
|
|
11172
|
-
|
|
11173
|
-
|
|
11230
|
+
if (onCleanup) {
|
|
11231
|
+
onCleanup((async () => {
|
|
11232
|
+
try {
|
|
11233
|
+
await session?.dispose();
|
|
11234
|
+
return { kind: "reaped" };
|
|
11235
|
+
} catch (error) {
|
|
11236
|
+
return {
|
|
11237
|
+
kind: "failed",
|
|
11238
|
+
resources: [
|
|
11239
|
+
{
|
|
11240
|
+
resource: "agent-session",
|
|
11241
|
+
code: "CleanupFailed",
|
|
11242
|
+
message: error instanceof Error ? error.message : String(error)
|
|
11243
|
+
}
|
|
11244
|
+
]
|
|
11245
|
+
};
|
|
11246
|
+
}
|
|
11247
|
+
})());
|
|
11248
|
+
} else {
|
|
11249
|
+
try {
|
|
11250
|
+
session?.dispose();
|
|
11251
|
+
} catch {}
|
|
11252
|
+
}
|
|
11174
11253
|
if (this.attemptTokens.get(admitted.identity.path) === token)
|
|
11175
11254
|
this.attemptTokens.delete(admitted.identity.path);
|
|
11176
11255
|
if (this.attemptTerminators.get(admitted.identity.path) === terminate)
|
|
11177
11256
|
this.attemptTerminators.delete(admitted.identity.path);
|
|
11178
11257
|
}
|
|
11179
11258
|
}
|
|
11180
|
-
startAttempt(admitted, candidate, signals) {
|
|
11259
|
+
startAttempt(admitted, candidate, signals, taskHooks) {
|
|
11181
11260
|
const initialModel = modelIdForCandidate(candidate, admitted.policy.model);
|
|
11182
11261
|
const initialThinking = initialThinkingForAttempt(initialModel, candidate.thinkingLevel ?? admitted.policy.thinkingLevel);
|
|
11183
11262
|
const running = {
|
|
@@ -11196,19 +11275,26 @@ class SubagentControlRuntime {
|
|
|
11196
11275
|
envelope: "uninitialized"
|
|
11197
11276
|
})
|
|
11198
11277
|
};
|
|
11278
|
+
let cleanup = Promise.resolve({ kind: "reaped" });
|
|
11199
11279
|
running.promise = this.runChildAttempt(admitted, candidate, signals, (model, thinking) => {
|
|
11200
11280
|
running.currentModel = model;
|
|
11201
11281
|
running.currentThinking = thinking;
|
|
11202
|
-
}
|
|
11203
|
-
|
|
11282
|
+
}, taskHooks, taskHooks ? (result) => {
|
|
11283
|
+
cleanup = result;
|
|
11284
|
+
} : undefined).then((result) => {
|
|
11285
|
+
running.status = result.status;
|
|
11204
11286
|
this.runningAttempts.delete(running.id);
|
|
11205
|
-
return
|
|
11287
|
+
return result;
|
|
11206
11288
|
});
|
|
11207
11289
|
running.terminate = (cause) => this.terminateRunningAttempt(running, cause);
|
|
11208
11290
|
running.promise.catch(() => {
|
|
11209
11291
|
return;
|
|
11210
11292
|
});
|
|
11211
11293
|
this.runningAttempts.set(running.id, running);
|
|
11294
|
+
taskHooks?.onExecution({
|
|
11295
|
+
result: running.promise,
|
|
11296
|
+
cleanup: running.promise.then(() => cleanup, () => cleanup)
|
|
11297
|
+
});
|
|
11212
11298
|
return running;
|
|
11213
11299
|
}
|
|
11214
11300
|
continueDetached(running, _reason) {
|
|
@@ -11349,6 +11435,21 @@ function childLines(control, id) {
|
|
|
11349
11435
|
}
|
|
11350
11436
|
return control.listChildren().map((child) => `${child.path} — ${child.status} (${child.loaded ? "loaded" : "cold"})`);
|
|
11351
11437
|
}
|
|
11438
|
+
function statusGroup(control, id) {
|
|
11439
|
+
return {
|
|
11440
|
+
parentPath: control.parent.path,
|
|
11441
|
+
children: canonicalChildren(control).filter((child) => !id || id === control.parent.path || child.path === id).map((child) => {
|
|
11442
|
+
const delivered = control.getDeliveredResult(child.path);
|
|
11443
|
+
const metadata = control.getChildMetadata(child.path) ?? delivered;
|
|
11444
|
+
return {
|
|
11445
|
+
...child,
|
|
11446
|
+
sessionFile: delivered?.sessionFile,
|
|
11447
|
+
...metadata?.model === undefined ? {} : { model: metadata.model },
|
|
11448
|
+
...metadata?.thinking === undefined ? {} : { thinking: metadata.thinking }
|
|
11449
|
+
};
|
|
11450
|
+
})
|
|
11451
|
+
};
|
|
11452
|
+
}
|
|
11352
11453
|
function inspectInProcessChildStatus(id) {
|
|
11353
11454
|
if (id) {
|
|
11354
11455
|
const control = findSubagentControl(id);
|
|
@@ -11361,19 +11462,17 @@ function inspectInProcessChildStatus(id) {
|
|
|
11361
11462
|
return;
|
|
11362
11463
|
return {
|
|
11363
11464
|
content: [{ type: "text", text }],
|
|
11364
|
-
details: { mode: "management", results: [] }
|
|
11465
|
+
details: { mode: "management", results: [], statusGroups: [statusGroup(control, id)] }
|
|
11365
11466
|
};
|
|
11366
11467
|
}
|
|
11367
|
-
const
|
|
11368
|
-
|
|
11369
|
-
...childLines(control)
|
|
11370
|
-
]);
|
|
11468
|
+
const controls = listSubagentControls();
|
|
11469
|
+
const lines = controls.flatMap((control) => [`Parent: ${control.parent.path}`, ...childLines(control)]);
|
|
11371
11470
|
if (lines.length === 0)
|
|
11372
11471
|
return;
|
|
11373
11472
|
return {
|
|
11374
11473
|
content: [{ type: "text", text: lines.join(`
|
|
11375
11474
|
`) }],
|
|
11376
|
-
details: { mode: "management", results: [] }
|
|
11475
|
+
details: { mode: "management", results: [], statusGroups: controls.map((control) => statusGroup(control)) }
|
|
11377
11476
|
};
|
|
11378
11477
|
}
|
|
11379
11478
|
async function interruptInProcessChild(id) {
|
|
@@ -11481,8 +11580,8 @@ function registerBurstDisplay(callIds, taskCount) {
|
|
|
11481
11580
|
}
|
|
11482
11581
|
return display;
|
|
11483
11582
|
}
|
|
11484
|
-
function updateBurstDisplay(display,
|
|
11485
|
-
display.result =
|
|
11583
|
+
function updateBurstDisplay(display, result) {
|
|
11584
|
+
display.result = result;
|
|
11486
11585
|
}
|
|
11487
11586
|
function getBurstDisplay(callId) {
|
|
11488
11587
|
const display = displayByCallId.get(callId);
|
|
@@ -11503,20 +11602,17 @@ function resolveRequestedCwd(runtimeCwd, requestedCwd) {
|
|
|
11503
11602
|
|
|
11504
11603
|
// dist/builtin/subagents/src/runs/foreground/subagent-executor-live-update.ts
|
|
11505
11604
|
var liveResultIndices = new WeakMap;
|
|
11506
|
-
function markLiveResultIndices(
|
|
11507
|
-
liveResultIndices.set(
|
|
11605
|
+
function markLiveResultIndices(result, indices) {
|
|
11606
|
+
liveResultIndices.set(result, indices);
|
|
11508
11607
|
}
|
|
11509
|
-
function getLiveResultIndices(
|
|
11510
|
-
return liveResultIndices.get(
|
|
11608
|
+
function getLiveResultIndices(result) {
|
|
11609
|
+
return liveResultIndices.get(result);
|
|
11511
11610
|
}
|
|
11512
11611
|
|
|
11513
11612
|
// dist/builtin/subagents/src/runs/foreground/subagent-executor-parent-ask-projection.ts
|
|
11514
11613
|
var parentAskHandoffs = new WeakMap;
|
|
11515
|
-
function
|
|
11516
|
-
parentAskHandoffs.
|
|
11517
|
-
}
|
|
11518
|
-
function getParentAskHandoff(result2) {
|
|
11519
|
-
return parentAskHandoffs.get(result2);
|
|
11614
|
+
function getParentAskHandoff(result) {
|
|
11615
|
+
return parentAskHandoffs.get(result);
|
|
11520
11616
|
}
|
|
11521
11617
|
|
|
11522
11618
|
// dist/builtin/subagents/src/runs/foreground/subagent-executor-types.ts
|
|
@@ -11656,11 +11752,11 @@ function formatStandardParallelContent(results) {
|
|
|
11656
11752
|
error: child.error
|
|
11657
11753
|
})), (index, agent) => `=== Task ${index + 1}: ${agent} ===`);
|
|
11658
11754
|
}
|
|
11659
|
-
function projectParentAskContent(
|
|
11660
|
-
const handoff = getParentAskHandoff(
|
|
11755
|
+
function projectParentAskContent(result, route, projectedResults) {
|
|
11756
|
+
const handoff = getParentAskHandoff(result);
|
|
11661
11757
|
if (!handoff)
|
|
11662
11758
|
return;
|
|
11663
|
-
const originalItem =
|
|
11759
|
+
const originalItem = result.content.length === 1 && result.content[0]?.type === "text" ? result.content[0] : { type: "text", text: "" };
|
|
11664
11760
|
const routeEnd = route.start + route.length;
|
|
11665
11761
|
const inRoute = (index) => index >= route.start && index < routeEnd;
|
|
11666
11762
|
if (!inRoute(handoff.askingChildIndex)) {
|
|
@@ -11680,16 +11776,16 @@ function projectParentAskContent(result2, route, projectedResults) {
|
|
|
11680
11776
|
}
|
|
11681
11777
|
];
|
|
11682
11778
|
}
|
|
11683
|
-
function projectParallelContent(
|
|
11779
|
+
function projectParallelContent(result, sharedResults, projectedResults, route, live) {
|
|
11684
11780
|
const projectedText = formatStandardParallelContent(projectedResults);
|
|
11685
11781
|
if (live)
|
|
11686
11782
|
return [{ type: "text", text: projectedText }];
|
|
11687
|
-
const parentAskContent = projectParentAskContent(
|
|
11783
|
+
const parentAskContent = projectParentAskContent(result, route, projectedResults);
|
|
11688
11784
|
if (parentAskContent)
|
|
11689
11785
|
return parentAskContent;
|
|
11690
|
-
if (
|
|
11691
|
-
return
|
|
11692
|
-
const originalItem =
|
|
11786
|
+
if (result.content.length !== 1 || result.content[0]?.type !== "text")
|
|
11787
|
+
return result.content;
|
|
11788
|
+
const originalItem = result.content[0];
|
|
11693
11789
|
const originalText = originalItem.text;
|
|
11694
11790
|
const sharedText = formatStandardParallelContent(sharedResults);
|
|
11695
11791
|
if (originalText === sharedText)
|
|
@@ -11699,13 +11795,13 @@ function projectParallelContent(result2, sharedResults, projectedResults, route,
|
|
|
11699
11795
|
`)) {
|
|
11700
11796
|
return [{ ...originalItem, text: `${projectedText}${originalText.slice(sharedText.length)}` }];
|
|
11701
11797
|
}
|
|
11702
|
-
return
|
|
11798
|
+
return result.content;
|
|
11703
11799
|
}
|
|
11704
|
-
function projectResult(
|
|
11705
|
-
const sharedDetails =
|
|
11800
|
+
function projectResult(result, route, live = false) {
|
|
11801
|
+
const sharedDetails = result.details;
|
|
11706
11802
|
if (!sharedDetails || !live && sharedDetails.results.length === 0)
|
|
11707
|
-
return
|
|
11708
|
-
const liveIndices = live ? getLiveResultIndices(
|
|
11803
|
+
return result;
|
|
11804
|
+
const liveIndices = live ? getLiveResultIndices(result) : undefined;
|
|
11709
11805
|
const results = liveIndices ? sharedDetails.results.filter((_child, index) => {
|
|
11710
11806
|
const resultIndex = liveIndices[index];
|
|
11711
11807
|
return resultIndex !== undefined && resultIndex >= route.start && resultIndex < route.start + route.length;
|
|
@@ -11714,8 +11810,8 @@ function projectResult(result2, route, live = false) {
|
|
|
11714
11810
|
const controlEvents = sharedDetails.controlEvents?.filter((event) => event.index !== undefined && event.index >= route.start && event.index < route.start + route.length).map((event) => ({ ...event, index: event.index - route.start }));
|
|
11715
11811
|
const artifactFiles = results.flatMap((child) => child.artifactPaths ? [child.artifactPaths] : []);
|
|
11716
11812
|
return {
|
|
11717
|
-
content: projectParallelContent(
|
|
11718
|
-
...
|
|
11813
|
+
content: projectParallelContent(result, sharedDetails.results, results, route, live),
|
|
11814
|
+
...result.isError !== undefined ? { isError: result.isError } : {},
|
|
11719
11815
|
details: {
|
|
11720
11816
|
mode: "parallel",
|
|
11721
11817
|
...sharedDetails.runId !== undefined ? { runId: sharedDetails.runId } : {},
|
|
@@ -11729,11 +11825,11 @@ function projectResult(result2, route, live = false) {
|
|
|
11729
11825
|
}
|
|
11730
11826
|
};
|
|
11731
11827
|
}
|
|
11732
|
-
function resolveItem(item,
|
|
11828
|
+
function resolveItem(item, result) {
|
|
11733
11829
|
if (item.settled)
|
|
11734
11830
|
return;
|
|
11735
11831
|
item.settled = true;
|
|
11736
|
-
item.resolve(
|
|
11832
|
+
item.resolve(result);
|
|
11737
11833
|
}
|
|
11738
11834
|
function rejectItem(item, reason) {
|
|
11739
11835
|
if (item.settled)
|
|
@@ -11804,10 +11900,10 @@ function createExecutionBurstDispatcher(input) {
|
|
|
11804
11900
|
};
|
|
11805
11901
|
input.setActive(true);
|
|
11806
11902
|
try {
|
|
11807
|
-
const
|
|
11808
|
-
updateBurstDisplay(display,
|
|
11903
|
+
const result = await input.execute(first.id, merged.params, first.signal, onUpdate, first.ctx);
|
|
11904
|
+
updateBurstDisplay(display, result);
|
|
11809
11905
|
for (let index = 0;index < items.length; index++) {
|
|
11810
|
-
resolveItem(items[index], projectResult(
|
|
11906
|
+
resolveItem(items[index], projectResult(result, merged.routes[index]));
|
|
11811
11907
|
}
|
|
11812
11908
|
} catch (error) {
|
|
11813
11909
|
const rejection = error instanceof Error ? error : new Error(String(error));
|
|
@@ -11827,8 +11923,8 @@ function createExecutionBurstDispatcher(input) {
|
|
|
11827
11923
|
return (id, params, signal, onUpdate, ctx) => {
|
|
11828
11924
|
if (input.isActive())
|
|
11829
11925
|
return Promise.resolve(input.duplicateResult(params));
|
|
11830
|
-
return new Promise((
|
|
11831
|
-
queue.push({ id, params, signal, onUpdate, ctx, settled: false, resolve
|
|
11926
|
+
return new Promise((resolve, reject) => {
|
|
11927
|
+
queue.push({ id, params, signal, onUpdate, ctx, settled: false, resolve, reject });
|
|
11832
11928
|
if (!flushScheduled) {
|
|
11833
11929
|
flushScheduled = true;
|
|
11834
11930
|
setImmediate(flush);
|
|
@@ -11838,7 +11934,7 @@ function createExecutionBurstDispatcher(input) {
|
|
|
11838
11934
|
}
|
|
11839
11935
|
|
|
11840
11936
|
// dist/builtin/subagents/src/runs/foreground/subagent-executor-context.ts
|
|
11841
|
-
import { randomUUID } from "node:crypto";
|
|
11937
|
+
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
11842
11938
|
import * as fs13 from "node:fs";
|
|
11843
11939
|
import * as path13 from "node:path";
|
|
11844
11940
|
|
|
@@ -12081,13 +12177,13 @@ function normalizeRepeatedParallelCounts(params) {
|
|
|
12081
12177
|
return { error: buildRequestedModeError(params, expandedTasks.error) };
|
|
12082
12178
|
return { params: { ...params, tasks: expandedTasks.tasks } };
|
|
12083
12179
|
}
|
|
12084
|
-
function withForkContext(
|
|
12085
|
-
if (context !== "fork" || !
|
|
12086
|
-
return
|
|
12180
|
+
function withForkContext(result, context) {
|
|
12181
|
+
if (context !== "fork" || !result.details)
|
|
12182
|
+
return result;
|
|
12087
12183
|
return {
|
|
12088
|
-
...
|
|
12184
|
+
...result,
|
|
12089
12185
|
details: {
|
|
12090
|
-
...
|
|
12186
|
+
...result.details,
|
|
12091
12187
|
context: "fork"
|
|
12092
12188
|
}
|
|
12093
12189
|
};
|
|
@@ -12166,7 +12262,7 @@ function prepareExecutionContext(input) {
|
|
|
12166
12262
|
});
|
|
12167
12263
|
const agents = intercomBridge.active ? discoveredAgents.map((agent) => applyIntercomBridgeToAgent(agent, intercomBridge)) : discoveredAgents;
|
|
12168
12264
|
const parallelAgentConfigs = intercomBridge.active ? resolvedTaskAgents?.map((agent) => applyIntercomBridgeToAgent(agent, intercomBridge)) : resolvedTaskAgents;
|
|
12169
|
-
const runId =
|
|
12265
|
+
const runId = randomUUID2().slice(0, 8);
|
|
12170
12266
|
const shareEnabled = effectiveParams.share === true;
|
|
12171
12267
|
const hasTasks = (effectiveParams.tasks?.length ?? 0) > 0;
|
|
12172
12268
|
const hasSingle = !hasTasks && Boolean(effectiveParams.agent);
|
|
@@ -12272,10 +12368,10 @@ function resolveCandidateModel(candidateId, lookup, preferredProvider) {
|
|
|
12272
12368
|
const slash = baseModel.indexOf("/");
|
|
12273
12369
|
if (slash < 0) {
|
|
12274
12370
|
const available = lookup.getAvailable().filter((entry) => entry.id === baseModel);
|
|
12275
|
-
const
|
|
12276
|
-
if (!
|
|
12371
|
+
const model = available.find((entry) => entry.provider === preferredProvider) ?? (available.length === 1 ? available[0] : undefined);
|
|
12372
|
+
if (!model)
|
|
12277
12373
|
return;
|
|
12278
|
-
return thinkingLevel === undefined ? { model
|
|
12374
|
+
return thinkingLevel === undefined ? { model } : { model, thinkingLevel };
|
|
12279
12375
|
}
|
|
12280
12376
|
const provider = baseModel.slice(0, slash);
|
|
12281
12377
|
const modelId = baseModel.slice(slash + 1);
|
|
@@ -12289,7 +12385,7 @@ function createCandidateModelResolver(lookup, preferredProvider) {
|
|
|
12289
12385
|
}
|
|
12290
12386
|
|
|
12291
12387
|
// dist/builtin/subagents/src/runs/shared/intercom-group.ts
|
|
12292
|
-
import { randomUUID as
|
|
12388
|
+
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
12293
12389
|
import { readRuntimeIntercomGroup } from "@bastani/atomic";
|
|
12294
12390
|
function normalizeAutoGroupSentinel(group) {
|
|
12295
12391
|
if (group === undefined || group === true)
|
|
@@ -12313,14 +12409,14 @@ function inheritedIntercomGroup(ctx) {
|
|
|
12313
12409
|
function resolveChildIntercomGroup(explicit, inherited, sharedAutoGroup) {
|
|
12314
12410
|
const normalized = normalizeAutoGroupSentinel(explicit);
|
|
12315
12411
|
if (normalized === true)
|
|
12316
|
-
return sharedAutoGroup ??
|
|
12412
|
+
return sharedAutoGroup ?? randomUUID3();
|
|
12317
12413
|
if (typeof normalized === "string" && normalized.trim().length > 0)
|
|
12318
12414
|
return normalized.trim();
|
|
12319
12415
|
return inherited;
|
|
12320
12416
|
}
|
|
12321
12417
|
function sharedAutoGroupForSet(setGroup, items) {
|
|
12322
12418
|
const needsAuto = normalizeAutoGroupSentinel(setGroup) === true || items.some((item) => normalizeAutoGroupSentinel(item.group) === true);
|
|
12323
|
-
return needsAuto ?
|
|
12419
|
+
return needsAuto ? randomUUID3() : undefined;
|
|
12324
12420
|
}
|
|
12325
12421
|
|
|
12326
12422
|
// dist/builtin/subagents/src/runs/shared/model-fallback.ts
|
|
@@ -12499,8 +12595,8 @@ function hasTrackedPathComponent(runGit, repo, relativePath) {
|
|
|
12499
12595
|
let candidate = "";
|
|
12500
12596
|
for (const component of components) {
|
|
12501
12597
|
candidate = candidate ? `${candidate}/${component}` : component;
|
|
12502
|
-
const
|
|
12503
|
-
if (
|
|
12598
|
+
const result = runGit(repo, ["ls-files", "--stage", "--", candidate]);
|
|
12599
|
+
if (result.stdout.split(/\r?\n/).some((line) => line.slice(line.indexOf("\t") + 1) === candidate))
|
|
12504
12600
|
return true;
|
|
12505
12601
|
}
|
|
12506
12602
|
return false;
|
|
@@ -12533,9 +12629,9 @@ function configureHooks(runGit, mainRoot) {
|
|
|
12533
12629
|
const current = runGit(mainRoot, ["config", "--get", "core.hooksPath"]);
|
|
12534
12630
|
if (current.status === 0 && path16.resolve(mainRoot, current.stdout.trim()) === desired)
|
|
12535
12631
|
return;
|
|
12536
|
-
const
|
|
12537
|
-
if (
|
|
12538
|
-
throw new Error(
|
|
12632
|
+
const result = runGit(mainRoot, ["config", "core.hooksPath", desired]);
|
|
12633
|
+
if (result.status !== 0)
|
|
12634
|
+
throw new Error(result.stderr.trim() || "failed to configure shared core.hooksPath");
|
|
12539
12635
|
}
|
|
12540
12636
|
function copyIncludes(runGit, mainRoot, worktreeRoot) {
|
|
12541
12637
|
if (!fs15.existsSync(path16.join(mainRoot, ".worktreeinclude")))
|
|
@@ -12659,24 +12755,24 @@ function findCanonicalGitRoot(cwd) {
|
|
|
12659
12755
|
// dist/builtin/subagents/src/runs/shared/worktree.ts
|
|
12660
12756
|
var DEFAULT_WORKTREE_SETUP_HOOK_TIMEOUT_MS = 30000;
|
|
12661
12757
|
function runGit(cwd, args) {
|
|
12662
|
-
const
|
|
12758
|
+
const result = spawnSync("git", ["-C", cwd, ...args], {
|
|
12663
12759
|
encoding: "utf-8",
|
|
12664
12760
|
env: createGitEnvironment({}, createChildProcessEnvironment3())
|
|
12665
12761
|
});
|
|
12666
12762
|
return {
|
|
12667
|
-
stdout:
|
|
12668
|
-
stderr:
|
|
12669
|
-
status:
|
|
12763
|
+
stdout: result.stdout ?? "",
|
|
12764
|
+
stderr: result.stderr ?? "",
|
|
12765
|
+
status: result.status
|
|
12670
12766
|
};
|
|
12671
12767
|
}
|
|
12672
12768
|
function runGitChecked(cwd, args) {
|
|
12673
|
-
const
|
|
12674
|
-
if (
|
|
12769
|
+
const result = runGit(cwd, args);
|
|
12770
|
+
if (result.status !== 0) {
|
|
12675
12771
|
const command = `git -C ${cwd} ${args.join(" ")}`;
|
|
12676
|
-
const message =
|
|
12772
|
+
const message = result.stderr.trim() || result.stdout.trim() || `${command} failed`;
|
|
12677
12773
|
throw new Error(message);
|
|
12678
12774
|
}
|
|
12679
|
-
return
|
|
12775
|
+
return result.stdout;
|
|
12680
12776
|
}
|
|
12681
12777
|
function originDefaultBranch(mainRoot) {
|
|
12682
12778
|
const symbolic = runGit(mainRoot, ["symbolic-ref", "--short", "refs/remotes/origin/HEAD"]);
|
|
@@ -12798,18 +12894,18 @@ function normalizeSyntheticPath(worktreePath, rawPath) {
|
|
|
12798
12894
|
if (path18.isAbsolute(trimmed))
|
|
12799
12895
|
throw new Error(`synthetic path must be relative: ${rawPath}`);
|
|
12800
12896
|
const resolved = path18.resolve(worktreePath, trimmed);
|
|
12801
|
-
const
|
|
12802
|
-
if (!
|
|
12897
|
+
const relative = path18.relative(worktreePath, resolved);
|
|
12898
|
+
if (!relative || relative === ".") {
|
|
12803
12899
|
throw new Error(`synthetic path cannot target the worktree root: ${rawPath}`);
|
|
12804
12900
|
}
|
|
12805
|
-
if (
|
|
12901
|
+
if (relative === ".." || relative.startsWith(`..${path18.sep}`) || path18.isAbsolute(relative)) {
|
|
12806
12902
|
throw new Error(`synthetic path escapes the worktree root: ${rawPath}`);
|
|
12807
12903
|
}
|
|
12808
|
-
return path18.normalize(
|
|
12904
|
+
return path18.normalize(relative);
|
|
12809
12905
|
}
|
|
12810
12906
|
function hasTrackedEntries(worktreePath, relativePath) {
|
|
12811
|
-
const
|
|
12812
|
-
return
|
|
12907
|
+
const result = runGit(worktreePath, ["ls-files", "--", relativePath]);
|
|
12908
|
+
return result.status === 0 && result.stdout.trim().length > 0;
|
|
12813
12909
|
}
|
|
12814
12910
|
function parseWorktreeSetupHookOutput(rawStdout) {
|
|
12815
12911
|
const trimmed = rawStdout.trim();
|
|
@@ -12832,7 +12928,7 @@ function isSpuriousHookStdinWriteFailure(code, status) {
|
|
|
12832
12928
|
return code === "EPIPE" && status !== null;
|
|
12833
12929
|
}
|
|
12834
12930
|
function runWorktreeSetupHook(hook, input) {
|
|
12835
|
-
const
|
|
12931
|
+
const result = spawnSync(hook.hookPath, [], {
|
|
12836
12932
|
cwd: input.worktreePath,
|
|
12837
12933
|
encoding: "utf-8",
|
|
12838
12934
|
input: JSON.stringify(input),
|
|
@@ -12840,20 +12936,20 @@ function runWorktreeSetupHook(hook, input) {
|
|
|
12840
12936
|
timeout: hook.timeoutMs,
|
|
12841
12937
|
shell: false
|
|
12842
12938
|
});
|
|
12843
|
-
if (
|
|
12844
|
-
const code = "code" in
|
|
12939
|
+
if (result.error) {
|
|
12940
|
+
const code = "code" in result.error && typeof result.error.code === "string" ? result.error.code : undefined;
|
|
12845
12941
|
if (code === "ETIMEDOUT") {
|
|
12846
12942
|
throw new Error(`worktree setup hook timed out after ${hook.timeoutMs}ms`);
|
|
12847
12943
|
}
|
|
12848
|
-
if (!isSpuriousHookStdinWriteFailure(code,
|
|
12849
|
-
throw new Error(`worktree setup hook failed: ${
|
|
12944
|
+
if (!isSpuriousHookStdinWriteFailure(code, result.status)) {
|
|
12945
|
+
throw new Error(`worktree setup hook failed: ${result.error.message}`);
|
|
12850
12946
|
}
|
|
12851
12947
|
}
|
|
12852
|
-
if (
|
|
12853
|
-
const details =
|
|
12854
|
-
throw new Error(`worktree setup hook failed with exit code ${
|
|
12948
|
+
if (result.status !== 0) {
|
|
12949
|
+
const details = result.stderr.trim() || result.stdout.trim() || "no output";
|
|
12950
|
+
throw new Error(`worktree setup hook failed with exit code ${result.status}: ${details}`);
|
|
12855
12951
|
}
|
|
12856
|
-
const output = parseWorktreeSetupHookOutput(
|
|
12952
|
+
const output = parseWorktreeSetupHookOutput(result.stdout);
|
|
12857
12953
|
if (output.syntheticPaths === undefined)
|
|
12858
12954
|
return [];
|
|
12859
12955
|
if (!Array.isArray(output.syntheticPaths)) {
|
|
@@ -12924,8 +13020,8 @@ function createSingleWorktree(mainRoot, cwdRelative, runId, index, baseRef, base
|
|
|
12924
13020
|
}
|
|
12925
13021
|
function removeSyntheticPath(worktree, syntheticPath) {
|
|
12926
13022
|
const resolved = path18.resolve(worktree.path, syntheticPath);
|
|
12927
|
-
const
|
|
12928
|
-
if (!
|
|
13023
|
+
const relative = path18.relative(worktree.path, resolved);
|
|
13024
|
+
if (!relative || relative === "." || relative === ".." || relative.startsWith(`..${path18.sep}`) || path18.isAbsolute(relative)) {
|
|
12929
13025
|
return;
|
|
12930
13026
|
}
|
|
12931
13027
|
let stat;
|
|
@@ -13187,29 +13283,205 @@ function findDuplicateParallelOutputPath(input) {
|
|
|
13187
13283
|
return;
|
|
13188
13284
|
}
|
|
13189
13285
|
|
|
13190
|
-
// dist/builtin/subagents/src/runs/foreground/
|
|
13191
|
-
function
|
|
13286
|
+
// dist/builtin/subagents/src/runs/foreground/task-execution.ts
|
|
13287
|
+
function taskToolResult(response, host) {
|
|
13192
13288
|
return {
|
|
13193
|
-
|
|
13194
|
-
|
|
13195
|
-
|
|
13196
|
-
|
|
13197
|
-
|
|
13198
|
-
|
|
13289
|
+
content: [{ type: "text", text: JSON.stringify(response) }],
|
|
13290
|
+
details: {
|
|
13291
|
+
mode: "single",
|
|
13292
|
+
results: [],
|
|
13293
|
+
taskResponse: response,
|
|
13294
|
+
taskRecords: taskResponseRecords(response, host)
|
|
13295
|
+
},
|
|
13296
|
+
...response.kind === "unstarted" ? { isError: true } : {}
|
|
13297
|
+
};
|
|
13298
|
+
}
|
|
13299
|
+
function taskResponseRecords(response, host) {
|
|
13300
|
+
const outcomes = response.kind === "parallel" ? response.slots.map((slot) => slot.outcome) : [response];
|
|
13301
|
+
const ids = new Set(outcomes.flatMap((outcome) => outcome.kind === "admitted" ? [outcome.observation.taskId] : []));
|
|
13302
|
+
const watched = host?.watchOwnerTasks();
|
|
13303
|
+
if (!watched?.ok)
|
|
13304
|
+
return [];
|
|
13305
|
+
try {
|
|
13306
|
+
return watched.value.snapshot.tasks.filter((task) => ids.has(task.ref.taskId));
|
|
13307
|
+
} finally {
|
|
13308
|
+
watched.value.dispose();
|
|
13309
|
+
}
|
|
13310
|
+
}
|
|
13311
|
+
async function runAgentTask(input) {
|
|
13312
|
+
let yieldWait;
|
|
13313
|
+
let pendingYield = false;
|
|
13314
|
+
const registered = Promise.withResolvers();
|
|
13315
|
+
const started = await input.host.startAgentTask({ kind: "agent", agent: input.agent, task: input.intentTask ?? input.task, cwd: input.options.cwd ?? input.cwd }, `${input.options.runId}:${input.options.index ?? 0}`, (context) => {
|
|
13316
|
+
const cleaned = Promise.withResolvers();
|
|
13317
|
+
let executionBound = false;
|
|
13318
|
+
const result = registered.promise.then(async () => {
|
|
13319
|
+
try {
|
|
13320
|
+
const child = await input.runtime.runSync(input.cwd, input.agents, input.agent, input.task, {
|
|
13321
|
+
...input.options,
|
|
13322
|
+
signal: context.signal,
|
|
13323
|
+
taskExecution: {
|
|
13324
|
+
signal: context.signal,
|
|
13325
|
+
reportActivity: context.reportActivity,
|
|
13326
|
+
bindTranscript: (session) => context.bindTranscript({
|
|
13327
|
+
getSessionId: () => session.getSessionId(),
|
|
13328
|
+
getEntries: () => session.getEntries(),
|
|
13329
|
+
...session.subscribe ? { subscribe: session.subscribe.bind(session) } : {},
|
|
13330
|
+
...session.getStreamingMessage ? { getStreamingMessage: session.getStreamingMessage.bind(session) } : {},
|
|
13331
|
+
...input.options.intercomSessionName ? {
|
|
13332
|
+
completionSource: {
|
|
13333
|
+
runId: input.options.runId,
|
|
13334
|
+
intercomTarget: input.options.intercomSessionName
|
|
13335
|
+
}
|
|
13336
|
+
} : {}
|
|
13337
|
+
}),
|
|
13338
|
+
onExecution: (execution) => {
|
|
13339
|
+
executionBound = true;
|
|
13340
|
+
execution.cleanup.then(cleaned.resolve, (error) => cleaned.resolve({
|
|
13341
|
+
kind: "failed",
|
|
13342
|
+
resources: [{ resource: "agent-session", code: "CleanupFailed", message: String(error) }]
|
|
13343
|
+
}));
|
|
13344
|
+
},
|
|
13345
|
+
yieldTaskWait: () => {
|
|
13346
|
+
if (yieldWait)
|
|
13347
|
+
yieldWait("intercom-coordination");
|
|
13348
|
+
else
|
|
13349
|
+
pendingYield = true;
|
|
13350
|
+
}
|
|
13351
|
+
}
|
|
13352
|
+
});
|
|
13353
|
+
if (child.model !== undefined || child.thinking !== undefined)
|
|
13354
|
+
context.reportActivity({
|
|
13355
|
+
reportId: "terminal-model",
|
|
13356
|
+
change: { kind: "model", model: child.model, thinking: child.thinking }
|
|
13357
|
+
});
|
|
13358
|
+
input.onTerminal?.(child);
|
|
13359
|
+
const text = input.outputText?.(child) ?? getSingleResultOutput(child);
|
|
13360
|
+
const bytes = Buffer.from(text);
|
|
13361
|
+
context.reportActivity({
|
|
13362
|
+
reportId: "terminal-output",
|
|
13363
|
+
change: { kind: "output", offset: "0", bytesBase64: bytes.toString("base64") }
|
|
13364
|
+
});
|
|
13365
|
+
const output = {
|
|
13366
|
+
ownerId: context.ref.ownerId,
|
|
13367
|
+
taskId: context.ref.taskId,
|
|
13368
|
+
artifactId: `output:${context.ref.taskId}`,
|
|
13369
|
+
byteCount: String(bytes.length),
|
|
13370
|
+
omittedRanges: []
|
|
13371
|
+
};
|
|
13372
|
+
if (child.interrupted)
|
|
13373
|
+
return {
|
|
13374
|
+
kind: "cancelled",
|
|
13375
|
+
cause: input.options.interruptSignal?.aborted ? "parent-handoff" : "owner-close",
|
|
13376
|
+
output
|
|
13377
|
+
};
|
|
13378
|
+
return child.status === "ok" ? { kind: "completed", output } : {
|
|
13379
|
+
kind: "failed",
|
|
13380
|
+
code: "AgentFailed",
|
|
13381
|
+
message: child.error ?? child.envelope ?? "Agent failed",
|
|
13382
|
+
output
|
|
13383
|
+
};
|
|
13384
|
+
} finally {
|
|
13385
|
+
if (!executionBound)
|
|
13386
|
+
cleaned.resolve({ kind: "reaped" });
|
|
13387
|
+
}
|
|
13388
|
+
});
|
|
13389
|
+
return { result, cleanup: cleaned.promise };
|
|
13390
|
+
}, input.schedule);
|
|
13391
|
+
if (!started.ok)
|
|
13392
|
+
return { kind: "unstarted", reason: { kind: "rejected", error: started.error } };
|
|
13393
|
+
const yieldForIntercom = () => {
|
|
13394
|
+
if (yieldWait)
|
|
13395
|
+
yieldWait("intercom-coordination");
|
|
13396
|
+
else
|
|
13397
|
+
pendingYield = true;
|
|
13199
13398
|
};
|
|
13399
|
+
input.options.intercomDetachSignal?.addEventListener("abort", yieldForIntercom, { once: true });
|
|
13400
|
+
if (input.options.intercomDetachSignal?.aborted)
|
|
13401
|
+
yieldForIntercom();
|
|
13402
|
+
const observation = input.host.observeAgentLaunch(started.value.taskId, input.wait, (yieldRegistered) => {
|
|
13403
|
+
yieldWait = yieldRegistered;
|
|
13404
|
+
if (pendingYield)
|
|
13405
|
+
yieldRegistered("intercom-coordination");
|
|
13406
|
+
registered.resolve();
|
|
13407
|
+
});
|
|
13408
|
+
registered.resolve();
|
|
13409
|
+
const observed = await observation.finally(() => input.options.intercomDetachSignal?.removeEventListener("abort", yieldForIntercom));
|
|
13410
|
+
if (!observed.ok)
|
|
13411
|
+
throw new Error(`${observed.error.code}: ${observed.error.message}`);
|
|
13412
|
+
return { kind: "admitted", observation: observed.value };
|
|
13413
|
+
}
|
|
13414
|
+
|
|
13415
|
+
// dist/builtin/subagents/src/runs/foreground/subagent-executor-parallel-task.ts
|
|
13416
|
+
function runUnboundParallelTask(options, agent, task, schedule, run) {
|
|
13417
|
+
const observed = Promise.withResolvers();
|
|
13418
|
+
const finished = Promise.withResolvers();
|
|
13419
|
+
let started = false;
|
|
13420
|
+
let yielded = false;
|
|
13421
|
+
const yieldQueued = () => {
|
|
13422
|
+
if (started)
|
|
13423
|
+
return;
|
|
13424
|
+
yielded = true;
|
|
13425
|
+
observed.resolve({
|
|
13426
|
+
agent,
|
|
13427
|
+
task,
|
|
13428
|
+
status: "continued",
|
|
13429
|
+
detached: true,
|
|
13430
|
+
detachedReason: "intercom-coordination",
|
|
13431
|
+
messages: [],
|
|
13432
|
+
usage: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, cost: 0, turns: 0 }
|
|
13433
|
+
});
|
|
13434
|
+
};
|
|
13435
|
+
options.intercomDetachSignal?.addEventListener("abort", yieldQueued, { once: true });
|
|
13436
|
+
schedule(async () => {
|
|
13437
|
+
started = true;
|
|
13438
|
+
try {
|
|
13439
|
+
const result = await run({
|
|
13440
|
+
...options,
|
|
13441
|
+
onDetachedExit: (result) => {
|
|
13442
|
+
try {
|
|
13443
|
+
options.onDetachedExit?.(result);
|
|
13444
|
+
} finally {
|
|
13445
|
+
finished.resolve();
|
|
13446
|
+
}
|
|
13447
|
+
}
|
|
13448
|
+
});
|
|
13449
|
+
observed.resolve(result);
|
|
13450
|
+
if (!result.detached) {
|
|
13451
|
+
finished.resolve();
|
|
13452
|
+
if (yielded)
|
|
13453
|
+
options.onDetachedExit?.(result);
|
|
13454
|
+
}
|
|
13455
|
+
await finished.promise;
|
|
13456
|
+
} catch (error) {
|
|
13457
|
+
observed.reject(error);
|
|
13458
|
+
}
|
|
13459
|
+
});
|
|
13460
|
+
if (options.intercomDetachSignal?.aborted)
|
|
13461
|
+
yieldQueued();
|
|
13462
|
+
return observed.promise.finally(() => options.intercomDetachSignal?.removeEventListener("abort", yieldQueued));
|
|
13200
13463
|
}
|
|
13201
13464
|
async function runForegroundParallelTasks(input) {
|
|
13202
13465
|
const intercomDetachController = new AbortController;
|
|
13203
|
-
const
|
|
13204
|
-
|
|
13205
|
-
const
|
|
13206
|
-
|
|
13207
|
-
|
|
13208
|
-
|
|
13209
|
-
|
|
13210
|
-
|
|
13211
|
-
|
|
13466
|
+
const host = input.ctx.getAgentTaskHost?.();
|
|
13467
|
+
let active = 0;
|
|
13468
|
+
const queued = [];
|
|
13469
|
+
const pump = () => {
|
|
13470
|
+
while (active < input.concurrencyLimit && queued.length > 0) {
|
|
13471
|
+
const dispatch = queued.shift();
|
|
13472
|
+
active++;
|
|
13473
|
+
const release = () => {
|
|
13474
|
+
active--;
|
|
13475
|
+
pump();
|
|
13476
|
+
};
|
|
13477
|
+
dispatch().then(release, release);
|
|
13212
13478
|
}
|
|
13479
|
+
};
|
|
13480
|
+
const schedule = (dispatch) => {
|
|
13481
|
+
queued.push(dispatch);
|
|
13482
|
+
pump();
|
|
13483
|
+
};
|
|
13484
|
+
return mapConcurrent(input.tasks, input.tasks.length, async (task, index) => {
|
|
13213
13485
|
const behavior = input.behaviors[index];
|
|
13214
13486
|
const effectiveSkills = behavior?.skills;
|
|
13215
13487
|
const taskCwd = resolveParallelTaskCwd(task, input.paramsCwd, input.worktreeSetup, index);
|
|
@@ -13219,19 +13491,7 @@ async function runForegroundParallelTasks(input) {
|
|
|
13219
13491
|
const taskText = injectSingleOutputInstruction(`${readInstructions.prefix}${input.taskTexts[index]}${progressInstructions.suffix}`, outputPath);
|
|
13220
13492
|
const childIntercomTarget = input.childIntercomTarget?.(task.agent, index);
|
|
13221
13493
|
const supervisorAuthorization = await requestSupervisorAuthorization(input.intercomEvents, childIntercomTarget);
|
|
13222
|
-
if (parentAskController.signal.aborted) {
|
|
13223
|
-
return skippedParallelResult(task, input.taskTexts[index] ?? task.task, "Skipped after parent ask handoff");
|
|
13224
|
-
}
|
|
13225
|
-
if (intercomDetachController.signal.aborted) {
|
|
13226
|
-
return skippedParallelResult(task, input.taskTexts[index] ?? task.task, "Skipped after foreground group detached for intercom coordination");
|
|
13227
|
-
}
|
|
13228
13494
|
const interruptController = new AbortController;
|
|
13229
|
-
const interruptForParentAsk = () => interruptController.abort();
|
|
13230
|
-
parentAskController.signal.addEventListener("abort", interruptForParentAsk, { once: true });
|
|
13231
|
-
if (parentAskController.signal.aborted)
|
|
13232
|
-
interruptController.abort();
|
|
13233
|
-
startedIndices.add(index);
|
|
13234
|
-
activeIndices.add(index);
|
|
13235
13495
|
if (input.foregroundControl) {
|
|
13236
13496
|
input.foregroundControl.currentAgent = task.agent;
|
|
13237
13497
|
input.foregroundControl.currentIndex = index;
|
|
@@ -13275,21 +13535,9 @@ async function runForegroundParallelTasks(input) {
|
|
|
13275
13535
|
supervisorAuthorization,
|
|
13276
13536
|
orchestratorIntercomTarget: input.orchestratorIntercomTarget,
|
|
13277
13537
|
intercomGroup: resolveChildIntercomGroup(task.group ?? input.setIntercomGroup, inheritedIntercomGroup(input.ctx), input.sharedAutoIntercomGroup),
|
|
13278
|
-
onDetachedExit: (
|
|
13538
|
+
onDetachedExit: (result) => input.onDetachedExit?.(index, result),
|
|
13279
13539
|
intercomDetachSignal: intercomDetachController.signal,
|
|
13280
13540
|
onIntercomDetachCommit: () => intercomDetachController.abort(),
|
|
13281
|
-
onParentAskHandoff: input.onParentAskHandoff ? (request) => {
|
|
13282
|
-
if (parentAskController.signal.aborted)
|
|
13283
|
-
return;
|
|
13284
|
-
request.taskContext = input.tasks[request.index]?.task ?? "";
|
|
13285
|
-
input.onParentAskHandoff?.({
|
|
13286
|
-
askingChildIndex: request.index,
|
|
13287
|
-
releasedChildIndices: [...activeIndices].sort((left, right) => left - right),
|
|
13288
|
-
unlaunchedChildIndices: input.tasks.map((_, taskIndex) => taskIndex).filter((taskIndex) => !startedIndices.has(taskIndex)),
|
|
13289
|
-
request
|
|
13290
|
-
});
|
|
13291
|
-
parentAskController.abort();
|
|
13292
|
-
} : undefined,
|
|
13293
13541
|
modelOverride: input.modelOverrides[index],
|
|
13294
13542
|
availableModels: input.availableModels,
|
|
13295
13543
|
knownModelProviders: input.knownModelProviders,
|
|
@@ -13319,12 +13567,12 @@ async function runForegroundParallelTasks(input) {
|
|
|
13319
13567
|
input.liveResults[index] = stepResults[0];
|
|
13320
13568
|
if (stepProgress.length > 0)
|
|
13321
13569
|
input.liveProgress[index] = stepProgress[0];
|
|
13322
|
-
const indexedResults = input.liveResults.flatMap((
|
|
13323
|
-
const mergedResults = indexedResults.map(({ result
|
|
13570
|
+
const indexedResults = input.liveResults.flatMap((result, resultIndex) => result === undefined ? [] : [{ result, index: resultIndex }]);
|
|
13571
|
+
const mergedResults = indexedResults.map(({ result }) => result);
|
|
13324
13572
|
const mergedProgress = input.liveProgress.filter((progress) => progress !== undefined);
|
|
13325
13573
|
const controlEvents = progressUpdate.details?.controlEvents?.map((event) => ({ ...event, index }));
|
|
13326
13574
|
const artifactDir = progressUpdate.details?.artifacts?.dir;
|
|
13327
|
-
const artifactFiles = mergedResults.flatMap((
|
|
13575
|
+
const artifactFiles = mergedResults.flatMap((result) => result.artifactPaths ? [result.artifactPaths] : []);
|
|
13328
13576
|
const aggregateUpdate = {
|
|
13329
13577
|
content: progressUpdate.content,
|
|
13330
13578
|
details: {
|
|
@@ -13341,9 +13589,39 @@ async function runForegroundParallelTasks(input) {
|
|
|
13341
13589
|
} : undefined
|
|
13342
13590
|
};
|
|
13343
13591
|
input.onExecution?.(index, input.ctx.cwd, runOptions);
|
|
13344
|
-
|
|
13345
|
-
|
|
13346
|
-
|
|
13592
|
+
if (host) {
|
|
13593
|
+
if (input.wait?.kind !== "foreground") {
|
|
13594
|
+
runOptions.intercomDetachSignal = undefined;
|
|
13595
|
+
runOptions.onIntercomDetachCommit = undefined;
|
|
13596
|
+
}
|
|
13597
|
+
let terminalChild;
|
|
13598
|
+
const response = await runAgentTask({
|
|
13599
|
+
host,
|
|
13600
|
+
cwd: input.ctx.cwd,
|
|
13601
|
+
agents: taskAgents,
|
|
13602
|
+
agent: task.agent,
|
|
13603
|
+
task: taskText,
|
|
13604
|
+
intentTask: task.task,
|
|
13605
|
+
options: runOptions,
|
|
13606
|
+
wait: input.wait,
|
|
13607
|
+
runtime: input.runtime,
|
|
13608
|
+
schedule: (dispatch) => schedule(() => dispatch().finally(() => input.onTaskTerminal?.(index))),
|
|
13609
|
+
onTerminal: (child) => {
|
|
13610
|
+
terminalChild = child;
|
|
13611
|
+
}
|
|
13612
|
+
});
|
|
13613
|
+
if (terminalChild)
|
|
13614
|
+
return { ...terminalChild, taskResponse: response };
|
|
13615
|
+
return {
|
|
13616
|
+
agent: task.agent,
|
|
13617
|
+
task: task.task,
|
|
13618
|
+
status: "continued",
|
|
13619
|
+
messages: [],
|
|
13620
|
+
usage: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, cost: 0, turns: 0 },
|
|
13621
|
+
taskResponse: response
|
|
13622
|
+
};
|
|
13623
|
+
}
|
|
13624
|
+
return runUnboundParallelTask(runOptions, task.agent, taskText, schedule, (options) => input.runtime.runSync(input.ctx.cwd, taskAgents, task.agent, taskText, options)).finally(() => {
|
|
13347
13625
|
if (input.foregroundControl?.currentIndex === index) {
|
|
13348
13626
|
input.foregroundControl.interrupt = undefined;
|
|
13349
13627
|
input.foregroundControl.updatedAt = Date.now();
|
|
@@ -13356,7 +13634,7 @@ async function runForegroundParallelTasks(input) {
|
|
|
13356
13634
|
import { isStaleExtensionContextError as isStaleExtensionContextError4 } from "@bastani/atomic";
|
|
13357
13635
|
|
|
13358
13636
|
// dist/builtin/subagents/src/intercom/result-intercom.ts
|
|
13359
|
-
import { randomUUID as
|
|
13637
|
+
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
13360
13638
|
import { isStaleExtensionContextError as isStaleExtensionContextError3 } from "@bastani/atomic";
|
|
13361
13639
|
function resolveSubagentResultStatus(input) {
|
|
13362
13640
|
if (input.detached || input.status === "continued")
|
|
@@ -13491,8 +13769,8 @@ async function deliverSubagentResultIntercomEvent(events, payload, timeoutMs = 5
|
|
|
13491
13769
|
async function deliverSubagentIntercomMessageEvent(events, to, message, timeoutMs = 500, extra = {}) {
|
|
13492
13770
|
if (typeof events.on !== "function" || typeof events.emit !== "function")
|
|
13493
13771
|
return false;
|
|
13494
|
-
const requestId = typeof extra.requestId === "string" ? extra.requestId :
|
|
13495
|
-
return new Promise((
|
|
13772
|
+
const requestId = typeof extra.requestId === "string" ? extra.requestId : randomUUID4();
|
|
13773
|
+
return new Promise((resolve) => {
|
|
13496
13774
|
let settled = false;
|
|
13497
13775
|
let unsubscribe;
|
|
13498
13776
|
let timer;
|
|
@@ -13508,7 +13786,7 @@ async function deliverSubagentIntercomMessageEvent(events, to, message, timeoutM
|
|
|
13508
13786
|
if (!isStaleExtensionContextError3(error))
|
|
13509
13787
|
throw error;
|
|
13510
13788
|
}
|
|
13511
|
-
|
|
13789
|
+
resolve(delivered);
|
|
13512
13790
|
};
|
|
13513
13791
|
try {
|
|
13514
13792
|
unsubscribe = events.on(SUBAGENT_RESULT_INTERCOM_DELIVERY_EVENT, (data) => {
|
|
@@ -13534,9 +13812,9 @@ async function deliverSubagentIntercomMessageEvent(events, to, message, timeoutM
|
|
|
13534
13812
|
}
|
|
13535
13813
|
});
|
|
13536
13814
|
}
|
|
13537
|
-
function stripSingleResultOutputs(
|
|
13815
|
+
function stripSingleResultOutputs(result) {
|
|
13538
13816
|
return {
|
|
13539
|
-
...
|
|
13817
|
+
...result,
|
|
13540
13818
|
messages: undefined,
|
|
13541
13819
|
finalOutput: undefined,
|
|
13542
13820
|
truncation: undefined
|
|
@@ -13583,14 +13861,14 @@ function formatSubagentResultReceipt(input) {
|
|
|
13583
13861
|
|
|
13584
13862
|
// dist/builtin/subagents/src/runs/foreground/completion-notification.ts
|
|
13585
13863
|
function deliverLocalCompletionNotification(events, payload, notificationId) {
|
|
13586
|
-
return new Promise((
|
|
13864
|
+
return new Promise((resolve, reject) => {
|
|
13587
13865
|
let settled = false;
|
|
13588
13866
|
let deferred = false;
|
|
13589
13867
|
const finish = (delivered) => {
|
|
13590
13868
|
if (settled)
|
|
13591
13869
|
return;
|
|
13592
13870
|
settled = true;
|
|
13593
|
-
|
|
13871
|
+
resolve(delivered);
|
|
13594
13872
|
};
|
|
13595
13873
|
const fail = (error) => {
|
|
13596
13874
|
if (settled)
|
|
@@ -13713,28 +13991,28 @@ function createForegroundControlNotifier(data, deps) {
|
|
|
13713
13991
|
function workflowStageAcceptsDetachedNotification(ctx) {
|
|
13714
13992
|
return ctx.orchestrationContext?.messageAdmission?.isOpen() !== false;
|
|
13715
13993
|
}
|
|
13716
|
-
function resultSummaryForIntercom(
|
|
13717
|
-
const output = getSingleResultOutput(
|
|
13718
|
-
if (
|
|
13719
|
-
return output ? `${
|
|
13994
|
+
function resultSummaryForIntercom(result) {
|
|
13995
|
+
const output = getSingleResultOutput(result);
|
|
13996
|
+
if (result.status === "error" && result.error) {
|
|
13997
|
+
return output ? `${result.error}
|
|
13720
13998
|
|
|
13721
13999
|
Output:
|
|
13722
|
-
${output}` :
|
|
14000
|
+
${output}` : result.error;
|
|
13723
14001
|
}
|
|
13724
|
-
return output ||
|
|
14002
|
+
return output || result.error || "(no output)";
|
|
13725
14003
|
}
|
|
13726
14004
|
function notifyDetachedForegroundChildExit(input) {
|
|
13727
|
-
const { pi, runId, index, result
|
|
14005
|
+
const { pi, runId, index, result } = input;
|
|
13728
14006
|
deliverLocalCompletionNotification(pi.events, {
|
|
13729
14007
|
id: runId,
|
|
13730
14008
|
runId,
|
|
13731
|
-
agent:
|
|
13732
|
-
status:
|
|
13733
|
-
summary: resultSummaryForIntercom(
|
|
13734
|
-
...
|
|
14009
|
+
agent: result.agent,
|
|
14010
|
+
status: result.status,
|
|
14011
|
+
summary: resultSummaryForIntercom(result),
|
|
14012
|
+
...result.interrupted ? { state: "interrupted" } : {},
|
|
13735
14013
|
timestamp: Date.now(),
|
|
13736
|
-
...
|
|
13737
|
-
...
|
|
14014
|
+
...result.progressSummary?.durationMs !== undefined ? { durationMs: result.progressSummary.durationMs } : {},
|
|
14015
|
+
...result.sessionFile ? { sessionFile: result.sessionFile } : {},
|
|
13738
14016
|
...input.totalTasks !== undefined && input.totalTasks > 1 ? { taskIndex: index, totalTasks: input.totalTasks } : {},
|
|
13739
14017
|
noticeLabel: "Detached subagent task"
|
|
13740
14018
|
}, `foreground-detach-${runId}-${index}`).catch((error) => {
|
|
@@ -13746,20 +14024,20 @@ function notifyDetachedForegroundChildExit(input) {
|
|
|
13746
14024
|
async function emitForegroundResultIntercom(input) {
|
|
13747
14025
|
if (!input.intercomBridge.active || !input.intercomBridge.orchestratorTarget)
|
|
13748
14026
|
return null;
|
|
13749
|
-
const children = input.results.flatMap((
|
|
14027
|
+
const children = input.results.flatMap((result, index) => result.detached ? [] : [
|
|
13750
14028
|
{
|
|
13751
|
-
agent:
|
|
14029
|
+
agent: result.agent,
|
|
13752
14030
|
status: resolveSubagentResultStatus({
|
|
13753
|
-
status:
|
|
13754
|
-
interrupted:
|
|
13755
|
-
detached:
|
|
14031
|
+
status: result.status,
|
|
14032
|
+
interrupted: result.interrupted,
|
|
14033
|
+
detached: result.detached
|
|
13756
14034
|
}),
|
|
13757
|
-
summary: resultSummaryForIntercom(
|
|
14035
|
+
summary: resultSummaryForIntercom(result),
|
|
13758
14036
|
index,
|
|
13759
|
-
...
|
|
13760
|
-
artifactPath:
|
|
13761
|
-
sessionPath:
|
|
13762
|
-
intercomTarget: resolveSubagentIntercomTarget(input.runId,
|
|
14037
|
+
...result.cause ? { cause: result.cause } : {},
|
|
14038
|
+
artifactPath: result.artifactPaths?.outputPath,
|
|
14039
|
+
sessionPath: result.sessionFile,
|
|
14040
|
+
intercomTarget: resolveSubagentIntercomTarget(input.runId, result.agent, index)
|
|
13763
14041
|
}
|
|
13764
14042
|
]);
|
|
13765
14043
|
if (children.length === 0)
|
|
@@ -13870,7 +14148,6 @@ async function runParallelPath(data, deps) {
|
|
|
13870
14148
|
});
|
|
13871
14149
|
if (errorResult)
|
|
13872
14150
|
return errorResult;
|
|
13873
|
-
let parentAsk;
|
|
13874
14151
|
try {
|
|
13875
14152
|
const duplicateOutputError = findDuplicateParallelOutputPath({
|
|
13876
14153
|
tasks,
|
|
@@ -13897,7 +14174,9 @@ async function runParallelPath(data, deps) {
|
|
|
13897
14174
|
}
|
|
13898
14175
|
}
|
|
13899
14176
|
const results = await runForegroundParallelTasks({
|
|
13900
|
-
|
|
14177
|
+
wait: params.wait,
|
|
14178
|
+
onTaskTerminal: (index) => detachedCleanup.recover(index),
|
|
14179
|
+
onDetachedExit: (index, result) => {
|
|
13901
14180
|
try {
|
|
13902
14181
|
if (workflowStageAcceptsDetachedNotification(ctx)) {
|
|
13903
14182
|
notifyDetachedForegroundChildExit({
|
|
@@ -13906,17 +14185,13 @@ async function runParallelPath(data, deps) {
|
|
|
13906
14185
|
mode: "parallel",
|
|
13907
14186
|
index,
|
|
13908
14187
|
totalTasks: tasks.length,
|
|
13909
|
-
result
|
|
14188
|
+
result
|
|
13910
14189
|
});
|
|
13911
14190
|
}
|
|
13912
14191
|
} finally {
|
|
13913
14192
|
detachedCleanup.recover(index);
|
|
13914
14193
|
}
|
|
13915
14194
|
},
|
|
13916
|
-
onParentAskHandoff: (handoff) => {
|
|
13917
|
-
if (!parentAsk)
|
|
13918
|
-
parentAsk = handoff;
|
|
13919
|
-
},
|
|
13920
14195
|
tasks,
|
|
13921
14196
|
taskTexts,
|
|
13922
14197
|
agents,
|
|
@@ -13954,38 +14229,48 @@ async function runParallelPath(data, deps) {
|
|
|
13954
14229
|
worktreeSetup,
|
|
13955
14230
|
runtime: deps.runtime
|
|
13956
14231
|
});
|
|
14232
|
+
if (ctx.getAgentTaskHost) {
|
|
14233
|
+
const response = {
|
|
14234
|
+
kind: "parallel",
|
|
14235
|
+
slots: results.map((result, ordinal) => ({
|
|
14236
|
+
ordinal,
|
|
14237
|
+
outcome: result.taskResponse ?? {
|
|
14238
|
+
kind: "unstarted",
|
|
14239
|
+
reason: { kind: "skipped", cause: "parallel-group-detach" }
|
|
14240
|
+
}
|
|
14241
|
+
}))
|
|
14242
|
+
};
|
|
14243
|
+
worktreeCleanupDeferred = detachedCleanup.defer(response.slots.flatMap(({ ordinal, outcome }) => outcome.kind === "admitted" && outcome.observation.kind === "yielded" ? [ordinal] : []));
|
|
14244
|
+
return {
|
|
14245
|
+
content: [{ type: "text", text: JSON.stringify(response) }],
|
|
14246
|
+
details: {
|
|
14247
|
+
mode: "parallel",
|
|
14248
|
+
results: [],
|
|
14249
|
+
taskResponse: response,
|
|
14250
|
+
taskRecords: taskResponseRecords(response, ctx.getAgentTaskHost())
|
|
14251
|
+
}
|
|
14252
|
+
};
|
|
14253
|
+
}
|
|
13957
14254
|
for (let i = 0;i < results.length; i++) {
|
|
13958
14255
|
const run = results[i];
|
|
13959
14256
|
recordRun(run.agent, taskTexts[i], run.status, run.progressSummary?.durationMs ?? 0);
|
|
13960
14257
|
}
|
|
13961
|
-
for (const
|
|
13962
|
-
if (
|
|
13963
|
-
allProgress.push(
|
|
13964
|
-
if (
|
|
13965
|
-
allArtifactPaths.push(
|
|
14258
|
+
for (const result of results) {
|
|
14259
|
+
if (result.progress)
|
|
14260
|
+
allProgress.push(result.progress);
|
|
14261
|
+
if (result.artifactPaths)
|
|
14262
|
+
allArtifactPaths.push(result.artifactPaths);
|
|
13966
14263
|
}
|
|
13967
|
-
const interrupted = results.find((
|
|
14264
|
+
const interrupted = results.find((result) => result.interrupted && !isParentCancellation(result.cause));
|
|
13968
14265
|
const details = compactForegroundDetails({
|
|
13969
14266
|
mode: "parallel",
|
|
13970
14267
|
runId,
|
|
13971
14268
|
results,
|
|
13972
|
-
parentAskYielded:
|
|
14269
|
+
parentAskYielded: false,
|
|
13973
14270
|
progress: params.includeProgress ? allProgress : undefined,
|
|
13974
14271
|
artifacts: allArtifactPaths.length ? { dir: artifactsDir, files: allArtifactPaths } : undefined
|
|
13975
14272
|
});
|
|
13976
|
-
if (
|
|
13977
|
-
const worktreeSuffix2 = buildParallelWorktreeSuffix(worktreeSetup, artifactsDir, tasks);
|
|
13978
|
-
const handoffText = formatParentAskHandoffOutput(parentAsk);
|
|
13979
|
-
const yieldedResult = {
|
|
13980
|
-
content: [{ type: "text", text: worktreeSuffix2 ? `${handoffText}
|
|
13981
|
-
|
|
13982
|
-
${worktreeSuffix2}` : handoffText }],
|
|
13983
|
-
details
|
|
13984
|
-
};
|
|
13985
|
-
markParentAskHandoff(yieldedResult, parentAsk);
|
|
13986
|
-
return yieldedResult;
|
|
13987
|
-
}
|
|
13988
|
-
if (interrupted && !results.some((result2) => isParentCancellation(result2.cause) && (result2.interrupted || result2.status === "interrupted"))) {
|
|
14273
|
+
if (interrupted && !results.some((result) => isParentCancellation(result.cause) && (result.interrupted || result.status === "interrupted"))) {
|
|
13989
14274
|
return {
|
|
13990
14275
|
content: [
|
|
13991
14276
|
{
|
|
@@ -13996,15 +14281,15 @@ ${worktreeSuffix2}` : handoffText }],
|
|
|
13996
14281
|
details
|
|
13997
14282
|
};
|
|
13998
14283
|
}
|
|
13999
|
-
const detachedIndex = results.findIndex((
|
|
14284
|
+
const detachedIndex = results.findIndex((result) => result.detached);
|
|
14000
14285
|
const detached = detachedIndex >= 0 ? results[detachedIndex] : undefined;
|
|
14001
|
-
worktreeCleanupDeferred = detachedCleanup.defer(results.flatMap((
|
|
14286
|
+
worktreeCleanupDeferred = detachedCleanup.defer(results.flatMap((result, index) => result.detached ? [index] : []));
|
|
14002
14287
|
if (detached) {
|
|
14003
14288
|
return {
|
|
14004
14289
|
content: [
|
|
14005
14290
|
{
|
|
14006
14291
|
type: "text",
|
|
14007
|
-
text: `Parallel
|
|
14292
|
+
text: `Parallel observation yielded for intercom coordination (${detached.agent}). The original children continue; reply to any pending ask without relaunching them.`
|
|
14008
14293
|
}
|
|
14009
14294
|
],
|
|
14010
14295
|
details
|
|
@@ -14024,12 +14309,12 @@ ${worktreeSuffix2}` : handoffText }],
|
|
|
14024
14309
|
};
|
|
14025
14310
|
}
|
|
14026
14311
|
const worktreeSuffix = buildParallelWorktreeSuffix(worktreeSetup, artifactsDir, tasks);
|
|
14027
|
-
const childContent = formatParallelResultContent(results.map((
|
|
14028
|
-
agent:
|
|
14029
|
-
output:
|
|
14030
|
-
status:
|
|
14031
|
-
error:
|
|
14032
|
-
...
|
|
14312
|
+
const childContent = formatParallelResultContent(results.map((result) => ({
|
|
14313
|
+
agent: result.agent,
|
|
14314
|
+
output: result.truncation?.text || getSingleResultOutput(result),
|
|
14315
|
+
status: result.status,
|
|
14316
|
+
error: result.error,
|
|
14317
|
+
...result.cause ? { cause: result.cause } : {}
|
|
14033
14318
|
})), (i, agent) => `=== Task ${i + 1}: ${agent} ===`);
|
|
14034
14319
|
const fullContent = worktreeSuffix ? `${childContent}
|
|
14035
14320
|
|
|
@@ -14132,8 +14417,9 @@ function matchesIntercomDetachRoute(event, expected) {
|
|
|
14132
14417
|
// dist/builtin/subagents/src/runs/foreground/execution-intercom-detach.ts
|
|
14133
14418
|
function registerExecutionIntercomDetach(options, state) {
|
|
14134
14419
|
const reservations = new IntercomDetachReservations;
|
|
14420
|
+
let taskWaitYielded = false;
|
|
14135
14421
|
const unsubscribe = options.intercomEvents?.on?.(INTERCOM_DETACH_REQUEST_EVENT, (payload) => {
|
|
14136
|
-
if (!options.allowIntercomDetach || state.isUnavailable())
|
|
14422
|
+
if (!options.allowIntercomDetach || state.isUnavailable() || taskWaitYielded)
|
|
14137
14423
|
return;
|
|
14138
14424
|
if (!payload || typeof payload !== "object")
|
|
14139
14425
|
return;
|
|
@@ -14150,11 +14436,26 @@ function registerExecutionIntercomDetach(options, state) {
|
|
|
14150
14436
|
}
|
|
14151
14437
|
if (event.phase !== "commit" || state.isDetached() || !reservations.commit(event))
|
|
14152
14438
|
return;
|
|
14153
|
-
options.
|
|
14154
|
-
|
|
14439
|
+
if (options.taskExecution) {
|
|
14440
|
+
taskWaitYielded = true;
|
|
14441
|
+
options.taskExecution.yieldTaskWait("intercom-coordination");
|
|
14442
|
+
options.onIntercomDetachCommit?.();
|
|
14443
|
+
} else {
|
|
14444
|
+
options.onIntercomDetachCommit?.();
|
|
14445
|
+
state.detach();
|
|
14446
|
+
}
|
|
14155
14447
|
options.intercomEvents?.emit?.(INTERCOM_DETACH_RESPONSE_EVENT, { ...event, accepted: true });
|
|
14156
14448
|
});
|
|
14157
|
-
const detachSibling = () =>
|
|
14449
|
+
const detachSibling = () => {
|
|
14450
|
+
if (options.taskExecution) {
|
|
14451
|
+
if (state.isUnavailable() || taskWaitYielded)
|
|
14452
|
+
return;
|
|
14453
|
+
taskWaitYielded = true;
|
|
14454
|
+
options.taskExecution.yieldTaskWait("intercom-coordination");
|
|
14455
|
+
} else {
|
|
14456
|
+
state.detach();
|
|
14457
|
+
}
|
|
14458
|
+
};
|
|
14158
14459
|
options.intercomDetachSignal?.addEventListener("abort", detachSibling, { once: true });
|
|
14159
14460
|
if (options.intercomDetachSignal?.aborted)
|
|
14160
14461
|
detachSibling();
|
|
@@ -14273,7 +14574,7 @@ function resultFromOutcome(agent, task, outcome, startedAt, artifactPaths) {
|
|
|
14273
14574
|
const output = outcome.status === "ok" ? outcome.output : outcome.envelope;
|
|
14274
14575
|
const model = outcome.model;
|
|
14275
14576
|
const thinking = outcome.thinking;
|
|
14276
|
-
const
|
|
14577
|
+
const result = {
|
|
14277
14578
|
agent: agent.name,
|
|
14278
14579
|
task,
|
|
14279
14580
|
status,
|
|
@@ -14299,7 +14600,7 @@ function resultFromOutcome(agent, task, outcome, startedAt, artifactPaths) {
|
|
|
14299
14600
|
},
|
|
14300
14601
|
...artifactPaths ? { artifactPaths } : {}
|
|
14301
14602
|
};
|
|
14302
|
-
return
|
|
14603
|
+
return result;
|
|
14303
14604
|
}
|
|
14304
14605
|
function refusedResult(agent, task, reason) {
|
|
14305
14606
|
return {
|
|
@@ -14431,9 +14732,9 @@ ${task}`);
|
|
|
14431
14732
|
const startedAt = Date.now();
|
|
14432
14733
|
const neverAbort = new AbortController().signal;
|
|
14433
14734
|
const running = control.startAttempt(admission.admitted, { model: resolvedCandidate?.model, modelId: candidate, thinkingLevel: spec.thinkingLevel }, {
|
|
14434
|
-
abort: options.signal ?? neverAbort,
|
|
14735
|
+
abort: options.taskExecution?.signal ?? options.signal ?? neverAbort,
|
|
14435
14736
|
interrupt: options.interruptSignal ?? neverAbort
|
|
14436
|
-
});
|
|
14737
|
+
}, options.taskExecution);
|
|
14437
14738
|
if (options.onUpdate) {
|
|
14438
14739
|
const launchModel = running.currentModel ?? candidate;
|
|
14439
14740
|
spec.onProgress?.({
|
|
@@ -14453,8 +14754,8 @@ ${task}`);
|
|
|
14453
14754
|
}
|
|
14454
14755
|
let detached = false;
|
|
14455
14756
|
let resolveContinuation;
|
|
14456
|
-
const continuation = new Promise((
|
|
14457
|
-
resolveContinuation =
|
|
14757
|
+
const continuation = new Promise((resolve) => {
|
|
14758
|
+
resolveContinuation = resolve;
|
|
14458
14759
|
});
|
|
14459
14760
|
const detachCleanup = registerExecutionIntercomDetach(options, {
|
|
14460
14761
|
isUnavailable: () => running.status !== "running",
|
|
@@ -14490,10 +14791,10 @@ ${task}`);
|
|
|
14490
14791
|
timestamp: Date.now(),
|
|
14491
14792
|
artifactsDir: options.artifactsDir
|
|
14492
14793
|
}, { artifactsDir: options.artifactsDir, artifactPaths, artifactsDisabled, maxOutput: options.maxOutput });
|
|
14493
|
-
const
|
|
14494
|
-
if (
|
|
14495
|
-
recovered.envelope =
|
|
14496
|
-
recovered.finalOutput =
|
|
14794
|
+
const delivered = control.getDeliveredResult(continuedOutcome.path);
|
|
14795
|
+
if (delivered) {
|
|
14796
|
+
recovered.envelope = delivered.envelope;
|
|
14797
|
+
recovered.finalOutput = delivered.envelope;
|
|
14497
14798
|
}
|
|
14498
14799
|
options.onDetachedExit?.(recovered);
|
|
14499
14800
|
});
|
|
@@ -14535,37 +14836,37 @@ ${task}`);
|
|
|
14535
14836
|
detachCleanup();
|
|
14536
14837
|
parentAskCleanup();
|
|
14537
14838
|
const outcome = winner.value;
|
|
14538
|
-
const
|
|
14839
|
+
const result = resultFromOutcome(agent, task, outcome, startedAt, artifactPaths);
|
|
14539
14840
|
if (filteredCandidates.skippedAttempts.length)
|
|
14540
|
-
|
|
14841
|
+
result.modelAttempts = [...filteredCandidates.skippedAttempts, ...result.modelAttempts ?? []];
|
|
14541
14842
|
await control.deliverChildResult({
|
|
14542
14843
|
path: outcome.path,
|
|
14543
14844
|
status: outcome.status,
|
|
14544
14845
|
...outcome.status === "error" || outcome.status === "interrupted" && outcome.cause ? { cause: outcome.cause } : {},
|
|
14545
14846
|
stats: outcome.stats,
|
|
14546
14847
|
envelope: outcome.envelope,
|
|
14547
|
-
...
|
|
14548
|
-
...
|
|
14848
|
+
...result.model === undefined ? {} : { model: result.model },
|
|
14849
|
+
...result.thinking === undefined ? {} : { thinking: result.thinking },
|
|
14549
14850
|
sessionFile: outcome.sessionFile,
|
|
14550
14851
|
timestamp: Date.now(),
|
|
14551
14852
|
artifactsDir: options.artifactsDir
|
|
14552
14853
|
}, { artifactsDir: options.artifactsDir, artifactPaths, artifactsDisabled, maxOutput: options.maxOutput });
|
|
14553
14854
|
const delivered = control.getDeliveredResult(outcome.path);
|
|
14554
14855
|
if (delivered) {
|
|
14555
|
-
|
|
14556
|
-
|
|
14856
|
+
result.envelope = delivered.envelope;
|
|
14857
|
+
result.finalOutput = delivered.envelope;
|
|
14557
14858
|
}
|
|
14558
14859
|
const update = {
|
|
14559
|
-
content: [{ type: "text", text:
|
|
14860
|
+
content: [{ type: "text", text: result.finalOutput ?? "(no output)" }],
|
|
14560
14861
|
details: {
|
|
14561
14862
|
mode: "single",
|
|
14562
14863
|
runId: options.runId,
|
|
14563
|
-
results: [
|
|
14564
|
-
progress:
|
|
14864
|
+
results: [result],
|
|
14865
|
+
progress: result.progress ? [result.progress] : undefined
|
|
14565
14866
|
}
|
|
14566
14867
|
};
|
|
14567
14868
|
options.onUpdate?.(update);
|
|
14568
|
-
return
|
|
14869
|
+
return result;
|
|
14569
14870
|
}
|
|
14570
14871
|
async function runSync(runtimeCwd, agents, agentName, task, options) {
|
|
14571
14872
|
const agent = agents.find((candidate) => candidate.name === agentName);
|
|
@@ -14593,15 +14894,15 @@ function resolveSubagentExecutorRuntimeDeps(overrides) {
|
|
|
14593
14894
|
// dist/builtin/subagents/src/runs/foreground/subagent-executor-single.ts
|
|
14594
14895
|
import * as fs18 from "node:fs";
|
|
14595
14896
|
import * as path20 from "node:path";
|
|
14596
|
-
function formatFailedSingleRunOutput(
|
|
14597
|
-
const error =
|
|
14897
|
+
function formatFailedSingleRunOutput(result, displayOutput) {
|
|
14898
|
+
const error = result.error || "Failed";
|
|
14598
14899
|
const output = displayOutput.trim();
|
|
14599
14900
|
const lines = [error];
|
|
14600
14901
|
if (output && output !== error.trim()) {
|
|
14601
14902
|
lines.push("", "Output:", output);
|
|
14602
14903
|
}
|
|
14603
|
-
if (
|
|
14604
|
-
lines.push("", `Output artifact: ${
|
|
14904
|
+
if (result.artifactPaths?.outputPath) {
|
|
14905
|
+
lines.push("", `Output artifact: ${result.artifactPaths.outputPath}`);
|
|
14605
14906
|
}
|
|
14606
14907
|
return lines.join(`
|
|
14607
14908
|
`);
|
|
@@ -14753,10 +15054,10 @@ async function runSinglePath(data, deps) {
|
|
|
14753
15054
|
parentAsk = request;
|
|
14754
15055
|
interruptController.abort();
|
|
14755
15056
|
},
|
|
14756
|
-
onDetachedExit: (
|
|
15057
|
+
onDetachedExit: (result) => {
|
|
14757
15058
|
cleanupTransientProgress(progressDir, artifactConfig.enabled);
|
|
14758
|
-
if (
|
|
14759
|
-
notifyDetachedForegroundChildExit({ pi: deps.pi, runId, mode: "single", index: 0, result
|
|
15059
|
+
if (result && workflowStageAcceptsDetachedNotification(ctx)) {
|
|
15060
|
+
notifyDetachedForegroundChildExit({ pi: deps.pi, runId, mode: "single", index: 0, result });
|
|
14760
15061
|
}
|
|
14761
15062
|
},
|
|
14762
15063
|
index: 0,
|
|
@@ -14769,7 +15070,34 @@ async function runSinglePath(data, deps) {
|
|
|
14769
15070
|
currentThinkingLevel: ctx.thinkingLevel,
|
|
14770
15071
|
skills: effectiveSkills
|
|
14771
15072
|
};
|
|
14772
|
-
|
|
15073
|
+
if (ctx.getAgentTaskHost) {
|
|
15074
|
+
let settledChild;
|
|
15075
|
+
const response = await runAgentTask({
|
|
15076
|
+
host: ctx.getAgentTaskHost(),
|
|
15077
|
+
cwd: ctx.cwd,
|
|
15078
|
+
agents,
|
|
15079
|
+
agent: params.agent,
|
|
15080
|
+
task,
|
|
15081
|
+
intentTask: handoffTaskContext,
|
|
15082
|
+
options: runOptions,
|
|
15083
|
+
wait: params.wait,
|
|
15084
|
+
runtime: deps.runtime,
|
|
15085
|
+
onTerminal: (child) => {
|
|
15086
|
+
settledChild = child;
|
|
15087
|
+
cleanupTransientProgress(progressDir, artifactConfig.enabled);
|
|
15088
|
+
},
|
|
15089
|
+
outputText: (child) => parentAsk && child.interrupted ? formatParentAskHandoffOutput({
|
|
15090
|
+
askingChildIndex: 0,
|
|
15091
|
+
releasedChildIndices: [0],
|
|
15092
|
+
unlaunchedChildIndices: [],
|
|
15093
|
+
request: parentAsk
|
|
15094
|
+
}) : getSingleResultOutput(child)
|
|
15095
|
+
});
|
|
15096
|
+
if (!parentAsk || !settledChild?.interrupted)
|
|
15097
|
+
return taskToolResult(response, ctx.getAgentTaskHost());
|
|
15098
|
+
r = settledChild;
|
|
15099
|
+
} else
|
|
15100
|
+
r = await deps.runtime.runSync(ctx.cwd, agents, params.agent, task, runOptions);
|
|
14773
15101
|
} catch (error) {
|
|
14774
15102
|
cleanupTransientProgress(progressDir, artifactConfig.enabled);
|
|
14775
15103
|
throw error;
|
|
@@ -14887,7 +15215,7 @@ async function runSinglePath(data, deps) {
|
|
|
14887
15215
|
|
|
14888
15216
|
// dist/builtin/subagents/src/runs/foreground/subagent-executor.ts
|
|
14889
15217
|
var MUTATING_MANAGEMENT_ACTIONS = new Set(["create", "update", "delete"]);
|
|
14890
|
-
var READ_ONLY_MANAGEMENT_ACTIONS = new Set(["list", "get", "status"]);
|
|
15218
|
+
var READ_ONLY_MANAGEMENT_ACTIONS = new Set(["list", "get", "status", "wait"]);
|
|
14891
15219
|
var FANOUT_REFUSAL_MESSAGE = "Subagent fanout is not authorized for this child.";
|
|
14892
15220
|
async function handleManagementRequest(input) {
|
|
14893
15221
|
const { params, paramsWithResolvedCwd, requestCwd, ctx, deps } = input;
|
|
@@ -14925,6 +15253,51 @@ async function handleManagementRequest(input) {
|
|
|
14925
15253
|
if (childRefusal)
|
|
14926
15254
|
return childRefusal;
|
|
14927
15255
|
}
|
|
15256
|
+
if (action === "wait") {
|
|
15257
|
+
const observed = ctx.getAgentTaskHost && params.id !== undefined ? await ctx.getAgentTaskHost().waitForTask(params.id, params.budgetMs) : { ok: false, error: { code: "UnknownTask", message: "Task not found in this owner" } };
|
|
15258
|
+
return {
|
|
15259
|
+
content: [{ type: "text", text: JSON.stringify(observed.ok ? observed.value : observed.error) }],
|
|
15260
|
+
details: {
|
|
15261
|
+
mode: "management",
|
|
15262
|
+
results: [],
|
|
15263
|
+
...observed.ok ? {
|
|
15264
|
+
taskResponse: { kind: "admitted", observation: observed.value },
|
|
15265
|
+
taskRecords: taskResponseRecords({ kind: "admitted", observation: observed.value }, ctx.getAgentTaskHost?.())
|
|
15266
|
+
} : { taskError: observed.error.message }
|
|
15267
|
+
},
|
|
15268
|
+
...!observed.ok ? { isError: true } : {}
|
|
15269
|
+
};
|
|
15270
|
+
}
|
|
15271
|
+
const targetTaskId = paramsWithResolvedCwd.id ?? paramsWithResolvedCwd.runId;
|
|
15272
|
+
if ((action === "status" || action === "interrupt") && ctx.getAgentTaskHost && targetTaskId) {
|
|
15273
|
+
const host = ctx.getAgentTaskHost();
|
|
15274
|
+
const taskId = targetTaskId;
|
|
15275
|
+
if (host.resolveTask(taskId).ok) {
|
|
15276
|
+
if (action === "interrupt") {
|
|
15277
|
+
const cancelled = await host.cancelTask(taskId, "user");
|
|
15278
|
+
if (!cancelled.ok)
|
|
15279
|
+
return {
|
|
15280
|
+
content: [{ type: "text", text: cancelled.error.message }],
|
|
15281
|
+
isError: true,
|
|
15282
|
+
details: { mode: "management", results: [], taskError: cancelled.error.message }
|
|
15283
|
+
};
|
|
15284
|
+
}
|
|
15285
|
+
const watched = host.watchOwnerTasks();
|
|
15286
|
+
if (watched.ok) {
|
|
15287
|
+
const records = watched.value.snapshot.tasks.filter((task) => task.ref.taskId === taskId);
|
|
15288
|
+
watched.value.dispose();
|
|
15289
|
+
return {
|
|
15290
|
+
content: [{ type: "text", text: JSON.stringify(records) }],
|
|
15291
|
+
details: { mode: "management", results: [], taskRecords: records }
|
|
15292
|
+
};
|
|
15293
|
+
}
|
|
15294
|
+
return {
|
|
15295
|
+
content: [{ type: "text", text: watched.error.message }],
|
|
15296
|
+
isError: true,
|
|
15297
|
+
details: { mode: "management", results: [], taskError: watched.error.message }
|
|
15298
|
+
};
|
|
15299
|
+
}
|
|
15300
|
+
}
|
|
14928
15301
|
if (action === "status") {
|
|
14929
15302
|
const targetRunId = paramsWithResolvedCwd.id ?? paramsWithResolvedCwd.runId;
|
|
14930
15303
|
const inProcess = inspectInProcessChildStatus(targetRunId);
|
|
@@ -15008,12 +15381,12 @@ function createSubagentExecutor(rawDeps) {
|
|
|
15008
15381
|
const prepared = built.prepared;
|
|
15009
15382
|
try {
|
|
15010
15383
|
if (prepared.hasTasks && prepared.effectiveParams.tasks) {
|
|
15011
|
-
const
|
|
15012
|
-
return withForkContext(
|
|
15384
|
+
const result = await runParallelPath(prepared.execData, deps);
|
|
15385
|
+
return withForkContext(result, prepared.effectiveParams.context);
|
|
15013
15386
|
}
|
|
15014
15387
|
if (prepared.hasSingle) {
|
|
15015
|
-
const
|
|
15016
|
-
return withForkContext(
|
|
15388
|
+
const result = await runSinglePath(prepared.execData, deps);
|
|
15389
|
+
return withForkContext(result, prepared.effectiveParams.context);
|
|
15017
15390
|
}
|
|
15018
15391
|
} catch (error) {
|
|
15019
15392
|
return toExecutionErrorResult(prepared.effectiveParams, error);
|
|
@@ -15215,28 +15588,28 @@ function resolveProgressModel(update, entry) {
|
|
|
15215
15588
|
return byIndex.model;
|
|
15216
15589
|
}
|
|
15217
15590
|
if (entry.agent) {
|
|
15218
|
-
const byAgent = results.find((
|
|
15591
|
+
const byAgent = results.find((result) => result.agent === entry.agent && typeof result.model === "string");
|
|
15219
15592
|
if (byAgent?.model)
|
|
15220
15593
|
return byAgent.model;
|
|
15221
15594
|
}
|
|
15222
|
-
const firstWithModel = results.find((
|
|
15595
|
+
const firstWithModel = results.find((result) => typeof result.model === "string");
|
|
15223
15596
|
return firstWithModel?.model;
|
|
15224
15597
|
}
|
|
15225
15598
|
function toolCallSummaryText(summary) {
|
|
15226
15599
|
const text = typeof summary.expandedText === "string" && summary.expandedText.trim().length > 0 ? summary.expandedText.trim() : typeof summary.text === "string" ? summary.text.trim() : "";
|
|
15227
15600
|
return text || undefined;
|
|
15228
15601
|
}
|
|
15229
|
-
function buildDelegationMessages(
|
|
15230
|
-
if (Array.isArray(
|
|
15231
|
-
return
|
|
15232
|
-
const toolCallSummaries = (
|
|
15233
|
-
const
|
|
15234
|
-
return
|
|
15602
|
+
function buildDelegationMessages(result, fallbackText) {
|
|
15603
|
+
if (Array.isArray(result.messages) && result.messages.length > 0)
|
|
15604
|
+
return result.messages;
|
|
15605
|
+
const toolCallSummaries = (result.toolCalls ?? []).flatMap((summary) => {
|
|
15606
|
+
const text = toolCallSummaryText(summary);
|
|
15607
|
+
return text ? [`- ${text}`] : [];
|
|
15235
15608
|
});
|
|
15236
15609
|
const toolCallText = toolCallSummaries.length > 0 ? `Tool calls:
|
|
15237
15610
|
${toolCallSummaries.join(`
|
|
15238
15611
|
`)}` : undefined;
|
|
15239
|
-
const text = typeof
|
|
15612
|
+
const text = typeof result.finalOutput === "string" && result.finalOutput.trim().length > 0 ? result.finalOutput.trim() : fallbackText;
|
|
15240
15613
|
const contentText = [toolCallText, text].filter((part) => Boolean(part)).join(`
|
|
15241
15614
|
|
|
15242
15615
|
`);
|
|
@@ -15247,15 +15620,15 @@ ${toolCallSummaries.join(`
|
|
|
15247
15620
|
function toDelegationUpdate(requestId, update) {
|
|
15248
15621
|
const progress = update.details?.progress?.[0];
|
|
15249
15622
|
const taskProgress = update.details?.progress?.map((entry) => {
|
|
15250
|
-
const
|
|
15251
|
-
const
|
|
15623
|
+
const lastOutput = entry.recentOutput?.[entry.recentOutput.length - 1];
|
|
15624
|
+
const safeLastOutput = typeof lastOutput === "string" && lastOutput.trim() && lastOutput !== "(running...)" ? lastOutput : undefined;
|
|
15252
15625
|
return {
|
|
15253
15626
|
index: entry.index,
|
|
15254
15627
|
agent: entry.agent ?? "delegate",
|
|
15255
15628
|
status: entry.status,
|
|
15256
15629
|
currentTool: entry.currentTool,
|
|
15257
15630
|
currentToolArgs: entry.currentToolArgs,
|
|
15258
|
-
recentOutput:
|
|
15631
|
+
recentOutput: safeLastOutput,
|
|
15259
15632
|
recentOutputLines: filterRecentOutput(entry.recentOutput),
|
|
15260
15633
|
recentTools: sanitizeRecentTools(entry.recentTools),
|
|
15261
15634
|
model: resolveProgressModel(update, entry),
|
|
@@ -15345,7 +15718,7 @@ function registerPromptTemplateDelegationBridge(options) {
|
|
|
15345
15718
|
return;
|
|
15346
15719
|
}
|
|
15347
15720
|
try {
|
|
15348
|
-
const
|
|
15721
|
+
const result = await options.execute(request.requestId, request, controller.signal, ctx, (update) => {
|
|
15349
15722
|
const payload = toDelegationUpdate(request.requestId, update);
|
|
15350
15723
|
if (!payload)
|
|
15351
15724
|
return;
|
|
@@ -15353,10 +15726,10 @@ function registerPromptTemplateDelegationBridge(options) {
|
|
|
15353
15726
|
controller.abort();
|
|
15354
15727
|
}
|
|
15355
15728
|
});
|
|
15356
|
-
const contentText = firstTextContent(
|
|
15357
|
-
const messages = buildDelegationMessages(
|
|
15729
|
+
const contentText = firstTextContent(result.content);
|
|
15730
|
+
const messages = buildDelegationMessages(result.details?.results?.[0] ?? {}, contentText);
|
|
15358
15731
|
const parallelResults = request.tasks ? request.tasks.map((task, index) => {
|
|
15359
|
-
const step =
|
|
15732
|
+
const step = result.details?.results?.[index];
|
|
15360
15733
|
if (!step) {
|
|
15361
15734
|
return {
|
|
15362
15735
|
agent: task.agent,
|
|
@@ -15378,8 +15751,8 @@ function registerPromptTemplateDelegationBridge(options) {
|
|
|
15378
15751
|
messages,
|
|
15379
15752
|
...parallelResults ? { parallelResults } : {},
|
|
15380
15753
|
...contentText ? { contentText } : {},
|
|
15381
|
-
isError:
|
|
15382
|
-
errorText:
|
|
15754
|
+
isError: result.isError === true,
|
|
15755
|
+
errorText: result.isError ? contentText : undefined
|
|
15383
15756
|
};
|
|
15384
15757
|
emitBridgeEvent(options.events, PROMPT_TEMPLATE_SUBAGENT_RESPONSE_EVENT, response, settlement);
|
|
15385
15758
|
} catch (error) {
|
|
@@ -15487,7 +15860,7 @@ function registerSlashSubagentBridge(options) {
|
|
|
15487
15860
|
return;
|
|
15488
15861
|
}
|
|
15489
15862
|
try {
|
|
15490
|
-
const
|
|
15863
|
+
const result = await options.execute(requestId, params, controller.signal, (update) => {
|
|
15491
15864
|
const progress = update.details?.progress;
|
|
15492
15865
|
const first = progress?.[0];
|
|
15493
15866
|
const payload = {
|
|
@@ -15502,9 +15875,9 @@ function registerSlashSubagentBridge(options) {
|
|
|
15502
15875
|
}, ctx);
|
|
15503
15876
|
const response = {
|
|
15504
15877
|
requestId,
|
|
15505
|
-
result
|
|
15506
|
-
isError:
|
|
15507
|
-
errorText:
|
|
15878
|
+
result,
|
|
15879
|
+
isError: result.isError === true,
|
|
15880
|
+
errorText: result.isError ? result.content.find((c) => c.type === "text")?.text : undefined
|
|
15508
15881
|
};
|
|
15509
15882
|
emitBridgeEvent(options.events, SLASH_SUBAGENT_RESPONSE_EVENT, response, settlement);
|
|
15510
15883
|
} catch (error) {
|
|
@@ -15542,8 +15915,166 @@ function registerSlashSubagentBridge(options) {
|
|
|
15542
15915
|
};
|
|
15543
15916
|
}
|
|
15544
15917
|
|
|
15918
|
+
// dist/builtin/subagents/src/tui/agent-browser.ts
|
|
15919
|
+
import {
|
|
15920
|
+
Input,
|
|
15921
|
+
matchesKey,
|
|
15922
|
+
truncateToWidth,
|
|
15923
|
+
visibleWidth,
|
|
15924
|
+
wrapTextWithAnsi
|
|
15925
|
+
} from "@earendil-works/pi-tui";
|
|
15926
|
+
var sources = ["project", "user", "builtin"];
|
|
15927
|
+
var sourceLabels = { project: "Project agents", user: "User agents", builtin: "Built-in agents" };
|
|
15928
|
+
var clean = (text) => text.replace(/\x1b\[[0-?]*[ -/]*[@-~]/g, "").replace(/[\x00-\x1f\x7f-\x9f]/g, " ");
|
|
15929
|
+
|
|
15930
|
+
class AgentBrowser {
|
|
15931
|
+
theme;
|
|
15932
|
+
close;
|
|
15933
|
+
height;
|
|
15934
|
+
search = new Input({ prompt: "Search: ", placeholder: "name, role, or source" });
|
|
15935
|
+
index = 0;
|
|
15936
|
+
detail = false;
|
|
15937
|
+
scroll = 0;
|
|
15938
|
+
agents;
|
|
15939
|
+
get focused() {
|
|
15940
|
+
return this.search.focused;
|
|
15941
|
+
}
|
|
15942
|
+
set focused(value) {
|
|
15943
|
+
this.search.focused = value;
|
|
15944
|
+
}
|
|
15945
|
+
constructor(agents, theme, close, height, query = "") {
|
|
15946
|
+
this.theme = theme;
|
|
15947
|
+
this.close = close;
|
|
15948
|
+
this.height = height;
|
|
15949
|
+
this.agents = sources.flatMap((source) => agents.filter((agent) => agent.source === source).sort((a, b) => a.name.localeCompare(b.name)));
|
|
15950
|
+
this.search.setValue(query);
|
|
15951
|
+
this.search.handleInput("\x05");
|
|
15952
|
+
}
|
|
15953
|
+
invalidate() {}
|
|
15954
|
+
matches() {
|
|
15955
|
+
const query = this.search.getValue().toLowerCase().trim();
|
|
15956
|
+
return this.agents.filter((agent) => `${agent.name} ${agent.description} ${agent.source}`.toLowerCase().includes(query));
|
|
15957
|
+
}
|
|
15958
|
+
handleInput(data) {
|
|
15959
|
+
if (matchesKey(data, "escape") || matchesKey(data, "ctrl+c")) {
|
|
15960
|
+
if (this.detail) {
|
|
15961
|
+
this.detail = false;
|
|
15962
|
+
this.scroll = 0;
|
|
15963
|
+
} else
|
|
15964
|
+
this.close();
|
|
15965
|
+
return true;
|
|
15966
|
+
}
|
|
15967
|
+
if (this.detail) {
|
|
15968
|
+
if (matchesKey(data, "up"))
|
|
15969
|
+
this.scroll = Math.max(0, this.scroll - 1);
|
|
15970
|
+
else if (matchesKey(data, "down"))
|
|
15971
|
+
this.scroll++;
|
|
15972
|
+
else if (matchesKey(data, "pageDown"))
|
|
15973
|
+
this.scroll += 10;
|
|
15974
|
+
else if (matchesKey(data, "pageUp"))
|
|
15975
|
+
this.scroll = Math.max(0, this.scroll - 10);
|
|
15976
|
+
else if (matchesKey(data, "enter")) {
|
|
15977
|
+
this.detail = false;
|
|
15978
|
+
this.scroll = 0;
|
|
15979
|
+
}
|
|
15980
|
+
return true;
|
|
15981
|
+
}
|
|
15982
|
+
const agents = this.matches();
|
|
15983
|
+
if (matchesKey(data, "up"))
|
|
15984
|
+
this.index = Math.max(0, this.index - 1);
|
|
15985
|
+
else if (matchesKey(data, "down"))
|
|
15986
|
+
this.index = Math.min(Math.max(0, agents.length - 1), this.index + 1);
|
|
15987
|
+
else if (matchesKey(data, "enter"))
|
|
15988
|
+
this.detail = agents.length > 0;
|
|
15989
|
+
else {
|
|
15990
|
+
this.search.handleInput(data);
|
|
15991
|
+
this.index = 0;
|
|
15992
|
+
}
|
|
15993
|
+
return true;
|
|
15994
|
+
}
|
|
15995
|
+
render(width) {
|
|
15996
|
+
const theme = this.theme;
|
|
15997
|
+
const budget = Math.max(4, this.height() - 6);
|
|
15998
|
+
const framed = width >= 24 && budget >= 7;
|
|
15999
|
+
const inner = Math.max(1, width - (framed ? 4 : 0));
|
|
16000
|
+
const agents = this.matches();
|
|
16001
|
+
const agent = agents[this.index];
|
|
16002
|
+
const title = this.detail && agent ? agent.name : "Agents";
|
|
16003
|
+
const heading = theme.bold(truncateToWidth(clean(title), Math.max(1, width - 6)));
|
|
16004
|
+
const top = theme.fg("borderMuted", "╭─ ") + heading + theme.fg("borderMuted", ` ${"─".repeat(Math.max(0, width - visibleWidth(heading) - 5))}╮`);
|
|
16005
|
+
const body = [];
|
|
16006
|
+
let selectedRow = 0;
|
|
16007
|
+
if (this.detail && agent) {
|
|
16008
|
+
const section = (label, value) => {
|
|
16009
|
+
body.push("", theme.fg("muted", theme.bold(label)), ...wrapTextWithAnsi(clean(value), inner));
|
|
16010
|
+
};
|
|
16011
|
+
body.push(theme.fg("dim", `${sourceLabels[agent.source]} · ${agent.defaultContext ?? "fresh"} context`));
|
|
16012
|
+
section("Description", agent.description || "No description provided.");
|
|
16013
|
+
section("Model", agent.model ?? "Inherits the current model");
|
|
16014
|
+
if (agent.fallbackModels?.length)
|
|
16015
|
+
section("Fallbacks", agent.fallbackModels.join(" → "));
|
|
16016
|
+
section("Tools", agent.tools ? agent.tools.join(", ") || "None" : "Inherited tools");
|
|
16017
|
+
if (agent.skills?.length)
|
|
16018
|
+
section("Skills", agent.skills.join(", "));
|
|
16019
|
+
section("Definition", agent.filePath);
|
|
16020
|
+
section("System prompt", agent.systemPrompt || "No additional system prompt.");
|
|
16021
|
+
} else {
|
|
16022
|
+
if (!agents.length)
|
|
16023
|
+
body.push(theme.fg("muted", "No matching agents."), theme.fg("dim", "Try a name, role, or source."));
|
|
16024
|
+
for (const source of sources) {
|
|
16025
|
+
const group = agents.filter((agent) => agent.source === source);
|
|
16026
|
+
if (!group.length)
|
|
16027
|
+
continue;
|
|
16028
|
+
body.push(theme.fg("muted", theme.bold(`${sourceLabels[source]} (${group.length})`)));
|
|
16029
|
+
for (const item of group) {
|
|
16030
|
+
const selected = item === agent;
|
|
16031
|
+
if (selected)
|
|
16032
|
+
selectedRow = body.length;
|
|
16033
|
+
const name = `${selected ? "›" : " "} ${clean(item.name)}`;
|
|
16034
|
+
body.push(selected ? theme.fg("accent", theme.bold(name)) : name);
|
|
16035
|
+
if (selected)
|
|
16036
|
+
body.push(theme.fg("muted", ` ${clean(item.description)}`));
|
|
16037
|
+
}
|
|
16038
|
+
body.push("");
|
|
16039
|
+
}
|
|
16040
|
+
}
|
|
16041
|
+
const pinned = this.detail ? [] : this.search.render(inner);
|
|
16042
|
+
const room = Math.max(1, budget - (framed ? 3 : 2) - pinned.length);
|
|
16043
|
+
this.scroll = Math.min(this.scroll, Math.max(0, body.length - room));
|
|
16044
|
+
const offset = this.detail ? this.scroll : Math.max(0, selectedRow - room + Math.min(2, room));
|
|
16045
|
+
const rows = [...pinned, ...body.slice(offset, offset + room)].map((line) => {
|
|
16046
|
+
const text = truncateToWidth(line, inner);
|
|
16047
|
+
if (!framed)
|
|
16048
|
+
return text;
|
|
16049
|
+
return theme.fg("borderMuted", "│ ") + text + " ".repeat(Math.max(0, inner - visibleWidth(text))) + theme.fg("borderMuted", " │");
|
|
16050
|
+
});
|
|
16051
|
+
const hint = this.detail ? "↑↓ scroll · Enter / Esc back" : "Type to filter · ↑↓ select · Enter details · Esc close";
|
|
16052
|
+
return [
|
|
16053
|
+
framed ? top : heading,
|
|
16054
|
+
...rows,
|
|
16055
|
+
...framed ? [theme.fg("borderMuted", `╰${"─".repeat(Math.max(0, width - 2))}╯`)] : [],
|
|
16056
|
+
theme.fg("dim", hint)
|
|
16057
|
+
].map((line) => truncateToWidth(line, width));
|
|
16058
|
+
}
|
|
16059
|
+
}
|
|
16060
|
+
|
|
15545
16061
|
// dist/builtin/subagents/src/slash/slash-commands.ts
|
|
15546
|
-
function registerSlashCommands(
|
|
16062
|
+
function registerSlashCommands(pi, _state) {
|
|
16063
|
+
pi.registerCommand("agents", {
|
|
16064
|
+
description: "Browse available subagents and inspect their configuration",
|
|
16065
|
+
handler: async (args, ctx) => {
|
|
16066
|
+
if (!ctx.hasUI) {
|
|
16067
|
+
ctx.ui.notify("Use subagent action=list to list agents outside interactive mode.", "info");
|
|
16068
|
+
return;
|
|
16069
|
+
}
|
|
16070
|
+
const { agents } = discoverAgents(ctx.cwd, "both");
|
|
16071
|
+
await ctx.ui.custom((tui, theme, _keys, done) => {
|
|
16072
|
+
const browser = new AgentBrowser(agents, theme, () => done(), () => tui.terminal.rows, args.trim());
|
|
16073
|
+
return browser;
|
|
16074
|
+
}, { purpose: "navigation" });
|
|
16075
|
+
}
|
|
16076
|
+
});
|
|
16077
|
+
}
|
|
15547
16078
|
|
|
15548
16079
|
// dist/builtin/subagents/src/slash/slash-live-state.ts
|
|
15549
16080
|
var defaultStoreOwner = {};
|
|
@@ -15607,16 +16138,16 @@ function clearSlashSnapshots(owner) {
|
|
|
15607
16138
|
}
|
|
15608
16139
|
|
|
15609
16140
|
// dist/builtin/subagents/src/tui/render-layout.ts
|
|
15610
|
-
import { visibleWidth } from "@earendil-works/pi-tui";
|
|
16141
|
+
import { visibleWidth as visibleWidth2 } from "@earendil-works/pi-tui";
|
|
15611
16142
|
function getTermWidth() {
|
|
15612
16143
|
return process.stdout.columns || 120;
|
|
15613
16144
|
}
|
|
15614
16145
|
var segmenter = new Intl.Segmenter(undefined, { granularity: "grapheme" });
|
|
15615
16146
|
function truncLine(text, maxWidth) {
|
|
15616
|
-
if (
|
|
16147
|
+
if (visibleWidth2(text) <= maxWidth)
|
|
15617
16148
|
return text;
|
|
15618
16149
|
const targetWidth = maxWidth - 1;
|
|
15619
|
-
let
|
|
16150
|
+
let result = "";
|
|
15620
16151
|
let currentWidth = 0;
|
|
15621
16152
|
let activeStyles = [];
|
|
15622
16153
|
let i = 0;
|
|
@@ -15624,7 +16155,7 @@ function truncLine(text, maxWidth) {
|
|
|
15624
16155
|
const ansiMatch = text.slice(i).match(/^\x1b\[[0-9;]*m/);
|
|
15625
16156
|
if (ansiMatch) {
|
|
15626
16157
|
const code = ansiMatch[0];
|
|
15627
|
-
|
|
16158
|
+
result += code;
|
|
15628
16159
|
if (code === "\x1B[0m" || code === "\x1B[m") {
|
|
15629
16160
|
activeStyles = [];
|
|
15630
16161
|
} else {
|
|
@@ -15640,16 +16171,16 @@ function truncLine(text, maxWidth) {
|
|
|
15640
16171
|
const textPortion = text.slice(i, end);
|
|
15641
16172
|
for (const seg of segmenter.segment(textPortion)) {
|
|
15642
16173
|
const grapheme = seg.segment;
|
|
15643
|
-
const graphemeWidth =
|
|
16174
|
+
const graphemeWidth = visibleWidth2(grapheme);
|
|
15644
16175
|
if (currentWidth + graphemeWidth > targetWidth) {
|
|
15645
|
-
return `${
|
|
16176
|
+
return `${result + activeStyles.join("")}…`;
|
|
15646
16177
|
}
|
|
15647
|
-
|
|
16178
|
+
result += grapheme;
|
|
15648
16179
|
currentWidth += graphemeWidth;
|
|
15649
16180
|
}
|
|
15650
16181
|
i = end;
|
|
15651
16182
|
}
|
|
15652
|
-
return `${
|
|
16183
|
+
return `${result + activeStyles.join("")}…`;
|
|
15653
16184
|
}
|
|
15654
16185
|
var PULSE_FRAMES = ["·", "•", "●", "•"];
|
|
15655
16186
|
function pulseGlyph(frame) {
|
|
@@ -15657,8 +16188,8 @@ function pulseGlyph(frame) {
|
|
|
15657
16188
|
return PULSE_FRAMES[index % PULSE_FRAMES.length];
|
|
15658
16189
|
}
|
|
15659
16190
|
// dist/builtin/subagents/src/tui/render-result.ts
|
|
15660
|
-
import { getMarkdownTheme, keyHintIfBound as
|
|
15661
|
-
import { Container as Container2, Markdown, Spacer, Text as
|
|
16191
|
+
import { getMarkdownTheme, keyHintIfBound as keyHintIfBound3 } from "@bastani/atomic";
|
|
16192
|
+
import { Container as Container2, Markdown, Spacer, Text as Text3 } from "@earendil-works/pi-tui";
|
|
15662
16193
|
|
|
15663
16194
|
// dist/builtin/subagents/src/tui/render-event-formatting.ts
|
|
15664
16195
|
function modelThinkingBadge(theme, model, thinking) {
|
|
@@ -15694,13 +16225,13 @@ function formatAgentRunningLabel(count) {
|
|
|
15694
16225
|
}
|
|
15695
16226
|
|
|
15696
16227
|
// dist/builtin/subagents/src/tui/render-progress.ts
|
|
15697
|
-
function isDoneResult(
|
|
15698
|
-
const status =
|
|
16228
|
+
function isDoneResult(result) {
|
|
16229
|
+
const status = result.progress?.status;
|
|
15699
16230
|
if (status === "completed")
|
|
15700
16231
|
return true;
|
|
15701
16232
|
if (status === "running" || status === "pending")
|
|
15702
16233
|
return false;
|
|
15703
|
-
if (
|
|
16234
|
+
if (result.interrupted || result.detached || result.status !== "ok")
|
|
15704
16235
|
return false;
|
|
15705
16236
|
return true;
|
|
15706
16237
|
}
|
|
@@ -15714,20 +16245,20 @@ function buildMultiProgressLabel(details, hasRunning) {
|
|
|
15714
16245
|
statuses[progress.index] = progress.status;
|
|
15715
16246
|
}
|
|
15716
16247
|
for (let i = 0;i < details.results.length; i++) {
|
|
15717
|
-
const
|
|
15718
|
-
const progressFromArray = details.progress?.find((progress) => progress.index === i) || details.progress?.find((progress) => progress.agent ===
|
|
15719
|
-
const index =
|
|
16248
|
+
const result = details.results[i];
|
|
16249
|
+
const progressFromArray = details.progress?.find((progress) => progress.index === i) || details.progress?.find((progress) => progress.agent === result.agent && progress.status === "running");
|
|
16250
|
+
const index = result.progress?.index ?? progressFromArray?.index ?? i;
|
|
15720
16251
|
if (index < 0 || index >= totalCount)
|
|
15721
16252
|
continue;
|
|
15722
|
-
const status =
|
|
16253
|
+
const status = result.progress?.status ?? (result.interrupted || result.status === "interrupted" ? "interrupted" : result.detached || result.status === "continued" ? "detached" : result.status === "ok" ? "completed" : "failed");
|
|
15723
16254
|
statuses[index] = status;
|
|
15724
16255
|
}
|
|
15725
16256
|
const running = statuses.filter((status) => status === "running").length;
|
|
15726
|
-
const
|
|
15727
|
-
const cancelled = details.results.filter((
|
|
15728
|
-
const
|
|
16257
|
+
const done = statuses.filter((status) => status === "completed").length;
|
|
16258
|
+
const cancelled = details.results.filter((result) => isParentCancellation(result.cause) && (result.interrupted || result.status === "interrupted")).length;
|
|
16259
|
+
const headerLabel = hasRunning ? `${formatAgentRunningLabel(running)} · ${done}/${totalCount} done` : cancelled > 0 ? `${done}/${totalCount} done · ${cancelled} cancelled` : `${done}/${totalCount} done`;
|
|
15729
16260
|
return {
|
|
15730
|
-
headerLabel
|
|
16261
|
+
headerLabel,
|
|
15731
16262
|
itemTitle,
|
|
15732
16263
|
totalCount,
|
|
15733
16264
|
groupStartIndex: 0,
|
|
@@ -15788,11 +16319,11 @@ function hasEmptyTextOutputWithoutOutputTarget(task, output) {
|
|
|
15788
16319
|
return false;
|
|
15789
16320
|
return !extractOutputTarget(task);
|
|
15790
16321
|
}
|
|
15791
|
-
function getToolCallLines(
|
|
15792
|
-
if (
|
|
15793
|
-
return getDisplayItems(
|
|
16322
|
+
function getToolCallLines(result, expanded) {
|
|
16323
|
+
if (result.messages) {
|
|
16324
|
+
return getDisplayItems(result.messages).filter((item) => item.type === "tool").map((item) => formatToolCall(item.name, item.args, expanded));
|
|
15794
16325
|
}
|
|
15795
|
-
return
|
|
16326
|
+
return result.toolCalls?.map((toolCall) => expanded ? toolCall.expandedText : toolCall.text) ?? [];
|
|
15796
16327
|
}
|
|
15797
16328
|
function snapshotNowForProgress(progress, now) {
|
|
15798
16329
|
if (now !== undefined)
|
|
@@ -15857,33 +16388,33 @@ function firstOutputLine(text) {
|
|
|
15857
16388
|
return text.split(`
|
|
15858
16389
|
`).find((line) => line.trim())?.trim() ?? "";
|
|
15859
16390
|
}
|
|
15860
|
-
function resultStatusLine(
|
|
15861
|
-
if (
|
|
15862
|
-
return
|
|
15863
|
-
if (
|
|
16391
|
+
function resultStatusLine(result, output) {
|
|
16392
|
+
if (result.detached)
|
|
16393
|
+
return result.detachedReason ? `Detached: ${result.detachedReason}` : "Detached";
|
|
16394
|
+
if (result.status === "continued")
|
|
15864
16395
|
return "Continued";
|
|
15865
|
-
if (isParentCancellation(
|
|
16396
|
+
if (isParentCancellation(result.cause) && (result.interrupted || result.status === "interrupted"))
|
|
15866
16397
|
return "Cancelled";
|
|
15867
|
-
if (
|
|
16398
|
+
if (result.interrupted || result.status === "interrupted")
|
|
15868
16399
|
return "Interrupted";
|
|
15869
|
-
if (
|
|
15870
|
-
return
|
|
15871
|
-
if (
|
|
15872
|
-
return `Error: ${
|
|
15873
|
-
if (hasEmptyTextOutputWithoutOutputTarget(
|
|
16400
|
+
if (result.status === "skipped")
|
|
16401
|
+
return result.error ? `Skipped: ${result.error}` : "Skipped";
|
|
16402
|
+
if (result.status === "error")
|
|
16403
|
+
return `Error: ${result.error ?? (firstOutputLine(output) || "failed")}`;
|
|
16404
|
+
if (hasEmptyTextOutputWithoutOutputTarget(result.task, output))
|
|
15874
16405
|
return "Done (no text output)";
|
|
15875
16406
|
return "Done";
|
|
15876
16407
|
}
|
|
15877
|
-
function resultGlyph(
|
|
16408
|
+
function resultGlyph(result, output, theme, running = result.progress?.status === "running", pulseFrame) {
|
|
15878
16409
|
if (running)
|
|
15879
16410
|
return theme.fg("accent", pulseGlyph(pulseFrame));
|
|
15880
|
-
if (
|
|
16411
|
+
if (result.detached || result.status === "continued")
|
|
15881
16412
|
return theme.fg("warning", "■");
|
|
15882
|
-
if (
|
|
16413
|
+
if (result.interrupted || result.status === "interrupted" || result.status === "skipped")
|
|
15883
16414
|
return theme.fg("warning", "■");
|
|
15884
|
-
if (
|
|
16415
|
+
if (result.status === "error")
|
|
15885
16416
|
return theme.fg("error", "✗");
|
|
15886
|
-
if (hasEmptyTextOutputWithoutOutputTarget(
|
|
16417
|
+
if (hasEmptyTextOutputWithoutOutputTarget(result.task, output))
|
|
15887
16418
|
return theme.fg("warning", "✓");
|
|
15888
16419
|
return theme.fg("success", "✓");
|
|
15889
16420
|
}
|
|
@@ -16011,10 +16542,10 @@ function renderMultiCompact(d, theme, now, pulseFrame) {
|
|
|
16011
16542
|
const stepNumber = r.progress?.index !== undefined ? r.progress.index + 1 : progressFromArray?.index !== undefined ? progressFromArray.index + 1 : i + 1;
|
|
16012
16543
|
const stepStats = formatProgressStats(theme, rProg, true, now);
|
|
16013
16544
|
const modelDisplay = modelThinkingBadge(theme, r.model ?? rProg?.model, r.thinking ?? rProg?.thinking);
|
|
16014
|
-
const
|
|
16545
|
+
const glyph = rPending ? theme.fg("dim", "◦") : resultGlyph(r, output, theme, rRunning, pulseFrame);
|
|
16015
16546
|
const pendingLabel = rPending ? ` ${theme.fg("dim", "· pending")}` : "";
|
|
16016
16547
|
const stepLabel = resultRowLabel(d, multiLabel, i, stepNumber);
|
|
16017
|
-
const line = `${
|
|
16548
|
+
const line = `${glyph} ${stepLabel}: ${themeBold(theme, agentName)}${modelDisplay}${stepStats ? ` ${theme.fg("dim", "·")} ${stepStats}` : ""}${pendingLabel}`;
|
|
16018
16549
|
c.addChild(new Text(truncLine(` ${line}`, width), 0, 0));
|
|
16019
16550
|
if (rRunning && rProg && "status" in rProg) {
|
|
16020
16551
|
const activity = compactCurrentActivity(rProg, now);
|
|
@@ -16061,10 +16592,10 @@ function progressRenderKey(progress) {
|
|
|
16061
16592
|
progress.currentPath ?? ""
|
|
16062
16593
|
].join(":");
|
|
16063
16594
|
}
|
|
16064
|
-
function subagentResultRenderKey(
|
|
16065
|
-
const details =
|
|
16595
|
+
function subagentResultRenderKey(result, options) {
|
|
16596
|
+
const details = result.details;
|
|
16066
16597
|
if (!details)
|
|
16067
|
-
return `${options.isPartial ? "partial" : "final"}:${
|
|
16598
|
+
return `${options.isPartial ? "partial" : "final"}:${result.content.length}`;
|
|
16068
16599
|
const progressKeys = [
|
|
16069
16600
|
...(details.progress ?? []).map(progressRenderKey),
|
|
16070
16601
|
...details.results.map((entry) => [
|
|
@@ -16088,22 +16619,89 @@ function subagentResultRenderKey(result2, options) {
|
|
|
16088
16619
|
].join("|");
|
|
16089
16620
|
}
|
|
16090
16621
|
|
|
16622
|
+
// dist/builtin/subagents/src/tui/render-status.ts
|
|
16623
|
+
import { keyHintIfBound as keyHintIfBound2 } from "@bastani/atomic";
|
|
16624
|
+
import { stripTerminalSequences, Text as Text2, truncateToWidth as truncateToWidth2, visibleWidth as visibleWidth3 } from "@earendil-works/pi-tui";
|
|
16625
|
+
var COMPACT_CHILD_LIMIT = 6;
|
|
16626
|
+
var statusStyles = {
|
|
16627
|
+
pending: { glyph: "○", label: "Pending", color: "dim" },
|
|
16628
|
+
running: { glyph: "∀", label: "Running", color: "accent" },
|
|
16629
|
+
ok: { glyph: "✓", label: "Completed", color: "success" },
|
|
16630
|
+
error: { glyph: "✗", label: "Failed", color: "error" },
|
|
16631
|
+
interrupted: { glyph: "■", label: "Interrupted", color: "warning" },
|
|
16632
|
+
continued: { glyph: "■", label: "Continued", color: "warning" }
|
|
16633
|
+
};
|
|
16634
|
+
var displayText = (value) => stripTerminalSequences(value).replace(/[\x00-\x1f\x7f-\x9f]/g, " ");
|
|
16635
|
+
function childStatusLines(child, expanded, theme, width) {
|
|
16636
|
+
const style = statusStyles[child.status];
|
|
16637
|
+
const name = displayText(child.path.split("/").at(-1) || child.taskName);
|
|
16638
|
+
const label = expanded ? name : displayText(truncateToWidth2(name, Math.max(1, width - visibleWidth3(style.label) - 5), "…"));
|
|
16639
|
+
const heading = `${theme.fg(style.color, style.glyph)} ${theme.fg("toolTitle", theme.bold(label))}${theme.fg("dim", " · ")}${theme.fg(style.color, style.label)}`;
|
|
16640
|
+
const model = formatModelThinking(child.model, child.thinking);
|
|
16641
|
+
const metadata = model ? [theme.fg("dim", ` ${displayText(model)}`)] : [];
|
|
16642
|
+
if (!expanded)
|
|
16643
|
+
return [heading, ...metadata];
|
|
16644
|
+
return [
|
|
16645
|
+
heading,
|
|
16646
|
+
...metadata,
|
|
16647
|
+
theme.fg("dim", ` Path: ${displayText(child.path)}`),
|
|
16648
|
+
theme.fg("dim", ` Parent: ${displayText(child.parentPath)} · Depth: ${child.depth}`),
|
|
16649
|
+
theme.fg("dim", ` Task: ${displayText(child.taskName)}`),
|
|
16650
|
+
theme.fg("dim", ` Residency: ${child.loaded ? "loaded" : "cold"}`),
|
|
16651
|
+
...child.cause ? [theme.fg("muted", ` Cause: ${displayText(child.cause)}`)] : [],
|
|
16652
|
+
...child.sessionFile ? [theme.fg("dim", ` Session: ${displayText(child.sessionFile)}`)] : []
|
|
16653
|
+
];
|
|
16654
|
+
}
|
|
16655
|
+
function statusLines(groups, expanded, theme, width) {
|
|
16656
|
+
const total = groups.reduce((sum, group) => sum + group.children.length, 0);
|
|
16657
|
+
const lines = total > 1 ? [theme.fg("muted", `${total} agents`)] : [];
|
|
16658
|
+
let shown = 0;
|
|
16659
|
+
for (const group of groups) {
|
|
16660
|
+
const children = expanded ? group.children : group.children.slice(0, COMPACT_CHILD_LIMIT - shown);
|
|
16661
|
+
if (!children.length && !expanded)
|
|
16662
|
+
continue;
|
|
16663
|
+
if (groups.length > 1 || !children.length)
|
|
16664
|
+
lines.push(theme.fg("dim", `Run ${displayText(group.parentPath)}`));
|
|
16665
|
+
lines.push(...children.length ? children.flatMap((child) => childStatusLines(child, expanded, theme, width)) : [theme.fg("muted", " No subagents")]);
|
|
16666
|
+
shown += children.length;
|
|
16667
|
+
}
|
|
16668
|
+
if (!lines.length)
|
|
16669
|
+
lines.push(theme.fg("muted", "No subagents"));
|
|
16670
|
+
if (shown < total)
|
|
16671
|
+
lines.push(theme.fg("muted", `… ${total - shown} more agents`));
|
|
16672
|
+
const hint = !expanded && keyHintIfBound2("app.tools.expand", "to expand");
|
|
16673
|
+
if (hint)
|
|
16674
|
+
lines.push(theme.fg("dim", hint));
|
|
16675
|
+
return lines;
|
|
16676
|
+
}
|
|
16677
|
+
function renderSubagentStatus(groups, expanded, theme) {
|
|
16678
|
+
return {
|
|
16679
|
+
invalidate() {},
|
|
16680
|
+
render(width) {
|
|
16681
|
+
if (width <= 0)
|
|
16682
|
+
return [];
|
|
16683
|
+
return new Text2(statusLines(groups, expanded, theme, width).join(`
|
|
16684
|
+
`), 0, 0).render(width);
|
|
16685
|
+
}
|
|
16686
|
+
};
|
|
16687
|
+
}
|
|
16688
|
+
|
|
16091
16689
|
// dist/builtin/subagents/src/tui/render-result.ts
|
|
16092
|
-
function parentAskOutput(
|
|
16093
|
-
if (!
|
|
16690
|
+
function parentAskOutput(result) {
|
|
16691
|
+
if (!result.details?.parentAskYielded)
|
|
16094
16692
|
return;
|
|
16095
|
-
return
|
|
16693
|
+
return result.content.find((part) => part.type === "text")?.text;
|
|
16096
16694
|
}
|
|
16097
16695
|
function appendParentAskOutput(component, output, theme) {
|
|
16098
16696
|
if (!output)
|
|
16099
16697
|
return component;
|
|
16100
16698
|
const container = new Container2;
|
|
16101
16699
|
container.addChild(component);
|
|
16102
|
-
container.addChild(new
|
|
16700
|
+
container.addChild(new Text3(theme.fg("accent", output), 0, 0));
|
|
16103
16701
|
return container;
|
|
16104
16702
|
}
|
|
16105
|
-
function renderLiveSubagentResult(
|
|
16106
|
-
const nextKey = subagentResultRenderKey(
|
|
16703
|
+
function renderLiveSubagentResult(result, options, theme, context) {
|
|
16704
|
+
const nextKey = subagentResultRenderKey(result, options);
|
|
16107
16705
|
if (context.state.subagentResultSnapshotKey !== nextKey) {
|
|
16108
16706
|
context.state.subagentResultSnapshotKey = nextKey;
|
|
16109
16707
|
context.state.subagentResultSnapshotNow = Date.now();
|
|
@@ -16112,110 +16710,112 @@ function renderLiveSubagentResult(result2, options, theme, context) {
|
|
|
16112
16710
|
context.state.subagentResultSnapshotNow ??= Date.now();
|
|
16113
16711
|
context.state.subagentResultPulseFrame ??= 0;
|
|
16114
16712
|
clearResultAnimationTimer(context);
|
|
16115
|
-
return renderSubagentResult(
|
|
16713
|
+
return renderSubagentResult(result, {
|
|
16116
16714
|
...options,
|
|
16117
16715
|
now: context.state.subagentResultSnapshotNow,
|
|
16118
16716
|
pulseFrame: context.state.subagentResultPulseFrame
|
|
16119
16717
|
}, theme);
|
|
16120
16718
|
}
|
|
16121
|
-
function renderSubagentResult(
|
|
16122
|
-
const d =
|
|
16719
|
+
function renderSubagentResult(result, options, theme) {
|
|
16720
|
+
const d = result.details;
|
|
16721
|
+
if (d?.statusGroups)
|
|
16722
|
+
return renderSubagentStatus(d.statusGroups, options.expanded, theme);
|
|
16123
16723
|
const liveMultiProgress = d?.mode === "parallel" && (d?.progress?.length ?? 0) > 0;
|
|
16124
16724
|
if (!d?.results.length && !liveMultiProgress) {
|
|
16125
|
-
const t =
|
|
16725
|
+
const t = result.content[0];
|
|
16126
16726
|
const text = t?.type === "text" ? t.text : "(no output)";
|
|
16127
16727
|
const contextPrefix = d?.context === "fork" ? `${theme.fg("warning", "[fork]")} ` : "";
|
|
16128
|
-
return new
|
|
16728
|
+
return new Text3(truncLine(`${contextPrefix}${text}`, getTermWidth() - 4), 0, 0);
|
|
16129
16729
|
}
|
|
16130
16730
|
const expanded = options.expanded;
|
|
16131
16731
|
const mdTheme = getMarkdownTheme();
|
|
16132
|
-
const handoffOutput = parentAskOutput(
|
|
16732
|
+
const handoffOutput = parentAskOutput(result);
|
|
16133
16733
|
if (d.mode === "single" && d.results.length === 1) {
|
|
16134
16734
|
const r = d.results[0];
|
|
16135
16735
|
if (!expanded)
|
|
16136
16736
|
return appendParentAskOutput(renderSingleCompact(d, r, theme, options.now, options.pulseFrame), handoffOutput, theme);
|
|
16137
16737
|
const isRunning = r.progress?.status === "running";
|
|
16138
|
-
const
|
|
16139
|
-
const
|
|
16738
|
+
const icon = isRunning ? theme.fg("warning", "running") : d.parentAskYielded ? theme.fg("warning", "yielded") : r.detached || r.status === "continued" ? theme.fg("warning", "detached") : isParentCancellation(r.cause) && (r.interrupted || r.status === "interrupted") ? theme.fg("warning", "cancelled") : r.status === "ok" ? theme.fg("success", "ok") : theme.fg("error", "failed");
|
|
16739
|
+
const contextBadge = d.context === "fork" ? theme.fg("warning", " [fork]") : "";
|
|
16140
16740
|
const output = r.truncation?.text || getSingleResultOutput(r);
|
|
16141
16741
|
const progressInfo = isRunning && r.progress ? ` | ${r.progress.toolCount} tools, ${formatTokens(r.progress.tokens)} tok, ${formatDuration(displayProgressDurationMs(r.progress, options.now))}` : r.progressSummary ? ` | ${r.progressSummary.toolCount} tools, ${formatTokens(r.progressSummary.tokens)} tok, ${formatDuration(r.progressSummary.durationMs)}` : "";
|
|
16142
|
-
const
|
|
16143
|
-
const
|
|
16742
|
+
const w = getTermWidth() - 4;
|
|
16743
|
+
const fit = (text) => expanded ? text : truncLine(text, w);
|
|
16144
16744
|
const modelDisplay = modelThinkingBadge(theme, r.model, r.thinking);
|
|
16145
16745
|
const toolCallLines = getToolCallLines(r, expanded);
|
|
16146
|
-
const
|
|
16147
|
-
|
|
16148
|
-
|
|
16149
|
-
const taskMaxLen = Math.max(20,
|
|
16746
|
+
const c = new Container2;
|
|
16747
|
+
c.addChild(new Text3(fit(`${icon} ${theme.fg("toolTitle", theme.bold(r.agent))}${modelDisplay}${contextBadge}${progressInfo}`), 0, 0));
|
|
16748
|
+
c.addChild(new Spacer(1));
|
|
16749
|
+
const taskMaxLen = Math.max(20, w - 8);
|
|
16150
16750
|
const taskPreview = expanded || r.task.length <= taskMaxLen ? r.task : `${r.task.slice(0, taskMaxLen)}...`;
|
|
16151
|
-
|
|
16152
|
-
|
|
16751
|
+
c.addChild(new Text3(fit(theme.fg("dim", `Task: ${taskPreview}`)), 0, 0));
|
|
16752
|
+
c.addChild(new Spacer(1));
|
|
16153
16753
|
if (isRunning && r.progress) {
|
|
16154
16754
|
const progressSnapshotNow = snapshotNowForProgress(r.progress, options.now);
|
|
16155
|
-
const toolLine = formatCurrentToolLine(r.progress,
|
|
16755
|
+
const toolLine = formatCurrentToolLine(r.progress, w, expanded, progressSnapshotNow);
|
|
16156
16756
|
if (toolLine) {
|
|
16157
|
-
|
|
16757
|
+
c.addChild(new Text3(fit(theme.fg("warning", `> ${toolLine}`)), 0, 0));
|
|
16158
16758
|
}
|
|
16159
16759
|
const liveStatusLine = buildLiveStatusLine(r.progress, progressSnapshotNow);
|
|
16160
16760
|
if (liveStatusLine) {
|
|
16161
|
-
|
|
16761
|
+
c.addChild(new Text3(fit(theme.fg("accent", liveStatusLine)), 0, 0));
|
|
16162
16762
|
}
|
|
16163
|
-
const expandHint =
|
|
16763
|
+
const expandHint = keyHintIfBound3("app.tools.expand", "for live detail");
|
|
16164
16764
|
if (expandHint)
|
|
16165
|
-
|
|
16765
|
+
c.addChild(new Text3(fit(theme.fg("accent", `Press ${expandHint}`)), 0, 0));
|
|
16166
16766
|
if (r.artifactPaths) {
|
|
16167
|
-
|
|
16767
|
+
c.addChild(new Text3(fit(theme.fg("dim", `Artifacts: ${shortenPath(r.artifactPaths.outputPath)}`)), 0, 0));
|
|
16168
16768
|
}
|
|
16169
16769
|
if (r.progress.recentTools?.length) {
|
|
16170
16770
|
for (const t of r.progress.recentTools.slice(-3)) {
|
|
16171
|
-
const maxArgsLen = Math.max(40,
|
|
16771
|
+
const maxArgsLen = Math.max(40, w - 24);
|
|
16172
16772
|
const argsPreview = expanded || t.args.length <= maxArgsLen ? t.args : `${t.args.slice(0, maxArgsLen)}...`;
|
|
16173
|
-
|
|
16773
|
+
c.addChild(new Text3(fit(theme.fg("dim", `${t.tool}: ${argsPreview}`)), 0, 0));
|
|
16174
16774
|
}
|
|
16175
16775
|
}
|
|
16176
16776
|
for (const line of (r.progress.recentOutput ?? []).slice(-5)) {
|
|
16177
|
-
|
|
16777
|
+
c.addChild(new Text3(fit(theme.fg("dim", ` ${line}`)), 0, 0));
|
|
16178
16778
|
}
|
|
16179
16779
|
if (toolLine || liveStatusLine || r.progress.recentTools?.length || r.progress.recentOutput?.length || r.artifactPaths) {
|
|
16180
|
-
|
|
16780
|
+
c.addChild(new Spacer(1));
|
|
16181
16781
|
}
|
|
16182
16782
|
}
|
|
16183
16783
|
if (expanded) {
|
|
16184
16784
|
for (const line of toolCallLines) {
|
|
16185
|
-
|
|
16785
|
+
c.addChild(new Text3(fit(theme.fg("muted", line)), 0, 0));
|
|
16186
16786
|
}
|
|
16187
16787
|
if (toolCallLines.length)
|
|
16188
|
-
|
|
16788
|
+
c.addChild(new Spacer(1));
|
|
16189
16789
|
}
|
|
16190
16790
|
if (output)
|
|
16191
|
-
|
|
16192
|
-
|
|
16791
|
+
c.addChild(new Markdown(output, 0, 0, mdTheme));
|
|
16792
|
+
c.addChild(new Spacer(1));
|
|
16193
16793
|
if (r.skills?.length) {
|
|
16194
|
-
|
|
16794
|
+
c.addChild(new Text3(fit(theme.fg("dim", `Skills: ${r.skills.join(", ")}`)), 0, 0));
|
|
16195
16795
|
}
|
|
16196
16796
|
if (r.skillsWarning) {
|
|
16197
|
-
|
|
16797
|
+
c.addChild(new Text3(fit(theme.fg("warning", `Warning: ${r.skillsWarning}`)), 0, 0));
|
|
16198
16798
|
}
|
|
16199
16799
|
if (r.attemptedModels && r.attemptedModels.length > 1) {
|
|
16200
|
-
|
|
16800
|
+
c.addChild(new Text3(fit(theme.fg("dim", `Fallbacks: ${r.attemptedModels.join(" → ")}`)), 0, 0));
|
|
16201
16801
|
}
|
|
16202
|
-
|
|
16802
|
+
c.addChild(new Text3(fit(theme.fg("dim", formatUsage(r.usage))), 0, 0));
|
|
16203
16803
|
if (r.sessionFile) {
|
|
16204
|
-
|
|
16804
|
+
c.addChild(new Text3(fit(theme.fg("dim", `Session: ${shortenPath(r.sessionFile)}`)), 0, 0));
|
|
16205
16805
|
}
|
|
16206
16806
|
if (!isRunning && r.artifactPaths) {
|
|
16207
|
-
|
|
16208
|
-
|
|
16807
|
+
c.addChild(new Spacer(1));
|
|
16808
|
+
c.addChild(new Text3(fit(theme.fg("dim", `Artifacts: ${shortenPath(r.artifactPaths.outputPath)}`)), 0, 0));
|
|
16209
16809
|
}
|
|
16210
|
-
return appendParentAskOutput(
|
|
16810
|
+
return appendParentAskOutput(c, handoffOutput, theme);
|
|
16211
16811
|
}
|
|
16212
16812
|
if (!expanded)
|
|
16213
16813
|
return appendParentAskOutput(renderMultiCompact(d, theme, options.now, options.pulseFrame), handoffOutput, theme);
|
|
16214
16814
|
const hasRunning = d.progress?.some((p) => p.status === "running") || d.results.some((r) => r.progress?.status === "running");
|
|
16215
16815
|
const ok = d.results.filter((r) => r.progress?.status === "completed" || r.status === "ok" && r.progress?.status !== "running").length;
|
|
16216
16816
|
const hasEmptyWithoutTarget = d.results.some((r) => r.status === "ok" && r.progress?.status !== "running" && hasEmptyTextOutputWithoutOutputTarget(r.task, getSingleResultOutput(r)));
|
|
16217
|
-
const hasCancelled = d.results.some((
|
|
16218
|
-
const icon = hasRunning ? theme.fg("warning", "running") : d.parentAskYielded ? theme.fg("warning", "yielded") : hasEmptyWithoutTarget ? theme.fg("warning", "warning") : ok === d.results.length ? theme.fg("success", "ok") : d.results.some((
|
|
16817
|
+
const hasCancelled = d.results.some((result) => isParentCancellation(result.cause) && (result.interrupted || result.status === "interrupted"));
|
|
16818
|
+
const icon = hasRunning ? theme.fg("warning", "running") : d.parentAskYielded ? theme.fg("warning", "yielded") : hasEmptyWithoutTarget ? theme.fg("warning", "warning") : ok === d.results.length ? theme.fg("success", "ok") : d.results.some((result) => result.status === "error") ? theme.fg("error", "failed") : hasCancelled ? theme.fg("warning", "cancelled") : theme.fg("error", "failed");
|
|
16219
16819
|
const totalSummary = d.progressSummary || d.results.reduce((acc, r) => {
|
|
16220
16820
|
const prog = r.progress || r.progressSummary;
|
|
16221
16821
|
if (prog) {
|
|
@@ -16232,7 +16832,7 @@ function renderSubagentResult(result2, options, theme) {
|
|
|
16232
16832
|
const w = getTermWidth() - 4;
|
|
16233
16833
|
const fit = (text) => expanded ? text : truncLine(text, w);
|
|
16234
16834
|
const c = new Container2;
|
|
16235
|
-
c.addChild(new
|
|
16835
|
+
c.addChild(new Text3(fit(`${icon} ${theme.fg("toolTitle", theme.bold(modeLabel))}${contextBadge} · ${multiLabel.headerLabel}${summaryStr}`), 0, 0));
|
|
16236
16836
|
const progressSpan = d.progress?.length ? Math.max(...d.progress.map((p) => p.index + 1)) : 0;
|
|
16237
16837
|
const resultsSpan = Math.max(d.results.length, progressSpan, d.mode === "parallel" ? d.totalSteps ?? 0 : 0);
|
|
16238
16838
|
const displayStart = multiLabel.showActiveGroupOnly ? multiLabel.groupStartIndex : 0;
|
|
@@ -16260,20 +16860,20 @@ function renderSubagentResult(result2, options, theme) {
|
|
|
16260
16860
|
if (runningProg) {
|
|
16261
16861
|
const runningStats = ` | ${runningProg.toolCount} tools, ${formatDuration(displayProgressDurationMs(runningProg, options.now))}`;
|
|
16262
16862
|
const runningBadge = modelThinkingBadge(theme, runningProg.model, runningProg.thinking);
|
|
16263
|
-
c.addChild(new
|
|
16863
|
+
c.addChild(new Text3(fit(`${theme.fg("warning", "running")} ${rowLabel}: ${theme.bold(theme.fg("warning", agentName))}${runningBadge}${runningStats}`), 0, 0));
|
|
16264
16864
|
const progressSnapshotNow = snapshotNowForProgress(runningProg, options.now);
|
|
16265
16865
|
const liveStatusLine = buildLiveStatusLine(runningProg, progressSnapshotNow);
|
|
16266
16866
|
if (liveStatusLine) {
|
|
16267
|
-
c.addChild(new
|
|
16867
|
+
c.addChild(new Text3(fit(theme.fg("accent", ` ${liveStatusLine}`)), 0, 0));
|
|
16268
16868
|
}
|
|
16269
|
-
const expandHint =
|
|
16869
|
+
const expandHint = keyHintIfBound3("app.tools.expand", "for live detail");
|
|
16270
16870
|
if (expandHint)
|
|
16271
|
-
c.addChild(new
|
|
16871
|
+
c.addChild(new Text3(fit(theme.fg("accent", ` Press ${expandHint}`)), 0, 0));
|
|
16272
16872
|
c.addChild(new Spacer(1));
|
|
16273
16873
|
continue;
|
|
16274
16874
|
}
|
|
16275
|
-
c.addChild(new
|
|
16276
|
-
c.addChild(new
|
|
16875
|
+
c.addChild(new Text3(fit(theme.fg("dim", ` ${rowLabel}: ${agentName}`)), 0, 0));
|
|
16876
|
+
c.addChild(new Text3(theme.fg("dim", ` status: pending`), 0, 0));
|
|
16277
16877
|
c.addChild(new Spacer(1));
|
|
16278
16878
|
continue;
|
|
16279
16879
|
}
|
|
@@ -16288,60 +16888,60 @@ function renderSubagentResult(result2, options, theme) {
|
|
|
16288
16888
|
const stepLabel = resultRowLabel(d, multiLabel, i, stepNumber);
|
|
16289
16889
|
const stepHeader = rRunning ? `${statusIcon} ${stepLabel}: ${theme.bold(theme.fg("warning", r.agent))}${modelDisplay}${stats}` : `${statusIcon} ${stepLabel}: ${theme.bold(r.agent)}${modelDisplay}${stats}`;
|
|
16290
16890
|
const toolCallLines = getToolCallLines(r, expanded);
|
|
16291
|
-
c.addChild(new
|
|
16891
|
+
c.addChild(new Text3(fit(stepHeader), 0, 0));
|
|
16292
16892
|
const taskMaxLen = Math.max(20, w - 12);
|
|
16293
16893
|
const taskPreview = expanded || r.task.length <= taskMaxLen ? r.task : `${r.task.slice(0, taskMaxLen)}...`;
|
|
16294
|
-
c.addChild(new
|
|
16894
|
+
c.addChild(new Text3(fit(theme.fg("dim", ` task: ${taskPreview}`)), 0, 0));
|
|
16295
16895
|
const outputTarget = extractOutputTarget(r.task);
|
|
16296
16896
|
if (outputTarget) {
|
|
16297
|
-
c.addChild(new
|
|
16897
|
+
c.addChild(new Text3(fit(theme.fg("dim", ` output: ${outputTarget}`)), 0, 0));
|
|
16298
16898
|
}
|
|
16299
16899
|
if (r.skills?.length) {
|
|
16300
|
-
c.addChild(new
|
|
16900
|
+
c.addChild(new Text3(fit(theme.fg("dim", ` skills: ${r.skills.join(", ")}`)), 0, 0));
|
|
16301
16901
|
}
|
|
16302
16902
|
if (r.skillsWarning) {
|
|
16303
|
-
c.addChild(new
|
|
16903
|
+
c.addChild(new Text3(fit(theme.fg("warning", ` Warning: ${r.skillsWarning}`)), 0, 0));
|
|
16304
16904
|
}
|
|
16305
16905
|
if (r.attemptedModels && r.attemptedModels.length > 1) {
|
|
16306
|
-
c.addChild(new
|
|
16906
|
+
c.addChild(new Text3(fit(theme.fg("dim", ` fallbacks: ${r.attemptedModels.join(" → ")}`)), 0, 0));
|
|
16307
16907
|
}
|
|
16308
16908
|
if (rRunning && rProg) {
|
|
16309
16909
|
if (rProg.skills?.length) {
|
|
16310
|
-
c.addChild(new
|
|
16910
|
+
c.addChild(new Text3(fit(theme.fg("accent", ` skills: ${rProg.skills.join(", ")}`)), 0, 0));
|
|
16311
16911
|
}
|
|
16312
16912
|
const progressSnapshotNow = snapshotNowForProgress(rProg, options.now);
|
|
16313
16913
|
const toolLine = formatCurrentToolLine(rProg, w, expanded, progressSnapshotNow);
|
|
16314
16914
|
if (toolLine) {
|
|
16315
|
-
c.addChild(new
|
|
16915
|
+
c.addChild(new Text3(fit(theme.fg("warning", ` > ${toolLine}`)), 0, 0));
|
|
16316
16916
|
}
|
|
16317
16917
|
const liveStatusLine = buildLiveStatusLine(rProg, progressSnapshotNow);
|
|
16318
16918
|
if (liveStatusLine) {
|
|
16319
|
-
c.addChild(new
|
|
16919
|
+
c.addChild(new Text3(fit(theme.fg("accent", ` ${liveStatusLine}`)), 0, 0));
|
|
16320
16920
|
}
|
|
16321
|
-
const expandHint =
|
|
16921
|
+
const expandHint = keyHintIfBound3("app.tools.expand", "for live detail");
|
|
16322
16922
|
if (expandHint)
|
|
16323
|
-
c.addChild(new
|
|
16923
|
+
c.addChild(new Text3(fit(theme.fg("accent", ` Press ${expandHint}`)), 0, 0));
|
|
16324
16924
|
if (r.artifactPaths) {
|
|
16325
|
-
c.addChild(new
|
|
16925
|
+
c.addChild(new Text3(fit(theme.fg("dim", ` artifacts: ${shortenPath(r.artifactPaths.outputPath)}`)), 0, 0));
|
|
16326
16926
|
}
|
|
16327
16927
|
if (rProg.recentTools?.length) {
|
|
16328
16928
|
for (const t of rProg.recentTools.slice(-3)) {
|
|
16329
16929
|
const maxArgsLen = Math.max(40, w - 30);
|
|
16330
16930
|
const argsPreview = expanded || t.args.length <= maxArgsLen ? t.args : `${t.args.slice(0, maxArgsLen)}...`;
|
|
16331
|
-
c.addChild(new
|
|
16931
|
+
c.addChild(new Text3(fit(theme.fg("dim", ` ${t.tool}: ${argsPreview}`)), 0, 0));
|
|
16332
16932
|
}
|
|
16333
16933
|
}
|
|
16334
16934
|
const recentLines = (rProg.recentOutput ?? []).slice(-5);
|
|
16335
16935
|
for (const line of recentLines) {
|
|
16336
|
-
c.addChild(new
|
|
16936
|
+
c.addChild(new Text3(fit(theme.fg("dim", ` ${line}`)), 0, 0));
|
|
16337
16937
|
}
|
|
16338
16938
|
}
|
|
16339
16939
|
if (!rRunning && r.artifactPaths) {
|
|
16340
|
-
c.addChild(new
|
|
16940
|
+
c.addChild(new Text3(fit(theme.fg("dim", ` artifacts: ${shortenPath(r.artifactPaths.outputPath)}`)), 0, 0));
|
|
16341
16941
|
}
|
|
16342
16942
|
if (expanded && !rRunning) {
|
|
16343
16943
|
for (const line of toolCallLines) {
|
|
16344
|
-
c.addChild(new
|
|
16944
|
+
c.addChild(new Text3(fit(theme.fg("muted", ` ${line}`)), 0, 0));
|
|
16345
16945
|
}
|
|
16346
16946
|
if (toolCallLines.length)
|
|
16347
16947
|
c.addChild(new Spacer(1));
|
|
@@ -16350,7 +16950,7 @@ function renderSubagentResult(result2, options, theme) {
|
|
|
16350
16950
|
}
|
|
16351
16951
|
if (d.artifacts) {
|
|
16352
16952
|
c.addChild(new Spacer(1));
|
|
16353
|
-
c.addChild(new
|
|
16953
|
+
c.addChild(new Text3(fit(theme.fg("dim", `Artifacts dir: ${shortenPath(d.artifacts.dir)}`)), 0, 0));
|
|
16354
16954
|
}
|
|
16355
16955
|
return appendParentAskOutput(c, handoffOutput, theme);
|
|
16356
16956
|
}
|
|
@@ -16463,11 +17063,12 @@ function parseSubagentNotifyContent(content) {
|
|
|
16463
17063
|
var DEFAULT_PROMPT_GUIDANCE = [
|
|
16464
17064
|
`**Subagent orchestration**: Use subagents for focused specialist work inside workflows or as bounded delegation when a workflow would be unnecessary overhead.
|
|
16465
17065
|
- Unless the user explicitly chooses inline execution for the specified task, workflows are the default for non-trivial structured work with verifiable objectives; use a workflow for implementation, review, or retry pipelines and let its stages delegate specialists.
|
|
16466
|
-
- Explicit requests such as "inline", "do this directly", or "don't use a workflow", and equivalent wording, override that default even for complex tasks. Do not create or launch a hidden/nested workflow or pressure the user to reapprove the choice. Preserve appropriate testing, review and evidence inline, and unrelated safety and authorization constraints. Apply the preference only to the specified task. Quoted examples and questions about inline code are not execution-mode instructions.
|
|
17066
|
+
- Explicit requests such as "quickly", "inline", "do this directly", or "don't use a workflow", and equivalent wording, override that default even for complex tasks. Treat "quickly" as an inline execution choice, not a request for a faster workflow. Do not create or launch a hidden/nested workflow or pressure the user to reapprove the choice. Preserve appropriate testing, review and evidence inline, and unrelated safety and authorization constraints. Apply the preference only to the specified task. Quoted examples and questions about inline code are not execution-mode instructions; neither are descriptions of software that should run quickly.
|
|
16467
17067
|
- On a switch from an active workflow to inline, notify the controlling session to safely hold/stop the affected run, reconcile completed work and in-flight side effects, then continue inline without duplicate execution. Do not claim completed work was undone.
|
|
16468
17068
|
- Use a single subagent for a focused specialty or parallel tasks for independent work. Keep substantial-overlap tasks together rather than duplicating investigation across agents.
|
|
16469
17069
|
- Delegate noisy or context-heavy command investigation when isolation helps, but run concise commands inline when that is simpler.
|
|
16470
|
-
-
|
|
17070
|
+
- Background subagents are supported in owner-bound sessions: omitted wait or wait:{kind:"background"} yields after admission while the child continues. Use wait:{kind:"foreground",budgetMs:30000} for foreground-first observation. A yielded observation never means the task stopped. Do not duplicate delegated work; observe the existing task or await its completion notice. The UI shows compact status below the prompt, and /tasks opens inspection only when invoked.
|
|
17071
|
+
- Choose foreground-first or background observation for each authorized call based on whether the next action needs the result; do not ask the user merely to select a mode. Foreground observation automatically yields on budget expiry while the same task continues. Wait for terminal completion before starting dependent work. Execution mode does not bypass tool permissions, delegation boundaries, or owner lifetime.
|
|
16471
17072
|
- Use the debugger subagent for actual failures that need reproduction, root-cause diagnosis, and a validated fix; additional debugger or research delegates are optional when they add a distinct useful angle.
|
|
16472
17073
|
- Let each named agent use its declared model and fallback policy: omit the explicit model argument unless the user requests an exact model or a documented task requirement needs one, and record the reason for any override before launch. Do not choose an ad hoc model merely for diversity.
|
|
16473
17074
|
- If an agent has no declared model or fallback policy, consult packages/coding-agent/docs/models/model-selection.md for the role's Pareto-efficient recommendations and packages/coding-agent/docs/models/evals.md for the measured per-evaluation scores by task type, then use workflow({ action: "models" }) when available to inspect the configured catalog. Pin only a returned fullId and only append a thinking level listed for that entry. If the catalog tool is unavailable, the catalog is empty, or no recommended model is present, leave the child unpinned and state the limitation rather than inventing a model. Do not inspect credentials or infer why a model is absent.
|
|
@@ -16546,6 +17147,14 @@ var ControlOverrides = Type.Object({
|
|
|
16546
17147
|
}))
|
|
16547
17148
|
});
|
|
16548
17149
|
var SubagentParams = Type.Object({
|
|
17150
|
+
wait: Type.Optional(Type.Object({
|
|
17151
|
+
kind: Type.String({
|
|
17152
|
+
enum: ["background", "foreground"],
|
|
17153
|
+
description: "Wait policy kind. 'background' yields immediately; 'foreground' waits up to budgetMs."
|
|
17154
|
+
}),
|
|
17155
|
+
budgetMs: Type.Optional(Type.Number({ description: "Foreground wait budget in milliseconds (kind='foreground' only)." }))
|
|
17156
|
+
}, { additionalProperties: false })),
|
|
17157
|
+
budgetMs: Type.Optional(Type.Number({ description: "Foreground wait budget in milliseconds." })),
|
|
16549
17158
|
agent: Type.Optional(Type.String({ description: "Agent name (SINGLE mode) or target for management get/update/delete" })),
|
|
16550
17159
|
task: Type.Optional(Type.String({ description: "Task (SINGLE mode, optional for self-contained agents)" })),
|
|
16551
17160
|
action: Type.Optional(Type.String({
|
|
@@ -16621,7 +17230,10 @@ CONTROL:
|
|
|
16621
17230
|
• { action: "interrupt", id?: "..." } - soft-interrupt the current child turn; the child is terminal for continuation, so follow-up work starts a fresh launch`;
|
|
16622
17231
|
|
|
16623
17232
|
// dist/builtin/subagents/src/extension/tool-rendering.ts
|
|
16624
|
-
import {
|
|
17233
|
+
import { keyHintIfBound as keyHintIfBound4 } from "@bastani/atomic";
|
|
17234
|
+
import { Container as Container3, Text as Text4, truncateToWidth as truncateToWidth3 } from "@earendil-works/pi-tui";
|
|
17235
|
+
var renderRequests = new WeakMap;
|
|
17236
|
+
var displayText2 = (text) => text.replace(/\x1b\[[0-?]*[ -/]*[@-~]/g, "").replace(/[\x00-\x1f\x7f-\x9f]/g, " ");
|
|
16625
17237
|
function effectiveParallelTaskCount(tasks) {
|
|
16626
17238
|
if (!tasks || tasks.length === 0)
|
|
16627
17239
|
return 0;
|
|
@@ -16631,25 +17243,88 @@ function effectiveParallelTaskCount(tasks) {
|
|
|
16631
17243
|
}, 0);
|
|
16632
17244
|
}
|
|
16633
17245
|
function renderSubagentToolCall(args, theme, context) {
|
|
17246
|
+
renderRequests.set(context.state, args);
|
|
16634
17247
|
const burst = getBurstDisplay(context.toolCallId);
|
|
16635
17248
|
if (burst && !burst.owner)
|
|
16636
17249
|
return new Container3;
|
|
16637
17250
|
if (args.action) {
|
|
16638
|
-
const target = args.agent || "";
|
|
16639
|
-
return new
|
|
17251
|
+
const target = args.agent || args.id || args.runId || "";
|
|
17252
|
+
return new Text4(`${theme.fg("toolTitle", theme.bold("subagent "))}${args.action}${target ? ` ${theme.fg(args.action === "status" ? "dim" : "accent", displayText2(target))}` : ""}`, 0, 0);
|
|
16640
17253
|
}
|
|
16641
17254
|
if (burst) {
|
|
16642
|
-
return new
|
|
17255
|
+
return new Text4(`${theme.fg("toolTitle", theme.bold("subagent "))}parallel (${burst.taskCount})`, 0, 0);
|
|
16643
17256
|
}
|
|
16644
17257
|
const isParallel = (args.tasks?.length ?? 0) > 0;
|
|
16645
17258
|
const parallelCount = effectiveParallelTaskCount(args.tasks);
|
|
16646
|
-
return new
|
|
17259
|
+
return new Text4(isParallel ? `${theme.fg("toolTitle", theme.bold("subagent "))}parallel (${parallelCount})` : `${theme.fg("toolTitle", theme.bold("subagent "))}${theme.fg("accent", displayText2(args.agent || "?"))}${args.task ? `
|
|
17260
|
+
${theme.fg("muted", displayText2(truncateToWidth3(displayText2(args.task), 100)))}` : ""}`, 0, 0);
|
|
16647
17261
|
}
|
|
16648
|
-
function renderSubagentToolResult(
|
|
17262
|
+
function renderSubagentToolResult(result, options, theme, context) {
|
|
16649
17263
|
const burst = getBurstDisplay(context.toolCallId);
|
|
16650
17264
|
if (burst && !burst.owner)
|
|
16651
17265
|
return new Container3;
|
|
16652
|
-
|
|
17266
|
+
result = burst?.result ?? result;
|
|
17267
|
+
if (result.details?.taskError)
|
|
17268
|
+
return new Text4(theme.fg("error", `✗ ${displayText2(result.details.taskError)}`), 0, 0);
|
|
17269
|
+
if (result.details?.taskRecords && !result.details.taskResponse) {
|
|
17270
|
+
const lines = result.details.taskRecords.flatMap((task) => {
|
|
17271
|
+
const state = task.execution.kind === "settled" ? task.execution.result.kind : task.execution.kind;
|
|
17272
|
+
return [
|
|
17273
|
+
theme.bold(`${displayText2(task.agentName ?? "bash")} · ${state}`),
|
|
17274
|
+
...task.kind === "agent" ? [
|
|
17275
|
+
theme.fg("dim", displayText2(formatModelThinking(task.model, task.thinking) || "model / thinking unavailable"))
|
|
17276
|
+
] : [],
|
|
17277
|
+
theme.fg("muted", displayText2(task.title)),
|
|
17278
|
+
...options.expanded ? [theme.fg("dim", task.ref.taskId)] : [],
|
|
17279
|
+
...task.execution.kind === "settled" && task.execution.result.kind === "failed" ? [theme.fg("error", displayText2(task.execution.result.message))] : []
|
|
17280
|
+
];
|
|
17281
|
+
});
|
|
17282
|
+
return new Text4([...lines, theme.fg("dim", "/tasks to inspect output and manage tasks")].join(`
|
|
17283
|
+
`), 0, 0);
|
|
17284
|
+
}
|
|
17285
|
+
const response = result.details?.taskResponse;
|
|
17286
|
+
const request = renderRequests.get(context.state);
|
|
17287
|
+
if (response) {
|
|
17288
|
+
const outcomes = response.kind === "parallel" ? response.slots.map((slot) => slot.outcome) : [response];
|
|
17289
|
+
const labels = request && !burst ? [
|
|
17290
|
+
...request.agent ? [{ agent: request.agent, task: request.task ?? "" }] : [],
|
|
17291
|
+
...(request.tasks ?? []).flatMap((task) => Array.from({ length: Math.min(50, Math.max(1, task.count ?? 1)) }, () => task))
|
|
17292
|
+
] : [];
|
|
17293
|
+
const lines = outcomes.map((outcome, index) => {
|
|
17294
|
+
if (outcome.kind === "unstarted")
|
|
17295
|
+
return theme.fg("error", outcome.reason.kind === "rejected" ? `✗ ${index + 1}. Not started · ${displayText2(outcome.reason.error.message)}` : `○ ${index + 1}. Skipped`);
|
|
17296
|
+
const observation = outcome.observation;
|
|
17297
|
+
const state = observation.kind === "yielded" ? request?.action === "wait" ? "Still running in background" : "Launched in background" : observation.result.kind === "completed" ? "Completed" : observation.result.kind === "failed" ? "Failed" : "Stopped";
|
|
17298
|
+
const icon = observation.kind === "yielded" ? "∀" : observation.result.kind === "completed" ? "✓" : observation.result.kind === "failed" ? "✗" : "○";
|
|
17299
|
+
const color = observation.kind === "yielded" ? "accent" : observation.result.kind === "failed" ? "error" : observation.result.kind === "completed" ? "success" : "warning";
|
|
17300
|
+
const identity = labels[index];
|
|
17301
|
+
const name = outcomes.length > 1 ? `${index + 1}. ${identity ? displayText2(identity.agent) : "Agent"} · ` : "";
|
|
17302
|
+
const summary = theme.fg(color, `${icon} ${name}${state}`);
|
|
17303
|
+
const task = result.details?.taskRecords?.find((task) => task.ref.taskId === observation.taskId);
|
|
17304
|
+
const model = theme.fg("dim", `
|
|
17305
|
+
${displayText2(formatModelThinking(task?.model, task?.thinking) || "model / thinking unavailable")}`);
|
|
17306
|
+
const metadata = options.expanded ? theme.fg("dim", `
|
|
17307
|
+
${observation.taskId}${identity?.task ? ` · ${displayText2(identity.task)}` : ""}`) : "";
|
|
17308
|
+
const error = observation.kind === "settled" && observation.result.kind === "failed" ? `
|
|
17309
|
+
${theme.fg("error", displayText2(observation.result.message))}` : "";
|
|
17310
|
+
return summary + model + metadata + error;
|
|
17311
|
+
});
|
|
17312
|
+
const heading = outcomes.length > 1 ? [theme.bold(`${outcomes.length} agent tasks`)] : [];
|
|
17313
|
+
return new Text4([
|
|
17314
|
+
...heading,
|
|
17315
|
+
...lines.map((line, index) => outcomes.length > 1 ? `${index === lines.length - 1 ? "└─" : "├─"} ${line}` : line),
|
|
17316
|
+
theme.fg("dim", "/tasks to inspect output and manage tasks")
|
|
17317
|
+
].join(`
|
|
17318
|
+
`), 0, 0);
|
|
17319
|
+
}
|
|
17320
|
+
const text = result.content.find((part) => part.type === "text");
|
|
17321
|
+
if (text?.type === "text" && text.text.startsWith("Executable agents:")) {
|
|
17322
|
+
const count = text.text.split(`
|
|
17323
|
+
`).filter((line) => line.startsWith("- ") && line !== "- (none)").length;
|
|
17324
|
+
return new Text4(options.expanded ? text.text : `${theme.bold(`${count} available agents`)}
|
|
17325
|
+
${theme.fg("dim", ["/agents to browse", keyHintIfBound4("app.tools.expand", "Expand")].filter(Boolean).map((hint, index) => index ? `(${hint})` : hint).join(" · "))}`, 0, 0);
|
|
17326
|
+
}
|
|
17327
|
+
return renderLiveSubagentResult(burst?.result ?? result, options, theme, context);
|
|
16653
17328
|
}
|
|
16654
17329
|
// dist/builtin/subagents/src/extension/api-lifecycle.ts
|
|
16655
17330
|
function getWeakMap(key) {
|
|
@@ -16861,18 +17536,18 @@ function getSubagentSessionRoot(parentSessionFile) {
|
|
|
16861
17536
|
function expandTilde2(p) {
|
|
16862
17537
|
return p.startsWith("~/") ? path23.join(os8.homedir(), p.slice(2)) : p;
|
|
16863
17538
|
}
|
|
16864
|
-
function isSlashResultRunning(
|
|
16865
|
-
return
|
|
17539
|
+
function isSlashResultRunning(result) {
|
|
17540
|
+
return result.details?.progress?.some((entry) => entry.status === "running") || result.details?.results.some((entry) => entry.progress?.status === "running") || false;
|
|
16866
17541
|
}
|
|
16867
|
-
function isSlashResultError(
|
|
16868
|
-
return
|
|
17542
|
+
function isSlashResultError(result) {
|
|
17543
|
+
return result.details?.results.some((entry) => entry.status === "error" && entry.progress?.status !== "running") || false;
|
|
16869
17544
|
}
|
|
16870
|
-
function rebuildSlashResultContainer(container,
|
|
17545
|
+
function rebuildSlashResultContainer(container, result, options, theme) {
|
|
16871
17546
|
container.clear();
|
|
16872
17547
|
container.addChild(new Spacer2(1));
|
|
16873
|
-
const boxTheme = isSlashResultRunning(
|
|
17548
|
+
const boxTheme = isSlashResultRunning(result) ? "toolPendingBg" : isSlashResultError(result) ? "toolErrorBg" : "toolSuccessBg";
|
|
16874
17549
|
const box = new Box(1, 1, (text) => theme.bg(boxTheme, text));
|
|
16875
|
-
box.addChild(renderSubagentResult(
|
|
17550
|
+
box.addChild(renderSubagentResult(result, options, theme));
|
|
16876
17551
|
container.addChild(box);
|
|
16877
17552
|
}
|
|
16878
17553
|
function createSlashResultComponent(details, options, theme, owner) {
|
|
@@ -16896,7 +17571,7 @@ function renderSubagentNotification(message, options, theme) {
|
|
|
16896
17571
|
const content = typeof message.content === "string" ? message.content : "";
|
|
16897
17572
|
const details = message.details ?? parseSubagentNotifyContent(content);
|
|
16898
17573
|
if (!details)
|
|
16899
|
-
return new
|
|
17574
|
+
return new Text5(content, 0, 0);
|
|
16900
17575
|
const icon = details.status === "completed" ? theme.fg("success", "✓") : details.status === "interrupted" ? theme.fg("warning", "■") : theme.fg("error", "✗");
|
|
16901
17576
|
const parts = [];
|
|
16902
17577
|
if (details.taskInfo)
|
|
@@ -16916,7 +17591,7 @@ function renderSubagentNotification(message, options, theme) {
|
|
|
16916
17591
|
}
|
|
16917
17592
|
if (!options.expanded && trimmedPreview.includes(`
|
|
16918
17593
|
`)) {
|
|
16919
|
-
const expandHint =
|
|
17594
|
+
const expandHint = keyHintIfBound5("app.tools.expand", "full notification");
|
|
16920
17595
|
if (expandHint)
|
|
16921
17596
|
text += `
|
|
16922
17597
|
${expandHint}`;
|
|
@@ -16929,7 +17604,7 @@ function renderSubagentNotification(message, options, theme) {
|
|
|
16929
17604
|
container.addChild(new Spacer2(1));
|
|
16930
17605
|
const boxTheme = details.status === "completed" ? "toolSuccessBg" : details.status === "failed" ? "toolErrorBg" : "toolPendingBg";
|
|
16931
17606
|
const box = new Box(1, 1, (line) => theme.bg(boxTheme, line));
|
|
16932
|
-
box.addChild(new
|
|
17607
|
+
box.addChild(new Text5(text, 0, 0));
|
|
16933
17608
|
container.addChild(box);
|
|
16934
17609
|
return container;
|
|
16935
17610
|
}
|
|
@@ -16945,16 +17620,16 @@ class SubagentControlNoticeComponent {
|
|
|
16945
17620
|
render(width) {
|
|
16946
17621
|
const eventLabel = this.details.event.type.replaceAll("_", " ");
|
|
16947
17622
|
if (width < 3)
|
|
16948
|
-
return [
|
|
17623
|
+
return [truncateToWidth4(`Subagent ${eventLabel}`, width)];
|
|
16949
17624
|
const bodyWidth = Math.max(1, width - 2);
|
|
16950
17625
|
const borderChar = "─";
|
|
16951
17626
|
const header = ` ⚠ Subagent ${eventLabel}: ${this.details.event.agent} `;
|
|
16952
|
-
const headerText =
|
|
16953
|
-
const headerPadding = Math.max(0, bodyWidth -
|
|
17627
|
+
const headerText = truncateToWidth4(header, bodyWidth, "");
|
|
17628
|
+
const headerPadding = Math.max(0, bodyWidth - visibleWidth4(headerText));
|
|
16954
17629
|
const lines = [this.theme.fg("accent", `╭${headerText}${borderChar.repeat(headerPadding)}╮`)];
|
|
16955
|
-
for (const line of
|
|
16956
|
-
const text =
|
|
16957
|
-
const padding = Math.max(0, bodyWidth -
|
|
17630
|
+
for (const line of wrapTextWithAnsi2(formatSubagentControlNotice(this.details), bodyWidth)) {
|
|
17631
|
+
const text = truncateToWidth4(line, bodyWidth, "");
|
|
17632
|
+
const padding = Math.max(0, bodyWidth - visibleWidth4(text));
|
|
16958
17633
|
lines.push(this.theme.fg("accent", `│${text}${" ".repeat(padding)}│`));
|
|
16959
17634
|
}
|
|
16960
17635
|
lines.push(this.theme.fg("accent", `╰${borderChar.repeat(bodyWidth)}╯`));
|
|
@@ -17072,8 +17747,8 @@ function registerSubagentExtension(pi) {
|
|
|
17072
17747
|
renderCall(args, theme, context) {
|
|
17073
17748
|
return renderSubagentToolCall(args, theme, context);
|
|
17074
17749
|
},
|
|
17075
|
-
renderResult(
|
|
17076
|
-
return renderSubagentToolResult(
|
|
17750
|
+
renderResult(result, options, theme, context) {
|
|
17751
|
+
return renderSubagentToolResult(result, options, theme, context);
|
|
17077
17752
|
}
|
|
17078
17753
|
};
|
|
17079
17754
|
pi.registerTool(tool);
|