@apralabs/apra-fleet 0.3.5 → 0.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 (571) hide show
  1. package/README.md +245 -257
  2. package/dist/agents/backlog-groomer.md +287 -0
  3. package/dist/agents/deployer.md +52 -11
  4. package/dist/agents/doer.md +32 -7
  5. package/dist/agents/integ-test-runner.md +151 -61
  6. package/dist/agents/plan-reviewer.md +74 -17
  7. package/dist/agents/planner.md +94 -14
  8. package/dist/agents/regression-test-runner.md +216 -0
  9. package/dist/agents/reviewer.md +21 -6
  10. package/dist/agents/schemas/backlog-groomer-input.json +35 -0
  11. package/dist/agents/schemas/backlog-groomer-output.json +164 -0
  12. package/dist/agents/schemas/integ-test-runner-output.json +34 -0
  13. package/dist/agents/schemas/regression-test-runner-input.json +15 -0
  14. package/dist/agents/schemas/regression-test-runner-output.json +50 -0
  15. package/dist/agents/schemas/reviewer-output.json +4 -0
  16. package/dist/cli/agent-transform.d.ts +1 -0
  17. package/dist/cli/agent-transform.d.ts.map +1 -1
  18. package/dist/cli/agent-transform.js +77 -0
  19. package/dist/cli/agent-transform.js.map +1 -1
  20. package/dist/cli/auth.d.ts +3 -0
  21. package/dist/cli/auth.d.ts.map +1 -1
  22. package/dist/cli/auth.js +181 -5
  23. package/dist/cli/auth.js.map +1 -1
  24. package/dist/cli/config.d.ts +5 -1
  25. package/dist/cli/config.d.ts.map +1 -1
  26. package/dist/cli/config.js +7 -1
  27. package/dist/cli/config.js.map +1 -1
  28. package/dist/cli/dolt-install.d.ts +91 -0
  29. package/dist/cli/dolt-install.d.ts.map +1 -0
  30. package/dist/cli/dolt-install.js +334 -0
  31. package/dist/cli/dolt-install.js.map +1 -0
  32. package/dist/cli/install-guard.d.ts +29 -0
  33. package/dist/cli/install-guard.d.ts.map +1 -0
  34. package/dist/cli/install-guard.js +153 -0
  35. package/dist/cli/install-guard.js.map +1 -0
  36. package/dist/cli/install.d.ts +44 -3
  37. package/dist/cli/install.d.ts.map +1 -1
  38. package/dist/cli/install.js +604 -108
  39. package/dist/cli/install.js.map +1 -1
  40. package/dist/cli/join.d.ts +12 -0
  41. package/dist/cli/join.d.ts.map +1 -0
  42. package/dist/cli/join.js +87 -0
  43. package/dist/cli/join.js.map +1 -0
  44. package/dist/cli/register-member.d.ts +2 -0
  45. package/dist/cli/register-member.d.ts.map +1 -0
  46. package/dist/cli/register-member.js +193 -0
  47. package/dist/cli/register-member.js.map +1 -0
  48. package/dist/cli/restart.d.ts +2 -0
  49. package/dist/cli/restart.d.ts.map +1 -0
  50. package/dist/cli/restart.js +7 -0
  51. package/dist/cli/restart.js.map +1 -0
  52. package/dist/cli/secret.js +8 -2
  53. package/dist/cli/secret.js.map +1 -1
  54. package/dist/cli/spoke.d.ts +35 -0
  55. package/dist/cli/spoke.d.ts.map +1 -0
  56. package/dist/cli/spoke.js +212 -0
  57. package/dist/cli/spoke.js.map +1 -0
  58. package/dist/cli/start.d.ts +2 -0
  59. package/dist/cli/start.d.ts.map +1 -0
  60. package/dist/cli/start.js +92 -0
  61. package/dist/cli/start.js.map +1 -0
  62. package/dist/cli/status.d.ts +2 -0
  63. package/dist/cli/status.d.ts.map +1 -0
  64. package/dist/cli/status.js +83 -0
  65. package/dist/cli/status.js.map +1 -0
  66. package/dist/cli/stop.d.ts +2 -0
  67. package/dist/cli/stop.d.ts.map +1 -0
  68. package/dist/cli/stop.js +51 -0
  69. package/dist/cli/stop.js.map +1 -0
  70. package/dist/cli/uninstall.d.ts.map +1 -1
  71. package/dist/cli/uninstall.js +109 -9
  72. package/dist/cli/uninstall.js.map +1 -1
  73. package/dist/cli/update.d.ts.map +1 -1
  74. package/dist/cli/update.js +10 -1
  75. package/dist/cli/update.js.map +1 -1
  76. package/dist/cli/workflow-assets.d.ts +37 -0
  77. package/dist/cli/workflow-assets.d.ts.map +1 -0
  78. package/dist/cli/workflow-assets.js +144 -0
  79. package/dist/cli/workflow-assets.js.map +1 -0
  80. package/dist/cli/workflow.d.ts +75 -0
  81. package/dist/cli/workflow.d.ts.map +1 -0
  82. package/dist/cli/workflow.js +397 -0
  83. package/dist/cli/workflow.js.map +1 -0
  84. package/dist/hub-service/activity.d.ts +30 -0
  85. package/dist/hub-service/activity.d.ts.map +1 -0
  86. package/dist/hub-service/activity.js +20 -0
  87. package/dist/hub-service/activity.js.map +1 -0
  88. package/dist/hub-service/audit-log.d.ts +19 -0
  89. package/dist/hub-service/audit-log.d.ts.map +1 -0
  90. package/dist/hub-service/audit-log.js +13 -0
  91. package/dist/hub-service/audit-log.js.map +1 -0
  92. package/dist/hub-service/db/pool.d.ts +19 -0
  93. package/dist/hub-service/db/pool.d.ts.map +1 -0
  94. package/dist/hub-service/db/pool.js +53 -0
  95. package/dist/hub-service/db/pool.js.map +1 -0
  96. package/dist/hub-service/enrollment.d.ts +29 -0
  97. package/dist/hub-service/enrollment.d.ts.map +1 -0
  98. package/dist/hub-service/enrollment.js +48 -0
  99. package/dist/hub-service/enrollment.js.map +1 -0
  100. package/dist/hub-service/envelope-routes.d.ts +46 -0
  101. package/dist/hub-service/envelope-routes.d.ts.map +1 -0
  102. package/dist/hub-service/envelope-routes.js +94 -0
  103. package/dist/hub-service/envelope-routes.js.map +1 -0
  104. package/dist/hub-service/handlers/installers.d.ts +14 -0
  105. package/dist/hub-service/handlers/installers.d.ts.map +1 -0
  106. package/dist/hub-service/handlers/installers.js +8 -0
  107. package/dist/hub-service/handlers/installers.js.map +1 -0
  108. package/dist/hub-service/http-server.d.ts +31 -0
  109. package/dist/hub-service/http-server.d.ts.map +1 -0
  110. package/dist/hub-service/http-server.js +711 -0
  111. package/dist/hub-service/http-server.js.map +1 -0
  112. package/dist/hub-service/hub-jwt.d.ts +30 -0
  113. package/dist/hub-service/hub-jwt.d.ts.map +1 -0
  114. package/dist/hub-service/hub-jwt.js +105 -0
  115. package/dist/hub-service/hub-jwt.js.map +1 -0
  116. package/dist/hub-service/jwt-revocation.d.ts +20 -0
  117. package/dist/hub-service/jwt-revocation.d.ts.map +1 -0
  118. package/dist/hub-service/jwt-revocation.js +18 -0
  119. package/dist/hub-service/jwt-revocation.js.map +1 -0
  120. package/dist/hub-service/machines.d.ts +16 -0
  121. package/dist/hub-service/machines.d.ts.map +1 -0
  122. package/dist/hub-service/machines.js +14 -0
  123. package/dist/hub-service/machines.js.map +1 -0
  124. package/dist/hub-service/main.d.ts +3 -0
  125. package/dist/hub-service/main.d.ts.map +1 -0
  126. package/dist/hub-service/main.js +64 -0
  127. package/dist/hub-service/main.js.map +1 -0
  128. package/dist/hub-service/member-tokens.d.ts +11 -0
  129. package/dist/hub-service/member-tokens.d.ts.map +1 -0
  130. package/dist/hub-service/member-tokens.js +49 -0
  131. package/dist/hub-service/member-tokens.js.map +1 -0
  132. package/dist/hub-service/member-view.d.ts +20 -0
  133. package/dist/hub-service/member-view.d.ts.map +1 -0
  134. package/dist/hub-service/member-view.js +76 -0
  135. package/dist/hub-service/member-view.js.map +1 -0
  136. package/dist/hub-service/members.d.ts +44 -0
  137. package/dist/hub-service/members.d.ts.map +1 -0
  138. package/dist/hub-service/members.js +25 -0
  139. package/dist/hub-service/members.js.map +1 -0
  140. package/dist/hub-service/presence.d.ts +40 -0
  141. package/dist/hub-service/presence.d.ts.map +1 -0
  142. package/dist/hub-service/presence.js +44 -0
  143. package/dist/hub-service/presence.js.map +1 -0
  144. package/dist/hub-service/project-view.d.ts +12 -0
  145. package/dist/hub-service/project-view.d.ts.map +1 -0
  146. package/dist/hub-service/project-view.js +34 -0
  147. package/dist/hub-service/project-view.js.map +1 -0
  148. package/dist/hub-service/projects.d.ts +48 -0
  149. package/dist/hub-service/projects.d.ts.map +1 -0
  150. package/dist/hub-service/projects.js +80 -0
  151. package/dist/hub-service/projects.js.map +1 -0
  152. package/dist/hub-service/relay-queue.d.ts +115 -0
  153. package/dist/hub-service/relay-queue.d.ts.map +1 -0
  154. package/dist/hub-service/relay-queue.js +148 -0
  155. package/dist/hub-service/relay-queue.js.map +1 -0
  156. package/dist/hub-service/session-jwt.d.ts +10 -0
  157. package/dist/hub-service/session-jwt.d.ts.map +1 -0
  158. package/dist/hub-service/session-jwt.js +69 -0
  159. package/dist/hub-service/session-jwt.js.map +1 -0
  160. package/dist/hub-service/usage.d.ts +40 -0
  161. package/dist/hub-service/usage.d.ts.map +1 -0
  162. package/dist/hub-service/usage.js +25 -0
  163. package/dist/hub-service/usage.js.map +1 -0
  164. package/dist/hub-service/users.d.ts +56 -0
  165. package/dist/hub-service/users.d.ts.map +1 -0
  166. package/dist/hub-service/users.js +72 -0
  167. package/dist/hub-service/users.js.map +1 -0
  168. package/dist/hub-service/workspaces.d.ts +20 -0
  169. package/dist/hub-service/workspaces.d.ts.map +1 -0
  170. package/dist/hub-service/workspaces.js +10 -0
  171. package/dist/hub-service/workspaces.js.map +1 -0
  172. package/dist/index.js +179 -132
  173. package/dist/index.js.map +1 -1
  174. package/dist/os/linux.d.ts +13 -0
  175. package/dist/os/linux.d.ts.map +1 -1
  176. package/dist/os/linux.js +62 -3
  177. package/dist/os/linux.js.map +1 -1
  178. package/dist/os/os-commands.d.ts +10 -0
  179. package/dist/os/os-commands.d.ts.map +1 -1
  180. package/dist/os/windows.d.ts +1 -0
  181. package/dist/os/windows.d.ts.map +1 -1
  182. package/dist/os/windows.js +21 -1
  183. package/dist/os/windows.js.map +1 -1
  184. package/dist/paths.d.ts +23 -0
  185. package/dist/paths.d.ts.map +1 -1
  186. package/dist/paths.js +29 -0
  187. package/dist/paths.js.map +1 -1
  188. package/dist/providers/agy.d.ts +9 -2
  189. package/dist/providers/agy.d.ts.map +1 -1
  190. package/dist/providers/agy.js +127 -14
  191. package/dist/providers/agy.js.map +1 -1
  192. package/dist/providers/claude.d.ts +6 -2
  193. package/dist/providers/claude.d.ts.map +1 -1
  194. package/dist/providers/claude.js +248 -9
  195. package/dist/providers/claude.js.map +1 -1
  196. package/dist/providers/codex.d.ts +3 -2
  197. package/dist/providers/codex.d.ts.map +1 -1
  198. package/dist/providers/codex.js +7 -0
  199. package/dist/providers/codex.js.map +1 -1
  200. package/dist/providers/copilot.d.ts +3 -2
  201. package/dist/providers/copilot.d.ts.map +1 -1
  202. package/dist/providers/copilot.js +8 -1
  203. package/dist/providers/copilot.js.map +1 -1
  204. package/dist/providers/gemini.d.ts +3 -2
  205. package/dist/providers/gemini.d.ts.map +1 -1
  206. package/dist/providers/gemini.js +11 -1
  207. package/dist/providers/gemini.js.map +1 -1
  208. package/dist/providers/index.d.ts +1 -0
  209. package/dist/providers/index.d.ts.map +1 -1
  210. package/dist/providers/index.js +3 -0
  211. package/dist/providers/index.js.map +1 -1
  212. package/dist/providers/none.d.ts +51 -0
  213. package/dist/providers/none.d.ts.map +1 -0
  214. package/dist/providers/none.js +103 -0
  215. package/dist/providers/none.js.map +1 -0
  216. package/dist/providers/opencode.d.ts +4 -2
  217. package/dist/providers/opencode.d.ts.map +1 -1
  218. package/dist/providers/opencode.js +49 -0
  219. package/dist/providers/opencode.js.map +1 -1
  220. package/dist/providers/provider.d.ts +79 -1
  221. package/dist/providers/provider.d.ts.map +1 -1
  222. package/dist/providers/provider.js +10 -0
  223. package/dist/providers/provider.js.map +1 -1
  224. package/dist/services/agent-provisioner.d.ts +3 -3
  225. package/dist/services/agent-provisioner.d.ts.map +1 -1
  226. package/dist/services/agent-provisioner.js +12 -5
  227. package/dist/services/agent-provisioner.js.map +1 -1
  228. package/dist/services/auth-socket.d.ts.map +1 -1
  229. package/dist/services/auth-socket.js +2 -0
  230. package/dist/services/auth-socket.js.map +1 -1
  231. package/dist/services/budget-awareness.d.ts +130 -0
  232. package/dist/services/budget-awareness.d.ts.map +1 -0
  233. package/dist/services/budget-awareness.js +129 -0
  234. package/dist/services/budget-awareness.js.map +1 -0
  235. package/dist/services/cloud-sync.d.ts +35 -0
  236. package/dist/services/cloud-sync.d.ts.map +1 -0
  237. package/dist/services/cloud-sync.js +90 -0
  238. package/dist/services/cloud-sync.js.map +1 -0
  239. package/dist/services/context-admission.d.ts +82 -0
  240. package/dist/services/context-admission.d.ts.map +1 -0
  241. package/dist/services/context-admission.js +136 -0
  242. package/dist/services/context-admission.js.map +1 -0
  243. package/dist/services/event-bus.d.ts +27 -0
  244. package/dist/services/event-bus.d.ts.map +1 -0
  245. package/dist/services/event-bus.js +20 -0
  246. package/dist/services/event-bus.js.map +1 -0
  247. package/dist/services/file-chunker.d.ts +38 -0
  248. package/dist/services/file-chunker.d.ts.map +1 -0
  249. package/dist/services/file-chunker.js +63 -0
  250. package/dist/services/file-chunker.js.map +1 -0
  251. package/dist/services/file-transfer-relay.d.ts +55 -0
  252. package/dist/services/file-transfer-relay.d.ts.map +1 -0
  253. package/dist/services/file-transfer-relay.js +115 -0
  254. package/dist/services/file-transfer-relay.js.map +1 -0
  255. package/dist/services/github-app.d.ts.map +1 -1
  256. package/dist/services/github-app.js +1 -0
  257. package/dist/services/github-app.js.map +1 -1
  258. package/dist/services/http-transport.d.ts +25 -0
  259. package/dist/services/http-transport.d.ts.map +1 -0
  260. package/dist/services/http-transport.js +371 -0
  261. package/dist/services/http-transport.js.map +1 -0
  262. package/dist/services/hub-client.d.ts +69 -0
  263. package/dist/services/hub-client.d.ts.map +1 -0
  264. package/dist/services/hub-client.js +217 -0
  265. package/dist/services/hub-client.js.map +1 -0
  266. package/dist/services/jwt.d.ts +17 -0
  267. package/dist/services/jwt.d.ts.map +1 -0
  268. package/dist/services/jwt.js +70 -0
  269. package/dist/services/jwt.js.map +1 -0
  270. package/dist/services/known-sessions.d.ts +8 -0
  271. package/dist/services/known-sessions.d.ts.map +1 -0
  272. package/dist/services/known-sessions.js +40 -0
  273. package/dist/services/known-sessions.js.map +1 -0
  274. package/dist/services/model-pricing.d.ts +36 -0
  275. package/dist/services/model-pricing.d.ts.map +1 -0
  276. package/dist/services/model-pricing.js +108 -0
  277. package/dist/services/model-pricing.js.map +1 -0
  278. package/dist/services/orphan-recovery.d.ts +56 -0
  279. package/dist/services/orphan-recovery.d.ts.map +1 -0
  280. package/dist/services/orphan-recovery.js +111 -0
  281. package/dist/services/orphan-recovery.js.map +1 -0
  282. package/dist/services/pending-responses.d.ts +23 -0
  283. package/dist/services/pending-responses.d.ts.map +1 -0
  284. package/dist/services/pending-responses.js +52 -0
  285. package/dist/services/pending-responses.js.map +1 -0
  286. package/dist/services/registry.d.ts +4 -1
  287. package/dist/services/registry.d.ts.map +1 -1
  288. package/dist/services/registry.js +3 -0
  289. package/dist/services/registry.js.map +1 -1
  290. package/dist/services/relay-context.d.ts +23 -0
  291. package/dist/services/relay-context.d.ts.map +1 -0
  292. package/dist/services/relay-context.js +8 -0
  293. package/dist/services/relay-context.js.map +1 -0
  294. package/dist/services/relay-executor.d.ts +68 -0
  295. package/dist/services/relay-executor.d.ts.map +1 -0
  296. package/dist/services/relay-executor.js +70 -0
  297. package/dist/services/relay-executor.js.map +1 -0
  298. package/dist/services/relay-request.d.ts +65 -0
  299. package/dist/services/relay-request.d.ts.map +1 -0
  300. package/dist/services/relay-request.js +129 -0
  301. package/dist/services/relay-request.js.map +1 -0
  302. package/dist/services/relay-strategy.d.ts +19 -0
  303. package/dist/services/relay-strategy.d.ts.map +1 -0
  304. package/dist/services/relay-strategy.js +111 -0
  305. package/dist/services/relay-strategy.js.map +1 -0
  306. package/dist/services/service-manager/index.d.ts +5 -0
  307. package/dist/services/service-manager/index.d.ts.map +1 -0
  308. package/dist/services/service-manager/index.js +66 -0
  309. package/dist/services/service-manager/index.js.map +1 -0
  310. package/dist/services/service-manager/linux.d.ts +10 -0
  311. package/dist/services/service-manager/linux.d.ts.map +1 -0
  312. package/dist/services/service-manager/linux.js +97 -0
  313. package/dist/services/service-manager/linux.js.map +1 -0
  314. package/dist/services/service-manager/macos.d.ts +10 -0
  315. package/dist/services/service-manager/macos.d.ts.map +1 -0
  316. package/dist/services/service-manager/macos.js +94 -0
  317. package/dist/services/service-manager/macos.js.map +1 -0
  318. package/dist/services/service-manager/types.d.ts +18 -0
  319. package/dist/services/service-manager/types.d.ts.map +1 -0
  320. package/dist/services/service-manager/types.js +5 -0
  321. package/dist/services/service-manager/types.js.map +1 -0
  322. package/dist/services/service-manager/windows.d.ts +10 -0
  323. package/dist/services/service-manager/windows.d.ts.map +1 -0
  324. package/dist/services/service-manager/windows.js +73 -0
  325. package/dist/services/service-manager/windows.js.map +1 -0
  326. package/dist/services/session-registry.d.ts +70 -0
  327. package/dist/services/session-registry.d.ts.map +1 -0
  328. package/dist/services/session-registry.js +91 -0
  329. package/dist/services/session-registry.js.map +1 -0
  330. package/dist/services/singleton.d.ts +15 -0
  331. package/dist/services/singleton.d.ts.map +1 -0
  332. package/dist/services/singleton.js +98 -0
  333. package/dist/services/singleton.js.map +1 -0
  334. package/dist/services/sprint-coordination.d.ts +168 -0
  335. package/dist/services/sprint-coordination.d.ts.map +1 -0
  336. package/dist/services/sprint-coordination.js +564 -0
  337. package/dist/services/sprint-coordination.js.map +1 -0
  338. package/dist/services/ssh.d.ts.map +1 -1
  339. package/dist/services/ssh.js +70 -3
  340. package/dist/services/ssh.js.map +1 -1
  341. package/dist/services/stall/log-path-resolver.d.ts.map +1 -1
  342. package/dist/services/stall/log-path-resolver.js +8 -1
  343. package/dist/services/stall/log-path-resolver.js.map +1 -1
  344. package/dist/services/stall/stall-detector.d.ts.map +1 -1
  345. package/dist/services/stall/stall-detector.js +39 -7
  346. package/dist/services/stall/stall-detector.js.map +1 -1
  347. package/dist/services/stall/stall-poller.d.ts +16 -0
  348. package/dist/services/stall/stall-poller.d.ts.map +1 -1
  349. package/dist/services/stall/stall-poller.js +136 -18
  350. package/dist/services/stall/stall-poller.js.map +1 -1
  351. package/dist/services/strategy.d.ts.map +1 -1
  352. package/dist/services/strategy.js +55 -5
  353. package/dist/services/strategy.js.map +1 -1
  354. package/dist/services/substitution-engine.d.ts +20 -0
  355. package/dist/services/substitution-engine.d.ts.map +1 -0
  356. package/dist/services/substitution-engine.js +92 -0
  357. package/dist/services/substitution-engine.js.map +1 -0
  358. package/dist/services/task-cleanup.d.ts.map +1 -1
  359. package/dist/services/task-cleanup.js +1 -9
  360. package/dist/services/task-cleanup.js.map +1 -1
  361. package/dist/services/token-issuer.d.ts +47 -0
  362. package/dist/services/token-issuer.d.ts.map +1 -0
  363. package/dist/services/token-issuer.js +63 -0
  364. package/dist/services/token-issuer.js.map +1 -0
  365. package/dist/services/tool-registry.d.ts +3 -0
  366. package/dist/services/tool-registry.d.ts.map +1 -0
  367. package/dist/services/tool-registry.js +139 -0
  368. package/dist/services/tool-registry.js.map +1 -0
  369. package/dist/services/user-config.d.ts +14 -0
  370. package/dist/services/user-config.d.ts.map +1 -1
  371. package/dist/services/user-config.js +55 -0
  372. package/dist/services/user-config.js.map +1 -1
  373. package/dist/services/vcs/types.d.ts +44 -0
  374. package/dist/services/vcs/types.d.ts.map +1 -1
  375. package/dist/skills/fleet-sprint-cli/SKILL.md +103 -0
  376. package/dist/skills/pm/cost.md +3 -0
  377. package/dist/skills/pm/doer-reviewer-loop.md +3 -0
  378. package/dist/tools/check-status.d.ts.map +1 -1
  379. package/dist/tools/check-status.js +8 -2
  380. package/dist/tools/check-status.js.map +1 -1
  381. package/dist/tools/child-id-allocator.d.ts +45 -0
  382. package/dist/tools/child-id-allocator.d.ts.map +1 -0
  383. package/dist/tools/child-id-allocator.js +62 -0
  384. package/dist/tools/child-id-allocator.js.map +1 -0
  385. package/dist/tools/cloud-control.d.ts +2 -2
  386. package/dist/tools/compose-permissions.d.ts +12 -4
  387. package/dist/tools/compose-permissions.d.ts.map +1 -1
  388. package/dist/tools/compose-permissions.js +55 -4
  389. package/dist/tools/compose-permissions.js.map +1 -1
  390. package/dist/tools/dolt-push-mutex.d.ts +44 -0
  391. package/dist/tools/dolt-push-mutex.d.ts.map +1 -0
  392. package/dist/tools/dolt-push-mutex.js +83 -0
  393. package/dist/tools/dolt-push-mutex.js.map +1 -0
  394. package/dist/tools/execute-command.d.ts +11 -1
  395. package/dist/tools/execute-command.d.ts.map +1 -1
  396. package/dist/tools/execute-command.js +22 -5
  397. package/dist/tools/execute-command.js.map +1 -1
  398. package/dist/tools/execute-prompt.d.ts +72 -12
  399. package/dist/tools/execute-prompt.d.ts.map +1 -1
  400. package/dist/tools/execute-prompt.js +962 -71
  401. package/dist/tools/execute-prompt.js.map +1 -1
  402. package/dist/tools/get-member-model-pricing.d.ts +21 -0
  403. package/dist/tools/get-member-model-pricing.d.ts.map +1 -0
  404. package/dist/tools/get-member-model-pricing.js +29 -0
  405. package/dist/tools/get-member-model-pricing.js.map +1 -0
  406. package/dist/tools/list-members.d.ts.map +1 -1
  407. package/dist/tools/list-members.js +39 -7
  408. package/dist/tools/list-members.js.map +1 -1
  409. package/dist/tools/member-detail.d.ts +1 -1
  410. package/dist/tools/member-detail.d.ts.map +1 -1
  411. package/dist/tools/member-detail.js +8 -2
  412. package/dist/tools/member-detail.js.map +1 -1
  413. package/dist/tools/member-reservation.d.ts +29 -0
  414. package/dist/tools/member-reservation.d.ts.map +1 -0
  415. package/dist/tools/member-reservation.js +71 -0
  416. package/dist/tools/member-reservation.js.map +1 -0
  417. package/dist/tools/provision-vcs-auth.d.ts +7 -7
  418. package/dist/tools/provision-vcs-auth.js +1 -1
  419. package/dist/tools/provision-vcs-auth.js.map +1 -1
  420. package/dist/tools/register-member.d.ts +17 -5
  421. package/dist/tools/register-member.d.ts.map +1 -1
  422. package/dist/tools/register-member.js +144 -5
  423. package/dist/tools/register-member.js.map +1 -1
  424. package/dist/tools/remove-member.d.ts +1 -1
  425. package/dist/tools/report-status.d.ts +33 -0
  426. package/dist/tools/report-status.d.ts.map +1 -0
  427. package/dist/tools/report-status.js +44 -0
  428. package/dist/tools/report-status.js.map +1 -0
  429. package/dist/tools/respond-to-message.d.ts +21 -0
  430. package/dist/tools/respond-to-message.d.ts.map +1 -0
  431. package/dist/tools/respond-to-message.js +23 -0
  432. package/dist/tools/respond-to-message.js.map +1 -0
  433. package/dist/tools/send-files.d.ts +3 -0
  434. package/dist/tools/send-files.d.ts.map +1 -1
  435. package/dist/tools/send-files.js +88 -8
  436. package/dist/tools/send-files.js.map +1 -1
  437. package/dist/tools/send-message.d.ts +27 -0
  438. package/dist/tools/send-message.d.ts.map +1 -0
  439. package/dist/tools/send-message.js +46 -0
  440. package/dist/tools/send-message.js.map +1 -0
  441. package/dist/tools/shutdown-server.d.ts +2 -0
  442. package/dist/tools/shutdown-server.d.ts.map +1 -1
  443. package/dist/tools/shutdown-server.js +19 -0
  444. package/dist/tools/shutdown-server.js.map +1 -1
  445. package/dist/tools/update-member.d.ts +8 -8
  446. package/dist/tools/update-member.d.ts.map +1 -1
  447. package/dist/tools/update-member.js +11 -1
  448. package/dist/tools/update-member.js.map +1 -1
  449. package/dist/types.d.ts +15 -3
  450. package/dist/types.d.ts.map +1 -1
  451. package/dist/utils/agent-helpers.d.ts +2 -1
  452. package/dist/utils/agent-helpers.d.ts.map +1 -1
  453. package/dist/utils/agent-helpers.js +7 -2
  454. package/dist/utils/agent-helpers.js.map +1 -1
  455. package/dist/utils/pid-helpers.d.ts +15 -0
  456. package/dist/utils/pid-helpers.d.ts.map +1 -1
  457. package/dist/utils/pid-helpers.js +23 -0
  458. package/dist/utils/pid-helpers.js.map +1 -1
  459. package/dist/utils/process-utils.d.ts +3 -0
  460. package/dist/utils/process-utils.d.ts.map +1 -0
  461. package/dist/utils/process-utils.js +42 -0
  462. package/dist/utils/process-utils.js.map +1 -0
  463. package/dist/utils/prompt-errors.d.ts +2 -1
  464. package/dist/utils/prompt-errors.d.ts.map +1 -1
  465. package/dist/utils/prompt-errors.js +13 -3
  466. package/dist/utils/prompt-errors.js.map +1 -1
  467. package/dist/utils/workspace-trust.d.ts +24 -0
  468. package/dist/utils/workspace-trust.d.ts.map +1 -0
  469. package/dist/utils/workspace-trust.js +35 -0
  470. package/dist/utils/workspace-trust.js.map +1 -0
  471. package/dist/workflows/auto-sprint.js +450 -87
  472. package/package.json +35 -7
  473. package/packages/apra-fleet-client/package.json +26 -0
  474. package/packages/apra-fleet-client/src/client/api.mjs +396 -0
  475. package/packages/apra-fleet-client/src/client/client.mjs +146 -0
  476. package/packages/apra-fleet-client/src/client/errors.mjs +71 -0
  477. package/packages/apra-fleet-client/src/client/factory.mjs +65 -0
  478. package/packages/apra-fleet-client/src/client/server-resolution.mjs +265 -0
  479. package/packages/apra-fleet-client/src/client/transport.mjs +327 -0
  480. package/packages/apra-fleet-se/apra-pm/agents/backlog-groomer.md +287 -0
  481. package/packages/apra-fleet-se/apra-pm/agents/ci-watcher.md +89 -0
  482. package/packages/apra-fleet-se/apra-pm/agents/deployer.md +139 -0
  483. package/packages/apra-fleet-se/apra-pm/agents/doer.md +225 -0
  484. package/packages/apra-fleet-se/apra-pm/agents/harvester.md +169 -0
  485. package/packages/apra-fleet-se/apra-pm/agents/integ-test-runner.md +316 -0
  486. package/packages/apra-fleet-se/apra-pm/agents/plan-reviewer.md +188 -0
  487. package/packages/apra-fleet-se/apra-pm/agents/planner.md +239 -0
  488. package/packages/apra-fleet-se/apra-pm/agents/regression-test-runner.md +216 -0
  489. package/packages/apra-fleet-se/apra-pm/agents/reviewer.md +174 -0
  490. package/packages/apra-fleet-se/apra-pm/agents/schemas/backlog-groomer-input.json +35 -0
  491. package/packages/apra-fleet-se/apra-pm/agents/schemas/backlog-groomer-output.json +164 -0
  492. package/packages/apra-fleet-se/apra-pm/agents/schemas/ci-watcher-input.json +26 -0
  493. package/packages/apra-fleet-se/apra-pm/agents/schemas/ci-watcher-output.json +18 -0
  494. package/packages/apra-fleet-se/apra-pm/agents/schemas/deployer-input.json +19 -0
  495. package/packages/apra-fleet-se/apra-pm/agents/schemas/deployer-output.json +17 -0
  496. package/packages/apra-fleet-se/apra-pm/agents/schemas/doer-input.json +25 -0
  497. package/packages/apra-fleet-se/apra-pm/agents/schemas/doer-output.json +22 -0
  498. package/packages/apra-fleet-se/apra-pm/agents/schemas/harvester-input.json +31 -0
  499. package/packages/apra-fleet-se/apra-pm/agents/schemas/harvester-output.json +18 -0
  500. package/packages/apra-fleet-se/apra-pm/agents/schemas/integ-test-runner-input.json +20 -0
  501. package/packages/apra-fleet-se/apra-pm/agents/schemas/integ-test-runner-output.json +61 -0
  502. package/packages/apra-fleet-se/apra-pm/agents/schemas/plan-reviewer-input.json +15 -0
  503. package/packages/apra-fleet-se/apra-pm/agents/schemas/plan-reviewer-output.json +30 -0
  504. package/packages/apra-fleet-se/apra-pm/agents/schemas/regression-test-runner-input.json +15 -0
  505. package/packages/apra-fleet-se/apra-pm/agents/schemas/regression-test-runner-output.json +50 -0
  506. package/packages/apra-fleet-se/apra-pm/agents/schemas/reviewer-input.json +25 -0
  507. package/packages/apra-fleet-se/apra-pm/agents/schemas/reviewer-output.json +38 -0
  508. package/packages/apra-fleet-se/apra-pm/skills/pm/SKILL.md +402 -0
  509. package/packages/apra-fleet-se/apra-pm/skills/pm/beads.md +142 -0
  510. package/packages/apra-fleet-se/apra-pm/skills/pm/cost.md +157 -0
  511. package/packages/apra-fleet-se/apra-pm/skills/pm/doer-reviewer-loop.md +300 -0
  512. package/packages/apra-fleet-se/apra-pm/skills/pm/fleet-addendum.md +121 -0
  513. package/packages/apra-fleet-se/apra-pm/skills/pm/simple-sprint.md +65 -0
  514. package/packages/apra-fleet-se/apra-pm/skills/pm/sprint.md +327 -0
  515. package/packages/apra-fleet-se/apra-pm/skills/pm/worktrees.md +92 -0
  516. package/packages/apra-fleet-se/apra-pm/version.json +3 -0
  517. package/packages/apra-fleet-se/bin/cli.mjs +857 -0
  518. package/packages/apra-fleet-se/bin/serve.mjs +383 -0
  519. package/packages/apra-fleet-se/fleet-sprint/conflict-ladder.mjs +178 -0
  520. package/packages/apra-fleet-se/fleet-sprint/contracts.mjs +914 -0
  521. package/packages/apra-fleet-se/fleet-sprint/dispatch-safety-guard.mjs +177 -0
  522. package/packages/apra-fleet-se/fleet-sprint/docs/README.md +191 -0
  523. package/packages/apra-fleet-se/fleet-sprint/docs/coach-role-design.md +151 -0
  524. package/packages/apra-fleet-se/fleet-sprint/docs/dolt-tier2-runbook.md +127 -0
  525. package/packages/apra-fleet-se/fleet-sprint/docs/fleet-sprint-diagram.md +94 -0
  526. package/packages/apra-fleet-se/fleet-sprint/docs/stabilization-log.md +1125 -0
  527. package/packages/apra-fleet-se/fleet-sprint/dolt-literal-guard.mjs +72 -0
  528. package/packages/apra-fleet-se/fleet-sprint/dolt-recovery-path-b.mjs +339 -0
  529. package/packages/apra-fleet-se/fleet-sprint/dolt-recovery-tier2.mjs +360 -0
  530. package/packages/apra-fleet-se/fleet-sprint/dolt-recovery.mjs +363 -0
  531. package/packages/apra-fleet-se/fleet-sprint/dolt-sync.mjs +1244 -0
  532. package/packages/apra-fleet-se/fleet-sprint/errors.mjs +572 -0
  533. package/packages/apra-fleet-se/fleet-sprint/full-db-fetch-guard.mjs +118 -0
  534. package/packages/apra-fleet-se/fleet-sprint/runner.js +9447 -0
  535. package/packages/apra-fleet-se/fleet-sprint/skills/fleet-sprint-cli/SKILL.md +103 -0
  536. package/packages/apra-fleet-se/fleet-sprint/sprint-lock.mjs +140 -0
  537. package/packages/apra-fleet-se/fleet-sprint/vcs-module.mjs +435 -0
  538. package/packages/apra-fleet-se/fleet-sprint/vcs-providers/azure-devops.mjs +68 -0
  539. package/packages/apra-fleet-se/fleet-sprint/vcs-providers/bitbucket.mjs +53 -0
  540. package/packages/apra-fleet-se/fleet-sprint/vcs-providers/dolt.mjs +146 -0
  541. package/packages/apra-fleet-se/fleet-sprint/vcs-providers/generic-git.mjs +176 -0
  542. package/packages/apra-fleet-se/fleet-sprint/vcs-providers/github.mjs +222 -0
  543. package/packages/apra-fleet-se/fleet-sprint/vcs-providers/index.mjs +218 -0
  544. package/packages/apra-fleet-se/fleet-sprint/viewer-extensions.mjs +882 -0
  545. package/packages/apra-fleet-se/package.json +28 -0
  546. package/packages/apra-fleet-se/workflow.json +1 -0
  547. package/packages/apra-fleet-workflow/package.json +30 -0
  548. package/packages/apra-fleet-workflow/src/viewer/command-output-cap.mjs +112 -0
  549. package/packages/apra-fleet-workflow/src/viewer/debounced-writer.mjs +153 -0
  550. package/packages/apra-fleet-workflow/src/viewer/html-utils.mjs +31 -0
  551. package/packages/apra-fleet-workflow/src/viewer/index.mjs +1325 -0
  552. package/packages/apra-fleet-workflow/src/viewer/lean-state.mjs +237 -0
  553. package/packages/apra-fleet-workflow/src/viewer/run-state-paths.mjs +130 -0
  554. package/packages/apra-fleet-workflow/src/viewer/sprint-state-paths.mjs +29 -0
  555. package/packages/apra-fleet-workflow/src/workflow/engine.mjs +200 -0
  556. package/packages/apra-fleet-workflow/src/workflow/errors.mjs +146 -0
  557. package/packages/apra-fleet-workflow/src/workflow/index.mjs +1723 -0
  558. package/packages/apra-fleet-workflow/src/workflow/journal.mjs +291 -0
  559. package/packages/apra-fleet-workflow/src/workflow/pricing.mjs +99 -0
  560. package/packages/apra-fleet-workflow/src/workflow/vetting.mjs +111 -0
  561. package/scripts/agy-transcript-reader.js +1 -0
  562. package/scripts/fleet-statusline.sh +17 -13
  563. package/skills/fleet/SKILL.md +37 -2
  564. package/skills/fleet/beads.md +14 -7
  565. package/skills/fleet/permissions.md +50 -0
  566. package/skills/fleet/profiles/base-dev.json +1 -0
  567. package/skills/fleet/profiles/base-reviewer.json +1 -0
  568. package/skills/fleet/profiles/node.json +2 -2
  569. package/version.json +1 -1
  570. package/scripts/agy-settings-merge.js +0 -27
  571. /package/{dist → packages/apra-fleet-se/apra-pm}/agents/_shared/GRAPH-SEMANTICS.md +0 -0
@@ -0,0 +1,360 @@
1
+ // apra-fleet-eft.9.6 (Plan 3.4 -- Dolt conflict recovery ladder, Tier 2).
2
+ //
3
+ // This module is the dolt counterpart of conflict-ladder.mjs's Tier 2
4
+ // (agent-with-runbook) git conflict escalation. Where conflict-ladder.mjs
5
+ // escalates when Tier 1's own git-porcelain check finds real unmerged paths,
6
+ // this module escalates a wedged dolt clone to a REAL agent dispatch ONLY
7
+ // when the two scripted recovery paths (Path A, apra-fleet-eft.9.4;
8
+ // Path B, apra-fleet-eft.9.5) have BOTH failed to close it:
9
+ //
10
+ // - Path A's deterministic gate rejected the conflict shape (a multi-row
11
+ // conflict, or a conflict outside the table allowlist), OR Path A hit a
12
+ // genuine operational failure -- so Path B was attempted as the fallback;
13
+ // - Path B ALSO failed: a scripted step (most commonly `bd bootstrap` or
14
+ // the pending-mutation replay) returned output this ladder does not
15
+ // recognize as one of its already-classified recoverable patterns.
16
+ //
17
+ // Script-first posture, never proceed blind: the whole point of this module
18
+ // is that neither Path A's gate rejection NOR an unrecognized Path B failure
19
+ // is ever silently swallowed or blindly retried. Both are recorded as a
20
+ // "wedged state" snapshot (clone path, conflict shape, last command output)
21
+ // BEFORE any further action, and Tier 2 is the escalation -- a real agent,
22
+ // armed with the runbook at fleet-sprint/docs/dolt-tier2-runbook.md, is
23
+ // dispatched to resolve the clone with actual judgment. Exactly like the git
24
+ // Tier 2 (conflict-ladder.mjs), this module only DISPATCHES: it does not
25
+ // itself decide whether the agent's attempt succeeded -- that is the
26
+ // caller's job (mechanically re-observing `bd dolt status`/`bd dolt push`
27
+ // after dispatch, the same posture as runner.js's syncMemberAfter Tier 2
28
+ // re-verification).
29
+ //
30
+ // -----------------------------------------------------------------------------
31
+ // apra-fleet-vkc.1 -- THE LADDER ENTRY POINT (buildDoltRecoveryLadder, below).
32
+ //
33
+ // This module is where the three previously test-only recovery paths
34
+ // (dolt-recovery.mjs Path A, dolt-recovery-path-b.mjs Path B, this module's
35
+ // Tier 2) are wired together into ONE zero-argument callback that a diverged
36
+ // D-push terminal invokes. That callback is what dolt-sync.mjs's
37
+ // doltPushAfter() calls at its divergence terminal, and what runner.js's
38
+ // post-dispatch sync bracket (syncMemberAfterOrdered) constructs and threads
39
+ // in. The disposition executed by apra-fleet-vkc.1 is WIRE, not decommission
40
+ // (see dolt-sync.mjs's RECOVERY-LADDER DISPOSITION header for the rationale):
41
+ // the failure these paths handle -- a wedged beads clone that stops the whole
42
+ // sprint -- is real and was previously sprint-fatal with no recovery attempt.
43
+ // =============================================================================
44
+
45
+ import { recoverDoltConflictPathA } from './dolt-recovery.mjs';
46
+ import { recoverDoltConflictPathB } from './dolt-recovery-path-b.mjs';
47
+
48
+ /** Repo-relative path to the Tier 2 runbook doc this module's escalation
49
+ * prompt references. Kept as a constant so the reference cannot drift
50
+ * silently from the actual doc location. */
51
+ export const DEFAULT_TIER2_RUNBOOK_PATH = 'packages/apra-fleet-se/fleet-sprint/docs/dolt-tier2-runbook.md';
52
+
53
+ /** Default embedded dolt data dir recorded in the wedged state when the
54
+ * caller does not supply a more specific `clonePath`. Mirrors
55
+ * dolt-recovery.mjs's DEFAULT_EMBEDDED_DATA_DIR. */
56
+ export const DEFAULT_CLONE_PATH = '.beads/embeddeddolt';
57
+
58
+ /**
59
+ * Records the wedged state a Tier 2 dispatch is armed with: exactly the
60
+ * three facts the runbook doc tells the dispatched agent to read first
61
+ * (clone path, conflict shape, last command output), plus which ladder
62
+ * stage produced it and when. Never partial -- every field is always
63
+ * present (`null`/`'(unknown)'` rather than omitted) so a human/agent
64
+ * reading it never has to guess whether a field was simply not collected.
65
+ *
66
+ * @param {{
67
+ * member: string,
68
+ * clonePath?: string,
69
+ * conflictShape?: object|null,
70
+ * lastOutput?: string|null,
71
+ * stage: string,
72
+ * now?: () => Date,
73
+ * }} opts
74
+ * @returns {{ member: string, clonePath: string, conflictShape: object|null, lastOutput: string, stage: string, recordedAt: string }}
75
+ */
76
+ export function recordWedgedState(opts = {}) {
77
+ const {
78
+ member,
79
+ clonePath = DEFAULT_CLONE_PATH,
80
+ conflictShape = null,
81
+ lastOutput = null,
82
+ stage,
83
+ now = () => new Date(),
84
+ } = opts;
85
+ if (!member) throw new Error('recordWedgedState requires a member in opts');
86
+ if (!stage) throw new Error('recordWedgedState requires a stage in opts');
87
+ return {
88
+ member,
89
+ clonePath,
90
+ conflictShape,
91
+ lastOutput: lastOutput == null ? '(no output captured)' : String(lastOutput),
92
+ stage,
93
+ recordedAt: now().toISOString(),
94
+ };
95
+ }
96
+
97
+ /**
98
+ * Builds the self-contained Tier 2 runbook prompt: the recorded wedged
99
+ * state in full, plus a reference to the full runbook doc the dispatched
100
+ * agent should follow step by step. ASCII-only per project convention.
101
+ *
102
+ * @param {{ member: string, wedgedState: object, runbookPath?: string }} opts
103
+ * @returns {string}
104
+ */
105
+ export function buildDoltTier2RunbookPrompt({ member, wedgedState, runbookPath = DEFAULT_TIER2_RUNBOOK_PATH }) {
106
+ const shapeText = wedgedState && wedgedState.conflictShape
107
+ ? JSON.stringify(wedgedState.conflictShape)
108
+ : '(no gate result available -- Path A did not reach the conflict gate)';
109
+ return [
110
+ 'DOLT CONFLICT RECOVERY RUNBOOK (Tier 2 of the dolt sync recovery ladder).',
111
+ '',
112
+ `The scripted recovery ladder (Path A resolve-in-place, Path B discard-and-` +
113
+ `re-bootstrap) could not close a wedged beads clone for member '${member}'. ` +
114
+ `Follow the full runbook at '${runbookPath}' EXACTLY, in order. Do not proceed ` +
115
+ 'past any output you do not recognize -- record what you observed and report it ' +
116
+ 'rather than guessing.',
117
+ '',
118
+ 'WEDGED STATE (recorded before this dispatch -- read this first):',
119
+ ` - member: ${wedgedState.member}`,
120
+ ` - clone path: ${wedgedState.clonePath}`,
121
+ ` - conflict shape (last Path A gate result): ${shapeText}`,
122
+ ` - last command output: ${wedgedState.lastOutput}`,
123
+ ` - ladder stage that escalated: ${wedgedState.stage}`,
124
+ ` - recorded at: ${wedgedState.recordedAt}`,
125
+ '',
126
+ `See '${runbookPath}' for the full step-by-step recovery procedure.`,
127
+ '',
128
+ 'Do not run any beads-content `bd` command unrelated to this recovery (no',
129
+ 'closing/reopening beads) -- this is a pure dolt-clone-recovery dispatch, not a',
130
+ 'development streak.',
131
+ ].join('\n');
132
+ }
133
+
134
+ /**
135
+ * Tier 2: dispatches an agent, armed with the runbook above, to resolve a
136
+ * wedged dolt clone neither Path A nor Path B could close. This function
137
+ * only DISPATCHES -- it deliberately does not itself decide whether the
138
+ * attempt succeeded; the caller re-verifies success mechanically afterwards
139
+ * (a clean `bd dolt status` and a genuinely successful `bd dolt push`),
140
+ * exactly like the git ladder's Tier 2 never trusts the agent's own claim.
141
+ *
142
+ * @param {{
143
+ * agent: Function, member: string, wedgedState: object,
144
+ * log?: Function, model?: string, runbookPath?: string,
145
+ * }} opts
146
+ * @returns {Promise<unknown>} whatever the injected agent() call resolves to
147
+ */
148
+ export async function dispatchDoltTier2Escalation({ agent, member, wedgedState, log = () => {}, model, runbookPath = DEFAULT_TIER2_RUNBOOK_PATH }) {
149
+ if (typeof agent !== 'function') {
150
+ throw new Error('dispatchDoltTier2Escalation requires an injected agent() in opts');
151
+ }
152
+ log(`[Dolt] Tier 2: dispatching a dolt conflict recovery runbook to member '${member}' -- ` +
153
+ `wedged state: stage='${wedgedState.stage}', clonePath='${wedgedState.clonePath}'.`);
154
+ const prompt = buildDoltTier2RunbookPrompt({ member, wedgedState, runbookPath });
155
+ return agent(prompt, {
156
+ member_name: member,
157
+ label: `Tier 2 dolt conflict recovery [${wedgedState.stage}]`,
158
+ model,
159
+ timeout_s: 1800,
160
+ max_total_s: 1800,
161
+ });
162
+ }
163
+
164
+ /**
165
+ * Records the wedged state for an escalation and, if an agent() was
166
+ * injected, dispatches Tier 2 with it. If no agent() was injected, the
167
+ * escalation is still recorded and logged (never silently dropped) but
168
+ * `dispatched` is false -- the caller (a test harness, or a scripted context
169
+ * with no agent available) can decide what to do with an un-dispatched
170
+ * escalation, but the wedged state itself is never lost.
171
+ *
172
+ * @param {{
173
+ * agent?: Function, member: string, clonePath?: string,
174
+ * conflictShape?: object|null, lastOutput?: string|null, stage: string,
175
+ * log?: Function, model?: string, runbookPath?: string,
176
+ * }} opts
177
+ * @returns {Promise<{ escalated: true, wedgedState: object, dispatched: boolean, dispatchResult?: unknown }>}
178
+ */
179
+ export async function escalateDoltConflict(opts = {}) {
180
+ const { agent, member, clonePath, conflictShape, lastOutput, stage, log = () => {}, model, runbookPath } = opts;
181
+ const wedgedState = recordWedgedState({ member, clonePath, conflictShape, lastOutput, stage });
182
+ log(`[Dolt] Tier 2 ESCALATION for member '${member}' at stage '${stage}': recording wedged state instead of proceeding blind -- ` +
183
+ `clonePath='${wedgedState.clonePath}', lastOutput='${wedgedState.lastOutput}'.`);
184
+
185
+ if (typeof agent !== 'function') {
186
+ log(`[Dolt] Tier 2 escalation for member '${member}' recorded but NOT dispatched -- no agent() was injected. ` +
187
+ `See ${runbookPath || DEFAULT_TIER2_RUNBOOK_PATH} for the runbook a real dispatch would receive.`);
188
+ return { escalated: true, wedgedState, dispatched: false };
189
+ }
190
+
191
+ const dispatchResult = await dispatchDoltTier2Escalation({ agent, member, wedgedState, log, model, runbookPath });
192
+ return { escalated: true, wedgedState, dispatched: true, dispatchResult };
193
+ }
194
+
195
+ /**
196
+ * The full recovery ladder: Path A (primary, resolve-in-place) -> Path B
197
+ * (fallback, discard-and-re-bootstrap) -> Tier 2 (agent escalation, this
198
+ * module). `pathA`/`pathB` are injected as zero-argument callbacks (the
199
+ * caller closes over whatever command()/sql()/spawnSqlServer/etc. options
200
+ * each path needs -- see dolt-recovery.mjs / dolt-recovery-path-b.mjs) so
201
+ * this orchestrator stays agnostic of their individual wiring and is simple
202
+ * to unit test with mock callbacks.
203
+ *
204
+ * Never proceeds blind past an unrecognized outcome: if Path A does not
205
+ * report `ok:true` (whether by a rejected gate or a thrown operational
206
+ * error), Path B is attempted; if Path B ALSO does not report `ok:true`
207
+ * (whether by a thrown operational error or an unrecognized scripted-step
208
+ * output), this function escalates to Tier 2 rather than returning as if
209
+ * recovery succeeded, or retrying either path again unbounded.
210
+ *
211
+ * @param {{
212
+ * member: string,
213
+ * pathA: () => Promise<{ ok: boolean, gate?: object, reason?: string }>,
214
+ * pathB: () => Promise<{ ok: boolean, reason?: string }>,
215
+ * agent?: Function,
216
+ * log?: Function,
217
+ * model?: string,
218
+ * clonePath?: string,
219
+ * runbookPath?: string,
220
+ * }} opts
221
+ * @returns {Promise<{ ok: boolean, tier: 'path-a'|'path-b'|'tier-2', result?: object, escalated?: boolean, escalation?: object }>}
222
+ */
223
+ export async function recoverDoltConflict(opts = {}) {
224
+ const { member, pathA, pathB, agent, log = () => {}, model, clonePath, runbookPath } = opts;
225
+ if (!member) throw new Error('recoverDoltConflict requires a member in opts');
226
+ if (typeof pathA !== 'function') throw new Error('recoverDoltConflict requires an injected pathA() in opts');
227
+ if (typeof pathB !== 'function') throw new Error('recoverDoltConflict requires an injected pathB() in opts');
228
+
229
+ let pathAResult = null;
230
+ let pathAError = null;
231
+ try {
232
+ pathAResult = await pathA();
233
+ } catch (err) {
234
+ pathAError = err;
235
+ }
236
+
237
+ if (pathAResult && pathAResult.ok) {
238
+ return { ok: true, tier: 'path-a', result: pathAResult };
239
+ }
240
+
241
+ const conflictShape = pathAResult && pathAResult.gate ? pathAResult.gate : null;
242
+ const pathAReason = pathAError ? pathAError.message : (pathAResult ? pathAResult.reason : 'Path A returned no result');
243
+ log(`[Dolt] Path A did not resolve the conflict for member '${member}' (${pathAReason}) -- falling back to Path B (discard-and-re-bootstrap).`);
244
+
245
+ let pathBResult = null;
246
+ let pathBError = null;
247
+ try {
248
+ pathBResult = await pathB();
249
+ } catch (err) {
250
+ pathBError = err;
251
+ }
252
+
253
+ if (pathBResult && pathBResult.ok) {
254
+ return { ok: true, tier: 'path-b', result: pathBResult, pathAReason };
255
+ }
256
+
257
+ // Both Path A and Path B failed to close the clone -- this is exactly
258
+ // the "gate failed or a scripted step returned unrecognized output"
259
+ // case this module exists for. Never proceed blind: record the wedged
260
+ // state and escalate to Tier 2.
261
+ const pathBReason = pathBError ? pathBError.message : (pathBResult ? pathBResult.reason : 'Path B returned no result');
262
+ const escalation = await escalateDoltConflict({
263
+ agent, member, clonePath, conflictShape, lastOutput: pathBReason,
264
+ stage: 'path-b-exhausted', log, model, runbookPath,
265
+ });
266
+
267
+ return { ok: false, tier: 'tier-2', escalated: true, escalation, pathAReason, pathBReason };
268
+ }
269
+
270
+ /**
271
+ * apra-fleet-vkc.1: build the Path A -> Path B -> Tier 2 recovery ladder as a
272
+ * single zero-argument async callback the diverged D-push terminal invokes.
273
+ * This is the ONE place the three recovery modules are composed together with
274
+ * their concrete dependencies, so doltPushAfter()/repair() (dolt-sync.mjs) and
275
+ * runner.js's post-dispatch sync bracket all wire recovery through the same
276
+ * audited seam rather than re-composing the paths at each call site.
277
+ *
278
+ * The returned callback resolves to recoverDoltConflict()'s outcome
279
+ * (`{ ok, tier, ... }`) and never throws for an ordinary recovery failure --
280
+ * recoverDoltConflict already catches each path's operational error and routes
281
+ * it onward (Path A error -> Path B -> Tier 2 escalation), so a caller can
282
+ * branch purely on `.ok`.
283
+ *
284
+ * DEPENDENCY POSTURE (deliberately unchanged from the individual paths):
285
+ * - Path A (resolve-in-place) requires an injected sql()/spawnSqlServer()
286
+ * runtime -- a live dolt sql-server client. When those are NOT supplied
287
+ * (the current runner.js posture, which has no such runtime), Path A's own
288
+ * guard throws "requires an injected sql()"; recoverDoltConflict catches
289
+ * that as a Path A operational failure and falls through to Path B. Path A
290
+ * is therefore genuinely REACHED and invoked (no silent dead module), and
291
+ * becomes able to resolve-in-place the moment a sql runtime is injected.
292
+ * - Path B (discard-and-re-bootstrap) needs only command() plus the fs-backed
293
+ * defaults it already ships (readConfig/removePath/listLocalState) to RUN
294
+ * -- but "runs" is not "runs correctly here". Those defaults are plain
295
+ * Node `fs` calls against whatever process invokes them; without injected
296
+ * member-scoped readConfig/removePath/listLocalState (routed through
297
+ * command()), Path B discards and re-bootstraps THE CALLING PROCESS's
298
+ * local `.beads/*`, not `member`'s. A caller composing this for a
299
+ * specific `member` (anything other than "repair my own local clone")
300
+ * MUST inject member-scoped fs functions, or set `enablePathB: false` to
301
+ * keep Path B out of the ladder entirely (falls straight to Tier 2 when
302
+ * Path A can't resolve). See runner.js's syncMemberAfterOrdered() call
303
+ * site (apra-fleet-vkc.1 post-review fix) for why it does the latter: it
304
+ * wraps an arbitrary, possibly-multi-command agent dispatch, so there is
305
+ * no single well-defined `pendingMutation` it could capture and replay --
306
+ * Path B firing there would silently discard whatever the dispatch just
307
+ * did on `member`, then report the D-push as recovered.
308
+ * - Tier 2 needs an injected agent() to dispatch; without one the wedged
309
+ * state is still recorded (never silently dropped) but not dispatched.
310
+ *
311
+ * @param {string} member
312
+ * @param {{
313
+ * command: Function,
314
+ * sql?: Function, spawnSqlServer?: Function, allocatePort?: Function,
315
+ * readMetadata?: Function, writeMetadata?: Function,
316
+ * dataDir?: string, remote?: string, branch?: string,
317
+ * allowlistTables?: string[], resolveStrategy?: '--theirs'|'--ours',
318
+ * enablePathB?: boolean,
319
+ * readConfig?: Function, removePath?: Function, listLocalState?: Function,
320
+ * configPath?: string, removePaths?: string[], embeddedDataDir?: string,
321
+ * pendingMutation?: { description: string, cmd: string } | null,
322
+ * agent?: Function, log?: Function, model?: string,
323
+ * clonePath?: string, runbookPath?: string,
324
+ * }} opts
325
+ * @returns {() => Promise<{ ok: boolean, tier: string, escalated?: boolean, result?: object, escalation?: object }>}
326
+ */
327
+ export function buildDoltRecoveryLadder(member, opts = {}) {
328
+ const {
329
+ command,
330
+ sql, spawnSqlServer, allocatePort, readMetadata, writeMetadata,
331
+ dataDir, remote, branch, allowlistTables, resolveStrategy,
332
+ enablePathB = true,
333
+ readConfig, removePath, listLocalState, configPath, removePaths, embeddedDataDir,
334
+ pendingMutation, agent, log = () => {}, model, clonePath, runbookPath,
335
+ } = opts;
336
+ if (!member) throw new Error('buildDoltRecoveryLadder requires a member');
337
+ if (typeof command !== 'function') {
338
+ throw new Error('buildDoltRecoveryLadder requires an injected command() in opts');
339
+ }
340
+ const pathB = enablePathB
341
+ ? () => recoverDoltConflictPathB({
342
+ member, command, readConfig, removePath, listLocalState,
343
+ configPath, removePaths, embeddedDataDir, pendingMutation, log,
344
+ })
345
+ : async () => {
346
+ log(`[Dolt] Path B for member '${member}': disabled at this call site (enablePathB:false) -- ` +
347
+ `discard-and-re-bootstrap needs a specific member-scoped pendingMutation to replay safely, ` +
348
+ `which this caller cannot provide. Falling through to Tier 2 without touching any local state.`);
349
+ return { ok: false, reason: 'Path B disabled for this call site (enablePathB:false)' };
350
+ };
351
+ return async () => recoverDoltConflict({
352
+ member,
353
+ pathA: () => recoverDoltConflictPathA({
354
+ member, command, sql, spawnSqlServer, allocatePort, readMetadata, writeMetadata,
355
+ dataDir, remote, branch, allowlistTables, resolveStrategy, log,
356
+ }),
357
+ pathB,
358
+ agent, log, model, clonePath, runbookPath,
359
+ });
360
+ }