opencastle 1.3.1 → 1.4.0
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/README.md +16 -10
- package/bin/cli.mjs +8 -9
- package/dist/cli/agent-roster.test.js +0 -48
- package/dist/cli/agent-roster.test.js.map +1 -1
- package/dist/cli/boundary.test.js +9 -7
- package/dist/cli/boundary.test.js.map +1 -1
- package/dist/cli/convoy/artifacts.d.ts +9 -2
- package/dist/cli/convoy/artifacts.d.ts.map +1 -1
- package/dist/cli/convoy/artifacts.js +13 -10
- package/dist/cli/convoy/artifacts.js.map +1 -1
- package/dist/cli/convoy/artifacts.test.js +4 -2
- package/dist/cli/convoy/artifacts.test.js.map +1 -1
- package/dist/cli/convoy/engine.d.ts +53 -23
- package/dist/cli/convoy/engine.d.ts.map +1 -1
- package/dist/cli/convoy/engine.git.test.d.ts +2 -0
- package/dist/cli/convoy/engine.git.test.d.ts.map +1 -0
- package/dist/cli/convoy/engine.git.test.js +435 -0
- package/dist/cli/convoy/engine.git.test.js.map +1 -0
- package/dist/cli/convoy/engine.js +1746 -2305
- package/dist/cli/convoy/engine.js.map +1 -1
- package/dist/cli/convoy/engine.test.js +698 -678
- package/dist/cli/convoy/engine.test.js.map +1 -1
- package/dist/cli/convoy/event-schemas.d.ts +2 -0
- package/dist/cli/convoy/event-schemas.d.ts.map +1 -1
- package/dist/cli/convoy/event-schemas.js +59 -57
- package/dist/cli/convoy/event-schemas.js.map +1 -1
- package/dist/cli/convoy/events.d.ts +4 -1
- package/dist/cli/convoy/events.d.ts.map +1 -1
- package/dist/cli/convoy/events.js +69 -84
- package/dist/cli/convoy/events.js.map +1 -1
- package/dist/cli/convoy/events.test.js +50 -9
- package/dist/cli/convoy/events.test.js.map +1 -1
- package/dist/cli/convoy/gates.d.ts +9 -4
- package/dist/cli/convoy/gates.d.ts.map +1 -1
- package/dist/cli/convoy/gates.js +29 -14
- package/dist/cli/convoy/gates.js.map +1 -1
- package/dist/cli/convoy/isolation.d.ts +32 -6
- package/dist/cli/convoy/isolation.d.ts.map +1 -1
- package/dist/cli/convoy/isolation.js +72 -34
- package/dist/cli/convoy/isolation.js.map +1 -1
- package/dist/cli/convoy/isolation.test.js +66 -42
- package/dist/cli/convoy/isolation.test.js.map +1 -1
- package/dist/cli/convoy/lock.d.ts.map +1 -1
- package/dist/cli/convoy/lock.js +25 -10
- package/dist/cli/convoy/lock.js.map +1 -1
- package/dist/cli/convoy/lock.test.js +12 -0
- package/dist/cli/convoy/lock.test.js.map +1 -1
- package/dist/cli/convoy/merge.d.ts +21 -4
- package/dist/cli/convoy/merge.d.ts.map +1 -1
- package/dist/cli/convoy/merge.js +69 -53
- package/dist/cli/convoy/merge.js.map +1 -1
- package/dist/cli/convoy/merge.test.js +23 -1
- package/dist/cli/convoy/merge.test.js.map +1 -1
- package/dist/cli/convoy/progress.d.ts +35 -0
- package/dist/cli/convoy/progress.d.ts.map +1 -0
- package/dist/cli/convoy/progress.js +103 -0
- package/dist/cli/convoy/progress.js.map +1 -0
- package/dist/cli/convoy/progress.test.d.ts +2 -0
- package/dist/cli/convoy/progress.test.d.ts.map +1 -0
- package/dist/cli/convoy/progress.test.js +53 -0
- package/dist/cli/convoy/progress.test.js.map +1 -0
- package/dist/cli/convoy/read-model.d.ts +468 -0
- package/dist/cli/convoy/read-model.d.ts.map +1 -0
- package/dist/cli/convoy/read-model.js +1132 -0
- package/dist/cli/convoy/read-model.js.map +1 -0
- package/dist/cli/convoy/read-model.test.d.ts +2 -0
- package/dist/cli/convoy/read-model.test.d.ts.map +1 -0
- package/dist/cli/convoy/read-model.test.js +609 -0
- package/dist/cli/convoy/read-model.test.js.map +1 -0
- package/dist/cli/convoy/redact.d.ts +34 -0
- package/dist/cli/convoy/redact.d.ts.map +1 -0
- package/dist/cli/convoy/redact.js +66 -0
- package/dist/cli/convoy/redact.js.map +1 -0
- package/dist/cli/convoy/redact.test.d.ts +2 -0
- package/dist/cli/convoy/redact.test.d.ts.map +1 -0
- package/dist/cli/convoy/redact.test.js +43 -0
- package/dist/cli/convoy/redact.test.js.map +1 -0
- package/dist/cli/convoy/reviewer.d.ts +65 -0
- package/dist/cli/convoy/reviewer.d.ts.map +1 -0
- package/dist/cli/convoy/reviewer.js +141 -0
- package/dist/cli/convoy/reviewer.js.map +1 -0
- package/dist/cli/convoy/reviewer.test.d.ts +2 -0
- package/dist/cli/convoy/reviewer.test.d.ts.map +1 -0
- package/dist/cli/convoy/reviewer.test.js +96 -0
- package/dist/cli/convoy/reviewer.test.js.map +1 -0
- package/dist/cli/convoy/schedule.d.ts +30 -0
- package/dist/cli/convoy/schedule.d.ts.map +1 -0
- package/dist/cli/convoy/schedule.js +111 -0
- package/dist/cli/convoy/schedule.js.map +1 -0
- package/dist/cli/convoy/schedule.test.d.ts +2 -0
- package/dist/cli/convoy/schedule.test.d.ts.map +1 -0
- package/dist/cli/convoy/schedule.test.js +45 -0
- package/dist/cli/convoy/schedule.test.js.map +1 -0
- package/dist/cli/convoy/spec-builder.d.ts +120 -30
- package/dist/cli/convoy/spec-builder.d.ts.map +1 -1
- package/dist/cli/convoy/spec-builder.js +438 -114
- package/dist/cli/convoy/spec-builder.js.map +1 -1
- package/dist/cli/convoy/spec-builder.test.js +419 -435
- package/dist/cli/convoy/spec-builder.test.js.map +1 -1
- package/dist/cli/convoy/spec-types.d.ts +46 -92
- package/dist/cli/convoy/spec-types.d.ts.map +1 -1
- package/dist/cli/convoy/store.d.ts +6 -1
- package/dist/cli/convoy/store.d.ts.map +1 -1
- package/dist/cli/convoy/store.js +111 -15
- package/dist/cli/convoy/store.js.map +1 -1
- package/dist/cli/convoy/store.test.js +59 -13
- package/dist/cli/convoy/store.test.js.map +1 -1
- package/dist/cli/convoy/types.d.ts +76 -113
- package/dist/cli/convoy/types.d.ts.map +1 -1
- package/dist/cli/convoy/types.js +6 -13
- package/dist/cli/convoy/types.js.map +1 -1
- package/dist/cli/convoy/worktree.d.ts +88 -3
- package/dist/cli/convoy/worktree.d.ts.map +1 -1
- package/dist/cli/convoy/worktree.js +282 -56
- package/dist/cli/convoy/worktree.js.map +1 -1
- package/dist/cli/convoy/worktree.test.js +132 -1
- package/dist/cli/convoy/worktree.test.js.map +1 -1
- package/dist/cli/convoy-args.test.js +9 -27
- package/dist/cli/convoy-args.test.js.map +1 -1
- package/dist/cli/convoy-cmd.d.ts +31 -6
- package/dist/cli/convoy-cmd.d.ts.map +1 -1
- package/dist/cli/convoy-cmd.js +150 -201
- package/dist/cli/convoy-cmd.js.map +1 -1
- package/dist/cli/convoy-cmd.test.d.ts +2 -0
- package/dist/cli/convoy-cmd.test.d.ts.map +1 -0
- package/dist/cli/convoy-cmd.test.js +144 -0
- package/dist/cli/convoy-cmd.test.js.map +1 -0
- package/dist/cli/dashboard.d.ts +24 -11
- package/dist/cli/dashboard.d.ts.map +1 -1
- package/dist/cli/dashboard.js +241 -303
- package/dist/cli/dashboard.js.map +1 -1
- package/dist/cli/dashboard.test.d.ts +2 -0
- package/dist/cli/dashboard.test.d.ts.map +1 -0
- package/dist/cli/dashboard.test.js +340 -0
- package/dist/cli/dashboard.test.js.map +1 -0
- package/dist/cli/dispatcher.test.js +35 -2
- package/dist/cli/dispatcher.test.js.map +1 -1
- package/dist/cli/docs-accuracy.test.js +3 -3
- package/dist/cli/docs-accuracy.test.js.map +1 -1
- package/dist/cli/log.d.ts +39 -0
- package/dist/cli/log.d.ts.map +1 -1
- package/dist/cli/log.js +267 -93
- package/dist/cli/log.js.map +1 -1
- package/dist/cli/log.test.d.ts +2 -0
- package/dist/cli/log.test.d.ts.map +1 -0
- package/dist/cli/log.test.js +208 -0
- package/dist/cli/log.test.js.map +1 -0
- package/dist/cli/nearest.d.ts +18 -0
- package/dist/cli/nearest.d.ts.map +1 -0
- package/dist/cli/nearest.js +38 -0
- package/dist/cli/nearest.js.map +1 -0
- package/dist/cli/nearest.test.d.ts +2 -0
- package/dist/cli/nearest.test.d.ts.map +1 -0
- package/dist/cli/nearest.test.js +24 -0
- package/dist/cli/nearest.test.js.map +1 -0
- package/dist/cli/pipeline.d.ts +61 -0
- package/dist/cli/pipeline.d.ts.map +1 -1
- package/dist/cli/pipeline.flow.test.d.ts +2 -0
- package/dist/cli/pipeline.flow.test.d.ts.map +1 -0
- package/dist/cli/pipeline.flow.test.js +524 -0
- package/dist/cli/pipeline.flow.test.js.map +1 -0
- package/dist/cli/pipeline.js +471 -690
- package/dist/cli/pipeline.js.map +1 -1
- package/dist/cli/plan.d.ts +82 -31
- package/dist/cli/plan.d.ts.map +1 -1
- package/dist/cli/plan.js +167 -507
- package/dist/cli/plan.js.map +1 -1
- package/dist/cli/plan.test.d.ts +2 -0
- package/dist/cli/plan.test.d.ts.map +1 -0
- package/dist/cli/plan.test.js +158 -0
- package/dist/cli/plan.test.js.map +1 -0
- package/dist/cli/run/adapters/agent-process.d.ts +82 -0
- package/dist/cli/run/adapters/agent-process.d.ts.map +1 -0
- package/dist/cli/run/adapters/agent-process.js +224 -0
- package/dist/cli/run/adapters/agent-process.js.map +1 -0
- package/dist/cli/run/adapters/agent-process.test.d.ts +2 -0
- package/dist/cli/run/adapters/agent-process.test.d.ts.map +1 -0
- package/dist/cli/run/adapters/agent-process.test.js +159 -0
- package/dist/cli/run/adapters/agent-process.test.js.map +1 -0
- package/dist/cli/run/adapters/claude.d.ts +53 -2
- package/dist/cli/run/adapters/claude.d.ts.map +1 -1
- package/dist/cli/run/adapters/claude.js +147 -171
- package/dist/cli/run/adapters/claude.js.map +1 -1
- package/dist/cli/run/adapters/claude.test.js +197 -254
- package/dist/cli/run/adapters/claude.test.js.map +1 -1
- package/dist/cli/run/adapters/codex.d.ts +25 -2
- package/dist/cli/run/adapters/codex.d.ts.map +1 -1
- package/dist/cli/run/adapters/codex.js +113 -81
- package/dist/cli/run/adapters/codex.js.map +1 -1
- package/dist/cli/run/adapters/codex.test.js +116 -95
- package/dist/cli/run/adapters/codex.test.js.map +1 -1
- package/dist/cli/run/adapters/copilot.d.ts +35 -1
- package/dist/cli/run/adapters/copilot.d.ts.map +1 -1
- package/dist/cli/run/adapters/copilot.js +104 -287
- package/dist/cli/run/adapters/copilot.js.map +1 -1
- package/dist/cli/run/adapters/copilot.test.js +122 -282
- package/dist/cli/run/adapters/copilot.test.js.map +1 -1
- package/dist/cli/run/adapters/cursor.d.ts +25 -7
- package/dist/cli/run/adapters/cursor.d.ts.map +1 -1
- package/dist/cli/run/adapters/cursor.js +103 -156
- package/dist/cli/run/adapters/cursor.js.map +1 -1
- package/dist/cli/run/adapters/cursor.test.js +106 -218
- package/dist/cli/run/adapters/cursor.test.js.map +1 -1
- package/dist/cli/run/adapters/index.d.ts +34 -5
- package/dist/cli/run/adapters/index.d.ts.map +1 -1
- package/dist/cli/run/adapters/index.js +147 -21
- package/dist/cli/run/adapters/index.js.map +1 -1
- package/dist/cli/run/adapters/index.test.d.ts +2 -0
- package/dist/cli/run/adapters/index.test.d.ts.map +1 -0
- package/dist/cli/run/adapters/index.test.js +129 -0
- package/dist/cli/run/adapters/index.test.js.map +1 -0
- package/dist/cli/run/adapters/opencode.d.ts +25 -9
- package/dist/cli/run/adapters/opencode.d.ts.map +1 -1
- package/dist/cli/run/adapters/opencode.js +136 -152
- package/dist/cli/run/adapters/opencode.js.map +1 -1
- package/dist/cli/run/adapters/opencode.test.js +99 -218
- package/dist/cli/run/adapters/opencode.test.js.map +1 -1
- package/dist/cli/run/adapters/permission-modes.d.ts +47 -4
- package/dist/cli/run/adapters/permission-modes.d.ts.map +1 -1
- package/dist/cli/run/adapters/permission-modes.js +113 -37
- package/dist/cli/run/adapters/permission-modes.js.map +1 -1
- package/dist/cli/run/adapters/permission-modes.test.js +55 -40
- package/dist/cli/run/adapters/permission-modes.test.js.map +1 -1
- package/dist/cli/run/adapters/stub-cli.test-helper.d.ts +22 -0
- package/dist/cli/run/adapters/stub-cli.test-helper.d.ts.map +1 -0
- package/dist/cli/run/adapters/stub-cli.test-helper.js +73 -0
- package/dist/cli/run/adapters/stub-cli.test-helper.js.map +1 -0
- package/dist/cli/run/platform.d.ts +52 -0
- package/dist/cli/run/platform.d.ts.map +1 -0
- package/dist/cli/run/platform.js +207 -0
- package/dist/cli/run/platform.js.map +1 -0
- package/dist/cli/run/platform.test.d.ts +2 -0
- package/dist/cli/run/platform.test.d.ts.map +1 -0
- package/dist/cli/run/platform.test.js +119 -0
- package/dist/cli/run/platform.test.js.map +1 -0
- package/dist/cli/run/schema.d.ts +6 -8
- package/dist/cli/run/schema.d.ts.map +1 -1
- package/dist/cli/run/schema.js +44 -68
- package/dist/cli/run/schema.js.map +1 -1
- package/dist/cli/run/schema.test.js +59 -279
- package/dist/cli/run/schema.test.js.map +1 -1
- package/dist/cli/run.d.ts +34 -56
- package/dist/cli/run.d.ts.map +1 -1
- package/dist/cli/run.js +379 -1132
- package/dist/cli/run.js.map +1 -1
- package/dist/cli/run.test.d.ts +2 -0
- package/dist/cli/run.test.d.ts.map +1 -0
- package/dist/cli/run.test.js +318 -0
- package/dist/cli/run.test.js.map +1 -0
- package/dist/cli/team-config.d.ts.map +1 -1
- package/dist/cli/team-config.js +2 -21
- package/dist/cli/team-config.js.map +1 -1
- package/dist/cli/tiers.test.js +4 -13
- package/dist/cli/tiers.test.js.map +1 -1
- package/package.json +3 -10
- package/src/cli/agent-roster.test.ts +0 -55
- package/src/cli/boundary.test.ts +9 -7
- package/src/cli/convoy/TELEMETRY.md +131 -125
- package/src/cli/convoy/artifacts.test.ts +4 -2
- package/src/cli/convoy/artifacts.ts +13 -12
- package/src/cli/convoy/engine.git.test.ts +462 -0
- package/src/cli/convoy/engine.test.ts +817 -850
- package/src/cli/convoy/engine.ts +1864 -2596
- package/src/cli/convoy/event-schemas.ts +63 -59
- package/src/cli/convoy/events.test.ts +58 -9
- package/src/cli/convoy/events.ts +69 -91
- package/src/cli/convoy/gates.ts +31 -12
- package/src/cli/convoy/isolation.test.ts +76 -43
- package/src/cli/convoy/isolation.ts +100 -38
- package/src/cli/convoy/lock.test.ts +16 -0
- package/src/cli/convoy/lock.ts +25 -8
- package/src/cli/convoy/merge.test.ts +25 -1
- package/src/cli/convoy/merge.ts +74 -61
- package/src/cli/convoy/progress.test.ts +59 -0
- package/src/cli/convoy/progress.ts +121 -0
- package/src/cli/convoy/read-model.test.ts +685 -0
- package/src/cli/convoy/read-model.ts +1469 -0
- package/src/cli/convoy/redact.test.ts +49 -0
- package/src/cli/convoy/redact.ts +73 -0
- package/src/cli/convoy/reviewer.test.ts +112 -0
- package/src/cli/convoy/reviewer.ts +196 -0
- package/src/cli/convoy/schedule.test.ts +56 -0
- package/src/cli/convoy/schedule.ts +109 -0
- package/src/cli/convoy/spec-builder.test.ts +460 -464
- package/src/cli/convoy/spec-builder.ts +460 -129
- package/src/cli/convoy/spec-types.ts +46 -108
- package/src/cli/convoy/store.test.ts +64 -13
- package/src/cli/convoy/store.ts +143 -33
- package/src/cli/convoy/types.ts +59 -71
- package/src/cli/convoy/worktree.test.ts +140 -1
- package/src/cli/convoy/worktree.ts +311 -61
- package/src/cli/convoy-args.test.ts +10 -30
- package/src/cli/convoy-cmd.test.ts +163 -0
- package/src/cli/convoy-cmd.ts +173 -216
- package/src/cli/dashboard/dashboard.css +2086 -0
- package/src/cli/dashboard/dashboard.js +1687 -0
- package/src/cli/dashboard/index.html +307 -0
- package/src/cli/dashboard.test.ts +382 -0
- package/src/cli/dashboard.ts +243 -339
- package/src/cli/dispatcher.test.ts +36 -2
- package/src/cli/docs-accuracy.test.ts +3 -3
- package/src/cli/log.test.ts +228 -0
- package/src/cli/log.ts +302 -83
- package/src/cli/nearest.test.ts +27 -0
- package/src/cli/nearest.ts +38 -0
- package/src/cli/pipeline.flow.test.ts +607 -0
- package/src/cli/pipeline.ts +544 -759
- package/src/cli/plan.test.ts +193 -0
- package/src/cli/plan.ts +209 -545
- package/src/cli/run/adapters/agent-process.test.ts +175 -0
- package/src/cli/run/adapters/agent-process.ts +252 -0
- package/src/cli/run/adapters/claude.test.ts +205 -260
- package/src/cli/run/adapters/claude.ts +151 -162
- package/src/cli/run/adapters/codex.test.ts +120 -100
- package/src/cli/run/adapters/codex.ts +115 -91
- package/src/cli/run/adapters/copilot.test.ts +135 -306
- package/src/cli/run/adapters/copilot.ts +105 -274
- package/src/cli/run/adapters/cursor.test.ts +111 -220
- package/src/cli/run/adapters/cursor.ts +105 -156
- package/src/cli/run/adapters/index.test.ts +148 -0
- package/src/cli/run/adapters/index.ts +168 -20
- package/src/cli/run/adapters/opencode.test.ts +106 -227
- package/src/cli/run/adapters/opencode.ts +139 -151
- package/src/cli/run/adapters/permission-modes.test.ts +63 -41
- package/src/cli/run/adapters/permission-modes.ts +118 -37
- package/src/cli/run/adapters/stub-cli.test-helper.ts +88 -0
- package/src/cli/run/platform.test.ts +128 -0
- package/src/cli/run/platform.ts +213 -0
- package/src/cli/run/schema.test.ts +62 -344
- package/src/cli/run/schema.ts +48 -78
- package/src/cli/run.test.ts +351 -0
- package/src/cli/run.ts +366 -1151
- package/src/cli/team-config.ts +2 -21
- package/src/cli/tiers.test.ts +4 -17
- package/src/orchestrator/agents/team-lead.agent.md +1 -1
- package/src/orchestrator/prompts/assess-complexity.prompt.md +43 -26
- package/src/orchestrator/prompts/brainstorm.prompt.md +1 -1
- package/src/orchestrator/prompts/bug-fix.prompt.md +2 -2
- package/src/orchestrator/prompts/fix-convoy.prompt.md +43 -29
- package/src/orchestrator/prompts/fix-prd.prompt.md +26 -22
- package/src/orchestrator/prompts/generate-convoy.prompt.md +139 -147
- package/src/orchestrator/prompts/generate-prd.prompt.md +75 -68
- package/src/orchestrator/prompts/implement-feature.prompt.md +2 -2
- package/src/orchestrator/prompts/validate-convoy.prompt.md +29 -28
- package/src/orchestrator/prompts/validate-prd.prompt.md +28 -21
- package/src/orchestrator/skills/agent-hooks/HOOKS-REFERENCE.md +3 -3
- package/src/orchestrator/skills/agent-hooks/SKILL.md +1 -1
- package/src/orchestrator/skills/fast-review/SKILL.md +3 -1
- package/src/orchestrator/skills/orchestration-protocols/SKILL.md +7 -8
- package/dist/cli/convoy/dag-analysis.d.ts +0 -39
- package/dist/cli/convoy/dag-analysis.d.ts.map +0 -1
- package/dist/cli/convoy/dag-analysis.js +0 -279
- package/dist/cli/convoy/dag-analysis.js.map +0 -1
- package/dist/cli/convoy/dag-analysis.test.d.ts +0 -2
- package/dist/cli/convoy/dag-analysis.test.d.ts.map +0 -1
- package/dist/cli/convoy/dag-analysis.test.js +0 -289
- package/dist/cli/convoy/dag-analysis.test.js.map +0 -1
- package/dist/cli/convoy/formula.d.ts +0 -19
- package/dist/cli/convoy/formula.d.ts.map +0 -1
- package/dist/cli/convoy/formula.js +0 -142
- package/dist/cli/convoy/formula.js.map +0 -1
- package/dist/cli/convoy/formula.test.d.ts +0 -2
- package/dist/cli/convoy/formula.test.d.ts.map +0 -1
- package/dist/cli/convoy/formula.test.js +0 -342
- package/dist/cli/convoy/formula.test.js.map +0 -1
- package/dist/cli/convoy/health.d.ts +0 -34
- package/dist/cli/convoy/health.d.ts.map +0 -1
- package/dist/cli/convoy/health.js +0 -123
- package/dist/cli/convoy/health.js.map +0 -1
- package/dist/cli/convoy/health.test.d.ts +0 -2
- package/dist/cli/convoy/health.test.d.ts.map +0 -1
- package/dist/cli/convoy/health.test.js +0 -448
- package/dist/cli/convoy/health.test.js.map +0 -1
- package/dist/cli/convoy/last-run.d.ts +0 -53
- package/dist/cli/convoy/last-run.d.ts.map +0 -1
- package/dist/cli/convoy/last-run.js +0 -54
- package/dist/cli/convoy/last-run.js.map +0 -1
- package/dist/cli/convoy/last-run.test.d.ts +0 -2
- package/dist/cli/convoy/last-run.test.d.ts.map +0 -1
- package/dist/cli/convoy/last-run.test.js +0 -110
- package/dist/cli/convoy/last-run.test.js.map +0 -1
- package/dist/cli/convoy/pipeline.d.ts +0 -41
- package/dist/cli/convoy/pipeline.d.ts.map +0 -1
- package/dist/cli/convoy/pipeline.js +0 -414
- package/dist/cli/convoy/pipeline.js.map +0 -1
- package/dist/cli/convoy/pipeline.test.d.ts +0 -2
- package/dist/cli/convoy/pipeline.test.d.ts.map +0 -1
- package/dist/cli/convoy/pipeline.test.js +0 -837
- package/dist/cli/convoy/pipeline.test.js.map +0 -1
- package/dist/cli/convoy/review-stages.d.ts +0 -9
- package/dist/cli/convoy/review-stages.d.ts.map +0 -1
- package/dist/cli/convoy/review-stages.js +0 -134
- package/dist/cli/convoy/review-stages.js.map +0 -1
- package/dist/cli/convoy/review-stages.test.d.ts +0 -2
- package/dist/cli/convoy/review-stages.test.d.ts.map +0 -1
- package/dist/cli/convoy/review-stages.test.js +0 -197
- package/dist/cli/convoy/review-stages.test.js.map +0 -1
- package/dist/cli/run/executor.d.ts +0 -15
- package/dist/cli/run/executor.d.ts.map +0 -1
- package/dist/cli/run/executor.js +0 -249
- package/dist/cli/run/executor.js.map +0 -1
- package/dist/cli/run/executor.test.d.ts +0 -2
- package/dist/cli/run/executor.test.d.ts.map +0 -1
- package/dist/cli/run/executor.test.js +0 -297
- package/dist/cli/run/executor.test.js.map +0 -1
- package/dist/cli/run/reporter.d.ts +0 -10
- package/dist/cli/run/reporter.d.ts.map +0 -1
- package/dist/cli/run/reporter.js +0 -142
- package/dist/cli/run/reporter.js.map +0 -1
- package/dist/cli/run-dry-run.test.d.ts +0 -2
- package/dist/cli/run-dry-run.test.d.ts.map +0 -1
- package/dist/cli/run-dry-run.test.js +0 -83
- package/dist/cli/run-dry-run.test.js.map +0 -1
- package/dist/cli/run-executor-flags.test.d.ts +0 -2
- package/dist/cli/run-executor-flags.test.d.ts.map +0 -1
- package/dist/cli/run-executor-flags.test.js +0 -31
- package/dist/cli/run-executor-flags.test.js.map +0 -1
- package/dist/cli/run-finish.test.d.ts +0 -2
- package/dist/cli/run-finish.test.d.ts.map +0 -1
- package/dist/cli/run-finish.test.js +0 -77
- package/dist/cli/run-finish.test.js.map +0 -1
- package/dist/cli/watch.d.ts +0 -15
- package/dist/cli/watch.d.ts.map +0 -1
- package/dist/cli/watch.js +0 -277
- package/dist/cli/watch.js.map +0 -1
- package/dist/dashboard/scripts/etl.d.ts +0 -10
- package/dist/dashboard/scripts/etl.d.ts.map +0 -1
- package/dist/dashboard/scripts/etl.js +0 -141
- package/dist/dashboard/scripts/etl.js.map +0 -1
- package/src/cli/convoy/dag-analysis.test.ts +0 -349
- package/src/cli/convoy/dag-analysis.ts +0 -367
- package/src/cli/convoy/formula.test.ts +0 -404
- package/src/cli/convoy/formula.ts +0 -174
- package/src/cli/convoy/health.test.ts +0 -519
- package/src/cli/convoy/health.ts +0 -189
- package/src/cli/convoy/last-run.test.ts +0 -130
- package/src/cli/convoy/last-run.ts +0 -87
- package/src/cli/convoy/pipeline.test.ts +0 -999
- package/src/cli/convoy/pipeline.ts +0 -492
- package/src/cli/convoy/review-stages.test.ts +0 -235
- package/src/cli/convoy/review-stages.ts +0 -166
- package/src/cli/run/executor.test.ts +0 -338
- package/src/cli/run/executor.ts +0 -292
- package/src/cli/run/reporter.ts +0 -160
- package/src/cli/run-dry-run.test.ts +0 -97
- package/src/cli/run-executor-flags.test.ts +0 -38
- package/src/cli/run-finish.test.ts +0 -91
- package/src/cli/watch.ts +0 -295
- package/src/dashboard/astro.config.mjs +0 -6
- package/src/dashboard/dist/_astro/index.CADNhRPS.css +0 -1
- package/src/dashboard/dist/data/.gitkeep +0 -0
- package/src/dashboard/dist/data/convoy-list.json +0 -1
- package/src/dashboard/dist/data/overall-stats.json +0 -29
- package/src/dashboard/dist/index.html +0 -1963
- package/src/dashboard/node_modules/.vite/deps/_metadata.json +0 -31
- package/src/dashboard/node_modules/.vite/deps/astro___aria-query.js +0 -6776
- package/src/dashboard/node_modules/.vite/deps/astro___aria-query.js.map +0 -7
- package/src/dashboard/node_modules/.vite/deps/astro___axobject-query.js +0 -3754
- package/src/dashboard/node_modules/.vite/deps/astro___axobject-query.js.map +0 -7
- package/src/dashboard/node_modules/.vite/deps/astro___cssesc.js +0 -99
- package/src/dashboard/node_modules/.vite/deps/astro___cssesc.js.map +0 -7
- package/src/dashboard/node_modules/.vite/deps/chunk-BUSYA2B4.js +0 -8
- package/src/dashboard/node_modules/.vite/deps/chunk-BUSYA2B4.js.map +0 -7
- package/src/dashboard/node_modules/.vite/deps/package.json +0 -3
- package/src/dashboard/package-lock.json +0 -6
- package/src/dashboard/public/data/.gitkeep +0 -0
- package/src/dashboard/public/data/convoy-list.json +0 -1
- package/src/dashboard/public/data/overall-stats.json +0 -29
- package/src/dashboard/public/icon-192.png +0 -0
- package/src/dashboard/scripts/etl.test.ts +0 -166
- package/src/dashboard/scripts/etl.ts +0 -170
- package/src/dashboard/scripts/generate-demo-db.test.ts +0 -30
- package/src/dashboard/scripts/generate-demo-db.ts +0 -529
- package/src/dashboard/scripts/integration-test.ts +0 -504
- package/src/dashboard/scripts/verify-demo-data.sh +0 -51
- package/src/dashboard/seed-data/delegations.ndjson +0 -35
- package/src/dashboard/seed-data/events.ndjson +0 -104
- package/src/dashboard/seed-data/panels.ndjson +0 -13
- package/src/dashboard/seed-data/reviews.ndjson +0 -6
- package/src/dashboard/seed-data/sessions.ndjson +0 -50
- package/src/dashboard/src/env.d.ts +0 -1
- package/src/dashboard/src/layouts/Layout.astro +0 -25
- package/src/dashboard/src/pages/index.astro +0 -2313
- package/src/dashboard/src/styles/dashboard.css +0 -2943
- package/src/dashboard/tsconfig.json +0 -6
- /package/src/{dashboard/dist → cli/dashboard}/icon-192.png +0 -0
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { mkdtempSync, writeFileSync, chmodSync, readFileSync, rmSync, realpathSync, existsSync } from 'node:fs'
|
|
2
|
+
import { tmpdir } from 'node:os'
|
|
3
|
+
import { join } from 'node:path'
|
|
4
|
+
import { describe, it, expect, afterEach } from 'vitest'
|
|
5
|
+
import type { Task } from '../../convoy/spec-types.js'
|
|
6
|
+
import { runAgent, stopTask, liveAgentCount, timeoutMsOf, promptOf } from './agent-process.js'
|
|
7
|
+
|
|
8
|
+
const posix = process.platform !== 'win32'
|
|
9
|
+
|
|
10
|
+
function task(id: string, timeout = '5m', prompt = 'p'): Task {
|
|
11
|
+
return { id, prompt, agent: 'developer', timeout, depends_on: [], files: [], description: '', max_retries: 0 }
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function alive(pid: number): boolean {
|
|
15
|
+
try {
|
|
16
|
+
process.kill(pid, 0)
|
|
17
|
+
return true
|
|
18
|
+
} catch {
|
|
19
|
+
return false
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
async function waitFor(check: () => boolean, ms = 3000): Promise<boolean> {
|
|
24
|
+
const until = Date.now() + ms
|
|
25
|
+
while (Date.now() < until) {
|
|
26
|
+
if (check()) return true
|
|
27
|
+
await new Promise((r) => setTimeout(r, 25))
|
|
28
|
+
}
|
|
29
|
+
return check()
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
describe('timeoutMsOf', () => {
|
|
33
|
+
it('reads the units a spec and the engine use, including ms', () => {
|
|
34
|
+
expect(timeoutMsOf('30s')).toBe(30_000)
|
|
35
|
+
expect(timeoutMsOf('10m')).toBe(600_000)
|
|
36
|
+
expect(timeoutMsOf('2h')).toBe(7_200_000)
|
|
37
|
+
// The engine hands a step its timeout as `<n>ms`, which the spec parser does not read.
|
|
38
|
+
expect(timeoutMsOf('1500ms')).toBe(1500)
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
it('means no timeout for anything else', () => {
|
|
42
|
+
expect(timeoutMsOf(undefined)).toBeUndefined()
|
|
43
|
+
expect(timeoutMsOf('')).toBeUndefined()
|
|
44
|
+
expect(timeoutMsOf('soon')).toBeUndefined()
|
|
45
|
+
expect(timeoutMsOf('0s')).toBeUndefined()
|
|
46
|
+
})
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
describe('promptOf', () => {
|
|
50
|
+
it('sends the prompt exactly as written, so tasks can share a cached prefix', () => {
|
|
51
|
+
const t = { ...task('a'), agent: 'developer', files: ['src/a.ts'], prompt: '## Shared context\n\nDo a.' }
|
|
52
|
+
expect(promptOf(t)).toBe('## Shared context\n\nDo a.')
|
|
53
|
+
})
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
describe.skipIf(!posix)('running an agent CLI', () => {
|
|
57
|
+
const dirs: string[] = []
|
|
58
|
+
afterEach(() => {
|
|
59
|
+
for (const d of dirs.splice(0)) rmSync(d, { recursive: true, force: true })
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
function scratch(): string {
|
|
63
|
+
const d = realpathSync(mkdtempSync(join(tmpdir(), 'oc-agent-')))
|
|
64
|
+
dirs.push(d)
|
|
65
|
+
return d
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function script(dir: string, body: string): string {
|
|
69
|
+
const path = join(dir, 'fake-agent')
|
|
70
|
+
writeFileSync(path, `#!/bin/sh\n${body}\n`)
|
|
71
|
+
chmodSync(path, 0o755)
|
|
72
|
+
return path
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
it('sends the prompt on stdin, runs in the given directory, and collects both streams', async () => {
|
|
76
|
+
const dir = scratch()
|
|
77
|
+
const work = scratch()
|
|
78
|
+
const cmd = script(dir, `pwd > "${dir}/cwd"; cat > "${dir}/stdin"; echo out; echo err >&2; exit 3`)
|
|
79
|
+
// Larger than Windows' ~32K command line and Linux's 128 KiB single-argument limit.
|
|
80
|
+
const prompt = 'x'.repeat(300_000)
|
|
81
|
+
const exit = await runAgent(task('io'), { command: cmd, args: [], input: prompt, cwd: work })
|
|
82
|
+
expect(exit.code).toBe(3)
|
|
83
|
+
expect(exit.stdout.trim()).toBe('out')
|
|
84
|
+
expect(exit.stderr.trim()).toBe('err')
|
|
85
|
+
expect(exit.stopped).toBe(false)
|
|
86
|
+
expect(exit.timedOut).toBe(false)
|
|
87
|
+
expect(readFileSync(join(dir, 'cwd'), 'utf8').trim()).toBe(work)
|
|
88
|
+
expect(readFileSync(join(dir, 'stdin'), 'utf8')).toBe(prompt)
|
|
89
|
+
})
|
|
90
|
+
|
|
91
|
+
it('keeps a multi-byte character whole when it arrives split across two writes', async () => {
|
|
92
|
+
const dir = scratch()
|
|
93
|
+
// "é" is 0xC3 0xA9; the two bytes are written separately.
|
|
94
|
+
const cmd = script(dir, `printf '\\303'; sleep 0.2; printf '\\251\\n'`)
|
|
95
|
+
const exit = await runAgent(task('utf8'), { command: cmd, args: [], cwd: dir })
|
|
96
|
+
expect(exit.stdout).toBe('é\n')
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
it('reports a CLI that cannot be started instead of throwing', async () => {
|
|
100
|
+
const exit = await runAgent(task('missing'), { command: join(scratch(), 'no-such-agent'), args: [], cwd: tmpdir() })
|
|
101
|
+
expect(exit.code).toBe(-1)
|
|
102
|
+
expect(exit.spawnError).toBeTruthy()
|
|
103
|
+
})
|
|
104
|
+
|
|
105
|
+
it('stops a step that runs under a copy of the task, and what it started', async () => {
|
|
106
|
+
// The engine stops the task object it holds; a step runs under a copy with
|
|
107
|
+
// the same id. The old adapters tracked the process on the copy, so the
|
|
108
|
+
// step was never stopped.
|
|
109
|
+
const dir = scratch()
|
|
110
|
+
const cmd = script(dir, `sleep 30 & echo $! > "${dir}/child"; wait`)
|
|
111
|
+
const stepTask = task('t-1')
|
|
112
|
+
const running = runAgent(stepTask, { command: cmd, args: [], cwd: dir })
|
|
113
|
+
expect(await waitFor(() => existsSync(join(dir, 'child')) && readFileSync(join(dir, 'child'), 'utf8').trim() !== '')).toBe(true)
|
|
114
|
+
const childPid = Number(readFileSync(join(dir, 'child'), 'utf8').trim())
|
|
115
|
+
expect(liveAgentCount()).toBe(1)
|
|
116
|
+
|
|
117
|
+
stopTask(task('t-1')) // a different object, the same id
|
|
118
|
+
const exit = await running
|
|
119
|
+
expect(exit.stopped).toBe(true)
|
|
120
|
+
expect(await waitFor(() => !alive(childPid))).toBe(true)
|
|
121
|
+
expect(liveAgentCount()).toBe(0)
|
|
122
|
+
})
|
|
123
|
+
|
|
124
|
+
it('escalates to SIGKILL when the agent ignores SIGTERM', async () => {
|
|
125
|
+
// The old escalation tested `proc.killed`, which is true once SIGTERM is
|
|
126
|
+
// sent, so an agent that ignored SIGTERM ran on and `execute` reported
|
|
127
|
+
// whatever it exited with.
|
|
128
|
+
const dir = scratch()
|
|
129
|
+
const cmd = script(dir, `trap '' TERM; echo $$ > "${dir}/pid"; while true; do sleep 1; done`)
|
|
130
|
+
const running = runAgent(task('stubborn'), { command: cmd, args: [], cwd: dir })
|
|
131
|
+
// Stop it only once the trap is set; before that SIGTERM alone would do.
|
|
132
|
+
expect(await waitFor(() => existsSync(join(dir, 'pid')) && readFileSync(join(dir, 'pid'), 'utf8').trim() !== '')).toBe(true)
|
|
133
|
+
const pid = Number(readFileSync(join(dir, 'pid'), 'utf8').trim())
|
|
134
|
+
const started = Date.now()
|
|
135
|
+
stopTask(task('stubborn'))
|
|
136
|
+
const exit = await running
|
|
137
|
+
expect(exit.stopped).toBe(true)
|
|
138
|
+
const took = Date.now() - started
|
|
139
|
+
// SIGTERM was ignored, SIGKILL followed at 5 s — not the 8 s settle deadline.
|
|
140
|
+
expect(took).toBeGreaterThanOrEqual(4_500)
|
|
141
|
+
expect(took).toBeLessThan(7_500)
|
|
142
|
+
expect(alive(pid)).toBe(false)
|
|
143
|
+
}, 15_000)
|
|
144
|
+
|
|
145
|
+
it('stops an agent that outlives its timeout and says it timed out', async () => {
|
|
146
|
+
const dir = scratch()
|
|
147
|
+
const cmd = script(dir, 'sleep 30')
|
|
148
|
+
const exit = await runAgent(task('slow', '200ms'), { command: cmd, args: [], cwd: dir })
|
|
149
|
+
expect(exit.timedOut).toBe(true)
|
|
150
|
+
expect(exit.stopped).toBe(true)
|
|
151
|
+
})
|
|
152
|
+
|
|
153
|
+
it('leaves a finished task alone: nothing stale is signalled', async () => {
|
|
154
|
+
const dir = scratch()
|
|
155
|
+
const cmd = script(dir, 'exit 0')
|
|
156
|
+
const t = task('done-already')
|
|
157
|
+
const exit = await runAgent(t, { command: cmd, args: [], cwd: dir })
|
|
158
|
+
expect(exit.code).toBe(0)
|
|
159
|
+
expect(t._process).toBeUndefined()
|
|
160
|
+
expect(() => stopTask(t)).not.toThrow()
|
|
161
|
+
expect(liveAgentCount()).toBe(0)
|
|
162
|
+
})
|
|
163
|
+
|
|
164
|
+
it('settles when the agent exits but something it started still holds stdout open', async () => {
|
|
165
|
+
const dir = scratch()
|
|
166
|
+
const cmd = script(dir, `sleep 30 & echo $! > "${dir}/child"; echo done; exit 0`)
|
|
167
|
+
const started = Date.now()
|
|
168
|
+
const exit = await runAgent(task('holder'), { command: cmd, args: [], cwd: dir })
|
|
169
|
+
expect(exit.code).toBe(0)
|
|
170
|
+
expect(exit.stdout).toContain('done')
|
|
171
|
+
expect(Date.now() - started).toBeLessThan(6_000)
|
|
172
|
+
const childPid = Number(readFileSync(join(dir, 'child'), 'utf8').trim())
|
|
173
|
+
expect(await waitFor(() => !alive(childPid))).toBe(true)
|
|
174
|
+
})
|
|
175
|
+
})
|
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
import type { ChildProcess } from 'node:child_process'
|
|
2
|
+
import { spawnCommand, killTree } from '../platform.js'
|
|
3
|
+
import type { Task } from '../../convoy/spec-types.js'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Starting and stopping an agent CLI, shared by every adapter.
|
|
7
|
+
*
|
|
8
|
+
* Each adapter used to carry its own copy of this, and each copy had the same
|
|
9
|
+
* faults: the prompt went on argv (Windows caps a command line near 32K
|
|
10
|
+
* characters, and planning prompts are larger), `kill` signalled one pid and
|
|
11
|
+
* never escalated, and the process it signalled was whichever one was last
|
|
12
|
+
* written to `task._process` — for a multi-step task, a different object from
|
|
13
|
+
* the task the engine asked to stop.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/** How much of an agent's final message a result carries. */
|
|
17
|
+
export const OUTPUT_LIMIT = 500_000
|
|
18
|
+
|
|
19
|
+
/** Raw stdout kept for parsing. A JSONL stream's usage events come last, so the tail is what is kept. */
|
|
20
|
+
const STREAM_LIMIT = 32 * 1024 * 1024
|
|
21
|
+
|
|
22
|
+
/** After the agent itself exits, how long its stdout may stay open (held by something it started). */
|
|
23
|
+
const EXIT_GRACE_MS = 2_000
|
|
24
|
+
|
|
25
|
+
/** After a stop, how long to wait for the process to go before giving up on it. killTree escalates to SIGKILL at 5 s. */
|
|
26
|
+
const STOP_DEADLINE_MS = 8_000
|
|
27
|
+
|
|
28
|
+
export interface AgentRun {
|
|
29
|
+
/** The CLI to start, by the name it has on PATH. */
|
|
30
|
+
command: string
|
|
31
|
+
args: string[]
|
|
32
|
+
/** Written to the CLI's stdin, which is then closed. Undefined leaves stdin closed from the start. */
|
|
33
|
+
input?: string
|
|
34
|
+
cwd: string
|
|
35
|
+
/** Variables set for the CLI on top of this process's environment. */
|
|
36
|
+
env?: Record<string, string>
|
|
37
|
+
verbose?: boolean
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface AgentExit {
|
|
41
|
+
/** The exit code; -1 when there is none (it could not start, or a signal ended it). */
|
|
42
|
+
code: number
|
|
43
|
+
stdout: string
|
|
44
|
+
stderr: string
|
|
45
|
+
/** The task's own timeout ended it. */
|
|
46
|
+
timedOut: boolean
|
|
47
|
+
/** `kill(task)` or the timeout ended it — its exit code says nothing about the work. */
|
|
48
|
+
stopped: boolean
|
|
49
|
+
/** Why it could not be started, when it could not. */
|
|
50
|
+
spawnError?: string
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** Every agent process still running, by task id. A task id can have more than one: a step and its retry overlap briefly. */
|
|
54
|
+
const live = new Map<string, Set<ChildProcess>>()
|
|
55
|
+
/** What each running process does when it is stopped: arm the deadline that keeps `runAgent` from hanging. */
|
|
56
|
+
const onStop = new WeakMap<ChildProcess, () => void>()
|
|
57
|
+
const stoppedProcs = new WeakSet<ChildProcess>()
|
|
58
|
+
let exitHookInstalled = false
|
|
59
|
+
|
|
60
|
+
function track(taskId: string, child: ChildProcess): void {
|
|
61
|
+
let set = live.get(taskId)
|
|
62
|
+
if (!set) live.set(taskId, (set = new Set()))
|
|
63
|
+
set.add(child)
|
|
64
|
+
if (!exitHookInstalled) {
|
|
65
|
+
exitHookInstalled = true
|
|
66
|
+
// On POSIX each agent leads its own process group, so it does not get the
|
|
67
|
+
// terminal's Ctrl+C. Anything still running when this process exits would
|
|
68
|
+
// be orphaned, still editing a worktree nobody is watching. There is no
|
|
69
|
+
// later to escalate in, so it is SIGKILL now.
|
|
70
|
+
process.once('exit', () => {
|
|
71
|
+
for (const s of live.values()) for (const c of s) killTree(c.pid, 0)
|
|
72
|
+
})
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function untrack(taskId: string, child: ChildProcess): void {
|
|
77
|
+
const set = live.get(taskId)
|
|
78
|
+
if (!set) return
|
|
79
|
+
set.delete(child)
|
|
80
|
+
if (set.size === 0) live.delete(taskId)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function stop(child: ChildProcess): void {
|
|
84
|
+
if (stoppedProcs.has(child)) return
|
|
85
|
+
stoppedProcs.add(child)
|
|
86
|
+
killTree(child.pid)
|
|
87
|
+
onStop.get(child)?.()
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Stop every agent process running for this task, and everything each one
|
|
92
|
+
* started. Every adapter's `kill` is this.
|
|
93
|
+
*
|
|
94
|
+
* Looked up by task id rather than by `task._process`, because the engine asks
|
|
95
|
+
* to stop the task it holds while a step runs under a copy with the same id.
|
|
96
|
+
* The old escalation tested `proc.killed`, which is true as soon as SIGTERM is
|
|
97
|
+
* *sent*, so SIGKILL never followed; and it signalled the CLI alone, leaving
|
|
98
|
+
* the shells and servers it had started. A task with nothing running is left
|
|
99
|
+
* alone, so a stale pid is never signalled.
|
|
100
|
+
*/
|
|
101
|
+
export function stopTask(task: Pick<Task, 'id'>): void {
|
|
102
|
+
for (const child of live.get(task.id) ?? []) stop(child)
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/** Stop every agent process this process started. */
|
|
106
|
+
export function stopAllAgents(): void {
|
|
107
|
+
for (const set of live.values()) for (const child of set) stop(child)
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** How many agent processes are running — for tests. */
|
|
111
|
+
export function liveAgentCount(): number {
|
|
112
|
+
let n = 0
|
|
113
|
+
for (const set of live.values()) n += set.size
|
|
114
|
+
return n
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* A task's timeout in milliseconds, or undefined for none.
|
|
119
|
+
*
|
|
120
|
+
* Accepts `ms` as well as `s`/`m`/`h`: the engine hands a step its timeout as
|
|
121
|
+
* `<n>ms`, which the spec parser does not read.
|
|
122
|
+
*/
|
|
123
|
+
export function timeoutMsOf(timeout: string | undefined): number | undefined {
|
|
124
|
+
const m = String(timeout ?? '').trim().match(/^(\d+)\s*(ms|s|m|h)$/)
|
|
125
|
+
if (!m) return undefined
|
|
126
|
+
const n = parseInt(m[1], 10)
|
|
127
|
+
const unit = { ms: 1, s: 1_000, m: 60_000, h: 3_600_000 }[m[2] as 'ms' | 's' | 'm' | 'h']
|
|
128
|
+
return n > 0 ? n * unit : undefined
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* The prompt as the engine or planner wrote it.
|
|
133
|
+
*
|
|
134
|
+
* Adapters used to prefix "You are a <agent>." and append the file partition.
|
|
135
|
+
* The engine's preamble already states both, and a per-task first line made
|
|
136
|
+
* every task's prompt differ from its first byte, so no two tasks could share
|
|
137
|
+
* a prompt cache.
|
|
138
|
+
*/
|
|
139
|
+
export function promptOf(task: Pick<Task, 'prompt'>): string {
|
|
140
|
+
return task.prompt
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
function appendTail(current: string, chunk: string, limit: number): string {
|
|
144
|
+
const next = current + chunk
|
|
145
|
+
return next.length > limit ? next.slice(next.length - limit) : next
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Run an agent CLI for a task and collect what it printed.
|
|
150
|
+
*
|
|
151
|
+
* - The child runs in `run.cwd` — the task's worktree — and nowhere else.
|
|
152
|
+
* - `run.input` goes on stdin, so prompt size is not bounded by argv.
|
|
153
|
+
* - The task's `timeout` is enforced here as well as by the engine: the
|
|
154
|
+
* planner calls adapters directly, and nothing else bounded its sessions.
|
|
155
|
+
* - It never hangs: a stop that cannot end the process, or a process that
|
|
156
|
+
* exits while something it started holds stdout open, still settles.
|
|
157
|
+
*/
|
|
158
|
+
export function runAgent(task: Task, run: AgentRun): Promise<AgentExit> {
|
|
159
|
+
return new Promise<AgentExit>((resolve) => {
|
|
160
|
+
let child: ChildProcess
|
|
161
|
+
try {
|
|
162
|
+
child = spawnCommand(run.command, run.args, {
|
|
163
|
+
cwd: run.cwd,
|
|
164
|
+
env: run.env ? { ...process.env, ...run.env } : process.env,
|
|
165
|
+
stdio: [run.input === undefined ? 'ignore' : 'pipe', 'pipe', 'pipe'],
|
|
166
|
+
})
|
|
167
|
+
} catch (err) {
|
|
168
|
+
resolve({ code: -1, stdout: '', stderr: '', timedOut: false, stopped: false, spawnError: (err as Error).message })
|
|
169
|
+
return
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
track(task.id, child)
|
|
173
|
+
task._process = child
|
|
174
|
+
|
|
175
|
+
let stdout = ''
|
|
176
|
+
let stderr = ''
|
|
177
|
+
let timedOut = false
|
|
178
|
+
let settled = false
|
|
179
|
+
const timers: ReturnType<typeof setTimeout>[] = []
|
|
180
|
+
|
|
181
|
+
const finish = (code: number, spawnError?: string): void => {
|
|
182
|
+
if (settled) return
|
|
183
|
+
settled = true
|
|
184
|
+
for (const t of timers) clearTimeout(t)
|
|
185
|
+
untrack(task.id, child)
|
|
186
|
+
if (task._process === child) task._process = undefined
|
|
187
|
+
resolve({ code, stdout, stderr, timedOut, stopped: stoppedProcs.has(child), ...(spawnError ? { spawnError } : {}) })
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
onStop.set(child, () => {
|
|
191
|
+
const t = setTimeout(() => {
|
|
192
|
+
child.stdout?.destroy()
|
|
193
|
+
child.stderr?.destroy()
|
|
194
|
+
finish(child.exitCode ?? -1)
|
|
195
|
+
}, STOP_DEADLINE_MS)
|
|
196
|
+
t.unref?.()
|
|
197
|
+
timers.push(t)
|
|
198
|
+
})
|
|
199
|
+
|
|
200
|
+
const timeoutMs = timeoutMsOf(task.timeout)
|
|
201
|
+
if (timeoutMs) {
|
|
202
|
+
timers.push(setTimeout(() => {
|
|
203
|
+
timedOut = true
|
|
204
|
+
stop(child)
|
|
205
|
+
}, timeoutMs))
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
if (run.input !== undefined && child.stdin) {
|
|
209
|
+
// A CLI that exits before reading its input closes the pipe under us.
|
|
210
|
+
child.stdin.on('error', () => {})
|
|
211
|
+
child.stdin.end(run.input)
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
// Decoded by the stream, so a character split across two chunks stays whole.
|
|
215
|
+
child.stdout?.setEncoding('utf8')
|
|
216
|
+
child.stderr?.setEncoding('utf8')
|
|
217
|
+
child.stdout?.on('data', (chunk: string) => {
|
|
218
|
+
stdout = appendTail(stdout, chunk, STREAM_LIMIT)
|
|
219
|
+
if (run.verbose) process.stdout.write(chunk)
|
|
220
|
+
})
|
|
221
|
+
child.stderr?.on('data', (chunk: string) => {
|
|
222
|
+
stderr = appendTail(stderr, chunk, STREAM_LIMIT)
|
|
223
|
+
if (run.verbose) process.stderr.write(chunk)
|
|
224
|
+
})
|
|
225
|
+
|
|
226
|
+
child.on('error', (err) => finish(-1, err.message))
|
|
227
|
+
child.on('exit', () => {
|
|
228
|
+
// 'close' waits for stdout to close, and a process the agent started can
|
|
229
|
+
// hold it open long after the agent is gone. Give it a moment, then end
|
|
230
|
+
// what is left of the group and settle.
|
|
231
|
+
const t = setTimeout(() => {
|
|
232
|
+
if (process.platform !== 'win32' && child.pid) {
|
|
233
|
+
try { process.kill(-child.pid, 'SIGKILL') } catch { /* already gone */ }
|
|
234
|
+
}
|
|
235
|
+
child.stdout?.destroy()
|
|
236
|
+
child.stderr?.destroy()
|
|
237
|
+
finish(child.exitCode ?? -1)
|
|
238
|
+
}, EXIT_GRACE_MS)
|
|
239
|
+
t.unref?.()
|
|
240
|
+
timers.push(t)
|
|
241
|
+
})
|
|
242
|
+
child.on('close', (code) => finish(code ?? -1))
|
|
243
|
+
})
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/** The message for a run that ended without the agent finishing, or null when it finished. */
|
|
247
|
+
export function interruptedMessage(cli: string, task: Task, exit: AgentExit): string | null {
|
|
248
|
+
if (exit.spawnError) return `Failed to start ${cli}: ${exit.spawnError}`
|
|
249
|
+
if (exit.timedOut) return `${cli} timed out after ${task.timeout} and was stopped`
|
|
250
|
+
if (exit.stopped) return `${cli} was stopped before it finished`
|
|
251
|
+
return null
|
|
252
|
+
}
|