@stigmer/runner 3.14.1 → 3.15.1

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 (320) hide show
  1. package/dist/.build-fingerprint +1 -1
  2. package/dist/__test-utils__/execution-record-fixture.d.ts +47 -0
  3. package/dist/__test-utils__/execution-record-fixture.js +68 -0
  4. package/dist/__test-utils__/execution-record-fixture.js.map +1 -0
  5. package/dist/__test-utils__/harness-contract/types.d.ts +166 -0
  6. package/dist/__test-utils__/harness-contract/types.js +49 -0
  7. package/dist/__test-utils__/harness-contract/types.js.map +1 -0
  8. package/dist/__test-utils__/hermetic-activity.d.ts +28 -5
  9. package/dist/__test-utils__/hermetic-activity.js +23 -7
  10. package/dist/__test-utils__/hermetic-activity.js.map +1 -1
  11. package/dist/__test-utils__/mock-workspace.d.ts +15 -0
  12. package/dist/__test-utils__/mock-workspace.js +21 -0
  13. package/dist/__test-utils__/mock-workspace.js.map +1 -0
  14. package/dist/__test-utils__/model-registry-fixture.d.ts +56 -0
  15. package/dist/__test-utils__/model-registry-fixture.js +66 -0
  16. package/dist/__test-utils__/model-registry-fixture.js.map +1 -0
  17. package/dist/__test-utils__/turn-input-fixture.d.ts +60 -0
  18. package/dist/__test-utils__/turn-input-fixture.js +118 -0
  19. package/dist/__test-utils__/turn-input-fixture.js.map +1 -0
  20. package/dist/activities/execute-cursor/__test-utils__/contract-subject.d.ts +107 -0
  21. package/dist/activities/execute-cursor/__test-utils__/contract-subject.js +344 -0
  22. package/dist/activities/execute-cursor/__test-utils__/contract-subject.js.map +1 -0
  23. package/dist/activities/execute-cursor/__test-utils__/cursor-hook-harness.d.ts +20 -0
  24. package/dist/activities/execute-cursor/__test-utils__/cursor-hook-harness.js +58 -0
  25. package/dist/activities/execute-cursor/__test-utils__/cursor-hook-harness.js.map +1 -1
  26. package/dist/activities/execute-cursor/__test-utils__/gateway-substrate.js +2 -32
  27. package/dist/activities/execute-cursor/__test-utils__/gateway-substrate.js.map +1 -1
  28. package/dist/activities/execute-cursor/__test-utils__/hermetic-cursor.d.ts +38 -62
  29. package/dist/activities/execute-cursor/__test-utils__/hermetic-cursor.js +47 -121
  30. package/dist/activities/execute-cursor/__test-utils__/hermetic-cursor.js.map +1 -1
  31. package/dist/activities/execute-cursor/__test-utils__/scripted-agent.d.ts +17 -1
  32. package/dist/activities/execute-cursor/__test-utils__/scripted-agent.js +27 -4
  33. package/dist/activities/execute-cursor/__test-utils__/scripted-agent.js.map +1 -1
  34. package/dist/activities/execute-cursor/__test-utils__/scripted-sdk.d.ts +52 -11
  35. package/dist/activities/execute-cursor/__test-utils__/scripted-sdk.js +66 -7
  36. package/dist/activities/execute-cursor/__test-utils__/scripted-sdk.js.map +1 -1
  37. package/dist/activities/execute-cursor/adapter.d.ts +55 -0
  38. package/dist/activities/execute-cursor/adapter.js +119 -0
  39. package/dist/activities/execute-cursor/adapter.js.map +1 -0
  40. package/dist/activities/execute-cursor/approval-state.d.ts +2 -2
  41. package/dist/activities/execute-cursor/approval-state.js.map +1 -1
  42. package/dist/activities/execute-cursor/capture-flow.d.ts +15 -30
  43. package/dist/activities/execute-cursor/capture-flow.js +17 -26
  44. package/dist/activities/execute-cursor/capture-flow.js.map +1 -1
  45. package/dist/activities/execute-cursor/cursor-capabilities.d.ts +23 -0
  46. package/dist/activities/execute-cursor/cursor-capabilities.js +33 -0
  47. package/dist/activities/execute-cursor/cursor-capabilities.js.map +1 -0
  48. package/dist/activities/execute-cursor/cursor-mcp-config.d.ts +2 -2
  49. package/dist/activities/execute-cursor/cursor-mcp-config.js.map +1 -1
  50. package/dist/activities/execute-cursor/fetch-interceptor.d.ts +15 -25
  51. package/dist/activities/execute-cursor/fetch-interceptor.js +39 -33
  52. package/dist/activities/execute-cursor/fetch-interceptor.js.map +1 -1
  53. package/dist/activities/execute-cursor/http2-interceptor.d.ts +21 -17
  54. package/dist/activities/execute-cursor/http2-interceptor.js +38 -31
  55. package/dist/activities/execute-cursor/http2-interceptor.js.map +1 -1
  56. package/dist/activities/execute-cursor/message-translator.d.ts +28 -19
  57. package/dist/activities/execute-cursor/message-translator.js +76 -27
  58. package/dist/activities/execute-cursor/message-translator.js.map +1 -1
  59. package/dist/activities/execute-cursor/prompt-builder.d.ts +180 -11
  60. package/dist/activities/execute-cursor/prompt-builder.js +171 -0
  61. package/dist/activities/execute-cursor/prompt-builder.js.map +1 -1
  62. package/dist/activities/execute-cursor/rejection-capture.d.ts +3 -6
  63. package/dist/activities/execute-cursor/rejection-capture.js +5 -7
  64. package/dist/activities/execute-cursor/rejection-capture.js.map +1 -1
  65. package/dist/activities/execute-cursor/session-lifecycle.d.ts +1 -4
  66. package/dist/activities/execute-cursor/session-lifecycle.js.map +1 -1
  67. package/dist/activities/execute-cursor/turn-boundary.d.ts +1 -1
  68. package/dist/activities/execute-cursor/turn-settle.d.ts +49 -0
  69. package/dist/activities/execute-cursor/turn-settle.js +507 -0
  70. package/dist/activities/execute-cursor/turn-settle.js.map +1 -0
  71. package/dist/activities/execute-cursor/turn-setup.d.ts +173 -0
  72. package/dist/activities/execute-cursor/turn-setup.js +496 -0
  73. package/dist/activities/execute-cursor/turn-setup.js.map +1 -0
  74. package/dist/activities/execute-cursor/turn-stream.d.ts +41 -71
  75. package/dist/activities/execute-cursor/turn-stream.js +70 -135
  76. package/dist/activities/execute-cursor/turn-stream.js.map +1 -1
  77. package/dist/activities/execute-cursor/turn.d.ts +43 -0
  78. package/dist/activities/execute-cursor/turn.js +222 -0
  79. package/dist/activities/execute-cursor/turn.js.map +1 -0
  80. package/dist/activities/execute-cursor/usage-pricing.d.ts +38 -0
  81. package/dist/activities/execute-cursor/usage-pricing.js +50 -0
  82. package/dist/activities/execute-cursor/usage-pricing.js.map +1 -0
  83. package/dist/activities/execute-deep-agent/approval-file-change.d.ts +1 -1
  84. package/dist/activities/execute-deep-agent/approval-file-change.js +1 -1
  85. package/dist/activities/execute-deep-agent/environment.js +1 -1
  86. package/dist/activities/execute-deep-agent/environment.js.map +1 -1
  87. package/dist/activities/execute-deep-agent/setup.js +3 -2
  88. package/dist/activities/execute-deep-agent/setup.js.map +1 -1
  89. package/dist/activities/hydrate-workflow-execution.js +1 -1
  90. package/dist/activities/hydrate-workflow-execution.js.map +1 -1
  91. package/dist/config.d.ts +15 -0
  92. package/dist/config.js.map +1 -1
  93. package/dist/harness/capabilities.d.ts +16 -0
  94. package/dist/harness/capabilities.js +1 -0
  95. package/dist/harness/capabilities.js.map +1 -1
  96. package/dist/harness/persist-chokepoint.d.ts +74 -0
  97. package/dist/harness/persist-chokepoint.js +88 -0
  98. package/dist/harness/persist-chokepoint.js.map +1 -0
  99. package/dist/harness/registry.d.ts +44 -5
  100. package/dist/harness/registry.js +61 -5
  101. package/dist/harness/registry.js.map +1 -1
  102. package/dist/harness/run-turn.d.ts +53 -0
  103. package/dist/harness/run-turn.js +528 -0
  104. package/dist/harness/run-turn.js.map +1 -0
  105. package/dist/harness/stop-controller.d.ts +50 -0
  106. package/dist/harness/stop-controller.js +62 -0
  107. package/dist/harness/stop-controller.js.map +1 -0
  108. package/dist/harness/terminal-table.d.ts +141 -0
  109. package/dist/harness/terminal-table.js +239 -0
  110. package/dist/harness/terminal-table.js.map +1 -0
  111. package/dist/harness/turn-context.d.ts +523 -0
  112. package/dist/harness/turn-context.js +739 -0
  113. package/dist/harness/turn-context.js.map +1 -0
  114. package/dist/harness/types.d.ts +232 -52
  115. package/dist/harness/types.js +17 -8
  116. package/dist/harness/types.js.map +1 -1
  117. package/dist/harness/usage-accumulator.d.ts +68 -0
  118. package/dist/harness/usage-accumulator.js +101 -0
  119. package/dist/harness/usage-accumulator.js.map +1 -0
  120. package/dist/harness-adapters.d.ts +27 -0
  121. package/dist/harness-adapters.js +28 -0
  122. package/dist/harness-adapters.js.map +1 -0
  123. package/dist/main.js.map +1 -1
  124. package/dist/runner-manager.js +64 -48
  125. package/dist/runner-manager.js.map +1 -1
  126. package/dist/runner.d.ts +5 -4
  127. package/dist/runner.js +65 -64
  128. package/dist/runner.js.map +1 -1
  129. package/dist/shared/approval-policy.d.ts +1 -1
  130. package/dist/shared/approval-policy.js.map +1 -1
  131. package/dist/{activities/execute-cursor → shared}/attachment-resolver.d.ts +2 -2
  132. package/dist/{activities/execute-cursor → shared}/attachment-resolver.js +5 -5
  133. package/dist/shared/attachment-resolver.js.map +1 -0
  134. package/dist/{activities/execute-cursor → shared}/blueprint-resolver.d.ts +7 -5
  135. package/dist/{activities/execute-cursor → shared}/blueprint-resolver.js +3 -63
  136. package/dist/shared/blueprint-resolver.js.map +1 -0
  137. package/dist/shared/channel-attachment.d.ts +1 -1
  138. package/dist/shared/channel-attachment.js.map +1 -1
  139. package/dist/{activities/execute-cursor → shared}/cost-guard.d.ts +5 -1
  140. package/dist/{activities/execute-cursor → shared}/cost-guard.js +5 -1
  141. package/dist/shared/cost-guard.js.map +1 -0
  142. package/dist/{activities/execute-cursor → shared}/env-resolver.d.ts +1 -1
  143. package/dist/shared/env-resolver.js.map +1 -0
  144. package/dist/{activities/execute-cursor → shared}/exact-apply.d.ts +1 -1
  145. package/dist/{activities/execute-cursor → shared}/exact-apply.js +6 -6
  146. package/dist/shared/exact-apply.js.map +1 -0
  147. package/dist/shared/execution-context.d.ts +35 -0
  148. package/dist/shared/execution-context.js +38 -0
  149. package/dist/shared/execution-context.js.map +1 -0
  150. package/dist/{activities/execute-cursor → shared}/extract-structured-output.d.ts +5 -2
  151. package/dist/{activities/execute-cursor → shared}/extract-structured-output.js +9 -6
  152. package/dist/shared/extract-structured-output.js.map +1 -0
  153. package/dist/shared/filereview/capture.d.ts +1 -1
  154. package/dist/shared/filereview/capture.js +1 -1
  155. package/dist/shared/heartbeat.d.ts +13 -11
  156. package/dist/shared/heartbeat.js +14 -29
  157. package/dist/shared/heartbeat.js.map +1 -1
  158. package/dist/{activities/execute-cursor → shared}/persist-decision.d.ts +5 -2
  159. package/dist/{activities/execute-cursor → shared}/persist-decision.js +4 -1
  160. package/dist/shared/persist-decision.js.map +1 -0
  161. package/dist/{activities/execute-cursor → shared}/skill-resolver.d.ts +16 -3
  162. package/dist/{activities/execute-cursor → shared}/skill-resolver.js +12 -4
  163. package/dist/shared/skill-resolver.js.map +1 -0
  164. package/dist/shared/subagent-rows.d.ts +21 -0
  165. package/dist/shared/subagent-rows.js +34 -0
  166. package/dist/shared/subagent-rows.js.map +1 -0
  167. package/dist/shared/worker-shutdown.d.ts +43 -16
  168. package/dist/shared/worker-shutdown.js +28 -13
  169. package/dist/shared/worker-shutdown.js.map +1 -1
  170. package/dist/shared/workspace/platform-dir.d.ts +1 -1
  171. package/dist/shared/workspace/platform-dir.js +1 -1
  172. package/dist/shared/workspace/session-provision.d.ts +54 -0
  173. package/dist/{activities/execute-cursor/workspace-provision.js → shared/workspace/session-provision.js} +15 -12
  174. package/dist/shared/workspace/session-provision.js.map +1 -0
  175. package/package.json +4 -4
  176. package/src/__test-utils__/__tests__/harness-contract-self-check.test.ts +110 -14
  177. package/src/__test-utils__/execution-record-fixture.ts +104 -0
  178. package/src/__test-utils__/harness-boot-order-child.ts +58 -0
  179. package/src/__test-utils__/harness-contract/contract.ts +128 -83
  180. package/src/__test-utils__/harness-contract/recording-sink.ts +15 -4
  181. package/src/__test-utils__/harness-contract/runtime-contract.ts +666 -0
  182. package/src/__test-utils__/harness-contract/scripted-adapter.ts +92 -32
  183. package/src/__test-utils__/harness-contract/types.ts +85 -9
  184. package/src/__test-utils__/hermetic-activity.ts +33 -8
  185. package/src/__test-utils__/model-registry-fixture.ts +72 -0
  186. package/src/__test-utils__/module-specifiers.ts +82 -0
  187. package/src/__test-utils__/turn-input-fixture.ts +155 -0
  188. package/src/__tests__/harness-boot-order.test.ts +77 -0
  189. package/src/__tests__/harness-contract.test.ts +7 -5
  190. package/src/__tests__/runner-manager.test.ts +18 -0
  191. package/src/activities/execute-cursor/__test-utils__/__tests__/scripted-double.test.ts +102 -0
  192. package/src/activities/execute-cursor/__test-utils__/contract-subject.ts +396 -0
  193. package/src/activities/execute-cursor/__test-utils__/cursor-hook-harness.ts +66 -0
  194. package/src/activities/execute-cursor/__test-utils__/gateway-substrate.ts +2 -43
  195. package/src/activities/execute-cursor/__test-utils__/hermetic-cursor.ts +65 -145
  196. package/src/activities/execute-cursor/__test-utils__/scripted-agent.ts +30 -4
  197. package/src/activities/execute-cursor/__test-utils__/scripted-sdk.ts +96 -8
  198. package/src/activities/execute-cursor/__tests__/adapter-is-temporal-free.test.ts +45 -0
  199. package/src/activities/execute-cursor/__tests__/approval-decisions-agree.test.ts +90 -0
  200. package/src/activities/execute-cursor/__tests__/build-prompt.test.ts +7 -8
  201. package/src/activities/execute-cursor/__tests__/capture-flow.test.ts +28 -1
  202. package/src/activities/execute-cursor/__tests__/deny-gate-exact-apply.test.ts +1 -1
  203. package/src/activities/execute-cursor/__tests__/fetch-interceptor.test.ts +64 -6
  204. package/src/activities/execute-cursor/__tests__/hermetic/deny-and-retry.test.ts +1 -1
  205. package/src/activities/execute-cursor/__tests__/hermetic/file-review-capture.test.ts +1 -1
  206. package/src/activities/execute-cursor/__tests__/hermetic/goldens/cost-cap.status.json +53 -0
  207. package/src/activities/execute-cursor/__tests__/hermetic/goldens/pause.status.json +1 -6
  208. package/src/activities/execute-cursor/__tests__/hermetic/goldens/platform-stop.status.json +56 -0
  209. package/src/activities/execute-cursor/__tests__/hermetic/goldens/recovery-transport-timeout.status.json +48 -0
  210. package/src/activities/execute-cursor/__tests__/hermetic/goldens/resolution-error.status.json +18 -0
  211. package/src/activities/execute-cursor/__tests__/hermetic/goldens/run-cancelled.status.json +36 -0
  212. package/src/activities/execute-cursor/__tests__/hermetic/goldens/run-error-non-retryable.status.json +37 -0
  213. package/src/activities/execute-cursor/__tests__/hermetic/goldens/sdk-error-at-create.status.json +38 -0
  214. package/src/activities/execute-cursor/__tests__/hermetic/goldens/stall.status.json +59 -0
  215. package/src/activities/execute-cursor/__tests__/hermetic/goldens/unattributed-hook-block.status.json +79 -0
  216. package/src/activities/execute-cursor/__tests__/hermetic/goldens/worker-shutdown.status.json +2 -7
  217. package/src/activities/execute-cursor/__tests__/hermetic/harness-contract.test.ts +170 -0
  218. package/src/activities/execute-cursor/__tests__/hermetic/pause-vs-shutdown.test.ts +22 -18
  219. package/src/activities/execute-cursor/__tests__/hermetic/plain-turn.test.ts +1 -1
  220. package/src/activities/execute-cursor/__tests__/hermetic/recovery-fresh-agent.test.ts +1 -1
  221. package/src/activities/execute-cursor/__tests__/hermetic/run-wait-arms.test.ts +286 -0
  222. package/src/activities/execute-cursor/__tests__/hermetic/stream-self-stop-arms.test.ts +332 -0
  223. package/src/activities/execute-cursor/__tests__/hermetic/thrown-error-arms.test.ts +193 -0
  224. package/src/activities/execute-cursor/__tests__/hermetic/tool-call.test.ts +1 -1
  225. package/src/activities/execute-cursor/__tests__/hermetic/unattributed-hook-block.test.ts +185 -0
  226. package/src/activities/execute-cursor/__tests__/hermetic/workspace-lock-timeout.test.ts +151 -0
  227. package/src/activities/execute-cursor/__tests__/http2-interceptor.test.ts +65 -35
  228. package/src/activities/execute-cursor/__tests__/message-translator.test.ts +0 -40
  229. package/src/activities/execute-cursor/__tests__/same-identity-reproposal.test.ts +171 -0
  230. package/src/activities/execute-cursor/__tests__/turn-stream.test.ts +118 -243
  231. package/src/activities/execute-cursor/__tests__/usage-pricing.test.ts +84 -0
  232. package/src/activities/execute-cursor/adapter.ts +138 -0
  233. package/src/activities/execute-cursor/approval-state.ts +2 -2
  234. package/src/activities/execute-cursor/capture-flow.ts +18 -41
  235. package/src/activities/execute-cursor/cursor-capabilities.ts +35 -0
  236. package/src/activities/execute-cursor/cursor-mcp-config.ts +2 -2
  237. package/src/activities/execute-cursor/fetch-interceptor.ts +48 -45
  238. package/src/activities/execute-cursor/http2-interceptor.ts +47 -34
  239. package/src/activities/execute-cursor/message-translator.ts +90 -45
  240. package/src/activities/execute-cursor/prompt-builder.ts +327 -12
  241. package/src/activities/execute-cursor/rejection-capture.ts +5 -12
  242. package/src/activities/execute-cursor/session-lifecycle.ts +1 -5
  243. package/src/activities/execute-cursor/turn-boundary.ts +1 -1
  244. package/src/activities/execute-cursor/turn-settle.ts +601 -0
  245. package/src/activities/execute-cursor/turn-setup.ts +645 -0
  246. package/src/activities/execute-cursor/turn-stream.ts +84 -210
  247. package/src/activities/execute-cursor/turn.ts +240 -0
  248. package/src/activities/execute-cursor/usage-pricing.ts +67 -0
  249. package/src/activities/execute-deep-agent/approval-file-change.ts +1 -1
  250. package/src/activities/execute-deep-agent/environment.ts +1 -1
  251. package/src/activities/execute-deep-agent/setup.ts +3 -2
  252. package/src/activities/hydrate-workflow-execution.ts +1 -1
  253. package/src/config.ts +13 -0
  254. package/src/harness/__tests__/import-direction.test.ts +168 -0
  255. package/src/harness/__tests__/persist-chokepoint.test.ts +146 -0
  256. package/src/harness/__tests__/registry.test.ts +1 -0
  257. package/src/harness/__tests__/run-turn.test.ts +165 -0
  258. package/src/harness/__tests__/stop-controller.test.ts +49 -0
  259. package/src/harness/__tests__/turn-context.test.ts +178 -0
  260. package/src/harness/__tests__/usage-accumulator.test.ts +83 -0
  261. package/src/harness/capabilities.ts +17 -0
  262. package/src/harness/persist-chokepoint.ts +112 -0
  263. package/src/harness/registry.ts +79 -5
  264. package/src/harness/run-turn.ts +618 -0
  265. package/src/harness/stop-controller.ts +83 -0
  266. package/src/harness/terminal-table.ts +276 -0
  267. package/src/harness/turn-context.ts +1028 -0
  268. package/src/harness/types.ts +248 -53
  269. package/src/harness/usage-accumulator.ts +122 -0
  270. package/src/harness-adapters.ts +30 -0
  271. package/src/main.ts +1 -1
  272. package/src/runner-manager.ts +68 -61
  273. package/src/runner.ts +67 -78
  274. package/src/shared/__tests__/attachment-naming.test.ts +1 -1
  275. package/src/{activities/execute-cursor → shared}/__tests__/attachment-resolver.test.ts +6 -4
  276. package/src/{activities/execute-cursor → shared}/__tests__/cost-guard.test.ts +2 -1
  277. package/src/{activities/execute-cursor → shared}/__tests__/exact-apply.test.ts +3 -3
  278. package/src/{activities/execute-cursor → shared}/__tests__/extract-structured-output.test.ts +8 -8
  279. package/src/{activities/execute-cursor → shared}/__tests__/persist-decision.test.ts +4 -2
  280. package/src/{activities/execute-cursor → shared}/__tests__/skill-resolver.test.ts +1 -1
  281. package/src/shared/__tests__/subagent-rows.test.ts +34 -0
  282. package/src/shared/__tests__/worker-shutdown.test.ts +44 -39
  283. package/src/shared/approval-policy.ts +1 -1
  284. package/src/{activities/execute-cursor → shared}/attachment-resolver.ts +6 -6
  285. package/src/{activities/execute-cursor → shared}/blueprint-resolver.ts +7 -78
  286. package/src/shared/channel-attachment.ts +1 -1
  287. package/src/{activities/execute-cursor → shared}/cost-guard.ts +5 -1
  288. package/src/{activities/execute-cursor → shared}/env-resolver.ts +1 -1
  289. package/src/{activities/execute-cursor → shared}/exact-apply.ts +7 -7
  290. package/src/shared/execution-context.ts +45 -0
  291. package/src/{activities/execute-cursor → shared}/extract-structured-output.ts +10 -7
  292. package/src/shared/filereview/capture.ts +1 -1
  293. package/src/shared/heartbeat.ts +13 -33
  294. package/src/{activities/execute-cursor → shared}/persist-decision.ts +5 -2
  295. package/src/{activities/execute-cursor → shared}/skill-resolver.ts +20 -6
  296. package/src/shared/subagent-rows.ts +39 -0
  297. package/src/shared/worker-shutdown.ts +55 -25
  298. package/src/{activities/execute-cursor/__tests__/workspace-provision.test.ts → shared/workspace/__tests__/session-provision.test.ts} +25 -28
  299. package/src/shared/workspace/platform-dir.ts +1 -1
  300. package/src/{activities/execute-cursor/workspace-provision.ts → shared/workspace/session-provision.ts} +29 -16
  301. package/dist/activities/execute-cursor/attachment-resolver.js.map +0 -1
  302. package/dist/activities/execute-cursor/blueprint-resolver.js.map +0 -1
  303. package/dist/activities/execute-cursor/cost-guard.js.map +0 -1
  304. package/dist/activities/execute-cursor/env-resolver.js.map +0 -1
  305. package/dist/activities/execute-cursor/exact-apply.js.map +0 -1
  306. package/dist/activities/execute-cursor/extract-structured-output.js.map +0 -1
  307. package/dist/activities/execute-cursor/index.d.ts +0 -209
  308. package/dist/activities/execute-cursor/index.js +0 -2345
  309. package/dist/activities/execute-cursor/index.js.map +0 -1
  310. package/dist/activities/execute-cursor/persist-decision.js.map +0 -1
  311. package/dist/activities/execute-cursor/skill-resolver.js.map +0 -1
  312. package/dist/activities/execute-cursor/usage-accumulator.d.ts +0 -89
  313. package/dist/activities/execute-cursor/usage-accumulator.js +0 -121
  314. package/dist/activities/execute-cursor/usage-accumulator.js.map +0 -1
  315. package/dist/activities/execute-cursor/workspace-provision.d.ts +0 -42
  316. package/dist/activities/execute-cursor/workspace-provision.js.map +0 -1
  317. package/src/activities/execute-cursor/__tests__/usage-accumulator.test.ts +0 -164
  318. package/src/activities/execute-cursor/index.ts +0 -2876
  319. package/src/activities/execute-cursor/usage-accumulator.ts +0 -169
  320. /package/dist/{activities/execute-cursor → shared}/env-resolver.js +0 -0
@@ -0,0 +1,155 @@
1
+ /**
2
+ * A whole `TurnInput` for tests that stand in for the runtime.
3
+ *
4
+ * The contract's input is the runtime's entire resolved record (`harness/
5
+ * types.ts`): the execution and session protos, the blueprint, the
6
+ * environment, the workspace, the tool surface, the attachments, the model
7
+ * preferences, the standing context. A test that drives an adapter WITHOUT
8
+ * the runtime — the harness contract kit's `ExecutionDriver`, a unit test of
9
+ * one adapter step — needs a record that type-checks and is inert: empty
10
+ * protos, an empty tool surface, a workspace under the OS temp dir, a memory
11
+ * selection that answers nothing. Everything here is the neutral value;
12
+ * `overrides` deep-merges one level (a test states the fields it is about
13
+ * and nothing else), the way `testConfig()` does for `Config`.
14
+ *
15
+ * Nothing here is Cursor's or native's: the vision profile, the file-review
16
+ * identity and the state id source are the ADAPTER's capabilities, not
17
+ * input facts, so they do not appear.
18
+ */
19
+
20
+ import { create } from "@bufbuild/protobuf";
21
+ import { tmpdir } from "node:os";
22
+ import { join } from "node:path";
23
+ import {
24
+ AgentExecutionSchema,
25
+ type AgentExecution,
26
+ type AgentExecutionStatus,
27
+ } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/api_pb";
28
+ import { AgentExecutionSpecSchema } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/spec_pb";
29
+ import { ServiceTier, ThinkingMode } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/enum_pb";
30
+ import { SessionSchema, type Session } from "@stigmer/protos/ai/stigmer/agentic/session/v1/api_pb";
31
+ import { SessionSpecSchema } from "@stigmer/protos/ai/stigmer/agentic/session/v1/spec_pb";
32
+ import { AgentSchema } from "@stigmer/protos/ai/stigmer/agentic/agent/v1/api_pb";
33
+ import { AgentSpecSchema } from "@stigmer/protos/ai/stigmer/agentic/agent/v1/spec_pb";
34
+ import { ApiResourceMetadataSchema } from "@stigmer/protos/ai/stigmer/commons/apiresource/metadata_pb";
35
+
36
+ import type { TurnInput } from "../harness/types.js";
37
+ import type { ResolvedBlueprint } from "../shared/blueprint-resolver.js";
38
+ import { mockWorkspaceBackend } from "./mock-workspace.js";
39
+
40
+ /** The ids a fixture record carries when a test does not name its own. */
41
+ export const TURN_INPUT_FIXTURE_IDS = {
42
+ executionId: "aex_fixture_0001",
43
+ sessionId: "ses_fixture_0001",
44
+ agentId: "agt_fixture_0001",
45
+ org: "fixture-org",
46
+ } as const;
47
+
48
+ export interface TurnInputFixtureOverrides extends Partial<Omit<TurnInput, "execution" | "session" | "blueprint">> {
49
+ readonly execution?: AgentExecution;
50
+ readonly session?: Session;
51
+ readonly blueprint?: Partial<ResolvedBlueprint>;
52
+ /**
53
+ * The user's message on the default execution's spec (ignored when a whole
54
+ * `execution` is given). Empty by default: the neutral record asks nothing.
55
+ */
56
+ readonly message?: string;
57
+ /**
58
+ * The status the default execution carries — what the control plane
59
+ * persisted at the end of the previous invocation, on a reinvocation. The
60
+ * runtime seeds the turn's in-progress status from a clone of it
61
+ * (`seedTranscriptFromExecution`) and an adapter may read the record's own
62
+ * copy for its facts, so a test standing in for the runtime hands both.
63
+ */
64
+ readonly persistedStatus?: AgentExecutionStatus;
65
+ /**
66
+ * Where the default workspace lives (ignored when a whole `workspace` is
67
+ * given). A test that only needs "my workspace is here" — because its
68
+ * engine writes into it — states the directory and nothing else of the
69
+ * provision record.
70
+ */
71
+ readonly workspaceDir?: string;
72
+ }
73
+
74
+ /**
75
+ * The neutral record, with `overrides` laid over it one level deep. The
76
+ * `session` and `blueprint.session` are the SAME object, as the runtime
77
+ * guarantees (`bindHarnessState` writes it).
78
+ */
79
+ export function turnInputFixture(overrides: TurnInputFixtureOverrides = {}): TurnInput {
80
+ const executionId = overrides.executionId ?? TURN_INPUT_FIXTURE_IDS.executionId;
81
+ const sessionId = overrides.sessionId ?? TURN_INPUT_FIXTURE_IDS.sessionId;
82
+ const session =
83
+ overrides.session ??
84
+ create(SessionSchema, {
85
+ metadata: create(ApiResourceMetadataSchema, { id: sessionId, org: TURN_INPUT_FIXTURE_IDS.org, name: sessionId }),
86
+ spec: create(SessionSpecSchema, {}),
87
+ });
88
+ const execution =
89
+ overrides.execution ??
90
+ create(AgentExecutionSchema, {
91
+ metadata: create(ApiResourceMetadataSchema, { id: executionId, org: TURN_INPUT_FIXTURE_IDS.org, name: executionId }),
92
+ spec: create(AgentExecutionSpecSchema, { sessionId, message: overrides.message ?? "" }),
93
+ status: overrides.persistedStatus,
94
+ });
95
+ const agent = create(AgentSchema, {
96
+ metadata: create(ApiResourceMetadataSchema, {
97
+ id: TURN_INPUT_FIXTURE_IDS.agentId,
98
+ org: TURN_INPUT_FIXTURE_IDS.org,
99
+ name: "fixture-agent",
100
+ }),
101
+ spec: create(AgentSpecSchema, { instructions: "You are the fixture agent." }),
102
+ });
103
+ const workspaceDir = overrides.workspaceDir ?? join(tmpdir(), "stigmer-runner-turn-input-fixture");
104
+ const blueprint: ResolvedBlueprint = {
105
+ agent,
106
+ agentSpec: agent.spec!,
107
+ session,
108
+ sessionSpec: session.spec!,
109
+ instructions: agent.spec!.instructions,
110
+ subAgents: [],
111
+ mergedMcpServerUsages: [],
112
+ mergedSkillRefs: [],
113
+ cloudRepos: [],
114
+ ...overrides.blueprint,
115
+ };
116
+ return {
117
+ executionId,
118
+ threadId: overrides.threadId ?? "",
119
+ turnSeq: overrides.turnSeq ?? 0,
120
+ sessionId,
121
+ approvalDecisions: overrides.approvalDecisions ?? new Map(),
122
+ execution,
123
+ session,
124
+ blueprint,
125
+ environment: overrides.environment ?? { envVars: {}, secretKeys: new Set() },
126
+ workspace: overrides.workspace ?? {
127
+ dirs: [workspaceDir],
128
+ primaryDir: workspaceDir,
129
+ gitWorkspace: false,
130
+ captureMode: false,
131
+ changeSetId: `${executionId}:${overrides.turnSeq ?? 0}`,
132
+ provision: { workspaceDirs: [workspaceDir], provisionResults: [], workspaceBackend: mockWorkspaceBackend() },
133
+ },
134
+ mcp: overrides.mcp ?? {
135
+ servers: [],
136
+ channelMessaging: [],
137
+ leases: { global: false, categories: new Set(), servers: new Set() },
138
+ policies: new Map(),
139
+ },
140
+ skills: overrides.skills ?? [],
141
+ attachments: overrides.attachments ?? { results: [], visionImages: [], visionNotViewable: [] },
142
+ appliedToolCallIds: overrides.appliedToolCallIds ?? new Set(),
143
+ model: overrides.model ?? { requested: "default", serviceTier: ServiceTier.STANDARD, thinkingMode: ThinkingMode.DISABLED },
144
+ structuredOutputSchema: overrides.structuredOutputSchema,
145
+ standing: overrides.standing ?? {
146
+ contextBridge: undefined,
147
+ senderIdentity: undefined,
148
+ sessionContext: undefined,
149
+ declaredPreferences: undefined,
150
+ conversationCatchup: undefined,
151
+ selectRecalledMemories: async () => undefined,
152
+ },
153
+ artifactStorage: overrides.artifactStorage,
154
+ };
155
+ }
@@ -0,0 +1,77 @@
1
+ /**
2
+ * The harness boot order, proven in a fresh process.
3
+ *
4
+ * The contract (`harness/types.ts` `boot`, `http2-interceptor.ts` header):
5
+ * the composition roots import `harness-adapters.js` and `harness/registry.js`
6
+ * BEFORE bootstrap, the Cursor adapter's `boot` installs the proxy
7
+ * interceptors — the HTTP/2 one patches `node:http2`, whose ESM facade is
8
+ * snapshotted at its first import by `@connectrpc/connect-node` — proves the
9
+ * patch reached the facade, and only then loads `@cursor/sdk`. Every module
10
+ * on the pre-boot path must therefore be connect-free, and the adapter's
11
+ * static graph SDK-free.
12
+ *
13
+ * Nothing in-process can test the positive arm: a vitest worker has imported
14
+ * `node:http2` long before any test runs, so the facade is frozen to the
15
+ * unpatched `connect` no matter what a test installs
16
+ * (`http2-interceptor.test.ts` covers only the two deterministic negatives
17
+ * for that reason). So each arm here spawns ONE fresh Node process
18
+ * (`__test-utils__/harness-boot-order-child.ts`) that does exactly what the
19
+ * roots do, and reads its one-line verdict. A static SDK import anywhere on
20
+ * `adapter.ts`'s graph, or a static client import on the registry's, fails
21
+ * the first arm; a `boot` that stopped asserting fails the second.
22
+ *
23
+ * `HOME` points at a temp dir so an SDK import-time side effect cannot touch
24
+ * the developer's home; the proxy endpoint is an inert loopback; nothing is
25
+ * dialled. Two spawns, a few seconds: the SDK is imported for real once.
26
+ */
27
+
28
+ import { describe, it, expect } from "vitest";
29
+ import { execFile } from "node:child_process";
30
+ import { mkdtempSync, rmSync } from "node:fs";
31
+ import { tmpdir } from "node:os";
32
+ import { join } from "node:path";
33
+ import { fileURLToPath } from "node:url";
34
+ import { promisify } from "node:util";
35
+
36
+ const execFileAsync = promisify(execFile);
37
+ const CHILD = fileURLToPath(new URL("../__test-utils__/harness-boot-order-child.ts", import.meta.url));
38
+
39
+ interface ChildVerdict {
40
+ readonly exitCode: number;
41
+ readonly line: string;
42
+ }
43
+
44
+ async function runChild(arm: "boot" | "boot-after-connect-node"): Promise<ChildVerdict> {
45
+ const home = mkdtempSync(join(tmpdir(), "stigmer-boot-order-"));
46
+ try {
47
+ const { stdout } = await execFileAsync(process.execPath, ["--import", "tsx", CHILD, arm], {
48
+ env: { ...process.env, HOME: home },
49
+ timeout: 25_000,
50
+ });
51
+ return { exitCode: 0, line: lastLine(stdout) };
52
+ } catch (err) {
53
+ const failure = err as { code?: number; stdout?: string; stderr?: string };
54
+ return { exitCode: failure.code ?? -1, line: lastLine(`${failure.stdout ?? ""}${failure.stderr ?? ""}`) };
55
+ } finally {
56
+ rmSync(home, { recursive: true, force: true });
57
+ }
58
+ }
59
+
60
+ function lastLine(text: string): string {
61
+ const lines = text.trim().split("\n");
62
+ return lines[lines.length - 1] ?? "";
63
+ }
64
+
65
+ describe("harness boot order (fresh process)", () => {
66
+ it("booting the harnesses on a proxy-mode config, the way the roots do, installs the interceptors, patches the facade, and loads the SDK", async () => {
67
+ const verdict = await runChild("boot");
68
+ expect(verdict.line, "the child's verdict").toBe("harness-boot-order: ok");
69
+ expect(verdict.exitCode).toBe(0);
70
+ });
71
+
72
+ it("the same boot after connect-node was imported first fails loudly on the facade (the guard is live inside boot)", async () => {
73
+ const verdict = await runChild("boot-after-connect-node");
74
+ expect(verdict.exitCode).toBe(1);
75
+ expect(verdict.line).toMatch(/node:http2 ESM facade is unpatched/);
76
+ });
77
+ });
@@ -8,11 +8,13 @@
8
8
  * deterministic id. Neither the kit nor the fake branches on the pause
9
9
  * primitive — running both is what proves it.
10
10
  *
11
- * This is the consolidation home for what every harness owes the turn
12
- * runtime. A real adapter joins the net by implementing
13
- * `HarnessContractSubject` for its own SDK double and adding one line below;
14
- * the runtime extraction (S2 of the program) adds the Cursor adapter here
15
- * and runs the runtime-side half through the hermetic activity driver.
11
+ * This is the fake's home in the net. A real adapter joins by implementing
12
+ * `HarnessContractSubject` over its own SDK double and registering both
13
+ * halves in its own hermetic file, where the mocks its double needs can be
14
+ * hoisted: the Cursor adapter does so in
15
+ * `activities/execute-cursor/__tests__/hermetic/harness-contract.test.ts`
16
+ * (S2 M4), and the fake's runtime-side half runs in
17
+ * `harness/__tests__/run-turn.test.ts`.
16
18
  */
17
19
 
18
20
  import { describeHarnessContract } from "../__test-utils__/harness-contract/contract.js";
@@ -33,6 +33,24 @@ describe("mapManagerOptionsToConfig", () => {
33
33
  expect(config.checkpointerType).toBe("http");
34
34
  });
35
35
 
36
+ it("binds the proxy credential to the runner-token ref, never the control-plane ref (Q-S2-7)", () => {
37
+ const tokenRef = { current: "control-plane-token" };
38
+ const runnerTokenRef = { current: "control-plane-token" };
39
+ const config = mapManagerOptionsToConfig(
40
+ { ...base, proxyEndpoint: "https://localhost:9090", stigmerToken: "control-plane-token" },
41
+ tokenRef,
42
+ runnerTokenRef,
43
+ );
44
+ expect(config.proxyTokenRef).toBe(runnerTokenRef);
45
+ expect(config.stigmerRunnerTokenRef).toBe(runnerTokenRef);
46
+ expect(config.stigmerTokenRef).toBe(tokenRef);
47
+
48
+ // After the mint the two refs diverge; the proxy credential follows the mint.
49
+ runnerTokenRef.current = "minted-runner-token";
50
+ expect(config.proxyTokenRef?.current).toBe("minted-runner-token");
51
+ expect(config.stigmerTokenRef?.current).toBe("control-plane-token");
52
+ });
53
+
36
54
  it("uses cloud only when executionMode is explicitly cloud", () => {
37
55
  const config = mapManagerOptionsToConfig({
38
56
  ...base,
@@ -0,0 +1,102 @@
1
+ /**
2
+ * The scripted `@cursor/sdk` double's own arms — the surface the harness
3
+ * contract kit's Cursor subject drives, added at S2 M4 beside the golden
4
+ * scenarios' declared-up-front surface (which the seventeen goldens prove).
5
+ *
6
+ * - `arrangeNextTurn` writes the slot the NEXT `send()` consumes, replaces a
7
+ * slot already arranged, and never touches a slot already consumed or one
8
+ * declared for a later send.
9
+ * - `nextRunId` names the run the next send will be given, so a script can be
10
+ * built with matching event ids before the send happens.
11
+ * - `agentForWorkspaceRef` hands `Agent.create` the agent declared for the
12
+ * session the create names (via `platform.workspaceRef`), consulted before
13
+ * the ordered list and registered for `Agent.resume` by id; a create with no
14
+ * session, or a session the resolver does not know, falls through to the
15
+ * list as before.
16
+ */
17
+
18
+ import { describe, it, expect } from "vitest";
19
+ import type { AgentOptions, SDKMessage } from "@cursor/sdk";
20
+
21
+ import { ScriptedCursorAgent, defaultRunId, sdkEvents, step } from "../scripted-agent.js";
22
+ import { ScriptedCursorSdk } from "../scripted-sdk.js";
23
+
24
+ /** An agent whose declared turns each play the given events and finish. */
25
+ function agent(id: string, turns: SDKMessage[][] = []): ScriptedCursorAgent {
26
+ return new ScriptedCursorAgent({ agentId: id, turns: turns.map((events) => [...events.map((e) => step.event(e)), step.finished()]) });
27
+ }
28
+
29
+ async function drain(a: ScriptedCursorAgent): Promise<string[]> {
30
+ const run = await a.send("go");
31
+ const texts: string[] = [];
32
+ for await (const event of run.stream()) {
33
+ if (event.type === "assistant") texts.push(event.message.content.map((c) => (c.type === "text" ? c.text : "")).join(""));
34
+ }
35
+ await run.wait();
36
+ return texts;
37
+ }
38
+
39
+ describe("ScriptedCursorAgent.arrangeNextTurn", () => {
40
+ it("writes the slot the next send consumes and replaces an arrangement not yet played", async () => {
41
+ const a = agent("a1");
42
+ const ev = sdkEvents("a1", a.nextRunId);
43
+ a.arrangeNextTurn([step.event(ev.assistant("first arrangement")), step.finished()]);
44
+ a.arrangeNextTurn([step.event(ev.assistant("replaced")), step.finished()]);
45
+
46
+ expect(await drain(a)).toEqual(["replaced"]);
47
+ });
48
+
49
+ it("leaves a consumed slot and a later declared slot where they are", async () => {
50
+ const ev1 = sdkEvents("a2", defaultRunId("a2", 0));
51
+ const ev3 = sdkEvents("a2", defaultRunId("a2", 2));
52
+ const a = agent("a2", [[ev1.assistant("declared one")], [ev1.assistant("declared two")], [ev3.assistant("declared three")]]);
53
+
54
+ expect(await drain(a)).toEqual(["declared one"]);
55
+ a.arrangeNextTurn([step.event(sdkEvents("a2", a.nextRunId).assistant("arranged two")), step.finished()]);
56
+ expect(await drain(a)).toEqual(["arranged two"]);
57
+ expect(await drain(a), "the third slot was declared up front and stands").toEqual(["declared three"]);
58
+ });
59
+
60
+ it("a send with no slot is a test bug and throws", async () => {
61
+ const a = agent("a3");
62
+ await expect(a.send("go")).rejects.toThrow(/send\(\) #1 has no script/);
63
+ });
64
+ });
65
+
66
+ describe("ScriptedCursorAgent.nextRunId", () => {
67
+ it("is the id the next send is given — the declared one, else the default", async () => {
68
+ const declared = new ScriptedCursorAgent({ agentId: "a4", runIds: ["run-x"], turns: [[step.finished()], [step.finished()]] });
69
+ expect(declared.nextRunId).toBe("run-x");
70
+ const run1 = await declared.send("go");
71
+ expect(run1.id).toBe("run-x");
72
+ expect(declared.nextRunId, "no second id declared: the default, counting sends from 1").toBe(defaultRunId("a4", 1));
73
+ const run2 = await declared.send("go");
74
+ expect(run2.id).toBe("run-a4-2");
75
+ });
76
+ });
77
+
78
+ describe("ScriptedCursorSdk.agentForWorkspaceRef", () => {
79
+ const createFor = (workspaceRef: string | undefined): AgentOptions =>
80
+ ({ apiKey: "k", ...(workspaceRef !== undefined ? { platform: { workspaceRef, stateRoot: "/tmp/x" } } : {}) }) as unknown as AgentOptions;
81
+
82
+ it("hands out the session's agent before the ordered list and registers it for resume", () => {
83
+ const forSession = agent("session-agent");
84
+ const listed = agent("listed-agent");
85
+ const sdk = new ScriptedCursorSdk({
86
+ agents: [listed],
87
+ catalog: [],
88
+ agentForWorkspaceRef: (ref) => (ref === "stigmer-session:ses-1" ? forSession : undefined),
89
+ });
90
+
91
+ expect(sdk.create(createFor("stigmer-session:ses-1"))).toBe(forSession);
92
+ expect(sdk.resume("session-agent", undefined)).toBe(forSession);
93
+ expect(sdk.create(createFor("stigmer-session:unknown")), "an unknown session falls through to the list").toBe(listed);
94
+ expect(sdk.resolutions.map((r) => `${r.kind}:${r.agentId}`)).toEqual(["create:session-agent", "resume:session-agent", "create:listed-agent"]);
95
+ });
96
+
97
+ it("a create without a platform ref falls through to the ordered list", () => {
98
+ const listed = agent("listed-only");
99
+ const sdk = new ScriptedCursorSdk({ agents: [listed], catalog: [], agentForWorkspaceRef: () => agent("never") });
100
+ expect(sdk.create(createFor(undefined))).toBe(listed);
101
+ });
102
+ });