@selesai/code 0.13.15 → 0.13.18
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 +37 -0
- package/README.md +2 -14
- package/dist/bun/cli.d.ts +3 -1
- package/dist/bun/cli.js +3 -9
- package/dist/bun/{register-bedrock.js → runtime-setup.js} +5 -0
- package/dist/bun/sandbox-env-setup.d.ts +1 -0
- package/dist/bun/sandbox-env-setup.js +3 -0
- package/dist/cli/auth-command.d.ts +23 -0
- package/dist/cli/auth-command.js +102 -0
- package/dist/cli/config-selector.js +2 -1
- package/dist/cli/setup.d.ts +1 -0
- package/dist/cli/setup.js +11 -0
- package/dist/cli.js +2 -14
- package/dist/config.d.ts +3 -2
- package/dist/config.js +9 -4
- package/dist/core/agent-session-runtime.js +15 -7
- package/dist/core/agent-session.d.ts +2 -6
- package/dist/core/agent-session.js +15 -4
- package/dist/core/compaction/branch-summarization.d.ts +1 -1
- package/dist/core/compaction/branch-summarization.js +2 -1
- package/dist/core/extensions/loader.js +3 -0
- package/dist/core/extensions/types.d.ts +16 -2
- package/dist/core/http-dispatcher.js +2 -0
- package/dist/core/keybindings.d.ts +5 -0
- package/dist/core/keybindings.js +4 -0
- package/dist/core/messages.d.ts +1 -1
- package/dist/core/model-config.d.ts +15 -0
- package/dist/core/model-config.js +3 -0
- package/dist/core/model-runtime.d.ts +1 -0
- package/dist/core/model-runtime.js +5 -2
- package/dist/core/provider-composer.js +8 -2
- package/dist/core/session-export.d.ts +3 -0
- package/dist/core/session-export.js +31 -0
- package/dist/core/session-manager.d.ts +3 -2
- package/dist/core/session-manager.js +40 -13
- package/dist/core/skills.d.ts +1 -1
- package/dist/core/skills.js +4 -2
- package/dist/core/system-prompt.js +10 -10
- package/dist/core/tools/bash.js +3 -117
- package/dist/core/tools/edit.d.ts +1 -12
- package/dist/core/tools/edit.js +5 -163
- package/dist/core/tools/find.js +4 -55
- package/dist/core/tools/grep.js +4 -60
- package/dist/core/tools/ls.js +4 -49
- package/dist/core/tools/read.d.ts +4 -0
- package/dist/core/tools/read.js +10 -122
- package/dist/core/tools/renderers/bash.d.ts +11 -0
- package/dist/core/tools/renderers/bash.js +129 -0
- package/dist/core/tools/renderers/edit.d.ts +22 -0
- package/dist/core/tools/renderers/edit.js +166 -0
- package/dist/core/tools/renderers/find.d.ts +9 -0
- package/dist/core/tools/renderers/find.js +63 -0
- package/dist/core/tools/renderers/grep.d.ts +9 -0
- package/dist/core/tools/renderers/grep.js +68 -0
- package/dist/core/tools/renderers/index.d.ts +27 -0
- package/dist/core/tools/renderers/index.js +46 -0
- package/dist/core/tools/renderers/ls.d.ts +9 -0
- package/dist/core/tools/renderers/ls.js +57 -0
- package/dist/core/tools/renderers/read.d.ts +10 -0
- package/dist/core/tools/renderers/read.js +128 -0
- package/dist/core/tools/renderers/write.d.ts +9 -0
- package/dist/core/tools/renderers/write.js +152 -0
- package/dist/core/tools/write.js +5 -146
- package/dist/extensions/capability-gateway/index.ts +12 -1
- package/dist/extensions/capability-gateway/integration.test.ts +23 -0
- package/dist/extensions/pi-hermes-memory/CHANGELOG.md +18 -0
- package/dist/extensions/pi-hermes-memory/README.md +16 -12
- package/dist/extensions/pi-hermes-memory/docs/ROADMAP.md +1 -1
- package/dist/extensions/pi-hermes-memory/package-lock.json +587 -62
- package/dist/extensions/pi-hermes-memory/package.json +4 -4
- package/dist/extensions/pi-hermes-memory/src/config.ts +32 -0
- package/dist/extensions/pi-hermes-memory/src/constants.ts +12 -2
- package/dist/extensions/pi-hermes-memory/src/handlers/background-review.ts +109 -51
- package/dist/extensions/pi-hermes-memory/src/handlers/index-sessions.ts +9 -3
- package/dist/extensions/pi-hermes-memory/src/handlers/review-memory-ops.ts +257 -98
- package/dist/extensions/pi-hermes-memory/src/handlers/session-backfill.ts +9 -2
- package/dist/extensions/pi-hermes-memory/src/handlers/sync-markdown-memories.ts +5 -0
- package/dist/extensions/pi-hermes-memory/src/index.ts +22 -2
- package/dist/extensions/pi-hermes-memory/src/paths.ts +1 -1
- package/dist/extensions/pi-hermes-memory/src/store/db.ts +6 -0
- package/dist/extensions/pi-hermes-memory/src/store/fts-query.ts +58 -1
- package/dist/extensions/pi-hermes-memory/src/store/memory-store.ts +60 -8
- package/dist/extensions/pi-hermes-memory/src/store/session-indexer.ts +169 -7
- package/dist/extensions/pi-hermes-memory/src/store/session-search.ts +7 -21
- package/dist/extensions/pi-hermes-memory/src/store/sqlite-memory-store.ts +134 -15
- package/dist/extensions/pi-hermes-memory/src/tools/memory-search-tool.ts +4 -2
- package/dist/extensions/pi-hermes-memory/src/tools/memory-tool.ts +24 -9
- package/dist/extensions/pi-hermes-memory/src/types.ts +11 -0
- package/dist/extensions/pi-hermes-memory/tests/config.test.ts +42 -0
- package/dist/extensions/pi-hermes-memory/tests/handlers/background-review.test.ts +159 -3
- package/dist/extensions/pi-hermes-memory/tests/handlers/review-memory-ops.test.ts +452 -0
- package/dist/extensions/pi-hermes-memory/tests/handlers/session-backfill.test.ts +39 -0
- package/dist/extensions/pi-hermes-memory/tests/integration/corruption-recovery-integration.test.ts +91 -0
- package/dist/extensions/pi-hermes-memory/tests/store/db.test.ts +29 -0
- package/dist/extensions/pi-hermes-memory/tests/store/fts-query.test.ts +116 -0
- package/dist/extensions/pi-hermes-memory/tests/store/memory-store.test.ts +163 -0
- package/dist/extensions/pi-hermes-memory/tests/store/session-indexer.test.ts +233 -0
- package/dist/extensions/pi-hermes-memory/tests/store/session-search.test.ts +12 -0
- package/dist/extensions/pi-hermes-memory/tests/store/sqlite-memory-store.test.ts +175 -0
- package/dist/extensions/pi-hermes-memory/tests/store/sqlite-native.test.ts +2 -2
- package/dist/extensions/pi-hermes-memory/tests/tools/memory-search-tool.test.ts +22 -0
- package/dist/extensions/pi-hermes-memory/tests/tools/memory-tool.test.ts +37 -1
- package/dist/extensions/pi-intercom/CHANGELOG.md +13 -0
- package/dist/extensions/pi-intercom/README.md +16 -2
- package/dist/extensions/pi-intercom/broker/spawn.test.ts +19 -2
- package/dist/extensions/pi-intercom/broker/spawn.ts +4 -4
- package/dist/extensions/pi-intercom/index.ts +1 -1
- package/dist/extensions/pi-intercom/intercom.integration.test.ts +121 -2
- package/dist/extensions/pi-intercom/package.json +1 -1
- package/dist/extensions/pi-intercom/project-agent.test.ts +1 -1
- package/dist/extensions/pi-intercom/project-agent.ts +1 -6
- package/dist/extensions/pi-intercom/skills/pi-intercom/SKILL.md +7 -6
- package/dist/extensions/pi-rewind-hook/index.test.ts +7 -0
- package/dist/extensions/pi-subagents/.github/workflows/test.yml +36 -4
- package/dist/extensions/pi-subagents/CHANGELOG.md +120 -0
- package/dist/extensions/pi-subagents/README.md +3 -3
- package/dist/extensions/pi-subagents/agents/researcher.md +23 -13
- package/dist/extensions/pi-subagents/agents/reviewer.md +1 -1
- package/dist/extensions/pi-subagents/agents/scout.md +1 -1
- package/dist/extensions/pi-subagents/docs/agents.md +32 -16
- package/dist/extensions/pi-subagents/docs/configuration.md +41 -15
- package/dist/extensions/pi-subagents/docs/extension-api.md +109 -6
- package/dist/extensions/pi-subagents/docs/missions.md +2 -0
- package/dist/extensions/pi-subagents/docs/models.md +58 -1
- package/dist/extensions/pi-subagents/docs/observability.md +50 -12
- package/dist/extensions/pi-subagents/docs/tool-reference.md +17 -10
- package/dist/extensions/pi-subagents/docs/watchdog.md +1 -1
- package/dist/extensions/pi-subagents/docs/workflows.md +26 -9
- package/dist/extensions/pi-subagents/package-lock.json +747 -177
- package/dist/extensions/pi-subagents/package.json +6 -4
- package/dist/extensions/pi-subagents/runner-server-preload.mjs +13 -0
- package/dist/extensions/pi-subagents/skills/pi-subagents/SKILL.md +2 -1
- package/dist/extensions/pi-subagents/skills/pi-subagents/references/constraints-and-recipes.md +1 -1
- package/dist/extensions/pi-subagents/skills/pi-subagents/references/execution-controls.md +21 -4
- package/dist/extensions/pi-subagents/skills/pi-subagents/references/management-authoring-rpc.md +2 -1
- package/dist/extensions/pi-subagents/skills/pi-subagents/references/multi-lane-orchestration.md +2 -0
- package/dist/extensions/pi-subagents/src/agents/advertised-agent-prompt.ts +63 -0
- package/dist/extensions/pi-subagents/src/agents/agent-management.ts +61 -16
- package/dist/extensions/pi-subagents/src/agents/agent-serializer.ts +2 -0
- package/dist/extensions/pi-subagents/src/agents/agents.ts +8 -0
- package/dist/extensions/pi-subagents/src/api/capability-ceiling.ts +0 -1
- package/dist/extensions/pi-subagents/src/api/{pi-args.ts → child-tool-plan.ts} +1 -1
- package/dist/extensions/pi-subagents/src/api/preflight.ts +7 -4
- package/dist/extensions/pi-subagents/src/api/shared-types.ts +2 -2
- package/dist/extensions/pi-subagents/src/api/workflow-resources.ts +6 -0
- package/dist/extensions/pi-subagents/src/extension/config.ts +4 -2
- package/dist/extensions/pi-subagents/src/extension/doctor.ts +2 -10
- package/dist/extensions/pi-subagents/src/extension/fanout-child.ts +9 -11
- package/dist/extensions/pi-subagents/src/extension/index.ts +99 -10
- package/dist/extensions/pi-subagents/src/extension/public-execution.ts +13 -0
- package/dist/extensions/pi-subagents/src/extension/rpc.ts +7 -23
- package/dist/extensions/pi-subagents/src/extension/schemas.ts +11 -8
- package/dist/extensions/pi-subagents/src/extension/tool-description.ts +25 -7
- package/dist/extensions/pi-subagents/src/integrations/pi-web-session-liveness.ts +73 -0
- package/dist/extensions/pi-subagents/src/intercom/native-supervisor-channel.ts +228 -136
- package/dist/extensions/pi-subagents/src/intercom/supervisor-ui.ts +244 -0
- package/dist/extensions/pi-subagents/src/missions/workflow-state.ts +37 -16
- package/dist/extensions/pi-subagents/src/runs/background/active-async-capacity.ts +18 -18
- package/dist/extensions/pi-subagents/src/runs/background/async-execution.ts +51 -25
- package/dist/extensions/pi-subagents/src/runs/background/async-job-tracker.ts +46 -3
- package/dist/extensions/pi-subagents/src/runs/background/async-resume.ts +14 -3
- package/dist/extensions/pi-subagents/src/runs/background/async-retention.ts +9 -0
- package/dist/extensions/pi-subagents/src/runs/background/async-status-snapshot.ts +10 -12
- package/dist/extensions/pi-subagents/src/runs/background/async-status.ts +18 -15
- package/dist/extensions/pi-subagents/src/runs/background/auto-drain.ts +40 -29
- package/dist/extensions/pi-subagents/src/runs/background/chain-root-attachment.ts +8 -0
- package/dist/extensions/pi-subagents/src/runs/background/control-channel.ts +79 -247
- package/dist/extensions/pi-subagents/src/runs/background/notify.ts +88 -12
- package/dist/extensions/pi-subagents/src/runs/background/owned-process-tree.ts +6 -6
- package/dist/extensions/pi-subagents/src/runs/background/process-terminal.ts +24 -24
- package/dist/extensions/pi-subagents/src/runs/background/retained-nested-route-tracker.ts +96 -0
- package/dist/extensions/pi-subagents/src/runs/background/run-child-session.ts +642 -0
- package/dist/extensions/pi-subagents/src/runs/background/run-status.ts +75 -6
- package/dist/extensions/pi-subagents/src/runs/background/runner-aliases.ts +163 -0
- package/dist/extensions/pi-subagents/src/runs/background/runner-child-launch.ts +86 -0
- package/dist/extensions/pi-subagents/src/runs/background/runner-child-sessions.ts +31 -0
- package/dist/extensions/pi-subagents/src/runs/background/scheduled-runs.ts +18 -4
- package/dist/extensions/pi-subagents/src/runs/background/stale-run-reconciler.ts +3 -1
- package/dist/extensions/pi-subagents/src/runs/background/subagent-runner.ts +597 -1092
- package/dist/extensions/pi-subagents/src/runs/background/subagent-wait.ts +3 -0
- package/dist/extensions/pi-subagents/src/runs/background/wait-completions.ts +4 -0
- package/dist/extensions/pi-subagents/src/runs/foreground/async-steering-action.ts +20 -17
- package/dist/extensions/pi-subagents/src/runs/foreground/execution.ts +296 -394
- package/dist/extensions/pi-subagents/src/runs/foreground/foreground-control.ts +4 -0
- package/dist/extensions/pi-subagents/src/runs/foreground/foreground-history.ts +3 -1
- package/dist/extensions/pi-subagents/src/runs/foreground/prompt-audit.ts +9 -5
- package/dist/extensions/pi-subagents/src/runs/foreground/subagent-executor.ts +630 -283
- package/dist/extensions/pi-subagents/src/runs/foreground/workflow-detach-reconcile.ts +8 -5
- package/dist/extensions/pi-subagents/src/runs/foreground/workflow-foreground-steering.ts +78 -98
- package/dist/extensions/pi-subagents/src/runs/shared/abort-recovery.ts +3 -3
- package/dist/extensions/pi-subagents/src/runs/shared/acceptance.ts +16 -3
- package/dist/extensions/pi-subagents/src/runs/shared/agent-contract.ts +1 -1
- package/dist/extensions/pi-subagents/src/runs/shared/async-status-projection.ts +47 -47
- package/dist/extensions/pi-subagents/src/runs/shared/capability-ceiling.ts +1 -2
- package/dist/extensions/pi-subagents/src/runs/shared/child-hooks.ts +174 -0
- package/dist/extensions/pi-subagents/src/runs/shared/child-identity.ts +14 -3
- package/dist/extensions/pi-subagents/src/runs/shared/child-launch.ts +319 -0
- package/dist/extensions/pi-subagents/src/runs/shared/child-lifecycle.ts +25 -0
- package/dist/extensions/pi-subagents/src/runs/shared/child-runtime-config.ts +126 -0
- package/dist/extensions/pi-subagents/src/runs/shared/child-session.ts +373 -0
- package/dist/extensions/pi-subagents/src/runs/shared/child-tool-plan.ts +530 -0
- package/dist/extensions/pi-subagents/src/runs/shared/completion-evidence.ts +2 -2
- package/dist/extensions/pi-subagents/src/runs/shared/completion-guard.ts +2 -1
- package/dist/extensions/pi-subagents/src/runs/shared/external-cli-preflight.ts +16 -0
- package/dist/extensions/pi-subagents/src/runs/shared/host-step-status.ts +11 -11
- package/dist/extensions/pi-subagents/src/runs/shared/llm-intent-arbiter.ts +30 -20
- package/dist/extensions/pi-subagents/src/runs/shared/mcp-direct-tool-allowlist.ts +5 -4
- package/dist/extensions/pi-subagents/src/runs/shared/model-exclusions.ts +84 -15
- package/dist/extensions/pi-subagents/src/runs/shared/model-fallback.ts +88 -12
- package/dist/extensions/pi-subagents/src/runs/shared/nested-events.ts +37 -53
- package/dist/extensions/pi-subagents/src/runs/shared/nested-path.ts +1 -1
- package/dist/extensions/pi-subagents/src/runs/shared/orca-progress-tabs.ts +18 -7
- package/dist/extensions/pi-subagents/src/runs/shared/parallel-handoff.ts +57 -12
- package/dist/extensions/pi-subagents/src/runs/shared/parallel-utils.ts +3 -4
- package/dist/extensions/pi-subagents/src/runs/shared/permissions.ts +0 -11
- package/dist/extensions/pi-subagents/src/runs/shared/process-signal.ts +4 -1
- package/dist/extensions/pi-subagents/src/runs/shared/readonly-drain-observation.ts +42 -0
- package/dist/extensions/pi-subagents/src/runs/shared/readonly-model-continuation.ts +69 -0
- package/dist/extensions/pi-subagents/src/runs/shared/readonly-session-evidence.ts +307 -0
- package/dist/extensions/pi-subagents/src/runs/shared/run-fanout-budget.ts +8 -21
- package/dist/extensions/pi-subagents/src/runs/shared/runtime-acknowledged-extensions.ts +3 -30
- package/dist/extensions/pi-subagents/src/runs/shared/structured-output.ts +17 -4
- package/dist/extensions/pi-subagents/src/runs/shared/subagent-control.ts +2 -0
- package/dist/extensions/pi-subagents/src/runs/shared/subagent-prompt-runtime.ts +99 -386
- package/dist/extensions/pi-subagents/src/runs/shared/tool-availability.ts +18 -62
- package/dist/extensions/pi-subagents/src/runs/shared/tool-budget.ts +0 -14
- package/dist/extensions/pi-subagents/src/runs/shared/worktree-cleanup-plan.ts +31 -9
- package/dist/extensions/pi-subagents/src/runs/shared/worktree-setup-command.ts +190 -0
- package/dist/extensions/pi-subagents/src/runs/shared/worktree.ts +506 -226
- package/dist/extensions/pi-subagents/src/shared/child-session-name.ts +1 -1
- package/dist/extensions/pi-subagents/src/shared/jsonl-writer.ts +11 -0
- package/dist/extensions/pi-subagents/src/shared/model-response-aliases.ts +13 -0
- package/dist/extensions/pi-subagents/src/shared/thinking-ceiling.ts +0 -6
- package/dist/extensions/pi-subagents/src/shared/types.ts +145 -89
- package/dist/extensions/pi-subagents/src/shared/utils.ts +13 -6
- package/dist/extensions/pi-subagents/src/shared/watch-strategy.ts +2 -0
- package/dist/extensions/pi-subagents/src/shared/workflow-child-permit.ts +18 -13
- package/dist/extensions/pi-subagents/src/slash/slash-commands.ts +0 -6
- package/dist/extensions/pi-subagents/src/tui/fleet-status.ts +1 -1
- package/dist/extensions/pi-subagents/src/tui/fleet.ts +11 -6
- package/dist/extensions/pi-subagents/src/tui/render.ts +277 -46
- package/dist/extensions/pi-subagents/src/watchdog/child-status.ts +0 -1
- package/dist/extensions/pi-subagents/src/watchdog/register-child.ts +12 -12
- package/dist/extensions/pi-subagents/src/workflows/chat-progress.ts +3 -3
- package/dist/extensions/pi-subagents/src/workflows/scripted-workflow.ts +116 -15
- package/dist/extensions/pi-subagents/src/workflows/workflow-checklist.ts +15 -18
- package/dist/extensions/pi-subagents/src/workflows/workflow-child-summary.ts +57 -8
- package/dist/extensions/pi-subagents/src/workflows/workflow-preflight.ts +19 -19
- package/dist/extensions/pi-subagents/src/workflows/workflow-receipt.ts +3 -3
- package/dist/extensions/pi-subagents/src/workflows/workflow-resources.ts +97 -22
- package/dist/extensions/pi-subagents/src/workflows/workflow-settlement.ts +3 -0
- package/dist/extensions/pi-subagents/test/integration/acceptance-file-report.test.ts +336 -21
- package/dist/extensions/pi-subagents/test/integration/async-execution.part-1.test.ts +1181 -0
- package/dist/extensions/pi-subagents/test/integration/async-execution.part-2.test.ts +2240 -0
- package/dist/extensions/pi-subagents/test/integration/async-execution.part-3.test.ts +2268 -0
- package/dist/extensions/pi-subagents/test/integration/async-execution.part-4.test.ts +1512 -0
- package/dist/extensions/pi-subagents/test/integration/async-job-tracker.test.ts +231 -16
- package/dist/extensions/pi-subagents/test/integration/error-handling.test.ts +4 -18
- package/dist/extensions/pi-subagents/test/integration/foreign-workflow-steering.test.ts +95 -0
- package/dist/extensions/pi-subagents/test/integration/fork-context-execution.test.ts +9 -15
- package/dist/extensions/pi-subagents/test/integration/in-process-child.test.ts +374 -0
- package/dist/extensions/pi-subagents/test/integration/intercom-result-delivery.test.ts +20 -10
- package/dist/extensions/pi-subagents/test/integration/orca-progress-tabs.test.ts +18 -6
- package/dist/extensions/pi-subagents/test/integration/recovered-assistant-error.test.ts +151 -0
- package/dist/extensions/pi-subagents/test/integration/render-fork-badge.test.ts +42 -1
- package/dist/extensions/pi-subagents/test/integration/render-widget.test.ts +150 -25
- package/dist/extensions/pi-subagents/test/integration/result-publication.test.ts +354 -0
- package/dist/extensions/pi-subagents/test/integration/shared-cwd-terminal-evidence.test.ts +117 -0
- package/dist/extensions/pi-subagents/test/integration/single-execution.part-1.test.ts +3678 -0
- package/dist/extensions/pi-subagents/test/integration/{single-execution.test.ts → single-execution.part-2.test.ts} +500 -4207
- package/dist/extensions/pi-subagents/test/integration/slash-commands.test.ts +1 -2
- package/dist/extensions/pi-subagents/test/integration/workflow-result-publication.test.ts +127 -0
- package/dist/extensions/pi-subagents/test/integration/workflow-steer-inbox.test.ts +365 -0
- package/dist/extensions/pi-subagents/test/smoke/pi085-child.ts +31 -0
- package/dist/extensions/pi-subagents/test/smoke/pi085-clean-install.mjs +74 -0
- package/dist/extensions/pi-subagents/test/smoke/pi085-extension.ts +16 -0
- package/dist/extensions/pi-subagents/test/support/async-execution-fixture.ts +699 -0
- package/dist/extensions/pi-subagents/test/support/fake-child-session.ts +418 -0
- package/dist/extensions/pi-subagents/test/support/foreign-workflow-steer-host.mjs +13 -0
- package/dist/extensions/pi-subagents/test/support/mock-pi.ts +30 -76
- package/dist/extensions/pi-subagents/test/support/notify-diagnostics-fixture.ts +84 -0
- package/dist/extensions/pi-subagents/test/support/result-publication-capacity-preload.mjs +70 -0
- package/dist/extensions/pi-subagents/test/support/runner-child-session-factory.ts +17 -0
- package/dist/extensions/pi-subagents/test/support/single-execution-fixture.ts +390 -0
- package/dist/extensions/pi-subagents/test/unit/acceptance-compaction.test.ts +120 -0
- package/dist/extensions/pi-subagents/test/unit/acceptance.test.ts +24 -3
- package/dist/extensions/pi-subagents/test/unit/advertised-agent-prompt.test.ts +87 -0
- package/dist/extensions/pi-subagents/test/unit/advertised-agent-refresh.test.ts +163 -0
- package/dist/extensions/pi-subagents/test/unit/agent-frontmatter.test.ts +70 -31
- package/dist/extensions/pi-subagents/test/unit/agent-management.test.ts +78 -3
- package/dist/extensions/pi-subagents/test/unit/agent-overrides.test.ts +2 -8
- package/dist/extensions/pi-subagents/test/unit/async-execution.test.ts +1 -1
- package/dist/extensions/pi-subagents/test/unit/async-interrupt-action.test.ts +73 -66
- package/dist/extensions/pi-subagents/test/unit/async-recovery-descriptor.test.ts +51 -1
- package/dist/extensions/pi-subagents/test/unit/async-retention.test.ts +49 -1
- package/dist/extensions/pi-subagents/test/unit/async-spawn-preload.test.ts +103 -0
- package/dist/extensions/pi-subagents/test/unit/async-status-projection.test.ts +3 -3
- package/dist/extensions/pi-subagents/test/unit/capability-ceiling-agent-allowlist.test.ts +9 -8
- package/dist/extensions/pi-subagents/test/unit/capability-ceiling.test.ts +10 -7
- package/dist/extensions/pi-subagents/test/unit/chain-root-attachment.test.ts +48 -6
- package/dist/extensions/pi-subagents/test/unit/child-runtime-config.test.ts +90 -0
- package/dist/extensions/pi-subagents/test/unit/{pi-args-permission-system.test.ts → child-tool-plan-permission-system.test.ts} +48 -86
- package/dist/extensions/pi-subagents/test/unit/child-tool-plan.test.ts +33 -0
- package/dist/extensions/pi-subagents/test/unit/compaction-resume.test.ts +18 -18
- package/dist/extensions/pi-subagents/test/unit/completion-evidence.test.ts +9 -9
- package/dist/extensions/pi-subagents/test/unit/completion-guard.test.ts +8 -7
- package/dist/extensions/pi-subagents/test/unit/control-channel.test.ts +225 -65
- package/dist/extensions/pi-subagents/test/unit/extension-bindings.test.ts +17 -22
- package/dist/extensions/pi-subagents/test/unit/fleet-status.test.ts +11 -1
- package/dist/extensions/pi-subagents/test/unit/fleet.test.ts +47 -3
- package/dist/extensions/pi-subagents/test/unit/foreign-workflow-steering.test.ts +74 -0
- package/dist/extensions/pi-subagents/test/unit/fork-cache-key.test.ts +23 -29
- package/dist/extensions/pi-subagents/test/unit/host-peer-runtime-imports.test.ts +96 -4
- package/dist/extensions/pi-subagents/test/unit/host-step-status.test.ts +4 -4
- package/dist/extensions/pi-subagents/test/unit/index-child-registration.test.ts +116 -55
- package/dist/extensions/pi-subagents/test/unit/index-segment.test.ts +58 -1
- package/dist/extensions/pi-subagents/test/unit/llm-intent-arbiter.test.ts +104 -3
- package/dist/extensions/pi-subagents/test/unit/mission-lifecycle.test.ts +10 -1
- package/dist/extensions/pi-subagents/test/unit/mission-store.test.ts +31 -1
- package/dist/extensions/pi-subagents/test/unit/model-exclusions.test.ts +102 -51
- package/dist/extensions/pi-subagents/test/unit/model-fallback.test.ts +196 -6
- package/dist/extensions/pi-subagents/test/unit/native-supervisor-channel.test.ts +181 -38
- package/dist/extensions/pi-subagents/test/unit/nested-control.test.ts +62 -70
- package/dist/extensions/pi-subagents/test/unit/nested-events.test.ts +58 -53
- package/dist/extensions/pi-subagents/test/unit/notify-diagnostics.test.ts +42 -0
- package/dist/extensions/pi-subagents/test/unit/notify.test.ts +84 -0
- package/dist/extensions/pi-subagents/test/unit/orca-progress-tabs.test.ts +13 -5
- package/dist/extensions/pi-subagents/test/unit/package-manifest.test.ts +21 -5
- package/dist/extensions/pi-subagents/test/unit/parallel-handoff.test.ts +5 -4
- package/dist/extensions/pi-subagents/test/unit/permissions.test.ts +2 -6
- package/dist/extensions/pi-subagents/test/unit/pi-coding-agent-dir.test.ts +28 -2
- package/dist/extensions/pi-subagents/test/unit/pi-web-session-liveness.test.ts +209 -0
- package/dist/extensions/pi-subagents/test/unit/preflight.test.ts +38 -1
- package/dist/extensions/pi-subagents/test/unit/prompt-audit-optional-peers.test.ts +43 -0
- package/dist/extensions/pi-subagents/test/unit/public-execution.test.ts +24 -2
- package/dist/extensions/pi-subagents/test/unit/readonly-drain-observation.test.ts +174 -0
- package/dist/extensions/pi-subagents/test/unit/readonly-model-continuation.test.ts +94 -0
- package/dist/extensions/pi-subagents/test/unit/readonly-session-evidence.test.ts +1329 -0
- package/dist/extensions/pi-subagents/test/unit/recursion-guard.test.ts +29 -80
- package/dist/extensions/pi-subagents/test/unit/render-helpers.test.ts +11 -8
- package/dist/extensions/pi-subagents/test/unit/result-files.test.ts +2 -2
- package/dist/extensions/pi-subagents/test/unit/retained-nested-route-tracker.test.ts +175 -0
- package/dist/extensions/pi-subagents/test/unit/rpc.test.ts +38 -12
- package/dist/extensions/pi-subagents/test/unit/run-fanout-budget.test.ts +2 -5
- package/dist/extensions/pi-subagents/test/unit/run-status.test.ts +89 -1
- package/dist/extensions/pi-subagents/test/unit/runtime-acknowledged-extensions.test.ts +2 -16
- package/dist/extensions/pi-subagents/test/unit/scheduled-runs.test.ts +27 -3
- package/dist/extensions/pi-subagents/test/unit/scheduled-supervisor-demand.test.ts +215 -0
- package/dist/extensions/pi-subagents/test/unit/schemas.test.ts +15 -11
- package/dist/extensions/pi-subagents/test/unit/scripted-workflow.test.ts +237 -1
- package/dist/extensions/pi-subagents/test/unit/steering-action.test.ts +2 -5
- package/dist/extensions/pi-subagents/test/unit/streamed-progress-bounds.test.ts +2 -2
- package/dist/extensions/pi-subagents/test/unit/subagent-guide.test.ts +14 -1
- package/dist/extensions/pi-subagents/test/unit/subagent-prompt-runtime.test.ts +130 -739
- package/dist/extensions/pi-subagents/test/unit/supervisor-ask-registration.test.ts +682 -0
- package/dist/extensions/pi-subagents/test/unit/supervisor-ui.test.ts +137 -0
- package/dist/extensions/pi-subagents/test/unit/tool-budget.test.ts +1 -11
- package/dist/extensions/pi-subagents/test/unit/tool-description.test.ts +23 -3
- package/dist/extensions/pi-subagents/test/unit/wait-completions.test.ts +8 -1
- package/dist/extensions/pi-subagents/test/unit/watchdog-tool-actions.test.ts +19 -1
- package/dist/extensions/pi-subagents/test/unit/workflow-chat-progress.test.ts +72 -4
- package/dist/extensions/pi-subagents/test/unit/workflow-checklist.test.ts +17 -3
- package/dist/extensions/pi-subagents/test/unit/workflow-child-summary.test.ts +34 -0
- package/dist/extensions/pi-subagents/test/unit/workflow-detach-reconcile.test.ts +12 -2
- package/dist/extensions/pi-subagents/test/unit/workflow-launch-params.test.ts +46 -6
- package/dist/extensions/pi-subagents/test/unit/workflow-receipt.test.ts +3 -3
- package/dist/extensions/pi-subagents/test/unit/workflow-resources.test.ts +133 -1
- package/dist/extensions/pi-subagents/test/unit/workflow-resume-hint.test.ts +53 -2
- package/dist/extensions/pi-subagents/test/unit/worktree-cleanup-plan.test.ts +222 -14
- package/dist/extensions/pi-subagents/test/unit/worktree.test.ts +526 -85
- package/dist/extensions/pi-web-agent/src/backends/config.ts +1 -0
- package/dist/extensions/pi-web-agent/src/backends/settings-reader.ts +5 -3
- package/dist/extensions/pi-web-agent/src/search/tokenin.ts +7 -3
- package/dist/extensions/pi-web-agent/src/types.ts +1 -1
- package/dist/extensions/pi-zentui/README.md +17 -0
- package/dist/extensions/pi-zentui/assets/screenshots/footer-status-hyperlink.png +0 -0
- package/dist/extensions/pi-zentui/docs/configuration.md +71 -2
- package/dist/extensions/pi-zentui/extensions/zentui/config.ts +11 -0
- package/dist/extensions/pi-zentui/extensions/zentui/editor-transfer.ts +14 -0
- package/dist/extensions/pi-zentui/extensions/zentui/extension-status.ts +29 -13
- package/dist/extensions/pi-zentui/extensions/zentui/footer-layout.ts +5 -4
- package/dist/extensions/pi-zentui/extensions/zentui/footer-text.ts +11 -0
- package/dist/extensions/pi-zentui/extensions/zentui/footer.ts +11 -10
- package/dist/extensions/pi-zentui/extensions/zentui/index.ts +77 -3
- package/dist/extensions/pi-zentui/extensions/zentui/presets.ts +77 -0
- package/dist/extensions/pi-zentui/extensions/zentui/settings-command.ts +103 -2
- package/dist/extensions/pi-zentui/extensions/zentui/working-line-extension-segments.ts +115 -0
- package/dist/extensions/pi-zentui/extensions/zentui/working-line.ts +87 -5
- package/dist/extensions/pi-zentui/package-lock.json +277 -517
- package/dist/extensions/pi-zentui/package.json +7 -4
- package/dist/extensions/pi-zentui/test/config-presets.test.ts +238 -0
- package/dist/extensions/pi-zentui/test/editor-transfer.test.ts +24 -1
- package/dist/extensions/pi-zentui/test/extension-compliance.test.ts +570 -2
- package/dist/extensions/pi-zentui/test/extension-status.test.ts +90 -0
- package/dist/extensions/pi-zentui/test/footer-hyperlink.test.ts +243 -0
- package/dist/extensions/pi-zentui/test/package-contents.mjs +1 -0
- package/dist/extensions/pi-zentui/test/presets.test.ts +121 -0
- package/dist/extensions/pi-zentui/test/settings-command.test.ts +205 -1
- package/dist/extensions/pi-zentui/test/working-line-extension-segments.test.ts +139 -0
- package/dist/extensions/pi-zentui/test/working-line-lifecycle.integration.test.ts +237 -3
- package/dist/extensions/pi-zentui/test/working-line.test.ts +94 -2
- package/dist/index.d.ts +1 -1
- package/dist/main.js +4 -1
- package/dist/modes/interactive/chat-viewport.d.ts +19 -0
- package/dist/modes/interactive/chat-viewport.js +27 -0
- package/dist/modes/interactive/components/assistant-message.d.ts +6 -2
- package/dist/modes/interactive/components/assistant-message.js +30 -13
- package/dist/modes/interactive/components/custom-editor.d.ts +10 -1
- package/dist/modes/interactive/components/custom-editor.js +39 -1
- package/dist/modes/interactive/components/first-time-setup.js +1 -1
- package/dist/modes/interactive/components/index.d.ts +1 -1
- package/dist/modes/interactive/components/markdown-transform.d.ts +2 -0
- package/dist/modes/interactive/components/markdown-transform.js +18 -0
- package/dist/modes/interactive/components/model-selector.js +19 -17
- package/dist/modes/interactive/components/scoped-models-selector.js +21 -23
- package/dist/modes/interactive/components/settings-selector.d.ts +7 -1
- package/dist/modes/interactive/components/settings-selector.js +128 -20
- package/dist/modes/interactive/components/settings-submenu.d.ts +71 -0
- package/dist/modes/interactive/components/settings-submenu.js +164 -0
- package/dist/modes/interactive/components/status-indicator.d.ts +3 -1
- package/dist/modes/interactive/components/status-indicator.js +10 -3
- package/dist/modes/interactive/components/thinking-selector.d.ts +15 -3
- package/dist/modes/interactive/components/thinking-selector.js +75 -18
- package/dist/modes/interactive/components/tool-execution.d.ts +21 -4
- package/dist/modes/interactive/components/tool-execution.js +35 -33
- package/dist/modes/interactive/components/trust-selector.js +2 -2
- package/dist/modes/interactive/interactive-mode.d.ts +13 -15
- package/dist/modes/interactive/interactive-mode.js +144 -80
- package/dist/modes/interactive/session-share.d.ts +15 -0
- package/dist/modes/interactive/session-share.js +183 -0
- package/dist/modes/interactive/theme/dark.json +2 -1
- package/dist/modes/interactive/theme/light.json +2 -1
- package/dist/modes/interactive/theme/theme-controller.d.ts +1 -0
- package/dist/modes/interactive/theme/theme-controller.js +5 -0
- package/dist/modes/interactive/theme/theme-json.d.ts +83 -0
- package/dist/modes/interactive/theme/theme-json.js +129 -0
- package/dist/modes/interactive/theme/theme-schema.json +9 -1
- package/dist/modes/interactive/theme/theme.d.ts +14 -5
- package/dist/modes/interactive/theme/theme.js +18 -119
- package/dist/modes/interactive/tui-renderer.d.ts +20 -0
- package/dist/modes/interactive/tui-renderer.js +65 -0
- package/dist/utils/exif-orientation.js +2 -3
- package/dist/utils/management-http.d.ts +24 -0
- package/dist/utils/management-http.js +53 -0
- package/dist/utils/text.d.ts +7 -0
- package/dist/utils/text.js +8 -0
- package/dist/utils/tools-manager.d.ts +1 -0
- package/dist/utils/tools-manager.js +43 -21
- package/docs/docs.json +0 -4
- package/package.json +4 -4
- package/dist/extensions/pi-subagents/src/runs/shared/child-protocol.ts +0 -415
- package/dist/extensions/pi-subagents/src/runs/shared/pi-args.ts +0 -1059
- package/dist/extensions/pi-subagents/src/runs/shared/subagent-startup-retry.ts +0 -116
- package/dist/extensions/pi-subagents/src/shared/post-exit-stdio-guard.ts +0 -85
- package/dist/extensions/pi-subagents/test/e2e/real-session-subagent.test.ts +0 -224
- package/dist/extensions/pi-subagents/test/integration/async-execution.test.ts +0 -6986
- package/dist/extensions/pi-subagents/test/support/mock-pi-script.mjs +0 -447
- package/dist/extensions/pi-subagents/test/support/real-session-child-cli.mjs +0 -185
- package/dist/extensions/pi-subagents/test/support/real-session-runner.ts +0 -311
- package/dist/extensions/pi-subagents/test/unit/capability-ceiling-pi-args.test.ts +0 -84
- package/dist/extensions/pi-subagents/test/unit/child-protocol.test.ts +0 -202
- package/dist/extensions/pi-subagents/test/unit/close-grace-timer.test.ts +0 -101
- package/dist/extensions/pi-subagents/test/unit/pi-args.test.ts +0 -2347
- package/dist/extensions/pi-subagents/test/unit/subagent-startup-retry.test.ts +0 -104
- package/dist/extensions/pi-subagents/test/unit/windows-hide-spawn.test.ts +0 -49
- package/dist/skills/imagegen-frontend-mobile/SKILL.md +0 -1465
- package/dist/skills/imagegen-frontend-web/SKILL.md +0 -987
- package/dist/skills/implanger/SKILL.md +0 -70
- package/dist/skills/output/SKILL.md +0 -49
- package/dist/skills/planger/SKILL.md +0 -167
- package/dist/skills/workflow/SKILL.md +0 -95
- package/docs/workflows.md +0 -18
- /package/dist/bun/{register-bedrock.d.ts → runtime-setup.d.ts} +0 -0
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
resolveModelCandidate,
|
|
14
14
|
resolveSubagentModelOverride,
|
|
15
15
|
} from "../../src/runs/shared/model-fallback.ts";
|
|
16
|
-
import { clearExclusions, recordModelFailure } from "../../src/runs/shared/model-exclusions.ts";
|
|
16
|
+
import { clearExclusions, findModelExclusion, getExcludedCount, recordModelFailure } from "../../src/runs/shared/model-exclusions.ts";
|
|
17
17
|
import { resolveModelScopesForAgent } from "../../src/runs/shared/model-scope.ts";
|
|
18
18
|
|
|
19
19
|
beforeEach(() => clearExclusions());
|
|
@@ -30,10 +30,15 @@ describe("model fallback helpers", () => {
|
|
|
30
30
|
});
|
|
31
31
|
|
|
32
32
|
it("fails verification when the child reports an unregistered different model", () => {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
);
|
|
33
|
+
const error = formatSubagentModelVerificationError("openai/gpt-5-mini:high", "unknown-provider/wrong-model", availableModels) ?? "";
|
|
34
|
+
assert.match(error, /model_verification_failed: native Pi child/);
|
|
35
|
+
assert.match(error, /Expected 'openai\/gpt-5-mini:high' but observed 'unknown-provider\/wrong-model'/);
|
|
36
|
+
assert.match(error, /independently verified/);
|
|
37
|
+
assert.match(error, /modelResponseAliases in ~\/\.selesai\/agent\/extensions\/subagent\/config\.json/);
|
|
38
|
+
assert.match(error, /docs\/configuration\.md#modelresponsealiases/);
|
|
39
|
+
assert.match(error, /resolved provider\/model ID without its thinking suffix/);
|
|
40
|
+
assert.match(error, /outgoing request unchanged/);
|
|
41
|
+
assert.match(error, /Configuration changes affect new independent native runs; resumed native runs retain their launch-time declaration\. External CLI adapters do not use this setting\./);
|
|
37
42
|
});
|
|
38
43
|
|
|
39
44
|
it("accepts child-reported bare model ids for the expected registry entry", () => {
|
|
@@ -86,6 +91,27 @@ describe("model fallback helpers", () => {
|
|
|
86
91
|
);
|
|
87
92
|
});
|
|
88
93
|
|
|
94
|
+
it("accepts exact response aliases only for the resolved candidate route", () => {
|
|
95
|
+
const route = "litellm/claude-haiku-4-5";
|
|
96
|
+
const responseId = "anthropic.claude-haiku-4-5-20251001-v1:0";
|
|
97
|
+
const registry = [{ provider: "litellm", id: "claude-haiku-4-5", fullId: route }];
|
|
98
|
+
const aliases = { [route]: [responseId] };
|
|
99
|
+
const candidate = resolveModelCandidate("claude-haiku-4-5:high", registry)!;
|
|
100
|
+
assert.equal(candidate, `${route}:high`);
|
|
101
|
+
assert.equal(formatSubagentModelVerificationError(candidate, responseId, registry, aliases), undefined);
|
|
102
|
+
for (const expected of ["other-provider/claude-haiku-4-5", "litellm/other-route", "claude-haiku-4-5"]) {
|
|
103
|
+
assert.match(formatSubagentModelVerificationError(expected, responseId, registry, aliases) ?? "", /model_verification_failed/);
|
|
104
|
+
}
|
|
105
|
+
for (const observed of [`wrong-provider/${responseId}`, "anthropic.claude-haiku-4-5-20251002-v1:0", "claude-sonnet-4", responseId.toUpperCase(), `${responseId}:high`]) {
|
|
106
|
+
assert.match(formatSubagentModelVerificationError(candidate, observed, registry, aliases) ?? "", /model_verification_failed/);
|
|
107
|
+
}
|
|
108
|
+
for (const map of [undefined, {}, { [route]: [] }]) {
|
|
109
|
+
assert.match(formatSubagentModelVerificationError(candidate, responseId, registry, map) ?? "", /model_verification_failed/);
|
|
110
|
+
}
|
|
111
|
+
assert.equal(formatSubagentModelVerificationError(candidate, "response:high", registry, { [route]: ["response:high"] }), undefined);
|
|
112
|
+
assert.match(formatSubagentModelVerificationError(candidate, "response", registry, { [route]: ["response:high"] }) ?? "", /model_verification_failed/);
|
|
113
|
+
});
|
|
114
|
+
|
|
89
115
|
it("resolves unique owner/name ids when the owner is not a registered provider", () => {
|
|
90
116
|
const registry = [
|
|
91
117
|
...availableModels,
|
|
@@ -184,6 +210,60 @@ describe("model fallback helpers", () => {
|
|
|
184
210
|
);
|
|
185
211
|
});
|
|
186
212
|
|
|
213
|
+
it("does not cache context overflow even when upstream makes it retryable", () => {
|
|
214
|
+
const error = "upstream: maximum context length exceeded";
|
|
215
|
+
assert.equal(isRetryableModelFailure(error), true);
|
|
216
|
+
assert.equal(isContextOverflow(error), true);
|
|
217
|
+
recordRetryableModelFailure("openai/gpt-5-mini", error);
|
|
218
|
+
assert.equal(getExcludedCount(), 0);
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
it("does not cache the reported Databricks tool-message request error (issue #1955)", () => {
|
|
222
|
+
const model = "databricks/databricks-kimi-k3";
|
|
223
|
+
const error = 'Databricks error: {"error_code":"BAD_REQUEST","message":"{\\"error\\":\\"Upstream error: INVALID_ARGUMENT: Kimi K3 tool messages need a resolvable tool name: carry `tool`/`name`, or match a preceding assistant tool_call by order.\\"}"}';
|
|
224
|
+
assert.equal(isRetryableModelFailure(error), true);
|
|
225
|
+
const messages = [{ role: "assistant", errorMessage: error }];
|
|
226
|
+
assert.equal(isRetryableModelFailureAttempt({ error, messages, toolCount: 0 }), true);
|
|
227
|
+
assert.equal(isRetryableModelFailureAttempt({ error, messages, toolCount: 1 }), false);
|
|
228
|
+
recordRetryableModelFailure(model, error);
|
|
229
|
+
assert.equal(findModelExclusion(model), undefined);
|
|
230
|
+
assert.equal(getExcludedCount(), 0);
|
|
231
|
+
assert.deepEqual(buildModelCandidates(model, undefined, undefined), [model]);
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
it("does not cache request-shape errors despite retryable upstream prose", () => {
|
|
235
|
+
for (const error of [
|
|
236
|
+
"Bad Request: upstream rejected the request",
|
|
237
|
+
"BAD_REQUEST: upstream rejected the request",
|
|
238
|
+
"INVALID_ARGUMENT: upstream rejected the request",
|
|
239
|
+
"invalid_request_error: upstream rejected the request",
|
|
240
|
+
]) {
|
|
241
|
+
assert.equal(isRetryableModelFailure(error), true, error);
|
|
242
|
+
recordRetryableModelFailure("openai/gpt-5-mini", error);
|
|
243
|
+
assert.equal(getExcludedCount(), 0, error);
|
|
244
|
+
}
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
it("still caches rate limits that mention numeric request quotas", () => {
|
|
248
|
+
const error = "rate limit exceeded: 400 requests per minute";
|
|
249
|
+
recordRetryableModelFailure("openai/gpt-5-mini", error);
|
|
250
|
+
assert.equal(findModelExclusion("openai/gpt-5-mini")?.reason, error);
|
|
251
|
+
assert.equal(getExcludedCount(), 1);
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
it("still caches raw request limits and per-minute input-token rate quotas", () => {
|
|
255
|
+
for (const error of [
|
|
256
|
+
"REQUEST_LIMIT_EXCEEDED",
|
|
257
|
+
'{"error_code":"REQUEST_LIMIT_EXCEEDED","message":"REQUEST_LIMIT_EXCEEDED: Exceeded workspace input tokens per minute rate limit for <model>."}',
|
|
258
|
+
]) {
|
|
259
|
+
clearExclusions();
|
|
260
|
+
assert.equal(isContextOverflow(error), false);
|
|
261
|
+
recordRetryableModelFailure("openai/gpt-5-mini", error);
|
|
262
|
+
assert.equal(findModelExclusion("openai/gpt-5-mini")?.reason, error);
|
|
263
|
+
assert.equal(getExcludedCount(), 1);
|
|
264
|
+
}
|
|
265
|
+
});
|
|
266
|
+
|
|
187
267
|
it("applies the current provider preference to fallback candidates too", () => {
|
|
188
268
|
const ambiguous = [
|
|
189
269
|
...availableModels,
|
|
@@ -250,6 +330,19 @@ describe("model fallback helpers", () => {
|
|
|
250
330
|
assert.equal(warnings.some((warning) => warning.includes("Skipping primary model 'does-not-exist'")), false);
|
|
251
331
|
});
|
|
252
332
|
|
|
333
|
+
it("fails closed when fallback-only configuration resolves no candidates", () => {
|
|
334
|
+
const originalWarn = console.warn;
|
|
335
|
+
console.warn = () => {};
|
|
336
|
+
try {
|
|
337
|
+
assert.throws(
|
|
338
|
+
() => buildModelCandidates(undefined, ["does-not-exist"], availableModels),
|
|
339
|
+
/Unknown subagent model 'does-not-exist'/,
|
|
340
|
+
);
|
|
341
|
+
} finally {
|
|
342
|
+
console.warn = originalWarn;
|
|
343
|
+
}
|
|
344
|
+
});
|
|
345
|
+
|
|
253
346
|
it("keeps an explicit unknown primary strict even when fallbacks exist", () => {
|
|
254
347
|
assert.throws(
|
|
255
348
|
() => buildModelCandidates("does-not-exist", ["anthropic/claude-sonnet-4"], availableModels, undefined, { origin: "explicit" }),
|
|
@@ -264,6 +357,40 @@ describe("model fallback helpers", () => {
|
|
|
264
357
|
);
|
|
265
358
|
});
|
|
266
359
|
|
|
360
|
+
it("ignores stale model-not-found exclusions when the model is back in the registry", () => {
|
|
361
|
+
recordModelFailure({
|
|
362
|
+
modelId: "gpt-5-mini",
|
|
363
|
+
provider: "openai",
|
|
364
|
+
reason: 'Model "openai/gpt-5-mini" not found. Use --list-models to see available models.',
|
|
365
|
+
});
|
|
366
|
+
assert.deepEqual(buildModelCandidates("openai/gpt-5-mini", undefined, availableModels), ["openai/gpt-5-mini"]);
|
|
367
|
+
});
|
|
368
|
+
|
|
369
|
+
it("keeps provider-wide exclusions when ignoring a stale model-not-found entry", () => {
|
|
370
|
+
recordModelFailure({ provider: "openai", reason: "quota exceeded" });
|
|
371
|
+
recordModelFailure({
|
|
372
|
+
modelId: "gpt-5-mini",
|
|
373
|
+
provider: "openai",
|
|
374
|
+
reason: 'Model "openai/gpt-5-mini" not found. Use --list-models to see available models.',
|
|
375
|
+
});
|
|
376
|
+
assert.throws(
|
|
377
|
+
() => buildModelCandidates("openai/gpt-5-mini", undefined, availableModels),
|
|
378
|
+
/No usable subagent models remain after registry, scope, and cached-exclusion filtering/,
|
|
379
|
+
);
|
|
380
|
+
});
|
|
381
|
+
|
|
382
|
+
it("keeps explicit stale model-not-found exclusions strict", () => {
|
|
383
|
+
recordModelFailure({
|
|
384
|
+
modelId: "gpt-5-mini",
|
|
385
|
+
provider: "openai",
|
|
386
|
+
reason: 'Model "openai/gpt-5-mini" not found. Use --list-models to see available models.',
|
|
387
|
+
});
|
|
388
|
+
assert.throws(
|
|
389
|
+
() => buildModelCandidates("openai/gpt-5-mini", ["anthropic/claude-sonnet-4"], availableModels, undefined, { origin: "explicit" }),
|
|
390
|
+
/Requested subagent model 'openai\/gpt-5-mini' is excluded and cannot be replaced by a fallback/,
|
|
391
|
+
);
|
|
392
|
+
});
|
|
393
|
+
|
|
267
394
|
it("keeps an explicit cached-excluded primary strict even when fallbacks exist", () => {
|
|
268
395
|
recordModelFailure({ modelId: "gpt-5-mini", provider: "openai", reason: "sk-secret-token-xyz" });
|
|
269
396
|
assert.throws(
|
|
@@ -290,11 +417,67 @@ describe("model fallback helpers", () => {
|
|
|
290
417
|
(error: unknown) => {
|
|
291
418
|
const message = String(error);
|
|
292
419
|
return /No usable subagent models remain after registry, scope, and cached-exclusion filtering/.test(message)
|
|
420
|
+
&& /excluded: openai\/gpt-5-mini — model: gpt-5-mini; provider: openai; reason: \[redacted\]; expires: \d{4}-\d{2}-\d{2}T/.test(message)
|
|
421
|
+
&& /excluded: .*anthropic\/claude-sonnet-4/.test(message)
|
|
293
422
|
&& !message.includes("sk-secret-token-xyz");
|
|
294
423
|
},
|
|
295
424
|
);
|
|
296
425
|
});
|
|
297
426
|
|
|
427
|
+
it("keeps cached-exclusion diagnostics when an unrelated fallback is unavailable", () => {
|
|
428
|
+
recordModelFailure({ modelId: "gpt-5-mini", provider: "openai", reason: "sk-secret-token-xyz" });
|
|
429
|
+
const originalWarn = console.warn;
|
|
430
|
+
console.warn = () => {};
|
|
431
|
+
try {
|
|
432
|
+
assert.throws(
|
|
433
|
+
() => buildModelCandidates("openai/gpt-5-mini", ["does-not-exist"], availableModels),
|
|
434
|
+
/No usable subagent models remain after registry, scope, and cached-exclusion filtering/,
|
|
435
|
+
);
|
|
436
|
+
} finally {
|
|
437
|
+
console.warn = originalWarn;
|
|
438
|
+
}
|
|
439
|
+
});
|
|
440
|
+
|
|
441
|
+
it("bounds and sanitizes excluded-candidate evidence", () => {
|
|
442
|
+
const warnings: string[] = [];
|
|
443
|
+
const originalWarn = console.warn;
|
|
444
|
+
console.warn = (message: unknown) => warnings.push(String(message));
|
|
445
|
+
const candidates = Array.from({ length: 21 }, (_, index) => ({
|
|
446
|
+
provider: index === 0 ? "sk-provider-secret" : "diagnostic-provider",
|
|
447
|
+
id: index === 0 ? "sk-model-secret" : `diagnostic-model-${index}`,
|
|
448
|
+
fullId: index === 0 ? "sk-provider-secret/sk-model-secret" : `diagnostic-provider/diagnostic-model-${index}`,
|
|
449
|
+
}));
|
|
450
|
+
for (const [index, candidate] of candidates.entries()) {
|
|
451
|
+
recordModelFailure({
|
|
452
|
+
modelId: candidate.id,
|
|
453
|
+
provider: candidate.provider,
|
|
454
|
+
reason: index === 0 ? "Bearer sk-secret-token-xyz\n" + "long-reason-".repeat(100) : `failure-${index}`,
|
|
455
|
+
});
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
try {
|
|
459
|
+
assert.throws(
|
|
460
|
+
() => buildModelCandidates(candidates[0]!.fullId, candidates.slice(1).map((candidate) => candidate.fullId), candidates),
|
|
461
|
+
(error: unknown) => {
|
|
462
|
+
const message = String(error);
|
|
463
|
+
assert.match(message, /excluded: \[redacted\]\/\[redacted\] — model: \[redacted\]; provider: \[redacted\]/);
|
|
464
|
+
assert.match(message, /reason: \[redacted\] long-reason-/);
|
|
465
|
+
assert.doesNotMatch(message, /sk-provider-secret|sk-model-secret|sk-secret-token-xyz/);
|
|
466
|
+
assert.doesNotMatch(message, /[\r\n]/);
|
|
467
|
+
assert.match(message, /diagnostic-model-19/);
|
|
468
|
+
assert.doesNotMatch(message, /diagnostic-model-20/);
|
|
469
|
+
assert.match(message, /\.\.\. and 1 more/);
|
|
470
|
+
assert.equal((message.match(/reason: /g) ?? []).length, 20);
|
|
471
|
+
return true;
|
|
472
|
+
},
|
|
473
|
+
);
|
|
474
|
+
} finally {
|
|
475
|
+
console.warn = originalWarn;
|
|
476
|
+
}
|
|
477
|
+
assert.equal(warnings.length, 21);
|
|
478
|
+
assert.doesNotMatch(warnings.join("\n"), /sk-provider-secret|sk-model-secret|sk-secret-token-xyz/);
|
|
479
|
+
});
|
|
480
|
+
|
|
298
481
|
it("trusts an inherited parent model outside the registry", () => {
|
|
299
482
|
assert.deepEqual(
|
|
300
483
|
buildModelCandidates("gateway/parent-model", undefined, availableModels, undefined, { primaryModelFromParent: true }),
|
|
@@ -328,6 +511,13 @@ describe("model fallback helpers", () => {
|
|
|
328
511
|
assert.equal(isRetryableModelFailure(undefined), false);
|
|
329
512
|
});
|
|
330
513
|
|
|
514
|
+
it("recognizes only the exact raw request-limit code without broadening limit families", () => {
|
|
515
|
+
assert.equal(isRetryableModelFailure("REQUEST_LIMIT_EXCEEDED"), true);
|
|
516
|
+
for (const error of ["TOKEN_LIMIT_EXCEEDED", "INPUT_LIMIT_EXCEEDED", "OUTPUT_LIMIT_EXCEEDED", "RESOURCE_EXHAUSTED", "NOT_REQUEST_LIMIT_EXCEEDED", "REQUEST_LIMIT_EXCEEDED_OTHER", "400"]) {
|
|
517
|
+
assert.equal(isRetryableModelFailure(error), false, error);
|
|
518
|
+
}
|
|
519
|
+
});
|
|
520
|
+
|
|
331
521
|
it("does not treat network-flavored tool failures as retryable model failures", () => {
|
|
332
522
|
assert.equal(isRetryableModelFailure("bash failed (exit 1): requests.exceptions.ConnectionError: Connection error."), false);
|
|
333
523
|
assert.equal(isRetryableModelFailure("bash failed (exit 1): urllib.error.URLError: request timed out"), false);
|
|
@@ -900,4 +1090,4 @@ describe("isContextOverflow", () => {
|
|
|
900
1090
|
assert.equal(isContextOverflow(undefined), false);
|
|
901
1091
|
assert.equal(isContextOverflow(""), false);
|
|
902
1092
|
});
|
|
903
|
-
});
|
|
1093
|
+
});
|
|
@@ -11,30 +11,16 @@ import {
|
|
|
11
11
|
registerNativeSupervisorClient,
|
|
12
12
|
resolveSupervisorChannelDir,
|
|
13
13
|
} from "../../src/intercom/native-supervisor-channel.ts";
|
|
14
|
-
import {
|
|
15
|
-
SUBAGENT_CHILD_AGENT_ENV,
|
|
16
|
-
SUBAGENT_CHILD_INDEX_ENV,
|
|
17
|
-
SUBAGENT_ORCHESTRATOR_SESSION_ID_ENV,
|
|
18
|
-
SUBAGENT_ORCHESTRATOR_TARGET_ENV,
|
|
19
|
-
SUBAGENT_RUN_ID_ENV,
|
|
20
|
-
SUBAGENT_SUPERVISOR_CHANNEL_DIR_ENV,
|
|
21
|
-
} from "../../src/runs/shared/pi-args.ts";
|
|
14
|
+
import { SUPERVISOR_REPLY_ENTRY_TYPE, SUPERVISOR_REQUEST_MESSAGE_TYPE } from "../../src/intercom/supervisor-ui.ts";
|
|
22
15
|
import { INTERCOM_DETACH_REQUEST_EVENT, type SubagentState } from "../../src/shared/types.ts";
|
|
23
16
|
|
|
24
17
|
const createdChannels: string[] = [];
|
|
25
|
-
const savedEnv = {
|
|
26
|
-
[SUBAGENT_CHILD_AGENT_ENV]: process.env[SUBAGENT_CHILD_AGENT_ENV],
|
|
27
|
-
[SUBAGENT_CHILD_INDEX_ENV]: process.env[SUBAGENT_CHILD_INDEX_ENV],
|
|
28
|
-
[SUBAGENT_ORCHESTRATOR_SESSION_ID_ENV]: process.env[SUBAGENT_ORCHESTRATOR_SESSION_ID_ENV],
|
|
29
|
-
[SUBAGENT_ORCHESTRATOR_TARGET_ENV]: process.env[SUBAGENT_ORCHESTRATOR_TARGET_ENV],
|
|
30
|
-
[SUBAGENT_RUN_ID_ENV]: process.env[SUBAGENT_RUN_ID_ENV],
|
|
31
|
-
[SUBAGENT_SUPERVISOR_CHANNEL_DIR_ENV]: process.env[SUBAGENT_SUPERVISOR_CHANNEL_DIR_ENV],
|
|
32
|
-
};
|
|
33
18
|
|
|
34
19
|
function makeState(sessionId: string | null, ctx: unknown): SubagentState {
|
|
35
20
|
return {
|
|
36
21
|
baseCwd: process.cwd(),
|
|
37
22
|
currentSessionId: sessionId,
|
|
23
|
+
supervisorOwnerSessionId: (ctx as SubagentState["lastUiContext"])?.sessionManager.getSessionId() ?? null,
|
|
38
24
|
asyncJobs: new Map(),
|
|
39
25
|
foregroundControls: new Map(),
|
|
40
26
|
lastForegroundControlId: null,
|
|
@@ -48,7 +34,7 @@ function makeState(sessionId: string | null, ctx: unknown): SubagentState {
|
|
|
48
34
|
};
|
|
49
35
|
}
|
|
50
36
|
|
|
51
|
-
function writeRequest(input: { sessionId: string; runId: string; agent?: string; index?: number; message?: string; createdAt?: number; expiresAt?: number }): string {
|
|
37
|
+
function writeRequest(input: { sessionId: string; runId: string; agent?: string; index?: number; message?: string; reason?: "need_decision" | "interview_request" | "progress_update"; childTarget?: string; interview?: unknown; createdAt?: number; expiresAt?: number }): string {
|
|
52
38
|
const agent = input.agent ?? "worker";
|
|
53
39
|
const index = input.index ?? 0;
|
|
54
40
|
const channelDir = resolveSupervisorChannelDir(input.runId, agent, index);
|
|
@@ -60,14 +46,16 @@ function writeRequest(input: { sessionId: string; runId: string; agent?: string;
|
|
|
60
46
|
id: requestId,
|
|
61
47
|
createdAt: input.createdAt ?? Date.now(),
|
|
62
48
|
...(input.expiresAt !== undefined ? { expiresAt: input.expiresAt } : {}),
|
|
63
|
-
reason: "need_decision",
|
|
49
|
+
reason: input.reason ?? "need_decision",
|
|
64
50
|
message: input.message ?? "Need a decision",
|
|
65
|
-
expectsReply:
|
|
51
|
+
expectsReply: input.reason !== "progress_update",
|
|
66
52
|
orchestratorSessionId: input.sessionId,
|
|
67
53
|
orchestratorTarget: "shared-name",
|
|
68
54
|
runId: input.runId,
|
|
69
55
|
agent,
|
|
70
56
|
childIndex: index,
|
|
57
|
+
...(input.childTarget ? { childTarget: input.childTarget } : {}),
|
|
58
|
+
...(input.interview !== undefined ? { interview: input.interview } : {}),
|
|
71
59
|
}, null, "\t"));
|
|
72
60
|
return requestId;
|
|
73
61
|
}
|
|
@@ -102,15 +90,7 @@ async function waitForCondition(condition: () => boolean, description: string):
|
|
|
102
90
|
}
|
|
103
91
|
}
|
|
104
92
|
|
|
105
|
-
function restoreEnv(): void {
|
|
106
|
-
for (const [key, value] of Object.entries(savedEnv)) {
|
|
107
|
-
if (value === undefined) delete process.env[key];
|
|
108
|
-
else process.env[key] = value;
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
93
|
afterEach(() => {
|
|
113
|
-
restoreEnv();
|
|
114
94
|
delete process.env.PI_INTERCOM_ASK_TIMEOUT_MS;
|
|
115
95
|
for (const channel of createdChannels.splice(0)) fs.rmSync(channel, { recursive: true, force: true });
|
|
116
96
|
});
|
|
@@ -125,7 +105,7 @@ describe("native supervisor channel", () => {
|
|
|
125
105
|
message: { content?: string; details?: { id?: string } };
|
|
126
106
|
options?: { triggerTurn?: boolean };
|
|
127
107
|
}> = [];
|
|
128
|
-
const registeredTools: string
|
|
108
|
+
const registeredTools: Array<{ name: string; parameters: { properties: { action: unknown } } }> = [];
|
|
129
109
|
const ctx = {
|
|
130
110
|
cwd: process.cwd(),
|
|
131
111
|
hasUI: false,
|
|
@@ -137,7 +117,7 @@ describe("native supervisor channel", () => {
|
|
|
137
117
|
};
|
|
138
118
|
const pi = {
|
|
139
119
|
getAllTools: () => [],
|
|
140
|
-
registerTool: (tool:
|
|
120
|
+
registerTool: (tool: typeof registeredTools[number]) => { registeredTools.push(tool); },
|
|
141
121
|
sendMessage: (
|
|
142
122
|
message: { content?: string; details?: { id?: string } },
|
|
143
123
|
options?: { triggerTurn?: boolean },
|
|
@@ -150,7 +130,8 @@ describe("native supervisor channel", () => {
|
|
|
150
130
|
channel.start();
|
|
151
131
|
channel.dispose();
|
|
152
132
|
|
|
153
|
-
assert.deepEqual(registeredTools, [NATIVE_SUPERVISOR_TOOL_NAME]);
|
|
133
|
+
assert.deepEqual(registeredTools.map((tool) => tool.name), [NATIVE_SUPERVISOR_TOOL_NAME]);
|
|
134
|
+
assert.deepEqual(registeredTools[0]?.parameters.properties.action, { type: "string", enum: ["list", "pending", "status", "reply"] });
|
|
154
135
|
assert.deepEqual(sent.map(({ message }) => message.details?.id), [matchingId]);
|
|
155
136
|
assert.deepEqual(sent[0]?.options, { triggerTurn: true });
|
|
156
137
|
assert.equal(channel.pending.has(matchingId), false, "disposed channel clears pending requests");
|
|
@@ -671,6 +652,130 @@ describe("native supervisor channel", () => {
|
|
|
671
652
|
}
|
|
672
653
|
});
|
|
673
654
|
|
|
655
|
+
it("includes supervisor request metadata and journals a successful reply", async () => {
|
|
656
|
+
const currentSessionId = `session-${randomUUID()}`;
|
|
657
|
+
const runId = `run-${randomUUID()}`;
|
|
658
|
+
const requestId = writeRequest({
|
|
659
|
+
sessionId: currentSessionId,
|
|
660
|
+
runId,
|
|
661
|
+
agent: "worker",
|
|
662
|
+
index: 2,
|
|
663
|
+
message: "Should this change be applied?",
|
|
664
|
+
reason: "interview_request",
|
|
665
|
+
childTarget: "child-worker",
|
|
666
|
+
interview: { approved: "boolean", rationale: "string" },
|
|
667
|
+
});
|
|
668
|
+
const sent: Array<{ customType?: string; content?: string; details?: Record<string, unknown> }> = [];
|
|
669
|
+
const entries: Array<{ customType: string; data?: Record<string, unknown> }> = [];
|
|
670
|
+
const journalState = { replyExistsAtAppend: false, requestExistsAtAppend: true };
|
|
671
|
+
const registeredTools = new Map<string, { execute: (_id: string, params: { action: string; replyTo?: string; message?: string }) => Promise<unknown> }>();
|
|
672
|
+
const ctx = {
|
|
673
|
+
cwd: process.cwd(),
|
|
674
|
+
hasUI: false,
|
|
675
|
+
sessionManager: {
|
|
676
|
+
getSessionId: () => currentSessionId,
|
|
677
|
+
getSessionFile: () => null,
|
|
678
|
+
getEntries: () => [],
|
|
679
|
+
},
|
|
680
|
+
};
|
|
681
|
+
const pi = {
|
|
682
|
+
getAllTools: () => [...registeredTools.keys()].map((name) => ({ name })),
|
|
683
|
+
registerTool: (tool: { name: string; execute: (_id: string, params: { action: string; replyTo?: string; message?: string }) => Promise<unknown> }) => {
|
|
684
|
+
registeredTools.set(tool.name, tool);
|
|
685
|
+
},
|
|
686
|
+
sendMessage: (message: { customType?: string; content?: string; details?: Record<string, unknown> }) => { sent.push(message); },
|
|
687
|
+
appendEntry: (customType: string, data?: Record<string, unknown>) => {
|
|
688
|
+
journalState.replyExistsAtAppend = fs.existsSync(replyFile(runId, requestId, "worker", 2));
|
|
689
|
+
journalState.requestExistsAtAppend = fs.existsSync(requestFile(runId, requestId, "worker", 2));
|
|
690
|
+
entries.push({ customType, data });
|
|
691
|
+
},
|
|
692
|
+
getSessionName: () => "shared-name",
|
|
693
|
+
};
|
|
694
|
+
const channel = createNativeSupervisorChannel(pi as never, makeState(currentSessionId, ctx));
|
|
695
|
+
|
|
696
|
+
try {
|
|
697
|
+
channel.start();
|
|
698
|
+
assert.equal(sent.length, 1);
|
|
699
|
+
assert.equal(sent[0]?.customType, SUPERVISOR_REQUEST_MESSAGE_TYPE);
|
|
700
|
+
assert.match(sent[0]?.content ?? "", /Subagent requests a structured supervisor interview\./);
|
|
701
|
+
assert.match(sent[0]?.content ?? "", /Should this change be applied\?/);
|
|
702
|
+
assert.ok(sent[0]?.content?.includes(`Reply with: subagent_supervisor({ action: "reply", replyTo: "${requestId}", message: "..." })`));
|
|
703
|
+
assert.ok(sent[0]?.content?.includes(`Live guidance: subagent({ action: "steer", id: "${runId}", index: 2, message: "..." }) (Reply to the pending request first.)`));
|
|
704
|
+
assert.doesNotMatch(sent[0]?.content ?? "", /Child intercom target:|child-worker/);
|
|
705
|
+
assert.deepEqual(sent[0]?.details, {
|
|
706
|
+
id: requestId,
|
|
707
|
+
requestId,
|
|
708
|
+
reason: "interview_request",
|
|
709
|
+
expectsReply: true,
|
|
710
|
+
runId,
|
|
711
|
+
agent: "worker",
|
|
712
|
+
childIndex: 2,
|
|
713
|
+
childTarget: "child-worker",
|
|
714
|
+
interview: { approved: "boolean", rationale: "string" },
|
|
715
|
+
requestBody: "Should this change be applied?",
|
|
716
|
+
replyHint: `subagent_supervisor({ action: "reply", replyTo: "${requestId}", message: "..." })`,
|
|
717
|
+
});
|
|
718
|
+
|
|
719
|
+
await registeredTools.get(NATIVE_SUPERVISOR_TOOL_NAME)!.execute("reply", {
|
|
720
|
+
action: "reply",
|
|
721
|
+
replyTo: requestId,
|
|
722
|
+
message: "Approved with rationale",
|
|
723
|
+
});
|
|
724
|
+
|
|
725
|
+
assert.equal(entries.length, 1);
|
|
726
|
+
assert.equal(entries[0]?.customType, SUPERVISOR_REPLY_ENTRY_TYPE);
|
|
727
|
+
assert.deepEqual(journalState, { replyExistsAtAppend: true, requestExistsAtAppend: false });
|
|
728
|
+
assert.deepEqual({ ...entries[0]?.data, createdAt: undefined }, {
|
|
729
|
+
requestId,
|
|
730
|
+
reason: "interview_request",
|
|
731
|
+
runId,
|
|
732
|
+
agent: "worker",
|
|
733
|
+
childIndex: 2,
|
|
734
|
+
childTarget: "child-worker",
|
|
735
|
+
message: "Approved with rationale",
|
|
736
|
+
createdAt: undefined,
|
|
737
|
+
});
|
|
738
|
+
assert.equal(typeof entries[0]?.data?.createdAt, "number");
|
|
739
|
+
const reply = JSON.parse(fs.readFileSync(replyFile(runId, requestId, "worker", 2), "utf-8")) as { message?: string };
|
|
740
|
+
assert.equal(reply.message, "Approved with rationale");
|
|
741
|
+
assert.equal(fs.existsSync(requestFile(runId, requestId, "worker", 2)), false);
|
|
742
|
+
} finally {
|
|
743
|
+
channel.dispose();
|
|
744
|
+
}
|
|
745
|
+
});
|
|
746
|
+
|
|
747
|
+
it("keeps message-less interview metadata visible to the parent model", () => {
|
|
748
|
+
const currentSessionId = `session-${randomUUID()}`;
|
|
749
|
+
const runId = `run-${randomUUID()}`;
|
|
750
|
+
const requestId = writeRequest({ sessionId: currentSessionId, runId, reason: "interview_request", message: "", interview: { approved: "boolean" } });
|
|
751
|
+
const sent: Array<{ content?: string; details?: Record<string, unknown> }> = [];
|
|
752
|
+
const ctx = {
|
|
753
|
+
cwd: process.cwd(),
|
|
754
|
+
hasUI: false,
|
|
755
|
+
sessionManager: {
|
|
756
|
+
getSessionId: () => currentSessionId,
|
|
757
|
+
getSessionFile: () => null,
|
|
758
|
+
getEntries: () => [],
|
|
759
|
+
},
|
|
760
|
+
};
|
|
761
|
+
const pi = {
|
|
762
|
+
getAllTools: () => [],
|
|
763
|
+
registerTool: () => {},
|
|
764
|
+
sendMessage: (message: { content?: string; details?: Record<string, unknown> }) => { sent.push(message); },
|
|
765
|
+
getSessionName: () => "shared-name",
|
|
766
|
+
};
|
|
767
|
+
const channel = createNativeSupervisorChannel(pi as never, makeState(currentSessionId, ctx));
|
|
768
|
+
|
|
769
|
+
channel.start();
|
|
770
|
+
channel.dispose();
|
|
771
|
+
|
|
772
|
+
assert.equal(sent.length, 1);
|
|
773
|
+
assert.match(sent[0]?.content ?? "", /Structured response requested/);
|
|
774
|
+
assert.match(sent[0]?.content ?? "", /"approved": "boolean"/);
|
|
775
|
+
assert.match(sent[0]?.content ?? "", new RegExp(`replyTo: "${requestId}"`));
|
|
776
|
+
assert.equal(sent[0]?.details?.requestBody, "");
|
|
777
|
+
});
|
|
778
|
+
|
|
674
779
|
it("suppresses resolved, expired, and inactive requests before displaying them", () => {
|
|
675
780
|
const currentSessionId = `session-${randomUUID()}`;
|
|
676
781
|
const resolvedRunId = `run-${randomUUID()}`;
|
|
@@ -765,16 +870,47 @@ describe("native supervisor channel", () => {
|
|
|
765
870
|
}
|
|
766
871
|
});
|
|
767
872
|
|
|
873
|
+
it("stores only the child-authored supervisor message in the request body", async () => {
|
|
874
|
+
const runId = `run-${randomUUID()}`;
|
|
875
|
+
const channelDir = resolveSupervisorChannelDir(runId, "worker", 3);
|
|
876
|
+
createdChannels.push(channelDir);
|
|
877
|
+
const registeredTools = new Map<string, { execute: (_id: string, params: { reason: string; message?: string }) => Promise<unknown> | unknown }>();
|
|
878
|
+
const pi = {
|
|
879
|
+
getAllTools: () => [...registeredTools.keys()].map((name) => ({ name })),
|
|
880
|
+
registerTool: (tool: { name: string; execute: (_id: string, params: { reason: string; message?: string }) => Promise<unknown> | unknown }) => {
|
|
881
|
+
registeredTools.set(tool.name, tool);
|
|
882
|
+
},
|
|
883
|
+
};
|
|
884
|
+
registerNativeSupervisorClient(pi as never, {
|
|
885
|
+
channelDir,
|
|
886
|
+
runId,
|
|
887
|
+
agent: "worker",
|
|
888
|
+
childIndex: 3,
|
|
889
|
+
orchestratorTarget: "shared-name",
|
|
890
|
+
orchestratorSessionId: "session-parent",
|
|
891
|
+
});
|
|
892
|
+
|
|
893
|
+
await assert.rejects(
|
|
894
|
+
() => registeredTools.get("contact_supervisor")!.execute("blank-progress", { reason: "progress_update" }),
|
|
895
|
+
/message is required for supervisor decisions and progress updates/,
|
|
896
|
+
);
|
|
897
|
+
await registeredTools.get("contact_supervisor")!.execute("contact", {
|
|
898
|
+
reason: "progress_update",
|
|
899
|
+
message: " Finished the first review pass. ",
|
|
900
|
+
});
|
|
901
|
+
|
|
902
|
+
const [file] = fs.readdirSync(path.join(channelDir, "requests"));
|
|
903
|
+
const request = JSON.parse(fs.readFileSync(path.join(channelDir, "requests", file!), "utf-8")) as { message?: string; runId?: string; agent?: string; childIndex?: number };
|
|
904
|
+
assert.equal(request.message, "Finished the first review pass.");
|
|
905
|
+
assert.equal(request.runId, runId);
|
|
906
|
+
assert.equal(request.agent, "worker");
|
|
907
|
+
assert.equal(request.childIndex, 3);
|
|
908
|
+
});
|
|
909
|
+
|
|
768
910
|
it("removes the request file when a child supervisor ask is cancelled", async () => {
|
|
769
911
|
const runId = `run-${randomUUID()}`;
|
|
770
912
|
const channelDir = resolveSupervisorChannelDir(runId, "worker", 0);
|
|
771
913
|
createdChannels.push(channelDir);
|
|
772
|
-
process.env[SUBAGENT_ORCHESTRATOR_TARGET_ENV] = "shared-name";
|
|
773
|
-
process.env[SUBAGENT_ORCHESTRATOR_SESSION_ID_ENV] = "session-parent";
|
|
774
|
-
process.env[SUBAGENT_SUPERVISOR_CHANNEL_DIR_ENV] = channelDir;
|
|
775
|
-
process.env[SUBAGENT_RUN_ID_ENV] = runId;
|
|
776
|
-
process.env[SUBAGENT_CHILD_AGENT_ENV] = "worker";
|
|
777
|
-
process.env[SUBAGENT_CHILD_INDEX_ENV] = "0";
|
|
778
914
|
const registeredTools = new Map<string, { execute: (_id: string, params: { reason: string; message?: string }, signal?: AbortSignal) => Promise<unknown> | unknown }>();
|
|
779
915
|
const pi = {
|
|
780
916
|
getAllTools: () => [...registeredTools.keys()].map((name) => ({ name })),
|
|
@@ -782,7 +918,14 @@ describe("native supervisor channel", () => {
|
|
|
782
918
|
registeredTools.set(tool.name, tool);
|
|
783
919
|
},
|
|
784
920
|
};
|
|
785
|
-
registerNativeSupervisorClient(pi as never
|
|
921
|
+
registerNativeSupervisorClient(pi as never, {
|
|
922
|
+
channelDir,
|
|
923
|
+
runId,
|
|
924
|
+
agent: "worker",
|
|
925
|
+
childIndex: 0,
|
|
926
|
+
orchestratorTarget: "shared-name",
|
|
927
|
+
orchestratorSessionId: "session-parent",
|
|
928
|
+
});
|
|
786
929
|
const controller = new AbortController();
|
|
787
930
|
controller.abort();
|
|
788
931
|
|
|
@@ -793,4 +936,4 @@ describe("native supervisor channel", () => {
|
|
|
793
936
|
|
|
794
937
|
assert.deepEqual(fs.readdirSync(path.join(channelDir, "requests")), []);
|
|
795
938
|
});
|
|
796
|
-
});
|
|
939
|
+
});
|