@selesai/code 0.9.10 → 0.9.12
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 +271 -255
- package/dist/cli/args.js +13 -2
- package/dist/cli/args.test.js +8 -0
- package/dist/cli/credential-print.js +4 -4
- package/dist/cli.js +0 -0
- package/dist/config.d.ts +4 -6
- package/dist/config.js +10 -14
- package/dist/core/agent-session-auto-handoff.test.js +24 -1
- package/dist/core/agent-session.d.ts +10 -4
- package/dist/core/agent-session.js +61 -46
- package/dist/core/compaction/branch-summarization.js +30 -30
- package/dist/core/compaction/compaction.js +81 -81
- package/dist/core/compaction/utils.js +2 -2
- package/dist/core/defaults.d.ts +1 -0
- package/dist/core/defaults.js +9 -0
- package/dist/core/export-html/template.css +1066 -1066
- package/dist/core/export-html/template.html +55 -55
- package/dist/core/export-html/template.js +1864 -1864
- package/dist/core/export-html/vendor/highlight.min.js +1212 -1212
- package/dist/core/export-html/vendor/marked.min.js +78 -78
- package/dist/core/extensions/loader.js +108 -35
- package/dist/core/extensions/loader.test.js +21 -0
- package/dist/core/extensions/types.d.ts +12 -4
- package/dist/core/keybindings.d.ts +2 -2
- package/dist/core/messages.js +7 -7
- package/dist/core/model-resolver.d.ts +1 -0
- package/dist/core/model-resolver.js +10 -4
- package/dist/core/package-manager.js +4 -4
- package/dist/core/sdk.d.ts +5 -5
- package/dist/core/sdk.js +16 -4
- package/dist/core/settings-manager.d.ts +6 -2
- package/dist/core/settings-manager.js +22 -3
- package/dist/core/tools/bash.d.ts +18 -1
- package/dist/core/tools/bash.js +41 -23
- package/dist/core/tools/index.d.ts +4 -2
- package/dist/core/tools/index.js +9 -2
- package/dist/core/tools/powershell.d.ts +15 -0
- package/dist/core/tools/powershell.js +38 -0
- package/dist/core/tools/powershell.test.d.ts +1 -0
- package/dist/core/tools/powershell.test.js +20 -0
- package/dist/defaults/settings.json +0 -1
- package/dist/extensions/context-compaction-reminder.test.ts +82 -82
- package/dist/extensions/context-compaction-reminder.ts +28 -28
- 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/LICENSE +21 -21
- 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.test.ts +83 -83
- package/dist/extensions/pi-intercom/broker/client.ts +39 -12
- package/dist/extensions/pi-intercom/broker/extension.test.ts +486 -387
- package/dist/extensions/pi-intercom/broker/framing.test.ts +114 -114
- package/dist/extensions/pi-intercom/broker/paths.test.ts +153 -153
- package/dist/extensions/pi-intercom/broker/paths.ts +134 -134
- package/dist/extensions/pi-intercom/broker/protocol.ts +26 -0
- package/dist/extensions/pi-intercom/broker/runtime-claim.test.ts +34 -34
- package/dist/extensions/pi-intercom/broker/runtime-claim.ts +21 -21
- 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/cwd.test.ts +40 -40
- package/dist/extensions/pi-intercom/cwd.ts +31 -31
- package/dist/extensions/pi-intercom/extension-api.ts +84 -44
- package/dist/extensions/pi-intercom/format-context.test.ts +31 -31
- package/dist/extensions/pi-intercom/format-context.ts +32 -32
- 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/test/overlay-width.test.ts +66 -66
- package/dist/extensions/pi-intercom/types.ts +32 -5
- package/dist/extensions/pi-intercom/ui/compose.ts +143 -143
- package/dist/extensions/pi-intercom/ui/inline-message.ts +6 -0
- package/dist/extensions/pi-intercom/ui/session-list.ts +166 -166
- package/dist/extensions/pi-powerline-footer/bash-mode/shell-session.ts +286 -286
- package/dist/extensions/pi-powerline-footer/bash-mode/transcript.ts +108 -108
- package/dist/extensions/pi-powerline-footer/separators.ts +57 -57
- package/dist/extensions/pi-powerline-footer/tests/session-usage.test.ts +47 -47
- package/dist/extensions/pi-powerline-footer/tests/tps.test.ts +39 -39
- package/dist/extensions/pi-powerline-footer/theme.example.json +24 -24
- package/dist/extensions/pi-powerline-footer/theme.json +12 -12
- package/dist/extensions/pi-powerline-footer/tps.ts +345 -345
- package/dist/extensions/pi-rewind-hook/README.md +245 -245
- package/dist/extensions/pi-rewind-hook/index.ts +1445 -1445
- package/dist/extensions/pi-rewind-hook/package.json +29 -29
- 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/pi-web-agent/package.json +31 -31
- package/dist/extensions/pi-web-agent/src/backends/config.ts +205 -205
- package/dist/extensions/pi-web-agent/src/backends/doctor.ts +136 -136
- package/dist/extensions/pi-web-agent/src/backends/factory.ts +152 -152
- package/dist/extensions/pi-web-agent/src/backends/settings-reader.ts +25 -25
- package/dist/extensions/pi-web-agent/src/cache/ttl-cache.ts +28 -28
- package/dist/extensions/pi-web-agent/src/changelog-notice.ts +136 -136
- package/dist/extensions/pi-web-agent/src/commands/web-agent-config.ts +946 -946
- package/dist/extensions/pi-web-agent/src/extension.ts +126 -126
- package/dist/extensions/pi-web-agent/src/extract/readability.ts +118 -118
- package/dist/extensions/pi-web-agent/src/fetch/browser-resolution.ts +199 -199
- package/dist/extensions/pi-web-agent/src/fetch/firecrawl-fetch.ts +100 -100
- package/dist/extensions/pi-web-agent/src/fetch/headless-fetch.ts +117 -117
- package/dist/extensions/pi-web-agent/src/fetch/http-fetch.ts +67 -67
- package/dist/extensions/pi-web-agent/src/orchestration/answer-synthesizer.ts +60 -60
- package/dist/extensions/pi-web-agent/src/orchestration/candidate-selector.ts +50 -50
- package/dist/extensions/pi-web-agent/src/orchestration/direct-url.ts +52 -52
- package/dist/extensions/pi-web-agent/src/orchestration/evidence-quality.ts +105 -105
- package/dist/extensions/pi-web-agent/src/orchestration/evidence-ranker.ts +45 -45
- package/dist/extensions/pi-web-agent/src/orchestration/index.ts +28 -28
- package/dist/extensions/pi-web-agent/src/orchestration/query-planner.ts +47 -47
- package/dist/extensions/pi-web-agent/src/orchestration/research-orchestrator.ts +376 -376
- package/dist/extensions/pi-web-agent/src/orchestration/research-types.ts +64 -64
- package/dist/extensions/pi-web-agent/src/orchestration/research-worker.ts +181 -181
- package/dist/extensions/pi-web-agent/src/orchestration/source-profile.ts +101 -101
- package/dist/extensions/pi-web-agent/src/orchestration/stop-decider.ts +81 -81
- package/dist/extensions/pi-web-agent/src/presentation/config-store.ts +210 -210
- package/dist/extensions/pi-web-agent/src/presentation/config.ts +75 -75
- package/dist/extensions/pi-web-agent/src/presentation/explore-presentation.ts +61 -61
- package/dist/extensions/pi-web-agent/src/presentation/fetch-presentation.ts +54 -54
- package/dist/extensions/pi-web-agent/src/presentation/search-presentation.ts +41 -41
- package/dist/extensions/pi-web-agent/src/presentation/select-view.ts +20 -20
- package/dist/extensions/pi-web-agent/src/presentation/types.ts +63 -63
- package/dist/extensions/pi-web-agent/src/search/brave.ts +114 -114
- package/dist/extensions/pi-web-agent/src/search/duckduckgo.ts +72 -72
- package/dist/extensions/pi-web-agent/src/search/searxng.ts +96 -96
- package/dist/extensions/pi-web-agent/src/tools/web-explore.ts +71 -71
- package/dist/extensions/pi-web-agent/src/tools/web-fetch-headless.ts +31 -31
- package/dist/extensions/pi-web-agent/src/tools/web-fetch.ts +31 -31
- package/dist/extensions/pi-web-agent/src/tools/web-search.ts +157 -157
- package/dist/extensions/pi-web-agent/src/types.ts +88 -88
- package/dist/extensions/ponytail/index.js +31 -25
- package/dist/extensions/ponytail/package.json +8 -8
- 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/extensions/question/batch.ts +103 -103
- package/dist/extensions/question/constants.ts +30 -30
- package/dist/extensions/question/helpers.ts +58 -58
- package/dist/extensions/question/navigation.ts +14 -14
- package/dist/extensions/question/package.json +19 -19
- package/dist/extensions/question/schemas.ts +43 -43
- package/dist/extensions/question/selection-mode.ts +46 -46
- package/dist/extensions/question/shortcuts.ts +44 -44
- package/dist/extensions/question/types.ts +132 -132
- package/dist/extensions/test-resolve-hook-impl.mjs +6 -6
- package/dist/extensions/test-resolve-hook.mjs +6 -6
- package/dist/extensions/web-agent-onboarding.ts +222 -222
- package/dist/extensions/workflow/package.json +17 -17
- package/dist/package-manager-cli.js +71 -71
- package/dist/rpc-entry.js +0 -0
- package/dist/skills/agent-browser/SKILL.md +52 -52
- package/dist/skills/batch-grill-me/SKILL.md +19 -19
- 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/grill-me/SKILL.md +10 -10
- package/dist/skills/handoff/SKILL.md +16 -16
- package/dist/skills/handoff-text/SKILL.md +14 -14
- 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/implanger/SKILL.md +69 -69
- package/dist/skills/improve-codebase/REFERENCE.md +78 -78
- package/dist/skills/improve-codebase/SKILL.md +178 -178
- 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/planger/SKILL.md +166 -166
- package/dist/skills/ponytail/SKILL.md +120 -116
- package/dist/skills/ponytail-audit/SKILL.md +41 -42
- package/dist/skills/ponytail-debt/SKILL.md +44 -45
- package/dist/skills/ponytail-gain/SKILL.md +50 -51
- package/dist/skills/ponytail-help/SKILL.md +71 -70
- package/dist/skills/ponytail-review/SKILL.md +57 -58
- package/dist/skills/redesign-existing-projects/SKILL.md +179 -0
- package/dist/skills/selesai-handoff/SKILL.md +20 -20
- 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/dist/skills/workflow-creation/SKILL.md +73 -73
- package/dist/themes/powerline-footer/theme.json +33 -33
- package/dist/utils/shell.d.ts +3 -0
- package/dist/utils/shell.js +17 -5
- package/docs/compaction.md +396 -396
- package/docs/containerization.md +111 -111
- package/docs/development.md +71 -71
- package/docs/docs.json +164 -164
- package/docs/environment-variables.md +86 -86
- package/docs/index.md +83 -83
- package/docs/json.md +82 -82
- package/docs/models.md +502 -502
- package/docs/packages.md +227 -227
- package/docs/plans/subagent-delegation/phase-0-correctness.md +264 -264
- package/docs/plans/subagent-delegation/phase-1-behavioral-contract.md +485 -485
- package/docs/plans/subagent-delegation/phase-2-context-controls.md +281 -281
- package/docs/plans/subagent-delegation/phase-3-advisory-routing.md +361 -361
- package/docs/plans/subagent-delegation/phase-4-optional-enforcement.md +380 -380
- package/docs/prompt-templates.md +95 -95
- package/docs/providers.md +293 -293
- package/docs/sdk.md +1144 -1143
- package/docs/security.md +59 -59
- package/docs/session-format.md +414 -414
- package/docs/sessions.md +145 -145
- package/docs/settings.md +0 -5
- package/docs/shared-host-extensions.md +109 -109
- package/docs/shell-aliases.md +13 -13
- package/docs/skills.md +231 -231
- package/docs/terminal-setup.md +142 -142
- package/docs/termux.md +127 -127
- package/docs/themes.md +295 -295
- package/docs/tmux.md +63 -63
- package/docs/tui.md +927 -927
- package/docs/windows.md +17 -17
- package/examples/README.md +25 -25
- package/examples/extensions/README.md +211 -211
- package/examples/extensions/auto-commit-on-exit.ts +49 -49
- package/examples/extensions/bash-spawn-hook.ts +30 -30
- package/examples/extensions/bookmark.ts +50 -50
- package/examples/extensions/border-status-editor.ts +150 -150
- package/examples/extensions/built-in-tool-renderer.ts +249 -249
- package/examples/extensions/claude-rules.ts +86 -86
- package/examples/extensions/commands.ts +72 -72
- package/examples/extensions/confirm-destructive.ts +59 -59
- package/examples/extensions/custom-compaction.ts +130 -130
- package/examples/extensions/custom-footer.ts +64 -64
- package/examples/extensions/custom-header.ts +73 -73
- package/examples/extensions/custom-provider-anthropic/index.ts +610 -610
- package/examples/extensions/custom-provider-anthropic/package-lock.json +24 -24
- package/examples/extensions/custom-provider-anthropic/package.json +19 -19
- package/examples/extensions/custom-provider-gitlab-duo/index.ts +404 -404
- package/examples/extensions/custom-provider-gitlab-duo/package.json +16 -16
- package/examples/extensions/custom-provider-gitlab-duo/test.ts +82 -82
- package/examples/extensions/dirty-repo-guard.ts +56 -56
- package/examples/extensions/doom-overlay/README.md +46 -46
- package/examples/extensions/doom-overlay/doom/build/doom.js +21 -21
- package/examples/extensions/doom-overlay/doom/build/doom.wasm +0 -0
- package/examples/extensions/doom-overlay/doom/build.sh +152 -152
- package/examples/extensions/doom-overlay/doom/doomgeneric_pi.c +72 -72
- package/examples/extensions/doom-overlay/doom-component.ts +132 -132
- package/examples/extensions/doom-overlay/doom-engine.ts +173 -173
- package/examples/extensions/doom-overlay/doom-keys.ts +104 -104
- package/examples/extensions/doom-overlay/index.ts +74 -74
- package/examples/extensions/doom-overlay/wad-finder.ts +51 -51
- package/examples/extensions/dynamic-resources/SKILL.md +8 -8
- package/examples/extensions/dynamic-resources/dynamic.json +79 -79
- package/examples/extensions/dynamic-resources/dynamic.md +5 -5
- package/examples/extensions/dynamic-resources/index.ts +15 -15
- package/examples/extensions/dynamic-tools.ts +74 -74
- package/examples/extensions/event-bus.ts +43 -43
- package/examples/extensions/file-trigger.ts +41 -41
- package/examples/extensions/git-checkpoint.ts +53 -53
- package/examples/extensions/git-merge-and-resolve.ts +115 -115
- package/examples/extensions/github-issue-autocomplete.ts +185 -185
- package/examples/extensions/gondolin/index.ts +531 -531
- package/examples/extensions/gondolin/package-lock.json +185 -185
- package/examples/extensions/gondolin/package.json +19 -19
- package/examples/extensions/handoff.ts +199 -199
- package/examples/extensions/hello.ts +26 -26
- package/examples/extensions/hidden-thinking-label.ts +53 -53
- package/examples/extensions/inline-bash.ts +94 -94
- package/examples/extensions/input-transform-streaming.ts +39 -39
- package/examples/extensions/input-transform.ts +43 -43
- package/examples/extensions/interactive-shell.ts +196 -196
- package/examples/extensions/mac-system-theme.ts +47 -47
- package/examples/extensions/message-renderer.ts +59 -59
- package/examples/extensions/minimal-mode.ts +426 -426
- package/examples/extensions/modal-editor.ts +85 -85
- package/examples/extensions/model-status.ts +31 -31
- package/examples/extensions/notify.ts +55 -55
- package/examples/extensions/overlay-qa-tests.ts +1450 -1450
- package/examples/extensions/overlay-test.ts +153 -153
- package/examples/extensions/permission-gate.ts +34 -34
- package/examples/extensions/pirate.ts +47 -47
- package/examples/extensions/plan-mode/README.md +66 -66
- package/examples/extensions/plan-mode/index.ts +390 -390
- package/examples/extensions/plan-mode/utils.ts +168 -168
- package/examples/extensions/preset.ts +436 -436
- package/examples/extensions/project-trust.ts +64 -64
- package/examples/extensions/prompt-customizer.ts +97 -97
- package/examples/extensions/protected-paths.ts +30 -30
- package/examples/extensions/provider-payload.ts +18 -18
- package/examples/extensions/qna.ts +122 -122
- package/examples/extensions/question.ts +285 -285
- package/examples/extensions/questionnaire.ts +448 -448
- package/examples/extensions/rainbow-editor.ts +88 -88
- package/examples/extensions/reload-runtime.ts +37 -37
- package/examples/extensions/rpc-demo.ts +118 -118
- package/examples/extensions/sandbox/index.ts +321 -321
- package/examples/extensions/sandbox/package-lock.json +92 -92
- package/examples/extensions/sandbox/package.json +19 -19
- package/examples/extensions/send-user-message.ts +97 -97
- package/examples/extensions/session-name.ts +27 -27
- package/examples/extensions/shutdown-command.ts +63 -63
- package/examples/extensions/snake.ts +343 -343
- package/examples/extensions/space-invaders.ts +560 -560
- package/examples/extensions/ssh.ts +220 -220
- package/examples/extensions/status-line.ts +32 -32
- package/examples/extensions/structured-output.ts +65 -65
- package/examples/extensions/subagent/README.md +175 -175
- package/examples/extensions/subagent/agents/planner.md +37 -37
- package/examples/extensions/subagent/agents/reviewer.md +35 -35
- package/examples/extensions/subagent/agents/scout.md +50 -50
- package/examples/extensions/subagent/agents/worker.md +24 -24
- package/examples/extensions/subagent/agents.ts +126 -126
- package/examples/extensions/subagent/index.ts +1015 -1015
- package/examples/extensions/subagent/prompts/implement-and-review.md +10 -10
- package/examples/extensions/subagent/prompts/implement.md +10 -10
- package/examples/extensions/subagent/prompts/scout-and-plan.md +9 -9
- package/examples/extensions/summarize.ts +209 -209
- package/examples/extensions/system-prompt-header.ts +17 -17
- package/examples/extensions/tic-tac-toe.ts +1008 -1008
- package/examples/extensions/timed-confirm.ts +70 -70
- package/examples/extensions/titlebar-spinner.ts +58 -58
- package/examples/extensions/todo.ts +297 -297
- package/examples/extensions/tool-override.ts +144 -144
- package/examples/extensions/tools.ts +146 -146
- package/examples/extensions/trigger-compact.ts +50 -50
- package/examples/extensions/truncated-tool.ts +195 -195
- package/examples/extensions/widget-placement.ts +9 -9
- package/examples/extensions/with-deps/index.ts +32 -32
- package/examples/extensions/with-deps/package-lock.json +31 -31
- package/examples/extensions/with-deps/package.json +22 -22
- package/examples/extensions/working-indicator.ts +123 -123
- package/examples/extensions/working-message-test.ts +25 -25
- package/examples/rpc-extension-ui.ts +632 -632
- package/examples/sdk/01-minimal.ts +26 -26
- package/examples/sdk/02-custom-model.ts +53 -53
- package/examples/sdk/03-custom-prompt.ts +75 -75
- package/examples/sdk/04-skills.ts +55 -55
- package/examples/sdk/05-tools.ts +48 -48
- package/examples/sdk/06-extensions.ts +99 -99
- package/examples/sdk/07-context-files.ts +47 -47
- package/examples/sdk/08-prompt-templates.ts +51 -51
- package/examples/sdk/09-api-keys-and-oauth.ts +52 -52
- package/examples/sdk/10-settings.ts +53 -53
- package/examples/sdk/11-sessions.ts +52 -52
- package/examples/sdk/12-full-control.ts +79 -79
- package/examples/sdk/13-session-runtime.ts +67 -67
- package/examples/sdk/README.md +144 -144
- package/package.json +4 -4
- 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.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
- /package/dist/core/{tools/schema-prune.test.d.ts → extensions/loader.test.d.ts} +0 -0
|
@@ -1,14 +1,31 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { createRequire } from "node:module";
|
|
3
|
+
import { dirname, resolve as resolvePath } from "node:path";
|
|
1
4
|
import { Worker } from "node:worker_threads";
|
|
2
5
|
|
|
3
6
|
const KEY_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/;
|
|
7
|
+
const requireFromPackage = createRequire(import.meta.url);
|
|
4
8
|
|
|
5
9
|
const WORKER_SOURCE = String.raw`
|
|
6
|
-
const { parentPort } = require("node:worker_threads");
|
|
7
|
-
const { promiseHooks } = require("node:v8");
|
|
10
|
+
const { parentPort, workerData } = require("node:worker_threads");
|
|
8
11
|
const vm = require("node:vm");
|
|
9
12
|
const { inspect } = require("node:util");
|
|
13
|
+
const { parse } = require(workerData.acornPath);
|
|
10
14
|
|
|
11
|
-
|
|
15
|
+
let promiseHooks;
|
|
16
|
+
try {
|
|
17
|
+
({ promiseHooks } = require("node:v8"));
|
|
18
|
+
} catch {}
|
|
19
|
+
|
|
20
|
+
function createWorkflowPromiseHook(callbacks) {
|
|
21
|
+
if (!promiseHooks || typeof promiseHooks.createHook !== "function") return () => {};
|
|
22
|
+
try {
|
|
23
|
+
return promiseHooks.createHook(callbacks);
|
|
24
|
+
} catch (error) {
|
|
25
|
+
if (error?.name !== "NotImplementedError") throw error;
|
|
26
|
+
return () => {};
|
|
27
|
+
}
|
|
28
|
+
}
|
|
12
29
|
|
|
13
30
|
let nextCallId = 0;
|
|
14
31
|
let topLevelWorkflowPromise;
|
|
@@ -20,7 +37,7 @@ const trackedPromiseTrackers = new WeakMap();
|
|
|
20
37
|
const trackedPromiseTargets = new WeakMap();
|
|
21
38
|
let nativePromiseTrackers = new WeakMap();
|
|
22
39
|
let nativePromiseParents = new WeakMap();
|
|
23
|
-
const
|
|
40
|
+
const observedCallIds = new Set();
|
|
24
41
|
|
|
25
42
|
function stableRunJson(value) {
|
|
26
43
|
if (Array.isArray(value)) return "[" + value.map(stableRunJson).join(",") + "]";
|
|
@@ -79,7 +96,7 @@ function mergeObservations(...groups) {
|
|
|
79
96
|
const merged = [];
|
|
80
97
|
for (const group of groups) {
|
|
81
98
|
for (const observation of group) {
|
|
82
|
-
if (!observation || typeof observation.callId !== "number" || typeof observation.key !== "string" || seen.has(observation.callId)) continue;
|
|
99
|
+
if (!observation || typeof observation.callId !== "number" || typeof observation.key !== "string" || typeof observation.operation !== "string" || seen.has(observation.callId)) continue;
|
|
83
100
|
seen.add(observation.callId);
|
|
84
101
|
merged.push(observation);
|
|
85
102
|
}
|
|
@@ -99,9 +116,9 @@ function addTrackedObservations(tracker, observations) {
|
|
|
99
116
|
tracker.observations = mergeObservations(tracker.observations, observations);
|
|
100
117
|
if (!tracker.consumed) return;
|
|
101
118
|
for (const observation of tracker.observations) {
|
|
102
|
-
if (
|
|
103
|
-
|
|
104
|
-
parentPort.postMessage({ type: "
|
|
119
|
+
if (observedCallIds.has(observation.callId)) continue;
|
|
120
|
+
observedCallIds.add(observation.callId);
|
|
121
|
+
parentPort.postMessage({ type: "callObserved", callId: observation.callId, key: observation.key, operation: observation.operation });
|
|
105
122
|
}
|
|
106
123
|
}
|
|
107
124
|
|
|
@@ -133,7 +150,15 @@ function trackObservationTracker(tracker, promise, allowFutureObservations = fal
|
|
|
133
150
|
get(promiseTarget, prop) {
|
|
134
151
|
if (prop === "then") return function promiseThen(onFulfilled, onRejected) {
|
|
135
152
|
consumeTrackedObservations(tracker);
|
|
136
|
-
|
|
153
|
+
const chainTracker = { observations: tracker.observations, consumed: false, dependencies: [tracker] };
|
|
154
|
+
const wrapHandler = (handler) => typeof handler === "function"
|
|
155
|
+
? function trackedThenHandler(...args) {
|
|
156
|
+
const value = handler.apply(this, args);
|
|
157
|
+
addTrackerDependency(chainTracker, promiseObservationTracker(value));
|
|
158
|
+
return trackedPromiseTarget(value);
|
|
159
|
+
}
|
|
160
|
+
: handler;
|
|
161
|
+
return trackObservationTracker(chainTracker, promiseTarget.then(wrapHandler(onFulfilled), wrapHandler(onRejected)), true);
|
|
137
162
|
};
|
|
138
163
|
if (prop === "catch") return function promiseCatch(onRejected) {
|
|
139
164
|
consumeTrackedObservations(tracker);
|
|
@@ -211,8 +236,8 @@ function hostCall(method, args, observation) {
|
|
|
211
236
|
pending.set(callId, { resolve, reject });
|
|
212
237
|
parentPort.postMessage({ type: "call", callId, method, args });
|
|
213
238
|
});
|
|
214
|
-
return observation && typeof observation.key === "string"
|
|
215
|
-
? trackRunObservation([{ key: observation.key, callId }], promise)
|
|
239
|
+
return observation && typeof observation.key === "string" && typeof observation.operation === "string"
|
|
240
|
+
? trackRunObservation([{ key: observation.key, operation: observation.operation, callId }], promise)
|
|
216
241
|
: promise;
|
|
217
242
|
}
|
|
218
243
|
|
|
@@ -225,6 +250,33 @@ function runHostCall(key, params, collectFailure, batch) {
|
|
|
225
250
|
return { key, callId, promise };
|
|
226
251
|
}
|
|
227
252
|
|
|
253
|
+
function isArrayIndexProperty(prop) {
|
|
254
|
+
if (!/^(0|[1-9]\d*)$/.test(prop)) return false;
|
|
255
|
+
const index = Number(prop);
|
|
256
|
+
return Number.isSafeInteger(index) && index >= 0 && index < 4294967295;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
const runsAllResultTargets = new WeakMap();
|
|
260
|
+
|
|
261
|
+
function runsAllKeyAccessError(prop) {
|
|
262
|
+
return new Error("Cannot read runs.all result property '" + prop + "'. runs.all resolves to an ordered array, not a key map. Use results[0], array destructuring, or results.map((result) => result.output), not results." + prop + ".");
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
function wrapRunsAllResults(results, keys) {
|
|
266
|
+
const keySet = new Set(keys);
|
|
267
|
+
const proxy = new Proxy(results, {
|
|
268
|
+
get(target, prop, receiver) {
|
|
269
|
+
if (typeof prop !== "string") return Reflect.get(target, prop, receiver);
|
|
270
|
+
if (prop === "then" || prop === "toJSON") return undefined;
|
|
271
|
+
if (prop in target || isArrayIndexProperty(prop)) return Reflect.get(target, prop, receiver);
|
|
272
|
+
if (keySet.has(prop)) throw runsAllKeyAccessError(prop);
|
|
273
|
+
throw runsAllKeyAccessError(prop);
|
|
274
|
+
},
|
|
275
|
+
});
|
|
276
|
+
runsAllResultTargets.set(proxy, results);
|
|
277
|
+
return proxy;
|
|
278
|
+
}
|
|
279
|
+
|
|
228
280
|
function formatRef(result) {
|
|
229
281
|
if (!result || typeof result !== "object") throw new Error("runs.ref(result) requires a run result object.");
|
|
230
282
|
const parts = ["run " + (result.key || "unknown")];
|
|
@@ -232,7 +284,42 @@ function formatRef(result) {
|
|
|
232
284
|
return "[" + parts.join("; ") + "]";
|
|
233
285
|
}
|
|
234
286
|
|
|
235
|
-
|
|
287
|
+
function formatChildResultString(result) {
|
|
288
|
+
const output = typeof result?.output === "string" ? result.output.trim() : "";
|
|
289
|
+
return output || formatRef(result);
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
function decorateWorkflowChildResult(result) {
|
|
293
|
+
if (!result || typeof result !== "object" || Array.isArray(result)) return result;
|
|
294
|
+
Object.defineProperties(result, {
|
|
295
|
+
toString: { value() { return formatChildResultString(this); }, enumerable: false, configurable: true },
|
|
296
|
+
});
|
|
297
|
+
return result;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
let runFingerprints = new Map();
|
|
301
|
+
|
|
302
|
+
function validateExtensionBindings(value, label) {
|
|
303
|
+
if (value === undefined) return;
|
|
304
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) throw new Error(label + " extensionBindings must be a plain JSON object.");
|
|
305
|
+
const keys = Object.keys(value);
|
|
306
|
+
if (keys.length > 16) throw new Error(label + " extensionBindings supports at most 16 namespaces.");
|
|
307
|
+
for (const key of keys) if (!/^[A-Za-z0-9](?:[A-Za-z0-9._-]{0,62})\/[1-9][0-9]{0,8}$/.test(key)) throw new Error(label + " extensionBindings namespace '" + key + "' must use a package-like name followed by '/<positive-version>'.");
|
|
308
|
+
assertJsonValue(value, label + " extensionBindings");
|
|
309
|
+
let propertyCount = 0;
|
|
310
|
+
function visit(entry, depth) {
|
|
311
|
+
if (!entry || typeof entry !== "object") return;
|
|
312
|
+
if (depth > 16) throw new Error(label + " extensionBindings exceeds the maximum nesting depth of 16.");
|
|
313
|
+
if (Array.isArray(entry)) { for (const item of entry) visit(item, depth + 1); return; }
|
|
314
|
+
for (const child of Object.values(entry)) {
|
|
315
|
+
propertyCount++;
|
|
316
|
+
if (propertyCount > 256) throw new Error(label + " extensionBindings exceeds 256 total properties.");
|
|
317
|
+
visit(child, depth + 1);
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
visit(value, 0);
|
|
321
|
+
if (new TextEncoder().encode(stableRunJson(value)).byteLength > 16384) throw new Error(label + " extensionBindings canonical JSON exceeds 16384 bytes.");
|
|
322
|
+
}
|
|
236
323
|
|
|
237
324
|
function validateRunCall(key, params, label, fingerprints) {
|
|
238
325
|
if (typeof key !== "string" || !runKeyPattern.test(key)) throw new Error(label + " has an invalid key.");
|
|
@@ -241,13 +328,25 @@ function validateRunCall(key, params, label, fingerprints) {
|
|
|
241
328
|
const hint = label === "runs.run" ? "; use runs.all(...) and JavaScript control flow for orchestration." : ".";
|
|
242
329
|
throw new Error(label + " accepts one child via { agent, task } and execution controls only" + hint);
|
|
243
330
|
}
|
|
331
|
+
if (Object.prototype.hasOwnProperty.call(params, "clarify")) throw new Error(label + " does not support clarify UI.");
|
|
244
332
|
if (params.worktree !== undefined && typeof params.worktree !== "boolean") throw new Error(label + " worktree must be true or false.");
|
|
245
333
|
if (params.gate !== undefined && (typeof params.gate !== "string" || !params.gate.trim())) throw new Error(label + " gate must be a non-empty command string.");
|
|
246
334
|
if (params.gate !== undefined && params.acceptance !== undefined) throw new Error(label + " gate cannot be combined with acceptance; use one gate command or acceptance.verify.");
|
|
247
335
|
if (params.gate !== undefined && params.resume !== undefined) throw new Error(label + " gate is not supported with retained resume.");
|
|
248
|
-
if (params.
|
|
336
|
+
if (params.extensionBindings !== undefined && params.resume !== undefined) throw new Error(label + " extensionBindings is not supported with retained resume; resume uses the original retained child binding.");
|
|
337
|
+
if (params.resume !== undefined && typeof params.resume !== "string") {
|
|
338
|
+
const reference = params.resume;
|
|
339
|
+
if (!reference || typeof reference !== "object" || Array.isArray(reference)) throw new Error(label + " resume must be a retained run id or keyed workflow receipt reference.");
|
|
340
|
+
const fields = Object.keys(reference);
|
|
341
|
+
if (fields.some((field) => field !== "workflowRunId" && field !== "key" && field !== "latest")) throw new Error(label + " keyed resume contains unsupported fields.");
|
|
342
|
+
if (typeof reference.workflowRunId !== "string" || !reference.workflowRunId.trim()) throw new Error(label + " keyed resume workflowRunId must be non-empty.");
|
|
343
|
+
if (typeof reference.key !== "string" || !runKeyPattern.test(reference.key)) throw new Error(label + " keyed resume key is invalid.");
|
|
344
|
+
if (reference.latest !== true) throw new Error(label + " keyed resume requires latest: true.");
|
|
345
|
+
}
|
|
346
|
+
if (typeof params.resume === "string" && !params.resume.trim()) throw new Error(label + " resume must be a non-empty retained run id.");
|
|
249
347
|
if (params.resume !== undefined && params.agent !== undefined) throw new Error(label + " resume and agent are mutually exclusive.");
|
|
250
348
|
if (params.resume !== undefined && (typeof params.task !== "string" || !params.task.trim())) throw new Error(label + " resume requires a non-empty task follow-up.");
|
|
349
|
+
validateExtensionBindings(params.extensionBindings, label);
|
|
251
350
|
assertJsonValue(params, label + " params");
|
|
252
351
|
const fingerprint = stableRunJson(params);
|
|
253
352
|
const existing = fingerprints.get(key);
|
|
@@ -258,7 +357,8 @@ function validateRunCall(key, params, label, fingerprints) {
|
|
|
258
357
|
const runs = Object.freeze({
|
|
259
358
|
run(key, params) {
|
|
260
359
|
validateRunCall(key, params, "runs.run", runFingerprints);
|
|
261
|
-
|
|
360
|
+
const launched = runHostCall(key, params, false);
|
|
361
|
+
return trackRunObservation([{ key, operation: "run", callId: launched.callId }], launched.promise.then(decorateWorkflowChildResult));
|
|
262
362
|
},
|
|
263
363
|
all(items) {
|
|
264
364
|
if (!Array.isArray(items)) throw new Error("runs.all(items) requires an array.");
|
|
@@ -272,10 +372,21 @@ const runs = Object.freeze({
|
|
|
272
372
|
validateRunCall(key, params, "runs.all item " + index, fingerprints);
|
|
273
373
|
calls.push({ key, params });
|
|
274
374
|
}
|
|
275
|
-
|
|
375
|
+
runFingerprints = fingerprints;
|
|
276
376
|
const batch = { id: "batch-" + (++nextCallId), calls };
|
|
277
377
|
const launched = calls.map(({ key, params }) => runHostCall(key, params, true, batch));
|
|
278
|
-
return trackRunObservation(launched.map(({ key, callId }) => ({ key, callId })), Promise.all(launched.map(({ promise }) => promise)));
|
|
378
|
+
return trackRunObservation(launched.map(({ key, callId }) => ({ key, operation: "run", callId })), Promise.all(launched.map(({ promise }) => promise)).then((results) => wrapRunsAllResults(results.map(decorateWorkflowChildResult), calls.map(({ key }) => key))));
|
|
379
|
+
},
|
|
380
|
+
steer(key, message, options = {}) {
|
|
381
|
+
if (typeof key !== "string" || !runKeyPattern.test(key)) throw new Error("runs.steer has an invalid key.");
|
|
382
|
+
if (typeof message !== "string" || !message.trim()) throw new Error("runs.steer message must be a non-empty string.");
|
|
383
|
+
if (!options || typeof options !== "object" || Array.isArray(options)) throw new Error("runs.steer options must be an object.");
|
|
384
|
+
const allowed = new Set(["mode", "index", "ackTimeoutMs"]);
|
|
385
|
+
for (const option of Object.keys(options)) if (!allowed.has(option)) throw new Error("runs.steer options contain unsupported field '" + option + "'.");
|
|
386
|
+
if (options.mode !== undefined && options.mode !== "steer" && options.mode !== "follow_up" && options.mode !== "auto") throw new Error("runs.steer mode must be 'steer', 'follow_up', or 'auto'.");
|
|
387
|
+
if (options.index !== undefined && (!Number.isInteger(options.index) || options.index < 0 || options.index > 1000000)) throw new Error("runs.steer index must be an integer between 0 and 1000000.");
|
|
388
|
+
if (options.ackTimeoutMs !== undefined && (!Number.isInteger(options.ackTimeoutMs) || options.ackTimeoutMs < 1)) throw new Error("runs.steer ackTimeoutMs must be a positive integer.");
|
|
389
|
+
return hostCall("steer", { key, message: message.trim(), options }, { key, operation: "steer" });
|
|
279
390
|
},
|
|
280
391
|
status(keyOrRunId) { return hostCall("status", { keyOrRunId }); },
|
|
281
392
|
ref: formatRef,
|
|
@@ -299,14 +410,6 @@ const state = Object.freeze({
|
|
|
299
410
|
},
|
|
300
411
|
});
|
|
301
412
|
|
|
302
|
-
const prompts = Object.freeze({
|
|
303
|
-
render(ref, vars) {
|
|
304
|
-
if (typeof ref !== "string" || !ref.trim()) throw new Error("prompts.render(ref, vars) requires a non-empty ref string.");
|
|
305
|
-
if (vars !== undefined) assertJsonValue(vars, "prompts.render vars");
|
|
306
|
-
return hostCall("prompts.render", { ref, vars });
|
|
307
|
-
},
|
|
308
|
-
});
|
|
309
|
-
|
|
310
413
|
let contextObjectPrototype;
|
|
311
414
|
|
|
312
415
|
const capturedConsole = Object.freeze(Object.fromEntries(
|
|
@@ -316,7 +419,7 @@ const capturedConsole = Object.freeze(Object.fromEntries(
|
|
|
316
419
|
));
|
|
317
420
|
|
|
318
421
|
function formatWorkflowScriptSyntaxError(error) {
|
|
319
|
-
const details =
|
|
422
|
+
const details = formatWorkflowScriptError(error);
|
|
320
423
|
return [
|
|
321
424
|
"workflowScript must be valid JavaScript.",
|
|
322
425
|
"If task text contains Markdown fences or backticks, use an array joined with \"\\n\" or escaped strings instead of a raw backtick template literal.",
|
|
@@ -326,6 +429,52 @@ function formatWorkflowScriptSyntaxError(error) {
|
|
|
326
429
|
].join("\n");
|
|
327
430
|
}
|
|
328
431
|
|
|
432
|
+
function formatWorkflowScriptError(error) {
|
|
433
|
+
const message = error && typeof error.message === "string" ? error.message : String(error);
|
|
434
|
+
const stack = error && typeof error.stack === "string" ? error.stack : "";
|
|
435
|
+
if (!stack) return message;
|
|
436
|
+
return stack.includes(message) ? stack : message + "\n" + stack;
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
function isSyntaxError(error) {
|
|
440
|
+
return error instanceof SyntaxError || error?.name === "SyntaxError";
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
const NESTED_ASYNC_WORKFLOW_ERROR = "workflowScript does not support nested async functions. Use top-level await, plain helper functions that return runs.run(...), or explicit Promise chains so workflows stay portable across Node and Bun.";
|
|
444
|
+
const AST_SCALAR_KEYS = new Set(["type", "start", "end"]);
|
|
445
|
+
|
|
446
|
+
function assertPortableWorkflowScript(source) {
|
|
447
|
+
const wrapped = "(async () => {\n" + source + "\n})()";
|
|
448
|
+
const ast = parse(wrapped, { ecmaVersion: "latest", sourceType: "script" });
|
|
449
|
+
const wrapper = workflowWrapperFunction(ast);
|
|
450
|
+
walkWorkflowAst(wrapper.body, wrapper);
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
function workflowWrapperFunction(ast) {
|
|
454
|
+
const wrapper = ast.body?.[0]?.expression?.callee;
|
|
455
|
+
if (!wrapper || wrapper.type !== "ArrowFunctionExpression") throw new Error("workflowScript wrapper parse invariant failed.");
|
|
456
|
+
return wrapper;
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
function isAsyncFunctionNode(node) {
|
|
460
|
+
return node.async === true && (node.type === "FunctionDeclaration" || node.type === "FunctionExpression" || node.type === "ArrowFunctionExpression");
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
function walkWorkflowAst(node, allowedAsyncFunction) {
|
|
464
|
+
if (!node || typeof node !== "object") return;
|
|
465
|
+
if (Array.isArray(node)) {
|
|
466
|
+
for (const item of node) walkWorkflowAst(item, allowedAsyncFunction);
|
|
467
|
+
return;
|
|
468
|
+
}
|
|
469
|
+
if (node !== allowedAsyncFunction && isAsyncFunctionNode(node)) {
|
|
470
|
+
throw new Error(NESTED_ASYNC_WORKFLOW_ERROR);
|
|
471
|
+
}
|
|
472
|
+
for (const [key, child] of Object.entries(node)) {
|
|
473
|
+
if (AST_SCALAR_KEYS.has(key)) continue;
|
|
474
|
+
walkWorkflowAst(child, allowedAsyncFunction);
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
|
|
329
478
|
function assertJsonValue(value, path = "emit", seen = new Set()) {
|
|
330
479
|
if (value === null || typeof value === "string" || typeof value === "boolean") return;
|
|
331
480
|
if (typeof value === "number") {
|
|
@@ -355,6 +504,31 @@ function isPlainWorkflowObject(value) {
|
|
|
355
504
|
return prototype === null || prototype === Object.prototype || prototype === contextObjectPrototype;
|
|
356
505
|
}
|
|
357
506
|
|
|
507
|
+
function unwrapRunsAllResults(value, seen = new Map()) {
|
|
508
|
+
if (value === null || typeof value !== "object") return value;
|
|
509
|
+
const runsAllTarget = runsAllResultTargets.get(value);
|
|
510
|
+
const target = runsAllTarget || value;
|
|
511
|
+
if (seen.has(target)) return seen.get(target);
|
|
512
|
+
if (Array.isArray(target)) {
|
|
513
|
+
const copy = [];
|
|
514
|
+
seen.set(target, copy);
|
|
515
|
+
let changed = !!runsAllTarget;
|
|
516
|
+
for (let index = 0; index < target.length; index++) {
|
|
517
|
+
copy[index] = unwrapRunsAllResults(target[index], seen);
|
|
518
|
+
changed ||= copy[index] !== target[index];
|
|
519
|
+
}
|
|
520
|
+
return changed ? copy : target;
|
|
521
|
+
}
|
|
522
|
+
if (!isPlainWorkflowObject(target) || Object.getOwnPropertySymbols(target).length > 0) return target;
|
|
523
|
+
let changed = false;
|
|
524
|
+
const entries = Object.entries(target).map(([key, entry]) => {
|
|
525
|
+
const unwrapped = unwrapRunsAllResults(entry, seen);
|
|
526
|
+
changed ||= unwrapped !== entry;
|
|
527
|
+
return [key, unwrapped];
|
|
528
|
+
});
|
|
529
|
+
return changed ? Object.fromEntries(entries) : target;
|
|
530
|
+
}
|
|
531
|
+
|
|
358
532
|
function omitUndefinedWorkflowValues(value, seen = new Set()) {
|
|
359
533
|
if (value === null || typeof value !== "object") return value;
|
|
360
534
|
if (seen.has(value)) return value;
|
|
@@ -383,16 +557,16 @@ parentPort.on("message", async (message) => {
|
|
|
383
557
|
}
|
|
384
558
|
if (message.type !== "start") return;
|
|
385
559
|
try {
|
|
386
|
-
const sandbox = { runs,
|
|
560
|
+
const sandbox = { runs, Promise: workflowPromise, emit(value) { const emittedValue = unwrapRunsAllResults(value); assertJsonValue(emittedValue); parentPort.postMessage({ type: "emit", value: emittedValue }); }, console: capturedConsole };
|
|
387
561
|
if (message.stateEnabled) sandbox.state = state;
|
|
388
562
|
const context = vm.createContext(sandbox, { codeGeneration: { strings: false, wasm: false } });
|
|
389
563
|
contextObjectPrototype = vm.runInContext("Object.prototype", context);
|
|
390
564
|
let compiled;
|
|
391
565
|
try {
|
|
566
|
+
assertPortableWorkflowScript(message.script);
|
|
392
567
|
compiled = new vm.Script("(async () => {\n" + message.script + "\n})()", { filename: "workflow-script.js" });
|
|
393
568
|
} catch (error) {
|
|
394
|
-
|
|
395
|
-
parentPort.postMessage({ type: "error", error: formatWorkflowScriptSyntaxError(error) });
|
|
569
|
+
parentPort.postMessage({ type: "error", error: isSyntaxError(error) ? formatWorkflowScriptSyntaxError(error) : formatWorkflowScriptError(error) });
|
|
396
570
|
return;
|
|
397
571
|
}
|
|
398
572
|
const nativePromisePrototype = vm.runInContext("(async () => {})().constructor.prototype", context);
|
|
@@ -411,7 +585,7 @@ parentPort.on("message", async (message) => {
|
|
|
411
585
|
return Reflect.apply(nativeThen, this, args);
|
|
412
586
|
},
|
|
413
587
|
});
|
|
414
|
-
stopWorkflowPromiseHook =
|
|
588
|
+
stopWorkflowPromiseHook = createWorkflowPromiseHook({
|
|
415
589
|
before(promise) {
|
|
416
590
|
activeNativePromises.push(promise);
|
|
417
591
|
},
|
|
@@ -456,7 +630,7 @@ parentPort.on("message", async (message) => {
|
|
|
456
630
|
assertJsonValue(persistedValue, "return");
|
|
457
631
|
parentPort.postMessage({ type: "complete", value: persistedValue });
|
|
458
632
|
} catch (error) {
|
|
459
|
-
parentPort.postMessage({ type: "error", error: error
|
|
633
|
+
parentPort.postMessage({ type: "error", error: isSyntaxError(error) ? formatWorkflowScriptSyntaxError(error) : formatWorkflowScriptError(error), ...(error && error.workflowErrorKind === "detached-child" ? { errorKind: "detached-child" } : {}) });
|
|
460
634
|
}
|
|
461
635
|
});
|
|
462
636
|
`;
|
|
@@ -464,21 +638,28 @@ parentPort.on("message", async (message) => {
|
|
|
464
638
|
export interface WorkflowScriptChildResult {
|
|
465
639
|
key: string;
|
|
466
640
|
ok: boolean;
|
|
641
|
+
stopped?: boolean;
|
|
467
642
|
/** Canonical child agent name when launch resolution produced one. */
|
|
468
643
|
agent?: string;
|
|
469
644
|
runId?: string;
|
|
470
645
|
output: string;
|
|
471
646
|
error?: string;
|
|
472
647
|
detached?: boolean;
|
|
648
|
+
interrupted?: boolean;
|
|
473
649
|
structuredOutput?: unknown;
|
|
650
|
+
requestedContext?: "fresh" | "fork";
|
|
651
|
+
resolvedContext?: "fresh" | "fork" | "mixed";
|
|
652
|
+
outputReference?: string;
|
|
653
|
+
resumability?: { state: "resumable" } | { state: "not-resumable"; reason: string };
|
|
654
|
+
continuation?: { runIds: string[] };
|
|
474
655
|
artifactPaths: string[];
|
|
475
656
|
results?: unknown[];
|
|
476
657
|
}
|
|
477
658
|
|
|
478
659
|
export interface WorkflowScriptTraceEntry {
|
|
479
|
-
operation: "run" | "status";
|
|
660
|
+
operation: "run" | "status" | "steer";
|
|
480
661
|
key: string;
|
|
481
|
-
state: "started" | "completed" | "failed" | "detached" | "stopped" | "reused";
|
|
662
|
+
state: "started" | "completed" | "failed" | "detached" | "stopped" | "reused" | "queued" | "delivered" | "missed";
|
|
482
663
|
/** Canonical child agent name when resolved launch or result data is available. */
|
|
483
664
|
agent?: string;
|
|
484
665
|
runId?: string;
|
|
@@ -488,6 +669,32 @@ export interface WorkflowScriptTraceEntry {
|
|
|
488
669
|
error?: string;
|
|
489
670
|
}
|
|
490
671
|
|
|
672
|
+
export interface WorkflowSteerOptions {
|
|
673
|
+
mode?: "steer" | "follow_up" | "auto";
|
|
674
|
+
index?: number;
|
|
675
|
+
ackTimeoutMs?: number;
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
export interface WorkflowSteerResult {
|
|
679
|
+
key: string;
|
|
680
|
+
state: "queued" | "delivered" | "missed" | "failed";
|
|
681
|
+
requestId?: string;
|
|
682
|
+
deliveryStatus?: "queued" | "delivered";
|
|
683
|
+
targets?: Array<{ index: number; state: string; reason?: string }>;
|
|
684
|
+
error?: string;
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
export interface WorkflowReceiptResumeReference {
|
|
688
|
+
workflowRunId: string;
|
|
689
|
+
key: string;
|
|
690
|
+
latest: true;
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
export interface WorkflowResolvedResumeReference {
|
|
694
|
+
runId: string;
|
|
695
|
+
runIds?: string[];
|
|
696
|
+
}
|
|
697
|
+
|
|
491
698
|
export interface WorkflowScriptResult {
|
|
492
699
|
value: unknown;
|
|
493
700
|
emits: unknown[];
|
|
@@ -514,18 +721,34 @@ export interface RunWorkflowScriptOptions {
|
|
|
514
721
|
signal?: AbortSignal;
|
|
515
722
|
admit?: (calls: Array<{ key: string; params: Record<string, unknown> }>) => void | Promise<void>;
|
|
516
723
|
launch: (key: string, params: Record<string, unknown>, signal: AbortSignal, admission: { admitted: boolean }) => Promise<WorkflowScriptChildResult>;
|
|
724
|
+
resolveResume?: (reference: WorkflowReceiptResumeReference, signal: AbortSignal) => string | WorkflowResolvedResumeReference | Promise<string | WorkflowResolvedResumeReference>;
|
|
517
725
|
status: (keyOrRunId: string, signal: AbortSignal) => Promise<WorkflowScriptChildResult>;
|
|
726
|
+
steer?: (key: string, message: string, options: WorkflowSteerOptions, signal: AbortSignal) => Promise<WorkflowSteerResult>;
|
|
518
727
|
state?: {
|
|
519
728
|
get: (key: string) => unknown | Promise<unknown>;
|
|
520
729
|
set: (key: string, value: unknown) => void | Promise<void>;
|
|
521
730
|
};
|
|
522
|
-
|
|
523
|
-
render: (ref: string, vars?: unknown) => string | Promise<string>;
|
|
524
|
-
};
|
|
731
|
+
registerStopChild?: (stop: ((key: string, message?: string) => boolean) | undefined) => void;
|
|
525
732
|
onTrace?: (trace: WorkflowScriptTraceEntry[]) => void;
|
|
526
733
|
onEmit?: (emits: unknown[]) => void;
|
|
527
734
|
}
|
|
528
735
|
|
|
736
|
+
function combinedAbortSignal(signals: AbortSignal[]): AbortSignal {
|
|
737
|
+
const controller = new AbortController();
|
|
738
|
+
const abort = (signal: AbortSignal): void => {
|
|
739
|
+
if (controller.signal.aborted) return;
|
|
740
|
+
controller.abort(signal.reason);
|
|
741
|
+
};
|
|
742
|
+
for (const signal of signals) {
|
|
743
|
+
if (signal.aborted) {
|
|
744
|
+
abort(signal);
|
|
745
|
+
break;
|
|
746
|
+
}
|
|
747
|
+
signal.addEventListener("abort", () => abort(signal), { once: true });
|
|
748
|
+
}
|
|
749
|
+
return controller.signal;
|
|
750
|
+
}
|
|
751
|
+
|
|
529
752
|
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
530
753
|
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
531
754
|
}
|
|
@@ -536,6 +759,16 @@ function isPlainJsonObject(value: unknown): value is Record<string, unknown> {
|
|
|
536
759
|
return prototype === null || prototype === Object.prototype;
|
|
537
760
|
}
|
|
538
761
|
|
|
762
|
+
function parseWorkflowResumeReference(value: unknown): WorkflowReceiptResumeReference | undefined {
|
|
763
|
+
if (!isRecord(value)) return undefined;
|
|
764
|
+
const fields = Object.keys(value);
|
|
765
|
+
if (fields.some((field) => field !== "workflowRunId" && field !== "key" && field !== "latest")) throw new Error("keyed resume contains unsupported fields.");
|
|
766
|
+
if (typeof value.workflowRunId !== "string" || !value.workflowRunId.trim()) throw new Error("keyed resume workflowRunId must be non-empty.");
|
|
767
|
+
const key = validateKey(value.key, "keyed resume");
|
|
768
|
+
if (value.latest !== true) throw new Error("keyed resume requires latest: true.");
|
|
769
|
+
return { workflowRunId: value.workflowRunId.trim(), key, latest: true };
|
|
770
|
+
}
|
|
771
|
+
|
|
539
772
|
function omitUndefinedWorkflowValues(value: unknown, seen = new Set<object>()): unknown {
|
|
540
773
|
if (value === null || typeof value !== "object") return value;
|
|
541
774
|
if (seen.has(value)) return value;
|
|
@@ -549,6 +782,18 @@ function omitUndefinedWorkflowValues(value: unknown, seen = new Set<object>()):
|
|
|
549
782
|
return normalized;
|
|
550
783
|
}
|
|
551
784
|
|
|
785
|
+
function omitNonJsonWorkflowResultMetadata(value: unknown): unknown {
|
|
786
|
+
const normalized = omitUndefinedWorkflowValues(value);
|
|
787
|
+
if (!isPlainJsonObject(normalized) || !Object.hasOwn(normalized, "results")) return normalized;
|
|
788
|
+
try {
|
|
789
|
+
assertWorkflowJsonValue(normalized.results, "runs.run result.results");
|
|
790
|
+
return normalized;
|
|
791
|
+
} catch {
|
|
792
|
+
const { results: _results, ...safeResult } = normalized;
|
|
793
|
+
return safeResult;
|
|
794
|
+
}
|
|
795
|
+
}
|
|
796
|
+
|
|
552
797
|
export function assertWorkflowJsonValue(value: unknown, path = "value", seen = new Set<object>()): void {
|
|
553
798
|
if (value === null || typeof value === "string" || typeof value === "boolean") return;
|
|
554
799
|
if (typeof value === "number") {
|
|
@@ -629,44 +874,114 @@ function workflowStringMetadata(params: Record<string, unknown>): Pick<WorkflowS
|
|
|
629
874
|
};
|
|
630
875
|
}
|
|
631
876
|
|
|
877
|
+
function resolveWorkflowParserEntry(): string {
|
|
878
|
+
try {
|
|
879
|
+
return requireFromPackage.resolve("acorn");
|
|
880
|
+
} catch (primaryError) {
|
|
881
|
+
// Some runtimes (e.g. Bun-compiled single-file binaries) fail bare
|
|
882
|
+
// package-specifier resolution through createRequire while subpath
|
|
883
|
+
// resolution still works. Resolve the manifest and derive the
|
|
884
|
+
// CommonJS entry from its "main" field instead.
|
|
885
|
+
try {
|
|
886
|
+
const manifestPath = requireFromPackage.resolve("acorn/package.json");
|
|
887
|
+
const manifest = JSON.parse(readFileSync(manifestPath, "utf8")) as { main?: unknown };
|
|
888
|
+
const entry = typeof manifest.main === "string" && manifest.main ? manifest.main : "./dist/acorn.js";
|
|
889
|
+
return resolvePath(dirname(manifestPath), entry);
|
|
890
|
+
} catch {
|
|
891
|
+
throw primaryError;
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
}
|
|
895
|
+
|
|
632
896
|
export async function runWorkflowScript(options: RunWorkflowScriptOptions): Promise<WorkflowScriptResult> {
|
|
633
897
|
if (!options.script.trim()) throw new Error("workflowScript must not be empty.");
|
|
634
898
|
if (options.timeoutMs !== undefined && (!Number.isInteger(options.timeoutMs) || options.timeoutMs < 1)) throw new Error("workflow script timeout must be a positive integer.");
|
|
635
899
|
|
|
636
|
-
|
|
900
|
+
let acornPath: string;
|
|
901
|
+
try {
|
|
902
|
+
acornPath = resolveWorkflowParserEntry();
|
|
903
|
+
} catch (error) {
|
|
904
|
+
throw new Error("Workflow parser dependency 'acorn' is unavailable from pi-subagents. Reinstall pi-subagents dependencies before launching workflowScript.", { cause: error });
|
|
905
|
+
}
|
|
906
|
+
const worker = new Worker(WORKER_SOURCE, { eval: true, workerData: { acornPath } });
|
|
637
907
|
const emits: unknown[] = [];
|
|
638
908
|
const consoleEntries: WorkflowScriptResult["console"] = [];
|
|
639
909
|
const trace: WorkflowScriptTraceEntry[] = [];
|
|
640
910
|
const children = new Map<string, WorkflowScriptChildResult>();
|
|
641
911
|
const childOrder: string[] = [];
|
|
642
912
|
const launches = new Map<string, { fingerprint: string; promise: Promise<WorkflowScriptChildResult>; observed: boolean }>();
|
|
913
|
+
const steers = new Map<number, { key: string; promise: Promise<WorkflowSteerResult>; observed: boolean }>();
|
|
643
914
|
const stoppedLaunches = new Set<string>();
|
|
915
|
+
const childStopControllers = new Map<string, AbortController>();
|
|
644
916
|
const batchAdmissions = new Map<string, Promise<void>>();
|
|
645
917
|
const observedRunCalls = new Set<number>();
|
|
918
|
+
const observedSteerCalls = new Set<number>();
|
|
646
919
|
const childController = new AbortController();
|
|
647
920
|
let settled = false;
|
|
921
|
+
let finishing = false;
|
|
648
922
|
|
|
649
923
|
const partial = (): Omit<WorkflowScriptResult, "value"> => ({ emits, console: consoleEntries, trace, children: childOrder.flatMap((key) => {
|
|
650
924
|
const child = children.get(key);
|
|
651
925
|
return child ? [child] : [];
|
|
652
926
|
}) });
|
|
653
|
-
|
|
927
|
+
// Hosts use onTrace to persist a progress journal, and it is invoked from inside
|
|
928
|
+
// the run-promise handlers below. A throw here would reject the child promise the
|
|
929
|
+
// script is awaiting, so a single failed status write could mark a completed child
|
|
930
|
+
// failed and abort its siblings through Promise.all. Telemetry must not decide
|
|
931
|
+
// workflow outcomes, so a failing callback is reported and the run continues.
|
|
932
|
+
const traceChanged = () => {
|
|
933
|
+
try {
|
|
934
|
+
options.onTrace?.([...trace]);
|
|
935
|
+
} catch (error) {
|
|
936
|
+
console.error("Workflow onTrace callback failed:", error);
|
|
937
|
+
}
|
|
938
|
+
};
|
|
939
|
+
const stoppedChildResult = (key: string, message: string): WorkflowScriptChildResult => ({ key, ok: false, stopped: true, output: message, error: message, artifactPaths: [] });
|
|
940
|
+
const stopChild = (key: string, message = `Workflow child '${key}' stopped by user.`): boolean => {
|
|
941
|
+
if (!launches.has(key) || children.has(key)) return false;
|
|
942
|
+
stoppedLaunches.add(key);
|
|
943
|
+
children.set(key, stoppedChildResult(key, message));
|
|
944
|
+
childStopControllers.get(key)?.abort(new Error(message));
|
|
945
|
+
const started = trace.findLast((entry) => entry.operation === "run" && entry.key === key && entry.state === "started");
|
|
946
|
+
trace.push({
|
|
947
|
+
operation: "run",
|
|
948
|
+
key,
|
|
949
|
+
state: "stopped",
|
|
950
|
+
...(started?.agent ? { agent: started.agent } : {}),
|
|
951
|
+
...(started?.phase ? { phase: started.phase } : {}),
|
|
952
|
+
...(started?.label ? { label: started.label } : {}),
|
|
953
|
+
error: message,
|
|
954
|
+
});
|
|
955
|
+
traceChanged();
|
|
956
|
+
return true;
|
|
957
|
+
};
|
|
958
|
+
options.registerStopChild?.(stopChild);
|
|
654
959
|
|
|
655
960
|
return await new Promise<WorkflowScriptResult>((resolve, reject) => {
|
|
656
961
|
const finish = (outcome: { value: unknown } | { error: Error & { workflowErrorKind?: unknown } }) => {
|
|
657
|
-
if (settled) return;
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
962
|
+
if (settled || finishing) return;
|
|
963
|
+
finishing = true;
|
|
964
|
+
childController.abort("error" in outcome ? outcome.error : new Error("Workflow script completed."));
|
|
965
|
+
void Promise.allSettled([...steers.values()].map(({ promise }) => promise)).then(() => {
|
|
966
|
+
if (settled) return;
|
|
967
|
+
settled = true;
|
|
968
|
+
options.registerStopChild?.(undefined);
|
|
969
|
+
if (timer) clearTimeout(timer);
|
|
970
|
+
options.signal?.removeEventListener("abort", onAbort);
|
|
971
|
+
void worker.terminate();
|
|
972
|
+
const unobservedKeys = "value" in outcome ? [...launches].filter(([, launch]) => !launch.observed).map(([key]) => key) : [];
|
|
973
|
+
const completionError = unobservedKeys.length > 0
|
|
974
|
+
? new Error(`workflowScript completed with unawaited runs.run launch(es): ${unobservedKeys.map((key) => `'${key}'`).join(", ")}. For ordinary parallel fanout use await runs.all([{key, agent, task}, ...]); do not read .output from unawaited launches.`)
|
|
975
|
+
: "value" in outcome
|
|
976
|
+
? (() => {
|
|
977
|
+
const unobservedSteers = [...steers.values()].filter((steer) => !steer.observed).map((steer) => steer.key);
|
|
978
|
+
return unobservedSteers.length > 0 ? new Error(`workflowScript completed with unawaited runs.steer call(s): ${unobservedSteers.map((key) => `'${key}'`).join(", ")}. Await or return each call.`) : undefined;
|
|
979
|
+
})()
|
|
980
|
+
: undefined;
|
|
981
|
+
if ("error" in outcome) reject(new WorkflowScriptError(outcome.error.message, partial(), outcome.error.workflowErrorKind === "detached-child" ? "detached-child" : undefined));
|
|
982
|
+
else if (completionError) reject(new WorkflowScriptError(completionError.message, partial()));
|
|
983
|
+
else resolve({ value: outcome.value, ...partial() });
|
|
984
|
+
});
|
|
670
985
|
};
|
|
671
986
|
const onAbort = () => {
|
|
672
987
|
const signalReason = options.signal?.reason;
|
|
@@ -738,37 +1053,42 @@ export async function runWorkflowScript(options: RunWorkflowScriptOptions): Prom
|
|
|
738
1053
|
if (message.errorKind === "detached-child") workflowError.workflowErrorKind = "detached-child";
|
|
739
1054
|
return finish({ error: workflowError });
|
|
740
1055
|
}
|
|
741
|
-
if (message.type === "
|
|
1056
|
+
if (message.type === "callObserved" && typeof message.callId === "number") {
|
|
742
1057
|
const key = typeof message.key === "string" ? message.key : undefined;
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
1058
|
+
if (message.operation === "run") {
|
|
1059
|
+
const launch = key ? launches.get(key) : undefined;
|
|
1060
|
+
if (launch) launch.observed = true;
|
|
1061
|
+
else observedRunCalls.add(message.callId);
|
|
1062
|
+
} else if (message.operation === "steer") {
|
|
1063
|
+
const steer = steers.get(message.callId);
|
|
1064
|
+
if (steer) steer.observed = true;
|
|
1065
|
+
else observedSteerCalls.add(message.callId);
|
|
1066
|
+
}
|
|
746
1067
|
return;
|
|
747
1068
|
}
|
|
748
1069
|
if (message.type !== "call" || typeof message.callId !== "number" || typeof message.method !== "string" || !isRecord(message.args)) return;
|
|
749
1070
|
|
|
750
|
-
const respond = (promise: Promise<unknown
|
|
1071
|
+
const respond = (promise: Promise<unknown>, responsePath?: string) => {
|
|
751
1072
|
void promise.then(
|
|
752
1073
|
(value) => {
|
|
753
|
-
if (
|
|
1074
|
+
if (settled) return;
|
|
1075
|
+
const normalized = responsePath ? omitNonJsonWorkflowResultMetadata(value) : omitUndefinedWorkflowValues(value);
|
|
1076
|
+
if (!responsePath) {
|
|
1077
|
+
worker.postMessage({ type: "response", callId: message.callId, ok: true, value: normalized });
|
|
1078
|
+
return;
|
|
1079
|
+
}
|
|
1080
|
+
try {
|
|
1081
|
+
assertWorkflowJsonValue(normalized, responsePath);
|
|
1082
|
+
worker.postMessage({ type: "response", callId: message.callId, ok: true, value: normalized });
|
|
1083
|
+
} catch (error) {
|
|
1084
|
+
worker.postMessage({ type: "response", callId: message.callId, ok: false, error: `${responsePath} must contain only JSON data before it can be returned from workflowScript. Return a plain projection such as { runId, ok, output }. ${error instanceof Error ? error.message : String(error)}` });
|
|
1085
|
+
}
|
|
754
1086
|
},
|
|
755
1087
|
(error: unknown) => {
|
|
756
1088
|
if (!settled) worker.postMessage({ type: "response", callId: message.callId, ok: false, error: error instanceof Error ? error.message : String(error), ...(error instanceof Error && (error as { workflowErrorKind?: unknown }).workflowErrorKind === "detached-child" ? { errorKind: "detached-child" } : {}) });
|
|
757
1089
|
},
|
|
758
1090
|
);
|
|
759
1091
|
};
|
|
760
|
-
|
|
761
|
-
if (message.method === "prompts.render") {
|
|
762
|
-
if (!options.prompts) return respond(Promise.reject(new Error("Workflow prompt rendering is unavailable.")));
|
|
763
|
-
const ref = message.args.ref;
|
|
764
|
-
const vars = message.args.vars;
|
|
765
|
-
if (typeof ref !== "string" || !ref.trim()) return respond(Promise.reject(new Error("prompts.render(ref, vars) requires a non-empty ref string.")));
|
|
766
|
-
return respond(Promise.resolve().then(() => options.prompts!.render(ref, vars)).then((rendered) => {
|
|
767
|
-
if (typeof rendered !== "string") throw new Error("prompts.render must return task text.");
|
|
768
|
-
return rendered;
|
|
769
|
-
}));
|
|
770
|
-
}
|
|
771
|
-
|
|
772
1092
|
if (message.method === "state.get" || message.method === "state.set") {
|
|
773
1093
|
if (!options.state) return respond(Promise.reject(new Error("Workflow state is unavailable without a mission.")));
|
|
774
1094
|
let key: string;
|
|
@@ -794,9 +1114,9 @@ export async function runWorkflowScript(options: RunWorkflowScriptOptions): Prom
|
|
|
794
1114
|
const target = known?.runId ?? keyOrRunId;
|
|
795
1115
|
trace.push({ operation: "status", key: keyOrRunId, state: "started", ...(known?.runId ? { runId: known.runId } : {}) });
|
|
796
1116
|
traceChanged();
|
|
797
|
-
if (settled) return;
|
|
1117
|
+
if (settled || finishing) return;
|
|
798
1118
|
respond(options.status(target, childController.signal).then((result) => {
|
|
799
|
-
if (settled) return result;
|
|
1119
|
+
if (settled || finishing) return result;
|
|
800
1120
|
trace.push({ operation: "status", key: keyOrRunId, state: result.ok ? "completed" : "failed", ...(result.runId ? { runId: result.runId } : {}), ...(!result.ok ? { error: result.output } : {}) });
|
|
801
1121
|
traceChanged();
|
|
802
1122
|
if (!result.ok) throw new Error(`Status '${keyOrRunId}' failed: ${result.output}`);
|
|
@@ -804,6 +1124,37 @@ export async function runWorkflowScript(options: RunWorkflowScriptOptions): Prom
|
|
|
804
1124
|
}));
|
|
805
1125
|
return;
|
|
806
1126
|
}
|
|
1127
|
+
if (message.method === "steer") {
|
|
1128
|
+
let key: string;
|
|
1129
|
+
try {
|
|
1130
|
+
key = validateKey(message.args.key, "runs.steer");
|
|
1131
|
+
} catch (error) {
|
|
1132
|
+
return respond(Promise.reject(error));
|
|
1133
|
+
}
|
|
1134
|
+
const steerMessage = message.args.message;
|
|
1135
|
+
if (typeof steerMessage !== "string" || !steerMessage.trim()) return respond(Promise.reject(new Error(`runs.steer('${key}') requires a non-empty message.`)));
|
|
1136
|
+
const steerOptions = isRecord(message.args.options) ? message.args.options as WorkflowSteerOptions : {};
|
|
1137
|
+
const startedAt = Date.now();
|
|
1138
|
+
trace.push({ operation: "steer", key, state: "started" });
|
|
1139
|
+
traceChanged();
|
|
1140
|
+
const promise = Promise.resolve().then(() => {
|
|
1141
|
+
if (!launches.has(key)) throw new Error(`runs.steer('${key}') requires a prior runs.run/runs.all launch with that key.`);
|
|
1142
|
+
if (!options.steer) throw new Error("Workflow steering is unavailable in this host.");
|
|
1143
|
+
return options.steer(key, steerMessage.trim(), steerOptions, childController.signal);
|
|
1144
|
+
}).then((receipt) => {
|
|
1145
|
+
trace.push({ operation: "steer", key, state: receipt.state, durationMs: Date.now() - startedAt, ...(receipt.error ? { error: receipt.error } : {}) });
|
|
1146
|
+
traceChanged();
|
|
1147
|
+
return receipt;
|
|
1148
|
+
}, (error: unknown) => {
|
|
1149
|
+
const text = error instanceof Error ? error.message : String(error);
|
|
1150
|
+
trace.push({ operation: "steer", key, state: "failed", durationMs: Date.now() - startedAt, error: text });
|
|
1151
|
+
traceChanged();
|
|
1152
|
+
throw error;
|
|
1153
|
+
});
|
|
1154
|
+
steers.set(message.callId, { key, promise, observed: observedSteerCalls.delete(message.callId) });
|
|
1155
|
+
respond(promise);
|
|
1156
|
+
return;
|
|
1157
|
+
}
|
|
807
1158
|
if (message.method !== "run") return respond(Promise.reject(new Error(`Unknown runs API method '${message.method}'.`)));
|
|
808
1159
|
|
|
809
1160
|
let key: string;
|
|
@@ -831,9 +1182,13 @@ export async function runWorkflowScript(options: RunWorkflowScriptOptions): Prom
|
|
|
831
1182
|
if (params.gate !== undefined && params.resume !== undefined) {
|
|
832
1183
|
return respond(Promise.reject(new Error(`runs.run('${key}') gate is not supported with retained resume.`)));
|
|
833
1184
|
}
|
|
834
|
-
|
|
835
|
-
|
|
1185
|
+
let resumeReference: WorkflowReceiptResumeReference | undefined;
|
|
1186
|
+
try {
|
|
1187
|
+
if (params.resume !== undefined && typeof params.resume !== "string") resumeReference = parseWorkflowResumeReference(params.resume);
|
|
1188
|
+
} catch (error) {
|
|
1189
|
+
return respond(Promise.reject(new Error(`runs.run('${key}') ${error instanceof Error ? error.message : String(error)}`)));
|
|
836
1190
|
}
|
|
1191
|
+
if (typeof params.resume === "string" && !params.resume.trim()) return respond(Promise.reject(new Error(`runs.run('${key}') resume must be a non-empty retained run id.`)));
|
|
837
1192
|
if (params.resume !== undefined && params.agent !== undefined) {
|
|
838
1193
|
return respond(Promise.reject(new Error(`runs.run('${key}') resume and agent are mutually exclusive.`)));
|
|
839
1194
|
}
|
|
@@ -845,7 +1200,7 @@ export async function runWorkflowScript(options: RunWorkflowScriptOptions): Prom
|
|
|
845
1200
|
const deliver = (promise: Promise<WorkflowScriptChildResult>) => collectFailure
|
|
846
1201
|
? promise
|
|
847
1202
|
: promise.then((result) => {
|
|
848
|
-
if (!result.ok) {
|
|
1203
|
+
if (!result.ok && !result.stopped) {
|
|
849
1204
|
const childError = new Error(result.detached ? `Run '${key}' detached: ${result.error ?? result.output}` : `Run '${key}' failed: ${result.error ?? result.output}`) as Error & { workflowErrorKind?: "detached-child" };
|
|
850
1205
|
if (result.detached) childError.workflowErrorKind = "detached-child";
|
|
851
1206
|
throw childError;
|
|
@@ -859,7 +1214,7 @@ export async function runWorkflowScript(options: RunWorkflowScriptOptions): Prom
|
|
|
859
1214
|
if (callObserved) existing.observed = true;
|
|
860
1215
|
trace.push({ operation: "run", key, state: "reused", ...workflowStringMetadata(params) });
|
|
861
1216
|
traceChanged();
|
|
862
|
-
return respond(deliver(existing.promise));
|
|
1217
|
+
return respond(deliver(existing.promise), `runs.run('${key}') result`);
|
|
863
1218
|
}
|
|
864
1219
|
|
|
865
1220
|
const startedAt = Date.now();
|
|
@@ -870,35 +1225,65 @@ export async function runWorkflowScript(options: RunWorkflowScriptOptions): Prom
|
|
|
870
1225
|
if (!admission) {
|
|
871
1226
|
const seenKeys = new Set<string>();
|
|
872
1227
|
const calls = (batch?.calls ?? [{ key, params }]).filter((call) => {
|
|
873
|
-
if (seenKeys.has(call.key) || launches.has(call.key)
|
|
1228
|
+
if (seenKeys.has(call.key) || launches.has(call.key)) return false;
|
|
874
1229
|
seenKeys.add(call.key);
|
|
875
1230
|
return true;
|
|
876
1231
|
});
|
|
877
1232
|
admission = Promise.resolve().then(() => {
|
|
878
|
-
if (settled) return;
|
|
1233
|
+
if (settled || finishing) return;
|
|
879
1234
|
return options.admit?.(calls);
|
|
880
1235
|
});
|
|
881
1236
|
if (batch) batchAdmissions.set(batch.id, admission);
|
|
882
1237
|
}
|
|
883
|
-
|
|
884
|
-
|
|
1238
|
+
let resolvedResumeLineage: string[] | undefined;
|
|
1239
|
+
const promise = admission.then(async () => {
|
|
1240
|
+
if (settled || finishing || stoppedLaunches.has(key)) {
|
|
885
1241
|
const reason = childController.signal.reason;
|
|
886
|
-
const text = reason instanceof Error ? reason.message : typeof reason === "string" ? reason : "Workflow script aborted.";
|
|
887
|
-
return
|
|
1242
|
+
const text = children.get(key)?.error ?? (reason instanceof Error ? reason.message : typeof reason === "string" ? reason : "Workflow script aborted.");
|
|
1243
|
+
return stoppedChildResult(key, text);
|
|
1244
|
+
}
|
|
1245
|
+
const childStopController = new AbortController();
|
|
1246
|
+
childStopControllers.set(key, childStopController);
|
|
1247
|
+
const childSignal = combinedAbortSignal([childController.signal, childStopController.signal]);
|
|
1248
|
+
const resolvedResumeValue = resumeReference
|
|
1249
|
+
? await Promise.resolve().then(() => {
|
|
1250
|
+
if (!options.resolveResume) throw new Error("Keyed workflow receipt resume is unavailable in this host.");
|
|
1251
|
+
return options.resolveResume(resumeReference, childSignal);
|
|
1252
|
+
})
|
|
1253
|
+
: undefined;
|
|
1254
|
+
const resolvedResume = typeof resolvedResumeValue === "string"
|
|
1255
|
+
? resolvedResumeValue
|
|
1256
|
+
: isRecord(resolvedResumeValue) && typeof resolvedResumeValue.runId === "string"
|
|
1257
|
+
? resolvedResumeValue.runId
|
|
1258
|
+
: undefined;
|
|
1259
|
+
if (resumeReference && (typeof resolvedResume !== "string" || !resolvedResume.trim())) throw new Error("Keyed workflow receipt resume resolved without a retained run id.");
|
|
1260
|
+
const resolvedResumeId = resolvedResume?.trim();
|
|
1261
|
+
if (isRecord(resolvedResumeValue)) {
|
|
1262
|
+
const lineage = Array.isArray(resolvedResumeValue.runIds)
|
|
1263
|
+
? resolvedResumeValue.runIds.filter((runId): runId is string => typeof runId === "string" && Boolean(runId.trim())).map((runId) => runId.trim())
|
|
1264
|
+
: [];
|
|
1265
|
+
resolvedResumeLineage = [...new Set(lineage.length ? lineage : [resolvedResumeId!])];
|
|
1266
|
+
if (resolvedResumeLineage.at(-1) !== resolvedResumeId) resolvedResumeLineage.push(resolvedResumeId!);
|
|
888
1267
|
}
|
|
889
|
-
|
|
1268
|
+
const launchParams = resolvedResumeId ? { ...params, resume: resolvedResumeId } : params;
|
|
1269
|
+
return options.launch(key, launchParams, childSignal, { admitted: true });
|
|
890
1270
|
}).then((result) => {
|
|
891
|
-
|
|
892
|
-
if (
|
|
1271
|
+
let normalized = !result.ok && !result.error ? { ...result, error: result.output } : result;
|
|
1272
|
+
if (resolvedResumeLineage?.length && normalized.runId) {
|
|
1273
|
+
normalized = { ...normalized, continuation: { runIds: [...new Set([...resolvedResumeLineage, normalized.runId])] } };
|
|
1274
|
+
}
|
|
1275
|
+
childStopControllers.delete(key);
|
|
1276
|
+
if (stoppedLaunches.has(key)) return children.get(key) ?? normalized;
|
|
893
1277
|
children.set(key, normalized);
|
|
894
|
-
const state = normalized.ok ? "completed" : normalized.detached ? "detached" : "failed";
|
|
1278
|
+
const state = normalized.ok ? "completed" : normalized.stopped ? "stopped" : normalized.detached ? "detached" : "failed";
|
|
895
1279
|
trace.push({ operation: "run", key, state, durationMs: Date.now() - startedAt, ...workflowStringMetadata(params), ...(normalized.agent ? { agent: normalized.agent } : {}), ...(normalized.runId ? { runId: normalized.runId } : {}), ...(!normalized.ok ? { error: normalized.error ?? normalized.output } : {}) });
|
|
896
1280
|
traceChanged();
|
|
897
1281
|
return normalized;
|
|
898
1282
|
}, (error: unknown) => {
|
|
899
1283
|
const text = error instanceof Error ? error.message : String(error);
|
|
900
1284
|
const failure: WorkflowScriptChildResult = { key, ok: false, output: text, error: text, artifactPaths: [] };
|
|
901
|
-
|
|
1285
|
+
childStopControllers.delete(key);
|
|
1286
|
+
if (stoppedLaunches.has(key)) return children.get(key) ?? { ...failure, stopped: true };
|
|
902
1287
|
children.set(key, failure);
|
|
903
1288
|
trace.push({ operation: "run", key, state: "failed", durationMs: Date.now() - startedAt, ...workflowStringMetadata(params), error: text });
|
|
904
1289
|
traceChanged();
|
|
@@ -908,7 +1293,7 @@ export async function runWorkflowScript(options: RunWorkflowScriptOptions): Prom
|
|
|
908
1293
|
childOrder.push(key);
|
|
909
1294
|
trace.push({ operation: "run", key, state: "started", ...workflowStringMetadata(params) });
|
|
910
1295
|
traceChanged();
|
|
911
|
-
respond(deliver(promise));
|
|
1296
|
+
respond(deliver(promise), `runs.run('${key}') result`);
|
|
912
1297
|
});
|
|
913
1298
|
|
|
914
1299
|
worker.postMessage({ type: "start", script: options.script, stateEnabled: options.state !== undefined });
|