@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
|
@@ -6,14 +6,11 @@ import { describe, it } from "node:test";
|
|
|
6
6
|
import {
|
|
7
7
|
closeSteerInbox,
|
|
8
8
|
consumeInterruptRequest,
|
|
9
|
-
consumeSteerAcks,
|
|
10
|
-
consumeSteerCapabilities,
|
|
11
9
|
consumeSteerRequests,
|
|
12
10
|
consumeStopRequest,
|
|
13
11
|
consumeStopRequestPayload,
|
|
14
12
|
consumeStopRequestPayloads,
|
|
15
13
|
deliverInterruptRequest,
|
|
16
|
-
enqueueStepSteer,
|
|
17
14
|
interruptRequestPath,
|
|
18
15
|
MAX_STEER_QUEUE_SIZE,
|
|
19
16
|
queueRevivalBrief,
|
|
@@ -21,16 +18,12 @@ import {
|
|
|
21
18
|
requestAsyncInterrupt,
|
|
22
19
|
requestAsyncSteer,
|
|
23
20
|
requestAsyncStop,
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
requestAsyncTimeout,
|
|
22
|
+
timeoutRequestPath,
|
|
26
23
|
steerInboxClosedPath,
|
|
27
|
-
steerCapabilityPath,
|
|
28
24
|
stopRequestsDir,
|
|
29
|
-
writeSteerAck,
|
|
30
|
-
writeSteerCapability,
|
|
31
25
|
stopRequestPath,
|
|
32
26
|
steerRequestsDir,
|
|
33
|
-
stepSteerInboxDir,
|
|
34
27
|
watchAsyncControlInbox,
|
|
35
28
|
} from "../../src/runs/background/control-channel.ts";
|
|
36
29
|
|
|
@@ -265,19 +258,6 @@ describe("control channel: request file", () => {
|
|
|
265
258
|
}
|
|
266
259
|
});
|
|
267
260
|
|
|
268
|
-
it("enqueues a steer request for a specific child inbox", () => {
|
|
269
|
-
const asyncDir = tmpAsyncDir("pi-control-step-steer-");
|
|
270
|
-
try {
|
|
271
|
-
enqueueStepSteer(asyncDir, 2, { type: "steer", id: "s1", ts: 300, message: "focus", targetIndexes: [0, 1] });
|
|
272
|
-
const request = JSON.parse(fs.readFileSync(path.join(stepSteerInboxDir(asyncDir, 2), fs.readdirSync(stepSteerInboxDir(asyncDir, 2))[0]!), "utf-8"));
|
|
273
|
-
assert.equal(request.targetIndex, 2);
|
|
274
|
-
assert.equal(request.targetIndexes, undefined);
|
|
275
|
-
assert.equal(request.message, "focus");
|
|
276
|
-
} finally {
|
|
277
|
-
cleanup(asyncDir);
|
|
278
|
-
}
|
|
279
|
-
});
|
|
280
|
-
|
|
281
261
|
it("bounds retained revival briefs and keeps them FIFO", () => {
|
|
282
262
|
const asyncDir = tmpAsyncDir("pi-control-revival-brief-");
|
|
283
263
|
try {
|
|
@@ -308,47 +288,6 @@ describe("control channel: request file", () => {
|
|
|
308
288
|
}
|
|
309
289
|
});
|
|
310
290
|
|
|
311
|
-
it("writes strict capabilities and acknowledgments with safe paths", () => {
|
|
312
|
-
const asyncDir = tmpAsyncDir("pi-control-steer-ack-");
|
|
313
|
-
try {
|
|
314
|
-
const capabilityPath = writeSteerCapability(asyncDir, { index: 0, pid: 42, readyAt: 100, supported: true });
|
|
315
|
-
assert.equal(capabilityPath, steerCapabilityPath(asyncDir, 0));
|
|
316
|
-
writeSteerAck(asyncDir, { requestId: "../request", index: 0, ts: 101, state: "queued", deliveryStatus: "queued", message: "accepted" });
|
|
317
|
-
assert.equal(path.dirname(steerAckPathFromDir(steerAcksDir(asyncDir, 0), "../request")), steerAcksDir(asyncDir, 0));
|
|
318
|
-
assert.deepEqual(consumeSteerCapabilities(asyncDir), [{ type: "steer-capability", protocolVersion: 1, index: 0, pid: 42, readyAt: 100, supported: true }]);
|
|
319
|
-
assert.deepEqual(consumeSteerAcks(asyncDir), [{ type: "steer-ack", protocolVersion: 1, requestId: "../request", index: 0, ts: 101, state: "queued", deliveryStatus: "queued", message: "accepted" }]);
|
|
320
|
-
assert.deepEqual(consumeSteerAcks(asyncDir), []);
|
|
321
|
-
} finally {
|
|
322
|
-
cleanup(asyncDir);
|
|
323
|
-
}
|
|
324
|
-
});
|
|
325
|
-
|
|
326
|
-
it("preserves queued and delivered receipts for the same request", () => {
|
|
327
|
-
const asyncDir = tmpAsyncDir("pi-control-steer-ack-order-");
|
|
328
|
-
try {
|
|
329
|
-
writeSteerAck(asyncDir, { requestId: "follow", index: 0, ts: 101, state: "queued", deliveryStatus: "queued", message: "queued" });
|
|
330
|
-
writeSteerAck(asyncDir, { requestId: "follow", index: 0, ts: 102, state: "delivered", deliveryStatus: "delivered", message: "delivered" });
|
|
331
|
-
assert.deepEqual(consumeSteerAcks(asyncDir).map((ack) => ack.state), ["queued", "delivered"]);
|
|
332
|
-
} finally {
|
|
333
|
-
cleanup(asyncDir);
|
|
334
|
-
}
|
|
335
|
-
});
|
|
336
|
-
|
|
337
|
-
it("ignores malformed capabilities and acknowledgments", () => {
|
|
338
|
-
const asyncDir = tmpAsyncDir("pi-control-steer-malformed-");
|
|
339
|
-
try {
|
|
340
|
-
fs.mkdirSync(path.join(asyncDir, "control", "steer-capabilities"), { recursive: true });
|
|
341
|
-
fs.writeFileSync(steerCapabilityPath(asyncDir, 0), JSON.stringify({ type: "steer-capability", protocolVersion: 99 }), "utf-8");
|
|
342
|
-
fs.mkdirSync(steerAcksDir(asyncDir, 0), { recursive: true });
|
|
343
|
-
fs.writeFileSync(path.join(steerAcksDir(asyncDir, 0), "bad.json"), JSON.stringify({ type: "steer-ack", protocolVersion: 1, requestId: "", index: 0, ts: 1, state: "delivered", message: "bad" }), "utf-8");
|
|
344
|
-
fs.writeFileSync(path.join(asyncDir, "control", "steer-acks", "1"), "not a directory", "utf-8");
|
|
345
|
-
writeSteerAck(asyncDir, { requestId: "valid", index: 2, ts: 2, state: "delivered", message: "accepted" });
|
|
346
|
-
assert.deepEqual(consumeSteerCapabilities(asyncDir), []);
|
|
347
|
-
assert.deepEqual(consumeSteerAcks(asyncDir), [{ type: "steer-ack", protocolVersion: 1, requestId: "valid", index: 2, ts: 2, state: "delivered", message: "accepted" }]);
|
|
348
|
-
} finally {
|
|
349
|
-
cleanup(asyncDir);
|
|
350
|
-
}
|
|
351
|
-
});
|
|
352
291
|
});
|
|
353
292
|
|
|
354
293
|
describe("control channel: deliverInterruptRequest", () => {
|
|
@@ -538,17 +477,23 @@ describe("control channel: watchAsyncControlInbox", () => {
|
|
|
538
477
|
try {
|
|
539
478
|
requestAsyncStop(asyncDir);
|
|
540
479
|
requestAsyncInterrupt(asyncDir);
|
|
480
|
+
requestAsyncTimeout(asyncDir);
|
|
481
|
+
requestAsyncSteer(asyncDir, { id: "all-handlers", message: "guide" });
|
|
541
482
|
const events: string[] = [];
|
|
542
483
|
const h = harness();
|
|
543
484
|
const dispose = watchAsyncControlInbox(asyncDir, {
|
|
544
485
|
onInterrupt: () => events.push("interrupt"),
|
|
545
486
|
onStop: () => events.push("stop"),
|
|
487
|
+
onTimeout: () => events.push("timeout"),
|
|
488
|
+
onSteer: () => events.push("steer"),
|
|
546
489
|
fs: h.fsImpl,
|
|
547
490
|
timers: h.timers,
|
|
548
491
|
platform: "linux",
|
|
549
492
|
});
|
|
550
493
|
|
|
551
|
-
assert.deepEqual(events, ["stop", "interrupt"]);
|
|
494
|
+
assert.deepEqual(events, ["stop", "timeout", "interrupt", "steer"]);
|
|
495
|
+
h.trigger();
|
|
496
|
+
assert.deepEqual(events, ["stop", "timeout", "interrupt", "steer"], "all-handler runner consumes each request once");
|
|
552
497
|
dispose();
|
|
553
498
|
} finally {
|
|
554
499
|
cleanup(asyncDir);
|
|
@@ -627,4 +572,219 @@ describe("control channel: watchAsyncControlInbox", () => {
|
|
|
627
572
|
cleanup(asyncDir);
|
|
628
573
|
}
|
|
629
574
|
});
|
|
630
|
-
|
|
575
|
+
|
|
576
|
+
it("consumes a steer request that arrived before the watcher started", () => {
|
|
577
|
+
const asyncDir = tmpAsyncDir("pi-steer-watch-early-");
|
|
578
|
+
try {
|
|
579
|
+
requestAsyncSteer(asyncDir, { message: "queued before install", id: "s1", ts: 1 });
|
|
580
|
+
const steers: string[] = [];
|
|
581
|
+
const h = harness();
|
|
582
|
+
const dispose = watchAsyncControlInbox(asyncDir, { onSteer: (request) => steers.push(request.message), fs: h.fsImpl, timers: h.timers, platform: "linux" });
|
|
583
|
+
assert.deepEqual(steers, ["queued before install"]);
|
|
584
|
+
assert.deepEqual(fs.readdirSync(steerRequestsDir(asyncDir)), []);
|
|
585
|
+
dispose();
|
|
586
|
+
} finally {
|
|
587
|
+
cleanup(asyncDir);
|
|
588
|
+
}
|
|
589
|
+
});
|
|
590
|
+
|
|
591
|
+
it("consumes later requests via the watch event and stops after dispose", () => {
|
|
592
|
+
const asyncDir = tmpAsyncDir("pi-steer-watch-event-");
|
|
593
|
+
try {
|
|
594
|
+
const steers: string[] = [];
|
|
595
|
+
const h = harness();
|
|
596
|
+
const dispose = watchAsyncControlInbox(asyncDir, { onSteer: (request) => steers.push(request.message), fs: h.fsImpl, timers: h.timers, platform: "linux" });
|
|
597
|
+
assert.deepEqual(steers, []);
|
|
598
|
+
|
|
599
|
+
requestAsyncSteer(asyncDir, { message: "first", id: "s1", ts: 1 });
|
|
600
|
+
h.trigger();
|
|
601
|
+
assert.deepEqual(steers, ["first"]);
|
|
602
|
+
|
|
603
|
+
// A spurious event with nothing queued is a no-op.
|
|
604
|
+
h.trigger();
|
|
605
|
+
assert.deepEqual(steers, ["first"]);
|
|
606
|
+
|
|
607
|
+
dispose();
|
|
608
|
+
assert.equal(h.closed(), true);
|
|
609
|
+
|
|
610
|
+
requestAsyncSteer(asyncDir, { message: "after dispose", id: "s2", ts: 2 });
|
|
611
|
+
h.trigger();
|
|
612
|
+
assert.deepEqual(steers, ["first"], "a disposed watcher must not consume further requests");
|
|
613
|
+
} finally {
|
|
614
|
+
cleanup(asyncDir);
|
|
615
|
+
}
|
|
616
|
+
});
|
|
617
|
+
|
|
618
|
+
it("watches only the steer directory, so a stop request stays for its own consumer", () => {
|
|
619
|
+
const asyncDir = tmpAsyncDir("pi-steer-watch-scope-");
|
|
620
|
+
try {
|
|
621
|
+
requestAsyncStop(asyncDir, { source: "test" });
|
|
622
|
+
requestAsyncInterrupt(asyncDir);
|
|
623
|
+
requestAsyncTimeout(asyncDir);
|
|
624
|
+
const steers: string[] = [];
|
|
625
|
+
const h = harness();
|
|
626
|
+
const dispose = watchAsyncControlInbox(asyncDir, { onSteer: (request) => steers.push(request.message), fs: h.fsImpl, timers: h.timers, platform: "linux" });
|
|
627
|
+
h.trigger();
|
|
628
|
+
assert.deepEqual(steers, []);
|
|
629
|
+
assert.equal(h.watchedDir(), fs.realpathSync.native(steerRequestsDir(asyncDir)));
|
|
630
|
+
assert.equal(fs.readdirSync(stopRequestsDir(asyncDir)).length, 1, "a stop request must not be consumed by the steer watcher");
|
|
631
|
+
assert.equal(fs.existsSync(interruptRequestPath(asyncDir)), true);
|
|
632
|
+
assert.equal(fs.existsSync(timeoutRequestPath(asyncDir)), true);
|
|
633
|
+
dispose();
|
|
634
|
+
} finally {
|
|
635
|
+
cleanup(asyncDir);
|
|
636
|
+
}
|
|
637
|
+
});
|
|
638
|
+
|
|
639
|
+
it("keeps watching when a consumer throws", () => {
|
|
640
|
+
const asyncDir = tmpAsyncDir("pi-steer-watch-throws-");
|
|
641
|
+
try {
|
|
642
|
+
const seen: string[] = [];
|
|
643
|
+
const failures: string[] = [];
|
|
644
|
+
const h = harness();
|
|
645
|
+
const dispose = watchAsyncControlInbox(asyncDir, {
|
|
646
|
+
onError: (_error, phase, request) => failures.push(`${phase}:${request?.id}`),
|
|
647
|
+
onSteer: (request) => {
|
|
648
|
+
seen.push(request.message);
|
|
649
|
+
if (request.message === "boom") throw new Error("consumer failed");
|
|
650
|
+
},
|
|
651
|
+
fs: h.fsImpl,
|
|
652
|
+
timers: h.timers,
|
|
653
|
+
platform: "linux",
|
|
654
|
+
});
|
|
655
|
+
|
|
656
|
+
requestAsyncSteer(asyncDir, { message: "boom", id: "s1", ts: 1 });
|
|
657
|
+
requestAsyncSteer(asyncDir, { message: "still delivered", id: "s2", ts: 2 });
|
|
658
|
+
h.trigger();
|
|
659
|
+
|
|
660
|
+
assert.deepEqual(seen, ["boom", "still delivered"], "a throwing consumer must not kill the watcher");
|
|
661
|
+
assert.deepEqual(failures, ["callback:s1"]);
|
|
662
|
+
dispose();
|
|
663
|
+
} finally {
|
|
664
|
+
cleanup(asyncDir);
|
|
665
|
+
}
|
|
666
|
+
});
|
|
667
|
+
});
|
|
668
|
+
|
|
669
|
+
describe("control inbox diagnostics and active-owner cost", () => {
|
|
670
|
+
for (const operation of ["read", "remove"] as const) it(`retries stop request ${operation} failures without losing readable siblings`, () => {
|
|
671
|
+
const asyncDir = tmpAsyncDir("pi-stop-retry-");
|
|
672
|
+
const denied = Object.assign(new Error("denied"), { code: "EACCES" });
|
|
673
|
+
const pending = requestAsyncStop(asyncDir, { childId: "retry" });
|
|
674
|
+
requestAsyncStop(asyncDir, { childId: "ready" });
|
|
675
|
+
const seen: string[] = [], failures: unknown[] = [];
|
|
676
|
+
let failing = true, tick = () => {};
|
|
677
|
+
const dispose = watchAsyncControlInbox(asyncDir, {
|
|
678
|
+
onStop: (request) => seen.push(request.childId!),
|
|
679
|
+
onError: (error, phase) => { assert.equal(phase, "scan"); failures.push(error); },
|
|
680
|
+
platform: "darwin",
|
|
681
|
+
fs: { ...fs, readFileSync: ((...args: Parameters<typeof fs.readFileSync>) => {
|
|
682
|
+
if (failing && operation === "read" && args[0] === pending) throw denied;
|
|
683
|
+
return fs.readFileSync(...args);
|
|
684
|
+
}) as typeof fs.readFileSync, rmSync: (target, options) => {
|
|
685
|
+
if (failing && operation === "remove" && target === pending) throw denied;
|
|
686
|
+
fs.rmSync(target, options);
|
|
687
|
+
} },
|
|
688
|
+
timers: { setInterval: ((handler: () => void) => { tick = handler; return { unref() {} }; }) as unknown as typeof setInterval, clearInterval() {} },
|
|
689
|
+
});
|
|
690
|
+
try {
|
|
691
|
+
assert.deepEqual(seen, ["ready"]);
|
|
692
|
+
assert.deepEqual(failures, [denied]);
|
|
693
|
+
assert.equal(fs.existsSync(pending), true);
|
|
694
|
+
failing = false;
|
|
695
|
+
tick();
|
|
696
|
+
assert.deepEqual(seen, ["ready", "retry"]);
|
|
697
|
+
assert.equal(fs.existsSync(pending), false);
|
|
698
|
+
tick();
|
|
699
|
+
assert.deepEqual(seen, ["ready", "retry"]);
|
|
700
|
+
} finally { dispose(); cleanup(asyncDir); }
|
|
701
|
+
});
|
|
702
|
+
|
|
703
|
+
it("reports scan/read/install failures, retains retryable files, and distinguishes healthy watch fallback", () => {
|
|
704
|
+
const asyncDir = tmpAsyncDir("pi-steer-diagnostics-");
|
|
705
|
+
const failures: string[] = [];
|
|
706
|
+
const seen: string[] = [];
|
|
707
|
+
let tick: () => void = () => {};
|
|
708
|
+
let fault: "scan" | "read" | "none" = "scan";
|
|
709
|
+
const denied = Object.assign(new Error("denied"), { code: "EACCES" });
|
|
710
|
+
const dispose = watchAsyncControlInbox(asyncDir, {
|
|
711
|
+
onSteer: (request) => seen.push(request.id),
|
|
712
|
+
onError: (_error, phase) => failures.push(phase),
|
|
713
|
+
platform: "linux",
|
|
714
|
+
fs: {
|
|
715
|
+
...fs,
|
|
716
|
+
mkdirSync: (() => { throw denied; }) as typeof fs.mkdirSync,
|
|
717
|
+
readdirSync: ((...args: Parameters<typeof fs.readdirSync>) => { if (fault === "scan") throw denied; return fs.readdirSync(...args); }) as typeof fs.readdirSync,
|
|
718
|
+
readFileSync: ((...args: Parameters<typeof fs.readFileSync>) => { if (fault === "read") throw denied; return fs.readFileSync(...args); }) as typeof fs.readFileSync,
|
|
719
|
+
watch: (() => { throw new Error("native watch unavailable"); }) as typeof fs.watch,
|
|
720
|
+
},
|
|
721
|
+
timers: {
|
|
722
|
+
setInterval: ((handler: () => void) => { tick = handler; return { unref() {} }; }) as unknown as typeof setInterval,
|
|
723
|
+
clearInterval: (() => {}) as typeof clearInterval,
|
|
724
|
+
},
|
|
725
|
+
});
|
|
726
|
+
try {
|
|
727
|
+
requestAsyncSteer(asyncDir, { id: "retry", message: "retry" });
|
|
728
|
+
tick();
|
|
729
|
+
assert.deepEqual(failures, ["install", "scan", "scan"]);
|
|
730
|
+
assert.equal(fs.readdirSync(steerRequestsDir(asyncDir)).length, 1);
|
|
731
|
+
fault = "read";
|
|
732
|
+
tick();
|
|
733
|
+
assert.equal(failures.at(-1), "scan");
|
|
734
|
+
assert.equal(fs.readdirSync(steerRequestsDir(asyncDir)).length, 1);
|
|
735
|
+
fault = "none";
|
|
736
|
+
tick();
|
|
737
|
+
assert.deepEqual(seen, ["retry"]);
|
|
738
|
+
assert.deepEqual(fs.readdirSync(steerRequestsDir(asyncDir)), []);
|
|
739
|
+
assert.equal(failures.length, 4, "healthy fallback does not report consumption failure");
|
|
740
|
+
} finally { dispose(); cleanup(asyncDir); }
|
|
741
|
+
});
|
|
742
|
+
|
|
743
|
+
for (const mode of ["native", "fallback", "portable"]) for (const owners of [1, 8]) it(`measures bounded empty-inbox ${mode} and cleanup for ${owners} active owners`, async (t) => {
|
|
744
|
+
const asyncDir = tmpAsyncDir("pi-steer-cost-");
|
|
745
|
+
const handles = new Set<ReturnType<typeof setInterval>>();
|
|
746
|
+
const watchers = new Set<fs.FSWatcher>();
|
|
747
|
+
const watchedDirs: string[] = [];
|
|
748
|
+
const disposers: Array<() => void> = [];
|
|
749
|
+
let scans = 0;
|
|
750
|
+
let scanMs = 0;
|
|
751
|
+
const cpuStart = process.cpuUsage();
|
|
752
|
+
const start = performance.now();
|
|
753
|
+
try {
|
|
754
|
+
for (let index = 0; index < owners; index++) disposers.push(watchAsyncControlInbox(path.join(asyncDir, String(index)), {
|
|
755
|
+
onSteer() {}, platform: mode === "portable" ? "darwin" : "linux",
|
|
756
|
+
fs: { ...fs, readdirSync: ((...args: Parameters<typeof fs.readdirSync>) => {
|
|
757
|
+
const before = performance.now();
|
|
758
|
+
try { return fs.readdirSync(...args); } finally { scans++; scanMs += performance.now() - before; }
|
|
759
|
+
}) as typeof fs.readdirSync, watch: ((target: string, listener: fs.WatchListener<string>) => {
|
|
760
|
+
watchedDirs.push(target);
|
|
761
|
+
const watcher = fs.watch(target, listener);
|
|
762
|
+
watchers.add(watcher);
|
|
763
|
+
const close = watcher.close.bind(watcher);
|
|
764
|
+
watcher.close = () => { watchers.delete(watcher); close(); };
|
|
765
|
+
if (mode === "fallback") queueMicrotask(() => watcher.emit("error", new Error("watch unavailable")));
|
|
766
|
+
return watcher;
|
|
767
|
+
}) as typeof fs.watch },
|
|
768
|
+
timers: {
|
|
769
|
+
setInterval: ((handler: () => void, delay: number) => { const handle = setInterval(handler, delay); handles.add(handle); return handle; }) as typeof setInterval,
|
|
770
|
+
clearInterval: ((handle: ReturnType<typeof setInterval>) => { handles.delete(handle); clearInterval(handle); }) as typeof clearInterval,
|
|
771
|
+
},
|
|
772
|
+
}));
|
|
773
|
+
await new Promise((resolve) => setTimeout(resolve, 1_100));
|
|
774
|
+
const elapsed = performance.now() - start;
|
|
775
|
+
const cpu = process.cpuUsage(cpuStart);
|
|
776
|
+
assert.ok(scans >= owners && scans <= owners * 6, `bounded scans: ${scans}`);
|
|
777
|
+
assert.equal(handles.size, owners);
|
|
778
|
+
assert.equal(watchers.size, mode === "portable" ? 0 : owners);
|
|
779
|
+
assert.equal(watchedDirs.length, mode === "portable" ? 0 : owners, "only one directory watched per steer owner");
|
|
780
|
+
assert.ok(watchedDirs.every((dir) => dir.endsWith("steer-requests")));
|
|
781
|
+
for (const dispose of disposers) { dispose(); dispose(); }
|
|
782
|
+
assert.equal(handles.size, 0, "all real polling intervals cleared");
|
|
783
|
+
assert.equal(watchers.size, 0, "all native watchers closed");
|
|
784
|
+
const finalScans = scans;
|
|
785
|
+
await new Promise((resolve) => setTimeout(resolve, 300));
|
|
786
|
+
assert.equal(scans, finalScans, "no scans after owner cleanup");
|
|
787
|
+
t.diagnostic(JSON.stringify({ mode, owners, elapsedMs: +elapsed.toFixed(2), scans, scanMs: +scanMs.toFixed(3), processCpuMs: (cpu.user + cpu.system) / 1000, remainingTimers: handles.size, remainingWatchers: watchers.size }));
|
|
788
|
+
} finally { for (const dispose of disposers) dispose(); cleanup(asyncDir); }
|
|
789
|
+
});
|
|
790
|
+
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import assert from "node:assert/strict";
|
|
2
|
-
import * as
|
|
3
|
-
import {
|
|
2
|
+
import * as os from "node:os";
|
|
3
|
+
import { describe, it } from "node:test";
|
|
4
4
|
import { launchBindingDigest } from "../../src/shared/launch-contract.ts";
|
|
5
5
|
import {
|
|
6
6
|
MAX_EXTENSION_BINDING_NAMESPACES,
|
|
@@ -10,29 +10,22 @@ import {
|
|
|
10
10
|
normalizeExtensionBindings,
|
|
11
11
|
omitExtensionBindingsEnv,
|
|
12
12
|
} from "../../src/runs/shared/extension-bindings.ts";
|
|
13
|
-
import {
|
|
13
|
+
import { buildInProcessChildLaunch } from "../../src/runs/shared/child-launch.ts";
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
const tempDirs: string[] = [];
|
|
17
|
-
|
|
18
|
-
afterEach(() => {
|
|
19
|
-
if (originalBindingEnv === undefined) delete process.env[SELESAI_SUBAGENT_EXTENSION_BINDINGS_ENV];
|
|
20
|
-
else process.env[SELESAI_SUBAGENT_EXTENSION_BINDINGS_ENV] = originalBindingEnv;
|
|
21
|
-
for (const dir of tempDirs.splice(0)) fs.rmSync(dir, { recursive: true, force: true });
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
function childEnv(extensionBindings?: ExtensionBindings): Record<string, string | undefined> {
|
|
15
|
+
function childEnv(extensionBindings?: ExtensionBindings, host: "parent" | "runner" = "runner"): Record<string, string | undefined> {
|
|
25
16
|
const normalizedExtensionBindings = normalizeExtensionBindings(extensionBindings)?.value;
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
17
|
+
const launch = buildInProcessChildLaunch({
|
|
18
|
+
host,
|
|
19
|
+
cwd: os.tmpdir(),
|
|
20
|
+
childAgentName: "worker",
|
|
21
|
+
childIndex: 0,
|
|
29
22
|
sessionEnabled: false,
|
|
30
23
|
inheritProjectContext: false,
|
|
24
|
+
inheritGlobalContext: false,
|
|
31
25
|
inheritSkills: false,
|
|
32
26
|
extensionBindings: normalizedExtensionBindings,
|
|
33
27
|
});
|
|
34
|
-
|
|
35
|
-
return result.env;
|
|
28
|
+
return launch.session.processEnv ?? {};
|
|
36
29
|
}
|
|
37
30
|
|
|
38
31
|
describe("extension bindings", () => {
|
|
@@ -58,10 +51,12 @@ describe("extension bindings", () => {
|
|
|
58
51
|
assert.throws(() => normalizeExtensionBindings(accessor), /data property/);
|
|
59
52
|
});
|
|
60
53
|
|
|
61
|
-
it("sets canonical child
|
|
62
|
-
|
|
63
|
-
assert.equal(
|
|
54
|
+
it("sets canonical child env for the runner host and clears it when omitted", () => {
|
|
55
|
+
const omitted = childEnv();
|
|
56
|
+
assert.equal(Object.hasOwn(omitted, SELESAI_SUBAGENT_EXTENSION_BINDINGS_ENV), true);
|
|
57
|
+
assert.equal(omitted[SELESAI_SUBAGENT_EXTENSION_BINDINGS_ENV], undefined);
|
|
64
58
|
assert.equal(childEnv({ "child/1": { z: 1, a: 2 } })[SELESAI_SUBAGENT_EXTENSION_BINDINGS_ENV], '{"child/1":{"a":2,"z":1}}');
|
|
59
|
+
assert.deepEqual(childEnv({ "child/1": true }, "parent"), {}, "the parent host never writes child environment values");
|
|
65
60
|
});
|
|
66
61
|
|
|
67
62
|
it("removes ambient bindings from external runner environments", () => {
|
|
@@ -76,4 +71,4 @@ describe("extension bindings", () => {
|
|
|
76
71
|
assert.notEqual(first, omitted);
|
|
77
72
|
assert.notEqual(first, second);
|
|
78
73
|
});
|
|
79
|
-
});
|
|
74
|
+
});
|
|
@@ -178,6 +178,16 @@ describe("below-editor subagent FleetView", () => {
|
|
|
178
178
|
assert.ok(compactLines[0]!.includes("↓/← to inspect"));
|
|
179
179
|
assert.ok(visibleWidth(compactLines[0]!) <= 80);
|
|
180
180
|
|
|
181
|
+
state.activeAsyncCapacity = { used: 0, limit: 0 };
|
|
182
|
+
const unlimitedIdleSummary = component.render(80)[0]!;
|
|
183
|
+
assert.match(unlimitedIdleSummary, /7 active agents/);
|
|
184
|
+
assert.doesNotMatch(unlimitedIdleSummary, /Async runs 0\/∞/);
|
|
185
|
+
state.activeAsyncCapacity = { used: 2, limit: 0 };
|
|
186
|
+
assert.match(component.render(80)[0]!, /Async runs 2\/∞/);
|
|
187
|
+
state.activeAsyncCapacity = { used: 0, limit: 4 };
|
|
188
|
+
assert.match(component.render(80)[0]!, /Async runs 0\/4/);
|
|
189
|
+
state.activeAsyncCapacity = { used: 2, limit: 4 };
|
|
190
|
+
|
|
181
191
|
assert.deepEqual(fleet.handleKey("\x1b[B"), { consume: true });
|
|
182
192
|
const expandedLines = component.render(80);
|
|
183
193
|
assert.ok(expandedLines.some((line) => line.includes("> main")));
|
|
@@ -1374,4 +1384,4 @@ describe("below-editor subagent FleetView", () => {
|
|
|
1374
1384
|
fleet.dispose();
|
|
1375
1385
|
}
|
|
1376
1386
|
});
|
|
1377
|
-
});
|
|
1387
|
+
});
|
|
@@ -44,6 +44,7 @@ function writeAsyncRun(root: string, input: {
|
|
|
44
44
|
state?: "running" | "complete" | "failed";
|
|
45
45
|
mode?: "single" | "parallel" | "workflow";
|
|
46
46
|
lastUpdate?: number;
|
|
47
|
+
startedAt?: number;
|
|
47
48
|
agents?: string[];
|
|
48
49
|
contexts?: Array<"fresh" | "fork">;
|
|
49
50
|
models?: string[];
|
|
@@ -63,7 +64,7 @@ function writeAsyncRun(root: string, input: {
|
|
|
63
64
|
sessionId: input.sessionId ?? "session-current",
|
|
64
65
|
mode: input.mode ?? (agents.length > 1 ? "parallel" : "single"),
|
|
65
66
|
state,
|
|
66
|
-
startedAt: 100,
|
|
67
|
+
startedAt: input.startedAt ?? 100,
|
|
67
68
|
lastUpdate: input.lastUpdate ?? 200,
|
|
68
69
|
currentStep: 0,
|
|
69
70
|
steps: agents.map((agent, index) => ({
|
|
@@ -446,6 +447,29 @@ describe("native subagent fleet", () => {
|
|
|
446
447
|
}
|
|
447
448
|
});
|
|
448
449
|
|
|
450
|
+
it("keeps tracked missing-start rows stable across opposing heartbeat updates", () => {
|
|
451
|
+
const state = stateForTest();
|
|
452
|
+
state.fleetJobs = new Map();
|
|
453
|
+
for (const [id, startedAt, status] of [
|
|
454
|
+
["known", 100, "running"], ["unknown-b", undefined, "running"], ["unknown-a", undefined, "queued"],
|
|
455
|
+
] as const) {
|
|
456
|
+
state.fleetJobs.set(id, {
|
|
457
|
+
asyncId: id, asyncDir: `/tmp/${id}`, sessionId: "session-current", status, startedAt,
|
|
458
|
+
});
|
|
459
|
+
}
|
|
460
|
+
for (const direction of [1, -1]) {
|
|
461
|
+
let heartbeat = 500;
|
|
462
|
+
for (const job of state.fleetJobs.values()) job.updatedAt = heartbeat += direction * 10;
|
|
463
|
+
const snapshot = collectFleetSnapshot(state);
|
|
464
|
+
assert.equal(snapshot.error, undefined);
|
|
465
|
+
assert.deepEqual(snapshot.items.map((item) => item.key), ["async:unknown-a", "async:unknown-b", "async:known"]);
|
|
466
|
+
for (const item of snapshot.items) {
|
|
467
|
+
const job = state.fleetJobs.get(item.runId)!;
|
|
468
|
+
assert.equal(item.run?.startedAt, job.startedAt ?? job.updatedAt);
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
});
|
|
472
|
+
|
|
449
473
|
it("keeps tracked active workflows ahead of older failed terminal history", () => {
|
|
450
474
|
const root = fs.mkdtempSync(path.join(os.tmpdir(), "pi-fleet-history-"));
|
|
451
475
|
try {
|
|
@@ -627,8 +651,8 @@ describe("native subagent fleet", () => {
|
|
|
627
651
|
});
|
|
628
652
|
const snapshot = collectFleetSnapshot(state);
|
|
629
653
|
assert.deepEqual(snapshot.items.map((item) => item.key), [
|
|
630
|
-
"foreground-active:child-2:0",
|
|
631
654
|
"foreground-active:child-1:0",
|
|
655
|
+
"foreground-active:child-2:0",
|
|
632
656
|
"async:unrelated",
|
|
633
657
|
"async:workflow-1",
|
|
634
658
|
]);
|
|
@@ -697,6 +721,26 @@ describe("native subagent fleet", () => {
|
|
|
697
721
|
assert.ok(!snapshot.items.some((item) => item.runId === "terminal-0"));
|
|
698
722
|
});
|
|
699
723
|
|
|
724
|
+
it("orders active runs by start time so the roster stays stable while they emit", () => {
|
|
725
|
+
const root = fs.mkdtempSync(path.join(os.tmpdir(), "pi-fleet-active-order-"));
|
|
726
|
+
try {
|
|
727
|
+
writeAsyncRun(root, { id: "worker-b", startedAt: 200, lastUpdate: 900 });
|
|
728
|
+
writeAsyncRun(root, { id: "worker-a", startedAt: 100, lastUpdate: 500 });
|
|
729
|
+
const state = stateForTest();
|
|
730
|
+
const keys = () => collectFleetSnapshot(state, { asyncDirRoot: root, resultsDir: path.join(root, "results") }).items.map((item) => item.key);
|
|
731
|
+
// First refresh: the run created first stays on top, even though worker-b emitted most recently.
|
|
732
|
+
assert.deepEqual(keys(), ["async:worker-a:0", "async:worker-b:0"]);
|
|
733
|
+
// Later activity on worker-b must not reorder the roster.
|
|
734
|
+
writeAsyncRun(root, { id: "worker-b", startedAt: 200, lastUpdate: 1500 });
|
|
735
|
+
assert.deepEqual(keys(), ["async:worker-a:0", "async:worker-b:0"]);
|
|
736
|
+
// A run started later still lands after the earlier ones.
|
|
737
|
+
writeAsyncRun(root, { id: "worker-c", startedAt: 300, lastUpdate: 300 });
|
|
738
|
+
assert.deepEqual(keys(), ["async:worker-a:0", "async:worker-b:0", "async:worker-c:0"]);
|
|
739
|
+
} finally {
|
|
740
|
+
fs.rmSync(root, { recursive: true, force: true });
|
|
741
|
+
}
|
|
742
|
+
});
|
|
743
|
+
|
|
700
744
|
it("accepts default Fleet navigation from Kitty CSI-u input", () => {
|
|
701
745
|
const root = fs.mkdtempSync(path.join(os.tmpdir(), "pi-fleet-kitty-default-"));
|
|
702
746
|
try {
|
|
@@ -1783,4 +1827,4 @@ describe("native subagent fleet", () => {
|
|
|
1783
1827
|
fs.rmSync(root, { recursive: true, force: true });
|
|
1784
1828
|
}
|
|
1785
1829
|
});
|
|
1786
|
-
});
|
|
1830
|
+
});
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { it } from "node:test";
|
|
2
|
+
import assert from "node:assert/strict";
|
|
3
|
+
import * as fs from "node:fs";
|
|
4
|
+
import * as os from "node:os";
|
|
5
|
+
import * as path from "node:path";
|
|
6
|
+
import { steerWorkflowRun } from "../../src/runs/foreground/workflow-foreground-steering.ts";
|
|
7
|
+
import { closeSteerInbox, steerRequestsDir } from "../../src/runs/background/control-channel.ts";
|
|
8
|
+
import { currentCompletionOwnerId } from "../../src/shared/completion-owner.ts";
|
|
9
|
+
import type { SubagentState } from "../../src/shared/types.ts";
|
|
10
|
+
|
|
11
|
+
it("foreign admission refuses invalid authority, identities, ownership, status and projected targets without writes", async () => {
|
|
12
|
+
const root = fs.mkdtempSync(path.join(os.tmpdir(), "foreign-workflow-"));
|
|
13
|
+
const runId = "workflow-run";
|
|
14
|
+
const asyncDir = path.join(root, runId);
|
|
15
|
+
fs.mkdirSync(asyncDir);
|
|
16
|
+
const baseline = { runId, mode: "workflow", state: "running", sessionId: "parent-file", completionOwnerId: "foreign-owner", steps: [{ status: "running", workflowKey: "A" }] };
|
|
17
|
+
const makeState = (): SubagentState => ({ baseCwd: root, currentSessionId: "parent-file", asyncJobs: new Map(), foregroundControls: new Map(), lastForegroundControlId: null });
|
|
18
|
+
const control = (id: string): any => ({ runId: id, parentWorkflowRunId: runId, sessionId: "parent-file", activeChildren: new Map([[0, { steer: async () => ({ state: "delivered" }) }]]) });
|
|
19
|
+
try {
|
|
20
|
+
const cases: Array<{ name: string; status?: object; state?: (s: SubagentState) => void; index?: number }> = [
|
|
21
|
+
{ name: "missing session", state: s => { s.currentSessionId = null; } },
|
|
22
|
+
{ name: "wrong session", state: s => { s.currentSessionId = "other"; } },
|
|
23
|
+
{ name: "wrong run", status: { runId: "other" } },
|
|
24
|
+
{ name: "non-workflow", status: { mode: "single" } },
|
|
25
|
+
...(["complete", "failed", "partial", "paused", "stopped"] as const).map(state => ({ name: state, status: { state } })),
|
|
26
|
+
{ name: "missing owner", status: { completionOwnerId: undefined } },
|
|
27
|
+
{ name: "invalid owner", status: { completionOwnerId: 123 } },
|
|
28
|
+
{ name: "blank owner", status: { completionOwnerId: " " } },
|
|
29
|
+
{ name: "local orphan", status: { completionOwnerId: currentCompletionOwnerId() } },
|
|
30
|
+
{ name: "configured local orphan", status: { completionOwnerId: "configured" }, state: s => { s.completionOwnerId = "configured"; } },
|
|
31
|
+
{ name: "contradictory control", state: s => { s.foregroundControls.set("A", control("A")); } },
|
|
32
|
+
{ name: "local empty controller", state: s => { s.workflowControllers = new Map([[runId, new AbortController()]]); } },
|
|
33
|
+
{ name: "local ambiguity", state: s => { s.workflowControllers = new Map([[runId, new AbortController()]]); s.foregroundControls.set("A", control("A")); s.foregroundControls.set("B", control("B")); } },
|
|
34
|
+
...[NaN, Infinity, -1, 0.5, 1].map(index => ({ name: `invalid index ${index}`, index })),
|
|
35
|
+
{ name: "terminal child", index: 0, status: { steps: [{ status: "complete", workflowKey: "A" }] } },
|
|
36
|
+
{ name: "missing projected key", index: 0, status: { steps: [{ status: "running" }] } },
|
|
37
|
+
];
|
|
38
|
+
for (const test of cases) {
|
|
39
|
+
const statusText = JSON.stringify({ ...baseline, ...test.status });
|
|
40
|
+
fs.writeFileSync(path.join(asyncDir, "status.json"), statusText);
|
|
41
|
+
const state = makeState(); test.state?.(state);
|
|
42
|
+
const result = await steerWorkflowRun({ state, runId, asyncDir, message: "steer", index: test.index, ackTimeoutMs: 0 });
|
|
43
|
+
assert.equal(result.isError, true, test.name);
|
|
44
|
+
assert.equal(fs.readFileSync(path.join(asyncDir, "status.json"), "utf8"), statusText, test.name);
|
|
45
|
+
assert.equal(fs.existsSync(steerRequestsDir(asyncDir)), false, test.name);
|
|
46
|
+
}
|
|
47
|
+
fs.writeFileSync(path.join(asyncDir, "status.json"), JSON.stringify(baseline));
|
|
48
|
+
const local = makeState(); local.workflowControllers = new Map([[runId, new AbortController()]]); local.foregroundControls.set("A", control("A"));
|
|
49
|
+
const badLocalIndex = await steerWorkflowRun({ state: local, runId, asyncDir, message: "local", index: 1, ackTimeoutMs: 0 });
|
|
50
|
+
assert.equal(badLocalIndex.isError, true);
|
|
51
|
+
assert.equal(fs.existsSync(steerRequestsDir(asyncDir)), false);
|
|
52
|
+
closeSteerInbox(asyncDir, "complete");
|
|
53
|
+
const closed = await steerWorkflowRun({ state: makeState(), runId, asyncDir, message: "closed", ackTimeoutMs: 0 });
|
|
54
|
+
assert.equal(closed.isError, true);
|
|
55
|
+
assert.match((closed.content[0] as any).text, /no longer accepts steering/);
|
|
56
|
+
} finally { fs.rmSync(root, { recursive: true, force: true }); }
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it("explicit projected pending index stays addressed and queued without fabricating delivery or changing the owner ledger", async () => {
|
|
60
|
+
const root = fs.mkdtempSync(path.join(os.tmpdir(), "foreign-pending-"));
|
|
61
|
+
const runId = "workflow-run";
|
|
62
|
+
const asyncDir = path.join(root, runId); fs.mkdirSync(asyncDir);
|
|
63
|
+
try {
|
|
64
|
+
const status = JSON.stringify({ runId, mode: "workflow", state: "queued", sessionId: "parent", completionOwnerId: "foreign", steps: [{ status: "complete", workflowKey: "A" }, { status: "pending", workflowKey: "B" }] });
|
|
65
|
+
fs.writeFileSync(path.join(asyncDir, "status.json"), status);
|
|
66
|
+
const state: SubagentState = { baseCwd: root, currentSessionId: "parent", asyncJobs: new Map(), foregroundControls: new Map(), lastForegroundControlId: null };
|
|
67
|
+
const result = await steerWorkflowRun({ state, runId, asyncDir, message: "next", index: 1, mode: "follow_up", ackTimeoutMs: 0 });
|
|
68
|
+
assert.equal(result.details.steering?.state, "pending");
|
|
69
|
+
assert.deepEqual(result.details.steering?.targets, [{ index: 1, state: "pending" }]);
|
|
70
|
+
const request = JSON.parse(fs.readFileSync(path.join(steerRequestsDir(asyncDir), fs.readdirSync(steerRequestsDir(asyncDir))[0]!), "utf8"));
|
|
71
|
+
assert.equal(request.targetIndex, 1); assert.equal(request.targetIndexes, undefined); assert.equal(request.mode, "follow_up");
|
|
72
|
+
assert.equal(fs.readFileSync(path.join(asyncDir, "status.json"), "utf8"), status);
|
|
73
|
+
} finally { fs.rmSync(root, { recursive: true, force: true }); }
|
|
74
|
+
});
|