@stigmer/runner 3.0.9-dev.20260616060535 → 3.1.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 (328) hide show
  1. package/dist/.build-fingerprint +1 -1
  2. package/dist/__test-utils__/approval-contract/types.d.ts +174 -0
  3. package/dist/__test-utils__/approval-contract/types.js +24 -0
  4. package/dist/__test-utils__/approval-contract/types.js.map +1 -0
  5. package/dist/activities/call-agent-status.d.ts +19 -1
  6. package/dist/activities/call-agent-status.js +64 -5
  7. package/dist/activities/call-agent-status.js.map +1 -1
  8. package/dist/activities/call-llm.js +19 -53
  9. package/dist/activities/call-llm.js.map +1 -1
  10. package/dist/activities/classify-tool-approvals.d.ts +24 -0
  11. package/dist/activities/classify-tool-approvals.js +69 -17
  12. package/dist/activities/classify-tool-approvals.js.map +1 -1
  13. package/dist/activities/discover-mcp-server.d.ts +7 -0
  14. package/dist/activities/discover-mcp-server.js +11 -1
  15. package/dist/activities/discover-mcp-server.js.map +1 -1
  16. package/dist/activities/execute-cursor/__test-utils__/cursor-hook-harness.d.ts +140 -0
  17. package/dist/activities/execute-cursor/__test-utils__/cursor-hook-harness.js +130 -0
  18. package/dist/activities/execute-cursor/__test-utils__/cursor-hook-harness.js.map +1 -0
  19. package/dist/activities/execute-cursor/__test-utils__/gateway-substrate.d.ts +18 -0
  20. package/dist/activities/execute-cursor/__test-utils__/gateway-substrate.js +123 -0
  21. package/dist/activities/execute-cursor/__test-utils__/gateway-substrate.js.map +1 -0
  22. package/dist/activities/execute-cursor/approval-policy.d.ts +17 -61
  23. package/dist/activities/execute-cursor/approval-policy.js +8 -120
  24. package/dist/activities/execute-cursor/approval-policy.js.map +1 -1
  25. package/dist/activities/execute-cursor/approval-state.d.ts +219 -9
  26. package/dist/activities/execute-cursor/approval-state.js +233 -17
  27. package/dist/activities/execute-cursor/approval-state.js.map +1 -1
  28. package/dist/activities/execute-cursor/capture-flow.d.ts +127 -0
  29. package/dist/activities/execute-cursor/capture-flow.js +234 -0
  30. package/dist/activities/execute-cursor/capture-flow.js.map +1 -0
  31. package/dist/activities/execute-cursor/cas-observations.d.ts +96 -0
  32. package/dist/activities/execute-cursor/cas-observations.js +184 -0
  33. package/dist/activities/execute-cursor/cas-observations.js.map +1 -0
  34. package/dist/activities/execute-cursor/command-provenance.d.ts +62 -0
  35. package/dist/activities/execute-cursor/command-provenance.js +128 -0
  36. package/dist/activities/execute-cursor/command-provenance.js.map +1 -0
  37. package/dist/activities/execute-cursor/exact-apply.d.ts +110 -0
  38. package/dist/activities/execute-cursor/exact-apply.js +204 -0
  39. package/dist/activities/execute-cursor/exact-apply.js.map +1 -0
  40. package/dist/activities/execute-cursor/hook-script.d.ts +53 -24
  41. package/dist/activities/execute-cursor/hook-script.js +310 -47
  42. package/dist/activities/execute-cursor/hook-script.js.map +1 -1
  43. package/dist/activities/execute-cursor/index.d.ts +8 -1
  44. package/dist/activities/execute-cursor/index.js +500 -64
  45. package/dist/activities/execute-cursor/index.js.map +1 -1
  46. package/dist/activities/execute-cursor/message-translator.d.ts +258 -11
  47. package/dist/activities/execute-cursor/message-translator.js +836 -90
  48. package/dist/activities/execute-cursor/message-translator.js.map +1 -1
  49. package/dist/activities/execute-cursor/prompt-builder.d.ts +20 -23
  50. package/dist/activities/execute-cursor/prompt-builder.js +74 -15
  51. package/dist/activities/execute-cursor/prompt-builder.js.map +1 -1
  52. package/dist/activities/execute-cursor/workspace-setup.d.ts +17 -0
  53. package/dist/activities/execute-cursor/workspace-setup.js +212 -33
  54. package/dist/activities/execute-cursor/workspace-setup.js.map +1 -1
  55. package/dist/activities/execute-deep-agent/__test-utils__/gateway-substrate.d.ts +19 -0
  56. package/dist/activities/execute-deep-agent/__test-utils__/gateway-substrate.js +143 -0
  57. package/dist/activities/execute-deep-agent/__test-utils__/gateway-substrate.js.map +1 -0
  58. package/dist/activities/execute-deep-agent/__test-utils__/scripted-model.d.ts +88 -0
  59. package/dist/activities/execute-deep-agent/__test-utils__/scripted-model.js +81 -0
  60. package/dist/activities/execute-deep-agent/__test-utils__/scripted-model.js.map +1 -0
  61. package/dist/activities/execute-deep-agent/approval-file-change.d.ts +47 -0
  62. package/dist/activities/execute-deep-agent/approval-file-change.js +68 -0
  63. package/dist/activities/execute-deep-agent/approval-file-change.js.map +1 -0
  64. package/dist/activities/execute-deep-agent/attachment-injector.d.ts +8 -1
  65. package/dist/activities/execute-deep-agent/attachment-injector.js +7 -7
  66. package/dist/activities/execute-deep-agent/attachment-injector.js.map +1 -1
  67. package/dist/activities/execute-deep-agent/cas-capture-backend.d.ts +42 -0
  68. package/dist/activities/execute-deep-agent/cas-capture-backend.js +47 -0
  69. package/dist/activities/execute-deep-agent/cas-capture-backend.js.map +1 -0
  70. package/dist/activities/execute-deep-agent/cas-capture-observer.d.ts +79 -0
  71. package/dist/activities/execute-deep-agent/cas-capture-observer.js +112 -0
  72. package/dist/activities/execute-deep-agent/cas-capture-observer.js.map +1 -0
  73. package/dist/activities/execute-deep-agent/hitl.d.ts +10 -0
  74. package/dist/activities/execute-deep-agent/hitl.js +5 -1
  75. package/dist/activities/execute-deep-agent/hitl.js.map +1 -1
  76. package/dist/activities/execute-deep-agent/index.d.ts +2 -1
  77. package/dist/activities/execute-deep-agent/index.js +370 -56
  78. package/dist/activities/execute-deep-agent/index.js.map +1 -1
  79. package/dist/activities/execute-deep-agent/inline-publisher.d.ts +7 -1
  80. package/dist/activities/execute-deep-agent/inline-publisher.js +23 -2
  81. package/dist/activities/execute-deep-agent/inline-publisher.js.map +1 -1
  82. package/dist/activities/execute-deep-agent/setup.d.ts +53 -2
  83. package/dist/activities/execute-deep-agent/setup.js +149 -92
  84. package/dist/activities/execute-deep-agent/setup.js.map +1 -1
  85. package/dist/activities/execute-deep-agent/stamp-flowed-rows.d.ts +36 -0
  86. package/dist/activities/execute-deep-agent/stamp-flowed-rows.js +56 -0
  87. package/dist/activities/execute-deep-agent/stamp-flowed-rows.js.map +1 -0
  88. package/dist/activities/execute-deep-agent/status-builder-shared.d.ts +34 -1
  89. package/dist/activities/execute-deep-agent/status-builder-shared.js +26 -25
  90. package/dist/activities/execute-deep-agent/status-builder-shared.js.map +1 -1
  91. package/dist/activities/execute-deep-agent/status-builder.d.ts +11 -5
  92. package/dist/activities/execute-deep-agent/status-builder.js +6 -2
  93. package/dist/activities/execute-deep-agent/status-builder.js.map +1 -1
  94. package/dist/activities/execute-deep-agent/streaming-side-effects.js +2 -19
  95. package/dist/activities/execute-deep-agent/streaming-side-effects.js.map +1 -1
  96. package/dist/activities/execute-deep-agent/streaming.js +3 -15
  97. package/dist/activities/execute-deep-agent/streaming.js.map +1 -1
  98. package/dist/activities/execute-deep-agent/subagent-transformer.d.ts +25 -7
  99. package/dist/activities/execute-deep-agent/subagent-transformer.js +23 -7
  100. package/dist/activities/execute-deep-agent/subagent-transformer.js.map +1 -1
  101. package/dist/activities/execute-deep-agent/subagent-wiring.d.ts +30 -3
  102. package/dist/activities/execute-deep-agent/subagent-wiring.js +29 -3
  103. package/dist/activities/execute-deep-agent/subagent-wiring.js.map +1 -1
  104. package/dist/activities/execute-deep-agent/v3-status-builder.js +6 -2
  105. package/dist/activities/execute-deep-agent/v3-status-builder.js.map +1 -1
  106. package/dist/claimcheck/payload-codec.js +9 -5
  107. package/dist/claimcheck/payload-codec.js.map +1 -1
  108. package/dist/client/stigmer-client.d.ts +2 -0
  109. package/dist/client/stigmer-client.js +2 -0
  110. package/dist/client/stigmer-client.js.map +1 -1
  111. package/dist/middleware/approval-gate.d.ts +85 -4
  112. package/dist/middleware/approval-gate.js +165 -38
  113. package/dist/middleware/approval-gate.js.map +1 -1
  114. package/dist/middleware/types.d.ts +2 -5
  115. package/dist/shared/activity-input.d.ts +43 -0
  116. package/dist/shared/activity-input.js +17 -0
  117. package/dist/shared/activity-input.js.map +1 -0
  118. package/dist/shared/approval-canonicalize.d.ts +19 -0
  119. package/dist/shared/approval-canonicalize.js +119 -0
  120. package/dist/shared/approval-canonicalize.js.map +1 -0
  121. package/dist/shared/approval-fingerprint.d.ts +106 -0
  122. package/dist/shared/approval-fingerprint.js +113 -0
  123. package/dist/shared/approval-fingerprint.js.map +1 -0
  124. package/dist/shared/approval-policy.d.ts +182 -12
  125. package/dist/shared/approval-policy.js +213 -27
  126. package/dist/shared/approval-policy.js.map +1 -1
  127. package/dist/shared/args-preview.d.ts +52 -0
  128. package/dist/shared/args-preview.js +93 -0
  129. package/dist/shared/args-preview.js.map +1 -0
  130. package/dist/shared/artifact-storage.d.ts +19 -1
  131. package/dist/shared/artifact-storage.js +48 -11
  132. package/dist/shared/artifact-storage.js.map +1 -1
  133. package/dist/shared/file-change.d.ts +44 -0
  134. package/dist/shared/file-change.js +57 -0
  135. package/dist/shared/file-change.js.map +1 -0
  136. package/dist/shared/file-tools.d.ts +107 -0
  137. package/dist/shared/file-tools.js +168 -0
  138. package/dist/shared/file-tools.js.map +1 -0
  139. package/dist/shared/filereview/capture.d.ts +202 -0
  140. package/dist/shared/filereview/capture.js +498 -0
  141. package/dist/shared/filereview/capture.js.map +1 -0
  142. package/dist/shared/filereview/cas-substrate.d.ts +190 -0
  143. package/dist/shared/filereview/cas-substrate.js +284 -0
  144. package/dist/shared/filereview/cas-substrate.js.map +1 -0
  145. package/dist/shared/filereview/digest.d.ts +40 -0
  146. package/dist/shared/filereview/digest.js +66 -0
  147. package/dist/shared/filereview/digest.js.map +1 -0
  148. package/dist/shared/filereview/events.d.ts +170 -0
  149. package/dist/shared/filereview/events.js +298 -0
  150. package/dist/shared/filereview/events.js.map +1 -0
  151. package/dist/shared/filereview/git-substrate.d.ts +175 -0
  152. package/dist/shared/filereview/git-substrate.js +439 -0
  153. package/dist/shared/filereview/git-substrate.js.map +1 -0
  154. package/dist/shared/filereview/index.d.ts +11 -0
  155. package/dist/shared/filereview/index.js +12 -0
  156. package/dist/shared/filereview/index.js.map +1 -0
  157. package/dist/shared/filereview/secret-paths.d.ts +63 -0
  158. package/dist/shared/filereview/secret-paths.js +105 -0
  159. package/dist/shared/filereview/secret-paths.js.map +1 -0
  160. package/dist/shared/fingerprint-secret.d.ts +26 -0
  161. package/dist/shared/fingerprint-secret.js +47 -0
  162. package/dist/shared/fingerprint-secret.js.map +1 -0
  163. package/dist/shared/model-client.d.ts +51 -0
  164. package/dist/shared/model-client.js +77 -0
  165. package/dist/shared/model-client.js.map +1 -0
  166. package/dist/shared/plan-artifact.js +0 -2
  167. package/dist/shared/plan-artifact.js.map +1 -1
  168. package/dist/shared/status-offload.d.ts +83 -9
  169. package/dist/shared/status-offload.js +399 -79
  170. package/dist/shared/status-offload.js.map +1 -1
  171. package/dist/shared/status.js +14 -1
  172. package/dist/shared/status.js.map +1 -1
  173. package/dist/shared/tool-kind.d.ts +19 -0
  174. package/dist/shared/tool-kind.js +13 -0
  175. package/dist/shared/tool-kind.js.map +1 -1
  176. package/dist/shared/tool-row.d.ts +88 -0
  177. package/dist/shared/tool-row.js +127 -0
  178. package/dist/shared/tool-row.js.map +1 -0
  179. package/dist/shared/workspace/platform-dir.d.ts +25 -0
  180. package/dist/shared/workspace/platform-dir.js +38 -2
  181. package/dist/shared/workspace/platform-dir.js.map +1 -1
  182. package/dist/workflows/call-agent-orchestrator.js +56 -7
  183. package/dist/workflows/call-agent-orchestrator.js.map +1 -1
  184. package/dist/workflows/connect-mcp-server.d.ts +50 -0
  185. package/dist/workflows/connect-mcp-server.js +136 -15
  186. package/dist/workflows/connect-mcp-server.js.map +1 -1
  187. package/dist/workflows/types.d.ts +8 -0
  188. package/package.json +2 -2
  189. package/src/__test-utils__/approval-contract/contract.ts +224 -0
  190. package/src/__test-utils__/approval-contract/types.ts +179 -0
  191. package/src/__test-utils__/fake-artifact-storage.ts +72 -0
  192. package/src/__tests__/approval-gateway-contract.test.ts +29 -0
  193. package/src/__tests__/claimcheck-codec.test.ts +16 -53
  194. package/src/__tests__/golden-e2e.test.ts +2 -0
  195. package/src/__tests__/runner-token-coordinator.test.ts +3 -3
  196. package/src/activities/__tests__/call-agent-status.test.ts +135 -0
  197. package/src/activities/__tests__/call-llm.test.ts +1 -1
  198. package/src/activities/__tests__/classify-tool-approvals.test.ts +208 -1
  199. package/src/activities/__tests__/discover-mcp-server.test.ts +30 -0
  200. package/src/activities/__tests__/workflow-event-activities.test.ts +2 -1
  201. package/src/activities/call-agent-status.ts +74 -4
  202. package/src/activities/call-llm.ts +18 -63
  203. package/src/activities/classify-tool-approvals.ts +101 -19
  204. package/src/activities/discover-mcp-server.ts +29 -1
  205. package/src/activities/execute-cursor/__test-utils__/cursor-hook-harness.ts +216 -0
  206. package/src/activities/execute-cursor/__test-utils__/gateway-substrate.ts +148 -0
  207. package/src/activities/execute-cursor/__tests__/approval-gate.test.ts +41 -9
  208. package/src/activities/execute-cursor/__tests__/approval-state.test.ts +292 -0
  209. package/src/activities/execute-cursor/__tests__/build-prompt.test.ts +68 -1
  210. package/src/activities/execute-cursor/__tests__/capture-flow.test.ts +1005 -0
  211. package/src/activities/execute-cursor/__tests__/cas-observations.test.ts +187 -0
  212. package/src/activities/execute-cursor/__tests__/coarse-fingerprint.test.ts +97 -0
  213. package/src/activities/execute-cursor/__tests__/command-provenance.test.ts +240 -0
  214. package/src/activities/execute-cursor/__tests__/deny-gate-exact-apply.test.ts +203 -0
  215. package/src/activities/execute-cursor/__tests__/exact-apply.test.ts +375 -0
  216. package/src/activities/execute-cursor/__tests__/hitl-ledger.test.ts +1294 -24
  217. package/src/activities/execute-cursor/__tests__/hitl-resume-history.test.ts +446 -0
  218. package/src/activities/execute-cursor/__tests__/hook-script.test.ts +384 -110
  219. package/src/activities/execute-cursor/__tests__/message-translator.test.ts +171 -25
  220. package/src/activities/execute-cursor/__tests__/sequential-gate-resume.test.ts +189 -0
  221. package/src/activities/execute-cursor/__tests__/tool-result-image.test.ts +44 -23
  222. package/src/activities/execute-cursor/__tests__/workspace-setup.test.ts +190 -10
  223. package/src/activities/execute-cursor/approval-policy.ts +28 -159
  224. package/src/activities/execute-cursor/approval-state.ts +366 -18
  225. package/src/activities/execute-cursor/capture-flow.ts +323 -0
  226. package/src/activities/execute-cursor/cas-observations.ts +204 -0
  227. package/src/activities/execute-cursor/command-provenance.ts +168 -0
  228. package/src/activities/execute-cursor/exact-apply.ts +253 -0
  229. package/src/activities/execute-cursor/hook-script.ts +317 -51
  230. package/src/activities/execute-cursor/index.ts +575 -67
  231. package/src/activities/execute-cursor/message-translator.ts +963 -89
  232. package/src/activities/execute-cursor/prompt-builder.ts +80 -14
  233. package/src/activities/execute-cursor/workspace-setup.ts +257 -42
  234. package/src/activities/execute-deep-agent/__test-utils__/gateway-substrate.ts +180 -0
  235. package/src/activities/execute-deep-agent/__test-utils__/scripted-model.ts +134 -0
  236. package/src/activities/execute-deep-agent/__tests__/approval-file-change.test.ts +84 -0
  237. package/src/activities/execute-deep-agent/__tests__/attachment-injector.test.ts +11 -24
  238. package/src/activities/execute-deep-agent/__tests__/cas-capture-backend.test.ts +64 -0
  239. package/src/activities/execute-deep-agent/__tests__/cas-capture-observer.test.ts +163 -0
  240. package/src/activities/execute-deep-agent/__tests__/hitl-integration.test.ts +8 -5
  241. package/src/activities/execute-deep-agent/__tests__/hitl-resume-approve-all.test.ts +342 -0
  242. package/src/activities/execute-deep-agent/__tests__/hitl-resume-history.test.ts +2 -5
  243. package/src/activities/execute-deep-agent/__tests__/inline-publisher.test.ts +31 -13
  244. package/src/activities/execute-deep-agent/__tests__/sequential-gate-resume.test.ts +349 -0
  245. package/src/activities/execute-deep-agent/__tests__/stamp-flowed-rows.test.ts +119 -0
  246. package/src/activities/execute-deep-agent/__tests__/status-builder.test.ts +12 -11
  247. package/src/activities/execute-deep-agent/__tests__/streaming-v3.test.ts +9 -9
  248. package/src/activities/execute-deep-agent/__tests__/subagent-approval-propagation.test.ts +160 -0
  249. package/src/activities/execute-deep-agent/__tests__/subagent-gitignored-capture.test.ts +213 -0
  250. package/src/activities/execute-deep-agent/__tests__/subagent-transformer.test.ts +3 -6
  251. package/src/activities/execute-deep-agent/__tests__/subagent-wiring.test.ts +84 -1
  252. package/src/activities/execute-deep-agent/__tests__/v3-status-builder.test.ts +4 -1
  253. package/src/activities/execute-deep-agent/approval-file-change.ts +80 -0
  254. package/src/activities/execute-deep-agent/attachment-injector.ts +20 -11
  255. package/src/activities/execute-deep-agent/cas-capture-backend.ts +66 -0
  256. package/src/activities/execute-deep-agent/cas-capture-observer.ts +125 -0
  257. package/src/activities/execute-deep-agent/hitl.ts +15 -1
  258. package/src/activities/execute-deep-agent/index.ts +434 -64
  259. package/src/activities/execute-deep-agent/inline-publisher.ts +27 -4
  260. package/src/activities/execute-deep-agent/setup.ts +223 -125
  261. package/src/activities/execute-deep-agent/stamp-flowed-rows.ts +64 -0
  262. package/src/activities/execute-deep-agent/status-builder-shared.ts +62 -23
  263. package/src/activities/execute-deep-agent/status-builder.ts +19 -7
  264. package/src/activities/execute-deep-agent/streaming-side-effects.ts +2 -16
  265. package/src/activities/execute-deep-agent/streaming.ts +3 -13
  266. package/src/activities/execute-deep-agent/subagent-transformer.ts +53 -13
  267. package/src/activities/execute-deep-agent/subagent-wiring.ts +50 -3
  268. package/src/activities/execute-deep-agent/v3-status-builder.ts +8 -2
  269. package/src/claimcheck/payload-codec.ts +8 -8
  270. package/src/client/stigmer-client.ts +9 -1
  271. package/src/middleware/__tests__/approval-gate.test.ts +488 -4
  272. package/src/middleware/approval-gate.ts +247 -38
  273. package/src/middleware/types.ts +5 -5
  274. package/src/shared/__tests__/activity-input.test.ts +78 -0
  275. package/src/shared/__tests__/approval-canonicalize.test.ts +106 -0
  276. package/src/shared/__tests__/approval-fingerprint.test.ts +115 -0
  277. package/src/shared/__tests__/approval-policy.test.ts +274 -40
  278. package/src/shared/__tests__/args-preview.test.ts +78 -0
  279. package/src/shared/__tests__/artifact-storage-extended.test.ts +62 -10
  280. package/src/shared/__tests__/artifact-storage.test.ts +123 -11
  281. package/src/shared/__tests__/file-change.test.ts +85 -0
  282. package/src/shared/__tests__/file-tools.test.ts +90 -0
  283. package/src/shared/__tests__/fingerprint-secret.test.ts +51 -0
  284. package/src/shared/__tests__/lease-scope-corpus.test.ts +56 -0
  285. package/src/shared/__tests__/model-client.test.ts +162 -0
  286. package/src/shared/__tests__/plan-artifact.test.ts +11 -26
  287. package/src/shared/__tests__/policy-source-corpus.test.ts +58 -0
  288. package/src/shared/__tests__/status-offload.test.ts +573 -16
  289. package/src/shared/__tests__/status.test.ts +4 -5
  290. package/src/shared/__tests__/tool-kind.test.ts +24 -1
  291. package/src/shared/__tests__/tool-row.test.ts +221 -0
  292. package/src/shared/activity-input.ts +57 -0
  293. package/src/shared/approval-canonicalize.ts +159 -0
  294. package/src/shared/approval-fingerprint.ts +148 -0
  295. package/src/shared/approval-policy.ts +303 -27
  296. package/src/shared/args-preview.ts +98 -0
  297. package/src/shared/artifact-storage.ts +62 -11
  298. package/src/shared/checkpointer/__tests__/http-saver.test.ts +1 -2
  299. package/src/shared/file-change.ts +64 -0
  300. package/src/shared/file-tools.ts +169 -0
  301. package/src/shared/filereview/__tests__/capture.test.ts +856 -0
  302. package/src/shared/filereview/__tests__/cas-substrate.test.ts +404 -0
  303. package/src/shared/filereview/__tests__/digest.test.ts +100 -0
  304. package/src/shared/filereview/__tests__/events.test.ts +245 -0
  305. package/src/shared/filereview/__tests__/git-substrate.test.ts +362 -0
  306. package/src/shared/filereview/__tests__/proxy-reconcile.test.ts +286 -0
  307. package/src/shared/filereview/__tests__/secret-paths.test.ts +121 -0
  308. package/src/shared/filereview/capture.ts +727 -0
  309. package/src/shared/filereview/cas-substrate.ts +401 -0
  310. package/src/shared/filereview/digest.ts +83 -0
  311. package/src/shared/filereview/events.ts +449 -0
  312. package/src/shared/filereview/git-substrate.ts +555 -0
  313. package/src/shared/filereview/index.ts +60 -0
  314. package/src/shared/filereview/secret-paths.ts +121 -0
  315. package/src/shared/fingerprint-secret.ts +53 -0
  316. package/src/shared/model-client.ts +122 -0
  317. package/src/shared/plan-artifact.ts +0 -2
  318. package/src/shared/status-offload.ts +433 -77
  319. package/src/shared/status.ts +13 -0
  320. package/src/shared/tool-kind.ts +33 -0
  321. package/src/shared/tool-row.ts +135 -0
  322. package/src/shared/workspace/platform-dir.ts +41 -2
  323. package/src/workflow-engine/__tests__/golden-execution.test.ts +35 -18
  324. package/src/workflow-engine/__tests__/tasks/try.test.ts +1 -1
  325. package/src/workflows/__tests__/connect-mcp-server.test.ts +304 -29
  326. package/src/workflows/call-agent-orchestrator.ts +53 -6
  327. package/src/workflows/connect-mcp-server.ts +179 -24
  328. package/src/workflows/types.ts +8 -0
@@ -0,0 +1,498 @@
1
+ /**
2
+ * Harness-agnostic capture-mode turn orchestration for the apply-then-review
3
+ * HITL subsystem. This is the glue between the git snapshot/restore substrate
4
+ * ({@link ./git-substrate.js}) and the file-review ledger ({@link ./events.js}):
5
+ * it turns "the agent edited files freely this turn" into the append-only
6
+ * `file_review` events the server folds into `file_change_sets` (the single
7
+ * review surface), and on resume reconciles the tree to the user's decisions.
8
+ *
9
+ * It is parameterized by `harnessId` (stamped onto the BASELINE payload, which is
10
+ * the projection's source of truth for `turn_id`/`harness_id`) and `excludePaths`
11
+ * (the runner-owned files a harness writes into the workspace), so the Cursor and
12
+ * deep-agent harnesses author IDENTICAL ledger entries through this one seam. Each
13
+ * harness keeps only its presentation concerns (e.g. hiding flowed transcript
14
+ * rows) in its own adapter.
15
+ *
16
+ * Identity: the change set id is `${executionId}:${turnSeq}` (one turn = one
17
+ * change set), minted by the caller; each file's stable id is
18
+ * `${changeSetId}:${pathAfter||pathBefore}` so the resume can map a per-file
19
+ * decision back to its path without depending on any other identity.
20
+ */
21
+ import { create } from "@bufbuild/protobuf";
22
+ import { FileCaptureClass, FileChangeKind, FileChangeType, FileDecisionAction, FileDecisionScope, FileReviewBlockReason, FileReviewFailureKind, SnapshotKind, } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/enum_pb";
23
+ import { CasManifestRefSchema, GitTreeRefSchema, SnapshotRefSchema, } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/filereview_pb";
24
+ import { utcTimestamp } from "../status.js";
25
+ import { appendFileReviewEvents, buildBaselineCapturedEvent, buildCandidateCapturedEvent, buildCapturedFileChange, buildFailedEvent, buildReconciledEvent, contentSha256, } from "./events.js";
26
+ import { applyApprovedPaths, baselineRef, captureChangeSet, captureRef, dropCaptureRefs, recomputeChangeSet, restoreToBaseline, snapshotApproved, snapshotBaseline, } from "./git-substrate.js";
27
+ import { applyCasApproved, loadCasManifest, restoreCasToBaseline, snapshotCasChangeSet, } from "./cas-substrate.js";
28
+ /**
29
+ * Whether a turn runs in apply-then-review CAPTURE mode (file edits flow and are
30
+ * reviewed post-hoc) rather than the classic pre-write DENY-GATE. Shared by BOTH
31
+ * harnesses (Cursor and deep-agent) so the capture-vs-deny-gate decision is made
32
+ * one way everywhere — the single point where a workspace's substrate availability
33
+ * decides the HITL model.
34
+ *
35
+ * Capture needs a primary workspace AND a substrate to capture into:
36
+ * - a git work tree captures tracked edits from the git diff (no storage needed);
37
+ * - a NON-git workspace captures every write via the path-scoped CAS substrate,
38
+ * which needs artifact storage to persist blobs.
39
+ *
40
+ * So a non-git workspace with NO artifact storage — or no workspace at all — has
41
+ * no capture substrate and falls back to the deny-gate: the agent still runs, but
42
+ * file writes gate pre-execution instead of flowing. In the Cursor harness that
43
+ * fallback is also the ONLY branch that arms the resume-time exact-apply guarantee
44
+ * (see execute-cursor/exact-apply.ts); the deep-agent harness re-applies an
45
+ * approved write via LangGraph checkpoint replay and needs no exact-apply. Keeping
46
+ * this the single, named, truth-table-tested decision pins exactly when the
47
+ * no-storage deny-gate engages in either harness.
48
+ */
49
+ export function deriveCaptureMode(primaryWorkspaceDir, gitWorkspace, hasArtifactStorage) {
50
+ return !!primaryWorkspaceDir && (gitWorkspace || hasArtifactStorage);
51
+ }
52
+ /**
53
+ * Turn start: pin the pre-turn working tree behind the baseline ref and author
54
+ * the BASELINE_CAPTURED event. The projection reads `turn_id`/`harness_id` ONLY
55
+ * from this payload, so `turnId == changeSetId` (one turn = one change set) and
56
+ * `harnessId` identifies the producer. Returns the baseline tree sha for the
57
+ * turn-end diff. Appends onto `status.fileReviewEventStream`; the event rides the
58
+ * next persist.
59
+ *
60
+ * `gitWorkspace=false` (a non-git workspace, DD-21 D2) has no whole-tree baseline
61
+ * to pin — a file's pre-edit bytes are captured per-path by the CAS observer at
62
+ * mutation time, and the reconcile sources them from the durable CAS manifest,
63
+ * not this snapshot. The BASELINE event is still authored (it is the projection's
64
+ * sole source for `turn_id`/`harness_id`), carrying a `CAS_MANIFEST` snapshot with
65
+ * no manifest yet (the manifest is authored at candidate time). Returns "".
66
+ */
67
+ export async function captureBaselineToLedger(opts) {
68
+ const { status, gitRoot, executionId, changeSetId, harnessId, excludePaths } = opts;
69
+ const gitWorkspace = opts.gitWorkspace ?? true;
70
+ if (!gitWorkspace) {
71
+ const event = buildBaselineCapturedEvent(changeSetContext(changeSetId, harnessId), casManifestSnapshotRef());
72
+ appendFileReviewEvents(status, executionId, [event]);
73
+ return "";
74
+ }
75
+ const baselineTree = await snapshotBaseline(gitRoot, executionId, excludePaths);
76
+ const event = buildBaselineCapturedEvent(changeSetContext(changeSetId, harnessId), gitTreeSnapshotRef(baselineTree, baselineRef(executionId)));
77
+ appendFileReviewEvents(status, executionId, [event]);
78
+ return baselineTree;
79
+ }
80
+ /**
81
+ * Turn end: capture the change set, LEAVE the working tree in its applied
82
+ * ("after") state (the user reviews the real change; nothing is committed and the
83
+ * next turn is blocked until they decide), and author the CANDIDATE_CAPTURED
84
+ * event. The pinned baseline/after refs are the authoritative source for the
85
+ * resume-time reconcile ({@link applyCaptureDecisions}).
86
+ *
87
+ * Presentation (hiding the harness's flowed transcript rows so `file_change_sets`
88
+ * is the single review surface) is the harness adapter's concern, not this seam's.
89
+ * Returns the captured changes. No-op authoring when the turn changed nothing.
90
+ */
91
+ export async function captureCandidateToLedger(opts) {
92
+ const { status, gitRoot, executionId, changeSetId, baselineTree, harnessId, excludePaths, casCaptures, storage, unreviewablePaths, commandProvenance, } = opts;
93
+ const gitWorkspace = opts.gitWorkspace ?? true;
94
+ const unreviewableCaptureClass = opts.unreviewableCaptureClass ?? FileCaptureClass.GIT_IGNORED_CAPTURED;
95
+ // A non-git workspace has no tree to diff; git-tracked changes are empty and
96
+ // the whole change set comes from the CAS captures below.
97
+ const { afterTree, changes: gitChanges } = gitWorkspace
98
+ ? await captureChangeSet(gitRoot, executionId, baselineTree, excludePaths)
99
+ : { afterTree: "", changes: [] };
100
+ // Capture the ignored / non-git deltas into CAS (content-addressed, deduped,
101
+ // offloaded), if the harness supplied any this turn.
102
+ let casFiles = [];
103
+ let casRef;
104
+ if (casCaptures && casCaptures.length > 0) {
105
+ if (!storage) {
106
+ throw new Error("captureCandidateToLedger: casCaptures requires an ArtifactStorage");
107
+ }
108
+ const snap = await snapshotCasChangeSet({ storage, executionId, changeSetId, captures: casCaptures });
109
+ casFiles = snap.manifest.files;
110
+ if (casFiles.length > 0)
111
+ casRef = snap.ref;
112
+ }
113
+ const unreviewable = unreviewablePaths ?? [];
114
+ // A turn that changed nothing (no tracked/ignored change and no blocked path)
115
+ // authors no event.
116
+ if (gitChanges.length === 0 && casFiles.length === 0 && unreviewable.length === 0) {
117
+ return gitChanges;
118
+ }
119
+ // One combined change set: git-tracked (inline bodies) + CAS (blob refs) +
120
+ // secret-blocked (content-less, DIFF_UNREVIEWABLE). The aggregate digest folds
121
+ // all (buildCandidateCapturedEvent sorts by file digest), so the reviewed diff
122
+ // and its identity span every substrate. deriveDiffCompleteness then rolls the
123
+ // per-file signals up three ways: any content-less (non-binary) entry forces
124
+ // PARTIAL_BLOCKED; a set blocked only by binaries is BINARY_SUMMARY_ONLY
125
+ // (keepable in one acknowledged action); else COMPLETE.
126
+ const captured = [
127
+ ...gitChanges.map((c) => buildCapturedFileChange(toCapturedChangeInput(changeSetId, c))),
128
+ ...casFiles.map((f) => buildCapturedFileChange(casToCapturedChangeInput(changeSetId, f))),
129
+ ...unreviewable.map((p) => buildCapturedFileChange(unreviewableChangeInput(changeSetId, p, unreviewableCaptureClass))),
130
+ ];
131
+ // Snapshot kind follows the substrate(s) that captured this turn: CAS-only for
132
+ // a non-git workspace, HYBRID when a git turn also touched ignored/non-git
133
+ // paths, else a plain git tree.
134
+ const snapshot = !gitWorkspace
135
+ ? casManifestSnapshotRef(casRef)
136
+ : casRef
137
+ ? hybridSnapshotRef(afterTree, captureRef(executionId), casRef)
138
+ : gitTreeSnapshotRef(afterTree, captureRef(executionId));
139
+ const event = buildCandidateCapturedEvent(changeSetContext(changeSetId, harnessId), snapshot, captured, commandProvenance);
140
+ appendFileReviewEvents(status, executionId, [event]);
141
+ return gitChanges;
142
+ }
143
+ /**
144
+ * Resume: reconcile the working tree to the change set's DECIDED decisions
145
+ * (projected server-side onto `FileChangeSet.decisions`), sourced entirely from
146
+ * the pinned baseline/after refs — approved files are ensured at their "after"
147
+ * bytes (uncommitted; normally already on disk from the review window, re-asserted
148
+ * idempotently), rejected/undecided files are snapped back to baseline. Then
149
+ * author RECONCILED with the post-reconcile approved snapshot and release the
150
+ * refs. Because both sides are ref-sourced, the result is correct regardless of
151
+ * the tree's current contents (idempotent under a Temporal retry or a tree reset).
152
+ *
153
+ * Scope precedence is runner-owned, most-specific-wins: the CHANGE_SET decision
154
+ * (if any) seeds every file, then per-file FILE decisions override it.
155
+ *
156
+ * Enforcement ("what you approve is what applies"): before keeping an approved
157
+ * file, the recomputed bytes must still hash to the reviewed digest. Any mismatch
158
+ * authors a FileReviewFailure(HASH_MISMATCH) and applies NOTHING.
159
+ *
160
+ * Mutates `status.fileReviewEventStream` in place (authors RECONCILED / FAILED).
161
+ */
162
+ export async function applyCaptureDecisions(opts) {
163
+ const { status, gitRoot, executionId, changeSet, harnessId, excludePaths, readBlob } = opts;
164
+ const gitWorkspace = opts.gitWorkspace ?? true;
165
+ // The two substrates are resolved up front and reconciled independently below:
166
+ // git-tracked files from the pinned baseline/after refs, ignored/non-git files
167
+ // from the durable CAS manifest. A resume is a capture turn iff at least one is
168
+ // present; with neither this is an ordinary (non-capture) resume.
169
+ //
170
+ // Whether this turn captured any CAS (ignored / non-git) files is a fact the
171
+ // ledger already records: the change set's CANDIDATE snapshot carries a CAS
172
+ // manifest ref for a CAS/HYBRID turn and none for a git-only turn. We branch on
173
+ // that ledger fact — NOT on probing artifact storage. A git-only turn writes no
174
+ // manifest, and asking storage "does the manifest exist?" is both redundant and
175
+ // unsafe: a presigned/proxy backend answers true for any key, which turned a
176
+ // git-only reconcile into a doomed manifest download and a 404 crash. Single
177
+ // source of truth: derive the substrate from the ledger, never from storage.
178
+ const recomputed = gitWorkspace ? await recomputeChangeSet(gitRoot, executionId) : undefined;
179
+ const casRef = candidateCasRef(changeSet);
180
+ if (casRef && !readBlob) {
181
+ // The ledger says CAS files were captured, but this caller cannot read blobs
182
+ // back. Skipping would leave those files applied with their decisions
183
+ // unenforced — a silent partial reconcile — so refuse loudly instead.
184
+ throw new Error(`applyCaptureDecisions: change set '${changeSet.id}' captured CAS files ` +
185
+ `(manifest '${casRef.artifactUri}') but no blob reader was provided`);
186
+ }
187
+ const manifest = casRef && readBlob ? await loadCasManifest({ readBlob, ref: casRef }) : undefined;
188
+ if (!recomputed && !manifest) {
189
+ return {
190
+ isCaptureTurn: false,
191
+ approvedPaths: [],
192
+ rejectedPaths: [],
193
+ hadReject: false,
194
+ failed: false,
195
+ };
196
+ }
197
+ const actionByChangeId = resolveDecisions(changeSet);
198
+ const approved = [];
199
+ const rejected = [];
200
+ const approvedPaths = [];
201
+ const rejectedPaths = [];
202
+ const mismatches = [];
203
+ let hadReject = false;
204
+ for (const change of recomputed?.changes ?? []) {
205
+ const protoChange = changeSet.changes.find((c) => c.id === `${changeSet.id}:${change.path}`);
206
+ const action = protoChange
207
+ ? actionByChangeId.get(protoChange.id) ?? FileDecisionAction.UNSPECIFIED
208
+ : FileDecisionAction.UNSPECIFIED;
209
+ if (action === FileDecisionAction.APPROVE) {
210
+ // Enforcement gate: the bytes we are about to keep must still match what
211
+ // the reviewer approved. A divergence is never silently applied.
212
+ if (protoChange && !digestMatches(change, protoChange)) {
213
+ mismatches.push(change.path);
214
+ continue;
215
+ }
216
+ approved.push(change);
217
+ approvedPaths.push(change.path);
218
+ }
219
+ else {
220
+ if (action === FileDecisionAction.REJECT)
221
+ hadReject = true;
222
+ rejected.push(change);
223
+ rejectedPaths.push(change.path);
224
+ }
225
+ }
226
+ if (mismatches.length > 0) {
227
+ const detail = `on-disk content diverged from the approved digest for: ${mismatches.join(", ")}`;
228
+ appendFileReviewEvents(status, executionId, [
229
+ buildFailedEvent(changeSetContext(changeSet.id, harnessId), FileReviewFailureKind.HASH_MISMATCH, detail),
230
+ ]);
231
+ // Refuse to apply anything: a partial apply under a verification failure is
232
+ // worse than none. The refs are left in place for diagnosis.
233
+ return {
234
+ isCaptureTurn: true,
235
+ approvedPaths: [],
236
+ rejectedPaths: [],
237
+ hadReject,
238
+ failed: true,
239
+ failureDetail: detail,
240
+ };
241
+ }
242
+ // Reconcile git-tracked files from the authoritative refs: approved files keep
243
+ // (re-assert) their "after" bytes; rejected/undecided files snap back to baseline.
244
+ if (recomputed) {
245
+ await applyApprovedPaths(gitRoot, recomputed.afterTree, approved);
246
+ await restoreToBaseline(gitRoot, recomputed.baselineTree, rejected);
247
+ }
248
+ // Reconcile CAS-captured (ignored / non-git) files from the durable manifest,
249
+ // sourced entirely from artifact storage (the CAS analogue of the git refs).
250
+ // Same decision map, keyed by the per-file change id, so the resolution rule is
251
+ // identical across substrates. For a non-git workspace this is the ONLY reconcile.
252
+ if (manifest) {
253
+ const casApproved = [];
254
+ const casRejected = [];
255
+ for (const file of manifest.files) {
256
+ const path = file.pathAfter || file.pathBefore;
257
+ const action = actionByChangeId.get(`${changeSet.id}:${path}`) ?? FileDecisionAction.UNSPECIFIED;
258
+ if (action === FileDecisionAction.APPROVE) {
259
+ casApproved.push(file);
260
+ approvedPaths.push(path);
261
+ }
262
+ else {
263
+ if (action === FileDecisionAction.REJECT)
264
+ hadReject = true;
265
+ casRejected.push(file);
266
+ rejectedPaths.push(path);
267
+ }
268
+ }
269
+ await applyCasApproved({ readBlob: readBlob, workspaceRoot: gitRoot, files: casApproved });
270
+ await restoreCasToBaseline({ readBlob: readBlob, workspaceRoot: gitRoot, files: casRejected });
271
+ }
272
+ // Author RECONCILED carrying the exact post-reconcile snapshot. A git turn
273
+ // re-pins the approved working tree; a CAS-only turn references the durable
274
+ // manifest (the reconciled state is fully derivable from manifest + decisions,
275
+ // and there is no tree to pin).
276
+ let approvedSnapshot;
277
+ if (recomputed) {
278
+ const snap = await snapshotApproved(gitRoot, executionId, excludePaths);
279
+ approvedSnapshot = gitTreeSnapshotRef(snap.treeOid, snap.ref);
280
+ }
281
+ else {
282
+ approvedSnapshot = casManifestSnapshotRef(candidateCasRef(changeSet));
283
+ }
284
+ appendFileReviewEvents(status, executionId, [
285
+ buildReconciledEvent(changeSetContext(changeSet.id, harnessId), approvedSnapshot),
286
+ ]);
287
+ if (recomputed)
288
+ await dropCaptureRefs(gitRoot, executionId);
289
+ return {
290
+ isCaptureTurn: true,
291
+ approvedPaths,
292
+ rejectedPaths,
293
+ hadReject,
294
+ failed: false,
295
+ };
296
+ }
297
+ // ---------------------------------------------------------------------------
298
+ // Internals
299
+ // ---------------------------------------------------------------------------
300
+ /**
301
+ * Resolve each file's effective decision (most-specific-wins, runner-owned):
302
+ * seed every change with the CHANGE_SET decision (if present), then override per
303
+ * file with FILE decisions. Returns change-id -> action.
304
+ */
305
+ function resolveDecisions(changeSet) {
306
+ const byChangeId = new Map();
307
+ const changeSetDecision = changeSet.decisions.find((d) => d.scope === FileDecisionScope.CHANGE_SET);
308
+ if (changeSetDecision) {
309
+ for (const change of changeSet.changes) {
310
+ byChangeId.set(change.id, changeSetDecision.action);
311
+ }
312
+ }
313
+ for (const decision of changeSet.decisions) {
314
+ if (decision.scope === FileDecisionScope.FILE && decision.fileChangeId) {
315
+ byChangeId.set(decision.fileChangeId, decision.action);
316
+ }
317
+ }
318
+ return byChangeId;
319
+ }
320
+ /**
321
+ * Verify the recomputed content still hashes to the digests the reviewer
322
+ * approved. The "after" side is checked for CREATE/MODIFY (the bytes we keep);
323
+ * the "before" side for MODIFY/DELETE (the baseline we restore from / remove).
324
+ *
325
+ * The sha is taken via the shared {@link contentSha256} over the recomputed
326
+ * {@link CapturedContent} — the SAME function that produced the persisted
327
+ * `before_sha256`/`after_sha256` at capture — so it is byte-true for binary and
328
+ * text alike and matches by construction when the underlying bytes are unchanged.
329
+ * (Re-hashing an inline body string here would be lossy for binaries and would
330
+ * spuriously fail an approved binary, since a binary side carries no body.)
331
+ */
332
+ function digestMatches(gitChange, protoChange) {
333
+ if (gitChange.changeType !== FileChangeType.DELETE) {
334
+ if (!gitChange.after || contentSha256(gitChange.after) !== protoChange.afterSha256) {
335
+ return false;
336
+ }
337
+ }
338
+ if (gitChange.changeType !== FileChangeType.CREATE) {
339
+ if (!gitChange.before || contentSha256(gitChange.before) !== protoChange.beforeSha256) {
340
+ return false;
341
+ }
342
+ }
343
+ return true;
344
+ }
345
+ /** The shared change-set context every event for this turn carries. */
346
+ function changeSetContext(changeSetId, harnessId) {
347
+ return {
348
+ changeSetId,
349
+ turnId: changeSetId,
350
+ harnessId,
351
+ timestamp: utcTimestamp(),
352
+ };
353
+ }
354
+ /** Build a git-tree {@link SnapshotRef} for the ledger from a pinned ref. */
355
+ function gitTreeSnapshotRef(treeOid, ref) {
356
+ return create(SnapshotRefSchema, {
357
+ kind: SnapshotKind.GIT_TREE_REF,
358
+ git: create(GitTreeRefSchema, { treeOid, ref }),
359
+ });
360
+ }
361
+ /**
362
+ * Build a HYBRID {@link SnapshotRef} composing the git after-tree with the CAS
363
+ * manifest — the shape for a turn that touched both git-tracked and ignored /
364
+ * non-git paths (design doc 06 D3).
365
+ */
366
+ function hybridSnapshotRef(treeOid, ref, cas) {
367
+ return create(SnapshotRefSchema, {
368
+ kind: SnapshotKind.HYBRID,
369
+ git: create(GitTreeRefSchema, { treeOid, ref }),
370
+ cas: create(CasManifestRefSchema, {
371
+ manifestDigest: cas.manifestDigest,
372
+ artifactUri: cas.artifactUri,
373
+ }),
374
+ });
375
+ }
376
+ /**
377
+ * Build a CAS-only {@link SnapshotRef} — the shape for a non-git workspace, whose
378
+ * every captured path lives in the content-addressed manifest and no git tree
379
+ * exists (DD-21 D2). `cas` is absent for the BASELINE placeholder (the manifest is
380
+ * authored at candidate time); present for CANDIDATE/RECONCILED once it exists.
381
+ */
382
+ function casManifestSnapshotRef(cas) {
383
+ return create(SnapshotRefSchema, {
384
+ kind: SnapshotKind.CAS_MANIFEST,
385
+ cas: cas
386
+ ? create(CasManifestRefSchema, {
387
+ manifestDigest: cas.manifestDigest,
388
+ artifactUri: cas.artifactUri,
389
+ })
390
+ : undefined,
391
+ });
392
+ }
393
+ /**
394
+ * The CAS manifest reference a change set was captured against, read from its
395
+ * CANDIDATE snapshot — the durable record a CAS-only RECONCILED event points back
396
+ * at (the reconciled state is manifest + decisions; there is no tree to re-pin).
397
+ * Undefined when the candidate carried no CAS manifest.
398
+ */
399
+ function candidateCasRef(changeSet) {
400
+ const cas = changeSet.candidateSnapshot?.cas;
401
+ return cas ? { manifestDigest: cas.manifestDigest, artifactUri: cas.artifactUri } : undefined;
402
+ }
403
+ /**
404
+ * Map a CAS-captured file to the harness-agnostic producer input. The before/
405
+ * after bodies are carried as blob REFS (already offloaded to artifact storage
406
+ * by the CAS substrate), never re-inlined — so the CANDIDATE event stays small
407
+ * and the bytes are stored exactly once. Enforcement digests come from the blob
408
+ * content addresses, identical in form to the git path.
409
+ */
410
+ function casToCapturedChangeInput(changeSetId, file) {
411
+ return {
412
+ id: `${changeSetId}:${file.pathAfter || file.pathBefore}`,
413
+ pathBefore: file.pathBefore,
414
+ pathAfter: file.pathAfter,
415
+ kind: file.kind,
416
+ captureClass: file.captureClass,
417
+ before: file.before
418
+ ? {
419
+ kind: "ref",
420
+ sha256: file.before.sha256,
421
+ storageKey: file.before.storageKey,
422
+ sizeBytes: file.before.sizeBytes,
423
+ isBinary: file.before.isBinary,
424
+ }
425
+ : undefined,
426
+ after: file.after
427
+ ? {
428
+ kind: "ref",
429
+ sha256: file.after.sha256,
430
+ storageKey: file.after.storageKey,
431
+ sizeBytes: file.after.sizeBytes,
432
+ isBinary: file.after.isBinary,
433
+ }
434
+ : undefined,
435
+ diffComplete: file.diffComplete,
436
+ };
437
+ }
438
+ /**
439
+ * Map a secret-blocked gitignored path to a content-less producer input (design
440
+ * doc 12, DD-E). The bytes are deliberately never captured, so both sides are
441
+ * absent (empty enforcement digests) and `diffComplete=false`. Being non-binary
442
+ * incomplete with no keepable bytes, it forces the change set to PARTIAL_BLOCKED
443
+ * (never BINARY_SUMMARY_ONLY) — approval is blocked and the path is surfaced
444
+ * honestly, while its CONTENT never enters the ledger or storage. `blockedReason` records
445
+ * the honest cause (SECRET_WITHHELD) so the review UI can say *why* rather than
446
+ * showing a cause-agnostic "unavailable" (doc 15). Kind is MODIFY: the write was
447
+ * blocked before it ran, so create-vs-modify is unknown and irrelevant (nothing
448
+ * is ever applied or reconciled for this entry). `captureClass` is the turn's CAS
449
+ * substrate class (GIT_IGNORED_CAPTURED | NON_GIT_CAS) so the blocked path is
450
+ * labeled with its true provenance.
451
+ */
452
+ function unreviewableChangeInput(changeSetId, path, captureClass) {
453
+ return {
454
+ id: `${changeSetId}:${path}`,
455
+ pathBefore: path,
456
+ pathAfter: path,
457
+ kind: FileChangeKind.MODIFY,
458
+ captureClass,
459
+ diffComplete: false,
460
+ blockedReason: FileReviewBlockReason.SECRET_WITHHELD,
461
+ };
462
+ }
463
+ /** Map the git capture kind to the file-review {@link FileChangeKind}. */
464
+ function toFileChangeKind(changeType) {
465
+ switch (changeType) {
466
+ case FileChangeType.CREATE:
467
+ return FileChangeKind.ADD;
468
+ case FileChangeType.DELETE:
469
+ return FileChangeKind.DELETE;
470
+ default:
471
+ return FileChangeKind.MODIFY;
472
+ }
473
+ }
474
+ /**
475
+ * Map a git-derived capture (`--no-renames`, so ADD/MODIFY/DELETE) to the
476
+ * harness-agnostic producer input. The before/after content is the
477
+ * {@link CapturedContent} the substrate derived from the exact blob bytes; a
478
+ * binary side (carried as a content address, no body) marks the file incomplete
479
+ * so the change set cannot be approved as a complete text diff.
480
+ */
481
+ function toCapturedChangeInput(changeSetId, change) {
482
+ const isCreate = change.changeType === FileChangeType.CREATE;
483
+ const isDelete = change.changeType === FileChangeType.DELETE;
484
+ const pathBefore = isCreate ? "" : change.path;
485
+ const pathAfter = isDelete ? "" : change.path;
486
+ const binary = change.before?.kind === "binary" || change.after?.kind === "binary";
487
+ return {
488
+ id: `${changeSetId}:${pathAfter || pathBefore}`,
489
+ pathBefore,
490
+ pathAfter,
491
+ kind: toFileChangeKind(change.changeType),
492
+ captureClass: FileCaptureClass.GIT_TRACKED,
493
+ before: change.before,
494
+ after: change.after,
495
+ diffComplete: !binary,
496
+ };
497
+ }
498
+ //# sourceMappingURL=capture.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"capture.js","sourceRoot":"","sources":["../../../src/shared/filereview/capture.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EACL,gBAAgB,EAChB,cAAc,EACd,cAAc,EACd,kBAAkB,EAClB,iBAAiB,EACjB,qBAAqB,EACrB,qBAAqB,EACrB,YAAY,GACb,MAAM,8DAA8D,CAAC;AAEtE,OAAO,EACL,oBAAoB,EACpB,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,oEAAoE,CAAC;AAO5E,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EACL,sBAAsB,EACtB,0BAA0B,EAC1B,2BAA2B,EAC3B,uBAAuB,EACvB,gBAAgB,EAChB,oBAAoB,EACpB,aAAa,GAGd,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,kBAAkB,EAClB,WAAW,EACX,gBAAgB,EAChB,UAAU,EACV,eAAe,EACf,kBAAkB,EAClB,iBAAiB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