@selesai/code 0.13.0 → 0.13.2
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 +22 -0
- package/dist/core/agent-session.d.ts +1 -1
- package/dist/core/agent-session.js +1 -1
- package/dist/core/sdk.d.ts +2 -2
- package/dist/core/sdk.js +1 -1
- package/dist/core/system-prompt.d.ts +1 -1
- package/dist/core/system-prompt.js +1 -1
- package/dist/extensions/package.json +1 -2
- package/dist/extensions/pi-hermes-memory/CHANGELOG.md +371 -0
- package/dist/extensions/pi-hermes-memory/LICENSE +21 -0
- package/dist/extensions/pi-hermes-memory/README.md +643 -0
- package/dist/extensions/pi-hermes-memory/docs/0.1/TASKS.md +197 -0
- package/dist/extensions/pi-hermes-memory/docs/0.2/PLAN.md +290 -0
- package/dist/extensions/pi-hermes-memory/docs/0.2/TASKS.md +134 -0
- package/dist/extensions/pi-hermes-memory/docs/0.2/TEST-PLAN.md +216 -0
- package/dist/extensions/pi-hermes-memory/docs/0.3/PLAN.md +330 -0
- package/dist/extensions/pi-hermes-memory/docs/0.3/TASKS.md +125 -0
- package/dist/extensions/pi-hermes-memory/docs/0.4/PLAN.md +160 -0
- package/dist/extensions/pi-hermes-memory/docs/0.4/TASKS.md +113 -0
- package/dist/extensions/pi-hermes-memory/docs/0.6/CHANGELOG.md +57 -0
- package/dist/extensions/pi-hermes-memory/docs/0.6/PLAN.md +202 -0
- package/dist/extensions/pi-hermes-memory/docs/0.6/TASKS.md +144 -0
- package/dist/extensions/pi-hermes-memory/docs/0.7/PLAN.md +349 -0
- package/dist/extensions/pi-hermes-memory/docs/0.7/TASKS.md +110 -0
- package/dist/extensions/pi-hermes-memory/docs/PUBLISHING.md +149 -0
- package/dist/extensions/pi-hermes-memory/docs/ROADMAP.md +468 -0
- package/dist/extensions/pi-hermes-memory/docs/images/memory-architecture.svg +1 -0
- package/dist/extensions/pi-hermes-memory/docs/images/pi-logo.svg +22 -0
- package/dist/extensions/pi-hermes-memory/docs/images/pi_memory.png +0 -0
- package/dist/extensions/pi-hermes-memory/docs/images/pi_memory.svg +19 -0
- package/dist/extensions/pi-hermes-memory/docs/images/security-flow.svg +1 -0
- package/dist/extensions/pi-hermes-memory/docs/images/session-lifecycle.svg +1 -0
- package/dist/extensions/pi-hermes-memory/docs/images/source-architecture.svg +1 -0
- package/dist/extensions/pi-hermes-memory/docs/mermaid/memory-architecture.mmd +49 -0
- package/dist/extensions/pi-hermes-memory/docs/mermaid/security-flow.mmd +40 -0
- package/dist/extensions/pi-hermes-memory/docs/mermaid/session-lifecycle.mmd +56 -0
- package/dist/extensions/pi-hermes-memory/docs/mermaid/source-architecture.mmd +54 -0
- package/dist/extensions/pi-hermes-memory/package-lock.json +3799 -0
- package/dist/extensions/pi-hermes-memory/package.json +66 -0
- package/dist/extensions/pi-hermes-memory/scripts/check-min-sdk.mjs +99 -0
- package/dist/extensions/pi-hermes-memory/scripts/ensure-dev.mjs +57 -0
- package/dist/extensions/pi-hermes-memory/src/auto-consolidation-warning.ts +6 -0
- package/dist/extensions/pi-hermes-memory/src/config.ts +178 -0
- package/dist/extensions/pi-hermes-memory/src/constants.ts +424 -0
- package/dist/extensions/pi-hermes-memory/src/extension-root-migration.ts +639 -0
- package/dist/extensions/pi-hermes-memory/src/handlers/auto-consolidate.ts +401 -0
- package/dist/extensions/pi-hermes-memory/src/handlers/background-review.ts +297 -0
- package/dist/extensions/pi-hermes-memory/src/handlers/child-process-watchdog.mjs +90 -0
- package/dist/extensions/pi-hermes-memory/src/handlers/correction-detector.ts +300 -0
- package/dist/extensions/pi-hermes-memory/src/handlers/index-sessions.ts +86 -0
- package/dist/extensions/pi-hermes-memory/src/handlers/insights.ts +78 -0
- package/dist/extensions/pi-hermes-memory/src/handlers/interview.ts +37 -0
- package/dist/extensions/pi-hermes-memory/src/handlers/learn-memory.ts +186 -0
- package/dist/extensions/pi-hermes-memory/src/handlers/message-parts.ts +27 -0
- package/dist/extensions/pi-hermes-memory/src/handlers/pi-child-process.ts +485 -0
- package/dist/extensions/pi-hermes-memory/src/handlers/preview-context.ts +105 -0
- package/dist/extensions/pi-hermes-memory/src/handlers/review-memory-ops.ts +506 -0
- package/dist/extensions/pi-hermes-memory/src/handlers/session-backfill.ts +145 -0
- package/dist/extensions/pi-hermes-memory/src/handlers/session-flush.ts +151 -0
- package/dist/extensions/pi-hermes-memory/src/handlers/session-live-index.ts +94 -0
- package/dist/extensions/pi-hermes-memory/src/handlers/skills-command.ts +1334 -0
- package/dist/extensions/pi-hermes-memory/src/handlers/standing-pin.ts +111 -0
- package/dist/extensions/pi-hermes-memory/src/handlers/switch-project.ts +75 -0
- package/dist/extensions/pi-hermes-memory/src/handlers/sync-markdown-memories.ts +266 -0
- package/dist/extensions/pi-hermes-memory/src/index.ts +378 -0
- package/dist/extensions/pi-hermes-memory/src/lifecycle-timing.ts +54 -0
- package/dist/extensions/pi-hermes-memory/src/paths.ts +61 -0
- package/dist/extensions/pi-hermes-memory/src/project-context.ts +13 -0
- package/dist/extensions/pi-hermes-memory/src/project-memory-migration.ts +93 -0
- package/dist/extensions/pi-hermes-memory/src/project.ts +157 -0
- package/dist/extensions/pi-hermes-memory/src/prompt-context.ts +55 -0
- package/dist/extensions/pi-hermes-memory/src/store/atomic-lock-coordinator.ts +375 -0
- package/dist/extensions/pi-hermes-memory/src/store/canonical-storage-path.ts +54 -0
- package/dist/extensions/pi-hermes-memory/src/store/content-scanner.ts +101 -0
- package/dist/extensions/pi-hermes-memory/src/store/db.ts +1180 -0
- package/dist/extensions/pi-hermes-memory/src/store/fts-query.ts +101 -0
- package/dist/extensions/pi-hermes-memory/src/store/markdown-mutation-lock.ts +38 -0
- package/dist/extensions/pi-hermes-memory/src/store/memory-lookup.ts +24 -0
- package/dist/extensions/pi-hermes-memory/src/store/memory-store.ts +1191 -0
- package/dist/extensions/pi-hermes-memory/src/store/recovery-maintenance.ts +66 -0
- package/dist/extensions/pi-hermes-memory/src/store/schema.ts +118 -0
- package/dist/extensions/pi-hermes-memory/src/store/session-anchor-search.ts +472 -0
- package/dist/extensions/pi-hermes-memory/src/store/session-indexer.ts +511 -0
- package/dist/extensions/pi-hermes-memory/src/store/session-parser.ts +213 -0
- package/dist/extensions/pi-hermes-memory/src/store/session-search.ts +234 -0
- package/dist/extensions/pi-hermes-memory/src/store/skill-store.ts +950 -0
- package/dist/extensions/pi-hermes-memory/src/store/skill-utils.ts +133 -0
- package/dist/extensions/pi-hermes-memory/src/store/sqlite-memory-store.ts +1002 -0
- package/dist/extensions/pi-hermes-memory/src/store/sqlite-native.ts +241 -0
- package/dist/extensions/pi-hermes-memory/src/store/standing-instructions.ts +247 -0
- package/dist/extensions/pi-hermes-memory/src/tools/memory-search-tool.ts +95 -0
- package/dist/extensions/pi-hermes-memory/src/tools/memory-tool.ts +469 -0
- package/dist/extensions/pi-hermes-memory/src/tools/session-search-tool.ts +246 -0
- package/dist/extensions/pi-hermes-memory/src/tools/shared-output-view.ts +170 -0
- package/dist/extensions/pi-hermes-memory/src/tools/skill-tool.ts +333 -0
- package/dist/extensions/pi-hermes-memory/src/tools/tool-result-views.ts +105 -0
- package/dist/extensions/pi-hermes-memory/src/types.ts +214 -0
- package/dist/extensions/pi-hermes-memory/tests/config.test.ts +434 -0
- package/dist/extensions/pi-hermes-memory/tests/extension-root-migration.test.ts +368 -0
- package/dist/extensions/pi-hermes-memory/tests/handlers/auto-consolidate.test.ts +984 -0
- package/dist/extensions/pi-hermes-memory/tests/handlers/background-review.test.ts +950 -0
- package/dist/extensions/pi-hermes-memory/tests/handlers/correction-detector.test.ts +671 -0
- package/dist/extensions/pi-hermes-memory/tests/handlers/insights.test.ts +157 -0
- package/dist/extensions/pi-hermes-memory/tests/handlers/interview.test.ts +127 -0
- package/dist/extensions/pi-hermes-memory/tests/handlers/pi-child-process.test.ts +905 -0
- package/dist/extensions/pi-hermes-memory/tests/handlers/preview-context.test.ts +152 -0
- package/dist/extensions/pi-hermes-memory/tests/handlers/prompt-context.test.ts +166 -0
- package/dist/extensions/pi-hermes-memory/tests/handlers/resources-discover.test.ts +71 -0
- package/dist/extensions/pi-hermes-memory/tests/handlers/review-memory-ops.test.ts +614 -0
- package/dist/extensions/pi-hermes-memory/tests/handlers/session-backfill.test.ts +192 -0
- package/dist/extensions/pi-hermes-memory/tests/handlers/session-flush.test.ts +677 -0
- package/dist/extensions/pi-hermes-memory/tests/handlers/session-live-index.test.ts +225 -0
- package/dist/extensions/pi-hermes-memory/tests/handlers/skills-command.test.ts +827 -0
- package/dist/extensions/pi-hermes-memory/tests/handlers/standing-pin.test.ts +134 -0
- package/dist/extensions/pi-hermes-memory/tests/handlers/sync-markdown-memories.test.ts +491 -0
- package/dist/extensions/pi-hermes-memory/tests/handlers/system-prompt.test.ts +199 -0
- package/dist/extensions/pi-hermes-memory/tests/handlers/thinking-max.test.ts +64 -0
- package/dist/extensions/pi-hermes-memory/tests/index.test.ts +30 -0
- package/dist/extensions/pi-hermes-memory/tests/integration/flow.test.ts +126 -0
- package/dist/extensions/pi-hermes-memory/tests/lifecycle-timing.test.ts +76 -0
- package/dist/extensions/pi-hermes-memory/tests/paths.test.ts +23 -0
- package/dist/extensions/pi-hermes-memory/tests/project-memory-migration.test.ts +80 -0
- package/dist/extensions/pi-hermes-memory/tests/project-rebinding.test.ts +115 -0
- package/dist/extensions/pi-hermes-memory/tests/project.test.ts +120 -0
- package/dist/extensions/pi-hermes-memory/tests/run-all-timeout.test.ts +107 -0
- package/dist/extensions/pi-hermes-memory/tests/run-all.sh +45 -0
- package/dist/extensions/pi-hermes-memory/tests/store/atomic-lock-coordinator.test.ts +381 -0
- package/dist/extensions/pi-hermes-memory/tests/store/content-scanner.test.ts +388 -0
- package/dist/extensions/pi-hermes-memory/tests/store/db.test.ts +1046 -0
- package/dist/extensions/pi-hermes-memory/tests/store/markdown-mutation-lock.test.ts +34 -0
- package/dist/extensions/pi-hermes-memory/tests/store/memory-store.test.ts +2150 -0
- package/dist/extensions/pi-hermes-memory/tests/store/recovery-maintenance.test.ts +170 -0
- package/dist/extensions/pi-hermes-memory/tests/store/session-anchor-search.test.ts +210 -0
- package/dist/extensions/pi-hermes-memory/tests/store/session-indexer.test.ts +643 -0
- package/dist/extensions/pi-hermes-memory/tests/store/session-parser.test.ts +282 -0
- package/dist/extensions/pi-hermes-memory/tests/store/session-search.test.ts +287 -0
- package/dist/extensions/pi-hermes-memory/tests/store/skill-store.test.ts +678 -0
- package/dist/extensions/pi-hermes-memory/tests/store/skill-utils.test.ts +21 -0
- package/dist/extensions/pi-hermes-memory/tests/store/sqlite-lazy-load.test.ts +78 -0
- package/dist/extensions/pi-hermes-memory/tests/store/sqlite-memory-store.test.ts +543 -0
- package/dist/extensions/pi-hermes-memory/tests/store/sqlite-native.test.ts +164 -0
- package/dist/extensions/pi-hermes-memory/tests/store/standing-instructions.test.ts +171 -0
- package/dist/extensions/pi-hermes-memory/tests/tools/memory-search-tool.test.ts +84 -0
- package/dist/extensions/pi-hermes-memory/tests/tools/memory-tool.test.ts +709 -0
- package/dist/extensions/pi-hermes-memory/tests/tools/session-search-tool.test.ts +345 -0
- package/dist/extensions/pi-hermes-memory/tests/tools/shared-output-view.test.ts +362 -0
- package/dist/extensions/pi-hermes-memory/tests/tools/skill-tool.test.ts +478 -0
- package/dist/extensions/pi-hermes-memory/tests/tools/tool-result-renderer-wiring.test.ts +40 -0
- package/dist/extensions/pi-hermes-memory/tsconfig.json +19 -0
- package/dist/extensions/pi-rewind-hook/README.md +4 -1
- package/dist/extensions/pi-rewind-hook/index.ts +151 -21
- package/dist/extensions/pi-rewind-hook/package.json +5 -3
- package/dist/extensions/pi-subagents/.oxlintrc.json +43 -0
- package/dist/extensions/pi-subagents/AGENTS.md +5 -0
- package/dist/extensions/pi-subagents/CHANGELOG.md +157 -0
- package/dist/extensions/pi-subagents/README.md +12 -6
- package/dist/extensions/pi-subagents/VISION.md +81 -0
- package/dist/extensions/pi-subagents/agents/claude-code-writer.md +15 -0
- package/dist/extensions/pi-subagents/agents/claude-code.md +15 -0
- package/dist/extensions/pi-subagents/agents/codex-exec-writer.md +15 -0
- package/dist/extensions/pi-subagents/agents/codex-exec.md +15 -0
- package/dist/extensions/pi-subagents/agents/cursor-agent-writer.md +14 -0
- package/dist/extensions/pi-subagents/agents/cursor-agent.md +14 -0
- package/dist/extensions/pi-subagents/agents/reviewer.md +1 -3
- package/dist/extensions/pi-subagents/docs/agents.md +488 -0
- package/dist/extensions/pi-subagents/docs/configuration.md +46 -9
- package/dist/extensions/pi-subagents/docs/extension-api.md +42 -3
- package/dist/extensions/pi-subagents/docs/models.md +27 -4
- package/dist/extensions/pi-subagents/docs/observability.md +10 -9
- package/dist/extensions/pi-subagents/docs/tool-reference.md +102 -6
- package/dist/extensions/pi-subagents/docs/workflows.md +135 -0
- package/dist/extensions/pi-subagents/package-lock.json +389 -2
- package/dist/extensions/pi-subagents/package.json +3 -1
- package/dist/extensions/pi-subagents/prompts/review-loop.md +2 -2
- package/dist/extensions/pi-subagents/skills/council-mode/SKILL.md +1 -1
- package/dist/extensions/pi-subagents/skills/pi-subagents/SKILL.md +3 -1
- package/dist/extensions/pi-subagents/skills/pi-subagents/references/execution-controls.md +7 -3
- package/dist/extensions/pi-subagents/skills/pi-subagents/references/management-authoring-rpc.md +2 -2
- package/dist/extensions/pi-subagents/skills/pi-subagents/references/prompting-and-roles.md +26 -5
- package/dist/extensions/pi-subagents/src/agents/agent-management.ts +41 -22
- package/dist/extensions/pi-subagents/src/agents/agent-refinements.ts +4 -4
- package/dist/extensions/pi-subagents/src/agents/agent-serializer.ts +9 -2
- package/dist/extensions/pi-subagents/src/agents/agents.ts +322 -75
- package/dist/extensions/pi-subagents/src/agents/builtin-names.ts +6 -0
- package/dist/extensions/pi-subagents/src/agents/runtime-agent-events.ts +70 -0
- package/dist/extensions/pi-subagents/src/agents/runtime-agent-registry.ts +27 -20
- package/dist/extensions/pi-subagents/src/api/agents.ts +10 -5
- package/dist/extensions/pi-subagents/src/api/background-work.ts +5 -1
- package/dist/extensions/pi-subagents/src/api/delegation.ts +0 -7
- package/dist/extensions/pi-subagents/src/api/preflight.ts +34 -12
- package/dist/extensions/pi-subagents/src/extension/config.ts +70 -0
- package/dist/extensions/pi-subagents/src/extension/doctor.ts +3 -3
- package/dist/extensions/pi-subagents/src/extension/fanout-child.ts +5 -3
- package/dist/extensions/pi-subagents/src/extension/index.ts +83 -30
- package/dist/extensions/pi-subagents/src/extension/public-execution.ts +44 -15
- package/dist/extensions/pi-subagents/src/extension/rpc.ts +55 -19
- package/dist/extensions/pi-subagents/src/extension/schemas.ts +41 -15
- package/dist/extensions/pi-subagents/src/extension/tool-description.ts +28 -31
- package/dist/extensions/pi-subagents/src/inspectors/herdr/actions.ts +2 -1
- package/dist/extensions/pi-subagents/src/inspectors/herdr/inspector-runner.ts +2 -10
- package/dist/extensions/pi-subagents/src/inspectors/herdr/session-roots-codec.ts +42 -0
- package/dist/extensions/pi-subagents/src/integrations/herdr-status.ts +51 -7
- package/dist/extensions/pi-subagents/src/intercom/result-intercom.ts +2 -0
- package/dist/extensions/pi-subagents/src/profiles/profiles.ts +5 -6
- package/dist/extensions/pi-subagents/src/runs/background/active-async-capacity.ts +77 -10
- package/dist/extensions/pi-subagents/src/runs/background/async-execution.ts +176 -53
- package/dist/extensions/pi-subagents/src/runs/background/async-job-tracker.ts +19 -12
- package/dist/extensions/pi-subagents/src/runs/background/async-resume.ts +29 -27
- package/dist/extensions/pi-subagents/src/runs/background/async-retention.ts +20 -3
- package/dist/extensions/pi-subagents/src/runs/background/async-status-snapshot.ts +23 -261
- package/dist/extensions/pi-subagents/src/runs/background/async-status.ts +73 -7
- package/dist/extensions/pi-subagents/src/runs/background/chain-append.ts +8 -3
- package/dist/extensions/pi-subagents/src/runs/background/chain-root-attachment.ts +74 -8
- package/dist/extensions/pi-subagents/src/runs/background/fleet-view.ts +37 -21
- package/dist/extensions/pi-subagents/src/runs/background/inspect-rpc.ts +8 -8
- package/dist/extensions/pi-subagents/src/runs/background/notify.ts +184 -9
- package/dist/extensions/pi-subagents/src/runs/background/result-delivery-ownership.ts +45 -0
- package/dist/extensions/pi-subagents/src/runs/background/result-files.ts +28 -14
- package/dist/extensions/pi-subagents/src/runs/background/result-watcher.ts +38 -15
- package/dist/extensions/pi-subagents/src/runs/background/resume-guidance.ts +1 -1
- package/dist/extensions/pi-subagents/src/runs/background/retained-children.ts +1 -1
- package/dist/extensions/pi-subagents/src/runs/background/run-status.ts +50 -13
- package/dist/extensions/pi-subagents/src/runs/background/scheduled-runs.ts +93 -8
- package/dist/extensions/pi-subagents/src/runs/background/stale-run-reconciler.ts +10 -4
- package/dist/extensions/pi-subagents/src/runs/background/steering.ts +4 -14
- package/dist/extensions/pi-subagents/src/runs/background/subagent-runner.ts +549 -377
- package/dist/extensions/pi-subagents/src/runs/background/subagent-wait.ts +58 -10
- package/dist/extensions/pi-subagents/src/runs/background/terminal-run-index.ts +1 -1
- package/dist/extensions/pi-subagents/src/runs/background/wait-completions.ts +26 -1
- package/dist/extensions/pi-subagents/src/runs/background/wait-config.ts +23 -9
- package/dist/extensions/pi-subagents/src/runs/background/wait-tool.ts +9 -2
- package/dist/extensions/pi-subagents/src/runs/foreground/async-steering-action.ts +2 -2
- package/dist/extensions/pi-subagents/src/runs/foreground/execution.ts +204 -129
- package/dist/extensions/pi-subagents/src/runs/foreground/foreground-control.ts +9 -0
- package/dist/extensions/pi-subagents/src/runs/foreground/foreground-history.ts +23 -1
- package/dist/extensions/pi-subagents/src/runs/foreground/subagent-executor.ts +773 -311
- package/dist/extensions/pi-subagents/src/runs/foreground/workflow-detach-reconcile.ts +140 -115
- package/dist/extensions/pi-subagents/src/runs/shared/abort-recovery.ts +119 -0
- package/dist/extensions/pi-subagents/src/runs/shared/async-status-projection.ts +463 -0
- package/dist/extensions/pi-subagents/src/runs/shared/child-identity.ts +19 -4
- package/dist/extensions/pi-subagents/src/runs/shared/child-launch-plan.ts +151 -0
- package/dist/extensions/pi-subagents/src/runs/shared/child-protocol.ts +21 -7
- package/dist/extensions/pi-subagents/src/runs/shared/claude-code-adapter.ts +129 -0
- package/dist/extensions/pi-subagents/src/runs/shared/codex-exec-adapter.ts +129 -0
- package/dist/extensions/pi-subagents/src/runs/shared/completion-evidence.ts +89 -0
- package/dist/extensions/pi-subagents/src/runs/shared/completion-guard.ts +5 -4
- package/dist/extensions/pi-subagents/src/runs/shared/cursor-agent-adapter.ts +114 -0
- package/dist/extensions/pi-subagents/src/runs/shared/dynamic-fanout.ts +3 -3
- package/dist/extensions/pi-subagents/src/runs/shared/external-cli-contract.ts +167 -0
- package/dist/extensions/pi-subagents/src/runs/shared/external-cli-preflight.ts +122 -0
- package/dist/extensions/pi-subagents/src/runs/shared/external-cli-runner.ts +348 -55
- package/dist/extensions/pi-subagents/src/runs/shared/fast-mode-extension.ts +5 -5
- package/dist/extensions/pi-subagents/src/runs/shared/host-step-status.ts +230 -0
- package/dist/extensions/pi-subagents/src/runs/shared/lane-metadata.ts +105 -0
- package/dist/extensions/pi-subagents/src/runs/shared/launch-cwd.ts +16 -0
- package/dist/extensions/pi-subagents/src/runs/shared/long-running-guard.ts +2 -1
- package/dist/extensions/pi-subagents/src/runs/shared/mcp-config-sources.ts +422 -0
- package/dist/extensions/pi-subagents/src/runs/shared/mcp-direct-tool-allowlist.ts +221 -158
- package/dist/extensions/pi-subagents/src/runs/shared/mcp-direct-tool-grant.ts +197 -0
- package/dist/extensions/pi-subagents/src/runs/shared/model-exclusions.ts +69 -7
- package/dist/extensions/pi-subagents/src/runs/shared/model-fallback.ts +47 -6
- package/dist/extensions/pi-subagents/src/runs/shared/mutation-evidence.ts +7 -2
- package/dist/extensions/pi-subagents/src/runs/shared/nested-events.ts +9 -3
- package/dist/extensions/pi-subagents/src/runs/shared/nested-render.ts +9 -5
- package/dist/extensions/pi-subagents/src/runs/shared/parallel-handoff.ts +419 -7
- package/dist/extensions/pi-subagents/src/runs/shared/parallel-utils.ts +15 -1
- package/dist/extensions/pi-subagents/src/runs/shared/pi-args.ts +81 -8
- package/dist/extensions/pi-subagents/src/runs/shared/process-signal.ts +13 -0
- package/dist/extensions/pi-subagents/src/runs/shared/run-history.ts +21 -1
- package/dist/extensions/pi-subagents/src/runs/shared/single-output.ts +44 -4
- package/dist/extensions/pi-subagents/src/runs/shared/subagent-prompt-runtime.ts +98 -13
- package/dist/extensions/pi-subagents/src/runs/shared/subagent-startup-retry.ts +1 -1
- package/dist/extensions/pi-subagents/src/runs/shared/worktree-cleanup-plan.ts +847 -0
- package/dist/extensions/pi-subagents/src/runs/shared/worktree.ts +18 -0
- package/dist/extensions/pi-subagents/src/shared/child-session-name.ts +46 -0
- package/dist/extensions/pi-subagents/src/shared/extension-context.ts +24 -0
- package/dist/extensions/pi-subagents/src/shared/fork-context.ts +21 -0
- package/dist/extensions/pi-subagents/src/shared/formatters.ts +18 -3
- package/dist/extensions/pi-subagents/src/shared/launch-contract.ts +5 -1
- package/dist/extensions/pi-subagents/src/shared/pruned-fork.ts +450 -0
- package/dist/extensions/pi-subagents/src/shared/session-file-trust.ts +19 -0
- package/dist/extensions/pi-subagents/src/shared/session-tokens.ts +14 -3
- package/dist/extensions/pi-subagents/src/shared/settings.ts +19 -105
- package/dist/extensions/pi-subagents/src/shared/shortcuts.ts +17 -0
- package/dist/extensions/pi-subagents/src/shared/types.ts +359 -40
- package/dist/extensions/pi-subagents/src/shared/utils.ts +41 -84
- package/dist/extensions/pi-subagents/src/shared/workflow-child-permit.ts +116 -0
- package/dist/extensions/pi-subagents/src/slash/delegation-adapters.ts +1 -9
- package/dist/extensions/pi-subagents/src/slash/delegation-request.ts +0 -4
- package/dist/extensions/pi-subagents/src/slash/slash-bridge.ts +1 -2
- package/dist/extensions/pi-subagents/src/slash/slash-commands.ts +378 -88
- package/dist/extensions/pi-subagents/src/slash/slash-live-state.ts +22 -11
- package/dist/extensions/pi-subagents/src/slash/subagents-admin.ts +3 -0
- package/dist/extensions/pi-subagents/src/tui/fleet-status.ts +147 -79
- package/dist/extensions/pi-subagents/src/tui/fleet-transcript.ts +11 -5
- package/dist/extensions/pi-subagents/src/tui/fleet.ts +39 -18
- package/dist/extensions/pi-subagents/src/tui/render.ts +369 -46
- package/dist/extensions/pi-subagents/src/watchdog/turn-delta.ts +1 -1
- package/dist/extensions/pi-subagents/src/workflows/chat-progress.ts +6 -3
- package/dist/extensions/pi-subagents/src/workflows/host-command.ts +230 -0
- package/dist/extensions/pi-subagents/src/workflows/scripted-workflow.ts +740 -58
- package/dist/extensions/pi-subagents/src/workflows/workflow-child-summary.ts +121 -0
- package/dist/extensions/pi-subagents/src/workflows/workflow-preflight.ts +270 -0
- package/dist/extensions/pi-subagents/src/workflows/workflow-receipt.ts +195 -6
- package/dist/extensions/pi-subagents/src/workflows/workflow-settlement.ts +246 -0
- package/dist/extensions/pi-subagents/test/e2e/real-session-subagent.test.ts +2 -2
- package/dist/extensions/pi-subagents/test/integration/async-execution.test.ts +1114 -260
- package/dist/extensions/pi-subagents/test/integration/async-job-tracker.test.ts +34 -0
- package/dist/extensions/pi-subagents/test/integration/async-status.test.ts +150 -3
- package/dist/extensions/pi-subagents/test/integration/claude-code-smoke.test.ts +52 -0
- package/dist/extensions/pi-subagents/test/integration/claude-code-writer-smoke.test.ts +55 -0
- package/dist/extensions/pi-subagents/test/integration/codex-exec-smoke.test.ts +53 -0
- package/dist/extensions/pi-subagents/test/integration/codex-exec-writer-smoke.test.ts +57 -0
- package/dist/extensions/pi-subagents/test/integration/cursor-agent-smoke.test.ts +59 -0
- package/dist/extensions/pi-subagents/test/integration/cursor-agent-writer-smoke.test.ts +62 -0
- package/dist/extensions/pi-subagents/test/integration/error-handling.test.ts +57 -1
- package/dist/extensions/pi-subagents/test/integration/external-cli-runner.test.ts +1 -0
- package/dist/extensions/pi-subagents/test/integration/fork-context-execution.test.ts +20 -0
- package/dist/extensions/pi-subagents/test/integration/intercom-result-delivery.test.ts +4 -3
- package/dist/extensions/pi-subagents/test/integration/orca-progress-tabs.test.ts +2 -2
- package/dist/extensions/pi-subagents/test/integration/render-fork-badge.test.ts +54 -4
- package/dist/extensions/pi-subagents/test/integration/render-widget.test.ts +482 -4
- package/dist/extensions/pi-subagents/test/integration/result-watcher.test.ts +157 -9
- package/dist/extensions/pi-subagents/test/integration/session-tokens.test.ts +5 -5
- package/dist/extensions/pi-subagents/test/integration/single-execution.test.ts +1508 -291
- package/dist/extensions/pi-subagents/test/integration/slash-commands.test.ts +423 -1
- package/dist/extensions/pi-subagents/test/integration/template-resolution.test.ts +8 -0
- package/dist/extensions/pi-subagents/test/support/cursor-smoke-inputs.ts +51 -0
- package/dist/extensions/pi-subagents/test/support/helpers.ts +2 -0
- package/dist/extensions/pi-subagents/test/support/mock-pi.ts +5 -5
- package/dist/extensions/pi-subagents/test/support/real-session-runner.ts +6 -6
- package/dist/extensions/pi-subagents/test/unit/abort-recovery.test.ts +152 -0
- package/dist/extensions/pi-subagents/test/unit/active-async-capacity.test.ts +48 -0
- package/dist/extensions/pi-subagents/test/unit/agent-frontmatter.test.ts +184 -6
- package/dist/extensions/pi-subagents/test/unit/agent-management.test.ts +66 -6
- package/dist/extensions/pi-subagents/test/unit/agent-overrides.test.ts +77 -0
- package/dist/extensions/pi-subagents/test/unit/agent-refinements.test.ts +18 -0
- package/dist/extensions/pi-subagents/test/unit/anti-slop-oxlint.test.ts +86 -0
- package/dist/extensions/pi-subagents/test/unit/artifacts.test.ts +1 -1
- package/dist/extensions/pi-subagents/test/unit/async-execution.test.ts +101 -1
- package/dist/extensions/pi-subagents/test/unit/async-interrupt-action.test.ts +121 -0
- package/dist/extensions/pi-subagents/test/unit/async-recovery-descriptor.test.ts +28 -0
- package/dist/extensions/pi-subagents/test/unit/async-resume.test.ts +14 -7
- package/dist/extensions/pi-subagents/test/unit/async-retention.test.ts +53 -0
- package/dist/extensions/pi-subagents/test/unit/async-status-projection.test.ts +190 -0
- package/dist/extensions/pi-subagents/test/unit/async-status-snapshot.test.ts +42 -0
- package/dist/extensions/pi-subagents/test/unit/auto-drain.test.ts +8 -4
- package/dist/extensions/pi-subagents/test/unit/background-work.test.ts +23 -0
- package/dist/extensions/pi-subagents/test/unit/chain-root-attachment.test.ts +78 -1
- package/dist/extensions/pi-subagents/test/unit/child-launch-plan.test.ts +94 -0
- package/dist/extensions/pi-subagents/test/unit/child-protocol.test.ts +21 -0
- package/dist/extensions/pi-subagents/test/unit/child-session-name.test.ts +50 -0
- package/dist/extensions/pi-subagents/test/unit/claude-code-adapter.test.ts +245 -0
- package/dist/extensions/pi-subagents/test/unit/codex-exec-adapter.test.ts +192 -0
- package/dist/extensions/pi-subagents/test/unit/compaction-resume.test.ts +27 -0
- package/dist/extensions/pi-subagents/test/unit/completion-evidence.test.ts +150 -0
- package/dist/extensions/pi-subagents/test/unit/completion-guard.test.ts +21 -0
- package/dist/extensions/pi-subagents/test/unit/cursor-agent-adapter.test.ts +259 -0
- package/dist/extensions/pi-subagents/test/unit/cursor-smoke-inputs.test.ts +77 -0
- package/dist/extensions/pi-subagents/test/unit/delegation-api.test.ts +1 -4
- package/dist/extensions/pi-subagents/test/unit/doctor.test.ts +1 -1
- package/dist/extensions/pi-subagents/test/unit/extension-context.test.ts +27 -0
- package/dist/extensions/pi-subagents/test/unit/external-cli-runner.test.ts +223 -0
- package/dist/extensions/pi-subagents/test/unit/fast-mode-extension.test.ts +27 -0
- package/dist/extensions/pi-subagents/test/unit/fleet-status.test.ts +208 -2
- package/dist/extensions/pi-subagents/test/unit/fleet-transcript.test.ts +29 -1
- package/dist/extensions/pi-subagents/test/unit/fleet.test.ts +110 -1
- package/dist/extensions/pi-subagents/test/unit/foreground-control.test.ts +10 -0
- package/dist/extensions/pi-subagents/test/unit/formatters.test.ts +14 -0
- package/dist/extensions/pi-subagents/test/unit/herdr-inspector.test.ts +18 -9
- package/dist/extensions/pi-subagents/test/unit/herdr-session-roots-codec.test.ts +63 -0
- package/dist/extensions/pi-subagents/test/unit/herdr-shell-command.test.ts +2 -2
- package/dist/extensions/pi-subagents/test/unit/herdr-status-bridge.test.ts +136 -6
- package/dist/extensions/pi-subagents/test/unit/host-command.test.ts +156 -0
- package/dist/extensions/pi-subagents/test/unit/host-step-status.test.ts +98 -0
- package/dist/extensions/pi-subagents/test/unit/index-child-registration.test.ts +178 -26
- package/dist/extensions/pi-subagents/test/unit/index-segment.test.ts +2 -1
- package/dist/extensions/pi-subagents/test/unit/inspect-rpc.test.ts +21 -0
- package/dist/extensions/pi-subagents/test/unit/mcp-direct-tool-grant.test.ts +138 -0
- package/dist/extensions/pi-subagents/test/unit/mission-lifecycle.test.ts +1 -1
- package/dist/extensions/pi-subagents/test/unit/model-exclusions.test.ts +91 -0
- package/dist/extensions/pi-subagents/test/unit/model-fallback.test.ts +72 -7
- package/dist/extensions/pi-subagents/test/unit/mutation-evidence.test.ts +21 -0
- package/dist/extensions/pi-subagents/test/unit/nested-control.test.ts +1 -0
- package/dist/extensions/pi-subagents/test/unit/nested-events.test.ts +20 -2
- package/dist/extensions/pi-subagents/test/unit/notify.test.ts +129 -1
- package/dist/extensions/pi-subagents/test/unit/orca-progress-tabs.test.ts +2 -2
- package/dist/extensions/pi-subagents/test/unit/package-manifest.test.ts +4 -0
- package/dist/extensions/pi-subagents/test/unit/parallel-handoff.test.ts +358 -0
- package/dist/extensions/pi-subagents/test/unit/pi-args.test.ts +574 -21
- package/dist/extensions/pi-subagents/test/unit/pi-coding-agent-dir.test.ts +109 -1
- package/dist/extensions/pi-subagents/test/unit/preflight.test.ts +71 -1
- package/dist/extensions/pi-subagents/test/unit/profiles.test.ts +7 -7
- package/dist/extensions/pi-subagents/test/unit/pruned-fork.test.ts +214 -0
- package/dist/extensions/pi-subagents/test/unit/public-execution.test.ts +29 -8
- package/dist/extensions/pi-subagents/test/unit/render-helpers.test.ts +53 -0
- package/dist/extensions/pi-subagents/test/unit/result-delivery-ownership.test.ts +34 -0
- package/dist/extensions/pi-subagents/test/unit/result-files.test.ts +101 -3
- package/dist/extensions/pi-subagents/test/unit/retained-children.test.ts +1 -0
- package/dist/extensions/pi-subagents/test/unit/rpc.test.ts +10 -8
- package/dist/extensions/pi-subagents/test/unit/run-fanout-budget.test.ts +71 -1
- package/dist/extensions/pi-subagents/test/unit/run-status.test.ts +41 -7
- package/dist/extensions/pi-subagents/test/unit/runtime-agent-registration.test.ts +136 -2
- package/dist/extensions/pi-subagents/test/unit/scheduled-runs.test.ts +137 -0
- package/dist/extensions/pi-subagents/test/unit/schemas.test.ts +33 -12
- package/dist/extensions/pi-subagents/test/unit/scripted-workflow.test.ts +504 -1
- package/dist/extensions/pi-subagents/test/unit/single-output.test.ts +8 -0
- package/dist/extensions/pi-subagents/test/unit/skills-fallback.test.ts +1 -1
- package/dist/extensions/pi-subagents/test/unit/stale-run-reconciler.test.ts +12 -1
- package/dist/extensions/pi-subagents/test/unit/steering-action.test.ts +3 -5
- package/dist/extensions/pi-subagents/test/unit/steering.test.ts +5 -6
- package/dist/extensions/pi-subagents/test/unit/subagent-action-recovery.test.ts +0 -8
- package/dist/extensions/pi-subagents/test/unit/subagent-guide.test.ts +5 -0
- package/dist/extensions/pi-subagents/test/unit/subagent-prompt-runtime.test.ts +157 -2
- package/dist/extensions/pi-subagents/test/unit/subagent-startup-retry.test.ts +1 -1
- package/dist/extensions/pi-subagents/test/unit/subagent-wait.test.ts +63 -4
- package/dist/extensions/pi-subagents/test/unit/tool-description.test.ts +27 -23
- package/dist/extensions/pi-subagents/test/unit/wait-completions.test.ts +44 -0
- package/dist/extensions/pi-subagents/test/unit/wait-subscriptions.test.ts +1 -0
- package/dist/extensions/pi-subagents/test/unit/widget-nested-render.test.ts +7 -5
- package/dist/extensions/pi-subagents/test/unit/workflow-chat-progress.test.ts +106 -0
- package/dist/extensions/pi-subagents/test/unit/workflow-detach-reconcile.test.ts +484 -9
- package/dist/extensions/pi-subagents/test/unit/workflow-launch-params.test.ts +38 -4
- package/dist/extensions/pi-subagents/test/unit/workflow-preflight.test.ts +155 -0
- package/dist/extensions/pi-subagents/test/unit/workflow-receipt.test.ts +318 -0
- package/dist/extensions/pi-subagents/test/unit/workflow-resume-hint.test.ts +365 -0
- package/dist/extensions/pi-subagents/test/unit/worktree-cleanup-plan.test.ts +349 -0
- package/dist/extensions/pi-subagents/test/unit/worktree.test.ts +21 -0
- package/dist/extensions/pi-subagents/test/unit/writer-budget-guidance.test.ts +2 -7
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/effect/index.ts +13 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/effect/rules/no-service-constructor-imports.ts +52 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/index.ts +41 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/rules/no-chained-type-assertions.ts +77 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/rules/no-conditional-empty-object-spread.ts +49 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/rules/no-known-value-widening.ts +247 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/rules/no-module-mocking.ts +91 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/rules/no-object-parameters.ts +126 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/rules/no-reflect-apply.ts +28 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/rules/no-reflect-get.ts +28 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/rules/no-runtime-typeof.ts +67 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/rules/no-shape-in-symbol-names.ts +39 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/rules/no-unknown-parameters.ts +83 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/rules/no-unknown-returns.ts +115 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/rules/no-unknown-type-aliases.ts +72 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/rules/no-unsafe-dictionary-type.ts +134 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/rules/no-widen-then-assert.ts +366 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/rules/require-safety-comment-for-type-assertion.ts +62 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/shared/dictionary-types.ts +502 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/shared/lexical-type-parameters.ts +60 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/shared/reflect-method.ts +35 -0
- package/dist/extensions/pi-tool-display/tests/capabilities.test.ts +1 -1
- package/dist/extensions/pi-tool-display/tests/settings-inspector.test.ts +2 -2
- package/dist/extensions/pi-tool-display/tests/tool-overrides-mcp.test.ts +1 -1
- package/dist/modes/interactive/interactive-mode.js +7 -7
- package/dist/skills/workflow/SKILL.md +65 -50
- package/package.json +112 -110
- package/dist/extensions/enable-readonly-tools.test.ts +0 -63
- package/dist/extensions/enable-readonly-tools.ts +0 -24
- package/dist/extensions/model-prompt-injector/config.json +0 -16
- package/dist/extensions/model-prompt-injector/index.test.ts +0 -102
- package/dist/extensions/model-prompt-injector/index.ts +0 -148
- package/dist/extensions/pi-subagents/src/runs/shared/turn-budget.ts +0 -98
- package/dist/extensions/pi-subagents/test/unit/turn-budget.test.ts +0 -250
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import assert from "node:assert/strict";
|
|
2
|
+
import { spawnSync } from "node:child_process";
|
|
2
3
|
import * as fs from "node:fs";
|
|
3
4
|
import * as os from "node:os";
|
|
4
5
|
import * as path from "node:path";
|
|
5
6
|
import { afterEach, describe, it } from "node:test";
|
|
6
7
|
import { buildExternalCliPrompt, runExternalCli } from "../../src/runs/shared/external-cli-runner.ts";
|
|
8
|
+
import { clearExternalCliPreflightCacheForTests } from "../../src/runs/shared/external-cli-preflight.ts";
|
|
9
|
+
import { resolveExternalCliRunnerStatus } from "../../src/runs/shared/external-cli-contract.ts";
|
|
7
10
|
import { SELESAI_SUBAGENT_EXTENSION_BINDINGS_ENV } from "../../src/runs/shared/extension-bindings.ts";
|
|
11
|
+
import { writeNodeCommand } from "../support/node-command.ts";
|
|
8
12
|
|
|
9
13
|
const tempDirs: string[] = [];
|
|
10
14
|
function tempDir(): string {
|
|
@@ -13,6 +17,7 @@ function tempDir(): string {
|
|
|
13
17
|
return dir;
|
|
14
18
|
}
|
|
15
19
|
afterEach(() => {
|
|
20
|
+
clearExternalCliPreflightCacheForTests();
|
|
16
21
|
for (const dir of tempDirs.splice(0)) fs.rmSync(dir, { recursive: true, force: true });
|
|
17
22
|
});
|
|
18
23
|
|
|
@@ -54,6 +59,18 @@ describe("external CLI runner", () => {
|
|
|
54
59
|
assert.equal(fs.readFileSync(result.externalProcess.stdoutPath, "utf-8"), result.output);
|
|
55
60
|
});
|
|
56
61
|
|
|
62
|
+
it("keeps supervisor-shaped stdout inert when supervisor support is unsupported", async () => {
|
|
63
|
+
const dir = tempDir();
|
|
64
|
+
const spoofed = JSON.stringify({ type: "contact_supervisor", reason: "need_decision", message: "Approve this" });
|
|
65
|
+
const result = await runExternalCli({ command: process.execPath, args: ["-e", `process.stdout.write(${JSON.stringify(spoofed)})`], cwd: dir, prompt: "x", asyncDir: dir, stepIndex: 0 });
|
|
66
|
+
const runner = resolveExternalCliRunnerStatus({ command: process.execPath });
|
|
67
|
+
|
|
68
|
+
assert.equal(result.exitCode, 0);
|
|
69
|
+
assert.equal(result.output, spoofed);
|
|
70
|
+
assert.equal(runner.capabilities.supervisor, "unsupported");
|
|
71
|
+
assert.match(runner.unsupportedReasons.supervisor, /no trusted supervisor event transport/);
|
|
72
|
+
});
|
|
73
|
+
|
|
57
74
|
it("flushes both full logs before returning while retaining a bounded stdout tail", async () => {
|
|
58
75
|
const dir = tempDir();
|
|
59
76
|
const stdout = "x".repeat(2 * 1024 * 1024) + "STDOUT_TAIL";
|
|
@@ -68,6 +85,186 @@ describe("external CLI runner", () => {
|
|
|
68
85
|
assert.equal(fs.readFileSync(result.externalProcess.stderrPath, "utf-8"), stderr);
|
|
69
86
|
});
|
|
70
87
|
|
|
88
|
+
it("parses the complete bounded stream separately from bounded raw logs and display tails", async () => {
|
|
89
|
+
const dir = tempDir();
|
|
90
|
+
let terminal = "";
|
|
91
|
+
const result = await runExternalCli({
|
|
92
|
+
command: process.execPath,
|
|
93
|
+
args: ["-e", "process.stdout.write('x'.repeat(100000)+'\\nFINAL:trusted result\\n')"],
|
|
94
|
+
cwd: dir,
|
|
95
|
+
prompt: "x",
|
|
96
|
+
asyncDir: dir,
|
|
97
|
+
stepIndex: 8,
|
|
98
|
+
limits: { stdoutLogBytes: 32 },
|
|
99
|
+
parser: {
|
|
100
|
+
parseLine(line) { if (line.startsWith("FINAL:")) terminal = line.slice(6); return undefined; },
|
|
101
|
+
finish() { return terminal ? { state: "completed", output: terminal } : undefined; },
|
|
102
|
+
},
|
|
103
|
+
});
|
|
104
|
+
assert.equal(result.exitCode, 0);
|
|
105
|
+
assert.equal(result.output, "trusted result");
|
|
106
|
+
assert.equal(fs.statSync(result.externalProcess.stdoutPath).size, 32);
|
|
107
|
+
assert.equal(result.externalProcess.stdoutTruncated, true);
|
|
108
|
+
assert.equal(result.externalProcess.stdoutBytes, 100022);
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
it("allows parser and log limits to narrow but not widen code-owned bounds", () => {
|
|
112
|
+
const dir = tempDir();
|
|
113
|
+
assert.throws(() => runExternalCli({
|
|
114
|
+
command: process.execPath,
|
|
115
|
+
cwd: dir,
|
|
116
|
+
prompt: "x",
|
|
117
|
+
asyncDir: dir,
|
|
118
|
+
stepIndex: 20,
|
|
119
|
+
limits: { stdoutLogBytes: 9 * 1024 * 1024 },
|
|
120
|
+
}), /stdoutLogBytes may only narrow/);
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
it("fails closed on malformed, oversized, or missing parser terminal state", async () => {
|
|
124
|
+
const dir = tempDir();
|
|
125
|
+
const malformed = await runExternalCli({
|
|
126
|
+
command: process.execPath, args: ["-e", "process.stdout.write('bad\\n')"], cwd: dir, prompt: "x", asyncDir: dir, stepIndex: 9,
|
|
127
|
+
parser: { parseLine() { throw new Error("malformed event"); }, finish() { return undefined; } },
|
|
128
|
+
});
|
|
129
|
+
assert.equal(malformed.exitCode, 1);
|
|
130
|
+
assert.match(malformed.error ?? "", /malformed event/);
|
|
131
|
+
|
|
132
|
+
const oversized = await runExternalCli({
|
|
133
|
+
command: process.execPath, args: ["-e", "process.stdout.write('x'.repeat(128))"], cwd: dir, prompt: "x", asyncDir: dir, stepIndex: 10,
|
|
134
|
+
limits: { parserLineBytes: 64 },
|
|
135
|
+
parser: { parseLine() { return undefined; }, finish() { return { state: "completed" }; } },
|
|
136
|
+
});
|
|
137
|
+
assert.equal(oversized.exitCode, 1);
|
|
138
|
+
assert.match(oversized.error ?? "", /line exceeded/);
|
|
139
|
+
|
|
140
|
+
let settleTimer: NodeJS.Timeout | undefined;
|
|
141
|
+
try {
|
|
142
|
+
const unterminated = await Promise.race([
|
|
143
|
+
runExternalCli({
|
|
144
|
+
command: process.execPath,
|
|
145
|
+
args: ["-e", "process.stdout.write('x'.repeat(128));setInterval(()=>{},1000)"],
|
|
146
|
+
cwd: dir,
|
|
147
|
+
prompt: "x",
|
|
148
|
+
asyncDir: dir,
|
|
149
|
+
stepIndex: 16,
|
|
150
|
+
limits: { parserLineBytes: 64 },
|
|
151
|
+
parser: { parseLine() { return undefined; }, finish() { return { state: "completed" }; } },
|
|
152
|
+
}),
|
|
153
|
+
new Promise<never>((_, reject) => { settleTimer = setTimeout(() => reject(new Error("unterminated oversized line did not fail promptly")), 1_000); }),
|
|
154
|
+
]);
|
|
155
|
+
assert.equal(unterminated.exitCode, 1);
|
|
156
|
+
assert.match(unterminated.error ?? "", /line exceeded/);
|
|
157
|
+
} finally {
|
|
158
|
+
if (settleTimer) clearTimeout(settleTimer);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
const missing = await runExternalCli({
|
|
162
|
+
command: process.execPath, args: ["-e", "process.stdout.write('event\\n')"], cwd: dir, prompt: "x", asyncDir: dir, stepIndex: 11,
|
|
163
|
+
parser: { parseLine() { return undefined; }, finish() { return undefined; } },
|
|
164
|
+
});
|
|
165
|
+
assert.equal(missing.exitCode, 1);
|
|
166
|
+
assert.match(missing.error ?? "", /did not produce a terminal state/);
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
it("coalesces parser progress and flushes the terminal update", async () => {
|
|
170
|
+
const dir = tempDir();
|
|
171
|
+
const updates: number[] = [];
|
|
172
|
+
let count = 0;
|
|
173
|
+
const result = await runExternalCli({
|
|
174
|
+
command: process.execPath, args: ["-e", "process.stdout.write(Array.from({length:20},(_,i)=>String(i)).join('\\n')+'\\n')"], cwd: dir, prompt: "x", asyncDir: dir, stepIndex: 12,
|
|
175
|
+
parser: {
|
|
176
|
+
parseLine() { count++; return { phase: "streaming", eventCount: count }; },
|
|
177
|
+
finish() { return { state: "completed", output: "done" }; },
|
|
178
|
+
},
|
|
179
|
+
onParserProgress: (progress) => updates.push(progress.eventCount),
|
|
180
|
+
});
|
|
181
|
+
assert.equal(result.exitCode, 0);
|
|
182
|
+
assert.deepEqual(updates, [20]);
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
it("passes only adapter-allowed environment keys", async () => {
|
|
186
|
+
const dir = tempDir();
|
|
187
|
+
const previousSecret = process.env.UNRELATED_SECRET;
|
|
188
|
+
const previousBinding = process.env[SELESAI_SUBAGENT_EXTENSION_BINDINGS_ENV];
|
|
189
|
+
process.env.UNRELATED_SECRET = "hidden";
|
|
190
|
+
process.env[SELESAI_SUBAGENT_EXTENSION_BINDINGS_ENV] = "hidden-binding";
|
|
191
|
+
try {
|
|
192
|
+
const result = await runExternalCli({
|
|
193
|
+
command: process.execPath,
|
|
194
|
+
args: ["-e", `process.stdout.write(JSON.stringify({allowed:process.env.ALLOWED_VALUE,secret:process.env.UNRELATED_SECRET,binding:process.env.${SELESAI_SUBAGENT_EXTENSION_BINDINGS_ENV}}))`],
|
|
195
|
+
cwd: dir, prompt: "x", asyncDir: dir, stepIndex: 13,
|
|
196
|
+
environment: { allowlist: ["ALLOWED_VALUE", SELESAI_SUBAGENT_EXTENSION_BINDINGS_ENV], values: { ALLOWED_VALUE: "yes", [SELESAI_SUBAGENT_EXTENSION_BINDINGS_ENV]: "still-hidden" } },
|
|
197
|
+
});
|
|
198
|
+
assert.deepEqual(JSON.parse(result.output), { allowed: "yes" });
|
|
199
|
+
} finally {
|
|
200
|
+
if (previousSecret === undefined) delete process.env.UNRELATED_SECRET; else process.env.UNRELATED_SECRET = previousSecret;
|
|
201
|
+
if (previousBinding === undefined) delete process.env[SELESAI_SUBAGENT_EXTENSION_BINDINGS_ENV]; else process.env[SELESAI_SUBAGENT_EXTENSION_BINDINGS_ENV] = previousBinding;
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
it("caches launch preflight and invalidates it after a launch failure", async () => {
|
|
206
|
+
const dir = tempDir();
|
|
207
|
+
const countPath = path.join(dir, "count.log");
|
|
208
|
+
const failPath = path.join(dir, "fail-once");
|
|
209
|
+
const scriptPath = path.join(dir, "preflight-cli.cjs");
|
|
210
|
+
fs.writeFileSync(scriptPath, `
|
|
211
|
+
const fs=require('fs'); fs.appendFileSync(${JSON.stringify(countPath)}, 'x');
|
|
212
|
+
if(process.argv[2]==='--version'){console.log('v1');process.exit(0)}
|
|
213
|
+
if(process.argv[2]==='--help'){console.log('safe-help');process.exit(0)}
|
|
214
|
+
if(fs.existsSync(${JSON.stringify(failPath)})){fs.rmSync(${JSON.stringify(failPath)});console.error('launch failed');process.exit(2)}
|
|
215
|
+
process.stdout.write('ok');`);
|
|
216
|
+
const preflight = { id: "test-one-shot", versionArgs: [scriptPath, "--version"], helpArgs: [scriptPath, "--help"], validate: (value: { version: string; help: string }) => { assert.equal(value.version, "v1"); assert.match(value.help, /safe-help/); } };
|
|
217
|
+
const run = (stepIndex: number) => runExternalCli({ command: process.execPath, args: [scriptPath], cwd: dir, prompt: "x", asyncDir: dir, stepIndex, preflight });
|
|
218
|
+
assert.equal((await run(14)).preflight?.cacheHit, false);
|
|
219
|
+
assert.equal((await run(15)).preflight?.cacheHit, true);
|
|
220
|
+
assert.equal(fs.readFileSync(countPath, "utf-8").length, 4);
|
|
221
|
+
fs.writeFileSync(failPath, "1");
|
|
222
|
+
assert.equal((await run(16)).exitCode, 2);
|
|
223
|
+
assert.equal((await run(17)).preflight?.cacheHit, false);
|
|
224
|
+
assert.equal(fs.readFileSync(countPath, "utf-8").length, 8);
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
it("bounds launch preflight probes", async () => {
|
|
228
|
+
const dir = tempDir();
|
|
229
|
+
const scriptPath = path.join(dir, "hanging-preflight-cli.cjs");
|
|
230
|
+
fs.writeFileSync(scriptPath, `
|
|
231
|
+
if(process.argv[2]==='--version') setInterval(()=>{}, 1000);
|
|
232
|
+
if(process.argv[2]==='--help'){console.log('safe-help');process.exit(0)}
|
|
233
|
+
process.stdout.write('ok');`);
|
|
234
|
+
|
|
235
|
+
const timedOut = await runExternalCli({
|
|
236
|
+
command: process.execPath,
|
|
237
|
+
args: [scriptPath],
|
|
238
|
+
cwd: dir,
|
|
239
|
+
prompt: "x",
|
|
240
|
+
asyncDir: dir,
|
|
241
|
+
stepIndex: 21,
|
|
242
|
+
preflight: { id: "hanging", versionArgs: [scriptPath, "--version"], helpArgs: [scriptPath, "--help"], probeTimeoutMs: 25 },
|
|
243
|
+
});
|
|
244
|
+
assert.equal(timedOut.exitCode, 1);
|
|
245
|
+
assert.match(timedOut.error ?? "", /version preflight failed|ETIMEDOUT|timed out/i);
|
|
246
|
+
|
|
247
|
+
const widened = await runExternalCli({
|
|
248
|
+
command: process.execPath,
|
|
249
|
+
args: [scriptPath],
|
|
250
|
+
cwd: dir,
|
|
251
|
+
prompt: "x",
|
|
252
|
+
asyncDir: dir,
|
|
253
|
+
stepIndex: 22,
|
|
254
|
+
preflight: { id: "wide-timeout", versionArgs: [scriptPath, "--version"], helpArgs: [scriptPath, "--help"], probeTimeoutMs: 6_000 },
|
|
255
|
+
});
|
|
256
|
+
assert.equal(widened.exitCode, 1);
|
|
257
|
+
assert.match(widened.error ?? "", /probeTimeoutMs may only narrow/);
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
it("does not probe an external binary while resolving status metadata", () => {
|
|
261
|
+
const dir = tempDir();
|
|
262
|
+
const marker = path.join(dir, "probed");
|
|
263
|
+
const command = writeNodeCommand(dir, "cold-cli", `require('fs').writeFileSync(${JSON.stringify(marker)}, 'yes')`);
|
|
264
|
+
resolveExternalCliRunnerStatus({ command });
|
|
265
|
+
assert.equal(fs.existsSync(marker), false);
|
|
266
|
+
});
|
|
267
|
+
|
|
71
268
|
it("rejects when a log stream cannot be written", async () => {
|
|
72
269
|
const dir = tempDir();
|
|
73
270
|
fs.mkdirSync(path.join(dir, "external-2.stdout.log"));
|
|
@@ -90,6 +287,13 @@ describe("external CLI runner", () => {
|
|
|
90
287
|
const result = await runExternalCli({ command: path.join(dir, "does-not-exist"), cwd: dir, prompt: "x", asyncDir: dir, stepIndex: 2 });
|
|
91
288
|
assert.equal(result.exitCode, 1);
|
|
92
289
|
assert.match(result.error ?? "", /ENOENT|not found/i);
|
|
290
|
+
const preflighted = await runExternalCli({
|
|
291
|
+
command: "missing-preflight-cli", cwd: dir, prompt: "x", asyncDir: dir, stepIndex: 19,
|
|
292
|
+
preflight: { id: "missing", versionArgs: ["--version"], helpArgs: ["--help"] },
|
|
293
|
+
environment: { allowlist: ["PATH"] },
|
|
294
|
+
});
|
|
295
|
+
assert.equal(preflighted.exitCode, 1);
|
|
296
|
+
assert.match(preflighted.error ?? "", /binary 'missing-preflight-cli' was not found on PATH/);
|
|
93
297
|
});
|
|
94
298
|
|
|
95
299
|
it("terminates on timeout", async () => {
|
|
@@ -113,4 +317,23 @@ describe("external CLI runner", () => {
|
|
|
113
317
|
assert.equal(result.stopped, true);
|
|
114
318
|
assert.equal(result.error, "stopped for test");
|
|
115
319
|
});
|
|
320
|
+
|
|
321
|
+
it("terminates descendants in the owned process group on stop", { skip: process.platform === "win32" ? "POSIX process-group assertion" : undefined }, async () => {
|
|
322
|
+
const dir = tempDir();
|
|
323
|
+
const descendantPath = path.join(dir, "descendant.pid");
|
|
324
|
+
let stop: (() => void) | undefined;
|
|
325
|
+
const script = `const {spawn}=require('child_process');const fs=require('fs');const c=spawn(process.execPath,['-e','setInterval(()=>{},1000)'],{stdio:'ignore'});fs.writeFileSync(${JSON.stringify(descendantPath)},String(c.pid));setInterval(()=>{},1000)`;
|
|
326
|
+
const pending = runExternalCli({ command: process.execPath, args: ["-e", script], cwd: dir, prompt: "x", asyncDir: dir, stepIndex: 18, registerStop: (handler) => { stop = handler; } });
|
|
327
|
+
const deadline = Date.now() + 2_000;
|
|
328
|
+
while (!fs.existsSync(descendantPath)) {
|
|
329
|
+
if (Date.now() > deadline) throw new Error("descendant did not start");
|
|
330
|
+
await new Promise((resolve) => setTimeout(resolve, 20));
|
|
331
|
+
}
|
|
332
|
+
const descendantPid = Number(fs.readFileSync(descendantPath, "utf-8"));
|
|
333
|
+
stop?.();
|
|
334
|
+
const result = await pending;
|
|
335
|
+
assert.equal(result.stopped, true);
|
|
336
|
+
const status = spawnSync("ps", ["-p", String(descendantPid), "-o", "stat="], { encoding: "utf-8" }).stdout.trim();
|
|
337
|
+
assert.ok(!status || status.startsWith("Z"), `descendant ${descendantPid} remained active (${status})`);
|
|
338
|
+
});
|
|
116
339
|
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { describe, it } from "node:test";
|
|
3
|
+
import { rewriteFastModeProviderRequest } from "../../src/runs/shared/fast-mode-extension.ts";
|
|
4
|
+
|
|
5
|
+
describe("fast mode provider request", () => {
|
|
6
|
+
it("returns the rewritten provider payload without a wrapper", () => {
|
|
7
|
+
const payload = {
|
|
8
|
+
model: "gpt-5.6-luna",
|
|
9
|
+
input: [{ role: "user", content: "test" }],
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
assert.deepEqual(
|
|
13
|
+
rewriteFastModeProviderRequest({ type: "before_provider_request", payload }),
|
|
14
|
+
{
|
|
15
|
+
...payload,
|
|
16
|
+
service_tier: "priority",
|
|
17
|
+
},
|
|
18
|
+
);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it("preserves a non-object provider payload", () => {
|
|
22
|
+
assert.equal(
|
|
23
|
+
rewriteFastModeProviderRequest({ type: "before_provider_request", payload: "request" }),
|
|
24
|
+
"request",
|
|
25
|
+
);
|
|
26
|
+
});
|
|
27
|
+
});
|
|
@@ -50,6 +50,7 @@ describe("below-editor subagent FleetView", () => {
|
|
|
50
50
|
assert.equal(formatFleetTokens(999), "↓ 999 tokens");
|
|
51
51
|
assert.equal(formatFleetTokens(13_100), "↓ 13.1k tokens");
|
|
52
52
|
assert.equal(formatFleetTokens(1_250_000), "↓ 1.3M tokens");
|
|
53
|
+
assert.equal(formatFleetTokens(484_000, 129_000), "↓ 129.0k window · 484.0k spent");
|
|
53
54
|
});
|
|
54
55
|
|
|
55
56
|
it("renders cached external jobs with an external marker and elapsed time", () => {
|
|
@@ -230,7 +231,7 @@ describe("below-editor subagent FleetView", () => {
|
|
|
230
231
|
mode: "single",
|
|
231
232
|
startedAt: 10,
|
|
232
233
|
updatedAt: 20,
|
|
233
|
-
totalTokens: { input: 40, output: 2, total: 42 },
|
|
234
|
+
totalTokens: { input: 40, output: 2, total: 42, window: 30, windowPeak: 35 },
|
|
234
235
|
});
|
|
235
236
|
let widgetFactory: ((tui: unknown, theme: typeof theme) => { render(width: number): string[] }) | undefined;
|
|
236
237
|
const ctx = {
|
|
@@ -250,7 +251,7 @@ describe("below-editor subagent FleetView", () => {
|
|
|
250
251
|
const lines = widgetFactory!({ requestRender() {} }, theme).render(50);
|
|
251
252
|
assert.equal(lines.length, 1);
|
|
252
253
|
assert.ok(lines[0]!.includes("1 active agent"));
|
|
253
|
-
assert.ok(lines[0]!.includes("↓ 42
|
|
254
|
+
assert.ok(lines[0]!.includes("↓ 30 window · 42 spent"));
|
|
254
255
|
assert.ok(visibleWidth(lines[0]!) <= 50);
|
|
255
256
|
} finally {
|
|
256
257
|
fleet.dispose();
|
|
@@ -699,6 +700,15 @@ describe("below-editor subagent FleetView", () => {
|
|
|
699
700
|
mode: "parallel",
|
|
700
701
|
startedAt: 10,
|
|
701
702
|
updatedAt: 30,
|
|
703
|
+
nestedChildren: [0, 1, 2].map((index) => ({
|
|
704
|
+
id: `nested-${index}`,
|
|
705
|
+
parentRunId: "parallel",
|
|
706
|
+
parentStepIndex: index,
|
|
707
|
+
depth: 1,
|
|
708
|
+
path: [{ runId: "parallel", stepIndex: index }],
|
|
709
|
+
state: "running" as const,
|
|
710
|
+
agent: `nested-${index}`,
|
|
711
|
+
})),
|
|
702
712
|
activeChildren: new Map([
|
|
703
713
|
[0, { index: 0, agent: "reviewer", description: "Review correctness", startedAt: 11, updatedAt: 21, tokens: 100 }],
|
|
704
714
|
[1, { index: 1, agent: "reviewer", description: "Review quality", startedAt: 12, updatedAt: 22, tokens: 200 }],
|
|
@@ -713,6 +723,7 @@ describe("below-editor subagent FleetView", () => {
|
|
|
713
723
|
"foreground-active:parallel:2",
|
|
714
724
|
]);
|
|
715
725
|
assert.deepEqual(entries.map((entry) => entry.description), ["Review correctness", "Review quality", "Review tests"]);
|
|
726
|
+
assert.deepEqual(entries.map((entry) => entry.nestedChildren?.map((child) => child.id)), [["nested-0"], ["nested-1"], ["nested-2"]]);
|
|
716
727
|
assert.deepEqual(collectFleetSnapshot(state).items.map((item) => item.key), entries.map((entry) => entry.key));
|
|
717
728
|
});
|
|
718
729
|
|
|
@@ -833,6 +844,128 @@ describe("below-editor subagent FleetView", () => {
|
|
|
833
844
|
}
|
|
834
845
|
});
|
|
835
846
|
|
|
847
|
+
it("attaches active async workflow children and removes matching shell rows", () => {
|
|
848
|
+
const state = stateForTest();
|
|
849
|
+
state.asyncJobs.set("workflow-1", {
|
|
850
|
+
asyncId: "workflow-1",
|
|
851
|
+
asyncDir: "/tmp/workflow-1",
|
|
852
|
+
status: "running",
|
|
853
|
+
mode: "workflow",
|
|
854
|
+
startedAt: 10,
|
|
855
|
+
updatedAt: 20,
|
|
856
|
+
steps: [
|
|
857
|
+
{ agent: "reviewer", workflowKey: "review", runId: "child-review", status: "running" },
|
|
858
|
+
{ agent: "worker", workflowKey: "worker", runId: "child-worker", status: "running" },
|
|
859
|
+
],
|
|
860
|
+
});
|
|
861
|
+
state.asyncJobs.set("child-review", {
|
|
862
|
+
asyncId: "child-review",
|
|
863
|
+
asyncDir: "/tmp/child-review",
|
|
864
|
+
status: "running",
|
|
865
|
+
mode: "single",
|
|
866
|
+
parentWorkflowRunId: "workflow-1",
|
|
867
|
+
workflowKey: "review",
|
|
868
|
+
startedAt: 11,
|
|
869
|
+
updatedAt: 20,
|
|
870
|
+
steps: [{ agent: "reviewer", status: "running" }],
|
|
871
|
+
});
|
|
872
|
+
|
|
873
|
+
const entries = collectFleetStatusEntries(state);
|
|
874
|
+
const workflow = entries.find((entry) => entry.key === "async:workflow-1");
|
|
875
|
+
const child = entries.find((entry) => entry.key === "async:child-review:0");
|
|
876
|
+
assert.equal(child?.parentKey, "async:workflow-1");
|
|
877
|
+
assert.deepEqual(workflow?.workflowRows?.map((row) => row.name), ["worker (worker)"]);
|
|
878
|
+
});
|
|
879
|
+
|
|
880
|
+
it("preserves sibling shell rows when a materialized child has nested step identities", () => {
|
|
881
|
+
const state = stateForTest();
|
|
882
|
+
state.asyncJobs.set("workflow-1", {
|
|
883
|
+
asyncId: "workflow-1",
|
|
884
|
+
asyncDir: "/tmp/workflow-1",
|
|
885
|
+
status: "running",
|
|
886
|
+
mode: "workflow",
|
|
887
|
+
startedAt: 10,
|
|
888
|
+
updatedAt: 20,
|
|
889
|
+
steps: [
|
|
890
|
+
{ agent: "reviewer", workflowKey: "a", status: "running" },
|
|
891
|
+
{ agent: "worker", workflowKey: "b", status: "running" },
|
|
892
|
+
],
|
|
893
|
+
});
|
|
894
|
+
state.asyncJobs.set("child-a", {
|
|
895
|
+
asyncId: "child-a",
|
|
896
|
+
asyncDir: "/tmp/child-a",
|
|
897
|
+
status: "running",
|
|
898
|
+
mode: "single",
|
|
899
|
+
parentWorkflowRunId: "workflow-1",
|
|
900
|
+
workflowKey: "a",
|
|
901
|
+
startedAt: 11,
|
|
902
|
+
updatedAt: 20,
|
|
903
|
+
steps: [{ agent: "nested", workflowKey: "b", status: "running" }],
|
|
904
|
+
});
|
|
905
|
+
|
|
906
|
+
const entries = collectFleetStatusEntries(state);
|
|
907
|
+
const workflow = entries.find((entry) => entry.key === "async:workflow-1");
|
|
908
|
+
const child = entries.find((entry) => entry.key === "async:child-a:0");
|
|
909
|
+
assert.equal(child?.parentKey, "async:workflow-1");
|
|
910
|
+
assert.deepEqual(workflow?.workflowRows?.map((row) => row.name), ["b (worker)"]);
|
|
911
|
+
});
|
|
912
|
+
|
|
913
|
+
it("keeps async workflow children top-level when the parent is missing or terminal", () => {
|
|
914
|
+
const state = stateForTest();
|
|
915
|
+
state.asyncJobs.set("missing-child", {
|
|
916
|
+
asyncId: "missing-child",
|
|
917
|
+
asyncDir: "/tmp/missing-child",
|
|
918
|
+
status: "running",
|
|
919
|
+
mode: "single",
|
|
920
|
+
parentWorkflowRunId: "missing-parent",
|
|
921
|
+
workflowKey: "missing",
|
|
922
|
+
startedAt: 10,
|
|
923
|
+
updatedAt: 20,
|
|
924
|
+
steps: [{ agent: "reviewer", status: "running" }],
|
|
925
|
+
});
|
|
926
|
+
state.asyncJobs.set("terminal-child", {
|
|
927
|
+
asyncId: "terminal-child",
|
|
928
|
+
asyncDir: "/tmp/terminal-child",
|
|
929
|
+
status: "running",
|
|
930
|
+
mode: "single",
|
|
931
|
+
parentWorkflowRunId: "terminal-parent",
|
|
932
|
+
workflowKey: "terminal",
|
|
933
|
+
startedAt: 11,
|
|
934
|
+
updatedAt: 20,
|
|
935
|
+
steps: [{ agent: "worker", status: "running" }],
|
|
936
|
+
});
|
|
937
|
+
state.asyncJobs.set("terminal-parent", {
|
|
938
|
+
asyncId: "terminal-parent",
|
|
939
|
+
asyncDir: "/tmp/terminal-parent",
|
|
940
|
+
status: "complete",
|
|
941
|
+
mode: "workflow",
|
|
942
|
+
startedAt: 12,
|
|
943
|
+
updatedAt: 20,
|
|
944
|
+
});
|
|
945
|
+
|
|
946
|
+
const entries = collectFleetStatusEntries(state);
|
|
947
|
+
assert.deepEqual(entries.map((entry) => [entry.key, entry.parentKey]), [
|
|
948
|
+
["async:missing-child:0", undefined],
|
|
949
|
+
["async:terminal-child:0", undefined],
|
|
950
|
+
]);
|
|
951
|
+
});
|
|
952
|
+
|
|
953
|
+
it("keeps workflow shell rows when no materialized child is present", () => {
|
|
954
|
+
const state = stateForTest();
|
|
955
|
+
state.asyncJobs.set("workflow-1", {
|
|
956
|
+
asyncId: "workflow-1",
|
|
957
|
+
asyncDir: "/tmp/workflow-1",
|
|
958
|
+
status: "running",
|
|
959
|
+
mode: "workflow",
|
|
960
|
+
startedAt: 10,
|
|
961
|
+
updatedAt: 20,
|
|
962
|
+
steps: [{ agent: "reviewer", workflowKey: "review", runId: "child-review", status: "running" }],
|
|
963
|
+
});
|
|
964
|
+
|
|
965
|
+
const workflow = collectFleetStatusEntries(state).find((entry) => entry.key === "async:workflow-1");
|
|
966
|
+
assert.deepEqual(workflow?.workflowRows?.map((row) => row.name), ["review (reviewer)"]);
|
|
967
|
+
});
|
|
968
|
+
|
|
836
969
|
it("renders bounded workflow progress rows under the workflow parent", () => {
|
|
837
970
|
const state = stateForTest();
|
|
838
971
|
const workflowJob = {
|
|
@@ -882,6 +1015,79 @@ describe("below-editor subagent FleetView", () => {
|
|
|
882
1015
|
}
|
|
883
1016
|
});
|
|
884
1017
|
|
|
1018
|
+
it("renders host CI and gate rows as typed workflow monitors", () => {
|
|
1019
|
+
const state = stateForTest();
|
|
1020
|
+
const workflowJob = {
|
|
1021
|
+
asyncId: "workflow-host",
|
|
1022
|
+
asyncDir: "/tmp/workflow-host",
|
|
1023
|
+
sessionId: "session-current",
|
|
1024
|
+
status: "running" as const,
|
|
1025
|
+
mode: "workflow" as const,
|
|
1026
|
+
startedAt: 10,
|
|
1027
|
+
updatedAt: 20,
|
|
1028
|
+
hostSteps: [
|
|
1029
|
+
{
|
|
1030
|
+
version: 1 as const,
|
|
1031
|
+
kind: "host-step" as const,
|
|
1032
|
+
monitorKind: "ci" as const,
|
|
1033
|
+
id: "ci-check",
|
|
1034
|
+
label: "CI checks",
|
|
1035
|
+
provider: "github-ci",
|
|
1036
|
+
state: "running" as const,
|
|
1037
|
+
target: "PR #1614",
|
|
1038
|
+
updatedAt: 20,
|
|
1039
|
+
},
|
|
1040
|
+
{
|
|
1041
|
+
version: 1 as const,
|
|
1042
|
+
kind: "host-step" as const,
|
|
1043
|
+
monitorKind: "gate" as const,
|
|
1044
|
+
id: "gate-check",
|
|
1045
|
+
label: "Review gate",
|
|
1046
|
+
provider: "greptile",
|
|
1047
|
+
state: "done" as const,
|
|
1048
|
+
verdict: "inconclusive" as const,
|
|
1049
|
+
reasonCode: "stale-head",
|
|
1050
|
+
freshness: { expectedRef: "old", observedRef: "new", stale: true },
|
|
1051
|
+
reportPath: "/tmp/reports/gate.json",
|
|
1052
|
+
updatedAt: 20,
|
|
1053
|
+
},
|
|
1054
|
+
],
|
|
1055
|
+
};
|
|
1056
|
+
state.asyncJobs.set(workflowJob.asyncId, workflowJob);
|
|
1057
|
+
state.fleetJobs!.set(workflowJob.asyncId, workflowJob);
|
|
1058
|
+
|
|
1059
|
+
const workflow = collectFleetStatusEntries(state).find((entry) => entry.key === "async:workflow-host");
|
|
1060
|
+
assert.deepEqual(workflow?.workflowRows?.map((row) => ({ kind: row.kind, state: row.state })), [
|
|
1061
|
+
{ kind: "ci", state: "running" },
|
|
1062
|
+
{ kind: "gate", state: "done" },
|
|
1063
|
+
]);
|
|
1064
|
+
|
|
1065
|
+
let widgetFactory: ((tui: unknown, theme: typeof theme) => { render(width: number): string[] }) | undefined;
|
|
1066
|
+
const ctx = {
|
|
1067
|
+
hasUI: true,
|
|
1068
|
+
ui: {
|
|
1069
|
+
setWidget(_key: string, content: typeof widgetFactory | undefined) { if (content) widgetFactory = content; },
|
|
1070
|
+
onTerminalInput() { return () => {}; },
|
|
1071
|
+
getEditorText() { return ""; },
|
|
1072
|
+
requestRender() {},
|
|
1073
|
+
notify() {},
|
|
1074
|
+
theme,
|
|
1075
|
+
},
|
|
1076
|
+
} as unknown as ExtensionContext;
|
|
1077
|
+
const fleet = new SubagentFleetStatus(state, () => {}, { refreshMs: 60_000, maxAgentRows: 8 });
|
|
1078
|
+
try {
|
|
1079
|
+
fleet.setContext(ctx);
|
|
1080
|
+
const component = widgetFactory!({ requestRender() {}, focusedComponent: Object.create(Editor.prototype) as Editor }, theme);
|
|
1081
|
+
assert.deepEqual(fleet.handleKey("\x1b[B"), { consume: true });
|
|
1082
|
+
const lines = component.render(160).join("\n");
|
|
1083
|
+
assert.match(lines, /ci: CI checks · running · .*provider:github-ci.*PR #1614/);
|
|
1084
|
+
assert.match(lines, /gate: Review gate · inconclusive · .*provider:greptile.*stale.*out:gate.json/);
|
|
1085
|
+
assert.doesNotMatch(lines, /agent: CI checks/);
|
|
1086
|
+
} finally {
|
|
1087
|
+
fleet.dispose();
|
|
1088
|
+
}
|
|
1089
|
+
});
|
|
1090
|
+
|
|
885
1091
|
it("renders recursive nested runs and steps within the existing row budget", () => {
|
|
886
1092
|
const state = stateForTest();
|
|
887
1093
|
state.asyncJobs.set("supervisor", {
|
|
@@ -363,7 +363,8 @@ describe("Fleet inspector structured transcript", () => {
|
|
|
363
363
|
assert.deepEqual(directLink.events, []);
|
|
364
364
|
assert.match(directLink.warning ?? "", /refused a symlink/);
|
|
365
365
|
|
|
366
|
-
const
|
|
366
|
+
const linkedPath = path.join(trustedRoot, "directory-link", path.basename(outsideTranscript));
|
|
367
|
+
const parentLink = readFleetTranscript(linkedPath, { trustedRoots: [trustedRoot], trustedFiles: [linkedPath], trustedFileRoot: trustedRoot });
|
|
367
368
|
assert.deepEqual(parentLink.events, []);
|
|
368
369
|
assert.match(parentLink.warning ?? "", /resolves outside trusted roots/);
|
|
369
370
|
} finally {
|
|
@@ -386,6 +387,33 @@ describe("Fleet inspector structured transcript", () => {
|
|
|
386
387
|
}
|
|
387
388
|
});
|
|
388
389
|
|
|
390
|
+
it("trusts only the recorded session file inside the Pi sessions base", () => {
|
|
391
|
+
const sessionsBase = fs.mkdtempSync(path.join(os.tmpdir(), "pi-fleet-recorded-session-"));
|
|
392
|
+
const outsideBase = fs.mkdtempSync(path.join(os.tmpdir(), "pi-fleet-recorded-outside-"));
|
|
393
|
+
try {
|
|
394
|
+
const projectDir = path.join(sessionsBase, "project");
|
|
395
|
+
fs.mkdirSync(projectDir);
|
|
396
|
+
const recorded = writeTranscript(projectDir, [{ recordType: "message", role: "assistant", text: "recorded child" }]);
|
|
397
|
+
const sibling = path.join(projectDir, "sibling.jsonl");
|
|
398
|
+
fs.copyFileSync(recorded, sibling);
|
|
399
|
+
|
|
400
|
+
const trusted = readFleetTranscript(recorded, { trustedRoots: [], trustedFiles: [recorded], trustedFileRoot: sessionsBase });
|
|
401
|
+
assert.equal(trusted.events.find((event) => event.kind === "assistant")?.text, "recorded child");
|
|
402
|
+
|
|
403
|
+
const refused = readFleetTranscript(sibling, { trustedRoots: [], trustedFiles: [recorded], trustedFileRoot: sessionsBase });
|
|
404
|
+
assert.deepEqual(refused.events, []);
|
|
405
|
+
assert.match(refused.warning ?? "", /outside trusted roots/);
|
|
406
|
+
|
|
407
|
+
const outside = writeTranscript(outsideBase, [{ recordType: "message", role: "assistant", text: "outside" }]);
|
|
408
|
+
const outsideRefused = readFleetTranscript(outside, { trustedRoots: [], trustedFiles: [outside], trustedFileRoot: sessionsBase });
|
|
409
|
+
assert.deepEqual(outsideRefused.events, []);
|
|
410
|
+
assert.match(outsideRefused.warning ?? "", /outside trusted roots/);
|
|
411
|
+
} finally {
|
|
412
|
+
fs.rmSync(sessionsBase, { recursive: true, force: true });
|
|
413
|
+
fs.rmSync(outsideBase, { recursive: true, force: true });
|
|
414
|
+
}
|
|
415
|
+
});
|
|
416
|
+
|
|
389
417
|
it("sanitizes read-boundary warnings before other Fleet views consume them", () => {
|
|
390
418
|
const trustedRoot = fs.mkdtempSync(path.join(os.tmpdir(), "pi-fleet-warning-trusted-"));
|
|
391
419
|
const outsideRoot = fs.mkdtempSync(path.join(os.tmpdir(), "pi-fleet-warning-outside-"));
|