@selesai/code 0.9.11 → 0.9.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/dist/config.d.ts +4 -6
- package/dist/config.js +10 -14
- package/dist/core/agent-session.d.ts +0 -1
- package/dist/core/agent-session.js +3 -49
- package/dist/core/extensions/types.d.ts +0 -2
- package/dist/core/settings-manager.d.ts +0 -2
- package/dist/core/settings-manager.js +0 -3
- package/dist/core/tools/index.d.ts +0 -1
- package/dist/core/tools/index.js +0 -1
- package/dist/defaults/settings.json +2 -3
- package/dist/extensions/model-prompt-injector/index.test.ts +0 -10
- package/dist/extensions/model-prompt-injector/index.ts +0 -3
- package/dist/extensions/pi-intercom/CHANGELOG.md +53 -16
- package/dist/extensions/pi-intercom/README.md +41 -8
- package/dist/extensions/pi-intercom/banner.png +0 -0
- package/dist/extensions/pi-intercom/broker/broker.ts +498 -215
- package/dist/extensions/pi-intercom/broker/client.ts +39 -12
- package/dist/extensions/pi-intercom/broker/extension.test.ts +102 -3
- package/dist/extensions/pi-intercom/broker/paths.test.ts +2 -2
- package/dist/extensions/pi-intercom/broker/protocol.ts +26 -0
- package/dist/extensions/pi-intercom/broker/spawn.test.ts +5 -20
- package/dist/extensions/pi-intercom/config.test.ts +41 -0
- package/dist/extensions/pi-intercom/config.ts +21 -0
- package/dist/extensions/pi-intercom/extension-api.ts +40 -0
- package/dist/extensions/pi-intercom/index.ts +362 -26
- package/dist/extensions/pi-intercom/intercom.integration.test.ts +819 -13
- package/dist/extensions/pi-intercom/package.json +1 -1
- package/dist/extensions/pi-intercom/project-agent.ts +2 -2
- package/dist/extensions/pi-intercom/skills/pi-intercom/SKILL.md +8 -110
- package/dist/extensions/pi-intercom/types.ts +32 -5
- package/dist/extensions/pi-intercom/ui/inline-message.ts +6 -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/CHANGELOG.md +309 -87
- package/dist/extensions/pi-subagents/README.md +15 -17
- package/dist/extensions/pi-subagents/agents/oracle.md +3 -1
- package/dist/extensions/pi-subagents/agents/researcher.md +32 -13
- package/dist/extensions/pi-subagents/agents/reviewer.md +13 -2
- package/dist/extensions/pi-subagents/agents/scout.md +2 -2
- package/dist/extensions/pi-subagents/agents/worker.md +2 -1
- package/dist/extensions/pi-subagents/async-retention-discovery-worker.mjs +180 -0
- package/dist/extensions/pi-subagents/docs/configuration.md +106 -27
- package/dist/extensions/pi-subagents/docs/extension-api.md +85 -21
- package/dist/extensions/pi-subagents/docs/missions.md +41 -4
- package/dist/extensions/pi-subagents/docs/models.md +52 -9
- package/dist/extensions/pi-subagents/docs/observability.md +103 -16
- package/dist/extensions/pi-subagents/docs/tool-reference.md +60 -45
- package/dist/extensions/pi-subagents/docs/watchdog.md +60 -3
- package/dist/extensions/pi-subagents/docs/workflows.md +181 -7
- package/dist/extensions/pi-subagents/index.ts +10 -1
- package/dist/extensions/pi-subagents/install.mjs +4 -4
- package/dist/extensions/pi-subagents/package-lock.json +1483 -1470
- package/dist/extensions/pi-subagents/package.json +6 -3
- package/dist/extensions/pi-subagents/prompts/council.md +60 -0
- package/dist/extensions/pi-subagents/prompts/parallel-review.md +5 -1
- package/dist/extensions/pi-subagents/prompts/review-loop.md +9 -5
- package/dist/extensions/pi-subagents/skills/council-mode/SKILL.md +254 -0
- package/dist/extensions/pi-subagents/skills/pi-subagents/SKILL.md +18 -17
- package/dist/extensions/pi-subagents/skills/pi-subagents/references/constraints-and-recipes.md +31 -9
- package/dist/extensions/pi-subagents/skills/pi-subagents/references/execution-controls.md +107 -140
- package/dist/extensions/pi-subagents/skills/pi-subagents/references/management-authoring-rpc.md +9 -12
- package/dist/extensions/pi-subagents/skills/pi-subagents/references/multi-lane-orchestration.md +39 -0
- package/dist/extensions/pi-subagents/skills/pi-subagents/references/prompting-and-roles.md +44 -92
- package/dist/extensions/pi-subagents/src/agents/agent-management.ts +261 -368
- package/dist/extensions/pi-subagents/src/agents/agent-serializer.ts +6 -2
- package/dist/extensions/pi-subagents/src/agents/agents.ts +388 -85
- package/dist/extensions/pi-subagents/src/agents/builtin-names.ts +14 -0
- package/dist/extensions/pi-subagents/src/agents/runtime-agent-registry.ts +418 -0
- package/dist/extensions/pi-subagents/src/agents/skills.ts +1 -1
- package/dist/extensions/pi-subagents/src/api/agents.ts +7 -0
- package/dist/extensions/pi-subagents/src/api/external-job-provider.ts +195 -0
- package/dist/extensions/pi-subagents/src/api/preflight.ts +88 -27
- package/dist/extensions/pi-subagents/src/api/project-panes.ts +2 -0
- package/dist/extensions/pi-subagents/src/api/shared-types.ts +2 -0
- package/dist/extensions/pi-subagents/src/extension/config.ts +20 -11
- package/dist/extensions/pi-subagents/src/extension/doctor.ts +14 -6
- package/dist/extensions/pi-subagents/src/extension/fanout-child.ts +5 -4
- package/dist/extensions/pi-subagents/src/extension/index.ts +270 -187
- package/dist/extensions/pi-subagents/src/extension/public-execution.ts +65 -28
- package/dist/extensions/pi-subagents/src/extension/rpc.ts +120 -11
- package/dist/extensions/pi-subagents/src/extension/schemas.ts +46 -64
- package/dist/extensions/pi-subagents/src/extension/tool-description.ts +51 -37
- package/dist/extensions/pi-subagents/src/extension/tool-result.ts +19 -0
- package/dist/extensions/pi-subagents/src/inspectors/herdr/actions.ts +2 -2
- package/dist/extensions/pi-subagents/src/inspectors/herdr/client.ts +3 -3
- package/dist/extensions/pi-subagents/src/inspectors/herdr/focus.ts +55 -0
- package/dist/extensions/pi-subagents/src/inspectors/herdr/inspector-runner.ts +2 -1
- package/dist/extensions/pi-subagents/src/inspectors/herdr/project-panes.ts +230 -46
- package/dist/extensions/pi-subagents/src/integrations/herdr-status.ts +26 -4
- package/dist/extensions/pi-subagents/src/intercom/native-supervisor-channel.ts +32 -10
- package/dist/extensions/pi-subagents/src/missions/lifecycle.ts +6 -1
- package/dist/extensions/pi-subagents/src/missions/store.ts +4 -9
- package/dist/extensions/pi-subagents/src/missions/workflow-state.ts +2 -2
- package/dist/extensions/pi-subagents/src/policy/authority.ts +2 -0
- package/dist/extensions/pi-subagents/src/profiles/profiles.ts +3 -1
- package/dist/extensions/pi-subagents/src/runs/background/active-run-index.ts +31 -8
- package/dist/extensions/pi-subagents/src/runs/background/async-execution.ts +210 -52
- package/dist/extensions/pi-subagents/src/runs/background/async-job-tracker.ts +63 -33
- package/dist/extensions/pi-subagents/src/runs/background/async-resume.ts +71 -17
- package/dist/extensions/pi-subagents/src/runs/background/async-retention.ts +886 -0
- package/dist/extensions/pi-subagents/src/runs/background/async-status-snapshot.ts +14 -5
- package/dist/extensions/pi-subagents/src/runs/background/async-status.ts +49 -56
- package/dist/extensions/pi-subagents/src/runs/background/auto-drain.ts +1 -0
- package/dist/extensions/pi-subagents/src/runs/background/chain-append.ts +3 -33
- package/dist/extensions/pi-subagents/src/runs/background/chain-root-attachment.ts +5 -0
- package/dist/extensions/pi-subagents/src/runs/background/completion-dedupe.ts +5 -1
- package/dist/extensions/pi-subagents/src/runs/background/completion-replay.ts +22 -12
- package/dist/extensions/pi-subagents/src/runs/background/control-channel.ts +105 -71
- package/dist/extensions/pi-subagents/src/runs/background/fleet-view.ts +68 -19
- 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 +94 -10
- package/dist/extensions/pi-subagents/src/runs/background/result-files.ts +158 -90
- package/dist/extensions/pi-subagents/src/runs/background/result-watcher.ts +141 -53
- package/dist/extensions/pi-subagents/src/runs/background/resume-guidance.ts +8 -5
- package/dist/extensions/pi-subagents/src/runs/background/retained-children.ts +14 -4
- 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 +13 -14
- package/dist/extensions/pi-subagents/src/runs/background/run-status.ts +46 -25
- package/dist/extensions/pi-subagents/src/runs/background/scheduled-runs.ts +823 -0
- package/dist/extensions/pi-subagents/src/runs/background/stale-run-reconciler.ts +9 -3
- package/dist/extensions/pi-subagents/src/runs/background/steering.ts +11 -1
- package/dist/extensions/pi-subagents/src/runs/background/subagent-runner.ts +594 -216
- package/dist/extensions/pi-subagents/src/runs/background/subagent-wait.ts +17 -13
- package/dist/extensions/pi-subagents/src/runs/background/terminal-run-index.ts +138 -0
- package/dist/extensions/pi-subagents/src/runs/background/wait-completions.ts +23 -4
- package/dist/extensions/pi-subagents/src/runs/background/wait-subscriptions.ts +82 -4
- package/dist/extensions/pi-subagents/src/runs/background/wait-tool.ts +5 -3
- package/dist/extensions/pi-subagents/src/runs/foreground/async-steering-action.ts +21 -14
- package/dist/extensions/pi-subagents/src/runs/foreground/async-stop-action.ts +23 -2
- package/dist/extensions/pi-subagents/src/runs/foreground/execution.ts +153 -58
- package/dist/extensions/pi-subagents/src/runs/foreground/foreground-history.ts +7 -9
- package/dist/extensions/pi-subagents/src/runs/foreground/subagent-executor.ts +1283 -1657
- package/dist/extensions/pi-subagents/src/runs/foreground/workflow-detach-reconcile.ts +274 -0
- package/dist/extensions/pi-subagents/src/runs/foreground/workflow-foreground-steering.ts +6 -5
- package/dist/extensions/pi-subagents/src/runs/shared/acceptance.ts +59 -10
- package/dist/extensions/pi-subagents/src/runs/shared/agent-contract.ts +1 -1
- package/dist/extensions/pi-subagents/src/runs/shared/chain-outputs.ts +1 -3
- package/dist/extensions/pi-subagents/src/runs/shared/child-identity.ts +36 -0
- package/dist/extensions/pi-subagents/src/runs/shared/completion-guard.ts +52 -2
- package/dist/extensions/pi-subagents/src/runs/shared/dynamic-fanout.ts +1 -1
- package/dist/extensions/pi-subagents/src/runs/shared/extension-bindings.ts +78 -0
- package/dist/extensions/pi-subagents/src/runs/shared/external-cli-runner.ts +2 -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/mcp-direct-tool-allowlist.ts +14 -0
- package/dist/extensions/pi-subagents/src/runs/shared/model-exclusions.ts +243 -0
- package/dist/extensions/pi-subagents/src/runs/shared/model-fallback.ts +201 -85
- package/dist/extensions/pi-subagents/src/runs/shared/model-scope.ts +106 -39
- package/dist/extensions/pi-subagents/src/runs/shared/mutation-evidence.ts +145 -0
- package/dist/extensions/pi-subagents/src/runs/shared/orca-progress-tabs.ts +150 -27
- package/dist/extensions/pi-subagents/src/runs/shared/parallel-handoff.ts +46 -4
- package/dist/extensions/pi-subagents/src/runs/shared/parallel-utils.ts +19 -15
- package/dist/extensions/pi-subagents/src/runs/shared/permissions.ts +5 -1
- package/dist/extensions/pi-subagents/src/runs/shared/pi-args.ts +86 -2
- package/dist/extensions/pi-subagents/src/runs/shared/pi-spawn.ts +9 -9
- package/dist/extensions/pi-subagents/src/runs/shared/session-lease.ts +0 -6
- package/dist/extensions/pi-subagents/src/runs/shared/structured-output.ts +18 -4
- package/dist/extensions/pi-subagents/src/runs/shared/subagent-control.ts +51 -7
- package/dist/extensions/pi-subagents/src/runs/shared/subagent-prompt-runtime.ts +62 -21
- package/dist/extensions/pi-subagents/src/runs/shared/tool-availability.ts +1 -3
- package/dist/extensions/pi-subagents/src/runs/shared/tool-timeout.ts +1 -3
- package/dist/extensions/pi-subagents/src/runs/shared/workflow-graph.ts +1 -23
- package/dist/extensions/pi-subagents/src/runs/shared/worktree.ts +14 -2
- package/dist/extensions/pi-subagents/src/shared/artifacts.ts +2 -2
- package/dist/extensions/pi-subagents/src/shared/atomic-json.ts +22 -2
- package/dist/extensions/pi-subagents/src/shared/capacity-resilient-json.ts +102 -0
- package/dist/extensions/pi-subagents/src/shared/completion-owner.ts +14 -0
- package/dist/extensions/pi-subagents/src/shared/file-system-retry.ts +49 -1
- package/dist/extensions/pi-subagents/src/shared/fork-context.ts +59 -1
- package/dist/extensions/pi-subagents/src/shared/launch-contract.ts +12 -5
- package/dist/extensions/pi-subagents/src/shared/model-info.ts +20 -0
- package/dist/extensions/pi-subagents/src/shared/prompt-resources.ts +0 -40
- package/dist/extensions/pi-subagents/src/shared/settings.ts +11 -30
- package/dist/extensions/pi-subagents/src/shared/thinking-ceiling.ts +52 -0
- package/dist/extensions/pi-subagents/src/shared/types.ts +228 -49
- package/dist/extensions/pi-subagents/src/shared/utils.ts +11 -3
- package/dist/extensions/pi-subagents/src/shared/watch-strategy.ts +10 -0
- package/dist/extensions/pi-subagents/src/slash/prompt-workflows.ts +0 -162
- package/dist/extensions/pi-subagents/src/slash/slash-bridge.ts +2 -5
- package/dist/extensions/pi-subagents/src/slash/slash-commands.ts +105 -13
- package/dist/extensions/pi-subagents/src/slash/slash-live-state.ts +6 -36
- package/dist/extensions/pi-subagents/src/tui/fleet-status.ts +829 -0
- package/dist/extensions/pi-subagents/src/tui/fleet.ts +1415 -0
- package/dist/extensions/pi-subagents/src/tui/render.ts +78 -7
- package/dist/extensions/pi-subagents/src/watchdog/change-signature.ts +1 -1
- package/dist/extensions/pi-subagents/src/watchdog/lsp-diagnostics.ts +1 -0
- package/dist/extensions/pi-subagents/src/watchdog/permission-arbiter.ts +59 -51
- package/dist/extensions/pi-subagents/src/watchdog/register-main.ts +8 -2
- package/dist/extensions/pi-subagents/src/watchdog/tool-actions.ts +2 -1
- package/dist/extensions/pi-subagents/src/workflows/chat-progress.ts +4 -4
- package/dist/extensions/pi-subagents/src/workflows/scripted-workflow.ts +471 -86
- package/dist/extensions/pi-subagents/src/workflows/workflow-receipt.ts +140 -0
- package/dist/extensions/pi-subagents/test/e2e/real-session-subagent.test.ts +2 -2
- 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 +1 -1
- package/dist/extensions/pi-subagents/test/integration/acceptance-file-report.test.ts +0 -54
- package/dist/extensions/pi-subagents/test/integration/async-execution.test.ts +1053 -414
- package/dist/extensions/pi-subagents/test/integration/async-job-tracker.test.ts +194 -4
- package/dist/extensions/pi-subagents/test/integration/async-status.test.ts +59 -4
- package/dist/extensions/pi-subagents/test/integration/error-handling.test.ts +0 -77
- package/dist/extensions/pi-subagents/test/integration/external-cli-runner.test.ts +107 -6
- package/dist/extensions/pi-subagents/test/integration/fork-context-execution.test.ts +211 -897
- package/dist/extensions/pi-subagents/test/integration/intercom-result-delivery.test.ts +265 -375
- package/dist/extensions/pi-subagents/test/integration/orca-progress-tabs.test.ts +77 -7
- package/dist/extensions/pi-subagents/test/integration/render-fork-badge.test.ts +1 -1
- package/dist/extensions/pi-subagents/test/integration/render-widget.test.ts +10 -10
- package/dist/extensions/pi-subagents/test/integration/result-watcher.test.ts +547 -30
- package/dist/extensions/pi-subagents/test/integration/single-execution.test.ts +2112 -310
- package/dist/extensions/pi-subagents/test/integration/slash-commands.test.ts +274 -34
- package/dist/extensions/pi-subagents/test/integration/slash-live-state.test.ts +1 -1
- package/dist/extensions/pi-subagents/test/integration/template-resolution.test.ts +20 -3
- package/dist/extensions/pi-subagents/test/support/isolated-temp-root.mjs +9 -0
- package/dist/extensions/pi-subagents/test/support/mock-pi-script.mjs +30 -5
- package/dist/extensions/pi-subagents/test/support/mock-pi.ts +2 -0
- package/dist/extensions/pi-subagents/test/support/real-session-runner.ts +4 -2
- package/dist/extensions/pi-subagents/test/support/register-loader.mjs +1 -0
- package/dist/extensions/pi-subagents/test/unit/acceptance.test.ts +197 -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 +1 -1
- package/dist/extensions/pi-subagents/test/unit/agent-frontmatter.test.ts +204 -27
- package/dist/extensions/pi-subagents/test/unit/agent-management.test.ts +444 -145
- package/dist/extensions/pi-subagents/test/unit/agent-overrides.test.ts +256 -4
- package/dist/extensions/pi-subagents/test/unit/artifacts.test.ts +9 -7
- package/dist/extensions/pi-subagents/test/unit/async-interrupt-action.test.ts +152 -22
- package/dist/extensions/pi-subagents/test/unit/async-recovery-descriptor.test.ts +29 -0
- package/dist/extensions/pi-subagents/test/unit/async-resume.test.ts +205 -23
- package/dist/extensions/pi-subagents/test/unit/async-retention.test.ts +579 -0
- package/dist/extensions/pi-subagents/test/unit/atomic-json.test.ts +24 -0
- package/dist/extensions/pi-subagents/test/unit/authority-policy.test.ts +1 -0
- package/dist/extensions/pi-subagents/test/unit/auto-drain.test.ts +3 -3
- package/dist/extensions/pi-subagents/test/unit/capacity-resilient-json.test.ts +155 -0
- package/dist/extensions/pi-subagents/test/unit/compaction-resume.test.ts +2 -2
- package/dist/extensions/pi-subagents/test/unit/completion-dedupe.test.ts +7 -0
- package/dist/extensions/pi-subagents/test/unit/completion-guard.test.ts +123 -0
- package/dist/extensions/pi-subagents/test/unit/completion-replay.test.ts +81 -3
- package/dist/extensions/pi-subagents/test/unit/control-channel.test.ts +109 -7
- package/dist/extensions/pi-subagents/test/unit/default-extensions.test.ts +2 -2
- package/dist/extensions/pi-subagents/test/unit/doctor.test.ts +5 -2
- package/dist/extensions/pi-subagents/test/unit/dynamic-fanout.test.ts +3 -2
- package/dist/extensions/pi-subagents/test/unit/extension-bindings.test.ts +79 -0
- package/dist/extensions/pi-subagents/test/unit/external-cli-runner.test.ts +22 -0
- package/dist/extensions/pi-subagents/test/unit/external-job-runner.test.ts +961 -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 +1110 -0
- package/dist/extensions/pi-subagents/test/unit/fleet.test.ts +1664 -0
- package/dist/extensions/pi-subagents/test/unit/fork-context.test.ts +81 -1
- package/dist/extensions/pi-subagents/test/unit/herdr-inspector.test.ts +138 -11
- package/dist/extensions/pi-subagents/test/unit/herdr-status-bridge.test.ts +41 -2
- package/dist/extensions/pi-subagents/test/unit/index-child-registration.test.ts +210 -79
- package/dist/extensions/pi-subagents/test/unit/index-segment.test.ts +95 -0
- package/dist/extensions/pi-subagents/test/unit/inspect-rpc.test.ts +596 -0
- package/dist/extensions/pi-subagents/test/unit/mission-lifecycle.test.ts +10 -1
- package/dist/extensions/pi-subagents/test/unit/mission-store.test.ts +3 -5
- package/dist/extensions/pi-subagents/test/unit/model-exclusions.test.ts +167 -0
- package/dist/extensions/pi-subagents/test/unit/model-fallback.test.ts +319 -18
- package/dist/extensions/pi-subagents/test/unit/model-info.test.ts +78 -0
- package/dist/extensions/pi-subagents/test/unit/model-scope-settings.test.ts +19 -5
- package/dist/extensions/pi-subagents/test/unit/model-scope.test.ts +44 -0
- package/dist/extensions/pi-subagents/test/unit/mutation-evidence.test.ts +129 -0
- package/dist/extensions/pi-subagents/test/unit/native-supervisor-channel.test.ts +231 -2
- package/dist/extensions/pi-subagents/test/unit/nested-control.test.ts +28 -1
- package/dist/extensions/pi-subagents/test/unit/notify.test.ts +106 -2
- package/dist/extensions/pi-subagents/test/unit/orca-progress-tabs.test.ts +204 -7
- package/dist/extensions/pi-subagents/test/unit/package-manifest.test.ts +59 -4
- package/dist/extensions/pi-subagents/test/unit/path-handling.test.ts +2 -6
- package/dist/extensions/pi-subagents/test/unit/pi-args-permission-system.test.ts +34 -2
- package/dist/extensions/pi-subagents/test/unit/pi-args.test.ts +116 -6
- package/dist/extensions/pi-subagents/test/unit/pi-coding-agent-dir.test.ts +12 -3
- package/dist/extensions/pi-subagents/test/unit/pi-spawn.test.ts +56 -61
- package/dist/extensions/pi-subagents/test/unit/preflight.test.ts +416 -1
- package/dist/extensions/pi-subagents/test/unit/profiles.test.ts +9 -2
- package/dist/extensions/pi-subagents/test/unit/project-panes-public-api.test.ts +42 -0
- package/dist/extensions/pi-subagents/test/unit/prompt-workflows.test.ts +21 -30
- package/dist/extensions/pi-subagents/test/unit/public-execution.test.ts +86 -11
- package/dist/extensions/pi-subagents/test/unit/render-helpers.test.ts +49 -1
- package/dist/extensions/pi-subagents/test/unit/result-files.test.ts +233 -5
- package/dist/extensions/pi-subagents/test/unit/retained-children.test.ts +28 -5
- package/dist/extensions/pi-subagents/test/unit/rpc.test.ts +323 -20
- package/dist/extensions/pi-subagents/test/unit/run-id-resolver.test.ts +66 -10
- package/dist/extensions/pi-subagents/test/unit/run-status.test.ts +68 -5
- package/dist/extensions/pi-subagents/test/unit/runtime-agent-registration.test.ts +174 -0
- package/dist/extensions/pi-subagents/test/unit/scheduled-runs.test.ts +679 -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 +55 -44
- package/dist/extensions/pi-subagents/test/unit/scripted-workflow.test.ts +399 -84
- package/dist/extensions/pi-subagents/test/unit/session-lease.test.ts +13 -0
- package/dist/extensions/pi-subagents/test/unit/skills-fallback.test.ts +1 -1
- package/dist/extensions/pi-subagents/test/unit/slash-bridge.test.ts +15 -10
- package/dist/extensions/pi-subagents/test/unit/stale-run-reconciler.test.ts +11 -7
- package/dist/extensions/pi-subagents/test/unit/steering-action.test.ts +2 -0
- package/dist/extensions/pi-subagents/test/unit/steering.test.ts +40 -1
- package/dist/extensions/pi-subagents/test/unit/subagent-action-recovery.test.ts +10 -2
- package/dist/extensions/pi-subagents/test/unit/subagent-control.test.ts +38 -3
- package/dist/extensions/pi-subagents/test/unit/subagent-prompt-runtime.test.ts +110 -12
- package/dist/extensions/pi-subagents/test/unit/subagent-wait.test.ts +204 -19
- package/dist/extensions/pi-subagents/test/unit/temp-paths.test.ts +25 -0
- package/dist/extensions/pi-subagents/test/unit/thinking-ceiling.test.ts +73 -0
- package/dist/extensions/pi-subagents/test/unit/tool-description.test.ts +90 -50
- package/dist/extensions/pi-subagents/test/unit/tool-timeout.test.ts +1 -2
- package/dist/extensions/pi-subagents/test/unit/wait-subscriptions.test.ts +234 -7
- package/dist/extensions/pi-subagents/test/unit/watch-strategy.test.ts +24 -0
- package/dist/extensions/pi-subagents/test/unit/watchdog-permission-arbiter.test.ts +36 -0
- package/dist/extensions/pi-subagents/test/unit/workflow-chat-progress.test.ts +37 -9
- package/dist/extensions/pi-subagents/test/unit/workflow-detach-reconcile.test.ts +302 -0
- package/dist/extensions/pi-subagents/test/unit/workflow-launch-params.test.ts +167 -7
- package/dist/extensions/pi-subagents/test/unit/workflow-receipt.test.ts +113 -0
- package/dist/extensions/pi-subagents/test/unit/worktree.test.ts +6 -6
- package/dist/extensions/ponytail/index.js +31 -25
- package/dist/extensions/ponytail/ponytail-config.cjs +34 -7
- package/dist/extensions/ponytail/ponytail-instructions.cjs +7 -9
- package/dist/extensions/ponytail/test/extension.test.js +7 -8
- package/dist/extensions/ponytail/test/helpers.test.js +1 -1
- package/dist/skills/brandkit/SKILL.md +799 -0
- package/dist/skills/design-taste-frontend/SKILL.md +1207 -0
- package/dist/skills/design-taste-frontend-v1/SKILL.md +227 -0
- package/dist/skills/full-output-enforcement/SKILL.md +50 -0
- package/dist/skills/gpt-taste/SKILL.md +75 -0
- package/dist/skills/high-end-visual-design/SKILL.md +99 -0
- package/dist/skills/image-to-code/SKILL.md +1229 -0
- package/dist/skills/imagegen-frontend-mobile/SKILL.md +1466 -0
- package/dist/skills/imagegen-frontend-web/SKILL.md +988 -0
- package/dist/skills/industrial-brutalist-ui/SKILL.md +93 -0
- package/dist/skills/minimalist-ui/SKILL.md +86 -0
- package/dist/skills/pi-subagents/SKILL.md +18 -17
- package/dist/skills/pi-subagents/references/constraints-and-recipes.md +31 -9
- package/dist/skills/pi-subagents/references/execution-controls.md +95 -143
- package/dist/skills/pi-subagents/references/management-authoring-rpc.md +9 -12
- package/dist/skills/pi-subagents/references/multi-lane-orchestration.md +39 -0
- package/dist/skills/pi-subagents/references/prompting-and-roles.md +45 -94
- package/dist/skills/ponytail/SKILL.md +12 -8
- package/dist/skills/ponytail-audit/SKILL.md +0 -1
- package/dist/skills/ponytail-debt/SKILL.md +0 -1
- package/dist/skills/ponytail-gain/SKILL.md +0 -1
- package/dist/skills/ponytail-help/SKILL.md +4 -3
- package/dist/skills/ponytail-review/SKILL.md +0 -1
- package/dist/skills/redesign-existing-projects/SKILL.md +179 -0
- package/dist/skills/stitch-design-taste/SKILL.md +185 -0
- package/dist/skills/unlazy/CHANGELOG.md +100 -0
- package/dist/skills/unlazy/CONTRIBUTING.md +66 -0
- package/dist/skills/unlazy/LICENSE +21 -0
- package/dist/skills/unlazy/README.md +242 -0
- package/dist/skills/unlazy/SECURITY.md +70 -0
- package/dist/skills/unlazy/SKILL.md +100 -0
- package/dist/skills/unlazy/package.json +13 -0
- package/dist/skills/unlazy/references/dispatch.md +82 -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 +99 -0
- package/dist/skills/unlazy/references/parallel.md +123 -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 +894 -0
- package/dist/skills/unlazy/scripts/gate-lint.mjs +178 -0
- package/dist/skills/unlazy/scripts/install-hooks.mjs +206 -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 +629 -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/scripts/stop-hook.mjs +174 -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 +481 -0
- package/dist/skills/unlazy/tests/hardening-tests.mjs +903 -0
- package/dist/skills/unlazy/tests/lint-tests.mjs +242 -0
- package/dist/skills/unlazy/tests/run-tests.mjs +554 -0
- package/dist/skills/unlazy/tests/self-check.mjs +165 -0
- package/dist/skills/unlazy/tests/stress-tests.mjs +356 -0
- package/dist/skills/web-design-guidelines/SKILL.md +40 -0
- package/docs/settings.md +0 -5
- package/package.json +1 -1
- package/dist/core/tools/schema-prune.d.ts +0 -16
- package/dist/core/tools/schema-prune.js +0 -39
- package/dist/core/tools/schema-prune.test.d.ts +0 -1
- package/dist/core/tools/schema-prune.test.js +0 -111
- package/dist/extensions/pi-subagents/UPSTREAM-V0.50-MAPPING.md +0 -172
- package/dist/extensions/pi-subagents/prompts/parallel-context-build.md +0 -55
- package/dist/extensions/pi-subagents/prompts/parallel-handoff-plan.md +0 -61
- package/dist/extensions/pi-subagents/src/agents/task-aware-routing.ts +0 -132
- package/dist/extensions/pi-subagents/src/extension/chain-validation.ts +0 -181
- package/dist/extensions/pi-subagents/src/runs/foreground/chain-clarify.ts +0 -1354
- package/dist/extensions/pi-subagents/src/runs/foreground/chain-execution.ts +0 -1581
- package/dist/extensions/pi-subagents/src/shared/env.ts +0 -16
- package/dist/extensions/pi-subagents/src/shared/session-lineage.ts +0 -71
- package/dist/extensions/pi-subagents/src/slash/inline-subagents.ts +0 -136
- package/dist/extensions/pi-subagents/src/workflows/workflow-auto-relaunch.ts +0 -41
- package/dist/extensions/pi-subagents/test/integration/chain-clarify.test.ts +0 -466
- package/dist/extensions/pi-subagents/test/integration/chain-execution.test.ts +0 -1859
- package/dist/extensions/pi-subagents/test/integration/parallel-execution.test.ts +0 -733
- package/dist/extensions/pi-subagents/test/unit/builtin-agent-documentation.test.ts +0 -63
- package/dist/extensions/pi-subagents/test/unit/chain-validation.test.ts +0 -326
- package/dist/extensions/pi-subagents/test/unit/handoff-adoption.test.ts +0 -103
- package/dist/extensions/pi-subagents/test/unit/inline-subagents.test.ts +0 -127
- package/dist/extensions/pi-subagents/test/unit/session-lineage.test.ts +0 -73
- package/dist/extensions/pi-subagents/test/unit/task-aware-routing.test.ts +0 -213
- package/dist/extensions/pi-subagents/test/unit/workflow-auto-relaunch.test.ts +0 -65
|
@@ -7,9 +7,11 @@ import type { Message } from "@earendil-works/pi-ai";
|
|
|
7
7
|
import { writeAtomicJson } from "../../shared/atomic-json.ts";
|
|
8
8
|
import { writeAsyncResultFile, writePendingAsyncResultFile } from "./result-files.ts";
|
|
9
9
|
import { createFileCoalescer } from "../../shared/file-coalescer.ts";
|
|
10
|
-
import {
|
|
10
|
+
import { createCapacityResilientJsonWriter } from "../../shared/capacity-resilient-json.ts";
|
|
11
|
+
import { isStorageCapacityError } from "../../shared/file-system-retry.ts";
|
|
12
|
+
import { updateActiveRunIndex } from "./active-run-index.ts";
|
|
11
13
|
import { createChildTranscriptWriter, type ChildTranscriptWriter } from "../../shared/child-transcript.ts";
|
|
12
|
-
import { closeSteerInbox, consumeInterruptRequest, consumeSteerRequests, deliverInterruptRequest, deliverStopRequest, deliverTimeoutRequest, enqueueStepSteer, steerAcksDir, steerCapabilityPath, stepSteerInboxDir, watchAsyncControlInbox, type SteerAck, type SteerCapability, type SteerRequest } from "./control-channel.ts";
|
|
14
|
+
import { closeSteerInbox, consumeInterruptRequest, consumeSteerRequests, deliverInterruptRequest, deliverStopRequest, deliverTimeoutRequest, enqueueStepSteer, steerAcksDir, steerCapabilityPath, stepSteerInboxDir, watchAsyncControlInbox, type SteerAck, type SteerCapability, type SteerRequest, type StopRequest } from "./control-channel.ts";
|
|
13
15
|
import { appendJsonl as appendRawJsonl, formatOutputArtifactContent, getArtifactPaths, writeArtifact, writeMetadata } from "../../shared/artifacts.ts";
|
|
14
16
|
import { PI_CODING_AGENT_PACKAGE, getPiSpawnCommand, resolveInstalledPiPackageRoot } from "../shared/pi-spawn.ts";
|
|
15
17
|
import { captureSingleOutputSnapshot, extractChildWrittenOutput, finalizeSingleOutput, formatSavedOutputReference, injectOutputPathSystemPrompt, injectSingleOutputInstruction, resolveSingleOutput, type SingleOutputSnapshot } from "../shared/single-output.ts";
|
|
@@ -17,6 +19,8 @@ import {
|
|
|
17
19
|
type ActivityState,
|
|
18
20
|
type ArtifactConfig,
|
|
19
21
|
type ExternalCliRunnerStatus,
|
|
22
|
+
type ExternalJobRunnerStatus,
|
|
23
|
+
type ExternalJobStatus,
|
|
20
24
|
type ExternalProcessStatus,
|
|
21
25
|
type ArtifactPaths,
|
|
22
26
|
type AsyncParallelGroupStatus,
|
|
@@ -44,6 +48,7 @@ import {
|
|
|
44
48
|
type SteeringStatus,
|
|
45
49
|
type SteeringTargetState,
|
|
46
50
|
type SteeringTargetStatus,
|
|
51
|
+
type SubagentChildStatusEvent,
|
|
47
52
|
DEFAULT_MAX_OUTPUT,
|
|
48
53
|
type MaxOutputConfig,
|
|
49
54
|
SUBAGENT_LIFECYCLE_ARTIFACT_VERSION,
|
|
@@ -63,7 +68,6 @@ import {
|
|
|
63
68
|
import {
|
|
64
69
|
type RunnerSubagentStep as SubagentStep,
|
|
65
70
|
type RunnerStep,
|
|
66
|
-
isCheckpointRunnerStep,
|
|
67
71
|
isDynamicRunnerGroup,
|
|
68
72
|
isParallelGroup,
|
|
69
73
|
flattenSteps,
|
|
@@ -76,13 +80,14 @@ import {
|
|
|
76
80
|
import { applyThinkingSuffix, buildPiArgs, cleanupTempDir, projectLaunchResolvedChildExtensions, resolvePiLaunchToolPlan, type SubagentTaskDelivery } from "../shared/pi-args.ts";
|
|
77
81
|
import { readRuntimeAcknowledgedExtensions } from "../shared/runtime-acknowledged-extensions.ts";
|
|
78
82
|
import { outputEntryFromAsyncResult, resolveOutputReferences } from "../shared/chain-outputs.ts";
|
|
79
|
-
import { createStructuredOutputRuntime, MISSING_STRUCTURED_OUTPUT_CALL_ERROR, readStructuredOutput } from "../shared/structured-output.ts";
|
|
83
|
+
import { createStructuredOutputRuntime, MISSING_STRUCTURED_OUTPUT_CALL_ERROR, readStructuredOutput, readStructuredOutputAcceptanceReport } from "../shared/structured-output.ts";
|
|
80
84
|
import { formatProcessSignalError, isUnexplainedProcessSignal } from "../shared/process-signal.ts";
|
|
81
85
|
import { readChildToolDiagnosticError } from "../shared/tool-availability.ts";
|
|
86
|
+
import { buildTimeoutRecoverySummary, collectTrackedMutationEvidence, snapshotTrackedMutations } from "../shared/mutation-evidence.ts";
|
|
82
87
|
import { collectDynamicResults, DynamicFanoutError, materializeDynamicParallelStep, validateDynamicCollection } from "../shared/dynamic-fanout.ts";
|
|
83
88
|
import { claimRunFanoutBatch, getRunFanoutBudgetSnapshot } from "../shared/run-fanout-budget.ts";
|
|
84
89
|
import { nestedSummaryFromAsyncStatus, projectNestedEvents, resolveNestedAsyncDir, writeNestedEvent } from "../shared/nested-events.ts";
|
|
85
|
-
import { formatModelAttemptNote,
|
|
90
|
+
import { formatModelAttemptNote, formatSubagentModelVerificationError, isContextOverflow, isRetryableModelFailure, recordRetryableModelFailure } from "../shared/model-fallback.ts";
|
|
86
91
|
import {
|
|
87
92
|
SUBAGENT_STARTUP_RETRY_DELAYS_MS,
|
|
88
93
|
formatSubagentExtensionConflictError,
|
|
@@ -96,7 +101,7 @@ import { createOwnedProcessTreeController, type OwnedProcessTreeController } fro
|
|
|
96
101
|
import { createSteeringStatus, recordSteeringRequest, steeringStatus, terminalSteeringNoticeState, updateSteeringTarget } from "./steering.ts";
|
|
97
102
|
import { attachPostExitStdioGuard, trySignalChild } from "../../shared/post-exit-stdio-guard.ts";
|
|
98
103
|
import { PROMPT_REDACTED, detectSubagentError, extractTextFromContent, extractToolArgsPreview, getFinalOutput, hasEmptyTerminalAssistantResponse, readStatus } from "../../shared/utils.ts";
|
|
99
|
-
import { evaluateCompletionMutationGuard } from "../shared/completion-guard.ts";
|
|
104
|
+
import { evaluateCompletionMutationGuard, validateImplementationToolContract } from "../shared/completion-guard.ts";
|
|
100
105
|
import {
|
|
101
106
|
createMutatingFailureState,
|
|
102
107
|
didMutatingToolFail,
|
|
@@ -120,13 +125,16 @@ import {
|
|
|
120
125
|
type WorktreeSetup,
|
|
121
126
|
} from "../shared/worktree.ts";
|
|
122
127
|
import { resolveEffectiveThinking } from "../../shared/model-info.ts";
|
|
128
|
+
import { assertThinkingWithinCeiling, decodeThinkingCeiling, SUBAGENT_THINKING_CEILING_ENV } from "../../shared/thinking-ceiling.ts";
|
|
123
129
|
import { launchBindingDigest } from "../../shared/launch-contract.ts";
|
|
124
130
|
import { writeInitialProgressFile } from "../../shared/settings.ts";
|
|
125
131
|
import { resolveSubagentIntercomTarget } from "../../intercom/intercom-bridge.ts";
|
|
126
132
|
import { acceptanceFailureMessage, aggregateAcceptanceReport, buildSkippedAcceptanceLedger, evaluateAcceptance, formatAcceptancePrompt, resolveEffectiveAcceptance, stripAcceptanceReport } from "../shared/acceptance.ts";
|
|
127
133
|
import { attachContractProjections, isAgentContractV1 } from "../shared/agent-contract.ts";
|
|
128
134
|
import { waitForImportedAsyncRoot } from "./chain-root-attachment.ts";
|
|
135
|
+
import { normalizeExtensionBindings } from "../shared/extension-bindings.ts";
|
|
129
136
|
import { appendRunnerStepsToStatus, consumeChainAppendRequests, countPendingChainAppendRequests, statusStepDescription } from "./chain-append.ts";
|
|
137
|
+
import { asyncStatusChildIdentity } from "../shared/child-identity.ts";
|
|
130
138
|
import { appendTurnBudgetSystemPrompt, formatTurnBudgetOutput, initialTurnBudgetState, turnBudgetDecision, turnBudgetDeferredNote, turnBudgetDeferredState, turnBudgetExceededMessage, turnBudgetSoftNote, turnBudgetState } from "../shared/turn-budget.ts";
|
|
131
139
|
import { initialToolBudgetState, toolBudgetState } from "../shared/tool-budget.ts";
|
|
132
140
|
import { effectiveToolTimeoutMs, formatToolTimeoutMessage, toolTimeoutCallKey } from "../shared/tool-timeout.ts";
|
|
@@ -136,6 +144,7 @@ import { resolveWatchdogConfig } from "../../watchdog/settings.ts";
|
|
|
136
144
|
import { createBoundedByteTail, createBoundedLineReader, formatProtocolOutputLimit, MAX_CHILD_STDERR_BYTES, PI_AGGREGATE_EVENT_PROJECTOR, projectChildLifecycle, type ChildLifecycleAction, type ProtocolOutputLimit } from "../shared/child-protocol.ts";
|
|
137
145
|
import { acquireSessionLease, type SessionLeaseRequest } from "../shared/session-lease.ts";
|
|
138
146
|
import { buildExternalCliPrompt, runExternalCli } from "../shared/external-cli-runner.ts";
|
|
147
|
+
import { runExternalJob } from "../shared/external-job-runner.ts";
|
|
139
148
|
import { createOrcaProgressTab, type OrcaProgressTab } from "../shared/orca-progress-tabs.ts";
|
|
140
149
|
import { decodeSubagentCapabilityCeiling, SUBAGENT_CAPABILITY_CEILING_ENV, type ResolvedSubagentCapabilityCeiling } from "../shared/capability-ceiling.ts";
|
|
141
150
|
import {
|
|
@@ -165,6 +174,7 @@ interface SubagentRunConfig {
|
|
|
165
174
|
sessionDir?: string;
|
|
166
175
|
asyncDir: string;
|
|
167
176
|
sessionId?: string | null;
|
|
177
|
+
completionOwnerId?: string;
|
|
168
178
|
piPackageRoot?: string;
|
|
169
179
|
piArgv1?: string;
|
|
170
180
|
worktreeSetupHook?: string;
|
|
@@ -217,9 +227,11 @@ interface StepResult {
|
|
|
217
227
|
savedOutputPath?: string;
|
|
218
228
|
skipped?: boolean;
|
|
219
229
|
interrupted?: boolean;
|
|
230
|
+
detached?: boolean;
|
|
220
231
|
timedOut?: boolean;
|
|
221
232
|
stopped?: boolean;
|
|
222
233
|
processSignal?: string | null;
|
|
234
|
+
timeoutRecovery?: import("../../shared/types.ts").TimeoutRecoverySummary;
|
|
223
235
|
turnBudget?: TurnBudgetState;
|
|
224
236
|
turnBudgetExceeded?: boolean;
|
|
225
237
|
wrapUpRequested?: boolean;
|
|
@@ -230,6 +242,8 @@ interface StepResult {
|
|
|
230
242
|
model?: string;
|
|
231
243
|
attemptedModels?: string[];
|
|
232
244
|
modelAttempts?: ModelAttempt[];
|
|
245
|
+
/** True when the dispatch failed because the input exceeded the model's context window. */
|
|
246
|
+
contextOverflow?: boolean;
|
|
233
247
|
totalCost?: CostSummary;
|
|
234
248
|
artifactPaths?: ArtifactPaths;
|
|
235
249
|
outputSaveError?: string;
|
|
@@ -249,8 +263,9 @@ interface StepResult {
|
|
|
249
263
|
watchdog?: import("../../shared/types.ts").ChildWatchdogProgress;
|
|
250
264
|
writerProcesses?: PiWriterProcessInstanceExitV1[];
|
|
251
265
|
writerAttemptCount?: number;
|
|
252
|
-
runner?: ExternalCliRunnerStatus;
|
|
266
|
+
runner?: ExternalCliRunnerStatus | ExternalJobRunnerStatus;
|
|
253
267
|
externalProcess?: ExternalProcessStatus;
|
|
268
|
+
externalJob?: ExternalJobStatus;
|
|
254
269
|
}
|
|
255
270
|
|
|
256
271
|
function persistStepArtifacts(input: {
|
|
@@ -528,6 +543,9 @@ interface RunPiStreamingResult {
|
|
|
528
543
|
processCloseObservedAt?: number;
|
|
529
544
|
processSignal?: string | null;
|
|
530
545
|
processTree: ProcessTreeTerminalV1;
|
|
546
|
+
currentTool?: string;
|
|
547
|
+
currentToolArgs?: string;
|
|
548
|
+
currentPath?: string;
|
|
531
549
|
}
|
|
532
550
|
|
|
533
551
|
function runPiStreaming(
|
|
@@ -551,6 +569,8 @@ function runPiStreaming(
|
|
|
551
569
|
toolTimeoutMs?: number,
|
|
552
570
|
runDeadlineAt?: number,
|
|
553
571
|
orcaProgressTab?: OrcaProgressTab,
|
|
572
|
+
expectedModelForVerification?: string,
|
|
573
|
+
modelVerificationRegistry?: Array<{ provider: string; id: string; fullId: string }>,
|
|
554
574
|
): Promise<RunPiStreamingResult> {
|
|
555
575
|
return new Promise((resolve) => {
|
|
556
576
|
const startedAt = Date.now();
|
|
@@ -596,6 +616,9 @@ function runPiStreaming(
|
|
|
596
616
|
let observedMutationAttempt = false;
|
|
597
617
|
let structuredOutputToolInvoked = false;
|
|
598
618
|
let structuredOutputMessageStartIndex: number | undefined;
|
|
619
|
+
let currentTool: string | undefined;
|
|
620
|
+
let currentToolArgs: string | undefined;
|
|
621
|
+
let currentPath: string | undefined;
|
|
599
622
|
let toolCount = 0;
|
|
600
623
|
const childWatchdogConfig = decodeChildWatchdogConfig(env?.[CHILD_WATCHDOG_CONFIG_ENV]);
|
|
601
624
|
let childWatchdogState: ChildWatchdogStateSnapshot | undefined;
|
|
@@ -687,12 +710,18 @@ function runPiStreaming(
|
|
|
687
710
|
|
|
688
711
|
if (event.type === "tool_execution_end") {
|
|
689
712
|
clearActiveToolTimeout(event);
|
|
713
|
+
currentTool = undefined;
|
|
714
|
+
currentToolArgs = undefined;
|
|
715
|
+
currentPath = undefined;
|
|
690
716
|
return;
|
|
691
717
|
}
|
|
692
718
|
|
|
693
719
|
if (event.type === "tool_execution_start" && event.toolName) {
|
|
694
720
|
toolCount += 1;
|
|
695
721
|
armToolTimeout({ toolCallId: (event as { toolCallId?: unknown }).toolCallId, toolName: event.toolName });
|
|
722
|
+
currentTool = event.toolName;
|
|
723
|
+
currentToolArgs = extractToolArgsPreview(event.args ?? {});
|
|
724
|
+
currentPath = resolveCurrentPath(event.toolName, event.args);
|
|
696
725
|
if (event.toolName === "structured_output") {
|
|
697
726
|
structuredOutputToolInvoked = true;
|
|
698
727
|
structuredOutputMessageStartIndex = messages.length;
|
|
@@ -709,7 +738,14 @@ function runPiStreaming(
|
|
|
709
738
|
if (text) writeOutputText(text);
|
|
710
739
|
|
|
711
740
|
if (event.type !== "message_end" || event.message.role !== "assistant") return;
|
|
712
|
-
|
|
741
|
+
const hasToolCall = assistantStartsToolCall(event.message);
|
|
742
|
+
if (event.message.model) {
|
|
743
|
+
model = event.message.model;
|
|
744
|
+
if (expectedModelForVerification && !hasToolCall) {
|
|
745
|
+
const modelVerificationError = formatSubagentModelVerificationError(expectedModelForVerification, event.message.model, modelVerificationRegistry);
|
|
746
|
+
if (modelVerificationError && !error) error = modelVerificationError;
|
|
747
|
+
}
|
|
748
|
+
}
|
|
713
749
|
if (event.message.errorMessage) assistantError = event.message.errorMessage;
|
|
714
750
|
const eventUsage = event.message.usage;
|
|
715
751
|
if (eventUsage) {
|
|
@@ -1008,6 +1044,9 @@ function runPiStreaming(
|
|
|
1008
1044
|
processCloseObservedAt,
|
|
1009
1045
|
processSignal: signal,
|
|
1010
1046
|
processTree,
|
|
1047
|
+
currentTool,
|
|
1048
|
+
currentToolArgs,
|
|
1049
|
+
currentPath,
|
|
1011
1050
|
}));
|
|
1012
1051
|
});
|
|
1013
1052
|
|
|
@@ -1057,7 +1096,7 @@ async function exportSessionHtml(sessionFile: string, outputDir: string, piPacka
|
|
|
1057
1096
|
|
|
1058
1097
|
function createShareLink(htmlPath: string): { shareUrl: string; gistUrl: string } | { error: string } {
|
|
1059
1098
|
try {
|
|
1060
|
-
const auth = spawnSync("gh", ["auth", "status"], { encoding: "utf-8" });
|
|
1099
|
+
const auth = spawnSync("gh", ["auth", "status"], { encoding: "utf-8", windowsHide: true });
|
|
1061
1100
|
if (auth.status !== 0) {
|
|
1062
1101
|
return { error: "GitHub CLI is not logged in. Run 'gh auth login' first." };
|
|
1063
1102
|
}
|
|
@@ -1066,7 +1105,7 @@ function createShareLink(htmlPath: string): { shareUrl: string; gistUrl: string
|
|
|
1066
1105
|
}
|
|
1067
1106
|
|
|
1068
1107
|
try {
|
|
1069
|
-
const result = spawnSync("gh", ["gist", "create", htmlPath], { encoding: "utf-8" });
|
|
1108
|
+
const result = spawnSync("gh", ["gist", "create", htmlPath], { encoding: "utf-8", windowsHide: true });
|
|
1070
1109
|
if (result.status !== 0) {
|
|
1071
1110
|
const err = (result.stderr || "").trim() || "Failed to create gist.";
|
|
1072
1111
|
return { error: err };
|
|
@@ -1109,6 +1148,7 @@ function writeRunLog(
|
|
|
1109
1148
|
shareUrl?: string;
|
|
1110
1149
|
shareError?: string;
|
|
1111
1150
|
},
|
|
1151
|
+
write: (filePath: string, content: string) => void = (filePath, content) => fs.writeFileSync(filePath, content, "utf-8"),
|
|
1112
1152
|
): void {
|
|
1113
1153
|
const lines: string[] = [];
|
|
1114
1154
|
lines.push(`# Subagent run ${input.id}`);
|
|
@@ -1138,7 +1178,7 @@ function writeRunLog(
|
|
|
1138
1178
|
}
|
|
1139
1179
|
lines.push(input.summary.trim() || "(no output)");
|
|
1140
1180
|
lines.push("");
|
|
1141
|
-
|
|
1181
|
+
write(logPath, lines.join("\n"));
|
|
1142
1182
|
}
|
|
1143
1183
|
|
|
1144
1184
|
/** Context for running a single step */
|
|
@@ -1183,7 +1223,10 @@ interface SingleStepContext {
|
|
|
1183
1223
|
onChildEvent?: (event: ChildEvent) => void;
|
|
1184
1224
|
onWriterProcess?: (writer: { state: "none" | "spawning" } | { state: "running"; pid: number }) => void;
|
|
1185
1225
|
onExternalProcess?: (process: ExternalProcessStatus) => void;
|
|
1226
|
+
onExternalJob?: (status: ExternalJobStatus) => void;
|
|
1186
1227
|
skipAcceptance?: () => boolean;
|
|
1228
|
+
/** False when sibling work in the same Git worktree could have caused the tracked diff. */
|
|
1229
|
+
trackedMutationEvidenceForCompletionGuard?: boolean;
|
|
1187
1230
|
orcaProgressTab?: OrcaProgressTab;
|
|
1188
1231
|
}
|
|
1189
1232
|
|
|
@@ -1248,6 +1291,7 @@ async function runSingleStepInner(
|
|
|
1248
1291
|
model: imported.model,
|
|
1249
1292
|
attemptedModels: imported.attemptedModels,
|
|
1250
1293
|
modelAttempts: imported.modelAttempts,
|
|
1294
|
+
contextOverflow: imported.contextOverflow,
|
|
1251
1295
|
totalCost: imported.totalCost,
|
|
1252
1296
|
structuredOutput: timedOut || stopped ? undefined : imported.structuredOutput,
|
|
1253
1297
|
structuredOutputPath: timedOut || stopped ? undefined : imported.structuredOutputPath,
|
|
@@ -1267,8 +1311,48 @@ async function runSingleStepInner(
|
|
|
1267
1311
|
let task = step.task.replace(placeholderRegex, () => ctx.previousOutput);
|
|
1268
1312
|
if (ctx.outputs) task = resolveOutputReferences(task, ctx.outputs);
|
|
1269
1313
|
const taskForCompletionGuard = task;
|
|
1314
|
+
let resolvedTaskToolPlan: ReturnType<typeof resolvePiLaunchToolPlan> | undefined;
|
|
1315
|
+
if (!step.runner) {
|
|
1316
|
+
resolvedTaskToolPlan = resolvePiLaunchToolPlan(omitUndefinedProperties({
|
|
1317
|
+
tools: step.tools,
|
|
1318
|
+
extensions: step.extensions,
|
|
1319
|
+
subagentOnlyExtensions: step.subagentOnlyExtensions,
|
|
1320
|
+
fast: step.fast,
|
|
1321
|
+
model: step.model,
|
|
1322
|
+
modelCandidates: step.modelCandidates,
|
|
1323
|
+
mcpDirectTools: step.mcpDirectTools,
|
|
1324
|
+
cwd: step.cwd ?? ctx.cwd,
|
|
1325
|
+
requireReadTool: Boolean(step.skills?.length),
|
|
1326
|
+
structuredOutput: Boolean(effectiveStructuredOutput),
|
|
1327
|
+
capabilityCeiling: step.capabilityCeiling ?? ctx.capabilityCeiling,
|
|
1328
|
+
inheritedCapabilityCeiling: decodeSubagentCapabilityCeiling(process.env[SUBAGENT_CAPABILITY_CEILING_ENV]),
|
|
1329
|
+
permissionRules: step.permissionRules,
|
|
1330
|
+
}));
|
|
1331
|
+
const contractTools = resolvedTaskToolPlan.explicitToolAllowlist ? resolvedTaskToolPlan.effectiveToolAllowlist : undefined;
|
|
1332
|
+
const contractError = validateImplementationToolContract({
|
|
1333
|
+
agent: step.agent,
|
|
1334
|
+
task: taskForCompletionGuard,
|
|
1335
|
+
tools: contractTools,
|
|
1336
|
+
mcpDirectTools: resolvedTaskToolPlan.effectiveMcpTools,
|
|
1337
|
+
configuredExtensions: resolvedTaskToolPlan.configuredExtensions,
|
|
1338
|
+
requestedTools: resolvedTaskToolPlan.requestedBuiltinTools,
|
|
1339
|
+
acceptanceRole: step.acceptanceRole,
|
|
1340
|
+
completionGuard: step.completionGuard,
|
|
1341
|
+
});
|
|
1342
|
+
if (contractError) {
|
|
1343
|
+
return omitUndefinedProperties({
|
|
1344
|
+
agent: step.agent,
|
|
1345
|
+
context: step.context,
|
|
1346
|
+
output: contractError,
|
|
1347
|
+
error: contractError,
|
|
1348
|
+
exitCode: 1,
|
|
1349
|
+
capabilityCeiling: resolvedTaskToolPlan.capabilityCeiling,
|
|
1350
|
+
capabilityAudit: resolvedTaskToolPlan.capabilityAudit,
|
|
1351
|
+
});
|
|
1352
|
+
}
|
|
1353
|
+
}
|
|
1270
1354
|
if (step.effectiveAcceptance) {
|
|
1271
|
-
const acceptancePrompt = formatAcceptancePrompt(step.effectiveAcceptance, { reportOptional: isAgentContractV1(step.agentContract) });
|
|
1355
|
+
const acceptancePrompt = formatAcceptancePrompt(step.effectiveAcceptance, { reportOptional: isAgentContractV1(step.agentContract), structuredOutput: Boolean(step.structuredOutput?.acceptanceReportPath) });
|
|
1272
1356
|
if (acceptancePrompt) task = `${task}\n${acceptancePrompt}`;
|
|
1273
1357
|
}
|
|
1274
1358
|
const sessionEnabled = Boolean(step.sessionFile) || ctx.sessionEnabled;
|
|
@@ -1360,8 +1444,72 @@ async function runSingleStepInner(
|
|
|
1360
1444
|
});
|
|
1361
1445
|
}
|
|
1362
1446
|
|
|
1363
|
-
|
|
1364
|
-
|
|
1447
|
+
if (step.runner?.type === "external-job") {
|
|
1448
|
+
const runner: ExternalJobRunnerStatus = {
|
|
1449
|
+
type: "external-job",
|
|
1450
|
+
provider: step.runner.provider,
|
|
1451
|
+
options: step.runner.options ?? {},
|
|
1452
|
+
capabilities: { stop: false, steer: false, resume: false, structuredOutput: false, toolEvents: false },
|
|
1453
|
+
};
|
|
1454
|
+
const outputSnapshot = captureSingleOutputSnapshot(step.outputPath);
|
|
1455
|
+
const external = await runExternalJob(omitUndefinedProperties({
|
|
1456
|
+
provider: runner.provider,
|
|
1457
|
+
options: runner.options,
|
|
1458
|
+
cwd: step.cwd ?? ctx.cwd,
|
|
1459
|
+
prompt: buildExternalCliPrompt(step.systemPrompt ?? "", task),
|
|
1460
|
+
asyncDir: path.dirname(ctx.outputFile),
|
|
1461
|
+
stepIndex: ctx.flatIndex,
|
|
1462
|
+
runId: ctx.id,
|
|
1463
|
+
agent: step.agent,
|
|
1464
|
+
sessionId: step.parentSessionId,
|
|
1465
|
+
registerTimeout: ctx.registerTimeout,
|
|
1466
|
+
registerStop: ctx.registerStop,
|
|
1467
|
+
timeoutMessage: ctx.timeoutMessage,
|
|
1468
|
+
stopMessage: ctx.stopMessage,
|
|
1469
|
+
onExternalJob: ctx.onExternalJob,
|
|
1470
|
+
followUp: step.externalJobFollowUp,
|
|
1471
|
+
}));
|
|
1472
|
+
try { fs.writeFileSync(ctx.outputFile, external.output, "utf-8"); } catch { /* Observability output is best-effort. */ }
|
|
1473
|
+
const resolvedOutput = step.outputPath && external.exitCode === 0
|
|
1474
|
+
? resolveSingleOutput(step.outputPath, external.output, outputSnapshot)
|
|
1475
|
+
: { fullOutput: external.output };
|
|
1476
|
+
const outputReference = resolvedOutput.savedPath ? formatSavedOutputReference(resolvedOutput.savedPath, resolvedOutput.fullOutput) : undefined;
|
|
1477
|
+
const finalizedOutput = finalizeSingleOutput(omitUndefinedProperties({
|
|
1478
|
+
fullOutput: resolvedOutput.fullOutput,
|
|
1479
|
+
outputPath: step.outputPath,
|
|
1480
|
+
outputMode: step.outputMode,
|
|
1481
|
+
exitCode: external.exitCode,
|
|
1482
|
+
savedPath: resolvedOutput.savedPath,
|
|
1483
|
+
outputReference,
|
|
1484
|
+
saveError: resolvedOutput.saveError,
|
|
1485
|
+
}));
|
|
1486
|
+
const artifactErrors = artifactPaths && ctx.artifactConfig?.enabled !== false
|
|
1487
|
+
? persistStepArtifacts({
|
|
1488
|
+
artifactPaths,
|
|
1489
|
+
artifactConfig: ctx.artifactConfig,
|
|
1490
|
+
output: formatOutputArtifactContent(omitUndefinedProperties({ output: resolvedOutput.fullOutput, error: external.error, metadataPath: ctx.artifactConfig?.includeMetadata === false ? undefined : artifactPaths.metadataPath })),
|
|
1491
|
+
metadata: { runId: ctx.id, agent: step.agent, task: PROMPT_REDACTED, runner, externalJob: external.externalJob, exitCode: external.exitCode, error: external.error, timestamp: Date.now() },
|
|
1492
|
+
})
|
|
1493
|
+
: {};
|
|
1494
|
+
return omitUndefinedProperties({
|
|
1495
|
+
agent: step.agent,
|
|
1496
|
+
context: step.context,
|
|
1497
|
+
output: finalizedOutput.displayOutput,
|
|
1498
|
+
outputState: external.output.trim() ? "present" : "absent",
|
|
1499
|
+
exitCode: external.exitCode,
|
|
1500
|
+
error: external.error,
|
|
1501
|
+
timedOut: external.timedOut,
|
|
1502
|
+
stopped: external.stopped,
|
|
1503
|
+
artifactPaths,
|
|
1504
|
+
outputSaveError: artifactErrors.outputSaveError,
|
|
1505
|
+
metadataSaveError: artifactErrors.metadataSaveError,
|
|
1506
|
+
runner,
|
|
1507
|
+
externalJob: external.externalJob,
|
|
1508
|
+
});
|
|
1509
|
+
}
|
|
1510
|
+
|
|
1511
|
+
const candidates = step.modelCandidates !== undefined
|
|
1512
|
+
? step.modelCandidates.length > 0 ? step.modelCandidates : [undefined]
|
|
1365
1513
|
: step.model
|
|
1366
1514
|
? [step.model]
|
|
1367
1515
|
: [undefined];
|
|
@@ -1375,21 +1523,33 @@ async function runSingleStepInner(
|
|
|
1375
1523
|
const eventsPath = path.join(path.dirname(ctx.outputFile), "events.jsonl");
|
|
1376
1524
|
let finalResult: RunPiStreamingResult | undefined;
|
|
1377
1525
|
let finalOutputSnapshot: SingleOutputSnapshot | undefined;
|
|
1526
|
+
let structuredAcceptanceReport: unknown;
|
|
1527
|
+
let structuredAcceptanceReportError: string | undefined;
|
|
1378
1528
|
let completionGuardTriggeredFinal = false;
|
|
1379
1529
|
let turnBudget = ctx.turnBudget ? initialTurnBudgetState(ctx.turnBudget) : undefined;
|
|
1380
1530
|
let toolBudget = step.toolBudget ? initialToolBudgetState(step.toolBudget) : undefined;
|
|
1381
1531
|
let toolBudgetBlocked = false;
|
|
1382
1532
|
let actualLaunchContractDigest = step.launchContractDigest;
|
|
1533
|
+
const mutationSnapshot = snapshotTrackedMutations(step.cwd ?? ctx.cwd);
|
|
1534
|
+
let finalMutationEvidence = collectTrackedMutationEvidence(mutationSnapshot, step.cwd ?? ctx.cwd);
|
|
1383
1535
|
|
|
1384
1536
|
let modelIndex = 0;
|
|
1385
1537
|
let startupAttemptIndex = 0;
|
|
1386
|
-
let modelRetryIndex = 0;
|
|
1387
1538
|
// Escalated to "file" after an unexplained zero-activity startup failure so
|
|
1388
1539
|
// retries keep the task text out of argv (endpoint pre-exec scans may deny it).
|
|
1389
1540
|
let taskDeliveryOverride: SubagentTaskDelivery | undefined;
|
|
1541
|
+
let contextOverflow = false;
|
|
1542
|
+
let launchWarningsEmitted = false;
|
|
1390
1543
|
modelAttemptsLoop: while (modelIndex < candidates.length) {
|
|
1391
1544
|
if (ctx.timeoutSignal?.aborted || ctx.stopSignal?.aborted || ctx.skipAcceptance?.()) break;
|
|
1392
1545
|
const candidate = candidates[modelIndex];
|
|
1546
|
+
const expectedModelForVerification = candidate && !(step.skipPrimaryModelVerification && modelIndex === 0) ? candidate : undefined;
|
|
1547
|
+
try {
|
|
1548
|
+
assertThinkingWithinCeiling({ model: candidate, configThinking: step.thinking, ceiling: step.thinkingCeiling ?? decodeThinkingCeiling(process.env[SUBAGENT_THINKING_CEILING_ENV]), agent: step.agent, runId: ctx.id });
|
|
1549
|
+
} catch (error) {
|
|
1550
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
1551
|
+
return omitUndefinedProperties({ agent: step.agent, output: message, error: message, exitCode: 1, context: step.context, thinkingCeiling: step.thinkingCeiling });
|
|
1552
|
+
}
|
|
1393
1553
|
ctx.onAttemptStart?.(omitUndefinedProperties({ model: candidate, thinking: resolveEffectiveThinking(candidate, step.thinking) }));
|
|
1394
1554
|
const outputSnapshot = captureSingleOutputSnapshot(step.outputPath);
|
|
1395
1555
|
if (effectiveStructuredOutput) {
|
|
@@ -1400,6 +1560,7 @@ async function runSingleStepInner(
|
|
|
1400
1560
|
}
|
|
1401
1561
|
}
|
|
1402
1562
|
const watchdogConfig = resolveWatchdogConfig(step.cwd ?? ctx.cwd);
|
|
1563
|
+
const extensionBindings = normalizeExtensionBindings(step.extensionBindings)?.value;
|
|
1403
1564
|
const childWatchdog = watchdogConfig.ok
|
|
1404
1565
|
? resolveChildWatchdogConfig({
|
|
1405
1566
|
config: watchdogConfig.config,
|
|
@@ -1408,7 +1569,7 @@ async function runSingleStepInner(
|
|
|
1408
1569
|
childIndex: ctx.flatIndex,
|
|
1409
1570
|
})
|
|
1410
1571
|
: undefined;
|
|
1411
|
-
const { args, env, tempDir, toolDiagnosticPath, runtimeAcknowledgedExtensionsPath, capabilityAudit: attemptCapabilityAudit } = buildPiArgs(omitUndefinedProperties({
|
|
1572
|
+
const { args, env, tempDir, toolDiagnosticPath, runtimeAcknowledgedExtensionsPath, capabilityAudit: attemptCapabilityAudit, warnings } = buildPiArgs(omitUndefinedProperties({
|
|
1412
1573
|
parentSessionId: step.parentSessionId,
|
|
1413
1574
|
baseArgs: ["--mode", "json", "-p"],
|
|
1414
1575
|
task,
|
|
@@ -1423,6 +1584,8 @@ async function runSingleStepInner(
|
|
|
1423
1584
|
tools: step.tools,
|
|
1424
1585
|
extensions: step.extensions,
|
|
1425
1586
|
subagentOnlyExtensions: step.subagentOnlyExtensions,
|
|
1587
|
+
fast: step.fast,
|
|
1588
|
+
modelCandidates: step.modelCandidates,
|
|
1426
1589
|
systemPrompt: appendTurnBudgetSystemPrompt(step.systemPrompt ?? "", ctx.turnBudget),
|
|
1427
1590
|
systemPromptMode: step.systemPromptMode,
|
|
1428
1591
|
mcpDirectTools: step.mcpDirectTools,
|
|
@@ -1453,18 +1616,28 @@ async function runSingleStepInner(
|
|
|
1453
1616
|
: undefined,
|
|
1454
1617
|
childWatchdog,
|
|
1455
1618
|
waitToolEnabled: step.waitToolEnabled,
|
|
1619
|
+
thinkingCeiling: step.thinkingCeiling,
|
|
1620
|
+
extensionBindings,
|
|
1456
1621
|
}));
|
|
1622
|
+
if (!launchWarningsEmitted && warnings.length > 0) {
|
|
1623
|
+
for (const warning of warnings) console.warn(`[pi-subagents] ${warning}`);
|
|
1624
|
+
launchWarningsEmitted = true;
|
|
1625
|
+
}
|
|
1457
1626
|
if (step.definitionDigest) {
|
|
1458
|
-
const toolPlan = resolvePiLaunchToolPlan(omitUndefinedProperties({
|
|
1627
|
+
const toolPlan = resolvedTaskToolPlan ?? resolvePiLaunchToolPlan(omitUndefinedProperties({
|
|
1459
1628
|
tools: step.tools,
|
|
1460
1629
|
extensions: step.extensions,
|
|
1461
1630
|
subagentOnlyExtensions: step.subagentOnlyExtensions,
|
|
1631
|
+
fast: step.fast,
|
|
1632
|
+
model: step.model,
|
|
1633
|
+
modelCandidates: step.modelCandidates,
|
|
1462
1634
|
mcpDirectTools: step.mcpDirectTools,
|
|
1463
1635
|
cwd: step.cwd ?? ctx.cwd,
|
|
1464
1636
|
requireReadTool: Boolean(step.skills?.length),
|
|
1465
1637
|
structuredOutput: Boolean(effectiveStructuredOutput),
|
|
1466
1638
|
capabilityCeiling: step.capabilityCeiling ?? ctx.capabilityCeiling,
|
|
1467
1639
|
inheritedCapabilityCeiling: decodeSubagentCapabilityCeiling(process.env[SUBAGENT_CAPABILITY_CEILING_ENV]),
|
|
1640
|
+
permissionRules: step.permissionRules,
|
|
1468
1641
|
}));
|
|
1469
1642
|
launchResolvedExtensions = projectLaunchResolvedChildExtensions(toolPlan);
|
|
1470
1643
|
actualLaunchContractDigest = launchBindingDigest(omitUndefinedProperties({
|
|
@@ -1472,7 +1645,9 @@ async function runSingleStepInner(
|
|
|
1472
1645
|
task: step.launchBindingTask ?? task,
|
|
1473
1646
|
...(candidate ? { model: candidate } : {}),
|
|
1474
1647
|
modelCandidates: candidates as string[],
|
|
1648
|
+
...(step.fast !== undefined ? { fast: step.fast } : {}),
|
|
1475
1649
|
...(resolveEffectiveThinking(candidate, step.thinking) ? { thinking: resolveEffectiveThinking(candidate, step.thinking) } : {}),
|
|
1650
|
+
...(step.thinkingCeiling ? { thinkingCeiling: step.thinkingCeiling } : {}),
|
|
1476
1651
|
systemPrompt: appendTurnBudgetSystemPrompt(step.systemPrompt ?? "", ctx.turnBudget),
|
|
1477
1652
|
systemPromptMode: step.systemPromptMode,
|
|
1478
1653
|
inheritProjectContext: step.inheritProjectContext,
|
|
@@ -1484,6 +1659,7 @@ async function runSingleStepInner(
|
|
|
1484
1659
|
...(step.outputPath ? { outputPath: step.outputPath } : {}),
|
|
1485
1660
|
...(step.outputMode ? { outputMode: step.outputMode } : {}),
|
|
1486
1661
|
...(step.structuredOutputSchema ? { structuredOutputSchema: step.structuredOutputSchema } : {}),
|
|
1662
|
+
...(extensionBindings ? { extensionBindings } : {}),
|
|
1487
1663
|
}));
|
|
1488
1664
|
}
|
|
1489
1665
|
capabilityAudit = attemptCapabilityAudit;
|
|
@@ -1509,6 +1685,8 @@ async function runSingleStepInner(
|
|
|
1509
1685
|
ctx.toolTimeoutMs,
|
|
1510
1686
|
ctx.deadlineAt,
|
|
1511
1687
|
ctx.orcaProgressTab,
|
|
1688
|
+
expectedModelForVerification,
|
|
1689
|
+
step.modelVerificationRegistry,
|
|
1512
1690
|
);
|
|
1513
1691
|
if (run.processCloseObservedAt !== undefined) {
|
|
1514
1692
|
writerProcesses.push({
|
|
@@ -1561,6 +1739,9 @@ async function runSingleStepInner(
|
|
|
1561
1739
|
if (structured.error) structuredError = structured.error;
|
|
1562
1740
|
else {
|
|
1563
1741
|
structuredOutput = structured.value;
|
|
1742
|
+
const acceptanceReport = readStructuredOutputAcceptanceReport(effectiveStructuredOutput);
|
|
1743
|
+
structuredAcceptanceReport = acceptanceReport.value;
|
|
1744
|
+
structuredAcceptanceReportError = acceptanceReport.error;
|
|
1564
1745
|
validatedStructuredOutput = true;
|
|
1565
1746
|
}
|
|
1566
1747
|
}
|
|
@@ -1581,21 +1762,31 @@ async function runSingleStepInner(
|
|
|
1581
1762
|
? "Subagent produced no output (possible model cold-start or empty response)."
|
|
1582
1763
|
: undefined;
|
|
1583
1764
|
const completionGuardEnabled = isAgentContractV1(step.agentContract) ? step.completionGuard === true : step.completionGuard !== false;
|
|
1584
|
-
const
|
|
1765
|
+
const completionToolPlan = resolvedTaskToolPlan;
|
|
1766
|
+
const mutationEvidence = collectTrackedMutationEvidence(mutationSnapshot, step.cwd ?? ctx.cwd);
|
|
1767
|
+
finalMutationEvidence = mutationEvidence;
|
|
1768
|
+
const completionMutationEvidence = ctx.trackedMutationEvidenceForCompletionGuard === false ? undefined : mutationEvidence;
|
|
1769
|
+
const completionGuard = run.exitCode === 0 && !run.error && !structuredError && !hiddenError?.hasError && !emptyOutputError && completionGuardEnabled
|
|
1585
1770
|
? evaluateCompletionMutationGuard(omitUndefinedProperties({
|
|
1586
1771
|
agent: step.agent,
|
|
1587
1772
|
task: taskForCompletionGuard,
|
|
1588
1773
|
messages: run.messages,
|
|
1589
|
-
tools: step.tools,
|
|
1590
|
-
mcpDirectTools: step.mcpDirectTools,
|
|
1774
|
+
tools: completionToolPlan ? (completionToolPlan.explicitToolAllowlist ? completionToolPlan.effectiveToolAllowlist : undefined) : step.tools,
|
|
1775
|
+
mcpDirectTools: completionToolPlan?.effectiveMcpTools ?? step.mcpDirectTools,
|
|
1776
|
+
toolAvailabilityError,
|
|
1777
|
+
mutationEvidence: completionMutationEvidence,
|
|
1591
1778
|
}))
|
|
1592
1779
|
: undefined;
|
|
1593
|
-
const
|
|
1780
|
+
const mutationAttemptObserved = run.observedMutationAttempt === true || completionMutationEvidence?.attemptedMutation === true;
|
|
1781
|
+
const completionGuardTriggered = completionGuard?.triggered === true && !mutationAttemptObserved;
|
|
1782
|
+
const completionGuardBlocked = completionGuard?.blocked === true;
|
|
1594
1783
|
const fileMutationEffect = completionGuard
|
|
1595
1784
|
? {
|
|
1596
|
-
status: completionGuard.expectedMutation ? completionGuardTriggered ? "missing" as const : "observed" as const : "not-applicable" as const,
|
|
1785
|
+
status: completionGuardBlocked ? "blocked" as const : completionGuard.expectedMutation ? completionGuardTriggered ? "missing" as const : "observed" as const : "not-applicable" as const,
|
|
1597
1786
|
expected: completionGuard.expectedMutation,
|
|
1598
|
-
attempted: completionGuard.attemptedMutation ||
|
|
1787
|
+
attempted: completionGuardBlocked ? false : completionGuard.attemptedMutation || mutationAttemptObserved,
|
|
1788
|
+
...(completionMutationEvidence ? { evidence: completionMutationEvidence } : {}),
|
|
1789
|
+
...(completionGuardBlocked && completionGuard.message ? { message: completionGuard.message } : {}),
|
|
1599
1790
|
...(completionGuardTriggered ? { message: "Subagent completed without making edits for an implementation task." } : {}),
|
|
1600
1791
|
}
|
|
1601
1792
|
: undefined;
|
|
@@ -1698,32 +1889,17 @@ async function runSingleStepInner(
|
|
|
1698
1889
|
finalResult.finalOutput = startupError;
|
|
1699
1890
|
break modelAttemptsLoop;
|
|
1700
1891
|
}
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
continue;
|
|
1708
|
-
}
|
|
1709
|
-
const modelRetryDelayMs = MODEL_RETRY_DELAYS_MS[modelRetryIndex];
|
|
1710
|
-
if (modelRetryDelayMs !== undefined) {
|
|
1711
|
-
const retryNote = formatModelRetryNote({
|
|
1712
|
-
model: attempt.model,
|
|
1713
|
-
attempt: modelRetryIndex + 1,
|
|
1714
|
-
maxAttempts: MODEL_RETRY_DELAYS_MS.length + 1,
|
|
1715
|
-
delayMs: modelRetryDelayMs,
|
|
1716
|
-
});
|
|
1717
|
-
const shouldRetry = await waitForSubagentStartupRetry(modelRetryDelayMs, [ctx.timeoutSignal, ctx.stopSignal]);
|
|
1718
|
-
if (!shouldRetry || ctx.skipAcceptance?.()) break modelAttemptsLoop;
|
|
1719
|
-
attempt.error = retryNote;
|
|
1720
|
-
attemptNotes.push(retryNote);
|
|
1721
|
-
modelRetryIndex += 1;
|
|
1722
|
-
startupAttemptIndex = 0;
|
|
1723
|
-
continue;
|
|
1724
|
-
}
|
|
1892
|
+
const retryableModelFailure = isRetryableModelFailure(error);
|
|
1893
|
+
if (retryableModelFailure) recordRetryableModelFailure(candidate ?? run.model ?? step.model, error);
|
|
1894
|
+
if (isContextOverflow(error)) {
|
|
1895
|
+
contextOverflow = true;
|
|
1896
|
+
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.`);
|
|
1897
|
+
break modelAttemptsLoop;
|
|
1725
1898
|
}
|
|
1726
|
-
break modelAttemptsLoop;
|
|
1899
|
+
if (!retryableModelFailure || modelIndex === candidates.length - 1) break modelAttemptsLoop;
|
|
1900
|
+
attemptNotes.push(formatModelAttemptNote(attempt, candidates[modelIndex + 1]));
|
|
1901
|
+
modelIndex += 1;
|
|
1902
|
+
startupAttemptIndex = 0;
|
|
1727
1903
|
}
|
|
1728
1904
|
|
|
1729
1905
|
const rawOutput = finalResult?.finalOutput ?? "";
|
|
@@ -1759,6 +1935,21 @@ async function runSingleStepInner(
|
|
|
1759
1935
|
: resolvedOutput.savedPath
|
|
1760
1936
|
? "unknown"
|
|
1761
1937
|
: finalResult?.outputState ?? "unknown";
|
|
1938
|
+
const timeoutRecovery = finalResult?.timedOut === true || ctx.timeoutSignal?.aborted === true
|
|
1939
|
+
? buildTimeoutRecoverySummary({
|
|
1940
|
+
termination: "timed-out",
|
|
1941
|
+
evidence: finalMutationEvidence,
|
|
1942
|
+
currentTool: finalResult?.currentTool,
|
|
1943
|
+
currentToolArgs: finalResult?.currentToolArgs,
|
|
1944
|
+
currentPath: finalResult?.currentPath,
|
|
1945
|
+
sessionFile: step.sessionFile,
|
|
1946
|
+
transcriptPath: transcriptWriter ? artifactPaths?.transcriptPath : undefined,
|
|
1947
|
+
artifactPaths,
|
|
1948
|
+
})
|
|
1949
|
+
: undefined;
|
|
1950
|
+
if (timeoutRecovery) outputForSummary = outputForSummary.trim()
|
|
1951
|
+
? `${outputForSummary}\n\n${timeoutRecovery.message}`
|
|
1952
|
+
: timeoutRecovery.message;
|
|
1762
1953
|
const finalizedOutput = finalizeSingleOutput(omitUndefinedProperties({
|
|
1763
1954
|
fullOutput: outputForSummary,
|
|
1764
1955
|
outputPath: step.outputPath,
|
|
@@ -1773,6 +1964,8 @@ async function runSingleStepInner(
|
|
|
1773
1964
|
? await evaluateAcceptance(omitUndefinedProperties({
|
|
1774
1965
|
acceptance: step.effectiveAcceptance,
|
|
1775
1966
|
output: outputForAcceptance,
|
|
1967
|
+
report: structuredAcceptanceReport as import("../../shared/types.ts").AcceptanceReport | undefined,
|
|
1968
|
+
reportError: structuredAcceptanceReportError,
|
|
1776
1969
|
fileOutput: childWrittenOutput !== undefined && step.outputPath
|
|
1777
1970
|
? { content: childWrittenOutput, path: step.outputPath, authoritative: step.outputMode === "file-only" }
|
|
1778
1971
|
: undefined,
|
|
@@ -1857,6 +2050,7 @@ async function runSingleStepInner(
|
|
|
1857
2050
|
model: finalResult?.model,
|
|
1858
2051
|
attemptedModels: attemptedModels.length > 0 ? attemptedModels : undefined,
|
|
1859
2052
|
modelAttempts,
|
|
2053
|
+
contextOverflow: contextOverflow || undefined,
|
|
1860
2054
|
totalCost: costSummaryFromAttempts(modelAttempts),
|
|
1861
2055
|
artifactPaths,
|
|
1862
2056
|
outputSaveError: artifactErrors.outputSaveError,
|
|
@@ -1867,6 +2061,7 @@ async function runSingleStepInner(
|
|
|
1867
2061
|
timedOut: timedOutAfterAcceptance ? true : finalResult?.timedOut,
|
|
1868
2062
|
stopped: stoppedAfterAcceptance ? true : finalResult?.stopped,
|
|
1869
2063
|
processSignal: finalResult?.processSignal,
|
|
2064
|
+
timeoutRecovery,
|
|
1870
2065
|
turnBudget,
|
|
1871
2066
|
turnBudgetExceeded: turnBudgetExceeded || undefined,
|
|
1872
2067
|
wrapUpRequested: finalResult?.wrapUpRequested || turnBudget?.outcome === "wrap-up-requested" || turnBudget?.outcome === "termination-deferred" || turnBudgetExceeded || undefined,
|
|
@@ -1892,21 +2087,8 @@ async function runSingleStep(
|
|
|
1892
2087
|
step: SubagentStep,
|
|
1893
2088
|
ctx: SingleStepContext,
|
|
1894
2089
|
): Promise<StepResult & { completionGuardTriggered?: boolean }> {
|
|
1895
|
-
if (step.importAsyncRoot)
|
|
1896
|
-
|
|
1897
|
-
cwd: step.cwd ?? ctx.cwd,
|
|
1898
|
-
runId: ctx.id,
|
|
1899
|
-
agent: step.agent,
|
|
1900
|
-
index: ctx.flatIndex,
|
|
1901
|
-
});
|
|
1902
|
-
try {
|
|
1903
|
-
const result = await runSingleStepInner(step, { ...ctx, orcaProgressTab });
|
|
1904
|
-
orcaProgressTab?.finish(result.stopped ? "stopped" : result.exitCode === 0 && !result.error ? "completed" : "failed", result.sessionFile);
|
|
1905
|
-
return result;
|
|
1906
|
-
} catch (error) {
|
|
1907
|
-
orcaProgressTab?.finish("failed");
|
|
1908
|
-
throw error;
|
|
1909
|
-
}
|
|
2090
|
+
if (!step.importAsyncRoot) ctx.orcaProgressTab?.section({ agent: step.agent, index: ctx.flatIndex, count: ctx.flatStepCount });
|
|
2091
|
+
return runSingleStepInner(step, ctx);
|
|
1910
2092
|
}
|
|
1911
2093
|
|
|
1912
2094
|
type RunnerStatusStep = NonNullable<AsyncStatus["steps"]>[number] & {
|
|
@@ -1914,15 +2096,25 @@ type RunnerStatusStep = NonNullable<AsyncStatus["steps"]>[number] & {
|
|
|
1914
2096
|
description?: string;
|
|
1915
2097
|
};
|
|
1916
2098
|
|
|
1917
|
-
function externalRunnerStatus(runner: SubagentStep["runner"]): ExternalCliRunnerStatus | undefined {
|
|
1918
|
-
if (runner?.type
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
2099
|
+
function externalRunnerStatus(runner: SubagentStep["runner"]): ExternalCliRunnerStatus | ExternalJobRunnerStatus | undefined {
|
|
2100
|
+
if (runner?.type === "external-cli") {
|
|
2101
|
+
return {
|
|
2102
|
+
type: "external-cli",
|
|
2103
|
+
command: runner.command,
|
|
2104
|
+
args: runner.args ?? [],
|
|
2105
|
+
promptDelivery: runner.promptDelivery ?? "stdin",
|
|
2106
|
+
capabilities: { stop: true, steer: false, resume: false, structuredOutput: false, toolEvents: false },
|
|
2107
|
+
};
|
|
2108
|
+
}
|
|
2109
|
+
if (runner?.type === "external-job") {
|
|
2110
|
+
return {
|
|
2111
|
+
type: "external-job",
|
|
2112
|
+
provider: runner.provider,
|
|
2113
|
+
options: runner.options ?? {},
|
|
2114
|
+
capabilities: { stop: false, steer: false, resume: false, structuredOutput: false, toolEvents: false },
|
|
2115
|
+
};
|
|
2116
|
+
}
|
|
2117
|
+
return undefined;
|
|
1926
2118
|
}
|
|
1927
2119
|
|
|
1928
2120
|
function appendCapabilityCeilingAppliedEvent(eventsPath: string, runId: string, stepIndex: number, agent: string, result: StepResult): void {
|
|
@@ -1971,6 +2163,7 @@ function markParallelGroupSetupFailure(input: {
|
|
|
1971
2163
|
asyncDir: string;
|
|
1972
2164
|
runId: string;
|
|
1973
2165
|
stepIndex: number;
|
|
2166
|
+
writeStatus: (status: RunnerStatusPayload) => void;
|
|
1974
2167
|
}): void {
|
|
1975
2168
|
for (let taskIndex = 0; taskIndex < input.group.parallel.length; taskIndex++) {
|
|
1976
2169
|
const flatTaskIndex = input.groupStartFlatIndex + taskIndex;
|
|
@@ -1987,7 +2180,7 @@ function markParallelGroupSetupFailure(input: {
|
|
|
1987
2180
|
input.statusPayload.currentStep = input.groupStartFlatIndex;
|
|
1988
2181
|
input.statusPayload.lastUpdate = input.failedAt;
|
|
1989
2182
|
input.statusPayload.outputFile = path.join(input.asyncDir, `output-${input.groupStartFlatIndex}.log`);
|
|
1990
|
-
|
|
2183
|
+
input.writeStatus(input.statusPayload);
|
|
1991
2184
|
appendJsonl(input.eventsPath, JSON.stringify({
|
|
1992
2185
|
type: "subagent.parallel.completed",
|
|
1993
2186
|
ts: input.failedAt,
|
|
@@ -2007,6 +2200,7 @@ function markParallelGroupRunning(input: {
|
|
|
2007
2200
|
asyncDir: string;
|
|
2008
2201
|
runId: string;
|
|
2009
2202
|
stepIndex: number;
|
|
2203
|
+
writeStatus: (status: RunnerStatusPayload) => void;
|
|
2010
2204
|
}): void {
|
|
2011
2205
|
for (let taskIndex = 0; taskIndex < input.group.parallel.length; taskIndex++) {
|
|
2012
2206
|
const flatTaskIndex = input.groupStartFlatIndex + taskIndex;
|
|
@@ -2024,7 +2218,7 @@ function markParallelGroupRunning(input: {
|
|
|
2024
2218
|
input.statusPayload.lastActivityAt = input.groupStartTime;
|
|
2025
2219
|
input.statusPayload.lastUpdate = input.groupStartTime;
|
|
2026
2220
|
input.statusPayload.outputFile = path.join(input.asyncDir, `output-${input.groupStartFlatIndex}.log`);
|
|
2027
|
-
|
|
2221
|
+
input.writeStatus(input.statusPayload);
|
|
2028
2222
|
appendJsonl(input.eventsPath, JSON.stringify({
|
|
2029
2223
|
type: "subagent.parallel.started",
|
|
2030
2224
|
ts: input.groupStartTime,
|
|
@@ -2163,6 +2357,7 @@ async function runSubagent(
|
|
|
2163
2357
|
const activeChildInterrupts = new Map<number, () => void>();
|
|
2164
2358
|
const activeChildTimeouts = new Map<number, () => void>();
|
|
2165
2359
|
const activeChildStops = new Map<number, () => void>();
|
|
2360
|
+
const childStopRequests = new Map<number, { childId: string; requestedAt: number }>();
|
|
2166
2361
|
const activeChildTurnBudgetAborts = new Map<number, (message: string, state?: TurnBudgetState) => void>();
|
|
2167
2362
|
const pendingStepSteers: SteerRequest[] = [];
|
|
2168
2363
|
const steeringCapabilities = new Map<number, SteerCapability>();
|
|
@@ -2174,9 +2369,6 @@ async function runSubagent(
|
|
|
2174
2369
|
let stopped = false;
|
|
2175
2370
|
let turnBudgetExceeded = false;
|
|
2176
2371
|
let usageBudgetExceeded = false;
|
|
2177
|
-
let checkpointRejected = false;
|
|
2178
|
-
let pendingCheckpointDecision: "approved" | "rejected" | undefined;
|
|
2179
|
-
let wakeCheckpointDecision: (() => void) | undefined;
|
|
2180
2372
|
const timeoutMessage = config.timeoutMs !== undefined ? `Subagent timed out after ${config.timeoutMs}ms.` : undefined;
|
|
2181
2373
|
const stopMessage = "Subagent stopped by user.";
|
|
2182
2374
|
const timeoutAbortController = new AbortController();
|
|
@@ -2191,19 +2383,6 @@ async function runSubagent(
|
|
|
2191
2383
|
let flatStepCount = 0;
|
|
2192
2384
|
for (let stepIndex = 0; stepIndex < steps.length; stepIndex++) {
|
|
2193
2385
|
const step = steps[stepIndex]!;
|
|
2194
|
-
if (isCheckpointRunnerStep(step)) {
|
|
2195
|
-
initialStatusSteps.push(omitUndefinedProperties({
|
|
2196
|
-
agent: `checkpoint:${step.checkpoint}`,
|
|
2197
|
-
phase: step.phase,
|
|
2198
|
-
label: step.label ?? step.checkpoint,
|
|
2199
|
-
status: "pending",
|
|
2200
|
-
checkpoint: { name: step.checkpoint, ...(step.message ? { message: step.message } : {}), status: "pending", stepIndex },
|
|
2201
|
-
recentTools: [],
|
|
2202
|
-
recentOutput: [],
|
|
2203
|
-
}));
|
|
2204
|
-
flatStepCount++;
|
|
2205
|
-
continue;
|
|
2206
|
-
}
|
|
2207
2386
|
if (isParallelGroup(step)) {
|
|
2208
2387
|
parallelGroups.push({ start: flatStepCount, count: step.parallel.length, stepIndex });
|
|
2209
2388
|
for (const task of step.parallel) {
|
|
@@ -2222,6 +2401,7 @@ async function runSubagent(
|
|
|
2222
2401
|
...(task.launchContractDigest ? { launchContractDigest: task.launchContractDigest } : {}),
|
|
2223
2402
|
...(task.launchResolvedExtensions ? { launchResolvedExtensions: task.launchResolvedExtensions } : {}),
|
|
2224
2403
|
...(task.capabilityCeiling ? { capabilityCeiling: task.capabilityCeiling } : {}),
|
|
2404
|
+
...(task.thinkingCeiling ? { thinkingCeiling: task.thinkingCeiling } : {}),
|
|
2225
2405
|
status: "pending",
|
|
2226
2406
|
...(task.toolBudget ? { toolBudget: initialToolBudgetState(task.toolBudget) } : {}),
|
|
2227
2407
|
...(task.sessionFile ? { sessionFile: task.sessionFile } : {}),
|
|
@@ -2247,6 +2427,7 @@ async function runSubagent(
|
|
|
2247
2427
|
structured: Boolean(step.collect.outputSchema),
|
|
2248
2428
|
...(step.agentContract ? { agentContract: step.agentContract } : {}),
|
|
2249
2429
|
...(step.capabilityCeiling ? { capabilityCeiling: step.capabilityCeiling } : {}),
|
|
2430
|
+
...(step.thinkingCeiling ? { thinkingCeiling: step.thinkingCeiling } : {}),
|
|
2250
2431
|
status: "pending",
|
|
2251
2432
|
...(step.parallel.toolBudget ? { toolBudget: initialToolBudgetState(step.parallel.toolBudget) } : {}),
|
|
2252
2433
|
recentTools: [],
|
|
@@ -2269,6 +2450,7 @@ async function runSubagent(
|
|
|
2269
2450
|
...(step.launchContractDigest ? { launchContractDigest: step.launchContractDigest } : {}),
|
|
2270
2451
|
...(step.launchResolvedExtensions ? { launchResolvedExtensions: step.launchResolvedExtensions } : {}),
|
|
2271
2452
|
...(step.capabilityCeiling ? { capabilityCeiling: step.capabilityCeiling } : {}),
|
|
2453
|
+
...(step.thinkingCeiling ? { thinkingCeiling: step.thinkingCeiling } : {}),
|
|
2272
2454
|
status: "pending",
|
|
2273
2455
|
...(step.toolBudget ? { toolBudget: initialToolBudgetState(step.toolBudget) } : {}),
|
|
2274
2456
|
...(step.sessionFile ? { sessionFile: step.sessionFile } : {}),
|
|
@@ -2291,12 +2473,26 @@ async function runSubagent(
|
|
|
2291
2473
|
step.processTerminal = { version: 1, state: "pending", runId: id, runnerProcessInstanceId: config.runnerProcessInstanceId };
|
|
2292
2474
|
}
|
|
2293
2475
|
}
|
|
2476
|
+
const initialAgentLabel = initialStatusSteps.length === 1
|
|
2477
|
+
? initialStatusSteps[0]!.agent
|
|
2478
|
+
: (config.resultMode ?? (flatSteps.length > 1 ? "chain" : "single")) === "parallel"
|
|
2479
|
+
? `parallel:${initialStatusSteps.map((step) => step.agent).join("+")}`
|
|
2480
|
+
: `chain:${initialStatusSteps.map((step) => step.agent).join("->")}`;
|
|
2481
|
+
const orcaProgressTab = flatSteps.every((step) => step.importAsyncRoot) ? undefined : createOrcaProgressTab({
|
|
2482
|
+
cwd,
|
|
2483
|
+
runId: id,
|
|
2484
|
+
agent: initialAgentLabel,
|
|
2485
|
+
index: 0,
|
|
2486
|
+
stepCount: Math.max(initialStatusSteps.length, 1),
|
|
2487
|
+
});
|
|
2488
|
+
|
|
2294
2489
|
const statusPayload: RunnerStatusPayload = omitUndefinedProperties({
|
|
2295
2490
|
lifecycleArtifactVersion: SUBAGENT_LIFECYCLE_ARTIFACT_VERSION,
|
|
2296
2491
|
runId: id,
|
|
2297
2492
|
...(config.sessionId ? { sessionId: config.sessionId } : {}),
|
|
2493
|
+
...(config.completionOwnerId ? { completionOwnerId: config.completionOwnerId } : {}),
|
|
2298
2494
|
mode: config.resultMode ?? (flatSteps.length > 1 ? "chain" : "single"),
|
|
2299
|
-
...(config.
|
|
2495
|
+
...(config.nestedSelf ? { isNested: true } : {}),
|
|
2300
2496
|
state: "running",
|
|
2301
2497
|
steering: createSteeringStatus(),
|
|
2302
2498
|
lastActivityAt: overallStartTime,
|
|
@@ -2326,9 +2522,37 @@ async function runSubagent(
|
|
|
2326
2522
|
outputFile: path.join(asyncDir, "output-0.log"),
|
|
2327
2523
|
});
|
|
2328
2524
|
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2525
|
+
let lastIndexedStatusState: AsyncStatus["state"] | undefined;
|
|
2526
|
+
const indexPersistence = createCapacityResilientJsonWriter({
|
|
2527
|
+
keepAlive: true,
|
|
2528
|
+
onSuccess: (_filePath, payload) => {
|
|
2529
|
+
lastIndexedStatusState = (payload as { state: AsyncStatus["state"] }).state;
|
|
2530
|
+
},
|
|
2531
|
+
onError: (error, filePath) => console.error(`Failed to update async run index '${filePath}':`, error),
|
|
2532
|
+
});
|
|
2533
|
+
const queueActiveRunIndex = (): void => {
|
|
2534
|
+
const state = statusPayload.state;
|
|
2535
|
+
if (state === lastIndexedStatusState && indexPersistence.pendingCount() === 0) return;
|
|
2536
|
+
indexPersistence.write(asyncDir, { state, toolCallId: statusPayload.toolCallId }, (_filePath, payload) => {
|
|
2537
|
+
const indexPayload = payload as { state: AsyncStatus["state"]; toolCallId?: string };
|
|
2538
|
+
updateActiveRunIndex(asyncDir, indexPayload.state, indexPayload.toolCallId, { retryCapacityErrors: true });
|
|
2539
|
+
});
|
|
2540
|
+
};
|
|
2541
|
+
const runPersistence = createCapacityResilientJsonWriter({
|
|
2542
|
+
keepAlive: true,
|
|
2543
|
+
onSuccess: (filePath) => {
|
|
2544
|
+
if (filePath === statusPath) queueActiveRunIndex();
|
|
2545
|
+
},
|
|
2546
|
+
onError: (error, filePath) => console.error(`Failed to persist async run state '${filePath}':`, error),
|
|
2547
|
+
});
|
|
2548
|
+
try {
|
|
2549
|
+
fs.mkdirSync(asyncDir, { recursive: true });
|
|
2550
|
+
} catch (error) {
|
|
2551
|
+
if (!isStorageCapacityError(error)) throw error;
|
|
2552
|
+
console.error(`Failed to prepare async run storage '${asyncDir}' while storage is full:`, error);
|
|
2553
|
+
}
|
|
2554
|
+
runPersistence.write(statusPath, statusPayload);
|
|
2555
|
+
|
|
2332
2556
|
let pendingParallelUsageCost: CostSummary = { inputTokens: 0, outputTokens: 0, costUsd: 0 };
|
|
2333
2557
|
const currentUsageTotals = (): CostSummary => {
|
|
2334
2558
|
const cost = results.reduce<CostSummary>((sum, result) => ({
|
|
@@ -2383,7 +2607,6 @@ async function runSubagent(
|
|
|
2383
2607
|
node.status = normalize(step.status);
|
|
2384
2608
|
setOptionalProperty(node, "error", step.error);
|
|
2385
2609
|
setOptionalProperty(node, "acceptanceStatus", step.acceptance?.status);
|
|
2386
|
-
setOptionalProperty(node, "checkpoint", step.checkpoint);
|
|
2387
2610
|
}
|
|
2388
2611
|
if (statusPayload.currentStep === node.flatIndex) graph.currentNodeId = node.id;
|
|
2389
2612
|
}
|
|
@@ -2402,17 +2625,15 @@ async function runSubagent(
|
|
|
2402
2625
|
statusPayload.workflowGraph = graph;
|
|
2403
2626
|
};
|
|
2404
2627
|
let finalResultCommitted = false;
|
|
2405
|
-
let lastIndexedActiveState = isActiveAsyncState(statusPayload.state);
|
|
2406
2628
|
const statusResultState = (): AsyncStatus["state"] | undefined => {
|
|
2407
2629
|
if (statusPayload.state === "running" || statusPayload.state === "queued") return undefined;
|
|
2408
|
-
if (statusPayload.state === "paused" && statusPayload.checkpoint?.status === "pending") return undefined;
|
|
2409
2630
|
return statusPayload.state;
|
|
2410
2631
|
};
|
|
2411
2632
|
const statusResultSummary = (state: AsyncStatus["state"]): string => {
|
|
2412
2633
|
if (statusPayload.error) return statusPayload.error;
|
|
2413
2634
|
if (state === "paused") return "Paused after interrupt. Waiting for explicit next action.";
|
|
2414
2635
|
if (state === "stopped") return stopMessage;
|
|
2415
|
-
if (state === "rejected") return
|
|
2636
|
+
if (state === "rejected") return "Subagent rejected.";
|
|
2416
2637
|
return state === "complete" ? "Subagent completed." : "Subagent failed.";
|
|
2417
2638
|
};
|
|
2418
2639
|
const statusResultSuccess = (state: AsyncStatus["state"], step: RunnerStatusStep): boolean | undefined => {
|
|
@@ -2427,7 +2648,7 @@ async function runSubagent(
|
|
|
2427
2648
|
if (!state || finalResultCommitted || !config.sessionId) return;
|
|
2428
2649
|
const now = statusPayload.endedAt ?? statusPayload.lastUpdate ?? Date.now();
|
|
2429
2650
|
const summary = statusResultSummary(state);
|
|
2430
|
-
|
|
2651
|
+
runPersistence.write(resultPath, omitUndefinedProperties({
|
|
2431
2652
|
lifecycleArtifactVersion: SUBAGENT_LIFECYCLE_ARTIFACT_VERSION,
|
|
2432
2653
|
id,
|
|
2433
2654
|
runId: id,
|
|
@@ -2438,7 +2659,6 @@ async function runSubagent(
|
|
|
2438
2659
|
summary,
|
|
2439
2660
|
error: state === "failed" || state === "stopped" || state === "rejected" ? summary : undefined,
|
|
2440
2661
|
stopped: state === "stopped" ? true : undefined,
|
|
2441
|
-
checkpoint: statusPayload.checkpoint,
|
|
2442
2662
|
results: statusPayload.steps.map((step) => omitUndefinedProperties({
|
|
2443
2663
|
agent: step.agent,
|
|
2444
2664
|
output: step.status === "complete" || step.status === "completed" ? "" : step.error ?? summary,
|
|
@@ -2448,6 +2668,7 @@ async function runSubagent(
|
|
|
2448
2668
|
model: step.model,
|
|
2449
2669
|
attemptedModels: step.attemptedModels,
|
|
2450
2670
|
modelAttempts: step.modelAttempts,
|
|
2671
|
+
contextOverflow: step.contextOverflow,
|
|
2451
2672
|
})),
|
|
2452
2673
|
exitCode: state === "complete" || state === "paused" ? 0 : 1,
|
|
2453
2674
|
timestamp: now,
|
|
@@ -2455,18 +2676,14 @@ async function runSubagent(
|
|
|
2455
2676
|
asyncDir,
|
|
2456
2677
|
cwd,
|
|
2457
2678
|
sessionId: config.sessionId,
|
|
2679
|
+
completionOwnerId: config.completionOwnerId,
|
|
2458
2680
|
sessionFile: statusPayload.sessionFile ?? latestSessionFile,
|
|
2459
|
-
}));
|
|
2681
|
+
}), (filePath, payload) => writePendingAsyncResultFile(filePath, payload as Record<string, unknown>));
|
|
2460
2682
|
};
|
|
2461
2683
|
const writeStatusPayloadNow = (): void => {
|
|
2462
2684
|
refreshWorkflowGraph();
|
|
2463
2685
|
writeRecoverableStatusResult();
|
|
2464
|
-
|
|
2465
|
-
const activeState = isActiveAsyncState(statusPayload.state);
|
|
2466
|
-
if (activeState !== lastIndexedActiveState) {
|
|
2467
|
-
updateActiveRunIndex(asyncDir, statusPayload.state, statusPayload.toolCallId);
|
|
2468
|
-
}
|
|
2469
|
-
lastIndexedActiveState = activeState;
|
|
2686
|
+
runPersistence.write(statusPath, statusPayload);
|
|
2470
2687
|
emitNestedSelfEvent(statusPayload.state === "running" || statusPayload.state === "queued" ? "subagent.nested.updated" : "subagent.nested.completed");
|
|
2471
2688
|
};
|
|
2472
2689
|
const statusWriteCoalescer = createFileCoalescer(writeStatusPayloadNow, 100);
|
|
@@ -2482,6 +2699,88 @@ async function runSubagent(
|
|
|
2482
2699
|
statusPayload.lastUpdate = Date.now();
|
|
2483
2700
|
writeStatusPayload();
|
|
2484
2701
|
};
|
|
2702
|
+
const updateExternalJob = (index: number, externalJob: ExternalJobStatus): void => {
|
|
2703
|
+
requiredStatusStep(statusPayload, index).externalJob = externalJob;
|
|
2704
|
+
statusPayload.lastUpdate = Date.now();
|
|
2705
|
+
writeStatusPayload();
|
|
2706
|
+
};
|
|
2707
|
+
const childStopTargetId = (index: number): string => asyncStatusChildIdentity(requiredStatusStep(statusPayload, index), index);
|
|
2708
|
+
const appendChildStatusEvent = (index: number, childId: string, status: "stopping" | "stopped", now = Date.now()): void => {
|
|
2709
|
+
const step = requiredStatusStep(statusPayload, index);
|
|
2710
|
+
appendJsonl(eventsPath, JSON.stringify({
|
|
2711
|
+
type: "subagent.child-status",
|
|
2712
|
+
version: 1,
|
|
2713
|
+
ts: now,
|
|
2714
|
+
runId: id,
|
|
2715
|
+
childId,
|
|
2716
|
+
status,
|
|
2717
|
+
reason: "user",
|
|
2718
|
+
source: "async",
|
|
2719
|
+
stepIndex: index,
|
|
2720
|
+
agent: step.agent,
|
|
2721
|
+
...(step.runId ? { childRunId: step.runId } : {}),
|
|
2722
|
+
...(step.workflowKey ? { workflowKey: step.workflowKey } : {}),
|
|
2723
|
+
...(step.phase ? { phase: step.phase } : {}),
|
|
2724
|
+
...(step.label ? { label: step.label } : {}),
|
|
2725
|
+
} satisfies SubagentChildStatusEvent));
|
|
2726
|
+
};
|
|
2727
|
+
const appendTerminalChildStatusEvent = (index: number, now = Date.now()): void => {
|
|
2728
|
+
const request = childStopRequests.get(index);
|
|
2729
|
+
if (request) appendChildStatusEvent(index, request.childId, "stopped", now);
|
|
2730
|
+
};
|
|
2731
|
+
const markChildStopRequested = (index: number, childId: string, now = Date.now()): boolean => {
|
|
2732
|
+
const step = statusPayload.steps[index];
|
|
2733
|
+
if (!step || (step.status !== "pending" && step.status !== "running")) return false;
|
|
2734
|
+
childStopRequests.set(index, { childId, requestedAt: now });
|
|
2735
|
+
step.stopRequested = true;
|
|
2736
|
+
step.stopRequestedAt = now;
|
|
2737
|
+
delete step.activityState;
|
|
2738
|
+
statusPayload.lastUpdate = now;
|
|
2739
|
+
writeStatusPayload();
|
|
2740
|
+
appendJsonl(eventsPath, JSON.stringify({ type: "subagent.step.stop_requested", ts: now, runId: id, stepIndex: index, childId, agent: step.agent }));
|
|
2741
|
+
appendChildStatusEvent(index, childId, "stopping", now);
|
|
2742
|
+
return true;
|
|
2743
|
+
};
|
|
2744
|
+
const markChildStopped = (index: number, now = Date.now()): void => {
|
|
2745
|
+
const step = requiredStatusStep(statusPayload, index);
|
|
2746
|
+
if (step.status === "stopped") return;
|
|
2747
|
+
step.status = "stopped";
|
|
2748
|
+
step.error = stopMessage;
|
|
2749
|
+
step.exitCode = 1;
|
|
2750
|
+
step.stopped = true;
|
|
2751
|
+
step.stopRequested = true;
|
|
2752
|
+
step.stopRequestedAt = childStopRequests.get(index)?.requestedAt ?? step.stopRequestedAt ?? now;
|
|
2753
|
+
delete step.activityState;
|
|
2754
|
+
step.endedAt = now;
|
|
2755
|
+
step.durationMs = step.startedAt ? now - step.startedAt : 0;
|
|
2756
|
+
step.lastActivityAt = now;
|
|
2757
|
+
statusPayload.lastUpdate = now;
|
|
2758
|
+
writeStatusPayload();
|
|
2759
|
+
const childId = childStopRequests.get(index)?.childId ?? childStopTargetId(index);
|
|
2760
|
+
appendJsonl(eventsPath, JSON.stringify({ type: "subagent.step.stopped", ts: now, runId: id, stepIndex: index, childId, agent: step.agent, exitCode: 1, durationMs: step.durationMs }));
|
|
2761
|
+
appendChildStatusEvent(index, childId, "stopped", now);
|
|
2762
|
+
};
|
|
2763
|
+
const childStopResult = (index: number, agent: string, context?: "fresh" | "fork"): SingleStepResult => {
|
|
2764
|
+
markChildStopped(index);
|
|
2765
|
+
return stoppedStepResult(agent, context);
|
|
2766
|
+
};
|
|
2767
|
+
const stopChildStep = (request: StopRequest): void => {
|
|
2768
|
+
if (request.targetIndex === undefined) {
|
|
2769
|
+
stopRunner();
|
|
2770
|
+
return;
|
|
2771
|
+
}
|
|
2772
|
+
const childId = request.childId ?? childStopTargetId(request.targetIndex);
|
|
2773
|
+
const now = Date.now();
|
|
2774
|
+
if (!markChildStopRequested(request.targetIndex, childId, now)) {
|
|
2775
|
+
appendJsonl(eventsPath, JSON.stringify({ type: "subagent.step.stop_failed", ts: now, runId: id, stepIndex: request.targetIndex, childId, message: "Child is not pending or running." }));
|
|
2776
|
+
return;
|
|
2777
|
+
}
|
|
2778
|
+
const stop = activeChildStops.get(request.targetIndex);
|
|
2779
|
+
if (stop) stop();
|
|
2780
|
+
else if (requiredStatusStep(statusPayload, request.targetIndex).status === "pending") {
|
|
2781
|
+
appendJsonl(eventsPath, JSON.stringify({ type: "subagent.step.stop_queued", ts: now, runId: id, stepIndex: request.targetIndex, childId }));
|
|
2782
|
+
}
|
|
2783
|
+
};
|
|
2485
2784
|
const registerStepInterrupt = (flatIndex: number, interrupt: (() => void) | undefined): void => {
|
|
2486
2785
|
if (!interrupt) {
|
|
2487
2786
|
activeChildInterrupts.delete(flatIndex);
|
|
@@ -2504,7 +2803,7 @@ async function runSubagent(
|
|
|
2504
2803
|
return;
|
|
2505
2804
|
}
|
|
2506
2805
|
activeChildStops.set(flatIndex, stop);
|
|
2507
|
-
if (stopped) stop();
|
|
2806
|
+
if (stopped || childStopRequests.has(flatIndex)) stop();
|
|
2508
2807
|
};
|
|
2509
2808
|
const registerStepTurnBudgetAbort = (flatIndex: number, abort: ((message: string, state?: TurnBudgetState) => void) | undefined): void => {
|
|
2510
2809
|
if (!abort) {
|
|
@@ -2777,8 +3076,16 @@ async function runSubagent(
|
|
|
2777
3076
|
.sort((left, right) => left.startedAt - right.startedAt)[0];
|
|
2778
3077
|
const supervisorAttentionSteps = new Map<number, ActivityState | undefined>();
|
|
2779
3078
|
const mutatingFailureWindowMs = 5 * 60_000;
|
|
2780
|
-
const appendControlEvent = (
|
|
3079
|
+
const appendControlEvent = (rawEvent: ReturnType<typeof buildControlEvent>) => {
|
|
2781
3080
|
if (!controlConfig.enabled) return;
|
|
3081
|
+
const contextStep = statusPayload.steps[rawEvent.index ?? statusPayload.currentStep ?? 0];
|
|
3082
|
+
const event = {
|
|
3083
|
+
...rawEvent,
|
|
3084
|
+
...(contextStep?.workflowKey ?? statusPayload.workflowKey ? { workflowKey: contextStep?.workflowKey ?? statusPayload.workflowKey } : {}),
|
|
3085
|
+
...(contextStep?.phase ? { phase: contextStep.phase } : {}),
|
|
3086
|
+
...(contextStep?.label ? { label: contextStep.label } : {}),
|
|
3087
|
+
...(contextStep?.description ? { taskPreview: contextStep.description } : {}),
|
|
3088
|
+
};
|
|
2782
3089
|
const childIntercomTarget = config.childIntercomTargets?.[event.index ?? statusPayload.currentStep];
|
|
2783
3090
|
const channels = event.type === "active_long_running"
|
|
2784
3091
|
? controlConfig.notifyChannels.filter((channel) => channel !== "intercom")
|
|
@@ -3251,6 +3558,7 @@ async function runSubagent(
|
|
|
3251
3558
|
startedAt: step.startedAt ?? overallStartTime,
|
|
3252
3559
|
lastActivityAt,
|
|
3253
3560
|
currentTool: step.currentTool,
|
|
3561
|
+
thinking: step.thinking,
|
|
3254
3562
|
now,
|
|
3255
3563
|
}));
|
|
3256
3564
|
if (idleState === "needs_attention") {
|
|
@@ -3400,11 +3708,7 @@ async function runSubagent(
|
|
|
3400
3708
|
const disposeControlInbox = watchAsyncControlInbox(asyncDir, {
|
|
3401
3709
|
onInterrupt: interruptRunner,
|
|
3402
3710
|
onTimeout: timeoutRunner,
|
|
3403
|
-
onStop:
|
|
3404
|
-
onCheckpointDecision: (decision) => {
|
|
3405
|
-
pendingCheckpointDecision = decision;
|
|
3406
|
-
wakeCheckpointDecision?.();
|
|
3407
|
-
},
|
|
3711
|
+
onStop: stopChildStep,
|
|
3408
3712
|
onSteer: (request) => {
|
|
3409
3713
|
const targetStep = request.targetIndex !== undefined ? statusPayload.steps[request.targetIndex] : undefined;
|
|
3410
3714
|
if (targetStep?.status === "pending") {
|
|
@@ -3455,20 +3759,6 @@ async function runSubagent(
|
|
|
3455
3759
|
|
|
3456
3760
|
let flatIndex = 0;
|
|
3457
3761
|
let stepCursor = 0;
|
|
3458
|
-
const waitForCheckpointDecision = async (): Promise<"approved" | "rejected" | undefined> => {
|
|
3459
|
-
while (!pendingCheckpointDecision && !interrupted && !timedOut && !stopped) {
|
|
3460
|
-
await new Promise<void>((resolve) => {
|
|
3461
|
-
wakeCheckpointDecision = resolve;
|
|
3462
|
-
const timer = setTimeout(resolve, POLL_INTERVAL_MS);
|
|
3463
|
-
timer.unref?.();
|
|
3464
|
-
});
|
|
3465
|
-
wakeCheckpointDecision = undefined;
|
|
3466
|
-
}
|
|
3467
|
-
const decision = pendingCheckpointDecision;
|
|
3468
|
-
pendingCheckpointDecision = undefined;
|
|
3469
|
-
return decision;
|
|
3470
|
-
};
|
|
3471
|
-
|
|
3472
3762
|
while (true) {
|
|
3473
3763
|
if (interrupted || timedOut || stopped || turnBudgetExceeded) break;
|
|
3474
3764
|
consumePendingAppendRequests();
|
|
@@ -3486,64 +3776,6 @@ async function runSubagent(
|
|
|
3486
3776
|
const stepIndex = stepCursor++;
|
|
3487
3777
|
const step = steps[stepIndex]!;
|
|
3488
3778
|
|
|
3489
|
-
if (isCheckpointRunnerStep(step)) {
|
|
3490
|
-
const now = Date.now();
|
|
3491
|
-
const statusStep = statusPayload.steps[flatIndex];
|
|
3492
|
-
const checkpoint = { name: step.checkpoint, ...(step.message ? { message: step.message } : {}), status: "pending" as const, stepIndex };
|
|
3493
|
-
statusPayload.state = "paused";
|
|
3494
|
-
statusPayload.currentStep = flatIndex;
|
|
3495
|
-
statusPayload.checkpoint = checkpoint;
|
|
3496
|
-
delete statusPayload.activityState;
|
|
3497
|
-
statusPayload.lastUpdate = now;
|
|
3498
|
-
if (statusStep) {
|
|
3499
|
-
statusStep.status = "paused";
|
|
3500
|
-
statusStep.startedAt = now;
|
|
3501
|
-
statusStep.checkpoint = checkpoint;
|
|
3502
|
-
}
|
|
3503
|
-
writeStatusPayload();
|
|
3504
|
-
appendJsonl(eventsPath, JSON.stringify({ type: "subagent.checkpoint.paused", ts: now, runId: id, stepIndex, checkpoint }));
|
|
3505
|
-
const decision = await waitForCheckpointDecision();
|
|
3506
|
-
if (decision === "approved") {
|
|
3507
|
-
const approvedAt = Date.now();
|
|
3508
|
-
const approved = { ...checkpoint, status: "approved" as const, approvedAt };
|
|
3509
|
-
statusPayload.state = "running";
|
|
3510
|
-
statusPayload.checkpoint = approved;
|
|
3511
|
-
if (statusStep) {
|
|
3512
|
-
statusStep.status = "complete";
|
|
3513
|
-
statusStep.endedAt = approvedAt;
|
|
3514
|
-
statusStep.durationMs = approvedAt - now;
|
|
3515
|
-
statusStep.exitCode = 0;
|
|
3516
|
-
statusStep.checkpoint = approved;
|
|
3517
|
-
}
|
|
3518
|
-
statusPayload.lastUpdate = approvedAt;
|
|
3519
|
-
writeStatusPayload();
|
|
3520
|
-
appendJsonl(eventsPath, JSON.stringify({ type: "subagent.checkpoint.approved", ts: approvedAt, runId: id, stepIndex, checkpoint: approved }));
|
|
3521
|
-
flatIndex++;
|
|
3522
|
-
continue;
|
|
3523
|
-
}
|
|
3524
|
-
if (decision === "rejected") {
|
|
3525
|
-
const rejectedAt = Date.now();
|
|
3526
|
-
const rejected = { ...checkpoint, status: "rejected" as const, rejectedAt };
|
|
3527
|
-
checkpointRejected = true;
|
|
3528
|
-
statusPayload.state = "rejected";
|
|
3529
|
-
statusPayload.error = `Checkpoint '${step.checkpoint}' rejected.`;
|
|
3530
|
-
statusPayload.checkpoint = rejected;
|
|
3531
|
-
if (statusStep) {
|
|
3532
|
-
statusStep.status = "rejected";
|
|
3533
|
-
statusStep.error = statusPayload.error;
|
|
3534
|
-
statusStep.endedAt = rejectedAt;
|
|
3535
|
-
statusStep.durationMs = rejectedAt - now;
|
|
3536
|
-
statusStep.exitCode = 1;
|
|
3537
|
-
statusStep.checkpoint = rejected;
|
|
3538
|
-
}
|
|
3539
|
-
statusPayload.lastUpdate = rejectedAt;
|
|
3540
|
-
writeStatusPayload();
|
|
3541
|
-
appendJsonl(eventsPath, JSON.stringify({ type: "subagent.checkpoint.rejected", ts: rejectedAt, runId: id, stepIndex, checkpoint: rejected }));
|
|
3542
|
-
break;
|
|
3543
|
-
}
|
|
3544
|
-
break;
|
|
3545
|
-
}
|
|
3546
|
-
|
|
3547
3779
|
if (isDynamicRunnerGroup(step)) {
|
|
3548
3780
|
const groupStartFlatIndex = flatIndex;
|
|
3549
3781
|
let materialized: ReturnType<typeof materializeDynamicParallelStep>;
|
|
@@ -3552,6 +3784,19 @@ async function runSubagent(
|
|
|
3552
3784
|
if (materialized.parallel.length > 1 && step.parallel.outputPath && !step.parallel.namespaceOutputPath) {
|
|
3553
3785
|
throw new DynamicFanoutError(`Dynamic chain step ${stepIndex + 1} materialized ${materialized.parallel.length} items that resolve output to the same path: ${step.parallel.outputPath}. Remove the explicit output path or use an inherited relative agent output so each item can be isolated.`);
|
|
3554
3786
|
}
|
|
3787
|
+
for (const [itemIndex] of materialized.parallel.entries()) {
|
|
3788
|
+
const thinkingOverride = step.thinkingOverrides?.[itemIndex];
|
|
3789
|
+
const model = thinkingOverride ? applyThinkingSuffix(step.parallel.model, thinkingOverride, true) : step.parallel.model;
|
|
3790
|
+
const configThinking = thinkingOverride ? thinkingOverride : step.parallel.thinking;
|
|
3791
|
+
const candidates = step.parallel.modelCandidates !== undefined
|
|
3792
|
+
? step.parallel.modelCandidates.length > 0
|
|
3793
|
+
? step.parallel.modelCandidates.map((candidate) => thinkingOverride ? applyThinkingSuffix(candidate, thinkingOverride, true) ?? candidate : candidate)
|
|
3794
|
+
: [undefined]
|
|
3795
|
+
: model ? [model] : [undefined];
|
|
3796
|
+
for (const candidate of candidates) {
|
|
3797
|
+
assertThinkingWithinCeiling({ model: candidate, configThinking, ceiling: step.parallel.thinkingCeiling ?? decodeThinkingCeiling(process.env[SUBAGENT_THINKING_CEILING_ENV]), agent: step.parallel.agent, runId: id });
|
|
3798
|
+
}
|
|
3799
|
+
}
|
|
3555
3800
|
if (materialized.collectedOnEmpty) await validateDynamicCollection(step.collect.outputSchema, materialized.collectedOnEmpty);
|
|
3556
3801
|
if (!config.runFanoutBudget) throw new Error("Async runner is missing its run fan-out budget identity.");
|
|
3557
3802
|
const runFanoutBudget = claimRunFanoutBatch(config.runFanoutBudget, materialized.parallel.map((_, itemIndex) => `chain[${stepIndex}].expand[${itemIndex}]`));
|
|
@@ -3708,6 +3953,7 @@ async function runSubagent(
|
|
|
3708
3953
|
...(task.skills ? { skills: task.skills } : {}),
|
|
3709
3954
|
...(task.model ? { model: task.model } : {}),
|
|
3710
3955
|
...(task.thinking ? { thinking: task.thinking } : {}),
|
|
3956
|
+
...(task.thinkingCeiling ? { thinkingCeiling: task.thinkingCeiling } : {}),
|
|
3711
3957
|
...(task.modelCandidates && task.modelCandidates.length > 0 ? { attemptedModels: task.modelCandidates } : task.model ? { attemptedModels: [task.model] } : {}),
|
|
3712
3958
|
recentTools: [],
|
|
3713
3959
|
recentOutput: [],
|
|
@@ -3779,6 +4025,7 @@ async function runSubagent(
|
|
|
3779
4025
|
}
|
|
3780
4026
|
if (timedOut) return timedOutStepResult(task.agent, task.context);
|
|
3781
4027
|
if (stopped) return stoppedStepResult(task.agent, task.context);
|
|
4028
|
+
if (childStopRequests.has(fi)) return childStopResult(fi, task.agent, task.context);
|
|
3782
4029
|
if (interrupted) return pausedStepResult(task.agent, task.context);
|
|
3783
4030
|
if (aborted && failFast) {
|
|
3784
4031
|
const skippedAt = Date.now();
|
|
@@ -3829,6 +4076,7 @@ async function runSubagent(
|
|
|
3829
4076
|
registerTurnBudgetAbort: (abort) => registerStepTurnBudgetAbort(fi, abort),
|
|
3830
4077
|
timeoutSignal: timeoutAbortController.signal,
|
|
3831
4078
|
stopSignal: stopAbortController.signal,
|
|
4079
|
+
trackedMutationEvidenceForCompletionGuard: false,
|
|
3832
4080
|
timeoutMessage,
|
|
3833
4081
|
stopMessage,
|
|
3834
4082
|
turnBudget: config.turnBudget,
|
|
@@ -3837,7 +4085,9 @@ async function runSubagent(
|
|
|
3837
4085
|
onChildEvent: (event) => updateStepFromChildEvent(fi, event),
|
|
3838
4086
|
onWriterProcess,
|
|
3839
4087
|
onExternalProcess: (process) => updateExternalProcess(fi, process),
|
|
3840
|
-
|
|
4088
|
+
onExternalJob: (externalJob) => updateExternalJob(fi, externalJob),
|
|
4089
|
+
skipAcceptance: () => timedOut || stopped || childStopRequests.has(fi),
|
|
4090
|
+
orcaProgressTab,
|
|
3841
4091
|
}), config.deadlineAt);
|
|
3842
4092
|
const taskEndTime = Date.now();
|
|
3843
4093
|
const childInterrupted = singleResult.interrupted === true;
|
|
@@ -3862,6 +4112,7 @@ async function runSubagent(
|
|
|
3862
4112
|
setOptionalProperty(requiredStatusStep(statusPayload, fi), "thinking", resolveEffectiveThinking(singleResult.model, requiredStatusStep(statusPayload, fi).thinking));
|
|
3863
4113
|
setOptionalProperty(requiredStatusStep(statusPayload, fi), "attemptedModels", singleResult.attemptedModels);
|
|
3864
4114
|
setOptionalProperty(requiredStatusStep(statusPayload, fi), "modelAttempts", singleResult.modelAttempts);
|
|
4115
|
+
setOptionalProperty(requiredStatusStep(statusPayload, fi), "contextOverflow", singleResult.contextOverflow);
|
|
3865
4116
|
setOptionalProperty(requiredStatusStep(statusPayload, fi), "totalCost", singleResult.totalCost);
|
|
3866
4117
|
if (singleResult.totalCost) {
|
|
3867
4118
|
pendingParallelUsageCost = {
|
|
@@ -3885,6 +4136,7 @@ async function runSubagent(
|
|
|
3885
4136
|
setOptionalProperty(requiredStatusStep(statusPayload, fi), "structuredOutputPath", singleResult.structuredOutputPath);
|
|
3886
4137
|
setOptionalProperty(requiredStatusStep(statusPayload, fi), "structuredOutputSchemaPath", singleResult.structuredOutputSchemaPath);
|
|
3887
4138
|
setOptionalProperty(requiredStatusStep(statusPayload, fi), "acceptance", singleResult.acceptance);
|
|
4139
|
+
setOptionalProperty(requiredStatusStep(statusPayload, fi), "timeoutRecovery", singleResult.timeoutRecovery);
|
|
3888
4140
|
setOptionalProperty(requiredStatusStep(statusPayload, fi), "watchdog", singleResult.watchdog);
|
|
3889
4141
|
setOptionalProperty(requiredStatusStep(statusPayload, fi), "capabilityCeiling", singleResult.capabilityCeiling);
|
|
3890
4142
|
setOptionalProperty(requiredStatusStep(statusPayload, fi), "capabilityAudit", singleResult.capabilityAudit);
|
|
@@ -3893,13 +4145,14 @@ async function runSubagent(
|
|
|
3893
4145
|
statusPayload.lastUpdate = taskEndTime;
|
|
3894
4146
|
writeStatusPayload();
|
|
3895
4147
|
appendCapabilityCeilingAppliedEvent(eventsPath, id, fi, task.agent, singleResult);
|
|
3896
|
-
|
|
3897
|
-
|
|
3898
|
-
|
|
3899
|
-
|
|
3900
|
-
|
|
3901
|
-
|
|
3902
|
-
|
|
4148
|
+
appendJsonl(eventsPath, JSON.stringify({
|
|
4149
|
+
type: stopped || childStopped ? "subagent.step.stopped" : timedOut ? "subagent.step.failed" : childInterrupted ? "subagent.step.paused" : singleResult.exitCode === 0 ? "subagent.step.completed" : "subagent.step.failed",
|
|
4150
|
+
ts: taskEndTime, runId: id, stepIndex: fi, agent: task.agent,
|
|
4151
|
+
exitCode: stopped || childStopped ? 1 : timedOut ? 1 : childInterrupted ? 0 : singleResult.exitCode, durationMs: taskEndTime - taskStartTime,
|
|
4152
|
+
}));
|
|
4153
|
+
if (stopped || childStopped) appendTerminalChildStatusEvent(fi, taskEndTime);
|
|
4154
|
+
if (singleResult.exitCode !== 0 && failFast && !childStopped) aborted = true;
|
|
4155
|
+
return stopped || childStopped ? { ...singleResult, output: stopMessage, error: stopMessage, exitCode: 1, interrupted: false, timedOut: false, stopped: true, skipped: false } : timedOut ? { ...singleResult, output: singleResult.output || (timeoutMessage ?? "Subagent timed out."), error: singleResult.error ?? timeoutMessage ?? "Subagent timed out.", exitCode: 1, interrupted: false, timedOut: true, skipped: false } : { ...singleResult, skipped: false };
|
|
3903
4156
|
}, globalSemaphore);
|
|
3904
4157
|
|
|
3905
4158
|
flatIndex += dynamicSteps.length;
|
|
@@ -3931,6 +4184,7 @@ async function runSubagent(
|
|
|
3931
4184
|
model: pr.model,
|
|
3932
4185
|
attemptedModels: pr.attemptedModels,
|
|
3933
4186
|
modelAttempts: pr.modelAttempts,
|
|
4187
|
+
contextOverflow: pr.contextOverflow,
|
|
3934
4188
|
totalCost: pr.totalCost,
|
|
3935
4189
|
artifactPaths: pr.artifactPaths,
|
|
3936
4190
|
transcriptPath: pr.transcriptPath,
|
|
@@ -3938,6 +4192,7 @@ async function runSubagent(
|
|
|
3938
4192
|
effects: pr.effects,
|
|
3939
4193
|
execution: pr.execution,
|
|
3940
4194
|
review: pr.review,
|
|
4195
|
+
timeoutRecovery: pr.timeoutRecovery,
|
|
3941
4196
|
structuredOutput: pr.structuredOutput,
|
|
3942
4197
|
structuredOutputPath: pr.structuredOutputPath,
|
|
3943
4198
|
structuredOutputSchemaPath: pr.structuredOutputSchemaPath,
|
|
@@ -4062,6 +4317,7 @@ async function runSubagent(
|
|
|
4062
4317
|
asyncDir,
|
|
4063
4318
|
runId: id,
|
|
4064
4319
|
stepIndex,
|
|
4320
|
+
writeStatus: () => writeStatusPayload(),
|
|
4065
4321
|
});
|
|
4066
4322
|
flatIndex += group.parallel.length;
|
|
4067
4323
|
break;
|
|
@@ -4089,6 +4345,7 @@ async function runSubagent(
|
|
|
4089
4345
|
asyncDir,
|
|
4090
4346
|
runId: id,
|
|
4091
4347
|
stepIndex,
|
|
4348
|
+
writeStatus: () => writeStatusPayload(),
|
|
4092
4349
|
});
|
|
4093
4350
|
flatIndex += group.parallel.length;
|
|
4094
4351
|
break;
|
|
@@ -4120,6 +4377,7 @@ async function runSubagent(
|
|
|
4120
4377
|
asyncDir,
|
|
4121
4378
|
runId: id,
|
|
4122
4379
|
stepIndex,
|
|
4380
|
+
writeStatus: () => writeStatusPayload(),
|
|
4123
4381
|
});
|
|
4124
4382
|
const parallelResults = await mapConcurrent(
|
|
4125
4383
|
group.parallel,
|
|
@@ -4147,6 +4405,7 @@ async function runSubagent(
|
|
|
4147
4405
|
}
|
|
4148
4406
|
if (timedOut) return timedOutStepResult(task.agent, task.context);
|
|
4149
4407
|
if (stopped) return stoppedStepResult(task.agent, task.context);
|
|
4408
|
+
if (childStopRequests.has(fi)) return childStopResult(fi, task.agent, task.context);
|
|
4150
4409
|
if (interrupted) return pausedStepResult(task.agent, task.context);
|
|
4151
4410
|
if (aborted && failFast) {
|
|
4152
4411
|
const skippedAt = Date.now();
|
|
@@ -4213,6 +4472,7 @@ async function runSubagent(
|
|
|
4213
4472
|
registerTurnBudgetAbort: (abort) => registerStepTurnBudgetAbort(fi, abort),
|
|
4214
4473
|
timeoutSignal: timeoutAbortController.signal,
|
|
4215
4474
|
stopSignal: stopAbortController.signal,
|
|
4475
|
+
trackedMutationEvidenceForCompletionGuard: Boolean(worktreeSetup),
|
|
4216
4476
|
timeoutMessage,
|
|
4217
4477
|
stopMessage,
|
|
4218
4478
|
turnBudget: config.turnBudget,
|
|
@@ -4221,7 +4481,9 @@ async function runSubagent(
|
|
|
4221
4481
|
onChildEvent: (event) => updateStepFromChildEvent(fi, event),
|
|
4222
4482
|
onWriterProcess,
|
|
4223
4483
|
onExternalProcess: (process) => updateExternalProcess(fi, process),
|
|
4224
|
-
|
|
4484
|
+
onExternalJob: (externalJob) => updateExternalJob(fi, externalJob),
|
|
4485
|
+
skipAcceptance: () => timedOut || stopped || childStopRequests.has(fi),
|
|
4486
|
+
orcaProgressTab,
|
|
4225
4487
|
}), config.deadlineAt);
|
|
4226
4488
|
if (task.sessionFile) {
|
|
4227
4489
|
latestSessionFile = task.sessionFile;
|
|
@@ -4252,6 +4514,7 @@ async function runSubagent(
|
|
|
4252
4514
|
setOptionalProperty(requiredStatusStep(statusPayload, fi), "thinking", resolveEffectiveThinking(singleResult.model, requiredStatusStep(statusPayload, fi).thinking));
|
|
4253
4515
|
setOptionalProperty(requiredStatusStep(statusPayload, fi), "attemptedModels", singleResult.attemptedModels);
|
|
4254
4516
|
setOptionalProperty(requiredStatusStep(statusPayload, fi), "modelAttempts", singleResult.modelAttempts);
|
|
4517
|
+
setOptionalProperty(requiredStatusStep(statusPayload, fi), "contextOverflow", singleResult.contextOverflow);
|
|
4255
4518
|
setOptionalProperty(requiredStatusStep(statusPayload, fi), "totalCost", singleResult.totalCost);
|
|
4256
4519
|
if (singleResult.totalCost) {
|
|
4257
4520
|
pendingParallelUsageCost = {
|
|
@@ -4274,6 +4537,7 @@ async function runSubagent(
|
|
|
4274
4537
|
setOptionalProperty(requiredStatusStep(statusPayload, fi), "structuredOutputPath", singleResult.structuredOutputPath);
|
|
4275
4538
|
setOptionalProperty(requiredStatusStep(statusPayload, fi), "structuredOutputSchemaPath", singleResult.structuredOutputSchemaPath);
|
|
4276
4539
|
setOptionalProperty(requiredStatusStep(statusPayload, fi), "acceptance", singleResult.acceptance);
|
|
4540
|
+
setOptionalProperty(requiredStatusStep(statusPayload, fi), "timeoutRecovery", singleResult.timeoutRecovery);
|
|
4277
4541
|
setOptionalProperty(requiredStatusStep(statusPayload, fi), "watchdog", singleResult.watchdog);
|
|
4278
4542
|
setOptionalProperty(requiredStatusStep(statusPayload, fi), "capabilityCeiling", singleResult.capabilityCeiling);
|
|
4279
4543
|
setOptionalProperty(requiredStatusStep(statusPayload, fi), "capabilityAudit", singleResult.capabilityAudit);
|
|
@@ -4288,6 +4552,7 @@ async function runSubagent(
|
|
|
4288
4552
|
ts: taskEndTime, runId: id, stepIndex: fi, agent: task.agent,
|
|
4289
4553
|
exitCode: stopped || childStopped ? 1 : timedOut ? 1 : childInterrupted ? 0 : singleResult.exitCode, durationMs: taskDuration,
|
|
4290
4554
|
}));
|
|
4555
|
+
if (stopped || childStopped) appendTerminalChildStatusEvent(fi, taskEndTime);
|
|
4291
4556
|
if (singleResult.completionGuardTriggered) {
|
|
4292
4557
|
const event = buildControlEvent(omitUndefinedProperties({
|
|
4293
4558
|
from: requiredStatusStep(statusPayload, fi).activityState,
|
|
@@ -4302,8 +4567,8 @@ async function runSubagent(
|
|
|
4302
4567
|
appendControlEvent(event);
|
|
4303
4568
|
}
|
|
4304
4569
|
|
|
4305
|
-
if (singleResult.exitCode !== 0 && failFast) aborted = true;
|
|
4306
|
-
return stopped || childStopped ? { ...singleResult, output: stopMessage, error: stopMessage, exitCode: 1, interrupted: false, timedOut: false, stopped: true, skipped: false } : timedOut ? { ...singleResult, output: timeoutMessage ?? "Subagent timed out.", error: timeoutMessage ?? "Subagent timed out.", exitCode: 1, interrupted: false, timedOut: true, skipped: false } : { ...singleResult, skipped: false };
|
|
4570
|
+
if (singleResult.exitCode !== 0 && failFast && !childStopped) aborted = true;
|
|
4571
|
+
return stopped || childStopped ? { ...singleResult, output: stopMessage, error: stopMessage, exitCode: 1, interrupted: false, timedOut: false, stopped: true, skipped: false } : timedOut ? { ...singleResult, output: singleResult.output || (timeoutMessage ?? "Subagent timed out."), error: singleResult.error ?? timeoutMessage ?? "Subagent timed out.", exitCode: 1, interrupted: false, timedOut: true, skipped: false } : { ...singleResult, skipped: false };
|
|
4307
4572
|
},
|
|
4308
4573
|
globalSemaphore,
|
|
4309
4574
|
);
|
|
@@ -4355,14 +4620,16 @@ async function runSubagent(
|
|
|
4355
4620
|
model: pr.model,
|
|
4356
4621
|
attemptedModels: pr.attemptedModels,
|
|
4357
4622
|
modelAttempts: pr.modelAttempts,
|
|
4623
|
+
contextOverflow: pr.contextOverflow,
|
|
4358
4624
|
totalCost: pr.totalCost,
|
|
4359
4625
|
artifactPaths: pr.artifactPaths,
|
|
4360
4626
|
transcriptPath: pr.transcriptPath,
|
|
4361
4627
|
transcriptError: pr.transcriptError,
|
|
4362
|
-
|
|
4363
|
-
|
|
4364
|
-
|
|
4365
|
-
|
|
4628
|
+
effects: pr.effects,
|
|
4629
|
+
execution: pr.execution,
|
|
4630
|
+
review: pr.review,
|
|
4631
|
+
timeoutRecovery: pr.timeoutRecovery,
|
|
4632
|
+
structuredOutput: pr.structuredOutput,
|
|
4366
4633
|
structuredOutputPath: pr.structuredOutputPath,
|
|
4367
4634
|
structuredOutputSchemaPath: pr.structuredOutputSchemaPath,
|
|
4368
4635
|
acceptance: pr.acceptance,
|
|
@@ -4458,6 +4725,52 @@ async function runSubagent(
|
|
|
4458
4725
|
}
|
|
4459
4726
|
} else {
|
|
4460
4727
|
const seqStep = step as SubagentStep;
|
|
4728
|
+
if (timedOut) {
|
|
4729
|
+
results.push(timedOutStepResult(seqStep.agent, seqStep.context));
|
|
4730
|
+
flatIndex++;
|
|
4731
|
+
continue;
|
|
4732
|
+
}
|
|
4733
|
+
if (stopped) {
|
|
4734
|
+
results.push(stoppedStepResult(seqStep.agent, seqStep.context));
|
|
4735
|
+
flatIndex++;
|
|
4736
|
+
continue;
|
|
4737
|
+
}
|
|
4738
|
+
if (childStopRequests.has(flatIndex)) {
|
|
4739
|
+
results.push(childStopResult(flatIndex, seqStep.agent, seqStep.context));
|
|
4740
|
+
flatIndex++;
|
|
4741
|
+
continue;
|
|
4742
|
+
}
|
|
4743
|
+
if (interrupted) {
|
|
4744
|
+
results.push(pausedStepResult(seqStep.agent, seqStep.context));
|
|
4745
|
+
flatIndex++;
|
|
4746
|
+
continue;
|
|
4747
|
+
}
|
|
4748
|
+
let singleWorktreeSetup: WorktreeSetup | undefined;
|
|
4749
|
+
if (seqStep.worktree) {
|
|
4750
|
+
try {
|
|
4751
|
+
singleWorktreeSetup = createWorktrees(cwd, `${id}-s${stepIndex}`, 1, omitUndefinedProperties({
|
|
4752
|
+
agents: [seqStep.agent],
|
|
4753
|
+
setupHook: config.worktreeSetupHook
|
|
4754
|
+
? omitUndefinedProperties({ hookPath: config.worktreeSetupHook, timeoutMs: config.worktreeSetupHookTimeoutMs })
|
|
4755
|
+
: undefined,
|
|
4756
|
+
baseDir: config.worktreeBaseDir,
|
|
4757
|
+
}));
|
|
4758
|
+
writePendingParallelHandoff({
|
|
4759
|
+
manifestPath: parallelHandoffPath(asyncDir),
|
|
4760
|
+
runId: id,
|
|
4761
|
+
mode: "single",
|
|
4762
|
+
source: "async",
|
|
4763
|
+
cwd,
|
|
4764
|
+
stepIndex,
|
|
4765
|
+
flatStartIndex: flatIndex,
|
|
4766
|
+
setup: singleWorktreeSetup,
|
|
4767
|
+
});
|
|
4768
|
+
} catch (error) {
|
|
4769
|
+
if (singleWorktreeSetup) cleanupWorktrees(singleWorktreeSetup);
|
|
4770
|
+
throw error;
|
|
4771
|
+
}
|
|
4772
|
+
}
|
|
4773
|
+
const singleCwd = singleWorktreeSetup?.worktrees[0]?.agentCwd ?? cwd;
|
|
4461
4774
|
const stepStartTime = Date.now();
|
|
4462
4775
|
statusPayload.currentStep = flatIndex;
|
|
4463
4776
|
requiredStatusStep(statusPayload, flatIndex).status = "running";
|
|
@@ -4481,8 +4794,11 @@ async function runSubagent(
|
|
|
4481
4794
|
}));
|
|
4482
4795
|
|
|
4483
4796
|
flushPendingStepSteers(flatIndex);
|
|
4484
|
-
const
|
|
4485
|
-
|
|
4797
|
+
const executionStep = singleWorktreeSetup ? { ...seqStep, cwd: singleCwd } : seqStep;
|
|
4798
|
+
let singleResult: Awaited<ReturnType<typeof runSingleStepWithTimeout>>;
|
|
4799
|
+
try {
|
|
4800
|
+
singleResult = await runSingleStepWithTimeout(executionStep, compactOptional<SingleStepContext>({
|
|
4801
|
+
previousOutput, placeholder, cwd: singleCwd, sessionEnabled,
|
|
4486
4802
|
outputs: statusPayload.mode === "single" ? undefined : outputs,
|
|
4487
4803
|
sessionDir: config.sessionDir,
|
|
4488
4804
|
artifactsDir, artifactConfig, id,
|
|
@@ -4512,8 +4828,14 @@ async function runSubagent(
|
|
|
4512
4828
|
onChildEvent: (event) => updateStepFromChildEvent(flatIndex, event),
|
|
4513
4829
|
onWriterProcess,
|
|
4514
4830
|
onExternalProcess: (process) => updateExternalProcess(flatIndex, process),
|
|
4515
|
-
|
|
4516
|
-
|
|
4831
|
+
onExternalJob: (externalJob) => updateExternalJob(flatIndex, externalJob),
|
|
4832
|
+
skipAcceptance: () => timedOut || stopped || childStopRequests.has(flatIndex),
|
|
4833
|
+
orcaProgressTab,
|
|
4834
|
+
}), config.deadlineAt);
|
|
4835
|
+
} catch (error) {
|
|
4836
|
+
if (singleWorktreeSetup) cleanupWorktrees(singleWorktreeSetup);
|
|
4837
|
+
throw error;
|
|
4838
|
+
}
|
|
4517
4839
|
if (seqStep.sessionFile) {
|
|
4518
4840
|
latestSessionFile = seqStep.sessionFile;
|
|
4519
4841
|
}
|
|
@@ -4527,7 +4849,7 @@ async function runSubagent(
|
|
|
4527
4849
|
launchContractDigest: singleResult.launchContractDigest,
|
|
4528
4850
|
launchResolvedExtensions: singleResult.launchResolvedExtensions,
|
|
4529
4851
|
runtimeAcknowledgedExtensions: singleResult.runtimeAcknowledgedExtensions,
|
|
4530
|
-
output: stopped || childStopped ? stopMessage : timedOut ? (timeoutMessage ?? "Subagent timed out.") : singleResult.output,
|
|
4852
|
+
output: stopped || childStopped ? stopMessage : timedOut ? singleResult.output || (timeoutMessage ?? "Subagent timed out.") : singleResult.output,
|
|
4531
4853
|
outputState: singleResult.outputState,
|
|
4532
4854
|
error: stopped || childStopped ? stopMessage : timedOut ? (timeoutMessage ?? "Subagent timed out.") : singleResult.error,
|
|
4533
4855
|
protocolError: singleResult.protocolError,
|
|
@@ -4538,6 +4860,7 @@ async function runSubagent(
|
|
|
4538
4860
|
model: singleResult.model,
|
|
4539
4861
|
attemptedModels: singleResult.attemptedModels,
|
|
4540
4862
|
modelAttempts: singleResult.modelAttempts,
|
|
4863
|
+
contextOverflow: singleResult.contextOverflow,
|
|
4541
4864
|
totalCost: singleResult.totalCost,
|
|
4542
4865
|
artifactPaths: singleResult.artifactPaths,
|
|
4543
4866
|
transcriptPath: singleResult.transcriptPath,
|
|
@@ -4545,6 +4868,7 @@ async function runSubagent(
|
|
|
4545
4868
|
effects: singleResult.effects,
|
|
4546
4869
|
execution: singleResult.execution,
|
|
4547
4870
|
review: singleResult.review,
|
|
4871
|
+
timeoutRecovery: singleResult.timeoutRecovery,
|
|
4548
4872
|
structuredOutput: singleResult.structuredOutput,
|
|
4549
4873
|
structuredOutputPath: singleResult.structuredOutputPath,
|
|
4550
4874
|
structuredOutputSchemaPath: singleResult.structuredOutputSchemaPath,
|
|
@@ -4562,6 +4886,7 @@ async function runSubagent(
|
|
|
4562
4886
|
toolBudgetBlocked: singleResult.toolBudgetBlocked,
|
|
4563
4887
|
runner: singleResult.runner,
|
|
4564
4888
|
externalProcess: singleResult.externalProcess,
|
|
4889
|
+
externalJob: singleResult.externalJob,
|
|
4565
4890
|
}));
|
|
4566
4891
|
if (seqStep.outputName) {
|
|
4567
4892
|
outputs[seqStep.outputName] = outputEntryFromAsyncResult({
|
|
@@ -4615,6 +4940,7 @@ async function runSubagent(
|
|
|
4615
4940
|
setOptionalProperty(requiredStatusStep(statusPayload, flatIndex), "thinking", resolveEffectiveThinking(singleResult.model, requiredStatusStep(statusPayload, flatIndex).thinking));
|
|
4616
4941
|
setOptionalProperty(requiredStatusStep(statusPayload, flatIndex), "attemptedModels", singleResult.attemptedModels);
|
|
4617
4942
|
setOptionalProperty(requiredStatusStep(statusPayload, flatIndex), "modelAttempts", singleResult.modelAttempts);
|
|
4943
|
+
setOptionalProperty(requiredStatusStep(statusPayload, flatIndex), "contextOverflow", singleResult.contextOverflow);
|
|
4618
4944
|
setOptionalProperty(requiredStatusStep(statusPayload, flatIndex), "totalCost", singleResult.totalCost);
|
|
4619
4945
|
setOptionalProperty(requiredStatusStep(statusPayload, flatIndex), "error", stopped || childStopped ? stopMessage : timedOut ? (timeoutMessage ?? "Subagent timed out.") : singleResult.error);
|
|
4620
4946
|
setOptionalProperty(requiredStatusStep(statusPayload, flatIndex), "transcriptPath", singleResult.transcriptPath ?? requiredStatusStep(statusPayload, flatIndex).transcriptPath);
|
|
@@ -4629,6 +4955,7 @@ async function runSubagent(
|
|
|
4629
4955
|
setOptionalProperty(requiredStatusStep(statusPayload, flatIndex), "structuredOutputPath", singleResult.structuredOutputPath);
|
|
4630
4956
|
setOptionalProperty(requiredStatusStep(statusPayload, flatIndex), "structuredOutputSchemaPath", singleResult.structuredOutputSchemaPath);
|
|
4631
4957
|
setOptionalProperty(requiredStatusStep(statusPayload, flatIndex), "acceptance", singleResult.acceptance);
|
|
4958
|
+
setOptionalProperty(requiredStatusStep(statusPayload, flatIndex), "timeoutRecovery", singleResult.timeoutRecovery);
|
|
4632
4959
|
setOptionalProperty(requiredStatusStep(statusPayload, flatIndex), "watchdog", singleResult.watchdog);
|
|
4633
4960
|
setOptionalProperty(requiredStatusStep(statusPayload, flatIndex), "capabilityCeiling", singleResult.capabilityCeiling);
|
|
4634
4961
|
setOptionalProperty(requiredStatusStep(statusPayload, flatIndex), "capabilityAudit", singleResult.capabilityAudit);
|
|
@@ -4652,6 +4979,49 @@ async function runSubagent(
|
|
|
4652
4979
|
durationMs: stepEndTime - stepStartTime,
|
|
4653
4980
|
tokens: stepTokens,
|
|
4654
4981
|
}));
|
|
4982
|
+
if (stopped || childStopped) appendTerminalChildStatusEvent(flatIndex, stepEndTime);
|
|
4983
|
+
if (singleWorktreeSetup && !singleResult.detached) {
|
|
4984
|
+
const diffs = diffWorktrees(singleWorktreeSetup, [seqStep.agent], path.join(asyncDir, "worktree-diffs", `step-${stepIndex}`));
|
|
4985
|
+
const diffSummary = formatWorktreeDiffSummary(diffs);
|
|
4986
|
+
const manifestPath = parallelHandoffPath(asyncDir);
|
|
4987
|
+
const handoff = {
|
|
4988
|
+
manifestPath,
|
|
4989
|
+
runId: id,
|
|
4990
|
+
mode: "single" as const,
|
|
4991
|
+
source: "async" as const,
|
|
4992
|
+
cwd,
|
|
4993
|
+
stepIndex,
|
|
4994
|
+
flatStartIndex: flatIndex,
|
|
4995
|
+
setup: singleWorktreeSetup,
|
|
4996
|
+
diffs,
|
|
4997
|
+
results: [{
|
|
4998
|
+
agent: singleResult.agent,
|
|
4999
|
+
status: singleResult.stopped ? "stopped" as const : singleResult.interrupted ? "paused" as const : singleResult.exitCode === 0 ? "completed" as const : "failed" as const,
|
|
5000
|
+
summary: singleResult.output || singleResult.error || "(no output)",
|
|
5001
|
+
...(singleResult.artifactPaths?.outputPath ? { outputPath: singleResult.artifactPaths.outputPath } : {}),
|
|
5002
|
+
...(singleResult.structuredOutput !== undefined ? { structuredOutput: singleResult.structuredOutput } : {}),
|
|
5003
|
+
...(singleResult.structuredOutputPath ? { structuredOutputPath: singleResult.structuredOutputPath } : {}),
|
|
5004
|
+
...(singleResult.sessionFile ? { sessionPath: singleResult.sessionFile } : {}),
|
|
5005
|
+
}],
|
|
5006
|
+
};
|
|
5007
|
+
try {
|
|
5008
|
+
writeParallelHandoffGroup(handoff);
|
|
5009
|
+
const cleanup = cleanupWorktrees(singleWorktreeSetup, {
|
|
5010
|
+
kind: "preserve",
|
|
5011
|
+
capturedDiffs: diffs,
|
|
5012
|
+
handoffManifestPath: manifestPath,
|
|
5013
|
+
...(config.parentWorkflowRunId && singleResult.sessionFile && fs.existsSync(singleResult.sessionFile) && !singleResult.stopped
|
|
5014
|
+
? { cleanupBlocker: "retained child resume requires managed worktree cwd" }
|
|
5015
|
+
: {}),
|
|
5016
|
+
});
|
|
5017
|
+
statusPayload.parallelHandoff = writeParallelHandoffGroup({ ...handoff, cleanup });
|
|
5018
|
+
previousOutput = [previousOutput, diffSummary, formatParallelHandoffReference(statusPayload.parallelHandoff)].filter(Boolean).join("\n\n");
|
|
5019
|
+
} catch (error) {
|
|
5020
|
+
previousOutput = [previousOutput, diffSummary, formatParallelHandoffError(error)].filter(Boolean).join("\n\n");
|
|
5021
|
+
}
|
|
5022
|
+
writeStatusPayload();
|
|
5023
|
+
}
|
|
5024
|
+
|
|
4655
5025
|
if (singleResult.completionGuardTriggered) {
|
|
4656
5026
|
const event = buildControlEvent(omitUndefinedProperties({
|
|
4657
5027
|
from: requiredStatusStep(statusPayload, flatIndex).activityState,
|
|
@@ -4753,8 +5123,8 @@ async function runSubagent(
|
|
|
4753
5123
|
stopped: result.stopped,
|
|
4754
5124
|
turnBudgetExceeded: result.turnBudgetExceeded,
|
|
4755
5125
|
})));
|
|
4756
|
-
statusPayload.state =
|
|
4757
|
-
closeSteerInbox(asyncDir, statusPayload.state);
|
|
5126
|
+
statusPayload.state = stopped || signalTerminated ? "stopped" : timedOut || turnBudgetExceeded || usageBudgetExceeded || statusPayload.error ? "failed" : interrupted ? "paused" : results.every((r) => r.success) ? "complete" : "failed";
|
|
5127
|
+
closeSteerInbox(asyncDir, statusPayload.state, (filePath, payload) => runPersistence.write(filePath, payload));
|
|
4758
5128
|
disposeControlInbox();
|
|
4759
5129
|
for (const request of consumeSteerRequests(asyncDir)) deliverSteerRequest(request);
|
|
4760
5130
|
const effectiveSessionFile = sessionFile ?? latestSessionFile;
|
|
@@ -4805,15 +5175,16 @@ async function runSubagent(
|
|
|
4805
5175
|
statusPayload.error = `Step failed: ${failedStep.agent}`;
|
|
4806
5176
|
}
|
|
4807
5177
|
}
|
|
5178
|
+
writeStatusPayload();
|
|
4808
5179
|
try {
|
|
4809
|
-
|
|
5180
|
+
runPersistence.write(resultPath, {
|
|
4810
5181
|
lifecycleArtifactVersion: SUBAGENT_LIFECYCLE_ARTIFACT_VERSION,
|
|
4811
5182
|
id,
|
|
4812
5183
|
agent: agentName,
|
|
4813
5184
|
mode: resultMode,
|
|
4814
|
-
success: !
|
|
4815
|
-
state:
|
|
4816
|
-
summary:
|
|
5185
|
+
success: !stopped && !timedOut && !turnBudgetExceeded && !usageBudgetExceeded && !interrupted && !signalTerminated && results.every((r) => r.success),
|
|
5186
|
+
state: stopped || signalTerminated ? "stopped" : timedOut || turnBudgetExceeded || usageBudgetExceeded ? "failed" : interrupted ? "paused" : results.every((r) => r.success) ? "complete" : "failed",
|
|
5187
|
+
summary: stopped ? stopMessage : signalTerminated ? (statusPayload.error ?? "Subagent process terminated by signal.") : timedOut ? (timeoutMessage ?? "Subagent timed out.") : turnBudgetExceeded ? (statusPayload.error ?? "Subagent exceeded turn budget.") : usageBudgetExceeded ? (statusPayload.error ?? "Usage budget exhausted.") : interrupted ? "Paused after interrupt. Waiting for explicit next action." : summary,
|
|
4817
5188
|
...(config.timeoutMs !== undefined ? { timeoutMs: config.timeoutMs } : {}),
|
|
4818
5189
|
...(config.deadlineAt !== undefined ? { deadlineAt: config.deadlineAt } : {}),
|
|
4819
5190
|
...(statusPayload.turnBudget ? { turnBudget: statusPayload.turnBudget } : {}),
|
|
@@ -4822,7 +5193,6 @@ async function runSubagent(
|
|
|
4822
5193
|
...(statusPayload.toolBudget ? { toolBudget: statusPayload.toolBudget } : {}),
|
|
4823
5194
|
...(statusPayload.toolBudgetBlocked ? { toolBudgetBlocked: true } : {}),
|
|
4824
5195
|
...(statusPayload.usageBudget ? { usageBudget: statusPayload.usageBudget } : {}),
|
|
4825
|
-
...(statusPayload.checkpoint ? { checkpoint: statusPayload.checkpoint } : {}),
|
|
4826
5196
|
...(stopped ? { stopped: true, error: stopMessage } : timedOut ? { timedOut: true, error: timeoutMessage ?? "Subagent timed out." } : turnBudgetExceeded ? { error: statusPayload.error ?? "Subagent exceeded turn budget." } : usageBudgetExceeded ? { error: statusPayload.error ?? "Usage budget exhausted." } : {}),
|
|
4827
5197
|
results: results.map((r) => omitUndefinedProperties({
|
|
4828
5198
|
agent: r.agent,
|
|
@@ -4847,6 +5217,7 @@ async function runSubagent(
|
|
|
4847
5217
|
model: r.model,
|
|
4848
5218
|
attemptedModels: r.attemptedModels,
|
|
4849
5219
|
modelAttempts: r.modelAttempts,
|
|
5220
|
+
contextOverflow: r.contextOverflow,
|
|
4850
5221
|
totalCost: r.totalCost,
|
|
4851
5222
|
artifactPaths: r.artifactPaths,
|
|
4852
5223
|
outputSaveError: r.outputSaveError,
|
|
@@ -4860,6 +5231,7 @@ async function runSubagent(
|
|
|
4860
5231
|
runtimeAcknowledgedExtensions: r.runtimeAcknowledgedExtensions,
|
|
4861
5232
|
runner: r.runner,
|
|
4862
5233
|
externalProcess: r.externalProcess,
|
|
5234
|
+
externalJob: r.externalJob,
|
|
4863
5235
|
execution: r.execution,
|
|
4864
5236
|
review: r.review,
|
|
4865
5237
|
effects: r.effects,
|
|
@@ -4868,6 +5240,7 @@ async function runSubagent(
|
|
|
4868
5240
|
structuredOutputSchemaPath: r.structuredOutputSchemaPath,
|
|
4869
5241
|
acceptance: r.acceptance,
|
|
4870
5242
|
watchdog: r.watchdog,
|
|
5243
|
+
timeoutRecovery: r.timeoutRecovery,
|
|
4871
5244
|
capabilityCeiling: r.capabilityCeiling,
|
|
4872
5245
|
capabilityAudit: r.capabilityAudit,
|
|
4873
5246
|
})),
|
|
@@ -4878,13 +5251,12 @@ async function runSubagent(
|
|
|
4878
5251
|
capabilityAudit: statusPayload.capabilityAudit,
|
|
4879
5252
|
...(config.parentWorkflowRunId ? { parentWorkflowRunId: config.parentWorkflowRunId } : {}),
|
|
4880
5253
|
...(config.workflowKey ? { workflowKey: config.workflowKey } : {}),
|
|
4881
|
-
exitCode:
|
|
5254
|
+
exitCode: stopped || timedOut || turnBudgetExceeded || usageBudgetExceeded ? 1 : interrupted || results.every((r) => r.success) ? 0 : 1,
|
|
4882
5255
|
timestamp: runEndedAt,
|
|
4883
5256
|
durationMs: runEndedAt - overallStartTime,
|
|
4884
5257
|
totalTokens: statusPayload.totalTokens,
|
|
4885
5258
|
totalCost: finalTotalCost,
|
|
4886
5259
|
usageBudget: statusPayload.usageBudget,
|
|
4887
|
-
checkpoint: statusPayload.checkpoint,
|
|
4888
5260
|
truncated,
|
|
4889
5261
|
artifactsDir,
|
|
4890
5262
|
cwd,
|
|
@@ -4893,6 +5265,7 @@ async function runSubagent(
|
|
|
4893
5265
|
launchResolvedExtensions: config.launchResolvedExtensions,
|
|
4894
5266
|
runtimeAcknowledgedExtensions: singleRuntimeAcknowledgedExtensions,
|
|
4895
5267
|
sessionId: config.sessionId,
|
|
5268
|
+
completionOwnerId: config.completionOwnerId,
|
|
4896
5269
|
sessionFile: effectiveSessionFile,
|
|
4897
5270
|
intercomTarget: config.controlIntercomTarget,
|
|
4898
5271
|
shareUrl,
|
|
@@ -4900,7 +5273,7 @@ async function runSubagent(
|
|
|
4900
5273
|
shareError,
|
|
4901
5274
|
...(taskIndex !== undefined && { taskIndex }),
|
|
4902
5275
|
...(totalTasks !== undefined && { totalTasks }),
|
|
4903
|
-
});
|
|
5276
|
+
}, (filePath, payload) => { writeAsyncResultFile(filePath, payload as Record<string, unknown>); });
|
|
4904
5277
|
finalResultCommitted = true;
|
|
4905
5278
|
} catch (err) {
|
|
4906
5279
|
const message = `Failed to write result file ${resultPath}: ${err instanceof Error ? err.message : String(err)}`;
|
|
@@ -4910,6 +5283,7 @@ async function runSubagent(
|
|
|
4910
5283
|
statusPayload.lastUpdate = Date.now();
|
|
4911
5284
|
}
|
|
4912
5285
|
writeStatusPayload();
|
|
5286
|
+
orcaProgressTab?.finish(statusPayload.state === "complete" ? "completed" : statusPayload.state === "stopped" ? "stopped" : "failed", effectiveSessionFile);
|
|
4913
5287
|
appendJsonl(
|
|
4914
5288
|
eventsPath,
|
|
4915
5289
|
JSON.stringify({
|
|
@@ -4941,7 +5315,11 @@ async function runSubagent(
|
|
|
4941
5315
|
sessionFile: effectiveSessionFile,
|
|
4942
5316
|
shareUrl,
|
|
4943
5317
|
shareError,
|
|
5318
|
+
}), (filePath, content) => runPersistence.write(filePath, { content }, (_path, payload) => {
|
|
5319
|
+
fs.writeFileSync(_path, (payload as { content: string }).content, "utf-8");
|
|
4944
5320
|
}));
|
|
5321
|
+
if (runPersistence.pendingCount() === 0) runPersistence.dispose();
|
|
5322
|
+
if (indexPersistence.pendingCount() === 0) indexPersistence.dispose();
|
|
4945
5323
|
if (config.runnerProcessInstanceId) {
|
|
4946
5324
|
const writers: Record<string, PiWriterProcessInstanceExitV1[]> = {};
|
|
4947
5325
|
const expectedWriters: Record<string, number> = {};
|