@selesai/code 0.9.11 → 0.9.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -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 +0 -1
- 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,389 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import * as fs from "node:fs";
|
|
3
|
+
import * as path from "node:path";
|
|
4
|
+
import { ExternalJobProviderError, type ExternalJobHandle, type ExternalJobResult, type ExternalJobState } from "../../api/external-job-provider.ts";
|
|
5
|
+
import type { ExternalJobStatus } from "../../shared/types.ts";
|
|
6
|
+
import { requestExternalJobOperation } from "./external-job-bridge.ts";
|
|
7
|
+
|
|
8
|
+
const STATUS_POLL_INTERVAL_MS = 1_000;
|
|
9
|
+
|
|
10
|
+
export interface ExternalJobRunResult {
|
|
11
|
+
output: string;
|
|
12
|
+
exitCode: number;
|
|
13
|
+
error?: string;
|
|
14
|
+
timedOut?: boolean;
|
|
15
|
+
stopped?: boolean;
|
|
16
|
+
externalJob: ExternalJobStatus;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function externalJobPromptDigest(prompt: string): string {
|
|
20
|
+
return createHash("sha256").update(prompt).digest("hex");
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function externalJobStableJson(value: unknown): string {
|
|
24
|
+
if (value === null || typeof value !== "object") return JSON.stringify(value);
|
|
25
|
+
if (Array.isArray(value)) return `[${value.map(externalJobStableJson).join(",")}]`;
|
|
26
|
+
const record = value as Record<string, unknown>;
|
|
27
|
+
return `{${Object.keys(record).sort().map((key) => `${JSON.stringify(key)}:${externalJobStableJson(record[key])}`).join(",")}}`;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function externalJobFollowUpRequestDigest(input: { provider: string; parentProviderJobId: string; promptDigest: string; options: Record<string, unknown> }): string {
|
|
31
|
+
return createHash("sha256")
|
|
32
|
+
.update(externalJobStableJson({ provider: input.provider, parentProviderJobId: input.parentProviderJobId, promptDigest: input.promptDigest, options: input.options }))
|
|
33
|
+
.digest("hex");
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function externalJobFollowUpRequestId(requestDigest: string): string {
|
|
37
|
+
return `follow-up-${requestDigest.slice(0, 48)}`;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function externalJobFollowUpRunId(requestDigest: string): string {
|
|
41
|
+
const hex = requestDigest.padEnd(32, "0").slice(0, 32).split("");
|
|
42
|
+
hex[12] = "4";
|
|
43
|
+
hex[16] = ((Number.parseInt(hex[16]!, 16) & 0x3) | 0x8).toString(16);
|
|
44
|
+
const value = hex.join("");
|
|
45
|
+
return `${value.slice(0, 8)}-${value.slice(8, 12)}-${value.slice(12, 16)}-${value.slice(16, 20)}-${value.slice(20, 32)}`;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function sleep(ms: number): Promise<void> {
|
|
49
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function terminal(state: ExternalJobState): boolean {
|
|
53
|
+
return state === "completed" || state === "failed" || state === "stopped" || state === "blocked";
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function formatError(error: ExternalJobProviderError, provider: string): string {
|
|
57
|
+
const blocking = error.blockingJobId ? ` Blocking provider job: ${error.blockingJobId}.` : "";
|
|
58
|
+
return `External-job provider '${provider}' failed closed (${error.code}): ${error.message}.${blocking}`;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function isNotFound(error: unknown): boolean {
|
|
62
|
+
return typeof error === "object" && error !== null && "code" in error && (error as NodeJS.ErrnoException).code === "ENOENT";
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
66
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function malformedStatus(statusPath: string): ExternalJobProviderError {
|
|
70
|
+
return new ExternalJobProviderError(`Malformed external-job status '${statusPath}'. Refusing to redispatch the prompt.`, { code: "status-unreadable" });
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function parseExternalJobStatus(value: unknown, statusPath: string): ExternalJobStatus {
|
|
74
|
+
if (!isRecord(value)) throw malformedStatus(statusPath);
|
|
75
|
+
const provider = value.provider;
|
|
76
|
+
const promptDigest = value.promptDigest;
|
|
77
|
+
const state = value.state;
|
|
78
|
+
if (typeof provider !== "string" || provider.length === 0) throw malformedStatus(statusPath);
|
|
79
|
+
if (typeof promptDigest !== "string" || promptDigest.length === 0) throw malformedStatus(statusPath);
|
|
80
|
+
if (state !== "queued" && state !== "running" && state !== "completed" && state !== "failed" && state !== "stopped" && state !== "blocked") throw malformedStatus(statusPath);
|
|
81
|
+
if (value.options !== undefined && !isRecord(value.options)) throw malformedStatus(statusPath);
|
|
82
|
+
const providerJobId = value.providerJobId;
|
|
83
|
+
const handleUrl = value.handleUrl;
|
|
84
|
+
const conversationUrl = value.conversationUrl;
|
|
85
|
+
const resultArtifactPath = value.resultArtifactPath;
|
|
86
|
+
const failureCode = value.failureCode;
|
|
87
|
+
const failureMessage = value.failureMessage;
|
|
88
|
+
const blockingJobId = value.blockingJobId;
|
|
89
|
+
const startedAt = value.startedAt;
|
|
90
|
+
const updatedAt = value.updatedAt;
|
|
91
|
+
if (providerJobId !== undefined && (typeof providerJobId !== "string" || providerJobId.length === 0)) throw malformedStatus(statusPath);
|
|
92
|
+
if (handleUrl !== undefined && typeof handleUrl !== "string") throw malformedStatus(statusPath);
|
|
93
|
+
if (conversationUrl !== undefined && typeof conversationUrl !== "string") throw malformedStatus(statusPath);
|
|
94
|
+
if (resultArtifactPath !== undefined && typeof resultArtifactPath !== "string") throw malformedStatus(statusPath);
|
|
95
|
+
if (failureCode !== undefined && typeof failureCode !== "string") throw malformedStatus(statusPath);
|
|
96
|
+
if (failureMessage !== undefined && typeof failureMessage !== "string") throw malformedStatus(statusPath);
|
|
97
|
+
if (blockingJobId !== undefined && typeof blockingJobId !== "string") throw malformedStatus(statusPath);
|
|
98
|
+
const operation = value.operation;
|
|
99
|
+
const sourceRunId = value.sourceRunId;
|
|
100
|
+
const sourceStepIndex = value.sourceStepIndex;
|
|
101
|
+
const parentProviderJobId = value.parentProviderJobId;
|
|
102
|
+
const requestId = value.requestId;
|
|
103
|
+
const requestDigest = value.requestDigest;
|
|
104
|
+
if (operation !== undefined && operation !== "start" && operation !== "follow-up") throw malformedStatus(statusPath);
|
|
105
|
+
if (sourceRunId !== undefined && (typeof sourceRunId !== "string" || sourceRunId.length === 0)) throw malformedStatus(statusPath);
|
|
106
|
+
if (sourceStepIndex !== undefined && (typeof sourceStepIndex !== "number" || !Number.isInteger(sourceStepIndex) || sourceStepIndex < 0)) throw malformedStatus(statusPath);
|
|
107
|
+
if (parentProviderJobId !== undefined && (typeof parentProviderJobId !== "string" || parentProviderJobId.length === 0)) throw malformedStatus(statusPath);
|
|
108
|
+
if (requestId !== undefined && (typeof requestId !== "string" || requestId.length === 0)) throw malformedStatus(statusPath);
|
|
109
|
+
if (requestDigest !== undefined && (typeof requestDigest !== "string" || requestDigest.length === 0)) throw malformedStatus(statusPath);
|
|
110
|
+
if (startedAt !== undefined && typeof startedAt !== "number") throw malformedStatus(statusPath);
|
|
111
|
+
if (updatedAt !== undefined && typeof updatedAt !== "number") throw malformedStatus(statusPath);
|
|
112
|
+
return {
|
|
113
|
+
provider,
|
|
114
|
+
promptDigest,
|
|
115
|
+
...(operation ? { operation } : {}),
|
|
116
|
+
...(sourceRunId ? { sourceRunId } : {}),
|
|
117
|
+
...(sourceStepIndex !== undefined ? { sourceStepIndex } : {}),
|
|
118
|
+
...(parentProviderJobId ? { parentProviderJobId } : {}),
|
|
119
|
+
...(requestId ? { requestId } : {}),
|
|
120
|
+
...(requestDigest ? { requestDigest } : {}),
|
|
121
|
+
options: value.options ?? {},
|
|
122
|
+
state,
|
|
123
|
+
...(providerJobId ? { providerJobId } : {}),
|
|
124
|
+
...(handleUrl ? { handleUrl } : {}),
|
|
125
|
+
...(conversationUrl ? { conversationUrl } : {}),
|
|
126
|
+
...(resultArtifactPath ? { resultArtifactPath } : {}),
|
|
127
|
+
...(failureCode ? { failureCode } : {}),
|
|
128
|
+
...(failureMessage ? { failureMessage } : {}),
|
|
129
|
+
...(blockingJobId ? { blockingJobId } : {}),
|
|
130
|
+
...(startedAt !== undefined ? { startedAt } : {}),
|
|
131
|
+
...(updatedAt !== undefined ? { updatedAt } : {}),
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function readExistingExternalJob(asyncDir: string, stepIndex: number): ExternalJobStatus | undefined {
|
|
136
|
+
const statusPath = path.join(asyncDir, "status.json");
|
|
137
|
+
let raw: string;
|
|
138
|
+
try {
|
|
139
|
+
raw = fs.readFileSync(statusPath, "utf-8");
|
|
140
|
+
} catch (error) {
|
|
141
|
+
if (isNotFound(error)) return undefined;
|
|
142
|
+
throw new ExternalJobProviderError(`Unreadable external-job status '${statusPath}'. Refusing to redispatch the prompt.`, { code: "status-unreadable", cause: error });
|
|
143
|
+
}
|
|
144
|
+
let parsed: unknown;
|
|
145
|
+
try {
|
|
146
|
+
parsed = JSON.parse(raw);
|
|
147
|
+
} catch (error) {
|
|
148
|
+
throw new ExternalJobProviderError(`Malformed external-job status '${statusPath}'. Refusing to redispatch the prompt.`, { code: "status-unreadable", cause: error });
|
|
149
|
+
}
|
|
150
|
+
if (!isRecord(parsed) || !Array.isArray(parsed.steps)) throw malformedStatus(statusPath);
|
|
151
|
+
const step = parsed.steps[stepIndex];
|
|
152
|
+
if (step === undefined || !isRecord(step)) throw malformedStatus(statusPath);
|
|
153
|
+
if (step.externalJob === undefined) return undefined;
|
|
154
|
+
return parseExternalJobStatus(step.externalJob, statusPath);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function externalJobLineage(followUp: ExternalJobFollowUpDescriptor | undefined, previous: ExternalJobStatus | undefined) {
|
|
158
|
+
return {
|
|
159
|
+
operation: followUp ? "follow-up" as const : previous?.operation,
|
|
160
|
+
...(followUp ? {
|
|
161
|
+
sourceRunId: followUp.sourceRunId,
|
|
162
|
+
sourceStepIndex: followUp.sourceStepIndex,
|
|
163
|
+
parentProviderJobId: followUp.parentProviderJobId,
|
|
164
|
+
requestId: followUp.requestId,
|
|
165
|
+
requestDigest: followUp.requestDigest,
|
|
166
|
+
} : {
|
|
167
|
+
...(previous?.sourceRunId ? { sourceRunId: previous.sourceRunId } : {}),
|
|
168
|
+
...(previous?.sourceStepIndex !== undefined ? { sourceStepIndex: previous.sourceStepIndex } : {}),
|
|
169
|
+
...(previous?.parentProviderJobId ? { parentProviderJobId: previous.parentProviderJobId } : {}),
|
|
170
|
+
...(previous?.requestId ? { requestId: previous.requestId } : {}),
|
|
171
|
+
...(previous?.requestDigest ? { requestDigest: previous.requestDigest } : {}),
|
|
172
|
+
}),
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function statusFromHandle(input: {
|
|
177
|
+
provider: string;
|
|
178
|
+
promptDigest: string;
|
|
179
|
+
options: Record<string, unknown>;
|
|
180
|
+
followUp?: ExternalJobFollowUpDescriptor;
|
|
181
|
+
startedAt?: number;
|
|
182
|
+
previous?: ExternalJobStatus;
|
|
183
|
+
handle: ExternalJobHandle;
|
|
184
|
+
resultArtifactPath?: string;
|
|
185
|
+
}): ExternalJobStatus {
|
|
186
|
+
return {
|
|
187
|
+
provider: input.provider,
|
|
188
|
+
providerJobId: input.handle.providerJobId,
|
|
189
|
+
promptDigest: input.promptDigest,
|
|
190
|
+
...externalJobLineage(input.followUp, input.previous),
|
|
191
|
+
options: input.options,
|
|
192
|
+
handleUrl: input.handle.handleUrl ?? input.previous?.handleUrl,
|
|
193
|
+
conversationUrl: input.handle.conversationUrl ?? input.previous?.conversationUrl,
|
|
194
|
+
resultArtifactPath: input.resultArtifactPath ?? input.previous?.resultArtifactPath,
|
|
195
|
+
state: input.handle.state,
|
|
196
|
+
failureCode: input.handle.failureCode,
|
|
197
|
+
failureMessage: input.handle.failureMessage,
|
|
198
|
+
blockingJobId: input.handle.blockingJobId,
|
|
199
|
+
startedAt: input.previous?.startedAt ?? input.startedAt,
|
|
200
|
+
updatedAt: Date.now(),
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
function failureStatus(input: {
|
|
205
|
+
provider: string;
|
|
206
|
+
promptDigest: string;
|
|
207
|
+
options: Record<string, unknown>;
|
|
208
|
+
followUp?: ExternalJobFollowUpDescriptor;
|
|
209
|
+
previous?: ExternalJobStatus;
|
|
210
|
+
code: string;
|
|
211
|
+
message: string;
|
|
212
|
+
blockingJobId?: string;
|
|
213
|
+
}): ExternalJobStatus {
|
|
214
|
+
return {
|
|
215
|
+
provider: input.provider,
|
|
216
|
+
providerJobId: input.previous?.providerJobId,
|
|
217
|
+
promptDigest: input.promptDigest,
|
|
218
|
+
...externalJobLineage(input.followUp, input.previous),
|
|
219
|
+
options: input.options,
|
|
220
|
+
handleUrl: input.previous?.handleUrl,
|
|
221
|
+
conversationUrl: input.previous?.conversationUrl,
|
|
222
|
+
resultArtifactPath: input.previous?.resultArtifactPath,
|
|
223
|
+
state: input.blockingJobId ? "blocked" : "failed",
|
|
224
|
+
failureCode: input.code,
|
|
225
|
+
failureMessage: input.message,
|
|
226
|
+
blockingJobId: input.blockingJobId,
|
|
227
|
+
startedAt: input.previous?.startedAt,
|
|
228
|
+
updatedAt: Date.now(),
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
function resultOutput(result: ExternalJobResult, artifactPath: string | undefined): string {
|
|
233
|
+
if (result.output?.trim()) return result.output.trim();
|
|
234
|
+
if (artifactPath) return `External job finished. Result artifact: ${artifactPath}`;
|
|
235
|
+
return "External job finished without text output.";
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
function blocksStartRedispatch(status: ExternalJobStatus, provider: string, promptDigest: string): boolean {
|
|
239
|
+
return status.provider === provider
|
|
240
|
+
&& status.promptDigest === promptDigest
|
|
241
|
+
&& !status.providerJobId
|
|
242
|
+
&& status.failureCode !== "provider-unavailable";
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
interface ExternalJobFollowUpDescriptor {
|
|
246
|
+
sourceRunId: string;
|
|
247
|
+
sourceStepIndex: number;
|
|
248
|
+
parentProviderJobId: string;
|
|
249
|
+
requestId: string;
|
|
250
|
+
requestDigest: string;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
function sameFollowUpLineage(status: ExternalJobStatus, followUp: ExternalJobFollowUpDescriptor | undefined): boolean {
|
|
254
|
+
if (!followUp) return status.operation !== "follow-up";
|
|
255
|
+
return status.operation === "follow-up"
|
|
256
|
+
&& status.sourceRunId === followUp.sourceRunId
|
|
257
|
+
&& status.sourceStepIndex === followUp.sourceStepIndex
|
|
258
|
+
&& status.parentProviderJobId === followUp.parentProviderJobId
|
|
259
|
+
&& status.requestId === followUp.requestId
|
|
260
|
+
&& status.requestDigest === followUp.requestDigest;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
export async function runExternalJob(input: {
|
|
264
|
+
provider: string;
|
|
265
|
+
options?: Record<string, unknown>;
|
|
266
|
+
cwd: string;
|
|
267
|
+
prompt: string;
|
|
268
|
+
asyncDir: string;
|
|
269
|
+
stepIndex: number;
|
|
270
|
+
runId: string;
|
|
271
|
+
agent: string;
|
|
272
|
+
sessionId?: string;
|
|
273
|
+
registerTimeout?: (stop: (() => void) | undefined) => void;
|
|
274
|
+
registerStop?: (stop: (() => void) | undefined) => void;
|
|
275
|
+
timeoutMessage?: string;
|
|
276
|
+
stopMessage?: string;
|
|
277
|
+
onExternalJob?: (status: ExternalJobStatus) => void;
|
|
278
|
+
followUp?: ExternalJobFollowUpDescriptor;
|
|
279
|
+
}): Promise<ExternalJobRunResult> {
|
|
280
|
+
const provider = input.provider;
|
|
281
|
+
const options = input.options ?? {};
|
|
282
|
+
const promptDigest = externalJobPromptDigest(input.prompt);
|
|
283
|
+
const startedAt = Date.now();
|
|
284
|
+
let timedOut = false;
|
|
285
|
+
let stopped = false;
|
|
286
|
+
let current: ExternalJobStatus | undefined;
|
|
287
|
+
const timeout = () => { timedOut = true; };
|
|
288
|
+
const stop = () => { stopped = true; };
|
|
289
|
+
input.registerTimeout?.(timeout);
|
|
290
|
+
input.registerStop?.(stop);
|
|
291
|
+
const publish = (status: ExternalJobStatus) => {
|
|
292
|
+
current = status;
|
|
293
|
+
input.onExternalJob?.(status);
|
|
294
|
+
};
|
|
295
|
+
const localCancellation = () => {
|
|
296
|
+
if (!timedOut && !stopped) return undefined;
|
|
297
|
+
const message = stopped
|
|
298
|
+
? input.stopMessage ?? `Subagent stopped locally before external provider '${provider}' returned a job id. The provider start may still be running.`
|
|
299
|
+
: input.timeoutMessage ?? `Subagent timed out locally before external provider '${provider}' returned a job id. The provider start may still be running.`;
|
|
300
|
+
return new ExternalJobProviderError(message, { code: stopped ? "local-stop" : "local-timeout" });
|
|
301
|
+
};
|
|
302
|
+
try {
|
|
303
|
+
current = readExistingExternalJob(input.asyncDir, input.stepIndex);
|
|
304
|
+
let handle: ExternalJobHandle;
|
|
305
|
+
if (current?.providerJobId) {
|
|
306
|
+
if (current.provider !== provider || current.promptDigest !== promptDigest || !sameFollowUpLineage(current, input.followUp)) {
|
|
307
|
+
const message = `Existing external job '${current.providerJobId}' does not match provider, prompt digest, or follow-up lineage. Refusing to redispatch prompt.`;
|
|
308
|
+
const status = failureStatus({ provider, promptDigest, options, followUp: input.followUp, previous: current, code: "recovery-mismatch", message });
|
|
309
|
+
publish(status);
|
|
310
|
+
return { output: message, exitCode: 1, error: message, externalJob: status };
|
|
311
|
+
}
|
|
312
|
+
handle = await requestExternalJobOperation<ExternalJobHandle>(input.asyncDir, { operation: "reattach", provider, providerJobId: current.providerJobId });
|
|
313
|
+
} else {
|
|
314
|
+
if (current && blocksStartRedispatch(current, provider, promptDigest)) {
|
|
315
|
+
const message = `External-job ${input.followUp ? "follow-up" : "start"} for provider '${provider}' previously ended without a durable provider job id. Refusing to redispatch the prompt automatically.`;
|
|
316
|
+
const status = failureStatus({ provider, promptDigest, options, followUp: input.followUp, previous: current, code: input.followUp ? "dispatch-redispatch-blocked" : "start-redispatch-blocked", message });
|
|
317
|
+
publish(status);
|
|
318
|
+
return { output: message, exitCode: 1, error: message, externalJob: status };
|
|
319
|
+
}
|
|
320
|
+
publish({ provider, promptDigest, ...(input.followUp ? { operation: "follow-up" as const, ...input.followUp } : {}), options, state: "queued", startedAt, updatedAt: Date.now() });
|
|
321
|
+
if (input.followUp) {
|
|
322
|
+
handle = await requestExternalJobOperation<ExternalJobHandle>(input.asyncDir, {
|
|
323
|
+
operation: "follow-up",
|
|
324
|
+
provider,
|
|
325
|
+
followUp: {
|
|
326
|
+
prompt: input.prompt,
|
|
327
|
+
promptDigest,
|
|
328
|
+
cwd: input.cwd,
|
|
329
|
+
runId: input.runId,
|
|
330
|
+
stepIndex: input.stepIndex,
|
|
331
|
+
agent: input.agent,
|
|
332
|
+
options,
|
|
333
|
+
...(input.sessionId ? { sessionId: input.sessionId } : {}),
|
|
334
|
+
...input.followUp,
|
|
335
|
+
},
|
|
336
|
+
}, undefined, localCancellation);
|
|
337
|
+
} else {
|
|
338
|
+
handle = await requestExternalJobOperation<ExternalJobHandle>(input.asyncDir, {
|
|
339
|
+
operation: "start",
|
|
340
|
+
provider,
|
|
341
|
+
start: {
|
|
342
|
+
prompt: input.prompt,
|
|
343
|
+
promptDigest,
|
|
344
|
+
cwd: input.cwd,
|
|
345
|
+
runId: input.runId,
|
|
346
|
+
stepIndex: input.stepIndex,
|
|
347
|
+
agent: input.agent,
|
|
348
|
+
options,
|
|
349
|
+
...(input.sessionId ? { sessionId: input.sessionId } : {}),
|
|
350
|
+
},
|
|
351
|
+
}, undefined, localCancellation);
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
publish(statusFromHandle({ provider, promptDigest, options, followUp: input.followUp, startedAt, previous: current, handle }));
|
|
355
|
+
while (!terminal(handle.state)) {
|
|
356
|
+
if (timedOut || stopped) {
|
|
357
|
+
const message = stopped
|
|
358
|
+
? input.stopMessage ?? `Subagent stopped locally; external provider job '${handle.providerJobId}' may still be running.`
|
|
359
|
+
: input.timeoutMessage ?? `Subagent timed out locally; external provider job '${handle.providerJobId}' may still be running.`;
|
|
360
|
+
return { output: message, exitCode: 1, error: message, ...(timedOut ? { timedOut: true } : {}), ...(stopped ? { stopped: true } : {}), externalJob: current! };
|
|
361
|
+
}
|
|
362
|
+
await sleep(STATUS_POLL_INTERVAL_MS);
|
|
363
|
+
handle = await requestExternalJobOperation<ExternalJobHandle>(input.asyncDir, { operation: "status", provider, providerJobId: handle.providerJobId });
|
|
364
|
+
publish(statusFromHandle({ provider, promptDigest, options, followUp: input.followUp, previous: current, handle }));
|
|
365
|
+
}
|
|
366
|
+
const result = await requestExternalJobOperation<ExternalJobResult>(input.asyncDir, { operation: "result", provider, providerJobId: handle.providerJobId });
|
|
367
|
+
let artifactPath = result.artifactPath;
|
|
368
|
+
if (!artifactPath && result.output !== undefined) {
|
|
369
|
+
artifactPath = path.join(input.asyncDir, `external-job-${input.stepIndex}.result.md`);
|
|
370
|
+
fs.writeFileSync(artifactPath, result.output, "utf-8");
|
|
371
|
+
}
|
|
372
|
+
const finalStatus = statusFromHandle({ provider, promptDigest, options, followUp: input.followUp, previous: current, handle: result, resultArtifactPath: artifactPath });
|
|
373
|
+
publish(finalStatus);
|
|
374
|
+
const output = resultOutput(result, artifactPath);
|
|
375
|
+
const error = result.state === "completed" ? undefined : result.failureMessage ?? `External job ${result.state}.`;
|
|
376
|
+
return { output, exitCode: result.state === "completed" ? 0 : 1, ...(error ? { error } : {}), externalJob: finalStatus };
|
|
377
|
+
} catch (error) {
|
|
378
|
+
const providerError = error instanceof ExternalJobProviderError
|
|
379
|
+
? error
|
|
380
|
+
: new ExternalJobProviderError(error instanceof Error ? error.message : String(error), { code: "provider-error", cause: error });
|
|
381
|
+
const message = formatError(providerError, provider);
|
|
382
|
+
const status = failureStatus({ provider, promptDigest, options, followUp: input.followUp, previous: current, code: providerError.code, message, ...(providerError.blockingJobId ? { blockingJobId: providerError.blockingJobId } : {}) });
|
|
383
|
+
publish(status);
|
|
384
|
+
return { output: message, exitCode: 1, error: message, ...(timedOut ? { timedOut: true } : {}), ...(stopped ? { stopped: true } : {}), externalJob: status };
|
|
385
|
+
} finally {
|
|
386
|
+
input.registerTimeout?.(undefined);
|
|
387
|
+
input.registerStop?.(undefined);
|
|
388
|
+
}
|
|
389
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ExtensionAPI } from "@selesai/code";
|
|
2
|
+
|
|
3
|
+
function withPriorityServiceTier(payload: unknown): unknown {
|
|
4
|
+
if (!payload || typeof payload !== "object" || Array.isArray(payload)) return payload;
|
|
5
|
+
return { ...payload, service_tier: "priority" };
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export default function registerSubagentFastModeExtension(pi: ExtensionAPI): void {
|
|
9
|
+
pi.on("before_provider_request", (event) => ({ payload: withPriorityServiceTier(event.payload) }));
|
|
10
|
+
}
|
|
@@ -32,6 +32,12 @@ interface ServerEntry {
|
|
|
32
32
|
cwd?: string;
|
|
33
33
|
url?: string;
|
|
34
34
|
headers?: Record<string, string>;
|
|
35
|
+
requestHeadersCommand?: {
|
|
36
|
+
command: string;
|
|
37
|
+
args?: string[];
|
|
38
|
+
env?: Record<string, string>;
|
|
39
|
+
timeoutMs?: number;
|
|
40
|
+
};
|
|
35
41
|
auth?: "oauth" | "bearer" | false;
|
|
36
42
|
bearerToken?: string;
|
|
37
43
|
bearerTokenEnv?: string;
|
|
@@ -279,6 +285,14 @@ export function computeMcpServerHash(definition: ServerEntry): string {
|
|
|
279
285
|
cwd: resolveConfigPath(definition.cwd),
|
|
280
286
|
url: resolveServerUrl(definition),
|
|
281
287
|
headers: interpolateEnvRecord(definition.headers),
|
|
288
|
+
requestHeadersCommand: definition.requestHeadersCommand
|
|
289
|
+
? {
|
|
290
|
+
command: interpolateEnvVars(definition.requestHeadersCommand.command),
|
|
291
|
+
args: definition.requestHeadersCommand.args?.map(interpolateEnvVars),
|
|
292
|
+
env: interpolateEnvRecord(definition.requestHeadersCommand.env),
|
|
293
|
+
timeoutMs: definition.requestHeadersCommand.timeoutMs,
|
|
294
|
+
}
|
|
295
|
+
: undefined,
|
|
282
296
|
auth: definition.auth,
|
|
283
297
|
bearerToken: resolveBearerToken(definition),
|
|
284
298
|
bearerTokenEnv: definition.bearerTokenEnv,
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
import * as fs from "node:fs";
|
|
2
|
+
import * as path from "node:path";
|
|
3
|
+
import { splitKnownThinkingSuffix } from "../../shared/model-info.ts";
|
|
4
|
+
import { TEMP_ROOT_DIR } from "../../shared/types.ts";
|
|
5
|
+
|
|
6
|
+
export const EXCLUSIONS_PATH_ENV = "PI_MODEL_EXCLUSIONS_PATH";
|
|
7
|
+
|
|
8
|
+
type ModelExclusionTarget = { modelId: string; provider?: string } | { provider: string; modelId?: never };
|
|
9
|
+
|
|
10
|
+
export type ModelExclusion = ModelExclusionTarget & {
|
|
11
|
+
reason?: string;
|
|
12
|
+
recordedAt: number;
|
|
13
|
+
expiresAt: number;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
type RecordModelFailureOptions = ModelExclusionTarget & {
|
|
17
|
+
reason?: string;
|
|
18
|
+
ttlMs?: number;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
let exclusions: ModelExclusion[] = [];
|
|
22
|
+
let loaded = false;
|
|
23
|
+
let defaultTTLMs = 24 * 60 * 60_000; // 24 hours, overridable via setDefaultTTL
|
|
24
|
+
let persistTimer: ReturnType<typeof setTimeout> | null = null;
|
|
25
|
+
let persistSeq = 0;
|
|
26
|
+
|
|
27
|
+
/** Override the default exclusion TTL. */
|
|
28
|
+
export function setDefaultTTL(ms: number): void {
|
|
29
|
+
if (!Number.isFinite(ms) || ms <= 0) throw new Error("Default model exclusion TTL must be a finite positive number.");
|
|
30
|
+
defaultTTLMs = ms;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Resolve the persistence path. Honors PI_MODEL_EXCLUSIONS_PATH; defaults to
|
|
35
|
+
* <TEMP_ROOT_DIR>/model-exclusions.json. Resolved lazily so tests can point the
|
|
36
|
+
* store at an isolated location after module load.
|
|
37
|
+
*/
|
|
38
|
+
export function getExclusionsFilePath(): string {
|
|
39
|
+
const envPath = process.env[EXCLUSIONS_PATH_ENV];
|
|
40
|
+
if (typeof envPath === "string" && envPath.trim()) return envPath.trim();
|
|
41
|
+
return path.join(TEMP_ROOT_DIR, "model-exclusions.json");
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Persist exclusions to disk immediately (atomic write via tmp + rename).
|
|
46
|
+
* The store otherwise debounces writes; call this when durability matters
|
|
47
|
+
* (and in tests).
|
|
48
|
+
*/
|
|
49
|
+
export function flushPersist(): void {
|
|
50
|
+
const file = getExclusionsFilePath();
|
|
51
|
+
try {
|
|
52
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
53
|
+
const tmpPath = `${file}.${process.pid}.${persistSeq++}.tmp`;
|
|
54
|
+
fs.writeFileSync(tmpPath, JSON.stringify({
|
|
55
|
+
version: 1,
|
|
56
|
+
exclusions: deduplicate(exclusions),
|
|
57
|
+
}, null, 2), "utf-8");
|
|
58
|
+
fs.renameSync(tmpPath, file);
|
|
59
|
+
} catch (error) {
|
|
60
|
+
console.error(`[model-exclusions] Failed to persist exclusions to ${file}:`, error);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function schedulePersist(): void {
|
|
65
|
+
if (persistTimer) clearTimeout(persistTimer);
|
|
66
|
+
persistTimer = setTimeout(() => {
|
|
67
|
+
persistTimer = null;
|
|
68
|
+
flushPersist();
|
|
69
|
+
}, 5000);
|
|
70
|
+
// Never hold the process open just to flush exclusions.
|
|
71
|
+
persistTimer.unref?.();
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function ensureLoaded(): void {
|
|
75
|
+
if (loaded) return;
|
|
76
|
+
loaded = true;
|
|
77
|
+
try {
|
|
78
|
+
const raw = fs.readFileSync(getExclusionsFilePath(), "utf-8");
|
|
79
|
+
const data = JSON.parse(raw);
|
|
80
|
+
if (data.version === 1) {
|
|
81
|
+
const now = Date.now();
|
|
82
|
+
exclusions = (data.exclusions ?? []).filter((e: ModelExclusion) => e.expiresAt > now);
|
|
83
|
+
exclusions = deduplicate(exclusions);
|
|
84
|
+
}
|
|
85
|
+
} catch (error) {
|
|
86
|
+
if ((error as NodeJS.ErrnoException).code !== "ENOENT") {
|
|
87
|
+
console.error(`[model-exclusions] Failed to load exclusions from ${getExclusionsFilePath()}:`, error);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function dedupKey(entry: ModelExclusion): string {
|
|
93
|
+
return `${entry.provider ?? ""}|${entry.modelId ?? ""}`;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function deduplicate(items: ModelExclusion[]): ModelExclusion[] {
|
|
97
|
+
const map = new Map<string, ModelExclusion>();
|
|
98
|
+
for (const entry of items) {
|
|
99
|
+
const key = dedupKey(entry);
|
|
100
|
+
const existing = map.get(key);
|
|
101
|
+
if (!existing || entry.recordedAt > existing.recordedAt) {
|
|
102
|
+
map.set(key, entry);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return Array.from(map.values());
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Record a model failure as a temporary exclusion. While the exclusion is
|
|
110
|
+
* active, {@link isExcluded} returns true for the model (or for every model of
|
|
111
|
+
* the provider when modelId is omitted), and {@link filterFallbackCandidates}
|
|
112
|
+
* removes matching candidates from fallback lists.
|
|
113
|
+
*/
|
|
114
|
+
export function recordModelFailure(options: RecordModelFailureOptions): void {
|
|
115
|
+
ensureLoaded();
|
|
116
|
+
const ttl = options.ttlMs ?? defaultTTLMs;
|
|
117
|
+
const now = Date.now();
|
|
118
|
+
const target: ModelExclusionTarget = options.modelId !== undefined
|
|
119
|
+
? { modelId: options.modelId, ...(options.provider ? { provider: options.provider } : {}) }
|
|
120
|
+
: { provider: options.provider };
|
|
121
|
+
const exclusion: ModelExclusion = {
|
|
122
|
+
...target,
|
|
123
|
+
reason: options.reason ?? "runtime-failure",
|
|
124
|
+
recordedAt: now,
|
|
125
|
+
expiresAt: now + ttl,
|
|
126
|
+
};
|
|
127
|
+
exclusions.unshift(exclusion);
|
|
128
|
+
exclusions = deduplicate(exclusions);
|
|
129
|
+
if (exclusions.length > 200) exclusions.length = 200;
|
|
130
|
+
flushPersist();
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Drop all expired exclusions from memory and schedule a persist.
|
|
135
|
+
*/
|
|
136
|
+
export function clearExpiredExclusions(): void {
|
|
137
|
+
ensureLoaded();
|
|
138
|
+
prune(exclusions, Date.now());
|
|
139
|
+
schedulePersist();
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Remove every exclusion (e.g. after the operator fixes credentials).
|
|
144
|
+
*/
|
|
145
|
+
export function clearExclusions(): void {
|
|
146
|
+
ensureLoaded();
|
|
147
|
+
exclusions.length = 0;
|
|
148
|
+
schedulePersist();
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Whether an exclusion entry matches a candidate.
|
|
153
|
+
*
|
|
154
|
+
* Semantics:
|
|
155
|
+
* - Entry with modelId: model-specific exclusion. Matches only that modelId;
|
|
156
|
+
* when both the entry and the candidate carry a provider, the providers must
|
|
157
|
+
* also agree so `openai/gpt-4` does not exclude `github-copilot/gpt-4`.
|
|
158
|
+
* - Entry without modelId: provider-wide exclusion (e.g. quota or auth failure).
|
|
159
|
+
* Matches every model of that provider.
|
|
160
|
+
*/
|
|
161
|
+
function entryMatches(entry: ModelExclusion, candidateModelId: string, candidateProvider: string | undefined, now: number): boolean {
|
|
162
|
+
if (entry.expiresAt <= now) return false;
|
|
163
|
+
if (entry.modelId) {
|
|
164
|
+
if (entry.modelId !== candidateModelId) return false;
|
|
165
|
+
return !entry.provider || !candidateProvider || entry.provider === candidateProvider;
|
|
166
|
+
}
|
|
167
|
+
return Boolean(entry.provider) && entry.provider === candidateProvider;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Whether a model (or its provider) is currently excluded.
|
|
172
|
+
*/
|
|
173
|
+
export function isExcluded(modelId: string, provider: string): boolean {
|
|
174
|
+
ensureLoaded();
|
|
175
|
+
return exclusions.some((entry) => entryMatches(entry, modelId, provider, Date.now()));
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Number of live (non-expired) exclusions.
|
|
180
|
+
*/
|
|
181
|
+
export function getExcludedCount(): number {
|
|
182
|
+
ensureLoaded();
|
|
183
|
+
clearExpiredExclusions();
|
|
184
|
+
return exclusions.length;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Split a candidate fullId into its provider + modelId components.
|
|
189
|
+
*
|
|
190
|
+
* A fullId may carry a thinking suffix (`provider/model:thinking`) which is
|
|
191
|
+
* stripped before parsing, and the modelId itself may contain slashes
|
|
192
|
+
* (e.g. `openrouter/google/gemini-flash`). The first `/`-segment is the
|
|
193
|
+
* provider; everything after is the modelId. This MUST stay in lock-step with
|
|
194
|
+
* the matching inside {@link isExcluded} so that a failure recorded via
|
|
195
|
+
* {@link recordModelFailure} is later recognised by the candidate filter.
|
|
196
|
+
*/
|
|
197
|
+
export function parseModelKey(fullId: string): { provider?: string; modelId: string } {
|
|
198
|
+
const base = splitKnownThinkingSuffix(fullId).baseModel;
|
|
199
|
+
if (!base.includes("/")) return { modelId: base };
|
|
200
|
+
const slash = base.indexOf("/");
|
|
201
|
+
return { provider: base.slice(0, slash), modelId: base.slice(slash + 1) };
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Filter a list of candidate fullIds, removing excluded models/providers and
|
|
206
|
+
* duplicates while preserving order.
|
|
207
|
+
*/
|
|
208
|
+
export function filterFallbackCandidates(candidates: string[], opts?: { now?: number }): string[] {
|
|
209
|
+
ensureLoaded();
|
|
210
|
+
const timestamp = opts?.now ?? Date.now();
|
|
211
|
+
const seen = new Set<string>();
|
|
212
|
+
const filtered: string[] = [];
|
|
213
|
+
for (const raw of candidates) {
|
|
214
|
+
if (!raw || seen.has(raw)) continue;
|
|
215
|
+
const { provider: candidateProvider, modelId: candidateModelId } = parseModelKey(raw);
|
|
216
|
+
const excluded = exclusions.some((entry) => entryMatches(entry, candidateModelId, candidateProvider, timestamp));
|
|
217
|
+
if (excluded) continue;
|
|
218
|
+
seen.add(raw);
|
|
219
|
+
filtered.push(raw);
|
|
220
|
+
}
|
|
221
|
+
return filtered;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Reload exclusions from disk (for tests and config hot-reload).
|
|
226
|
+
* Discards any in-memory-only exclusions that were not yet persisted.
|
|
227
|
+
*/
|
|
228
|
+
export function reloadFromDisk(): void {
|
|
229
|
+
loaded = false;
|
|
230
|
+
exclusions = [];
|
|
231
|
+
ensureLoaded();
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
function prune(items: ModelExclusion[], now: number): void {
|
|
235
|
+
let write = 0;
|
|
236
|
+
for (let i = 0; i < items.length; i++) {
|
|
237
|
+
const entry = items[i]!;
|
|
238
|
+
if (entry.expiresAt > now) {
|
|
239
|
+
items[write++] = entry;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
items.length = write;
|
|
243
|
+
}
|