@defrex/autobuild 1.10.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 (250) hide show
  1. package/README.md +1 -1
  2. package/SPEC.md +738 -68
  3. package/bin/ab-dispatch-generation.ts +3 -1
  4. package/docs/accounts.md +2 -1
  5. package/docs/answering-blocked-builds.md +20 -0
  6. package/docs/architecture.md +155 -25
  7. package/docs/build-store.md +10 -7
  8. package/docs/cli.md +33 -1
  9. package/docs/configuration-overview.md +4 -1
  10. package/docs/configuration.md +381 -29
  11. package/docs/dispatcher.md +63 -4
  12. package/docs/forges.md +7 -0
  13. package/docs/integration-tree.md +2 -2
  14. package/docs/operating.md +4 -2
  15. package/docs/operator-api.md +134 -6
  16. package/docs/operator-surfaces.md +85 -0
  17. package/docs/optimization-nodes.md +69 -11
  18. package/docs/plugin-authoring.md +37 -1
  19. package/docs/remote-store-protocol.md +94 -13
  20. package/docs/remote-ticket-protocol.md +40 -0
  21. package/docs/restacking.md +20 -4
  22. package/docs/setup.md +14 -2
  23. package/docs/ticket-dependencies.md +10 -3
  24. package/docs/ticket-sources.md +24 -2
  25. package/docs/tickets.md +7 -1
  26. package/docs/troubleshooting.md +8 -0
  27. package/docs/verification.md +4 -3
  28. package/docs/workspaces.md +3 -0
  29. package/package.json +9 -5
  30. package/packages/core/src/cli/accounts.ts +7 -2
  31. package/packages/core/src/cli/attention.ts +3 -1
  32. package/packages/core/src/cli/binary-direct.ts +2 -0
  33. package/packages/core/src/cli/binary-lifecycle.ts +2 -1
  34. package/packages/core/src/cli/build-control.ts +79 -1
  35. package/packages/core/src/cli/context.ts +4 -0
  36. package/packages/core/src/cli/dashboard/facts.ts +49 -53
  37. package/packages/core/src/cli/dashboard/header.ts +101 -0
  38. package/packages/core/src/cli/dashboard/model.ts +31 -39
  39. package/packages/core/src/cli/dashboard/objective-row.ts +46 -14
  40. package/packages/core/src/cli/dashboard/poll.ts +178 -76
  41. package/packages/core/src/cli/dashboard/render.ts +129 -230
  42. package/packages/core/src/cli/dashboard/row-text.ts +538 -0
  43. package/packages/core/src/cli/dashboard/timeline.ts +288 -0
  44. package/packages/core/src/cli/dashboard/vocabulary.ts +188 -0
  45. package/packages/core/src/cli/dispatch-args.ts +44 -1
  46. package/packages/core/src/cli/dispatch-frontend.ts +29 -38
  47. package/packages/core/src/cli/dispatch-launch-stop.ts +18 -0
  48. package/packages/core/src/cli/dispatch-launcher.ts +20 -7
  49. package/packages/core/src/cli/dispatch-web.ts +155 -0
  50. package/packages/core/src/cli/dispatch.ts +200 -34
  51. package/packages/core/src/cli/help.ts +87 -3
  52. package/packages/core/src/cli/init-validation.ts +3 -3
  53. package/packages/core/src/cli/main.ts +70 -6
  54. package/packages/core/src/cli/mcp.ts +35 -3
  55. package/packages/core/src/cli/objective.ts +1 -1
  56. package/packages/core/src/cli/operator-preference.ts +57 -0
  57. package/packages/core/src/cli/repo-lease.ts +2 -0
  58. package/packages/core/src/cli/repo-state.ts +56 -6
  59. package/packages/core/src/cli/repository-status.ts +97 -43
  60. package/packages/core/src/cli/status.ts +82 -1
  61. package/packages/core/src/cli/terminal-restore.ts +32 -7
  62. package/packages/core/src/cli/ticket.ts +98 -36
  63. package/packages/core/src/cli/wait.ts +14 -6
  64. package/packages/core/src/cli/watch.ts +20 -4
  65. package/packages/core/src/cli/web.ts +139 -0
  66. package/packages/core/src/config/live.ts +99 -14
  67. package/packages/core/src/config/load.ts +61 -20
  68. package/packages/core/src/config/local.ts +212 -0
  69. package/packages/core/src/config/pipeline-source.ts +2 -0
  70. package/packages/core/src/config/reference.ts +18 -0
  71. package/packages/core/src/config/schema.ts +45 -10
  72. package/packages/core/src/events/catalog.ts +4 -0
  73. package/packages/core/src/events/payloads.ts +97 -0
  74. package/packages/core/src/events/policy.ts +10 -0
  75. package/packages/core/src/events/repository.ts +46 -3
  76. package/packages/core/src/kernel/__snapshots__/reducer-accumulator-shapes.json +316 -0
  77. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/017d8dd5bb6dd80b.json.gz +0 -0
  78. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/178e12f1759b7552.json.gz +0 -0
  79. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/4932c70a2af97faf.json.gz +0 -0
  80. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/536085773daf6b58.json.gz +0 -0
  81. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/6bd6275061aaffa5.json.gz +0 -0
  82. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/89625654b02e9ac1.json.gz +0 -0
  83. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/a98af134be2da8a9.json.gz +0 -0
  84. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/d5d5ccca80a893d8.json.gz +0 -0
  85. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/f8155387eb5f375c.json.gz +0 -0
  86. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/3c27f918b194e3b3.json +465 -0
  87. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/79f0e0f4ccd43ba2.json +455 -0
  88. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/859c09edac738823.json +1086 -0
  89. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/a283c1f3462b1cc1.json +81 -0
  90. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/a6e570fb126991ff.json +36 -0
  91. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/a8acf22c968b6e3d.json +81 -0
  92. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/ba7b85895bf6698e.json +1153 -0
  93. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/fc66408cde0b6b04.json +637 -0
  94. package/packages/core/src/kernel/build-roster.ts +230 -0
  95. package/packages/core/src/kernel/dispatch-capacity.ts +4 -2
  96. package/packages/core/src/kernel/engine.ts +43 -5
  97. package/packages/core/src/kernel/execution-intervals.ts +61 -0
  98. package/packages/core/src/kernel/generators/optimization-log.ts +101 -0
  99. package/packages/core/src/kernel/generators/repository-journals.ts +13 -0
  100. package/packages/core/src/kernel/leaf-restack-base.ts +33 -7
  101. package/packages/core/src/kernel/leaf-restack-state.ts +82 -3
  102. package/packages/core/src/kernel/log-index.ts +19 -0
  103. package/packages/core/src/kernel/optimization-admission.ts +244 -3
  104. package/packages/core/src/kernel/optimization.ts +183 -4
  105. package/packages/core/src/kernel/phase-failures.ts +121 -0
  106. package/packages/core/src/kernel/published-branch-head.ts +60 -0
  107. package/packages/core/src/kernel/reducer-registry.ts +27 -8
  108. package/packages/core/src/kernel/reducer-revisions.ts +25 -0
  109. package/packages/core/src/kernel/reducer.ts +63 -4
  110. package/packages/core/src/kernel/rollup.ts +61 -0
  111. package/packages/core/src/kernel/setup-streak.ts +38 -0
  112. package/packages/core/src/kernel/step-durations.ts +257 -0
  113. package/packages/core/src/kernel/target-observation.ts +6 -1
  114. package/packages/core/src/kernel/target-rewrite-recovery.ts +116 -0
  115. package/packages/core/src/kernel/verify-diff-base.ts +5 -0
  116. package/packages/core/src/kernel/verify-stages.ts +13 -3
  117. package/packages/core/src/ontology.ts +5 -0
  118. package/packages/core/src/operator/agent-context-serve.ts +631 -0
  119. package/packages/core/src/operator/annotations.ts +75 -5
  120. package/packages/core/src/operator/attention.ts +470 -0
  121. package/packages/core/src/operator/canonical-skills.ts +35 -0
  122. package/packages/core/src/operator/cli-equivalents.ts +270 -0
  123. package/packages/core/src/operator/context-prompts.ts +61 -0
  124. package/packages/core/src/operator/index.ts +49 -1
  125. package/packages/core/src/operator/landings.ts +28 -19
  126. package/packages/core/src/operator/optimization.ts +7 -0
  127. package/packages/core/src/operator/protocol.ts +3 -0
  128. package/packages/core/src/operator/query.ts +122 -72
  129. package/packages/core/src/operator/read-view.ts +5 -2
  130. package/packages/core/src/operator/registry.ts +406 -46
  131. package/packages/core/src/operator/requests.ts +20 -18
  132. package/packages/core/src/operator/sandbox-host.ts +107 -11
  133. package/packages/core/src/operator/sandbox-resolver.ts +253 -0
  134. package/packages/core/src/operator/sandbox.ts +778 -82
  135. package/packages/core/src/operator/ticket-asset-list.ts +77 -0
  136. package/packages/core/src/operator/ticket-assets.ts +167 -0
  137. package/packages/core/src/operator/tickets.ts +33 -2
  138. package/packages/core/src/plugin-sdk/index.ts +22 -0
  139. package/packages/core/src/plugins/manifest.ts +1 -1
  140. package/packages/core/src/ports/forge/fake.ts +92 -1
  141. package/packages/core/src/ports/forge/git-blob.ts +15 -0
  142. package/packages/core/src/ports/forge/github.ts +82 -0
  143. package/packages/core/src/ports/forge/local-git.ts +61 -1
  144. package/packages/core/src/ports/forge-failure.ts +24 -0
  145. package/packages/core/src/ports/runner/antigravity-test.fixture.ts +149 -0
  146. package/packages/core/src/ports/runner/claude-test.fixture.ts +71 -0
  147. package/packages/core/src/ports/runner/codex-test.fixture.ts +63 -0
  148. package/packages/core/src/ports/tickets/contract.ts +71 -0
  149. package/packages/core/src/ports/tickets/fake.ts +11 -0
  150. package/packages/core/src/ports/tickets/file.ts +18 -0
  151. package/packages/core/src/ports/tickets/github-fake.ts +136 -4
  152. package/packages/core/src/ports/tickets/github.ts +387 -30
  153. package/packages/core/src/ports/tickets/hosted-index.ts +10 -0
  154. package/packages/core/src/ports/tickets/linear.ts +130 -0
  155. package/packages/core/src/ports/tickets/priority.ts +9 -0
  156. package/packages/core/src/ports/tickets/remote-protocol.ts +34 -0
  157. package/packages/core/src/ports/tickets/remote.ts +70 -6
  158. package/packages/core/src/ports/tickets/search.ts +139 -0
  159. package/packages/core/src/ports/types.ts +104 -2
  160. package/packages/core/src/ports/workspace/builtin-capabilities.ts +9 -0
  161. package/packages/core/src/ports/workspace/create.ts +15 -1
  162. package/packages/core/src/ports/workspace/fake.ts +340 -12
  163. package/packages/core/src/ports/workspace/git-worktree.ts +833 -42
  164. package/packages/core/src/ports/workspace/operator-sandbox.ts +129 -12
  165. package/packages/core/src/ports/workspace/process-group.ts +48 -0
  166. package/packages/core/src/ports/workspace/vercel-sandbox.ts +1260 -123
  167. package/packages/core/src/processes/agent-context-assemble.ts +576 -0
  168. package/packages/core/src/processes/agent-context.ts +469 -0
  169. package/packages/core/src/processes/build-runner.ts +387 -236
  170. package/packages/core/src/processes/dispatcher.ts +211 -55
  171. package/packages/core/src/processes/execution-no-progress.ts +4 -0
  172. package/packages/core/src/processes/optimization-activity.ts +120 -0
  173. package/packages/core/src/processes/phase-failure-budget.ts +1 -0
  174. package/packages/core/src/processes/repo-view.ts +78 -2
  175. package/packages/core/src/processes/sandbox-state.ts +53 -6
  176. package/packages/core/src/processes/tick-publication.ts +2 -0
  177. package/packages/core/src/processes/workspace-preparation.ts +76 -0
  178. package/packages/core/src/scenarios/harness.ts +0 -5
  179. package/packages/core/src/store/account-redaction.ts +1 -0
  180. package/packages/core/src/store/adapter.ts +52 -1
  181. package/packages/core/src/store/agent-context.ts +432 -0
  182. package/packages/core/src/store/build-feed.ts +291 -0
  183. package/packages/core/src/store/build-scope.ts +19 -1
  184. package/packages/core/src/store/contract.ts +911 -14
  185. package/packages/core/src/store/digest.ts +19 -6
  186. package/packages/core/src/store/histogram.ts +113 -0
  187. package/packages/core/src/store/local/schema.ts +62 -0
  188. package/packages/core/src/store/local/store.ts +628 -22
  189. package/packages/core/src/store/local/ticket-asset-heads.ts +23 -0
  190. package/packages/core/src/store/memory.ts +461 -69
  191. package/packages/core/src/store/open-builds.ts +19 -0
  192. package/packages/core/src/store/phase-session.ts +32 -4
  193. package/packages/core/src/store/reduced-reads.ts +14 -4
  194. package/packages/core/src/store/reducer-value-shapes.json +6987 -5749
  195. package/packages/core/src/store/reducer-values.ts +6 -1
  196. package/packages/core/src/store/remote/client.ts +208 -2
  197. package/packages/core/src/store/remote/compatibility.ts +1 -1
  198. package/packages/core/src/store/remote/index.ts +33 -0
  199. package/packages/core/src/store/remote/protocol.ts +69 -0
  200. package/packages/core/src/store/remote/released-clients.json +11 -0
  201. package/packages/core/src/store/remote/released-reducer-values/1.11.0.json +35680 -0
  202. package/packages/core/src/store/remote/released-reducer-values/index.ts +18 -16
  203. package/packages/core/src/store/retention.ts +23 -1
  204. package/packages/core/src/store/rollups.ts +337 -0
  205. package/packages/core/src/store/session-handle.ts +20 -2
  206. package/packages/core/src/store/snapshots.ts +10 -0
  207. package/packages/core/src/store/types.ts +108 -9
  208. package/packages/core/src/testing/dispatch-read-budget.ts +1092 -2
  209. package/packages/core/src/testing/git-config-isolation.ts +7 -5
  210. package/packages/core/src/testing/index.ts +27 -0
  211. package/packages/core/src/testing/memory-operator-sandbox.ts +346 -0
  212. package/packages/core/src/testing/reduced-read-budget.ts +1873 -98
  213. package/packages/core/src/web/analytics-source.ts +303 -0
  214. package/packages/core/src/web/assets/Atkinson-OFL.txt +93 -0
  215. package/packages/core/src/web/assets/AtkinsonHyperlegibleNext.latin.woff2 +0 -0
  216. package/packages/core/src/web/assets/JetBrains-OFL.txt +93 -0
  217. package/packages/core/src/web/assets/JetBrainsMono.latin.woff2 +0 -0
  218. package/packages/core/src/web/assets/app.css +1 -0
  219. package/packages/core/src/web/assets/app.js +9 -0
  220. package/packages/core/src/web/assets/manifest.json +31 -0
  221. package/packages/core/src/web/assets/theme.js +1 -0
  222. package/packages/core/src/web/bounded.ts +31 -0
  223. package/packages/core/src/web/http.ts +315 -0
  224. package/packages/core/src/web/hub.ts +160 -0
  225. package/packages/core/src/web/options.ts +38 -0
  226. package/packages/core/src/web/overview-source.ts +322 -0
  227. package/packages/core/src/web/page.ts +56 -0
  228. package/packages/core/src/web/protocol.ts +151 -0
  229. package/packages/core/src/web/read-only.ts +23 -0
  230. package/packages/core/src/web/repository-source.ts +35 -0
  231. package/packages/core/src/web/server.ts +97 -0
  232. package/skills/code-review/SKILL.md +10 -2
  233. package/skills/guide/SKILL.md +366 -52
  234. package/skills/guide/references/accounts.md +2 -1
  235. package/skills/guide/references/integration-tree.md +2 -2
  236. package/skills/guide/references/operator-api.md +134 -6
  237. package/skills/guide/references/optimization-nodes.md +69 -11
  238. package/skills/guide/references/plugin-authoring.md +37 -1
  239. package/skills/guide/references/remote-store-protocol.md +94 -13
  240. package/skills/guide/references/remote-ticket-protocol.md +40 -0
  241. package/skills/guide/references/restacking.md +20 -4
  242. package/skills/guide/references/setup.md +14 -2
  243. package/skills/guide/references/ticket-dependencies.md +10 -3
  244. package/skills/implement/SKILL.md +23 -4
  245. package/skills/operate/SKILL.md +134 -32
  246. package/skills/plan/SKILL.md +10 -4
  247. package/skills/plan-review/SKILL.md +9 -2
  248. package/skills/spec/SKILL.md +34 -8
  249. package/skills/tickets/SKILL.md +51 -5
  250. package/templates/hosted-service/package.json +2 -2
@@ -0,0 +1,270 @@
1
+ /**
2
+ * The checked-in map between the `ab` CLI and the operator tool registry.
3
+ *
4
+ * A connected agent reads skills written for agents with a shell. The
5
+ * context tools (`context.read`) prepend a generated preamble that maps every
6
+ * `ab` command a text mentions onto the tool that performs it, or says why no
7
+ * tool does. The mapping lives here, never in a skill, so it cannot drift
8
+ * from the registry: a unit test holds every tool to a declaration and every
9
+ * declared or classified command to the help catalog (`cli/help.ts`).
10
+ */
11
+ import type { OperatorToolName } from './annotations'
12
+
13
+ /** One CLI form a tool performs. `command` is the full spelling
14
+ * (`ab ticket create`); `note` names the argument or flag that selects it. */
15
+ export interface CliEquivalent {
16
+ command: string
17
+ note?: string
18
+ }
19
+
20
+ /** Every tool declares its CLI forms, or `none` with the reason no command
21
+ * performs it. `aliasOf` marks a deprecated tool alias the preamble skips. */
22
+ export type ToolCliDeclaration =
23
+ | { cli: readonly CliEquivalent[]; aliasOf?: OperatorToolName }
24
+ | { none: string }
25
+
26
+ export const OPERATOR_TOOL_CLI: Record<OperatorToolName, ToolCliDeclaration> = {
27
+ 'merges.list': { cli: [{ command: 'ab merges' }] },
28
+ 'landings.list': { cli: [{ command: 'ab merges' }], aliasOf: 'merges.list' },
29
+ 'tickets.tree': { cli: [{ command: 'ab ticket tree' }] },
30
+ 'builds.list': { cli: [{ command: 'ab builds' }] },
31
+ 'builds.get': { cli: [{ command: 'ab build status' }] },
32
+ 'builds.events': {
33
+ cli: [
34
+ { command: 'ab build status', note: 'the --events tail, paged by cursor' },
35
+ { command: 'ab wait', note: 'poll with cursor and waitSeconds' },
36
+ { command: 'ab watch', note: 'named slugs; poll with cursor' },
37
+ ],
38
+ },
39
+ 'builds.artifact': {
40
+ cli: [{ command: 'ab artifact download', note: 'returns contentBase64 instead of --output' }],
41
+ },
42
+ 'builds.restack': { cli: [{ command: 'ab restack' }] },
43
+ 'optimization.revise': { cli: [{ command: 'ab objective', note: 'the revision flags' }] },
44
+ 'optimization.stop': { cli: [{ command: 'ab objective', note: '--stop' }] },
45
+ 'optimization.settle-unmeasured': {
46
+ cli: [{ command: 'ab objective', note: '--settle-unmeasured' }],
47
+ },
48
+ 'builds.control': {
49
+ cli: [
50
+ { command: 'ab pause', note: 'action: "pause"' },
51
+ { command: 'ab resume', note: 'action: "resume"' },
52
+ { command: 'ab abort', note: 'action: "abort"' },
53
+ { command: 'ab merge', note: 'action: "merge"' },
54
+ { command: 'ab hold', note: 'action: "hold"' },
55
+ { command: 'ab priority', note: 'action: "priority"' },
56
+ ],
57
+ },
58
+ 'builds.answer': { cli: [{ command: 'ab answer' }] },
59
+ 'builds.reopen': { cli: [{ command: 'ab reopen' }] },
60
+ 'repository.forge_clear': { cli: [{ command: 'ab repository forge-clear' }] },
61
+ 'repository.status': { cli: [{ command: 'ab repository status' }] },
62
+ 'repository.events': {
63
+ cli: [{ command: 'ab watch', note: 'the repository journal; poll with cursor' }],
64
+ },
65
+ 'repository.attention': {
66
+ none: 'the attention digest has no CLI form; it gathers what ab watch and ab repository status show',
67
+ },
68
+ 'repository.settings': {
69
+ none: 'ticket intake and the auto-merge default are dispatcher flags and dashboard toggles',
70
+ },
71
+ 'repository.bulk_control': {
72
+ cli: [
73
+ { command: 'ab pause', note: '--all; action: "pause"' },
74
+ { command: 'ab resume', note: '--all; action: "resume"' },
75
+ ],
76
+ },
77
+ 'harvest.status': { cli: [{ command: 'ab harvest status' }] },
78
+ 'harvest.control': { none: 'harvest gate and run controls are dashboard actions' },
79
+ 'tickets.states': { cli: [{ command: 'ab ticket states' }] },
80
+ 'tickets.state.create': { cli: [{ command: 'ab ticket state create' }] },
81
+ 'tickets.list': { cli: [{ command: 'ab ticket list' }] },
82
+ 'tickets.search': { cli: [{ command: 'ab ticket search' }] },
83
+ 'tickets.get': { cli: [{ command: 'ab ticket show' }] },
84
+ 'tickets.create': { cli: [{ command: 'ab ticket create', note: 'body as text, not a file' }] },
85
+ 'tickets.update': {
86
+ cli: [
87
+ { command: 'ab ticket update', note: 'body as text, not a file' },
88
+ { command: 'ab ticket edit', note: 'pass the changed fields' },
89
+ ],
90
+ },
91
+ 'tickets.block': { cli: [{ command: 'ab ticket block' }] },
92
+ 'tickets.unblock': { cli: [{ command: 'ab ticket unblock' }] },
93
+ 'tickets.move': { cli: [{ command: 'ab ticket move' }] },
94
+ 'tickets.start': { cli: [{ command: 'ab start' }] },
95
+ 'tickets.asset.attach': {
96
+ cli: [{ command: 'ab ticket attach', note: 'files as base64 entries' }],
97
+ },
98
+ 'tickets.asset.get': { cli: [{ command: 'ab ticket asset get', note: 'returns base64' }] },
99
+ 'tickets.asset.remove': { cli: [{ command: 'ab ticket asset rm' }] },
100
+ 'notes.read': { none: 'operator notes are reachable only through the tools' },
101
+ 'notes.write': { none: 'operator notes are reachable only through the tools' },
102
+ 'sandbox.open': { none: 'the sandbox is a connected agent’s checkout; no command manages it' },
103
+ 'sandbox.status': { none: 'the sandbox is a connected agent’s checkout; no command manages it' },
104
+ 'sandbox.close': { none: 'the sandbox is a connected agent’s checkout; no command manages it' },
105
+ 'sandbox.refresh': { none: 'the sandbox is a connected agent’s checkout; no command manages it' },
106
+ 'sandbox.exec': { none: 'runs a shell command in the sandbox' },
107
+ 'sandbox.start': { none: 'runs a shell command in the sandbox' },
108
+ 'sandbox.wait': { none: 'runs a shell command in the sandbox' },
109
+ 'sandbox.read_file': { none: 'reads a file in the sandbox' },
110
+ 'sandbox.write_file': { none: 'writes a file in the sandbox' },
111
+ 'sandbox.reset': { none: 'the sandbox is a connected agent’s checkout; no command manages it' },
112
+ 'sandbox.publish': { none: 'the sandbox is a connected agent’s checkout; no command manages it' },
113
+ 'context.list': { none: 'a checkout reads its skills and agent instructions directly' },
114
+ 'context.read': { none: 'a checkout reads its skills and agent instructions directly' },
115
+ }
116
+
117
+ /** Where a command with no tool can run, from a connected agent's seat:
118
+ * - `sandbox`: works from a checkout with no store credential and no session,
119
+ * so `sandbox.exec` can run it;
120
+ * - `build-session`: a phase or harvest session's own command;
121
+ * - `host`: needs store credentials, a dispatcher or the maintainer's
122
+ * machine. */
123
+ export type CliAvailability = 'sandbox' | 'build-session' | 'host'
124
+
125
+ export const CLI_WITHOUT_TOOL: readonly {
126
+ command: string
127
+ availability: CliAvailability
128
+ note?: string
129
+ }[] = [
130
+ { command: 'ab help', availability: 'sandbox' },
131
+ { command: 'ab init', availability: 'sandbox' },
132
+ { command: 'ab plugin', availability: 'sandbox' },
133
+ { command: 'ab context', availability: 'build-session' },
134
+ { command: 'ab artifact', availability: 'build-session' },
135
+ { command: 'ab observe', availability: 'build-session' },
136
+ { command: 'ab issue', availability: 'build-session' },
137
+ { command: 'ab done', availability: 'build-session' },
138
+ { command: 'ab verdict', availability: 'build-session' },
139
+ { command: 'ab propose', availability: 'build-session' },
140
+ { command: 'ab escalate', availability: 'build-session' },
141
+ { command: 'ab wait-on', availability: 'build-session' },
142
+ { command: 'ab judge', availability: 'build-session' },
143
+ { command: 'ab harvest', availability: 'build-session' },
144
+ { command: 'ab dispatch', availability: 'host' },
145
+ { command: 'ab upgrade', availability: 'host' },
146
+ { command: 'ab connect', availability: 'host' },
147
+ { command: 'ab disconnect', availability: 'host' },
148
+ { command: 'ab accounts', availability: 'host' },
149
+ { command: 'ab secrets', availability: 'host' },
150
+ { command: 'ab web', availability: 'host' },
151
+ { command: 'ab mcp', availability: 'host' },
152
+ { command: 'ab operator', availability: 'host' },
153
+ { command: 'ab models', availability: 'host' },
154
+ { command: 'ab ticket export', availability: 'host' },
155
+ { command: 'ab ticket import', availability: 'host' },
156
+ { command: 'ab ticket migration', availability: 'host' },
157
+ { command: 'ab build asset', availability: 'host', note: 'a build’s frozen asset copy' },
158
+ ]
159
+
160
+ /** Spellings the CLI accepts for another command. */
161
+ export const CLI_COMMAND_ALIASES: Readonly<Record<string, string>> = {
162
+ 'ab land': 'ab merge',
163
+ 'ab landings': 'ab merges',
164
+ 'ab update': 'ab upgrade',
165
+ }
166
+
167
+ interface CommandTarget {
168
+ tool: OperatorToolName
169
+ note?: string
170
+ }
171
+
172
+ function toolTargets(): Map<string, CommandTarget[]> {
173
+ const targets = new Map<string, CommandTarget[]>()
174
+ for (const [tool, declaration] of Object.entries(OPERATOR_TOOL_CLI) as [
175
+ OperatorToolName,
176
+ ToolCliDeclaration,
177
+ ][]) {
178
+ if (!('cli' in declaration) || declaration.aliasOf !== undefined) continue
179
+ for (const { command, note } of declaration.cli) {
180
+ const list = targets.get(command) ?? []
181
+ list.push({ tool, ...(note !== undefined ? { note } : {}) })
182
+ targets.set(command, list)
183
+ }
184
+ }
185
+ return targets
186
+ }
187
+
188
+ const TARGETS = toolTargets()
189
+ const WITHOUT = new Map(CLI_WITHOUT_TOOL.map((entry) => [entry.command, entry]))
190
+
191
+ /** Every command this module knows: tool-mapped and tool-less. */
192
+ export function knownCliCommands(): string[] {
193
+ return [...new Set([...TARGETS.keys(), ...WITHOUT.keys()])]
194
+ }
195
+
196
+ /** Top-level command words (`ticket`, `build`, …) that the table covers,
197
+ * directly or through a subcommand. */
198
+ const TOP_LEVEL: ReadonlySet<string> = new Set(
199
+ [...knownCliCommands(), ...Object.keys(CLI_COMMAND_ALIASES)].map(
200
+ (command) => command.split(' ')[1]!,
201
+ ),
202
+ )
203
+
204
+ /** The command families (`ab ticket`) whose subcommands map to tools but
205
+ * which have no declaration of their own. */
206
+ function familyTools(command: string): string[] {
207
+ const families = new Set<string>()
208
+ for (const [known, targets] of TARGETS)
209
+ if (known.startsWith(`${command} `))
210
+ for (const target of targets) families.add(target.tool.split('.')[0]!)
211
+ return [...families]
212
+ }
213
+
214
+ function resolve(mention: string): string | undefined {
215
+ const words = mention.split(' ')
216
+ for (let length = words.length; length >= 2; length--) {
217
+ const candidate = words.slice(0, length).join(' ')
218
+ const aliased = CLI_COMMAND_ALIASES[candidate] ?? candidate
219
+ if (TARGETS.has(aliased) || WITHOUT.has(aliased)) return aliased
220
+ if (length === 2 && familyTools(aliased).length > 0) return aliased
221
+ }
222
+ return undefined
223
+ }
224
+
225
+ const MENTION = /(?<![\w./-])ab ((?:[a-z][a-z-]*)(?: [a-z][a-z-]*)*)/g
226
+
227
+ /** The distinct known `ab` commands a text mentions, in first-mention order.
228
+ * A mention resolves to the longest known command that prefixes it (through
229
+ * the CLI's own aliases); one whose first word is no known command is prose
230
+ * ("ab over") and is ignored. */
231
+ export function cliMentions(text: string): string[] {
232
+ const seen = new Set<string>()
233
+ for (const match of text.matchAll(MENTION)) {
234
+ const mention = `ab ${match[1]!}`
235
+ if (!TOP_LEVEL.has(mention.split(' ')[1]!)) continue
236
+ const command = resolve(mention)
237
+ if (command !== undefined) seen.add(command)
238
+ }
239
+ return [...seen]
240
+ }
241
+
242
+ function availabilityLine(availability: CliAvailability): string {
243
+ switch (availability) {
244
+ case 'sandbox':
245
+ return 'no tool: run it inside the sandbox with `sandbox.exec` (no store credentials there)'
246
+ case 'build-session':
247
+ return 'no tool: build sessions only; it does not apply to you'
248
+ case 'host':
249
+ return 'no tool: runs on the maintainer’s host with store credentials; ask a human'
250
+ }
251
+ }
252
+
253
+ /** One markdown line per command: the tools that perform it, or why none
254
+ * does. Commands come from `cliMentions`. */
255
+ export function renderCliMapping(commands: readonly string[]): string[] {
256
+ return commands.map((command) => {
257
+ const targets = TARGETS.get(command)
258
+ if (targets !== undefined) {
259
+ const tools = targets
260
+ .map(({ tool, note }) => `\`${tool}\`${note !== undefined ? ` (${note})` : ''}`)
261
+ .join(' or ')
262
+ return `- \`${command}\` → ${tools}`
263
+ }
264
+ const without = WITHOUT.get(command)
265
+ if (without !== undefined)
266
+ return `- \`${command}\` → ${availabilityLine(without.availability)}${without.note !== undefined ? ` (${without.note})` : ''}`
267
+ const families = familyTools(command)
268
+ return `- \`${command} …\` → the ${families.map((family) => `\`${family}.*\``).join(' and ')} tools`
269
+ })
270
+ }
@@ -0,0 +1,61 @@
1
+ /**
2
+ * MCP prompts for the agent context (#1225): one prompt per skill, whose
3
+ * messages are exactly the `context.read` text of the skill's SKILL.md. The
4
+ * hosted endpoints and `ab mcp` register them through this one helper, so
5
+ * naming and lookup cannot drift between bindings.
6
+ *
7
+ * `prompts/get` never parses a repository out of a name: it recomputes the
8
+ * listing for the repositories whose label matches the name's label and
9
+ * matches the name exactly.
10
+ */
11
+ import type { Server } from '@modelcontextprotocol/sdk/server/index.js'
12
+ import {
13
+ ErrorCode,
14
+ GetPromptRequestSchema,
15
+ ListPromptsRequestSchema,
16
+ McpError,
17
+ } from '@modelcontextprotocol/sdk/types.js'
18
+ import {
19
+ contextPromptMessages,
20
+ contextPrompts,
21
+ promptNameLabel,
22
+ type ContextIndex,
23
+ type ContextReadResult,
24
+ } from './agent-context-serve'
25
+
26
+ export interface ContextPromptSource {
27
+ /** True on a binding that serves one repository (names omit the label). */
28
+ scoped: boolean
29
+ /** The indexes in scope. `label` narrows a deployment binding to the
30
+ * repositories whose prompt label equals it. */
31
+ indexes(label?: string): Promise<{ repo: string; index: ContextIndex }[]>
32
+ read(repo: string, path: string): Promise<ContextReadResult>
33
+ }
34
+
35
+ export function registerContextPrompts(server: Server, source: ContextPromptSource): void {
36
+ server.registerCapabilities({ prompts: {} })
37
+ server.setRequestHandler(ListPromptsRequestSchema, async () => {
38
+ const prompts = contextPrompts(await source.indexes(), { scoped: source.scoped })
39
+ return {
40
+ prompts: prompts.map((prompt) => ({ name: prompt.name, description: prompt.description })),
41
+ }
42
+ })
43
+ server.setRequestHandler(GetPromptRequestSchema, async (request) => {
44
+ const name = request.params.name
45
+ const scope = await source
46
+ .indexes(source.scoped ? undefined : promptNameLabel(name))
47
+ .catch(() => [])
48
+ const prompt = contextPrompts(scope, { scoped: source.scoped }).find(
49
+ (candidate) => candidate.name === name,
50
+ )
51
+ if (prompt === undefined)
52
+ throw new McpError(ErrorCode.InvalidParams, `unknown prompt "${name}"`)
53
+ let result: ContextReadResult
54
+ try {
55
+ result = await source.read(prompt.repo, prompt.entry)
56
+ } catch {
57
+ throw new McpError(ErrorCode.InvalidParams, `prompt "${name}" is unavailable right now`)
58
+ }
59
+ return { description: prompt.description, messages: contextPromptMessages(result) }
60
+ })
61
+ }
@@ -56,8 +56,15 @@ export {
56
56
  OperatorQueryError,
57
57
  OrchestratorConfigError,
58
58
  orchestratorConfig,
59
+ readOrchestratorGate,
60
+ sandboxToolsListed,
61
+ type OrchestratorGate,
59
62
  } from './query'
60
- export type { OrchestratorConfig } from '../config/schema'
63
+ export {
64
+ orchestratorEnabled,
65
+ type OrchestratorConfig,
66
+ type OrchestratorHost,
67
+ } from '../config/schema'
61
68
  export { randomIds } from '../ids'
62
69
  export type { Config } from '../config/schema'
63
70
  export {
@@ -65,6 +72,7 @@ export {
65
72
  TOOLS,
66
73
  attributed,
67
74
  buildRegistry,
75
+ operatorToolTable,
68
76
  RegistryError,
69
77
  } from './registry'
70
78
  export type {
@@ -88,7 +96,14 @@ export type {
88
96
  OperatorTicketDetail,
89
97
  OperatorTicketPage,
90
98
  OperatorTicketQueue,
99
+ OperatorTicketView,
91
100
  } from './tickets'
101
+ export type { OperatorTicketAsset, OperatorTicketAssetEntry } from './ticket-assets'
102
+ export {
103
+ attachOperatorTicketAsset,
104
+ getOperatorTicketAsset,
105
+ removeOperatorTicketAsset,
106
+ } from './ticket-assets'
92
107
  export {
93
108
  openOperatorTickets,
94
109
  operatorControlTickets,
@@ -98,10 +113,20 @@ export {
98
113
  getOperatorTicket,
99
114
  listOperatorTickets,
100
115
  mutateOperatorTicket,
116
+ searchOperatorTickets,
101
117
  } from './tickets'
118
+ export { TicketSearchCursorInvalid, TicketSearchUnsupported } from '../ports/tickets/search'
102
119
  export { cancelTicketStart, controlTicketStart, requestTicketStart } from './ticket-start'
103
120
  export type { TicketStartCancelled, TicketStartRequested } from './ticket-start'
104
121
  export type { OperatorSandboxService } from './sandbox'
122
+ export {
123
+ createOperatorSandboxResolver,
124
+ SandboxUnavailableError,
125
+ type OperatorSandboxResolver,
126
+ type OperatorSandboxResolverOptions,
127
+ type SandboxRequestCredentials,
128
+ type SandboxUnavailableReason,
129
+ } from './sandbox-resolver'
105
130
  export * from './presentation'
106
131
 
107
132
  /**
@@ -159,4 +184,27 @@ export {
159
184
  export { clearForgeDegradation } from './control'
160
185
 
161
186
  export { readRepositoryAttentionPage, REPOSITORY_EVENTS_PAGE } from './repository-events'
187
+ export {
188
+ dispatcherAttention,
189
+ getOperatorAttention,
190
+ repositoryEventResolution,
191
+ waitingReasons,
192
+ type OperatorAttention,
193
+ type Resolution,
194
+ } from './attention'
162
195
  export { repositoryNeedsAttention } from '../cli/attention'
196
+ export {
197
+ contextIndex,
198
+ contextInstructions,
199
+ contextPromptMessages,
200
+ contextPrompts,
201
+ contextSource,
202
+ promptLabel,
203
+ readContextFile,
204
+ type CanonicalSkillBundle,
205
+ type ContextEntry,
206
+ type ContextIndex,
207
+ type ContextPrompt,
208
+ type ContextReadResult,
209
+ } from './agent-context-serve'
210
+ export { registerContextPrompts, type ContextPromptSource } from './context-prompts'
@@ -2,37 +2,46 @@ import {
2
2
  BUILD_EFFECTIVE_CONFIG_ARTIFACT,
3
3
  parseEffectiveBuildConfig,
4
4
  } from '../processes/build-execution-state'
5
- import type { BuildStore } from '../store/types'
6
- import { readBuildDigests } from '../store/reduced-reads'
5
+ import type { RepoViewStore } from '../processes/repo-view'
6
+ import type { CurrentBuildFacts } from '../store/reduced-reads'
7
+ import type { BuildRecord, BuildStore } from '../store/types'
7
8
  import { withOperatorView } from './read-view'
8
9
  import { projectTree, type ConsentQueueEntry } from '../cli/dashboard/tree'
9
10
 
11
+ /** One open build's consent-queue entry, or null when it awaits no consent.
12
+ * Reads the pinned effective-config artifact only for a build with a landing
13
+ * decision. */
14
+ export async function consentEntryFromView(
15
+ view: RepoViewStore,
16
+ record: BuildRecord,
17
+ facts: CurrentBuildFacts,
18
+ ): Promise<ConsentQueueEntry | null> {
19
+ const artifact = facts.state.landing?.decision
20
+ ? await view.getArtifact(
21
+ record.slug,
22
+ facts.state.verify.configPin?.artifact.kind ?? BUILD_EFFECTIVE_CONFIG_ARTIFACT,
23
+ facts.state.verify.configPin?.artifact.rev,
24
+ )
25
+ : null
26
+ const expected = artifact ? parseEffectiveBuildConfig(artifact).verify.steps : undefined
27
+ const tree = projectTree(record, facts.state, facts.log.restack, expected)
28
+ return tree.consent ? { slug: record.slug, ...tree } : null
29
+ }
30
+
10
31
  /** Stored readiness only; land reobserves live completeness at its mutation boundary. */
11
32
  export async function listOperatorLandings(opts: {
12
33
  store: BuildStore
13
34
  repo: string
14
35
  }): Promise<ConsentQueueEntry[]> {
15
36
  return withOperatorView(opts.store, opts.repo, 'builds', async (view) => {
16
- const records = await view.listBuilds()
17
- const digests = await readBuildDigests(view, opts.repo)
18
37
  const entries: ConsentQueueEntry[] = []
19
- for (const record of records) {
38
+ // Only nonterminal builds can await consent; the open listing never
39
+ // reads a settled build.
40
+ for (const { record, digest } of await view.listOpenBuilds(opts.repo)) {
20
41
  if (record.repo !== opts.repo) continue
21
- const digest = digests.get(record.slug)
22
- if (!digest)
23
- throw new Error(`getRepoBuildDigests is missing an entry for build "${record.slug}"`)
24
42
  if (digest.terminal !== undefined) continue
25
- const facts = await view.buildFacts(record.slug)
26
- const artifact = facts.state.landing?.decision
27
- ? await view.getArtifact(
28
- record.slug,
29
- facts.state.verify.configPin?.artifact.kind ?? BUILD_EFFECTIVE_CONFIG_ARTIFACT,
30
- facts.state.verify.configPin?.artifact.rev,
31
- )
32
- : null
33
- const expected = artifact ? parseEffectiveBuildConfig(artifact).verify.steps : undefined
34
- const tree = projectTree(record, facts.state, facts.log.restack, expected)
35
- if (tree.consent) entries.push({ slug: record.slug, ...tree })
43
+ const entry = await consentEntryFromView(view, record, await view.buildFacts(record.slug))
44
+ if (entry) entries.push(entry)
36
45
  }
37
46
  return entries.sort((a, b) => a.slug.localeCompare(b.slug))
38
47
  })
@@ -8,6 +8,7 @@ import { settleAttempt } from '../kernel/attempt-settlement'
8
8
  import { mergedAttemptMeasurement } from '../kernel/landing-measurement'
9
9
  import type { BuildState } from '../kernel/reducer'
10
10
  import {
11
+ clockSettling,
11
12
  optimizationCompletionBlocker,
12
13
  optimizationElapsedHours,
13
14
  optimizationPendingCleanups,
@@ -37,7 +38,12 @@ export interface ObjectiveProgress {
37
38
  best?: number
38
39
  attempts: OptimizationState['attempts'] & { running: number }
39
40
  plateau: number
41
+ /** Active hours: the time the node's attempts, proposer or measurements
42
+ * ran, never time since opening. Constant once the node stopped. */
40
43
  elapsedHours: number
44
+ /** Stopped, and the dispatcher has not yet accounted attempt runs from
45
+ * before the stop: `elapsedHours` may rise once more. */
46
+ settling?: true
41
47
  eligibility: OptimizationStopEligibility
42
48
  stopped?: OptimizationState['stopped']
43
49
  /** Once stopped: what still keeps the node from completing, if anything. */
@@ -74,6 +80,7 @@ export function objectiveView(slug: string, state: OptimizationState, now: Date)
74
80
  attempts: { ...state.attempts, running: state.inFlight.length },
75
81
  plateau: state.plateau,
76
82
  elapsedHours: optimizationElapsedHours(state, now),
83
+ ...(clockSettling(state) ? { settling: true as const } : {}),
77
84
  eligibility: optimizationStopEligibility(state, now),
78
85
  ...(state.stopped !== undefined ? { stopped: state.stopped } : {}),
79
86
  ...(() => {
@@ -56,6 +56,9 @@ export const answerRequestSchema = z.union([
56
56
  z.strictObject({ resolution: z.literal('guidance'), text: z.string().trim().min(1) }),
57
57
  z.strictObject({ resolution: z.literal('retry') }),
58
58
  z.strictObject({ resolution: z.literal('dismiss'), text: optionalText }),
59
+ /** Answers only a leaf's target-rewritten escalation: restack its own
60
+ * commits onto the current target. */
61
+ z.strictObject({ resolution: z.literal('accept-target'), text: optionalText }),
59
62
  z.strictObject({
60
63
  resolution: z.literal('review-round-ceiling'),
61
64
  ceiling: z.number().int().positive(),