@stigmer/runner 3.14.0 → 3.15.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 (331) 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 +268 -0
  9. package/dist/__test-utils__/hermetic-activity.js +385 -0
  10. package/dist/__test-utils__/hermetic-activity.js.map +1 -0
  11. package/dist/__test-utils__/mock-client.d.ts +13 -0
  12. package/dist/__test-utils__/mock-client.js +45 -0
  13. package/dist/__test-utils__/mock-client.js.map +1 -0
  14. package/dist/__test-utils__/mock-workspace.d.ts +15 -0
  15. package/dist/__test-utils__/mock-workspace.js +21 -0
  16. package/dist/__test-utils__/mock-workspace.js.map +1 -0
  17. package/dist/__test-utils__/model-registry-fixture.d.ts +56 -0
  18. package/dist/__test-utils__/model-registry-fixture.js +66 -0
  19. package/dist/__test-utils__/model-registry-fixture.js.map +1 -0
  20. package/dist/__test-utils__/turn-input-fixture.d.ts +60 -0
  21. package/dist/__test-utils__/turn-input-fixture.js +118 -0
  22. package/dist/__test-utils__/turn-input-fixture.js.map +1 -0
  23. package/dist/activities/execute-cursor/__test-utils__/contract-subject.d.ts +107 -0
  24. package/dist/activities/execute-cursor/__test-utils__/contract-subject.js +344 -0
  25. package/dist/activities/execute-cursor/__test-utils__/contract-subject.js.map +1 -0
  26. package/dist/activities/execute-cursor/__test-utils__/cursor-hook-harness.d.ts +20 -0
  27. package/dist/activities/execute-cursor/__test-utils__/cursor-hook-harness.js +58 -0
  28. package/dist/activities/execute-cursor/__test-utils__/cursor-hook-harness.js.map +1 -1
  29. package/dist/activities/execute-cursor/__test-utils__/gateway-substrate.js +2 -32
  30. package/dist/activities/execute-cursor/__test-utils__/gateway-substrate.js.map +1 -1
  31. package/dist/activities/execute-cursor/__test-utils__/hermetic-cursor.d.ts +148 -0
  32. package/dist/activities/execute-cursor/__test-utils__/hermetic-cursor.js +257 -0
  33. package/dist/activities/execute-cursor/__test-utils__/hermetic-cursor.js.map +1 -0
  34. package/dist/activities/execute-cursor/__test-utils__/scripted-agent.d.ts +183 -0
  35. package/dist/activities/execute-cursor/__test-utils__/scripted-agent.js +262 -0
  36. package/dist/activities/execute-cursor/__test-utils__/scripted-agent.js.map +1 -0
  37. package/dist/activities/execute-cursor/__test-utils__/scripted-sdk.d.ts +138 -0
  38. package/dist/activities/execute-cursor/__test-utils__/scripted-sdk.js +191 -0
  39. package/dist/activities/execute-cursor/__test-utils__/scripted-sdk.js.map +1 -0
  40. package/dist/activities/execute-cursor/adapter.d.ts +55 -0
  41. package/dist/activities/execute-cursor/adapter.js +119 -0
  42. package/dist/activities/execute-cursor/adapter.js.map +1 -0
  43. package/dist/activities/execute-cursor/approval-state.d.ts +2 -2
  44. package/dist/activities/execute-cursor/approval-state.js.map +1 -1
  45. package/dist/activities/execute-cursor/capture-flow.d.ts +15 -30
  46. package/dist/activities/execute-cursor/capture-flow.js +17 -26
  47. package/dist/activities/execute-cursor/capture-flow.js.map +1 -1
  48. package/dist/activities/execute-cursor/cursor-capabilities.d.ts +23 -0
  49. package/dist/activities/execute-cursor/cursor-capabilities.js +33 -0
  50. package/dist/activities/execute-cursor/cursor-capabilities.js.map +1 -0
  51. package/dist/activities/execute-cursor/cursor-mcp-config.d.ts +2 -2
  52. package/dist/activities/execute-cursor/cursor-mcp-config.js.map +1 -1
  53. package/dist/activities/execute-cursor/fetch-interceptor.d.ts +15 -25
  54. package/dist/activities/execute-cursor/fetch-interceptor.js +39 -33
  55. package/dist/activities/execute-cursor/fetch-interceptor.js.map +1 -1
  56. package/dist/activities/execute-cursor/http2-interceptor.d.ts +21 -17
  57. package/dist/activities/execute-cursor/http2-interceptor.js +38 -31
  58. package/dist/activities/execute-cursor/http2-interceptor.js.map +1 -1
  59. package/dist/activities/execute-cursor/message-translator.d.ts +28 -19
  60. package/dist/activities/execute-cursor/message-translator.js +76 -27
  61. package/dist/activities/execute-cursor/message-translator.js.map +1 -1
  62. package/dist/activities/execute-cursor/prompt-builder.d.ts +180 -11
  63. package/dist/activities/execute-cursor/prompt-builder.js +171 -0
  64. package/dist/activities/execute-cursor/prompt-builder.js.map +1 -1
  65. package/dist/activities/execute-cursor/rejection-capture.d.ts +3 -6
  66. package/dist/activities/execute-cursor/rejection-capture.js +5 -7
  67. package/dist/activities/execute-cursor/rejection-capture.js.map +1 -1
  68. package/dist/activities/execute-cursor/session-lifecycle.d.ts +1 -4
  69. package/dist/activities/execute-cursor/session-lifecycle.js.map +1 -1
  70. package/dist/activities/execute-cursor/turn-boundary.d.ts +1 -1
  71. package/dist/activities/execute-cursor/turn-settle.d.ts +49 -0
  72. package/dist/activities/execute-cursor/turn-settle.js +507 -0
  73. package/dist/activities/execute-cursor/turn-settle.js.map +1 -0
  74. package/dist/activities/execute-cursor/turn-setup.d.ts +173 -0
  75. package/dist/activities/execute-cursor/turn-setup.js +496 -0
  76. package/dist/activities/execute-cursor/turn-setup.js.map +1 -0
  77. package/dist/activities/execute-cursor/turn-stream.d.ts +41 -71
  78. package/dist/activities/execute-cursor/turn-stream.js +70 -135
  79. package/dist/activities/execute-cursor/turn-stream.js.map +1 -1
  80. package/dist/activities/execute-cursor/turn.d.ts +43 -0
  81. package/dist/activities/execute-cursor/turn.js +222 -0
  82. package/dist/activities/execute-cursor/turn.js.map +1 -0
  83. package/dist/activities/execute-cursor/usage-pricing.d.ts +38 -0
  84. package/dist/activities/execute-cursor/usage-pricing.js +50 -0
  85. package/dist/activities/execute-cursor/usage-pricing.js.map +1 -0
  86. package/dist/activities/execute-deep-agent/approval-file-change.d.ts +1 -1
  87. package/dist/activities/execute-deep-agent/approval-file-change.js +1 -1
  88. package/dist/activities/execute-deep-agent/environment.js +1 -1
  89. package/dist/activities/execute-deep-agent/environment.js.map +1 -1
  90. package/dist/activities/execute-deep-agent/setup.js +3 -2
  91. package/dist/activities/execute-deep-agent/setup.js.map +1 -1
  92. package/dist/activities/hydrate-workflow-execution.js +1 -1
  93. package/dist/activities/hydrate-workflow-execution.js.map +1 -1
  94. package/dist/config.d.ts +15 -0
  95. package/dist/config.js.map +1 -1
  96. package/dist/harness/capabilities.d.ts +87 -0
  97. package/dist/harness/capabilities.js +37 -0
  98. package/dist/harness/capabilities.js.map +1 -0
  99. package/dist/harness/persist-chokepoint.d.ts +74 -0
  100. package/dist/harness/persist-chokepoint.js +88 -0
  101. package/dist/harness/persist-chokepoint.js.map +1 -0
  102. package/dist/harness/registry.d.ts +106 -0
  103. package/dist/harness/registry.js +168 -0
  104. package/dist/harness/registry.js.map +1 -0
  105. package/dist/harness/run-turn.d.ts +53 -0
  106. package/dist/harness/run-turn.js +528 -0
  107. package/dist/harness/run-turn.js.map +1 -0
  108. package/dist/harness/stop-controller.d.ts +50 -0
  109. package/dist/harness/stop-controller.js +62 -0
  110. package/dist/harness/stop-controller.js.map +1 -0
  111. package/dist/harness/terminal-table.d.ts +141 -0
  112. package/dist/harness/terminal-table.js +239 -0
  113. package/dist/harness/terminal-table.js.map +1 -0
  114. package/dist/harness/turn-context.d.ts +523 -0
  115. package/dist/harness/turn-context.js +739 -0
  116. package/dist/harness/turn-context.js.map +1 -0
  117. package/dist/harness/types.d.ts +448 -0
  118. package/dist/harness/types.js +64 -0
  119. package/dist/harness/types.js.map +1 -0
  120. package/dist/harness/usage-accumulator.d.ts +68 -0
  121. package/dist/harness/usage-accumulator.js +101 -0
  122. package/dist/harness/usage-accumulator.js.map +1 -0
  123. package/dist/harness-adapters.d.ts +27 -0
  124. package/dist/harness-adapters.js +28 -0
  125. package/dist/harness-adapters.js.map +1 -0
  126. package/dist/main.js.map +1 -1
  127. package/dist/runner-manager.js +64 -48
  128. package/dist/runner-manager.js.map +1 -1
  129. package/dist/runner.d.ts +5 -4
  130. package/dist/runner.js +65 -64
  131. package/dist/runner.js.map +1 -1
  132. package/dist/shared/approval-policy.d.ts +1 -1
  133. package/dist/shared/approval-policy.js.map +1 -1
  134. package/dist/{activities/execute-cursor → shared}/attachment-resolver.d.ts +2 -2
  135. package/dist/{activities/execute-cursor → shared}/attachment-resolver.js +5 -5
  136. package/dist/shared/attachment-resolver.js.map +1 -0
  137. package/dist/{activities/execute-cursor → shared}/blueprint-resolver.d.ts +7 -5
  138. package/dist/{activities/execute-cursor → shared}/blueprint-resolver.js +3 -63
  139. package/dist/shared/blueprint-resolver.js.map +1 -0
  140. package/dist/shared/channel-attachment.d.ts +1 -1
  141. package/dist/shared/channel-attachment.js.map +1 -1
  142. package/dist/{activities/execute-cursor → shared}/cost-guard.d.ts +5 -1
  143. package/dist/{activities/execute-cursor → shared}/cost-guard.js +5 -1
  144. package/dist/shared/cost-guard.js.map +1 -0
  145. package/dist/{activities/execute-cursor → shared}/env-resolver.d.ts +1 -1
  146. package/dist/shared/env-resolver.js.map +1 -0
  147. package/dist/{activities/execute-cursor → shared}/exact-apply.d.ts +1 -1
  148. package/dist/{activities/execute-cursor → shared}/exact-apply.js +6 -6
  149. package/dist/shared/exact-apply.js.map +1 -0
  150. package/dist/shared/execution-context.d.ts +35 -0
  151. package/dist/shared/execution-context.js +38 -0
  152. package/dist/shared/execution-context.js.map +1 -0
  153. package/dist/{activities/execute-cursor → shared}/extract-structured-output.d.ts +5 -2
  154. package/dist/{activities/execute-cursor → shared}/extract-structured-output.js +9 -6
  155. package/dist/shared/extract-structured-output.js.map +1 -0
  156. package/dist/shared/filereview/capture.d.ts +1 -1
  157. package/dist/shared/filereview/capture.js +1 -1
  158. package/dist/shared/heartbeat.d.ts +13 -11
  159. package/dist/shared/heartbeat.js +14 -29
  160. package/dist/shared/heartbeat.js.map +1 -1
  161. package/dist/{activities/execute-cursor → shared}/persist-decision.d.ts +5 -2
  162. package/dist/{activities/execute-cursor → shared}/persist-decision.js +4 -1
  163. package/dist/shared/persist-decision.js.map +1 -0
  164. package/dist/{activities/execute-cursor → shared}/skill-resolver.d.ts +16 -3
  165. package/dist/{activities/execute-cursor → shared}/skill-resolver.js +12 -4
  166. package/dist/shared/skill-resolver.js.map +1 -0
  167. package/dist/shared/subagent-rows.d.ts +21 -0
  168. package/dist/shared/subagent-rows.js +34 -0
  169. package/dist/shared/subagent-rows.js.map +1 -0
  170. package/dist/shared/worker-shutdown.d.ts +43 -16
  171. package/dist/shared/worker-shutdown.js +28 -13
  172. package/dist/shared/worker-shutdown.js.map +1 -1
  173. package/dist/shared/workspace/platform-dir.d.ts +1 -1
  174. package/dist/shared/workspace/platform-dir.js +1 -1
  175. package/dist/shared/workspace/session-provision.d.ts +54 -0
  176. package/dist/{activities/execute-cursor/workspace-provision.js → shared/workspace/session-provision.js} +15 -12
  177. package/dist/shared/workspace/session-provision.js.map +1 -0
  178. package/package.json +4 -4
  179. package/src/__test-utils__/__tests__/harness-contract-self-check.test.ts +325 -0
  180. package/src/__test-utils__/config-fixture.ts +63 -0
  181. package/src/__test-utils__/execution-record-fixture.ts +104 -0
  182. package/src/__test-utils__/harness-boot-order-child.ts +58 -0
  183. package/src/__test-utils__/harness-contract/contract.ts +581 -0
  184. package/src/__test-utils__/harness-contract/recording-sink.ts +107 -0
  185. package/src/__test-utils__/harness-contract/runtime-contract.ts +666 -0
  186. package/src/__test-utils__/harness-contract/scripted-adapter.ts +349 -0
  187. package/src/__test-utils__/harness-contract/types.ts +176 -0
  188. package/src/__test-utils__/hermetic-activity.ts +502 -0
  189. package/src/__test-utils__/model-registry-fixture.ts +72 -0
  190. package/src/__test-utils__/module-specifiers.ts +82 -0
  191. package/src/__test-utils__/proto-helpers.ts +25 -0
  192. package/src/__test-utils__/turn-input-fixture.ts +155 -0
  193. package/src/__tests__/harness-boot-order.test.ts +77 -0
  194. package/src/__tests__/harness-contract.test.ts +27 -0
  195. package/src/__tests__/runner-manager.test.ts +18 -0
  196. package/src/activities/execute-cursor/__test-utils__/__tests__/scripted-double.test.ts +102 -0
  197. package/src/activities/execute-cursor/__test-utils__/contract-subject.ts +396 -0
  198. package/src/activities/execute-cursor/__test-utils__/cursor-hook-harness.ts +66 -0
  199. package/src/activities/execute-cursor/__test-utils__/gateway-substrate.ts +2 -43
  200. package/src/activities/execute-cursor/__test-utils__/hermetic-cursor.ts +342 -0
  201. package/src/activities/execute-cursor/__test-utils__/scripted-agent.ts +368 -0
  202. package/src/activities/execute-cursor/__test-utils__/scripted-sdk.ts +254 -0
  203. package/src/activities/execute-cursor/__tests__/adapter-is-temporal-free.test.ts +45 -0
  204. package/src/activities/execute-cursor/__tests__/approval-decisions-agree.test.ts +90 -0
  205. package/src/activities/execute-cursor/__tests__/build-prompt.test.ts +7 -8
  206. package/src/activities/execute-cursor/__tests__/capture-flow.test.ts +28 -1
  207. package/src/activities/execute-cursor/__tests__/deny-gate-exact-apply.test.ts +1 -1
  208. package/src/activities/execute-cursor/__tests__/fetch-interceptor.test.ts +64 -6
  209. package/src/activities/execute-cursor/__tests__/hermetic/deny-and-retry.test.ts +228 -0
  210. package/src/activities/execute-cursor/__tests__/hermetic/file-review-capture.test.ts +180 -0
  211. package/src/activities/execute-cursor/__tests__/hermetic/goldens/cost-cap.status.json +53 -0
  212. package/src/activities/execute-cursor/__tests__/hermetic/goldens/deny-and-retry.turn1.status.json +55 -0
  213. package/src/activities/execute-cursor/__tests__/hermetic/goldens/deny-and-retry.turn2.status.json +77 -0
  214. package/src/activities/execute-cursor/__tests__/hermetic/goldens/file-review-capture.status.json +126 -0
  215. package/src/activities/execute-cursor/__tests__/hermetic/goldens/pause.status.json +40 -0
  216. package/src/activities/execute-cursor/__tests__/hermetic/goldens/plain-turn.status.json +48 -0
  217. package/src/activities/execute-cursor/__tests__/hermetic/goldens/platform-stop.status.json +56 -0
  218. package/src/activities/execute-cursor/__tests__/hermetic/goldens/recovery-fresh-agent.status.json +53 -0
  219. package/src/activities/execute-cursor/__tests__/hermetic/goldens/recovery-transport-timeout.status.json +48 -0
  220. package/src/activities/execute-cursor/__tests__/hermetic/goldens/resolution-error.status.json +18 -0
  221. package/src/activities/execute-cursor/__tests__/hermetic/goldens/run-cancelled.status.json +36 -0
  222. package/src/activities/execute-cursor/__tests__/hermetic/goldens/run-error-non-retryable.status.json +37 -0
  223. package/src/activities/execute-cursor/__tests__/hermetic/goldens/sdk-error-at-create.status.json +38 -0
  224. package/src/activities/execute-cursor/__tests__/hermetic/goldens/stall.status.json +59 -0
  225. package/src/activities/execute-cursor/__tests__/hermetic/goldens/tool-call.status.json +68 -0
  226. package/src/activities/execute-cursor/__tests__/hermetic/goldens/unattributed-hook-block.status.json +79 -0
  227. package/src/activities/execute-cursor/__tests__/hermetic/goldens/worker-shutdown.status.json +42 -0
  228. package/src/activities/execute-cursor/__tests__/hermetic/harness-contract.test.ts +170 -0
  229. package/src/activities/execute-cursor/__tests__/hermetic/pause-vs-shutdown.test.ts +205 -0
  230. package/src/activities/execute-cursor/__tests__/hermetic/plain-turn.test.ts +171 -0
  231. package/src/activities/execute-cursor/__tests__/hermetic/recovery-fresh-agent.test.ts +156 -0
  232. package/src/activities/execute-cursor/__tests__/hermetic/run-wait-arms.test.ts +286 -0
  233. package/src/activities/execute-cursor/__tests__/hermetic/stream-self-stop-arms.test.ts +332 -0
  234. package/src/activities/execute-cursor/__tests__/hermetic/thrown-error-arms.test.ts +193 -0
  235. package/src/activities/execute-cursor/__tests__/hermetic/tool-call.test.ts +137 -0
  236. package/src/activities/execute-cursor/__tests__/hermetic/unattributed-hook-block.test.ts +185 -0
  237. package/src/activities/execute-cursor/__tests__/hermetic/workspace-lock-timeout.test.ts +151 -0
  238. package/src/activities/execute-cursor/__tests__/http2-interceptor.test.ts +65 -35
  239. package/src/activities/execute-cursor/__tests__/message-translator.test.ts +0 -40
  240. package/src/activities/execute-cursor/__tests__/same-identity-reproposal.test.ts +171 -0
  241. package/src/activities/execute-cursor/__tests__/turn-stream.test.ts +118 -243
  242. package/src/activities/execute-cursor/__tests__/usage-pricing.test.ts +84 -0
  243. package/src/activities/execute-cursor/adapter.ts +138 -0
  244. package/src/activities/execute-cursor/approval-state.ts +2 -2
  245. package/src/activities/execute-cursor/capture-flow.ts +18 -41
  246. package/src/activities/execute-cursor/cursor-capabilities.ts +35 -0
  247. package/src/activities/execute-cursor/cursor-mcp-config.ts +2 -2
  248. package/src/activities/execute-cursor/fetch-interceptor.ts +48 -45
  249. package/src/activities/execute-cursor/http2-interceptor.ts +47 -34
  250. package/src/activities/execute-cursor/message-translator.ts +90 -45
  251. package/src/activities/execute-cursor/prompt-builder.ts +327 -12
  252. package/src/activities/execute-cursor/rejection-capture.ts +5 -12
  253. package/src/activities/execute-cursor/session-lifecycle.ts +1 -5
  254. package/src/activities/execute-cursor/turn-boundary.ts +1 -1
  255. package/src/activities/execute-cursor/turn-settle.ts +601 -0
  256. package/src/activities/execute-cursor/turn-setup.ts +645 -0
  257. package/src/activities/execute-cursor/turn-stream.ts +84 -210
  258. package/src/activities/execute-cursor/turn.ts +240 -0
  259. package/src/activities/execute-cursor/usage-pricing.ts +67 -0
  260. package/src/activities/execute-deep-agent/approval-file-change.ts +1 -1
  261. package/src/activities/execute-deep-agent/environment.ts +1 -1
  262. package/src/activities/execute-deep-agent/setup.ts +3 -2
  263. package/src/activities/hydrate-workflow-execution.ts +1 -1
  264. package/src/config.ts +13 -0
  265. package/src/harness/__tests__/import-direction.test.ts +168 -0
  266. package/src/harness/__tests__/persist-chokepoint.test.ts +146 -0
  267. package/src/harness/__tests__/registry.test.ts +168 -0
  268. package/src/harness/__tests__/run-turn.test.ts +165 -0
  269. package/src/harness/__tests__/stop-controller.test.ts +49 -0
  270. package/src/harness/__tests__/turn-context.test.ts +178 -0
  271. package/src/harness/__tests__/usage-accumulator.test.ts +83 -0
  272. package/src/harness/capabilities.ts +92 -0
  273. package/src/harness/persist-chokepoint.ts +112 -0
  274. package/src/harness/registry.ts +197 -0
  275. package/src/harness/run-turn.ts +618 -0
  276. package/src/harness/stop-controller.ts +83 -0
  277. package/src/harness/terminal-table.ts +276 -0
  278. package/src/harness/turn-context.ts +1028 -0
  279. package/src/harness/types.ts +473 -0
  280. package/src/harness/usage-accumulator.ts +122 -0
  281. package/src/harness-adapters.ts +30 -0
  282. package/src/main.ts +1 -1
  283. package/src/runner-manager.ts +68 -61
  284. package/src/runner.ts +67 -78
  285. package/src/shared/__tests__/attachment-naming.test.ts +1 -1
  286. package/src/{activities/execute-cursor → shared}/__tests__/attachment-resolver.test.ts +6 -4
  287. package/src/{activities/execute-cursor → shared}/__tests__/cost-guard.test.ts +2 -1
  288. package/src/{activities/execute-cursor → shared}/__tests__/exact-apply.test.ts +3 -3
  289. package/src/{activities/execute-cursor → shared}/__tests__/extract-structured-output.test.ts +8 -8
  290. package/src/{activities/execute-cursor → shared}/__tests__/persist-decision.test.ts +4 -2
  291. package/src/{activities/execute-cursor → shared}/__tests__/skill-resolver.test.ts +1 -1
  292. package/src/shared/__tests__/subagent-rows.test.ts +34 -0
  293. package/src/shared/__tests__/worker-shutdown.test.ts +44 -39
  294. package/src/shared/approval-policy.ts +1 -1
  295. package/src/{activities/execute-cursor → shared}/attachment-resolver.ts +6 -6
  296. package/src/{activities/execute-cursor → shared}/blueprint-resolver.ts +7 -78
  297. package/src/shared/channel-attachment.ts +1 -1
  298. package/src/{activities/execute-cursor → shared}/cost-guard.ts +5 -1
  299. package/src/{activities/execute-cursor → shared}/env-resolver.ts +1 -1
  300. package/src/{activities/execute-cursor → shared}/exact-apply.ts +7 -7
  301. package/src/shared/execution-context.ts +45 -0
  302. package/src/{activities/execute-cursor → shared}/extract-structured-output.ts +10 -7
  303. package/src/shared/filereview/capture.ts +1 -1
  304. package/src/shared/heartbeat.ts +13 -33
  305. package/src/{activities/execute-cursor → shared}/persist-decision.ts +5 -2
  306. package/src/{activities/execute-cursor → shared}/skill-resolver.ts +20 -6
  307. package/src/shared/subagent-rows.ts +39 -0
  308. package/src/shared/worker-shutdown.ts +55 -25
  309. package/src/{activities/execute-cursor/__tests__/workspace-provision.test.ts → shared/workspace/__tests__/session-provision.test.ts} +25 -28
  310. package/src/shared/workspace/platform-dir.ts +1 -1
  311. package/src/{activities/execute-cursor/workspace-provision.ts → shared/workspace/session-provision.ts} +29 -16
  312. package/dist/activities/execute-cursor/attachment-resolver.js.map +0 -1
  313. package/dist/activities/execute-cursor/blueprint-resolver.js.map +0 -1
  314. package/dist/activities/execute-cursor/cost-guard.js.map +0 -1
  315. package/dist/activities/execute-cursor/env-resolver.js.map +0 -1
  316. package/dist/activities/execute-cursor/exact-apply.js.map +0 -1
  317. package/dist/activities/execute-cursor/extract-structured-output.js.map +0 -1
  318. package/dist/activities/execute-cursor/index.d.ts +0 -209
  319. package/dist/activities/execute-cursor/index.js +0 -2345
  320. package/dist/activities/execute-cursor/index.js.map +0 -1
  321. package/dist/activities/execute-cursor/persist-decision.js.map +0 -1
  322. package/dist/activities/execute-cursor/skill-resolver.js.map +0 -1
  323. package/dist/activities/execute-cursor/usage-accumulator.d.ts +0 -89
  324. package/dist/activities/execute-cursor/usage-accumulator.js +0 -121
  325. package/dist/activities/execute-cursor/usage-accumulator.js.map +0 -1
  326. package/dist/activities/execute-cursor/workspace-provision.d.ts +0 -42
  327. package/dist/activities/execute-cursor/workspace-provision.js.map +0 -1
  328. package/src/activities/execute-cursor/__tests__/usage-accumulator.test.ts +0 -164
  329. package/src/activities/execute-cursor/index.ts +0 -2876
  330. package/src/activities/execute-cursor/usage-accumulator.ts +0 -169
  331. /package/dist/{activities/execute-cursor → shared}/env-resolver.js +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"turn-context.js","sourceRoot":"","sources":["../../src/harness/turn-context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgEG;AAEH,OAAO,EAAE,gBAAgB,EAA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line between what the turn runtime owns
3
+ * and what a harness owns.
4
+ *
5
+ * Stigmer runs an agent turn through one of several engines ("harnesses"):
6
+ * the native LangGraph deep-agent, the Cursor SDK, and in future the Claude
7
+ * Agent SDK and the Codex SDK. Everything about a turn that does NOT touch a
8
+ * vendor SDK — fetching the execution, resolving the blueprint and the
9
+ * environment, provisioning and locking the workspace, mounting skills,
10
+ * resolving MCP servers and approval policies, seeding the transcript, the
11
+ * persist chokepoint, the stall watchdog, the Temporal heartbeat, pause vs
12
+ * shutdown, the cost cap, the terminal mapping — is the RUNTIME's
13
+ * (`run-turn.ts`), written once. What a harness owns is its SDK slice: how
14
+ * the engine is created or resumed, how the prompt is placed, how MCP servers
15
+ * are bound, how the engine is made to stop before a gated side effect, and
16
+ * how its events become transcript rows. This file is the whole of what a
17
+ * harness author has to implement; `__test-utils__/harness-contract/` is the
18
+ * kit every implementation has to pass.
19
+ *
20
+ * Every member here is a rename of a function the Cursor loop already injects
21
+ * (`execute-cursor/turn-stream.ts` `CursorTurnStreamDeps`) or a fact the
22
+ * runtime cannot read anywhere else. Nothing here is speculative: where the
23
+ * program's original sketch and the code disagreed, the code won, and the
24
+ * disagreement was ruled at the entry's gate
25
+ * (stigmer-cloud `_projects/2026-09/20260911.02.sp.harness-contract-and-kit/`
26
+ * for S1; `20260911.03.sp.turn-runtime-extraction/` M3 for the growth below).
27
+ *
28
+ * What is deliberately NOT on this contract, and why:
29
+ *
30
+ * - No `dispose()`. One adapter object serves many concurrent turns
31
+ * (`maxConcurrentActivities`), so a per-turn teardown method on the
32
+ * adapter is a race. The adapter owns its per-turn teardown in its own
33
+ * `finally` inside `runTurn` (the Cursor harness parks its agent there).
34
+ * - No `isCancelled()`, no `heartbeat(details)`, no `ExecutionStatusWriter`
35
+ * base. Each would be a second way of saying something `stopSignal`,
36
+ * `recordActivity()` or `requestPersist()` already says, and two writers of
37
+ * one fact drift (the native builders' `forceNextUpdate` flag is the same
38
+ * fact as a `requestPersist()` call).
39
+ * - No `reason` on `interrupted`, no payload on `completed`, no `retryable`
40
+ * on `failed`. Every cause of stopping is the runtime's own evidence; the
41
+ * final text and structured output are already folded onto the status;
42
+ * Temporal never retries a returned activity, so a retryable flag would
43
+ * have no reader.
44
+ * - No token-rotation hook. `Config.stigmerTokenRef` is the canonical
45
+ * mutable ref; an adapter's transport reads it per request.
46
+ * - No `TurnInput.status`. The runtime seeds `TurnSink.status` from the
47
+ * persisted transcript; a second copy on the input is the drift the
48
+ * single-source-of-truth mandate forbids.
49
+ * - No execution context. "This activity is execution X" is the runtime's
50
+ * ambient fact for the WHOLE activity (`shared/execution-context.ts`, an
51
+ * `AsyncLocalStorage` the runtime enters before anything runs); the
52
+ * interceptors read it per request, so no adapter establishes or
53
+ * propagates it.
54
+ * - No persist cadence. The runtime's chokepoint is single-flight and
55
+ * unconditional at settle; WHEN a streaming turn asks for a write is the
56
+ * adapter's (`shared/persist-decision.ts` over its own dirty flags, since
57
+ * what counts as a discrete change is engine knowledge), until S3 lifts
58
+ * the file-review capture and can revisit with both loops in view.
59
+ *
60
+ * Module shape follows `shared/checkpointer/`: `types.ts`, `capabilities.ts`,
61
+ * `registry.ts`, no barrel.
62
+ */
63
+ import type { ApprovalAction } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/enum_pb";
64
+ import type { AgentExecution, AgentExecutionStatus } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/api_pb";
65
+ import type { Session } from "@stigmer/protos/ai/stigmer/agentic/session/v1/api_pb";
66
+ import type { Config } from "../config.js";
67
+ import type { NormalizedActivityInput } from "../shared/activity-input.js";
68
+ import type { ArtifactStorage } from "../shared/artifact-storage.js";
69
+ import type { TimingRecorder } from "../shared/cold-start-timing.js";
70
+ import type { ResolvedBlueprint } from "../shared/blueprint-resolver.js";
71
+ import type { SessionWorkspaceProvision } from "../shared/workspace/session-provision.js";
72
+ import type { ResolvedMcpServer } from "../shared/mcp-resolver.js";
73
+ import type { ChannelMessagingInfo } from "../shared/channel-attachment.js";
74
+ import type { ActiveLeases, MergedToolPolicy } from "../shared/approval-policy.js";
75
+ import type { SkillMetadata } from "../shared/skill-resolver.js";
76
+ import type { ResolvedAttachment } from "../shared/attachment-resolver.js";
77
+ import type { NotViewableEntry, VisionImage } from "../shared/attachment-vision.js";
78
+ import type { EffectiveServiceTier } from "../shared/service-tier.js";
79
+ import type { EffectiveThinkingMode } from "../shared/thinking-mode.js";
80
+ import type { SenderIdentity } from "../shared/sender-identity.js";
81
+ import type { DeclaredPreferencesContent } from "../shared/declared-preferences.js";
82
+ import type { RecalledMemoriesContent } from "../shared/recalled-memories.js";
83
+ import type { HarnessCapabilities } from "./capabilities.js";
84
+ /**
85
+ * One harness, as the runtime sees it. ONE adapter object exists per worker
86
+ * process; it serves every concurrent turn of its harness and holds no
87
+ * per-turn state (per-turn state lives in the `runTurn` frame). Three
88
+ * lifetimes meet here — worker (`boot`/`shutdown`), session
89
+ * (`releaseSession`) and turn (`runTurn`) — because the Cursor harness parks
90
+ * an engine per SESSION between turns, longer than a turn and shorter than
91
+ * the worker.
92
+ *
93
+ * `name` is a diagnostic identity (log lines, kit messages, the registry's
94
+ * duplicate check). It is NOT the activity the harness is bound to: the wire
95
+ * binding is the registry row's (`registry.ts` `HARNESS_ACTIVITY_NAMES`),
96
+ * so an adapter never declares a byte-pinned wire name and a test double can
97
+ * implement this interface under its own name.
98
+ */
99
+ export interface HarnessAdapter {
100
+ readonly name: string;
101
+ readonly capabilities: HarnessCapabilities;
102
+ /**
103
+ * Worker lifetime, once per process, run by the registry in declaration
104
+ * order in BOTH composition roots (`runner.ts`, `runner-manager.ts`). Runs
105
+ * BEFORE bootstrap resolution — the Cursor interceptors must patch
106
+ * `node:http2` before the control plane is dialled — so `config` carries
107
+ * no Temporal coordinates yet. Vendor SDKs are imported lazily inside, so a
108
+ * harness that is not selected costs nothing at boot. A rejection here
109
+ * fails the worker's boot; a worker that cannot boot a harness must not
110
+ * start.
111
+ */
112
+ boot(config: Config): Promise<void>;
113
+ /**
114
+ * Worker lifetime, once per process, after the Temporal worker has drained.
115
+ * Releases everything the adapter still holds (the Cursor harness closes
116
+ * every parked agent). Must resolve even when nothing is held.
117
+ */
118
+ shutdown(): Promise<void>;
119
+ /**
120
+ * Session lifetime: the session is done on this host, release anything
121
+ * parked for it (the Cursor harness: the parked agent, its executor and the
122
+ * MCP subprocesses the lease pins, #215). Called by the registry from the
123
+ * manager's `removeSession`. A harness that parks nothing per session
124
+ * resolves as a no-op and says so in its header. Unknown session ids are a
125
+ * no-op, never an error: the runtime does not track which host parked what.
126
+ */
127
+ releaseSession(sessionId: string): Promise<void>;
128
+ /**
129
+ * Turn lifetime: run ONE engine turn against the resolved input, folding
130
+ * the engine's transcript rows into `sink.status` as they arrive, and
131
+ * settle with a {@link TurnOutcome}.
132
+ *
133
+ * The rules every implementation is held to (the kit's invariants):
134
+ *
135
+ * - Resolves, never rejects. A vendor failure becomes
136
+ * `{ kind: "failed", message, surface }` with the user-facing sentence
137
+ * the adapter's classifier produced. A `CancelledFailure` never escapes:
138
+ * the runtime, not the adapter, decides what is a pause and what is a
139
+ * shutdown, and it throws exactly where Temporal semantics require.
140
+ * - Stops promptly when `sink.stopSignal` aborts, whatever the cause,
141
+ * settling `interrupted`. Every call the adapter makes is bounded: the
142
+ * runtime's heartbeat is live for the whole activity, and a live
143
+ * heartbeat over an unbounded call keeps a dead activity alive forever.
144
+ * - Proposes, never adjudicates. A gated side effect surfaces as a
145
+ * WAITING_APPROVAL row on `sink.status` and the turn ends
146
+ * `awaiting_approval`; the decision arrives on the next invocation in
147
+ * `input.approvalDecisions`. APPROVE executes exactly once; REJECT and
148
+ * SKIP never execute.
149
+ * - Owns its own per-turn teardown in a `finally` inside this method.
150
+ * - Imports nothing from `@temporalio/*`: the kit runs an adapter outside
151
+ * any activity context, and every Temporal fact it needs arrives through
152
+ * the sink (`execute-cursor/__tests__/adapter-is-temporal-free.test.ts`).
153
+ */
154
+ runTurn(input: TurnInput, sink: TurnSink): Promise<TurnOutcome>;
155
+ }
156
+ /** The resolved environment (phase 2b): the MCP-bound env map and the keys that are secrets. */
157
+ export interface TurnEnvironment {
158
+ readonly envVars: Record<string, string>;
159
+ readonly secretKeys: ReadonlySet<string>;
160
+ }
161
+ /** The provisioned workspace (phase 2c) and the capture posture derived from it. */
162
+ export interface TurnWorkspace {
163
+ /** The directories the agent operates in; never empty (`provisionSessionWorkspace` guarantees it). */
164
+ readonly dirs: readonly string[];
165
+ /** `dirs[0]`, the tree the turn's lock, gate, capture and skill mount all key on. */
166
+ readonly primaryDir: string;
167
+ /** True when `primaryDir` is a git work tree: selects the git-diff capture substrate over CAS. */
168
+ readonly gitWorkspace: boolean;
169
+ /** Apply-then-review capture (true) or the classic deny-gate (false); see `shared/filereview/capture.ts` `deriveCaptureMode`. */
170
+ readonly captureMode: boolean;
171
+ /** `${executionId}:${turnSeq}`: the deterministic id of the change set this turn may produce. */
172
+ readonly changeSetId: string;
173
+ readonly provision: SessionWorkspaceProvision;
174
+ }
175
+ /** The tool surface (phases 4 to 4b): the resolved servers with the attachments folded in, and the merged approval policies. */
176
+ export interface TurnMcp {
177
+ /** Every resolved server, synthesized attachments included; the harness projects its SDK config from this list. */
178
+ readonly servers: readonly ResolvedMcpServer[];
179
+ /** Serving proactive channels and their templates (the DD-006 D2 discovery read). */
180
+ readonly channelMessaging: readonly ChannelMessagingInfo[];
181
+ readonly leases: ActiveLeases;
182
+ readonly policies: ReadonlyMap<string, MergedToolPolicy>;
183
+ }
184
+ /** The turn's explicit inputs (phase 5b), resolved into the workspace with the vision facts derived once. */
185
+ export interface TurnAttachments {
186
+ readonly results: readonly ResolvedAttachment[];
187
+ /** The images the model sees inline, in attachment order. */
188
+ readonly visionImages: readonly VisionImage[];
189
+ /** The image-shaped attachments that degraded to path-only, disclosed in the prompt. */
190
+ readonly visionNotViewable: readonly NotViewableEntry[];
191
+ }
192
+ /** What the execution asked for (phase 6, the harness-agnostic half): the raw model name and the effective tier and thinking mode. */
193
+ export interface TurnModelPreferences {
194
+ /** `spec.executionConfig.modelName`, or `"default"`; the harness validates it against its own catalog. */
195
+ readonly requested: string;
196
+ /** Never UNSPECIFIED: `resolveEffectiveServiceTier` is where the platform default is applied. */
197
+ readonly serviceTier: EffectiveServiceTier;
198
+ /** Never UNSPECIFIED: `resolveEffectiveThinkingMode` is where the platform default is applied. */
199
+ readonly thinkingMode: EffectiveThinkingMode;
200
+ }
201
+ /**
202
+ * The standing context a first prompt carries (phase 9c) and the per-turn
203
+ * catchup, read once from the session metadata and the execution spec.
204
+ */
205
+ export interface TurnStandingContext {
206
+ readonly contextBridge: string | undefined;
207
+ readonly senderIdentity: SenderIdentity | undefined;
208
+ readonly sessionContext: string | undefined;
209
+ readonly declaredPreferences: DeclaredPreferencesContent | undefined;
210
+ readonly conversationCatchup: string | undefined;
211
+ /**
212
+ * The semantic memory selection, memoized to at most one run per
213
+ * invocation and stamping `status.recalledMemoriesReport` once. A thunk
214
+ * because only the harness knows whether its prompt carries standing
215
+ * context (a successfully resumed engine already holds it).
216
+ */
217
+ readonly selectRecalledMemories: () => Promise<RecalledMemoriesContent | undefined>;
218
+ }
219
+ /**
220
+ * Everything the runtime resolved for this turn, as small named groups
221
+ * (`turn-context.ts` produces one per phase; `run-turn.ts` composes them).
222
+ * This is the whole record: the runtime keeps nothing "private" beside it —
223
+ * the lock release and the write-back coordinator are the finally's
224
+ * resources (`run-turn.ts` `TurnFrame`), not facts about the turn.
225
+ *
226
+ * `threadId` is the engine's state id as the runtime knows it: empty on an
227
+ * `engine-minted` harness's first turn (nothing minted yet) and the id the
228
+ * adapter bound through {@link TurnSink.bindHarnessState} on every later
229
+ * invocation; the runtime-minted id on every turn of a `deterministic`
230
+ * harness. An adapter derives create-vs-resume from it and its own state
231
+ * through `turn-context.ts`'s `isReinvocation`; the contract carries no flag
232
+ * because the two harnesses would derive it differently.
233
+ *
234
+ * Adapter-only facts (the Cursor mode, the service-tier params, the seeded
235
+ * sub-agent rows) are read by the adapter from these records, never resolved
236
+ * by the runtime.
237
+ */
238
+ export interface TurnInput extends NormalizedActivityInput {
239
+ /**
240
+ * The session this turn belongs to. Read by the runtime from the fetched
241
+ * execution; the adapter needs it to key anything it parks per session and
242
+ * to recognise a later {@link HarnessAdapter.releaseSession}.
243
+ */
244
+ readonly sessionId: string;
245
+ /**
246
+ * The approval decisions the user has made on this execution's WAITING
247
+ * rows, keyed by tool-call id: the one projection both harness readers
248
+ * agree on (`status.messages[].toolCalls[]` where `approvalAction` is set
249
+ * and `status` is WAITING_APPROVAL). Derived by the runtime from
250
+ * `sink.status` on every invocation, never stored, so it cannot drift from
251
+ * the rows. An adapter reads the ROW for anything else it needs (args,
252
+ * content digest) and this map for the verdict; it never re-derives the
253
+ * verdict from the rows itself.
254
+ */
255
+ readonly approvalDecisions: ReadonlyMap<string, ApprovalAction>;
256
+ readonly execution: AgentExecution;
257
+ /** The same object as `blueprint.session`; `bindHarnessState` writes it. */
258
+ readonly session: Session;
259
+ readonly blueprint: ResolvedBlueprint;
260
+ readonly environment: TurnEnvironment;
261
+ readonly workspace: TurnWorkspace;
262
+ readonly mcp: TurnMcp;
263
+ /** The mounted skills (phase 5): each under the session's platform dir, reachable from the workspace through its `.stigmer` link; the harness renders them into its prompt. */
264
+ readonly skills: readonly SkillMetadata[];
265
+ readonly attachments: TurnAttachments;
266
+ /** Approved whole-file writes the runtime applied itself this turn (exact-apply); the harness issues no grant for them. */
267
+ readonly appliedToolCallIds: ReadonlySet<string>;
268
+ readonly model: TurnModelPreferences;
269
+ /** `spec.executionConfig.structuredOutputSchema`, when the execution asks for structured output. */
270
+ readonly structuredOutputSchema: Record<string, unknown> | undefined;
271
+ readonly standing: TurnStandingContext;
272
+ /** Resolved once by the runtime before any phase; absent when no substrate works. */
273
+ readonly artifactStorage: ArtifactStorage | undefined;
274
+ }
275
+ /**
276
+ * The runtime's face during one turn: what an adapter may ask of it, and the
277
+ * one status it folds into. One sink per turn, owned by the runtime; the
278
+ * adapter never constructs one.
279
+ *
280
+ * Field ownership on `status` before the canonical transcript lands (S4):
281
+ * the adapter appends the engine's transcript rows (assistant messages,
282
+ * tool-call rows and their approval status, sub-agent rows, todos); the
283
+ * runtime writes the phase, the terminal system messages, `streamingUsage`,
284
+ * artifacts, write-backs and the file-review projection. An adapter never
285
+ * writes a phase or a terminal copy: those are Temporal semantics the
286
+ * runtime owns once. (The file-review boundary itself is the adapter's until
287
+ * S3 lifts both harnesses' captures together; `execute-cursor/adapter.ts`
288
+ * says so.)
289
+ */
290
+ export interface TurnSink {
291
+ /**
292
+ * The one execution status this turn folds into. On a reinvocation it is
293
+ * seeded by the runtime from the persisted transcript, so the WAITING rows
294
+ * the adapter wrote last time, and their decisions, are already on it.
295
+ */
296
+ readonly status: AgentExecutionStatus;
297
+ /**
298
+ * The ONE way a turn is told to stop, whatever the cause: user pause,
299
+ * worker shutdown, stall, cost cap, platform STOP. The runtime knows why
300
+ * and maps the outcome; the adapter's only job is to settle promptly as
301
+ * `interrupted`. `stopSignal.reason` is the runtime's own evidence — an
302
+ * adapter never branches on it. Check `aborted` at every step boundary and
303
+ * listen for `abort` inside anything long-running (the Cursor adapter
304
+ * cancels its SDK run from that listener). May already be aborted when
305
+ * `runTurn` is entered; then return `interrupted` before doing any work.
306
+ */
307
+ readonly stopSignal: AbortSignal;
308
+ /**
309
+ * The runtime's cold-start timeline for this turn, a live handle like
310
+ * `status`. The runtime marked its own resolution segments on it before
311
+ * `runTurn`; the adapter marks its setup segments (skills, gate, engine
312
+ * resolve) and emits the `execution_setup` line once its engine is ready,
313
+ * so the one timeline reads end to end (`shared/cold-start-timing.ts`).
314
+ * Diagnostics only; nothing branches on it.
315
+ */
316
+ readonly setupTiming: TimingRecorder;
317
+ /**
318
+ * "Persist the status": a write through the runtime's single persist
319
+ * chokepoint (tool-output offload, size cap, secret withholding,
320
+ * `streamingUsage`). Single-flight: a request while a write is in flight
321
+ * coalesces into the next write. Resolves when the state as of the request
322
+ * has been written, so an adapter that needs ordering MAY await it (the
323
+ * Cursor loop awaits before pulling the next event, so a platform STOP
324
+ * answered by that write stops the turn before the next event, as it
325
+ * always has); an adapter never MUST await it, because the runtime
326
+ * persists unconditionally when the turn settles. Never rejects.
327
+ */
328
+ requestPersist(): Promise<void>;
329
+ /**
330
+ * "I made progress": resets the runtime's stall watchdog and is carried
331
+ * into the next Temporal heartbeat. Call it on every engine event, every
332
+ * token delta, and every step boundary of the adapter's own setup (engine
333
+ * resolved, send returned, boundary done) — a long generation emits deltas
334
+ * but few discrete events, and resetting only on events false-positives a
335
+ * stall. `detail` names what progressed (the Cursor loop passes the tool
336
+ * name of a `tool_call` event); the runtime quotes the last detail in the
337
+ * stall diagnostic (`last tool: shell`). Never throws.
338
+ */
339
+ recordActivity(detail?: string): void;
340
+ /**
341
+ * Token counts for one engine turn, priced by the adapter against its own
342
+ * vendor's table. The runtime accumulates and enforces `max_cost_usd`; an
343
+ * adapter reports and never accounts. Every count is a non-negative delta
344
+ * since the previous report.
345
+ */
346
+ reportUsage(delta: UsageDelta): void;
347
+ /**
348
+ * The user-visible setup label (`status.setupProgress.currentPhase`) for a
349
+ * step only the adapter knows ("Initializing Cursor agent"). The runtime
350
+ * reports its own resolution labels itself; the adapter reports the labels
351
+ * of its setup steps exactly as the orchestrator did, so the UI's spinner
352
+ * copy is unchanged by the extraction (Q-S2-5). Resolves once the label is
353
+ * written; the write carries no phase, so it never advances the execution.
354
+ */
355
+ reportProgress(label: string): Promise<void>;
356
+ /**
357
+ * The engine-minted state id, the moment it exists and BEFORE the turn
358
+ * proceeds, so a crash mid-turn still resumes on the next invocation. The
359
+ * runtime writes it to the session record the adapter was handed
360
+ * (`input.session`, with `harness_state_id` set and the metadata slug
361
+ * cleared, the agnostic quirk of `BuildUpdateStateStep`); the adapter may
362
+ * set its own harness-specific `SessionSpec` fields on that record before
363
+ * binding, one writer per field (`harnessStateId` the runtime's,
364
+ * `cursorMode` the adapter's; Q-S2-11). Called only by adapters whose
365
+ * `capabilities.stateIdSource` is `"engine-minted"`, and before their first
366
+ * `requestPersist`; a `deterministic` harness never calls it. Rejects when
367
+ * the session write fails; the adapter then ends the turn `failed` with
368
+ * that error and executes nothing further.
369
+ */
370
+ bindHarnessState(harnessStateId: string): Promise<void>;
371
+ }
372
+ /**
373
+ * Token counts for one engine turn, priced. The four counts are what the
374
+ * Cursor loop reads from the SDK's `turn-ended` delta; `estimatedCostUsd` is
375
+ * the adapter's price for them at its vendor's rates (the runtime cannot
376
+ * price without the vendor's table and must not import it; Q-S2-12), and
377
+ * `model` / `requestedModelParams` name the basis it priced against, which
378
+ * the runtime records into `streamingUsage` (`model` is the catalog-validated
379
+ * id, `requestedModelParams` the JSON of the params sent — a string on the
380
+ * proto, so the SDK type stays inside the adapter). Every field is optional
381
+ * because engines report different subsets; a missing count means zero,
382
+ * never "unknown"; a missing basis inherits the previous delta's.
383
+ */
384
+ export interface UsageDelta {
385
+ readonly inputTokens?: number;
386
+ readonly outputTokens?: number;
387
+ readonly cacheReadTokens?: number;
388
+ readonly cacheWriteTokens?: number;
389
+ readonly estimatedCostUsd?: number;
390
+ readonly model?: string;
391
+ readonly requestedModelParams?: string;
392
+ }
393
+ /**
394
+ * Which of the runtime's three failure copies a `failed` outcome takes. A
395
+ * classification, never copy: the runtime owns the words
396
+ * (`terminal-table.ts`), the adapter says what kind of thing failed.
397
+ *
398
+ * - `engine`: the engine reported its run as failed. The transcript already
399
+ * tells the story, so the runtime writes `status.error` and no system row
400
+ * (the Cursor `run.wait()` error arm).
401
+ * - `actionable`: the user can fix it (a foreign hook blocked a tool). One
402
+ * `Execution failed: …` row, the same shape the runtime's own settlements
403
+ * use.
404
+ * - `internal`: the runner or its transport broke unexpectedly (a thrown
405
+ * SDK error, an exception in the adapter). The boilerplate row and an
406
+ * `Error details:` row.
407
+ */
408
+ export type FailureSurface = "engine" | "actionable" | "internal";
409
+ /**
410
+ * How one turn ended, carrying ONLY what the runtime cannot read from
411
+ * `sink.status` or its own evidence.
412
+ *
413
+ * - `completed`: the engine finished. The final text and any structured
414
+ * output are already folded onto the status; nothing rides here.
415
+ * - `cancelled`: the engine ended its own run cancelled and there is nothing
416
+ * to wait for — an SDK-side cancel, or a deny-and-retry adapter that
417
+ * stopped its run to gate a call and then found nothing to pause for
418
+ * (an unattended denial settled as skipped). Not `interrupted`: the
419
+ * runtime's `stopSignal` never fired. The runtime writes
420
+ * `EXECUTION_CANCELLED` with no copy and completes the turn.
421
+ * - `awaiting_approval`: the engine proposed at least one gated side effect
422
+ * and stopped. The WAITING_APPROVAL rows are already on the status; the
423
+ * runtime persists them and returns to the workflow, which reinvokes with
424
+ * the decisions.
425
+ * - `failed`: the engine or its transport failed in a way the adapter can
426
+ * name. `message` is the user-facing sentence, `surface` which copy it
427
+ * takes, `cause` is for the log. The runtime persists FAILED and RETURNS
428
+ * (Temporal does not retry a returned activity; re-running the same
429
+ * prompt would fail the same way).
430
+ * - `interrupted`: `sink.stopSignal` aborted and the adapter stopped. WHY it
431
+ * aborted is the runtime's evidence (its watchdog, its accounting, its
432
+ * chokepoint, the cancellation it was delivered), so no reason rides here;
433
+ * the runtime classifies and applies the throw-vs-return table.
434
+ */
435
+ export type TurnOutcome = {
436
+ readonly kind: "completed";
437
+ } | {
438
+ readonly kind: "cancelled";
439
+ } | {
440
+ readonly kind: "awaiting_approval";
441
+ } | {
442
+ readonly kind: "failed";
443
+ readonly message: string;
444
+ readonly surface: FailureSurface;
445
+ readonly cause?: unknown;
446
+ } | {
447
+ readonly kind: "interrupted";
448
+ };
@@ -0,0 +1,64 @@
1
+ /**
2
+ * The harness adapter contract — the line between what the turn runtime owns
3
+ * and what a harness owns.
4
+ *
5
+ * Stigmer runs an agent turn through one of several engines ("harnesses"):
6
+ * the native LangGraph deep-agent, the Cursor SDK, and in future the Claude
7
+ * Agent SDK and the Codex SDK. Everything about a turn that does NOT touch a
8
+ * vendor SDK — fetching the execution, resolving the blueprint and the
9
+ * environment, provisioning and locking the workspace, mounting skills,
10
+ * resolving MCP servers and approval policies, seeding the transcript, the
11
+ * persist chokepoint, the stall watchdog, the Temporal heartbeat, pause vs
12
+ * shutdown, the cost cap, the terminal mapping — is the RUNTIME's
13
+ * (`run-turn.ts`), written once. What a harness owns is its SDK slice: how
14
+ * the engine is created or resumed, how the prompt is placed, how MCP servers
15
+ * are bound, how the engine is made to stop before a gated side effect, and
16
+ * how its events become transcript rows. This file is the whole of what a
17
+ * harness author has to implement; `__test-utils__/harness-contract/` is the
18
+ * kit every implementation has to pass.
19
+ *
20
+ * Every member here is a rename of a function the Cursor loop already injects
21
+ * (`execute-cursor/turn-stream.ts` `CursorTurnStreamDeps`) or a fact the
22
+ * runtime cannot read anywhere else. Nothing here is speculative: where the
23
+ * program's original sketch and the code disagreed, the code won, and the
24
+ * disagreement was ruled at the entry's gate
25
+ * (stigmer-cloud `_projects/2026-09/20260911.02.sp.harness-contract-and-kit/`
26
+ * for S1; `20260911.03.sp.turn-runtime-extraction/` M3 for the growth below).
27
+ *
28
+ * What is deliberately NOT on this contract, and why:
29
+ *
30
+ * - No `dispose()`. One adapter object serves many concurrent turns
31
+ * (`maxConcurrentActivities`), so a per-turn teardown method on the
32
+ * adapter is a race. The adapter owns its per-turn teardown in its own
33
+ * `finally` inside `runTurn` (the Cursor harness parks its agent there).
34
+ * - No `isCancelled()`, no `heartbeat(details)`, no `ExecutionStatusWriter`
35
+ * base. Each would be a second way of saying something `stopSignal`,
36
+ * `recordActivity()` or `requestPersist()` already says, and two writers of
37
+ * one fact drift (the native builders' `forceNextUpdate` flag is the same
38
+ * fact as a `requestPersist()` call).
39
+ * - No `reason` on `interrupted`, no payload on `completed`, no `retryable`
40
+ * on `failed`. Every cause of stopping is the runtime's own evidence; the
41
+ * final text and structured output are already folded onto the status;
42
+ * Temporal never retries a returned activity, so a retryable flag would
43
+ * have no reader.
44
+ * - No token-rotation hook. `Config.stigmerTokenRef` is the canonical
45
+ * mutable ref; an adapter's transport reads it per request.
46
+ * - No `TurnInput.status`. The runtime seeds `TurnSink.status` from the
47
+ * persisted transcript; a second copy on the input is the drift the
48
+ * single-source-of-truth mandate forbids.
49
+ * - No execution context. "This activity is execution X" is the runtime's
50
+ * ambient fact for the WHOLE activity (`shared/execution-context.ts`, an
51
+ * `AsyncLocalStorage` the runtime enters before anything runs); the
52
+ * interceptors read it per request, so no adapter establishes or
53
+ * propagates it.
54
+ * - No persist cadence. The runtime's chokepoint is single-flight and
55
+ * unconditional at settle; WHEN a streaming turn asks for a write is the
56
+ * adapter's (`shared/persist-decision.ts` over its own dirty flags, since
57
+ * what counts as a discrete change is engine knowledge), until S3 lifts
58
+ * the file-review capture and can revisit with both loops in view.
59
+ *
60
+ * Module shape follows `shared/checkpointer/`: `types.ts`, `capabilities.ts`,
61
+ * `registry.ts`, no barrel.
62
+ */
63
+ export {};
64
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/harness/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6DG"}
@@ -0,0 +1,68 @@
1
+ /**
2
+ * The turn runtime's usage accounting: the priced deltas an adapter reports
3
+ * through `TurnSink.reportUsage`, summed into the `streaming_usage` summary
4
+ * the persist chokepoint writes before every status write, and the running
5
+ * cost the `max_cost_usd` cap is enforced against.
6
+ *
7
+ * Who owns what (Q-S2-12): the ADAPTER prices, because only it has its
8
+ * vendor's rate table and variant semantics (`execute-cursor/usage-pricing.ts`
9
+ * for Cursor); the RUNTIME accounts and enforces, because the cap and the
10
+ * summary are the platform's, the same for every engine. A delta therefore
11
+ * arrives already priced, naming the basis it was priced against (`model`,
12
+ * `requestedModelParams`), and this class adds — it never multiplies. The
13
+ * tier and thinking mode it records are the runtime's own effective
14
+ * preferences (`TurnInput.model`), the audit trail that the account default
15
+ * was never left in control (#357, #772).
16
+ *
17
+ * Moved from `activities/execute-cursor/usage-accumulator.ts` at S2 M3, the
18
+ * pricing call split out; the sums, the snapshot shape and the empty
19
+ * snapshot are unchanged, so `streamingUsage` is byte-for-byte what the
20
+ * Cursor orchestrator wrote.
21
+ *
22
+ * This data is display-only. The authoritative billing source is the BiDi
23
+ * proxy, which records usage from the wire.
24
+ */
25
+ import { ServiceTier, ThinkingMode } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/enum_pb";
26
+ import type { UsageDelta } from "./types.js";
27
+ export interface UsageSnapshot {
28
+ readonly inputTokens: bigint;
29
+ readonly outputTokens: bigint;
30
+ readonly cacheReadTokens: bigint;
31
+ readonly cacheWriteTokens: bigint;
32
+ readonly totalTokens: bigint;
33
+ readonly turnCount: number;
34
+ readonly estimatedCostUsd: number;
35
+ /** The basis the adapter last priced against (its catalog-validated model id); `""` until a delta names one. */
36
+ readonly model: string;
37
+ readonly observedAt: string;
38
+ /** Tier the runner requested — always explicit post-translation (#357). */
39
+ readonly requestedServiceTier: ServiceTier;
40
+ /** JSON-encoded params the adapter sent with its model selection; "" when none. */
41
+ readonly requestedModelParams: string;
42
+ /** Thinking mode the runner requested — always explicit post-translation (#772). */
43
+ readonly requestedThinkingMode: ThinkingMode;
44
+ }
45
+ export declare class UsageAccumulator {
46
+ /** The effective tier the runtime resolved (never UNSPECIFIED on a real turn; the default keeps the empty snapshot honest). */
47
+ private readonly requestedServiceTier;
48
+ /** The effective thinking mode the runtime resolved. Price-neutral (#772); recorded purely as the audit trail twin of the tier. */
49
+ private readonly requestedThinkingMode;
50
+ private inputTokens;
51
+ private outputTokens;
52
+ private cacheReadTokens;
53
+ private cacheWriteTokens;
54
+ private turnCount;
55
+ private estimatedCostUsd;
56
+ private observedAt;
57
+ private model;
58
+ private requestedModelParams;
59
+ constructor(
60
+ /** The effective tier the runtime resolved (never UNSPECIFIED on a real turn; the default keeps the empty snapshot honest). */
61
+ requestedServiceTier?: ServiceTier,
62
+ /** The effective thinking mode the runtime resolved. Price-neutral (#772); recorded purely as the audit trail twin of the tier. */
63
+ requestedThinkingMode?: ThinkingMode);
64
+ /** Add one priced delta. A delta without a basis inherits the previous one; a missing count is zero. */
65
+ addTurn(delta: UsageDelta): void;
66
+ get hasTurns(): boolean;
67
+ snapshot(): UsageSnapshot;
68
+ }