@ashx-j/lunr 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5042 -0
- package/README.md +691 -0
- package/dist/builtin-extensions/ashxj-spinners.d.ts +3 -0
- package/dist/builtin-extensions/ashxj-spinners.d.ts.map +1 -0
- package/dist/builtin-extensions/ashxj-spinners.js +271 -0
- package/dist/builtin-extensions/ashxj-spinners.js.map +1 -0
- package/dist/builtin-extensions/ashxj-thinking.d.ts +65 -0
- package/dist/builtin-extensions/ashxj-thinking.d.ts.map +1 -0
- package/dist/builtin-extensions/ashxj-thinking.js +308 -0
- package/dist/builtin-extensions/ashxj-thinking.js.map +1 -0
- package/dist/builtin-extensions/ashxj-tui.d.ts +137 -0
- package/dist/builtin-extensions/ashxj-tui.d.ts.map +1 -0
- package/dist/builtin-extensions/ashxj-tui.js +579 -0
- package/dist/builtin-extensions/ashxj-tui.js.map +1 -0
- package/dist/builtin-extensions/index.d.ts +11 -0
- package/dist/builtin-extensions/index.d.ts.map +1 -0
- package/dist/builtin-extensions/index.js +62 -0
- package/dist/builtin-extensions/index.js.map +1 -0
- package/dist/builtin-extensions/lunr-behavior.d.ts +43 -0
- package/dist/builtin-extensions/lunr-behavior.d.ts.map +1 -0
- package/dist/builtin-extensions/lunr-behavior.js +201 -0
- package/dist/builtin-extensions/lunr-behavior.js.map +1 -0
- package/dist/builtin-extensions/lunr-cron.d.ts +26 -0
- package/dist/builtin-extensions/lunr-cron.d.ts.map +1 -0
- package/dist/builtin-extensions/lunr-cron.js +346 -0
- package/dist/builtin-extensions/lunr-cron.js.map +1 -0
- package/dist/builtin-extensions/lunr-local-providers/index.d.ts +20 -0
- package/dist/builtin-extensions/lunr-local-providers/index.d.ts.map +1 -0
- package/dist/builtin-extensions/lunr-local-providers/index.js +108 -0
- package/dist/builtin-extensions/lunr-local-providers/index.js.map +1 -0
- package/dist/builtin-extensions/lunr-local-providers/local-servers.d.ts +51 -0
- package/dist/builtin-extensions/lunr-local-providers/local-servers.d.ts.map +1 -0
- package/dist/builtin-extensions/lunr-local-providers/local-servers.js +128 -0
- package/dist/builtin-extensions/lunr-local-providers/local-servers.js.map +1 -0
- package/dist/builtin-extensions/lunr-plan-tools.d.ts +25 -0
- package/dist/builtin-extensions/lunr-plan-tools.d.ts.map +1 -0
- package/dist/builtin-extensions/lunr-plan-tools.js +59 -0
- package/dist/builtin-extensions/lunr-plan-tools.js.map +1 -0
- package/dist/builtin-extensions/lunr-skill-creator/index.d.ts +12 -0
- package/dist/builtin-extensions/lunr-skill-creator/index.d.ts.map +1 -0
- package/dist/builtin-extensions/lunr-skill-creator/index.js +18 -0
- package/dist/builtin-extensions/lunr-skill-creator/index.js.map +1 -0
- package/dist/builtin-extensions/lunr-skill-creator/skills/skill-creator/SKILL.md +68 -0
- package/dist/builtin-extensions/lunr-todos.d.ts +52 -0
- package/dist/builtin-extensions/lunr-todos.d.ts.map +1 -0
- package/dist/builtin-extensions/lunr-todos.js +189 -0
- package/dist/builtin-extensions/lunr-todos.js.map +1 -0
- package/dist/builtin-extensions/narumiruna-pi-goal/src/accounting.d.ts +23 -0
- package/dist/builtin-extensions/narumiruna-pi-goal/src/accounting.d.ts.map +1 -0
- package/dist/builtin-extensions/narumiruna-pi-goal/src/accounting.js +77 -0
- package/dist/builtin-extensions/narumiruna-pi-goal/src/accounting.js.map +1 -0
- package/dist/builtin-extensions/narumiruna-pi-goal/src/command.d.ts +18 -0
- package/dist/builtin-extensions/narumiruna-pi-goal/src/command.d.ts.map +1 -0
- package/dist/builtin-extensions/narumiruna-pi-goal/src/command.js +165 -0
- package/dist/builtin-extensions/narumiruna-pi-goal/src/command.js.map +1 -0
- package/dist/builtin-extensions/narumiruna-pi-goal/src/commands.d.ts +19 -0
- package/dist/builtin-extensions/narumiruna-pi-goal/src/commands.d.ts.map +1 -0
- package/dist/builtin-extensions/narumiruna-pi-goal/src/commands.js +495 -0
- package/dist/builtin-extensions/narumiruna-pi-goal/src/commands.js.map +1 -0
- package/dist/builtin-extensions/narumiruna-pi-goal/src/goal.d.ts +10 -0
- package/dist/builtin-extensions/narumiruna-pi-goal/src/goal.d.ts.map +1 -0
- package/dist/builtin-extensions/narumiruna-pi-goal/src/goal.js +857 -0
- package/dist/builtin-extensions/narumiruna-pi-goal/src/goal.js.map +1 -0
- package/dist/builtin-extensions/narumiruna-pi-goal/src/persistence.d.ts +57 -0
- package/dist/builtin-extensions/narumiruna-pi-goal/src/persistence.d.ts.map +1 -0
- package/dist/builtin-extensions/narumiruna-pi-goal/src/persistence.js +225 -0
- package/dist/builtin-extensions/narumiruna-pi-goal/src/persistence.js.map +1 -0
- package/dist/builtin-extensions/narumiruna-pi-goal/src/prompts.d.ts +20 -0
- package/dist/builtin-extensions/narumiruna-pi-goal/src/prompts.d.ts.map +1 -0
- package/dist/builtin-extensions/narumiruna-pi-goal/src/prompts.js +75 -0
- package/dist/builtin-extensions/narumiruna-pi-goal/src/prompts.js.map +1 -0
- package/dist/builtin-extensions/narumiruna-pi-goal/src/queue.d.ts +16 -0
- package/dist/builtin-extensions/narumiruna-pi-goal/src/queue.d.ts.map +1 -0
- package/dist/builtin-extensions/narumiruna-pi-goal/src/queue.js +67 -0
- package/dist/builtin-extensions/narumiruna-pi-goal/src/queue.js.map +1 -0
- package/dist/builtin-extensions/narumiruna-pi-goal/src/runtime.d.ts +157 -0
- package/dist/builtin-extensions/narumiruna-pi-goal/src/runtime.d.ts.map +1 -0
- package/dist/builtin-extensions/narumiruna-pi-goal/src/runtime.js +825 -0
- package/dist/builtin-extensions/narumiruna-pi-goal/src/runtime.js.map +1 -0
- package/dist/builtin-extensions/narumiruna-pi-goal/src/settings.d.ts +22 -0
- package/dist/builtin-extensions/narumiruna-pi-goal/src/settings.d.ts.map +1 -0
- package/dist/builtin-extensions/narumiruna-pi-goal/src/settings.js +64 -0
- package/dist/builtin-extensions/narumiruna-pi-goal/src/settings.js.map +1 -0
- package/dist/builtin-extensions/pi-intercom/broker/broker.d.ts +2 -0
- package/dist/builtin-extensions/pi-intercom/broker/broker.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-intercom/broker/broker.js +541 -0
- package/dist/builtin-extensions/pi-intercom/broker/broker.js.map +1 -0
- package/dist/builtin-extensions/pi-intercom/broker/client.d.ts +39 -0
- package/dist/builtin-extensions/pi-intercom/broker/client.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-intercom/broker/client.js +484 -0
- package/dist/builtin-extensions/pi-intercom/broker/client.js.map +1 -0
- package/dist/builtin-extensions/pi-intercom/broker/framing.d.ts +14 -0
- package/dist/builtin-extensions/pi-intercom/broker/framing.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-intercom/broker/framing.js +74 -0
- package/dist/builtin-extensions/pi-intercom/broker/framing.js.map +1 -0
- package/dist/builtin-extensions/pi-intercom/broker/paths.d.ts +22 -0
- package/dist/builtin-extensions/pi-intercom/broker/paths.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-intercom/broker/paths.js +88 -0
- package/dist/builtin-extensions/pi-intercom/broker/paths.js.map +1 -0
- package/dist/builtin-extensions/pi-intercom/broker/spawn.d.ts +27 -0
- package/dist/builtin-extensions/pi-intercom/broker/spawn.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-intercom/broker/spawn.js +313 -0
- package/dist/builtin-extensions/pi-intercom/broker/spawn.js.map +1 -0
- package/dist/builtin-extensions/pi-intercom/config.d.ts +22 -0
- package/dist/builtin-extensions/pi-intercom/config.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-intercom/config.js +103 -0
- package/dist/builtin-extensions/pi-intercom/config.js.map +1 -0
- package/dist/builtin-extensions/pi-intercom/index.d.ts +3 -0
- package/dist/builtin-extensions/pi-intercom/index.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-intercom/index.js +1800 -0
- package/dist/builtin-extensions/pi-intercom/index.js.map +1 -0
- package/dist/builtin-extensions/pi-intercom/reply-tracker.d.ts +27 -0
- package/dist/builtin-extensions/pi-intercom/reply-tracker.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-intercom/reply-tracker.js +101 -0
- package/dist/builtin-extensions/pi-intercom/reply-tracker.js.map +1 -0
- package/dist/builtin-extensions/pi-intercom/types.d.ts +84 -0
- package/dist/builtin-extensions/pi-intercom/types.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-intercom/types.js +2 -0
- package/dist/builtin-extensions/pi-intercom/types.js.map +1 -0
- package/dist/builtin-extensions/pi-intercom/ui/compose.d.ts +27 -0
- package/dist/builtin-extensions/pi-intercom/ui/compose.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-intercom/ui/compose.js +112 -0
- package/dist/builtin-extensions/pi-intercom/ui/compose.js.map +1 -0
- package/dist/builtin-extensions/pi-intercom/ui/inline-message.d.ts +15 -0
- package/dist/builtin-extensions/pi-intercom/ui/inline-message.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-intercom/ui/inline-message.js +86 -0
- package/dist/builtin-extensions/pi-intercom/ui/inline-message.js.map +1 -0
- package/dist/builtin-extensions/pi-intercom/ui/session-list.d.ts +18 -0
- package/dist/builtin-extensions/pi-intercom/ui/session-list.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-intercom/ui/session-list.js +134 -0
- package/dist/builtin-extensions/pi-intercom/ui/session-list.js.map +1 -0
- package/dist/builtin-extensions/pi-lsp-extension/bemol-extension/bemol.d.ts +81 -0
- package/dist/builtin-extensions/pi-lsp-extension/bemol-extension/bemol.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-lsp-extension/bemol-extension/bemol.js +273 -0
- package/dist/builtin-extensions/pi-lsp-extension/bemol-extension/bemol.js.map +1 -0
- package/dist/builtin-extensions/pi-lsp-extension/bemol-extension/index.d.ts +13 -0
- package/dist/builtin-extensions/pi-lsp-extension/bemol-extension/index.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-lsp-extension/bemol-extension/index.js +163 -0
- package/dist/builtin-extensions/pi-lsp-extension/bemol-extension/index.js.map +1 -0
- package/dist/builtin-extensions/pi-lsp-extension/bemol-extension/locks.d.ts +34 -0
- package/dist/builtin-extensions/pi-lsp-extension/bemol-extension/locks.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-lsp-extension/bemol-extension/locks.js +148 -0
- package/dist/builtin-extensions/pi-lsp-extension/bemol-extension/locks.js.map +1 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/file-sync.d.ts +59 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/file-sync.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/file-sync.js +172 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/file-sync.js.map +1 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/index.d.ts +25 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/index.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/index.js +521 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/index.js.map +1 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/lsp-client.d.ts +80 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/lsp-client.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/lsp-client.js +366 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/lsp-client.js.map +1 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/lsp-daemon.d.ts +22 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/lsp-daemon.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/lsp-daemon.js +476 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/lsp-daemon.js.map +1 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/lsp-manager.d.ts +141 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/lsp-manager.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/lsp-manager.js +633 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/lsp-manager.js.map +1 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/resolve-provider.d.ts +30 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/resolve-provider.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/resolve-provider.js +52 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/resolve-provider.js.map +1 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/shared/constants.d.ts +12 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/shared/constants.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/shared/constants.js +18 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/shared/constants.js.map +1 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/shared/debug.d.ts +10 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/shared/debug.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/shared/debug.js +18 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/shared/debug.js.map +1 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/shared/format.d.ts +9 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/shared/format.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/shared/format.js +29 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/shared/format.js.map +1 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/shared/language-map.d.ts +10 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/shared/language-map.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/shared/language-map.js +51 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/shared/language-map.js.map +1 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/shared/resolve-position.d.ts +33 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/shared/resolve-position.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/shared/resolve-position.js +191 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/shared/resolve-position.js.map +1 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/shared/timing.d.ts +14 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/shared/timing.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/shared/timing.js +15 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/shared/timing.js.map +1 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/tools/code-actions.d.ts +23 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/tools/code-actions.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/tools/code-actions.js +259 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/tools/code-actions.js.map +1 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/tools/code-overview.d.ts +23 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/tools/code-overview.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/tools/code-overview.js +197 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/tools/code-overview.js.map +1 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/tools/code-rewrite.d.ts +23 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/tools/code-rewrite.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/tools/code-rewrite.js +131 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/tools/code-rewrite.js.map +1 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/tools/code-search.d.ts +18 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/tools/code-search.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/tools/code-search.js +87 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/tools/code-search.js.map +1 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/tools/completions.d.ts +34 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/tools/completions.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/tools/completions.js +347 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/tools/completions.js.map +1 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/tools/definition.d.ts +20 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/tools/definition.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/tools/definition.js +166 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/tools/definition.js.map +1 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/tools/diagnostics.d.ts +22 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/tools/diagnostics.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/tools/diagnostics.js +228 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/tools/diagnostics.js.map +1 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/tools/hover.d.ts +19 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/tools/hover.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/tools/hover.js +143 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/tools/hover.js.map +1 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/tools/references.d.ts +20 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/tools/references.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/tools/references.js +98 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/tools/references.js.map +1 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/tools/rename.d.ts +22 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/tools/rename.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/tools/rename.js +150 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/tools/rename.js.map +1 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/tools/symbols.d.ts +18 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/tools/symbols.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/tools/symbols.js +211 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/tools/symbols.js.map +1 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/tree-sitter/parser-manager.d.ts +44 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/tree-sitter/parser-manager.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/tree-sitter/parser-manager.js +188 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/tree-sitter/parser-manager.js.map +1 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/tree-sitter/pattern-compiler.d.ts +58 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/tree-sitter/pattern-compiler.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/tree-sitter/pattern-compiler.js +260 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/tree-sitter/pattern-compiler.js.map +1 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/tree-sitter/rewrite-engine.d.ts +33 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/tree-sitter/rewrite-engine.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/tree-sitter/rewrite-engine.js +102 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/tree-sitter/rewrite-engine.js.map +1 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/tree-sitter/search-engine.d.ts +38 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/tree-sitter/search-engine.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/tree-sitter/search-engine.js +276 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/tree-sitter/search-engine.js.map +1 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/tree-sitter/symbol-extractor.d.ts +77 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/tree-sitter/symbol-extractor.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/tree-sitter/symbol-extractor.js +339 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/tree-sitter/symbol-extractor.js.map +1 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/tree-sitter/workspace-index.d.ts +51 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/tree-sitter/workspace-index.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/tree-sitter/workspace-index.js +219 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/tree-sitter/workspace-index.js.map +1 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/workspace-provider.d.ts +45 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/workspace-provider.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/workspace-provider.js +30 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/workspace-provider.js.map +1 -0
- package/dist/builtin-extensions/pi-mcp-adapter/abort.d.ts +3 -0
- package/dist/builtin-extensions/pi-mcp-adapter/abort.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-mcp-adapter/abort.js +37 -0
- package/dist/builtin-extensions/pi-mcp-adapter/abort.js.map +1 -0
- package/dist/builtin-extensions/pi-mcp-adapter/agent-dir.d.ts +3 -0
- package/dist/builtin-extensions/pi-mcp-adapter/agent-dir.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-mcp-adapter/agent-dir.js +22 -0
- package/dist/builtin-extensions/pi-mcp-adapter/agent-dir.js.map +1 -0
- package/dist/builtin-extensions/pi-mcp-adapter/commands.d.ts +18 -0
- package/dist/builtin-extensions/pi-mcp-adapter/commands.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-mcp-adapter/commands.js +327 -0
- package/dist/builtin-extensions/pi-mcp-adapter/commands.js.map +1 -0
- package/dist/builtin-extensions/pi-mcp-adapter/config.d.ts +79 -0
- package/dist/builtin-extensions/pi-mcp-adapter/config.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-mcp-adapter/config.js +557 -0
- package/dist/builtin-extensions/pi-mcp-adapter/config.js.map +1 -0
- package/dist/builtin-extensions/pi-mcp-adapter/consent-manager.d.ts +14 -0
- package/dist/builtin-extensions/pi-mcp-adapter/consent-manager.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-mcp-adapter/consent-manager.js +61 -0
- package/dist/builtin-extensions/pi-mcp-adapter/consent-manager.js.map +1 -0
- package/dist/builtin-extensions/pi-mcp-adapter/direct-tools.d.ts +11 -0
- package/dist/builtin-extensions/pi-mcp-adapter/direct-tools.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-mcp-adapter/direct-tools.js +374 -0
- package/dist/builtin-extensions/pi-mcp-adapter/direct-tools.js.map +1 -0
- package/dist/builtin-extensions/pi-mcp-adapter/elicitation-handler.d.ts +18 -0
- package/dist/builtin-extensions/pi-mcp-adapter/elicitation-handler.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-mcp-adapter/elicitation-handler.js +309 -0
- package/dist/builtin-extensions/pi-mcp-adapter/elicitation-handler.js.map +1 -0
- package/dist/builtin-extensions/pi-mcp-adapter/error-signal.d.ts +16 -0
- package/dist/builtin-extensions/pi-mcp-adapter/error-signal.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-mcp-adapter/error-signal.js +23 -0
- package/dist/builtin-extensions/pi-mcp-adapter/error-signal.js.map +1 -0
- package/dist/builtin-extensions/pi-mcp-adapter/errors.d.ts +100 -0
- package/dist/builtin-extensions/pi-mcp-adapter/errors.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-mcp-adapter/errors.js +167 -0
- package/dist/builtin-extensions/pi-mcp-adapter/errors.js.map +1 -0
- package/dist/builtin-extensions/pi-mcp-adapter/glimpse-ui.d.ts +10 -0
- package/dist/builtin-extensions/pi-mcp-adapter/glimpse-ui.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-mcp-adapter/glimpse-ui.js +77 -0
- package/dist/builtin-extensions/pi-mcp-adapter/glimpse-ui.js.map +1 -0
- package/dist/builtin-extensions/pi-mcp-adapter/host-html-template.d.ts +17 -0
- package/dist/builtin-extensions/pi-mcp-adapter/host-html-template.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-mcp-adapter/host-html-template.js +413 -0
- package/dist/builtin-extensions/pi-mcp-adapter/host-html-template.js.map +1 -0
- package/dist/builtin-extensions/pi-mcp-adapter/index.d.ts +3 -0
- package/dist/builtin-extensions/pi-mcp-adapter/index.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-mcp-adapter/index.js +334 -0
- package/dist/builtin-extensions/pi-mcp-adapter/index.js.map +1 -0
- package/dist/builtin-extensions/pi-mcp-adapter/init.d.ts +11 -0
- package/dist/builtin-extensions/pi-mcp-adapter/init.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-mcp-adapter/init.js +296 -0
- package/dist/builtin-extensions/pi-mcp-adapter/init.js.map +1 -0
- package/dist/builtin-extensions/pi-mcp-adapter/lifecycle.d.ts +30 -0
- package/dist/builtin-extensions/pi-mcp-adapter/lifecycle.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-mcp-adapter/lifecycle.js +80 -0
- package/dist/builtin-extensions/pi-mcp-adapter/lifecycle.js.map +1 -0
- package/dist/builtin-extensions/pi-mcp-adapter/logger.d.ts +52 -0
- package/dist/builtin-extensions/pi-mcp-adapter/logger.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-mcp-adapter/logger.js +132 -0
- package/dist/builtin-extensions/pi-mcp-adapter/logger.js.map +1 -0
- package/dist/builtin-extensions/pi-mcp-adapter/mcp-auth-flow.d.ts +86 -0
- package/dist/builtin-extensions/pi-mcp-adapter/mcp-auth-flow.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-mcp-adapter/mcp-auth-flow.js +482 -0
- package/dist/builtin-extensions/pi-mcp-adapter/mcp-auth-flow.js.map +1 -0
- package/dist/builtin-extensions/pi-mcp-adapter/mcp-auth.d.ts +104 -0
- package/dist/builtin-extensions/pi-mcp-adapter/mcp-auth.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-mcp-adapter/mcp-auth.js +252 -0
- package/dist/builtin-extensions/pi-mcp-adapter/mcp-auth.js.map +1 -0
- package/dist/builtin-extensions/pi-mcp-adapter/mcp-callback-server.d.ts +45 -0
- package/dist/builtin-extensions/pi-mcp-adapter/mcp-callback-server.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-mcp-adapter/mcp-callback-server.js +305 -0
- package/dist/builtin-extensions/pi-mcp-adapter/mcp-callback-server.js.map +1 -0
- package/dist/builtin-extensions/pi-mcp-adapter/mcp-oauth-provider.d.ts +111 -0
- package/dist/builtin-extensions/pi-mcp-adapter/mcp-oauth-provider.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-mcp-adapter/mcp-oauth-provider.js +302 -0
- package/dist/builtin-extensions/pi-mcp-adapter/mcp-oauth-provider.js.map +1 -0
- package/dist/builtin-extensions/pi-mcp-adapter/mcp-output-guard.d.ts +59 -0
- package/dist/builtin-extensions/pi-mcp-adapter/mcp-output-guard.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-mcp-adapter/mcp-output-guard.js +325 -0
- package/dist/builtin-extensions/pi-mcp-adapter/mcp-output-guard.js.map +1 -0
- package/dist/builtin-extensions/pi-mcp-adapter/mcp-panel.d.ts +64 -0
- package/dist/builtin-extensions/pi-mcp-adapter/mcp-panel.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-mcp-adapter/mcp-panel.js +777 -0
- package/dist/builtin-extensions/pi-mcp-adapter/mcp-panel.js.map +1 -0
- package/dist/builtin-extensions/pi-mcp-adapter/mcp-setup-panel.d.ts +77 -0
- package/dist/builtin-extensions/pi-mcp-adapter/mcp-setup-panel.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-mcp-adapter/mcp-setup-panel.js +490 -0
- package/dist/builtin-extensions/pi-mcp-adapter/mcp-setup-panel.js.map +1 -0
- package/dist/builtin-extensions/pi-mcp-adapter/metadata-cache.d.ts +32 -0
- package/dist/builtin-extensions/pi-mcp-adapter/metadata-cache.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-mcp-adapter/metadata-cache.js +160 -0
- package/dist/builtin-extensions/pi-mcp-adapter/metadata-cache.js.map +1 -0
- package/dist/builtin-extensions/pi-mcp-adapter/npx-resolver.d.ts +7 -0
- package/dist/builtin-extensions/pi-mcp-adapter/npx-resolver.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-mcp-adapter/npx-resolver.js +388 -0
- package/dist/builtin-extensions/pi-mcp-adapter/npx-resolver.js.map +1 -0
- package/dist/builtin-extensions/pi-mcp-adapter/oauth-handler.d.ts +19 -0
- package/dist/builtin-extensions/pi-mcp-adapter/oauth-handler.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-mcp-adapter/oauth-handler.js +53 -0
- package/dist/builtin-extensions/pi-mcp-adapter/oauth-handler.js.map +1 -0
- package/dist/builtin-extensions/pi-mcp-adapter/onboarding-state.d.ts +13 -0
- package/dist/builtin-extensions/pi-mcp-adapter/onboarding-state.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-mcp-adapter/onboarding-state.js +58 -0
- package/dist/builtin-extensions/pi-mcp-adapter/onboarding-state.js.map +1 -0
- package/dist/builtin-extensions/pi-mcp-adapter/panel-keys.d.ts +17 -0
- package/dist/builtin-extensions/pi-mcp-adapter/panel-keys.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-mcp-adapter/panel-keys.js +17 -0
- package/dist/builtin-extensions/pi-mcp-adapter/panel-keys.js.map +1 -0
- package/dist/builtin-extensions/pi-mcp-adapter/proxy-modes.d.ts +14 -0
- package/dist/builtin-extensions/pi-mcp-adapter/proxy-modes.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-mcp-adapter/proxy-modes.js +853 -0
- package/dist/builtin-extensions/pi-mcp-adapter/proxy-modes.js.map +1 -0
- package/dist/builtin-extensions/pi-mcp-adapter/resource-tools.d.ts +2 -0
- package/dist/builtin-extensions/pi-mcp-adapter/resource-tools.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-mcp-adapter/resource-tools.js +16 -0
- package/dist/builtin-extensions/pi-mcp-adapter/resource-tools.js.map +1 -0
- package/dist/builtin-extensions/pi-mcp-adapter/sampling-handler.d.ts +16 -0
- package/dist/builtin-extensions/pi-mcp-adapter/sampling-handler.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-mcp-adapter/sampling-handler.js +209 -0
- package/dist/builtin-extensions/pi-mcp-adapter/sampling-handler.js.map +1 -0
- package/dist/builtin-extensions/pi-mcp-adapter/server-manager.d.ts +58 -0
- package/dist/builtin-extensions/pi-mcp-adapter/server-manager.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-mcp-adapter/server-manager.js +403 -0
- package/dist/builtin-extensions/pi-mcp-adapter/server-manager.js.map +1 -0
- package/dist/builtin-extensions/pi-mcp-adapter/state.d.ts +41 -0
- package/dist/builtin-extensions/pi-mcp-adapter/state.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-mcp-adapter/state.js +2 -0
- package/dist/builtin-extensions/pi-mcp-adapter/state.js.map +1 -0
- package/dist/builtin-extensions/pi-mcp-adapter/tool-metadata.d.ts +11 -0
- package/dist/builtin-extensions/pi-mcp-adapter/tool-metadata.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-mcp-adapter/tool-metadata.js +178 -0
- package/dist/builtin-extensions/pi-mcp-adapter/tool-metadata.js.map +1 -0
- package/dist/builtin-extensions/pi-mcp-adapter/tool-registrar.d.ts +11 -0
- package/dist/builtin-extensions/pi-mcp-adapter/tool-registrar.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-mcp-adapter/tool-registrar.js +66 -0
- package/dist/builtin-extensions/pi-mcp-adapter/tool-registrar.js.map +1 -0
- package/dist/builtin-extensions/pi-mcp-adapter/tool-result-renderer.d.ts +35 -0
- package/dist/builtin-extensions/pi-mcp-adapter/tool-result-renderer.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-mcp-adapter/tool-result-renderer.js +107 -0
- package/dist/builtin-extensions/pi-mcp-adapter/tool-result-renderer.js.map +1 -0
- package/dist/builtin-extensions/pi-mcp-adapter/types.d.ts +286 -0
- package/dist/builtin-extensions/pi-mcp-adapter/types.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-mcp-adapter/types.js +94 -0
- package/dist/builtin-extensions/pi-mcp-adapter/types.js.map +1 -0
- package/dist/builtin-extensions/pi-mcp-adapter/ui-resource-handler.d.ts +10 -0
- package/dist/builtin-extensions/pi-mcp-adapter/ui-resource-handler.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-mcp-adapter/ui-resource-handler.js +118 -0
- package/dist/builtin-extensions/pi-mcp-adapter/ui-resource-handler.js.map +1 -0
- package/dist/builtin-extensions/pi-mcp-adapter/ui-server.d.ts +37 -0
- package/dist/builtin-extensions/pi-mcp-adapter/ui-server.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-mcp-adapter/ui-server.js +524 -0
- package/dist/builtin-extensions/pi-mcp-adapter/ui-server.js.map +1 -0
- package/dist/builtin-extensions/pi-mcp-adapter/ui-session.d.ts +27 -0
- package/dist/builtin-extensions/pi-mcp-adapter/ui-session.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-mcp-adapter/ui-session.js +311 -0
- package/dist/builtin-extensions/pi-mcp-adapter/ui-session.js.map +1 -0
- package/dist/builtin-extensions/pi-mcp-adapter/ui-stream-types.d.ts +105 -0
- package/dist/builtin-extensions/pi-mcp-adapter/ui-stream-types.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-mcp-adapter/ui-stream-types.js +60 -0
- package/dist/builtin-extensions/pi-mcp-adapter/ui-stream-types.js.map +1 -0
- package/dist/builtin-extensions/pi-mcp-adapter/utils.d.ts +18 -0
- package/dist/builtin-extensions/pi-mcp-adapter/utils.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-mcp-adapter/utils.js +112 -0
- package/dist/builtin-extensions/pi-mcp-adapter/utils.js.map +1 -0
- package/dist/builtin-extensions/pi-mcp-adapter/vitest.config.d.ts +3 -0
- package/dist/builtin-extensions/pi-mcp-adapter/vitest.config.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-mcp-adapter/vitest.config.js +15 -0
- package/dist/builtin-extensions/pi-mcp-adapter/vitest.config.js.map +1 -0
- package/dist/builtin-extensions/pi-ollama-cloud/index.d.ts +31 -0
- package/dist/builtin-extensions/pi-ollama-cloud/index.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-ollama-cloud/index.js +120 -0
- package/dist/builtin-extensions/pi-ollama-cloud/index.js.map +1 -0
- package/dist/builtin-extensions/pi-ollama-cloud/models.d.ts +49 -0
- package/dist/builtin-extensions/pi-ollama-cloud/models.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-ollama-cloud/models.generated.d.ts +3 -0
- package/dist/builtin-extensions/pi-ollama-cloud/models.generated.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-ollama-cloud/models.generated.js +1135 -0
- package/dist/builtin-extensions/pi-ollama-cloud/models.generated.js.map +1 -0
- package/dist/builtin-extensions/pi-ollama-cloud/models.js +239 -0
- package/dist/builtin-extensions/pi-ollama-cloud/models.js.map +1 -0
- package/dist/builtin-extensions/pi-ollama-cloud/thinking-levels.d.ts +40 -0
- package/dist/builtin-extensions/pi-ollama-cloud/thinking-levels.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-ollama-cloud/thinking-levels.js +80 -0
- package/dist/builtin-extensions/pi-ollama-cloud/thinking-levels.js.map +1 -0
- package/dist/builtin-extensions/pi-ollama-cloud/utils.d.ts +9 -0
- package/dist/builtin-extensions/pi-ollama-cloud/utils.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-ollama-cloud/utils.js +52 -0
- package/dist/builtin-extensions/pi-ollama-cloud/utils.js.map +1 -0
- package/dist/builtin-extensions/pi-prompt-template-model/args.d.ts +56 -0
- package/dist/builtin-extensions/pi-prompt-template-model/args.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-prompt-template-model/args.js +555 -0
- package/dist/builtin-extensions/pi-prompt-template-model/args.js.map +1 -0
- package/dist/builtin-extensions/pi-prompt-template-model/chain-parser.d.ts +22 -0
- package/dist/builtin-extensions/pi-prompt-template-model/chain-parser.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-prompt-template-model/chain-parser.js +249 -0
- package/dist/builtin-extensions/pi-prompt-template-model/chain-parser.js.map +1 -0
- package/dist/builtin-extensions/pi-prompt-template-model/deterministic-renderer.d.ts +20 -0
- package/dist/builtin-extensions/pi-prompt-template-model/deterministic-renderer.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-prompt-template-model/deterministic-renderer.js +102 -0
- package/dist/builtin-extensions/pi-prompt-template-model/deterministic-renderer.js.map +1 -0
- package/dist/builtin-extensions/pi-prompt-template-model/deterministic-step.d.ts +30 -0
- package/dist/builtin-extensions/pi-prompt-template-model/deterministic-step.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-prompt-template-model/deterministic-step.js +260 -0
- package/dist/builtin-extensions/pi-prompt-template-model/deterministic-step.js.map +1 -0
- package/dist/builtin-extensions/pi-prompt-template-model/index.d.ts +3 -0
- package/dist/builtin-extensions/pi-prompt-template-model/index.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-prompt-template-model/index.js +1403 -0
- package/dist/builtin-extensions/pi-prompt-template-model/index.js.map +1 -0
- package/dist/builtin-extensions/pi-prompt-template-model/loop-utils.d.ts +8 -0
- package/dist/builtin-extensions/pi-prompt-template-model/loop-utils.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-prompt-template-model/loop-utils.js +164 -0
- package/dist/builtin-extensions/pi-prompt-template-model/loop-utils.js.map +1 -0
- package/dist/builtin-extensions/pi-prompt-template-model/model-selection.d.ts +22 -0
- package/dist/builtin-extensions/pi-prompt-template-model/model-selection.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-prompt-template-model/model-selection.js +82 -0
- package/dist/builtin-extensions/pi-prompt-template-model/model-selection.js.map +1 -0
- package/dist/builtin-extensions/pi-prompt-template-model/notifications.d.ts +6 -0
- package/dist/builtin-extensions/pi-prompt-template-model/notifications.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-prompt-template-model/notifications.js +21 -0
- package/dist/builtin-extensions/pi-prompt-template-model/notifications.js.map +1 -0
- package/dist/builtin-extensions/pi-prompt-template-model/prompt-execution.d.ts +24 -0
- package/dist/builtin-extensions/pi-prompt-template-model/prompt-execution.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-prompt-template-model/prompt-execution.js +56 -0
- package/dist/builtin-extensions/pi-prompt-template-model/prompt-execution.js.map +1 -0
- package/dist/builtin-extensions/pi-prompt-template-model/prompt-loader.d.ts +80 -0
- package/dist/builtin-extensions/pi-prompt-template-model/prompt-loader.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-prompt-template-model/prompt-loader.js +1234 -0
- package/dist/builtin-extensions/pi-prompt-template-model/prompt-loader.js.map +1 -0
- package/dist/builtin-extensions/pi-prompt-template-model/skill-loaded-renderer.d.ts +11 -0
- package/dist/builtin-extensions/pi-prompt-template-model/skill-loaded-renderer.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-prompt-template-model/skill-loaded-renderer.js +31 -0
- package/dist/builtin-extensions/pi-prompt-template-model/skill-loaded-renderer.js.map +1 -0
- package/dist/builtin-extensions/pi-prompt-template-model/subagent-renderer.d.ts +43 -0
- package/dist/builtin-extensions/pi-prompt-template-model/subagent-renderer.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-prompt-template-model/subagent-renderer.js +177 -0
- package/dist/builtin-extensions/pi-prompt-template-model/subagent-renderer.js.map +1 -0
- package/dist/builtin-extensions/pi-prompt-template-model/subagent-runtime.d.ts +97 -0
- package/dist/builtin-extensions/pi-prompt-template-model/subagent-runtime.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-prompt-template-model/subagent-runtime.js +64 -0
- package/dist/builtin-extensions/pi-prompt-template-model/subagent-runtime.js.map +1 -0
- package/dist/builtin-extensions/pi-prompt-template-model/subagent-step.d.ts +48 -0
- package/dist/builtin-extensions/pi-prompt-template-model/subagent-step.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-prompt-template-model/subagent-step.js +550 -0
- package/dist/builtin-extensions/pi-prompt-template-model/subagent-step.js.map +1 -0
- package/dist/builtin-extensions/pi-prompt-template-model/subagent-widget.d.ts +8 -0
- package/dist/builtin-extensions/pi-prompt-template-model/subagent-widget.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-prompt-template-model/subagent-widget.js +230 -0
- package/dist/builtin-extensions/pi-prompt-template-model/subagent-widget.js.map +1 -0
- package/dist/builtin-extensions/pi-prompt-template-model/template-conditionals.d.ts +10 -0
- package/dist/builtin-extensions/pi-prompt-template-model/template-conditionals.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-prompt-template-model/template-conditionals.js +226 -0
- package/dist/builtin-extensions/pi-prompt-template-model/template-conditionals.js.map +1 -0
- package/dist/builtin-extensions/pi-prompt-template-model/tool-manager.d.ts +17 -0
- package/dist/builtin-extensions/pi-prompt-template-model/tool-manager.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-prompt-template-model/tool-manager.js +201 -0
- package/dist/builtin-extensions/pi-prompt-template-model/tool-manager.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/agents/context-builder.md +46 -0
- package/dist/builtin-extensions/pi-subagents/agents/deep-researcher.md +36 -0
- package/dist/builtin-extensions/pi-subagents/agents/delegate.md +12 -0
- package/dist/builtin-extensions/pi-subagents/agents/oracle.md +73 -0
- package/dist/builtin-extensions/pi-subagents/agents/planner.md +55 -0
- package/dist/builtin-extensions/pi-subagents/agents/research-writer.md +37 -0
- package/dist/builtin-extensions/pi-subagents/agents/researcher.md +52 -0
- package/dist/builtin-extensions/pi-subagents/agents/reviewer.md +79 -0
- package/dist/builtin-extensions/pi-subagents/agents/scout.md +50 -0
- package/dist/builtin-extensions/pi-subagents/agents/worker.md +55 -0
- package/dist/builtin-extensions/pi-subagents/index.d.ts +2 -0
- package/dist/builtin-extensions/pi-subagents/index.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/index.js +3 -0
- package/dist/builtin-extensions/pi-subagents/index.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/agents/agent-management.d.ts +20 -0
- package/dist/builtin-extensions/pi-subagents/src/agents/agent-management.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/agents/agent-management.js +1273 -0
- package/dist/builtin-extensions/pi-subagents/src/agents/agent-management.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/agents/agent-memory.d.ts +49 -0
- package/dist/builtin-extensions/pi-subagents/src/agents/agent-memory.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/agents/agent-memory.js +252 -0
- package/dist/builtin-extensions/pi-subagents/src/agents/agent-memory.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/agents/agent-scope.d.ts +3 -0
- package/dist/builtin-extensions/pi-subagents/src/agents/agent-scope.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/agents/agent-scope.js +6 -0
- package/dist/builtin-extensions/pi-subagents/src/agents/agent-scope.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/agents/agent-selection.d.ts +3 -0
- package/dist/builtin-extensions/pi-subagents/src/agents/agent-selection.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/agents/agent-selection.js +23 -0
- package/dist/builtin-extensions/pi-subagents/src/agents/agent-selection.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/agents/agent-serializer.d.ts +8 -0
- package/dist/builtin-extensions/pi-subagents/src/agents/agent-serializer.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/agents/agent-serializer.js +143 -0
- package/dist/builtin-extensions/pi-subagents/src/agents/agent-serializer.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/agents/agents.d.ts +176 -0
- package/dist/builtin-extensions/pi-subagents/src/agents/agents.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/agents/agents.js +1326 -0
- package/dist/builtin-extensions/pi-subagents/src/agents/agents.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/agents/chain-serializer.d.ts +7 -0
- package/dist/builtin-extensions/pi-subagents/src/agents/chain-serializer.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/agents/chain-serializer.js +307 -0
- package/dist/builtin-extensions/pi-subagents/src/agents/chain-serializer.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/agents/frontmatter.d.ts +11 -0
- package/dist/builtin-extensions/pi-subagents/src/agents/frontmatter.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/agents/frontmatter.js +84 -0
- package/dist/builtin-extensions/pi-subagents/src/agents/frontmatter.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/agents/identity.d.ts +8 -0
- package/dist/builtin-extensions/pi-subagents/src/agents/identity.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/agents/identity.js +30 -0
- package/dist/builtin-extensions/pi-subagents/src/agents/identity.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/agents/proactive-skills.d.ts +35 -0
- package/dist/builtin-extensions/pi-subagents/src/agents/proactive-skills.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/agents/proactive-skills.js +151 -0
- package/dist/builtin-extensions/pi-subagents/src/agents/proactive-skills.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/agents/skills.d.ts +33 -0
- package/dist/builtin-extensions/pi-subagents/src/agents/skills.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/agents/skills.js +674 -0
- package/dist/builtin-extensions/pi-subagents/src/agents/skills.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/api/background-work.d.ts +35 -0
- package/dist/builtin-extensions/pi-subagents/src/api/background-work.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/api/background-work.js +162 -0
- package/dist/builtin-extensions/pi-subagents/src/api/background-work.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/api/delegation.d.ts +113 -0
- package/dist/builtin-extensions/pi-subagents/src/api/delegation.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/api/delegation.js +10 -0
- package/dist/builtin-extensions/pi-subagents/src/api/delegation.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/extension/chain-validation.d.ts +34 -0
- package/dist/builtin-extensions/pi-subagents/src/extension/chain-validation.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/extension/chain-validation.js +125 -0
- package/dist/builtin-extensions/pi-subagents/src/extension/chain-validation.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/extension/config.d.ts +6 -0
- package/dist/builtin-extensions/pi-subagents/src/extension/config.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/extension/config.js +37 -0
- package/dist/builtin-extensions/pi-subagents/src/extension/config.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/extension/control-notices.d.ts +21 -0
- package/dist/builtin-extensions/pi-subagents/src/extension/control-notices.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/extension/control-notices.js +70 -0
- package/dist/builtin-extensions/pi-subagents/src/extension/control-notices.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/extension/doctor.d.ts +33 -0
- package/dist/builtin-extensions/pi-subagents/src/extension/doctor.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/extension/doctor.js +174 -0
- package/dist/builtin-extensions/pi-subagents/src/extension/doctor.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/extension/fanout-child.d.ts +3 -0
- package/dist/builtin-extensions/pi-subagents/src/extension/fanout-child.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/extension/fanout-child.js +175 -0
- package/dist/builtin-extensions/pi-subagents/src/extension/fanout-child.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/extension/index.d.ts +17 -0
- package/dist/builtin-extensions/pi-subagents/src/extension/index.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/extension/index.js +577 -0
- package/dist/builtin-extensions/pi-subagents/src/extension/index.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/extension/rpc.d.ts +57 -0
- package/dist/builtin-extensions/pi-subagents/src/extension/rpc.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/extension/rpc.js +291 -0
- package/dist/builtin-extensions/pi-subagents/src/extension/rpc.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/extension/schemas.d.ts +225 -0
- package/dist/builtin-extensions/pi-subagents/src/extension/schemas.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/extension/schemas.js +301 -0
- package/dist/builtin-extensions/pi-subagents/src/extension/schemas.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/extension/steering-notices.d.ts +15 -0
- package/dist/builtin-extensions/pi-subagents/src/extension/steering-notices.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/extension/steering-notices.js +23 -0
- package/dist/builtin-extensions/pi-subagents/src/extension/steering-notices.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/extension/tool-description.d.ts +12 -0
- package/dist/builtin-extensions/pi-subagents/src/extension/tool-description.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/extension/tool-description.js +225 -0
- package/dist/builtin-extensions/pi-subagents/src/extension/tool-description.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/intercom/intercom-bridge.d.ts +35 -0
- package/dist/builtin-extensions/pi-subagents/src/intercom/intercom-bridge.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/intercom/intercom-bridge.js +144 -0
- package/dist/builtin-extensions/pi-subagents/src/intercom/intercom-bridge.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/intercom/native-supervisor-channel.d.ts +36 -0
- package/dist/builtin-extensions/pi-subagents/src/intercom/native-supervisor-channel.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/intercom/native-supervisor-channel.js +626 -0
- package/dist/builtin-extensions/pi-subagents/src/intercom/native-supervisor-channel.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/intercom/result-intercom.d.ts +31 -0
- package/dist/builtin-extensions/pi-subagents/src/intercom/result-intercom.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/intercom/result-intercom.js +331 -0
- package/dist/builtin-extensions/pi-subagents/src/intercom/result-intercom.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/profiles/profiles.d.ts +131 -0
- package/dist/builtin-extensions/pi-subagents/src/profiles/profiles.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/profiles/profiles.js +491 -0
- package/dist/builtin-extensions/pi-subagents/src/profiles/profiles.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/async-execution.d.ts +169 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/async-execution.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/async-execution.js +1065 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/async-execution.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/async-job-tracker.d.ts +20 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/async-job-tracker.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/async-job-tracker.js +500 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/async-job-tracker.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/async-resume.d.ts +64 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/async-resume.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/async-resume.js +525 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/async-resume.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/async-status.d.ts +96 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/async-status.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/async-status.js +336 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/async-status.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/auto-drain.d.ts +15 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/auto-drain.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/auto-drain.js +47 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/auto-drain.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/chain-append.d.ts +31 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/chain-append.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/chain-append.js +260 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/chain-append.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/chain-root-attachment.d.ts +35 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/chain-root-attachment.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/chain-root-attachment.js +146 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/chain-root-attachment.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/completion-batcher.d.ts +52 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/completion-batcher.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/completion-batcher.js +119 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/completion-batcher.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/completion-dedupe.d.ts +14 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/completion-dedupe.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/completion-dedupe.js +55 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/completion-dedupe.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/control-channel.d.ts +182 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/control-channel.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/control-channel.js +487 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/control-channel.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/fleet-view.d.ts +43 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/fleet-view.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/fleet-view.js +518 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/fleet-view.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/notify.d.ts +63 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/notify.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/notify.js +202 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/notify.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/parallel-groups.d.ts +4 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/parallel-groups.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/parallel-groups.js +47 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/parallel-groups.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/result-watcher.d.ts +22 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/result-watcher.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/result-watcher.js +247 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/result-watcher.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/run-id-resolver.d.ts +23 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/run-id-resolver.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/run-id-resolver.js +91 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/run-id-resolver.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/run-status.d.ts +24 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/run-status.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/run-status.js +453 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/run-status.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/scheduled-runs.d.ts +48 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/scheduled-runs.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/scheduled-runs.js +473 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/scheduled-runs.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/stale-run-reconciler.d.ts +34 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/stale-run-reconciler.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/stale-run-reconciler.js +351 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/stale-run-reconciler.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/steering.d.ts +44 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/steering.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/steering.js +228 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/steering.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-runner.d.ts +2 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-runner.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-runner.js +3513 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-runner.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-wait.d.ts +95 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-wait.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-wait.js +387 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-wait.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/top-level-async.d.ts +8 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/top-level-async.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/top-level-async.js +6 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/top-level-async.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/wait-config.d.ts +7 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/wait-config.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/wait-config.js +34 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/wait-config.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/wait-tool.d.ts +4 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/wait-tool.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/wait-tool.js +24 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/wait-tool.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/async-steering-action.d.ts +23 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/async-steering-action.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/async-steering-action.js +230 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/async-steering-action.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/chain-clarify.d.ts +127 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/chain-clarify.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/chain-clarify.js +1161 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/chain-clarify.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/chain-execution.d.ts +81 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/chain-execution.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/chain-execution.js +1014 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/chain-execution.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/execution.d.ts +10 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/execution.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/execution.js +1374 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/execution.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/subagent-executor.d.ts +87 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/subagent-executor.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/subagent-executor.js +3358 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/subagent-executor.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/acceptance.d.ts +64 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/acceptance.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/acceptance.js +1122 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/acceptance.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/chain-outputs.d.ts +19 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/chain-outputs.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/chain-outputs.js +106 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/chain-outputs.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/child-protocol.d.ts +27 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/child-protocol.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/child-protocol.js +108 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/child-protocol.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/completion-guard.d.ts +19 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/completion-guard.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/completion-guard.js +51 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/completion-guard.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/dynamic-fanout.d.ts +49 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/dynamic-fanout.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/dynamic-fanout.js +274 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/dynamic-fanout.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/long-running-guard.d.ts +33 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/long-running-guard.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/long-running-guard.js +152 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/long-running-guard.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/mcp-direct-tool-allowlist.d.ts +18 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/mcp-direct-tool-allowlist.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/mcp-direct-tool-allowlist.js +326 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/mcp-direct-tool-allowlist.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/model-fallback.d.ts +83 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/model-fallback.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/model-fallback.js +291 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/model-fallback.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/model-scope.d.ts +49 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/model-scope.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/model-scope.js +98 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/model-scope.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/nested-events.d.ts +121 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/nested-events.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/nested-events.js +881 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/nested-events.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/nested-path.d.ts +11 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/nested-path.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/nested-path.js +50 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/nested-path.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/nested-render.d.ts +19 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/nested-render.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/nested-render.js +109 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/nested-render.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/parallel-utils.d.ts +101 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/parallel-utils.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/parallel-utils.js +112 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/parallel-utils.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/pi-args.d.ts +80 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/pi-args.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/pi-args.js +252 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/pi-args.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/pi-spawn.d.ts +25 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/pi-spawn.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/pi-spawn.js +111 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/pi-spawn.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/run-history.d.ts +11 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/run-history.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/run-history.js +57 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/run-history.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/session-lease.d.ts +54 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/session-lease.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/session-lease.js +244 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/session-lease.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/single-output.d.ts +50 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/single-output.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/single-output.js +202 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/single-output.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/structured-output.d.ts +22 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/structured-output.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/structured-output.js +67 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/structured-output.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/subagent-control.d.ts +35 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/subagent-control.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/subagent-control.js +187 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/subagent-control.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/subagent-prompt-runtime.d.ts +22 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/subagent-prompt-runtime.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/subagent-prompt-runtime.js +438 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/subagent-prompt-runtime.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/task-intent.d.ts +35 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/task-intent.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/task-intent.js +154 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/task-intent.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/tool-availability.d.ts +13 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/tool-availability.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/tool-availability.js +51 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/tool-availability.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/tool-budget.d.ts +16 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/tool-budget.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/tool-budget.js +74 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/tool-budget.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/turn-budget.d.ts +14 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/turn-budget.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/turn-budget.js +66 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/turn-budget.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/workflow-graph.d.ts +30 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/workflow-graph.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/workflow-graph.js +200 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/workflow-graph.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/worktree.d.ts +49 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/worktree.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/worktree.js +473 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/worktree.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/shared/artifacts.d.ts +13 -0
- package/dist/builtin-extensions/pi-subagents/src/shared/artifacts.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/shared/artifacts.js +104 -0
- package/dist/builtin-extensions/pi-subagents/src/shared/artifacts.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/shared/atomic-json.d.ts +17 -0
- package/dist/builtin-extensions/pi-subagents/src/shared/atomic-json.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/shared/atomic-json.js +68 -0
- package/dist/builtin-extensions/pi-subagents/src/shared/atomic-json.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/shared/child-transcript.d.ts +36 -0
- package/dist/builtin-extensions/pi-subagents/src/shared/child-transcript.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/shared/child-transcript.js +173 -0
- package/dist/builtin-extensions/pi-subagents/src/shared/child-transcript.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/shared/file-coalescer.d.ts +11 -0
- package/dist/builtin-extensions/pi-subagents/src/shared/file-coalescer.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/shared/file-coalescer.js +26 -0
- package/dist/builtin-extensions/pi-subagents/src/shared/file-coalescer.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/shared/fork-context.d.ts +44 -0
- package/dist/builtin-extensions/pi-subagents/src/shared/fork-context.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/shared/fork-context.js +158 -0
- package/dist/builtin-extensions/pi-subagents/src/shared/fork-context.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/shared/formatters.d.ts +34 -0
- package/dist/builtin-extensions/pi-subagents/src/shared/formatters.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/shared/formatters.js +128 -0
- package/dist/builtin-extensions/pi-subagents/src/shared/formatters.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/shared/jsonl-writer.d.ts +20 -0
- package/dist/builtin-extensions/pi-subagents/src/shared/jsonl-writer.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/shared/jsonl-writer.js +59 -0
- package/dist/builtin-extensions/pi-subagents/src/shared/jsonl-writer.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/shared/model-info.d.ts +31 -0
- package/dist/builtin-extensions/pi-subagents/src/shared/model-info.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/shared/model-info.js +68 -0
- package/dist/builtin-extensions/pi-subagents/src/shared/model-info.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/shared/post-exit-stdio-guard.d.ts +17 -0
- package/dist/builtin-extensions/pi-subagents/src/shared/post-exit-stdio-guard.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/shared/post-exit-stdio-guard.js +72 -0
- package/dist/builtin-extensions/pi-subagents/src/shared/post-exit-stdio-guard.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/shared/session-identity.d.ts +7 -0
- package/dist/builtin-extensions/pi-subagents/src/shared/session-identity.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/shared/session-identity.js +7 -0
- package/dist/builtin-extensions/pi-subagents/src/shared/session-identity.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/shared/session-tokens.d.ts +3 -0
- package/dist/builtin-extensions/pi-subagents/src/shared/session-tokens.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/shared/session-tokens.js +49 -0
- package/dist/builtin-extensions/pi-subagents/src/shared/session-tokens.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/shared/settings.d.ts +136 -0
- package/dist/builtin-extensions/pi-subagents/src/shared/settings.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/shared/settings.js +285 -0
- package/dist/builtin-extensions/pi-subagents/src/shared/settings.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/shared/status-format.d.ts +10 -0
- package/dist/builtin-extensions/pi-subagents/src/shared/status-format.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/shared/status-format.js +61 -0
- package/dist/builtin-extensions/pi-subagents/src/shared/status-format.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/shared/types.d.ts +1101 -0
- package/dist/builtin-extensions/pi-subagents/src/shared/types.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/shared/types.js +221 -0
- package/dist/builtin-extensions/pi-subagents/src/shared/types.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/shared/utils.d.ts +52 -0
- package/dist/builtin-extensions/pi-subagents/src/shared/utils.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/shared/utils.js +562 -0
- package/dist/builtin-extensions/pi-subagents/src/shared/utils.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/slash/delegation-adapters.d.ts +149 -0
- package/dist/builtin-extensions/pi-subagents/src/slash/delegation-adapters.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/slash/delegation-adapters.js +321 -0
- package/dist/builtin-extensions/pi-subagents/src/slash/delegation-adapters.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/slash/delegation-request.d.ts +11 -0
- package/dist/builtin-extensions/pi-subagents/src/slash/delegation-request.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/slash/delegation-request.js +102 -0
- package/dist/builtin-extensions/pi-subagents/src/slash/delegation-request.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/slash/prompt-template-bridge.d.ts +25 -0
- package/dist/builtin-extensions/pi-subagents/src/slash/prompt-template-bridge.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/slash/prompt-template-bridge.js +200 -0
- package/dist/builtin-extensions/pi-subagents/src/slash/prompt-template-bridge.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/slash/prompt-workflows.d.ts +23 -0
- package/dist/builtin-extensions/pi-subagents/src/slash/prompt-workflows.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/slash/prompt-workflows.js +305 -0
- package/dist/builtin-extensions/pi-subagents/src/slash/prompt-workflows.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/slash/slash-bridge.d.ts +31 -0
- package/dist/builtin-extensions/pi-subagents/src/slash/slash-bridge.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/slash/slash-bridge.js +117 -0
- package/dist/builtin-extensions/pi-subagents/src/slash/slash-bridge.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/slash/slash-commands.d.ts +51 -0
- package/dist/builtin-extensions/pi-subagents/src/slash/slash-commands.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/slash/slash-commands.js +1531 -0
- package/dist/builtin-extensions/pi-subagents/src/slash/slash-commands.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/slash/slash-live-state.d.ts +22 -0
- package/dist/builtin-extensions/pi-subagents/src/slash/slash-live-state.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/slash/slash-live-state.js +246 -0
- package/dist/builtin-extensions/pi-subagents/src/slash/slash-live-state.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/tui/fleet.d.ts +78 -0
- package/dist/builtin-extensions/pi-subagents/src/tui/fleet.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/tui/fleet.js +401 -0
- package/dist/builtin-extensions/pi-subagents/src/tui/fleet.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/tui/render-helpers.d.ts +13 -0
- package/dist/builtin-extensions/pi-subagents/src/tui/render-helpers.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/tui/render-helpers.js +74 -0
- package/dist/builtin-extensions/pi-subagents/src/tui/render-helpers.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/tui/render.d.ts +35 -0
- package/dist/builtin-extensions/pi-subagents/src/tui/render.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/tui/render.js +1687 -0
- package/dist/builtin-extensions/pi-subagents/src/tui/render.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/watchdog/change-signature.d.ts +8 -0
- package/dist/builtin-extensions/pi-subagents/src/watchdog/change-signature.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/watchdog/change-signature.js +123 -0
- package/dist/builtin-extensions/pi-subagents/src/watchdog/change-signature.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/watchdog/child-status.d.ts +58 -0
- package/dist/builtin-extensions/pi-subagents/src/watchdog/child-status.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/watchdog/child-status.js +160 -0
- package/dist/builtin-extensions/pi-subagents/src/watchdog/child-status.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/watchdog/emission-guard.d.ts +34 -0
- package/dist/builtin-extensions/pi-subagents/src/watchdog/emission-guard.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/watchdog/emission-guard.js +96 -0
- package/dist/builtin-extensions/pi-subagents/src/watchdog/emission-guard.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/watchdog/lsp-diagnostics.d.ts +18 -0
- package/dist/builtin-extensions/pi-subagents/src/watchdog/lsp-diagnostics.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/watchdog/lsp-diagnostics.js +485 -0
- package/dist/builtin-extensions/pi-subagents/src/watchdog/lsp-diagnostics.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/watchdog/model-selection.d.ts +21 -0
- package/dist/builtin-extensions/pi-subagents/src/watchdog/model-selection.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/watchdog/model-selection.js +151 -0
- package/dist/builtin-extensions/pi-subagents/src/watchdog/model-selection.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/watchdog/register-child.d.ts +4 -0
- package/dist/builtin-extensions/pi-subagents/src/watchdog/register-child.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/watchdog/register-child.js +111 -0
- package/dist/builtin-extensions/pi-subagents/src/watchdog/register-child.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/watchdog/register-main.d.ts +10 -0
- package/dist/builtin-extensions/pi-subagents/src/watchdog/register-main.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/watchdog/register-main.js +407 -0
- package/dist/builtin-extensions/pi-subagents/src/watchdog/register-main.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/watchdog/render.d.ts +12 -0
- package/dist/builtin-extensions/pi-subagents/src/watchdog/render.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/watchdog/render.js +55 -0
- package/dist/builtin-extensions/pi-subagents/src/watchdog/render.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/watchdog/review.d.ts +29 -0
- package/dist/builtin-extensions/pi-subagents/src/watchdog/review.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/watchdog/review.js +245 -0
- package/dist/builtin-extensions/pi-subagents/src/watchdog/review.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/watchdog/runtime.d.ts +141 -0
- package/dist/builtin-extensions/pi-subagents/src/watchdog/runtime.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/watchdog/runtime.js +647 -0
- package/dist/builtin-extensions/pi-subagents/src/watchdog/runtime.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/watchdog/settings.d.ts +30 -0
- package/dist/builtin-extensions/pi-subagents/src/watchdog/settings.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/watchdog/settings.js +486 -0
- package/dist/builtin-extensions/pi-subagents/src/watchdog/settings.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/watchdog/tool-actions.d.ts +18 -0
- package/dist/builtin-extensions/pi-subagents/src/watchdog/tool-actions.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/watchdog/tool-actions.js +150 -0
- package/dist/builtin-extensions/pi-subagents/src/watchdog/tool-actions.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/watchdog/turn-delta.d.ts +10 -0
- package/dist/builtin-extensions/pi-subagents/src/watchdog/turn-delta.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/watchdog/turn-delta.js +159 -0
- package/dist/builtin-extensions/pi-subagents/src/watchdog/turn-delta.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/watchdog/types.d.ts +143 -0
- package/dist/builtin-extensions/pi-subagents/src/watchdog/types.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/watchdog/types.js +31 -0
- package/dist/builtin-extensions/pi-subagents/src/watchdog/types.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/watchdog/warning-format.d.ts +8 -0
- package/dist/builtin-extensions/pi-subagents/src/watchdog/warning-format.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/watchdog/warning-format.js +62 -0
- package/dist/builtin-extensions/pi-subagents/src/watchdog/warning-format.js.map +1 -0
- package/dist/builtin-extensions/pi-tps.d.ts +3 -0
- package/dist/builtin-extensions/pi-tps.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-tps.js +89 -0
- package/dist/builtin-extensions/pi-tps.js.map +1 -0
- package/dist/builtin-extensions/pi-web-access/activity.d.ts +34 -0
- package/dist/builtin-extensions/pi-web-access/activity.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-web-access/activity.js +68 -0
- package/dist/builtin-extensions/pi-web-access/activity.js.map +1 -0
- package/dist/builtin-extensions/pi-web-access/brave.d.ts +4 -0
- package/dist/builtin-extensions/pi-web-access/brave.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-web-access/brave.js +185 -0
- package/dist/builtin-extensions/pi-web-access/brave.js.map +1 -0
- package/dist/builtin-extensions/pi-web-access/chrome-cookies.d.ts +9 -0
- package/dist/builtin-extensions/pi-web-access/chrome-cookies.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-web-access/chrome-cookies.js +299 -0
- package/dist/builtin-extensions/pi-web-access/chrome-cookies.js.map +1 -0
- package/dist/builtin-extensions/pi-web-access/curator-page.d.ts +13 -0
- package/dist/builtin-extensions/pi-web-access/curator-page.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-web-access/curator-page.js +3382 -0
- package/dist/builtin-extensions/pi-web-access/curator-page.js.map +1 -0
- package/dist/builtin-extensions/pi-web-access/curator-server.d.ts +71 -0
- package/dist/builtin-extensions/pi-web-access/curator-server.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-web-access/curator-server.js +604 -0
- package/dist/builtin-extensions/pi-web-access/curator-server.js.map +1 -0
- package/dist/builtin-extensions/pi-web-access/exa.d.ts +10 -0
- package/dist/builtin-extensions/pi-web-access/exa.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-web-access/exa.js +391 -0
- package/dist/builtin-extensions/pi-web-access/exa.js.map +1 -0
- package/dist/builtin-extensions/pi-web-access/extract.d.ts +48 -0
- package/dist/builtin-extensions/pi-web-access/extract.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-web-access/extract.js +619 -0
- package/dist/builtin-extensions/pi-web-access/extract.js.map +1 -0
- package/dist/builtin-extensions/pi-web-access/fetch-params.d.ts +21 -0
- package/dist/builtin-extensions/pi-web-access/fetch-params.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-web-access/fetch-params.js +44 -0
- package/dist/builtin-extensions/pi-web-access/fetch-params.js.map +1 -0
- package/dist/builtin-extensions/pi-web-access/gemini-api.d.ts +18 -0
- package/dist/builtin-extensions/pi-web-access/gemini-api.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-web-access/gemini-api.js +120 -0
- package/dist/builtin-extensions/pi-web-access/gemini-api.js.map +1 -0
- package/dist/builtin-extensions/pi-web-access/gemini-search.d.ts +14 -0
- package/dist/builtin-extensions/pi-web-access/gemini-search.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-web-access/gemini-search.js +371 -0
- package/dist/builtin-extensions/pi-web-access/gemini-search.js.map +1 -0
- package/dist/builtin-extensions/pi-web-access/gemini-url-context.d.ts +4 -0
- package/dist/builtin-extensions/pi-web-access/gemini-url-context.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-web-access/gemini-url-context.js +101 -0
- package/dist/builtin-extensions/pi-web-access/gemini-url-context.js.map +1 -0
- package/dist/builtin-extensions/pi-web-access/gemini-web-config.d.ts +4 -0
- package/dist/builtin-extensions/pi-web-access/gemini-web-config.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-web-access/gemini-web-config.js +43 -0
- package/dist/builtin-extensions/pi-web-access/gemini-web-config.js.map +1 -0
- package/dist/builtin-extensions/pi-web-access/gemini-web.d.ts +12 -0
- package/dist/builtin-extensions/pi-web-access/gemini-web.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-web-access/gemini-web.js +331 -0
- package/dist/builtin-extensions/pi-web-access/gemini-web.js.map +1 -0
- package/dist/builtin-extensions/pi-web-access/github-api.d.ts +7 -0
- package/dist/builtin-extensions/pi-web-access/github-api.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-web-access/github-api.js +161 -0
- package/dist/builtin-extensions/pi-web-access/github-api.js.map +1 -0
- package/dist/builtin-extensions/pi-web-access/github-extract.d.ts +13 -0
- package/dist/builtin-extensions/pi-web-access/github-extract.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-web-access/github-extract.js +558 -0
- package/dist/builtin-extensions/pi-web-access/github-extract.js.map +1 -0
- package/dist/builtin-extensions/pi-web-access/index.d.ts +3 -0
- package/dist/builtin-extensions/pi-web-access/index.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-web-access/index.js +2347 -0
- package/dist/builtin-extensions/pi-web-access/index.js.map +1 -0
- package/dist/builtin-extensions/pi-web-access/openai-search.d.ts +13 -0
- package/dist/builtin-extensions/pi-web-access/openai-search.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-web-access/openai-search.js +374 -0
- package/dist/builtin-extensions/pi-web-access/openai-search.js.map +1 -0
- package/dist/builtin-extensions/pi-web-access/parallel.d.ts +12 -0
- package/dist/builtin-extensions/pi-web-access/parallel.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-web-access/parallel.js +316 -0
- package/dist/builtin-extensions/pi-web-access/parallel.js.map +1 -0
- package/dist/builtin-extensions/pi-web-access/pdf-extract.d.ts +26 -0
- package/dist/builtin-extensions/pi-web-access/pdf-extract.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-web-access/pdf-extract.js +150 -0
- package/dist/builtin-extensions/pi-web-access/pdf-extract.js.map +1 -0
- package/dist/builtin-extensions/pi-web-access/perplexity.d.ts +20 -0
- package/dist/builtin-extensions/pi-web-access/perplexity.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-web-access/perplexity.js +150 -0
- package/dist/builtin-extensions/pi-web-access/perplexity.js.map +1 -0
- package/dist/builtin-extensions/pi-web-access/render-search-error.d.ts +57 -0
- package/dist/builtin-extensions/pi-web-access/render-search-error.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-web-access/render-search-error.js +131 -0
- package/dist/builtin-extensions/pi-web-access/render-search-error.js.map +1 -0
- package/dist/builtin-extensions/pi-web-access/rsc-extract.d.ts +12 -0
- package/dist/builtin-extensions/pi-web-access/rsc-extract.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-web-access/rsc-extract.js +330 -0
- package/dist/builtin-extensions/pi-web-access/rsc-extract.js.map +1 -0
- package/dist/builtin-extensions/pi-web-access/ssrf-protection.d.ts +24 -0
- package/dist/builtin-extensions/pi-web-access/ssrf-protection.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-web-access/ssrf-protection.js +255 -0
- package/dist/builtin-extensions/pi-web-access/ssrf-protection.js.map +1 -0
- package/dist/builtin-extensions/pi-web-access/storage.d.ts +25 -0
- package/dist/builtin-extensions/pi-web-access/storage.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-web-access/storage.js +49 -0
- package/dist/builtin-extensions/pi-web-access/storage.js.map +1 -0
- package/dist/builtin-extensions/pi-web-access/summary-model-scope.d.ts +13 -0
- package/dist/builtin-extensions/pi-web-access/summary-model-scope.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-web-access/summary-model-scope.js +86 -0
- package/dist/builtin-extensions/pi-web-access/summary-model-scope.js.map +1 -0
- package/dist/builtin-extensions/pi-web-access/summary-review.d.ts +21 -0
- package/dist/builtin-extensions/pi-web-access/summary-review.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-web-access/summary-review.js +278 -0
- package/dist/builtin-extensions/pi-web-access/summary-review.js.map +1 -0
- package/dist/builtin-extensions/pi-web-access/tavily.d.ts +8 -0
- package/dist/builtin-extensions/pi-web-access/tavily.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-web-access/tavily.js +184 -0
- package/dist/builtin-extensions/pi-web-access/tavily.js.map +1 -0
- package/dist/builtin-extensions/pi-web-access/utils.d.ts +12 -0
- package/dist/builtin-extensions/pi-web-access/utils.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-web-access/utils.js +61 -0
- package/dist/builtin-extensions/pi-web-access/utils.js.map +1 -0
- package/dist/builtin-extensions/pi-web-access/video-extract.d.ts +14 -0
- package/dist/builtin-extensions/pi-web-access/video-extract.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-web-access/video-extract.js +324 -0
- package/dist/builtin-extensions/pi-web-access/video-extract.js.map +1 -0
- package/dist/builtin-extensions/pi-web-access/youtube-extract.d.ts +27 -0
- package/dist/builtin-extensions/pi-web-access/youtube-extract.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-web-access/youtube-extract.js +282 -0
- package/dist/builtin-extensions/pi-web-access/youtube-extract.js.map +1 -0
- package/dist/builtin-extensions/simple-pi-memory.d.ts +55 -0
- package/dist/builtin-extensions/simple-pi-memory.d.ts.map +1 -0
- package/dist/builtin-extensions/simple-pi-memory.js +239 -0
- package/dist/builtin-extensions/simple-pi-memory.js.map +1 -0
- package/dist/bun/cli.d.ts +3 -0
- package/dist/bun/cli.d.ts.map +1 -0
- package/dist/bun/cli.js +11 -0
- package/dist/bun/cli.js.map +1 -0
- package/dist/bun/register-bedrock.d.ts +2 -0
- package/dist/bun/register-bedrock.d.ts.map +1 -0
- package/dist/bun/register-bedrock.js +4 -0
- package/dist/bun/register-bedrock.js.map +1 -0
- package/dist/bun/restore-sandbox-env.d.ts +17 -0
- package/dist/bun/restore-sandbox-env.d.ts.map +1 -0
- package/dist/bun/restore-sandbox-env.js +36 -0
- package/dist/bun/restore-sandbox-env.js.map +1 -0
- package/dist/catalog/models.json +1 -0
- package/dist/catalog/providers/amazon-bedrock.json +1 -0
- package/dist/catalog/providers/ant-ling.json +1 -0
- package/dist/catalog/providers/anthropic.json +1 -0
- package/dist/catalog/providers/azure-openai-responses.json +1 -0
- package/dist/catalog/providers/cerebras.json +1 -0
- package/dist/catalog/providers/cloudflare-ai-gateway.json +1 -0
- package/dist/catalog/providers/cloudflare-workers-ai.json +1 -0
- package/dist/catalog/providers/deepseek.json +1 -0
- package/dist/catalog/providers/fireworks.json +1 -0
- package/dist/catalog/providers/github-copilot.json +1 -0
- package/dist/catalog/providers/google-vertex.json +1 -0
- package/dist/catalog/providers/google.json +1 -0
- package/dist/catalog/providers/groq.json +1 -0
- package/dist/catalog/providers/huggingface.json +1 -0
- package/dist/catalog/providers/kimi-coding.json +1 -0
- package/dist/catalog/providers/minimax-cn.json +1 -0
- package/dist/catalog/providers/minimax.json +1 -0
- package/dist/catalog/providers/mistral.json +1 -0
- package/dist/catalog/providers/moonshotai-cn.json +1 -0
- package/dist/catalog/providers/moonshotai.json +1 -0
- package/dist/catalog/providers/nvidia.json +1 -0
- package/dist/catalog/providers/openai-codex.json +1 -0
- package/dist/catalog/providers/openai.json +1 -0
- package/dist/catalog/providers/opencode-go.json +1 -0
- package/dist/catalog/providers/opencode.json +1 -0
- package/dist/catalog/providers/openrouter.json +1 -0
- package/dist/catalog/providers/qwen-cloud-cn.json +1 -0
- package/dist/catalog/providers/qwen-cloud.json +1 -0
- package/dist/catalog/providers/qwen-token-plan-cn.json +1 -0
- package/dist/catalog/providers/qwen-token-plan.json +1 -0
- package/dist/catalog/providers/together.json +1 -0
- package/dist/catalog/providers/vercel-ai-gateway.json +1 -0
- package/dist/catalog/providers/xai.json +1 -0
- package/dist/catalog/providers/xiaomi-token-plan-ams.json +1 -0
- package/dist/catalog/providers/xiaomi-token-plan-cn.json +1 -0
- package/dist/catalog/providers/xiaomi-token-plan-sgp.json +1 -0
- package/dist/catalog/providers/xiaomi.json +1 -0
- package/dist/catalog/providers/zai-coding-cn.json +1 -0
- package/dist/catalog/providers/zai.json +1 -0
- package/dist/catalog/providers.json +1 -0
- package/dist/catalog/publication.json +6 -0
- package/dist/cli/args.d.ts +57 -0
- package/dist/cli/args.d.ts.map +1 -0
- package/dist/cli/args.js +381 -0
- package/dist/cli/args.js.map +1 -0
- package/dist/cli/config-selector.d.ts +16 -0
- package/dist/cli/config-selector.d.ts.map +1 -0
- package/dist/cli/config-selector.js +31 -0
- package/dist/cli/config-selector.js.map +1 -0
- package/dist/cli/file-processor.d.ts +15 -0
- package/dist/cli/file-processor.d.ts.map +1 -0
- package/dist/cli/file-processor.js +70 -0
- package/dist/cli/file-processor.js.map +1 -0
- package/dist/cli/initial-message.d.ts +18 -0
- package/dist/cli/initial-message.d.ts.map +1 -0
- package/dist/cli/initial-message.js +22 -0
- package/dist/cli/initial-message.js.map +1 -0
- package/dist/cli/install-cli.d.ts +13 -0
- package/dist/cli/install-cli.d.ts.map +1 -0
- package/dist/cli/install-cli.js +352 -0
- package/dist/cli/install-cli.js.map +1 -0
- package/dist/cli/list-models.d.ts +9 -0
- package/dist/cli/list-models.d.ts.map +1 -0
- package/dist/cli/list-models.js +98 -0
- package/dist/cli/list-models.js.map +1 -0
- package/dist/cli/project-trust.d.ts +10 -0
- package/dist/cli/project-trust.d.ts.map +1 -0
- package/dist/cli/project-trust.js +48 -0
- package/dist/cli/project-trust.js.map +1 -0
- package/dist/cli/read-secret.d.ts +6 -0
- package/dist/cli/read-secret.d.ts.map +1 -0
- package/dist/cli/read-secret.js +62 -0
- package/dist/cli/read-secret.js.map +1 -0
- package/dist/cli/session-picker.d.ts +10 -0
- package/dist/cli/session-picker.d.ts.map +1 -0
- package/dist/cli/session-picker.js +36 -0
- package/dist/cli/session-picker.js.map +1 -0
- package/dist/cli/startup-ui.d.ts +20 -0
- package/dist/cli/startup-ui.d.ts.map +1 -0
- package/dist/cli/startup-ui.js +190 -0
- package/dist/cli/startup-ui.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +18 -0
- package/dist/cli.js.map +1 -0
- package/dist/config.d.ts +84 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +211 -0
- package/dist/config.js.map +1 -0
- package/dist/core/agent-session-runtime.d.ts +119 -0
- package/dist/core/agent-session-runtime.d.ts.map +1 -0
- package/dist/core/agent-session-runtime.js +306 -0
- package/dist/core/agent-session-runtime.js.map +1 -0
- package/dist/core/agent-session-services.d.ts +85 -0
- package/dist/core/agent-session-services.d.ts.map +1 -0
- package/dist/core/agent-session-services.js +120 -0
- package/dist/core/agent-session-services.js.map +1 -0
- package/dist/core/agent-session.d.ts +650 -0
- package/dist/core/agent-session.d.ts.map +1 -0
- package/dist/core/agent-session.js +2797 -0
- package/dist/core/agent-session.js.map +1 -0
- package/dist/core/auth-guidance.d.ts +5 -0
- package/dist/core/auth-guidance.d.ts.map +1 -0
- package/dist/core/auth-guidance.js +21 -0
- package/dist/core/auth-guidance.js.map +1 -0
- package/dist/core/auth-storage.d.ts +56 -0
- package/dist/core/auth-storage.d.ts.map +1 -0
- package/dist/core/auth-storage.js +229 -0
- package/dist/core/auth-storage.js.map +1 -0
- package/dist/core/bash-executor.d.ts +32 -0
- package/dist/core/bash-executor.d.ts.map +1 -0
- package/dist/core/bash-executor.js +111 -0
- package/dist/core/bash-executor.js.map +1 -0
- package/dist/core/cache-stats.d.ts +49 -0
- package/dist/core/cache-stats.d.ts.map +1 -0
- package/dist/core/cache-stats.js +101 -0
- package/dist/core/cache-stats.js.map +1 -0
- package/dist/core/catalog-merge.d.ts +46 -0
- package/dist/core/catalog-merge.d.ts.map +1 -0
- package/dist/core/catalog-merge.js +128 -0
- package/dist/core/catalog-merge.js.map +1 -0
- package/dist/core/compaction/branch-summarization.d.ts +92 -0
- package/dist/core/compaction/branch-summarization.d.ts.map +1 -0
- package/dist/core/compaction/branch-summarization.js +249 -0
- package/dist/core/compaction/branch-summarization.js.map +1 -0
- package/dist/core/compaction/compaction.d.ts +121 -0
- package/dist/core/compaction/compaction.d.ts.map +1 -0
- package/dist/core/compaction/compaction.js +600 -0
- package/dist/core/compaction/compaction.js.map +1 -0
- package/dist/core/compaction/index.d.ts +7 -0
- package/dist/core/compaction/index.d.ts.map +1 -0
- package/dist/core/compaction/index.js +7 -0
- package/dist/core/compaction/index.js.map +1 -0
- package/dist/core/compaction/utils.d.ts +38 -0
- package/dist/core/compaction/utils.d.ts.map +1 -0
- package/dist/core/compaction/utils.js +153 -0
- package/dist/core/compaction/utils.js.map +1 -0
- package/dist/core/context-breakdown.d.ts +67 -0
- package/dist/core/context-breakdown.d.ts.map +1 -0
- package/dist/core/context-breakdown.js +116 -0
- package/dist/core/context-breakdown.js.map +1 -0
- package/dist/core/cron/fire-guard.d.ts +16 -0
- package/dist/core/cron/fire-guard.d.ts.map +1 -0
- package/dist/core/cron/fire-guard.js +24 -0
- package/dist/core/cron/fire-guard.js.map +1 -0
- package/dist/core/cron/jobs.d.ts +162 -0
- package/dist/core/cron/jobs.d.ts.map +1 -0
- package/dist/core/cron/jobs.js +545 -0
- package/dist/core/cron/jobs.js.map +1 -0
- package/dist/core/cron/origin-context.d.ts +22 -0
- package/dist/core/cron/origin-context.d.ts.map +1 -0
- package/dist/core/cron/origin-context.js +22 -0
- package/dist/core/cron/origin-context.js.map +1 -0
- package/dist/core/cron/scheduler.d.ts +51 -0
- package/dist/core/cron/scheduler.d.ts.map +1 -0
- package/dist/core/cron/scheduler.js +165 -0
- package/dist/core/cron/scheduler.js.map +1 -0
- package/dist/core/customize.d.ts +31 -0
- package/dist/core/customize.d.ts.map +1 -0
- package/dist/core/customize.js +54 -0
- package/dist/core/customize.js.map +1 -0
- package/dist/core/defaults.d.ts +3 -0
- package/dist/core/defaults.d.ts.map +1 -0
- package/dist/core/defaults.js +2 -0
- package/dist/core/defaults.js.map +1 -0
- package/dist/core/diagnostics.d.ts +15 -0
- package/dist/core/diagnostics.d.ts.map +1 -0
- package/dist/core/diagnostics.js +2 -0
- package/dist/core/diagnostics.js.map +1 -0
- package/dist/core/event-bus.d.ts +9 -0
- package/dist/core/event-bus.d.ts.map +1 -0
- package/dist/core/event-bus.js +25 -0
- package/dist/core/event-bus.js.map +1 -0
- package/dist/core/exec.d.ts +29 -0
- package/dist/core/exec.d.ts.map +1 -0
- package/dist/core/exec.js +75 -0
- package/dist/core/exec.js.map +1 -0
- package/dist/core/experimental.d.ts +2 -0
- package/dist/core/experimental.d.ts.map +1 -0
- package/dist/core/experimental.js +4 -0
- package/dist/core/experimental.js.map +1 -0
- package/dist/core/export-html/ansi-to-html.d.ts +22 -0
- package/dist/core/export-html/ansi-to-html.d.ts.map +1 -0
- package/dist/core/export-html/ansi-to-html.js +249 -0
- package/dist/core/export-html/ansi-to-html.js.map +1 -0
- package/dist/core/export-html/index.d.ts +37 -0
- package/dist/core/export-html/index.d.ts.map +1 -0
- package/dist/core/export-html/index.js +226 -0
- package/dist/core/export-html/index.js.map +1 -0
- package/dist/core/export-html/template.css +1066 -0
- package/dist/core/export-html/template.html +55 -0
- package/dist/core/export-html/template.js +1864 -0
- package/dist/core/export-html/tool-renderer.d.ts +34 -0
- package/dist/core/export-html/tool-renderer.d.ts.map +1 -0
- package/dist/core/export-html/tool-renderer.js +108 -0
- package/dist/core/export-html/tool-renderer.js.map +1 -0
- package/dist/core/export-html/vendor/highlight.min.js +1213 -0
- package/dist/core/export-html/vendor/marked.min.js +78 -0
- package/dist/core/extensions/index.d.ts +12 -0
- package/dist/core/extensions/index.d.ts.map +1 -0
- package/dist/core/extensions/index.js +9 -0
- package/dist/core/extensions/index.js.map +1 -0
- package/dist/core/extensions/loader.d.ts +23 -0
- package/dist/core/extensions/loader.d.ts.map +1 -0
- package/dist/core/extensions/loader.js +547 -0
- package/dist/core/extensions/loader.js.map +1 -0
- package/dist/core/extensions/runner.d.ts +170 -0
- package/dist/core/extensions/runner.d.ts.map +1 -0
- package/dist/core/extensions/runner.js +923 -0
- package/dist/core/extensions/runner.js.map +1 -0
- package/dist/core/extensions/types.d.ts +1247 -0
- package/dist/core/extensions/types.d.ts.map +1 -0
- package/dist/core/extensions/types.js +45 -0
- package/dist/core/extensions/types.js.map +1 -0
- package/dist/core/extensions/wrapper.d.ts +20 -0
- package/dist/core/extensions/wrapper.d.ts.map +1 -0
- package/dist/core/extensions/wrapper.js +41 -0
- package/dist/core/extensions/wrapper.js.map +1 -0
- package/dist/core/footer-data-provider.d.ts +54 -0
- package/dist/core/footer-data-provider.d.ts.map +1 -0
- package/dist/core/footer-data-provider.js +338 -0
- package/dist/core/footer-data-provider.js.map +1 -0
- package/dist/core/http-dispatcher.d.ts +22 -0
- package/dist/core/http-dispatcher.d.ts.map +1 -0
- package/dist/core/http-dispatcher.js +91 -0
- package/dist/core/http-dispatcher.js.map +1 -0
- package/dist/core/index.d.ts +13 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +13 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/injected-prompt.d.ts +20 -0
- package/dist/core/injected-prompt.d.ts.map +1 -0
- package/dist/core/injected-prompt.js +64 -0
- package/dist/core/injected-prompt.js.map +1 -0
- package/dist/core/install-features.d.ts +106 -0
- package/dist/core/install-features.d.ts.map +1 -0
- package/dist/core/install-features.js +392 -0
- package/dist/core/install-features.js.map +1 -0
- package/dist/core/install-layout.d.ts +18 -0
- package/dist/core/install-layout.d.ts.map +1 -0
- package/dist/core/install-layout.js +54 -0
- package/dist/core/install-layout.js.map +1 -0
- package/dist/core/keybindings.d.ts +373 -0
- package/dist/core/keybindings.d.ts.map +1 -0
- package/dist/core/keybindings.js +309 -0
- package/dist/core/keybindings.js.map +1 -0
- package/dist/core/live-catalog.d.ts +74 -0
- package/dist/core/live-catalog.d.ts.map +1 -0
- package/dist/core/live-catalog.js +351 -0
- package/dist/core/live-catalog.js.map +1 -0
- package/dist/core/memory-cap.d.ts +27 -0
- package/dist/core/memory-cap.d.ts.map +1 -0
- package/dist/core/memory-cap.js +32 -0
- package/dist/core/memory-cap.js.map +1 -0
- package/dist/core/messages.d.ts +77 -0
- package/dist/core/messages.d.ts.map +1 -0
- package/dist/core/messages.js +123 -0
- package/dist/core/messages.js.map +1 -0
- package/dist/core/model-config-writer.d.ts +24 -0
- package/dist/core/model-config-writer.d.ts.map +1 -0
- package/dist/core/model-config-writer.js +84 -0
- package/dist/core/model-config-writer.js.map +1 -0
- package/dist/core/model-config.d.ts +512 -0
- package/dist/core/model-config.d.ts.map +1 -0
- package/dist/core/model-config.js +243 -0
- package/dist/core/model-config.js.map +1 -0
- package/dist/core/model-registry.d.ts +39 -0
- package/dist/core/model-registry.d.ts.map +1 -0
- package/dist/core/model-registry.js +89 -0
- package/dist/core/model-registry.js.map +1 -0
- package/dist/core/model-resolver.d.ts +121 -0
- package/dist/core/model-resolver.d.ts.map +1 -0
- package/dist/core/model-resolver.js +536 -0
- package/dist/core/model-resolver.js.map +1 -0
- package/dist/core/model-runtime.d.ts +115 -0
- package/dist/core/model-runtime.d.ts.map +1 -0
- package/dist/core/model-runtime.js +640 -0
- package/dist/core/model-runtime.js.map +1 -0
- package/dist/core/model-tiers.d.ts +34 -0
- package/dist/core/model-tiers.d.ts.map +1 -0
- package/dist/core/model-tiers.js +53 -0
- package/dist/core/model-tiers.js.map +1 -0
- package/dist/core/models-store.d.ts +17 -0
- package/dist/core/models-store.d.ts.map +1 -0
- package/dist/core/models-store.js +45 -0
- package/dist/core/models-store.js.map +1 -0
- package/dist/core/official-catalog.d.ts +72 -0
- package/dist/core/official-catalog.d.ts.map +1 -0
- package/dist/core/official-catalog.js +370 -0
- package/dist/core/official-catalog.js.map +1 -0
- package/dist/core/output-guard.d.ts +7 -0
- package/dist/core/output-guard.d.ts.map +1 -0
- package/dist/core/output-guard.js +89 -0
- package/dist/core/output-guard.js.map +1 -0
- package/dist/core/package-manager.d.ts +198 -0
- package/dist/core/package-manager.d.ts.map +1 -0
- package/dist/core/package-manager.js +2005 -0
- package/dist/core/package-manager.js.map +1 -0
- package/dist/core/permission-mode.d.ts +19 -0
- package/dist/core/permission-mode.d.ts.map +1 -0
- package/dist/core/permission-mode.js +26 -0
- package/dist/core/permission-mode.js.map +1 -0
- package/dist/core/permissions.d.ts +99 -0
- package/dist/core/permissions.d.ts.map +1 -0
- package/dist/core/permissions.js +323 -0
- package/dist/core/permissions.js.map +1 -0
- package/dist/core/plan-mode.d.ts +37 -0
- package/dist/core/plan-mode.d.ts.map +1 -0
- package/dist/core/plan-mode.js +388 -0
- package/dist/core/plan-mode.js.map +1 -0
- package/dist/core/process-registry.d.ts +40 -0
- package/dist/core/process-registry.d.ts.map +1 -0
- package/dist/core/process-registry.js +190 -0
- package/dist/core/process-registry.js.map +1 -0
- package/dist/core/project-trust.d.ts +15 -0
- package/dist/core/project-trust.d.ts.map +1 -0
- package/dist/core/project-trust.js +59 -0
- package/dist/core/project-trust.js.map +1 -0
- package/dist/core/prompt-templates.d.ts +53 -0
- package/dist/core/prompt-templates.d.ts.map +1 -0
- package/dist/core/prompt-templates.js +236 -0
- package/dist/core/prompt-templates.js.map +1 -0
- package/dist/core/provider-attribution.d.ts +4 -0
- package/dist/core/provider-attribution.d.ts.map +1 -0
- package/dist/core/provider-attribution.js +31 -0
- package/dist/core/provider-attribution.js.map +1 -0
- package/dist/core/provider-composer.d.ts +55 -0
- package/dist/core/provider-composer.d.ts.map +1 -0
- package/dist/core/provider-composer.js +375 -0
- package/dist/core/provider-composer.js.map +1 -0
- package/dist/core/radius.d.ts +2 -0
- package/dist/core/radius.d.ts.map +1 -0
- package/dist/core/radius.js +2 -0
- package/dist/core/radius.js.map +1 -0
- package/dist/core/resolve-config-value.d.ts +30 -0
- package/dist/core/resolve-config-value.d.ts.map +1 -0
- package/dist/core/resolve-config-value.js +247 -0
- package/dist/core/resolve-config-value.js.map +1 -0
- package/dist/core/resource-loader.d.ts +206 -0
- package/dist/core/resource-loader.d.ts.map +1 -0
- package/dist/core/resource-loader.js +816 -0
- package/dist/core/resource-loader.js.map +1 -0
- package/dist/core/rollback.d.ts +80 -0
- package/dist/core/rollback.d.ts.map +1 -0
- package/dist/core/rollback.js +582 -0
- package/dist/core/rollback.js.map +1 -0
- package/dist/core/runtime-credentials.d.ts +15 -0
- package/dist/core/runtime-credentials.d.ts.map +1 -0
- package/dist/core/runtime-credentials.js +36 -0
- package/dist/core/runtime-credentials.js.map +1 -0
- package/dist/core/sdk.d.ts +106 -0
- package/dist/core/sdk.d.ts.map +1 -0
- package/dist/core/sdk.js +264 -0
- package/dist/core/sdk.js.map +1 -0
- package/dist/core/search-curator.d.ts +23 -0
- package/dist/core/search-curator.d.ts.map +1 -0
- package/dist/core/search-curator.js +34 -0
- package/dist/core/search-curator.js.map +1 -0
- package/dist/core/session-cwd.d.ts +19 -0
- package/dist/core/session-cwd.d.ts.map +1 -0
- package/dist/core/session-cwd.js +38 -0
- package/dist/core/session-cwd.js.map +1 -0
- package/dist/core/session-manager.d.ts +351 -0
- package/dist/core/session-manager.d.ts.map +1 -0
- package/dist/core/session-manager.js +1262 -0
- package/dist/core/session-manager.js.map +1 -0
- package/dist/core/session-retention.d.ts +17 -0
- package/dist/core/session-retention.d.ts.map +1 -0
- package/dist/core/session-retention.js +69 -0
- package/dist/core/session-retention.js.map +1 -0
- package/dist/core/settings-manager.d.ts +355 -0
- package/dist/core/settings-manager.d.ts.map +1 -0
- package/dist/core/settings-manager.js +1064 -0
- package/dist/core/settings-manager.js.map +1 -0
- package/dist/core/skills.d.ts +60 -0
- package/dist/core/skills.d.ts.map +1 -0
- package/dist/core/skills.js +387 -0
- package/dist/core/skills.js.map +1 -0
- package/dist/core/slash-commands.d.ts +15 -0
- package/dist/core/slash-commands.d.ts.map +1 -0
- package/dist/core/slash-commands.js +58 -0
- package/dist/core/slash-commands.js.map +1 -0
- package/dist/core/source-info.d.ts +18 -0
- package/dist/core/source-info.d.ts.map +1 -0
- package/dist/core/source-info.js +19 -0
- package/dist/core/source-info.js.map +1 -0
- package/dist/core/subscriptions.d.ts +64 -0
- package/dist/core/subscriptions.d.ts.map +1 -0
- package/dist/core/subscriptions.js +259 -0
- package/dist/core/subscriptions.js.map +1 -0
- package/dist/core/swarm.d.ts +41 -0
- package/dist/core/swarm.d.ts.map +1 -0
- package/dist/core/swarm.js +81 -0
- package/dist/core/swarm.js.map +1 -0
- package/dist/core/system-prompt.d.ts +28 -0
- package/dist/core/system-prompt.d.ts.map +1 -0
- package/dist/core/system-prompt.js +107 -0
- package/dist/core/system-prompt.js.map +1 -0
- package/dist/core/timings.d.ts +10 -0
- package/dist/core/timings.d.ts.map +1 -0
- package/dist/core/timings.js +41 -0
- package/dist/core/timings.js.map +1 -0
- package/dist/core/tools/bash.d.ts +69 -0
- package/dist/core/tools/bash.d.ts.map +1 -0
- package/dist/core/tools/bash.js +395 -0
- package/dist/core/tools/bash.js.map +1 -0
- package/dist/core/tools/edit-diff.d.ts +106 -0
- package/dist/core/tools/edit-diff.d.ts.map +1 -0
- package/dist/core/tools/edit-diff.js +424 -0
- package/dist/core/tools/edit-diff.js.map +1 -0
- package/dist/core/tools/edit.d.ts +51 -0
- package/dist/core/tools/edit.d.ts.map +1 -0
- package/dist/core/tools/edit.js +293 -0
- package/dist/core/tools/edit.js.map +1 -0
- package/dist/core/tools/file-mutation-queue.d.ts +6 -0
- package/dist/core/tools/file-mutation-queue.d.ts.map +1 -0
- package/dist/core/tools/file-mutation-queue.js +52 -0
- package/dist/core/tools/file-mutation-queue.js.map +1 -0
- package/dist/core/tools/find.d.ts +35 -0
- package/dist/core/tools/find.d.ts.map +1 -0
- package/dist/core/tools/find.js +313 -0
- package/dist/core/tools/find.js.map +1 -0
- package/dist/core/tools/grep.d.ts +37 -0
- package/dist/core/tools/grep.d.ts.map +1 -0
- package/dist/core/tools/grep.js +312 -0
- package/dist/core/tools/grep.js.map +1 -0
- package/dist/core/tools/index.d.ts +40 -0
- package/dist/core/tools/index.d.ts.map +1 -0
- package/dist/core/tools/index.js +112 -0
- package/dist/core/tools/index.js.map +1 -0
- package/dist/core/tools/ls.d.ts +37 -0
- package/dist/core/tools/ls.d.ts.map +1 -0
- package/dist/core/tools/ls.js +175 -0
- package/dist/core/tools/ls.js.map +1 -0
- package/dist/core/tools/output-accumulator.d.ts +52 -0
- package/dist/core/tools/output-accumulator.d.ts.map +1 -0
- package/dist/core/tools/output-accumulator.js +184 -0
- package/dist/core/tools/output-accumulator.js.map +1 -0
- package/dist/core/tools/path-utils.d.ts +10 -0
- package/dist/core/tools/path-utils.d.ts.map +1 -0
- package/dist/core/tools/path-utils.js +99 -0
- package/dist/core/tools/path-utils.js.map +1 -0
- package/dist/core/tools/read.d.ts +35 -0
- package/dist/core/tools/read.d.ts.map +1 -0
- package/dist/core/tools/read.js +285 -0
- package/dist/core/tools/read.js.map +1 -0
- package/dist/core/tools/render-utils.d.ts +36 -0
- package/dist/core/tools/render-utils.d.ts.map +1 -0
- package/dist/core/tools/render-utils.js +88 -0
- package/dist/core/tools/render-utils.js.map +1 -0
- package/dist/core/tools/tool-definition-wrapper.d.ts +14 -0
- package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -0
- package/dist/core/tools/tool-definition-wrapper.js +34 -0
- package/dist/core/tools/tool-definition-wrapper.js.map +1 -0
- package/dist/core/tools/truncate.d.ts +70 -0
- package/dist/core/tools/truncate.d.ts.map +1 -0
- package/dist/core/tools/truncate.js +215 -0
- package/dist/core/tools/truncate.js.map +1 -0
- package/dist/core/tools/write.d.ts +26 -0
- package/dist/core/tools/write.d.ts.map +1 -0
- package/dist/core/tools/write.js +202 -0
- package/dist/core/tools/write.js.map +1 -0
- package/dist/core/trust-manager.d.ts +36 -0
- package/dist/core/trust-manager.d.ts.map +1 -0
- package/dist/core/trust-manager.js +202 -0
- package/dist/core/trust-manager.js.map +1 -0
- package/dist/core/usage-adapters/kimi-coding.d.ts +11 -0
- package/dist/core/usage-adapters/kimi-coding.d.ts.map +1 -0
- package/dist/core/usage-adapters/kimi-coding.js +78 -0
- package/dist/core/usage-adapters/kimi-coding.js.map +1 -0
- package/dist/core/usage-adapters/openai-codex.d.ts +4 -0
- package/dist/core/usage-adapters/openai-codex.d.ts.map +1 -0
- package/dist/core/usage-adapters/openai-codex.js +180 -0
- package/dist/core/usage-adapters/openai-codex.js.map +1 -0
- package/dist/core/usage-adapters/shared.d.ts +20 -0
- package/dist/core/usage-adapters/shared.d.ts.map +1 -0
- package/dist/core/usage-adapters/shared.js +75 -0
- package/dist/core/usage-adapters/shared.js.map +1 -0
- package/dist/core/usage-adapters/xai.d.ts +21 -0
- package/dist/core/usage-adapters/xai.d.ts.map +1 -0
- package/dist/core/usage-adapters/xai.js +77 -0
- package/dist/core/usage-adapters/xai.js.map +1 -0
- package/dist/core/usage-adapters/zai.d.ts +14 -0
- package/dist/core/usage-adapters/zai.d.ts.map +1 -0
- package/dist/core/usage-adapters/zai.js +67 -0
- package/dist/core/usage-adapters/zai.js.map +1 -0
- package/dist/core/usage-history.d.ts +63 -0
- package/dist/core/usage-history.d.ts.map +1 -0
- package/dist/core/usage-history.js +239 -0
- package/dist/core/usage-history.js.map +1 -0
- package/dist/core/usage-limit.d.ts +17 -0
- package/dist/core/usage-limit.d.ts.map +1 -0
- package/dist/core/usage-limit.js +79 -0
- package/dist/core/usage-limit.js.map +1 -0
- package/dist/core/usage-service.d.ts +33 -0
- package/dist/core/usage-service.d.ts.map +1 -0
- package/dist/core/usage-service.js +56 -0
- package/dist/core/usage-service.js.map +1 -0
- package/dist/core/user-models.d.ts +50 -0
- package/dist/core/user-models.d.ts.map +1 -0
- package/dist/core/user-models.js +192 -0
- package/dist/core/user-models.js.map +1 -0
- package/dist/gateway/adapters/discord.d.ts +251 -0
- package/dist/gateway/adapters/discord.d.ts.map +1 -0
- package/dist/gateway/adapters/discord.js +693 -0
- package/dist/gateway/adapters/discord.js.map +1 -0
- package/dist/gateway/adapters/telegram.d.ts +187 -0
- package/dist/gateway/adapters/telegram.d.ts.map +1 -0
- package/dist/gateway/adapters/telegram.js +581 -0
- package/dist/gateway/adapters/telegram.js.map +1 -0
- package/dist/gateway/agent-bridge.d.ts +143 -0
- package/dist/gateway/agent-bridge.d.ts.map +1 -0
- package/dist/gateway/agent-bridge.js +466 -0
- package/dist/gateway/agent-bridge.js.map +1 -0
- package/dist/gateway/approval.d.ts +34 -0
- package/dist/gateway/approval.d.ts.map +1 -0
- package/dist/gateway/approval.js +152 -0
- package/dist/gateway/approval.js.map +1 -0
- package/dist/gateway/authz.d.ts +21 -0
- package/dist/gateway/authz.d.ts.map +1 -0
- package/dist/gateway/authz.js +61 -0
- package/dist/gateway/authz.js.map +1 -0
- package/dist/gateway/buttons.d.ts +58 -0
- package/dist/gateway/buttons.d.ts.map +1 -0
- package/dist/gateway/buttons.js +269 -0
- package/dist/gateway/buttons.js.map +1 -0
- package/dist/gateway/command.d.ts +8 -0
- package/dist/gateway/command.d.ts.map +1 -0
- package/dist/gateway/command.js +16 -0
- package/dist/gateway/command.js.map +1 -0
- package/dist/gateway/commands.d.ts +43 -0
- package/dist/gateway/commands.d.ts.map +1 -0
- package/dist/gateway/commands.js +642 -0
- package/dist/gateway/commands.js.map +1 -0
- package/dist/gateway/config.d.ts +53 -0
- package/dist/gateway/config.d.ts.map +1 -0
- package/dist/gateway/config.js +136 -0
- package/dist/gateway/config.js.map +1 -0
- package/dist/gateway/cron.d.ts +69 -0
- package/dist/gateway/cron.d.ts.map +1 -0
- package/dist/gateway/cron.js +321 -0
- package/dist/gateway/cron.js.map +1 -0
- package/dist/gateway/index.d.ts +31 -0
- package/dist/gateway/index.d.ts.map +1 -0
- package/dist/gateway/index.js +233 -0
- package/dist/gateway/index.js.map +1 -0
- package/dist/gateway/pairing.d.ts +44 -0
- package/dist/gateway/pairing.d.ts.map +1 -0
- package/dist/gateway/pairing.js +171 -0
- package/dist/gateway/pairing.js.map +1 -0
- package/dist/gateway/router.d.ts +48 -0
- package/dist/gateway/router.d.ts.map +1 -0
- package/dist/gateway/router.js +215 -0
- package/dist/gateway/router.js.map +1 -0
- package/dist/gateway/session-keys.d.ts +18 -0
- package/dist/gateway/session-keys.d.ts.map +1 -0
- package/dist/gateway/session-keys.js +26 -0
- package/dist/gateway/session-keys.js.map +1 -0
- package/dist/gateway/store.d.ts +28 -0
- package/dist/gateway/store.d.ts.map +1 -0
- package/dist/gateway/store.js +93 -0
- package/dist/gateway/store.js.map +1 -0
- package/dist/gateway/stream.d.ts +55 -0
- package/dist/gateway/stream.d.ts.map +1 -0
- package/dist/gateway/stream.js +107 -0
- package/dist/gateway/stream.js.map +1 -0
- package/dist/gateway/text.d.ts +18 -0
- package/dist/gateway/text.d.ts.map +1 -0
- package/dist/gateway/text.js +136 -0
- package/dist/gateway/text.js.map +1 -0
- package/dist/gateway/types.d.ts +95 -0
- package/dist/gateway/types.d.ts.map +1 -0
- package/dist/gateway/types.js +9 -0
- package/dist/gateway/types.js.map +1 -0
- package/dist/index.d.ts +35 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +47 -0
- package/dist/index.js.map +1 -0
- package/dist/main.d.ts +12 -0
- package/dist/main.d.ts.map +1 -0
- package/dist/main.js +742 -0
- package/dist/main.js.map +1 -0
- package/dist/migrations.d.ts +46 -0
- package/dist/migrations.d.ts.map +1 -0
- package/dist/migrations.js +351 -0
- package/dist/migrations.js.map +1 -0
- package/dist/modes/index.d.ts +9 -0
- package/dist/modes/index.d.ts.map +1 -0
- package/dist/modes/index.js +8 -0
- package/dist/modes/index.js.map +1 -0
- package/dist/modes/interactive/assets/clankolas.png +0 -0
- package/dist/modes/interactive/components/armin.d.ts +34 -0
- package/dist/modes/interactive/components/armin.d.ts.map +1 -0
- package/dist/modes/interactive/components/armin.js +333 -0
- package/dist/modes/interactive/components/armin.js.map +1 -0
- package/dist/modes/interactive/components/assistant-message.d.ts +31 -0
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/assistant-message.js +246 -0
- package/dist/modes/interactive/components/assistant-message.js.map +1 -0
- package/dist/modes/interactive/components/bash-execution.d.ts +32 -0
- package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -0
- package/dist/modes/interactive/components/bash-execution.js +171 -0
- package/dist/modes/interactive/components/bash-execution.js.map +1 -0
- package/dist/modes/interactive/components/boot-ascii.d.ts +6 -0
- package/dist/modes/interactive/components/boot-ascii.d.ts.map +1 -0
- package/dist/modes/interactive/components/boot-ascii.js +6 -0
- package/dist/modes/interactive/components/boot-ascii.js.map +1 -0
- package/dist/modes/interactive/components/boot-screen.d.ts +22 -0
- package/dist/modes/interactive/components/boot-screen.d.ts.map +1 -0
- package/dist/modes/interactive/components/boot-screen.js +53 -0
- package/dist/modes/interactive/components/boot-screen.js.map +1 -0
- package/dist/modes/interactive/components/bordered-loader.d.ts +16 -0
- package/dist/modes/interactive/components/bordered-loader.d.ts.map +1 -0
- package/dist/modes/interactive/components/bordered-loader.js +54 -0
- package/dist/modes/interactive/components/bordered-loader.js.map +1 -0
- package/dist/modes/interactive/components/branch-summary-message.d.ts +16 -0
- package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/branch-summary-message.js +44 -0
- package/dist/modes/interactive/components/branch-summary-message.js.map +1 -0
- package/dist/modes/interactive/components/compaction-summary-message.d.ts +16 -0
- package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/compaction-summary-message.js +45 -0
- package/dist/modes/interactive/components/compaction-summary-message.js.map +1 -0
- package/dist/modes/interactive/components/config-selector.d.ts +102 -0
- package/dist/modes/interactive/components/config-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/config-selector.js +761 -0
- package/dist/modes/interactive/components/config-selector.js.map +1 -0
- package/dist/modes/interactive/components/context-view.d.ts +13 -0
- package/dist/modes/interactive/components/context-view.d.ts.map +1 -0
- package/dist/modes/interactive/components/context-view.js +42 -0
- package/dist/modes/interactive/components/context-view.js.map +1 -0
- package/dist/modes/interactive/components/countdown-timer.d.ts +14 -0
- package/dist/modes/interactive/components/countdown-timer.d.ts.map +1 -0
- package/dist/modes/interactive/components/countdown-timer.js +33 -0
- package/dist/modes/interactive/components/countdown-timer.js.map +1 -0
- package/dist/modes/interactive/components/custom-editor.d.ts +21 -0
- package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -0
- package/dist/modes/interactive/components/custom-editor.js +70 -0
- package/dist/modes/interactive/components/custom-editor.js.map +1 -0
- package/dist/modes/interactive/components/custom-entry.d.ts +19 -0
- package/dist/modes/interactive/components/custom-entry.d.ts.map +1 -0
- package/dist/modes/interactive/components/custom-entry.js +52 -0
- package/dist/modes/interactive/components/custom-entry.js.map +1 -0
- package/dist/modes/interactive/components/custom-message.d.ts +20 -0
- package/dist/modes/interactive/components/custom-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/custom-message.js +79 -0
- package/dist/modes/interactive/components/custom-message.js.map +1 -0
- package/dist/modes/interactive/components/daxnuts.d.ts +23 -0
- package/dist/modes/interactive/components/daxnuts.d.ts.map +1 -0
- package/dist/modes/interactive/components/daxnuts.js +140 -0
- package/dist/modes/interactive/components/daxnuts.js.map +1 -0
- package/dist/modes/interactive/components/diff.d.ts +12 -0
- package/dist/modes/interactive/components/diff.d.ts.map +1 -0
- package/dist/modes/interactive/components/diff.js +133 -0
- package/dist/modes/interactive/components/diff.js.map +1 -0
- package/dist/modes/interactive/components/dynamic-border.d.ts +15 -0
- package/dist/modes/interactive/components/dynamic-border.d.ts.map +1 -0
- package/dist/modes/interactive/components/dynamic-border.js +21 -0
- package/dist/modes/interactive/components/dynamic-border.js.map +1 -0
- package/dist/modes/interactive/components/earendil-announcement.d.ts +5 -0
- package/dist/modes/interactive/components/earendil-announcement.d.ts.map +1 -0
- package/dist/modes/interactive/components/earendil-announcement.js +40 -0
- package/dist/modes/interactive/components/earendil-announcement.js.map +1 -0
- package/dist/modes/interactive/components/exit-card.d.ts +22 -0
- package/dist/modes/interactive/components/exit-card.d.ts.map +1 -0
- package/dist/modes/interactive/components/exit-card.js +69 -0
- package/dist/modes/interactive/components/exit-card.js.map +1 -0
- package/dist/modes/interactive/components/extension-editor.d.ts +22 -0
- package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -0
- package/dist/modes/interactive/components/extension-editor.js +128 -0
- package/dist/modes/interactive/components/extension-editor.js.map +1 -0
- package/dist/modes/interactive/components/extension-input.d.ts +23 -0
- package/dist/modes/interactive/components/extension-input.d.ts.map +1 -0
- package/dist/modes/interactive/components/extension-input.js +61 -0
- package/dist/modes/interactive/components/extension-input.js.map +1 -0
- package/dist/modes/interactive/components/extension-selector.d.ts +30 -0
- package/dist/modes/interactive/components/extension-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/extension-selector.js +106 -0
- package/dist/modes/interactive/components/extension-selector.js.map +1 -0
- package/dist/modes/interactive/components/first-time-setup.d.ts +25 -0
- package/dist/modes/interactive/components/first-time-setup.d.ts.map +1 -0
- package/dist/modes/interactive/components/first-time-setup.js +99 -0
- package/dist/modes/interactive/components/first-time-setup.js.map +1 -0
- package/dist/modes/interactive/components/footer.d.ts +32 -0
- package/dist/modes/interactive/components/footer.d.ts.map +1 -0
- package/dist/modes/interactive/components/footer.js +221 -0
- package/dist/modes/interactive/components/footer.js.map +1 -0
- package/dist/modes/interactive/components/index.d.ts +34 -0
- package/dist/modes/interactive/components/index.d.ts.map +1 -0
- package/dist/modes/interactive/components/index.js +35 -0
- package/dist/modes/interactive/components/index.js.map +1 -0
- package/dist/modes/interactive/components/injected-prompt-message.d.ts +21 -0
- package/dist/modes/interactive/components/injected-prompt-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/injected-prompt-message.js +51 -0
- package/dist/modes/interactive/components/injected-prompt-message.js.map +1 -0
- package/dist/modes/interactive/components/keybinding-hints.d.ts +13 -0
- package/dist/modes/interactive/components/keybinding-hints.d.ts.map +1 -0
- package/dist/modes/interactive/components/keybinding-hints.js +36 -0
- package/dist/modes/interactive/components/keybinding-hints.js.map +1 -0
- package/dist/modes/interactive/components/login-dialog.d.ts +52 -0
- package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -0
- package/dist/modes/interactive/components/login-dialog.js +188 -0
- package/dist/modes/interactive/components/login-dialog.js.map +1 -0
- package/dist/modes/interactive/components/model-selector.d.ts +61 -0
- package/dist/modes/interactive/components/model-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/model-selector.js +320 -0
- package/dist/modes/interactive/components/model-selector.js.map +1 -0
- package/dist/modes/interactive/components/oauth-selector.d.ts +33 -0
- package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/oauth-selector.js +163 -0
- package/dist/modes/interactive/components/oauth-selector.js.map +1 -0
- package/dist/modes/interactive/components/processes-selector.d.ts +19 -0
- package/dist/modes/interactive/components/processes-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/processes-selector.js +170 -0
- package/dist/modes/interactive/components/processes-selector.js.map +1 -0
- package/dist/modes/interactive/components/scoped-models-selector.d.ts +42 -0
- package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/scoped-models-selector.js +293 -0
- package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -0
- package/dist/modes/interactive/components/session-selector-search.d.ts +23 -0
- package/dist/modes/interactive/components/session-selector-search.d.ts.map +1 -0
- package/dist/modes/interactive/components/session-selector-search.js +155 -0
- package/dist/modes/interactive/components/session-selector-search.js.map +1 -0
- package/dist/modes/interactive/components/session-selector.d.ts +95 -0
- package/dist/modes/interactive/components/session-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/session-selector.js +857 -0
- package/dist/modes/interactive/components/session-selector.js.map +1 -0
- package/dist/modes/interactive/components/settings-selector.d.ts +139 -0
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/settings-selector.js +1156 -0
- package/dist/modes/interactive/components/settings-selector.js.map +1 -0
- package/dist/modes/interactive/components/show-images-selector.d.ts +10 -0
- package/dist/modes/interactive/components/show-images-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/show-images-selector.js +39 -0
- package/dist/modes/interactive/components/show-images-selector.js.map +1 -0
- package/dist/modes/interactive/components/skill-invocation-message.d.ts +17 -0
- package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/skill-invocation-message.js +47 -0
- package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -0
- package/dist/modes/interactive/components/status-indicator.d.ts +28 -0
- package/dist/modes/interactive/components/status-indicator.d.ts.map +1 -0
- package/dist/modes/interactive/components/status-indicator.js +60 -0
- package/dist/modes/interactive/components/status-indicator.js.map +1 -0
- package/dist/modes/interactive/components/theme-selector.d.ts +11 -0
- package/dist/modes/interactive/components/theme-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/theme-selector.js +50 -0
- package/dist/modes/interactive/components/theme-selector.js.map +1 -0
- package/dist/modes/interactive/components/thinking-selector.d.ts +11 -0
- package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/thinking-selector.js +52 -0
- package/dist/modes/interactive/components/thinking-selector.js.map +1 -0
- package/dist/modes/interactive/components/thinking-summary.d.ts +36 -0
- package/dist/modes/interactive/components/thinking-summary.d.ts.map +1 -0
- package/dist/modes/interactive/components/thinking-summary.js +94 -0
- package/dist/modes/interactive/components/thinking-summary.js.map +1 -0
- package/dist/modes/interactive/components/thinking-tail.d.ts +21 -0
- package/dist/modes/interactive/components/thinking-tail.d.ts.map +1 -0
- package/dist/modes/interactive/components/thinking-tail.js +29 -0
- package/dist/modes/interactive/components/thinking-tail.js.map +1 -0
- package/dist/modes/interactive/components/tool-execution.d.ts +67 -0
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -0
- package/dist/modes/interactive/components/tool-execution.js +340 -0
- package/dist/modes/interactive/components/tool-execution.js.map +1 -0
- package/dist/modes/interactive/components/tree-selector.d.ts +94 -0
- package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/tree-selector.js +1245 -0
- package/dist/modes/interactive/components/tree-selector.js.map +1 -0
- package/dist/modes/interactive/components/trust-selector.d.ts +23 -0
- package/dist/modes/interactive/components/trust-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/trust-selector.js +91 -0
- package/dist/modes/interactive/components/trust-selector.js.map +1 -0
- package/dist/modes/interactive/components/usage-view.d.ts +63 -0
- package/dist/modes/interactive/components/usage-view.d.ts.map +1 -0
- package/dist/modes/interactive/components/usage-view.js +189 -0
- package/dist/modes/interactive/components/usage-view.js.map +1 -0
- package/dist/modes/interactive/components/user-message-selector.d.ts +30 -0
- package/dist/modes/interactive/components/user-message-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/user-message-selector.js +114 -0
- package/dist/modes/interactive/components/user-message-selector.js.map +1 -0
- package/dist/modes/interactive/components/user-message.d.ts +16 -0
- package/dist/modes/interactive/components/user-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/user-message.js +62 -0
- package/dist/modes/interactive/components/user-message.js.map +1 -0
- package/dist/modes/interactive/components/visual-truncate.d.ts +24 -0
- package/dist/modes/interactive/components/visual-truncate.d.ts.map +1 -0
- package/dist/modes/interactive/components/visual-truncate.js +33 -0
- package/dist/modes/interactive/components/visual-truncate.js.map +1 -0
- package/dist/modes/interactive/interactive-mode.d.ts +448 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-mode.js +6487 -0
- package/dist/modes/interactive/interactive-mode.js.map +1 -0
- package/dist/modes/interactive/model-search.d.ts +12 -0
- package/dist/modes/interactive/model-search.d.ts.map +1 -0
- package/dist/modes/interactive/model-search.js +15 -0
- package/dist/modes/interactive/model-search.js.map +1 -0
- package/dist/modes/interactive/smooth-streaming.d.ts +10 -0
- package/dist/modes/interactive/smooth-streaming.d.ts.map +1 -0
- package/dist/modes/interactive/smooth-streaming.js +95 -0
- package/dist/modes/interactive/smooth-streaming.js.map +1 -0
- package/dist/modes/interactive/theme/moon.json +83 -0
- package/dist/modes/interactive/theme/theme-controller.d.ts +29 -0
- package/dist/modes/interactive/theme/theme-controller.d.ts.map +1 -0
- package/dist/modes/interactive/theme/theme-controller.js +97 -0
- package/dist/modes/interactive/theme/theme-controller.js.map +1 -0
- package/dist/modes/interactive/theme/theme-schema.json +363 -0
- package/dist/modes/interactive/theme/theme.d.ts +128 -0
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -0
- package/dist/modes/interactive/theme/theme.js +1092 -0
- package/dist/modes/interactive/theme/theme.js.map +1 -0
- package/dist/modes/print-mode.d.ts +28 -0
- package/dist/modes/print-mode.d.ts.map +1 -0
- package/dist/modes/print-mode.js +132 -0
- package/dist/modes/print-mode.js.map +1 -0
- package/dist/modes/rpc/jsonl.d.ts +17 -0
- package/dist/modes/rpc/jsonl.d.ts.map +1 -0
- package/dist/modes/rpc/jsonl.js +49 -0
- package/dist/modes/rpc/jsonl.js.map +1 -0
- package/dist/modes/rpc/rpc-client.d.ts +242 -0
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-client.js +481 -0
- package/dist/modes/rpc/rpc-client.js.map +1 -0
- package/dist/modes/rpc/rpc-mode.d.ts +20 -0
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-mode.js +635 -0
- package/dist/modes/rpc/rpc-mode.js.map +1 -0
- package/dist/modes/rpc/rpc-types.d.ts +446 -0
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-types.js +8 -0
- package/dist/modes/rpc/rpc-types.js.map +1 -0
- package/dist/package-manager-cli.d.ts +8 -0
- package/dist/package-manager-cli.d.ts.map +1 -0
- package/dist/package-manager-cli.js +378 -0
- package/dist/package-manager-cli.js.map +1 -0
- package/dist/rpc-entry.d.ts +3 -0
- package/dist/rpc-entry.d.ts.map +1 -0
- package/dist/rpc-entry.js +10 -0
- package/dist/rpc-entry.js.map +1 -0
- package/dist/utils/ansi.d.ts +2 -0
- package/dist/utils/ansi.d.ts.map +1 -0
- package/dist/utils/ansi.js +52 -0
- package/dist/utils/ansi.js.map +1 -0
- package/dist/utils/child-process.d.ts +18 -0
- package/dist/utils/child-process.d.ts.map +1 -0
- package/dist/utils/child-process.js +106 -0
- package/dist/utils/child-process.js.map +1 -0
- package/dist/utils/clipboard-image.d.ts +11 -0
- package/dist/utils/clipboard-image.d.ts.map +1 -0
- package/dist/utils/clipboard-image.js +300 -0
- package/dist/utils/clipboard-image.js.map +1 -0
- package/dist/utils/clipboard-native.d.ts +11 -0
- package/dist/utils/clipboard-native.d.ts.map +1 -0
- package/dist/utils/clipboard-native.js +20 -0
- package/dist/utils/clipboard-native.js.map +1 -0
- package/dist/utils/clipboard.d.ts +4 -0
- package/dist/utils/clipboard.d.ts.map +1 -0
- package/dist/utils/clipboard.js +130 -0
- package/dist/utils/clipboard.js.map +1 -0
- package/dist/utils/deprecation.d.ts +4 -0
- package/dist/utils/deprecation.d.ts.map +1 -0
- package/dist/utils/deprecation.js +13 -0
- package/dist/utils/deprecation.js.map +1 -0
- package/dist/utils/exif-orientation.d.ts +5 -0
- package/dist/utils/exif-orientation.d.ts.map +1 -0
- package/dist/utils/exif-orientation.js +158 -0
- package/dist/utils/exif-orientation.js.map +1 -0
- package/dist/utils/frontmatter.d.ts +8 -0
- package/dist/utils/frontmatter.d.ts.map +1 -0
- package/dist/utils/frontmatter.js +26 -0
- package/dist/utils/frontmatter.js.map +1 -0
- package/dist/utils/fs-watch.d.ts +5 -0
- package/dist/utils/fs-watch.d.ts.map +1 -0
- package/dist/utils/fs-watch.js +25 -0
- package/dist/utils/fs-watch.js.map +1 -0
- package/dist/utils/git.d.ts +26 -0
- package/dist/utils/git.d.ts.map +1 -0
- package/dist/utils/git.js +195 -0
- package/dist/utils/git.js.map +1 -0
- package/dist/utils/html.d.ts +7 -0
- package/dist/utils/html.d.ts.map +1 -0
- package/dist/utils/html.js +40 -0
- package/dist/utils/html.js.map +1 -0
- package/dist/utils/image-convert.d.ts +10 -0
- package/dist/utils/image-convert.d.ts.map +1 -0
- package/dist/utils/image-convert.js +45 -0
- package/dist/utils/image-convert.js.map +1 -0
- package/dist/utils/image-process.d.ts +18 -0
- package/dist/utils/image-process.d.ts.map +1 -0
- package/dist/utils/image-process.js +83 -0
- package/dist/utils/image-process.js.map +1 -0
- package/dist/utils/image-resize-core.d.ts +30 -0
- package/dist/utils/image-resize-core.d.ts.map +1 -0
- package/dist/utils/image-resize-core.js +124 -0
- package/dist/utils/image-resize-core.js.map +1 -0
- package/dist/utils/image-resize-worker.d.ts +2 -0
- package/dist/utils/image-resize-worker.d.ts.map +1 -0
- package/dist/utils/image-resize-worker.js +31 -0
- package/dist/utils/image-resize-worker.js.map +1 -0
- package/dist/utils/image-resize.d.ts +16 -0
- package/dist/utils/image-resize.d.ts.map +1 -0
- package/dist/utils/image-resize.js +97 -0
- package/dist/utils/image-resize.js.map +1 -0
- package/dist/utils/json.d.ts +3 -0
- package/dist/utils/json.d.ts.map +1 -0
- package/dist/utils/json.js +7 -0
- package/dist/utils/json.js.map +1 -0
- package/dist/utils/mime.d.ts +3 -0
- package/dist/utils/mime.d.ts.map +1 -0
- package/dist/utils/mime.js +110 -0
- package/dist/utils/mime.js.map +1 -0
- package/dist/utils/open-browser.d.ts +9 -0
- package/dist/utils/open-browser.d.ts.map +1 -0
- package/dist/utils/open-browser.js +22 -0
- package/dist/utils/open-browser.js.map +1 -0
- package/dist/utils/paths.d.ts +31 -0
- package/dist/utils/paths.d.ts.map +1 -0
- package/dist/utils/paths.js +92 -0
- package/dist/utils/paths.js.map +1 -0
- package/dist/utils/photon.d.ts +21 -0
- package/dist/utils/photon.d.ts.map +1 -0
- package/dist/utils/photon.js +121 -0
- package/dist/utils/photon.js.map +1 -0
- package/dist/utils/pi-user-agent.d.ts +2 -0
- package/dist/utils/pi-user-agent.d.ts.map +1 -0
- package/dist/utils/pi-user-agent.js +5 -0
- package/dist/utils/pi-user-agent.js.map +1 -0
- package/dist/utils/shell.d.ts +31 -0
- package/dist/utils/shell.d.ts.map +1 -0
- package/dist/utils/shell.js +202 -0
- package/dist/utils/shell.js.map +1 -0
- package/dist/utils/sleep.d.ts +5 -0
- package/dist/utils/sleep.d.ts.map +1 -0
- package/dist/utils/sleep.js +17 -0
- package/dist/utils/sleep.js.map +1 -0
- package/dist/utils/syntax-highlight.d.ts +12 -0
- package/dist/utils/syntax-highlight.d.ts.map +1 -0
- package/dist/utils/syntax-highlight.js +118 -0
- package/dist/utils/syntax-highlight.js.map +1 -0
- package/dist/utils/tools-manager.d.ts +3 -0
- package/dist/utils/tools-manager.d.ts.map +1 -0
- package/dist/utils/tools-manager.js +328 -0
- package/dist/utils/tools-manager.js.map +1 -0
- package/docs/compaction.md +396 -0
- package/docs/containerization.md +111 -0
- package/docs/custom-provider.md +735 -0
- package/docs/development.md +71 -0
- package/docs/docs.json +156 -0
- package/docs/extensions.md +2911 -0
- package/docs/images/doom-extension.png +0 -0
- package/docs/images/exy.png +0 -0
- package/docs/images/interactive-mode.png +0 -0
- package/docs/images/tree-view.png +0 -0
- package/docs/index.md +82 -0
- package/docs/json.md +82 -0
- package/docs/keybindings.md +201 -0
- package/docs/models.md +540 -0
- package/docs/packages.md +228 -0
- package/docs/prompt-templates.md +95 -0
- package/docs/providers.md +294 -0
- package/docs/quickstart.md +165 -0
- package/docs/rpc.md +1480 -0
- package/docs/sdk.md +1183 -0
- package/docs/security.md +59 -0
- package/docs/session-format.md +422 -0
- package/docs/sessions.md +145 -0
- package/docs/settings.md +302 -0
- package/docs/shell-aliases.md +13 -0
- package/docs/skills.md +231 -0
- package/docs/terminal-setup.md +142 -0
- package/docs/termux.md +127 -0
- package/docs/themes.md +297 -0
- package/docs/tmux.md +63 -0
- package/docs/tui.md +927 -0
- package/docs/usage.md +312 -0
- package/docs/windows.md +17 -0
- package/examples/README.md +25 -0
- package/examples/extensions/README.md +213 -0
- package/examples/extensions/auto-commit-on-exit.ts +49 -0
- package/examples/extensions/bash-spawn-hook.ts +30 -0
- package/examples/extensions/bookmark.ts +50 -0
- package/examples/extensions/border-status-editor.ts +150 -0
- package/examples/extensions/built-in-tool-renderer.ts +249 -0
- package/examples/extensions/claude-rules.ts +86 -0
- package/examples/extensions/commands.ts +72 -0
- package/examples/extensions/confirm-destructive.ts +59 -0
- package/examples/extensions/custom-compaction.ts +128 -0
- package/examples/extensions/custom-footer.ts +64 -0
- package/examples/extensions/custom-header.ts +73 -0
- package/examples/extensions/custom-provider-anthropic/index.ts +604 -0
- package/examples/extensions/custom-provider-anthropic/package-lock.json +24 -0
- package/examples/extensions/custom-provider-anthropic/package.json +19 -0
- package/examples/extensions/custom-provider-gitlab-duo/index.ts +404 -0
- package/examples/extensions/custom-provider-gitlab-duo/package.json +16 -0
- package/examples/extensions/custom-provider-gitlab-duo/test.ts +82 -0
- package/examples/extensions/dirty-repo-guard.ts +56 -0
- package/examples/extensions/doom-overlay/README.md +46 -0
- package/examples/extensions/doom-overlay/doom/build/doom.js +21 -0
- package/examples/extensions/doom-overlay/doom/build/doom.wasm +0 -0
- package/examples/extensions/doom-overlay/doom/build.sh +152 -0
- package/examples/extensions/doom-overlay/doom/doomgeneric_pi.c +72 -0
- package/examples/extensions/doom-overlay/doom-component.ts +132 -0
- package/examples/extensions/doom-overlay/doom-engine.ts +173 -0
- package/examples/extensions/doom-overlay/doom-keys.ts +104 -0
- package/examples/extensions/doom-overlay/index.ts +74 -0
- package/examples/extensions/doom-overlay/wad-finder.ts +51 -0
- package/examples/extensions/dynamic-resources/SKILL.md +8 -0
- package/examples/extensions/dynamic-resources/dynamic.json +79 -0
- package/examples/extensions/dynamic-resources/dynamic.md +5 -0
- package/examples/extensions/dynamic-resources/index.ts +15 -0
- package/examples/extensions/dynamic-tools.ts +74 -0
- package/examples/extensions/entry-renderer.ts +41 -0
- package/examples/extensions/event-bus.ts +43 -0
- package/examples/extensions/file-trigger.ts +41 -0
- package/examples/extensions/git-checkpoint.ts +53 -0
- package/examples/extensions/git-merge-and-resolve.ts +115 -0
- package/examples/extensions/github-issue-autocomplete.ts +185 -0
- package/examples/extensions/gondolin/index.ts +531 -0
- package/examples/extensions/gondolin/package-lock.json +185 -0
- package/examples/extensions/gondolin/package.json +19 -0
- package/examples/extensions/handoff.ts +191 -0
- package/examples/extensions/hello.ts +26 -0
- package/examples/extensions/hidden-thinking-label.ts +53 -0
- package/examples/extensions/inline-bash.ts +94 -0
- package/examples/extensions/input-transform-streaming.ts +39 -0
- package/examples/extensions/input-transform.ts +43 -0
- package/examples/extensions/interactive-shell.ts +196 -0
- package/examples/extensions/kimi-deferred-tools.ts +61 -0
- package/examples/extensions/mac-system-theme.ts +47 -0
- package/examples/extensions/message-renderer.ts +59 -0
- package/examples/extensions/minimal-mode.ts +426 -0
- package/examples/extensions/modal-editor.ts +85 -0
- package/examples/extensions/model-status.ts +31 -0
- package/examples/extensions/notify.ts +55 -0
- package/examples/extensions/overlay-qa-tests.ts +1450 -0
- package/examples/extensions/overlay-test.ts +153 -0
- package/examples/extensions/permission-gate.ts +34 -0
- package/examples/extensions/pirate.ts +47 -0
- package/examples/extensions/plan-mode/README.md +66 -0
- package/examples/extensions/plan-mode/index.ts +390 -0
- package/examples/extensions/plan-mode/utils.ts +168 -0
- package/examples/extensions/preset.ts +436 -0
- package/examples/extensions/project-trust.ts +64 -0
- package/examples/extensions/prompt-customizer.ts +97 -0
- package/examples/extensions/protected-paths.ts +30 -0
- package/examples/extensions/provider-payload.ts +18 -0
- package/examples/extensions/qna.ts +122 -0
- package/examples/extensions/question.ts +286 -0
- package/examples/extensions/questionnaire.ts +448 -0
- package/examples/extensions/rainbow-editor.ts +88 -0
- package/examples/extensions/reload-runtime.ts +37 -0
- package/examples/extensions/rpc-demo.ts +118 -0
- package/examples/extensions/sandbox/index.ts +321 -0
- package/examples/extensions/sandbox/package-lock.json +92 -0
- package/examples/extensions/sandbox/package.json +19 -0
- package/examples/extensions/send-user-message.ts +97 -0
- package/examples/extensions/session-name.ts +27 -0
- package/examples/extensions/shutdown-command.ts +63 -0
- package/examples/extensions/snake.ts +343 -0
- package/examples/extensions/space-invaders.ts +560 -0
- package/examples/extensions/ssh.ts +220 -0
- package/examples/extensions/status-line.ts +32 -0
- package/examples/extensions/structured-output.ts +65 -0
- package/examples/extensions/subagent/README.md +175 -0
- package/examples/extensions/subagent/agents/planner.md +37 -0
- package/examples/extensions/subagent/agents/reviewer.md +35 -0
- package/examples/extensions/subagent/agents/scout.md +50 -0
- package/examples/extensions/subagent/agents/worker.md +24 -0
- package/examples/extensions/subagent/agents.ts +126 -0
- package/examples/extensions/subagent/index.ts +1015 -0
- package/examples/extensions/subagent/prompts/implement-and-review.md +10 -0
- package/examples/extensions/subagent/prompts/implement.md +10 -0
- package/examples/extensions/subagent/prompts/scout-and-plan.md +9 -0
- package/examples/extensions/summarize.ts +207 -0
- package/examples/extensions/system-prompt-header.ts +17 -0
- package/examples/extensions/tic-tac-toe.ts +1008 -0
- package/examples/extensions/timed-confirm.ts +70 -0
- package/examples/extensions/titlebar-spinner.ts +58 -0
- package/examples/extensions/todo.ts +297 -0
- package/examples/extensions/tool-override.ts +144 -0
- package/examples/extensions/tools.ts +146 -0
- package/examples/extensions/trigger-compact.ts +50 -0
- package/examples/extensions/truncated-tool.ts +195 -0
- package/examples/extensions/widget-placement.ts +9 -0
- package/examples/extensions/with-deps/index.ts +32 -0
- package/examples/extensions/with-deps/package-lock.json +31 -0
- package/examples/extensions/with-deps/package.json +22 -0
- package/examples/extensions/working-indicator.ts +123 -0
- package/examples/extensions/working-message-test.ts +25 -0
- package/examples/rpc-extension-ui.ts +632 -0
- package/examples/sdk/01-minimal.ts +26 -0
- package/examples/sdk/02-custom-model.ts +50 -0
- package/examples/sdk/03-custom-prompt.ts +75 -0
- package/examples/sdk/04-skills.ts +55 -0
- package/examples/sdk/05-tools.ts +48 -0
- package/examples/sdk/06-extensions.ts +99 -0
- package/examples/sdk/07-context-files.ts +47 -0
- package/examples/sdk/08-prompt-templates.ts +51 -0
- package/examples/sdk/09-api-keys-and-oauth.ts +34 -0
- package/examples/sdk/10-settings.ts +53 -0
- package/examples/sdk/11-sessions.ts +52 -0
- package/examples/sdk/12-full-control.ts +72 -0
- package/examples/sdk/13-session-runtime.ts +67 -0
- package/examples/sdk/README.md +140 -0
- package/package.json +116 -0
|
@@ -0,0 +1,3513 @@
|
|
|
1
|
+
var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
|
|
2
|
+
if (typeof path === "string" && /^\.\.?\//.test(path)) {
|
|
3
|
+
return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
|
|
4
|
+
return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
|
|
5
|
+
});
|
|
6
|
+
}
|
|
7
|
+
return path;
|
|
8
|
+
};
|
|
9
|
+
// @ts-nocheck
|
|
10
|
+
import { spawn, spawnSync } from "node:child_process";
|
|
11
|
+
import * as fs from "node:fs";
|
|
12
|
+
import * as path from "node:path";
|
|
13
|
+
import { pathToFileURL } from "node:url";
|
|
14
|
+
import { writeAtomicJson } from "../../shared/atomic-json.js";
|
|
15
|
+
import { createChildTranscriptWriter } from "../../shared/child-transcript.js";
|
|
16
|
+
import { closeSteerInbox, consumeInterruptRequest, consumeSteerRequests, deliverInterruptRequest, deliverStopRequest, deliverTimeoutRequest, enqueueStepSteer, steerAcksDir, steerCapabilityPath, stepSteerInboxDir, watchAsyncControlInbox } from "./control-channel.js";
|
|
17
|
+
import { appendJsonl as appendRawJsonl, getArtifactPaths } from "../../shared/artifacts.js";
|
|
18
|
+
import { PI_CODING_AGENT_PACKAGE, getPiSpawnCommand, resolveInstalledPiPackageRoot } from "../shared/pi-spawn.js";
|
|
19
|
+
import { captureSingleOutputSnapshot, extractChildWrittenOutput, finalizeSingleOutput, formatSavedOutputReference, injectOutputPathSystemPrompt, injectSingleOutputInstruction, resolveSingleOutput } from "../shared/single-output.js";
|
|
20
|
+
import { DEFAULT_MAX_OUTPUT, SUBAGENT_LIFECYCLE_ARTIFACT_VERSION, truncateOutput, getSubagentDepthEnv, } from "../../shared/types.js";
|
|
21
|
+
import { DEFAULT_CONTROL_CONFIG, buildControlEvent, deriveActivityState, claimControlNotification, formatControlIntercomMessage, formatControlNoticeMessage, } from "../shared/subagent-control.js";
|
|
22
|
+
import { isDynamicRunnerGroup, isParallelGroup, flattenSteps, mapConcurrent, aggregateParallelOutputs, MAX_PARALLEL_CONCURRENCY, DEFAULT_GLOBAL_CONCURRENCY_LIMIT, Semaphore, } from "../shared/parallel-utils.js";
|
|
23
|
+
import { applyThinkingSuffix, buildPiArgs, cleanupTempDir } from "../shared/pi-args.js";
|
|
24
|
+
import { outputEntryFromAsyncResult, resolveOutputReferences } from "../shared/chain-outputs.js";
|
|
25
|
+
import { createStructuredOutputRuntime, readStructuredOutput } from "../shared/structured-output.js";
|
|
26
|
+
import { readChildToolDiagnosticError } from "../shared/tool-availability.js";
|
|
27
|
+
import { collectDynamicResults, DynamicFanoutError, materializeDynamicParallelStep, validateDynamicCollection } from "../shared/dynamic-fanout.js";
|
|
28
|
+
import { nestedSummaryFromAsyncStatus, projectNestedEvents, resolveNestedAsyncDir, writeNestedEvent } from "../shared/nested-events.js";
|
|
29
|
+
import { formatModelAttemptNote, isRetryableModelFailure } from "../shared/model-fallback.js";
|
|
30
|
+
import { createSteeringStatus, recordSteeringRequest, steeringStatus, terminalSteeringNoticeState, updateSteeringTarget } from "./steering.js";
|
|
31
|
+
import { attachPostExitStdioGuard, trySignalChild } from "../../shared/post-exit-stdio-guard.js";
|
|
32
|
+
import { detectSubagentError, extractTextFromContent, extractToolArgsPreview, getFinalOutput, readStatus } from "../../shared/utils.js";
|
|
33
|
+
import { evaluateCompletionMutationGuard } from "../shared/completion-guard.js";
|
|
34
|
+
import { createMutatingFailureState, didMutatingToolFail, isMutatingTool, nextLongRunningTrigger, recordMutatingFailure, resetMutatingFailureState, resolveCurrentPath, shouldEscalateMutatingFailures, summarizeRecentMutatingFailures, } from "../shared/long-running-guard.js";
|
|
35
|
+
import { parseSessionTokens } from "../../shared/session-tokens.js";
|
|
36
|
+
import { cleanupWorktrees, createWorktrees, diffWorktrees, findWorktreeTaskCwdConflict, formatWorktreeDiffSummary, formatWorktreeTaskCwdConflict, } from "../shared/worktree.js";
|
|
37
|
+
import { resolveEffectiveThinking } from "../../shared/model-info.js";
|
|
38
|
+
import { writeInitialProgressFile } from "../../shared/settings.js";
|
|
39
|
+
import { resolveSubagentIntercomTarget } from "../../intercom/intercom-bridge.js";
|
|
40
|
+
import { acceptanceFailureMessage, aggregateAcceptanceReport, buildSkippedAcceptanceLedger, evaluateAcceptance, formatAcceptancePrompt, resolveEffectiveAcceptance, stripAcceptanceReport } from "../shared/acceptance.js";
|
|
41
|
+
import { waitForImportedAsyncRoot } from "./chain-root-attachment.js";
|
|
42
|
+
import { appendRunnerStepsToStatus, consumeChainAppendRequests, countPendingChainAppendRequests } from "./chain-append.js";
|
|
43
|
+
import { appendTurnBudgetSystemPrompt, formatTurnBudgetOutput, initialTurnBudgetState, shouldAbortForTurnBudget, turnBudgetExceededMessage, turnBudgetSoftNote, turnBudgetState } from "../shared/turn-budget.js";
|
|
44
|
+
import { initialToolBudgetState, toolBudgetState } from "../shared/tool-budget.js";
|
|
45
|
+
import { resolveWatchdogConfig } from "../../watchdog/settings.js";
|
|
46
|
+
import { createBoundedByteTail, createBoundedLineReader, formatProtocolOutputLimit, MAX_CHILD_STDERR_BYTES, projectChildLifecycle } from "../shared/child-protocol.js";
|
|
47
|
+
import { acquireSessionLease } from "../shared/session-lease.js";
|
|
48
|
+
import { CHILD_WATCHDOG_CONFIG_ENV, acceptChildWatchdogEvent, childWatchdogIsActive, decodeChildWatchdogConfig, isChildWatchdogStatusEvent, resolveChildWatchdogConfig, } from "../../watchdog/child-status.js";
|
|
49
|
+
const ASYNC_INTERRUPT_SIGNAL = process.platform === "win32" ? "SIGBREAK" : "SIGUSR2";
|
|
50
|
+
const DEFAULT_MAX_ASYNC_EVENTS_BYTES = 50 * 1024 * 1024;
|
|
51
|
+
const ASYNC_EVENTS_MAX_BYTES_ENV = "PI_SUBAGENT_ASYNC_EVENTS_MAX_BYTES";
|
|
52
|
+
const TRUNCATED_EVENT_TYPE = "subagent.events.truncated";
|
|
53
|
+
const TRUNCATION_MARKER_RESERVE_BYTES = 512;
|
|
54
|
+
const asyncEventLogStates = new Map();
|
|
55
|
+
function maxAsyncEventsBytes() {
|
|
56
|
+
const raw = process.env[ASYNC_EVENTS_MAX_BYTES_ENV];
|
|
57
|
+
if (!raw)
|
|
58
|
+
return DEFAULT_MAX_ASYNC_EVENTS_BYTES;
|
|
59
|
+
const parsed = Number(raw);
|
|
60
|
+
if (!Number.isFinite(parsed) || parsed < 0)
|
|
61
|
+
return DEFAULT_MAX_ASYNC_EVENTS_BYTES;
|
|
62
|
+
return Math.floor(parsed);
|
|
63
|
+
}
|
|
64
|
+
function eventLogState(filePath) {
|
|
65
|
+
let state = asyncEventLogStates.get(filePath);
|
|
66
|
+
if (state)
|
|
67
|
+
return state;
|
|
68
|
+
let bytes = 0;
|
|
69
|
+
try {
|
|
70
|
+
bytes = fs.statSync(filePath).size;
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
if (error.code !== "ENOENT") {
|
|
74
|
+
// Diagnostic event accounting is best-effort; writes below are also safe.
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
state = { bytes, diagnosticsTruncated: false };
|
|
78
|
+
asyncEventLogStates.set(filePath, state);
|
|
79
|
+
return state;
|
|
80
|
+
}
|
|
81
|
+
function appendJsonl(filePath, line) {
|
|
82
|
+
try {
|
|
83
|
+
appendRawJsonl(filePath, line);
|
|
84
|
+
const state = asyncEventLogStates.get(filePath);
|
|
85
|
+
if (state)
|
|
86
|
+
state.bytes += Buffer.byteLength(`${line}\n`, "utf-8");
|
|
87
|
+
}
|
|
88
|
+
catch {
|
|
89
|
+
// Async event logging is diagnostic and must not fail the run.
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
function appendDiagnosticJsonl(filePath, line, droppedEventType) {
|
|
93
|
+
if (!line.trim())
|
|
94
|
+
return;
|
|
95
|
+
const state = eventLogState(filePath);
|
|
96
|
+
if (state.diagnosticsTruncated)
|
|
97
|
+
return;
|
|
98
|
+
const maxBytes = maxAsyncEventsBytes();
|
|
99
|
+
const chunkBytes = Buffer.byteLength(`${line}\n`, "utf-8");
|
|
100
|
+
const diagnosticBudget = Math.max(0, maxBytes - TRUNCATION_MARKER_RESERVE_BYTES);
|
|
101
|
+
if (state.bytes + chunkBytes <= diagnosticBudget) {
|
|
102
|
+
appendJsonl(filePath, line);
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
const marker = JSON.stringify({
|
|
106
|
+
type: TRUNCATED_EVENT_TYPE,
|
|
107
|
+
ts: Date.now(),
|
|
108
|
+
maxBytes,
|
|
109
|
+
droppedEventType,
|
|
110
|
+
});
|
|
111
|
+
if (state.bytes + Buffer.byteLength(`${marker}\n`, "utf-8") <= maxBytes) {
|
|
112
|
+
appendJsonl(filePath, marker);
|
|
113
|
+
}
|
|
114
|
+
state.diagnosticsTruncated = true;
|
|
115
|
+
}
|
|
116
|
+
function shouldPersistChildEvent(event) {
|
|
117
|
+
return event.type !== "message_update";
|
|
118
|
+
}
|
|
119
|
+
function findLatestSessionFile(sessionDir) {
|
|
120
|
+
try {
|
|
121
|
+
const files = fs
|
|
122
|
+
.readdirSync(sessionDir)
|
|
123
|
+
.filter((f) => f.endsWith(".jsonl"))
|
|
124
|
+
.map((f) => path.join(sessionDir, f));
|
|
125
|
+
if (files.length === 0)
|
|
126
|
+
return null;
|
|
127
|
+
files.sort((a, b) => fs.statSync(b).mtimeMs - fs.statSync(a).mtimeMs);
|
|
128
|
+
return files[0] ?? null;
|
|
129
|
+
}
|
|
130
|
+
catch {
|
|
131
|
+
// Session lookup is optional metadata.
|
|
132
|
+
return null;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
function emptyUsage() {
|
|
136
|
+
return { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, cost: 0, turns: 0 };
|
|
137
|
+
}
|
|
138
|
+
function tokenUsageFromAttempts(attempts) {
|
|
139
|
+
if (!attempts || attempts.length === 0)
|
|
140
|
+
return null;
|
|
141
|
+
let input = 0;
|
|
142
|
+
let output = 0;
|
|
143
|
+
for (const attempt of attempts) {
|
|
144
|
+
input += attempt.usage?.input ?? 0;
|
|
145
|
+
output += attempt.usage?.output ?? 0;
|
|
146
|
+
}
|
|
147
|
+
const total = input + output;
|
|
148
|
+
return total > 0 ? { input, output, total } : null;
|
|
149
|
+
}
|
|
150
|
+
function costSummaryFromAttempts(attempts) {
|
|
151
|
+
if (!attempts || attempts.length === 0)
|
|
152
|
+
return undefined;
|
|
153
|
+
let inputTokens = 0;
|
|
154
|
+
let outputTokens = 0;
|
|
155
|
+
let costUsd = 0;
|
|
156
|
+
for (const attempt of attempts) {
|
|
157
|
+
inputTokens += attempt.usage?.input ?? 0;
|
|
158
|
+
outputTokens += attempt.usage?.output ?? 0;
|
|
159
|
+
costUsd += attempt.usage?.cost ?? 0;
|
|
160
|
+
}
|
|
161
|
+
return inputTokens > 0 || outputTokens > 0 || costUsd > 0
|
|
162
|
+
? { inputTokens, outputTokens, costUsd }
|
|
163
|
+
: undefined;
|
|
164
|
+
}
|
|
165
|
+
function appendRecentStepOutput(step, lines) {
|
|
166
|
+
const nonEmpty = lines.filter((line) => line.trim());
|
|
167
|
+
if (nonEmpty.length === 0)
|
|
168
|
+
return;
|
|
169
|
+
step.recentOutput ??= [];
|
|
170
|
+
step.recentOutput.push(...nonEmpty);
|
|
171
|
+
if (step.recentOutput.length > 50) {
|
|
172
|
+
step.recentOutput.splice(0, step.recentOutput.length - 50);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
function isTerminalAssistantStop(message) {
|
|
176
|
+
const stopReason = message.stopReason;
|
|
177
|
+
const hasToolCall = Array.isArray(message.content)
|
|
178
|
+
&& message.content.some((part) => part.type === "toolCall");
|
|
179
|
+
return stopReason === "stop" && !hasToolCall;
|
|
180
|
+
}
|
|
181
|
+
function resetStepLiveDetail(step) {
|
|
182
|
+
step.currentTool = undefined;
|
|
183
|
+
step.currentToolArgs = undefined;
|
|
184
|
+
step.currentToolStartedAt = undefined;
|
|
185
|
+
step.currentPath = undefined;
|
|
186
|
+
step.recentTools = [];
|
|
187
|
+
step.recentOutput = [];
|
|
188
|
+
}
|
|
189
|
+
function runPiStreaming(args, cwd, outputFile, env, piPackageRoot, piArgv1, maxSubagentDepth, childEventContext, registerInterrupt, onChildEvent, transcriptWriter, registerTimeout, timeoutMessage, registerStop, stopMessage, registerTurnBudgetAbort, onWriterProcess) {
|
|
190
|
+
return new Promise((resolve) => {
|
|
191
|
+
onWriterProcess?.({ state: "spawning" });
|
|
192
|
+
const outputStream = fs.createWriteStream(outputFile, { flags: "w" });
|
|
193
|
+
const spawnEnv = { ...process.env, ...(env ?? {}), ...getSubagentDepthEnv(maxSubagentDepth) };
|
|
194
|
+
const spawnSpec = getPiSpawnCommand(args, {
|
|
195
|
+
...(piPackageRoot ? { piPackageRoot } : {}),
|
|
196
|
+
...(piArgv1 ? { argv1: piArgv1 } : {}),
|
|
197
|
+
});
|
|
198
|
+
const child = spawn(spawnSpec.command, spawnSpec.args, {
|
|
199
|
+
cwd,
|
|
200
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
201
|
+
env: spawnEnv,
|
|
202
|
+
windowsHide: true,
|
|
203
|
+
});
|
|
204
|
+
const stderrTail = createBoundedByteTail();
|
|
205
|
+
const rawStdoutTail = createBoundedByteTail();
|
|
206
|
+
const messages = [];
|
|
207
|
+
const usage = emptyUsage();
|
|
208
|
+
let model;
|
|
209
|
+
let writerRegistrationError;
|
|
210
|
+
if (typeof child.pid === "number") {
|
|
211
|
+
try {
|
|
212
|
+
onWriterProcess?.({ state: "running", pid: child.pid });
|
|
213
|
+
}
|
|
214
|
+
catch (writerError) {
|
|
215
|
+
writerRegistrationError = `Failed to record revived Pi writer ownership: ${writerError instanceof Error ? writerError.message : String(writerError)}`;
|
|
216
|
+
trySignalChild(child, "SIGKILL");
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
let error = writerRegistrationError;
|
|
220
|
+
let assistantError;
|
|
221
|
+
let interrupted = false;
|
|
222
|
+
let timedOut = false;
|
|
223
|
+
let stopped = false;
|
|
224
|
+
let turnBudgetExceeded = false;
|
|
225
|
+
let turnBudgetMessage;
|
|
226
|
+
let turnBudget;
|
|
227
|
+
let observedMutationAttempt = false;
|
|
228
|
+
const childWatchdogConfig = decodeChildWatchdogConfig(env?.[CHILD_WATCHDOG_CONFIG_ENV]);
|
|
229
|
+
let childWatchdogState;
|
|
230
|
+
let applyChildLifecycle = (_action) => { };
|
|
231
|
+
const updateChildWatchdogState = (snapshot) => {
|
|
232
|
+
childWatchdogState = snapshot;
|
|
233
|
+
};
|
|
234
|
+
const writeOutputLine = (line) => {
|
|
235
|
+
if (!line.trim())
|
|
236
|
+
return;
|
|
237
|
+
outputStream.write(`${line}\n`);
|
|
238
|
+
};
|
|
239
|
+
const writeOutputText = (text) => {
|
|
240
|
+
for (const line of text.split("\n")) {
|
|
241
|
+
writeOutputLine(line);
|
|
242
|
+
}
|
|
243
|
+
};
|
|
244
|
+
const appendChildEvent = (event) => {
|
|
245
|
+
if (!childEventContext)
|
|
246
|
+
return;
|
|
247
|
+
if (!shouldPersistChildEvent(event))
|
|
248
|
+
return;
|
|
249
|
+
appendDiagnosticJsonl(childEventContext.eventsPath, JSON.stringify({
|
|
250
|
+
...event,
|
|
251
|
+
subagentSource: "child",
|
|
252
|
+
subagentRunId: childEventContext.runId,
|
|
253
|
+
subagentStepIndex: childEventContext.stepIndex,
|
|
254
|
+
subagentAgent: childEventContext.agent,
|
|
255
|
+
observedAt: Date.now(),
|
|
256
|
+
}), typeof event.type === "string" ? event.type : undefined);
|
|
257
|
+
};
|
|
258
|
+
const appendChildLine = (type, line) => {
|
|
259
|
+
appendChildEvent({ type, line });
|
|
260
|
+
if (type === "subagent.child.stdout")
|
|
261
|
+
transcriptWriter?.writeStdoutLine(line);
|
|
262
|
+
else
|
|
263
|
+
transcriptWriter?.writeStderrLine(line);
|
|
264
|
+
};
|
|
265
|
+
const processStdoutLine = (line) => {
|
|
266
|
+
if (!line.trim())
|
|
267
|
+
return;
|
|
268
|
+
let event;
|
|
269
|
+
try {
|
|
270
|
+
event = JSON.parse(line);
|
|
271
|
+
}
|
|
272
|
+
catch {
|
|
273
|
+
rawStdoutTail.push(`${line}\n`);
|
|
274
|
+
writeOutputLine(line);
|
|
275
|
+
appendChildLine("subagent.child.stdout", line);
|
|
276
|
+
return;
|
|
277
|
+
}
|
|
278
|
+
appendChildEvent(event);
|
|
279
|
+
transcriptWriter?.writeChildEvent(event);
|
|
280
|
+
if (event.type === "agent_settled")
|
|
281
|
+
agentSettledReceived = true;
|
|
282
|
+
applyChildLifecycle(projectChildLifecycle(event));
|
|
283
|
+
if (isChildWatchdogStatusEvent(event)) {
|
|
284
|
+
if (!childWatchdogConfig)
|
|
285
|
+
return;
|
|
286
|
+
const next = acceptChildWatchdogEvent({
|
|
287
|
+
current: childWatchdogState,
|
|
288
|
+
event,
|
|
289
|
+
runId: childEventContext?.runId,
|
|
290
|
+
agent: childEventContext?.agent,
|
|
291
|
+
childIndex: childEventContext?.stepIndex,
|
|
292
|
+
});
|
|
293
|
+
if (!next)
|
|
294
|
+
return;
|
|
295
|
+
updateChildWatchdogState(next);
|
|
296
|
+
onChildEvent?.(event);
|
|
297
|
+
if (childWatchdogIsActive(next)) {
|
|
298
|
+
if (finalDrainTimer) {
|
|
299
|
+
clearTimeout(finalDrainTimer);
|
|
300
|
+
finalDrainTimer = undefined;
|
|
301
|
+
}
|
|
302
|
+
if (finalHardKillTimer) {
|
|
303
|
+
clearTimeout(finalHardKillTimer);
|
|
304
|
+
finalHardKillTimer = undefined;
|
|
305
|
+
}
|
|
306
|
+
armWatchdogTail();
|
|
307
|
+
}
|
|
308
|
+
else {
|
|
309
|
+
clearWatchdogTailTimer();
|
|
310
|
+
if (cleanTerminalAssistantStopReceived || agentSettledReceived)
|
|
311
|
+
startFinalDrain();
|
|
312
|
+
}
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
onChildEvent?.(event);
|
|
316
|
+
if (event.type === "tool_execution_start" && event.toolName) {
|
|
317
|
+
observedMutationAttempt = observedMutationAttempt || isMutatingTool(event.toolName, event.args);
|
|
318
|
+
const toolArgs = extractToolArgsPreview(event.args ?? {});
|
|
319
|
+
writeOutputLine(toolArgs ? `${event.toolName}: ${toolArgs}` : event.toolName);
|
|
320
|
+
return;
|
|
321
|
+
}
|
|
322
|
+
if ((event.type === "message_end" || event.type === "tool_result_end") && event.message) {
|
|
323
|
+
messages.push(event.message);
|
|
324
|
+
const text = extractTextFromContent(event.message.content);
|
|
325
|
+
if (text)
|
|
326
|
+
writeOutputText(text);
|
|
327
|
+
if (event.type !== "message_end" || event.message.role !== "assistant")
|
|
328
|
+
return;
|
|
329
|
+
if (event.message.model)
|
|
330
|
+
model = event.message.model;
|
|
331
|
+
if (event.message.errorMessage)
|
|
332
|
+
assistantError = event.message.errorMessage;
|
|
333
|
+
const eventUsage = event.message.usage;
|
|
334
|
+
if (eventUsage) {
|
|
335
|
+
usage.turns++;
|
|
336
|
+
usage.input += eventUsage.input ?? eventUsage.inputTokens ?? 0;
|
|
337
|
+
usage.output += eventUsage.output ?? eventUsage.outputTokens ?? 0;
|
|
338
|
+
usage.cacheRead += eventUsage.cacheRead ?? 0;
|
|
339
|
+
usage.cacheWrite += eventUsage.cacheWrite ?? 0;
|
|
340
|
+
usage.cost += eventUsage.cost?.total ?? 0;
|
|
341
|
+
}
|
|
342
|
+
if (isTerminalAssistantStop(event.message)) {
|
|
343
|
+
if (!event.message.errorMessage && extractTextFromContent(event.message.content).trim())
|
|
344
|
+
assistantError = undefined;
|
|
345
|
+
cleanTerminalAssistantStopReceived ||= !event.message.errorMessage;
|
|
346
|
+
applyChildLifecycle(projectChildLifecycle(event, true));
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
};
|
|
350
|
+
// Guard both cases that can leave the parent waiting on `close` forever:
|
|
351
|
+
// a lingering stdio holder after `exit`, or a child that never exits.
|
|
352
|
+
const FINAL_STOP_GRACE_MS = 1000;
|
|
353
|
+
const HARD_KILL_MS = 3000;
|
|
354
|
+
const TIMEOUT_HARD_KILL_MS = 3000;
|
|
355
|
+
let childExited = false;
|
|
356
|
+
let forcedTerminationSignal = false;
|
|
357
|
+
let cleanTerminalAssistantStopReceived = false;
|
|
358
|
+
let agentSettledReceived = false;
|
|
359
|
+
let finalDrainTimer;
|
|
360
|
+
let finalHardKillTimer;
|
|
361
|
+
let watchdogTailTimer;
|
|
362
|
+
let timeoutHardKillTimer;
|
|
363
|
+
let turnBudgetTerminationTimer;
|
|
364
|
+
let turnBudgetHardKillTimer;
|
|
365
|
+
let protocolHardKillTimer;
|
|
366
|
+
let protocolError;
|
|
367
|
+
let settled = false;
|
|
368
|
+
applyChildLifecycle = (action) => {
|
|
369
|
+
if (action === "cancel-drain") {
|
|
370
|
+
if (finalDrainTimer) {
|
|
371
|
+
clearTimeout(finalDrainTimer);
|
|
372
|
+
finalDrainTimer = undefined;
|
|
373
|
+
}
|
|
374
|
+
if (finalHardKillTimer) {
|
|
375
|
+
clearTimeout(finalHardKillTimer);
|
|
376
|
+
finalHardKillTimer = undefined;
|
|
377
|
+
}
|
|
378
|
+
clearWatchdogTailTimer();
|
|
379
|
+
return;
|
|
380
|
+
}
|
|
381
|
+
if (action === "start-drain")
|
|
382
|
+
startFinalDrain();
|
|
383
|
+
};
|
|
384
|
+
const failProtocol = (limit) => {
|
|
385
|
+
if (protocolError)
|
|
386
|
+
return;
|
|
387
|
+
protocolError = limit;
|
|
388
|
+
error = formatProtocolOutputLimit(limit);
|
|
389
|
+
if (!childExited) {
|
|
390
|
+
trySignalChild(child, "SIGTERM");
|
|
391
|
+
protocolHardKillTimer = setTimeout(() => {
|
|
392
|
+
if (!settled)
|
|
393
|
+
trySignalChild(child, "SIGKILL");
|
|
394
|
+
}, 3000);
|
|
395
|
+
protocolHardKillTimer.unref?.();
|
|
396
|
+
}
|
|
397
|
+
};
|
|
398
|
+
const stdoutReader = createBoundedLineReader({ onLine: processStdoutLine, onLimit: failProtocol });
|
|
399
|
+
const stderrReader = createBoundedLineReader({
|
|
400
|
+
stream: "stderr",
|
|
401
|
+
maxPendingLineBytes: MAX_CHILD_STDERR_BYTES,
|
|
402
|
+
onLine: (line) => appendChildLine("subagent.child.stderr", line),
|
|
403
|
+
onLimit: (limit) => appendChildLine("subagent.child.stderr", formatProtocolOutputLimit(limit)),
|
|
404
|
+
});
|
|
405
|
+
const clearStdioGuard = attachPostExitStdioGuard(child, { idleMs: 2000, hardMs: 8000 });
|
|
406
|
+
child.stdout.on("data", (chunk) => stdoutReader.push(chunk));
|
|
407
|
+
child.stderr.on("data", (chunk) => {
|
|
408
|
+
stderrTail.push(chunk);
|
|
409
|
+
stderrReader.push(chunk);
|
|
410
|
+
outputStream.write(chunk);
|
|
411
|
+
});
|
|
412
|
+
registerInterrupt?.(() => {
|
|
413
|
+
if (settled || timedOut || stopped)
|
|
414
|
+
return;
|
|
415
|
+
interrupted = true;
|
|
416
|
+
if (!error)
|
|
417
|
+
error = "Interrupted. Waiting for explicit next action.";
|
|
418
|
+
trySignalChild(child, "SIGINT");
|
|
419
|
+
setTimeout(() => {
|
|
420
|
+
if (!settled && !timedOut && !stopped)
|
|
421
|
+
trySignalChild(child, "SIGTERM");
|
|
422
|
+
}, 1000).unref?.();
|
|
423
|
+
});
|
|
424
|
+
registerTimeout?.(() => {
|
|
425
|
+
if (settled || timedOut || stopped)
|
|
426
|
+
return;
|
|
427
|
+
timedOut = true;
|
|
428
|
+
interrupted = false;
|
|
429
|
+
error = timeoutMessage ?? "Subagent timed out.";
|
|
430
|
+
trySignalChild(child, "SIGTERM");
|
|
431
|
+
timeoutHardKillTimer = setTimeout(() => {
|
|
432
|
+
if (!settled)
|
|
433
|
+
trySignalChild(child, "SIGKILL");
|
|
434
|
+
}, TIMEOUT_HARD_KILL_MS);
|
|
435
|
+
timeoutHardKillTimer.unref?.();
|
|
436
|
+
});
|
|
437
|
+
registerStop?.(() => {
|
|
438
|
+
if (settled || timedOut || stopped)
|
|
439
|
+
return;
|
|
440
|
+
stopped = true;
|
|
441
|
+
interrupted = false;
|
|
442
|
+
error = stopMessage ?? "Subagent stopped by user.";
|
|
443
|
+
trySignalChild(child, "SIGTERM");
|
|
444
|
+
timeoutHardKillTimer = setTimeout(() => {
|
|
445
|
+
if (!settled)
|
|
446
|
+
trySignalChild(child, "SIGKILL");
|
|
447
|
+
}, TIMEOUT_HARD_KILL_MS);
|
|
448
|
+
timeoutHardKillTimer.unref?.();
|
|
449
|
+
});
|
|
450
|
+
registerTurnBudgetAbort?.((message, state) => {
|
|
451
|
+
if (settled || timedOut || stopped || turnBudgetExceeded)
|
|
452
|
+
return;
|
|
453
|
+
turnBudgetExceeded = true;
|
|
454
|
+
turnBudgetMessage = message;
|
|
455
|
+
turnBudget = state;
|
|
456
|
+
interrupted = false;
|
|
457
|
+
error = message;
|
|
458
|
+
trySignalChild(child, "SIGINT");
|
|
459
|
+
turnBudgetTerminationTimer = setTimeout(() => {
|
|
460
|
+
if (!settled && !timedOut && !stopped)
|
|
461
|
+
trySignalChild(child, "SIGTERM");
|
|
462
|
+
}, 1000);
|
|
463
|
+
turnBudgetTerminationTimer.unref?.();
|
|
464
|
+
turnBudgetHardKillTimer = setTimeout(() => {
|
|
465
|
+
if (!settled && !timedOut && !stopped)
|
|
466
|
+
trySignalChild(child, "SIGKILL");
|
|
467
|
+
}, 4000);
|
|
468
|
+
turnBudgetHardKillTimer.unref?.();
|
|
469
|
+
});
|
|
470
|
+
const clearDrainTimers = () => {
|
|
471
|
+
if (finalDrainTimer) {
|
|
472
|
+
clearTimeout(finalDrainTimer);
|
|
473
|
+
finalDrainTimer = undefined;
|
|
474
|
+
}
|
|
475
|
+
if (finalHardKillTimer) {
|
|
476
|
+
clearTimeout(finalHardKillTimer);
|
|
477
|
+
finalHardKillTimer = undefined;
|
|
478
|
+
}
|
|
479
|
+
clearWatchdogTailTimer();
|
|
480
|
+
if (timeoutHardKillTimer) {
|
|
481
|
+
clearTimeout(timeoutHardKillTimer);
|
|
482
|
+
timeoutHardKillTimer = undefined;
|
|
483
|
+
}
|
|
484
|
+
if (turnBudgetTerminationTimer) {
|
|
485
|
+
clearTimeout(turnBudgetTerminationTimer);
|
|
486
|
+
turnBudgetTerminationTimer = undefined;
|
|
487
|
+
}
|
|
488
|
+
if (turnBudgetHardKillTimer) {
|
|
489
|
+
clearTimeout(turnBudgetHardKillTimer);
|
|
490
|
+
turnBudgetHardKillTimer = undefined;
|
|
491
|
+
}
|
|
492
|
+
if (protocolHardKillTimer) {
|
|
493
|
+
clearTimeout(protocolHardKillTimer);
|
|
494
|
+
protocolHardKillTimer = undefined;
|
|
495
|
+
}
|
|
496
|
+
};
|
|
497
|
+
function startFinalDrain() {
|
|
498
|
+
if (childWatchdogIsActive(childWatchdogState)) {
|
|
499
|
+
armWatchdogTail();
|
|
500
|
+
return;
|
|
501
|
+
}
|
|
502
|
+
if (childExited || finalDrainTimer || settled)
|
|
503
|
+
return;
|
|
504
|
+
finalDrainTimer = setTimeout(() => {
|
|
505
|
+
if (settled)
|
|
506
|
+
return;
|
|
507
|
+
const termSent = trySignalChild(child, "SIGTERM");
|
|
508
|
+
if (!termSent)
|
|
509
|
+
return;
|
|
510
|
+
forcedTerminationSignal = true;
|
|
511
|
+
if (!cleanTerminalAssistantStopReceived && !agentSettledReceived && !error && !assistantError) {
|
|
512
|
+
error = `Subagent process did not exit within ${FINAL_STOP_GRACE_MS}ms after its terminal event. Forcing termination.`;
|
|
513
|
+
}
|
|
514
|
+
finalHardKillTimer = setTimeout(() => {
|
|
515
|
+
if (settled)
|
|
516
|
+
return;
|
|
517
|
+
forcedTerminationSignal = trySignalChild(child, "SIGKILL") || forcedTerminationSignal;
|
|
518
|
+
}, HARD_KILL_MS);
|
|
519
|
+
finalHardKillTimer.unref?.();
|
|
520
|
+
}, FINAL_STOP_GRACE_MS);
|
|
521
|
+
finalDrainTimer.unref?.();
|
|
522
|
+
}
|
|
523
|
+
function clearWatchdogTailTimer() {
|
|
524
|
+
if (watchdogTailTimer) {
|
|
525
|
+
clearTimeout(watchdogTailTimer);
|
|
526
|
+
watchdogTailTimer = undefined;
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
function armWatchdogTail() {
|
|
530
|
+
if ((!cleanTerminalAssistantStopReceived && !agentSettledReceived) || watchdogTailTimer || settled)
|
|
531
|
+
return;
|
|
532
|
+
watchdogTailTimer = setTimeout(() => {
|
|
533
|
+
watchdogTailTimer = undefined;
|
|
534
|
+
updateChildWatchdogState({
|
|
535
|
+
phase: "stale",
|
|
536
|
+
seq: (childWatchdogState?.seq ?? 0) + 1,
|
|
537
|
+
lastUpdate: Date.now(),
|
|
538
|
+
followUpPending: false,
|
|
539
|
+
reason: "child watchdog tail timeout",
|
|
540
|
+
timedOut: true,
|
|
541
|
+
});
|
|
542
|
+
startFinalDrain();
|
|
543
|
+
}, childWatchdogConfig?.watchdogTailTimeoutMs ?? 120_000);
|
|
544
|
+
watchdogTailTimer.unref?.();
|
|
545
|
+
}
|
|
546
|
+
child.on("exit", () => {
|
|
547
|
+
childExited = true;
|
|
548
|
+
clearDrainTimers();
|
|
549
|
+
});
|
|
550
|
+
child.on("close", (exitCode, signal) => {
|
|
551
|
+
settled = true;
|
|
552
|
+
try {
|
|
553
|
+
onWriterProcess?.({ state: "none" });
|
|
554
|
+
}
|
|
555
|
+
catch {
|
|
556
|
+
// The runner still owns and releases the lease during finalization.
|
|
557
|
+
}
|
|
558
|
+
registerInterrupt?.(undefined);
|
|
559
|
+
registerTimeout?.(undefined);
|
|
560
|
+
registerStop?.(undefined);
|
|
561
|
+
registerTurnBudgetAbort?.(undefined);
|
|
562
|
+
clearDrainTimers();
|
|
563
|
+
clearStdioGuard();
|
|
564
|
+
stdoutReader.end();
|
|
565
|
+
stderrReader.end();
|
|
566
|
+
outputStream.end();
|
|
567
|
+
const stderr = stderrTail.text();
|
|
568
|
+
const finalOutput = getFinalOutput(messages) || rawStdoutTail.text().trim();
|
|
569
|
+
const finalError = error ?? assistantError;
|
|
570
|
+
const forcedDrainAfterFinalSuccess = forcedTerminationSignal && (cleanTerminalAssistantStopReceived || agentSettledReceived) && !finalError;
|
|
571
|
+
resolve({
|
|
572
|
+
stderr,
|
|
573
|
+
exitCode: timedOut || stopped ? 1 : turnBudgetExceeded ? 1 : interrupted || forcedDrainAfterFinalSuccess ? 0 : forcedTerminationSignal || signal ? (exitCode ?? 1) : exitCode,
|
|
574
|
+
messages,
|
|
575
|
+
usage,
|
|
576
|
+
model,
|
|
577
|
+
error: stopped ? (stopMessage ?? "Subagent stopped by user.") : timedOut ? (timeoutMessage ?? "Subagent timed out.") : turnBudgetExceeded ? turnBudgetMessage : interrupted || forcedDrainAfterFinalSuccess ? undefined : finalError,
|
|
578
|
+
protocolError,
|
|
579
|
+
finalOutput: (timedOut || stopped) && !finalOutput.trim() ? (stopped ? stopMessage ?? "Subagent stopped by user." : timeoutMessage ?? "Subagent timed out.") : finalOutput,
|
|
580
|
+
interrupted,
|
|
581
|
+
timedOut,
|
|
582
|
+
stopped,
|
|
583
|
+
turnBudget,
|
|
584
|
+
turnBudgetExceeded,
|
|
585
|
+
wrapUpRequested: turnBudget?.outcome === "wrap-up-requested" || turnBudgetExceeded || undefined,
|
|
586
|
+
observedMutationAttempt,
|
|
587
|
+
watchdog: childWatchdogState,
|
|
588
|
+
});
|
|
589
|
+
});
|
|
590
|
+
child.on("error", (spawnError) => {
|
|
591
|
+
settled = true;
|
|
592
|
+
try {
|
|
593
|
+
onWriterProcess?.({ state: "none" });
|
|
594
|
+
}
|
|
595
|
+
catch {
|
|
596
|
+
// The runner still owns and releases the lease during finalization.
|
|
597
|
+
}
|
|
598
|
+
registerInterrupt?.(undefined);
|
|
599
|
+
registerTimeout?.(undefined);
|
|
600
|
+
registerStop?.(undefined);
|
|
601
|
+
registerTurnBudgetAbort?.(undefined);
|
|
602
|
+
clearDrainTimers();
|
|
603
|
+
clearStdioGuard();
|
|
604
|
+
stdoutReader.end();
|
|
605
|
+
stderrReader.end();
|
|
606
|
+
outputStream.end();
|
|
607
|
+
const stderr = stderrTail.text();
|
|
608
|
+
const finalOutput = getFinalOutput(messages) || rawStdoutTail.text().trim();
|
|
609
|
+
const spawnErrorMessage = spawnError instanceof Error ? spawnError.message : String(spawnError);
|
|
610
|
+
resolve({ stderr, exitCode: 1, messages, usage, model, error: stopped ? (stopMessage ?? "Subagent stopped by user.") : timedOut ? (timeoutMessage ?? "Subagent timed out.") : turnBudgetExceeded ? turnBudgetMessage : error ?? assistantError ?? spawnErrorMessage, protocolError, finalOutput: (timedOut || stopped) && !finalOutput.trim() ? (stopped ? stopMessage ?? "Subagent stopped by user." : timeoutMessage ?? "Subagent timed out.") : finalOutput, timedOut, stopped, turnBudget, turnBudgetExceeded, wrapUpRequested: turnBudget?.outcome === "wrap-up-requested" || turnBudgetExceeded || undefined, observedMutationAttempt, watchdog: childWatchdogState });
|
|
611
|
+
});
|
|
612
|
+
});
|
|
613
|
+
}
|
|
614
|
+
function resolvePiPackageRootFallback() {
|
|
615
|
+
const root = resolveInstalledPiPackageRoot();
|
|
616
|
+
if (root)
|
|
617
|
+
return root;
|
|
618
|
+
throw new Error(`Could not resolve ${PI_CODING_AGENT_PACKAGE} package root`);
|
|
619
|
+
}
|
|
620
|
+
async function exportSessionHtml(sessionFile, outputDir, piPackageRoot) {
|
|
621
|
+
const pkgRoot = piPackageRoot ?? resolvePiPackageRootFallback();
|
|
622
|
+
const exportModulePath = path.join(pkgRoot, "dist", "core", "export-html", "index.js");
|
|
623
|
+
const moduleUrl = pathToFileURL(exportModulePath).href;
|
|
624
|
+
const mod = await import(__rewriteRelativeImportExtension(moduleUrl));
|
|
625
|
+
const exportFromFile = mod
|
|
626
|
+
.exportFromFile;
|
|
627
|
+
if (typeof exportFromFile !== "function") {
|
|
628
|
+
throw new Error("exportFromFile not available");
|
|
629
|
+
}
|
|
630
|
+
const outputPath = path.join(outputDir, `${path.basename(sessionFile, ".jsonl")}.html`);
|
|
631
|
+
return exportFromFile(sessionFile, { outputPath });
|
|
632
|
+
}
|
|
633
|
+
function createShareLink(htmlPath) {
|
|
634
|
+
try {
|
|
635
|
+
const auth = spawnSync("gh", ["auth", "status"], { encoding: "utf-8" });
|
|
636
|
+
if (auth.status !== 0) {
|
|
637
|
+
return { error: "GitHub CLI is not logged in. Run 'gh auth login' first." };
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
catch {
|
|
641
|
+
return { error: "GitHub CLI (gh) is not installed." };
|
|
642
|
+
}
|
|
643
|
+
try {
|
|
644
|
+
const result = spawnSync("gh", ["gist", "create", htmlPath], { encoding: "utf-8" });
|
|
645
|
+
if (result.status !== 0) {
|
|
646
|
+
const err = (result.stderr || "").trim() || "Failed to create gist.";
|
|
647
|
+
return { error: err };
|
|
648
|
+
}
|
|
649
|
+
const gistUrl = (result.stdout || "").trim();
|
|
650
|
+
const gistId = gistUrl.split("/").pop();
|
|
651
|
+
if (!gistId)
|
|
652
|
+
return { error: "Failed to parse gist ID." };
|
|
653
|
+
const shareUrl = `https://shittycodingagent.ai/session/?${gistId}`;
|
|
654
|
+
return { shareUrl, gistUrl };
|
|
655
|
+
}
|
|
656
|
+
catch (err) {
|
|
657
|
+
return { error: String(err) };
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
function formatDuration(ms) {
|
|
661
|
+
if (ms < 1000)
|
|
662
|
+
return `${ms}ms`;
|
|
663
|
+
if (ms < 60000)
|
|
664
|
+
return `${(ms / 1000).toFixed(1)}s`;
|
|
665
|
+
const minutes = Math.floor(ms / 60000);
|
|
666
|
+
const seconds = Math.floor((ms % 60000) / 1000);
|
|
667
|
+
return `${minutes}m${seconds}s`;
|
|
668
|
+
}
|
|
669
|
+
function writeRunLog(logPath, input) {
|
|
670
|
+
const lines = [];
|
|
671
|
+
lines.push(`# Subagent run ${input.id}`);
|
|
672
|
+
lines.push("");
|
|
673
|
+
lines.push(`- **Mode:** ${input.mode}`);
|
|
674
|
+
lines.push(`- **CWD:** ${input.cwd}`);
|
|
675
|
+
lines.push(`- **Started:** ${new Date(input.startedAt).toISOString()}`);
|
|
676
|
+
lines.push(`- **Ended:** ${new Date(input.endedAt).toISOString()}`);
|
|
677
|
+
lines.push(`- **Duration:** ${formatDuration(input.endedAt - input.startedAt)}`);
|
|
678
|
+
if (input.sessionFile)
|
|
679
|
+
lines.push(`- **Session:** ${input.sessionFile}`);
|
|
680
|
+
if (input.shareUrl)
|
|
681
|
+
lines.push(`- **Share:** ${input.shareUrl}`);
|
|
682
|
+
if (input.shareError)
|
|
683
|
+
lines.push(`- **Share error:** ${input.shareError}`);
|
|
684
|
+
if (input.artifactsDir)
|
|
685
|
+
lines.push(`- **Artifacts:** ${input.artifactsDir}`);
|
|
686
|
+
lines.push("");
|
|
687
|
+
lines.push("## Steps");
|
|
688
|
+
lines.push("| Step | Agent | Status | Duration |");
|
|
689
|
+
lines.push("| --- | --- | --- | --- |");
|
|
690
|
+
input.steps.forEach((step, i) => {
|
|
691
|
+
const duration = step.durationMs !== undefined ? formatDuration(step.durationMs) : "-";
|
|
692
|
+
lines.push(`| ${i + 1} | ${step.agent} | ${step.status} | ${duration} |`);
|
|
693
|
+
});
|
|
694
|
+
lines.push("");
|
|
695
|
+
lines.push("## Summary");
|
|
696
|
+
if (input.truncated) {
|
|
697
|
+
lines.push("_Output truncated_");
|
|
698
|
+
lines.push("");
|
|
699
|
+
}
|
|
700
|
+
lines.push(input.summary.trim() || "(no output)");
|
|
701
|
+
lines.push("");
|
|
702
|
+
fs.writeFileSync(logPath, lines.join("\n"), "utf-8");
|
|
703
|
+
}
|
|
704
|
+
/** Run a single pi agent step, returning output and metadata */
|
|
705
|
+
async function runSingleStep(step, ctx) {
|
|
706
|
+
if (step.importAsyncRoot) {
|
|
707
|
+
let importTimedOut = false;
|
|
708
|
+
let importStopped = false;
|
|
709
|
+
ctx.registerTimeout?.(() => {
|
|
710
|
+
importTimedOut = true;
|
|
711
|
+
let pid;
|
|
712
|
+
try {
|
|
713
|
+
pid = readStatus(step.importAsyncRoot.asyncDir)?.pid;
|
|
714
|
+
}
|
|
715
|
+
catch {
|
|
716
|
+
pid = undefined;
|
|
717
|
+
}
|
|
718
|
+
try {
|
|
719
|
+
deliverTimeoutRequest({ asyncDir: step.importAsyncRoot.asyncDir, pid, source: "ancestor-timeout" });
|
|
720
|
+
}
|
|
721
|
+
catch {
|
|
722
|
+
// The parent runner's own timeout result is authoritative for the attached step.
|
|
723
|
+
}
|
|
724
|
+
});
|
|
725
|
+
ctx.registerStop?.(() => {
|
|
726
|
+
importStopped = true;
|
|
727
|
+
let pid;
|
|
728
|
+
try {
|
|
729
|
+
pid = readStatus(step.importAsyncRoot.asyncDir)?.pid;
|
|
730
|
+
}
|
|
731
|
+
catch {
|
|
732
|
+
pid = undefined;
|
|
733
|
+
}
|
|
734
|
+
try {
|
|
735
|
+
deliverStopRequest({ asyncDir: step.importAsyncRoot.asyncDir, pid, source: "ancestor-stop" });
|
|
736
|
+
}
|
|
737
|
+
catch {
|
|
738
|
+
// The parent runner's own stopped result is authoritative for the attached step.
|
|
739
|
+
}
|
|
740
|
+
});
|
|
741
|
+
try {
|
|
742
|
+
const imported = await waitForImportedAsyncRoot(step.importAsyncRoot, {
|
|
743
|
+
shouldAbort: () => importTimedOut || importStopped || ctx.timeoutSignal?.aborted === true || ctx.stopSignal?.aborted === true || ctx.skipAcceptance?.() === true,
|
|
744
|
+
timeoutMessage: importStopped || ctx.stopSignal?.aborted === true ? ctx.stopMessage : ctx.timeoutMessage,
|
|
745
|
+
});
|
|
746
|
+
try {
|
|
747
|
+
fs.writeFileSync(ctx.outputFile, imported.output, "utf-8");
|
|
748
|
+
}
|
|
749
|
+
catch {
|
|
750
|
+
// Output files are observability only for imported roots.
|
|
751
|
+
}
|
|
752
|
+
const stopped = importStopped || imported.stopped === true || ctx.stopSignal?.aborted === true;
|
|
753
|
+
const timedOut = !stopped && (importTimedOut || imported.timedOut === true || ctx.timeoutSignal?.aborted === true || ctx.skipAcceptance?.() === true);
|
|
754
|
+
const message = stopped ? ctx.stopMessage ?? "Subagent stopped by user." : ctx.timeoutMessage ?? "Subagent timed out.";
|
|
755
|
+
return {
|
|
756
|
+
agent: imported.agent,
|
|
757
|
+
output: timedOut || stopped ? message : imported.output,
|
|
758
|
+
exitCode: timedOut || stopped ? 1 : imported.exitCode,
|
|
759
|
+
error: timedOut || stopped ? message : imported.error,
|
|
760
|
+
timedOut: timedOut ? true : undefined,
|
|
761
|
+
stopped: stopped ? true : undefined,
|
|
762
|
+
sessionFile: imported.sessionFile,
|
|
763
|
+
intercomTarget: imported.intercomTarget,
|
|
764
|
+
model: imported.model,
|
|
765
|
+
attemptedModels: imported.attemptedModels,
|
|
766
|
+
modelAttempts: imported.modelAttempts,
|
|
767
|
+
totalCost: imported.totalCost,
|
|
768
|
+
structuredOutput: timedOut || stopped ? undefined : imported.structuredOutput,
|
|
769
|
+
structuredOutputPath: timedOut || stopped ? undefined : imported.structuredOutputPath,
|
|
770
|
+
structuredOutputSchemaPath: timedOut || stopped ? undefined : imported.structuredOutputSchemaPath,
|
|
771
|
+
acceptance: timedOut || stopped ? undefined : imported.acceptance,
|
|
772
|
+
};
|
|
773
|
+
}
|
|
774
|
+
finally {
|
|
775
|
+
ctx.registerTimeout?.(undefined);
|
|
776
|
+
ctx.registerStop?.(undefined);
|
|
777
|
+
}
|
|
778
|
+
}
|
|
779
|
+
const effectiveStructuredOutput = step.structuredOutput ?? (step.structuredOutputSchema
|
|
780
|
+
? createStructuredOutputRuntime(step.structuredOutputSchema, path.join(path.dirname(ctx.outputFile), "structured-output"))
|
|
781
|
+
: undefined);
|
|
782
|
+
const placeholderRegex = new RegExp(ctx.placeholder.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), "g");
|
|
783
|
+
let task = step.task.replace(placeholderRegex, () => ctx.previousOutput);
|
|
784
|
+
if (ctx.outputs)
|
|
785
|
+
task = resolveOutputReferences(task, ctx.outputs);
|
|
786
|
+
const taskForCompletionGuard = task;
|
|
787
|
+
if (step.effectiveAcceptance) {
|
|
788
|
+
const acceptancePrompt = formatAcceptancePrompt(step.effectiveAcceptance);
|
|
789
|
+
if (acceptancePrompt)
|
|
790
|
+
task = `${task}\n${acceptancePrompt}`;
|
|
791
|
+
}
|
|
792
|
+
const sessionEnabled = Boolean(step.sessionFile) || ctx.sessionEnabled;
|
|
793
|
+
const sessionDir = step.sessionFile ? undefined : ctx.sessionDir;
|
|
794
|
+
let artifactPaths;
|
|
795
|
+
let transcriptWriter;
|
|
796
|
+
if (ctx.artifactsDir && ctx.artifactConfig?.enabled !== false) {
|
|
797
|
+
const index = ctx.flatStepCount > 1 ? ctx.flatIndex : undefined;
|
|
798
|
+
artifactPaths = getArtifactPaths(ctx.artifactsDir, ctx.id, step.agent, index);
|
|
799
|
+
fs.mkdirSync(ctx.artifactsDir, { recursive: true });
|
|
800
|
+
if (ctx.artifactConfig?.includeInput !== false) {
|
|
801
|
+
fs.writeFileSync(artifactPaths.inputPath, `# Task for ${step.agent}\n\n${task}`, "utf-8");
|
|
802
|
+
}
|
|
803
|
+
if (ctx.artifactConfig?.includeTranscript !== false) {
|
|
804
|
+
transcriptWriter = createChildTranscriptWriter({
|
|
805
|
+
transcriptPath: artifactPaths.transcriptPath,
|
|
806
|
+
source: "async",
|
|
807
|
+
runId: ctx.id,
|
|
808
|
+
agent: step.agent,
|
|
809
|
+
childIndex: ctx.flatIndex,
|
|
810
|
+
cwd: step.cwd ?? ctx.cwd,
|
|
811
|
+
});
|
|
812
|
+
}
|
|
813
|
+
}
|
|
814
|
+
transcriptWriter?.writeInitialUserMessage(task);
|
|
815
|
+
const candidates = step.modelCandidates && step.modelCandidates.length > 0
|
|
816
|
+
? step.modelCandidates
|
|
817
|
+
: step.model
|
|
818
|
+
? [step.model]
|
|
819
|
+
: [undefined];
|
|
820
|
+
const attemptedModels = [];
|
|
821
|
+
const modelAttempts = [];
|
|
822
|
+
const attemptNotes = [];
|
|
823
|
+
const eventsPath = path.join(path.dirname(ctx.outputFile), "events.jsonl");
|
|
824
|
+
let finalResult;
|
|
825
|
+
let finalOutputSnapshot;
|
|
826
|
+
let completionGuardTriggeredFinal = false;
|
|
827
|
+
let turnBudget = ctx.turnBudget ? initialTurnBudgetState(ctx.turnBudget) : undefined;
|
|
828
|
+
let toolBudget = step.toolBudget ? initialToolBudgetState(step.toolBudget) : undefined;
|
|
829
|
+
let toolBudgetBlocked = false;
|
|
830
|
+
for (let index = 0; index < candidates.length; index++) {
|
|
831
|
+
if (ctx.timeoutSignal?.aborted || ctx.skipAcceptance?.())
|
|
832
|
+
break;
|
|
833
|
+
const candidate = candidates[index];
|
|
834
|
+
ctx.onAttemptStart?.({ model: candidate, thinking: resolveEffectiveThinking(candidate, step.thinking) });
|
|
835
|
+
const outputSnapshot = captureSingleOutputSnapshot(step.outputPath);
|
|
836
|
+
if (effectiveStructuredOutput) {
|
|
837
|
+
try {
|
|
838
|
+
if (fs.existsSync(effectiveStructuredOutput.outputPath))
|
|
839
|
+
fs.unlinkSync(effectiveStructuredOutput.outputPath);
|
|
840
|
+
}
|
|
841
|
+
catch {
|
|
842
|
+
// Missing/stale structured-output files are handled after the child exits.
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
const watchdogConfig = resolveWatchdogConfig(step.cwd ?? ctx.cwd);
|
|
846
|
+
const childWatchdog = watchdogConfig.ok
|
|
847
|
+
? resolveChildWatchdogConfig({
|
|
848
|
+
config: watchdogConfig.config,
|
|
849
|
+
agent: step.agent,
|
|
850
|
+
runId: ctx.id,
|
|
851
|
+
childIndex: ctx.flatIndex,
|
|
852
|
+
})
|
|
853
|
+
: undefined;
|
|
854
|
+
const { args, env, tempDir, toolDiagnosticPath } = buildPiArgs({
|
|
855
|
+
parentSessionId: step.parentSessionId,
|
|
856
|
+
baseArgs: ["--mode", "json", "-p"],
|
|
857
|
+
task,
|
|
858
|
+
sessionEnabled,
|
|
859
|
+
sessionDir,
|
|
860
|
+
sessionFile: step.sessionFile,
|
|
861
|
+
model: candidate,
|
|
862
|
+
inheritProjectContext: step.inheritProjectContext,
|
|
863
|
+
inheritSkills: step.inheritSkills,
|
|
864
|
+
requireReadTool: Boolean(step.skills?.length),
|
|
865
|
+
tools: step.tools,
|
|
866
|
+
extensions: step.extensions,
|
|
867
|
+
subagentOnlyExtensions: step.subagentOnlyExtensions,
|
|
868
|
+
systemPrompt: appendTurnBudgetSystemPrompt(step.systemPrompt ?? "", ctx.turnBudget),
|
|
869
|
+
systemPromptMode: step.systemPromptMode,
|
|
870
|
+
mcpDirectTools: step.mcpDirectTools,
|
|
871
|
+
cwd: step.cwd ?? ctx.cwd,
|
|
872
|
+
promptFileStem: step.agent,
|
|
873
|
+
intercomSessionName: ctx.childIntercomTarget,
|
|
874
|
+
orchestratorIntercomTarget: ctx.orchestratorIntercomTarget,
|
|
875
|
+
runId: ctx.id,
|
|
876
|
+
childAgentName: step.agent,
|
|
877
|
+
childIndex: ctx.flatIndex,
|
|
878
|
+
parentEventSink: ctx.nestedRoute?.eventSink,
|
|
879
|
+
parentControlInbox: ctx.nestedRoute?.controlInbox,
|
|
880
|
+
parentRootRunId: ctx.nestedRoute?.rootRunId,
|
|
881
|
+
parentCapabilityToken: ctx.nestedRoute?.capabilityToken,
|
|
882
|
+
steerInboxDir: ctx.steerInboxDir,
|
|
883
|
+
steerCapabilityPath: ctx.steerCapabilityPath,
|
|
884
|
+
steerAckDir: ctx.steerAckDir,
|
|
885
|
+
structuredOutput: effectiveStructuredOutput,
|
|
886
|
+
toolBudget: step.toolBudget,
|
|
887
|
+
childWatchdog,
|
|
888
|
+
waitToolEnabled: step.waitToolEnabled,
|
|
889
|
+
});
|
|
890
|
+
const run = await runPiStreaming(args, step.cwd ?? ctx.cwd, ctx.outputFile, env, ctx.piPackageRoot, ctx.piArgv1, step.maxSubagentDepth, { eventsPath, runId: ctx.id, stepIndex: ctx.flatIndex, agent: step.agent }, ctx.registerInterrupt, ctx.onChildEvent, transcriptWriter, ctx.registerTimeout, ctx.timeoutMessage, ctx.registerStop, ctx.stopMessage, ctx.registerTurnBudgetAbort, ctx.onWriterProcess);
|
|
891
|
+
if (run.turnBudget)
|
|
892
|
+
turnBudget = run.turnBudget;
|
|
893
|
+
else if (ctx.turnBudget) {
|
|
894
|
+
const assistantMessages = run.messages.filter((message) => message.role === "assistant");
|
|
895
|
+
const turnCount = assistantMessages.length;
|
|
896
|
+
const lastAssistantMessage = assistantMessages.at(-1);
|
|
897
|
+
if (turnCount > 0 && turnCount < ctx.turnBudget.maxTurns) {
|
|
898
|
+
turnBudget = { ...ctx.turnBudget, outcome: "within-budget", turnCount };
|
|
899
|
+
}
|
|
900
|
+
else if (turnCount >= ctx.turnBudget.maxTurns) {
|
|
901
|
+
turnBudget = turnBudgetState(ctx.turnBudget, turnCount, shouldAbortForTurnBudget(ctx.turnBudget, turnCount, lastAssistantMessage ? isTerminalAssistantStop(lastAssistantMessage) : false));
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
const toolAvailabilityError = run.exitCode === 0 && !run.error
|
|
905
|
+
? readChildToolDiagnosticError(toolDiagnosticPath)
|
|
906
|
+
: undefined;
|
|
907
|
+
cleanupTempDir(tempDir);
|
|
908
|
+
const hiddenError = run.exitCode === 0 && !run.error && !toolAvailabilityError ? detectSubagentError(run.messages) : null;
|
|
909
|
+
const missingStructuredOutput = effectiveStructuredOutput
|
|
910
|
+
? !fs.existsSync(effectiveStructuredOutput.outputPath)
|
|
911
|
+
: false;
|
|
912
|
+
const emptyOutputError = run.exitCode === 0 && !run.error && !toolAvailabilityError && !hiddenError?.hasError && !run.finalOutput.trim() && (!effectiveStructuredOutput || missingStructuredOutput)
|
|
913
|
+
? "Subagent produced no output (possible model cold-start or empty response)."
|
|
914
|
+
: undefined;
|
|
915
|
+
let structuredOutput;
|
|
916
|
+
let structuredError;
|
|
917
|
+
if (effectiveStructuredOutput && run.exitCode === 0 && !run.error && !toolAvailabilityError && !hiddenError?.hasError && !emptyOutputError) {
|
|
918
|
+
const structured = readStructuredOutput({
|
|
919
|
+
schema: effectiveStructuredOutput.schema,
|
|
920
|
+
schemaPath: effectiveStructuredOutput.schemaPath,
|
|
921
|
+
outputPath: effectiveStructuredOutput.outputPath,
|
|
922
|
+
});
|
|
923
|
+
if (structured.error)
|
|
924
|
+
structuredError = structured.error;
|
|
925
|
+
else
|
|
926
|
+
structuredOutput = structured.value;
|
|
927
|
+
}
|
|
928
|
+
const completionGuard = run.exitCode === 0 && !run.error && !toolAvailabilityError && !hiddenError?.hasError && !emptyOutputError && step.completionGuard !== false
|
|
929
|
+
? evaluateCompletionMutationGuard({
|
|
930
|
+
agent: step.agent,
|
|
931
|
+
task: taskForCompletionGuard,
|
|
932
|
+
messages: run.messages,
|
|
933
|
+
tools: step.tools,
|
|
934
|
+
mcpDirectTools: step.mcpDirectTools,
|
|
935
|
+
})
|
|
936
|
+
: undefined;
|
|
937
|
+
const completionGuardTriggered = completionGuard?.triggered === true && !run.observedMutationAttempt;
|
|
938
|
+
const completionGuardError = completionGuardTriggered
|
|
939
|
+
? "Subagent completed without making edits for an implementation task.\nIt appears to have returned planning or scratchpad output instead of applying changes."
|
|
940
|
+
: undefined;
|
|
941
|
+
const effectiveExitCode = toolAvailabilityError || completionGuardTriggered || structuredError
|
|
942
|
+
? 1
|
|
943
|
+
: hiddenError?.hasError
|
|
944
|
+
? (hiddenError.exitCode ?? 1)
|
|
945
|
+
: emptyOutputError
|
|
946
|
+
? 1
|
|
947
|
+
: run.error && run.exitCode === 0
|
|
948
|
+
? 1
|
|
949
|
+
: run.exitCode;
|
|
950
|
+
const error = toolAvailabilityError
|
|
951
|
+
?? completionGuardError
|
|
952
|
+
?? structuredError
|
|
953
|
+
?? (hiddenError?.hasError
|
|
954
|
+
? hiddenError.details
|
|
955
|
+
? `${hiddenError.errorType} failed (exit ${effectiveExitCode}): ${hiddenError.details}`
|
|
956
|
+
: `${hiddenError.errorType} failed with exit code ${effectiveExitCode}`
|
|
957
|
+
: emptyOutputError ?? (run.error || (run.exitCode !== 0 && run.stderr.trim() ? run.stderr.trim() : undefined)));
|
|
958
|
+
const attempt = {
|
|
959
|
+
model: candidate ?? run.model ?? step.model ?? "default",
|
|
960
|
+
success: effectiveExitCode === 0 && !error,
|
|
961
|
+
exitCode: effectiveExitCode,
|
|
962
|
+
error,
|
|
963
|
+
usage: run.usage,
|
|
964
|
+
};
|
|
965
|
+
modelAttempts.push(attempt);
|
|
966
|
+
if (candidate)
|
|
967
|
+
attemptedModels.push(candidate);
|
|
968
|
+
completionGuardTriggeredFinal = completionGuardTriggered;
|
|
969
|
+
finalOutputSnapshot = outputSnapshot;
|
|
970
|
+
if (step.toolBudget) {
|
|
971
|
+
const toolMessages = run.messages.filter((message) => message.role === "toolResult");
|
|
972
|
+
const blockedMessage = toolMessages.find((message) => extractTextFromContent(message.content).includes("Tool budget hard limit reached"));
|
|
973
|
+
toolBudgetBlocked = Boolean(blockedMessage);
|
|
974
|
+
toolBudget = toolBudgetState(step.toolBudget, toolMessages.length, blockedMessage ? blockedMessage.toolName : undefined);
|
|
975
|
+
}
|
|
976
|
+
finalResult = { ...run, exitCode: effectiveExitCode, model: candidate ?? run.model, error, structuredOutput };
|
|
977
|
+
if (run.turnBudgetExceeded)
|
|
978
|
+
break;
|
|
979
|
+
if (run.stopped || run.timedOut || ctx.timeoutSignal?.aborted || ctx.stopSignal?.aborted || ctx.skipAcceptance?.())
|
|
980
|
+
break;
|
|
981
|
+
if (attempt.success || completionGuardTriggered)
|
|
982
|
+
break;
|
|
983
|
+
if (!isRetryableModelFailure(error) || index === candidates.length - 1)
|
|
984
|
+
break;
|
|
985
|
+
attemptNotes.push(formatModelAttemptNote(attempt, candidates[index + 1]));
|
|
986
|
+
}
|
|
987
|
+
const rawOutput = finalResult?.finalOutput ?? "";
|
|
988
|
+
const outputForPersistence = stripAcceptanceReport(rawOutput);
|
|
989
|
+
const resolvedOutput = step.outputPath && finalResult?.exitCode === 0
|
|
990
|
+
? resolveSingleOutput(step.outputPath, outputForPersistence, finalOutputSnapshot)
|
|
991
|
+
: { fullOutput: outputForPersistence };
|
|
992
|
+
const output = stripAcceptanceReport(resolvedOutput.fullOutput);
|
|
993
|
+
const outputReference = resolvedOutput.savedPath ? formatSavedOutputReference(resolvedOutput.savedPath, output) : undefined;
|
|
994
|
+
let outputForSummary = output;
|
|
995
|
+
if (attemptNotes.length > 0) {
|
|
996
|
+
outputForSummary = `${attemptNotes.join("\n")}\n\n${outputForSummary}`.trim();
|
|
997
|
+
}
|
|
998
|
+
if (finalResult?.stopped && !outputForSummary.trim()) {
|
|
999
|
+
outputForSummary = ctx.stopMessage ?? "Subagent stopped by user.";
|
|
1000
|
+
}
|
|
1001
|
+
else if (!finalResult?.timedOut && !finalResult?.stopped && finalResult?.turnBudgetExceeded && turnBudget) {
|
|
1002
|
+
outputForSummary = formatTurnBudgetOutput(turnBudgetExceededMessage(turnBudget, turnBudget.turnCount), outputForSummary);
|
|
1003
|
+
}
|
|
1004
|
+
else if (!finalResult?.timedOut && !finalResult?.stopped && turnBudget?.outcome === "wrap-up-requested") {
|
|
1005
|
+
const note = turnBudgetSoftNote(turnBudget, turnBudget.wrapUpRequestedAtTurn ?? turnBudget.turnCount);
|
|
1006
|
+
outputForSummary = outputForSummary.trim() ? `${note}\n\n${outputForSummary}` : note;
|
|
1007
|
+
}
|
|
1008
|
+
const outputForAcceptance = rawOutput;
|
|
1009
|
+
const childWrittenOutput = step.outputPath
|
|
1010
|
+
? extractChildWrittenOutput(finalResult?.messages, step.outputPath, step.cwd ?? ctx.cwd)
|
|
1011
|
+
: undefined;
|
|
1012
|
+
const finalizedOutput = finalizeSingleOutput({
|
|
1013
|
+
fullOutput: outputForSummary,
|
|
1014
|
+
outputPath: step.outputPath,
|
|
1015
|
+
outputMode: step.outputMode,
|
|
1016
|
+
exitCode: finalResult?.exitCode ?? 1,
|
|
1017
|
+
savedPath: resolvedOutput.savedPath,
|
|
1018
|
+
outputReference,
|
|
1019
|
+
saveError: resolvedOutput.saveError,
|
|
1020
|
+
});
|
|
1021
|
+
outputForSummary = finalizedOutput.displayOutput;
|
|
1022
|
+
const acceptance = step.effectiveAcceptance && !finalResult?.stopped && !finalResult?.turnBudgetExceeded && !ctx.timeoutSignal?.aborted && !ctx.stopSignal?.aborted && !ctx.skipAcceptance?.()
|
|
1023
|
+
? await evaluateAcceptance({
|
|
1024
|
+
acceptance: step.effectiveAcceptance,
|
|
1025
|
+
output: outputForAcceptance,
|
|
1026
|
+
fileOutput: childWrittenOutput !== undefined && step.outputPath
|
|
1027
|
+
? { content: childWrittenOutput, path: step.outputPath, authoritative: step.outputMode === "file-only" }
|
|
1028
|
+
: undefined,
|
|
1029
|
+
cwd: step.cwd ?? ctx.cwd,
|
|
1030
|
+
signal: combinedAbortSignal([ctx.timeoutSignal, ctx.stopSignal]),
|
|
1031
|
+
abortMessage: ctx.stopSignal?.aborted ? ctx.stopMessage ?? "Subagent stopped by user." : ctx.timeoutMessage ?? "Subagent timed out.",
|
|
1032
|
+
})
|
|
1033
|
+
: undefined;
|
|
1034
|
+
const stoppedAfterAcceptance = finalResult?.stopped === true || ctx.stopSignal?.aborted === true;
|
|
1035
|
+
const timedOutAfterAcceptance = !stoppedAfterAcceptance && (finalResult?.timedOut === true || ctx.timeoutSignal?.aborted === true);
|
|
1036
|
+
const turnBudgetExceeded = finalResult?.turnBudgetExceeded === true;
|
|
1037
|
+
const effectiveAcceptance = step.effectiveAcceptance
|
|
1038
|
+
? stoppedAfterAcceptance
|
|
1039
|
+
? buildSkippedAcceptanceLedger(step.effectiveAcceptance, { id: "stopped", message: "Acceptance was not evaluated because the subagent was stopped." })
|
|
1040
|
+
: timedOutAfterAcceptance
|
|
1041
|
+
? buildSkippedAcceptanceLedger(step.effectiveAcceptance, { id: "timeout", message: "Acceptance was not evaluated because the subagent timed out." })
|
|
1042
|
+
: turnBudgetExceeded
|
|
1043
|
+
? buildSkippedAcceptanceLedger(step.effectiveAcceptance, { id: "turn-budget", message: "Acceptance was not evaluated because the subagent exceeded its turn budget." })
|
|
1044
|
+
: acceptance
|
|
1045
|
+
: undefined;
|
|
1046
|
+
const acceptanceFailure = effectiveAcceptance ? acceptanceFailureMessage(effectiveAcceptance) : undefined;
|
|
1047
|
+
const acceptanceCanFailRun = acceptanceFailure && effectiveAcceptance?.explicit && (finalResult?.exitCode ?? 1) === 0 && !finalResult?.interrupted && !timedOutAfterAcceptance && !stoppedAfterAcceptance && !turnBudgetExceeded;
|
|
1048
|
+
const effectiveFinalExitCode = timedOutAfterAcceptance || stoppedAfterAcceptance || turnBudgetExceeded ? 1 : acceptanceCanFailRun ? 1 : finalResult?.exitCode ?? 1;
|
|
1049
|
+
const effectiveFinalError = stoppedAfterAcceptance
|
|
1050
|
+
? ctx.stopMessage ?? "Subagent stopped by user."
|
|
1051
|
+
: timedOutAfterAcceptance
|
|
1052
|
+
? ctx.timeoutMessage ?? "Subagent timed out."
|
|
1053
|
+
: turnBudgetExceeded
|
|
1054
|
+
? finalResult?.error ?? (turnBudget ? turnBudgetExceededMessage(turnBudget, turnBudget.turnCount) : "Subagent exceeded turn budget.")
|
|
1055
|
+
: acceptanceCanFailRun
|
|
1056
|
+
? (finalResult?.error ? `${finalResult.error}\n${acceptanceFailure}` : acceptanceFailure)
|
|
1057
|
+
: finalResult?.error;
|
|
1058
|
+
if (artifactPaths && ctx.artifactConfig?.enabled !== false) {
|
|
1059
|
+
if (ctx.artifactConfig?.includeOutput !== false) {
|
|
1060
|
+
fs.writeFileSync(artifactPaths.outputPath, output, "utf-8");
|
|
1061
|
+
}
|
|
1062
|
+
if (ctx.artifactConfig?.includeMetadata !== false) {
|
|
1063
|
+
fs.writeFileSync(artifactPaths.metadataPath, JSON.stringify({
|
|
1064
|
+
runId: ctx.id,
|
|
1065
|
+
agent: step.agent,
|
|
1066
|
+
task,
|
|
1067
|
+
exitCode: effectiveFinalExitCode,
|
|
1068
|
+
model: finalResult?.model,
|
|
1069
|
+
attemptedModels: attemptedModels.length > 0 ? attemptedModels : undefined,
|
|
1070
|
+
modelAttempts,
|
|
1071
|
+
error: effectiveFinalError,
|
|
1072
|
+
acceptance: effectiveAcceptance,
|
|
1073
|
+
...(transcriptWriter ? { transcriptPath: artifactPaths.transcriptPath } : {}),
|
|
1074
|
+
transcriptError: transcriptWriter?.getError(),
|
|
1075
|
+
skills: step.skills,
|
|
1076
|
+
timestamp: Date.now(),
|
|
1077
|
+
}, null, 2), "utf-8");
|
|
1078
|
+
}
|
|
1079
|
+
}
|
|
1080
|
+
return {
|
|
1081
|
+
agent: step.agent,
|
|
1082
|
+
output: outputForSummary,
|
|
1083
|
+
exitCode: effectiveFinalExitCode,
|
|
1084
|
+
error: effectiveFinalError,
|
|
1085
|
+
protocolError: finalResult?.protocolError,
|
|
1086
|
+
sessionFile: step.sessionFile,
|
|
1087
|
+
intercomTarget: ctx.childIntercomTarget,
|
|
1088
|
+
model: finalResult?.model,
|
|
1089
|
+
attemptedModels: attemptedModels.length > 0 ? attemptedModels : undefined,
|
|
1090
|
+
modelAttempts,
|
|
1091
|
+
totalCost: costSummaryFromAttempts(modelAttempts),
|
|
1092
|
+
artifactPaths,
|
|
1093
|
+
transcriptPath: transcriptWriter ? artifactPaths?.transcriptPath : undefined,
|
|
1094
|
+
transcriptError: transcriptWriter?.getError(),
|
|
1095
|
+
interrupted: timedOutAfterAcceptance || stoppedAfterAcceptance || turnBudgetExceeded ? false : finalResult?.interrupted,
|
|
1096
|
+
timedOut: timedOutAfterAcceptance ? true : finalResult?.timedOut,
|
|
1097
|
+
stopped: stoppedAfterAcceptance ? true : finalResult?.stopped,
|
|
1098
|
+
turnBudget,
|
|
1099
|
+
turnBudgetExceeded: turnBudgetExceeded || undefined,
|
|
1100
|
+
wrapUpRequested: finalResult?.wrapUpRequested || turnBudget?.outcome === "wrap-up-requested" || turnBudgetExceeded || undefined,
|
|
1101
|
+
toolBudget,
|
|
1102
|
+
toolBudgetBlocked: toolBudgetBlocked || undefined,
|
|
1103
|
+
completionGuardTriggered: completionGuardTriggeredFinal,
|
|
1104
|
+
structuredOutput: timedOutAfterAcceptance || stoppedAfterAcceptance || turnBudgetExceeded ? undefined : finalResult?.structuredOutput,
|
|
1105
|
+
structuredOutputPath: timedOutAfterAcceptance || stoppedAfterAcceptance || turnBudgetExceeded ? undefined : effectiveStructuredOutput?.outputPath,
|
|
1106
|
+
structuredOutputSchemaPath: timedOutAfterAcceptance || stoppedAfterAcceptance || turnBudgetExceeded ? undefined : effectiveStructuredOutput?.schemaPath,
|
|
1107
|
+
acceptance: effectiveAcceptance,
|
|
1108
|
+
watchdog: finalResult?.watchdog,
|
|
1109
|
+
};
|
|
1110
|
+
}
|
|
1111
|
+
function markParallelGroupSetupFailure(input) {
|
|
1112
|
+
for (let taskIndex = 0; taskIndex < input.group.parallel.length; taskIndex++) {
|
|
1113
|
+
const flatTaskIndex = input.groupStartFlatIndex + taskIndex;
|
|
1114
|
+
input.statusPayload.steps[flatTaskIndex].status = "failed";
|
|
1115
|
+
input.statusPayload.steps[flatTaskIndex].startedAt = input.failedAt;
|
|
1116
|
+
input.statusPayload.steps[flatTaskIndex].endedAt = input.failedAt;
|
|
1117
|
+
input.statusPayload.steps[flatTaskIndex].durationMs = 0;
|
|
1118
|
+
input.statusPayload.steps[flatTaskIndex].exitCode = 1;
|
|
1119
|
+
input.results.push({ agent: input.group.parallel[taskIndex].agent, output: input.setupError, success: false, exitCode: 1, sessionFile: input.group.parallel[taskIndex].sessionFile });
|
|
1120
|
+
}
|
|
1121
|
+
input.statusPayload.currentStep = input.groupStartFlatIndex;
|
|
1122
|
+
input.statusPayload.lastUpdate = input.failedAt;
|
|
1123
|
+
input.statusPayload.outputFile = path.join(input.asyncDir, `output-${input.groupStartFlatIndex}.log`);
|
|
1124
|
+
writeAtomicJson(input.statusPath, input.statusPayload);
|
|
1125
|
+
appendJsonl(input.eventsPath, JSON.stringify({
|
|
1126
|
+
type: "subagent.parallel.completed",
|
|
1127
|
+
ts: input.failedAt,
|
|
1128
|
+
runId: input.runId,
|
|
1129
|
+
stepIndex: input.stepIndex,
|
|
1130
|
+
success: false,
|
|
1131
|
+
}));
|
|
1132
|
+
}
|
|
1133
|
+
function markParallelGroupRunning(input) {
|
|
1134
|
+
for (let taskIndex = 0; taskIndex < input.group.parallel.length; taskIndex++) {
|
|
1135
|
+
const flatTaskIndex = input.groupStartFlatIndex + taskIndex;
|
|
1136
|
+
input.statusPayload.steps[flatTaskIndex].status = "pending";
|
|
1137
|
+
input.statusPayload.steps[flatTaskIndex].startedAt = undefined;
|
|
1138
|
+
input.statusPayload.steps[flatTaskIndex].endedAt = undefined;
|
|
1139
|
+
input.statusPayload.steps[flatTaskIndex].durationMs = undefined;
|
|
1140
|
+
input.statusPayload.steps[flatTaskIndex].lastActivityAt = undefined;
|
|
1141
|
+
input.statusPayload.steps[flatTaskIndex].activityState = undefined;
|
|
1142
|
+
input.statusPayload.steps[flatTaskIndex].error = undefined;
|
|
1143
|
+
}
|
|
1144
|
+
input.statusPayload.currentStep = input.groupStartFlatIndex;
|
|
1145
|
+
input.statusPayload.activityState = undefined;
|
|
1146
|
+
input.statusPayload.lastActivityAt = input.groupStartTime;
|
|
1147
|
+
input.statusPayload.lastUpdate = input.groupStartTime;
|
|
1148
|
+
input.statusPayload.outputFile = path.join(input.asyncDir, `output-${input.groupStartFlatIndex}.log`);
|
|
1149
|
+
writeAtomicJson(input.statusPath, input.statusPayload);
|
|
1150
|
+
appendJsonl(input.eventsPath, JSON.stringify({
|
|
1151
|
+
type: "subagent.parallel.started",
|
|
1152
|
+
ts: input.groupStartTime,
|
|
1153
|
+
runId: input.runId,
|
|
1154
|
+
stepIndex: input.stepIndex,
|
|
1155
|
+
agents: input.group.parallel.map((task) => task.agent),
|
|
1156
|
+
count: input.group.parallel.length,
|
|
1157
|
+
}));
|
|
1158
|
+
}
|
|
1159
|
+
function prepareParallelTaskRun(task, cwd, worktreeSetup, taskIndex) {
|
|
1160
|
+
if (!worktreeSetup)
|
|
1161
|
+
return { taskForRun: task, taskCwd: cwd };
|
|
1162
|
+
return {
|
|
1163
|
+
taskForRun: { ...task, cwd: undefined },
|
|
1164
|
+
taskCwd: worktreeSetup.worktrees[taskIndex].agentCwd,
|
|
1165
|
+
};
|
|
1166
|
+
}
|
|
1167
|
+
function appendParallelWorktreeSummary(previousOutput, worktreeSetup, asyncDir, stepIndex, group) {
|
|
1168
|
+
if (!worktreeSetup)
|
|
1169
|
+
return previousOutput;
|
|
1170
|
+
const diffsDir = path.join(asyncDir, "worktree-diffs", `step-${stepIndex}`);
|
|
1171
|
+
const diffs = diffWorktrees(worktreeSetup, group.parallel.map((task) => task.agent), diffsDir);
|
|
1172
|
+
const diffSummary = formatWorktreeDiffSummary(diffs);
|
|
1173
|
+
if (!diffSummary)
|
|
1174
|
+
return previousOutput;
|
|
1175
|
+
return `${previousOutput}\n\n${diffSummary}`;
|
|
1176
|
+
}
|
|
1177
|
+
function ensureParallelProgressFile(cwd, group) {
|
|
1178
|
+
const progressPath = path.join(cwd, "progress.md");
|
|
1179
|
+
if (!group.parallel.some((task) => task.task.includes(`Update progress at: ${progressPath}`)))
|
|
1180
|
+
return;
|
|
1181
|
+
writeInitialProgressFile(cwd);
|
|
1182
|
+
}
|
|
1183
|
+
function resolveAsyncStepTranscriptPath(input) {
|
|
1184
|
+
if (!input.artifactsDir || input.artifactConfig?.enabled === false || input.artifactConfig?.includeTranscript === false)
|
|
1185
|
+
return undefined;
|
|
1186
|
+
return getArtifactPaths(input.artifactsDir, input.runId, input.agent, input.flatStepCount > 1 ? input.flatIndex : undefined).transcriptPath;
|
|
1187
|
+
}
|
|
1188
|
+
function combinedAbortSignal(signals) {
|
|
1189
|
+
const activeSignals = signals.filter((signal) => Boolean(signal));
|
|
1190
|
+
if (activeSignals.length === 0)
|
|
1191
|
+
return undefined;
|
|
1192
|
+
if (activeSignals.length === 1)
|
|
1193
|
+
return activeSignals[0];
|
|
1194
|
+
const controller = new AbortController();
|
|
1195
|
+
const abort = () => controller.abort();
|
|
1196
|
+
for (const signal of activeSignals) {
|
|
1197
|
+
if (signal.aborted) {
|
|
1198
|
+
abort();
|
|
1199
|
+
break;
|
|
1200
|
+
}
|
|
1201
|
+
signal.addEventListener("abort", abort, { once: true });
|
|
1202
|
+
}
|
|
1203
|
+
return controller.signal;
|
|
1204
|
+
}
|
|
1205
|
+
async function runSubagent(config, onWriterProcess) {
|
|
1206
|
+
const { id, steps, resultPath, cwd, placeholder, taskIndex, totalTasks, maxOutput, artifactsDir, artifactConfig } = config;
|
|
1207
|
+
const globalSemaphore = new Semaphore(config.globalConcurrencyLimit ?? DEFAULT_GLOBAL_CONCURRENCY_LIMIT);
|
|
1208
|
+
let previousOutput = "";
|
|
1209
|
+
const outputs = {};
|
|
1210
|
+
const results = [];
|
|
1211
|
+
const overallStartTime = Date.now();
|
|
1212
|
+
const shareEnabled = config.share === true;
|
|
1213
|
+
const asyncDir = config.asyncDir;
|
|
1214
|
+
const statusPath = path.join(asyncDir, "status.json");
|
|
1215
|
+
const eventsPath = path.join(asyncDir, "events.jsonl");
|
|
1216
|
+
const logPath = path.join(asyncDir, `subagent-log-${id}.md`);
|
|
1217
|
+
const controlConfig = config.controlConfig ?? DEFAULT_CONTROL_CONFIG;
|
|
1218
|
+
const activeChildInterrupts = new Map();
|
|
1219
|
+
const activeChildTimeouts = new Map();
|
|
1220
|
+
const activeChildStops = new Map();
|
|
1221
|
+
const activeChildTurnBudgetAborts = new Map();
|
|
1222
|
+
const pendingStepSteers = [];
|
|
1223
|
+
const steeringCapabilities = new Map();
|
|
1224
|
+
let interrupted = false;
|
|
1225
|
+
let currentActivityState;
|
|
1226
|
+
let activityTimer;
|
|
1227
|
+
let timeoutTimer;
|
|
1228
|
+
let timedOut = false;
|
|
1229
|
+
let stopped = false;
|
|
1230
|
+
let turnBudgetExceeded = false;
|
|
1231
|
+
const timeoutMessage = config.timeoutMs !== undefined ? `Subagent timed out after ${config.timeoutMs}ms.` : undefined;
|
|
1232
|
+
const stopMessage = "Subagent stopped by user.";
|
|
1233
|
+
const timeoutAbortController = new AbortController();
|
|
1234
|
+
const stopAbortController = new AbortController();
|
|
1235
|
+
let previousCumulativeTokens = { input: 0, output: 0, total: 0 };
|
|
1236
|
+
let latestSessionFile;
|
|
1237
|
+
const flatSteps = flattenSteps(steps);
|
|
1238
|
+
const initialFlatStepCount = flatSteps.length;
|
|
1239
|
+
const parallelGroups = [];
|
|
1240
|
+
const initialStatusSteps = [];
|
|
1241
|
+
let flatStepCount = 0;
|
|
1242
|
+
for (let stepIndex = 0; stepIndex < steps.length; stepIndex++) {
|
|
1243
|
+
const step = steps[stepIndex];
|
|
1244
|
+
if (isParallelGroup(step)) {
|
|
1245
|
+
parallelGroups.push({ start: flatStepCount, count: step.parallel.length, stepIndex });
|
|
1246
|
+
for (const task of step.parallel) {
|
|
1247
|
+
const taskFlatIndex = flatStepCount;
|
|
1248
|
+
const transcriptPath = resolveAsyncStepTranscriptPath({ artifactsDir, artifactConfig, runId: id, agent: task.agent, flatIndex: taskFlatIndex, flatStepCount: initialFlatStepCount });
|
|
1249
|
+
initialStatusSteps.push({
|
|
1250
|
+
agent: task.agent,
|
|
1251
|
+
phase: task.phase,
|
|
1252
|
+
label: task.label,
|
|
1253
|
+
outputName: task.outputName,
|
|
1254
|
+
structured: task.structured,
|
|
1255
|
+
status: "pending",
|
|
1256
|
+
...(task.toolBudget ? { toolBudget: initialToolBudgetState(task.toolBudget) } : {}),
|
|
1257
|
+
...(task.sessionFile ? { sessionFile: task.sessionFile } : {}),
|
|
1258
|
+
...(transcriptPath ? { transcriptPath } : {}),
|
|
1259
|
+
skills: task.skills,
|
|
1260
|
+
model: task.model,
|
|
1261
|
+
thinking: task.thinking,
|
|
1262
|
+
attemptedModels: task.modelCandidates && task.modelCandidates.length > 0 ? task.modelCandidates : task.model ? [task.model] : undefined,
|
|
1263
|
+
recentTools: [],
|
|
1264
|
+
recentOutput: [],
|
|
1265
|
+
});
|
|
1266
|
+
flatStepCount++;
|
|
1267
|
+
}
|
|
1268
|
+
}
|
|
1269
|
+
else if (isDynamicRunnerGroup(step)) {
|
|
1270
|
+
parallelGroups.push({ start: flatStepCount, count: 1, stepIndex });
|
|
1271
|
+
initialStatusSteps.push({
|
|
1272
|
+
agent: `expand:${step.parallel.agent}`,
|
|
1273
|
+
phase: step.phase ?? step.parallel.phase,
|
|
1274
|
+
label: step.label ?? step.parallel.label ?? `Dynamic fanout (${step.collect.as})`,
|
|
1275
|
+
outputName: step.collect.as,
|
|
1276
|
+
structured: Boolean(step.collect.outputSchema),
|
|
1277
|
+
status: "pending",
|
|
1278
|
+
...(step.parallel.toolBudget ? { toolBudget: initialToolBudgetState(step.parallel.toolBudget) } : {}),
|
|
1279
|
+
recentTools: [],
|
|
1280
|
+
recentOutput: [],
|
|
1281
|
+
});
|
|
1282
|
+
flatStepCount++;
|
|
1283
|
+
}
|
|
1284
|
+
else {
|
|
1285
|
+
const stepFlatIndex = flatStepCount;
|
|
1286
|
+
const transcriptPath = resolveAsyncStepTranscriptPath({ artifactsDir, artifactConfig, runId: id, agent: step.agent, flatIndex: stepFlatIndex, flatStepCount: initialFlatStepCount });
|
|
1287
|
+
initialStatusSteps.push({
|
|
1288
|
+
agent: step.agent,
|
|
1289
|
+
phase: step.phase,
|
|
1290
|
+
label: step.label,
|
|
1291
|
+
outputName: step.outputName,
|
|
1292
|
+
structured: step.structured,
|
|
1293
|
+
status: "pending",
|
|
1294
|
+
...(step.toolBudget ? { toolBudget: initialToolBudgetState(step.toolBudget) } : {}),
|
|
1295
|
+
...(step.sessionFile ? { sessionFile: step.sessionFile } : {}),
|
|
1296
|
+
...(transcriptPath ? { transcriptPath } : {}),
|
|
1297
|
+
skills: step.skills,
|
|
1298
|
+
model: step.model,
|
|
1299
|
+
thinking: step.thinking,
|
|
1300
|
+
attemptedModels: step.modelCandidates && step.modelCandidates.length > 0 ? step.modelCandidates : step.model ? [step.model] : undefined,
|
|
1301
|
+
recentTools: [],
|
|
1302
|
+
recentOutput: [],
|
|
1303
|
+
});
|
|
1304
|
+
flatStepCount++;
|
|
1305
|
+
}
|
|
1306
|
+
}
|
|
1307
|
+
const sessionEnabled = Boolean(config.sessionDir)
|
|
1308
|
+
|| shareEnabled
|
|
1309
|
+
|| flatSteps.some((step) => Boolean(step.sessionFile));
|
|
1310
|
+
const statusPayload = {
|
|
1311
|
+
lifecycleArtifactVersion: SUBAGENT_LIFECYCLE_ARTIFACT_VERSION,
|
|
1312
|
+
runId: id,
|
|
1313
|
+
...(config.sessionId ? { sessionId: config.sessionId } : {}),
|
|
1314
|
+
mode: config.resultMode ?? (flatSteps.length > 1 ? "chain" : "single"),
|
|
1315
|
+
...(config.nestedRoute ? { isNested: true } : {}),
|
|
1316
|
+
state: "running",
|
|
1317
|
+
steering: createSteeringStatus(),
|
|
1318
|
+
lastActivityAt: overallStartTime,
|
|
1319
|
+
startedAt: overallStartTime,
|
|
1320
|
+
lastUpdate: overallStartTime,
|
|
1321
|
+
...(config.timeoutMs !== undefined ? { timeoutMs: config.timeoutMs } : {}),
|
|
1322
|
+
...(config.deadlineAt !== undefined ? { deadlineAt: config.deadlineAt } : {}),
|
|
1323
|
+
...(config.turnBudget ? { turnBudget: initialTurnBudgetState(config.turnBudget) } : {}),
|
|
1324
|
+
...(config.toolBudget ? { toolBudget: initialToolBudgetState(config.toolBudget) } : {}),
|
|
1325
|
+
pid: process.pid,
|
|
1326
|
+
cwd,
|
|
1327
|
+
currentStep: 0,
|
|
1328
|
+
chainStepCount: steps.length,
|
|
1329
|
+
parallelGroups,
|
|
1330
|
+
workflowGraph: config.workflowGraph,
|
|
1331
|
+
steps: initialStatusSteps,
|
|
1332
|
+
artifactsDir,
|
|
1333
|
+
sessionDir: config.sessionDir,
|
|
1334
|
+
outputFile: path.join(asyncDir, "output-0.log"),
|
|
1335
|
+
};
|
|
1336
|
+
fs.mkdirSync(asyncDir, { recursive: true });
|
|
1337
|
+
writeAtomicJson(statusPath, statusPayload);
|
|
1338
|
+
const emitNestedSelfEvent = (type) => {
|
|
1339
|
+
if (!config.nestedRoute || !config.nestedSelf)
|
|
1340
|
+
return;
|
|
1341
|
+
try {
|
|
1342
|
+
writeNestedEvent(config.nestedRoute, {
|
|
1343
|
+
type,
|
|
1344
|
+
ts: Date.now(),
|
|
1345
|
+
parentRunId: config.nestedSelf.parentRunId,
|
|
1346
|
+
parentStepIndex: config.nestedSelf.parentStepIndex,
|
|
1347
|
+
child: nestedSummaryFromAsyncStatus(statusPayload, asyncDir, {
|
|
1348
|
+
id,
|
|
1349
|
+
parentRunId: config.nestedSelf.parentRunId,
|
|
1350
|
+
parentStepIndex: config.nestedSelf.parentStepIndex,
|
|
1351
|
+
depth: config.nestedSelf.depth,
|
|
1352
|
+
path: config.nestedSelf.path,
|
|
1353
|
+
mode: statusPayload.mode,
|
|
1354
|
+
ts: Date.now(),
|
|
1355
|
+
}),
|
|
1356
|
+
});
|
|
1357
|
+
}
|
|
1358
|
+
catch (error) {
|
|
1359
|
+
console.error("Failed to emit nested async status event:", error);
|
|
1360
|
+
}
|
|
1361
|
+
};
|
|
1362
|
+
const refreshWorkflowGraph = () => {
|
|
1363
|
+
if (!config.workflowGraph)
|
|
1364
|
+
return;
|
|
1365
|
+
const graph = structuredClone(statusPayload.workflowGraph ?? config.workflowGraph);
|
|
1366
|
+
const normalize = (status) => {
|
|
1367
|
+
if (status === "complete" || status === "completed")
|
|
1368
|
+
return "completed";
|
|
1369
|
+
if (status === "running" || status === "failed" || status === "paused" || status === "stopped" || status === "pending")
|
|
1370
|
+
return status;
|
|
1371
|
+
return "pending";
|
|
1372
|
+
};
|
|
1373
|
+
const updateNode = (node) => {
|
|
1374
|
+
if (node.flatIndex !== undefined) {
|
|
1375
|
+
const step = statusPayload.steps[node.flatIndex];
|
|
1376
|
+
if (step) {
|
|
1377
|
+
node.status = normalize(step.status);
|
|
1378
|
+
node.error = step.error;
|
|
1379
|
+
node.acceptanceStatus = step.acceptance?.status;
|
|
1380
|
+
}
|
|
1381
|
+
if (statusPayload.currentStep === node.flatIndex)
|
|
1382
|
+
graph.currentNodeId = node.id;
|
|
1383
|
+
}
|
|
1384
|
+
for (const child of node.children ?? [])
|
|
1385
|
+
updateNode(child);
|
|
1386
|
+
if (node.children?.length) {
|
|
1387
|
+
if (node.children.every((child) => child.status === "completed"))
|
|
1388
|
+
node.status = "completed";
|
|
1389
|
+
else if (node.children.some((child) => child.status === "running"))
|
|
1390
|
+
node.status = "running";
|
|
1391
|
+
else if (node.children.some((child) => child.status === "stopped"))
|
|
1392
|
+
node.status = "stopped";
|
|
1393
|
+
else if (node.children.some((child) => child.status === "failed"))
|
|
1394
|
+
node.status = "failed";
|
|
1395
|
+
else if (node.children.some((child) => child.status === "paused"))
|
|
1396
|
+
node.status = "paused";
|
|
1397
|
+
}
|
|
1398
|
+
if (node.error && node.status !== "stopped")
|
|
1399
|
+
node.status = "failed";
|
|
1400
|
+
};
|
|
1401
|
+
for (const node of graph.nodes)
|
|
1402
|
+
updateNode(node);
|
|
1403
|
+
statusPayload.workflowGraph = graph;
|
|
1404
|
+
};
|
|
1405
|
+
const writeStatusPayload = () => {
|
|
1406
|
+
refreshWorkflowGraph();
|
|
1407
|
+
writeAtomicJson(statusPath, statusPayload);
|
|
1408
|
+
emitNestedSelfEvent(statusPayload.state === "running" || statusPayload.state === "queued" ? "subagent.nested.updated" : "subagent.nested.completed");
|
|
1409
|
+
};
|
|
1410
|
+
const registerStepInterrupt = (flatIndex, interrupt) => {
|
|
1411
|
+
if (!interrupt) {
|
|
1412
|
+
activeChildInterrupts.delete(flatIndex);
|
|
1413
|
+
return;
|
|
1414
|
+
}
|
|
1415
|
+
activeChildInterrupts.set(flatIndex, interrupt);
|
|
1416
|
+
if (interrupted)
|
|
1417
|
+
interrupt();
|
|
1418
|
+
};
|
|
1419
|
+
const registerStepTimeout = (flatIndex, interrupt) => {
|
|
1420
|
+
if (!interrupt) {
|
|
1421
|
+
activeChildTimeouts.delete(flatIndex);
|
|
1422
|
+
return;
|
|
1423
|
+
}
|
|
1424
|
+
activeChildTimeouts.set(flatIndex, interrupt);
|
|
1425
|
+
if (timedOut)
|
|
1426
|
+
interrupt();
|
|
1427
|
+
};
|
|
1428
|
+
const registerStepStop = (flatIndex, stop) => {
|
|
1429
|
+
if (!stop) {
|
|
1430
|
+
activeChildStops.delete(flatIndex);
|
|
1431
|
+
return;
|
|
1432
|
+
}
|
|
1433
|
+
activeChildStops.set(flatIndex, stop);
|
|
1434
|
+
if (stopped)
|
|
1435
|
+
stop();
|
|
1436
|
+
};
|
|
1437
|
+
const registerStepTurnBudgetAbort = (flatIndex, abort) => {
|
|
1438
|
+
if (!abort) {
|
|
1439
|
+
activeChildTurnBudgetAborts.delete(flatIndex);
|
|
1440
|
+
return;
|
|
1441
|
+
}
|
|
1442
|
+
activeChildTurnBudgetAborts.set(flatIndex, abort);
|
|
1443
|
+
};
|
|
1444
|
+
const interruptActiveChildren = () => {
|
|
1445
|
+
for (const interrupt of [...activeChildInterrupts.values()])
|
|
1446
|
+
interrupt();
|
|
1447
|
+
};
|
|
1448
|
+
const timeoutActiveChildren = () => {
|
|
1449
|
+
for (const interrupt of [...activeChildTimeouts.values()])
|
|
1450
|
+
interrupt();
|
|
1451
|
+
};
|
|
1452
|
+
const stopActiveChildren = () => {
|
|
1453
|
+
for (const stop of [...activeChildStops.values()])
|
|
1454
|
+
stop();
|
|
1455
|
+
};
|
|
1456
|
+
const nestedRuns = function* (children) {
|
|
1457
|
+
for (const child of children ?? []) {
|
|
1458
|
+
yield child;
|
|
1459
|
+
yield* nestedRuns(child.children);
|
|
1460
|
+
yield* nestedRuns(child.steps?.flatMap((step) => step.children ?? []));
|
|
1461
|
+
}
|
|
1462
|
+
};
|
|
1463
|
+
const interruptNestedAsyncDescendants = () => {
|
|
1464
|
+
if (!config.nestedRoute)
|
|
1465
|
+
return;
|
|
1466
|
+
let registry;
|
|
1467
|
+
try {
|
|
1468
|
+
registry = projectNestedEvents(config.nestedRoute);
|
|
1469
|
+
}
|
|
1470
|
+
catch (error) {
|
|
1471
|
+
appendJsonl(eventsPath, JSON.stringify({
|
|
1472
|
+
type: "subagent.nested.interrupt_failed",
|
|
1473
|
+
ts: Date.now(),
|
|
1474
|
+
runId: id,
|
|
1475
|
+
message: error instanceof Error ? error.message : String(error),
|
|
1476
|
+
}));
|
|
1477
|
+
return;
|
|
1478
|
+
}
|
|
1479
|
+
for (const run of nestedRuns(registry.children)) {
|
|
1480
|
+
if (run.state !== "running" && run.state !== "queued")
|
|
1481
|
+
continue;
|
|
1482
|
+
const nestedAsyncDir = run.asyncDir ?? resolveNestedAsyncDir(config.nestedRoute.rootRunId, run);
|
|
1483
|
+
if (!nestedAsyncDir)
|
|
1484
|
+
continue;
|
|
1485
|
+
try {
|
|
1486
|
+
deliverInterruptRequest({ asyncDir: nestedAsyncDir, pid: run.pid, source: "ancestor-interrupt" });
|
|
1487
|
+
}
|
|
1488
|
+
catch (error) {
|
|
1489
|
+
appendJsonl(eventsPath, JSON.stringify({
|
|
1490
|
+
type: "subagent.nested.interrupt_failed",
|
|
1491
|
+
ts: Date.now(),
|
|
1492
|
+
runId: id,
|
|
1493
|
+
targetRunId: run.id,
|
|
1494
|
+
message: error instanceof Error ? error.message : String(error),
|
|
1495
|
+
}));
|
|
1496
|
+
}
|
|
1497
|
+
}
|
|
1498
|
+
};
|
|
1499
|
+
const stopNestedAsyncDescendants = () => {
|
|
1500
|
+
if (!config.nestedRoute)
|
|
1501
|
+
return;
|
|
1502
|
+
let registry;
|
|
1503
|
+
try {
|
|
1504
|
+
registry = projectNestedEvents(config.nestedRoute);
|
|
1505
|
+
}
|
|
1506
|
+
catch (error) {
|
|
1507
|
+
appendJsonl(eventsPath, JSON.stringify({
|
|
1508
|
+
type: "subagent.nested.stop_failed",
|
|
1509
|
+
ts: Date.now(),
|
|
1510
|
+
runId: id,
|
|
1511
|
+
message: error instanceof Error ? error.message : String(error),
|
|
1512
|
+
}));
|
|
1513
|
+
return;
|
|
1514
|
+
}
|
|
1515
|
+
for (const run of nestedRuns(registry.children)) {
|
|
1516
|
+
if (run.state !== "running" && run.state !== "queued")
|
|
1517
|
+
continue;
|
|
1518
|
+
const nestedAsyncDir = run.asyncDir ?? resolveNestedAsyncDir(config.nestedRoute.rootRunId, run);
|
|
1519
|
+
if (!nestedAsyncDir)
|
|
1520
|
+
continue;
|
|
1521
|
+
try {
|
|
1522
|
+
deliverStopRequest({ asyncDir: nestedAsyncDir, pid: run.pid, source: "ancestor-stop" });
|
|
1523
|
+
}
|
|
1524
|
+
catch (error) {
|
|
1525
|
+
appendJsonl(eventsPath, JSON.stringify({
|
|
1526
|
+
type: "subagent.nested.stop_failed",
|
|
1527
|
+
ts: Date.now(),
|
|
1528
|
+
runId: id,
|
|
1529
|
+
targetRunId: run.id,
|
|
1530
|
+
message: error instanceof Error ? error.message : String(error),
|
|
1531
|
+
}));
|
|
1532
|
+
}
|
|
1533
|
+
}
|
|
1534
|
+
};
|
|
1535
|
+
const timeoutNestedAsyncDescendants = () => {
|
|
1536
|
+
if (!config.nestedRoute)
|
|
1537
|
+
return;
|
|
1538
|
+
let registry;
|
|
1539
|
+
try {
|
|
1540
|
+
registry = projectNestedEvents(config.nestedRoute);
|
|
1541
|
+
}
|
|
1542
|
+
catch (error) {
|
|
1543
|
+
appendJsonl(eventsPath, JSON.stringify({
|
|
1544
|
+
type: "subagent.nested.timeout_failed",
|
|
1545
|
+
ts: Date.now(),
|
|
1546
|
+
runId: id,
|
|
1547
|
+
message: error instanceof Error ? error.message : String(error),
|
|
1548
|
+
}));
|
|
1549
|
+
return;
|
|
1550
|
+
}
|
|
1551
|
+
for (const run of nestedRuns(registry.children)) {
|
|
1552
|
+
if (run.state !== "running" && run.state !== "queued")
|
|
1553
|
+
continue;
|
|
1554
|
+
const nestedAsyncDir = run.asyncDir ?? resolveNestedAsyncDir(config.nestedRoute.rootRunId, run);
|
|
1555
|
+
if (!nestedAsyncDir)
|
|
1556
|
+
continue;
|
|
1557
|
+
try {
|
|
1558
|
+
deliverTimeoutRequest({ asyncDir: nestedAsyncDir, pid: run.pid, source: "ancestor-timeout" });
|
|
1559
|
+
}
|
|
1560
|
+
catch (error) {
|
|
1561
|
+
appendJsonl(eventsPath, JSON.stringify({
|
|
1562
|
+
type: "subagent.nested.timeout_failed",
|
|
1563
|
+
ts: Date.now(),
|
|
1564
|
+
runId: id,
|
|
1565
|
+
targetRunId: run.id,
|
|
1566
|
+
message: error instanceof Error ? error.message : String(error),
|
|
1567
|
+
}));
|
|
1568
|
+
}
|
|
1569
|
+
}
|
|
1570
|
+
};
|
|
1571
|
+
const pausedStepResult = (agent) => ({
|
|
1572
|
+
agent,
|
|
1573
|
+
output: "Paused after interrupt. Waiting for explicit next action.",
|
|
1574
|
+
exitCode: 0,
|
|
1575
|
+
interrupted: true,
|
|
1576
|
+
});
|
|
1577
|
+
const timedOutStepResult = (agent) => ({
|
|
1578
|
+
agent,
|
|
1579
|
+
output: timeoutMessage ?? "Subagent timed out.",
|
|
1580
|
+
error: timeoutMessage ?? "Subagent timed out.",
|
|
1581
|
+
exitCode: 1,
|
|
1582
|
+
timedOut: true,
|
|
1583
|
+
});
|
|
1584
|
+
const stoppedStepResult = (agent) => ({
|
|
1585
|
+
agent,
|
|
1586
|
+
output: stopMessage,
|
|
1587
|
+
error: stopMessage,
|
|
1588
|
+
exitCode: 1,
|
|
1589
|
+
stopped: true,
|
|
1590
|
+
});
|
|
1591
|
+
const consumePendingAppendRequests = () => {
|
|
1592
|
+
if (statusPayload.mode !== "chain" || statusPayload.state !== "running")
|
|
1593
|
+
return;
|
|
1594
|
+
const requests = consumeChainAppendRequests(asyncDir);
|
|
1595
|
+
if (requests.length === 0) {
|
|
1596
|
+
const pendingAppends = countPendingChainAppendRequests(asyncDir);
|
|
1597
|
+
if ((statusPayload.pendingAppends ?? 0) !== pendingAppends) {
|
|
1598
|
+
statusPayload.pendingAppends = pendingAppends;
|
|
1599
|
+
statusPayload.lastUpdate = Date.now();
|
|
1600
|
+
writeStatusPayload();
|
|
1601
|
+
}
|
|
1602
|
+
return;
|
|
1603
|
+
}
|
|
1604
|
+
const appendedSteps = requests.flatMap((request) => request.steps);
|
|
1605
|
+
steps.push(...appendedSteps);
|
|
1606
|
+
const now = Date.now();
|
|
1607
|
+
const pendingAppends = countPendingChainAppendRequests(asyncDir);
|
|
1608
|
+
const added = appendRunnerStepsToStatus({
|
|
1609
|
+
status: statusPayload,
|
|
1610
|
+
steps: appendedSteps,
|
|
1611
|
+
now,
|
|
1612
|
+
pendingAppends,
|
|
1613
|
+
});
|
|
1614
|
+
mutatingFailureStates.push(...Array.from({ length: added.addedFlatSteps }, () => createMutatingFailureState()));
|
|
1615
|
+
pendingToolResults.push(...Array.from({ length: added.addedFlatSteps }, () => undefined));
|
|
1616
|
+
if (config.childIntercomTargets) {
|
|
1617
|
+
config.childIntercomTargets = statusPayload.steps.map((statusStep, index) => resolveSubagentIntercomTarget(id, statusStep.agent, index));
|
|
1618
|
+
}
|
|
1619
|
+
writeStatusPayload();
|
|
1620
|
+
for (const request of requests) {
|
|
1621
|
+
appendJsonl(eventsPath, JSON.stringify({
|
|
1622
|
+
type: "subagent.chain.append.accepted",
|
|
1623
|
+
ts: now,
|
|
1624
|
+
runId: id,
|
|
1625
|
+
requestId: request.id,
|
|
1626
|
+
stepCount: request.steps.length,
|
|
1627
|
+
pendingAppends,
|
|
1628
|
+
}));
|
|
1629
|
+
}
|
|
1630
|
+
};
|
|
1631
|
+
const markDynamicGraphGroup = (stepIndex, status, error, acceptance) => {
|
|
1632
|
+
const groupNode = statusPayload.workflowGraph?.nodes.find((node) => node.id === `step-${stepIndex}`);
|
|
1633
|
+
if (!groupNode)
|
|
1634
|
+
return;
|
|
1635
|
+
groupNode.status = status;
|
|
1636
|
+
groupNode.error = error;
|
|
1637
|
+
groupNode.acceptanceStatus = acceptance?.status ?? groupNode.acceptanceStatus;
|
|
1638
|
+
};
|
|
1639
|
+
const stepOutputActivityAt = (index) => {
|
|
1640
|
+
const step = statusPayload.steps[index];
|
|
1641
|
+
let lastActivityAt = step?.lastActivityAt ?? step?.startedAt ?? overallStartTime;
|
|
1642
|
+
const outputPath = path.join(asyncDir, `output-${index}.log`);
|
|
1643
|
+
try {
|
|
1644
|
+
lastActivityAt = Math.max(lastActivityAt, fs.statSync(outputPath).mtimeMs);
|
|
1645
|
+
}
|
|
1646
|
+
catch (error) {
|
|
1647
|
+
if (error.code !== "ENOENT") {
|
|
1648
|
+
console.error(`Failed to inspect async output file '${outputPath}':`, error);
|
|
1649
|
+
}
|
|
1650
|
+
}
|
|
1651
|
+
return lastActivityAt;
|
|
1652
|
+
};
|
|
1653
|
+
const emittedControlEventKeys = new Set();
|
|
1654
|
+
const activeLongRunningSteps = new Set();
|
|
1655
|
+
const mutatingFailureStates = initialStatusSteps.map(() => createMutatingFailureState());
|
|
1656
|
+
const pendingToolResults = initialStatusSteps.map(() => undefined);
|
|
1657
|
+
const mutatingFailureWindowMs = 5 * 60_000;
|
|
1658
|
+
const appendControlEvent = (event) => {
|
|
1659
|
+
if (!controlConfig.enabled)
|
|
1660
|
+
return;
|
|
1661
|
+
const childIntercomTarget = config.childIntercomTargets?.[event.index ?? statusPayload.currentStep];
|
|
1662
|
+
const channels = event.type === "active_long_running"
|
|
1663
|
+
? controlConfig.notifyChannels.filter((channel) => channel !== "intercom")
|
|
1664
|
+
: controlConfig.notifyChannels;
|
|
1665
|
+
if (channels.length === 0 || !claimControlNotification(controlConfig, event, emittedControlEventKeys, childIntercomTarget))
|
|
1666
|
+
return;
|
|
1667
|
+
appendJsonl(eventsPath, JSON.stringify({
|
|
1668
|
+
type: "subagent.control",
|
|
1669
|
+
event,
|
|
1670
|
+
channels,
|
|
1671
|
+
childIntercomTarget,
|
|
1672
|
+
noticeText: formatControlNoticeMessage(event, childIntercomTarget),
|
|
1673
|
+
...(config.controlIntercomTarget && channels.includes("intercom") ? {
|
|
1674
|
+
intercom: {
|
|
1675
|
+
to: config.controlIntercomTarget,
|
|
1676
|
+
message: formatControlIntercomMessage(event, childIntercomTarget),
|
|
1677
|
+
},
|
|
1678
|
+
} : {}),
|
|
1679
|
+
}));
|
|
1680
|
+
};
|
|
1681
|
+
const syncTopLevelCurrentTool = () => {
|
|
1682
|
+
const activeStep = statusPayload.steps
|
|
1683
|
+
.filter((step) => step.status === "running" && typeof step.currentTool === "string" && step.currentTool.length > 0)
|
|
1684
|
+
.sort((left, right) => (right.currentToolStartedAt ?? 0) - (left.currentToolStartedAt ?? 0))[0];
|
|
1685
|
+
statusPayload.currentTool = activeStep?.currentTool;
|
|
1686
|
+
statusPayload.currentToolStartedAt = activeStep?.currentToolStartedAt;
|
|
1687
|
+
statusPayload.currentPath = activeStep?.currentPath;
|
|
1688
|
+
};
|
|
1689
|
+
const maybeEmitActiveLongRunning = (flatIndex, now) => {
|
|
1690
|
+
if (!controlConfig.enabled || activeLongRunningSteps.has(flatIndex))
|
|
1691
|
+
return false;
|
|
1692
|
+
const step = statusPayload.steps[flatIndex];
|
|
1693
|
+
if (!step || step.status !== "running" || step.activityState === "needs_attention")
|
|
1694
|
+
return false;
|
|
1695
|
+
const reason = nextLongRunningTrigger(controlConfig, {
|
|
1696
|
+
startedAt: step.startedAt ?? overallStartTime,
|
|
1697
|
+
now,
|
|
1698
|
+
turns: step.turnCount ?? 0,
|
|
1699
|
+
tokens: step.tokens?.total ?? 0,
|
|
1700
|
+
});
|
|
1701
|
+
if (!reason)
|
|
1702
|
+
return false;
|
|
1703
|
+
activeLongRunningSteps.add(flatIndex);
|
|
1704
|
+
const previous = step.activityState;
|
|
1705
|
+
step.activityState = "active_long_running";
|
|
1706
|
+
statusPayload.activityState = statusPayload.activityState === "needs_attention" ? "needs_attention" : "active_long_running";
|
|
1707
|
+
const event = buildControlEvent({
|
|
1708
|
+
type: "active_long_running",
|
|
1709
|
+
from: previous,
|
|
1710
|
+
to: "active_long_running",
|
|
1711
|
+
runId: id,
|
|
1712
|
+
agent: step.agent,
|
|
1713
|
+
index: flatIndex,
|
|
1714
|
+
ts: now,
|
|
1715
|
+
message: `${step.agent} is still active but long-running`,
|
|
1716
|
+
reason,
|
|
1717
|
+
turns: step.turnCount,
|
|
1718
|
+
tokens: step.tokens?.total,
|
|
1719
|
+
toolCount: step.toolCount,
|
|
1720
|
+
currentTool: step.currentTool,
|
|
1721
|
+
currentToolDurationMs: step.currentToolStartedAt ? Math.max(0, now - step.currentToolStartedAt) : undefined,
|
|
1722
|
+
currentPath: step.currentPath,
|
|
1723
|
+
elapsedMs: now - (step.startedAt ?? overallStartTime),
|
|
1724
|
+
});
|
|
1725
|
+
appendControlEvent(event);
|
|
1726
|
+
return true;
|
|
1727
|
+
};
|
|
1728
|
+
const steeringMarkerPath = (requestId) => path.join(asyncDir, "control", "steer-recovery", `${Buffer.from(requestId).toString("base64url")}.json`);
|
|
1729
|
+
const markSteeringAttention = (index) => {
|
|
1730
|
+
const step = statusPayload.steps[index];
|
|
1731
|
+
if (step)
|
|
1732
|
+
step.activityState = "needs_attention";
|
|
1733
|
+
statusPayload.activityState = "needs_attention";
|
|
1734
|
+
};
|
|
1735
|
+
const emitSteeringEvent = (type, request, index, extra = {}) => {
|
|
1736
|
+
appendJsonl(eventsPath, JSON.stringify({ type, ts: Date.now(), runId: id, requestId: request.id, ...(index !== undefined ? { index } : {}), ...extra }));
|
|
1737
|
+
};
|
|
1738
|
+
const emitSteeringNotice = (requestId, state, message) => {
|
|
1739
|
+
appendJsonl(eventsPath, JSON.stringify({ type: "subagent.steering.notice", ts: Date.now(), runId: id, requestId, state, message, ...(config.sessionId ? { currentSessionId: config.sessionId } : {}) }));
|
|
1740
|
+
};
|
|
1741
|
+
const recordSteeringLifecycle = (request, targets) => {
|
|
1742
|
+
const lifecycle = steeringStatus(statusPayload);
|
|
1743
|
+
recordSteeringRequest(lifecycle, { id: request.id, requestedAt: request.ts, source: request.source, message: request.message, targets });
|
|
1744
|
+
for (const target of targets) {
|
|
1745
|
+
const step = statusPayload.steps[target.index];
|
|
1746
|
+
if (!step)
|
|
1747
|
+
continue;
|
|
1748
|
+
step.steering ??= createSteeringStatus();
|
|
1749
|
+
recordSteeringRequest(step.steering, { id: request.id, requestedAt: request.ts, source: request.source, message: request.message, targets: [target] });
|
|
1750
|
+
}
|
|
1751
|
+
};
|
|
1752
|
+
const updateSteeringLifecycleTarget = (requestId, index, state, now, fields = {}) => {
|
|
1753
|
+
const updated = updateSteeringTarget(steeringStatus(statusPayload), requestId, index, state, now, fields);
|
|
1754
|
+
const step = statusPayload.steps[index];
|
|
1755
|
+
if (step?.steering)
|
|
1756
|
+
updateSteeringTarget(step.steering, requestId, index, state, now, fields);
|
|
1757
|
+
return updated;
|
|
1758
|
+
};
|
|
1759
|
+
const emitTerminalSteeringNotice = (requestId, failureMessage) => {
|
|
1760
|
+
const state = terminalSteeringNoticeState(steeringStatus(statusPayload), requestId);
|
|
1761
|
+
if (state === "partial")
|
|
1762
|
+
emitSteeringNotice(requestId, "partial", `Steering partially delivered for run ${id}.`);
|
|
1763
|
+
else if (state === "failed")
|
|
1764
|
+
emitSteeringNotice(requestId, "failed", failureMessage);
|
|
1765
|
+
};
|
|
1766
|
+
const deliverSteerRequest = (request) => {
|
|
1767
|
+
if (statusPayload.state !== "running") {
|
|
1768
|
+
const reason = `run became ${statusPayload.state} before steering request was consumed`;
|
|
1769
|
+
const indexes = request.targetIndex !== undefined
|
|
1770
|
+
? [request.targetIndex]
|
|
1771
|
+
: request.targetIndexes?.length
|
|
1772
|
+
? request.targetIndexes
|
|
1773
|
+
: statusPayload.steps.map((_, index) => index);
|
|
1774
|
+
const targets = indexes.map((index) => ({ index, state: "failed", reason }));
|
|
1775
|
+
recordSteeringLifecycle(request, targets);
|
|
1776
|
+
emitSteeringEvent("subagent.steer.requested", request, undefined, { targets });
|
|
1777
|
+
for (const target of targets)
|
|
1778
|
+
emitSteeringEvent("subagent.steer.failed", request, target.index, { reason });
|
|
1779
|
+
emitTerminalSteeringNotice(request.id, `Steering failed for run ${id}: ${reason}.`);
|
|
1780
|
+
statusPayload.lastUpdate = Date.now();
|
|
1781
|
+
writeStatusPayload();
|
|
1782
|
+
return;
|
|
1783
|
+
}
|
|
1784
|
+
const runningIndexes = statusPayload.steps
|
|
1785
|
+
.map((step, index) => ({ step, index }))
|
|
1786
|
+
.filter(({ step }) => step.status === "running")
|
|
1787
|
+
.map(({ index }) => index);
|
|
1788
|
+
const targets = request.targetIndex !== undefined
|
|
1789
|
+
? [request.targetIndex]
|
|
1790
|
+
: request.targetIndexes?.length
|
|
1791
|
+
? request.targetIndexes
|
|
1792
|
+
: runningIndexes.length > 0
|
|
1793
|
+
? runningIndexes
|
|
1794
|
+
: statusPayload.mode === "single" && statusPayload.steps[0]?.status === "pending"
|
|
1795
|
+
? [0]
|
|
1796
|
+
: [];
|
|
1797
|
+
const now = Date.now();
|
|
1798
|
+
const targetStates = targets.map((index) => {
|
|
1799
|
+
const step = statusPayload.steps[index];
|
|
1800
|
+
if (!step)
|
|
1801
|
+
return { index, state: "failed", reason: "child index out of range" };
|
|
1802
|
+
if (step.status === "pending")
|
|
1803
|
+
return { index, state: "scheduled" };
|
|
1804
|
+
if (step.status !== "running")
|
|
1805
|
+
return { index, state: "failed", reason: `child is ${step.status}` };
|
|
1806
|
+
if (steeringCapabilities.get(index)?.supported === false)
|
|
1807
|
+
return { index, state: "failed", reason: "child Pi session does not support steering" };
|
|
1808
|
+
return { index, state: "routed" };
|
|
1809
|
+
});
|
|
1810
|
+
recordSteeringLifecycle(request, targetStates);
|
|
1811
|
+
emitSteeringEvent("subagent.steer.requested", request, undefined, { targets: targetStates });
|
|
1812
|
+
for (const target of targetStates) {
|
|
1813
|
+
if (target.state === "routed") {
|
|
1814
|
+
try {
|
|
1815
|
+
enqueueStepSteer(asyncDir, target.index, request);
|
|
1816
|
+
updateSteeringLifecycleTarget(request.id, target.index, "routed", now);
|
|
1817
|
+
emitSteeringEvent("subagent.steer.routed", request, target.index);
|
|
1818
|
+
}
|
|
1819
|
+
catch (error) {
|
|
1820
|
+
markSteeringAttention(target.index);
|
|
1821
|
+
updateSteeringLifecycleTarget(request.id, target.index, "failed", now, { reason: error instanceof Error ? error.message : String(error) });
|
|
1822
|
+
emitSteeringEvent("subagent.steer.failed", request, target.index, { reason: error instanceof Error ? error.message : String(error) });
|
|
1823
|
+
}
|
|
1824
|
+
}
|
|
1825
|
+
else if (target.state === "failed") {
|
|
1826
|
+
markSteeringAttention(target.index);
|
|
1827
|
+
emitSteeringEvent("subagent.steer.failed", request, target.index, { reason: target.reason });
|
|
1828
|
+
}
|
|
1829
|
+
else {
|
|
1830
|
+
emitSteeringEvent("subagent.steer.scheduled", request, target.index);
|
|
1831
|
+
}
|
|
1832
|
+
}
|
|
1833
|
+
emitTerminalSteeringNotice(request.id, `Steering failed for run ${id}: no requested child remained steerable.`);
|
|
1834
|
+
statusPayload.lastUpdate = now;
|
|
1835
|
+
writeStatusPayload();
|
|
1836
|
+
};
|
|
1837
|
+
const consumeSteerAck = (ack) => {
|
|
1838
|
+
const lifecycle = steeringStatus(statusPayload);
|
|
1839
|
+
const request = lifecycle.recent.find((candidate) => candidate.id === ack.requestId);
|
|
1840
|
+
if (!request || !request.targets.some((target) => target.index === ack.index))
|
|
1841
|
+
return;
|
|
1842
|
+
const late = fs.existsSync(steeringMarkerPath(ack.requestId));
|
|
1843
|
+
const now = Date.now();
|
|
1844
|
+
if (ack.state === "delivered") {
|
|
1845
|
+
updateSteeringLifecycleTarget(ack.requestId, ack.index, late ? "late" : "delivered", now, { reason: late ? "acknowledged after recovery commit" : undefined });
|
|
1846
|
+
emitSteeringEvent("subagent.steer.delivered", { type: "steer", id: ack.requestId, ts: now, message: ack.message }, ack.index, { late, message: ack.message });
|
|
1847
|
+
}
|
|
1848
|
+
else {
|
|
1849
|
+
markSteeringAttention(ack.index);
|
|
1850
|
+
updateSteeringLifecycleTarget(ack.requestId, ack.index, "failed", now, { reason: ack.message });
|
|
1851
|
+
emitSteeringEvent("subagent.steer.failed", { type: "steer", id: ack.requestId, ts: now, message: ack.message }, ack.index, { reason: ack.message });
|
|
1852
|
+
}
|
|
1853
|
+
emitTerminalSteeringNotice(ack.requestId, `Steering failed for run ${id}: ${ack.message}`);
|
|
1854
|
+
statusPayload.lastUpdate = now;
|
|
1855
|
+
writeStatusPayload();
|
|
1856
|
+
};
|
|
1857
|
+
const flushPendingStepSteers = (flatIndex) => {
|
|
1858
|
+
const remaining = [];
|
|
1859
|
+
for (const request of pendingStepSteers.splice(0)) {
|
|
1860
|
+
if (request.targetIndex === undefined)
|
|
1861
|
+
deliverSteerRequest({ ...request, targetIndex: flatIndex });
|
|
1862
|
+
else if (request.targetIndex === flatIndex)
|
|
1863
|
+
deliverSteerRequest(request);
|
|
1864
|
+
else
|
|
1865
|
+
remaining.push(request);
|
|
1866
|
+
}
|
|
1867
|
+
pendingStepSteers.push(...remaining);
|
|
1868
|
+
};
|
|
1869
|
+
const updateStepModel = (flatIndex, model, thinking, now = Date.now()) => {
|
|
1870
|
+
const step = statusPayload.steps[flatIndex];
|
|
1871
|
+
if (!step)
|
|
1872
|
+
return;
|
|
1873
|
+
step.model = model;
|
|
1874
|
+
step.thinking = thinking;
|
|
1875
|
+
statusPayload.lastUpdate = now;
|
|
1876
|
+
writeStatusPayload();
|
|
1877
|
+
};
|
|
1878
|
+
const updateStepTurnBudget = (flatIndex, turnCount, now, terminalAssistantStop) => {
|
|
1879
|
+
const budget = config.turnBudget;
|
|
1880
|
+
const step = statusPayload.steps[flatIndex];
|
|
1881
|
+
if (!budget || !step || timedOut || stopped || turnBudgetExceeded || step.turnBudgetExceeded)
|
|
1882
|
+
return;
|
|
1883
|
+
if (turnCount < budget.maxTurns) {
|
|
1884
|
+
const state = { ...budget, outcome: "within-budget", turnCount };
|
|
1885
|
+
step.turnBudget = state;
|
|
1886
|
+
statusPayload.turnBudget = state;
|
|
1887
|
+
return;
|
|
1888
|
+
}
|
|
1889
|
+
const state = turnBudgetState(budget, turnCount, false);
|
|
1890
|
+
step.turnBudget = state;
|
|
1891
|
+
statusPayload.turnBudget = state;
|
|
1892
|
+
if (!step.wrapUpRequested) {
|
|
1893
|
+
step.wrapUpRequested = true;
|
|
1894
|
+
statusPayload.wrapUpRequested = true;
|
|
1895
|
+
appendRecentStepOutput(step, [turnBudgetSoftNote(budget, turnCount)]);
|
|
1896
|
+
}
|
|
1897
|
+
if (!shouldAbortForTurnBudget(budget, turnCount, terminalAssistantStop))
|
|
1898
|
+
return;
|
|
1899
|
+
const exceededState = turnBudgetState(budget, turnCount, true);
|
|
1900
|
+
const message = turnBudgetExceededMessage(budget, turnCount);
|
|
1901
|
+
step.turnBudget = exceededState;
|
|
1902
|
+
step.turnBudgetExceeded = true;
|
|
1903
|
+
step.wrapUpRequested = true;
|
|
1904
|
+
step.error = message;
|
|
1905
|
+
turnBudgetExceeded = true;
|
|
1906
|
+
statusPayload.turnBudget = exceededState;
|
|
1907
|
+
statusPayload.turnBudgetExceeded = true;
|
|
1908
|
+
statusPayload.wrapUpRequested = true;
|
|
1909
|
+
statusPayload.error = message;
|
|
1910
|
+
statusPayload.lastUpdate = now;
|
|
1911
|
+
appendJsonl(eventsPath, JSON.stringify({ type: "subagent.step.turn_budget_exceeded", ts: now, runId: id, stepIndex: flatIndex, agent: step.agent, turnCount, maxTurns: budget.maxTurns, graceTurns: budget.graceTurns, message }));
|
|
1912
|
+
activeChildTurnBudgetAborts.get(flatIndex)?.(message, exceededState);
|
|
1913
|
+
};
|
|
1914
|
+
const updateStepFromChildEvent = (flatIndex, event) => {
|
|
1915
|
+
const step = statusPayload.steps[flatIndex];
|
|
1916
|
+
if (!step)
|
|
1917
|
+
return;
|
|
1918
|
+
const now = Date.now();
|
|
1919
|
+
statusPayload.currentStep = flatIndex;
|
|
1920
|
+
if (isChildWatchdogStatusEvent(event)) {
|
|
1921
|
+
const next = acceptChildWatchdogEvent({
|
|
1922
|
+
current: step.watchdog,
|
|
1923
|
+
event,
|
|
1924
|
+
runId: id,
|
|
1925
|
+
agent: step.agent,
|
|
1926
|
+
childIndex: flatIndex,
|
|
1927
|
+
});
|
|
1928
|
+
if (!next)
|
|
1929
|
+
return;
|
|
1930
|
+
step.watchdog = next;
|
|
1931
|
+
step.lastActivityAt = now;
|
|
1932
|
+
statusPayload.lastActivityAt = now;
|
|
1933
|
+
statusPayload.lastUpdate = now;
|
|
1934
|
+
writeStatusPayload();
|
|
1935
|
+
return;
|
|
1936
|
+
}
|
|
1937
|
+
if (event.type === "tool_execution_start" && event.toolName) {
|
|
1938
|
+
const mutates = isMutatingTool(event.toolName, event.args);
|
|
1939
|
+
const currentPath = resolveCurrentPath(event.toolName, event.args);
|
|
1940
|
+
step.toolCount = (step.toolCount ?? 0) + 1;
|
|
1941
|
+
const configuredToolBudget = flatSteps[flatIndex]?.toolBudget;
|
|
1942
|
+
if (configuredToolBudget) {
|
|
1943
|
+
step.toolBudget = toolBudgetState(configuredToolBudget, step.toolCount);
|
|
1944
|
+
statusPayload.toolBudget = step.toolBudget;
|
|
1945
|
+
}
|
|
1946
|
+
step.currentTool = event.toolName;
|
|
1947
|
+
step.currentToolArgs = extractToolArgsPreview(event.args ?? {});
|
|
1948
|
+
step.currentToolStartedAt = now;
|
|
1949
|
+
step.currentPath = currentPath;
|
|
1950
|
+
pendingToolResults[flatIndex] = { tool: event.toolName, path: currentPath, mutates, startedAt: now };
|
|
1951
|
+
statusPayload.toolCount = (statusPayload.toolCount ?? 0) + 1;
|
|
1952
|
+
syncTopLevelCurrentTool();
|
|
1953
|
+
}
|
|
1954
|
+
else if (event.type === "tool_execution_end") {
|
|
1955
|
+
if (step.currentTool) {
|
|
1956
|
+
step.recentTools ??= [];
|
|
1957
|
+
step.recentTools.push({ tool: step.currentTool, args: step.currentToolArgs || "", endMs: now });
|
|
1958
|
+
}
|
|
1959
|
+
step.currentTool = undefined;
|
|
1960
|
+
step.currentToolArgs = undefined;
|
|
1961
|
+
step.currentToolStartedAt = undefined;
|
|
1962
|
+
step.currentPath = undefined;
|
|
1963
|
+
syncTopLevelCurrentTool();
|
|
1964
|
+
}
|
|
1965
|
+
else if (event.type === "tool_result_end" && event.message) {
|
|
1966
|
+
const toolSnapshot = pendingToolResults[flatIndex];
|
|
1967
|
+
pendingToolResults[flatIndex] = undefined;
|
|
1968
|
+
const resultText = extractTextFromContent(event.message.content);
|
|
1969
|
+
if (toolSnapshot && resultText.includes("Tool budget hard limit reached")) {
|
|
1970
|
+
const configuredToolBudget = flatSteps[flatIndex]?.toolBudget;
|
|
1971
|
+
if (configuredToolBudget) {
|
|
1972
|
+
step.toolBudget = toolBudgetState(configuredToolBudget, step.toolCount ?? 0, toolSnapshot.tool);
|
|
1973
|
+
step.toolBudgetBlocked = true;
|
|
1974
|
+
statusPayload.toolBudget = step.toolBudget;
|
|
1975
|
+
statusPayload.toolBudgetBlocked = true;
|
|
1976
|
+
}
|
|
1977
|
+
}
|
|
1978
|
+
appendRecentStepOutput(step, resultText.split("\n").slice(-10));
|
|
1979
|
+
if (toolSnapshot?.mutates && didMutatingToolFail(resultText)) {
|
|
1980
|
+
const state = mutatingFailureStates[flatIndex];
|
|
1981
|
+
recordMutatingFailure(state, {
|
|
1982
|
+
tool: toolSnapshot.tool,
|
|
1983
|
+
path: toolSnapshot.path,
|
|
1984
|
+
error: resultText.split("\n").find((line) => line.trim())?.trim().slice(0, 180) ?? "mutating tool failed",
|
|
1985
|
+
ts: now,
|
|
1986
|
+
}, mutatingFailureWindowMs);
|
|
1987
|
+
if (controlConfig.enabled && shouldEscalateMutatingFailures(state, controlConfig.failedToolAttemptsBeforeAttention) && step.activityState !== "needs_attention") {
|
|
1988
|
+
const previous = step.activityState;
|
|
1989
|
+
step.activityState = "needs_attention";
|
|
1990
|
+
statusPayload.activityState = "needs_attention";
|
|
1991
|
+
appendControlEvent(buildControlEvent({
|
|
1992
|
+
type: "needs_attention",
|
|
1993
|
+
from: previous,
|
|
1994
|
+
to: "needs_attention",
|
|
1995
|
+
runId: id,
|
|
1996
|
+
agent: step.agent,
|
|
1997
|
+
index: flatIndex,
|
|
1998
|
+
ts: now,
|
|
1999
|
+
message: `${step.agent} needs attention after repeated mutating tool failures`,
|
|
2000
|
+
reason: "tool_failures",
|
|
2001
|
+
turns: step.turnCount,
|
|
2002
|
+
tokens: step.tokens?.total,
|
|
2003
|
+
toolCount: step.toolCount,
|
|
2004
|
+
currentTool: toolSnapshot.tool,
|
|
2005
|
+
currentToolDurationMs: toolSnapshot.startedAt ? Math.max(0, now - toolSnapshot.startedAt) : undefined,
|
|
2006
|
+
currentPath: toolSnapshot.path,
|
|
2007
|
+
recentFailureSummary: summarizeRecentMutatingFailures(state),
|
|
2008
|
+
}));
|
|
2009
|
+
}
|
|
2010
|
+
}
|
|
2011
|
+
else if (toolSnapshot?.mutates) {
|
|
2012
|
+
resetMutatingFailureState(mutatingFailureStates[flatIndex]);
|
|
2013
|
+
}
|
|
2014
|
+
}
|
|
2015
|
+
else if (event.type === "message_end" && event.message?.role === "assistant") {
|
|
2016
|
+
appendRecentStepOutput(step, stripAcceptanceReport(extractTextFromContent(event.message.content)).split("\n").slice(-10));
|
|
2017
|
+
step.turnCount = (step.turnCount ?? 0) + 1;
|
|
2018
|
+
const usage = event.message.usage;
|
|
2019
|
+
if (usage) {
|
|
2020
|
+
const input = usage.input ?? usage.inputTokens ?? 0;
|
|
2021
|
+
const output = usage.output ?? usage.outputTokens ?? 0;
|
|
2022
|
+
const previousInput = step.tokens?.input ?? 0;
|
|
2023
|
+
const previousOutput = step.tokens?.output ?? 0;
|
|
2024
|
+
step.tokens = { input: previousInput + input, output: previousOutput + output, total: previousInput + previousOutput + input + output };
|
|
2025
|
+
const totalInput = statusPayload.totalTokens?.input ?? 0;
|
|
2026
|
+
const totalOutput = statusPayload.totalTokens?.output ?? 0;
|
|
2027
|
+
statusPayload.totalTokens = { input: totalInput + input, output: totalOutput + output, total: totalInput + totalOutput + input + output };
|
|
2028
|
+
}
|
|
2029
|
+
statusPayload.turnCount = Math.max(statusPayload.turnCount ?? 0, step.turnCount);
|
|
2030
|
+
updateStepTurnBudget(flatIndex, step.turnCount, now, isTerminalAssistantStop(event.message));
|
|
2031
|
+
}
|
|
2032
|
+
syncTopLevelCurrentTool();
|
|
2033
|
+
step.lastActivityAt = now;
|
|
2034
|
+
statusPayload.lastActivityAt = now;
|
|
2035
|
+
statusPayload.lastUpdate = now;
|
|
2036
|
+
maybeEmitActiveLongRunning(flatIndex, now);
|
|
2037
|
+
writeStatusPayload();
|
|
2038
|
+
};
|
|
2039
|
+
const updateRunnerActivityState = (now) => {
|
|
2040
|
+
if (!controlConfig.enabled)
|
|
2041
|
+
return false;
|
|
2042
|
+
let changed = false;
|
|
2043
|
+
let runLastActivityAt = statusPayload.lastActivityAt ?? overallStartTime;
|
|
2044
|
+
for (let index = 0; index < statusPayload.steps.length; index++) {
|
|
2045
|
+
const step = statusPayload.steps[index];
|
|
2046
|
+
if (step.status !== "running")
|
|
2047
|
+
continue;
|
|
2048
|
+
const lastActivityAt = stepOutputActivityAt(index);
|
|
2049
|
+
runLastActivityAt = Math.max(runLastActivityAt, lastActivityAt);
|
|
2050
|
+
if (step.lastActivityAt !== lastActivityAt) {
|
|
2051
|
+
step.lastActivityAt = lastActivityAt;
|
|
2052
|
+
changed = true;
|
|
2053
|
+
}
|
|
2054
|
+
const idleState = deriveActivityState({
|
|
2055
|
+
config: controlConfig,
|
|
2056
|
+
startedAt: step.startedAt ?? overallStartTime,
|
|
2057
|
+
lastActivityAt,
|
|
2058
|
+
now,
|
|
2059
|
+
});
|
|
2060
|
+
if (idleState === "needs_attention") {
|
|
2061
|
+
const previous = step.activityState;
|
|
2062
|
+
step.activityState = "needs_attention";
|
|
2063
|
+
if (previous !== "needs_attention") {
|
|
2064
|
+
appendControlEvent(buildControlEvent({
|
|
2065
|
+
from: previous,
|
|
2066
|
+
to: "needs_attention",
|
|
2067
|
+
runId: id,
|
|
2068
|
+
agent: step.agent,
|
|
2069
|
+
index,
|
|
2070
|
+
ts: now,
|
|
2071
|
+
lastActivityAt,
|
|
2072
|
+
}));
|
|
2073
|
+
changed = true;
|
|
2074
|
+
}
|
|
2075
|
+
}
|
|
2076
|
+
else if (maybeEmitActiveLongRunning(index, now)) {
|
|
2077
|
+
changed = true;
|
|
2078
|
+
}
|
|
2079
|
+
}
|
|
2080
|
+
if (statusPayload.lastActivityAt !== runLastActivityAt) {
|
|
2081
|
+
statusPayload.lastActivityAt = runLastActivityAt;
|
|
2082
|
+
changed = true;
|
|
2083
|
+
}
|
|
2084
|
+
const nextRunState = statusPayload.steps.some((step) => step.activityState === "needs_attention")
|
|
2085
|
+
? "needs_attention"
|
|
2086
|
+
: statusPayload.steps.some((step) => step.activityState === "active_long_running")
|
|
2087
|
+
? "active_long_running"
|
|
2088
|
+
: undefined;
|
|
2089
|
+
if (nextRunState !== currentActivityState) {
|
|
2090
|
+
currentActivityState = nextRunState;
|
|
2091
|
+
statusPayload.activityState = nextRunState;
|
|
2092
|
+
changed = true;
|
|
2093
|
+
}
|
|
2094
|
+
statusPayload.lastUpdate = now;
|
|
2095
|
+
if (changed)
|
|
2096
|
+
writeStatusPayload();
|
|
2097
|
+
return changed;
|
|
2098
|
+
};
|
|
2099
|
+
if (controlConfig.enabled) {
|
|
2100
|
+
activityTimer = setInterval(() => {
|
|
2101
|
+
if (statusPayload.state !== "running")
|
|
2102
|
+
return;
|
|
2103
|
+
const now = Date.now();
|
|
2104
|
+
updateRunnerActivityState(now);
|
|
2105
|
+
}, 1000);
|
|
2106
|
+
activityTimer.unref?.();
|
|
2107
|
+
}
|
|
2108
|
+
const interruptRunner = () => {
|
|
2109
|
+
consumeInterruptRequest(asyncDir);
|
|
2110
|
+
if (interrupted || statusPayload.state !== "running")
|
|
2111
|
+
return;
|
|
2112
|
+
interrupted = true;
|
|
2113
|
+
const now = Date.now();
|
|
2114
|
+
statusPayload.state = "paused";
|
|
2115
|
+
currentActivityState = undefined;
|
|
2116
|
+
statusPayload.activityState = undefined;
|
|
2117
|
+
statusPayload.lastUpdate = now;
|
|
2118
|
+
for (const step of statusPayload.steps) {
|
|
2119
|
+
if (step.status === "running") {
|
|
2120
|
+
step.status = "paused";
|
|
2121
|
+
step.activityState = undefined;
|
|
2122
|
+
step.endedAt = now;
|
|
2123
|
+
step.durationMs = step.startedAt ? now - step.startedAt : undefined;
|
|
2124
|
+
step.lastActivityAt = now;
|
|
2125
|
+
}
|
|
2126
|
+
}
|
|
2127
|
+
writeStatusPayload();
|
|
2128
|
+
appendJsonl(eventsPath, JSON.stringify({
|
|
2129
|
+
type: "subagent.run.paused",
|
|
2130
|
+
ts: now,
|
|
2131
|
+
runId: id,
|
|
2132
|
+
}));
|
|
2133
|
+
interruptNestedAsyncDescendants();
|
|
2134
|
+
interruptActiveChildren();
|
|
2135
|
+
};
|
|
2136
|
+
const stopRunner = () => {
|
|
2137
|
+
if (stopped || timedOut || interrupted || statusPayload.state !== "running")
|
|
2138
|
+
return;
|
|
2139
|
+
stopped = true;
|
|
2140
|
+
const now = Date.now();
|
|
2141
|
+
statusPayload.state = "stopped";
|
|
2142
|
+
statusPayload.stopped = true;
|
|
2143
|
+
statusPayload.error = stopMessage;
|
|
2144
|
+
currentActivityState = undefined;
|
|
2145
|
+
statusPayload.activityState = undefined;
|
|
2146
|
+
statusPayload.lastUpdate = now;
|
|
2147
|
+
for (const step of statusPayload.steps) {
|
|
2148
|
+
if (step.status !== "running" && step.status !== "pending")
|
|
2149
|
+
continue;
|
|
2150
|
+
step.status = "stopped";
|
|
2151
|
+
step.error = stopMessage;
|
|
2152
|
+
step.exitCode = 1;
|
|
2153
|
+
step.stopped = true;
|
|
2154
|
+
step.activityState = undefined;
|
|
2155
|
+
step.endedAt = now;
|
|
2156
|
+
step.durationMs = step.startedAt ? now - step.startedAt : 0;
|
|
2157
|
+
step.lastActivityAt = now;
|
|
2158
|
+
}
|
|
2159
|
+
writeStatusPayload();
|
|
2160
|
+
appendJsonl(eventsPath, JSON.stringify({
|
|
2161
|
+
type: "subagent.run.stopped",
|
|
2162
|
+
ts: now,
|
|
2163
|
+
runId: id,
|
|
2164
|
+
message: stopMessage,
|
|
2165
|
+
}));
|
|
2166
|
+
stopAbortController.abort();
|
|
2167
|
+
stopNestedAsyncDescendants();
|
|
2168
|
+
stopActiveChildren();
|
|
2169
|
+
};
|
|
2170
|
+
const timeoutRunner = () => {
|
|
2171
|
+
if (timedOut || stopped || interrupted || statusPayload.state !== "running")
|
|
2172
|
+
return;
|
|
2173
|
+
timedOut = true;
|
|
2174
|
+
const now = Date.now();
|
|
2175
|
+
const message = timeoutMessage ?? "Subagent timed out.";
|
|
2176
|
+
statusPayload.state = "failed";
|
|
2177
|
+
statusPayload.timedOut = true;
|
|
2178
|
+
statusPayload.error = message;
|
|
2179
|
+
currentActivityState = undefined;
|
|
2180
|
+
statusPayload.activityState = undefined;
|
|
2181
|
+
statusPayload.lastUpdate = now;
|
|
2182
|
+
for (const step of statusPayload.steps) {
|
|
2183
|
+
if (step.status !== "running" && step.status !== "pending")
|
|
2184
|
+
continue;
|
|
2185
|
+
step.status = "failed";
|
|
2186
|
+
step.error = message;
|
|
2187
|
+
step.exitCode = 1;
|
|
2188
|
+
step.timedOut = true;
|
|
2189
|
+
step.activityState = undefined;
|
|
2190
|
+
step.endedAt = now;
|
|
2191
|
+
step.durationMs = step.startedAt ? now - step.startedAt : 0;
|
|
2192
|
+
step.lastActivityAt = now;
|
|
2193
|
+
}
|
|
2194
|
+
writeStatusPayload();
|
|
2195
|
+
appendJsonl(eventsPath, JSON.stringify({
|
|
2196
|
+
type: "subagent.run.timed_out",
|
|
2197
|
+
ts: now,
|
|
2198
|
+
runId: id,
|
|
2199
|
+
timeoutMs: config.timeoutMs,
|
|
2200
|
+
deadlineAt: config.deadlineAt,
|
|
2201
|
+
message,
|
|
2202
|
+
}));
|
|
2203
|
+
timeoutAbortController.abort();
|
|
2204
|
+
timeoutNestedAsyncDescendants();
|
|
2205
|
+
timeoutActiveChildren();
|
|
2206
|
+
};
|
|
2207
|
+
process.on(ASYNC_INTERRUPT_SIGNAL, interruptRunner);
|
|
2208
|
+
// Portable control inbox: the parent drops control request files here when
|
|
2209
|
+
// it cannot deliver OS signals (e.g. ENOSYS on Windows) or when steering a
|
|
2210
|
+
// live child. Interrupts still route into the same graceful interruptRunner().
|
|
2211
|
+
const disposeControlInbox = watchAsyncControlInbox(asyncDir, {
|
|
2212
|
+
onInterrupt: interruptRunner,
|
|
2213
|
+
onTimeout: timeoutRunner,
|
|
2214
|
+
onStop: stopRunner,
|
|
2215
|
+
onSteer: (request) => {
|
|
2216
|
+
const targetStep = request.targetIndex !== undefined ? statusPayload.steps[request.targetIndex] : undefined;
|
|
2217
|
+
if (targetStep?.status === "pending") {
|
|
2218
|
+
deliverSteerRequest(request);
|
|
2219
|
+
pendingStepSteers.push(request);
|
|
2220
|
+
}
|
|
2221
|
+
else if (request.targetIndexes !== undefined || request.targetIndex !== undefined || statusPayload.steps.some((step) => step.status === "running")) {
|
|
2222
|
+
deliverSteerRequest(request);
|
|
2223
|
+
}
|
|
2224
|
+
else {
|
|
2225
|
+
deliverSteerRequest(request);
|
|
2226
|
+
pendingStepSteers.push(request);
|
|
2227
|
+
}
|
|
2228
|
+
},
|
|
2229
|
+
onSteerCapability: (capability) => {
|
|
2230
|
+
steeringCapabilities.set(capability.index, capability);
|
|
2231
|
+
if (!capability.supported) {
|
|
2232
|
+
const now = Date.now();
|
|
2233
|
+
const lifecycle = steeringStatus(statusPayload);
|
|
2234
|
+
for (const request of lifecycle.recent) {
|
|
2235
|
+
if (!request.targets.some((target) => target.index === capability.index && (target.state === "routed" || target.state === "scheduled")))
|
|
2236
|
+
continue;
|
|
2237
|
+
markSteeringAttention(capability.index);
|
|
2238
|
+
updateSteeringLifecycleTarget(request.id, capability.index, "failed", now, { reason: "child Pi session does not support steering" });
|
|
2239
|
+
emitSteeringEvent("subagent.steer.failed", { type: "steer", id: request.id, ts: request.requestedAt, message: "child Pi session does not support steering" }, capability.index, { reason: "child Pi session does not support steering" });
|
|
2240
|
+
emitTerminalSteeringNotice(request.id, `Steering failed for run ${id}: child ${capability.index} does not support steering.`);
|
|
2241
|
+
}
|
|
2242
|
+
statusPayload.lastUpdate = now;
|
|
2243
|
+
writeStatusPayload();
|
|
2244
|
+
}
|
|
2245
|
+
},
|
|
2246
|
+
onSteerAck: consumeSteerAck,
|
|
2247
|
+
});
|
|
2248
|
+
if (config.deadlineAt !== undefined) {
|
|
2249
|
+
const remainingMs = Math.max(0, config.deadlineAt - Date.now());
|
|
2250
|
+
timeoutTimer = setTimeout(timeoutRunner, remainingMs);
|
|
2251
|
+
timeoutTimer.unref?.();
|
|
2252
|
+
}
|
|
2253
|
+
appendJsonl(eventsPath, JSON.stringify({
|
|
2254
|
+
type: "subagent.run.started",
|
|
2255
|
+
lifecycleArtifactVersion: SUBAGENT_LIFECYCLE_ARTIFACT_VERSION,
|
|
2256
|
+
ts: overallStartTime,
|
|
2257
|
+
runId: id,
|
|
2258
|
+
mode: statusPayload.mode,
|
|
2259
|
+
cwd,
|
|
2260
|
+
pid: process.pid,
|
|
2261
|
+
}));
|
|
2262
|
+
let flatIndex = 0;
|
|
2263
|
+
let stepCursor = 0;
|
|
2264
|
+
while (true) {
|
|
2265
|
+
if (interrupted || timedOut || stopped || turnBudgetExceeded)
|
|
2266
|
+
break;
|
|
2267
|
+
consumePendingAppendRequests();
|
|
2268
|
+
if (stepCursor >= steps.length)
|
|
2269
|
+
break;
|
|
2270
|
+
const stepIndex = stepCursor++;
|
|
2271
|
+
const step = steps[stepIndex];
|
|
2272
|
+
if (isDynamicRunnerGroup(step)) {
|
|
2273
|
+
const groupStartFlatIndex = flatIndex;
|
|
2274
|
+
let materialized;
|
|
2275
|
+
try {
|
|
2276
|
+
materialized = materializeDynamicParallelStep(step, outputs, stepIndex, { maxItems: config.dynamicFanoutMaxItems, allowRunnerFields: true });
|
|
2277
|
+
if (materialized.parallel.length > 1 && step.parallel.outputPath && !step.parallel.namespaceOutputPath) {
|
|
2278
|
+
throw new DynamicFanoutError(`Dynamic chain step ${stepIndex + 1} materialized ${materialized.parallel.length} items that resolve output to the same path: ${step.parallel.outputPath}. Remove the explicit output path or use an inherited relative agent output so each item can be isolated.`);
|
|
2279
|
+
}
|
|
2280
|
+
if (materialized.collectedOnEmpty)
|
|
2281
|
+
validateDynamicCollection(step.collect.outputSchema, materialized.collectedOnEmpty);
|
|
2282
|
+
}
|
|
2283
|
+
catch (error) {
|
|
2284
|
+
const now = Date.now();
|
|
2285
|
+
const message = error instanceof DynamicFanoutError ? error.message : error instanceof Error ? error.message : String(error);
|
|
2286
|
+
statusPayload.state = "failed";
|
|
2287
|
+
statusPayload.error = message;
|
|
2288
|
+
statusPayload.currentStep = flatIndex;
|
|
2289
|
+
const placeholder = statusPayload.steps[groupStartFlatIndex];
|
|
2290
|
+
if (placeholder) {
|
|
2291
|
+
placeholder.status = "failed";
|
|
2292
|
+
placeholder.error = message;
|
|
2293
|
+
placeholder.startedAt = now;
|
|
2294
|
+
placeholder.endedAt = now;
|
|
2295
|
+
placeholder.durationMs = 0;
|
|
2296
|
+
placeholder.exitCode = 1;
|
|
2297
|
+
}
|
|
2298
|
+
statusPayload.lastUpdate = now;
|
|
2299
|
+
markDynamicGraphGroup(stepIndex, "failed", message);
|
|
2300
|
+
writeStatusPayload();
|
|
2301
|
+
results.push({ agent: step.parallel.agent, output: message, error: message, success: false, exitCode: 1 });
|
|
2302
|
+
break;
|
|
2303
|
+
}
|
|
2304
|
+
const effectiveDynamicGroupAcceptance = resolveEffectiveAcceptance({
|
|
2305
|
+
explicit: step.acceptanceInput,
|
|
2306
|
+
agentName: step.parallel.agent,
|
|
2307
|
+
acceptanceRole: step.acceptanceRole,
|
|
2308
|
+
task: materialized.parallel.map((task) => task.task ?? step.parallel.task).join("\n") || step.parallel.task,
|
|
2309
|
+
mode: config.mode,
|
|
2310
|
+
async: true,
|
|
2311
|
+
dynamicGroup: true,
|
|
2312
|
+
});
|
|
2313
|
+
if (materialized.parallel.length === 0) {
|
|
2314
|
+
const now = Date.now();
|
|
2315
|
+
const collection = materialized.collectedOnEmpty ?? [];
|
|
2316
|
+
outputs[step.collect.as] = {
|
|
2317
|
+
text: JSON.stringify(collection),
|
|
2318
|
+
structured: collection,
|
|
2319
|
+
agent: step.parallel.agent,
|
|
2320
|
+
stepIndex,
|
|
2321
|
+
};
|
|
2322
|
+
statusPayload.outputs = outputs;
|
|
2323
|
+
const placeholder = statusPayload.steps[groupStartFlatIndex];
|
|
2324
|
+
if (placeholder) {
|
|
2325
|
+
placeholder.status = "complete";
|
|
2326
|
+
placeholder.startedAt = now;
|
|
2327
|
+
placeholder.endedAt = now;
|
|
2328
|
+
placeholder.durationMs = 0;
|
|
2329
|
+
}
|
|
2330
|
+
previousOutput = "Dynamic fanout produced 0 results.";
|
|
2331
|
+
const groupAcceptance = effectiveDynamicGroupAcceptance.explicit && !timedOut && !stopped
|
|
2332
|
+
? await evaluateAcceptance({
|
|
2333
|
+
acceptance: effectiveDynamicGroupAcceptance,
|
|
2334
|
+
output: "",
|
|
2335
|
+
report: aggregateAcceptanceReport({
|
|
2336
|
+
results: [],
|
|
2337
|
+
notes: "Dynamic fanout produced 0 results.",
|
|
2338
|
+
}),
|
|
2339
|
+
cwd,
|
|
2340
|
+
signal: combinedAbortSignal([timeoutAbortController.signal, stopAbortController.signal]),
|
|
2341
|
+
abortMessage: stopAbortController.signal.aborted ? stopMessage : timeoutMessage ?? "Subagent timed out.",
|
|
2342
|
+
})
|
|
2343
|
+
: undefined;
|
|
2344
|
+
const groupStopped = stopped || stopAbortController.signal.aborted;
|
|
2345
|
+
const groupTimedOut = !groupStopped && (timedOut || timeoutAbortController.signal.aborted);
|
|
2346
|
+
const effectiveGroupAcceptance = groupTimedOut || groupStopped ? undefined : groupAcceptance;
|
|
2347
|
+
if (placeholder && effectiveGroupAcceptance)
|
|
2348
|
+
placeholder.acceptance = effectiveGroupAcceptance;
|
|
2349
|
+
const groupAcceptanceFailure = effectiveGroupAcceptance ? acceptanceFailureMessage(effectiveGroupAcceptance) : undefined;
|
|
2350
|
+
if (groupTimedOut || groupStopped || groupAcceptanceFailure) {
|
|
2351
|
+
const errorMessage = groupStopped ? stopMessage : groupTimedOut ? timeoutMessage ?? "Subagent timed out." : groupAcceptanceFailure;
|
|
2352
|
+
statusPayload.state = groupStopped ? "stopped" : "failed";
|
|
2353
|
+
statusPayload.error = errorMessage;
|
|
2354
|
+
statusPayload.stopped = groupStopped ? true : statusPayload.stopped;
|
|
2355
|
+
if (placeholder) {
|
|
2356
|
+
placeholder.status = groupStopped ? "stopped" : "failed";
|
|
2357
|
+
placeholder.error = errorMessage;
|
|
2358
|
+
placeholder.exitCode = 1;
|
|
2359
|
+
placeholder.timedOut = groupTimedOut ? true : undefined;
|
|
2360
|
+
placeholder.stopped = groupStopped ? true : undefined;
|
|
2361
|
+
}
|
|
2362
|
+
markDynamicGraphGroup(stepIndex, groupStopped ? "stopped" : "failed", errorMessage, effectiveGroupAcceptance);
|
|
2363
|
+
statusPayload.lastUpdate = Date.now();
|
|
2364
|
+
writeStatusPayload();
|
|
2365
|
+
results.push({ agent: step.parallel.agent, output: errorMessage, error: errorMessage, success: false, exitCode: 1, timedOut: groupTimedOut ? true : undefined, stopped: groupStopped ? true : undefined, acceptance: effectiveGroupAcceptance });
|
|
2366
|
+
break;
|
|
2367
|
+
}
|
|
2368
|
+
flatIndex++;
|
|
2369
|
+
statusPayload.lastUpdate = now;
|
|
2370
|
+
markDynamicGraphGroup(stepIndex, "completed", undefined, effectiveGroupAcceptance);
|
|
2371
|
+
writeStatusPayload();
|
|
2372
|
+
continue;
|
|
2373
|
+
}
|
|
2374
|
+
const dynamicSteps = materialized.parallel.map((task, itemIndex) => {
|
|
2375
|
+
const thinkingOverride = step.thinkingOverrides?.[itemIndex];
|
|
2376
|
+
const model = thinkingOverride ? applyThinkingSuffix(step.parallel.model, thinkingOverride, true) : step.parallel.model;
|
|
2377
|
+
const thinking = thinkingOverride ? resolveEffectiveThinking(model, thinkingOverride) : undefined;
|
|
2378
|
+
const outputPath = step.parallel.namespaceOutputPath && step.parallel.outputPath
|
|
2379
|
+
? path.join(path.dirname(step.parallel.outputPath), `dynamic-${stepIndex}`, `${itemIndex}-${step.parallel.agent}`, path.basename(step.parallel.outputPath))
|
|
2380
|
+
: step.parallel.outputPath;
|
|
2381
|
+
const taskText = task.task ?? step.parallel.task;
|
|
2382
|
+
const materializedTask = step.parallel.namespaceOutputPath ? injectSingleOutputInstruction(taskText, outputPath, step.parallel) : taskText;
|
|
2383
|
+
return {
|
|
2384
|
+
...step.parallel,
|
|
2385
|
+
task: materializedTask,
|
|
2386
|
+
effectiveAcceptance: resolveEffectiveAcceptance({
|
|
2387
|
+
explicit: step.parallel.acceptanceInput,
|
|
2388
|
+
agentName: step.parallel.agent,
|
|
2389
|
+
acceptanceRole: step.parallel.acceptanceRole,
|
|
2390
|
+
task: materializedTask,
|
|
2391
|
+
mode: config.mode,
|
|
2392
|
+
async: true,
|
|
2393
|
+
dynamic: step.parallel.acceptanceInput === undefined,
|
|
2394
|
+
}),
|
|
2395
|
+
systemPrompt: step.parallel.namespaceOutputPath ? injectOutputPathSystemPrompt(step.parallel.systemPrompt ?? "", outputPath, step.parallel) : step.parallel.systemPrompt,
|
|
2396
|
+
outputPath,
|
|
2397
|
+
label: task.label ?? step.parallel.label,
|
|
2398
|
+
...(step.sessionFiles?.[itemIndex] ? { sessionFile: step.sessionFiles[itemIndex] } : {}),
|
|
2399
|
+
...(thinkingOverride ? {
|
|
2400
|
+
...(model ? { model } : {}),
|
|
2401
|
+
...(thinking ? { thinking } : {}),
|
|
2402
|
+
...(step.parallel.modelCandidates ? { modelCandidates: step.parallel.modelCandidates.map((candidate) => applyThinkingSuffix(candidate, thinkingOverride, true)) } : {}),
|
|
2403
|
+
} : {}),
|
|
2404
|
+
structuredOutput: undefined,
|
|
2405
|
+
structuredOutputSchema: step.parallel.structuredOutputSchema ?? step.parallel.structuredOutput?.schema,
|
|
2406
|
+
};
|
|
2407
|
+
});
|
|
2408
|
+
const dynamicFlatStepCount = Math.max(statusPayload.steps.length - 1 + dynamicSteps.length, 1);
|
|
2409
|
+
const dynamicStatusSteps = dynamicSteps.map((task, itemIndex) => {
|
|
2410
|
+
const transcriptPath = resolveAsyncStepTranscriptPath({ artifactsDir, artifactConfig, runId: id, agent: task.agent, flatIndex: groupStartFlatIndex + itemIndex, flatStepCount: dynamicFlatStepCount });
|
|
2411
|
+
return {
|
|
2412
|
+
agent: task.agent,
|
|
2413
|
+
phase: task.phase ?? step.phase,
|
|
2414
|
+
label: task.label,
|
|
2415
|
+
outputName: undefined,
|
|
2416
|
+
structured: Boolean(task.structuredOutputSchema),
|
|
2417
|
+
status: "pending",
|
|
2418
|
+
...(task.sessionFile ? { sessionFile: task.sessionFile } : {}),
|
|
2419
|
+
...(transcriptPath ? { transcriptPath } : {}),
|
|
2420
|
+
skills: task.skills,
|
|
2421
|
+
model: task.model,
|
|
2422
|
+
thinking: task.thinking,
|
|
2423
|
+
attemptedModels: task.modelCandidates && task.modelCandidates.length > 0 ? task.modelCandidates : task.model ? [task.model] : undefined,
|
|
2424
|
+
recentTools: [],
|
|
2425
|
+
recentOutput: [],
|
|
2426
|
+
};
|
|
2427
|
+
});
|
|
2428
|
+
statusPayload.steps.splice(groupStartFlatIndex, 1, ...dynamicStatusSteps);
|
|
2429
|
+
if (config.childIntercomTargets) {
|
|
2430
|
+
config.childIntercomTargets = statusPayload.steps.map((statusStep, index) => resolveSubagentIntercomTarget(id, statusStep.agent, index));
|
|
2431
|
+
}
|
|
2432
|
+
mutatingFailureStates.splice(groupStartFlatIndex, 1, ...dynamicStatusSteps.map(() => createMutatingFailureState()));
|
|
2433
|
+
pendingToolResults.splice(groupStartFlatIndex, 1, ...dynamicStatusSteps.map(() => undefined));
|
|
2434
|
+
const materializedDelta = dynamicStatusSteps.length - 1;
|
|
2435
|
+
for (const group of statusPayload.parallelGroups) {
|
|
2436
|
+
if (group.stepIndex === stepIndex) {
|
|
2437
|
+
group.start = groupStartFlatIndex;
|
|
2438
|
+
group.count = dynamicStatusSteps.length;
|
|
2439
|
+
}
|
|
2440
|
+
else if (group.start > groupStartFlatIndex) {
|
|
2441
|
+
group.start += materializedDelta;
|
|
2442
|
+
}
|
|
2443
|
+
}
|
|
2444
|
+
if (statusPayload.workflowGraph) {
|
|
2445
|
+
const shiftFlatIndexes = (nodes) => {
|
|
2446
|
+
for (const node of nodes) {
|
|
2447
|
+
if (node.stepIndex !== undefined && node.stepIndex > stepIndex && node.flatIndex !== undefined && node.flatIndex >= groupStartFlatIndex) {
|
|
2448
|
+
node.flatIndex += dynamicStatusSteps.length;
|
|
2449
|
+
}
|
|
2450
|
+
if (node.children)
|
|
2451
|
+
shiftFlatIndexes(node.children);
|
|
2452
|
+
}
|
|
2453
|
+
};
|
|
2454
|
+
shiftFlatIndexes(statusPayload.workflowGraph.nodes);
|
|
2455
|
+
const groupNode = statusPayload.workflowGraph.nodes.find((node) => node.id === `step-${stepIndex}`);
|
|
2456
|
+
if (groupNode) {
|
|
2457
|
+
groupNode.children = materialized.items.map((item, itemIndex) => ({
|
|
2458
|
+
id: `step-${stepIndex}-item-${item.idKey}`,
|
|
2459
|
+
kind: "agent",
|
|
2460
|
+
agent: step.parallel.agent,
|
|
2461
|
+
phase: dynamicSteps[itemIndex]?.phase ?? step.phase,
|
|
2462
|
+
label: dynamicSteps[itemIndex]?.label?.trim() || `${step.parallel.agent} ${item.key}`,
|
|
2463
|
+
status: "pending",
|
|
2464
|
+
flatIndex: groupStartFlatIndex + itemIndex,
|
|
2465
|
+
stepIndex,
|
|
2466
|
+
itemKey: item.key,
|
|
2467
|
+
structured: Boolean(dynamicSteps[itemIndex]?.structuredOutputSchema),
|
|
2468
|
+
}));
|
|
2469
|
+
}
|
|
2470
|
+
}
|
|
2471
|
+
writeStatusPayload();
|
|
2472
|
+
const concurrency = step.concurrency ?? MAX_PARALLEL_CONCURRENCY;
|
|
2473
|
+
const failFast = step.failFast ?? false;
|
|
2474
|
+
let aborted = false;
|
|
2475
|
+
const parallelResults = await mapConcurrent(dynamicSteps, concurrency, async (task, taskIdx) => {
|
|
2476
|
+
const fi = groupStartFlatIndex + taskIdx;
|
|
2477
|
+
if (timedOut)
|
|
2478
|
+
return timedOutStepResult(task.agent);
|
|
2479
|
+
if (stopped)
|
|
2480
|
+
return stoppedStepResult(task.agent);
|
|
2481
|
+
if (interrupted)
|
|
2482
|
+
return pausedStepResult(task.agent);
|
|
2483
|
+
if (aborted && failFast) {
|
|
2484
|
+
const skippedAt = Date.now();
|
|
2485
|
+
statusPayload.steps[fi].status = "failed";
|
|
2486
|
+
statusPayload.steps[fi].error = "Skipped due to fail-fast";
|
|
2487
|
+
statusPayload.steps[fi].startedAt = skippedAt;
|
|
2488
|
+
statusPayload.steps[fi].endedAt = skippedAt;
|
|
2489
|
+
statusPayload.steps[fi].durationMs = 0;
|
|
2490
|
+
statusPayload.steps[fi].exitCode = -1;
|
|
2491
|
+
statusPayload.lastUpdate = skippedAt;
|
|
2492
|
+
writeStatusPayload();
|
|
2493
|
+
return { agent: task.agent, output: "(skipped — fail-fast)", exitCode: -1, skipped: true };
|
|
2494
|
+
}
|
|
2495
|
+
const taskStartTime = Date.now();
|
|
2496
|
+
statusPayload.currentStep = fi;
|
|
2497
|
+
statusPayload.steps[fi].status = "running";
|
|
2498
|
+
statusPayload.steps[fi].error = undefined;
|
|
2499
|
+
statusPayload.steps[fi].activityState = undefined;
|
|
2500
|
+
resetStepLiveDetail(statusPayload.steps[fi]);
|
|
2501
|
+
statusPayload.steps[fi].startedAt = taskStartTime;
|
|
2502
|
+
statusPayload.steps[fi].lastActivityAt = taskStartTime;
|
|
2503
|
+
statusPayload.outputFile = path.join(asyncDir, `output-${fi}.log`);
|
|
2504
|
+
statusPayload.lastActivityAt = taskStartTime;
|
|
2505
|
+
statusPayload.lastUpdate = taskStartTime;
|
|
2506
|
+
writeStatusPayload();
|
|
2507
|
+
appendJsonl(eventsPath, JSON.stringify({ type: "subagent.step.started", ts: taskStartTime, runId: id, stepIndex: fi, agent: task.agent }));
|
|
2508
|
+
flushPendingStepSteers(fi);
|
|
2509
|
+
const singleResult = await runSingleStep(task, {
|
|
2510
|
+
previousOutput, placeholder, cwd, sessionEnabled,
|
|
2511
|
+
outputs,
|
|
2512
|
+
sessionDir: config.sessionDir ? path.join(config.sessionDir, `dynamic-${stepIndex}-${taskIdx}`) : undefined,
|
|
2513
|
+
artifactsDir, artifactConfig, id,
|
|
2514
|
+
flatIndex: fi, flatStepCount: Math.max(statusPayload.steps.length, 1),
|
|
2515
|
+
outputFile: path.join(asyncDir, `output-${fi}.log`),
|
|
2516
|
+
steerInboxDir: stepSteerInboxDir(asyncDir, fi),
|
|
2517
|
+
steerCapabilityPath: steerCapabilityPath(asyncDir, fi),
|
|
2518
|
+
steerAckDir: steerAcksDir(asyncDir, fi),
|
|
2519
|
+
piPackageRoot: config.piPackageRoot,
|
|
2520
|
+
piArgv1: config.piArgv1,
|
|
2521
|
+
childIntercomTarget: config.childIntercomTargets?.[fi],
|
|
2522
|
+
orchestratorIntercomTarget: config.controlIntercomTarget,
|
|
2523
|
+
nestedRoute: config.nestedRoute,
|
|
2524
|
+
registerInterrupt: (interrupt) => registerStepInterrupt(fi, interrupt),
|
|
2525
|
+
registerTimeout: (interrupt) => registerStepTimeout(fi, interrupt),
|
|
2526
|
+
registerStop: (stop) => registerStepStop(fi, stop),
|
|
2527
|
+
registerTurnBudgetAbort: (abort) => registerStepTurnBudgetAbort(fi, abort),
|
|
2528
|
+
timeoutSignal: timeoutAbortController.signal,
|
|
2529
|
+
stopSignal: stopAbortController.signal,
|
|
2530
|
+
timeoutMessage,
|
|
2531
|
+
stopMessage,
|
|
2532
|
+
turnBudget: config.turnBudget,
|
|
2533
|
+
onAttemptStart: (attempt) => updateStepModel(fi, attempt.model, attempt.thinking),
|
|
2534
|
+
onChildEvent: (event) => updateStepFromChildEvent(fi, event),
|
|
2535
|
+
onWriterProcess,
|
|
2536
|
+
skipAcceptance: () => timedOut || stopped,
|
|
2537
|
+
});
|
|
2538
|
+
const taskEndTime = Date.now();
|
|
2539
|
+
const childInterrupted = singleResult.interrupted === true;
|
|
2540
|
+
const childStopped = singleResult.stopped === true;
|
|
2541
|
+
statusPayload.steps[fi].status = stopped || childStopped ? "stopped" : timedOut ? "failed" : childInterrupted ? "paused" : singleResult.exitCode === 0 ? "complete" : "failed";
|
|
2542
|
+
statusPayload.steps[fi].endedAt = taskEndTime;
|
|
2543
|
+
statusPayload.steps[fi].durationMs = taskEndTime - taskStartTime;
|
|
2544
|
+
statusPayload.steps[fi].exitCode = stopped || childStopped ? 1 : timedOut ? 1 : childInterrupted ? 0 : singleResult.exitCode;
|
|
2545
|
+
statusPayload.steps[fi].timedOut = timedOut || singleResult.timedOut ? true : undefined;
|
|
2546
|
+
statusPayload.steps[fi].stopped = stopped || childStopped ? true : undefined;
|
|
2547
|
+
statusPayload.steps[fi].turnBudget = singleResult.turnBudget;
|
|
2548
|
+
statusPayload.steps[fi].turnBudgetExceeded = singleResult.turnBudgetExceeded;
|
|
2549
|
+
statusPayload.steps[fi].wrapUpRequested = singleResult.wrapUpRequested;
|
|
2550
|
+
statusPayload.steps[fi].toolBudget = singleResult.toolBudget;
|
|
2551
|
+
statusPayload.steps[fi].toolBudgetBlocked = singleResult.toolBudgetBlocked;
|
|
2552
|
+
if (singleResult.toolBudget)
|
|
2553
|
+
statusPayload.toolBudget = singleResult.toolBudget;
|
|
2554
|
+
if (singleResult.toolBudgetBlocked)
|
|
2555
|
+
statusPayload.toolBudgetBlocked = true;
|
|
2556
|
+
if (singleResult.turnBudget)
|
|
2557
|
+
statusPayload.turnBudget = singleResult.turnBudget;
|
|
2558
|
+
if (singleResult.turnBudgetExceeded)
|
|
2559
|
+
statusPayload.turnBudgetExceeded = true;
|
|
2560
|
+
if (singleResult.wrapUpRequested)
|
|
2561
|
+
statusPayload.wrapUpRequested = true;
|
|
2562
|
+
statusPayload.steps[fi].model = singleResult.model;
|
|
2563
|
+
statusPayload.steps[fi].thinking = resolveEffectiveThinking(singleResult.model, statusPayload.steps[fi].thinking);
|
|
2564
|
+
statusPayload.steps[fi].attemptedModels = singleResult.attemptedModels;
|
|
2565
|
+
statusPayload.steps[fi].modelAttempts = singleResult.modelAttempts;
|
|
2566
|
+
statusPayload.steps[fi].totalCost = singleResult.totalCost;
|
|
2567
|
+
statusPayload.steps[fi].error = stopped || childStopped ? stopMessage : timedOut ? (timeoutMessage ?? "Subagent timed out.") : singleResult.error;
|
|
2568
|
+
statusPayload.steps[fi].transcriptPath = singleResult.transcriptPath ?? statusPayload.steps[fi].transcriptPath;
|
|
2569
|
+
statusPayload.steps[fi].transcriptError = singleResult.transcriptError;
|
|
2570
|
+
statusPayload.steps[fi].structuredOutput = singleResult.structuredOutput;
|
|
2571
|
+
statusPayload.steps[fi].structuredOutputPath = singleResult.structuredOutputPath;
|
|
2572
|
+
statusPayload.steps[fi].structuredOutputSchemaPath = singleResult.structuredOutputSchemaPath;
|
|
2573
|
+
statusPayload.steps[fi].acceptance = singleResult.acceptance;
|
|
2574
|
+
statusPayload.steps[fi].watchdog = singleResult.watchdog;
|
|
2575
|
+
statusPayload.lastUpdate = taskEndTime;
|
|
2576
|
+
writeStatusPayload();
|
|
2577
|
+
appendJsonl(eventsPath, JSON.stringify({
|
|
2578
|
+
type: stopped || childStopped ? "subagent.step.stopped" : timedOut ? "subagent.step.failed" : childInterrupted ? "subagent.step.paused" : singleResult.exitCode === 0 ? "subagent.step.completed" : "subagent.step.failed",
|
|
2579
|
+
ts: taskEndTime, runId: id, stepIndex: fi, agent: task.agent,
|
|
2580
|
+
exitCode: stopped || childStopped ? 1 : timedOut ? 1 : childInterrupted ? 0 : singleResult.exitCode, durationMs: taskEndTime - taskStartTime,
|
|
2581
|
+
}));
|
|
2582
|
+
if (singleResult.exitCode !== 0 && failFast)
|
|
2583
|
+
aborted = true;
|
|
2584
|
+
return stopped || childStopped ? { ...singleResult, output: stopMessage, error: stopMessage, exitCode: 1, interrupted: false, timedOut: false, stopped: true, skipped: false } : timedOut ? { ...singleResult, output: timeoutMessage ?? "Subagent timed out.", error: timeoutMessage ?? "Subagent timed out.", exitCode: 1, interrupted: false, timedOut: true, skipped: false } : { ...singleResult, skipped: false };
|
|
2585
|
+
}, globalSemaphore);
|
|
2586
|
+
flatIndex += dynamicSteps.length;
|
|
2587
|
+
for (const pr of parallelResults) {
|
|
2588
|
+
results.push({
|
|
2589
|
+
agent: pr.agent,
|
|
2590
|
+
output: pr.output,
|
|
2591
|
+
error: pr.error,
|
|
2592
|
+
protocolError: pr.protocolError,
|
|
2593
|
+
success: pr.stopped !== true && pr.interrupted !== true && pr.exitCode === 0,
|
|
2594
|
+
exitCode: pr.interrupted === true ? 0 : pr.exitCode,
|
|
2595
|
+
skipped: pr.skipped,
|
|
2596
|
+
interrupted: pr.interrupted,
|
|
2597
|
+
timedOut: pr.timedOut,
|
|
2598
|
+
stopped: pr.stopped,
|
|
2599
|
+
turnBudget: pr.turnBudget,
|
|
2600
|
+
turnBudgetExceeded: pr.turnBudgetExceeded,
|
|
2601
|
+
wrapUpRequested: pr.wrapUpRequested,
|
|
2602
|
+
toolBudget: pr.toolBudget,
|
|
2603
|
+
toolBudgetBlocked: pr.toolBudgetBlocked,
|
|
2604
|
+
sessionFile: pr.sessionFile,
|
|
2605
|
+
intercomTarget: pr.intercomTarget,
|
|
2606
|
+
model: pr.model,
|
|
2607
|
+
attemptedModels: pr.attemptedModels,
|
|
2608
|
+
modelAttempts: pr.modelAttempts,
|
|
2609
|
+
totalCost: pr.totalCost,
|
|
2610
|
+
artifactPaths: pr.artifactPaths,
|
|
2611
|
+
transcriptPath: pr.transcriptPath,
|
|
2612
|
+
transcriptError: pr.transcriptError,
|
|
2613
|
+
structuredOutput: pr.structuredOutput,
|
|
2614
|
+
structuredOutputPath: pr.structuredOutputPath,
|
|
2615
|
+
structuredOutputSchemaPath: pr.structuredOutputSchemaPath,
|
|
2616
|
+
acceptance: pr.acceptance,
|
|
2617
|
+
watchdog: pr.watchdog,
|
|
2618
|
+
});
|
|
2619
|
+
}
|
|
2620
|
+
const collection = collectDynamicResults(step, materialized.items, parallelResults);
|
|
2621
|
+
const failures = parallelResults.filter((result) => result.exitCode !== 0 && result.exitCode !== -1);
|
|
2622
|
+
if (failures.length === 0) {
|
|
2623
|
+
try {
|
|
2624
|
+
validateDynamicCollection(step.collect.outputSchema, collection);
|
|
2625
|
+
outputs[step.collect.as] = {
|
|
2626
|
+
text: JSON.stringify(collection),
|
|
2627
|
+
structured: collection,
|
|
2628
|
+
agent: step.parallel.agent,
|
|
2629
|
+
stepIndex,
|
|
2630
|
+
};
|
|
2631
|
+
statusPayload.outputs = outputs;
|
|
2632
|
+
const groupAcceptance = !timedOut && !stopped
|
|
2633
|
+
? await evaluateAcceptance({
|
|
2634
|
+
acceptance: effectiveDynamicGroupAcceptance,
|
|
2635
|
+
output: "",
|
|
2636
|
+
report: aggregateAcceptanceReport({
|
|
2637
|
+
results: parallelResults,
|
|
2638
|
+
notes: `Dynamic fanout collected ${collection.length} result(s) into ${step.collect.as}.`,
|
|
2639
|
+
}),
|
|
2640
|
+
cwd,
|
|
2641
|
+
signal: combinedAbortSignal([timeoutAbortController.signal, stopAbortController.signal]),
|
|
2642
|
+
abortMessage: stopAbortController.signal.aborted ? stopMessage : timeoutMessage ?? "Subagent timed out.",
|
|
2643
|
+
})
|
|
2644
|
+
: undefined;
|
|
2645
|
+
const groupStopped = stopped || stopAbortController.signal.aborted;
|
|
2646
|
+
const groupTimedOut = !groupStopped && (timedOut || timeoutAbortController.signal.aborted);
|
|
2647
|
+
const effectiveGroupAcceptance = groupTimedOut || groupStopped ? undefined : groupAcceptance;
|
|
2648
|
+
const groupAcceptanceFailure = effectiveDynamicGroupAcceptance.explicit && effectiveGroupAcceptance ? acceptanceFailureMessage(effectiveGroupAcceptance) : undefined;
|
|
2649
|
+
const groupError = groupStopped ? stopMessage : groupTimedOut ? timeoutMessage ?? "Subagent timed out." : groupAcceptanceFailure;
|
|
2650
|
+
markDynamicGraphGroup(stepIndex, groupError ? groupStopped ? "stopped" : "failed" : "completed", groupError, effectiveGroupAcceptance);
|
|
2651
|
+
if (groupError) {
|
|
2652
|
+
results.push({
|
|
2653
|
+
agent: step.parallel.agent,
|
|
2654
|
+
output: groupError,
|
|
2655
|
+
error: groupError,
|
|
2656
|
+
success: false,
|
|
2657
|
+
exitCode: 1,
|
|
2658
|
+
timedOut: groupTimedOut ? true : undefined,
|
|
2659
|
+
stopped: groupStopped ? true : undefined,
|
|
2660
|
+
structuredOutput: collection,
|
|
2661
|
+
acceptance: effectiveGroupAcceptance,
|
|
2662
|
+
});
|
|
2663
|
+
statusPayload.error = groupError;
|
|
2664
|
+
statusPayload.stopped = groupStopped ? true : statusPayload.stopped;
|
|
2665
|
+
}
|
|
2666
|
+
}
|
|
2667
|
+
catch (error) {
|
|
2668
|
+
const message = error instanceof DynamicFanoutError ? error.message : error instanceof Error ? error.message : String(error);
|
|
2669
|
+
results.push({ agent: step.parallel.agent, output: message, error: message, success: false, exitCode: 1, structuredOutput: collection });
|
|
2670
|
+
statusPayload.error = message;
|
|
2671
|
+
markDynamicGraphGroup(stepIndex, "failed", message);
|
|
2672
|
+
}
|
|
2673
|
+
}
|
|
2674
|
+
previousOutput = aggregateParallelOutputs(parallelResults.map((r, i) => ({
|
|
2675
|
+
agent: r.agent,
|
|
2676
|
+
taskIndex: i,
|
|
2677
|
+
output: r.output,
|
|
2678
|
+
exitCode: r.exitCode,
|
|
2679
|
+
error: r.error,
|
|
2680
|
+
})), (i, agent) => `=== Dynamic Item ${i + 1} (${agent}, key ${materialized.items[i]?.key ?? i}) ===`);
|
|
2681
|
+
appendJsonl(eventsPath, JSON.stringify({
|
|
2682
|
+
type: "subagent.dynamic.completed",
|
|
2683
|
+
ts: Date.now(),
|
|
2684
|
+
runId: id,
|
|
2685
|
+
stepIndex,
|
|
2686
|
+
success: failures.length === 0,
|
|
2687
|
+
}));
|
|
2688
|
+
if (failures.length > 0)
|
|
2689
|
+
markDynamicGraphGroup(stepIndex, "failed", failures[0]?.error ?? "Dynamic fanout child failed.");
|
|
2690
|
+
statusPayload.lastUpdate = Date.now();
|
|
2691
|
+
writeStatusPayload();
|
|
2692
|
+
if (failures.length > 0 || statusPayload.error)
|
|
2693
|
+
break;
|
|
2694
|
+
continue;
|
|
2695
|
+
}
|
|
2696
|
+
if (isParallelGroup(step)) {
|
|
2697
|
+
const group = step;
|
|
2698
|
+
const concurrency = group.concurrency ?? MAX_PARALLEL_CONCURRENCY;
|
|
2699
|
+
const failFast = group.failFast ?? false;
|
|
2700
|
+
const groupStartFlatIndex = flatIndex;
|
|
2701
|
+
let aborted = false;
|
|
2702
|
+
let worktreeSetup;
|
|
2703
|
+
if (group.worktree) {
|
|
2704
|
+
const worktreeTaskCwdConflict = findWorktreeTaskCwdConflict(group.parallel, cwd);
|
|
2705
|
+
if (worktreeTaskCwdConflict) {
|
|
2706
|
+
const failedAt = Date.now();
|
|
2707
|
+
markParallelGroupSetupFailure({
|
|
2708
|
+
statusPayload,
|
|
2709
|
+
results,
|
|
2710
|
+
group,
|
|
2711
|
+
groupStartFlatIndex,
|
|
2712
|
+
setupError: formatWorktreeTaskCwdConflict(worktreeTaskCwdConflict, cwd),
|
|
2713
|
+
failedAt,
|
|
2714
|
+
statusPath,
|
|
2715
|
+
eventsPath,
|
|
2716
|
+
asyncDir,
|
|
2717
|
+
runId: id,
|
|
2718
|
+
stepIndex,
|
|
2719
|
+
});
|
|
2720
|
+
flatIndex += group.parallel.length;
|
|
2721
|
+
break;
|
|
2722
|
+
}
|
|
2723
|
+
try {
|
|
2724
|
+
worktreeSetup = createWorktrees(cwd, `${id}-s${stepIndex}`, group.parallel.length, {
|
|
2725
|
+
agents: group.parallel.map((task) => task.agent),
|
|
2726
|
+
setupHook: config.worktreeSetupHook
|
|
2727
|
+
? { hookPath: config.worktreeSetupHook, timeoutMs: config.worktreeSetupHookTimeoutMs }
|
|
2728
|
+
: undefined,
|
|
2729
|
+
baseDir: config.worktreeBaseDir,
|
|
2730
|
+
});
|
|
2731
|
+
}
|
|
2732
|
+
catch (error) {
|
|
2733
|
+
const setupError = error instanceof Error ? error.message : String(error);
|
|
2734
|
+
const failedAt = Date.now();
|
|
2735
|
+
markParallelGroupSetupFailure({
|
|
2736
|
+
statusPayload,
|
|
2737
|
+
results,
|
|
2738
|
+
group,
|
|
2739
|
+
groupStartFlatIndex,
|
|
2740
|
+
setupError,
|
|
2741
|
+
failedAt,
|
|
2742
|
+
statusPath,
|
|
2743
|
+
eventsPath,
|
|
2744
|
+
asyncDir,
|
|
2745
|
+
runId: id,
|
|
2746
|
+
stepIndex,
|
|
2747
|
+
});
|
|
2748
|
+
flatIndex += group.parallel.length;
|
|
2749
|
+
break;
|
|
2750
|
+
}
|
|
2751
|
+
}
|
|
2752
|
+
try {
|
|
2753
|
+
if (group.worktree)
|
|
2754
|
+
ensureParallelProgressFile(cwd, group);
|
|
2755
|
+
const groupStartTime = Date.now();
|
|
2756
|
+
markParallelGroupRunning({
|
|
2757
|
+
statusPayload,
|
|
2758
|
+
group,
|
|
2759
|
+
groupStartFlatIndex,
|
|
2760
|
+
groupStartTime,
|
|
2761
|
+
statusPath,
|
|
2762
|
+
eventsPath,
|
|
2763
|
+
asyncDir,
|
|
2764
|
+
runId: id,
|
|
2765
|
+
stepIndex,
|
|
2766
|
+
});
|
|
2767
|
+
const parallelResults = await mapConcurrent(group.parallel, concurrency, async (task, taskIdx) => {
|
|
2768
|
+
const fi = groupStartFlatIndex + taskIdx;
|
|
2769
|
+
if (timedOut)
|
|
2770
|
+
return timedOutStepResult(task.agent);
|
|
2771
|
+
if (stopped)
|
|
2772
|
+
return stoppedStepResult(task.agent);
|
|
2773
|
+
if (interrupted)
|
|
2774
|
+
return pausedStepResult(task.agent);
|
|
2775
|
+
if (aborted && failFast) {
|
|
2776
|
+
const skippedAt = Date.now();
|
|
2777
|
+
statusPayload.steps[fi].status = "failed";
|
|
2778
|
+
statusPayload.steps[fi].error = "Skipped due to fail-fast";
|
|
2779
|
+
statusPayload.steps[fi].startedAt = skippedAt;
|
|
2780
|
+
statusPayload.steps[fi].endedAt = skippedAt;
|
|
2781
|
+
statusPayload.steps[fi].durationMs = 0;
|
|
2782
|
+
statusPayload.steps[fi].exitCode = -1;
|
|
2783
|
+
statusPayload.steps[fi].activityState = undefined;
|
|
2784
|
+
statusPayload.lastUpdate = skippedAt;
|
|
2785
|
+
writeStatusPayload();
|
|
2786
|
+
appendJsonl(eventsPath, JSON.stringify({
|
|
2787
|
+
type: "subagent.step.failed", ts: skippedAt, runId: id, stepIndex: fi, agent: task.agent, exitCode: -1, durationMs: 0,
|
|
2788
|
+
}));
|
|
2789
|
+
return { agent: task.agent, output: "(skipped — fail-fast)", exitCode: -1, skipped: true };
|
|
2790
|
+
}
|
|
2791
|
+
const taskStartTime = Date.now();
|
|
2792
|
+
statusPayload.currentStep = fi;
|
|
2793
|
+
statusPayload.steps[fi].status = "running";
|
|
2794
|
+
statusPayload.steps[fi].error = undefined;
|
|
2795
|
+
statusPayload.steps[fi].activityState = undefined;
|
|
2796
|
+
resetStepLiveDetail(statusPayload.steps[fi]);
|
|
2797
|
+
statusPayload.steps[fi].startedAt = taskStartTime;
|
|
2798
|
+
statusPayload.steps[fi].endedAt = undefined;
|
|
2799
|
+
statusPayload.steps[fi].durationMs = undefined;
|
|
2800
|
+
statusPayload.steps[fi].lastActivityAt = taskStartTime;
|
|
2801
|
+
statusPayload.outputFile = path.join(asyncDir, `output-${fi}.log`);
|
|
2802
|
+
statusPayload.lastActivityAt = taskStartTime;
|
|
2803
|
+
statusPayload.lastUpdate = taskStartTime;
|
|
2804
|
+
writeStatusPayload();
|
|
2805
|
+
appendJsonl(eventsPath, JSON.stringify({
|
|
2806
|
+
type: "subagent.step.started", ts: taskStartTime, runId: id, stepIndex: fi, agent: task.agent,
|
|
2807
|
+
}));
|
|
2808
|
+
const taskSessionDir = config.sessionDir
|
|
2809
|
+
? path.join(config.sessionDir, `parallel-${taskIdx}`)
|
|
2810
|
+
: undefined;
|
|
2811
|
+
const { taskForRun, taskCwd } = prepareParallelTaskRun(task, cwd, worktreeSetup, taskIdx);
|
|
2812
|
+
flushPendingStepSteers(fi);
|
|
2813
|
+
const singleResult = await runSingleStep(taskForRun, {
|
|
2814
|
+
previousOutput, placeholder, cwd: taskCwd, sessionEnabled,
|
|
2815
|
+
outputs,
|
|
2816
|
+
sessionDir: taskSessionDir,
|
|
2817
|
+
artifactsDir, artifactConfig, id,
|
|
2818
|
+
flatIndex: fi, flatStepCount: Math.max(statusPayload.steps.length, 1),
|
|
2819
|
+
outputFile: path.join(asyncDir, `output-${fi}.log`),
|
|
2820
|
+
steerInboxDir: stepSteerInboxDir(asyncDir, fi),
|
|
2821
|
+
steerCapabilityPath: steerCapabilityPath(asyncDir, fi),
|
|
2822
|
+
steerAckDir: steerAcksDir(asyncDir, fi),
|
|
2823
|
+
piPackageRoot: config.piPackageRoot,
|
|
2824
|
+
piArgv1: config.piArgv1,
|
|
2825
|
+
childIntercomTarget: config.childIntercomTargets?.[fi],
|
|
2826
|
+
orchestratorIntercomTarget: config.controlIntercomTarget,
|
|
2827
|
+
nestedRoute: config.nestedRoute,
|
|
2828
|
+
registerInterrupt: (interrupt) => registerStepInterrupt(fi, interrupt),
|
|
2829
|
+
registerTimeout: (interrupt) => registerStepTimeout(fi, interrupt),
|
|
2830
|
+
registerStop: (stop) => registerStepStop(fi, stop),
|
|
2831
|
+
registerTurnBudgetAbort: (abort) => registerStepTurnBudgetAbort(fi, abort),
|
|
2832
|
+
timeoutSignal: timeoutAbortController.signal,
|
|
2833
|
+
stopSignal: stopAbortController.signal,
|
|
2834
|
+
timeoutMessage,
|
|
2835
|
+
stopMessage,
|
|
2836
|
+
turnBudget: config.turnBudget,
|
|
2837
|
+
onAttemptStart: (attempt) => updateStepModel(fi, attempt.model, attempt.thinking),
|
|
2838
|
+
onChildEvent: (event) => updateStepFromChildEvent(fi, event),
|
|
2839
|
+
onWriterProcess,
|
|
2840
|
+
skipAcceptance: () => timedOut || stopped,
|
|
2841
|
+
});
|
|
2842
|
+
if (task.sessionFile) {
|
|
2843
|
+
latestSessionFile = task.sessionFile;
|
|
2844
|
+
}
|
|
2845
|
+
const taskEndTime = Date.now();
|
|
2846
|
+
const taskDuration = taskEndTime - taskStartTime;
|
|
2847
|
+
const childInterrupted = singleResult.interrupted === true;
|
|
2848
|
+
const childStopped = singleResult.stopped === true;
|
|
2849
|
+
statusPayload.steps[fi].status = stopped || childStopped ? "stopped" : timedOut ? "failed" : childInterrupted ? "paused" : singleResult.exitCode === 0 ? "complete" : "failed";
|
|
2850
|
+
statusPayload.steps[fi].endedAt = taskEndTime;
|
|
2851
|
+
statusPayload.steps[fi].durationMs = taskDuration;
|
|
2852
|
+
statusPayload.steps[fi].exitCode = stopped || childStopped ? 1 : timedOut ? 1 : childInterrupted ? 0 : singleResult.exitCode;
|
|
2853
|
+
statusPayload.steps[fi].timedOut = timedOut || singleResult.timedOut ? true : undefined;
|
|
2854
|
+
statusPayload.steps[fi].stopped = stopped || childStopped ? true : undefined;
|
|
2855
|
+
statusPayload.steps[fi].turnBudget = singleResult.turnBudget;
|
|
2856
|
+
statusPayload.steps[fi].turnBudgetExceeded = singleResult.turnBudgetExceeded;
|
|
2857
|
+
statusPayload.steps[fi].wrapUpRequested = singleResult.wrapUpRequested;
|
|
2858
|
+
statusPayload.steps[fi].toolBudget = singleResult.toolBudget;
|
|
2859
|
+
statusPayload.steps[fi].toolBudgetBlocked = singleResult.toolBudgetBlocked;
|
|
2860
|
+
if (singleResult.toolBudget)
|
|
2861
|
+
statusPayload.toolBudget = singleResult.toolBudget;
|
|
2862
|
+
if (singleResult.toolBudgetBlocked)
|
|
2863
|
+
statusPayload.toolBudgetBlocked = true;
|
|
2864
|
+
if (singleResult.turnBudget)
|
|
2865
|
+
statusPayload.turnBudget = singleResult.turnBudget;
|
|
2866
|
+
if (singleResult.turnBudgetExceeded)
|
|
2867
|
+
statusPayload.turnBudgetExceeded = true;
|
|
2868
|
+
if (singleResult.wrapUpRequested)
|
|
2869
|
+
statusPayload.wrapUpRequested = true;
|
|
2870
|
+
statusPayload.steps[fi].model = singleResult.model;
|
|
2871
|
+
statusPayload.steps[fi].thinking = resolveEffectiveThinking(singleResult.model, statusPayload.steps[fi].thinking);
|
|
2872
|
+
statusPayload.steps[fi].attemptedModels = singleResult.attemptedModels;
|
|
2873
|
+
statusPayload.steps[fi].modelAttempts = singleResult.modelAttempts;
|
|
2874
|
+
statusPayload.steps[fi].totalCost = singleResult.totalCost;
|
|
2875
|
+
statusPayload.steps[fi].error = stopped || childStopped ? stopMessage : timedOut ? (timeoutMessage ?? "Subagent timed out.") : singleResult.error;
|
|
2876
|
+
statusPayload.steps[fi].transcriptPath = singleResult.transcriptPath ?? statusPayload.steps[fi].transcriptPath;
|
|
2877
|
+
statusPayload.steps[fi].transcriptError = singleResult.transcriptError;
|
|
2878
|
+
statusPayload.steps[fi].structuredOutput = singleResult.structuredOutput;
|
|
2879
|
+
statusPayload.steps[fi].structuredOutputPath = singleResult.structuredOutputPath;
|
|
2880
|
+
statusPayload.steps[fi].structuredOutputSchemaPath = singleResult.structuredOutputSchemaPath;
|
|
2881
|
+
statusPayload.steps[fi].acceptance = singleResult.acceptance;
|
|
2882
|
+
statusPayload.steps[fi].watchdog = singleResult.watchdog;
|
|
2883
|
+
statusPayload.lastUpdate = taskEndTime;
|
|
2884
|
+
writeStatusPayload();
|
|
2885
|
+
appendJsonl(eventsPath, JSON.stringify({
|
|
2886
|
+
type: stopped || childStopped ? "subagent.step.stopped" : timedOut ? "subagent.step.failed" : childInterrupted ? "subagent.step.paused" : singleResult.exitCode === 0 ? "subagent.step.completed" : "subagent.step.failed",
|
|
2887
|
+
ts: taskEndTime, runId: id, stepIndex: fi, agent: task.agent,
|
|
2888
|
+
exitCode: stopped || childStopped ? 1 : timedOut ? 1 : childInterrupted ? 0 : singleResult.exitCode, durationMs: taskDuration,
|
|
2889
|
+
}));
|
|
2890
|
+
if (singleResult.completionGuardTriggered) {
|
|
2891
|
+
const event = buildControlEvent({
|
|
2892
|
+
from: statusPayload.steps[fi].activityState,
|
|
2893
|
+
to: "needs_attention",
|
|
2894
|
+
runId: id,
|
|
2895
|
+
agent: task.agent,
|
|
2896
|
+
index: fi,
|
|
2897
|
+
ts: taskEndTime,
|
|
2898
|
+
message: `${task.agent} completed without making edits for an implementation task`,
|
|
2899
|
+
reason: "completion_guard",
|
|
2900
|
+
});
|
|
2901
|
+
appendControlEvent(event);
|
|
2902
|
+
}
|
|
2903
|
+
if (singleResult.exitCode !== 0 && failFast)
|
|
2904
|
+
aborted = true;
|
|
2905
|
+
return stopped || childStopped ? { ...singleResult, output: stopMessage, error: stopMessage, exitCode: 1, interrupted: false, timedOut: false, stopped: true, skipped: false } : timedOut ? { ...singleResult, output: timeoutMessage ?? "Subagent timed out.", error: timeoutMessage ?? "Subagent timed out.", exitCode: 1, interrupted: false, timedOut: true, skipped: false } : { ...singleResult, skipped: false };
|
|
2906
|
+
}, globalSemaphore);
|
|
2907
|
+
flatIndex += group.parallel.length;
|
|
2908
|
+
for (let t = 0; t < group.parallel.length; t++) {
|
|
2909
|
+
const fi = groupStartFlatIndex + t;
|
|
2910
|
+
const sessionTokens = config.sessionDir
|
|
2911
|
+
? parseSessionTokens(path.join(config.sessionDir, `parallel-${t}`))
|
|
2912
|
+
: null;
|
|
2913
|
+
const taskTokens = sessionTokens ?? tokenUsageFromAttempts(parallelResults[t]?.modelAttempts);
|
|
2914
|
+
if (!taskTokens)
|
|
2915
|
+
continue;
|
|
2916
|
+
statusPayload.steps[fi].tokens = taskTokens;
|
|
2917
|
+
previousCumulativeTokens = {
|
|
2918
|
+
input: previousCumulativeTokens.input + taskTokens.input,
|
|
2919
|
+
output: previousCumulativeTokens.output + taskTokens.output,
|
|
2920
|
+
total: previousCumulativeTokens.total + taskTokens.total,
|
|
2921
|
+
};
|
|
2922
|
+
}
|
|
2923
|
+
statusPayload.totalTokens = { ...previousCumulativeTokens };
|
|
2924
|
+
statusPayload.lastUpdate = Date.now();
|
|
2925
|
+
writeStatusPayload();
|
|
2926
|
+
for (const pr of parallelResults) {
|
|
2927
|
+
results.push({
|
|
2928
|
+
agent: pr.agent,
|
|
2929
|
+
output: pr.output,
|
|
2930
|
+
error: pr.error,
|
|
2931
|
+
protocolError: pr.protocolError,
|
|
2932
|
+
success: pr.stopped !== true && pr.interrupted !== true && pr.exitCode === 0,
|
|
2933
|
+
exitCode: pr.interrupted === true ? 0 : pr.exitCode,
|
|
2934
|
+
skipped: pr.skipped,
|
|
2935
|
+
interrupted: pr.interrupted,
|
|
2936
|
+
timedOut: pr.timedOut,
|
|
2937
|
+
stopped: pr.stopped,
|
|
2938
|
+
turnBudget: pr.turnBudget,
|
|
2939
|
+
turnBudgetExceeded: pr.turnBudgetExceeded,
|
|
2940
|
+
wrapUpRequested: pr.wrapUpRequested,
|
|
2941
|
+
toolBudget: pr.toolBudget,
|
|
2942
|
+
toolBudgetBlocked: pr.toolBudgetBlocked,
|
|
2943
|
+
sessionFile: pr.sessionFile,
|
|
2944
|
+
intercomTarget: pr.intercomTarget,
|
|
2945
|
+
model: pr.model,
|
|
2946
|
+
attemptedModels: pr.attemptedModels,
|
|
2947
|
+
modelAttempts: pr.modelAttempts,
|
|
2948
|
+
totalCost: pr.totalCost,
|
|
2949
|
+
artifactPaths: pr.artifactPaths,
|
|
2950
|
+
transcriptPath: pr.transcriptPath,
|
|
2951
|
+
transcriptError: pr.transcriptError,
|
|
2952
|
+
structuredOutput: pr.structuredOutput,
|
|
2953
|
+
structuredOutputPath: pr.structuredOutputPath,
|
|
2954
|
+
structuredOutputSchemaPath: pr.structuredOutputSchemaPath,
|
|
2955
|
+
acceptance: pr.acceptance,
|
|
2956
|
+
watchdog: pr.watchdog,
|
|
2957
|
+
});
|
|
2958
|
+
}
|
|
2959
|
+
for (let t = 0; t < group.parallel.length; t++) {
|
|
2960
|
+
const outputName = group.parallel[t]?.outputName;
|
|
2961
|
+
if (outputName)
|
|
2962
|
+
outputs[outputName] = outputEntryFromAsyncResult({
|
|
2963
|
+
agent: parallelResults[t].agent,
|
|
2964
|
+
output: parallelResults[t].output,
|
|
2965
|
+
structuredOutput: parallelResults[t].structuredOutput,
|
|
2966
|
+
}, stepIndex);
|
|
2967
|
+
}
|
|
2968
|
+
statusPayload.outputs = outputs;
|
|
2969
|
+
previousOutput = aggregateParallelOutputs(parallelResults.map((r) => ({
|
|
2970
|
+
agent: r.agent,
|
|
2971
|
+
output: r.output,
|
|
2972
|
+
exitCode: r.exitCode,
|
|
2973
|
+
error: r.error,
|
|
2974
|
+
model: r.model,
|
|
2975
|
+
attemptedModels: r.attemptedModels,
|
|
2976
|
+
})));
|
|
2977
|
+
previousOutput = appendParallelWorktreeSummary(previousOutput, worktreeSetup, asyncDir, stepIndex, group);
|
|
2978
|
+
appendJsonl(eventsPath, JSON.stringify({
|
|
2979
|
+
type: "subagent.parallel.completed",
|
|
2980
|
+
ts: Date.now(),
|
|
2981
|
+
runId: id,
|
|
2982
|
+
stepIndex,
|
|
2983
|
+
success: parallelResults.every((r) => r.exitCode === 0 || r.exitCode === -1),
|
|
2984
|
+
}));
|
|
2985
|
+
if (parallelResults.some((r) => r.exitCode !== 0 && r.exitCode !== -1)) {
|
|
2986
|
+
break;
|
|
2987
|
+
}
|
|
2988
|
+
}
|
|
2989
|
+
finally {
|
|
2990
|
+
if (worktreeSetup)
|
|
2991
|
+
cleanupWorktrees(worktreeSetup);
|
|
2992
|
+
}
|
|
2993
|
+
}
|
|
2994
|
+
else {
|
|
2995
|
+
const seqStep = step;
|
|
2996
|
+
const stepStartTime = Date.now();
|
|
2997
|
+
statusPayload.currentStep = flatIndex;
|
|
2998
|
+
statusPayload.steps[flatIndex].status = "running";
|
|
2999
|
+
statusPayload.steps[flatIndex].activityState = undefined;
|
|
3000
|
+
statusPayload.activityState = undefined;
|
|
3001
|
+
resetStepLiveDetail(statusPayload.steps[flatIndex]);
|
|
3002
|
+
statusPayload.steps[flatIndex].skills = seqStep.skills;
|
|
3003
|
+
statusPayload.steps[flatIndex].startedAt = stepStartTime;
|
|
3004
|
+
statusPayload.steps[flatIndex].lastActivityAt = stepStartTime;
|
|
3005
|
+
statusPayload.lastActivityAt = stepStartTime;
|
|
3006
|
+
statusPayload.lastUpdate = stepStartTime;
|
|
3007
|
+
statusPayload.outputFile = path.join(asyncDir, `output-${flatIndex}.log`);
|
|
3008
|
+
writeStatusPayload();
|
|
3009
|
+
appendJsonl(eventsPath, JSON.stringify({
|
|
3010
|
+
type: "subagent.step.started",
|
|
3011
|
+
ts: stepStartTime,
|
|
3012
|
+
runId: id,
|
|
3013
|
+
stepIndex: flatIndex,
|
|
3014
|
+
agent: seqStep.agent,
|
|
3015
|
+
}));
|
|
3016
|
+
flushPendingStepSteers(flatIndex);
|
|
3017
|
+
const singleResult = await runSingleStep(seqStep, {
|
|
3018
|
+
previousOutput, placeholder, cwd, sessionEnabled,
|
|
3019
|
+
outputs: statusPayload.mode === "single" ? undefined : outputs,
|
|
3020
|
+
sessionDir: config.sessionDir,
|
|
3021
|
+
artifactsDir, artifactConfig, id,
|
|
3022
|
+
flatIndex, flatStepCount: Math.max(statusPayload.steps.length, 1),
|
|
3023
|
+
outputFile: path.join(asyncDir, `output-${flatIndex}.log`),
|
|
3024
|
+
steerInboxDir: stepSteerInboxDir(asyncDir, flatIndex),
|
|
3025
|
+
steerCapabilityPath: steerCapabilityPath(asyncDir, flatIndex),
|
|
3026
|
+
steerAckDir: steerAcksDir(asyncDir, flatIndex),
|
|
3027
|
+
piPackageRoot: config.piPackageRoot,
|
|
3028
|
+
piArgv1: config.piArgv1,
|
|
3029
|
+
childIntercomTarget: config.childIntercomTargets?.[flatIndex],
|
|
3030
|
+
orchestratorIntercomTarget: config.controlIntercomTarget,
|
|
3031
|
+
nestedRoute: config.nestedRoute,
|
|
3032
|
+
registerInterrupt: (interrupt) => registerStepInterrupt(flatIndex, interrupt),
|
|
3033
|
+
registerTimeout: (interrupt) => registerStepTimeout(flatIndex, interrupt),
|
|
3034
|
+
registerStop: (stop) => registerStepStop(flatIndex, stop),
|
|
3035
|
+
registerTurnBudgetAbort: (abort) => registerStepTurnBudgetAbort(flatIndex, abort),
|
|
3036
|
+
timeoutSignal: timeoutAbortController.signal,
|
|
3037
|
+
stopSignal: stopAbortController.signal,
|
|
3038
|
+
timeoutMessage,
|
|
3039
|
+
stopMessage,
|
|
3040
|
+
turnBudget: config.turnBudget,
|
|
3041
|
+
onAttemptStart: (attempt) => updateStepModel(flatIndex, attempt.model, attempt.thinking),
|
|
3042
|
+
onChildEvent: (event) => updateStepFromChildEvent(flatIndex, event),
|
|
3043
|
+
onWriterProcess,
|
|
3044
|
+
skipAcceptance: () => timedOut || stopped,
|
|
3045
|
+
});
|
|
3046
|
+
if (seqStep.sessionFile) {
|
|
3047
|
+
latestSessionFile = seqStep.sessionFile;
|
|
3048
|
+
}
|
|
3049
|
+
previousOutput = singleResult.output;
|
|
3050
|
+
const childStopped = singleResult.stopped === true;
|
|
3051
|
+
results.push({
|
|
3052
|
+
agent: singleResult.agent,
|
|
3053
|
+
output: stopped || childStopped ? stopMessage : timedOut ? (timeoutMessage ?? "Subagent timed out.") : singleResult.output,
|
|
3054
|
+
error: stopped || childStopped ? stopMessage : timedOut ? (timeoutMessage ?? "Subagent timed out.") : singleResult.error,
|
|
3055
|
+
protocolError: singleResult.protocolError,
|
|
3056
|
+
success: !stopped && !childStopped && !timedOut && singleResult.interrupted !== true && singleResult.exitCode === 0,
|
|
3057
|
+
exitCode: stopped || childStopped ? 1 : timedOut ? 1 : singleResult.interrupted === true ? 0 : singleResult.exitCode,
|
|
3058
|
+
sessionFile: singleResult.sessionFile,
|
|
3059
|
+
intercomTarget: singleResult.intercomTarget,
|
|
3060
|
+
model: singleResult.model,
|
|
3061
|
+
attemptedModels: singleResult.attemptedModels,
|
|
3062
|
+
modelAttempts: singleResult.modelAttempts,
|
|
3063
|
+
totalCost: singleResult.totalCost,
|
|
3064
|
+
artifactPaths: singleResult.artifactPaths,
|
|
3065
|
+
transcriptPath: singleResult.transcriptPath,
|
|
3066
|
+
transcriptError: singleResult.transcriptError,
|
|
3067
|
+
structuredOutput: singleResult.structuredOutput,
|
|
3068
|
+
structuredOutputPath: singleResult.structuredOutputPath,
|
|
3069
|
+
structuredOutputSchemaPath: singleResult.structuredOutputSchemaPath,
|
|
3070
|
+
acceptance: singleResult.acceptance,
|
|
3071
|
+
watchdog: singleResult.watchdog,
|
|
3072
|
+
interrupted: singleResult.interrupted,
|
|
3073
|
+
timedOut: timedOut || singleResult.timedOut ? true : undefined,
|
|
3074
|
+
stopped: stopped || childStopped ? true : undefined,
|
|
3075
|
+
turnBudget: singleResult.turnBudget,
|
|
3076
|
+
turnBudgetExceeded: singleResult.turnBudgetExceeded,
|
|
3077
|
+
wrapUpRequested: singleResult.wrapUpRequested,
|
|
3078
|
+
toolBudget: singleResult.toolBudget,
|
|
3079
|
+
toolBudgetBlocked: singleResult.toolBudgetBlocked,
|
|
3080
|
+
});
|
|
3081
|
+
if (seqStep.outputName) {
|
|
3082
|
+
outputs[seqStep.outputName] = outputEntryFromAsyncResult({
|
|
3083
|
+
agent: singleResult.agent,
|
|
3084
|
+
output: singleResult.output,
|
|
3085
|
+
structuredOutput: singleResult.structuredOutput,
|
|
3086
|
+
}, stepIndex);
|
|
3087
|
+
}
|
|
3088
|
+
statusPayload.outputs = outputs;
|
|
3089
|
+
const cumulativeTokens = config.sessionDir ? parseSessionTokens(config.sessionDir) : null;
|
|
3090
|
+
let stepTokens = cumulativeTokens
|
|
3091
|
+
? {
|
|
3092
|
+
input: cumulativeTokens.input - previousCumulativeTokens.input,
|
|
3093
|
+
output: cumulativeTokens.output - previousCumulativeTokens.output,
|
|
3094
|
+
total: cumulativeTokens.total - previousCumulativeTokens.total,
|
|
3095
|
+
}
|
|
3096
|
+
: null;
|
|
3097
|
+
if (cumulativeTokens) {
|
|
3098
|
+
previousCumulativeTokens = cumulativeTokens;
|
|
3099
|
+
}
|
|
3100
|
+
else {
|
|
3101
|
+
stepTokens = tokenUsageFromAttempts(singleResult.modelAttempts);
|
|
3102
|
+
if (stepTokens) {
|
|
3103
|
+
previousCumulativeTokens = {
|
|
3104
|
+
input: previousCumulativeTokens.input + stepTokens.input,
|
|
3105
|
+
output: previousCumulativeTokens.output + stepTokens.output,
|
|
3106
|
+
total: previousCumulativeTokens.total + stepTokens.total,
|
|
3107
|
+
};
|
|
3108
|
+
}
|
|
3109
|
+
}
|
|
3110
|
+
const stepEndTime = Date.now();
|
|
3111
|
+
const childInterrupted = singleResult.interrupted === true;
|
|
3112
|
+
statusPayload.steps[flatIndex].status = stopped || childStopped ? "stopped" : timedOut ? "failed" : childInterrupted ? "paused" : singleResult.exitCode === 0 ? "complete" : "failed";
|
|
3113
|
+
statusPayload.steps[flatIndex].endedAt = stepEndTime;
|
|
3114
|
+
statusPayload.steps[flatIndex].durationMs = stepEndTime - stepStartTime;
|
|
3115
|
+
statusPayload.steps[flatIndex].exitCode = stopped || childStopped ? 1 : timedOut ? 1 : childInterrupted ? 0 : singleResult.exitCode;
|
|
3116
|
+
statusPayload.steps[flatIndex].timedOut = timedOut || singleResult.timedOut ? true : undefined;
|
|
3117
|
+
statusPayload.steps[flatIndex].stopped = stopped || childStopped ? true : undefined;
|
|
3118
|
+
statusPayload.steps[flatIndex].turnBudget = singleResult.turnBudget;
|
|
3119
|
+
statusPayload.steps[flatIndex].turnBudgetExceeded = singleResult.turnBudgetExceeded;
|
|
3120
|
+
statusPayload.steps[flatIndex].wrapUpRequested = singleResult.wrapUpRequested;
|
|
3121
|
+
statusPayload.steps[flatIndex].toolBudget = singleResult.toolBudget;
|
|
3122
|
+
statusPayload.steps[flatIndex].toolBudgetBlocked = singleResult.toolBudgetBlocked;
|
|
3123
|
+
if (singleResult.toolBudget)
|
|
3124
|
+
statusPayload.toolBudget = singleResult.toolBudget;
|
|
3125
|
+
if (singleResult.toolBudgetBlocked)
|
|
3126
|
+
statusPayload.toolBudgetBlocked = true;
|
|
3127
|
+
if (singleResult.turnBudget)
|
|
3128
|
+
statusPayload.turnBudget = singleResult.turnBudget;
|
|
3129
|
+
if (singleResult.turnBudgetExceeded)
|
|
3130
|
+
statusPayload.turnBudgetExceeded = true;
|
|
3131
|
+
if (singleResult.wrapUpRequested)
|
|
3132
|
+
statusPayload.wrapUpRequested = true;
|
|
3133
|
+
statusPayload.steps[flatIndex].model = singleResult.model;
|
|
3134
|
+
statusPayload.steps[flatIndex].thinking = resolveEffectiveThinking(singleResult.model, statusPayload.steps[flatIndex].thinking);
|
|
3135
|
+
statusPayload.steps[flatIndex].attemptedModels = singleResult.attemptedModels;
|
|
3136
|
+
statusPayload.steps[flatIndex].modelAttempts = singleResult.modelAttempts;
|
|
3137
|
+
statusPayload.steps[flatIndex].totalCost = singleResult.totalCost;
|
|
3138
|
+
statusPayload.steps[flatIndex].error = stopped || childStopped ? stopMessage : timedOut ? (timeoutMessage ?? "Subagent timed out.") : singleResult.error;
|
|
3139
|
+
statusPayload.steps[flatIndex].transcriptPath = singleResult.transcriptPath ?? statusPayload.steps[flatIndex].transcriptPath;
|
|
3140
|
+
statusPayload.steps[flatIndex].transcriptError = singleResult.transcriptError;
|
|
3141
|
+
statusPayload.steps[flatIndex].structuredOutput = singleResult.structuredOutput;
|
|
3142
|
+
statusPayload.steps[flatIndex].structuredOutputPath = singleResult.structuredOutputPath;
|
|
3143
|
+
statusPayload.steps[flatIndex].structuredOutputSchemaPath = singleResult.structuredOutputSchemaPath;
|
|
3144
|
+
statusPayload.steps[flatIndex].acceptance = singleResult.acceptance;
|
|
3145
|
+
statusPayload.steps[flatIndex].watchdog = singleResult.watchdog;
|
|
3146
|
+
if (stepTokens) {
|
|
3147
|
+
statusPayload.steps[flatIndex].tokens = stepTokens;
|
|
3148
|
+
statusPayload.totalTokens = { ...previousCumulativeTokens };
|
|
3149
|
+
}
|
|
3150
|
+
statusPayload.lastUpdate = stepEndTime;
|
|
3151
|
+
writeStatusPayload();
|
|
3152
|
+
appendJsonl(eventsPath, JSON.stringify({
|
|
3153
|
+
type: stopped || childStopped ? "subagent.step.stopped" : timedOut ? "subagent.step.failed" : childInterrupted ? "subagent.step.paused" : singleResult.exitCode === 0 ? "subagent.step.completed" : "subagent.step.failed",
|
|
3154
|
+
ts: stepEndTime,
|
|
3155
|
+
runId: id,
|
|
3156
|
+
stepIndex: flatIndex,
|
|
3157
|
+
agent: seqStep.agent,
|
|
3158
|
+
exitCode: stopped || childStopped ? 1 : timedOut ? 1 : childInterrupted ? 0 : singleResult.exitCode,
|
|
3159
|
+
durationMs: stepEndTime - stepStartTime,
|
|
3160
|
+
tokens: stepTokens,
|
|
3161
|
+
}));
|
|
3162
|
+
if (singleResult.completionGuardTriggered) {
|
|
3163
|
+
const event = buildControlEvent({
|
|
3164
|
+
from: statusPayload.steps[flatIndex].activityState,
|
|
3165
|
+
to: "needs_attention",
|
|
3166
|
+
runId: id,
|
|
3167
|
+
agent: seqStep.agent,
|
|
3168
|
+
index: flatIndex,
|
|
3169
|
+
ts: stepEndTime,
|
|
3170
|
+
message: `${seqStep.agent} completed without making edits for an implementation task`,
|
|
3171
|
+
reason: "completion_guard",
|
|
3172
|
+
});
|
|
3173
|
+
appendControlEvent(event);
|
|
3174
|
+
}
|
|
3175
|
+
flatIndex++;
|
|
3176
|
+
if (singleResult.exitCode !== 0) {
|
|
3177
|
+
break;
|
|
3178
|
+
}
|
|
3179
|
+
}
|
|
3180
|
+
}
|
|
3181
|
+
let summary = results.map((r) => `${r.agent}:\n${r.output}`).join("\n\n");
|
|
3182
|
+
let truncated = false;
|
|
3183
|
+
if (maxOutput) {
|
|
3184
|
+
const config = { ...DEFAULT_MAX_OUTPUT, ...maxOutput };
|
|
3185
|
+
const lastArtifactPath = results[results.length - 1]?.artifactPaths?.outputPath;
|
|
3186
|
+
const truncResult = truncateOutput(summary, config, lastArtifactPath);
|
|
3187
|
+
if (truncResult.truncated) {
|
|
3188
|
+
summary = truncResult.text;
|
|
3189
|
+
truncated = true;
|
|
3190
|
+
}
|
|
3191
|
+
}
|
|
3192
|
+
const resultMode = config.resultMode ?? statusPayload.mode;
|
|
3193
|
+
const totalCost = results.reduce((sum, result) => ({
|
|
3194
|
+
inputTokens: sum.inputTokens + (result.totalCost?.inputTokens ?? 0),
|
|
3195
|
+
outputTokens: sum.outputTokens + (result.totalCost?.outputTokens ?? 0),
|
|
3196
|
+
costUsd: sum.costUsd + (result.totalCost?.costUsd ?? 0),
|
|
3197
|
+
}), { inputTokens: 0, outputTokens: 0, costUsd: 0 });
|
|
3198
|
+
const finalTotalCost = totalCost.inputTokens > 0 || totalCost.outputTokens > 0 || totalCost.costUsd > 0 ? totalCost : undefined;
|
|
3199
|
+
const finalFlatAgents = statusPayload.steps.map((step) => step.agent);
|
|
3200
|
+
const agentName = finalFlatAgents.length === 1
|
|
3201
|
+
? finalFlatAgents[0]
|
|
3202
|
+
: resultMode === "parallel"
|
|
3203
|
+
? `parallel:${finalFlatAgents.join("+")}`
|
|
3204
|
+
: `chain:${finalFlatAgents.join("->")}`;
|
|
3205
|
+
let sessionFile;
|
|
3206
|
+
let shareUrl;
|
|
3207
|
+
let gistUrl;
|
|
3208
|
+
let shareError;
|
|
3209
|
+
if (shareEnabled) {
|
|
3210
|
+
sessionFile = config.sessionDir
|
|
3211
|
+
? (findLatestSessionFile(config.sessionDir) ?? undefined)
|
|
3212
|
+
: undefined;
|
|
3213
|
+
if (!sessionFile && latestSessionFile) {
|
|
3214
|
+
sessionFile = latestSessionFile;
|
|
3215
|
+
}
|
|
3216
|
+
if (sessionFile) {
|
|
3217
|
+
try {
|
|
3218
|
+
const exportDir = config.sessionDir ?? path.dirname(sessionFile);
|
|
3219
|
+
const htmlPath = await exportSessionHtml(sessionFile, exportDir, config.piPackageRoot);
|
|
3220
|
+
const share = createShareLink(htmlPath);
|
|
3221
|
+
if ("error" in share)
|
|
3222
|
+
shareError = share.error;
|
|
3223
|
+
else {
|
|
3224
|
+
shareUrl = share.shareUrl;
|
|
3225
|
+
gistUrl = share.gistUrl;
|
|
3226
|
+
}
|
|
3227
|
+
}
|
|
3228
|
+
catch (err) {
|
|
3229
|
+
shareError = String(err);
|
|
3230
|
+
}
|
|
3231
|
+
}
|
|
3232
|
+
else {
|
|
3233
|
+
shareError = "Session file not found.";
|
|
3234
|
+
}
|
|
3235
|
+
}
|
|
3236
|
+
if (activityTimer) {
|
|
3237
|
+
clearInterval(activityTimer);
|
|
3238
|
+
activityTimer = undefined;
|
|
3239
|
+
}
|
|
3240
|
+
if (timeoutTimer) {
|
|
3241
|
+
clearTimeout(timeoutTimer);
|
|
3242
|
+
timeoutTimer = undefined;
|
|
3243
|
+
}
|
|
3244
|
+
statusPayload.state = stopped ? "stopped" : timedOut || turnBudgetExceeded ? "failed" : interrupted ? "paused" : results.every((r) => r.success) ? "complete" : "failed";
|
|
3245
|
+
closeSteerInbox(asyncDir, statusPayload.state);
|
|
3246
|
+
disposeControlInbox();
|
|
3247
|
+
for (const request of consumeSteerRequests(asyncDir))
|
|
3248
|
+
deliverSteerRequest(request);
|
|
3249
|
+
const effectiveSessionFile = sessionFile ?? latestSessionFile;
|
|
3250
|
+
const steeringLifecycle = steeringStatus(statusPayload);
|
|
3251
|
+
for (const request of steeringLifecycle.recent) {
|
|
3252
|
+
let changed = false;
|
|
3253
|
+
for (const target of request.targets) {
|
|
3254
|
+
if (target.state !== "scheduled" && target.state !== "routed")
|
|
3255
|
+
continue;
|
|
3256
|
+
changed = true;
|
|
3257
|
+
updateSteeringLifecycleTarget(request.id, target.index, "failed", Date.now(), { reason: "child terminated before steering delivery" });
|
|
3258
|
+
markSteeringAttention(target.index);
|
|
3259
|
+
emitSteeringEvent("subagent.steer.failed", { type: "steer", id: request.id, ts: request.requestedAt, message: "child terminated before steering delivery" }, target.index, { reason: "child terminated before steering delivery" });
|
|
3260
|
+
}
|
|
3261
|
+
if (changed)
|
|
3262
|
+
emitTerminalSteeringNotice(request.id, `Steering failed for run ${id}: child terminated before delivery.`);
|
|
3263
|
+
}
|
|
3264
|
+
const runEndedAt = Date.now();
|
|
3265
|
+
statusPayload.activityState = undefined;
|
|
3266
|
+
if (stopped) {
|
|
3267
|
+
statusPayload.stopped = true;
|
|
3268
|
+
statusPayload.error = stopMessage;
|
|
3269
|
+
}
|
|
3270
|
+
if (timedOut) {
|
|
3271
|
+
statusPayload.timedOut = true;
|
|
3272
|
+
statusPayload.error = timeoutMessage ?? "Subagent timed out.";
|
|
3273
|
+
}
|
|
3274
|
+
if (turnBudgetExceeded && !statusPayload.error) {
|
|
3275
|
+
const budget = statusPayload.turnBudget;
|
|
3276
|
+
statusPayload.error = budget ? turnBudgetExceededMessage(budget, budget.turnCount) : "Subagent exceeded turn budget.";
|
|
3277
|
+
}
|
|
3278
|
+
statusPayload.endedAt = runEndedAt;
|
|
3279
|
+
statusPayload.lastUpdate = runEndedAt;
|
|
3280
|
+
statusPayload.sessionFile = effectiveSessionFile;
|
|
3281
|
+
statusPayload.totalCost = finalTotalCost;
|
|
3282
|
+
statusPayload.shareUrl = shareUrl;
|
|
3283
|
+
statusPayload.gistUrl = gistUrl;
|
|
3284
|
+
statusPayload.shareError = shareError;
|
|
3285
|
+
if (statusPayload.state === "failed" && !statusPayload.error) {
|
|
3286
|
+
const failedStep = statusPayload.steps.find((s) => s.status === "failed");
|
|
3287
|
+
if (failedStep?.agent) {
|
|
3288
|
+
statusPayload.error = `Step failed: ${failedStep.agent}`;
|
|
3289
|
+
}
|
|
3290
|
+
}
|
|
3291
|
+
writeStatusPayload();
|
|
3292
|
+
appendJsonl(eventsPath, JSON.stringify({
|
|
3293
|
+
type: "subagent.run.completed",
|
|
3294
|
+
lifecycleArtifactVersion: SUBAGENT_LIFECYCLE_ARTIFACT_VERSION,
|
|
3295
|
+
ts: runEndedAt,
|
|
3296
|
+
runId: id,
|
|
3297
|
+
status: statusPayload.state,
|
|
3298
|
+
durationMs: runEndedAt - overallStartTime,
|
|
3299
|
+
totalTokens: statusPayload.totalTokens,
|
|
3300
|
+
totalCost: finalTotalCost,
|
|
3301
|
+
}));
|
|
3302
|
+
writeRunLog(logPath, {
|
|
3303
|
+
id,
|
|
3304
|
+
mode: statusPayload.mode,
|
|
3305
|
+
cwd,
|
|
3306
|
+
startedAt: overallStartTime,
|
|
3307
|
+
endedAt: runEndedAt,
|
|
3308
|
+
steps: statusPayload.steps.map((step) => ({
|
|
3309
|
+
agent: step.agent,
|
|
3310
|
+
status: step.status,
|
|
3311
|
+
durationMs: step.durationMs,
|
|
3312
|
+
})),
|
|
3313
|
+
summary,
|
|
3314
|
+
truncated,
|
|
3315
|
+
artifactsDir,
|
|
3316
|
+
sessionFile: effectiveSessionFile,
|
|
3317
|
+
shareUrl,
|
|
3318
|
+
shareError,
|
|
3319
|
+
});
|
|
3320
|
+
try {
|
|
3321
|
+
writeAtomicJson(resultPath, {
|
|
3322
|
+
lifecycleArtifactVersion: SUBAGENT_LIFECYCLE_ARTIFACT_VERSION,
|
|
3323
|
+
id,
|
|
3324
|
+
agent: agentName,
|
|
3325
|
+
mode: resultMode,
|
|
3326
|
+
success: !stopped && !timedOut && !turnBudgetExceeded && !interrupted && results.every((r) => r.success),
|
|
3327
|
+
state: stopped ? "stopped" : timedOut || turnBudgetExceeded ? "failed" : interrupted ? "paused" : results.every((r) => r.success) ? "complete" : "failed",
|
|
3328
|
+
summary: stopped ? stopMessage : timedOut ? (timeoutMessage ?? "Subagent timed out.") : turnBudgetExceeded ? (statusPayload.error ?? "Subagent exceeded turn budget.") : interrupted ? "Paused after interrupt. Waiting for explicit next action." : summary,
|
|
3329
|
+
...(config.timeoutMs !== undefined ? { timeoutMs: config.timeoutMs } : {}),
|
|
3330
|
+
...(config.deadlineAt !== undefined ? { deadlineAt: config.deadlineAt } : {}),
|
|
3331
|
+
...(statusPayload.turnBudget ? { turnBudget: statusPayload.turnBudget } : {}),
|
|
3332
|
+
...(statusPayload.turnBudgetExceeded ? { turnBudgetExceeded: true } : {}),
|
|
3333
|
+
...(statusPayload.wrapUpRequested ? { wrapUpRequested: true } : {}),
|
|
3334
|
+
...(statusPayload.toolBudget ? { toolBudget: statusPayload.toolBudget } : {}),
|
|
3335
|
+
...(statusPayload.toolBudgetBlocked ? { toolBudgetBlocked: true } : {}),
|
|
3336
|
+
...(stopped ? { stopped: true, error: stopMessage } : timedOut ? { timedOut: true, error: timeoutMessage ?? "Subagent timed out." } : turnBudgetExceeded ? { error: statusPayload.error ?? "Subagent exceeded turn budget." } : {}),
|
|
3337
|
+
results: results.map((r) => ({
|
|
3338
|
+
agent: r.agent,
|
|
3339
|
+
output: r.output,
|
|
3340
|
+
error: r.error,
|
|
3341
|
+
protocolError: r.protocolError,
|
|
3342
|
+
success: r.success,
|
|
3343
|
+
skipped: r.skipped || undefined,
|
|
3344
|
+
interrupted: r.interrupted || undefined,
|
|
3345
|
+
timedOut: r.timedOut || undefined,
|
|
3346
|
+
stopped: r.stopped || undefined,
|
|
3347
|
+
turnBudget: r.turnBudget,
|
|
3348
|
+
turnBudgetExceeded: r.turnBudgetExceeded || undefined,
|
|
3349
|
+
wrapUpRequested: r.wrapUpRequested || undefined,
|
|
3350
|
+
toolBudget: r.toolBudget,
|
|
3351
|
+
toolBudgetBlocked: r.toolBudgetBlocked || undefined,
|
|
3352
|
+
sessionFile: r.sessionFile,
|
|
3353
|
+
intercomTarget: r.intercomTarget,
|
|
3354
|
+
model: r.model,
|
|
3355
|
+
attemptedModels: r.attemptedModels,
|
|
3356
|
+
modelAttempts: r.modelAttempts,
|
|
3357
|
+
totalCost: r.totalCost,
|
|
3358
|
+
artifactPaths: r.artifactPaths,
|
|
3359
|
+
truncated: r.truncated,
|
|
3360
|
+
transcriptPath: r.transcriptPath,
|
|
3361
|
+
transcriptError: r.transcriptError,
|
|
3362
|
+
structuredOutput: r.structuredOutput,
|
|
3363
|
+
structuredOutputPath: r.structuredOutputPath,
|
|
3364
|
+
structuredOutputSchemaPath: r.structuredOutputSchemaPath,
|
|
3365
|
+
acceptance: r.acceptance,
|
|
3366
|
+
watchdog: r.watchdog,
|
|
3367
|
+
})),
|
|
3368
|
+
outputs,
|
|
3369
|
+
workflowGraph: statusPayload.workflowGraph,
|
|
3370
|
+
exitCode: stopped || timedOut || turnBudgetExceeded ? 1 : interrupted || results.every((r) => r.success) ? 0 : 1,
|
|
3371
|
+
timestamp: runEndedAt,
|
|
3372
|
+
durationMs: runEndedAt - overallStartTime,
|
|
3373
|
+
totalTokens: statusPayload.totalTokens,
|
|
3374
|
+
totalCost: finalTotalCost,
|
|
3375
|
+
truncated,
|
|
3376
|
+
artifactsDir,
|
|
3377
|
+
cwd,
|
|
3378
|
+
asyncDir,
|
|
3379
|
+
sessionId: config.sessionId,
|
|
3380
|
+
sessionFile: effectiveSessionFile,
|
|
3381
|
+
intercomTarget: config.controlIntercomTarget,
|
|
3382
|
+
shareUrl,
|
|
3383
|
+
gistUrl,
|
|
3384
|
+
shareError,
|
|
3385
|
+
...(taskIndex !== undefined && { taskIndex }),
|
|
3386
|
+
...(totalTasks !== undefined && { totalTasks }),
|
|
3387
|
+
});
|
|
3388
|
+
}
|
|
3389
|
+
catch (err) {
|
|
3390
|
+
console.error(`Failed to write result file ${resultPath}:`, err);
|
|
3391
|
+
}
|
|
3392
|
+
}
|
|
3393
|
+
async function waitForStartupControl(controlPath, token, action, timeoutMs = 30_000) {
|
|
3394
|
+
const deadline = Date.now() + timeoutMs;
|
|
3395
|
+
while (Date.now() <= deadline) {
|
|
3396
|
+
if (fs.existsSync(controlPath)) {
|
|
3397
|
+
let payload;
|
|
3398
|
+
try {
|
|
3399
|
+
payload = JSON.parse(fs.readFileSync(controlPath, "utf-8"));
|
|
3400
|
+
}
|
|
3401
|
+
catch (error) {
|
|
3402
|
+
throw new Error(`Failed to read runner startup control '${controlPath}': ${error instanceof Error ? error.message : String(error)}`);
|
|
3403
|
+
}
|
|
3404
|
+
if (payload.token !== token)
|
|
3405
|
+
throw new Error("Runner startup control token does not match the acquired session lease.");
|
|
3406
|
+
if (payload.action === action)
|
|
3407
|
+
return;
|
|
3408
|
+
if (payload.action !== "ack" && payload.action !== "proceed")
|
|
3409
|
+
throw new Error("Runner startup control action is invalid.");
|
|
3410
|
+
}
|
|
3411
|
+
await new Promise((resolve) => setTimeout(resolve, 20));
|
|
3412
|
+
}
|
|
3413
|
+
throw new Error(`Timed out after ${timeoutMs}ms waiting for runner startup control '${action}'.`);
|
|
3414
|
+
}
|
|
3415
|
+
async function runConfiguredSubagent(config) {
|
|
3416
|
+
let lease;
|
|
3417
|
+
let startupCommitted = config.revivalLease === undefined;
|
|
3418
|
+
const startupPath = path.join(config.asyncDir, "runner-startup.json");
|
|
3419
|
+
const startupAckPath = path.join(config.asyncDir, "runner-startup-ack.json");
|
|
3420
|
+
const startupProceedPath = path.join(config.asyncDir, "runner-startup-proceed.json");
|
|
3421
|
+
const releaseOnExit = () => {
|
|
3422
|
+
try {
|
|
3423
|
+
lease?.release();
|
|
3424
|
+
}
|
|
3425
|
+
catch {
|
|
3426
|
+
// Exit cleanup is best effort; a dead-owner lease is reclaimed on the next revival.
|
|
3427
|
+
}
|
|
3428
|
+
};
|
|
3429
|
+
process.once("exit", releaseOnExit);
|
|
3430
|
+
try {
|
|
3431
|
+
if (config.revivalLease) {
|
|
3432
|
+
lease = acquireSessionLease(config.revivalLease);
|
|
3433
|
+
writeAtomicJson(startupPath, { state: "ready", token: lease.owner.token, pid: process.pid, owner: lease.owner });
|
|
3434
|
+
await waitForStartupControl(startupAckPath, lease.owner.token, "ack");
|
|
3435
|
+
writeAtomicJson(startupPath, { state: "acknowledged", token: lease.owner.token, pid: process.pid });
|
|
3436
|
+
await waitForStartupControl(startupProceedPath, lease.owner.token, "proceed");
|
|
3437
|
+
startupCommitted = true;
|
|
3438
|
+
for (const controlPath of [startupAckPath, startupProceedPath]) {
|
|
3439
|
+
try {
|
|
3440
|
+
fs.rmSync(controlPath, { force: true });
|
|
3441
|
+
}
|
|
3442
|
+
catch {
|
|
3443
|
+
// Startup control cleanup is best effort after the parent commits the run.
|
|
3444
|
+
}
|
|
3445
|
+
}
|
|
3446
|
+
}
|
|
3447
|
+
await runSubagent(config, lease ? (writer) => lease.updateWriter(writer) : undefined);
|
|
3448
|
+
}
|
|
3449
|
+
catch (error) {
|
|
3450
|
+
if (config.revivalLease && !startupCommitted) {
|
|
3451
|
+
try {
|
|
3452
|
+
writeAtomicJson(startupPath, { state: "error", pid: process.pid, error: error instanceof Error ? error.message : String(error) });
|
|
3453
|
+
}
|
|
3454
|
+
catch {
|
|
3455
|
+
// The parent will time out and terminate this runner if the handshake cannot be written.
|
|
3456
|
+
}
|
|
3457
|
+
}
|
|
3458
|
+
throw error;
|
|
3459
|
+
}
|
|
3460
|
+
finally {
|
|
3461
|
+
process.off("exit", releaseOnExit);
|
|
3462
|
+
if (lease) {
|
|
3463
|
+
try {
|
|
3464
|
+
lease.release();
|
|
3465
|
+
}
|
|
3466
|
+
catch (error) {
|
|
3467
|
+
console.error("Failed to release session revival lease:", error);
|
|
3468
|
+
}
|
|
3469
|
+
}
|
|
3470
|
+
}
|
|
3471
|
+
}
|
|
3472
|
+
function startConfiguredSubagent(config) {
|
|
3473
|
+
runConfiguredSubagent(config).catch((runErr) => {
|
|
3474
|
+
console.error("Subagent runner error:", runErr);
|
|
3475
|
+
process.exit(1);
|
|
3476
|
+
});
|
|
3477
|
+
}
|
|
3478
|
+
const configArg = process.argv[2];
|
|
3479
|
+
if (configArg) {
|
|
3480
|
+
try {
|
|
3481
|
+
const configJson = fs.readFileSync(configArg, "utf-8");
|
|
3482
|
+
const config = JSON.parse(configJson);
|
|
3483
|
+
try {
|
|
3484
|
+
fs.unlinkSync(configArg);
|
|
3485
|
+
}
|
|
3486
|
+
catch {
|
|
3487
|
+
// Temp config cleanup is best effort.
|
|
3488
|
+
}
|
|
3489
|
+
startConfiguredSubagent(config);
|
|
3490
|
+
}
|
|
3491
|
+
catch (err) {
|
|
3492
|
+
console.error("Subagent runner error:", err);
|
|
3493
|
+
process.exit(1);
|
|
3494
|
+
}
|
|
3495
|
+
}
|
|
3496
|
+
else {
|
|
3497
|
+
let input = "";
|
|
3498
|
+
process.stdin.setEncoding("utf-8");
|
|
3499
|
+
process.stdin.on("data", (chunk) => {
|
|
3500
|
+
input += chunk;
|
|
3501
|
+
});
|
|
3502
|
+
process.stdin.on("end", () => {
|
|
3503
|
+
try {
|
|
3504
|
+
const config = JSON.parse(input);
|
|
3505
|
+
startConfiguredSubagent(config);
|
|
3506
|
+
}
|
|
3507
|
+
catch (err) {
|
|
3508
|
+
console.error("Subagent runner error:", err);
|
|
3509
|
+
process.exit(1);
|
|
3510
|
+
}
|
|
3511
|
+
});
|
|
3512
|
+
}
|
|
3513
|
+
//# sourceMappingURL=subagent-runner.js.map
|