@selesai/code 0.12.0 → 0.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/dist/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/core/usage-totals.d.ts +2 -0
- package/dist/core/usage-totals.js +10 -0
- package/dist/extensions/ascii.txt +9 -0
- 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-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 -3
- 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 +132 -0
- 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/extensions/pi-zentui/extensions/zentui/format.ts +2 -1
- package/dist/extensions/pi-zentui/test/format.test.ts +15 -1
- package/dist/modes/interactive/components/footer.js +2 -2
- package/dist/modes/interactive/interactive-mode.js +11 -11
- 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
|
@@ -47,6 +47,12 @@ function writeOldResult(resultsDir: string, runId: string, overrides: Record<str
|
|
|
47
47
|
return resultPath;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
+
function errno(code: string): NodeJS.ErrnoException {
|
|
51
|
+
const error = new Error(code) as NodeJS.ErrnoException;
|
|
52
|
+
error.code = code;
|
|
53
|
+
return error;
|
|
54
|
+
}
|
|
55
|
+
|
|
50
56
|
function cleanupOptions(roots: ReturnType<typeof makeRoots>) {
|
|
51
57
|
return {
|
|
52
58
|
...roots,
|
|
@@ -64,6 +70,53 @@ function writeRunTombstoneMarker(roots: ReturnType<typeof makeRoots>, runId: str
|
|
|
64
70
|
}
|
|
65
71
|
|
|
66
72
|
describe("async retention cleanup", () => {
|
|
73
|
+
it("repairs bounded dead running candidates before retention classification", async () => {
|
|
74
|
+
const roots = makeRoots();
|
|
75
|
+
try {
|
|
76
|
+
const runDir = writeOldRun(roots.asyncDirRoot, "dead-running", {
|
|
77
|
+
state: "running",
|
|
78
|
+
endedAt: undefined,
|
|
79
|
+
lastUpdate: OLD,
|
|
80
|
+
pid: 12345,
|
|
81
|
+
sessionId: "session-a",
|
|
82
|
+
steps: [{ agent: "worker", status: "running" }],
|
|
83
|
+
});
|
|
84
|
+
fs.mkdirSync(path.join(roots.asyncDirRoot, ".active-runs"));
|
|
85
|
+
fs.writeFileSync(path.join(roots.asyncDirRoot, ".active-runs", "dead-running"), "");
|
|
86
|
+
const protectedDir = writeOldRun(roots.asyncDirRoot, "protected-running", {
|
|
87
|
+
state: "running",
|
|
88
|
+
endedAt: undefined,
|
|
89
|
+
lastUpdate: OLD,
|
|
90
|
+
pid: 12346,
|
|
91
|
+
steps: [{ agent: "worker", status: "running" }],
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
const repaired = await cleanupAsyncRetention({
|
|
95
|
+
...cleanupOptions(roots),
|
|
96
|
+
protectedRunIds: ["protected-running"],
|
|
97
|
+
reconcileKill: () => { throw errno("ESRCH"); },
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
assert.equal(repaired.repairedRuns, 1);
|
|
101
|
+
assert.equal(repaired.deletedRuns, 0);
|
|
102
|
+
assert.equal(repaired.skipped.recent, 1);
|
|
103
|
+
assert.equal(JSON.parse(fs.readFileSync(path.join(runDir, "status.json"), "utf-8")).state, "failed");
|
|
104
|
+
assert.equal(fs.existsSync(path.join(roots.asyncDirRoot, ".active-runs", "dead-running")), false);
|
|
105
|
+
assert.equal(fs.existsSync(path.join(roots.resultsDir, "dead-running.json")), true);
|
|
106
|
+
assert.equal(JSON.parse(fs.readFileSync(path.join(protectedDir, "status.json"), "utf-8")).state, "running");
|
|
107
|
+
assert.equal(repaired.skipped["runtime-reference"], 1);
|
|
108
|
+
|
|
109
|
+
const retained = await cleanupAsyncRetention({
|
|
110
|
+
...cleanupOptions(roots),
|
|
111
|
+
now: () => NOW + 45 * DAY_MS,
|
|
112
|
+
});
|
|
113
|
+
assert.equal(retained.deletedRuns, 1);
|
|
114
|
+
assert.equal(fs.existsSync(runDir), false);
|
|
115
|
+
} finally {
|
|
116
|
+
fs.rmSync(roots.root, { recursive: true, force: true });
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
|
|
67
120
|
it("deletes old proven-terminal runs and orphan results through tombstones", async () => {
|
|
68
121
|
const roots = makeRoots();
|
|
69
122
|
try {
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { describe, it } from "node:test";
|
|
3
|
+
import type { AsyncJobState, HostStepNodeV1 } from "../../src/shared/types.ts";
|
|
4
|
+
import {
|
|
5
|
+
ASYNC_STATUS_SNAPSHOT_KIND,
|
|
6
|
+
ASYNC_STATUS_SNAPSHOT_VERSION,
|
|
7
|
+
projectAsyncWorkflowRows,
|
|
8
|
+
projectAsyncStatusSnapshot,
|
|
9
|
+
} from "../../src/runs/shared/async-status-projection.ts";
|
|
10
|
+
|
|
11
|
+
function job(input: Partial<AsyncJobState> & Pick<AsyncJobState, "asyncId" | "status">): AsyncJobState {
|
|
12
|
+
return {
|
|
13
|
+
asyncDir: `/tmp/${input.asyncId}`,
|
|
14
|
+
...input,
|
|
15
|
+
} as AsyncJobState;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function hostStep(overrides: Partial<HostStepNodeV1> = {}): HostStepNodeV1 {
|
|
19
|
+
return {
|
|
20
|
+
version: 1,
|
|
21
|
+
kind: "host-step",
|
|
22
|
+
monitorKind: "ci",
|
|
23
|
+
id: "ci-check",
|
|
24
|
+
label: "CI checks",
|
|
25
|
+
provider: "github-ci",
|
|
26
|
+
state: "done",
|
|
27
|
+
verdict: "pass",
|
|
28
|
+
updatedAt: 20,
|
|
29
|
+
...overrides,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
describe("async status projection", () => {
|
|
34
|
+
it("projects already-loaded jobs in deterministic newest-first order", () => {
|
|
35
|
+
const snapshot = projectAsyncStatusSnapshot([
|
|
36
|
+
job({ asyncId: "older", status: "complete", agents: ["reviewer"], updatedAt: 10 }),
|
|
37
|
+
job({
|
|
38
|
+
asyncId: "newer",
|
|
39
|
+
status: "running",
|
|
40
|
+
mode: "workflow",
|
|
41
|
+
agents: ["worker"],
|
|
42
|
+
updatedAt: 20,
|
|
43
|
+
steps: [{ agent: "worker", status: "pending" }],
|
|
44
|
+
}),
|
|
45
|
+
], { generatedAt: 30 });
|
|
46
|
+
|
|
47
|
+
assert.equal(snapshot.kind, ASYNC_STATUS_SNAPSHOT_KIND);
|
|
48
|
+
assert.equal(snapshot.version, ASYNC_STATUS_SNAPSHOT_VERSION);
|
|
49
|
+
assert.equal(snapshot.generatedAt, 30);
|
|
50
|
+
assert.deepEqual(snapshot.runs.map(({ id, kind, state }) => ({ id, kind, state })), [
|
|
51
|
+
{ id: "newer", kind: "workflow", state: "running" },
|
|
52
|
+
{ id: "older", kind: "subagent", state: "complete" },
|
|
53
|
+
]);
|
|
54
|
+
assert.equal(snapshot.runs[0]?.children?.[0]?.state, "queued");
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it("preserves partial needs-attention status while excluding private evidence", () => {
|
|
58
|
+
const snapshot = projectAsyncStatusSnapshot([job({
|
|
59
|
+
asyncId: "partial-run",
|
|
60
|
+
status: "partial",
|
|
61
|
+
agents: ["writer"],
|
|
62
|
+
activityState: "needs_attention",
|
|
63
|
+
steps: [{
|
|
64
|
+
agent: "writer",
|
|
65
|
+
status: "partial",
|
|
66
|
+
activityState: "needs_attention",
|
|
67
|
+
error: "Required file-only output was not produced: /private/report.md",
|
|
68
|
+
effects: { fileMutation: true },
|
|
69
|
+
}],
|
|
70
|
+
})], { generatedAt: 1 });
|
|
71
|
+
|
|
72
|
+
assert.equal(snapshot.runs[0]?.state, "partial");
|
|
73
|
+
assert.equal(snapshot.runs[0]?.activity?.state, "needs_attention");
|
|
74
|
+
assert.equal(snapshot.runs[0]?.children?.[0]?.state, "partial");
|
|
75
|
+
assert.equal(snapshot.runs[0]?.children?.[0]?.activity?.state, "needs_attention");
|
|
76
|
+
const serialized = JSON.stringify(snapshot);
|
|
77
|
+
assert.doesNotMatch(serialized, /private\/report|fileMutation|Required file-only output/);
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
it("projects compact Fleet workflow rows without applying UI bounds", () => {
|
|
81
|
+
const rows = projectAsyncWorkflowRows([{
|
|
82
|
+
agent: "reviewer",
|
|
83
|
+
workflowKey: "review",
|
|
84
|
+
label: "Fresh review",
|
|
85
|
+
phase: "quality",
|
|
86
|
+
status: "partial",
|
|
87
|
+
activityState: "needs_attention",
|
|
88
|
+
startedAt: 10,
|
|
89
|
+
tokens: { input: 20, output: 5, total: 25, window: 18 },
|
|
90
|
+
}]);
|
|
91
|
+
|
|
92
|
+
assert.deepEqual(rows, [{
|
|
93
|
+
name: "quality: review · Fresh review (reviewer)",
|
|
94
|
+
state: "partial",
|
|
95
|
+
activity: "needs attention",
|
|
96
|
+
startedAt: 10,
|
|
97
|
+
tokens: 25,
|
|
98
|
+
window: 18,
|
|
99
|
+
}]);
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it("projects typed CI and gate host rows without treating them as child agents", () => {
|
|
103
|
+
const rows = projectAsyncWorkflowRows([], {
|
|
104
|
+
runId: "workflow-1",
|
|
105
|
+
mode: "workflow",
|
|
106
|
+
phases: [],
|
|
107
|
+
nodes: [
|
|
108
|
+
{ id: "ci-check", kind: "host-step", label: "CI checks", status: "completed", hostStep: hostStep() },
|
|
109
|
+
{ id: "review-gate", kind: "host-step", label: "Review gate", status: "completed", hostStep: hostStep({ id: "review-gate", monitorKind: "gate", label: "Review gate", verdict: "inconclusive", reasonCode: "stale-head", detail: "head changed", target: "PR #1614", freshness: { expectedRef: "old-head", observedRef: "new-head", stale: true }, reportPath: "/tmp/reports/gate.json" }) },
|
|
110
|
+
],
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
assert.deepEqual(rows, [
|
|
114
|
+
{ name: "CI checks", kind: "ci", state: "done", provider: "github-ci", verdict: "pass" },
|
|
115
|
+
{ name: "Review gate", kind: "gate", state: "done", provider: "github-ci", verdict: "inconclusive", reasonCode: "stale-head", detail: "head changed", target: "PR #1614", freshness: { expectedRef: "old-head", observedRef: "new-head", stale: true }, reportPath: "gate.json" },
|
|
116
|
+
]);
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
it("projects done host steps without verdicts as partial", () => {
|
|
120
|
+
const snapshot = projectAsyncStatusSnapshot([job({
|
|
121
|
+
asyncId: "inconclusive-gate",
|
|
122
|
+
status: "running",
|
|
123
|
+
hostSteps: [hostStep({ verdict: undefined })],
|
|
124
|
+
})]);
|
|
125
|
+
|
|
126
|
+
assert.equal(snapshot.runs[0]?.children?.[0]?.state, "partial");
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
it("reserves bounded snapshot capacity for host steps", () => {
|
|
130
|
+
const snapshot = projectAsyncStatusSnapshot([job({
|
|
131
|
+
asyncId: "bounded-gate",
|
|
132
|
+
status: "running",
|
|
133
|
+
steps: [
|
|
134
|
+
{ agent: "first", status: "running" },
|
|
135
|
+
{ agent: "second", status: "running" },
|
|
136
|
+
],
|
|
137
|
+
hostSteps: [hostStep()],
|
|
138
|
+
})], { maxChildrenPerNode: 2 });
|
|
139
|
+
|
|
140
|
+
assert.deepEqual(snapshot.runs[0]?.children?.map(({ kind, id }) => ({ kind, id })), [
|
|
141
|
+
{ kind: "step", id: "step:0" },
|
|
142
|
+
{ kind: "host-step", id: "ci-check" },
|
|
143
|
+
]);
|
|
144
|
+
assert.equal(snapshot.omitted.children, 1);
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
it("omits malformed host nodes instead of rendering them as agents", () => {
|
|
148
|
+
const rows = projectAsyncWorkflowRows([], {
|
|
149
|
+
runId: "workflow-1",
|
|
150
|
+
mode: "workflow",
|
|
151
|
+
phases: [],
|
|
152
|
+
nodes: [{ id: "bad", kind: "host-step", label: "bad", status: "running" }],
|
|
153
|
+
});
|
|
154
|
+
assert.deepEqual(rows, []);
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
it("projects stored preflight lanes as planned rows and merges launched facts", () => {
|
|
158
|
+
const rows = projectAsyncWorkflowRows([
|
|
159
|
+
{ agent: "worker", workflowKey: "writer", label: "Writer", status: "running" },
|
|
160
|
+
], {
|
|
161
|
+
version: 1,
|
|
162
|
+
coverage: "complete",
|
|
163
|
+
lanes: [
|
|
164
|
+
{ key: "writer", mode: "mutation", claims: ["src/a.ts"] },
|
|
165
|
+
{ key: "review", mode: "review", expectedOutput: "review.md" },
|
|
166
|
+
],
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
assert.deepEqual(rows.map((row) => ({ name: row.name, state: row.state, mode: row.preflight?.mode })), [
|
|
170
|
+
{ name: "writer · Writer (worker)", state: "running", mode: "mutation" },
|
|
171
|
+
{ name: "review", state: "planned", mode: "review" },
|
|
172
|
+
]);
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
it("preserves duplicate loaded rows when a declared lane key is reused", () => {
|
|
176
|
+
const rows = projectAsyncWorkflowRows([
|
|
177
|
+
{ agent: "worker", workflowKey: "writer", label: "First", status: "complete" },
|
|
178
|
+
{ agent: "worker", workflowKey: "writer", label: "Second", status: "running" },
|
|
179
|
+
], {
|
|
180
|
+
version: 1,
|
|
181
|
+
coverage: "partial",
|
|
182
|
+
lanes: [{ key: "writer", mode: "mutation" }],
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
assert.deepEqual(rows.map((row) => ({ name: row.name, state: row.state })), [
|
|
186
|
+
{ name: "writer · First (worker)", state: "complete" },
|
|
187
|
+
{ name: "writer · Second (worker)", state: "running" },
|
|
188
|
+
]);
|
|
189
|
+
});
|
|
190
|
+
});
|
|
@@ -88,6 +88,48 @@ describe("async status snapshot", () => {
|
|
|
88
88
|
assert.equal(snapshot.runs[0]?.children?.[0]?.state, "queued");
|
|
89
89
|
});
|
|
90
90
|
|
|
91
|
+
it("projects loaded host CI/gate nodes with bounded provider-neutral metadata", () => {
|
|
92
|
+
const snapshot = buildAsyncStatusSnapshot([{
|
|
93
|
+
asyncId: "workflow-1",
|
|
94
|
+
asyncDir: "/tmp/workflow-1",
|
|
95
|
+
status: "running",
|
|
96
|
+
mode: "workflow",
|
|
97
|
+
agents: [],
|
|
98
|
+
hostSteps: [{
|
|
99
|
+
version: 1,
|
|
100
|
+
kind: "host-step",
|
|
101
|
+
monitorKind: "gate",
|
|
102
|
+
id: "gate-1",
|
|
103
|
+
label: "Gate",
|
|
104
|
+
provider: "opaque-provider",
|
|
105
|
+
state: "done",
|
|
106
|
+
verdict: "inconclusive",
|
|
107
|
+
reasonCode: "stale-head",
|
|
108
|
+
freshness: { expectedRef: "old", observedRef: "new", stale: true },
|
|
109
|
+
reportPath: "/private/reports/gate.json",
|
|
110
|
+
updatedAt: 100,
|
|
111
|
+
}],
|
|
112
|
+
}] as any, { generatedAt: 200 });
|
|
113
|
+
|
|
114
|
+
assert.deepEqual(snapshot.runs[0]?.children, [{
|
|
115
|
+
id: "gate-1",
|
|
116
|
+
kind: "host-step",
|
|
117
|
+
label: "Gate",
|
|
118
|
+
state: "partial",
|
|
119
|
+
updatedAt: 100,
|
|
120
|
+
endedAt: 100,
|
|
121
|
+
hostStep: {
|
|
122
|
+
kind: "gate",
|
|
123
|
+
provider: "opaque-provider",
|
|
124
|
+
state: "done",
|
|
125
|
+
verdict: "inconclusive",
|
|
126
|
+
reasonCode: "stale-head",
|
|
127
|
+
stale: true,
|
|
128
|
+
report: "gate.json",
|
|
129
|
+
},
|
|
130
|
+
}]);
|
|
131
|
+
});
|
|
132
|
+
|
|
91
133
|
it("applies run, child, depth, string, and byte caps", () => {
|
|
92
134
|
const jobs = Array.from({ length: 5 }, (_, runIndex) => ({
|
|
93
135
|
asyncId: `run-${runIndex}`,
|
|
@@ -7,11 +7,15 @@ function state(sessionId: string | null = "session-a"): SubagentState {
|
|
|
7
7
|
return { currentSessionId: sessionId } as SubagentState;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
function waitResult(text: string, isError = false) {
|
|
10
|
+
function waitResult(text: string, isError = false, windowElapsed = false) {
|
|
11
11
|
return {
|
|
12
12
|
content: [{ type: "text" as const, text }],
|
|
13
13
|
...(isError ? { isError: true } : {}),
|
|
14
|
-
details: {
|
|
14
|
+
details: {
|
|
15
|
+
mode: "management" as const,
|
|
16
|
+
results: [],
|
|
17
|
+
...(windowElapsed ? { wait: { reason: "window_elapsed" as const, timedOut: true as const, activeRunIds: ["run-a"], activeProviderItems: [] } } : {}),
|
|
18
|
+
} satisfies Details,
|
|
15
19
|
};
|
|
16
20
|
}
|
|
17
21
|
|
|
@@ -59,7 +63,7 @@ describe("headless background-work auto-drain", () => {
|
|
|
59
63
|
}), /provider reconcile failed/);
|
|
60
64
|
});
|
|
61
65
|
|
|
62
|
-
it("
|
|
66
|
+
it("keeps its absolute deadline strict after a non-error wait window elapses", async () => {
|
|
63
67
|
let clock = 0;
|
|
64
68
|
await assert.rejects(() => drainOutstandingWork({
|
|
65
69
|
state: state(),
|
|
@@ -68,7 +72,7 @@ describe("headless background-work auto-drain", () => {
|
|
|
68
72
|
hasWork: () => true,
|
|
69
73
|
wait: async () => {
|
|
70
74
|
clock = 101;
|
|
71
|
-
return waitResult("
|
|
75
|
+
return waitResult("Wait window elapsed; work remains active.", false, true);
|
|
72
76
|
},
|
|
73
77
|
}), /timed out after 100ms.*session 'session-a'/);
|
|
74
78
|
});
|
|
@@ -127,6 +127,29 @@ describe("background-work provider protocol", () => {
|
|
|
127
127
|
assert.throws(() => snapshotBackgroundWork("session-a"), /duplicate item 'job'/);
|
|
128
128
|
});
|
|
129
129
|
|
|
130
|
+
it("accepts path-like session ids up to the bound and rejects longer ids", () => {
|
|
131
|
+
const longSessionId = `${"/nested/".repeat(511)}xsession`;
|
|
132
|
+
const overBoundSessionId = `${longSessionId}x`;
|
|
133
|
+
assert.equal(longSessionId.length, 4_096);
|
|
134
|
+
|
|
135
|
+
registerBackgroundWorkProvider({
|
|
136
|
+
name: "patty",
|
|
137
|
+
listActiveWork: () => [{ id: "job", sessionId: longSessionId }],
|
|
138
|
+
});
|
|
139
|
+
assert.deepEqual(snapshotBackgroundWork(longSessionId), {
|
|
140
|
+
providers: ["patty"],
|
|
141
|
+
items: [{ provider: "patty", id: "job", sessionId: longSessionId }],
|
|
142
|
+
});
|
|
143
|
+
assert.throws(() => snapshotBackgroundWork(overBoundSessionId), /at most 4096 characters/);
|
|
144
|
+
|
|
145
|
+
clearRegistry();
|
|
146
|
+
registerBackgroundWorkProvider({
|
|
147
|
+
name: "patty",
|
|
148
|
+
listActiveWork: () => [{ id: "job", sessionId: overBoundSessionId }],
|
|
149
|
+
});
|
|
150
|
+
assert.throws(() => snapshotBackgroundWork("session-a"), /at most 4096 characters/);
|
|
151
|
+
});
|
|
152
|
+
|
|
130
153
|
it("preserves list and reconcile errors with provider context", () => {
|
|
131
154
|
registerBackgroundWorkProvider({
|
|
132
155
|
name: "broken-reconcile",
|
|
@@ -3,6 +3,7 @@ import * as fs from "node:fs";
|
|
|
3
3
|
import * as os from "node:os";
|
|
4
4
|
import * as path from "node:path";
|
|
5
5
|
import { afterEach, beforeEach, describe, it } from "node:test";
|
|
6
|
+
import { writePendingAsyncResultFile } from "../../src/runs/background/result-files.ts";
|
|
6
7
|
import { waitForImportedAsyncRoot } from "../../src/runs/background/chain-root-attachment.ts";
|
|
7
8
|
|
|
8
9
|
let tempDir: string;
|
|
@@ -44,7 +45,7 @@ describe("async chain root attachment", () => {
|
|
|
44
45
|
writeJson(importedRoot.resultPath, {
|
|
45
46
|
state: "complete",
|
|
46
47
|
success: true,
|
|
47
|
-
|
|
48
|
+
results: [{ agent: "worker", output: "root output", success: true, sessionFile, usage: { input: 100, output: 50, cacheRead: 0, cacheWrite: 0, cost: 0.001, turns: 1 } }],
|
|
48
49
|
});
|
|
49
50
|
|
|
50
51
|
const result = await waitForImportedAsyncRoot(importedRoot, { pollIntervalMs: 1 });
|
|
@@ -54,14 +55,41 @@ describe("async chain root attachment", () => {
|
|
|
54
55
|
output: result.output,
|
|
55
56
|
exitCode: result.exitCode,
|
|
56
57
|
sessionFile: result.sessionFile,
|
|
58
|
+
usage: result.usage,
|
|
57
59
|
}, {
|
|
58
60
|
agent: "worker",
|
|
59
61
|
output: "root output",
|
|
60
62
|
exitCode: 0,
|
|
61
63
|
sessionFile,
|
|
64
|
+
usage: { input: 100, output: 50, cacheRead: 0, cacheWrite: 0, cost: 0.001, turns: 1 },
|
|
62
65
|
});
|
|
63
66
|
});
|
|
64
67
|
|
|
68
|
+
it("imports a session-indexed pending result before terminal status fallback", async () => {
|
|
69
|
+
const importedRoot = { ...root(), resultPath: path.join(tempDir, "root-run", "workflow-result.json") };
|
|
70
|
+
writeJson(path.join(importedRoot.asyncDir, "status.json"), {
|
|
71
|
+
runId: importedRoot.runId,
|
|
72
|
+
mode: "single",
|
|
73
|
+
state: "complete",
|
|
74
|
+
sessionId: "session-a",
|
|
75
|
+
startedAt: 1,
|
|
76
|
+
steps: [{ agent: "worker", status: "complete" }],
|
|
77
|
+
});
|
|
78
|
+
writePendingAsyncResultFile(importedRoot.resultPath, {
|
|
79
|
+
id: importedRoot.runId,
|
|
80
|
+
runId: importedRoot.runId,
|
|
81
|
+
sessionId: "session-a",
|
|
82
|
+
state: "complete",
|
|
83
|
+
success: true,
|
|
84
|
+
results: [{ agent: "worker", output: "pending root output", success: true }],
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
const result = await waitForImportedAsyncRoot(importedRoot, { pollIntervalMs: 1, terminalResultGraceMs: 0 });
|
|
88
|
+
|
|
89
|
+
assert.equal(result.output, "pending root output");
|
|
90
|
+
assert.equal(result.exitCode, 0);
|
|
91
|
+
});
|
|
92
|
+
|
|
65
93
|
it("waits for a running async child to write its terminal result", async () => {
|
|
66
94
|
const importedRoot = root();
|
|
67
95
|
writeJson(path.join(importedRoot.asyncDir, "status.json"), {
|
|
@@ -111,6 +139,55 @@ describe("async chain root attachment", () => {
|
|
|
111
139
|
assert.equal(result.output, "root failed");
|
|
112
140
|
});
|
|
113
141
|
|
|
142
|
+
it("imports a partial root without collapsing it to failed", async () => {
|
|
143
|
+
const importedRoot = root();
|
|
144
|
+
writeJson(path.join(importedRoot.asyncDir, "status.json"), {
|
|
145
|
+
runId: importedRoot.runId,
|
|
146
|
+
mode: "single",
|
|
147
|
+
state: "partial",
|
|
148
|
+
activityState: "needs_attention",
|
|
149
|
+
startedAt: 1,
|
|
150
|
+
error: "Required file-only output was not produced: report.md",
|
|
151
|
+
steps: [{ agent: "worker", status: "failed", activityState: "needs_attention", error: "Required file-only output was not produced: report.md" }],
|
|
152
|
+
});
|
|
153
|
+
writeJson(importedRoot.resultPath, {
|
|
154
|
+
state: "partial",
|
|
155
|
+
success: false,
|
|
156
|
+
summary: "Required file-only output was not produced: report.md",
|
|
157
|
+
results: [{ agent: "worker", output: "Required file-only output was not produced: report.md", error: "Required file-only output was not produced: report.md", success: false, effects: { fileMutation: { status: "observed", expected: true, attempted: true, evidence: { source: "tracked-files", trackedOnly: true, cwd: tempDir, changedFiles: ["input.md"], attemptedMutation: true } } } }],
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
const result = await waitForImportedAsyncRoot(importedRoot, { pollIntervalMs: 1 });
|
|
161
|
+
|
|
162
|
+
assert.equal(result.exitCode, 1);
|
|
163
|
+
assert.equal(result.error, "Required file-only output was not produced: report.md");
|
|
164
|
+
assert.equal(result.execution?.status, "partial");
|
|
165
|
+
assert.deepEqual(result.effects?.fileMutation?.evidence?.changedFiles, ["input.md"]);
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
it("fails a partial root that never produced a result file", async () => {
|
|
169
|
+
const importedRoot = root();
|
|
170
|
+
const effects = { fileMutation: { status: "observed", expected: true, attempted: true, evidence: { source: "tracked-files", trackedOnly: true, cwd: tempDir, changedFiles: ["input.md"], attemptedMutation: true } } };
|
|
171
|
+
writeJson(path.join(importedRoot.asyncDir, "status.json"), {
|
|
172
|
+
runId: importedRoot.runId,
|
|
173
|
+
mode: "single",
|
|
174
|
+
state: "partial",
|
|
175
|
+
startedAt: 1,
|
|
176
|
+
error: "Required file-only output was not produced: report.md",
|
|
177
|
+
steps: [{ agent: "worker", status: "failed", activityState: "needs_attention", error: "Required file-only output was not produced: report.md", effects }],
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
const result = await waitForImportedAsyncRoot(importedRoot, {
|
|
181
|
+
pollIntervalMs: 1,
|
|
182
|
+
terminalResultGraceMs: 0,
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
assert.equal(result.exitCode, 1);
|
|
186
|
+
assert.equal(result.error, "Required file-only output was not produced: report.md");
|
|
187
|
+
assert.equal(result.execution?.status, "partial");
|
|
188
|
+
assert.deepEqual(result.effects?.fileMutation?.evidence?.changedFiles, ["input.md"]);
|
|
189
|
+
});
|
|
190
|
+
|
|
114
191
|
it("fails a terminal root that never produced a result file", async () => {
|
|
115
192
|
const importedRoot = root();
|
|
116
193
|
writeJson(path.join(importedRoot.asyncDir, "status.json"), {
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import * as path from "node:path";
|
|
3
|
+
import { describe, it } from "node:test";
|
|
4
|
+
import type { AgentConfig } from "../../src/agents/agents.ts";
|
|
5
|
+
import { planChildLaunch, resolveStepBehavior } from "../../src/runs/shared/child-launch-plan.ts";
|
|
6
|
+
|
|
7
|
+
const agent = {
|
|
8
|
+
name: "worker",
|
|
9
|
+
output: "report.md",
|
|
10
|
+
outputMode: "file-only",
|
|
11
|
+
defaultReads: ["brief.md"],
|
|
12
|
+
defaultProgress: true,
|
|
13
|
+
skills: ["typescript"],
|
|
14
|
+
model: "openai-codex/gpt-5.6-luna",
|
|
15
|
+
fast: true,
|
|
16
|
+
} as AgentConfig;
|
|
17
|
+
|
|
18
|
+
describe("child launch planning", () => {
|
|
19
|
+
it("resolves cwd, behavior, skills, model, and output path without side effects", () => {
|
|
20
|
+
const runnerCwd = path.join("/tmp", "repo");
|
|
21
|
+
const resolvedRunnerCwd = path.resolve(runnerCwd);
|
|
22
|
+
const plan = planChildLaunch({
|
|
23
|
+
agentConfig: agent,
|
|
24
|
+
stepOverrides: { skills: ["review"], outputMode: "inline" },
|
|
25
|
+
task: "Implement the change",
|
|
26
|
+
runnerCwd,
|
|
27
|
+
runtimeCwd: runnerCwd,
|
|
28
|
+
stepCwdInput: "packages/cli",
|
|
29
|
+
chainSkills: ["shared"],
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
assert.equal(plan.stepCwd, path.join(resolvedRunnerCwd, "packages/cli"));
|
|
33
|
+
assert.equal(plan.instructionCwd, plan.stepCwd);
|
|
34
|
+
assert.equal(plan.readExistenceCwd, plan.stepCwd);
|
|
35
|
+
assert.equal(plan.outputPath, path.join(resolvedRunnerCwd, "packages/cli", "report.md"));
|
|
36
|
+
assert.deepEqual(plan.skillNames, ["review", "shared"]);
|
|
37
|
+
assert.deepEqual(plan.behavior, {
|
|
38
|
+
output: "report.md",
|
|
39
|
+
outputMode: "inline",
|
|
40
|
+
reads: ["brief.md"],
|
|
41
|
+
progress: true,
|
|
42
|
+
skills: ["review", "shared"],
|
|
43
|
+
model: "openai-codex/gpt-5.6-luna",
|
|
44
|
+
fast: true,
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it("keeps dynamic namespace output unresolved until fanout items materialize", () => {
|
|
49
|
+
const runnerCwd = path.join("/tmp", "repo");
|
|
50
|
+
const resolvedRunnerCwd = path.resolve(runnerCwd);
|
|
51
|
+
const plan = planChildLaunch({
|
|
52
|
+
agentConfig: agent,
|
|
53
|
+
stepOverrides: {},
|
|
54
|
+
runnerCwd,
|
|
55
|
+
runtimeCwd: runnerCwd,
|
|
56
|
+
parallelOutputNamespace: { stepIndex: 2 },
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
assert.equal(plan.namespaceOutputPath, true);
|
|
60
|
+
assert.equal(plan.behavior.output, "report.md");
|
|
61
|
+
assert.equal(plan.outputPath, path.join(resolvedRunnerCwd, "report.md"));
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it("namespaces inherited relative parallel output for concrete items", () => {
|
|
65
|
+
const runnerCwd = path.join("/tmp", "repo");
|
|
66
|
+
const resolvedRunnerCwd = path.resolve(runnerCwd);
|
|
67
|
+
const plan = planChildLaunch({
|
|
68
|
+
agentConfig: agent,
|
|
69
|
+
stepOverrides: {},
|
|
70
|
+
runnerCwd,
|
|
71
|
+
runtimeCwd: runnerCwd,
|
|
72
|
+
parallelOutputNamespace: { stepIndex: 2, taskIndex: 4 },
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
assert.equal(plan.namespaceOutputPath, false);
|
|
76
|
+
assert.equal(plan.behavior.output, path.join("parallel-2", "4-worker", "report.md"));
|
|
77
|
+
assert.equal(plan.outputPath, path.join(resolvedRunnerCwd, "parallel-2", "4-worker", "report.md"));
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
it("suppresses progress for read-only templated tasks", () => {
|
|
81
|
+
const behavior = resolveStepBehavior(agent, {});
|
|
82
|
+
const plan = planChildLaunch({
|
|
83
|
+
agentConfig: agent,
|
|
84
|
+
stepOverrides: {},
|
|
85
|
+
resolvedBehavior: behavior,
|
|
86
|
+
task: "{task}",
|
|
87
|
+
originalTask: "Review-only. Do not edit files.",
|
|
88
|
+
runnerCwd: "/tmp/repo",
|
|
89
|
+
runtimeCwd: "/tmp/repo",
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
assert.equal(plan.behavior.progress, false);
|
|
93
|
+
});
|
|
94
|
+
});
|
|
@@ -76,6 +76,19 @@ describe("bounded child protocol reader", () => {
|
|
|
76
76
|
}
|
|
77
77
|
});
|
|
78
78
|
|
|
79
|
+
it("projects oversized compaction_end aggregates without losing retry lifecycle metadata", () => {
|
|
80
|
+
const lines: string[] = [];
|
|
81
|
+
const reader = createBoundedLineReader({
|
|
82
|
+
maxPendingLineBytes: 64,
|
|
83
|
+
oversizedLineProjector: PI_AGGREGATE_EVENT_PROJECTOR,
|
|
84
|
+
onLine: (line) => lines.push(line),
|
|
85
|
+
onLimit: () => assert.fail("valid compaction_end aggregate must not fail"),
|
|
86
|
+
});
|
|
87
|
+
reader.push(`${JSON.stringify({ type: "compaction_end", result: { summary: "x".repeat(256) }, willRetry: true })}\n`);
|
|
88
|
+
reader.end();
|
|
89
|
+
assert.deepEqual(lines.map((line) => JSON.parse(line)), [{ type: "compaction_end", willRetry: true }]);
|
|
90
|
+
});
|
|
91
|
+
|
|
79
92
|
it("fails closed when an oversized agent_end aggregate lacks lifecycle metadata", () => {
|
|
80
93
|
let failure: ProtocolOutputLimit | undefined;
|
|
81
94
|
const reader = createBoundedLineReader({
|
|
@@ -178,4 +191,12 @@ describe("child lifecycle projection", () => {
|
|
|
178
191
|
assert.equal(projectChildLifecycle({ type: "agent_settled" }), "start-drain");
|
|
179
192
|
assert.equal(projectChildLifecycle({ type: "tool_execution_start" }), "none");
|
|
180
193
|
});
|
|
194
|
+
|
|
195
|
+
it("ignores settlement from a compaction attempt that will retry", () => {
|
|
196
|
+
const state = { compactionRetryActive: false };
|
|
197
|
+
assert.equal(projectChildLifecycle({ type: "compaction_end", willRetry: true }, false, state), "cancel-drain");
|
|
198
|
+
assert.equal(projectChildLifecycle({ type: "agent_settled" }, false, state), "none");
|
|
199
|
+
assert.equal(projectChildLifecycle({ type: "agent_start" }, false, state), "none");
|
|
200
|
+
assert.equal(projectChildLifecycle({ type: "agent_settled" }, false, state), "start-drain");
|
|
201
|
+
});
|
|
181
202
|
});
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { describe, it } from "node:test";
|
|
3
|
+
import {
|
|
4
|
+
CHILD_SESSION_NAME_MAX_CHARS,
|
|
5
|
+
deriveChildSessionName,
|
|
6
|
+
} from "../../src/shared/child-session-name.ts";
|
|
7
|
+
import { PROMPT_REDACTED } from "../../src/shared/utils.ts";
|
|
8
|
+
|
|
9
|
+
describe("deriveChildSessionName", () => {
|
|
10
|
+
it("combines agent and task excerpt", () => {
|
|
11
|
+
assert.equal(
|
|
12
|
+
deriveChildSessionName({ agent: "reviewer", task: "Review the diff since main" }),
|
|
13
|
+
"reviewer: Review the diff since main",
|
|
14
|
+
);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it("prefers a workflow label over the task", () => {
|
|
18
|
+
assert.equal(
|
|
19
|
+
deriveChildSessionName({ agent: "scout", label: "find-callers", task: "ignored task text" }),
|
|
20
|
+
"scout: find-callers",
|
|
21
|
+
);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it("falls back to the bare agent when no task or label is usable", () => {
|
|
25
|
+
assert.equal(deriveChildSessionName({ agent: "worker" }), "worker");
|
|
26
|
+
assert.equal(deriveChildSessionName({ agent: "worker", task: " " }), "worker");
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it("never builds a name from a redacted prompt", () => {
|
|
30
|
+
assert.equal(deriveChildSessionName({ agent: "worker", task: PROMPT_REDACTED }), "worker");
|
|
31
|
+
assert.equal(deriveChildSessionName({ task: PROMPT_REDACTED }), undefined);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it("collapses newlines and control characters into a single line", () => {
|
|
35
|
+
const name = deriveChildSessionName({ agent: "scout", task: "line one\nline two" });
|
|
36
|
+
assert.equal(name, "scout: line one line two");
|
|
37
|
+
assert.doesNotMatch(name!, /[\n]/);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it("caps the final name at CHILD_SESSION_NAME_MAX_CHARS", () => {
|
|
41
|
+
const name = deriveChildSessionName({ agent: "worker", task: "x".repeat(500) });
|
|
42
|
+
assert.ok(name);
|
|
43
|
+
assert.ok(name.length <= CHILD_SESSION_NAME_MAX_CHARS);
|
|
44
|
+
assert.ok(name.endsWith("..."));
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it("returns undefined when there is nothing to name", () => {
|
|
48
|
+
assert.equal(deriveChildSessionName({}), undefined);
|
|
49
|
+
});
|
|
50
|
+
});
|