@apralabs/apra-fleet 0.4.4 → 0.4.5

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 (268) hide show
  1. package/README.md +49 -4
  2. package/dist/agents/backlog-groomer.md +5 -0
  3. package/dist/agents/ci-watcher.md +5 -0
  4. package/dist/agents/deployer.md +20 -2
  5. package/dist/agents/doer.md +38 -2
  6. package/dist/agents/harvester.md +12 -9
  7. package/dist/agents/integ-test-runner.md +5 -0
  8. package/dist/agents/kb-reconciler.md +6 -0
  9. package/dist/agents/plan-reviewer.md +5 -0
  10. package/dist/agents/planner.md +5 -0
  11. package/dist/agents/regression-test-runner.md +5 -0
  12. package/dist/agents/reviewer.md +67 -15
  13. package/dist/agents/schemas/deployer-output.json +5 -0
  14. package/dist/agents/schemas/doer-output.json +78 -2
  15. package/dist/agents/schemas/reviewer-output.json +104 -2
  16. package/dist/cli/auth.js +5 -1
  17. package/dist/cli/beads-pin.js +6 -7
  18. package/dist/cli/claude-mod.d.ts +75 -0
  19. package/dist/cli/claude-mod.js +288 -0
  20. package/dist/cli/dolt-install.d.ts +1 -1
  21. package/dist/cli/dolt-install.js +5 -1
  22. package/dist/cli/fleet-se-guard.d.ts +8 -0
  23. package/dist/cli/fleet-se-guard.js +19 -3
  24. package/dist/cli/install-guard.d.ts +9 -0
  25. package/dist/cli/install-guard.js +24 -0
  26. package/dist/cli/install.d.ts +12 -0
  27. package/dist/cli/install.js +180 -20
  28. package/dist/cli/kb-profile.d.ts +16 -0
  29. package/dist/cli/kb-profile.js +81 -0
  30. package/dist/cli/start.js +3 -0
  31. package/dist/cli/uninstall.js +13 -3
  32. package/dist/cli/update.d.ts +4 -0
  33. package/dist/cli/update.js +19 -3
  34. package/dist/commands/kb-server.d.ts +10 -1
  35. package/dist/commands/kb-server.js +285 -11
  36. package/dist/index.js +22 -1
  37. package/dist/os/git-executable.d.ts +57 -0
  38. package/dist/os/git-executable.js +85 -0
  39. package/dist/os/go-concurrency.d.ts +44 -0
  40. package/dist/os/go-concurrency.js +53 -0
  41. package/dist/os/index.d.ts +1 -0
  42. package/dist/os/index.js +1 -0
  43. package/dist/os/linux.d.ts +2 -0
  44. package/dist/os/linux.js +10 -1
  45. package/dist/os/os-commands.d.ts +25 -0
  46. package/dist/os/os-commands.js +2 -0
  47. package/dist/os/windows-executable.d.ts +53 -0
  48. package/dist/os/windows-executable.js +185 -0
  49. package/dist/os/windows-gitbash.d.ts +23 -14
  50. package/dist/os/windows-gitbash.js +40 -16
  51. package/dist/os/windows.d.ts +2 -0
  52. package/dist/os/windows.js +37 -6
  53. package/dist/paths.d.ts +10 -1
  54. package/dist/paths.js +19 -2
  55. package/dist/services/agy-project.d.ts +7 -1
  56. package/dist/services/agy-project.js +7 -2
  57. package/dist/services/auth-socket.d.ts +18 -0
  58. package/dist/services/auth-socket.js +30 -4
  59. package/dist/services/credential-store.d.ts +33 -0
  60. package/dist/services/credential-store.js +79 -2
  61. package/dist/services/http-transport.d.ts +29 -0
  62. package/dist/services/http-transport.js +166 -37
  63. package/dist/services/kb-tool-profile.d.ts +36 -0
  64. package/dist/services/kb-tool-profile.js +88 -0
  65. package/dist/services/knowledge/bible-blob-id.js +10 -1
  66. package/dist/services/knowledge/bible-import.d.ts +108 -0
  67. package/dist/services/knowledge/bible-import.js +137 -4
  68. package/dist/services/knowledge/file-hash.js +6 -5
  69. package/dist/services/knowledge/http-provider.d.ts +303 -20
  70. package/dist/services/knowledge/http-provider.js +795 -125
  71. package/dist/services/knowledge/kb-config.d.ts +65 -1
  72. package/dist/services/knowledge/kb-config.js +143 -3
  73. package/dist/services/knowledge/kb-http-auth-state.d.ts +26 -0
  74. package/dist/services/knowledge/kb-http-auth-state.js +40 -0
  75. package/dist/services/knowledge/kb-providers.d.ts +9 -2
  76. package/dist/services/knowledge/kb-providers.js +67 -37
  77. package/dist/services/knowledge/kb-removed-scope-keys.js +1 -1
  78. package/dist/services/knowledge/kb-self.d.ts +122 -9
  79. package/dist/services/knowledge/kb-self.js +196 -36
  80. package/dist/services/knowledge/member-bible-view.js +16 -3
  81. package/dist/services/knowledge/path-validation.d.ts +7 -0
  82. package/dist/services/knowledge/path-validation.js +11 -0
  83. package/dist/services/knowledge/project-slug.js +3 -2
  84. package/dist/services/knowledge/repository-header.d.ts +77 -0
  85. package/dist/services/knowledge/repository-header.js +233 -0
  86. package/dist/services/knowledge/require-sqlite-project.d.ts +1 -1
  87. package/dist/services/knowledge/require-sqlite-project.js +1 -1
  88. package/dist/services/knowledge/sqlite-provider.d.ts +169 -0
  89. package/dist/services/knowledge/sqlite-provider.js +416 -4
  90. package/dist/services/knowledge/types.d.ts +15 -2
  91. package/dist/services/member-busy.d.ts +12 -0
  92. package/dist/services/member-busy.js +20 -0
  93. package/dist/services/member-config-io.d.ts +3 -2
  94. package/dist/services/member-config-io.js +7 -4
  95. package/dist/services/member-fleet-install.js +1 -0
  96. package/dist/services/member-tool-allowlist.d.ts +1 -1
  97. package/dist/services/member-tool-allowlist.js +8 -4
  98. package/dist/services/port-holder.js +2 -1
  99. package/dist/services/service-manager/types.d.ts +17 -1
  100. package/dist/services/service-manager/windows.d.ts +7 -2
  101. package/dist/services/service-manager/windows.js +28 -11
  102. package/dist/services/service-notice.d.ts +7 -0
  103. package/dist/services/service-notice.js +19 -0
  104. package/dist/services/session-registry.d.ts +13 -0
  105. package/dist/services/session-registry.js +13 -0
  106. package/dist/services/session-roots.d.ts +67 -0
  107. package/dist/services/session-roots.js +126 -0
  108. package/dist/services/statusline.d.ts +21 -0
  109. package/dist/services/statusline.js +97 -1
  110. package/dist/services/supervisor-service-cleanup.js +2 -1
  111. package/dist/services/tool-registry.js +108 -20
  112. package/dist/services/tool-scope.d.ts +34 -1
  113. package/dist/services/tool-scope.js +27 -2
  114. package/dist/services/vcs/azure-devops.js +10 -0
  115. package/dist/services/vcs/bitbucket.d.ts +22 -1
  116. package/dist/services/vcs/bitbucket.js +163 -17
  117. package/dist/services/vcs/types.d.ts +25 -2
  118. package/dist/services/watch/project-resolver.js +2 -1
  119. package/dist/skills/pm/cost.md +5 -1
  120. package/dist/skills/pm/index.md +9 -9
  121. package/dist/skills/pm/sprint.md +2 -1
  122. package/dist/tools/check-status.d.ts +51 -0
  123. package/dist/tools/check-status.js +124 -12
  124. package/dist/tools/code-intelligence-freshness.js +1 -1
  125. package/dist/tools/code-intelligence-gitnexus.d.ts +19 -0
  126. package/dist/tools/code-intelligence-gitnexus.js +166 -9
  127. package/dist/tools/code-intelligence-readiness.d.ts +58 -1
  128. package/dist/tools/code-intelligence-readiness.js +93 -8
  129. package/dist/tools/code-intelligence-reindex.d.ts +25 -1
  130. package/dist/tools/code-intelligence-reindex.js +76 -4
  131. package/dist/tools/code-intelligence.d.ts +1 -1
  132. package/dist/tools/code-intelligence.js +1 -1
  133. package/dist/tools/execute-command.js +14 -8
  134. package/dist/tools/execute-prompt.js +6 -2
  135. package/dist/tools/fleet-snapshot.d.ts +21 -0
  136. package/dist/tools/fleet-snapshot.js +78 -0
  137. package/dist/tools/kb-bible-commit.d.ts +25 -11
  138. package/dist/tools/kb-bible-commit.js +142 -33
  139. package/dist/tools/kb-capture.d.ts +2 -2
  140. package/dist/tools/kb-context.js +47 -27
  141. package/dist/tools/kb-demote.d.ts +27 -0
  142. package/dist/tools/kb-demote.js +37 -0
  143. package/dist/tools/kb-export.d.ts +35 -3
  144. package/dist/tools/kb-export.js +56 -13
  145. package/dist/tools/kb-feedback.d.ts +2 -0
  146. package/dist/tools/kb-feedback.js +17 -7
  147. package/dist/tools/kb-harvest.js +28 -9
  148. package/dist/tools/kb-import.d.ts +18 -2
  149. package/dist/tools/kb-import.js +24 -9
  150. package/dist/tools/kb-invalidate.d.ts +11 -3
  151. package/dist/tools/kb-invalidate.js +80 -7
  152. package/dist/tools/kb-list.js +38 -10
  153. package/dist/tools/kb-promote.js +6 -4
  154. package/dist/tools/kb-query.d.ts +3 -0
  155. package/dist/tools/kb-query.js +181 -37
  156. package/dist/tools/kb-session-prime.d.ts +4 -4
  157. package/dist/tools/kb-session-prime.js +89 -9
  158. package/dist/tools/kb-setup.d.ts +20 -0
  159. package/dist/tools/kb-setup.js +149 -11
  160. package/dist/tools/list-members.js +1 -1
  161. package/dist/tools/member-detail.js +7 -3
  162. package/dist/tools/provision-vcs-auth.d.ts +28 -3
  163. package/dist/tools/provision-vcs-auth.js +53 -7
  164. package/dist/tools/receive-files.js +7 -4
  165. package/dist/tools/send-files.js +5 -4
  166. package/dist/tools/send-message.d.ts +3 -0
  167. package/dist/tools/send-message.js +15 -2
  168. package/dist/tools/stop-prompt.js +3 -1
  169. package/dist/tools/vcs-credential-exec.d.ts +45 -3
  170. package/dist/tools/vcs-credential-exec.js +90 -11
  171. package/dist/utils/process-utils.js +5 -1
  172. package/dist/utils/redact-known-secrets.d.ts +17 -0
  173. package/dist/utils/redact-known-secrets.js +70 -0
  174. package/dist/utils/skill-matrix.js +1 -1
  175. package/dist/utils/vcs-provider-detect.js +2 -2
  176. package/dist/workflows/auto-sprint.js +245 -9
  177. package/package.json +10 -7
  178. package/packages/apra-fleet-client/package.json +1 -1
  179. package/packages/apra-fleet-client/src/client/api.mjs +172 -19
  180. package/packages/apra-fleet-client/src/client/reconnecting-transport.mjs +35 -2
  181. package/packages/apra-fleet-client/src/client/transport.mjs +6 -0
  182. package/packages/apra-fleet-se/apra-pm/agents/backlog-groomer.md +5 -0
  183. package/packages/apra-fleet-se/apra-pm/agents/ci-watcher.md +5 -0
  184. package/packages/apra-fleet-se/apra-pm/agents/deployer.md +20 -2
  185. package/packages/apra-fleet-se/apra-pm/agents/doer.md +38 -2
  186. package/packages/apra-fleet-se/apra-pm/agents/harvester.md +12 -9
  187. package/packages/apra-fleet-se/apra-pm/agents/integ-test-runner.md +5 -0
  188. package/packages/apra-fleet-se/apra-pm/agents/kb-reconciler.md +6 -0
  189. package/packages/apra-fleet-se/apra-pm/agents/plan-reviewer.md +5 -0
  190. package/packages/apra-fleet-se/apra-pm/agents/planner.md +5 -0
  191. package/packages/apra-fleet-se/apra-pm/agents/regression-test-runner.md +5 -0
  192. package/packages/apra-fleet-se/apra-pm/agents/reviewer.md +67 -15
  193. package/packages/apra-fleet-se/apra-pm/agents/schemas/deployer-output.json +5 -0
  194. package/packages/apra-fleet-se/apra-pm/agents/schemas/doer-output.json +78 -2
  195. package/packages/apra-fleet-se/apra-pm/agents/schemas/reviewer-output.json +104 -2
  196. package/packages/apra-fleet-se/apra-pm/skills/pm/cost.md +5 -1
  197. package/packages/apra-fleet-se/apra-pm/skills/pm/index.md +9 -9
  198. package/packages/apra-fleet-se/apra-pm/skills/pm/sprint.md +2 -1
  199. package/packages/apra-fleet-se/bin/cli.mjs +104 -31
  200. package/packages/apra-fleet-se/bin/serve.mjs +46 -8
  201. package/packages/apra-fleet-se/fleet-sprint/abort.mjs +184 -32
  202. package/packages/apra-fleet-se/fleet-sprint/bd-sync-command.mjs +69 -0
  203. package/packages/apra-fleet-se/fleet-sprint/beads-children.mjs +21 -0
  204. package/packages/apra-fleet-se/fleet-sprint/beads-lock-probe.mjs +176 -0
  205. package/packages/apra-fleet-se/fleet-sprint/beads-reachability.mjs +126 -0
  206. package/packages/apra-fleet-se/fleet-sprint/beads-scope.mjs +158 -1
  207. package/packages/apra-fleet-se/fleet-sprint/contracts.mjs +82 -2
  208. package/packages/apra-fleet-se/fleet-sprint/coordination.mjs +23 -6
  209. package/packages/apra-fleet-se/fleet-sprint/decision-notify.mjs +338 -0
  210. package/packages/apra-fleet-se/fleet-sprint/decision-wait.mjs +731 -0
  211. package/packages/apra-fleet-se/fleet-sprint/decisions.mjs +372 -0
  212. package/packages/apra-fleet-se/fleet-sprint/dispatch-role.mjs +44 -11
  213. package/packages/apra-fleet-se/fleet-sprint/docs/README.md +4 -1
  214. package/packages/apra-fleet-se/fleet-sprint/dolt-settle.mjs +9 -3
  215. package/packages/apra-fleet-se/fleet-sprint/dolt-sync.mjs +314 -19
  216. package/packages/apra-fleet-se/fleet-sprint/errors.mjs +72 -4
  217. package/packages/apra-fleet-se/fleet-sprint/git-sync.mjs +7 -1
  218. package/packages/apra-fleet-se/fleet-sprint/git-topology.mjs +112 -1
  219. package/packages/apra-fleet-se/fleet-sprint/guarded-modules.mjs +36 -2
  220. package/packages/apra-fleet-se/fleet-sprint/kb.mjs +736 -101
  221. package/packages/apra-fleet-se/fleet-sprint/member-init-probe.mjs +1 -1
  222. package/packages/apra-fleet-se/fleet-sprint/member-provisioning.mjs +7 -1
  223. package/packages/apra-fleet-se/fleet-sprint/phases/deploy.mjs +49 -2
  224. package/packages/apra-fleet-se/fleet-sprint/phases/develop.mjs +206 -3
  225. package/packages/apra-fleet-se/fleet-sprint/phases/final-review.mjs +61 -3
  226. package/packages/apra-fleet-se/fleet-sprint/phases/harvest.mjs +81 -31
  227. package/packages/apra-fleet-se/fleet-sprint/phases/plan.mjs +7 -3
  228. package/packages/apra-fleet-se/fleet-sprint/phases/publish-pr.mjs +39 -14
  229. package/packages/apra-fleet-se/fleet-sprint/phases/re-review.mjs +17 -1
  230. package/packages/apra-fleet-se/fleet-sprint/phases/review.mjs +18 -3
  231. package/packages/apra-fleet-se/fleet-sprint/pr-body.mjs +14 -1
  232. package/packages/apra-fleet-se/fleet-sprint/prompts.mjs +32 -5
  233. package/packages/apra-fleet-se/fleet-sprint/runner.js +824 -98
  234. package/packages/apra-fleet-se/fleet-sprint/se-os-commands.mjs +4 -2
  235. package/packages/apra-fleet-se/fleet-sprint/se-posix.mjs +54 -1
  236. package/packages/apra-fleet-se/fleet-sprint/se-windows.mjs +29 -2
  237. package/packages/apra-fleet-se/fleet-sprint/set-aside.mjs +288 -0
  238. package/packages/apra-fleet-se/fleet-sprint/skills/fleet-supervisor/SKILL.md +3 -2
  239. package/packages/apra-fleet-se/fleet-sprint/sprint-args.mjs +20 -0
  240. package/packages/apra-fleet-se/fleet-sprint/sprint-report.mjs +21 -0
  241. package/packages/apra-fleet-se/fleet-sprint/sprint-state.mjs +9 -0
  242. package/packages/apra-fleet-se/fleet-sprint/vcs-auth.mjs +605 -32
  243. package/packages/apra-fleet-se/fleet-sprint/vcs-providers/bitbucket.mjs +811 -17
  244. package/packages/apra-fleet-se/fleet-sprint/vcs-providers/index.mjs +89 -1
  245. package/packages/apra-fleet-se/fleet-sprint/viewer-extensions.mjs +225 -2
  246. package/packages/apra-fleet-se/fleet-sprint/worklists.mjs +59 -3
  247. package/packages/apra-fleet-se/src/supervisor/api.mjs +148 -8
  248. package/packages/apra-fleet-se/src/supervisor/dashboard.mjs +6 -3
  249. package/packages/apra-fleet-se/src/supervisor/dolt-mutex.mjs +30 -10
  250. package/packages/apra-fleet-se/src/supervisor/fleet-members.mjs +17 -4
  251. package/packages/apra-fleet-se/src/supervisor/history.mjs +8 -1
  252. package/packages/apra-fleet-se/src/supervisor/id-allocator.mjs +92 -2
  253. package/packages/apra-fleet-se/src/supervisor/proxy.mjs +26 -1
  254. package/packages/apra-fleet-se/src/supervisor/server.mjs +151 -8
  255. package/packages/apra-fleet-se/src/supervisor/spawner.mjs +11 -9
  256. package/packages/apra-fleet-se/src/supervisor/watchdog.mjs +7 -1
  257. package/packages/apra-fleet-workflow/package.json +2 -1
  258. package/packages/apra-fleet-workflow/src/viewer/index.mjs +86 -5
  259. package/packages/apra-fleet-workflow/src/viewer/request-guard.mjs +222 -0
  260. package/packages/apra-fleet-workflow/src/workflow/index.mjs +34 -2
  261. package/plugins/claude-code/fleet-status/.claude-plugin/plugin.json +7 -0
  262. package/plugins/claude-code/fleet-status/hooks/hooks.json +1 -0
  263. package/plugins/claude-code/fleet-status/hooks/register.tsx +906 -0
  264. package/plugins/claude-code/fleet-status/types/index.d.ts +88 -0
  265. package/skills/fleet/auth-bitbucket.md +47 -20
  266. package/skills/fleet/onboarding.md +1 -1
  267. package/skills/fleet/skill-matrix.md +3 -3
  268. package/version.json +1 -1
@@ -81,7 +81,7 @@
81
81
  * // literal -- out of the shared
82
82
  * // callers. Only meaningful
83
83
  * // alongside parseRepoRef.
84
- * buildProvisionArgs: (ctx) => { args, note? }|{ error } // OPTIONAL;
84
+ * buildProvisionArgs: (ctx) => { args, note? }|{ skip: true, note? }|{ error } // OPTIONAL;
85
85
  * // provisioning axis. Build the
86
86
  * // provision_vcs_auth argument
87
87
  * // object for a member of this
@@ -112,6 +112,20 @@
112
112
  * // optional `note` string next to
113
113
  * // `args` is logged as an advisory,
114
114
  * // never treated as a failure.
115
+ * // A THIRD answer, `{ skip: true }`,
116
+ * // means "nothing to provision for
117
+ * // this request -- proceed on the
118
+ * // credential already deployed":
119
+ * // for a provider whose credential
120
+ * // is deployed out of band and has
121
+ * // no scope axis to widen, a
122
+ * // just-in-time re-provision is
123
+ * // both impossible and pointless,
124
+ * // and failing it would abort the
125
+ * // call it exists to enable (see
126
+ * // ./bitbucket.mjs). Pair it with a
127
+ * // `note` so the skip is never
128
+ * // silent.
115
129
  * defaultAuthMode: string|null // OPTIONAL, but declaring it (even
116
130
  * // as null) is what makes a provider
117
131
  * // part of resolveProvider()'s/
@@ -170,6 +184,62 @@
170
184
  * // not yet implemented" (fails
171
185
  * // closed with a typed ERROR:,
172
186
  * // never a silently wrong command)
187
+ * httpFailureHint: (statusOrCtx) => string|{ hint, remedy } // OPTIONAL;
188
+ * // REST failure explanation.
189
+ * // Called with a bare status
190
+ * // (legacy; returns a diagnosis
191
+ * // string, '' for none) or with
192
+ * // { status, body, headers,
193
+ * // availableSecrets, memberName,
194
+ * // repoRef, repo, local? } --
195
+ * // headers are the RESPONSE
196
+ * // headers (lowercased names) a
197
+ * // builder captured with curl
198
+ * // `-D -`; availableSecrets is
199
+ * // the credential-store name list
200
+ * // (null when unreadable). The
201
+ * // ctx form returns { hint,
202
+ * // remedy }: `hint` diagnoses the
203
+ * // failure from the response, and
204
+ * // a non-empty `remedy` REPLACES
205
+ * // authRemedy.hint for this one
206
+ * // failure (lead with the one-line
207
+ * // fix). Providers that ignore the
208
+ * // ctx keep working: a string
209
+ * // answer is used as the hint and
210
+ * // the generic remedy stays.
211
+ * credentialProbe: { // OPTIONAL; preflight credential
212
+ * build: (params) => { command, // probe axis, only consulted for
213
+ * logSafeCommand, interpret }, // a non-re-mintable provider
214
+ * expectedUsername?: string, // (authRemedy.serverSideReMintable
215
+ * remedy?: (ctx) => string // === false). With it, the VCS
216
+ * } // preflight (vcs-auth.mjs
217
+ * // createVcsAuthPreflightCallback)
218
+ * // runs git ls-remote AND `build`'s
219
+ * // REST command through
220
+ * // vcs_credential_exec with the
221
+ * // provider label (params: repoRef,
222
+ * // token = the {{vcs_token_inline}}
223
+ * // placeholder, os, shell) -- the
224
+ * // exact credential Publish PR
225
+ * // reads -- and, when
226
+ * // expectedUsername is set, checks
227
+ * // the helper's username= line
228
+ * // (read member-side, token line
229
+ * // never printed). ok only if all
230
+ * // pass. A REST refusal is worded
231
+ * // via httpFailureHint(ctx);
232
+ * // `remedy(ctx)` (ctx:
233
+ * // availableSecrets, memberName,
234
+ * // repoRef, local) words the fix
235
+ * // for every other failure. Omit it
236
+ * // and the preflight probes with
237
+ * // git ls-remote only, as before.
238
+ * findBeforeCreate: boolean, // OPTIONAL; create is not an upsert.
239
+ * // raiseVcsPrForMember runs
240
+ * // find-pull-request first and
241
+ * // updates a hit (PUT) instead of
242
+ * // POSTing a duplicate.
173
243
  * authRemedy: { // OPTIONAL; auth-self-heal axis
174
244
  * serverSideReMintable: boolean, // (apra-fleet-5co8.4.2). Whether
175
245
  * hint: string // the REACTIVE self-heal callback
@@ -383,6 +453,24 @@ export function registerVcsProvider(impl) {
383
453
  throw new Error(`ERROR: VCSModule: provider "${impl.name}" has an \`authRemedy\` with no non-empty string \`hint\`.`); // shell-guard-allow: escaped backtick is markdown-style inline-code formatting in a thrown developer-facing Error message, never a shell command string -- shell-command-guard flags any literal backtick in any JS string, not just dispatched command-string arguments.
384
454
  }
385
455
  }
456
+ // The preflight credential-probe axis. OPTIONAL, validated up front for
457
+ // the same reason as the hooks above: a malformed probe must fail at
458
+ // registration, not inside a sprint preflight that never throws.
459
+ if (impl.httpFailureHint != null && typeof impl.httpFailureHint !== 'function') {
460
+ throw new Error(`ERROR: VCSModule: provider "${impl.name}" has a non-function httpFailureHint.`);
461
+ }
462
+ if (impl.credentialProbe != null) {
463
+ const probe = impl.credentialProbe;
464
+ if (typeof probe !== 'object' || typeof probe.build !== 'function') {
465
+ throw new Error(`ERROR: VCSModule: provider "${impl.name}" has a credentialProbe with no build function.`);
466
+ }
467
+ if (probe.expectedUsername != null && (typeof probe.expectedUsername !== 'string' || !probe.expectedUsername.trim())) {
468
+ throw new Error(`ERROR: VCSModule: provider "${impl.name}" has a credentialProbe with a non-string or empty expectedUsername.`);
469
+ }
470
+ if (probe.remedy != null && typeof probe.remedy !== 'function') {
471
+ throw new Error(`ERROR: VCSModule: provider "${impl.name}" has a credentialProbe with a non-function remedy.`);
472
+ }
473
+ }
386
474
  // The permission-scope axis. OPTIONAL (omitting it means "this provider
387
475
  // declares no permission-scope rules", i.e. today's behavior for every
388
476
  // AUTH_DENIED it produces), but validated up front for the same reason as
@@ -2,6 +2,7 @@ import { escapeHtml } from '@apralabs/apra-fleet-workflow/viewer/html-utils';
2
2
  import { computeSprintProgress } from './sprint-progress.mjs';
3
3
  import { DISPATCH_TOOL_CALLS_STATE_NAMESPACE } from './dispatch-accounting.mjs';
4
4
  import { MEMBER_INIT_STATE_NAMESPACE } from './member-init-probe.mjs';
5
+ import { DECISIONS_STATE_NAMESPACE, answerPendingDecision } from './decision-wait.mjs';
5
6
 
6
7
  /**
7
8
  * apra-fleet-x8r.1: pure HTML-string builder for the beads-closed/required
@@ -720,9 +721,12 @@ export function renderBeadsHtml(sprintTasks, backlogTasks, collapsedIds) {
720
721
  export function renderResultExtrasHtml(result) {
721
722
  const verdict = result && typeof result === 'object' ? result.verdict : undefined;
722
723
  const prUrl = result && typeof result === 'object' ? result.prUrl : undefined;
724
+ const warnings = result && typeof result === 'object' && Array.isArray(result.warnings)
725
+ ? result.warnings.filter((w) => typeof w === 'string' && w.length > 0)
726
+ : [];
723
727
  // Nothing se-meaningful to show (non-fleet-sprint workflow, or a run that
724
728
  // hasn't finished yet) -- let the caller hide its container entirely.
725
- if (verdict == null && prUrl == null) return '';
729
+ if (verdict == null && prUrl == null && warnings.length === 0) return '';
726
730
 
727
731
  // Color signals outcome, same register as the beads status badges above:
728
732
  // a clean PASS/MERGED/APPROVED recedes to green, anything that means
@@ -752,7 +756,17 @@ export function renderResultExtrasHtml(result) {
752
756
  'style="color: var(--accent); font-size: 11px; text-decoration: none; white-space: nowrap;">PR -&gt;</a>';
753
757
  }
754
758
 
755
- return verdictHtml + prHtml;
759
+ // A terminal status of success-with-warnings (e.g. PR skipped for a VCS
760
+ // auth failure) renders each warning as an amber badge, never as plain
761
+ // success.
762
+ let warnHtml = '';
763
+ for (let i = 0; i < warnings.length; i++) {
764
+ warnHtml += '<span title="' + escapeHtml(warnings[i]) + '" style="color: var(--warning, #f59e0b); ' +
765
+ 'font-weight: 700; font-size: 11px; border: 1px solid var(--warning, #f59e0b); border-radius: 4px; ' +
766
+ 'padding: 2px 6px; white-space: nowrap;">WARNING: ' + escapeHtml(warnings[i]) + '</span>';
767
+ }
768
+
769
+ return verdictHtml + warnHtml + prHtml;
756
770
  }
757
771
 
758
772
  /**
@@ -1284,3 +1298,212 @@ export const kbCodeIntelExtension = {
1284
1298
  renderKbCodeIntelPanel();
1285
1299
  `
1286
1300
  };
1301
+
1302
+ // =============================================================================
1303
+ // PENDING OPERATOR DECISIONS: banner + answer form (decision-wait.mjs publishes
1304
+ // the 'decisions' namespace: { state, pending: [...], waitingSince, setAside }).
1305
+ // =============================================================================
1306
+
1307
+ /** Longest operator answer the answer route accepts. */
1308
+ export const DECISION_ANSWER_MAX_CHARS = 4000;
1309
+
1310
+ /**
1311
+ * The decisions banner. Pure and self-contained (it is embedded into the
1312
+ * browser page with .toString(), like the other renderers here): every
1313
+ * interpolated value goes through escapeHtml; a malformed record can never
1314
+ * take the page down. Returns '' when nothing is pending. Question, options
1315
+ * and recommendation are never truncated.
1316
+ *
1317
+ * @param {{ state?: string, pending?: object[] }|null|undefined} data
1318
+ * @returns {string}
1319
+ */
1320
+ export function renderDecisionsBannerHtml(data) {
1321
+ try {
1322
+ const pending = data && Array.isArray(data.pending) ? data.pending.filter(function (d) { return d && typeof d === 'object'; }) : [];
1323
+ if (pending.length === 0) return '';
1324
+ function channelHtml(name, n) {
1325
+ if (!n || typeof n !== 'object' || !n.status) {
1326
+ return '<span data-notify-channel="' + escapeHtml(name) + '" style="color: #a1a1aa;">' + escapeHtml(name) + ': not attempted</span>';
1327
+ }
1328
+ if (n.status === 'sent') {
1329
+ return '<span data-notify-channel="' + escapeHtml(name) + '" style="color: #4ade80;">' + escapeHtml(name) + ': sent</span>';
1330
+ }
1331
+ return '<span data-notify-channel="' + escapeHtml(name) + '" data-notify-failed="true" style="color: #f87171;">'
1332
+ + escapeHtml(name) + ': notification failed' + (n.reason ? ' (' + escapeHtml(String(n.reason)) + ')' : '') + '</span>';
1333
+ }
1334
+ const paused = data.state === 'paused-awaiting-decision';
1335
+ let html = '<div data-decisions-banner="true" style="border: 1px solid #f59e0b; background: #2a2110; border-radius: 6px; padding: 10px; margin: 6px;">'
1336
+ + '<div style="font-weight: 600; color: #fbbf24; font-size: 13px;">Operator decision needed ('
1337
+ + escapeHtml(String(pending.length)) + ' pending' + (paused ? ', sprint paused awaiting decision' : '') + ')</div>';
1338
+ for (const d of pending) {
1339
+ const id = escapeHtml(String(d.decisionId || ''));
1340
+ const options = Array.isArray(d.options) ? d.options : [];
1341
+ const n = d.notification && typeof d.notification === 'object' ? d.notification : {};
1342
+ html += '<div data-decision-id="' + id + '" style="margin-top: 10px; font-size: 12px; color: #e4e4e7;">'
1343
+ + '<div style="color: #a1a1aa;">Bead ' + escapeHtml(String(d.beadId || '')) + (d.decisionBeadId ? ' (decision bead ' + escapeHtml(String(d.decisionBeadId)) + ')' : '') + '</div>'
1344
+ + '<div data-decision-question="true" style="white-space: pre-wrap; margin: 4px 0;">' + escapeHtml(String(d.question || '')) + '</div>'
1345
+ + '<ul style="margin: 4px 0; padding-left: 18px;">';
1346
+ for (const o of options) {
1347
+ html += '<li data-decision-option="' + escapeHtml(String(o && o.id)) + '" style="white-space: pre-wrap;">(' + escapeHtml(String(o && o.id)) + ') ' + escapeHtml(String(o && o.text)) + '</li>';
1348
+ }
1349
+ html += '</ul><div data-decision-recommendation="true">Recommendation: ' + escapeHtml(String(d.recommendation || '')) + '</div>'
1350
+ + '<div style="margin-top: 4px; font-size: 11px;">Notification: ' + channelHtml('message', n.message) + ' &middot; ' + channelHtml('email', n.email) + '</div>'
1351
+ + '<form data-decision-form="' + id + '" style="margin-top: 6px;">';
1352
+ for (const o of options) {
1353
+ html += '<label style="margin-right: 10px;"><input type="radio" name="option-' + id + '" value="' + escapeHtml(String(o && o.id)) + '"/> ' + escapeHtml(String(o && o.id)) + '</label>';
1354
+ }
1355
+ html += '<div><textarea name="text" maxlength="4000" rows="2" placeholder="Answer or extra instructions" style="width: 90%; margin-top: 4px; background: #18181b; color: #e4e4e7; border: 1px solid #3f3f46;"></textarea></div>'
1356
+ + '<button type="submit" style="margin-top: 4px;">Submit answer</button> <span data-decision-result="true" style="font-size: 11px;"></span>'
1357
+ + '</form></div>';
1358
+ }
1359
+ return html + '</div>';
1360
+ } catch (err) {
1361
+ return '<div data-decisions-banner="true" data-decisions-error="true" style="color: #f87171; padding: 8px;">(pending decisions present but could not be rendered)</div>';
1362
+ }
1363
+ }
1364
+
1365
+ /**
1366
+ * Validates an answer-route body: { decisionId, answer } with a non-empty
1367
+ * string answer of at most DECISION_ANSWER_MAX_CHARS. Returns { ok, ... }.
1368
+ */
1369
+ export function validateDecisionAnswerBody(body) {
1370
+ if (!body || typeof body !== 'object' || Array.isArray(body)) return { ok: false, error: 'body must be a JSON object' };
1371
+ if (typeof body.decisionId !== 'string' || !body.decisionId.trim()) return { ok: false, error: 'decisionId is required' };
1372
+ if (typeof body.answer !== 'string' || !body.answer.trim()) return { ok: false, error: 'answer is required' };
1373
+ if (body.answer.length > DECISION_ANSWER_MAX_CHARS) return { ok: false, error: `answer is longer than ${DECISION_ANSWER_MAX_CHARS} characters` };
1374
+ return { ok: true, decisionId: body.decisionId.trim(), answer: body.answer.trim() };
1375
+ }
1376
+
1377
+ /**
1378
+ * Builds the decisions dashboard extension. `answer(decisionId, answer)` is
1379
+ * injectable for tests; it defaults to the in-process run that owns the
1380
+ * decision (decision-wait.mjs), which records it exactly like
1381
+ * `bd human respond` and resumes the sprint without a relaunch.
1382
+ */
1383
+ export function createDecisionsExtension({ answer = answerPendingDecision } = {}) {
1384
+ return {
1385
+ id: DECISIONS_STATE_NAMESPACE,
1386
+ title: 'Decisions',
1387
+ // Once-per-publish summary, delivered unleaned in both GET /state
1388
+ // (top-level `summary`) and GET /state?summary=1, so a pending
1389
+ // decision's question and options are never truncated.
1390
+ summarize(data) {
1391
+ const d = data || {};
1392
+ return {
1393
+ state: d.state || 'running',
1394
+ pending: Array.isArray(d.pending) ? d.pending : [],
1395
+ waitingSince: d.waitingSince ?? null,
1396
+ };
1397
+ },
1398
+ actions: {
1399
+ async answer({ body, state }) {
1400
+ const checked = validateDecisionAnswerBody(body);
1401
+ if (!checked.ok) return { status: 400, body: { error: checked.error } };
1402
+ const known = state && state.extensions && state.extensions[DECISIONS_STATE_NAMESPACE];
1403
+ const pending = known && Array.isArray(known.pending) ? known.pending : [];
1404
+ if (!pending.some((d) => d && d.decisionId === checked.decisionId)) {
1405
+ return { status: 404, body: { error: 'no such pending decision', decisionId: checked.decisionId } };
1406
+ }
1407
+ try {
1408
+ const rec = await answer(checked.decisionId, checked.answer);
1409
+ return { status: 200, body: { ok: true, decisionId: checked.decisionId, status: (rec && rec.status) || 'recorded', released: (rec && rec.released) || [] } };
1410
+ } catch (err) {
1411
+ return { status: 409, body: { error: String(err && err.message ? err.message : err).slice(0, 500) } };
1412
+ }
1413
+ },
1414
+ },
1415
+ js: `
1416
+ ${escapeHtml.toString()}
1417
+ ${renderDecisionsBannerHtml.toString()}
1418
+
1419
+ let lastDecisions = null;
1420
+ let formBusy = false;
1421
+ // A render that arrived while an answer was in flight; applied once
1422
+ // the operator has had a moment to read the inline result.
1423
+ let renderDeferred = false;
1424
+ // Last HTML written to each surface: an identical re-publish must
1425
+ // not wipe an answer the operator is still typing.
1426
+ const renderedHtml = { panel: null, banner: null };
1427
+
1428
+ function renderDecisionsPanel() {
1429
+ const container = document.getElementById('extension-decisions');
1430
+ if (!container) return;
1431
+ const html = renderDecisionsBannerHtml(lastDecisions) || '<div style="font-size: 11px; color: #71717a; padding: 8px;">(no decisions pending)</div>';
1432
+ if (html === renderedHtml.panel) return;
1433
+ renderedHtml.panel = html;
1434
+ container.innerHTML = html;
1435
+ }
1436
+
1437
+ // The header-level banner (the viewer's per-extension slot outside
1438
+ // every tab panel): visible on every tab while a decision is
1439
+ // pending, hidden when none is.
1440
+ function renderDecisionsHeaderBanner() {
1441
+ const slot = document.getElementById('extension-banner-decisions');
1442
+ if (!slot) return;
1443
+ const html = renderDecisionsBannerHtml(lastDecisions);
1444
+ if (html === renderedHtml.banner) return;
1445
+ renderedHtml.banner = html;
1446
+ slot.innerHTML = html;
1447
+ slot.style.display = html ? 'block' : 'none';
1448
+ }
1449
+
1450
+ function renderDecisions() {
1451
+ if (formBusy) { renderDeferred = true; return; }
1452
+ renderDecisionsPanel();
1453
+ renderDecisionsHeaderBanner();
1454
+ }
1455
+
1456
+ // GET /state leans long strings under state.extensions, so the
1457
+ // untruncated per-publish summary (summarize() above, dispatched
1458
+ // just before the state event) is preferred; the raw state is the
1459
+ // fallback when no summary has been published yet.
1460
+ let lastSummary = null;
1461
+ document.addEventListener('workflow:summary:decisions', (e) => {
1462
+ lastSummary = e.detail || null;
1463
+ });
1464
+ document.addEventListener('workflow:state:decisions', (e) => {
1465
+ lastDecisions = lastSummary || e.detail || null;
1466
+ renderDecisions();
1467
+ });
1468
+
1469
+ document.addEventListener('submit', async (ev) => {
1470
+ const form = ev.target && ev.target.closest ? ev.target.closest('form[data-decision-form]') : null;
1471
+ if (!form) return;
1472
+ ev.preventDefault();
1473
+ const decisionId = form.getAttribute('data-decision-form');
1474
+ const picked = form.querySelector('input[type=radio]:checked');
1475
+ const text = (form.querySelector('textarea') || {}).value || '';
1476
+ const answer = [picked ? picked.value : '', text.trim()].filter(Boolean).join(': ');
1477
+ const result = form.querySelector('[data-decision-result]');
1478
+ if (!answer) { if (result) result.textContent = 'Choose an option or type an answer.'; return; }
1479
+ formBusy = true;
1480
+ let recorded = false;
1481
+ try {
1482
+ // Same-origin JSON POST: the answer routes refuse any other
1483
+ // content type and any cross-site origin.
1484
+ const res = await fetch('/extensions/decisions/actions/answer', {
1485
+ method: 'POST', headers: { 'Content-Type': 'application/json' },
1486
+ body: JSON.stringify({ decisionId: decisionId, answer: answer })
1487
+ });
1488
+ const out = await res.json().catch(() => ({}));
1489
+ recorded = res.ok;
1490
+ if (result) result.textContent = res.ok ? 'Answer recorded; the sprint resumes.' : ('Failed: ' + (out.error || res.status));
1491
+ } catch (err) {
1492
+ if (result) result.textContent = 'Failed: ' + err.message;
1493
+ } finally {
1494
+ const release = () => {
1495
+ formBusy = false;
1496
+ if (renderDeferred) { renderDeferred = false; renderDecisions(); }
1497
+ };
1498
+ // Keep a recorded result readable briefly before a state
1499
+ // update that drops the answered decision hides it.
1500
+ if (recorded) setTimeout(release, 2500); else release();
1501
+ }
1502
+ });
1503
+
1504
+ renderDecisions();
1505
+ `
1506
+ };
1507
+ }
1508
+
1509
+ export const decisionsExtension = createDecisionsExtension();
@@ -13,6 +13,7 @@
13
13
  // <-> worklists.mjs cycle is safe because every use is inside a function
14
14
  // body, never at module-evaluation time.
15
15
  import { normalizeTierToken, DEFAULT_CONTEXT_CEILING } from './runner.js';
16
+ import { laneOf } from './beads-scope.mjs';
16
17
 
17
18
  /**
18
19
  * Validates a streak-assignment agent() result against the set of currently
@@ -86,9 +87,12 @@ export function selectStreaks(candidate, currentReady) {
86
87
  * Ordering is total and stable: within a lane by numeric `streakOrder`
87
88
  * ascending (missing/non-numeric last), then `title`, then `id`; lanes by their
88
89
  * minimum `streakOrder`, then `streak` id. Members of a ready set are mutually
89
- * unblocked by definition (a `blocks` edge would keep the blocked side out of
90
- * the set), so `streakOrder` alone cannot violate a blocks edge and the
91
- * title/id tiebreak only separates otherwise-equal peers.
90
+ * unblocked over `blocks` edges (such an edge keeps the blocked side out of
91
+ * the set), and lane order is enforced before this point by
92
+ * holdBackByLaneOrder(): a bead whose lower-order lane-mate is open and not
93
+ * in the same ready set never reaches here. So `streakOrder` alone cannot
94
+ * violate a prerequisite and the title/id tiebreak only separates
95
+ * otherwise-equal peers.
92
96
  *
93
97
  * Pure: no I/O, no agent() calls.
94
98
  * @param {Array<{id: string, title?: string, metadata?: {streak?: string, streakOrder?: number|string}}>} currentReady
@@ -135,6 +139,58 @@ export function groupStreaksFromLaneMetadata(currentReady) {
135
139
  return { streaks: laneEntries.map((e) => e.sorted), reason: null };
136
140
  }
137
141
 
142
+ /**
143
+ * Lane order is a prerequisite: a laned ready bead is dispatchable only when
144
+ * every lane-mate with a LOWER `streakOrder` is closed or is itself in the
145
+ * dispatchable set (it then runs ahead of it in the same streak, since
146
+ * groupStreaksFromLaneMetadata puts one lane into one streak in order).
147
+ * Holding one bead can hold its successors, so this runs to a fixpoint. Beads
148
+ * without a finite `streakOrder` take no part.
149
+ *
150
+ * Pure: no I/O.
151
+ * @param {Array<object>} ready this round's candidate beads, after every other exclusion
152
+ * @param {Array<object>} scopeBeads every in-scope bead, any status
153
+ * @returns {{ dispatchable: object[], held: Array<{ id: string, on: string[] }> }}
154
+ */
155
+ export function holdBackByLaneOrder(ready, scopeBeads) {
156
+ const list = Array.isArray(ready) ? ready : [];
157
+ const kept = new Set(list.map((b) => String(b.id)));
158
+ const openLaned = [];
159
+ const seen = new Set();
160
+ for (const b of [...(Array.isArray(scopeBeads) ? scopeBeads : []), ...list]) {
161
+ if (!b || seen.has(String(b.id))) continue;
162
+ seen.add(String(b.id));
163
+ if (b.status !== 'closed' && laneOf(b)) openLaned.push(b);
164
+ }
165
+ const lowerOpenMates = (bead) => {
166
+ const lane = laneOf(bead);
167
+ if (!lane) return [];
168
+ return openLaned
169
+ .filter((m) => String(m.id) !== String(bead.id))
170
+ .filter((m) => { const ml = laneOf(m); return ml.streak === lane.streak && ml.order < lane.order; })
171
+ .map((m) => String(m.id));
172
+ };
173
+ const heldOn = new Map();
174
+ let changed = true;
175
+ while (changed) {
176
+ changed = false;
177
+ for (const b of list) {
178
+ const id = String(b.id);
179
+ if (!kept.has(id)) continue;
180
+ const missing = lowerOpenMates(b).filter((m) => !kept.has(m));
181
+ if (missing.length > 0) {
182
+ kept.delete(id);
183
+ heldOn.set(id, missing.sort());
184
+ changed = true;
185
+ }
186
+ }
187
+ }
188
+ return {
189
+ dispatchable: list.filter((b) => kept.has(String(b.id))),
190
+ held: [...heldOn.entries()].map(([id, on]) => ({ id, on })),
191
+ };
192
+ }
193
+
138
194
  export const SIZE_POINTS = Object.freeze({ S: 1, M: 2, L: 4 });
139
195
  export const MODEL_WEIGHT = Object.freeze({ cheap: 1, standard: 10, premium: 20 });
140
196
  export const DEFAULT_EFFORT_THRESHOLD = 200;