@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,62 @@
1
+ /**
2
+ * The one way a turn is told to stop, and the runtime's record of why.
3
+ *
4
+ * The adapter contract gives an engine ONE signal (`TurnSink.stopSignal`) for
5
+ * every cause of stopping and forbids it to branch on the cause; the runtime
6
+ * keeps the cause here, as evidence its terminal table reads after the
7
+ * adapter settles `interrupted`. Four producers abort the signal: the stall
8
+ * watchdog, the usage accumulator's cost cap, the persist chokepoint's
9
+ * platform STOP, and Temporal's own cancellation (a pause, a worker
10
+ * shutdown, a heartbeat timeout — told apart later from the signal's reason,
11
+ * `shared/worker-shutdown.ts`). The first cause wins the abort; every cause
12
+ * is recorded, because the table's precedence (stall over cost cap over
13
+ * cancellation over platform stop) is decided at settlement, not at abort.
14
+ *
15
+ * Nothing here is engine-specific and nothing here persists; the Cursor
16
+ * orchestrator kept the same facts as flags on its stream state
17
+ * (`turn-stream.ts` `TurnStreamState`, before S2 M3 moved them out).
18
+ */
19
+ export class StopController {
20
+ controller = new AbortController();
21
+ stall;
22
+ costCapExceeded = false;
23
+ platformStop = false;
24
+ cancellation = false;
25
+ /** The adapter's `stopSignal`. Its `reason` is the first cause's kind, a diagnostic only. */
26
+ get signal() {
27
+ return this.controller.signal;
28
+ }
29
+ get evidence() {
30
+ return {
31
+ stall: this.stall,
32
+ costCapExceeded: this.costCapExceeded,
33
+ platformStop: this.platformStop,
34
+ cancellation: this.cancellation,
35
+ };
36
+ }
37
+ /** Record a cause and abort the signal (idempotent per cause; the signal aborts once). */
38
+ stop(cause) {
39
+ switch (cause.kind) {
40
+ case "stall":
41
+ this.stall ??= cause.error;
42
+ break;
43
+ case "cost-cap":
44
+ this.costCapExceeded = true;
45
+ break;
46
+ case "platform-stop":
47
+ this.platformStop = true;
48
+ break;
49
+ case "cancellation":
50
+ this.cancellation = true;
51
+ break;
52
+ default: {
53
+ const exhaustive = cause;
54
+ throw new Error(`StopController: unknown stop cause ${JSON.stringify(exhaustive)}`);
55
+ }
56
+ }
57
+ if (!this.controller.signal.aborted) {
58
+ this.controller.abort(cause.kind);
59
+ }
60
+ }
61
+ }
62
+ //# sourceMappingURL=stop-controller.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stop-controller.js","sourceRoot":"","sources":["../../src/harness/stop-controller.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAoBH,MAAM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 * The terminal table: every way a turn ends, as data — the phase it writes,
3
+ * the `error` it sets, the system rows it appends, whether it stamps
4
+ * `completedAt`, and whether the activity RETURNS the slim status or THROWS
5
+ * a `CancelledFailure` — with one function that applies an arm to a status.
6
+ *
7
+ * Why data and not one function per arm: the copy is the user-facing
8
+ * contract of the runner (the hermetic goldens pin every string below byte
9
+ * for byte, `activities/execute-cursor/__tests__/hermetic/`), and a table a
10
+ * reader can scan is how that contract stays reviewable. The native
11
+ * harness's `execute-deep-agent/streaming-terminal.ts` keeps one function
12
+ * per arm; S3 aligns the two (P-1's copy alignment) with both in view.
13
+ *
14
+ * The throw-vs-return rule, unchanged from the orchestrator it replaces:
15
+ * - RETURN when a Temporal retry would only repeat the outcome — a stall
16
+ * would wedge again, an exhausted budget would burn again, a platform
17
+ * stop is the platform's decision, a failed engine would fail the same
18
+ * prompt the same way, a completed turn is complete.
19
+ * - THROW `CancelledFailure` when the workflow must see the activity as
20
+ * cancelled — the orchestrator's pause, the runner's own drain, and an
21
+ * infrastructure cancel it delivered — with the message the control
22
+ * planes recognise.
23
+ *
24
+ * An arm's rows are appended exactly once, by `applyTerminalArm`, and an arm
25
+ * is persisted exactly once, by `run-turn.ts`'s `settleWith` — the one
26
+ * writer of a terminal. The orchestrator this table replaced appended the
27
+ * three THROW arms' rows twice (its throw fell into its own catch, which
28
+ * wrote the copy again); S2 reproduced that on purpose so the goldens could
29
+ * pin the wire byte for byte, and the PR after S2 removed it with a reviewed
30
+ * golden regeneration (stigmer#1054, Q-S2-4).
31
+ */
32
+ import type { AgentExecutionStatus } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/api_pb";
33
+ import { ExecutionPhase } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/enum_pb";
34
+ import { type StallTimeoutError } from "../shared/stall-watchdog.js";
35
+ import type { WorkspaceLockTimeoutError } from "../shared/workspace/workspace-lock.js";
36
+ import type { FailureSurface } from "./types.js";
37
+ /** How the activity ends after the arm is written and persisted. */
38
+ export type TerminalDisposition = {
39
+ readonly kind: "return";
40
+ } | {
41
+ readonly kind: "throw";
42
+ readonly message: string;
43
+ };
44
+ /** One arm of the table: what to write, and how to end. */
45
+ export interface TerminalArm {
46
+ readonly phase: ExecutionPhase;
47
+ /** `status.error`; absent leaves it as it is (a pause is not an error). */
48
+ readonly error?: string;
49
+ /** System rows appended in order, each exactly once. */
50
+ readonly rows: readonly string[];
51
+ /** Stamp `completedAt`; a paused turn is not complete. */
52
+ readonly completes: boolean;
53
+ readonly disposition: TerminalDisposition;
54
+ }
55
+ /** The fixed strings of the table, in one place. Every one is pinned by a golden or a hermetic assertion. */
56
+ export declare const TERMINAL_COPY: {
57
+ readonly pause: {
58
+ readonly row: "Execution paused by user. Use resume to continue.";
59
+ readonly throwMessage: "Activity paused by orchestrator";
60
+ readonly throwMessageAfterError: "Activity paused by orchestrator (error during pause)";
61
+ };
62
+ readonly workerShutdown: {
63
+ readonly error: "Execution interrupted: runner worker was shut down. Retry or resume.";
64
+ readonly row: "Execution interrupted: the runner worker was shut down while the agent was still running. You can retry or resume.";
65
+ readonly throwMessage: "Activity cancelled (worker shutdown, not user pause)";
66
+ };
67
+ readonly infrastructureCancel: {
68
+ readonly error: "Execution interrupted: agent was unresponsive (heartbeat timeout). Retry or resume.";
69
+ readonly row: "Execution interrupted: the agent was unresponsive for too long. You can retry or resume.";
70
+ readonly throwMessage: "Activity cancelled (heartbeat timeout, not user pause)";
71
+ readonly throwMessageAfterError: "Activity cancelled (infrastructure, not user pause)";
72
+ };
73
+ readonly platformStop: {
74
+ readonly row: "Execution stopped by the platform.";
75
+ };
76
+ readonly rejectedByUser: {
77
+ readonly error: "Execution rejected by user";
78
+ readonly row: "Execution was rejected by the user during tool approval.";
79
+ };
80
+ readonly fileReview: {
81
+ readonly applyFailedPrefix: "Some approved file changes could not be applied because the file changed after review: ";
82
+ readonly discardedPrefix: "Some proposed file changes were discarded by the user and were not applied: ";
83
+ };
84
+ readonly internalFailure: {
85
+ readonly row: "Internal system error occurred. Please contact support if this issue persists.";
86
+ };
87
+ };
88
+ /** The watchdog cancelled a turn that made no progress. RETURN: an identical prompt would wedge again. */
89
+ export declare function stallArm(error: StallTimeoutError): TerminalArm;
90
+ /**
91
+ * The cost cap stopped the turn. TERMINATED, not FAILED: the platform
92
+ * deliberately stopped the run, work is checkpointed, and the conversation
93
+ * continues on the next message (the recursion-limit precedent in
94
+ * `execute-deep-agent/streaming-terminal.ts`). RETURN: a retry would burn
95
+ * the same budget again.
96
+ */
97
+ export declare function costCapArm(maxCostUsd: number, estimatedCostUsd: number): TerminalArm;
98
+ /** The runner is draining. Not a user pause: FAILED with the shutdown copy, thrown as cancelled. */
99
+ export declare function workerShutdownArm(): TerminalArm;
100
+ /** The orchestrator paused the execution. Not an error, not complete; thrown as cancelled. */
101
+ export declare function pauseArm(): TerminalArm;
102
+ /** Temporal cancelled for its own reason (a heartbeat timeout). FAILED with the unresponsive copy, thrown as cancelled. */
103
+ export declare function infrastructureCancelArm(): TerminalArm;
104
+ /** The control plane answered STOP. A clean COMPLETED early exit. */
105
+ export declare function platformStopArm(): TerminalArm;
106
+ /** Another turn held the primary tree past the lock timeout. RETURN: a retry would queue behind the same holder. */
107
+ export declare function workspaceLockTimeoutArm(error: WorkspaceLockTimeoutError): TerminalArm;
108
+ /** An adjudicated irreversible action (shell / MCP) was REJECTed. */
109
+ export declare function rejectedByUserArm(): TerminalArm;
110
+ /**
111
+ * A pure file-review resume: the agent already finished its turn during
112
+ * capture, so keeping or discarding a change never re-prompts it
113
+ * (Cursor-like); the reconcile is the whole act and the execution is
114
+ * complete. A failed reconcile (what-you-approve-is-what-applies could not
115
+ * be honored) tells the human; a discard tells the human which files were
116
+ * reverted — the agent's native context still believes those edits stuck,
117
+ * and any edit it makes from that belief is re-surfaced next turn (the
118
+ * structural safety net; design-decisions/capture-reject-next-turn-resync-not-built.md).
119
+ */
120
+ export declare function fileReviewResolvedArm(settlement: {
121
+ readonly failed: boolean;
122
+ readonly failureDetail: string;
123
+ readonly discardedPaths: readonly string[];
124
+ }): TerminalArm;
125
+ /**
126
+ * The adapter settled `failed`. The surface picks the copy (the three shapes
127
+ * the Cursor orchestrator wrote, `types.ts` `FailureSurface`); `message` is
128
+ * the adapter's user-facing sentence and becomes `status.error` whole.
129
+ */
130
+ export declare function failedArm(message: string, surface: FailureSurface): TerminalArm;
131
+ /**
132
+ * An error the runtime caught itself, outside any adapter (a resolution
133
+ * phase, the epilogue): the boilerplate row and the described error as the
134
+ * details, with `status.error` carrying the `Execution failed:` prefix the
135
+ * orchestrator's generic arm always wrote (`describeExecutionError` supplies
136
+ * the two parts). The one arm whose `error` and details row differ, kept as
137
+ * it was because the resolution-error golden pins both.
138
+ */
139
+ export declare function unexpectedErrorArm(errorType: string, errorMessage: string): TerminalArm;
140
+ /** Write an arm onto the status: phase, error, completion stamp, rows. The caller persists and disposes. */
141
+ export declare function applyTerminalArm(status: AgentExecutionStatus, arm: TerminalArm): void;
@@ -0,0 +1,239 @@
1
+ /**
2
+ * The terminal table: every way a turn ends, as data — the phase it writes,
3
+ * the `error` it sets, the system rows it appends, whether it stamps
4
+ * `completedAt`, and whether the activity RETURNS the slim status or THROWS
5
+ * a `CancelledFailure` — with one function that applies an arm to a status.
6
+ *
7
+ * Why data and not one function per arm: the copy is the user-facing
8
+ * contract of the runner (the hermetic goldens pin every string below byte
9
+ * for byte, `activities/execute-cursor/__tests__/hermetic/`), and a table a
10
+ * reader can scan is how that contract stays reviewable. The native
11
+ * harness's `execute-deep-agent/streaming-terminal.ts` keeps one function
12
+ * per arm; S3 aligns the two (P-1's copy alignment) with both in view.
13
+ *
14
+ * The throw-vs-return rule, unchanged from the orchestrator it replaces:
15
+ * - RETURN when a Temporal retry would only repeat the outcome — a stall
16
+ * would wedge again, an exhausted budget would burn again, a platform
17
+ * stop is the platform's decision, a failed engine would fail the same
18
+ * prompt the same way, a completed turn is complete.
19
+ * - THROW `CancelledFailure` when the workflow must see the activity as
20
+ * cancelled — the orchestrator's pause, the runner's own drain, and an
21
+ * infrastructure cancel it delivered — with the message the control
22
+ * planes recognise.
23
+ *
24
+ * An arm's rows are appended exactly once, by `applyTerminalArm`, and an arm
25
+ * is persisted exactly once, by `run-turn.ts`'s `settleWith` — the one
26
+ * writer of a terminal. The orchestrator this table replaced appended the
27
+ * three THROW arms' rows twice (its throw fell into its own catch, which
28
+ * wrote the copy again); S2 reproduced that on purpose so the goldens could
29
+ * pin the wire byte for byte, and the PR after S2 removed it with a reviewed
30
+ * golden regeneration (stigmer#1054, Q-S2-4).
31
+ */
32
+ import { create } from "@bufbuild/protobuf";
33
+ import { AgentMessageSchema } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/message_pb";
34
+ import { ExecutionPhase, MessageType } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/enum_pb";
35
+ import { COST_LIMIT_USER_COPY, formatCostLimitError } from "../shared/cost-guard.js";
36
+ import { formatStallFailure } from "../shared/stall-watchdog.js";
37
+ import { utcTimestamp } from "../shared/status.js";
38
+ const RETURN = { kind: "return" };
39
+ /** The fixed strings of the table, in one place. Every one is pinned by a golden or a hermetic assertion. */
40
+ export const TERMINAL_COPY = {
41
+ pause: {
42
+ row: "Execution paused by user. Use resume to continue.",
43
+ throwMessage: "Activity paused by orchestrator",
44
+ throwMessageAfterError: "Activity paused by orchestrator (error during pause)",
45
+ },
46
+ workerShutdown: {
47
+ error: "Execution interrupted: runner worker was shut down. Retry or resume.",
48
+ row: "Execution interrupted: the runner worker was shut down while the agent was still running. You can retry or resume.",
49
+ throwMessage: "Activity cancelled (worker shutdown, not user pause)",
50
+ },
51
+ infrastructureCancel: {
52
+ error: "Execution interrupted: agent was unresponsive (heartbeat timeout). Retry or resume.",
53
+ row: "Execution interrupted: the agent was unresponsive for too long. You can retry or resume.",
54
+ throwMessage: "Activity cancelled (heartbeat timeout, not user pause)",
55
+ throwMessageAfterError: "Activity cancelled (infrastructure, not user pause)",
56
+ },
57
+ platformStop: {
58
+ row: "Execution stopped by the platform.",
59
+ },
60
+ rejectedByUser: {
61
+ error: "Execution rejected by user",
62
+ row: "Execution was rejected by the user during tool approval.",
63
+ },
64
+ fileReview: {
65
+ applyFailedPrefix: "Some approved file changes could not be applied because the file changed after review: ",
66
+ discardedPrefix: "Some proposed file changes were discarded by the user and were not applied: ",
67
+ },
68
+ internalFailure: {
69
+ row: "Internal system error occurred. Please contact support if this issue persists.",
70
+ },
71
+ };
72
+ // ── The arms ────────────────────────────────────────────────────────────────
73
+ /** The watchdog cancelled a turn that made no progress. RETURN: an identical prompt would wedge again. */
74
+ export function stallArm(error) {
75
+ return {
76
+ phase: ExecutionPhase.EXECUTION_FAILED,
77
+ error: formatStallFailure(error),
78
+ rows: [
79
+ `Execution failed: the agent made no progress for too long and was stopped (${error.message}). You can retry or resume.`,
80
+ ],
81
+ completes: true,
82
+ disposition: RETURN,
83
+ };
84
+ }
85
+ /**
86
+ * The cost cap stopped the turn. TERMINATED, not FAILED: the platform
87
+ * deliberately stopped the run, work is checkpointed, and the conversation
88
+ * continues on the next message (the recursion-limit precedent in
89
+ * `execute-deep-agent/streaming-terminal.ts`). RETURN: a retry would burn
90
+ * the same budget again.
91
+ */
92
+ export function costCapArm(maxCostUsd, estimatedCostUsd) {
93
+ return {
94
+ phase: ExecutionPhase.EXECUTION_TERMINATED,
95
+ error: formatCostLimitError(maxCostUsd, estimatedCostUsd),
96
+ rows: [COST_LIMIT_USER_COPY],
97
+ completes: true,
98
+ disposition: RETURN,
99
+ };
100
+ }
101
+ /** The runner is draining. Not a user pause: FAILED with the shutdown copy, thrown as cancelled. */
102
+ export function workerShutdownArm() {
103
+ return {
104
+ phase: ExecutionPhase.EXECUTION_FAILED,
105
+ error: TERMINAL_COPY.workerShutdown.error,
106
+ rows: [TERMINAL_COPY.workerShutdown.row],
107
+ completes: true,
108
+ disposition: { kind: "throw", message: TERMINAL_COPY.workerShutdown.throwMessage },
109
+ };
110
+ }
111
+ /** The orchestrator paused the execution. Not an error, not complete; thrown as cancelled. */
112
+ export function pauseArm() {
113
+ return {
114
+ phase: ExecutionPhase.EXECUTION_PAUSED,
115
+ rows: [TERMINAL_COPY.pause.row],
116
+ completes: false,
117
+ disposition: { kind: "throw", message: TERMINAL_COPY.pause.throwMessage },
118
+ };
119
+ }
120
+ /** Temporal cancelled for its own reason (a heartbeat timeout). FAILED with the unresponsive copy, thrown as cancelled. */
121
+ export function infrastructureCancelArm() {
122
+ return {
123
+ phase: ExecutionPhase.EXECUTION_FAILED,
124
+ error: TERMINAL_COPY.infrastructureCancel.error,
125
+ rows: [TERMINAL_COPY.infrastructureCancel.row],
126
+ completes: true,
127
+ disposition: { kind: "throw", message: TERMINAL_COPY.infrastructureCancel.throwMessage },
128
+ };
129
+ }
130
+ /** The control plane answered STOP. A clean COMPLETED early exit. */
131
+ export function platformStopArm() {
132
+ return {
133
+ phase: ExecutionPhase.EXECUTION_COMPLETED,
134
+ rows: [TERMINAL_COPY.platformStop.row],
135
+ completes: true,
136
+ disposition: RETURN,
137
+ };
138
+ }
139
+ /** Another turn held the primary tree past the lock timeout. RETURN: a retry would queue behind the same holder. */
140
+ export function workspaceLockTimeoutArm(error) {
141
+ return {
142
+ phase: ExecutionPhase.EXECUTION_FAILED,
143
+ error: error.message,
144
+ rows: [`Execution failed: ${error.message}`],
145
+ completes: true,
146
+ disposition: RETURN,
147
+ };
148
+ }
149
+ /** An adjudicated irreversible action (shell / MCP) was REJECTed. */
150
+ export function rejectedByUserArm() {
151
+ return {
152
+ phase: ExecutionPhase.EXECUTION_FAILED,
153
+ error: TERMINAL_COPY.rejectedByUser.error,
154
+ rows: [TERMINAL_COPY.rejectedByUser.row],
155
+ completes: true,
156
+ disposition: RETURN,
157
+ };
158
+ }
159
+ /**
160
+ * A pure file-review resume: the agent already finished its turn during
161
+ * capture, so keeping or discarding a change never re-prompts it
162
+ * (Cursor-like); the reconcile is the whole act and the execution is
163
+ * complete. A failed reconcile (what-you-approve-is-what-applies could not
164
+ * be honored) tells the human; a discard tells the human which files were
165
+ * reverted — the agent's native context still believes those edits stuck,
166
+ * and any edit it makes from that belief is re-surfaced next turn (the
167
+ * structural safety net; design-decisions/capture-reject-next-turn-resync-not-built.md).
168
+ */
169
+ export function fileReviewResolvedArm(settlement) {
170
+ const rows = [];
171
+ if (settlement.failed) {
172
+ rows.push(`${TERMINAL_COPY.fileReview.applyFailedPrefix}${settlement.failureDetail}.`);
173
+ }
174
+ else if (settlement.discardedPaths.length > 0) {
175
+ rows.push(`${TERMINAL_COPY.fileReview.discardedPrefix}${settlement.discardedPaths.join(", ")}.`);
176
+ }
177
+ return { phase: ExecutionPhase.EXECUTION_COMPLETED, rows, completes: true, disposition: RETURN };
178
+ }
179
+ /**
180
+ * The adapter settled `failed`. The surface picks the copy (the three shapes
181
+ * the Cursor orchestrator wrote, `types.ts` `FailureSurface`); `message` is
182
+ * the adapter's user-facing sentence and becomes `status.error` whole.
183
+ */
184
+ export function failedArm(message, surface) {
185
+ const rows = (() => {
186
+ switch (surface) {
187
+ case "engine":
188
+ return [];
189
+ case "actionable":
190
+ return [`Execution failed: ${message}`];
191
+ case "internal":
192
+ return [TERMINAL_COPY.internalFailure.row, `Error details: ${message}`];
193
+ default: {
194
+ const exhaustive = surface;
195
+ throw new Error(`terminal table: unknown failure surface ${String(exhaustive)}`);
196
+ }
197
+ }
198
+ })();
199
+ return { phase: ExecutionPhase.EXECUTION_FAILED, error: message, rows, completes: true, disposition: RETURN };
200
+ }
201
+ /**
202
+ * An error the runtime caught itself, outside any adapter (a resolution
203
+ * phase, the epilogue): the boilerplate row and the described error as the
204
+ * details, with `status.error` carrying the `Execution failed:` prefix the
205
+ * orchestrator's generic arm always wrote (`describeExecutionError` supplies
206
+ * the two parts). The one arm whose `error` and details row differ, kept as
207
+ * it was because the resolution-error golden pins both.
208
+ */
209
+ export function unexpectedErrorArm(errorType, errorMessage) {
210
+ const described = `[${errorType}] ${errorMessage}`;
211
+ return {
212
+ phase: ExecutionPhase.EXECUTION_FAILED,
213
+ error: `Execution failed: ${described}`,
214
+ rows: [TERMINAL_COPY.internalFailure.row, `Error details: ${described}`],
215
+ completes: true,
216
+ disposition: RETURN,
217
+ };
218
+ }
219
+ // ── Applying an arm ─────────────────────────────────────────────────────────
220
+ /**
221
+ * Append system rows, each with its own timestamp, in order. Module-private
222
+ * on purpose: rows reach a status only through `applyTerminalArm`, so no
223
+ * caller can append an arm's copy a second time (the shape of stigmer#1054).
224
+ */
225
+ function appendSystemRows(status, rows) {
226
+ for (const content of rows) {
227
+ status.messages.push(create(AgentMessageSchema, { type: MessageType.MESSAGE_SYSTEM, content, timestamp: utcTimestamp() }));
228
+ }
229
+ }
230
+ /** Write an arm onto the status: phase, error, completion stamp, rows. The caller persists and disposes. */
231
+ export function applyTerminalArm(status, arm) {
232
+ status.phase = arm.phase;
233
+ if (arm.error !== undefined)
234
+ status.error = arm.error;
235
+ if (arm.completes)
236
+ status.completedAt = utcTimestamp();
237
+ appendSystemRows(status, arm.rows);
238
+ }
239
+ //# sourceMappingURL=terminal-table.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"terminal-table.js","sourceRoot":"","sources":["../../src/harness/terminal-table.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,iEAAiE,CAAC;AACrG,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,8DAA8D,CAAC;AAE3G,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AACrF,OAAO,EAAE,kBAAkB,EAA0B,MAAM,6BAA6B,CAAC;AACzF,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAmBnD,MAAM,MAAM,GAAwB,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;AAEvD,6GAA6G;AAC7G,MAAM,CAAC,MAAM,aAAa,GAAG;I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