@apralabs/apra-fleet 0.4.2 → 0.4.3

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 (370) hide show
  1. package/README.md +38 -5
  2. package/dist/agents/backlog-groomer.md +25 -0
  3. package/dist/agents/ci-watcher.md +11 -0
  4. package/dist/agents/deployer.md +37 -2
  5. package/dist/agents/doer.md +36 -12
  6. package/dist/agents/harvester.md +11 -0
  7. package/dist/agents/integ-test-runner.md +11 -0
  8. package/dist/agents/kb-reconciler.md +9 -0
  9. package/dist/agents/plan-reviewer.md +110 -22
  10. package/dist/agents/planner.md +125 -37
  11. package/dist/agents/regression-test-runner.md +11 -0
  12. package/dist/agents/reviewer.md +13 -2
  13. package/dist/agents/schemas/plan-reviewer-output.json +37 -0
  14. package/dist/cli/agent-transform.d.ts +83 -2
  15. package/dist/cli/agent-transform.d.ts.map +1 -1
  16. package/dist/cli/agent-transform.js +266 -21
  17. package/dist/cli/agent-transform.js.map +1 -1
  18. package/dist/cli/auth.d.ts.map +1 -1
  19. package/dist/cli/auth.js +28 -9
  20. package/dist/cli/auth.js.map +1 -1
  21. package/dist/cli/config.d.ts +7 -5
  22. package/dist/cli/config.d.ts.map +1 -1
  23. package/dist/cli/config.js +44 -34
  24. package/dist/cli/config.js.map +1 -1
  25. package/dist/cli/install.d.ts +33 -0
  26. package/dist/cli/install.d.ts.map +1 -1
  27. package/dist/cli/install.js +290 -23
  28. package/dist/cli/install.js.map +1 -1
  29. package/dist/cli/kb-directives.d.ts.map +1 -1
  30. package/dist/cli/kb-directives.js +2 -1
  31. package/dist/cli/kb-directives.js.map +1 -1
  32. package/dist/cli/register-member.d.ts.map +1 -1
  33. package/dist/cli/register-member.js +6 -2
  34. package/dist/cli/register-member.js.map +1 -1
  35. package/dist/commands/kb-server.d.ts +3 -0
  36. package/dist/commands/kb-server.d.ts.map +1 -1
  37. package/dist/commands/kb-server.js +43 -3
  38. package/dist/commands/kb-server.js.map +1 -1
  39. package/dist/index.js +3 -3
  40. package/dist/os/linux.d.ts +6 -0
  41. package/dist/os/linux.d.ts.map +1 -1
  42. package/dist/os/linux.js +35 -2
  43. package/dist/os/linux.js.map +1 -1
  44. package/dist/os/os-commands.d.ts +61 -2
  45. package/dist/os/os-commands.d.ts.map +1 -1
  46. package/dist/os/windows-gitbash.d.ts +5 -0
  47. package/dist/os/windows-gitbash.d.ts.map +1 -1
  48. package/dist/os/windows-gitbash.js +15 -0
  49. package/dist/os/windows-gitbash.js.map +1 -1
  50. package/dist/os/windows.d.ts +6 -0
  51. package/dist/os/windows.d.ts.map +1 -1
  52. package/dist/os/windows.js +46 -3
  53. package/dist/os/windows.js.map +1 -1
  54. package/dist/providers/agy.d.ts +115 -6
  55. package/dist/providers/agy.d.ts.map +1 -1
  56. package/dist/providers/agy.js +569 -53
  57. package/dist/providers/agy.js.map +1 -1
  58. package/dist/providers/claude.d.ts +81 -3
  59. package/dist/providers/claude.d.ts.map +1 -1
  60. package/dist/providers/claude.js +344 -10
  61. package/dist/providers/claude.js.map +1 -1
  62. package/dist/providers/codex.d.ts +4 -2
  63. package/dist/providers/codex.d.ts.map +1 -1
  64. package/dist/providers/codex.js +19 -2
  65. package/dist/providers/codex.js.map +1 -1
  66. package/dist/providers/copilot.d.ts +4 -2
  67. package/dist/providers/copilot.d.ts.map +1 -1
  68. package/dist/providers/copilot.js +20 -2
  69. package/dist/providers/copilot.js.map +1 -1
  70. package/dist/providers/none.d.ts +4 -2
  71. package/dist/providers/none.d.ts.map +1 -1
  72. package/dist/providers/none.js +17 -2
  73. package/dist/providers/none.js.map +1 -1
  74. package/dist/providers/opencode.d.ts +3 -1
  75. package/dist/providers/opencode.d.ts.map +1 -1
  76. package/dist/providers/opencode.js +22 -2
  77. package/dist/providers/opencode.js.map +1 -1
  78. package/dist/providers/provider.d.ts +201 -6
  79. package/dist/providers/provider.d.ts.map +1 -1
  80. package/dist/providers/provider.js +56 -0
  81. package/dist/providers/provider.js.map +1 -1
  82. package/dist/services/agy-project.d.ts +102 -0
  83. package/dist/services/agy-project.d.ts.map +1 -0
  84. package/dist/services/agy-project.js +356 -0
  85. package/dist/services/agy-project.js.map +1 -0
  86. package/dist/services/auth-socket.js +4 -4
  87. package/dist/services/auth-web.js +1 -1
  88. package/dist/services/cloud/lifecycle.d.ts.map +1 -1
  89. package/dist/services/cloud/lifecycle.js +33 -4
  90. package/dist/services/cloud/lifecycle.js.map +1 -1
  91. package/dist/services/credential-cleanup.d.ts.map +1 -1
  92. package/dist/services/credential-cleanup.js +35 -17
  93. package/dist/services/credential-cleanup.js.map +1 -1
  94. package/dist/services/exit-drain.d.ts +44 -0
  95. package/dist/services/exit-drain.d.ts.map +1 -0
  96. package/dist/services/exit-drain.js +52 -0
  97. package/dist/services/exit-drain.js.map +1 -0
  98. package/dist/services/github-app.d.ts.map +1 -1
  99. package/dist/services/github-app.js +32 -4
  100. package/dist/services/github-app.js.map +1 -1
  101. package/dist/services/http-transport.d.ts +1 -0
  102. package/dist/services/http-transport.d.ts.map +1 -1
  103. package/dist/services/http-transport.js +48 -1
  104. package/dist/services/http-transport.js.map +1 -1
  105. package/dist/services/knowledge/kb-config.d.ts +42 -0
  106. package/dist/services/knowledge/kb-config.d.ts.map +1 -0
  107. package/dist/services/knowledge/kb-config.js +54 -0
  108. package/dist/services/knowledge/kb-config.js.map +1 -0
  109. package/dist/services/knowledge/kb-providers.d.ts +7 -1
  110. package/dist/services/knowledge/kb-providers.d.ts.map +1 -1
  111. package/dist/services/knowledge/kb-providers.js +191 -17
  112. package/dist/services/knowledge/kb-providers.js.map +1 -1
  113. package/dist/services/knowledge/require-sqlite-project.d.ts +32 -0
  114. package/dist/services/knowledge/require-sqlite-project.d.ts.map +1 -0
  115. package/dist/services/knowledge/require-sqlite-project.js +38 -0
  116. package/dist/services/knowledge/require-sqlite-project.js.map +1 -0
  117. package/dist/services/model-pricing.d.ts.map +1 -1
  118. package/dist/services/model-pricing.js +7 -3
  119. package/dist/services/model-pricing.js.map +1 -1
  120. package/dist/services/secret-token.d.ts +38 -0
  121. package/dist/services/secret-token.d.ts.map +1 -0
  122. package/dist/services/secret-token.js +51 -0
  123. package/dist/services/secret-token.js.map +1 -0
  124. package/dist/services/service-manager/types.d.ts +3 -1
  125. package/dist/services/service-manager/types.d.ts.map +1 -1
  126. package/dist/services/service-manager/windows.d.ts +14 -2
  127. package/dist/services/service-manager/windows.d.ts.map +1 -1
  128. package/dist/services/service-manager/windows.js +65 -7
  129. package/dist/services/service-manager/windows.js.map +1 -1
  130. package/dist/services/ssh.d.ts.map +1 -1
  131. package/dist/services/ssh.js +58 -2
  132. package/dist/services/ssh.js.map +1 -1
  133. package/dist/services/stall/read-log-tail.d.ts.map +1 -1
  134. package/dist/services/stall/read-log-tail.js +20 -10
  135. package/dist/services/stall/read-log-tail.js.map +1 -1
  136. package/dist/services/stall/stall-detector.d.ts +53 -4
  137. package/dist/services/stall/stall-detector.d.ts.map +1 -1
  138. package/dist/services/stall/stall-detector.js +212 -34
  139. package/dist/services/stall/stall-detector.js.map +1 -1
  140. package/dist/services/strategy.d.ts.map +1 -1
  141. package/dist/services/strategy.js +79 -2
  142. package/dist/services/strategy.js.map +1 -1
  143. package/dist/services/substitution-engine.js +2 -2
  144. package/dist/services/substitution-engine.js.map +1 -1
  145. package/dist/services/tool-registry.d.ts.map +1 -1
  146. package/dist/services/tool-registry.js +5 -3
  147. package/dist/services/tool-registry.js.map +1 -1
  148. package/dist/services/vcs/azure-devops.d.ts +66 -1
  149. package/dist/services/vcs/azure-devops.d.ts.map +1 -1
  150. package/dist/services/vcs/azure-devops.js +192 -21
  151. package/dist/services/vcs/azure-devops.js.map +1 -1
  152. package/dist/services/vcs/types.d.ts +1 -1
  153. package/dist/skills/fleet-sprint-cli/SKILL.md +18 -0
  154. package/dist/skills/pm/SKILL.md +1 -1
  155. package/dist/skills/pm/cost.md +0 -3
  156. package/dist/skills/pm/fleet-addendum.md +2 -2
  157. package/dist/tools/check-status.d.ts +7 -4
  158. package/dist/tools/check-status.d.ts.map +1 -1
  159. package/dist/tools/check-status.js +2 -0
  160. package/dist/tools/check-status.js.map +1 -1
  161. package/dist/tools/compose-permissions.d.ts +6 -0
  162. package/dist/tools/compose-permissions.d.ts.map +1 -1
  163. package/dist/tools/compose-permissions.js +182 -34
  164. package/dist/tools/compose-permissions.js.map +1 -1
  165. package/dist/tools/credential-store-set.js +1 -1
  166. package/dist/tools/execute-command.d.ts.map +1 -1
  167. package/dist/tools/execute-command.js +31 -20
  168. package/dist/tools/execute-command.js.map +1 -1
  169. package/dist/tools/execute-prompt.d.ts +15 -2
  170. package/dist/tools/execute-prompt.d.ts.map +1 -1
  171. package/dist/tools/execute-prompt.js +1196 -892
  172. package/dist/tools/execute-prompt.js.map +1 -1
  173. package/dist/tools/kb-capture.d.ts +2 -2
  174. package/dist/tools/kb-capture.d.ts.map +1 -1
  175. package/dist/tools/kb-capture.js +29 -5
  176. package/dist/tools/kb-capture.js.map +1 -1
  177. package/dist/tools/kb-export.d.ts +2 -2
  178. package/dist/tools/kb-export.d.ts.map +1 -1
  179. package/dist/tools/kb-export.js +3 -28
  180. package/dist/tools/kb-export.js.map +1 -1
  181. package/dist/tools/kb-feedback.d.ts.map +1 -1
  182. package/dist/tools/kb-feedback.js +3 -1
  183. package/dist/tools/kb-feedback.js.map +1 -1
  184. package/dist/tools/kb-freshness-sweep.d.ts.map +1 -1
  185. package/dist/tools/kb-freshness-sweep.js +3 -1
  186. package/dist/tools/kb-freshness-sweep.js.map +1 -1
  187. package/dist/tools/kb-import.d.ts.map +1 -1
  188. package/dist/tools/kb-import.js +2 -1
  189. package/dist/tools/kb-import.js.map +1 -1
  190. package/dist/tools/kb-list.d.ts.map +1 -1
  191. package/dist/tools/kb-list.js +3 -1
  192. package/dist/tools/kb-list.js.map +1 -1
  193. package/dist/tools/kb-query.d.ts +2 -2
  194. package/dist/tools/kb-reconcile-prefilter.d.ts.map +1 -1
  195. package/dist/tools/kb-reconcile-prefilter.js +3 -1
  196. package/dist/tools/kb-reconcile-prefilter.js.map +1 -1
  197. package/dist/tools/kb-resolve-contradiction.d.ts.map +1 -1
  198. package/dist/tools/kb-resolve-contradiction.js +3 -1
  199. package/dist/tools/kb-resolve-contradiction.js.map +1 -1
  200. package/dist/tools/kb-setup.d.ts.map +1 -1
  201. package/dist/tools/kb-setup.js +125 -20
  202. package/dist/tools/kb-setup.js.map +1 -1
  203. package/dist/tools/kb-stats.d.ts.map +1 -1
  204. package/dist/tools/kb-stats.js +64 -43
  205. package/dist/tools/kb-stats.js.map +1 -1
  206. package/dist/tools/list-members.d.ts +2 -2
  207. package/dist/tools/list-members.d.ts.map +1 -1
  208. package/dist/tools/list-members.js +1 -0
  209. package/dist/tools/list-members.js.map +1 -1
  210. package/dist/tools/member-detail.d.ts +2 -2
  211. package/dist/tools/member-detail.d.ts.map +1 -1
  212. package/dist/tools/member-detail.js +17 -0
  213. package/dist/tools/member-detail.js.map +1 -1
  214. package/dist/tools/member-reservation.d.ts +58 -1
  215. package/dist/tools/member-reservation.d.ts.map +1 -1
  216. package/dist/tools/member-reservation.js +61 -20
  217. package/dist/tools/member-reservation.js.map +1 -1
  218. package/dist/tools/provision-auth.d.ts +80 -1
  219. package/dist/tools/provision-auth.d.ts.map +1 -1
  220. package/dist/tools/provision-auth.js +142 -54
  221. package/dist/tools/provision-auth.js.map +1 -1
  222. package/dist/tools/provision-vcs-auth.d.ts +91 -1
  223. package/dist/tools/provision-vcs-auth.d.ts.map +1 -1
  224. package/dist/tools/provision-vcs-auth.js +209 -49
  225. package/dist/tools/provision-vcs-auth.js.map +1 -1
  226. package/dist/tools/register-member.d.ts +12 -9
  227. package/dist/tools/register-member.d.ts.map +1 -1
  228. package/dist/tools/register-member.js +99 -12
  229. package/dist/tools/register-member.js.map +1 -1
  230. package/dist/tools/remove-member.d.ts.map +1 -1
  231. package/dist/tools/remove-member.js +27 -2
  232. package/dist/tools/remove-member.js.map +1 -1
  233. package/dist/tools/send-email.d.ts +2 -2
  234. package/dist/tools/setup-git-app.d.ts.map +1 -1
  235. package/dist/tools/setup-git-app.js +11 -7
  236. package/dist/tools/setup-git-app.js.map +1 -1
  237. package/dist/tools/shutdown-server.d.ts +2 -0
  238. package/dist/tools/shutdown-server.d.ts.map +1 -1
  239. package/dist/tools/shutdown-server.js +23 -1
  240. package/dist/tools/shutdown-server.js.map +1 -1
  241. package/dist/tools/update-member.d.ts +12 -9
  242. package/dist/tools/update-member.d.ts.map +1 -1
  243. package/dist/tools/update-member.js +43 -11
  244. package/dist/tools/update-member.js.map +1 -1
  245. package/dist/tools/vcs-credential-exec.d.ts +127 -0
  246. package/dist/tools/vcs-credential-exec.d.ts.map +1 -0
  247. package/dist/tools/vcs-credential-exec.js +197 -0
  248. package/dist/tools/vcs-credential-exec.js.map +1 -0
  249. package/dist/types.d.ts +13 -0
  250. package/dist/types.d.ts.map +1 -1
  251. package/dist/utils/log-helpers.d.ts.map +1 -1
  252. package/dist/utils/log-helpers.js +2 -2
  253. package/dist/utils/log-helpers.js.map +1 -1
  254. package/dist/utils/prompt-errors.d.ts.map +1 -1
  255. package/dist/utils/prompt-errors.js +7 -1
  256. package/dist/utils/prompt-errors.js.map +1 -1
  257. package/dist/utils/shell-escape.d.ts +16 -0
  258. package/dist/utils/shell-escape.d.ts.map +1 -1
  259. package/dist/utils/shell-escape.js +22 -2
  260. package/dist/utils/shell-escape.js.map +1 -1
  261. package/dist/utils/vcs-provider-detect.d.ts +65 -0
  262. package/dist/utils/vcs-provider-detect.d.ts.map +1 -0
  263. package/dist/utils/vcs-provider-detect.js +109 -0
  264. package/dist/utils/vcs-provider-detect.js.map +1 -0
  265. package/dist/utils/workspace-trust.d.ts +20 -17
  266. package/dist/utils/workspace-trust.d.ts.map +1 -1
  267. package/dist/utils/workspace-trust.js +87 -1
  268. package/dist/utils/workspace-trust.js.map +1 -1
  269. package/dist/workflows/auto-sprint.js +176 -15
  270. package/package.json +6 -4
  271. package/packages/apra-fleet-client/src/client/api.mjs +319 -17
  272. package/packages/apra-fleet-client/src/client/errors.mjs +6 -2
  273. package/packages/apra-fleet-se/apra-pm/agents/_shared/GRAPH-SEMANTICS.md +10 -2
  274. package/packages/apra-fleet-se/apra-pm/agents/backlog-groomer.md +25 -0
  275. package/packages/apra-fleet-se/apra-pm/agents/ci-watcher.md +11 -0
  276. package/packages/apra-fleet-se/apra-pm/agents/deployer.md +37 -2
  277. package/packages/apra-fleet-se/apra-pm/agents/doer.md +36 -12
  278. package/packages/apra-fleet-se/apra-pm/agents/harvester.md +11 -0
  279. package/packages/apra-fleet-se/apra-pm/agents/integ-test-runner.md +11 -0
  280. package/packages/apra-fleet-se/apra-pm/agents/kb-reconciler.md +9 -0
  281. package/packages/apra-fleet-se/apra-pm/agents/plan-reviewer.md +110 -22
  282. package/packages/apra-fleet-se/apra-pm/agents/planner.md +125 -37
  283. package/packages/apra-fleet-se/apra-pm/agents/regression-test-runner.md +11 -0
  284. package/packages/apra-fleet-se/apra-pm/agents/reviewer.md +13 -2
  285. package/packages/apra-fleet-se/apra-pm/agents/schemas/plan-reviewer-output.json +37 -0
  286. package/packages/apra-fleet-se/apra-pm/skills/pm/SKILL.md +1 -1
  287. package/packages/apra-fleet-se/apra-pm/skills/pm/cost.md +0 -3
  288. package/packages/apra-fleet-se/apra-pm/skills/pm/fleet-addendum.md +2 -2
  289. package/packages/apra-fleet-se/bin/cli.mjs +149 -1
  290. package/packages/apra-fleet-se/bin/serve.mjs +78 -4
  291. package/packages/apra-fleet-se/fleet-sprint/abort.mjs +481 -0
  292. package/packages/apra-fleet-se/fleet-sprint/beads-children.mjs +491 -0
  293. package/packages/apra-fleet-se/fleet-sprint/beads-identity-check.mjs +282 -0
  294. package/packages/apra-fleet-se/fleet-sprint/beads-identity.mjs +208 -0
  295. package/packages/apra-fleet-se/fleet-sprint/beads-scope.mjs +638 -0
  296. package/packages/apra-fleet-se/fleet-sprint/beads-transitions.mjs +301 -0
  297. package/packages/apra-fleet-se/fleet-sprint/branch-ensure.mjs +96 -0
  298. package/packages/apra-fleet-se/fleet-sprint/conflict-ladder.mjs +8 -0
  299. package/packages/apra-fleet-se/fleet-sprint/contracts.mjs +61 -14
  300. package/packages/apra-fleet-se/fleet-sprint/coordination.mjs +516 -0
  301. package/packages/apra-fleet-se/fleet-sprint/dispatch-failure.mjs +184 -0
  302. package/packages/apra-fleet-se/fleet-sprint/dispatch-role.mjs +1121 -0
  303. package/packages/apra-fleet-se/fleet-sprint/dispatch-safety-guard.mjs +216 -4
  304. package/packages/apra-fleet-se/fleet-sprint/docs/README.md +1 -1
  305. package/packages/apra-fleet-se/fleet-sprint/docs/dolt-sync-redesign.md +276 -0
  306. package/packages/apra-fleet-se/fleet-sprint/docs/escalate-to-llm-design.md +1 -1
  307. package/packages/apra-fleet-se/fleet-sprint/docs/run-sprint-cycle-prelude-decision.md +215 -0
  308. package/packages/apra-fleet-se/fleet-sprint/dolt-literal-guard.mjs +56 -1
  309. package/packages/apra-fleet-se/fleet-sprint/dolt-sync.mjs +996 -32
  310. package/packages/apra-fleet-se/fleet-sprint/errors.mjs +267 -0
  311. package/packages/apra-fleet-se/fleet-sprint/explicit-id-create-guard.mjs +501 -0
  312. package/packages/apra-fleet-se/fleet-sprint/fatal-diagnostics.mjs +134 -0
  313. package/packages/apra-fleet-se/fleet-sprint/full-db-fetch-guard.mjs +102 -0
  314. package/packages/apra-fleet-se/fleet-sprint/git-sync.mjs +556 -0
  315. package/packages/apra-fleet-se/fleet-sprint/git-topology.mjs +495 -0
  316. package/packages/apra-fleet-se/fleet-sprint/guarded-modules.mjs +564 -0
  317. package/packages/apra-fleet-se/fleet-sprint/inline-ladder-guard.mjs +216 -0
  318. package/packages/apra-fleet-se/fleet-sprint/kb.mjs +728 -0
  319. package/packages/apra-fleet-se/fleet-sprint/mcp-result.mjs +75 -0
  320. package/packages/apra-fleet-se/fleet-sprint/member-provisioning.mjs +252 -0
  321. package/packages/apra-fleet-se/fleet-sprint/member-sync.mjs +581 -0
  322. package/packages/apra-fleet-se/fleet-sprint/member-target.mjs +93 -0
  323. package/packages/apra-fleet-se/fleet-sprint/newtask-text.mjs +266 -0
  324. package/packages/apra-fleet-se/fleet-sprint/parent-notes-staleness.mjs +201 -0
  325. package/packages/apra-fleet-se/fleet-sprint/phases/deploy.mjs +136 -0
  326. package/packages/apra-fleet-se/fleet-sprint/phases/develop.mjs +822 -0
  327. package/packages/apra-fleet-se/fleet-sprint/phases/ensure-sprint-branch.mjs +294 -0
  328. package/packages/apra-fleet-se/fleet-sprint/phases/final-review.mjs +403 -0
  329. package/packages/apra-fleet-se/fleet-sprint/phases/harvest.mjs +180 -0
  330. package/packages/apra-fleet-se/fleet-sprint/phases/integ-test.mjs +358 -0
  331. package/packages/apra-fleet-se/fleet-sprint/phases/plan.mjs +390 -0
  332. package/packages/apra-fleet-se/fleet-sprint/phases/publish-pr.mjs +323 -0
  333. package/packages/apra-fleet-se/fleet-sprint/phases/re-review.mjs +232 -0
  334. package/packages/apra-fleet-se/fleet-sprint/phases/regression-test.mjs +174 -0
  335. package/packages/apra-fleet-se/fleet-sprint/phases/replan.mjs +197 -0
  336. package/packages/apra-fleet-se/fleet-sprint/phases/review.mjs +305 -0
  337. package/packages/apra-fleet-se/fleet-sprint/prompts.mjs +559 -0
  338. package/packages/apra-fleet-se/fleet-sprint/role-policies.mjs +1416 -0
  339. package/packages/apra-fleet-se/fleet-sprint/round-session.mjs +100 -0
  340. package/packages/apra-fleet-se/fleet-sprint/runner.js +1467 -9798
  341. package/packages/apra-fleet-se/fleet-sprint/se-posix.mjs +17 -12
  342. package/packages/apra-fleet-se/fleet-sprint/shell-command-guard.mjs +304 -0
  343. package/packages/apra-fleet-se/fleet-sprint/skills/fleet-sprint-cli/SKILL.md +18 -0
  344. package/packages/apra-fleet-se/fleet-sprint/skills/fleet-supervisor/SKILL.md +21 -2
  345. package/packages/apra-fleet-se/fleet-sprint/sprint-args.mjs +454 -0
  346. package/packages/apra-fleet-se/fleet-sprint/sprint-report.mjs +239 -0
  347. package/packages/apra-fleet-se/fleet-sprint/sprint-state.mjs +163 -0
  348. package/packages/apra-fleet-se/fleet-sprint/unbracketed-push-guard.mjs +234 -0
  349. package/packages/apra-fleet-se/fleet-sprint/usage-limit-controller.mjs +211 -0
  350. package/packages/apra-fleet-se/fleet-sprint/vcs-auth.mjs +1279 -0
  351. package/packages/apra-fleet-se/fleet-sprint/vcs-module.mjs +153 -19
  352. package/packages/apra-fleet-se/fleet-sprint/vcs-providers/azure-devops.mjs +71 -21
  353. package/packages/apra-fleet-se/fleet-sprint/vcs-providers/bitbucket.mjs +28 -0
  354. package/packages/apra-fleet-se/fleet-sprint/vcs-providers/github.mjs +131 -0
  355. package/packages/apra-fleet-se/fleet-sprint/vcs-providers/index.mjs +140 -16
  356. package/packages/apra-fleet-se/fleet-sprint/vcs-providers/shell-helpers.mjs +1 -0
  357. package/packages/apra-fleet-se/fleet-sprint/viewer-extensions.mjs +77 -2
  358. package/packages/apra-fleet-se/fleet-sprint/worklists.mjs +559 -0
  359. package/packages/apra-fleet-se/package.json +1 -1
  360. package/packages/apra-fleet-workflow/src/viewer/index.mjs +17 -6
  361. package/packages/apra-fleet-workflow/src/workflow/index.mjs +49 -7
  362. package/skills/fleet/SKILL.md +8 -8
  363. package/skills/fleet/auth-azdevops.md +14 -3
  364. package/skills/fleet/auth-bitbucket.md +2 -2
  365. package/skills/fleet/auth-github.md +5 -4
  366. package/skills/fleet/onboarding.md +3 -3
  367. package/skills/fleet/permissions.md +5 -1
  368. package/skills/fleet/profiles/node.json +1 -1
  369. package/skills/fleet/troubleshooting.md +3 -3
  370. package/version.json +1 -1
@@ -1,4 +1,4 @@
1
- import { joinForOS, resolveHomeDir } from './provider.js';
1
+ import { joinForOS, resolveHomeDir, defaultUsageLimitSignal } from './provider.js';
2
2
  import { classifyPromptError } from '../utils/prompt-errors.js';
3
3
  import { escapeDoubleQuoted } from '../os/os-commands.js';
4
4
  import { wrapPowerShellEncoded } from '../os/windows.js';
@@ -9,15 +9,47 @@ import { transformAgentForAgy } from '../cli/agent-transform.js';
9
9
  import fs from 'node:fs';
10
10
  import path from 'node:path';
11
11
  import os from 'node:os';
12
- const AGY_MODEL_FOR_TIER = {
13
- cheap: 'Gemini 3.5 Flash (Medium)',
14
- standard: 'Gemini 3.1 Pro (Low)',
15
- premium: 'Claude Opus 4.6 (Thinking)',
12
+ /**
13
+ * SINGLE source of truth for AGY's tier -> model mapping, keyed by the STABLE
14
+ * slug ids `agy models` prints in its first column (verified accepted by
15
+ * `agy --model <slug>` on 1.2.8).
16
+ *
17
+ * This used to be two maps that drifted: display names ("Gemini 3.5 Flash
18
+ * (Medium)") for dispatch and slugs ("gemini-3.5-flash-lite") for
19
+ * modelTiers()/modelForTier(). Both catalogs went stale, and because the doer
20
+ * runs on the CHEAP tier, EVERY doer dispatch in an agy sprint came back as
21
+ * invalid model selection (--model "Gemini 3.5 Flash (Medium)"): model ...
22
+ * is not recognized as a known model or custom model in settings
23
+ * -- which the engine then reported as unparseable structured output, three
24
+ * rounds in a row, with no code ever written. Slugs are preferred over display
25
+ * names precisely because they are the stable identifier, and keeping ONE map
26
+ * removes the drift that caused this.
27
+ */
28
+ export const AGY_MODEL_FOR_TIER = {
29
+ cheap: 'gemini-3.8-flash-low',
30
+ standard: 'gemini-3.8-flash-high',
31
+ premium: 'gemini-3.1-pro-high',
16
32
  };
17
33
  // Paths to the fleet-installed agy helper scripts on the member machine.
18
34
  // Unix (bash): uses $HOME; Windows (PowerShell): uses $env:USERPROFILE.
19
35
  const SCRIPTS_UNIX = '$HOME/.apra-fleet/scripts';
20
36
  const SCRIPTS_WIN = '$env:USERPROFILE\\.apra-fleet\\scripts';
37
+ /**
38
+ * Wrap a JavaScript snippet for remote node execution across member operating systems.
39
+ * On Windows, wraps as PowerShell here-string encoded in base64 (-EncodedCommand)
40
+ * targeting `node --input-type=commonjs -` so that no outer shell (PowerShell,
41
+ * cmd.exe, or MSYS2/Git Bash) can re-parse or unescape backslashes, quotes, or
42
+ * regexes in the script.
43
+ * On POSIX (Linux/macOS), delivers via verbatim heredoc to `node --input-type=commonjs -`.
44
+ * Passing `--input-type=commonjs` explicitly prevents Node 22+ from treating stdin as TypeScript.
45
+ */
46
+ export function buildAgyNodeCommand(jsCode, agentOs = 'linux', eofMarker = 'FLEET_NODE_EOF') {
47
+ if (agentOs === 'windows') {
48
+ const psScript = `$code = @'\n${jsCode}\n'@\n$code | node --input-type=commonjs -`;
49
+ return wrapPowerShellEncoded(psScript);
50
+ }
51
+ return `cat << '${eofMarker}' | node --input-type=commonjs -\n${jsCode}\n${eofMarker}`;
52
+ }
21
53
  export class AgyProvider {
22
54
  name = 'agy';
23
55
  processName = 'agy';
@@ -56,7 +88,7 @@ export class AgyProvider {
56
88
  return 'standard';
57
89
  }
58
90
  buildPromptCommand(opts) {
59
- const { folder, promptFile, sessionId, resuming, unattended, inv, model, tier: inputTier, agentName } = opts;
91
+ const { folder, promptFile, sessionId, resuming, unattended, inv, model, tier: inputTier, agentName, projectId } = opts;
60
92
  const escapedFolder = escapeDoubleQuoted(folder);
61
93
  const normalizedFolder = folder.replace(/\\/g, '/');
62
94
  const fullPromptPath = path.posix.join(normalizedFolder, promptFile);
@@ -67,7 +99,15 @@ export class AgyProvider {
67
99
  // Write per-workspace model override before launching agy.
68
100
  const tier = inputTier ?? this.resolveTierFromModel(model);
69
101
  const displayModel = getModelOverride('agy', tier) ?? AGY_MODEL_FOR_TIER[tier];
70
- let cmd = `cd "${escapedFolder}" && agy --model "${escapeDoubleQuoted(displayModel)}" --output-format json`;
102
+ // --add-dir is REQUIRED, not cosmetic: AGY does not adopt the process's
103
+ // working directory as its workspace. A bare `cd <folder> && agy -p ...`
104
+ // starts with NO active workspace, so the model cannot see the repo at all
105
+ // and falls back to shelling out from ~/.gemini/antigravity-cli/scratch --
106
+ // which then trips the headless permission wall on the first run_command.
107
+ // (Live-verified on agy 1.2.8: the same prompt fails without --add-dir and
108
+ // succeeds with it.) The `cd` is kept so relative paths a dispatched agent
109
+ // builds itself still resolve.
110
+ let cmd = `cd "${escapedFolder}" && agy ${this.workspaceDirFlag(escapedFolder)} ${this.projectFlag(projectId)} --model "${escapeDoubleQuoted(displayModel)}" --output-format json`;
71
111
  if (agentName) {
72
112
  cmd += ` --agent "${escapeDoubleQuoted(agentName)}"`;
73
113
  }
@@ -83,8 +123,10 @@ export class AgyProvider {
83
123
  const permFlag = this.resolvePermissionFlag(unattended);
84
124
  if (permFlag)
85
125
  cmd += ` ${permFlag}`;
86
- // After agy exits, read its transcript from disk (primary output channel --
87
- // agy writes its response to CONOUT$, not stdout, so file I/O is required).
126
+ // After agy exits, also print its transcript from disk. The JSON result
127
+ // usually arrives on stdout (observed under gitbash on Windows too), but
128
+ // agy can write to CONOUT$ instead, and the transcript is also where a
129
+ // permission denial names its concrete target (detectAgyPermissionDenial).
88
130
  const transcriptScript = `${SCRIPTS_UNIX}/agy-transcript-reader.js`;
89
131
  const convArg = sessionId ? `"${escapeDoubleQuoted(sessionId)}"` : '""';
90
132
  const folderArg = `"${escapeDoubleQuoted(folder)}"`;
@@ -94,6 +136,21 @@ export class AgyProvider {
94
136
  skipPermissionsFlag() {
95
137
  return '--dangerously-skip-permissions';
96
138
  }
139
+ /** `--project <id>` binds the run to the member's own agy project, whose
140
+ * permissionGrants compose_permissions writes. Without it agy runs under the
141
+ * machine-wide default-cli-project (docs/agy-provider.md
142
+ * section 1), so a missing id is a hard error, never an omitted flag. */
143
+ projectFlag(projectId) {
144
+ if (!projectId || !/^[A-Za-z0-9][A-Za-z0-9-]*$/.test(projectId)) {
145
+ throw new Error('agy: refusing to dispatch without a valid agy project id (--project); run compose_permissions to provision one');
146
+ }
147
+ return `--project "${projectId}"`;
148
+ }
149
+ /** AGY's workspace is set by --add-dir, never inherited from the process cwd.
150
+ * See the comment in buildPromptCommand for why this is load-bearing. */
151
+ workspaceDirFlag(escapedFolder) {
152
+ return `--add-dir "${escapedFolder}"`;
153
+ }
97
154
  permissionModeAutoFlag() {
98
155
  return '--mode accept-edits';
99
156
  }
@@ -118,7 +175,18 @@ export class AgyProvider {
118
175
  // default (false/undefined) and 'auto' both resolve to the same baseline.
119
176
  return this.workspaceEditPermissionFlag() ?? '';
120
177
  }
121
- parseResponse(result) {
178
+ /** Parses the run's result and, when agy refused a tool call for lack of a
179
+ * grant, attaches the denial (see detectAgyPermissionDenial). A headless
180
+ * denial exits 0 with status SUCCESS and an empty response, so without this
181
+ * it is indistinguishable from a blank reply. */
182
+ parseResponse(result, ctx) {
183
+ const parsed = this.parseResult(result);
184
+ const denial = detectAgyPermissionDenial(result, ctx?.agentOs);
185
+ if (denial)
186
+ parsed.permissionDenial = denial;
187
+ return parsed;
188
+ }
189
+ parseResult(result) {
122
190
  const raw = result.stdout;
123
191
  let extractedSessionId;
124
192
  const sessionMatch = raw.match(/FLEET_SESSION_ID:([^\r\n]+)/);
@@ -234,6 +302,11 @@ export class AgyProvider {
234
302
  usage: undefined,
235
303
  };
236
304
  }
305
+ // apra-fleet-hzeb.1: AGY has no distinct usage-limit event surface, so key off
306
+ // the raw output using the shared quota detector (guessed resume window).
307
+ detectUsageLimit(result, parsed) {
308
+ return defaultUsageLimitSignal(result.stderr || result.stdout || parsed.result);
309
+ }
237
310
  supportsResume() {
238
311
  return true;
239
312
  }
@@ -243,6 +316,14 @@ export class AgyProvider {
243
316
  sessionIdStrategy() {
244
317
  return { type: 'provider-minted' };
245
318
  }
319
+ // apra-fleet-25yl.2.1: like Claude, an AGY dispatch is batch/CONOUT$-only --
320
+ // the exec channel carries no mid-turn signal, so a `timeout_s`-sized
321
+ // rolling deadline there is a false kill. AGY's working mechanism is the
322
+ // StallDetector watching its brain/transcript directory (resolveSessionLogDir
323
+ // below returns a real path), which still gets `timeout_s` as thresholdMs.
324
+ execTimeoutSource() {
325
+ return 'total_ceiling';
326
+ }
246
327
  resolveSessionLogPath(sessionId, _workFolder, homeDir, targetOs) {
247
328
  const home = resolveHomeDir(homeDir);
248
329
  if (!home)
@@ -264,18 +345,10 @@ export class AgyProvider {
264
345
  return `--conversation "${escapeDoubleQuoted(sessionId)}"`;
265
346
  }
266
347
  modelTiers() {
267
- return {
268
- cheap: 'gemini-3.5-flash-lite',
269
- standard: 'gemini-3.5-flash',
270
- premium: 'claude-sonnet-4.6',
271
- };
348
+ return { ...AGY_MODEL_FOR_TIER };
272
349
  }
273
350
  modelForTier(tier) {
274
- if (tier === 'cheap')
275
- return 'gemini-3.5-flash-lite';
276
- if (tier === 'premium')
277
- return 'claude-sonnet-4.6';
278
- return 'gemini-3.5-flash';
351
+ return AGY_MODEL_FOR_TIER[tier];
279
352
  }
280
353
  modelFlag(model) {
281
354
  return '';
@@ -293,12 +366,43 @@ export class AgyProvider {
293
366
  classifyError(output) {
294
367
  return classifyPromptError(output);
295
368
  }
296
- permissionConfigPaths() {
297
- return ['.gemini/antigravity-cli/settings.json'];
298
- }
299
- composePermissionConfig(_role, allow = []) {
300
- const agyAllow = convertClaudeAllowToAgyPermissions(allow);
301
- return [{ permissions: { allow: agyAllow }, mcpServers: { 'apra-fleet': { disabled: true } }, skillOverrides: { pm: 'off', fleet: 'off' } }];
369
+ /** The member's own agy project file, named by the id `agy --new-project`
370
+ * created for it (Agent.agyProjectId). ensureAgyProject must have run first;
371
+ * a member without an id has no file fleet may write. */
372
+ permissionConfigPaths(agent) {
373
+ const id = agent?.agyProjectId;
374
+ if (!id) {
375
+ throw new Error('agy: member has no agy project id -- provision it (ensureAgyProject) before composing permissions');
376
+ }
377
+ return [`~/.gemini/config/projects/${id}.json`];
378
+ }
379
+ /** Only `permissionGrants.permissionGrants.{allow,deny}` -- deliverConfigFile
380
+ * deep-merges this into the file agy created, so the id, name and
381
+ * projectResources agy wrote are kept as they are. */
382
+ composePermissionConfig(_role, allow = [], agent, opts = {}) {
383
+ this.permissionConfigPaths(agent);
384
+ const agyAllow = formatAgyPermissionRules(convertClaudeAllowToAgyPermissions(allow, {
385
+ os: agent?.os,
386
+ homeDir: opts.memberHomeDir,
387
+ warnings: opts.warnings,
388
+ }));
389
+ return [{
390
+ permissionGrants: {
391
+ permissionGrants: {
392
+ allow: agyAllow,
393
+ deny: AGY_ORCHESTRATOR_DENY_RULES,
394
+ },
395
+ },
396
+ }];
397
+ }
398
+ async preparePermissionsDelivery(_agent, execCommand, memberHomeDir, agentOs = 'linux', shell) {
399
+ const warnings = [];
400
+ const skillsResult = await checkAgyMemberSkills(execCommand, memberHomeDir, agentOs, shell);
401
+ if (skillsResult?.warning) {
402
+ logWarn('agy', skillsResult.warning);
403
+ warnings.push(skillsResult.warning);
404
+ }
405
+ return warnings;
302
406
  }
303
407
  supportsOAuthCopy() {
304
408
  return false;
@@ -374,13 +478,390 @@ export class AgyProvider {
374
478
  };
375
479
  }
376
480
  async ensureWorkspaceTrusted(_workFolder, _execCommand, _agentOs, _shell) {
377
- // apra-fleet-eft.40 provider trust matrix: AGY has NO per-project trust concept -- its
378
- // config is machine-global (live-verified, docs/member-onboarding-journey.md section
379
- // 3a). No-op.
380
- return { seeded: false, detail: 'agy: no per-project trust concept -- machine-global config' };
481
+ // Live-verified (docs/agy-provider.md section 5): a
482
+ // headless run with --project enforces the project's grants in a folder
483
+ // fleet never seeded into trustedWorkspaces, so there is nothing to seed.
484
+ return { seeded: false, detail: 'agy: no workspace trust needed -- grants bind via --project' };
485
+ }
486
+ }
487
+ // --- Permission denials -----------------------------------------------------
488
+ //
489
+ // A headless agy run that needs a grant it does not have exits 0 and reports
490
+ // the refusal in three places (docs/agy-provider.md section 4):
491
+ // 1. the --output-format json result: "denied_actions":[{"action":"command",...}]
492
+ // (with "status":"SUCCESS" and usually "response":"");
493
+ // 2. stderr: a tool required the "command" permission that headless mode
494
+ // cannot prompt for, so it was auto-denied ...;
495
+ // 3. the transcript (printed between FLEET_TRANSCRIPT_START/END by
496
+ // agy-transcript-reader.js): an ERROR step
497
+ // permission check failed for command "git status --short --branch": user denied ...
498
+ // (Linux/macOS name a shell command "unsandboxed" there: permission check
499
+ // failed for unsandboxed "whoami": user denied ...).
500
+ const AGY_STDERR_DENIAL_RE = /a tool required the "([a-z_]+)" permission that headless mode cannot prompt for/g;
501
+ const AGY_TRANSCRIPT_DENIAL_RES = [
502
+ /permission check failed for ([a-z_]+) "([\s\S]*?)": user denied/,
503
+ /user denied permission for ([a-z_]+)\(([^)]*)\)/,
504
+ ];
505
+ const SHELL_CHAIN_RE = /[|;`]|&&|\$\(/;
506
+ function stripTranscript(text) {
507
+ return text.replace(/FLEET_TRANSCRIPT_START[\s\S]*?FLEET_TRANSCRIPT_END/g, '');
508
+ }
509
+ const SHELL_SEQUENCE_RE = /[|;`]|&&/;
510
+ const PLAIN_COMMAND_WORD_RE = /^[\w.+-]+$/;
511
+ /** The compose_permissions grants that allow one denied call, primary first.
512
+ * The prefix grant Bash(<first word>:*) composes to command(<word>) plus
513
+ * command(regex:<word> .*) on every OS, and the regex matches the full raw
514
+ * line, including a $(...) argument (docs/agy-provider.md section 3), so it comes first and the
515
+ * exact command follows as the narrow option. Linux/macOS agy reports a shell
516
+ * command it refuses as `unsandboxed "<command line>"` (the JSON result says
517
+ * `command`), so both actions are handled alike. */
518
+ function suggestedGrantsFor(item) {
519
+ const t = item.target?.trim();
520
+ if (item.action === 'command' || item.action === 'unsandboxed') {
521
+ if (!t || SHELL_SEQUENCE_RE.test(t))
522
+ return [];
523
+ const first = t.split(/\s+/)[0];
524
+ const out = [];
525
+ if (PLAIN_COMMAND_WORD_RE.test(first))
526
+ out.push(`Bash(${first}:*)`);
527
+ if (!SHELL_CHAIN_RE.test(t) && t !== first)
528
+ out.push(`Bash(${t})`);
529
+ return out;
530
+ }
531
+ const one = suggestedGrantFor(item);
532
+ return one ? [one] : [];
533
+ }
534
+ function suggestedGrantFor(item) {
535
+ const t = item.target?.trim();
536
+ switch (item.action) {
537
+ case 'command':
538
+ return t && !SHELL_CHAIN_RE.test(t) ? `Bash(${t})` : undefined;
539
+ case 'read_file':
540
+ return t ? `Read(${t})` : 'Read';
541
+ case 'write_file':
542
+ return t ? `Write(${t})` : 'Write';
543
+ case 'mcp': {
544
+ const m = t ? /^([^/\s]+)\/([^/\s]+)$/.exec(t) : null;
545
+ return m ? `mcp__${m[1]}__${m[2]}` : undefined;
546
+ }
547
+ case 'read_url':
548
+ return 'WebSearch';
549
+ default:
550
+ return undefined;
551
+ }
552
+ }
553
+ /**
554
+ * Detects an agy permission denial in a dispatch's output. The JSON result is
555
+ * authoritative when present: a non-empty denied_actions is a denial whatever
556
+ * its status, and a result without it is not (older transcript steps are
557
+ * ignored). Without a JSON result, the stderr auto-denied line or a
558
+ * transcript ERROR step from the current turn counts. Targets always come
559
+ * from the current turn's transcript steps.
560
+ */
561
+ export function detectAgyPermissionDenial(result, agentOs) {
562
+ const stdout = stripAnsi(result.stdout ?? '');
563
+ const outside = stripTranscript(stdout);
564
+ const signals = [];
565
+ // 1. JSON result envelope(s) outside the transcript section.
566
+ let sawEnvelope = false;
567
+ const jsonActions = [];
568
+ for (const line of outside.split(/\r?\n/)) {
569
+ const l = line.trim();
570
+ const start = l.indexOf('{');
571
+ if (start < 0 || !l.endsWith('}'))
572
+ continue;
573
+ let obj;
574
+ try {
575
+ obj = JSON.parse(l.slice(start));
576
+ }
577
+ catch {
578
+ continue;
579
+ }
580
+ if (!obj || typeof obj !== 'object')
581
+ continue;
582
+ if ('conversation_id' in obj || 'denied_actions' in obj || obj.status === 'SUCCESS' || obj.status === 'ERROR')
583
+ sawEnvelope = true;
584
+ if (Array.isArray(obj.denied_actions)) {
585
+ for (const d of obj.denied_actions) {
586
+ const action = typeof d === 'string' ? d : (d && typeof d.action === 'string' ? d.action : undefined);
587
+ if (action)
588
+ jsonActions.push(action);
589
+ }
590
+ }
591
+ }
592
+ if (jsonActions.length)
593
+ signals.push('result_json');
594
+ // 2. stderr (and, defensively, stdout outside the transcript).
595
+ const stderrActions = [];
596
+ for (const text of [result.stderr ?? '', outside]) {
597
+ for (const m of text.matchAll(AGY_STDERR_DENIAL_RE))
598
+ stderrActions.push(m[1]);
599
+ }
600
+ if (stderrActions.length)
601
+ signals.push('stderr');
602
+ // 3. Transcript ERROR steps of the current turn (after the last user input).
603
+ const transcriptItems = [];
604
+ const section = /FLEET_TRANSCRIPT_START([\s\S]*?)FLEET_TRANSCRIPT_END/.exec(stdout)?.[1];
605
+ if (section) {
606
+ const entries = [];
607
+ for (const line of section.split(/\r?\n/)) {
608
+ const l = line.trim();
609
+ if (!l.startsWith('{'))
610
+ continue;
611
+ try {
612
+ entries.push(JSON.parse(l));
613
+ }
614
+ catch { /* skip */ }
615
+ }
616
+ let from = 0;
617
+ entries.forEach((e, i) => { if (e && e.type === 'USER_INPUT')
618
+ from = i + 1; });
619
+ for (const e of entries.slice(from)) {
620
+ if (!e || e.status !== 'ERROR' || typeof e.error !== 'string')
621
+ continue;
622
+ for (const re of AGY_TRANSCRIPT_DENIAL_RES) {
623
+ const m = re.exec(e.error);
624
+ if (m) {
625
+ transcriptItems.push({ action: m[1], target: m[2] });
626
+ break;
627
+ }
628
+ }
629
+ }
630
+ }
631
+ if (transcriptItems.length)
632
+ signals.push('transcript');
633
+ const denied = jsonActions.length > 0 || stderrActions.length > 0 || (!sawEnvelope && transcriptItems.length > 0);
634
+ if (!denied)
635
+ return undefined;
636
+ const denials = [];
637
+ const seen = new Set();
638
+ const add = (item) => {
639
+ const key = `${item.action}\u0000${item.target ?? ''}`;
640
+ if (!seen.has(key)) {
641
+ seen.add(key);
642
+ denials.push(item);
643
+ }
644
+ };
645
+ transcriptItems.forEach(add);
646
+ for (const action of [...jsonActions, ...stderrActions]) {
647
+ if (!denials.some(d => d.action === action))
648
+ add({ action });
649
+ }
650
+ const actions = [...new Set(denials.map(d => d.action))];
651
+ const perDenial = denials.map(d => suggestedGrantsFor(d));
652
+ const primary = [...new Set(perDenial.map(g => g[0]).filter((g) => !!g))];
653
+ const narrow = [...new Set(perDenial.flatMap(g => g.slice(1)))].filter(g => !primary.includes(g));
654
+ const suggestedGrants = [...primary, ...narrow];
655
+ const what = denials.map(d => (d.target ? `${d.action} "${d.target}"` : d.action)).join(', ');
656
+ let hint = `agy auto-denied ${what} (headless mode cannot prompt for permission).`;
657
+ if (suggestedGrants.length) {
658
+ hint += ` Grant it with compose_permissions grant: ${JSON.stringify(primary)} and retry.`;
659
+ if (narrow.length)
660
+ hint += ` Narrower alternative (this exact command line only): ${JSON.stringify(narrow)}.`;
661
+ }
662
+ else {
663
+ hint += ' No compose_permissions grant maps to this action automatically; grant it on the member by hand or escalate.';
664
+ }
665
+ if (actions.includes('command') || actions.includes('unsandboxed')) {
666
+ hint += agentOs === 'windows'
667
+ ? ' On Windows, Bash(<bin>:*) composes to command(<bin>) plus command(regex:<bin> .*), which allows <bin> with any arguments.'
668
+ : ' Bash(<bin>:*) composes to command(<bin>) plus command(regex:<bin> .*): command(<bin>) matches <bin> and its arguments by word prefix, and a command line with $(...), backticks, brace expansion or redirections needs the regex rule, which matches the full line.';
669
+ }
670
+ return { actions, denials, suggestedGrants, hint, signals };
671
+ }
672
+ export const AGY_MEMBER_ALLOWED_TOOLS = [
673
+ 'code_graph', 'code_impact', 'code_query', 'code_context', 'code_map',
674
+ 'code_flow', 'code_tests', 'kb_session_prime', 'kb_query', 'kb_stats',
675
+ 'kb_capture', 'kb_feedback', 'kb_list',
676
+ ];
677
+ export const AGY_ORCHESTRATOR_DENIED_TOOLS = [
678
+ 'register_member', 'list_members', 'get_member_model_pricing', 'remove_member',
679
+ 'update_member', 'dolt_push_mutex', 'child_id_allocator', 'member_reservation',
680
+ 'send_files', 'receive_files', 'execute_prompt', 'execute_command',
681
+ 'provision_llm_auth', 'setup_ssh_key', 'setup_git_app', 'provision_vcs_auth',
682
+ 'revoke_vcs_auth', 'vcs_credential_exec', 'fleet_status', 'member_detail',
683
+ 'update_llm_cli', 'shutdown_server', 'version', 'compose_permissions',
684
+ 'cloud_control', 'monitor_task', 'stop_prompt', 'credential_store_set',
685
+ 'credential_store_list', 'credential_store_delete', 'credential_store_update',
686
+ 'send_email', 'send_message', 'report_status', 'respond_to_message',
687
+ 'kb_invalidate', 'kb_context', 'kb_harvest', 'kb_promote',
688
+ 'kb_freshness_sweep', 'kb_import', 'kb_resolve_contradiction',
689
+ 'kb_reconcile_prefilter', 'kb_setup', 'kb_export',
690
+ ];
691
+ export const AGY_ORCHESTRATOR_DENY_RULES = AGY_ORCHESTRATOR_DENIED_TOOLS.flatMap(tool => [
692
+ `mcp(apra-fleet/${tool})`,
693
+ `mcp(apra-fleet-member/${tool})`
694
+ ]);
695
+ export async function checkAgyMemberSkills(execCommand, memberHomeDir, agentOs = 'linux', shell) {
696
+ const jsCode = `const fs = require('fs');
697
+ const path = require('path');
698
+ const home = ${memberHomeDir ? JSON.stringify(memberHomeDir) : 'process.env.HOME || process.env.USERPROFILE'};
699
+ const skillsDir = path.join(home, '.gemini', 'antigravity-cli', 'skills');
700
+ const pmInstalled = fs.existsSync(path.join(skillsDir, 'pm'));
701
+ const fleetInstalled = fs.existsSync(path.join(skillsDir, 'fleet'));
702
+ console.log(JSON.stringify({ pmInstalled, fleetInstalled, skillsDir }));
703
+ `;
704
+ const cmd = buildAgyNodeCommand(jsCode, agentOs, 'FLEET_SKILLS_EOF');
705
+ let result;
706
+ try {
707
+ result = await execCommand(cmd, 5000);
708
+ }
709
+ catch (err) {
710
+ const detail = err?.message || String(err);
711
+ return {
712
+ installed: [],
713
+ probeFailed: true,
714
+ warning: `[fleet:warn] agy: member skills check probe could not run (${detail}). Global skill isolation status unverified.`,
715
+ };
716
+ }
717
+ if (result.code !== 0) {
718
+ const errOutput = (result.stderr || result.stdout || '').trim();
719
+ const detail = errOutput ? `exit code ${result.code}: ${errOutput}` : `exit code ${result.code}`;
720
+ return {
721
+ installed: [],
722
+ probeFailed: true,
723
+ warning: `[fleet:warn] agy: member skills check probe could not run (${detail}). Global skill isolation status unverified.`,
724
+ };
725
+ }
726
+ const raw = result.stdout ? result.stdout.trim() : '';
727
+ if (!raw) {
728
+ return {
729
+ installed: [],
730
+ probeFailed: true,
731
+ warning: `[fleet:warn] agy: member skills check probe could not run (empty output). Global skill isolation status unverified.`,
732
+ };
733
+ }
734
+ try {
735
+ const parsed = JSON.parse(raw);
736
+ if (!parsed || typeof parsed !== 'object') {
737
+ return {
738
+ installed: [],
739
+ probeFailed: true,
740
+ warning: `[fleet:warn] agy: member skills check probe could not run (non-object JSON output). Global skill isolation status unverified.`,
741
+ };
742
+ }
743
+ const installed = [];
744
+ if (parsed.pmInstalled)
745
+ installed.push('pm');
746
+ if (parsed.fleetInstalled)
747
+ installed.push('fleet');
748
+ const skillsDir = typeof parsed.skillsDir === 'string' ? parsed.skillsDir : undefined;
749
+ if (installed.length > 0) {
750
+ const list = installed.join(', ');
751
+ const loc = skillsDir ? ` in ${skillsDir}` : '';
752
+ return {
753
+ installed,
754
+ skillsDir,
755
+ probeFailed: false,
756
+ warning: `[fleet:warn] agy: AGY provider has no per-member skill isolation mechanism. Global skill(s) [${list}] are installed${loc} and will be visible to this member.`,
757
+ };
758
+ }
759
+ return {
760
+ installed: [],
761
+ skillsDir,
762
+ probeFailed: false,
763
+ };
764
+ }
765
+ catch (e) {
766
+ return {
767
+ installed: [],
768
+ probeFailed: true,
769
+ warning: `[fleet:warn] agy: member skills check probe could not run (unparseable output: ${raw}). Global skill isolation status unverified.`,
770
+ };
771
+ }
772
+ }
773
+ export function checkAgyGlobalSkillsWarning(homeDir) {
774
+ const home = resolveHomeDir(homeDir);
775
+ if (!home)
776
+ return null;
777
+ const skillsDir = path.join(home, '.gemini', 'antigravity-cli', 'skills');
778
+ const pmInstalled = fs.existsSync(path.join(skillsDir, 'pm'));
779
+ const fleetInstalled = fs.existsSync(path.join(skillsDir, 'fleet'));
780
+ if (pmInstalled || fleetInstalled) {
781
+ const list = [pmInstalled && 'pm', fleetInstalled && 'fleet'].filter(Boolean).join(', ');
782
+ return `[fleet:warn] agy: AGY provider has no per-member skill isolation mechanism. Global skill(s) [${list}] are installed in ${skillsDir} and will be visible to AGY members.`;
783
+ }
784
+ return null;
785
+ }
786
+ /** The ONLY actions AGY accepts in `permissions.allow`. Taken verbatim from the
787
+ * CLI's own validation regex (agy 1.2.8):
788
+ * ^(command|read_file|write_file|read_url|mcp|execute_url|unsandboxed)\s*\(.*\)$
789
+ * `custom`, `invoke_subagent` and `send_message` are NOT permission actions --
790
+ * the latter two are AGY *tool* names with no permission gate of their own --
791
+ * so rules carrying them are dropped at serialization time rather than written
792
+ * as entries AGY would reject. */
793
+ const AGY_PERMISSION_ACTIONS = new Set(['command', 'read_file', 'write_file', 'read_url', 'mcp', 'execute_url', 'unsandboxed']);
794
+ /**
795
+ * Render structured rules into the ONLY shape AGY's permission parser
796
+ * accepts: a flat array of `action(target)` STRINGS in permissionGrants.allow.
797
+ *
798
+ * Before this, fleet wrote the `{ action, target }` objects straight through.
799
+ * AGY silently ignored every one of them, so a headless `-p` dispatch behaved
800
+ * as if the member had no grants at all and died on the first tool call with
801
+ * "a tool required the \"command\" permission that headless mode cannot prompt
802
+ * for, so it was auto-denied" -- the failure this function exists to prevent.
803
+ *
804
+ * Rules whose action is outside AGY's vocabulary are dropped with a warning:
805
+ * writing entries its parser rejects causes validation failure.
806
+ * The dropped tokens are already surfaced by
807
+ * convertClaudeAllowToAgyPermissions' own warnings for manual escalation.
808
+ */
809
+ export function formatAgyPermissionRules(rules) {
810
+ const out = [];
811
+ for (const rule of rules) {
812
+ if (!AGY_PERMISSION_ACTIONS.has(rule.action)) {
813
+ console.warn(`[agy] dropping permission rule "${rule.action}(${rule.target})": AGY's permissions.allow accepts only ${[...AGY_PERMISSION_ACTIONS].join(', ')}.`);
814
+ continue;
815
+ }
816
+ const entry = `${rule.action}(${rule.target})`;
817
+ if (!out.includes(entry))
818
+ out.push(entry);
381
819
  }
820
+ return out;
821
+ }
822
+ const PATH_SCOPED_READ_RE = /^(?:Read|Glob|Grep)\((.+)\)$/;
823
+ const PATH_SCOPED_WRITE_RE = /^(?:Write|Edit)\((.+)\)$/;
824
+ /** Escapes regex metacharacters so a literal command prefix can sit inside an
825
+ * agy `regex:` target. Spaces are kept. */
826
+ export function escapeAgyRegex(s) {
827
+ return s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
382
828
  }
383
- export function convertClaudeAllowToAgyPermissions(allow) {
829
+ /** The agy `command` targets for one Claude command prefix, on every OS. agy
830
+ * prefix-matches `command(git)` word by word only for a command line it can
831
+ * split into words: on Windows that excludes most lines (PowerShell/cmd), and
832
+ * on Linux/macOS a line with command substitution, backticks, brace expansion
833
+ * or fd redirections disables prefix matching. A `regex:` target is matched
834
+ * against the full raw line (docs/agy-provider.md section 3),
835
+ * so a prefix grant becomes the bare command plus a regex for any arguments.
836
+ * A command deny rule must be built here too, so it matches full lines. */
837
+ export function agyCommandRules(cmd) {
838
+ if (cmd === '*')
839
+ return ['*'];
840
+ return [cmd, `regex:${escapeAgyRegex(cmd)} .*`];
841
+ }
842
+ /** Reduces a Claude path pattern to the plain path agy's read_file/write_file
843
+ * targets take (agy has no globs and grants a directory recursively): a
844
+ * leading `~` becomes the member's home directory, a trailing `/**` or `/*`
845
+ * becomes the directory itself, and a bare `*`/`**` is the global wildcard.
846
+ * A glob anywhere else cannot be expressed: no target is returned and the
847
+ * caller drops the grant with a warning. */
848
+ function agyPathTarget(item, opts) {
849
+ let inner = item.slice(item.indexOf('(') + 1, -1).trim();
850
+ if (inner === '*' || inner === '**')
851
+ return { target: '*' };
852
+ if (inner === '~' || inner.startsWith('~/') || inner.startsWith('~\\')) {
853
+ if (!opts.homeDir)
854
+ return { reason: 'the member home directory is unknown, so ~ cannot be resolved' };
855
+ const home = opts.homeDir.replace(/\\/g, '/').replace(/\/+$/, '');
856
+ inner = inner === '~' ? home : `${home}/${inner.slice(2).replace(/\\/g, '/')}`;
857
+ }
858
+ const stripped = inner.replace(/[\\/]\*{1,2}$/, '');
859
+ if (/[*?]/.test(stripped))
860
+ return { reason: 'agy path targets cannot hold a glob' };
861
+ const trimmed = stripped.replace(/[\\/]+$/, '');
862
+ return { target: trimmed || '*' };
863
+ }
864
+ export function convertClaudeAllowToAgyPermissions(allow, opts = {}) {
384
865
  const rules = [];
385
866
  const added = new Set();
386
867
  const addRule = (action, target) => {
@@ -390,6 +871,17 @@ export function convertClaudeAllowToAgyPermissions(allow) {
390
871
  rules.push({ action, target });
391
872
  }
392
873
  };
874
+ const addPathRule = (action, item) => {
875
+ const { target, reason } = agyPathTarget(item, opts);
876
+ if (target !== undefined) {
877
+ addRule(action, target);
878
+ return;
879
+ }
880
+ const line = `agy: dropped "${item}" -- ${reason}; grant a directory or an exact path instead.`;
881
+ console.warn(`[fleet:warn] ${line}`);
882
+ if (opts.warnings && !opts.warnings.includes(line))
883
+ opts.warnings.push(line);
884
+ };
393
885
  for (const item of allow) {
394
886
  if (item === 'Read' || item === 'Glob' || item === 'Grep') {
395
887
  addRule('read_file', '*');
@@ -397,18 +889,35 @@ export function convertClaudeAllowToAgyPermissions(allow) {
397
889
  else if (item === 'Write' || item === 'Edit') {
398
890
  addRule('write_file', '*');
399
891
  }
892
+ else if (PATH_SCOPED_READ_RE.test(item)) {
893
+ // Path-scoped Claude grant, e.g. Read(/home/u/.claude/skills/**). AGY
894
+ // targets are path PREFIXES (`read_file(/Users/alice/notes)`), so the
895
+ // trailing glob is stripped; a bare `Read`/`Write` (no argument) is
896
+ // unrestricted in Claude and keeps mapping to '*' above.
897
+ addPathRule('read_file', item);
898
+ }
899
+ else if (PATH_SCOPED_WRITE_RE.test(item)) {
900
+ addPathRule('write_file', item);
901
+ }
400
902
  else if (item === 'Agent') {
401
903
  addRule('invoke_subagent', '*');
402
904
  addRule('send_message', '*');
403
905
  }
404
906
  else if (item.startsWith('Bash(')) {
405
- const match = item.match(/^Bash\(([^:*]+)(?::|\s|\*|\))/);
406
- if (match && match[1]) {
407
- const cmdName = match[1].trim();
408
- addRule('command', cmdName === '*' ? '*' : cmdName);
907
+ const inner = item.endsWith(')') ? item.slice(5, -1).trim() : '';
908
+ if (inner && !inner.includes('*')) {
909
+ // Exact grant (no wildcard): that command line only, no widening.
910
+ addRule('command', inner);
409
911
  }
410
912
  else {
411
- addRule('command', '*');
913
+ const match = item.match(/^Bash\(([^:*]+)(?::|\s|\*|\))/);
914
+ if (match && match[1]) {
915
+ for (const t of agyCommandRules(match[1].trim()))
916
+ addRule('command', t);
917
+ }
918
+ else {
919
+ addRule('command', '*');
920
+ }
412
921
  }
413
922
  }
414
923
  else if (item === 'Bash') {
@@ -422,25 +931,32 @@ export function convertClaudeAllowToAgyPermissions(allow) {
422
931
  addRule('mcp', '*');
423
932
  }
424
933
  else if (item.startsWith('mcp__')) {
425
- // Claude's real MCP permission-string format is `mcp__<server>__<tool>` (e.g.
426
- // "mcp__apra-fleet__kb_capture") -- NOT the fictional `Mcp(name)` shape above.
427
- // AGY's own permission model is server-granular, not per-tool (see the 'mcp'
428
- // action's target). The 'apra-fleet' server deliberately colocates safe
429
- // read-only KB tools (kb_query, kb_capture, ...) alongside destructive
430
- // fleet-admin tools (remove_member, shutdown_server, credential_store_*) --
431
- // see src/services/tool-registry.ts's registerAllTools. Auto-collapsing a
432
- // narrow per-tool Claude grant like "mcp__apra-fleet__kb_query" into a
433
- // server-level AGY rule would silently hand that member blanket access to
434
- // every tool on the server, not just the one requested -- a real privilege
435
- // escalation, not a convenience gap. Until the MCP surface is split by trust
436
- // tier (or AGY gains per-tool granularity), do NOT auto-grant here; surface it
437
- // so a human can escalate deliberately, same as the NEVER_AUTO_GRANT pattern
438
- // in compose-permissions.ts.
934
+ // Claude's real MCP permission-string format is `mcp__<server>__<tool>`
935
+ // (e.g. "mcp__apra-fleet__kb_capture") -- NOT the fictional `Mcp(name)`
936
+ // shape above. AGY expresses the SAME per-tool granularity as
937
+ // `mcp(<server>/<tool>)` (its own docs: "mcp(<server_name>/<tool_name>)
938
+ // e.g. mcp(buganizer/get_bugs)", and a denial reads
939
+ // `user denied permission for mcp(apra-fleet/kb_session_prime)`), so the
940
+ // two map across exactly, with no widening.
941
+ //
942
+ // This previously refused to map at all, on the belief that AGY was
943
+ // server-granular only -- which WOULD have been a privilege escalation,
944
+ // since the 'apra-fleet' server colocates safe read-only KB tools with
945
+ // destructive fleet-admin ones (remove_member, shutdown_server,
946
+ // credential_store_*; see src/services/tool-registry.ts). That belief is
947
+ // wrong for AGY 1.2.8, and the cost of the workaround was real: the
948
+ // deployer's Step 0 kb_session_prime was auto-denied in headless mode,
949
+ // taking the whole Deploy phase down with it. Note what is NOT done here:
950
+ // a bare server-level `mcp(apra-fleet)` is still never emitted.
439
951
  const rest = item.slice('mcp__'.length);
440
952
  const sep = rest.indexOf('__');
441
- const server = sep >= 0 ? rest.slice(0, sep) : rest;
442
- console.warn(`[agy] refusing to auto-grant mcp permission "${item}": AGY has no per-tool MCP granularity, only server-level ("${server}"), and that server also exposes destructive tools. Escalate manually if this member genuinely needs it.`);
443
- addRule('custom', item);
953
+ if (sep < 0) {
954
+ console.warn(`[agy] warning: unmapped mcp permission token "${item}" (expected mcp__<server>__<tool>)`);
955
+ addRule('custom', item);
956
+ }
957
+ else {
958
+ addRule('mcp', `${rest.slice(0, sep)}/${rest.slice(sep + 2)}`);
959
+ }
444
960
  }
445
961
  else if (item === 'Web' || item === 'Fetch' || item === 'WebSearch') {
446
962
  addRule('read_url', '*');