agentfootprint 14.7.3 → 14.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (286) hide show
  1. package/AGENTS.md +1 -1
  2. package/CAPABILITIES.md +1 -0
  3. package/ai-instructions/claude-code/SKILL.md +1 -1
  4. package/dist/adapters/observability/auditShapes/events/decisions.js +11 -0
  5. package/dist/adapters/observability/auditShapes/events/decisions.js.map +1 -1
  6. package/dist/artifacts/sourceEvidence/datasets.js.map +1 -1
  7. package/dist/core/agent/resultRowsets/catalog.js +55 -0
  8. package/dist/core/agent/resultRowsets/catalog.js.map +1 -0
  9. package/dist/core/agent/resultRowsets/finalization.js +116 -0
  10. package/dist/core/agent/resultRowsets/finalization.js.map +1 -0
  11. package/dist/core/agent/resultRowsets/inlineRows.js +125 -0
  12. package/dist/core/agent/resultRowsets/inlineRows.js.map +1 -0
  13. package/dist/core/agent/resultRowsets/judge.js +104 -0
  14. package/dist/core/agent/resultRowsets/judge.js.map +1 -0
  15. package/dist/core/agent/resultRowsets/read.js +91 -0
  16. package/dist/core/agent/resultRowsets/read.js.map +1 -0
  17. package/dist/core/agent/resultRowsets/resumed.js +18 -0
  18. package/dist/core/agent/resultRowsets/resumed.js.map +1 -0
  19. package/dist/core/agent/runtime/chart/owner.js +5 -1
  20. package/dist/core/agent/runtime/chart/owner.js.map +1 -1
  21. package/dist/core/agent/runtime/integrity/owner.js +1 -1
  22. package/dist/core/agent/runtime/integrity/owner.js.map +1 -1
  23. package/dist/core/agent/runtime/request/factory.js +10 -2
  24. package/dist/core/agent/runtime/request/factory.js.map +1 -1
  25. package/dist/core/agent/runtime/slots/buildSlots.js +16 -1
  26. package/dist/core/agent/runtime/slots/buildSlots.js.map +1 -1
  27. package/dist/core/agent/runtime/toolCalls/factory.js +9 -2
  28. package/dist/core/agent/runtime/toolCalls/factory.js.map +1 -1
  29. package/dist/core/agent/sourceEvidence/capture.js +9 -4
  30. package/dist/core/agent/sourceEvidence/capture.js.map +1 -1
  31. package/dist/core/agent/sourceEvidence/publications.js +57 -22
  32. package/dist/core/agent/sourceEvidence/publications.js.map +1 -1
  33. package/dist/core/agent/stages/callLLM.js +7 -8
  34. package/dist/core/agent/stages/callLLM.js.map +1 -1
  35. package/dist/core/agent/stages/toolCalls/batch/execute.js +21 -1
  36. package/dist/core/agent/stages/toolCalls/batch/execute.js.map +1 -1
  37. package/dist/core/agent/stages/toolCalls/execution/contextOperations.js +2 -2
  38. package/dist/core/agent/stages/toolCalls/execution/contextOperations.js.map +1 -1
  39. package/dist/core/agent/stages/toolCalls/execution/dispatchCall.js +415 -442
  40. package/dist/core/agent/stages/toolCalls/execution/dispatchCall.js.map +1 -1
  41. package/dist/core/agent/stages/toolCalls/execution/finalizeCallResult.js +73 -0
  42. package/dist/core/agent/stages/toolCalls/execution/finalizeCallResult.js.map +1 -0
  43. package/dist/core/agent/stages/toolCalls/execution/initialInvocation.js +4 -5
  44. package/dist/core/agent/stages/toolCalls/execution/initialInvocation.js.map +1 -1
  45. package/dist/core/agent/stages/toolCalls/execution/resumedInvocation.js +7 -6
  46. package/dist/core/agent/stages/toolCalls/execution/resumedInvocation.js.map +1 -1
  47. package/dist/core/agent/stages/toolCalls/resume/ask.js +354 -333
  48. package/dist/core/agent/stages/toolCalls/resume/ask.js.map +1 -1
  49. package/dist/core/agent/stages/toolCalls/resume/checkIn.js +159 -136
  50. package/dist/core/agent/stages/toolCalls/resume/checkIn.js.map +1 -1
  51. package/dist/core/agent/stages/toolCalls/resume/credential.js +142 -117
  52. package/dist/core/agent/stages/toolCalls/resume/credential.js.map +1 -1
  53. package/dist/core/slots/discoverTools.js +5 -0
  54. package/dist/core/slots/discoverTools.js.map +1 -1
  55. package/dist/esm/adapters/observability/auditShapes/events/decisions.d.ts +1 -0
  56. package/dist/esm/adapters/observability/auditShapes/events/decisions.js +11 -0
  57. package/dist/esm/adapters/observability/auditShapes/events/decisions.js.map +1 -1
  58. package/dist/esm/artifacts/sourceEvidence/datasets.d.ts +1 -1
  59. package/dist/esm/artifacts/sourceEvidence/datasets.js.map +1 -1
  60. package/dist/esm/core/agent/resultRowsets/catalog.d.ts +17 -0
  61. package/dist/esm/core/agent/resultRowsets/catalog.js +47 -0
  62. package/dist/esm/core/agent/resultRowsets/catalog.js.map +1 -0
  63. package/dist/esm/core/agent/resultRowsets/finalization.d.ts +25 -0
  64. package/dist/esm/core/agent/resultRowsets/finalization.js +112 -0
  65. package/dist/esm/core/agent/resultRowsets/finalization.js.map +1 -0
  66. package/dist/esm/core/agent/resultRowsets/inlineRows.d.ts +15 -0
  67. package/dist/esm/core/agent/resultRowsets/inlineRows.js +119 -0
  68. package/dist/esm/core/agent/resultRowsets/inlineRows.js.map +1 -0
  69. package/dist/esm/core/agent/resultRowsets/judge.d.ts +18 -0
  70. package/dist/esm/core/agent/resultRowsets/judge.js +99 -0
  71. package/dist/esm/core/agent/resultRowsets/judge.js.map +1 -0
  72. package/dist/esm/core/agent/resultRowsets/read.d.ts +12 -0
  73. package/dist/esm/core/agent/resultRowsets/read.js +87 -0
  74. package/dist/esm/core/agent/resultRowsets/read.js.map +1 -0
  75. package/dist/esm/core/agent/resultRowsets/resumed.d.ts +21 -0
  76. package/dist/esm/core/agent/resultRowsets/resumed.js +14 -0
  77. package/dist/esm/core/agent/resultRowsets/resumed.js.map +1 -0
  78. package/dist/esm/core/agent/runtime/chart/owner.js +5 -1
  79. package/dist/esm/core/agent/runtime/chart/owner.js.map +1 -1
  80. package/dist/esm/core/agent/runtime/integrity/owner.js +1 -1
  81. package/dist/esm/core/agent/runtime/integrity/owner.js.map +1 -1
  82. package/dist/esm/core/agent/runtime/request/factory.d.ts +3 -0
  83. package/dist/esm/core/agent/runtime/request/factory.js +10 -2
  84. package/dist/esm/core/agent/runtime/request/factory.js.map +1 -1
  85. package/dist/esm/core/agent/runtime/slots/buildSlots.d.ts +3 -0
  86. package/dist/esm/core/agent/runtime/slots/buildSlots.js +16 -1
  87. package/dist/esm/core/agent/runtime/slots/buildSlots.js.map +1 -1
  88. package/dist/esm/core/agent/runtime/toolCalls/factory.d.ts +3 -0
  89. package/dist/esm/core/agent/runtime/toolCalls/factory.js +9 -2
  90. package/dist/esm/core/agent/runtime/toolCalls/factory.js.map +1 -1
  91. package/dist/esm/core/agent/sourceEvidence/capture.d.ts +2 -1
  92. package/dist/esm/core/agent/sourceEvidence/capture.js +10 -5
  93. package/dist/esm/core/agent/sourceEvidence/capture.js.map +1 -1
  94. package/dist/esm/core/agent/sourceEvidence/publications.d.ts +3 -1
  95. package/dist/esm/core/agent/sourceEvidence/publications.js +55 -20
  96. package/dist/esm/core/agent/sourceEvidence/publications.js.map +1 -1
  97. package/dist/esm/core/agent/stages/callLLM/types.d.ts +4 -3
  98. package/dist/esm/core/agent/stages/callLLM.js +7 -8
  99. package/dist/esm/core/agent/stages/callLLM.js.map +1 -1
  100. package/dist/esm/core/agent/stages/toolCalls/batch/execute.js +21 -1
  101. package/dist/esm/core/agent/stages/toolCalls/batch/execute.js.map +1 -1
  102. package/dist/esm/core/agent/stages/toolCalls/compose.d.ts +1 -1
  103. package/dist/esm/core/agent/stages/toolCalls/contracts/callCells.d.ts +2 -2
  104. package/dist/esm/core/agent/stages/toolCalls/contracts/callFacts.d.ts +2 -2
  105. package/dist/esm/core/agent/stages/toolCalls/contracts/evidence.d.ts +7 -0
  106. package/dist/esm/core/agent/stages/toolCalls/contracts/operations/context.d.ts +1 -1
  107. package/dist/esm/core/agent/stages/toolCalls/execution/contextOperations.js +2 -2
  108. package/dist/esm/core/agent/stages/toolCalls/execution/contextOperations.js.map +1 -1
  109. package/dist/esm/core/agent/stages/toolCalls/execution/dispatchCall.js +415 -442
  110. package/dist/esm/core/agent/stages/toolCalls/execution/dispatchCall.js.map +1 -1
  111. package/dist/esm/core/agent/stages/toolCalls/execution/finalizeCallResult.d.ts +25 -0
  112. package/dist/esm/core/agent/stages/toolCalls/execution/finalizeCallResult.js +69 -0
  113. package/dist/esm/core/agent/stages/toolCalls/execution/finalizeCallResult.js.map +1 -0
  114. package/dist/esm/core/agent/stages/toolCalls/execution/initialInvocation.js +4 -5
  115. package/dist/esm/core/agent/stages/toolCalls/execution/initialInvocation.js.map +1 -1
  116. package/dist/esm/core/agent/stages/toolCalls/execution/resumedInvocation.d.ts +1 -1
  117. package/dist/esm/core/agent/stages/toolCalls/execution/resumedInvocation.js +7 -6
  118. package/dist/esm/core/agent/stages/toolCalls/execution/resumedInvocation.js.map +1 -1
  119. package/dist/esm/core/agent/stages/toolCalls/resume/ask.js +354 -333
  120. package/dist/esm/core/agent/stages/toolCalls/resume/ask.js.map +1 -1
  121. package/dist/esm/core/agent/stages/toolCalls/resume/checkIn.js +159 -136
  122. package/dist/esm/core/agent/stages/toolCalls/resume/checkIn.js.map +1 -1
  123. package/dist/esm/core/agent/stages/toolCalls/resume/credential.js +142 -117
  124. package/dist/esm/core/agent/stages/toolCalls/resume/credential.js.map +1 -1
  125. package/dist/esm/core/slots/discoverTools.js +5 -0
  126. package/dist/esm/core/slots/discoverTools.js.map +1 -1
  127. package/dist/esm/events/payloads/toolRowsets.d.ts +14 -0
  128. package/dist/esm/events/payloads/toolRowsets.js +2 -0
  129. package/dist/esm/events/payloads/toolRowsets.js.map +1 -0
  130. package/dist/esm/events/payloads.d.ts +1 -0
  131. package/dist/esm/events/registry/names.d.ts +1 -0
  132. package/dist/esm/events/registry/names.js +1 -0
  133. package/dist/esm/events/registry/names.js.map +1 -1
  134. package/dist/esm/events/registry/toolEvents.d.ts +32 -0
  135. package/dist/esm/events/registry/toolEvents.js +2 -0
  136. package/dist/esm/events/registry/toolEvents.js.map +1 -0
  137. package/dist/esm/events/registry.d.ts +3 -28
  138. package/dist/esm/events/registry.js +1 -0
  139. package/dist/esm/events/registry.js.map +1 -1
  140. package/dist/esm/index.d.ts +1 -0
  141. package/dist/esm/index.js +1 -2
  142. package/dist/esm/index.js.map +1 -1
  143. package/dist/esm/integrity/column-types/check.d.ts +2 -0
  144. package/dist/esm/integrity/column-types/check.js +8 -2
  145. package/dist/esm/integrity/column-types/check.js.map +1 -1
  146. package/dist/esm/integrity/finding/types.d.ts +2 -0
  147. package/dist/esm/integrity/finding/types.js +18 -0
  148. package/dist/esm/integrity/finding/types.js.map +1 -1
  149. package/dist/esm/mcp/toolExtras.d.ts +8 -4
  150. package/dist/esm/mcp/toolExtras.js +20 -4
  151. package/dist/esm/mcp/toolExtras.js.map +1 -1
  152. package/dist/esm/recorders/observability/commentary/commentaryTemplates/dispositions.js +1 -0
  153. package/dist/esm/recorders/observability/commentary/commentaryTemplates/dispositions.js.map +1 -1
  154. package/dist/esm/redaction/knownStrings/fields-1.d.ts +1 -1
  155. package/dist/esm/redaction/knownStrings/fields-1.js +1 -1
  156. package/dist/esm/redaction/knownStrings/fields-1.js.map +1 -1
  157. package/dist/esm/redaction/knownStrings/fields-2.d.ts +1 -0
  158. package/dist/esm/redaction/knownStrings/fields-2.js +1 -0
  159. package/dist/esm/redaction/knownStrings/fields-2.js.map +1 -1
  160. package/dist/esm/redaction/knownStrings/words-0.d.ts +4 -4
  161. package/dist/esm/redaction/knownStrings/words-0.js +4 -4
  162. package/dist/esm/redaction/knownStrings/words-0.js.map +1 -1
  163. package/dist/esm/redaction/knownStrings/words-1.d.ts +15 -15
  164. package/dist/esm/redaction/knownStrings/words-1.js +15 -15
  165. package/dist/esm/redaction/knownStrings/words-1.js.map +1 -1
  166. package/dist/esm/redaction/knownStrings/words-2.d.ts +18 -0
  167. package/dist/esm/redaction/knownStrings/words-2.js +18 -0
  168. package/dist/esm/redaction/knownStrings/words-2.js.map +1 -1
  169. package/dist/esm/tools/resultRowsets.d.ts +22 -0
  170. package/dist/esm/tools/resultRowsets.js +65 -0
  171. package/dist/esm/tools/resultRowsets.js.map +1 -0
  172. package/dist/esm/tools/tools.d.ts +7 -9
  173. package/dist/esm/tools/tools.js +5 -9
  174. package/dist/esm/tools/tools.js.map +1 -1
  175. package/dist/events/payloads/toolRowsets.js +3 -0
  176. package/dist/events/payloads/toolRowsets.js.map +1 -0
  177. package/dist/events/registry/names.js +1 -0
  178. package/dist/events/registry/names.js.map +1 -1
  179. package/dist/events/registry/toolEvents.js +3 -0
  180. package/dist/events/registry/toolEvents.js.map +1 -0
  181. package/dist/events/registry.js +1 -0
  182. package/dist/events/registry.js.map +1 -1
  183. package/dist/index.js +1 -2
  184. package/dist/index.js.map +1 -1
  185. package/dist/integrity/column-types/check.js +8 -2
  186. package/dist/integrity/column-types/check.js.map +1 -1
  187. package/dist/integrity/finding/types.js +18 -0
  188. package/dist/integrity/finding/types.js.map +1 -1
  189. package/dist/mcp/toolExtras.js +20 -4
  190. package/dist/mcp/toolExtras.js.map +1 -1
  191. package/dist/recorders/observability/commentary/commentaryTemplates/dispositions.js +1 -0
  192. package/dist/recorders/observability/commentary/commentaryTemplates/dispositions.js.map +1 -1
  193. package/dist/redaction/knownStrings/fields-1.js +1 -1
  194. package/dist/redaction/knownStrings/fields-1.js.map +1 -1
  195. package/dist/redaction/knownStrings/fields-2.js +1 -0
  196. package/dist/redaction/knownStrings/fields-2.js.map +1 -1
  197. package/dist/redaction/knownStrings/words-0.js +4 -4
  198. package/dist/redaction/knownStrings/words-0.js.map +1 -1
  199. package/dist/redaction/knownStrings/words-1.js +15 -15
  200. package/dist/redaction/knownStrings/words-1.js.map +1 -1
  201. package/dist/redaction/knownStrings/words-2.js +18 -0
  202. package/dist/redaction/knownStrings/words-2.js.map +1 -1
  203. package/dist/tools/resultRowsets.js +70 -0
  204. package/dist/tools/resultRowsets.js.map +1 -0
  205. package/dist/tools/tools.js +5 -9
  206. package/dist/tools/tools.js.map +1 -1
  207. package/dist/types/adapters/observability/auditShapes/events/decisions.d.ts +1 -0
  208. package/dist/types/adapters/observability/auditShapes/events/decisions.d.ts.map +1 -1
  209. package/dist/types/artifacts/sourceEvidence/datasets.d.ts +1 -1
  210. package/dist/types/artifacts/sourceEvidence/datasets.d.ts.map +1 -1
  211. package/dist/types/core/agent/resultRowsets/catalog.d.ts +18 -0
  212. package/dist/types/core/agent/resultRowsets/catalog.d.ts.map +1 -0
  213. package/dist/types/core/agent/resultRowsets/finalization.d.ts +26 -0
  214. package/dist/types/core/agent/resultRowsets/finalization.d.ts.map +1 -0
  215. package/dist/types/core/agent/resultRowsets/inlineRows.d.ts +16 -0
  216. package/dist/types/core/agent/resultRowsets/inlineRows.d.ts.map +1 -0
  217. package/dist/types/core/agent/resultRowsets/judge.d.ts +19 -0
  218. package/dist/types/core/agent/resultRowsets/judge.d.ts.map +1 -0
  219. package/dist/types/core/agent/resultRowsets/read.d.ts +13 -0
  220. package/dist/types/core/agent/resultRowsets/read.d.ts.map +1 -0
  221. package/dist/types/core/agent/resultRowsets/resumed.d.ts +22 -0
  222. package/dist/types/core/agent/resultRowsets/resumed.d.ts.map +1 -0
  223. package/dist/types/core/agent/runtime/chart/owner.d.ts.map +1 -1
  224. package/dist/types/core/agent/runtime/request/factory.d.ts +3 -0
  225. package/dist/types/core/agent/runtime/request/factory.d.ts.map +1 -1
  226. package/dist/types/core/agent/runtime/slots/buildSlots.d.ts +3 -0
  227. package/dist/types/core/agent/runtime/slots/buildSlots.d.ts.map +1 -1
  228. package/dist/types/core/agent/runtime/toolCalls/factory.d.ts +3 -0
  229. package/dist/types/core/agent/runtime/toolCalls/factory.d.ts.map +1 -1
  230. package/dist/types/core/agent/sourceEvidence/capture.d.ts +2 -1
  231. package/dist/types/core/agent/sourceEvidence/capture.d.ts.map +1 -1
  232. package/dist/types/core/agent/sourceEvidence/publications.d.ts +3 -1
  233. package/dist/types/core/agent/sourceEvidence/publications.d.ts.map +1 -1
  234. package/dist/types/core/agent/stages/callLLM/types.d.ts +4 -3
  235. package/dist/types/core/agent/stages/callLLM/types.d.ts.map +1 -1
  236. package/dist/types/core/agent/stages/toolCalls/batch/execute.d.ts.map +1 -1
  237. package/dist/types/core/agent/stages/toolCalls/compose.d.ts +1 -1
  238. package/dist/types/core/agent/stages/toolCalls/contracts/callCells.d.ts +2 -2
  239. package/dist/types/core/agent/stages/toolCalls/contracts/callCells.d.ts.map +1 -1
  240. package/dist/types/core/agent/stages/toolCalls/contracts/callFacts.d.ts +2 -2
  241. package/dist/types/core/agent/stages/toolCalls/contracts/callFacts.d.ts.map +1 -1
  242. package/dist/types/core/agent/stages/toolCalls/contracts/evidence.d.ts +7 -0
  243. package/dist/types/core/agent/stages/toolCalls/contracts/evidence.d.ts.map +1 -1
  244. package/dist/types/core/agent/stages/toolCalls/contracts/operations/context.d.ts +1 -1
  245. package/dist/types/core/agent/stages/toolCalls/contracts/operations/context.d.ts.map +1 -1
  246. package/dist/types/core/agent/stages/toolCalls/execution/dispatchCall.d.ts.map +1 -1
  247. package/dist/types/core/agent/stages/toolCalls/execution/finalizeCallResult.d.ts +26 -0
  248. package/dist/types/core/agent/stages/toolCalls/execution/finalizeCallResult.d.ts.map +1 -0
  249. package/dist/types/core/agent/stages/toolCalls/execution/initialInvocation.d.ts.map +1 -1
  250. package/dist/types/core/agent/stages/toolCalls/execution/resumedInvocation.d.ts +1 -1
  251. package/dist/types/core/agent/stages/toolCalls/execution/resumedInvocation.d.ts.map +1 -1
  252. package/dist/types/core/agent/stages/toolCalls/resume/ask.d.ts.map +1 -1
  253. package/dist/types/core/agent/stages/toolCalls/resume/checkIn.d.ts.map +1 -1
  254. package/dist/types/core/agent/stages/toolCalls/resume/credential.d.ts.map +1 -1
  255. package/dist/types/core/slots/discoverTools.d.ts.map +1 -1
  256. package/dist/types/events/payloads/toolRowsets.d.ts +15 -0
  257. package/dist/types/events/payloads/toolRowsets.d.ts.map +1 -0
  258. package/dist/types/events/payloads.d.ts +1 -0
  259. package/dist/types/events/payloads.d.ts.map +1 -1
  260. package/dist/types/events/registry/names.d.ts +1 -0
  261. package/dist/types/events/registry/names.d.ts.map +1 -1
  262. package/dist/types/events/registry/toolEvents.d.ts +33 -0
  263. package/dist/types/events/registry/toolEvents.d.ts.map +1 -0
  264. package/dist/types/events/registry.d.ts +3 -28
  265. package/dist/types/events/registry.d.ts.map +1 -1
  266. package/dist/types/index.d.ts +1 -0
  267. package/dist/types/index.d.ts.map +1 -1
  268. package/dist/types/integrity/column-types/check.d.ts +2 -0
  269. package/dist/types/integrity/column-types/check.d.ts.map +1 -1
  270. package/dist/types/integrity/finding/types.d.ts +2 -0
  271. package/dist/types/integrity/finding/types.d.ts.map +1 -1
  272. package/dist/types/mcp/toolExtras.d.ts +8 -4
  273. package/dist/types/mcp/toolExtras.d.ts.map +1 -1
  274. package/dist/types/recorders/observability/commentary/commentaryTemplates/dispositions.d.ts.map +1 -1
  275. package/dist/types/redaction/knownStrings/fields-1.d.ts +1 -1
  276. package/dist/types/redaction/knownStrings/fields-2.d.ts +1 -0
  277. package/dist/types/redaction/knownStrings/fields-2.d.ts.map +1 -1
  278. package/dist/types/redaction/knownStrings/words-0.d.ts +4 -4
  279. package/dist/types/redaction/knownStrings/words-1.d.ts +15 -15
  280. package/dist/types/redaction/knownStrings/words-2.d.ts +18 -0
  281. package/dist/types/redaction/knownStrings/words-2.d.ts.map +1 -1
  282. package/dist/types/tools/resultRowsets.d.ts +23 -0
  283. package/dist/types/tools/resultRowsets.d.ts.map +1 -0
  284. package/dist/types/tools/tools.d.ts +7 -9
  285. package/dist/types/tools/tools.d.ts.map +1 -1
  286. package/package.json +1 -1
@@ -24,6 +24,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.buildResumeAsk = void 0;
27
+ const resumed_js_1 = require("../../../resultRowsets/resumed.js");
27
28
  const consentRequest_js_1 = require("../../../../consentRequest.js");
28
29
  const bindings_js_1 = require("../access/bindings.js");
29
30
  const checkin_js_1 = require("../../../../checkin.js");
@@ -71,182 +72,129 @@ function buildResumeAsk(deps, links) {
71
72
  let negativeResultId;
72
73
  /** What the approved call's `execute` saw — its script row reads it. */
73
74
  const scriptSeen = {};
74
- if (!decision.approved) {
75
- result = (0, checkin_js_1.declinedResult)(decision.note);
76
- (0, ledger_js_1.recordDecisions)(scope, [
77
- {
78
- middleware: askedBy,
79
- moment: 'before-tool',
80
- at: 'tool',
81
- toolName,
82
- toolCallId,
83
- iteration,
84
- outcome: 'deny',
85
- changed: false,
86
- why: `declined by ${decision.by}${decision.note ? `: ${decision.note}` : ''}`,
87
- ...(answeredVia !== undefined && { componentId: answeredVia }),
88
- },
89
- ]);
90
- }
91
- else {
92
- (0, ledger_js_1.recordDecisions)(scope, [
93
- {
94
- middleware: askedBy,
95
- moment: 'before-tool',
96
- at: 'tool',
97
- toolName,
98
- toolCallId,
99
- iteration,
100
- outcome: 'allow',
101
- changed: false,
102
- why: `approved by ${decision.by}${decision.note ? `: ${decision.note}` : ''}`,
103
- ...(answeredVia !== undefined && { componentId: answeredVia }),
104
- },
105
- ]);
106
- // Continue the chain from the link AFTER the one that asked. Its
107
- // decision is already on the checkpoint; re-running it would ask the
108
- // same question twice and file a duplicate row.
109
- //
110
- // `askPolicy: 'refuse'` because footprintjs's `PausableHandler.resume`
111
- // returns void — a resumed dispatch has no second checkpoint to give.
112
- // A link further down the chain that also wants a person gets a named,
113
- // model-visible refusal and the tool does NOT run. That is the same
114
- // rule already applied to a tool that tries to pause during an
115
- // approved check-in resume: at most one human question per resume.
116
- // Resolved BEFORE the chain runs, not after, because the links that
117
- // continue here must see the same `toolSource` the links before the
118
- // ask saw. A chain that changed its mind about where a tool came from
119
- // halfway through one dispatch would be worse than not knowing.
120
- //
121
- // Resolved against the party the CHECKPOINT carries (9.92.0): a
122
- // fresh instance has an empty served record and Compose has not
123
- // re-run, so without it the build-time map's first holder answered.
124
- const resolved = links.resolveTool(toolName, scope.pausedToolParty);
125
- const tool = resolved.tool;
126
- // ── THE INPUTS LAYER'S REFUSALS, re-applied at this door (honesty
127
- // layer 2). The batch loop decides them BEFORE the chain, so a call
128
- // it refuses never reaches an ask. This door still asks both
129
- // questions itself: a checkpoint written before they moved ahead of
130
- // the chain, or resumed on an agent built without the layer, must
131
- // not run a ruled tool unruled because a person approved the ask.
132
- // Refused here, the rest of the chain is not walked and the tool
133
- // does not run — the argument-refusal shape the loop lands.
134
- const inputs = deps.inputsLayer === true ? await Promise.resolve().then(() => __importStar(require('../../../arguments/dispatch.js'))) : undefined;
135
- const unmounted = links.unmountedRules(tool, toolName);
136
- const rulesRefusal = inputs?.resolutionsFor(scope, iteration).get(toolCallId)?.refused ??
137
- (unmounted === undefined ? undefined : await unmounted);
138
- if (rulesRefusal !== undefined) {
139
- error = true;
140
- result = rulesRefusal;
75
+ try {
76
+ if (!decision.approved) {
77
+ result = (0, checkin_js_1.declinedResult)(decision.note);
78
+ (0, ledger_js_1.recordDecisions)(scope, [
79
+ {
80
+ middleware: askedBy,
81
+ moment: 'before-tool',
82
+ at: 'tool',
83
+ toolName,
84
+ toolCallId,
85
+ iteration,
86
+ outcome: 'deny',
87
+ changed: false,
88
+ why: `declined by ${decision.by}${decision.note ? `: ${decision.note}` : ''}`,
89
+ ...(answeredVia !== undefined && { componentId: answeredVia }),
90
+ },
91
+ ]);
141
92
  }
142
93
  else {
143
- const rest = await (0, runChain_js_1.runToolChain)(deps.toolMiddleware ?? [], {
144
- toolName,
145
- ...(tool?.source !== undefined && { toolSource: tool.source }),
146
- toolCallId,
147
- iteration,
148
- args,
149
- history: [...scope.history],
150
- startIndex: askIndex + 1,
151
- askPolicy: 'refuse',
152
- });
153
- (0, ledger_js_1.recordDecisions)(scope, rest.decisions);
154
- // The approval covers the arguments the person was shown. The ones
155
- // the rest of the chain hands back must re-derive the paused
156
- // request's id (`runsAsAsked`) — held to the request itself, never
157
- // to the copy the links were handed. Any other arguments are not
158
- // approved: the call does not run, and the record and the model
159
- // are told why ('call-changed').
160
- const read = (key) => scope.$getValue(key);
161
- const rewrittenBy = rest.kind === 'deny' ||
162
- (0, consentRequest_js_1.runsAsAsked)(read('pausedRequest'), (0, consentRequest_js_1.gatedCallOf)(read, 'ask'), rest.args)
163
- ? undefined
164
- : (0, bindings_js_1.changedAfterApproval)(rest.decisions);
165
- // The arguments the call runs with: a fresh copy of the approved
166
- // ones (equal, by the check above, to what the chain handed back),
167
- // so nothing a link still holds can reach the tool.
168
- const runArgs = (0, bindings_js_1.boundArgsOf)(scope, 'pausedAskArgs');
169
- // Would this tool's OWN consent gate have fired for this call? Asked by
170
- // EVALUATING the demand, not by noticing that one was declared (8.13.0).
171
- // Before that, any tool carrying a `checkIn` field was refused here even
172
- // when its predicate said no — a selective gate (`amount > 1000`) blocked
173
- // the £5 refunds it was written to let through, and the refusal claimed a
174
- // consent gate would have run when it provably would not have.
175
- //
176
- // Judged on `runArgs` (what the tool would actually run with) and on
177
- // the same history shape the loop's gate uses, so the answer cannot
178
- // depend on which door the call arrived through. The predicate is
179
- // handed its own frozen copy of them (`shouldCheckIn`), never
180
- // `runArgs` itself: a predicate that wrote into its argument used
181
- // to change the call the person had approved.
182
- const demandTrips = rest.kind !== 'deny' &&
183
- rewrittenBy === undefined &&
184
- tool?.checkIn !== undefined &&
185
- (0, checkin_js_1.shouldCheckIn)(tool.checkIn, runArgs, {
186
- iteration,
94
+ (0, ledger_js_1.recordDecisions)(scope, [
95
+ {
96
+ middleware: askedBy,
97
+ moment: 'before-tool',
98
+ at: 'tool',
99
+ toolName,
187
100
  toolCallId,
188
- history: links.historyForCheckIn(scope, scope.history),
189
- });
190
- if (rest.kind === 'deny') {
191
- result = rest.reason;
192
- }
193
- else if (rewrittenBy !== undefined) {
194
- error = true;
195
- result = (0, bindings_js_1.rewrittenAfterApproval)(toolName, rewrittenBy);
196
- (0, ledger_js_1.recordDecisions)(scope, [
197
- {
198
- middleware: askedBy,
199
- moment: 'before-tool',
200
- at: 'tool',
201
- toolName,
202
- toolCallId,
203
- iteration,
204
- outcome: 'deny',
205
- changed: false,
206
- why: `the approval covers the arguments the person was shown; ${rewrittenBy}, ` +
207
- `so the call was not run (call-changed)`,
208
- },
209
- ]);
210
- }
211
- else if (demandTrips) {
212
- // The one-question rule, from the other direction: this tool's own
213
- // consent gate really does demand a person for THESE arguments, and
214
- // there is no checkpoint left to ask with.
215
- //
216
- // The two gates ask DIFFERENT questions, which is why an approval of
217
- // one is not an answer to the other. A middleware `ask` carries the
218
- // rule's own free-text question; a check-in carries the TOOL's demand
219
- // with the evidence pack attached — `willDo`, what the run read, what
220
- // drove the choice, the trail — none of which the person who approved
221
- // the ask ever saw. Letting the approval satisfy both would file a
222
- // `checkin.decision` for a question nobody was asked. Governance never
223
- // silently invents a decision, for the same reason it never silently
224
- // drops one.
101
+ iteration,
102
+ outcome: 'allow',
103
+ changed: false,
104
+ why: `approved by ${decision.by}${decision.note ? `: ${decision.note}` : ''}`,
105
+ ...(answeredVia !== undefined && { componentId: answeredVia }),
106
+ },
107
+ ]);
108
+ // Continue the chain from the link AFTER the one that asked. Its
109
+ // decision is already on the checkpoint; re-running it would ask the
110
+ // same question twice and file a duplicate row.
111
+ //
112
+ // `askPolicy: 'refuse'` because footprintjs's `PausableHandler.resume`
113
+ // returns void — a resumed dispatch has no second checkpoint to give.
114
+ // A link further down the chain that also wants a person gets a named,
115
+ // model-visible refusal and the tool does NOT run. That is the same
116
+ // rule already applied to a tool that tries to pause during an
117
+ // approved check-in resume: at most one human question per resume.
118
+ // Resolved BEFORE the chain runs, not after, because the links that
119
+ // continue here must see the same `toolSource` the links before the
120
+ // ask saw. A chain that changed its mind about where a tool came from
121
+ // halfway through one dispatch would be worse than not knowing.
122
+ //
123
+ // Resolved against the party the CHECKPOINT carries (9.92.0): a
124
+ // fresh instance has an empty served record and Compose has not
125
+ // re-run, so without it the build-time map's first holder answered.
126
+ const resolved = links.resolveTool(toolName, scope.pausedToolParty);
127
+ const tool = resolved.tool;
128
+ // ── THE INPUTS LAYER'S REFUSALS, re-applied at this door (honesty
129
+ // layer 2). The batch loop decides them BEFORE the chain, so a call
130
+ // it refuses never reaches an ask. This door still asks both
131
+ // questions itself: a checkpoint written before they moved ahead of
132
+ // the chain, or resumed on an agent built without the layer, must
133
+ // not run a ruled tool unruled because a person approved the ask.
134
+ // Refused here, the rest of the chain is not walked and the tool
135
+ // does not run — the argument-refusal shape the loop lands.
136
+ const inputs = deps.inputsLayer === true ? await Promise.resolve().then(() => __importStar(require('../../../arguments/dispatch.js'))) : undefined;
137
+ const unmounted = links.unmountedRules(tool, toolName);
138
+ const rulesRefusal = inputs?.resolutionsFor(scope, iteration).get(toolCallId)?.refused ??
139
+ (unmounted === undefined ? undefined : await unmounted);
140
+ if (rulesRefusal !== undefined) {
225
141
  error = true;
226
- // A past fact about the resumed call, not a forecast about the
227
- // turn (9.86.1): "cannot be retried this turn … Answer without it,
228
- // or finish" was a prediction plus a standing order on a result
229
- // that is re-read on every later call.
230
- result =
231
- `tool '${toolName}' was not executed on that call, and the resumed dispatch had ` +
232
- `no second checkpoint to retry it on: it declares its own checkIn consent gate, ` +
233
- `and that gate tripped for those arguments. (To ` +
234
- `the agent's author: the middleware '${askedBy}' and the tool's checkIn ask ` +
235
- `different questions — one is the rule's, one is the tool's with the evidence ` +
236
- `pack attached — so approving one is not answering the other. Keep one gate for ` +
237
- `this tool: drop the tool's \`checkIn\`, or let \`onToolCall\` return allow() for ` +
238
- `tools that declare their own.)`;
142
+ result = rulesRefusal;
239
143
  }
240
144
  else {
241
- const env = scope.$getEnv();
242
- const dispatched = await links.resolveCredentialAndExecute(scope, resolved, toolName, runArgs, toolCallId, iteration, env, 'ask', scriptSeen);
243
- negativeResultId = dispatched.negativeResultId;
244
- result = dispatched.result;
245
- error = dispatched.error;
246
- toolRan = dispatched.executed === true;
247
- // Held to the request at the last moment and found changed: the
248
- // record says so, as for a rewrite the chain handed back.
249
- if (dispatched.callChanged === true) {
145
+ const rest = await (0, runChain_js_1.runToolChain)(deps.toolMiddleware ?? [], {
146
+ toolName,
147
+ ...(tool?.source !== undefined && { toolSource: tool.source }),
148
+ toolCallId,
149
+ iteration,
150
+ args,
151
+ history: [...scope.history],
152
+ startIndex: askIndex + 1,
153
+ askPolicy: 'refuse',
154
+ });
155
+ (0, ledger_js_1.recordDecisions)(scope, rest.decisions);
156
+ // The approval covers the arguments the person was shown. The ones
157
+ // the rest of the chain hands back must re-derive the paused
158
+ // request's id (`runsAsAsked`) — held to the request itself, never
159
+ // to the copy the links were handed. Any other arguments are not
160
+ // approved: the call does not run, and the record and the model
161
+ // are told why ('call-changed').
162
+ const read = (key) => scope.$getValue(key);
163
+ const rewrittenBy = rest.kind === 'deny' ||
164
+ (0, consentRequest_js_1.runsAsAsked)(read('pausedRequest'), (0, consentRequest_js_1.gatedCallOf)(read, 'ask'), rest.args)
165
+ ? undefined
166
+ : (0, bindings_js_1.changedAfterApproval)(rest.decisions);
167
+ // The arguments the call runs with: a fresh copy of the approved
168
+ // ones (equal, by the check above, to what the chain handed back),
169
+ // so nothing a link still holds can reach the tool.
170
+ const runArgs = (0, bindings_js_1.boundArgsOf)(scope, 'pausedAskArgs');
171
+ // Would this tool's OWN consent gate have fired for this call? Asked by
172
+ // EVALUATING the demand, not by noticing that one was declared (8.13.0).
173
+ // Before that, any tool carrying a `checkIn` field was refused here even
174
+ // when its predicate said no — a selective gate (`amount > 1000`) blocked
175
+ // the £5 refunds it was written to let through, and the refusal claimed a
176
+ // consent gate would have run when it provably would not have.
177
+ //
178
+ // Judged on `runArgs` (what the tool would actually run with) and on
179
+ // the same history shape the loop's gate uses, so the answer cannot
180
+ // depend on which door the call arrived through. The predicate is
181
+ // handed its own frozen copy of them (`shouldCheckIn`), never
182
+ // `runArgs` itself: a predicate that wrote into its argument used
183
+ // to change the call the person had approved.
184
+ const demandTrips = rest.kind !== 'deny' &&
185
+ rewrittenBy === undefined &&
186
+ tool?.checkIn !== undefined &&
187
+ (0, checkin_js_1.shouldCheckIn)(tool.checkIn, runArgs, {
188
+ iteration,
189
+ toolCallId,
190
+ history: links.historyForCheckIn(scope, scope.history),
191
+ });
192
+ if (rest.kind === 'deny') {
193
+ result = rest.reason;
194
+ }
195
+ else if (rewrittenBy !== undefined) {
196
+ error = true;
197
+ result = (0, bindings_js_1.rewrittenAfterApproval)(toolName, rewrittenBy);
250
198
  (0, ledger_js_1.recordDecisions)(scope, [
251
199
  {
252
200
  middleware: askedBy,
@@ -257,181 +205,254 @@ function buildResumeAsk(deps, links) {
257
205
  iteration,
258
206
  outcome: 'deny',
259
207
  changed: false,
260
- why: 'the approval covers the arguments the person was shown; they changed ' +
261
- 'before the call could run, so the call was not run (call-changed)',
208
+ why: `the approval covers the arguments the person was shown; ${rewrittenBy}, ` +
209
+ `so the call was not run (call-changed)`,
262
210
  },
263
211
  ]);
264
212
  }
265
- // A ceiling-refused call RAN but must not advance a step (9.20.0);
266
- // its envelope — status 'invalid' plus any surviving declared
267
- // effects — is still picked up and judged below.
268
- stepToolRan =
269
- dispatched.executed === true && error !== true && dispatched.ceilingRefused !== true;
270
- if (dispatched.executed === true && error !== true) {
271
- resumeEnvelope = dispatched.envelope;
272
- }
273
- // skip_step behind a middleware ask, approved (9.18.0): the
274
- // placeholder just landed — replace it with the authoritative
275
- // sentence BEFORE the chain's last word, the execute loop's
276
- // composition kept.
277
- if (links.frameworkSkipStepAnswered(toolName, tool) && stepToolRan) {
278
- result = links.applySkipStep(scope, { args: runArgs, toolCallId, iteration });
213
+ else if (demandTrips) {
214
+ // The one-question rule, from the other direction: this tool's own
215
+ // consent gate really does demand a person for THESE arguments, and
216
+ // there is no checkpoint left to ask with.
217
+ //
218
+ // The two gates ask DIFFERENT questions, which is why an approval of
219
+ // one is not an answer to the other. A middleware `ask` carries the
220
+ // rule's own free-text question; a check-in carries the TOOL's demand
221
+ // with the evidence pack attached — `willDo`, what the run read, what
222
+ // drove the choice, the trail — none of which the person who approved
223
+ // the ask ever saw. Letting the approval satisfy both would file a
224
+ // `checkin.decision` for a question nobody was asked. Governance never
225
+ // silently invents a decision, for the same reason it never silently
226
+ // drops one.
227
+ error = true;
228
+ // A past fact about the resumed call, not a forecast about the
229
+ // turn (9.86.1): "cannot be retried this turn … Answer without it,
230
+ // or finish" was a prediction plus a standing order on a result
231
+ // that is re-read on every later call.
232
+ result =
233
+ `tool '${toolName}' was not executed on that call, and the resumed dispatch had ` +
234
+ `no second checkpoint to retry it on: it declares its own checkIn consent gate, ` +
235
+ `and that gate tripped for those arguments. (To ` +
236
+ `the agent's author: the middleware '${askedBy}' and the tool's checkIn ask ` +
237
+ `different questions — one is the rule's, one is the tool's with the evidence ` +
238
+ `pack attached — so approving one is not answering the other. Keep one gate for ` +
239
+ `this tool: drop the tool's \`checkIn\`, or let \`onToolCall\` return allow() for ` +
240
+ `tools that declare their own.)`;
279
241
  }
280
- // present behind a middleware ask, approved (9.22.0): same
281
- // overwrite the batch loop applies — the snapshot (or refusal)
282
- // replaces the placeholder before the chain's last word. A miss
283
- // is an errored call here too.
284
- if (deps.artifactStore && toolName === present_js_1.PRESENT_TOOL_NAME && stepToolRan) {
285
- const presented = await links.applyPresent(scope, {
286
- args: runArgs,
287
- toolCallId,
288
- iteration,
289
- });
290
- result = presented.text;
291
- if (!presented.ok) {
292
- error = true;
293
- stepToolRan = false;
242
+ else {
243
+ const env = scope.$getEnv();
244
+ const dispatched = await links.resolveCredentialAndExecute(scope, resolved, toolName, runArgs, toolCallId, iteration, env, 'ask', scriptSeen);
245
+ negativeResultId = dispatched.negativeResultId;
246
+ result = dispatched.result;
247
+ error = dispatched.error;
248
+ toolRan = dispatched.executed === true;
249
+ // Held to the request at the last moment and found changed: the
250
+ // record says so, as for a rewrite the chain handed back.
251
+ if (dispatched.callChanged === true) {
252
+ (0, ledger_js_1.recordDecisions)(scope, [
253
+ {
254
+ middleware: askedBy,
255
+ moment: 'before-tool',
256
+ at: 'tool',
257
+ toolName,
258
+ toolCallId,
259
+ iteration,
260
+ outcome: 'deny',
261
+ changed: false,
262
+ why: 'the approval covers the arguments the person was shown; they changed ' +
263
+ 'before the call could run, so the call was not run (call-changed)',
264
+ },
265
+ ]);
266
+ }
267
+ // A ceiling-refused call RAN but must not advance a step (9.20.0);
268
+ // its envelope — status 'invalid' plus any surviving declared
269
+ // effects — is still picked up and judged below.
270
+ stepToolRan =
271
+ dispatched.executed === true && error !== true && dispatched.ceilingRefused !== true;
272
+ if (dispatched.executed === true && error !== true) {
273
+ resumeEnvelope = dispatched.envelope;
274
+ }
275
+ // skip_step behind a middleware ask, approved (9.18.0): the
276
+ // placeholder just landed — replace it with the authoritative
277
+ // sentence BEFORE the chain's last word, the execute loop's
278
+ // composition kept.
279
+ if (links.frameworkSkipStepAnswered(toolName, tool) && stepToolRan) {
280
+ result = links.applySkipStep(scope, { args: runArgs, toolCallId, iteration });
281
+ }
282
+ // present behind a middleware ask, approved (9.22.0): same
283
+ // overwrite the batch loop applies — the snapshot (or refusal)
284
+ // replaces the placeholder before the chain's last word. A miss
285
+ // is an errored call here too.
286
+ if (deps.artifactStore && toolName === present_js_1.PRESENT_TOOL_NAME && stepToolRan) {
287
+ const presented = await links.applyPresent(scope, {
288
+ args: runArgs,
289
+ toolCallId,
290
+ iteration,
291
+ });
292
+ result = presented.text;
293
+ if (!presented.ok) {
294
+ error = true;
295
+ stepToolRan = false;
296
+ }
297
+ }
298
+ // The tool ran on this side of the pause, so the chain gets its
299
+ // last word here too — a rule about results cannot be skipped by
300
+ // routing a call through a human.
301
+ if (dispatched.executed === true) {
302
+ modelResult = await links.afterMoment(scope, {
303
+ ...(tool && { tool }),
304
+ toolName,
305
+ toolCallId,
306
+ iteration,
307
+ args: runArgs,
308
+ result,
309
+ negativeResultId,
310
+ ...(scriptSeen.resultFinalizer && {
311
+ onSourceWithheld: scriptSeen.resultFinalizer.withheld,
312
+ }),
313
+ ...(error === true && { error: true }),
314
+ history: [...scope.history],
315
+ ...(scope.runIdentity && { identity: scope.runIdentity }),
316
+ ...(env.signal && { signal: env.signal }),
317
+ });
294
318
  }
295
- }
296
- // The tool ran on this side of the pause, so the chain gets its
297
- // last word here too — a rule about results cannot be skipped by
298
- // routing a call through a human.
299
- if (dispatched.executed === true) {
300
- modelResult = await links.afterMoment(scope, {
301
- ...(tool && { tool }),
302
- toolName,
303
- toolCallId,
304
- iteration,
305
- args: runArgs,
306
- result,
307
- negativeResultId,
308
- ...(scriptSeen.sourceCapture && {
309
- onSourceWithheld: scriptSeen.sourceCapture.withheld,
310
- }),
311
- ...(error === true && { error: true }),
312
- history: [...scope.history],
313
- ...(scope.runIdentity && { identity: scope.runIdentity }),
314
- ...(env.signal && { signal: env.signal }),
315
- });
316
319
  }
317
320
  }
318
321
  }
319
- }
320
- // `modelResult` is only set where the after-tool moment ran; everywhere
321
- // else the two are the same value.
322
- if (modelResult === undefined)
323
- modelResult = result;
324
- // Placement then the truncation net — the batch loop's precedence,
325
- // kept on this door (a resumed result is as placeable as an inline
326
- // one; `stepToolRan` is exactly "ran clean").
327
- const askPlaced = await links.placeResults(scope, { toolName, toolCallId, iteration }, { result, modelResult }, stepToolRan);
328
- const askCapped = links.capResults(toolName, askPlaced);
329
- modelResult = askCapped.modelResult;
330
- if (scriptSeen.sourceCapture)
331
- await scriptSeen.sourceCapture(modelResult, {
332
- eligible: stepToolRan && modelResult === askPlaced.modelResult,
322
+ // `modelResult` is only set where the after-tool moment ran; everywhere
323
+ // else the two are the same value.
324
+ if (modelResult === undefined)
325
+ modelResult = result;
326
+ // Placement then the truncation net — the batch loop's precedence,
327
+ // kept on this door (a resumed result is as placeable as an inline
328
+ // one; `stepToolRan` is exactly "ran clean").
329
+ const askPlaced = await links.placeResults(scope, { toolName, toolCallId, iteration }, { result, modelResult }, stepToolRan);
330
+ let askCapped = links.capResults(toolName, askPlaced);
331
+ modelResult = askCapped.modelResult;
332
+ if (scriptSeen.resultFinalizer) {
333
+ const uncapped = modelResult === askPlaced.modelResult;
334
+ const finalized = await (0, resumed_js_1.finalizeResumedResult)(scope, scriptSeen.resultFinalizer, toolName, askCapped, {
335
+ eligible: stepToolRan && uncapped,
336
+ ...(resumeEnvelope?.status !== undefined && { status: resumeEnvelope?.status }),
337
+ ...(!uncapped && { unavailableReason: 'result-capped' }),
338
+ }, links.capResults, negativeResultId);
339
+ askCapped = finalized.values;
340
+ modelResult = askCapped.modelResult;
341
+ if (finalized.refused) {
342
+ result = askCapped.result;
343
+ stepToolRan = false;
344
+ resumeEnvelope = { content: result, effects: [], status: 'invalid', malformed: [] };
345
+ }
346
+ }
347
+ scriptSeen.resultFinalizer?.assertFinalized();
348
+ const sourceHalt = (0, permissions_js_1.sourceEvidenceHaltOf)(scope);
349
+ if (sourceHalt)
350
+ scope.$break(`policy-halt: ${sourceHalt.reason}`);
351
+ let askResultStr = typeof modelResult === 'string' ? modelResult : (0, validators_js_1.safeStringify)(modelResult);
352
+ const askToolChars = askResultStr.length;
353
+ if (deps.negativeClaimsArmed === true)
354
+ askResultStr = (0, capture_js_1.serveNegativeHandle)(scope, negativeResultId, askResultStr);
355
+ // Step boundary (9.18.0) — a result finalized HERE is as final as one
356
+ // from the batch loop; the answered call advances the pointer before
357
+ // the push, exactly as it would have inline.
358
+ if (deps.stepPlanFor && stepToolRan) {
359
+ askResultStr += links.applyStepReturn(scope, { toolName, toolCallId, iteration });
360
+ }
361
+ // Typed tool effects (9.19.0) — a resumed call's envelope is judged
362
+ // exactly as an inline one's (fresh single-call batch state).
363
+ if (resumeEnvelope !== undefined) {
364
+ const askTransition = { losers: [] };
365
+ askResultStr += links.applyToolEffects(scope, { toolName, toolCallId, iteration }, resumeEnvelope, askTransition);
366
+ links.emitTransitionConflict(scope, iteration, askTransition);
367
+ }
368
+ // The batch settlement (9.113.0): the answered call's result, then the
369
+ // siblings the pause left un-dispatched, each settled — never run.
370
+ const askSettlement = links.settleBatch([
371
+ ...scope.history,
372
+ {
373
+ role: 'tool',
374
+ content: askResultStr,
375
+ ...(deps.negativeClaimsArmed === true && { toolChars: askToolChars }),
376
+ toolCallId,
377
+ toolName,
378
+ ...(deps.findings === true && !toolRan && { toolResultOrigin: 'not-entered' }),
379
+ },
380
+ ], { toolName, toolCallId });
381
+ const askHistory = askSettlement.history;
382
+ scope.history = askHistory;
383
+ scope.lastToolResult = {
384
+ toolName,
385
+ result: askResultStr,
386
+ ...(resumeEnvelope?.status !== undefined && { status: resumeEnvelope.status }),
387
+ };
388
+ (0, settle_js_1.appendBatchResult)(scope, {
389
+ toolName,
390
+ result: askResultStr,
391
+ toolCallId,
333
392
  ...(resumeEnvelope?.status !== undefined && { status: resumeEnvelope.status }),
334
393
  });
335
- const sourceHalt = (0, permissions_js_1.sourceEvidenceHaltOf)(scope);
336
- if (sourceHalt)
337
- scope.$break(`policy-halt: ${sourceHalt.reason}`);
338
- let askResultStr = typeof modelResult === 'string' ? modelResult : (0, validators_js_1.safeStringify)(modelResult);
339
- const askToolChars = askResultStr.length;
340
- if (deps.negativeClaimsArmed === true)
341
- askResultStr = (0, capture_js_1.serveNegativeHandle)(scope, negativeResultId, askResultStr);
342
- // Step boundary (9.18.0) — a result finalized HERE is as final as one
343
- // from the batch loop; the answered call advances the pointer before
344
- // the push, exactly as it would have inline.
345
- if (deps.stepPlanFor && stepToolRan) {
346
- askResultStr += links.applyStepReturn(scope, { toolName, toolCallId, iteration });
394
+ await (0, judgeLanded_js_1.judgeLanded)(scope, deps.findingsJudge, toolRan, { toolName, result: askResultStr, toolCallId }, iteration, links.turnStampOf(scope));
395
+ links.fileResumedScript(scope, {
396
+ toolName,
397
+ toolCallId,
398
+ iteration,
399
+ carried: args,
400
+ entered: toolRan,
401
+ seen: scriptSeen,
402
+ });
403
+ links.emitToolEnd(scope, toolName, {
404
+ toolCallId,
405
+ result: askCapped.result,
406
+ durationMs: Date.now() - startMs,
407
+ ...(error === true && { error: true }),
408
+ ...(resumeEnvelope?.status !== undefined && { status: resumeEnvelope.status }),
409
+ ...(askCapped.modelResult !== askCapped.result && {
410
+ modelResult: askCapped.modelResult,
411
+ }),
412
+ }, toolRan, undefined, negativeResultId, args);
413
+ links.bracketSettled(scope, askSettlement);
414
+ (0, typedEmit_js_1.typedEmit)(scope, 'agentfootprint.agent.iteration_end', {
415
+ turnIndex: 0,
416
+ iterIndex: iteration,
417
+ // The brackets THIS leg closed: the answered call's, plus one per
418
+ // settled sibling. The calls before the paused one closed theirs on
419
+ // the leg that paused, which ended in a checkpoint, not here.
420
+ toolCallCount: 1 + askSettlement.settled.length,
421
+ history: askHistory,
422
+ });
423
+ if (deps.inputsLayer === true)
424
+ scope.argumentAsk = undefined;
425
+ scope.iteration = iteration + 1;
426
+ await links.endCall(scope);
427
+ scope.pausedToolCallId = '';
428
+ scope.pausedToolName = '';
429
+ scope.pausedToolStartMs = 0;
430
+ scope.pausedAsk = false;
431
+ scope.pausedAskArgs = undefined;
432
+ scope.pausedAskIndex = undefined;
433
+ scope.pausedAskMiddleware = undefined;
434
+ scope.pausedAskChain = undefined;
435
+ // The request was answered — and spent — by this resume.
436
+ scope.pausedRequest = undefined;
437
+ // Cleared ONLY when it was set: a later component-less pause in this
438
+ // run must not inherit this ask's surface, and a run that never
439
+ // carried one must not gain the key (byte-identical).
440
+ if (answeredVia !== undefined)
441
+ scope.pausedComponentId = undefined;
442
+ // The served party the checkpoint carried is consumed with it (9.92.0);
443
+ // written back only when it was there, so an older checkpoint's resume
444
+ // commits exactly what it always did.
445
+ if (scope.pausedToolParty !== undefined)
446
+ scope.pausedToolParty = undefined;
447
+ return;
347
448
  }
348
- // Typed tool effects (9.19.0) — a resumed call's envelope is judged
349
- // exactly as an inline one's (fresh single-call batch state).
350
- if (resumeEnvelope !== undefined) {
351
- const askTransition = { losers: [] };
352
- askResultStr += links.applyToolEffects(scope, { toolName, toolCallId, iteration }, resumeEnvelope, askTransition);
353
- links.emitTransitionConflict(scope, iteration, askTransition);
449
+ catch (error) {
450
+ scriptSeen.resultFinalizer?.withheld();
451
+ throw error;
452
+ }
453
+ finally {
454
+ scriptSeen.resultFinalizer?.close();
354
455
  }
355
- // The batch settlement (9.113.0): the answered call's result, then the
356
- // siblings the pause left un-dispatched, each settled — never run.
357
- const askSettlement = links.settleBatch([
358
- ...scope.history,
359
- {
360
- role: 'tool',
361
- content: askResultStr,
362
- ...(deps.negativeClaimsArmed === true && { toolChars: askToolChars }),
363
- toolCallId,
364
- toolName,
365
- ...(deps.findings === true && !toolRan && { toolResultOrigin: 'not-entered' }),
366
- },
367
- ], { toolName, toolCallId });
368
- const askHistory = askSettlement.history;
369
- scope.history = askHistory;
370
- scope.lastToolResult = {
371
- toolName,
372
- result: askResultStr,
373
- ...(resumeEnvelope?.status !== undefined && { status: resumeEnvelope.status }),
374
- };
375
- (0, settle_js_1.appendBatchResult)(scope, {
376
- toolName,
377
- result: askResultStr,
378
- toolCallId,
379
- ...(resumeEnvelope?.status !== undefined && { status: resumeEnvelope.status }),
380
- });
381
- await (0, judgeLanded_js_1.judgeLanded)(scope, deps.findingsJudge, toolRan, { toolName, result: askResultStr, toolCallId }, iteration, links.turnStampOf(scope));
382
- links.fileResumedScript(scope, {
383
- toolName,
384
- toolCallId,
385
- iteration,
386
- carried: args,
387
- entered: toolRan,
388
- seen: scriptSeen,
389
- });
390
- links.emitToolEnd(scope, toolName, {
391
- toolCallId,
392
- result: askCapped.result,
393
- durationMs: Date.now() - startMs,
394
- ...(error === true && { error: true }),
395
- ...(resumeEnvelope?.status !== undefined && { status: resumeEnvelope.status }),
396
- ...(askCapped.modelResult !== askCapped.result && {
397
- modelResult: askCapped.modelResult,
398
- }),
399
- }, toolRan, undefined, negativeResultId, args);
400
- links.bracketSettled(scope, askSettlement);
401
- (0, typedEmit_js_1.typedEmit)(scope, 'agentfootprint.agent.iteration_end', {
402
- turnIndex: 0,
403
- iterIndex: iteration,
404
- // The brackets THIS leg closed: the answered call's, plus one per
405
- // settled sibling. The calls before the paused one closed theirs on
406
- // the leg that paused, which ended in a checkpoint, not here.
407
- toolCallCount: 1 + askSettlement.settled.length,
408
- history: askHistory,
409
- });
410
- if (deps.inputsLayer === true)
411
- scope.argumentAsk = undefined;
412
- scope.iteration = iteration + 1;
413
- await links.endCall(scope);
414
- scope.pausedToolCallId = '';
415
- scope.pausedToolName = '';
416
- scope.pausedToolStartMs = 0;
417
- scope.pausedAsk = false;
418
- scope.pausedAskArgs = undefined;
419
- scope.pausedAskIndex = undefined;
420
- scope.pausedAskMiddleware = undefined;
421
- scope.pausedAskChain = undefined;
422
- // The request was answered — and spent — by this resume.
423
- scope.pausedRequest = undefined;
424
- // Cleared ONLY when it was set: a later component-less pause in this
425
- // run must not inherit this ask's surface, and a run that never
426
- // carried one must not gain the key (byte-identical).
427
- if (answeredVia !== undefined)
428
- scope.pausedComponentId = undefined;
429
- // The served party the checkpoint carried is consumed with it (9.92.0);
430
- // written back only when it was there, so an older checkpoint's resume
431
- // commits exactly what it always did.
432
- if (scope.pausedToolParty !== undefined)
433
- scope.pausedToolParty = undefined;
434
- return;
435
456
  };
436
457
  return { resumeAsk };
437
458
  }