@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,2443 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core execution logic for running subagents
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { spawn } from "node:child_process";
|
|
6
|
+
import { existsSync } from "node:fs";
|
|
7
|
+
import * as path from "node:path";
|
|
8
|
+
import type { Message } from "@earendil-works/pi-ai";
|
|
9
|
+
import { discoverAgents, formatUnknownAgentError, unknownAgentDiagnosticContext, type AgentConfig } from "../../agents/agents.ts";
|
|
10
|
+
import { appendAgentRefinementOverlay } from "../../agents/agent-refinements.ts";
|
|
11
|
+
import { alignForkedSessionCwd } from "../../shared/fork-session-cwd.ts";
|
|
12
|
+
import {
|
|
13
|
+
ensureArtifactsDir,
|
|
14
|
+
formatOutputArtifactContent,
|
|
15
|
+
getArtifactPaths,
|
|
16
|
+
writeArtifact,
|
|
17
|
+
writeMetadata,
|
|
18
|
+
} from "../../shared/artifacts.ts";
|
|
19
|
+
import { createChildTranscriptWriter, type ChildTranscriptWriter } from "../../shared/child-transcript.ts";
|
|
20
|
+
import {
|
|
21
|
+
type AgentProgress,
|
|
22
|
+
type ArtifactPaths,
|
|
23
|
+
type ControlEvent,
|
|
24
|
+
type ModelAttempt,
|
|
25
|
+
type RunSyncOptions,
|
|
26
|
+
type SingleResult,
|
|
27
|
+
type Usage,
|
|
28
|
+
DEFAULT_MAX_OUTPUT,
|
|
29
|
+
INTERCOM_DETACH_REQUEST_EVENT,
|
|
30
|
+
INTERCOM_DETACH_RESPONSE_EVENT,
|
|
31
|
+
type AcceptanceLedger,
|
|
32
|
+
type ResolvedAcceptanceConfig,
|
|
33
|
+
truncateOutput,
|
|
34
|
+
getSubagentDepthEnv,
|
|
35
|
+
} from "../../shared/types.ts";
|
|
36
|
+
import {
|
|
37
|
+
DEFAULT_CONTROL_CONFIG,
|
|
38
|
+
buildControlEvent,
|
|
39
|
+
claimControlNotification,
|
|
40
|
+
deriveActivityState,
|
|
41
|
+
shouldEmitOpenToolAttention,
|
|
42
|
+
shouldNotifyControlEvent,
|
|
43
|
+
} from "../shared/subagent-control.ts";
|
|
44
|
+
import {
|
|
45
|
+
getFinalOutput,
|
|
46
|
+
findLatestSessionFile,
|
|
47
|
+
detectSubagentError,
|
|
48
|
+
hasEmptyTerminalAssistantResponse,
|
|
49
|
+
formatEmptyTerminalAssistantResponseError,
|
|
50
|
+
extractToolArgsPreview,
|
|
51
|
+
extractTextFromContent,
|
|
52
|
+
MAX_STREAMED_RECENT_TOOLS,
|
|
53
|
+
boundStreamedRecentTools,
|
|
54
|
+
boundStreamedRecentOutput,
|
|
55
|
+
boundStreamedToolCalls,
|
|
56
|
+
} from "../../shared/utils.ts";
|
|
57
|
+
import { buildSkillInjection, resolveSkillsWithFallback } from "../../agents/skills.ts";
|
|
58
|
+
import { buildAgentMemoryInjection } from "../../agents/agent-memory.ts";
|
|
59
|
+
import { effectiveToolTimeoutMs, formatToolTimeoutMessage, resolveToolTimeoutMs, toolTimeoutCallKey, toolTimeoutFromEnv } from "../shared/tool-timeout.ts";
|
|
60
|
+
import { evaluateCompletionMutationGuard, expectsImplementationMutation, hasMutationToolCapability, validateImplementationToolContract } from "../shared/completion-guard.ts";
|
|
61
|
+
import { planCompletionEvidence } from "../shared/completion-evidence.ts";
|
|
62
|
+
import { planAbortRecovery } from "../shared/abort-recovery.ts";
|
|
63
|
+
import { arbitrateCompletionGuardRescue } from "../shared/llm-intent-arbiter.ts";
|
|
64
|
+
import { getPiSpawnCommand } from "../shared/pi-spawn.ts";
|
|
65
|
+
import { preflightLaunchCwd } from "../shared/launch-cwd.ts";
|
|
66
|
+
import { createJsonlWriter } from "../../shared/jsonl-writer.ts";
|
|
67
|
+
import { createOrcaProgressTab, type OrcaProgressTab } from "../shared/orca-progress-tabs.ts";
|
|
68
|
+
import { attachPostExitStdioGuard, trySignalChild } from "../../shared/post-exit-stdio-guard.ts";
|
|
69
|
+
import { resolvePermissionRules } from "../shared/permissions.ts";
|
|
70
|
+
import { applyThinkingSuffix, buildPiArgs, cleanupTempDir, deriveForkPromptCacheKey, projectLaunchResolvedChildExtensions, resolvePiLaunchToolPlan, type SubagentTaskDelivery } from "../shared/pi-args.ts";
|
|
71
|
+
import { deriveChildSessionName } from "../../shared/child-session-name.ts";
|
|
72
|
+
import { readRuntimeAcknowledgedExtensions } from "../shared/runtime-acknowledged-extensions.ts";
|
|
73
|
+
import { assertAgentAllowedByCapabilityCeiling, decodeSubagentCapabilityCeiling, intersectSubagentCapabilityCeilings, resolveCurrentSubagentCapabilityCeiling, SUBAGENT_CAPABILITY_CEILING_ENV } from "../shared/capability-ceiling.ts";
|
|
74
|
+
import { resolveEffectiveThinking } from "../../shared/model-info.ts";
|
|
75
|
+
import { assertThinkingWithinCeiling, decodeThinkingCeiling, intersectThinkingCeilings, SUBAGENT_THINKING_CEILING_ENV } from "../../shared/thinking-ceiling.ts";
|
|
76
|
+
import { clearStructuredOutputCaptures, MISSING_STRUCTURED_OUTPUT_CALL_ERROR, readStructuredOutput, readStructuredOutputAcceptanceReport } from "../shared/structured-output.ts";
|
|
77
|
+
import { formatMidToolExitError, formatProcessSignalError, isOrdinaryToolForMidToolExit, isUnexplainedProcessSignal } from "../shared/process-signal.ts";
|
|
78
|
+
import { readChildToolDiagnosticError } from "../shared/tool-availability.ts";
|
|
79
|
+
import { buildTimeoutRecoverySummary, collectTrackedMutationEvidence, snapshotTrackedMutations } from "../shared/mutation-evidence.ts";
|
|
80
|
+
import { captureSingleOutputSnapshot, extractChildWrittenOutput, finalizeSingleOutput, formatSavedOutputReference, hasSingleOutputChangedSinceSnapshot, injectOutputPathSystemPrompt, resolveSingleOutput, validateFileOnlyOutputMode, type SingleOutputSnapshot } from "../shared/single-output.ts";
|
|
81
|
+
import {
|
|
82
|
+
buildModelCandidates,
|
|
83
|
+
formatSubagentModelVerificationError,
|
|
84
|
+
formatModelAttemptNote,
|
|
85
|
+
isContextOverflow,
|
|
86
|
+
isRetryableModelFailureAttempt,
|
|
87
|
+
recordRetryableModelFailure,
|
|
88
|
+
} from "../shared/model-fallback.ts";
|
|
89
|
+
import {
|
|
90
|
+
SUBAGENT_STARTUP_RETRY_DELAYS_MS,
|
|
91
|
+
formatSubagentExtensionConflictError,
|
|
92
|
+
formatSubagentStartupRetryExhaustedError,
|
|
93
|
+
formatSubagentStartupRetryNote,
|
|
94
|
+
isRetryableSubagentStartupFailure,
|
|
95
|
+
waitForSubagentStartupRetry,
|
|
96
|
+
} from "../shared/subagent-startup-retry.ts";
|
|
97
|
+
import {
|
|
98
|
+
createMutatingFailureState,
|
|
99
|
+
didMutatingToolFail,
|
|
100
|
+
isMutatingTool,
|
|
101
|
+
nextLongRunningTrigger,
|
|
102
|
+
recordMutatingFailure,
|
|
103
|
+
resetMutatingFailureState,
|
|
104
|
+
resolveCurrentPath,
|
|
105
|
+
shouldEscalateMutatingFailures,
|
|
106
|
+
summarizeRecentMutatingFailures,
|
|
107
|
+
} from "../shared/long-running-guard.ts";
|
|
108
|
+
import { acceptanceFailureMessage, buildSkippedAcceptanceLedger, evaluateAcceptance, formatAcceptancePrompt, resolveEffectiveAcceptance, stripAcceptanceReport, validateAcceptanceInput } from "../shared/acceptance.ts";
|
|
109
|
+
import { PROMPT_REDACTED } from "../../shared/utils.ts";
|
|
110
|
+
import { attachContractProjections, isAgentContractV1 } from "../shared/agent-contract.ts";
|
|
111
|
+
import { initialToolBudgetState, toolBudgetState } from "../shared/tool-budget.ts";
|
|
112
|
+
import { resolveWatchdogConfig } from "../../watchdog/settings.ts";
|
|
113
|
+
import { agentDefinitionDigest, launchBindingDigest } from "../../shared/launch-contract.ts";
|
|
114
|
+
import { consumeWorkflowChildPermit } from "../../shared/workflow-child-permit.ts";
|
|
115
|
+
import { createBoundedByteTail, createBoundedLineReader, formatProtocolOutputLimit, MAX_CHILD_STDERR_BYTES, PI_AGGREGATE_EVENT_PROJECTOR, projectChildLifecycle, type ChildLifecycleAction, type ChildLifecycleState, type ProtocolOutputLimit } from "../shared/child-protocol.ts";
|
|
116
|
+
import {
|
|
117
|
+
acceptChildWatchdogEvent,
|
|
118
|
+
applyChildWatchdogMessage,
|
|
119
|
+
childWatchdogIsActive,
|
|
120
|
+
isChildWatchdogStatusEvent,
|
|
121
|
+
resolveChildWatchdogConfig,
|
|
122
|
+
type ChildWatchdogStateSnapshot,
|
|
123
|
+
} from "../../watchdog/child-status.ts";
|
|
124
|
+
|
|
125
|
+
const artifactOutputByResult = new WeakMap<SingleResult, string>();
|
|
126
|
+
const acceptanceOutputByResult = new WeakMap<SingleResult, string>();
|
|
127
|
+
|
|
128
|
+
function emptyUsage(): Usage {
|
|
129
|
+
return { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, cost: 0, turns: 0 };
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function withRunContext<T extends SingleResult>(result: T, context: RunSyncOptions["context"]): T {
|
|
133
|
+
if (!context) return result;
|
|
134
|
+
result.context = context;
|
|
135
|
+
return result;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function redactResultPrompt<T extends SingleResult>(result: T): T {
|
|
139
|
+
result.task = PROMPT_REDACTED;
|
|
140
|
+
if (result.progress) result.progress.task = PROMPT_REDACTED;
|
|
141
|
+
return result;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function sumUsage(target: Usage, source: Usage): void {
|
|
145
|
+
target.input += source.input;
|
|
146
|
+
target.output += source.output;
|
|
147
|
+
target.cacheRead += source.cacheRead;
|
|
148
|
+
target.cacheWrite += source.cacheWrite;
|
|
149
|
+
target.cost += source.cost;
|
|
150
|
+
target.turns += source.turns;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function persistSingleResultMetadata(input: {
|
|
154
|
+
metadataPath?: string;
|
|
155
|
+
enabled: boolean;
|
|
156
|
+
runId?: string;
|
|
157
|
+
agent: string;
|
|
158
|
+
task: string;
|
|
159
|
+
result: SingleResult;
|
|
160
|
+
}): void {
|
|
161
|
+
if (!input.enabled || !input.metadataPath) return;
|
|
162
|
+
const target = input.result;
|
|
163
|
+
writeMetadata(input.metadataPath, {
|
|
164
|
+
runId: input.runId,
|
|
165
|
+
agent: input.agent,
|
|
166
|
+
task: PROMPT_REDACTED,
|
|
167
|
+
exitCode: target.exitCode,
|
|
168
|
+
processSignal: target.processSignal,
|
|
169
|
+
usage: target.usage,
|
|
170
|
+
model: target.model,
|
|
171
|
+
attemptedModels: target.attemptedModels,
|
|
172
|
+
modelAttempts: target.modelAttempts,
|
|
173
|
+
durationMs: target.progressSummary?.durationMs,
|
|
174
|
+
toolCount: target.progressSummary?.toolCount,
|
|
175
|
+
error: target.error,
|
|
176
|
+
agentContract: target.agentContract,
|
|
177
|
+
launchContractDigest: target.launchContractDigest,
|
|
178
|
+
launchResolvedExtensions: target.launchResolvedExtensions,
|
|
179
|
+
runtimeAcknowledgedExtensions: target.runtimeAcknowledgedExtensions,
|
|
180
|
+
execution: target.execution,
|
|
181
|
+
acceptance: target.acceptance,
|
|
182
|
+
capabilityCeiling: target.capabilityCeiling,
|
|
183
|
+
capabilityAudit: target.capabilityAudit,
|
|
184
|
+
review: target.review,
|
|
185
|
+
effects: target.effects,
|
|
186
|
+
transcriptPath: target.transcriptPath,
|
|
187
|
+
transcriptError: target.transcriptError,
|
|
188
|
+
skills: target.skills,
|
|
189
|
+
skillsWarning: target.skillsWarning,
|
|
190
|
+
timestamp: Date.now(),
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
function formatTimeoutMessage(timeoutMs: number): string {
|
|
195
|
+
return `Subagent timed out after ${timeoutMs}ms.`;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
function resolveAttemptTimeout(options: RunSyncOptions): { timeoutMs: number; remainingMs: number; message: string } | undefined {
|
|
199
|
+
if (options.timeoutMs === undefined) return undefined;
|
|
200
|
+
const deadlineAt = options.deadlineAt ?? Date.now() + options.timeoutMs;
|
|
201
|
+
return {
|
|
202
|
+
timeoutMs: options.timeoutMs,
|
|
203
|
+
remainingMs: Math.max(0, deadlineAt - Date.now()),
|
|
204
|
+
message: formatTimeoutMessage(options.timeoutMs),
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
function buildPendingAcceptanceLedger(acceptance: ResolvedAcceptanceConfig): AcceptanceLedger {
|
|
209
|
+
return {
|
|
210
|
+
status: "pending",
|
|
211
|
+
evidenceStatus: "pending",
|
|
212
|
+
explicit: acceptance.explicit,
|
|
213
|
+
effectiveAcceptance: acceptance,
|
|
214
|
+
inferredReason: acceptance.inferredReason,
|
|
215
|
+
criteria: acceptance.criteria,
|
|
216
|
+
runtimeChecks: [],
|
|
217
|
+
verifyRuns: [],
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
function buildInterruptedAcceptanceLedger(acceptance: ResolvedAcceptanceConfig): AcceptanceLedger {
|
|
222
|
+
const pending = buildPendingAcceptanceLedger(acceptance);
|
|
223
|
+
if (acceptance.level === "none") {
|
|
224
|
+
pending.status = "not-required";
|
|
225
|
+
pending.evidenceStatus = "not-required";
|
|
226
|
+
} else {
|
|
227
|
+
pending.runtimeChecks = [{
|
|
228
|
+
id: "interrupted",
|
|
229
|
+
status: "not-applicable",
|
|
230
|
+
message: "Acceptance was not evaluated because the subagent was interrupted.",
|
|
231
|
+
}];
|
|
232
|
+
}
|
|
233
|
+
return pending;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
function appendRecentOutput(progress: AgentProgress, lines: string[]): void {
|
|
237
|
+
if (lines.length === 0) return;
|
|
238
|
+
progress.recentOutput.push(...lines.filter((line) => line.trim()));
|
|
239
|
+
if (progress.recentOutput.length > 50) {
|
|
240
|
+
progress.recentOutput.splice(0, progress.recentOutput.length - 50);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
function stripAcceptanceReportsFromMessages(messages: Message[] | undefined): void {
|
|
245
|
+
for (const message of messages ?? []) {
|
|
246
|
+
if (message.role !== "assistant" || !Array.isArray(message.content)) continue;
|
|
247
|
+
for (const part of message.content) {
|
|
248
|
+
if (part.type === "text" && "text" in part && typeof part.text === "string") {
|
|
249
|
+
part.text = stripAcceptanceReport(part.text);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
function snapshotProgress(progress: AgentProgress): AgentProgress {
|
|
256
|
+
return {
|
|
257
|
+
...progress,
|
|
258
|
+
task: PROMPT_REDACTED,
|
|
259
|
+
skills: progress.skills ? [...progress.skills] : undefined,
|
|
260
|
+
recentTools: boundStreamedRecentTools(progress.recentTools),
|
|
261
|
+
recentOutput: boundStreamedRecentOutput(progress.recentOutput),
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
function snapshotResult(result: SingleResult, progress: AgentProgress): SingleResult {
|
|
266
|
+
return {
|
|
267
|
+
...result,
|
|
268
|
+
task: PROMPT_REDACTED,
|
|
269
|
+
messages: result.outputMode === "file-only" && result.savedOutputPath ? undefined : result.messages ? [...result.messages] : undefined,
|
|
270
|
+
usage: { ...result.usage },
|
|
271
|
+
skills: result.skills ? [...result.skills] : undefined,
|
|
272
|
+
attemptedModels: result.attemptedModels ? [...result.attemptedModels] : undefined,
|
|
273
|
+
modelAttempts: result.modelAttempts
|
|
274
|
+
? result.modelAttempts.map((attempt) => ({
|
|
275
|
+
...attempt,
|
|
276
|
+
usage: attempt.usage ? { ...attempt.usage } : undefined,
|
|
277
|
+
}))
|
|
278
|
+
: undefined,
|
|
279
|
+
controlEvents: result.controlEvents ? result.controlEvents.map((event) => ({ ...event })) : undefined,
|
|
280
|
+
progress,
|
|
281
|
+
progressSummary: result.progressSummary ? { ...result.progressSummary } : undefined,
|
|
282
|
+
artifactPaths: result.artifactPaths ? { ...result.artifactPaths } : undefined,
|
|
283
|
+
truncation: result.truncation ? { ...result.truncation } : undefined,
|
|
284
|
+
outputReference: result.outputReference ? { ...result.outputReference } : undefined,
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
* Streaming variant of snapshotResult for `onUpdate` progress events: it drops the
|
|
290
|
+
* unbounded `messages` transcript in favour of compact tool-call summaries so a
|
|
291
|
+
* single `tool_execution_update` line stays well under the child-stdout protocol
|
|
292
|
+
* cap (`MAX_CHILD_PENDING_LINE_BYTES`). Non-streaming consumers such as
|
|
293
|
+
* foreground detach receipts and terminal consumers use snapshotResult directly.
|
|
294
|
+
*/
|
|
295
|
+
function snapshotStreamResult(result: SingleResult, progress: AgentProgress): SingleResult {
|
|
296
|
+
const snapshot = snapshotResult(result, progress);
|
|
297
|
+
snapshot.messages = undefined;
|
|
298
|
+
snapshot.toolCalls = boundStreamedToolCalls(result);
|
|
299
|
+
return snapshot;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
interface StructuredDelegationProgressState {
|
|
303
|
+
currentTool?: string;
|
|
304
|
+
currentToolArgs?: string;
|
|
305
|
+
recentOutput: string[];
|
|
306
|
+
recentTools: Array<{ tool: string; args: string }>;
|
|
307
|
+
activityState?: AgentProgress["activityState"];
|
|
308
|
+
model?: string;
|
|
309
|
+
toolCount: number;
|
|
310
|
+
tokens: number;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
function captureStructuredDelegationProgressState(progress: AgentProgress, result: SingleResult): StructuredDelegationProgressState {
|
|
314
|
+
return {
|
|
315
|
+
currentTool: progress.currentTool,
|
|
316
|
+
currentToolArgs: progress.currentToolArgs,
|
|
317
|
+
recentOutput: [...progress.recentOutput],
|
|
318
|
+
recentTools: progress.recentTools.slice(-MAX_STREAMED_RECENT_TOOLS).map(({ tool, args }) => ({ tool, args })),
|
|
319
|
+
activityState: progress.activityState,
|
|
320
|
+
model: progress.model ?? result.model,
|
|
321
|
+
toolCount: progress.toolCount,
|
|
322
|
+
tokens: progress.tokens,
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
function structuredDelegationProgressChanged(
|
|
327
|
+
previous: StructuredDelegationProgressState,
|
|
328
|
+
progress: AgentProgress,
|
|
329
|
+
result: SingleResult,
|
|
330
|
+
): boolean {
|
|
331
|
+
if (previous.currentTool !== progress.currentTool
|
|
332
|
+
|| previous.currentToolArgs !== progress.currentToolArgs
|
|
333
|
+
|| previous.activityState !== progress.activityState
|
|
334
|
+
|| previous.model !== (progress.model ?? result.model)
|
|
335
|
+
|| previous.toolCount !== progress.toolCount
|
|
336
|
+
|| previous.tokens !== progress.tokens
|
|
337
|
+
|| previous.recentOutput.length !== progress.recentOutput.length) return true;
|
|
338
|
+
for (let index = 0; index < progress.recentOutput.length; index++) {
|
|
339
|
+
if (previous.recentOutput[index] !== progress.recentOutput[index]) return true;
|
|
340
|
+
}
|
|
341
|
+
const recentToolsStart = Math.max(0, progress.recentTools.length - MAX_STREAMED_RECENT_TOOLS);
|
|
342
|
+
if (previous.recentTools.length !== progress.recentTools.length - recentToolsStart) return true;
|
|
343
|
+
for (let index = recentToolsStart; index < progress.recentTools.length; index++) {
|
|
344
|
+
const previousTool = previous.recentTools[index - recentToolsStart];
|
|
345
|
+
const currentTool = progress.recentTools[index];
|
|
346
|
+
if (previousTool?.tool !== currentTool?.tool || previousTool?.args !== currentTool?.args) return true;
|
|
347
|
+
}
|
|
348
|
+
return false;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
const AFTER_COMPACTION_SETTLEMENT = Symbol("afterCompactionSettlement");
|
|
352
|
+
type AbortRecoverySingleResult = SingleResult & { [AFTER_COMPACTION_SETTLEMENT]?: true };
|
|
353
|
+
|
|
354
|
+
async function runSingleAttempt(
|
|
355
|
+
runtimeCwd: string,
|
|
356
|
+
agent: AgentConfig,
|
|
357
|
+
task: string,
|
|
358
|
+
model: string | undefined,
|
|
359
|
+
options: RunSyncOptions,
|
|
360
|
+
shared: {
|
|
361
|
+
sessionEnabled: boolean;
|
|
362
|
+
systemPrompt: string;
|
|
363
|
+
resolvedSkillNames?: string[];
|
|
364
|
+
modelCandidates?: string[];
|
|
365
|
+
skillsWarning?: string;
|
|
366
|
+
jsonlPath?: string;
|
|
367
|
+
artifactPaths?: ArtifactPaths;
|
|
368
|
+
transcriptWriter?: ChildTranscriptWriter;
|
|
369
|
+
attemptNotes: string[];
|
|
370
|
+
outputSnapshot?: SingleOutputSnapshot;
|
|
371
|
+
originalTask?: string;
|
|
372
|
+
taskDelivery?: SubagentTaskDelivery;
|
|
373
|
+
orcaProgressTab?: OrcaProgressTab;
|
|
374
|
+
launchWarnings: { emitted: boolean };
|
|
375
|
+
verifyModel: boolean;
|
|
376
|
+
},
|
|
377
|
+
): Promise<SingleResult> {
|
|
378
|
+
const effectiveThinking = options.thinkingOverride ?? agent.thinking;
|
|
379
|
+
const modelArg = applyThinkingSuffix(model, effectiveThinking, options.thinkingOverride !== undefined);
|
|
380
|
+
assertThinkingWithinCeiling({ model: modelArg, configThinking: effectiveThinking, ceiling: options.thinkingCeiling, agent: agent.name, runId: options.runId });
|
|
381
|
+
const expectedModelForVerification = shared.verifyModel ? modelArg : undefined;
|
|
382
|
+
const resolvedThinking = resolveEffectiveThinking(modelArg, effectiveThinking);
|
|
383
|
+
// Display name for the child session: applied inside the child via
|
|
384
|
+
// SELESAI_SUBAGENT_SESSION_NAME and echoed back on the result payload so hosts
|
|
385
|
+
// can label this run without reading the child's session file.
|
|
386
|
+
const childSessionName = deriveChildSessionName({ agent: agent.name, task: shared.originalTask ?? task });
|
|
387
|
+
const watchdogConfig = resolveWatchdogConfig(options.cwd ?? runtimeCwd);
|
|
388
|
+
const childWatchdog = watchdogConfig.ok
|
|
389
|
+
? resolveChildWatchdogConfig({
|
|
390
|
+
config: watchdogConfig.config,
|
|
391
|
+
agent: agent.name,
|
|
392
|
+
runId: options.runId,
|
|
393
|
+
childIndex: options.index ?? 0,
|
|
394
|
+
})
|
|
395
|
+
: undefined;
|
|
396
|
+
const permissionRules = resolvePermissionRules(options.permissions, agent.permissions);
|
|
397
|
+
const permissionAuditPath = permissionRules && options.artifactsDir
|
|
398
|
+
? path.join(options.artifactsDir, "permission-audit", `${options.runId}-${options.index ?? 0}.jsonl`)
|
|
399
|
+
: undefined;
|
|
400
|
+
const { args, env: sharedEnv, tempDir, toolDiagnosticPath, runtimeAcknowledgedExtensionsPath, capabilityAudit, warnings } = buildPiArgs({
|
|
401
|
+
baseArgs: ["--mode", "json", "-p"],
|
|
402
|
+
task,
|
|
403
|
+
taskDelivery: shared.taskDelivery,
|
|
404
|
+
sessionEnabled: shared.sessionEnabled,
|
|
405
|
+
sessionDir: options.sessionDir,
|
|
406
|
+
sessionFile: options.sessionFile,
|
|
407
|
+
model: modelArg,
|
|
408
|
+
thinking: effectiveThinking,
|
|
409
|
+
systemPromptMode: agent.systemPromptMode,
|
|
410
|
+
inheritProjectContext: agent.inheritProjectContext,
|
|
411
|
+
inheritGlobalContext: agent.inheritGlobalContext,
|
|
412
|
+
inheritSkills: agent.inheritSkills,
|
|
413
|
+
requireReadTool: Boolean(shared.resolvedSkillNames?.length),
|
|
414
|
+
tools: agent.tools,
|
|
415
|
+
excludeTools: agent.excludeTools,
|
|
416
|
+
allowNestedSubagents: agent.allowNestedSubagents,
|
|
417
|
+
extensions: agent.extensions,
|
|
418
|
+
subagentOnlyExtensions: agent.subagentOnlyExtensions,
|
|
419
|
+
systemPrompt: shared.systemPrompt,
|
|
420
|
+
mcpDirectTools: agent.mcpDirectTools,
|
|
421
|
+
cwd: options.cwd ?? runtimeCwd,
|
|
422
|
+
promptFileStem: agent.name,
|
|
423
|
+
intercomSessionName: options.intercomSessionName,
|
|
424
|
+
sessionName: childSessionName,
|
|
425
|
+
orchestratorIntercomTarget: options.orchestratorIntercomTarget,
|
|
426
|
+
runId: options.runId,
|
|
427
|
+
childAgentName: agent.name,
|
|
428
|
+
childIndex: options.index ?? 0,
|
|
429
|
+
parentEventSink: options.nestedRoute?.eventSink,
|
|
430
|
+
parentControlInbox: options.nestedRoute?.controlInbox,
|
|
431
|
+
parentRootRunId: options.nestedRoute?.rootRunId,
|
|
432
|
+
parentCapabilityToken: options.nestedRoute?.capabilityToken,
|
|
433
|
+
runFanoutBudget: options.runFanoutBudget,
|
|
434
|
+
parentSessionId: options.parentSessionId,
|
|
435
|
+
forkCacheKey: options.context === "fork" ? deriveForkPromptCacheKey(options.parentSessionId) : undefined,
|
|
436
|
+
steerInboxDir: options.steerInboxDir,
|
|
437
|
+
steerCapabilityPath: options.steerCapabilityPath,
|
|
438
|
+
steerAckDir: options.steerAckDir,
|
|
439
|
+
structuredOutput: options.structuredOutput,
|
|
440
|
+
fast: options.fast ?? agent.fast,
|
|
441
|
+
modelCandidates: shared.modelCandidates,
|
|
442
|
+
toolBudget: options.toolBudget,
|
|
443
|
+
allowZeroToolBudget: options.allowZeroToolBudget,
|
|
444
|
+
permissionRules,
|
|
445
|
+
permissionAuditPath,
|
|
446
|
+
childWatchdog,
|
|
447
|
+
waitToolEnabled: options.waitToolEnabled,
|
|
448
|
+
waitToolDefaultTimeoutMs: options.waitToolDefaultTimeoutMs,
|
|
449
|
+
capabilityCeiling: options.capabilityCeiling,
|
|
450
|
+
thinkingCeiling: options.thinkingCeiling,
|
|
451
|
+
extensionBindings: options.extensionBindings,
|
|
452
|
+
runtimeSnapshotHost: options.runtimeSnapshotHost,
|
|
453
|
+
});
|
|
454
|
+
if (!shared.launchWarnings.emitted && warnings.length > 0) {
|
|
455
|
+
for (const warning of warnings) console.warn(`[pi-subagents] ${warning}`);
|
|
456
|
+
shared.launchWarnings.emitted = true;
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
const effectiveSystemPrompt = shared.systemPrompt;
|
|
460
|
+
const toolPlan = resolvePiLaunchToolPlan({
|
|
461
|
+
tools: agent.tools,
|
|
462
|
+
allowNestedSubagents: agent.allowNestedSubagents,
|
|
463
|
+
extensions: agent.extensions,
|
|
464
|
+
subagentOnlyExtensions: agent.subagentOnlyExtensions,
|
|
465
|
+
mcpDirectTools: agent.mcpDirectTools,
|
|
466
|
+
cwd: options.cwd ?? runtimeCwd,
|
|
467
|
+
requireReadTool: Boolean(shared.resolvedSkillNames?.length),
|
|
468
|
+
structuredOutput: Boolean(options.structuredOutput),
|
|
469
|
+
excludeTools: agent.excludeTools,
|
|
470
|
+
fast: options.fast ?? agent.fast,
|
|
471
|
+
model: modelArg,
|
|
472
|
+
modelCandidates: shared.modelCandidates,
|
|
473
|
+
capabilityCeiling: options.capabilityCeiling,
|
|
474
|
+
inheritedCapabilityCeiling: decodeSubagentCapabilityCeiling(process.env[SUBAGENT_CAPABILITY_CEILING_ENV]),
|
|
475
|
+
agentName: agent.name,
|
|
476
|
+
permissionRules,
|
|
477
|
+
runtimeSnapshotHost: options.runtimeSnapshotHost,
|
|
478
|
+
});
|
|
479
|
+
const contractTools = toolPlan.explicitToolAllowlist ? toolPlan.effectiveToolAllowlist : undefined;
|
|
480
|
+
const contractError = validateImplementationToolContract({
|
|
481
|
+
agent: agent.name,
|
|
482
|
+
task: shared.originalTask ?? task,
|
|
483
|
+
tools: contractTools,
|
|
484
|
+
mcpDirectTools: toolPlan.effectiveMcpTools,
|
|
485
|
+
configuredExtensions: toolPlan.configuredExtensions,
|
|
486
|
+
requestedTools: toolPlan.requestedBuiltinTools,
|
|
487
|
+
acceptanceRole: agent.acceptanceRole,
|
|
488
|
+
completionGuard: agent.completionGuard,
|
|
489
|
+
});
|
|
490
|
+
if (contractError) {
|
|
491
|
+
cleanupTempDir(tempDir);
|
|
492
|
+
return {
|
|
493
|
+
index: options.index ?? 0,
|
|
494
|
+
agent: agent.name,
|
|
495
|
+
task,
|
|
496
|
+
...(childSessionName ? { sessionName: childSessionName } : {}),
|
|
497
|
+
messages: [],
|
|
498
|
+
finalOutput: "",
|
|
499
|
+
exitCode: 1,
|
|
500
|
+
error: contractError,
|
|
501
|
+
usage: emptyUsage(),
|
|
502
|
+
model: modelArg,
|
|
503
|
+
modelAttempts: [],
|
|
504
|
+
attemptedModels: [],
|
|
505
|
+
progressSummary: { status: "failed", toolCount: 0, tokens: 0, durationMs: 0 },
|
|
506
|
+
...(toolPlan.capabilityCeiling ? { capabilityCeiling: toolPlan.capabilityCeiling } : {}),
|
|
507
|
+
...(toolPlan.capabilityAudit ? { capabilityAudit: toolPlan.capabilityAudit } : {}),
|
|
508
|
+
};
|
|
509
|
+
}
|
|
510
|
+
const launchResolvedExtensions = projectLaunchResolvedChildExtensions(toolPlan);
|
|
511
|
+
const launchContractDigest = launchBindingDigest({
|
|
512
|
+
definitionDigest: agentDefinitionDigest(agent),
|
|
513
|
+
task: shared.originalTask ?? task,
|
|
514
|
+
...(modelArg ? { model: modelArg } : {}),
|
|
515
|
+
modelCandidates: shared.modelCandidates,
|
|
516
|
+
...((options.fast ?? agent.fast) !== undefined ? { fast: options.fast ?? agent.fast } : {}),
|
|
517
|
+
...(resolvedThinking ? { thinking: resolvedThinking } : {}),
|
|
518
|
+
...(options.thinkingCeiling ? { thinkingCeiling: options.thinkingCeiling } : {}),
|
|
519
|
+
systemPrompt: effectiveSystemPrompt,
|
|
520
|
+
systemPromptMode: agent.systemPromptMode,
|
|
521
|
+
inheritProjectContext: agent.inheritProjectContext,
|
|
522
|
+
inheritGlobalContext: agent.inheritGlobalContext,
|
|
523
|
+
inheritSkills: agent.inheritSkills,
|
|
524
|
+
skills: shared.resolvedSkillNames ?? [],
|
|
525
|
+
tools: toolPlan.effectiveToolAllowlist,
|
|
526
|
+
...(toolPlan.excludeTools.length > 0 ? { excludeTools: toolPlan.excludeTools } : {}),
|
|
527
|
+
extensions: toolPlan.extensionArgs,
|
|
528
|
+
mcpDirectTools: toolPlan.effectiveMcpTools,
|
|
529
|
+
...(options.outputPath ? { outputPath: options.outputPath } : {}),
|
|
530
|
+
outputMode: options.outputMode ?? "inline",
|
|
531
|
+
...(options.structuredOutput ? { structuredOutputSchema: options.structuredOutput.schema } : {}),
|
|
532
|
+
...(options.extensionBindings ? { extensionBindings: options.extensionBindings } : {}),
|
|
533
|
+
});
|
|
534
|
+
const result: SingleResult = withRunContext({
|
|
535
|
+
index: options.index ?? 0,
|
|
536
|
+
agent: agent.name,
|
|
537
|
+
task: shared.originalTask ?? task,
|
|
538
|
+
...(childSessionName ? { sessionName: childSessionName } : {}),
|
|
539
|
+
...(options.agentContract ? { agentContract: options.agentContract } : {}),
|
|
540
|
+
launchContractDigest,
|
|
541
|
+
launchResolvedExtensions,
|
|
542
|
+
exitCode: 0,
|
|
543
|
+
outputState: "absent",
|
|
544
|
+
messages: [],
|
|
545
|
+
usage: emptyUsage(),
|
|
546
|
+
model: modelArg,
|
|
547
|
+
...(resolvedThinking ? { thinking: resolvedThinking } : {}),
|
|
548
|
+
artifactPaths: shared.artifactPaths,
|
|
549
|
+
transcriptPath: shared.transcriptWriter ? shared.artifactPaths?.transcriptPath : undefined,
|
|
550
|
+
skills: shared.resolvedSkillNames,
|
|
551
|
+
skillsWarning: shared.skillsWarning,
|
|
552
|
+
...(options.toolBudget ? { toolBudget: initialToolBudgetState(options.toolBudget) } : {}),
|
|
553
|
+
...(options.capabilityCeiling ? { capabilityCeiling: options.capabilityCeiling } : {}),
|
|
554
|
+
...(capabilityAudit ? { capabilityAudit } : {}),
|
|
555
|
+
}, options.context);
|
|
556
|
+
const startTime = Date.now();
|
|
557
|
+
if (options.structuredOutput) {
|
|
558
|
+
const cleanupError = clearStructuredOutputCaptures(options.structuredOutput);
|
|
559
|
+
if (cleanupError) {
|
|
560
|
+
cleanupTempDir(tempDir);
|
|
561
|
+
result.exitCode = 1;
|
|
562
|
+
result.error = cleanupError;
|
|
563
|
+
result.finalOutput = cleanupError;
|
|
564
|
+
result.progressSummary = { toolCount: 0, tokens: 0, durationMs: Date.now() - startTime };
|
|
565
|
+
return result;
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
const controlConfig = options.controlConfig ?? DEFAULT_CONTROL_CONFIG;
|
|
569
|
+
let interruptedByControl = false;
|
|
570
|
+
const allControlEvents: ControlEvent[] = [];
|
|
571
|
+
let pendingControlEvents: ControlEvent[] = [];
|
|
572
|
+
const emittedControlEventKeys = new Set<string>();
|
|
573
|
+
const emitControlEvent = (event: ControlEvent) => {
|
|
574
|
+
if (!shouldNotifyControlEvent(controlConfig, event)) return;
|
|
575
|
+
if (!claimControlNotification(controlConfig, event, emittedControlEventKeys)) return;
|
|
576
|
+
allControlEvents.push(event);
|
|
577
|
+
pendingControlEvents.push(event);
|
|
578
|
+
options.onControlEvent?.(event);
|
|
579
|
+
};
|
|
580
|
+
|
|
581
|
+
const progress: AgentProgress = {
|
|
582
|
+
index: options.index ?? 0,
|
|
583
|
+
agent: agent.name,
|
|
584
|
+
...(childSessionName ? { sessionName: childSessionName } : {}),
|
|
585
|
+
status: "running",
|
|
586
|
+
task,
|
|
587
|
+
skills: shared.resolvedSkillNames,
|
|
588
|
+
recentTools: [],
|
|
589
|
+
recentOutput: [...shared.attemptNotes],
|
|
590
|
+
toolCount: 0,
|
|
591
|
+
tokens: 0,
|
|
592
|
+
...(modelArg ? { model: modelArg } : {}),
|
|
593
|
+
...(resolvedThinking ? { thinking: resolvedThinking } : {}),
|
|
594
|
+
inputTokens: 0,
|
|
595
|
+
outputTokens: 0,
|
|
596
|
+
durationMs: 0,
|
|
597
|
+
lastActivityAt: startTime,
|
|
598
|
+
};
|
|
599
|
+
result.progress = progress;
|
|
600
|
+
const attemptTimeout = resolveAttemptTimeout(options);
|
|
601
|
+
if (attemptTimeout?.remainingMs === 0) {
|
|
602
|
+
cleanupTempDir(tempDir);
|
|
603
|
+
result.exitCode = 1;
|
|
604
|
+
result.timedOut = true;
|
|
605
|
+
result.error = attemptTimeout.message;
|
|
606
|
+
result.finalOutput = attemptTimeout.message;
|
|
607
|
+
progress.status = "failed";
|
|
608
|
+
progress.error = attemptTimeout.message;
|
|
609
|
+
result.progressSummary = {
|
|
610
|
+
toolCount: progress.toolCount,
|
|
611
|
+
tokens: progress.tokens,
|
|
612
|
+
durationMs: progress.durationMs,
|
|
613
|
+
};
|
|
614
|
+
return result;
|
|
615
|
+
}
|
|
616
|
+
const spawnEnv = { ...process.env, ...sharedEnv, ...getSubagentDepthEnv(options.maxSubagentDepth) };
|
|
617
|
+
const mutationSnapshot = snapshotTrackedMutations(options.cwd ?? runtimeCwd);
|
|
618
|
+
let observedMutationAttempt = false;
|
|
619
|
+
let structuredOutputToolInvoked = false;
|
|
620
|
+
let structuredOutputMessageStartIndex: number | undefined;
|
|
621
|
+
let toolAvailabilityError: string | undefined;
|
|
622
|
+
let abortedBySignal = options.signal?.aborted === true;
|
|
623
|
+
|
|
624
|
+
const spawnSpec = getPiSpawnCommand(args);
|
|
625
|
+
if (options.workflowChildPermitLaunch) {
|
|
626
|
+
const permitError = consumeWorkflowChildPermit(options.workflowChildPermitLaunch.permit, {
|
|
627
|
+
workflowRunId: options.workflowChildPermitLaunch.workflowRunId,
|
|
628
|
+
childKey: options.workflowChildPermitLaunch.childKey,
|
|
629
|
+
agent: agent.name,
|
|
630
|
+
launchContractDigest,
|
|
631
|
+
context: options.context ?? "fresh",
|
|
632
|
+
runner: "pi",
|
|
633
|
+
});
|
|
634
|
+
if (permitError) {
|
|
635
|
+
cleanupTempDir(tempDir);
|
|
636
|
+
result.exitCode = 1;
|
|
637
|
+
result.error = permitError;
|
|
638
|
+
result.finalOutput = permitError;
|
|
639
|
+
progress.status = "failed";
|
|
640
|
+
progress.error = permitError;
|
|
641
|
+
return result;
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
let afterCompactionSettlement = false;
|
|
645
|
+
const exitCode = await new Promise<number>((resolve) => {
|
|
646
|
+
const proc = spawn(spawnSpec.command, spawnSpec.args, {
|
|
647
|
+
cwd: options.cwd ?? runtimeCwd,
|
|
648
|
+
env: spawnEnv,
|
|
649
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
650
|
+
windowsHide: true,
|
|
651
|
+
});
|
|
652
|
+
const jsonlWriter = createJsonlWriter(shared.jsonlPath, proc.stdout);
|
|
653
|
+
let processClosed = false;
|
|
654
|
+
let lifecycleFinished = false;
|
|
655
|
+
let detached = false;
|
|
656
|
+
let intercomStarted = false;
|
|
657
|
+
let assistantError: string | undefined;
|
|
658
|
+
let removeAbortListener: (() => void) | undefined;
|
|
659
|
+
let removeInterruptListener: (() => void) | undefined;
|
|
660
|
+
let activityTimer: NodeJS.Timeout | undefined;
|
|
661
|
+
let timeoutTimer: NodeJS.Timeout | undefined;
|
|
662
|
+
let timeoutTerminationTimer: NodeJS.Timeout | undefined;
|
|
663
|
+
let timeoutHardKillTimer: NodeJS.Timeout | undefined;
|
|
664
|
+
let protocolHardKillTimer: NodeJS.Timeout | undefined;
|
|
665
|
+
const clearTimeoutTimers = () => {
|
|
666
|
+
if (timeoutTimer) {
|
|
667
|
+
clearTimeout(timeoutTimer);
|
|
668
|
+
timeoutTimer = undefined;
|
|
669
|
+
}
|
|
670
|
+
if (timeoutTerminationTimer) {
|
|
671
|
+
clearTimeout(timeoutTerminationTimer);
|
|
672
|
+
timeoutTerminationTimer = undefined;
|
|
673
|
+
}
|
|
674
|
+
if (timeoutHardKillTimer) {
|
|
675
|
+
clearTimeout(timeoutHardKillTimer);
|
|
676
|
+
timeoutHardKillTimer = undefined;
|
|
677
|
+
}
|
|
678
|
+
};
|
|
679
|
+
|
|
680
|
+
const detachForeground = (reason: string): boolean => {
|
|
681
|
+
if (detached || processClosed || lifecycleFinished || options.signal?.aborted) return false;
|
|
682
|
+
const receiptProgress = snapshotProgress(progress);
|
|
683
|
+
receiptProgress.status = "detached";
|
|
684
|
+
receiptProgress.durationMs = Date.now() - startTime;
|
|
685
|
+
const receipt = snapshotResult(result, receiptProgress);
|
|
686
|
+
receipt.exitCode = -2;
|
|
687
|
+
receipt.detached = true;
|
|
688
|
+
receipt.detachedReason = reason;
|
|
689
|
+
receipt.finalOutput = reason === "intercom coordination"
|
|
690
|
+
? "Detached for intercom coordination before task completion."
|
|
691
|
+
: reason === "user request"
|
|
692
|
+
? "Detached at user request before task completion."
|
|
693
|
+
: `Detached for ${reason} before task completion.`;
|
|
694
|
+
receipt.outputMode = options.outputMode ?? "inline";
|
|
695
|
+
if (options.outputPath) {
|
|
696
|
+
receipt.outputSaveError = reason === "user request"
|
|
697
|
+
? "Output file was not finalized because the subagent detached at user request."
|
|
698
|
+
: `Output file was not finalized because the subagent detached for ${reason}.`;
|
|
699
|
+
}
|
|
700
|
+
receipt.progressSummary = {
|
|
701
|
+
toolCount: receiptProgress.toolCount,
|
|
702
|
+
tokens: receiptProgress.tokens,
|
|
703
|
+
durationMs: receiptProgress.durationMs,
|
|
704
|
+
};
|
|
705
|
+
// The attempt is not detached until the outer coordinator has accepted and
|
|
706
|
+
// synchronously published the receipt. A persistence/callback failure must
|
|
707
|
+
// leave this attempt attached and abortable rather than orphaning it.
|
|
708
|
+
let accepted = false;
|
|
709
|
+
try {
|
|
710
|
+
accepted = options.onDetachReceipt?.(receipt) === true;
|
|
711
|
+
} catch {
|
|
712
|
+
return false;
|
|
713
|
+
}
|
|
714
|
+
if (!accepted) return false;
|
|
715
|
+
detached = true;
|
|
716
|
+
return true;
|
|
717
|
+
};
|
|
718
|
+
|
|
719
|
+
// If the child emits a terminal assistant stop but never exits,
|
|
720
|
+
// give it a short grace period to flush naturally, then clean it up.
|
|
721
|
+
const FINAL_STOP_GRACE_MS = 1000;
|
|
722
|
+
const HARD_KILL_MS = 3000;
|
|
723
|
+
let childExited = false;
|
|
724
|
+
let forcedTerminationSignal = false;
|
|
725
|
+
let cleanTerminalAssistantStopReceived = false;
|
|
726
|
+
let agentSettledReceived = false;
|
|
727
|
+
let compactionStartedReceived = false;
|
|
728
|
+
let finalDrainTimer: NodeJS.Timeout | undefined;
|
|
729
|
+
let finalHardKillTimer: NodeJS.Timeout | undefined;
|
|
730
|
+
let watchdogTailTimer: NodeJS.Timeout | undefined;
|
|
731
|
+
let childWatchdogState: ChildWatchdogStateSnapshot | undefined;
|
|
732
|
+
const updateChildWatchdogState = (snapshot: ChildWatchdogStateSnapshot): void => {
|
|
733
|
+
childWatchdogState = snapshot;
|
|
734
|
+
result.watchdog = snapshot;
|
|
735
|
+
progress.watchdog = snapshot;
|
|
736
|
+
};
|
|
737
|
+
const clearWatchdogTailTimer = () => {
|
|
738
|
+
if (watchdogTailTimer) {
|
|
739
|
+
clearTimeout(watchdogTailTimer);
|
|
740
|
+
watchdogTailTimer = undefined;
|
|
741
|
+
}
|
|
742
|
+
};
|
|
743
|
+
const clearFinalDrainTimers = () => {
|
|
744
|
+
if (finalDrainTimer) {
|
|
745
|
+
clearTimeout(finalDrainTimer);
|
|
746
|
+
finalDrainTimer = undefined;
|
|
747
|
+
}
|
|
748
|
+
if (finalHardKillTimer) {
|
|
749
|
+
clearTimeout(finalHardKillTimer);
|
|
750
|
+
finalHardKillTimer = undefined;
|
|
751
|
+
}
|
|
752
|
+
};
|
|
753
|
+
const startFinalDrain = () => {
|
|
754
|
+
if (childWatchdogIsActive(childWatchdogState)) {
|
|
755
|
+
armWatchdogTail();
|
|
756
|
+
return;
|
|
757
|
+
}
|
|
758
|
+
if (childExited || finalDrainTimer || lifecycleFinished || processClosed) return;
|
|
759
|
+
finalDrainTimer = setTimeout(() => {
|
|
760
|
+
if (lifecycleFinished || processClosed) return;
|
|
761
|
+
const termSent = trySignalChild(proc, "SIGTERM");
|
|
762
|
+
if (!termSent) return;
|
|
763
|
+
forcedTerminationSignal = true;
|
|
764
|
+
if (!cleanTerminalAssistantStopReceived && !agentSettledReceived && !assistantError) {
|
|
765
|
+
result.error = result.error ?? `Subagent process did not exit within ${FINAL_STOP_GRACE_MS}ms after its terminal event. Forcing termination.`;
|
|
766
|
+
}
|
|
767
|
+
finalHardKillTimer = setTimeout(() => {
|
|
768
|
+
if (lifecycleFinished || processClosed) return;
|
|
769
|
+
forcedTerminationSignal = trySignalChild(proc, "SIGKILL") || forcedTerminationSignal;
|
|
770
|
+
}, HARD_KILL_MS);
|
|
771
|
+
finalHardKillTimer.unref?.();
|
|
772
|
+
}, FINAL_STOP_GRACE_MS);
|
|
773
|
+
finalDrainTimer.unref?.();
|
|
774
|
+
};
|
|
775
|
+
function armWatchdogTail(): void {
|
|
776
|
+
if ((!cleanTerminalAssistantStopReceived && !agentSettledReceived) || watchdogTailTimer || lifecycleFinished || processClosed) return;
|
|
777
|
+
watchdogTailTimer = setTimeout(() => {
|
|
778
|
+
watchdogTailTimer = undefined;
|
|
779
|
+
updateChildWatchdogState({
|
|
780
|
+
phase: "stale",
|
|
781
|
+
seq: (childWatchdogState?.seq ?? 0) + 1,
|
|
782
|
+
lastUpdate: Date.now(),
|
|
783
|
+
reason: "child watchdog tail timeout",
|
|
784
|
+
timedOut: true,
|
|
785
|
+
});
|
|
786
|
+
startFinalDrain();
|
|
787
|
+
fireUpdate();
|
|
788
|
+
}, childWatchdog?.watchdogTailTimeoutMs ?? 120_000);
|
|
789
|
+
watchdogTailTimer.unref?.();
|
|
790
|
+
}
|
|
791
|
+
const applyChildLifecycle = (action: ChildLifecycleAction): void => {
|
|
792
|
+
if (action === "cancel-drain") {
|
|
793
|
+
clearFinalDrainTimers();
|
|
794
|
+
clearWatchdogTailTimer();
|
|
795
|
+
return;
|
|
796
|
+
}
|
|
797
|
+
if (action === "start-drain") startFinalDrain();
|
|
798
|
+
};
|
|
799
|
+
const childLifecycleState: ChildLifecycleState = { compactionRetryActive: false };
|
|
800
|
+
|
|
801
|
+
const unsubscribeIntercomDetach = options.intercomEvents?.on?.(INTERCOM_DETACH_REQUEST_EVENT, (payload) => {
|
|
802
|
+
if (!options.allowIntercomDetach || processClosed) return;
|
|
803
|
+
if (!payload || typeof payload !== "object") return;
|
|
804
|
+
const event = payload as { requestId?: unknown; runId?: unknown; agent?: unknown; childIndex?: unknown };
|
|
805
|
+
const requestId = event.requestId;
|
|
806
|
+
if (typeof requestId !== "string" || requestId.length === 0) return;
|
|
807
|
+
const hasRoute = event.runId !== undefined || event.agent !== undefined || event.childIndex !== undefined;
|
|
808
|
+
if (hasRoute) {
|
|
809
|
+
if (typeof event.runId === "string" && event.runId !== options.runId) return;
|
|
810
|
+
if (typeof event.agent === "string" && event.agent !== agent.name) return;
|
|
811
|
+
if (typeof event.childIndex === "number" && event.childIndex !== (options.index ?? 0)) return;
|
|
812
|
+
} else if (!intercomStarted) return;
|
|
813
|
+
const accepted = detachForeground("intercom coordination");
|
|
814
|
+
options.intercomEvents?.emit(INTERCOM_DETACH_RESPONSE_EVENT, { requestId, accepted, runId: options.runId, agent: agent.name, childIndex: options.index ?? 0 });
|
|
815
|
+
});
|
|
816
|
+
|
|
817
|
+
const finish = (code: number) => {
|
|
818
|
+
if (lifecycleFinished) return;
|
|
819
|
+
lifecycleFinished = true;
|
|
820
|
+
clearFinalDrainTimers();
|
|
821
|
+
clearWatchdogTailTimer();
|
|
822
|
+
clearStdioGuard();
|
|
823
|
+
clearTimeoutTimers();
|
|
824
|
+
clearAllToolTimeouts();
|
|
825
|
+
if (protocolHardKillTimer) {
|
|
826
|
+
clearTimeout(protocolHardKillTimer);
|
|
827
|
+
protocolHardKillTimer = undefined;
|
|
828
|
+
}
|
|
829
|
+
if (activityTimer) {
|
|
830
|
+
clearInterval(activityTimer);
|
|
831
|
+
activityTimer = undefined;
|
|
832
|
+
}
|
|
833
|
+
unsubscribeIntercomDetach?.();
|
|
834
|
+
removeAbortListener?.();
|
|
835
|
+
removeInterruptListener?.();
|
|
836
|
+
resolve(code);
|
|
837
|
+
};
|
|
838
|
+
|
|
839
|
+
const drainPendingControlEvents = (): ControlEvent[] | undefined => {
|
|
840
|
+
if (pendingControlEvents.length === 0) return undefined;
|
|
841
|
+
const events = pendingControlEvents;
|
|
842
|
+
pendingControlEvents = [];
|
|
843
|
+
return events;
|
|
844
|
+
};
|
|
845
|
+
|
|
846
|
+
let activeLongRunningNotified = false;
|
|
847
|
+
let pendingToolResult: { tool: string; path?: string; mutates: boolean; startedAt?: number } | undefined;
|
|
848
|
+
type ActiveToolCall = { key: string; tool: string; args: string; startedAt: number; path?: string };
|
|
849
|
+
let activeToolSequence = 0;
|
|
850
|
+
const activeToolCalls = new Map<string, ActiveToolCall>();
|
|
851
|
+
const activeToolKeysByName = new Map<string, string[]>();
|
|
852
|
+
const latestActiveToolCall = (): ActiveToolCall | undefined => [...activeToolCalls.values()].sort((left, right) => right.startedAt - left.startedAt)[0];
|
|
853
|
+
const refreshCurrentTool = (): void => {
|
|
854
|
+
const active = latestActiveToolCall();
|
|
855
|
+
if (!active) {
|
|
856
|
+
progress.currentTool = undefined;
|
|
857
|
+
progress.currentToolArgs = undefined;
|
|
858
|
+
progress.currentToolStartedAt = undefined;
|
|
859
|
+
progress.currentPath = undefined;
|
|
860
|
+
return;
|
|
861
|
+
}
|
|
862
|
+
progress.currentTool = active.tool;
|
|
863
|
+
progress.currentToolArgs = active.args;
|
|
864
|
+
progress.currentToolStartedAt = active.startedAt;
|
|
865
|
+
progress.currentPath = active.path;
|
|
866
|
+
};
|
|
867
|
+
const recordActiveToolCall = (event: { toolCallId?: unknown; toolName: string }, args: Record<string, unknown>, now: number): ActiveToolCall => {
|
|
868
|
+
const key = toolTimeoutCallKey(event, ++activeToolSequence);
|
|
869
|
+
const path = resolveCurrentPath(event.toolName, args);
|
|
870
|
+
const active: ActiveToolCall = {
|
|
871
|
+
key,
|
|
872
|
+
tool: event.toolName,
|
|
873
|
+
args: extractToolArgsPreview(args),
|
|
874
|
+
startedAt: now,
|
|
875
|
+
...(path !== undefined ? { path } : {}),
|
|
876
|
+
};
|
|
877
|
+
activeToolCalls.set(key, active);
|
|
878
|
+
const keys = activeToolKeysByName.get(active.tool) ?? [];
|
|
879
|
+
keys.push(key);
|
|
880
|
+
activeToolKeysByName.set(active.tool, keys);
|
|
881
|
+
refreshCurrentTool();
|
|
882
|
+
return active;
|
|
883
|
+
};
|
|
884
|
+
const removeActiveToolCallKey = (key: string): ActiveToolCall | undefined => {
|
|
885
|
+
const active = activeToolCalls.get(key);
|
|
886
|
+
if (!active) return undefined;
|
|
887
|
+
activeToolCalls.delete(key);
|
|
888
|
+
const keys = activeToolKeysByName.get(active.tool)?.filter((candidate) => candidate !== key) ?? [];
|
|
889
|
+
if (keys.length > 0) activeToolKeysByName.set(active.tool, keys);
|
|
890
|
+
else activeToolKeysByName.delete(active.tool);
|
|
891
|
+
return active;
|
|
892
|
+
};
|
|
893
|
+
const removeActiveToolCall = (event: { toolCallId?: unknown; toolName?: unknown }): ActiveToolCall | undefined => {
|
|
894
|
+
const key = typeof event.toolCallId === "string" && event.toolCallId.length > 0
|
|
895
|
+
? `id:${event.toolCallId}`
|
|
896
|
+
: typeof event.toolName === "string"
|
|
897
|
+
? activeToolKeysByName.get(event.toolName)?.[0]
|
|
898
|
+
: activeToolCalls.size === 1
|
|
899
|
+
? [...activeToolCalls.keys()][0]
|
|
900
|
+
: undefined;
|
|
901
|
+
return key ? removeActiveToolCallKey(key) : undefined;
|
|
902
|
+
};
|
|
903
|
+
const openToolAttentionTarget = (now: number): ActiveToolCall | undefined => [...activeToolCalls.values()]
|
|
904
|
+
.filter((active) => shouldEmitOpenToolAttention({ config: controlConfig, currentTool: active.tool, currentToolStartedAt: active.startedAt, now }))
|
|
905
|
+
.sort((left, right) => left.startedAt - right.startedAt)[0];
|
|
906
|
+
const mutatingFailures = createMutatingFailureState();
|
|
907
|
+
const mutatingFailureWindowMs = 5 * 60_000;
|
|
908
|
+
const currentToolDurationMs = (now: number) => progress.currentToolStartedAt ? Math.max(0, now - progress.currentToolStartedAt) : undefined;
|
|
909
|
+
const emitNeedsAttention = (now: number, input: { message?: string; reason?: ControlEvent["reason"]; recentFailureSummary?: string; currentTool?: string; currentPath?: string; currentToolDurationMs?: number } = {}): boolean => {
|
|
910
|
+
if (!controlConfig.enabled) return false;
|
|
911
|
+
const previous = progress.activityState;
|
|
912
|
+
progress.activityState = "needs_attention";
|
|
913
|
+
const event = buildControlEvent({
|
|
914
|
+
type: "needs_attention",
|
|
915
|
+
from: previous,
|
|
916
|
+
to: "needs_attention",
|
|
917
|
+
runId: options.runId,
|
|
918
|
+
agent: agent.name,
|
|
919
|
+
index: options.index,
|
|
920
|
+
ts: now,
|
|
921
|
+
lastActivityAt: progress.lastActivityAt,
|
|
922
|
+
message: input.message,
|
|
923
|
+
reason: input.reason ?? "idle",
|
|
924
|
+
turns: result.usage.turns,
|
|
925
|
+
tokens: progress.tokens,
|
|
926
|
+
toolCount: progress.toolCount,
|
|
927
|
+
currentTool: input.currentTool ?? progress.currentTool,
|
|
928
|
+
currentToolDurationMs: input.currentToolDurationMs ?? currentToolDurationMs(now),
|
|
929
|
+
currentPath: input.currentPath ?? progress.currentPath,
|
|
930
|
+
recentFailureSummary: input.recentFailureSummary,
|
|
931
|
+
taskPreview: task,
|
|
932
|
+
});
|
|
933
|
+
emitControlEvent(event);
|
|
934
|
+
return previous !== "needs_attention";
|
|
935
|
+
};
|
|
936
|
+
const emitActiveLongRunning = (now: number, reason: ControlEvent["reason"]): boolean => {
|
|
937
|
+
if (!controlConfig.enabled || activeLongRunningNotified || progress.activityState === "needs_attention") return false;
|
|
938
|
+
activeLongRunningNotified = true;
|
|
939
|
+
const previous = progress.activityState;
|
|
940
|
+
progress.activityState = "active_long_running";
|
|
941
|
+
emitControlEvent(buildControlEvent({
|
|
942
|
+
type: "active_long_running",
|
|
943
|
+
from: previous,
|
|
944
|
+
to: "active_long_running",
|
|
945
|
+
runId: options.runId,
|
|
946
|
+
agent: agent.name,
|
|
947
|
+
index: options.index,
|
|
948
|
+
ts: now,
|
|
949
|
+
message: `${agent.name} is still active but long-running`,
|
|
950
|
+
reason,
|
|
951
|
+
turns: result.usage.turns,
|
|
952
|
+
tokens: progress.tokens,
|
|
953
|
+
toolCount: progress.toolCount,
|
|
954
|
+
currentTool: progress.currentTool,
|
|
955
|
+
currentToolDurationMs: currentToolDurationMs(now),
|
|
956
|
+
currentPath: progress.currentPath,
|
|
957
|
+
elapsedMs: now - startTime,
|
|
958
|
+
taskPreview: task,
|
|
959
|
+
}));
|
|
960
|
+
return true;
|
|
961
|
+
};
|
|
962
|
+
const updateActivityState = (now: number): boolean => {
|
|
963
|
+
if (!controlConfig.enabled) return false;
|
|
964
|
+
const idleState = deriveActivityState({
|
|
965
|
+
config: controlConfig,
|
|
966
|
+
startedAt: startTime,
|
|
967
|
+
lastActivityAt: progress.lastActivityAt,
|
|
968
|
+
turnCount: progress.turnCount,
|
|
969
|
+
currentTool: progress.currentTool,
|
|
970
|
+
thinking: resolvedThinking,
|
|
971
|
+
now,
|
|
972
|
+
});
|
|
973
|
+
if (idleState === "needs_attention") {
|
|
974
|
+
return progress.activityState === "needs_attention" ? false : emitNeedsAttention(now);
|
|
975
|
+
}
|
|
976
|
+
const toolAttentionTarget = progress.activityState !== "needs_attention" ? openToolAttentionTarget(now) : undefined;
|
|
977
|
+
if (toolAttentionTarget) {
|
|
978
|
+
const durationMs = Math.max(0, now - toolAttentionTarget.startedAt);
|
|
979
|
+
return emitNeedsAttention(now, {
|
|
980
|
+
message: `${agent.name} has had tool '${toolAttentionTarget.tool}' open for ${Math.floor(durationMs / 1000)}s`,
|
|
981
|
+
reason: "tool_open_threshold",
|
|
982
|
+
currentTool: toolAttentionTarget.tool,
|
|
983
|
+
currentPath: toolAttentionTarget.path,
|
|
984
|
+
currentToolDurationMs: durationMs,
|
|
985
|
+
});
|
|
986
|
+
}
|
|
987
|
+
const activeReason = nextLongRunningTrigger(controlConfig, {
|
|
988
|
+
startedAt: startTime,
|
|
989
|
+
now,
|
|
990
|
+
turns: result.usage.turns,
|
|
991
|
+
tokens: progress.tokens,
|
|
992
|
+
});
|
|
993
|
+
return activeReason ? emitActiveLongRunning(now, activeReason) : false;
|
|
994
|
+
};
|
|
995
|
+
|
|
996
|
+
|
|
997
|
+
let lastStructuredDelegationProgressState: StructuredDelegationProgressState | undefined;
|
|
998
|
+
const emitUpdateSnapshot = (text: string) => {
|
|
999
|
+
if (!options.onUpdate || processClosed) return;
|
|
1000
|
+
const progressSnapshot = snapshotProgress(progress);
|
|
1001
|
+
const resultSnapshot = snapshotStreamResult(result, progressSnapshot);
|
|
1002
|
+
const controlEvents = drainPendingControlEvents();
|
|
1003
|
+
options.onUpdate({
|
|
1004
|
+
content: [{ type: "text", text }],
|
|
1005
|
+
details: {
|
|
1006
|
+
mode: "single",
|
|
1007
|
+
results: [resultSnapshot],
|
|
1008
|
+
progress: [progressSnapshot],
|
|
1009
|
+
controlEvents,
|
|
1010
|
+
},
|
|
1011
|
+
});
|
|
1012
|
+
};
|
|
1013
|
+
|
|
1014
|
+
const fireUpdate = () => {
|
|
1015
|
+
if (!options.onUpdate || processClosed) return;
|
|
1016
|
+
progress.durationMs = Date.now() - startTime;
|
|
1017
|
+
if (options.suppressUnchangedDelegationUpdates) {
|
|
1018
|
+
if (lastStructuredDelegationProgressState && !structuredDelegationProgressChanged(lastStructuredDelegationProgressState, progress, result)) return;
|
|
1019
|
+
lastStructuredDelegationProgressState = captureStructuredDelegationProgressState(progress, result);
|
|
1020
|
+
}
|
|
1021
|
+
const output = result.timedOut && result.finalOutput ? result.finalOutput : getFinalOutput(result.messages ?? []);
|
|
1022
|
+
emitUpdateSnapshot(output || "(running...)");
|
|
1023
|
+
};
|
|
1024
|
+
|
|
1025
|
+
const rawStdoutTail = createBoundedByteTail();
|
|
1026
|
+
const processLine = (line: string) => {
|
|
1027
|
+
if (!line.trim()) return;
|
|
1028
|
+
jsonlWriter.writeLine(line);
|
|
1029
|
+
let evt: { type?: string; message?: Message; toolName?: string; toolCallId?: string; args?: unknown; willRetry?: unknown };
|
|
1030
|
+
try {
|
|
1031
|
+
evt = JSON.parse(line) as { type?: string; message?: Message; toolName?: string; toolCallId?: string; args?: unknown; willRetry?: unknown };
|
|
1032
|
+
} catch {
|
|
1033
|
+
rawStdoutTail.push(`${line}\n`);
|
|
1034
|
+
shared.transcriptWriter?.writeStdoutLine(line);
|
|
1035
|
+
shared.orcaProgressTab?.append(`${line}\n`);
|
|
1036
|
+
// Non-JSON stdout lines are expected; only structured events are parsed.
|
|
1037
|
+
return;
|
|
1038
|
+
}
|
|
1039
|
+
shared.transcriptWriter?.writeChildEvent(evt);
|
|
1040
|
+
shared.orcaProgressTab?.event(evt);
|
|
1041
|
+
if (evt.type === "compaction_start") compactionStartedReceived = true;
|
|
1042
|
+
if (evt.type === "compaction_end" && evt.willRetry === true) {
|
|
1043
|
+
compactionStartedReceived = false;
|
|
1044
|
+
afterCompactionSettlement = false;
|
|
1045
|
+
}
|
|
1046
|
+
if (evt.type === "agent_start" || evt.type === "auto_retry_start") {
|
|
1047
|
+
compactionStartedReceived = false;
|
|
1048
|
+
afterCompactionSettlement = false;
|
|
1049
|
+
}
|
|
1050
|
+
const lifecycleAction = projectChildLifecycle(evt, false, childLifecycleState);
|
|
1051
|
+
if (evt.type === "agent_settled" && lifecycleAction === "start-drain") {
|
|
1052
|
+
agentSettledReceived = true;
|
|
1053
|
+
afterCompactionSettlement = compactionStartedReceived;
|
|
1054
|
+
}
|
|
1055
|
+
applyChildLifecycle(lifecycleAction);
|
|
1056
|
+
|
|
1057
|
+
if (isChildWatchdogStatusEvent(evt)) {
|
|
1058
|
+
if (!childWatchdog) return;
|
|
1059
|
+
const next = acceptChildWatchdogEvent({
|
|
1060
|
+
current: childWatchdogState,
|
|
1061
|
+
event: evt,
|
|
1062
|
+
runId: options.runId,
|
|
1063
|
+
agent: agent.name,
|
|
1064
|
+
childIndex: options.index ?? 0,
|
|
1065
|
+
});
|
|
1066
|
+
if (!next) return;
|
|
1067
|
+
updateChildWatchdogState(next);
|
|
1068
|
+
if (childWatchdogIsActive(next)) {
|
|
1069
|
+
clearFinalDrainTimers();
|
|
1070
|
+
armWatchdogTail();
|
|
1071
|
+
} else {
|
|
1072
|
+
clearWatchdogTailTimer();
|
|
1073
|
+
if (cleanTerminalAssistantStopReceived || agentSettledReceived) startFinalDrain();
|
|
1074
|
+
}
|
|
1075
|
+
fireUpdate();
|
|
1076
|
+
return;
|
|
1077
|
+
}
|
|
1078
|
+
|
|
1079
|
+
const now = Date.now();
|
|
1080
|
+
progress.durationMs = now - startTime;
|
|
1081
|
+
progress.lastActivityAt = now;
|
|
1082
|
+
updateActivityState(now);
|
|
1083
|
+
|
|
1084
|
+
if (evt.type === "tool_execution_start") {
|
|
1085
|
+
const toolArgs = evt.args && typeof evt.args === "object" && !Array.isArray(evt.args)
|
|
1086
|
+
? evt.args as Record<string, unknown>
|
|
1087
|
+
: {};
|
|
1088
|
+
const activeTool = evt.toolName !== undefined ? recordActiveToolCall(evt as { toolCallId?: unknown; toolName: string }, toolArgs, now) : undefined;
|
|
1089
|
+
if (evt.toolName !== undefined) armToolTimeout(evt as { toolCallId?: unknown; toolName: string });
|
|
1090
|
+
if (options.structuredOutput && evt.toolName === "structured_output") {
|
|
1091
|
+
structuredOutputToolInvoked = true;
|
|
1092
|
+
structuredOutputMessageStartIndex = result.messages?.length ?? 0;
|
|
1093
|
+
}
|
|
1094
|
+
if (options.allowIntercomDetach && (evt.toolName === "intercom" || evt.toolName === "contact_supervisor")) {
|
|
1095
|
+
intercomStarted = true;
|
|
1096
|
+
}
|
|
1097
|
+
progress.toolCount++;
|
|
1098
|
+
if (options.toolBudget) {
|
|
1099
|
+
result.toolBudget = toolBudgetState(options.toolBudget, progress.toolCount);
|
|
1100
|
+
}
|
|
1101
|
+
const mutates = isMutatingTool(evt.toolName, toolArgs, agent.mutationTools);
|
|
1102
|
+
observedMutationAttempt = observedMutationAttempt || mutates;
|
|
1103
|
+
pendingToolResult = { tool: evt.toolName ?? "tool", path: activeTool?.path, mutates, startedAt: now };
|
|
1104
|
+
fireUpdate();
|
|
1105
|
+
}
|
|
1106
|
+
|
|
1107
|
+
if (evt.type === "tool_execution_end") {
|
|
1108
|
+
clearActiveToolTimeout(evt);
|
|
1109
|
+
const endedTool = removeActiveToolCall(evt);
|
|
1110
|
+
if (endedTool) {
|
|
1111
|
+
progress.recentTools.push({
|
|
1112
|
+
tool: endedTool.tool,
|
|
1113
|
+
args: endedTool.args,
|
|
1114
|
+
endMs: now,
|
|
1115
|
+
});
|
|
1116
|
+
}
|
|
1117
|
+
refreshCurrentTool();
|
|
1118
|
+
fireUpdate();
|
|
1119
|
+
}
|
|
1120
|
+
|
|
1121
|
+
if (evt.type === "message_end" && evt.message) {
|
|
1122
|
+
result.messages!.push(evt.message);
|
|
1123
|
+
if (childWatchdog) {
|
|
1124
|
+
const next = applyChildWatchdogMessage(childWatchdogState, evt.message);
|
|
1125
|
+
if (next) updateChildWatchdogState(next);
|
|
1126
|
+
}
|
|
1127
|
+
if (evt.message.role === "assistant") {
|
|
1128
|
+
result.usage.turns++;
|
|
1129
|
+
progress.turnCount = result.usage.turns;
|
|
1130
|
+
const toolCalls = Array.isArray(evt.message.content)
|
|
1131
|
+
? evt.message.content.filter((part) => (part as { type?: string }).type === "toolCall")
|
|
1132
|
+
: [];
|
|
1133
|
+
const hasToolCall = toolCalls.length > 0;
|
|
1134
|
+
const terminalAssistantStop = (evt.message as { stopReason?: string }).stopReason === "stop" && !hasToolCall;
|
|
1135
|
+
const u = evt.message.usage;
|
|
1136
|
+
if (u) {
|
|
1137
|
+
const window = (u.input || 0) + (u.cacheRead || 0);
|
|
1138
|
+
result.usage.input += u.input || 0;
|
|
1139
|
+
result.usage.output += u.output || 0;
|
|
1140
|
+
result.usage.cacheRead += u.cacheRead || 0;
|
|
1141
|
+
result.usage.cacheWrite += u.cacheWrite || 0;
|
|
1142
|
+
result.usage.cost += u.cost?.total || 0;
|
|
1143
|
+
progress.tokens = result.usage.input + result.usage.output;
|
|
1144
|
+
progress.inputTokens = result.usage.input;
|
|
1145
|
+
progress.outputTokens = result.usage.output;
|
|
1146
|
+
progress.window = window;
|
|
1147
|
+
progress.windowPeak = Math.max(progress.windowPeak ?? 0, window);
|
|
1148
|
+
}
|
|
1149
|
+
if (evt.message.model) {
|
|
1150
|
+
progress.model = evt.message.model;
|
|
1151
|
+
if (!result.model) result.model = evt.message.model;
|
|
1152
|
+
if (expectedModelForVerification && !hasToolCall) {
|
|
1153
|
+
const modelVerificationError = formatSubagentModelVerificationError(expectedModelForVerification, evt.message.model, options.availableModels);
|
|
1154
|
+
if (modelVerificationError && !result.error) result.error = modelVerificationError;
|
|
1155
|
+
}
|
|
1156
|
+
}
|
|
1157
|
+
if (evt.message.errorMessage) assistantError = evt.message.errorMessage;
|
|
1158
|
+
const assistantText = extractTextFromContent(evt.message.content);
|
|
1159
|
+
appendRecentOutput(progress, assistantText.split("\n").slice(-10));
|
|
1160
|
+
// Final assistant message: start the exit drain window.
|
|
1161
|
+
if (terminalAssistantStop) {
|
|
1162
|
+
if (!evt.message.errorMessage && assistantText.trim()) assistantError = undefined;
|
|
1163
|
+
cleanTerminalAssistantStopReceived ||= !evt.message.errorMessage;
|
|
1164
|
+
clearAllToolTimeouts();
|
|
1165
|
+
activeToolCalls.clear();
|
|
1166
|
+
activeToolKeysByName.clear();
|
|
1167
|
+
refreshCurrentTool();
|
|
1168
|
+
applyChildLifecycle(projectChildLifecycle(evt, true, childLifecycleState));
|
|
1169
|
+
}
|
|
1170
|
+
}
|
|
1171
|
+
updateActivityState(now);
|
|
1172
|
+
fireUpdate();
|
|
1173
|
+
}
|
|
1174
|
+
|
|
1175
|
+
if (evt.type === "tool_result_end" && evt.message) {
|
|
1176
|
+
const toolResultCompletion = {
|
|
1177
|
+
toolCallId: (evt.message as { toolCallId?: unknown }).toolCallId ?? (evt as { toolCallId?: unknown }).toolCallId,
|
|
1178
|
+
toolName: (evt.message as { toolName?: unknown }).toolName ?? (evt as { toolName?: unknown }).toolName,
|
|
1179
|
+
};
|
|
1180
|
+
clearActiveToolTimeout(toolResultCompletion);
|
|
1181
|
+
const endedTool = removeActiveToolCall(toolResultCompletion);
|
|
1182
|
+
if (endedTool) {
|
|
1183
|
+
progress.recentTools.push({
|
|
1184
|
+
tool: endedTool.tool,
|
|
1185
|
+
args: endedTool.args,
|
|
1186
|
+
endMs: now,
|
|
1187
|
+
});
|
|
1188
|
+
refreshCurrentTool();
|
|
1189
|
+
}
|
|
1190
|
+
result.messages!.push(evt.message);
|
|
1191
|
+
const resultText = extractTextFromContent(evt.message.content);
|
|
1192
|
+
if (options.toolBudget && pendingToolResult && resultText.includes("Tool budget hard limit reached")) {
|
|
1193
|
+
result.toolBudgetBlocked = true;
|
|
1194
|
+
result.toolBudget = toolBudgetState(options.toolBudget, progress.toolCount, pendingToolResult.tool);
|
|
1195
|
+
}
|
|
1196
|
+
appendRecentOutput(progress, resultText.split("\n").slice(-10));
|
|
1197
|
+
const toolSnapshot = pendingToolResult;
|
|
1198
|
+
pendingToolResult = undefined;
|
|
1199
|
+
if (toolSnapshot?.mutates && didMutatingToolFail(resultText)) {
|
|
1200
|
+
recordMutatingFailure(mutatingFailures, {
|
|
1201
|
+
tool: toolSnapshot.tool,
|
|
1202
|
+
path: toolSnapshot.path,
|
|
1203
|
+
error: resultText.split("\n").find((line) => line.trim())?.trim().slice(0, 180) ?? "mutating tool failed",
|
|
1204
|
+
ts: now,
|
|
1205
|
+
}, mutatingFailureWindowMs);
|
|
1206
|
+
if (shouldEscalateMutatingFailures(mutatingFailures, controlConfig.failedToolAttemptsBeforeAttention)) {
|
|
1207
|
+
emitNeedsAttention(now, {
|
|
1208
|
+
message: `${agent.name} needs attention after repeated mutating tool failures`,
|
|
1209
|
+
reason: "tool_failures",
|
|
1210
|
+
currentTool: toolSnapshot.tool,
|
|
1211
|
+
currentPath: toolSnapshot.path,
|
|
1212
|
+
currentToolDurationMs: toolSnapshot.startedAt ? Math.max(0, now - toolSnapshot.startedAt) : undefined,
|
|
1213
|
+
recentFailureSummary: summarizeRecentMutatingFailures(mutatingFailures),
|
|
1214
|
+
});
|
|
1215
|
+
}
|
|
1216
|
+
} else if (toolSnapshot?.mutates) {
|
|
1217
|
+
resetMutatingFailureState(mutatingFailures);
|
|
1218
|
+
}
|
|
1219
|
+
fireUpdate();
|
|
1220
|
+
}
|
|
1221
|
+
};
|
|
1222
|
+
|
|
1223
|
+
fireUpdate();
|
|
1224
|
+
if (controlConfig.enabled || options.onUpdate) {
|
|
1225
|
+
activityTimer = setInterval(() => {
|
|
1226
|
+
if (processClosed || lifecycleFinished) {
|
|
1227
|
+
return;
|
|
1228
|
+
}
|
|
1229
|
+
updateActivityState(Date.now());
|
|
1230
|
+
fireUpdate();
|
|
1231
|
+
}, 1000);
|
|
1232
|
+
activityTimer.unref?.();
|
|
1233
|
+
}
|
|
1234
|
+
|
|
1235
|
+
if (attemptTimeout) {
|
|
1236
|
+
timeoutTimer = setTimeout(() => {
|
|
1237
|
+
if (processClosed || lifecycleFinished || interruptedByControl) return;
|
|
1238
|
+
result.timedOut = true;
|
|
1239
|
+
clearAllToolTimeouts();
|
|
1240
|
+
result.error = attemptTimeout.message;
|
|
1241
|
+
result.finalOutput = attemptTimeout.message;
|
|
1242
|
+
progress.status = "failed";
|
|
1243
|
+
progress.error = attemptTimeout.message;
|
|
1244
|
+
progress.durationMs = Date.now() - startTime;
|
|
1245
|
+
fireUpdate();
|
|
1246
|
+
trySignalChild(proc, "SIGINT");
|
|
1247
|
+
timeoutTerminationTimer = setTimeout(() => {
|
|
1248
|
+
if (processClosed || lifecycleFinished) return;
|
|
1249
|
+
trySignalChild(proc, "SIGTERM");
|
|
1250
|
+
}, 1000);
|
|
1251
|
+
timeoutTerminationTimer.unref?.();
|
|
1252
|
+
timeoutHardKillTimer = setTimeout(() => {
|
|
1253
|
+
if (processClosed || lifecycleFinished) return;
|
|
1254
|
+
trySignalChild(proc, "SIGKILL");
|
|
1255
|
+
}, 4000);
|
|
1256
|
+
timeoutHardKillTimer.unref?.();
|
|
1257
|
+
}, attemptTimeout.remainingMs);
|
|
1258
|
+
timeoutTimer.unref?.();
|
|
1259
|
+
}
|
|
1260
|
+
|
|
1261
|
+
let toolTimeoutSequence = 0;
|
|
1262
|
+
const activeToolTimeouts = new Map<string, { toolName: string; timer: ReturnType<typeof setTimeout> }>();
|
|
1263
|
+
const activeToolTimeoutKeysByName = new Map<string, string[]>();
|
|
1264
|
+
let toolTimeoutTerminationTimer: ReturnType<typeof setTimeout> | undefined;
|
|
1265
|
+
let toolTimeoutHardKillTimer: ReturnType<typeof setTimeout> | undefined;
|
|
1266
|
+
const removeToolTimeoutKey = (key: string): void => {
|
|
1267
|
+
const active = activeToolTimeouts.get(key);
|
|
1268
|
+
if (!active) return;
|
|
1269
|
+
clearTimeout(active.timer);
|
|
1270
|
+
activeToolTimeouts.delete(key);
|
|
1271
|
+
const keys = activeToolTimeoutKeysByName.get(active.toolName)?.filter((candidate) => candidate !== key) ?? [];
|
|
1272
|
+
if (keys.length > 0) activeToolTimeoutKeysByName.set(active.toolName, keys);
|
|
1273
|
+
else activeToolTimeoutKeysByName.delete(active.toolName);
|
|
1274
|
+
};
|
|
1275
|
+
const clearActiveToolTimeout = (event: { toolCallId?: unknown; toolName?: unknown }): void => {
|
|
1276
|
+
const key = typeof event.toolCallId === "string" && event.toolCallId.length > 0
|
|
1277
|
+
? `id:${event.toolCallId}`
|
|
1278
|
+
: typeof event.toolName === "string"
|
|
1279
|
+
? activeToolTimeoutKeysByName.get(event.toolName)?.[0]
|
|
1280
|
+
: activeToolTimeouts.size === 1
|
|
1281
|
+
? [...activeToolTimeouts.keys()][0]
|
|
1282
|
+
: undefined;
|
|
1283
|
+
if (key) removeToolTimeoutKey(key);
|
|
1284
|
+
};
|
|
1285
|
+
const clearAllToolTimeouts = (): void => {
|
|
1286
|
+
for (const key of [...activeToolTimeouts.keys()]) removeToolTimeoutKey(key);
|
|
1287
|
+
if (toolTimeoutTerminationTimer) {
|
|
1288
|
+
clearTimeout(toolTimeoutTerminationTimer);
|
|
1289
|
+
toolTimeoutTerminationTimer = undefined;
|
|
1290
|
+
}
|
|
1291
|
+
if (toolTimeoutHardKillTimer) {
|
|
1292
|
+
clearTimeout(toolTimeoutHardKillTimer);
|
|
1293
|
+
toolTimeoutHardKillTimer = undefined;
|
|
1294
|
+
}
|
|
1295
|
+
};
|
|
1296
|
+
const terminateForToolTimeout = (message: string): void => {
|
|
1297
|
+
if (processClosed || lifecycleFinished || interruptedByControl) return;
|
|
1298
|
+
result.timedOut = true;
|
|
1299
|
+
result.error = message;
|
|
1300
|
+
result.finalOutput = message;
|
|
1301
|
+
progress.status = "failed";
|
|
1302
|
+
progress.error = message;
|
|
1303
|
+
progress.durationMs = Date.now() - startTime;
|
|
1304
|
+
fireUpdate();
|
|
1305
|
+
trySignalChild(proc, "SIGINT");
|
|
1306
|
+
toolTimeoutTerminationTimer = setTimeout(() => {
|
|
1307
|
+
if (processClosed || lifecycleFinished) return;
|
|
1308
|
+
trySignalChild(proc, "SIGTERM");
|
|
1309
|
+
}, 1000);
|
|
1310
|
+
toolTimeoutTerminationTimer.unref?.();
|
|
1311
|
+
toolTimeoutHardKillTimer = setTimeout(() => {
|
|
1312
|
+
if (processClosed || lifecycleFinished) return;
|
|
1313
|
+
trySignalChild(proc, "SIGKILL");
|
|
1314
|
+
}, 4000);
|
|
1315
|
+
toolTimeoutHardKillTimer.unref?.();
|
|
1316
|
+
};
|
|
1317
|
+
const armToolTimeout = (event: { toolCallId?: unknown; toolName: string }): void => {
|
|
1318
|
+
const timeoutForTool = effectiveToolTimeoutMs(event.toolName, options.toolTimeoutMs);
|
|
1319
|
+
if (timeoutForTool === undefined) return;
|
|
1320
|
+
const elapsed = Date.now() - startTime;
|
|
1321
|
+
const runRemaining = attemptTimeout ? Math.max(0, attemptTimeout.remainingMs - elapsed) : undefined;
|
|
1322
|
+
if (runRemaining !== undefined && timeoutForTool >= runRemaining) return;
|
|
1323
|
+
const key = toolTimeoutCallKey(event, ++toolTimeoutSequence);
|
|
1324
|
+
const toolName = event.toolName;
|
|
1325
|
+
const timer = setTimeout(() => {
|
|
1326
|
+
removeToolTimeoutKey(key);
|
|
1327
|
+
terminateForToolTimeout(formatToolTimeoutMessage(toolName, timeoutForTool));
|
|
1328
|
+
}, timeoutForTool);
|
|
1329
|
+
timer.unref?.();
|
|
1330
|
+
activeToolTimeouts.set(key, { toolName, timer });
|
|
1331
|
+
const keys = activeToolTimeoutKeysByName.get(toolName) ?? [];
|
|
1332
|
+
keys.push(key);
|
|
1333
|
+
activeToolTimeoutKeysByName.set(toolName, keys);
|
|
1334
|
+
};
|
|
1335
|
+
|
|
1336
|
+
const stderrTail = createBoundedByteTail();
|
|
1337
|
+
const failProtocol = (limit: ProtocolOutputLimit): void => {
|
|
1338
|
+
if (result.protocolError) return;
|
|
1339
|
+
result.protocolError = limit;
|
|
1340
|
+
result.error = formatProtocolOutputLimit(limit);
|
|
1341
|
+
progress.status = "failed";
|
|
1342
|
+
progress.error = result.error;
|
|
1343
|
+
progress.durationMs = Date.now() - startTime;
|
|
1344
|
+
fireUpdate();
|
|
1345
|
+
if (!childExited) {
|
|
1346
|
+
trySignalChild(proc, "SIGTERM");
|
|
1347
|
+
protocolHardKillTimer = setTimeout(() => {
|
|
1348
|
+
if (!childExited) trySignalChild(proc, "SIGKILL");
|
|
1349
|
+
}, 3000);
|
|
1350
|
+
protocolHardKillTimer.unref?.();
|
|
1351
|
+
}
|
|
1352
|
+
};
|
|
1353
|
+
const stdoutReader = createBoundedLineReader({
|
|
1354
|
+
oversizedLineProjector: PI_AGGREGATE_EVENT_PROJECTOR,
|
|
1355
|
+
onLine: processLine,
|
|
1356
|
+
onLimit: failProtocol,
|
|
1357
|
+
});
|
|
1358
|
+
const stderrReader = createBoundedLineReader({
|
|
1359
|
+
stream: "stderr",
|
|
1360
|
+
maxPendingLineBytes: MAX_CHILD_STDERR_BYTES,
|
|
1361
|
+
onLine: (line) => shared.transcriptWriter?.writeStderrLine(line),
|
|
1362
|
+
onLimit: (limit) => shared.transcriptWriter?.writeStderrLine(formatProtocolOutputLimit(limit)),
|
|
1363
|
+
});
|
|
1364
|
+
|
|
1365
|
+
const clearStdioGuard = attachPostExitStdioGuard(proc, { idleMs: 2000, hardMs: 8000 });
|
|
1366
|
+
proc.stdout.on("data", (chunk: Buffer) => stdoutReader.push(chunk));
|
|
1367
|
+
proc.stderr.on("data", (chunk: Buffer) => {
|
|
1368
|
+
stderrTail.push(chunk);
|
|
1369
|
+
stderrReader.push(chunk);
|
|
1370
|
+
shared.orcaProgressTab?.append(chunk.toString("utf-8"));
|
|
1371
|
+
});
|
|
1372
|
+
proc.on("exit", () => {
|
|
1373
|
+
childExited = true;
|
|
1374
|
+
clearFinalDrainTimers();
|
|
1375
|
+
});
|
|
1376
|
+
proc.on("close", (code, signal) => {
|
|
1377
|
+
if (lifecycleFinished) return;
|
|
1378
|
+
processClosed = true;
|
|
1379
|
+
clearFinalDrainTimers();
|
|
1380
|
+
clearStdioGuard();
|
|
1381
|
+
void jsonlWriter.close().catch(() => {
|
|
1382
|
+
// JSONL artifact flush is best effort.
|
|
1383
|
+
});
|
|
1384
|
+
const toolDiagnosticError = readChildToolDiagnosticError(toolDiagnosticPath);
|
|
1385
|
+
toolAvailabilityError = toolDiagnosticError;
|
|
1386
|
+
result.runtimeAcknowledgedExtensions = readRuntimeAcknowledgedExtensions(runtimeAcknowledgedExtensionsPath);
|
|
1387
|
+
cleanupTempDir(tempDir);
|
|
1388
|
+
stdoutReader.end();
|
|
1389
|
+
stderrReader.end();
|
|
1390
|
+
const stderr = stderrTail.text();
|
|
1391
|
+
const rawStdout = rawStdoutTail.text();
|
|
1392
|
+
let closeError = result.error ?? toolDiagnosticError ?? assistantError;
|
|
1393
|
+
const forcedDrainAfterFinalSuccess = Boolean(forcedTerminationSignal || signal) && (cleanTerminalAssistantStopReceived || agentSettledReceived) && !closeError;
|
|
1394
|
+
const forcedDrainAfterEmptyTerminal = forcedDrainAfterFinalSuccess && hasEmptyTerminalAssistantResponse(result.messages ?? []);
|
|
1395
|
+
if (signal) result.processSignal = signal;
|
|
1396
|
+
if (!closeError && forcedDrainAfterEmptyTerminal && stderr.trim()) {
|
|
1397
|
+
closeError = stderr.trim();
|
|
1398
|
+
}
|
|
1399
|
+
if (!closeError && isUnexplainedProcessSignal({
|
|
1400
|
+
processSignal: signal,
|
|
1401
|
+
interrupted: result.interrupted,
|
|
1402
|
+
timedOut: result.timedOut,
|
|
1403
|
+
stopped: result.stopped,
|
|
1404
|
+
forcedDrainAfterFinalSuccess: forcedDrainAfterFinalSuccess && !forcedDrainAfterEmptyTerminal,
|
|
1405
|
+
})) {
|
|
1406
|
+
closeError = formatProcessSignalError(signal!);
|
|
1407
|
+
}
|
|
1408
|
+
if (code !== 0 && rawStdout.trim() && !closeError && !forcedDrainAfterFinalSuccess) {
|
|
1409
|
+
closeError = rawStdout.trim();
|
|
1410
|
+
}
|
|
1411
|
+
if (code !== 0 && stderr.trim() && !closeError && !forcedDrainAfterFinalSuccess) {
|
|
1412
|
+
closeError = stderr.trim();
|
|
1413
|
+
}
|
|
1414
|
+
const finalCode = forcedDrainAfterFinalSuccess && !forcedDrainAfterEmptyTerminal ? 0 : forcedTerminationSignal || signal ? (code ?? 1) : (code ?? 0);
|
|
1415
|
+
if (!result.error && closeError) result.error = closeError;
|
|
1416
|
+
finish(finalCode);
|
|
1417
|
+
});
|
|
1418
|
+
proc.on("error", (error) => {
|
|
1419
|
+
if (lifecycleFinished) return;
|
|
1420
|
+
processClosed = true;
|
|
1421
|
+
clearFinalDrainTimers();
|
|
1422
|
+
clearStdioGuard();
|
|
1423
|
+
void jsonlWriter.close().catch(() => {
|
|
1424
|
+
// JSONL artifact flush is best effort.
|
|
1425
|
+
});
|
|
1426
|
+
cleanupTempDir(tempDir);
|
|
1427
|
+
stdoutReader.end();
|
|
1428
|
+
stderrReader.end();
|
|
1429
|
+
if (!result.error) {
|
|
1430
|
+
result.error = error instanceof Error ? error.message : String(error);
|
|
1431
|
+
}
|
|
1432
|
+
finish(1);
|
|
1433
|
+
});
|
|
1434
|
+
|
|
1435
|
+
if (options.signal) {
|
|
1436
|
+
const kill = () => {
|
|
1437
|
+
if (processClosed || lifecycleFinished) return;
|
|
1438
|
+
abortedBySignal = true;
|
|
1439
|
+
proc.kill("SIGTERM");
|
|
1440
|
+
setTimeout(() => !proc.killed && proc.kill("SIGKILL"), 3000);
|
|
1441
|
+
};
|
|
1442
|
+
if (options.signal.aborted) kill();
|
|
1443
|
+
else {
|
|
1444
|
+
options.signal.addEventListener("abort", kill, { once: true });
|
|
1445
|
+
removeAbortListener = () => options.signal?.removeEventListener("abort", kill);
|
|
1446
|
+
}
|
|
1447
|
+
}
|
|
1448
|
+
|
|
1449
|
+
if (options.interruptSignal) {
|
|
1450
|
+
const interrupt = () => {
|
|
1451
|
+
if (processClosed || lifecycleFinished) return;
|
|
1452
|
+
if (result.timedOut) return;
|
|
1453
|
+
interruptedByControl = true;
|
|
1454
|
+
clearTimeoutTimers();
|
|
1455
|
+
clearAllToolTimeouts();
|
|
1456
|
+
progress.status = "running";
|
|
1457
|
+
progress.durationMs = Date.now() - startTime;
|
|
1458
|
+
result.interrupted = true;
|
|
1459
|
+
result.finalOutput = "Interrupted. Waiting for explicit next action.";
|
|
1460
|
+
progress.activityState = undefined;
|
|
1461
|
+
fireUpdate();
|
|
1462
|
+
trySignalChild(proc, "SIGINT");
|
|
1463
|
+
setTimeout(() => {
|
|
1464
|
+
if (lifecycleFinished || processClosed) return;
|
|
1465
|
+
trySignalChild(proc, "SIGTERM");
|
|
1466
|
+
}, 1000).unref?.();
|
|
1467
|
+
};
|
|
1468
|
+
if (options.interruptSignal.aborted) interrupt();
|
|
1469
|
+
else {
|
|
1470
|
+
options.interruptSignal.addEventListener("abort", interrupt, { once: true });
|
|
1471
|
+
removeInterruptListener = () => options.interruptSignal?.removeEventListener("abort", interrupt);
|
|
1472
|
+
}
|
|
1473
|
+
}
|
|
1474
|
+
|
|
1475
|
+
// Publish only after every callback and cleanup guard captured by detach or
|
|
1476
|
+
// later lifecycle events has initialized. Consumers may invoke synchronously.
|
|
1477
|
+
try {
|
|
1478
|
+
options.onDetachReady?.((reason = "user request") => detachForeground(reason));
|
|
1479
|
+
} catch (error) {
|
|
1480
|
+
// A consumer callback is advisory. Keep the child attached and observable
|
|
1481
|
+
// rather than rejecting this attempt and orphaning its live process.
|
|
1482
|
+
appendRecentOutput(progress, [`Foreground detach callback failed: ${error instanceof Error ? error.message : String(error)}`]);
|
|
1483
|
+
}
|
|
1484
|
+
});
|
|
1485
|
+
result.exitCode = exitCode;
|
|
1486
|
+
if (afterCompactionSettlement) {
|
|
1487
|
+
(result as AbortRecoverySingleResult)[AFTER_COMPACTION_SETTLEMENT] = true;
|
|
1488
|
+
}
|
|
1489
|
+
if (interruptedByControl) {
|
|
1490
|
+
result.exitCode = 0;
|
|
1491
|
+
result.interrupted = true;
|
|
1492
|
+
result.error = undefined;
|
|
1493
|
+
result.finalOutput = result.finalOutput || "Interrupted. Waiting for explicit next action.";
|
|
1494
|
+
result.controlEvents = allControlEvents.length ? allControlEvents : undefined;
|
|
1495
|
+
progress.activityState = undefined;
|
|
1496
|
+
progress.durationMs = Date.now() - startTime;
|
|
1497
|
+
result.progressSummary = {
|
|
1498
|
+
toolCount: progress.toolCount,
|
|
1499
|
+
tokens: progress.tokens,
|
|
1500
|
+
durationMs: progress.durationMs,
|
|
1501
|
+
};
|
|
1502
|
+
return result;
|
|
1503
|
+
}
|
|
1504
|
+
if (progress.currentTool
|
|
1505
|
+
&& isOrdinaryToolForMidToolExit(progress.currentTool)
|
|
1506
|
+
&& !abortedBySignal
|
|
1507
|
+
&& !result.timedOut
|
|
1508
|
+
&& !result.stopped
|
|
1509
|
+
&& !result.protocolError
|
|
1510
|
+
&& !toolAvailabilityError) {
|
|
1511
|
+
const processExitCode = result.exitCode;
|
|
1512
|
+
result.exitCode = 1;
|
|
1513
|
+
result.error = formatMidToolExitError({
|
|
1514
|
+
toolName: progress.currentTool,
|
|
1515
|
+
exitCode: processExitCode,
|
|
1516
|
+
processSignal: result.processSignal,
|
|
1517
|
+
});
|
|
1518
|
+
}
|
|
1519
|
+
result.error = formatSubagentExtensionConflictError(result.error, {
|
|
1520
|
+
agent: agent.name,
|
|
1521
|
+
ambientExtensionsEnabled: !launchResolvedExtensions.disableAmbientExtensions,
|
|
1522
|
+
});
|
|
1523
|
+
if (result.error && result.exitCode === 0) {
|
|
1524
|
+
result.exitCode = 1;
|
|
1525
|
+
}
|
|
1526
|
+
let validatedStructuredOutput = false;
|
|
1527
|
+
if (options.structuredOutput && result.exitCode === 0 && !result.error) {
|
|
1528
|
+
result.structuredOutputSchemaPath = options.structuredOutput.schemaPath;
|
|
1529
|
+
result.structuredOutputPath = options.structuredOutput.outputPath;
|
|
1530
|
+
if (!structuredOutputToolInvoked) {
|
|
1531
|
+
result.exitCode = 1;
|
|
1532
|
+
result.error = MISSING_STRUCTURED_OUTPUT_CALL_ERROR;
|
|
1533
|
+
result.structuredOutputFailed = true;
|
|
1534
|
+
} else {
|
|
1535
|
+
const structured = await readStructuredOutput({
|
|
1536
|
+
schema: options.structuredOutput.schema,
|
|
1537
|
+
schemaPath: options.structuredOutput.schemaPath,
|
|
1538
|
+
outputPath: options.structuredOutput.outputPath,
|
|
1539
|
+
});
|
|
1540
|
+
if (structured.error) {
|
|
1541
|
+
result.exitCode = 1;
|
|
1542
|
+
result.error = structured.error;
|
|
1543
|
+
result.structuredOutputFailed = true;
|
|
1544
|
+
} else {
|
|
1545
|
+
result.structuredOutput = structured.value;
|
|
1546
|
+
const acceptanceReport = readStructuredOutputAcceptanceReport(options.structuredOutput);
|
|
1547
|
+
(result as SingleResult & { structuredAcceptanceReport?: unknown; structuredAcceptanceReportError?: string }).structuredAcceptanceReport = acceptanceReport.value;
|
|
1548
|
+
(result as SingleResult & { structuredAcceptanceReport?: unknown; structuredAcceptanceReportError?: string }).structuredAcceptanceReportError = acceptanceReport.error;
|
|
1549
|
+
validatedStructuredOutput = true;
|
|
1550
|
+
}
|
|
1551
|
+
}
|
|
1552
|
+
}
|
|
1553
|
+
if (result.exitCode === 0 && !result.error) {
|
|
1554
|
+
const messages = result.messages ?? [];
|
|
1555
|
+
const finalText = getFinalOutput(messages);
|
|
1556
|
+
const errorMessages = validatedStructuredOutput
|
|
1557
|
+
? messages.slice(structuredOutputMessageStartIndex ?? messages.length)
|
|
1558
|
+
: messages;
|
|
1559
|
+
const errInfo = detectSubagentError(errorMessages);
|
|
1560
|
+
const missingOutput = !finalText?.trim() && !validatedStructuredOutput;
|
|
1561
|
+
const terminalEmptyAfterUsefulWork = !validatedStructuredOutput
|
|
1562
|
+
&& hasEmptyTerminalAssistantResponse(messages)
|
|
1563
|
+
&& (progress.toolCount > 0 || Boolean(finalText?.trim()));
|
|
1564
|
+
if ((missingOutput || terminalEmptyAfterUsefulWork) && (!errInfo.hasError || hasEmptyTerminalAssistantResponse(messages))) {
|
|
1565
|
+
result.exitCode = 1;
|
|
1566
|
+
result.error = formatEmptyTerminalAssistantResponseError(messages);
|
|
1567
|
+
} else if (errInfo.hasError) {
|
|
1568
|
+
result.exitCode = errInfo.exitCode ?? 1;
|
|
1569
|
+
result.error = errInfo.details
|
|
1570
|
+
? `${errInfo.errorType} failed (exit ${errInfo.exitCode}): ${errInfo.details}`
|
|
1571
|
+
: `${errInfo.errorType} failed with exit code ${errInfo.exitCode}`;
|
|
1572
|
+
}
|
|
1573
|
+
}
|
|
1574
|
+
|
|
1575
|
+
progress.status = result.exitCode === 0 ? "completed" : "failed";
|
|
1576
|
+
progress.durationMs = Date.now() - startTime;
|
|
1577
|
+
if (result.error) {
|
|
1578
|
+
progress.error = result.error;
|
|
1579
|
+
if (progress.currentTool) {
|
|
1580
|
+
progress.failedTool = progress.currentTool;
|
|
1581
|
+
}
|
|
1582
|
+
}
|
|
1583
|
+
|
|
1584
|
+
result.progressSummary = {
|
|
1585
|
+
...(childSessionName ? { sessionName: childSessionName } : {}),
|
|
1586
|
+
toolCount: progress.toolCount,
|
|
1587
|
+
tokens: progress.tokens,
|
|
1588
|
+
durationMs: progress.durationMs,
|
|
1589
|
+
};
|
|
1590
|
+
const mutationEvidence = collectTrackedMutationEvidence(mutationSnapshot, options.cwd ?? runtimeCwd);
|
|
1591
|
+
|
|
1592
|
+
const acceptanceOutput = getFinalOutput(result.messages ?? []);
|
|
1593
|
+
let fullOutput = stripAcceptanceReport(acceptanceOutput);
|
|
1594
|
+
if (!fullOutput.trim() && result.structuredOutput !== undefined) fullOutput = JSON.stringify(result.structuredOutput, null, 2);
|
|
1595
|
+
result.outputState = fullOutput.trim() || result.structuredOutput !== undefined ? "present" : "absent";
|
|
1596
|
+
if (result.timedOut) {
|
|
1597
|
+
const timeoutMessage = formatTimeoutMessage(options.timeoutMs ?? 0);
|
|
1598
|
+
let requiredOutputMissing: boolean | undefined;
|
|
1599
|
+
if (options.outputMode === "file-only" && options.outputPath) {
|
|
1600
|
+
const outputChanged = hasSingleOutputChangedSinceSnapshot(options.outputPath, shared.outputSnapshot);
|
|
1601
|
+
requiredOutputMissing = outputChanged === undefined ? undefined : !outputChanged;
|
|
1602
|
+
} else if (options.structuredOutput) {
|
|
1603
|
+
requiredOutputMissing = !existsSync(options.structuredOutput.outputPath);
|
|
1604
|
+
}
|
|
1605
|
+
result.timeoutRecovery = buildTimeoutRecoverySummary({
|
|
1606
|
+
termination: "timed-out",
|
|
1607
|
+
evidence: mutationEvidence,
|
|
1608
|
+
requiredOutputMissing,
|
|
1609
|
+
currentTool: progress.currentTool,
|
|
1610
|
+
currentToolArgs: progress.currentToolArgs,
|
|
1611
|
+
currentPath: progress.currentPath,
|
|
1612
|
+
sessionFile: options.sessionFile,
|
|
1613
|
+
transcriptPath: shared.transcriptWriter ? shared.artifactPaths?.transcriptPath : undefined,
|
|
1614
|
+
artifactPaths: shared.artifactPaths,
|
|
1615
|
+
});
|
|
1616
|
+
fullOutput = fullOutput.trim()
|
|
1617
|
+
? `${timeoutMessage}\n\n${result.timeoutRecovery.message}\n\nPartial output before timeout:\n${fullOutput}`
|
|
1618
|
+
: `${timeoutMessage}\n\n${result.timeoutRecovery.message}`;
|
|
1619
|
+
}
|
|
1620
|
+
const completionGuardEnabled = isAgentContractV1(options.agentContract) ? agent.completionGuard === true : agent.completionGuard !== false;
|
|
1621
|
+
const completionGuard = ((result.exitCode === 0 && !result.error) || toolAvailabilityError) && completionGuardEnabled
|
|
1622
|
+
? evaluateCompletionMutationGuard({
|
|
1623
|
+
agent: agent.name,
|
|
1624
|
+
task: shared.originalTask ?? task,
|
|
1625
|
+
messages: result.messages ?? [],
|
|
1626
|
+
tools: contractTools,
|
|
1627
|
+
mcpDirectTools: toolPlan.effectiveMcpTools,
|
|
1628
|
+
mutationTools: agent.mutationTools,
|
|
1629
|
+
toolAvailabilityError,
|
|
1630
|
+
mutationEvidence,
|
|
1631
|
+
})
|
|
1632
|
+
: undefined;
|
|
1633
|
+
const mutationAttemptObserved = observedMutationAttempt || mutationEvidence.attemptedMutation;
|
|
1634
|
+
let completionGuardTriggered = completionGuard?.triggered === true && !mutationAttemptObserved;
|
|
1635
|
+
// The classifier is deliberately narrow, so a read-only review task can
|
|
1636
|
+
// still be misread as implementation. Arbitrate BEFORE any failure side
|
|
1637
|
+
// effect is published (effects, exit code, progress, notifications,
|
|
1638
|
+
// acceptance, output persistence): only a confident read-only verdict
|
|
1639
|
+
// rescues, and the task text alone is evidence — never the child's own
|
|
1640
|
+
// final message.
|
|
1641
|
+
let arbiterRescued = false;
|
|
1642
|
+
if (completionGuardTriggered) {
|
|
1643
|
+
const arbitration = await arbitrateCompletionGuardRescue({
|
|
1644
|
+
guardTriggered: true,
|
|
1645
|
+
task: shared.originalTask ?? task,
|
|
1646
|
+
arbiter: options.llmIntentArbiter,
|
|
1647
|
+
});
|
|
1648
|
+
completionGuardTriggered = arbitration.triggered;
|
|
1649
|
+
arbiterRescued = arbitration.rescued;
|
|
1650
|
+
}
|
|
1651
|
+
const completionEvidence = planCompletionEvidence({
|
|
1652
|
+
guard: completionGuard,
|
|
1653
|
+
guardTriggered: completionGuardTriggered,
|
|
1654
|
+
completionGuardEnabled,
|
|
1655
|
+
mutationCapable: hasMutationToolCapability(contractTools, toolPlan.effectiveMcpTools),
|
|
1656
|
+
implementationMutationExpected: expectsImplementationMutation(agent.name, shared.originalTask ?? task),
|
|
1657
|
+
mutationAttemptObserved,
|
|
1658
|
+
mutationEvidence,
|
|
1659
|
+
arbiterRescued,
|
|
1660
|
+
agentContractV1: isAgentContractV1(options.agentContract),
|
|
1661
|
+
});
|
|
1662
|
+
if (completionEvidence.fileMutation) {
|
|
1663
|
+
result.effects = {
|
|
1664
|
+
...(result.effects ?? {}),
|
|
1665
|
+
fileMutation: completionEvidence.fileMutation,
|
|
1666
|
+
};
|
|
1667
|
+
}
|
|
1668
|
+
if (completionEvidence.legacyFailureError) {
|
|
1669
|
+
result.exitCode = 1;
|
|
1670
|
+
result.error = completionEvidence.legacyFailureError;
|
|
1671
|
+
progress.status = "failed";
|
|
1672
|
+
progress.error = result.error;
|
|
1673
|
+
emitControlEvent(buildControlEvent({
|
|
1674
|
+
from: progress.activityState,
|
|
1675
|
+
to: "needs_attention",
|
|
1676
|
+
runId: options.runId ?? agent.name,
|
|
1677
|
+
agent: agent.name,
|
|
1678
|
+
index: options.index,
|
|
1679
|
+
ts: Date.now(),
|
|
1680
|
+
message: `${agent.name} completed without making edits for an implementation task`,
|
|
1681
|
+
reason: "completion_guard",
|
|
1682
|
+
}));
|
|
1683
|
+
}
|
|
1684
|
+
if (options.outputPath && result.exitCode === 0) {
|
|
1685
|
+
const resolvedOutput = resolveSingleOutput(options.outputPath, fullOutput, shared.outputSnapshot, options.outputClaimPath);
|
|
1686
|
+
fullOutput = stripAcceptanceReport(resolvedOutput.fullOutput);
|
|
1687
|
+
result.savedOutputPath = resolvedOutput.savedPath;
|
|
1688
|
+
result.outputSaveError = resolvedOutput.saveError;
|
|
1689
|
+
if (resolvedOutput.fatalError) {
|
|
1690
|
+
result.exitCode = 1;
|
|
1691
|
+
result.error = result.error ? `${result.error}\n${resolvedOutput.saveError}` : resolvedOutput.saveError;
|
|
1692
|
+
}
|
|
1693
|
+
if (resolvedOutput.savedPath) {
|
|
1694
|
+
result.outputReference = formatSavedOutputReference(resolvedOutput.savedPath, fullOutput);
|
|
1695
|
+
if (result.outputState === "absent") result.outputState = "unknown";
|
|
1696
|
+
}
|
|
1697
|
+
}
|
|
1698
|
+
artifactOutputByResult.set(result, fullOutput);
|
|
1699
|
+
acceptanceOutputByResult.set(result, acceptanceOutput);
|
|
1700
|
+
result.outputMode = options.outputMode ?? "inline";
|
|
1701
|
+
result.finalOutput = options.outputMode === "file-only" && result.savedOutputPath && result.outputReference
|
|
1702
|
+
? result.outputReference.message
|
|
1703
|
+
: fullOutput;
|
|
1704
|
+
result.controlEvents = allControlEvents.length ? allControlEvents : undefined;
|
|
1705
|
+
if (options.onUpdate) {
|
|
1706
|
+
const finalText = result.finalOutput || result.error || "(no output)";
|
|
1707
|
+
const progressSnapshot = snapshotProgress(progress);
|
|
1708
|
+
const resultSnapshot = snapshotStreamResult(result, progressSnapshot);
|
|
1709
|
+
options.onUpdate({
|
|
1710
|
+
content: [{ type: "text", text: finalText }],
|
|
1711
|
+
details: {
|
|
1712
|
+
mode: "single",
|
|
1713
|
+
results: [resultSnapshot],
|
|
1714
|
+
progress: [progressSnapshot],
|
|
1715
|
+
controlEvents: allControlEvents.length ? allControlEvents : undefined,
|
|
1716
|
+
},
|
|
1717
|
+
});
|
|
1718
|
+
}
|
|
1719
|
+
return result;
|
|
1720
|
+
}
|
|
1721
|
+
|
|
1722
|
+
/**
|
|
1723
|
+
* Run a subagent synchronously (blocking until complete)
|
|
1724
|
+
*/
|
|
1725
|
+
async function runSyncCompletionInner(
|
|
1726
|
+
runtimeCwd: string,
|
|
1727
|
+
agents: AgentConfig[],
|
|
1728
|
+
agentName: string,
|
|
1729
|
+
task: string,
|
|
1730
|
+
options: RunSyncOptions,
|
|
1731
|
+
): Promise<SingleResult> {
|
|
1732
|
+
const effectiveCwd = options.cwd ?? runtimeCwd;
|
|
1733
|
+
const cwdError = preflightLaunchCwd(options.requestedCwd ?? effectiveCwd, effectiveCwd);
|
|
1734
|
+
if (cwdError) {
|
|
1735
|
+
return redactResultPrompt(withRunContext({
|
|
1736
|
+
index: options.index ?? 0,
|
|
1737
|
+
agent: agentName,
|
|
1738
|
+
task,
|
|
1739
|
+
exitCode: 1,
|
|
1740
|
+
messages: [],
|
|
1741
|
+
usage: emptyUsage(),
|
|
1742
|
+
error: cwdError,
|
|
1743
|
+
}, options.context));
|
|
1744
|
+
}
|
|
1745
|
+
options = {
|
|
1746
|
+
...options,
|
|
1747
|
+
capabilityCeiling: intersectSubagentCapabilityCeilings(options.capabilityCeiling ?? resolveCurrentSubagentCapabilityCeiling(options.parentSessionId), decodeSubagentCapabilityCeiling(process.env[SUBAGENT_CAPABILITY_CEILING_ENV])),
|
|
1748
|
+
};
|
|
1749
|
+
const childSessionName = deriveChildSessionName({ agent: agentName, task });
|
|
1750
|
+
const agent = agents.find((a) => a.name === agentName);
|
|
1751
|
+
if (!agent) {
|
|
1752
|
+
const diagnosticContext = options.unknownAgentDiagnosticContext
|
|
1753
|
+
?? unknownAgentDiagnosticContext(discoverAgents(path.resolve(options.cwd ?? runtimeCwd), "both"));
|
|
1754
|
+
return redactResultPrompt(withRunContext({
|
|
1755
|
+
index: options.index ?? 0,
|
|
1756
|
+
agent: agentName,
|
|
1757
|
+
task,
|
|
1758
|
+
exitCode: 1,
|
|
1759
|
+
messages: [],
|
|
1760
|
+
usage: emptyUsage(),
|
|
1761
|
+
error: formatUnknownAgentError(agentName, diagnosticContext),
|
|
1762
|
+
}, options.context));
|
|
1763
|
+
}
|
|
1764
|
+
options = {
|
|
1765
|
+
...options,
|
|
1766
|
+
thinkingCeiling: intersectThinkingCeilings(
|
|
1767
|
+
options.thinkingCeiling,
|
|
1768
|
+
agent.maxThinking,
|
|
1769
|
+
decodeThinkingCeiling(process.env[SUBAGENT_THINKING_CEILING_ENV]),
|
|
1770
|
+
),
|
|
1771
|
+
};
|
|
1772
|
+
try {
|
|
1773
|
+
assertAgentAllowedByCapabilityCeiling(agent.name, options.capabilityCeiling);
|
|
1774
|
+
} catch (error) {
|
|
1775
|
+
return redactResultPrompt(withRunContext({
|
|
1776
|
+
index: options.index ?? 0,
|
|
1777
|
+
agent: agent.name,
|
|
1778
|
+
task,
|
|
1779
|
+
exitCode: 1,
|
|
1780
|
+
messages: [],
|
|
1781
|
+
usage: emptyUsage(),
|
|
1782
|
+
error: error instanceof Error ? error.message : String(error),
|
|
1783
|
+
...(options.capabilityCeiling ? { capabilityCeiling: options.capabilityCeiling } : {}),
|
|
1784
|
+
}, options.context));
|
|
1785
|
+
}
|
|
1786
|
+
const acceptanceErrors = validateAcceptanceInput(options.acceptance);
|
|
1787
|
+
if (acceptanceErrors.length > 0) {
|
|
1788
|
+
return redactResultPrompt(withRunContext({
|
|
1789
|
+
index: options.index ?? 0,
|
|
1790
|
+
agent: agentName,
|
|
1791
|
+
task,
|
|
1792
|
+
exitCode: 1,
|
|
1793
|
+
messages: [],
|
|
1794
|
+
usage: emptyUsage(),
|
|
1795
|
+
error: acceptanceErrors.join(" "),
|
|
1796
|
+
}, options.context));
|
|
1797
|
+
}
|
|
1798
|
+
const toolTimeout = resolveToolTimeoutMs({
|
|
1799
|
+
callValue: options.toolTimeoutMs,
|
|
1800
|
+
agentValue: agent.defaultToolTimeoutMs,
|
|
1801
|
+
configValue: options.configToolTimeoutMs,
|
|
1802
|
+
envValue: toolTimeoutFromEnv(),
|
|
1803
|
+
});
|
|
1804
|
+
if (toolTimeout.error) {
|
|
1805
|
+
return redactResultPrompt(withRunContext({
|
|
1806
|
+
index: options.index ?? 0,
|
|
1807
|
+
agent: agentName,
|
|
1808
|
+
task,
|
|
1809
|
+
exitCode: 1,
|
|
1810
|
+
messages: [],
|
|
1811
|
+
usage: emptyUsage(),
|
|
1812
|
+
error: toolTimeout.error,
|
|
1813
|
+
}, options.context));
|
|
1814
|
+
}
|
|
1815
|
+
options = { ...options, toolTimeoutMs: toolTimeout.toolTimeoutMs };
|
|
1816
|
+
const outputModeValidationError = validateFileOnlyOutputMode(options.outputMode, options.outputPath, `Single run (${agentName})`);
|
|
1817
|
+
if (outputModeValidationError) {
|
|
1818
|
+
return redactResultPrompt(withRunContext({
|
|
1819
|
+
index: options.index ?? 0,
|
|
1820
|
+
agent: agentName,
|
|
1821
|
+
task,
|
|
1822
|
+
exitCode: 1,
|
|
1823
|
+
messages: [],
|
|
1824
|
+
usage: emptyUsage(),
|
|
1825
|
+
outputMode: options.outputMode,
|
|
1826
|
+
error: outputModeValidationError,
|
|
1827
|
+
}, options.context));
|
|
1828
|
+
}
|
|
1829
|
+
|
|
1830
|
+
const shareEnabled = options.share === true;
|
|
1831
|
+
const effectiveAcceptance = resolveEffectiveAcceptance({
|
|
1832
|
+
explicit: options.acceptance,
|
|
1833
|
+
agentName,
|
|
1834
|
+
acceptanceRole: agent.acceptanceRole,
|
|
1835
|
+
task,
|
|
1836
|
+
mode: options.acceptanceContext?.mode ?? "single",
|
|
1837
|
+
async: options.acceptanceContext?.async,
|
|
1838
|
+
dynamic: options.acceptanceContext?.dynamic,
|
|
1839
|
+
dynamicGroup: options.acceptanceContext?.dynamicGroup,
|
|
1840
|
+
agentContract: options.agentContract,
|
|
1841
|
+
});
|
|
1842
|
+
const acceptancePrompt = formatAcceptancePrompt(effectiveAcceptance, { reportOptional: isAgentContractV1(options.agentContract), structuredOutput: Boolean(options.structuredOutput?.acceptanceReportPath) });
|
|
1843
|
+
const taskWithAcceptance = acceptancePrompt ? `${task}\n${acceptancePrompt}` : task;
|
|
1844
|
+
options.onEffectivePrompt?.(taskWithAcceptance);
|
|
1845
|
+
const sessionEnabled = Boolean(options.sessionFile || options.sessionDir) || shareEnabled;
|
|
1846
|
+
if (options.context === "fork" && options.sessionFile && existsSync(options.sessionFile)) {
|
|
1847
|
+
alignForkedSessionCwd(options.sessionFile, options.cwd ?? runtimeCwd);
|
|
1848
|
+
}
|
|
1849
|
+
const skillNames = options.skills ?? agent.skills ?? [];
|
|
1850
|
+
const skillCwd = options.cwd ?? runtimeCwd;
|
|
1851
|
+
const { resolved: resolvedSkills, missing: missingSkills } = resolveSkillsWithFallback(
|
|
1852
|
+
skillNames,
|
|
1853
|
+
skillCwd,
|
|
1854
|
+
runtimeCwd,
|
|
1855
|
+
agent.skillPath,
|
|
1856
|
+
agent.filePath ? path.dirname(agent.filePath) : skillCwd,
|
|
1857
|
+
);
|
|
1858
|
+
if (skillNames.some((skill) => skill.trim() === "pi-subagents") && missingSkills.includes("pi-subagents")) {
|
|
1859
|
+
return redactResultPrompt(withRunContext({
|
|
1860
|
+
index: options.index ?? 0,
|
|
1861
|
+
agent: agentName,
|
|
1862
|
+
task,
|
|
1863
|
+
exitCode: 1,
|
|
1864
|
+
messages: [],
|
|
1865
|
+
usage: emptyUsage(),
|
|
1866
|
+
error: "Skills not found: pi-subagents",
|
|
1867
|
+
}, options.context));
|
|
1868
|
+
}
|
|
1869
|
+
let systemPrompt = agent.systemPrompt?.trim() || "";
|
|
1870
|
+
if (resolvedSkills.length > 0) {
|
|
1871
|
+
const skillInjection = buildSkillInjection(resolvedSkills);
|
|
1872
|
+
systemPrompt = systemPrompt ? `${systemPrompt}\n\n${skillInjection}` : skillInjection;
|
|
1873
|
+
}
|
|
1874
|
+
const memoryInjection = buildAgentMemoryInjection(agent, skillCwd);
|
|
1875
|
+
if (memoryInjection) {
|
|
1876
|
+
systemPrompt = systemPrompt ? `${systemPrompt}\n\n${memoryInjection}` : memoryInjection;
|
|
1877
|
+
}
|
|
1878
|
+
systemPrompt = appendAgentRefinementOverlay(systemPrompt, { cwd: skillCwd, agentName });
|
|
1879
|
+
systemPrompt = injectOutputPathSystemPrompt(systemPrompt, options.outputPath, agent);
|
|
1880
|
+
|
|
1881
|
+
const candidates = buildModelCandidates(
|
|
1882
|
+
options.modelOverride ?? agent.model,
|
|
1883
|
+
agent.fallbackModels,
|
|
1884
|
+
options.availableModels,
|
|
1885
|
+
agent.modelProvider ?? options.preferredModelProvider,
|
|
1886
|
+
{
|
|
1887
|
+
scope: options.modelScope,
|
|
1888
|
+
primaryModelFromParent: options.modelOverrideFromParent,
|
|
1889
|
+
origin: options.modelOrigin ?? (options.modelOverrideFromParent ? "inherited" : "configured"),
|
|
1890
|
+
},
|
|
1891
|
+
);
|
|
1892
|
+
if (options.workflowChildPermitLaunch && candidates.length > 1) {
|
|
1893
|
+
const error = "Workflow child permit does not support model fallback.";
|
|
1894
|
+
return redactResultPrompt(withRunContext({
|
|
1895
|
+
index: options.index ?? 0,
|
|
1896
|
+
agent: agent.name,
|
|
1897
|
+
task,
|
|
1898
|
+
exitCode: 1,
|
|
1899
|
+
messages: [],
|
|
1900
|
+
usage: emptyUsage(),
|
|
1901
|
+
error,
|
|
1902
|
+
}, options.context));
|
|
1903
|
+
}
|
|
1904
|
+
try {
|
|
1905
|
+
for (const candidate of candidates) {
|
|
1906
|
+
const model = applyThinkingSuffix(candidate, options.thinkingOverride ?? agent.thinking, options.thinkingOverride !== undefined);
|
|
1907
|
+
assertThinkingWithinCeiling({ model, configThinking: options.thinkingOverride ?? agent.thinking, ceiling: options.thinkingCeiling, agent: agent.name, runId: options.runId });
|
|
1908
|
+
}
|
|
1909
|
+
} catch (error) {
|
|
1910
|
+
return redactResultPrompt(withRunContext({
|
|
1911
|
+
index: options.index ?? 0,
|
|
1912
|
+
agent: agent.name,
|
|
1913
|
+
task,
|
|
1914
|
+
exitCode: 1,
|
|
1915
|
+
messages: [],
|
|
1916
|
+
usage: emptyUsage(),
|
|
1917
|
+
error: error instanceof Error ? error.message : String(error),
|
|
1918
|
+
}, options.context));
|
|
1919
|
+
}
|
|
1920
|
+
const attemptedModels: string[] = [];
|
|
1921
|
+
const modelAttempts: ModelAttempt[] = [];
|
|
1922
|
+
const aggregateUsage = emptyUsage();
|
|
1923
|
+
const attemptNotes: string[] = [];
|
|
1924
|
+
const launchWarnings = { emitted: false };
|
|
1925
|
+
let totalToolCount = 0;
|
|
1926
|
+
let totalDurationMs = 0;
|
|
1927
|
+
|
|
1928
|
+
let artifactPathsResult: ArtifactPaths | undefined;
|
|
1929
|
+
let jsonlPath: string | undefined;
|
|
1930
|
+
let transcriptWriter: ChildTranscriptWriter | undefined;
|
|
1931
|
+
if (options.artifactsDir && options.artifactConfig?.enabled !== false) {
|
|
1932
|
+
artifactPathsResult = getArtifactPaths(options.artifactsDir, options.runId, agentName, options.index);
|
|
1933
|
+
ensureArtifactsDir(options.artifactsDir);
|
|
1934
|
+
if (options.artifactConfig?.includeInput !== false) {
|
|
1935
|
+
writeArtifact(artifactPathsResult.inputPath, `# Task for ${agentName}\n\n${PROMPT_REDACTED}; live Prompt Audit only.\n`);
|
|
1936
|
+
}
|
|
1937
|
+
if (options.artifactConfig?.includeJsonl !== false) {
|
|
1938
|
+
jsonlPath = artifactPathsResult.jsonlPath;
|
|
1939
|
+
}
|
|
1940
|
+
if (options.artifactConfig?.includeTranscript !== false) {
|
|
1941
|
+
transcriptWriter = createChildTranscriptWriter({
|
|
1942
|
+
transcriptPath: artifactPathsResult.transcriptPath,
|
|
1943
|
+
source: "foreground",
|
|
1944
|
+
runId: options.runId,
|
|
1945
|
+
agent: agentName,
|
|
1946
|
+
childIndex: options.index,
|
|
1947
|
+
cwd: options.cwd ?? runtimeCwd,
|
|
1948
|
+
});
|
|
1949
|
+
transcriptWriter.writeInitialUserMessage(`${PROMPT_REDACTED}; live Prompt Audit only.`);
|
|
1950
|
+
}
|
|
1951
|
+
}
|
|
1952
|
+
|
|
1953
|
+
const orcaProgressTab = createOrcaProgressTab({
|
|
1954
|
+
cwd: options.cwd ?? runtimeCwd,
|
|
1955
|
+
runId: options.runId,
|
|
1956
|
+
agent: agentName,
|
|
1957
|
+
index: options.index ?? 0,
|
|
1958
|
+
});
|
|
1959
|
+
if (orcaProgressTab) options.onOrcaProgressTabCreated?.(orcaProgressTab);
|
|
1960
|
+
|
|
1961
|
+
const persistResultMetadata = (target: SingleResult): void => {
|
|
1962
|
+
persistSingleResultMetadata({
|
|
1963
|
+
metadataPath: artifactPathsResult?.metadataPath,
|
|
1964
|
+
enabled: options.artifactConfig?.enabled !== false && options.artifactConfig?.includeMetadata !== false,
|
|
1965
|
+
runId: options.runId,
|
|
1966
|
+
agent: agentName,
|
|
1967
|
+
task,
|
|
1968
|
+
result: target,
|
|
1969
|
+
});
|
|
1970
|
+
};
|
|
1971
|
+
|
|
1972
|
+
let intercomDetached = false;
|
|
1973
|
+
let detachedReason: string | undefined;
|
|
1974
|
+
const attemptOptions: RunSyncOptions = {
|
|
1975
|
+
...options,
|
|
1976
|
+
onDetachReceipt: (receipt) => {
|
|
1977
|
+
receipt.acceptance = buildPendingAcceptanceLedger(effectiveAcceptance);
|
|
1978
|
+
try {
|
|
1979
|
+
persistResultMetadata(receipt);
|
|
1980
|
+
} catch (error) {
|
|
1981
|
+
receipt.metadataSaveError = error instanceof Error ? error.message : String(error);
|
|
1982
|
+
}
|
|
1983
|
+
const accepted = options.onDetachReceipt?.(receipt) === true;
|
|
1984
|
+
if (accepted) {
|
|
1985
|
+
detachedReason = receipt.detachedReason;
|
|
1986
|
+
if (receipt.detachedReason === "intercom coordination") intercomDetached = true;
|
|
1987
|
+
}
|
|
1988
|
+
return accepted;
|
|
1989
|
+
},
|
|
1990
|
+
};
|
|
1991
|
+
let lastResult: SingleResult | undefined;
|
|
1992
|
+
const modelsToTry = candidates.length > 0 ? candidates : [undefined];
|
|
1993
|
+
// Escalated to "file" after an unexplained zero-activity startup failure so
|
|
1994
|
+
// retries keep the task text out of argv (endpoint pre-exec scans may deny it).
|
|
1995
|
+
let taskDeliveryOverride: SubagentTaskDelivery | undefined;
|
|
1996
|
+
let abortRecoveryAttempted = false;
|
|
1997
|
+
let nextAttemptTask = taskWithAcceptance;
|
|
1998
|
+
modelAttemptsLoop: for (let modelIndex = 0; modelIndex < modelsToTry.length; modelIndex++) {
|
|
1999
|
+
const candidate = modelsToTry[modelIndex];
|
|
2000
|
+
for (let startupAttemptIndex = 0; ; startupAttemptIndex++) {
|
|
2001
|
+
const recoveringAbort = abortRecoveryAttempted;
|
|
2002
|
+
const attemptTask = nextAttemptTask;
|
|
2003
|
+
const verifyModel = Boolean(candidate) && !(options.modelOverrideFromParent && modelIndex === 0);
|
|
2004
|
+
const outputSnapshot = captureSingleOutputSnapshot(options.outputPath);
|
|
2005
|
+
const result = await runSingleAttempt(runtimeCwd, agent, attemptTask, candidate, attemptOptions, {
|
|
2006
|
+
sessionEnabled,
|
|
2007
|
+
systemPrompt,
|
|
2008
|
+
resolvedSkillNames: resolvedSkills.length > 0 ? resolvedSkills.map((skill) => skill.name) : undefined,
|
|
2009
|
+
skillsWarning: missingSkills.length > 0 ? `Skills not found: ${missingSkills.join(", ")}` : undefined,
|
|
2010
|
+
jsonlPath,
|
|
2011
|
+
artifactPaths: artifactPathsResult,
|
|
2012
|
+
transcriptWriter,
|
|
2013
|
+
attemptNotes,
|
|
2014
|
+
modelCandidates: candidates
|
|
2015
|
+
.map((modelCandidate) => applyThinkingSuffix(modelCandidate, options.thinkingOverride ?? agent.thinking, options.thinkingOverride !== undefined))
|
|
2016
|
+
.filter((modelCandidate): modelCandidate is string => Boolean(modelCandidate)),
|
|
2017
|
+
outputSnapshot,
|
|
2018
|
+
originalTask: task,
|
|
2019
|
+
taskDelivery: taskDeliveryOverride,
|
|
2020
|
+
orcaProgressTab,
|
|
2021
|
+
launchWarnings,
|
|
2022
|
+
verifyModel,
|
|
2023
|
+
});
|
|
2024
|
+
lastResult = result;
|
|
2025
|
+
if (!recoveringAbort && startupAttemptIndex === 0) {
|
|
2026
|
+
if (result.model) attemptedModels.push(result.model);
|
|
2027
|
+
else if (candidate) attemptedModels.push(candidate);
|
|
2028
|
+
}
|
|
2029
|
+
sumUsage(aggregateUsage, result.usage);
|
|
2030
|
+
totalToolCount += result.progressSummary?.toolCount ?? 0;
|
|
2031
|
+
totalDurationMs += result.progressSummary?.durationMs ?? 0;
|
|
2032
|
+
const attemptSucceeded = result.exitCode === 0 && !result.error;
|
|
2033
|
+
const attempt: ModelAttempt = {
|
|
2034
|
+
model: result.model ?? candidate ?? agent.model ?? "default",
|
|
2035
|
+
success: attemptSucceeded,
|
|
2036
|
+
exitCode: result.exitCode,
|
|
2037
|
+
error: result.error,
|
|
2038
|
+
usage: { ...result.usage },
|
|
2039
|
+
};
|
|
2040
|
+
modelAttempts.push(attempt);
|
|
2041
|
+
if (!attemptSucceeded) {
|
|
2042
|
+
const afterCompactionSettlement = (result as AbortRecoverySingleResult)[AFTER_COMPACTION_SETTLEMENT];
|
|
2043
|
+
const abortRecovery = planAbortRecovery({
|
|
2044
|
+
messages: result.messages ?? [],
|
|
2045
|
+
error: result.error,
|
|
2046
|
+
processSignal: result.processSignal,
|
|
2047
|
+
sessionAvailable: Boolean(options.sessionFile && existsSync(options.sessionFile)),
|
|
2048
|
+
alreadyResumed: abortRecoveryAttempted,
|
|
2049
|
+
stopped: result.stopped || result.detached || options.signal?.aborted,
|
|
2050
|
+
interrupted: result.interrupted || intercomDetached || options.interruptSignal?.aborted,
|
|
2051
|
+
timedOut: result.timedOut,
|
|
2052
|
+
toolBudgetExhausted: result.toolBudgetBlocked,
|
|
2053
|
+
usageBudgetExhausted: false,
|
|
2054
|
+
structuredOutputFailed: result.structuredOutputFailed,
|
|
2055
|
+
acceptanceFailed: false,
|
|
2056
|
+
currentTool: result.progress?.currentTool,
|
|
2057
|
+
afterCompactionSettlement,
|
|
2058
|
+
});
|
|
2059
|
+
if (abortRecovery.action === "resume") {
|
|
2060
|
+
abortRecoveryAttempted = true;
|
|
2061
|
+
nextAttemptTask = abortRecovery.prompt;
|
|
2062
|
+
attemptNotes.push("[abort-recovery] provider/transport abort after useful progress; resuming the retained child session once.");
|
|
2063
|
+
continue;
|
|
2064
|
+
}
|
|
2065
|
+
if (abortRecovery.diagnostic) {
|
|
2066
|
+
result.error = result.error ? `${result.error}\n${abortRecovery.diagnostic}` : abortRecovery.diagnostic;
|
|
2067
|
+
attempt.error = result.error;
|
|
2068
|
+
break modelAttemptsLoop;
|
|
2069
|
+
}
|
|
2070
|
+
}
|
|
2071
|
+
if (recoveringAbort && !attemptSucceeded) break modelAttemptsLoop;
|
|
2072
|
+
if (options.workflowChildPermitLaunch && !attemptSucceeded) break modelAttemptsLoop;
|
|
2073
|
+
// Preserve the legacy intercom handoff contract: once this logical run has
|
|
2074
|
+
// been handed to a supervisor, terminating that attempt must not launch a
|
|
2075
|
+
// startup retry or model fallback. Explicit user detach retains fallback.
|
|
2076
|
+
if (intercomDetached || result.timedOut) break modelAttemptsLoop;
|
|
2077
|
+
if (attemptSucceeded) break modelAttemptsLoop;
|
|
2078
|
+
|
|
2079
|
+
const startupFailure = isRetryableSubagentStartupFailure({
|
|
2080
|
+
exitCode: result.exitCode,
|
|
2081
|
+
error: result.error,
|
|
2082
|
+
finalOutput: result.finalOutput,
|
|
2083
|
+
messageCount: result.messages?.length ?? 0,
|
|
2084
|
+
toolCount: result.progressSummary?.toolCount ?? 0,
|
|
2085
|
+
usage: result.usage,
|
|
2086
|
+
durationMs: result.progressSummary?.durationMs ?? Number.POSITIVE_INFINITY,
|
|
2087
|
+
protocolError: result.protocolError,
|
|
2088
|
+
processSignal: result.processSignal,
|
|
2089
|
+
detached: result.detached,
|
|
2090
|
+
interrupted: result.interrupted,
|
|
2091
|
+
timedOut: result.timedOut,
|
|
2092
|
+
stopped: result.stopped,
|
|
2093
|
+
});
|
|
2094
|
+
const retryDelayMs = SUBAGENT_STARTUP_RETRY_DELAYS_MS[startupAttemptIndex];
|
|
2095
|
+
if (startupFailure && retryDelayMs !== undefined) {
|
|
2096
|
+
const retryNote = formatSubagentStartupRetryNote({
|
|
2097
|
+
model: attempt.model,
|
|
2098
|
+
attempt: startupAttemptIndex + 1,
|
|
2099
|
+
maxAttempts: SUBAGENT_STARTUP_RETRY_DELAYS_MS.length + 1,
|
|
2100
|
+
delayMs: retryDelayMs,
|
|
2101
|
+
});
|
|
2102
|
+
const shouldRetry = await waitForSubagentStartupRetry(retryDelayMs, [options.signal, options.interruptSignal]);
|
|
2103
|
+
if (!shouldRetry) {
|
|
2104
|
+
if (options.interruptSignal?.aborted) {
|
|
2105
|
+
result.exitCode = 0;
|
|
2106
|
+
result.interrupted = true;
|
|
2107
|
+
result.error = undefined;
|
|
2108
|
+
result.finalOutput = "Interrupted. Waiting for explicit next action.";
|
|
2109
|
+
if (result.progress) {
|
|
2110
|
+
result.progress.status = "running";
|
|
2111
|
+
result.progress.error = undefined;
|
|
2112
|
+
}
|
|
2113
|
+
} else {
|
|
2114
|
+
const cancellationError = "Subagent startup retry cancelled before relaunch.";
|
|
2115
|
+
result.error = cancellationError;
|
|
2116
|
+
result.finalOutput = cancellationError;
|
|
2117
|
+
attempt.error = cancellationError;
|
|
2118
|
+
if (result.progress) result.progress.error = cancellationError;
|
|
2119
|
+
}
|
|
2120
|
+
break modelAttemptsLoop;
|
|
2121
|
+
}
|
|
2122
|
+
if (!taskDeliveryOverride && result.processSignal === "SIGKILL") {
|
|
2123
|
+
taskDeliveryOverride = "file";
|
|
2124
|
+
attemptNotes.push("[startup-retry] retrying with file task delivery to keep the task text out of the child process argv.");
|
|
2125
|
+
}
|
|
2126
|
+
attempt.error = retryNote;
|
|
2127
|
+
attemptNotes.push(retryNote);
|
|
2128
|
+
continue;
|
|
2129
|
+
}
|
|
2130
|
+
if (startupFailure) {
|
|
2131
|
+
const startupError = formatSubagentStartupRetryExhaustedError({
|
|
2132
|
+
model: attempt.model,
|
|
2133
|
+
attempts: startupAttemptIndex + 1,
|
|
2134
|
+
});
|
|
2135
|
+
result.error = startupError;
|
|
2136
|
+
result.finalOutput = startupError;
|
|
2137
|
+
if (result.progress) {
|
|
2138
|
+
result.progress.error = startupError;
|
|
2139
|
+
result.progress.status = "failed";
|
|
2140
|
+
}
|
|
2141
|
+
attempt.error = startupError;
|
|
2142
|
+
break modelAttemptsLoop;
|
|
2143
|
+
}
|
|
2144
|
+
const retryableModelFailure = isRetryableModelFailureAttempt({ error: result.error, messages: result.messages, toolCount: result.progressSummary?.toolCount });
|
|
2145
|
+
if (retryableModelFailure) recordRetryableModelFailure(result.model ?? candidate, result.error);
|
|
2146
|
+
if (isContextOverflow(result.error)) {
|
|
2147
|
+
result.contextOverflow = true;
|
|
2148
|
+
attemptNotes.push(`[fallback] ${attempt.model} failed: context overflow — the input exceeds this model's context window. Reduce the task input or use a model with a larger context window.`);
|
|
2149
|
+
break modelAttemptsLoop;
|
|
2150
|
+
}
|
|
2151
|
+
if (!retryableModelFailure || modelIndex === modelsToTry.length - 1) break modelAttemptsLoop;
|
|
2152
|
+
attemptNotes.push(formatModelAttemptNote(attempt, modelsToTry[modelIndex + 1]));
|
|
2153
|
+
break;
|
|
2154
|
+
}
|
|
2155
|
+
}
|
|
2156
|
+
|
|
2157
|
+
const result = withRunContext(lastResult ?? {
|
|
2158
|
+
index: options.index ?? 0,
|
|
2159
|
+
agent: agentName,
|
|
2160
|
+
task,
|
|
2161
|
+
exitCode: 1,
|
|
2162
|
+
messages: [],
|
|
2163
|
+
usage: emptyUsage(),
|
|
2164
|
+
error: "Subagent did not produce a result.",
|
|
2165
|
+
} satisfies SingleResult, options.context);
|
|
2166
|
+
result.task = task;
|
|
2167
|
+
|
|
2168
|
+
result.usage = aggregateUsage;
|
|
2169
|
+
result.attemptedModels = attemptedModels.length > 0 ? attemptedModels : undefined;
|
|
2170
|
+
result.modelAttempts = modelAttempts.length > 0 ? modelAttempts : undefined;
|
|
2171
|
+
result.progressSummary = {
|
|
2172
|
+
...(childSessionName ? { sessionName: childSessionName } : {}),
|
|
2173
|
+
toolCount: totalToolCount,
|
|
2174
|
+
tokens: aggregateUsage.input + aggregateUsage.output,
|
|
2175
|
+
durationMs: totalDurationMs,
|
|
2176
|
+
};
|
|
2177
|
+
if (transcriptWriter) result.transcriptPath = artifactPathsResult?.transcriptPath;
|
|
2178
|
+
if (transcriptWriter?.getError()) result.transcriptError = transcriptWriter.getError();
|
|
2179
|
+
|
|
2180
|
+
try {
|
|
2181
|
+
if (artifactPathsResult && options.artifactConfig?.enabled !== false) {
|
|
2182
|
+
result.artifactPaths = artifactPathsResult;
|
|
2183
|
+
if (options.artifactConfig?.includeOutput !== false) {
|
|
2184
|
+
writeArtifact(artifactPathsResult.outputPath, formatOutputArtifactContent({
|
|
2185
|
+
output: artifactOutputByResult.get(result) ?? result.finalOutput ?? "",
|
|
2186
|
+
error: result.error,
|
|
2187
|
+
transcriptPath: result.transcriptPath,
|
|
2188
|
+
metadataPath: options.artifactConfig?.includeMetadata === false ? undefined : artifactPathsResult.metadataPath,
|
|
2189
|
+
}));
|
|
2190
|
+
}
|
|
2191
|
+
if (options.maxOutput) {
|
|
2192
|
+
const config = { ...DEFAULT_MAX_OUTPUT, ...options.maxOutput };
|
|
2193
|
+
const truncationResult = truncateOutput(result.finalOutput ?? "", config, artifactPathsResult.outputPath);
|
|
2194
|
+
if (truncationResult.truncated) result.truncation = truncationResult;
|
|
2195
|
+
}
|
|
2196
|
+
} else if (options.maxOutput) {
|
|
2197
|
+
const config = { ...DEFAULT_MAX_OUTPUT, ...options.maxOutput };
|
|
2198
|
+
const truncationResult = truncateOutput(result.finalOutput ?? "", config);
|
|
2199
|
+
if (truncationResult.truncated) result.truncation = truncationResult;
|
|
2200
|
+
}
|
|
2201
|
+
} catch (error) {
|
|
2202
|
+
const message = `Artifact output post-processing failed: ${error instanceof Error ? error.message : String(error)}`;
|
|
2203
|
+
result.outputSaveError = result.outputSaveError ? `${result.outputSaveError}\n${message}` : message;
|
|
2204
|
+
}
|
|
2205
|
+
|
|
2206
|
+
if (options.sessionFile && (existsSync(options.sessionFile) || result.messages?.length)) {
|
|
2207
|
+
result.sessionFile = options.sessionFile;
|
|
2208
|
+
} else if (shareEnabled && options.sessionDir) {
|
|
2209
|
+
const sessionFile = findLatestSessionFile(options.sessionDir);
|
|
2210
|
+
if (sessionFile) result.sessionFile = sessionFile;
|
|
2211
|
+
}
|
|
2212
|
+
|
|
2213
|
+
const childWrittenOutput = options.outputPath
|
|
2214
|
+
? extractChildWrittenOutput(result.messages, options.outputPath, options.cwd ?? runtimeCwd)
|
|
2215
|
+
: undefined;
|
|
2216
|
+
try {
|
|
2217
|
+
if (result.interrupted && detachedReason === "user request") {
|
|
2218
|
+
// Only an accepted user-detach receipt needs a non-rejecting terminal
|
|
2219
|
+
// ledger. Attached and background execution retain their baseline
|
|
2220
|
+
// acceptance behavior.
|
|
2221
|
+
result.acceptance = buildInterruptedAcceptanceLedger(effectiveAcceptance);
|
|
2222
|
+
} else if (result.stopped) {
|
|
2223
|
+
result.acceptance = buildSkippedAcceptanceLedger(effectiveAcceptance, { id: "stopped", message: "Acceptance was not evaluated because the subagent was stopped." });
|
|
2224
|
+
} else if (result.timedOut) {
|
|
2225
|
+
result.acceptance = buildSkippedAcceptanceLedger(effectiveAcceptance, { id: "timeout", message: "Acceptance was not evaluated because the subagent timed out." });
|
|
2226
|
+
} else {
|
|
2227
|
+
result.acceptance = await evaluateAcceptance({
|
|
2228
|
+
acceptance: effectiveAcceptance,
|
|
2229
|
+
output: acceptanceOutputByResult.get(result) ?? result.finalOutput ?? "",
|
|
2230
|
+
report: (result as SingleResult & { structuredAcceptanceReport?: import("../../shared/types.ts").AcceptanceReport; structuredAcceptanceReportError?: string }).structuredAcceptanceReport,
|
|
2231
|
+
reportError: (result as SingleResult & { structuredAcceptanceReport?: import("../../shared/types.ts").AcceptanceReport; structuredAcceptanceReportError?: string }).structuredAcceptanceReportError,
|
|
2232
|
+
fileOutput: childWrittenOutput !== undefined && options.outputPath
|
|
2233
|
+
? { content: childWrittenOutput, path: options.outputPath, authoritative: options.outputMode === "file-only", durable: result.savedOutputPath !== undefined }
|
|
2234
|
+
: undefined,
|
|
2235
|
+
cwd: options.cwd ?? runtimeCwd,
|
|
2236
|
+
reportOptional: isAgentContractV1(options.agentContract),
|
|
2237
|
+
artifactsDir: options.artifactsDir,
|
|
2238
|
+
runId: options.runId,
|
|
2239
|
+
watchdog: result.watchdog,
|
|
2240
|
+
});
|
|
2241
|
+
}
|
|
2242
|
+
} catch (error) {
|
|
2243
|
+
const message = `Acceptance evaluation failed: ${error instanceof Error ? error.message : String(error)}`;
|
|
2244
|
+
result.acceptance = buildSkippedAcceptanceLedger(effectiveAcceptance, { id: "acceptance-evaluation", message });
|
|
2245
|
+
}
|
|
2246
|
+
const acceptanceFailure = acceptanceFailureMessage(result.acceptance);
|
|
2247
|
+
stripAcceptanceReportsFromMessages(result.messages);
|
|
2248
|
+
if (acceptanceFailure && result.acceptance.explicit && result.exitCode === 0 && !result.interrupted && !result.timedOut && !isAgentContractV1(options.agentContract)) {
|
|
2249
|
+
result.exitCode = 1;
|
|
2250
|
+
if (result.savedOutputPath) {
|
|
2251
|
+
result.finalOutput = finalizeSingleOutput({
|
|
2252
|
+
fullOutput: result.finalOutput ?? "",
|
|
2253
|
+
outputPath: options.outputPath,
|
|
2254
|
+
outputMode: result.outputMode,
|
|
2255
|
+
exitCode: result.exitCode,
|
|
2256
|
+
preserveSavedOutput: true,
|
|
2257
|
+
savedPath: result.savedOutputPath,
|
|
2258
|
+
outputReference: result.outputReference,
|
|
2259
|
+
}).displayOutput;
|
|
2260
|
+
artifactOutputByResult.set(result, result.finalOutput);
|
|
2261
|
+
}
|
|
2262
|
+
result.error = result.error ? `${result.error}\n${acceptanceFailure}` : acceptanceFailure;
|
|
2263
|
+
if (artifactPathsResult && options.artifactConfig?.enabled !== false && options.artifactConfig?.includeOutput !== false) {
|
|
2264
|
+
try {
|
|
2265
|
+
writeArtifact(artifactPathsResult.outputPath, formatOutputArtifactContent({
|
|
2266
|
+
output: artifactOutputByResult.get(result) ?? result.finalOutput ?? "",
|
|
2267
|
+
error: result.error,
|
|
2268
|
+
transcriptPath: result.transcriptPath,
|
|
2269
|
+
metadataPath: options.artifactConfig?.includeMetadata === false ? undefined : artifactPathsResult.metadataPath,
|
|
2270
|
+
}));
|
|
2271
|
+
} catch (error) {
|
|
2272
|
+
const message = `Artifact output post-processing failed: ${error instanceof Error ? error.message : String(error)}`;
|
|
2273
|
+
result.outputSaveError = result.outputSaveError ? `${result.outputSaveError}\n${message}` : message;
|
|
2274
|
+
}
|
|
2275
|
+
}
|
|
2276
|
+
if (result.progress) {
|
|
2277
|
+
result.progress.status = "failed";
|
|
2278
|
+
result.progress.error = result.error;
|
|
2279
|
+
}
|
|
2280
|
+
}
|
|
2281
|
+
if (isAgentContractV1(options.agentContract)) attachContractProjections(result);
|
|
2282
|
+
redactResultPrompt(result);
|
|
2283
|
+
try {
|
|
2284
|
+
persistResultMetadata(result);
|
|
2285
|
+
} catch (error) {
|
|
2286
|
+
result.metadataSaveError = error instanceof Error ? error.message : String(error);
|
|
2287
|
+
}
|
|
2288
|
+
|
|
2289
|
+
return result;
|
|
2290
|
+
}
|
|
2291
|
+
|
|
2292
|
+
async function runSyncCompletion(
|
|
2293
|
+
runtimeCwd: string,
|
|
2294
|
+
agents: AgentConfig[],
|
|
2295
|
+
agentName: string,
|
|
2296
|
+
task: string,
|
|
2297
|
+
options: RunSyncOptions,
|
|
2298
|
+
): Promise<SingleResult> {
|
|
2299
|
+
let orcaProgressTab: OrcaProgressTab | undefined;
|
|
2300
|
+
try {
|
|
2301
|
+
const result = await runSyncCompletionInner(runtimeCwd, agents, agentName, task, {
|
|
2302
|
+
...options,
|
|
2303
|
+
onOrcaProgressTabCreated: (tab) => { orcaProgressTab = tab; },
|
|
2304
|
+
});
|
|
2305
|
+
orcaProgressTab?.finish(result.stopped ? "stopped" : result.exitCode === 0 && !result.error ? "completed" : "failed", result.sessionFile);
|
|
2306
|
+
return result;
|
|
2307
|
+
} catch (error) {
|
|
2308
|
+
orcaProgressTab?.finish("failed");
|
|
2309
|
+
throw error;
|
|
2310
|
+
}
|
|
2311
|
+
}
|
|
2312
|
+
|
|
2313
|
+
/**
|
|
2314
|
+
* Runs the authoritative completion pipeline independently from the foreground
|
|
2315
|
+
* receipt. Detachment is same-runtime only: it does not adopt or daemonize work.
|
|
2316
|
+
*/
|
|
2317
|
+
export async function runSync(
|
|
2318
|
+
runtimeCwd: string,
|
|
2319
|
+
agents: AgentConfig[],
|
|
2320
|
+
agentName: string,
|
|
2321
|
+
task: string,
|
|
2322
|
+
options: RunSyncOptions,
|
|
2323
|
+
): Promise<SingleResult> {
|
|
2324
|
+
// Capture the strict contract before consumer-owned objects can be mutated
|
|
2325
|
+
// after a detached receipt is published.
|
|
2326
|
+
const strictContract = isAgentContractV1(options.agentContract);
|
|
2327
|
+
let detachedReason: string | undefined;
|
|
2328
|
+
let publishedReceipt: SingleResult | undefined;
|
|
2329
|
+
let activeDetachAttempt: ((reason?: string) => boolean) | undefined;
|
|
2330
|
+
let detachReadyPublished = false;
|
|
2331
|
+
let resolveReceipt!: (result: SingleResult) => void;
|
|
2332
|
+
const receipt = new Promise<SingleResult>((resolve) => { resolveReceipt = resolve; });
|
|
2333
|
+
const originSignal = options.signal;
|
|
2334
|
+
const originController = new AbortController();
|
|
2335
|
+
const forwardOriginAbort = () => {
|
|
2336
|
+
if (!detachedReason) originController.abort(originSignal?.reason);
|
|
2337
|
+
};
|
|
2338
|
+
if (originSignal?.aborted) forwardOriginAbort();
|
|
2339
|
+
else originSignal?.addEventListener("abort", forwardOriginAbort, { once: true });
|
|
2340
|
+
|
|
2341
|
+
const completion = runSyncCompletion(runtimeCwd, agents, agentName, task, {
|
|
2342
|
+
...options,
|
|
2343
|
+
signal: originController.signal,
|
|
2344
|
+
onDetachedExit: undefined,
|
|
2345
|
+
onDetachReceipt: (detachedReceipt) => {
|
|
2346
|
+
if (detachedReason || publishedReceipt) return false;
|
|
2347
|
+
// Keep the authoritative result, fallback snapshot, and caller receipt
|
|
2348
|
+
// separately owned while the completion pipeline remains live.
|
|
2349
|
+
publishedReceipt = structuredClone(detachedReceipt);
|
|
2350
|
+
const callerReceipt = structuredClone(detachedReceipt);
|
|
2351
|
+
// A strict contract was already validated before detach; normalize private
|
|
2352
|
+
// and caller snapshots to the only safely known version.
|
|
2353
|
+
publishedReceipt.agentContract = strictContract ? { version: 1 } : undefined;
|
|
2354
|
+
callerReceipt.agentContract = strictContract ? { version: 1 } : undefined;
|
|
2355
|
+
detachedReason = detachedReceipt.detachedReason ?? "user request";
|
|
2356
|
+
resolveReceipt(callerReceipt);
|
|
2357
|
+
return true;
|
|
2358
|
+
},
|
|
2359
|
+
onDetachReady: (detachAttempt) => {
|
|
2360
|
+
activeDetachAttempt = detachAttempt;
|
|
2361
|
+
if (detachReadyPublished) return;
|
|
2362
|
+
detachReadyPublished = true;
|
|
2363
|
+
options.onDetachReady?.((reason = "user request") => {
|
|
2364
|
+
if (detachedReason || originController.signal.aborted) return false;
|
|
2365
|
+
return activeDetachAttempt?.(reason) ?? false;
|
|
2366
|
+
});
|
|
2367
|
+
},
|
|
2368
|
+
});
|
|
2369
|
+
|
|
2370
|
+
const authoritativeCompletion = completion.catch((error: unknown) => {
|
|
2371
|
+
if (!publishedReceipt || !detachedReason) throw error;
|
|
2372
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
2373
|
+
const failureMessage = `Detached completion pipeline failed after receipt: ${message}`;
|
|
2374
|
+
const failedProgress: AgentProgress = publishedReceipt.progress
|
|
2375
|
+
? { ...publishedReceipt.progress, status: "failed", error: failureMessage }
|
|
2376
|
+
: {
|
|
2377
|
+
index: options.index ?? 0,
|
|
2378
|
+
agent: publishedReceipt.agent,
|
|
2379
|
+
status: "failed",
|
|
2380
|
+
task: publishedReceipt.task,
|
|
2381
|
+
recentTools: [],
|
|
2382
|
+
recentOutput: [],
|
|
2383
|
+
toolCount: publishedReceipt.progressSummary?.toolCount ?? 0,
|
|
2384
|
+
tokens: publishedReceipt.progressSummary?.tokens ?? 0,
|
|
2385
|
+
durationMs: publishedReceipt.progressSummary?.durationMs ?? 0,
|
|
2386
|
+
error: failureMessage,
|
|
2387
|
+
};
|
|
2388
|
+
const failedResult: SingleResult = redactResultPrompt({
|
|
2389
|
+
...publishedReceipt,
|
|
2390
|
+
detached: undefined,
|
|
2391
|
+
detachedReason,
|
|
2392
|
+
exitCode: 1,
|
|
2393
|
+
error: failureMessage,
|
|
2394
|
+
finalOutput: failureMessage,
|
|
2395
|
+
progress: failedProgress,
|
|
2396
|
+
progressSummary: {
|
|
2397
|
+
toolCount: failedProgress.toolCount,
|
|
2398
|
+
tokens: failedProgress.tokens,
|
|
2399
|
+
durationMs: failedProgress.durationMs,
|
|
2400
|
+
},
|
|
2401
|
+
acceptance: publishedReceipt.acceptance
|
|
2402
|
+
? buildSkippedAcceptanceLedger(publishedReceipt.acceptance.effectiveAcceptance, { id: "completion-pipeline", message: failureMessage })
|
|
2403
|
+
: undefined,
|
|
2404
|
+
});
|
|
2405
|
+
if (strictContract) attachContractProjections(failedResult);
|
|
2406
|
+
try {
|
|
2407
|
+
// Replace the provisional detach receipt metadata with the authoritative
|
|
2408
|
+
// terminal failure. Persistence remains best-effort and cannot orphan work.
|
|
2409
|
+
persistSingleResultMetadata({
|
|
2410
|
+
metadataPath: failedResult.artifactPaths?.metadataPath,
|
|
2411
|
+
enabled: options.artifactConfig?.enabled !== false && options.artifactConfig?.includeMetadata !== false,
|
|
2412
|
+
runId: options.runId,
|
|
2413
|
+
agent: failedResult.agent,
|
|
2414
|
+
task: failedResult.task,
|
|
2415
|
+
result: failedResult,
|
|
2416
|
+
});
|
|
2417
|
+
} catch (metadataError) {
|
|
2418
|
+
failedResult.metadataSaveError = metadataError instanceof Error ? metadataError.message : String(metadataError);
|
|
2419
|
+
}
|
|
2420
|
+
return failedResult;
|
|
2421
|
+
});
|
|
2422
|
+
|
|
2423
|
+
let terminalCallbackInvoked = false;
|
|
2424
|
+
void authoritativeCompletion.then((terminalResult) => {
|
|
2425
|
+
if (!detachedReason || terminalCallbackInvoked) return;
|
|
2426
|
+
terminalCallbackInvoked = true;
|
|
2427
|
+
terminalResult.detached = undefined;
|
|
2428
|
+
terminalResult.detachedReason = detachedReason;
|
|
2429
|
+
try {
|
|
2430
|
+
options.onDetachedExit?.(terminalResult);
|
|
2431
|
+
} catch {
|
|
2432
|
+
// The authoritative result has settled. Consumer callback failures are
|
|
2433
|
+
// contained here; each consumer owns cleanup through its own finally block.
|
|
2434
|
+
}
|
|
2435
|
+
}).catch(() => {
|
|
2436
|
+
// Attached completion rejection remains observable through the returned
|
|
2437
|
+
// promise without becoming an unhandled side-channel rejection.
|
|
2438
|
+
}).finally(() => {
|
|
2439
|
+
originSignal?.removeEventListener("abort", forwardOriginAbort);
|
|
2440
|
+
});
|
|
2441
|
+
|
|
2442
|
+
return Promise.race([authoritativeCompletion, receipt]);
|
|
2443
|
+
}
|