@stigmer/runner 0.1.0-dev.20261017020314.g644422724c27

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 (2029) hide show
  1. package/LICENSE +194 -0
  2. package/README.md +310 -0
  3. package/dist/.build-fingerprint +1 -0
  4. package/dist/__test-utils__/approval-contract/hook-commands.d.ts +25 -0
  5. package/dist/__test-utils__/approval-contract/hook-commands.js +87 -0
  6. package/dist/__test-utils__/approval-contract/hook-commands.js.map +1 -0
  7. package/dist/__test-utils__/approval-contract/types.d.ts +326 -0
  8. package/dist/__test-utils__/approval-contract/types.js +24 -0
  9. package/dist/__test-utils__/approval-contract/types.js.map +1 -0
  10. package/dist/__test-utils__/approval-log.d.ts +34 -0
  11. package/dist/__test-utils__/approval-log.js +126 -0
  12. package/dist/__test-utils__/approval-log.js.map +1 -0
  13. package/dist/__test-utils__/execution-record-fixture.d.ts +121 -0
  14. package/dist/__test-utils__/execution-record-fixture.js +134 -0
  15. package/dist/__test-utils__/execution-record-fixture.js.map +1 -0
  16. package/dist/__test-utils__/file-review-projection.d.ts +45 -0
  17. package/dist/__test-utils__/file-review-projection.js +61 -0
  18. package/dist/__test-utils__/file-review-projection.js.map +1 -0
  19. package/dist/__test-utils__/harness-contract/types.d.ts +188 -0
  20. package/dist/__test-utils__/harness-contract/types.js +64 -0
  21. package/dist/__test-utils__/harness-contract/types.js.map +1 -0
  22. package/dist/__test-utils__/hermetic-activity.d.ts +450 -0
  23. package/dist/__test-utils__/hermetic-activity.js +883 -0
  24. package/dist/__test-utils__/hermetic-activity.js.map +1 -0
  25. package/dist/__test-utils__/loopback-host.d.ts +23 -0
  26. package/dist/__test-utils__/loopback-host.js +45 -0
  27. package/dist/__test-utils__/loopback-host.js.map +1 -0
  28. package/dist/__test-utils__/mock-client.d.ts +13 -0
  29. package/dist/__test-utils__/mock-client.js +46 -0
  30. package/dist/__test-utils__/mock-client.js.map +1 -0
  31. package/dist/__test-utils__/mock-workspace.d.ts +15 -0
  32. package/dist/__test-utils__/mock-workspace.js +21 -0
  33. package/dist/__test-utils__/mock-workspace.js.map +1 -0
  34. package/dist/__test-utils__/model-registry-fixture.d.ts +111 -0
  35. package/dist/__test-utils__/model-registry-fixture.js +109 -0
  36. package/dist/__test-utils__/model-registry-fixture.js.map +1 -0
  37. package/dist/__test-utils__/turn-input-fixture.d.ts +60 -0
  38. package/dist/__test-utils__/turn-input-fixture.js +129 -0
  39. package/dist/__test-utils__/turn-input-fixture.js.map +1 -0
  40. package/dist/activities/attach-session.d.ts +34 -0
  41. package/dist/activities/attach-session.js +94 -0
  42. package/dist/activities/attach-session.js.map +1 -0
  43. package/dist/activities/ensure-thread.d.ts +24 -0
  44. package/dist/activities/ensure-thread.js +44 -0
  45. package/dist/activities/ensure-thread.js.map +1 -0
  46. package/dist/activities/execute-cursor/__test-utils__/contract-subject.d.ts +107 -0
  47. package/dist/activities/execute-cursor/__test-utils__/contract-subject.js +392 -0
  48. package/dist/activities/execute-cursor/__test-utils__/contract-subject.js.map +1 -0
  49. package/dist/activities/execute-cursor/__test-utils__/cursor-hook-harness.d.ts +251 -0
  50. package/dist/activities/execute-cursor/__test-utils__/cursor-hook-harness.js +254 -0
  51. package/dist/activities/execute-cursor/__test-utils__/cursor-hook-harness.js.map +1 -0
  52. package/dist/activities/execute-cursor/__test-utils__/fold.d.ts +62 -0
  53. package/dist/activities/execute-cursor/__test-utils__/fold.js +94 -0
  54. package/dist/activities/execute-cursor/__test-utils__/fold.js.map +1 -0
  55. package/dist/activities/execute-cursor/__test-utils__/gateway-substrate.d.ts +34 -0
  56. package/dist/activities/execute-cursor/__test-utils__/gateway-substrate.js +287 -0
  57. package/dist/activities/execute-cursor/__test-utils__/gateway-substrate.js.map +1 -0
  58. package/dist/activities/execute-cursor/__test-utils__/hermetic-cursor.d.ts +202 -0
  59. package/dist/activities/execute-cursor/__test-utils__/hermetic-cursor.js +306 -0
  60. package/dist/activities/execute-cursor/__test-utils__/hermetic-cursor.js.map +1 -0
  61. package/dist/activities/execute-cursor/__test-utils__/scripted-agent.d.ts +176 -0
  62. package/dist/activities/execute-cursor/__test-utils__/scripted-agent.js +278 -0
  63. package/dist/activities/execute-cursor/__test-utils__/scripted-agent.js.map +1 -0
  64. package/dist/activities/execute-cursor/__test-utils__/scripted-sdk.d.ts +182 -0
  65. package/dist/activities/execute-cursor/__test-utils__/scripted-sdk.js +241 -0
  66. package/dist/activities/execute-cursor/__test-utils__/scripted-sdk.js.map +1 -0
  67. package/dist/activities/execute-cursor/adapter.d.ts +63 -0
  68. package/dist/activities/execute-cursor/adapter.js +141 -0
  69. package/dist/activities/execute-cursor/adapter.js.map +1 -0
  70. package/dist/activities/execute-cursor/agent-session-cache.d.ts +72 -0
  71. package/dist/activities/execute-cursor/agent-session-cache.js +186 -0
  72. package/dist/activities/execute-cursor/agent-session-cache.js.map +1 -0
  73. package/dist/activities/execute-cursor/approval-policy.d.ts +67 -0
  74. package/dist/activities/execute-cursor/approval-policy.js +101 -0
  75. package/dist/activities/execute-cursor/approval-policy.js.map +1 -0
  76. package/dist/activities/execute-cursor/approval-state.d.ts +657 -0
  77. package/dist/activities/execute-cursor/approval-state.js +682 -0
  78. package/dist/activities/execute-cursor/approval-state.js.map +1 -0
  79. package/dist/activities/execute-cursor/boundary-rows.d.ts +455 -0
  80. package/dist/activities/execute-cursor/boundary-rows.js +1268 -0
  81. package/dist/activities/execute-cursor/boundary-rows.js.map +1 -0
  82. package/dist/activities/execute-cursor/cas-observations.d.ts +126 -0
  83. package/dist/activities/execute-cursor/cas-observations.js +240 -0
  84. package/dist/activities/execute-cursor/cas-observations.js.map +1 -0
  85. package/dist/activities/execute-cursor/cursor-capabilities.d.ts +37 -0
  86. package/dist/activities/execute-cursor/cursor-capabilities.js +74 -0
  87. package/dist/activities/execute-cursor/cursor-capabilities.js.map +1 -0
  88. package/dist/activities/execute-cursor/cursor-event-recorder.d.ts +43 -0
  89. package/dist/activities/execute-cursor/cursor-event-recorder.js +88 -0
  90. package/dist/activities/execute-cursor/cursor-event-recorder.js.map +1 -0
  91. package/dist/activities/execute-cursor/cursor-mcp-config.d.ts +58 -0
  92. package/dist/activities/execute-cursor/cursor-mcp-config.js +86 -0
  93. package/dist/activities/execute-cursor/cursor-mcp-config.js.map +1 -0
  94. package/dist/activities/execute-cursor/cursor-mode.d.ts +32 -0
  95. package/dist/activities/execute-cursor/cursor-mode.js +36 -0
  96. package/dist/activities/execute-cursor/cursor-mode.js.map +1 -0
  97. package/dist/activities/execute-cursor/error-classifier.d.ts +138 -0
  98. package/dist/activities/execute-cursor/error-classifier.js +330 -0
  99. package/dist/activities/execute-cursor/error-classifier.js.map +1 -0
  100. package/dist/activities/execute-cursor/fetch-interceptor.d.ts +56 -0
  101. package/dist/activities/execute-cursor/fetch-interceptor.js +378 -0
  102. package/dist/activities/execute-cursor/fetch-interceptor.js.map +1 -0
  103. package/dist/activities/execute-cursor/hook-scope.d.ts +143 -0
  104. package/dist/activities/execute-cursor/hook-scope.js +149 -0
  105. package/dist/activities/execute-cursor/hook-scope.js.map +1 -0
  106. package/dist/activities/execute-cursor/hook-script.d.ts +172 -0
  107. package/dist/activities/execute-cursor/hook-script.js +1204 -0
  108. package/dist/activities/execute-cursor/hook-script.js.map +1 -0
  109. package/dist/activities/execute-cursor/hook-server.d.ts +152 -0
  110. package/dist/activities/execute-cursor/hook-server.js +422 -0
  111. package/dist/activities/execute-cursor/hook-server.js.map +1 -0
  112. package/dist/activities/execute-cursor/hook-tool-hiding.d.ts +37 -0
  113. package/dist/activities/execute-cursor/hook-tool-hiding.js +58 -0
  114. package/dist/activities/execute-cursor/hook-tool-hiding.js.map +1 -0
  115. package/dist/activities/execute-cursor/hook-views.d.ts +74 -0
  116. package/dist/activities/execute-cursor/hook-views.js +180 -0
  117. package/dist/activities/execute-cursor/hook-views.js.map +1 -0
  118. package/dist/activities/execute-cursor/http2-interceptor.d.ts +98 -0
  119. package/dist/activities/execute-cursor/http2-interceptor.js +218 -0
  120. package/dist/activities/execute-cursor/http2-interceptor.js.map +1 -0
  121. package/dist/activities/execute-cursor/model-pricing-data.d.ts +39 -0
  122. package/dist/activities/execute-cursor/model-pricing-data.js +109 -0
  123. package/dist/activities/execute-cursor/model-pricing-data.js.map +1 -0
  124. package/dist/activities/execute-cursor/model-pricing.d.ts +51 -0
  125. package/dist/activities/execute-cursor/model-pricing.js +160 -0
  126. package/dist/activities/execute-cursor/model-pricing.js.map +1 -0
  127. package/dist/activities/execute-cursor/prompt-builder.d.ts +437 -0
  128. package/dist/activities/execute-cursor/prompt-builder.js +719 -0
  129. package/dist/activities/execute-cursor/prompt-builder.js.map +1 -0
  130. package/dist/activities/execute-cursor/rejection-capture.d.ts +27 -0
  131. package/dist/activities/execute-cursor/rejection-capture.js +78 -0
  132. package/dist/activities/execute-cursor/rejection-capture.js.map +1 -0
  133. package/dist/activities/execute-cursor/run-telemetry.d.ts +61 -0
  134. package/dist/activities/execute-cursor/run-telemetry.js +149 -0
  135. package/dist/activities/execute-cursor/run-telemetry.js.map +1 -0
  136. package/dist/activities/execute-cursor/sdk-warmup.d.ts +53 -0
  137. package/dist/activities/execute-cursor/sdk-warmup.js +70 -0
  138. package/dist/activities/execute-cursor/sdk-warmup.js.map +1 -0
  139. package/dist/activities/execute-cursor/service-tier.d.ts +68 -0
  140. package/dist/activities/execute-cursor/service-tier.js +200 -0
  141. package/dist/activities/execute-cursor/service-tier.js.map +1 -0
  142. package/dist/activities/execute-cursor/session-lifecycle.d.ts +247 -0
  143. package/dist/activities/execute-cursor/session-lifecycle.js +330 -0
  144. package/dist/activities/execute-cursor/session-lifecycle.js.map +1 -0
  145. package/dist/activities/execute-cursor/session-store.d.ts +99 -0
  146. package/dist/activities/execute-cursor/session-store.js +156 -0
  147. package/dist/activities/execute-cursor/session-store.js.map +1 -0
  148. package/dist/activities/execute-cursor/sub-agent-steps.d.ts +79 -0
  149. package/dist/activities/execute-cursor/sub-agent-steps.js +180 -0
  150. package/dist/activities/execute-cursor/sub-agent-steps.js.map +1 -0
  151. package/dist/activities/execute-cursor/subagent-config.d.ts +61 -0
  152. package/dist/activities/execute-cursor/subagent-config.js +102 -0
  153. package/dist/activities/execute-cursor/subagent-config.js.map +1 -0
  154. package/dist/activities/execute-cursor/tool-result.d.ts +49 -0
  155. package/dist/activities/execute-cursor/tool-result.js +130 -0
  156. package/dist/activities/execute-cursor/tool-result.js.map +1 -0
  157. package/dist/activities/execute-cursor/translator.d.ts +183 -0
  158. package/dist/activities/execute-cursor/translator.js +485 -0
  159. package/dist/activities/execute-cursor/translator.js.map +1 -0
  160. package/dist/activities/execute-cursor/turn-boundary.d.ts +124 -0
  161. package/dist/activities/execute-cursor/turn-boundary.js +210 -0
  162. package/dist/activities/execute-cursor/turn-boundary.js.map +1 -0
  163. package/dist/activities/execute-cursor/turn-recovery.d.ts +62 -0
  164. package/dist/activities/execute-cursor/turn-recovery.js +208 -0
  165. package/dist/activities/execute-cursor/turn-recovery.js.map +1 -0
  166. package/dist/activities/execute-cursor/turn-settle.d.ts +59 -0
  167. package/dist/activities/execute-cursor/turn-settle.js +512 -0
  168. package/dist/activities/execute-cursor/turn-settle.js.map +1 -0
  169. package/dist/activities/execute-cursor/turn-setup.d.ts +281 -0
  170. package/dist/activities/execute-cursor/turn-setup.js +739 -0
  171. package/dist/activities/execute-cursor/turn-setup.js.map +1 -0
  172. package/dist/activities/execute-cursor/turn-stream.d.ts +133 -0
  173. package/dist/activities/execute-cursor/turn-stream.js +239 -0
  174. package/dist/activities/execute-cursor/turn-stream.js.map +1 -0
  175. package/dist/activities/execute-cursor/turn.d.ts +46 -0
  176. package/dist/activities/execute-cursor/turn.js +247 -0
  177. package/dist/activities/execute-cursor/turn.js.map +1 -0
  178. package/dist/activities/execute-cursor/usage-pricing.d.ts +38 -0
  179. package/dist/activities/execute-cursor/usage-pricing.js +50 -0
  180. package/dist/activities/execute-cursor/usage-pricing.js.map +1 -0
  181. package/dist/activities/execute-cursor/workspace-hook-files.d.ts +116 -0
  182. package/dist/activities/execute-cursor/workspace-hook-files.js +390 -0
  183. package/dist/activities/execute-cursor/workspace-hook-files.js.map +1 -0
  184. package/dist/activities/execute-cursor/workspace-setup.d.ts +148 -0
  185. package/dist/activities/execute-cursor/workspace-setup.js +444 -0
  186. package/dist/activities/execute-cursor/workspace-setup.js.map +1 -0
  187. package/dist/activities/execute-deep-agent/__test-utils__/contract-subject.d.ts +102 -0
  188. package/dist/activities/execute-deep-agent/__test-utils__/contract-subject.js +361 -0
  189. package/dist/activities/execute-deep-agent/__test-utils__/contract-subject.js.map +1 -0
  190. package/dist/activities/execute-deep-agent/__test-utils__/gateway-substrate.d.ts +33 -0
  191. package/dist/activities/execute-deep-agent/__test-utils__/gateway-substrate.js +423 -0
  192. package/dist/activities/execute-deep-agent/__test-utils__/gateway-substrate.js.map +1 -0
  193. package/dist/activities/execute-deep-agent/__test-utils__/hermetic-deep-agent.d.ts +224 -0
  194. package/dist/activities/execute-deep-agent/__test-utils__/hermetic-deep-agent.js +307 -0
  195. package/dist/activities/execute-deep-agent/__test-utils__/hermetic-deep-agent.js.map +1 -0
  196. package/dist/activities/execute-deep-agent/__test-utils__/hitl-script.d.ts +24 -0
  197. package/dist/activities/execute-deep-agent/__test-utils__/hitl-script.js +41 -0
  198. package/dist/activities/execute-deep-agent/__test-utils__/hitl-script.js.map +1 -0
  199. package/dist/activities/execute-deep-agent/__test-utils__/paused-session-fixture.d.ts +76 -0
  200. package/dist/activities/execute-deep-agent/__test-utils__/paused-session-fixture.js +112 -0
  201. package/dist/activities/execute-deep-agent/__test-utils__/paused-session-fixture.js.map +1 -0
  202. package/dist/activities/execute-deep-agent/__test-utils__/scripted-model-module.d.ts +53 -0
  203. package/dist/activities/execute-deep-agent/__test-utils__/scripted-model-module.js +71 -0
  204. package/dist/activities/execute-deep-agent/__test-utils__/scripted-model-module.js.map +1 -0
  205. package/dist/activities/execute-deep-agent/__test-utils__/scripted-model.d.ts +305 -0
  206. package/dist/activities/execute-deep-agent/__test-utils__/scripted-model.js +368 -0
  207. package/dist/activities/execute-deep-agent/__test-utils__/scripted-model.js.map +1 -0
  208. package/dist/activities/execute-deep-agent/__test-utils__/think-bound-session.d.ts +17 -0
  209. package/dist/activities/execute-deep-agent/__test-utils__/think-bound-session.js +23 -0
  210. package/dist/activities/execute-deep-agent/__test-utils__/think-bound-session.js.map +1 -0
  211. package/dist/activities/execute-deep-agent/__test-utils__/v3-event-fixtures.d.ts +80 -0
  212. package/dist/activities/execute-deep-agent/__test-utils__/v3-event-fixtures.js +195 -0
  213. package/dist/activities/execute-deep-agent/__test-utils__/v3-event-fixtures.js.map +1 -0
  214. package/dist/activities/execute-deep-agent/adapter.d.ts +41 -0
  215. package/dist/activities/execute-deep-agent/adapter.js +79 -0
  216. package/dist/activities/execute-deep-agent/adapter.js.map +1 -0
  217. package/dist/activities/execute-deep-agent/approval-file-change.d.ts +54 -0
  218. package/dist/activities/execute-deep-agent/approval-file-change.js +68 -0
  219. package/dist/activities/execute-deep-agent/approval-file-change.js.map +1 -0
  220. package/dist/activities/execute-deep-agent/auto-publish.d.ts +17 -0
  221. package/dist/activities/execute-deep-agent/auto-publish.js +71 -0
  222. package/dist/activities/execute-deep-agent/auto-publish.js.map +1 -0
  223. package/dist/activities/execute-deep-agent/cas-capture-backend.d.ts +84 -0
  224. package/dist/activities/execute-deep-agent/cas-capture-backend.js +106 -0
  225. package/dist/activities/execute-deep-agent/cas-capture-backend.js.map +1 -0
  226. package/dist/activities/execute-deep-agent/cas-capture-observer.d.ts +83 -0
  227. package/dist/activities/execute-deep-agent/cas-capture-observer.js +117 -0
  228. package/dist/activities/execute-deep-agent/cas-capture-observer.js.map +1 -0
  229. package/dist/activities/execute-deep-agent/deep-agent-capabilities.d.ts +32 -0
  230. package/dist/activities/execute-deep-agent/deep-agent-capabilities.js +45 -0
  231. package/dist/activities/execute-deep-agent/deep-agent-capabilities.js.map +1 -0
  232. package/dist/activities/execute-deep-agent/deepagents-profiles.d.ts +30 -0
  233. package/dist/activities/execute-deep-agent/deepagents-profiles.js +46 -0
  234. package/dist/activities/execute-deep-agent/deepagents-profiles.js.map +1 -0
  235. package/dist/activities/execute-deep-agent/engine-tools.d.ts +32 -0
  236. package/dist/activities/execute-deep-agent/engine-tools.js +32 -0
  237. package/dist/activities/execute-deep-agent/engine-tools.js.map +1 -0
  238. package/dist/activities/execute-deep-agent/hitl.d.ts +126 -0
  239. package/dist/activities/execute-deep-agent/hitl.js +194 -0
  240. package/dist/activities/execute-deep-agent/hitl.js.map +1 -0
  241. package/dist/activities/execute-deep-agent/hooks-setup.d.ts +25 -0
  242. package/dist/activities/execute-deep-agent/hooks-setup.js +59 -0
  243. package/dist/activities/execute-deep-agent/hooks-setup.js.map +1 -0
  244. package/dist/activities/execute-deep-agent/inline-publisher.d.ts +83 -0
  245. package/dist/activities/execute-deep-agent/inline-publisher.js +152 -0
  246. package/dist/activities/execute-deep-agent/inline-publisher.js.map +1 -0
  247. package/dist/activities/execute-deep-agent/platform-route.d.ts +145 -0
  248. package/dist/activities/execute-deep-agent/platform-route.js +237 -0
  249. package/dist/activities/execute-deep-agent/platform-route.js.map +1 -0
  250. package/dist/activities/execute-deep-agent/prompt-builder.d.ts +189 -0
  251. package/dist/activities/execute-deep-agent/prompt-builder.js +369 -0
  252. package/dist/activities/execute-deep-agent/prompt-builder.js.map +1 -0
  253. package/dist/activities/execute-deep-agent/resumed-history.d.ts +25 -0
  254. package/dist/activities/execute-deep-agent/resumed-history.js +47 -0
  255. package/dist/activities/execute-deep-agent/resumed-history.js.map +1 -0
  256. package/dist/activities/execute-deep-agent/streaming-side-effects.d.ts +49 -0
  257. package/dist/activities/execute-deep-agent/streaming-side-effects.js +73 -0
  258. package/dist/activities/execute-deep-agent/streaming-side-effects.js.map +1 -0
  259. package/dist/activities/execute-deep-agent/subagent-transformer.d.ts +253 -0
  260. package/dist/activities/execute-deep-agent/subagent-transformer.js +474 -0
  261. package/dist/activities/execute-deep-agent/subagent-transformer.js.map +1 -0
  262. package/dist/activities/execute-deep-agent/subagent-wiring.d.ts +99 -0
  263. package/dist/activities/execute-deep-agent/subagent-wiring.js +119 -0
  264. package/dist/activities/execute-deep-agent/subagent-wiring.js.map +1 -0
  265. package/dist/activities/execute-deep-agent/todo-list.d.ts +40 -0
  266. package/dist/activities/execute-deep-agent/todo-list.js +51 -0
  267. package/dist/activities/execute-deep-agent/todo-list.js.map +1 -0
  268. package/dist/activities/execute-deep-agent/translator.d.ts +167 -0
  269. package/dist/activities/execute-deep-agent/translator.js +521 -0
  270. package/dist/activities/execute-deep-agent/translator.js.map +1 -0
  271. package/dist/activities/execute-deep-agent/turn-settle.d.ts +48 -0
  272. package/dist/activities/execute-deep-agent/turn-settle.js +141 -0
  273. package/dist/activities/execute-deep-agent/turn-settle.js.map +1 -0
  274. package/dist/activities/execute-deep-agent/turn-setup.d.ts +281 -0
  275. package/dist/activities/execute-deep-agent/turn-setup.js +687 -0
  276. package/dist/activities/execute-deep-agent/turn-setup.js.map +1 -0
  277. package/dist/activities/execute-deep-agent/turn-stream.d.ts +105 -0
  278. package/dist/activities/execute-deep-agent/turn-stream.js +236 -0
  279. package/dist/activities/execute-deep-agent/turn-stream.js.map +1 -0
  280. package/dist/activities/execute-deep-agent/turn.d.ts +48 -0
  281. package/dist/activities/execute-deep-agent/turn.js +136 -0
  282. package/dist/activities/execute-deep-agent/turn.js.map +1 -0
  283. package/dist/activities/execute-deep-agent/v3-event-recorder.d.ts +32 -0
  284. package/dist/activities/execute-deep-agent/v3-event-recorder.js +72 -0
  285. package/dist/activities/execute-deep-agent/v3-event-recorder.js.map +1 -0
  286. package/dist/activities/generate-session-subject.d.ts +93 -0
  287. package/dist/activities/generate-session-subject.js +285 -0
  288. package/dist/activities/generate-session-subject.js.map +1 -0
  289. package/dist/activities/list-plugin-tools.d.ts +76 -0
  290. package/dist/activities/list-plugin-tools.js +170 -0
  291. package/dist/activities/list-plugin-tools.js.map +1 -0
  292. package/dist/agent-host/channel.d.ts +93 -0
  293. package/dist/agent-host/channel.js +332 -0
  294. package/dist/agent-host/channel.js.map +1 -0
  295. package/dist/agent-host/codec.d.ts +290 -0
  296. package/dist/agent-host/codec.js +437 -0
  297. package/dist/agent-host/codec.js.map +1 -0
  298. package/dist/agent-host/entry.d.ts +56 -0
  299. package/dist/agent-host/entry.js +137 -0
  300. package/dist/agent-host/entry.js.map +1 -0
  301. package/dist/agent-host/environment.d.ts +36 -0
  302. package/dist/agent-host/environment.js +72 -0
  303. package/dist/agent-host/environment.js.map +1 -0
  304. package/dist/agent-host/failed-boot.d.ts +15 -0
  305. package/dist/agent-host/failed-boot.js +26 -0
  306. package/dist/agent-host/failed-boot.js.map +1 -0
  307. package/dist/agent-host/fs-service.d.ts +18 -0
  308. package/dist/agent-host/fs-service.js +133 -0
  309. package/dist/agent-host/fs-service.js.map +1 -0
  310. package/dist/agent-host/host-sink.d.ts +63 -0
  311. package/dist/agent-host/host-sink.js +136 -0
  312. package/dist/agent-host/host-sink.js.map +1 -0
  313. package/dist/agent-host/host.d.ts +48 -0
  314. package/dist/agent-host/host.js +191 -0
  315. package/dist/agent-host/host.js.map +1 -0
  316. package/dist/agent-host/hosting.d.ts +80 -0
  317. package/dist/agent-host/hosting.js +126 -0
  318. package/dist/agent-host/hosting.js.map +1 -0
  319. package/dist/agent-host/protocol.d.ts +478 -0
  320. package/dist/agent-host/protocol.js +77 -0
  321. package/dist/agent-host/protocol.js.map +1 -0
  322. package/dist/agent-host/remote-adapter.d.ts +64 -0
  323. package/dist/agent-host/remote-adapter.js +283 -0
  324. package/dist/agent-host/remote-adapter.js.map +1 -0
  325. package/dist/agent-host/remote-fs.d.ts +19 -0
  326. package/dist/agent-host/remote-fs.js +120 -0
  327. package/dist/agent-host/remote-fs.js.map +1 -0
  328. package/dist/agent-host/supervisor.d.ts +149 -0
  329. package/dist/agent-host/supervisor.js +311 -0
  330. package/dist/agent-host/supervisor.js.map +1 -0
  331. package/dist/agent-proxy/cursor-lane.d.ts +124 -0
  332. package/dist/agent-proxy/cursor-lane.js +507 -0
  333. package/dist/agent-proxy/cursor-lane.js.map +1 -0
  334. package/dist/agent-proxy/lanes.d.ts +63 -0
  335. package/dist/agent-proxy/lanes.js +255 -0
  336. package/dist/agent-proxy/lanes.js.map +1 -0
  337. package/dist/agent-proxy/loopback-certificate.d.ts +27 -0
  338. package/dist/agent-proxy/loopback-certificate.js +115 -0
  339. package/dist/agent-proxy/loopback-certificate.js.map +1 -0
  340. package/dist/agent-proxy/otlp-forward.d.ts +67 -0
  341. package/dist/agent-proxy/otlp-forward.js +170 -0
  342. package/dist/agent-proxy/otlp-forward.js.map +1 -0
  343. package/dist/agent-proxy/relay.d.ts +67 -0
  344. package/dist/agent-proxy/relay.js +164 -0
  345. package/dist/agent-proxy/relay.js.map +1 -0
  346. package/dist/agent-proxy/server.d.ts +84 -0
  347. package/dist/agent-proxy/server.js +258 -0
  348. package/dist/agent-proxy/server.js.map +1 -0
  349. package/dist/attach/entry.d.ts +36 -0
  350. package/dist/attach/entry.js +69 -0
  351. package/dist/attach/entry.js.map +1 -0
  352. package/dist/attach/main.d.ts +14 -0
  353. package/dist/attach/main.js +25 -0
  354. package/dist/attach/main.js.map +1 -0
  355. package/dist/attach/push.d.ts +71 -0
  356. package/dist/attach/push.js +123 -0
  357. package/dist/attach/push.js.map +1 -0
  358. package/dist/attach/waiter.d.ts +108 -0
  359. package/dist/attach/waiter.js +323 -0
  360. package/dist/attach/waiter.js.map +1 -0
  361. package/dist/bootstrap.d.ts +80 -0
  362. package/dist/bootstrap.js +119 -0
  363. package/dist/bootstrap.js.map +1 -0
  364. package/dist/client/server-contracts.d.ts +51 -0
  365. package/dist/client/server-contracts.js +70 -0
  366. package/dist/client/server-contracts.js.map +1 -0
  367. package/dist/client/stigmer-client.d.ts +328 -0
  368. package/dist/client/stigmer-client.js +478 -0
  369. package/dist/client/stigmer-client.js.map +1 -0
  370. package/dist/client/token-claims.d.ts +40 -0
  371. package/dist/client/token-claims.js +88 -0
  372. package/dist/client/token-claims.js.map +1 -0
  373. package/dist/config.d.ts +216 -0
  374. package/dist/config.js +200 -0
  375. package/dist/config.js.map +1 -0
  376. package/dist/exit-backstop.d.ts +64 -0
  377. package/dist/exit-backstop.js +79 -0
  378. package/dist/exit-backstop.js.map +1 -0
  379. package/dist/gen/turn/ai/stigmer/runner/turn/v1/enum_pb.d.ts +1016 -0
  380. package/dist/gen/turn/ai/stigmer/runner/turn/v1/enum_pb.js +1035 -0
  381. package/dist/gen/turn/ai/stigmer/runner/turn/v1/enum_pb.js.map +1 -0
  382. package/dist/gen/turn/ai/stigmer/runner/turn/v1/ledger_pb.d.ts +402 -0
  383. package/dist/gen/turn/ai/stigmer/runner/turn/v1/ledger_pb.js +47 -0
  384. package/dist/gen/turn/ai/stigmer/runner/turn/v1/ledger_pb.js.map +1 -0
  385. package/dist/gen/turn/ai/stigmer/runner/turn/v1/rows_pb.d.ts +826 -0
  386. package/dist/gen/turn/ai/stigmer/runner/turn/v1/rows_pb.js +48 -0
  387. package/dist/gen/turn/ai/stigmer/runner/turn/v1/rows_pb.js.map +1 -0
  388. package/dist/gen-ai-conventions.d.ts +95 -0
  389. package/dist/gen-ai-conventions.js +102 -0
  390. package/dist/gen-ai-conventions.js.map +1 -0
  391. package/dist/harness/approval-answers.d.ts +104 -0
  392. package/dist/harness/approval-answers.js +136 -0
  393. package/dist/harness/approval-answers.js.map +1 -0
  394. package/dist/harness/approval-decisions.d.ts +50 -0
  395. package/dist/harness/approval-decisions.js +80 -0
  396. package/dist/harness/approval-decisions.js.map +1 -0
  397. package/dist/harness/capabilities.d.ts +149 -0
  398. package/dist/harness/capabilities.js +48 -0
  399. package/dist/harness/capabilities.js.map +1 -0
  400. package/dist/harness/capture.d.ts +154 -0
  401. package/dist/harness/capture.js +248 -0
  402. package/dist/harness/capture.js.map +1 -0
  403. package/dist/harness/cost-cap-watch.d.ts +31 -0
  404. package/dist/harness/cost-cap-watch.js +44 -0
  405. package/dist/harness/cost-cap-watch.js.map +1 -0
  406. package/dist/harness/events/emitter.d.ts +220 -0
  407. package/dist/harness/events/emitter.js +726 -0
  408. package/dist/harness/events/emitter.js.map +1 -0
  409. package/dist/harness/events/ids.d.ts +88 -0
  410. package/dist/harness/events/ids.js +136 -0
  411. package/dist/harness/events/ids.js.map +1 -0
  412. package/dist/harness/loaded-versions.d.ts +20 -0
  413. package/dist/harness/loaded-versions.js +70 -0
  414. package/dist/harness/loaded-versions.js.map +1 -0
  415. package/dist/harness/owed-undos.d.ts +119 -0
  416. package/dist/harness/owed-undos.js +200 -0
  417. package/dist/harness/owed-undos.js.map +1 -0
  418. package/dist/harness/persist-chokepoint.d.ts +113 -0
  419. package/dist/harness/persist-chokepoint.js +126 -0
  420. package/dist/harness/persist-chokepoint.js.map +1 -0
  421. package/dist/harness/registry.d.ts +108 -0
  422. package/dist/harness/registry.js +174 -0
  423. package/dist/harness/registry.js.map +1 -0
  424. package/dist/harness/run-span.d.ts +78 -0
  425. package/dist/harness/run-span.js +139 -0
  426. package/dist/harness/run-span.js.map +1 -0
  427. package/dist/harness/run-turn.d.ts +59 -0
  428. package/dist/harness/run-turn.js +749 -0
  429. package/dist/harness/run-turn.js.map +1 -0
  430. package/dist/harness/stop-controller.d.ts +65 -0
  431. package/dist/harness/stop-controller.js +70 -0
  432. package/dist/harness/stop-controller.js.map +1 -0
  433. package/dist/harness/terminal-table.d.ts +212 -0
  434. package/dist/harness/terminal-table.js +329 -0
  435. package/dist/harness/terminal-table.js.map +1 -0
  436. package/dist/harness/transcript/builder.d.ts +269 -0
  437. package/dist/harness/transcript/builder.js +842 -0
  438. package/dist/harness/transcript/builder.js.map +1 -0
  439. package/dist/harness/transcript/events.d.ts +236 -0
  440. package/dist/harness/transcript/events.js +55 -0
  441. package/dist/harness/transcript/events.js.map +1 -0
  442. package/dist/harness/transcript/resume-seed.d.ts +67 -0
  443. package/dist/harness/transcript/resume-seed.js +228 -0
  444. package/dist/harness/transcript/resume-seed.js.map +1 -0
  445. package/dist/harness/transcript/state.d.ts +111 -0
  446. package/dist/harness/transcript/state.js +147 -0
  447. package/dist/harness/transcript/state.js.map +1 -0
  448. package/dist/harness/turn-context.d.ts +923 -0
  449. package/dist/harness/turn-context.js +1448 -0
  450. package/dist/harness/turn-context.js.map +1 -0
  451. package/dist/harness/turn-timeline.d.ts +132 -0
  452. package/dist/harness/turn-timeline.js +213 -0
  453. package/dist/harness/turn-timeline.js.map +1 -0
  454. package/dist/harness/types.d.ts +700 -0
  455. package/dist/harness/types.js +72 -0
  456. package/dist/harness/types.js.map +1 -0
  457. package/dist/harness/usage-accumulator.d.ts +76 -0
  458. package/dist/harness/usage-accumulator.js +112 -0
  459. package/dist/harness/usage-accumulator.js.map +1 -0
  460. package/dist/harness-adapters.d.ts +40 -0
  461. package/dist/harness-adapters.js +45 -0
  462. package/dist/harness-adapters.js.map +1 -0
  463. package/dist/idle-watchdog.d.ts +11 -0
  464. package/dist/idle-watchdog.js +24 -0
  465. package/dist/idle-watchdog.js.map +1 -0
  466. package/dist/in-flight.d.ts +35 -0
  467. package/dist/in-flight.js +61 -0
  468. package/dist/in-flight.js.map +1 -0
  469. package/dist/index.d.ts +43 -0
  470. package/dist/index.js +42 -0
  471. package/dist/index.js.map +1 -0
  472. package/dist/interceptors/run-credential-activity.d.ts +24 -0
  473. package/dist/interceptors/run-credential-activity.js +36 -0
  474. package/dist/interceptors/run-credential-activity.js.map +1 -0
  475. package/dist/ipc-protocol-fixtures.d.ts +28 -0
  476. package/dist/ipc-protocol-fixtures.js +50 -0
  477. package/dist/ipc-protocol-fixtures.js.map +1 -0
  478. package/dist/ipc-protocol.d.ts +43 -0
  479. package/dist/ipc-protocol.js +20 -0
  480. package/dist/ipc-protocol.js.map +1 -0
  481. package/dist/main.d.ts +26 -0
  482. package/dist/main.js +451 -0
  483. package/dist/main.js.map +1 -0
  484. package/dist/middleware/advisory-message.d.ts +52 -0
  485. package/dist/middleware/advisory-message.js +58 -0
  486. package/dist/middleware/advisory-message.js.map +1 -0
  487. package/dist/middleware/approval-gate.d.ts +255 -0
  488. package/dist/middleware/approval-gate.js +502 -0
  489. package/dist/middleware/approval-gate.js.map +1 -0
  490. package/dist/middleware/cost-advisory.d.ts +65 -0
  491. package/dist/middleware/cost-advisory.js +185 -0
  492. package/dist/middleware/cost-advisory.js.map +1 -0
  493. package/dist/middleware/error-hints.d.ts +27 -0
  494. package/dist/middleware/error-hints.js +116 -0
  495. package/dist/middleware/error-hints.js.map +1 -0
  496. package/dist/middleware/execution-budget.d.ts +38 -0
  497. package/dist/middleware/execution-budget.js +168 -0
  498. package/dist/middleware/execution-budget.js.map +1 -0
  499. package/dist/middleware/index.d.ts +55 -0
  500. package/dist/middleware/index.js +80 -0
  501. package/dist/middleware/index.js.map +1 -0
  502. package/dist/middleware/loop-detection.d.ts +22 -0
  503. package/dist/middleware/loop-detection.js +161 -0
  504. package/dist/middleware/loop-detection.js.map +1 -0
  505. package/dist/middleware/otel-spans.d.ts +43 -0
  506. package/dist/middleware/otel-spans.js +281 -0
  507. package/dist/middleware/otel-spans.js.map +1 -0
  508. package/dist/middleware/path-normalization.d.ts +84 -0
  509. package/dist/middleware/path-normalization.js +161 -0
  510. package/dist/middleware/path-normalization.js.map +1 -0
  511. package/dist/middleware/tool-intent.d.ts +57 -0
  512. package/dist/middleware/tool-intent.js +152 -0
  513. package/dist/middleware/tool-intent.js.map +1 -0
  514. package/dist/middleware/tool-scope.d.ts +119 -0
  515. package/dist/middleware/tool-scope.js +159 -0
  516. package/dist/middleware/tool-scope.js.map +1 -0
  517. package/dist/middleware/tool-truncation.d.ts +16 -0
  518. package/dist/middleware/tool-truncation.js +67 -0
  519. package/dist/middleware/tool-truncation.js.map +1 -0
  520. package/dist/middleware/types.d.ts +119 -0
  521. package/dist/middleware/types.js +10 -0
  522. package/dist/middleware/types.js.map +1 -0
  523. package/dist/otel-export.d.ts +142 -0
  524. package/dist/otel-export.js +269 -0
  525. package/dist/otel-export.js.map +1 -0
  526. package/dist/otel-metrics.d.ts +22 -0
  527. package/dist/otel-metrics.js +47 -0
  528. package/dist/otel-metrics.js.map +1 -0
  529. package/dist/otel.d.ts +49 -0
  530. package/dist/otel.js +125 -0
  531. package/dist/otel.js.map +1 -0
  532. package/dist/payload-codecs.d.ts +17 -0
  533. package/dist/payload-codecs.js +45 -0
  534. package/dist/payload-codecs.js.map +1 -0
  535. package/dist/pipe-safety.d.ts +55 -0
  536. package/dist/pipe-safety.js +103 -0
  537. package/dist/pipe-safety.js.map +1 -0
  538. package/dist/pool-member.d.ts +61 -0
  539. package/dist/pool-member.js +51 -0
  540. package/dist/pool-member.js.map +1 -0
  541. package/dist/preflight.d.ts +77 -0
  542. package/dist/preflight.js +98 -0
  543. package/dist/preflight.js.map +1 -0
  544. package/dist/run-trace-id.d.ts +34 -0
  545. package/dist/run-trace-id.js +44 -0
  546. package/dist/run-trace-id.js.map +1 -0
  547. package/dist/runner-entry.d.ts +15 -0
  548. package/dist/runner-entry.js +17 -0
  549. package/dist/runner-entry.js.map +1 -0
  550. package/dist/runner-manager.d.ts +160 -0
  551. package/dist/runner-manager.js +590 -0
  552. package/dist/runner-manager.js.map +1 -0
  553. package/dist/runner-token-coordinator.d.ts +61 -0
  554. package/dist/runner-token-coordinator.js +89 -0
  555. package/dist/runner-token-coordinator.js.map +1 -0
  556. package/dist/runner.d.ts +155 -0
  557. package/dist/runner.js +392 -0
  558. package/dist/runner.js.map +1 -0
  559. package/dist/sandbox-token-renewal.d.ts +64 -0
  560. package/dist/sandbox-token-renewal.js +168 -0
  561. package/dist/sandbox-token-renewal.js.map +1 -0
  562. package/dist/shared/activity-input.d.ts +52 -0
  563. package/dist/shared/activity-input.js +34 -0
  564. package/dist/shared/activity-input.js.map +1 -0
  565. package/dist/shared/agent-fs.d.ts +144 -0
  566. package/dist/shared/agent-fs.js +171 -0
  567. package/dist/shared/agent-fs.js.map +1 -0
  568. package/dist/shared/agent-handover.d.ts +42 -0
  569. package/dist/shared/agent-handover.js +156 -0
  570. package/dist/shared/agent-handover.js.map +1 -0
  571. package/dist/shared/agent-identity.d.ts +96 -0
  572. package/dist/shared/agent-identity.js +153 -0
  573. package/dist/shared/agent-identity.js.map +1 -0
  574. package/dist/shared/agent-servers.d.ts +4 -0
  575. package/dist/shared/agent-servers.js +46 -0
  576. package/dist/shared/agent-servers.js.map +1 -0
  577. package/dist/shared/approval-canonicalize.d.ts +19 -0
  578. package/dist/shared/approval-canonicalize.js +119 -0
  579. package/dist/shared/approval-canonicalize.js.map +1 -0
  580. package/dist/shared/approval-fingerprint.d.ts +103 -0
  581. package/dist/shared/approval-fingerprint.js +110 -0
  582. package/dist/shared/approval-fingerprint.js.map +1 -0
  583. package/dist/shared/approval-policy.d.ts +323 -0
  584. package/dist/shared/approval-policy.js +375 -0
  585. package/dist/shared/approval-policy.js.map +1 -0
  586. package/dist/shared/archive-mount.d.ts +68 -0
  587. package/dist/shared/archive-mount.js +108 -0
  588. package/dist/shared/archive-mount.js.map +1 -0
  589. package/dist/shared/args-preview.d.ts +90 -0
  590. package/dist/shared/args-preview.js +121 -0
  591. package/dist/shared/args-preview.js.map +1 -0
  592. package/dist/shared/artifact-storage.d.ts +155 -0
  593. package/dist/shared/artifact-storage.js +373 -0
  594. package/dist/shared/artifact-storage.js.map +1 -0
  595. package/dist/shared/attachment-download-urls.d.ts +53 -0
  596. package/dist/shared/attachment-download-urls.js +68 -0
  597. package/dist/shared/attachment-download-urls.js.map +1 -0
  598. package/dist/shared/attachment-naming.d.ts +53 -0
  599. package/dist/shared/attachment-naming.js +59 -0
  600. package/dist/shared/attachment-naming.js.map +1 -0
  601. package/dist/shared/attachment-resolver.d.ts +124 -0
  602. package/dist/shared/attachment-resolver.js +322 -0
  603. package/dist/shared/attachment-resolver.js.map +1 -0
  604. package/dist/shared/attachment-vision.d.ts +245 -0
  605. package/dist/shared/attachment-vision.js +339 -0
  606. package/dist/shared/attachment-vision.js.map +1 -0
  607. package/dist/shared/attachment-zip.d.ts +85 -0
  608. package/dist/shared/attachment-zip.js +185 -0
  609. package/dist/shared/attachment-zip.js.map +1 -0
  610. package/dist/shared/blueprint-resolver.d.ts +175 -0
  611. package/dist/shared/blueprint-resolver.js +305 -0
  612. package/dist/shared/blueprint-resolver.js.map +1 -0
  613. package/dist/shared/builtin-assistant-prompt.d.ts +30 -0
  614. package/dist/shared/builtin-assistant-prompt.js +36 -0
  615. package/dist/shared/builtin-assistant-prompt.js.map +1 -0
  616. package/dist/shared/builtin-judge.d.ts +9 -0
  617. package/dist/shared/builtin-judge.js +53 -0
  618. package/dist/shared/builtin-judge.js.map +1 -0
  619. package/dist/shared/caller-identity.d.ts +112 -0
  620. package/dist/shared/caller-identity.js +150 -0
  621. package/dist/shared/caller-identity.js.map +1 -0
  622. package/dist/shared/channel-attachment.d.ts +90 -0
  623. package/dist/shared/channel-attachment.js +209 -0
  624. package/dist/shared/channel-attachment.js.map +1 -0
  625. package/dist/shared/checkpointer/factory.d.ts +32 -0
  626. package/dist/shared/checkpointer/factory.js +72 -0
  627. package/dist/shared/checkpointer/factory.js.map +1 -0
  628. package/dist/shared/checkpointer/http-saver.d.ts +70 -0
  629. package/dist/shared/checkpointer/http-saver.js +335 -0
  630. package/dist/shared/checkpointer/http-saver.js.map +1 -0
  631. package/dist/shared/checkpointer/sqlite-saver.d.ts +54 -0
  632. package/dist/shared/checkpointer/sqlite-saver.js +272 -0
  633. package/dist/shared/checkpointer/sqlite-saver.js.map +1 -0
  634. package/dist/shared/checkpointer/types.d.ts +25 -0
  635. package/dist/shared/checkpointer/types.js +18 -0
  636. package/dist/shared/checkpointer/types.js.map +1 -0
  637. package/dist/shared/cold-start-timing.d.ts +124 -0
  638. package/dist/shared/cold-start-timing.js +220 -0
  639. package/dist/shared/cold-start-timing.js.map +1 -0
  640. package/dist/shared/context-bridge.d.ts +30 -0
  641. package/dist/shared/context-bridge.js +45 -0
  642. package/dist/shared/context-bridge.js.map +1 -0
  643. package/dist/shared/conversation-attachment.d.ts +103 -0
  644. package/dist/shared/conversation-attachment.js +128 -0
  645. package/dist/shared/conversation-attachment.js.map +1 -0
  646. package/dist/shared/conversation-catchup.d.ts +40 -0
  647. package/dist/shared/conversation-catchup.js +86 -0
  648. package/dist/shared/conversation-catchup.js.map +1 -0
  649. package/dist/shared/cost-guard.d.ts +51 -0
  650. package/dist/shared/cost-guard.js +58 -0
  651. package/dist/shared/cost-guard.js.map +1 -0
  652. package/dist/shared/declared-preferences.d.ts +47 -0
  653. package/dist/shared/declared-preferences.js +64 -0
  654. package/dist/shared/declared-preferences.js.map +1 -0
  655. package/dist/shared/eval-case/agent-mock.d.ts +61 -0
  656. package/dist/shared/eval-case/agent-mock.js +88 -0
  657. package/dist/shared/eval-case/agent-mock.js.map +1 -0
  658. package/dist/shared/eval-case/case-archive.d.ts +51 -0
  659. package/dist/shared/eval-case/case-archive.js +119 -0
  660. package/dist/shared/eval-case/case-archive.js.map +1 -0
  661. package/dist/shared/eval-case/mock-endpoint.d.ts +68 -0
  662. package/dist/shared/eval-case/mock-endpoint.js +209 -0
  663. package/dist/shared/eval-case/mock-endpoint.js.map +1 -0
  664. package/dist/shared/eval-case/prepare-case.d.ts +78 -0
  665. package/dist/shared/eval-case/prepare-case.js +193 -0
  666. package/dist/shared/eval-case/prepare-case.js.map +1 -0
  667. package/dist/shared/eval-case/read-files.d.ts +26 -0
  668. package/dist/shared/eval-case/read-files.js +88 -0
  669. package/dist/shared/eval-case/read-files.js.map +1 -0
  670. package/dist/shared/exact-apply.d.ts +109 -0
  671. package/dist/shared/exact-apply.js +205 -0
  672. package/dist/shared/exact-apply.js.map +1 -0
  673. package/dist/shared/execution-context.d.ts +47 -0
  674. package/dist/shared/execution-context.js +51 -0
  675. package/dist/shared/execution-context.js.map +1 -0
  676. package/dist/shared/execution-target.d.ts +13 -0
  677. package/dist/shared/execution-target.js +15 -0
  678. package/dist/shared/execution-target.js.map +1 -0
  679. package/dist/shared/extract-json.d.ts +26 -0
  680. package/dist/shared/extract-json.js +140 -0
  681. package/dist/shared/extract-json.js.map +1 -0
  682. package/dist/shared/extract-structured-output.d.ts +38 -0
  683. package/dist/shared/extract-structured-output.js +68 -0
  684. package/dist/shared/extract-structured-output.js.map +1 -0
  685. package/dist/shared/file-change.d.ts +42 -0
  686. package/dist/shared/file-change.js +55 -0
  687. package/dist/shared/file-change.js.map +1 -0
  688. package/dist/shared/file-tools.d.ts +105 -0
  689. package/dist/shared/file-tools.js +166 -0
  690. package/dist/shared/file-tools.js.map +1 -0
  691. package/dist/shared/filereview/capture.d.ts +238 -0
  692. package/dist/shared/filereview/capture.js +559 -0
  693. package/dist/shared/filereview/capture.js.map +1 -0
  694. package/dist/shared/filereview/cas-progress.d.ts +45 -0
  695. package/dist/shared/filereview/cas-progress.js +131 -0
  696. package/dist/shared/filereview/cas-progress.js.map +1 -0
  697. package/dist/shared/filereview/cas-substrate.d.ts +226 -0
  698. package/dist/shared/filereview/cas-substrate.js +315 -0
  699. package/dist/shared/filereview/cas-substrate.js.map +1 -0
  700. package/dist/shared/filereview/cas-touched.d.ts +56 -0
  701. package/dist/shared/filereview/cas-touched.js +63 -0
  702. package/dist/shared/filereview/cas-touched.js.map +1 -0
  703. package/dist/shared/filereview/command-provenance.d.ts +95 -0
  704. package/dist/shared/filereview/command-provenance.js +134 -0
  705. package/dist/shared/filereview/command-provenance.js.map +1 -0
  706. package/dist/shared/filereview/digest.d.ts +40 -0
  707. package/dist/shared/filereview/digest.js +66 -0
  708. package/dist/shared/filereview/digest.js.map +1 -0
  709. package/dist/shared/filereview/events.d.ts +199 -0
  710. package/dist/shared/filereview/events.js +348 -0
  711. package/dist/shared/filereview/events.js.map +1 -0
  712. package/dist/shared/filereview/git-substrate.d.ts +233 -0
  713. package/dist/shared/filereview/git-substrate.js +528 -0
  714. package/dist/shared/filereview/git-substrate.js.map +1 -0
  715. package/dist/shared/filereview/index.d.ts +15 -0
  716. package/dist/shared/filereview/index.js +16 -0
  717. package/dist/shared/filereview/index.js.map +1 -0
  718. package/dist/shared/filereview/line-counts.d.ts +48 -0
  719. package/dist/shared/filereview/line-counts.js +72 -0
  720. package/dist/shared/filereview/line-counts.js.map +1 -0
  721. package/dist/shared/filereview/progress.d.ts +200 -0
  722. package/dist/shared/filereview/progress.js +245 -0
  723. package/dist/shared/filereview/progress.js.map +1 -0
  724. package/dist/shared/filereview/record.d.ts +53 -0
  725. package/dist/shared/filereview/record.js +104 -0
  726. package/dist/shared/filereview/record.js.map +1 -0
  727. package/dist/shared/filereview/secret-paths.d.ts +61 -0
  728. package/dist/shared/filereview/secret-paths.js +103 -0
  729. package/dist/shared/filereview/secret-paths.js.map +1 -0
  730. package/dist/shared/fingerprint-secret.d.ts +35 -0
  731. package/dist/shared/fingerprint-secret.js +68 -0
  732. package/dist/shared/fingerprint-secret.js.map +1 -0
  733. package/dist/shared/grpc-retry.d.ts +28 -0
  734. package/dist/shared/grpc-retry.js +39 -0
  735. package/dist/shared/grpc-retry.js.map +1 -0
  736. package/dist/shared/heartbeat.d.ts +24 -0
  737. package/dist/shared/heartbeat.js +40 -0
  738. package/dist/shared/heartbeat.js.map +1 -0
  739. package/dist/shared/hooks/answer.d.ts +49 -0
  740. package/dist/shared/hooks/answer.js +152 -0
  741. package/dist/shared/hooks/answer.js.map +1 -0
  742. package/dist/shared/hooks/condition.d.ts +71 -0
  743. package/dist/shared/hooks/condition.js +341 -0
  744. package/dist/shared/hooks/condition.js.map +1 -0
  745. package/dist/shared/hooks/evaluate.d.ts +125 -0
  746. package/dist/shared/hooks/evaluate.js +253 -0
  747. package/dist/shared/hooks/evaluate.js.map +1 -0
  748. package/dist/shared/hooks/formats/claude-code.d.ts +43 -0
  749. package/dist/shared/hooks/formats/claude-code.js +90 -0
  750. package/dist/shared/hooks/formats/claude-code.js.map +1 -0
  751. package/dist/shared/hooks/formats/common.d.ts +30 -0
  752. package/dist/shared/hooks/formats/common.js +7 -0
  753. package/dist/shared/hooks/formats/common.js.map +1 -0
  754. package/dist/shared/hooks/formats/cursor.d.ts +72 -0
  755. package/dist/shared/hooks/formats/cursor.js +238 -0
  756. package/dist/shared/hooks/formats/cursor.js.map +1 -0
  757. package/dist/shared/hooks/hook-set.d.ts +84 -0
  758. package/dist/shared/hooks/hook-set.js +80 -0
  759. package/dist/shared/hooks/hook-set.js.map +1 -0
  760. package/dist/shared/hooks/matcher.d.ts +14 -0
  761. package/dist/shared/hooks/matcher.js +32 -0
  762. package/dist/shared/hooks/matcher.js.map +1 -0
  763. package/dist/shared/hooks/messages.d.ts +19 -0
  764. package/dist/shared/hooks/messages.js +34 -0
  765. package/dist/shared/hooks/messages.js.map +1 -0
  766. package/dist/shared/hooks/run.d.ts +89 -0
  767. package/dist/shared/hooks/run.js +146 -0
  768. package/dist/shared/hooks/run.js.map +1 -0
  769. package/dist/shared/hooks/setup.d.ts +73 -0
  770. package/dist/shared/hooks/setup.js +166 -0
  771. package/dist/shared/hooks/setup.js.map +1 -0
  772. package/dist/shared/hooks/shell-commands.d.ts +39 -0
  773. package/dist/shared/hooks/shell-commands.js +326 -0
  774. package/dist/shared/hooks/shell-commands.js.map +1 -0
  775. package/dist/shared/hooks/tool-view.d.ts +164 -0
  776. package/dist/shared/hooks/tool-view.js +310 -0
  777. package/dist/shared/hooks/tool-view.js.map +1 -0
  778. package/dist/shared/http-retry.d.ts +85 -0
  779. package/dist/shared/http-retry.js +101 -0
  780. package/dist/shared/http-retry.js.map +1 -0
  781. package/dist/shared/implement-plan-prompt.d.ts +44 -0
  782. package/dist/shared/implement-plan-prompt.js +98 -0
  783. package/dist/shared/implement-plan-prompt.js.map +1 -0
  784. package/dist/shared/json-schema-to-zod.d.ts +13 -0
  785. package/dist/shared/json-schema-to-zod.js +49 -0
  786. package/dist/shared/json-schema-to-zod.js.map +1 -0
  787. package/dist/shared/llm-backend.d.ts +303 -0
  788. package/dist/shared/llm-backend.js +491 -0
  789. package/dist/shared/llm-backend.js.map +1 -0
  790. package/dist/shared/llm-proxy.d.ts +64 -0
  791. package/dist/shared/llm-proxy.js +131 -0
  792. package/dist/shared/llm-proxy.js.map +1 -0
  793. package/dist/shared/mcp-manager.d.ts +61 -0
  794. package/dist/shared/mcp-manager.js +131 -0
  795. package/dist/shared/mcp-manager.js.map +1 -0
  796. package/dist/shared/mcp-oauth-detect.d.ts +23 -0
  797. package/dist/shared/mcp-oauth-detect.js +72 -0
  798. package/dist/shared/mcp-oauth-detect.js.map +1 -0
  799. package/dist/shared/mcp-resolver.d.ts +145 -0
  800. package/dist/shared/mcp-resolver.js +238 -0
  801. package/dist/shared/mcp-resolver.js.map +1 -0
  802. package/dist/shared/mcp-schema-sanitizer.d.ts +68 -0
  803. package/dist/shared/mcp-schema-sanitizer.js +195 -0
  804. package/dist/shared/mcp-schema-sanitizer.js.map +1 -0
  805. package/dist/shared/mcp-tool-listing.d.ts +80 -0
  806. package/dist/shared/mcp-tool-listing.js +166 -0
  807. package/dist/shared/mcp-tool-listing.js.map +1 -0
  808. package/dist/shared/mcp-transport-guard.d.ts +53 -0
  809. package/dist/shared/mcp-transport-guard.js +70 -0
  810. package/dist/shared/mcp-transport-guard.js.map +1 -0
  811. package/dist/shared/memory-attachment.d.ts +103 -0
  812. package/dist/shared/memory-attachment.js +142 -0
  813. package/dist/shared/memory-attachment.js.map +1 -0
  814. package/dist/shared/memory-retrieval.d.ts +126 -0
  815. package/dist/shared/memory-retrieval.js +293 -0
  816. package/dist/shared/memory-retrieval.js.map +1 -0
  817. package/dist/shared/model-client.d.ts +111 -0
  818. package/dist/shared/model-client.js +328 -0
  819. package/dist/shared/model-client.js.map +1 -0
  820. package/dist/shared/model-error.d.ts +94 -0
  821. package/dist/shared/model-error.js +475 -0
  822. package/dist/shared/model-error.js.map +1 -0
  823. package/dist/shared/model-facts.d.ts +21 -0
  824. package/dist/shared/model-facts.js +22 -0
  825. package/dist/shared/model-facts.js.map +1 -0
  826. package/dist/shared/model-lanes.d.ts +48 -0
  827. package/dist/shared/model-lanes.js +52 -0
  828. package/dist/shared/model-lanes.js.map +1 -0
  829. package/dist/shared/model-pricing-data.d.ts +20 -0
  830. package/dist/shared/model-pricing-data.js +82 -0
  831. package/dist/shared/model-pricing-data.js.map +1 -0
  832. package/dist/shared/model-pricing.d.ts +16 -0
  833. package/dist/shared/model-pricing.js +46 -0
  834. package/dist/shared/model-pricing.js.map +1 -0
  835. package/dist/shared/model-registry.d.ts +113 -0
  836. package/dist/shared/model-registry.js +250 -0
  837. package/dist/shared/model-registry.js.map +1 -0
  838. package/dist/shared/persist-decision.d.ts +38 -0
  839. package/dist/shared/persist-decision.js +40 -0
  840. package/dist/shared/persist-decision.js.map +1 -0
  841. package/dist/shared/placeholder-resolver.d.ts +39 -0
  842. package/dist/shared/placeholder-resolver.js +86 -0
  843. package/dist/shared/placeholder-resolver.js.map +1 -0
  844. package/dist/shared/plan-artifact.d.ts +105 -0
  845. package/dist/shared/plan-artifact.js +225 -0
  846. package/dist/shared/plan-artifact.js.map +1 -0
  847. package/dist/shared/plan-mode-permissions.d.ts +49 -0
  848. package/dist/shared/plan-mode-permissions.js +51 -0
  849. package/dist/shared/plan-mode-permissions.js.map +1 -0
  850. package/dist/shared/plan-mode-prompt.d.ts +41 -0
  851. package/dist/shared/plan-mode-prompt.js +74 -0
  852. package/dist/shared/plan-mode-prompt.js.map +1 -0
  853. package/dist/shared/platform-server-address.d.ts +72 -0
  854. package/dist/shared/platform-server-address.js +103 -0
  855. package/dist/shared/platform-server-address.js.map +1 -0
  856. package/dist/shared/plugin-mount.d.ts +165 -0
  857. package/dist/shared/plugin-mount.js +428 -0
  858. package/dist/shared/plugin-mount.js.map +1 -0
  859. package/dist/shared/plugin-servers.d.ts +16 -0
  860. package/dist/shared/plugin-servers.js +22 -0
  861. package/dist/shared/plugin-servers.js.map +1 -0
  862. package/dist/shared/prompt-sections.d.ts +140 -0
  863. package/dist/shared/prompt-sections.js +135 -0
  864. package/dist/shared/prompt-sections.js.map +1 -0
  865. package/dist/shared/recalled-memories.d.ts +55 -0
  866. package/dist/shared/recalled-memories.js +70 -0
  867. package/dist/shared/recalled-memories.js.map +1 -0
  868. package/dist/shared/registry-endpoint.d.ts +60 -0
  869. package/dist/shared/registry-endpoint.js +99 -0
  870. package/dist/shared/registry-endpoint.js.map +1 -0
  871. package/dist/shared/run-credential-store.d.ts +32 -0
  872. package/dist/shared/run-credential-store.js +39 -0
  873. package/dist/shared/run-credential-store.js.map +1 -0
  874. package/dist/shared/run-credential.d.ts +40 -0
  875. package/dist/shared/run-credential.js +47 -0
  876. package/dist/shared/run-credential.js.map +1 -0
  877. package/dist/shared/run-values.d.ts +88 -0
  878. package/dist/shared/run-values.js +101 -0
  879. package/dist/shared/run-values.js.map +1 -0
  880. package/dist/shared/runner-credential-keys.d.ts +20 -0
  881. package/dist/shared/runner-credential-keys.js +101 -0
  882. package/dist/shared/runner-credential-keys.js.map +1 -0
  883. package/dist/shared/runner-credential-store.d.ts +77 -0
  884. package/dist/shared/runner-credential-store.js +111 -0
  885. package/dist/shared/runner-credential-store.js.map +1 -0
  886. package/dist/shared/sender-identity.d.ts +50 -0
  887. package/dist/shared/sender-identity.js +69 -0
  888. package/dist/shared/sender-identity.js.map +1 -0
  889. package/dist/shared/service-tier.d.ts +55 -0
  890. package/dist/shared/service-tier.js +67 -0
  891. package/dist/shared/service-tier.js.map +1 -0
  892. package/dist/shared/session-context.d.ts +35 -0
  893. package/dist/shared/session-context.js +52 -0
  894. package/dist/shared/session-context.js.map +1 -0
  895. package/dist/shared/shell-env.d.ts +42 -0
  896. package/dist/shared/shell-env.js +65 -0
  897. package/dist/shared/shell-env.js.map +1 -0
  898. package/dist/shared/skill-mount.d.ts +135 -0
  899. package/dist/shared/skill-mount.js +178 -0
  900. package/dist/shared/skill-mount.js.map +1 -0
  901. package/dist/shared/skill-resolver.d.ts +57 -0
  902. package/dist/shared/skill-resolver.js +113 -0
  903. package/dist/shared/skill-resolver.js.map +1 -0
  904. package/dist/shared/stall-watchdog.d.ts +68 -0
  905. package/dist/shared/stall-watchdog.js +102 -0
  906. package/dist/shared/stall-watchdog.js.map +1 -0
  907. package/dist/shared/status-offload.d.ts +196 -0
  908. package/dist/shared/status-offload.js +655 -0
  909. package/dist/shared/status-offload.js.map +1 -0
  910. package/dist/shared/status.d.ts +100 -0
  911. package/dist/shared/status.js +191 -0
  912. package/dist/shared/status.js.map +1 -0
  913. package/dist/shared/streaming-scheduler.d.ts +59 -0
  914. package/dist/shared/streaming-scheduler.js +110 -0
  915. package/dist/shared/streaming-scheduler.js.map +1 -0
  916. package/dist/shared/subagent-gate.d.ts +47 -0
  917. package/dist/shared/subagent-gate.js +98 -0
  918. package/dist/shared/subagent-gate.js.map +1 -0
  919. package/dist/shared/subagent-rows.d.ts +21 -0
  920. package/dist/shared/subagent-rows.js +34 -0
  921. package/dist/shared/subagent-rows.js.map +1 -0
  922. package/dist/shared/subagents.d.ts +49 -0
  923. package/dist/shared/subagents.js +51 -0
  924. package/dist/shared/subagents.js.map +1 -0
  925. package/dist/shared/synthesized-attachment.d.ts +73 -0
  926. package/dist/shared/synthesized-attachment.js +59 -0
  927. package/dist/shared/synthesized-attachment.js.map +1 -0
  928. package/dist/shared/telemetry-content.d.ts +132 -0
  929. package/dist/shared/telemetry-content.js +239 -0
  930. package/dist/shared/telemetry-content.js.map +1 -0
  931. package/dist/shared/thinking-mode.d.ts +82 -0
  932. package/dist/shared/thinking-mode.js +105 -0
  933. package/dist/shared/thinking-mode.js.map +1 -0
  934. package/dist/shared/todos.d.ts +30 -0
  935. package/dist/shared/todos.js +58 -0
  936. package/dist/shared/todos.js.map +1 -0
  937. package/dist/shared/tool-kind.d.ts +41 -0
  938. package/dist/shared/tool-kind.js +107 -0
  939. package/dist/shared/tool-kind.js.map +1 -0
  940. package/dist/shared/tool-lists.d.ts +283 -0
  941. package/dist/shared/tool-lists.js +518 -0
  942. package/dist/shared/tool-lists.js.map +1 -0
  943. package/dist/shared/tool-rounds.d.ts +91 -0
  944. package/dist/shared/tool-rounds.js +136 -0
  945. package/dist/shared/tool-rounds.js.map +1 -0
  946. package/dist/shared/tool-row.d.ts +195 -0
  947. package/dist/shared/tool-row.js +320 -0
  948. package/dist/shared/tool-row.js.map +1 -0
  949. package/dist/shared/trace-context.d.ts +20 -0
  950. package/dist/shared/trace-context.js +36 -0
  951. package/dist/shared/trace-context.js.map +1 -0
  952. package/dist/shared/with-timeout.d.ts +27 -0
  953. package/dist/shared/with-timeout.js +47 -0
  954. package/dist/shared/with-timeout.js.map +1 -0
  955. package/dist/shared/worker-shutdown.d.ts +99 -0
  956. package/dist/shared/worker-shutdown.js +94 -0
  957. package/dist/shared/worker-shutdown.js.map +1 -0
  958. package/dist/shared/workspace/file-tree.d.ts +13 -0
  959. package/dist/shared/workspace/file-tree.js +101 -0
  960. package/dist/shared/workspace/file-tree.js.map +1 -0
  961. package/dist/shared/workspace/git-credential.d.ts +91 -0
  962. package/dist/shared/workspace/git-credential.js +222 -0
  963. package/dist/shared/workspace/git-credential.js.map +1 -0
  964. package/dist/shared/workspace/git-identity.d.ts +36 -0
  965. package/dist/shared/workspace/git-identity.js +39 -0
  966. package/dist/shared/workspace/git-identity.js.map +1 -0
  967. package/dist/shared/workspace/local-backend.d.ts +44 -0
  968. package/dist/shared/workspace/local-backend.js +110 -0
  969. package/dist/shared/workspace/local-backend.js.map +1 -0
  970. package/dist/shared/workspace/platform-dir.d.ts +106 -0
  971. package/dist/shared/workspace/platform-dir.js +151 -0
  972. package/dist/shared/workspace/platform-dir.js.map +1 -0
  973. package/dist/shared/workspace/platform-mount.d.ts +95 -0
  974. package/dist/shared/workspace/platform-mount.js +157 -0
  975. package/dist/shared/workspace/platform-mount.js.map +1 -0
  976. package/dist/shared/workspace/provisioner.d.ts +52 -0
  977. package/dist/shared/workspace/provisioner.js +70 -0
  978. package/dist/shared/workspace/provisioner.js.map +1 -0
  979. package/dist/shared/workspace/session-provision.d.ts +56 -0
  980. package/dist/shared/workspace/session-provision.js +54 -0
  981. package/dist/shared/workspace/session-provision.js.map +1 -0
  982. package/dist/shared/workspace/session-root.d.ts +35 -0
  983. package/dist/shared/workspace/session-root.js +53 -0
  984. package/dist/shared/workspace/session-root.js.map +1 -0
  985. package/dist/shared/workspace/sources/empty.d.ts +8 -0
  986. package/dist/shared/workspace/sources/empty.js +16 -0
  987. package/dist/shared/workspace/sources/empty.js.map +1 -0
  988. package/dist/shared/workspace/sources/git.d.ts +30 -0
  989. package/dist/shared/workspace/sources/git.js +224 -0
  990. package/dist/shared/workspace/sources/git.js.map +1 -0
  991. package/dist/shared/workspace/sources/local-path.d.ts +17 -0
  992. package/dist/shared/workspace/sources/local-path.js +61 -0
  993. package/dist/shared/workspace/sources/local-path.js.map +1 -0
  994. package/dist/shared/workspace/stigmer-link.d.ts +73 -0
  995. package/dist/shared/workspace/stigmer-link.js +173 -0
  996. package/dist/shared/workspace/stigmer-link.js.map +1 -0
  997. package/dist/shared/workspace/types.d.ts +71 -0
  998. package/dist/shared/workspace/types.js +19 -0
  999. package/dist/shared/workspace/types.js.map +1 -0
  1000. package/dist/shared/workspace/workspace-lock.d.ts +86 -0
  1001. package/dist/shared/workspace/workspace-lock.js +190 -0
  1002. package/dist/shared/workspace/workspace-lock.js.map +1 -0
  1003. package/dist/shared/workspace/writeback-coordinator.d.ts +119 -0
  1004. package/dist/shared/workspace/writeback-coordinator.js +361 -0
  1005. package/dist/shared/workspace/writeback-coordinator.js.map +1 -0
  1006. package/dist/shared/zip-extract.d.ts +55 -0
  1007. package/dist/shared/zip-extract.js +98 -0
  1008. package/dist/shared/zip-extract.js.map +1 -0
  1009. package/dist/tools/index.d.ts +26 -0
  1010. package/dist/tools/index.js +26 -0
  1011. package/dist/tools/index.js.map +1 -0
  1012. package/dist/tools/url-guard.d.ts +77 -0
  1013. package/dist/tools/url-guard.js +119 -0
  1014. package/dist/tools/url-guard.js.map +1 -0
  1015. package/dist/tools/web-fetch-tool.d.ts +55 -0
  1016. package/dist/tools/web-fetch-tool.js +218 -0
  1017. package/dist/tools/web-fetch-tool.js.map +1 -0
  1018. package/dist/worker.d.ts +35 -0
  1019. package/dist/worker.js +71 -0
  1020. package/dist/worker.js.map +1 -0
  1021. package/dist/workflow-source.d.ts +38 -0
  1022. package/dist/workflow-source.js +53 -0
  1023. package/dist/workflow-source.js.map +1 -0
  1024. package/dist/workflows/index.d.ts +32 -0
  1025. package/dist/workflows/index.js +33 -0
  1026. package/dist/workflows/index.js.map +1 -0
  1027. package/dist/workflows/list-plugin-tools.d.ts +23 -0
  1028. package/dist/workflows/list-plugin-tools.js +56 -0
  1029. package/dist/workflows/list-plugin-tools.js.map +1 -0
  1030. package/dist/workflows/types.d.ts +43 -0
  1031. package/dist/workflows/types.js +18 -0
  1032. package/dist/workflows/types.js.map +1 -0
  1033. package/package.json +161 -0
  1034. package/src/__test-utils__/__tests__/execution-record-barrier.test.ts +75 -0
  1035. package/src/__test-utils__/__tests__/harness-contract-self-check.test.ts +361 -0
  1036. package/src/__test-utils__/__tests__/live-gate.test.ts +100 -0
  1037. package/src/__test-utils__/__tests__/real-model-registry.test.ts +53 -0
  1038. package/src/__test-utils__/__tests__/vitest-global-setup.test.ts +37 -0
  1039. package/src/__test-utils__/agent-host-probe-child.ts +77 -0
  1040. package/src/__test-utils__/approval-contract/contract.ts +613 -0
  1041. package/src/__test-utils__/approval-contract/hook-commands.ts +100 -0
  1042. package/src/__test-utils__/approval-contract/types.ts +323 -0
  1043. package/src/__test-utils__/approval-log.ts +142 -0
  1044. package/src/__test-utils__/config-fixture.ts +65 -0
  1045. package/src/__test-utils__/cursor-sdk-wire-child.ts +47 -0
  1046. package/src/__test-utils__/execution-record-fixture.ts +229 -0
  1047. package/src/__test-utils__/fake-artifact-storage.ts +83 -0
  1048. package/src/__test-utils__/fake-upstream.ts +67 -0
  1049. package/src/__test-utils__/file-review-projection.ts +77 -0
  1050. package/src/__test-utils__/git-workspace-fixture.ts +58 -0
  1051. package/src/__test-utils__/harness-boot-order-child.ts +78 -0
  1052. package/src/__test-utils__/harness-contract/contract.ts +652 -0
  1053. package/src/__test-utils__/harness-contract/recording-sink.ts +138 -0
  1054. package/src/__test-utils__/harness-contract/runtime-contract.ts +1136 -0
  1055. package/src/__test-utils__/harness-contract/scripted-adapter.ts +404 -0
  1056. package/src/__test-utils__/harness-contract/types.ts +200 -0
  1057. package/src/__test-utils__/hermetic-activity.ts +1061 -0
  1058. package/src/__test-utils__/import-http2-first.ts +11 -0
  1059. package/src/__test-utils__/live-gate.ts +106 -0
  1060. package/src/__test-utils__/loopback-host.ts +48 -0
  1061. package/src/__test-utils__/mock-client.ts +52 -0
  1062. package/src/__test-utils__/mock-workspace.ts +28 -0
  1063. package/src/__test-utils__/model-registry-fixture.ts +133 -0
  1064. package/src/__test-utils__/module-specifiers.ts +177 -0
  1065. package/src/__test-utils__/proto-helpers.ts +70 -0
  1066. package/src/__test-utils__/real-model-registry.ts +85 -0
  1067. package/src/__test-utils__/refuse-engine-sdks.ts +18 -0
  1068. package/src/__test-utils__/timing-lines.ts +43 -0
  1069. package/src/__test-utils__/turn-input-fixture.ts +166 -0
  1070. package/src/__test-utils__/vitest-global-setup.ts +50 -0
  1071. package/src/__tests__/agent-separation.container.test.ts +157 -0
  1072. package/src/__tests__/approval-gateway-contract.test.ts +29 -0
  1073. package/src/__tests__/bootstrap.test.ts +264 -0
  1074. package/src/__tests__/config-boundary.test.ts +135 -0
  1075. package/src/__tests__/config.test.ts +165 -0
  1076. package/src/__tests__/exit-backstop.test.ts +91 -0
  1077. package/src/__tests__/harness-boot-order.test.ts +87 -0
  1078. package/src/__tests__/harness-contract.test.ts +27 -0
  1079. package/src/__tests__/in-flight.test.ts +84 -0
  1080. package/src/__tests__/ipc-protocol-fixtures.test.ts +61 -0
  1081. package/src/__tests__/ipc-protocol.test.ts +33 -0
  1082. package/src/__tests__/otel-export.test.ts +266 -0
  1083. package/src/__tests__/otel-init.test.ts +111 -0
  1084. package/src/__tests__/otel-metrics.test.ts +37 -0
  1085. package/src/__tests__/pipe-safety.test.ts +119 -0
  1086. package/src/__tests__/pool-member.test.ts +77 -0
  1087. package/src/__tests__/preflight.test.ts +104 -0
  1088. package/src/__tests__/readme-environment.test.ts +678 -0
  1089. package/src/__tests__/run-credential-registration.test.ts +53 -0
  1090. package/src/__tests__/run-trace-id.test.ts +53 -0
  1091. package/src/__tests__/runner-hosting.test.ts +134 -0
  1092. package/src/__tests__/runner-manager-interceptors.test.ts +67 -0
  1093. package/src/__tests__/runner-manager-shutdown.test.ts +199 -0
  1094. package/src/__tests__/runner-manager.test.ts +95 -0
  1095. package/src/__tests__/runner-token-coordinator.test.ts +166 -0
  1096. package/src/__tests__/runner.test.ts +284 -0
  1097. package/src/__tests__/sandbox-token-renewal.test.ts +175 -0
  1098. package/src/__tests__/worker.test.ts +107 -0
  1099. package/src/activities/__tests__/attach-session.test.ts +133 -0
  1100. package/src/activities/__tests__/ensure-thread.test.ts +96 -0
  1101. package/src/activities/__tests__/error-classifier.test.ts +464 -0
  1102. package/src/activities/__tests__/generate-session-subject-wire.test.ts +119 -0
  1103. package/src/activities/__tests__/generate-session-subject.test.ts +356 -0
  1104. package/src/activities/__tests__/list-plugin-tools.test.ts +392 -0
  1105. package/src/activities/attach-session.ts +111 -0
  1106. package/src/activities/ensure-thread.ts +45 -0
  1107. package/src/activities/execute-cursor/__test-utils__/__tests__/scripted-double.test.ts +126 -0
  1108. package/src/activities/execute-cursor/__test-utils__/contract-subject.ts +445 -0
  1109. package/src/activities/execute-cursor/__test-utils__/cursor-hook-harness.ts +407 -0
  1110. package/src/activities/execute-cursor/__test-utils__/fold.ts +118 -0
  1111. package/src/activities/execute-cursor/__test-utils__/gateway-substrate.ts +316 -0
  1112. package/src/activities/execute-cursor/__test-utils__/hermetic-cursor.ts +428 -0
  1113. package/src/activities/execute-cursor/__test-utils__/scripted-agent.ts +374 -0
  1114. package/src/activities/execute-cursor/__test-utils__/scripted-sdk.ts +310 -0
  1115. package/src/activities/execute-cursor/__tests__/adapter-is-temporal-free.test.ts +45 -0
  1116. package/src/activities/execute-cursor/__tests__/agent-session-cache.test.ts +220 -0
  1117. package/src/activities/execute-cursor/__tests__/approval-decisions-agree.test.ts +141 -0
  1118. package/src/activities/execute-cursor/__tests__/approval-gate.test.ts +335 -0
  1119. package/src/activities/execute-cursor/__tests__/approval-state.test.ts +288 -0
  1120. package/src/activities/execute-cursor/__tests__/boundary-seal.test.ts +125 -0
  1121. package/src/activities/execute-cursor/__tests__/build-prompt.test.ts +1045 -0
  1122. package/src/activities/execute-cursor/__tests__/cas-observations.test.ts +267 -0
  1123. package/src/activities/execute-cursor/__tests__/check-tool-scope.test.ts +290 -0
  1124. package/src/activities/execute-cursor/__tests__/coarse-fingerprint.test.ts +98 -0
  1125. package/src/activities/execute-cursor/__tests__/cursor-baseurl-routing.live.test.ts +94 -0
  1126. package/src/activities/execute-cursor/__tests__/cursor-event-recorder.test.ts +142 -0
  1127. package/src/activities/execute-cursor/__tests__/cursor-fetch-interceptor-bypass.live.test.ts +76 -0
  1128. package/src/activities/execute-cursor/__tests__/cursor-generate-image.live.test.ts +154 -0
  1129. package/src/activities/execute-cursor/__tests__/cursor-hook-protocol.live.test.ts +479 -0
  1130. package/src/activities/execute-cursor/__tests__/cursor-hooks-gate.live.test.ts +295 -0
  1131. package/src/activities/execute-cursor/__tests__/cursor-mcp-config.test.ts +128 -0
  1132. package/src/activities/execute-cursor/__tests__/cursor-mode.test.ts +95 -0
  1133. package/src/activities/execute-cursor/__tests__/cursor-sdk-auth.live.test.ts +97 -0
  1134. package/src/activities/execute-cursor/__tests__/cursor-transcript.live.test.ts +289 -0
  1135. package/src/activities/execute-cursor/__tests__/deny-gate-exact-apply.test.ts +200 -0
  1136. package/src/activities/execute-cursor/__tests__/error-classifier-billing.test.ts +178 -0
  1137. package/src/activities/execute-cursor/__tests__/error-classifier-extraction.test.ts +208 -0
  1138. package/src/activities/execute-cursor/__tests__/error-classifier-introspection.test.ts +156 -0
  1139. package/src/activities/execute-cursor/__tests__/fetch-interceptor.test.ts +389 -0
  1140. package/src/activities/execute-cursor/__tests__/goldens/prompt.enhanced.append.prompt.md +147 -0
  1141. package/src/activities/execute-cursor/__tests__/goldens/prompt.enhanced.everything.prompt.md +164 -0
  1142. package/src/activities/execute-cursor/__tests__/goldens/prompt.enhanced.no-instructions.prompt.md +142 -0
  1143. package/src/activities/execute-cursor/__tests__/goldens/prompt.enhanced.plan-mode.prompt.md +184 -0
  1144. package/src/activities/execute-cursor/__tests__/goldens/prompt.hitl.recovery.prompt.md +189 -0
  1145. package/src/activities/execute-cursor/__tests__/goldens/prompt.hitl.reinvocation.prompt.md +13 -0
  1146. package/src/activities/execute-cursor/__tests__/goldens/prompt.resumed.prefixed.prompt.md +32 -0
  1147. package/src/activities/execute-cursor/__tests__/goldens/prompt.resumed.raw.append.prompt.md +5 -0
  1148. package/src/activities/execute-cursor/__tests__/goldens/prompt.resumed.raw.prompt.md +1 -0
  1149. package/src/activities/execute-cursor/__tests__/hermetic/answers.test.ts +279 -0
  1150. package/src/activities/execute-cursor/__tests__/hermetic/built-in-assistant.test.ts +127 -0
  1151. package/src/activities/execute-cursor/__tests__/hermetic/bypassed-tool-call.test.ts +120 -0
  1152. package/src/activities/execute-cursor/__tests__/hermetic/deny-and-retry.test.ts +233 -0
  1153. package/src/activities/execute-cursor/__tests__/hermetic/file-review-capture.test.ts +262 -0
  1154. package/src/activities/execute-cursor/__tests__/hermetic/goldens/approve-all.turn2.events.json +94 -0
  1155. package/src/activities/execute-cursor/__tests__/hermetic/goldens/approve-all.turn2.rows.json +47 -0
  1156. package/src/activities/execute-cursor/__tests__/hermetic/goldens/approve-all.turn2.status.json +17 -0
  1157. package/src/activities/execute-cursor/__tests__/hermetic/goldens/cost-cap.events.json +14 -0
  1158. package/src/activities/execute-cursor/__tests__/hermetic/goldens/cost-cap.rows.json +14 -0
  1159. package/src/activities/execute-cursor/__tests__/hermetic/goldens/cost-cap.status.json +18 -0
  1160. package/src/activities/execute-cursor/__tests__/hermetic/goldens/deny-and-retry.turn1.events.json +37 -0
  1161. package/src/activities/execute-cursor/__tests__/hermetic/goldens/deny-and-retry.turn1.rows.json +29 -0
  1162. package/src/activities/execute-cursor/__tests__/hermetic/goldens/deny-and-retry.turn1.status.json +4 -0
  1163. package/src/activities/execute-cursor/__tests__/hermetic/goldens/deny-and-retry.turn2.events.json +71 -0
  1164. package/src/activities/execute-cursor/__tests__/hermetic/goldens/deny-and-retry.turn2.rows.json +32 -0
  1165. package/src/activities/execute-cursor/__tests__/hermetic/goldens/deny-and-retry.turn2.status.json +17 -0
  1166. package/src/activities/execute-cursor/__tests__/hermetic/goldens/file-review-capture.events.json +68 -0
  1167. package/src/activities/execute-cursor/__tests__/hermetic/goldens/file-review-capture.rows.json +96 -0
  1168. package/src/activities/execute-cursor/__tests__/hermetic/goldens/file-review-capture.status.json +74 -0
  1169. package/src/activities/execute-cursor/__tests__/hermetic/goldens/file-review-off.events.json +50 -0
  1170. package/src/activities/execute-cursor/__tests__/hermetic/goldens/file-review-off.rows.json +32 -0
  1171. package/src/activities/execute-cursor/__tests__/hermetic/goldens/file-review-off.status.json +17 -0
  1172. package/src/activities/execute-cursor/__tests__/hermetic/goldens/file-review-reconcile.events.json +91 -0
  1173. package/src/activities/execute-cursor/__tests__/hermetic/goldens/file-review-reconcile.rows.json +9 -0
  1174. package/src/activities/execute-cursor/__tests__/hermetic/goldens/file-review-reconcile.status.json +6 -0
  1175. package/src/activities/execute-cursor/__tests__/hermetic/goldens/hooks.turn1.events.json +110 -0
  1176. package/src/activities/execute-cursor/__tests__/hermetic/goldens/hooks.turn1.rows.json +77 -0
  1177. package/src/activities/execute-cursor/__tests__/hermetic/goldens/hooks.turn1.status.json +14 -0
  1178. package/src/activities/execute-cursor/__tests__/hermetic/goldens/hooks.turn2.events.json +144 -0
  1179. package/src/activities/execute-cursor/__tests__/hermetic/goldens/hooks.turn2.rows.json +34 -0
  1180. package/src/activities/execute-cursor/__tests__/hermetic/goldens/hooks.turn2.status.json +27 -0
  1181. package/src/activities/execute-cursor/__tests__/hermetic/goldens/mcp-tool-call.events.json +50 -0
  1182. package/src/activities/execute-cursor/__tests__/hermetic/goldens/mcp-tool-call.rows.json +30 -0
  1183. package/src/activities/execute-cursor/__tests__/hermetic/goldens/mcp-tool-call.status.json +17 -0
  1184. package/src/activities/execute-cursor/__tests__/hermetic/goldens/pause.events.json +14 -0
  1185. package/src/activities/execute-cursor/__tests__/hermetic/goldens/pause.rows.json +9 -0
  1186. package/src/activities/execute-cursor/__tests__/hermetic/goldens/pause.status.json +4 -0
  1187. package/src/activities/execute-cursor/__tests__/hermetic/goldens/plain-turn.events.json +14 -0
  1188. package/src/activities/execute-cursor/__tests__/hermetic/goldens/plain-turn.rows.json +9 -0
  1189. package/src/activities/execute-cursor/__tests__/hermetic/goldens/plain-turn.status.json +17 -0
  1190. package/src/activities/execute-cursor/__tests__/hermetic/goldens/platform-stop.events.json +37 -0
  1191. package/src/activities/execute-cursor/__tests__/hermetic/goldens/platform-stop.rows.json +29 -0
  1192. package/src/activities/execute-cursor/__tests__/hermetic/goldens/platform-stop.status.json +6 -0
  1193. package/src/activities/execute-cursor/__tests__/hermetic/goldens/recovery-fresh-agent.events.json +26 -0
  1194. package/src/activities/execute-cursor/__tests__/hermetic/goldens/recovery-fresh-agent.rows.json +14 -0
  1195. package/src/activities/execute-cursor/__tests__/hermetic/goldens/recovery-fresh-agent.status.json +17 -0
  1196. package/src/activities/execute-cursor/__tests__/hermetic/goldens/recovery-transport-timeout.events.json +14 -0
  1197. package/src/activities/execute-cursor/__tests__/hermetic/goldens/recovery-transport-timeout.rows.json +9 -0
  1198. package/src/activities/execute-cursor/__tests__/hermetic/goldens/recovery-transport-timeout.status.json +17 -0
  1199. package/src/activities/execute-cursor/__tests__/hermetic/goldens/reject.turn2.events.json +61 -0
  1200. package/src/activities/execute-cursor/__tests__/hermetic/goldens/reject.turn2.rows.json +31 -0
  1201. package/src/activities/execute-cursor/__tests__/hermetic/goldens/reject.turn2.status.json +17 -0
  1202. package/src/activities/execute-cursor/__tests__/hermetic/goldens/resolution-error.events.json +1 -0
  1203. package/src/activities/execute-cursor/__tests__/hermetic/goldens/resolution-error.rows.json +14 -0
  1204. package/src/activities/execute-cursor/__tests__/hermetic/goldens/resolution-error.status.json +7 -0
  1205. package/src/activities/execute-cursor/__tests__/hermetic/goldens/run-cancelled.events.json +14 -0
  1206. package/src/activities/execute-cursor/__tests__/hermetic/goldens/run-cancelled.rows.json +9 -0
  1207. package/src/activities/execute-cursor/__tests__/hermetic/goldens/run-cancelled.status.json +5 -0
  1208. package/src/activities/execute-cursor/__tests__/hermetic/goldens/run-error-non-retryable.events.json +14 -0
  1209. package/src/activities/execute-cursor/__tests__/hermetic/goldens/run-error-non-retryable.rows.json +9 -0
  1210. package/src/activities/execute-cursor/__tests__/hermetic/goldens/run-error-non-retryable.status.json +7 -0
  1211. package/src/activities/execute-cursor/__tests__/hermetic/goldens/sdk-error-at-create.events.json +1 -0
  1212. package/src/activities/execute-cursor/__tests__/hermetic/goldens/sdk-error-at-create.rows.json +14 -0
  1213. package/src/activities/execute-cursor/__tests__/hermetic/goldens/sdk-error-at-create.status.json +7 -0
  1214. package/src/activities/execute-cursor/__tests__/hermetic/goldens/sdk-task-note.events.json +56 -0
  1215. package/src/activities/execute-cursor/__tests__/hermetic/goldens/sdk-task-note.rows.json +34 -0
  1216. package/src/activities/execute-cursor/__tests__/hermetic/goldens/sdk-task-note.status.json +17 -0
  1217. package/src/activities/execute-cursor/__tests__/hermetic/goldens/shell-output-delta.error-delta.events.json +64 -0
  1218. package/src/activities/execute-cursor/__tests__/hermetic/goldens/shell-output-delta.error-delta.rows.json +36 -0
  1219. package/src/activities/execute-cursor/__tests__/hermetic/goldens/shell-output-delta.error-delta.status.json +17 -0
  1220. package/src/activities/execute-cursor/__tests__/hermetic/goldens/shell-output-delta.events.json +49 -0
  1221. package/src/activities/execute-cursor/__tests__/hermetic/goldens/shell-output-delta.output-first.events.json +49 -0
  1222. package/src/activities/execute-cursor/__tests__/hermetic/goldens/shell-output-delta.output-first.rows.json +31 -0
  1223. package/src/activities/execute-cursor/__tests__/hermetic/goldens/shell-output-delta.output-first.status.json +17 -0
  1224. package/src/activities/execute-cursor/__tests__/hermetic/goldens/shell-output-delta.rows.json +31 -0
  1225. package/src/activities/execute-cursor/__tests__/hermetic/goldens/shell-output-delta.status.json +17 -0
  1226. package/src/activities/execute-cursor/__tests__/hermetic/goldens/stall.events.json +24 -0
  1227. package/src/activities/execute-cursor/__tests__/hermetic/goldens/stall.rows.json +29 -0
  1228. package/src/activities/execute-cursor/__tests__/hermetic/goldens/stall.status.json +7 -0
  1229. package/src/activities/execute-cursor/__tests__/hermetic/goldens/sub-agent-delegation.events.json +158 -0
  1230. package/src/activities/execute-cursor/__tests__/hermetic/goldens/sub-agent-delegation.rows.json +70 -0
  1231. package/src/activities/execute-cursor/__tests__/hermetic/goldens/sub-agent-delegation.status.json +17 -0
  1232. package/src/activities/execute-cursor/__tests__/hermetic/goldens/thinking-turn.events.json +77 -0
  1233. package/src/activities/execute-cursor/__tests__/hermetic/goldens/thinking-turn.rows.json +39 -0
  1234. package/src/activities/execute-cursor/__tests__/hermetic/goldens/thinking-turn.status.json +17 -0
  1235. package/src/activities/execute-cursor/__tests__/hermetic/goldens/todo-write.events.json +99 -0
  1236. package/src/activities/execute-cursor/__tests__/hermetic/goldens/todo-write.rows.json +80 -0
  1237. package/src/activities/execute-cursor/__tests__/hermetic/goldens/todo-write.status.json +17 -0
  1238. package/src/activities/execute-cursor/__tests__/hermetic/goldens/tool-call.events.json +49 -0
  1239. package/src/activities/execute-cursor/__tests__/hermetic/goldens/tool-call.rows.json +29 -0
  1240. package/src/activities/execute-cursor/__tests__/hermetic/goldens/tool-call.status.json +17 -0
  1241. package/src/activities/execute-cursor/__tests__/hermetic/goldens/tool-error.events.json +50 -0
  1242. package/src/activities/execute-cursor/__tests__/hermetic/goldens/tool-error.rows.json +29 -0
  1243. package/src/activities/execute-cursor/__tests__/hermetic/goldens/tool-error.status.json +17 -0
  1244. package/src/activities/execute-cursor/__tests__/hermetic/goldens/tool-only-step.events.json +37 -0
  1245. package/src/activities/execute-cursor/__tests__/hermetic/goldens/tool-only-step.rows.json +28 -0
  1246. package/src/activities/execute-cursor/__tests__/hermetic/goldens/tool-only-step.status.json +17 -0
  1247. package/src/activities/execute-cursor/__tests__/hermetic/goldens/unattended-skip.events.json +51 -0
  1248. package/src/activities/execute-cursor/__tests__/hermetic/goldens/unattended-skip.rows.json +31 -0
  1249. package/src/activities/execute-cursor/__tests__/hermetic/goldens/unattended-skip.status.json +17 -0
  1250. package/src/activities/execute-cursor/__tests__/hermetic/goldens/unattributed-hook-block.events.json +50 -0
  1251. package/src/activities/execute-cursor/__tests__/hermetic/goldens/unattributed-hook-block.rows.json +36 -0
  1252. package/src/activities/execute-cursor/__tests__/hermetic/goldens/unattributed-hook-block.status.json +19 -0
  1253. package/src/activities/execute-cursor/__tests__/hermetic/goldens/worker-shutdown.events.json +14 -0
  1254. package/src/activities/execute-cursor/__tests__/hermetic/goldens/worker-shutdown.rows.json +14 -0
  1255. package/src/activities/execute-cursor/__tests__/hermetic/goldens/worker-shutdown.status.json +7 -0
  1256. package/src/activities/execute-cursor/__tests__/hermetic/harness-contract.test.ts +198 -0
  1257. package/src/activities/execute-cursor/__tests__/hermetic/hooks.test.ts +569 -0
  1258. package/src/activities/execute-cursor/__tests__/hermetic/mcp-tool-call.test.ts +149 -0
  1259. package/src/activities/execute-cursor/__tests__/hermetic/pause-vs-shutdown.test.ts +222 -0
  1260. package/src/activities/execute-cursor/__tests__/hermetic/plain-turn.test.ts +178 -0
  1261. package/src/activities/execute-cursor/__tests__/hermetic/recovery-fresh-agent.test.ts +162 -0
  1262. package/src/activities/execute-cursor/__tests__/hermetic/run-wait-arms.test.ts +296 -0
  1263. package/src/activities/execute-cursor/__tests__/hermetic/sdk-task-note.test.ts +125 -0
  1264. package/src/activities/execute-cursor/__tests__/hermetic/shell-output-delta.test.ts +283 -0
  1265. package/src/activities/execute-cursor/__tests__/hermetic/stream-self-stop-arms.test.ts +342 -0
  1266. package/src/activities/execute-cursor/__tests__/hermetic/sub-agent-delegation.test.ts +197 -0
  1267. package/src/activities/execute-cursor/__tests__/hermetic/thinking-turn.test.ts +149 -0
  1268. package/src/activities/execute-cursor/__tests__/hermetic/thrown-error-arms.test.ts +214 -0
  1269. package/src/activities/execute-cursor/__tests__/hermetic/todo-write.test.ts +169 -0
  1270. package/src/activities/execute-cursor/__tests__/hermetic/tool-call.test.ts +143 -0
  1271. package/src/activities/execute-cursor/__tests__/hermetic/tool-error.test.ts +141 -0
  1272. package/src/activities/execute-cursor/__tests__/hermetic/tool-lists.test.ts +391 -0
  1273. package/src/activities/execute-cursor/__tests__/hermetic/tool-only-step.test.ts +134 -0
  1274. package/src/activities/execute-cursor/__tests__/hermetic/turn-phases.test.ts +136 -0
  1275. package/src/activities/execute-cursor/__tests__/hermetic/unattended-skip.test.ts +157 -0
  1276. package/src/activities/execute-cursor/__tests__/hermetic/unattributed-hook-block.test.ts +200 -0
  1277. package/src/activities/execute-cursor/__tests__/hermetic/workspace-lock-timeout.test.ts +156 -0
  1278. package/src/activities/execute-cursor/__tests__/hitl-ledger.test.ts +2109 -0
  1279. package/src/activities/execute-cursor/__tests__/hitl-resume-history.test.ts +431 -0
  1280. package/src/activities/execute-cursor/__tests__/hook-refusal-rows.test.ts +95 -0
  1281. package/src/activities/execute-cursor/__tests__/hook-scope.test.ts +175 -0
  1282. package/src/activities/execute-cursor/__tests__/hook-script.test.ts +1408 -0
  1283. package/src/activities/execute-cursor/__tests__/hook-server.test.ts +465 -0
  1284. package/src/activities/execute-cursor/__tests__/hook-views.test.ts +171 -0
  1285. package/src/activities/execute-cursor/__tests__/http2-interceptor.test.ts +408 -0
  1286. package/src/activities/execute-cursor/__tests__/model-pricing.test.ts +173 -0
  1287. package/src/activities/execute-cursor/__tests__/prepare-hooks.test.ts +97 -0
  1288. package/src/activities/execute-cursor/__tests__/prompt-builder-delegation.test.ts +85 -0
  1289. package/src/activities/execute-cursor/__tests__/prompt-goldens.test.ts +270 -0
  1290. package/src/activities/execute-cursor/__tests__/resolve-timeout-message.test.ts +24 -0
  1291. package/src/activities/execute-cursor/__tests__/run-telemetry.test.ts +177 -0
  1292. package/src/activities/execute-cursor/__tests__/runner-error-regressions.test.ts +103 -0
  1293. package/src/activities/execute-cursor/__tests__/same-identity-reproposal.test.ts +174 -0
  1294. package/src/activities/execute-cursor/__tests__/scope-refusal-rows.test.ts +269 -0
  1295. package/src/activities/execute-cursor/__tests__/sdk-warmup.test.ts +45 -0
  1296. package/src/activities/execute-cursor/__tests__/sequential-gate-resume.test.ts +182 -0
  1297. package/src/activities/execute-cursor/__tests__/service-tier.test.ts +230 -0
  1298. package/src/activities/execute-cursor/__tests__/session-lifecycle.test.ts +336 -0
  1299. package/src/activities/execute-cursor/__tests__/session-store.test.ts +220 -0
  1300. package/src/activities/execute-cursor/__tests__/subagent-config.test.ts +181 -0
  1301. package/src/activities/execute-cursor/__tests__/tool-result-image.test.ts +250 -0
  1302. package/src/activities/execute-cursor/__tests__/translator.test.ts +651 -0
  1303. package/src/activities/execute-cursor/__tests__/turn-boundary.test.ts +415 -0
  1304. package/src/activities/execute-cursor/__tests__/turn-recovery.test.ts +186 -0
  1305. package/src/activities/execute-cursor/__tests__/turn-stream.test.ts +354 -0
  1306. package/src/activities/execute-cursor/__tests__/usage-pricing.test.ts +84 -0
  1307. package/src/activities/execute-cursor/__tests__/workspace-setup.test.ts +814 -0
  1308. package/src/activities/execute-cursor/adapter.ts +161 -0
  1309. package/src/activities/execute-cursor/agent-session-cache.ts +229 -0
  1310. package/src/activities/execute-cursor/approval-policy.ts +129 -0
  1311. package/src/activities/execute-cursor/approval-state.ts +1097 -0
  1312. package/src/activities/execute-cursor/boundary-rows.ts +1419 -0
  1313. package/src/activities/execute-cursor/cas-observations.ts +263 -0
  1314. package/src/activities/execute-cursor/cursor-capabilities.ts +80 -0
  1315. package/src/activities/execute-cursor/cursor-event-recorder.ts +112 -0
  1316. package/src/activities/execute-cursor/cursor-mcp-config.ts +124 -0
  1317. package/src/activities/execute-cursor/cursor-mode.ts +42 -0
  1318. package/src/activities/execute-cursor/error-classifier.ts +416 -0
  1319. package/src/activities/execute-cursor/fetch-interceptor.ts +454 -0
  1320. package/src/activities/execute-cursor/hook-scope.ts +216 -0
  1321. package/src/activities/execute-cursor/hook-script.ts +1232 -0
  1322. package/src/activities/execute-cursor/hook-server.ts +473 -0
  1323. package/src/activities/execute-cursor/hook-tool-hiding.ts +76 -0
  1324. package/src/activities/execute-cursor/hook-views.ts +195 -0
  1325. package/src/activities/execute-cursor/http2-interceptor.ts +267 -0
  1326. package/src/activities/execute-cursor/model-pricing-data.ts +170 -0
  1327. package/src/activities/execute-cursor/model-pricing.ts +190 -0
  1328. package/src/activities/execute-cursor/prompt-builder.ts +1081 -0
  1329. package/src/activities/execute-cursor/rejection-capture.ts +93 -0
  1330. package/src/activities/execute-cursor/run-telemetry.ts +189 -0
  1331. package/src/activities/execute-cursor/sdk-warmup.ts +77 -0
  1332. package/src/activities/execute-cursor/service-tier.ts +251 -0
  1333. package/src/activities/execute-cursor/session-lifecycle.ts +543 -0
  1334. package/src/activities/execute-cursor/session-store.ts +186 -0
  1335. package/src/activities/execute-cursor/sub-agent-steps.ts +188 -0
  1336. package/src/activities/execute-cursor/subagent-config.ts +124 -0
  1337. package/src/activities/execute-cursor/tool-result.ts +128 -0
  1338. package/src/activities/execute-cursor/translator.ts +544 -0
  1339. package/src/activities/execute-cursor/turn-boundary.ts +373 -0
  1340. package/src/activities/execute-cursor/turn-recovery.ts +223 -0
  1341. package/src/activities/execute-cursor/turn-settle.ts +605 -0
  1342. package/src/activities/execute-cursor/turn-setup.ts +964 -0
  1343. package/src/activities/execute-cursor/turn-stream.ts +354 -0
  1344. package/src/activities/execute-cursor/turn.ts +271 -0
  1345. package/src/activities/execute-cursor/usage-pricing.ts +67 -0
  1346. package/src/activities/execute-cursor/workspace-hook-files.ts +424 -0
  1347. package/src/activities/execute-cursor/workspace-setup.ts +549 -0
  1348. package/src/activities/execute-deep-agent/__test-utils__/contract-subject.ts +404 -0
  1349. package/src/activities/execute-deep-agent/__test-utils__/gateway-substrate.ts +519 -0
  1350. package/src/activities/execute-deep-agent/__test-utils__/hermetic-deep-agent.ts +430 -0
  1351. package/src/activities/execute-deep-agent/__test-utils__/hitl-script.ts +48 -0
  1352. package/src/activities/execute-deep-agent/__test-utils__/paused-session-fixture.ts +172 -0
  1353. package/src/activities/execute-deep-agent/__test-utils__/scripted-model-module.ts +84 -0
  1354. package/src/activities/execute-deep-agent/__test-utils__/scripted-model.ts +585 -0
  1355. package/src/activities/execute-deep-agent/__test-utils__/think-bound-session.ts +29 -0
  1356. package/src/activities/execute-deep-agent/__test-utils__/v3-event-fixtures.ts +295 -0
  1357. package/src/activities/execute-deep-agent/__tests__/adapter-graph-is-sdk-free.test.ts +76 -0
  1358. package/src/activities/execute-deep-agent/__tests__/adapter-is-temporal-free.test.ts +47 -0
  1359. package/src/activities/execute-deep-agent/__tests__/adapter.test.ts +83 -0
  1360. package/src/activities/execute-deep-agent/__tests__/approval-file-change.test.ts +88 -0
  1361. package/src/activities/execute-deep-agent/__tests__/auto-publish.test.ts +144 -0
  1362. package/src/activities/execute-deep-agent/__tests__/builtin-tool-surface.test.ts +108 -0
  1363. package/src/activities/execute-deep-agent/__tests__/cas-capture-backend.test.ts +286 -0
  1364. package/src/activities/execute-deep-agent/__tests__/cas-capture-observer.test.ts +163 -0
  1365. package/src/activities/execute-deep-agent/__tests__/engine-tools.test.ts +97 -0
  1366. package/src/activities/execute-deep-agent/__tests__/goldens/system-prompt.build-from-plan.prompt.md +133 -0
  1367. package/src/activities/execute-deep-agent/__tests__/goldens/system-prompt.everything.prompt.md +151 -0
  1368. package/src/activities/execute-deep-agent/__tests__/goldens/system-prompt.judge.prompt.md +26 -0
  1369. package/src/activities/execute-deep-agent/__tests__/goldens/system-prompt.minimal.append.prompt.md +28 -0
  1370. package/src/activities/execute-deep-agent/__tests__/goldens/system-prompt.minimal.prompt.md +25 -0
  1371. package/src/activities/execute-deep-agent/__tests__/goldens/system-prompt.plan-mode.prompt.md +140 -0
  1372. package/src/activities/execute-deep-agent/__tests__/goldens/user-message.everything.md +36 -0
  1373. package/src/activities/execute-deep-agent/__tests__/hermetic/answers.test.ts +114 -0
  1374. package/src/activities/execute-deep-agent/__tests__/hermetic/built-in-assistant.test.ts +103 -0
  1375. package/src/activities/execute-deep-agent/__tests__/hermetic/cost-advisory.test.ts +239 -0
  1376. package/src/activities/execute-deep-agent/__tests__/hermetic/file-review-capture.test.ts +306 -0
  1377. package/src/activities/execute-deep-agent/__tests__/hermetic/fixtures/paused-session.deepagents-1.10.2.json +592 -0
  1378. package/src/activities/execute-deep-agent/__tests__/hermetic/fixtures/paused-session.think-bound.json +498 -0
  1379. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/approve-all-lease.turn1.events.json +49 -0
  1380. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/approve-all-lease.turn1.rows.json +32 -0
  1381. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/approve-all-lease.turn1.status.json +15 -0
  1382. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/approve-all-lease.turn2.events.json +118 -0
  1383. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/approve-all-lease.turn2.rows.json +45 -0
  1384. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/approve-all-lease.turn2.status.json +16 -0
  1385. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/approve.turn2.events.json +69 -0
  1386. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/approve.turn2.rows.json +30 -0
  1387. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/approve.turn2.status.json +16 -0
  1388. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/file-review-capture.events.json +69 -0
  1389. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/file-review-capture.rows.json +97 -0
  1390. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/file-review-capture.status.json +84 -0
  1391. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/file-review-off.events.json +51 -0
  1392. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/file-review-off.rows.json +33 -0
  1393. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/file-review-off.status.json +27 -0
  1394. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/file-review-reconcile.events.json +92 -0
  1395. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/file-review-reconcile.rows.json +9 -0
  1396. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/file-review-reconcile.status.json +6 -0
  1397. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/gate.turn1.events.json +35 -0
  1398. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/gate.turn1.rows.json +27 -0
  1399. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/gate.turn1.status.json +15 -0
  1400. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/hooks.turn1.events.json +107 -0
  1401. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/hooks.turn1.rows.json +74 -0
  1402. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/hooks.turn1.status.json +25 -0
  1403. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/hooks.turn2.events.json +141 -0
  1404. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/hooks.turn2.rows.json +31 -0
  1405. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/hooks.turn2.status.json +26 -0
  1406. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/inline-artifact.turn1.events.json +71 -0
  1407. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/inline-artifact.turn1.rows.json +50 -0
  1408. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/inline-artifact.turn1.status.json +26 -0
  1409. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/inline-artifact.turn2.events.json +105 -0
  1410. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/inline-artifact.turn2.rows.json +30 -0
  1411. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/inline-artifact.turn2.status.json +27 -0
  1412. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/pause.loop.after-tool.events.json +37 -0
  1413. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/pause.loop.after-tool.rows.json +24 -0
  1414. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/pause.loop.after-tool.status.json +15 -0
  1415. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/pause.loop.mid-tool.events.json +24 -0
  1416. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/pause.loop.mid-tool.rows.json +22 -0
  1417. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/pause.loop.mid-tool.status.json +15 -0
  1418. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/plain-turn.events.json +14 -0
  1419. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/plain-turn.rows.json +9 -0
  1420. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/plain-turn.status.json +16 -0
  1421. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/platform-stop.events.json +24 -0
  1422. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/platform-stop.rows.json +27 -0
  1423. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/platform-stop.status.json +17 -0
  1424. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/recursion-limit.persisted.events.json +352 -0
  1425. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/recursion-limit.persisted.rows.json +209 -0
  1426. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/recursion-limit.persisted.status.json +18 -0
  1427. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/reject.turn2.events.json +71 -0
  1428. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/reject.turn2.rows.json +29 -0
  1429. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/reject.turn2.status.json +16 -0
  1430. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/resolution-error.events.json +1 -0
  1431. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/resolution-error.rows.json +14 -0
  1432. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/resolution-error.status.json +7 -0
  1433. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/sequential-gates.turn2.events.json +90 -0
  1434. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/sequential-gates.turn2.rows.json +48 -0
  1435. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/sequential-gates.turn2.status.json +15 -0
  1436. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/sequential-gates.turn3.events.json +124 -0
  1437. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/sequential-gates.turn3.rows.json +30 -0
  1438. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/sequential-gates.turn3.status.json +16 -0
  1439. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/skip.turn2.events.json +70 -0
  1440. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/skip.turn2.rows.json +29 -0
  1441. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/skip.turn2.status.json +16 -0
  1442. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/structured-output.text-fallback.events.json +24 -0
  1443. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/structured-output.text-fallback.rows.json +13 -0
  1444. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/structured-output.text-fallback.status.json +16 -0
  1445. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/structured-output.tier2.events.json +24 -0
  1446. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/structured-output.tier2.rows.json +13 -0
  1447. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/structured-output.tier2.status.json +16 -0
  1448. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/structured-output.tool-strategy.events.json +36 -0
  1449. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/structured-output.tool-strategy.rows.json +18 -0
  1450. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/structured-output.tool-strategy.status.json +16 -0
  1451. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/sub-agent-delegation.events.json +118 -0
  1452. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/sub-agent-delegation.rows.json +49 -0
  1453. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/sub-agent-delegation.status.json +16 -0
  1454. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/tool-call.events.json +49 -0
  1455. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/tool-call.rows.json +29 -0
  1456. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/tool-call.status.json +16 -0
  1457. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/unattended-skip.events.json +51 -0
  1458. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/unattended-skip.rows.json +31 -0
  1459. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/unattended-skip.status.json +16 -0
  1460. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/worker-shutdown.events.json +37 -0
  1461. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/worker-shutdown.rows.json +29 -0
  1462. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/worker-shutdown.status.json +18 -0
  1463. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/write-todos.events.json +58 -0
  1464. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/write-todos.rows.json +54 -0
  1465. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/write-todos.status.json +16 -0
  1466. package/src/activities/execute-deep-agent/__tests__/hermetic/harness-contract.test.ts +144 -0
  1467. package/src/activities/execute-deep-agent/__tests__/hermetic/hitl-approve-all-lease.test.ts +194 -0
  1468. package/src/activities/execute-deep-agent/__tests__/hermetic/hitl-parallel-gates.test.ts +131 -0
  1469. package/src/activities/execute-deep-agent/__tests__/hermetic/hitl-round-trips.test.ts +224 -0
  1470. package/src/activities/execute-deep-agent/__tests__/hermetic/hitl-sequential-gates.test.ts +180 -0
  1471. package/src/activities/execute-deep-agent/__tests__/hermetic/hooks.test.ts +556 -0
  1472. package/src/activities/execute-deep-agent/__tests__/hermetic/inline-artifact-across-gate.test.ts +188 -0
  1473. package/src/activities/execute-deep-agent/__tests__/hermetic/pause-vs-shutdown.test.ts +217 -0
  1474. package/src/activities/execute-deep-agent/__tests__/hermetic/plain-turn.test.ts +162 -0
  1475. package/src/activities/execute-deep-agent/__tests__/hermetic/platform-stop.test.ts +130 -0
  1476. package/src/activities/execute-deep-agent/__tests__/hermetic/recorded-agent-version.test.ts +148 -0
  1477. package/src/activities/execute-deep-agent/__tests__/hermetic/recursion-limit.test.ts +212 -0
  1478. package/src/activities/execute-deep-agent/__tests__/hermetic/resolution-error.test.ts +130 -0
  1479. package/src/activities/execute-deep-agent/__tests__/hermetic/resume-across-engine-upgrade.test.ts +268 -0
  1480. package/src/activities/execute-deep-agent/__tests__/hermetic/resume-across-think-retirement.test.ts +181 -0
  1481. package/src/activities/execute-deep-agent/__tests__/hermetic/run-finished-while-waiting.test.ts +110 -0
  1482. package/src/activities/execute-deep-agent/__tests__/hermetic/run-values-refused.test.ts +106 -0
  1483. package/src/activities/execute-deep-agent/__tests__/hermetic/structured-output.test.ts +242 -0
  1484. package/src/activities/execute-deep-agent/__tests__/hermetic/sub-agent-concurrent-invocations.test.ts +312 -0
  1485. package/src/activities/execute-deep-agent/__tests__/hermetic/sub-agent-delegation.test.ts +211 -0
  1486. package/src/activities/execute-deep-agent/__tests__/hermetic/sub-agent-own-context.test.ts +192 -0
  1487. package/src/activities/execute-deep-agent/__tests__/hermetic/thrown-turn-drains-publishes.test.ts +154 -0
  1488. package/src/activities/execute-deep-agent/__tests__/hermetic/tool-call.test.ts +167 -0
  1489. package/src/activities/execute-deep-agent/__tests__/hermetic/tool-lists.test.ts +291 -0
  1490. package/src/activities/execute-deep-agent/__tests__/hermetic/turn-phases.test.ts +118 -0
  1491. package/src/activities/execute-deep-agent/__tests__/hermetic/unattended-skip.test.ts +130 -0
  1492. package/src/activities/execute-deep-agent/__tests__/hermetic/workspace-lock-timeout.test.ts +154 -0
  1493. package/src/activities/execute-deep-agent/__tests__/hermetic/write-todos.test.ts +160 -0
  1494. package/src/activities/execute-deep-agent/__tests__/hitl.test.ts +355 -0
  1495. package/src/activities/execute-deep-agent/__tests__/hooks-setup.test.ts +333 -0
  1496. package/src/activities/execute-deep-agent/__tests__/inline-publisher.test.ts +350 -0
  1497. package/src/activities/execute-deep-agent/__tests__/loaded-tool-marks.test.ts +95 -0
  1498. package/src/activities/execute-deep-agent/__tests__/plain-turn.live.test.ts +103 -0
  1499. package/src/activities/execute-deep-agent/__tests__/plan-mode-path-normalization.test.ts +404 -0
  1500. package/src/activities/execute-deep-agent/__tests__/platform-route.test.ts +185 -0
  1501. package/src/activities/execute-deep-agent/__tests__/prompt-builder.test.ts +577 -0
  1502. package/src/activities/execute-deep-agent/__tests__/prompt-goldens.test.ts +293 -0
  1503. package/src/activities/execute-deep-agent/__tests__/resume-across-think-retirement.live.test.ts +98 -0
  1504. package/src/activities/execute-deep-agent/__tests__/resumed-history.test.ts +48 -0
  1505. package/src/activities/execute-deep-agent/__tests__/scripted-model.test.ts +408 -0
  1506. package/src/activities/execute-deep-agent/__tests__/shell-execute-gate.test.ts +293 -0
  1507. package/src/activities/execute-deep-agent/__tests__/streaming-side-effects.test.ts +120 -0
  1508. package/src/activities/execute-deep-agent/__tests__/subagent-approval-propagation.test.ts +160 -0
  1509. package/src/activities/execute-deep-agent/__tests__/subagent-gitignored-capture.test.ts +214 -0
  1510. package/src/activities/execute-deep-agent/__tests__/subagent-plan-mode-permissions.test.ts +213 -0
  1511. package/src/activities/execute-deep-agent/__tests__/subagent-spans.test.ts +110 -0
  1512. package/src/activities/execute-deep-agent/__tests__/subagent-transformer.test.ts +662 -0
  1513. package/src/activities/execute-deep-agent/__tests__/subagent-wiring.test.ts +197 -0
  1514. package/src/activities/execute-deep-agent/__tests__/summarization-verification.test.ts +330 -0
  1515. package/src/activities/execute-deep-agent/__tests__/tool-call.live.test.ts +80 -0
  1516. package/src/activities/execute-deep-agent/__tests__/tool-scope.test.ts +519 -0
  1517. package/src/activities/execute-deep-agent/__tests__/translator-subagents.test.ts +519 -0
  1518. package/src/activities/execute-deep-agent/__tests__/translator-through-builder.test.ts +830 -0
  1519. package/src/activities/execute-deep-agent/__tests__/translator.test.ts +641 -0
  1520. package/src/activities/execute-deep-agent/__tests__/turn-setup-connect.test.ts +89 -0
  1521. package/src/activities/execute-deep-agent/__tests__/turn-setup-tool-lists.test.ts +192 -0
  1522. package/src/activities/execute-deep-agent/__tests__/turn-stream.test.ts +381 -0
  1523. package/src/activities/execute-deep-agent/__tests__/v3-event-recorder.test.ts +186 -0
  1524. package/src/activities/execute-deep-agent/__tests__/vision-input.test.ts +152 -0
  1525. package/src/activities/execute-deep-agent/adapter.ts +95 -0
  1526. package/src/activities/execute-deep-agent/approval-file-change.ts +86 -0
  1527. package/src/activities/execute-deep-agent/auto-publish.ts +80 -0
  1528. package/src/activities/execute-deep-agent/cas-capture-backend.ts +154 -0
  1529. package/src/activities/execute-deep-agent/cas-capture-observer.ts +132 -0
  1530. package/src/activities/execute-deep-agent/deep-agent-capabilities.ts +49 -0
  1531. package/src/activities/execute-deep-agent/deepagents-profiles.ts +51 -0
  1532. package/src/activities/execute-deep-agent/engine-tools.ts +33 -0
  1533. package/src/activities/execute-deep-agent/hitl.ts +274 -0
  1534. package/src/activities/execute-deep-agent/hooks-setup.ts +75 -0
  1535. package/src/activities/execute-deep-agent/inline-publisher.ts +208 -0
  1536. package/src/activities/execute-deep-agent/platform-route.ts +284 -0
  1537. package/src/activities/execute-deep-agent/prompt-builder.ts +547 -0
  1538. package/src/activities/execute-deep-agent/resumed-history.ts +52 -0
  1539. package/src/activities/execute-deep-agent/streaming-side-effects.ts +83 -0
  1540. package/src/activities/execute-deep-agent/subagent-transformer.ts +732 -0
  1541. package/src/activities/execute-deep-agent/subagent-wiring.ts +180 -0
  1542. package/src/activities/execute-deep-agent/todo-list.ts +56 -0
  1543. package/src/activities/execute-deep-agent/translator.ts +564 -0
  1544. package/src/activities/execute-deep-agent/turn-settle.ts +162 -0
  1545. package/src/activities/execute-deep-agent/turn-setup.ts +842 -0
  1546. package/src/activities/execute-deep-agent/turn-stream.ts +309 -0
  1547. package/src/activities/execute-deep-agent/turn.ts +151 -0
  1548. package/src/activities/execute-deep-agent/v3-event-recorder.ts +112 -0
  1549. package/src/activities/generate-session-subject.ts +376 -0
  1550. package/src/activities/list-plugin-tools.ts +251 -0
  1551. package/src/agent-host/__tests__/channel.test.ts +271 -0
  1552. package/src/agent-host/__tests__/codec.test.ts +435 -0
  1553. package/src/agent-host/__tests__/entry-telemetry.test.ts +159 -0
  1554. package/src/agent-host/__tests__/entry.test.ts +223 -0
  1555. package/src/agent-host/__tests__/environment.test.ts +73 -0
  1556. package/src/agent-host/__tests__/failed-boot.test.ts +58 -0
  1557. package/src/agent-host/__tests__/host-sink.test.ts +118 -0
  1558. package/src/agent-host/__tests__/host.test.ts +162 -0
  1559. package/src/agent-host/__tests__/hostile-host.test.ts +440 -0
  1560. package/src/agent-host/__tests__/offload-through-host.test.ts +124 -0
  1561. package/src/agent-host/__tests__/remote-fs.test.ts +177 -0
  1562. package/src/agent-host/__tests__/spawned-host.test.ts +174 -0
  1563. package/src/agent-host/__tests__/supervisor.test.ts +488 -0
  1564. package/src/agent-host/channel.ts +334 -0
  1565. package/src/agent-host/codec.ts +631 -0
  1566. package/src/agent-host/entry.ts +153 -0
  1567. package/src/agent-host/environment.ts +76 -0
  1568. package/src/agent-host/failed-boot.ts +29 -0
  1569. package/src/agent-host/fs-service.ts +133 -0
  1570. package/src/agent-host/host-sink.ts +153 -0
  1571. package/src/agent-host/host.ts +228 -0
  1572. package/src/agent-host/hosting.ts +162 -0
  1573. package/src/agent-host/protocol.ts +380 -0
  1574. package/src/agent-host/remote-adapter.ts +320 -0
  1575. package/src/agent-host/remote-fs.ts +128 -0
  1576. package/src/agent-host/supervisor.ts +382 -0
  1577. package/src/agent-proxy/__tests__/cursor-lane.test.ts +635 -0
  1578. package/src/agent-proxy/__tests__/cursor-sdk-key-required.test.ts +119 -0
  1579. package/src/agent-proxy/__tests__/cursor-sdk-wire.test.ts +175 -0
  1580. package/src/agent-proxy/__tests__/lanes.test.ts +258 -0
  1581. package/src/agent-proxy/__tests__/loopback-certificate.test.ts +100 -0
  1582. package/src/agent-proxy/__tests__/otlp-forward-rebuild.test.ts +66 -0
  1583. package/src/agent-proxy/__tests__/otlp-forward.test.ts +295 -0
  1584. package/src/agent-proxy/__tests__/relay.test.ts +115 -0
  1585. package/src/agent-proxy/__tests__/server.test.ts +436 -0
  1586. package/src/agent-proxy/cursor-lane.ts +528 -0
  1587. package/src/agent-proxy/lanes.ts +285 -0
  1588. package/src/agent-proxy/loopback-certificate.ts +143 -0
  1589. package/src/agent-proxy/otlp-forward.ts +190 -0
  1590. package/src/agent-proxy/relay.ts +188 -0
  1591. package/src/agent-proxy/server.ts +266 -0
  1592. package/src/attach/__tests__/entry.test.ts +123 -0
  1593. package/src/attach/__tests__/import-graph.test.ts +66 -0
  1594. package/src/attach/__tests__/push.test.ts +162 -0
  1595. package/src/attach/__tests__/waiter.test.ts +416 -0
  1596. package/src/attach/entry.ts +92 -0
  1597. package/src/attach/main.ts +26 -0
  1598. package/src/attach/push.ts +165 -0
  1599. package/src/attach/waiter.ts +370 -0
  1600. package/src/bootstrap.ts +178 -0
  1601. package/src/client/__tests__/agent-version-read.test.ts +39 -0
  1602. package/src/client/__tests__/eval-read.test.ts +43 -0
  1603. package/src/client/__tests__/plugin-read.test.ts +57 -0
  1604. package/src/client/__tests__/run-calls.test.ts +65 -0
  1605. package/src/client/__tests__/server-contracts.test.ts +157 -0
  1606. package/src/client/__tests__/session-events-calls.test.ts +139 -0
  1607. package/src/client/__tests__/stigmer-client.test.ts +577 -0
  1608. package/src/client/__tests__/token-claims.test.ts +102 -0
  1609. package/src/client/server-contracts.ts +124 -0
  1610. package/src/client/stigmer-client.ts +686 -0
  1611. package/src/client/token-claims.ts +103 -0
  1612. package/src/config.ts +378 -0
  1613. package/src/exit-backstop.ts +97 -0
  1614. package/src/gen/turn/ai/stigmer/runner/turn/v1/enum_pb.ts +1142 -0
  1615. package/src/gen/turn/ai/stigmer/runner/turn/v1/ledger_pb.ts +458 -0
  1616. package/src/gen/turn/ai/stigmer/runner/turn/v1/rows_pb.ts +920 -0
  1617. package/src/gen-ai-conventions.ts +121 -0
  1618. package/src/harness/README.md +372 -0
  1619. package/src/harness/__tests__/approval-answers.test.ts +202 -0
  1620. package/src/harness/__tests__/approval-decisions.test.ts +114 -0
  1621. package/src/harness/__tests__/attachment-credential.test.ts +115 -0
  1622. package/src/harness/__tests__/capture.test.ts +285 -0
  1623. package/src/harness/__tests__/import-direction.test.ts +169 -0
  1624. package/src/harness/__tests__/loaded-versions.test.ts +76 -0
  1625. package/src/harness/__tests__/mount-skills.test.ts +305 -0
  1626. package/src/harness/__tests__/owed-undos.test.ts +305 -0
  1627. package/src/harness/__tests__/persist-chokepoint.test.ts +344 -0
  1628. package/src/harness/__tests__/readme-index.test.ts +339 -0
  1629. package/src/harness/__tests__/reconcile-turn.test.ts +111 -0
  1630. package/src/harness/__tests__/registry.test.ts +178 -0
  1631. package/src/harness/__tests__/reinvocation-carry.test.ts +65 -0
  1632. package/src/harness/__tests__/resolve-hooks.test.ts +241 -0
  1633. package/src/harness/__tests__/resolve-subagents.test.ts +477 -0
  1634. package/src/harness/__tests__/run-span.test.ts +255 -0
  1635. package/src/harness/__tests__/run-turn-deterministic.test.ts +94 -0
  1636. package/src/harness/__tests__/run-turn-eval-case.test.ts +211 -0
  1637. package/src/harness/__tests__/run-turn.test.ts +435 -0
  1638. package/src/harness/__tests__/runtime-touches-no-agent-path.test.ts +109 -0
  1639. package/src/harness/__tests__/stop-controller.test.ts +93 -0
  1640. package/src/harness/__tests__/terminal-table.test.ts +81 -0
  1641. package/src/harness/__tests__/transcript-is-engine-free.test.ts +83 -0
  1642. package/src/harness/__tests__/transcript-writers.test.ts +193 -0
  1643. package/src/harness/__tests__/turn-attachments-vision.test.ts +105 -0
  1644. package/src/harness/__tests__/turn-context.test.ts +213 -0
  1645. package/src/harness/__tests__/turn-mcp.test.ts +554 -0
  1646. package/src/harness/__tests__/turn-timeline.test.ts +290 -0
  1647. package/src/harness/__tests__/usage-accumulator.test.ts +106 -0
  1648. package/src/harness/approval-answers.ts +174 -0
  1649. package/src/harness/approval-decisions.ts +82 -0
  1650. package/src/harness/capabilities.ts +155 -0
  1651. package/src/harness/capture.ts +337 -0
  1652. package/src/harness/cost-cap-watch.ts +52 -0
  1653. package/src/harness/events/__tests__/emitter.test.ts +715 -0
  1654. package/src/harness/events/__tests__/ids-corpus.test.ts +86 -0
  1655. package/src/harness/events/emitter.ts +805 -0
  1656. package/src/harness/events/ids.ts +156 -0
  1657. package/src/harness/loaded-versions.ts +78 -0
  1658. package/src/harness/owed-undos.ts +258 -0
  1659. package/src/harness/persist-chokepoint.ts +163 -0
  1660. package/src/harness/registry.ts +203 -0
  1661. package/src/harness/run-span.ts +184 -0
  1662. package/src/harness/run-turn.ts +862 -0
  1663. package/src/harness/stop-controller.ts +101 -0
  1664. package/src/harness/terminal-table.ts +390 -0
  1665. package/src/harness/transcript/__tests__/builder.test.ts +1246 -0
  1666. package/src/harness/transcript/__tests__/resume-seed.test.ts +148 -0
  1667. package/src/harness/transcript/__tests__/state.test.ts +144 -0
  1668. package/src/harness/transcript/builder.ts +925 -0
  1669. package/src/harness/transcript/events.ts +281 -0
  1670. package/src/harness/transcript/resume-seed.ts +280 -0
  1671. package/src/harness/transcript/state.ts +167 -0
  1672. package/src/harness/turn-context.ts +1982 -0
  1673. package/src/harness/turn-timeline.ts +248 -0
  1674. package/src/harness/types.ts +725 -0
  1675. package/src/harness/usage-accumulator.ts +134 -0
  1676. package/src/harness-adapters.ts +48 -0
  1677. package/src/idle-watchdog.ts +28 -0
  1678. package/src/in-flight.ts +71 -0
  1679. package/src/index.ts +48 -0
  1680. package/src/interceptors/__tests__/run-credential-activity.test.ts +86 -0
  1681. package/src/interceptors/run-credential-activity.ts +40 -0
  1682. package/src/ipc-protocol-fixtures.ts +90 -0
  1683. package/src/ipc-protocol.ts +89 -0
  1684. package/src/main.ts +506 -0
  1685. package/src/middleware/__tests__/advisory-message.test.ts +59 -0
  1686. package/src/middleware/__tests__/approval-gate-hooks.test.ts +269 -0
  1687. package/src/middleware/__tests__/approval-gate.test.ts +1072 -0
  1688. package/src/middleware/__tests__/cost-advisory.test.ts +272 -0
  1689. package/src/middleware/__tests__/error-hints.test.ts +90 -0
  1690. package/src/middleware/__tests__/execution-budget.test.ts +239 -0
  1691. package/src/middleware/__tests__/loop-detection.test.ts +194 -0
  1692. package/src/middleware/__tests__/otel-spans.test.ts +460 -0
  1693. package/src/middleware/__tests__/path-normalization.test.ts +198 -0
  1694. package/src/middleware/__tests__/tool-intent.test.ts +266 -0
  1695. package/src/middleware/__tests__/tool-truncation.test.ts +112 -0
  1696. package/src/middleware/advisory-message.ts +62 -0
  1697. package/src/middleware/approval-gate.ts +741 -0
  1698. package/src/middleware/cost-advisory.ts +224 -0
  1699. package/src/middleware/error-hints.ts +136 -0
  1700. package/src/middleware/execution-budget.ts +197 -0
  1701. package/src/middleware/index.ts +100 -0
  1702. package/src/middleware/loop-detection.ts +197 -0
  1703. package/src/middleware/otel-spans.ts +345 -0
  1704. package/src/middleware/path-normalization.ts +178 -0
  1705. package/src/middleware/tool-intent.ts +174 -0
  1706. package/src/middleware/tool-scope.ts +201 -0
  1707. package/src/middleware/tool-truncation.ts +94 -0
  1708. package/src/middleware/types.ts +141 -0
  1709. package/src/otel-export.ts +325 -0
  1710. package/src/otel-metrics.ts +61 -0
  1711. package/src/otel.ts +173 -0
  1712. package/src/payload-codecs.ts +66 -0
  1713. package/src/pipe-safety.ts +117 -0
  1714. package/src/pool-member.ts +99 -0
  1715. package/src/preflight.ts +104 -0
  1716. package/src/run-trace-id.ts +50 -0
  1717. package/src/runner-entry.ts +18 -0
  1718. package/src/runner-manager.ts +882 -0
  1719. package/src/runner-token-coordinator.ts +140 -0
  1720. package/src/runner.ts +588 -0
  1721. package/src/sandbox-token-renewal.ts +211 -0
  1722. package/src/shared/__tests__/activity-input.test.ts +78 -0
  1723. package/src/shared/__tests__/advisory-anthropic-payload.test.ts +194 -0
  1724. package/src/shared/__tests__/agent-handover.test.ts +186 -0
  1725. package/src/shared/__tests__/agent-identity.test.ts +144 -0
  1726. package/src/shared/__tests__/agent-servers.test.ts +55 -0
  1727. package/src/shared/__tests__/approval-canonicalize.test.ts +106 -0
  1728. package/src/shared/__tests__/approval-fingerprint.test.ts +115 -0
  1729. package/src/shared/__tests__/approval-policy.test.ts +466 -0
  1730. package/src/shared/__tests__/args-preview.test.ts +147 -0
  1731. package/src/shared/__tests__/artifact-storage-extended.test.ts +243 -0
  1732. package/src/shared/__tests__/artifact-storage.test.ts +844 -0
  1733. package/src/shared/__tests__/attachment-download-urls.test.ts +72 -0
  1734. package/src/shared/__tests__/attachment-naming.test.ts +146 -0
  1735. package/src/shared/__tests__/attachment-resolver.test.ts +644 -0
  1736. package/src/shared/__tests__/attachment-vision.test.ts +424 -0
  1737. package/src/shared/__tests__/attachment-zip.test.ts +236 -0
  1738. package/src/shared/__tests__/bedrock-adapter.test.ts +213 -0
  1739. package/src/shared/__tests__/bedrock-seam.test.ts +390 -0
  1740. package/src/shared/__tests__/blueprint-resolver.test.ts +629 -0
  1741. package/src/shared/__tests__/builtin-judge.test.ts +57 -0
  1742. package/src/shared/__tests__/caller-identity.test.ts +172 -0
  1743. package/src/shared/__tests__/channel-attachment.test.ts +285 -0
  1744. package/src/shared/__tests__/cold-start-timing.test.ts +333 -0
  1745. package/src/shared/__tests__/context-bridge.test.ts +51 -0
  1746. package/src/shared/__tests__/conversation-attachment.test.ts +152 -0
  1747. package/src/shared/__tests__/conversation-catchup.test.ts +94 -0
  1748. package/src/shared/__tests__/cost-guard.test.ts +68 -0
  1749. package/src/shared/__tests__/declared-preferences.test.ts +109 -0
  1750. package/src/shared/__tests__/default-model-agrees-with-server.test.ts +74 -0
  1751. package/src/shared/__tests__/exact-apply.test.ts +370 -0
  1752. package/src/shared/__tests__/execution-target.test.ts +33 -0
  1753. package/src/shared/__tests__/extract-json.test.ts +153 -0
  1754. package/src/shared/__tests__/extract-structured-output.test.ts +149 -0
  1755. package/src/shared/__tests__/file-change.test.ts +85 -0
  1756. package/src/shared/__tests__/file-tools.test.ts +90 -0
  1757. package/src/shared/__tests__/fingerprint-secret.test.ts +51 -0
  1758. package/src/shared/__tests__/foundry-adapter.test.ts +276 -0
  1759. package/src/shared/__tests__/foundry-seam.test.ts +482 -0
  1760. package/src/shared/__tests__/grpc-retry-extended.test.ts +38 -0
  1761. package/src/shared/__tests__/grpc-retry.test.ts +43 -0
  1762. package/src/shared/__tests__/http-retry.test.ts +68 -0
  1763. package/src/shared/__tests__/implement-plan-prompt.test.ts +86 -0
  1764. package/src/shared/__tests__/json-schema-to-zod.test.ts +227 -0
  1765. package/src/shared/__tests__/lease-scope-corpus.test.ts +78 -0
  1766. package/src/shared/__tests__/llm-backend.test.ts +676 -0
  1767. package/src/shared/__tests__/llm-proxy.test.ts +179 -0
  1768. package/src/shared/__tests__/mcp-manager.test.ts +272 -0
  1769. package/src/shared/__tests__/mcp-oauth-detect.test.ts +167 -0
  1770. package/src/shared/__tests__/mcp-resolver.test.ts +454 -0
  1771. package/src/shared/__tests__/mcp-schema-sanitizer.test.ts +267 -0
  1772. package/src/shared/__tests__/mcp-tool-listing.hang.test.ts +82 -0
  1773. package/src/shared/__tests__/mcp-tool-listing.test.ts +257 -0
  1774. package/src/shared/__tests__/mcp-transport-guard.test.ts +71 -0
  1775. package/src/shared/__tests__/memory-attachment.test.ts +183 -0
  1776. package/src/shared/__tests__/memory-retrieval.test.ts +310 -0
  1777. package/src/shared/__tests__/model-client-sampling.test.ts +110 -0
  1778. package/src/shared/__tests__/model-client.test.ts +623 -0
  1779. package/src/shared/__tests__/model-error.test.ts +579 -0
  1780. package/src/shared/__tests__/model-lanes.test.ts +225 -0
  1781. package/src/shared/__tests__/model-pricing.test.ts +131 -0
  1782. package/src/shared/__tests__/model-registry-at-provider.live.test.ts +63 -0
  1783. package/src/shared/__tests__/model-registry.test.ts +460 -0
  1784. package/src/shared/__tests__/persist-decision.test.ts +87 -0
  1785. package/src/shared/__tests__/placeholder-resolver.test.ts +210 -0
  1786. package/src/shared/__tests__/plan-artifact.test.ts +260 -0
  1787. package/src/shared/__tests__/plan-mode-permissions.test.ts +29 -0
  1788. package/src/shared/__tests__/platform-server-address.test.ts +125 -0
  1789. package/src/shared/__tests__/plugin-mount-faults.test.ts +71 -0
  1790. package/src/shared/__tests__/plugin-mount.test.ts +407 -0
  1791. package/src/shared/__tests__/plugin-servers.test.ts +53 -0
  1792. package/src/shared/__tests__/policy-source-corpus.test.ts +69 -0
  1793. package/src/shared/__tests__/prompt-sections.test.ts +113 -0
  1794. package/src/shared/__tests__/recalled-memories.test.ts +88 -0
  1795. package/src/shared/__tests__/registry-endpoint.test.ts +96 -0
  1796. package/src/shared/__tests__/run-credential.test.ts +109 -0
  1797. package/src/shared/__tests__/run-values.test.ts +125 -0
  1798. package/src/shared/__tests__/runner-credential-store.test.ts +175 -0
  1799. package/src/shared/__tests__/secret-leak-scan.test.ts +100 -0
  1800. package/src/shared/__tests__/sender-identity.test.ts +92 -0
  1801. package/src/shared/__tests__/session-context.test.ts +67 -0
  1802. package/src/shared/__tests__/shell-env.test.ts +118 -0
  1803. package/src/shared/__tests__/skill-mount.test.ts +353 -0
  1804. package/src/shared/__tests__/skill-resolver.test.ts +401 -0
  1805. package/src/shared/__tests__/stall-watchdog.test.ts +193 -0
  1806. package/src/shared/__tests__/stamp-flowed-rows.test.ts +142 -0
  1807. package/src/shared/__tests__/status-offload.test.ts +778 -0
  1808. package/src/shared/__tests__/status.test.ts +350 -0
  1809. package/src/shared/__tests__/streaming-scheduler.test.ts +198 -0
  1810. package/src/shared/__tests__/subagent-gate.test.ts +112 -0
  1811. package/src/shared/__tests__/subagent-rows.test.ts +34 -0
  1812. package/src/shared/__tests__/subagents.test.ts +135 -0
  1813. package/src/shared/__tests__/synthesized-attachment.test.ts +96 -0
  1814. package/src/shared/__tests__/telemetry-content.test.ts +220 -0
  1815. package/src/shared/__tests__/thinking-mode.test.ts +69 -0
  1816. package/src/shared/__tests__/todos.test.ts +216 -0
  1817. package/src/shared/__tests__/tool-kind.test.ts +81 -0
  1818. package/src/shared/__tests__/tool-lists.test.ts +463 -0
  1819. package/src/shared/__tests__/tool-rounds.test.ts +107 -0
  1820. package/src/shared/__tests__/tool-row.test.ts +390 -0
  1821. package/src/shared/__tests__/trace-context.test.ts +68 -0
  1822. package/src/shared/__tests__/vertex-adapter.test.ts +196 -0
  1823. package/src/shared/__tests__/vertex-seam.test.ts +296 -0
  1824. package/src/shared/__tests__/with-timeout.test.ts +60 -0
  1825. package/src/shared/__tests__/worker-shutdown.test.ts +106 -0
  1826. package/src/shared/__tests__/zip-extract.test.ts +256 -0
  1827. package/src/shared/activity-input.ts +78 -0
  1828. package/src/shared/agent-fs.ts +264 -0
  1829. package/src/shared/agent-handover.ts +171 -0
  1830. package/src/shared/agent-identity.ts +185 -0
  1831. package/src/shared/agent-servers.ts +51 -0
  1832. package/src/shared/approval-canonicalize.ts +159 -0
  1833. package/src/shared/approval-fingerprint.ts +145 -0
  1834. package/src/shared/approval-policy.ts +536 -0
  1835. package/src/shared/archive-mount.ts +140 -0
  1836. package/src/shared/args-preview.ts +128 -0
  1837. package/src/shared/artifact-storage.ts +496 -0
  1838. package/src/shared/attachment-download-urls.ts +76 -0
  1839. package/src/shared/attachment-naming.ts +78 -0
  1840. package/src/shared/attachment-resolver.ts +468 -0
  1841. package/src/shared/attachment-vision.ts +466 -0
  1842. package/src/shared/attachment-zip.ts +281 -0
  1843. package/src/shared/blueprint-resolver.ts +420 -0
  1844. package/src/shared/builtin-assistant-prompt.ts +38 -0
  1845. package/src/shared/builtin-judge.ts +62 -0
  1846. package/src/shared/caller-identity.ts +186 -0
  1847. package/src/shared/channel-attachment.ts +246 -0
  1848. package/src/shared/checkpointer/__tests__/factory.test.ts +88 -0
  1849. package/src/shared/checkpointer/__tests__/http-saver.test.ts +393 -0
  1850. package/src/shared/checkpointer/__tests__/sqlite-saver.test.ts +212 -0
  1851. package/src/shared/checkpointer/factory.ts +94 -0
  1852. package/src/shared/checkpointer/http-saver.ts +429 -0
  1853. package/src/shared/checkpointer/sqlite-saver.ts +384 -0
  1854. package/src/shared/checkpointer/types.ts +27 -0
  1855. package/src/shared/cold-start-timing.ts +260 -0
  1856. package/src/shared/context-bridge.ts +51 -0
  1857. package/src/shared/conversation-attachment.ts +141 -0
  1858. package/src/shared/conversation-catchup.ts +93 -0
  1859. package/src/shared/cost-guard.ts +63 -0
  1860. package/src/shared/declared-preferences.ts +84 -0
  1861. package/src/shared/eval-case/__tests__/agent-mock.test.ts +126 -0
  1862. package/src/shared/eval-case/__tests__/case-archive.test.ts +159 -0
  1863. package/src/shared/eval-case/__tests__/mock-endpoint-failure.test.ts +65 -0
  1864. package/src/shared/eval-case/__tests__/mock-endpoint.test.ts +269 -0
  1865. package/src/shared/eval-case/__tests__/prepare-case.test.ts +228 -0
  1866. package/src/shared/eval-case/__tests__/read-files.test.ts +90 -0
  1867. package/src/shared/eval-case/agent-mock.ts +131 -0
  1868. package/src/shared/eval-case/case-archive.ts +135 -0
  1869. package/src/shared/eval-case/mock-endpoint.ts +282 -0
  1870. package/src/shared/eval-case/prepare-case.ts +227 -0
  1871. package/src/shared/eval-case/read-files.ts +94 -0
  1872. package/src/shared/exact-apply.ts +247 -0
  1873. package/src/shared/execution-context.ts +62 -0
  1874. package/src/shared/execution-target.ts +17 -0
  1875. package/src/shared/extract-json.ts +153 -0
  1876. package/src/shared/extract-structured-output.ts +83 -0
  1877. package/src/shared/file-change.ts +62 -0
  1878. package/src/shared/file-tools.ts +167 -0
  1879. package/src/shared/filereview/__tests__/capture.test.ts +1178 -0
  1880. package/src/shared/filereview/__tests__/cas-progress.test.ts +229 -0
  1881. package/src/shared/filereview/__tests__/cas-substrate.test.ts +504 -0
  1882. package/src/shared/filereview/__tests__/command-provenance.test.ts +249 -0
  1883. package/src/shared/filereview/__tests__/digest.test.ts +100 -0
  1884. package/src/shared/filereview/__tests__/events.test.ts +350 -0
  1885. package/src/shared/filereview/__tests__/git-substrate.test.ts +365 -0
  1886. package/src/shared/filereview/__tests__/line-counts.test.ts +73 -0
  1887. package/src/shared/filereview/__tests__/progress.test.ts +480 -0
  1888. package/src/shared/filereview/__tests__/proxy-reconcile.test.ts +265 -0
  1889. package/src/shared/filereview/__tests__/record.test.ts +126 -0
  1890. package/src/shared/filereview/__tests__/secret-paths.test.ts +121 -0
  1891. package/src/shared/filereview/capture.ts +783 -0
  1892. package/src/shared/filereview/cas-progress.ts +155 -0
  1893. package/src/shared/filereview/cas-substrate.ts +460 -0
  1894. package/src/shared/filereview/cas-touched.ts +89 -0
  1895. package/src/shared/filereview/command-provenance.ts +182 -0
  1896. package/src/shared/filereview/digest.ts +83 -0
  1897. package/src/shared/filereview/events.ts +515 -0
  1898. package/src/shared/filereview/git-substrate.ts +680 -0
  1899. package/src/shared/filereview/index.ts +99 -0
  1900. package/src/shared/filereview/line-counts.ts +83 -0
  1901. package/src/shared/filereview/progress.ts +361 -0
  1902. package/src/shared/filereview/record.ts +107 -0
  1903. package/src/shared/filereview/secret-paths.ts +119 -0
  1904. package/src/shared/fingerprint-secret.ts +77 -0
  1905. package/src/shared/grpc-retry.ts +54 -0
  1906. package/src/shared/heartbeat.ts +50 -0
  1907. package/src/shared/hooks/__tests__/answer.test.ts +179 -0
  1908. package/src/shared/hooks/__tests__/condition.test.ts +389 -0
  1909. package/src/shared/hooks/__tests__/cursor-format.test.ts +209 -0
  1910. package/src/shared/hooks/__tests__/evaluate.test.ts +473 -0
  1911. package/src/shared/hooks/__tests__/run.test.ts +159 -0
  1912. package/src/shared/hooks/__tests__/stall.test.ts +75 -0
  1913. package/src/shared/hooks/__tests__/tool-view.test.ts +235 -0
  1914. package/src/shared/hooks/answer.ts +180 -0
  1915. package/src/shared/hooks/condition.ts +341 -0
  1916. package/src/shared/hooks/evaluate.ts +381 -0
  1917. package/src/shared/hooks/formats/claude-code.ts +106 -0
  1918. package/src/shared/hooks/formats/common.ts +31 -0
  1919. package/src/shared/hooks/formats/cursor.ts +261 -0
  1920. package/src/shared/hooks/hook-set.ts +134 -0
  1921. package/src/shared/hooks/matcher.ts +31 -0
  1922. package/src/shared/hooks/messages.ts +38 -0
  1923. package/src/shared/hooks/run.ts +190 -0
  1924. package/src/shared/hooks/setup.ts +209 -0
  1925. package/src/shared/hooks/shell-commands.ts +326 -0
  1926. package/src/shared/hooks/tool-view.ts +406 -0
  1927. package/src/shared/http-retry.ts +139 -0
  1928. package/src/shared/implement-plan-prompt.ts +104 -0
  1929. package/src/shared/json-schema-to-zod.ts +53 -0
  1930. package/src/shared/llm-backend.ts +623 -0
  1931. package/src/shared/llm-proxy.ts +154 -0
  1932. package/src/shared/mcp-manager.ts +161 -0
  1933. package/src/shared/mcp-oauth-detect.ts +80 -0
  1934. package/src/shared/mcp-resolver.ts +338 -0
  1935. package/src/shared/mcp-schema-sanitizer.ts +222 -0
  1936. package/src/shared/mcp-tool-listing.ts +203 -0
  1937. package/src/shared/mcp-transport-guard.ts +81 -0
  1938. package/src/shared/memory-attachment.ts +177 -0
  1939. package/src/shared/memory-retrieval.ts +380 -0
  1940. package/src/shared/model-client.ts +465 -0
  1941. package/src/shared/model-error.ts +551 -0
  1942. package/src/shared/model-facts.ts +30 -0
  1943. package/src/shared/model-lanes.ts +66 -0
  1944. package/src/shared/model-pricing-data.ts +123 -0
  1945. package/src/shared/model-pricing.ts +64 -0
  1946. package/src/shared/model-registry.ts +352 -0
  1947. package/src/shared/persist-decision.ts +47 -0
  1948. package/src/shared/placeholder-resolver.ts +113 -0
  1949. package/src/shared/plan-artifact.ts +255 -0
  1950. package/src/shared/plan-mode-permissions.ts +53 -0
  1951. package/src/shared/plan-mode-prompt.ts +74 -0
  1952. package/src/shared/platform-server-address.ts +124 -0
  1953. package/src/shared/plugin-mount.ts +495 -0
  1954. package/src/shared/plugin-servers.ts +23 -0
  1955. package/src/shared/prompt-sections.ts +205 -0
  1956. package/src/shared/recalled-memories.ts +90 -0
  1957. package/src/shared/registry-endpoint.ts +108 -0
  1958. package/src/shared/run-credential-store.ts +45 -0
  1959. package/src/shared/run-credential.ts +48 -0
  1960. package/src/shared/run-values.ts +154 -0
  1961. package/src/shared/runner-credential-keys.ts +106 -0
  1962. package/src/shared/runner-credential-store.ts +115 -0
  1963. package/src/shared/sender-identity.ts +85 -0
  1964. package/src/shared/service-tier.ts +78 -0
  1965. package/src/shared/session-context.ts +58 -0
  1966. package/src/shared/shell-env.ts +75 -0
  1967. package/src/shared/skill-mount.ts +214 -0
  1968. package/src/shared/skill-resolver.ts +167 -0
  1969. package/src/shared/stall-watchdog.ts +122 -0
  1970. package/src/shared/status-offload.ts +742 -0
  1971. package/src/shared/status.ts +268 -0
  1972. package/src/shared/streaming-scheduler.ts +158 -0
  1973. package/src/shared/subagent-gate.ts +122 -0
  1974. package/src/shared/subagent-rows.ts +39 -0
  1975. package/src/shared/subagents.ts +75 -0
  1976. package/src/shared/synthesized-attachment.ts +100 -0
  1977. package/src/shared/telemetry-content.ts +301 -0
  1978. package/src/shared/thinking-mode.ts +125 -0
  1979. package/src/shared/todos.ts +68 -0
  1980. package/src/shared/tool-kind.ts +140 -0
  1981. package/src/shared/tool-lists.ts +617 -0
  1982. package/src/shared/tool-rounds.ts +151 -0
  1983. package/src/shared/tool-row.ts +346 -0
  1984. package/src/shared/trace-context.ts +35 -0
  1985. package/src/shared/with-timeout.ts +53 -0
  1986. package/src/shared/worker-shutdown.ts +134 -0
  1987. package/src/shared/workspace/__tests__/file-tree.test.ts +210 -0
  1988. package/src/shared/workspace/__tests__/git-credential.test.ts +470 -0
  1989. package/src/shared/workspace/__tests__/git-identity.test.ts +124 -0
  1990. package/src/shared/workspace/__tests__/git-source.test.ts +476 -0
  1991. package/src/shared/workspace/__tests__/local-backend-platform.test.ts +259 -0
  1992. package/src/shared/workspace/__tests__/local-backend.test.ts +160 -0
  1993. package/src/shared/workspace/__tests__/platform-mount.test.ts +378 -0
  1994. package/src/shared/workspace/__tests__/provisioner.test.ts +194 -0
  1995. package/src/shared/workspace/__tests__/session-provision.test.ts +322 -0
  1996. package/src/shared/workspace/__tests__/session-root.test.ts +42 -0
  1997. package/src/shared/workspace/__tests__/stigmer-link.test.ts +278 -0
  1998. package/src/shared/workspace/__tests__/workspace-lock.test.ts +207 -0
  1999. package/src/shared/workspace/__tests__/writeback-coordinator-git.test.ts +244 -0
  2000. package/src/shared/workspace/__tests__/writeback-coordinator.test.ts +495 -0
  2001. package/src/shared/workspace/file-tree.ts +116 -0
  2002. package/src/shared/workspace/git-credential.ts +247 -0
  2003. package/src/shared/workspace/git-identity.ts +41 -0
  2004. package/src/shared/workspace/local-backend.ts +132 -0
  2005. package/src/shared/workspace/platform-dir.ts +163 -0
  2006. package/src/shared/workspace/platform-mount.ts +190 -0
  2007. package/src/shared/workspace/provisioner.ts +119 -0
  2008. package/src/shared/workspace/session-provision.ts +104 -0
  2009. package/src/shared/workspace/session-root.ts +60 -0
  2010. package/src/shared/workspace/sources/empty.ts +19 -0
  2011. package/src/shared/workspace/sources/git.ts +292 -0
  2012. package/src/shared/workspace/sources/local-path.ts +92 -0
  2013. package/src/shared/workspace/stigmer-link.ts +185 -0
  2014. package/src/shared/workspace/types.ts +85 -0
  2015. package/src/shared/workspace/workspace-lock.ts +245 -0
  2016. package/src/shared/workspace/writeback-coordinator.ts +522 -0
  2017. package/src/shared/zip-extract.ts +118 -0
  2018. package/src/tools/__tests__/url-guard.test.ts +155 -0
  2019. package/src/tools/__tests__/web-fetch-tool.test.ts +193 -0
  2020. package/src/tools/index.ts +27 -0
  2021. package/src/tools/url-guard.ts +140 -0
  2022. package/src/tools/web-fetch-tool.ts +278 -0
  2023. package/src/worker.ts +112 -0
  2024. package/src/workflow-source.ts +72 -0
  2025. package/src/workflows/__tests__/barrel.test.ts +21 -0
  2026. package/src/workflows/__tests__/list-plugin-tools.test.ts +82 -0
  2027. package/src/workflows/index.ts +36 -0
  2028. package/src/workflows/list-plugin-tools.ts +70 -0
  2029. package/src/workflows/types.ts +46 -0
@@ -0,0 +1,1268 @@
1
+ /**
2
+ * The Cursor harness's boundary rows — the post-stream settlements that turn
3
+ * the deny-and-retry primitive's evidence into transcript rows the runtime's
4
+ * review surfaces read: the denial overlay (a hook-denied call becomes the
5
+ * turn's one WAITING_APPROVAL gate), the same-identity twin collapse, the
6
+ * one-gate-per-turn collapse of non-anchor denials, the provisional-narration
7
+ * redaction, the #205 foreign-hook-block detector, the #965 unresolved-row
8
+ * settle, and the unattended-mode SKIPPED stamp.
9
+ *
10
+ * Moved verbatim from the boundary half of `message-translator.ts` in #1097,
11
+ * so that module's folding half — the Cursor accumulator, the
12
+ * second copy of the transcript folding rule — could be deleted whole at the
13
+ * swap and replaced by `translator.ts` over the shared
14
+ * `TranscriptBuilder`. Nothing here folds engine events: every function
15
+ * AMENDS rows the stream already created, by identity (the token the hook and
16
+ * the runner share); the one row this module ever needs CREATED — the gate for
17
+ * a denial no streamed call matched — and the one it REOPENS — the streamed
18
+ * call the hook denied — go through the shared `TranscriptBuilder` as
19
+ * `approval_proposed`, the one post-stream fact both harnesses produce
20
+ * (#1097). `isTerminalToolStatus` below is the twin
21
+ * collapse's own settled set (`shared/tool-row.ts` explains why INTERRUPTED is
22
+ * not in it).
23
+ *
24
+ * The identity this module correlates on lives in `approval-state.ts`
25
+ * (`toolCallIdentityToken` beside `toolIdentity`/`primaryToken`, the same
26
+ * space the hook records denials in); the row predicates it shares with the
27
+ * runtime (`isAdjudicatedRow`, `isDeclinedRow`) in `shared/tool-row.ts`.
28
+ * The pipeline that calls these, and its ordering rationale, is
29
+ * `turn-boundary.ts`.
30
+ */
31
+ import { resolveApprovalMessage, resolveBuiltInApprovalMessage } from "./approval-policy.js";
32
+ import { CURSOR_SDK_TOOL_COVERS } from "@stigmer/tool-vocabulary";
33
+ import { normalizeSubAgentType } from "../../shared/tool-lists.js";
34
+ import { AGENT_SCOPE_KEY, READ_SCOPE_KEY, SCOPE_KEY_PREFIX, scopeKey } from "./hook-scope.js";
35
+ import { DESTRUCTIVE_MCP_APPROVAL_MESSAGE, mcpToolKey, UNLISTED_MCP_APPROVAL_MESSAGE, POLICY_ENGINE_VERSION, resolveApprovalProvenance, unattendedSkipMessage, } from "../../shared/approval-policy.js";
36
+ import { approvalDenials, decodeIdentityToken, denialKindOf, DISABLED_DENIAL_KIND, grantToken, HOOK_DENIAL_KIND, hookAskDigest, toolCallArgs, toolCallIdentityToken, toolIdentity, } from "./approval-state.js";
37
+ import { utcTimestamp } from "../../shared/status.js";
38
+ import { hideToolCallRow, isAdjudicatedRow, isToolCallRowHidden } from "../../shared/tool-row.js";
39
+ import { toolApprovalCategory } from "../../shared/tool-kind.js";
40
+ import { resolveWorkspacePath } from "../../shared/file-change.js";
41
+ import { contentDigest, extractFilePath } from "../../shared/file-tools.js";
42
+ import { isSecretLikePath } from "../../shared/filereview/secret-paths.js";
43
+ import { ApprovalPolicySource, MessageType, ToolCallStatus } from "../../gen/turn/ai/stigmer/runner/turn/v1/enum_pb.js";
44
+ /** No row settled from a refusal: the twin collapse's default keep-set. */
45
+ const NO_REFUSED_ROWS = new Set();
46
+ /** Shared empty set so a synthesized gate's provenance read allocates nothing. */
47
+ const NO_LEASED_CATEGORIES = new Set();
48
+ /**
49
+ * Terminal for the twin collapse's "prefer a settled representative" pick —
50
+ * the same set the merge guard used (`isSettled` in the shared builder):
51
+ * INTERRUPTED is deliberately NOT here; see `shared/tool-row.ts`.
52
+ */
53
+ function isTerminalToolStatus(status) {
54
+ return (status === ToolCallStatus.TOOL_CALL_COMPLETED ||
55
+ status === ToolCallStatus.TOOL_CALL_FAILED ||
56
+ status === ToolCallStatus.TOOL_CALL_SKIPPED);
57
+ }
58
+ /**
59
+ * Reconcile the denial ledger written by the preToolUse hook against the tool
60
+ * calls accumulated from the stream, marking each denied call as
61
+ * WAITING_APPROVAL.
62
+ *
63
+ * This is the cursor analog of the native harness synthesizing WAITING_APPROVAL
64
+ * tool calls from LangGraph interrupts (execute-deep-agent/turn-settle.ts). The hook
65
+ * ledger — not the SDK-reported tool status — is the authoritative record of
66
+ * what was gated, because the hook is the only component that makes the per-call
67
+ * allow/deny decision. The backend then projects pending_approvals from these
68
+ * WAITING_APPROVAL tool calls (PendingApprovalComputer), so the approval surface
69
+ * is driven entirely by tool-call status, exactly like the native harness.
70
+ *
71
+ * Correlation is by tool identity token (the same space as approvedGrantTokens),
72
+ * not by call id: a denied tool's identity is stable, and a single resource
73
+ * approved once should produce one approval regardless of how many times the
74
+ * agent re-attempted it within the turn.
75
+ *
76
+ * ONE GATE PER TURN (deny-only clean pause). The Cursor harness can only gate by
77
+ * the hook returning `deny`, which Cursor surfaces to the model as a tool
78
+ * *failure* — so a blocked model frequently improvises a workaround (the
79
+ * canonical case: a denied `edit notes.md` followed ~2.5s later by a
80
+ * `shell: cat > notes.md`, in the SAME assistant message with no narration
81
+ * between them — observed in production, exec aex_01kw4p0cqgk0j8vvxbs5t8gv59).
82
+ * The first-denial stop (index.ts) tries to cancel the turn at that first
83
+ * denial, but `run.cancel()` is async and races the SDK's auto-execution, so the
84
+ * workaround can still stream and land a SECOND denial in the ledger. Two
85
+ * denials of distinct identity would otherwise surface two approval cards for
86
+ * one logical intent. Their identities differ (`write\nnotes.md` vs
87
+ * `shell\ncat > notes.md`), so no same-identity twin collapse can join them, and
88
+ * they share one message, so no positional rule can separate them; the only
89
+ * honest signal that the second is a reaction is CAUSALITY — it was emitted
90
+ * after the model saw the first denial. We therefore ANCHOR on the FIRST ledger
91
+ * denial of the turn (the ledger is reset per turn and appended in denial order,
92
+ * so ledger[0] is the original intent) and surface ONLY that identity. Every
93
+ * other denied identity in the turn — a post-denial workaround, or a genuine
94
+ * co-pending sibling the deny-only harness defers — is blanked in place to a
95
+ * hidden SKIPPED row ({@link collapseNonAnchorDenials}). A deferred sibling is
96
+ * not lost: on resume it re-attempts and gates again next turn (sequential
97
+ * gating). The native (LangGraph) harness pauses BEFORE the model can react, so
98
+ * it keeps full in-turn co-pending and is untouched by this rule. This is the
99
+ * near-term, invariant-preserving stepping stone to the Tool Execution Gateway,
100
+ * where an un-leased workaround is refused by construction.
101
+ *
102
+ * Correlation runs in two passes. The first matches the streamed token to a
103
+ * ledger token byte-for-byte (the common case). The hook, however, records its
104
+ * token from the RAW path Cursor hands it — a bash script cannot normalize a
105
+ * path against the workspace root — so an ABSOLUTE hook `file_path` against a
106
+ * RELATIVE stream `path` (or vice versa) yields two different raw tokens for one
107
+ * edit and the exact pass misses. The runner CAN normalize, so a second pass
108
+ * matches any still-unmatched FILE denial to a streamed call by (category,
109
+ * workspace-normalized path) and overlays the REAL streamed call, never appending
110
+ * a content-less placeholder beside it. This is the difference between one honest
111
+ * gate and two cards, one of which reads "No preview available". It reuses the
112
+ * single tool-identity definition + `resolveWorkspacePath`; it introduces no
113
+ * parallel identity.
114
+ *
115
+ * Only after BOTH passes miss is a placeholder WAITING_APPROVAL tool call
116
+ * synthesized (rare — Cursor normally emits a tool_call event for every
117
+ * attempt), so the gate still surfaces and never renders as a silent success.
118
+ * Critically, every match overlays a call IN PLACE (the committed id is
119
+ * preserved): the backend's append-only-at-identity transcript guard rejects a
120
+ * finalize that drops a previously-committed tool-call id, so reconciliation may
121
+ * only reconcile entries in place, never remove them.
122
+ *
123
+ * Every matched/synthesized call is enriched with the hook-captured authoritative
124
+ * input (`ledger.input`) via {@link applyGateInput}: the full proposed args, a
125
+ * compact `args_preview`, and the content digest — so the approval card renders
126
+ * the proposed write/edit content from `args` and a resume re-gates a diverging
127
+ * sibling edit. A missing capture (the hook's grep fallback) degrades to the
128
+ * prior behavior.
129
+ *
130
+ * Every gate this function opens goes through the transcript builder as an
131
+ * `approval_proposed` (since #1097): a known row REOPENS
132
+ * (WAITING, the outcome the stream wrote cleared, the hook's captured input as
133
+ * its args and preview), an unknown one gets a WAITING row on the message
134
+ * whose text proposed it. The builder is the one writer of a WAITING row on
135
+ * both harnesses; this module supplies the fact and reads the row back.
136
+ *
137
+ * Two handles, one object: `messages` is the root transcript's own array
138
+ * (`status.messages`, the rows this function reads and matches against) and
139
+ * `transcript` is the builder that creates rows INTO that same array — it
140
+ * pushes and never replaces, so a row proposed through the builder is found
141
+ * in `messages` on the next line. Rows to read, a builder to create through:
142
+ * the sink's ownership rule, stated in the signature.
143
+ *
144
+ * Returns the tool calls now marked WAITING_APPROVAL — the single anchor gate
145
+ * for the turn (overlaid or, rarely, synthesized).
146
+ */
147
+ export async function reconcileDeniedToolCalls(messages, transcript, ledger, mcpDefault, workspaceBackend) {
148
+ // Defense-in-depth: only APPROVAL-kind denials may become approval gates.
149
+ // The turn boundary already passes the filtered subset; re-filtering here
150
+ // makes it structurally impossible for a secret/capture-error/fail-closed
151
+ // entry to manufacture a pause the user cannot meaningfully grant, no matter
152
+ // what a future caller passes (an absent kind is the pre-kind format and
153
+ // counts as approval).
154
+ ledger = approvalDenials(ledger);
155
+ if (ledger.length === 0)
156
+ return [];
157
+ // The workspace the gated files live in; its rootDir normalizes paths for the
158
+ // abs-vs-rel correlation fallback (normalizedFileSalient).
159
+ const workspaceRoot = workspaceBackend?.rootDir;
160
+ // One gate per turn: anchor on the FIRST ledger denial. The ledger is reset
161
+ // per turn and appended in denial order, so ledger[0] is the model's original
162
+ // intent; any later denial of a DIFFERENT identity is a post-denial workaround
163
+ // or a deferred co-pending sibling (see the doc comment). We surface ONLY the
164
+ // anchor identity below and blank every other denied identity to a hidden
165
+ // SKIPPED row. `deniedTokens` still carries every denied identity — it is the
166
+ // scope for that collapse, never an additional gate.
167
+ const anchorToken = ledger[0].token;
168
+ const deniedTokens = new Set(ledger.map((e) => e.token));
169
+ // The authoritative pre-execution args the hook captured for the anchor. A
170
+ // resource re-attempted within the turn shares a token; last write wins (the
171
+ // attempts carry the same proposed change).
172
+ let anchorInput;
173
+ for (const e of ledger) {
174
+ if (e.token === anchorToken && e.input)
175
+ anchorInput = e.input;
176
+ }
177
+ // A hook asked for the anchor: the card names the hook and says why.
178
+ const anchorAsk = askedByHook(ledger[0]);
179
+ const matchedCalls = new Set();
180
+ const result = [];
181
+ let anchorMatched = false;
182
+ // 1. Exact overlay: a streamed call whose token equals the anchor denial token
183
+ // byte-for-byte (the path form agreed on both sides). The anchor resource
184
+ // re-attempted within the turn shares one token and collapses to a single
185
+ // approval (the first match is the keeper; same-identity twins are blanked
186
+ // by collapseRedundantToolCallTwins below). A row an earlier invocation's
187
+ // gate already settled is never the home of THIS turn's denial
188
+ // (isAdjudicatedRow) — the search moves past it to this turn's attempt.
189
+ for (const msg of messages) {
190
+ if (anchorMatched)
191
+ break;
192
+ for (const tc of msg.toolCalls) {
193
+ if (isAdjudicatedRow(tc))
194
+ continue;
195
+ if (toolCallIdentityToken(tc) !== anchorToken)
196
+ continue;
197
+ proposeOnStreamedRow(transcript, tc, anchorInput, mcpDefault, anchorAsk);
198
+ matchedCalls.add(tc);
199
+ result.push(tc);
200
+ anchorMatched = true;
201
+ break;
202
+ }
203
+ }
204
+ // 2. Normalized-path fallback (the abs-vs-rel drift fix): if the anchor is a
205
+ // FILE denial the exact pass missed, match a streamed call by (category,
206
+ // workspace-normalized path) and overlay the REAL call — never a content-
207
+ // less placeholder beside it. Requires the workspace root to normalize;
208
+ // shell/MCP denials (no path) and resumes without a root fall through to
209
+ // synthesis.
210
+ if (!anchorMatched && workspaceRoot) {
211
+ const decoded = decodeIdentityToken(anchorToken);
212
+ const wanted = decoded
213
+ ? normalizedFileSalient(decoded.key, decoded.salient, workspaceRoot)
214
+ : undefined;
215
+ if (wanted) {
216
+ const tc = findUnmatchedStreamCallByNormalizedSalient(messages, matchedCalls, wanted, workspaceRoot);
217
+ if (tc) {
218
+ proposeOnStreamedRow(transcript, tc, anchorInput, mcpDefault, anchorAsk);
219
+ matchedCalls.add(tc);
220
+ result.push(tc);
221
+ anchorMatched = true;
222
+ }
223
+ }
224
+ }
225
+ // 2a. One gate per turn: blank every denied identity OTHER than the anchor to a
226
+ // hidden SKIPPED row (the workaround shell, or a deferred co-pending
227
+ // sibling). Runs BEFORE the WAITING_FOR_APPROVAL persist so a reaction is
228
+ // never persisted as WAITING_APPROVAL — the backend authors an approval
229
+ // REQUESTED event only from a WAITING_APPROVAL tool call, so collapsing
230
+ // here keeps the append-only approval-event stream free of an orphan
231
+ // REQUESTED that would need retraction.
232
+ const nonAnchorCollapsed = collapseNonAnchorDenials(messages, deniedTokens, anchorToken);
233
+ if (nonAnchorCollapsed > 0) {
234
+ console.log(`ExecuteCursor reconcile collapsed ${nonAnchorCollapsed} non-anchor denied ` +
235
+ `tool call(s) to hidden SKIPPED (one gate per turn; anchor is the first ` +
236
+ `denial of the turn)`);
237
+ }
238
+ // 2b. Collapse same-turn duplicate edits. When the model emitted the SAME
239
+ // resource twice in one turn (two call ids, one identity token), only the
240
+ // FIRST same-token stream call was overlaid into the gate above; any OTHER
241
+ // same-token call stays a committed row (RUNNING zombie, or a
242
+ // denied-reported-as-success COMPLETED) that would render as a second,
243
+ // content-less card beside the gate (the reported "No preview available"
244
+ // duplicate). The overlaid gate is now WAITING_APPROVAL, so the shared
245
+ // routine recognizes it as the keeper and blanks the twins IN PLACE to
246
+ // hidden SKIPPED rows — we cannot drop them, since the backend's
247
+ // append-only-at-identity guard rejects removing a previously-committed
248
+ // tool-call id, but the id is preserved so the finalize stays append-only.
249
+ const collapsed = collapseRedundantToolCallTwins(messages);
250
+ if (collapsed > 0) {
251
+ console.log(`ExecuteCursor reconcile collapsed ${collapsed} redundant tool-call twin(s) ` +
252
+ `superseded by the approval gate (kept in place as hidden SKIPPED rows)`);
253
+ }
254
+ // 2c. Finalize interrupted rows. The first-denial stop cancelled the run, so
255
+ // a tool call still PENDING/RUNNING here can never complete — no event
256
+ // will ever deliver its result, and left alone it persists as a spinner
257
+ // forever. The canonical victim is a post-denial workaround whose own
258
+ // hook denial raced (or never reached) the final ledger read, so the
259
+ // token-scoped collapse in 2a could not see it (production case
260
+ // aex_01kwj07f7g23c3wp9sn8496z5g: a python-write shell reaction persisted
261
+ // as RUNNING with requiresApproval=true). Whatever the cause, a
262
+ // non-terminal row on a turn that is pausing is an interrupted attempt
263
+ // with no output: collapse it to the same hidden SKIPPED shape as every
264
+ // other superseded row (in place — the append-only-at-identity guard
265
+ // forbids dropping a committed id). Runs AFTER the anchor overlay, so the
266
+ // gate itself (now WAITING_APPROVAL) is never touched.
267
+ const interrupted = finalizeInterruptedToolCalls(messages);
268
+ if (interrupted > 0) {
269
+ console.log(`ExecuteCursor reconcile collapsed ${interrupted} interrupted non-terminal ` +
270
+ `tool call(s) that can never complete (run cancelled at first denial)`);
271
+ }
272
+ // 3. Synthesize the anchor gate if it matched NO streamed call in either pass
273
+ // (rare — Cursor emits a tool_call event for every attempt), so the gate
274
+ // still surfaces rather than rendering as a silent success. After the
275
+ // normalized fallback this should be ~0; the caller logs a divergence when
276
+ // it is not (a synthesized id is prefixed `approval:`). Only the anchor is
277
+ // ever synthesized: non-anchor denials are deliberately collapsed, never
278
+ // surfaced (one gate per turn).
279
+ if (!anchorMatched) {
280
+ const anchorEntry = ledger.find((e) => e.token === anchorToken) ?? ledger[0];
281
+ const decoded = decodeIdentityToken(anchorToken);
282
+ // Display the hook's raw tool name; carry the decoded salient so the grant
283
+ // rebuilt from this tool call on reinvocation keys on the same resource.
284
+ const displayName = anchorEntry.toolName || decoded?.key || "tool";
285
+ const salient = decoded?.salient ?? "";
286
+ const tc = proposeSynthesizedGate(messages, transcript, {
287
+ displayName,
288
+ salient,
289
+ digest: decoded?.digest ?? "",
290
+ token: anchorToken,
291
+ input: anchorInput ?? anchorEntry.input,
292
+ mcpDefault,
293
+ asked: anchorAsk,
294
+ });
295
+ result.push(tc);
296
+ }
297
+ return result;
298
+ }
299
+ /**
300
+ * Propose the gate ON a streamed tool call the hook denied: the row REOPENS
301
+ * WAITING through the builder and keeps its committed id, so the backend's
302
+ * append-only-at-identity transcript guard accepts the finalize (an in-place
303
+ * status change is a reconcile, not a drop). The single routine for both the
304
+ * exact and the normalized correlation passes, so the gate can never diverge
305
+ * between them. The message is the one the stream already stamped when the
306
+ * policy gated the call, else resolved now; the hook-captured `input` (when
307
+ * present) is the authoritative, complete proposed args — the stream may have
308
+ * carried only partial args before the first-denial cancel — and supplies the
309
+ * args, the preview and the content digest (see {@link proposalArgs}).
310
+ */
311
+ function proposeOnStreamedRow(transcript, tc, input, mcpDefault, asked) {
312
+ const args = proposalArgs(input);
313
+ const digest = approvalDigest(tc.mcpServerSlug, args ? contentDigest(args) : "", input, asked !== undefined);
314
+ transcript.apply({
315
+ kind: "approval_proposed",
316
+ callId: tc.id,
317
+ name: tc.name,
318
+ mcpServerSlug: tc.mcpServerSlug,
319
+ message: asked?.message || tc.approvalMessage || resolveDeniedApprovalMessage(tc.name, tc.mcpServerSlug, toolCallArgs(tc), mcpDefault),
320
+ ...(asked !== undefined ? { provenance: "hook", policyHook: asked.hook } : {}),
321
+ ...(args !== undefined ? { args } : {}),
322
+ ...(digest ? { contentDigest: digest } : {}),
323
+ });
324
+ }
325
+ /**
326
+ * The digest an approval is granted under: a built-in's file content when it
327
+ * has some; for a call a hook asked on and that has none, or any MCP call a
328
+ * hook asked on, the hook's whole input ({@link hookAskDigest}), so the grant
329
+ * lets through that call and no other, as the native engine asks for each.
330
+ */
331
+ export function approvalDigest(mcpServerSlug, content, input, askedByHook) {
332
+ if (!askedByHook || input === undefined)
333
+ return content;
334
+ return content && !mcpServerSlug ? content : hookAskDigest(input);
335
+ }
336
+ /** The hook that asked for a ledger entry's approval, when one did. */
337
+ function askedByHook(entry) {
338
+ if (entry?.hook === undefined)
339
+ return undefined;
340
+ return { hook: entry.hook, message: entry.message ?? "" };
341
+ }
342
+ /**
343
+ * Propose the gate for a denial that matched NO streamed call: a WAITING row
344
+ * with a synthesized id (`approval:<token>`) on the message whose text proposed
345
+ * it. It displays the hook's raw tool name and carries the decoded salient as
346
+ * its args (so the grant rebuilt from it on reinvocation keys on the same
347
+ * resource) and the anchor's content digest (so its identity equals the
348
+ * anchor's content token); the hook-captured input, when present, upgrades
349
+ * both to the full proposed change. A synthesized call is a ledger denial — it
350
+ * was gated, so it has a governing layer, and a denied call never occurs under
351
+ * a global bypass or a matching lease, so empty leases + no bypass attribute
352
+ * it faithfully (a built-in resolves to builtin_category; an MCP placeholder
353
+ * lacks a reconstructed slug and stays UNSPECIFIED rather than be mislabeled).
354
+ * The row is read back from `messages`, the array the builder appended into.
355
+ */
356
+ function proposeSynthesizedGate(messages, transcript, gate) {
357
+ const { displayName, salient, digest, token, input, mcpDefault, asked } = gate;
358
+ const callId = `approval:${token}`;
359
+ const captured = proposalArgs(input);
360
+ const args = captured ?? (salient ? { path: salient } : undefined);
361
+ const provenance = asked !== undefined
362
+ ? "hook"
363
+ : mcpDefault
364
+ ? resolveApprovalProvenance(displayName, "", mcpDefault, NO_LEASED_CATEGORIES, false)
365
+ : undefined;
366
+ transcript.apply({
367
+ kind: "approval_proposed",
368
+ callId,
369
+ name: displayName,
370
+ mcpServerSlug: "",
371
+ message: asked?.message || (salient
372
+ ? `Tool requires approval: ${displayName} (${salient})`
373
+ : resolveDeniedApprovalMessage(displayName, "", {}, mcpDefault)),
374
+ ...(args !== undefined ? { args } : {}),
375
+ ...(provenance !== undefined ? { provenance } : {}),
376
+ ...(asked !== undefined ? { policyHook: asked.hook } : {}),
377
+ contentDigest: approvalDigest("", captured ? contentDigest(captured) : digest, input, asked !== undefined),
378
+ });
379
+ const row = findToolCallById(messages, callId);
380
+ if (!row)
381
+ throw new Error(`reconcileDeniedToolCalls: the builder did not create the proposed row ${callId}`);
382
+ return row;
383
+ }
384
+ /** The last row with this id in the root transcript (the builder appends; a synthesized gate is always the newest). */
385
+ function findToolCallById(messages, id) {
386
+ for (let i = messages.length - 1; i >= 0; i--) {
387
+ const found = messages[i].toolCalls.find((tc) => tc.id === id);
388
+ if (found)
389
+ return found;
390
+ }
391
+ return undefined;
392
+ }
393
+ /**
394
+ * Collapse every tool call still in a non-terminal state (PENDING / RUNNING)
395
+ * to the hidden SKIPPED row shape, returning how many were collapsed.
396
+ *
397
+ * Called only on the pause-for-approval path, after the anchor gate has been
398
+ * overlaid to WAITING_APPROVAL: the run was cancelled, so nothing will ever
399
+ * complete these calls, and a permanently-RUNNING row would render as an
400
+ * eternal spinner beside the approval card. This is the causality sibling of
401
+ * {@link collapseNonAnchorDenials}: that collapse is token-scoped (it needs the
402
+ * denial in the ledger), while this one catches the attempt whose hook denial
403
+ * raced the final ledger read or whose execution the cancel interrupted
404
+ * outright — either way an attempt with no output that the turn's end orphaned.
405
+ */
406
+ function finalizeInterruptedToolCalls(messages) {
407
+ let finalized = 0;
408
+ for (const msg of messages) {
409
+ for (const tc of msg.toolCalls) {
410
+ if (tc.status !== ToolCallStatus.TOOL_CALL_PENDING &&
411
+ tc.status !== ToolCallStatus.TOOL_CALL_RUNNING) {
412
+ continue;
413
+ }
414
+ hideToolCallRow(tc);
415
+ finalized++;
416
+ }
417
+ }
418
+ return finalized;
419
+ }
420
+ /**
421
+ * Recognizes a tool call already blanked to a hidden collapsed row, so a second
422
+ * pass never re-collapses it (and never miscounts). Mirrors the SDK's
423
+ * `isCollapsedToolCall` shape without importing across the runner/SDK seam.
424
+ */
425
+ function isAlreadyCollapsed(tc) {
426
+ return (tc.status === ToolCallStatus.TOOL_CALL_SKIPPED &&
427
+ !tc.requiresApproval &&
428
+ !tc.result &&
429
+ !tc.error &&
430
+ !tc.argsPreview);
431
+ }
432
+ /**
433
+ * Whether a tool call carries a change/output of its own — the signal that it is
434
+ * authoritative for its resource rather than a redundant denial/cancel twin.
435
+ *
436
+ * The notion of "change" is category-aware on purpose:
437
+ * - A file mutation (`write`/`delete`) never carries an authoritative change on
438
+ * the tool-call ROW: under apply-then-review its review lives in the
439
+ * `FileChangeSet` ledger (capture mode), and under the no-storage deny-gate it
440
+ * is the WAITING_APPROVAL gate itself (kept explicitly by the caller). So a
441
+ * file row is authoritative only as that gate, never on its own — hence
442
+ * `false` here. (This once read `file_changes.length > 0`;
443
+ * that field is gone, and the row was never the review surface.)
444
+ * - Every other gated tool (shell, MCP) has no ledger; its "change" is its
445
+ * execution output, so a genuine run carries a non-empty `result` while a
446
+ * denied/cancelled attempt that never executed does not. This keeps two
447
+ * distinct shell runs (each with output) both visible while still collapsing a
448
+ * same-command denial twin.
449
+ */
450
+ function carriesOwnChange(tc) {
451
+ const category = toolApprovalCategory(tc.name);
452
+ if (category === "write" || category === "delete") {
453
+ return false;
454
+ }
455
+ return !!tc.result;
456
+ }
457
+ /**
458
+ * Whether this turn's boundary may still rewrite a row: the fact the
459
+ * session event emitter reads (`harness/events/emitter.ts`, through this
460
+ * harness's `boundaryRewritesRow` capability) so it never writes into the
461
+ * log a row the boundary will reopen, hide or settle differently. Such a
462
+ * row, and everything after it in its thread, is written once the turn's
463
+ * terminal write proves the boundary ran.
464
+ *
465
+ * The rows each pass of the boundary can still touch, and no others:
466
+ * - a call still PENDING or RUNNING: the interrupted-attempt finalize hides
467
+ * it, the unresolved settle marks it, the refusal stamps settle it;
468
+ * - a call FAILED by a hook block (`isHookBlockError`): the denial overlay
469
+ * reopens it as the turn's gate, the one-gate collapse hides it, the
470
+ * refusal and unattended stamps settle it;
471
+ * - a gated call (a file write or delete, a shell, an MCP tool) that
472
+ * carries no change of its own (`carriesOwnChange`): the twin collapse
473
+ * hides it when a same-identity sibling turns up later in the turn.
474
+ *
475
+ * A row a person already decided is a keeper of every pass, so never
476
+ * rewritten; a read-only built-in that settled, or a shell or MCP call that
477
+ * returned output, is final the moment it settles.
478
+ */
479
+ export function boundaryMayStillRewrite(tc) {
480
+ if (isAdjudicatedRow(tc))
481
+ return false;
482
+ if (tc.status === ToolCallStatus.TOOL_CALL_PENDING || tc.status === ToolCallStatus.TOOL_CALL_RUNNING)
483
+ return true;
484
+ if (tc.status === ToolCallStatus.TOOL_CALL_FAILED && isHookBlockError(tc.error))
485
+ return true;
486
+ const key = toolIdentity(tc.name, tc.mcpServerSlug, toolCallArgs(tc)).key;
487
+ const gated = tc.mcpServerSlug ? true : key === "write" || key === "delete" || key === "shell";
488
+ return gated && !carriesOwnChange(tc);
489
+ }
490
+ /**
491
+ * Collapse redundant same-identity tool-call twins to a single visible row.
492
+ *
493
+ * The model frequently emits the SAME gated action twice in one turn (two
494
+ * tool-call ids, one identity). When the first attempt is gated and the run is
495
+ * cancelled mid-flight, the extra attempt never receives a terminal event and
496
+ * persists as a stuck `RUNNING` row ("No preview available"); other variants are
497
+ * a denied-reported-as-success `COMPLETED` with an empty result, two no-change
498
+ * `COMPLETED` attempts where neither carries a change, or — on the denial path —
499
+ * a `FAILED` twin beside the overlaid gate. All render as a duplicate card beside
500
+ * the real action (or the approval gate). This is the recurring duplicate-card
501
+ * defect, most visible for file edits but shared by every gated tool family.
502
+ *
503
+ * The routine is harness-agnostic and a pure function of `messages`:
504
+ *
505
+ * 1. Scope to GATED identities — file mutations (`write`/`delete`) and shell key
506
+ * on their cross-taxonomy category; MCP tools are recognized by their server
507
+ * slug. A same-turn duplicate of a gated tool is a denial/cancel artifact, not
508
+ * meaningful repetition. The category is name-derived (via {@link toolIdentity}
509
+ * -> approvalCategory), so a twin cancelled before classification (empty
510
+ * `toolKind`) is still scoped via its name (`edit` -> `write`). Ungated
511
+ * read-only tools are left untouched.
512
+ * 2. Group those calls by `toolCallIdentityToken` — the SAME `toolIdentity` used
513
+ * for denial correlation and resume grants, so scope and grouping cannot drift.
514
+ * 3. In each group the keepers carry authoritative state — a change/output of
515
+ * their own (see {@link carriesOwnChange}), a row named in `refusedRowIds`
516
+ * (the ids {@link stampHookRefusedToolCalls} settled: each the record of a
517
+ * refusal, carried by id because its shape matches a hook-block twin's) or
518
+ * the approval gate itself (`WAITING_APPROVAL`). For a file mutation the gate is the sole authoritative
519
+ * row: the row carries no diff (review lives in the `FileChangeSet` ledger, or
520
+ * is the no-storage deny-gate itself), so a denied write's same-identity
521
+ * siblings — a denied/zombie row or a stale snapshot from a second attempt —
522
+ * collapse onto the gate. A shell/MCP twin keeps every distinct run with
523
+ * output. If NO member qualifies (every attempt produced no change), keep
524
+ * exactly ONE representative — preferring a terminal attempt over a stuck
525
+ * `RUNNING` zombie — so the resource still shows a single card. Every
526
+ * non-keeper is blanked in place to a hidden `SKIPPED` row (see
527
+ * {@link collapseDenialTwin}).
528
+ *
529
+ * It is deliberately subtractive — it only ever HIDES a row, never invents a
530
+ * terminal state. The committed `id` is preserved on every collapse, so the
531
+ * finalize stays append-only by construction and the backend's
532
+ * append-only-at-identity guard accepts it. Returns the number collapsed, for
533
+ * observability.
534
+ */
535
+ export function collapseRedundantToolCallTwins(messages, refusedRowIds = NO_REFUSED_ROWS) {
536
+ const groups = new Map();
537
+ for (const msg of messages) {
538
+ for (const tc of msg.toolCalls) {
539
+ const id = toolIdentity(tc.name, tc.mcpServerSlug, toolCallArgs(tc));
540
+ const gated = tc.mcpServerSlug
541
+ ? true
542
+ : id.key === "write" || id.key === "delete" || id.key === "shell";
543
+ if (!gated)
544
+ continue;
545
+ const token = grantToken(id.key, id.salient);
546
+ const bucket = groups.get(token);
547
+ if (bucket)
548
+ bucket.push(tc);
549
+ else
550
+ groups.set(token, [tc]);
551
+ }
552
+ }
553
+ let collapsed = 0;
554
+ for (const group of groups.values()) {
555
+ if (group.length < 2)
556
+ continue; // a lone call is never a twin
557
+ // Keepers carry authoritative state: a change/output of their own
558
+ // (carriesOwnChange), the approval gate itself, or a gate an earlier
559
+ // invocation already settled (isAdjudicatedRow — the transcript's record of
560
+ // what the user decided and what ran; a same-identity act in a later turn
561
+ // is a new act, never this row's twin), or a row the boundary settled from
562
+ // a refusal in the ledger (`refusedRowIds`: one row per refusal, so two
563
+ // refusals of one command in a turn are two acts, #1967). For a file
564
+ // mutation the gate is the sole authoritative row (the row carries no diff — review lives in
565
+ // the ledger, or the row IS the no-storage deny-gate), so a denied write's
566
+ // same-identity siblings collapse onto it; a shell/MCP twin keeps every
567
+ // distinct run with output.
568
+ const keepers = new Set(group.filter((tc) => carriesOwnChange(tc) ||
569
+ isAdjudicatedRow(tc) ||
570
+ refusedRowIds.has(tc.id) ||
571
+ tc.status === ToolCallStatus.TOOL_CALL_WAITING_APPROVAL));
572
+ // All attempts produced no change (e.g. denied-reported-as-success): keep one
573
+ // representative, preferring a settled outcome over a stuck RUNNING zombie.
574
+ if (keepers.size === 0) {
575
+ const terminal = [...group].reverse().find((tc) => isTerminalToolStatus(tc.status));
576
+ keepers.add(terminal ?? group[0]);
577
+ }
578
+ for (const tc of group) {
579
+ if (keepers.has(tc))
580
+ continue;
581
+ if (isAlreadyCollapsed(tc))
582
+ continue;
583
+ collapseDenialTwin(tc);
584
+ collapsed++;
585
+ }
586
+ }
587
+ return collapsed;
588
+ }
589
+ /**
590
+ * One gate per turn: blank every DENIED tool call whose identity differs from
591
+ * the anchor (the first denial of the turn) to a hidden SKIPPED row.
592
+ *
593
+ * This is the cross-identity complement of {@link collapseRedundantToolCallTwins}
594
+ * (which only joins SAME-identity duplicates). The canonical target is the
595
+ * deny-only workaround — a denied `edit notes.md` followed by a `shell:
596
+ * cat > notes.md` whose identity (`shell\n…`) differs from the edit's
597
+ * (`write\nnotes.md`), so no twin collapse can join them and (since they share
598
+ * one assistant message) no positional rule can separate them. The honest signal
599
+ * that the shell is redundant is that it is a DIFFERENT denied identity in the
600
+ * same turn as the anchor; under the one-gate-per-turn contract every such
601
+ * identity is either a post-denial reaction or a co-pending sibling the harness
602
+ * defers to the next turn, so it is hidden, not surfaced.
603
+ *
604
+ * Scoped strictly to identities present in `deniedTokens`: a non-denied tool
605
+ * (an earlier read/glob, or an already-granted call that ran) is never touched.
606
+ * Subtractive and id-preserving (via {@link collapseDenialTwin}), so the finalize
607
+ * stays append-only. Returns the number collapsed, for observability.
608
+ */
609
+ function collapseNonAnchorDenials(messages, deniedTokens, anchorToken) {
610
+ let collapsed = 0;
611
+ for (const msg of messages) {
612
+ for (const tc of msg.toolCalls) {
613
+ if (isAdjudicatedRow(tc))
614
+ continue;
615
+ const token = toolCallIdentityToken(tc);
616
+ if (token === anchorToken)
617
+ continue;
618
+ if (!deniedTokens.has(token))
619
+ continue;
620
+ if (isAlreadyCollapsed(tc))
621
+ continue;
622
+ collapseDenialTwin(tc);
623
+ collapsed++;
624
+ }
625
+ }
626
+ return collapsed;
627
+ }
628
+ /**
629
+ * Blank a superseded denial twin in place to a hidden SKIPPED row. Keeps the
630
+ * committed `id` (append-only), `name`, and `toolKind`; clears every renderable
631
+ * surface and the approval flags so the SDK's `isCollapsedToolCall` predicate
632
+ * recognizes it and renders nothing. The structured `args` are left as the honest
633
+ * stored record of the redundant attempt (never rendered, since the row is
634
+ * hidden; the gate carries the authoritative proposed change).
635
+ */
636
+ function collapseDenialTwin(tc) {
637
+ hideToolCallRow(tc);
638
+ }
639
+ // `hideToolCallRow` (the "hidden row" shape, shared by the denial-twin collapse
640
+ // and the capture flow) lives in shared/tool-row.ts so both harnesses collapse
641
+ // rows identically; imported at the top of this module.
642
+ /**
643
+ * The hook-captured authoritative tool input as a proposal's args, so the
644
+ * approval card can show the proposed change before the user approves.
645
+ *
646
+ * When present it becomes the single source for the preview: the full
647
+ * structured `args` (the approval card renders the proposed write/edit content
648
+ * from these), the compact-but-always-valid `args_preview` the builder derives
649
+ * from them (the field a resumed turn parses to rebuild the grant salient — so
650
+ * salient fields are never elided), and the content digest the caller stamps
651
+ * beside them. The digest is the resume identity: it binds the grant to
652
+ * (category, path, content) so a sibling edit to the same file re-gates rather
653
+ * than riding an earlier approval through. It is also the identity the Cursor
654
+ * deny-gate's exact-apply reads on resume — together with the whole-file bytes
655
+ * in `args` — to write exactly what was approved (see exact-apply.ts). There is
656
+ * no separate captured `file_changes` mirror; `args` is the single source for
657
+ * both the preview and the applied bytes.
658
+ *
659
+ * Defense-in-depth: a secret-like write's content never reaches the
660
+ * persisted approval preview. Normally unreachable — the hook hard-blocks a
661
+ * secret write and records no ledger input — but if a hook classify failure
662
+ * fell one through, its content must still never reach args/args_preview; the
663
+ * Invariant-A backstop is the final net, this closes the path at the source.
664
+ * With no input (the hook's grep fallback) there is nothing authoritative and
665
+ * the row keeps its existing args.
666
+ */
667
+ function proposalArgs(input) {
668
+ if (!input)
669
+ return undefined;
670
+ const gatePath = extractFilePath(input);
671
+ if (gatePath !== null && isSecretLikePath(gatePath))
672
+ return undefined;
673
+ return input;
674
+ }
675
+ /** The identity keys whose salient is a path: the file categories, and the read, search, listing and lint read a hook may ask on. */
676
+ const PATH_KEYS = new Set(["write", "delete", "Read", "Grep", "List", "ReadLints"]);
677
+ /**
678
+ * The workspace-normalized identity of a FILE approval category's salient, or
679
+ * undefined for a non-file category (shell, whose salient is a command, not a
680
+ * path) or an empty salient. Both the hook-decoded denial salient and a streamed
681
+ * call's salient pass through this, so an absolute-vs-relative path difference
682
+ * collapses to one comparable key (`category + "\n" + relPath`). Restricting to
683
+ * write/delete keeps a shell command from being mangled by path normalization.
684
+ */
685
+ function normalizedFileSalient(category, salient, workspaceRoot) {
686
+ if (!PATH_KEYS.has(category) || !salient)
687
+ return undefined;
688
+ const { path } = resolveWorkspacePath(salient, workspaceRoot, /* virtualRoot */ false);
689
+ return `${category}\n${path}`;
690
+ }
691
+ /**
692
+ * Find the first not-yet-overlaid streamed tool call whose workspace-normalized
693
+ * (category, path) equals `wanted`. Skips calls already claimed by an earlier
694
+ * denial so several concurrent file denials each overlay a distinct stream call.
695
+ */
696
+ function findUnmatchedStreamCallByNormalizedSalient(messages, matchedCalls, wanted, workspaceRoot) {
697
+ for (const msg of messages) {
698
+ for (const tc of msg.toolCalls) {
699
+ if (matchedCalls.has(tc) || isAdjudicatedRow(tc))
700
+ continue;
701
+ const id = toolIdentity(tc.name, tc.mcpServerSlug, toolCallArgs(tc));
702
+ if (normalizedFileSalient(id.key, id.salient, workspaceRoot) === wanted) {
703
+ return tc;
704
+ }
705
+ }
706
+ }
707
+ return undefined;
708
+ }
709
+ /**
710
+ * Redact provisional post-denial narration when a Cursor turn pauses for approval.
711
+ *
712
+ * THE PROBLEM. Unlike the native harness — which gates with a LangGraph
713
+ * `interrupt()` *before* the tool runs, so the model never sees a denial — the
714
+ * Cursor harness can only gate via the file-based `beforeMCPExecution`/
715
+ * `preToolUse` hook returning `deny`. Cursor surfaces that deny to the model as
716
+ * a tool *failure* (often its own generic "blocked by a hook" text; see the
717
+ * ground-truth capture in cursor_hitl_test.go), and there is no
718
+ * non-leaky SDK approval primitive to use instead (the `request` event is
719
+ * opaque and carries no responder). So a well-behaved model frequently reacts by
720
+ * narrating defeat — "I couldn't do this; enable the hook in your Cursor
721
+ * settings" — which would otherwise be persisted as the assistant's verdict and
722
+ * rendered right next to the approval card that is, in fact, asking the user to
723
+ * approve. Contradictory and alarming.
724
+ *
725
+ * THE GUARANTEE. The runner's job is to simplify this data, not mirror its
726
+ * complexity: a turn that pauses for approval must read the SAME shape the
727
+ * native harness produces — `[pre-tool text][tool calls WAITING_APPROVAL]`, with
728
+ * no post-denial verdict. We therefore BLANK (clear the `content` of, and mark
729
+ * non-streaming) the trailing assistant/thinking messages that (a) appear
730
+ * positionally AFTER the last message bearing a WAITING_APPROVAL tool call and
731
+ * (b) carry no tool calls of their own. The approval card (projected from the
732
+ * WAITING_APPROVAL tool-call status) becomes the single, unambiguous source of
733
+ * truth. The blanked messages are already invisible on every surface via the
734
+ * existing empty-message handling (`buildThreadItems` skips empty `MESSAGE_AI`;
735
+ * `MessageEntry` renders nothing for empty `MESSAGE_THINKING`), so the shared
736
+ * `@stigmer/react-sdk`/Ink components stay harness-agnostic with zero per-harness UI
737
+ * special-casing — the cleanliness lives in the data, not in each consumer.
738
+ *
739
+ * WHY BLANK INSTEAD OF REMOVE. Removing the messages would make the persisted
740
+ * WAITING_FOR_APPROVAL transcript SHORTER than the in-progress transcript the
741
+ * runner already streamed. The backend's append-only message guard rejects a
742
+ * shrink for a non-terminal execution (it protects against regressed/partial
743
+ * writes). Blanking keeps the message COUNT identical, so the finalize is
744
+ * append-only BY CONSTRUCTION and the guard accepts it with no special case —
745
+ * which is why this phase deletes the backend's former `isApprovalFinalize`
746
+ * shrink exception in both editions. The transcript is the authoritative *raw*
747
+ * record; the verbatim narration text remains recoverable from the runner logs
748
+ * and the recorded cursor-event stream.
749
+ *
750
+ * WHY THIS IS DETERMINISTIC. `attachToolCallToLastAi` calls
751
+ * `finalizeStreaming(run_id)` before attaching a tool call, so any assistant
752
+ * text the model emits *after* the denied tool call always starts a NEW message
753
+ * — post-denial narration is never merged into the message that holds the gated
754
+ * call. We stop at the first non-narration message — one bearing a VISIBLE tool
755
+ * call — so legitimately-executed tools after the gate and any text around them
756
+ * are never touched; only the contiguous trailing reaction block is blanked. A
757
+ * message whose every tool call was collapsed to the hidden SKIPPED row (a
758
+ * post-denial workaround or an interrupted attempt — see
759
+ * collapseNonAnchorDenials / finalizeInterruptedToolCalls, which run first) IS
760
+ * trailing narration: its rows render as absent, so only its text remains, and
761
+ * that text is precisely the reaction this redaction exists to blank. Treating
762
+ * it as a stop would strand every reaction message behind it (the production
763
+ * shape in aex_01kwj07f7g23c3wp9sn8496z5g: [gate][thinking][narration+workaround
764
+ * row] — the old walk stopped at the workaround message and redacted nothing).
765
+ * The first-denial stop in index.ts is the primary mechanism that keeps this
766
+ * block small (it ends the turn before the model produces inter-tool
767
+ * narration); this redaction is the backstop for any token that streamed before
768
+ * the cancel landed.
769
+ *
770
+ * Returns the blanked messages (for diagnostics); mutates `messages` in place.
771
+ */
772
+ export function clearProvisionalPostDenialNarration(messages, deniedToolCalls) {
773
+ if (deniedToolCalls.length === 0)
774
+ return [];
775
+ // reconcileDeniedToolCalls returns the very ToolCall protos held inside
776
+ // messages[].toolCalls (overlaid) or appended to the last AI message
777
+ // (synthesized), so object identity is a stable, exact match.
778
+ const denied = new Set(deniedToolCalls);
779
+ let lastGatedIdx = -1;
780
+ for (let i = 0; i < messages.length; i++) {
781
+ if (messages[i].toolCalls.some((tc) => denied.has(tc))) {
782
+ lastGatedIdx = i;
783
+ }
784
+ }
785
+ if (lastGatedIdx < 0)
786
+ return [];
787
+ const redacted = [];
788
+ for (let i = messages.length - 1; i > lastGatedIdx; i--) {
789
+ const msg = messages[i];
790
+ const isProvisionalNarration = (msg.type === MessageType.MESSAGE_AI || msg.type === MessageType.MESSAGE_THINKING) &&
791
+ msg.toolCalls.every((tc) => isToolCallRowHidden(tc));
792
+ // Stop at the first message that is NOT trailing narration: a message
793
+ // bearing a visible (non-collapsed) tool call marks real activity we must
794
+ // preserve, and anything before it is no longer "trailing".
795
+ if (!isProvisionalNarration)
796
+ break;
797
+ // Blank in place — keep the message so the transcript count never shrinks,
798
+ // but drop its provisional content so no consumer renders the defeatist
799
+ // verdict. Empty AI/THINKING messages are hidden by the SDK already; hidden
800
+ // SKIPPED rows already render as absent.
801
+ msg.content = "";
802
+ msg.isStreaming = false;
803
+ redacted.unshift(msg);
804
+ }
805
+ return redacted;
806
+ }
807
+ /**
808
+ * Substrings of the error text Cursor stamps onto a tool call blocked by a
809
+ * `preToolUse`/`beforeMCPExecution` hook (its generic replacement for the
810
+ * hook's own agent_message — confirmed by the ground-truth capture in
811
+ * cursor_hitl_test.go). The SDK has NO structured "denied by hook" signal, so
812
+ * this marker family is the only stream-side trace of a hook block and is
813
+ * single-sourced here for every consumer (the issue #205 attribution detector
814
+ * below; tests). Matched case-insensitively against the FAILED call's error.
815
+ */
816
+ export const HOOK_BLOCK_ERROR_MARKERS = ["blocked by a hook"];
817
+ /** True when a tool call's error text reads as a hook block. */
818
+ function isHookBlockError(errorText) {
819
+ if (!errorText)
820
+ return false;
821
+ const lowered = errorText.toLowerCase();
822
+ return HOOK_BLOCK_ERROR_MARKERS.some((marker) => lowered.includes(marker));
823
+ }
824
+ /**
825
+ * Detect tool calls blocked by a hook that STIGMER'S OWN hook did not deny —
826
+ * the issue #205 invariant check "a blocked tool must never silently complete".
827
+ *
828
+ * Cursor runs EVERY hook it loads, and a deny from any of them blocks the
829
+ * tool. The gate sets a workspace's own hook files aside for the turn
830
+ * (`workspace-hook-files.ts`), and our hook records every deny it issues to
831
+ * the denial ledger (all kinds — see {@link DeniedLedgerEntry}), so a FAILED
832
+ * tool call carrying Cursor's hook-block error text with NO matching ledger
833
+ * entry was blocked by a FOREIGN hook the set-aside missed (one loaded from
834
+ * a file the turn does not rewrite, or written during the turn) — or,
835
+ * equally fatally, by our own hook whose best-effort ledger append failed.
836
+ * Either way the runner cannot pause for approval (an approval grants a
837
+ * token only OUR hook reads; the foreign hook would deny the re-attempt
838
+ * forever), so the caller surfaces an explicit failure instead of
839
+ * completing with the work silently undone.
840
+ *
841
+ * Attribution, in order:
842
+ * 1. Any `fail-closed` ledger entry → the gate itself was broken this turn and
843
+ * denied EVERYTHING it saw; per-call correlation is meaningless, so every
844
+ * hook block is attributed to our own (broken) gate. Nothing is reported.
845
+ * 2. Exact identity: the call's {@link toolCallIdentityToken} appears in the
846
+ * ledger (any kind — approval gates were overlaid to WAITING_APPROVAL or
847
+ * collapsed by the reconcile that runs first, so a still-FAILED row here is
848
+ * typically a secret/capture-error deny, correctly attributed as ours).
849
+ * 3. Normalized-path fallback: the same abs-vs-rel drift the reconcile's
850
+ * second pass handles — a FILE call matches a ledger entry by (category,
851
+ * workspace-normalized path) even when the raw tokens differ.
852
+ * 4. Tool-list refusal: a call the hook refused as out of scope
853
+ * ({@link scopeRefusalOf}: the tool, and for a tool the lists exclude only
854
+ * in part, the call it names). {@link stampScopeRefusedToolCalls}
855
+ * normally rewrote such rows already; this keeps a refusal recorded
856
+ * without its text attributable too.
857
+ *
858
+ * Scoped to THIS turn's messages (from `turnStartMessageIndex`): seeded
859
+ * prior-turn rows were already adjudicated and must never re-trigger.
860
+ * Deliberately conservative: an ordinary tool failure (no hook-block text)
861
+ * is never reported, and a foreign hook denying with fully custom text evades
862
+ * the marker match (the documented residual).
863
+ */
864
+ export function detectUnattributedHookBlocks(messages, turnStartMessageIndex, ledger, workspaceRoot) {
865
+ if (ledger.some((e) => denialKindOf(e) === "fail-closed"))
866
+ return [];
867
+ const ledgerTokens = new Set(ledger.map((e) => e.token));
868
+ const ledgerNormalizedSalients = new Set();
869
+ if (workspaceRoot) {
870
+ for (const entry of ledger) {
871
+ const decoded = decodeIdentityToken(entry.token);
872
+ if (!decoded)
873
+ continue;
874
+ const normalized = normalizedFileSalient(decoded.key, decoded.salient, workspaceRoot);
875
+ if (normalized)
876
+ ledgerNormalizedSalients.add(normalized);
877
+ }
878
+ }
879
+ const refusals = scopeRefusalsIn(ledger);
880
+ const blocks = [];
881
+ for (const msg of messages.slice(Math.max(0, turnStartMessageIndex))) {
882
+ for (const tc of msg.toolCalls) {
883
+ if (tc.status !== ToolCallStatus.TOOL_CALL_FAILED)
884
+ continue;
885
+ if (!isHookBlockError(tc.error))
886
+ continue;
887
+ if (ledgerTokens.has(toolCallIdentityToken(tc)))
888
+ continue;
889
+ if (scopeRefusalOf(tc, refusals, workspaceRoot) !== undefined)
890
+ continue;
891
+ if (workspaceRoot) {
892
+ const id = toolIdentity(tc.name, tc.mcpServerSlug, toolCallArgs(tc));
893
+ const normalized = normalizedFileSalient(id.key, id.salient, workspaceRoot);
894
+ if (normalized && ledgerNormalizedSalients.has(normalized))
895
+ continue;
896
+ }
897
+ blocks.push({ toolCallId: tc.id, toolName: tc.name, error: tc.error });
898
+ }
899
+ }
900
+ return blocks;
901
+ }
902
+ /**
903
+ * The honest terminal error stamped on a tool call that never resolved (issue
904
+ * #965). Deliberately states all three negatives — not executed, not approved,
905
+ * not denied — because the incident's harm was the model claiming an approval
906
+ * was pending: this text is what the transcript shows INSTEAD of a spinner or
907
+ * a silent after-the-fact interruption, and it must leave no room for an
908
+ * approval-is-coming reading.
909
+ */
910
+ export const UNRESOLVED_TOOL_CALL_ERROR = "The tool did not return a result before the turn ended. It was never " +
911
+ "executed, approved, or denied — no approval is pending for it.";
912
+ /**
913
+ * Settle this-turn tool calls that are still NON-TERMINAL when a turn
914
+ * completes without pausing — the issue #965 invariant, the sibling of
915
+ * {@link detectUnattributedHookBlocks}' #205 invariant ("a blocked tool must
916
+ * never silently complete" → "an unresolved tool must never silently
917
+ * complete").
918
+ *
919
+ * THE SHAPE THIS CATCHES. A tool that hangs INSIDE the Cursor agent runtime —
920
+ * the production case is `generateImage`, which rides the SDK's
921
+ * interaction-query channel rather than the ordinary tool path — streams a
922
+ * tool_call start, never streams a result, and is invisible to every Stigmer
923
+ * seam: the hook never denied it (no ledger entry), so the reconcile never
924
+ * gated it, and the turn completes with the row still PENDING/RUNNING. Before
925
+ * this sweep, the server's terminal settle (issue #207) stamped such rows
926
+ * TOOL_CALL_INTERRUPTED silently AFTER the runner reported completion — the
927
+ * transcript's last word stayed whatever the model claimed, which in
928
+ * aex_01m1a6ww3nmp4952ar5v0g4g85 was a promise that an approval was pending
929
+ * when none existed.
930
+ *
931
+ * Settling here instead makes the runner the author of the honest record: the
932
+ * row gets TOOL_CALL_INTERRUPTED with {@link UNRESOLVED_TOOL_CALL_ERROR}, and
933
+ * the caller (turn-boundary.ts) appends a system disclosure naming what never
934
+ * ran.
935
+ *
936
+ * WHY INTERRUPTED AND NEVER FAILED. TOOL_CALL_INTERRUPTED is deliberately the
937
+ * one settled status the monotonic merge guard lets live execution evidence
938
+ * supersede (see the guard's note in this file, ~line 331): if this FAILED
939
+ * execution is later RECOVERED, the harness checkpoint may re-execute the call
940
+ * under its original id, and the replayed events must be able to advance the
941
+ * row to its true outcome. A boundary-stamped FAILED would freeze it forever.
942
+ *
943
+ * WHY IT NEVER FAILS THE RUN (unlike #205). A foreign hook block is provably
944
+ * adversarial — approval semantics are permanently broken, so completing would
945
+ * always be a lie. An unresolved row can also be benign stream event-loss
946
+ * where the tool actually ran; failing the run would convert those into
947
+ * regressions. Disclosure restores honesty at zero regression risk.
948
+ *
949
+ * Scope and exclusions, in order:
950
+ * - THIS turn's parent-transcript rows only (from `turnStartMessageIndex`):
951
+ * seeded prior-turn rows were adjudicated by their own execution's settle,
952
+ * and sub-agent inner rows are the server settle's concern — the parent row
953
+ * (e.g. the Task call) is what the user sees. Mirrors #205's scoping.
954
+ * - Only PENDING/RUNNING rows: every terminal row was adjudicated, and
955
+ * WAITING_APPROVAL rows belong to the pause machinery (the caller only runs
956
+ * this sweep on a NON-pausing turn, so none should exist here anyway).
957
+ * - Only rows with NO denial-ledger entry of ANY kind (exact token, then the
958
+ * normalized-path fallback — the same two identities every sweep in this
959
+ * file uses): a ledger-attributed row is the unattended/secret/fail-closed
960
+ * machinery's to settle, not ours.
961
+ *
962
+ * Returns the settled calls so the boundary can disclose and log them.
963
+ */
964
+ export function settleUnresolvedToolCalls(messages, turnStartMessageIndex, ledger, workspaceRoot) {
965
+ const ledgerTokens = new Set(ledger.map((e) => e.token));
966
+ const ledgerNormalizedSalients = new Set();
967
+ if (workspaceRoot) {
968
+ for (const entry of ledger) {
969
+ const decoded = decodeIdentityToken(entry.token);
970
+ if (!decoded)
971
+ continue;
972
+ const normalized = normalizedFileSalient(decoded.key, decoded.salient, workspaceRoot);
973
+ if (normalized)
974
+ ledgerNormalizedSalients.add(normalized);
975
+ }
976
+ }
977
+ const matchesLedger = (tc) => {
978
+ if (ledgerTokens.has(toolCallIdentityToken(tc)))
979
+ return true;
980
+ if (!workspaceRoot)
981
+ return false;
982
+ const id = toolIdentity(tc.name, tc.mcpServerSlug, toolCallArgs(tc));
983
+ const normalized = normalizedFileSalient(id.key, id.salient, workspaceRoot);
984
+ return !!normalized && ledgerNormalizedSalients.has(normalized);
985
+ };
986
+ const settled = [];
987
+ for (const msg of messages.slice(Math.max(0, turnStartMessageIndex))) {
988
+ for (const tc of msg.toolCalls) {
989
+ if (tc.status !== ToolCallStatus.TOOL_CALL_PENDING &&
990
+ tc.status !== ToolCallStatus.TOOL_CALL_RUNNING) {
991
+ continue;
992
+ }
993
+ if (matchesLedger(tc))
994
+ continue;
995
+ tc.status = ToolCallStatus.TOOL_CALL_INTERRUPTED;
996
+ tc.error = UNRESOLVED_TOOL_CALL_ERROR;
997
+ tc.isStreaming = false;
998
+ if (!tc.completedAt)
999
+ tc.completedAt = utcTimestamp();
1000
+ settled.push({ toolCallId: tc.id, toolName: tc.name });
1001
+ }
1002
+ }
1003
+ return settled;
1004
+ }
1005
+ /**
1006
+ * Stamp the tool calls the hook denied under UNATTENDED approval mode
1007
+ * as terminal TOOL_CALL_SKIPPED rows with UNATTENDED_SKIP
1008
+ * provenance — the Cursor twin of the native harness's
1009
+ * `reconcileUnattendedSkips`, so both harnesses persist the same honest
1010
+ * shape for a platform-resolved skip.
1011
+ *
1012
+ * An unattended denial never pauses the run (its ledger kind is excluded
1013
+ * from {@link approvalDenials}), so the stream leaves the denied call as a
1014
+ * FAILED row carrying Cursor's generic hook-block error — dishonest ("the
1015
+ * tool broke") and alarming in a transcript an org admin reviews. This pass
1016
+ * correlates the unattended ledger entries to their streamed calls with the
1017
+ * SAME two identities the rest of the file uses — exact token, then
1018
+ * (category, workspace-normalized path) for the abs-vs-rel drift — and
1019
+ * settles each match to SKIPPED with a result explaining the skip.
1020
+ *
1021
+ * Scope: hook-blocked FAILED rows and still-non-terminal (PENDING/RUNNING)
1022
+ * rows only — a COMPLETED row is a real execution and is never rewritten
1023
+ * (an unattended deny cannot produce one). `approval_action`/`approved_by`
1024
+ * stay untouched: they record a person's decision only (the runtime's seed
1025
+ * copies the answer from the session's log).
1026
+ * Unmatched ledger entries need no synthesis — there is no pause to
1027
+ * surface; the model already saw the deny and adapted in-turn.
1028
+ *
1029
+ * Returns how many tool calls were stamped.
1030
+ */
1031
+ export function stampUnattendedSkippedToolCalls(messages, subAgentExecutions, unattendedLedger, workspaceRoot) {
1032
+ if (unattendedLedger.length === 0)
1033
+ return 0;
1034
+ const ledgerTokens = new Set(unattendedLedger.map((e) => e.token));
1035
+ // The hook that asked, by the call's token: the skipped row names it.
1036
+ const askingHooks = new Map(unattendedLedger.flatMap((e) => (e.hook !== undefined ? [[e.token, e.hook]] : [])));
1037
+ const ledgerNormalizedSalients = new Set();
1038
+ if (workspaceRoot) {
1039
+ for (const entry of unattendedLedger) {
1040
+ const decoded = decodeIdentityToken(entry.token);
1041
+ if (!decoded)
1042
+ continue;
1043
+ const normalized = normalizedFileSalient(decoded.key, decoded.salient, workspaceRoot);
1044
+ if (normalized)
1045
+ ledgerNormalizedSalients.add(normalized);
1046
+ }
1047
+ }
1048
+ const matchesLedger = (tc) => {
1049
+ if (ledgerTokens.has(toolCallIdentityToken(tc)))
1050
+ return true;
1051
+ if (!workspaceRoot)
1052
+ return false;
1053
+ const id = toolIdentity(tc.name, tc.mcpServerSlug, toolCallArgs(tc));
1054
+ const normalized = normalizedFileSalient(id.key, id.salient, workspaceRoot);
1055
+ return !!normalized && ledgerNormalizedSalients.has(normalized);
1056
+ };
1057
+ let stamped = 0;
1058
+ const apply = (msgs) => {
1059
+ for (const msg of msgs) {
1060
+ for (const tc of msg.toolCalls) {
1061
+ const deniedShape = (tc.status === ToolCallStatus.TOOL_CALL_FAILED && isHookBlockError(tc.error)) ||
1062
+ tc.status === ToolCallStatus.TOOL_CALL_PENDING ||
1063
+ tc.status === ToolCallStatus.TOOL_CALL_RUNNING;
1064
+ if (!deniedShape || !matchesLedger(tc))
1065
+ continue;
1066
+ tc.status = ToolCallStatus.TOOL_CALL_SKIPPED;
1067
+ tc.approvalPolicySource = ApprovalPolicySource.UNATTENDED_SKIP;
1068
+ tc.approvalPolicyHook = askingHooks.get(toolCallIdentityToken(tc)) ?? "";
1069
+ tc.policyEngineVersion = POLICY_ENGINE_VERSION;
1070
+ tc.error = "";
1071
+ tc.result = unattendedSkipMessage(tc.name);
1072
+ tc.isStreaming = false;
1073
+ if (!tc.completedAt)
1074
+ tc.completedAt = utcTimestamp();
1075
+ stamped++;
1076
+ }
1077
+ }
1078
+ };
1079
+ apply(messages);
1080
+ for (const subAgent of subAgentExecutions) {
1081
+ apply(subAgent.messages);
1082
+ }
1083
+ return stamped;
1084
+ }
1085
+ /** The tool-list refusals in a ledger, decoded from their scope tokens (`scopeRefusalToken`). */
1086
+ function scopeRefusalsIn(ledger) {
1087
+ const refusals = [];
1088
+ for (const entry of ledger) {
1089
+ if (denialKindOf(entry) !== DISABLED_DENIAL_KIND)
1090
+ continue;
1091
+ const decoded = decodeIdentityToken(entry.token);
1092
+ if (!decoded || !decoded.key.startsWith(SCOPE_KEY_PREFIX))
1093
+ continue;
1094
+ refusals.push({ key: decoded.key.slice(SCOPE_KEY_PREFIX.length), discriminator: decoded.salient, message: entry.message ?? "" });
1095
+ }
1096
+ return refusals;
1097
+ }
1098
+ /**
1099
+ * The refusal this streamed call is, if any. The tool must match: its
1100
+ * `server/tool` for an MCP call, else the stream name's `scopeKey` in the
1101
+ * SDK's taxonomy (every engine extra shares one); the hook computes the same
1102
+ * key from its own names (`hook-script.ts` `buildScopeEvalScript`). A refusal
1103
+ * naming the whole tool then matches every call of it. One carrying a
1104
+ * discriminator (a tool the lists exclude only in part) matches only the
1105
+ * call it names: a `task` by its normalized sub-agent type, a `read` by its
1106
+ * path, as given or normalized against the workspace (the hook and the
1107
+ * stream may spell one path absolutely and relatively). An allowed call of
1108
+ * the same tool, a `.stigmer/` read or a permitted sub-agent type, is never
1109
+ * matched.
1110
+ */
1111
+ function scopeRefusalOf(tc, refusals, workspaceRoot) {
1112
+ const key = tc.mcpServerSlug ? mcpToolKey(tc.mcpServerSlug, tc.name) : scopeKey(tc.name, CURSOR_SDK_TOOL_COVERS);
1113
+ const args = toolCallArgs(tc);
1114
+ const callDiscriminator = () => {
1115
+ if (key !== AGENT_SCOPE_KEY)
1116
+ return toolIdentity(tc.name, tc.mcpServerSlug, args).salient;
1117
+ return typeof args.subagentType === "string" ? normalizeSubAgentType(args.subagentType) : "";
1118
+ };
1119
+ return refusals.find((r) => {
1120
+ if (r.key !== key)
1121
+ return false;
1122
+ if (r.discriminator === "")
1123
+ return true;
1124
+ const own = callDiscriminator();
1125
+ if (own === r.discriminator)
1126
+ return true;
1127
+ if (key !== READ_SCOPE_KEY || own === "" || workspaceRoot === undefined)
1128
+ return false;
1129
+ return resolveWorkspacePath(own, workspaceRoot, false).path === resolveWorkspacePath(r.discriminator, workspaceRoot, false).path;
1130
+ });
1131
+ }
1132
+ /**
1133
+ * Settle the streamed rows of calls the hook refused under the agent's tool
1134
+ * lists (ledger kind `disabled`) into the shape the native harness persists
1135
+ * for the same refusal: TOOL_CALL_FAILED, the error the very text the model
1136
+ * read (`outOfScopeMessage`, carried on the ledger entry), no approval and no
1137
+ * provenance. Cursor stamps such a row with its generic hook-block text, and
1138
+ * the translator stamped the provenance its approval default would have
1139
+ * had at tool start, before anyone knew the call would be refused.
1140
+ *
1141
+ * Which rows: THIS turn's (from `turnStartMessageIndex`) and those of the
1142
+ * sub-agents this turn's `task` calls started, hook-blocked FAILED or still
1143
+ * PENDING/RUNNING (the unattended stamp's shape), that a refusal names
1144
+ * ({@link scopeRefusalOf}): an earlier turn's rows were settled then, and an
1145
+ * allowed call of a tool the lists exclude only in part is never one. A row
1146
+ * that failed for another reason carries no hook-block text and is left
1147
+ * alone.
1148
+ *
1149
+ * Runs before the #205 attribution pass, which then never sees these rows as
1150
+ * hook blocks. Returns how many rows were stamped.
1151
+ */
1152
+ export function stampScopeRefusedToolCalls(messages, subAgentExecutions, ledger, turnStartMessageIndex, workspaceRoot) {
1153
+ const refusals = scopeRefusalsIn(ledger).filter((r) => r.message !== "");
1154
+ if (refusals.length === 0)
1155
+ return 0;
1156
+ const turnMessages = messages.slice(Math.max(0, turnStartMessageIndex));
1157
+ const turnCallIds = new Set(turnMessages.flatMap((m) => m.toolCalls.map((tc) => tc.id)));
1158
+ let stamped = 0;
1159
+ const apply = (msgs) => {
1160
+ for (const msg of msgs) {
1161
+ for (const tc of msg.toolCalls) {
1162
+ const deniedShape = (tc.status === ToolCallStatus.TOOL_CALL_FAILED && isHookBlockError(tc.error)) ||
1163
+ tc.status === ToolCallStatus.TOOL_CALL_PENDING ||
1164
+ tc.status === ToolCallStatus.TOOL_CALL_RUNNING;
1165
+ if (!deniedShape)
1166
+ continue;
1167
+ const refusal = scopeRefusalOf(tc, refusals, workspaceRoot);
1168
+ if (refusal === undefined)
1169
+ continue;
1170
+ tc.status = ToolCallStatus.TOOL_CALL_FAILED;
1171
+ tc.error = refusal.message;
1172
+ tc.requiresApproval = false;
1173
+ tc.approvalPolicySource = ApprovalPolicySource.UNSPECIFIED;
1174
+ tc.policyEngineVersion = "";
1175
+ tc.isStreaming = false;
1176
+ if (!tc.completedAt)
1177
+ tc.completedAt = utcTimestamp();
1178
+ stamped++;
1179
+ }
1180
+ }
1181
+ };
1182
+ apply(turnMessages);
1183
+ for (const subAgent of subAgentExecutions) {
1184
+ if (turnCallIds.has(subAgent.id))
1185
+ apply(subAgent.messages);
1186
+ }
1187
+ return stamped;
1188
+ }
1189
+ /**
1190
+ * Settle the streamed rows of calls the hook layer refused before they ran
1191
+ * (ledger kind `hook`) into the shape the native engine persists for the
1192
+ * same refusal: TOOL_CALL_FAILED, the error the very text the model read,
1193
+ * no approval, and HOOK provenance naming the hook that refused, or no
1194
+ * provenance when it was a person's earlier refusal standing over a hook's
1195
+ * allow. Cursor stamps such a row with its generic hook-block text.
1196
+ *
1197
+ * Which rows: THIS turn's (from `turnStartMessageIndex`) and those of the
1198
+ * sub-agents this turn's `task` calls started, hook-blocked FAILED or still
1199
+ * PENDING/RUNNING, each entry settling the first row of its call: the exact
1200
+ * identity token, its coarse (key, salient), then the workspace-normalized
1201
+ * path for the abs-vs-rel drift. Runs before the #205 attribution pass,
1202
+ * which then never sees these rows as hook blocks. Returns the ids of the
1203
+ * rows it stamped, which the terminal twin collapse keeps (#1967).
1204
+ */
1205
+ export function stampHookRefusedToolCalls(messages, subAgentExecutions, ledger, turnStartMessageIndex, workspaceRoot) {
1206
+ const refusals = ledger.filter((e) => denialKindOf(e) === HOOK_DENIAL_KIND && e.message);
1207
+ if (refusals.length === 0)
1208
+ return [];
1209
+ const turnMessages = messages.slice(Math.max(0, turnStartMessageIndex));
1210
+ const turnCallIds = new Set(turnMessages.flatMap((m) => m.toolCalls.map((tc) => tc.id)));
1211
+ const rows = [
1212
+ ...turnMessages.flatMap((m) => m.toolCalls),
1213
+ ...subAgentExecutions.filter((sa) => turnCallIds.has(sa.id)).flatMap((sa) => sa.messages.flatMap((m) => m.toolCalls)),
1214
+ ].filter((tc) => (tc.status === ToolCallStatus.TOOL_CALL_FAILED && isHookBlockError(tc.error)) ||
1215
+ tc.status === ToolCallStatus.TOOL_CALL_PENDING ||
1216
+ tc.status === ToolCallStatus.TOOL_CALL_RUNNING);
1217
+ const stamped = [];
1218
+ const settled = new Set();
1219
+ for (const entry of refusals) {
1220
+ const decoded = decodeIdentityToken(entry.token);
1221
+ const coarse = decoded ? grantToken(decoded.key, decoded.salient) : undefined;
1222
+ const normalized = decoded && workspaceRoot ? normalizedFileSalient(decoded.key, decoded.salient, workspaceRoot) : undefined;
1223
+ const matches = (tc) => {
1224
+ if (toolCallIdentityToken(tc) === entry.token)
1225
+ return true;
1226
+ const id = toolIdentity(tc.name, tc.mcpServerSlug, toolCallArgs(tc));
1227
+ if (coarse !== undefined && grantToken(id.key, id.salient) === coarse)
1228
+ return true;
1229
+ return normalized !== undefined && workspaceRoot !== undefined && normalizedFileSalient(id.key, id.salient, workspaceRoot) === normalized;
1230
+ };
1231
+ const tc = rows.find((row) => !settled.has(row) && matches(row));
1232
+ if (tc === undefined)
1233
+ continue;
1234
+ settled.add(tc);
1235
+ tc.status = ToolCallStatus.TOOL_CALL_FAILED;
1236
+ tc.error = entry.message ?? "";
1237
+ tc.requiresApproval = false;
1238
+ tc.approvalPolicySource = entry.hook !== undefined ? ApprovalPolicySource.HOOK : ApprovalPolicySource.UNSPECIFIED;
1239
+ tc.approvalPolicyHook = entry.hook ?? "";
1240
+ tc.policyEngineVersion = entry.hook !== undefined ? POLICY_ENGINE_VERSION : "";
1241
+ tc.isStreaming = false;
1242
+ if (!tc.completedAt)
1243
+ tc.completedAt = utcTimestamp();
1244
+ stamped.push(tc.id);
1245
+ }
1246
+ return stamped;
1247
+ }
1248
+ /**
1249
+ * Resolve a human-readable approval message for a denied tool, preferring the
1250
+ * destructive-MCP template, then the unlisted-server one (a server whose
1251
+ * tools could not be listed this turn, so every tool of it asks), then the
1252
+ * built-in template, then a generic fallback.
1253
+ */
1254
+ function resolveDeniedApprovalMessage(name, mcpServerSlug, args, mcpDefault) {
1255
+ if (mcpDefault && mcpServerSlug && mcpDefault.destructive.has(mcpToolKey(mcpServerSlug, name))) {
1256
+ return resolveApprovalMessage(DESTRUCTIVE_MCP_APPROVAL_MESSAGE, name, args);
1257
+ }
1258
+ if (mcpDefault && mcpServerSlug && mcpDefault.unlisted.has(mcpServerSlug)) {
1259
+ return resolveApprovalMessage(UNLISTED_MCP_APPROVAL_MESSAGE, name, args);
1260
+ }
1261
+ if (!mcpServerSlug) {
1262
+ const message = resolveBuiltInApprovalMessage(name, args);
1263
+ if (message !== undefined)
1264
+ return message;
1265
+ }
1266
+ return `Tool requires approval: ${name}`;
1267
+ }
1268
+ //# sourceMappingURL=boundary-rows.js.map