@selesai/code 0.9.11 → 0.9.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/dist/config.d.ts +4 -6
- package/dist/config.js +10 -14
- package/dist/core/agent-session.d.ts +0 -1
- package/dist/core/agent-session.js +3 -49
- package/dist/core/extensions/types.d.ts +0 -2
- package/dist/core/settings-manager.d.ts +0 -2
- package/dist/core/settings-manager.js +0 -3
- package/dist/core/tools/index.d.ts +0 -1
- package/dist/core/tools/index.js +0 -1
- package/dist/defaults/settings.json +2 -3
- package/dist/extensions/model-prompt-injector/index.test.ts +0 -10
- package/dist/extensions/model-prompt-injector/index.ts +0 -3
- package/dist/extensions/pi-intercom/CHANGELOG.md +53 -16
- package/dist/extensions/pi-intercom/README.md +41 -8
- package/dist/extensions/pi-intercom/banner.png +0 -0
- package/dist/extensions/pi-intercom/broker/broker.ts +498 -215
- package/dist/extensions/pi-intercom/broker/client.ts +39 -12
- package/dist/extensions/pi-intercom/broker/extension.test.ts +102 -3
- package/dist/extensions/pi-intercom/broker/paths.test.ts +2 -2
- package/dist/extensions/pi-intercom/broker/protocol.ts +26 -0
- package/dist/extensions/pi-intercom/broker/spawn.test.ts +5 -20
- package/dist/extensions/pi-intercom/config.test.ts +41 -0
- package/dist/extensions/pi-intercom/config.ts +21 -0
- package/dist/extensions/pi-intercom/extension-api.ts +40 -0
- package/dist/extensions/pi-intercom/index.ts +362 -26
- package/dist/extensions/pi-intercom/intercom.integration.test.ts +819 -13
- package/dist/extensions/pi-intercom/package.json +1 -1
- package/dist/extensions/pi-intercom/project-agent.ts +2 -2
- package/dist/extensions/pi-intercom/skills/pi-intercom/SKILL.md +8 -110
- package/dist/extensions/pi-intercom/types.ts +32 -5
- package/dist/extensions/pi-intercom/ui/inline-message.ts +6 -0
- package/dist/extensions/pi-subagents/.github/assets/subagent-fleet-inspector.png +0 -0
- package/dist/extensions/pi-subagents/.github/workflows/release.yml +28 -0
- package/dist/extensions/pi-subagents/.github/workflows/test.yml +51 -0
- package/dist/extensions/pi-subagents/.greptile/config.json +33 -0
- package/dist/extensions/pi-subagents/.greptile/files.json +8 -0
- package/dist/extensions/pi-subagents/.greptile/rules.md +16 -0
- package/dist/extensions/pi-subagents/CHANGELOG.md +309 -87
- package/dist/extensions/pi-subagents/README.md +15 -17
- package/dist/extensions/pi-subagents/agents/oracle.md +3 -1
- package/dist/extensions/pi-subagents/agents/researcher.md +32 -13
- package/dist/extensions/pi-subagents/agents/reviewer.md +13 -2
- package/dist/extensions/pi-subagents/agents/scout.md +2 -2
- package/dist/extensions/pi-subagents/agents/worker.md +2 -1
- package/dist/extensions/pi-subagents/async-retention-discovery-worker.mjs +180 -0
- package/dist/extensions/pi-subagents/docs/configuration.md +106 -27
- package/dist/extensions/pi-subagents/docs/extension-api.md +85 -21
- package/dist/extensions/pi-subagents/docs/missions.md +41 -4
- package/dist/extensions/pi-subagents/docs/models.md +52 -9
- package/dist/extensions/pi-subagents/docs/observability.md +103 -16
- package/dist/extensions/pi-subagents/docs/tool-reference.md +60 -45
- package/dist/extensions/pi-subagents/docs/watchdog.md +60 -3
- package/dist/extensions/pi-subagents/docs/workflows.md +181 -7
- package/dist/extensions/pi-subagents/index.ts +10 -1
- package/dist/extensions/pi-subagents/install.mjs +4 -4
- package/dist/extensions/pi-subagents/package-lock.json +1483 -1470
- package/dist/extensions/pi-subagents/package.json +6 -3
- package/dist/extensions/pi-subagents/prompts/council.md +60 -0
- package/dist/extensions/pi-subagents/prompts/parallel-review.md +5 -1
- package/dist/extensions/pi-subagents/prompts/review-loop.md +9 -5
- package/dist/extensions/pi-subagents/skills/council-mode/SKILL.md +254 -0
- package/dist/extensions/pi-subagents/skills/pi-subagents/SKILL.md +18 -17
- package/dist/extensions/pi-subagents/skills/pi-subagents/references/constraints-and-recipes.md +31 -9
- package/dist/extensions/pi-subagents/skills/pi-subagents/references/execution-controls.md +107 -140
- package/dist/extensions/pi-subagents/skills/pi-subagents/references/management-authoring-rpc.md +9 -12
- package/dist/extensions/pi-subagents/skills/pi-subagents/references/multi-lane-orchestration.md +39 -0
- package/dist/extensions/pi-subagents/skills/pi-subagents/references/prompting-and-roles.md +44 -92
- package/dist/extensions/pi-subagents/src/agents/agent-management.ts +261 -368
- package/dist/extensions/pi-subagents/src/agents/agent-serializer.ts +6 -2
- package/dist/extensions/pi-subagents/src/agents/agents.ts +388 -85
- package/dist/extensions/pi-subagents/src/agents/builtin-names.ts +14 -0
- package/dist/extensions/pi-subagents/src/agents/runtime-agent-registry.ts +418 -0
- package/dist/extensions/pi-subagents/src/agents/skills.ts +1 -1
- package/dist/extensions/pi-subagents/src/api/agents.ts +7 -0
- package/dist/extensions/pi-subagents/src/api/external-job-provider.ts +195 -0
- package/dist/extensions/pi-subagents/src/api/preflight.ts +88 -27
- package/dist/extensions/pi-subagents/src/api/project-panes.ts +2 -0
- package/dist/extensions/pi-subagents/src/api/shared-types.ts +2 -0
- package/dist/extensions/pi-subagents/src/extension/config.ts +20 -11
- package/dist/extensions/pi-subagents/src/extension/doctor.ts +14 -6
- package/dist/extensions/pi-subagents/src/extension/fanout-child.ts +5 -4
- package/dist/extensions/pi-subagents/src/extension/index.ts +270 -187
- package/dist/extensions/pi-subagents/src/extension/public-execution.ts +65 -28
- package/dist/extensions/pi-subagents/src/extension/rpc.ts +120 -11
- package/dist/extensions/pi-subagents/src/extension/schemas.ts +46 -64
- package/dist/extensions/pi-subagents/src/extension/tool-description.ts +51 -37
- package/dist/extensions/pi-subagents/src/extension/tool-result.ts +19 -0
- package/dist/extensions/pi-subagents/src/inspectors/herdr/actions.ts +2 -2
- package/dist/extensions/pi-subagents/src/inspectors/herdr/client.ts +3 -3
- package/dist/extensions/pi-subagents/src/inspectors/herdr/focus.ts +55 -0
- package/dist/extensions/pi-subagents/src/inspectors/herdr/inspector-runner.ts +2 -1
- package/dist/extensions/pi-subagents/src/inspectors/herdr/project-panes.ts +230 -46
- package/dist/extensions/pi-subagents/src/integrations/herdr-status.ts +26 -4
- package/dist/extensions/pi-subagents/src/intercom/native-supervisor-channel.ts +32 -10
- package/dist/extensions/pi-subagents/src/missions/lifecycle.ts +6 -1
- package/dist/extensions/pi-subagents/src/missions/store.ts +4 -9
- package/dist/extensions/pi-subagents/src/missions/workflow-state.ts +2 -2
- package/dist/extensions/pi-subagents/src/policy/authority.ts +2 -0
- package/dist/extensions/pi-subagents/src/profiles/profiles.ts +3 -1
- package/dist/extensions/pi-subagents/src/runs/background/active-run-index.ts +31 -8
- package/dist/extensions/pi-subagents/src/runs/background/async-execution.ts +210 -52
- package/dist/extensions/pi-subagents/src/runs/background/async-job-tracker.ts +63 -33
- package/dist/extensions/pi-subagents/src/runs/background/async-resume.ts +71 -17
- package/dist/extensions/pi-subagents/src/runs/background/async-retention.ts +886 -0
- package/dist/extensions/pi-subagents/src/runs/background/async-status-snapshot.ts +14 -5
- package/dist/extensions/pi-subagents/src/runs/background/async-status.ts +49 -56
- package/dist/extensions/pi-subagents/src/runs/background/auto-drain.ts +1 -0
- package/dist/extensions/pi-subagents/src/runs/background/chain-append.ts +3 -33
- package/dist/extensions/pi-subagents/src/runs/background/chain-root-attachment.ts +5 -0
- package/dist/extensions/pi-subagents/src/runs/background/completion-dedupe.ts +5 -1
- package/dist/extensions/pi-subagents/src/runs/background/completion-replay.ts +22 -12
- package/dist/extensions/pi-subagents/src/runs/background/control-channel.ts +105 -71
- package/dist/extensions/pi-subagents/src/runs/background/fleet-view.ts +68 -19
- package/dist/extensions/pi-subagents/src/runs/background/index-segment.ts +59 -0
- package/dist/extensions/pi-subagents/src/runs/background/inspect-rpc.ts +443 -0
- package/dist/extensions/pi-subagents/src/runs/background/notify.ts +94 -10
- package/dist/extensions/pi-subagents/src/runs/background/result-files.ts +158 -90
- package/dist/extensions/pi-subagents/src/runs/background/result-watcher.ts +141 -53
- package/dist/extensions/pi-subagents/src/runs/background/resume-guidance.ts +8 -5
- package/dist/extensions/pi-subagents/src/runs/background/retained-children.ts +14 -4
- package/dist/extensions/pi-subagents/src/runs/background/run-id-query.ts +7 -0
- package/dist/extensions/pi-subagents/src/runs/background/run-id-resolver.ts +13 -14
- package/dist/extensions/pi-subagents/src/runs/background/run-status.ts +46 -25
- package/dist/extensions/pi-subagents/src/runs/background/scheduled-runs.ts +823 -0
- package/dist/extensions/pi-subagents/src/runs/background/stale-run-reconciler.ts +9 -3
- package/dist/extensions/pi-subagents/src/runs/background/steering.ts +11 -1
- package/dist/extensions/pi-subagents/src/runs/background/subagent-runner.ts +594 -216
- package/dist/extensions/pi-subagents/src/runs/background/subagent-wait.ts +17 -13
- package/dist/extensions/pi-subagents/src/runs/background/terminal-run-index.ts +138 -0
- package/dist/extensions/pi-subagents/src/runs/background/wait-completions.ts +23 -4
- package/dist/extensions/pi-subagents/src/runs/background/wait-subscriptions.ts +82 -4
- package/dist/extensions/pi-subagents/src/runs/background/wait-tool.ts +5 -3
- package/dist/extensions/pi-subagents/src/runs/foreground/async-steering-action.ts +21 -14
- package/dist/extensions/pi-subagents/src/runs/foreground/async-stop-action.ts +23 -2
- package/dist/extensions/pi-subagents/src/runs/foreground/execution.ts +153 -58
- package/dist/extensions/pi-subagents/src/runs/foreground/foreground-history.ts +7 -9
- package/dist/extensions/pi-subagents/src/runs/foreground/subagent-executor.ts +1283 -1657
- package/dist/extensions/pi-subagents/src/runs/foreground/workflow-detach-reconcile.ts +274 -0
- package/dist/extensions/pi-subagents/src/runs/foreground/workflow-foreground-steering.ts +6 -5
- package/dist/extensions/pi-subagents/src/runs/shared/acceptance.ts +59 -10
- package/dist/extensions/pi-subagents/src/runs/shared/agent-contract.ts +1 -1
- package/dist/extensions/pi-subagents/src/runs/shared/chain-outputs.ts +1 -3
- package/dist/extensions/pi-subagents/src/runs/shared/child-identity.ts +36 -0
- package/dist/extensions/pi-subagents/src/runs/shared/completion-guard.ts +52 -2
- package/dist/extensions/pi-subagents/src/runs/shared/dynamic-fanout.ts +1 -1
- package/dist/extensions/pi-subagents/src/runs/shared/extension-bindings.ts +78 -0
- package/dist/extensions/pi-subagents/src/runs/shared/external-cli-runner.ts +2 -0
- package/dist/extensions/pi-subagents/src/runs/shared/external-job-bridge.ts +460 -0
- package/dist/extensions/pi-subagents/src/runs/shared/external-job-runner.ts +389 -0
- package/dist/extensions/pi-subagents/src/runs/shared/fast-mode-extension.ts +10 -0
- package/dist/extensions/pi-subagents/src/runs/shared/mcp-direct-tool-allowlist.ts +14 -0
- package/dist/extensions/pi-subagents/src/runs/shared/model-exclusions.ts +243 -0
- package/dist/extensions/pi-subagents/src/runs/shared/model-fallback.ts +201 -85
- package/dist/extensions/pi-subagents/src/runs/shared/model-scope.ts +106 -39
- package/dist/extensions/pi-subagents/src/runs/shared/mutation-evidence.ts +145 -0
- package/dist/extensions/pi-subagents/src/runs/shared/orca-progress-tabs.ts +150 -27
- package/dist/extensions/pi-subagents/src/runs/shared/parallel-handoff.ts +46 -4
- package/dist/extensions/pi-subagents/src/runs/shared/parallel-utils.ts +19 -15
- package/dist/extensions/pi-subagents/src/runs/shared/permissions.ts +5 -1
- package/dist/extensions/pi-subagents/src/runs/shared/pi-args.ts +86 -2
- package/dist/extensions/pi-subagents/src/runs/shared/pi-spawn.ts +9 -9
- package/dist/extensions/pi-subagents/src/runs/shared/session-lease.ts +0 -6
- package/dist/extensions/pi-subagents/src/runs/shared/structured-output.ts +18 -4
- package/dist/extensions/pi-subagents/src/runs/shared/subagent-control.ts +51 -7
- package/dist/extensions/pi-subagents/src/runs/shared/subagent-prompt-runtime.ts +62 -21
- package/dist/extensions/pi-subagents/src/runs/shared/tool-availability.ts +1 -3
- package/dist/extensions/pi-subagents/src/runs/shared/tool-timeout.ts +1 -3
- package/dist/extensions/pi-subagents/src/runs/shared/workflow-graph.ts +1 -23
- package/dist/extensions/pi-subagents/src/runs/shared/worktree.ts +14 -2
- package/dist/extensions/pi-subagents/src/shared/artifacts.ts +2 -2
- package/dist/extensions/pi-subagents/src/shared/atomic-json.ts +22 -2
- package/dist/extensions/pi-subagents/src/shared/capacity-resilient-json.ts +102 -0
- package/dist/extensions/pi-subagents/src/shared/completion-owner.ts +14 -0
- package/dist/extensions/pi-subagents/src/shared/file-system-retry.ts +49 -1
- package/dist/extensions/pi-subagents/src/shared/fork-context.ts +59 -1
- package/dist/extensions/pi-subagents/src/shared/launch-contract.ts +12 -5
- package/dist/extensions/pi-subagents/src/shared/model-info.ts +20 -0
- package/dist/extensions/pi-subagents/src/shared/prompt-resources.ts +0 -40
- package/dist/extensions/pi-subagents/src/shared/settings.ts +11 -30
- package/dist/extensions/pi-subagents/src/shared/thinking-ceiling.ts +52 -0
- package/dist/extensions/pi-subagents/src/shared/types.ts +228 -49
- package/dist/extensions/pi-subagents/src/shared/utils.ts +11 -3
- package/dist/extensions/pi-subagents/src/shared/watch-strategy.ts +10 -0
- package/dist/extensions/pi-subagents/src/slash/prompt-workflows.ts +0 -162
- package/dist/extensions/pi-subagents/src/slash/slash-bridge.ts +2 -5
- package/dist/extensions/pi-subagents/src/slash/slash-commands.ts +105 -13
- package/dist/extensions/pi-subagents/src/slash/slash-live-state.ts +6 -36
- package/dist/extensions/pi-subagents/src/tui/fleet-status.ts +829 -0
- package/dist/extensions/pi-subagents/src/tui/fleet.ts +1415 -0
- package/dist/extensions/pi-subagents/src/tui/render.ts +78 -7
- package/dist/extensions/pi-subagents/src/watchdog/change-signature.ts +1 -1
- package/dist/extensions/pi-subagents/src/watchdog/lsp-diagnostics.ts +1 -0
- package/dist/extensions/pi-subagents/src/watchdog/permission-arbiter.ts +59 -51
- package/dist/extensions/pi-subagents/src/watchdog/register-main.ts +8 -2
- package/dist/extensions/pi-subagents/src/watchdog/tool-actions.ts +2 -1
- package/dist/extensions/pi-subagents/src/workflows/chat-progress.ts +4 -4
- package/dist/extensions/pi-subagents/src/workflows/scripted-workflow.ts +471 -86
- package/dist/extensions/pi-subagents/src/workflows/workflow-receipt.ts +140 -0
- package/dist/extensions/pi-subagents/test/e2e/real-session-subagent.test.ts +2 -2
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/bun/cli.d.ts +3 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/bun/register-bedrock.d.ts +2 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/bun/restore-sandbox-env.d.ts +17 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/cli/args.d.ts +57 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/cli/config-selector.d.ts +16 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/cli/file-processor.d.ts +15 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/cli/initial-message.d.ts +18 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/cli/list-models.d.ts +9 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/cli/project-trust.d.ts +10 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/cli/session-picker.d.ts +10 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/cli/startup-ui.d.ts +20 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/cli.d.ts +3 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/config.d.ts +96 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/agent-session-runtime.d.ts +119 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/agent-session-services.d.ts +85 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/agent-session.d.ts +620 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/auth-guidance.d.ts +5 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/auth-storage.d.ts +56 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/bash-executor.d.ts +32 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/cache-stats.d.ts +49 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/compaction/branch-summarization.d.ts +93 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/compaction/compaction.d.ts +128 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/compaction/index.d.ts +7 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/compaction/utils.d.ts +38 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/defaults.d.ts +3 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/diagnostics.d.ts +15 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/event-bus.d.ts +9 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/exec.d.ts +29 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/experimental.d.ts +2 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/export-html/ansi-to-html.d.ts +22 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/export-html/index.d.ts +37 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/export-html/tool-renderer.d.ts +34 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/extensions/index.d.ts +12 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/extensions/loader.d.ts +23 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/extensions/runner.d.ts +171 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/extensions/types.d.ts +1261 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/extensions/wrapper.d.ts +20 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/footer-data-provider.d.ts +54 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/http-dispatcher.d.ts +22 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/index.d.ts +13 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/keybindings.d.ts +358 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/messages.d.ts +77 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/model-config.d.ts +512 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/model-registry.d.ts +43 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/model-resolver.d.ts +121 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/model-runtime.d.ts +82 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/models-store.d.ts +17 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/output-guard.d.ts +7 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/package-manager.d.ts +210 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/project-trust.d.ts +15 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/prompt-templates.d.ts +54 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/provider-attribution.d.ts +4 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/provider-composer.d.ts +55 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/radius.d.ts +2 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/remote-catalog-provider.d.ts +5 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/resolve-config-value.d.ts +30 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/resource-loader.d.ts +206 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/runtime-credentials.d.ts +15 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/sdk.d.ts +106 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/session-cwd.d.ts +19 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/session-manager.d.ts +356 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/settings-manager.d.ts +297 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/skills.d.ts +60 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/slash-commands.d.ts +15 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/source-info.d.ts +18 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/system-prompt.d.ts +28 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/telemetry.d.ts +3 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/timings.d.ts +10 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/bash.d.ts +68 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/edit-diff.d.ts +106 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/edit.d.ts +51 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/file-mutation-queue.d.ts +6 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/find.d.ts +35 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/grep.d.ts +37 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/index.d.ts +40 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/ls.d.ts +37 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/output-accumulator.d.ts +52 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/path-utils.d.ts +10 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/read.d.ts +35 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/render-utils.d.ts +24 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/tool-definition-wrapper.d.ts +14 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/truncate.d.ts +70 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/write.d.ts +26 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/trust-manager.d.ts +36 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/usage-totals.d.ts +19 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/extensions/index.d.ts +3 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/extensions/llama/client.d.ts +61 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/extensions/llama/huggingface.d.ts +23 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/extensions/llama/index.d.ts +3 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/extensions/llama/provider.d.ts +10 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/extensions/llama/ui.d.ts +42 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/index.d.ts +35 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/main.d.ts +12 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/migrations.d.ts +33 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/index.d.ts +9 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/armin.d.ts +34 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/assistant-message.d.ts +22 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/bash-execution.d.ts +34 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/bordered-loader.d.ts +16 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/branch-summary-message.d.ts +16 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/compaction-summary-message.d.ts +16 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/config-selector.d.ts +102 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/countdown-timer.d.ts +14 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/custom-editor.d.ts +21 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/custom-entry.d.ts +19 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/custom-message.d.ts +20 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/daxnuts.d.ts +23 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/diff.d.ts +12 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/dynamic-border.d.ts +15 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/earendil-announcement.d.ts +5 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/extension-editor.d.ts +22 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/extension-input.d.ts +23 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/extension-selector.d.ts +26 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/first-time-setup.d.ts +25 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/footer.d.ts +32 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/index.d.ts +34 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/keybinding-hints.d.ts +13 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/login-dialog.d.ts +52 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/model-selector.d.ts +54 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/oauth-selector.d.ts +33 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/scoped-models-selector.d.ts +42 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/session-selector-search.d.ts +23 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/session-selector.d.ts +95 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/settings-selector.d.ts +77 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/show-images-selector.d.ts +10 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/skill-invocation-message.d.ts +17 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/status-indicator.d.ts +28 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/theme-selector.d.ts +11 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/thinking-selector.d.ts +11 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/tool-execution.d.ts +63 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/tree-selector.d.ts +94 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/trust-selector.d.ts +23 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/user-message-selector.d.ts +30 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/user-message.d.ts +14 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/visual-truncate.d.ts +24 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/interactive-mode.d.ts +394 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/model-search.d.ts +12 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/theme/theme-controller.d.ts +29 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/theme/theme.d.ts +120 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/print-mode.d.ts +28 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/rpc/jsonl.d.ts +17 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/rpc/rpc-client.d.ts +246 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/rpc/rpc-mode.d.ts +20 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/rpc/rpc-types.d.ts +457 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/package-manager-cli.d.ts +8 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/rpc-entry.d.ts +3 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/ansi.d.ts +2 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/changelog.d.ts +22 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/child-process.d.ts +18 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/clipboard-image.d.ts +11 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/clipboard-native.d.ts +11 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/clipboard.d.ts +4 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/deprecation.d.ts +4 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/exif-orientation.d.ts +5 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/frontmatter.d.ts +8 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/fs-watch.d.ts +5 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/git.d.ts +26 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/html.d.ts +7 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/image-convert.d.ts +10 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/image-process.d.ts +18 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/image-resize-core.d.ts +30 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/image-resize-worker.d.ts +2 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/image-resize.d.ts +16 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/json.d.ts +3 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/mime.d.ts +3 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/open-browser.d.ts +9 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/paths.d.ts +31 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/photon.d.ts +21 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/pi-user-agent.d.ts +2 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/shell.d.ts +31 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/sleep.d.ts +5 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/syntax-highlight.d.ts +12 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/tools-manager.d.ts +3 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/version-check.d.ts +15 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/windows-self-update.d.ts +3 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/index.mjs +1 -1
- package/dist/extensions/pi-subagents/test/integration/acceptance-file-report.test.ts +0 -54
- package/dist/extensions/pi-subagents/test/integration/async-execution.test.ts +1053 -414
- package/dist/extensions/pi-subagents/test/integration/async-job-tracker.test.ts +194 -4
- package/dist/extensions/pi-subagents/test/integration/async-status.test.ts +59 -4
- package/dist/extensions/pi-subagents/test/integration/error-handling.test.ts +0 -77
- package/dist/extensions/pi-subagents/test/integration/external-cli-runner.test.ts +107 -6
- package/dist/extensions/pi-subagents/test/integration/fork-context-execution.test.ts +211 -897
- package/dist/extensions/pi-subagents/test/integration/intercom-result-delivery.test.ts +265 -375
- package/dist/extensions/pi-subagents/test/integration/orca-progress-tabs.test.ts +77 -7
- package/dist/extensions/pi-subagents/test/integration/render-fork-badge.test.ts +1 -1
- package/dist/extensions/pi-subagents/test/integration/render-widget.test.ts +10 -10
- package/dist/extensions/pi-subagents/test/integration/result-watcher.test.ts +547 -30
- package/dist/extensions/pi-subagents/test/integration/single-execution.test.ts +2112 -310
- package/dist/extensions/pi-subagents/test/integration/slash-commands.test.ts +274 -34
- package/dist/extensions/pi-subagents/test/integration/slash-live-state.test.ts +1 -1
- package/dist/extensions/pi-subagents/test/integration/template-resolution.test.ts +20 -3
- package/dist/extensions/pi-subagents/test/support/isolated-temp-root.mjs +9 -0
- package/dist/extensions/pi-subagents/test/support/mock-pi-script.mjs +30 -5
- package/dist/extensions/pi-subagents/test/support/mock-pi.ts +2 -0
- package/dist/extensions/pi-subagents/test/support/real-session-runner.ts +4 -2
- package/dist/extensions/pi-subagents/test/support/register-loader.mjs +1 -0
- package/dist/extensions/pi-subagents/test/unit/acceptance.test.ts +197 -0
- package/dist/extensions/pi-subagents/test/unit/agent-contract.test.ts +14 -0
- package/dist/extensions/pi-subagents/test/unit/agent-disabled.test.ts +1 -1
- package/dist/extensions/pi-subagents/test/unit/agent-frontmatter.test.ts +204 -27
- package/dist/extensions/pi-subagents/test/unit/agent-management.test.ts +444 -145
- package/dist/extensions/pi-subagents/test/unit/agent-overrides.test.ts +256 -4
- package/dist/extensions/pi-subagents/test/unit/artifacts.test.ts +9 -7
- package/dist/extensions/pi-subagents/test/unit/async-interrupt-action.test.ts +152 -22
- package/dist/extensions/pi-subagents/test/unit/async-recovery-descriptor.test.ts +29 -0
- package/dist/extensions/pi-subagents/test/unit/async-resume.test.ts +205 -23
- package/dist/extensions/pi-subagents/test/unit/async-retention.test.ts +579 -0
- package/dist/extensions/pi-subagents/test/unit/atomic-json.test.ts +24 -0
- package/dist/extensions/pi-subagents/test/unit/authority-policy.test.ts +1 -0
- package/dist/extensions/pi-subagents/test/unit/auto-drain.test.ts +3 -3
- package/dist/extensions/pi-subagents/test/unit/capacity-resilient-json.test.ts +155 -0
- package/dist/extensions/pi-subagents/test/unit/compaction-resume.test.ts +2 -2
- package/dist/extensions/pi-subagents/test/unit/completion-dedupe.test.ts +7 -0
- package/dist/extensions/pi-subagents/test/unit/completion-guard.test.ts +123 -0
- package/dist/extensions/pi-subagents/test/unit/completion-replay.test.ts +81 -3
- package/dist/extensions/pi-subagents/test/unit/control-channel.test.ts +109 -7
- package/dist/extensions/pi-subagents/test/unit/default-extensions.test.ts +2 -2
- package/dist/extensions/pi-subagents/test/unit/doctor.test.ts +5 -2
- package/dist/extensions/pi-subagents/test/unit/dynamic-fanout.test.ts +3 -2
- package/dist/extensions/pi-subagents/test/unit/extension-bindings.test.ts +79 -0
- package/dist/extensions/pi-subagents/test/unit/external-cli-runner.test.ts +22 -0
- package/dist/extensions/pi-subagents/test/unit/external-job-runner.test.ts +961 -0
- package/dist/extensions/pi-subagents/test/unit/file-system-retry.test.ts +64 -0
- package/dist/extensions/pi-subagents/test/unit/fleet-status.test.ts +1110 -0
- package/dist/extensions/pi-subagents/test/unit/fleet.test.ts +1664 -0
- package/dist/extensions/pi-subagents/test/unit/fork-context.test.ts +81 -1
- package/dist/extensions/pi-subagents/test/unit/herdr-inspector.test.ts +138 -11
- package/dist/extensions/pi-subagents/test/unit/herdr-status-bridge.test.ts +41 -2
- package/dist/extensions/pi-subagents/test/unit/index-child-registration.test.ts +210 -79
- package/dist/extensions/pi-subagents/test/unit/index-segment.test.ts +95 -0
- package/dist/extensions/pi-subagents/test/unit/inspect-rpc.test.ts +596 -0
- package/dist/extensions/pi-subagents/test/unit/mission-lifecycle.test.ts +10 -1
- package/dist/extensions/pi-subagents/test/unit/mission-store.test.ts +3 -5
- package/dist/extensions/pi-subagents/test/unit/model-exclusions.test.ts +167 -0
- package/dist/extensions/pi-subagents/test/unit/model-fallback.test.ts +319 -18
- package/dist/extensions/pi-subagents/test/unit/model-info.test.ts +78 -0
- package/dist/extensions/pi-subagents/test/unit/model-scope-settings.test.ts +19 -5
- package/dist/extensions/pi-subagents/test/unit/model-scope.test.ts +44 -0
- package/dist/extensions/pi-subagents/test/unit/mutation-evidence.test.ts +129 -0
- package/dist/extensions/pi-subagents/test/unit/native-supervisor-channel.test.ts +231 -2
- package/dist/extensions/pi-subagents/test/unit/nested-control.test.ts +28 -1
- package/dist/extensions/pi-subagents/test/unit/notify.test.ts +106 -2
- package/dist/extensions/pi-subagents/test/unit/orca-progress-tabs.test.ts +204 -7
- package/dist/extensions/pi-subagents/test/unit/package-manifest.test.ts +59 -4
- package/dist/extensions/pi-subagents/test/unit/path-handling.test.ts +2 -6
- package/dist/extensions/pi-subagents/test/unit/pi-args-permission-system.test.ts +34 -2
- package/dist/extensions/pi-subagents/test/unit/pi-args.test.ts +116 -6
- package/dist/extensions/pi-subagents/test/unit/pi-coding-agent-dir.test.ts +12 -3
- package/dist/extensions/pi-subagents/test/unit/pi-spawn.test.ts +56 -61
- package/dist/extensions/pi-subagents/test/unit/preflight.test.ts +416 -1
- package/dist/extensions/pi-subagents/test/unit/profiles.test.ts +9 -2
- package/dist/extensions/pi-subagents/test/unit/project-panes-public-api.test.ts +42 -0
- package/dist/extensions/pi-subagents/test/unit/prompt-workflows.test.ts +21 -30
- package/dist/extensions/pi-subagents/test/unit/public-execution.test.ts +86 -11
- package/dist/extensions/pi-subagents/test/unit/render-helpers.test.ts +49 -1
- package/dist/extensions/pi-subagents/test/unit/result-files.test.ts +233 -5
- package/dist/extensions/pi-subagents/test/unit/retained-children.test.ts +28 -5
- package/dist/extensions/pi-subagents/test/unit/rpc.test.ts +323 -20
- package/dist/extensions/pi-subagents/test/unit/run-id-resolver.test.ts +66 -10
- package/dist/extensions/pi-subagents/test/unit/run-status.test.ts +68 -5
- package/dist/extensions/pi-subagents/test/unit/runtime-agent-registration.test.ts +174 -0
- package/dist/extensions/pi-subagents/test/unit/scheduled-runs.test.ts +679 -0
- package/dist/extensions/pi-subagents/test/unit/scheduled-store-root.test.ts +67 -0
- package/dist/extensions/pi-subagents/test/unit/schemas.test.ts +55 -44
- package/dist/extensions/pi-subagents/test/unit/scripted-workflow.test.ts +399 -84
- package/dist/extensions/pi-subagents/test/unit/session-lease.test.ts +13 -0
- package/dist/extensions/pi-subagents/test/unit/skills-fallback.test.ts +1 -1
- package/dist/extensions/pi-subagents/test/unit/slash-bridge.test.ts +15 -10
- package/dist/extensions/pi-subagents/test/unit/stale-run-reconciler.test.ts +11 -7
- package/dist/extensions/pi-subagents/test/unit/steering-action.test.ts +2 -0
- package/dist/extensions/pi-subagents/test/unit/steering.test.ts +40 -1
- package/dist/extensions/pi-subagents/test/unit/subagent-action-recovery.test.ts +10 -2
- package/dist/extensions/pi-subagents/test/unit/subagent-control.test.ts +38 -3
- package/dist/extensions/pi-subagents/test/unit/subagent-prompt-runtime.test.ts +110 -12
- package/dist/extensions/pi-subagents/test/unit/subagent-wait.test.ts +204 -19
- package/dist/extensions/pi-subagents/test/unit/temp-paths.test.ts +25 -0
- package/dist/extensions/pi-subagents/test/unit/thinking-ceiling.test.ts +73 -0
- package/dist/extensions/pi-subagents/test/unit/tool-description.test.ts +90 -50
- package/dist/extensions/pi-subagents/test/unit/tool-timeout.test.ts +1 -2
- package/dist/extensions/pi-subagents/test/unit/wait-subscriptions.test.ts +234 -7
- package/dist/extensions/pi-subagents/test/unit/watch-strategy.test.ts +24 -0
- package/dist/extensions/pi-subagents/test/unit/watchdog-permission-arbiter.test.ts +36 -0
- package/dist/extensions/pi-subagents/test/unit/workflow-chat-progress.test.ts +37 -9
- package/dist/extensions/pi-subagents/test/unit/workflow-detach-reconcile.test.ts +302 -0
- package/dist/extensions/pi-subagents/test/unit/workflow-launch-params.test.ts +167 -7
- package/dist/extensions/pi-subagents/test/unit/workflow-receipt.test.ts +113 -0
- package/dist/extensions/pi-subagents/test/unit/worktree.test.ts +6 -6
- package/dist/extensions/ponytail/index.js +31 -25
- package/dist/extensions/ponytail/ponytail-config.cjs +34 -7
- package/dist/extensions/ponytail/ponytail-instructions.cjs +7 -9
- package/dist/extensions/ponytail/test/extension.test.js +7 -8
- package/dist/extensions/ponytail/test/helpers.test.js +1 -1
- package/dist/skills/brandkit/SKILL.md +799 -0
- package/dist/skills/design-taste-frontend/SKILL.md +1207 -0
- package/dist/skills/design-taste-frontend-v1/SKILL.md +227 -0
- package/dist/skills/full-output-enforcement/SKILL.md +50 -0
- package/dist/skills/gpt-taste/SKILL.md +75 -0
- package/dist/skills/high-end-visual-design/SKILL.md +99 -0
- package/dist/skills/image-to-code/SKILL.md +1229 -0
- package/dist/skills/imagegen-frontend-mobile/SKILL.md +1466 -0
- package/dist/skills/imagegen-frontend-web/SKILL.md +988 -0
- package/dist/skills/industrial-brutalist-ui/SKILL.md +93 -0
- package/dist/skills/minimalist-ui/SKILL.md +86 -0
- package/dist/skills/pi-subagents/SKILL.md +18 -17
- package/dist/skills/pi-subagents/references/constraints-and-recipes.md +31 -9
- package/dist/skills/pi-subagents/references/execution-controls.md +95 -143
- package/dist/skills/pi-subagents/references/management-authoring-rpc.md +9 -12
- package/dist/skills/pi-subagents/references/multi-lane-orchestration.md +39 -0
- package/dist/skills/pi-subagents/references/prompting-and-roles.md +45 -94
- package/dist/skills/ponytail/SKILL.md +12 -8
- package/dist/skills/ponytail-audit/SKILL.md +0 -1
- package/dist/skills/ponytail-debt/SKILL.md +0 -1
- package/dist/skills/ponytail-gain/SKILL.md +0 -1
- package/dist/skills/ponytail-help/SKILL.md +4 -3
- package/dist/skills/ponytail-review/SKILL.md +0 -1
- package/dist/skills/redesign-existing-projects/SKILL.md +179 -0
- package/dist/skills/stitch-design-taste/SKILL.md +185 -0
- package/dist/skills/unlazy/CHANGELOG.md +100 -0
- package/dist/skills/unlazy/CONTRIBUTING.md +66 -0
- package/dist/skills/unlazy/LICENSE +21 -0
- package/dist/skills/unlazy/README.md +242 -0
- package/dist/skills/unlazy/SECURITY.md +70 -0
- package/dist/skills/unlazy/SKILL.md +100 -0
- package/dist/skills/unlazy/package.json +13 -0
- package/dist/skills/unlazy/references/dispatch.md +82 -0
- package/dist/skills/unlazy/references/gates.md +132 -0
- package/dist/skills/unlazy/references/method.md +49 -0
- package/dist/skills/unlazy/references/orchestration.md +99 -0
- package/dist/skills/unlazy/references/parallel.md +123 -0
- package/dist/skills/unlazy/references/token-economy.md +39 -0
- package/dist/skills/unlazy/research/validation-protocol.md +81 -0
- package/dist/skills/unlazy/scripts/dispatch-check.mjs +108 -0
- package/dist/skills/unlazy/scripts/gate-check.mjs +894 -0
- package/dist/skills/unlazy/scripts/gate-lint.mjs +178 -0
- package/dist/skills/unlazy/scripts/install-hooks.mjs +206 -0
- package/dist/skills/unlazy/scripts/lib/check-supervisor.mjs +46 -0
- package/dist/skills/unlazy/scripts/lib/dispatch.mjs +283 -0
- package/dist/skills/unlazy/scripts/lib/gates.mjs +629 -0
- package/dist/skills/unlazy/scripts/lib/process-tree.mjs +161 -0
- package/dist/skills/unlazy/scripts/lib/regex-worker.mjs +9 -0
- package/dist/skills/unlazy/scripts/stop-hook.mjs +174 -0
- package/dist/skills/unlazy/templates/PLAN.md +65 -0
- package/dist/skills/unlazy/templates/gates-leaf.md +51 -0
- package/dist/skills/unlazy/templates/gates-node.md +50 -0
- package/dist/skills/unlazy/tests/contract-tests.mjs +127 -0
- package/dist/skills/unlazy/tests/dispatch-tests.mjs +481 -0
- package/dist/skills/unlazy/tests/hardening-tests.mjs +903 -0
- package/dist/skills/unlazy/tests/lint-tests.mjs +242 -0
- package/dist/skills/unlazy/tests/run-tests.mjs +554 -0
- package/dist/skills/unlazy/tests/self-check.mjs +165 -0
- package/dist/skills/unlazy/tests/stress-tests.mjs +356 -0
- package/dist/skills/web-design-guidelines/SKILL.md +40 -0
- package/docs/settings.md +0 -5
- package/package.json +1 -1
- package/dist/core/tools/schema-prune.d.ts +0 -16
- package/dist/core/tools/schema-prune.js +0 -39
- package/dist/core/tools/schema-prune.test.d.ts +0 -1
- package/dist/core/tools/schema-prune.test.js +0 -111
- package/dist/extensions/pi-subagents/UPSTREAM-V0.50-MAPPING.md +0 -172
- package/dist/extensions/pi-subagents/prompts/parallel-context-build.md +0 -55
- package/dist/extensions/pi-subagents/prompts/parallel-handoff-plan.md +0 -61
- package/dist/extensions/pi-subagents/src/agents/task-aware-routing.ts +0 -132
- package/dist/extensions/pi-subagents/src/extension/chain-validation.ts +0 -181
- package/dist/extensions/pi-subagents/src/runs/foreground/chain-clarify.ts +0 -1354
- package/dist/extensions/pi-subagents/src/runs/foreground/chain-execution.ts +0 -1581
- package/dist/extensions/pi-subagents/src/shared/env.ts +0 -16
- package/dist/extensions/pi-subagents/src/shared/session-lineage.ts +0 -71
- package/dist/extensions/pi-subagents/src/slash/inline-subagents.ts +0 -136
- package/dist/extensions/pi-subagents/src/workflows/workflow-auto-relaunch.ts +0 -41
- package/dist/extensions/pi-subagents/test/integration/chain-clarify.test.ts +0 -466
- package/dist/extensions/pi-subagents/test/integration/chain-execution.test.ts +0 -1859
- package/dist/extensions/pi-subagents/test/integration/parallel-execution.test.ts +0 -733
- package/dist/extensions/pi-subagents/test/unit/builtin-agent-documentation.test.ts +0 -63
- package/dist/extensions/pi-subagents/test/unit/chain-validation.test.ts +0 -326
- package/dist/extensions/pi-subagents/test/unit/handoff-adoption.test.ts +0 -103
- package/dist/extensions/pi-subagents/test/unit/inline-subagents.test.ts +0 -127
- package/dist/extensions/pi-subagents/test/unit/session-lineage.test.ts +0 -73
- package/dist/extensions/pi-subagents/test/unit/task-aware-routing.test.ts +0 -213
- package/dist/extensions/pi-subagents/test/unit/workflow-auto-relaunch.test.ts +0 -65
|
@@ -0,0 +1,961 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import * as fs from "node:fs";
|
|
3
|
+
import * as os from "node:os";
|
|
4
|
+
import * as path from "node:path";
|
|
5
|
+
import { afterEach, describe, it } from "node:test";
|
|
6
|
+
import { EXTERNAL_JOB_PROVIDER_REGISTRY_KEY, ExternalJobProviderError, registerExternalJobProvider } from "../../src/api/external-job-provider.ts";
|
|
7
|
+
import { EXTERNAL_JOB_BRIDGE_REQUEST_DIR, requestExternalJobOperation, serviceExternalJobBridgeRequestFile, serviceExternalJobBridgeRequests } from "../../src/runs/shared/external-job-bridge.ts";
|
|
8
|
+
import { externalJobFollowUpRequestDigest, externalJobFollowUpRequestId, externalJobPromptDigest, runExternalJob } from "../../src/runs/shared/external-job-runner.ts";
|
|
9
|
+
|
|
10
|
+
const tempDirs: string[] = [];
|
|
11
|
+
|
|
12
|
+
function clearRegistry(): void {
|
|
13
|
+
delete (globalThis as Record<PropertyKey, unknown>)[Symbol.for(EXTERNAL_JOB_PROVIDER_REGISTRY_KEY)];
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
afterEach(() => {
|
|
17
|
+
clearRegistry();
|
|
18
|
+
for (const dir of tempDirs.splice(0)) fs.rmSync(dir, { recursive: true, force: true });
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
function tempDir(prefix: string): string {
|
|
22
|
+
const dir = fs.mkdtempSync(path.join(os.tmpdir(), prefix));
|
|
23
|
+
tempDirs.push(dir);
|
|
24
|
+
return dir;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
async function serviceUntil<T>(asyncDir: string, promise: Promise<T>): Promise<T> {
|
|
28
|
+
let done = false;
|
|
29
|
+
promise.then(() => { done = true; }, () => { done = true; });
|
|
30
|
+
while (!done) {
|
|
31
|
+
serviceExternalJobBridgeRequests(asyncDir);
|
|
32
|
+
await new Promise((resolve) => setTimeout(resolve, 10));
|
|
33
|
+
}
|
|
34
|
+
return promise;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
async function waitForFile(filePath: string): Promise<void> {
|
|
38
|
+
const deadline = Date.now() + 5_000;
|
|
39
|
+
while (!fs.existsSync(filePath)) {
|
|
40
|
+
if (Date.now() >= deadline) throw new Error(`Timed out waiting for ${filePath}`);
|
|
41
|
+
await new Promise((resolve) => setTimeout(resolve, 10));
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
describe("external-job runner bridge", () => {
|
|
46
|
+
it("starts a provider job and persists result artifact metadata", async () => {
|
|
47
|
+
const dir = tempDir("pi-external-job-start-");
|
|
48
|
+
let startInput: { promptDigest: string; options: Record<string, unknown> } | undefined;
|
|
49
|
+
registerExternalJobProvider({
|
|
50
|
+
name: "surf-oracle",
|
|
51
|
+
start: (input) => {
|
|
52
|
+
startInput = { promptDigest: input.promptDigest, options: input.options };
|
|
53
|
+
return { providerJobId: "job-1", state: "completed", conversationUrl: "https://surf.example/jobs/job-1" };
|
|
54
|
+
},
|
|
55
|
+
status: () => ({ providerJobId: "job-1", state: "completed" }),
|
|
56
|
+
reattach: () => ({ providerJobId: "job-1", state: "completed" }),
|
|
57
|
+
result: () => ({ providerJobId: "job-1", state: "completed", output: "advisor result" }),
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
const result = await serviceUntil(dir, runExternalJob({
|
|
61
|
+
provider: "surf-oracle",
|
|
62
|
+
options: { tier: "pro" },
|
|
63
|
+
cwd: dir,
|
|
64
|
+
prompt: "prompt text",
|
|
65
|
+
asyncDir: dir,
|
|
66
|
+
stepIndex: 0,
|
|
67
|
+
runId: "run-1",
|
|
68
|
+
agent: "gpt-pro",
|
|
69
|
+
}));
|
|
70
|
+
|
|
71
|
+
assert.equal(result.exitCode, 0);
|
|
72
|
+
assert.equal(result.output, "advisor result");
|
|
73
|
+
assert.equal(result.externalJob.providerJobId, "job-1");
|
|
74
|
+
assert.equal(result.externalJob.conversationUrl, "https://surf.example/jobs/job-1");
|
|
75
|
+
assert.equal(result.externalJob.resultArtifactPath, path.join(dir, "external-job-0.result.md"));
|
|
76
|
+
assert.equal(fs.readFileSync(result.externalJob.resultArtifactPath!, "utf-8"), "advisor result");
|
|
77
|
+
assert.deepEqual(startInput, { promptDigest: externalJobPromptDigest("prompt text"), options: { tier: "pro" } });
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
it("reattaches an existing provider job instead of redispatching the prompt", async () => {
|
|
81
|
+
const dir = tempDir("pi-external-job-reattach-");
|
|
82
|
+
const prompt = "same prompt";
|
|
83
|
+
fs.writeFileSync(path.join(dir, "status.json"), JSON.stringify({
|
|
84
|
+
steps: [{
|
|
85
|
+
externalJob: {
|
|
86
|
+
provider: "surf-oracle",
|
|
87
|
+
providerJobId: "job-existing",
|
|
88
|
+
promptDigest: externalJobPromptDigest(prompt),
|
|
89
|
+
options: {},
|
|
90
|
+
state: "running",
|
|
91
|
+
},
|
|
92
|
+
}],
|
|
93
|
+
}), "utf-8");
|
|
94
|
+
let reattached = false;
|
|
95
|
+
registerExternalJobProvider({
|
|
96
|
+
name: "surf-oracle",
|
|
97
|
+
start: () => { throw new Error("start must not be called"); },
|
|
98
|
+
reattach: (providerJobId) => { reattached = true; return { providerJobId, state: "completed" }; },
|
|
99
|
+
status: (providerJobId) => ({ providerJobId, state: "completed" }),
|
|
100
|
+
result: (providerJobId) => ({ providerJobId, state: "completed", output: "recovered result" }),
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
const result = await serviceUntil(dir, runExternalJob({
|
|
104
|
+
provider: "surf-oracle",
|
|
105
|
+
cwd: dir,
|
|
106
|
+
prompt,
|
|
107
|
+
asyncDir: dir,
|
|
108
|
+
stepIndex: 0,
|
|
109
|
+
runId: "run-reattach",
|
|
110
|
+
agent: "gpt-pro",
|
|
111
|
+
}));
|
|
112
|
+
|
|
113
|
+
assert.equal(reattached, true);
|
|
114
|
+
assert.equal(result.exitCode, 0);
|
|
115
|
+
assert.equal(result.externalJob.providerJobId, "job-existing");
|
|
116
|
+
assert.equal(result.output, "recovered result");
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
it("fails closed with the blocking provider job on capacity conflicts", async () => {
|
|
120
|
+
const dir = tempDir("pi-external-job-capacity-");
|
|
121
|
+
registerExternalJobProvider({
|
|
122
|
+
name: "surf-oracle",
|
|
123
|
+
start: () => { throw new ExternalJobProviderError("Surf capacity is occupied", { code: "capacity", blockingJobId: "job-blocking" }); },
|
|
124
|
+
status: () => ({ providerJobId: "unused", state: "failed" }),
|
|
125
|
+
reattach: () => ({ providerJobId: "unused", state: "failed" }),
|
|
126
|
+
result: () => ({ providerJobId: "unused", state: "failed" }),
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
const result = await serviceUntil(dir, runExternalJob({
|
|
130
|
+
provider: "surf-oracle",
|
|
131
|
+
cwd: dir,
|
|
132
|
+
prompt: "prompt",
|
|
133
|
+
asyncDir: dir,
|
|
134
|
+
stepIndex: 0,
|
|
135
|
+
runId: "run-capacity",
|
|
136
|
+
agent: "gpt-pro",
|
|
137
|
+
}));
|
|
138
|
+
|
|
139
|
+
assert.equal(result.exitCode, 1);
|
|
140
|
+
assert.equal(result.externalJob.state, "blocked");
|
|
141
|
+
assert.equal(result.externalJob.blockingJobId, "job-blocking");
|
|
142
|
+
assert.match(result.error ?? "", /job-blocking/);
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
it("recovers an incomplete start claim and dispatches the original request once", async () => {
|
|
146
|
+
const dir = tempDir("pi-external-job-claimed-start-");
|
|
147
|
+
let starts = 0;
|
|
148
|
+
registerExternalJobProvider({
|
|
149
|
+
name: "surf-oracle",
|
|
150
|
+
start: () => { starts += 1; return { providerJobId: "job-duplicate", state: "completed" }; },
|
|
151
|
+
status: () => ({ providerJobId: "unused", state: "completed" }),
|
|
152
|
+
reattach: () => ({ providerJobId: "unused", state: "completed" }),
|
|
153
|
+
result: () => ({ providerJobId: "unused", state: "completed" }),
|
|
154
|
+
});
|
|
155
|
+
const requestDir = path.join(dir, EXTERNAL_JOB_BRIDGE_REQUEST_DIR);
|
|
156
|
+
fs.mkdirSync(requestDir, { recursive: true });
|
|
157
|
+
fs.mkdirSync(path.join(requestDir, "start-timeout.claim"));
|
|
158
|
+
fs.writeFileSync(path.join(requestDir, "start-timeout.json"), JSON.stringify({
|
|
159
|
+
id: "start-timeout",
|
|
160
|
+
operation: "start",
|
|
161
|
+
provider: "surf-oracle",
|
|
162
|
+
createdAt: 1,
|
|
163
|
+
start: {
|
|
164
|
+
prompt: "prompt",
|
|
165
|
+
promptDigest: externalJobPromptDigest("prompt"),
|
|
166
|
+
cwd: dir,
|
|
167
|
+
runId: "run-timeout",
|
|
168
|
+
stepIndex: 0,
|
|
169
|
+
agent: "gpt-pro",
|
|
170
|
+
options: {},
|
|
171
|
+
},
|
|
172
|
+
}), "utf-8");
|
|
173
|
+
|
|
174
|
+
serviceExternalJobBridgeRequests(dir);
|
|
175
|
+
serviceExternalJobBridgeRequests(dir);
|
|
176
|
+
await waitForFile(path.join(dir, "external-job-responses", "start-timeout.json"));
|
|
177
|
+
const response = JSON.parse(fs.readFileSync(path.join(dir, "external-job-responses", "start-timeout.json"), "utf-8"));
|
|
178
|
+
|
|
179
|
+
assert.equal(starts, 1);
|
|
180
|
+
assert.equal(response.ok, true);
|
|
181
|
+
assert.equal(response.result.providerJobId, "job-duplicate");
|
|
182
|
+
assert.equal(fs.existsSync(path.join(requestDir, "start-timeout.claim")), true);
|
|
183
|
+
assert.equal(fs.existsSync(path.join(requestDir, "start-timeout.json")), false);
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
it("does not dispatch a start request twice while the first claim is active", async () => {
|
|
187
|
+
const dir = tempDir("pi-external-job-active-claim-");
|
|
188
|
+
let starts = 0;
|
|
189
|
+
let resolveStart: ((value: { providerJobId: string; state: "completed" }) => void) | undefined;
|
|
190
|
+
registerExternalJobProvider({
|
|
191
|
+
name: "surf-oracle",
|
|
192
|
+
start: () => {
|
|
193
|
+
starts += 1;
|
|
194
|
+
return new Promise((resolve) => { resolveStart = resolve; });
|
|
195
|
+
},
|
|
196
|
+
status: () => ({ providerJobId: "unused", state: "completed" }),
|
|
197
|
+
reattach: () => ({ providerJobId: "unused", state: "completed" }),
|
|
198
|
+
result: () => ({ providerJobId: "unused", state: "completed" }),
|
|
199
|
+
});
|
|
200
|
+
const requestDir = path.join(dir, EXTERNAL_JOB_BRIDGE_REQUEST_DIR);
|
|
201
|
+
fs.mkdirSync(requestDir, { recursive: true });
|
|
202
|
+
fs.writeFileSync(path.join(requestDir, "start-race.json"), JSON.stringify({
|
|
203
|
+
id: "start-race",
|
|
204
|
+
operation: "start",
|
|
205
|
+
provider: "surf-oracle",
|
|
206
|
+
createdAt: Date.now(),
|
|
207
|
+
start: {
|
|
208
|
+
prompt: "prompt",
|
|
209
|
+
promptDigest: externalJobPromptDigest("prompt"),
|
|
210
|
+
cwd: dir,
|
|
211
|
+
runId: "run-race",
|
|
212
|
+
stepIndex: 0,
|
|
213
|
+
agent: "gpt-pro",
|
|
214
|
+
options: {},
|
|
215
|
+
},
|
|
216
|
+
}), "utf-8");
|
|
217
|
+
|
|
218
|
+
serviceExternalJobBridgeRequests(dir);
|
|
219
|
+
serviceExternalJobBridgeRequests(dir);
|
|
220
|
+
|
|
221
|
+
assert.equal(starts, 1);
|
|
222
|
+
assert.equal(fs.existsSync(path.join(dir, "external-job-responses", "start-race.json")), false);
|
|
223
|
+
resolveStart!({ providerJobId: "job-race", state: "completed" });
|
|
224
|
+
await waitForFile(path.join(dir, "external-job-responses", "start-race.json"));
|
|
225
|
+
const response = JSON.parse(fs.readFileSync(path.join(dir, "external-job-responses", "start-race.json"), "utf-8"));
|
|
226
|
+
assert.equal(response.ok, true);
|
|
227
|
+
assert.equal(response.result.providerJobId, "job-race");
|
|
228
|
+
assert.equal(starts, 1);
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
it("does not fail an old active start claim while provider start may still be running", () => {
|
|
232
|
+
const dir = tempDir("pi-external-job-long-active-claim-");
|
|
233
|
+
let starts = 0;
|
|
234
|
+
registerExternalJobProvider({
|
|
235
|
+
name: "surf-oracle",
|
|
236
|
+
start: () => { starts += 1; return { providerJobId: "job-duplicate", state: "completed" }; },
|
|
237
|
+
status: () => ({ providerJobId: "unused", state: "completed" }),
|
|
238
|
+
reattach: () => ({ providerJobId: "unused", state: "completed" }),
|
|
239
|
+
result: () => ({ providerJobId: "unused", state: "completed" }),
|
|
240
|
+
});
|
|
241
|
+
const requestDir = path.join(dir, EXTERNAL_JOB_BRIDGE_REQUEST_DIR);
|
|
242
|
+
const claimDir = path.join(requestDir, "start-long.claim");
|
|
243
|
+
fs.mkdirSync(requestDir, { recursive: true });
|
|
244
|
+
fs.mkdirSync(claimDir);
|
|
245
|
+
fs.writeFileSync(path.join(claimDir, "owner.json"), JSON.stringify({ version: 1, pid: process.pid, hostname: os.hostname(), claimedAt: 1 }), "utf-8");
|
|
246
|
+
fs.writeFileSync(path.join(claimDir, "request.json"), JSON.stringify({
|
|
247
|
+
id: "start-long",
|
|
248
|
+
operation: "start",
|
|
249
|
+
provider: "surf-oracle",
|
|
250
|
+
createdAt: 1,
|
|
251
|
+
claimedAt: 2,
|
|
252
|
+
start: {
|
|
253
|
+
prompt: "prompt",
|
|
254
|
+
promptDigest: externalJobPromptDigest("prompt"),
|
|
255
|
+
cwd: dir,
|
|
256
|
+
runId: "run-long",
|
|
257
|
+
stepIndex: 0,
|
|
258
|
+
agent: "gpt-pro",
|
|
259
|
+
options: {},
|
|
260
|
+
},
|
|
261
|
+
}), "utf-8");
|
|
262
|
+
|
|
263
|
+
serviceExternalJobBridgeRequestFile(dir, "start-long.claim");
|
|
264
|
+
|
|
265
|
+
assert.equal(starts, 0);
|
|
266
|
+
assert.equal(fs.existsSync(path.join(dir, "external-job-responses", "start-long.json")), false);
|
|
267
|
+
assert.equal(fs.existsSync(claimDir), true);
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
it("settles an abandoned start claim without redispatching", () => {
|
|
271
|
+
const dir = tempDir("pi-external-job-abandoned-claim-");
|
|
272
|
+
let starts = 0;
|
|
273
|
+
registerExternalJobProvider({
|
|
274
|
+
name: "surf-oracle",
|
|
275
|
+
start: () => { starts += 1; return { providerJobId: "job-duplicate", state: "completed" }; },
|
|
276
|
+
status: () => ({ providerJobId: "unused", state: "completed" }),
|
|
277
|
+
reattach: () => ({ providerJobId: "unused", state: "completed" }),
|
|
278
|
+
result: () => ({ providerJobId: "unused", state: "completed" }),
|
|
279
|
+
});
|
|
280
|
+
const requestDir = path.join(dir, EXTERNAL_JOB_BRIDGE_REQUEST_DIR);
|
|
281
|
+
const claimDir = path.join(requestDir, "start-abandoned.claim");
|
|
282
|
+
fs.mkdirSync(claimDir, { recursive: true });
|
|
283
|
+
fs.writeFileSync(path.join(claimDir, "owner.json"), JSON.stringify({ version: 1, pid: 9_999_999, hostname: os.hostname(), claimedAt: 1 }), "utf-8");
|
|
284
|
+
fs.writeFileSync(path.join(claimDir, "request.json"), JSON.stringify({
|
|
285
|
+
id: "start-abandoned",
|
|
286
|
+
operation: "start",
|
|
287
|
+
provider: "surf-oracle",
|
|
288
|
+
createdAt: 1,
|
|
289
|
+
claimedAt: 2,
|
|
290
|
+
start: {
|
|
291
|
+
prompt: "prompt",
|
|
292
|
+
promptDigest: externalJobPromptDigest("prompt"),
|
|
293
|
+
cwd: dir,
|
|
294
|
+
runId: "run-abandoned",
|
|
295
|
+
stepIndex: 0,
|
|
296
|
+
agent: "gpt-pro",
|
|
297
|
+
options: {},
|
|
298
|
+
},
|
|
299
|
+
}), "utf-8");
|
|
300
|
+
|
|
301
|
+
serviceExternalJobBridgeRequests(dir);
|
|
302
|
+
|
|
303
|
+
assert.equal(starts, 0);
|
|
304
|
+
const response = JSON.parse(fs.readFileSync(path.join(dir, "external-job-responses", "start-abandoned.json"), "utf-8"));
|
|
305
|
+
assert.equal(response.ok, false);
|
|
306
|
+
assert.equal(response.code, "start-dispatch-abandoned");
|
|
307
|
+
assert.match(response.message, /Refusing to redispatch/);
|
|
308
|
+
assert.equal(fs.existsSync(claimDir), false);
|
|
309
|
+
});
|
|
310
|
+
|
|
311
|
+
it("reports abandoned follow-up claims with follow-up context", () => {
|
|
312
|
+
const dir = tempDir("pi-external-job-abandoned-follow-up-");
|
|
313
|
+
let followUps = 0;
|
|
314
|
+
registerExternalJobProvider({
|
|
315
|
+
name: "surf-oracle",
|
|
316
|
+
start: () => { throw new Error("start must not be called"); },
|
|
317
|
+
followUp: () => { followUps += 1; return { providerJobId: "job-duplicate", state: "completed" }; },
|
|
318
|
+
status: () => ({ providerJobId: "unused", state: "completed" }),
|
|
319
|
+
reattach: () => ({ providerJobId: "unused", state: "completed" }),
|
|
320
|
+
result: () => ({ providerJobId: "unused", state: "completed" }),
|
|
321
|
+
});
|
|
322
|
+
const requestDir = path.join(dir, EXTERNAL_JOB_BRIDGE_REQUEST_DIR);
|
|
323
|
+
const claimDir = path.join(requestDir, "follow-up-abandoned.claim");
|
|
324
|
+
fs.mkdirSync(claimDir, { recursive: true });
|
|
325
|
+
fs.writeFileSync(path.join(claimDir, "owner.json"), JSON.stringify({ version: 1, pid: 9_999_999, hostname: os.hostname(), claimedAt: 1 }), "utf-8");
|
|
326
|
+
fs.writeFileSync(path.join(claimDir, "request.json"), JSON.stringify({
|
|
327
|
+
id: "follow-up-abandoned",
|
|
328
|
+
operation: "follow-up",
|
|
329
|
+
provider: "surf-oracle",
|
|
330
|
+
createdAt: 1,
|
|
331
|
+
claimedAt: 2,
|
|
332
|
+
followUp: {
|
|
333
|
+
prompt: "prompt",
|
|
334
|
+
promptDigest: externalJobPromptDigest("prompt"),
|
|
335
|
+
cwd: dir,
|
|
336
|
+
runId: "run-abandoned-follow-up",
|
|
337
|
+
stepIndex: 0,
|
|
338
|
+
agent: "gpt-pro",
|
|
339
|
+
options: {},
|
|
340
|
+
sourceRunId: "run-parent",
|
|
341
|
+
sourceStepIndex: 0,
|
|
342
|
+
parentProviderJobId: "job-parent",
|
|
343
|
+
requestId: "request-abandoned-follow-up",
|
|
344
|
+
requestDigest: "digest-abandoned-follow-up",
|
|
345
|
+
},
|
|
346
|
+
}), "utf-8");
|
|
347
|
+
|
|
348
|
+
serviceExternalJobBridgeRequests(dir);
|
|
349
|
+
|
|
350
|
+
assert.equal(followUps, 0);
|
|
351
|
+
const response = JSON.parse(fs.readFileSync(path.join(dir, "external-job-responses", "follow-up-abandoned.json"), "utf-8"));
|
|
352
|
+
assert.equal(response.ok, false);
|
|
353
|
+
assert.equal(response.code, "follow-up-dispatch-abandoned");
|
|
354
|
+
assert.match(response.message, /External-job follow-up/);
|
|
355
|
+
assert.equal(fs.existsSync(claimDir), false);
|
|
356
|
+
});
|
|
357
|
+
|
|
358
|
+
it("recovers a persisted start handle from a dead owner claim", () => {
|
|
359
|
+
const dir = tempDir("pi-external-job-dead-owner-handle-");
|
|
360
|
+
let starts = 0;
|
|
361
|
+
registerExternalJobProvider({
|
|
362
|
+
name: "surf-oracle",
|
|
363
|
+
start: () => { starts += 1; return { providerJobId: "job-duplicate", state: "completed" }; },
|
|
364
|
+
status: () => ({ providerJobId: "unused", state: "completed" }),
|
|
365
|
+
reattach: () => ({ providerJobId: "unused", state: "completed" }),
|
|
366
|
+
result: () => ({ providerJobId: "unused", state: "completed" }),
|
|
367
|
+
});
|
|
368
|
+
const requestDir = path.join(dir, EXTERNAL_JOB_BRIDGE_REQUEST_DIR);
|
|
369
|
+
const claimDir = path.join(requestDir, "start-recovered.claim");
|
|
370
|
+
fs.mkdirSync(claimDir, { recursive: true });
|
|
371
|
+
fs.writeFileSync(path.join(claimDir, "owner.json"), JSON.stringify({ version: 1, pid: 9_999_999, hostname: os.hostname(), claimedAt: 1 }), "utf-8");
|
|
372
|
+
fs.writeFileSync(path.join(claimDir, "request.json"), JSON.stringify({
|
|
373
|
+
id: "start-recovered",
|
|
374
|
+
operation: "start",
|
|
375
|
+
provider: "surf-oracle",
|
|
376
|
+
createdAt: 1,
|
|
377
|
+
claimedAt: 2,
|
|
378
|
+
start: {
|
|
379
|
+
prompt: "prompt",
|
|
380
|
+
promptDigest: externalJobPromptDigest("prompt"),
|
|
381
|
+
cwd: dir,
|
|
382
|
+
runId: "run-recovered",
|
|
383
|
+
stepIndex: 0,
|
|
384
|
+
agent: "gpt-pro",
|
|
385
|
+
options: {},
|
|
386
|
+
},
|
|
387
|
+
}), "utf-8");
|
|
388
|
+
fs.writeFileSync(path.join(claimDir, "handle.json"), JSON.stringify({ providerJobId: "job-recovered", state: "running" }), "utf-8");
|
|
389
|
+
|
|
390
|
+
serviceExternalJobBridgeRequests(dir);
|
|
391
|
+
|
|
392
|
+
assert.equal(starts, 0);
|
|
393
|
+
const response = JSON.parse(fs.readFileSync(path.join(dir, "external-job-responses", "start-recovered.json"), "utf-8"));
|
|
394
|
+
assert.equal(response.ok, true);
|
|
395
|
+
assert.equal(response.result.providerJobId, "job-recovered");
|
|
396
|
+
assert.equal(fs.existsSync(path.join(claimDir, "completed.json")), true);
|
|
397
|
+
});
|
|
398
|
+
|
|
399
|
+
it("ignores a stale start request snapshot after another host claimed it", async () => {
|
|
400
|
+
const dir = tempDir("pi-external-job-stale-snapshot-");
|
|
401
|
+
let starts = 0;
|
|
402
|
+
let resolveStart: ((value: { providerJobId: string; state: "completed" }) => void) | undefined;
|
|
403
|
+
registerExternalJobProvider({
|
|
404
|
+
name: "surf-oracle",
|
|
405
|
+
start: () => {
|
|
406
|
+
starts += 1;
|
|
407
|
+
return new Promise((resolve) => { resolveStart = resolve; });
|
|
408
|
+
},
|
|
409
|
+
status: () => ({ providerJobId: "unused", state: "completed" }),
|
|
410
|
+
reattach: () => ({ providerJobId: "unused", state: "completed" }),
|
|
411
|
+
result: () => ({ providerJobId: "unused", state: "completed" }),
|
|
412
|
+
});
|
|
413
|
+
const requestDir = path.join(dir, EXTERNAL_JOB_BRIDGE_REQUEST_DIR);
|
|
414
|
+
fs.mkdirSync(requestDir, { recursive: true });
|
|
415
|
+
fs.writeFileSync(path.join(requestDir, "start-stale.json"), JSON.stringify({
|
|
416
|
+
id: "start-stale",
|
|
417
|
+
operation: "start",
|
|
418
|
+
provider: "surf-oracle",
|
|
419
|
+
createdAt: Date.now(),
|
|
420
|
+
start: {
|
|
421
|
+
prompt: "prompt",
|
|
422
|
+
promptDigest: externalJobPromptDigest("prompt"),
|
|
423
|
+
cwd: dir,
|
|
424
|
+
runId: "run-stale",
|
|
425
|
+
stepIndex: 0,
|
|
426
|
+
agent: "gpt-pro",
|
|
427
|
+
options: {},
|
|
428
|
+
},
|
|
429
|
+
}), "utf-8");
|
|
430
|
+
|
|
431
|
+
serviceExternalJobBridgeRequests(dir);
|
|
432
|
+
serviceExternalJobBridgeRequestFile(dir, "start-stale.json");
|
|
433
|
+
|
|
434
|
+
assert.equal(starts, 1);
|
|
435
|
+
assert.equal(fs.existsSync(path.join(dir, "external-job-responses", "start-stale.json")), false);
|
|
436
|
+
resolveStart!({ providerJobId: "job-stale", state: "completed" });
|
|
437
|
+
await waitForFile(path.join(dir, "external-job-responses", "start-stale.json"));
|
|
438
|
+
const response = JSON.parse(fs.readFileSync(path.join(dir, "external-job-responses", "start-stale.json"), "utf-8"));
|
|
439
|
+
assert.equal(response.ok, true);
|
|
440
|
+
assert.equal(response.result.providerJobId, "job-stale");
|
|
441
|
+
assert.equal(starts, 1);
|
|
442
|
+
});
|
|
443
|
+
|
|
444
|
+
it("does not redispatch after a completed start claim", async () => {
|
|
445
|
+
const dir = tempDir("pi-external-job-completed-claim-");
|
|
446
|
+
let starts = 0;
|
|
447
|
+
registerExternalJobProvider({
|
|
448
|
+
name: "surf-oracle",
|
|
449
|
+
start: () => { starts += 1; return { providerJobId: "job-completed", state: "completed" }; },
|
|
450
|
+
status: () => ({ providerJobId: "unused", state: "completed" }),
|
|
451
|
+
reattach: () => ({ providerJobId: "unused", state: "completed" }),
|
|
452
|
+
result: () => ({ providerJobId: "unused", state: "completed" }),
|
|
453
|
+
});
|
|
454
|
+
const requestDir = path.join(dir, EXTERNAL_JOB_BRIDGE_REQUEST_DIR);
|
|
455
|
+
fs.mkdirSync(requestDir, { recursive: true });
|
|
456
|
+
const request = {
|
|
457
|
+
id: "start-completed",
|
|
458
|
+
operation: "start",
|
|
459
|
+
provider: "surf-oracle",
|
|
460
|
+
createdAt: Date.now(),
|
|
461
|
+
start: {
|
|
462
|
+
prompt: "prompt",
|
|
463
|
+
promptDigest: externalJobPromptDigest("prompt"),
|
|
464
|
+
cwd: dir,
|
|
465
|
+
runId: "run-completed",
|
|
466
|
+
stepIndex: 0,
|
|
467
|
+
agent: "gpt-pro",
|
|
468
|
+
options: {},
|
|
469
|
+
},
|
|
470
|
+
};
|
|
471
|
+
fs.writeFileSync(path.join(requestDir, "start-completed.json"), JSON.stringify(request), "utf-8");
|
|
472
|
+
|
|
473
|
+
serviceExternalJobBridgeRequests(dir);
|
|
474
|
+
await waitForFile(path.join(dir, "external-job-responses", "start-completed.json"));
|
|
475
|
+
fs.rmSync(path.join(dir, "external-job-responses", "start-completed.json"), { force: true });
|
|
476
|
+
fs.writeFileSync(path.join(requestDir, "start-completed.json"), JSON.stringify(request), "utf-8");
|
|
477
|
+
serviceExternalJobBridgeRequests(dir);
|
|
478
|
+
|
|
479
|
+
assert.equal(starts, 1);
|
|
480
|
+
assert.equal(fs.existsSync(path.join(requestDir, "start-completed.claim")), true);
|
|
481
|
+
});
|
|
482
|
+
|
|
483
|
+
it("does not let completed start claims starve later requests", async () => {
|
|
484
|
+
const dir = tempDir("pi-external-job-completed-claim-starvation-");
|
|
485
|
+
let starts = 0;
|
|
486
|
+
registerExternalJobProvider({
|
|
487
|
+
name: "surf-oracle",
|
|
488
|
+
start: () => { starts += 1; return { providerJobId: "job-after-tombstones", state: "completed" }; },
|
|
489
|
+
status: () => ({ providerJobId: "unused", state: "completed" }),
|
|
490
|
+
reattach: () => ({ providerJobId: "unused", state: "completed" }),
|
|
491
|
+
result: () => ({ providerJobId: "unused", state: "completed" }),
|
|
492
|
+
});
|
|
493
|
+
const requestDir = path.join(dir, EXTERNAL_JOB_BRIDGE_REQUEST_DIR);
|
|
494
|
+
fs.mkdirSync(requestDir, { recursive: true });
|
|
495
|
+
for (let index = 0; index < 100; index += 1) {
|
|
496
|
+
const id = `000-${String(index).padStart(3, "0")}`;
|
|
497
|
+
const claimDir = path.join(requestDir, `${id}.claim`);
|
|
498
|
+
fs.mkdirSync(claimDir);
|
|
499
|
+
fs.writeFileSync(path.join(claimDir, "completed.json"), JSON.stringify({ completedAt: 1 }), "utf-8");
|
|
500
|
+
fs.writeFileSync(path.join(requestDir, `${id}.json`), JSON.stringify({
|
|
501
|
+
id,
|
|
502
|
+
operation: "start",
|
|
503
|
+
provider: "surf-oracle",
|
|
504
|
+
createdAt: Date.now(),
|
|
505
|
+
start: {
|
|
506
|
+
prompt: "stale prompt",
|
|
507
|
+
promptDigest: externalJobPromptDigest("stale prompt"),
|
|
508
|
+
cwd: dir,
|
|
509
|
+
runId: "run-stale-completed",
|
|
510
|
+
stepIndex: 0,
|
|
511
|
+
agent: "gpt-pro",
|
|
512
|
+
options: {},
|
|
513
|
+
},
|
|
514
|
+
}), "utf-8");
|
|
515
|
+
}
|
|
516
|
+
fs.writeFileSync(path.join(requestDir, "zzz.json"), JSON.stringify({
|
|
517
|
+
id: "zzz",
|
|
518
|
+
operation: "start",
|
|
519
|
+
provider: "surf-oracle",
|
|
520
|
+
createdAt: Date.now(),
|
|
521
|
+
start: {
|
|
522
|
+
prompt: "prompt",
|
|
523
|
+
promptDigest: externalJobPromptDigest("prompt"),
|
|
524
|
+
cwd: dir,
|
|
525
|
+
runId: "run-after-tombstones",
|
|
526
|
+
stepIndex: 0,
|
|
527
|
+
agent: "gpt-pro",
|
|
528
|
+
options: {},
|
|
529
|
+
},
|
|
530
|
+
}), "utf-8");
|
|
531
|
+
|
|
532
|
+
serviceExternalJobBridgeRequests(dir);
|
|
533
|
+
await waitForFile(path.join(dir, "external-job-responses", "zzz.json"));
|
|
534
|
+
|
|
535
|
+
assert.equal(starts, 1);
|
|
536
|
+
});
|
|
537
|
+
|
|
538
|
+
it("does not start again after a bridge timeout without provider job id", async () => {
|
|
539
|
+
const dir = tempDir("pi-external-job-timeout-retry-");
|
|
540
|
+
const prompt = "prompt";
|
|
541
|
+
fs.writeFileSync(path.join(dir, "status.json"), JSON.stringify({
|
|
542
|
+
steps: [{
|
|
543
|
+
externalJob: {
|
|
544
|
+
provider: "surf-oracle",
|
|
545
|
+
promptDigest: externalJobPromptDigest(prompt),
|
|
546
|
+
options: {},
|
|
547
|
+
state: "failed",
|
|
548
|
+
failureCode: "bridge-timeout",
|
|
549
|
+
failureMessage: "Bridge timed out before a provider job id was committed.",
|
|
550
|
+
},
|
|
551
|
+
}],
|
|
552
|
+
}), "utf-8");
|
|
553
|
+
let starts = 0;
|
|
554
|
+
registerExternalJobProvider({
|
|
555
|
+
name: "surf-oracle",
|
|
556
|
+
start: () => { starts += 1; return { providerJobId: "job-2", state: "completed" }; },
|
|
557
|
+
status: () => ({ providerJobId: "unused", state: "completed" }),
|
|
558
|
+
reattach: () => ({ providerJobId: "unused", state: "completed" }),
|
|
559
|
+
result: () => ({ providerJobId: "unused", state: "completed" }),
|
|
560
|
+
});
|
|
561
|
+
|
|
562
|
+
const result = await runExternalJob({
|
|
563
|
+
provider: "surf-oracle",
|
|
564
|
+
cwd: dir,
|
|
565
|
+
prompt,
|
|
566
|
+
asyncDir: dir,
|
|
567
|
+
stepIndex: 0,
|
|
568
|
+
runId: "run-timeout-retry",
|
|
569
|
+
agent: "gpt-pro",
|
|
570
|
+
});
|
|
571
|
+
|
|
572
|
+
assert.equal(starts, 0);
|
|
573
|
+
assert.equal(result.exitCode, 1);
|
|
574
|
+
assert.equal(result.externalJob.failureCode, "start-redispatch-blocked");
|
|
575
|
+
assert.match(result.error ?? "", /Refusing to redispatch/);
|
|
576
|
+
assert.equal(fs.existsSync(path.join(dir, EXTERNAL_JOB_BRIDGE_REQUEST_DIR)), false);
|
|
577
|
+
});
|
|
578
|
+
|
|
579
|
+
it("fails closed when existing status.json is malformed", async () => {
|
|
580
|
+
const dir = tempDir("pi-external-job-corrupt-status-");
|
|
581
|
+
fs.writeFileSync(path.join(dir, "status.json"), "{ not json", "utf-8");
|
|
582
|
+
let starts = 0;
|
|
583
|
+
registerExternalJobProvider({
|
|
584
|
+
name: "surf-oracle",
|
|
585
|
+
start: () => { starts += 1; return { providerJobId: "job-new", state: "completed" }; },
|
|
586
|
+
status: () => ({ providerJobId: "unused", state: "completed" }),
|
|
587
|
+
reattach: () => ({ providerJobId: "unused", state: "completed" }),
|
|
588
|
+
result: () => ({ providerJobId: "unused", state: "completed" }),
|
|
589
|
+
});
|
|
590
|
+
|
|
591
|
+
const result = await runExternalJob({
|
|
592
|
+
provider: "surf-oracle",
|
|
593
|
+
cwd: dir,
|
|
594
|
+
prompt: "prompt",
|
|
595
|
+
asyncDir: dir,
|
|
596
|
+
stepIndex: 0,
|
|
597
|
+
runId: "run-corrupt-status",
|
|
598
|
+
agent: "gpt-pro",
|
|
599
|
+
});
|
|
600
|
+
|
|
601
|
+
assert.equal(starts, 0);
|
|
602
|
+
assert.equal(result.exitCode, 1);
|
|
603
|
+
assert.equal(result.externalJob.failureCode, "status-unreadable");
|
|
604
|
+
assert.match(result.error ?? "", /Malformed external-job status/);
|
|
605
|
+
assert.equal(fs.existsSync(path.join(dir, EXTERNAL_JOB_BRIDGE_REQUEST_DIR)), false);
|
|
606
|
+
});
|
|
607
|
+
|
|
608
|
+
it("fails closed when existing status.json has an invalid steps shape", async () => {
|
|
609
|
+
const dir = tempDir("pi-external-job-invalid-steps-");
|
|
610
|
+
fs.writeFileSync(path.join(dir, "status.json"), JSON.stringify({ steps: "nope" }), "utf-8");
|
|
611
|
+
let starts = 0;
|
|
612
|
+
registerExternalJobProvider({
|
|
613
|
+
name: "surf-oracle",
|
|
614
|
+
start: () => { starts += 1; return { providerJobId: "job-new", state: "completed" }; },
|
|
615
|
+
status: () => ({ providerJobId: "unused", state: "completed" }),
|
|
616
|
+
reattach: () => ({ providerJobId: "unused", state: "completed" }),
|
|
617
|
+
result: () => ({ providerJobId: "unused", state: "completed" }),
|
|
618
|
+
});
|
|
619
|
+
|
|
620
|
+
const result = await runExternalJob({
|
|
621
|
+
provider: "surf-oracle",
|
|
622
|
+
cwd: dir,
|
|
623
|
+
prompt: "prompt",
|
|
624
|
+
asyncDir: dir,
|
|
625
|
+
stepIndex: 0,
|
|
626
|
+
runId: "run-invalid-steps",
|
|
627
|
+
agent: "gpt-pro",
|
|
628
|
+
});
|
|
629
|
+
|
|
630
|
+
assert.equal(starts, 0);
|
|
631
|
+
assert.equal(result.exitCode, 1);
|
|
632
|
+
assert.equal(result.externalJob.failureCode, "status-unreadable");
|
|
633
|
+
assert.match(result.error ?? "", /Malformed external-job status/);
|
|
634
|
+
assert.equal(fs.existsSync(path.join(dir, EXTERNAL_JOB_BRIDGE_REQUEST_DIR)), false);
|
|
635
|
+
});
|
|
636
|
+
|
|
637
|
+
it("starts when existing status.json has a pending step without an external job", async () => {
|
|
638
|
+
const dir = tempDir("pi-external-job-pending-step-");
|
|
639
|
+
fs.writeFileSync(path.join(dir, "status.json"), JSON.stringify({
|
|
640
|
+
steps: [{ agent: "gpt-pro", status: "pending" }],
|
|
641
|
+
}), "utf-8");
|
|
642
|
+
let starts = 0;
|
|
643
|
+
registerExternalJobProvider({
|
|
644
|
+
name: "surf-oracle",
|
|
645
|
+
start: () => { starts += 1; return { providerJobId: "job-1", state: "completed" }; },
|
|
646
|
+
status: () => ({ providerJobId: "job-1", state: "completed" }),
|
|
647
|
+
reattach: () => ({ providerJobId: "job-1", state: "completed" }),
|
|
648
|
+
result: () => ({ providerJobId: "job-1", state: "completed", output: "first start" }),
|
|
649
|
+
});
|
|
650
|
+
|
|
651
|
+
const result = await serviceUntil(dir, runExternalJob({
|
|
652
|
+
provider: "surf-oracle",
|
|
653
|
+
cwd: dir,
|
|
654
|
+
prompt: "prompt",
|
|
655
|
+
asyncDir: dir,
|
|
656
|
+
stepIndex: 0,
|
|
657
|
+
runId: "run-pending-step",
|
|
658
|
+
agent: "gpt-pro",
|
|
659
|
+
}));
|
|
660
|
+
|
|
661
|
+
assert.equal(starts, 1);
|
|
662
|
+
assert.equal(result.exitCode, 0);
|
|
663
|
+
assert.equal(result.externalJob.providerJobId, "job-1");
|
|
664
|
+
});
|
|
665
|
+
|
|
666
|
+
it("stops waiting for start when local timeout fires before a provider job id", async () => {
|
|
667
|
+
const dir = tempDir("pi-external-job-start-local-timeout-");
|
|
668
|
+
let starts = 0;
|
|
669
|
+
let timeout: (() => void) | undefined;
|
|
670
|
+
registerExternalJobProvider({
|
|
671
|
+
name: "surf-oracle",
|
|
672
|
+
start: () => {
|
|
673
|
+
starts += 1;
|
|
674
|
+
return new Promise(() => {});
|
|
675
|
+
},
|
|
676
|
+
status: () => ({ providerJobId: "unused", state: "completed" }),
|
|
677
|
+
reattach: () => ({ providerJobId: "unused", state: "completed" }),
|
|
678
|
+
result: () => ({ providerJobId: "unused", state: "completed" }),
|
|
679
|
+
});
|
|
680
|
+
|
|
681
|
+
const operation = runExternalJob({
|
|
682
|
+
provider: "surf-oracle",
|
|
683
|
+
cwd: dir,
|
|
684
|
+
prompt: "prompt",
|
|
685
|
+
asyncDir: dir,
|
|
686
|
+
stepIndex: 0,
|
|
687
|
+
runId: "run-local-timeout",
|
|
688
|
+
agent: "gpt-pro",
|
|
689
|
+
registerTimeout: (registered) => { timeout = registered; },
|
|
690
|
+
});
|
|
691
|
+
timeout!();
|
|
692
|
+
const result = await operation;
|
|
693
|
+
|
|
694
|
+
assert.equal(starts, 0);
|
|
695
|
+
assert.equal(result.exitCode, 1);
|
|
696
|
+
assert.equal(result.timedOut, true);
|
|
697
|
+
assert.equal(result.externalJob.failureCode, "local-timeout");
|
|
698
|
+
assert.match(result.error ?? "", /timed out locally/);
|
|
699
|
+
const requestDir = path.join(dir, EXTERNAL_JOB_BRIDGE_REQUEST_DIR);
|
|
700
|
+
const tombstone = fs.readdirSync(requestDir).find((entry) => entry.endsWith(".claim"));
|
|
701
|
+
assert.ok(tombstone);
|
|
702
|
+
const staleId = tombstone.replace(/\.claim$/, "");
|
|
703
|
+
fs.writeFileSync(path.join(requestDir, `${staleId}.json`), JSON.stringify({
|
|
704
|
+
id: staleId,
|
|
705
|
+
operation: "start",
|
|
706
|
+
provider: "surf-oracle",
|
|
707
|
+
createdAt: Date.now(),
|
|
708
|
+
start: {
|
|
709
|
+
prompt: "prompt",
|
|
710
|
+
promptDigest: externalJobPromptDigest("prompt"),
|
|
711
|
+
cwd: dir,
|
|
712
|
+
runId: "run-local-timeout",
|
|
713
|
+
stepIndex: 0,
|
|
714
|
+
agent: "gpt-pro",
|
|
715
|
+
options: {},
|
|
716
|
+
},
|
|
717
|
+
}), "utf-8");
|
|
718
|
+
serviceExternalJobBridgeRequests(dir);
|
|
719
|
+
assert.equal(starts, 0);
|
|
720
|
+
});
|
|
721
|
+
|
|
722
|
+
it("waits for a slow start response instead of timing out without provider job id", async () => {
|
|
723
|
+
const dir = tempDir("pi-external-job-slow-start-");
|
|
724
|
+
let starts = 0;
|
|
725
|
+
let settled = false;
|
|
726
|
+
let resolveStart: ((value: { providerJobId: string; state: "completed" }) => void) | undefined;
|
|
727
|
+
registerExternalJobProvider({
|
|
728
|
+
name: "surf-oracle",
|
|
729
|
+
start: () => {
|
|
730
|
+
starts += 1;
|
|
731
|
+
return new Promise((resolve) => { resolveStart = resolve; });
|
|
732
|
+
},
|
|
733
|
+
status: () => ({ providerJobId: "unused", state: "completed" }),
|
|
734
|
+
reattach: () => ({ providerJobId: "unused", state: "completed" }),
|
|
735
|
+
result: () => ({ providerJobId: "unused", state: "completed" }),
|
|
736
|
+
});
|
|
737
|
+
const operation = requestExternalJobOperation(dir, {
|
|
738
|
+
operation: "start",
|
|
739
|
+
provider: "surf-oracle",
|
|
740
|
+
start: {
|
|
741
|
+
prompt: "prompt",
|
|
742
|
+
promptDigest: externalJobPromptDigest("prompt"),
|
|
743
|
+
cwd: dir,
|
|
744
|
+
runId: "run-slow",
|
|
745
|
+
stepIndex: 0,
|
|
746
|
+
agent: "gpt-pro",
|
|
747
|
+
options: {},
|
|
748
|
+
},
|
|
749
|
+
}, 1).finally(() => { settled = true; });
|
|
750
|
+
|
|
751
|
+
serviceExternalJobBridgeRequests(dir);
|
|
752
|
+
await new Promise((resolve) => setTimeout(resolve, 30));
|
|
753
|
+
assert.equal(starts, 1);
|
|
754
|
+
assert.equal(settled, false);
|
|
755
|
+
|
|
756
|
+
resolveStart!({ providerJobId: "job-slow", state: "completed" });
|
|
757
|
+
const result = await serviceUntil(dir, operation);
|
|
758
|
+
|
|
759
|
+
assert.equal(result.providerJobId, "job-slow");
|
|
760
|
+
assert.equal(starts, 1);
|
|
761
|
+
});
|
|
762
|
+
|
|
763
|
+
it("tolerates extra provider fields such as kind, wakeChannels, and follow", async () => {
|
|
764
|
+
const dir = tempDir("pi-external-job-extra-fields-");
|
|
765
|
+
registerExternalJobProvider({
|
|
766
|
+
name: "surf-oracle",
|
|
767
|
+
kind: "external-job",
|
|
768
|
+
wakeChannels: ["surf-oracle:finished"],
|
|
769
|
+
follow: () => { throw new Error("follow must not be called"); },
|
|
770
|
+
start: () => ({ providerJobId: "job-extra", state: "completed" }),
|
|
771
|
+
status: () => ({ providerJobId: "job-extra", state: "completed" }),
|
|
772
|
+
reattach: () => ({ providerJobId: "job-extra", state: "completed" }),
|
|
773
|
+
result: () => ({ providerJobId: "job-extra", state: "completed", output: "advisor result" }),
|
|
774
|
+
} as never);
|
|
775
|
+
|
|
776
|
+
const result = await serviceUntil(dir, requestExternalJobOperation(dir, {
|
|
777
|
+
operation: "status",
|
|
778
|
+
provider: "surf-oracle",
|
|
779
|
+
providerJobId: "job-extra",
|
|
780
|
+
}));
|
|
781
|
+
|
|
782
|
+
assert.equal(result.providerJobId, "job-extra");
|
|
783
|
+
assert.equal(result.state, "completed");
|
|
784
|
+
});
|
|
785
|
+
|
|
786
|
+
it("dispatches a provider follow-up and persists source lineage", async () => {
|
|
787
|
+
const dir = tempDir("pi-external-job-follow-up-");
|
|
788
|
+
const prompt = "ask a follow-up";
|
|
789
|
+
const promptDigest = externalJobPromptDigest(prompt);
|
|
790
|
+
const requestDigest = externalJobFollowUpRequestDigest({ provider: "surf-oracle", parentProviderJobId: "job-parent", promptDigest, options: { tier: "pro" } });
|
|
791
|
+
let followUpInput: { parentProviderJobId: string; requestId: string; requestDigest: string; promptDigest: string } | undefined;
|
|
792
|
+
registerExternalJobProvider({
|
|
793
|
+
name: "surf-oracle",
|
|
794
|
+
start: () => { throw new Error("start must not be called"); },
|
|
795
|
+
followUp: (input) => {
|
|
796
|
+
followUpInput = { parentProviderJobId: input.parentProviderJobId, requestId: input.requestId, requestDigest: input.requestDigest, promptDigest: input.promptDigest };
|
|
797
|
+
return { providerJobId: "job-child", state: "completed", conversationUrl: "https://surf.example/jobs/job-child" };
|
|
798
|
+
},
|
|
799
|
+
status: (providerJobId) => ({ providerJobId, state: "completed" }),
|
|
800
|
+
reattach: (providerJobId) => ({ providerJobId, state: "completed" }),
|
|
801
|
+
result: (providerJobId) => ({ providerJobId, state: "completed", output: "follow-up result" }),
|
|
802
|
+
});
|
|
803
|
+
|
|
804
|
+
const result = await serviceUntil(dir, runExternalJob({
|
|
805
|
+
provider: "surf-oracle",
|
|
806
|
+
options: { tier: "pro" },
|
|
807
|
+
cwd: dir,
|
|
808
|
+
prompt,
|
|
809
|
+
asyncDir: dir,
|
|
810
|
+
stepIndex: 0,
|
|
811
|
+
runId: "run-follow-up",
|
|
812
|
+
agent: "gpt-pro",
|
|
813
|
+
followUp: { sourceRunId: "run-parent", sourceStepIndex: 0, parentProviderJobId: "job-parent", requestId: externalJobFollowUpRequestId(requestDigest), requestDigest },
|
|
814
|
+
}));
|
|
815
|
+
|
|
816
|
+
assert.equal(result.exitCode, 0);
|
|
817
|
+
assert.equal(result.output, "follow-up result");
|
|
818
|
+
assert.deepEqual(followUpInput, { parentProviderJobId: "job-parent", requestId: externalJobFollowUpRequestId(requestDigest), requestDigest, promptDigest });
|
|
819
|
+
assert.equal(result.externalJob.operation, "follow-up");
|
|
820
|
+
assert.equal(result.externalJob.sourceRunId, "run-parent");
|
|
821
|
+
assert.equal(result.externalJob.sourceStepIndex, 0);
|
|
822
|
+
assert.equal(result.externalJob.parentProviderJobId, "job-parent");
|
|
823
|
+
assert.equal(result.externalJob.requestDigest, requestDigest);
|
|
824
|
+
assert.equal(result.externalJob.providerJobId, "job-child");
|
|
825
|
+
});
|
|
826
|
+
|
|
827
|
+
it("fails closed when a provider does not support follow-up", async () => {
|
|
828
|
+
const dir = tempDir("pi-external-job-follow-up-unsupported-");
|
|
829
|
+
registerExternalJobProvider({
|
|
830
|
+
name: "surf-oracle",
|
|
831
|
+
start: () => ({ providerJobId: "job-start", state: "completed" }),
|
|
832
|
+
status: (providerJobId) => ({ providerJobId, state: "completed" }),
|
|
833
|
+
reattach: (providerJobId) => ({ providerJobId, state: "completed" }),
|
|
834
|
+
result: (providerJobId) => ({ providerJobId, state: "completed" }),
|
|
835
|
+
});
|
|
836
|
+
|
|
837
|
+
const responsePromise = requestExternalJobOperation(dir, {
|
|
838
|
+
operation: "follow-up",
|
|
839
|
+
provider: "surf-oracle",
|
|
840
|
+
followUp: {
|
|
841
|
+
prompt: "prompt",
|
|
842
|
+
promptDigest: externalJobPromptDigest("prompt"),
|
|
843
|
+
cwd: dir,
|
|
844
|
+
runId: "run-follow-up-unsupported",
|
|
845
|
+
stepIndex: 0,
|
|
846
|
+
agent: "gpt-pro",
|
|
847
|
+
options: {},
|
|
848
|
+
sourceRunId: "run-parent",
|
|
849
|
+
sourceStepIndex: 0,
|
|
850
|
+
parentProviderJobId: "job-parent",
|
|
851
|
+
requestId: "request-unsupported",
|
|
852
|
+
requestDigest: "digest-unsupported",
|
|
853
|
+
},
|
|
854
|
+
});
|
|
855
|
+
await assert.rejects(serviceUntil(dir, responsePromise), /does not support follow-up/);
|
|
856
|
+
});
|
|
857
|
+
|
|
858
|
+
it("fails closed with the blocking provider job on follow-up capacity conflicts", async () => {
|
|
859
|
+
const dir = tempDir("pi-external-job-follow-up-capacity-");
|
|
860
|
+
registerExternalJobProvider({
|
|
861
|
+
name: "surf-oracle",
|
|
862
|
+
start: () => { throw new Error("start must not be called"); },
|
|
863
|
+
followUp: () => { throw new ExternalJobProviderError("Surf capacity is occupied", { code: "capacity", blockingJobId: "job-blocking" }); },
|
|
864
|
+
status: () => ({ providerJobId: "unused", state: "failed" }),
|
|
865
|
+
reattach: () => ({ providerJobId: "unused", state: "failed" }),
|
|
866
|
+
result: () => ({ providerJobId: "unused", state: "failed" }),
|
|
867
|
+
});
|
|
868
|
+
|
|
869
|
+
const result = await serviceUntil(dir, runExternalJob({
|
|
870
|
+
provider: "surf-oracle",
|
|
871
|
+
cwd: dir,
|
|
872
|
+
prompt: "prompt",
|
|
873
|
+
asyncDir: dir,
|
|
874
|
+
stepIndex: 0,
|
|
875
|
+
runId: "run-follow-up-capacity",
|
|
876
|
+
agent: "gpt-pro",
|
|
877
|
+
followUp: { sourceRunId: "run-parent", sourceStepIndex: 0, parentProviderJobId: "job-parent", requestId: "request-capacity", requestDigest: "digest-capacity" },
|
|
878
|
+
}));
|
|
879
|
+
|
|
880
|
+
assert.equal(result.exitCode, 1);
|
|
881
|
+
assert.equal(result.externalJob.state, "blocked");
|
|
882
|
+
assert.equal(result.externalJob.blockingJobId, "job-blocking");
|
|
883
|
+
assert.match(result.error ?? "", /job-blocking/);
|
|
884
|
+
});
|
|
885
|
+
|
|
886
|
+
it("does not redispatch an ambiguous follow-up without a provider job id", async () => {
|
|
887
|
+
const dir = tempDir("pi-external-job-follow-up-in-doubt-");
|
|
888
|
+
fs.writeFileSync(path.join(dir, "status.json"), JSON.stringify({
|
|
889
|
+
steps: [{
|
|
890
|
+
externalJob: {
|
|
891
|
+
provider: "surf-oracle",
|
|
892
|
+
promptDigest: externalJobPromptDigest("prompt"),
|
|
893
|
+
operation: "follow-up",
|
|
894
|
+
sourceRunId: "run-parent",
|
|
895
|
+
sourceStepIndex: 0,
|
|
896
|
+
parentProviderJobId: "job-parent",
|
|
897
|
+
requestId: "request-in-doubt",
|
|
898
|
+
requestDigest: "digest-in-doubt",
|
|
899
|
+
options: {},
|
|
900
|
+
state: "failed",
|
|
901
|
+
failureCode: "in-doubt",
|
|
902
|
+
failureMessage: "Browser submission became ambiguous.",
|
|
903
|
+
},
|
|
904
|
+
}],
|
|
905
|
+
}), "utf-8");
|
|
906
|
+
let followUps = 0;
|
|
907
|
+
registerExternalJobProvider({
|
|
908
|
+
name: "surf-oracle",
|
|
909
|
+
start: () => { throw new Error("start must not be called"); },
|
|
910
|
+
followUp: () => { followUps += 1; return { providerJobId: "job-child", state: "completed" }; },
|
|
911
|
+
status: () => ({ providerJobId: "unused", state: "completed" }),
|
|
912
|
+
reattach: () => ({ providerJobId: "unused", state: "completed" }),
|
|
913
|
+
result: () => ({ providerJobId: "unused", state: "completed" }),
|
|
914
|
+
});
|
|
915
|
+
|
|
916
|
+
const result = await runExternalJob({
|
|
917
|
+
provider: "surf-oracle",
|
|
918
|
+
cwd: dir,
|
|
919
|
+
prompt: "prompt",
|
|
920
|
+
asyncDir: dir,
|
|
921
|
+
stepIndex: 0,
|
|
922
|
+
runId: "run-follow-up-in-doubt",
|
|
923
|
+
agent: "gpt-pro",
|
|
924
|
+
followUp: { sourceRunId: "run-parent", sourceStepIndex: 0, parentProviderJobId: "job-parent", requestId: "request-in-doubt", requestDigest: "digest-in-doubt" },
|
|
925
|
+
});
|
|
926
|
+
|
|
927
|
+
assert.equal(followUps, 0);
|
|
928
|
+
assert.equal(result.exitCode, 1);
|
|
929
|
+
assert.equal(result.externalJob.failureCode, "dispatch-redispatch-blocked");
|
|
930
|
+
assert.match(result.error ?? "", /Refusing to redispatch/);
|
|
931
|
+
});
|
|
932
|
+
|
|
933
|
+
it("fails closed when the parent provider thread is missing", async () => {
|
|
934
|
+
const dir = tempDir("pi-external-job-follow-up-parent-missing-");
|
|
935
|
+
let starts = 0;
|
|
936
|
+
registerExternalJobProvider({
|
|
937
|
+
name: "surf-oracle",
|
|
938
|
+
start: () => { starts += 1; return { providerJobId: "fresh-thread", state: "completed" }; },
|
|
939
|
+
followUp: () => { throw new ExternalJobProviderError("Parent conversation is unavailable", { code: "parent-missing" }); },
|
|
940
|
+
status: () => ({ providerJobId: "unused", state: "completed" }),
|
|
941
|
+
reattach: () => ({ providerJobId: "unused", state: "completed" }),
|
|
942
|
+
result: () => ({ providerJobId: "unused", state: "completed" }),
|
|
943
|
+
});
|
|
944
|
+
|
|
945
|
+
const result = await serviceUntil(dir, runExternalJob({
|
|
946
|
+
provider: "surf-oracle",
|
|
947
|
+
cwd: dir,
|
|
948
|
+
prompt: "prompt",
|
|
949
|
+
asyncDir: dir,
|
|
950
|
+
stepIndex: 0,
|
|
951
|
+
runId: "run-follow-up-parent-missing",
|
|
952
|
+
agent: "gpt-pro",
|
|
953
|
+
followUp: { sourceRunId: "run-parent", sourceStepIndex: 0, parentProviderJobId: "job-parent", requestId: "request-parent-missing", requestDigest: "digest-parent-missing" },
|
|
954
|
+
}));
|
|
955
|
+
|
|
956
|
+
assert.equal(starts, 0);
|
|
957
|
+
assert.equal(result.exitCode, 1);
|
|
958
|
+
assert.equal(result.externalJob.failureCode, "parent-missing");
|
|
959
|
+
assert.match(result.error ?? "", /Parent conversation is unavailable/);
|
|
960
|
+
});
|
|
961
|
+
});
|