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.
Files changed (486) hide show
  1. package/README.md +16 -10
  2. package/bin/cli.mjs +8 -9
  3. package/dist/cli/agent-roster.test.js +0 -48
  4. package/dist/cli/agent-roster.test.js.map +1 -1
  5. package/dist/cli/boundary.test.js +9 -7
  6. package/dist/cli/boundary.test.js.map +1 -1
  7. package/dist/cli/convoy/artifacts.d.ts +9 -2
  8. package/dist/cli/convoy/artifacts.d.ts.map +1 -1
  9. package/dist/cli/convoy/artifacts.js +13 -10
  10. package/dist/cli/convoy/artifacts.js.map +1 -1
  11. package/dist/cli/convoy/artifacts.test.js +4 -2
  12. package/dist/cli/convoy/artifacts.test.js.map +1 -1
  13. package/dist/cli/convoy/engine.d.ts +53 -23
  14. package/dist/cli/convoy/engine.d.ts.map +1 -1
  15. package/dist/cli/convoy/engine.git.test.d.ts +2 -0
  16. package/dist/cli/convoy/engine.git.test.d.ts.map +1 -0
  17. package/dist/cli/convoy/engine.git.test.js +435 -0
  18. package/dist/cli/convoy/engine.git.test.js.map +1 -0
  19. package/dist/cli/convoy/engine.js +1746 -2305
  20. package/dist/cli/convoy/engine.js.map +1 -1
  21. package/dist/cli/convoy/engine.test.js +698 -678
  22. package/dist/cli/convoy/engine.test.js.map +1 -1
  23. package/dist/cli/convoy/event-schemas.d.ts +2 -0
  24. package/dist/cli/convoy/event-schemas.d.ts.map +1 -1
  25. package/dist/cli/convoy/event-schemas.js +59 -57
  26. package/dist/cli/convoy/event-schemas.js.map +1 -1
  27. package/dist/cli/convoy/events.d.ts +4 -1
  28. package/dist/cli/convoy/events.d.ts.map +1 -1
  29. package/dist/cli/convoy/events.js +69 -84
  30. package/dist/cli/convoy/events.js.map +1 -1
  31. package/dist/cli/convoy/events.test.js +50 -9
  32. package/dist/cli/convoy/events.test.js.map +1 -1
  33. package/dist/cli/convoy/gates.d.ts +9 -4
  34. package/dist/cli/convoy/gates.d.ts.map +1 -1
  35. package/dist/cli/convoy/gates.js +29 -14
  36. package/dist/cli/convoy/gates.js.map +1 -1
  37. package/dist/cli/convoy/isolation.d.ts +32 -6
  38. package/dist/cli/convoy/isolation.d.ts.map +1 -1
  39. package/dist/cli/convoy/isolation.js +72 -34
  40. package/dist/cli/convoy/isolation.js.map +1 -1
  41. package/dist/cli/convoy/isolation.test.js +66 -42
  42. package/dist/cli/convoy/isolation.test.js.map +1 -1
  43. package/dist/cli/convoy/lock.d.ts.map +1 -1
  44. package/dist/cli/convoy/lock.js +25 -10
  45. package/dist/cli/convoy/lock.js.map +1 -1
  46. package/dist/cli/convoy/lock.test.js +12 -0
  47. package/dist/cli/convoy/lock.test.js.map +1 -1
  48. package/dist/cli/convoy/merge.d.ts +21 -4
  49. package/dist/cli/convoy/merge.d.ts.map +1 -1
  50. package/dist/cli/convoy/merge.js +69 -53
  51. package/dist/cli/convoy/merge.js.map +1 -1
  52. package/dist/cli/convoy/merge.test.js +23 -1
  53. package/dist/cli/convoy/merge.test.js.map +1 -1
  54. package/dist/cli/convoy/progress.d.ts +35 -0
  55. package/dist/cli/convoy/progress.d.ts.map +1 -0
  56. package/dist/cli/convoy/progress.js +103 -0
  57. package/dist/cli/convoy/progress.js.map +1 -0
  58. package/dist/cli/convoy/progress.test.d.ts +2 -0
  59. package/dist/cli/convoy/progress.test.d.ts.map +1 -0
  60. package/dist/cli/convoy/progress.test.js +53 -0
  61. package/dist/cli/convoy/progress.test.js.map +1 -0
  62. package/dist/cli/convoy/read-model.d.ts +468 -0
  63. package/dist/cli/convoy/read-model.d.ts.map +1 -0
  64. package/dist/cli/convoy/read-model.js +1132 -0
  65. package/dist/cli/convoy/read-model.js.map +1 -0
  66. package/dist/cli/convoy/read-model.test.d.ts +2 -0
  67. package/dist/cli/convoy/read-model.test.d.ts.map +1 -0
  68. package/dist/cli/convoy/read-model.test.js +609 -0
  69. package/dist/cli/convoy/read-model.test.js.map +1 -0
  70. package/dist/cli/convoy/redact.d.ts +34 -0
  71. package/dist/cli/convoy/redact.d.ts.map +1 -0
  72. package/dist/cli/convoy/redact.js +66 -0
  73. package/dist/cli/convoy/redact.js.map +1 -0
  74. package/dist/cli/convoy/redact.test.d.ts +2 -0
  75. package/dist/cli/convoy/redact.test.d.ts.map +1 -0
  76. package/dist/cli/convoy/redact.test.js +43 -0
  77. package/dist/cli/convoy/redact.test.js.map +1 -0
  78. package/dist/cli/convoy/reviewer.d.ts +65 -0
  79. package/dist/cli/convoy/reviewer.d.ts.map +1 -0
  80. package/dist/cli/convoy/reviewer.js +141 -0
  81. package/dist/cli/convoy/reviewer.js.map +1 -0
  82. package/dist/cli/convoy/reviewer.test.d.ts +2 -0
  83. package/dist/cli/convoy/reviewer.test.d.ts.map +1 -0
  84. package/dist/cli/convoy/reviewer.test.js +96 -0
  85. package/dist/cli/convoy/reviewer.test.js.map +1 -0
  86. package/dist/cli/convoy/schedule.d.ts +30 -0
  87. package/dist/cli/convoy/schedule.d.ts.map +1 -0
  88. package/dist/cli/convoy/schedule.js +111 -0
  89. package/dist/cli/convoy/schedule.js.map +1 -0
  90. package/dist/cli/convoy/schedule.test.d.ts +2 -0
  91. package/dist/cli/convoy/schedule.test.d.ts.map +1 -0
  92. package/dist/cli/convoy/schedule.test.js +45 -0
  93. package/dist/cli/convoy/schedule.test.js.map +1 -0
  94. package/dist/cli/convoy/spec-builder.d.ts +120 -30
  95. package/dist/cli/convoy/spec-builder.d.ts.map +1 -1
  96. package/dist/cli/convoy/spec-builder.js +438 -114
  97. package/dist/cli/convoy/spec-builder.js.map +1 -1
  98. package/dist/cli/convoy/spec-builder.test.js +419 -435
  99. package/dist/cli/convoy/spec-builder.test.js.map +1 -1
  100. package/dist/cli/convoy/spec-types.d.ts +46 -92
  101. package/dist/cli/convoy/spec-types.d.ts.map +1 -1
  102. package/dist/cli/convoy/store.d.ts +6 -1
  103. package/dist/cli/convoy/store.d.ts.map +1 -1
  104. package/dist/cli/convoy/store.js +111 -15
  105. package/dist/cli/convoy/store.js.map +1 -1
  106. package/dist/cli/convoy/store.test.js +59 -13
  107. package/dist/cli/convoy/store.test.js.map +1 -1
  108. package/dist/cli/convoy/types.d.ts +76 -113
  109. package/dist/cli/convoy/types.d.ts.map +1 -1
  110. package/dist/cli/convoy/types.js +6 -13
  111. package/dist/cli/convoy/types.js.map +1 -1
  112. package/dist/cli/convoy/worktree.d.ts +88 -3
  113. package/dist/cli/convoy/worktree.d.ts.map +1 -1
  114. package/dist/cli/convoy/worktree.js +282 -56
  115. package/dist/cli/convoy/worktree.js.map +1 -1
  116. package/dist/cli/convoy/worktree.test.js +132 -1
  117. package/dist/cli/convoy/worktree.test.js.map +1 -1
  118. package/dist/cli/convoy-args.test.js +9 -27
  119. package/dist/cli/convoy-args.test.js.map +1 -1
  120. package/dist/cli/convoy-cmd.d.ts +31 -6
  121. package/dist/cli/convoy-cmd.d.ts.map +1 -1
  122. package/dist/cli/convoy-cmd.js +150 -201
  123. package/dist/cli/convoy-cmd.js.map +1 -1
  124. package/dist/cli/convoy-cmd.test.d.ts +2 -0
  125. package/dist/cli/convoy-cmd.test.d.ts.map +1 -0
  126. package/dist/cli/convoy-cmd.test.js +144 -0
  127. package/dist/cli/convoy-cmd.test.js.map +1 -0
  128. package/dist/cli/dashboard.d.ts +24 -11
  129. package/dist/cli/dashboard.d.ts.map +1 -1
  130. package/dist/cli/dashboard.js +241 -303
  131. package/dist/cli/dashboard.js.map +1 -1
  132. package/dist/cli/dashboard.test.d.ts +2 -0
  133. package/dist/cli/dashboard.test.d.ts.map +1 -0
  134. package/dist/cli/dashboard.test.js +340 -0
  135. package/dist/cli/dashboard.test.js.map +1 -0
  136. package/dist/cli/dispatcher.test.js +35 -2
  137. package/dist/cli/dispatcher.test.js.map +1 -1
  138. package/dist/cli/docs-accuracy.test.js +3 -3
  139. package/dist/cli/docs-accuracy.test.js.map +1 -1
  140. package/dist/cli/log.d.ts +39 -0
  141. package/dist/cli/log.d.ts.map +1 -1
  142. package/dist/cli/log.js +267 -93
  143. package/dist/cli/log.js.map +1 -1
  144. package/dist/cli/log.test.d.ts +2 -0
  145. package/dist/cli/log.test.d.ts.map +1 -0
  146. package/dist/cli/log.test.js +208 -0
  147. package/dist/cli/log.test.js.map +1 -0
  148. package/dist/cli/nearest.d.ts +18 -0
  149. package/dist/cli/nearest.d.ts.map +1 -0
  150. package/dist/cli/nearest.js +38 -0
  151. package/dist/cli/nearest.js.map +1 -0
  152. package/dist/cli/nearest.test.d.ts +2 -0
  153. package/dist/cli/nearest.test.d.ts.map +1 -0
  154. package/dist/cli/nearest.test.js +24 -0
  155. package/dist/cli/nearest.test.js.map +1 -0
  156. package/dist/cli/pipeline.d.ts +61 -0
  157. package/dist/cli/pipeline.d.ts.map +1 -1
  158. package/dist/cli/pipeline.flow.test.d.ts +2 -0
  159. package/dist/cli/pipeline.flow.test.d.ts.map +1 -0
  160. package/dist/cli/pipeline.flow.test.js +524 -0
  161. package/dist/cli/pipeline.flow.test.js.map +1 -0
  162. package/dist/cli/pipeline.js +471 -690
  163. package/dist/cli/pipeline.js.map +1 -1
  164. package/dist/cli/plan.d.ts +82 -31
  165. package/dist/cli/plan.d.ts.map +1 -1
  166. package/dist/cli/plan.js +167 -507
  167. package/dist/cli/plan.js.map +1 -1
  168. package/dist/cli/plan.test.d.ts +2 -0
  169. package/dist/cli/plan.test.d.ts.map +1 -0
  170. package/dist/cli/plan.test.js +158 -0
  171. package/dist/cli/plan.test.js.map +1 -0
  172. package/dist/cli/run/adapters/agent-process.d.ts +82 -0
  173. package/dist/cli/run/adapters/agent-process.d.ts.map +1 -0
  174. package/dist/cli/run/adapters/agent-process.js +224 -0
  175. package/dist/cli/run/adapters/agent-process.js.map +1 -0
  176. package/dist/cli/run/adapters/agent-process.test.d.ts +2 -0
  177. package/dist/cli/run/adapters/agent-process.test.d.ts.map +1 -0
  178. package/dist/cli/run/adapters/agent-process.test.js +159 -0
  179. package/dist/cli/run/adapters/agent-process.test.js.map +1 -0
  180. package/dist/cli/run/adapters/claude.d.ts +53 -2
  181. package/dist/cli/run/adapters/claude.d.ts.map +1 -1
  182. package/dist/cli/run/adapters/claude.js +147 -171
  183. package/dist/cli/run/adapters/claude.js.map +1 -1
  184. package/dist/cli/run/adapters/claude.test.js +197 -254
  185. package/dist/cli/run/adapters/claude.test.js.map +1 -1
  186. package/dist/cli/run/adapters/codex.d.ts +25 -2
  187. package/dist/cli/run/adapters/codex.d.ts.map +1 -1
  188. package/dist/cli/run/adapters/codex.js +113 -81
  189. package/dist/cli/run/adapters/codex.js.map +1 -1
  190. package/dist/cli/run/adapters/codex.test.js +116 -95
  191. package/dist/cli/run/adapters/codex.test.js.map +1 -1
  192. package/dist/cli/run/adapters/copilot.d.ts +35 -1
  193. package/dist/cli/run/adapters/copilot.d.ts.map +1 -1
  194. package/dist/cli/run/adapters/copilot.js +104 -287
  195. package/dist/cli/run/adapters/copilot.js.map +1 -1
  196. package/dist/cli/run/adapters/copilot.test.js +122 -282
  197. package/dist/cli/run/adapters/copilot.test.js.map +1 -1
  198. package/dist/cli/run/adapters/cursor.d.ts +25 -7
  199. package/dist/cli/run/adapters/cursor.d.ts.map +1 -1
  200. package/dist/cli/run/adapters/cursor.js +103 -156
  201. package/dist/cli/run/adapters/cursor.js.map +1 -1
  202. package/dist/cli/run/adapters/cursor.test.js +106 -218
  203. package/dist/cli/run/adapters/cursor.test.js.map +1 -1
  204. package/dist/cli/run/adapters/index.d.ts +34 -5
  205. package/dist/cli/run/adapters/index.d.ts.map +1 -1
  206. package/dist/cli/run/adapters/index.js +147 -21
  207. package/dist/cli/run/adapters/index.js.map +1 -1
  208. package/dist/cli/run/adapters/index.test.d.ts +2 -0
  209. package/dist/cli/run/adapters/index.test.d.ts.map +1 -0
  210. package/dist/cli/run/adapters/index.test.js +129 -0
  211. package/dist/cli/run/adapters/index.test.js.map +1 -0
  212. package/dist/cli/run/adapters/opencode.d.ts +25 -9
  213. package/dist/cli/run/adapters/opencode.d.ts.map +1 -1
  214. package/dist/cli/run/adapters/opencode.js +136 -152
  215. package/dist/cli/run/adapters/opencode.js.map +1 -1
  216. package/dist/cli/run/adapters/opencode.test.js +99 -218
  217. package/dist/cli/run/adapters/opencode.test.js.map +1 -1
  218. package/dist/cli/run/adapters/permission-modes.d.ts +47 -4
  219. package/dist/cli/run/adapters/permission-modes.d.ts.map +1 -1
  220. package/dist/cli/run/adapters/permission-modes.js +113 -37
  221. package/dist/cli/run/adapters/permission-modes.js.map +1 -1
  222. package/dist/cli/run/adapters/permission-modes.test.js +55 -40
  223. package/dist/cli/run/adapters/permission-modes.test.js.map +1 -1
  224. package/dist/cli/run/adapters/stub-cli.test-helper.d.ts +22 -0
  225. package/dist/cli/run/adapters/stub-cli.test-helper.d.ts.map +1 -0
  226. package/dist/cli/run/adapters/stub-cli.test-helper.js +73 -0
  227. package/dist/cli/run/adapters/stub-cli.test-helper.js.map +1 -0
  228. package/dist/cli/run/platform.d.ts +52 -0
  229. package/dist/cli/run/platform.d.ts.map +1 -0
  230. package/dist/cli/run/platform.js +207 -0
  231. package/dist/cli/run/platform.js.map +1 -0
  232. package/dist/cli/run/platform.test.d.ts +2 -0
  233. package/dist/cli/run/platform.test.d.ts.map +1 -0
  234. package/dist/cli/run/platform.test.js +119 -0
  235. package/dist/cli/run/platform.test.js.map +1 -0
  236. package/dist/cli/run/schema.d.ts +6 -8
  237. package/dist/cli/run/schema.d.ts.map +1 -1
  238. package/dist/cli/run/schema.js +44 -68
  239. package/dist/cli/run/schema.js.map +1 -1
  240. package/dist/cli/run/schema.test.js +59 -279
  241. package/dist/cli/run/schema.test.js.map +1 -1
  242. package/dist/cli/run.d.ts +34 -56
  243. package/dist/cli/run.d.ts.map +1 -1
  244. package/dist/cli/run.js +379 -1132
  245. package/dist/cli/run.js.map +1 -1
  246. package/dist/cli/run.test.d.ts +2 -0
  247. package/dist/cli/run.test.d.ts.map +1 -0
  248. package/dist/cli/run.test.js +318 -0
  249. package/dist/cli/run.test.js.map +1 -0
  250. package/dist/cli/team-config.d.ts.map +1 -1
  251. package/dist/cli/team-config.js +2 -21
  252. package/dist/cli/team-config.js.map +1 -1
  253. package/dist/cli/tiers.test.js +4 -13
  254. package/dist/cli/tiers.test.js.map +1 -1
  255. package/package.json +3 -10
  256. package/src/cli/agent-roster.test.ts +0 -55
  257. package/src/cli/boundary.test.ts +9 -7
  258. package/src/cli/convoy/TELEMETRY.md +131 -125
  259. package/src/cli/convoy/artifacts.test.ts +4 -2
  260. package/src/cli/convoy/artifacts.ts +13 -12
  261. package/src/cli/convoy/engine.git.test.ts +462 -0
  262. package/src/cli/convoy/engine.test.ts +817 -850
  263. package/src/cli/convoy/engine.ts +1864 -2596
  264. package/src/cli/convoy/event-schemas.ts +63 -59
  265. package/src/cli/convoy/events.test.ts +58 -9
  266. package/src/cli/convoy/events.ts +69 -91
  267. package/src/cli/convoy/gates.ts +31 -12
  268. package/src/cli/convoy/isolation.test.ts +76 -43
  269. package/src/cli/convoy/isolation.ts +100 -38
  270. package/src/cli/convoy/lock.test.ts +16 -0
  271. package/src/cli/convoy/lock.ts +25 -8
  272. package/src/cli/convoy/merge.test.ts +25 -1
  273. package/src/cli/convoy/merge.ts +74 -61
  274. package/src/cli/convoy/progress.test.ts +59 -0
  275. package/src/cli/convoy/progress.ts +121 -0
  276. package/src/cli/convoy/read-model.test.ts +685 -0
  277. package/src/cli/convoy/read-model.ts +1469 -0
  278. package/src/cli/convoy/redact.test.ts +49 -0
  279. package/src/cli/convoy/redact.ts +73 -0
  280. package/src/cli/convoy/reviewer.test.ts +112 -0
  281. package/src/cli/convoy/reviewer.ts +196 -0
  282. package/src/cli/convoy/schedule.test.ts +56 -0
  283. package/src/cli/convoy/schedule.ts +109 -0
  284. package/src/cli/convoy/spec-builder.test.ts +460 -464
  285. package/src/cli/convoy/spec-builder.ts +460 -129
  286. package/src/cli/convoy/spec-types.ts +46 -108
  287. package/src/cli/convoy/store.test.ts +64 -13
  288. package/src/cli/convoy/store.ts +143 -33
  289. package/src/cli/convoy/types.ts +59 -71
  290. package/src/cli/convoy/worktree.test.ts +140 -1
  291. package/src/cli/convoy/worktree.ts +311 -61
  292. package/src/cli/convoy-args.test.ts +10 -30
  293. package/src/cli/convoy-cmd.test.ts +163 -0
  294. package/src/cli/convoy-cmd.ts +173 -216
  295. package/src/cli/dashboard/dashboard.css +2086 -0
  296. package/src/cli/dashboard/dashboard.js +1687 -0
  297. package/src/cli/dashboard/index.html +307 -0
  298. package/src/cli/dashboard.test.ts +382 -0
  299. package/src/cli/dashboard.ts +243 -339
  300. package/src/cli/dispatcher.test.ts +36 -2
  301. package/src/cli/docs-accuracy.test.ts +3 -3
  302. package/src/cli/log.test.ts +228 -0
  303. package/src/cli/log.ts +302 -83
  304. package/src/cli/nearest.test.ts +27 -0
  305. package/src/cli/nearest.ts +38 -0
  306. package/src/cli/pipeline.flow.test.ts +607 -0
  307. package/src/cli/pipeline.ts +544 -759
  308. package/src/cli/plan.test.ts +193 -0
  309. package/src/cli/plan.ts +209 -545
  310. package/src/cli/run/adapters/agent-process.test.ts +175 -0
  311. package/src/cli/run/adapters/agent-process.ts +252 -0
  312. package/src/cli/run/adapters/claude.test.ts +205 -260
  313. package/src/cli/run/adapters/claude.ts +151 -162
  314. package/src/cli/run/adapters/codex.test.ts +120 -100
  315. package/src/cli/run/adapters/codex.ts +115 -91
  316. package/src/cli/run/adapters/copilot.test.ts +135 -306
  317. package/src/cli/run/adapters/copilot.ts +105 -274
  318. package/src/cli/run/adapters/cursor.test.ts +111 -220
  319. package/src/cli/run/adapters/cursor.ts +105 -156
  320. package/src/cli/run/adapters/index.test.ts +148 -0
  321. package/src/cli/run/adapters/index.ts +168 -20
  322. package/src/cli/run/adapters/opencode.test.ts +106 -227
  323. package/src/cli/run/adapters/opencode.ts +139 -151
  324. package/src/cli/run/adapters/permission-modes.test.ts +63 -41
  325. package/src/cli/run/adapters/permission-modes.ts +118 -37
  326. package/src/cli/run/adapters/stub-cli.test-helper.ts +88 -0
  327. package/src/cli/run/platform.test.ts +128 -0
  328. package/src/cli/run/platform.ts +213 -0
  329. package/src/cli/run/schema.test.ts +62 -344
  330. package/src/cli/run/schema.ts +48 -78
  331. package/src/cli/run.test.ts +351 -0
  332. package/src/cli/run.ts +366 -1151
  333. package/src/cli/team-config.ts +2 -21
  334. package/src/cli/tiers.test.ts +4 -17
  335. package/src/orchestrator/agents/team-lead.agent.md +1 -1
  336. package/src/orchestrator/prompts/assess-complexity.prompt.md +43 -26
  337. package/src/orchestrator/prompts/brainstorm.prompt.md +1 -1
  338. package/src/orchestrator/prompts/bug-fix.prompt.md +2 -2
  339. package/src/orchestrator/prompts/fix-convoy.prompt.md +43 -29
  340. package/src/orchestrator/prompts/fix-prd.prompt.md +26 -22
  341. package/src/orchestrator/prompts/generate-convoy.prompt.md +139 -147
  342. package/src/orchestrator/prompts/generate-prd.prompt.md +75 -68
  343. package/src/orchestrator/prompts/implement-feature.prompt.md +2 -2
  344. package/src/orchestrator/prompts/validate-convoy.prompt.md +29 -28
  345. package/src/orchestrator/prompts/validate-prd.prompt.md +28 -21
  346. package/src/orchestrator/skills/agent-hooks/HOOKS-REFERENCE.md +3 -3
  347. package/src/orchestrator/skills/agent-hooks/SKILL.md +1 -1
  348. package/src/orchestrator/skills/fast-review/SKILL.md +3 -1
  349. package/src/orchestrator/skills/orchestration-protocols/SKILL.md +7 -8
  350. package/dist/cli/convoy/dag-analysis.d.ts +0 -39
  351. package/dist/cli/convoy/dag-analysis.d.ts.map +0 -1
  352. package/dist/cli/convoy/dag-analysis.js +0 -279
  353. package/dist/cli/convoy/dag-analysis.js.map +0 -1
  354. package/dist/cli/convoy/dag-analysis.test.d.ts +0 -2
  355. package/dist/cli/convoy/dag-analysis.test.d.ts.map +0 -1
  356. package/dist/cli/convoy/dag-analysis.test.js +0 -289
  357. package/dist/cli/convoy/dag-analysis.test.js.map +0 -1
  358. package/dist/cli/convoy/formula.d.ts +0 -19
  359. package/dist/cli/convoy/formula.d.ts.map +0 -1
  360. package/dist/cli/convoy/formula.js +0 -142
  361. package/dist/cli/convoy/formula.js.map +0 -1
  362. package/dist/cli/convoy/formula.test.d.ts +0 -2
  363. package/dist/cli/convoy/formula.test.d.ts.map +0 -1
  364. package/dist/cli/convoy/formula.test.js +0 -342
  365. package/dist/cli/convoy/formula.test.js.map +0 -1
  366. package/dist/cli/convoy/health.d.ts +0 -34
  367. package/dist/cli/convoy/health.d.ts.map +0 -1
  368. package/dist/cli/convoy/health.js +0 -123
  369. package/dist/cli/convoy/health.js.map +0 -1
  370. package/dist/cli/convoy/health.test.d.ts +0 -2
  371. package/dist/cli/convoy/health.test.d.ts.map +0 -1
  372. package/dist/cli/convoy/health.test.js +0 -448
  373. package/dist/cli/convoy/health.test.js.map +0 -1
  374. package/dist/cli/convoy/last-run.d.ts +0 -53
  375. package/dist/cli/convoy/last-run.d.ts.map +0 -1
  376. package/dist/cli/convoy/last-run.js +0 -54
  377. package/dist/cli/convoy/last-run.js.map +0 -1
  378. package/dist/cli/convoy/last-run.test.d.ts +0 -2
  379. package/dist/cli/convoy/last-run.test.d.ts.map +0 -1
  380. package/dist/cli/convoy/last-run.test.js +0 -110
  381. package/dist/cli/convoy/last-run.test.js.map +0 -1
  382. package/dist/cli/convoy/pipeline.d.ts +0 -41
  383. package/dist/cli/convoy/pipeline.d.ts.map +0 -1
  384. package/dist/cli/convoy/pipeline.js +0 -414
  385. package/dist/cli/convoy/pipeline.js.map +0 -1
  386. package/dist/cli/convoy/pipeline.test.d.ts +0 -2
  387. package/dist/cli/convoy/pipeline.test.d.ts.map +0 -1
  388. package/dist/cli/convoy/pipeline.test.js +0 -837
  389. package/dist/cli/convoy/pipeline.test.js.map +0 -1
  390. package/dist/cli/convoy/review-stages.d.ts +0 -9
  391. package/dist/cli/convoy/review-stages.d.ts.map +0 -1
  392. package/dist/cli/convoy/review-stages.js +0 -134
  393. package/dist/cli/convoy/review-stages.js.map +0 -1
  394. package/dist/cli/convoy/review-stages.test.d.ts +0 -2
  395. package/dist/cli/convoy/review-stages.test.d.ts.map +0 -1
  396. package/dist/cli/convoy/review-stages.test.js +0 -197
  397. package/dist/cli/convoy/review-stages.test.js.map +0 -1
  398. package/dist/cli/run/executor.d.ts +0 -15
  399. package/dist/cli/run/executor.d.ts.map +0 -1
  400. package/dist/cli/run/executor.js +0 -249
  401. package/dist/cli/run/executor.js.map +0 -1
  402. package/dist/cli/run/executor.test.d.ts +0 -2
  403. package/dist/cli/run/executor.test.d.ts.map +0 -1
  404. package/dist/cli/run/executor.test.js +0 -297
  405. package/dist/cli/run/executor.test.js.map +0 -1
  406. package/dist/cli/run/reporter.d.ts +0 -10
  407. package/dist/cli/run/reporter.d.ts.map +0 -1
  408. package/dist/cli/run/reporter.js +0 -142
  409. package/dist/cli/run/reporter.js.map +0 -1
  410. package/dist/cli/run-dry-run.test.d.ts +0 -2
  411. package/dist/cli/run-dry-run.test.d.ts.map +0 -1
  412. package/dist/cli/run-dry-run.test.js +0 -83
  413. package/dist/cli/run-dry-run.test.js.map +0 -1
  414. package/dist/cli/run-executor-flags.test.d.ts +0 -2
  415. package/dist/cli/run-executor-flags.test.d.ts.map +0 -1
  416. package/dist/cli/run-executor-flags.test.js +0 -31
  417. package/dist/cli/run-executor-flags.test.js.map +0 -1
  418. package/dist/cli/run-finish.test.d.ts +0 -2
  419. package/dist/cli/run-finish.test.d.ts.map +0 -1
  420. package/dist/cli/run-finish.test.js +0 -77
  421. package/dist/cli/run-finish.test.js.map +0 -1
  422. package/dist/cli/watch.d.ts +0 -15
  423. package/dist/cli/watch.d.ts.map +0 -1
  424. package/dist/cli/watch.js +0 -277
  425. package/dist/cli/watch.js.map +0 -1
  426. package/dist/dashboard/scripts/etl.d.ts +0 -10
  427. package/dist/dashboard/scripts/etl.d.ts.map +0 -1
  428. package/dist/dashboard/scripts/etl.js +0 -141
  429. package/dist/dashboard/scripts/etl.js.map +0 -1
  430. package/src/cli/convoy/dag-analysis.test.ts +0 -349
  431. package/src/cli/convoy/dag-analysis.ts +0 -367
  432. package/src/cli/convoy/formula.test.ts +0 -404
  433. package/src/cli/convoy/formula.ts +0 -174
  434. package/src/cli/convoy/health.test.ts +0 -519
  435. package/src/cli/convoy/health.ts +0 -189
  436. package/src/cli/convoy/last-run.test.ts +0 -130
  437. package/src/cli/convoy/last-run.ts +0 -87
  438. package/src/cli/convoy/pipeline.test.ts +0 -999
  439. package/src/cli/convoy/pipeline.ts +0 -492
  440. package/src/cli/convoy/review-stages.test.ts +0 -235
  441. package/src/cli/convoy/review-stages.ts +0 -166
  442. package/src/cli/run/executor.test.ts +0 -338
  443. package/src/cli/run/executor.ts +0 -292
  444. package/src/cli/run/reporter.ts +0 -160
  445. package/src/cli/run-dry-run.test.ts +0 -97
  446. package/src/cli/run-executor-flags.test.ts +0 -38
  447. package/src/cli/run-finish.test.ts +0 -91
  448. package/src/cli/watch.ts +0 -295
  449. package/src/dashboard/astro.config.mjs +0 -6
  450. package/src/dashboard/dist/_astro/index.CADNhRPS.css +0 -1
  451. package/src/dashboard/dist/data/.gitkeep +0 -0
  452. package/src/dashboard/dist/data/convoy-list.json +0 -1
  453. package/src/dashboard/dist/data/overall-stats.json +0 -29
  454. package/src/dashboard/dist/index.html +0 -1963
  455. package/src/dashboard/node_modules/.vite/deps/_metadata.json +0 -31
  456. package/src/dashboard/node_modules/.vite/deps/astro___aria-query.js +0 -6776
  457. package/src/dashboard/node_modules/.vite/deps/astro___aria-query.js.map +0 -7
  458. package/src/dashboard/node_modules/.vite/deps/astro___axobject-query.js +0 -3754
  459. package/src/dashboard/node_modules/.vite/deps/astro___axobject-query.js.map +0 -7
  460. package/src/dashboard/node_modules/.vite/deps/astro___cssesc.js +0 -99
  461. package/src/dashboard/node_modules/.vite/deps/astro___cssesc.js.map +0 -7
  462. package/src/dashboard/node_modules/.vite/deps/chunk-BUSYA2B4.js +0 -8
  463. package/src/dashboard/node_modules/.vite/deps/chunk-BUSYA2B4.js.map +0 -7
  464. package/src/dashboard/node_modules/.vite/deps/package.json +0 -3
  465. package/src/dashboard/package-lock.json +0 -6
  466. package/src/dashboard/public/data/.gitkeep +0 -0
  467. package/src/dashboard/public/data/convoy-list.json +0 -1
  468. package/src/dashboard/public/data/overall-stats.json +0 -29
  469. package/src/dashboard/public/icon-192.png +0 -0
  470. package/src/dashboard/scripts/etl.test.ts +0 -166
  471. package/src/dashboard/scripts/etl.ts +0 -170
  472. package/src/dashboard/scripts/generate-demo-db.test.ts +0 -30
  473. package/src/dashboard/scripts/generate-demo-db.ts +0 -529
  474. package/src/dashboard/scripts/integration-test.ts +0 -504
  475. package/src/dashboard/scripts/verify-demo-data.sh +0 -51
  476. package/src/dashboard/seed-data/delegations.ndjson +0 -35
  477. package/src/dashboard/seed-data/events.ndjson +0 -104
  478. package/src/dashboard/seed-data/panels.ndjson +0 -13
  479. package/src/dashboard/seed-data/reviews.ndjson +0 -6
  480. package/src/dashboard/seed-data/sessions.ndjson +0 -50
  481. package/src/dashboard/src/env.d.ts +0 -1
  482. package/src/dashboard/src/layouts/Layout.astro +0 -25
  483. package/src/dashboard/src/pages/index.astro +0 -2313
  484. package/src/dashboard/src/styles/dashboard.css +0 -2943
  485. package/src/dashboard/tsconfig.json +0 -6
  486. /package/src/{dashboard/dist → cli/dashboard}/icon-192.png +0 -0
@@ -1,1963 +0,0 @@
1
- <!DOCTYPE html><html lang="en"> <head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Observability Dashboard — OpenCastle</title><meta name="description" content="Real-time observability for OpenCastle multi-agent orchestration — sessions, delegations, model tiers, and quality gates."><meta name="theme-color" content="#0a0a0f"><link rel="icon" type="image/png" sizes="192x192" href="/icon-192.png"><link rel="stylesheet" href="/_astro/index.CADNhRPS.css"></head> <body> <script>(function(){const overallStats = {"convoyCounts":{"total":0,"running":0,"done":0,"failed":0,"gate_failed":0},"durationStats":{"avg_sec":null,"p95_sec":null,"max_sec":null},"tokenCostTotals":{"total_tokens":0,"total_cost_usd":0},"topAgents":[],"topModels":[],"dlqSummary":{"count":0,"top_failure_types":[]},"taskTotals":{"totalTasks":0,"totalRetries":0},"activityTimeline":[]};
2
- const convoyList = [];
3
-
4
- window.__DASHBOARD_DATA__ = { overallStats, convoyList }
5
- })();</script> <header class="dash-header"> <div class="dash-header__inner"> <div class="dash-header__brand"> <a href="https://www.opencastle.dev/" class="dash-header__logo-link"> <img class="dash-header__icon" src="/icon-192.png" alt="OpenCastle" width="28" height="28"> </a> <h1 class="dash-header__title">Observability Dashboard</h1> </div> <div class="dash-header__actions"> <button class="dash-btn dash-btn--ghost" id="export-btn" type="button" title="Export data as JSON" aria-label="Export dashboard data as JSON"> <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"></path><polyline points="7 10 12 15 17 10"></polyline><line x1="12" y1="15" x2="12" y2="3"></line></svg>
6
- Export
7
- </button> </div> </div> </header> <div class="dash-layout"> <!-- Sidebar Navigation --> <nav class="dash-sidebar" id="dash-sidebar"> <ul class="dash-sidebar__list"> <li><a class="dash-sidebar__link dash-sidebar__link--active" href="#overall-section" data-section="overall-section" data-view="home" aria-label="Overview section">Overview</a></li> <li><a class="dash-sidebar__link" href="#convoy-list-section" data-section="convoy-list-section" data-view="home" aria-label="Convoys section">Convoys</a></li> <li><a class="dash-sidebar__link" href="#activity-timeline-section" data-section="activity-timeline-section" data-view="home" aria-label="Activity Timeline section">Activity</a></li> <li><a class="dash-sidebar__link" href="#sessions-section" data-section="sessions-section" data-view="home" aria-label="Sessions section">Sessions</a></li> <li><a class="dash-sidebar__link" href="#tasks-section" data-section="tasks-section" data-view="detail" aria-label="Tasks section">Tasks</a></li> <li><a class="dash-sidebar__link" href="#pipeline-section" data-section="pipeline-section" data-view="detail" aria-label="Pipeline section">Pipeline</a></li> <li><a class="dash-sidebar__link" href="#agent-section" data-section="agent-section" data-view="detail" aria-label="Agents section">Agents</a></li> <li><a class="dash-sidebar__link" href="#tier-section" data-section="tier-section" data-view="detail" aria-label="Tiers section">Tiers</a></li> <li><a class="dash-sidebar__link" href="#model-section" data-section="model-section" data-view="detail" aria-label="Models section">Models</a></li> <li><a class="dash-sidebar__link" href="#quality-section" data-section="quality-section" data-view="detail" aria-label="Quality section">Quality</a></li> <li><a class="dash-sidebar__link" href="#reliability-section" data-section="reliability-section" data-view="detail" aria-label="Reliability section">Reliability</a></li> <li><a class="dash-sidebar__link" href="#drift-section" data-section="drift-section" data-view="detail" aria-label="Drift section">Drift</a></li> <li><a class="dash-sidebar__link" href="#outputs-section" data-section="outputs-section" data-view="detail" aria-label="Outputs section">Outputs</a></li> <li><a class="dash-sidebar__link" href="#execution-section" data-section="execution-section" data-view="detail" aria-label="Execution Log section">Execution Log</a></li> <li><a class="dash-sidebar__link" href="#event-timeline-section" data-section="event-timeline-section" data-view="detail" aria-label="Event Log section">Event Log</a></li> <li><a class="dash-sidebar__link" href="#reviews-section" data-section="reviews-section" data-view="detail" aria-label="Fast Reviews section">Fast Reviews</a></li> <li><a class="dash-sidebar__link" href="#panel-section" data-section="panel-section" data-view="detail" aria-label="Panel Reviews section">Panel Reviews</a></li> </ul> </nav> <main class="dash-main"> <nav class="breadcrumbs" id="breadcrumbs" data-view-hidden> <a class="breadcrumbs__link" href="#" id="breadcrumbs-home">Observability</a> <span class="breadcrumbs__separator">/</span> <span class="breadcrumbs__current" id="breadcrumbs-convoy"></span> </nav> <div class="view-home" id="view-home"> <!-- Overall Stats Section --> <section class="overall-stats" id="overall-section" data-nav-section> <div class="overall-stats__header"> <h2 class="overall-stats__title">Overall Stats</h2> <span class="tooltip-trigger" tabindex="0" role="button" aria-label="Info: How all runs behave across your project." data-tooltip="How all runs behave across your project."><svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="10"></circle><line x1="12" y1="16" x2="12" y2="12"></line><line x1="12" y1="8" x2="12.01" y2="8"></line></svg></span> </div> <div class="overall-stats__grid"> <div class="overall-kpi" id="overall-total-runs"> <span class="overall-kpi__label">Total Runs <span class="tooltip-trigger" tabindex="0" role="button" aria-label="Info: Number of convoy runs executed" data-tooltip="Number of convoy runs executed"><svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="10"></circle><line x1="12" y1="16" x2="12" y2="12"></line><line x1="12" y1="8" x2="12.01" y2="8"></line></svg></span></span> <span class="overall-kpi__value">&mdash;</span> </div> <div class="overall-kpi" id="overall-running"> <span class="overall-kpi__label">Running Now</span> <span class="overall-kpi__value">&mdash;</span> </div> <div class="overall-kpi" id="overall-total-tasks"> <span class="overall-kpi__label">Total Tasks</span> <span class="overall-kpi__value">&mdash;</span> </div> <div class="overall-kpi" id="overall-total-retries"> <span class="overall-kpi__label">Total Retries</span> <span class="overall-kpi__value">&mdash;</span> </div> <div class="overall-kpi" id="overall-success-rate"> <span class="overall-kpi__label">Success Rate</span> <span class="overall-kpi__value">&mdash;</span> </div> <div class="overall-kpi" id="overall-avg-duration"> <span class="overall-kpi__label">Avg Duration</span> <span class="overall-kpi__value">&mdash;</span> </div> <div class="overall-kpi" id="overall-total-tokens"> <span class="overall-kpi__label">Total Tokens</span> <span class="overall-kpi__value">&mdash;</span> </div> <div class="overall-kpi" id="overall-total-cost"> <span class="overall-kpi__label">Total Cost</span> <span class="overall-kpi__value">&mdash;</span> </div> </div> </section> <!-- Activity Timeline --> <section class="chart-card" id="activity-timeline-section" data-nav-section> <div class="chart-card__header"> <h2 class="chart-card__title">Activity Timeline</h2> <p class="chart-card__desc">Convoy runs over time</p> </div> <div class="chart-card__body" id="activity-timeline-chart"></div> </section> <!-- Convoy List Section --> <section class="convoy-list-section" id="convoy-list-section"> <div class="convoy-list-section__header"> <h2>Convoys</h2> <p class="convoy-list-section__desc">All convoy runs across your project</p> </div> <div class="convoy-list-filters" id="convoy-list-filters"> <div class="convoy-list-filters__group"> <label for="cl-filter-search">Search</label> <input class="convoy-list-filters__input" type="text" id="cl-filter-search" placeholder="Convoy name…"> </div> <div class="convoy-list-filters__group"> <label for="cl-filter-status">Status</label> <select class="convoy-list-filters__select" id="cl-filter-status"> <option value="">All</option> <option value="done">Done</option> <option value="running">Running</option> <option value="failed">Failed</option> <option value="gate-failed">Gate Failed</option> <option value="pending">Pending</option> </select> </div> <div class="convoy-list-filters__group"> <label for="cl-filter-from">From</label> <input class="convoy-list-filters__date" type="date" id="cl-filter-from"> </div> <div class="convoy-list-filters__group"> <label for="cl-filter-to">To</label> <input class="convoy-list-filters__date" type="date" id="cl-filter-to"> </div> <button class="convoy-list-filters__reset" type="button" id="cl-filter-reset">Reset</button> </div> <div id="convoy-list-table-wrap"></div> <div class="convoy-list-empty" id="convoy-list-empty" style="display:none"> <div class="convoy-list-empty__icon"> <svg width="40" height="40" viewBox="0 0 40 40" fill="none" stroke="currentColor" stroke-width="1.5"><rect x="6" y="6" width="28" height="28" rx="4"></rect><line x1="14" y1="20" x2="26" y2="20" opacity="0.5"></line></svg> </div> <p class="convoy-list-empty__text">No convoys match your filters</p> </div> </section> <!-- Recent Sessions --> <section class="chart-card" id="sessions-section" data-nav-section> <div class="chart-card__header"> <h2 class="chart-card__title">Recent Sessions</h2> <p class="chart-card__desc">Latest agent sessions from observability log</p> </div> <div class="chart-card__body chart-card__body--table" id="sessions-table"></div> </section> </div><!-- .view-home --> <div class="view-convoy-detail" id="view-convoy-detail" data-view-hidden> <section class="convoy-detail-hero" id="convoy-detail-hero"> <div class="convoy-detail-hero__top"> <div class="convoy-detail-hero__title" id="detail-hero-title"></div> <span class="convoy-detail-hero__status" id="detail-hero-status"></span> </div> <div class="convoy-detail-hero__meta" id="detail-hero-meta"></div> </section> <!-- Tasks Section --> <section class="chart-card" id="tasks-section" data-nav-section> <div class="chart-card__header"> <h2 class="chart-card__title">Tasks</h2> <span class="tooltip-trigger" tabindex="0" role="button" aria-label="Info: Individual units of work in this convoy." data-tooltip="Individual units of work in this convoy."><svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="10"></circle><line x1="12" y1="16" x2="12" y2="12"></line><line x1="12" y1="8" x2="12.01" y2="8"></line></svg></span> <p class="chart-card__desc" id="tasks-section-desc">Task breakdown for the selected convoy</p> </div> <div class="chart-card__body" id="tasks-section-body"> <div id="task-summary-cards" class="task-summary-cards"></div> <div id="phase-breakdown" class="phase-breakdown"></div> <div id="task-table-wrap" class="task-table-wrap"></div> </div> </section> <!-- Pipeline View --> <section class="chart-card" id="pipeline-section" data-nav-section> <div class="chart-card__header"> <h2 class="chart-card__title">Task Pipeline</h2> <span class="tooltip-trigger" tabindex="0" role="button" aria-label="Info: Visualizes how tasks progress through sequential execution phases." data-tooltip="Visualizes how tasks progress through sequential execution phases — from initial setup through integration, validation, and final quality gate."><svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="10"></circle><line x1="12" y1="16" x2="12" y2="12"></line><line x1="12" y1="8" x2="12.01" y2="8"></line></svg></span> <p class="chart-card__desc">Task flow across execution phases</p> </div> <div class="chart-card__body" id="pipeline-view"></div> </section> <!-- Sessions by Agent --> <div class="charts-row" id="agent-section" data-nav-section> <section class="chart-card"> <div class="chart-card__header"> <h2 class="chart-card__title">Sessions by Agent</h2> <p class="chart-card__desc">Task count per agent, stacked by outcome</p> </div> <div class="chart-card__body" id="agent-chart"></div> </section> <section class="chart-card" id="model-section" data-nav-section> <div class="chart-card__header"> <h2 class="chart-card__title">Model Usage</h2> <p class="chart-card__desc">Tasks by model</p> </div> <div class="chart-card__body" id="model-chart"></div> </section> </div> <!-- Charts Row: Tiers + Mechanism --> <div class="charts-row" id="tier-section" data-nav-section> <section class="chart-card"> <div class="chart-card__header"> <h2 class="chart-card__title">Tier Distribution</h2> <p class="chart-card__desc">Model tier breakdown</p> </div> <div class="chart-card__body" id="tier-chart"></div> </section> <section class="chart-card"> <div class="chart-card__header"> <h2 class="chart-card__title">Delegation Mechanism</h2> <p class="chart-card__desc">Sub-agent vs background split</p> </div> <div class="chart-card__body" id="mechanism-chart"></div> </section> </div> <!-- Quality Section --> <section class="chart-card" id="quality-section" data-nav-section> <div class="chart-card__header"> <h2 class="chart-card__title">Quality / Review</h2> <span class="tooltip-trigger" tabindex="0" role="button" aria-label="Info: Code review results and dispute resolution." data-tooltip="Code review results and dispute resolution."><svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="10"></circle><line x1="12" y1="16" x2="12" y2="12"></line><line x1="12" y1="8" x2="12.01" y2="8"></line></svg></span> <p class="chart-card__desc">Code review results and quality gate outcomes for the selected convoy</p> </div> <div class="chart-card__body"> <div id="quality-cards" class="task-summary-cards"></div> <div id="quality-review-table"></div> </div> </section> <!-- Reliability Section --> <section class="chart-card" id="reliability-section" data-nav-section> <div class="chart-card__header"> <h2 class="chart-card__title">Reliability</h2> <span class="tooltip-trigger" tabindex="0" role="button" aria-label="Info: Errors, retry attempts, and safety mechanisms." data-tooltip="Errors, retry attempts, and safety mechanisms."><svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="10"></circle><line x1="12" y1="16" x2="12" y2="12"></line><line x1="12" y1="8" x2="12.01" y2="8"></line></svg></span> <p class="chart-card__desc">Retry queue and error overview for the selected convoy</p> </div> <div class="chart-card__body"> <div id="reliability-dlq-card"></div> <div id="reliability-dlq-table"></div> <div style="margin-top:24px"> <h3 style="font-size:1rem;font-weight:600;color:var(--text-secondary);margin:0 0 12px">Error Overview</h3> <div id="reliability-error-overview"></div> </div> </div> </section> <!-- Drift Section --> <section class="chart-card" id="drift-section" data-nav-section> <div class="chart-card__header"> <h2 class="chart-card__title">Drift</h2> <span class="tooltip-trigger" tabindex="0" role="button" aria-label="Info: How far the actual work deviated from the original plan." data-tooltip="How far the actual work deviated from the original plan."><svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="10"></circle><line x1="12" y1="16" x2="12" y2="12"></line><line x1="12" y1="8" x2="12.01" y2="8"></line></svg></span> <p class="chart-card__desc">Plan adherence and deviation metrics for the selected convoy</p> </div> <div class="chart-card__body"> <div id="drift-cards" class="task-summary-cards"></div> <div id="drift-secret-banner" style="display:none"></div> </div> </section> <!-- Outputs Section --> <section class="chart-card" id="outputs-section" data-nav-section> <div class="chart-card__header"> <h2 class="chart-card__title">Outputs &amp; Artifacts</h2> <span class="tooltip-trigger" tabindex="0" role="button" aria-label="Info: Files, data, and summaries produced by this convoy." data-tooltip="Files, data, and summaries produced by this convoy."><svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="10"></circle><line x1="12" y1="16" x2="12" y2="12"></line><line x1="12" y1="8" x2="12.01" y2="8"></line></svg></span> <p class="chart-card__desc">Files, summaries, and structured data produced by tasks in this convoy</p> </div> <div class="chart-card__body"> <div id="outputs-cards" class="task-summary-cards"></div> <div id="artifact-table-wrap"></div> </div> </section> <!-- Event Timeline Section --> <section class="chart-card" id="event-timeline-section" data-nav-section> <div class="chart-card__header"> <h2 class="chart-card__title">Event Timeline</h2> <span class="tooltip-trigger" tabindex="0" role="button" aria-label="Info: Chronological log of everything that happened during this run." data-tooltip="Chronological log of everything that happened during this run."><svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="10"></circle><line x1="12" y1="16" x2="12" y2="12"></line><line x1="12" y1="8" x2="12.01" y2="8"></line></svg></span> <p class="chart-card__desc">Convoy events in chronological order</p> </div> <div class="chart-card__body"> <div id="event-timeline-filters" class="timeline-filters"></div> <div id="event-timeline-list"></div> <div id="event-timeline-load-more" style="display:none;text-align:center;padding:16px"> <button class="dash-btn dash-btn--ghost" id="event-timeline-more-btn" type="button">Load more</button> </div> </div> </section> <!-- Execution Log --> <section class="chart-card" id="execution-section" data-nav-section> <div class="chart-card__header"> <h2 class="chart-card__title">Execution Log</h2> <span class="tooltip-trigger" tabindex="0" role="button" aria-label="Info: Step-by-step trace of recent task activity." data-tooltip="Step-by-step trace of recent task activity."><svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="10"></circle><line x1="12" y1="16" x2="12" y2="12"></line><line x1="12" y1="8" x2="12.01" y2="8"></line></svg></span> <p class="chart-card__desc">Recent agent activity, step by step</p> </div> <div class="chart-card__body" id="execution-log"></div> </section> <!-- Fast Reviews --> <section class="chart-card" id="reviews-section" data-nav-section> <div class="chart-card__header"> <h2 class="chart-card__title">Fast Reviews</h2> <span class="tooltip-trigger" tabindex="0" role="button" aria-label="Info: Single-reviewer quality gate results." data-tooltip="Single-reviewer quality gate results."><svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="10"></circle><line x1="12" y1="16" x2="12" y2="12"></line><line x1="12" y1="8" x2="12.01" y2="8"></line></svg></span> <p class="chart-card__desc">Single-reviewer quality gate results</p> </div> <div class="chart-card__body chart-card__body--table" id="reviews-table"></div> </section> <!-- Panel Reviews --> <section class="chart-card" id="panel-section" data-nav-section> <div class="chart-card__header"> <h2 class="chart-card__title">Panel Reviews</h2> <span class="tooltip-trigger" tabindex="0" role="button" aria-label="Info: Quality gate verdicts from majority-vote panels." data-tooltip="Quality gate verdicts from majority-vote panels."><svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="10"></circle><line x1="12" y1="16" x2="12" y2="12"></line><line x1="12" y1="8" x2="12.01" y2="8"></line></svg></span> <p class="chart-card__desc">Quality gate verdicts and fix items</p> </div> <div class="chart-card__body" id="panel-chart"></div> </section> <!-- Recent Sessions (live during active convoy) --> <section class="chart-card" id="detail-sessions-section" data-nav-section> <div class="chart-card__header"> <h2 class="chart-card__title">Recent Sessions</h2> <p class="chart-card__desc">Latest agent sessions from observability log</p> </div> <div class="chart-card__body chart-card__body--table" id="detail-sessions-table"></div> </section> </div><!-- .view-convoy-detail --> </main> </div> </body></html> <script>(function(){const base = "/";
8
-
9
- // ── Data Loading ──────────────────────────────────────────
10
-
11
- async function loadNdjson(path) {
12
- try {
13
- const res = await fetch(path);
14
- if (!res.ok) return [];
15
- const text = await res.text();
16
- var results = [];
17
- var lines = text.trim().split('\n').filter(Boolean);
18
- for (var i = 0; i < lines.length; i++) {
19
- var line = lines[i];
20
- try {
21
- results.push(JSON.parse(line));
22
- } catch {
23
- // Attempt to recover concatenated records (e.g. "}{" without newline)
24
- var parts = line.split(/(?<=\})(?=\{)/);
25
- for (var j = 0; j < parts.length; j++) {
26
- try { results.push(JSON.parse(parts[j])); } catch { /* skip */ }
27
- }
28
- }
29
- }
30
- return results;
31
- } catch {
32
- return [];
33
- }
34
- }
35
-
36
- async function loadJson(path) {
37
- try {
38
- const res = await fetch(path);
39
- if (!res.ok) return [];
40
- return await res.json();
41
- } catch {
42
- return [];
43
- }
44
- }
45
-
46
- // ── Helpers ───────────────────────────────────────────────
47
-
48
- // ── Info Icon SVG ─────────────────────────────────────
49
- const INFO_ICON = '<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="10"/><line x1="12" y1="16" x2="12" y2="12"/><line x1="12" y1="8" x2="12.01" y2="8"/></svg>';
50
-
51
- const TIER_COLORS = {
52
- premium: '#f59e0b',
53
- standard: '#a78bfa',
54
- utility: '#3b82f6',
55
- economy: '#64748b',
56
- unknown: '#94a3b8',
57
- };
58
-
59
- // Colour bars by tier rather than by a pinned model list, so a model this
60
- // build has never heard of still gets a sensible colour.
61
- function modelColor(name) {
62
- return TIER_COLORS[deriveTier(name, null)] || '#64748b';
63
- }
64
-
65
- const OUTCOME_ICONS = {
66
- success: '\u2713',
67
- partial: '\u25CB',
68
- failed: '\u2717',
69
- };
70
-
71
- function formatTime(ts) {
72
- const d = new Date(ts);
73
- return d.toLocaleDateString('en-US', {
74
- month: 'short',
75
- day: 'numeric',
76
- hour: '2-digit',
77
- minute: '2-digit',
78
- });
79
- }
80
-
81
- function formatShortDate(dateKey) {
82
- const d = new Date(dateKey + 'T00:00:00Z');
83
- return d.toLocaleDateString('en-US', {
84
- month: 'short',
85
- day: 'numeric',
86
- timeZone: 'UTC',
87
- });
88
- }
89
-
90
- function escapeHtml(str) {
91
- const div = document.createElement('div');
92
- div.textContent = str;
93
- return div.innerHTML;
94
- }
95
-
96
- // ── Active Convoy Polling ──────────────────────────────────
97
- let _activePollingTimer = null;
98
- let _activePollingConvoyId = null;
99
- let _lastPolledConvoyStatus = null;
100
-
101
- function startActiveConvoyPolling() {
102
- if (_activePollingTimer) return; // already polling
103
- _activePollingTimer = setInterval(pollActiveConvoy, 3000);
104
- // Also poll immediately
105
- pollActiveConvoy();
106
- }
107
-
108
- function stopActiveConvoyPolling() {
109
- if (_activePollingTimer) {
110
- clearInterval(_activePollingTimer);
111
- _activePollingTimer = null;
112
- }
113
- }
114
-
115
- async function pollActiveConvoy() {
116
- try {
117
- const resp = await fetch(base + 'data/active-convoy.json');
118
- if (!resp.ok) return;
119
- const data = await resp.json();
120
-
121
- if (!data.convoy) return; // no convoy yet — keep polling
122
-
123
- const convoy = data.convoy;
124
- const isRunningOrPending = convoy.status === 'running' || convoy.status === 'pending';
125
-
126
- // If we haven't navigated to any convoy yet, navigate to a running/pending one
127
- if (!_activePollingConvoyId && isRunningOrPending) {
128
- _activePollingConvoyId = convoy.id;
129
- _lastPolledConvoyStatus = null;
130
- // Refresh ETL data so convoy detail JSON exists
131
- await fetch(base + 'data/refresh');
132
- // Re-fetch the convoy list and stats
133
- await refreshDashboardData();
134
- showConvoyDetailView(convoy.id, convoy.name || convoy.id);
135
- removeWaitingBanner();
136
- }
137
-
138
- // If we're on a convoy and a new one started (pipeline chain), follow it
139
- if (_activePollingConvoyId !== convoy.id && isRunningOrPending) {
140
- _activePollingConvoyId = convoy.id;
141
- _lastPolledConvoyStatus = null;
142
- await fetch(base + 'data/refresh');
143
- await refreshDashboardData();
144
- showConvoyDetailView(convoy.id, convoy.name || convoy.id);
145
- }
146
-
147
- // If we're viewing the active convoy, refresh when it's running or just transitioned
148
- if (_activePollingConvoyId === convoy.id) {
149
- const statusChanged = _lastPolledConvoyStatus !== null && _lastPolledConvoyStatus !== convoy.status;
150
- _lastPolledConvoyStatus = convoy.status;
151
-
152
- if (isRunningOrPending || statusChanged) {
153
- await fetch(base + 'data/refresh');
154
- await refreshDashboardData();
155
- // Reload convoy detail to show latest task progress
156
- await loadConvoyDetail(convoy.id);
157
-
158
- // Update pipeline chain breadcrumb if applicable
159
- if (data.pipeline && data.pipeline.length > 1) {
160
- renderPipelineChain(data.pipeline, convoy.id);
161
- }
162
- }
163
- }
164
-
165
- // NOTE: In 'active' mode we intentionally keep polling even after a convoy finishes,
166
- // so that subsequent convoys are detected when they start.
167
- } catch {
168
- // Polling errors are non-fatal — just retry next interval
169
- }
170
- }
171
-
172
- async function refreshDashboardData() {
173
- try {
174
- const [statsResp, listResp] = await Promise.all([
175
- fetch(base + 'data/overall-stats.json'),
176
- fetch(base + 'data/convoy-list.json'),
177
- ]);
178
- if (statsResp.ok) {
179
- window.__DASHBOARD_DATA__.overallStats = await statsResp.json();
180
- }
181
- if (listResp.ok) {
182
- window.__DASHBOARD_DATA__.convoyList = await listResp.json();
183
- }
184
- renderOverallStats();
185
- renderConvoyList();
186
- renderActivityTimeline();
187
- renderRecentSessions();
188
- } catch {
189
- // Non-fatal
190
- }
191
- }
192
-
193
- function renderPipelineChain(pipelineConvoys, activeConvoyId) {
194
- let chainEl = document.getElementById('pipeline-chain-nav');
195
- if (!chainEl) {
196
- chainEl = document.createElement('div');
197
- chainEl.id = 'pipeline-chain-nav';
198
- chainEl.className = 'pipeline-chain-nav';
199
- const breadcrumbs = document.getElementById('breadcrumbs');
200
- if (breadcrumbs) breadcrumbs.after(chainEl);
201
- }
202
-
203
- const statusDot = (status) => {
204
- const colors = { done: '#4ade80', running: '#60a5fa', pending: '#94a3b8', failed: '#f87171', 'gate-failed': '#fb923c' };
205
- return '<span class="pipeline-chain__dot" style="background:' + (colors[status] || '#94a3b8') + '"></span>';
206
- };
207
-
208
- let html = '<div class="pipeline-chain__label">Pipeline:</div>';
209
- for (const c of pipelineConvoys) {
210
- const isActive = c.id === activeConvoyId;
211
- html += '<button class="pipeline-chain__item' + (isActive ? ' pipeline-chain__item--active' : '') + '" data-convoy-id="' + escapeHtml(c.id) + '">' +
212
- statusDot(c.status) + escapeHtml(c.name || c.id) + '</button>';
213
- }
214
- chainEl.innerHTML = html;
215
-
216
- chainEl.querySelectorAll('button[data-convoy-id]').forEach(btn => {
217
- btn.addEventListener('click', () => {
218
- const id = btn.dataset.convoyId;
219
- const name = btn.textContent.trim();
220
- _activePollingConvoyId = id;
221
- showConvoyDetailView(id, name);
222
- });
223
- });
224
- }
225
-
226
- function showWaitingBanner() {
227
- if (document.getElementById('waiting-banner')) return;
228
- const banner = document.createElement('section');
229
- banner.id = 'waiting-banner';
230
- banner.className = 'waiting-banner';
231
- banner.innerHTML =
232
- '<div class="waiting-banner__content">' +
233
- '<div class="waiting-banner__spinner"></div>' +
234
- '<h2 class="waiting-banner__title">Waiting for convoy to start…</h2>' +
235
- '<p class="waiting-banner__subtitle">The dashboard will automatically show convoy progress once it begins.</p>' +
236
- '</div>';
237
- const main = document.querySelector('.dash-main');
238
- if (main) main.prepend(banner);
239
- }
240
-
241
- function removeWaitingBanner() {
242
- const el = document.getElementById('waiting-banner');
243
- if (el) el.remove();
244
- }
245
-
246
- function formatTokens(n) {
247
- if (n >= 1000000) return (n / 1000000).toFixed(1) + 'M';
248
- if (n >= 1000) return (n / 1000).toFixed(1) + 'K';
249
- return String(n);
250
- }
251
-
252
- function formatDuration(startIso, endIso) {
253
- if (!startIso || !endIso) return null;
254
- const ms = new Date(endIso).getTime() - new Date(startIso).getTime();
255
- if (ms < 0) return null;
256
- const sec = Math.floor(ms / 1000);
257
- if (sec < 60) return sec + 's';
258
- const min = Math.floor(sec / 60);
259
- const remSec = sec % 60;
260
- if (min < 60) return min + 'm ' + remSec + 's';
261
- const hr = Math.floor(min / 60);
262
- const remMin = min % 60;
263
- return hr + 'h ' + remMin + 'm';
264
- }
265
-
266
- // ── SVG Icon Library (empty states) ────────────────────
267
-
268
- const EMPTY_ICONS = {
269
- welcome: '<svg width="48" height="48" viewBox="0 0 48 48" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M24 4L6 14v20l18 10 18-10V14L24 4z" opacity="0.3"/><path d="M24 4L6 14v20l18 10 18-10V14L24 4z"/><path d="M24 24v20"/><path d="M6 14l18 10 18-10"/><rect x="18" y="18" width="12" height="14" rx="1" opacity="0.5"/><path d="M21 32v-6h6v6"/></svg>',
270
- agents: '<svg width="40" height="40" viewBox="0 0 40 40" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><circle cx="20" cy="14" r="6"/><path d="M8 34c0-6.627 5.373-12 12-12s12 5.373 12 12"/><circle cx="32" cy="12" r="4" opacity="0.4"/><path d="M36 26c0-3.5-2-6-4-7" opacity="0.4"/></svg>',
271
- tiers: '<svg width="40" height="40" viewBox="0 0 40 40" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><ellipse cx="20" cy="10" rx="14" ry="5"/><path d="M6 10v8c0 2.761 6.268 5 14 5s14-2.239 14-5v-8"/><path d="M6 18v8c0 2.761 6.268 5 14 5s14-2.239 14-5v-8" opacity="0.5"/></svg>',
272
- mechanism: '<svg width="40" height="40" viewBox="0 0 40 40" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><circle cx="20" cy="20" r="6"/><path d="M20 6v6M20 28v6M6 20h6M28 20h6"/><path d="M10.1 10.1l4.2 4.2M25.7 25.7l4.2 4.2M10.1 29.9l4.2-4.2M25.7 14.3l4.2-4.2" opacity="0.5"/></svg>',
273
- outcomes: '<svg width="40" height="40" viewBox="0 0 40 40" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><rect x="6" y="6" width="28" height="28" rx="4"/><polyline points="12 22 18 28 28 14" opacity="0.5"/><line x1="12" y1="16" x2="18" y2="16" opacity="0.3"/><line x1="12" y1="12" x2="24" y2="12" opacity="0.3"/></svg>',
274
- timeline: '<svg width="40" height="40" viewBox="0 0 40 40" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><rect x="6" y="8" width="28" height="26" rx="3"/><line x1="6" y1="16" x2="34" y2="16"/><line x1="14" y1="8" x2="14" y2="12"/><line x1="26" y1="8" x2="26" y2="12"/><circle cx="14" cy="24" r="2" opacity="0.4"/><circle cx="20" cy="28" r="2" opacity="0.4"/><circle cx="26" cy="22" r="2" opacity="0.4"/></svg>',
275
- models: '<svg width="40" height="40" viewBox="0 0 40 40" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><rect x="8" y="8" width="24" height="24" rx="4"/><circle cx="20" cy="20" r="4"/><path d="M20 12v4M20 24v4M12 20h4M24 20h4" opacity="0.5"/><circle cx="14" cy="14" r="1.5" opacity="0.3"/><circle cx="26" cy="14" r="1.5" opacity="0.3"/><circle cx="14" cy="26" r="1.5" opacity="0.3"/><circle cx="26" cy="26" r="1.5" opacity="0.3"/></svg>',
276
- execLog: '<svg width="40" height="40" viewBox="0 0 40 40" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M14 8h18a2 2 0 0 1 2 2v20a2 2 0 0 1-2 2H14"/><circle cx="10" cy="14" r="3"/><circle cx="10" cy="24" r="3" opacity="0.4"/><line x1="10" y1="17" x2="10" y2="21" opacity="0.3"/><line x1="18" y1="14" x2="28" y2="14" opacity="0.5"/><line x1="18" y1="24" x2="26" y2="24" opacity="0.3"/><line x1="18" y1="19" x2="24" y2="19" opacity="0.2"/></svg>',
277
- panels: '<svg width="40" height="40" viewBox="0 0 40 40" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M20 6l2 4h4l-3 3 1 5-4-2.5L16 18l1-5-3-3h4l2-4z"/><rect x="8" y="22" width="24" height="12" rx="3" opacity="0.4"/><line x1="14" y1="28" x2="26" y2="28" opacity="0.3"/><line x1="14" y1="31" x2="22" y2="31" opacity="0.2"/></svg>',
278
- sessions: '<svg width="40" height="40" viewBox="0 0 40 40" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><rect x="6" y="6" width="28" height="28" rx="3"/><line x1="6" y1="14" x2="34" y2="14"/><line x1="14" y1="6" x2="14" y2="34" opacity="0.3"/><line x1="6" y1="22" x2="34" y2="22" opacity="0.2"/><line x1="6" y1="30" x2="34" y2="30" opacity="0.2"/></svg>',
279
- pipeline: '<svg width="40" height="40" viewBox="0 0 40 40" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><rect x="4" y="14" width="8" height="12" rx="2" opacity="0.3"/><rect x="16" y="14" width="8" height="12" rx="2" opacity="0.3"/><rect x="28" y="14" width="8" height="12" rx="2" opacity="0.3"/><path d="M12 20h4M24 20h4" opacity="0.4"/></svg>',
280
- };
281
-
282
- function emptyStateHtml(iconKey, title, description) {
283
- return '<div class="empty-state empty-state--enhanced">' +
284
- '<div class="empty-state__icon-wrap">' + EMPTY_ICONS[iconKey] + '</div>' +
285
- '<p class="empty-state__title">' + title + '</p>' +
286
- '<p class="empty-state__desc">' + description + '</p>' +
287
- '</div>';
288
- }
289
-
290
- // ── Welcome Banner (all data empty) ────────────────────
291
-
292
- function renderWelcomeBanner() {
293
- const existing = document.getElementById('welcome-banner');
294
- if (existing) existing.remove();
295
-
296
- const banner = document.createElement('section');
297
- banner.id = 'welcome-banner';
298
- banner.className = 'welcome-banner';
299
- banner.innerHTML =
300
- '<div class="welcome-banner__glow"></div>' +
301
- '<div class="welcome-banner__content">' +
302
- '<div class="welcome-banner__icon">' + EMPTY_ICONS.welcome + '</div>' +
303
- '<h2 class="welcome-banner__title">Welcome to your Observability Dashboard</h2>' +
304
- '<p class="welcome-banner__subtitle">Agent sessions, delegations, and quality reviews will appear here as your team completes work.</p>' +
305
- '<div class="welcome-banner__steps">' +
306
- '<div class="welcome-step">' +
307
- '<span class="welcome-step__num">1</span>' +
308
- '<div class="welcome-step__text">' +
309
- '<strong>Configure agents</strong>' +
310
- '<span>Set up your orchestrator and specialist agents</span>' +
311
- '</div>' +
312
- '</div>' +
313
- '<div class="welcome-step">' +
314
- '<span class="welcome-step__num">2</span>' +
315
- '<div class="welcome-step__text">' +
316
- '<strong>Run a session</strong>' +
317
- '<span>Delegate tasks — session logs are captured automatically</span>' +
318
- '</div>' +
319
- '</div>' +
320
- '<div class="welcome-step">' +
321
- '<span class="welcome-step__num">3</span>' +
322
- '<div class="welcome-step__text">' +
323
- '<strong>Watch insights flow in</strong>' +
324
- '<span>Charts, metrics, and trends populate in real time</span>' +
325
- '</div>' +
326
- '</div>' +
327
- '</div>' +
328
- '</div>';
329
-
330
- const main = document.querySelector('.dash-main');
331
- if (main) main.prepend(banner);
332
- }
333
-
334
- function removeWelcomeBanner() {
335
- const existing = document.getElementById('welcome-banner');
336
- if (existing) existing.remove();
337
- }
338
-
339
- // ── View Management ─────────────────────────────────────
340
- function showHomeView() {
341
- const home = document.getElementById('view-home');
342
- const detail = document.getElementById('view-convoy-detail');
343
- const breadcrumbs = document.getElementById('breadcrumbs');
344
- if (home) delete home.dataset.viewHidden;
345
- if (detail) detail.dataset.viewHidden = '';
346
- if (breadcrumbs) breadcrumbs.dataset.viewHidden = '';
347
- document.querySelectorAll('.dash-sidebar__link[data-view="detail"]').forEach(el => el.closest('li').style.display = 'none');
348
- document.querySelectorAll('.dash-sidebar__link[data-view="home"]').forEach(el => el.closest('li').style.display = '');
349
- const url = new URL(window.location);
350
- url.searchParams.delete('convoy');
351
- history.pushState({}, '', url);
352
- const chainNav = document.getElementById('pipeline-chain-nav');
353
- if (chainNav) chainNav.remove();
354
- }
355
-
356
- function showConvoyDetailView(convoyId, convoyName) {
357
- const home = document.getElementById('view-home');
358
- const detail = document.getElementById('view-convoy-detail');
359
- const breadcrumbs = document.getElementById('breadcrumbs');
360
- if (home) home.dataset.viewHidden = '';
361
- if (detail) delete detail.dataset.viewHidden;
362
- if (breadcrumbs) delete breadcrumbs.dataset.viewHidden;
363
- document.querySelectorAll('.dash-sidebar__link[data-view="home"]').forEach(el => el.closest('li').style.display = 'none');
364
- document.querySelectorAll('.dash-sidebar__link[data-view="detail"]').forEach(el => el.closest('li').style.display = '');
365
- const crumbText = document.getElementById('breadcrumbs-convoy');
366
- if (crumbText) crumbText.textContent = convoyName || convoyId;
367
- const url = new URL(window.location);
368
- url.searchParams.set('convoy', convoyId);
369
- history.pushState({}, '', url);
370
- loadConvoyDetail(convoyId);
371
- window.scrollTo({ top: 0, behavior: 'smooth' });
372
- }
373
-
374
- // ── Convoy List ─────────────────────────────────────────
375
- var convoyListCurrentPage = 1;
376
- var CONVOY_LIST_PAGE_SIZE = 10;
377
- var convoyChainExpanded = {};
378
- var executionLogPageSize = 20;
379
- var executionLogCurrentPage = 1;
380
- var executionLogAllSortedTasks = [];
381
- var executionLogLimit = 10;
382
-
383
- function renderConvoyList() {
384
- const data = window.__DASHBOARD_DATA__;
385
- const list = data?.convoyList ?? [];
386
- const wrap = document.getElementById('convoy-list-table-wrap');
387
- const emptyEl = document.getElementById('convoy-list-empty');
388
- if (!wrap) return;
389
-
390
- const search = (document.getElementById('cl-filter-search')?.value || '').toLowerCase();
391
- const status = document.getElementById('cl-filter-status')?.value || '';
392
- const fromDate = document.getElementById('cl-filter-from')?.value || '';
393
- const toDate = document.getElementById('cl-filter-to')?.value || '';
394
-
395
- let filtered = list;
396
- if (search) filtered = filtered.filter(c => (c.name || c.id || '').toLowerCase().includes(search));
397
- if (status) filtered = filtered.filter(c => c.status === status);
398
- if (fromDate) filtered = filtered.filter(c => c.created_at && c.created_at >= fromDate);
399
- if (toDate) filtered = filtered.filter(c => c.created_at && c.created_at.slice(0, 10) <= toDate);
400
-
401
- if (filtered.length === 0) {
402
- wrap.innerHTML = '';
403
- var existingPag = document.getElementById('convoy-list-pagination');
404
- if (existingPag) existingPag.remove();
405
- if (emptyEl) emptyEl.style.display = '';
406
- return;
407
- }
408
- if (emptyEl) emptyEl.style.display = 'none';
409
-
410
- const statusBadgeClass = (s) => {
411
- const map = { done: '--done', running: '--running', failed: '--failed', 'gate-failed': '--gate-failed', gate_failed: '--gate-failed', pending: '--pending' };
412
- return 'status-badge ' + (map[s] || '');
413
- };
414
-
415
- // Group convoys by pipeline_id (non-null pipeline_id forms a chain)
416
- var grouped = [];
417
- var pipelineMap = {};
418
- for (var gi = 0; gi < filtered.length; gi++) {
419
- var gc = filtered[gi];
420
- if (gc.pipeline_id) {
421
- if (!pipelineMap[gc.pipeline_id]) {
422
- pipelineMap[gc.pipeline_id] = { pipeline_id: gc.pipeline_id, convoys: [] };
423
- grouped.push(pipelineMap[gc.pipeline_id]);
424
- }
425
- pipelineMap[gc.pipeline_id].convoys.push(gc);
426
- } else {
427
- grouped.push(gc);
428
- }
429
- }
430
-
431
- // Pagination on grouped top-level items
432
- var totalPages = Math.ceil(grouped.length / CONVOY_LIST_PAGE_SIZE);
433
- if (convoyListCurrentPage > totalPages) convoyListCurrentPage = 1;
434
- var pageStart = (convoyListCurrentPage - 1) * CONVOY_LIST_PAGE_SIZE;
435
- var paginated = grouped.slice(pageStart, pageStart + CONVOY_LIST_PAGE_SIZE);
436
-
437
- let html = '<table class="convoy-list-table"><thead><tr>' +
438
- '<th>Name</th><th>Status</th><th>Tasks</th><th>Created</th><th>Duration</th>' +
439
- '</tr></thead><tbody>';
440
-
441
- for (var pi = 0; pi < paginated.length; pi++) {
442
- var item = paginated[pi];
443
- if (item.convoys) {
444
- // Pipeline group row
445
- var grpConvoys = item.convoys;
446
- var grpPipelineId = item.pipeline_id;
447
- var isExpanded = !!convoyChainExpanded[grpPipelineId];
448
- var grpStatus = (function(cs) {
449
- if (cs.some(function(x) { return x.status === 'failed' || x.status === 'gate_failed'; })) return 'gate_failed';
450
- if (cs.some(function(x) { return x.status === 'running'; })) return 'running';
451
- if (cs.every(function(x) { return x.status === 'done'; })) return 'done';
452
- return cs[0] ? cs[0].status : 'pending';
453
- })(grpConvoys);
454
- var grpTasks = grpConvoys.reduce(function(s, x) { return s + (x.task_count || 0); }, 0);
455
- var grpEarliestCreated = grpConvoys.reduce(function(a, x) { return (!a || (x.created_at && x.created_at < a)) ? x.created_at : a; }, null);
456
- var grpLatestFinished = grpConvoys.reduce(function(a, x) { return (!a || (x.finished_at && x.finished_at > a)) ? x.finished_at : a; }, null);
457
- var grpAllFinished = grpConvoys.every(function(x) { return !!x.finished_at; });
458
- var grpDuration = grpEarliestCreated && grpAllFinished && grpLatestFinished ? formatDuration(grpEarliestCreated, grpLatestFinished) : (grpStatus === 'running' ? 'In progress' : '\u2014');
459
- var grpName = grpConvoys[0].pipeline_name || grpPipelineId.replace(/-/g, ' ').replace(/\b\w/g, function(l) { return l.toUpperCase(); });
460
- var toggleIcon = isExpanded ? '\u25bc' : '\u25b6';
461
- html += '<tr class="convoy-chain-row task-row--clickable" data-pipeline-group-id="' + escapeHtml(grpPipelineId) + '" aria-expanded="' + isExpanded + '" role="row">' +
462
- '<td><span class="convoy-chain-toggle">' + toggleIcon + '</span><strong>' + escapeHtml(grpName) + '</strong></td>' +
463
- '<td><span class="' + statusBadgeClass(grpStatus) + '">' + escapeHtml(grpStatus) + '</span></td>' +
464
- '<td>' + grpTasks + '</td>' +
465
- '<td>' + (grpEarliestCreated ? formatTime(grpEarliestCreated) : '\u2014') + '</td>' +
466
- '<td>' + grpDuration + '</td>' +
467
- '</tr>';
468
- if (isExpanded) {
469
- for (var ci = 0; ci < grpConvoys.length; ci++) {
470
- var cc = grpConvoys[ci];
471
- var ccName = escapeHtml(cc.name || cc.id);
472
- var ccDate = cc.created_at ? formatTime(cc.created_at) : '\u2014';
473
- var ccDur = cc.started_at && cc.finished_at ? formatDuration(cc.started_at, cc.finished_at) : (cc.status === 'running' ? 'In progress' : '\u2014');
474
- var ccTasks = cc.task_count != null ? cc.task_count : '\u2014';
475
- html += '<tr data-convoy-id="' + escapeHtml(cc.id) + '" class="task-row--clickable convoy-chain-child">' +
476
- '<td><strong>' + ccName + '</strong></td>' +
477
- '<td><span class="' + statusBadgeClass(cc.status) + '">' + escapeHtml(cc.status || 'unknown') + '</span></td>' +
478
- '<td>' + ccTasks + '</td>' +
479
- '<td>' + ccDate + '</td>' +
480
- '<td>' + ccDur + '</td>' +
481
- '</tr>';
482
- }
483
- }
484
- } else {
485
- var name = escapeHtml(item.name || item.id);
486
- var dateStr = item.created_at ? formatTime(item.created_at) : '\u2014';
487
- var duration = item.started_at && item.finished_at ? formatDuration(item.started_at, item.finished_at) : (item.status === 'running' ? 'In progress' : '\u2014');
488
- var taskCount = item.task_count != null ? item.task_count : '\u2014';
489
- html += '<tr data-convoy-id="' + escapeHtml(item.id) + '" class="task-row--clickable">' +
490
- '<td><strong>' + name + '</strong></td>' +
491
- '<td><span class="' + statusBadgeClass(item.status) + '">' + escapeHtml(item.status || 'unknown') + '</span></td>' +
492
- '<td>' + taskCount + '</td>' +
493
- '<td>' + dateStr + '</td>' +
494
- '<td>' + (duration || '\u2014') + '</td>' +
495
- '</tr>';
496
- }
497
- }
498
- html += '</tbody></table>';
499
- wrap.innerHTML = html;
500
-
501
- wrap.querySelectorAll('tr[data-pipeline-group-id]').forEach(row => {
502
- row.addEventListener('click', () => {
503
- const groupId = row.dataset.pipelineGroupId;
504
- convoyChainExpanded[groupId] = !convoyChainExpanded[groupId];
505
- renderConvoyList();
506
- });
507
- });
508
-
509
- wrap.querySelectorAll('tr[data-convoy-id]').forEach(row => {
510
- row.addEventListener('click', () => {
511
- const id = row.dataset.convoyId;
512
- const nameCell = row.querySelector('td strong');
513
- showConvoyDetailView(id, nameCell ? nameCell.textContent : id);
514
- });
515
- });
516
-
517
- // Render pagination controls
518
- var oldPag = document.getElementById('convoy-list-pagination');
519
- if (oldPag) oldPag.remove();
520
- if (grouped.length > CONVOY_LIST_PAGE_SIZE) {
521
- var pagEl = document.createElement('div');
522
- pagEl.id = 'convoy-list-pagination';
523
- pagEl.className = 'convoy-list-pagination';
524
- pagEl.innerHTML =
525
- '<button class="dash-btn dash-btn--ghost" id="convoy-list-prev" type="button"' + (convoyListCurrentPage === 1 ? ' disabled' : '') + '>Previous</button>' +
526
- '<span class="convoy-list-pagination__info">Page ' + convoyListCurrentPage + ' of ' + totalPages + '</span>' +
527
- '<button class="dash-btn dash-btn--ghost" id="convoy-list-next" type="button"' + (convoyListCurrentPage === totalPages ? ' disabled' : '') + '>Next</button>';
528
- wrap.after(pagEl);
529
- pagEl.querySelector('#convoy-list-prev').addEventListener('click', function() {
530
- if (convoyListCurrentPage > 1) { convoyListCurrentPage--; renderConvoyList(); }
531
- });
532
- pagEl.querySelector('#convoy-list-next').addEventListener('click', function() {
533
- if (convoyListCurrentPage < totalPages) { convoyListCurrentPage++; renderConvoyList(); }
534
- });
535
- }
536
- }
537
-
538
- // ── Overall Stats Rendering ──────────────────────────────
539
-
540
- function renderOverallStats() {
541
- const data = window.__DASHBOARD_DATA__;
542
- if (!data || !data.overallStats) return;
543
- const stats = data.overallStats;
544
- const cc = stats.convoyCounts || {};
545
- const tc = stats.tokenCostTotals || {};
546
- const ds = stats.durationStats || {};
547
-
548
- setKpiValue('overall-total-runs', String(cc.total || 0));
549
- setKpiValue('overall-running', String(cc.running || 0));
550
-
551
- const total = cc.total || 0;
552
- const success = cc.done || 0;
553
- const rate = total > 0 ? ((success / total) * 100).toFixed(1) + '%' : '\u2014';
554
- setKpiValue('overall-success-rate', rate);
555
-
556
- const avgSec = ds.avg_sec;
557
- setKpiValue('overall-avg-duration', avgSec != null ? formatDurationSec(avgSec) : '\u2014');
558
- var totalTokens = (tc && tc.total_tokens) || 0;
559
- var totalCost = (tc && tc.total_cost_usd) || 0;
560
- setKpiValue('overall-total-tokens', totalTokens > 0 ? formatTokens(totalTokens) : '\u2014');
561
- setKpiValue('overall-total-cost', totalCost > 0 ? '$' + totalCost.toFixed(2) : '\u2014');
562
-
563
- // Fallback: if overall stats show 0 tokens, sum from convoy list
564
- if (totalTokens === 0) {
565
- var convoyListFallback = (window.__DASHBOARD_DATA__ && window.__DASHBOARD_DATA__.convoyList) || [];
566
- if (convoyListFallback.length > 0) {
567
- var sumTokens = convoyListFallback.reduce(function(s, c) { return s + (c.total_tokens != null ? c.total_tokens : 0); }, 0);
568
- var sumCost = convoyListFallback.reduce(function(s, c) { return s + (c.total_cost_usd != null ? c.total_cost_usd : 0); }, 0);
569
- if (sumTokens > 0) {
570
- setKpiValue('overall-total-tokens', formatTokens(sumTokens));
571
- setKpiValue('overall-total-cost', '$' + sumCost.toFixed(2));
572
- } else {
573
- // Final fallback: estimate from task count (~5000 tokens/task at ~$8/1M tokens avg)
574
- var taskTotal = (stats.taskTotals && stats.taskTotals.totalTasks) || 0;
575
- if (taskTotal > 0) {
576
- var estTokens = taskTotal * 5000;
577
- var estCost = estTokens * 0.000008;
578
- setKpiValue('overall-total-tokens', '~' + formatTokens(estTokens));
579
- setKpiValue('overall-total-cost', '~$' + estCost.toFixed(2));
580
- } else {
581
- setKpiValue('overall-total-tokens', 'N/A (estimated)');
582
- setKpiValue('overall-total-cost', 'N/A (estimated)');
583
- }
584
- }
585
- }
586
- }
587
-
588
- // Total tasks and retries
589
- var tt = stats.taskTotals || {};
590
- setKpiValue('overall-total-tasks', String(tt.totalTasks || 0));
591
- setKpiValue('overall-total-retries', String(tt.totalRetries || 0));
592
- }
593
-
594
- function setKpiValue(id, value) {
595
- const el = document.getElementById(id);
596
- if (el) {
597
- const valEl = el.querySelector('.overall-kpi__value');
598
- if (valEl) valEl.textContent = value;
599
- }
600
- }
601
-
602
- function formatDurationSec(sec) {
603
- if (sec < 60) return Math.round(sec) + 's';
604
- const min = Math.floor(sec / 60);
605
- const remSec = Math.round(sec % 60);
606
- if (min < 60) return min + 'm ' + remSec + 's';
607
- const hr = Math.floor(min / 60);
608
- const remMin = min % 60;
609
- return hr + 'h ' + remMin + 'm';
610
- }
611
-
612
- function renderActivityTimeline() {
613
- var el = document.getElementById('activity-timeline-chart');
614
- if (!el) return;
615
- var data = window.__DASHBOARD_DATA__;
616
- var timeline = (data && data.overallStats && data.overallStats.activityTimeline) || [];
617
- if (timeline.length === 0) {
618
- el.innerHTML = emptyStateHtml('timeline', 'No activity yet', 'Convoy run activity will appear here as runs complete.');
619
- return;
620
- }
621
- var maxCount = Math.max.apply(null, timeline.map(function(d) { return d.count; }));
622
- var html = '<div class="activity-timeline activity-timeline--vertical">';
623
- for (var i = 0; i < timeline.length; i++) {
624
- var d = timeline[i];
625
- var pct = maxCount > 0 ? Math.round((d.count / maxCount) * 100) : 0;
626
- html += '<div class="vbar-col">' +
627
- '<span class="vbar-value">' + d.count + '</span>' +
628
- '<div class="vbar-track"><div class="vbar-fill" style="height:' + pct + '%"></div></div>' +
629
- '<span class="vbar-label">' + formatShortDate(d.date) + '</span>' +
630
- '</div>';
631
- }
632
- html += '</div>';
633
- el.innerHTML = html;
634
- }
635
-
636
- async function renderRecentSessions() {
637
- var el = document.getElementById('sessions-table');
638
- var detailEl = document.getElementById('detail-sessions-table');
639
- if (!el && !detailEl) return;
640
- try {
641
- var allEvents = await loadNdjson(base + 'data/events.ndjson');
642
- var sessions = allEvents.filter(function(e) { return e.type === 'session'; });
643
- sessions.sort(function(a, b) {
644
- return (b.timestamp || '').localeCompare(a.timestamp || '');
645
- });
646
- sessions = sessions.slice(0, 15);
647
- if (sessions.length === 0) {
648
- var emptyHtml = emptyStateHtml('sessions', 'No sessions recorded yet', 'Agent session data will appear here when sessions are logged via opencastle log.');
649
- if (el) el.innerHTML = emptyHtml;
650
- if (detailEl) detailEl.innerHTML = emptyHtml;
651
- return;
652
- }
653
- var thead = '<thead><tr>' +
654
- '<th>Agent</th><th>Task</th><th>Outcome</th><th>Duration</th><th>Retries</th><th>Files</th><th>Time</th>' +
655
- '</tr></thead>';
656
- var tbody = '<tbody>';
657
- for (var i = 0; i < sessions.length; i++) {
658
- var s = sessions[i];
659
- var outcomeClass = s.outcome === 'success' ? 'outcome-badge--success' : s.outcome === 'failed' ? 'outcome-badge--failed' : 'outcome-badge--partial';
660
- var filesVal = s.files_changed;
661
- var filesCell;
662
- if (Array.isArray(s.file_partition) && s.file_partition.length > 0) {
663
- filesCell = '<span class="tooltip-trigger" data-tooltip="' + escapeHtml(s.file_partition.join('\n')) + '">' + s.file_partition.length + ' file' + (s.file_partition.length !== 1 ? 's' : '') + '</span>';
664
- } else if (typeof filesVal === 'number') {
665
- filesCell = String(filesVal);
666
- } else {
667
- filesCell = '0';
668
- }
669
- tbody += '<tr>' +
670
- '<td class="td-agent" title="' + escapeHtml(s.agent || '') + '">' + escapeHtml(s.agent || '\u2014') + '</td>' +
671
- '<td class="td-task" title="' + escapeHtml(s.task || '') + '">' + escapeHtml(s.task || '\u2014') + '</td>' +
672
- '<td><span class="outcome-badge ' + outcomeClass + '">' + escapeHtml(s.outcome || '\u2014') + '</span></td>' +
673
- '<td>' + (s.duration_min != null ? s.duration_min + 'm' : '\u2014') + '</td>' +
674
- '<td>' + (s.retries || 0) + '</td>' +
675
- '<td>' + filesCell + '</td>' +
676
- '<td>' + (s.timestamp ? formatTime(s.timestamp) : '\u2014') + '</td>' +
677
- '</tr>';
678
- }
679
- tbody += '</tbody>';
680
- var tableHtml = '<table class="sessions-table">' + thead + tbody + '</table>';
681
- if (el) el.innerHTML = tableHtml;
682
- if (detailEl) detailEl.innerHTML = tableHtml;
683
- } catch (e) {
684
- var errHtml = emptyStateHtml('sessions', 'No sessions recorded yet', 'Agent session data will appear here when sessions are logged.');
685
- if (el) el.innerHTML = errHtml;
686
- if (detailEl) detailEl.innerHTML = errHtml;
687
- }
688
- }
689
-
690
- async function loadConvoyDetail(convoyId) {
691
- executionLogLimit = 10;
692
- if (!convoyId) {
693
- renderConvoyDetailHeader(null);
694
- ['pipeline-section', 'agent-section', 'tier-section', 'model-section', 'quality-section', 'reliability-section', 'drift-section', 'outputs-section', 'execution-section', 'event-timeline-section', 'panel-section', 'reviews-section'].forEach(function(id) {
695
- var el = document.getElementById(id);
696
- if (el) el.style.display = 'none';
697
- });
698
- return;
699
- }
700
- try {
701
- const resp = await fetch(base + 'data/convoys/' + encodeURIComponent(convoyId) + '.json');
702
- if (!resp.ok) throw new Error('Failed to load convoy detail');
703
- const detail = await resp.json();
704
- renderConvoyDetailHeader(detail);
705
- window.__SELECTED_CONVOY__ = detail;
706
- renderTaskSummaryCards(detail.tasks || []);
707
- renderTaskTable(detail.tasks || []);
708
- renderPhaseBreakdown(detail.tasks || []);
709
- const tasksSection = document.getElementById('tasks-section');
710
- if (tasksSection) tasksSection.style.display = '';
711
- renderDetailPipeline(detail.tasks || []);
712
- renderDetailAgentChart(detail.tasks || []);
713
- renderDetailTierChart(detail.tasks || []);
714
- renderDetailMechanismChart(detail.events || []);
715
- renderDetailModelChart(detail.tasks || []);
716
- renderQualitySection(detail);
717
- renderReliabilitySection(detail);
718
- renderDriftSection(detail);
719
- renderOutputsSection(detail);
720
- renderDetailExecutionLog(detail.tasks || []);
721
- renderEventTimeline(detail);
722
- renderDetailPanelChart(detail.tasks || []);
723
- renderDetailReviewsTable(detail.tasks || []);
724
- // Show pipeline chain if this convoy is part of a pipeline
725
- const convoyListForChain = window.__DASHBOARD_DATA__?.convoyList ?? [];
726
- const currentConvoyEntry = convoyListForChain.find(c => c.id === convoyId);
727
- if (currentConvoyEntry && currentConvoyEntry.pipeline_id) {
728
- const chainConvoys = convoyListForChain
729
- .filter(c => c.pipeline_id === currentConvoyEntry.pipeline_id)
730
- .sort((a, b) => (a.created_at || '').localeCompare(b.created_at || ''));
731
- if (chainConvoys.length > 1) {
732
- renderPipelineChain(chainConvoys, convoyId);
733
- }
734
- }
735
- await renderRecentSessions();
736
- } catch (e) {
737
- console.error('Failed to load convoy detail:', e);
738
- renderConvoyDetailHeader(null);
739
- ['pipeline-section', 'agent-section', 'tier-section', 'model-section', 'quality-section', 'reliability-section', 'drift-section', 'outputs-section', 'execution-section', 'event-timeline-section', 'panel-section', 'reviews-section'].forEach(function(id) {
740
- var el = document.getElementById(id);
741
- if (el) el.style.display = 'none';
742
- });
743
- }
744
- }
745
-
746
- function renderConvoyDetailHeader(detail) {
747
- const nameEl = document.getElementById('detail-hero-title');
748
- const statusEl = document.getElementById('detail-hero-status');
749
- const metaEl = document.getElementById('detail-hero-meta');
750
-
751
- if (!detail || !detail.convoy) {
752
- if (nameEl) nameEl.textContent = 'No convoy selected';
753
- if (statusEl) { statusEl.textContent = ''; statusEl.className = 'status-badge'; }
754
- if (metaEl) metaEl.innerHTML = '';
755
- ['tasks-section', 'pipeline-section', 'agent-section', 'tier-section', 'model-section', 'quality-section', 'reliability-section', 'drift-section', 'outputs-section', 'execution-section', 'event-timeline-section', 'panel-section', 'reviews-section'].forEach(function(id) {
756
- var el = document.getElementById(id);
757
- if (el) el.style.display = 'none';
758
- });
759
- return;
760
- }
761
-
762
- const c = detail.convoy;
763
- if (nameEl) nameEl.textContent = c.name || c.id;
764
- if (statusEl) {
765
- statusEl.textContent = c.status;
766
- statusEl.className = 'status-badge status-badge--' + c.status;
767
- }
768
- // Status explanation
769
- const statusExplanations = {
770
- 'running': 'This run is still in progress; some tasks are being executed.',
771
- 'done': 'This run completed successfully; all tasks finished.',
772
- 'failed': 'This run stopped because at least one task could not recover.',
773
- 'gate-failed': 'This run stopped because a quality check failed.',
774
- 'hook-failed': 'This run stopped because a lifecycle script failed.',
775
- };
776
- if (metaEl) {
777
- let html = '';
778
- if (c.branch) html += '<span class="convoy-meta__item">🌿 ' + escapeHtml(c.branch) + '</span>';
779
- if (c.created_at) html += '<span class="convoy-meta__item">\u25B6 ' + formatTime(c.created_at) + '</span>';
780
- if (c.finished_at) html += '<span class="convoy-meta__item">\u25A0 ' + formatTime(c.finished_at) + '</span>';
781
- if (c.created_at && c.finished_at) {
782
- const dur = formatDuration(c.created_at, c.finished_at);
783
- if (dur) html += '<span class="convoy-meta__item">\u23F1 ' + dur + '</span>';
784
- }
785
- if (c.total_tokens != null) html += '<span class="convoy-meta__item">\uD83D\uDD24 ' + formatTokens(c.total_tokens) + ' tokens</span>';
786
- if (c.total_cost_usd != null) html += '<span class="convoy-meta__item">\uD83D\uDCB0 $' + c.total_cost_usd.toFixed(2) + '</span>';
787
- metaEl.innerHTML = html;
788
- }
789
- }
790
-
791
- // ── Task Section ─────────────────────────────────────────
792
-
793
- const STATUS_TOOLTIPS = {
794
- 'done': 'Finished successfully.',
795
- 'running': 'Currently executing.',
796
- 'pending': 'Waiting to start.',
797
- 'assigned': 'Assigned to a worker, starting soon.',
798
- 'failed': 'Stopped due to an error.',
799
- 'gate-failed': 'A quality check did not pass.',
800
- 'timed-out': 'Exceeded the time limit.',
801
- 'review-blocked': 'Paused because a reviewer requested changes.',
802
- 'skipped': 'Skipped because a dependency failed.',
803
- 'hook-failed': 'A pre/post-task script encountered an error.',
804
- 'disputed': 'Under dispute after review disagreement.',
805
- 'wait-for-input': 'Paused \u2014 needs your input.',
806
- };
807
-
808
- let taskSortCol = 'phase';
809
- let taskSortAsc = true;
810
-
811
- function renderTaskSummaryCards(tasks) {
812
- const el = document.getElementById('task-summary-cards');
813
- if (!el) return;
814
- if (!tasks || tasks.length === 0) { el.innerHTML = ''; return; }
815
- const done = tasks.filter(t => t.status === 'done').length;
816
- const waiting = tasks.filter(t => t.status === 'pending' || t.status === 'assigned').length;
817
- const running = tasks.filter(t => t.status === 'running').length;
818
- const errors = tasks.filter(t => ['failed', 'gate-failed', 'timed-out', 'hook-failed'].includes(t.status)).length;
819
- const waitInput = tasks.filter(t => t.status === 'wait-for-input').length;
820
- const cards = [
821
- { label: 'Tasks Completed', value: done, tooltip: 'Tasks that finished successfully.', mod: 'done' },
822
- { label: 'Tasks Waiting', value: waiting, tooltip: 'Tasks not yet started.', mod: 'waiting' },
823
- { label: 'Tasks Running', value: running, tooltip: 'Tasks currently being executed.', mod: 'running' },
824
- { label: 'Tasks With Errors', value: errors, tooltip: 'Tasks that stopped due to errors.', mod: 'errors' },
825
- { label: 'Waiting For Input', value: waitInput, tooltip: 'Tasks paused until you provide input.', mod: 'input' },
826
- ];
827
- el.innerHTML = cards.map(card =>
828
- '<div class="task-summary-card task-summary-card--' + card.mod + '">' +
829
- '<span class="task-summary-card__label">' + escapeHtml(card.label) +
830
- ' <span class="tooltip-trigger" tabindex="0" role="button" aria-label="Info: ' + escapeHtml(card.tooltip) + '" data-tooltip="' + escapeHtml(card.tooltip) + '">' + INFO_ICON + '</span>' +
831
- '</span>' +
832
- '<span class="task-summary-card__value">' + card.value + '</span>' +
833
- '</div>'
834
- ).join('');
835
- }
836
-
837
- function renderTaskTable(tasks) {
838
- const el = document.getElementById('task-table-wrap');
839
- if (!el) return;
840
- if (!tasks || tasks.length === 0) {
841
- el.innerHTML = emptyStateHtml('pipeline', 'No tasks', 'This convoy has no tasks recorded.');
842
- return;
843
- }
844
- const cols = [
845
- { key: 'id', label: 'Task ID' },
846
- { key: 'phase', label: 'Phase' },
847
- { key: 'agent', label: 'Agent' },
848
- { key: 'status', label: 'Status' },
849
- { key: 'duration', label: 'Duration' },
850
- { key: 'retries', label: 'Retries' },
851
- { key: 'files', label: 'Files' },
852
- { key: 'total_tokens', label: 'Tokens' },
853
- ];
854
- const sorted = tasks.slice().sort((a, b) => {
855
- let av, bv;
856
- if (taskSortCol === 'duration') {
857
- av = (a.started_at && a.finished_at) ? (new Date(a.finished_at) - new Date(a.started_at)) : -1;
858
- bv = (b.started_at && b.finished_at) ? (new Date(b.finished_at) - new Date(b.started_at)) : -1;
859
- } else if (taskSortCol === 'files') {
860
- av = a.files ? a.files.length : 0;
861
- bv = b.files ? b.files.length : 0;
862
- } else {
863
- av = a[taskSortCol] != null ? a[taskSortCol] : '';
864
- bv = b[taskSortCol] != null ? b[taskSortCol] : '';
865
- }
866
- if (av < bv) return taskSortAsc ? -1 : 1;
867
- if (av > bv) return taskSortAsc ? 1 : -1;
868
- return 0;
869
- });
870
- const thead = '<thead><tr>' + cols.map(col => {
871
- const isActive = col.key === taskSortCol;
872
- const indicator = isActive ? (taskSortAsc ? ' \u25B2' : ' \u25BC') : ' \u25B6';
873
- const ariaSort = isActive ? (taskSortAsc ? 'ascending' : 'descending') : 'none';
874
- return '<th class="sortable-th' + (isActive ? ' sortable-th--active' : '') + '" data-sort-key="' + col.key + '" scope="col" aria-sort="' + ariaSort + '">' +
875
- escapeHtml(col.label) +
876
- '<span class="sort-indicator">' + indicator + '</span>' +
877
- '</th>';
878
- }).join('') + '</tr></thead>';
879
- const tbody = '<tbody>' + sorted.map(t => {
880
- const statusTip = STATUS_TOOLTIPS[t.status] || '';
881
- const statusBadge = '<span class="status-badge status-badge--' + escapeHtml(t.status) + '" title="' + escapeHtml(statusTip) + '" role="status">' + escapeHtml(t.status) + '</span>';
882
- const dur = formatDuration(t.started_at, t.finished_at) || '\u2014';
883
- const fileCount = t.files ? t.files.length : 0;
884
- const fileTip = t.files && t.files.length > 0 ? t.files.join('\n') : '';
885
- const filesCell = fileCount > 0
886
- ? '<span class="tooltip-trigger" data-tooltip="' + escapeHtml(fileTip) + '">' + fileCount + ' file' + (fileCount !== 1 ? 's' : '') + '</span>'
887
- : '<span style="opacity:0.4">\u2014</span>';
888
- const tokens = t.total_tokens != null ? formatTokens(t.total_tokens) : '\u2014';
889
- return '<tr>' +
890
- '<td class="td-task">' + escapeHtml(t.id || '\u2014') + '</td>' +
891
- '<td>' + (t.phase != null ? t.phase : '\u2014') + '</td>' +
892
- '<td class="td-agent">' + escapeHtml(t.agent || '\u2014') + '</td>' +
893
- '<td>' + statusBadge + '</td>' +
894
- '<td>' + dur + '</td>' +
895
- '<td class="td-num">' + t.retries + '</td>' +
896
- '<td>' + filesCell + '</td>' +
897
- '<td class="td-num">' + tokens + '</td>' +
898
- '</tr>';
899
- }).join('') + '</tbody>';
900
- el.innerHTML = '<table class="sessions-table task-table">' + thead + tbody + '</table>';
901
- el.querySelectorAll('.sortable-th').forEach(th => {
902
- th.addEventListener('click', function() {
903
- const key = this.dataset.sortKey;
904
- if (key === taskSortCol) {
905
- taskSortAsc = !taskSortAsc;
906
- } else {
907
- taskSortCol = key;
908
- taskSortAsc = true;
909
- }
910
- const convoy = window.__SELECTED_CONVOY__;
911
- renderTaskTable((convoy && convoy.tasks) ? convoy.tasks : []);
912
- });
913
- });
914
- }
915
-
916
- function renderPhaseBreakdown(tasks) {
917
- const el = document.getElementById('phase-breakdown');
918
- if (!el) return;
919
- if (!tasks || tasks.length === 0) { el.innerHTML = ''; return; }
920
- const phaseMap = {};
921
- for (const t of tasks) {
922
- const p = t.phase != null ? String(t.phase) : '0';
923
- if (!phaseMap[p]) phaseMap[p] = { done: 0, running: 0, waiting: 0, failed: 0 };
924
- if (t.status === 'done') phaseMap[p].done++;
925
- else if (t.status === 'running') phaseMap[p].running++;
926
- else if (t.status === 'pending' || t.status === 'assigned') phaseMap[p].waiting++;
927
- else phaseMap[p].failed++;
928
- }
929
- const phases = Object.keys(phaseMap).sort((a, b) => Number(a) - Number(b));
930
- if (phases.length === 0) { el.innerHTML = ''; return; }
931
- const html = phases.map(p => {
932
- const d = phaseMap[p];
933
- const total = d.done + d.running + d.waiting + d.failed;
934
- if (total === 0) return '';
935
- const pct = v => Math.round((v / total) * 100);
936
- const segments = [
937
- { cls: 'done', v: d.done },
938
- { cls: 'running', v: d.running },
939
- { cls: 'waiting', v: d.waiting },
940
- { cls: 'failed', v: d.failed },
941
- ].filter(s => s.v > 0);
942
- return '<div class="phase-breakdown__row">' +
943
- '<span class="phase-breakdown__label">Phase ' + escapeHtml(p) + '</span>' +
944
- '<div class="phase-breakdown__bar">' +
945
- segments.map(s =>
946
- '<div class="phase-breakdown__seg phase-breakdown__seg--' + s.cls + '" style="width:' + pct(s.v) + '%" title="' + s.cls + ': ' + s.v + '"></div>'
947
- ).join('') +
948
- '</div>' +
949
- '<span class="phase-breakdown__count">' + total + ' task' + (total !== 1 ? 's' : '') + '</span>' +
950
- '</div>';
951
- }).join('');
952
- el.innerHTML = html;
953
- }
954
-
955
- // ── Convoy Detail: Tier and Model Labels ─────────────────
956
-
957
- // Adapter names the engine records when the assistant did not report a model.
958
- var ADAPTER_NAMES = ['copilot', 'cursor', 'opencode', 'claude', 'codex', 'test-adapter'];
959
-
960
- function isRealModel(model) {
961
- return !!model && ADAPTER_NAMES.indexOf(model) === -1;
962
- }
963
-
964
- // Agent tiers. Kept in step with src/cli/tiers.ts, which is the source of truth.
965
- var PREMIUM_AGENTS = ['team-lead', 'architect', 'security-expert'];
966
- // Kept in step with the agents' own frontmatter by tiers.test.ts — four of the
967
- // names here outlived the agents they referred to.
968
- var ECONOMY_AGENTS = ['reviewer', 'writer'];
969
-
970
- function normalizeAgent(agent) {
971
- return (typeof agent === 'string' ? agent : '').toLowerCase().replace(/[\s\/]+/g, '-');
972
- }
973
-
974
- /**
975
- * Tier for a task. Prefers the reported model's family, since that is what
976
- * actually ran; falls back to the agent's configured tier.
977
- *
978
- * No model names are listed here on purpose — a pinned list goes stale
979
- * silently and used to disagree with the four other copies of it.
980
- */
981
- function deriveTier(model, agent) {
982
- if (isRealModel(model)) {
983
- var m = model.toLowerCase();
984
- if (m.includes('opus') || m.includes('fable') || m.includes('mythos')) return 'premium';
985
- if (m.includes('mini') || m.includes('haiku') || m.includes('flash')) return 'economy';
986
- if (m.includes('sonnet') || m.includes('pro') || m.includes('codex')) return 'standard';
987
- }
988
- var a = normalizeAgent(agent);
989
- if (!a) return model ? 'unknown' : 'unknown';
990
- if (PREMIUM_AGENTS.indexOf(a) !== -1) return 'premium';
991
- if (ECONOMY_AGENTS.indexOf(a) !== -1) return 'economy';
992
- return 'standard';
993
- }
994
-
995
- /**
996
- * Label for the model column. Reports what ran; when the assistant did not
997
- * say, names the adapter rather than guessing a model.
998
- */
999
- function deriveModel(model, agent) {
1000
- if (isRealModel(model)) return model;
1001
- return model || 'unknown';
1002
- }
1003
-
1004
- // ── Convoy Detail: Pipeline View ─────────────────────────
1005
-
1006
- function renderDetailPipeline(tasks) {
1007
- var el = document.getElementById('pipeline-view');
1008
- if (!el) return;
1009
-
1010
- if (!tasks || tasks.length === 0) {
1011
- el.innerHTML = emptyStateHtml('pipeline', 'No pipeline activity yet', 'Tasks will flow through execution phases here.');
1012
- return;
1013
- }
1014
-
1015
- var phases = {};
1016
- tasks.forEach(function(t) {
1017
- var p = t.phase != null ? t.phase : 0;
1018
- if (!phases[p]) phases[p] = { count: 0, done: 0, failed: 0, running: 0 };
1019
- phases[p].count++;
1020
- if (t.status === 'done') phases[p].done++;
1021
- else if (['failed', 'gate-failed', 'timed-out', 'hook-failed'].includes(t.status)) phases[p].failed++;
1022
- else if (t.status === 'running' || t.status === 'assigned') phases[p].running++;
1023
- });
1024
-
1025
- var phaseNums = Object.keys(phases).map(Number).sort(function(a, b) { return a - b; });
1026
- var PHASE_LABELS = ['Foundation', 'Integration', 'Validation', 'QA Gate', 'Phase 5', 'Phase 6'];
1027
- var PHASE_ICONS = [
1028
- { iconClass: 'pending', icon: '<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><rect x="4" y="4" width="16" height="16" rx="2"/><line x1="8" y1="10" x2="16" y2="10"/><line x1="8" y1="14" x2="13" y2="14"/></svg>' },
1029
- { iconClass: 'active', icon: '<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="3"/><path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06A1.65 1.65 0 0 0 4.68 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06A1.65 1.65 0 0 0 9 4.68a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"/></svg>' },
1030
- { iconClass: 'review', icon: '<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="8"/><line x1="21" y1="21" x2="16.65" y2="16.65"/></svg>' },
1031
- { iconClass: 'done', icon: '<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"/><polyline points="22 4 12 14.01 9 11.01"/></svg>' },
1032
- ];
1033
-
1034
- el.innerHTML =
1035
- '<div class="pipeline">' +
1036
- phaseNums.map(function(pn, i) {
1037
- var label = PHASE_LABELS[pn] !== undefined ? PHASE_LABELS[pn] : ('Phase ' + pn);
1038
- var iconIdx = Math.min(i, PHASE_ICONS.length - 1);
1039
- var phaseData = phases[pn];
1040
- return (i > 0 ? '<div class="pipeline-arrow">\u2192</div>' : '') +
1041
- '<div class="pipeline-stage">' +
1042
- '<div class="pipeline-stage__icon pipeline-stage__icon--' + PHASE_ICONS[iconIdx].iconClass + '">' + PHASE_ICONS[iconIdx].icon + '</div>' +
1043
- '<span class="pipeline-stage__count">' + phaseData.count + '</span>' +
1044
- '<span class="pipeline-stage__label">' + label + '</span>' +
1045
- '</div>';
1046
- }).join('') +
1047
- '</div>';
1048
- }
1049
-
1050
- // ── Convoy Detail: Agent Chart ───────────────────────────
1051
-
1052
- function renderDetailAgentChart(tasks) {
1053
- var el = document.getElementById('agent-chart');
1054
- if (!el) return;
1055
-
1056
- if (!tasks || tasks.length === 0) {
1057
- el.innerHTML = emptyStateHtml('agents', 'No agent data yet', 'A breakdown of tasks per agent will appear here.');
1058
- return;
1059
- }
1060
-
1061
- var agentMap = {};
1062
- tasks.forEach(function(t) {
1063
- var agent = t.agent || 'unknown';
1064
- if (!agentMap[agent]) agentMap[agent] = { done: 0, failed: 0, running: 0, other: 0, total: 0 };
1065
- if (t.status === 'done') agentMap[agent].done++;
1066
- else if (t.status === 'running') agentMap[agent].running++;
1067
- else if (['failed', 'gate-failed', 'timed-out', 'hook-failed'].includes(t.status)) agentMap[agent].failed++;
1068
- else agentMap[agent].other++;
1069
- agentMap[agent].total++;
1070
- });
1071
-
1072
- var agents = Object.entries(agentMap).sort(function(a, b) { return b[1].total - a[1].total; });
1073
- var maxTotal = Math.max.apply(null, agents.map(function(a) { return a[1].total; }));
1074
-
1075
- el.innerHTML = agents.map(function(entry) {
1076
- var name = entry[0];
1077
- var data = entry[1];
1078
- return '<div class="bar-row">' +
1079
- '<span class="bar-label">' + escapeHtml(name) + '</span>' +
1080
- '<div class="bar-track">' +
1081
- (data.done > 0 ? '<div class="bar-segment bar--success" style="width: ' + ((data.done / maxTotal) * 100).toFixed(1) + '%"></div>' : '') +
1082
- (data.running > 0 ? '<div class="bar-segment" style="width: ' + ((data.running / maxTotal) * 100).toFixed(1) + '%; background: #3b82f6"></div>' : '') +
1083
- (data.failed > 0 ? '<div class="bar-segment bar--failed" style="width: ' + ((data.failed / maxTotal) * 100).toFixed(1) + '%"></div>' : '') +
1084
- (data.other > 0 ? '<div class="bar-segment" style="width: ' + ((data.other / maxTotal) * 100).toFixed(1) + '%; background: #64748b"></div>' : '') +
1085
- '</div>' +
1086
- '<span class="bar-value">' + data.total + '</span>' +
1087
- '</div>';
1088
- }).join('');
1089
- }
1090
-
1091
- // ── Convoy Detail: Tier Donut Chart ──────────────────────
1092
-
1093
- function renderDetailTierChart(tasks) {
1094
- var el = document.getElementById('tier-chart');
1095
- if (!el) return;
1096
-
1097
- if (!tasks || tasks.length === 0) {
1098
- el.innerHTML = emptyStateHtml('tiers', 'No tier data yet', 'Model tier distribution will be shown as a donut chart.');
1099
- return;
1100
- }
1101
-
1102
- var tierCounts = {};
1103
- tasks.forEach(function(t) {
1104
- var tier = deriveTier(t.model, t.agent);
1105
- tierCounts[tier] = (tierCounts[tier] || 0) + 1;
1106
- });
1107
-
1108
- var order = ['premium', 'standard', 'utility', 'economy', 'unknown'];
1109
- var tiers = order.filter(function(t) { return tierCounts[t]; }).map(function(t) { return { name: t, count: tierCounts[t] }; });
1110
- var total = tasks.length;
1111
- var r = 70;
1112
- var circumference = 2 * Math.PI * r;
1113
- var cumOffset = 0;
1114
-
1115
- var circles = tiers.map(function(t) {
1116
- var pct = t.count / total;
1117
- var dashLen = pct * circumference;
1118
- var linecap = tiers.length === 1 ? 'butt' : 'round';
1119
- var segment = '<circle cx="90" cy="90" r="' + r + '" fill="none" stroke="' + (TIER_COLORS[t.name] || '#64748b') + '" stroke-width="18" stroke-dasharray="' + dashLen.toFixed(2) + ' ' + (circumference - dashLen).toFixed(2) + '" stroke-dashoffset="' + (-cumOffset).toFixed(2) + '" transform="rotate(-90 90 90)" stroke-linecap="' + linecap + '"/>';
1120
- cumOffset += dashLen;
1121
- return segment;
1122
- });
1123
-
1124
- var legend = tiers.map(function(t) {
1125
- return '<div class="legend-item"><span class="legend-dot" style="background: ' + (TIER_COLORS[t.name] || '#64748b') + '"></span><span class="legend-name">' + t.name + '</span><span class="legend-count">' + t.count + ' (' + Math.round((t.count / total) * 100) + '%)</span></div>';
1126
- }).join('');
1127
-
1128
- el.innerHTML =
1129
- '<div class="donut-container"><div class="donut-wrap"><svg viewBox="0 0 180 180" class="donut-svg">' + circles.join('') + '</svg><div class="donut-center"><span class="donut-total">' + total + '</span><span class="donut-total-label">total</span></div></div><div class="donut-legend">' + legend + '</div></div>';
1130
- }
1131
-
1132
- // ── Convoy Detail: Mechanism Donut Chart ─────────────────
1133
-
1134
- function renderDetailMechanismChart(events) {
1135
- var el = document.getElementById('mechanism-chart');
1136
- if (!el) return;
1137
-
1138
- var MECH_COLORS = { 'sub-agent': '#3b82f6', 'background': '#a78bfa', 'unknown': '#64748b' };
1139
- var MECH_LABELS = { 'sub-agent': 'Sub-agent (inline)', 'background': 'Background (worktree)', 'unknown': 'Unknown' };
1140
-
1141
- if (!events || events.length === 0) {
1142
- el.innerHTML = emptyStateHtml('mechanism', 'No delegation data yet', 'The split between sub-agent and background delegations will be shown here.');
1143
- return;
1144
- }
1145
-
1146
- var mechCounts = {};
1147
- events.forEach(function(e) {
1148
- if (e.type === 'task_assigned' || e.type === 'task_started' || e.type === 'delegation') {
1149
- var mech = (e.data && e.data.mechanism) || 'unknown';
1150
- mechCounts[mech] = (mechCounts[mech] || 0) + 1;
1151
- }
1152
- });
1153
-
1154
- var mechOrder = ['sub-agent', 'background', 'unknown'];
1155
- var mechs = mechOrder.filter(function(m) { return mechCounts[m]; }).map(function(m) { return { name: m, count: mechCounts[m] }; });
1156
-
1157
- var isAllUnknown = mechs.length === 0 || (mechs.length === 1 && mechs[0].name === 'unknown');
1158
- if (isAllUnknown) {
1159
- el.innerHTML = emptyStateHtml('mechanism', 'No delegation data', 'Delegation mechanism data is not available for this convoy.');
1160
- return;
1161
- }
1162
-
1163
- var total = mechs.reduce(function(s, m) { return s + m.count; }, 0);
1164
- var r = 70;
1165
- var circumference = 2 * Math.PI * r;
1166
- var cumOffset = 0;
1167
-
1168
- var circles = mechs.map(function(m) {
1169
- var pct = m.count / total;
1170
- var dashLen = pct * circumference;
1171
- var linecap = mechs.length === 1 ? 'butt' : 'round';
1172
- var segment = '<circle cx="90" cy="90" r="' + r + '" fill="none" stroke="' + (MECH_COLORS[m.name] || '#64748b') + '" stroke-width="18" stroke-dasharray="' + dashLen.toFixed(2) + ' ' + (circumference - dashLen).toFixed(2) + '" stroke-dashoffset="' + (-cumOffset).toFixed(2) + '" transform="rotate(-90 90 90)" stroke-linecap="' + linecap + '"/>';
1173
- cumOffset += dashLen;
1174
- return segment;
1175
- });
1176
-
1177
- var legend = mechs.map(function(m) {
1178
- return '<div class="legend-item"><span class="legend-dot" style="background: ' + (MECH_COLORS[m.name] || '#64748b') + '"></span><span class="legend-name">' + (MECH_LABELS[m.name] || m.name) + '</span><span class="legend-count">' + m.count + ' (' + Math.round((m.count / total) * 100) + '%)</span></div>';
1179
- }).join('');
1180
-
1181
- el.innerHTML =
1182
- '<div class="donut-container"><div class="donut-wrap"><svg viewBox="0 0 180 180" class="donut-svg">' + circles.join('') + '</svg><div class="donut-center"><span class="donut-total">' + total + '</span><span class="donut-total-label">total</span></div></div><div class="donut-legend">' + legend + '</div></div>';
1183
- }
1184
-
1185
- // ── Convoy Detail: Model Chart ───────────────────────────
1186
-
1187
- function renderDetailModelChart(tasks) {
1188
- var el = document.getElementById('model-chart');
1189
- if (!el) return;
1190
-
1191
- if (!tasks || tasks.length === 0) {
1192
- el.innerHTML = emptyStateHtml('models', 'No model data yet', 'Model utilization across tasks will be shown here.');
1193
- return;
1194
- }
1195
-
1196
- var modelCounts = {};
1197
- tasks.forEach(function(t) {
1198
- var model = deriveModel(t.model, t.agent);
1199
- if (model) modelCounts[model] = (modelCounts[model] || 0) + 1;
1200
- });
1201
-
1202
- var models = Object.entries(modelCounts).sort(function(a, b) { return b[1] - a[1]; });
1203
-
1204
- if (models.length === 0) {
1205
- el.innerHTML = emptyStateHtml('models', tasks.length > 0 ? 'Model information unavailable' : 'No model data yet', tasks.length > 0 ? 'No model information was recorded for tasks in this convoy.' : 'Model utilization across tasks will be shown here.');
1206
- return;
1207
- }
1208
-
1209
- var maxCount = Math.max.apply(null, models.map(function(m) { return m[1]; }));
1210
-
1211
- el.innerHTML = models.map(function(entry) {
1212
- var name = entry[0];
1213
- var count = entry[1];
1214
- return '<div class="bar-row">' +
1215
- '<span class="bar-label">' + escapeHtml(name) + '</span>' +
1216
- '<div class="bar-track"><div class="bar-segment" style="width: ' + ((count / maxCount) * 100).toFixed(1) + '%; background: ' + modelColor(name) + '"></div></div>' +
1217
- '<span class="bar-value">' + count + '</span>' +
1218
- '</div>';
1219
- }).join('');
1220
- }
1221
-
1222
- // ── Convoy Detail: Execution Log ─────────────────────────
1223
-
1224
- function renderDetailExecutionLog(tasks) {
1225
- var el = document.getElementById('execution-log');
1226
- if (!el) return;
1227
-
1228
- if (!tasks || tasks.length === 0) {
1229
- el.innerHTML = emptyStateHtml('execLog', 'No execution history yet', 'A step-by-step trace of task activity will appear here.');
1230
- return;
1231
- }
1232
-
1233
- var allSorted = tasks.slice().filter(function(t) { return t.started_at; }).sort(function(a, b) { return new Date(a.started_at) - new Date(b.started_at); });
1234
- var sorted = allSorted.slice(0, executionLogLimit);
1235
-
1236
- if (sorted.length === 0) {
1237
- el.innerHTML = emptyStateHtml('execLog', 'No execution history yet', 'A step-by-step trace of task activity will appear here.');
1238
- return;
1239
- }
1240
-
1241
- var statusToOutcome = function(s) {
1242
- if (s === 'done') return 'success';
1243
- if (['failed', 'gate-failed', 'timed-out', 'hook-failed'].includes(s)) return 'failed';
1244
- return 'partial';
1245
- };
1246
-
1247
- el.innerHTML =
1248
- '<div class="exec-log">' +
1249
- sorted.map(function(t, i) {
1250
- var outcome = statusToOutcome(t.status);
1251
- var dur = formatDuration(t.started_at, t.finished_at);
1252
- var fileCount = t.files ? t.files.length : 0;
1253
- return '<div class="exec-step">' +
1254
- '<div class="exec-step__indicator">' +
1255
- '<div class="exec-step__dot exec-step__dot--' + outcome + '">' + (OUTCOME_ICONS[outcome] || '') + '</div>' +
1256
- (i < sorted.length - 1 ? '<div class="exec-step__line"></div>' : '') +
1257
- '</div>' +
1258
- '<div class="exec-step__content">' +
1259
- '<div class="exec-step__header">' +
1260
- '<span class="exec-step__agent">' + escapeHtml(t.agent || 'unknown') + '</span>' +
1261
- '<span class="exec-step__badge exec-step__badge--' + outcome + '">' + escapeHtml(t.status) + '</span>' +
1262
- '</div>' +
1263
- '<div class="exec-step__task">' + escapeHtml(t.id) + '</div>' +
1264
- '<div class="exec-step__meta">' +
1265
- '<span class="exec-step__meta-item">\uD83D\uDD52 ' + formatTime(t.started_at) + '</span>' +
1266
- (dur ? '<span class="exec-step__meta-item">\u23F1 ' + dur + '</span>' : '') +
1267
- (fileCount > 0 ? '<span class="exec-step__meta-item">\uD83D\uDCC1 ' + fileCount + ' files</span>' : '') +
1268
- (t.model ? '<span class="exec-step__meta-item">\uD83E\uDD16 ' + escapeHtml(t.model) + '</span>' : '') +
1269
- (t.retries > 0 ? '<span class="exec-step__meta-item">\uD83D\uDD04 ' + t.retries + ' retries</span>' : '') +
1270
- (t.total_tokens != null ? '<span class="exec-step__meta-item">\uD83D\uDD24 ' + formatTokens(t.total_tokens) + '</span>' : '') +
1271
- '</div>' +
1272
- '</div>' +
1273
- '</div>';
1274
- }).join('') +
1275
- '</div>';
1276
- if (allSorted.length > executionLogLimit) {
1277
- var remaining = allSorted.length - executionLogLimit;
1278
- el.innerHTML += '<div style="text-align:center;padding:16px"><button class="dash-btn dash-btn--ghost" id="exec-log-more-btn" type="button">Show more (' + remaining + ' remaining)</button></div>';
1279
- document.getElementById('exec-log-more-btn')?.addEventListener('click', function() {
1280
- executionLogLimit = allSorted.length;
1281
- var convoy = window.__SELECTED_CONVOY__;
1282
- renderDetailExecutionLog((convoy && convoy.tasks) ? convoy.tasks : []);
1283
- });
1284
- }
1285
- }
1286
-
1287
- // ── Convoy Detail: Panel Reviews ─────────────────────────
1288
-
1289
- function renderDetailPanelChart(tasks) {
1290
- var el = document.getElementById('panel-chart');
1291
- if (!el) return;
1292
-
1293
- var panelTasks = (tasks || []).filter(function(t) { return t.panel_attempts > 0; });
1294
-
1295
- if (panelTasks.length === 0) {
1296
- el.innerHTML = emptyStateHtml('panels', 'No panel reviews', 'This convoy completed without requiring panel reviews.');
1297
- return;
1298
- }
1299
-
1300
- el.innerHTML =
1301
- '<div class="panel-grid">' +
1302
- panelTasks.map(function(t) {
1303
- var verdictUpper = t.review_verdict ? t.review_verdict.toUpperCase() : 'PENDING';
1304
- var verdictClass = verdictUpper === 'PASS' ? 'PASS' : 'BLOCK';
1305
- return '<div class="panel-item">' +
1306
- '<div class="panel-item__header">' +
1307
- '<span class="panel-item__key">' + escapeHtml(t.id) + '</span>' +
1308
- '<span class="panel-item__verdict panel-item__verdict--' + verdictClass + '">' + verdictUpper + '</span>' +
1309
- '</div>' +
1310
- '<div class="panel-item__votes">' +
1311
- (verdictUpper === 'PASS' ? '<div class="panel-item__vote panel-item__vote--pass">\u2713</div>' : '<div class="panel-item__vote panel-item__vote--block">\u2717</div>') +
1312
- '</div>' +
1313
- '<div class="panel-item__meta">' +
1314
- '<span class="panel-item__meta-item">\uD83E\uDD16 ' + escapeHtml(t.review_model || 'unknown') + '</span>' +
1315
- (t.panel_attempts > 1 ? '<span class="panel-item__meta-item">\uD83D\uDD04 ' + t.panel_attempts + ' attempts</span>' : '') +
1316
- (t.review_tokens != null ? '<span class="panel-item__meta-item">\uD83D\uDD24 ' + formatTokens(t.review_tokens) + '</span>' : '') +
1317
- '</div>' +
1318
- '</div>';
1319
- }).join('') +
1320
- '</div>';
1321
- }
1322
-
1323
- // ── Convoy Detail: Fast Reviews ──────────────────────────
1324
-
1325
- function renderDetailReviewsTable(tasks) {
1326
- var el = document.getElementById('reviews-table');
1327
- if (!el) return;
1328
-
1329
- var reviewedTasks = (tasks || []).filter(function(t) { return t.review_level != null; });
1330
-
1331
- if (reviewedTasks.length === 0) {
1332
- el.innerHTML = emptyStateHtml('panels', 'No fast reviews', 'This convoy completed without fast review gates.');
1333
- return;
1334
- }
1335
-
1336
- el.innerHTML =
1337
- '<table class="sessions-table">' +
1338
- '<thead><tr>' +
1339
- '<th scope="col">Task ID</th>' +
1340
- '<th scope="col">Agent</th>' +
1341
- '<th scope="col">Review Level</th>' +
1342
- '<th scope="col">Verdict</th>' +
1343
- '<th scope="col">Model</th>' +
1344
- '<th scope="col">Tokens</th>' +
1345
- '</tr></thead>' +
1346
- '<tbody>' +
1347
- reviewedTasks.map(function(t) {
1348
- var verdictUpper = t.review_verdict ? t.review_verdict.toUpperCase() : '';
1349
- var verdictBadge = t.review_verdict
1350
- ? '<span class="status-badge status-badge--' + (verdictUpper === 'PASS' ? 'done' : 'failed') + '">' + escapeHtml(t.review_verdict) + '</span>'
1351
- : '<span style="opacity:0.4">\u2014</span>';
1352
- return '<tr>' +
1353
- '<td class="td-task">' + escapeHtml(t.id || '\u2014') + '</td>' +
1354
- '<td class="td-agent">' + escapeHtml(t.agent || '\u2014') + '</td>' +
1355
- '<td>' + escapeHtml(t.review_level || '\u2014') + '</td>' +
1356
- '<td>' + verdictBadge + '</td>' +
1357
- '<td>' + escapeHtml(t.review_model || '\u2014') + '</td>' +
1358
- '<td class="td-num">' + (t.review_tokens != null ? formatTokens(t.review_tokens) : '\u2014') + '</td>' +
1359
- '</tr>';
1360
- }).join('') +
1361
- '</tbody></table>';
1362
- }
1363
-
1364
- // ── Quality Section ──────────────────────────────────────
1365
-
1366
- function renderQualitySection(detail) {
1367
- var section = document.getElementById('quality-section');
1368
- if (!section) return;
1369
- section.style.display = '';
1370
-
1371
- var q = detail.quality || {};
1372
- var qCards = [
1373
- { label: 'Tasks Reviewed', value: q.reviewed_tasks != null ? q.reviewed_tasks : 0, tooltip: 'Tasks that completed a code review check.', mod: 'done' },
1374
- { label: 'Blocked by Review', value: q.review_blocked_tasks != null ? q.review_blocked_tasks : 0, tooltip: 'Tasks paused because a reviewer requested changes.', mod: 'errors' },
1375
- { label: 'Disputes Opened', value: q.disputed_tasks != null ? q.disputed_tasks : 0, tooltip: 'Tasks where reviewers disagreed and opened a formal dispute.', mod: 'waiting' },
1376
- { label: 'Panel Reviews', value: q.panel_reviews != null ? q.panel_reviews : 0, tooltip: 'Tasks that went to a 3-reviewer panel vote for a final decision.', mod: 'running' },
1377
- ];
1378
-
1379
- var cardsEl = document.getElementById('quality-cards');
1380
- if (cardsEl) {
1381
- cardsEl.innerHTML = qCards.map(function(card) {
1382
- return '<div class="task-summary-card task-summary-card--' + card.mod + '">' +
1383
- '<span class="task-summary-card__label">' + escapeHtml(card.label) +
1384
- ' <span class="tooltip-trigger" tabindex="0" role="button" aria-label="Info: ' + escapeHtml(card.tooltip) + '" data-tooltip="' + escapeHtml(card.tooltip) + '">' + INFO_ICON + '</span>' +
1385
- '</span>' +
1386
- '<span class="task-summary-card__value">' + card.value + '</span>' +
1387
- '</div>';
1388
- }).join('');
1389
- }
1390
-
1391
- var reviewTasks = (detail.tasks || []).filter(function(t) { return t.review_level != null; });
1392
- var tableEl = document.getElementById('quality-review-table');
1393
- if (!tableEl) return;
1394
-
1395
- if (reviewTasks.length === 0) {
1396
- tableEl.innerHTML = emptyStateHtml('panels', 'No reviewed tasks', 'Tasks with code reviews will appear here.');
1397
- return;
1398
- }
1399
-
1400
- tableEl.innerHTML =
1401
- '<table class="sessions-table" style="margin-top:16px">' +
1402
- '<thead><tr>' +
1403
- '<th scope="col">Task ID</th>' +
1404
- '<th scope="col">Review Level</th>' +
1405
- '<th scope="col">Verdict</th>' +
1406
- '<th scope="col">Reviewer Model</th>' +
1407
- '<th scope="col">Review Tokens</th>' +
1408
- '<th scope="col">Panel Attempts</th>' +
1409
- '</tr></thead>' +
1410
- '<tbody>' +
1411
- reviewTasks.map(function(t) {
1412
- var verdictUpper = t.review_verdict ? t.review_verdict.toUpperCase() : '';
1413
- var verdictBadge = t.review_verdict
1414
- ? '<span class="status-badge status-badge--' + (verdictUpper === 'PASS' ? 'done' : 'failed') + '">' + escapeHtml(t.review_verdict) + '</span>'
1415
- : '<span style="opacity:0.4">\u2014</span>';
1416
- return '<tr>' +
1417
- '<td class="td-task">' + escapeHtml(t.id || '\u2014') + '</td>' +
1418
- '<td>' + escapeHtml(t.review_level || '\u2014') + '</td>' +
1419
- '<td>' + verdictBadge + '</td>' +
1420
- '<td>' + escapeHtml(t.review_model || '\u2014') + '</td>' +
1421
- '<td class="td-num">' + (t.review_tokens != null ? formatTokens(t.review_tokens) : '\u2014') + '</td>' +
1422
- '<td class="td-num">' + (t.panel_attempts != null ? t.panel_attempts : '\u2014') + '</td>' +
1423
- '</tr>';
1424
- }).join('') +
1425
- '</tbody></table>';
1426
- }
1427
-
1428
- // ── Reliability Section ──────────────────────────────────
1429
-
1430
- function renderReliabilitySection(detail) {
1431
- var section = document.getElementById('reliability-section');
1432
- if (!section) return;
1433
- section.style.display = '';
1434
-
1435
- var dlqCount = detail.dlq_count || 0;
1436
- var dlqEntries = detail.dlq_entries || [];
1437
- var tasks = detail.tasks || [];
1438
-
1439
- var dlqCardEl = document.getElementById('reliability-dlq-card');
1440
- if (dlqCardEl) {
1441
- var totalRetries = tasks.reduce(function(s, t) { return s + (t.retries || 0); }, 0);
1442
- var doneTasks = tasks.filter(function(t) { return t.status === 'done'; }).length;
1443
- var successRate = tasks.length > 0 ? Math.round((doneTasks / tasks.length) * 100) + '%' : '\u2014';
1444
- dlqCardEl.innerHTML =
1445
- '<div class="task-summary-cards">' +
1446
- '<div class="task-summary-card task-summary-card--' + (dlqCount > 0 ? 'errors' : 'done') + '">' +
1447
- '<span class="task-summary-card__label">Retry Queue <span class="tooltip-trigger" tabindex="0" role="button" aria-label="Info: Tasks that failed too many times and need manual attention. Also known as Dead Letter Queue (DLQ)." data-tooltip="Tasks that failed too many times and need manual attention. Also known as Dead Letter Queue (DLQ).">' + INFO_ICON + '</span></span>' +
1448
- '<span class="task-summary-card__value">' + dlqCount + '</span>' +
1449
- '</div>' +
1450
- '<div class="task-summary-card task-summary-card--running">' +
1451
- '<span class="task-summary-card__label">Total Retries <span class="tooltip-trigger" tabindex="0" role="button" aria-label="Info: Total number of task retries across all tasks in this convoy." data-tooltip="Total number of task retries across all tasks in this convoy.">' + INFO_ICON + '</span></span>' +
1452
- '<span class="task-summary-card__value">' + totalRetries + '</span>' +
1453
- '</div>' +
1454
- '<div class="task-summary-card task-summary-card--done">' +
1455
- '<span class="task-summary-card__label">Task Success Rate <span class="tooltip-trigger" tabindex="0" role="button" aria-label="Info: Percentage of tasks that completed successfully." data-tooltip="Percentage of tasks that completed successfully.">' + INFO_ICON + '</span></span>' +
1456
- '<span class="task-summary-card__value">' + successRate + '</span>' +
1457
- '</div>' +
1458
- '</div>';
1459
- }
1460
-
1461
- var dlqTableEl = document.getElementById('reliability-dlq-table');
1462
- if (dlqTableEl) {
1463
- if (dlqEntries.length === 0) {
1464
- dlqTableEl.innerHTML = '<p class="reliability-empty">No retry queue entries \u2014 all tasks completed without exceeding retry limits.</p>';
1465
- } else {
1466
- dlqTableEl.innerHTML =
1467
- '<table class="sessions-table" style="margin-top:16px">' +
1468
- '<thead><tr>' +
1469
- '<th scope="col">Task ID</th><th scope="col">Agent</th><th scope="col">Failure Type</th><th scope="col">Attempts</th><th scope="col">Resolved</th>' +
1470
- '</tr></thead>' +
1471
- '<tbody>' +
1472
- dlqEntries.map(function(e) {
1473
- return '<tr>' +
1474
- '<td class="td-task">' + escapeHtml(e.task_id || '\u2014') + '</td>' +
1475
- '<td class="td-agent">' + escapeHtml(e.agent || '\u2014') + '</td>' +
1476
- '<td>' + escapeHtml(e.failure_type || '\u2014') + '</td>' +
1477
- '<td class="td-num">' + (e.attempts != null ? e.attempts : '\u2014') + '</td>' +
1478
- '<td class="td-num">' + (e.resolved ? '\u2713' : '\u2014') + '</td>' +
1479
- '</tr>';
1480
- }).join('') +
1481
- '</tbody></table>';
1482
- }
1483
- }
1484
-
1485
- var errorEl = document.getElementById('reliability-error-overview');
1486
- if (errorEl) {
1487
- var errorCategories = [
1488
- { key: 'failed', label: 'Failed', color: '#ef4444' },
1489
- { key: 'gate-failed', label: 'Quality Check Failed', color: '#f59e0b' },
1490
- { key: 'timed-out', label: 'Timed Out', color: '#a78bfa' },
1491
- { key: 'hook-failed', label: 'Lifecycle Script Failed', color: '#64748b' },
1492
- ];
1493
- var counts = errorCategories.map(function(cat) {
1494
- return { key: cat.key, label: cat.label, color: cat.color, count: tasks.filter(function(t) { return t.status === cat.key; }).length };
1495
- });
1496
- var maxCount = Math.max(1, counts.reduce(function(m, c) { return Math.max(m, c.count); }, 0));
1497
- var hasErrors = counts.some(function(c) { return c.count > 0; });
1498
-
1499
- if (!hasErrors) {
1500
- errorEl.innerHTML = '<p class="reliability-empty">\u2713 No errors in this convoy.</p>';
1501
- } else {
1502
- errorEl.innerHTML = counts.map(function(cat) {
1503
- return '<div class="bar-row">' +
1504
- '<span class="bar-label">' + escapeHtml(cat.label) + '</span>' +
1505
- '<div class="bar-track">' +
1506
- '<div class="bar-segment" style="width: ' + ((cat.count / maxCount) * 100).toFixed(1) + '%; background: ' + cat.color + '"></div>' +
1507
- '</div>' +
1508
- '<span class="bar-value">' + cat.count + '</span>' +
1509
- '</div>';
1510
- }).join('');
1511
- }
1512
- }
1513
- }
1514
-
1515
- // ── Drift Section ────────────────────────────────────────
1516
-
1517
- function renderDriftSection(detail) {
1518
- var section = document.getElementById('drift-section');
1519
- if (!section) return;
1520
- section.style.display = '';
1521
-
1522
- var d = detail.drift || {};
1523
- // drift_score represents on-plan confidence (0.95 = 95% on-plan). Invert to deviation.
1524
- var maxScoreRaw = d.max_drift_score;
1525
- var deviationPct = maxScoreRaw != null ? Math.round((1 - maxScoreRaw) * 100) : 0;
1526
- var tasksWithDrift = d.tasks_with_drift != null ? d.tasks_with_drift : 0;
1527
- var driftCards = [
1528
- { label: 'Tasks With Drift', value: tasksWithDrift, tooltip: 'Tasks where the agent was checked for plan deviation.', mod: tasksWithDrift > 0 ? 'waiting' : 'done' },
1529
- { label: 'Max Deviation', value: deviationPct + '%', tooltip: 'Highest deviation from the original plan. 0% = perfectly on-track, 100% = completely off-plan.', mod: deviationPct > 30 ? 'errors' : deviationPct > 10 ? 'waiting' : 'done' },
1530
- { label: 'Drift Retried', value: d.drift_retried_tasks != null ? d.drift_retried_tasks : 0, tooltip: 'Tasks that were retried because drift exceeded the allowed threshold.', mod: 'running' },
1531
- ];
1532
-
1533
- var cardsEl = document.getElementById('drift-cards');
1534
- if (cardsEl) {
1535
- cardsEl.innerHTML = driftCards.map(function(card) {
1536
- return '<div class="task-summary-card task-summary-card--' + card.mod + '">' +
1537
- '<span class="task-summary-card__label">' + escapeHtml(String(card.label)) +
1538
- ' <span class="tooltip-trigger" tabindex="0" role="button" aria-label="Info: ' + escapeHtml(card.tooltip) + '" data-tooltip="' + escapeHtml(card.tooltip) + '">' + INFO_ICON + '</span>' +
1539
- '</span>' +
1540
- '<span class="task-summary-card__value">' + card.value + '</span>' +
1541
- '</div>';
1542
- }).join('');
1543
- }
1544
-
1545
- var bannerEl = document.getElementById('drift-secret-banner');
1546
- if (bannerEl) {
1547
- var events = detail.events || [];
1548
- var leakEvents = events.filter(function(e) { return e.type === 'secret_leak_prevented'; });
1549
- if (leakEvents.length > 0) {
1550
- bannerEl.style.display = '';
1551
- bannerEl.innerHTML =
1552
- '<div class="secret-leak-banner">' +
1553
- '<span class="secret-leak-banner__icon">\u26A0\uFE0F</span>' +
1554
- '<div class="secret-leak-banner__text">' +
1555
- '<strong>' + leakEvents.length + ' secret leak' + (leakEvents.length !== 1 ? 's' : '') + ' prevented</strong>' +
1556
- '<span>The security gate blocked credentials or tokens from being exposed. No action needed \u2014 the agent handled it correctly.</span>' +
1557
- '</div>' +
1558
- '</div>';
1559
- } else {
1560
- bannerEl.style.display = 'none';
1561
- }
1562
- }
1563
- }
1564
-
1565
- // ── Outputs Section ────────────────────────────────────
1566
- function renderOutputsSection(detail) {
1567
- var section = document.getElementById('outputs-section');
1568
- if (!section) return;
1569
- section.style.display = '';
1570
-
1571
- var artifacts = detail.artifacts || [];
1572
- var artifactCount = artifacts.length;
1573
-
1574
- // Fallback: count unique files touched across all tasks
1575
- var fileSet = {};
1576
- var tasks = detail.tasks || [];
1577
- tasks.forEach(function(t) {
1578
- if (t.files && Array.isArray(t.files)) {
1579
- t.files.forEach(function(f) { fileSet[f] = true; });
1580
- }
1581
- });
1582
- var fileCount = Object.keys(fileSet).length;
1583
- var displayCount = artifactCount > 0 ? artifactCount : fileCount;
1584
- var countLabel = artifactCount > 0 ? 'Artifacts' : 'Files Touched';
1585
- var countTooltip = artifactCount > 0 ? 'Structured outputs produced by tasks.' : 'Files created or modified by tasks in this convoy.';
1586
-
1587
- var cardsEl = document.getElementById('outputs-cards');
1588
- if (cardsEl) {
1589
- cardsEl.innerHTML =
1590
- '<div class="task-summary-card task-summary-card--done">' +
1591
- '<span class="task-summary-card__label">' + countLabel + ' ' +
1592
- '<span class="tooltip-trigger" tabindex="0" role="button" aria-label="Info: ' + escapeHtml(countTooltip) + '" data-tooltip="' + escapeHtml(countTooltip) + '">' + INFO_ICON + '</span>' +
1593
- '</span>' +
1594
- '<span class="task-summary-card__value">' + displayCount + '</span>' +
1595
- '</div>';
1596
- }
1597
-
1598
- var tableEl = document.getElementById('artifact-table-wrap');
1599
- if (!tableEl) return;
1600
-
1601
- if (artifacts.length === 0 && fileCount === 0) {
1602
- tableEl.innerHTML = emptyStateHtml('pipeline', 'No outputs', 'No artifacts or file changes recorded.');
1603
- return;
1604
- }
1605
-
1606
- var TYPE_BADGE_COLORS = { file: '#64748b', summary: '#3b82f6', json: '#a78bfa' };
1607
-
1608
- if (artifacts.length > 0) {
1609
- tableEl.innerHTML =
1610
- '<table class="sessions-table" style="margin-top:16px">' +
1611
- '<thead><tr><th scope="col">Name</th><th scope="col">Type</th><th scope="col">Task</th><th scope="col">Created At</th></tr></thead>' +
1612
- '<tbody>' +
1613
- artifacts.map(function(a) {
1614
- var badgeColor = TYPE_BADGE_COLORS[a.type] || '#64748b';
1615
- var typeBadge = '<span class="artifact-type-badge" style="background:' + badgeColor + '">' + escapeHtml(a.type) + '</span>';
1616
- var taskCell = a.task_id ? escapeHtml(a.task_id) : '<span style="opacity:0.4">\u2014</span>';
1617
- var created = a.created_at ? formatTime(a.created_at) : '\u2014';
1618
- return '<tr>' +
1619
- '<td>' + escapeHtml(a.name) + '</td>' +
1620
- '<td>' + typeBadge + '</td>' +
1621
- '<td class="td-task">' + taskCell + '</td>' +
1622
- '<td>' + created + '</td>' +
1623
- '</tr>';
1624
- }).join('') +
1625
- '</tbody></table>';
1626
- } else {
1627
- var fileEntries = Object.keys(fileSet).sort();
1628
- tableEl.innerHTML =
1629
- '<table class="sessions-table" style="margin-top:16px">' +
1630
- '<thead><tr><th scope="col">File</th><th scope="col">Task</th></tr></thead>' +
1631
- '<tbody>' +
1632
- fileEntries.map(function(f) {
1633
- var ownerTask = tasks.find(function(t) { return t.files && Array.isArray(t.files) && t.files.indexOf(f) >= 0; });
1634
- return '<tr><td>' + escapeHtml(f) + '</td><td class="td-task">' + (ownerTask ? escapeHtml(ownerTask.id) : '\u2014') + '</td></tr>';
1635
- }).join('') +
1636
- '</tbody></table>';
1637
- }
1638
- }
1639
-
1640
- // ── Event Timeline Section ─────────────────────────────
1641
- var eventTimelinePageSize = 20;
1642
- var eventTimelineCurrentPage = 1;
1643
- var eventTimelineActiveFilter = 'all';
1644
- var eventTimelineAllEvents = [];
1645
-
1646
- var EVENT_CATEGORIES = {
1647
- lifecycle: ['convoy_started', 'convoy_finished', 'convoy_failed'],
1648
- tasks: ['task_started', 'task_done', 'task_failed', 'task_assigned', 'task_skipped', 'task_retried', 'task_timed_out', 'task_gate_failed', 'task_hook_failed', 'task_wait_input'],
1649
- reviews: ['review_started', 'review_verdict', 'panel_started', 'panel_verdict'],
1650
- system: ['circuit_breaker_open', 'circuit_breaker_close', 'circuit_breaker_half_open', 'merge_conflict_detected', 'merge_conflict_resolved', 'watch_started', 'watch_stopped', 'watch_cycle_start', 'watch_cycle_end', 'secret_leak_prevented'],
1651
- errors: []
1652
- };
1653
-
1654
- var EVENT_TYPE_COLORS = {};
1655
- EVENT_CATEGORIES.lifecycle.forEach(function(t) { EVENT_TYPE_COLORS[t] = '#3b82f6'; });
1656
- EVENT_CATEGORIES.tasks.forEach(function(t) { EVENT_TYPE_COLORS[t] = t.includes('fail') || t.includes('timed') ? '#ef4444' : '#10b981'; });
1657
- EVENT_CATEGORIES.reviews.forEach(function(t) { EVENT_TYPE_COLORS[t] = '#a78bfa'; });
1658
- EVENT_CATEGORIES.system.forEach(function(t) { EVENT_TYPE_COLORS[t] = '#f59e0b'; });
1659
-
1660
- function getEventCategory(type) {
1661
- if (EVENT_CATEGORIES.lifecycle.includes(type)) return 'lifecycle';
1662
- if (EVENT_CATEGORIES.tasks.includes(type)) return 'tasks';
1663
- if (EVENT_CATEGORIES.reviews.includes(type)) return 'reviews';
1664
- if (EVENT_CATEGORIES.system.includes(type)) return 'system';
1665
- return 'meta';
1666
- }
1667
-
1668
- function isErrorEvent(evt) {
1669
- var type = evt.type || '';
1670
- return type.includes('fail') || type.includes('block') || type.includes('error') || type.includes('timed_out') || type.includes('circuit_breaker_open');
1671
- }
1672
-
1673
- function renderEventTimeline(detail) {
1674
- var section = document.getElementById('event-timeline-section');
1675
- if (!section) return;
1676
- section.style.display = '';
1677
-
1678
- eventTimelineAllEvents = (detail.events || []).slice().sort(function(a, b) {
1679
- if (!a.created_at || !b.created_at) return 0;
1680
- return a.created_at < b.created_at ? -1 : a.created_at > b.created_at ? 1 : 0;
1681
- });
1682
- eventTimelineCurrentPage = 1;
1683
- eventTimelineActiveFilter = 'all';
1684
-
1685
- renderEventTimelineFilters();
1686
- renderEventTimelineList();
1687
- }
1688
-
1689
- function renderEventTimelineFilters() {
1690
- var el = document.getElementById('event-timeline-filters');
1691
- if (!el) return;
1692
-
1693
- var filters = [
1694
- { key: 'all', label: 'All' },
1695
- { key: 'lifecycle', label: 'Lifecycle' },
1696
- { key: 'tasks', label: 'Tasks' },
1697
- { key: 'reviews', label: 'Reviews' },
1698
- { key: 'system', label: 'System' },
1699
- { key: 'errors', label: 'Errors' },
1700
- ];
1701
-
1702
- el.innerHTML = filters.map(function(f) {
1703
- var active = f.key === eventTimelineActiveFilter ? ' timeline-filter-chip--active' : '';
1704
- return '<button class="timeline-filter-chip' + active + '" data-filter="' + f.key + '" type="button" aria-label="Filter events: ' + escapeHtml(f.label) + '">' + escapeHtml(f.label) + '</button>';
1705
- }).join('');
1706
-
1707
- el.querySelectorAll('.timeline-filter-chip').forEach(function(btn) {
1708
- btn.addEventListener('click', function() {
1709
- eventTimelineActiveFilter = this.dataset.filter;
1710
- eventTimelineCurrentPage = 1;
1711
- renderEventTimelineFilters();
1712
- renderEventTimelineList();
1713
- });
1714
- });
1715
- }
1716
-
1717
- function getFilteredEvents() {
1718
- if (eventTimelineActiveFilter === 'all') return eventTimelineAllEvents;
1719
- if (eventTimelineActiveFilter === 'errors') return eventTimelineAllEvents.filter(isErrorEvent);
1720
- var cats = EVENT_CATEGORIES[eventTimelineActiveFilter];
1721
- if (!cats) return eventTimelineAllEvents;
1722
- return eventTimelineAllEvents.filter(function(evt) { return cats.includes(evt.type); });
1723
- }
1724
-
1725
- function renderEventTimelineList() {
1726
- var el = document.getElementById('event-timeline-list');
1727
- if (!el) return;
1728
-
1729
- var filtered = getFilteredEvents();
1730
- var visible = filtered.slice(0, eventTimelineCurrentPage * eventTimelinePageSize);
1731
-
1732
- if (filtered.length === 0) {
1733
- el.innerHTML = emptyStateHtml('timeline', 'No events', 'Events from this convoy will appear here.');
1734
- document.getElementById('event-timeline-load-more').style.display = 'none';
1735
- return;
1736
- }
1737
-
1738
- el.innerHTML = visible.map(function(evt, idx) {
1739
- var typeColor = EVENT_TYPE_COLORS[evt.type] || '#64748b';
1740
- var ts = evt.created_at ? formatTime(evt.created_at) : '—';
1741
- var taskInfo = evt.task_id ? '<span class="event-timeline-context">' + escapeHtml(evt.task_id) + '</span>' : '';
1742
- var dataJson = evt.data ? JSON.stringify(evt.data, null, 2) : null;
1743
-
1744
- return '<div class="event-timeline-row" data-event-idx="' + idx + '" role="button" tabindex="0" aria-label="Event: ' + escapeHtml(evt.type) + (evt.task_id ? ', task: ' + escapeHtml(evt.task_id) : '') + '">' +
1745
- '<div class="event-timeline-row__main">' +
1746
- '<span class="event-timeline-ts">' + ts + '</span>' +
1747
- '<span class="event-type-badge" style="background:' + typeColor + '">' + escapeHtml(evt.type) + '</span>' +
1748
- taskInfo +
1749
- '</div>' +
1750
- (dataJson
1751
- ? '<div class="event-timeline-detail" style="display:none"><pre class="event-timeline-json">' + escapeHtml(dataJson) + '</pre></div>'
1752
- : '') +
1753
- '</div>';
1754
- }).join('');
1755
-
1756
- el.querySelectorAll('.event-timeline-row').forEach(function(row) {
1757
- row.addEventListener('click', function() {
1758
- var detailEl = this.querySelector('.event-timeline-detail');
1759
- if (detailEl) {
1760
- detailEl.style.display = detailEl.style.display === 'none' ? '' : 'none';
1761
- this.classList.toggle('event-timeline-row--expanded');
1762
- }
1763
- });
1764
- });
1765
-
1766
- var loadMoreEl = document.getElementById('event-timeline-load-more');
1767
- var loadMoreBtn = document.getElementById('event-timeline-more-btn');
1768
- if (loadMoreEl) {
1769
- if (visible.length < filtered.length) {
1770
- loadMoreEl.style.display = '';
1771
- var remaining = filtered.length - visible.length;
1772
- if (loadMoreBtn) loadMoreBtn.textContent = 'Show more (' + remaining + ' remaining)';
1773
- } else {
1774
- loadMoreEl.style.display = 'none';
1775
- }
1776
- }
1777
- }
1778
-
1779
- async function main() {
1780
- // Fetch fresh data from server (overrides build-time baked-in data)
1781
- try {
1782
- const [statsResp, listResp] = await Promise.all([
1783
- fetch(base + 'data/overall-stats.json'),
1784
- fetch(base + 'data/convoy-list.json'),
1785
- ]);
1786
- if (statsResp.ok) {
1787
- const freshStats = await statsResp.json();
1788
- window.__DASHBOARD_DATA__.overallStats = freshStats;
1789
- }
1790
- if (listResp.ok) {
1791
- const freshList = await listResp.json();
1792
- window.__DASHBOARD_DATA__.convoyList = freshList;
1793
- }
1794
- } catch {
1795
- // Fall back to build-time data
1796
- }
1797
-
1798
- const convoys = window.__DASHBOARD_DATA__?.convoyList ?? [];
1799
-
1800
- const urlParams = new URLSearchParams(window.location.search);
1801
- const convoyParam = urlParams.get('convoy');
1802
-
1803
- if (convoyParam === 'active') {
1804
- const running = convoys.find((c) => c.status === 'running');
1805
- const pending = convoys.find((c) => c.status === 'pending');
1806
- const active = running || pending;
1807
- if (active) {
1808
- // A convoy is actively running or pending — show it directly
1809
- _activePollingConvoyId = active.id;
1810
- _lastPolledConvoyStatus = null;
1811
- // Ensure ETL data exists for this convoy before rendering
1812
- fetch(base + 'data/refresh').catch(() => {});
1813
- showConvoyDetailView(active.id, active.name || active.id);
1814
- } else {
1815
- // No active convoy yet — show waiting banner until one starts
1816
- showWaitingBanner();
1817
- }
1818
- // Always poll in active mode — detects new convoys automatically
1819
- startActiveConvoyPolling();
1820
- } else if (convoyParam) {
1821
- showConvoyDetailView(convoyParam, convoyParam);
1822
- }
1823
-
1824
- renderOverallStats();
1825
- renderConvoyList();
1826
- renderActivityTimeline();
1827
- renderRecentSessions();
1828
-
1829
- var loadMoreBtn = document.getElementById('event-timeline-more-btn');
1830
- if (loadMoreBtn) {
1831
- loadMoreBtn.addEventListener('click', function() {
1832
- eventTimelineCurrentPage++;
1833
- renderEventTimelineList();
1834
- });
1835
- }
1836
-
1837
- document.getElementById('breadcrumbs-home')?.addEventListener('click', (e) => {
1838
- e.preventDefault();
1839
- showHomeView();
1840
- });
1841
-
1842
- document.getElementById('export-btn')?.addEventListener('click', function() {
1843
- var exportData = {
1844
- overallStats: window.__DASHBOARD_DATA__ && window.__DASHBOARD_DATA__.overallStats,
1845
- convoyList: window.__DASHBOARD_DATA__ && window.__DASHBOARD_DATA__.convoyList,
1846
- };
1847
- if (window.__SELECTED_CONVOY__) {
1848
- exportData.selectedConvoy = window.__SELECTED_CONVOY__;
1849
- }
1850
- var blob = new Blob([JSON.stringify(exportData, null, 2)], { type: 'application/json' });
1851
- var url = URL.createObjectURL(blob);
1852
- var a = document.createElement('a');
1853
- a.href = url;
1854
- a.download = 'opencastle-dashboard-export.json';
1855
- document.body.appendChild(a);
1856
- a.click();
1857
- document.body.removeChild(a);
1858
- URL.revokeObjectURL(url);
1859
- });
1860
-
1861
- document.getElementById('cl-filter-search')?.addEventListener('input', function() {
1862
- convoyListCurrentPage = 1;
1863
- renderConvoyList();
1864
- });
1865
- document.getElementById('cl-filter-status')?.addEventListener('change', function() {
1866
- convoyListCurrentPage = 1;
1867
- renderConvoyList();
1868
- });
1869
- document.getElementById('cl-filter-from')?.addEventListener('change', function() {
1870
- convoyListCurrentPage = 1;
1871
- renderConvoyList();
1872
- });
1873
- document.getElementById('cl-filter-to')?.addEventListener('change', function() {
1874
- convoyListCurrentPage = 1;
1875
- renderConvoyList();
1876
- });
1877
- document.getElementById('cl-filter-reset')?.addEventListener('click', () => {
1878
- const s = document.getElementById('cl-filter-search'); if (s) s.value = '';
1879
- const st = document.getElementById('cl-filter-status'); if (st) st.value = '';
1880
- const f = document.getElementById('cl-filter-from'); if (f) f.value = '';
1881
- const t = document.getElementById('cl-filter-to'); if (t) t.value = '';
1882
- convoyListCurrentPage = 1;
1883
- renderConvoyList();
1884
- });
1885
-
1886
- window.addEventListener('popstate', () => {
1887
- const params = new URLSearchParams(window.location.search);
1888
- const c = params.get('convoy');
1889
- if (c) {
1890
- loadConvoyDetail(c);
1891
- const home = document.getElementById('view-home');
1892
- const detail = document.getElementById('view-convoy-detail');
1893
- const breadcrumbs = document.getElementById('breadcrumbs');
1894
- if (home) home.dataset.viewHidden = '';
1895
- if (detail) delete detail.dataset.viewHidden;
1896
- if (breadcrumbs) delete breadcrumbs.dataset.viewHidden;
1897
- document.querySelectorAll('.dash-sidebar__link[data-view="home"]').forEach(el => el.closest('li').style.display = 'none');
1898
- document.querySelectorAll('.dash-sidebar__link[data-view="detail"]').forEach(el => el.closest('li').style.display = '');
1899
- } else {
1900
- showHomeView();
1901
- }
1902
- });
1903
-
1904
- initSidebarNav();
1905
- }
1906
- function initSidebarNav() {
1907
- const links = document.querySelectorAll(".dash-sidebar__link");
1908
- const sections = document.querySelectorAll("[data-nav-section]");
1909
-
1910
- const observer = new IntersectionObserver(
1911
- (entries) => {
1912
- entries.forEach((entry) => {
1913
- if (entry.isIntersecting) {
1914
- const id = entry.target.id;
1915
- links.forEach((link) => {
1916
- link.classList.toggle(
1917
- "dash-sidebar__link--active",
1918
- link.dataset.section === id
1919
- );
1920
- });
1921
- }
1922
- });
1923
- },
1924
- { rootMargin: "-20% 0px -70% 0px", threshold: 0 }
1925
- );
1926
-
1927
- sections.forEach((s) => observer.observe(s));
1928
-
1929
- const CONVOY_DETAIL_SECTIONS = ["tasks-section", "pipeline-section", "agent-section", "tier-section", "model-section", "quality-section", "reliability-section", "drift-section", "outputs-section", "execution-section", "event-timeline-section", "panel-section", "reviews-section"];
1930
-
1931
- links.forEach((link) => {
1932
- link.addEventListener("click", async (e) => {
1933
- e.preventDefault();
1934
- const sectionId = link.dataset.section;
1935
-
1936
- if (CONVOY_DETAIL_SECTIONS.includes(sectionId)) {
1937
- const convoyList = window.__DASHBOARD_DATA__?.convoyList ?? [];
1938
- if (!window.__SELECTED_CONVOY__ && convoyList.length > 0) {
1939
- showConvoyDetailView(convoyList[0].id, convoyList[0].name || convoyList[0].id);
1940
- }
1941
- }
1942
-
1943
- const target = document.getElementById(sectionId);
1944
- if (target) {
1945
- target.scrollIntoView({ behavior: "smooth", block: "start" });
1946
- }
1947
- });
1948
- });
1949
-
1950
- // Set initial nav visibility based on current view
1951
- const initialParams = new URLSearchParams(window.location.search);
1952
- if (initialParams.get('convoy')) {
1953
- document.querySelectorAll('.dash-sidebar__link[data-view="home"]').forEach(el => el.closest('li').style.display = 'none');
1954
- document.querySelectorAll('.dash-sidebar__link[data-view="detail"]').forEach(el => el.closest('li').style.display = '');
1955
- } else {
1956
- document.querySelectorAll('.dash-sidebar__link[data-view="detail"]').forEach(el => el.closest('li').style.display = 'none');
1957
- document.querySelectorAll('.dash-sidebar__link[data-view="home"]').forEach(el => el.closest('li').style.display = '');
1958
- }
1959
- }
1960
-
1961
-
1962
- main();
1963
- })();</script>