@stigmer/runner 3.15.3-dev.20260914100347 → 3.15.3-dev.20260916211208

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 (549) hide show
  1. package/README.md +1 -0
  2. package/dist/.build-fingerprint +1 -1
  3. package/dist/__test-utils__/approval-contract/types.d.ts +1 -1
  4. package/dist/__test-utils__/hermetic-activity.d.ts +61 -7
  5. package/dist/__test-utils__/hermetic-activity.js +100 -9
  6. package/dist/__test-utils__/hermetic-activity.js.map +1 -1
  7. package/dist/__test-utils__/model-registry-fixture.d.ts +22 -3
  8. package/dist/__test-utils__/model-registry-fixture.js +22 -7
  9. package/dist/__test-utils__/model-registry-fixture.js.map +1 -1
  10. package/dist/activities/execute-cursor/__test-utils__/contract-subject.d.ts +2 -2
  11. package/dist/activities/execute-cursor/__test-utils__/contract-subject.js +14 -11
  12. package/dist/activities/execute-cursor/__test-utils__/contract-subject.js.map +1 -1
  13. package/dist/activities/execute-cursor/__test-utils__/fold.d.ts +61 -0
  14. package/dist/activities/execute-cursor/__test-utils__/fold.js +94 -0
  15. package/dist/activities/execute-cursor/__test-utils__/fold.js.map +1 -0
  16. package/dist/activities/execute-cursor/__test-utils__/gateway-substrate.js +1 -1
  17. package/dist/activities/execute-cursor/__test-utils__/gateway-substrate.js.map +1 -1
  18. package/dist/activities/execute-cursor/__test-utils__/hermetic-cursor.d.ts +52 -14
  19. package/dist/activities/execute-cursor/__test-utils__/hermetic-cursor.js +46 -12
  20. package/dist/activities/execute-cursor/__test-utils__/hermetic-cursor.js.map +1 -1
  21. package/dist/activities/execute-cursor/__test-utils__/scripted-agent.d.ts +21 -28
  22. package/dist/activities/execute-cursor/__test-utils__/scripted-agent.js +27 -11
  23. package/dist/activities/execute-cursor/__test-utils__/scripted-agent.js.map +1 -1
  24. package/dist/activities/execute-cursor/__test-utils__/scripted-sdk.d.ts +70 -26
  25. package/dist/activities/execute-cursor/__test-utils__/scripted-sdk.js +82 -32
  26. package/dist/activities/execute-cursor/__test-utils__/scripted-sdk.js.map +1 -1
  27. package/dist/activities/execute-cursor/adapter.d.ts +8 -7
  28. package/dist/activities/execute-cursor/adapter.js +13 -9
  29. package/dist/activities/execute-cursor/adapter.js.map +1 -1
  30. package/dist/activities/execute-cursor/approval-policy.d.ts +10 -10
  31. package/dist/activities/execute-cursor/approval-policy.js +12 -23
  32. package/dist/activities/execute-cursor/approval-policy.js.map +1 -1
  33. package/dist/activities/execute-cursor/approval-state.d.ts +35 -1
  34. package/dist/activities/execute-cursor/approval-state.js +65 -0
  35. package/dist/activities/execute-cursor/approval-state.js.map +1 -1
  36. package/dist/activities/execute-cursor/{message-translator.d.ts → boundary-rows.d.ts} +45 -341
  37. package/dist/activities/execute-cursor/boundary-rows.js +1018 -0
  38. package/dist/activities/execute-cursor/boundary-rows.js.map +1 -0
  39. package/dist/activities/execute-cursor/cursor-capabilities.d.ts +1 -1
  40. package/dist/activities/execute-cursor/cursor-capabilities.js +1 -1
  41. package/dist/activities/execute-cursor/cursor-event-recorder.d.ts +33 -14
  42. package/dist/activities/execute-cursor/cursor-event-recorder.js +43 -21
  43. package/dist/activities/execute-cursor/cursor-event-recorder.js.map +1 -1
  44. package/dist/activities/execute-cursor/prompt-builder.d.ts +3 -3
  45. package/dist/activities/execute-cursor/prompt-builder.js +4 -4
  46. package/dist/activities/execute-cursor/prompt-builder.js.map +1 -1
  47. package/dist/activities/execute-cursor/sdk-warmup.d.ts +15 -6
  48. package/dist/activities/execute-cursor/sdk-warmup.js +15 -6
  49. package/dist/activities/execute-cursor/sdk-warmup.js.map +1 -1
  50. package/dist/activities/execute-cursor/service-tier.js +1 -2
  51. package/dist/activities/execute-cursor/service-tier.js.map +1 -1
  52. package/dist/activities/execute-cursor/session-lifecycle.d.ts +38 -59
  53. package/dist/activities/execute-cursor/session-lifecycle.js +59 -96
  54. package/dist/activities/execute-cursor/session-lifecycle.js.map +1 -1
  55. package/dist/activities/execute-cursor/session-store.d.ts +100 -0
  56. package/dist/activities/execute-cursor/session-store.js +157 -0
  57. package/dist/activities/execute-cursor/session-store.js.map +1 -0
  58. package/dist/activities/execute-cursor/sub-agent-steps.d.ts +79 -0
  59. package/dist/activities/execute-cursor/sub-agent-steps.js +180 -0
  60. package/dist/activities/execute-cursor/sub-agent-steps.js.map +1 -0
  61. package/dist/activities/execute-cursor/tool-result.d.ts +49 -0
  62. package/dist/activities/execute-cursor/tool-result.js +130 -0
  63. package/dist/activities/execute-cursor/tool-result.js.map +1 -0
  64. package/dist/activities/execute-cursor/translator.d.ts +178 -0
  65. package/dist/activities/execute-cursor/translator.js +485 -0
  66. package/dist/activities/execute-cursor/translator.js.map +1 -0
  67. package/dist/activities/execute-cursor/turn-boundary.d.ts +15 -5
  68. package/dist/activities/execute-cursor/turn-boundary.js +10 -14
  69. package/dist/activities/execute-cursor/turn-boundary.js.map +1 -1
  70. package/dist/activities/execute-cursor/turn-settle.d.ts +11 -7
  71. package/dist/activities/execute-cursor/turn-settle.js +47 -34
  72. package/dist/activities/execute-cursor/turn-settle.js.map +1 -1
  73. package/dist/activities/execute-cursor/turn-setup.d.ts +2 -2
  74. package/dist/activities/execute-cursor/turn-setup.js +5 -5
  75. package/dist/activities/execute-cursor/turn-setup.js.map +1 -1
  76. package/dist/activities/execute-cursor/turn-stream.d.ts +23 -14
  77. package/dist/activities/execute-cursor/turn-stream.js +41 -28
  78. package/dist/activities/execute-cursor/turn-stream.js.map +1 -1
  79. package/dist/activities/execute-cursor/turn.d.ts +4 -4
  80. package/dist/activities/execute-cursor/turn.js +5 -5
  81. package/dist/activities/execute-cursor/usage-pricing.d.ts +2 -2
  82. package/dist/activities/execute-cursor/usage-pricing.js +2 -2
  83. package/dist/activities/execute-deep-agent/__test-utils__/contract-subject.d.ts +2 -2
  84. package/dist/activities/execute-deep-agent/__test-utils__/contract-subject.js +2 -2
  85. package/dist/activities/execute-deep-agent/__test-utils__/hermetic-deep-agent.d.ts +16 -11
  86. package/dist/activities/execute-deep-agent/__test-utils__/hermetic-deep-agent.js +22 -10
  87. package/dist/activities/execute-deep-agent/__test-utils__/hermetic-deep-agent.js.map +1 -1
  88. package/dist/activities/execute-deep-agent/__test-utils__/hitl-script.js +1 -1
  89. package/dist/activities/execute-deep-agent/__test-utils__/hitl-script.js.map +1 -1
  90. package/dist/activities/execute-deep-agent/__test-utils__/scripted-model-module.d.ts +2 -3
  91. package/dist/activities/execute-deep-agent/__test-utils__/scripted-model-module.js +2 -3
  92. package/dist/activities/execute-deep-agent/__test-utils__/scripted-model-module.js.map +1 -1
  93. package/dist/activities/execute-deep-agent/__test-utils__/scripted-model.d.ts +12 -3
  94. package/dist/activities/execute-deep-agent/__test-utils__/scripted-model.js +18 -4
  95. package/dist/activities/execute-deep-agent/__test-utils__/scripted-model.js.map +1 -1
  96. package/dist/activities/execute-deep-agent/__test-utils__/v3-event-fixtures.d.ts +10 -1
  97. package/dist/activities/execute-deep-agent/__test-utils__/v3-event-fixtures.js +24 -11
  98. package/dist/activities/execute-deep-agent/__test-utils__/v3-event-fixtures.js.map +1 -1
  99. package/dist/activities/execute-deep-agent/adapter.d.ts +1 -1
  100. package/dist/activities/execute-deep-agent/adapter.js +1 -1
  101. package/dist/activities/execute-deep-agent/approval-file-change.d.ts +19 -19
  102. package/dist/activities/execute-deep-agent/approval-file-change.js +16 -15
  103. package/dist/activities/execute-deep-agent/approval-file-change.js.map +1 -1
  104. package/dist/activities/execute-deep-agent/deep-agent-capabilities.d.ts +2 -2
  105. package/dist/activities/execute-deep-agent/deep-agent-capabilities.js +2 -2
  106. package/dist/activities/execute-deep-agent/hitl.d.ts +2 -2
  107. package/dist/activities/execute-deep-agent/hitl.js +2 -2
  108. package/dist/activities/execute-deep-agent/inline-publisher.d.ts +13 -3
  109. package/dist/activities/execute-deep-agent/inline-publisher.js +3 -3
  110. package/dist/activities/execute-deep-agent/inline-publisher.js.map +1 -1
  111. package/dist/activities/execute-deep-agent/prompt-builder.d.ts +3 -3
  112. package/dist/activities/execute-deep-agent/prompt-builder.js +6 -7
  113. package/dist/activities/execute-deep-agent/prompt-builder.js.map +1 -1
  114. package/dist/activities/execute-deep-agent/streaming-side-effects.d.ts +16 -8
  115. package/dist/activities/execute-deep-agent/streaming-side-effects.js +20 -33
  116. package/dist/activities/execute-deep-agent/streaming-side-effects.js.map +1 -1
  117. package/dist/activities/execute-deep-agent/subagent-transformer.d.ts +3 -3
  118. package/dist/activities/execute-deep-agent/subagent-transformer.js +1 -1
  119. package/dist/activities/execute-deep-agent/translator.d.ts +134 -0
  120. package/dist/activities/execute-deep-agent/translator.js +418 -0
  121. package/dist/activities/execute-deep-agent/translator.js.map +1 -0
  122. package/dist/activities/execute-deep-agent/turn-settle.d.ts +13 -7
  123. package/dist/activities/execute-deep-agent/turn-settle.js +34 -45
  124. package/dist/activities/execute-deep-agent/turn-settle.js.map +1 -1
  125. package/dist/activities/execute-deep-agent/turn-setup.d.ts +8 -8
  126. package/dist/activities/execute-deep-agent/turn-setup.js +7 -7
  127. package/dist/activities/execute-deep-agent/turn-stream.d.ts +13 -10
  128. package/dist/activities/execute-deep-agent/turn-stream.js +44 -41
  129. package/dist/activities/execute-deep-agent/turn-stream.js.map +1 -1
  130. package/dist/activities/execute-deep-agent/turn.d.ts +3 -3
  131. package/dist/activities/execute-deep-agent/turn.js +3 -3
  132. package/dist/config.d.ts +2 -2
  133. package/dist/harness/approval-decisions.d.ts +1 -1
  134. package/dist/harness/approval-decisions.js +1 -1
  135. package/dist/harness/capabilities.d.ts +21 -11
  136. package/dist/harness/capabilities.js +2 -2
  137. package/dist/harness/capture.d.ts +4 -4
  138. package/dist/harness/capture.js +4 -4
  139. package/dist/harness/persist-chokepoint.d.ts +3 -3
  140. package/dist/harness/persist-chokepoint.js +3 -3
  141. package/dist/harness/registry.d.ts +2 -2
  142. package/dist/harness/registry.js +2 -2
  143. package/dist/harness/run-turn.d.ts +6 -4
  144. package/dist/harness/run-turn.js +31 -9
  145. package/dist/harness/run-turn.js.map +1 -1
  146. package/dist/harness/stop-controller.d.ts +1 -1
  147. package/dist/harness/stop-controller.js +1 -1
  148. package/dist/harness/terminal-table.d.ts +7 -7
  149. package/dist/harness/terminal-table.js +7 -7
  150. package/dist/harness/transcript/builder.d.ts +182 -0
  151. package/dist/harness/transcript/builder.js +693 -0
  152. package/dist/harness/transcript/builder.js.map +1 -0
  153. package/dist/harness/transcript/events.d.ts +218 -0
  154. package/dist/harness/transcript/events.js +50 -0
  155. package/dist/harness/transcript/events.js.map +1 -0
  156. package/dist/harness/transcript/state.d.ts +110 -0
  157. package/dist/harness/transcript/state.js +148 -0
  158. package/dist/harness/transcript/state.js.map +1 -0
  159. package/dist/harness/turn-context.d.ts +54 -38
  160. package/dist/harness/turn-context.js +42 -43
  161. package/dist/harness/turn-context.js.map +1 -1
  162. package/dist/harness/types.d.ts +63 -22
  163. package/dist/harness/types.js +12 -11
  164. package/dist/harness/types.js.map +1 -1
  165. package/dist/harness/usage-accumulator.d.ts +2 -2
  166. package/dist/harness/usage-accumulator.js +2 -2
  167. package/dist/harness-adapters.d.ts +5 -4
  168. package/dist/harness-adapters.js +5 -4
  169. package/dist/harness-adapters.js.map +1 -1
  170. package/dist/middleware/approval-gate.d.ts +6 -0
  171. package/dist/middleware/approval-gate.js +7 -57
  172. package/dist/middleware/approval-gate.js.map +1 -1
  173. package/dist/middleware/cost-advisory.d.ts +3 -3
  174. package/dist/middleware/cost-advisory.js +3 -3
  175. package/dist/middleware/index.d.ts +1 -1
  176. package/dist/middleware/index.js +1 -1
  177. package/dist/runner-manager.js +1 -1
  178. package/dist/runner-manager.js.map +1 -1
  179. package/dist/shared/approval-policy.d.ts +53 -0
  180. package/dist/shared/approval-policy.js +76 -0
  181. package/dist/shared/approval-policy.js.map +1 -1
  182. package/dist/shared/args-preview.d.ts +45 -22
  183. package/dist/shared/args-preview.js +51 -41
  184. package/dist/shared/args-preview.js.map +1 -1
  185. package/dist/shared/attachment-resolver.d.ts +4 -4
  186. package/dist/shared/attachment-resolver.js +4 -4
  187. package/dist/shared/attachment-vision.d.ts +2 -1
  188. package/dist/shared/attachment-vision.js.map +1 -1
  189. package/dist/shared/attachment-zip.d.ts +2 -2
  190. package/dist/shared/attachment-zip.js +2 -2
  191. package/dist/shared/cost-guard.d.ts +2 -2
  192. package/dist/shared/cost-guard.js +2 -2
  193. package/dist/shared/exact-apply.d.ts +1 -1
  194. package/dist/shared/exact-apply.js +1 -1
  195. package/dist/shared/execution-context.d.ts +2 -2
  196. package/dist/shared/execution-context.js +2 -2
  197. package/dist/shared/extract-structured-output.d.ts +2 -2
  198. package/dist/shared/extract-structured-output.js +2 -2
  199. package/dist/shared/filereview/cas-touched.d.ts +2 -2
  200. package/dist/shared/filereview/cas-touched.js +2 -2
  201. package/dist/shared/heartbeat.d.ts +1 -1
  202. package/dist/shared/heartbeat.js +1 -1
  203. package/dist/shared/llm-backend.d.ts +0 -4
  204. package/dist/shared/llm-backend.js +0 -4
  205. package/dist/shared/llm-backend.js.map +1 -1
  206. package/dist/shared/model-error.d.ts +1 -2
  207. package/dist/shared/model-error.js +1 -2
  208. package/dist/shared/model-error.js.map +1 -1
  209. package/dist/shared/persist-decision.d.ts +18 -24
  210. package/dist/shared/persist-decision.js +19 -11
  211. package/dist/shared/persist-decision.js.map +1 -1
  212. package/dist/shared/prompt-sections.d.ts +4 -4
  213. package/dist/shared/prompt-sections.js +4 -4
  214. package/dist/shared/skill-resolver.d.ts +3 -3
  215. package/dist/shared/skill-resolver.js +3 -3
  216. package/dist/shared/status-offload.d.ts +1 -1
  217. package/dist/shared/status-offload.js +2 -2
  218. package/dist/shared/status-offload.js.map +1 -1
  219. package/dist/shared/streaming-scheduler.d.ts +2 -7
  220. package/dist/shared/streaming-scheduler.js +6 -14
  221. package/dist/shared/streaming-scheduler.js.map +1 -1
  222. package/dist/shared/subagent-rows.d.ts +2 -2
  223. package/dist/shared/subagent-rows.js +2 -2
  224. package/dist/shared/todos.d.ts +3 -3
  225. package/dist/shared/todos.js +3 -3
  226. package/dist/shared/tool-row.d.ts +19 -1
  227. package/dist/shared/tool-row.js +36 -2
  228. package/dist/shared/tool-row.js.map +1 -1
  229. package/dist/shared/worker-shutdown.d.ts +1 -1
  230. package/dist/shared/worker-shutdown.js +1 -1
  231. package/dist/shared/workspace/session-provision.d.ts +1 -1
  232. package/dist/shared/workspace/session-provision.js +1 -1
  233. package/dist/shared/workspace/sources/empty.d.ts +1 -1
  234. package/dist/shared/workspace/sources/empty.js +1 -2
  235. package/dist/shared/workspace/sources/empty.js.map +1 -1
  236. package/dist/shared/workspace/sources/git.js +4 -4
  237. package/dist/shared/workspace/sources/git.js.map +1 -1
  238. package/dist/shared/workspace/sources/local-path.js +6 -6
  239. package/dist/shared/workspace/sources/local-path.js.map +1 -1
  240. package/dist/shared/workspace/stigmer-link.d.ts +1 -1
  241. package/dist/shared/workspace/stigmer-link.js +1 -1
  242. package/dist/shared/workspace/types.d.ts +2 -5
  243. package/dist/shared/workspace/types.js +0 -6
  244. package/dist/shared/workspace/types.js.map +1 -1
  245. package/dist/shared/workspace/writeback-coordinator.d.ts +17 -4
  246. package/dist/shared/workspace/writeback-coordinator.js +7 -9
  247. package/dist/shared/workspace/writeback-coordinator.js.map +1 -1
  248. package/package.json +5 -5
  249. package/src/__test-utils__/__tests__/execution-record-barrier.test.ts +70 -0
  250. package/src/__test-utils__/__tests__/harness-contract-self-check.test.ts +35 -1
  251. package/src/__test-utils__/approval-contract/contract.ts +1 -1
  252. package/src/__test-utils__/approval-contract/types.ts +1 -1
  253. package/src/__test-utils__/harness-boot-order-child.ts +1 -1
  254. package/src/__test-utils__/harness-contract/contract.ts +8 -8
  255. package/src/__test-utils__/harness-contract/recording-sink.ts +11 -1
  256. package/src/__test-utils__/harness-contract/runtime-contract.ts +52 -16
  257. package/src/__test-utils__/harness-contract/scripted-adapter.ts +47 -43
  258. package/src/__test-utils__/hermetic-activity.ts +113 -9
  259. package/src/__test-utils__/model-registry-fixture.ts +31 -7
  260. package/src/__test-utils__/module-specifiers.ts +32 -3
  261. package/src/__tests__/harness-boot-order.test.ts +1 -1
  262. package/src/__tests__/harness-contract.test.ts +1 -1
  263. package/src/__tests__/runner-manager.test.ts +1 -1
  264. package/src/activities/execute-cursor/__test-utils__/__tests__/scripted-double.test.ts +32 -8
  265. package/src/activities/execute-cursor/__test-utils__/contract-subject.ts +12 -10
  266. package/src/activities/execute-cursor/__test-utils__/fold.ts +116 -0
  267. package/src/activities/execute-cursor/__test-utils__/gateway-substrate.ts +1 -1
  268. package/src/activities/execute-cursor/__test-utils__/hermetic-cursor.ts +72 -19
  269. package/src/activities/execute-cursor/__test-utils__/scripted-agent.ts +35 -29
  270. package/src/activities/execute-cursor/__test-utils__/scripted-sdk.ts +94 -38
  271. package/src/activities/execute-cursor/__tests__/approval-gate.test.ts +2 -1
  272. package/src/activities/execute-cursor/__tests__/approval-state.test.ts +14 -21
  273. package/src/activities/execute-cursor/__tests__/build-prompt.test.ts +3 -3
  274. package/src/activities/execute-cursor/__tests__/coarse-fingerprint.test.ts +2 -1
  275. package/src/activities/execute-cursor/__tests__/cursor-baseurl-routing.test.ts +10 -8
  276. package/src/activities/execute-cursor/__tests__/cursor-event-recorder.test.ts +142 -0
  277. package/src/activities/execute-cursor/__tests__/cursor-fetch-interceptor-bypass.test.ts +24 -12
  278. package/src/activities/execute-cursor/__tests__/cursor-generate-image-live.test.ts +7 -2
  279. package/src/activities/execute-cursor/__tests__/cursor-hook-protocol-live.test.ts +163 -0
  280. package/src/activities/execute-cursor/__tests__/cursor-sdk-auth-smoke.test.ts +23 -20
  281. package/src/activities/execute-cursor/__tests__/cursor-transcript-live.test.ts +298 -0
  282. package/src/activities/execute-cursor/__tests__/deny-gate-exact-apply.test.ts +4 -2
  283. package/src/activities/execute-cursor/__tests__/fetch-interceptor.test.ts +1 -1
  284. package/src/activities/execute-cursor/__tests__/hermetic/deny-and-retry.test.ts +5 -2
  285. package/src/activities/execute-cursor/__tests__/hermetic/file-review-capture.test.ts +5 -2
  286. package/src/activities/execute-cursor/__tests__/hermetic/goldens/mcp-tool-call.status.json +71 -0
  287. package/src/activities/execute-cursor/__tests__/hermetic/goldens/sdk-task-note.status.json +73 -0
  288. package/src/activities/execute-cursor/__tests__/hermetic/goldens/shell-output-delta.error-delta.status.json +78 -0
  289. package/src/activities/execute-cursor/__tests__/hermetic/goldens/shell-output-delta.output-first.status.json +72 -0
  290. package/src/activities/execute-cursor/__tests__/hermetic/goldens/shell-output-delta.status.json +72 -0
  291. package/src/activities/execute-cursor/__tests__/hermetic/goldens/sub-agent-delegation.status.json +109 -0
  292. package/src/activities/execute-cursor/__tests__/hermetic/goldens/thinking-turn.status.json +78 -0
  293. package/src/activities/execute-cursor/__tests__/hermetic/goldens/todo-write.status.json +119 -0
  294. package/src/activities/execute-cursor/__tests__/hermetic/goldens/tool-error.status.json +68 -0
  295. package/src/activities/execute-cursor/__tests__/hermetic/goldens/tool-only-step.status.json +67 -0
  296. package/src/activities/execute-cursor/__tests__/hermetic/goldens/unattributed-hook-block.status.json +1 -1
  297. package/src/activities/execute-cursor/__tests__/hermetic/harness-contract.test.ts +10 -7
  298. package/src/activities/execute-cursor/__tests__/hermetic/mcp-tool-call.test.ts +146 -0
  299. package/src/activities/execute-cursor/__tests__/hermetic/pause-vs-shutdown.test.ts +8 -5
  300. package/src/activities/execute-cursor/__tests__/hermetic/plain-turn.test.ts +6 -2
  301. package/src/activities/execute-cursor/__tests__/hermetic/recovery-fresh-agent.test.ts +4 -1
  302. package/src/activities/execute-cursor/__tests__/hermetic/run-wait-arms.test.ts +6 -2
  303. package/src/activities/execute-cursor/__tests__/hermetic/sdk-task-note.test.ts +122 -0
  304. package/src/activities/execute-cursor/__tests__/hermetic/shell-output-delta.test.ts +276 -0
  305. package/src/activities/execute-cursor/__tests__/hermetic/stream-self-stop-arms.test.ts +12 -9
  306. package/src/activities/execute-cursor/__tests__/hermetic/sub-agent-delegation.test.ts +196 -0
  307. package/src/activities/execute-cursor/__tests__/hermetic/thinking-turn.test.ts +145 -0
  308. package/src/activities/execute-cursor/__tests__/hermetic/thrown-error-arms.test.ts +4 -1
  309. package/src/activities/execute-cursor/__tests__/hermetic/todo-write.test.ts +165 -0
  310. package/src/activities/execute-cursor/__tests__/hermetic/tool-call.test.ts +7 -4
  311. package/src/activities/execute-cursor/__tests__/hermetic/tool-error.test.ts +138 -0
  312. package/src/activities/execute-cursor/__tests__/hermetic/tool-only-step.test.ts +130 -0
  313. package/src/activities/execute-cursor/__tests__/hermetic/unattributed-hook-block.test.ts +17 -2
  314. package/src/activities/execute-cursor/__tests__/hermetic/workspace-lock-timeout.test.ts +5 -2
  315. package/src/activities/execute-cursor/__tests__/hitl-ledger.test.ts +43 -60
  316. package/src/activities/execute-cursor/__tests__/hitl-resume-history.test.ts +23 -28
  317. package/src/activities/execute-cursor/__tests__/hook-script.test.ts +2 -1
  318. package/src/activities/execute-cursor/__tests__/http2-interceptor.test.ts +1 -1
  319. package/src/activities/execute-cursor/__tests__/prompt-goldens.test.ts +5 -5
  320. package/src/activities/execute-cursor/__tests__/same-identity-reproposal.test.ts +11 -13
  321. package/src/activities/execute-cursor/__tests__/sequential-gate-resume.test.ts +8 -11
  322. package/src/activities/execute-cursor/__tests__/session-lifecycle.test.ts +86 -58
  323. package/src/activities/execute-cursor/__tests__/session-store.test.ts +220 -0
  324. package/src/activities/execute-cursor/__tests__/tool-result-image.test.ts +8 -22
  325. package/src/activities/execute-cursor/__tests__/translator.test.ts +594 -0
  326. package/src/activities/execute-cursor/__tests__/turn-boundary.test.ts +8 -5
  327. package/src/activities/execute-cursor/__tests__/turn-stream.test.ts +87 -63
  328. package/src/activities/execute-cursor/adapter.ts +13 -9
  329. package/src/activities/execute-cursor/approval-policy.ts +12 -24
  330. package/src/activities/execute-cursor/approval-state.ts +66 -1
  331. package/src/activities/execute-cursor/boundary-rows.ts +1132 -0
  332. package/src/activities/execute-cursor/cursor-capabilities.ts +1 -1
  333. package/src/activities/execute-cursor/cursor-event-recorder.ts +57 -28
  334. package/src/activities/execute-cursor/fetch-interceptor.ts +1 -1
  335. package/src/activities/execute-cursor/http2-interceptor.ts +1 -1
  336. package/src/activities/execute-cursor/prompt-builder.ts +6 -6
  337. package/src/activities/execute-cursor/sdk-warmup.ts +15 -6
  338. package/src/activities/execute-cursor/service-tier.ts +1 -2
  339. package/src/activities/execute-cursor/session-lifecycle.ts +63 -109
  340. package/src/activities/execute-cursor/session-store.ts +187 -0
  341. package/src/activities/execute-cursor/sub-agent-steps.ts +188 -0
  342. package/src/activities/execute-cursor/tool-result.ts +128 -0
  343. package/src/activities/execute-cursor/translator.ts +541 -0
  344. package/src/activities/execute-cursor/turn-boundary.ts +21 -14
  345. package/src/activities/execute-cursor/turn-settle.ts +46 -34
  346. package/src/activities/execute-cursor/turn-setup.ts +5 -5
  347. package/src/activities/execute-cursor/turn-stream.ts +49 -46
  348. package/src/activities/execute-cursor/turn.ts +5 -5
  349. package/src/activities/execute-cursor/usage-pricing.ts +2 -2
  350. package/src/activities/execute-deep-agent/__test-utils__/contract-subject.ts +2 -2
  351. package/src/activities/execute-deep-agent/__test-utils__/hermetic-deep-agent.ts +23 -11
  352. package/src/activities/execute-deep-agent/__test-utils__/hitl-script.ts +1 -1
  353. package/src/activities/execute-deep-agent/__test-utils__/scripted-model-module.ts +2 -3
  354. package/src/activities/execute-deep-agent/__test-utils__/scripted-model.ts +25 -4
  355. package/src/activities/execute-deep-agent/__test-utils__/v3-event-fixtures.ts +25 -11
  356. package/src/activities/execute-deep-agent/__tests__/adapter-graph-is-sdk-free.test.ts +1 -1
  357. package/src/activities/execute-deep-agent/__tests__/adapter-is-temporal-free.test.ts +1 -1
  358. package/src/activities/execute-deep-agent/__tests__/approval-file-change.test.ts +6 -17
  359. package/src/activities/execute-deep-agent/__tests__/hermetic/file-review-capture.test.ts +25 -8
  360. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/approve-all-lease.turn1.status.json +2 -7
  361. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/approve-all-lease.turn2.status.json +4 -14
  362. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/approve.turn2.status.json +1 -5
  363. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/file-review-capture.status.json +4 -7
  364. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/gate.turn1.status.json +1 -5
  365. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/inline-artifact.turn1.status.json +2 -9
  366. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/inline-artifact.turn2.status.json +2 -9
  367. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/pause.loop.after-tool.status.json +1 -4
  368. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/pause.loop.mid-tool.status.json +1 -4
  369. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/platform-stop.status.json +1 -4
  370. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/recursion-limit.persisted.status.json +109 -76
  371. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/reject.turn2.status.json +1 -5
  372. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/sequential-gates.turn2.status.json +2 -10
  373. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/sequential-gates.turn3.status.json +2 -10
  374. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/skip.turn2.status.json +1 -5
  375. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/sub-agent-delegation.status.json +3 -6
  376. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/tool-call.status.json +1 -4
  377. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/worker-shutdown.status.json +1 -4
  378. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/write-todos.status.json +92 -0
  379. package/src/activities/execute-deep-agent/__tests__/hermetic/harness-contract.test.ts +3 -3
  380. package/src/activities/execute-deep-agent/__tests__/hermetic/hitl-approve-all-lease.test.ts +9 -5
  381. package/src/activities/execute-deep-agent/__tests__/hermetic/hitl-round-trips.test.ts +3 -3
  382. package/src/activities/execute-deep-agent/__tests__/hermetic/hitl-sequential-gates.test.ts +3 -3
  383. package/src/activities/execute-deep-agent/__tests__/hermetic/inline-artifact-across-gate.test.ts +7 -6
  384. package/src/activities/execute-deep-agent/__tests__/hermetic/pause-vs-shutdown.test.ts +10 -11
  385. package/src/activities/execute-deep-agent/__tests__/hermetic/plain-turn.test.ts +4 -4
  386. package/src/activities/execute-deep-agent/__tests__/hermetic/platform-stop.test.ts +9 -8
  387. package/src/activities/execute-deep-agent/__tests__/hermetic/recursion-limit.test.ts +21 -13
  388. package/src/activities/execute-deep-agent/__tests__/hermetic/resolution-error.test.ts +2 -2
  389. package/src/activities/execute-deep-agent/__tests__/hermetic/structured-output.test.ts +7 -7
  390. package/src/activities/execute-deep-agent/__tests__/hermetic/sub-agent-delegation.test.ts +28 -12
  391. package/src/activities/execute-deep-agent/__tests__/hermetic/tool-call.test.ts +21 -21
  392. package/src/activities/execute-deep-agent/__tests__/hermetic/workspace-lock-timeout.test.ts +5 -5
  393. package/src/activities/execute-deep-agent/__tests__/hermetic/write-todos.test.ts +160 -0
  394. package/src/activities/execute-deep-agent/__tests__/inline-publisher.test.ts +35 -30
  395. package/src/activities/execute-deep-agent/__tests__/prompt-builder.test.ts +3 -4
  396. package/src/activities/execute-deep-agent/__tests__/prompt-goldens.test.ts +12 -10
  397. package/src/activities/execute-deep-agent/__tests__/scripted-model.test.ts +13 -3
  398. package/src/activities/execute-deep-agent/__tests__/streaming-side-effects.test.ts +26 -18
  399. package/src/activities/execute-deep-agent/__tests__/subagent-wiring.test.ts +1 -1
  400. package/src/activities/execute-deep-agent/__tests__/{subagent-tracker.test.ts → translator-subagents.test.ts} +76 -57
  401. package/src/activities/execute-deep-agent/__tests__/{v3-status-builder.test.ts → translator-through-builder.test.ts} +213 -299
  402. package/src/activities/execute-deep-agent/__tests__/translator.test.ts +505 -0
  403. package/src/activities/execute-deep-agent/__tests__/turn-stream.test.ts +11 -29
  404. package/src/activities/execute-deep-agent/adapter.ts +1 -1
  405. package/src/activities/execute-deep-agent/approval-file-change.ts +20 -22
  406. package/src/activities/execute-deep-agent/deep-agent-capabilities.ts +2 -2
  407. package/src/activities/execute-deep-agent/hitl.ts +2 -2
  408. package/src/activities/execute-deep-agent/inline-publisher.ts +16 -5
  409. package/src/activities/execute-deep-agent/prompt-builder.ts +6 -7
  410. package/src/activities/execute-deep-agent/streaming-side-effects.ts +22 -31
  411. package/src/activities/execute-deep-agent/subagent-transformer.ts +3 -3
  412. package/src/activities/execute-deep-agent/translator.ts +463 -0
  413. package/src/activities/execute-deep-agent/turn-settle.ts +35 -43
  414. package/src/activities/execute-deep-agent/turn-setup.ts +8 -8
  415. package/src/activities/execute-deep-agent/turn-stream.ts +53 -51
  416. package/src/activities/execute-deep-agent/turn.ts +3 -3
  417. package/src/config.ts +2 -2
  418. package/src/harness/README.md +335 -0
  419. package/src/harness/__tests__/approval-decisions.test.ts +2 -2
  420. package/src/harness/__tests__/capture.test.ts +3 -3
  421. package/src/harness/__tests__/import-direction.test.ts +3 -2
  422. package/src/harness/__tests__/mount-skills.test.ts +4 -1
  423. package/src/harness/__tests__/readme-index.test.ts +339 -0
  424. package/src/harness/__tests__/run-turn.test.ts +131 -6
  425. package/src/harness/__tests__/transcript-is-engine-free.test.ts +83 -0
  426. package/src/harness/__tests__/transcript-writers.test.ts +191 -0
  427. package/src/harness/__tests__/turn-attachments-vision.test.ts +5 -2
  428. package/src/harness/__tests__/turn-context.test.ts +5 -5
  429. package/src/harness/approval-decisions.ts +1 -1
  430. package/src/harness/capabilities.ts +21 -11
  431. package/src/harness/capture.ts +4 -4
  432. package/src/harness/persist-chokepoint.ts +3 -3
  433. package/src/harness/registry.ts +2 -2
  434. package/src/harness/run-turn.ts +33 -9
  435. package/src/harness/stop-controller.ts +1 -1
  436. package/src/harness/terminal-table.ts +7 -7
  437. package/src/harness/transcript/__tests__/builder.test.ts +975 -0
  438. package/src/harness/transcript/__tests__/state.test.ts +143 -0
  439. package/src/harness/transcript/builder.ts +755 -0
  440. package/src/harness/transcript/events.ts +262 -0
  441. package/src/harness/transcript/state.ts +167 -0
  442. package/src/harness/turn-context.ts +61 -46
  443. package/src/harness/types.ts +64 -22
  444. package/src/harness/usage-accumulator.ts +2 -2
  445. package/src/harness-adapters.ts +5 -4
  446. package/src/middleware/__tests__/cost-advisory.test.ts +2 -2
  447. package/src/middleware/approval-gate.ts +7 -74
  448. package/src/middleware/cost-advisory.ts +3 -3
  449. package/src/middleware/index.ts +1 -1
  450. package/src/runner-manager.ts +1 -1
  451. package/src/shared/__tests__/approval-policy.test.ts +45 -0
  452. package/src/shared/__tests__/args-preview.test.ts +40 -20
  453. package/src/shared/__tests__/attachment-naming.test.ts +1 -1
  454. package/src/shared/__tests__/attachment-resolver.test.ts +5 -5
  455. package/src/shared/__tests__/attachment-zip.test.ts +1 -1
  456. package/src/shared/__tests__/blueprint-resolver.test.ts +1 -1
  457. package/src/shared/__tests__/cost-guard.test.ts +1 -1
  458. package/src/shared/__tests__/exact-apply.test.ts +2 -1
  459. package/src/shared/__tests__/persist-decision.test.ts +19 -33
  460. package/src/shared/__tests__/prompt-sections.test.ts +1 -1
  461. package/src/shared/__tests__/stamp-flowed-rows.test.ts +1 -1
  462. package/src/shared/__tests__/status-offload.test.ts +1 -1
  463. package/src/shared/__tests__/streaming-scheduler.test.ts +8 -9
  464. package/src/shared/__tests__/todos.test.ts +1 -1
  465. package/src/shared/__tests__/tool-row.test.ts +1 -1
  466. package/src/shared/approval-policy.ts +95 -0
  467. package/src/shared/args-preview.ts +51 -42
  468. package/src/shared/attachment-resolver.ts +4 -4
  469. package/src/shared/attachment-vision.ts +2 -1
  470. package/src/shared/attachment-zip.ts +2 -2
  471. package/src/shared/cost-guard.ts +2 -2
  472. package/src/shared/exact-apply.ts +1 -1
  473. package/src/shared/execution-context.ts +2 -2
  474. package/src/shared/extract-structured-output.ts +2 -2
  475. package/src/shared/filereview/__tests__/capture.test.ts +9 -5
  476. package/src/shared/filereview/__tests__/git-substrate.test.ts +4 -1
  477. package/src/shared/filereview/__tests__/proxy-reconcile.test.ts +3 -3
  478. package/src/shared/filereview/cas-touched.ts +2 -2
  479. package/src/shared/heartbeat.ts +1 -1
  480. package/src/shared/llm-backend.ts +0 -4
  481. package/src/shared/model-error.ts +1 -2
  482. package/src/shared/persist-decision.ts +19 -28
  483. package/src/shared/prompt-sections.ts +4 -4
  484. package/src/shared/skill-resolver.ts +3 -3
  485. package/src/shared/status-offload.ts +2 -2
  486. package/src/shared/streaming-scheduler.ts +8 -13
  487. package/src/shared/subagent-rows.ts +2 -2
  488. package/src/shared/todos.ts +3 -3
  489. package/src/shared/tool-row.ts +38 -2
  490. package/src/shared/worker-shutdown.ts +1 -1
  491. package/src/shared/workspace/__tests__/git-source.test.ts +3 -3
  492. package/src/shared/workspace/__tests__/provisioner.test.ts +5 -5
  493. package/src/shared/workspace/__tests__/session-provision.test.ts +2 -2
  494. package/src/shared/workspace/__tests__/writeback-coordinator.integration.test.ts +8 -9
  495. package/src/shared/workspace/__tests__/writeback-coordinator.test.ts +25 -25
  496. package/src/shared/workspace/provisioner.ts +1 -1
  497. package/src/shared/workspace/session-provision.ts +1 -1
  498. package/src/shared/workspace/sources/empty.ts +2 -2
  499. package/src/shared/workspace/sources/git.ts +3 -4
  500. package/src/shared/workspace/sources/local-path.ts +5 -6
  501. package/src/shared/workspace/stigmer-link.ts +1 -1
  502. package/src/shared/workspace/types.ts +2 -5
  503. package/src/shared/workspace/writeback-coordinator.ts +23 -12
  504. package/dist/activities/execute-cursor/delta-enricher.d.ts +0 -87
  505. package/dist/activities/execute-cursor/delta-enricher.js +0 -265
  506. package/dist/activities/execute-cursor/delta-enricher.js.map +0 -1
  507. package/dist/activities/execute-cursor/message-translator.js +0 -2040
  508. package/dist/activities/execute-cursor/message-translator.js.map +0 -1
  509. package/dist/activities/execute-cursor/todo-tracker.d.ts +0 -40
  510. package/dist/activities/execute-cursor/todo-tracker.js +0 -80
  511. package/dist/activities/execute-cursor/todo-tracker.js.map +0 -1
  512. package/dist/activities/execute-deep-agent/execution-state.d.ts +0 -54
  513. package/dist/activities/execute-deep-agent/execution-state.js +0 -68
  514. package/dist/activities/execute-deep-agent/execution-state.js.map +0 -1
  515. package/dist/activities/execute-deep-agent/status-builder-shared.d.ts +0 -65
  516. package/dist/activities/execute-deep-agent/status-builder-shared.js +0 -90
  517. package/dist/activities/execute-deep-agent/status-builder-shared.js.map +0 -1
  518. package/dist/activities/execute-deep-agent/subagent-tracker.d.ts +0 -113
  519. package/dist/activities/execute-deep-agent/subagent-tracker.js +0 -400
  520. package/dist/activities/execute-deep-agent/subagent-tracker.js.map +0 -1
  521. package/dist/activities/execute-deep-agent/v3-events.d.ts +0 -102
  522. package/dist/activities/execute-deep-agent/v3-events.js +0 -35
  523. package/dist/activities/execute-deep-agent/v3-events.js.map +0 -1
  524. package/dist/activities/execute-deep-agent/v3-protocol-normalizer.d.ts +0 -15
  525. package/dist/activities/execute-deep-agent/v3-protocol-normalizer.js +0 -235
  526. package/dist/activities/execute-deep-agent/v3-protocol-normalizer.js.map +0 -1
  527. package/dist/activities/execute-deep-agent/v3-status-builder.d.ts +0 -111
  528. package/dist/activities/execute-deep-agent/v3-status-builder.js +0 -457
  529. package/dist/activities/execute-deep-agent/v3-status-builder.js.map +0 -1
  530. package/dist/shared/execution-status-writer.d.ts +0 -31
  531. package/dist/shared/execution-status-writer.js +0 -43
  532. package/dist/shared/execution-status-writer.js.map +0 -1
  533. package/src/activities/execute-cursor/__tests__/delta-enricher.test.ts +0 -310
  534. package/src/activities/execute-cursor/__tests__/message-translator.test.ts +0 -1033
  535. package/src/activities/execute-cursor/__tests__/todo-tracker.test.ts +0 -498
  536. package/src/activities/execute-cursor/delta-enricher.ts +0 -307
  537. package/src/activities/execute-cursor/message-translator.ts +0 -2319
  538. package/src/activities/execute-cursor/todo-tracker.ts +0 -91
  539. package/src/activities/execute-deep-agent/__tests__/execution-state-extended.test.ts +0 -148
  540. package/src/activities/execute-deep-agent/__tests__/execution-state.test.ts +0 -154
  541. package/src/activities/execute-deep-agent/__tests__/status-builder-shared.test.ts +0 -47
  542. package/src/activities/execute-deep-agent/__tests__/v3-protocol-normalizer.test.ts +0 -324
  543. package/src/activities/execute-deep-agent/execution-state.ts +0 -78
  544. package/src/activities/execute-deep-agent/status-builder-shared.ts +0 -142
  545. package/src/activities/execute-deep-agent/subagent-tracker.ts +0 -479
  546. package/src/activities/execute-deep-agent/v3-events.ts +0 -153
  547. package/src/activities/execute-deep-agent/v3-protocol-normalizer.ts +0 -264
  548. package/src/activities/execute-deep-agent/v3-status-builder.ts +0 -565
  549. package/src/shared/execution-status-writer.ts +0 -56
@@ -9,7 +9,7 @@
9
9
  * runtime's stall watchdog measures the engine; `reportUsage()` per parent
10
10
  * `message_finish`, priced here at the registry's rates for the model the
11
11
  * turn runs on (`shared/model-pricing.ts`), so the runtime accounts and
12
- * enforces the cost cap and writes `streamingUsage` (Q-M2a-2); `requestPersist()`
12
+ * enforces the cost cap and writes `streamingUsage`; `requestPersist()`
13
13
  * where a discrete change or the streaming cadence says so
14
14
  * (`shared/persist-decision.ts` over the builder's one dirty flag), AWAITED,
15
15
  * so a platform STOP the runtime reads from that write aborts the signal
@@ -19,7 +19,7 @@
19
19
  * this loop never does). An error the aborted run throws is the abort itself
20
20
  * and settles `interrupted`, never `failed`.
21
21
  *
22
- * WHEN the run is aborted (S3 M2a, F-M2a-18): on the arrival of the next
22
+ * WHEN the run is aborted: on the arrival of the next
23
23
  * event — the graph's own step boundary — or after {@link STOP_GRACE_MS} if
24
24
  * no event arrives. A LangGraph run aborted while a step is in flight leaves
25
25
  * `@langchain/core` with an orphaned rejection (`AsyncGeneratorWithSetup`
@@ -34,7 +34,7 @@
34
34
  * here) is forced, and that one orphan is the price of unblocking it — the
35
35
  * contract's bound on settling `interrupted` is what wins.
36
36
  *
37
- * Until S3 M2a this loop (`streaming-v3.ts`) armed its own 120 s stall
37
+ * Until #1096 this loop (`streaming-v3.ts`) armed its own 120 s stall
38
38
  * check, pulsed the Temporal heartbeat every 2 s, read STOP from its own
39
39
  * persist and activated a graceful-stop middleware on it, told a pause from
40
40
  * the activity's cancellation signal, and wrote PAUSED, COMPLETED and
@@ -53,8 +53,7 @@ import { TimeoutError, withTimeout } from "../../shared/with-timeout.js";
53
53
  import { InlinePublisher } from "./inline-publisher.js";
54
54
  import { StreamingSideEffects } from "./streaming-side-effects.js";
55
55
  import { createV3EventRecorder, type V3ProtocolEvent } from "./v3-event-recorder.js";
56
- import { normalize } from "./v3-protocol-normalizer.js";
57
- import { V3StatusBuilder } from "./v3-status-builder.js";
56
+ import { DeepAgentTranslator, usageOf, type V3UsagePayload } from "./translator.js";
58
57
  import type { DeepAgentEngine, DeepAgentGraphInput, DeepAgentWorkspace } from "./turn-setup.js";
59
58
 
60
59
  /**
@@ -95,14 +94,17 @@ export interface DeepAgentStreamResult {
95
94
  }
96
95
 
97
96
  /**
98
- * The transcript writers of one turn: the builder over `sink.status` and the
99
- * publisher that writes artifacts through it (so a published artifact still
100
- * forces the next persist). Built by the adapter's turn once and shared by
101
- * the stream and the settle; the builder reports usage into the sink, priced
102
- * for the model the turn runs on.
97
+ * This harness's transcript writers for one turn: the translator that turns
98
+ * the engine's events into canonical ones (over the gate's posture, so every
99
+ * tool start carries its attribution and gate answer), and the publisher
100
+ * that registers artifacts on the runtime's builder (`sink.transcript`, so
101
+ * a published artifact still dirties the next persist). The builder itself
102
+ * is the runtime's, one per turn, and is read from the sink where it is
103
+ * needed. Built by the adapter's turn once and shared by the stream and the
104
+ * settle.
103
105
  */
104
106
  export interface DeepAgentTranscript {
105
- readonly builder: V3StatusBuilder;
107
+ readonly translator: DeepAgentTranslator;
106
108
  readonly publisher: InlinePublisher;
107
109
  }
108
110
 
@@ -112,41 +114,40 @@ export function createDeepAgentTranscript(
112
114
  engine: DeepAgentEngine,
113
115
  workspace: DeepAgentWorkspace,
114
116
  ): DeepAgentTranscript {
115
- const builder = new V3StatusBuilder(input.executionId, sink.status, {
116
- onUsage: (usage) => {
117
- // LangChain's `input_tokens` already INCLUDES the cache buckets (the
118
- // Anthropic adapter folds them in; the cost advisory reads them the
119
- // same way), so the counts are reported as delivered and the price
120
- // is computed over the disjoint buckets.
121
- const inputTokens = usage.input_tokens ?? 0;
122
- const outputTokens = usage.output_tokens ?? 0;
123
- const cacheReadTokens = usage.input_token_details?.cache_read ?? 0;
124
- const cacheWriteTokens = usage.input_token_details?.cache_creation ?? 0;
125
- const uncachedInput = Math.max(inputTokens - cacheReadTokens - cacheWriteTokens, 0);
126
- sink.reportUsage({
127
- inputTokens,
128
- outputTokens,
129
- cacheReadTokens,
130
- cacheWriteTokens,
131
- estimatedCostUsd: computeTurnCost(engine.pricing, uncachedInput, outputTokens, cacheWriteTokens, cacheReadTokens),
132
- model: engine.modelName,
133
- });
134
- },
135
- });
136
- builder.setApprovalProvider({
137
- policies: engine.gate.policies,
138
- toolServerMap: engine.gate.toolServerMap,
139
- leasedCategories: engine.gate.leasedCategories,
140
- globalBypass: engine.gate.globalBypass,
141
- unattended: engine.gate.unattended,
142
- });
117
+ const translator = new DeepAgentTranslator(engine.gate);
143
118
  const publisher = new InlinePublisher({
144
119
  workspaceBackend: workspace.backend,
145
120
  artifactStorage: input.artifactStorage,
146
- statusWriter: builder,
121
+ artifacts: sink.transcript,
147
122
  executionId: input.executionId,
148
123
  });
149
- return { builder, publisher };
124
+ return { translator, publisher };
125
+ }
126
+
127
+ /**
128
+ * Price one `message-finish`'s usage at the engine's rates and report it to
129
+ * the sink, which accounts, enforces the cost cap and writes `streamingUsage`
130
+ * (one writer of the summary). LangChain's `input_tokens` already INCLUDES the cache buckets
131
+ * (the Anthropic adapter folds them in; the cost advisory reads them the same
132
+ * way), so the counts are reported as delivered and the price is computed
133
+ * over the disjoint buckets. A sub-agent on its own model is priced at the
134
+ * parent's rate, as the in-graph cost cap always did (per-sub-agent pricing
135
+ * is #1121).
136
+ */
137
+ function reportUsage(sink: TurnSink, engine: DeepAgentEngine, usage: V3UsagePayload): void {
138
+ const inputTokens = usage.input_tokens ?? 0;
139
+ const outputTokens = usage.output_tokens ?? 0;
140
+ const cacheReadTokens = usage.input_token_details?.cache_read ?? 0;
141
+ const cacheWriteTokens = usage.input_token_details?.cache_creation ?? 0;
142
+ const uncachedInput = Math.max(inputTokens - cacheReadTokens - cacheWriteTokens, 0);
143
+ sink.reportUsage({
144
+ inputTokens,
145
+ outputTokens,
146
+ cacheReadTokens,
147
+ cacheWriteTokens,
148
+ estimatedCostUsd: computeTurnCost(engine.pricing, uncachedInput, outputTokens, cacheWriteTokens, cacheReadTokens),
149
+ model: engine.modelName,
150
+ });
150
151
  }
151
152
 
152
153
  export interface DeepAgentStreamDeps {
@@ -165,7 +166,8 @@ export interface DeepAgentStreamDeps {
165
166
  export async function consumeDeepAgentStream(deps: DeepAgentStreamDeps): Promise<DeepAgentStreamResult> {
166
167
  const { input, sink, engine, graphInput, transcript } = deps;
167
168
  const { executionId } = input;
168
- const { builder, publisher } = transcript;
169
+ const { translator, publisher } = transcript;
170
+ const builder = sink.transcript;
169
171
 
170
172
  const scheduler = new StreamingUpdateScheduler(loadStreamingConfig());
171
173
  const recorder = createV3EventRecorder(executionId, process.env.V3_EVENT_RECORD_DIR);
@@ -214,21 +216,21 @@ export async function consumeDeepAgentStream(deps: DeepAgentStreamDeps): Promise
214
216
 
215
217
  recorder?.record(event, eventsProcessed);
216
218
  let detail: string | undefined;
217
- for (const normalized of normalize(event)) {
218
- builder.processEvent(normalized);
219
+ for (const normalized of translator.translate(event)) {
220
+ builder.apply(normalized);
221
+ sideEffects.onEvent(normalized);
219
222
  if (normalized.kind === "tool_started") detail = normalized.name;
220
223
  }
221
- sideEffects.onProtocolEvent(event);
224
+ const usage = usageOf(event);
225
+ if (usage) reportUsage(sink, engine, usage);
222
226
  eventsProcessed++;
223
227
  sink.recordActivity(detail);
224
228
 
225
- const persist = shouldPersistStreamingStatus(
226
- { deltaEnricherDirty: false, todosDirty: false, contentDirty: builder.forceNextUpdate },
227
- scheduler,
228
- eventsProcessed,
229
- );
229
+ const persist = shouldPersistStreamingStatus(builder.dirty, scheduler, eventsProcessed);
230
230
  if (!persist) continue;
231
- builder.clearForceFlag();
231
+ // Cleared as the write is requested, not after it lands: a change
232
+ // that folds while the write is in flight must dirty the next one.
233
+ builder.markPersisted();
232
234
  // The runtime attaches the mid-run file-change progress on this write
233
235
  // (the chokepoint's step 2), as it does on every write. Awaited so a platform STOP the runtime reads from this write has
234
236
  // aborted the signal by the time the next event arrives — where the
@@ -24,7 +24,7 @@
24
24
  * other exception — a provider error unwrapped from LangChain's middleware
25
25
  * wrapper, an MCP connect failure, an empty stream — is `failed` on the
26
26
  * `internal` surface with `describeExecutionError`'s sentence as
27
- * `status.error` whole (Q-M2a-9). Never branches on why `stopSignal`
27
+ * `status.error` whole. Never branches on why `stopSignal`
28
28
  * aborted, never writes a phase or a terminal copy, never imports
29
29
  * `@temporalio/*` (`__tests__/adapter-is-temporal-free.test.ts`).
30
30
  *
@@ -33,9 +33,9 @@
33
33
  * are connected and closed per turn. Both are closed on EVERY exit path in
34
34
  * the `finally`, before the runtime removes the link and releases the lock.
35
35
  *
36
- * Extracted from `index.ts` `createDeepAgentActivities` at S3 M2a; the
36
+ * Extracted from `index.ts` `createDeepAgentActivities` in #1096; the
37
37
  * hermetic goldens under `__tests__/hermetic/` pin the result byte for
38
- * byte, with the ruled alignments quoted in their headers.
38
+ * byte, with that move's deliberate alignments quoted in their headers.
39
39
  */
40
40
 
41
41
  import type { BaseCheckpointSaver } from "@langchain/langgraph-checkpoint";
package/src/config.ts CHANGED
@@ -151,8 +151,8 @@ export interface Config {
151
151
  * provides the proxy credential and mints no other, so
152
152
  * `proxyTokenRef === stigmerTokenRef`), the manager binds the minted runner
153
153
  * token (`proxyTokenRef === stigmerRunnerTokenRef`). Reading either sibling
154
- * directly would send the wrong credential from one of the two roots
155
- * (Q-S2-7). Required whenever `proxyEndpoint` is set; the Cursor adapter's
154
+ * directly would send the wrong credential from one of the two roots.
155
+ * Required whenever `proxyEndpoint` is set; the Cursor adapter's
156
156
  * boot refuses a proxy without it.
157
157
  */
158
158
  readonly proxyTokenRef?: { current: string | null };
@@ -0,0 +1,335 @@
1
+ # harness/ — the turn runtime and the adapter contract
2
+
3
+ This folder is the turn runtime, the code that runs one agent turn for every
4
+ harness, and the contract a harness implements to run behind it
5
+ (`harness/types.ts`). A harness is one engine the runner can drive: today the
6
+ native LangGraph deep-agent and the Cursor SDK; the contract was designed
7
+ against the Claude Agent SDK and the Codex SDK as well
8
+ (`harness/capabilities.ts`). An adapter is the `HarnessAdapter` object a
9
+ harness's factory returns; a harness is that adapter plus its registry row.
10
+
11
+ This file is an index for someone adding a harness. To add one: read the modules
12
+ below in order, write the adapter files, touch the sites, prove it with the kit.
13
+ The rules this file follows are at the end.
14
+
15
+ ## One harness, six spellings
16
+
17
+ The harness identity is spelled differently in each layer, and every spelling is
18
+ pinned somewhere. Read a row across before searching for anything.
19
+
20
+ | Spelling | Native | Cursor |
21
+ | --------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------- | ---------------------------- |
22
+ | The adapter's folder | `activities/execute-deep-agent/` | `activities/execute-cursor/` |
23
+ | `HarnessName` in `harness/registry.ts` | `deep-agent` | `cursor` |
24
+ | The Temporal activity in `harness/registry.ts` | `ExecuteDeepAgent` | `ExecuteCursor` |
25
+ | The proto enum in `apis/ai/stigmer/agentic/session/v1/enum.proto` | `HARNESS_NATIVE` | `HARNESS_CURSOR` |
26
+ | The model registry's key in `backend/services/stigmer-server/src/domain/workflow/registry/data/model-registry.json` | `native` | `cursor` |
27
+ | The file-review id in `activities/execute-deep-agent/deep-agent-capabilities.ts` and `activities/execute-cursor/cursor-capabilities.ts` | `deep-agent` | `cursor` |
28
+ | The vendor SDK package in `backend/services/runner/package.json` | `deepagents` | `@cursor/sdk` |
29
+
30
+ ## Modules, in reading order
31
+
32
+ - `harness/types.ts` — the contract: `HarnessAdapter`, `TurnInput`, `TurnSink`,
33
+ `TurnOutcome`, and what was deliberately left off it.
34
+ - `harness/capabilities.ts` — the flags the runtime branches on instead of
35
+ harness names (`HarnessCapabilities`, `PausePrimitive`, `StateIdSource`), the
36
+ harness matrix the contract was designed against, and which values a real
37
+ adapter stands behind.
38
+ - `__test-utils__/harness-contract/scripted-adapter.ts` — the template: every
39
+ rule of the contract as the smallest code that obeys it, with the reason
40
+ beside it.
41
+ - `harness/registry.ts` — the wire vocabulary: `HarnessName`, the byte-pinned
42
+ `HARNESS_ACTIVITY_NAMES`, the boot order and how a boot failure is handled,
43
+ and `createHarnessActivities`.
44
+ - `harness-adapters.ts` — the one table of real rows (`HARNESS_ADAPTERS`), and
45
+ why its static graph must stay SDK-free.
46
+ - `harness/transcript/events.ts` — `TranscriptEvent`, the canonical event a
47
+ translator emits.
48
+ - `harness/transcript/builder.ts` — `TranscriptBuilder`, the one builder every
49
+ harness folds its events through.
50
+ - `harness/capture.ts` — the file-review capture. The runtime owns all of it; an
51
+ adapter supplies one fact, which CAS-owned paths its engine touched.
52
+ - `harness/turn-context.ts` — the resolution phases that build the `TurnInput`
53
+ (`resolveTurnContext`), and what is deliberately left to the adapter.
54
+ - `harness/run-turn.ts` — the activity body (`runTurnActivity`) and
55
+ `settleWith`, the one place a turn's terminal status is written.
56
+
57
+ ## Adapter files
58
+
59
+ What the contract requires:
60
+
61
+ - `activities/<harness>/adapter.ts` — a factory returning a `HarnessAdapter`.
62
+ `activities/execute-deep-agent/adapter.ts` (`createDeepAgentAdapter`) is the
63
+ smaller real shape, with no per-session state;
64
+ `activities/execute-cursor/adapter.ts` (`createCursorAdapter`) is the one with
65
+ session state.
66
+ - `activities/<harness>/<harness>-capabilities.ts` — the flags, declared once,
67
+ each with its reason:
68
+ `activities/execute-deep-agent/deep-agent-capabilities.ts`
69
+ (`DEEP_AGENT_CAPABILITIES`),
70
+ `activities/execute-cursor/cursor-capabilities.ts` (`CURSOR_CAPABILITIES`).
71
+ - `activities/<harness>/translator.ts` — the engine's events rendered as
72
+ `TranscriptEvent`s into `TranscriptBuilder` (`harness/transcript/events.ts` is
73
+ the union): `activities/execute-deep-agent/translator.ts`,
74
+ `activities/execute-cursor/translator.ts`.
75
+
76
+ Everything else in an adapter's folder is the engine's business and is not a
77
+ template: 17 of the native adapter's 20 modules and 32 of the Cursor adapter's
78
+ 35, at the commit the footprint below measures. That business is:
79
+
80
+ - how the engine is created or resumed,
81
+ - how the prompt is placed,
82
+ - how MCP servers are bound,
83
+ - how the engine is made to stop before a gated side effect.
84
+
85
+ What every adapter's test side carries:
86
+
87
+ - `activities/<harness>/__test-utils__/contract-subject.ts` — the harness as a
88
+ `HarnessContractSubject`: the real adapter, with the kit's scenario vocabulary
89
+ translated onto the harness's own SDK double.
90
+ `activities/execute-deep-agent/__test-utils__/contract-subject.ts` is the
91
+ smaller example;
92
+ `activities/execute-cursor/__test-utils__/contract-subject.ts` the first.
93
+ - `activities/<harness>/__tests__/hermetic/harness-contract.test.ts` — both
94
+ halves of the kit against the real adapter, with what the subject cannot
95
+ produce declared SKIPPED:
96
+ `activities/execute-deep-agent/__tests__/hermetic/harness-contract.test.ts`,
97
+ `activities/execute-cursor/__tests__/hermetic/harness-contract.test.ts`. Their
98
+ goldens: `activities/execute-deep-agent/__tests__/hermetic/goldens/`,
99
+ `activities/execute-cursor/__tests__/hermetic/goldens/`.
100
+ - `activities/<harness>/__tests__/adapter-is-temporal-free.test.ts` — the fence
101
+ that keeps `@temporalio/*` out of the adapter:
102
+ `activities/execute-deep-agent/__tests__/adapter-is-temporal-free.test.ts`,
103
+ `activities/execute-cursor/__tests__/adapter-is-temporal-free.test.ts`.
104
+ - `activities/<harness>/__tests__/adapter-graph-is-sdk-free.test.ts` — the fence
105
+ that walks the adapter module's static graph and refuses a vendor SDK on it. A
106
+ new harness adds it.
107
+ `activities/execute-deep-agent/__tests__/adapter-graph-is-sdk-free.test.ts` is
108
+ the shape; the Cursor adapter predates it, and
109
+ `__tests__/harness-boot-order.test.ts` proves its graph in a fresh process.
110
+
111
+ ## Sites a new harness touches
112
+
113
+ Measured at commit f25d15131 (2026-09-16). Every list in this section is dated
114
+ by that line.
115
+
116
+ ### In the runner
117
+
118
+ Read off the registry, its tests and the package, not off the probes below. The
119
+ composition roots, `runner.ts` and `runner-manager.ts`, read `HARNESS_ADAPTERS`
120
+ and nothing per harness; there is nothing to touch there.
121
+
122
+ - `harness-adapters.ts` — one row in `HARNESS_ADAPTERS`, in boot order.
123
+ - `harness/registry.ts` — one member of `HarnessName` and one entry in
124
+ `HARNESS_ACTIVITY_NAMES`, byte-identical to the server's pin.
125
+ - `harness/capabilities.ts` — the harness matrix in the header gains a column.
126
+ - `config.ts` — the harness's own settings, if it has any (`cursorApiKey`,
127
+ `checkpointerType` are the two adapters' today).
128
+ - `activities/call-agent.ts` — `resolveHarness`, the wire string to the proto
129
+ enum for the workflow task.
130
+ - `workflow-engine/loader.ts` — the YAML shorthand map from harness word to enum
131
+ name.
132
+ - `shared/filereview/events.ts` — a comment stating the closed set of
133
+ file-review ids.
134
+ - `__tests__/harness-boot-order.test.ts` — the header states the row count; its
135
+ child process, `__test-utils__/harness-boot-order-child.ts`, boots
136
+ `HARNESS_ADAPTERS` itself, so a new row runs with no code change.
137
+ - `backend/services/runner/package.json` — the vendor SDK dependency.
138
+ - `backend/services/runner/scripts/bundle-slim.mjs` — `RUNTIME_EXTERNALS`, the
139
+ SDKs the slim bundle leaves external because they ship native helpers.
140
+ - `backend/services/runner/README.md` — the environment-variable table names
141
+ each harness's settings.
142
+ - `backend/services/runner/Dockerfile.sandbox` — a comment listing the
143
+ activities the image serves.
144
+
145
+ ### Outside the runner: the method
146
+
147
+ The identity has six spellings (the table above); the folder is not searched
148
+ for, and each of the five probes below finds one of the others. Run all five
149
+ from the repository root and read every hit; the lists below came from doing
150
+ exactly that.
151
+
152
+ ```bash
153
+ # The same exclusions for every probe. __test-utils__/ stays in: the kit and the hermetic drivers enumerate harnesses.
154
+ X=(-g '!node_modules' -g '!**/gen/**' -g '!*_pb.*' -g '!*.pb.go' -g '!apis/stubs/**' -g '!tools/codegen/output/**'
155
+ -g '!**/dist/**' -g '!**/dist-slim/**' -g '!**/__tests__/**' -g '!*.test.*' -g '!**/goldens/**' -g '!*lock*')
156
+ rg -l "${X[@]}" 'HARNESS_NATIVE|HARNESS_CURSOR|Harness\.(NATIVE|CURSOR)|\bHarnessOption\b' # the proto enum
157
+ rg -l "${X[@]}" 'ExecuteDeepAgent|ExecuteCursor|HARNESS_ACTIVITY_NAMES' # the activity name
158
+ rg -l "${X[@]}" '\bHarnessName\b|["'"'"']deep-agent["'"'"']|["'"'"']cursor["'"'"']' # the registry name and file-review id
159
+ rg -l "${X[@]}" '"harness"\s*:\s*"(native|cursor)"' # the model registry's key
160
+ rg -l "${X[@]}" '@cursor/sdk|\bdeepagents\b' # the vendor SDK package
161
+ ```
162
+
163
+ Every hit falls into one of three classes:
164
+
165
+ - **Enumerates** — a switch, a record keyed by harness, a label table, a
166
+ byte-pinned name, a per-harness data row, or a comment that states the closed
167
+ set. A new harness must touch it.
168
+ - **Passes through** — reads, forwards or types by the value, or a fixture that
169
+ carries it. Nothing to touch.
170
+ - **Generated** — rebuilt from the proto or the registry by `make codegen`.
171
+ Never edited by hand.
172
+
173
+ ### Outside the runner: sites that enumerate
174
+
175
+ | File | What enumerates the harness set |
176
+ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
177
+ | `apis/ai/stigmer/agentic/session/v1/enum.proto` | The `Harness` enum itself; the root. Then `make codegen`. |
178
+ | `apis/ai/stigmer/agentic/session/v1/spec.proto` | The `harness` field's comment lists each harness and its activity. |
179
+ | `apis/ai/stigmer/agentic/workflow/v1/tasks/agent_call.proto` | The `harness` field's comment lists each harness. |
180
+ | `apis/ai/stigmer/iam/identityaccount/v1/spec.proto` | `default_harness` names the allowed lowercase strings in its validation rule. |
181
+ | `apis/ai/stigmer/agentic/agentexecution/v1/filereview.proto` | `harness_id` comments state the closed set of file-review ids. |
182
+ | `apis/ai/stigmer/billing/v1/io.proto`, `apis/ai/stigmer/billing/v1/policy.proto` | Harness string fields whose comments state the set. |
183
+ | `backend/services/stigmer-server/src/temporal/agentexecution/names.ts` | `EXECUTE_CURSOR_ACTIVITY_NAME`, `EXECUTE_DEEP_AGENT_ACTIVITY_NAME`: the server side of the runner's byte-pinned names. |
184
+ | `backend/services/stigmer-server/src/temporal/agentexecution/workflows/invoke-agent-execution.ts` | The activity proxy typed per name, and a branch on the enum: `executeCursorFlow` for a harness whose engine mints the state id (the server reads it back), the deep-agent flow for one whose id the server mints first (`EnsureThread`). The largest site; a new harness needs an arm here, its own flow or one of these two. |
185
+ | `backend/services/stigmer-server/src/domain/workflow/converter/task-converters.ts` | A `switch` over `Harness` to the YAML shorthand. |
186
+ | `backend/services/stigmer-server/src/domain/workflow/converter/unmarshal.ts` | `normalizeEnumShorthands`: the YAML word to the enum name. |
187
+ | `backend/services/stigmer-server/src/domain/workflow/registry/pin-validation.ts` | `HARNESS_NAME_CURSOR` and a Cursor-only pin rule. |
188
+ | `backend/services/stigmer-server/src/domain/workflow/registry/data/model-registry.json` | Per-harness model rows; a harness with its own catalog adds rows. |
189
+ | `backend/services/stigmer-server/src/temporal/schedule/model-pinning.ts` | A Cursor-only pinning rule. |
190
+ | `backend/services/stigmer-server/scripts/capture-replay-histories.ts` | A map keyed by activity name, one stub per activity (a maintainer script). |
191
+ | `client-apps/cli/src/commands/agent-exec-flags.ts` | The `--harness` flag's help text lists the values. |
192
+ | `client-apps/cli/src/resources/run/create.ts` | The flag string to the enum. |
193
+ | `client-apps/cli/src/resources/run/prepare.ts` | `HarnessFlag` and its checks. |
194
+ | `client-apps/cli/src/resources/run/header.ts` | The run header's harness label. |
195
+ | `client-apps/cli/src/resources/task-configs.ts` | The YAML shorthand map. |
196
+ | `apis/ai/stigmer/agentic/agentexecution/v1/enum.proto` | A comment on tool-name casing per harness. |
197
+ | `backend/README.md` | Lists the harnesses and the SDK behind each. |
198
+ | `client-apps/desktop/scripts/stage-runner-slim.sh`, `client-apps/desktop/scripts/macos-codesign-tree.sh` | Stage and sign the vendor SDKs' native helpers for the desktop app; a harness whose SDK ships one touches both. |
199
+ | `sdk/react/src/models/harness.ts` | The SDK hub: `HarnessOption`, `HARNESS_META`, `HARNESS_LABELS`, `HARNESS_OPTIONS`, `DEFAULT_HARNESS`, `toProtoHarness`, `fromProtoHarness`. `HarnessOption` carries four values beyond the proto's two; `toProtoHarness` maps them to `NATIVE` through its `default` arm. |
200
+ | `sdk/react/src/models/HarnessSelector.tsx` | `OPTIONS`, the two selectable values. |
201
+ | `sdk/react/src/models/ModelSelector.tsx` | A Cursor-only thinking rule, and the filter that hides the extra options by name. |
202
+ | `sdk/react/src/identity-account/AccountPreferencesPanel.tsx` | One `HarnessOptionRow` per harness, placed by hand. |
203
+ | `sdk/react/src/identity-account/useAccountExecutionDefaults.ts` | Validates the preference against the two names. |
204
+ | `sdk/react/src/workflow/inspector/forms/AgentCallForm.tsx` | Two radio buttons, placed by hand. |
205
+ | `sdk/react/src/pricing-governance/BaselineEditor.tsx` | A select with one option per harness. |
206
+ | `site/src/components/pages/pricing/ModelPricingTable.tsx` | Harness to display label. |
207
+ | `site/src/data/harness-cost-comparison.json` | Per-harness cost rows. |
208
+ | `docs/concepts/harnesses.mdx`, `docs/concepts/sessions.mdx`, `docs/guides/runners/cursor-harness.mdx`, `docs/guides/workflows/task-types/agent-call.mdx`, `docs/vocabulary.md` | Hand-authored pages that name the harness set; each has an entry in `docs/_inventory/classification.yaml` to keep current. |
209
+
210
+ The cloud composition that serves api.stigmer.ai has sites of the same three
211
+ classes (billing gates, pricing arms, the channel broker's harness switch, its
212
+ own model registry). A harness that must run there is a change on that side too.
213
+
214
+ ### Outside the runner: sites that pass the value through
215
+
216
+ Nothing to touch. Listed so a probe's hit here is a stop, not a lead.
217
+
218
+ - `apis/`: `apis/ai/stigmer/agentic/workflow/v1/tasks/meta/agent_call.yaml` (an
219
+ example value); `apis/ai/stigmer/agentic/agentexecution/v1/io.proto`,
220
+ `apis/ai/stigmer/agentic/agentexecution/v1/usage.proto`,
221
+ `apis/ai/stigmer/billing/v1/model_pricing_baseline.proto`,
222
+ `apis/ai/stigmer/billing/v1/pricing_override.proto` (free-form provider or
223
+ harness strings with examples); the fixtures under
224
+ `apis/testdata/hitl/file-review/`.
225
+ - The server: `backend/services/stigmer-server/src/domain/session/steps.ts` (the
226
+ immutability check; no per-harness arm);
227
+ `backend/services/stigmer-server/src/temporal/agentexecution/dispatch.ts`,
228
+ `backend/services/stigmer-server/src/temporal/agentexecution/activities.ts`,
229
+ `backend/services/stigmer-server/src/temporal/agentexecution/worker.ts`,
230
+ `backend/services/stigmer-server/src/temporal/agentexecution/workflow-input.ts`
231
+ (read the session's harness or name the activities in prose).
232
+ - The React SDK: `sdk/react/src/models/registry.ts`,
233
+ `sdk/react/src/models/useModelRegistry.ts`,
234
+ `sdk/react/src/models/service-tier.ts`; everything under
235
+ `sdk/react/src/channel/`, `sdk/react/src/composer/`,
236
+ `sdk/react/src/execution/`, `sdk/react/src/schedule/`,
237
+ `sdk/react/src/session/` (typed by the option or defaulting to one value).
238
+ - Fixtures and clients: `test/e2e/helpers/approval.ts`,
239
+ `test/extension-consumer/src/fake-extension.ts`, `test/fixtures/tool-view/`,
240
+ `site/src/components/docs/demos/shared/StigmerPreviewProvider.tsx`,
241
+ `sdk/java/src/main/java/ai/stigmer/sdk/BillingClient.java` (a hand-written
242
+ client's field comment).
243
+ - Inside the runner: comments across `shared/` and the composition roots that
244
+ name both activities or the native engine's tool names as examples;
245
+ `__test-utils__/hermetic-activity.ts` and
246
+ `__test-utils__/model-registry-fixture.ts`; the kit's
247
+ `__test-utils__/harness-contract/runtime-contract.ts` and
248
+ `__test-utils__/harness-contract/types.ts`, typed by `HarnessName` and
249
+ selecting by it.
250
+
251
+ ### Generated
252
+
253
+ `make codegen` rebuilds these from the proto and the registry; do not edit them:
254
+ `apis/stubs/`, `sdk/go/proto/`, `tools/codegen/output/`,
255
+ `tools/codegen/schemas/`,
256
+ `backend/services/stigmer-server/src/domain/workflow/registry/data/task-kind-registry.json`,
257
+ `docs/sdk/resources/`, `docs/sdk/react/`, `docs/cli/commands/`.
258
+
259
+ ### Verifying
260
+
261
+ `make codegen` after the proto edit. `npm test` in `backend/services/runner/`
262
+ runs the kit, every fence, the boot-order test and this file's own test.
263
+
264
+ ## The contract kit
265
+
266
+ - `__test-utils__/harness-contract/contract.ts` — the adapter-side half:
267
+ `describeHarnessContract`, the invariants every adapter owes the runtime, and
268
+ what the kit cannot measure.
269
+ - `__test-utils__/harness-contract/runtime-contract.ts` — the runtime-side half:
270
+ `describeHarnessRuntimeContract`, what the runtime owes every harness, proven
271
+ through the real activity.
272
+ - `__test-utils__/harness-contract/types.ts` — `HarnessContractSubject`, the one
273
+ interface a real adapter implements to join the kit, and the scenario
274
+ vocabulary (`ScenarioStep`).
275
+ - `__test-utils__/hermetic-activity.ts` — `runActivityHermetically`: a real
276
+ activity with no network, and the rule for a golden that will not hold still.
277
+ The vendor SDK double is the adapter's own.
278
+ - `__tests__/harness-contract.test.ts` — the template under both pause
279
+ primitives and both state-id sources; a real adapter registers both halves in
280
+ its own hermetic file instead.
281
+ - `__test-utils__/__tests__/harness-contract-self-check.test.ts` — every
282
+ invariant run against an adapter broken in exactly the way it exists to catch.
283
+ - `harness/__tests__/run-turn.test.ts` — the runtime-side half against the
284
+ template, one arm per row of the terminal table, and the template's own
285
+ timing, not any engine's.
286
+
287
+ The hermetic goldens in each adapter's goldens folder (named above) are the
288
+ second net: they pin a turn's persisted status byte for byte.
289
+
290
+ ## Footprint
291
+
292
+ Measured at commit f25d15131 (2026-09-16), production TypeScript only,
293
+ `__tests__/` and `__test-utils__/` excluded. Run from `backend/services/runner/`
294
+ to re-measure:
295
+
296
+ ```bash
297
+ wc -l src/__test-utils__/harness-contract/scripted-adapter.ts
298
+ for d in src/activities/execute-deep-agent src/activities/execute-cursor src/harness; do
299
+ printf '%s: ' "$d"
300
+ find "$d" -name '*.ts' -not -path '*/__tests__/*' -not -path '*/__test-utils__/*' | xargs cat | wc -l
301
+ done
302
+ ```
303
+
304
+ | What | Lines | Files |
305
+ | -------------------------------------------------------------------------------------------------------- | ------ | ----- |
306
+ | The template, `__test-utils__/harness-contract/scripted-adapter.ts`: the floor, no engine, no translator | 385 | 1 |
307
+ | The native adapter, `activities/execute-deep-agent/` | 4,308 | 20 |
308
+ | The Cursor adapter, `activities/execute-cursor/`: the ceiling, with its deny-and-retry hook and ledger | 11,554 | 35 |
309
+ | The runtime, `harness/`, for scale: written once | 4,985 | 14 |
310
+ | The test side the native adapter adds: its subject, its hermetic kit file, its two fences | 658 | 4 |
311
+
312
+ ## Design history
313
+
314
+ The pull requests carry the measured acceptance of each step; the module headers
315
+ carry the reasoning.
316
+
317
+ - #1048 — the hermetic regression net: a real activity, no network, goldens byte
318
+ for byte.
319
+ - #1064 — the adapter contract, the scripted template, the contract kit and the
320
+ registry.
321
+ - #1070 — the turn runtime extracted; the Cursor activity became an adapter.
322
+ - #1096 — the native deep-agent harness as an adapter over the same runtime.
323
+ - #1097 — one transcript builder over one canonical event for every harness.
324
+ - #1136 — the headers made readable to a stranger; every citation public.
325
+
326
+ ## About this file
327
+
328
+ Every fact about the design has one home, the header of the module that owns it.
329
+ This file points at that home in one sentence and restates nothing; if this file
330
+ and a header disagree, the header is right and this file is corrected. It adds
331
+ two things no header can carry: the sites outside the runner, derived by the
332
+ method above, and the footprint. Paths inside the runner's `src` directory are
333
+ spelled from `src`; every other path is spelled from the repository root.
334
+ `harness/__tests__/readme-index.test.ts` fails when a path or a symbol named
335
+ here stops resolving.
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * `harness/approval-decisions.ts` — the runtime's one settler of a decision
3
3
  * that never runs the tool. These arms came with the function from the
4
- * native harness's `hitl.ts` (`reconcileNonExecutingDecisions`, S3 M1 /
5
- * M2a): SKIP and REJECT settle to SKIPPED (REJECT with the pinned reason),
4
+ * native harness's `hitl.ts` (`reconcileNonExecutingDecisions`, in #1096):
5
+ * SKIP and REJECT settle to SKIPPED (REJECT with the pinned reason),
6
6
  * APPROVE and APPROVE_ALL are left to the engine's own events, sub-agent
7
7
  * transcripts are settled alike, and an undecided row is untouched. The
8
8
  * reader half (`approvalDecisionsOf`) is pinned against the Cursor adapter's
@@ -5,14 +5,14 @@
5
5
  * resolution phases and the outcome table.
6
6
  *
7
7
  * What is asserted here and nowhere else are the two rules the lift made
8
- * one for every harness (S3 M4, Q-M4-5, Q-M4-6):
8
+ * one for every harness (#1096):
9
9
  *
10
10
  * - the stamp reads the ROW's status: a COMPLETED write row created this
11
11
  * turn is badged, a FAILED or WAITING one is not, a seeded prior-turn row
12
12
  * keeps its own change set;
13
13
  * - the provenance scopes by id-novelty and consents by the row's own
14
14
  * approval: the approved command that executed ON ITS SEEDED ROW (message
15
- * 0, the shape both engines produce — F-M4-P3) qualifies the turn, where
15
+ * 0, the shape both engines produce) qualifies the turn, where
16
16
  * a positional scope missed it.
17
17
  *
18
18
  * The ledger shape itself is `shared/filereview/capture.ts`'s and is pinned
@@ -210,7 +210,7 @@ describe("harness/capture over a git work tree", () => {
210
210
  });
211
211
  });
212
212
 
213
- describe("deriveCommandProvenance — one rule for both engines (F-M4-P3)", () => {
213
+ describe("deriveCommandProvenance — one rule for both engines", () => {
214
214
  const seededShell = (status: ToolCallStatus, approvalAction: ApprovalAction) =>
215
215
  row("tc-shell", "shell", status, { approvalAction, args: { command: "make generate" } });
216
216
 
@@ -17,8 +17,8 @@
17
17
  * Temporal-free fence), so a path quoted in a header comment (several
18
18
  * `shared/` modules cite `activities/...` in prose) cannot trip it, and no
19
19
  * import form can slip past it: static, type-only, side-effect, re-export
20
- * and dynamic `import()` are all module specifiers to the parser. Ruled at
21
- * the S2 gate (Q-S2-9); the `shared/` half ruled at the M1 gate (Q-M1-5).
20
+ * and dynamic `import()` are all module specifiers to the parser. The
21
+ * `harness/` fence landed in #1070; the `shared/` half in #1097.
22
22
  */
23
23
 
24
24
  import { describe, it, expect } from "vitest";
@@ -128,6 +128,7 @@ describe("src/harness never imports src/activities", () => {
128
128
  join("harness", "registry.ts"),
129
129
  join("harness", "types.ts"),
130
130
  join("harness", "capabilities.ts"),
131
+ join("harness", "transcript", "builder.ts"),
131
132
  ]),
132
133
  );
133
134
  });