@stigmer/runner 3.15.1 → 3.15.2-dev.20260913223433

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 (518) hide show
  1. package/README.md +2 -4
  2. package/dist/.build-fingerprint +1 -1
  3. package/dist/__test-utils__/execution-record-fixture.d.ts +14 -0
  4. package/dist/__test-utils__/execution-record-fixture.js +4 -0
  5. package/dist/__test-utils__/execution-record-fixture.js.map +1 -1
  6. package/dist/__test-utils__/file-review-projection.d.ts +40 -0
  7. package/dist/__test-utils__/file-review-projection.js +136 -0
  8. package/dist/__test-utils__/file-review-projection.js.map +1 -0
  9. package/dist/__test-utils__/harness-contract/types.d.ts +23 -1
  10. package/dist/__test-utils__/harness-contract/types.js +15 -0
  11. package/dist/__test-utils__/harness-contract/types.js.map +1 -1
  12. package/dist/__test-utils__/hermetic-activity.d.ts +44 -12
  13. package/dist/__test-utils__/hermetic-activity.js +52 -14
  14. package/dist/__test-utils__/hermetic-activity.js.map +1 -1
  15. package/dist/__test-utils__/model-registry-fixture.d.ts +32 -7
  16. package/dist/__test-utils__/model-registry-fixture.js +31 -7
  17. package/dist/__test-utils__/model-registry-fixture.js.map +1 -1
  18. package/dist/__test-utils__/turn-input-fixture.d.ts +1 -1
  19. package/dist/__test-utils__/turn-input-fixture.js +1 -1
  20. package/dist/__test-utils__/turn-input-fixture.js.map +1 -1
  21. package/dist/activities/call-agent.js +2 -2
  22. package/dist/activities/call-agent.js.map +1 -1
  23. package/dist/activities/execute-cursor/__test-utils__/contract-subject.js +45 -3
  24. package/dist/activities/execute-cursor/__test-utils__/contract-subject.js.map +1 -1
  25. package/dist/activities/execute-cursor/__test-utils__/hermetic-cursor.d.ts +0 -9
  26. package/dist/activities/execute-cursor/__test-utils__/hermetic-cursor.js +2 -41
  27. package/dist/activities/execute-cursor/__test-utils__/hermetic-cursor.js.map +1 -1
  28. package/dist/activities/execute-cursor/adapter.d.ts +7 -5
  29. package/dist/activities/execute-cursor/adapter.js +7 -5
  30. package/dist/activities/execute-cursor/adapter.js.map +1 -1
  31. package/dist/activities/execute-cursor/approval-policy.d.ts +5 -2
  32. package/dist/activities/execute-cursor/approval-policy.js +5 -2
  33. package/dist/activities/execute-cursor/approval-policy.js.map +1 -1
  34. package/dist/activities/execute-cursor/approval-state.d.ts +16 -8
  35. package/dist/activities/execute-cursor/approval-state.js +6 -3
  36. package/dist/activities/execute-cursor/approval-state.js.map +1 -1
  37. package/dist/activities/execute-cursor/cas-observations.d.ts +14 -2
  38. package/dist/activities/execute-cursor/cas-observations.js +19 -2
  39. package/dist/activities/execute-cursor/cas-observations.js.map +1 -1
  40. package/dist/activities/execute-cursor/cursor-capabilities.d.ts +8 -4
  41. package/dist/activities/execute-cursor/cursor-capabilities.js +21 -4
  42. package/dist/activities/execute-cursor/cursor-capabilities.js.map +1 -1
  43. package/dist/activities/execute-cursor/message-translator.d.ts +12 -20
  44. package/dist/activities/execute-cursor/message-translator.js +19 -32
  45. package/dist/activities/execute-cursor/message-translator.js.map +1 -1
  46. package/dist/activities/execute-cursor/prompt-builder.d.ts +48 -58
  47. package/dist/activities/execute-cursor/prompt-builder.js +76 -95
  48. package/dist/activities/execute-cursor/prompt-builder.js.map +1 -1
  49. package/dist/activities/execute-cursor/turn-boundary.d.ts +27 -55
  50. package/dist/activities/execute-cursor/turn-boundary.js +30 -90
  51. package/dist/activities/execute-cursor/turn-boundary.js.map +1 -1
  52. package/dist/activities/execute-cursor/turn-settle.d.ts +11 -7
  53. package/dist/activities/execute-cursor/turn-settle.js +37 -49
  54. package/dist/activities/execute-cursor/turn-settle.js.map +1 -1
  55. package/dist/activities/execute-cursor/turn-setup.d.ts +16 -24
  56. package/dist/activities/execute-cursor/turn-setup.js +29 -59
  57. package/dist/activities/execute-cursor/turn-setup.js.map +1 -1
  58. package/dist/activities/execute-cursor/turn-stream.d.ts +3 -8
  59. package/dist/activities/execute-cursor/turn-stream.js +9 -22
  60. package/dist/activities/execute-cursor/turn-stream.js.map +1 -1
  61. package/dist/activities/execute-cursor/turn.js +5 -1
  62. package/dist/activities/execute-cursor/turn.js.map +1 -1
  63. package/dist/activities/execute-deep-agent/__test-utils__/contract-subject.d.ts +93 -0
  64. package/dist/activities/execute-deep-agent/__test-utils__/contract-subject.js +348 -0
  65. package/dist/activities/execute-deep-agent/__test-utils__/contract-subject.js.map +1 -0
  66. package/dist/activities/execute-deep-agent/__test-utils__/hermetic-deep-agent.d.ts +170 -0
  67. package/dist/activities/execute-deep-agent/__test-utils__/hermetic-deep-agent.js +225 -0
  68. package/dist/activities/execute-deep-agent/__test-utils__/hermetic-deep-agent.js.map +1 -0
  69. package/dist/activities/execute-deep-agent/__test-utils__/hitl-script.d.ts +24 -0
  70. package/dist/activities/execute-deep-agent/__test-utils__/hitl-script.js +41 -0
  71. package/dist/activities/execute-deep-agent/__test-utils__/hitl-script.js.map +1 -0
  72. package/dist/activities/execute-deep-agent/__test-utils__/scripted-model-module.d.ts +54 -0
  73. package/dist/activities/execute-deep-agent/__test-utils__/scripted-model-module.js +72 -0
  74. package/dist/activities/execute-deep-agent/__test-utils__/scripted-model-module.js.map +1 -0
  75. package/dist/activities/execute-deep-agent/__test-utils__/scripted-model.d.ts +187 -23
  76. package/dist/activities/execute-deep-agent/__test-utils__/scripted-model.js +238 -27
  77. package/dist/activities/execute-deep-agent/__test-utils__/scripted-model.js.map +1 -1
  78. package/dist/activities/execute-deep-agent/adapter.d.ts +41 -0
  79. package/dist/activities/execute-deep-agent/adapter.js +78 -0
  80. package/dist/activities/execute-deep-agent/adapter.js.map +1 -0
  81. package/dist/activities/execute-deep-agent/cas-capture-observer.d.ts +8 -0
  82. package/dist/activities/execute-deep-agent/cas-capture-observer.js +9 -0
  83. package/dist/activities/execute-deep-agent/cas-capture-observer.js.map +1 -1
  84. package/dist/activities/execute-deep-agent/deep-agent-capabilities.d.ts +31 -0
  85. package/dist/activities/execute-deep-agent/deep-agent-capabilities.js +40 -0
  86. package/dist/activities/execute-deep-agent/deep-agent-capabilities.js.map +1 -0
  87. package/dist/activities/execute-deep-agent/execution-state.d.ts +4 -11
  88. package/dist/activities/execute-deep-agent/execution-state.js +4 -12
  89. package/dist/activities/execute-deep-agent/execution-state.js.map +1 -1
  90. package/dist/activities/execute-deep-agent/hitl.d.ts +49 -47
  91. package/dist/activities/execute-deep-agent/hitl.js +77 -103
  92. package/dist/activities/execute-deep-agent/hitl.js.map +1 -1
  93. package/dist/activities/execute-deep-agent/prompt-builder.d.ts +51 -23
  94. package/dist/activities/execute-deep-agent/prompt-builder.js +115 -76
  95. package/dist/activities/execute-deep-agent/prompt-builder.js.map +1 -1
  96. package/dist/activities/execute-deep-agent/status-builder-shared.d.ts +18 -32
  97. package/dist/activities/execute-deep-agent/status-builder-shared.js +10 -65
  98. package/dist/activities/execute-deep-agent/status-builder-shared.js.map +1 -1
  99. package/dist/activities/execute-deep-agent/streaming-side-effects.d.ts +10 -8
  100. package/dist/activities/execute-deep-agent/streaming-side-effects.js +12 -14
  101. package/dist/activities/execute-deep-agent/streaming-side-effects.js.map +1 -1
  102. package/dist/activities/execute-deep-agent/subagent-tracker.d.ts +36 -13
  103. package/dist/activities/execute-deep-agent/subagent-tracker.js +76 -39
  104. package/dist/activities/execute-deep-agent/subagent-tracker.js.map +1 -1
  105. package/dist/activities/execute-deep-agent/subagent-transformer.d.ts +25 -28
  106. package/dist/activities/execute-deep-agent/subagent-transformer.js +29 -82
  107. package/dist/activities/execute-deep-agent/subagent-transformer.js.map +1 -1
  108. package/dist/activities/execute-deep-agent/subagent-wiring.d.ts +3 -2
  109. package/dist/activities/execute-deep-agent/subagent-wiring.js +2 -2
  110. package/dist/activities/execute-deep-agent/subagent-wiring.js.map +1 -1
  111. package/dist/activities/execute-deep-agent/turn-settle.d.ts +42 -0
  112. package/dist/activities/execute-deep-agent/turn-settle.js +146 -0
  113. package/dist/activities/execute-deep-agent/turn-settle.js.map +1 -0
  114. package/dist/activities/execute-deep-agent/turn-setup.d.ts +212 -0
  115. package/dist/activities/execute-deep-agent/turn-setup.js +430 -0
  116. package/dist/activities/execute-deep-agent/turn-setup.js.map +1 -0
  117. package/dist/activities/execute-deep-agent/turn-stream.d.ts +97 -0
  118. package/dist/activities/execute-deep-agent/turn-stream.js +242 -0
  119. package/dist/activities/execute-deep-agent/turn-stream.js.map +1 -0
  120. package/dist/activities/execute-deep-agent/turn.d.ts +42 -0
  121. package/dist/activities/execute-deep-agent/turn.js +116 -0
  122. package/dist/activities/execute-deep-agent/turn.js.map +1 -0
  123. package/dist/activities/execute-deep-agent/v3-event-recorder.d.ts +6 -5
  124. package/dist/activities/execute-deep-agent/v3-event-recorder.js +6 -5
  125. package/dist/activities/execute-deep-agent/v3-event-recorder.js.map +1 -1
  126. package/dist/activities/execute-deep-agent/v3-events.d.ts +1 -1
  127. package/dist/activities/execute-deep-agent/v3-events.js +1 -1
  128. package/dist/activities/execute-deep-agent/v3-status-builder.d.ts +60 -17
  129. package/dist/activities/execute-deep-agent/v3-status-builder.js +72 -57
  130. package/dist/activities/execute-deep-agent/v3-status-builder.js.map +1 -1
  131. package/dist/harness/approval-decisions.d.ts +61 -0
  132. package/dist/harness/approval-decisions.js +102 -0
  133. package/dist/harness/approval-decisions.js.map +1 -0
  134. package/dist/harness/capabilities.d.ts +16 -5
  135. package/dist/harness/capabilities.js +9 -0
  136. package/dist/harness/capabilities.js.map +1 -1
  137. package/dist/harness/capture.d.ts +144 -0
  138. package/dist/harness/capture.js +219 -0
  139. package/dist/harness/capture.js.map +1 -0
  140. package/dist/harness/persist-chokepoint.d.ts +19 -4
  141. package/dist/harness/persist-chokepoint.js +17 -4
  142. package/dist/harness/persist-chokepoint.js.map +1 -1
  143. package/dist/harness/run-turn.js +115 -29
  144. package/dist/harness/run-turn.js.map +1 -1
  145. package/dist/harness/terminal-table.d.ts +40 -11
  146. package/dist/harness/terminal-table.js +58 -19
  147. package/dist/harness/terminal-table.js.map +1 -1
  148. package/dist/harness/turn-context.d.ts +141 -76
  149. package/dist/harness/turn-context.js +194 -99
  150. package/dist/harness/turn-context.js.map +1 -1
  151. package/dist/harness/types.d.ts +65 -12
  152. package/dist/harness/types.js +8 -2
  153. package/dist/harness/types.js.map +1 -1
  154. package/dist/harness-adapters.d.ts +12 -8
  155. package/dist/harness-adapters.js +17 -9
  156. package/dist/harness-adapters.js.map +1 -1
  157. package/dist/middleware/approval-gate.d.ts +1 -1
  158. package/dist/middleware/approval-gate.js +1 -1
  159. package/dist/middleware/approval-gate.js.map +1 -1
  160. package/dist/middleware/cost-advisory.d.ts +39 -0
  161. package/dist/middleware/{cost-cap.js → cost-advisory.js} +37 -55
  162. package/dist/middleware/cost-advisory.js.map +1 -0
  163. package/dist/middleware/index.d.ts +23 -12
  164. package/dist/middleware/index.js +26 -18
  165. package/dist/middleware/index.js.map +1 -1
  166. package/dist/middleware/types.d.ts +3 -2
  167. package/dist/runner-manager.js +1 -5
  168. package/dist/runner-manager.js.map +1 -1
  169. package/dist/runner.js +1 -5
  170. package/dist/runner.js.map +1 -1
  171. package/dist/shared/attachment-resolver.d.ts +41 -18
  172. package/dist/shared/attachment-resolver.js +178 -46
  173. package/dist/shared/attachment-resolver.js.map +1 -1
  174. package/dist/shared/attachment-zip.d.ts +85 -0
  175. package/dist/shared/attachment-zip.js +185 -0
  176. package/dist/shared/attachment-zip.js.map +1 -0
  177. package/dist/shared/connect-backfill.js +5 -4
  178. package/dist/shared/connect-backfill.js.map +1 -1
  179. package/dist/shared/cost-guard.d.ts +3 -3
  180. package/dist/shared/cost-guard.js +3 -3
  181. package/dist/shared/execution-status-writer.d.ts +5 -5
  182. package/dist/shared/execution-status-writer.js +5 -5
  183. package/dist/shared/extract-structured-output.d.ts +8 -7
  184. package/dist/shared/extract-structured-output.js +8 -7
  185. package/dist/shared/extract-structured-output.js.map +1 -1
  186. package/dist/shared/filereview/cas-progress.d.ts +1 -18
  187. package/dist/shared/filereview/cas-progress.js +4 -0
  188. package/dist/shared/filereview/cas-progress.js.map +1 -1
  189. package/dist/shared/filereview/cas-touched.d.ts +56 -0
  190. package/dist/shared/filereview/cas-touched.js +63 -0
  191. package/dist/shared/filereview/cas-touched.js.map +1 -0
  192. package/dist/shared/filereview/index.d.ts +2 -1
  193. package/dist/shared/filereview/index.js +2 -1
  194. package/dist/shared/filereview/index.js.map +1 -1
  195. package/dist/shared/mcp-resolver.d.ts +4 -5
  196. package/dist/shared/mcp-resolver.js +4 -5
  197. package/dist/shared/mcp-resolver.js.map +1 -1
  198. package/dist/shared/persist-decision.d.ts +3 -4
  199. package/dist/shared/persist-decision.js +3 -4
  200. package/dist/shared/persist-decision.js.map +1 -1
  201. package/dist/shared/plan-mode-permissions.d.ts +2 -2
  202. package/dist/shared/plan-mode-permissions.js +2 -2
  203. package/dist/shared/plan-mode-prompt.d.ts +1 -1
  204. package/dist/shared/plan-mode-prompt.js +1 -1
  205. package/dist/shared/prompt-sections.d.ts +163 -0
  206. package/dist/shared/prompt-sections.js +164 -0
  207. package/dist/shared/prompt-sections.js.map +1 -0
  208. package/dist/shared/skill-resolver.d.ts +4 -2
  209. package/dist/shared/skill-resolver.js +4 -2
  210. package/dist/shared/skill-resolver.js.map +1 -1
  211. package/dist/shared/tool-rounds.d.ts +32 -0
  212. package/dist/shared/tool-rounds.js +43 -0
  213. package/dist/shared/tool-rounds.js.map +1 -1
  214. package/dist/shared/tool-row.d.ts +34 -0
  215. package/dist/shared/tool-row.js +52 -0
  216. package/dist/shared/tool-row.js.map +1 -1
  217. package/dist/shared/workspace/session-provision.d.ts +3 -3
  218. package/dist/shared/workspace/session-provision.js +3 -3
  219. package/dist/shared/workspace/stigmer-link.d.ts +3 -3
  220. package/dist/shared/workspace/stigmer-link.js +3 -3
  221. package/dist/shared/workspace/writeback-coordinator.d.ts +15 -22
  222. package/dist/shared/workspace/writeback-coordinator.js +16 -53
  223. package/dist/shared/workspace/writeback-coordinator.js.map +1 -1
  224. package/dist/tools/index.d.ts +1 -1
  225. package/dist/tools/index.js +1 -1
  226. package/package.json +4 -4
  227. package/src/__test-utils__/__tests__/harness-contract-self-check.test.ts +1 -0
  228. package/src/__test-utils__/execution-record-fixture.ts +18 -2
  229. package/src/__test-utils__/file-review-projection.ts +156 -0
  230. package/src/__test-utils__/git-workspace-fixture.ts +58 -0
  231. package/src/__test-utils__/harness-boot-order-child.ts +7 -2
  232. package/src/__test-utils__/harness-contract/contract.ts +33 -20
  233. package/src/__test-utils__/harness-contract/recording-sink.ts +11 -1
  234. package/src/__test-utils__/harness-contract/runtime-contract.ts +328 -10
  235. package/src/__test-utils__/harness-contract/scripted-adapter.ts +38 -6
  236. package/src/__test-utils__/harness-contract/types.ts +27 -3
  237. package/src/__test-utils__/hermetic-activity.ts +52 -14
  238. package/src/__test-utils__/model-registry-fixture.ts +32 -7
  239. package/src/__test-utils__/module-specifiers.ts +24 -0
  240. package/src/__test-utils__/turn-input-fixture.ts +2 -2
  241. package/src/__tests__/harness-boot-order.test.ts +9 -2
  242. package/src/activities/call-agent.ts +2 -2
  243. package/src/activities/execute-cursor/__test-utils__/contract-subject.ts +47 -3
  244. package/src/activities/execute-cursor/__test-utils__/hermetic-cursor.ts +2 -48
  245. package/src/activities/execute-cursor/__tests__/approval-decisions-agree.test.ts +1 -1
  246. package/src/activities/execute-cursor/__tests__/approval-gate.test.ts +6 -1
  247. package/src/activities/execute-cursor/__tests__/build-prompt.test.ts +52 -27
  248. package/src/activities/execute-cursor/__tests__/cas-observations.test.ts +25 -0
  249. package/src/activities/execute-cursor/__tests__/goldens/prompt.enhanced.everything.prompt.md +166 -0
  250. package/src/activities/execute-cursor/__tests__/goldens/prompt.enhanced.plan-mode.prompt.md +186 -0
  251. package/src/activities/execute-cursor/__tests__/goldens/prompt.hitl.recovery.prompt.md +191 -0
  252. package/src/activities/execute-cursor/__tests__/goldens/prompt.hitl.reinvocation.prompt.md +13 -0
  253. package/src/activities/execute-cursor/__tests__/goldens/prompt.resumed.prefixed.prompt.md +32 -0
  254. package/src/activities/execute-cursor/__tests__/goldens/prompt.resumed.raw.prompt.md +1 -0
  255. package/src/activities/execute-cursor/__tests__/hermetic/file-review-capture.test.ts +1 -2
  256. package/src/activities/execute-cursor/__tests__/hermetic/goldens/sdk-error-at-create.status.json +4 -0
  257. package/src/activities/execute-cursor/__tests__/hermetic/harness-contract.test.ts +24 -4
  258. package/src/activities/execute-cursor/__tests__/hermetic/stream-self-stop-arms.test.ts +6 -5
  259. package/src/activities/execute-cursor/__tests__/hermetic/thrown-error-arms.test.ts +9 -0
  260. package/src/activities/execute-cursor/__tests__/hitl-resume-history.test.ts +11 -8
  261. package/src/activities/execute-cursor/__tests__/prompt-goldens.test.ts +229 -0
  262. package/src/activities/execute-cursor/__tests__/same-identity-reproposal.test.ts +3 -3
  263. package/src/activities/execute-cursor/__tests__/sequential-gate-resume.test.ts +2 -2
  264. package/src/activities/execute-cursor/__tests__/turn-boundary.test.ts +78 -234
  265. package/src/activities/execute-cursor/__tests__/turn-stream.test.ts +1 -26
  266. package/src/activities/execute-cursor/adapter.ts +7 -5
  267. package/src/activities/execute-cursor/approval-policy.ts +5 -2
  268. package/src/activities/execute-cursor/approval-state.ts +16 -8
  269. package/src/activities/execute-cursor/cas-observations.ts +20 -2
  270. package/src/activities/execute-cursor/cursor-capabilities.ts +24 -5
  271. package/src/activities/execute-cursor/message-translator.ts +29 -41
  272. package/src/activities/execute-cursor/prompt-builder.ts +99 -157
  273. package/src/activities/execute-cursor/turn-boundary.ts +34 -140
  274. package/src/activities/execute-cursor/turn-settle.ts +37 -51
  275. package/src/activities/execute-cursor/turn-setup.ts +30 -70
  276. package/src/activities/execute-cursor/turn-stream.ts +8 -31
  277. package/src/activities/execute-cursor/turn.ts +5 -1
  278. package/src/activities/execute-deep-agent/__test-utils__/contract-subject.ts +391 -0
  279. package/src/activities/execute-deep-agent/__test-utils__/hermetic-deep-agent.ts +313 -0
  280. package/src/activities/execute-deep-agent/__test-utils__/hitl-script.ts +48 -0
  281. package/src/activities/execute-deep-agent/__test-utils__/scripted-model-module.ts +85 -0
  282. package/src/activities/execute-deep-agent/__test-utils__/scripted-model.ts +383 -36
  283. package/src/activities/execute-deep-agent/__tests__/adapter-graph-is-sdk-free.test.ts +76 -0
  284. package/src/activities/execute-deep-agent/__tests__/adapter-is-temporal-free.test.ts +47 -0
  285. package/src/activities/execute-deep-agent/__tests__/adapter.test.ts +80 -0
  286. package/src/activities/execute-deep-agent/__tests__/cas-capture-backend.test.ts +1 -1
  287. package/src/activities/execute-deep-agent/__tests__/execution-state-extended.test.ts +0 -2
  288. package/src/activities/execute-deep-agent/__tests__/execution-state.test.ts +0 -3
  289. package/src/activities/execute-deep-agent/__tests__/goldens/system-prompt.build-from-plan.prompt.md +172 -0
  290. package/src/activities/execute-deep-agent/__tests__/goldens/system-prompt.everything.prompt.md +167 -0
  291. package/src/activities/execute-deep-agent/__tests__/goldens/system-prompt.minimal.prompt.md +36 -0
  292. package/src/activities/execute-deep-agent/__tests__/goldens/system-prompt.plan-mode.prompt.md +178 -0
  293. package/src/activities/execute-deep-agent/__tests__/goldens/system-prompt.skills-below-threshold.prompt.md +158 -0
  294. package/src/activities/execute-deep-agent/__tests__/hermetic/file-review-capture.test.ts +210 -0
  295. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/approve-all-lease.turn1.status.json +74 -0
  296. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/approve-all-lease.turn2.status.json +104 -0
  297. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/approve.turn2.status.json +78 -0
  298. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/file-review-capture.status.json +138 -0
  299. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/gate.turn1.status.json +68 -0
  300. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/inline-artifact.turn1.status.json +154 -0
  301. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/inline-artifact.turn2.status.json +116 -0
  302. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/pause.loop.after-tool.status.json +69 -0
  303. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/pause.loop.mid-tool.status.json +67 -0
  304. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/plain-turn.status.json +47 -0
  305. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/platform-stop.status.json +68 -0
  306. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/recursion-limit.persisted.status.json +280 -0
  307. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/reject.turn2.status.json +77 -0
  308. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/resolution-error.status.json +18 -0
  309. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/sequential-gates.turn2.status.json +99 -0
  310. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/sequential-gates.turn3.status.json +109 -0
  311. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/skip.turn2.status.json +76 -0
  312. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/structured-output.text-fallback.status.json +51 -0
  313. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/structured-output.tier2.status.json +51 -0
  314. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/structured-output.tool-strategy.status.json +56 -0
  315. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/sub-agent-delegation.status.json +90 -0
  316. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/tool-call.status.json +70 -0
  317. package/src/activities/execute-deep-agent/__tests__/hermetic/goldens/worker-shutdown.status.json +71 -0
  318. package/src/activities/execute-deep-agent/__tests__/hermetic/harness-contract.test.ts +144 -0
  319. package/src/activities/execute-deep-agent/__tests__/hermetic/hitl-approve-all-lease.test.ts +184 -0
  320. package/src/activities/execute-deep-agent/__tests__/hermetic/hitl-round-trips.test.ts +203 -0
  321. package/src/activities/execute-deep-agent/__tests__/hermetic/hitl-sequential-gates.test.ts +170 -0
  322. package/src/activities/execute-deep-agent/__tests__/hermetic/inline-artifact-across-gate.test.ts +175 -0
  323. package/src/activities/execute-deep-agent/__tests__/hermetic/pause-vs-shutdown.test.ts +206 -0
  324. package/src/activities/execute-deep-agent/__tests__/hermetic/plain-turn.test.ts +142 -0
  325. package/src/activities/execute-deep-agent/__tests__/hermetic/platform-stop.test.ts +126 -0
  326. package/src/activities/execute-deep-agent/__tests__/hermetic/recursion-limit.test.ts +139 -0
  327. package/src/activities/execute-deep-agent/__tests__/hermetic/resolution-error.test.ts +122 -0
  328. package/src/activities/execute-deep-agent/__tests__/hermetic/structured-output.test.ts +236 -0
  329. package/src/activities/execute-deep-agent/__tests__/hermetic/sub-agent-delegation.test.ts +161 -0
  330. package/src/activities/execute-deep-agent/__tests__/hermetic/tool-call.test.ts +157 -0
  331. package/src/activities/execute-deep-agent/__tests__/hermetic/workspace-lock-timeout.test.ts +152 -0
  332. package/src/activities/execute-deep-agent/__tests__/hitl.test.ts +50 -122
  333. package/src/activities/execute-deep-agent/__tests__/inline-publisher.test.ts +8 -6
  334. package/src/activities/execute-deep-agent/__tests__/plan-mode-path-normalization.test.ts +2 -2
  335. package/src/activities/execute-deep-agent/__tests__/prompt-builder.test.ts +35 -35
  336. package/src/activities/execute-deep-agent/__tests__/prompt-goldens.test.ts +247 -0
  337. package/src/activities/execute-deep-agent/__tests__/scripted-model.test.ts +329 -0
  338. package/src/activities/execute-deep-agent/__tests__/status-builder-shared.test.ts +1 -20
  339. package/src/activities/execute-deep-agent/__tests__/streaming-side-effects.test.ts +78 -0
  340. package/src/activities/execute-deep-agent/__tests__/subagent-gitignored-capture.test.ts +1 -1
  341. package/src/activities/execute-deep-agent/__tests__/subagent-plan-mode-permissions.test.ts +2 -2
  342. package/src/activities/execute-deep-agent/__tests__/subagent-tracker.test.ts +57 -31
  343. package/src/activities/execute-deep-agent/__tests__/subagent-transformer.test.ts +19 -79
  344. package/src/activities/execute-deep-agent/__tests__/subagent-wiring.test.ts +15 -15
  345. package/src/activities/execute-deep-agent/__tests__/summarization-verification.test.ts +1 -1
  346. package/src/activities/execute-deep-agent/__tests__/turn-stream.test.ts +391 -0
  347. package/src/activities/execute-deep-agent/__tests__/v3-status-builder.test.ts +343 -38
  348. package/src/activities/execute-deep-agent/__tests__/vision-input.test.ts +5 -5
  349. package/src/activities/execute-deep-agent/adapter.ts +94 -0
  350. package/src/activities/execute-deep-agent/cas-capture-observer.ts +11 -0
  351. package/src/activities/execute-deep-agent/deep-agent-capabilities.ts +43 -0
  352. package/src/activities/execute-deep-agent/execution-state.ts +4 -13
  353. package/src/activities/execute-deep-agent/hitl.ts +100 -123
  354. package/src/activities/execute-deep-agent/prompt-builder.ts +141 -115
  355. package/src/activities/execute-deep-agent/status-builder-shared.ts +21 -84
  356. package/src/activities/execute-deep-agent/streaming-side-effects.ts +13 -19
  357. package/src/activities/execute-deep-agent/subagent-tracker.ts +77 -42
  358. package/src/activities/execute-deep-agent/subagent-transformer.ts +46 -105
  359. package/src/activities/execute-deep-agent/subagent-wiring.ts +5 -4
  360. package/src/activities/execute-deep-agent/turn-settle.ts +164 -0
  361. package/src/activities/execute-deep-agent/turn-setup.ts +541 -0
  362. package/src/activities/execute-deep-agent/turn-stream.ts +313 -0
  363. package/src/activities/execute-deep-agent/turn.ts +131 -0
  364. package/src/activities/execute-deep-agent/v3-event-recorder.ts +6 -5
  365. package/src/activities/execute-deep-agent/v3-events.ts +1 -1
  366. package/src/activities/execute-deep-agent/v3-status-builder.ts +84 -63
  367. package/src/harness/__tests__/approval-decisions.test.ts +116 -0
  368. package/src/harness/__tests__/capture.test.ts +268 -0
  369. package/src/harness/__tests__/mount-skills.test.ts +169 -0
  370. package/src/harness/__tests__/persist-chokepoint.test.ts +38 -2
  371. package/src/harness/__tests__/run-turn-deterministic.test.ts +94 -0
  372. package/src/harness/__tests__/run-turn.test.ts +39 -23
  373. package/src/harness/__tests__/turn-attachments-vision.test.ts +80 -0
  374. package/src/harness/__tests__/turn-context.test.ts +73 -26
  375. package/src/harness/approval-decisions.ts +104 -0
  376. package/src/harness/capabilities.ts +16 -5
  377. package/src/harness/capture.ts +301 -0
  378. package/src/harness/persist-chokepoint.ts +24 -4
  379. package/src/harness/run-turn.ts +120 -29
  380. package/src/harness/terminal-table.ts +61 -20
  381. package/src/harness/turn-context.ts +208 -111
  382. package/src/harness/types.ts +66 -12
  383. package/src/harness-adapters.ts +17 -9
  384. package/src/middleware/__tests__/approval-gate.test.ts +1 -1
  385. package/src/middleware/__tests__/cost-advisory.test.ts +113 -0
  386. package/src/middleware/approval-gate.ts +2 -2
  387. package/src/middleware/{cost-cap.ts → cost-advisory.ts} +40 -70
  388. package/src/middleware/index.ts +29 -29
  389. package/src/middleware/types.ts +3 -2
  390. package/src/runner-manager.ts +0 -8
  391. package/src/runner.ts +0 -8
  392. package/src/shared/__tests__/attachment-naming.test.ts +6 -19
  393. package/src/shared/__tests__/attachment-resolver.test.ts +158 -8
  394. package/src/shared/__tests__/attachment-zip.test.ts +236 -0
  395. package/src/shared/__tests__/bedrock-adapter.test.ts +1 -1
  396. package/src/shared/__tests__/blueprint-resolver.test.ts +43 -0
  397. package/src/shared/__tests__/cost-guard.test.ts +3 -3
  398. package/src/shared/__tests__/prompt-sections.test.ts +167 -0
  399. package/src/shared/__tests__/secret-leak-scan.test.ts +2 -2
  400. package/src/{activities/execute-deep-agent → shared}/__tests__/stamp-flowed-rows.test.ts +33 -10
  401. package/src/shared/__tests__/vertex-adapter.test.ts +1 -1
  402. package/src/shared/attachment-resolver.ts +218 -55
  403. package/src/shared/attachment-zip.ts +281 -0
  404. package/src/shared/connect-backfill.ts +9 -11
  405. package/src/shared/cost-guard.ts +3 -3
  406. package/src/shared/execution-status-writer.ts +5 -5
  407. package/src/shared/extract-structured-output.ts +8 -7
  408. package/src/shared/filereview/__tests__/capture.test.ts +86 -4
  409. package/src/shared/filereview/__tests__/cas-progress.test.ts +2 -1
  410. package/src/shared/filereview/cas-progress.ts +5 -19
  411. package/src/shared/filereview/cas-touched.ts +89 -0
  412. package/src/shared/filereview/index.ts +4 -2
  413. package/src/shared/mcp-resolver.ts +4 -5
  414. package/src/shared/persist-decision.ts +3 -4
  415. package/src/shared/plan-mode-permissions.ts +2 -2
  416. package/src/shared/plan-mode-prompt.ts +1 -1
  417. package/src/shared/prompt-sections.ts +256 -0
  418. package/src/shared/skill-resolver.ts +4 -2
  419. package/src/shared/tool-rounds.ts +48 -0
  420. package/src/shared/tool-row.ts +61 -0
  421. package/src/shared/workspace/__tests__/stigmer-link.test.ts +7 -22
  422. package/src/shared/workspace/__tests__/writeback-coordinator.test.ts +20 -61
  423. package/src/shared/workspace/session-provision.ts +3 -3
  424. package/src/shared/workspace/stigmer-link.ts +3 -3
  425. package/src/shared/workspace/writeback-coordinator.ts +16 -64
  426. package/src/tools/index.ts +1 -1
  427. package/dist/activities/execute-cursor/capture-flow.d.ts +0 -142
  428. package/dist/activities/execute-cursor/capture-flow.js +0 -285
  429. package/dist/activities/execute-cursor/capture-flow.js.map +0 -1
  430. package/dist/activities/execute-cursor/command-provenance.d.ts +0 -48
  431. package/dist/activities/execute-cursor/command-provenance.js +0 -38
  432. package/dist/activities/execute-cursor/command-provenance.js.map +0 -1
  433. package/dist/activities/execute-deep-agent/attachment-injector.d.ts +0 -134
  434. package/dist/activities/execute-deep-agent/attachment-injector.js +0 -386
  435. package/dist/activities/execute-deep-agent/attachment-injector.js.map +0 -1
  436. package/dist/activities/execute-deep-agent/command-provenance.d.ts +0 -61
  437. package/dist/activities/execute-deep-agent/command-provenance.js +0 -72
  438. package/dist/activities/execute-deep-agent/command-provenance.js.map +0 -1
  439. package/dist/activities/execute-deep-agent/environment.d.ts +0 -24
  440. package/dist/activities/execute-deep-agent/environment.js +0 -58
  441. package/dist/activities/execute-deep-agent/environment.js.map +0 -1
  442. package/dist/activities/execute-deep-agent/event-recorder.d.ts +0 -21
  443. package/dist/activities/execute-deep-agent/event-recorder.js +0 -67
  444. package/dist/activities/execute-deep-agent/event-recorder.js.map +0 -1
  445. package/dist/activities/execute-deep-agent/index.d.ts +0 -15
  446. package/dist/activities/execute-deep-agent/index.js +0 -918
  447. package/dist/activities/execute-deep-agent/index.js.map +0 -1
  448. package/dist/activities/execute-deep-agent/mcp-gate.d.ts +0 -28
  449. package/dist/activities/execute-deep-agent/mcp-gate.js +0 -22
  450. package/dist/activities/execute-deep-agent/mcp-gate.js.map +0 -1
  451. package/dist/activities/execute-deep-agent/post-stream.d.ts +0 -23
  452. package/dist/activities/execute-deep-agent/post-stream.js +0 -71
  453. package/dist/activities/execute-deep-agent/post-stream.js.map +0 -1
  454. package/dist/activities/execute-deep-agent/setup.d.ts +0 -136
  455. package/dist/activities/execute-deep-agent/setup.js +0 -767
  456. package/dist/activities/execute-deep-agent/setup.js.map +0 -1
  457. package/dist/activities/execute-deep-agent/stamp-flowed-rows.d.ts +0 -36
  458. package/dist/activities/execute-deep-agent/stamp-flowed-rows.js +0 -56
  459. package/dist/activities/execute-deep-agent/stamp-flowed-rows.js.map +0 -1
  460. package/dist/activities/execute-deep-agent/status-builder.d.ts +0 -93
  461. package/dist/activities/execute-deep-agent/status-builder.js +0 -365
  462. package/dist/activities/execute-deep-agent/status-builder.js.map +0 -1
  463. package/dist/activities/execute-deep-agent/streaming-terminal.d.ts +0 -21
  464. package/dist/activities/execute-deep-agent/streaming-terminal.js +0 -80
  465. package/dist/activities/execute-deep-agent/streaming-terminal.js.map +0 -1
  466. package/dist/activities/execute-deep-agent/streaming-v3.d.ts +0 -13
  467. package/dist/activities/execute-deep-agent/streaming-v3.js +0 -174
  468. package/dist/activities/execute-deep-agent/streaming-v3.js.map +0 -1
  469. package/dist/activities/execute-deep-agent/streaming.d.ts +0 -81
  470. package/dist/activities/execute-deep-agent/streaming.js +0 -160
  471. package/dist/activities/execute-deep-agent/streaming.js.map +0 -1
  472. package/dist/middleware/cost-cap.d.ts +0 -22
  473. package/dist/middleware/cost-cap.js.map +0 -1
  474. package/dist/middleware/graceful-stop.d.ts +0 -17
  475. package/dist/middleware/graceful-stop.js +0 -63
  476. package/dist/middleware/graceful-stop.js.map +0 -1
  477. package/dist/shared/skill-writer.d.ts +0 -75
  478. package/dist/shared/skill-writer.js +0 -207
  479. package/dist/shared/skill-writer.js.map +0 -1
  480. package/src/activities/execute-cursor/__tests__/capture-flow.test.ts +0 -1032
  481. package/src/activities/execute-cursor/__tests__/command-provenance.test.ts +0 -240
  482. package/src/activities/execute-cursor/__tests__/progress-substrate.test.ts +0 -169
  483. package/src/activities/execute-cursor/capture-flow.ts +0 -379
  484. package/src/activities/execute-cursor/command-provenance.ts +0 -73
  485. package/src/activities/execute-deep-agent/__tests__/attachment-injector.test.ts +0 -1161
  486. package/src/activities/execute-deep-agent/__tests__/command-provenance.test.ts +0 -252
  487. package/src/activities/execute-deep-agent/__tests__/environment.test.ts +0 -108
  488. package/src/activities/execute-deep-agent/__tests__/event-recorder.test.ts +0 -150
  489. package/src/activities/execute-deep-agent/__tests__/hitl-integration.test.ts +0 -226
  490. package/src/activities/execute-deep-agent/__tests__/hitl-reject.test.ts +0 -318
  491. package/src/activities/execute-deep-agent/__tests__/hitl-resume-approve-all.test.ts +0 -351
  492. package/src/activities/execute-deep-agent/__tests__/hitl-resume-history.test.ts +0 -293
  493. package/src/activities/execute-deep-agent/__tests__/index.test.ts +0 -99
  494. package/src/activities/execute-deep-agent/__tests__/mcp-gate.test.ts +0 -44
  495. package/src/activities/execute-deep-agent/__tests__/post-stream.test.ts +0 -112
  496. package/src/activities/execute-deep-agent/__tests__/sequential-gate-resume.test.ts +0 -358
  497. package/src/activities/execute-deep-agent/__tests__/status-builder.test.ts +0 -1933
  498. package/src/activities/execute-deep-agent/__tests__/streaming-terminal.test.ts +0 -40
  499. package/src/activities/execute-deep-agent/__tests__/streaming-v3.test.ts +0 -597
  500. package/src/activities/execute-deep-agent/__tests__/streaming.test.ts +0 -508
  501. package/src/activities/execute-deep-agent/attachment-injector.ts +0 -627
  502. package/src/activities/execute-deep-agent/command-provenance.ts +0 -102
  503. package/src/activities/execute-deep-agent/environment.ts +0 -76
  504. package/src/activities/execute-deep-agent/event-recorder.ts +0 -95
  505. package/src/activities/execute-deep-agent/index.ts +0 -1072
  506. package/src/activities/execute-deep-agent/mcp-gate.ts +0 -37
  507. package/src/activities/execute-deep-agent/post-stream.ts +0 -109
  508. package/src/activities/execute-deep-agent/setup.ts +0 -1081
  509. package/src/activities/execute-deep-agent/stamp-flowed-rows.ts +0 -64
  510. package/src/activities/execute-deep-agent/status-builder.ts +0 -481
  511. package/src/activities/execute-deep-agent/streaming-terminal.ts +0 -106
  512. package/src/activities/execute-deep-agent/streaming-v3.ts +0 -277
  513. package/src/activities/execute-deep-agent/streaming.ts +0 -313
  514. package/src/middleware/__tests__/cost-cap.test.ts +0 -192
  515. package/src/middleware/__tests__/graceful-stop.test.ts +0 -105
  516. package/src/middleware/graceful-stop.ts +0 -86
  517. package/src/shared/__tests__/skill-writer.test.ts +0 -372
  518. package/src/shared/skill-writer.ts +0 -266
@@ -0,0 +1,163 @@
1
+ /**
2
+ * The prompt glue both harnesses share: WHICH sections, in WHAT order, with
3
+ * WHICH lines — never the framing, never the placement.
4
+ *
5
+ * The doctrine is `plan-mode-prompt.ts`'s: "the framing is house style; the
6
+ * words are shared." Every section BODY already has one home
7
+ * (`sender-identity.ts`, `declared-preferences.ts`, `recalled-memories.ts`,
8
+ * `session-context.ts`, `context-bridge.ts`, `attachment-vision.ts`,
9
+ * `attachment-download-urls.ts`). What the two prompt builders duplicated
10
+ * until S3 M5 (Q-S3-10, Q-M2b-8) was the glue around those bodies: the order
11
+ * the five standing sections read in, with the same doctrine comments written
12
+ * twice; the input-files bullet and disclosure lines; which skills a prompt
13
+ * highlights when there are many. This module is that glue, written once.
14
+ *
15
+ * What stays with each harness, on purpose:
16
+ * - Framing and placement. The native harness renders `## Heading` sections
17
+ * into a system prompt rebuilt on every turn; the Cursor harness renders
18
+ * `<xml_tag>` sections into the FIRST user message of a session
19
+ * (`capabilities.systemPrompt` is the declared reason). Each builder maps a
20
+ * section `kind` to its own label (`Record<StandingSectionKind, string>`,
21
+ * exhaustive by the compiler) and wraps the body itself. This module never
22
+ * learns a heading or a tag.
23
+ * - Words that quote an engine's tools: the native `## Skills` activation
24
+ * protocol (`read`, `execute(...)`) and Cursor's `<available_skills>` line
25
+ * (`the Read tool`); the response rules; the sub-agent rules; the
26
+ * structured-output directives (two mechanisms, two texts); Cursor's
27
+ * tool-approval protocol, which exists because of Cursor's gate model and
28
+ * would be false on a harness that interrupts before a tool runs.
29
+ *
30
+ * Fences: nothing under `shared/` imports `harness/` (and
31
+ * `harness/__tests__/import-direction.test.ts` forbids `shared/` reaching
32
+ * `activities/`), so every function here takes a plain struct that both
33
+ * builders' option objects satisfy structurally — never `TurnInput`. Pure:
34
+ * no I/O, no logging (a builder that wants to log what the selection did
35
+ * does so at its own call site).
36
+ */
37
+ import type { ResolvedAttachment } from "./attachment-resolver.js";
38
+ import { type NotViewableEntry } from "./attachment-vision.js";
39
+ import { type DownloadUrlKind } from "./attachment-download-urls.js";
40
+ import { type DeclaredPreferencesContent } from "./declared-preferences.js";
41
+ import { type RecalledMemoriesContent } from "./recalled-memories.js";
42
+ import { type SenderIdentity } from "./sender-identity.js";
43
+ import type { SkillMetadata } from "./skill-resolver.js";
44
+ /**
45
+ * The standing sections a prompt may carry, in the order they read. A builder
46
+ * labels each kind in its own vocabulary; adding a kind here fails every
47
+ * builder's label map until it names the new section — the point of a closed
48
+ * union over a bag of optional fields.
49
+ */
50
+ export type StandingSectionKind = "conversation-sender" | "declared-preferences" | "recalled-memories" | "session-context" | "previous-conversation";
51
+ export interface StandingSection {
52
+ readonly kind: StandingSectionKind;
53
+ /** The section's words, from the body's own module; the builder frames them. */
54
+ readonly body: string;
55
+ }
56
+ /**
57
+ * The standing facts as both builders already hold them (their option
58
+ * objects satisfy this structurally). Every field optional: an absent value
59
+ * renders no section, so a runner predating a fact simply says nothing.
60
+ */
61
+ export interface StandingPromptContext {
62
+ readonly senderIdentity?: SenderIdentity;
63
+ readonly declaredPreferences?: DeclaredPreferencesContent;
64
+ readonly recalledMemories?: RecalledMemoriesContent;
65
+ readonly sessionContext?: string;
66
+ readonly contextBridge?: string;
67
+ }
68
+ /**
69
+ * The present standing sections in the one ruled order. The order is the
70
+ * doctrine, stated once:
71
+ *
72
+ * 1. The conversation sender first: standing context about WHO the
73
+ * conversation is with, which everything after may refer back to.
74
+ * 2. Platform-declared standing facts precede embedder-supplied context
75
+ * (DD-002 D3): both are standing background, but the declared preferences
76
+ * are platform-authored while session context is the embedder's overlay —
77
+ * the more specific overlay reads later and naturally refines.
78
+ * 3. Declared-by-humans precedes learned-and-confirmed (DD-006 D4): both are
79
+ * platform-authored standing background, but a preference is the user's
80
+ * exact words while a memory is an agent's confirmed inference — the exact
81
+ * statement reads first.
82
+ * 4. Standing facts about the user (session context) come before the carried
83
+ * conversation (bridge): the bridge may refer back to them.
84
+ *
85
+ * Where the block sits in a prompt, and on which turns, is the builder's
86
+ * (native: every turn, the system prompt is rebuilt; Cursor: the session's
87
+ * first message, the agent's own store carries it after).
88
+ */
89
+ export declare function standingContextSections(standing: StandingPromptContext): readonly StandingSection[];
90
+ /**
91
+ * Which images ride the user message inline (in send order) and which
92
+ * degraded to the file-pointer story — the vision facts a prompt discloses
93
+ * beside its input files (`attachment-vision.ts` owns the wording). Derived
94
+ * per turn from the resolved attachments; never carried across turns.
95
+ */
96
+ export interface VisionPromptInfo {
97
+ readonly inlineFilenames: readonly string[];
98
+ readonly notViewable: readonly NotViewableEntry[];
99
+ }
100
+ /**
101
+ * The vision facts as the runtime's attachment phase resolves them (the
102
+ * `TurnInput.attachments` shape, structurally): the inline images in send
103
+ * order and the ones that degraded. `undefined` when the turn has neither, so
104
+ * the section renders no vision lines at all rather than an empty disclosure.
105
+ */
106
+ export declare function visionPromptInfoOf(attachments: {
107
+ readonly visionImages: readonly {
108
+ readonly filename: string;
109
+ }[];
110
+ readonly visionNotViewable: readonly NotViewableEntry[];
111
+ }): VisionPromptInfo | undefined;
112
+ /** The input-files section's lines; the builder supplies the intro and the frame. */
113
+ export interface InputFileLines {
114
+ /** One bullet per file: path, size, the rename disclosure, the download URL. */
115
+ readonly entries: readonly string[];
116
+ /** The URL hand-off line, present only when some listed file carries a URL. */
117
+ readonly urlHandoff: string | undefined;
118
+ /** The vision disclosure lines; empty when the turn carries no vision facts. */
119
+ readonly vision: readonly string[];
120
+ }
121
+ /**
122
+ * The input-files lines over the runtime's own `ResolvedAttachment` — one
123
+ * type, one truth (a structural twin once lived in each builder; native's
124
+ * silently dropped the size, Cursor's was deleted at S3 M5, Q-M5-5).
125
+ *
126
+ * Each bullet discloses the size (so the agent can weigh a read — the field's
127
+ * own stated purpose; Cursor's line gained it at S3 M5, Q-M5-3), the original
128
+ * name of a duplicate-renamed file (`attachment-naming.ts`; so the agent can
129
+ * connect "the two report.pdfs" in the user's message to distinct files on
130
+ * disk), and the download URL when one was minted
131
+ * (`attachment-download-urls.ts`; for the remote hand-off story). The URL
132
+ * hand-off line renders only when some listed file actually carries a URL —
133
+ * its wording keys on what kind of URL the storage backend mints. The vision
134
+ * lines tell the model which of these files it can already SEE inline versus
135
+ * which degraded to path-only; without them an agent silently ignores a photo
136
+ * the user believes it can see.
137
+ */
138
+ export declare function inputFileLines(files: readonly ResolvedAttachment[], vision: VisionPromptInfo | undefined, downloadUrlKind: DownloadUrlKind | undefined): InputFileLines;
139
+ /** Which mounted skills a prompt highlights, and which it only names. */
140
+ export interface SkillSelection {
141
+ /** The skills the prompt describes in full, in the filter's order. */
142
+ readonly highlighted: readonly SkillMetadata[];
143
+ /** The names of the skills left out of the highlighted set; empty below the threshold. */
144
+ readonly alsoAvailable: readonly string[];
145
+ }
146
+ /**
147
+ * The relevance selection over the turn's message (`skill-relevance.ts`):
148
+ * below `SKILL_COUNT_THRESHOLD` every skill is highlighted; at and above it,
149
+ * the skills the message's terms reach are highlighted and the rest are
150
+ * named, so the agent can still activate one on its own judgement (the Agent
151
+ * Skills spec's progressive disclosure: metadata up front, instructions on
152
+ * demand). The native harness calls this on every turn; the Cursor harness
153
+ * lists every skill today and its adoption is S4's (Q-M5-4).
154
+ */
155
+ export declare function selectSkillsForPrompt(userMessage: string, skills: readonly SkillMetadata[]): SkillSelection;
156
+ /**
157
+ * The tool-neutral sentence that names the skills a prompt did not highlight
158
+ * (`SkillSelection.alsoAvailable`), so the agent can activate one by reading
159
+ * its SKILL.md at the mounted path. The sentence names no tool, so it serves
160
+ * any harness; the heading above it is the builder's framing. Empty for no
161
+ * names.
162
+ */
163
+ export declare function alsoAvailableSkillsNote(excludedNames: readonly string[]): string;
@@ -0,0 +1,164 @@
1
+ /**
2
+ * The prompt glue both harnesses share: WHICH sections, in WHAT order, with
3
+ * WHICH lines — never the framing, never the placement.
4
+ *
5
+ * The doctrine is `plan-mode-prompt.ts`'s: "the framing is house style; the
6
+ * words are shared." Every section BODY already has one home
7
+ * (`sender-identity.ts`, `declared-preferences.ts`, `recalled-memories.ts`,
8
+ * `session-context.ts`, `context-bridge.ts`, `attachment-vision.ts`,
9
+ * `attachment-download-urls.ts`). What the two prompt builders duplicated
10
+ * until S3 M5 (Q-S3-10, Q-M2b-8) was the glue around those bodies: the order
11
+ * the five standing sections read in, with the same doctrine comments written
12
+ * twice; the input-files bullet and disclosure lines; which skills a prompt
13
+ * highlights when there are many. This module is that glue, written once.
14
+ *
15
+ * What stays with each harness, on purpose:
16
+ * - Framing and placement. The native harness renders `## Heading` sections
17
+ * into a system prompt rebuilt on every turn; the Cursor harness renders
18
+ * `<xml_tag>` sections into the FIRST user message of a session
19
+ * (`capabilities.systemPrompt` is the declared reason). Each builder maps a
20
+ * section `kind` to its own label (`Record<StandingSectionKind, string>`,
21
+ * exhaustive by the compiler) and wraps the body itself. This module never
22
+ * learns a heading or a tag.
23
+ * - Words that quote an engine's tools: the native `## Skills` activation
24
+ * protocol (`read`, `execute(...)`) and Cursor's `<available_skills>` line
25
+ * (`the Read tool`); the response rules; the sub-agent rules; the
26
+ * structured-output directives (two mechanisms, two texts); Cursor's
27
+ * tool-approval protocol, which exists because of Cursor's gate model and
28
+ * would be false on a harness that interrupts before a tool runs.
29
+ *
30
+ * Fences: nothing under `shared/` imports `harness/` (and
31
+ * `harness/__tests__/import-direction.test.ts` forbids `shared/` reaching
32
+ * `activities/`), so every function here takes a plain struct that both
33
+ * builders' option objects satisfy structurally — never `TurnInput`. Pure:
34
+ * no I/O, no logging (a builder that wants to log what the selection did
35
+ * does so at its own call site).
36
+ */
37
+ import { visionDisclosureLines } from "./attachment-vision.js";
38
+ import { downloadUrlDisclosureLine } from "./attachment-download-urls.js";
39
+ import { formatContextBridgeText } from "./context-bridge.js";
40
+ import { formatDeclaredPreferencesText } from "./declared-preferences.js";
41
+ import { formatRecalledMemoriesText } from "./recalled-memories.js";
42
+ import { formatSenderIdentityText } from "./sender-identity.js";
43
+ import { formatSessionContextText } from "./session-context.js";
44
+ import { filterSkills } from "./skill-relevance.js";
45
+ import { STIGMER_LOCAL_STATE_DIR } from "./workspace/stigmer-link.js";
46
+ /**
47
+ * The present standing sections in the one ruled order. The order is the
48
+ * doctrine, stated once:
49
+ *
50
+ * 1. The conversation sender first: standing context about WHO the
51
+ * conversation is with, which everything after may refer back to.
52
+ * 2. Platform-declared standing facts precede embedder-supplied context
53
+ * (DD-002 D3): both are standing background, but the declared preferences
54
+ * are platform-authored while session context is the embedder's overlay —
55
+ * the more specific overlay reads later and naturally refines.
56
+ * 3. Declared-by-humans precedes learned-and-confirmed (DD-006 D4): both are
57
+ * platform-authored standing background, but a preference is the user's
58
+ * exact words while a memory is an agent's confirmed inference — the exact
59
+ * statement reads first.
60
+ * 4. Standing facts about the user (session context) come before the carried
61
+ * conversation (bridge): the bridge may refer back to them.
62
+ *
63
+ * Where the block sits in a prompt, and on which turns, is the builder's
64
+ * (native: every turn, the system prompt is rebuilt; Cursor: the session's
65
+ * first message, the agent's own store carries it after).
66
+ */
67
+ export function standingContextSections(standing) {
68
+ const sections = [];
69
+ if (standing.senderIdentity) {
70
+ sections.push({ kind: "conversation-sender", body: formatSenderIdentityText(standing.senderIdentity) });
71
+ }
72
+ if (standing.declaredPreferences) {
73
+ sections.push({ kind: "declared-preferences", body: formatDeclaredPreferencesText(standing.declaredPreferences) });
74
+ }
75
+ if (standing.recalledMemories) {
76
+ sections.push({ kind: "recalled-memories", body: formatRecalledMemoriesText(standing.recalledMemories) });
77
+ }
78
+ if (standing.sessionContext) {
79
+ sections.push({ kind: "session-context", body: formatSessionContextText(standing.sessionContext) });
80
+ }
81
+ if (standing.contextBridge) {
82
+ sections.push({ kind: "previous-conversation", body: formatContextBridgeText(standing.contextBridge) });
83
+ }
84
+ return sections;
85
+ }
86
+ /**
87
+ * The vision facts as the runtime's attachment phase resolves them (the
88
+ * `TurnInput.attachments` shape, structurally): the inline images in send
89
+ * order and the ones that degraded. `undefined` when the turn has neither, so
90
+ * the section renders no vision lines at all rather than an empty disclosure.
91
+ */
92
+ export function visionPromptInfoOf(attachments) {
93
+ if (attachments.visionImages.length === 0 && attachments.visionNotViewable.length === 0)
94
+ return undefined;
95
+ return {
96
+ inlineFilenames: attachments.visionImages.map((v) => v.filename),
97
+ notViewable: attachments.visionNotViewable,
98
+ };
99
+ }
100
+ /**
101
+ * The input-files lines over the runtime's own `ResolvedAttachment` — one
102
+ * type, one truth (a structural twin once lived in each builder; native's
103
+ * silently dropped the size, Cursor's was deleted at S3 M5, Q-M5-5).
104
+ *
105
+ * Each bullet discloses the size (so the agent can weigh a read — the field's
106
+ * own stated purpose; Cursor's line gained it at S3 M5, Q-M5-3), the original
107
+ * name of a duplicate-renamed file (`attachment-naming.ts`; so the agent can
108
+ * connect "the two report.pdfs" in the user's message to distinct files on
109
+ * disk), and the download URL when one was minted
110
+ * (`attachment-download-urls.ts`; for the remote hand-off story). The URL
111
+ * hand-off line renders only when some listed file actually carries a URL —
112
+ * its wording keys on what kind of URL the storage backend mints. The vision
113
+ * lines tell the model which of these files it can already SEE inline versus
114
+ * which degraded to path-only; without them an agent silently ignores a photo
115
+ * the user believes it can see.
116
+ */
117
+ export function inputFileLines(files, vision, downloadUrlKind) {
118
+ const entries = files.map((f) => {
119
+ const size = ` (${f.sizeBytes} bytes)`;
120
+ const rename = f.renamedFrom !== undefined ? ` (renamed from duplicate '${f.renamedFrom}')` : "";
121
+ const url = f.downloadUrl !== undefined ? ` — download URL: ${f.downloadUrl}` : "";
122
+ return `- \`${f.relativePath}\`${size}${rename}${url}`;
123
+ });
124
+ const urlHandoff = downloadUrlKind !== undefined && files.some((f) => f.downloadUrl !== undefined)
125
+ ? downloadUrlDisclosureLine(downloadUrlKind)
126
+ : undefined;
127
+ return {
128
+ entries,
129
+ urlHandoff,
130
+ vision: vision ? visionDisclosureLines(vision.inlineFilenames, vision.notViewable) : [],
131
+ };
132
+ }
133
+ /**
134
+ * The relevance selection over the turn's message (`skill-relevance.ts`):
135
+ * below `SKILL_COUNT_THRESHOLD` every skill is highlighted; at and above it,
136
+ * the skills the message's terms reach are highlighted and the rest are
137
+ * named, so the agent can still activate one on its own judgement (the Agent
138
+ * Skills spec's progressive disclosure: metadata up front, instructions on
139
+ * demand). The native harness calls this on every turn; the Cursor harness
140
+ * lists every skill today and its adoption is S4's (Q-M5-4).
141
+ */
142
+ export function selectSkillsForPrompt(userMessage, skills) {
143
+ const filter = filterSkills(userMessage, skills.map((s) => s.name), skills.map((s) => s.description));
144
+ return {
145
+ highlighted: filter.includedIndices.map((i) => skills[i]),
146
+ alsoAvailable: filter.excludedNames,
147
+ };
148
+ }
149
+ /**
150
+ * The tool-neutral sentence that names the skills a prompt did not highlight
151
+ * (`SkillSelection.alsoAvailable`), so the agent can activate one by reading
152
+ * its SKILL.md at the mounted path. The sentence names no tool, so it serves
153
+ * any harness; the heading above it is the builder's framing. Empty for no
154
+ * names.
155
+ */
156
+ export function alsoAvailableSkillsNote(excludedNames) {
157
+ if (excludedNames.length === 0)
158
+ return "";
159
+ const names = excludedNames.map((n) => `\`${n}\``).join(", ");
160
+ return (`These skills are installed but were not highlighted above: ${names}. ` +
161
+ "If you determine one of them is relevant to your task, " +
162
+ `read its SKILL.md at \`${STIGMER_LOCAL_STATE_DIR}/skills/<name>/SKILL.md\` to activate it.`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,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IAC1C,MAAM,KAAK,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC9D,OAAO,CACL,8DAA8D,KAAK,IAAI;QACvE,yDAAyD;QACzD,0BAA0B,uBAAuB,2CAA2C,CAC7F,CAAC;AACJ,CAAC"}
@@ -13,8 +13,10 @@
13
13
  * platform dir the runtime owns; the harness renders the returned metadata
14
14
  * into its prompt in its own placement. Moved from
15
15
  * `activities/execute-cursor/` at S2 M3b; the native harness's twin
16
- * (`skill-writer.ts` `fetchSkillsByRefs` + `mountSkills`) is what S3
17
- * reconciles it with.
16
+ * (`skill-writer.ts` `fetchSkillsByRefs` + `mountSkills`) retired at S3 M2b,
17
+ * and the module itself at S3 M5 — the one renderer it kept is
18
+ * `shared/prompt-sections.ts` `alsoAvailableSkillsNote`. This is the one
19
+ * skills path for every harness.
18
20
  *
19
21
  * The mount is cached by the skill's content-addressed version hash
20
22
  * (stigmer/stigmer#672): metadata is fetched on every execution (that keeps
@@ -13,8 +13,10 @@
13
13
  * platform dir the runtime owns; the harness renders the returned metadata
14
14
  * into its prompt in its own placement. Moved from
15
15
  * `activities/execute-cursor/` at S2 M3b; the native harness's twin
16
- * (`skill-writer.ts` `fetchSkillsByRefs` + `mountSkills`) is what S3
17
- * reconciles it with.
16
+ * (`skill-writer.ts` `fetchSkillsByRefs` + `mountSkills`) retired at S3 M2b,
17
+ * and the module itself at S3 M5 — the one renderer it kept is
18
+ * `shared/prompt-sections.ts` `alsoAvailableSkillsNote`. This is the one
19
+ * skills path for every harness.
18
20
  *
19
21
  * The mount is cached by the skill's content-addressed version hash
20
22
  * (stigmer/stigmer#672): metadata is fetched on every execution (that keeps
@@ -1 +1 @@
1
- {"version":3,"file":"skill-resolver.js","sourceRoot":"","sources":["../../src/shared/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ExecutionBudgetMiddleware's wrap-up advisory, so the
15
15
  * "~80% of budget" warning and the enforcement point can never disagree.
16
+ *
17
+ * The knob and its terminal copy live together (the `cost-guard.ts` shape):
18
+ * when the budget is exhausted the adapter ends its turn `tool_call_limit`
19
+ * and the runtime's `toolCallLimitArm` writes TERMINATED with the copy
20
+ * below — the platform deliberately stopped the run, work is checkpointed,
21
+ * and the conversation continues on the next message.
16
22
  */
17
23
  export declare const SUPER_STEPS_PER_ROUND = 6;
18
24
  export declare const MIN_TOOL_ROUNDS = 10;
@@ -28,3 +34,29 @@ export declare const UNBOUNDED_ADVISORY_RECURSION_LIMIT = 6000;
28
34
  * unbounded (max_tool_rounds 0/unset — the pre-existing default posture).
29
35
  */
30
36
  export declare function resolveRecursionLimit(maxToolRounds: number | undefined): number | null;
37
+ /**
38
+ * Stable prefix of the tool-call-limit terminal error. This is a cross-repo
39
+ * contract: consumers that need to distinguish "ran out of tool-call budget"
40
+ * from other TERMINATED causes (Stigmer Cloud's channel reply extractor,
41
+ * which shows channel users a friendly limit message instead of generic
42
+ * error copy) match on this prefix with `startsWith`, because
43
+ * AgentExecutionStatus carries no structured termination reason. Do not
44
+ * reword without updating them. `COST_LIMIT_ERROR_PREFIX` (`cost-guard.ts`)
45
+ * mirrors it.
46
+ */
47
+ export declare const TOOL_CALL_LIMIT_ERROR_PREFIX = "Agent reached the tool-call limit";
48
+ /** The terminal `status.error` for a tool-call-limit stop; the prefix is the contract, the rest is prose. */
49
+ export declare function formatToolCallLimitError(): string;
50
+ /**
51
+ * User-facing system message for a tool-call-limit stop. Honest about the
52
+ * limit, clear that nothing is lost; the cost-cap copy is its parallel.
53
+ */
54
+ export declare const TOOL_CALL_LIMIT_USER_COPY: string;
55
+ /**
56
+ * Whether an error thrown out of a LangGraph run is the graph exhausting the
57
+ * recursion limit `resolveRecursionLimit` placed on it — the budget's own
58
+ * signal, not a failure: the adapter ends the turn `tool_call_limit`.
59
+ * Matched by class name and message because the error class is not
60
+ * exported on a stable path across `@langchain/langgraph` versions.
61
+ */
62
+ export declare function isGraphRecursionError(err: unknown): boolean;
@@ -13,6 +13,12 @@
13
13
  * The SAME resolved limit must feed both LangGraph's hard stop (the invoke
14
14
  * config) and the ExecutionBudgetMiddleware's wrap-up advisory, so the
15
15
  * "~80% of budget" warning and the enforcement point can never disagree.
16
+ *
17
+ * The knob and its terminal copy live together (the `cost-guard.ts` shape):
18
+ * when the budget is exhausted the adapter ends its turn `tool_call_limit`
19
+ * and the runtime's `toolCallLimitArm` writes TERMINATED with the copy
20
+ * below — the platform deliberately stopped the run, work is checkpointed,
21
+ * and the conversation continues on the next message.
16
22
  */
17
23
  export const SUPER_STEPS_PER_ROUND = 6;
18
24
  export const MIN_TOOL_ROUNDS = 10;
@@ -46,4 +52,41 @@ function clampToolRounds(requested) {
46
52
  }
47
53
  return requested;
48
54
  }
55
+ /**
56
+ * Stable prefix of the tool-call-limit terminal error. This is a cross-repo
57
+ * contract: consumers that need to distinguish "ran out of tool-call budget"
58
+ * from other TERMINATED causes (Stigmer Cloud's channel reply extractor,
59
+ * which shows channel users a friendly limit message instead of generic
60
+ * error copy) match on this prefix with `startsWith`, because
61
+ * AgentExecutionStatus carries no structured termination reason. Do not
62
+ * reword without updating them. `COST_LIMIT_ERROR_PREFIX` (`cost-guard.ts`)
63
+ * mirrors it.
64
+ */
65
+ export const TOOL_CALL_LIMIT_ERROR_PREFIX = "Agent reached the tool-call limit";
66
+ /** The terminal `status.error` for a tool-call-limit stop; the prefix is the contract, the rest is prose. */
67
+ export function formatToolCallLimitError() {
68
+ return `${TOOL_CALL_LIMIT_ERROR_PREFIX} for this message. Send another message to continue.`;
69
+ }
70
+ /**
71
+ * User-facing system message for a tool-call-limit stop. Honest about the
72
+ * limit, clear that nothing is lost; the cost-cap copy is its parallel.
73
+ */
74
+ export const TOOL_CALL_LIMIT_USER_COPY = "The agent reached the tool-call limit for this message. " +
75
+ "Work completed so far has been saved. " +
76
+ "Send another message to continue where the agent left off.";
77
+ /**
78
+ * Whether an error thrown out of a LangGraph run is the graph exhausting the
79
+ * recursion limit `resolveRecursionLimit` placed on it — the budget's own
80
+ * signal, not a failure: the adapter ends the turn `tool_call_limit`.
81
+ * Matched by class name and message because the error class is not
82
+ * exported on a stable path across `@langchain/langgraph` versions.
83
+ */
84
+ export function isGraphRecursionError(err) {
85
+ if (err instanceof Error) {
86
+ return err.constructor.name === "GraphRecursionError" ||
87
+ err.message.includes("GraphRecursionError") ||
88
+ err.message.includes("Recursion limit");
89
+ }
90
+ return false;
91
+ }
49
92
  //# sourceMappingURL=tool-rounds.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"tool-rounds.js","sourceRoot":"","sources":["../../src/shared/tool-rounds.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC;AACvC,MAAM,CAAC,MAAM,eAAe,GAAG,EAAE,CAAC;AAClC,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,CAAC;AAEpC;;;;GAIG;AACH,MAAM,CAAC,MAAM,kCAAkC,GAAG,IAAI,CAAC;AAEvD;;;GAGG;AACH,MAAM,UAAU,qBAAqB,CAAC,aAAiC;IACrE,IAAI,CAAC,aAAa,IAAI,aAAa,IAAI,CAAC,EAAE,CAAC;QACzC,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,eAAe,CAAC,aAAa,CAAC,GAAG,qBAAqB,CAAC;AAChE,CAAC;AAED,SAAS,eAAe,CAAC,SAAiB;IACxC,IAAI,SAAS,GAAG,eAAe,EAAE,CAAC;QAChC,OAAO,CAAC,IAAI,CACV,iCAAiC,SAAS,yBAAyB;YACnE,IAAI,eAAe,IAAI,eAAe,kBAAkB,eAAe,EAAE,CAC1E,CAAC;QACF,OAAO,eAAe,CAAC;IACzB,CAAC;IACD,IAAI,SAAS,GAAG,eAAe,EAAE,CAAC;QAChC,OAAO,CAAC,IAAI,CACV,iCAAiC,SAAS,yBAAyB;YAC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,wBAAwB;IACtC,OAAO,GAAG,4BAA4B,sDAAsD,CAAC;AAC/F,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,yBAAyB,GACpC,0DAA0D;IAC1D,wCAAwC;IACxC,4DAA4D,CAAC;AAE/D;;;;;;GAMG;AACH,MAAM,UAAU,qBAAqB,CAAC,GAAY;IAChD,IAAI,GAAG,YAAY,KAAK,EAAE,CAAC;QACzB,OAAO,GAAG,CAAC,WAAW,CAAC,IAAI,KAAK,qBAAqB;YACnD,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,qBAAqB,CAAC;YAC3C,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAC,CAAC;IAC5C,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -43,6 +43,40 @@ import type { SubAgentExecution } from "@stigmer/protos/ai/stigmer/agentic/agent
43
43
  * path cannot be determined is stripped rather than trusted.
44
44
  */
45
45
  export declare function stampFileEditRow(tc: ToolCall, changeSetId: string): void;
46
+ /**
47
+ * The turn-boundary pass over a transcript: stamp every file-edit row
48
+ * (category write/delete) that FLOWED this turn with the change set id, so
49
+ * the row stays visible in place as an observational record while
50
+ * `file_change_sets` remains the single decision surface (DD-24). Skips:
51
+ *
52
+ * - already-stamped rows — the idempotency AND cross-turn guard: a resume
53
+ * seeds prior turns' rows into this transcript, and re-stamping them with
54
+ * this turn's id would mis-attribute them ({@link stampFileEditRow});
55
+ * - legacy hidden rows (sessions persisted before stamping existed) — they
56
+ * belong to an earlier turn's set;
57
+ * - ids in `skipToolCallIds` — the sub-agent callers' pre-turn snapshot
58
+ * ({@link collectSubAgentToolCallIds}), since sub-agent rows have neither
59
+ * of the two shields above; top-level callers omit it;
60
+ * - rows `flowed` refuses — the caller's evidence that a row did NOT flow
61
+ * (the Cursor deny-gate's ledger tokens; a status rule). Omit to stamp
62
+ * every write/delete row, the deep-agent posture where every such row flowed.
63
+ *
64
+ * One pass for every harness (S3 M4; until then each adapter carried a copy
65
+ * differing only in the `flowed` predicate).
66
+ */
67
+ export declare function stampFlowedFileEditRows(messages: readonly AgentMessage[], changeSetId: string, opts?: {
68
+ readonly skipToolCallIds?: ReadonlySet<string>;
69
+ readonly flowed?: (tc: ToolCall) => boolean;
70
+ }): void;
71
+ /**
72
+ * The same pass over the turn's sub-agent transcripts. Sub-agent writes fold
73
+ * their files into the SAME parent turn set (shared git diff + one shared CAS
74
+ * observation, DD-19), so they carry the parent change set id and badge
75
+ * against the same set the parent's rows do. Scoped to this turn by
76
+ * `priorToolCallIds` (the sub-agent tool-call ids that existed before the
77
+ * turn's stream), because sub-agent rows lack the top-level pass's shields.
78
+ */
79
+ export declare function stampFlowedSubAgentFileEditRows(subAgents: readonly SubAgentExecution[], changeSetId: string, priorToolCallIds: ReadonlySet<string>, flowed?: (tc: ToolCall) => boolean): void;
46
80
  /**
47
81
  * Withhold a file-mutating row's CONTENT while keeping its path visible: reduce
48
82
  * `args` to `{ path }` (or `undefined` when the path cannot be determined) and
@@ -57,6 +57,58 @@ export function stampFileEditRow(tc, changeSetId) {
57
57
  tc.result = "";
58
58
  }
59
59
  }
60
+ /**
61
+ * The turn-boundary pass over a transcript: stamp every file-edit row
62
+ * (category write/delete) that FLOWED this turn with the change set id, so
63
+ * the row stays visible in place as an observational record while
64
+ * `file_change_sets` remains the single decision surface (DD-24). Skips:
65
+ *
66
+ * - already-stamped rows — the idempotency AND cross-turn guard: a resume
67
+ * seeds prior turns' rows into this transcript, and re-stamping them with
68
+ * this turn's id would mis-attribute them ({@link stampFileEditRow});
69
+ * - legacy hidden rows (sessions persisted before stamping existed) — they
70
+ * belong to an earlier turn's set;
71
+ * - ids in `skipToolCallIds` — the sub-agent callers' pre-turn snapshot
72
+ * ({@link collectSubAgentToolCallIds}), since sub-agent rows have neither
73
+ * of the two shields above; top-level callers omit it;
74
+ * - rows `flowed` refuses — the caller's evidence that a row did NOT flow
75
+ * (the Cursor deny-gate's ledger tokens; a status rule). Omit to stamp
76
+ * every write/delete row, the deep-agent posture where every such row flowed.
77
+ *
78
+ * One pass for every harness (S3 M4; until then each adapter carried a copy
79
+ * differing only in the `flowed` predicate).
80
+ */
81
+ export function stampFlowedFileEditRows(messages, changeSetId, opts = {}) {
82
+ for (const msg of messages) {
83
+ for (const tc of msg.toolCalls) {
84
+ if (tc.fileChangeSetId)
85
+ continue;
86
+ if (opts.skipToolCallIds?.has(tc.id))
87
+ continue;
88
+ if (isToolCallRowHidden(tc))
89
+ continue;
90
+ const category = toolApprovalCategory(tc.name);
91
+ if (category !== "write" && category !== "delete")
92
+ continue;
93
+ if (opts.flowed && !opts.flowed(tc))
94
+ continue;
95
+ stampFileEditRow(tc, changeSetId);
96
+ }
97
+ }
98
+ }
99
+ /**
100
+ * The same pass over the turn's sub-agent transcripts. Sub-agent writes fold
101
+ * their files into the SAME parent turn set (shared git diff + one shared CAS
102
+ * observation, DD-19), so they carry the parent change set id and badge
103
+ * against the same set the parent's rows do. Scoped to this turn by
104
+ * `priorToolCallIds` (the sub-agent tool-call ids that existed before the
105
+ * turn's stream), because sub-agent rows lack the top-level pass's shields.
106
+ */
107
+ export function stampFlowedSubAgentFileEditRows(subAgents, changeSetId, priorToolCallIds, flowed) {
108
+ for (const sa of subAgents) {
109
+ stampFlowedFileEditRows(sa.messages, changeSetId, { skipToolCallIds: priorToolCallIds, flowed });
110
+ }
111
+ }
60
112
  /**
61
113
  * Withhold a file-mutating row's CONTENT while keeping its path visible: reduce
62
114
  * `args` to `{ path }` (or `undefined` when the path cannot be determined) and
@@ -1 +1 @@
1
- {"version":3,"file":"tool-row.js","sourceRoot":"","sources":["../../src/shared/tool-row.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,8DAA8D,CAAC;AAG9F,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAA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M,CAAC;gBAAE,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;QACjE,CAAC;IACH,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -1,9 +1,9 @@
1
1
  /**
2
2
  * Local workspace provisioning for a harness turn.
3
3
  *
4
- * Harness-agnostic: the Cursor activity is today's only caller, the turn
5
- * runtime takes it over in S2 M3, and S3 retires the native twin
6
- * (execute-deep-agent/setup.ts `provisionWorkspace`). Agents run LOCAL
4
+ * Harness-agnostic: the turn runtime's workspace phase, serving both
5
+ * adapters (the native orchestrator's twin, `provisionWorkspace`, retired
6
+ * with it at S3 M2b; Q-S3-8 carried its one difference). Agents run LOCAL
7
7
  * (cloud is disabled — see execute-cursor/cursor-mode.ts), so the runner
8
8
  * must clone git-repo workspace entries itself and mount local-path entries
9
9
  * before the agent runs. Cloud agents previously cloned git repos
@@ -1,9 +1,9 @@
1
1
  /**
2
2
  * Local workspace provisioning for a harness turn.
3
3
  *
4
- * Harness-agnostic: the Cursor activity is today's only caller, the turn
5
- * runtime takes it over in S2 M3, and S3 retires the native twin
6
- * (execute-deep-agent/setup.ts `provisionWorkspace`). Agents run LOCAL
4
+ * Harness-agnostic: the turn runtime's workspace phase, serving both
5
+ * adapters (the native orchestrator's twin, `provisionWorkspace`, retired
6
+ * with it at S3 M2b; Q-S3-8 carried its one difference). Agents run LOCAL
7
7
  * (cloud is disabled — see execute-cursor/cursor-mode.ts), so the runner
8
8
  * must clone git-repo workspace entries itself and mount local-path entries
9
9
  * before the agent runs. Cloud agents previously cloned git repos