@stigmer/runner 3.0.9-dev.20260615153829 → 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 (329) 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 +16 -3
  74. package/dist/activities/execute-deep-agent/hitl.js +11 -3
  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 +393 -33
  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 +17 -5
  92. package/dist/activities/execute-deep-agent/status-builder.js +44 -3
  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 +32 -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 +284 -0
  243. package/src/activities/execute-deep-agent/__tests__/hitl.test.ts +14 -36
  244. package/src/activities/execute-deep-agent/__tests__/inline-publisher.test.ts +31 -13
  245. package/src/activities/execute-deep-agent/__tests__/sequential-gate-resume.test.ts +349 -0
  246. package/src/activities/execute-deep-agent/__tests__/stamp-flowed-rows.test.ts +119 -0
  247. package/src/activities/execute-deep-agent/__tests__/status-builder.test.ts +91 -10
  248. package/src/activities/execute-deep-agent/__tests__/streaming-v3.test.ts +9 -9
  249. package/src/activities/execute-deep-agent/__tests__/subagent-approval-propagation.test.ts +160 -0
  250. package/src/activities/execute-deep-agent/__tests__/subagent-gitignored-capture.test.ts +213 -0
  251. package/src/activities/execute-deep-agent/__tests__/subagent-transformer.test.ts +3 -6
  252. package/src/activities/execute-deep-agent/__tests__/subagent-wiring.test.ts +84 -1
  253. package/src/activities/execute-deep-agent/__tests__/v3-status-builder.test.ts +4 -1
  254. package/src/activities/execute-deep-agent/approval-file-change.ts +80 -0
  255. package/src/activities/execute-deep-agent/attachment-injector.ts +20 -11
  256. package/src/activities/execute-deep-agent/cas-capture-backend.ts +66 -0
  257. package/src/activities/execute-deep-agent/cas-capture-observer.ts +125 -0
  258. package/src/activities/execute-deep-agent/hitl.ts +23 -7
  259. package/src/activities/execute-deep-agent/index.ts +463 -40
  260. package/src/activities/execute-deep-agent/inline-publisher.ts +27 -4
  261. package/src/activities/execute-deep-agent/setup.ts +223 -125
  262. package/src/activities/execute-deep-agent/stamp-flowed-rows.ts +64 -0
  263. package/src/activities/execute-deep-agent/status-builder-shared.ts +62 -23
  264. package/src/activities/execute-deep-agent/status-builder.ts +63 -8
  265. package/src/activities/execute-deep-agent/streaming-side-effects.ts +2 -16
  266. package/src/activities/execute-deep-agent/streaming.ts +3 -13
  267. package/src/activities/execute-deep-agent/subagent-transformer.ts +53 -13
  268. package/src/activities/execute-deep-agent/subagent-wiring.ts +50 -3
  269. package/src/activities/execute-deep-agent/v3-status-builder.ts +36 -2
  270. package/src/claimcheck/payload-codec.ts +8 -8
  271. package/src/client/stigmer-client.ts +9 -1
  272. package/src/middleware/__tests__/approval-gate.test.ts +488 -4
  273. package/src/middleware/approval-gate.ts +247 -38
  274. package/src/middleware/types.ts +5 -5
  275. package/src/shared/__tests__/activity-input.test.ts +78 -0
  276. package/src/shared/__tests__/approval-canonicalize.test.ts +106 -0
  277. package/src/shared/__tests__/approval-fingerprint.test.ts +115 -0
  278. package/src/shared/__tests__/approval-policy.test.ts +274 -40
  279. package/src/shared/__tests__/args-preview.test.ts +78 -0
  280. package/src/shared/__tests__/artifact-storage-extended.test.ts +62 -10
  281. package/src/shared/__tests__/artifact-storage.test.ts +123 -11
  282. package/src/shared/__tests__/file-change.test.ts +85 -0
  283. package/src/shared/__tests__/file-tools.test.ts +90 -0
  284. package/src/shared/__tests__/fingerprint-secret.test.ts +51 -0
  285. package/src/shared/__tests__/lease-scope-corpus.test.ts +56 -0
  286. package/src/shared/__tests__/model-client.test.ts +162 -0
  287. package/src/shared/__tests__/plan-artifact.test.ts +11 -26
  288. package/src/shared/__tests__/policy-source-corpus.test.ts +58 -0
  289. package/src/shared/__tests__/status-offload.test.ts +573 -16
  290. package/src/shared/__tests__/status.test.ts +4 -5
  291. package/src/shared/__tests__/tool-kind.test.ts +24 -1
  292. package/src/shared/__tests__/tool-row.test.ts +221 -0
  293. package/src/shared/activity-input.ts +57 -0
  294. package/src/shared/approval-canonicalize.ts +159 -0
  295. package/src/shared/approval-fingerprint.ts +148 -0
  296. package/src/shared/approval-policy.ts +303 -27
  297. package/src/shared/args-preview.ts +98 -0
  298. package/src/shared/artifact-storage.ts +62 -11
  299. package/src/shared/checkpointer/__tests__/http-saver.test.ts +1 -2
  300. package/src/shared/file-change.ts +64 -0
  301. package/src/shared/file-tools.ts +169 -0
  302. package/src/shared/filereview/__tests__/capture.test.ts +856 -0
  303. package/src/shared/filereview/__tests__/cas-substrate.test.ts +404 -0
  304. package/src/shared/filereview/__tests__/digest.test.ts +100 -0
  305. package/src/shared/filereview/__tests__/events.test.ts +245 -0
  306. package/src/shared/filereview/__tests__/git-substrate.test.ts +362 -0
  307. package/src/shared/filereview/__tests__/proxy-reconcile.test.ts +286 -0
  308. package/src/shared/filereview/__tests__/secret-paths.test.ts +121 -0
  309. package/src/shared/filereview/capture.ts +727 -0
  310. package/src/shared/filereview/cas-substrate.ts +401 -0
  311. package/src/shared/filereview/digest.ts +83 -0
  312. package/src/shared/filereview/events.ts +449 -0
  313. package/src/shared/filereview/git-substrate.ts +555 -0
  314. package/src/shared/filereview/index.ts +60 -0
  315. package/src/shared/filereview/secret-paths.ts +121 -0
  316. package/src/shared/fingerprint-secret.ts +53 -0
  317. package/src/shared/model-client.ts +122 -0
  318. package/src/shared/plan-artifact.ts +0 -2
  319. package/src/shared/status-offload.ts +433 -77
  320. package/src/shared/status.ts +13 -0
  321. package/src/shared/tool-kind.ts +33 -0
  322. package/src/shared/tool-row.ts +135 -0
  323. package/src/shared/workspace/platform-dir.ts +41 -2
  324. package/src/workflow-engine/__tests__/golden-execution.test.ts +35 -18
  325. package/src/workflow-engine/__tests__/tasks/try.test.ts +1 -1
  326. package/src/workflows/__tests__/connect-mcp-server.test.ts +304 -29
  327. package/src/workflows/call-agent-orchestrator.ts +53 -6
  328. package/src/workflows/connect-mcp-server.ts +179 -24
  329. package/src/workflows/types.ts +8 -0
@@ -0,0 +1,123 @@
1
+ /**
2
+ * Cursor deny-oracle adapter for the HITL gateway Contract Test Kit.
3
+ *
4
+ * Drives the REAL out-of-process gateway: the runner writes the approval state
5
+ * file (with any grants), then the generated bash preToolUse hook makes the
6
+ * allow/deny decision for the tool the agent would run inside cursor-agent. There
7
+ * is no in-process execution to observe, so `executed` means "the hook allowed
8
+ * it" and the substrate cannot count executions (`observesExecution: false`).
9
+ *
10
+ * Cross-taxonomy by construction: grants are minted from the STREAM-side identity
11
+ * (`edit`/`shell`/`delete`), while the hook is fed the HOOK-side payload
12
+ * (`Write`/`Shell`/`Delete`). So every approve drive exercises the category
13
+ * collapse that lets a stream-minted grant match a hook-named call. The grant
14
+ * token binds the exact resource, so this substrate enforces lease isolation
15
+ * (`enforcesExactResource: true`) and implements `authorizeAfterGrant`.
16
+ */
17
+ import { setupCursorHookHarness, hasBash, hookWrite, hookShell, hookDelete, hookRead, hookMcp, } from "./cursor-hook-harness.js";
18
+ import { toolIdentity } from "../approval-state.js";
19
+ import { contentDigest } from "../../../shared/file-tools.js";
20
+ /** Build the real preToolUse hook-input payload for an abstract action. */
21
+ function hookInputFor(action) {
22
+ switch (action.kind) {
23
+ case "write":
24
+ return hookWrite(action.resource, action.content ?? "x");
25
+ case "shell":
26
+ return hookShell(action.resource);
27
+ case "delete":
28
+ return hookDelete(action.resource);
29
+ case "read":
30
+ return hookRead(action.resource);
31
+ case "mcp":
32
+ return hookMcp(action.mcpToolName ?? "mcp_tool");
33
+ }
34
+ }
35
+ // Stream-side (SDK) tool name per gated category — deliberately the OTHER
36
+ // taxonomy from the hook input, so a grant minted here matches a hook-named call
37
+ // only via the canonical category, not the raw name.
38
+ const STREAM_NAME = {
39
+ write: "edit",
40
+ shell: "shell",
41
+ delete: "delete",
42
+ };
43
+ /**
44
+ * Mint the approval grant for an action using its stream-side identity. Only the
45
+ * gated built-in categories are ever granted in the contract (read is never
46
+ * gated; the MCP cases under test are auto-approved, needing no grant).
47
+ */
48
+ function grantFor(action) {
49
+ if (action.kind === "read" || action.kind === "mcp") {
50
+ throw new Error(`grantFor: ${action.kind} actions are not granted in the contract`);
51
+ }
52
+ const streamName = STREAM_NAME[action.kind];
53
+ // Mirror hookInputFor: a write carries whole-file content (so its digest is
54
+ // content-exact and matches the hook's), a delete carries only a path (no
55
+ // content), and a shell carries its command (the salient is already exact).
56
+ const args = action.kind === "shell"
57
+ ? { command: action.resource }
58
+ : action.kind === "delete"
59
+ ? { path: action.resource }
60
+ : { path: action.resource, content: action.content ?? "x" };
61
+ const identity = toolIdentity(streamName, "", args);
62
+ return {
63
+ toolName: streamName,
64
+ mcpServerSlug: "",
65
+ key: identity.key,
66
+ salient: identity.salient,
67
+ // Content-exact for a write (the sibling-isolation probe), coarse otherwise —
68
+ // matching how the runner grants from the authoritative captured args.
69
+ contentDigest: contentDigest(args),
70
+ sourceToolCallId: `consent-${action.kind}`,
71
+ };
72
+ }
73
+ async function decide(grants, action) {
74
+ // MCP cases under test are auto-approved: no policy entry, so the hook allows
75
+ // them. Built-ins are gated by the script's baked-in category set, not state.
76
+ const harness = setupCursorHookHarness({ grants });
77
+ const { permission } = harness.decide(hookInputFor(action));
78
+ const executed = permission === "allow";
79
+ return { executed, gated: !executed };
80
+ }
81
+ // A gated built-in's contract kind IS its approval category (write/shell/delete),
82
+ // so it doubles as the leasedCategories entry the hook reads.
83
+ function leaseCategoryOf(action) {
84
+ if (action.kind === "read" || action.kind === "mcp") {
85
+ throw new Error(`leaseCategoryOf: ${action.kind} is not a leasable built-in class`);
86
+ }
87
+ return action.kind;
88
+ }
89
+ export function createCursorSubstrate() {
90
+ return {
91
+ name: "cursor",
92
+ available: hasBash,
93
+ capabilities: {
94
+ observesExecution: false,
95
+ enforcesExactResource: true,
96
+ // The grant binds (category, path, contentDigest), so a DIFFERENT edit to
97
+ // the same file re-gates — the sibling-hole fix.
98
+ enforcesExactContent: true,
99
+ appliesRunLifetimeLease: true,
100
+ // The Cursor hook's deny decision does not carry approval_policy_source;
101
+ // provenance is projected at message-reconstruction time (message-translator)
102
+ // and asserted by the corpus + resolveApprovalProvenance suites instead.
103
+ surfacesGatePolicySource: false,
104
+ },
105
+ async authorize(action, decision) {
106
+ const grants = decision === "approve" ? [grantFor(action)] : [];
107
+ return decide(grants, action);
108
+ },
109
+ async authorizeAfterGrant(granted, probe) {
110
+ return decide([grantFor(granted)], probe);
111
+ },
112
+ async authorizeUnderClassLease(leased, probe) {
113
+ // A run-lifetime category lease is carried in the state file (no per-call
114
+ // grant), exactly as the runner writes it after an APPROVE_ALL; the hook
115
+ // allows a probe iff its category is leased.
116
+ const harness = setupCursorHookHarness({ leasedCategories: [leaseCategoryOf(leased)] });
117
+ const { permission } = harness.decide(hookInputFor(probe));
118
+ const executed = permission === "allow";
119
+ return { executed, gated: !executed };
120
+ },
121
+ };
122
+ }
123
+ //# sourceMappingURL=gateway-substrate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gateway-substrate.js","sourceRoot":"","sources":["../../../../src/activities/execute-cursor/__test-utils__/gateway-substrate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EACL,sBAAsB,EACtB,OAAO,EACP,SAAS,EACT,SAAS,EACT,UAAU,EACV,QAAQ,EACR,OAAO,GACR,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,YAAY,EAAsB,MAAM,sBAAsB,CAAC;AACxE,OAAO,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- import type { ToolApprovalOverride } from "@stigmer/protos/ai/stigmer/agentic/agent/v1/spec_pb";
19
- import type { ResolvedMcpServer } from "./mcp-resolver.js";
18
+ import { toolApprovalCategory, type ToolApprovalCategory } from "../../shared/tool-kind.js";
19
+ export { mergeApprovalPolicies, lookupMcpToolPolicy, resolveApprovalMessage, POLICY_ENGINE_VERSION, } from "../../shared/approval-policy.js";
20
+ export type { MergedToolPolicy, PolicySource } from "../../shared/approval-policy.js";
20
21
  /**
21
- * A single tool's merged approval decision after evaluating all policy layers.
22
- */
23
- export interface MergedToolPolicy {
24
- toolName: string;
25
- mcpServerSlug: string;
26
- requiresApproval: boolean;
27
- approvalMessage: string;
28
- }
29
- /**
30
- * Canonical approval category for a gated tool, derived from EITHER taxonomy's
31
- * name via the shared {@link classifyTool}.
22
+ * Canonical approval category for a gated tool.
32
23
  *
33
- * The hook (`Write`/`Shell`/`Delete`) and the stream (`edit`/`shell`/`delete`)
34
- * name the same operation differently, so neither raw name is a stable
35
- * cross-layer identity. The category collapses both onto one value so the denial
36
- * ledger (recorded by the hook) correlates to the streamed tool call (read by
37
- * the runner) and so an approval grant matches the agent's re-attempt on
38
- * reinvocation regardless of which taxonomy named it. `FILE_WRITE` and
39
- * `FILE_EDIT` both map to `write` because the Cursor hook reports every file
40
- * mutation — create or edit — as `Write`.
24
+ * This is the cross-substrate identity, and it lives in ONE place:
25
+ * {@link toolApprovalCategory} in shared/tool-kind.ts (shared with the deep-agent
26
+ * gateway). The names below are kept as the Cursor harness's public surface
27
+ * (`approvalCategory` / `ApprovalCategory`) so existing imports do not churn, but
28
+ * they are exact aliases there is no second implementation to drift.
41
29
  *
42
- * Returns undefined for non-gated tools (read-only built-ins, MCP tools, and
43
- * anything `classifyTool` does not place in a mutating kind).
30
+ * Why this matters here: the hook (`Write`/`Shell`/`Delete`) and the stream
31
+ * (`edit`/`shell`/`delete`) name the same operation differently, so neither raw
32
+ * name is a stable cross-layer identity. The category collapses both onto one
33
+ * value so the denial ledger (recorded by the hook) correlates to the streamed
34
+ * tool call (read by the runner) and an approval grant matches the agent's
35
+ * re-attempt on reinvocation regardless of which taxonomy named it.
44
36
  */
45
- export type ApprovalCategory = "write" | "delete" | "shell";
46
- export declare function approvalCategory(toolName: string): ApprovalCategory | undefined;
37
+ export type ApprovalCategory = ToolApprovalCategory;
38
+ export declare const approvalCategory: typeof toolApprovalCategory;
47
39
  /**
48
40
  * Top-level tool-argument fields, in priority order, that identify the specific
49
41
  * resource a built-in tool acts on. The list deliberately spans BOTH taxonomies'
@@ -105,39 +97,3 @@ export declare function getBuiltInApprovalMessage(toolName: string): string | un
105
97
  * drift.
106
98
  */
107
99
  export declare function extractArgKey(args: Record<string, unknown> | undefined): string;
108
- /**
109
- * Merge approval policies from all four levels into a single lookup map.
110
- *
111
- * Keys are the raw tool name (e.g., "apply_cloud_resource"). Each MCP server
112
- * contributes its own set of policies, so the map is keyed by
113
- * "serverSlug/toolName" to avoid collisions between servers.
114
- *
115
- * Policy chain (each level overrides the previous):
116
- * 1. status.toolApprovals — presence means "requires approval"
117
- * 2. spec.pinnedToolApprovals — presence means "requires approval" (overrides)
118
- * 3. agent tool_approval_overrides — explicit boolean per tool
119
- * 4. auto_approve_all — bypasses everything
120
- *
121
- * When auto_approve_all is true, the returned map is empty (no tool
122
- * requires approval).
123
- */
124
- export declare function mergeApprovalPolicies(resolvedServers: ResolvedMcpServer[], agentOverrides: ToolApprovalOverride[], autoApproveAll: boolean): Map<string, MergedToolPolicy>;
125
- /**
126
- * Look up whether an MCP tool requires approval.
127
- *
128
- * @param toolName - The actual MCP tool name (e.g., "apply_cloud_resource")
129
- * @param mcpServerSlug - The MCP server slug (e.g., "planton")
130
- * @param policies - The merged policy map from mergeApprovalPolicies()
131
- * @returns The policy if approval is required, undefined if auto-approved
132
- */
133
- export declare function lookupMcpToolPolicy(toolName: string, mcpServerSlug: string, policies: Map<string, MergedToolPolicy>): MergedToolPolicy | undefined;
134
- /**
135
- * Resolve {{args.field}} placeholders in an approval message using the
136
- * tool's actual arguments.
137
- *
138
- * Placeholder syntax matches the proto-documented format:
139
- * - {{args.field_name}} — replaced with the argument value
140
- * - {{tool_name}} — replaced with the tool name
141
- * - Missing fields are replaced with "<unknown>"
142
- */
143
- export declare function resolveApprovalMessage(template: string, toolName: string, args: Record<string, unknown>): string;
@@ -15,8 +15,13 @@
15
15
  * allows or denies the call. For built-in Cursor tools (Shell, Read, etc.),
16
16
  * a separate local policy applies.
17
17
  */
18
- import { ToolKind } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/enum_pb";
19
- import { classifyTool } from "../../shared/tool-kind.js";
18
+ import { toolApprovalCategory } from "../../shared/tool-kind.js";
19
+ // The four-level MCP policy merge is harness-agnostic and lives in exactly one
20
+ // place (shared/approval-policy.ts) so the Cursor and native harnesses can never
21
+ // diverge. Re-exported here so existing Cursor-harness imports
22
+ // (`from "./approval-policy.js"`) keep working unchanged. This module now owns
23
+ // only the Cursor-specific built-in-tool gating helpers below.
24
+ export { mergeApprovalPolicies, lookupMcpToolPolicy, resolveApprovalMessage, POLICY_ENGINE_VERSION, } from "../../shared/approval-policy.js";
20
25
  /**
21
26
  * Built-in Cursor tools the preToolUse hook gates, named as the hook receives
22
27
  * them.
@@ -36,19 +41,7 @@ const BUILT_IN_GATED = new Set([
36
41
  "Shell",
37
42
  "Delete",
38
43
  ]);
39
- export function approvalCategory(toolName) {
40
- switch (classifyTool(toolName)) {
41
- case ToolKind.FILE_WRITE:
42
- case ToolKind.FILE_EDIT:
43
- return "write";
44
- case ToolKind.FILE_DELETE:
45
- return "delete";
46
- case ToolKind.SHELL:
47
- return "shell";
48
- default:
49
- return undefined;
50
- }
51
- }
44
+ export const approvalCategory = toolApprovalCategory;
52
45
  /**
53
46
  * Human-readable approval-message template per canonical category. Keyed by
54
47
  * category (not raw tool name) so a denial surfaced from either taxonomy renders
@@ -147,109 +140,4 @@ export function extractArgKey(args) {
147
140
  }
148
141
  return "";
149
142
  }
150
- /**
151
- * Merge approval policies from all four levels into a single lookup map.
152
- *
153
- * Keys are the raw tool name (e.g., "apply_cloud_resource"). Each MCP server
154
- * contributes its own set of policies, so the map is keyed by
155
- * "serverSlug/toolName" to avoid collisions between servers.
156
- *
157
- * Policy chain (each level overrides the previous):
158
- * 1. status.toolApprovals — presence means "requires approval"
159
- * 2. spec.pinnedToolApprovals — presence means "requires approval" (overrides)
160
- * 3. agent tool_approval_overrides — explicit boolean per tool
161
- * 4. auto_approve_all — bypasses everything
162
- *
163
- * When auto_approve_all is true, the returned map is empty (no tool
164
- * requires approval).
165
- */
166
- export function mergeApprovalPolicies(resolvedServers, agentOverrides, autoApproveAll) {
167
- const merged = new Map();
168
- if (autoApproveAll)
169
- return merged;
170
- for (const server of resolvedServers) {
171
- const serverPolicies = new Map();
172
- // Layer 1: system-generated defaults (presence = requires approval)
173
- for (const policy of server.toolApprovals) {
174
- if (!policy.toolName)
175
- continue;
176
- serverPolicies.set(policy.toolName, {
177
- requiresApproval: true,
178
- message: policy.message || `Execute tool: ${policy.toolName}`,
179
- });
180
- }
181
- // Layer 2: manual overrides (presence = requires approval, overrides layer 1)
182
- for (const pinned of server.pinnedToolApprovals) {
183
- if (!pinned.toolName)
184
- continue;
185
- serverPolicies.set(pinned.toolName, {
186
- requiresApproval: true,
187
- message: pinned.message || serverPolicies.get(pinned.toolName)?.message || `Execute tool: ${pinned.toolName}`,
188
- });
189
- }
190
- // Layer 3: per-agent overrides (explicit boolean, can enable or disable)
191
- for (const override of agentOverrides) {
192
- if (!override.toolName)
193
- continue;
194
- const existing = serverPolicies.get(override.toolName);
195
- if (existing) {
196
- existing.requiresApproval = override.requiresApproval;
197
- if (override.message) {
198
- existing.message = override.message;
199
- }
200
- }
201
- else if (override.requiresApproval) {
202
- serverPolicies.set(override.toolName, {
203
- requiresApproval: true,
204
- message: override.message || `Execute tool: ${override.toolName}`,
205
- });
206
- }
207
- }
208
- // Write merged policies into the result map
209
- for (const [toolName, policy] of serverPolicies) {
210
- if (!policy.requiresApproval)
211
- continue;
212
- const key = `${server.slug}/${toolName}`;
213
- merged.set(key, {
214
- toolName,
215
- mcpServerSlug: server.slug,
216
- requiresApproval: true,
217
- approvalMessage: policy.message,
218
- });
219
- }
220
- }
221
- return merged;
222
- }
223
- /**
224
- * Look up whether an MCP tool requires approval.
225
- *
226
- * @param toolName - The actual MCP tool name (e.g., "apply_cloud_resource")
227
- * @param mcpServerSlug - The MCP server slug (e.g., "planton")
228
- * @param policies - The merged policy map from mergeApprovalPolicies()
229
- * @returns The policy if approval is required, undefined if auto-approved
230
- */
231
- export function lookupMcpToolPolicy(toolName, mcpServerSlug, policies) {
232
- return policies.get(`${mcpServerSlug}/${toolName}`);
233
- }
234
- /**
235
- * Resolve {{args.field}} placeholders in an approval message using the
236
- * tool's actual arguments.
237
- *
238
- * Placeholder syntax matches the proto-documented format:
239
- * - {{args.field_name}} — replaced with the argument value
240
- * - {{tool_name}} — replaced with the tool name
241
- * - Missing fields are replaced with "<unknown>"
242
- */
243
- export function resolveApprovalMessage(template, toolName, args) {
244
- return template
245
- .replace(/\{\{tool_name\}\}/g, toolName)
246
- .replace(/\{\{args\.(\w+)\}\}/g, (_match, field) => {
247
- const value = args[field];
248
- if (value === undefined || value === null)
249
- return "<unknown>";
250
- if (typeof value === "string")
251
- return value;
252
- return JSON.stringify(value);
253
- });
254
- }
255
143
  //# sourceMappingURL=approval-policy.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"approval-policy.js","sourceRoot":"","sources":["../../../src/activities/execute-cursor/approval-policy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAIH,OAAO,EAAE,QAAQ,EAAE,MAAM,8DAA8D,CAAC;AAExF,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAYzD;;;;;;;;;;;GAWG;AACH,MAAM,cAAc,GAAwB,IAAI,GAAG,CAAC;IAClD,OAAO;IACP,YAAY;IACZ,cAAc;IACd,OAAO;IACP,QAAQ;CACT,CAAC,CAAC;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IAAI;gBAC1B,gBAAgB,EAAE,IAAI;gBACtB,eAAe,EAAE,MAAM,CAAC,OAAO;aAChC,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,mBAAmB,CACjC,QAAgB,EAChB,aAAqB,EACrB,QAAuC;IAEvC,OAAO,QAAQ,CAAC,GAAG,CAAC,GAAG,aAAa,IAAI,QAAQ,EAAE,CAAC,CAAC;AACtD,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,sBAAsB,CACpC,QAAgB,EAChB,QAAgB,EAChB,IAA6B;IAE7B,OAAO,QAAQ;SACZ,OAAO,CAAC,oBAAoB,EAAE,QAAQ,CAAC;SACvC,OAAO,CAAC,sBAAsB,EAAE,CAAC,MAAM,EAAE,KAAa,EAAE,EAAE;QACzD,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;QAC1B,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI;YAAE,OAAO,WAAW,CAAC;QAC9D,IAAI,OAAO,KAAK,KAAK,QAAQ;YAAE,OAAO,KAAK,CAAC;QAC5C,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IAC/B,CAAC,CAAC,CAAC;AACP,CAAC"}
1
+ {"version":3,"file":"approval-policy.js","sourceRoot":"","sources":["../../../src/activities/execute-cursor/approval-policy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,oBAAoB,EAA6B,MAAM,2BAA2B,CAAC;AAE5F,+EAA+E;AAC/E,iFAAiF;AACjF,+DAA+D;AAC/D,+EAA+E;AAC/E,+DAA+D;AAC/D,OAAO,EACL,qBAAqB,EACrB,mBAAmB,EACnB,sBAAsB,EACtB,qBAAqB,GACtB,MAAM,iCAAiC,CAAC;AAGzC;;;;;;;;;;;GAWG;AACH,MAAM,cAAc,GAAwB,IAAI,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