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