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,1132 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one read path into a project's convoy history.
|
|
3
|
+
*
|
|
4
|
+
* The status screen and the viewer both describe the same runs, and two readers
|
|
5
|
+
* of the same state eventually contradict each other. Both read through here.
|
|
6
|
+
*
|
|
7
|
+
* Read-only by construction: the database is opened with `readOnly: true`,
|
|
8
|
+
* queried and closed again. Opening it through the store used to run schema
|
|
9
|
+
* migrations, copy `.bak` files and switch the journal mode — writes, from a
|
|
10
|
+
* page that only looks. A viewer started against an older project must not
|
|
11
|
+
* upgrade that project's database behind the engine's back.
|
|
12
|
+
*
|
|
13
|
+
* The schema is read as it is found, not as this file expects it. Columns are
|
|
14
|
+
* selected only when the table has them, so a database from an older release
|
|
15
|
+
* reads with those fields `undefined`, and one from a newer release (a cost
|
|
16
|
+
* flag, cache token counts, an adapter column) reads without this file knowing
|
|
17
|
+
* about every addition first.
|
|
18
|
+
*/
|
|
19
|
+
import { closeSync, existsSync, fstatSync, openSync, readSync, statSync } from 'node:fs';
|
|
20
|
+
import { hostname } from 'node:os';
|
|
21
|
+
import { dirname, join, resolve } from 'node:path';
|
|
22
|
+
import { DatabaseSync } from 'node:sqlite';
|
|
23
|
+
import { KNOWN_EVENT_TYPES } from './types.js';
|
|
24
|
+
/** A run in one of these states may still have a process working on it. */
|
|
25
|
+
const ACTIVE_STATUSES = new Set(['pending', 'running']);
|
|
26
|
+
const FAILED_TASK_STATUSES = ['failed', 'gate-failed', 'timed-out', 'review-blocked', 'hook-failed', 'disputed'];
|
|
27
|
+
const RUNNING_TASK_STATUSES = new Set(['running', 'assigned']);
|
|
28
|
+
/**
|
|
29
|
+
* The engine beats every 10 seconds. A minute of silence is six missed beats:
|
|
30
|
+
* long enough not to flicker, short enough that a killed run stops reading as
|
|
31
|
+
* live within one glance.
|
|
32
|
+
*/
|
|
33
|
+
const HEARTBEAT_STALE_MS = 60_000;
|
|
34
|
+
/** How much of a failed task's output is shown as its reason. */
|
|
35
|
+
const TAIL_LINES = 20;
|
|
36
|
+
const TAIL_CHARS = 2000;
|
|
37
|
+
/**
|
|
38
|
+
* Runtime names the engine has written into `task.model` when the runtime
|
|
39
|
+
* reported no model. They name an adapter, not a model, so they read as unknown.
|
|
40
|
+
*/
|
|
41
|
+
const RUNTIME_NAMES = new Set(['claude', 'codex', 'copilot', 'cursor', 'opencode']);
|
|
42
|
+
// ── Project discovery ─────────────────────────────────────────────────────────
|
|
43
|
+
/**
|
|
44
|
+
* The nearest directory at or above `start` holding `.opencastle/`.
|
|
45
|
+
*
|
|
46
|
+
* The same walk `opencastle log` does. The dashboard used to read the current
|
|
47
|
+
* directory only, so started from `proj/src` it showed nothing while `log`,
|
|
48
|
+
* from the same place, was writing to `proj/.opencastle`.
|
|
49
|
+
*/
|
|
50
|
+
export function findProjectRoot(start) {
|
|
51
|
+
let dir = resolve(start);
|
|
52
|
+
for (;;) {
|
|
53
|
+
try {
|
|
54
|
+
if (statSync(join(dir, '.opencastle')).isDirectory())
|
|
55
|
+
return dir;
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
// not here; keep walking
|
|
59
|
+
}
|
|
60
|
+
const parent = dirname(dir);
|
|
61
|
+
if (parent === dir)
|
|
62
|
+
return null;
|
|
63
|
+
dir = parent;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
export function convoyDbPath(projectRoot) {
|
|
67
|
+
return join(projectRoot, '.opencastle', 'convoy.db');
|
|
68
|
+
}
|
|
69
|
+
// ── Database access ───────────────────────────────────────────────────────────
|
|
70
|
+
/** A read-only connection that knows which tables and columns this database has. */
|
|
71
|
+
class Reader {
|
|
72
|
+
db;
|
|
73
|
+
cols = new Map();
|
|
74
|
+
constructor(db) {
|
|
75
|
+
this.db = db;
|
|
76
|
+
}
|
|
77
|
+
columns(table) {
|
|
78
|
+
let found = this.cols.get(table);
|
|
79
|
+
if (!found) {
|
|
80
|
+
// Table names here are constants from this file, never request input.
|
|
81
|
+
const rows = this.db.prepare(`PRAGMA table_info(${table})`).all();
|
|
82
|
+
found = new Set(rows.map((r) => String(r.name)));
|
|
83
|
+
this.cols.set(table, found);
|
|
84
|
+
}
|
|
85
|
+
return found;
|
|
86
|
+
}
|
|
87
|
+
hasTable(table) {
|
|
88
|
+
return this.columns(table).size > 0;
|
|
89
|
+
}
|
|
90
|
+
/** A SELECT list of the wanted columns this database has. The others read as undefined. */
|
|
91
|
+
select(table, wanted) {
|
|
92
|
+
const have = this.columns(table);
|
|
93
|
+
const list = wanted.filter((c) => have.has(c));
|
|
94
|
+
return list.length > 0 ? list.join(', ') : 'NULL AS _none';
|
|
95
|
+
}
|
|
96
|
+
all(sql, ...params) {
|
|
97
|
+
return this.db.prepare(sql).all(...params);
|
|
98
|
+
}
|
|
99
|
+
get(sql, ...params) {
|
|
100
|
+
return this.db.prepare(sql).get(...params);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Run `fn` against a read-only connection, or return `fallback` when the project
|
|
105
|
+
* has no database yet. Query errors are not swallowed: a page that says "no
|
|
106
|
+
* runs" when the truth is "could not read them" is the kind of quiet wrongness
|
|
107
|
+
* this module exists to stop.
|
|
108
|
+
*/
|
|
109
|
+
function withDb(projectRoot, fallback, fn) {
|
|
110
|
+
const path = convoyDbPath(projectRoot);
|
|
111
|
+
if (!existsSync(path))
|
|
112
|
+
return fallback;
|
|
113
|
+
const db = new DatabaseSync(path, { readOnly: true });
|
|
114
|
+
try {
|
|
115
|
+
// A connection setting, not a write: wait out a checkpoint instead of failing.
|
|
116
|
+
db.exec('PRAGMA busy_timeout = 2000');
|
|
117
|
+
return fn(new Reader(db));
|
|
118
|
+
}
|
|
119
|
+
finally {
|
|
120
|
+
db.close();
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
// ── Value helpers ─────────────────────────────────────────────────────────────
|
|
124
|
+
function str(v) {
|
|
125
|
+
return typeof v === 'string' && v !== '' ? v : null;
|
|
126
|
+
}
|
|
127
|
+
function num(v) {
|
|
128
|
+
if (typeof v === 'number' && Number.isFinite(v))
|
|
129
|
+
return v;
|
|
130
|
+
if (typeof v === 'bigint')
|
|
131
|
+
return Number(v);
|
|
132
|
+
if (typeof v === 'string' && v.trim() !== '' && Number.isFinite(Number(v)))
|
|
133
|
+
return Number(v);
|
|
134
|
+
return null;
|
|
135
|
+
}
|
|
136
|
+
/** A column that may not exist: undefined when absent, null when empty. */
|
|
137
|
+
function optNum(row, key) {
|
|
138
|
+
return key in row ? num(row[key]) : undefined;
|
|
139
|
+
}
|
|
140
|
+
function optFlag(row, key) {
|
|
141
|
+
if (!(key in row))
|
|
142
|
+
return undefined;
|
|
143
|
+
const v = row[key];
|
|
144
|
+
return v === 1 || v === true || v === '1' || v === 'true';
|
|
145
|
+
}
|
|
146
|
+
function span(from, to) {
|
|
147
|
+
if (!from || !to)
|
|
148
|
+
return null;
|
|
149
|
+
const ms = Date.parse(to) - Date.parse(from);
|
|
150
|
+
return Number.isFinite(ms) && ms >= 0 ? ms : null;
|
|
151
|
+
}
|
|
152
|
+
function sumOrNull(values) {
|
|
153
|
+
let total = null;
|
|
154
|
+
for (const v of values)
|
|
155
|
+
if (v !== null)
|
|
156
|
+
total = (total ?? 0) + v;
|
|
157
|
+
return total;
|
|
158
|
+
}
|
|
159
|
+
function parseJson(text) {
|
|
160
|
+
if (typeof text !== 'string')
|
|
161
|
+
return text ?? null;
|
|
162
|
+
try {
|
|
163
|
+
return JSON.parse(text);
|
|
164
|
+
}
|
|
165
|
+
catch {
|
|
166
|
+
return text;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
function stringList(text) {
|
|
170
|
+
const parsed = parseJson(text);
|
|
171
|
+
return Array.isArray(parsed) ? parsed.filter((x) => typeof x === 'string') : [];
|
|
172
|
+
}
|
|
173
|
+
function tail(text) {
|
|
174
|
+
if (typeof text !== 'string')
|
|
175
|
+
return null;
|
|
176
|
+
const lines = text.trimEnd().split('\n');
|
|
177
|
+
let out = lines.slice(-TAIL_LINES).join('\n');
|
|
178
|
+
if (out.length > TAIL_CHARS)
|
|
179
|
+
out = out.slice(-TAIL_CHARS);
|
|
180
|
+
return out.trim() === '' ? null : out;
|
|
181
|
+
}
|
|
182
|
+
function costOf(row) {
|
|
183
|
+
// `*_num` is the REAL copy; older rows have only the TEXT column.
|
|
184
|
+
return num(row.cost_usd_num) ?? num(row.cost_usd);
|
|
185
|
+
}
|
|
186
|
+
function placeholders(n) {
|
|
187
|
+
return Array.from({ length: n }, () => '?').join(', ');
|
|
188
|
+
}
|
|
189
|
+
function readLock(r) {
|
|
190
|
+
if (!r.hasTable('engine_lock'))
|
|
191
|
+
return null;
|
|
192
|
+
const row = r.get(`SELECT ${r.select('engine_lock', ['pid', 'hostname', 'started_at', 'last_heartbeat'])} FROM engine_lock LIMIT 1`);
|
|
193
|
+
if (!row)
|
|
194
|
+
return null;
|
|
195
|
+
return { pid: num(row.pid), hostname: str(row.hostname), started_at: str(row.started_at), last_heartbeat: str(row.last_heartbeat) };
|
|
196
|
+
}
|
|
197
|
+
function pidAlive(pid) {
|
|
198
|
+
try {
|
|
199
|
+
process.kill(pid, 0);
|
|
200
|
+
return true;
|
|
201
|
+
}
|
|
202
|
+
catch (err) {
|
|
203
|
+
// EPERM: the process exists, it just is not ours to signal.
|
|
204
|
+
return err.code === 'EPERM';
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
/** Whether the lock's holder is still working: a recent heartbeat, and on this host, a live pid. */
|
|
208
|
+
function lockHeld(lock, now) {
|
|
209
|
+
const beat = lock.last_heartbeat ? Date.parse(lock.last_heartbeat) : NaN;
|
|
210
|
+
if (!Number.isFinite(beat) || now - beat > HEARTBEAT_STALE_MS)
|
|
211
|
+
return false;
|
|
212
|
+
if (lock.hostname === hostname())
|
|
213
|
+
return lock.pid !== null && pidAlive(lock.pid);
|
|
214
|
+
return true;
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* The lock covers the whole database, not one run, so a held lock only proves
|
|
218
|
+
* that *some* run is alive. A run that a crash left reading "running" must not
|
|
219
|
+
* borrow that liveness: it counts only if it was created, or wrote an event,
|
|
220
|
+
* after the current holder took the lock.
|
|
221
|
+
*/
|
|
222
|
+
function runAlive(r, convoy, lock, now) {
|
|
223
|
+
if (!ACTIVE_STATUSES.has(String(convoy.status)))
|
|
224
|
+
return false;
|
|
225
|
+
if (!lock || !lockHeld(lock, now))
|
|
226
|
+
return false;
|
|
227
|
+
const since = lock.started_at;
|
|
228
|
+
if (!since)
|
|
229
|
+
return true;
|
|
230
|
+
if (String(convoy.created_at ?? '') >= since)
|
|
231
|
+
return true;
|
|
232
|
+
if (!r.hasTable('event'))
|
|
233
|
+
return false;
|
|
234
|
+
const last = r.get('SELECT MAX(created_at) AS t FROM event WHERE convoy_id = ?', String(convoy.id));
|
|
235
|
+
return typeof last?.t === 'string' && last.t >= since;
|
|
236
|
+
}
|
|
237
|
+
// ── Runs ──────────────────────────────────────────────────────────────────────
|
|
238
|
+
const CONVOY_COLS = [
|
|
239
|
+
'id', 'name', 'status', 'branch', 'pipeline_id', 'created_at', 'started_at', 'finished_at',
|
|
240
|
+
'total_tokens', 'total_cost_usd', 'total_cost_usd_num', 'cost_estimated', 'adapter',
|
|
241
|
+
];
|
|
242
|
+
const TASK_SUMMARY_COLS = ['convoy_id', 'status', 'total_tokens', 'cost_usd', 'cost_usd_num', 'cost_estimated'];
|
|
243
|
+
function summarize(r, convoy, tasks, lock, now) {
|
|
244
|
+
const started = str(convoy.started_at);
|
|
245
|
+
const finished = str(convoy.finished_at);
|
|
246
|
+
const costed = tasks.filter((t) => costOf(t) !== null);
|
|
247
|
+
const taskEstimated = costed.some((t) => optFlag(t, 'cost_estimated'));
|
|
248
|
+
const storeSays = r.columns('task').has('cost_estimated') || r.columns('convoy').has('cost_estimated');
|
|
249
|
+
const runEstimated = optFlag(convoy, 'cost_estimated');
|
|
250
|
+
const status = String(convoy.status ?? 'unknown');
|
|
251
|
+
const alive = runAlive(r, convoy, lock, now);
|
|
252
|
+
return {
|
|
253
|
+
id: String(convoy.id),
|
|
254
|
+
name: String(convoy.name ?? convoy.id),
|
|
255
|
+
status,
|
|
256
|
+
branch: str(convoy.branch),
|
|
257
|
+
pipeline_id: str(convoy.pipeline_id),
|
|
258
|
+
created_at: String(convoy.created_at ?? ''),
|
|
259
|
+
started_at: started,
|
|
260
|
+
finished_at: finished,
|
|
261
|
+
duration_ms: span(started ?? str(convoy.created_at), finished),
|
|
262
|
+
tasks_total: tasks.length,
|
|
263
|
+
tasks_done: tasks.filter((t) => t.status === 'done').length,
|
|
264
|
+
tasks_failed: tasks.filter((t) => FAILED_TASK_STATUSES.includes(String(t.status))).length,
|
|
265
|
+
tasks_running: tasks.filter((t) => RUNNING_TASK_STATUSES.has(String(t.status))).length,
|
|
266
|
+
tokens: num(convoy.total_tokens) ?? sumOrNull(tasks.map((t) => num(t.total_tokens))),
|
|
267
|
+
cost_usd: num(convoy.total_cost_usd_num) ?? num(convoy.total_cost_usd) ?? sumOrNull(costed.map(costOf)),
|
|
268
|
+
cost_estimated: storeSays ? Boolean(runEstimated) || taskEstimated : undefined,
|
|
269
|
+
alive,
|
|
270
|
+
display_status: displayStatus(status, alive),
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
/** A task's status to show: `interrupted` for one recorded as running or assigned in a run nothing is working on. */
|
|
274
|
+
export function taskDisplayStatus(status, runAlive) {
|
|
275
|
+
return RUNNING_TASK_STATUSES.has(status) && !runAlive ? 'interrupted' : status;
|
|
276
|
+
}
|
|
277
|
+
/** The recorded status, or `interrupted` for a run that claims to be active with nothing running it. */
|
|
278
|
+
export function displayStatus(status, alive) {
|
|
279
|
+
return ACTIVE_STATUSES.has(status) && !alive ? 'interrupted' : status;
|
|
280
|
+
}
|
|
281
|
+
/** Summaries of the newest `limit` runs, or of every run when `limit` is null. */
|
|
282
|
+
function summaries(r, limit) {
|
|
283
|
+
if (!r.hasTable('convoy'))
|
|
284
|
+
return [];
|
|
285
|
+
const convoys = r.all(`SELECT ${r.select('convoy', CONVOY_COLS)} FROM convoy ORDER BY created_at DESC, rowid DESC LIMIT ?`, limit === null ? -1 : Math.max(1, Math.floor(limit)));
|
|
286
|
+
if (convoys.length === 0)
|
|
287
|
+
return [];
|
|
288
|
+
const wanted = new Set(convoys.map((c) => String(c.id)));
|
|
289
|
+
// One pass over the task table rather than an IN list, which SQLite caps.
|
|
290
|
+
const tasks = r.hasTable('task') ? r.all(`SELECT ${r.select('task', TASK_SUMMARY_COLS)} FROM task`) : [];
|
|
291
|
+
const byConvoy = new Map();
|
|
292
|
+
for (const t of tasks) {
|
|
293
|
+
const key = String(t.convoy_id);
|
|
294
|
+
if (!wanted.has(key))
|
|
295
|
+
continue;
|
|
296
|
+
let list = byConvoy.get(key);
|
|
297
|
+
if (!list)
|
|
298
|
+
byConvoy.set(key, (list = []));
|
|
299
|
+
list.push(t);
|
|
300
|
+
}
|
|
301
|
+
const lock = readLock(r);
|
|
302
|
+
const now = Date.now();
|
|
303
|
+
return convoys.map((c) => summarize(r, c, byConvoy.get(String(c.id)) ?? [], lock, now));
|
|
304
|
+
}
|
|
305
|
+
/** Runs, newest first. An empty list when the project has never run a convoy. */
|
|
306
|
+
export function readRuns(projectRoot, limit = 50) {
|
|
307
|
+
return withDb(projectRoot, [], (r) => summaries(r, limit));
|
|
308
|
+
}
|
|
309
|
+
const TASK_COLS = [
|
|
310
|
+
'id', 'convoy_id', 'phase', 'agent', 'status', 'depends_on', 'adapter', 'model', 'retries', 'worker_id',
|
|
311
|
+
'started_at', 'finished_at', 'prompt_tokens', 'completion_tokens', 'total_tokens',
|
|
312
|
+
'cache_read_tokens', 'cache_write_tokens', 'cost_usd', 'cost_usd_num', 'cost_estimated',
|
|
313
|
+
'review_verdict', 'review_level',
|
|
314
|
+
];
|
|
315
|
+
function failureReasons(r, convoyId) {
|
|
316
|
+
const out = new Map();
|
|
317
|
+
if (!r.hasTable('event'))
|
|
318
|
+
return out;
|
|
319
|
+
const rows = r.all("SELECT task_id, data FROM event WHERE convoy_id = ? AND type = 'task_failed' ORDER BY id", convoyId);
|
|
320
|
+
for (const row of rows) {
|
|
321
|
+
const data = parseJson(row.data);
|
|
322
|
+
if (!row.task_id || typeof data !== 'object' || data === null)
|
|
323
|
+
continue;
|
|
324
|
+
const d = data;
|
|
325
|
+
const reason = str(d.reason);
|
|
326
|
+
if (!reason)
|
|
327
|
+
continue;
|
|
328
|
+
// The message says what went wrong; the reason is the engine's code for the kind of failure.
|
|
329
|
+
const message = str(d.message)?.split('\n')[0].trim().slice(0, 300) || null;
|
|
330
|
+
const detail = [message ? reason : null, str(d.gate) ?? str(d.hook), typeof d.exit_code === 'number' ? `exit ${d.exit_code}` : null].filter(Boolean);
|
|
331
|
+
const head = message ?? reason;
|
|
332
|
+
out.set(String(row.task_id), detail.length ? `${head} (${detail.join(', ')})` : head);
|
|
333
|
+
}
|
|
334
|
+
return out;
|
|
335
|
+
}
|
|
336
|
+
function errorTails(r, convoyId) {
|
|
337
|
+
const out = new Map();
|
|
338
|
+
// The DLQ copy first, so the task's own output wins where both exist.
|
|
339
|
+
if (r.columns('dlq').has('error_output')) {
|
|
340
|
+
for (const row of r.all('SELECT task_id, substr(error_output, -4000) AS t FROM dlq WHERE convoy_id = ? ORDER BY rowid', convoyId)) {
|
|
341
|
+
const text = tail(row.t);
|
|
342
|
+
if (text)
|
|
343
|
+
out.set(String(row.task_id), text);
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
if (r.columns('task').has('output')) {
|
|
347
|
+
const rows = r.all(`SELECT id, substr(output, -4000) AS t FROM task WHERE convoy_id = ? AND status IN (${placeholders(FAILED_TASK_STATUSES.length)})`, convoyId, ...FAILED_TASK_STATUSES);
|
|
348
|
+
for (const row of rows) {
|
|
349
|
+
const text = tail(row.t);
|
|
350
|
+
if (text)
|
|
351
|
+
out.set(String(row.id), text);
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
return out;
|
|
355
|
+
}
|
|
356
|
+
function workerAdapters(r, convoyId) {
|
|
357
|
+
const out = new Map();
|
|
358
|
+
if (!r.columns('worker').has('adapter') || !r.columns('task').has('worker_id'))
|
|
359
|
+
return out;
|
|
360
|
+
const rows = r.all('SELECT id, adapter FROM worker WHERE id IN (SELECT worker_id FROM task WHERE convoy_id = ?)', convoyId);
|
|
361
|
+
for (const row of rows)
|
|
362
|
+
if (str(row.adapter))
|
|
363
|
+
out.set(String(row.id), String(row.adapter));
|
|
364
|
+
return out;
|
|
365
|
+
}
|
|
366
|
+
function reviewVerdict(row) {
|
|
367
|
+
if (!('review_verdict' in row))
|
|
368
|
+
return undefined;
|
|
369
|
+
const v = str(row.review_verdict);
|
|
370
|
+
return v === 'pass' || v === 'block' || v === 'skipped' ? v : null;
|
|
371
|
+
}
|
|
372
|
+
function toTask(t, workers, reasons, tails, alive) {
|
|
373
|
+
const id = String(t.id);
|
|
374
|
+
const status = String(t.status ?? 'unknown');
|
|
375
|
+
const failed = FAILED_TASK_STATUSES.includes(String(t.status));
|
|
376
|
+
const model = str(t.model);
|
|
377
|
+
const started = str(t.started_at);
|
|
378
|
+
const finished = str(t.finished_at);
|
|
379
|
+
return {
|
|
380
|
+
id,
|
|
381
|
+
phase: num(t.phase) ?? 0,
|
|
382
|
+
agent: String(t.agent ?? ''),
|
|
383
|
+
status,
|
|
384
|
+
display_status: taskDisplayStatus(status, alive),
|
|
385
|
+
depends_on: stringList(t.depends_on),
|
|
386
|
+
adapter: str(t.adapter) ?? (t.worker_id ? workers.get(String(t.worker_id)) ?? null : null),
|
|
387
|
+
model: model && !RUNTIME_NAMES.has(model) ? model : null,
|
|
388
|
+
retries: num(t.retries) ?? 0,
|
|
389
|
+
started_at: started,
|
|
390
|
+
finished_at: finished,
|
|
391
|
+
duration_ms: span(started, finished),
|
|
392
|
+
prompt_tokens: num(t.prompt_tokens),
|
|
393
|
+
completion_tokens: num(t.completion_tokens),
|
|
394
|
+
total_tokens: num(t.total_tokens),
|
|
395
|
+
cache_read_tokens: optNum(t, 'cache_read_tokens'),
|
|
396
|
+
cache_write_tokens: optNum(t, 'cache_write_tokens'),
|
|
397
|
+
cost_usd: costOf(t),
|
|
398
|
+
cost_estimated: optFlag(t, 'cost_estimated'),
|
|
399
|
+
review_verdict: reviewVerdict(t),
|
|
400
|
+
review_level: 'review_level' in t ? str(t.review_level) : undefined,
|
|
401
|
+
failure_reason: failed ? reasons.get(id) ?? null : null,
|
|
402
|
+
error_tail: failed ? tails.get(id) ?? null : null,
|
|
403
|
+
};
|
|
404
|
+
}
|
|
405
|
+
/** One run with its tasks, or null when there is no such run. */
|
|
406
|
+
export function readRun(projectRoot, convoyId) {
|
|
407
|
+
return withDb(projectRoot, null, (r) => {
|
|
408
|
+
if (!r.hasTable('convoy'))
|
|
409
|
+
return null;
|
|
410
|
+
const convoy = r.get(`SELECT ${r.select('convoy', CONVOY_COLS)} FROM convoy WHERE id = ?`, convoyId);
|
|
411
|
+
if (!convoy)
|
|
412
|
+
return null;
|
|
413
|
+
const rows = r.hasTable('task')
|
|
414
|
+
? r.all(`SELECT ${r.select('task', TASK_COLS)} FROM task WHERE convoy_id = ? ORDER BY phase, rowid`, convoyId)
|
|
415
|
+
: [];
|
|
416
|
+
const workers = workerAdapters(r, convoyId);
|
|
417
|
+
const reasons = failureReasons(r, convoyId);
|
|
418
|
+
const tails = errorTails(r, convoyId);
|
|
419
|
+
const summary = summarize(r, convoy, rows, readLock(r), Date.now());
|
|
420
|
+
const tasks = rows.map((t) => toTask(t, workers, reasons, tails, summary.alive));
|
|
421
|
+
const adapters = new Set();
|
|
422
|
+
if (str(convoy.adapter))
|
|
423
|
+
adapters.add(String(convoy.adapter));
|
|
424
|
+
for (const t of tasks)
|
|
425
|
+
if (t.adapter)
|
|
426
|
+
adapters.add(t.adapter);
|
|
427
|
+
for (const a of workers.values())
|
|
428
|
+
adapters.add(a);
|
|
429
|
+
const models = new Set(tasks.map((t) => t.model).filter((m) => m !== null));
|
|
430
|
+
return { ...summary, adapters: [...adapters].sort(), models: [...models].sort(), tasks };
|
|
431
|
+
});
|
|
432
|
+
}
|
|
433
|
+
/**
|
|
434
|
+
* The spec a run was started from, and the runtime it recorded, for `resume`
|
|
435
|
+
* and its `--dry-run` preview. Read here so a preview never opens the store,
|
|
436
|
+
* which migrates.
|
|
437
|
+
*/
|
|
438
|
+
export function readRunSpec(projectRoot, convoyId) {
|
|
439
|
+
return withDb(projectRoot, null, (r) => {
|
|
440
|
+
if (!r.hasTable('convoy'))
|
|
441
|
+
return null;
|
|
442
|
+
const row = r.get(`SELECT ${r.select('convoy', ['spec_yaml', 'adapter'])} FROM convoy WHERE id = ?`, convoyId);
|
|
443
|
+
if (!row || typeof row.spec_yaml !== 'string')
|
|
444
|
+
return null;
|
|
445
|
+
return { specYaml: row.spec_yaml, adapter: str(row.adapter) };
|
|
446
|
+
});
|
|
447
|
+
}
|
|
448
|
+
// ── Events ────────────────────────────────────────────────────────────────────
|
|
449
|
+
/**
|
|
450
|
+
* The feed's grouping, from the event type's own prefix.
|
|
451
|
+
*
|
|
452
|
+
* Read from the name rather than kept as a list so a type the engine adds later
|
|
453
|
+
* lands in the right group without this file changing — the old dashboard kept
|
|
454
|
+
* a hand-written list, offered nine filters for types that did not exist, and
|
|
455
|
+
* hid the real ones under "All".
|
|
456
|
+
*/
|
|
457
|
+
export function eventCategory(type) {
|
|
458
|
+
if (type.startsWith('merge_') || type === 'task_merged')
|
|
459
|
+
return 'merge';
|
|
460
|
+
if (/^(review_|dispute_)/.test(type))
|
|
461
|
+
return 'review';
|
|
462
|
+
if (/^(gate_|built_in_gate|tdd_|drift_|contract_|partition_|file_partition_|secret_|circuit_breaker_)/.test(type))
|
|
463
|
+
return 'check';
|
|
464
|
+
if (/^(task_|worker_|dlq_|file_injection_|artifact|agent_identity_)|^(session|delegation)$/.test(type))
|
|
465
|
+
return 'task';
|
|
466
|
+
if (/^(convoy_|post_convoy_|swarm_|watch_|ndjson_)/.test(type))
|
|
467
|
+
return 'run';
|
|
468
|
+
return 'other';
|
|
469
|
+
}
|
|
470
|
+
const PROBLEM_TYPE = /_failed$|violation|conflict|killed|tripped|blocked|rejected|leak|limit_reached|^dlq_|^drift_detected$|^task_skipped$|^task_retried$|^review_skipped$|interrupted|fallback/;
|
|
471
|
+
/**
|
|
472
|
+
* A failure or a warning: by type, a check whose data says it did not pass, or
|
|
473
|
+
* a review that blocked. A review that reached no verdict is `review_skipped`:
|
|
474
|
+
* the work went unreviewed, which is worth seeing, not a pass.
|
|
475
|
+
*/
|
|
476
|
+
export function isProblemEvent(type, data) {
|
|
477
|
+
if (PROBLEM_TYPE.test(type))
|
|
478
|
+
return true;
|
|
479
|
+
if (typeof data !== 'object' || data === null)
|
|
480
|
+
return false;
|
|
481
|
+
const d = data;
|
|
482
|
+
if (type === 'review_verdict')
|
|
483
|
+
return d.verdict === 'block' || d.verdict === 'skipped';
|
|
484
|
+
return d.passed === false;
|
|
485
|
+
}
|
|
486
|
+
/** Every type the engine can emit, grouped as the feed groups them. */
|
|
487
|
+
export function eventCategories() {
|
|
488
|
+
const out = { run: [], task: [], check: [], review: [], merge: [], other: [] };
|
|
489
|
+
for (const type of [...KNOWN_EVENT_TYPES].sort())
|
|
490
|
+
out[eventCategory(type)].push(type);
|
|
491
|
+
return out;
|
|
492
|
+
}
|
|
493
|
+
/** Events of one run after `sinceId`, oldest first. */
|
|
494
|
+
export function readEventsSince(projectRoot, convoyId, sinceId, limit = 500) {
|
|
495
|
+
const cap = Math.min(2000, Math.max(1, Math.floor(limit)));
|
|
496
|
+
return withDb(projectRoot, [], (r) => {
|
|
497
|
+
if (!r.hasTable('event'))
|
|
498
|
+
return [];
|
|
499
|
+
const rows = r.all(`SELECT ${r.select('event', ['id', 'type', 'task_id', 'worker_id', 'data', 'created_at'])}
|
|
500
|
+
FROM event WHERE convoy_id = ? AND id > ? ORDER BY id LIMIT ?`, convoyId, Math.max(0, Math.floor(sinceId)), cap);
|
|
501
|
+
return rows.map((e) => {
|
|
502
|
+
const type = String(e.type);
|
|
503
|
+
const data = parseJson(e.data);
|
|
504
|
+
return {
|
|
505
|
+
id: num(e.id) ?? 0,
|
|
506
|
+
type,
|
|
507
|
+
task_id: str(e.task_id),
|
|
508
|
+
worker_id: str(e.worker_id),
|
|
509
|
+
data,
|
|
510
|
+
created_at: String(e.created_at ?? ''),
|
|
511
|
+
category: eventCategory(type),
|
|
512
|
+
problem: isProblemEvent(type, data),
|
|
513
|
+
};
|
|
514
|
+
});
|
|
515
|
+
});
|
|
516
|
+
}
|
|
517
|
+
/**
|
|
518
|
+
* Whether a process is still working on this run.
|
|
519
|
+
*
|
|
520
|
+
* The run must be pending or running, and the engine lock must be held: a
|
|
521
|
+
* heartbeat within the last minute, and — on this host, where it can be
|
|
522
|
+
* checked — a pid that is alive. A dead pid means not alive, whatever the
|
|
523
|
+
* status column says.
|
|
524
|
+
*/
|
|
525
|
+
export function isRunAlive(projectRoot, convoyId) {
|
|
526
|
+
return withDb(projectRoot, false, (r) => {
|
|
527
|
+
if (!r.hasTable('convoy'))
|
|
528
|
+
return false;
|
|
529
|
+
const convoy = r.get('SELECT id, status, created_at FROM convoy WHERE id = ?', convoyId);
|
|
530
|
+
return convoy ? runAlive(r, convoy, readLock(r), Date.now()) : false;
|
|
531
|
+
});
|
|
532
|
+
}
|
|
533
|
+
// ── Agent sessions (`opencastle log`) ─────────────────────────────────────────
|
|
534
|
+
/** Read at most this much of the end of the log; sessions are shown newest first. */
|
|
535
|
+
const SESSION_LOG_TAIL_BYTES = 2 * 1024 * 1024;
|
|
536
|
+
function readTail(path, bytes) {
|
|
537
|
+
const fd = openSync(path, 'r');
|
|
538
|
+
try {
|
|
539
|
+
const size = fstatSync(fd).size;
|
|
540
|
+
const start = Math.max(0, size - bytes);
|
|
541
|
+
const buf = Buffer.alloc(size - start);
|
|
542
|
+
readSync(fd, buf, 0, buf.length, start);
|
|
543
|
+
const text = buf.toString('utf8');
|
|
544
|
+
// Starting mid-file means the first line is a fragment.
|
|
545
|
+
return start > 0 ? text.slice(text.indexOf('\n') + 1) : text;
|
|
546
|
+
}
|
|
547
|
+
finally {
|
|
548
|
+
closeSync(fd);
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
/** Session records from `.opencastle/logs/events.ndjson`, newest first. */
|
|
552
|
+
export function readSessions(projectRoot, limit = 50) {
|
|
553
|
+
const path = join(projectRoot, '.opencastle', 'logs', 'events.ndjson');
|
|
554
|
+
if (!existsSync(path))
|
|
555
|
+
return [];
|
|
556
|
+
const out = [];
|
|
557
|
+
const lines = readTail(path, SESSION_LOG_TAIL_BYTES).split('\n');
|
|
558
|
+
for (let i = lines.length - 1; i >= 0 && out.length < limit; i--) {
|
|
559
|
+
const line = lines[i].trim();
|
|
560
|
+
if (!line)
|
|
561
|
+
continue;
|
|
562
|
+
let rec;
|
|
563
|
+
try {
|
|
564
|
+
rec = JSON.parse(line);
|
|
565
|
+
}
|
|
566
|
+
catch {
|
|
567
|
+
continue;
|
|
568
|
+
}
|
|
569
|
+
if (typeof rec !== 'object' || rec === null)
|
|
570
|
+
continue;
|
|
571
|
+
const r = rec;
|
|
572
|
+
if (r.type !== 'session')
|
|
573
|
+
continue;
|
|
574
|
+
out.push({
|
|
575
|
+
source: 'log',
|
|
576
|
+
convoy_id: null,
|
|
577
|
+
timestamp: str(r.timestamp),
|
|
578
|
+
agent: str(r.agent),
|
|
579
|
+
task: str(r.task),
|
|
580
|
+
tracker_issue: str(r.tracker_issue),
|
|
581
|
+
outcome: str(r.outcome),
|
|
582
|
+
model: str(r.model),
|
|
583
|
+
duration_min: num(r.duration_min),
|
|
584
|
+
files_changed: num(r.files_changed),
|
|
585
|
+
retries: num(r.retries),
|
|
586
|
+
});
|
|
587
|
+
}
|
|
588
|
+
return out;
|
|
589
|
+
}
|
|
590
|
+
/**
|
|
591
|
+
* Agent sessions from both places they are recorded, newest first: what
|
|
592
|
+
* `opencastle log` appended (`source: 'log'`) and the engine's `session` event
|
|
593
|
+
* for each task it finished (`source: 'convoy'`). Each keeps its source, so a
|
|
594
|
+
* page can say which is which.
|
|
595
|
+
*/
|
|
596
|
+
export function readAllSessions(projectRoot, limit = 50) {
|
|
597
|
+
const merged = [...readSessions(projectRoot, limit), ...readEngineSessions(projectRoot, null, limit)];
|
|
598
|
+
merged.sort((a, b) => String(b.timestamp ?? '').localeCompare(String(a.timestamp ?? '')));
|
|
599
|
+
return merged.slice(0, limit);
|
|
600
|
+
}
|
|
601
|
+
/** The engine's `session` events, newest first: of one run, or of every run when `convoyId` is null. */
|
|
602
|
+
export function readEngineSessions(projectRoot, convoyId, limit = 50) {
|
|
603
|
+
return withDb(projectRoot, [], (r) => engineSessions(r, convoyId, limit));
|
|
604
|
+
}
|
|
605
|
+
function engineSessions(r, convoyId, limit) {
|
|
606
|
+
if (!r.hasTable('event'))
|
|
607
|
+
return [];
|
|
608
|
+
const rows = r.all(`SELECT ${r.select('event', ['convoy_id', 'task_id', 'data', 'created_at'])} FROM event
|
|
609
|
+
WHERE type = 'session'${convoyId === null ? '' : ' AND convoy_id = ?'} ORDER BY id DESC LIMIT ?`, ...(convoyId === null ? [] : [convoyId]), Math.max(1, Math.floor(limit)));
|
|
610
|
+
return rows.map((e) => {
|
|
611
|
+
const d = asRecord(parseJson(e.data));
|
|
612
|
+
return {
|
|
613
|
+
source: 'convoy',
|
|
614
|
+
convoy_id: str(e.convoy_id) ?? str(d.convoy_id),
|
|
615
|
+
timestamp: str(e.created_at),
|
|
616
|
+
agent: str(d.agent),
|
|
617
|
+
task: str(d.task) ?? str(e.task_id),
|
|
618
|
+
tracker_issue: null,
|
|
619
|
+
outcome: str(d.outcome),
|
|
620
|
+
model: modelOrNull(d.model),
|
|
621
|
+
duration_min: num(d.duration_min),
|
|
622
|
+
files_changed: num(d.files_changed),
|
|
623
|
+
retries: num(d.retries),
|
|
624
|
+
};
|
|
625
|
+
});
|
|
626
|
+
}
|
|
627
|
+
const INSIGHT_TYPES = [
|
|
628
|
+
'task_started', 'delegation', 'review_verdict', 'review_skipped', 'dispute_opened',
|
|
629
|
+
'gate_result', 'built_in_gate_result', 'contract_violation', 'partition_violation', 'secret_leak_prevented',
|
|
630
|
+
'task_merged', 'task_retried', 'worker_killed', 'convoy_interrupted', 'convoy_resumed',
|
|
631
|
+
];
|
|
632
|
+
function asRecord(v) {
|
|
633
|
+
return typeof v === 'object' && v !== null && !Array.isArray(v) ? v : {};
|
|
634
|
+
}
|
|
635
|
+
function modelOrNull(v) {
|
|
636
|
+
const m = str(v);
|
|
637
|
+
return m && !RUNTIME_NAMES.has(m) ? m : null;
|
|
638
|
+
}
|
|
639
|
+
function bump(t, key, by = 1) {
|
|
640
|
+
t[key] = (t[key] ?? 0) + by;
|
|
641
|
+
}
|
|
642
|
+
function addTally(into, from) {
|
|
643
|
+
for (const [k, v] of Object.entries(from))
|
|
644
|
+
bump(into, k, v);
|
|
645
|
+
}
|
|
646
|
+
function sortedTally(t, key, count) {
|
|
647
|
+
return Object.entries(t)
|
|
648
|
+
.sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0]))
|
|
649
|
+
.map(([k, v]) => ({ [key]: k, [count]: v }));
|
|
650
|
+
}
|
|
651
|
+
function flag(v) {
|
|
652
|
+
if (v === true || v === 1 || v === 'true')
|
|
653
|
+
return true;
|
|
654
|
+
if (v === false || v === 0 || v === 'false')
|
|
655
|
+
return false;
|
|
656
|
+
return null;
|
|
657
|
+
}
|
|
658
|
+
function stringItems(v) {
|
|
659
|
+
return Array.isArray(v) ? v.filter((x) => typeof x === 'string') : [];
|
|
660
|
+
}
|
|
661
|
+
function insightEvents(r, convoyId) {
|
|
662
|
+
if (!r.hasTable('event'))
|
|
663
|
+
return [];
|
|
664
|
+
const rows = r.all(`SELECT ${r.select('event', ['id', 'convoy_id', 'task_id', 'type', 'data', 'created_at'])} FROM event
|
|
665
|
+
WHERE type IN (${placeholders(INSIGHT_TYPES.length)})${convoyId === null ? '' : ' AND convoy_id = ?'} ORDER BY id`, ...INSIGHT_TYPES, ...(convoyId === null ? [] : [convoyId]));
|
|
666
|
+
return rows.map((e) => {
|
|
667
|
+
const data = asRecord(parseJson(e.data));
|
|
668
|
+
return {
|
|
669
|
+
id: num(e.id) ?? 0,
|
|
670
|
+
convoy_id: str(e.convoy_id),
|
|
671
|
+
task_id: str(e.task_id) ?? str(data.task_id),
|
|
672
|
+
type: String(e.type),
|
|
673
|
+
data,
|
|
674
|
+
created_at: String(e.created_at ?? ''),
|
|
675
|
+
};
|
|
676
|
+
});
|
|
677
|
+
}
|
|
678
|
+
function emptyReviewStats() {
|
|
679
|
+
return { ran: 0, passed: 0, blocked: 0, skipped: 0, auto_pass: 0, tokens: 0, by_level: {}, models: {}, disputes: 0 };
|
|
680
|
+
}
|
|
681
|
+
function emptyCheckStats() {
|
|
682
|
+
return {
|
|
683
|
+
ran: 0, passed: 0, failed: 0,
|
|
684
|
+
gates: { passed: 0, failed: 0 }, built_in: { passed: 0, failed: 0 },
|
|
685
|
+
by_scope: { task: { passed: 0, failed: 0 }, convoy: { passed: 0, failed: 0 } },
|
|
686
|
+
warnings: 0, secrets_prevented: 0,
|
|
687
|
+
};
|
|
688
|
+
}
|
|
689
|
+
/**
|
|
690
|
+
* Reviews, checks and the rest, read from one run's events (or every run's,
|
|
691
|
+
* for the overview) in the order they were written. The attempt a review or a
|
|
692
|
+
* gate belongs to is the `attempt` of the task's latest `task_started` before
|
|
693
|
+
* it; a check on the merged result counts its rounds by how often that check
|
|
694
|
+
* has run in the run so far.
|
|
695
|
+
*/
|
|
696
|
+
function digest(events) {
|
|
697
|
+
const reviews = [];
|
|
698
|
+
const skipped = [];
|
|
699
|
+
const disputes = [];
|
|
700
|
+
const checks = [];
|
|
701
|
+
const warnings = [];
|
|
702
|
+
const secrets = [];
|
|
703
|
+
const retries = [];
|
|
704
|
+
const interruptions = [];
|
|
705
|
+
const merges = {};
|
|
706
|
+
const starts = {};
|
|
707
|
+
const mechanisms = {};
|
|
708
|
+
const runtimes = {};
|
|
709
|
+
const taskTiers = {};
|
|
710
|
+
const reviewStats = emptyReviewStats();
|
|
711
|
+
const checkStats = emptyCheckStats();
|
|
712
|
+
const attempt = new Map();
|
|
713
|
+
const rounds = new Map();
|
|
714
|
+
const key = (e) => `${e.convoy_id ?? ''}\u0000${e.task_id ?? ''}`;
|
|
715
|
+
const taskKey = (e) => (e.task_id ?? '');
|
|
716
|
+
for (const e of events) {
|
|
717
|
+
const d = e.data;
|
|
718
|
+
switch (e.type) {
|
|
719
|
+
case 'task_started': {
|
|
720
|
+
const n = num(d.attempt);
|
|
721
|
+
if (n !== null)
|
|
722
|
+
attempt.set(key(e), n);
|
|
723
|
+
if (e.task_id)
|
|
724
|
+
starts[e.task_id] = (starts[e.task_id] ?? 0) + 1;
|
|
725
|
+
bump(mechanisms, str(d.mechanism) ?? 'not recorded');
|
|
726
|
+
bump(runtimes, str(d.adapter) ?? 'not recorded');
|
|
727
|
+
break;
|
|
728
|
+
}
|
|
729
|
+
case 'delegation': {
|
|
730
|
+
const tier = str(d.tier);
|
|
731
|
+
// The latest per task: a task that failed and was resumed reports twice.
|
|
732
|
+
if (tier && e.task_id)
|
|
733
|
+
taskTiers[`${e.convoy_id ?? ''}\u0000${e.task_id}`] = tier;
|
|
734
|
+
break;
|
|
735
|
+
}
|
|
736
|
+
case 'review_verdict': {
|
|
737
|
+
const level = str(d.level);
|
|
738
|
+
const verdict = str(d.verdict);
|
|
739
|
+
if (level === 'auto-pass') {
|
|
740
|
+
reviewStats.auto_pass++;
|
|
741
|
+
}
|
|
742
|
+
else {
|
|
743
|
+
reviewStats.ran++;
|
|
744
|
+
if (verdict === 'pass')
|
|
745
|
+
reviewStats.passed++;
|
|
746
|
+
if (verdict === 'block')
|
|
747
|
+
reviewStats.blocked++;
|
|
748
|
+
if (verdict === 'skipped')
|
|
749
|
+
reviewStats.skipped++;
|
|
750
|
+
const byLevel = (reviewStats.by_level[level ?? 'not recorded'] ??= { pass: 0, block: 0 });
|
|
751
|
+
if (verdict === 'pass')
|
|
752
|
+
byLevel.pass++;
|
|
753
|
+
if (verdict === 'block')
|
|
754
|
+
byLevel.block++;
|
|
755
|
+
reviewStats.tokens += num(d.tokens) ?? 0;
|
|
756
|
+
bump(reviewStats.models, str(d.model) ?? 'not reported');
|
|
757
|
+
}
|
|
758
|
+
reviews.push({
|
|
759
|
+
event_id: e.id, task_id: e.task_id, level, verdict,
|
|
760
|
+
tokens: num(d.tokens), model: str(d.model), passes: num(d.passes), blocks: num(d.blocks),
|
|
761
|
+
feedback_length: num(d.feedback_length), attempt: attempt.get(key(e)) ?? null, created_at: e.created_at,
|
|
762
|
+
});
|
|
763
|
+
break;
|
|
764
|
+
}
|
|
765
|
+
case 'review_skipped':
|
|
766
|
+
reviewStats.skipped++;
|
|
767
|
+
skipped.push({
|
|
768
|
+
event_id: e.id, task_id: e.task_id, level: str(d.level), reason: str(d.reason),
|
|
769
|
+
attempt: attempt.get(key(e)) ?? null, created_at: e.created_at,
|
|
770
|
+
});
|
|
771
|
+
break;
|
|
772
|
+
case 'dispute_opened':
|
|
773
|
+
reviewStats.disputes++;
|
|
774
|
+
disputes.push({
|
|
775
|
+
event_id: e.id, task_id: e.task_id, dispute_id: str(d.dispute_id), reason: str(d.reason),
|
|
776
|
+
panel_attempts: num(d.panel_attempts), created_at: e.created_at,
|
|
777
|
+
});
|
|
778
|
+
break;
|
|
779
|
+
case 'gate_result':
|
|
780
|
+
case 'built_in_gate_result': {
|
|
781
|
+
const builtIn = e.type === 'built_in_gate_result';
|
|
782
|
+
const name = (builtIn ? str(d.gate) : str(d.command)) ?? 'unnamed';
|
|
783
|
+
const scope = builtIn
|
|
784
|
+
? (e.task_id ? 'task' : 'convoy')
|
|
785
|
+
: str(d.scope) === 'convoy' || (!str(d.scope) && !e.task_id) ? 'convoy' : 'task';
|
|
786
|
+
const passed = flag(d.passed);
|
|
787
|
+
let round = null;
|
|
788
|
+
if (scope === 'convoy') {
|
|
789
|
+
const roundKey = `${e.convoy_id ?? ''}\u0000${builtIn ? 'b' : 'g'}\u0000${name}`;
|
|
790
|
+
round = (rounds.get(roundKey) ?? 0) + 1;
|
|
791
|
+
rounds.set(roundKey, round);
|
|
792
|
+
}
|
|
793
|
+
checks.push({
|
|
794
|
+
event_id: e.id, kind: builtIn ? 'built-in' : 'gate', scope, task_id: e.task_id, name, passed,
|
|
795
|
+
exit_code: num(d.exit_code), level: str(d.level), output: tail(d.output),
|
|
796
|
+
attempt: scope === 'task' ? attempt.get(key(e)) ?? null : null, round, created_at: e.created_at,
|
|
797
|
+
});
|
|
798
|
+
if (passed !== null) {
|
|
799
|
+
checkStats.ran++;
|
|
800
|
+
const outcome = passed ? 'passed' : 'failed';
|
|
801
|
+
checkStats[outcome]++;
|
|
802
|
+
checkStats[builtIn ? 'built_in' : 'gates'][outcome]++;
|
|
803
|
+
checkStats.by_scope[scope][outcome]++;
|
|
804
|
+
}
|
|
805
|
+
break;
|
|
806
|
+
}
|
|
807
|
+
case 'contract_violation':
|
|
808
|
+
case 'partition_violation':
|
|
809
|
+
checkStats.warnings++;
|
|
810
|
+
warnings.push({
|
|
811
|
+
event_id: e.id, type: e.type, task_id: e.task_id,
|
|
812
|
+
// `__contract_block` is the engine's name for an answer with no output
|
|
813
|
+
// summary block at all; say that, not the key.
|
|
814
|
+
items: e.type === 'partition_violation'
|
|
815
|
+
? stringItems(d.violations)
|
|
816
|
+
: [...stringItems(d.missing), ...stringItems(d.warnings)].map((m) => (m === '__contract_block' ? 'no output summary block in the answer' : m)),
|
|
817
|
+
created_at: e.created_at,
|
|
818
|
+
});
|
|
819
|
+
break;
|
|
820
|
+
case 'secret_leak_prevented':
|
|
821
|
+
checkStats.secrets_prevented++;
|
|
822
|
+
secrets.push({ event_id: e.id, task_id: e.task_id, context: str(d.context), patterns: stringItems(d.patterns), created_at: e.created_at });
|
|
823
|
+
break;
|
|
824
|
+
case 'task_merged':
|
|
825
|
+
if (e.task_id)
|
|
826
|
+
merges[taskKey(e)] = num(d.files) ?? 0;
|
|
827
|
+
break;
|
|
828
|
+
case 'task_retried':
|
|
829
|
+
retries.push({
|
|
830
|
+
event_id: e.id, task_id: e.task_id, attempt: num(d.attempt), previous_status: str(d.previous_status),
|
|
831
|
+
reason: str(d.reason), created_at: e.created_at,
|
|
832
|
+
});
|
|
833
|
+
break;
|
|
834
|
+
case 'worker_killed':
|
|
835
|
+
case 'convoy_interrupted':
|
|
836
|
+
case 'convoy_resumed':
|
|
837
|
+
interruptions.push({ event_id: e.id, type: e.type, task_id: e.task_id, signal: str(d.signal) ?? str(d.reason), created_at: e.created_at });
|
|
838
|
+
break;
|
|
839
|
+
}
|
|
840
|
+
}
|
|
841
|
+
return {
|
|
842
|
+
reviews, skipped, disputes, checks, warnings, secrets, retries, interruptions, merges, starts,
|
|
843
|
+
mechanisms, runtimes, taskTiers, reviewStats, checkStats,
|
|
844
|
+
};
|
|
845
|
+
}
|
|
846
|
+
function tierTally(taskTiers) {
|
|
847
|
+
const out = {};
|
|
848
|
+
for (const tier of Object.values(taskTiers))
|
|
849
|
+
bump(out, tier);
|
|
850
|
+
return out;
|
|
851
|
+
}
|
|
852
|
+
function dlqRows(r, convoyId) {
|
|
853
|
+
if (!r.hasTable('dlq'))
|
|
854
|
+
return null;
|
|
855
|
+
const rows = r.all(`SELECT ${r.select('dlq', ['id', 'task_id', 'agent', 'failure_type', 'attempts', 'tokens_spent', 'resolved', 'resolution', 'created_at', 'resolved_at'])}
|
|
856
|
+
${r.columns('dlq').has('error_output') ? ', substr(error_output, -4000) AS tail_text' : ''}
|
|
857
|
+
FROM dlq${convoyId === null ? '' : ' WHERE convoy_id = ?'} ORDER BY rowid`, ...(convoyId === null ? [] : [convoyId]));
|
|
858
|
+
return rows.map((d) => ({
|
|
859
|
+
id: String(d.id ?? ''),
|
|
860
|
+
task_id: str(d.task_id),
|
|
861
|
+
agent: str(d.agent),
|
|
862
|
+
failure_type: str(d.failure_type),
|
|
863
|
+
attempts: num(d.attempts),
|
|
864
|
+
tokens_spent: num(d.tokens_spent),
|
|
865
|
+
resolved: flag(d.resolved) === true,
|
|
866
|
+
resolution: str(d.resolution),
|
|
867
|
+
created_at: str(d.created_at),
|
|
868
|
+
resolved_at: str(d.resolved_at),
|
|
869
|
+
error_tail: tail(d.tail_text),
|
|
870
|
+
}));
|
|
871
|
+
}
|
|
872
|
+
function artifactRows(r, convoyId) {
|
|
873
|
+
if (!r.hasTable('artifact'))
|
|
874
|
+
return null;
|
|
875
|
+
const size = r.columns('artifact').has('content') ? ', length(content) AS size_bytes' : '';
|
|
876
|
+
return r.all(`SELECT ${r.select('artifact', ['name', 'type', 'task_id', 'created_at'])}${size} FROM artifact WHERE convoy_id = ? ORDER BY created_at, rowid`, convoyId).map((a) => ({
|
|
877
|
+
name: String(a.name ?? ''),
|
|
878
|
+
type: String(a.type ?? 'unknown'),
|
|
879
|
+
task_id: str(a.task_id),
|
|
880
|
+
created_at: str(a.created_at),
|
|
881
|
+
size_bytes: num(a.size_bytes),
|
|
882
|
+
}));
|
|
883
|
+
}
|
|
884
|
+
/**
|
|
885
|
+
* What the run's events and side tables say beyond its tasks: tiers,
|
|
886
|
+
* mechanisms, every review and check with the attempt it belonged to, retries,
|
|
887
|
+
* interrupts, the dead-letter queue, artifacts and the engine's sessions.
|
|
888
|
+
* Null when there is no such run.
|
|
889
|
+
*/
|
|
890
|
+
export function readRunInsights(projectRoot, convoyId) {
|
|
891
|
+
return withDb(projectRoot, null, (r) => {
|
|
892
|
+
if (!r.hasTable('convoy') || !r.get('SELECT id FROM convoy WHERE id = ?', convoyId))
|
|
893
|
+
return null;
|
|
894
|
+
const events = r.hasTable('event');
|
|
895
|
+
const g = digest(insightEvents(r, convoyId));
|
|
896
|
+
const taskIds = r.hasTable('task')
|
|
897
|
+
? r.all('SELECT id FROM task WHERE convoy_id = ?', convoyId).map((t) => String(t.id))
|
|
898
|
+
: [];
|
|
899
|
+
const tiers = {};
|
|
900
|
+
for (const [k, tier] of Object.entries(g.taskTiers))
|
|
901
|
+
tiers[k.split('\u0000')[1]] = tier;
|
|
902
|
+
return {
|
|
903
|
+
tiers: sortedTally(tierTally(g.taskTiers), 'tier', 'tasks'),
|
|
904
|
+
tiers_not_recorded: taskIds.filter((id) => !(id in tiers)).length,
|
|
905
|
+
task_tiers: tiers,
|
|
906
|
+
mechanisms: sortedTally(g.mechanisms, 'mechanism', 'attempts'),
|
|
907
|
+
runtimes: sortedTally(g.runtimes, 'runtime', 'attempts'),
|
|
908
|
+
starts: g.starts,
|
|
909
|
+
reviews: g.reviews,
|
|
910
|
+
reviews_skipped: g.skipped,
|
|
911
|
+
review_stats: g.reviewStats,
|
|
912
|
+
disputes: g.disputes,
|
|
913
|
+
checks: g.checks,
|
|
914
|
+
check_stats: g.checkStats,
|
|
915
|
+
warnings: g.warnings,
|
|
916
|
+
secrets_prevented: g.secrets,
|
|
917
|
+
merges: g.merges,
|
|
918
|
+
retries: g.retries,
|
|
919
|
+
interruptions: g.interruptions,
|
|
920
|
+
sessions: engineSessions(r, convoyId, 500),
|
|
921
|
+
dlq: dlqRows(r, convoyId),
|
|
922
|
+
artifacts: artifactRows(r, convoyId),
|
|
923
|
+
events_recorded: events,
|
|
924
|
+
};
|
|
925
|
+
});
|
|
926
|
+
}
|
|
927
|
+
/** One project's share of the overview. See `OverviewParts`. */
|
|
928
|
+
export function readOverviewParts(projectRoot) {
|
|
929
|
+
const empty = {
|
|
930
|
+
runs: [], tasks: [], tiers: {}, mechanisms: {}, runtimes: {}, reviews: null, checks: null, dlq: null, artifacts: null,
|
|
931
|
+
};
|
|
932
|
+
return withDb(projectRoot, empty, (r) => {
|
|
933
|
+
const runs = summaries(r, null);
|
|
934
|
+
const alive = new Map(runs.map((run) => [run.id, run.alive]));
|
|
935
|
+
const tasks = r.hasTable('task')
|
|
936
|
+
? r.all(`SELECT ${r.select('task', ['id', 'convoy_id', 'agent', 'status', 'model', 'retries'])} FROM task`).map((t) => ({
|
|
937
|
+
convoy_id: String(t.convoy_id ?? ''),
|
|
938
|
+
id: String(t.id ?? ''),
|
|
939
|
+
agent: str(t.agent) ?? 'not recorded',
|
|
940
|
+
display_status: taskDisplayStatus(String(t.status ?? 'unknown'), alive.get(String(t.convoy_id)) ?? false),
|
|
941
|
+
model: modelOrNull(t.model),
|
|
942
|
+
retries: num(t.retries) ?? 0,
|
|
943
|
+
}))
|
|
944
|
+
: [];
|
|
945
|
+
const events = r.hasTable('event');
|
|
946
|
+
const g = digest(insightEvents(r, null));
|
|
947
|
+
const dlq = dlqRows(r, null);
|
|
948
|
+
let artifacts = null;
|
|
949
|
+
if (r.hasTable('artifact'))
|
|
950
|
+
artifacts = num(r.get('SELECT COUNT(*) AS n FROM artifact')?.n) ?? 0;
|
|
951
|
+
return {
|
|
952
|
+
runs,
|
|
953
|
+
tasks,
|
|
954
|
+
tiers: tierTally(g.taskTiers),
|
|
955
|
+
mechanisms: g.mechanisms,
|
|
956
|
+
runtimes: g.runtimes,
|
|
957
|
+
reviews: events ? g.reviewStats : null,
|
|
958
|
+
checks: events ? g.checkStats : null,
|
|
959
|
+
dlq: dlq === null ? null : { entries: dlq.length, unresolved: dlq.filter((d) => !d.resolved).length },
|
|
960
|
+
artifacts,
|
|
961
|
+
};
|
|
962
|
+
});
|
|
963
|
+
}
|
|
964
|
+
const ENDED = new Set(['done', 'failed', 'gate-failed', 'hook-failed', 'interrupted']);
|
|
965
|
+
const FAILED_RUN = new Set(['failed', 'gate-failed', 'hook-failed']);
|
|
966
|
+
function mergeReviews(a, b) {
|
|
967
|
+
if (!a)
|
|
968
|
+
return b && { ...b, by_level: structuredClone(b.by_level), models: { ...b.models } };
|
|
969
|
+
if (!b)
|
|
970
|
+
return a;
|
|
971
|
+
const out = { ...a, by_level: structuredClone(a.by_level), models: { ...a.models } };
|
|
972
|
+
for (const k of ['ran', 'passed', 'blocked', 'skipped', 'auto_pass', 'tokens', 'disputes'])
|
|
973
|
+
out[k] += b[k];
|
|
974
|
+
for (const [level, v] of Object.entries(b.by_level)) {
|
|
975
|
+
const into = (out.by_level[level] ??= { pass: 0, block: 0 });
|
|
976
|
+
into.pass += v.pass;
|
|
977
|
+
into.block += v.block;
|
|
978
|
+
}
|
|
979
|
+
addTally(out.models, b.models);
|
|
980
|
+
return out;
|
|
981
|
+
}
|
|
982
|
+
function mergeChecks(a, b) {
|
|
983
|
+
if (!a)
|
|
984
|
+
return b && structuredClone(b);
|
|
985
|
+
if (!b)
|
|
986
|
+
return a;
|
|
987
|
+
const out = structuredClone(a);
|
|
988
|
+
out.ran += b.ran;
|
|
989
|
+
out.passed += b.passed;
|
|
990
|
+
out.failed += b.failed;
|
|
991
|
+
out.warnings += b.warnings;
|
|
992
|
+
out.secrets_prevented += b.secrets_prevented;
|
|
993
|
+
for (const group of ['gates', 'built_in']) {
|
|
994
|
+
out[group].passed += b[group].passed;
|
|
995
|
+
out[group].failed += b[group].failed;
|
|
996
|
+
}
|
|
997
|
+
for (const scope of ['task', 'convoy']) {
|
|
998
|
+
out.by_scope[scope].passed += b.by_scope[scope].passed;
|
|
999
|
+
out.by_scope[scope].failed += b.by_scope[scope].failed;
|
|
1000
|
+
}
|
|
1001
|
+
return out;
|
|
1002
|
+
}
|
|
1003
|
+
/** The nearest-rank percentile of an ascending list. */
|
|
1004
|
+
function percentile(sorted, p) {
|
|
1005
|
+
if (sorted.length === 0)
|
|
1006
|
+
return null;
|
|
1007
|
+
return sorted[Math.min(sorted.length - 1, Math.max(0, Math.ceil(p * sorted.length) - 1))];
|
|
1008
|
+
}
|
|
1009
|
+
/** The overview of one or more projects' shares. */
|
|
1010
|
+
export function overviewFrom(parts) {
|
|
1011
|
+
const runs = parts.flatMap((p) => p.runs);
|
|
1012
|
+
const tasks = parts.flatMap((p) => p.tasks);
|
|
1013
|
+
const byStatus = {};
|
|
1014
|
+
for (const run of runs)
|
|
1015
|
+
bump(byStatus, run.display_status);
|
|
1016
|
+
const ended = runs.filter((run) => ENDED.has(run.display_status));
|
|
1017
|
+
const done = ended.filter((run) => run.display_status === 'done').length;
|
|
1018
|
+
const durations = runs
|
|
1019
|
+
.filter((run) => run.finished_at !== null && run.duration_ms !== null)
|
|
1020
|
+
.map((run) => run.duration_ms)
|
|
1021
|
+
.sort((a, b) => a - b);
|
|
1022
|
+
const tokenRuns = runs.filter((run) => run.tokens !== null);
|
|
1023
|
+
const costRuns = runs.filter((run) => run.cost_usd !== null);
|
|
1024
|
+
const flagKnown = costRuns.some((run) => run.cost_estimated !== undefined);
|
|
1025
|
+
const days = new Map();
|
|
1026
|
+
for (const run of runs) {
|
|
1027
|
+
const date = run.created_at.slice(0, 10);
|
|
1028
|
+
if (!/^\d{4}-\d{2}-\d{2}$/.test(date))
|
|
1029
|
+
continue;
|
|
1030
|
+
let day = days.get(date);
|
|
1031
|
+
if (!day)
|
|
1032
|
+
days.set(date, (day = { date, total: 0, done: 0, failed: 0, interrupted: 0, other: 0 }));
|
|
1033
|
+
day.total++;
|
|
1034
|
+
if (run.display_status === 'done')
|
|
1035
|
+
day.done++;
|
|
1036
|
+
else if (FAILED_RUN.has(run.display_status))
|
|
1037
|
+
day.failed++;
|
|
1038
|
+
else if (run.display_status === 'interrupted')
|
|
1039
|
+
day.interrupted++;
|
|
1040
|
+
else
|
|
1041
|
+
day.other++;
|
|
1042
|
+
}
|
|
1043
|
+
const taskStatus = {};
|
|
1044
|
+
const agents = new Map();
|
|
1045
|
+
const models = {};
|
|
1046
|
+
let modelsNotReported = 0;
|
|
1047
|
+
for (const t of tasks) {
|
|
1048
|
+
bump(taskStatus, t.display_status);
|
|
1049
|
+
let a = agents.get(t.agent);
|
|
1050
|
+
if (!a)
|
|
1051
|
+
agents.set(t.agent, (a = { agent: t.agent, total: 0, done: 0, failed: 0, running: 0, other: 0 }));
|
|
1052
|
+
a.total++;
|
|
1053
|
+
if (t.display_status === 'done')
|
|
1054
|
+
a.done++;
|
|
1055
|
+
else if (FAILED_TASK_STATUSES.includes(t.display_status))
|
|
1056
|
+
a.failed++;
|
|
1057
|
+
else if (RUNNING_TASK_STATUSES.has(t.display_status))
|
|
1058
|
+
a.running++;
|
|
1059
|
+
else
|
|
1060
|
+
a.other++;
|
|
1061
|
+
if (t.model)
|
|
1062
|
+
bump(models, t.model);
|
|
1063
|
+
else
|
|
1064
|
+
modelsNotReported++;
|
|
1065
|
+
}
|
|
1066
|
+
const tiers = {};
|
|
1067
|
+
const mechanisms = {};
|
|
1068
|
+
const runtimes = {};
|
|
1069
|
+
for (const p of parts) {
|
|
1070
|
+
addTally(tiers, p.tiers);
|
|
1071
|
+
addTally(mechanisms, p.mechanisms);
|
|
1072
|
+
addTally(runtimes, p.runtimes);
|
|
1073
|
+
}
|
|
1074
|
+
const tiered = Object.values(tiers).reduce((s, n) => s + n, 0);
|
|
1075
|
+
let dlq = null;
|
|
1076
|
+
let artifacts = null;
|
|
1077
|
+
let reviews = null;
|
|
1078
|
+
let checks = null;
|
|
1079
|
+
for (const p of parts) {
|
|
1080
|
+
if (p.dlq)
|
|
1081
|
+
dlq = { entries: (dlq?.entries ?? 0) + p.dlq.entries, unresolved: (dlq?.unresolved ?? 0) + p.dlq.unresolved };
|
|
1082
|
+
if (p.artifacts !== null)
|
|
1083
|
+
artifacts = (artifacts ?? 0) + p.artifacts;
|
|
1084
|
+
reviews = mergeReviews(reviews, p.reviews);
|
|
1085
|
+
checks = mergeChecks(checks, p.checks);
|
|
1086
|
+
}
|
|
1087
|
+
return {
|
|
1088
|
+
runs: {
|
|
1089
|
+
total: runs.length,
|
|
1090
|
+
alive: runs.filter((run) => run.alive).length,
|
|
1091
|
+
by_status: byStatus,
|
|
1092
|
+
ended: ended.length,
|
|
1093
|
+
done,
|
|
1094
|
+
success_rate: ended.length > 0 ? done / ended.length : null,
|
|
1095
|
+
},
|
|
1096
|
+
duration: {
|
|
1097
|
+
measured: durations.length,
|
|
1098
|
+
avg_ms: durations.length > 0 ? durations.reduce((s, n) => s + n, 0) / durations.length : null,
|
|
1099
|
+
p95_ms: percentile(durations, 0.95),
|
|
1100
|
+
max_ms: durations.length > 0 ? durations[durations.length - 1] : null,
|
|
1101
|
+
},
|
|
1102
|
+
tokens: {
|
|
1103
|
+
total: tokenRuns.length > 0 ? tokenRuns.reduce((s, run) => s + run.tokens, 0) : null,
|
|
1104
|
+
runs_reported: tokenRuns.length,
|
|
1105
|
+
runs_not_reported: runs.length - tokenRuns.length,
|
|
1106
|
+
},
|
|
1107
|
+
cost: {
|
|
1108
|
+
total_usd: costRuns.length > 0 ? costRuns.reduce((s, run) => s + run.cost_usd, 0) : null,
|
|
1109
|
+
estimated: flagKnown ? costRuns.some((run) => run.cost_estimated === true) : undefined,
|
|
1110
|
+
runs_reported: costRuns.length,
|
|
1111
|
+
runs_not_reported: runs.length - costRuns.length,
|
|
1112
|
+
},
|
|
1113
|
+
activity: [...days.values()].sort((a, b) => a.date.localeCompare(b.date)),
|
|
1114
|
+
tasks: { total: tasks.length, retries: tasks.reduce((s, t) => s + t.retries, 0), by_status: taskStatus },
|
|
1115
|
+
agents: [...agents.values()].sort((a, b) => b.total - a.total || a.agent.localeCompare(b.agent)),
|
|
1116
|
+
models: sortedTally(models, 'model', 'tasks'),
|
|
1117
|
+
models_not_reported: modelsNotReported,
|
|
1118
|
+
tiers: sortedTally(tiers, 'tier', 'tasks'),
|
|
1119
|
+
tiers_not_recorded: Math.max(0, tasks.length - tiered),
|
|
1120
|
+
mechanisms: sortedTally(mechanisms, 'mechanism', 'attempts'),
|
|
1121
|
+
runtimes: sortedTally(runtimes, 'runtime', 'attempts'),
|
|
1122
|
+
reviews,
|
|
1123
|
+
checks,
|
|
1124
|
+
dlq,
|
|
1125
|
+
artifacts,
|
|
1126
|
+
};
|
|
1127
|
+
}
|
|
1128
|
+
/** The overview of one project. */
|
|
1129
|
+
export function readOverview(projectRoot) {
|
|
1130
|
+
return overviewFrom([readOverviewParts(projectRoot)]);
|
|
1131
|
+
}
|
|
1132
|
+
//# sourceMappingURL=read-model.js.map
|