@defrex/autobuild 1.9.0 → 1.11.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 (537) hide show
  1. package/README.md +3 -3
  2. package/SPEC.md +2232 -175
  3. package/bin/ab-dispatch-generation.ts +5 -1
  4. package/docs/accounts.md +2 -1
  5. package/docs/agent-runtimes.md +30 -3
  6. package/docs/answering-blocked-builds.md +35 -7
  7. package/docs/architecture.md +436 -63
  8. package/docs/build-store.md +10 -7
  9. package/docs/builds.md +5 -0
  10. package/docs/cli.md +40 -2
  11. package/docs/configuration-overview.md +5 -1
  12. package/docs/configuration.md +649 -74
  13. package/docs/dispatcher.md +79 -6
  14. package/docs/forges.md +8 -1
  15. package/docs/getting-started.md +1 -1
  16. package/docs/integration-overview.md +4 -2
  17. package/docs/integration-tree.md +102 -11
  18. package/docs/merge-policy.md +30 -14
  19. package/docs/migration-1.0.md +2 -1
  20. package/docs/operating.md +36 -6
  21. package/docs/operator-api.md +251 -20
  22. package/docs/operator-surfaces.md +85 -0
  23. package/docs/optimization-nodes.md +1100 -0
  24. package/docs/overview.md +1 -1
  25. package/docs/plugin-authoring.md +83 -13
  26. package/docs/remote-store-protocol.md +137 -17
  27. package/docs/remote-ticket-protocol.md +90 -2
  28. package/docs/restacking.md +119 -15
  29. package/docs/seams.md +2 -2
  30. package/docs/setup.md +27 -4
  31. package/docs/skills.md +4 -2
  32. package/docs/spec-standard.md +2 -1
  33. package/docs/ticket-dependencies.md +15 -3
  34. package/docs/ticket-migration.md +4 -2
  35. package/docs/ticket-sources.md +54 -14
  36. package/docs/tickets.md +21 -6
  37. package/docs/troubleshooting.md +11 -2
  38. package/docs/verification.md +15 -3
  39. package/docs/workspaces.md +6 -1
  40. package/package.json +9 -5
  41. package/packages/core/src/accounts/chatgpt-oauth.ts +7 -5
  42. package/packages/core/src/cli/accounts.ts +7 -2
  43. package/packages/core/src/cli/attempt.ts +103 -0
  44. package/packages/core/src/cli/attention.ts +11 -2
  45. package/packages/core/src/cli/binary-direct.ts +54 -1
  46. package/packages/core/src/cli/binary-lifecycle.ts +2 -1
  47. package/packages/core/src/cli/binary.ts +5 -3
  48. package/packages/core/src/cli/build-control.ts +407 -67
  49. package/packages/core/src/cli/context.ts +272 -15
  50. package/packages/core/src/cli/dashboard/detail.ts +26 -2
  51. package/packages/core/src/cli/dashboard/facts.ts +89 -56
  52. package/packages/core/src/cli/dashboard/header.ts +101 -0
  53. package/packages/core/src/cli/dashboard/integration-detail.ts +7 -2
  54. package/packages/core/src/cli/dashboard/landing-display.ts +15 -2
  55. package/packages/core/src/cli/dashboard/model.ts +133 -66
  56. package/packages/core/src/cli/dashboard/objective-row.ts +221 -0
  57. package/packages/core/src/cli/dashboard/poll.ts +178 -76
  58. package/packages/core/src/cli/dashboard/render.ts +172 -227
  59. package/packages/core/src/cli/dashboard/reopen-display.ts +39 -0
  60. package/packages/core/src/cli/dashboard/row-text.ts +538 -0
  61. package/packages/core/src/cli/dashboard/timeline.ts +288 -0
  62. package/packages/core/src/cli/dashboard/tree.ts +12 -1
  63. package/packages/core/src/cli/dashboard/vocabulary.ts +188 -0
  64. package/packages/core/src/cli/dispatch-args.ts +44 -1
  65. package/packages/core/src/cli/dispatch-frontend.ts +29 -30
  66. package/packages/core/src/cli/dispatch-launch-stop.ts +73 -0
  67. package/packages/core/src/cli/dispatch-launcher.ts +41 -46
  68. package/packages/core/src/cli/dispatch-repository-feed.ts +1 -1
  69. package/packages/core/src/cli/dispatch-web.ts +155 -0
  70. package/packages/core/src/cli/dispatch.ts +216 -38
  71. package/packages/core/src/cli/env.ts +42 -0
  72. package/packages/core/src/cli/help.ts +293 -12
  73. package/packages/core/src/cli/init-agent.ts +4 -1
  74. package/packages/core/src/cli/init-readiness-remote.ts +3 -2
  75. package/packages/core/src/cli/init-validation.ts +5 -5
  76. package/packages/core/src/cli/init.ts +3 -2
  77. package/packages/core/src/cli/judge-entry.ts +82 -0
  78. package/packages/core/src/cli/judge.ts +233 -0
  79. package/packages/core/src/cli/landings.ts +3 -2
  80. package/packages/core/src/cli/main.ts +481 -148
  81. package/packages/core/src/cli/mcp.ts +35 -3
  82. package/packages/core/src/cli/measurement-text.ts +19 -0
  83. package/packages/core/src/cli/objective.ts +154 -0
  84. package/packages/core/src/cli/operator-preference.ts +57 -0
  85. package/packages/core/src/cli/publication-settlement.ts +106 -22
  86. package/packages/core/src/cli/repo-lease.ts +3 -0
  87. package/packages/core/src/cli/repo-state.ts +56 -6
  88. package/packages/core/src/cli/repository-status.ts +205 -56
  89. package/packages/core/src/cli/status.ts +275 -16
  90. package/packages/core/src/cli/store-opening.ts +4 -0
  91. package/packages/core/src/cli/terminal-restore.ts +32 -7
  92. package/packages/core/src/cli/terminals.ts +205 -8
  93. package/packages/core/src/cli/ticket-start.ts +53 -0
  94. package/packages/core/src/cli/ticket.ts +166 -38
  95. package/packages/core/src/cli/upgrade-agent.ts +12 -8
  96. package/packages/core/src/cli/wait.ts +22 -8
  97. package/packages/core/src/cli/watch.ts +361 -95
  98. package/packages/core/src/cli/web.ts +139 -0
  99. package/packages/core/src/config/create-labels.ts +23 -0
  100. package/packages/core/src/config/live.ts +101 -14
  101. package/packages/core/src/config/load.ts +61 -20
  102. package/packages/core/src/config/local.ts +212 -0
  103. package/packages/core/src/config/pipeline-source.ts +3 -3
  104. package/packages/core/src/config/reference.ts +18 -0
  105. package/packages/core/src/config/roles.ts +182 -73
  106. package/packages/core/src/config/schema.ts +157 -19
  107. package/packages/core/src/events/catalog.ts +43 -3
  108. package/packages/core/src/events/compatibility.ts +7 -1
  109. package/packages/core/src/events/payloads.ts +685 -1
  110. package/packages/core/src/events/policy.ts +63 -0
  111. package/packages/core/src/events/repository.ts +153 -27
  112. package/packages/core/src/kernel/__snapshots__/reducer-accumulator-shapes.json +1797 -199
  113. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/017d8dd5bb6dd80b.json.gz +0 -0
  114. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/0ab2a90d0305dc9d.json.gz +0 -0
  115. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/10a4657408d4e121.json.gz +0 -0
  116. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/1152a2e97ee81728.json.gz +0 -0
  117. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/13ca84752c5f8b54.json.gz +0 -0
  118. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/1411d1cdbdd9911e.json.gz +0 -0
  119. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/1444fe1fa7fc802c.json.gz +0 -0
  120. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/1491ac0600349391.json.gz +0 -0
  121. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/178e12f1759b7552.json.gz +0 -0
  122. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/1921f86f752428c9.json.gz +0 -0
  123. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/1972c1d66008ef6b.json.gz +0 -0
  124. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/19e8e43e7f3f1a06.json.gz +0 -0
  125. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/20a85c143c3e8164.json.gz +0 -0
  126. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/21ce2c0bf58318e1.json.gz +0 -0
  127. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/293dcb3a94fb3470.json.gz +0 -0
  128. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/2ab7436356267118.json.gz +0 -0
  129. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/2d084641735caaff.json.gz +0 -0
  130. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/3237bcecf68e5db9.json.gz +0 -0
  131. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/33d0cc593610e56f.json.gz +0 -0
  132. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/3451ed2136dcc356.json.gz +0 -0
  133. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/358ec8693f2237e6.json.gz +0 -0
  134. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/35cf9ccc4478b2d2.json.gz +0 -0
  135. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/3649e7bd1203f154.json.gz +0 -0
  136. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/378da6dece82202a.json.gz +0 -0
  137. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/38c75099d9191471.json.gz +0 -0
  138. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/398952f1f01db1a3.json.gz +0 -0
  139. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/3b64d352d56c9121.json.gz +0 -0
  140. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/3dc486226c05372d.json.gz +0 -0
  141. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/431c9bb2ee8838e0.json.gz +0 -0
  142. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/4400dffca929e2f0.json.gz +0 -0
  143. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/49064fc079964a5c.json.gz +0 -0
  144. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/4932c70a2af97faf.json.gz +0 -0
  145. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/4edded75f17742f4.json.gz +0 -0
  146. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/4f00c0f2c8afd159.json.gz +0 -0
  147. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/516a5a7aadf97587.json.gz +0 -0
  148. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/516dc6ea85d67cd7.json.gz +0 -0
  149. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/536085773daf6b58.json.gz +0 -0
  150. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/584e2ba74608e051.json.gz +0 -0
  151. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/59ffaa6974094c72.json.gz +0 -0
  152. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/5bb43afb121674c6.json.gz +0 -0
  153. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/5f0ca42af862c4ee.json.gz +0 -0
  154. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/6118031132db9bfc.json.gz +0 -0
  155. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/63107a8d58776b63.json.gz +0 -0
  156. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/63546b08d4d6fa11.json.gz +0 -0
  157. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/643d70429ce03dad.json.gz +0 -0
  158. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/677ea92572c29082.json.gz +0 -0
  159. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/6ae5bf60504d6467.json.gz +0 -0
  160. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/6bd6275061aaffa5.json.gz +0 -0
  161. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/6efdc8defc75fccb.json.gz +0 -0
  162. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/71c53d33f09d8204.json.gz +0 -0
  163. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/7267ca2757cffba7.json.gz +0 -0
  164. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/76b7d4244082b3f9.json.gz +0 -0
  165. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/7749f918c6f10968.json.gz +0 -0
  166. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/7833e42d16301424.json.gz +0 -0
  167. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/7d4edad0614adaf1.json.gz +0 -0
  168. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/837365898d04f45a.json.gz +0 -0
  169. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/85f9f0c921b8b5bb.json.gz +0 -0
  170. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/8879f57a24733897.json.gz +0 -0
  171. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/88cb9e71bdec972d.json.gz +0 -0
  172. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/89625654b02e9ac1.json.gz +0 -0
  173. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/8a0cd6dd06cc155e.json.gz +0 -0
  174. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/8aa9ca8609dc051d.json.gz +0 -0
  175. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/8c8640255bd61658.json.gz +0 -0
  176. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/8cc15eb1807c0157.json.gz +0 -0
  177. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/8ced97c44bc0af3a.json.gz +0 -0
  178. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/8d4144004720b9f8.json.gz +0 -0
  179. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/8db633ead1807f8b.json.gz +0 -0
  180. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/8e42cdbd0994ab0c.json.gz +0 -0
  181. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/9011d0f6ff955ef9.json.gz +0 -0
  182. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/916ebc5433801c41.json.gz +0 -0
  183. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/9539b995af5c54a9.json.gz +0 -0
  184. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/95f391bfd7b7dbd7.json.gz +0 -0
  185. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/9613e8fa568a9281.json.gz +0 -0
  186. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/9a68f8753bd9038d.json.gz +0 -0
  187. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/9b25e58227080094.json.gz +0 -0
  188. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/9ee3919fbd4f9458.json.gz +0 -0
  189. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/a04a34cc2717147b.json.gz +0 -0
  190. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/a0b32c12e4e6edb6.json.gz +0 -0
  191. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/a55218252707bdd3.json.gz +0 -0
  192. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/a732fd08b31522a6.json.gz +0 -0
  193. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/a98af134be2da8a9.json.gz +0 -0
  194. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/a9d206a01f9039e5.json.gz +0 -0
  195. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/abf7fe3c92c82f2d.json.gz +0 -0
  196. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/ac928b04842c00db.json.gz +0 -0
  197. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/af953392d81911da.json.gz +0 -0
  198. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/b0d877c44810ecb0.json.gz +0 -0
  199. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/b0f7c6ebb2db57fc.json.gz +0 -0
  200. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/b905c22ec17eed31.json.gz +0 -0
  201. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/bce0c54e865f4b79.json.gz +0 -0
  202. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/c68b7ee2e2610f30.json.gz +0 -0
  203. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/c7f7e0378aeea237.json.gz +0 -0
  204. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/c98cb1659eb142b6.json.gz +0 -0
  205. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/ca830adf06ed55a1.json.gz +0 -0
  206. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/cb3a219f33e437ca.json.gz +0 -0
  207. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/cf1e0c0d82567e0c.json.gz +0 -0
  208. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/d008d86d9ff77b30.json.gz +0 -0
  209. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/d1432a819d8e48c5.json.gz +0 -0
  210. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/d185ed6aa9192aff.json.gz +0 -0
  211. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/d5d5ccca80a893d8.json.gz +0 -0
  212. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/d873fad29d6c7e55.json.gz +0 -0
  213. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/db84b12316e2da4a.json.gz +0 -0
  214. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/ddf6dc967d898767.json.gz +0 -0
  215. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/dfc64de6e7bfc0a0.json.gz +0 -0
  216. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/e2f18fa32fe1f6d0.json.gz +0 -0
  217. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/e37393fed29e84c5.json.gz +0 -0
  218. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/e6a8585e2a054ff6.json.gz +0 -0
  219. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/e7e9e327baca6903.json.gz +0 -0
  220. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/e86447af0571672c.json.gz +0 -0
  221. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/ea819202d22122e5.json.gz +0 -0
  222. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/eb4535585f2e84f6.json.gz +0 -0
  223. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/eb7ddd5319d09e27.json.gz +0 -0
  224. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/eca4959b2b87ae15.json.gz +0 -0
  225. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/ee10d7959ec4843c.json.gz +0 -0
  226. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/ef1b68347966ab26.json.gz +0 -0
  227. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/f3e55425cc41f230.json.gz +0 -0
  228. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/f40042c1cdb9fd43.json.gz +0 -0
  229. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/f48466215c790a3f.json.gz +0 -0
  230. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/f5b9ace9b59351e7.json.gz +0 -0
  231. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/f8155387eb5f375c.json.gz +0 -0
  232. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/fa8f1475a55be935.json.gz +0 -0
  233. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/fb21116a15d0b1f1.json.gz +0 -0
  234. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/fe95444fbeabe592.json.gz +0 -0
  235. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/09bf0a1611d07363.json +984 -0
  236. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/10eac4988d66e161.json +1067 -0
  237. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/1a436b5fb45aee3e.json +1116 -0
  238. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/249db6f7a41f90e2.json +161 -0
  239. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/25dcb2fb6eaa83f4.json +858 -0
  240. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/2e1bdc763924616f.json +4932 -0
  241. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/30e9dabce3c4263d.json +399 -0
  242. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/3c27f918b194e3b3.json +465 -0
  243. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/4898ef339c68fa36.json +83 -0
  244. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/51816c0ffa62af6e.json +417 -0
  245. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/561bf45320062a44.json +83 -0
  246. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/5672d0233085d050.json +84 -0
  247. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/5e39f42cbdbf35ef.json +163 -0
  248. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/7771a7a2250f9964.json +868 -0
  249. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/79f0e0f4ccd43ba2.json +455 -0
  250. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/859c09edac738823.json +1086 -0
  251. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/881c491321bec99a.json +1074 -0
  252. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/965f25c3af1d2cdc.json +160 -0
  253. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/9b76d89da575ca90.json +20 -0
  254. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/9eb485320a72a9ff.json +233 -0
  255. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/a283c1f3462b1cc1.json +81 -0
  256. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/a60448c01016135e.json +18 -0
  257. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/a6584fb61b6679bd.json +97 -0
  258. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/a6e570fb126991ff.json +36 -0
  259. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/a8acf22c968b6e3d.json +81 -0
  260. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/ba7b85895bf6698e.json +1153 -0
  261. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/c88365c25b3186d3.json +543 -0
  262. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/e8f0481b23f90056.json +711 -0
  263. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/ee55782ed40ebbac.json +110 -0
  264. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/fc5082fac8167f3d.json +98 -0
  265. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/fc66408cde0b6b04.json +637 -0
  266. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/fd55c329cfe921cc.json +1069 -0
  267. package/packages/core/src/kernel/attempt-creation-key.ts +20 -0
  268. package/packages/core/src/kernel/attempt-settlement.ts +125 -0
  269. package/packages/core/src/kernel/auto-merge-default.ts +1 -3
  270. package/packages/core/src/kernel/auto-merge.ts +1 -3
  271. package/packages/core/src/kernel/build-roster.ts +230 -0
  272. package/packages/core/src/kernel/dispatch-capacity.ts +316 -40
  273. package/packages/core/src/kernel/dispatch-placement.ts +1 -1
  274. package/packages/core/src/kernel/dispatch-settings.ts +1 -4
  275. package/packages/core/src/kernel/dispatch-status.ts +3 -5
  276. package/packages/core/src/kernel/dispatch-upgrade.ts +1 -1
  277. package/packages/core/src/kernel/engine.ts +152 -18
  278. package/packages/core/src/kernel/execution-intervals.ts +61 -0
  279. package/packages/core/src/kernel/forge-checks.ts +140 -0
  280. package/packages/core/src/kernel/forge-health.ts +2 -2
  281. package/packages/core/src/kernel/generated-files.ts +43 -0
  282. package/packages/core/src/kernel/generated-regeneration.ts +254 -0
  283. package/packages/core/src/kernel/generators/build-log.ts +30 -2
  284. package/packages/core/src/kernel/generators/optimization-log.ts +679 -0
  285. package/packages/core/src/kernel/generators/panel-log.ts +133 -0
  286. package/packages/core/src/kernel/generators/repository-journals.ts +13 -0
  287. package/packages/core/src/kernel/guarded-forge.ts +76 -11
  288. package/packages/core/src/kernel/harvest.ts +1 -4
  289. package/packages/core/src/kernel/head-paths.ts +4 -1
  290. package/packages/core/src/kernel/history-retention.ts +337 -0
  291. package/packages/core/src/kernel/incremental-fixtures.ts +6 -0
  292. package/packages/core/src/kernel/incremental.ts +14 -4
  293. package/packages/core/src/kernel/integration-landing.ts +64 -13
  294. package/packages/core/src/kernel/integration-stack.ts +123 -20
  295. package/packages/core/src/kernel/integration-state.ts +39 -2
  296. package/packages/core/src/kernel/janitor-failure.ts +2 -0
  297. package/packages/core/src/kernel/kernel-git.ts +1 -1
  298. package/packages/core/src/kernel/landing-measurement.ts +275 -0
  299. package/packages/core/src/kernel/landing-readiness.ts +2 -0
  300. package/packages/core/src/kernel/landing-state.ts +20 -1
  301. package/packages/core/src/kernel/leaf-restack-base.ts +33 -7
  302. package/packages/core/src/kernel/leaf-restack-state.ts +99 -4
  303. package/packages/core/src/kernel/log-index-value.ts +2 -0
  304. package/packages/core/src/kernel/log-index.ts +100 -3
  305. package/packages/core/src/kernel/measurement.ts +406 -0
  306. package/packages/core/src/kernel/mixed-version.ts +6 -3
  307. package/packages/core/src/kernel/node-landing.ts +92 -18
  308. package/packages/core/src/kernel/node-restack-state.ts +27 -1
  309. package/packages/core/src/kernel/node-restack-transaction.ts +80 -23
  310. package/packages/core/src/kernel/node-verification-context.ts +14 -4
  311. package/packages/core/src/kernel/open-pr-backpressure-state.ts +24 -0
  312. package/packages/core/src/kernel/open-pr-backpressure.ts +133 -0
  313. package/packages/core/src/kernel/optimization-admission.ts +490 -0
  314. package/packages/core/src/kernel/optimization.ts +953 -0
  315. package/packages/core/src/kernel/panel.ts +225 -0
  316. package/packages/core/src/kernel/phase-failures.ts +121 -0
  317. package/packages/core/src/kernel/phases.ts +42 -6
  318. package/packages/core/src/kernel/pr-attachments.ts +4 -16
  319. package/packages/core/src/kernel/pr-summary.ts +2 -2
  320. package/packages/core/src/kernel/published-branch-head.ts +60 -0
  321. package/packages/core/src/kernel/read-deferrals.ts +2 -2
  322. package/packages/core/src/kernel/read-facts.ts +69 -31
  323. package/packages/core/src/kernel/reconcile-restack.ts +352 -103
  324. package/packages/core/src/kernel/reducer-identity.ts +659 -0
  325. package/packages/core/src/kernel/reducer-registry.ts +62 -9
  326. package/packages/core/src/kernel/reducer-revisions.ts +75 -0
  327. package/packages/core/src/kernel/reducer.ts +269 -11
  328. package/packages/core/src/kernel/reopen-state.ts +48 -0
  329. package/packages/core/src/kernel/reopen.ts +143 -0
  330. package/packages/core/src/kernel/replay-retention.ts +208 -39
  331. package/packages/core/src/kernel/repository-attention.ts +1 -1
  332. package/packages/core/src/kernel/rollup.ts +61 -0
  333. package/packages/core/src/kernel/service-facts.ts +19 -7
  334. package/packages/core/src/kernel/setup-streak.ts +38 -0
  335. package/packages/core/src/kernel/step-durations.ts +257 -0
  336. package/packages/core/src/kernel/target-observation.ts +6 -1
  337. package/packages/core/src/kernel/target-rewrite-recovery.ts +116 -0
  338. package/packages/core/src/kernel/terminal-guard.ts +13 -5
  339. package/packages/core/src/kernel/ticket-handbacks.ts +1 -1
  340. package/packages/core/src/kernel/ticket-migrations.ts +1 -1
  341. package/packages/core/src/kernel/ticket-preparation.ts +1 -1
  342. package/packages/core/src/kernel/ticket-source-health.ts +1 -1
  343. package/packages/core/src/kernel/ticket-starts.ts +118 -0
  344. package/packages/core/src/kernel/ticket-wait.ts +37 -2
  345. package/packages/core/src/kernel/verify-diff-base.ts +67 -0
  346. package/packages/core/src/kernel/verify-stage-state.ts +1 -0
  347. package/packages/core/src/kernel/verify-stages.ts +51 -1
  348. package/packages/core/src/objective.ts +532 -0
  349. package/packages/core/src/ontology.ts +54 -6
  350. package/packages/core/src/operator/agent-context-serve.ts +631 -0
  351. package/packages/core/src/operator/annotations.ts +105 -4
  352. package/packages/core/src/operator/attention.ts +470 -0
  353. package/packages/core/src/operator/canonical-skills.ts +35 -0
  354. package/packages/core/src/operator/cli-equivalents.ts +270 -0
  355. package/packages/core/src/operator/context-prompts.ts +61 -0
  356. package/packages/core/src/operator/control.ts +2 -1
  357. package/packages/core/src/operator/index.ts +61 -1
  358. package/packages/core/src/operator/landings.ts +28 -19
  359. package/packages/core/src/operator/optimization.ts +314 -0
  360. package/packages/core/src/operator/protocol.ts +33 -1
  361. package/packages/core/src/operator/query.ts +137 -73
  362. package/packages/core/src/operator/read-view.ts +5 -2
  363. package/packages/core/src/operator/registry.ts +625 -59
  364. package/packages/core/src/operator/requests.ts +45 -20
  365. package/packages/core/src/operator/sandbox-host.ts +107 -11
  366. package/packages/core/src/operator/sandbox-resolver.ts +253 -0
  367. package/packages/core/src/operator/sandbox.ts +778 -82
  368. package/packages/core/src/operator/ticket-asset-list.ts +77 -0
  369. package/packages/core/src/operator/ticket-assets.ts +167 -0
  370. package/packages/core/src/operator/ticket-start.ts +152 -0
  371. package/packages/core/src/operator/tickets.ts +36 -4
  372. package/packages/core/src/plugin-sdk/index.ts +24 -0
  373. package/packages/core/src/plugins/manifest.ts +1 -1
  374. package/packages/core/src/plugins/registry.ts +1 -0
  375. package/packages/core/src/ports/forge/contract.ts +9 -0
  376. package/packages/core/src/ports/forge/fake.ts +114 -2
  377. package/packages/core/src/ports/forge/git-blob.ts +15 -0
  378. package/packages/core/src/ports/forge/git-rewrite.ts +6 -4
  379. package/packages/core/src/ports/forge/github-readiness.ts +1 -1
  380. package/packages/core/src/ports/forge/github-transport.ts +156 -1
  381. package/packages/core/src/ports/forge/github.ts +388 -100
  382. package/packages/core/src/ports/forge/local-git.ts +61 -1
  383. package/packages/core/src/ports/forge/readiness.ts +15 -3
  384. package/packages/core/src/ports/forge-failure.ts +46 -0
  385. package/packages/core/src/ports/forge-request-context.ts +23 -1
  386. package/packages/core/src/ports/forge-telemetry.ts +16 -0
  387. package/packages/core/src/ports/runner/antigravity-test.fixture.ts +149 -0
  388. package/packages/core/src/ports/runner/antigravity.ts +1071 -0
  389. package/packages/core/src/ports/runner/claude-test.fixture.ts +71 -0
  390. package/packages/core/src/ports/runner/claude.ts +6 -1
  391. package/packages/core/src/ports/runner/codex-test.fixture.ts +63 -0
  392. package/packages/core/src/ports/runner/codex.ts +11 -2
  393. package/packages/core/src/ports/runner/contract.ts +25 -1
  394. package/packages/core/src/ports/runner/fake.ts +2 -2
  395. package/packages/core/src/ports/runner/native-cli-fixture.ts +40 -5
  396. package/packages/core/src/ports/runner/native-process-fixture.ts +4 -1
  397. package/packages/core/src/ports/runner/pi.ts +23 -7
  398. package/packages/core/src/ports/runner/production.ts +19 -2
  399. package/packages/core/src/ports/runner/session-env.ts +65 -5
  400. package/packages/core/src/ports/runner/start-prompt.ts +6 -4
  401. package/packages/core/src/ports/tickets/contract.ts +75 -2
  402. package/packages/core/src/ports/tickets/fake.ts +11 -0
  403. package/packages/core/src/ports/tickets/file.ts +18 -0
  404. package/packages/core/src/ports/tickets/github-fake.ts +136 -4
  405. package/packages/core/src/ports/tickets/github.ts +407 -35
  406. package/packages/core/src/ports/tickets/hosted-index.ts +16 -1
  407. package/packages/core/src/ports/tickets/labels.ts +21 -0
  408. package/packages/core/src/ports/tickets/linear.ts +163 -0
  409. package/packages/core/src/ports/tickets/migration.ts +2 -0
  410. package/packages/core/src/ports/tickets/priority.ts +20 -0
  411. package/packages/core/src/ports/tickets/remote-protocol.ts +105 -6
  412. package/packages/core/src/ports/tickets/remote.ts +203 -17
  413. package/packages/core/src/ports/tickets/search.ts +139 -0
  414. package/packages/core/src/ports/tickets/tree.ts +17 -4
  415. package/packages/core/src/ports/types.ts +202 -6
  416. package/packages/core/src/ports/workspace/builtin-capabilities.ts +16 -4
  417. package/packages/core/src/ports/workspace/commit-preservation.ts +182 -64
  418. package/packages/core/src/ports/workspace/create.ts +18 -1
  419. package/packages/core/src/ports/workspace/fake.ts +340 -12
  420. package/packages/core/src/ports/workspace/git-worktree.ts +846 -43
  421. package/packages/core/src/ports/workspace/operator-sandbox.ts +129 -12
  422. package/packages/core/src/ports/workspace/process-group.ts +48 -0
  423. package/packages/core/src/ports/workspace/vercel-sandbox.ts +1539 -221
  424. package/packages/core/src/processes/agent-context-assemble.ts +576 -0
  425. package/packages/core/src/processes/agent-context.ts +469 -0
  426. package/packages/core/src/processes/build-execution-state.ts +1 -3
  427. package/packages/core/src/processes/build-runner.ts +1982 -528
  428. package/packages/core/src/processes/dispatch-failure-budget.ts +1 -1
  429. package/packages/core/src/processes/dispatcher-selectors.ts +15 -13
  430. package/packages/core/src/processes/dispatcher.ts +3003 -308
  431. package/packages/core/src/processes/execution-no-progress.ts +40 -1
  432. package/packages/core/src/processes/execution-settlement.ts +2 -6
  433. package/packages/core/src/processes/harvest-execution-state.ts +2 -6
  434. package/packages/core/src/processes/harvest-runner.ts +7 -2
  435. package/packages/core/src/processes/infrastructure-failure-budget.ts +1 -3
  436. package/packages/core/src/processes/judge-launcher.ts +38 -0
  437. package/packages/core/src/processes/measurement-runner.ts +235 -0
  438. package/packages/core/src/processes/optimization-activity.ts +120 -0
  439. package/packages/core/src/processes/optimization-merges.ts +101 -0
  440. package/packages/core/src/processes/optimization-stop.ts +179 -0
  441. package/packages/core/src/processes/panel-runner.ts +756 -0
  442. package/packages/core/src/processes/phase-failure-budget.ts +2 -0
  443. package/packages/core/src/processes/publication-state.ts +1 -4
  444. package/packages/core/src/processes/repo-view.ts +154 -6
  445. package/packages/core/src/processes/sandbox-state.ts +54 -10
  446. package/packages/core/src/processes/tick-publication.ts +2 -0
  447. package/packages/core/src/processes/tick-state.ts +1 -3
  448. package/packages/core/src/processes/workspace-preparation.ts +76 -0
  449. package/packages/core/src/processes/workspace-preservation.ts +67 -9
  450. package/packages/core/src/scenarios/harness.ts +19 -13
  451. package/packages/core/src/store/account-redaction.ts +1 -0
  452. package/packages/core/src/store/adapter.ts +52 -1
  453. package/packages/core/src/store/agent-context.ts +432 -0
  454. package/packages/core/src/store/build-feed.ts +291 -0
  455. package/packages/core/src/store/build-scope.ts +19 -1
  456. package/packages/core/src/store/contract.ts +955 -14
  457. package/packages/core/src/store/digest.ts +104 -9
  458. package/packages/core/src/store/histogram.ts +113 -0
  459. package/packages/core/src/store/judge-authority.ts +161 -0
  460. package/packages/core/src/store/local/schema.ts +62 -0
  461. package/packages/core/src/store/local/store.ts +628 -22
  462. package/packages/core/src/store/local/ticket-asset-heads.ts +23 -0
  463. package/packages/core/src/store/memory.ts +461 -69
  464. package/packages/core/src/store/open-builds.ts +19 -0
  465. package/packages/core/src/store/phase-session.ts +256 -6
  466. package/packages/core/src/store/reduced-reads.ts +24 -4
  467. package/packages/core/src/store/reducer-value-shapes.json +18023 -11824
  468. package/packages/core/src/store/reducer-values.ts +6 -1
  469. package/packages/core/src/store/remote/client.ts +220 -4
  470. package/packages/core/src/store/remote/compatibility.ts +1 -1
  471. package/packages/core/src/store/remote/credentials.ts +31 -1
  472. package/packages/core/src/store/remote/index.ts +41 -0
  473. package/packages/core/src/store/remote/protocol.ts +107 -0
  474. package/packages/core/src/store/remote/released-clients.json +22 -0
  475. package/packages/core/src/store/remote/released-reducer-values/1.10.0.json +34439 -0
  476. package/packages/core/src/store/remote/released-reducer-values/1.11.0.json +35680 -0
  477. package/packages/core/src/store/remote/released-reducer-values/index.ts +20 -16
  478. package/packages/core/src/store/remote/token.ts +13 -4
  479. package/packages/core/src/store/repo-state-events.ts +6 -8
  480. package/packages/core/src/store/retention.ts +23 -1
  481. package/packages/core/src/store/rollups.ts +337 -0
  482. package/packages/core/src/store/session-handle.ts +20 -2
  483. package/packages/core/src/store/session-reducer.ts +1 -4
  484. package/packages/core/src/store/snapshots.ts +10 -0
  485. package/packages/core/src/store/ticket-assets.ts +1 -3
  486. package/packages/core/src/store/types.ts +117 -9
  487. package/packages/core/src/testing/dispatch-read-budget.ts +1162 -2
  488. package/packages/core/src/testing/git-config-isolation.ts +27 -0
  489. package/packages/core/src/testing/index.ts +40 -0
  490. package/packages/core/src/testing/memory-operator-sandbox.ts +346 -0
  491. package/packages/core/src/testing/reduced-read-budget.ts +5349 -153
  492. package/packages/core/src/web/analytics-source.ts +303 -0
  493. package/packages/core/src/web/assets/Atkinson-OFL.txt +93 -0
  494. package/packages/core/src/web/assets/AtkinsonHyperlegibleNext.latin.woff2 +0 -0
  495. package/packages/core/src/web/assets/JetBrains-OFL.txt +93 -0
  496. package/packages/core/src/web/assets/JetBrainsMono.latin.woff2 +0 -0
  497. package/packages/core/src/web/assets/app.css +1 -0
  498. package/packages/core/src/web/assets/app.js +9 -0
  499. package/packages/core/src/web/assets/manifest.json +31 -0
  500. package/packages/core/src/web/assets/theme.js +1 -0
  501. package/packages/core/src/web/bounded.ts +31 -0
  502. package/packages/core/src/web/http.ts +315 -0
  503. package/packages/core/src/web/hub.ts +160 -0
  504. package/packages/core/src/web/options.ts +38 -0
  505. package/packages/core/src/web/overview-source.ts +322 -0
  506. package/packages/core/src/web/page.ts +56 -0
  507. package/packages/core/src/web/protocol.ts +151 -0
  508. package/packages/core/src/web/read-only.ts +23 -0
  509. package/packages/core/src/web/repository-source.ts +35 -0
  510. package/packages/core/src/web/server.ts +97 -0
  511. package/skills/code-review/SKILL.md +26 -2
  512. package/skills/finalize/SKILL.md +10 -4
  513. package/skills/guide/SKILL.md +743 -123
  514. package/skills/guide/references/accounts.md +2 -1
  515. package/skills/guide/references/integration-tree.md +102 -11
  516. package/skills/guide/references/merge-policy.md +30 -14
  517. package/skills/guide/references/migration-1.0.md +2 -1
  518. package/skills/guide/references/operator-api.md +251 -20
  519. package/skills/guide/references/optimization-nodes.md +1100 -0
  520. package/skills/guide/references/plugin-authoring.md +83 -13
  521. package/skills/guide/references/remote-store-protocol.md +137 -17
  522. package/skills/guide/references/remote-ticket-protocol.md +90 -2
  523. package/skills/guide/references/restacking.md +119 -15
  524. package/skills/guide/references/setup.md +27 -4
  525. package/skills/guide/references/spec-standard.md +2 -1
  526. package/skills/guide/references/ticket-dependencies.md +15 -3
  527. package/skills/guide/references/ticket-migration.md +4 -2
  528. package/skills/implement/SKILL.md +74 -5
  529. package/skills/judge/SKILL.md +43 -0
  530. package/skills/operate/SKILL.md +374 -57
  531. package/skills/plan/SKILL.md +28 -4
  532. package/skills/plan-review/SKILL.md +24 -3
  533. package/skills/propose/SKILL.md +121 -0
  534. package/skills/reconcile/SKILL.md +21 -2
  535. package/skills/spec/SKILL.md +63 -11
  536. package/skills/tickets/SKILL.md +94 -9
  537. package/templates/hosted-service/package.json +2 -2
@@ -1,13 +1,16 @@
1
1
  import { readBuildPage } from '../store/event-reads'
2
- import { abortDestinationSchema } from '../events/payloads'
2
+ import { abortDestinationSchema, unmeasuredSettlementPolicySchema } from '../events/payloads'
3
3
  import { readRepositoryAttentionPage } from './repository-events'
4
+ import { getOperatorAttention } from './attention'
4
5
  import { requestNodeRestack } from './restack'
6
+ import { reviseObjective, settleUnmeasuredAttempt, stopObjective } from './optimization'
7
+ import { objectiveEpsilonSchema } from '../objective'
5
8
  import { listOperatorLandings } from './landings'
6
9
  import { getOperatorTicketTree } from './tickets'
7
10
  import { openOperatorTickets, operatorControlTickets } from './tickets'
8
11
  import { TicketRevisionConflict, TicketRevisionUnsupported } from '../ports/tickets/revision'
9
12
  import { TicketIssueLinksUnsupported } from '../ports/tickets/issue-links'
10
- import { TicketPriorityUnsupported } from '../ports/tickets/priority'
13
+ import { TicketPriorityUnsupported, ticketPrioritySchema } from '../ports/tickets/priority'
11
14
  import { TicketAssigneesUnsupported } from '../ports/tickets/assignees'
12
15
  /**
13
16
  * The agent tool registry — one typed table that is the single source of
@@ -45,6 +48,14 @@ import type { Via } from '../events/envelope'
45
48
  import { bulkControlRepository, BulkWalkError } from '../cli/bulk-control'
46
49
  import { systemClock, type BuildStore, type Clock } from '../store/types'
47
50
  import { TicketOperationError } from '../ports/tickets/operations'
51
+ import { TicketSearchCursorInvalid, TicketSearchUnsupported } from '../ports/tickets/search'
52
+ import { controlTicketStart } from './ticket-start'
53
+ import {
54
+ attachOperatorTicketAsset,
55
+ getOperatorTicketAsset,
56
+ removeOperatorTicketAsset,
57
+ } from './ticket-assets'
58
+ import { TICKET_ASSET_MAX_BYTES, TicketAssetValidationError } from '../store/ticket-assets'
48
59
  import { OPERATOR_NOTES_REPO_KIND } from '../store/retention'
49
60
  import {
50
61
  clearForgeDegradation,
@@ -64,6 +75,7 @@ import {
64
75
  import {
65
76
  answerRequestSchema,
66
77
  harvestControlRequestSchema,
78
+ reopenRequestSchema,
67
79
  ticketBlockerRequestSchema,
68
80
  ticketCreateRequestSchema,
69
81
  exactlyOneMoveTarget,
@@ -71,17 +83,34 @@ import {
71
83
  ticketMoveRequestShape,
72
84
  ticketUpdateRequestSchema,
73
85
  type OperatorAnswerRequest,
86
+ type OperatorReopenRequest,
74
87
  } from './protocol'
75
88
  import { OPERATOR_TOOL_ANNOTATIONS, type OperatorToolName } from './annotations'
76
- import { answerAction, controlPrechecks, requireRouteBuild, RouteRefusalError } from './requests'
89
+ import {
90
+ answerAction,
91
+ controlPrechecks,
92
+ reopenAction,
93
+ requireRouteBuild,
94
+ RouteRefusalError,
95
+ } from './requests'
77
96
  import { SandboxOperationError } from '../ports/workspace/operator-sandbox'
97
+ import { readAgentContext } from '../store/agent-context'
98
+ import {
99
+ contextIndex,
100
+ contextSource,
101
+ readContextFile,
102
+ type CanonicalSkillBundle,
103
+ } from './agent-context-serve'
104
+ import { defaultCanonicalSkills } from './canonical-skills'
78
105
  import type { OperatorSandboxService } from './sandbox'
106
+ import { SandboxUnavailableError } from './sandbox-resolver'
79
107
  import {
80
108
  prepareOperatorTicketAssets,
81
109
  listOperatorTicketStates,
82
110
  createOperatorTicketState,
83
111
  getOperatorTicket,
84
112
  listOperatorTickets,
113
+ searchOperatorTickets,
85
114
  mutateOperatorTicket,
86
115
  type OperatorTicketBackend,
87
116
  } from './tickets'
@@ -104,6 +133,15 @@ export interface ToolContext {
104
133
  via?: Via
105
134
  /** The operator-sandbox backend; required only by the sandbox tools. */
106
135
  sandbox?: OperatorSandboxService
136
+ /** Lazy per-call backend resolution (the hosted mode): invoked only by a
137
+ * sandbox handler, and only when `sandbox` is absent. It may throw
138
+ * `SandboxUnavailableError`, which maps to a typed `sandbox-<reason>`
139
+ * refusal. */
140
+ sandboxFor?: () => Promise<OperatorSandboxService>
141
+ /** The canonical skill bundle the context tools serve when a repository
142
+ * has no captured agent context. Default: the serving distribution's
143
+ * `skills/` tree, read once per process. */
144
+ canonicalSkills?: () => Promise<CanonicalSkillBundle>
107
145
  }
108
146
 
109
147
  /** The failure body shape the operator API emits, mapped one-to-one so a tool
@@ -114,6 +152,8 @@ export interface ToolFailureBody {
114
152
  error: string
115
153
  code?: string
116
154
  progress?: unknown
155
+ /** The operator sandbox's lifecycle state, on `sandbox-not-ready`. */
156
+ state?: string
117
157
  }
118
158
 
119
159
  export type RegistryErrorReason =
@@ -193,15 +233,15 @@ function ticketsOf(ctx: ToolContext): OperatorTicketBackend {
193
233
  return ctx.tickets
194
234
  }
195
235
 
196
- /** The sandbox tools need the backend; same refusal shape as `ticketsOf`. */
197
- function sandboxOf(ctx: ToolContext): OperatorSandboxService {
198
- if (ctx.sandbox === undefined) {
199
- throw new RouteRefusalError({
200
- kind: 'conflict',
201
- error: 'operator sandbox backend is not configured',
202
- })
203
- }
204
- return ctx.sandbox
236
+ /** The sandbox tools need the backend: the static one, else the call's lazy
237
+ * resolution; otherwise the same refusal shape as `ticketsOf`. */
238
+ async function sandboxOf(ctx: ToolContext): Promise<OperatorSandboxService> {
239
+ if (ctx.sandbox !== undefined) return ctx.sandbox
240
+ if (ctx.sandboxFor !== undefined) return ctx.sandboxFor()
241
+ throw new RouteRefusalError({
242
+ kind: 'conflict',
243
+ error: 'operator sandbox backend is not configured',
244
+ })
205
245
  }
206
246
 
207
247
  /** Extend every member of a request-union schema with shared routing fields
@@ -243,6 +283,167 @@ const buildDetailInput = z.strictObject({ repo: repoField, slug: slugField })
243
283
 
244
284
  const ticketDetailInput = z.strictObject({ repo: repoField, id: ticketIdField })
245
285
 
286
+ const contextListInput = z.strictObject({ repo: repoField })
287
+ const contextReadInput = z.strictObject({
288
+ repo: repoField,
289
+ path: z
290
+ .string()
291
+ .min(1)
292
+ .describe(
293
+ 'A path from context.list (e.g. ".agents/skills/ab-operate/SKILL.md" or "AGENTS.md"), or a relative link from a file you read, with `from`.',
294
+ ),
295
+ from: z
296
+ .string()
297
+ .min(1)
298
+ .optional()
299
+ .describe(
300
+ 'The path of the file whose relative link `path` is (e.g. ".agents/skills/ab-spec/SKILL.md" with path "../ab-guide/references/spec-standard.md").',
301
+ ),
302
+ })
303
+
304
+ /** The context view for one repository: its captured record (one
305
+ * latest-revision artifact read), else the canonical bundle. A record that
306
+ * fails to decode propagates; it never falls back. */
307
+ async function contextViewFor(ctx: ToolContext, repo: string) {
308
+ const captured = await readAgentContext(ctx.store, repo)
309
+ if (captured !== null) return contextSource(captured.record, null)
310
+ return contextSource(null, await (ctx.canonicalSkills ?? defaultCanonicalSkills)())
311
+ }
312
+
313
+ /** Strict, padded standard base64: whole 4-character groups of the standard
314
+ * alphabet, `=` only as one or two trailing pad characters. Buffer.from would
315
+ * silently drop anything else. A linear scan, not a regex: a repeated-group
316
+ * pattern exhausts the regex engine on multi-megabyte payloads. */
317
+ function isPaddedBase64(value: string): boolean {
318
+ if (value.length % 4 !== 0) return false
319
+ const padding = value.endsWith('==') ? 2 : value.endsWith('=') ? 1 : 0
320
+ for (let i = 0; i < value.length - padding; i++) {
321
+ const c = value.charCodeAt(i)
322
+ const ok =
323
+ (c >= 65 && c <= 90) || // A-Z
324
+ (c >= 97 && c <= 122) || // a-z
325
+ (c >= 48 && c <= 57) || // 0-9
326
+ c === 43 || // +
327
+ c === 47 // /
328
+ if (!ok) return false
329
+ }
330
+ return true
331
+ }
332
+
333
+ const contentBase64Field = z
334
+ .string()
335
+ .max(Math.ceil(TICKET_ASSET_MAX_BYTES / 3) * 4)
336
+ .refine(isPaddedBase64, { message: 'contentBase64 must be padded standard base64' })
337
+ .describe('The file’s exact bytes, standard padded base64 ("" for an empty file).')
338
+ const assetKindField = z
339
+ .string()
340
+ .min(1)
341
+ .describe('Asset kind, a label such as "design" or "reference".')
342
+ const assetNameField = z
343
+ .string()
344
+ .min(1)
345
+ .describe('Asset name, unique per kind on the ticket (e.g. "checkout-canvas").')
346
+ const ticketAssetAttachInput = z.strictObject({
347
+ repo: repoField,
348
+ id: ticketIdField,
349
+ kind: assetKindField,
350
+ name: assetNameField,
351
+ layout: z
352
+ .enum(['file', 'tree'])
353
+ .describe(
354
+ '"file": exactly one file entry, a single-file asset. "tree": any number of entries, a folder (an empty tree is allowed).',
355
+ ),
356
+ entries: z
357
+ .array(
358
+ z.discriminatedUnion('type', [
359
+ z.strictObject({
360
+ type: z.literal('file'),
361
+ path: z
362
+ .string()
363
+ .describe('Relative "/"-separated path inside the asset (e.g. "img/a.png").'),
364
+ contentBase64: contentBase64Field,
365
+ }),
366
+ z.strictObject({
367
+ type: z.literal('dir'),
368
+ path: z
369
+ .string()
370
+ .describe('Relative "/"-separated path of an explicit, possibly empty, directory.'),
371
+ }),
372
+ ]),
373
+ )
374
+ .describe('The asset’s files and explicit directories.'),
375
+ })
376
+ const ticketAssetGetInput = z.strictObject({
377
+ repo: repoField,
378
+ id: ticketIdField,
379
+ kind: assetKindField,
380
+ name: assetNameField,
381
+ rev: z
382
+ .number()
383
+ .int()
384
+ .min(0)
385
+ .safe()
386
+ .optional()
387
+ .describe(
388
+ 'Exact revision to read. Omit for the latest; a removed asset is readable only by revision.',
389
+ ),
390
+ })
391
+ const ticketAssetRemoveInput = z.strictObject({
392
+ repo: repoField,
393
+ id: ticketIdField,
394
+ kind: assetKindField,
395
+ name: assetNameField,
396
+ })
397
+
398
+ const objectiveReviseInput = z
399
+ .strictObject({
400
+ repo: repoField,
401
+ slug: slugField,
402
+ threshold: z.number().optional().describe('Stop when the node head reaches this value.'),
403
+ epsilon: objectiveEpsilonSchema
404
+ .optional()
405
+ .describe('The smallest gain that counts: {absolute: n} or {relative: 0 < n < 1}.'),
406
+ maxAttempts: z.number().int().min(1).optional(),
407
+ maxHours: z.number().gt(0).optional(),
408
+ plateau: z
409
+ .number()
410
+ .int()
411
+ .min(1)
412
+ .optional()
413
+ .describe('Consecutive no-improvement or declined attempts that stop the node.'),
414
+ stopMode: z.enum(['abort', 'drain']).optional(),
415
+ concurrency: z.number().int().min(1).optional().describe('Attempts in flight.'),
416
+ })
417
+ .refine(
418
+ ({ repo: _repo, slug: _slug, ...changes }) =>
419
+ Object.values(changes).some((value) => value !== undefined),
420
+ 'revise at least one field',
421
+ )
422
+
423
+ const objectiveStopInput = z.strictObject({
424
+ repo: repoField,
425
+ slug: slugField,
426
+ mode: z
427
+ .enum(['abort', 'drain'])
428
+ .optional()
429
+ .describe(
430
+ 'Override the objective’s stop mode for this stop; omitted, the objective’s mode applies.',
431
+ ),
432
+ })
433
+
434
+ const objectiveSettleUnmeasuredInput = z.strictObject({
435
+ repo: repoField,
436
+ slug: slugField,
437
+ attempt: z
438
+ .string()
439
+ .min(1)
440
+ .describe('The unmeasured merged attempt: its proposal id or its build slug.'),
441
+ policy: unmeasuredSettlementPolicySchema.describe(
442
+ 'The explicit settlement policy. release-unmeasured releases the attempt’s concurrency slot and records its measurement as absent; it never counts as accepted or moves any value.',
443
+ ),
444
+ note: z.string().max(4000).optional().describe('A note recorded with the settlement.'),
445
+ })
446
+
246
447
  const buildEventsInput = z.strictObject({
247
448
  repo: repoField,
248
449
  slug: slugField,
@@ -289,9 +490,24 @@ const buildControlInput = z.strictObject({
289
490
  repo: repoField,
290
491
  slug: slugField,
291
492
  action: z
292
- .enum(['pause', 'cancel-pause', 'resume', 'merge', 'land', 'hold', 'abort', 'discard'])
493
+ .enum([
494
+ 'pause',
495
+ 'cancel-pause',
496
+ 'resume',
497
+ 'merge',
498
+ 'land',
499
+ 'hold',
500
+ 'priority',
501
+ 'abort',
502
+ 'discard',
503
+ ])
293
504
  .describe(
294
- 'Control to request: "pause" (or "cancel-pause" to revoke a pending pause), "resume" a paused build, "merge" (deprecated alias "land") for merge consent or "hold" to withdraw consent — or the destructive "abort" (cancels the build, cleans up its PR and workspace, hands the ticket back to triage, or to ready with `to`) and "discard" (dequeue a queued build).',
505
+ 'Control to request: "pause" (or "cancel-pause" to revoke a pending pause), "resume" a paused build, "merge" (deprecated alias "land") for merge consent or "hold" to withdraw consent, "priority" to set the build\'s slot-admission priority — or the destructive "abort" (cancels the build, cleans up its PR and workspace, hands the ticket back to triage, or to ready with `to`) and "discard" (dequeue a queued build).',
506
+ ),
507
+ priority: ticketPrioritySchema
508
+ .optional()
509
+ .describe(
510
+ 'Required with, and only valid with, "priority": "urgent" admits the build to free slots ahead of normal parked work and normal ticket claims; "normal" returns it to normal order. Running work is never preempted and the ticket is unchanged.',
295
511
  ),
296
512
  to: abortDestinationSchema
297
513
  .optional()
@@ -301,7 +517,9 @@ const buildControlInput = z.strictObject({
301
517
  reason: z
302
518
  .string()
303
519
  .optional()
304
- .describe('Abort only: why, 1–2000 characters; quoted in the hand-back ticket comment.'),
520
+ .describe(
521
+ 'Abort or hold: why, 1–2000 characters after trimming; abort quotes it in the hand-back ticket comment, hold shows it wherever the hold is displayed.',
522
+ ),
305
523
  })
306
524
 
307
525
  const repositoryEventsInput = z.strictObject({
@@ -332,8 +550,23 @@ const repositoryEventsInput = z.strictObject({
332
550
  ),
333
551
  })
334
552
 
553
+ const repositoryAttentionInput = z.strictObject({
554
+ repo: repoField,
555
+ cursor: z
556
+ .number()
557
+ .int()
558
+ .min(0)
559
+ .safe()
560
+ .optional()
561
+ .describe(
562
+ 'Repository journal cursor from the previous attention call: report attention events with seq strictly greater than this. Omit on the first call to receive no events and a baseline cursor for the current head.',
563
+ ),
564
+ })
565
+
335
566
  const buildsAnswerInput = extendUnion(answerRequestSchema, { repo: repoField, slug: slugField })
336
567
 
568
+ const buildsReopenInput = reopenRequestSchema.extend({ repo: repoField, slug: slugField })
569
+
337
570
  const repositoryStatusInput = z.strictObject({ repo: repoField })
338
571
 
339
572
  const repositorySettingsInput = z.strictObject({
@@ -387,6 +620,33 @@ const ticketsListInput = z.strictObject({
387
620
  ),
388
621
  })
389
622
 
623
+ const ticketsSearchInput = z.strictObject({
624
+ repo: repoField,
625
+ query: z
626
+ .string()
627
+ .regex(/\S/, 'query must contain a nonblank word')
628
+ .describe(
629
+ 'Words to find in ticket titles and bodies; every word must appear, case-insensitively.',
630
+ ),
631
+ state: z
632
+ .string()
633
+ .min(1)
634
+ .optional()
635
+ .describe(
636
+ 'Only tickets in this provider state; omitted searches every state, including completed and rejected tickets.',
637
+ ),
638
+ labels: z
639
+ .array(z.string().min(1))
640
+ .optional()
641
+ .describe('Only tickets carrying every named label.'),
642
+ limit: z.number().int().min(1).max(100).optional().describe('Page size; default 20.'),
643
+ cursor: z
644
+ .string()
645
+ .min(1)
646
+ .optional()
647
+ .describe('The `cursor` from the previous page of the same search.'),
648
+ })
649
+
390
650
  const ticketsCreateInput = ticketCreateRequestSchema.extend({ repo: repoField })
391
651
 
392
652
  const ticketsUpdateInput = ticketUpdateRequestSchema
@@ -415,6 +675,21 @@ const ticketsBlockersInput = ticketBlockerRequestSchema.extend({
415
675
  ),
416
676
  })
417
677
 
678
+ const ticketsStartInput = z.strictObject({
679
+ repo: repoField,
680
+ id: ticketIdField,
681
+ priority: z
682
+ .enum(['manual', 'urgent', 'normal'])
683
+ .optional()
684
+ .describe(
685
+ 'Slot-admission tier for the request (default "manual"): manual goes ahead of all waiting work; urgent waits for urgent parked work; normal waits for normal parked work and urgent claims. Not allowed with cancel.',
686
+ ),
687
+ cancel: z
688
+ .boolean()
689
+ .optional()
690
+ .describe('Cancel the pending start request for this ticket instead of requesting one.'),
691
+ })
692
+
418
693
  const ticketsMoveInput = ticketMoveRequestShape
419
694
  .extend({
420
695
  repo: repoField,
@@ -509,6 +784,10 @@ const sandboxWriteFileInput = z.strictObject({
509
784
  })
510
785
 
511
786
  const sandboxResetInput = z.strictObject({ repo: repoField })
787
+ const sandboxOpenInput = z.strictObject({ repo: repoField })
788
+ const sandboxStatusInput = z.strictObject({ repo: repoField })
789
+ const sandboxCloseInput = z.strictObject({ repo: repoField })
790
+ const sandboxRefreshInput = z.strictObject({ repo: repoField })
512
791
 
513
792
  const sandboxPublishInput = z.strictObject({
514
793
  repo: repoField,
@@ -525,7 +804,7 @@ const sandboxPublishInput = z.strictObject({
525
804
  .min(1)
526
805
  .optional()
527
806
  .describe(
528
- 'Optional commit-ish to publish instead of the checkout HEAD; must resolve to a commit that is a descendant of the base head recorded at provision or reset time.',
807
+ 'Optional commit-ish to publish instead of the checkout HEAD; must resolve to a commit that is a descendant of the base head recorded at provision, refresh, or reset time.',
529
808
  ),
530
809
  })
531
810
 
@@ -588,7 +867,7 @@ export const TOOLS: readonly ToolEntry[] = [
588
867
  'builds.list',
589
868
  'List one repository’s builds, newest first, with effective status derived from the build log.',
590
869
  buildListInput,
591
- 'JSON array of build summaries: slug, ticket ref, effective status, phase/round/attempt, PR number/url/state, updatedAt, lease health, durable-event progress, and any ticket wait (`wait` with its state and tickets; `waitOnly` when the wait is the only open escalation).',
870
+ 'JSON array of build summaries: slug, ticket ref, effective status, phase/round/attempt, PR number/url/state, updatedAt, lease health, durable-event progress, any ticket wait (`wait` with its state and tickets; `waitOnly` when the wait is the only open escalation), and an optimization node’s objective progress (`objective`).',
592
871
  async (raw, ctx) => {
593
872
  const input = raw as z.infer<typeof buildListInput>
594
873
  return listOperatorBuilds({
@@ -603,7 +882,7 @@ export const TOOLS: readonly ToolEntry[] = [
603
882
  'builds.get',
604
883
  'Show detailed state for one build: open escalations, verify progress, PR lifecycle, lease health, and the dashboard row.',
605
884
  buildDetailInput,
606
- '{detail, dashboardRow}: the full build detail projection and the dashboard row a terminal dashboard would render (null when the build has no dashboard row).',
885
+ '{detail, dashboardRow}: the full build detail projection and the dashboard row a terminal dashboard would render (null when the build has no dashboard row). An optimization node carries its objective progress as `detail.objective` and `dashboardRow.objectiveRow`.',
607
886
  async (raw, ctx) => {
608
887
  const input = raw as z.infer<typeof buildDetailInput>
609
888
  return getOperatorBuild({
@@ -666,9 +945,58 @@ export const TOOLS: readonly ToolEntry[] = [
666
945
  })
667
946
  },
668
947
  ),
948
+ defineTool(
949
+ 'optimization.revise',
950
+ 'Revise an optimization node’s objective knobs: threshold, epsilon, budget, plateau, stop mode or concurrency. Running attempts are unaffected and nothing is replanned; the metric, harness and purpose change only through a node spec revision. Refuses work builds, plain nodes and terminal nodes.',
951
+ objectiveReviseInput,
952
+ '{slug, revision, changes}: the recorded objective revision.',
953
+ async (raw, ctx) => {
954
+ const { repo, slug, ...changes } = raw as z.infer<typeof objectiveReviseInput>
955
+ return reviseObjective({
956
+ store: ctx.store,
957
+ repo,
958
+ slug,
959
+ changes,
960
+ user: attributed(ctx),
961
+ ...(ctx.via ? { via: ctx.via } : {}),
962
+ })
963
+ },
964
+ ),
965
+ defineTool(
966
+ 'optimization.stop',
967
+ 'Stop a running optimization node. Abort cancels queued attempts and aborts running ones, and all of them settle as stopped; drain cancels queued attempts and lets running ones finish and face the landing gate. Without mode the objective’s stop mode applies (abort by default). No proposer runs after a stop, and a stop is final. Stopping is not merge consent: land with builds.control merge once the node is complete. Refuses work builds, plain nodes, terminal nodes and a node that has already stopped.',
968
+ objectiveStopInput,
969
+ '{slug, cause, mode}: the recorded stop.',
970
+ async (raw, ctx) => {
971
+ const { repo, slug, mode } = raw as z.infer<typeof objectiveStopInput>
972
+ return stopObjective({
973
+ store: ctx.store,
974
+ repo,
975
+ slug,
976
+ ...(mode !== undefined ? { mode } : {}),
977
+ user: attributed(ctx),
978
+ ...(ctx.via ? { via: ctx.via } : {}),
979
+ })
980
+ },
981
+ ),
982
+ defineTool(
983
+ 'optimization.settle-unmeasured',
984
+ 'Settle an optimization attempt that merged on the forge without a landing measurement of its merged head. Such an attempt stays in flight, holding a concurrency slot, and optimization progress lists it under unmeasuredMerges. The policy is required: release-unmeasured records the settlement as merged-unmeasured, releasing the slot exactly once without claiming an improvement, moving the current or best value, or touching the plateau. Works on a stopped node. Refuses work builds, plain nodes, terminal nodes, settled or unmerged attempts, and heads with a valid measurement.',
985
+ objectiveSettleUnmeasuredInput,
986
+ '{slug, proposal, build, outcome, policy}: the recorded settlement.',
987
+ async (raw, ctx) => {
988
+ const input = raw as z.infer<typeof objectiveSettleUnmeasuredInput>
989
+ return settleUnmeasuredAttempt({
990
+ store: ctx.store,
991
+ ...input,
992
+ user: attributed(ctx),
993
+ ...(ctx.via ? { via: ctx.via } : {}),
994
+ })
995
+ },
996
+ ),
669
997
  defineTool(
670
998
  'builds.control',
671
- 'Pause immediately suspends a live agent session. Resume continues where stopped when supported; remote and unsupported sessions rerun fresh. Request a durable control for one active build: pause/cancel-pause, resume, hold or merge — or the destructive abort and discard. Merge requires a ready candidate, and an optional head binds consent to the reviewed head; hold withdraws merge consent.',
999
+ "Pause immediately suspends a live agent session. Resume continues where stopped when supported; remote and unsupported sessions rerun fresh. Request a durable control for one active build: pause/cancel-pause, resume, hold or merge — or the destructive abort and discard. Merge requires a ready candidate, and an optional head binds consent to the reviewed head; hold withdraws merge consent, with an optional reason. Priority sets the build's slot-admission priority (urgent or normal) to expedite waiting work without aborting it.",
672
1000
  buildControlInput,
673
1001
  'Either {kind: "command", slug, command, event} for an accepted control, or {kind: "answer-required", slug, escalationIds} when a resume needs its open escalations answered first.',
674
1002
  async (raw, ctx) => {
@@ -691,8 +1019,19 @@ export const TOOLS: readonly ToolEntry[] = [
691
1019
  error: 'head must be a nonblank commit SHA without whitespace',
692
1020
  })
693
1021
  }
694
- if (input.action !== 'abort' && (input.to !== undefined || input.reason !== undefined)) {
695
- const error = `"to" and "reason" apply only to the abort action, not "${received.action}"`
1022
+ if (input.action !== 'abort' && input.to !== undefined) {
1023
+ const error = `"to" applies only to the abort action, not "${received.action}"`
1024
+ throw new RegistryError('validation', error, { kind: 'validation', error })
1025
+ }
1026
+ if (input.action !== 'abort' && input.action !== 'hold' && input.reason !== undefined) {
1027
+ const error = `"reason" applies only to the abort and hold actions, not "${received.action}"`
1028
+ throw new RegistryError('validation', error, { kind: 'validation', error })
1029
+ }
1030
+ if ((input.action === 'priority') !== (input.priority !== undefined)) {
1031
+ const error =
1032
+ input.action === 'priority'
1033
+ ? '"priority" is required with the priority action'
1034
+ : `"priority" applies only to the priority action, not "${received.action}"`
696
1035
  throw new RegistryError('validation', error, { kind: 'validation', error })
697
1036
  }
698
1037
  await controlPrechecks(ctx.store, input.repo, input.slug, input.action)
@@ -713,7 +1052,14 @@ export const TOOLS: readonly ToolEntry[] = [
713
1052
  ...(input.to !== undefined ? { to: input.to } : {}),
714
1053
  ...(input.reason !== undefined ? { reason: input.reason } : {}),
715
1054
  }
716
- : { kind: input.action }
1055
+ : input.action === 'hold'
1056
+ ? {
1057
+ kind: 'hold',
1058
+ ...(input.reason !== undefined ? { reason: input.reason } : {}),
1059
+ }
1060
+ : input.action === 'priority'
1061
+ ? { kind: 'priority', priority: input.priority! }
1062
+ : { kind: input.action }
717
1063
  return controlBuild({
718
1064
  store: ctx.store,
719
1065
  ...operatorControlTickets({ store: ctx.store, repo: input.repo, backend: ctx.tickets }),
@@ -727,7 +1073,7 @@ export const TOOLS: readonly ToolEntry[] = [
727
1073
  ),
728
1074
  defineTool(
729
1075
  'builds.answer',
730
- 'Answer a blocked build’s open escalations: guidance text, a bare retry, a dismissal of the cited findings, a review-round ceiling, or a spec revision (destructive — replaces the spec). Leaves require an escalation and restart from plan; idle collecting or verification-failed nodes may revise without an escalation and recollect for verification.',
1076
+ 'Answer a blocked build’s open escalations: guidance text, a bare retry, a dismissal of the cited findings, a review-round ceiling, accept-target (answers only a leaf’s target-rewritten escalation: restack its own commits onto the rewritten target), or a spec revision (destructive — replaces the spec). Leaves require an escalation and restart from plan; idle collecting or verification-failed nodes may revise without an escalation and recollect for verification.',
731
1077
  buildsAnswerInput,
732
1078
  'The controlBuild answer result: {kind: "answered", slug, count, resolution, resumed, …} describing how many escalations were answered and with what.',
733
1079
  async (raw, ctx) => {
@@ -757,6 +1103,32 @@ export const TOOLS: readonly ToolEntry[] = [
757
1103
  })
758
1104
  },
759
1105
  ),
1106
+ defineTool(
1107
+ 'builds.reopen',
1108
+ 'Send a settled, unmerged leaf that waits for its merge decision back into execution, keeping its open PR and branch. Feedback alone returns it to implement with the feedback in its phase context; a spec revision (destructive — replaces the spec) restarts it from plan. Merge consent is revoked (a hold stays) and the dispatcher cancels any armed native auto-merge; the leaf then waits for a slot. Refused for integration nodes, optimization attempts, terminal builds, merged or closed PRs (a fixup is a new ticket), leaves still running or blocked (use builds.answer), and pending abort or discard.',
1109
+ buildsReopenInput,
1110
+ 'The controlBuild reopen result: {kind: "reopened", slug, route: "implement" | "plan", event?, specRev?, completedEarlier?}. completedEarlier means this call finished an earlier recorded spec reopen and did not use its own arguments.',
1111
+ async (raw, ctx) => {
1112
+ const input = raw as OperatorReopenRequest & { repo: string; slug: string }
1113
+ await requireRouteBuild(ctx.store, input.repo, input.slug)
1114
+ const { action, readTicketBody } = reopenAction(input)
1115
+ return controlBuild({
1116
+ store: ctx.store,
1117
+ repo: input.repo,
1118
+ slug: input.slug,
1119
+ user: attributed(ctx),
1120
+ ...(ctx.via !== undefined ? { via: ctx.via } : {}),
1121
+ action,
1122
+ ...(readTicketBody !== undefined
1123
+ ? {
1124
+ readTicketBody,
1125
+ prepareTicketAssets: (ref, store, repo) =>
1126
+ prepareOperatorTicketAssets({ ref, store, repo, backend: ctx.tickets }),
1127
+ }
1128
+ : {}),
1129
+ })
1130
+ },
1131
+ ),
760
1132
  defineTool(
761
1133
  'repository.forge_clear',
762
1134
  'Explicitly clear erroneous forge cooldown state with an audited reason; does not prove provider recovery.',
@@ -780,7 +1152,7 @@ export const TOOLS: readonly ToolEntry[] = [
780
1152
  'repository.status',
781
1153
  'Report one repository’s durable dispatcher settings and journal state.',
782
1154
  repositoryStatusInput,
783
- 'The repository status projection: ticket intake, repository-wide pause, claim-time auto-merge default, and the harvest/dispatch journal state the sessionless CLI and dashboard read. operator.presence is "unavailable" here because this tool does not load presence registrations; that is not evidence that no operator is present.',
1155
+ 'The repository status projection: dispatcherRunning is true for a holder, expired holder or unfinished draining handoff; ticket intake, repository-wide pause, claim-time auto-merge default, and the harvest/dispatch journal state the sessionless CLI and dashboard read. operator.presence is "unavailable" here because this tool does not load presence registrations; that is not evidence that no operator is present.',
784
1156
  async (raw, ctx) => {
785
1157
  const input = raw as z.infer<typeof repositoryStatusInput>
786
1158
  return getRepositoryStatus(ctx.store, input.repo)
@@ -800,6 +1172,21 @@ export const TOOLS: readonly ToolEntry[] = [
800
1172
  })
801
1173
  },
802
1174
  ),
1175
+ defineTool(
1176
+ 'repository.attention',
1177
+ 'One read of everything waiting on the operator for a repository — blocked builds with their open escalation questions, merges awaiting consent or held, repository attention events after the cursor, builds paused/stalled/failing verification, and dispatcher attention — each item naming the tool call that resolves it. The first call of each operator round.',
1178
+ repositoryAttentionInput,
1179
+ '{repo, generatedAt, escalations, merges, events: {items, cursor, hasMore}, waiting, dispatcher}. escalations: open builds with open escalations (as builds.get reports them), wait-only builds excluded. merges: the merges.list entries with each build’s PR. events: the repository.events attention page after the cursor; pass events.cursor back next call. waiting: builds paused, stalled (live lease, no durable event for an hour), failing node verification or failing forge CI, each with a reason and detail. dispatcher: no holder, a current upgrade failure, a rollback hold or a forge cooldown from repository.status. Every item carries resolve: [{tool, input, by, note?}], primary first; input is partial, and by "human" means no agent call fixes it — the tool reads the evidence to report. An omitted cursor returns no events and a baseline cursor beside every current-state section; an expired cursor fails with code "cursor-too-old": call again without one.',
1180
+ async (raw, ctx) => {
1181
+ const input = raw as z.infer<typeof repositoryAttentionInput>
1182
+ return getOperatorAttention({
1183
+ store: ctx.store,
1184
+ repo: input.repo,
1185
+ ...(input.cursor !== undefined ? { cursor: input.cursor } : {}),
1186
+ now: ctx.clock(),
1187
+ })
1188
+ },
1189
+ ),
803
1190
  defineTool(
804
1191
  'repository.settings',
805
1192
  'Set or toggle a durable repository setting: ticket intake or the claim-time auto-merge default.',
@@ -928,11 +1315,30 @@ export const TOOLS: readonly ToolEntry[] = [
928
1315
  })
929
1316
  },
930
1317
  ),
1318
+ defineTool(
1319
+ 'tickets.search',
1320
+ 'Search the repository’s tickets by title and body text across every state, to find duplicates before filing. Sources without search refuse; nothing falls back to listing.',
1321
+ ticketsSearchInput,
1322
+ '{tickets, cursor?, diagnostics}: matches as {id, title, state, labels, kind, target?} in source order; cursor continues the search and is absent on the last page.',
1323
+ async (raw, ctx) => {
1324
+ const input = raw as z.infer<typeof ticketsSearchInput>
1325
+ return searchOperatorTickets({
1326
+ store: ctx.store,
1327
+ repo: input.repo,
1328
+ backend: ticketsOf(ctx),
1329
+ query: input.query,
1330
+ ...(input.state !== undefined ? { state: input.state } : {}),
1331
+ ...(input.labels !== undefined ? { labels: input.labels } : {}),
1332
+ ...(input.limit !== undefined ? { limit: input.limit } : {}),
1333
+ ...(input.cursor !== undefined ? { cursor: input.cursor } : {}),
1334
+ })
1335
+ },
1336
+ ),
931
1337
  defineTool(
932
1338
  'tickets.get',
933
- 'Show one ticket with its hosted comments, blockers and any related build.',
1339
+ 'Show one ticket with its hosted comments, blockers, any related build and its current assets.',
934
1340
  ticketDetailInput,
935
- '{ticket, blockers, build}: the ticket (including hosted ticket.comments when available), its dependency states, and the most relevant build for it (null when none).',
1341
+ '{ticket, blockers, build, assets}: the ticket (including hosted ticket.comments when available), its dependency states, the most relevant build for it (null when none), and its current assets as `ab ticket show --json` lists them, each {kind, name, revision, size, layout, fileCount}.',
936
1342
  async (raw, ctx) => {
937
1343
  const input = raw as z.infer<typeof ticketDetailInput>
938
1344
  return getOperatorTicket({
@@ -945,7 +1351,7 @@ export const TOOLS: readonly ToolEntry[] = [
945
1351
  ),
946
1352
  defineTool(
947
1353
  'tickets.create',
948
- 'Create a ticket in the configured source, optionally labelled, pre-blocked, linked to the forge issues it addresses, urgent so it dispatches before normal ready work, assigned (explicit assignees replace the [tickets].createAssignee default), or filed in a nondefault state.',
1354
+ 'Create a ticket in the configured source, optionally labelled (explicit labels are unioned with the [tickets].createLabels default), pre-blocked, linked to the forge issues it addresses, urgent so it dispatches before normal ready work, assigned (explicit assignees replace the [tickets].createAssignee default), or filed in a nondefault state.',
949
1355
  ticketsCreateInput,
950
1356
  '{ticket, blockers, build}: the created ticket and its (usually empty) dependency states.',
951
1357
  async (raw, ctx) => {
@@ -1059,6 +1465,65 @@ export const TOOLS: readonly ToolEntry[] = [
1059
1465
  })
1060
1466
  },
1061
1467
  ),
1468
+ defineTool(
1469
+ 'tickets.start',
1470
+ "Ask the running dispatcher to start one ticket by id, even while intake is off. Records a durable, attributed request that the dispatcher (local or hosted) honours on its next tick with a free slot in the request's priority tier (manual by default, ahead of all waiting work; or urgent, or normal), claiming no other ticket. The claimed build is urgent when priority is urgent, otherwise it keeps its ticket's priority. Every gate still applies: ready state, spec standard, resolved blockers, no active build, capacity and repository pause. Repeating the request with another priority updates the pending request. With cancel, cancels the pending request instead.",
1471
+ ticketsStartInput,
1472
+ 'For a request: {status: "pending", existing, updated, request, priority, requestedAt, ticket, event?} — existing is true when a request for the ticket was already pending; updated is true when its priority was changed to this one (event is the update), and false with no event when nothing was written. For cancel: {cancelled: true, request, ticket, event} or {cancelled: false, id} when nothing was pending. The settlement arrives later as a ticket.start-settled repository event (repository.events) and in repository.status ticketStarts.',
1473
+ async (raw, ctx) => {
1474
+ const input = raw as z.infer<typeof ticketsStartInput>
1475
+ return controlTicketStart({
1476
+ store: ctx.store,
1477
+ repo: input.repo,
1478
+ backend: ticketsOf(ctx),
1479
+ id: input.id,
1480
+ user: attributed(ctx),
1481
+ ...(ctx.via !== undefined ? { via: ctx.via } : {}),
1482
+ ...(input.cancel === true ? { cancel: true } : {}),
1483
+ ...(input.priority !== undefined ? { priority: input.priority } : {}),
1484
+ })
1485
+ },
1486
+ ),
1487
+ defineTool(
1488
+ 'tickets.asset.attach',
1489
+ 'Attach one asset to a ticket by kind and name, like `ab ticket attach`: a single file (layout "file") or a folder (layout "tree"), with every file’s bytes as base64. Each attach stores a new revision; earlier revisions stay retrievable with tickets.asset.get rev. The CLI’s naming, path and layout rules apply, and so does the store’s size limit (25 MiB of file bytes by default, lower on stores with a request ceiling; a remote MCP transport may bound requests lower still). Leaves a note on the ticket. A build freezes its assets at the claim, so a running build keeps the ones it has.',
1490
+ ticketAssetAttachInput,
1491
+ '{asset, replaced, activeBuilds, noteError?}: the stored revision’s metadata (as `ab ticket attach --json` prints it), whether it replaced a current asset of that kind and name, the active builds for the ticket that keep their frozen assets, and noteError when the asset was stored but the note failed (do not retry: that stores another revision).',
1492
+ async (raw, ctx) => {
1493
+ const input = raw as z.infer<typeof ticketAssetAttachInput>
1494
+ attributed(ctx)
1495
+ return attachOperatorTicketAsset({ store: ctx.store, backend: ticketsOf(ctx), ...input })
1496
+ },
1497
+ ),
1498
+ defineTool(
1499
+ 'tickets.asset.get',
1500
+ 'Read one ticket asset, like `ab ticket asset get`: the latest revision, or an exact one by rev. Each file entry carries its exact bytes as base64.',
1501
+ ticketAssetGetInput,
1502
+ '{asset, entries}: the revision’s metadata and its entries in manifest order, each {type: "file", path, size, contentBase64} or {type: "dir", path}. Decode contentBase64 to recover the exact bytes.',
1503
+ async (raw, ctx) => {
1504
+ const input = raw as z.infer<typeof ticketAssetGetInput>
1505
+ return getOperatorTicketAsset({
1506
+ store: ctx.store,
1507
+ backend: ticketsOf(ctx),
1508
+ repo: input.repo,
1509
+ id: input.id,
1510
+ kind: input.kind,
1511
+ name: input.name,
1512
+ ...(input.rev !== undefined ? { rev: input.rev } : {}),
1513
+ })
1514
+ },
1515
+ ),
1516
+ defineTool(
1517
+ 'tickets.asset.remove',
1518
+ 'Destructive: remove one asset from the ticket’s current assets, like `ab ticket asset rm`. Its revisions stay retrievable with tickets.asset.get rev. Leaves a note on the ticket; running builds keep the assets they froze at the claim.',
1519
+ ticketAssetRemoveInput,
1520
+ '{removed, activeBuilds, noteError?}: the metadata of the revision that was current, the active builds for the ticket, and noteError when the asset was removed but the note failed.',
1521
+ async (raw, ctx) => {
1522
+ const input = raw as z.infer<typeof ticketAssetRemoveInput>
1523
+ attributed(ctx)
1524
+ return removeOperatorTicketAsset({ store: ctx.store, backend: ticketsOf(ctx), ...input })
1525
+ },
1526
+ ),
1062
1527
  defineTool(
1063
1528
  'notes.read',
1064
1529
  'Read the repository’s operator-notes artifact — the shared notes an operator agent leaves for the next round.',
@@ -1099,24 +1564,64 @@ export const TOOLS: readonly ToolEntry[] = [
1099
1564
  return { revision: meta.revision, blobRef: meta.blobRef, createdAt: meta.createdAt }
1100
1565
  },
1101
1566
  ),
1567
+ defineTool(
1568
+ 'sandbox.open',
1569
+ 'Open your operator sandbox, a persistent, credential-free environment provisioned from the repository, and return at once. Provisioning or resuming continues in the background; poll sandbox.status until it reports ready. Other sandbox tools refuse with code "sandbox-not-ready" until then. Idempotent: opening a ready or in-flight environment changes nothing.',
1570
+ sandboxOpenInput,
1571
+ '{state, environmentId, provider, baseSha?, failure?}: state is provisioning, resuming, ready, or failed; baseSha is the recorded base head once ready; failure ({stage, message}) explains a failed attempt.',
1572
+ async (raw, ctx) => {
1573
+ const input = raw as z.infer<typeof sandboxOpenInput>
1574
+ return (await sandboxOf(ctx)).open(attributed(ctx), input)
1575
+ },
1576
+ ),
1577
+ defineTool(
1578
+ 'sandbox.status',
1579
+ "Report your operator sandbox's lifecycle state: absent, provisioning, resuming, ready, stopped, or failed, plus the checkout head and the base head recorded at provisioning (or the last refresh or reset). Its only write records a finished background attempt's outcome, exactly once. Safe to poll; it never resumes a stopped environment or keeps an idle one alive.",
1580
+ sandboxStatusInput,
1581
+ "{state, environmentId, provider, headSha?, baseSha?, failure?, lastEvidenceAt?}: the lifecycle state, the checkout head when ready, the recorded base head, a failed attempt's {stage, message}, and the latest journaled evidence time.",
1582
+ async (raw, ctx) => {
1583
+ const input = raw as z.infer<typeof sandboxStatusInput>
1584
+ return (await sandboxOf(ctx)).status(attributed(ctx), input)
1585
+ },
1586
+ ),
1587
+ defineTool(
1588
+ 'sandbox.close',
1589
+ 'Close your operator sandbox: stop the environment and its detached commands and release provider capacity, keeping the checkout and any uncommitted work. A later sandbox.open resumes it. Cancels an in-flight provision. Closing an environment that does not exist succeeds and does nothing.',
1590
+ sandboxCloseInput,
1591
+ '{outcome, environmentId}: outcome is "closed", or "noop" when there was nothing to close.',
1592
+ async (raw, ctx) => {
1593
+ const input = raw as z.infer<typeof sandboxCloseInput>
1594
+ return (await sandboxOf(ctx)).close(attributed(ctx), input)
1595
+ },
1596
+ ),
1597
+ defineTool(
1598
+ 'sandbox.refresh',
1599
+ 'Fast-forward your operator sandbox\'s clean checkout to the current base-branch head and record that head as the publication base. Not destructive: a checkout with uncommitted changes refuses with code "sandbox-refresh-dirty", and one whose commits diverge from the base refuses with code "sandbox-refresh-diverged"; a refusal changes nothing. The environment must be open and ready first (sandbox.open, then sandbox.status); otherwise the call refuses with code "sandbox-not-ready" naming the state.',
1600
+ sandboxRefreshInput,
1601
+ '{outcome, headSha, baseSha, previousHeadSha}: outcome is "refreshed" (fast-forwarded) or "current" (the checkout already contains the base head).',
1602
+ async (raw, ctx) => {
1603
+ const input = raw as z.infer<typeof sandboxRefreshInput>
1604
+ return (await sandboxOf(ctx)).refresh(attributed(ctx), input)
1605
+ },
1606
+ ),
1102
1607
  defineTool(
1103
1608
  'sandbox.exec',
1104
- 'Run one shell command inside your operator sandbox: a persistent, credential-free environment provisioned from the repository (first call provisions; later calls reuse it). The command waits at most 300 seconds; on expiry it is killed and the tool fails with code "sandbox-exec-timeout". Stdout and stderr are each truncated at 65,536 bytes with a "[truncated by autobuild: output exceeded 65536 bytes]" marker. The environment holds no store, forge, or model credentials — the typed tools remain the only route to build state.',
1609
+ 'Run one shell command inside your operator sandbox, a persistent, credential-free environment provisioned from the repository. The environment must be open and ready first (sandbox.open, then sandbox.status); otherwise the call refuses with code "sandbox-not-ready" naming the state. The command waits at most 300 seconds; on expiry it is killed and the tool fails with code "sandbox-exec-timeout". Stdout and stderr are each truncated at 65,536 bytes with a "[truncated by autobuild: output exceeded 65536 bytes]" marker. The environment holds no store, forge, or model credentials — the typed tools remain the only route to build state.',
1105
1610
  sandboxExecInput,
1106
1611
  '{exitCode, stdout, stderr}: the command’s exit status and truncated output streams.',
1107
1612
  async (raw, ctx) => {
1108
1613
  const input = raw as z.infer<typeof sandboxExecInput>
1109
- return sandboxOf(ctx).exec(attributed(ctx), input)
1614
+ return (await sandboxOf(ctx)).exec(attributed(ctx), input)
1110
1615
  },
1111
1616
  ),
1112
1617
  defineTool(
1113
1618
  'sandbox.start',
1114
- 'Launch one shell command detached inside your operator sandbox and return immediately. Pair with sandbox.wait to observe it. Calls against one environment are serialized; a detached command is tracked only by the serving process.',
1619
+ 'Launch one shell command detached inside your operator sandbox and return immediately. Pair with sandbox.wait to observe it. Calls against one environment are serialized; a detached command is tracked only by the serving process. The environment must be open and ready first (sandbox.open, then sandbox.status); otherwise the call refuses with code "sandbox-not-ready" naming the state.',
1115
1620
  sandboxStartInput,
1116
1621
  '{commandId}: the id to pass to sandbox.wait.',
1117
1622
  async (raw, ctx) => {
1118
1623
  const input = raw as z.infer<typeof sandboxStartInput>
1119
- return sandboxOf(ctx).start(attributed(ctx), input)
1624
+ return (await sandboxOf(ctx)).start(attributed(ctx), input)
1120
1625
  },
1121
1626
  ),
1122
1627
  defineTool(
@@ -1126,17 +1631,17 @@ export const TOOLS: readonly ToolEntry[] = [
1126
1631
  '{state, exitCode?, stdout?, stderr?}: the command state; once exited, its exit code and truncated output streams; while running, the streamed output so far when the provider reports it (Vercel reports output only after exit).',
1127
1632
  async (raw, ctx) => {
1128
1633
  const input = raw as z.infer<typeof sandboxWaitInput>
1129
- return sandboxOf(ctx).wait(attributed(ctx), input)
1634
+ return (await sandboxOf(ctx)).wait(attributed(ctx), input)
1130
1635
  },
1131
1636
  ),
1132
1637
  defineTool(
1133
1638
  'sandbox.read_file',
1134
- 'Read one file from your operator sandbox, rooted at the checkout. Absolute paths and ".." escapes are refused.',
1639
+ 'Read one file from your operator sandbox, rooted at the checkout. Absolute paths and ".." escapes are refused. The environment must be open and ready first (sandbox.open, then sandbox.status); otherwise the call refuses with code "sandbox-not-ready" naming the state.',
1135
1640
  sandboxReadFileInput,
1136
1641
  '{encoding, content}: the file bytes — "utf8" when they decode as UTF-8, else "base64".',
1137
1642
  async (raw, ctx) => {
1138
1643
  const input = raw as z.infer<typeof sandboxReadFileInput>
1139
- const bytes = await sandboxOf(ctx).readFile(attributed(ctx), input)
1644
+ const bytes = await (await sandboxOf(ctx)).readFile(attributed(ctx), input)
1140
1645
  const decoded = new TextDecoder('utf-8').decode(bytes)
1141
1646
  if (!decoded.includes('\uFFFD')) {
1142
1647
  return { encoding: 'utf8', content: decoded }
@@ -1146,34 +1651,33 @@ export const TOOLS: readonly ToolEntry[] = [
1146
1651
  ),
1147
1652
  defineTool(
1148
1653
  'sandbox.write_file',
1149
- 'Write one file inside your operator sandbox, rooted at the checkout (parent directories are created). Absolute paths and ".." escapes are refused; content is bounded at 1 MiB after decoding.',
1654
+ 'Write one file inside your operator sandbox, rooted at the checkout (parent directories are created). Absolute paths and ".." escapes are refused; content is bounded at 1 MiB after decoding. The environment must be open and ready first (sandbox.open, then sandbox.status); otherwise the call refuses with code "sandbox-not-ready" naming the state.',
1150
1655
  sandboxWriteFileInput,
1151
1656
  '{path}: the written path, confirming the durable write.',
1152
1657
  async (raw, ctx) => {
1153
1658
  const input = raw as z.infer<typeof sandboxWriteFileInput>
1154
- await sandboxOf(ctx).writeFile(attributed(ctx), input)
1659
+ await (await sandboxOf(ctx)).writeFile(attributed(ctx), input)
1155
1660
  return { path: input.path }
1156
1661
  },
1157
1662
  ),
1158
1663
  defineTool(
1159
1664
  'sandbox.reset',
1160
- 'Destructively reset your operator sandbox: discard every change, purge the environment and its snapshots, and re-provision fresh from the current base branch head. Use when the environment is wedged or its checkout is dirty beyond repair.',
1665
+ 'Destructively reset your operator sandbox: discard every change, purge the environment and its snapshots, and re-provision fresh from the current base branch head. Returns at once while the fresh provision continues in the background; poll sandbox.status until it reports ready. Use when the environment is wedged or its checkout is dirty beyond repair; sandbox.refresh updates a clean checkout without discarding anything.',
1161
1666
  sandboxResetInput,
1162
- '{ok: true}: the environment was released and re-provisioned from the current base head.',
1667
+ '{state, environmentId, provider, baseSha?, failure?}: the sandbox.open result for the fresh provision, normally state "provisioning".',
1163
1668
  async (raw, ctx) => {
1164
1669
  const input = raw as z.infer<typeof sandboxResetInput>
1165
- await sandboxOf(ctx).reset(attributed(ctx), input)
1166
- return { ok: true as const }
1670
+ return (await sandboxOf(ctx)).reset(attributed(ctx), input)
1167
1671
  },
1168
1672
  ),
1169
1673
  defineTool(
1170
1674
  'sandbox.publish',
1171
- "Publish your operator sandbox's work as a pull request: push the checkout's current head commit (or an explicit commit) to your operator's dedicated branch and open or update a PR against the base branch. Refuses when the checkout has uncommitted changes (tracked or untracked; the sandbox's own provisioning marker is excluded), when the commit is not a descendant of the base head recorded at provision or reset time, or when the base branch head itself would be published. The sandbox itself never pushes and holds no credential — the push and PR creation are kernel plumbing; a publication is a durable repository-journal fact. PR only: the base branch is never pushed to.",
1675
+ "Publish your operator sandbox's work as a pull request: push the checkout's current head commit (or an explicit commit) to your operator's dedicated branch and open or update a PR against the base branch. Refuses when the checkout has uncommitted changes (tracked or untracked; the sandbox's own provisioning marker is excluded), when the commit is not a descendant of the base head recorded at provision, refresh, or reset time, or when the base branch head itself would be published. The sandbox itself never pushes and holds no credential — the push and PR creation are kernel plumbing; a publication is a durable repository-journal fact. PR only: the base branch is never pushed to. The environment must be open and ready first (sandbox.open, then sandbox.status); otherwise the call refuses with code \"sandbox-not-ready\" naming the state.",
1172
1676
  sandboxPublishInput,
1173
1677
  '{branch, sha, pr: {number, url, headSha}}: the publication branch, the published commit, and the opened or updated pull request.',
1174
1678
  async (raw, ctx) => {
1175
1679
  const input = raw as z.infer<typeof sandboxPublishInput>
1176
- return sandboxOf(ctx).publish(attributed(ctx), {
1680
+ return (await sandboxOf(ctx)).publish(attributed(ctx), {
1177
1681
  repo: input.repo,
1178
1682
  title: input.title,
1179
1683
  ...(input.body !== undefined ? { body: input.body } : {}),
@@ -1182,6 +1686,29 @@ export const TOOLS: readonly ToolEntry[] = [
1182
1686
  })
1183
1687
  },
1184
1688
  ),
1689
+ defineTool(
1690
+ 'context.list',
1691
+ 'Call first: the repository’s agent context — its skills (name, description, files) and its agent instructions files (AGENTS.md / CLAUDE.md, with scopes and imports), captured from the base branch, and which to load before operating and before ticket work. A repository with no captured context lists the canonical skills bundled with this Autobuild and reports agent instructions absent.',
1692
+ contextListInput,
1693
+ '{repo, source: "captured"|"canonical", commit, baseBranch?, version?, notice?, skills: [{name, description, paths, entry, files}], instructions: [{path, aliases, scope, imports}], imports: [{path, importedBy}], load: {beforeOperating, beforeTicketWork}}: load entries are paths for context.read.',
1694
+ async (raw, ctx) => {
1695
+ const input = raw as z.infer<typeof contextListInput>
1696
+ return contextIndex(await contextViewFor(ctx, input.repo), input.repo)
1697
+ },
1698
+ ),
1699
+ defineTool(
1700
+ 'context.read',
1701
+ 'Read one skill file or agent instructions file from the repository’s agent context, by a path from context.list or a relative link with `from`. A SKILL.md (and any skill file that mentions `ab` commands) returns with a generated preamble that maps each `ab` command it mentions to the tool that performs it, or says it has no tool; an agent instructions file returns with a preamble framing it as the repository’s own file, which takes precedence over Autobuild skills.',
1702
+ contextReadInput,
1703
+ '{path, kind: "skill"|"skill-file"|"instructions"|"import", skill?, scope?, source, commit, text | contentBase64, links: [{href, path}]}: text is the preamble, a "---" line, then the exact file; links are the relative links in the file that resolve to other context files.',
1704
+ async (raw, ctx) => {
1705
+ const input = raw as z.infer<typeof contextReadInput>
1706
+ const outcome = readContextFile(await contextViewFor(ctx, input.repo), input)
1707
+ if (outcome.kind === 'not-found')
1708
+ throw new RouteRefusalError({ kind: 'not-found', error: outcome.message })
1709
+ return outcome.result
1710
+ },
1711
+ ),
1185
1712
  ]
1186
1713
 
1187
1714
  // ── The registry constructor ─────────────────────────────────────────────────
@@ -1189,13 +1716,21 @@ export const TOOLS: readonly ToolEntry[] = [
1189
1716
  export interface RegistryOptions {
1190
1717
  store: BuildStore
1191
1718
  tickets?: OperatorTicketBackend
1192
- /** The operator-sandbox backend; when absent the sandbox tools are
1193
- * neither advertised nor callable (the compatibility case). When present
1194
- * but `canPublish` is false, only `sandbox.publish` is filtered. */
1719
+ /** The operator-sandbox backend; when absent (and `sandboxResolution` is
1720
+ * absent) the sandbox tools are neither advertised nor callable (the
1721
+ * compatibility case). When present but `canPublish` is false, only
1722
+ * `sandbox.publish` is filtered. */
1195
1723
  sandbox?: OperatorSandboxService
1724
+ /** The hosted mode: a declared sandbox capability with no backend yet. The
1725
+ * sandbox tools are served per `operatorToolTable(sandboxResolution)`, and
1726
+ * each call's backend arrives through `ToolContext.sandboxFor`. When both
1727
+ * this and `sandbox` are given, `sandbox` wins. */
1728
+ sandboxResolution?: { canPublish: boolean }
1196
1729
  clock?: Clock
1197
1730
  /** Constrain every call to this repository identity (the `ab mcp --repo` flag). */
1198
1731
  allowedRepo?: string
1732
+ /** The canonical skill loader for the context tools; tests inject one. */
1733
+ canonicalSkills?: () => Promise<CanonicalSkillBundle>
1199
1734
  }
1200
1735
 
1201
1736
  export interface OperatorToolRegistry {
@@ -1239,6 +1774,24 @@ function mapDomainError(error: unknown): RegistryError {
1239
1774
  error: error.message,
1240
1775
  code: 'assignees-unsupported',
1241
1776
  })
1777
+ if (error instanceof TicketAssetValidationError)
1778
+ return new RegistryError('domain', error.message, {
1779
+ kind: 'validation',
1780
+ error: error.message,
1781
+ code: 'ticket-asset-invalid',
1782
+ })
1783
+ if (error instanceof TicketSearchUnsupported)
1784
+ return new RegistryError('domain', error.message, {
1785
+ kind: 'refusal',
1786
+ error: error.message,
1787
+ code: 'search-unsupported',
1788
+ })
1789
+ if (error instanceof TicketSearchCursorInvalid)
1790
+ return new RegistryError('domain', error.message, {
1791
+ kind: 'refusal',
1792
+ error: error.message,
1793
+ code: 'search-cursor-invalid',
1794
+ })
1242
1795
  if (error instanceof TicketOperationError) {
1243
1796
  return new RegistryError('domain', error.message, {
1244
1797
  kind: error.code === 'not-found' ? 'not-found' : 'refusal',
@@ -1261,11 +1814,19 @@ function mapDomainError(error: unknown): RegistryError {
1261
1814
  progress: error.progress,
1262
1815
  })
1263
1816
  }
1817
+ if (error instanceof SandboxUnavailableError) {
1818
+ return new RegistryError('domain', error.message, {
1819
+ kind: 'refusal',
1820
+ error: error.message,
1821
+ code: `sandbox-${error.reason}`,
1822
+ })
1823
+ }
1264
1824
  if (error instanceof SandboxOperationError) {
1265
1825
  return new RegistryError('domain', error.message, {
1266
1826
  kind: 'refusal',
1267
1827
  error: error.message,
1268
1828
  code: `sandbox-${error.stage}`,
1829
+ ...(error.state !== undefined ? { state: error.state } : {}),
1269
1830
  })
1270
1831
  }
1271
1832
  if (error instanceof OperatorQueryError) {
@@ -1286,25 +1847,27 @@ function mapDomainError(error: unknown): RegistryError {
1286
1847
  )
1287
1848
  }
1288
1849
 
1850
+ const sandboxToolNames: ReadonlySet<string> = new Set(
1851
+ Object.keys(OPERATOR_TOOL_ANNOTATIONS).filter((name) => name.startsWith('sandbox.')),
1852
+ )
1853
+
1854
+ /** The served table for a sandbox capability — the one filter rule both
1855
+ * advertisement and dispatch use. Without a capability every sandbox tool is
1856
+ * filtered; with one that cannot publish (no forge or no provider publication
1857
+ * capability), only `sandbox.publish` is filtered. */
1858
+ export function operatorToolTable(sandbox?: { canPublish: boolean }): readonly ToolEntry[] {
1859
+ if (sandbox === undefined) return TOOLS.filter((tool) => !sandboxToolNames.has(tool.name))
1860
+ if (sandbox.canPublish === false) return TOOLS.filter((tool) => tool.name !== 'sandbox.publish')
1861
+ return TOOLS
1862
+ }
1863
+
1289
1864
  /** Bind the closed table to an opened store (and optional ticket and sandbox
1290
1865
  * backends). The returned registry is the in-process binding; every other
1291
1866
  * binding is generated from `entries`. Advertisement and dispatch share ONE
1292
1867
  * table: a filtered tool is neither advertised nor served. */
1293
1868
  export function buildRegistry(options: RegistryOptions): OperatorToolRegistry {
1294
- const sandboxToolNames = new Set(
1295
- Object.keys(OPERATOR_TOOL_ANNOTATIONS).filter((name) => name.startsWith('sandbox.')),
1296
- )
1297
- // Without a sandbox backend every sandbox tool is filtered; with a backend
1298
- // that cannot publish (no forge or no provider publication capability),
1299
- // only `sandbox.publish` is filtered. Filtered tools are absent from
1300
- // `entries` AND from `call()` dispatch.
1301
- const filtered = new Set<string>()
1302
- if (options.sandbox === undefined) {
1303
- for (const name of sandboxToolNames) filtered.add(name)
1304
- } else if (options.sandbox.canPublish === false) {
1305
- filtered.add('sandbox.publish')
1306
- }
1307
- const table = filtered.size === 0 ? TOOLS : TOOLS.filter((tool) => !filtered.has(tool.name))
1869
+ // Filtered tools are absent from `entries` AND from `call()` dispatch.
1870
+ const table = operatorToolTable(options.sandbox ?? options.sandboxResolution)
1308
1871
  return {
1309
1872
  entries: table,
1310
1873
  async call(name, input, partial = {}) {
@@ -1345,10 +1908,13 @@ export function buildRegistry(options: RegistryOptions): OperatorToolRegistry {
1345
1908
  }
1346
1909
  const tickets = partial.tickets ?? options.tickets
1347
1910
  const sandbox = partial.sandbox ?? options.sandbox
1911
+ const canonicalSkills = partial.canonicalSkills ?? options.canonicalSkills
1348
1912
  const ctx: ToolContext = {
1349
1913
  store: partial.store ?? options.store,
1350
1914
  ...(tickets !== undefined ? { tickets } : {}),
1351
1915
  ...(sandbox !== undefined ? { sandbox } : {}),
1916
+ ...(partial.sandboxFor !== undefined ? { sandboxFor: partial.sandboxFor } : {}),
1917
+ ...(canonicalSkills !== undefined ? { canonicalSkills } : {}),
1352
1918
  clock: partial.clock ?? options.clock ?? systemClock,
1353
1919
  ...(identity !== undefined ? { identity } : {}),
1354
1920
  ...(partial.via !== undefined ? { via: partial.via } : {}),