@selesai/code 0.13.13 → 0.13.14
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/dist/bun/cli.d.ts +2 -0
- package/dist/bun/cli.js +10 -0
- package/dist/bun/register-bedrock.d.ts +1 -0
- package/dist/bun/register-bedrock.js +3 -0
- package/dist/bun/restore-sandbox-env.d.ts +16 -0
- package/dist/bun/restore-sandbox-env.js +35 -0
- package/dist/cli/args.d.ts +59 -0
- package/dist/cli/args.js +428 -0
- package/dist/cli/args.test.d.ts +1 -0
- package/dist/cli/args.test.js +32 -0
- package/dist/cli/config-selector.d.ts +15 -0
- package/dist/cli/config-selector.js +30 -0
- package/dist/cli/credential-print.d.ts +22 -0
- package/dist/cli/credential-print.js +116 -0
- package/dist/cli/file-processor.d.ts +14 -0
- package/dist/cli/file-processor.js +69 -0
- package/dist/cli/initial-message.d.ts +17 -0
- package/dist/cli/initial-message.js +21 -0
- package/dist/cli/list-models.d.ts +8 -0
- package/dist/cli/list-models.js +97 -0
- package/dist/cli/project-trust.d.ts +9 -0
- package/dist/cli/project-trust.js +47 -0
- package/dist/cli/session-picker.d.ts +9 -0
- package/dist/cli/session-picker.js +35 -0
- package/dist/cli/startup-ui.d.ts +22 -0
- package/dist/cli/startup-ui.js +172 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +17 -0
- package/dist/config.d.ts +181 -0
- package/dist/config.js +788 -0
- package/dist/core/agent-session-auto-handoff.test.d.ts +1 -0
- package/dist/core/agent-session-auto-handoff.test.js +183 -0
- package/dist/core/agent-session-length-continuation.test.d.ts +1 -0
- package/dist/core/agent-session-length-continuation.test.js +107 -0
- package/dist/core/agent-session-runtime.d.ts +118 -0
- package/dist/core/agent-session-runtime.js +305 -0
- package/dist/core/agent-session-services.d.ts +84 -0
- package/dist/core/agent-session-services.js +132 -0
- package/dist/core/agent-session-skill-block.test.d.ts +1 -0
- package/dist/core/agent-session-skill-block.test.js +19 -0
- package/dist/core/agent-session.d.ts +713 -0
- package/dist/core/agent-session.js +3054 -0
- package/dist/core/agents.d.ts +52 -0
- package/dist/core/agents.js +237 -0
- package/dist/core/auth-guidance.d.ts +4 -0
- package/dist/core/auth-guidance.js +20 -0
- package/dist/core/auth-storage.d.ts +61 -0
- package/dist/core/auth-storage.js +249 -0
- package/dist/core/bash-executor.d.ts +31 -0
- package/dist/core/bash-executor.js +110 -0
- package/dist/core/built-in-extensions.d.ts +2 -0
- package/dist/core/built-in-extensions.js +2 -0
- package/dist/core/cache-stats.d.ts +48 -0
- package/dist/core/cache-stats.js +100 -0
- package/dist/core/compaction/branch-summarization.d.ts +97 -0
- package/dist/core/compaction/branch-summarization.js +246 -0
- package/dist/core/compaction/compaction.d.ts +141 -0
- package/dist/core/compaction/compaction.js +659 -0
- package/dist/core/compaction/index.d.ts +6 -0
- package/dist/core/compaction/index.js +6 -0
- package/dist/core/compaction/utils.d.ts +37 -0
- package/dist/core/compaction/utils.js +141 -0
- package/dist/core/defaults.d.ts +3 -0
- package/dist/core/defaults.js +10 -0
- package/dist/core/diagnostics.d.ts +15 -0
- package/dist/core/diagnostics.js +1 -0
- package/dist/core/event-bus.d.ts +8 -0
- package/dist/core/event-bus.js +24 -0
- package/dist/core/exec.d.ts +28 -0
- package/dist/core/exec.js +74 -0
- package/dist/core/experimental.d.ts +5 -0
- package/dist/core/experimental.js +7 -0
- package/dist/core/export-html/ansi-to-html.d.ts +21 -0
- package/dist/core/export-html/ansi-to-html.js +248 -0
- package/dist/core/export-html/index.d.ts +36 -0
- package/dist/core/export-html/index.js +225 -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 +33 -0
- package/dist/core/export-html/tool-renderer.js +107 -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 +11 -0
- package/dist/core/extensions/index.js +8 -0
- package/dist/core/extensions/loader.d.ts +22 -0
- package/dist/core/extensions/loader.js +632 -0
- package/dist/core/extensions/loader.test.d.ts +1 -0
- package/dist/core/extensions/loader.test.js +21 -0
- package/dist/core/extensions/runner.d.ts +176 -0
- package/dist/core/extensions/runner.js +1016 -0
- package/dist/core/extensions/types.d.ts +1313 -0
- package/dist/core/extensions/types.js +44 -0
- package/dist/core/extensions/wrapper.d.ts +19 -0
- package/dist/core/extensions/wrapper.js +40 -0
- package/dist/core/footer-data-provider.d.ts +63 -0
- package/dist/core/footer-data-provider.js +337 -0
- package/dist/core/git-command.d.ts +8 -0
- package/dist/core/git-command.js +48 -0
- package/dist/core/handoff.d.ts +11 -0
- package/dist/core/handoff.js +49 -0
- package/dist/core/http-dispatcher.d.ts +21 -0
- package/dist/core/http-dispatcher.js +90 -0
- package/dist/core/index.d.ts +12 -0
- package/dist/core/index.js +12 -0
- package/dist/core/keybindings.d.ts +421 -0
- package/dist/core/keybindings.js +295 -0
- package/dist/core/llama/client.d.ts +66 -0
- package/dist/core/llama/client.js +308 -0
- package/dist/core/llama/huggingface.d.ts +22 -0
- package/dist/core/llama/huggingface.js +140 -0
- package/dist/core/llama/index.d.ts +2 -0
- package/dist/core/llama/index.js +207 -0
- package/dist/core/llama/provider.d.ts +11 -0
- package/dist/core/llama/provider.js +143 -0
- package/dist/core/llama/ui.d.ts +41 -0
- package/dist/core/llama/ui.js +415 -0
- package/dist/core/messages.d.ts +76 -0
- package/dist/core/messages.js +122 -0
- package/dist/core/model-config.d.ts +547 -0
- package/dist/core/model-config.js +278 -0
- package/dist/core/model-registry.d.ts +45 -0
- package/dist/core/model-registry.js +107 -0
- package/dist/core/model-resolver.d.ts +122 -0
- package/dist/core/model-resolver.js +558 -0
- package/dist/core/model-runtime.d.ts +86 -0
- package/dist/core/model-runtime.js +472 -0
- package/dist/core/models-store.d.ts +16 -0
- package/dist/core/models-store.js +44 -0
- package/dist/core/output-guard.d.ts +6 -0
- package/dist/core/output-guard.js +88 -0
- package/dist/core/package-manager.d.ts +221 -0
- package/dist/core/package-manager.js +2232 -0
- package/dist/core/package-manager.test.d.ts +1 -0
- package/dist/core/package-manager.test.js +58 -0
- package/dist/core/project-trust.d.ts +14 -0
- package/dist/core/project-trust.js +58 -0
- package/dist/core/prompt-templates.d.ts +53 -0
- package/dist/core/prompt-templates.js +235 -0
- package/dist/core/provider-attribution.d.ts +3 -0
- package/dist/core/provider-attribution.js +71 -0
- package/dist/core/provider-composer.d.ts +54 -0
- package/dist/core/provider-composer.js +387 -0
- package/dist/core/radius.d.ts +1 -0
- package/dist/core/radius.js +1 -0
- package/dist/core/remote-catalog-provider.d.ts +4 -0
- package/dist/core/remote-catalog-provider.js +119 -0
- package/dist/core/resolve-config-value.d.ts +29 -0
- package/dist/core/resolve-config-value.js +246 -0
- package/dist/core/resource-loader.d.ts +256 -0
- package/dist/core/resource-loader.js +974 -0
- package/dist/core/runtime-credentials.d.ts +16 -0
- package/dist/core/runtime-credentials.js +41 -0
- package/dist/core/sdk.d.ts +107 -0
- package/dist/core/sdk.js +279 -0
- package/dist/core/session-cwd.d.ts +18 -0
- package/dist/core/session-cwd.js +37 -0
- package/dist/core/session-manager.d.ts +355 -0
- package/dist/core/session-manager.js +1339 -0
- package/dist/core/settings-manager-auto-handoff.test.d.ts +1 -0
- package/dist/core/settings-manager-auto-handoff.test.js +42 -0
- package/dist/core/settings-manager.d.ts +350 -0
- package/dist/core/settings-manager.js +1076 -0
- package/dist/core/skills.d.ts +70 -0
- package/dist/core/skills.js +401 -0
- package/dist/core/slash-commands.d.ts +14 -0
- package/dist/core/slash-commands.js +27 -0
- package/dist/core/source-info.d.ts +17 -0
- package/dist/core/source-info.js +18 -0
- package/dist/core/system-prompt.d.ts +30 -0
- package/dist/core/system-prompt.js +129 -0
- package/dist/core/system-prompt.test.d.ts +1 -0
- package/dist/core/system-prompt.test.js +94 -0
- package/dist/core/telemetry.d.ts +2 -0
- package/dist/core/telemetry.js +8 -0
- package/dist/core/timings.d.ts +9 -0
- package/dist/core/timings.js +40 -0
- package/dist/core/tools/bash.d.ts +86 -0
- package/dist/core/tools/bash.js +409 -0
- package/dist/core/tools/edit-diff.d.ts +105 -0
- package/dist/core/tools/edit-diff.js +423 -0
- package/dist/core/tools/edit.d.ts +50 -0
- package/dist/core/tools/edit.js +285 -0
- package/dist/core/tools/file-mutation-queue.d.ts +5 -0
- package/dist/core/tools/file-mutation-queue.js +51 -0
- package/dist/core/tools/find.d.ts +34 -0
- package/dist/core/tools/find.js +304 -0
- package/dist/core/tools/grep.d.ts +36 -0
- package/dist/core/tools/grep.js +303 -0
- package/dist/core/tools/index.d.ts +42 -0
- package/dist/core/tools/index.js +119 -0
- package/dist/core/tools/ls.d.ts +36 -0
- package/dist/core/tools/ls.js +166 -0
- package/dist/core/tools/output-accumulator.d.ts +51 -0
- package/dist/core/tools/output-accumulator.js +183 -0
- package/dist/core/tools/path-utils.d.ts +9 -0
- package/dist/core/tools/path-utils.js +98 -0
- package/dist/core/tools/powershell.d.ts +15 -0
- package/dist/core/tools/powershell.js +38 -0
- package/dist/core/tools/powershell.test.d.ts +1 -0
- package/dist/core/tools/powershell.test.js +20 -0
- package/dist/core/tools/read-vision.test.d.ts +1 -0
- package/dist/core/tools/read-vision.test.js +122 -0
- package/dist/core/tools/read.d.ts +46 -0
- package/dist/core/tools/read.js +327 -0
- package/dist/core/tools/render-utils.d.ts +23 -0
- package/dist/core/tools/render-utils.js +64 -0
- package/dist/core/tools/tool-definition-wrapper.d.ts +13 -0
- package/dist/core/tools/tool-definition-wrapper.js +35 -0
- package/dist/core/tools/truncate.d.ts +69 -0
- package/dist/core/tools/truncate.js +214 -0
- package/dist/core/tools/write.d.ts +25 -0
- package/dist/core/tools/write.js +198 -0
- package/dist/core/trust-manager.d.ts +35 -0
- package/dist/core/trust-manager.js +201 -0
- package/dist/core/usage-totals.d.ts +20 -0
- package/dist/core/usage-totals.js +61 -0
- package/dist/core/vision-caption.d.ts +30 -0
- package/dist/core/vision-caption.js +62 -0
- package/dist/defaults/models.json +335 -0
- package/dist/defaults/settings.json +61 -0
- package/dist/extensions/agent-browser.test.ts +371 -0
- package/dist/extensions/agent-browser.ts +160 -0
- package/dist/extensions/auto-session-name.test.ts +169 -0
- package/dist/extensions/auto-session-name.ts +100 -0
- package/dist/extensions/context-compaction-reminder.test.ts +82 -0
- package/dist/extensions/context-compaction-reminder.ts +28 -0
- package/dist/extensions/copy-turn.test.ts +383 -0
- package/dist/extensions/copy-turn.ts +146 -0
- package/dist/extensions/cost-reconcile.test.ts +272 -0
- package/dist/extensions/cost-reconcile.ts +264 -0
- package/dist/extensions/grep-app/index.test.ts +406 -0
- package/dist/extensions/grep-app/index.ts +216 -0
- package/dist/extensions/handoff-new.test.ts +434 -0
- package/dist/extensions/handoff-new.ts +129 -0
- package/dist/extensions/herdr-agent-state.ts +310 -0
- package/dist/extensions/inline-skills.test.ts +204 -0
- package/dist/extensions/inline-skills.ts +102 -0
- package/dist/extensions/package.json +32 -0
- package/dist/extensions/pi-hermes-memory/CHANGELOG.md +371 -0
- package/dist/extensions/pi-hermes-memory/LICENSE +21 -0
- package/dist/extensions/pi-hermes-memory/README.md +643 -0
- package/dist/extensions/pi-hermes-memory/docs/0.1/TASKS.md +197 -0
- package/dist/extensions/pi-hermes-memory/docs/0.2/PLAN.md +290 -0
- package/dist/extensions/pi-hermes-memory/docs/0.2/TASKS.md +134 -0
- package/dist/extensions/pi-hermes-memory/docs/0.2/TEST-PLAN.md +216 -0
- package/dist/extensions/pi-hermes-memory/docs/0.3/PLAN.md +330 -0
- package/dist/extensions/pi-hermes-memory/docs/0.3/TASKS.md +125 -0
- package/dist/extensions/pi-hermes-memory/docs/0.4/PLAN.md +160 -0
- package/dist/extensions/pi-hermes-memory/docs/0.4/TASKS.md +113 -0
- package/dist/extensions/pi-hermes-memory/docs/0.6/CHANGELOG.md +57 -0
- package/dist/extensions/pi-hermes-memory/docs/0.6/PLAN.md +202 -0
- package/dist/extensions/pi-hermes-memory/docs/0.6/TASKS.md +144 -0
- package/dist/extensions/pi-hermes-memory/docs/0.7/PLAN.md +349 -0
- package/dist/extensions/pi-hermes-memory/docs/0.7/TASKS.md +110 -0
- package/dist/extensions/pi-hermes-memory/docs/PUBLISHING.md +149 -0
- package/dist/extensions/pi-hermes-memory/docs/ROADMAP.md +468 -0
- package/dist/extensions/pi-hermes-memory/docs/images/memory-architecture.svg +1 -0
- package/dist/extensions/pi-hermes-memory/docs/images/pi-logo.svg +22 -0
- package/dist/extensions/pi-hermes-memory/docs/images/pi_memory.png +0 -0
- package/dist/extensions/pi-hermes-memory/docs/images/pi_memory.svg +19 -0
- package/dist/extensions/pi-hermes-memory/docs/images/security-flow.svg +1 -0
- package/dist/extensions/pi-hermes-memory/docs/images/session-lifecycle.svg +1 -0
- package/dist/extensions/pi-hermes-memory/docs/images/source-architecture.svg +1 -0
- package/dist/extensions/pi-hermes-memory/docs/mermaid/memory-architecture.mmd +49 -0
- package/dist/extensions/pi-hermes-memory/docs/mermaid/security-flow.mmd +40 -0
- package/dist/extensions/pi-hermes-memory/docs/mermaid/session-lifecycle.mmd +56 -0
- package/dist/extensions/pi-hermes-memory/docs/mermaid/source-architecture.mmd +54 -0
- package/dist/extensions/pi-hermes-memory/package-lock.json +3799 -0
- package/dist/extensions/pi-hermes-memory/package.json +66 -0
- package/dist/extensions/pi-hermes-memory/scripts/check-min-sdk.mjs +99 -0
- package/dist/extensions/pi-hermes-memory/scripts/ensure-dev.mjs +57 -0
- package/dist/extensions/pi-hermes-memory/src/auto-consolidation-warning.ts +6 -0
- package/dist/extensions/pi-hermes-memory/src/config.ts +178 -0
- package/dist/extensions/pi-hermes-memory/src/constants.ts +424 -0
- package/dist/extensions/pi-hermes-memory/src/extension-root-migration.ts +639 -0
- package/dist/extensions/pi-hermes-memory/src/handlers/auto-consolidate.ts +401 -0
- package/dist/extensions/pi-hermes-memory/src/handlers/background-review.ts +297 -0
- package/dist/extensions/pi-hermes-memory/src/handlers/child-process-watchdog.mjs +90 -0
- package/dist/extensions/pi-hermes-memory/src/handlers/correction-detector.ts +300 -0
- package/dist/extensions/pi-hermes-memory/src/handlers/index-sessions.ts +86 -0
- package/dist/extensions/pi-hermes-memory/src/handlers/insights.ts +78 -0
- package/dist/extensions/pi-hermes-memory/src/handlers/interview.ts +37 -0
- package/dist/extensions/pi-hermes-memory/src/handlers/learn-memory.ts +186 -0
- package/dist/extensions/pi-hermes-memory/src/handlers/message-parts.ts +27 -0
- package/dist/extensions/pi-hermes-memory/src/handlers/pi-child-process.ts +485 -0
- package/dist/extensions/pi-hermes-memory/src/handlers/preview-context.ts +105 -0
- package/dist/extensions/pi-hermes-memory/src/handlers/review-memory-ops.ts +506 -0
- package/dist/extensions/pi-hermes-memory/src/handlers/session-backfill.ts +145 -0
- package/dist/extensions/pi-hermes-memory/src/handlers/session-flush.ts +151 -0
- package/dist/extensions/pi-hermes-memory/src/handlers/session-live-index.ts +94 -0
- package/dist/extensions/pi-hermes-memory/src/handlers/skills-command.ts +1334 -0
- package/dist/extensions/pi-hermes-memory/src/handlers/standing-pin.ts +111 -0
- package/dist/extensions/pi-hermes-memory/src/handlers/switch-project.ts +75 -0
- package/dist/extensions/pi-hermes-memory/src/handlers/sync-markdown-memories.ts +266 -0
- package/dist/extensions/pi-hermes-memory/src/index.ts +384 -0
- package/dist/extensions/pi-hermes-memory/src/lifecycle-timing.ts +54 -0
- package/dist/extensions/pi-hermes-memory/src/paths.ts +61 -0
- package/dist/extensions/pi-hermes-memory/src/project-context.ts +13 -0
- package/dist/extensions/pi-hermes-memory/src/project-memory-migration.ts +93 -0
- package/dist/extensions/pi-hermes-memory/src/project.ts +157 -0
- package/dist/extensions/pi-hermes-memory/src/prompt-context.ts +55 -0
- package/dist/extensions/pi-hermes-memory/src/store/atomic-lock-coordinator.ts +375 -0
- package/dist/extensions/pi-hermes-memory/src/store/canonical-storage-path.ts +54 -0
- package/dist/extensions/pi-hermes-memory/src/store/content-scanner.ts +101 -0
- package/dist/extensions/pi-hermes-memory/src/store/db.ts +1180 -0
- package/dist/extensions/pi-hermes-memory/src/store/fts-query.ts +101 -0
- package/dist/extensions/pi-hermes-memory/src/store/markdown-mutation-lock.ts +38 -0
- package/dist/extensions/pi-hermes-memory/src/store/memory-lookup.ts +24 -0
- package/dist/extensions/pi-hermes-memory/src/store/memory-store.ts +1191 -0
- package/dist/extensions/pi-hermes-memory/src/store/recovery-maintenance.ts +66 -0
- package/dist/extensions/pi-hermes-memory/src/store/schema.ts +118 -0
- package/dist/extensions/pi-hermes-memory/src/store/session-anchor-search.ts +472 -0
- package/dist/extensions/pi-hermes-memory/src/store/session-indexer.ts +511 -0
- package/dist/extensions/pi-hermes-memory/src/store/session-parser.ts +213 -0
- package/dist/extensions/pi-hermes-memory/src/store/session-search.ts +234 -0
- package/dist/extensions/pi-hermes-memory/src/store/skill-store.ts +950 -0
- package/dist/extensions/pi-hermes-memory/src/store/skill-utils.ts +133 -0
- package/dist/extensions/pi-hermes-memory/src/store/sqlite-memory-store.ts +1002 -0
- package/dist/extensions/pi-hermes-memory/src/store/sqlite-native.ts +241 -0
- package/dist/extensions/pi-hermes-memory/src/store/standing-instructions.ts +247 -0
- package/dist/extensions/pi-hermes-memory/src/tools/memory-search-tool.ts +95 -0
- package/dist/extensions/pi-hermes-memory/src/tools/memory-tool.ts +469 -0
- package/dist/extensions/pi-hermes-memory/src/tools/session-search-tool.ts +246 -0
- package/dist/extensions/pi-hermes-memory/src/tools/shared-output-view.ts +170 -0
- package/dist/extensions/pi-hermes-memory/src/tools/skill-tool.ts +333 -0
- package/dist/extensions/pi-hermes-memory/src/tools/tool-result-views.ts +105 -0
- package/dist/extensions/pi-hermes-memory/src/types.ts +214 -0
- package/dist/extensions/pi-hermes-memory/tests/config.test.ts +434 -0
- package/dist/extensions/pi-hermes-memory/tests/extension-root-migration.test.ts +368 -0
- package/dist/extensions/pi-hermes-memory/tests/handlers/auto-consolidate.test.ts +984 -0
- package/dist/extensions/pi-hermes-memory/tests/handlers/background-review.test.ts +950 -0
- package/dist/extensions/pi-hermes-memory/tests/handlers/correction-detector.test.ts +671 -0
- package/dist/extensions/pi-hermes-memory/tests/handlers/insights.test.ts +157 -0
- package/dist/extensions/pi-hermes-memory/tests/handlers/interview.test.ts +127 -0
- package/dist/extensions/pi-hermes-memory/tests/handlers/pi-child-process.test.ts +905 -0
- package/dist/extensions/pi-hermes-memory/tests/handlers/preview-context.test.ts +152 -0
- package/dist/extensions/pi-hermes-memory/tests/handlers/prompt-context.test.ts +166 -0
- package/dist/extensions/pi-hermes-memory/tests/handlers/resources-discover.test.ts +71 -0
- package/dist/extensions/pi-hermes-memory/tests/handlers/review-memory-ops.test.ts +614 -0
- package/dist/extensions/pi-hermes-memory/tests/handlers/session-backfill.test.ts +192 -0
- package/dist/extensions/pi-hermes-memory/tests/handlers/session-flush.test.ts +677 -0
- package/dist/extensions/pi-hermes-memory/tests/handlers/session-live-index.test.ts +225 -0
- package/dist/extensions/pi-hermes-memory/tests/handlers/skills-command.test.ts +827 -0
- package/dist/extensions/pi-hermes-memory/tests/handlers/standing-pin.test.ts +134 -0
- package/dist/extensions/pi-hermes-memory/tests/handlers/sync-markdown-memories.test.ts +491 -0
- package/dist/extensions/pi-hermes-memory/tests/handlers/system-prompt.test.ts +199 -0
- package/dist/extensions/pi-hermes-memory/tests/handlers/thinking-max.test.ts +64 -0
- package/dist/extensions/pi-hermes-memory/tests/index.test.ts +30 -0
- package/dist/extensions/pi-hermes-memory/tests/integration/flow.test.ts +126 -0
- package/dist/extensions/pi-hermes-memory/tests/lifecycle-timing.test.ts +76 -0
- package/dist/extensions/pi-hermes-memory/tests/paths.test.ts +23 -0
- package/dist/extensions/pi-hermes-memory/tests/project-memory-migration.test.ts +80 -0
- package/dist/extensions/pi-hermes-memory/tests/project-rebinding.test.ts +115 -0
- package/dist/extensions/pi-hermes-memory/tests/project.test.ts +120 -0
- package/dist/extensions/pi-hermes-memory/tests/run-all-timeout.test.ts +107 -0
- package/dist/extensions/pi-hermes-memory/tests/run-all.sh +45 -0
- package/dist/extensions/pi-hermes-memory/tests/store/atomic-lock-coordinator.test.ts +381 -0
- package/dist/extensions/pi-hermes-memory/tests/store/content-scanner.test.ts +388 -0
- package/dist/extensions/pi-hermes-memory/tests/store/db.test.ts +1046 -0
- package/dist/extensions/pi-hermes-memory/tests/store/markdown-mutation-lock.test.ts +34 -0
- package/dist/extensions/pi-hermes-memory/tests/store/memory-store.test.ts +2150 -0
- package/dist/extensions/pi-hermes-memory/tests/store/recovery-maintenance.test.ts +170 -0
- package/dist/extensions/pi-hermes-memory/tests/store/session-anchor-search.test.ts +210 -0
- package/dist/extensions/pi-hermes-memory/tests/store/session-indexer.test.ts +643 -0
- package/dist/extensions/pi-hermes-memory/tests/store/session-parser.test.ts +282 -0
- package/dist/extensions/pi-hermes-memory/tests/store/session-search.test.ts +287 -0
- package/dist/extensions/pi-hermes-memory/tests/store/skill-store.test.ts +678 -0
- package/dist/extensions/pi-hermes-memory/tests/store/skill-utils.test.ts +21 -0
- package/dist/extensions/pi-hermes-memory/tests/store/sqlite-lazy-load.test.ts +78 -0
- package/dist/extensions/pi-hermes-memory/tests/store/sqlite-memory-store.test.ts +543 -0
- package/dist/extensions/pi-hermes-memory/tests/store/sqlite-native.test.ts +164 -0
- package/dist/extensions/pi-hermes-memory/tests/store/standing-instructions.test.ts +171 -0
- package/dist/extensions/pi-hermes-memory/tests/tools/memory-search-tool.test.ts +84 -0
- package/dist/extensions/pi-hermes-memory/tests/tools/memory-tool.test.ts +709 -0
- package/dist/extensions/pi-hermes-memory/tests/tools/session-search-tool.test.ts +345 -0
- package/dist/extensions/pi-hermes-memory/tests/tools/shared-output-view.test.ts +362 -0
- package/dist/extensions/pi-hermes-memory/tests/tools/skill-tool.test.ts +478 -0
- package/dist/extensions/pi-hermes-memory/tests/tools/tool-result-renderer-wiring.test.ts +40 -0
- package/dist/extensions/pi-hermes-memory/tsconfig.json +19 -0
- package/dist/extensions/pi-intercom/CHANGELOG.md +321 -0
- package/dist/extensions/pi-intercom/LICENSE +21 -0
- package/dist/extensions/pi-intercom/README.md +598 -0
- package/dist/extensions/pi-intercom/banner.png +0 -0
- package/dist/extensions/pi-intercom/broker/broker.ts +1721 -0
- package/dist/extensions/pi-intercom/broker/client-liveness.test.ts +173 -0
- package/dist/extensions/pi-intercom/broker/client.test.ts +83 -0
- package/dist/extensions/pi-intercom/broker/client.ts +793 -0
- package/dist/extensions/pi-intercom/broker/extension-state.ts +197 -0
- package/dist/extensions/pi-intercom/broker/extension.test.ts +486 -0
- package/dist/extensions/pi-intercom/broker/framing.test.ts +114 -0
- package/dist/extensions/pi-intercom/broker/framing.ts +115 -0
- package/dist/extensions/pi-intercom/broker/paths.test.ts +153 -0
- package/dist/extensions/pi-intercom/broker/paths.ts +134 -0
- package/dist/extensions/pi-intercom/broker/protocol.ts +208 -0
- package/dist/extensions/pi-intercom/broker/runtime-claim.test.ts +34 -0
- package/dist/extensions/pi-intercom/broker/runtime-claim.ts +21 -0
- package/dist/extensions/pi-intercom/broker/spawn.test.ts +252 -0
- package/dist/extensions/pi-intercom/broker/spawn.ts +420 -0
- package/dist/extensions/pi-intercom/config.test.ts +104 -0
- package/dist/extensions/pi-intercom/config.ts +163 -0
- package/dist/extensions/pi-intercom/cwd.test.ts +40 -0
- package/dist/extensions/pi-intercom/cwd.ts +31 -0
- package/dist/extensions/pi-intercom/extension-api.ts +84 -0
- package/dist/extensions/pi-intercom/format-context.test.ts +31 -0
- package/dist/extensions/pi-intercom/format-context.ts +32 -0
- package/dist/extensions/pi-intercom/index.ts +2821 -0
- package/dist/extensions/pi-intercom/intercom.integration.test.ts +4232 -0
- package/dist/extensions/pi-intercom/package.json +49 -0
- package/dist/extensions/pi-intercom/project-agent.test.ts +145 -0
- package/dist/extensions/pi-intercom/project-agent.ts +324 -0
- package/dist/extensions/pi-intercom/reply-tracker.test.ts +239 -0
- package/dist/extensions/pi-intercom/reply-tracker.ts +160 -0
- package/dist/extensions/pi-intercom/skills/pi-intercom/SKILL.md +452 -0
- package/dist/extensions/pi-intercom/test/inline-message.test.ts +184 -0
- package/dist/extensions/pi-intercom/test/overlay-width.test.ts +66 -0
- package/dist/extensions/pi-intercom/types.ts +165 -0
- package/dist/extensions/pi-intercom/ui/compose.ts +143 -0
- package/dist/extensions/pi-intercom/ui/inline-message.ts +118 -0
- package/dist/extensions/pi-intercom/ui/session-list.ts +166 -0
- package/dist/extensions/pi-rewind-hook/README.md +248 -0
- package/dist/extensions/pi-rewind-hook/index.ts +1575 -0
- package/dist/extensions/pi-rewind-hook/package.json +31 -0
- package/dist/extensions/pi-subagents/.github/assets/subagent-fleet-inspector.png +0 -0
- package/dist/extensions/pi-subagents/.github/workflows/release.yml +28 -0
- package/dist/extensions/pi-subagents/.github/workflows/test.yml +51 -0
- package/dist/extensions/pi-subagents/.greptile/config.json +33 -0
- package/dist/extensions/pi-subagents/.greptile/files.json +8 -0
- package/dist/extensions/pi-subagents/.greptile/rules.md +16 -0
- package/dist/extensions/pi-subagents/.oxlintrc.json +43 -0
- package/dist/extensions/pi-subagents/AGENTS.md +5 -0
- package/dist/extensions/pi-subagents/CHANGELOG.md +2325 -0
- package/dist/extensions/pi-subagents/LICENSE +21 -0
- package/dist/extensions/pi-subagents/README.md +126 -0
- package/dist/extensions/pi-subagents/VISION.md +92 -0
- package/dist/extensions/pi-subagents/agents/delegate.md +14 -0
- package/dist/extensions/pi-subagents/agents/oracle.md +78 -0
- package/dist/extensions/pi-subagents/agents/researcher.md +52 -0
- package/dist/extensions/pi-subagents/agents/reviewer.md +89 -0
- package/dist/extensions/pi-subagents/agents/scout.md +50 -0
- package/dist/extensions/pi-subagents/agents/worker.md +60 -0
- package/dist/extensions/pi-subagents/async-retention-discovery-worker.mjs +180 -0
- package/dist/extensions/pi-subagents/docs/agents.md +382 -0
- package/dist/extensions/pi-subagents/docs/configuration.md +534 -0
- package/dist/extensions/pi-subagents/docs/extension-api.md +443 -0
- package/dist/extensions/pi-subagents/docs/missions.md +121 -0
- package/dist/extensions/pi-subagents/docs/models.md +258 -0
- package/dist/extensions/pi-subagents/docs/observability.md +265 -0
- package/dist/extensions/pi-subagents/docs/tool-reference.md +482 -0
- package/dist/extensions/pi-subagents/docs/watchdog.md +154 -0
- package/dist/extensions/pi-subagents/docs/workflows.md +475 -0
- package/dist/extensions/pi-subagents/index.ts +10 -0
- package/dist/extensions/pi-subagents/inspector-runner.mjs +11 -0
- package/dist/extensions/pi-subagents/install.mjs +93 -0
- package/dist/extensions/pi-subagents/package-lock.json +1872 -0
- package/dist/extensions/pi-subagents/package.json +109 -0
- package/dist/extensions/pi-subagents/prompts/council.md +60 -0
- package/dist/extensions/pi-subagents/prompts/gather-context-and-clarify.md +13 -0
- package/dist/extensions/pi-subagents/prompts/parallel-cleanup.md +59 -0
- package/dist/extensions/pi-subagents/prompts/parallel-research.md +50 -0
- package/dist/extensions/pi-subagents/prompts/parallel-review.md +58 -0
- package/dist/extensions/pi-subagents/prompts/review-loop.md +47 -0
- package/dist/extensions/pi-subagents/skills/council-mode/SKILL.md +59 -0
- package/dist/extensions/pi-subagents/skills/council-mode/references/pass-contracts.md +150 -0
- package/dist/extensions/pi-subagents/skills/pi-subagents/SKILL.md +103 -0
- package/dist/extensions/pi-subagents/skills/pi-subagents/references/constraints-and-recipes.md +70 -0
- package/dist/extensions/pi-subagents/skills/pi-subagents/references/execution-controls.md +539 -0
- package/dist/extensions/pi-subagents/skills/pi-subagents/references/management-authoring-rpc.md +161 -0
- package/dist/extensions/pi-subagents/skills/pi-subagents/references/multi-lane-orchestration.md +51 -0
- package/dist/extensions/pi-subagents/skills/pi-subagents/references/prompting-and-roles.md +295 -0
- package/dist/extensions/pi-subagents/skills/pi-subagents/references/review-and-validation.md +73 -0
- package/dist/extensions/pi-subagents/src/agents/agent-management.ts +1373 -0
- package/dist/extensions/pi-subagents/src/agents/agent-memory.ts +254 -0
- package/dist/extensions/pi-subagents/src/agents/agent-refinements.ts +624 -0
- package/dist/extensions/pi-subagents/src/agents/agent-scope.ts +6 -0
- package/dist/extensions/pi-subagents/src/agents/agent-selection.ts +25 -0
- package/dist/extensions/pi-subagents/src/agents/agent-serializer.ts +179 -0
- package/dist/extensions/pi-subagents/src/agents/agents.ts +2790 -0
- package/dist/extensions/pi-subagents/src/agents/builtin-names.ts +9 -0
- package/dist/extensions/pi-subagents/src/agents/chain-serializer.ts +280 -0
- package/dist/extensions/pi-subagents/src/agents/frontmatter.ts +153 -0
- package/dist/extensions/pi-subagents/src/agents/identity.ts +30 -0
- package/dist/extensions/pi-subagents/src/agents/proactive-skills.ts +194 -0
- package/dist/extensions/pi-subagents/src/agents/runtime-agent-events.ts +70 -0
- package/dist/extensions/pi-subagents/src/agents/runtime-agent-registry.ts +429 -0
- package/dist/extensions/pi-subagents/src/agents/skills.ts +754 -0
- package/dist/extensions/pi-subagents/src/api/agents.ts +12 -0
- package/dist/extensions/pi-subagents/src/api/background-work.ts +206 -0
- package/dist/extensions/pi-subagents/src/api/capability-ceiling.ts +17 -0
- package/dist/extensions/pi-subagents/src/api/control-channel.ts +4 -0
- package/dist/extensions/pi-subagents/src/api/delegation.ts +112 -0
- package/dist/extensions/pi-subagents/src/api/external-job-provider.ts +195 -0
- package/dist/extensions/pi-subagents/src/api/external-runs.ts +282 -0
- package/dist/extensions/pi-subagents/src/api/intercom-bridge.ts +3 -0
- package/dist/extensions/pi-subagents/src/api/pi-args.ts +5 -0
- package/dist/extensions/pi-subagents/src/api/preflight.ts +501 -0
- package/dist/extensions/pi-subagents/src/api/project-panes.ts +32 -0
- package/dist/extensions/pi-subagents/src/api/shared-types.ts +27 -0
- package/dist/extensions/pi-subagents/src/extension/config.ts +255 -0
- package/dist/extensions/pi-subagents/src/extension/control-notices.ts +58 -0
- package/dist/extensions/pi-subagents/src/extension/doctor.ts +278 -0
- package/dist/extensions/pi-subagents/src/extension/fanout-child.ts +205 -0
- package/dist/extensions/pi-subagents/src/extension/index.ts +1093 -0
- package/dist/extensions/pi-subagents/src/extension/public-execution.ts +210 -0
- package/dist/extensions/pi-subagents/src/extension/rpc.ts +860 -0
- package/dist/extensions/pi-subagents/src/extension/schemas.ts +419 -0
- package/dist/extensions/pi-subagents/src/extension/steering-notices.ts +35 -0
- package/dist/extensions/pi-subagents/src/extension/subagent-guide.ts +39 -0
- package/dist/extensions/pi-subagents/src/extension/tool-description.ts +204 -0
- package/dist/extensions/pi-subagents/src/extension/tool-result.ts +19 -0
- package/dist/extensions/pi-subagents/src/inspectors/herdr/actions.ts +235 -0
- package/dist/extensions/pi-subagents/src/inspectors/herdr/client.ts +130 -0
- package/dist/extensions/pi-subagents/src/inspectors/herdr/focus.ts +55 -0
- package/dist/extensions/pi-subagents/src/inspectors/herdr/inspector-runner.ts +153 -0
- package/dist/extensions/pi-subagents/src/inspectors/herdr/project-panes.ts +730 -0
- package/dist/extensions/pi-subagents/src/inspectors/herdr/session-roots-codec.ts +42 -0
- package/dist/extensions/pi-subagents/src/inspectors/herdr/shell-command.ts +16 -0
- package/dist/extensions/pi-subagents/src/integrations/herdr-status.ts +396 -0
- package/dist/extensions/pi-subagents/src/intercom/intercom-bridge.ts +191 -0
- package/dist/extensions/pi-subagents/src/intercom/native-supervisor-channel.ts +812 -0
- package/dist/extensions/pi-subagents/src/intercom/result-intercom.ts +423 -0
- package/dist/extensions/pi-subagents/src/missions/actions.ts +433 -0
- package/dist/extensions/pi-subagents/src/missions/goal-driver.ts +164 -0
- package/dist/extensions/pi-subagents/src/missions/lifecycle.ts +367 -0
- package/dist/extensions/pi-subagents/src/missions/store.ts +584 -0
- package/dist/extensions/pi-subagents/src/missions/types.ts +190 -0
- package/dist/extensions/pi-subagents/src/missions/workflow-state.ts +260 -0
- package/dist/extensions/pi-subagents/src/policy/authority.ts +46 -0
- package/dist/extensions/pi-subagents/src/profiles/profiles.ts +662 -0
- package/dist/extensions/pi-subagents/src/runs/background/active-async-capacity.ts +516 -0
- package/dist/extensions/pi-subagents/src/runs/background/active-run-index.ts +139 -0
- package/dist/extensions/pi-subagents/src/runs/background/async-execution.ts +2080 -0
- package/dist/extensions/pi-subagents/src/runs/background/async-job-tracker.ts +781 -0
- package/dist/extensions/pi-subagents/src/runs/background/async-resume.ts +631 -0
- package/dist/extensions/pi-subagents/src/runs/background/async-retention.ts +903 -0
- package/dist/extensions/pi-subagents/src/runs/background/async-status-snapshot.ts +48 -0
- package/dist/extensions/pi-subagents/src/runs/background/async-status.ts +761 -0
- package/dist/extensions/pi-subagents/src/runs/background/auto-drain.ts +68 -0
- package/dist/extensions/pi-subagents/src/runs/background/chain-append.ts +321 -0
- package/dist/extensions/pi-subagents/src/runs/background/chain-root-attachment.ts +270 -0
- package/dist/extensions/pi-subagents/src/runs/background/completion-batcher.ts +168 -0
- package/dist/extensions/pi-subagents/src/runs/background/completion-dedupe.ts +58 -0
- package/dist/extensions/pi-subagents/src/runs/background/completion-replay.ts +287 -0
- package/dist/extensions/pi-subagents/src/runs/background/control-channel.ts +768 -0
- package/dist/extensions/pi-subagents/src/runs/background/fleet-view.ts +620 -0
- package/dist/extensions/pi-subagents/src/runs/background/index-segment.ts +59 -0
- package/dist/extensions/pi-subagents/src/runs/background/inspect-rpc.ts +443 -0
- package/dist/extensions/pi-subagents/src/runs/background/notify.ts +645 -0
- package/dist/extensions/pi-subagents/src/runs/background/owned-process-tree.ts +104 -0
- package/dist/extensions/pi-subagents/src/runs/background/parallel-groups.ts +45 -0
- package/dist/extensions/pi-subagents/src/runs/background/process-terminal.ts +310 -0
- package/dist/extensions/pi-subagents/src/runs/background/result-delivery-ownership.ts +45 -0
- package/dist/extensions/pi-subagents/src/runs/background/result-files.ts +519 -0
- package/dist/extensions/pi-subagents/src/runs/background/result-watcher.ts +792 -0
- package/dist/extensions/pi-subagents/src/runs/background/resume-guidance.ts +56 -0
- package/dist/extensions/pi-subagents/src/runs/background/retained-children.ts +135 -0
- package/dist/extensions/pi-subagents/src/runs/background/run-id-query.ts +7 -0
- package/dist/extensions/pi-subagents/src/runs/background/run-id-resolver.ts +175 -0
- package/dist/extensions/pi-subagents/src/runs/background/run-status.ts +714 -0
- package/dist/extensions/pi-subagents/src/runs/background/scheduled-runs.ts +965 -0
- package/dist/extensions/pi-subagents/src/runs/background/stale-run-reconciler.ts +410 -0
- package/dist/extensions/pi-subagents/src/runs/background/steering.ts +242 -0
- package/dist/extensions/pi-subagents/src/runs/background/subagent-runner.ts +5683 -0
- package/dist/extensions/pi-subagents/src/runs/background/subagent-wait.ts +725 -0
- package/dist/extensions/pi-subagents/src/runs/background/terminal-run-index.ts +138 -0
- package/dist/extensions/pi-subagents/src/runs/background/top-level-async.ts +14 -0
- package/dist/extensions/pi-subagents/src/runs/background/wait-completions.ts +209 -0
- package/dist/extensions/pi-subagents/src/runs/background/wait-config.ts +50 -0
- package/dist/extensions/pi-subagents/src/runs/background/wait-subscriptions.ts +348 -0
- package/dist/extensions/pi-subagents/src/runs/background/wait-tool.ts +51 -0
- package/dist/extensions/pi-subagents/src/runs/foreground/async-dismiss-action.ts +86 -0
- package/dist/extensions/pi-subagents/src/runs/foreground/async-steering-action.ts +262 -0
- package/dist/extensions/pi-subagents/src/runs/foreground/async-stop-action.ts +86 -0
- package/dist/extensions/pi-subagents/src/runs/foreground/execution.ts +2443 -0
- package/dist/extensions/pi-subagents/src/runs/foreground/foreground-control.ts +153 -0
- package/dist/extensions/pi-subagents/src/runs/foreground/foreground-history.ts +160 -0
- package/dist/extensions/pi-subagents/src/runs/foreground/prompt-audit.ts +172 -0
- package/dist/extensions/pi-subagents/src/runs/foreground/subagent-executor.ts +6971 -0
- package/dist/extensions/pi-subagents/src/runs/foreground/workflow-detach-reconcile.ts +299 -0
- package/dist/extensions/pi-subagents/src/runs/foreground/workflow-foreground-steering.ts +188 -0
- package/dist/extensions/pi-subagents/src/runs/shared/abort-recovery.ts +119 -0
- package/dist/extensions/pi-subagents/src/runs/shared/acceptance.ts +1525 -0
- package/dist/extensions/pi-subagents/src/runs/shared/agent-contract.ts +38 -0
- package/dist/extensions/pi-subagents/src/runs/shared/async-status-projection.ts +565 -0
- package/dist/extensions/pi-subagents/src/runs/shared/background-process-options.ts +9 -0
- package/dist/extensions/pi-subagents/src/runs/shared/capability-ceiling.ts +210 -0
- package/dist/extensions/pi-subagents/src/runs/shared/chain-outputs.ts +116 -0
- package/dist/extensions/pi-subagents/src/runs/shared/child-identity.ts +51 -0
- package/dist/extensions/pi-subagents/src/runs/shared/child-launch-plan.ts +151 -0
- package/dist/extensions/pi-subagents/src/runs/shared/child-protocol.ts +415 -0
- package/dist/extensions/pi-subagents/src/runs/shared/completion-evidence.ts +89 -0
- package/dist/extensions/pi-subagents/src/runs/shared/completion-guard.ts +252 -0
- package/dist/extensions/pi-subagents/src/runs/shared/context-mode.ts +44 -0
- package/dist/extensions/pi-subagents/src/runs/shared/dynamic-fanout.ts +297 -0
- package/dist/extensions/pi-subagents/src/runs/shared/extension-bindings.ts +78 -0
- package/dist/extensions/pi-subagents/src/runs/shared/external-cli-contract.ts +138 -0
- package/dist/extensions/pi-subagents/src/runs/shared/external-cli-preflight.ts +122 -0
- package/dist/extensions/pi-subagents/src/runs/shared/external-cli-runner.ts +429 -0
- package/dist/extensions/pi-subagents/src/runs/shared/external-job-bridge.ts +460 -0
- package/dist/extensions/pi-subagents/src/runs/shared/external-job-runner.ts +389 -0
- package/dist/extensions/pi-subagents/src/runs/shared/fast-mode-extension.ts +10 -0
- package/dist/extensions/pi-subagents/src/runs/shared/host-step-status.ts +231 -0
- package/dist/extensions/pi-subagents/src/runs/shared/lane-metadata.ts +126 -0
- package/dist/extensions/pi-subagents/src/runs/shared/launch-cwd.ts +16 -0
- package/dist/extensions/pi-subagents/src/runs/shared/llm-intent-arbiter.ts +302 -0
- package/dist/extensions/pi-subagents/src/runs/shared/long-running-guard.ts +221 -0
- package/dist/extensions/pi-subagents/src/runs/shared/mcp-config-sources.ts +422 -0
- package/dist/extensions/pi-subagents/src/runs/shared/mcp-direct-tool-allowlist.ts +483 -0
- package/dist/extensions/pi-subagents/src/runs/shared/mcp-direct-tool-grant.ts +194 -0
- package/dist/extensions/pi-subagents/src/runs/shared/model-exclusions.ts +305 -0
- package/dist/extensions/pi-subagents/src/runs/shared/model-fallback.ts +578 -0
- package/dist/extensions/pi-subagents/src/runs/shared/model-scope.ts +205 -0
- package/dist/extensions/pi-subagents/src/runs/shared/mutation-evidence.ts +199 -0
- package/dist/extensions/pi-subagents/src/runs/shared/nested-events.ts +1086 -0
- package/dist/extensions/pi-subagents/src/runs/shared/nested-path.ts +52 -0
- package/dist/extensions/pi-subagents/src/runs/shared/nested-render.ts +127 -0
- package/dist/extensions/pi-subagents/src/runs/shared/orca-progress-tabs.ts +499 -0
- package/dist/extensions/pi-subagents/src/runs/shared/parallel-handoff.ts +696 -0
- package/dist/extensions/pi-subagents/src/runs/shared/parallel-utils.ts +275 -0
- package/dist/extensions/pi-subagents/src/runs/shared/permissions.ts +100 -0
- package/dist/extensions/pi-subagents/src/runs/shared/pi-args.ts +1059 -0
- package/dist/extensions/pi-subagents/src/runs/shared/pi-spawn.ts +199 -0
- package/dist/extensions/pi-subagents/src/runs/shared/process-signal.ts +32 -0
- package/dist/extensions/pi-subagents/src/runs/shared/run-fanout-budget.ts +280 -0
- package/dist/extensions/pi-subagents/src/runs/shared/run-history.ts +201 -0
- package/dist/extensions/pi-subagents/src/runs/shared/runtime-acknowledged-extensions.ts +71 -0
- package/dist/extensions/pi-subagents/src/runs/shared/session-lease.ts +293 -0
- package/dist/extensions/pi-subagents/src/runs/shared/single-output.ts +304 -0
- package/dist/extensions/pi-subagents/src/runs/shared/spawn-budget.ts +128 -0
- package/dist/extensions/pi-subagents/src/runs/shared/structured-output.ts +223 -0
- package/dist/extensions/pi-subagents/src/runs/shared/subagent-control.ts +292 -0
- package/dist/extensions/pi-subagents/src/runs/shared/subagent-prompt-runtime.ts +825 -0
- package/dist/extensions/pi-subagents/src/runs/shared/subagent-startup-retry.ts +116 -0
- package/dist/extensions/pi-subagents/src/runs/shared/task-intent.ts +211 -0
- package/dist/extensions/pi-subagents/src/runs/shared/tool-availability.ts +81 -0
- package/dist/extensions/pi-subagents/src/runs/shared/tool-budget.ts +80 -0
- package/dist/extensions/pi-subagents/src/runs/shared/tool-timeout.ts +93 -0
- package/dist/extensions/pi-subagents/src/runs/shared/usage-budget.ts +65 -0
- package/dist/extensions/pi-subagents/src/runs/shared/workflow-graph.ts +225 -0
- package/dist/extensions/pi-subagents/src/runs/shared/worktree-cleanup-plan.ts +847 -0
- package/dist/extensions/pi-subagents/src/runs/shared/worktree.ts +1206 -0
- package/dist/extensions/pi-subagents/src/shared/accessible-dir.ts +47 -0
- package/dist/extensions/pi-subagents/src/shared/agent-stream-options.ts +5 -0
- package/dist/extensions/pi-subagents/src/shared/artifacts.ts +281 -0
- package/dist/extensions/pi-subagents/src/shared/atomic-json.ts +83 -0
- package/dist/extensions/pi-subagents/src/shared/capacity-resilient-json.ts +102 -0
- package/dist/extensions/pi-subagents/src/shared/child-session-name.ts +46 -0
- package/dist/extensions/pi-subagents/src/shared/child-transcript.ts +264 -0
- package/dist/extensions/pi-subagents/src/shared/completion-owner.ts +14 -0
- package/dist/extensions/pi-subagents/src/shared/display-text.ts +150 -0
- package/dist/extensions/pi-subagents/src/shared/extension-context.ts +24 -0
- package/dist/extensions/pi-subagents/src/shared/file-coalescer.ts +49 -0
- package/dist/extensions/pi-subagents/src/shared/file-system-retry.ts +95 -0
- package/dist/extensions/pi-subagents/src/shared/fork-context.ts +293 -0
- package/dist/extensions/pi-subagents/src/shared/fork-session-cwd.ts +27 -0
- package/dist/extensions/pi-subagents/src/shared/formatters.ts +146 -0
- package/dist/extensions/pi-subagents/src/shared/jsonl-writer.ts +81 -0
- package/dist/extensions/pi-subagents/src/shared/launch-contract.ts +138 -0
- package/dist/extensions/pi-subagents/src/shared/model-info.ts +101 -0
- package/dist/extensions/pi-subagents/src/shared/node-executable.ts +21 -0
- package/dist/extensions/pi-subagents/src/shared/post-exit-stdio-guard.ts +85 -0
- package/dist/extensions/pi-subagents/src/shared/prompt-resources.ts +11 -0
- package/dist/extensions/pi-subagents/src/shared/pruned-fork.ts +450 -0
- package/dist/extensions/pi-subagents/src/shared/session-file-trust.ts +19 -0
- package/dist/extensions/pi-subagents/src/shared/session-identity.ts +10 -0
- package/dist/extensions/pi-subagents/src/shared/session-tokens.ts +55 -0
- package/dist/extensions/pi-subagents/src/shared/settings.ts +409 -0
- package/dist/extensions/pi-subagents/src/shared/shortcuts.ts +17 -0
- package/dist/extensions/pi-subagents/src/shared/status-format.ts +55 -0
- package/dist/extensions/pi-subagents/src/shared/thinking-ceiling.ts +52 -0
- package/dist/extensions/pi-subagents/src/shared/types.ts +2872 -0
- package/dist/extensions/pi-subagents/src/shared/utf8.ts +11 -0
- package/dist/extensions/pi-subagents/src/shared/utils.ts +601 -0
- package/dist/extensions/pi-subagents/src/shared/watch-strategy.ts +10 -0
- package/dist/extensions/pi-subagents/src/shared/workflow-child-permit.ts +207 -0
- package/dist/extensions/pi-subagents/src/slash/delegation-adapters.ts +426 -0
- package/dist/extensions/pi-subagents/src/slash/delegation-json.ts +108 -0
- package/dist/extensions/pi-subagents/src/slash/delegation-request.ts +162 -0
- package/dist/extensions/pi-subagents/src/slash/prompt-template-bridge.ts +419 -0
- package/dist/extensions/pi-subagents/src/slash/prompt-workflows.ts +287 -0
- package/dist/extensions/pi-subagents/src/slash/selector.ts +147 -0
- package/dist/extensions/pi-subagents/src/slash/slash-bridge.ts +192 -0
- package/dist/extensions/pi-subagents/src/slash/slash-commands.ts +1345 -0
- package/dist/extensions/pi-subagents/src/slash/slash-live-state.ts +310 -0
- package/dist/extensions/pi-subagents/src/slash/subagents-admin.ts +449 -0
- package/dist/extensions/pi-subagents/src/tui/fleet-status.ts +964 -0
- package/dist/extensions/pi-subagents/src/tui/fleet-transcript.ts +536 -0
- package/dist/extensions/pi-subagents/src/tui/fleet.ts +1441 -0
- package/dist/extensions/pi-subagents/src/tui/render-helpers.ts +111 -0
- package/dist/extensions/pi-subagents/src/tui/render.ts +3359 -0
- package/dist/extensions/pi-subagents/src/types/pi-runtime-compat.d.ts +8 -0
- package/dist/extensions/pi-subagents/src/watchdog/change-signature.ts +260 -0
- package/dist/extensions/pi-subagents/src/watchdog/child-status.ts +227 -0
- package/dist/extensions/pi-subagents/src/watchdog/diff-tool.ts +77 -0
- package/dist/extensions/pi-subagents/src/watchdog/emission-guard.ts +125 -0
- package/dist/extensions/pi-subagents/src/watchdog/guidance.ts +20 -0
- package/dist/extensions/pi-subagents/src/watchdog/lsp-diagnostics.ts +538 -0
- package/dist/extensions/pi-subagents/src/watchdog/model-selection.ts +167 -0
- package/dist/extensions/pi-subagents/src/watchdog/permission-arbiter.ts +154 -0
- package/dist/extensions/pi-subagents/src/watchdog/register-child.ts +120 -0
- package/dist/extensions/pi-subagents/src/watchdog/register-main.ts +441 -0
- package/dist/extensions/pi-subagents/src/watchdog/render.ts +53 -0
- package/dist/extensions/pi-subagents/src/watchdog/review.ts +314 -0
- package/dist/extensions/pi-subagents/src/watchdog/rules.ts +70 -0
- package/dist/extensions/pi-subagents/src/watchdog/runtime.ts +851 -0
- package/dist/extensions/pi-subagents/src/watchdog/scope.ts +63 -0
- package/dist/extensions/pi-subagents/src/watchdog/settings.ts +512 -0
- package/dist/extensions/pi-subagents/src/watchdog/tool-actions.ts +155 -0
- package/dist/extensions/pi-subagents/src/watchdog/turn-delta.ts +161 -0
- package/dist/extensions/pi-subagents/src/watchdog/types.ts +184 -0
- package/dist/extensions/pi-subagents/src/watchdog/warning-format.ts +72 -0
- package/dist/extensions/pi-subagents/src/workflows/chat-progress.ts +152 -0
- package/dist/extensions/pi-subagents/src/workflows/host-command.ts +235 -0
- package/dist/extensions/pi-subagents/src/workflows/scripted-workflow.ts +2183 -0
- package/dist/extensions/pi-subagents/src/workflows/workflow-checklist.ts +439 -0
- package/dist/extensions/pi-subagents/src/workflows/workflow-child-summary.ts +121 -0
- package/dist/extensions/pi-subagents/src/workflows/workflow-preflight.ts +297 -0
- package/dist/extensions/pi-subagents/src/workflows/workflow-receipt.ts +330 -0
- package/dist/extensions/pi-subagents/src/workflows/workflow-resources.ts +150 -0
- package/dist/extensions/pi-subagents/src/workflows/workflow-settlement.ts +246 -0
- package/dist/extensions/pi-subagents/test/e2e/real-session-subagent.test.ts +224 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/bun/cli.d.ts +3 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/bun/register-bedrock.d.ts +2 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/bun/restore-sandbox-env.d.ts +17 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/cli/args.d.ts +57 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/cli/config-selector.d.ts +16 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/cli/file-processor.d.ts +15 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/cli/initial-message.d.ts +18 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/cli/list-models.d.ts +9 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/cli/project-trust.d.ts +10 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/cli/session-picker.d.ts +10 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/cli/startup-ui.d.ts +20 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/cli.d.ts +3 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/config.d.ts +96 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/agent-session-runtime.d.ts +119 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/agent-session-services.d.ts +85 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/agent-session.d.ts +620 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/auth-guidance.d.ts +5 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/auth-storage.d.ts +56 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/bash-executor.d.ts +32 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/cache-stats.d.ts +49 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/compaction/branch-summarization.d.ts +93 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/compaction/compaction.d.ts +128 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/compaction/index.d.ts +7 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/compaction/utils.d.ts +38 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/defaults.d.ts +3 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/diagnostics.d.ts +15 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/event-bus.d.ts +9 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/exec.d.ts +29 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/experimental.d.ts +2 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/export-html/ansi-to-html.d.ts +22 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/export-html/index.d.ts +37 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/export-html/tool-renderer.d.ts +34 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/extensions/index.d.ts +12 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/extensions/loader.d.ts +23 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/extensions/runner.d.ts +171 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/extensions/types.d.ts +1261 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/extensions/wrapper.d.ts +20 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/footer-data-provider.d.ts +54 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/http-dispatcher.d.ts +22 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/index.d.ts +13 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/keybindings.d.ts +358 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/messages.d.ts +77 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/model-config.d.ts +512 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/model-registry.d.ts +43 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/model-resolver.d.ts +121 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/model-runtime.d.ts +82 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/models-store.d.ts +17 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/output-guard.d.ts +7 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/package-manager.d.ts +210 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/project-trust.d.ts +15 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/prompt-templates.d.ts +54 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/provider-attribution.d.ts +4 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/provider-composer.d.ts +55 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/radius.d.ts +2 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/remote-catalog-provider.d.ts +5 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/resolve-config-value.d.ts +30 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/resource-loader.d.ts +206 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/runtime-credentials.d.ts +15 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/sdk.d.ts +106 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/session-cwd.d.ts +19 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/session-manager.d.ts +356 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/settings-manager.d.ts +297 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/skills.d.ts +60 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/slash-commands.d.ts +15 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/source-info.d.ts +18 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/system-prompt.d.ts +28 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/telemetry.d.ts +3 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/timings.d.ts +10 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/bash.d.ts +68 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/edit-diff.d.ts +106 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/edit.d.ts +51 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/file-mutation-queue.d.ts +6 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/find.d.ts +35 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/grep.d.ts +37 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/index.d.ts +40 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/ls.d.ts +37 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/output-accumulator.d.ts +52 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/path-utils.d.ts +10 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/read.d.ts +35 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/render-utils.d.ts +24 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/tool-definition-wrapper.d.ts +14 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/truncate.d.ts +70 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/write.d.ts +26 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/trust-manager.d.ts +36 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/usage-totals.d.ts +19 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/extensions/index.d.ts +3 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/extensions/llama/client.d.ts +61 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/extensions/llama/huggingface.d.ts +23 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/extensions/llama/index.d.ts +3 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/extensions/llama/provider.d.ts +10 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/extensions/llama/ui.d.ts +42 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/index.d.ts +35 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/main.d.ts +12 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/migrations.d.ts +33 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/index.d.ts +9 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/armin.d.ts +34 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/assistant-message.d.ts +22 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/bash-execution.d.ts +34 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/bordered-loader.d.ts +16 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/branch-summary-message.d.ts +16 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/compaction-summary-message.d.ts +16 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/config-selector.d.ts +102 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/countdown-timer.d.ts +14 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/custom-editor.d.ts +21 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/custom-entry.d.ts +19 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/custom-message.d.ts +20 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/daxnuts.d.ts +23 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/diff.d.ts +12 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/dynamic-border.d.ts +15 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/earendil-announcement.d.ts +5 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/extension-editor.d.ts +22 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/extension-input.d.ts +23 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/extension-selector.d.ts +26 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/first-time-setup.d.ts +25 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/footer.d.ts +32 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/index.d.ts +34 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/keybinding-hints.d.ts +13 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/login-dialog.d.ts +52 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/model-selector.d.ts +54 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/oauth-selector.d.ts +33 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/scoped-models-selector.d.ts +42 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/session-selector-search.d.ts +23 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/session-selector.d.ts +95 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/settings-selector.d.ts +77 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/show-images-selector.d.ts +10 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/skill-invocation-message.d.ts +17 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/status-indicator.d.ts +28 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/theme-selector.d.ts +11 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/thinking-selector.d.ts +11 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/tool-execution.d.ts +63 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/tree-selector.d.ts +94 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/trust-selector.d.ts +23 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/user-message-selector.d.ts +30 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/user-message.d.ts +14 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/visual-truncate.d.ts +24 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/interactive-mode.d.ts +394 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/model-search.d.ts +12 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/theme/theme-controller.d.ts +29 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/theme/theme.d.ts +120 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/print-mode.d.ts +28 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/rpc/jsonl.d.ts +17 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/rpc/rpc-client.d.ts +246 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/rpc/rpc-mode.d.ts +20 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/rpc/rpc-types.d.ts +457 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/package-manager-cli.d.ts +8 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/rpc-entry.d.ts +3 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/ansi.d.ts +2 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/changelog.d.ts +22 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/child-process.d.ts +18 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/clipboard-image.d.ts +11 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/clipboard-native.d.ts +11 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/clipboard.d.ts +4 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/deprecation.d.ts +4 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/exif-orientation.d.ts +5 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/frontmatter.d.ts +8 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/fs-watch.d.ts +5 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/git.d.ts +26 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/html.d.ts +7 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/image-convert.d.ts +10 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/image-process.d.ts +18 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/image-resize-core.d.ts +30 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/image-resize-worker.d.ts +2 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/image-resize.d.ts +16 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/json.d.ts +3 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/mime.d.ts +3 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/open-browser.d.ts +9 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/paths.d.ts +31 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/photon.d.ts +21 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/pi-user-agent.d.ts +2 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/shell.d.ts +31 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/sleep.d.ts +5 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/syntax-highlight.d.ts +12 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/tools-manager.d.ts +3 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/version-check.d.ts +15 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/windows-self-update.d.ts +3 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/index.mjs +84 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/package.json +14 -0
- package/dist/extensions/pi-subagents/test/integration/acceptance-file-report.test.ts +472 -0
- package/dist/extensions/pi-subagents/test/integration/async-execution.test.ts +6986 -0
- package/dist/extensions/pi-subagents/test/integration/async-job-tracker.test.ts +2000 -0
- package/dist/extensions/pi-subagents/test/integration/async-status.test.ts +1300 -0
- package/dist/extensions/pi-subagents/test/integration/detect-error.test.ts +249 -0
- package/dist/extensions/pi-subagents/test/integration/doctor-executor.test.ts +128 -0
- package/dist/extensions/pi-subagents/test/integration/error-handling.test.ts +281 -0
- package/dist/extensions/pi-subagents/test/integration/external-cli-runner.test.ts +167 -0
- package/dist/extensions/pi-subagents/test/integration/foreground-result-size.test.ts +188 -0
- package/dist/extensions/pi-subagents/test/integration/fork-context-execution.test.ts +1356 -0
- package/dist/extensions/pi-subagents/test/integration/intercom-result-delivery.test.ts +1946 -0
- package/dist/extensions/pi-subagents/test/integration/orca-progress-tabs.test.ts +214 -0
- package/dist/extensions/pi-subagents/test/integration/render-fork-badge.test.ts +1408 -0
- package/dist/extensions/pi-subagents/test/integration/render-widget.test.ts +2094 -0
- package/dist/extensions/pi-subagents/test/integration/result-watcher.test.ts +2442 -0
- package/dist/extensions/pi-subagents/test/integration/session-tokens.test.ts +62 -0
- package/dist/extensions/pi-subagents/test/integration/single-execution.test.ts +9292 -0
- package/dist/extensions/pi-subagents/test/integration/slash-commands.test.ts +1517 -0
- package/dist/extensions/pi-subagents/test/integration/slash-live-state.test.ts +166 -0
- package/dist/extensions/pi-subagents/test/integration/template-resolution.test.ts +344 -0
- package/dist/extensions/pi-subagents/test/integration/top-level-async.test.ts +43 -0
- package/dist/extensions/pi-subagents/test/support/cursor-smoke-inputs.ts +51 -0
- package/dist/extensions/pi-subagents/test/support/helpers.ts +250 -0
- package/dist/extensions/pi-subagents/test/support/isolated-temp-root.mjs +20 -0
- package/dist/extensions/pi-subagents/test/support/mock-pi-script.mjs +447 -0
- package/dist/extensions/pi-subagents/test/support/mock-pi.ts +159 -0
- package/dist/extensions/pi-subagents/test/support/node-command.ts +15 -0
- package/dist/extensions/pi-subagents/test/support/real-session-child-cli.mjs +185 -0
- package/dist/extensions/pi-subagents/test/support/real-session-runner.ts +311 -0
- package/dist/extensions/pi-subagents/test/support/register-loader.mjs +16 -0
- package/dist/extensions/pi-subagents/test/support/session-lease-child.mjs +42 -0
- package/dist/extensions/pi-subagents/test/support/ts-loader.mjs +100 -0
- package/dist/extensions/pi-subagents/test/unit/abort-recovery.test.ts +152 -0
- package/dist/extensions/pi-subagents/test/unit/acceptance.test.ts +1556 -0
- package/dist/extensions/pi-subagents/test/unit/accessible-dir.test.ts +82 -0
- package/dist/extensions/pi-subagents/test/unit/active-async-capacity.test.ts +463 -0
- package/dist/extensions/pi-subagents/test/unit/agent-contract.test.ts +14 -0
- package/dist/extensions/pi-subagents/test/unit/agent-disabled.test.ts +213 -0
- package/dist/extensions/pi-subagents/test/unit/agent-discovery-cache.test.ts +232 -0
- package/dist/extensions/pi-subagents/test/unit/agent-eject-disable.test.ts +343 -0
- package/dist/extensions/pi-subagents/test/unit/agent-frontmatter.test.ts +2324 -0
- package/dist/extensions/pi-subagents/test/unit/agent-management.test.ts +1408 -0
- package/dist/extensions/pi-subagents/test/unit/agent-memory.test.ts +420 -0
- package/dist/extensions/pi-subagents/test/unit/agent-overrides.test.ts +1174 -0
- package/dist/extensions/pi-subagents/test/unit/agent-refinements.test.ts +178 -0
- package/dist/extensions/pi-subagents/test/unit/agent-scan-dirs.test.ts +133 -0
- package/dist/extensions/pi-subagents/test/unit/agent-scope.test.ts +20 -0
- package/dist/extensions/pi-subagents/test/unit/agent-selection.test.ts +88 -0
- package/dist/extensions/pi-subagents/test/unit/agent-stream-options.test.ts +14 -0
- package/dist/extensions/pi-subagents/test/unit/anti-slop-oxlint.test.ts +98 -0
- package/dist/extensions/pi-subagents/test/unit/artifacts.test.ts +78 -0
- package/dist/extensions/pi-subagents/test/unit/async-execution.test.ts +280 -0
- package/dist/extensions/pi-subagents/test/unit/async-interrupt-action.test.ts +1022 -0
- package/dist/extensions/pi-subagents/test/unit/async-permission-session.test.ts +100 -0
- package/dist/extensions/pi-subagents/test/unit/async-recovery-descriptor.test.ts +188 -0
- package/dist/extensions/pi-subagents/test/unit/async-resume.test.ts +978 -0
- package/dist/extensions/pi-subagents/test/unit/async-retention.test.ts +635 -0
- package/dist/extensions/pi-subagents/test/unit/async-status-projection.test.ts +260 -0
- package/dist/extensions/pi-subagents/test/unit/async-status-snapshot.test.ts +204 -0
- package/dist/extensions/pi-subagents/test/unit/atomic-json.test.ts +192 -0
- package/dist/extensions/pi-subagents/test/unit/authority-policy.test.ts +22 -0
- package/dist/extensions/pi-subagents/test/unit/auto-drain.test.ts +83 -0
- package/dist/extensions/pi-subagents/test/unit/background-process-options.test.ts +17 -0
- package/dist/extensions/pi-subagents/test/unit/background-work.test.ts +365 -0
- package/dist/extensions/pi-subagents/test/unit/capability-ceiling-agent-allowlist.test.ts +102 -0
- package/dist/extensions/pi-subagents/test/unit/capability-ceiling-pi-args.test.ts +84 -0
- package/dist/extensions/pi-subagents/test/unit/capability-ceiling.test.ts +68 -0
- package/dist/extensions/pi-subagents/test/unit/capacity-resilient-json.test.ts +155 -0
- package/dist/extensions/pi-subagents/test/unit/chain-append.test.ts +283 -0
- package/dist/extensions/pi-subagents/test/unit/chain-root-attachment.test.ts +236 -0
- package/dist/extensions/pi-subagents/test/unit/chain-serializer.test.ts +229 -0
- package/dist/extensions/pi-subagents/test/unit/child-launch-plan.test.ts +94 -0
- package/dist/extensions/pi-subagents/test/unit/child-protocol.test.ts +202 -0
- package/dist/extensions/pi-subagents/test/unit/child-session-name.test.ts +50 -0
- package/dist/extensions/pi-subagents/test/unit/child-transcript.test.ts +267 -0
- package/dist/extensions/pi-subagents/test/unit/close-grace-timer.test.ts +101 -0
- package/dist/extensions/pi-subagents/test/unit/compaction-resume.test.ts +98 -0
- package/dist/extensions/pi-subagents/test/unit/completion-batcher.test.ts +230 -0
- package/dist/extensions/pi-subagents/test/unit/completion-dedupe.test.ts +35 -0
- package/dist/extensions/pi-subagents/test/unit/completion-evidence.test.ts +150 -0
- package/dist/extensions/pi-subagents/test/unit/completion-guard.test.ts +753 -0
- package/dist/extensions/pi-subagents/test/unit/completion-replay.test.ts +305 -0
- package/dist/extensions/pi-subagents/test/unit/config-dir-runtime.test.ts +107 -0
- package/dist/extensions/pi-subagents/test/unit/control-channel.test.ts +630 -0
- package/dist/extensions/pi-subagents/test/unit/control-notices.test.ts +110 -0
- package/dist/extensions/pi-subagents/test/unit/cursor-smoke-inputs.test.ts +77 -0
- package/dist/extensions/pi-subagents/test/unit/default-extensions.test.ts +219 -0
- package/dist/extensions/pi-subagents/test/unit/delegation-api.test.ts +588 -0
- package/dist/extensions/pi-subagents/test/unit/doctor.test.ts +201 -0
- package/dist/extensions/pi-subagents/test/unit/dynamic-fanout.test.ts +219 -0
- package/dist/extensions/pi-subagents/test/unit/ensure-accessible-dir.test.ts +125 -0
- package/dist/extensions/pi-subagents/test/unit/extension-bindings.test.ts +79 -0
- package/dist/extensions/pi-subagents/test/unit/extension-context.test.ts +27 -0
- package/dist/extensions/pi-subagents/test/unit/external-cli-runner.test.ts +339 -0
- package/dist/extensions/pi-subagents/test/unit/external-job-runner.test.ts +961 -0
- package/dist/extensions/pi-subagents/test/unit/external-runs.test.ts +261 -0
- package/dist/extensions/pi-subagents/test/unit/extra-agent-dirs.test.ts +88 -0
- package/dist/extensions/pi-subagents/test/unit/fast-mode-extension.test.ts +27 -0
- package/dist/extensions/pi-subagents/test/unit/file-coalescer.test.ts +83 -0
- package/dist/extensions/pi-subagents/test/unit/file-system-retry.test.ts +64 -0
- package/dist/extensions/pi-subagents/test/unit/fleet-status.test.ts +1377 -0
- package/dist/extensions/pi-subagents/test/unit/fleet-transcript.test.ts +435 -0
- package/dist/extensions/pi-subagents/test/unit/fleet.test.ts +1786 -0
- package/dist/extensions/pi-subagents/test/unit/foreground-control.test.ts +125 -0
- package/dist/extensions/pi-subagents/test/unit/foreground-tool-call-compaction.test.ts +115 -0
- package/dist/extensions/pi-subagents/test/unit/fork-cache-key.test.ts +91 -0
- package/dist/extensions/pi-subagents/test/unit/fork-context.test.ts +588 -0
- package/dist/extensions/pi-subagents/test/unit/formatters.test.ts +14 -0
- package/dist/extensions/pi-subagents/test/unit/get-final-output.test.ts +175 -0
- package/dist/extensions/pi-subagents/test/unit/herdr-inspector-bootstrap.test.ts +101 -0
- package/dist/extensions/pi-subagents/test/unit/herdr-inspector.test.ts +479 -0
- package/dist/extensions/pi-subagents/test/unit/herdr-session-roots-codec.test.ts +63 -0
- package/dist/extensions/pi-subagents/test/unit/herdr-shell-command.test.ts +59 -0
- package/dist/extensions/pi-subagents/test/unit/herdr-status-bridge.test.ts +716 -0
- package/dist/extensions/pi-subagents/test/unit/host-command.test.ts +157 -0
- package/dist/extensions/pi-subagents/test/unit/host-peer-runtime-imports.test.ts +157 -0
- package/dist/extensions/pi-subagents/test/unit/host-step-status.test.ts +98 -0
- package/dist/extensions/pi-subagents/test/unit/index-child-registration.test.ts +1307 -0
- package/dist/extensions/pi-subagents/test/unit/index-segment.test.ts +96 -0
- package/dist/extensions/pi-subagents/test/unit/inspect-rpc.test.ts +617 -0
- package/dist/extensions/pi-subagents/test/unit/intercom-bridge.test.ts +220 -0
- package/dist/extensions/pi-subagents/test/unit/jsonl-writer.test.ts +119 -0
- package/dist/extensions/pi-subagents/test/unit/llm-intent-arbiter.test.ts +226 -0
- package/dist/extensions/pi-subagents/test/unit/mcp-direct-tool-grant.test.ts +155 -0
- package/dist/extensions/pi-subagents/test/unit/mission-goal-driver.test.ts +180 -0
- package/dist/extensions/pi-subagents/test/unit/mission-lifecycle.test.ts +300 -0
- package/dist/extensions/pi-subagents/test/unit/mission-store.test.ts +470 -0
- package/dist/extensions/pi-subagents/test/unit/mock-pi.test.ts +22 -0
- package/dist/extensions/pi-subagents/test/unit/model-exclusions.test.ts +258 -0
- package/dist/extensions/pi-subagents/test/unit/model-fallback.test.ts +903 -0
- package/dist/extensions/pi-subagents/test/unit/model-info.test.ts +162 -0
- package/dist/extensions/pi-subagents/test/unit/model-scope-settings.test.ts +101 -0
- package/dist/extensions/pi-subagents/test/unit/model-scope.test.ts +198 -0
- package/dist/extensions/pi-subagents/test/unit/mutation-evidence.test.ts +177 -0
- package/dist/extensions/pi-subagents/test/unit/native-supervisor-channel.test.ts +796 -0
- package/dist/extensions/pi-subagents/test/unit/nested-control.test.ts +655 -0
- package/dist/extensions/pi-subagents/test/unit/nested-events.test.ts +492 -0
- package/dist/extensions/pi-subagents/test/unit/node-executable.test.ts +26 -0
- package/dist/extensions/pi-subagents/test/unit/notify.test.ts +816 -0
- package/dist/extensions/pi-subagents/test/unit/orca-progress-tabs.test.ts +545 -0
- package/dist/extensions/pi-subagents/test/unit/owned-process-tree.test.ts +69 -0
- package/dist/extensions/pi-subagents/test/unit/package-manifest.test.ts +241 -0
- package/dist/extensions/pi-subagents/test/unit/parallel-handoff.test.ts +563 -0
- package/dist/extensions/pi-subagents/test/unit/parallel-utils.test.ts +269 -0
- package/dist/extensions/pi-subagents/test/unit/path-handling.test.ts +108 -0
- package/dist/extensions/pi-subagents/test/unit/path-resolution.test.ts +103 -0
- package/dist/extensions/pi-subagents/test/unit/permissions.test.ts +46 -0
- package/dist/extensions/pi-subagents/test/unit/pi-args-permission-system.test.ts +437 -0
- package/dist/extensions/pi-subagents/test/unit/pi-args.test.ts +2347 -0
- package/dist/extensions/pi-subagents/test/unit/pi-coding-agent-dir.test.ts +461 -0
- package/dist/extensions/pi-subagents/test/unit/pi-spawn.test.ts +493 -0
- package/dist/extensions/pi-subagents/test/unit/preflight.test.ts +978 -0
- package/dist/extensions/pi-subagents/test/unit/proactive-skills.test.ts +118 -0
- package/dist/extensions/pi-subagents/test/unit/process-terminal.test.ts +279 -0
- package/dist/extensions/pi-subagents/test/unit/profiles.test.ts +373 -0
- package/dist/extensions/pi-subagents/test/unit/project-panes-public-api.test.ts +293 -0
- package/dist/extensions/pi-subagents/test/unit/prompt-template-bridge.test.ts +244 -0
- package/dist/extensions/pi-subagents/test/unit/prompt-workflows.test.ts +167 -0
- package/dist/extensions/pi-subagents/test/unit/pruned-fork.test.ts +214 -0
- package/dist/extensions/pi-subagents/test/unit/public-execution.test.ts +182 -0
- package/dist/extensions/pi-subagents/test/unit/reads-resolution.test.ts +66 -0
- package/dist/extensions/pi-subagents/test/unit/recursion-guard.test.ts +265 -0
- package/dist/extensions/pi-subagents/test/unit/render-helpers.test.ts +639 -0
- package/dist/extensions/pi-subagents/test/unit/result-delivery-ownership.test.ts +34 -0
- package/dist/extensions/pi-subagents/test/unit/result-files.test.ts +501 -0
- package/dist/extensions/pi-subagents/test/unit/result-intercom.test.ts +258 -0
- package/dist/extensions/pi-subagents/test/unit/retained-children.test.ts +191 -0
- package/dist/extensions/pi-subagents/test/unit/rpc.test.ts +1124 -0
- package/dist/extensions/pi-subagents/test/unit/run-fanout-budget.test.ts +191 -0
- package/dist/extensions/pi-subagents/test/unit/run-id-resolver.test.ts +247 -0
- package/dist/extensions/pi-subagents/test/unit/run-status.test.ts +1545 -0
- package/dist/extensions/pi-subagents/test/unit/runtime-acknowledged-extensions.test.ts +52 -0
- package/dist/extensions/pi-subagents/test/unit/runtime-agent-registration.test.ts +349 -0
- package/dist/extensions/pi-subagents/test/unit/scheduled-runs.test.ts +904 -0
- package/dist/extensions/pi-subagents/test/unit/scheduled-store-root.test.ts +67 -0
- package/dist/extensions/pi-subagents/test/unit/schemas.test.ts +657 -0
- package/dist/extensions/pi-subagents/test/unit/scripted-workflow.test.ts +2501 -0
- package/dist/extensions/pi-subagents/test/unit/selector.test.ts +57 -0
- package/dist/extensions/pi-subagents/test/unit/session-lease.test.ts +339 -0
- package/dist/extensions/pi-subagents/test/unit/single-output.test.ts +361 -0
- package/dist/extensions/pi-subagents/test/unit/skills-fallback.test.ts +709 -0
- package/dist/extensions/pi-subagents/test/unit/slash-bridge.test.ts +115 -0
- package/dist/extensions/pi-subagents/test/unit/spawn-budget.test.ts +124 -0
- package/dist/extensions/pi-subagents/test/unit/stale-run-reconciler.test.ts +440 -0
- package/dist/extensions/pi-subagents/test/unit/status-format.test.ts +26 -0
- package/dist/extensions/pi-subagents/test/unit/steering-action.test.ts +435 -0
- package/dist/extensions/pi-subagents/test/unit/steering-notices.test.ts +58 -0
- package/dist/extensions/pi-subagents/test/unit/steering.test.ts +217 -0
- package/dist/extensions/pi-subagents/test/unit/streamed-progress-bounds.test.ts +78 -0
- package/dist/extensions/pi-subagents/test/unit/subagent-action-recovery.test.ts +85 -0
- package/dist/extensions/pi-subagents/test/unit/subagent-control.test.ts +342 -0
- package/dist/extensions/pi-subagents/test/unit/subagent-guide.test.ts +37 -0
- package/dist/extensions/pi-subagents/test/unit/subagent-prompt-runtime.test.ts +1593 -0
- package/dist/extensions/pi-subagents/test/unit/subagent-startup-retry.test.ts +104 -0
- package/dist/extensions/pi-subagents/test/unit/subagent-wait.test.ts +1367 -0
- package/dist/extensions/pi-subagents/test/unit/task-intent.test.ts +153 -0
- package/dist/extensions/pi-subagents/test/unit/temp-paths.test.ts +147 -0
- package/dist/extensions/pi-subagents/test/unit/thinking-ceiling.test.ts +73 -0
- package/dist/extensions/pi-subagents/test/unit/timeout-defaults.test.ts +138 -0
- package/dist/extensions/pi-subagents/test/unit/tool-budget.test.ts +67 -0
- package/dist/extensions/pi-subagents/test/unit/tool-description.test.ts +308 -0
- package/dist/extensions/pi-subagents/test/unit/tool-timeout.test.ts +108 -0
- package/dist/extensions/pi-subagents/test/unit/total-cost.test.ts +61 -0
- package/dist/extensions/pi-subagents/test/unit/ts-loader.test.ts +33 -0
- package/dist/extensions/pi-subagents/test/unit/types-fork-preamble.test.ts +23 -0
- package/dist/extensions/pi-subagents/test/unit/wait-completions.test.ts +110 -0
- package/dist/extensions/pi-subagents/test/unit/wait-subscriptions.test.ts +663 -0
- package/dist/extensions/pi-subagents/test/unit/watch-strategy.test.ts +24 -0
- package/dist/extensions/pi-subagents/test/unit/watchdog-change-signature.test.ts +434 -0
- package/dist/extensions/pi-subagents/test/unit/watchdog-child-status.test.ts +170 -0
- package/dist/extensions/pi-subagents/test/unit/watchdog-diff-tool.test.ts +79 -0
- package/dist/extensions/pi-subagents/test/unit/watchdog-emission-guard.test.ts +62 -0
- package/dist/extensions/pi-subagents/test/unit/watchdog-lsp-diagnostics.test.ts +144 -0
- package/dist/extensions/pi-subagents/test/unit/watchdog-model-selection.test.ts +121 -0
- package/dist/extensions/pi-subagents/test/unit/watchdog-permission-arbiter.test.ts +113 -0
- package/dist/extensions/pi-subagents/test/unit/watchdog-render.test.ts +75 -0
- package/dist/extensions/pi-subagents/test/unit/watchdog-review.test.ts +372 -0
- package/dist/extensions/pi-subagents/test/unit/watchdog-rules.test.ts +37 -0
- package/dist/extensions/pi-subagents/test/unit/watchdog-runtime.test.ts +990 -0
- package/dist/extensions/pi-subagents/test/unit/watchdog-scope.test.ts +33 -0
- package/dist/extensions/pi-subagents/test/unit/watchdog-settings.test.ts +345 -0
- package/dist/extensions/pi-subagents/test/unit/watchdog-tool-actions.test.ts +91 -0
- package/dist/extensions/pi-subagents/test/unit/watchdog-turn-delta.test.ts +130 -0
- package/dist/extensions/pi-subagents/test/unit/widget-nested-render.test.ts +171 -0
- package/dist/extensions/pi-subagents/test/unit/windows-hide-spawn.test.ts +49 -0
- package/dist/extensions/pi-subagents/test/unit/workflow-chat-progress.test.ts +570 -0
- package/dist/extensions/pi-subagents/test/unit/workflow-checklist.test.ts +223 -0
- package/dist/extensions/pi-subagents/test/unit/workflow-detach-reconcile.test.ts +777 -0
- package/dist/extensions/pi-subagents/test/unit/workflow-graph.test.ts +134 -0
- package/dist/extensions/pi-subagents/test/unit/workflow-launch-params.test.ts +407 -0
- package/dist/extensions/pi-subagents/test/unit/workflow-preflight.test.ts +177 -0
- package/dist/extensions/pi-subagents/test/unit/workflow-receipt.test.ts +461 -0
- package/dist/extensions/pi-subagents/test/unit/workflow-resources.test.ts +98 -0
- package/dist/extensions/pi-subagents/test/unit/workflow-resume-hint.test.ts +365 -0
- package/dist/extensions/pi-subagents/test/unit/worktree-cleanup-plan.test.ts +349 -0
- package/dist/extensions/pi-subagents/test/unit/worktree.test.ts +827 -0
- package/dist/extensions/pi-subagents/test/unit/writer-budget-guidance.test.ts +25 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/effect/index.ts +13 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/effect/rules/no-service-constructor-imports.ts +52 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/index.ts +41 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/rules/no-chained-type-assertions.ts +77 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/rules/no-conditional-empty-object-spread.ts +49 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/rules/no-known-value-widening.ts +247 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/rules/no-module-mocking.ts +91 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/rules/no-object-parameters.ts +126 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/rules/no-reflect-apply.ts +28 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/rules/no-reflect-get.ts +28 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/rules/no-runtime-typeof.ts +67 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/rules/no-shape-in-symbol-names.ts +39 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/rules/no-unknown-parameters.ts +83 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/rules/no-unknown-returns.ts +115 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/rules/no-unknown-type-aliases.ts +72 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/rules/no-unsafe-dictionary-type.ts +134 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/rules/no-widen-then-assert.ts +366 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/rules/require-safety-comment-for-type-assertion.ts +62 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/shared/dictionary-types.ts +502 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/shared/lexical-type-parameters.ts +60 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/shared/reflect-method.ts +35 -0
- package/dist/extensions/pi-subagents/tsconfig.json +15 -0
- package/dist/extensions/pi-tool-display/CHANGELOG.md +329 -0
- package/dist/extensions/pi-tool-display/LICENSE +21 -0
- package/dist/extensions/pi-tool-display/README.md +417 -0
- package/dist/extensions/pi-tool-display/config/config.example.json +40 -0
- package/dist/extensions/pi-tool-display/index.ts +3 -0
- package/dist/extensions/pi-tool-display/package-lock.json +2555 -0
- package/dist/extensions/pi-tool-display/package.json +86 -0
- package/dist/extensions/pi-tool-display/src/agent-dir.ts +35 -0
- package/dist/extensions/pi-tool-display/src/ansi-utils.ts +116 -0
- package/dist/extensions/pi-tool-display/src/bash-display.ts +213 -0
- package/dist/extensions/pi-tool-display/src/capabilities.ts +88 -0
- package/dist/extensions/pi-tool-display/src/config-modal.ts +541 -0
- package/dist/extensions/pi-tool-display/src/config-store.ts +304 -0
- package/dist/extensions/pi-tool-display/src/debug-logger.ts +150 -0
- package/dist/extensions/pi-tool-display/src/diff-presentation.ts +72 -0
- package/dist/extensions/pi-tool-display/src/diff-renderer.ts +2517 -0
- package/dist/extensions/pi-tool-display/src/disposable.ts +34 -0
- package/dist/extensions/pi-tool-display/src/extension-lifecycle.ts +14 -0
- package/dist/extensions/pi-tool-display/src/index.ts +109 -0
- package/dist/extensions/pi-tool-display/src/line-width-safety.ts +93 -0
- package/dist/extensions/pi-tool-display/src/modal-icons.ts +57 -0
- package/dist/extensions/pi-tool-display/src/pending-diff-preview.ts +370 -0
- package/dist/extensions/pi-tool-display/src/presets.ts +117 -0
- package/dist/extensions/pi-tool-display/src/render-utils.ts +186 -0
- package/dist/extensions/pi-tool-display/src/settings-inspector-modal.ts +475 -0
- package/dist/extensions/pi-tool-display/src/thinking-label.ts +343 -0
- package/dist/extensions/pi-tool-display/src/tool-call-box.ts +181 -0
- package/dist/extensions/pi-tool-display/src/tool-metadata.ts +139 -0
- package/dist/extensions/pi-tool-display/src/tool-overrides.ts +2168 -0
- package/dist/extensions/pi-tool-display/src/types.ts +109 -0
- package/dist/extensions/pi-tool-display/src/user-message-box-markdown.ts +64 -0
- package/dist/extensions/pi-tool-display/src/user-message-box-native.ts +66 -0
- package/dist/extensions/pi-tool-display/src/user-message-box-patch.ts +72 -0
- package/dist/extensions/pi-tool-display/src/user-message-box-renderer.ts +419 -0
- package/dist/extensions/pi-tool-display/src/user-message-box-utils.ts +106 -0
- package/dist/extensions/pi-tool-display/src/write-display-utils.ts +31 -0
- package/dist/extensions/pi-tool-display/src/zellij-modal.ts +1027 -0
- package/dist/extensions/pi-tool-display/tests/active-backlog-red.test.ts +65 -0
- package/dist/extensions/pi-tool-display/tests/ansi-utils.test.ts +345 -0
- package/dist/extensions/pi-tool-display/tests/bash-display.test.ts +442 -0
- package/dist/extensions/pi-tool-display/tests/capabilities-edge.test.ts +360 -0
- package/dist/extensions/pi-tool-display/tests/capabilities.test.ts +54 -0
- package/dist/extensions/pi-tool-display/tests/config-modal.test.ts +360 -0
- package/dist/extensions/pi-tool-display/tests/config-store.test.ts +87 -0
- package/dist/extensions/pi-tool-display/tests/custom-tool-overrides.test.ts +415 -0
- package/dist/extensions/pi-tool-display/tests/debug-logger-edge.test.ts +630 -0
- package/dist/extensions/pi-tool-display/tests/debug-logger.test.ts +62 -0
- package/dist/extensions/pi-tool-display/tests/diff-renderer-ansi.test.ts +55 -0
- package/dist/extensions/pi-tool-display/tests/diff-renderer-edge.test.ts +886 -0
- package/dist/extensions/pi-tool-display/tests/diff-renderer-numbering.test.ts +135 -0
- package/dist/extensions/pi-tool-display/tests/diff-renderer-width.test.ts +454 -0
- package/dist/extensions/pi-tool-display/tests/diff-renderer-wrap.test.ts +169 -0
- package/dist/extensions/pi-tool-display/tests/index-integration.test.ts +354 -0
- package/dist/extensions/pi-tool-display/tests/pending-diff-preview.test.ts +79 -0
- package/dist/extensions/pi-tool-display/tests/presets-edge.test.ts +229 -0
- package/dist/extensions/pi-tool-display/tests/presets.test.ts +26 -0
- package/dist/extensions/pi-tool-display/tests/reload-behavior.test.ts +1241 -0
- package/dist/extensions/pi-tool-display/tests/render-utils.test.ts +710 -0
- package/dist/extensions/pi-tool-display/tests/settings-inspector.test.ts +450 -0
- package/dist/extensions/pi-tool-display/tests/thinking-label-edge.test.ts +904 -0
- package/dist/extensions/pi-tool-display/tests/thinking-label.test.ts +72 -0
- package/dist/extensions/pi-tool-display/tests/tool-call-box.test.ts +105 -0
- package/dist/extensions/pi-tool-display/tests/tool-overrides-config.test.ts +613 -0
- package/dist/extensions/pi-tool-display/tests/tool-overrides-mcp.test.ts +499 -0
- package/dist/extensions/pi-tool-display/tests/tool-overrides-registration.test.ts +315 -0
- package/dist/extensions/pi-tool-display/tests/tool-overrides-write-meta.test.ts +68 -0
- package/dist/extensions/pi-tool-display/tests/tool-ui-utils.test.ts +413 -0
- package/dist/extensions/pi-tool-display/tests/user-message-box-performance-red.test.ts +176 -0
- package/dist/extensions/pi-tool-display/tests/user-message-box.test.ts +908 -0
- package/dist/extensions/pi-tool-display/tests/zellij-modal.test.ts +848 -0
- package/dist/extensions/pi-tool-display/tool-display-api-consumer.d.ts +30 -0
- package/dist/extensions/pi-tool-display/tool-display-api-consumer.js +40 -0
- package/dist/extensions/pi-web-agent/CHANGELOG.md +410 -0
- package/dist/extensions/pi-web-agent/README.md +131 -0
- package/dist/extensions/pi-web-agent/package.json +33 -0
- package/dist/extensions/pi-web-agent/src/backends/config.ts +264 -0
- package/dist/extensions/pi-web-agent/src/backends/doctor.ts +272 -0
- package/dist/extensions/pi-web-agent/src/backends/factory.ts +253 -0
- package/dist/extensions/pi-web-agent/src/backends/settings-reader.ts +46 -0
- package/dist/extensions/pi-web-agent/src/cache/ttl-cache.ts +28 -0
- package/dist/extensions/pi-web-agent/src/changelog-notice.ts +136 -0
- package/dist/extensions/pi-web-agent/src/commands/web-agent-config.ts +1082 -0
- package/dist/extensions/pi-web-agent/src/extension.ts +163 -0
- package/dist/extensions/pi-web-agent/src/extract/readability.ts +126 -0
- package/dist/extensions/pi-web-agent/src/fetch/browser-resolution.ts +199 -0
- package/dist/extensions/pi-web-agent/src/fetch/firecrawl-fetch.ts +100 -0
- package/dist/extensions/pi-web-agent/src/fetch/headless-fetch.ts +117 -0
- package/dist/extensions/pi-web-agent/src/fetch/http-fetch.ts +67 -0
- package/dist/extensions/pi-web-agent/src/orchestration/answer-synthesizer.ts +60 -0
- package/dist/extensions/pi-web-agent/src/orchestration/candidate-selector.ts +51 -0
- package/dist/extensions/pi-web-agent/src/orchestration/direct-url.ts +29 -0
- package/dist/extensions/pi-web-agent/src/orchestration/evidence-quality.ts +108 -0
- package/dist/extensions/pi-web-agent/src/orchestration/evidence-ranker.ts +47 -0
- package/dist/extensions/pi-web-agent/src/orchestration/index.ts +28 -0
- package/dist/extensions/pi-web-agent/src/orchestration/query-planner.ts +47 -0
- package/dist/extensions/pi-web-agent/src/orchestration/research-orchestrator.ts +441 -0
- package/dist/extensions/pi-web-agent/src/orchestration/research-types.ts +71 -0
- package/dist/extensions/pi-web-agent/src/orchestration/research-worker.ts +206 -0
- package/dist/extensions/pi-web-agent/src/orchestration/source-profile.ts +105 -0
- package/dist/extensions/pi-web-agent/src/orchestration/stop-decider.ts +81 -0
- package/dist/extensions/pi-web-agent/src/orchestration/url.ts +35 -0
- package/dist/extensions/pi-web-agent/src/presentation/config-store.ts +210 -0
- package/dist/extensions/pi-web-agent/src/presentation/config.ts +75 -0
- package/dist/extensions/pi-web-agent/src/presentation/explore-presentation.ts +73 -0
- package/dist/extensions/pi-web-agent/src/presentation/fetch-presentation.ts +54 -0
- package/dist/extensions/pi-web-agent/src/presentation/search-presentation.ts +53 -0
- package/dist/extensions/pi-web-agent/src/presentation/select-view.ts +20 -0
- package/dist/extensions/pi-web-agent/src/presentation/types.ts +63 -0
- package/dist/extensions/pi-web-agent/src/readers/github-reader.ts +150 -0
- package/dist/extensions/pi-web-agent/src/readers/limits.ts +3 -0
- package/dist/extensions/pi-web-agent/src/readers/pdf-reader.ts +87 -0
- package/dist/extensions/pi-web-agent/src/readers/resolver.ts +25 -0
- package/dist/extensions/pi-web-agent/src/readers/types.ts +11 -0
- package/dist/extensions/pi-web-agent/src/readers/youtube-reader.ts +79 -0
- package/dist/extensions/pi-web-agent/src/search/brave.ts +114 -0
- package/dist/extensions/pi-web-agent/src/search/duckduckgo.ts +99 -0
- package/dist/extensions/pi-web-agent/src/search/exa.ts +109 -0
- package/dist/extensions/pi-web-agent/src/search/fanout.ts +154 -0
- package/dist/extensions/pi-web-agent/src/search/searxng.ts +96 -0
- package/dist/extensions/pi-web-agent/src/search/tavily.ts +113 -0
- package/dist/extensions/pi-web-agent/src/search/tokenin.ts +130 -0
- package/dist/extensions/pi-web-agent/src/search/youcom.ts +109 -0
- package/dist/extensions/pi-web-agent/src/tools/web-explore.ts +71 -0
- package/dist/extensions/pi-web-agent/src/tools/web-fetch-headless.ts +31 -0
- package/dist/extensions/pi-web-agent/src/tools/web-fetch.ts +31 -0
- package/dist/extensions/pi-web-agent/src/tools/web-search.ts +170 -0
- package/dist/extensions/pi-web-agent/src/types.ts +103 -0
- package/dist/extensions/pi-zentui/.editorconfig +12 -0
- package/dist/extensions/pi-zentui/.github/CODEOWNERS +1 -0
- package/dist/extensions/pi-zentui/.github/ISSUE_TEMPLATE/bug_report.yml +110 -0
- package/dist/extensions/pi-zentui/.github/ISSUE_TEMPLATE/config.yml +8 -0
- package/dist/extensions/pi-zentui/.github/ISSUE_TEMPLATE/config_question.yml +56 -0
- package/dist/extensions/pi-zentui/.github/ISSUE_TEMPLATE/feature_request.yml +63 -0
- package/dist/extensions/pi-zentui/.github/ISSUE_TEMPLATE/rendering_issue.yml +106 -0
- package/dist/extensions/pi-zentui/.github/ISSUE_TEMPLATE/runtime_detection.yml +103 -0
- package/dist/extensions/pi-zentui/.github/dependabot.yml +47 -0
- package/dist/extensions/pi-zentui/.github/pull_request_template.md +34 -0
- package/dist/extensions/pi-zentui/.github/release.yml +18 -0
- package/dist/extensions/pi-zentui/.github/workflows/ci.yml +79 -0
- package/dist/extensions/pi-zentui/.github/workflows/publish.yml +63 -0
- package/dist/extensions/pi-zentui/AGENTS.md +107 -0
- package/dist/extensions/pi-zentui/CONTRIBUTING.md +68 -0
- package/dist/extensions/pi-zentui/LICENSE +21 -0
- package/dist/extensions/pi-zentui/README.md +202 -0
- package/dist/extensions/pi-zentui/SECURITY.md +18 -0
- package/dist/extensions/pi-zentui/assets/main-cover.png +0 -0
- package/dist/extensions/pi-zentui/assets/screenshots/editor-accent-rail.png +0 -0
- package/dist/extensions/pi-zentui/assets/screenshots/editor-minimalist.png +0 -0
- package/dist/extensions/pi-zentui/assets/screenshots/editor-opencode-copy-friendly.png +0 -0
- package/dist/extensions/pi-zentui/assets/screenshots/editor-opencode.png +0 -0
- package/dist/extensions/pi-zentui/assets/screenshots/user-message-compact.png +0 -0
- package/dist/extensions/pi-zentui/assets/screenshots/user-message-framed-copy-friendly.png +0 -0
- package/dist/extensions/pi-zentui/assets/screenshots/user-message-framed.png +0 -0
- package/dist/extensions/pi-zentui/assets/screenshots/user-message-labeled.png +0 -0
- package/dist/extensions/pi-zentui/assets/zentui.png +0 -0
- package/dist/extensions/pi-zentui/biome.json +31 -0
- package/dist/extensions/pi-zentui/docs/configuration.md +537 -0
- package/dist/extensions/pi-zentui/docs/footer-format.md +162 -0
- package/dist/extensions/pi-zentui/extensions/zentui/accent-rail-editor.ts +99 -0
- package/dist/extensions/pi-zentui/extensions/zentui/accent-rail-layout-patch.ts +457 -0
- package/dist/extensions/pi-zentui/extensions/zentui/completion-menu.ts +157 -0
- package/dist/extensions/pi-zentui/extensions/zentui/config.ts +2129 -0
- package/dist/extensions/pi-zentui/extensions/zentui/editor-metadata-format.ts +321 -0
- package/dist/extensions/pi-zentui/extensions/zentui/editor-transfer.ts +73 -0
- package/dist/extensions/pi-zentui/extensions/zentui/extension-status.ts +89 -0
- package/dist/extensions/pi-zentui/extensions/zentui/footer-format.ts +364 -0
- package/dist/extensions/pi-zentui/extensions/zentui/footer-layout.ts +122 -0
- package/dist/extensions/pi-zentui/extensions/zentui/footer.ts +812 -0
- package/dist/extensions/pi-zentui/extensions/zentui/format.ts +620 -0
- package/dist/extensions/pi-zentui/extensions/zentui/git.ts +384 -0
- package/dist/extensions/pi-zentui/extensions/zentui/icons.ts +252 -0
- package/dist/extensions/pi-zentui/extensions/zentui/index.ts +1445 -0
- package/dist/extensions/pi-zentui/extensions/zentui/interaction-summary.ts +1049 -0
- package/dist/extensions/pi-zentui/extensions/zentui/live-context.ts +75 -0
- package/dist/extensions/pi-zentui/extensions/zentui/minimalist-editor.ts +463 -0
- package/dist/extensions/pi-zentui/extensions/zentui/package-version.ts +651 -0
- package/dist/extensions/pi-zentui/extensions/zentui/project-refresh.ts +120 -0
- package/dist/extensions/pi-zentui/extensions/zentui/project-state.ts +59 -0
- package/dist/extensions/pi-zentui/extensions/zentui/prototype-patch-registry.ts +210 -0
- package/dist/extensions/pi-zentui/extensions/zentui/repository-root.ts +98 -0
- package/dist/extensions/pi-zentui/extensions/zentui/runtime.ts +841 -0
- package/dist/extensions/pi-zentui/extensions/zentui/selector-border.ts +93 -0
- package/dist/extensions/pi-zentui/extensions/zentui/session-lifecycle.ts +60 -0
- package/dist/extensions/pi-zentui/extensions/zentui/settings-command.ts +1908 -0
- package/dist/extensions/pi-zentui/extensions/zentui/settings-previews.ts +245 -0
- package/dist/extensions/pi-zentui/extensions/zentui/state.ts +94 -0
- package/dist/extensions/pi-zentui/extensions/zentui/style.ts +424 -0
- package/dist/extensions/pi-zentui/extensions/zentui/telemetry.ts +82 -0
- package/dist/extensions/pi-zentui/extensions/zentui/thinking-experimental.ts +1768 -0
- package/dist/extensions/pi-zentui/extensions/zentui/thinking-status.ts +69 -0
- package/dist/extensions/pi-zentui/extensions/zentui/thinking-steps.ts +155 -0
- package/dist/extensions/pi-zentui/extensions/zentui/ui.ts +1291 -0
- package/dist/extensions/pi-zentui/extensions/zentui/user-message-osc.ts +262 -0
- package/dist/extensions/pi-zentui/extensions/zentui/user-message-styles.ts +215 -0
- package/dist/extensions/pi-zentui/extensions/zentui/user-message.ts +206 -0
- package/dist/extensions/pi-zentui/extensions/zentui/working-line-messages.ts +24 -0
- package/dist/extensions/pi-zentui/extensions/zentui/working-line-spinners.ts +54 -0
- package/dist/extensions/pi-zentui/extensions/zentui/working-line.ts +1433 -0
- package/dist/extensions/pi-zentui/package-lock.json +5311 -0
- package/dist/extensions/pi-zentui/package.json +60 -0
- package/dist/extensions/pi-zentui/test/accent-rail-editor.test.ts +232 -0
- package/dist/extensions/pi-zentui/test/accent-rail-layout-patch.test.ts +669 -0
- package/dist/extensions/pi-zentui/test/completion-menu.test.ts +265 -0
- package/dist/extensions/pi-zentui/test/config-load-lifecycle.test.ts +124 -0
- package/dist/extensions/pi-zentui/test/config.test.ts +3199 -0
- package/dist/extensions/pi-zentui/test/editor-metadata-format.test.ts +405 -0
- package/dist/extensions/pi-zentui/test/editor-transfer.test.ts +260 -0
- package/dist/extensions/pi-zentui/test/editor-viewport-indicators.test.ts +1301 -0
- package/dist/extensions/pi-zentui/test/extension-compliance.test.ts +7245 -0
- package/dist/extensions/pi-zentui/test/extension-status.test.ts +182 -0
- package/dist/extensions/pi-zentui/test/fixtures/starship-nerd-font-symbols.toml +172 -0
- package/dist/extensions/pi-zentui/test/footer-format.test.ts +431 -0
- package/dist/extensions/pi-zentui/test/footer-layout.test.ts +113 -0
- package/dist/extensions/pi-zentui/test/footer-repository-path.test.ts +123 -0
- package/dist/extensions/pi-zentui/test/format.test.ts +927 -0
- package/dist/extensions/pi-zentui/test/git.test.ts +212 -0
- package/dist/extensions/pi-zentui/test/icons.test.ts +69 -0
- package/dist/extensions/pi-zentui/test/interaction-summary.test.ts +1402 -0
- package/dist/extensions/pi-zentui/test/live-context-integration.test.ts +378 -0
- package/dist/extensions/pi-zentui/test/live-context.test.ts +139 -0
- package/dist/extensions/pi-zentui/test/minimalist-editor.test.ts +811 -0
- package/dist/extensions/pi-zentui/test/package-contents.mjs +33 -0
- package/dist/extensions/pi-zentui/test/package-version.test.ts +321 -0
- package/dist/extensions/pi-zentui/test/project-refresh.test.ts +250 -0
- package/dist/extensions/pi-zentui/test/project-state.test.ts +159 -0
- package/dist/extensions/pi-zentui/test/prototype-patch-registry.test.ts +131 -0
- package/dist/extensions/pi-zentui/test/repository-root.test.ts +108 -0
- package/dist/extensions/pi-zentui/test/responsive-dependencies.test.ts +825 -0
- package/dist/extensions/pi-zentui/test/runtime.test.ts +183 -0
- package/dist/extensions/pi-zentui/test/session-lifecycle.test.ts +40 -0
- package/dist/extensions/pi-zentui/test/settings-command.test.ts +1663 -0
- package/dist/extensions/pi-zentui/test/settings-previews.test.ts +453 -0
- package/dist/extensions/pi-zentui/test/state.test.ts +84 -0
- package/dist/extensions/pi-zentui/test/telemetry-lifecycle-integration.test.ts +276 -0
- package/dist/extensions/pi-zentui/test/telemetry.test.ts +105 -0
- package/dist/extensions/pi-zentui/test/thinking-experimental-docs.test.ts +51 -0
- package/dist/extensions/pi-zentui/test/thinking-experimental-loader-diagnostics.mjs +54 -0
- package/dist/extensions/pi-zentui/test/thinking-experimental-missing-export.test.ts +44 -0
- package/dist/extensions/pi-zentui/test/thinking-experimental-rows.test.ts +297 -0
- package/dist/extensions/pi-zentui/test/thinking-experimental-tui.mjs +2329 -0
- package/dist/extensions/pi-zentui/test/thinking-experimental.test.ts +1668 -0
- package/dist/extensions/pi-zentui/test/thinking-status.test.ts +85 -0
- package/dist/extensions/pi-zentui/test/thinking-steps.test.ts +122 -0
- package/dist/extensions/pi-zentui/test/turn-summary-lifecycle.integration.test.ts +327 -0
- package/dist/extensions/pi-zentui/test/user-message-osc.test.ts +222 -0
- package/dist/extensions/pi-zentui/test/user-message-styles.test.ts +292 -0
- package/dist/extensions/pi-zentui/test/working-line-lifecycle.integration.test.ts +730 -0
- package/dist/extensions/pi-zentui/test/working-line-messages.test.ts +34 -0
- package/dist/extensions/pi-zentui/test/working-line.test.ts +1990 -0
- package/dist/extensions/pi-zentui/tsconfig.json +16 -0
- package/dist/extensions/ponytail/index.js +176 -0
- package/dist/extensions/ponytail/package.json +8 -0
- package/dist/extensions/ponytail/ponytail-config.cjs +151 -0
- package/dist/extensions/ponytail/ponytail-instructions.cjs +112 -0
- package/dist/extensions/ponytail/test/extension.test.js +299 -0
- package/dist/extensions/ponytail/test/helpers.test.js +312 -0
- package/dist/extensions/question/batch.ts +103 -0
- package/dist/extensions/question/constants.ts +31 -0
- package/dist/extensions/question/helpers.ts +58 -0
- package/dist/extensions/question/index.ts +688 -0
- package/dist/extensions/question/navigation.ts +14 -0
- package/dist/extensions/question/package.json +19 -0
- package/dist/extensions/question/question-list.ts +533 -0
- package/dist/extensions/question/row-layout.ts +165 -0
- package/dist/extensions/question/schemas.ts +43 -0
- package/dist/extensions/question/selection-mode.ts +47 -0
- package/dist/extensions/question/shortcuts.ts +44 -0
- package/dist/extensions/question/tests/batch.test.ts +113 -0
- package/dist/extensions/question/tests/exp.test.ts +70 -0
- package/dist/extensions/question/tests/exp2.test.ts +59 -0
- package/dist/extensions/question/tests/exp3.test.ts +47 -0
- package/dist/extensions/question/tests/helpers.test.ts +93 -0
- package/dist/extensions/question/tests/question-list.test.ts +694 -0
- package/dist/extensions/question/tests/row-layout.test.ts +215 -0
- package/dist/extensions/question/tests/schemas.test.ts +53 -0
- package/dist/extensions/question/tests/selection-mode.test.ts +54 -0
- package/dist/extensions/question/tests/shortcuts.test.ts +107 -0
- package/dist/extensions/question/tests/wizard.test.ts +839 -0
- package/dist/extensions/question/tests/zz-ig3.test.ts +20 -0
- package/dist/extensions/question/tests/zz-probe.test.ts +29 -0
- package/dist/extensions/question/types.ts +132 -0
- package/dist/extensions/rtk.test.ts +320 -0
- package/dist/extensions/rtk.ts +123 -0
- package/dist/extensions/test-resolve-hook-impl.mjs +7 -0
- package/dist/extensions/test-resolve-hook.mjs +7 -0
- package/dist/extensions/tokenin-onboarding.ts +883 -0
- package/dist/extensions/tps.test.ts +38 -0
- package/dist/extensions/tps.ts +349 -0
- package/dist/extensions/undo.test.ts +720 -0
- package/dist/extensions/undo.ts +298 -0
- package/dist/extensions/web-agent-onboarding.test.ts +415 -0
- package/dist/extensions/web-agent-onboarding.ts +222 -0
- package/dist/index.d.ts +36 -0
- package/dist/index.js +48 -0
- package/dist/main.d.ts +11 -0
- package/dist/main.js +768 -0
- package/dist/migrations.d.ts +32 -0
- package/dist/migrations.js +280 -0
- package/dist/modes/index.d.ts +8 -0
- package/dist/modes/index.js +7 -0
- package/dist/modes/interactive/assets/clankolas.png +0 -0
- package/dist/modes/interactive/components/armin.d.ts +33 -0
- package/dist/modes/interactive/components/armin.js +332 -0
- package/dist/modes/interactive/components/assistant-message.d.ts +21 -0
- package/dist/modes/interactive/components/assistant-message.js +142 -0
- package/dist/modes/interactive/components/bash-execution.d.ts +33 -0
- package/dist/modes/interactive/components/bash-execution.js +174 -0
- package/dist/modes/interactive/components/bordered-loader.d.ts +15 -0
- package/dist/modes/interactive/components/bordered-loader.js +53 -0
- package/dist/modes/interactive/components/branch-summary-message.d.ts +15 -0
- package/dist/modes/interactive/components/branch-summary-message.js +43 -0
- package/dist/modes/interactive/components/compaction-summary-message.d.ts +15 -0
- package/dist/modes/interactive/components/compaction-summary-message.js +44 -0
- package/dist/modes/interactive/components/config-selector.d.ts +101 -0
- package/dist/modes/interactive/components/config-selector.js +760 -0
- package/dist/modes/interactive/components/countdown-timer.d.ts +13 -0
- package/dist/modes/interactive/components/countdown-timer.js +32 -0
- package/dist/modes/interactive/components/custom-editor.d.ts +20 -0
- package/dist/modes/interactive/components/custom-editor.js +69 -0
- package/dist/modes/interactive/components/custom-entry.d.ts +18 -0
- package/dist/modes/interactive/components/custom-entry.js +51 -0
- package/dist/modes/interactive/components/custom-message.d.ts +21 -0
- package/dist/modes/interactive/components/custom-message.js +86 -0
- package/dist/modes/interactive/components/daxnuts.d.ts +22 -0
- package/dist/modes/interactive/components/daxnuts.js +139 -0
- package/dist/modes/interactive/components/diff.d.ts +11 -0
- package/dist/modes/interactive/components/diff.js +132 -0
- package/dist/modes/interactive/components/dynamic-border.d.ts +14 -0
- package/dist/modes/interactive/components/dynamic-border.js +20 -0
- package/dist/modes/interactive/components/earendil-announcement.d.ts +4 -0
- package/dist/modes/interactive/components/earendil-announcement.js +39 -0
- package/dist/modes/interactive/components/extension-editor.d.ts +20 -0
- package/dist/modes/interactive/components/extension-editor.js +97 -0
- package/dist/modes/interactive/components/extension-input.d.ts +22 -0
- package/dist/modes/interactive/components/extension-input.js +60 -0
- package/dist/modes/interactive/components/extension-selector.d.ts +25 -0
- package/dist/modes/interactive/components/extension-selector.js +82 -0
- package/dist/modes/interactive/components/first-time-setup.d.ts +24 -0
- package/dist/modes/interactive/components/first-time-setup.js +116 -0
- package/dist/modes/interactive/components/footer.d.ts +31 -0
- package/dist/modes/interactive/components/footer.js +221 -0
- package/dist/modes/interactive/components/index.d.ts +33 -0
- package/dist/modes/interactive/components/index.js +34 -0
- package/dist/modes/interactive/components/keybinding-hints.d.ts +12 -0
- package/dist/modes/interactive/components/keybinding-hints.js +35 -0
- package/dist/modes/interactive/components/login-dialog.d.ts +51 -0
- package/dist/modes/interactive/components/login-dialog.js +187 -0
- package/dist/modes/interactive/components/model-selector.d.ts +63 -0
- package/dist/modes/interactive/components/model-selector.js +321 -0
- package/dist/modes/interactive/components/oauth-selector.d.ts +32 -0
- package/dist/modes/interactive/components/oauth-selector.js +162 -0
- package/dist/modes/interactive/components/scoped-models-selector.d.ts +41 -0
- package/dist/modes/interactive/components/scoped-models-selector.js +301 -0
- package/dist/modes/interactive/components/session-selector-search.d.ts +22 -0
- package/dist/modes/interactive/components/session-selector-search.js +154 -0
- package/dist/modes/interactive/components/session-selector.d.ts +94 -0
- package/dist/modes/interactive/components/session-selector.js +866 -0
- package/dist/modes/interactive/components/settings-selector.d.ts +103 -0
- package/dist/modes/interactive/components/settings-selector.js +726 -0
- package/dist/modes/interactive/components/show-images-selector.d.ts +9 -0
- package/dist/modes/interactive/components/show-images-selector.js +38 -0
- package/dist/modes/interactive/components/skill-invocation-message.d.ts +16 -0
- package/dist/modes/interactive/components/skill-invocation-message.js +46 -0
- package/dist/modes/interactive/components/startup-box.d.ts +38 -0
- package/dist/modes/interactive/components/startup-box.js +90 -0
- package/dist/modes/interactive/components/status-indicator.d.ts +30 -0
- package/dist/modes/interactive/components/status-indicator.js +64 -0
- package/dist/modes/interactive/components/theme-selector.d.ts +10 -0
- package/dist/modes/interactive/components/theme-selector.js +49 -0
- package/dist/modes/interactive/components/thinking-selector.d.ts +10 -0
- package/dist/modes/interactive/components/thinking-selector.js +51 -0
- package/dist/modes/interactive/components/tool-execution.d.ts +62 -0
- package/dist/modes/interactive/components/tool-execution.js +325 -0
- package/dist/modes/interactive/components/tree-selector.d.ts +93 -0
- package/dist/modes/interactive/components/tree-selector.js +1244 -0
- package/dist/modes/interactive/components/trust-selector.d.ts +22 -0
- package/dist/modes/interactive/components/trust-selector.js +90 -0
- package/dist/modes/interactive/components/user-message-selector.d.ts +29 -0
- package/dist/modes/interactive/components/user-message-selector.js +113 -0
- package/dist/modes/interactive/components/user-message.d.ts +13 -0
- package/dist/modes/interactive/components/user-message.js +41 -0
- package/dist/modes/interactive/components/visual-truncate.d.ts +23 -0
- package/dist/modes/interactive/components/visual-truncate.js +32 -0
- package/dist/modes/interactive/external-editor.d.ts +11 -0
- package/dist/modes/interactive/external-editor.js +36 -0
- package/dist/modes/interactive/interactive-mode.d.ts +447 -0
- package/dist/modes/interactive/interactive-mode.js +5489 -0
- package/dist/modes/interactive/model-catalog-refresh.d.ts +6 -0
- package/dist/modes/interactive/model-catalog-refresh.js +33 -0
- package/dist/modes/interactive/model-search.d.ts +11 -0
- package/dist/modes/interactive/model-search.js +14 -0
- package/dist/modes/interactive/theme/dark.json +90 -0
- package/dist/modes/interactive/theme/light.json +89 -0
- package/dist/modes/interactive/theme/theme-controller.d.ts +39 -0
- package/dist/modes/interactive/theme/theme-controller.js +124 -0
- package/dist/modes/interactive/theme/theme-schema.json +348 -0
- package/dist/modes/interactive/theme/theme.d.ts +121 -0
- package/dist/modes/interactive/theme/theme.js +1090 -0
- package/dist/modes/print-mode.d.ts +27 -0
- package/dist/modes/print-mode.js +141 -0
- package/dist/modes/rpc/jsonl.d.ts +16 -0
- package/dist/modes/rpc/jsonl.js +48 -0
- package/dist/modes/rpc/rpc-client.d.ts +438 -0
- package/dist/modes/rpc/rpc-client.js +712 -0
- package/dist/modes/rpc/rpc-mode.d.ts +19 -0
- package/dist/modes/rpc/rpc-mode.js +1459 -0
- package/dist/modes/rpc/rpc-types.d.ts +902 -0
- package/dist/modes/rpc/rpc-types.js +7 -0
- package/dist/package-manager-cli.d.ts +7 -0
- package/dist/package-manager-cli.js +789 -0
- package/dist/rpc-entry.d.ts +2 -0
- package/dist/rpc-entry.js +9 -0
- package/dist/skills/agent-browser/SKILL.md +53 -0
- package/dist/skills/batch-grill-me/SKILL.md +20 -0
- package/dist/skills/brandkit/SKILL.md +798 -0
- package/dist/skills/brutalist/SKILL.md +92 -0
- package/dist/skills/design-references/SKILL.md +32 -0
- package/dist/skills/design-references/references/clickhouse/DESIGN.md +544 -0
- package/dist/skills/gpt-taste/SKILL.md +74 -0
- package/dist/skills/grill-me/SKILL.md +11 -0
- package/dist/skills/handoff/SKILL.md +17 -0
- package/dist/skills/handoff-text/SKILL.md +15 -0
- package/dist/skills/image-to-code/SKILL.md +1228 -0
- package/dist/skills/imagegen-frontend-mobile/SKILL.md +1465 -0
- package/dist/skills/imagegen-frontend-web/SKILL.md +987 -0
- package/dist/skills/implanger/SKILL.md +70 -0
- package/dist/skills/improve-codebase/REFERENCE.md +78 -0
- package/dist/skills/improve-codebase/SKILL.md +180 -0
- package/dist/skills/minimalist/SKILL.md +85 -0
- package/dist/skills/output/SKILL.md +49 -0
- package/dist/skills/pi-subagents/SKILL.md +50 -0
- package/dist/skills/pi-subagents/references/constraints-and-recipes.md +274 -0
- package/dist/skills/pi-subagents/references/execution-controls.md +463 -0
- package/dist/skills/pi-subagents/references/management-authoring-rpc.md +161 -0
- package/dist/skills/pi-subagents/references/multi-lane-orchestration.md +39 -0
- package/dist/skills/pi-subagents/references/prompting-and-roles.md +267 -0
- package/dist/skills/planger/SKILL.md +167 -0
- package/dist/skills/ponytail/SKILL.md +121 -0
- package/dist/skills/ponytail-audit/SKILL.md +42 -0
- package/dist/skills/ponytail-debt/SKILL.md +45 -0
- package/dist/skills/ponytail-gain/SKILL.md +51 -0
- package/dist/skills/ponytail-help/SKILL.md +72 -0
- package/dist/skills/ponytail-review/SKILL.md +58 -0
- package/dist/skills/redesign/SKILL.md +178 -0
- package/dist/skills/selesai-handoff/SKILL.md +21 -0
- package/dist/skills/soft/SKILL.md +98 -0
- package/dist/skills/stitch/DESIGN.md +121 -0
- package/dist/skills/stitch/SKILL.md +184 -0
- package/dist/skills/taste/SKILL.md +1206 -0
- package/dist/skills/taste-v1/SKILL.md +226 -0
- package/dist/skills/unlazy/CHANGELOG.md +109 -0
- package/dist/skills/unlazy/CONTRIBUTING.md +63 -0
- package/dist/skills/unlazy/LICENSE +21 -0
- package/dist/skills/unlazy/README.md +228 -0
- package/dist/skills/unlazy/SECURITY.md +60 -0
- package/dist/skills/unlazy/SKILL.md +93 -0
- package/dist/skills/unlazy/package.json +13 -0
- package/dist/skills/unlazy/references/dispatch.md +79 -0
- package/dist/skills/unlazy/references/gates.md +132 -0
- package/dist/skills/unlazy/references/method.md +49 -0
- package/dist/skills/unlazy/references/orchestration.md +98 -0
- package/dist/skills/unlazy/references/parallel.md +111 -0
- package/dist/skills/unlazy/references/token-economy.md +39 -0
- package/dist/skills/unlazy/research/validation-protocol.md +81 -0
- package/dist/skills/unlazy/scripts/dispatch-check.mjs +108 -0
- package/dist/skills/unlazy/scripts/gate-check.mjs +879 -0
- package/dist/skills/unlazy/scripts/gate-lint.mjs +178 -0
- package/dist/skills/unlazy/scripts/lib/check-supervisor.mjs +46 -0
- package/dist/skills/unlazy/scripts/lib/dispatch.mjs +283 -0
- package/dist/skills/unlazy/scripts/lib/gates.mjs +625 -0
- package/dist/skills/unlazy/scripts/lib/process-tree.mjs +161 -0
- package/dist/skills/unlazy/scripts/lib/regex-worker.mjs +9 -0
- package/dist/skills/unlazy/templates/PLAN.md +65 -0
- package/dist/skills/unlazy/templates/gates-leaf.md +51 -0
- package/dist/skills/unlazy/templates/gates-node.md +50 -0
- package/dist/skills/unlazy/tests/contract-tests.mjs +127 -0
- package/dist/skills/unlazy/tests/dispatch-tests.mjs +296 -0
- package/dist/skills/unlazy/tests/hardening-tests.mjs +900 -0
- package/dist/skills/unlazy/tests/lint-tests.mjs +242 -0
- package/dist/skills/unlazy/tests/run-tests.mjs +360 -0
- package/dist/skills/unlazy/tests/self-check.mjs +152 -0
- package/dist/skills/unlazy/tests/stress-tests.mjs +165 -0
- package/dist/skills/web-design-guidelines/SKILL.md +41 -0
- package/dist/skills/workflow/SKILL.md +95 -0
- package/dist/themes/adventure.json +84 -0
- package/dist/themes/adwaita-dark.json +84 -0
- package/dist/themes/arcoiris.json +84 -0
- package/dist/themes/arthur.json +84 -0
- package/dist/themes/atom.json +84 -0
- package/dist/themes/aura.json +84 -0
- package/dist/themes/black-metal-bathory.json +84 -0
- package/dist/themes/black-metal-burzum.json +84 -0
- package/dist/themes/black-metal-khold.json +84 -0
- package/dist/themes/box.json +84 -0
- package/dist/themes/brogrammer.json +84 -0
- package/dist/themes/carbonfox.json +84 -0
- package/dist/themes/catppuccin-mocha.json +84 -0
- package/dist/themes/citruszest.json +84 -0
- package/dist/themes/cursor-dark.json +84 -0
- package/dist/themes/cutie-pro.json +84 -0
- package/dist/themes/dark-modern.json +84 -0
- package/dist/themes/dark-pastel.json +84 -0
- package/dist/themes/dimmed-monokai.json +84 -0
- package/dist/themes/doom-peacock.json +84 -0
- package/dist/themes/dracula-plus.json +84 -0
- package/dist/themes/dracula.json +80 -0
- package/dist/themes/earthsong.json +84 -0
- package/dist/themes/everforest-dark-hard.json +84 -0
- package/dist/themes/everforest-dark.json +80 -0
- package/dist/themes/fahrenheit.json +84 -0
- package/dist/themes/flatland.json +84 -0
- package/dist/themes/flexoki-dark.json +84 -0
- package/dist/themes/front-end-delight.json +84 -0
- package/dist/themes/fun-forrest.json +84 -0
- package/dist/themes/galizur.json +84 -0
- package/dist/themes/github-dark-colorblind.json +84 -0
- package/dist/themes/github-dark-high-contrast.json +84 -0
- package/dist/themes/glacier.json +84 -0
- package/dist/themes/gruber-darker.json +84 -0
- package/dist/themes/gruvbox-dark-hard.json +84 -0
- package/dist/themes/gruvbox-dark.json +84 -0
- package/dist/themes/gruvbox-material.json +84 -0
- package/dist/themes/guezwhoz.json +84 -0
- package/dist/themes/hacktober.json +84 -0
- package/dist/themes/hardcore.json +84 -0
- package/dist/themes/havn-skumring.json +84 -0
- package/dist/themes/ic-orange-ppl.json +84 -0
- package/dist/themes/iterm2-smoooooth.json +84 -0
- package/dist/themes/iterm2-tango-dark.json +84 -0
- package/dist/themes/japanesque.json +84 -0
- package/dist/themes/jellybeans.json +84 -0
- package/dist/themes/kanagawa-wave.json +84 -0
- package/dist/themes/kurokula.json +84 -0
- package/dist/themes/later-this-evening.json +84 -0
- package/dist/themes/lovelace.json +84 -0
- package/dist/themes/material-darker.json +84 -0
- package/dist/themes/matte-black.json +84 -0
- package/dist/themes/mellow.json +84 -0
- package/dist/themes/miasma.json +84 -0
- package/dist/themes/nord.json +80 -0
- package/dist/themes/nvim-dark.json +84 -0
- package/dist/themes/one-dark.json +80 -0
- package/dist/themes/popping-and-locking.json +84 -0
- package/dist/themes/rose-pine.json +80 -0
- package/dist/themes/sea-shells.json +84 -0
- package/dist/themes/sleepy-hollow.json +84 -0
- package/dist/themes/smyck.json +84 -0
- package/dist/themes/solarized-dark.json +80 -0
- package/dist/themes/tokyo-night.json +80 -0
- package/dist/themes/tomorrow-night-bright.json +84 -0
- package/dist/themes/tomorrow-night-burns.json +84 -0
- package/dist/themes/tomorrow-night.json +84 -0
- package/dist/themes/twilight.json +84 -0
- package/dist/themes/vague.json +84 -0
- package/dist/themes/vesper.json +84 -0
- package/dist/themes/xcode-dark-hc.json +84 -0
- package/dist/utils/abort.d.ts +4 -0
- package/dist/utils/abort.js +47 -0
- package/dist/utils/ansi.d.ts +1 -0
- package/dist/utils/ansi.js +51 -0
- package/dist/utils/changelog.d.ts +21 -0
- package/dist/utils/changelog.js +164 -0
- package/dist/utils/child-process.d.ts +17 -0
- package/dist/utils/child-process.js +105 -0
- package/dist/utils/clipboard-image.d.ts +10 -0
- package/dist/utils/clipboard-image.js +250 -0
- package/dist/utils/clipboard-native.d.ts +10 -0
- package/dist/utils/clipboard-native.js +19 -0
- package/dist/utils/clipboard.d.ts +3 -0
- package/dist/utils/clipboard.js +140 -0
- package/dist/utils/deprecation.d.ts +3 -0
- package/dist/utils/deprecation.js +12 -0
- package/dist/utils/exif-orientation.d.ts +4 -0
- package/dist/utils/exif-orientation.js +157 -0
- package/dist/utils/frontmatter.d.ts +7 -0
- package/dist/utils/frontmatter.js +25 -0
- package/dist/utils/fs-watch.d.ts +4 -0
- package/dist/utils/fs-watch.js +24 -0
- package/dist/utils/git.d.ts +25 -0
- package/dist/utils/git.js +194 -0
- package/dist/utils/html.d.ts +6 -0
- package/dist/utils/html.js +39 -0
- package/dist/utils/image-convert.d.ts +9 -0
- package/dist/utils/image-convert.js +44 -0
- package/dist/utils/image-process.d.ts +17 -0
- package/dist/utils/image-process.js +82 -0
- package/dist/utils/image-resize-core.d.ts +29 -0
- package/dist/utils/image-resize-core.js +123 -0
- package/dist/utils/image-resize-worker.d.ts +1 -0
- package/dist/utils/image-resize-worker.js +30 -0
- package/dist/utils/image-resize.d.ts +15 -0
- package/dist/utils/image-resize.js +96 -0
- package/dist/utils/json.d.ts +2 -0
- package/dist/utils/json.js +6 -0
- package/dist/utils/mime.d.ts +2 -0
- package/dist/utils/mime.js +132 -0
- package/dist/utils/open-browser.d.ts +8 -0
- package/dist/utils/open-browser.js +21 -0
- package/dist/utils/paths.d.ts +30 -0
- package/dist/utils/paths.js +91 -0
- package/dist/utils/photon.d.ts +20 -0
- package/dist/utils/photon.js +120 -0
- package/dist/utils/pi-user-agent.d.ts +1 -0
- package/dist/utils/pi-user-agent.js +4 -0
- package/dist/utils/shell.d.ts +33 -0
- package/dist/utils/shell.js +215 -0
- package/dist/utils/sleep.d.ts +4 -0
- package/dist/utils/sleep.js +16 -0
- package/dist/utils/syntax-highlight.d.ts +11 -0
- package/dist/utils/syntax-highlight.js +117 -0
- package/dist/utils/thinking-tags.d.ts +6 -0
- package/dist/utils/thinking-tags.js +62 -0
- package/dist/utils/tools-manager.d.ts +7 -0
- package/dist/utils/tools-manager.js +402 -0
- package/dist/utils/version-check.d.ts +19 -0
- package/dist/utils/version-check.js +72 -0
- package/dist/utils/windows-self-update.d.ts +2 -0
- package/dist/utils/windows-self-update.js +76 -0
- package/package.json +1 -1
|
@@ -0,0 +1,2080 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Async execution logic for subagent tool
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { spawn } from "node:child_process";
|
|
6
|
+
import { randomUUID } from "node:crypto";
|
|
7
|
+
import * as fs from "node:fs";
|
|
8
|
+
import * as path from "node:path";
|
|
9
|
+
import { fileURLToPath } from "node:url";
|
|
10
|
+
import { createRequire } from "node:module";
|
|
11
|
+
import type { ExtensionAPI } from "@selesai/code";
|
|
12
|
+
import { discoverAgents, formatUnknownAgentError, unknownAgentDiagnosticContext, type AgentConfig, type UnknownAgentDiagnosticContext } from "../../agents/agents.ts";
|
|
13
|
+
import { appendAgentRefinementOverlay } from "../../agents/agent-refinements.ts";
|
|
14
|
+
import { createAtomicJsonWriter, writePrivateAtomicJson } from "../../shared/atomic-json.ts";
|
|
15
|
+
import { currentCompletionOwnerId } from "../../shared/completion-owner.ts";
|
|
16
|
+
import { planChildLaunch, resolveStepBehavior, suppressProgressForReadOnlyTask, type ResolvedStepBehavior } from "../shared/child-launch-plan.ts";
|
|
17
|
+
import { applyThinkingSuffix, projectLaunchResolvedChildExtensions, resolvePiLaunchToolPlan } from "../shared/pi-args.ts";
|
|
18
|
+
import { injectOutputPathSystemPrompt, injectSingleOutputInstruction, normalizeSingleOutputOverride, resolveSingleOutputPath, validateFileOnlyOutputMode } from "../shared/single-output.ts";
|
|
19
|
+
import { applyWatchdogLaunchRules, sendRuleViolationWarning } from "../../watchdog/rules.ts";
|
|
20
|
+
import { buildChainInstructions, isDynamicParallelStep, isParallelStep, resolveExistingReadInstructionPaths, resolveExistingReadPaths, writeInitialProgressFile, type ChainStep, type SequentialStep, type StepOverrides } from "../../shared/settings.ts";
|
|
21
|
+
import type { RunnerStep } from "../shared/parallel-utils.ts";
|
|
22
|
+
import type { ContextMode } from "../shared/context-mode.ts";
|
|
23
|
+
import { resolveInstalledPiPackageRoot, resolvePiPackageRoot } from "../shared/pi-spawn.ts";
|
|
24
|
+
import { backgroundProcessOptions } from "../shared/background-process-options.ts";
|
|
25
|
+
import { preflightLaunchCwd } from "../shared/launch-cwd.ts";
|
|
26
|
+
import { resolveNodeExecutable } from "../../shared/node-executable.ts";
|
|
27
|
+
import { buildSkillInjection, normalizeSkillInput, resolveSkillsWithFallback } from "../../agents/skills.ts";
|
|
28
|
+
import { buildAgentMemoryInjection } from "../../agents/agent-memory.ts";
|
|
29
|
+
import { SELESAI_CODING_AGENT_PACKAGE_ROOT_ENV, PROMPT_REDACTED, resolveChildCwd } from "../../shared/utils.ts";
|
|
30
|
+
import { buildModelCandidates, resolveEffectiveSubagentModel, resolveModelOrigin, resolveSubagentModelOverride, type AvailableModelInfo, type ModelOrigin, type ParentModel } from "../shared/model-fallback.ts";
|
|
31
|
+
import { resolveToolTimeoutMs, toolTimeoutFromEnv } from "../shared/tool-timeout.ts";
|
|
32
|
+
import { resolveModelScopesForAgent, type ModelScopeConfig } from "../shared/model-scope.ts";
|
|
33
|
+
import { findModelInfo, resolveEffectiveThinking } from "../../shared/model-info.ts";
|
|
34
|
+
import { assertThinkingWithinCeiling, decodeThinkingCeiling, intersectThinkingCeilings, SUBAGENT_THINKING_CEILING_ENV, type ThinkingLevel } from "../../shared/thinking-ceiling.ts";
|
|
35
|
+
import { resolveExpectedWorktreeAgentCwd, resolveWorktreeProvider, shouldDeferWorktreeCwd, WORKTREE_AGENT_CWD_PLACEHOLDER } from "../shared/worktree.ts";
|
|
36
|
+
import { buildWorkflowGraphSnapshot } from "../shared/workflow-graph.ts";
|
|
37
|
+
import { ChainOutputValidationError, validateChainOutputBindings } from "../shared/chain-outputs.ts";
|
|
38
|
+
import { createStructuredOutputRuntime } from "../shared/structured-output.ts";
|
|
39
|
+
import { resolveAcceptanceReportMode, resolveEffectiveAcceptance, validateAcceptanceInput, validateExecutionAcceptance } from "../shared/acceptance.ts";
|
|
40
|
+
import { createRunFanoutBudget, writeRunFanoutBudgetDescriptor } from "../shared/run-fanout-budget.ts";
|
|
41
|
+
import { validateImplementationToolContract } from "../shared/completion-guard.ts";
|
|
42
|
+
import {
|
|
43
|
+
type AcceptanceInput,
|
|
44
|
+
type AgentContract,
|
|
45
|
+
type AsyncParallelGroupStatus,
|
|
46
|
+
type AsyncStatus,
|
|
47
|
+
type ArtifactConfig,
|
|
48
|
+
type Details,
|
|
49
|
+
type IntercomBridgeConfig,
|
|
50
|
+
type JsonSchemaObject,
|
|
51
|
+
type MaxOutputConfig,
|
|
52
|
+
type NestedRouteInfo,
|
|
53
|
+
type ResolvedControlConfig,
|
|
54
|
+
type ResolvedToolBudget,
|
|
55
|
+
type RunFanoutBudgetDescriptor,
|
|
56
|
+
type ToolBudgetConfig,
|
|
57
|
+
type SubagentRunMode,
|
|
58
|
+
type SteeringRecoveryDescriptor,
|
|
59
|
+
type WorkflowLaneMetadata,
|
|
60
|
+
type UsageBudgetConfig,
|
|
61
|
+
DIRS,
|
|
62
|
+
SUBAGENT_ASYNC_STARTED_EVENT,
|
|
63
|
+
SUBAGENT_LIFECYCLE_ARTIFACT_VERSION,
|
|
64
|
+
TEMP_ROOT_DIR,
|
|
65
|
+
getAsyncConfigPath,
|
|
66
|
+
resolveChildMaxSubagentDepth,
|
|
67
|
+
} from "../../shared/types.ts";
|
|
68
|
+
import { nestedResultsPath, nestedSummaryFromAsyncStatus, resolveInheritedNestedRouteFromEnv, resolveNestedParentAddressFromEnv, writeNestedEvent } from "../shared/nested-events.ts";
|
|
69
|
+
import { resultFilePath } from "./result-files.ts";
|
|
70
|
+
import { validateToolBudgetConfig } from "../shared/tool-budget.ts";
|
|
71
|
+
import { usageBudgetState } from "../shared/usage-budget.ts";
|
|
72
|
+
import type { ImportedAsyncRoot } from "./chain-root-attachment.ts";
|
|
73
|
+
import type { SessionLeaseRequest } from "../shared/session-lease.ts";
|
|
74
|
+
import { finalizeProcessTerminal, initializeProcessTerminal, readProcessTerminal } from "./process-terminal.ts";
|
|
75
|
+
import type { ActiveAsyncCapacityHandle } from "./active-async-capacity.ts";
|
|
76
|
+
import { statusStepDescription } from "./chain-append.ts";
|
|
77
|
+
import { SUBAGENT_PROCESS_TERMINAL_EVENT } from "../../shared/types.ts";
|
|
78
|
+
import { assertAgentAllowedByCapabilityCeiling, decodeSubagentCapabilityCeiling, intersectSubagentCapabilityCeilings, resolveCurrentSubagentCapabilityCeiling, SUBAGENT_CAPABILITY_CEILING_ENV, type ResolvedSubagentCapabilityCeiling } from "../shared/capability-ceiling.ts";
|
|
79
|
+
import { agentDefinitionDigest, launchBindingDigest } from "../../shared/launch-contract.ts";
|
|
80
|
+
import { resolvePermissionRules, type PermissionConfig } from "../shared/permissions.ts";
|
|
81
|
+
import { normalizeExtensionBindings, omitExtensionBindingsEnv, type ExtensionBindings } from "../shared/extension-bindings.ts";
|
|
82
|
+
import { assertWorkflowLaneKey, normalizeWorkflowLaneMetadata } from "../shared/lane-metadata.ts";
|
|
83
|
+
|
|
84
|
+
const require = createRequire(import.meta.url);
|
|
85
|
+
const piPackageRoot = resolvePiPackageRoot() ?? resolveInstalledPiPackageRoot();
|
|
86
|
+
|
|
87
|
+
function resolveJitiCliFromPackageJson(packageJsonPath: string): string | undefined {
|
|
88
|
+
if (!fs.existsSync(packageJsonPath)) return undefined;
|
|
89
|
+
const packageRoot = path.dirname(packageJsonPath);
|
|
90
|
+
const pkg = JSON.parse(fs.readFileSync(packageJsonPath, "utf-8")) as {
|
|
91
|
+
bin?: string | Record<string, string>;
|
|
92
|
+
};
|
|
93
|
+
const binField = pkg.bin;
|
|
94
|
+
const binPath = typeof binField === "string"
|
|
95
|
+
? binField
|
|
96
|
+
: binField?.jiti ?? Object.values(binField ?? {})[0];
|
|
97
|
+
const candidates = [binPath, "lib/jiti-cli.mjs"].filter((candidate): candidate is string => Boolean(candidate));
|
|
98
|
+
for (const candidate of candidates) {
|
|
99
|
+
const cliPath = path.resolve(packageRoot, candidate);
|
|
100
|
+
if (fs.existsSync(cliPath)) return cliPath;
|
|
101
|
+
}
|
|
102
|
+
return undefined;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function resolveJitiCliPath(): string | undefined {
|
|
106
|
+
const candidates: Array<() => string | undefined> = [
|
|
107
|
+
() => require.resolve("jiti/package.json"),
|
|
108
|
+
() => piPackageRoot
|
|
109
|
+
? createRequire(path.join(piPackageRoot, "package.json")).resolve("jiti/package.json")
|
|
110
|
+
: undefined,
|
|
111
|
+
() => {
|
|
112
|
+
if (!process.argv[1]) return undefined;
|
|
113
|
+
const piEntry = fs.realpathSync(process.argv[1]);
|
|
114
|
+
return createRequire(piEntry).resolve("jiti/package.json");
|
|
115
|
+
},
|
|
116
|
+
() => piPackageRoot ? path.join(piPackageRoot, "node_modules", "jiti", "package.json") : undefined,
|
|
117
|
+
];
|
|
118
|
+
for (const candidate of candidates) {
|
|
119
|
+
try {
|
|
120
|
+
const packageJsonPath = candidate();
|
|
121
|
+
if (!packageJsonPath) continue;
|
|
122
|
+
const cliPath = resolveJitiCliFromPackageJson(packageJsonPath);
|
|
123
|
+
if (cliPath) return cliPath;
|
|
124
|
+
} catch {
|
|
125
|
+
// Candidate not available in this install, continue probing.
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return undefined;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const jitiCliPath = resolveJitiCliPath();
|
|
132
|
+
|
|
133
|
+
interface AsyncExecutionContext {
|
|
134
|
+
pi: ExtensionAPI;
|
|
135
|
+
cwd: string;
|
|
136
|
+
currentSessionId: string;
|
|
137
|
+
completionOwnerId?: string;
|
|
138
|
+
/** Parent session id used by permission-system ask forwarding. */
|
|
139
|
+
parentSessionId?: string;
|
|
140
|
+
permissions?: PermissionConfig;
|
|
141
|
+
currentModelProvider?: string;
|
|
142
|
+
currentModel?: ParentModel;
|
|
143
|
+
/** Optional model-scope enforcement resolved from subagent settings. */
|
|
144
|
+
modelScope?: ModelScopeConfig;
|
|
145
|
+
/** Whether the parent session has an interactive UI. */
|
|
146
|
+
interactive?: boolean;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export const DEFAULT_ASYNC_TIMEOUT_MS = 30 * 60 * 1000;
|
|
150
|
+
|
|
151
|
+
interface AsyncChainParams {
|
|
152
|
+
chain: ChainStep[];
|
|
153
|
+
task?: string;
|
|
154
|
+
/** Raw caller-facing goal used only by the started event. */
|
|
155
|
+
goal?: string;
|
|
156
|
+
attachRoot?: ImportedAsyncRoot & { agent: string; outputName?: string; label?: string };
|
|
157
|
+
resultMode?: SubagentRunMode;
|
|
158
|
+
agents: AgentConfig[];
|
|
159
|
+
/** Original discovery provenance, retained by normal callers for unknown-agent diagnostics. */
|
|
160
|
+
unknownAgentDiagnosticContext?: UnknownAgentDiagnosticContext;
|
|
161
|
+
ctx: AsyncExecutionContext;
|
|
162
|
+
availableModels?: AvailableModelInfo[];
|
|
163
|
+
cwd?: string;
|
|
164
|
+
maxOutput?: MaxOutputConfig;
|
|
165
|
+
artifactsDir?: string;
|
|
166
|
+
artifactConfig: ArtifactConfig;
|
|
167
|
+
shareEnabled: boolean;
|
|
168
|
+
sessionRoot?: string;
|
|
169
|
+
agentContract?: AgentContract;
|
|
170
|
+
chainSkills?: string[];
|
|
171
|
+
sessionFilesByFlatIndex?: (string | undefined)[];
|
|
172
|
+
thinkingOverridesByFlatIndex?: (AgentConfig["thinking"] | undefined)[];
|
|
173
|
+
contextForAgent?: (agentName: string) => ContextMode;
|
|
174
|
+
progressDir?: string;
|
|
175
|
+
dynamicFanoutMaxItems?: number;
|
|
176
|
+
maxSubagentDepth: number;
|
|
177
|
+
waitToolEnabled?: boolean;
|
|
178
|
+
waitToolDefaultTimeoutMs?: number;
|
|
179
|
+
worktreeSetupHook?: string;
|
|
180
|
+
worktreeSetupHookTimeoutMs?: number;
|
|
181
|
+
worktreeBaseDir?: string;
|
|
182
|
+
worktreeProvider?: import("../../shared/types.ts").WorktreeProvider;
|
|
183
|
+
worktreeBranchPrefix?: string;
|
|
184
|
+
controlConfig?: ResolvedControlConfig;
|
|
185
|
+
controlIntercomTarget?: string;
|
|
186
|
+
childIntercomTarget?: (agent: string, index: number) => string | undefined;
|
|
187
|
+
nestedRoute?: NestedRouteInfo;
|
|
188
|
+
acceptance?: AcceptanceInput;
|
|
189
|
+
fast?: boolean;
|
|
190
|
+
timeoutMs?: number;
|
|
191
|
+
toolBudget?: ResolvedToolBudget;
|
|
192
|
+
usageBudget?: UsageBudgetConfig;
|
|
193
|
+
configToolBudget?: ResolvedToolBudget;
|
|
194
|
+
/** Optional per-call hard toolTimeoutMs override (highest precedence). */
|
|
195
|
+
callToolTimeoutMs?: number;
|
|
196
|
+
/** Global config.toolTimeoutMs (third precedence, after agent frontmatter). */
|
|
197
|
+
configToolTimeoutMs?: number;
|
|
198
|
+
/** SELESAI_SUBAGENT_TOOL_TIMEOUT_MS override (lowest precedence). */
|
|
199
|
+
toolTimeoutMsEnv?: string | undefined;
|
|
200
|
+
/** Global cap on simultaneously-running subagent tasks within the async run. */
|
|
201
|
+
globalConcurrencyLimit?: number;
|
|
202
|
+
capabilityCeiling?: ResolvedSubagentCapabilityCeiling;
|
|
203
|
+
thinkingCeiling?: ThinkingLevel;
|
|
204
|
+
runFanoutBudget?: RunFanoutBudgetDescriptor;
|
|
205
|
+
parentWorkflowRunId?: string;
|
|
206
|
+
workflowKey?: string;
|
|
207
|
+
lane?: WorkflowLaneMetadata;
|
|
208
|
+
activeAsyncCapacity?: ActiveAsyncCapacityHandle;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
interface AsyncSingleParams {
|
|
212
|
+
agent: string;
|
|
213
|
+
task?: string;
|
|
214
|
+
/** Raw caller-facing goal used only by the started event. */
|
|
215
|
+
goal?: string;
|
|
216
|
+
agentConfig: AgentConfig;
|
|
217
|
+
/** Agent contract before per-run bridge injection, used only for recovery persistence. */
|
|
218
|
+
recoveryAgentConfig?: AgentConfig;
|
|
219
|
+
ctx: AsyncExecutionContext;
|
|
220
|
+
cwd?: string;
|
|
221
|
+
requestedCwd?: string;
|
|
222
|
+
maxOutput?: MaxOutputConfig;
|
|
223
|
+
artifactsDir?: string;
|
|
224
|
+
artifactConfig: ArtifactConfig;
|
|
225
|
+
shareEnabled: boolean;
|
|
226
|
+
sessionRoot?: string;
|
|
227
|
+
sessionDir?: string;
|
|
228
|
+
sessionFile?: string;
|
|
229
|
+
revivalLease?: SessionLeaseRequest;
|
|
230
|
+
context?: ContextMode;
|
|
231
|
+
skills?: string[];
|
|
232
|
+
output?: string | boolean;
|
|
233
|
+
reads?: string[] | false;
|
|
234
|
+
outputMode?: "inline" | "file-only";
|
|
235
|
+
outputBaseDir?: string;
|
|
236
|
+
outputClaimPath?: string;
|
|
237
|
+
agentContract?: AgentContract;
|
|
238
|
+
structuredOutputSchema?: JsonSchemaObject;
|
|
239
|
+
modelOverride?: string;
|
|
240
|
+
modelOverrideFromParent?: boolean;
|
|
241
|
+
modelOrigin?: ModelOrigin;
|
|
242
|
+
fast?: boolean;
|
|
243
|
+
thinkingOverride?: AgentConfig["thinking"];
|
|
244
|
+
availableModels?: AvailableModelInfo[];
|
|
245
|
+
maxSubagentDepth: number;
|
|
246
|
+
waitToolEnabled?: boolean;
|
|
247
|
+
waitToolDefaultTimeoutMs?: number;
|
|
248
|
+
worktreeSetupHook?: string;
|
|
249
|
+
worktreeSetupHookTimeoutMs?: number;
|
|
250
|
+
worktreeBaseDir?: string;
|
|
251
|
+
worktreeProvider?: import("../../shared/types.ts").WorktreeProvider;
|
|
252
|
+
worktreeBranchPrefix?: string;
|
|
253
|
+
worktree?: boolean;
|
|
254
|
+
controlConfig?: ResolvedControlConfig;
|
|
255
|
+
intercomBridge?: IntercomBridgeConfig;
|
|
256
|
+
controlIntercomTarget?: string;
|
|
257
|
+
childIntercomTarget?: (agent: string, index: number) => string | undefined;
|
|
258
|
+
nestedRoute?: NestedRouteInfo;
|
|
259
|
+
acceptance?: AcceptanceInput;
|
|
260
|
+
timeoutMs?: number;
|
|
261
|
+
absoluteDeadlineAt?: number;
|
|
262
|
+
/** Optional per-call hard toolTimeoutMs override (highest precedence). */
|
|
263
|
+
toolTimeoutMs?: number;
|
|
264
|
+
toolBudget?: ResolvedToolBudget | ToolBudgetConfig;
|
|
265
|
+
usageBudget?: UsageBudgetConfig;
|
|
266
|
+
configToolBudget?: ResolvedToolBudget;
|
|
267
|
+
/** Global config.toolTimeoutMs (third precedence, after agent frontmatter). */
|
|
268
|
+
configToolTimeoutMs?: number;
|
|
269
|
+
/** SELESAI_SUBAGENT_TOOL_TIMEOUT_MS override (lowest precedence). */
|
|
270
|
+
toolTimeoutMsEnv?: string | undefined;
|
|
271
|
+
allowZeroToolBudget?: boolean;
|
|
272
|
+
capabilityCeiling?: ResolvedSubagentCapabilityCeiling;
|
|
273
|
+
thinkingCeiling?: ThinkingLevel;
|
|
274
|
+
runFanoutBudget?: RunFanoutBudgetDescriptor;
|
|
275
|
+
parentWorkflowRunId?: string;
|
|
276
|
+
workflowKey?: string;
|
|
277
|
+
lane?: WorkflowLaneMetadata;
|
|
278
|
+
workflowAwaitAsync?: boolean;
|
|
279
|
+
activeAsyncCapacity?: ActiveAsyncCapacityHandle;
|
|
280
|
+
externalJobFollowUp?: {
|
|
281
|
+
sourceRunId: string;
|
|
282
|
+
sourceStepIndex: number;
|
|
283
|
+
parentProviderJobId: string;
|
|
284
|
+
requestId: string;
|
|
285
|
+
requestDigest: string;
|
|
286
|
+
};
|
|
287
|
+
extensionBindings?: ExtensionBindings;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
interface AsyncExecutionResult {
|
|
291
|
+
content: Array<{ type: "text"; text: string }>;
|
|
292
|
+
details: Details;
|
|
293
|
+
isError?: boolean;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
export interface AsyncRunnerStepBuildParams {
|
|
297
|
+
chain: ChainStep[];
|
|
298
|
+
task?: string;
|
|
299
|
+
attachRoot?: ImportedAsyncRoot & { agent: string; outputName?: string; label?: string };
|
|
300
|
+
resultMode?: SubagentRunMode;
|
|
301
|
+
agents: AgentConfig[];
|
|
302
|
+
/** Exact discovery provenance for failed resolution; omission triggers defensive fallback discovery. */
|
|
303
|
+
unknownAgentDiagnosticContext?: UnknownAgentDiagnosticContext;
|
|
304
|
+
ctx: AsyncExecutionContext;
|
|
305
|
+
availableModels?: AvailableModelInfo[];
|
|
306
|
+
cwd?: string;
|
|
307
|
+
chainSkills?: string[];
|
|
308
|
+
sessionFilesByFlatIndex?: (string | undefined)[];
|
|
309
|
+
thinkingOverridesByFlatIndex?: (AgentConfig["thinking"] | undefined)[];
|
|
310
|
+
contextForAgent?: (agentName: string) => ContextMode;
|
|
311
|
+
progressDir?: string;
|
|
312
|
+
agentContract?: AgentContract;
|
|
313
|
+
dynamicFanoutMaxItems?: number;
|
|
314
|
+
maxSubagentDepth: number;
|
|
315
|
+
waitToolEnabled?: boolean;
|
|
316
|
+
waitToolDefaultTimeoutMs?: number;
|
|
317
|
+
worktreeBaseDir?: string;
|
|
318
|
+
worktreeProvider?: import("../../shared/types.ts").WorktreeProvider;
|
|
319
|
+
worktreeBranchPrefix?: string;
|
|
320
|
+
asyncDir: string;
|
|
321
|
+
outputBaseDir?: string;
|
|
322
|
+
validateOutputBindings?: boolean;
|
|
323
|
+
fast?: boolean;
|
|
324
|
+
toolBudget?: ResolvedToolBudget;
|
|
325
|
+
configToolBudget?: ResolvedToolBudget;
|
|
326
|
+
/** Optional per-call hard toolTimeoutMs override from the subagent invocation. */
|
|
327
|
+
callToolTimeoutMs?: number;
|
|
328
|
+
/** Global config.toolTimeoutMs (third precedence, after agent frontmatter). */
|
|
329
|
+
configToolTimeoutMs?: number;
|
|
330
|
+
/** SELESAI_SUBAGENT_TOOL_TIMEOUT_MS override (lowest precedence). */
|
|
331
|
+
toolTimeoutMsEnv?: string | undefined;
|
|
332
|
+
capabilityCeiling?: ResolvedSubagentCapabilityCeiling;
|
|
333
|
+
thinkingCeiling?: ThinkingLevel;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
export type AsyncRunnerStepBuildResult =
|
|
337
|
+
| {
|
|
338
|
+
steps: RunnerStep[];
|
|
339
|
+
runnerCwd: string;
|
|
340
|
+
workflowGraph: ReturnType<typeof buildWorkflowGraphSnapshot>;
|
|
341
|
+
eventChain: ChainStep[];
|
|
342
|
+
originalTask?: string;
|
|
343
|
+
}
|
|
344
|
+
| { error: string };
|
|
345
|
+
|
|
346
|
+
export function formatAsyncStartedMessage(headline: string, interactive: boolean): string {
|
|
347
|
+
const guidance = interactive
|
|
348
|
+
? [
|
|
349
|
+
"The async run is detached and running in the background.",
|
|
350
|
+
"You are in an interactive session. Return control to the user now; Pi will wake you through the native completion notification when this subagent completes or needs attention. Do not run sleep/polling loops to wait for this async subagent; it does not need a wait call.",
|
|
351
|
+
"Use bg_wait only for provider, detached, or other background work that lacks a native completion notification.",
|
|
352
|
+
"If the current turn must receive results from work without a native notification before it ends, call blocking bg_wait(); ordinary async subagent runs do not need a wait call because their completion is delivered natively.",
|
|
353
|
+
"Otherwise, continue any independent work or return control to the user. Use subagent({ action: \"status\", id: \"...\" }) for a one-shot status/result or to inspect a blocked/stale run, never as a wait loop.",
|
|
354
|
+
]
|
|
355
|
+
: [
|
|
356
|
+
"The async run is detached. Do not run sleep timers or polling loops just to wait for it.",
|
|
357
|
+
"This is a non-interactive run: Pi auto-drains current-session subagent work at agent_end so detached children are not abandoned. Use bg_wait only when this turn must receive provider, detached, or other background-work results that have no native completion notification.",
|
|
358
|
+
"Use subagent({ action: \"status\", id: \"...\" }) when you need a one-shot status/result or to inspect a blocked/stale run; do not poll in a loop.",
|
|
359
|
+
];
|
|
360
|
+
return [headline, "", ...guidance].join("\n");
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
/**
|
|
364
|
+
* Check if jiti is available for async execution
|
|
365
|
+
*/
|
|
366
|
+
export function isAsyncAvailable(): boolean {
|
|
367
|
+
return jitiCliPath !== undefined;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
export function resolveAsyncRunnerLogPaths(cfg: object): { stdoutPath: string; stderrPath: string } | undefined {
|
|
371
|
+
const asyncDir = typeof (cfg as { asyncDir?: unknown }).asyncDir === "string"
|
|
372
|
+
? (cfg as { asyncDir: string }).asyncDir
|
|
373
|
+
: undefined;
|
|
374
|
+
if (!asyncDir) return undefined;
|
|
375
|
+
return {
|
|
376
|
+
stdoutPath: path.join(asyncDir, "runner.stdout.log"),
|
|
377
|
+
stderrPath: path.join(asyncDir, "runner.stderr.log"),
|
|
378
|
+
};
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
function closeFd(fd: number | undefined): void {
|
|
382
|
+
if (fd === undefined) return;
|
|
383
|
+
try {
|
|
384
|
+
fs.closeSync(fd);
|
|
385
|
+
} catch {
|
|
386
|
+
// Best-effort cleanup; child process already owns its duplicated stdio fd.
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
/**
|
|
391
|
+
* Spawn the async runner process
|
|
392
|
+
*/
|
|
393
|
+
const RUNNER_STARTUP_TIMEOUT_MS = 10_000;
|
|
394
|
+
const RUNNER_STARTUP_WAIT_BUFFER = typeof SharedArrayBuffer !== "undefined" ? new SharedArrayBuffer(4) : undefined;
|
|
395
|
+
const RUNNER_STARTUP_WAIT_VIEW = RUNNER_STARTUP_WAIT_BUFFER ? new Int32Array(RUNNER_STARTUP_WAIT_BUFFER) : undefined;
|
|
396
|
+
|
|
397
|
+
type RunnerStartupState = "ready" | "acknowledged";
|
|
398
|
+
|
|
399
|
+
type RunnerStartupWaitResult =
|
|
400
|
+
| { ok: true; token: string }
|
|
401
|
+
| { ok: false; error: string; startupDidNotProceed?: boolean };
|
|
402
|
+
|
|
403
|
+
function waitForStartupInterval(delayMs = 20): void {
|
|
404
|
+
if (RUNNER_STARTUP_WAIT_VIEW) {
|
|
405
|
+
Atomics.wait(RUNNER_STARTUP_WAIT_VIEW, 0, 0, delayMs);
|
|
406
|
+
return;
|
|
407
|
+
}
|
|
408
|
+
const waitUntil = Date.now() + delayMs;
|
|
409
|
+
while (Date.now() < waitUntil) {
|
|
410
|
+
// Startup handshakes are synchronous so resume rejects before reporting a run as started.
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
function readRunnerStartup(startupPath: string, expectedState: RunnerStartupState, expectedToken?: string): RunnerStartupWaitResult | undefined {
|
|
415
|
+
if (!fs.existsSync(startupPath)) return undefined;
|
|
416
|
+
try {
|
|
417
|
+
const payload = JSON.parse(fs.readFileSync(startupPath, "utf-8")) as { state?: unknown; token?: unknown; error?: unknown };
|
|
418
|
+
if (payload.state === "error" && typeof payload.error === "string") return { ok: false, error: payload.error, startupDidNotProceed: true };
|
|
419
|
+
if (payload.state !== expectedState) return undefined;
|
|
420
|
+
if (typeof payload.token !== "string" || (expectedToken !== undefined && payload.token !== expectedToken)) {
|
|
421
|
+
return { ok: false, error: `Async runner wrote an invalid ${expectedState} startup handshake: ${startupPath}`, startupDidNotProceed: true };
|
|
422
|
+
}
|
|
423
|
+
return { ok: true, token: payload.token };
|
|
424
|
+
} catch (error) {
|
|
425
|
+
return { ok: false, error: `Failed to read async runner startup handshake '${startupPath}': ${error instanceof Error ? error.message : String(error)}`, startupDidNotProceed: true };
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
function waitForRunnerStartup(startupPath: string, expectedState: RunnerStartupState, timeoutMs: number, expectedToken?: string): RunnerStartupWaitResult {
|
|
430
|
+
const deadline = Date.now() + timeoutMs;
|
|
431
|
+
for (;;) {
|
|
432
|
+
const result = readRunnerStartup(startupPath, expectedState, expectedToken);
|
|
433
|
+
if (result) return result;
|
|
434
|
+
if (Date.now() >= deadline) break;
|
|
435
|
+
waitForStartupInterval(Math.min(20, Math.max(1, deadline - Date.now())));
|
|
436
|
+
}
|
|
437
|
+
const finalResult = readRunnerStartup(startupPath, expectedState, expectedToken);
|
|
438
|
+
if (finalResult) return finalResult;
|
|
439
|
+
return { ok: false, error: `Timed out after ${timeoutMs}ms waiting for the async runner startup state '${expectedState}'.`, startupDidNotProceed: true };
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
const writePrivateStartupControlJson = createAtomicJsonWriter({ mode: 0o600, ignoreCleanupErrorAfterSuccess: true });
|
|
443
|
+
|
|
444
|
+
function writeRunnerStartupControl(filePath: string, payload: { action: "ack" | "proceed"; token: string }): void {
|
|
445
|
+
// Delegate to the shared atomic JSON writer (temp file + rename, retrying
|
|
446
|
+
// transient Windows EPERM/EBUSY/EACCES locks and cleaning up the temp file
|
|
447
|
+
// on failure), so the startup handshake gets the same locking resilience as
|
|
448
|
+
// every other async control/result file. This is exercised by
|
|
449
|
+
// test/unit/atomic-json.test.ts.
|
|
450
|
+
writePrivateStartupControlJson(filePath, payload);
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
function runnerIsAlive(pid: number): boolean {
|
|
454
|
+
try {
|
|
455
|
+
process.kill(pid, 0);
|
|
456
|
+
return true;
|
|
457
|
+
} catch (error) {
|
|
458
|
+
return (error as NodeJS.ErrnoException).code === "EPERM";
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
function terminateRunnerBeforeProceed(pid: number): boolean {
|
|
463
|
+
for (const signal of ["SIGTERM", "SIGKILL"] as const) {
|
|
464
|
+
if (!runnerIsAlive(pid)) return true;
|
|
465
|
+
try {
|
|
466
|
+
process.kill(pid, signal);
|
|
467
|
+
} catch {
|
|
468
|
+
if (!runnerIsAlive(pid)) return true;
|
|
469
|
+
}
|
|
470
|
+
const deadline = Date.now() + 1000;
|
|
471
|
+
while (runnerIsAlive(pid) && Date.now() < deadline) waitForStartupInterval();
|
|
472
|
+
}
|
|
473
|
+
return !runnerIsAlive(pid);
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
function persistPreProceedStartupFailure(asyncDir: string, runId: string, runnerProcessInstanceId: string, sessionId: string | undefined, completionOwnerId: string | undefined, message: string): void {
|
|
477
|
+
const now = Date.now();
|
|
478
|
+
try {
|
|
479
|
+
const statusPath = path.join(asyncDir, "status.json");
|
|
480
|
+
let status: Partial<AsyncStatus> = {};
|
|
481
|
+
try {
|
|
482
|
+
status = JSON.parse(fs.readFileSync(statusPath, "utf-8")) as Partial<AsyncStatus>;
|
|
483
|
+
} catch {}
|
|
484
|
+
writePrivateAtomicJson(statusPath, {
|
|
485
|
+
...status,
|
|
486
|
+
runId,
|
|
487
|
+
...(sessionId ? { sessionId } : {}),
|
|
488
|
+
...(completionOwnerId ? { completionOwnerId } : {}),
|
|
489
|
+
state: "failed",
|
|
490
|
+
lastUpdate: now,
|
|
491
|
+
error: message,
|
|
492
|
+
processTerminal: {
|
|
493
|
+
version: 1,
|
|
494
|
+
state: "not-started",
|
|
495
|
+
runId,
|
|
496
|
+
runnerProcessInstanceId,
|
|
497
|
+
},
|
|
498
|
+
});
|
|
499
|
+
writePrivateAtomicJson(path.join(asyncDir, "process-terminal-candidate.json"), {
|
|
500
|
+
version: 1,
|
|
501
|
+
runId,
|
|
502
|
+
runnerProcessInstanceId,
|
|
503
|
+
writers: {},
|
|
504
|
+
expectedWriters: { 0: 0 },
|
|
505
|
+
});
|
|
506
|
+
} catch {
|
|
507
|
+
// Startup failures must still return the original launch error.
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
interface SpawnRunnerResult {
|
|
512
|
+
pid?: number;
|
|
513
|
+
runnerProcessInstanceId?: string;
|
|
514
|
+
error?: string;
|
|
515
|
+
terminationObserved?: boolean;
|
|
516
|
+
startupDidNotProceed?: boolean;
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
function isStaleExtensionContextError(error: unknown): boolean {
|
|
520
|
+
return error instanceof Error && /extension ctx is stale|stale after session replacement or reload/i.test(error.message);
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
export function emitProcessTerminalEvent(ctx: AsyncExecutionContext, proof: unknown): void {
|
|
524
|
+
try {
|
|
525
|
+
ctx.pi.events.emit(SUBAGENT_PROCESS_TERMINAL_EVENT, proof);
|
|
526
|
+
} catch (error) {
|
|
527
|
+
if (isStaleExtensionContextError(error)) return;
|
|
528
|
+
console.error("Failed to emit subagent process-terminal event:", error);
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
function spawnRunner(cfg: object, suffix: string, cwd: string, initialStatus: Omit<AsyncStatus, "pid" | "processTerminal">, initialStatusPath: string, onProcessTerminal?: (proof: unknown) => void, onBeforeProceed?: (runnerProcessInstanceId: string) => void, requestedCwd = cwd): SpawnRunnerResult {
|
|
533
|
+
const cwdError = preflightLaunchCwd(requestedCwd, cwd);
|
|
534
|
+
if (cwdError) return { error: cwdError };
|
|
535
|
+
|
|
536
|
+
if (!jitiCliPath) {
|
|
537
|
+
return { error: "upstream jiti for TypeScript execution could not be found; ensure package dependencies are installed" };
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
fs.mkdirSync(TEMP_ROOT_DIR, { recursive: true });
|
|
541
|
+
const cfgPath = getAsyncConfigPath(suffix);
|
|
542
|
+
const runnerProcessInstanceId = randomUUID();
|
|
543
|
+
const hasRevivalLease = typeof (cfg as { revivalLease?: unknown }).revivalLease === "object";
|
|
544
|
+
const launchBarrierToken = hasRevivalLease ? undefined : runnerProcessInstanceId;
|
|
545
|
+
const launchConfig = { ...cfg, runnerProcessInstanceId, ...(launchBarrierToken ? { launchBarrierToken } : {}) };
|
|
546
|
+
writePrivateAtomicJson(cfgPath, launchConfig);
|
|
547
|
+
const runner = path.join(path.dirname(fileURLToPath(import.meta.url)), "subagent-runner.ts");
|
|
548
|
+
const nodeCommand = resolveNodeExecutable();
|
|
549
|
+
const launchForStartup = launchConfig as typeof launchConfig & { asyncDir?: unknown; id?: unknown; sessionId?: unknown; completionOwnerId?: unknown; revivalLease?: unknown };
|
|
550
|
+
const launchAsyncDir = typeof launchForStartup.asyncDir === "string" ? launchForStartup.asyncDir : undefined;
|
|
551
|
+
const launchRunId = typeof launchForStartup.id === "string" ? launchForStartup.id : suffix;
|
|
552
|
+
const launchSessionId = typeof launchForStartup.sessionId === "string" ? launchForStartup.sessionId : undefined;
|
|
553
|
+
const launchCompletionOwnerId = typeof launchForStartup.completionOwnerId === "string" ? launchForStartup.completionOwnerId : undefined;
|
|
554
|
+
const startupPath = typeof launchForStartup.revivalLease === "object" && launchAsyncDir
|
|
555
|
+
? path.join(launchAsyncDir, "runner-startup.json")
|
|
556
|
+
: undefined;
|
|
557
|
+
const startupAckPath = startupPath ? path.join(path.dirname(startupPath), "runner-startup-ack.json") : undefined;
|
|
558
|
+
const startupProceedPath = launchAsyncDir && (startupPath || launchBarrierToken)
|
|
559
|
+
? path.join(launchAsyncDir, "runner-startup-proceed.json")
|
|
560
|
+
: undefined;
|
|
561
|
+
if (startupPath) fs.rmSync(startupPath, { force: true });
|
|
562
|
+
if (startupAckPath) fs.rmSync(startupAckPath, { force: true });
|
|
563
|
+
if (startupProceedPath) fs.rmSync(startupProceedPath, { force: true });
|
|
564
|
+
|
|
565
|
+
const logPaths = resolveAsyncRunnerLogPaths(launchConfig);
|
|
566
|
+
let stdoutFd: number | undefined;
|
|
567
|
+
let stderrFd: number | undefined;
|
|
568
|
+
try {
|
|
569
|
+
if (logPaths) {
|
|
570
|
+
fs.mkdirSync(path.dirname(logPaths.stdoutPath), { recursive: true });
|
|
571
|
+
stdoutFd = fs.openSync(logPaths.stdoutPath, "a");
|
|
572
|
+
stderrFd = fs.openSync(logPaths.stderrPath, "a");
|
|
573
|
+
}
|
|
574
|
+
const proc = spawn(nodeCommand, [jitiCliPath, runner, cfgPath], {
|
|
575
|
+
cwd,
|
|
576
|
+
...backgroundProcessOptions(),
|
|
577
|
+
stdio: ["ignore", stdoutFd ?? "ignore", stderrFd ?? "ignore"],
|
|
578
|
+
env: {
|
|
579
|
+
...omitExtensionBindingsEnv(process.env),
|
|
580
|
+
...(piPackageRoot ? { [SELESAI_CODING_AGENT_PACKAGE_ROOT_ENV]: piPackageRoot } : {}),
|
|
581
|
+
},
|
|
582
|
+
});
|
|
583
|
+
closeFd(stdoutFd);
|
|
584
|
+
closeFd(stderrFd);
|
|
585
|
+
proc.on("error", (error) => {
|
|
586
|
+
console.error(`[pi-subagents] async spawn failed: ${error.message}`);
|
|
587
|
+
});
|
|
588
|
+
proc.once("close", (exitCode, signal) => {
|
|
589
|
+
const launch = launchConfig as { asyncDir?: unknown; id?: unknown; nestedRoute?: NestedRouteInfo; nestedSelf?: { parentRunId: string; parentStepIndex?: number; depth: number; path?: Array<{ runId: string; stepIndex?: number; agent?: string }> } };
|
|
590
|
+
const asyncDir = launch.asyncDir;
|
|
591
|
+
const runId = launch.id;
|
|
592
|
+
if (typeof asyncDir !== "string" || typeof runId !== "string") return;
|
|
593
|
+
finalizeProcessTerminal(asyncDir, runId, {
|
|
594
|
+
processInstanceId: runnerProcessInstanceId,
|
|
595
|
+
closeObservedAt: Date.now(),
|
|
596
|
+
exitCode,
|
|
597
|
+
signal,
|
|
598
|
+
});
|
|
599
|
+
const persisted = readProcessTerminal(asyncDir, { runId, runnerProcessInstanceId });
|
|
600
|
+
if (!persisted) return;
|
|
601
|
+
if (launch.nestedRoute && launch.nestedSelf) {
|
|
602
|
+
try {
|
|
603
|
+
let status: import("../../shared/types.ts").AsyncStatus;
|
|
604
|
+
try {
|
|
605
|
+
status = JSON.parse(fs.readFileSync(path.join(asyncDir, "status.json"), "utf-8")) as import("../../shared/types.ts").AsyncStatus;
|
|
606
|
+
status.processTerminal = persisted;
|
|
607
|
+
} catch {
|
|
608
|
+
status = {
|
|
609
|
+
runId,
|
|
610
|
+
mode: "single",
|
|
611
|
+
state: persisted.state === "observed" ? "complete" : "failed",
|
|
612
|
+
startedAt: persisted.observedAt ?? Date.now(),
|
|
613
|
+
lastUpdate: Date.now(),
|
|
614
|
+
processTerminal: persisted,
|
|
615
|
+
};
|
|
616
|
+
}
|
|
617
|
+
writeNestedEvent(launch.nestedRoute, {
|
|
618
|
+
type: "subagent.nested.completed",
|
|
619
|
+
ts: Date.now(),
|
|
620
|
+
parentRunId: launch.nestedSelf.parentRunId,
|
|
621
|
+
parentStepIndex: launch.nestedSelf.parentStepIndex,
|
|
622
|
+
child: nestedSummaryFromAsyncStatus(status, asyncDir, {
|
|
623
|
+
id: runId,
|
|
624
|
+
parentRunId: launch.nestedSelf.parentRunId,
|
|
625
|
+
parentStepIndex: launch.nestedSelf.parentStepIndex,
|
|
626
|
+
depth: launch.nestedSelf.depth,
|
|
627
|
+
path: launch.nestedSelf.path,
|
|
628
|
+
mode: status.mode,
|
|
629
|
+
ts: Date.now(),
|
|
630
|
+
}),
|
|
631
|
+
});
|
|
632
|
+
} catch (error) {
|
|
633
|
+
console.error("Failed to emit final nested process-terminal status:", error);
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
onProcessTerminal?.(persisted);
|
|
637
|
+
});
|
|
638
|
+
if (typeof proc.pid !== "number") {
|
|
639
|
+
return { error: `async runner did not produce a pid for cwd: ${cwd}` };
|
|
640
|
+
}
|
|
641
|
+
try {
|
|
642
|
+
writePrivateAtomicJson(initialStatusPath, {
|
|
643
|
+
...initialStatus,
|
|
644
|
+
pid: proc.pid,
|
|
645
|
+
processTerminal: { version: 1, state: "pending", runId: initialStatus.runId, runnerProcessInstanceId },
|
|
646
|
+
});
|
|
647
|
+
} catch (error) {
|
|
648
|
+
const message = `Failed to persist initial async status: ${error instanceof Error ? error.message : String(error)}`;
|
|
649
|
+
if (launchAsyncDir) persistPreProceedStartupFailure(launchAsyncDir, launchRunId, runnerProcessInstanceId, launchSessionId, launchCompletionOwnerId, message);
|
|
650
|
+
const terminationObserved = terminateRunnerBeforeProceed(proc.pid);
|
|
651
|
+
return { pid: proc.pid, runnerProcessInstanceId, error: message, terminationObserved, startupDidNotProceed: true };
|
|
652
|
+
}
|
|
653
|
+
try {
|
|
654
|
+
if (!launchAsyncDir) throw new Error("Async runner is missing its lifecycle directory.");
|
|
655
|
+
initializeProcessTerminal(launchAsyncDir, launchRunId, runnerProcessInstanceId);
|
|
656
|
+
} catch (error) {
|
|
657
|
+
const message = `Failed to establish async runner lifecycle sidecar: ${error instanceof Error ? error.message : String(error)}`;
|
|
658
|
+
if (launchAsyncDir) persistPreProceedStartupFailure(launchAsyncDir, launchRunId, runnerProcessInstanceId, launchSessionId, launchCompletionOwnerId, message);
|
|
659
|
+
const terminationObserved = terminateRunnerBeforeProceed(proc.pid);
|
|
660
|
+
return { pid: proc.pid, runnerProcessInstanceId, error: message, terminationObserved, startupDidNotProceed: true };
|
|
661
|
+
}
|
|
662
|
+
try {
|
|
663
|
+
onBeforeProceed?.(runnerProcessInstanceId);
|
|
664
|
+
} catch (error) {
|
|
665
|
+
const message = `Failed to establish async runner capacity ownership: ${error instanceof Error ? error.message : String(error)}`;
|
|
666
|
+
if (launchAsyncDir) persistPreProceedStartupFailure(launchAsyncDir, launchRunId, runnerProcessInstanceId, launchSessionId, launchCompletionOwnerId, message);
|
|
667
|
+
const terminationObserved = terminateRunnerBeforeProceed(proc.pid);
|
|
668
|
+
return { pid: proc.pid, runnerProcessInstanceId, error: message, terminationObserved, startupDidNotProceed: true };
|
|
669
|
+
}
|
|
670
|
+
if (launchBarrierToken && startupProceedPath) {
|
|
671
|
+
try {
|
|
672
|
+
writeRunnerStartupControl(startupProceedPath, { action: "proceed", token: launchBarrierToken });
|
|
673
|
+
} catch (error) {
|
|
674
|
+
const message = `Failed to authorize async runner startup: ${error instanceof Error ? error.message : String(error)}`;
|
|
675
|
+
if (launchAsyncDir) persistPreProceedStartupFailure(launchAsyncDir, launchRunId, runnerProcessInstanceId, launchSessionId, launchCompletionOwnerId, message);
|
|
676
|
+
const terminationObserved = terminateRunnerBeforeProceed(proc.pid);
|
|
677
|
+
return { pid: proc.pid, runnerProcessInstanceId, error: message, terminationObserved, startupDidNotProceed: true };
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
proc.unref();
|
|
681
|
+
if (startupPath && startupAckPath && startupProceedPath) {
|
|
682
|
+
const persistStartupFailure = (message: string) => {
|
|
683
|
+
if (launchAsyncDir) persistPreProceedStartupFailure(launchAsyncDir, launchRunId, runnerProcessInstanceId, launchSessionId, launchCompletionOwnerId, message);
|
|
684
|
+
};
|
|
685
|
+
const ready = waitForRunnerStartup(startupPath, "ready", RUNNER_STARTUP_TIMEOUT_MS);
|
|
686
|
+
if (ready.ok === false) {
|
|
687
|
+
persistStartupFailure(ready.error);
|
|
688
|
+
const terminationObserved = terminateRunnerBeforeProceed(proc.pid);
|
|
689
|
+
return { pid: proc.pid, runnerProcessInstanceId, error: ready.error, terminationObserved, startupDidNotProceed: ready.startupDidNotProceed };
|
|
690
|
+
}
|
|
691
|
+
try {
|
|
692
|
+
writeRunnerStartupControl(startupAckPath, { action: "ack", token: ready.token });
|
|
693
|
+
} catch (error) {
|
|
694
|
+
const message = `Failed to acknowledge async runner startup: ${error instanceof Error ? error.message : String(error)}`;
|
|
695
|
+
persistStartupFailure(message);
|
|
696
|
+
const terminationObserved = terminateRunnerBeforeProceed(proc.pid);
|
|
697
|
+
return { pid: proc.pid, runnerProcessInstanceId, error: message, terminationObserved, startupDidNotProceed: true };
|
|
698
|
+
}
|
|
699
|
+
const acknowledged = waitForRunnerStartup(startupPath, "acknowledged", RUNNER_STARTUP_TIMEOUT_MS, ready.token);
|
|
700
|
+
if (acknowledged.ok === false) {
|
|
701
|
+
persistStartupFailure(acknowledged.error);
|
|
702
|
+
const terminationObserved = terminateRunnerBeforeProceed(proc.pid);
|
|
703
|
+
return { pid: proc.pid, runnerProcessInstanceId, error: acknowledged.error, terminationObserved, startupDidNotProceed: acknowledged.startupDidNotProceed };
|
|
704
|
+
}
|
|
705
|
+
try {
|
|
706
|
+
writeRunnerStartupControl(startupProceedPath, { action: "proceed", token: ready.token });
|
|
707
|
+
} catch (error) {
|
|
708
|
+
const message = `Failed to authorize async runner startup: ${error instanceof Error ? error.message : String(error)}`;
|
|
709
|
+
persistStartupFailure(message);
|
|
710
|
+
const terminationObserved = terminateRunnerBeforeProceed(proc.pid);
|
|
711
|
+
return { pid: proc.pid, runnerProcessInstanceId, error: message, terminationObserved, startupDidNotProceed: true };
|
|
712
|
+
}
|
|
713
|
+
try {
|
|
714
|
+
fs.rmSync(startupPath, { force: true });
|
|
715
|
+
} catch {
|
|
716
|
+
// Proceed is the commit point; handshake cleanup cannot turn a running revival into a start error.
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
return { pid: proc.pid, runnerProcessInstanceId };
|
|
720
|
+
} catch (error) {
|
|
721
|
+
closeFd(stdoutFd);
|
|
722
|
+
closeFd(stderrFd);
|
|
723
|
+
return { error: error instanceof Error ? error.message : String(error) };
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
function formatAsyncStartError(mode: SubagentRunMode, message: string): AsyncExecutionResult {
|
|
728
|
+
return {
|
|
729
|
+
content: [{ type: "text", text: message }],
|
|
730
|
+
isError: true,
|
|
731
|
+
details: { mode, results: [] },
|
|
732
|
+
};
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
const UNAVAILABLE_SUBAGENT_SKILL_ERROR = "Skills not found: pi-subagents";
|
|
736
|
+
|
|
737
|
+
class UnavailableSubagentSkillError extends Error {}
|
|
738
|
+
class AsyncStartValidationError extends Error {}
|
|
739
|
+
|
|
740
|
+
export function buildAsyncRunnerSteps(id: string, params: AsyncRunnerStepBuildParams): AsyncRunnerStepBuildResult {
|
|
741
|
+
const {
|
|
742
|
+
chain,
|
|
743
|
+
agents,
|
|
744
|
+
ctx,
|
|
745
|
+
cwd,
|
|
746
|
+
sessionFilesByFlatIndex,
|
|
747
|
+
thinkingOverridesByFlatIndex,
|
|
748
|
+
maxSubagentDepth,
|
|
749
|
+
worktreeBaseDir,
|
|
750
|
+
worktreeProvider,
|
|
751
|
+
worktreeBranchPrefix,
|
|
752
|
+
asyncDir,
|
|
753
|
+
} = params;
|
|
754
|
+
const outputBaseDir = params.outputBaseDir;
|
|
755
|
+
const resultMode = params.resultMode ?? "chain";
|
|
756
|
+
const chainSkills = params.chainSkills ?? [];
|
|
757
|
+
const availableModels = params.availableModels;
|
|
758
|
+
const runnerCwd = resolveChildCwd(ctx.cwd, cwd);
|
|
759
|
+
let managedWorktreeProvider: "native" | "worktrunk" | undefined;
|
|
760
|
+
try {
|
|
761
|
+
if (chain.some((step) => "worktree" in step && step.worktree === true)) {
|
|
762
|
+
const resolved = resolveWorktreeProvider(worktreeProvider, worktreeBaseDir);
|
|
763
|
+
managedWorktreeProvider = shouldDeferWorktreeCwd(worktreeProvider, worktreeBaseDir) ? "worktrunk" : resolved;
|
|
764
|
+
}
|
|
765
|
+
} catch (error) {
|
|
766
|
+
return { error: error instanceof Error ? error.message : String(error) };
|
|
767
|
+
}
|
|
768
|
+
const progressDir = params.progressDir ?? runnerCwd;
|
|
769
|
+
const graphChain: ChainStep[] = params.attachRoot
|
|
770
|
+
? [{
|
|
771
|
+
agent: params.attachRoot.agent,
|
|
772
|
+
task: `Attach async root ${params.attachRoot.runId}`,
|
|
773
|
+
label: params.attachRoot.label ?? `Attached root ${params.attachRoot.runId}`,
|
|
774
|
+
...(params.attachRoot.outputName ? { as: params.attachRoot.outputName } : {}),
|
|
775
|
+
}, ...chain]
|
|
776
|
+
: chain;
|
|
777
|
+
const firstStep = chain[0];
|
|
778
|
+
const originalTask = params.task ?? (firstStep
|
|
779
|
+
? (isParallelStep(firstStep)
|
|
780
|
+
? firstStep.parallel[0]?.task
|
|
781
|
+
: isDynamicParallelStep(firstStep)
|
|
782
|
+
? firstStep.parallel.task
|
|
783
|
+
: (firstStep as SequentialStep).task)
|
|
784
|
+
: undefined);
|
|
785
|
+
try {
|
|
786
|
+
if (params.validateOutputBindings !== false) {
|
|
787
|
+
validateChainOutputBindings(chain, { maxItems: params.dynamicFanoutMaxItems });
|
|
788
|
+
}
|
|
789
|
+
} catch (error) {
|
|
790
|
+
if (error instanceof ChainOutputValidationError) return { error: error.message };
|
|
791
|
+
throw error;
|
|
792
|
+
}
|
|
793
|
+
const workflowGraph = buildWorkflowGraphSnapshot({ runId: id, mode: resultMode, steps: graphChain });
|
|
794
|
+
|
|
795
|
+
const diagnosticContext = params.unknownAgentDiagnosticContext
|
|
796
|
+
?? unknownAgentDiagnosticContext(discoverAgents(path.resolve(runnerCwd), "both"));
|
|
797
|
+
for (const s of chain) {
|
|
798
|
+
const stepAgents = isParallelStep(s)
|
|
799
|
+
? s.parallel.map((t) => t.agent)
|
|
800
|
+
: isDynamicParallelStep(s)
|
|
801
|
+
? [s.parallel.agent]
|
|
802
|
+
: [(s as SequentialStep).agent];
|
|
803
|
+
for (const agentName of stepAgents) {
|
|
804
|
+
if (!agents.find((x) => x.name === agentName)) return { error: formatUnknownAgentError(agentName, diagnosticContext) };
|
|
805
|
+
}
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
let progressInstructionCreated = false;
|
|
809
|
+
const buildStepOverrides = (s: SequentialStep): StepOverrides => {
|
|
810
|
+
const stepSkillInput = normalizeSkillInput(s.skill);
|
|
811
|
+
return {
|
|
812
|
+
...(s.output !== undefined ? { output: s.output } : {}),
|
|
813
|
+
...(s.outputMode !== undefined ? { outputMode: s.outputMode } : {}),
|
|
814
|
+
...(s.reads !== undefined ? { reads: s.reads } : {}),
|
|
815
|
+
...(s.progress !== undefined ? { progress: s.progress } : {}),
|
|
816
|
+
...(stepSkillInput !== undefined ? { skills: stepSkillInput } : {}),
|
|
817
|
+
...(s.model !== undefined ? { model: s.model } : {}),
|
|
818
|
+
...(s.fast !== undefined ? { fast: s.fast } : {}),
|
|
819
|
+
};
|
|
820
|
+
};
|
|
821
|
+
const buildSeqStep = (s: SequentialStep, sessionFile?: string, behaviorCwd?: string, progressPrecreated = false, resolvedBehavior?: ResolvedStepBehavior, flatIndex?: number, parallelOutputNamespace?: { stepIndex: number; taskIndex?: number }, runFanoutPath?: string) => {
|
|
822
|
+
const a = agents.find((x) => x.name === s.agent)!;
|
|
823
|
+
const externalRunner = a.runner?.type === "external-cli" || a.runner?.type === "external-job";
|
|
824
|
+
const externalRunnerType = a.runner?.type;
|
|
825
|
+
if (externalRunner) {
|
|
826
|
+
const unsupported: string[] = [];
|
|
827
|
+
if (s.model !== undefined) unsupported.push("model override");
|
|
828
|
+
if (s.outputSchema !== undefined) unsupported.push("structured output");
|
|
829
|
+
if (s.acceptance !== undefined || params.agentContract !== undefined || s.agentContract !== undefined) unsupported.push("acceptance/agent contract");
|
|
830
|
+
if (s.toolBudget !== undefined || params.toolBudget !== undefined || a.toolBudget !== undefined || params.configToolBudget !== undefined) unsupported.push("tool budget");
|
|
831
|
+
if ((s.fast ?? params.fast ?? a.fast) === true) unsupported.push("fast mode");
|
|
832
|
+
if (params.contextForAgent?.(s.agent) === "fork") unsupported.push("fork context");
|
|
833
|
+
if (unsupported.length > 0) throw new AsyncStartValidationError(`Agent '${a.name}' uses runner.type='${externalRunnerType}' and does not support: ${unsupported.join(", ")}.`);
|
|
834
|
+
}
|
|
835
|
+
try {
|
|
836
|
+
assertAgentAllowedByCapabilityCeiling(a.name, intersectSubagentCapabilityCeilings(params.capabilityCeiling, decodeSubagentCapabilityCeiling(process.env[SUBAGENT_CAPABILITY_CEILING_ENV])));
|
|
837
|
+
} catch (error) {
|
|
838
|
+
throw new AsyncStartValidationError(error instanceof Error ? error.message : String(error));
|
|
839
|
+
}
|
|
840
|
+
const toolBudgetInput = s.toolBudget ?? params.toolBudget ?? a.toolBudget ?? params.configToolBudget;
|
|
841
|
+
const resolvedToolBudget = validateToolBudgetConfig(toolBudgetInput, s.toolBudget ? "toolBudget" : a.toolBudget ? "agent.toolBudget" : "config.toolBudget");
|
|
842
|
+
if (resolvedToolBudget.error) throw new AsyncStartValidationError(resolvedToolBudget.error);
|
|
843
|
+
const resolvedToolTimeout = resolveToolTimeoutMs({
|
|
844
|
+
callValue: params.callToolTimeoutMs,
|
|
845
|
+
agentValue: a.defaultToolTimeoutMs,
|
|
846
|
+
configValue: params.configToolTimeoutMs,
|
|
847
|
+
envValue: params.toolTimeoutMsEnv ?? toolTimeoutFromEnv(),
|
|
848
|
+
});
|
|
849
|
+
if (resolvedToolTimeout.error) throw new AsyncStartValidationError(resolvedToolTimeout.error);
|
|
850
|
+
const launchPlan = planChildLaunch({
|
|
851
|
+
agentConfig: a,
|
|
852
|
+
stepOverrides: buildStepOverrides(s),
|
|
853
|
+
task: s.task,
|
|
854
|
+
originalTask,
|
|
855
|
+
runnerCwd,
|
|
856
|
+
runtimeCwd: ctx.cwd,
|
|
857
|
+
stepCwdInput: s.cwd,
|
|
858
|
+
behaviorCwd,
|
|
859
|
+
chainSkills,
|
|
860
|
+
outputBaseDir,
|
|
861
|
+
parallelOutputNamespace,
|
|
862
|
+
resolvedBehavior,
|
|
863
|
+
});
|
|
864
|
+
const { stepCwd, instructionCwd, readExistenceCwd, behavior, namespaceOutputPath, outputPath, skillNames } = launchPlan;
|
|
865
|
+
const { resolved: resolvedSkills, missing: missingSkills } = resolveSkillsWithFallback(
|
|
866
|
+
skillNames,
|
|
867
|
+
stepCwd,
|
|
868
|
+
ctx.cwd,
|
|
869
|
+
a.skillPath,
|
|
870
|
+
a.filePath ? path.dirname(a.filePath) : stepCwd,
|
|
871
|
+
);
|
|
872
|
+
if (missingSkills.includes("pi-subagents")) throw new UnavailableSubagentSkillError(UNAVAILABLE_SUBAGENT_SKILL_ERROR);
|
|
873
|
+
|
|
874
|
+
let systemPrompt = a.systemPrompt?.trim() ?? "";
|
|
875
|
+
if (resolvedSkills.length > 0) {
|
|
876
|
+
const injection = buildSkillInjection(resolvedSkills);
|
|
877
|
+
systemPrompt = systemPrompt ? `${systemPrompt}\n\n${injection}` : injection;
|
|
878
|
+
}
|
|
879
|
+
const memoryInjection = buildAgentMemoryInjection(a, stepCwd);
|
|
880
|
+
if (memoryInjection) {
|
|
881
|
+
systemPrompt = systemPrompt ? `${systemPrompt}\n\n${memoryInjection}` : memoryInjection;
|
|
882
|
+
}
|
|
883
|
+
systemPrompt = appendAgentRefinementOverlay(systemPrompt, { cwd: stepCwd, agentName: a.name });
|
|
884
|
+
|
|
885
|
+
const readInstructions = buildChainInstructions({ ...behavior, output: false, progress: false }, instructionCwd, false, undefined, readExistenceCwd);
|
|
886
|
+
const isFirstProgressAgent = behavior.progress && !progressPrecreated && !progressInstructionCreated;
|
|
887
|
+
if (behavior.progress) progressInstructionCreated = true;
|
|
888
|
+
const progressInstructions = buildChainInstructions({ ...behavior, output: false, reads: false }, progressDir, isFirstProgressAgent);
|
|
889
|
+
if (!namespaceOutputPath) systemPrompt = injectOutputPathSystemPrompt(systemPrompt, outputPath, a);
|
|
890
|
+
const validationError = validateFileOnlyOutputMode(behavior.outputMode, outputPath, `Async step (${s.agent})`);
|
|
891
|
+
if (validationError) throw new AsyncStartValidationError(validationError);
|
|
892
|
+
let taskTemplate = s.task ?? "{previous}";
|
|
893
|
+
taskTemplate = taskTemplate.replace(/\{task\}/g, originalTask ?? "");
|
|
894
|
+
taskTemplate = taskTemplate.replace(/\{chain_dir\}/g, behaviorCwd ?? runnerCwd);
|
|
895
|
+
const taskText = `${readInstructions.prefix}${taskTemplate}${progressInstructions.suffix}`;
|
|
896
|
+
const task = namespaceOutputPath ? taskText : injectSingleOutputInstruction(taskText, outputPath, a);
|
|
897
|
+
|
|
898
|
+
const modelScopes = resolveModelScopesForAgent(ctx.modelScope, a.name, ctx.currentModel);
|
|
899
|
+
const modelOrigin = resolveModelOrigin({ explicitModel: s.model, agentModel: a.model, parentModel: ctx.currentModel });
|
|
900
|
+
const primaryModelFromParent = modelOrigin === "inherited";
|
|
901
|
+
const primaryModel = externalRunner ? undefined : resolveEffectiveSubagentModel(
|
|
902
|
+
s.model,
|
|
903
|
+
a.model,
|
|
904
|
+
ctx.currentModel,
|
|
905
|
+
availableModels,
|
|
906
|
+
a.modelProvider ?? ctx.currentModelProvider,
|
|
907
|
+
{ scope: modelScopes, source: modelOrigin === "explicit" ? "explicit" : "inherited" },
|
|
908
|
+
);
|
|
909
|
+
const thinkingOverride = flatIndex === undefined ? undefined : thinkingOverridesByFlatIndex?.[flatIndex];
|
|
910
|
+
const effectiveThinking = externalRunner ? undefined : thinkingOverride ?? a.thinking;
|
|
911
|
+
const model = externalRunner ? undefined : applyThinkingSuffix(primaryModel, effectiveThinking, thinkingOverride !== undefined);
|
|
912
|
+
const contextLimit = model ? findModelInfo(model, availableModels, a.modelProvider ?? ctx.currentModelProvider)?.contextWindow : undefined;
|
|
913
|
+
const thinkingCeiling = externalRunner ? undefined : intersectThinkingCeilings(
|
|
914
|
+
params.thinkingCeiling,
|
|
915
|
+
a.maxThinking,
|
|
916
|
+
decodeThinkingCeiling(process.env[SUBAGENT_THINKING_CEILING_ENV]),
|
|
917
|
+
);
|
|
918
|
+
if (!externalRunner) {
|
|
919
|
+
try {
|
|
920
|
+
assertThinkingWithinCeiling({ model, configThinking: effectiveThinking, ceiling: thinkingCeiling, agent: a.name, runId: id });
|
|
921
|
+
} catch (error) {
|
|
922
|
+
throw new AsyncStartValidationError(error instanceof Error ? error.message : String(error));
|
|
923
|
+
}
|
|
924
|
+
}
|
|
925
|
+
const agentContract = s.agentContract ?? params.agentContract;
|
|
926
|
+
const permissionRules = resolvePermissionRules(ctx.permissions, a.permissions);
|
|
927
|
+
let modelCandidates: string[] = [];
|
|
928
|
+
if (!externalRunner) {
|
|
929
|
+
try {
|
|
930
|
+
modelCandidates = buildModelCandidates(primaryModel, a.fallbackModels, availableModels, a.modelProvider ?? ctx.currentModelProvider, {
|
|
931
|
+
scope: modelScopes,
|
|
932
|
+
primaryModelFromParent,
|
|
933
|
+
origin: modelOrigin,
|
|
934
|
+
}).flatMap((candidate) => {
|
|
935
|
+
const resolved = applyThinkingSuffix(candidate, effectiveThinking, thinkingOverride !== undefined);
|
|
936
|
+
return resolved ? [resolved] : [];
|
|
937
|
+
});
|
|
938
|
+
for (const candidate of modelCandidates) assertThinkingWithinCeiling({ model: candidate, configThinking: effectiveThinking, ceiling: thinkingCeiling, agent: a.name, runId: id });
|
|
939
|
+
} catch (error) {
|
|
940
|
+
throw new AsyncStartValidationError(error instanceof Error ? error.message : String(error));
|
|
941
|
+
}
|
|
942
|
+
}
|
|
943
|
+
const launchRuleError = applyWatchdogLaunchRules({ cwd: stepCwd, agent: a.name, model: modelCandidates[0] ?? model, warn: (violation) => sendRuleViolationWarning(ctx.pi, violation) });
|
|
944
|
+
if (launchRuleError) throw new AsyncStartValidationError(launchRuleError);
|
|
945
|
+
const fast = s.fast ?? params.fast ?? a.fast;
|
|
946
|
+
const toolPlan = resolvePiLaunchToolPlan({
|
|
947
|
+
tools: a.tools,
|
|
948
|
+
excludeTools: a.excludeTools,
|
|
949
|
+
allowNestedSubagents: a.allowNestedSubagents,
|
|
950
|
+
extensions: a.extensions,
|
|
951
|
+
subagentOnlyExtensions: a.subagentOnlyExtensions,
|
|
952
|
+
mcpDirectTools: a.mcpDirectTools,
|
|
953
|
+
cwd: stepCwd,
|
|
954
|
+
requireReadTool: Boolean(resolvedSkills.length),
|
|
955
|
+
structuredOutput: Boolean(s.outputSchema),
|
|
956
|
+
fast,
|
|
957
|
+
model,
|
|
958
|
+
modelCandidates,
|
|
959
|
+
capabilityCeiling: params.capabilityCeiling,
|
|
960
|
+
inheritedCapabilityCeiling: decodeSubagentCapabilityCeiling(process.env[SUBAGENT_CAPABILITY_CEILING_ENV]),
|
|
961
|
+
agentName: a.name,
|
|
962
|
+
permissionRules,
|
|
963
|
+
runtimeSnapshotHost: ctx.pi,
|
|
964
|
+
});
|
|
965
|
+
const launchResolvedExtensions = externalRunner ? undefined : projectLaunchResolvedChildExtensions(toolPlan);
|
|
966
|
+
if (externalRunner && permissionRules) {
|
|
967
|
+
throw new AsyncStartValidationError(`Agent '${a.name}' uses runner.type='${externalRunnerType}', which cannot enforce native Pi child permission rules.`);
|
|
968
|
+
}
|
|
969
|
+
if (!externalRunner) {
|
|
970
|
+
const contractTools = toolPlan.explicitToolAllowlist ? toolPlan.effectiveToolAllowlist : undefined;
|
|
971
|
+
const contractError = validateImplementationToolContract({
|
|
972
|
+
agent: a.name,
|
|
973
|
+
task,
|
|
974
|
+
tools: contractTools,
|
|
975
|
+
mcpDirectTools: toolPlan.effectiveMcpTools,
|
|
976
|
+
configuredExtensions: toolPlan.configuredExtensions,
|
|
977
|
+
requestedTools: toolPlan.requestedBuiltinTools,
|
|
978
|
+
acceptanceRole: a.acceptanceRole,
|
|
979
|
+
completionGuard: a.completionGuard,
|
|
980
|
+
});
|
|
981
|
+
if (contractError) throw new AsyncStartValidationError(contractError);
|
|
982
|
+
}
|
|
983
|
+
return {
|
|
984
|
+
parentSessionId: ctx.parentSessionId ?? ctx.currentSessionId,
|
|
985
|
+
permissionRules,
|
|
986
|
+
...(params.capabilityCeiling ? { capabilityCeiling: params.capabilityCeiling } : {}),
|
|
987
|
+
...(runFanoutPath ? { runFanoutPath } : {}),
|
|
988
|
+
agent: s.agent,
|
|
989
|
+
task,
|
|
990
|
+
...(a.runner ? { runner: a.runner } : {}),
|
|
991
|
+
...(params.contextForAgent ? { context: params.contextForAgent(s.agent) } : {}),
|
|
992
|
+
...(agentContract ? { agentContract } : {}),
|
|
993
|
+
phase: s.phase,
|
|
994
|
+
label: s.label,
|
|
995
|
+
outputName: s.as,
|
|
996
|
+
structured: Boolean(s.outputSchema),
|
|
997
|
+
cwd: stepCwd,
|
|
998
|
+
requestedCwd: s.cwd ?? stepCwd,
|
|
999
|
+
model,
|
|
1000
|
+
...(contextLimit !== undefined ? { contextLimit } : {}),
|
|
1001
|
+
...(fast !== undefined ? { fast } : {}),
|
|
1002
|
+
thinking: resolveEffectiveThinking(model, effectiveThinking),
|
|
1003
|
+
...(thinkingCeiling ? { thinkingCeiling } : {}),
|
|
1004
|
+
launchResolvedExtensions,
|
|
1005
|
+
...(toolPlan.mcpConfig ? { mcpConfig: toolPlan.mcpConfig } : {}),
|
|
1006
|
+
...(toolPlan.runtimeServerNames ? { runtimeServerNames: toolPlan.runtimeServerNames } : {}),
|
|
1007
|
+
modelCandidates: externalRunner ? undefined : modelCandidates,
|
|
1008
|
+
...(primaryModelFromParent ? { skipPrimaryModelVerification: true } : {}),
|
|
1009
|
+
...(availableModels && availableModels.length > 0 ? { modelVerificationRegistry: availableModels } : {}),
|
|
1010
|
+
tools: a.tools,
|
|
1011
|
+
excludeTools: a.excludeTools,
|
|
1012
|
+
allowNestedSubagents: a.allowNestedSubagents,
|
|
1013
|
+
extensions: a.extensions,
|
|
1014
|
+
subagentOnlyExtensions: a.subagentOnlyExtensions,
|
|
1015
|
+
mcpDirectTools: a.mcpDirectTools,
|
|
1016
|
+
mutationTools: a.mutationTools,
|
|
1017
|
+
completionGuard: a.completionGuard,
|
|
1018
|
+
systemPrompt,
|
|
1019
|
+
systemPromptMode: a.systemPromptMode,
|
|
1020
|
+
inheritProjectContext: a.inheritProjectContext,
|
|
1021
|
+
inheritGlobalContext: a.inheritGlobalContext,
|
|
1022
|
+
inheritSkills: a.inheritSkills,
|
|
1023
|
+
skills: resolvedSkills.map((r) => r.name),
|
|
1024
|
+
outputPath,
|
|
1025
|
+
...(namespaceOutputPath ? { namespaceOutputPath: true } : {}),
|
|
1026
|
+
outputMode: behavior.outputMode,
|
|
1027
|
+
sessionFile,
|
|
1028
|
+
maxSubagentDepth: resolveChildMaxSubagentDepth(maxSubagentDepth, a.maxSubagentDepth),
|
|
1029
|
+
timeoutMs: a.defaultTimeoutMs ?? DEFAULT_ASYNC_TIMEOUT_MS,
|
|
1030
|
+
toolTimeoutMs: resolvedToolTimeout.toolTimeoutMs,
|
|
1031
|
+
waitToolEnabled: params.waitToolEnabled,
|
|
1032
|
+
waitToolDefaultTimeoutMs: params.waitToolDefaultTimeoutMs,
|
|
1033
|
+
effectiveAcceptance: resolveEffectiveAcceptance({
|
|
1034
|
+
explicit: s.acceptance,
|
|
1035
|
+
agentName: s.agent,
|
|
1036
|
+
acceptanceRole: a.acceptanceRole,
|
|
1037
|
+
task,
|
|
1038
|
+
mode: resultMode,
|
|
1039
|
+
async: true,
|
|
1040
|
+
dynamic: false,
|
|
1041
|
+
agentContract,
|
|
1042
|
+
}),
|
|
1043
|
+
acceptanceInput: s.acceptance,
|
|
1044
|
+
acceptanceRole: a.acceptanceRole,
|
|
1045
|
+
...(s.gateOn ? { gateOn: s.gateOn } : {}),
|
|
1046
|
+
...(s.outputSchema ? { structuredOutputSchema: s.outputSchema } : {}),
|
|
1047
|
+
...(s.outputSchema ? { structuredOutput: createStructuredOutputRuntime(s.outputSchema, path.join(asyncDir, "structured-output"), { acceptanceReport: resolveAcceptanceReportMode(s.acceptance) }) } : {}),
|
|
1048
|
+
...(resolvedToolBudget.budget ? { toolBudget: resolvedToolBudget.budget } : {}),
|
|
1049
|
+
...(s.worktree ? { worktree: true } : {}),
|
|
1050
|
+
};
|
|
1051
|
+
};
|
|
1052
|
+
|
|
1053
|
+
let flatStepIndex = 0;
|
|
1054
|
+
const nextFlatStep = (): { index: number; sessionFile?: string; thinkingOverride?: AgentConfig["thinking"] } => {
|
|
1055
|
+
const index = flatStepIndex;
|
|
1056
|
+
const sessionFile = sessionFilesByFlatIndex?.[flatStepIndex];
|
|
1057
|
+
const thinkingOverride = thinkingOverridesByFlatIndex?.[flatStepIndex];
|
|
1058
|
+
flatStepIndex++;
|
|
1059
|
+
return {
|
|
1060
|
+
index,
|
|
1061
|
+
...(sessionFile ? { sessionFile } : {}),
|
|
1062
|
+
...(thinkingOverride ? { thinkingOverride } : {}),
|
|
1063
|
+
};
|
|
1064
|
+
};
|
|
1065
|
+
|
|
1066
|
+
try {
|
|
1067
|
+
const builtSteps = chain.map((s, stepIndex) => {
|
|
1068
|
+
if (isParallelStep(s)) {
|
|
1069
|
+
const parallelBehaviors = s.parallel.map((task) => {
|
|
1070
|
+
const agent = agents.find((candidate) => candidate.name === task.agent)!;
|
|
1071
|
+
return suppressProgressForReadOnlyTask(resolveStepBehavior(agent, buildStepOverrides(task), chainSkills), task.task, originalTask);
|
|
1072
|
+
});
|
|
1073
|
+
const progressPrecreated = parallelBehaviors.some((behavior) => behavior.progress);
|
|
1074
|
+
if (progressPrecreated) {
|
|
1075
|
+
if (!s.worktree || params.progressDir) writeInitialProgressFile(progressDir);
|
|
1076
|
+
progressInstructionCreated = true;
|
|
1077
|
+
}
|
|
1078
|
+
return {
|
|
1079
|
+
parallel: s.parallel.map((t, taskIndex) => {
|
|
1080
|
+
let behaviorCwd: string | undefined;
|
|
1081
|
+
if (s.worktree && managedWorktreeProvider === "worktrunk") {
|
|
1082
|
+
behaviorCwd = WORKTREE_AGENT_CWD_PLACEHOLDER;
|
|
1083
|
+
} else if (s.worktree && managedWorktreeProvider === "native") {
|
|
1084
|
+
try {
|
|
1085
|
+
behaviorCwd = resolveExpectedWorktreeAgentCwd(runnerCwd, `${id}-s${stepIndex}`, taskIndex, worktreeBaseDir);
|
|
1086
|
+
} catch {
|
|
1087
|
+
behaviorCwd = undefined;
|
|
1088
|
+
}
|
|
1089
|
+
}
|
|
1090
|
+
const staticStep = nextFlatStep();
|
|
1091
|
+
return buildSeqStep({ ...t, agentContract: t.agentContract ?? s.agentContract, gateOn: t.gateOn ?? s.gateOn }, staticStep.sessionFile, behaviorCwd, progressPrecreated, parallelBehaviors[taskIndex], staticStep.index, { stepIndex, taskIndex }, resultMode === "parallel" ? `tasks[${taskIndex}]` : `chain[${stepIndex}].parallel[${taskIndex}]`);
|
|
1092
|
+
}),
|
|
1093
|
+
concurrency: s.concurrency,
|
|
1094
|
+
failFast: s.failFast,
|
|
1095
|
+
worktree: s.worktree,
|
|
1096
|
+
};
|
|
1097
|
+
}
|
|
1098
|
+
if (isDynamicParallelStep(s)) {
|
|
1099
|
+
const agent = agents.find((candidate) => candidate.name === s.parallel.agent)!;
|
|
1100
|
+
const behavior = suppressProgressForReadOnlyTask(resolveStepBehavior(agent, buildStepOverrides(s.parallel), chainSkills), s.parallel.task, originalTask);
|
|
1101
|
+
const progressPrecreated = behavior.progress;
|
|
1102
|
+
if (progressPrecreated) {
|
|
1103
|
+
writeInitialProgressFile(progressDir);
|
|
1104
|
+
progressInstructionCreated = true;
|
|
1105
|
+
}
|
|
1106
|
+
const maxItems = s.expand.maxItems ?? params.dynamicFanoutMaxItems ?? 0;
|
|
1107
|
+
const dynamicFlatSteps = Array.from({ length: maxItems }, () => nextFlatStep());
|
|
1108
|
+
const parallel = buildSeqStep({ ...(s.parallel as SequentialStep), agentContract: s.parallel.agentContract ?? s.agentContract, gateOn: s.parallel.gateOn ?? s.gateOn }, undefined, undefined, progressPrecreated, behavior, undefined, { stepIndex });
|
|
1109
|
+
return {
|
|
1110
|
+
expand: s.expand,
|
|
1111
|
+
parallel,
|
|
1112
|
+
collect: s.collect,
|
|
1113
|
+
concurrency: s.concurrency,
|
|
1114
|
+
failFast: s.failFast,
|
|
1115
|
+
phase: s.phase,
|
|
1116
|
+
label: s.label,
|
|
1117
|
+
sessionFiles: dynamicFlatSteps.map((step) => step.sessionFile),
|
|
1118
|
+
thinkingOverrides: dynamicFlatSteps.map((step) => step.thinkingOverride),
|
|
1119
|
+
effectiveAcceptance: resolveEffectiveAcceptance({
|
|
1120
|
+
explicit: s.acceptance,
|
|
1121
|
+
agentName: s.parallel.agent,
|
|
1122
|
+
acceptanceRole: agent.acceptanceRole,
|
|
1123
|
+
task: parallel.task,
|
|
1124
|
+
mode: resultMode,
|
|
1125
|
+
async: true,
|
|
1126
|
+
dynamicGroup: true,
|
|
1127
|
+
agentContract: s.agentContract ?? params.agentContract,
|
|
1128
|
+
}),
|
|
1129
|
+
acceptanceInput: s.acceptance,
|
|
1130
|
+
acceptanceRole: agent.acceptanceRole,
|
|
1131
|
+
...(s.agentContract ?? params.agentContract ? { agentContract: s.agentContract ?? params.agentContract } : {}),
|
|
1132
|
+
...(s.gateOn ? { gateOn: s.gateOn } : {}),
|
|
1133
|
+
...(parallel.thinkingCeiling ? { thinkingCeiling: parallel.thinkingCeiling } : {}),
|
|
1134
|
+
};
|
|
1135
|
+
}
|
|
1136
|
+
const sequential = s as SequentialStep;
|
|
1137
|
+
let behaviorCwd: string | undefined;
|
|
1138
|
+
if (sequential.worktree && managedWorktreeProvider === "worktrunk") {
|
|
1139
|
+
behaviorCwd = WORKTREE_AGENT_CWD_PLACEHOLDER;
|
|
1140
|
+
} else if (sequential.worktree && managedWorktreeProvider === "native") {
|
|
1141
|
+
try {
|
|
1142
|
+
behaviorCwd = resolveExpectedWorktreeAgentCwd(runnerCwd, `${id}-s${stepIndex}`, 0, worktreeBaseDir);
|
|
1143
|
+
} catch {
|
|
1144
|
+
behaviorCwd = undefined;
|
|
1145
|
+
}
|
|
1146
|
+
}
|
|
1147
|
+
const staticStep = nextFlatStep();
|
|
1148
|
+
return buildSeqStep(sequential, staticStep.sessionFile, behaviorCwd, false, undefined, staticStep.index, undefined, `chain[${stepIndex}]`);
|
|
1149
|
+
});
|
|
1150
|
+
const steps = params.attachRoot
|
|
1151
|
+
? [{
|
|
1152
|
+
agent: params.attachRoot.agent,
|
|
1153
|
+
task: "",
|
|
1154
|
+
label: params.attachRoot.label ?? `Attached root ${params.attachRoot.runId}`,
|
|
1155
|
+
outputName: params.attachRoot.outputName,
|
|
1156
|
+
importAsyncRoot: {
|
|
1157
|
+
runId: params.attachRoot.runId,
|
|
1158
|
+
asyncDir: params.attachRoot.asyncDir,
|
|
1159
|
+
resultPath: params.attachRoot.resultPath,
|
|
1160
|
+
index: params.attachRoot.index,
|
|
1161
|
+
},
|
|
1162
|
+
inheritProjectContext: false,
|
|
1163
|
+
inheritGlobalContext: false,
|
|
1164
|
+
inheritSkills: false,
|
|
1165
|
+
}, ...builtSteps]
|
|
1166
|
+
: builtSteps;
|
|
1167
|
+
for (const step of steps) {
|
|
1168
|
+
if (!("parallel" in step) || !Array.isArray(step.parallel)) continue;
|
|
1169
|
+
const seen = new Map<string, { index: number; agent: string }>();
|
|
1170
|
+
for (let index = 0; index < step.parallel.length; index++) {
|
|
1171
|
+
const task = step.parallel[index]!;
|
|
1172
|
+
if (!task.outputPath) continue;
|
|
1173
|
+
const previous = seen.get(task.outputPath);
|
|
1174
|
+
if (previous) {
|
|
1175
|
+
throw new AsyncStartValidationError(`Parallel tasks ${previous.index + 1} (${previous.agent}) and ${index + 1} (${task.agent}) resolve output to the same path: ${task.outputPath}. Use distinct output paths.`);
|
|
1176
|
+
}
|
|
1177
|
+
seen.set(task.outputPath, { index, agent: task.agent });
|
|
1178
|
+
}
|
|
1179
|
+
}
|
|
1180
|
+
return { steps: steps as RunnerStep[], runnerCwd, workflowGraph, eventChain: graphChain, ...(originalTask !== undefined ? { originalTask } : {}) };
|
|
1181
|
+
} catch (error) {
|
|
1182
|
+
if (error instanceof UnavailableSubagentSkillError || error instanceof AsyncStartValidationError) return { error: error.message };
|
|
1183
|
+
throw error;
|
|
1184
|
+
}
|
|
1185
|
+
}
|
|
1186
|
+
|
|
1187
|
+
/**
|
|
1188
|
+
* Execute a chain asynchronously
|
|
1189
|
+
*/
|
|
1190
|
+
export function executeAsyncChain(
|
|
1191
|
+
id: string,
|
|
1192
|
+
params: AsyncChainParams,
|
|
1193
|
+
): AsyncExecutionResult {
|
|
1194
|
+
const {
|
|
1195
|
+
chain,
|
|
1196
|
+
agents,
|
|
1197
|
+
ctx,
|
|
1198
|
+
cwd,
|
|
1199
|
+
maxOutput,
|
|
1200
|
+
artifactsDir,
|
|
1201
|
+
artifactConfig,
|
|
1202
|
+
shareEnabled,
|
|
1203
|
+
sessionRoot,
|
|
1204
|
+
sessionFilesByFlatIndex,
|
|
1205
|
+
thinkingOverridesByFlatIndex,
|
|
1206
|
+
maxSubagentDepth,
|
|
1207
|
+
worktreeSetupHook,
|
|
1208
|
+
worktreeSetupHookTimeoutMs,
|
|
1209
|
+
worktreeBaseDir,
|
|
1210
|
+
worktreeProvider,
|
|
1211
|
+
worktreeBranchPrefix,
|
|
1212
|
+
controlConfig,
|
|
1213
|
+
controlIntercomTarget,
|
|
1214
|
+
childIntercomTarget,
|
|
1215
|
+
nestedRoute,
|
|
1216
|
+
} = params;
|
|
1217
|
+
const resultMode = params.resultMode ?? "chain";
|
|
1218
|
+
const acceptanceErrors = validateExecutionAcceptance({
|
|
1219
|
+
chain: chain.map((step) => {
|
|
1220
|
+
if (isParallelStep(step)) return { parallel: step.parallel };
|
|
1221
|
+
if (isDynamicParallelStep(step)) return { acceptance: step.acceptance, parallel: step.parallel };
|
|
1222
|
+
return { acceptance: step.acceptance, outputSchema: step.outputSchema };
|
|
1223
|
+
}),
|
|
1224
|
+
});
|
|
1225
|
+
if (acceptanceErrors.length > 0) return formatAsyncStartError(resultMode, acceptanceErrors.join(" "));
|
|
1226
|
+
const capabilityCeiling = params.capabilityCeiling ?? resolveCurrentSubagentCapabilityCeiling(ctx.currentSessionId);
|
|
1227
|
+
const inheritedNestedRoute = resolveInheritedNestedRouteFromEnv();
|
|
1228
|
+
const nestedAddress = inheritedNestedRoute ? resolveNestedParentAddressFromEnv() : undefined;
|
|
1229
|
+
const asyncDir = inheritedNestedRoute
|
|
1230
|
+
? path.join(TEMP_ROOT_DIR, "nested-subagent-runs", inheritedNestedRoute.rootRunId, id)
|
|
1231
|
+
: path.join(DIRS.async, id);
|
|
1232
|
+
let runFanoutBudget: RunFanoutBudgetDescriptor;
|
|
1233
|
+
try {
|
|
1234
|
+
runFanoutBudget = params.runFanoutBudget ?? createRunFanoutBudget(id, 64);
|
|
1235
|
+
fs.mkdirSync(asyncDir, { recursive: true });
|
|
1236
|
+
writeRunFanoutBudgetDescriptor(asyncDir, runFanoutBudget);
|
|
1237
|
+
} catch (error) {
|
|
1238
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
1239
|
+
return {
|
|
1240
|
+
content: [{ type: "text", text: `Failed to create async run directory '${asyncDir}': ${message}` }],
|
|
1241
|
+
isError: true,
|
|
1242
|
+
details: { mode: resultMode, results: [] },
|
|
1243
|
+
};
|
|
1244
|
+
}
|
|
1245
|
+
|
|
1246
|
+
const built = buildAsyncRunnerSteps(id, {
|
|
1247
|
+
chain,
|
|
1248
|
+
task: params.task,
|
|
1249
|
+
attachRoot: params.attachRoot,
|
|
1250
|
+
resultMode,
|
|
1251
|
+
agents,
|
|
1252
|
+
unknownAgentDiagnosticContext: params.unknownAgentDiagnosticContext,
|
|
1253
|
+
ctx,
|
|
1254
|
+
availableModels: params.availableModels,
|
|
1255
|
+
cwd,
|
|
1256
|
+
chainSkills: params.chainSkills,
|
|
1257
|
+
sessionFilesByFlatIndex,
|
|
1258
|
+
thinkingOverridesByFlatIndex,
|
|
1259
|
+
contextForAgent: params.contextForAgent,
|
|
1260
|
+
progressDir: params.progressDir ?? (artifactsDir ? path.join(artifactsDir, "progress", id) : resultMode === "parallel" ? path.join(asyncDir, "progress") : undefined),
|
|
1261
|
+
agentContract: params.agentContract,
|
|
1262
|
+
outputBaseDir: artifactsDir ? path.join(artifactsDir, "outputs", id) : undefined,
|
|
1263
|
+
dynamicFanoutMaxItems: params.dynamicFanoutMaxItems,
|
|
1264
|
+
maxSubagentDepth,
|
|
1265
|
+
waitToolEnabled: params.waitToolEnabled,
|
|
1266
|
+
waitToolDefaultTimeoutMs: params.waitToolDefaultTimeoutMs,
|
|
1267
|
+
worktreeBaseDir,
|
|
1268
|
+
worktreeProvider,
|
|
1269
|
+
worktreeBranchPrefix,
|
|
1270
|
+
asyncDir,
|
|
1271
|
+
fast: params.fast,
|
|
1272
|
+
toolBudget: params.toolBudget,
|
|
1273
|
+
configToolBudget: params.configToolBudget,
|
|
1274
|
+
callToolTimeoutMs: params.callToolTimeoutMs,
|
|
1275
|
+
configToolTimeoutMs: params.configToolTimeoutMs,
|
|
1276
|
+
toolTimeoutMsEnv: params.toolTimeoutMsEnv ?? toolTimeoutFromEnv(),
|
|
1277
|
+
capabilityCeiling,
|
|
1278
|
+
thinkingCeiling: params.thinkingCeiling,
|
|
1279
|
+
});
|
|
1280
|
+
if ("error" in built) {
|
|
1281
|
+
try {
|
|
1282
|
+
fs.rmSync(asyncDir, { recursive: true, force: true });
|
|
1283
|
+
} catch {
|
|
1284
|
+
// Best-effort cleanup for validation failures before the runner is spawned.
|
|
1285
|
+
}
|
|
1286
|
+
return formatAsyncStartError(resultMode, built.error);
|
|
1287
|
+
}
|
|
1288
|
+
const { steps, runnerCwd, workflowGraph, eventChain } = built;
|
|
1289
|
+
const deadlineAt = params.timeoutMs !== undefined ? Date.now() + params.timeoutMs : undefined;
|
|
1290
|
+
const initialUsageBudget = usageBudgetState(params.usageBudget, undefined);
|
|
1291
|
+
let childTargetIndex = 0;
|
|
1292
|
+
const childIntercomTargets = childIntercomTarget ? steps.flatMap((step) => {
|
|
1293
|
+
if (!("parallel" in step) && "importAsyncRoot" in step && step.importAsyncRoot) {
|
|
1294
|
+
childTargetIndex++;
|
|
1295
|
+
return [undefined];
|
|
1296
|
+
}
|
|
1297
|
+
if ("parallel" in step) {
|
|
1298
|
+
if (!Array.isArray(step.parallel)) {
|
|
1299
|
+
childTargetIndex++;
|
|
1300
|
+
return [undefined];
|
|
1301
|
+
}
|
|
1302
|
+
return step.parallel.map((task) => childIntercomTarget(task.agent, childTargetIndex++));
|
|
1303
|
+
}
|
|
1304
|
+
return "agent" in step ? [childIntercomTarget(step.agent, childTargetIndex++)] : [undefined];
|
|
1305
|
+
}) : undefined;
|
|
1306
|
+
const initialStatusSteps = eventChain.flatMap((step) => isParallelStep(step)
|
|
1307
|
+
? step.parallel.map((task) => ({ agent: task.agent, ...(statusStepDescription(task.task) ? { description: statusStepDescription(task.task) } : {}), ...(task.label ? { label: task.label } : {}), ...(task.as ? { outputName: task.as } : {}), status: "pending" as const }))
|
|
1308
|
+
: isDynamicParallelStep(step)
|
|
1309
|
+
? [{ agent: `expand:${step.parallel.agent}`, label: step.label ?? step.parallel.label ?? `Dynamic fanout (${step.collect.as})`, outputName: step.collect.as, status: "pending" as const }]
|
|
1310
|
+
: [{ agent: (step as SequentialStep).agent, ...(statusStepDescription((step as SequentialStep).task) ? { description: statusStepDescription((step as SequentialStep).task) } : {}), ...((step as SequentialStep).label ? { label: (step as SequentialStep).label } : {}), ...((step as SequentialStep).as ? { outputName: (step as SequentialStep).as } : {}), status: "pending" as const }]);
|
|
1311
|
+
const initialParallelGroups: AsyncParallelGroupStatus[] = [];
|
|
1312
|
+
let initialFlatIndex = 0;
|
|
1313
|
+
for (let stepIndex = 0; stepIndex < eventChain.length; stepIndex++) {
|
|
1314
|
+
const step = eventChain[stepIndex]!;
|
|
1315
|
+
if (isParallelStep(step)) initialParallelGroups.push({ start: initialFlatIndex, count: step.parallel.length, stepIndex });
|
|
1316
|
+
else if (isDynamicParallelStep(step)) initialParallelGroups.push({ start: initialFlatIndex, count: 1, stepIndex });
|
|
1317
|
+
initialFlatIndex += isParallelStep(step) ? step.parallel.length : 1;
|
|
1318
|
+
}
|
|
1319
|
+
const initialStatusAt = Date.now();
|
|
1320
|
+
const initialCompletionOwnerId = ctx.completionOwnerId ?? currentCompletionOwnerId();
|
|
1321
|
+
|
|
1322
|
+
let spawnResult: SpawnRunnerResult = {};
|
|
1323
|
+
try {
|
|
1324
|
+
spawnResult = spawnRunner(
|
|
1325
|
+
{
|
|
1326
|
+
id,
|
|
1327
|
+
steps,
|
|
1328
|
+
resultPath: inheritedNestedRoute ? nestedResultsPath(inheritedNestedRoute.rootRunId, id) : resultFilePath(DIRS.results, id),
|
|
1329
|
+
cwd: runnerCwd,
|
|
1330
|
+
placeholder: "{previous}",
|
|
1331
|
+
maxOutput,
|
|
1332
|
+
artifactsDir: artifactConfig.enabled ? artifactsDir : undefined,
|
|
1333
|
+
artifactConfig,
|
|
1334
|
+
share: shareEnabled,
|
|
1335
|
+
sessionDir: sessionRoot ? path.join(sessionRoot, `async-${id}`) : undefined,
|
|
1336
|
+
asyncDir,
|
|
1337
|
+
sessionId: ctx.currentSessionId,
|
|
1338
|
+
completionOwnerId: ctx.completionOwnerId ?? currentCompletionOwnerId(),
|
|
1339
|
+
...(capabilityCeiling ? { capabilityCeiling } : {}),
|
|
1340
|
+
piPackageRoot,
|
|
1341
|
+
piArgv1: process.argv[1],
|
|
1342
|
+
worktreeSetupHook,
|
|
1343
|
+
worktreeSetupHookTimeoutMs,
|
|
1344
|
+
worktreeBaseDir,
|
|
1345
|
+
worktreeProvider,
|
|
1346
|
+
worktreeBranchPrefix,
|
|
1347
|
+
controlConfig,
|
|
1348
|
+
toolBudget: params.toolBudget,
|
|
1349
|
+
usageBudget: params.usageBudget,
|
|
1350
|
+
controlIntercomTarget,
|
|
1351
|
+
childIntercomTargets,
|
|
1352
|
+
resultMode,
|
|
1353
|
+
dynamicFanoutMaxItems: params.dynamicFanoutMaxItems,
|
|
1354
|
+
timeoutMs: params.timeoutMs,
|
|
1355
|
+
deadlineAt,
|
|
1356
|
+
globalConcurrencyLimit: params.globalConcurrencyLimit,
|
|
1357
|
+
runFanoutBudget,
|
|
1358
|
+
workflowGraph,
|
|
1359
|
+
...(params.parentWorkflowRunId ? { parentWorkflowRunId: params.parentWorkflowRunId } : {}),
|
|
1360
|
+
...(params.workflowKey ? { workflowKey: params.workflowKey } : {}),
|
|
1361
|
+
nestedRoute: nestedRoute ?? inheritedNestedRoute,
|
|
1362
|
+
nestedSelf: inheritedNestedRoute && nestedAddress ? {
|
|
1363
|
+
parentRunId: nestedAddress.parentRunId,
|
|
1364
|
+
parentStepIndex: nestedAddress.parentStepIndex,
|
|
1365
|
+
depth: nestedAddress.depth,
|
|
1366
|
+
path: nestedAddress.path,
|
|
1367
|
+
} : undefined,
|
|
1368
|
+
},
|
|
1369
|
+
id,
|
|
1370
|
+
runnerCwd,
|
|
1371
|
+
{
|
|
1372
|
+
lifecycleArtifactVersion: SUBAGENT_LIFECYCLE_ARTIFACT_VERSION,
|
|
1373
|
+
runId: id,
|
|
1374
|
+
...(ctx.currentSessionId ? { sessionId: ctx.currentSessionId } : {}),
|
|
1375
|
+
...(initialCompletionOwnerId ? { completionOwnerId: initialCompletionOwnerId } : {}),
|
|
1376
|
+
mode: resultMode,
|
|
1377
|
+
state: "running",
|
|
1378
|
+
startedAt: initialStatusAt,
|
|
1379
|
+
lastUpdate: initialStatusAt,
|
|
1380
|
+
currentStep: 0,
|
|
1381
|
+
chainStepCount: eventChain.length,
|
|
1382
|
+
...(initialParallelGroups.length ? { parallelGroups: initialParallelGroups } : {}),
|
|
1383
|
+
steps: initialStatusSteps,
|
|
1384
|
+
},
|
|
1385
|
+
path.join(asyncDir, "status.json"),
|
|
1386
|
+
(proof) => emitProcessTerminalEvent(ctx, proof),
|
|
1387
|
+
(runnerProcessInstanceId) => params.activeAsyncCapacity?.markStarted(runnerProcessInstanceId),
|
|
1388
|
+
);
|
|
1389
|
+
} catch (error) {
|
|
1390
|
+
params.activeAsyncCapacity?.rollback();
|
|
1391
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
1392
|
+
return formatAsyncStartError(resultMode, `Failed to start async ${resultMode} '${id}': ${message}`);
|
|
1393
|
+
}
|
|
1394
|
+
|
|
1395
|
+
if (spawnResult.error) {
|
|
1396
|
+
if (spawnResult.startupDidNotProceed) {
|
|
1397
|
+
if (!spawnResult.runnerProcessInstanceId || params.activeAsyncCapacity?.rollbackBeforeRunnerProceed(spawnResult.runnerProcessInstanceId) !== true) params.activeAsyncCapacity?.rollback();
|
|
1398
|
+
}
|
|
1399
|
+
else if (!spawnResult.pid || !spawnResult.runnerProcessInstanceId) params.activeAsyncCapacity?.rollback();
|
|
1400
|
+
else params.activeAsyncCapacity?.markStarted(spawnResult.runnerProcessInstanceId);
|
|
1401
|
+
return formatAsyncStartError(resultMode, `Failed to start async ${resultMode} '${id}': ${spawnResult.error}`);
|
|
1402
|
+
}
|
|
1403
|
+
if (!spawnResult.pid || !spawnResult.runnerProcessInstanceId) {
|
|
1404
|
+
params.activeAsyncCapacity?.rollback();
|
|
1405
|
+
return formatAsyncStartError(resultMode, `Failed to start async ${resultMode} '${id}': runner identity unavailable`);
|
|
1406
|
+
}
|
|
1407
|
+
if (spawnResult.pid) {
|
|
1408
|
+
const eventFirstStep = eventChain[0];
|
|
1409
|
+
if (!eventFirstStep) {
|
|
1410
|
+
return formatAsyncStartError(resultMode, `Failed to start async ${resultMode} '${id}': event chain has no steps`);
|
|
1411
|
+
}
|
|
1412
|
+
const firstAgents = isParallelStep(eventFirstStep)
|
|
1413
|
+
? eventFirstStep.parallel.map((t) => t.agent)
|
|
1414
|
+
: isDynamicParallelStep(eventFirstStep)
|
|
1415
|
+
? [eventFirstStep.parallel.agent]
|
|
1416
|
+
: [(eventFirstStep as SequentialStep).agent];
|
|
1417
|
+
const firstTask = isParallelStep(eventFirstStep)
|
|
1418
|
+
? eventFirstStep.parallel[0]?.task
|
|
1419
|
+
: isDynamicParallelStep(eventFirstStep)
|
|
1420
|
+
? eventFirstStep.parallel.task
|
|
1421
|
+
: (eventFirstStep as SequentialStep).task;
|
|
1422
|
+
const workflowGoal = params.goal ?? (params.task?.trim() || firstTask);
|
|
1423
|
+
const parallelGroups: Array<{ start: number; count: number; stepIndex: number }> = [];
|
|
1424
|
+
const flatAgents: string[] = [];
|
|
1425
|
+
let flatStepStart = 0;
|
|
1426
|
+
for (let stepIndex = 0; stepIndex < eventChain.length; stepIndex++) {
|
|
1427
|
+
const step = eventChain[stepIndex]!;
|
|
1428
|
+
if (isParallelStep(step)) {
|
|
1429
|
+
parallelGroups.push({ start: flatStepStart, count: step.parallel.length, stepIndex });
|
|
1430
|
+
flatAgents.push(...step.parallel.map((task) => task.agent));
|
|
1431
|
+
flatStepStart += step.parallel.length;
|
|
1432
|
+
} else if (isDynamicParallelStep(step)) {
|
|
1433
|
+
parallelGroups.push({ start: flatStepStart, count: 1, stepIndex });
|
|
1434
|
+
flatAgents.push(step.parallel.agent);
|
|
1435
|
+
flatStepStart++;
|
|
1436
|
+
} else {
|
|
1437
|
+
flatAgents.push((step as SequentialStep).agent);
|
|
1438
|
+
flatStepStart++;
|
|
1439
|
+
}
|
|
1440
|
+
}
|
|
1441
|
+
if (inheritedNestedRoute && nestedAddress) {
|
|
1442
|
+
const now = Date.now();
|
|
1443
|
+
try {
|
|
1444
|
+
writeNestedEvent(inheritedNestedRoute, {
|
|
1445
|
+
type: "subagent.nested.started",
|
|
1446
|
+
ts: now,
|
|
1447
|
+
parentRunId: nestedAddress.parentRunId,
|
|
1448
|
+
parentStepIndex: nestedAddress.parentStepIndex,
|
|
1449
|
+
child: {
|
|
1450
|
+
id,
|
|
1451
|
+
parentRunId: nestedAddress.parentRunId,
|
|
1452
|
+
parentStepIndex: nestedAddress.parentStepIndex,
|
|
1453
|
+
depth: nestedAddress.depth,
|
|
1454
|
+
path: nestedAddress.path,
|
|
1455
|
+
asyncDir,
|
|
1456
|
+
pid: spawnResult.pid,
|
|
1457
|
+
ownerIntercomTarget: process.env.SELESAI_SUBAGENT_INTERCOM_SESSION_NAME,
|
|
1458
|
+
leafIntercomTarget: childIntercomTargets?.[0],
|
|
1459
|
+
intercomTarget: childIntercomTargets?.[0],
|
|
1460
|
+
ownerState: "live",
|
|
1461
|
+
mode: resultMode,
|
|
1462
|
+
state: "running",
|
|
1463
|
+
agent: firstAgents[0],
|
|
1464
|
+
agents: flatAgents,
|
|
1465
|
+
chainStepCount: eventChain.length,
|
|
1466
|
+
parallelGroups,
|
|
1467
|
+
...(params.timeoutMs !== undefined ? { timeoutMs: params.timeoutMs, deadlineAt } : {}),
|
|
1468
|
+
startedAt: now,
|
|
1469
|
+
lastUpdate: now,
|
|
1470
|
+
...(capabilityCeiling ? { capabilityCeiling } : {}),
|
|
1471
|
+
},
|
|
1472
|
+
});
|
|
1473
|
+
} catch (error) {
|
|
1474
|
+
console.error("Failed to emit nested async start event:", error);
|
|
1475
|
+
}
|
|
1476
|
+
}
|
|
1477
|
+
ctx.pi.events.emit(SUBAGENT_ASYNC_STARTED_EVENT, {
|
|
1478
|
+
lifecycleArtifactVersion: SUBAGENT_LIFECYCLE_ARTIFACT_VERSION,
|
|
1479
|
+
id,
|
|
1480
|
+
pid: spawnResult.pid,
|
|
1481
|
+
sessionId: ctx.currentSessionId,
|
|
1482
|
+
completionOwnerId: ctx.completionOwnerId ?? currentCompletionOwnerId(),
|
|
1483
|
+
mode: resultMode,
|
|
1484
|
+
agent: firstAgents[0],
|
|
1485
|
+
agents: flatAgents,
|
|
1486
|
+
task: firstTask?.trim() ? PROMPT_REDACTED : undefined,
|
|
1487
|
+
goal: workflowGoal?.trim() ? PROMPT_REDACTED : undefined,
|
|
1488
|
+
chain: eventChain.map((s) =>
|
|
1489
|
+
isParallelStep(s) ? `[${s.parallel.map((t) => t.agent).join("+")}]` : isDynamicParallelStep(s) ? `expand:${s.parallel.agent}` : (s as SequentialStep).agent,
|
|
1490
|
+
),
|
|
1491
|
+
chainStepCount: eventChain.length,
|
|
1492
|
+
parallelGroups,
|
|
1493
|
+
workflowGraph,
|
|
1494
|
+
cwd: runnerCwd,
|
|
1495
|
+
asyncDir,
|
|
1496
|
+
...(sessionRoot ? { sessionRoot } : {}),
|
|
1497
|
+
...(params.timeoutMs !== undefined ? { timeoutMs: params.timeoutMs, deadlineAt } : {}),
|
|
1498
|
+
...(initialUsageBudget ? { usageBudget: initialUsageBudget } : {}),
|
|
1499
|
+
...(capabilityCeiling ? { capabilityCeiling } : {}),
|
|
1500
|
+
...(params.parentWorkflowRunId ? { parentWorkflowRunId: params.parentWorkflowRunId } : {}),
|
|
1501
|
+
...(params.workflowKey ? { workflowKey: params.workflowKey } : {}),
|
|
1502
|
+
nestedRoute,
|
|
1503
|
+
});
|
|
1504
|
+
}
|
|
1505
|
+
|
|
1506
|
+
const chainDesc = chain
|
|
1507
|
+
.map((s) =>
|
|
1508
|
+
isParallelStep(s) ? `[${s.parallel.map((t) => t.agent).join("+")}]` : isDynamicParallelStep(s) ? `expand:${s.parallel.agent}` : (s as SequentialStep).agent,
|
|
1509
|
+
)
|
|
1510
|
+
.join(" -> ");
|
|
1511
|
+
|
|
1512
|
+
return {
|
|
1513
|
+
content: [{ type: "text", text: formatAsyncStartedMessage(`Async ${resultMode}: ${chainDesc} [${id}]`, ctx.interactive === true) }],
|
|
1514
|
+
details: { mode: resultMode, runId: id, results: [], asyncId: id, asyncDir, workflowGraph, ...(capabilityCeiling ? { capabilityCeiling } : {}), ...(params.parentWorkflowRunId ? { parentWorkflowRunId: params.parentWorkflowRunId } : {}), ...(params.workflowKey ? { workflowKey: params.workflowKey } : {}), ...(params.timeoutMs !== undefined ? { timeoutMs: params.timeoutMs, deadlineAt } : {}), ...(params.toolBudget ? { toolBudget: params.toolBudget } : {}), ...(initialUsageBudget ? { usageBudget: initialUsageBudget } : {}) },
|
|
1515
|
+
};
|
|
1516
|
+
}
|
|
1517
|
+
|
|
1518
|
+
/**
|
|
1519
|
+
* Execute a single agent asynchronously
|
|
1520
|
+
*/
|
|
1521
|
+
export function workflowAwaitedAsyncResultPath(asyncDir: string): string {
|
|
1522
|
+
return path.join(asyncDir, "workflow-result.json");
|
|
1523
|
+
}
|
|
1524
|
+
|
|
1525
|
+
export function executeAsyncSingle(
|
|
1526
|
+
id: string,
|
|
1527
|
+
params: AsyncSingleParams,
|
|
1528
|
+
): AsyncExecutionResult {
|
|
1529
|
+
const {
|
|
1530
|
+
agent,
|
|
1531
|
+
agentConfig,
|
|
1532
|
+
ctx,
|
|
1533
|
+
cwd,
|
|
1534
|
+
maxOutput,
|
|
1535
|
+
artifactsDir,
|
|
1536
|
+
artifactConfig,
|
|
1537
|
+
shareEnabled,
|
|
1538
|
+
sessionRoot,
|
|
1539
|
+
sessionFile,
|
|
1540
|
+
maxSubagentDepth,
|
|
1541
|
+
worktreeSetupHook,
|
|
1542
|
+
worktreeSetupHookTimeoutMs,
|
|
1543
|
+
worktreeBaseDir,
|
|
1544
|
+
worktreeProvider,
|
|
1545
|
+
worktreeBranchPrefix,
|
|
1546
|
+
controlConfig,
|
|
1547
|
+
controlIntercomTarget,
|
|
1548
|
+
childIntercomTarget,
|
|
1549
|
+
nestedRoute,
|
|
1550
|
+
} = params;
|
|
1551
|
+
let lane: WorkflowLaneMetadata | undefined;
|
|
1552
|
+
try {
|
|
1553
|
+
lane = normalizeWorkflowLaneMetadata(params.lane, "lane");
|
|
1554
|
+
assertWorkflowLaneKey(lane, params.workflowKey, "lane");
|
|
1555
|
+
} catch (error) {
|
|
1556
|
+
return formatAsyncStartError("single", error instanceof Error ? error.message : String(error));
|
|
1557
|
+
}
|
|
1558
|
+
const task = params.task ?? "";
|
|
1559
|
+
let extensionBindings: ExtensionBindings | undefined;
|
|
1560
|
+
try {
|
|
1561
|
+
extensionBindings = normalizeExtensionBindings(params.extensionBindings)?.value;
|
|
1562
|
+
} catch (error) {
|
|
1563
|
+
return formatAsyncStartError("single", error instanceof Error ? error.message : String(error));
|
|
1564
|
+
}
|
|
1565
|
+
const acceptanceErrors = validateAcceptanceInput(params.acceptance);
|
|
1566
|
+
if (acceptanceErrors.length > 0) return formatAsyncStartError("single", acceptanceErrors.join(" "));
|
|
1567
|
+
const externalRunner = agentConfig.runner?.type === "external-cli" || agentConfig.runner?.type === "external-job";
|
|
1568
|
+
const externalRunnerType = agentConfig.runner?.type;
|
|
1569
|
+
const permissionRules = resolvePermissionRules(ctx.permissions, agentConfig.permissions);
|
|
1570
|
+
if (externalRunner) {
|
|
1571
|
+
const unsupported: string[] = [];
|
|
1572
|
+
if (params.modelOverride !== undefined) unsupported.push("model override");
|
|
1573
|
+
if ((params.fast ?? agentConfig.fast) === true) unsupported.push("fast mode");
|
|
1574
|
+
if (params.thinkingOverride !== undefined) unsupported.push("thinking override");
|
|
1575
|
+
if (params.structuredOutputSchema !== undefined) unsupported.push("structured output");
|
|
1576
|
+
if (params.acceptance !== undefined || params.agentContract !== undefined) unsupported.push("acceptance/agent contract");
|
|
1577
|
+
if (params.toolBudget !== undefined || agentConfig.toolBudget !== undefined || params.configToolBudget !== undefined) unsupported.push("tool budget");
|
|
1578
|
+
if (params.context === "fork") unsupported.push("fork context");
|
|
1579
|
+
if ((params.skills?.length ?? 0) > 0) unsupported.push("skills");
|
|
1580
|
+
if (permissionRules) unsupported.push("native Pi child permissions");
|
|
1581
|
+
if (extensionBindings !== undefined) unsupported.push("extension bindings");
|
|
1582
|
+
if (unsupported.length > 0) return formatAsyncStartError("single", `Agent '${agentConfig.name}' uses runner.type='${externalRunnerType}' and does not support: ${unsupported.join(", ")}.`);
|
|
1583
|
+
}
|
|
1584
|
+
const capabilityCeiling = intersectSubagentCapabilityCeilings(params.capabilityCeiling ?? resolveCurrentSubagentCapabilityCeiling(ctx.currentSessionId), decodeSubagentCapabilityCeiling(process.env[SUBAGENT_CAPABILITY_CEILING_ENV]));
|
|
1585
|
+
try {
|
|
1586
|
+
assertAgentAllowedByCapabilityCeiling(agentConfig.name, capabilityCeiling);
|
|
1587
|
+
} catch (error) {
|
|
1588
|
+
return formatAsyncStartError("single", error instanceof Error ? error.message : String(error));
|
|
1589
|
+
}
|
|
1590
|
+
const runnerCwd = resolveChildCwd(ctx.cwd, cwd);
|
|
1591
|
+
let managedWorktreeProvider: "native" | "worktrunk" | undefined;
|
|
1592
|
+
if (params.worktree === true) {
|
|
1593
|
+
try {
|
|
1594
|
+
const resolved = resolveWorktreeProvider(params.worktreeProvider, worktreeBaseDir);
|
|
1595
|
+
managedWorktreeProvider = shouldDeferWorktreeCwd(params.worktreeProvider, worktreeBaseDir) ? "worktrunk" : resolved;
|
|
1596
|
+
} catch (error) {
|
|
1597
|
+
return formatAsyncStartError("single", error instanceof Error ? error.message : String(error));
|
|
1598
|
+
}
|
|
1599
|
+
}
|
|
1600
|
+
const instructionCwd = params.worktree === true && managedWorktreeProvider === "worktrunk"
|
|
1601
|
+
? WORKTREE_AGENT_CWD_PLACEHOLDER
|
|
1602
|
+
: params.worktree === true && managedWorktreeProvider === "native"
|
|
1603
|
+
? resolveExpectedWorktreeAgentCwd(runnerCwd, `${id}-s0`, 0, worktreeBaseDir)
|
|
1604
|
+
: runnerCwd;
|
|
1605
|
+
const readExistenceCwd = params.worktree === true ? runnerCwd : instructionCwd;
|
|
1606
|
+
const skillNames = params.skills ?? agentConfig.skills ?? [];
|
|
1607
|
+
const availableModels = params.availableModels;
|
|
1608
|
+
const { resolved: resolvedSkills, missing: missingSkills } = resolveSkillsWithFallback(
|
|
1609
|
+
skillNames,
|
|
1610
|
+
runnerCwd,
|
|
1611
|
+
ctx.cwd,
|
|
1612
|
+
agentConfig.skillPath,
|
|
1613
|
+
agentConfig.filePath ? path.dirname(agentConfig.filePath) : runnerCwd,
|
|
1614
|
+
);
|
|
1615
|
+
if (missingSkills.includes("pi-subagents")) return formatAsyncStartError("single", UNAVAILABLE_SUBAGENT_SKILL_ERROR);
|
|
1616
|
+
let systemPrompt = agentConfig.systemPrompt?.trim() ?? "";
|
|
1617
|
+
if (resolvedSkills.length > 0) {
|
|
1618
|
+
const injection = buildSkillInjection(resolvedSkills);
|
|
1619
|
+
systemPrompt = systemPrompt ? `${systemPrompt}\n\n${injection}` : injection;
|
|
1620
|
+
}
|
|
1621
|
+
const memoryInjection = buildAgentMemoryInjection(agentConfig, runnerCwd);
|
|
1622
|
+
if (memoryInjection) {
|
|
1623
|
+
systemPrompt = systemPrompt ? `${systemPrompt}\n\n${memoryInjection}` : memoryInjection;
|
|
1624
|
+
}
|
|
1625
|
+
systemPrompt = appendAgentRefinementOverlay(systemPrompt, { cwd: runnerCwd, agentName: agentConfig.name });
|
|
1626
|
+
|
|
1627
|
+
const inheritedNestedRoute = resolveInheritedNestedRouteFromEnv();
|
|
1628
|
+
const nestedAddress = inheritedNestedRoute ? resolveNestedParentAddressFromEnv() : undefined;
|
|
1629
|
+
const asyncDir = inheritedNestedRoute
|
|
1630
|
+
? path.join(TEMP_ROOT_DIR, "nested-subagent-runs", inheritedNestedRoute.rootRunId, id)
|
|
1631
|
+
: path.join(DIRS.async, id);
|
|
1632
|
+
let runFanoutBudget: RunFanoutBudgetDescriptor;
|
|
1633
|
+
try {
|
|
1634
|
+
runFanoutBudget = params.runFanoutBudget ?? createRunFanoutBudget(id, 64);
|
|
1635
|
+
fs.mkdirSync(asyncDir, { recursive: true });
|
|
1636
|
+
writeRunFanoutBudgetDescriptor(asyncDir, runFanoutBudget);
|
|
1637
|
+
} catch (error) {
|
|
1638
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
1639
|
+
return {
|
|
1640
|
+
content: [{ type: "text", text: `Failed to create async run directory '${asyncDir}': ${message}` }],
|
|
1641
|
+
isError: true,
|
|
1642
|
+
details: { mode: "single" as const, results: [] },
|
|
1643
|
+
};
|
|
1644
|
+
}
|
|
1645
|
+
|
|
1646
|
+
const effectiveOutput = normalizeSingleOutputOverride(params.output, agentConfig.output);
|
|
1647
|
+
const outputPath = resolveSingleOutputPath(effectiveOutput, ctx.cwd, instructionCwd, params.outputBaseDir ?? (artifactsDir ? path.join(artifactsDir, "outputs", id) : undefined));
|
|
1648
|
+
systemPrompt = injectOutputPathSystemPrompt(systemPrompt, outputPath, agentConfig);
|
|
1649
|
+
const outputMode = params.outputMode ?? agentConfig.outputMode ?? "inline";
|
|
1650
|
+
const validationError = validateFileOnlyOutputMode(outputMode, outputPath, `Async single run (${agent})`);
|
|
1651
|
+
if (validationError) return formatAsyncStartError("single", validationError);
|
|
1652
|
+
const taskWithOutputInstruction = injectSingleOutputInstruction(task, outputPath, agentConfig);
|
|
1653
|
+
// Reads: caller override > agent defaultReads > none. `~`/`~/` expand to home;
|
|
1654
|
+
// absolute paths pass through; relative paths resolve against the child cwd.
|
|
1655
|
+
const reads = params.reads !== undefined ? params.reads : agentConfig.defaultReads ?? false;
|
|
1656
|
+
const readPaths = Array.isArray(reads)
|
|
1657
|
+
? managedWorktreeProvider === "worktrunk"
|
|
1658
|
+
? resolveExistingReadInstructionPaths(reads, instructionCwd, readExistenceCwd)
|
|
1659
|
+
: resolveExistingReadPaths(reads, readExistenceCwd)
|
|
1660
|
+
: [];
|
|
1661
|
+
const readsInstruction = readPaths.length > 0
|
|
1662
|
+
? `[Read from: ${readPaths.join(", ")}]\n\n`
|
|
1663
|
+
: "";
|
|
1664
|
+
const taskText = readsInstruction + taskWithOutputInstruction;
|
|
1665
|
+
const modelScopes = resolveModelScopesForAgent(ctx.modelScope, agentConfig.name, ctx.currentModel);
|
|
1666
|
+
const modelOrigin = resolveModelOrigin({
|
|
1667
|
+
fromParent: params.modelOverrideFromParent,
|
|
1668
|
+
storedOrigin: params.modelOrigin,
|
|
1669
|
+
explicitModel: params.modelOverrideFromParent ? undefined : params.modelOverride,
|
|
1670
|
+
agentModel: agentConfig.model,
|
|
1671
|
+
parentModel: ctx.currentModel,
|
|
1672
|
+
});
|
|
1673
|
+
let primaryModel: string | undefined;
|
|
1674
|
+
try {
|
|
1675
|
+
primaryModel = externalRunner ? undefined : modelOrigin === "inherited"
|
|
1676
|
+
? params.modelOverride ?? (ctx.currentModel ? `${ctx.currentModel.provider}/${ctx.currentModel.id}` : undefined)
|
|
1677
|
+
: resolveSubagentModelOverride(
|
|
1678
|
+
params.modelOverride ?? agentConfig.model,
|
|
1679
|
+
ctx.currentModel,
|
|
1680
|
+
availableModels,
|
|
1681
|
+
ctx.currentModelProvider,
|
|
1682
|
+
{ scope: modelScopes, source: modelOrigin === "explicit" ? "explicit" : "inherited" },
|
|
1683
|
+
);
|
|
1684
|
+
} catch (error) {
|
|
1685
|
+
return formatAsyncStartError("single", error instanceof Error ? error.message : String(error));
|
|
1686
|
+
}
|
|
1687
|
+
const effectiveThinking = externalRunner ? undefined : params.thinkingOverride ?? agentConfig.thinking;
|
|
1688
|
+
const model = externalRunner ? undefined : applyThinkingSuffix(primaryModel, effectiveThinking, params.thinkingOverride !== undefined);
|
|
1689
|
+
const contextLimit = model ? findModelInfo(model, availableModels, agentConfig.modelProvider ?? ctx.currentModelProvider)?.contextWindow : undefined;
|
|
1690
|
+
const thinkingCeiling = externalRunner ? undefined : intersectThinkingCeilings(
|
|
1691
|
+
params.thinkingCeiling,
|
|
1692
|
+
agentConfig.maxThinking,
|
|
1693
|
+
decodeThinkingCeiling(process.env[SUBAGENT_THINKING_CEILING_ENV]),
|
|
1694
|
+
);
|
|
1695
|
+
if (!externalRunner) {
|
|
1696
|
+
try {
|
|
1697
|
+
assertThinkingWithinCeiling({ model, configThinking: effectiveThinking, ceiling: thinkingCeiling, agent: agentConfig.name, runId: id });
|
|
1698
|
+
} catch (error) {
|
|
1699
|
+
return formatAsyncStartError("single", error instanceof Error ? error.message : String(error));
|
|
1700
|
+
}
|
|
1701
|
+
}
|
|
1702
|
+
const toolBudgetInput = params.toolBudget ?? agentConfig.toolBudget ?? params.configToolBudget;
|
|
1703
|
+
const resolvedToolBudget = validateToolBudgetConfig(toolBudgetInput, params.toolBudget ? "toolBudget" : agentConfig.toolBudget ? "agent.toolBudget" : "config.toolBudget");
|
|
1704
|
+
if (resolvedToolBudget.error) return formatAsyncStartError("single", resolvedToolBudget.error);
|
|
1705
|
+
const deadlineAt = params.absoluteDeadlineAt ?? (params.timeoutMs !== undefined ? Date.now() + params.timeoutMs : undefined);
|
|
1706
|
+
const timeoutMs = params.absoluteDeadlineAt !== undefined && deadlineAt !== undefined
|
|
1707
|
+
? deadlineAt - Date.now()
|
|
1708
|
+
: params.timeoutMs;
|
|
1709
|
+
if (timeoutMs !== undefined && timeoutMs <= 0) return formatAsyncStartError("single", "The source run's absolute deadline expired before recovery could launch.");
|
|
1710
|
+
const resolvedToolTimeout = resolveToolTimeoutMs({
|
|
1711
|
+
callValue: params.toolTimeoutMs,
|
|
1712
|
+
agentValue: agentConfig.defaultToolTimeoutMs,
|
|
1713
|
+
configValue: params.configToolTimeoutMs,
|
|
1714
|
+
envValue: params.toolTimeoutMsEnv ?? toolTimeoutFromEnv(),
|
|
1715
|
+
});
|
|
1716
|
+
if (resolvedToolTimeout.error) return formatAsyncStartError("single", resolvedToolTimeout.error);
|
|
1717
|
+
const toolTimeoutMs = resolvedToolTimeout.toolTimeoutMs;
|
|
1718
|
+
const initialUsageBudget = usageBudgetState(params.usageBudget, undefined);
|
|
1719
|
+
const resolvedSessionDir = params.sessionDir ?? (sessionRoot ? path.join(sessionRoot, `async-${id}`) : undefined);
|
|
1720
|
+
const structuredOutput = params.structuredOutputSchema
|
|
1721
|
+
? createStructuredOutputRuntime(params.structuredOutputSchema, path.join(asyncDir, "structured-output"), { acceptanceReport: resolveAcceptanceReportMode(params.acceptance) })
|
|
1722
|
+
: undefined;
|
|
1723
|
+
let modelCandidates: string[] = [];
|
|
1724
|
+
if (!externalRunner) {
|
|
1725
|
+
try {
|
|
1726
|
+
modelCandidates = buildModelCandidates(primaryModel, agentConfig.fallbackModels, availableModels, agentConfig.modelProvider ?? ctx.currentModelProvider, {
|
|
1727
|
+
scope: modelScopes,
|
|
1728
|
+
primaryModelFromParent: modelOrigin === "inherited",
|
|
1729
|
+
origin: modelOrigin,
|
|
1730
|
+
}).flatMap((candidate) => {
|
|
1731
|
+
const resolved = applyThinkingSuffix(candidate, effectiveThinking, params.thinkingOverride !== undefined);
|
|
1732
|
+
return resolved ? [resolved] : [];
|
|
1733
|
+
});
|
|
1734
|
+
for (const candidate of modelCandidates) assertThinkingWithinCeiling({ model: candidate, configThinking: effectiveThinking, ceiling: thinkingCeiling, agent: agentConfig.name, runId: id });
|
|
1735
|
+
} catch (error) {
|
|
1736
|
+
return formatAsyncStartError("single", error instanceof Error ? error.message : String(error));
|
|
1737
|
+
}
|
|
1738
|
+
}
|
|
1739
|
+
const toolPlan = resolvePiLaunchToolPlan({
|
|
1740
|
+
tools: agentConfig.tools,
|
|
1741
|
+
excludeTools: agentConfig.excludeTools,
|
|
1742
|
+
allowNestedSubagents: agentConfig.allowNestedSubagents,
|
|
1743
|
+
extensions: agentConfig.extensions,
|
|
1744
|
+
subagentOnlyExtensions: agentConfig.subagentOnlyExtensions,
|
|
1745
|
+
mcpDirectTools: agentConfig.mcpDirectTools,
|
|
1746
|
+
cwd: runnerCwd,
|
|
1747
|
+
requireReadTool: Boolean(resolvedSkills.length),
|
|
1748
|
+
structuredOutput: Boolean(params.structuredOutputSchema),
|
|
1749
|
+
fast: params.fast ?? agentConfig.fast,
|
|
1750
|
+
model,
|
|
1751
|
+
modelCandidates,
|
|
1752
|
+
capabilityCeiling,
|
|
1753
|
+
inheritedCapabilityCeiling: decodeSubagentCapabilityCeiling(process.env[SUBAGENT_CAPABILITY_CEILING_ENV]),
|
|
1754
|
+
agentName: agentConfig.name,
|
|
1755
|
+
permissionRules: resolvePermissionRules(ctx.permissions, agentConfig.permissions),
|
|
1756
|
+
runtimeSnapshotHost: ctx.pi,
|
|
1757
|
+
});
|
|
1758
|
+
const launchResolvedExtensions = externalRunner ? undefined : projectLaunchResolvedChildExtensions(toolPlan);
|
|
1759
|
+
if (!externalRunner) {
|
|
1760
|
+
const contractTools = toolPlan.explicitToolAllowlist ? toolPlan.effectiveToolAllowlist : undefined;
|
|
1761
|
+
const contractError = validateImplementationToolContract({
|
|
1762
|
+
agent: agentConfig.name,
|
|
1763
|
+
task: taskText,
|
|
1764
|
+
tools: contractTools,
|
|
1765
|
+
mcpDirectTools: toolPlan.effectiveMcpTools,
|
|
1766
|
+
configuredExtensions: toolPlan.configuredExtensions,
|
|
1767
|
+
requestedTools: toolPlan.requestedBuiltinTools,
|
|
1768
|
+
acceptanceRole: agentConfig.acceptanceRole,
|
|
1769
|
+
completionGuard: agentConfig.completionGuard,
|
|
1770
|
+
});
|
|
1771
|
+
if (contractError) return formatAsyncStartError("single", contractError);
|
|
1772
|
+
}
|
|
1773
|
+
const launchContractDigest = launchBindingDigest({
|
|
1774
|
+
definitionDigest: agentDefinitionDigest(agentConfig),
|
|
1775
|
+
task,
|
|
1776
|
+
...(model ? { model } : {}),
|
|
1777
|
+
modelCandidates,
|
|
1778
|
+
...((params.fast ?? agentConfig.fast) !== undefined ? { fast: params.fast ?? agentConfig.fast } : {}),
|
|
1779
|
+
...(resolveEffectiveThinking(model, effectiveThinking) ? { thinking: resolveEffectiveThinking(model, effectiveThinking) } : {}),
|
|
1780
|
+
...(thinkingCeiling ? { thinkingCeiling } : {}),
|
|
1781
|
+
systemPrompt,
|
|
1782
|
+
systemPromptMode: agentConfig.systemPromptMode,
|
|
1783
|
+
inheritProjectContext: agentConfig.inheritProjectContext,
|
|
1784
|
+
inheritGlobalContext: agentConfig.inheritGlobalContext,
|
|
1785
|
+
inheritSkills: agentConfig.inheritSkills,
|
|
1786
|
+
skills: resolvedSkills.map((skill) => skill.name),
|
|
1787
|
+
tools: toolPlan.effectiveToolAllowlist,
|
|
1788
|
+
...(toolPlan.excludeTools.length > 0 ? { excludeTools: toolPlan.excludeTools } : {}),
|
|
1789
|
+
extensions: toolPlan.extensionArgs,
|
|
1790
|
+
mcpDirectTools: toolPlan.effectiveMcpTools,
|
|
1791
|
+
...(outputPath ? { outputPath } : {}),
|
|
1792
|
+
outputMode,
|
|
1793
|
+
...(params.structuredOutputSchema ? { structuredOutputSchema: params.structuredOutputSchema } : {}),
|
|
1794
|
+
...(extensionBindings ? { extensionBindings } : {}),
|
|
1795
|
+
});
|
|
1796
|
+
const resolvedAcceptance = resolveEffectiveAcceptance({
|
|
1797
|
+
explicit: params.acceptance,
|
|
1798
|
+
agentName: agent,
|
|
1799
|
+
acceptanceRole: agentConfig.acceptanceRole,
|
|
1800
|
+
task,
|
|
1801
|
+
mode: "single",
|
|
1802
|
+
async: true,
|
|
1803
|
+
agentContract: params.agentContract,
|
|
1804
|
+
});
|
|
1805
|
+
const recoveryAgentConfig = params.recoveryAgentConfig ?? agentConfig;
|
|
1806
|
+
const recoveryDescriptor: SteeringRecoveryDescriptor = {
|
|
1807
|
+
version: 1,
|
|
1808
|
+
...(lane ? { lane } : {}),
|
|
1809
|
+
launchContractDigest,
|
|
1810
|
+
...(extensionBindings ? { extensionBindings } : {}),
|
|
1811
|
+
runFanoutBudget,
|
|
1812
|
+
sourceRunId: id,
|
|
1813
|
+
...(params.agentContract ? { agentContract: params.agentContract } : {}),
|
|
1814
|
+
agent,
|
|
1815
|
+
launchResolvedExtensions,
|
|
1816
|
+
...(sessionFile ? { sessionFile } : {}),
|
|
1817
|
+
cwd: runnerCwd,
|
|
1818
|
+
...(model ? { model } : {}),
|
|
1819
|
+
...(params.fast ?? recoveryAgentConfig.fast ? { fast: params.fast ?? recoveryAgentConfig.fast } : {}),
|
|
1820
|
+
...(recoveryAgentConfig.modelProvider ? { modelProvider: recoveryAgentConfig.modelProvider } : {}),
|
|
1821
|
+
...(modelOrigin === "inherited" ? { modelOverrideFromParent: true } : {}),
|
|
1822
|
+
modelOrigin,
|
|
1823
|
+
...(recoveryAgentConfig.fallbackModels ? { fallbackModels: [...recoveryAgentConfig.fallbackModels] } : {}),
|
|
1824
|
+
...(effectiveThinking ? { thinking: resolveEffectiveThinking(model, effectiveThinking) } : {}),
|
|
1825
|
+
...(thinkingCeiling ? { thinkingCeiling } : {}),
|
|
1826
|
+
...(recoveryAgentConfig.tools ? { tools: [...recoveryAgentConfig.tools] } : {}),
|
|
1827
|
+
...(recoveryAgentConfig.excludeTools ? { excludeTools: [...recoveryAgentConfig.excludeTools] } : {}),
|
|
1828
|
+
...(recoveryAgentConfig.allowNestedSubagents !== undefined ? { allowNestedSubagents: recoveryAgentConfig.allowNestedSubagents } : {}),
|
|
1829
|
+
...(recoveryAgentConfig.extensions ? { extensions: [...recoveryAgentConfig.extensions] } : {}),
|
|
1830
|
+
...(recoveryAgentConfig.subagentOnlyExtensions ? { subagentOnlyExtensions: [...recoveryAgentConfig.subagentOnlyExtensions] } : {}),
|
|
1831
|
+
...(recoveryAgentConfig.mcpDirectTools ? { mcpDirectTools: [...recoveryAgentConfig.mcpDirectTools] } : {}),
|
|
1832
|
+
...(recoveryAgentConfig.mutationTools ? { mutationTools: [...recoveryAgentConfig.mutationTools] } : {}),
|
|
1833
|
+
...(recoveryAgentConfig.systemPrompt ? { systemPrompt: recoveryAgentConfig.systemPrompt } : {}),
|
|
1834
|
+
systemPromptMode: recoveryAgentConfig.systemPromptMode,
|
|
1835
|
+
inheritProjectContext: recoveryAgentConfig.inheritProjectContext,
|
|
1836
|
+
inheritGlobalContext: recoveryAgentConfig.inheritGlobalContext,
|
|
1837
|
+
inheritSkills: recoveryAgentConfig.inheritSkills,
|
|
1838
|
+
...(resolvedSkills.length ? { skills: resolvedSkills.map((skill) => skill.name) } : {}),
|
|
1839
|
+
...(recoveryAgentConfig.skillPath ? { skillPath: [...recoveryAgentConfig.skillPath] } : {}),
|
|
1840
|
+
...(recoveryAgentConfig.filePath ? { agentFilePath: recoveryAgentConfig.filePath } : {}),
|
|
1841
|
+
...(recoveryAgentConfig.completionGuard !== undefined ? { completionGuard: recoveryAgentConfig.completionGuard } : {}),
|
|
1842
|
+
...(recoveryAgentConfig.memory ? { memory: { ...recoveryAgentConfig.memory } } : {}),
|
|
1843
|
+
...(outputPath ? { outputPath } : {}),
|
|
1844
|
+
outputMode,
|
|
1845
|
+
...(params.structuredOutputSchema ? { structuredOutputSchema: params.structuredOutputSchema } : {}),
|
|
1846
|
+
...(params.acceptance !== undefined ? { acceptance: params.acceptance } : {}),
|
|
1847
|
+
...(controlConfig ? { controlConfig } : {}),
|
|
1848
|
+
...(params.context ? { context: params.context } : {}),
|
|
1849
|
+
...(params.intercomBridge !== undefined ? { intercomBridge: params.intercomBridge } : {}),
|
|
1850
|
+
...(deadlineAt !== undefined ? { absoluteDeadlineAt: deadlineAt } : {}),
|
|
1851
|
+
...(resolvedToolBudget.budget ? { initialToolBudget: resolvedToolBudget.budget } : {}),
|
|
1852
|
+
maxSubagentDepth: resolveChildMaxSubagentDepth(maxSubagentDepth, recoveryAgentConfig.maxSubagentDepth),
|
|
1853
|
+
...(maxOutput ? { maxOutput } : {}),
|
|
1854
|
+
share: shareEnabled,
|
|
1855
|
+
...(resolvedSessionDir ? { sessionDir: resolvedSessionDir } : {}),
|
|
1856
|
+
...(artifactsDir ? { artifactsDir } : {}),
|
|
1857
|
+
artifactConfig,
|
|
1858
|
+
...(capabilityCeiling ? { capabilityCeiling } : {}),
|
|
1859
|
+
};
|
|
1860
|
+
if (!externalRunner) {
|
|
1861
|
+
try {
|
|
1862
|
+
writePrivateAtomicJson(path.join(asyncDir, "recovery-descriptor.json"), recoveryDescriptor);
|
|
1863
|
+
} catch (error) {
|
|
1864
|
+
return formatAsyncStartError("single", `Failed to persist async recovery descriptor for '${id}': ${error instanceof Error ? error.message : String(error)}`);
|
|
1865
|
+
}
|
|
1866
|
+
}
|
|
1867
|
+
let spawnResult: SpawnRunnerResult = {};
|
|
1868
|
+
const initialStatusAt = Date.now();
|
|
1869
|
+
const initialCompletionOwnerId = ctx.completionOwnerId ?? currentCompletionOwnerId();
|
|
1870
|
+
try {
|
|
1871
|
+
spawnResult = spawnRunner(
|
|
1872
|
+
{
|
|
1873
|
+
id,
|
|
1874
|
+
steps: [
|
|
1875
|
+
{
|
|
1876
|
+
parentSessionId: ctx.parentSessionId ?? ctx.currentSessionId,
|
|
1877
|
+
permissionRules,
|
|
1878
|
+
...(capabilityCeiling ? { capabilityCeiling } : {}),
|
|
1879
|
+
agent,
|
|
1880
|
+
task: taskText,
|
|
1881
|
+
...(agentConfig.runner ? { runner: agentConfig.runner } : {}),
|
|
1882
|
+
...(params.externalJobFollowUp ? { externalJobFollowUp: params.externalJobFollowUp } : {}),
|
|
1883
|
+
...(params.context ? { context: params.context } : {}),
|
|
1884
|
+
cwd: runnerCwd,
|
|
1885
|
+
requestedCwd: params.requestedCwd ?? runnerCwd,
|
|
1886
|
+
model,
|
|
1887
|
+
...(contextLimit !== undefined ? { contextLimit } : {}),
|
|
1888
|
+
...(params.fast ?? agentConfig.fast ? { fast: params.fast ?? agentConfig.fast } : {}),
|
|
1889
|
+
thinking: resolveEffectiveThinking(model, effectiveThinking),
|
|
1890
|
+
...(thinkingCeiling ? { thinkingCeiling } : {}),
|
|
1891
|
+
modelCandidates,
|
|
1892
|
+
...(modelOrigin === "inherited" ? { skipPrimaryModelVerification: true } : {}),
|
|
1893
|
+
...(availableModels && availableModels.length > 0 ? { modelVerificationRegistry: availableModels } : {}),
|
|
1894
|
+
tools: agentConfig.tools,
|
|
1895
|
+
excludeTools: agentConfig.excludeTools,
|
|
1896
|
+
allowNestedSubagents: agentConfig.allowNestedSubagents,
|
|
1897
|
+
extensions: agentConfig.extensions,
|
|
1898
|
+
subagentOnlyExtensions: agentConfig.subagentOnlyExtensions,
|
|
1899
|
+
mcpDirectTools: agentConfig.mcpDirectTools,
|
|
1900
|
+
...(toolPlan.mcpConfig ? { mcpConfig: toolPlan.mcpConfig } : {}),
|
|
1901
|
+
...(toolPlan.runtimeServerNames ? { runtimeServerNames: toolPlan.runtimeServerNames } : {}),
|
|
1902
|
+
mutationTools: agentConfig.mutationTools,
|
|
1903
|
+
completionGuard: agentConfig.completionGuard,
|
|
1904
|
+
systemPrompt,
|
|
1905
|
+
systemPromptMode: agentConfig.systemPromptMode,
|
|
1906
|
+
inheritProjectContext: agentConfig.inheritProjectContext,
|
|
1907
|
+
inheritGlobalContext: agentConfig.inheritGlobalContext,
|
|
1908
|
+
inheritSkills: agentConfig.inheritSkills,
|
|
1909
|
+
skills: resolvedSkills.map((r) => r.name),
|
|
1910
|
+
outputPath,
|
|
1911
|
+
...(params.outputClaimPath ? { outputClaimPath: params.outputClaimPath } : {}),
|
|
1912
|
+
outputMode,
|
|
1913
|
+
...(!externalRunner && sessionFile ? { sessionFile } : {}),
|
|
1914
|
+
maxSubagentDepth: resolveChildMaxSubagentDepth(maxSubagentDepth, agentConfig.maxSubagentDepth),
|
|
1915
|
+
waitToolEnabled: params.waitToolEnabled,
|
|
1916
|
+
waitToolDefaultTimeoutMs: params.waitToolDefaultTimeoutMs,
|
|
1917
|
+
...(params.agentContract ? { agentContract: params.agentContract } : {}),
|
|
1918
|
+
definitionDigest: agentDefinitionDigest(agentConfig),
|
|
1919
|
+
launchBindingTask: task,
|
|
1920
|
+
launchContractDigest,
|
|
1921
|
+
...(extensionBindings ? { extensionBindings } : {}),
|
|
1922
|
+
launchResolvedExtensions,
|
|
1923
|
+
effectiveAcceptance: resolvedAcceptance,
|
|
1924
|
+
acceptanceInput: params.acceptance,
|
|
1925
|
+
...(structuredOutput ? { structuredOutput } : {}),
|
|
1926
|
+
...(params.structuredOutputSchema ? { structuredOutputSchema: params.structuredOutputSchema } : {}),
|
|
1927
|
+
...(resolvedToolBudget.budget ? { toolBudget: resolvedToolBudget.budget } : {}),
|
|
1928
|
+
...(params.worktree === true ? { worktree: true } : {}),
|
|
1929
|
+
...(lane ? { lane } : {}),
|
|
1930
|
+
},
|
|
1931
|
+
],
|
|
1932
|
+
resultPath: params.parentWorkflowRunId !== undefined && (params.revivalLease !== undefined || params.workflowAwaitAsync === true)
|
|
1933
|
+
? workflowAwaitedAsyncResultPath(asyncDir)
|
|
1934
|
+
: inheritedNestedRoute ? nestedResultsPath(inheritedNestedRoute.rootRunId, id) : resultFilePath(DIRS.results, id),
|
|
1935
|
+
cwd: runnerCwd,
|
|
1936
|
+
placeholder: "{previous}",
|
|
1937
|
+
maxOutput,
|
|
1938
|
+
artifactsDir: artifactConfig.enabled ? artifactsDir : undefined,
|
|
1939
|
+
artifactConfig,
|
|
1940
|
+
share: shareEnabled,
|
|
1941
|
+
sessionDir: resolvedSessionDir,
|
|
1942
|
+
asyncDir,
|
|
1943
|
+
sessionId: ctx.currentSessionId,
|
|
1944
|
+
completionOwnerId: ctx.completionOwnerId ?? currentCompletionOwnerId(),
|
|
1945
|
+
...(capabilityCeiling ? { capabilityCeiling } : {}),
|
|
1946
|
+
piPackageRoot,
|
|
1947
|
+
piArgv1: process.argv[1],
|
|
1948
|
+
worktreeSetupHook,
|
|
1949
|
+
worktreeSetupHookTimeoutMs,
|
|
1950
|
+
worktreeBaseDir,
|
|
1951
|
+
worktreeProvider,
|
|
1952
|
+
worktreeBranchPrefix,
|
|
1953
|
+
controlConfig,
|
|
1954
|
+
timeoutMs,
|
|
1955
|
+
deadlineAt,
|
|
1956
|
+
toolTimeoutMs,
|
|
1957
|
+
toolBudget: params.toolBudget,
|
|
1958
|
+
usageBudget: params.usageBudget,
|
|
1959
|
+
controlIntercomTarget,
|
|
1960
|
+
childIntercomTargets: childIntercomTarget ? [childIntercomTarget(agent, 0)] : undefined,
|
|
1961
|
+
resultMode: "single",
|
|
1962
|
+
launchContractDigest,
|
|
1963
|
+
launchResolvedExtensions,
|
|
1964
|
+
runFanoutBudget,
|
|
1965
|
+
...(params.parentWorkflowRunId ? { parentWorkflowRunId: params.parentWorkflowRunId } : {}),
|
|
1966
|
+
...(params.workflowKey ? { workflowKey: params.workflowKey } : {}),
|
|
1967
|
+
...(lane ? { lane } : {}),
|
|
1968
|
+
...(params.revivalLease ? { revivalLease: params.revivalLease } : {}),
|
|
1969
|
+
nestedRoute: nestedRoute ?? inheritedNestedRoute,
|
|
1970
|
+
nestedSelf: inheritedNestedRoute && nestedAddress ? {
|
|
1971
|
+
parentRunId: nestedAddress.parentRunId,
|
|
1972
|
+
parentStepIndex: nestedAddress.parentStepIndex,
|
|
1973
|
+
depth: nestedAddress.depth,
|
|
1974
|
+
path: nestedAddress.path,
|
|
1975
|
+
} : undefined,
|
|
1976
|
+
},
|
|
1977
|
+
id,
|
|
1978
|
+
runnerCwd,
|
|
1979
|
+
{
|
|
1980
|
+
lifecycleArtifactVersion: SUBAGENT_LIFECYCLE_ARTIFACT_VERSION,
|
|
1981
|
+
runId: id,
|
|
1982
|
+
...(ctx.currentSessionId ? { sessionId: ctx.currentSessionId } : {}),
|
|
1983
|
+
...(initialCompletionOwnerId ? { completionOwnerId: initialCompletionOwnerId } : {}),
|
|
1984
|
+
mode: "single",
|
|
1985
|
+
state: "running",
|
|
1986
|
+
startedAt: initialStatusAt,
|
|
1987
|
+
lastUpdate: initialStatusAt,
|
|
1988
|
+
currentStep: 0,
|
|
1989
|
+
chainStepCount: 1,
|
|
1990
|
+
...(lane ? { lane } : {}),
|
|
1991
|
+
steps: [{ agent, status: "pending", ...(lane ? { lane } : {}), ...(model ? { model } : {}), ...(contextLimit !== undefined ? { contextLimit } : {}) }],
|
|
1992
|
+
},
|
|
1993
|
+
path.join(asyncDir, "status.json"),
|
|
1994
|
+
(proof) => emitProcessTerminalEvent(ctx, proof),
|
|
1995
|
+
(runnerProcessInstanceId) => params.activeAsyncCapacity?.markStarted(runnerProcessInstanceId),
|
|
1996
|
+
params.requestedCwd ?? runnerCwd,
|
|
1997
|
+
);
|
|
1998
|
+
} catch (error) {
|
|
1999
|
+
params.activeAsyncCapacity?.rollback();
|
|
2000
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
2001
|
+
return formatAsyncStartError("single", `Failed to start async run '${id}': ${message}`);
|
|
2002
|
+
}
|
|
2003
|
+
|
|
2004
|
+
if (spawnResult.error) {
|
|
2005
|
+
if (spawnResult.startupDidNotProceed) {
|
|
2006
|
+
if (!spawnResult.runnerProcessInstanceId || params.activeAsyncCapacity?.rollbackBeforeRunnerProceed(spawnResult.runnerProcessInstanceId) !== true) params.activeAsyncCapacity?.rollback();
|
|
2007
|
+
}
|
|
2008
|
+
else if (!spawnResult.pid || !spawnResult.runnerProcessInstanceId) params.activeAsyncCapacity?.rollback();
|
|
2009
|
+
else params.activeAsyncCapacity?.markStarted(spawnResult.runnerProcessInstanceId);
|
|
2010
|
+
return formatAsyncStartError("single", `Failed to start async run '${id}': ${spawnResult.error}`);
|
|
2011
|
+
}
|
|
2012
|
+
if (!spawnResult.pid || !spawnResult.runnerProcessInstanceId) {
|
|
2013
|
+
params.activeAsyncCapacity?.rollback();
|
|
2014
|
+
return formatAsyncStartError("single", `Failed to start async run '${id}': runner identity unavailable`);
|
|
2015
|
+
}
|
|
2016
|
+
if (spawnResult.pid) {
|
|
2017
|
+
if (inheritedNestedRoute && nestedAddress) {
|
|
2018
|
+
const now = Date.now();
|
|
2019
|
+
try {
|
|
2020
|
+
writeNestedEvent(inheritedNestedRoute, {
|
|
2021
|
+
type: "subagent.nested.started",
|
|
2022
|
+
ts: now,
|
|
2023
|
+
parentRunId: nestedAddress.parentRunId,
|
|
2024
|
+
parentStepIndex: nestedAddress.parentStepIndex,
|
|
2025
|
+
child: {
|
|
2026
|
+
id,
|
|
2027
|
+
parentRunId: nestedAddress.parentRunId,
|
|
2028
|
+
parentStepIndex: nestedAddress.parentStepIndex,
|
|
2029
|
+
depth: nestedAddress.depth,
|
|
2030
|
+
path: nestedAddress.path,
|
|
2031
|
+
asyncDir,
|
|
2032
|
+
pid: spawnResult.pid,
|
|
2033
|
+
ownerIntercomTarget: process.env.SELESAI_SUBAGENT_INTERCOM_SESSION_NAME,
|
|
2034
|
+
leafIntercomTarget: childIntercomTarget?.(agent, 0),
|
|
2035
|
+
intercomTarget: childIntercomTarget?.(agent, 0),
|
|
2036
|
+
ownerState: "live",
|
|
2037
|
+
mode: "single",
|
|
2038
|
+
state: "running",
|
|
2039
|
+
agent,
|
|
2040
|
+
agents: [agent],
|
|
2041
|
+
chainStepCount: 1,
|
|
2042
|
+
...(timeoutMs !== undefined ? { timeoutMs, deadlineAt } : {}),
|
|
2043
|
+
startedAt: now,
|
|
2044
|
+
lastUpdate: now,
|
|
2045
|
+
...(capabilityCeiling ? { capabilityCeiling } : {}),
|
|
2046
|
+
},
|
|
2047
|
+
});
|
|
2048
|
+
} catch (error) {
|
|
2049
|
+
console.error("Failed to emit nested async start event:", error);
|
|
2050
|
+
}
|
|
2051
|
+
}
|
|
2052
|
+
ctx.pi.events.emit(SUBAGENT_ASYNC_STARTED_EVENT, {
|
|
2053
|
+
lifecycleArtifactVersion: SUBAGENT_LIFECYCLE_ARTIFACT_VERSION,
|
|
2054
|
+
id,
|
|
2055
|
+
pid: spawnResult.pid,
|
|
2056
|
+
sessionId: ctx.currentSessionId,
|
|
2057
|
+
completionOwnerId: ctx.completionOwnerId ?? currentCompletionOwnerId(),
|
|
2058
|
+
mode: "single",
|
|
2059
|
+
agent,
|
|
2060
|
+
task: task?.trim() ? PROMPT_REDACTED : undefined,
|
|
2061
|
+
goal: (params.goal ?? task).trim() ? PROMPT_REDACTED : undefined,
|
|
2062
|
+
cwd: runnerCwd,
|
|
2063
|
+
asyncDir,
|
|
2064
|
+
...(sessionRoot ? { sessionRoot } : {}),
|
|
2065
|
+
launchContractDigest,
|
|
2066
|
+
launchResolvedExtensions,
|
|
2067
|
+
...(params.parentWorkflowRunId ? { parentWorkflowRunId: params.parentWorkflowRunId } : {}),
|
|
2068
|
+
...(params.workflowKey ? { workflowKey: params.workflowKey } : {}),
|
|
2069
|
+
...(timeoutMs !== undefined ? { timeoutMs, deadlineAt } : {}),
|
|
2070
|
+
...(initialUsageBudget ? { usageBudget: initialUsageBudget } : {}),
|
|
2071
|
+
...(capabilityCeiling ? { capabilityCeiling } : {}),
|
|
2072
|
+
nestedRoute,
|
|
2073
|
+
});
|
|
2074
|
+
}
|
|
2075
|
+
|
|
2076
|
+
return {
|
|
2077
|
+
content: [{ type: "text", text: formatAsyncStartedMessage(`Async: ${agent} [${id}]`, ctx.interactive === true) }],
|
|
2078
|
+
details: { mode: "single", runId: id, results: [], asyncId: id, asyncDir, launchContractDigest, launchResolvedExtensions, ...(capabilityCeiling ? { capabilityCeiling } : {}), ...(params.context ? { context: params.context } : {}), ...(timeoutMs !== undefined ? { timeoutMs, deadlineAt } : {}), ...(params.toolBudget ? { toolBudget: resolvedToolBudget.budget ?? params.toolBudget } : {}), ...(initialUsageBudget ? { usageBudget: initialUsageBudget } : {}) } as Details,
|
|
2079
|
+
};
|
|
2080
|
+
}
|