@apralabs/apra-fleet 0.4.1 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (276) hide show
  1. package/README.md +16 -8
  2. package/dist/agents/backlog-groomer.md +17 -21
  3. package/dist/agents/ci-watcher.md +3 -0
  4. package/dist/agents/deployer.md +22 -44
  5. package/dist/agents/doer.md +131 -132
  6. package/dist/agents/harvester.md +20 -32
  7. package/dist/agents/integ-test-runner.md +81 -113
  8. package/dist/agents/kb-reconciler.md +31 -42
  9. package/dist/agents/plan-reviewer.md +32 -44
  10. package/dist/agents/planner.md +51 -63
  11. package/dist/agents/regression-test-runner.md +65 -80
  12. package/dist/agents/reviewer.md +56 -83
  13. package/dist/agents/schemas/integ-test-runner-output.json +1 -1
  14. package/dist/agents/schemas/regression-test-runner-output.json +4 -17
  15. package/dist/cli/auth.d.ts.map +1 -1
  16. package/dist/cli/auth.js +1 -2
  17. package/dist/cli/auth.js.map +1 -1
  18. package/dist/cli/config.d.ts +3 -3
  19. package/dist/cli/config.d.ts.map +1 -1
  20. package/dist/cli/config.js +4 -13
  21. package/dist/cli/config.js.map +1 -1
  22. package/dist/cli/install.d.ts.map +1 -1
  23. package/dist/cli/install.js +5 -39
  24. package/dist/cli/install.js.map +1 -1
  25. package/dist/cli/register-member.js +1 -1
  26. package/dist/cli/start.d.ts.map +1 -1
  27. package/dist/cli/start.js +7 -0
  28. package/dist/cli/start.js.map +1 -1
  29. package/dist/cli/uninstall.d.ts.map +1 -1
  30. package/dist/cli/uninstall.js +5 -3
  31. package/dist/cli/uninstall.js.map +1 -1
  32. package/dist/cli/watch.d.ts +26 -3
  33. package/dist/cli/watch.d.ts.map +1 -1
  34. package/dist/cli/watch.js +41 -9
  35. package/dist/cli/watch.js.map +1 -1
  36. package/dist/os/git-bash-candidates.d.ts +35 -0
  37. package/dist/os/git-bash-candidates.d.ts.map +1 -0
  38. package/dist/os/git-bash-candidates.js +46 -0
  39. package/dist/os/git-bash-candidates.js.map +1 -0
  40. package/dist/os/index.d.ts +13 -4
  41. package/dist/os/index.d.ts.map +1 -1
  42. package/dist/os/index.js +17 -2
  43. package/dist/os/index.js.map +1 -1
  44. package/dist/os/linux.js +1 -1
  45. package/dist/os/linux.js.map +1 -1
  46. package/dist/os/os-commands.d.ts +7 -0
  47. package/dist/os/os-commands.d.ts.map +1 -1
  48. package/dist/os/os-commands.js.map +1 -1
  49. package/dist/os/windows-gitbash.d.ts +93 -0
  50. package/dist/os/windows-gitbash.d.ts.map +1 -0
  51. package/dist/os/windows-gitbash.js +244 -0
  52. package/dist/os/windows-gitbash.js.map +1 -0
  53. package/dist/os/windows.d.ts.map +1 -1
  54. package/dist/os/windows.js +27 -5
  55. package/dist/os/windows.js.map +1 -1
  56. package/dist/providers/agy.d.ts +3 -2
  57. package/dist/providers/agy.d.ts.map +1 -1
  58. package/dist/providers/agy.js +11 -2
  59. package/dist/providers/agy.js.map +1 -1
  60. package/dist/providers/claude.d.ts +3 -2
  61. package/dist/providers/claude.d.ts.map +1 -1
  62. package/dist/providers/claude.js +22 -3
  63. package/dist/providers/claude.js.map +1 -1
  64. package/dist/providers/codex.d.ts +3 -2
  65. package/dist/providers/codex.d.ts.map +1 -1
  66. package/dist/providers/codex.js +5 -2
  67. package/dist/providers/codex.js.map +1 -1
  68. package/dist/providers/copilot.d.ts +3 -2
  69. package/dist/providers/copilot.d.ts.map +1 -1
  70. package/dist/providers/copilot.js +7 -2
  71. package/dist/providers/copilot.js.map +1 -1
  72. package/dist/providers/index.d.ts +0 -1
  73. package/dist/providers/index.d.ts.map +1 -1
  74. package/dist/providers/index.js +0 -3
  75. package/dist/providers/index.js.map +1 -1
  76. package/dist/providers/none.d.ts +3 -2
  77. package/dist/providers/none.d.ts.map +1 -1
  78. package/dist/providers/none.js +5 -2
  79. package/dist/providers/none.js.map +1 -1
  80. package/dist/providers/opencode.d.ts +3 -2
  81. package/dist/providers/opencode.d.ts.map +1 -1
  82. package/dist/providers/opencode.js +5 -2
  83. package/dist/providers/opencode.js.map +1 -1
  84. package/dist/providers/provider.d.ts +16 -7
  85. package/dist/providers/provider.d.ts.map +1 -1
  86. package/dist/providers/provider.js +2 -2
  87. package/dist/providers/provider.js.map +1 -1
  88. package/dist/services/agent-provisioner.js +2 -2
  89. package/dist/services/agent-provisioner.js.map +1 -1
  90. package/dist/services/cloud/activity.js +2 -2
  91. package/dist/services/cloud/activity.js.map +1 -1
  92. package/dist/services/context-admission.d.ts.map +1 -1
  93. package/dist/services/context-admission.js +9 -7
  94. package/dist/services/context-admission.js.map +1 -1
  95. package/dist/services/credential-cleanup.d.ts.map +1 -1
  96. package/dist/services/credential-cleanup.js +22 -3
  97. package/dist/services/credential-cleanup.js.map +1 -1
  98. package/dist/services/member-home.d.ts +1 -1
  99. package/dist/services/member-home.d.ts.map +1 -1
  100. package/dist/services/member-home.js +15 -12
  101. package/dist/services/member-home.js.map +1 -1
  102. package/dist/services/model-pricing.d.ts.map +1 -1
  103. package/dist/services/model-pricing.js +0 -5
  104. package/dist/services/model-pricing.js.map +1 -1
  105. package/dist/services/orphan-recovery.d.ts +6 -3
  106. package/dist/services/orphan-recovery.d.ts.map +1 -1
  107. package/dist/services/orphan-recovery.js +17 -14
  108. package/dist/services/orphan-recovery.js.map +1 -1
  109. package/dist/services/preflight-check.js +2 -2
  110. package/dist/services/preflight-check.js.map +1 -1
  111. package/dist/services/shell-probe.d.ts +131 -0
  112. package/dist/services/shell-probe.d.ts.map +1 -0
  113. package/dist/services/shell-probe.js +210 -0
  114. package/dist/services/shell-probe.js.map +1 -0
  115. package/dist/services/singleton.d.ts +2 -0
  116. package/dist/services/singleton.d.ts.map +1 -1
  117. package/dist/services/singleton.js +1 -1
  118. package/dist/services/singleton.js.map +1 -1
  119. package/dist/services/ssh.js +2 -2
  120. package/dist/services/ssh.js.map +1 -1
  121. package/dist/services/stall/find-log-file.d.ts.map +1 -1
  122. package/dist/services/stall/find-log-file.js +22 -16
  123. package/dist/services/stall/find-log-file.js.map +1 -1
  124. package/dist/services/stall/read-log-tail.d.ts.map +1 -1
  125. package/dist/services/stall/read-log-tail.js +6 -5
  126. package/dist/services/stall/read-log-tail.js.map +1 -1
  127. package/dist/services/stall/stall-poller.d.ts.map +1 -1
  128. package/dist/services/stall/stall-poller.js +35 -42
  129. package/dist/services/stall/stall-poller.js.map +1 -1
  130. package/dist/services/strategy.d.ts +9 -0
  131. package/dist/services/strategy.d.ts.map +1 -1
  132. package/dist/services/strategy.js +40 -6
  133. package/dist/services/strategy.js.map +1 -1
  134. package/dist/services/user-config.js +1 -1
  135. package/dist/services/user-config.js.map +1 -1
  136. package/dist/services/vcs/azure-devops.d.ts +1 -1
  137. package/dist/services/vcs/azure-devops.d.ts.map +1 -1
  138. package/dist/services/vcs/azure-devops.js +105 -10
  139. package/dist/services/vcs/azure-devops.js.map +1 -1
  140. package/dist/services/vcs/bitbucket.d.ts.map +1 -1
  141. package/dist/services/vcs/bitbucket.js +16 -0
  142. package/dist/services/vcs/bitbucket.js.map +1 -1
  143. package/dist/services/vcs/github.d.ts.map +1 -1
  144. package/dist/services/vcs/github.js +24 -0
  145. package/dist/services/vcs/github.js.map +1 -1
  146. package/dist/services/vcs/types.d.ts +123 -2
  147. package/dist/services/vcs/types.d.ts.map +1 -1
  148. package/dist/skills/fleet-sprint-cli/SKILL.md +2 -1
  149. package/dist/skills/pm/SKILL.md +0 -1
  150. package/dist/skills/pm/cost.md +0 -1
  151. package/dist/skills/pm/fleet-addendum.md +0 -1
  152. package/dist/tools/check-status.js +3 -3
  153. package/dist/tools/check-status.js.map +1 -1
  154. package/dist/tools/cloud-control.js +2 -2
  155. package/dist/tools/cloud-control.js.map +1 -1
  156. package/dist/tools/compose-permissions.d.ts.map +1 -1
  157. package/dist/tools/compose-permissions.js +37 -24
  158. package/dist/tools/compose-permissions.js.map +1 -1
  159. package/dist/tools/execute-command.d.ts.map +1 -1
  160. package/dist/tools/execute-command.js +28 -12
  161. package/dist/tools/execute-command.js.map +1 -1
  162. package/dist/tools/execute-prompt.d.ts.map +1 -1
  163. package/dist/tools/execute-prompt.js +55 -18
  164. package/dist/tools/execute-prompt.js.map +1 -1
  165. package/dist/tools/list-members.d.ts.map +1 -1
  166. package/dist/tools/list-members.js +6 -2
  167. package/dist/tools/list-members.js.map +1 -1
  168. package/dist/tools/member-detail.d.ts.map +1 -1
  169. package/dist/tools/member-detail.js +5 -3
  170. package/dist/tools/member-detail.js.map +1 -1
  171. package/dist/tools/member-reservation.d.ts.map +1 -1
  172. package/dist/tools/member-reservation.js +13 -1
  173. package/dist/tools/member-reservation.js.map +1 -1
  174. package/dist/tools/monitor-task.d.ts.map +1 -1
  175. package/dist/tools/monitor-task.js +17 -2
  176. package/dist/tools/monitor-task.js.map +1 -1
  177. package/dist/tools/provision-auth.js +5 -5
  178. package/dist/tools/provision-auth.js.map +1 -1
  179. package/dist/tools/provision-vcs-auth.d.ts +5 -2
  180. package/dist/tools/provision-vcs-auth.d.ts.map +1 -1
  181. package/dist/tools/provision-vcs-auth.js +58 -52
  182. package/dist/tools/provision-vcs-auth.js.map +1 -1
  183. package/dist/tools/register-member.d.ts +18 -12
  184. package/dist/tools/register-member.d.ts.map +1 -1
  185. package/dist/tools/register-member.js +42 -4
  186. package/dist/tools/register-member.js.map +1 -1
  187. package/dist/tools/remove-member.js +2 -2
  188. package/dist/tools/remove-member.js.map +1 -1
  189. package/dist/tools/revoke-vcs-auth.js +2 -2
  190. package/dist/tools/revoke-vcs-auth.js.map +1 -1
  191. package/dist/tools/setup-ssh-key.d.ts.map +1 -1
  192. package/dist/tools/setup-ssh-key.js +2 -1
  193. package/dist/tools/setup-ssh-key.js.map +1 -1
  194. package/dist/tools/stop-prompt.js +2 -2
  195. package/dist/tools/stop-prompt.js.map +1 -1
  196. package/dist/tools/update-agent-cli.js +2 -2
  197. package/dist/tools/update-agent-cli.js.map +1 -1
  198. package/dist/tools/update-member.d.ts +18 -12
  199. package/dist/tools/update-member.d.ts.map +1 -1
  200. package/dist/tools/update-member.js +18 -1
  201. package/dist/tools/update-member.js.map +1 -1
  202. package/dist/types.d.ts +11 -1
  203. package/dist/types.d.ts.map +1 -1
  204. package/dist/utils/agent-helpers.d.ts +36 -0
  205. package/dist/utils/agent-helpers.d.ts.map +1 -1
  206. package/dist/utils/agent-helpers.js +39 -1
  207. package/dist/utils/agent-helpers.js.map +1 -1
  208. package/dist/utils/platform.d.ts +7 -0
  209. package/dist/utils/platform.d.ts.map +1 -1
  210. package/dist/utils/platform.js +11 -1
  211. package/dist/utils/platform.js.map +1 -1
  212. package/dist/utils/workspace-trust.d.ts.map +1 -1
  213. package/dist/utils/workspace-trust.js +5 -1
  214. package/dist/utils/workspace-trust.js.map +1 -1
  215. package/dist/workflows/auto-sprint.js +4 -17
  216. package/package.json +2 -2
  217. package/packages/apra-fleet-client/src/client/api.mjs +92 -3
  218. package/packages/apra-fleet-se/apra-pm/agents/backlog-groomer.md +17 -21
  219. package/packages/apra-fleet-se/apra-pm/agents/ci-watcher.md +3 -0
  220. package/packages/apra-fleet-se/apra-pm/agents/deployer.md +22 -44
  221. package/packages/apra-fleet-se/apra-pm/agents/doer.md +131 -132
  222. package/packages/apra-fleet-se/apra-pm/agents/harvester.md +20 -32
  223. package/packages/apra-fleet-se/apra-pm/agents/integ-test-runner.md +81 -113
  224. package/packages/apra-fleet-se/apra-pm/agents/kb-reconciler.md +31 -42
  225. package/packages/apra-fleet-se/apra-pm/agents/plan-reviewer.md +32 -44
  226. package/packages/apra-fleet-se/apra-pm/agents/planner.md +51 -63
  227. package/packages/apra-fleet-se/apra-pm/agents/regression-test-runner.md +65 -80
  228. package/packages/apra-fleet-se/apra-pm/agents/reviewer.md +56 -83
  229. package/packages/apra-fleet-se/apra-pm/agents/schemas/integ-test-runner-output.json +1 -1
  230. package/packages/apra-fleet-se/apra-pm/agents/schemas/regression-test-runner-output.json +4 -17
  231. package/packages/apra-fleet-se/apra-pm/skills/pm/SKILL.md +0 -1
  232. package/packages/apra-fleet-se/apra-pm/skills/pm/cost.md +0 -1
  233. package/packages/apra-fleet-se/apra-pm/skills/pm/fleet-addendum.md +0 -1
  234. package/packages/apra-fleet-se/bin/cli.mjs +132 -3
  235. package/packages/apra-fleet-se/bin/serve.mjs +36 -1
  236. package/packages/apra-fleet-se/fleet-sprint/contracts.mjs +151 -33
  237. package/packages/apra-fleet-se/fleet-sprint/docs/README.md +22 -7
  238. package/packages/apra-fleet-se/fleet-sprint/docs/dolt-manual-recovery-verified.md +10 -8
  239. package/packages/apra-fleet-se/fleet-sprint/docs/dolt-sync-redesign.md +9 -4
  240. package/packages/apra-fleet-se/fleet-sprint/docs/escalate-to-llm-design.md +2 -2
  241. package/packages/apra-fleet-se/fleet-sprint/docs/shared-orchestrator-reservation-design.md +12 -12
  242. package/packages/apra-fleet-se/fleet-sprint/docs/stabilization-log.md +14 -4
  243. package/packages/apra-fleet-se/fleet-sprint/dolt-settle.mjs +275 -99
  244. package/packages/apra-fleet-se/fleet-sprint/dolt-sync.mjs +67 -16
  245. package/packages/apra-fleet-se/fleet-sprint/errors.mjs +41 -0
  246. package/packages/apra-fleet-se/fleet-sprint/runner.js +1140 -209
  247. package/packages/apra-fleet-se/fleet-sprint/se-os-commands.mjs +134 -0
  248. package/packages/apra-fleet-se/fleet-sprint/se-posix.mjs +154 -0
  249. package/packages/apra-fleet-se/fleet-sprint/se-windows-gitbash.mjs +97 -0
  250. package/packages/apra-fleet-se/fleet-sprint/se-windows.mjs +143 -0
  251. package/packages/apra-fleet-se/fleet-sprint/skills/fleet-sprint-cli/SKILL.md +2 -1
  252. package/packages/apra-fleet-se/fleet-sprint/vcs-module.mjs +51 -0
  253. package/packages/apra-fleet-se/fleet-sprint/vcs-providers/azure-devops.mjs +657 -12
  254. package/packages/apra-fleet-se/fleet-sprint/vcs-providers/dolt.mjs +33 -4
  255. package/packages/apra-fleet-se/fleet-sprint/vcs-providers/github.mjs +60 -43
  256. package/packages/apra-fleet-se/fleet-sprint/vcs-providers/index.mjs +205 -2
  257. package/packages/apra-fleet-se/fleet-sprint/vcs-providers/shell-helpers.mjs +164 -0
  258. package/packages/apra-fleet-se/fleet-sprint/viewer-extensions.mjs +92 -37
  259. package/packages/apra-fleet-workflow/src/viewer/index.mjs +167 -1
  260. package/packages/apra-fleet-workflow/src/workflow/index.mjs +435 -31
  261. package/skills/fleet/SKILL.md +20 -9
  262. package/skills/fleet/auth-azdevops.md +44 -5
  263. package/skills/fleet/auth-bitbucket.md +3 -3
  264. package/skills/fleet/auth-github.md +2 -2
  265. package/skills/fleet/beads-conflict-resolution.md +141 -0
  266. package/skills/fleet/beads.md +16 -12
  267. package/skills/fleet/onboarding.md +4 -4
  268. package/skills/fleet/permissions.md +6 -6
  269. package/skills/fleet/skill-matrix.md +1 -1
  270. package/skills/fleet/troubleshooting.md +2 -1
  271. package/version.json +1 -1
  272. package/dist/providers/gemini.d.ts +0 -52
  273. package/dist/providers/gemini.d.ts.map +0 -1
  274. package/dist/providers/gemini.js +0 -236
  275. package/dist/providers/gemini.js.map +0 -1
  276. package/packages/apra-fleet-se/fleet-sprint/docs/coach-role-design.md +0 -23
@@ -9,7 +9,22 @@ import { computeSprintProgress } from './sprint-progress.mjs';
9
9
  * itself -- and renders a horizontal bar that fills left-to-right by
10
10
  * `fraction`, plus the numeric 'M/N' text. Styled with the viewer's existing
11
11
  * `--bg`/`--bg-glass`/`--accent` CSS variables. `required === 0` renders a
12
- * flat, empty bar and '0/0' text rather than dividing by zero or throwing.
12
+ * flat, empty bar and 'Required: 0/0' text rather than dividing by zero or
13
+ * throwing.
14
+ *
15
+ * apra-fleet-vk0a.1: the 'M/N' text carries an explicit `Required: ` label
16
+ * (closed/required, goal+decomposedParentIds-filtered per
17
+ * computeSprintProgress()) -- this widget is reused as-is by BOTH the
18
+ * fleet-sprint per-sprint viewer's Tasks tab (renderBeadsPanel() below --
19
+ * apra-fleet-vk0a.2 pins it into the FIXED panel-header row, next to the
20
+ * 'Tasks' label, rather than the top of the scrollable tree below, so it
21
+ * never scrolls out of view alongside renderBeadsHtml()'s OWN,
22
+ * differently-scoped 'All tasks (incl. backlog)' count -- see that widget's
23
+ * doc comment) AND the supervisor dashboard's Sprint Stack card
24
+ * (dashboard.mjs's renderSprintProgressHtml(), next to its OWN
25
+ * differently-scoped 'N total in scope' count -- apra-fleet-vk0a.3).
26
+ * Labeling it once, here, keeps both pairings unambiguous without a second
27
+ * implementation.
13
28
  *
14
29
  * @param {{ closed: number, required: number, fraction: number }} progress
15
30
  * @returns {string}
@@ -25,7 +40,7 @@ export function renderProgressBarHtml(progress) {
25
40
  '<div style="flex: 1; height: 8px; background: var(--bg); border: 1px solid var(--bg-glass); border-radius: 4px; overflow: hidden;">' +
26
41
  '<div style="width: ' + pct + '%; height: 100%; background: var(--accent);"></div>' +
27
42
  '</div>' +
28
- '<div style="color: #a1a1aa; white-space: nowrap;">' + closed + '/' + required + '</div>' +
43
+ '<div style="color: #a1a1aa; white-space: nowrap;">Required: ' + closed + '/' + required + '</div>' +
29
44
  '</div>'
30
45
  );
31
46
  }
@@ -89,20 +104,21 @@ export function renderProgressBarHtml(progress) {
89
104
  * header row and outer `<table>` wrapper always render regardless of which
90
105
  * (if either) section has content.
91
106
  *
92
- * apra-fleet-k7s: unlike Sprint (nested by `parent` containment), Backlog
93
- * has no shared parent/epic to nest under -- what it DOES sometimes have is
94
- * `blocks`-type dependency edges BETWEEN backlog items themselves (e.g. two
95
- * unplanned beads under the same stale epic, one blocking the other). When
96
- * present, those edges now drive nesting the same way `renderNode` nests
97
- * Sprint rows: the blocker renders as the parent row, the blocked item
98
- * nests as its child, using the identical indent/prefix/cycle-guard
99
- * mechanics. A backlog item with no blocks-edge to another IN-SET backlog
100
- * item (the common case -- most backlog beads are unrelated to each other)
101
- * remains a flat, top-level row, same as before -- nesting is only ever
102
- * drawn when a real edge justifies it, never implied. Root rows (including
103
- * every item with no in-set blocker) are still sorted priority-then-id for
104
- * scannability; a blocked item's DEPTH in the tree is what shows structure,
105
- * not its position in that sort.
107
+ * apra-fleet-k7s: Backlog nests the same way Sprint does -- by `parent`
108
+ * containment FIRST (an in-set parent-child edge, e.g. an epic's children
109
+ * that never made it into a sprint run) -- falling back to `blocks`-type
110
+ * dependency edges BETWEEN backlog items only for a genuinely parent-less
111
+ * item (e.g. two unplanned beads under the same stale epic, one blocking
112
+ * the other, with the epic itself out of this dataset). When a blocks-edge
113
+ * fallback fires, it drives nesting the same way `renderNode` nests Sprint
114
+ * rows: the blocker renders as the parent row, the blocked item nests as
115
+ * its child, using the identical indent/prefix/cycle-guard mechanics. A
116
+ * backlog item with neither an in-set parent nor a blocks-edge to another
117
+ * IN-SET backlog item remains a flat, top-level row -- nesting is only
118
+ * ever drawn when a real edge justifies it, never implied. Root rows
119
+ * (including every item with no in-set parent/blocker) are still sorted
120
+ * priority-then-id for scannability; a nested item's DEPTH in the tree is
121
+ * what shows structure, not its position in that sort.
106
122
  *
107
123
  * Every rendering decision here (status/type badges, tree placement) is
108
124
  * defensive by construction: unrecognized/missing status, type, model, or
@@ -475,15 +491,14 @@ export function renderBeadsHtml(sprintTasks, backlogTasks, collapsedIds) {
475
491
  return html;
476
492
  }
477
493
 
478
- // apra-fleet-k7s: Backlog is built into a tree from `blocks`-type
479
- // dependency edges BETWEEN backlog items (mirrors the doc-comment above
480
- // and reuses renderNode's own indent/prefix/cycle-guard mechanics, just
481
- // keyed off a separate `backlogMap`/`backlogChildrenOf` built from
482
- // blocks-edges instead of Sprint's `map`/`childrenOf` built from
483
- // `parent`). A blocker outside the backlog set (e.g. it's actually in
484
- // this run's Sprint, or not part of this dataset at all) does not
485
- // count -- same "only an in-dataset edge nests" rule Sprint applies to
486
- // `parent`.
494
+ // apra-fleet-k7s: Backlog is built into a tree from `parent` containment
495
+ // FIRST, `blocks`-type dependency edges BETWEEN backlog items SECOND
496
+ // (mirrors the doc-comment above and reuses renderNode's own indent/
497
+ // prefix/cycle-guard mechanics, just keyed off a separate `backlogMap`/
498
+ // `backlogChildrenOf` rather than Sprint's `map`/`childrenOf`). A parent
499
+ // or blocker outside the backlog set (e.g. it's actually in this run's
500
+ // Sprint, or not part of this dataset at all) does not count -- same
501
+ // "only an in-dataset edge nests" rule Sprint applies to `parent`.
487
502
  const backlogMap = {};
488
503
  backlogTasks.forEach((t) => { backlogMap[t.id] = { ...t, blockedBy: [] }; });
489
504
 
@@ -496,7 +511,20 @@ export function renderBeadsHtml(sprintTasks, backlogTasks, collapsedIds) {
496
511
  .filter((d) => d && d.type === 'blocks' && backlogMap[d.depends_on_id])
497
512
  .map((d) => d.depends_on_id);
498
513
  backlogMap[t.id].blockedBy = blockerIds;
499
- if (blockerIds.length > 0) {
514
+
515
+ // apra-fleet: containment (`parent`, in-set) nests FIRST, mirroring
516
+ // Sprint's `map`/`childrenOf` above -- most backlog beads have a real
517
+ // parent-child edge (an epic's children that never made it into a
518
+ // sprint run), and nesting those under a `blocks` edge instead left
519
+ // every parent-child-only bead rendering as a flat root alongside
520
+ // its own epic. `blocks`-edge nesting is now the FALLBACK, used only
521
+ // for a genuinely parent-less backlog item that still blocks/is
522
+ // blocked by another in-set item.
523
+ const parentId = t.parent;
524
+ if (parentId !== undefined && parentId !== null && backlogMap[parentId]) {
525
+ (backlogChildrenOf[parentId] = backlogChildrenOf[parentId] || []).push(t.id);
526
+ nestedBacklogIds.add(t.id);
527
+ } else if (blockerIds.length > 0) {
500
528
  // A node renders exactly once (cycle-guard below), so with
501
529
  // multiple in-set blockers only one can be the tree-parent --
502
530
  // the lowest-sorted blocker id wins, for deterministic output.
@@ -565,20 +593,31 @@ export function renderBeadsHtml(sprintTasks, backlogTasks, collapsedIds) {
565
593
  return html;
566
594
  }
567
595
 
568
- // apra-fleet-eft.90: a persistent 'M/N' item count at the top of the
569
- // panel -- N = every rendered bead across BOTH sections (Sprint +
570
- // Backlog), M = how many of those are not closed (open, in_progress,
571
- // blocked, etc). Parent and child beads each count as their own item
572
- // toward both numbers -- these are flat counts over the input arrays
573
- // themselves, never deduped/collapsed by tree hierarchy (a bead present
574
- // in `sprintTasks`/`backlogTasks` counts exactly once regardless of how
596
+ // apra-fleet-eft.90: a persistent item count at the top of the panel --
597
+ // N = every rendered bead across BOTH sections (Sprint + Backlog), M =
598
+ // how many of those are not closed (open, in_progress, blocked, etc).
599
+ // Parent and child beads each count as their own item toward both
600
+ // numbers -- these are flat counts over the input arrays themselves,
601
+ // never deduped/collapsed by tree hierarchy (a bead present in
602
+ // `sprintTasks`/`backlogTasks` counts exactly once regardless of how
575
603
  // many descendants it has). An empty panel (both lists empty) renders
576
- // '0/0', never NaN/throwing.
604
+ // 'All tasks (incl. backlog): 0 open / 0 total', never NaN/throwing.
605
+ //
606
+ // apra-fleet-vk0a.1: labeled 'All tasks (incl. backlog)' -- explicitly
607
+ // distinct from the DIFFERENT scope/definition of renderProgressBarHtml()'s
608
+ // 'Required: M/N' widget (goal+decomposedParentIds-filtered, sprintTasks
609
+ // only), which apra-fleet-vk0a.2 pins into the Tasks tab's FIXED
610
+ // panel-header row (renderBeadsPanel() below) rather than rendering it
611
+ // here at the top of this scrollable panel. Before the vk0a.1 label, the
612
+ // two counts read as a bug (same-looking 'M/N' pair, different
613
+ // denominators AND inverted numerator polarity -- this one is
614
+ // open-count, that one is closed-count) rather than two intentionally
615
+ // different, both-useful numbers.
577
616
  const countedTasks = sprintTasks.concat(backlogTasks);
578
617
  const totalBeadCount = countedTasks.length;
579
618
  const openBeadCount = countedTasks.filter((t) => t && (t.status || '').toString().toLowerCase() !== 'closed').length;
580
619
  const countHtml = '<div class="beads-count" style="padding: 4px 8px; font-size: 12px; color: #a1a1aa;">' +
581
- openBeadCount + '/' + totalBeadCount + '</div>';
620
+ 'All tasks (incl. backlog): ' + openBeadCount + ' open / ' + totalBeadCount + ' total</div>';
582
621
 
583
622
  let html = countHtml + '<table style="width: 100%; border-collapse: collapse; text-align: left; font-size: 13px;">';
584
623
  html += '<tr style="border-bottom: 1px solid rgba(255,255,255,0.1);">' +
@@ -900,8 +939,24 @@ export const beadsExtension = {
900
939
  goalMax: lastBeadsData.goalMax,
901
940
  decomposedParentIds: lastBeadsData.decomposedParentIds,
902
941
  });
903
- container.innerHTML = renderProgressBarHtml(progress)
904
- + renderBeadsHtml(lastBeadsData.sprintTasks || [], lastBeadsData.backlogTasks || [], collapsedBeadIds);
942
+ const progressHtml = renderProgressBarHtml(progress);
943
+ // apra-fleet-vk0a.2: pinned into the FIXED panel-header row (a
944
+ // sibling of the 'Tasks' label, core's generic per-extension
945
+ // header hook -- \`id="panel-header-\${ext.id}-extra"\`, see
946
+ // viewer/index.mjs) instead of re-rendered at the top of the
947
+ // SCROLLABLE #extension-beads container on every poll -- so it
948
+ // stays visible regardless of scroll position in a long task
949
+ // list. Falls back to the pre-vk0a.2 inline placement when the
950
+ // hook is absent (an older/mismatched core template), rather
951
+ // than silently dropping the widget.
952
+ const headerExtra = document.getElementById('panel-header-beads-extra');
953
+ if (headerExtra) {
954
+ headerExtra.innerHTML = progressHtml;
955
+ container.innerHTML = renderBeadsHtml(lastBeadsData.sprintTasks || [], lastBeadsData.backlogTasks || [], collapsedBeadIds);
956
+ } else {
957
+ container.innerHTML = progressHtml
958
+ + renderBeadsHtml(lastBeadsData.sprintTasks || [], lastBeadsData.backlogTasks || [], collapsedBeadIds);
959
+ }
905
960
  }
906
961
 
907
962
  // Single document-level click-delegation listener (same rationale
@@ -62,9 +62,15 @@ const HTML_TEMPLATE = (dashboardExtensions, opts = {}) => {
62
62
 
63
63
  .btn { padding: 4px 12px; font-size: 12px; border-radius: 4px; border: none; cursor: pointer; font-weight: 600; transition: opacity 0.2s; }
64
64
  .btn:hover { opacity: 0.8; }
65
+ .btn:disabled { opacity: 0.4; cursor: default; }
66
+ .btn:disabled:hover { opacity: 0.4; }
65
67
  .btn-save { background: var(--accent); color: #fff; }
66
68
  .btn-stop { background: var(--danger); color: #fff; }
69
+ .btn-pause { background: var(--warning); color: #000; }
67
70
  .btn-secondary { background: rgba(255,255,255,0.1); color: var(--text); }
71
+ /* (apra-fleet-p2to.2.1) 'paused since <ts>' badge + reason card,
72
+ generic to every workflow run -- no per-workflow-type styling. */
73
+ .pause-banner { background: rgba(245, 158, 11, 0.12); border-color: rgba(245, 158, 11, 0.4); color: var(--warning); }
68
74
 
69
75
  /* min-height: 0 on every rung of the flex chain: a flex item's default
70
76
  min-height is content-sized, which lets a tall Activity list push the
@@ -205,9 +211,15 @@ const HTML_TEMPLATE = (dashboardExtensions, opts = {}) => {
205
211
  (e.g. auto-sprint's verdict badge/PR link) is layered on by a
206
212
  dashboard extension's own js, not here. -->
207
213
  <div class="stats-banner" id="result-strip" style="display: none;"></div>
214
+ <!-- (apra-fleet-p2to.2.1) 'paused since <ts>' badge + reason card --
215
+ shown only while state.pause.status === 'paused' (renderState()
216
+ below); hidden for the process-free History view exactly like
217
+ Save/Stop, since a finished run can never be paused. -->
218
+ ${isHistory ? '' : '<div class="stats-banner pause-banner" id="pause-banner" style="display: none;"></div>'}
208
219
  <div class="stats-banner" id="stats-banner"></div>
209
220
  <div id="status-indicator" style="font-size: 12px; font-weight: 600; min-width: 70px; text-align: center;"></div>
210
221
  ${isHistory ? '' : '<button class="btn btn-save" onclick="saveState()">Save</button>'}
222
+ ${isHistory ? '' : '<button class="btn btn-pause" id="btn-pause" onclick="pauseWorkflow()">Pause</button>'}
211
223
  ${isHistory ? '' : '<button class="btn btn-stop" onclick="stopWorkflow()">Stop</button>'}
212
224
  </div>
213
225
  </div>
@@ -236,7 +248,10 @@ const HTML_TEMPLATE = (dashboardExtensions, opts = {}) => {
236
248
  </div>
237
249
  ${dashboardExtensions.map(ext => `
238
250
  <div id="tab-${ext.id}" class="tab-content panel">
239
- <div class="panel-header">${ext.title}</div>
251
+ <div class="panel-header" id="panel-header-${ext.id}" style="display: flex; justify-content: space-between; align-items: center; gap: 12px;">
252
+ <span>${ext.title}</span>
253
+ <div id="panel-header-${ext.id}-extra" style="flex: 1; min-width: 0; max-width: 320px; text-transform: none; letter-spacing: normal;"></div>
254
+ </div>
240
255
  <div id="extension-${ext.id}" style="flex: 1; min-height: 0; padding: 12px; overflow-y: auto;"></div>
241
256
  </div>
242
257
  `).join('\\n')}
@@ -353,6 +368,21 @@ const HTML_TEMPLATE = (dashboardExtensions, opts = {}) => {
353
368
  if (ev.key === 'Escape') closeStopModal();
354
369
  });
355
370
 
371
+ // (apra-fleet-p2to.2.1) Pause/Resume -- unlike stopWorkflow() these never
372
+ // set button state directly: POST /pause and /resume only forward the
373
+ // request to the engine (which may defer the actual pause), and the
374
+ // button's label/enabled-state + the 'paused since' badge are entirely
375
+ // driven by renderState()'s reading of state.pause on the next poll/SSE
376
+ // tick, below. That keeps the button truthful about what the engine has
377
+ // ACTUALLY done rather than what the browser merely asked for.
378
+ async function pauseWorkflow() {
379
+ await fetch('/pause', { method: 'POST' });
380
+ }
381
+ async function resumeWorkflow() {
382
+ await fetch('/resume', { method: 'POST' });
383
+ }
384
+
385
+
356
386
  let allExpanded = true;
357
387
  function toggleAllGlobal() {
358
388
  allExpanded = !allExpanded;
@@ -777,6 +807,50 @@ const HTML_TEMPLATE = (dashboardExtensions, opts = {}) => {
777
807
  else if (state.status === 'cancelled') { ind.innerHTML = '<span style="color:var(--warning)">CANCELLED</span>'; }
778
808
  else { ind.innerHTML = '<span style="color:var(--danger)">FAILED</span>'; }
779
809
 
810
+ // (apra-fleet-p2to.2.1) Pause/Resume button state machine: Pause ->
811
+ // Pausing -> Paused -> Resume, driven entirely by state.pause.status
812
+ // (itself set only by the engine's own 'pause:requested'/'paused'/
813
+ // 'resumed' events -- see the workflow.on() wiring in
814
+ // createDashboardViewer()). Absent for the History view, which never
815
+ // renders the button at all.
816
+ const pauseBtn = document.getElementById('btn-pause');
817
+ if (pauseBtn) {
818
+ const pause = state.pause || { status: 'none' };
819
+ if (pause.status === 'paused') {
820
+ pauseBtn.textContent = 'Resume';
821
+ pauseBtn.onclick = resumeWorkflow;
822
+ pauseBtn.disabled = false;
823
+ } else if (pause.status === 'pausing') {
824
+ pauseBtn.textContent = 'Pausing...';
825
+ pauseBtn.onclick = null;
826
+ pauseBtn.disabled = true;
827
+ } else {
828
+ pauseBtn.textContent = 'Pause';
829
+ pauseBtn.onclick = pauseWorkflow;
830
+ // Nothing to pause once the run isn't live anymore.
831
+ pauseBtn.disabled = (state.status !== 'running');
832
+ }
833
+ }
834
+
835
+ // 'paused since <ts>' badge + reason card -- shown only while the
836
+ // pause has actually engaged (status === 'paused'), never during the
837
+ // deferred 'pausing' window, since nothing has happened yet from the
838
+ // dashboard's point of view.
839
+ const pauseBanner = document.getElementById('pause-banner');
840
+ if (pauseBanner) {
841
+ const pause = state.pause || { status: 'none' };
842
+ if (pause.status === 'paused') {
843
+ const sinceStr = pause.since ? new Date(pause.since).toLocaleTimeString([], { hour12: false }) : '-';
844
+ const reasonHtml = pause.reason ? \`<span>Reason: <strong>\${escapeHtml(pause.reason)}</strong></span>\` : '';
845
+ const phaseHtml = pause.phase ? \`<span>Phase: <strong>\${escapeHtml(pause.phase)}</strong></span>\` : '';
846
+ pauseBanner.innerHTML = \`<span>Paused since <strong>\${sinceStr}</strong></span>\${phaseHtml}\${reasonHtml}\`;
847
+ pauseBanner.style.display = 'flex';
848
+ } else {
849
+ pauseBanner.innerHTML = '';
850
+ pauseBanner.style.display = 'none';
851
+ }
852
+ }
853
+
780
854
  const dur = state.status === 'running' ? Date.now() - state.stats.startTime : state.stats.durationMs;
781
855
  const unknownCostSuffix = state.stats.unknownCostCount > 0 ? \` <span style="color:var(--warning)">(+\${state.stats.unknownCostCount} unknown)</span>\` : '';
782
856
  document.getElementById('stats-banner').innerHTML =
@@ -990,6 +1064,21 @@ export function createDashboardViewer(workflow, opts = {}) {
990
1064
  startTime: Date.now(),
991
1065
  durationMs: 0
992
1066
  },
1067
+ // (apra-fleet-p2to.2.1) Generic pause lifecycle, driven entirely by
1068
+ // the engine's 'pause:requested'/'paused'/'resumed' events wired up
1069
+ // below -- never mutated directly by any route handler. `status` is
1070
+ // one of 'none' (not paused/requested), 'pausing' (requested, still
1071
+ // draining in-flight work / waiting on the script's pause guard) or
1072
+ // 'paused' (engaged: new agent()/command() dispatches are blocked at
1073
+ // the gate). `reason` is carried from the requestPause() call that
1074
+ // started this cycle (the 'paused' event itself carries no reason,
1075
+ // see FleetWorkflow._maybeEngagePause -- so it is preserved here
1076
+ // rather than re-read from that event); `since` is stamped locally
1077
+ // when 'paused' actually fires (the engine event carries no
1078
+ // timestamp). `phase`/`group` mirror wherever the run was when the
1079
+ // pause was requested, for the dashboard's reason card. Generic to
1080
+ // any workflow -- no fleet-sprint-specific fields.
1081
+ pause: { status: 'none', reason: null, since: null, phase: null, group: null },
993
1082
  tree: [],
994
1083
  extensions: {}
995
1084
  };
@@ -1235,6 +1324,45 @@ export function createDashboardViewer(workflow, opts = {}) {
1235
1324
  broadcast({ type: 'state', payload: stateData });
1236
1325
  });
1237
1326
 
1327
+ // (apra-fleet-p2to.2.1) Generic pause lifecycle wiring, mirroring how
1328
+ // 'end' below derives dashboard state entirely from engine events --
1329
+ // the /pause and /resume routes (below) only forward the request to
1330
+ // FleetWorkflow.requestPause()/requestResume() (src/workflow/index.mjs);
1331
+ // every actual state.pause transition happens here, driven by the
1332
+ // engine's own 'pause:requested'/'paused'/'resumed' events, so the
1333
+ // dashboard reflects when a deferred pause has ACTUALLY engaged, not
1334
+ // merely when it was requested.
1335
+ workflow.on('pause:requested', (payload) => {
1336
+ state.pause = {
1337
+ status: 'pausing',
1338
+ reason: payload.reason ?? null,
1339
+ since: null,
1340
+ phase: payload.phase ?? null,
1341
+ group: payload.group ?? null
1342
+ };
1343
+ broadcast({ type: 'update' });
1344
+ });
1345
+
1346
+ workflow.on('paused', (payload) => {
1347
+ // The 'paused' event itself carries no reason (see
1348
+ // FleetWorkflow._maybeEngagePause) -- preserve whatever
1349
+ // 'pause:requested' set, and only stamp `since` now, at the moment
1350
+ // the pause actually engaged.
1351
+ state.pause = {
1352
+ status: 'paused',
1353
+ reason: state.pause.reason,
1354
+ since: nowIso(),
1355
+ phase: payload.phase ?? state.pause.phase,
1356
+ group: payload.group ?? state.pause.group
1357
+ };
1358
+ broadcast({ type: 'update' });
1359
+ });
1360
+
1361
+ workflow.on('resumed', () => {
1362
+ state.pause = { status: 'none', reason: null, since: null, phase: null, group: null };
1363
+ broadcast({ type: 'update' });
1364
+ });
1365
+
1238
1366
  workflow.on('end', (res) => {
1239
1367
  // apra-fleet-eft.53.1: the run's final phase never gets a 'phase'
1240
1368
  // event to close it out -- stamp its phaseEndedAt here so no phase
@@ -1400,6 +1528,44 @@ export function createDashboardViewer(workflow, opts = {}) {
1400
1528
  debouncedWriter.flushSync();
1401
1529
  res.writeHead(200);
1402
1530
  res.end();
1531
+ } else if (req.url === '/pause' && req.method === 'POST') {
1532
+ // (apra-fleet-p2to.2.1) Cooperative pause -- same shape as /stop
1533
+ // above, but forwards to FleetWorkflow.requestPause() instead of
1534
+ // requestStop(). That call only fires 'pause:requested'
1535
+ // immediately; the pause itself is DEFERRED until the run drains
1536
+ // to zero in-flight activities and any script-registered pause
1537
+ // guard permits it (see requestPause()'s doc, src/workflow/
1538
+ // index.mjs) -- the workflow event listeners above are what
1539
+ // actually flip state.pause once 'paused' fires, exactly like
1540
+ // /stop leaves the terminal state.status transition to the
1541
+ // workflow's own 'end' handler rather than setting it here.
1542
+ console.log('[Viewer] Pause requested via dashboard /pause endpoint.');
1543
+ if (typeof workflow.requestPause === 'function') {
1544
+ workflow.requestPause('Pause requested via dashboard /pause endpoint');
1545
+ }
1546
+ debouncedWriter.flushSync();
1547
+ res.writeHead(200);
1548
+ res.end();
1549
+ } else if (req.url === '/resume' && req.method === 'POST') {
1550
+ // (apra-fleet-p2to.2.1) Cooperative resume -- mirrors /pause
1551
+ // above, forwarding to FleetWorkflow.requestResume(). A no-op on
1552
+ // the engine side if the run is neither paused nor pause-
1553
+ // requested; the 'resumed' event listener above clears
1554
+ // state.pause once it fires.
1555
+ console.log('[Viewer] Resume requested via dashboard /resume endpoint.');
1556
+ if (typeof workflow.requestResume === 'function') {
1557
+ // (apra-fleet-p2to.1.3) requestResume() is now async -- it
1558
+ // awaits a pre-resume barrier (member re-reserve/resync) before
1559
+ // it completes. Don't block the HTTP response on that barrier,
1560
+ // but do catch a barrier rejection so it surfaces as a log line
1561
+ // rather than an unhandled promise rejection; the run stays
1562
+ // paused on failure, exactly as the engine leaves it.
1563
+ Promise.resolve(workflow.requestResume('Resume requested via dashboard /resume endpoint'))
1564
+ .catch((err) => console.error('[Viewer] resume barrier failed (run stays paused):', err && err.message ? err.message : err));
1565
+ }
1566
+ debouncedWriter.flushSync();
1567
+ res.writeHead(200);
1568
+ res.end();
1403
1569
  } else if (req.url === '/save_logs' && req.method === 'POST') {
1404
1570
  // Manual/scriptable trigger for the same server-side save that
1405
1571
  // 'end' and SIGINT/SIGTERM already perform (persistState() above)