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
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.buildCallDispatch = void 0;
4
- const landing_js_1 = require("../../../sourceEvidence/landing.js");
5
4
  const callState_js_1 = require("../access/callState.js");
6
5
  const toolPermission_js_1 = require("../access/toolPermission.js");
7
6
  const capabilityQuestion_js_1 = require("../access/capabilityQuestion.js");
@@ -23,500 +22,474 @@ const deliveredResult_js_1 = require("./deliveredResult.js");
23
22
  const judgeLanded_js_1 = require("../evidence/judgeLanded.js");
24
23
  const skillActivation_js_1 = require("../routing/skillActivation.js");
25
24
  const policyHalt_js_1 = require("../routing/policyHalt.js");
26
- const permissions_js_1 = require("../../../sourceEvidence/permissions.js");
25
+ const finalizeCallResult_js_1 = require("./finalizeCallResult.js");
26
+ const finalization_js_1 = require("../../../resultRowsets/finalization.js");
27
27
  /** Execute one original serial-loop call using the native handler's scope and exact batch references. */
28
28
  function buildCallDispatch(deps, operations) {
29
29
  const dispatchCall = async (scope, tc, callIndex, batch) => {
30
30
  const { emitSecurity, resolved, tool, args, proposedProgram, viewOf, historyForCallbacks, startMs, findingsRefusal, invalidateViews, } = operations.beginDispatchCall(scope, tc, batch.iteration, batch.towers, callIndex, batch.toolCalls, batch.findingsRefusals, batch.frozenTurn, batch.callbackHistory, batch.frozenArgsAt);
31
31
  const { outcome, resolution, runArgs, callArguments, execution } = (0, callState_js_1.prepareCallState)(tc, findingsRefusal, batch.resolutions, batch.inputs, args);
32
- if (!execution.denied && operations.permissionChecker) {
33
- await (0, toolPermission_js_1.checkToolPermission)({
34
- historyForCallbacks,
35
- iteration: batch.iteration,
32
+ execution.resultFinalizer = (0, finalization_js_1.nativeResultFinalizer)(scope, tool, { toolName: tc.name, toolCallId: tc.id, iteration: batch.iteration }, deps, operations.runFactsOf(scope)?.runId, resolved.party);
33
+ try {
34
+ if (!execution.denied && operations.permissionChecker) {
35
+ await (0, toolPermission_js_1.checkToolPermission)({
36
+ historyForCallbacks,
37
+ iteration: batch.iteration,
38
+ permissionChecker: operations.permissionChecker,
39
+ tc,
40
+ viewOf,
41
+ runArgs,
42
+ runIdentity: batch.runIdentity,
43
+ env: batch.env,
44
+ emitSecurity,
45
+ execution,
46
+ outcome,
47
+ });
48
+ }
49
+ const askCapability = (0, capabilityQuestion_js_1.buildCapabilityQuestion)({
36
50
  permissionChecker: operations.permissionChecker,
37
- tc,
38
51
  viewOf,
39
- runArgs,
52
+ historyForCallbacks,
53
+ iteration: batch.iteration,
40
54
  runIdentity: batch.runIdentity,
41
55
  env: batch.env,
42
56
  emitSecurity,
43
- execution,
44
- outcome,
45
- });
46
- }
47
- const askCapability = (0, capabilityQuestion_js_1.buildCapabilityQuestion)({
48
- permissionChecker: operations.permissionChecker,
49
- viewOf,
50
- historyForCallbacks,
51
- iteration: batch.iteration,
52
- runIdentity: batch.runIdentity,
53
- env: batch.env,
54
- emitSecurity,
55
- tc,
56
- callArguments,
57
- execution,
58
- outcome,
59
- });
60
- // ── Declared tool capabilities (9.11.0) ──────────────────────────
61
- // Beside the tool_call gate, at the same layer and before any
62
- // middleware, so an existing checker still decides first. Asked once
63
- // per capability the TOOL declared and the CHECKER governs — either
64
- // side silent and this loop does not run at all, which is why an agent
65
- // that has not opted in is byte-identical.
66
- if (!execution.denied && operations.permissionChecker && tool?.capabilities) {
67
- for (const capability of tool.capabilities) {
68
- if (execution.denied)
69
- break;
70
- if (!(0, types_js_1.checkerGoverns)(operations.permissionChecker, capability))
71
- continue;
72
- await askCapability(capability, tc.name, `Tool '${tc.name}' is not available in this context.`);
73
- }
74
- }
75
- const { argumentGate, consentGate, unmounted } = (0, argumentGate_js_1.prepareArgumentGate)(scope, { tc, tool, iteration: batch.iteration, execution, outcome }, {
76
- unmountedRules: operations.unmountedRules,
77
- warnUnmountedToolPeriod: operations.warnUnmountedToolPeriod,
78
- });
79
- const rulesRefusal = argumentGate.argsRejected
80
- ? undefined
81
- : resolution?.refused ?? (unmounted === undefined ? undefined : await unmounted);
82
- if (!execution.denied && rulesRefusal !== undefined) {
83
- argumentGate.argsRejected = true;
84
- outcome.error = true;
85
- outcome.result = rulesRefusal;
86
- }
87
- // ── The middleware chain ─────────────────────────────────────────
88
- // Walked only for a call the permission gate let through, so an
89
- // existing checker keeps deciding first and a denial there costs
90
- // nothing. A denial from the chain lands as the tool result, exactly
91
- // like every other refusal in this loop — the model reads it and
92
- // adapts. An `ask` commits partial state and pauses, on the same wire
93
- // the check-in gate uses. Never walked for a call whose arguments the
94
- // inputs layer refused (above).
95
- if (!execution.denied &&
96
- !argumentGate.argsRejected &&
97
- deps.toolMiddleware &&
98
- deps.toolMiddleware.length > 0) {
99
- const pause = await (0, middlewareAdmission_js_1.admitMiddlewareCall)(scope, deps, {
100
57
  tc,
101
- tool,
102
- iteration: batch.iteration,
103
58
  callArguments,
104
- historyForCallbacks,
105
- runIdentity: batch.runIdentity,
106
- env: batch.env,
107
- oneQuestionAsked: batch.oneQuestionAsked,
108
- resolved,
109
- decisionLedger: operations.decisionLedger,
110
- inputs: batch.inputs,
111
- invalidateViews,
112
59
  execution,
113
60
  outcome,
114
- askedLayer: batch.askedLayer,
115
- resolution,
116
- assertComponentDeliverable: operations.assertComponentDeliverable,
117
- newHistory: batch.newHistory,
118
- startMs,
119
- fileScript: operations.fileScript,
120
- proposedProgram,
121
- programOfCall: operations.programOfCall,
122
61
  });
123
- if (pause !== undefined)
124
- return { kind: 'paused', pause };
125
- }
126
- // The keys the tool will run with a different value for than the
127
- // model proposed — a link's rewrite, or a key the tool's own
128
- // redaction hides (`../../../../toolShownArgs.ts` · `changedArgKeys`).
129
- // Taken HERE, before anything executes: names only, so nothing the
130
- // tool later writes into its arguments can ride `tool_end`.
131
- const changedKeys = (0, toolShownArgs_js_1.changedArgKeys)(args, (0, toolShownArgs_js_1.shownArgsOf)(tool, callArguments.chainedArgs));
132
- // Tool-args validation (#9) — AFTER the permission gate (policy must
133
- // see every attempted call, valid or not) and BEFORE credential
134
- // resolution (never acquire credentials for a call that won't run).
135
- // On 'enforce' mismatch the tool is NOT executed; the model gets a
136
- // structured retry message as the tool result and corrects its args
137
- // on the next ReAct iteration. Unknown tools keep the existing
138
- // "Unknown tool" path below — validation only applies to resolved
139
- // tools (their inputSchema is the contract the LLM was shown).
140
- // (`argsRejected` is declared above the middleware chain: the inputs
141
- // layer's refusals land in the same shape, before the chain.)
142
- if (!execution.denied && !argumentGate.argsRejected && tool) {
143
- const invalidArgs = operations.argumentRefusal(scope, tool, callArguments.callArgs, {
144
- toolName: tc.name,
145
- toolCallId: tc.id,
146
- iteration: batch.iteration,
62
+ // ── Declared tool capabilities (9.11.0) ──────────────────────────
63
+ // Beside the tool_call gate, at the same layer and before any
64
+ // middleware, so an existing checker still decides first. Asked once
65
+ // per capability the TOOL declared and the CHECKER governs — either
66
+ // side silent and this loop does not run at all, which is why an agent
67
+ // that has not opted in is byte-identical.
68
+ if (!execution.denied && operations.permissionChecker && tool?.capabilities) {
69
+ for (const capability of tool.capabilities) {
70
+ if (execution.denied)
71
+ break;
72
+ if (!(0, types_js_1.checkerGoverns)(operations.permissionChecker, capability))
73
+ continue;
74
+ await askCapability(capability, tc.name, `Tool '${tc.name}' is not available in this context.`);
75
+ }
76
+ }
77
+ const { argumentGate, consentGate, unmounted } = (0, argumentGate_js_1.prepareArgumentGate)(scope, { tc, tool, iteration: batch.iteration, execution, outcome }, {
78
+ unmountedRules: operations.unmountedRules,
79
+ warnUnmountedToolPeriod: operations.warnUnmountedToolPeriod,
147
80
  });
148
- if (invalidArgs !== undefined) {
81
+ const rulesRefusal = argumentGate.argsRejected
82
+ ? undefined
83
+ : resolution?.refused ?? (unmounted === undefined ? undefined : await unmounted);
84
+ if (!execution.denied && rulesRefusal !== undefined) {
149
85
  argumentGate.argsRejected = true;
150
86
  outcome.error = true;
151
- outcome.result = invalidArgs;
152
- }
153
- }
154
- // ── Skill-activation gate (9.11.0) ───────────────────────────────
155
- // `read_skill` activating a skill the policy hides for this role. The
156
- // menu the model reads was already filtered (the Tools slot asks the
157
- // same checker the same question), so this is the second half of one
158
- // rule rather than a second rule: a model that guessed a hidden id, or
159
- // remembered one from an earlier turn, reads the policy's own message.
160
- //
161
- // Ordered AFTER arg validation so the id judged is the one that will
162
- // actually run — a middleware may have rewritten it — and BEFORE
163
- // check-in, credentials and execute, so a refused skill's body is
164
- // never even computed (`surfaceMode: 'tool-only'` returns it from
165
- // `execute`). Off entirely unless the checker declares it governs
166
- // `'skill_read'`.
167
- if (!execution.denied &&
168
- !argumentGate.argsRejected &&
169
- tc.name === 'read_skill' &&
170
- (0, types_js_1.checkerGoverns)(operations.permissionChecker, 'skill_read')) {
171
- const requestedSkillId = callArguments.callArgs.id;
172
- if (typeof requestedSkillId === 'string' && requestedSkillId.length > 0) {
173
- // ── A SELF-CALL AT A MOUNTED CURSOR EXERCISES NO CAPABILITY ───
174
- // (9.86.0.) A MOUNTED cursor's own skill is already served: its
175
- // body is in that call's system prompt and its tools are on that
176
- // call's wire. Asking to read it activates nothing, moves nothing,
177
- // and reveals nothing the request did not already carry — so there
178
- // is no capability here for a policy to grant or deny, and denying
179
- // it told the model its current skill was "not available in this
180
- // context" while it was standing in it. That is the exact sentence
181
- // the self-call arm exists to stop the model reading. The gate's
182
- // self-call arm answers instead.
183
- //
184
- // A PARKED cursor is the one case where the same id is not a
185
- // no-op, and the skip is scoped to exclude it (9.86.0 fix pass):
186
- // parking suppressed the map's contribution, so the dispatch gate
187
- // 480 lines below reads that call as a RE-ENGAGEMENT and serves the
188
- // body and tools again on the next pass. That moves something, so
189
- // the policy keeps the question. `atMountedCursor` is where that
190
- // rule lives; the dispatch gate writes the same rule as two ordered
191
- // arms over the same `parkedNow` set. Every OTHER id still goes
192
- // through the policy, unchanged — this narrows nothing a role could
193
- // see.
194
- const stay = (0, mountedCursor_js_1.atMountedCursor)({
195
- ...(typeof scope.currentSkillId === 'string' && {
196
- cursor: scope.currentSkillId,
197
- }),
198
- target: requestedSkillId,
199
- parked: operations.parkedNow(scope),
200
- });
201
- if (!stay) {
202
- await askCapability('skill_read', (0, skillTarget_js_1.skillTarget)(requestedSkillId), `Skill '${requestedSkillId}' is not available in this context.`);
203
- }
87
+ outcome.result = rulesRefusal;
204
88
  }
205
- }
206
- // ── Check-in gate (evidence-carrying human consent) ──────────────
207
- // Ordered AFTER the permission gate + arg-validation (a call the policy
208
- // denied or that has invalid args never asks a human) and BEFORE
209
- // credential resolution + execute (never acquire credentials for a call
210
- // awaiting consent — that's the whole point of "consent WITH the
211
- // receipts"). Fires ONLY when the tool declared `checkIn` and it trips,
212
- // so tools without the field are byte-identical (no gate, no events, no
213
- // pause). Rides the EXISTING pause machinery: returning a defined value
214
- // triggers the footprintjs checkpoint, exactly like `pauseHere`.
215
- if (!execution.denied &&
216
- !argumentGate.argsRejected &&
217
- tool &&
218
- tool.checkIn !== undefined &&
219
- deps.checkIn) {
220
- const pause = await (0, checkInAdmission_js_1.admitCheckInCall)(scope, deps, {
221
- historyForCheckIn: operations.historyForCheckIn,
222
- historyForCallbacks,
223
- tool,
224
- viewOf,
225
- callArguments,
226
- iteration: batch.iteration,
227
- tc,
228
- askedLayer: batch.askedLayer,
229
- resolved,
230
- decisionLedger: operations.decisionLedger,
231
- consentGate,
232
- outcome,
233
- resolution,
234
- assertComponentDeliverable: operations.assertComponentDeliverable,
235
- env: batch.env,
236
- newHistory: batch.newHistory,
237
- startMs,
238
- fileScript: operations.fileScript,
239
- proposedProgram,
240
- programOfCall: operations.programOfCall,
241
- });
242
- if (pause !== undefined)
243
- return { kind: 'paused', pause };
244
- }
245
- if (!execution.denied && !argumentGate.argsRejected && !consentGate.checkInRefused) {
246
- const wanted = {
247
- // ── Declared artifact arguments (9.22.0) ──────────────────────
248
- // The `needs` precedent applied to data: resolve the tool's
249
- // declared `wants` refs BEFORE credential resolution (never
250
- // acquire credentials for a call that won't run) and BEFORE
251
- // execute — a stale/unknown/wrong-kind ref never reaches the
252
- // tool; the model reads a teaching refusal listing the live refs
253
- // of the wanted kind. On success `callArgs` carries the RESOLVED
254
- // DATA and `ctx.wanted` the claim tickets. Tools without `wants`
255
- // take the exact path they always took.
256
- wantedMeta: undefined,
257
- wantsBlocked: false,
258
- };
259
- if (tool?.wants !== undefined) {
260
- await (0, wantedArguments_js_1.admitWantedArguments)(scope, {
261
- resolveWantsAtDispatch: operations.resolveWantsAtDispatch,
89
+ // ── The middleware chain ─────────────────────────────────────────
90
+ // Walked only for a call the permission gate let through, so an
91
+ // existing checker keeps deciding first and a denial there costs
92
+ // nothing. A denial from the chain lands as the tool result, exactly
93
+ // like every other refusal in this loop — the model reads it and
94
+ // adapts. An `ask` commits partial state and pauses, on the same wire
95
+ // the check-in gate uses. Never walked for a call whose arguments the
96
+ // inputs layer refused (above).
97
+ if (!execution.denied &&
98
+ !argumentGate.argsRejected &&
99
+ deps.toolMiddleware &&
100
+ deps.toolMiddleware.length > 0) {
101
+ const pause = await (0, middlewareAdmission_js_1.admitMiddlewareCall)(scope, deps, {
262
102
  tc,
263
103
  tool,
104
+ iteration: batch.iteration,
264
105
  callArguments,
265
- wanted,
266
- outcome,
267
- });
268
- }
269
- const authorization = {
270
- // Declare-and-push: resolve the tool's declared credential BEFORE
271
- // invoking, and inject it as ctx.credential. On consent-required or
272
- // failure, surface the reason to the LLM (tool result) + emit; the
273
- // tool does NOT run (fail-closed — never half-authed; a denial that
274
- // throws is surfaced, not retried).
275
- resolvedCredential: undefined,
276
- credentialBlocked: false,
277
- };
278
- const need = wanted.wantsBlocked ? undefined : tool?.needs;
279
- if (need) {
280
- const pause = await (0, credentialAdmission_js_1.admitToolCredential)(scope, deps, {
281
- emitSecurity,
282
- need,
283
- credentialsIn: operations.credentialsIn,
106
+ historyForCallbacks,
284
107
  runIdentity: batch.runIdentity,
285
- authorization,
286
- onAuthorizationRequired: operations.onAuthorizationRequired,
108
+ env: batch.env,
287
109
  oneQuestionAsked: batch.oneQuestionAsked,
110
+ resolved,
111
+ decisionLedger: operations.decisionLedger,
112
+ inputs: batch.inputs,
113
+ invalidateViews,
114
+ execution,
115
+ outcome,
116
+ askedLayer: batch.askedLayer,
117
+ resolution,
118
+ assertComponentDeliverable: operations.assertComponentDeliverable,
288
119
  newHistory: batch.newHistory,
289
- tc,
290
120
  startMs,
291
- callArguments,
292
- resolved,
293
121
  fileScript: operations.fileScript,
294
- tool,
295
- iteration: batch.iteration,
296
122
  proposedProgram,
297
123
  programOfCall: operations.programOfCall,
298
- outcome,
299
- askedLayer: batch.askedLayer,
300
- resolution,
301
124
  });
302
125
  if (pause !== undefined)
303
126
  return { kind: 'paused', pause };
304
127
  }
305
- if (!authorization.credentialBlocked && !wanted.wantsBlocked) {
306
- const pause = await (0, initialInvocation_js_1.invokeInitialTool)(scope, deps, {
307
- tool,
308
- resolved,
309
- tc,
310
- dispatchRoster: operations.dispatchRoster,
311
- noteOffWire: operations.noteOffWire,
128
+ // The keys the tool will run with a different value for than the
129
+ // model proposed — a link's rewrite, or a key the tool's own
130
+ // redaction hides (`../../../../toolShownArgs.ts` · `changedArgKeys`).
131
+ // Taken HERE, before anything executes: names only, so nothing the
132
+ // tool later writes into its arguments can ride `tool_end`.
133
+ const changedKeys = (0, toolShownArgs_js_1.changedArgKeys)(args, (0, toolShownArgs_js_1.shownArgsOf)(tool, callArguments.chainedArgs));
134
+ // Tool-args validation (#9) — AFTER the permission gate (policy must
135
+ // see every attempted call, valid or not) and BEFORE credential
136
+ // resolution (never acquire credentials for a call that won't run).
137
+ // On 'enforce' mismatch the tool is NOT executed; the model gets a
138
+ // structured retry message as the tool result and corrects its args
139
+ // on the next ReAct iteration. Unknown tools keep the existing
140
+ // "Unknown tool" path below — validation only applies to resolved
141
+ // tools (their inputSchema is the contract the LLM was shown).
142
+ // (`argsRejected` is declared above the middleware chain: the inputs
143
+ // layer's refusals land in the same shape, before the chain.)
144
+ if (!execution.denied && !argumentGate.argsRejected && tool) {
145
+ const invalidArgs = operations.argumentRefusal(scope, tool, callArguments.callArgs, {
146
+ toolName: tc.name,
147
+ toolCallId: tc.id,
312
148
  iteration: batch.iteration,
149
+ });
150
+ if (invalidArgs !== undefined) {
151
+ argumentGate.argsRejected = true;
152
+ outcome.error = true;
153
+ outcome.result = invalidArgs;
154
+ }
155
+ }
156
+ // ── Skill-activation gate (9.11.0) ───────────────────────────────
157
+ // `read_skill` activating a skill the policy hides for this role. The
158
+ // menu the model reads was already filtered (the Tools slot asks the
159
+ // same checker the same question), so this is the second half of one
160
+ // rule rather than a second rule: a model that guessed a hidden id, or
161
+ // remembered one from an earlier turn, reads the policy's own message.
162
+ //
163
+ // Ordered AFTER arg validation so the id judged is the one that will
164
+ // actually run — a middleware may have rewritten it — and BEFORE
165
+ // check-in, credentials and execute, so a refused skill's body is
166
+ // never even computed (`surfaceMode: 'tool-only'` returns it from
167
+ // `execute`). Off entirely unless the checker declares it governs
168
+ // `'skill_read'`.
169
+ if (!execution.denied &&
170
+ !argumentGate.argsRejected &&
171
+ tc.name === 'read_skill' &&
172
+ (0, types_js_1.checkerGoverns)(operations.permissionChecker, 'skill_read')) {
173
+ const requestedSkillId = callArguments.callArgs.id;
174
+ if (typeof requestedSkillId === 'string' && requestedSkillId.length > 0) {
175
+ // ── A SELF-CALL AT A MOUNTED CURSOR EXERCISES NO CAPABILITY ───
176
+ // (9.86.0.) A MOUNTED cursor's own skill is already served: its
177
+ // body is in that call's system prompt and its tools are on that
178
+ // call's wire. Asking to read it activates nothing, moves nothing,
179
+ // and reveals nothing the request did not already carry — so there
180
+ // is no capability here for a policy to grant or deny, and denying
181
+ // it told the model its current skill was "not available in this
182
+ // context" while it was standing in it. That is the exact sentence
183
+ // the self-call arm exists to stop the model reading. The gate's
184
+ // self-call arm answers instead.
185
+ //
186
+ // A PARKED cursor is the one case where the same id is not a
187
+ // no-op, and the skip is scoped to exclude it (9.86.0 fix pass):
188
+ // parking suppressed the map's contribution, so the dispatch gate
189
+ // 480 lines below reads that call as a RE-ENGAGEMENT and serves the
190
+ // body and tools again on the next pass. That moves something, so
191
+ // the policy keeps the question. `atMountedCursor` is where that
192
+ // rule lives; the dispatch gate writes the same rule as two ordered
193
+ // arms over the same `parkedNow` set. Every OTHER id still goes
194
+ // through the policy, unchanged — this narrows nothing a role could
195
+ // see.
196
+ const stay = (0, mountedCursor_js_1.atMountedCursor)({
197
+ ...(typeof scope.currentSkillId === 'string' && {
198
+ cursor: scope.currentSkillId,
199
+ }),
200
+ target: requestedSkillId,
201
+ parked: operations.parkedNow(scope),
202
+ });
203
+ if (!stay) {
204
+ await askCapability('skill_read', (0, skillTarget_js_1.skillTarget)(requestedSkillId), `Skill '${requestedSkillId}' is not available in this context.`);
205
+ }
206
+ }
207
+ }
208
+ // ── Check-in gate (evidence-carrying human consent) ──────────────
209
+ // Ordered AFTER the permission gate + arg-validation (a call the policy
210
+ // denied or that has invalid args never asks a human) and BEFORE
211
+ // credential resolution + execute (never acquire credentials for a call
212
+ // awaiting consent — that's the whole point of "consent WITH the
213
+ // receipts"). Fires ONLY when the tool declared `checkIn` and it trips,
214
+ // so tools without the field are byte-identical (no gate, no events, no
215
+ // pause). Rides the EXISTING pause machinery: returning a defined value
216
+ // triggers the footprintjs checkpoint, exactly like `pauseHere`.
217
+ if (!execution.denied &&
218
+ !argumentGate.argsRejected &&
219
+ tool &&
220
+ tool.checkIn !== undefined &&
221
+ deps.checkIn) {
222
+ const pause = await (0, checkInAdmission_js_1.admitCheckInCall)(scope, deps, {
223
+ historyForCheckIn: operations.historyForCheckIn,
224
+ historyForCallbacks,
225
+ tool,
226
+ viewOf,
313
227
  callArguments,
314
- env: batch.env,
315
- credentialsIn: operations.credentialsIn,
316
- emitSecurity,
317
- hasCredentials: operations.hasCredentials,
318
- authorization,
319
- toolArtifacts: operations.toolArtifacts,
320
- wanted,
321
- toolProgress: operations.toolProgress,
322
- sessionContext: operations.sessionContext,
323
- toolDispatchCtx: operations.toolDispatchCtx,
324
- searchFunnel: operations.searchFunnel,
325
- execution,
326
- runFactsOf: operations.runFactsOf,
327
- programOfCall: operations.programOfCall,
228
+ iteration: batch.iteration,
229
+ tc,
230
+ askedLayer: batch.askedLayer,
231
+ resolved,
232
+ decisionLedger: operations.decisionLedger,
233
+ consentGate,
328
234
  outcome,
329
- takeCodeRun: operations.takeCodeRun,
330
- warnEffect: operations.warnEffect,
331
- declareCoverage: operations.declareCoverage,
332
- declareSemantics: operations.declareSemantics,
333
- refuseOverCeiling: operations.refuseOverCeiling,
334
- judgeColumns: operations.judgeColumns,
335
- endCall: operations.endCall,
336
- oneQuestionAsked: batch.oneQuestionAsked,
235
+ resolution,
337
236
  assertComponentDeliverable: operations.assertComponentDeliverable,
237
+ env: batch.env,
338
238
  newHistory: batch.newHistory,
339
239
  startMs,
340
- declareRaisedAbsence: operations.declareRaisedAbsence,
341
240
  fileScript: operations.fileScript,
342
241
  proposedProgram,
343
- askedLayer: batch.askedLayer,
344
- resolution,
242
+ programOfCall: operations.programOfCall,
345
243
  });
346
244
  if (pause !== undefined)
347
245
  return { kind: 'paused', pause };
348
246
  }
349
- }
350
- const skillRoute = {
351
- // ── Skill-graph read_skill GATE ────────────────────────
352
- // Reject a read_skill jump OUTSIDE the reachable set from the current
353
- // cursor: replace the result with a re-prompt naming the allowed ids (so
354
- // the model re-picks) and skip the activation below — cursor + activations
355
- // stay unchanged. Off when no skillGraph (deps.allowedSkillIds undefined),
356
- // so plain read_skill agents are byte-for-byte unaffected.
357
- //
358
- // The allowed set is two kinds of id, and the difference is the whole
359
- // design (8.4.0): a HOP — a skill the graph routes, reachable from where
360
- // the cursor stands — and an OPEN skill, one the graph never wires (a
361
- // `.selfExplain()` debug skill, a `.skill()` registered beside the graph,
362
- // a skill listed in `skills[]` and wired to nothing). Both activate; only a
363
- // hop moves the cursor. Before 8.4.0 the open ones were offered in
364
- // read_skill's own menu and then rejected on every single call — the
365
- // library refused its own flagship debug feature under its own routing
366
- // feature, and the model could burn a whole run re-asking.
367
- skillRejected: false,
368
- skillHop: false,
369
- };
370
- (0, readSkillRoute_js_1.applyReadSkillRoute)(scope, deps, {
371
- tc,
372
- iteration: batch.iteration,
373
- parkedNow: operations.parkedNow,
374
- noteSkillRefusal: operations.noteSkillRefusal,
375
- outcome,
376
- execution,
377
- callArguments,
378
- skillRoute,
379
- });
380
- // ── skip_step bookkeeping (9.18.0) ─────────────────────────────
381
- // Same block as the read_skill gate, same mechanism: the stage
382
- // OVERWRITES the tool's placeholder with the authoritative sentence
383
- // BEFORE the after-tool moment, so governance rules and the cap
384
- // compose over what the model will actually read, on both channels.
385
- // Postures never gate it — skipping is judgment inside a step, not
386
- // routing. Zero-cost gate: `stepPlanFor` is undefined on every agent
387
- // without a stepped skill.
388
- if (operations.frameworkSkipStepAnswered(tc.name, tool) &&
389
- !outcome.error &&
390
- !execution.denied) {
391
- outcome.result = operations.applySkipStep(scope, {
392
- args: callArguments.callArgs,
393
- toolCallId: tc.id,
247
+ if (!execution.denied && !argumentGate.argsRejected && !consentGate.checkInRefused) {
248
+ const wanted = {
249
+ // ── Declared artifact arguments (9.22.0) ──────────────────────
250
+ // The `needs` precedent applied to data: resolve the tool's
251
+ // declared `wants` refs BEFORE credential resolution (never
252
+ // acquire credentials for a call that won't run) and BEFORE
253
+ // execute — a stale/unknown/wrong-kind ref never reaches the
254
+ // tool; the model reads a teaching refusal listing the live refs
255
+ // of the wanted kind. On success `callArgs` carries the RESOLVED
256
+ // DATA and `ctx.wanted` the claim tickets. Tools without `wants`
257
+ // take the exact path they always took.
258
+ wantedMeta: undefined,
259
+ wantsBlocked: false,
260
+ };
261
+ if (tool?.wants !== undefined) {
262
+ await (0, wantedArguments_js_1.admitWantedArguments)(scope, {
263
+ resolveWantsAtDispatch: operations.resolveWantsAtDispatch,
264
+ tc,
265
+ tool,
266
+ callArguments,
267
+ wanted,
268
+ outcome,
269
+ });
270
+ }
271
+ const authorization = {
272
+ // Declare-and-push: resolve the tool's declared credential BEFORE
273
+ // invoking, and inject it as ctx.credential. On consent-required or
274
+ // failure, surface the reason to the LLM (tool result) + emit; the
275
+ // tool does NOT run (fail-closed — never half-authed; a denial that
276
+ // throws is surfaced, not retried).
277
+ resolvedCredential: undefined,
278
+ credentialBlocked: false,
279
+ };
280
+ const need = wanted.wantsBlocked ? undefined : tool?.needs;
281
+ if (need) {
282
+ const pause = await (0, credentialAdmission_js_1.admitToolCredential)(scope, deps, {
283
+ emitSecurity,
284
+ need,
285
+ credentialsIn: operations.credentialsIn,
286
+ runIdentity: batch.runIdentity,
287
+ authorization,
288
+ onAuthorizationRequired: operations.onAuthorizationRequired,
289
+ oneQuestionAsked: batch.oneQuestionAsked,
290
+ newHistory: batch.newHistory,
291
+ tc,
292
+ startMs,
293
+ callArguments,
294
+ resolved,
295
+ fileScript: operations.fileScript,
296
+ tool,
297
+ iteration: batch.iteration,
298
+ proposedProgram,
299
+ programOfCall: operations.programOfCall,
300
+ outcome,
301
+ askedLayer: batch.askedLayer,
302
+ resolution,
303
+ });
304
+ if (pause !== undefined)
305
+ return { kind: 'paused', pause };
306
+ }
307
+ if (!authorization.credentialBlocked && !wanted.wantsBlocked) {
308
+ const pause = await (0, initialInvocation_js_1.invokeInitialTool)(scope, deps, {
309
+ tool,
310
+ resolved,
311
+ tc,
312
+ dispatchRoster: operations.dispatchRoster,
313
+ noteOffWire: operations.noteOffWire,
314
+ iteration: batch.iteration,
315
+ callArguments,
316
+ env: batch.env,
317
+ credentialsIn: operations.credentialsIn,
318
+ emitSecurity,
319
+ hasCredentials: operations.hasCredentials,
320
+ authorization,
321
+ toolArtifacts: operations.toolArtifacts,
322
+ wanted,
323
+ toolProgress: operations.toolProgress,
324
+ sessionContext: operations.sessionContext,
325
+ toolDispatchCtx: operations.toolDispatchCtx,
326
+ searchFunnel: operations.searchFunnel,
327
+ execution,
328
+ runFactsOf: operations.runFactsOf,
329
+ programOfCall: operations.programOfCall,
330
+ outcome,
331
+ takeCodeRun: operations.takeCodeRun,
332
+ warnEffect: operations.warnEffect,
333
+ declareCoverage: operations.declareCoverage,
334
+ declareSemantics: operations.declareSemantics,
335
+ refuseOverCeiling: operations.refuseOverCeiling,
336
+ judgeColumns: operations.judgeColumns,
337
+ endCall: operations.endCall,
338
+ oneQuestionAsked: batch.oneQuestionAsked,
339
+ assertComponentDeliverable: operations.assertComponentDeliverable,
340
+ newHistory: batch.newHistory,
341
+ startMs,
342
+ declareRaisedAbsence: operations.declareRaisedAbsence,
343
+ fileScript: operations.fileScript,
344
+ proposedProgram,
345
+ askedLayer: batch.askedLayer,
346
+ resolution,
347
+ });
348
+ if (pause !== undefined)
349
+ return { kind: 'paused', pause };
350
+ }
351
+ }
352
+ const skillRoute = {
353
+ // ── Skill-graph read_skill GATE ────────────────────────
354
+ // Reject a read_skill jump OUTSIDE the reachable set from the current
355
+ // cursor: replace the result with a re-prompt naming the allowed ids (so
356
+ // the model re-picks) and skip the activation below — cursor + activations
357
+ // stay unchanged. Off when no skillGraph (deps.allowedSkillIds undefined),
358
+ // so plain read_skill agents are byte-for-byte unaffected.
359
+ //
360
+ // The allowed set is two kinds of id, and the difference is the whole
361
+ // design (8.4.0): a HOP — a skill the graph routes, reachable from where
362
+ // the cursor stands — and an OPEN skill, one the graph never wires (a
363
+ // `.selfExplain()` debug skill, a `.skill()` registered beside the graph,
364
+ // a skill listed in `skills[]` and wired to nothing). Both activate; only a
365
+ // hop moves the cursor. Before 8.4.0 the open ones were offered in
366
+ // read_skill's own menu and then rejected on every single call — the
367
+ // library refused its own flagship debug feature under its own routing
368
+ // feature, and the model could burn a whole run re-asking.
369
+ skillRejected: false,
370
+ skillHop: false,
371
+ };
372
+ (0, readSkillRoute_js_1.applyReadSkillRoute)(scope, deps, {
373
+ tc,
394
374
  iteration: batch.iteration,
375
+ parkedNow: operations.parkedNow,
376
+ noteSkillRefusal: operations.noteSkillRefusal,
377
+ outcome,
378
+ execution,
379
+ callArguments,
380
+ skillRoute,
395
381
  });
396
- }
397
- // ── present bookkeeping (9.22.0) ───────────────────────────────
398
- // Same mechanism as skip_step: the auto-attached placeholder ran;
399
- // the stage overwrites its result with the description snapshot (or
400
- // the teaching refusal) BEFORE the after-tool moment, so governance
401
- // and the caps compose over what the model will actually read. A
402
- // miss is an errored call: the model holds no presentation, and a
403
- // procedure step whose tool presented nothing must not advance.
404
- if (deps.artifactStore &&
405
- tc.name === present_js_1.PRESENT_TOOL_NAME &&
406
- execution.executed &&
407
- !outcome.error &&
408
- !execution.denied) {
409
- const presented = await operations.applyPresent(scope, {
410
- args: callArguments.callArgs,
411
- toolCallId: tc.id,
412
- iteration: batch.iteration,
382
+ // ── skip_step bookkeeping (9.18.0) ─────────────────────────────
383
+ // Same block as the read_skill gate, same mechanism: the stage
384
+ // OVERWRITES the tool's placeholder with the authoritative sentence
385
+ // BEFORE the after-tool moment, so governance rules and the cap
386
+ // compose over what the model will actually read, on both channels.
387
+ // Postures never gate it — skipping is judgment inside a step, not
388
+ // routing. Zero-cost gate: `stepPlanFor` is undefined on every agent
389
+ // without a stepped skill.
390
+ if (operations.frameworkSkipStepAnswered(tc.name, tool) &&
391
+ !outcome.error &&
392
+ !execution.denied) {
393
+ outcome.result = operations.applySkipStep(scope, {
394
+ args: callArguments.callArgs,
395
+ toolCallId: tc.id,
396
+ iteration: batch.iteration,
397
+ });
398
+ }
399
+ // ── present bookkeeping (9.22.0) ───────────────────────────────
400
+ // Same mechanism as skip_step: the auto-attached placeholder ran;
401
+ // the stage overwrites its result with the description snapshot (or
402
+ // the teaching refusal) BEFORE the after-tool moment, so governance
403
+ // and the caps compose over what the model will actually read. A
404
+ // miss is an errored call: the model holds no presentation, and a
405
+ // procedure step whose tool presented nothing must not advance.
406
+ if (deps.artifactStore &&
407
+ tc.name === present_js_1.PRESENT_TOOL_NAME &&
408
+ execution.executed &&
409
+ !outcome.error &&
410
+ !execution.denied) {
411
+ const presented = await operations.applyPresent(scope, {
412
+ args: callArguments.callArgs,
413
+ toolCallId: tc.id,
414
+ iteration: batch.iteration,
415
+ });
416
+ outcome.result = presented.text;
417
+ if (!presented.ok)
418
+ outcome.error = true;
419
+ }
420
+ const { capped, modelResult } = await (0, finalizeCallResult_js_1.finalizeCallResult)(scope, operations, {
421
+ tool,
422
+ tc,
423
+ batch,
424
+ callArguments,
425
+ execution,
426
+ outcome,
427
+ sourceEvidenceArmed: deps.sourceEvidenceConfig !== undefined,
413
428
  });
414
- outcome.result = presented.text;
415
- if (!presented.ok)
416
- outcome.error = true;
417
- }
418
- // ── The after-tool moment ────────────────────────────────────────
419
- // Last thing before the result becomes history, and only for a call
420
- // that ran. `modelResult` is what the model reads; `result` stays the
421
- // truth about the tool and is what `stream.tool_end` reports.
422
- const rawModelResult = execution.executed
423
- ? await operations.afterMoment(scope, {
424
- ...(tool && { tool }),
425
- toolName: tc.name,
426
- toolCallId: tc.id,
427
- iteration: batch.iteration,
428
- args: callArguments.callArgs,
429
- result: outcome.result,
430
- negativeResultId: execution.negativeDispatch?.resultId,
431
- ...(execution.sourceCapture && { onSourceWithheld: execution.sourceCapture.withheld }),
432
- ...(outcome.error === true && { error: true }),
433
- history: batch.newHistory,
434
- ...(batch.runIdentity && { identity: batch.runIdentity }),
435
- ...(batch.env.signal && { signal: batch.env.signal }),
436
- })
437
- : outcome.result;
438
- if (deps.sourceEvidenceConfig !== undefined && (0, permissions_js_1.sourceEvidenceHaltOf)(scope) !== undefined) {
439
- execution.denied = true;
440
- execution.haltContext = (0, permissions_js_1.sourceEvidenceHaltOf)(scope);
441
- }
442
- // Placement next (9.22.0) — the operator's ref-ing, judged on what
443
- // the chain let through (a rule that already summarized a huge
444
- // result is measured on what it produced, the same reasoning as the
445
- // cap). Over the threshold, the payload is checked into the store
446
- // and BOTH channels carry the ticket; the truncation net below then
447
- // measures the ticket. A refused/denied/errored call is never
448
- // placed: a refusal is already short, and 'tool-result/<name>' must
449
- // never claim an error is the tool's result.
450
- const placedValues = await operations.placeResults(scope, { toolName: tc.name, toolCallId: tc.id, iteration: batch.iteration }, { result: outcome.result, modelResult: rawModelResult }, execution.executed && !outcome.error && !execution.denied && !execution.ceilingRefused);
451
- // The write seam (9.77.0) — judged on `result`, the tool's own answer,
452
- // and on `newHistory`, which at this point holds every earlier tool
453
- // result and not yet this one. Same guard the placement decision uses:
454
- // a call that did not run, errored, was denied or had its payload
455
- // refused has no lookup answer to read.
456
- operations.noticeEmptyLookup(scope, { toolName: tc.name, toolCallId: tc.id, iteration: batch.iteration }, callArguments.callArgs, outcome.result, batch.newHistory, execution.executed && !outcome.error && !execution.denied && !execution.ceilingRefused);
457
- // The ceiling, last — after the tool, after the chain. A rule that
458
- // already summarized a huge result is measured on what it produced, so
459
- // the cap composes with governance rather than pre-empting it.
460
- const capped = operations.capResults(tc.name, placedValues);
461
- const modelResult = capped.modelResult;
462
- if (execution.sourceCapture)
463
- await execution.sourceCapture(modelResult, (0, landing_js_1.sourceLanding)(execution, outcome, capped.modelResult === placedValues.modelResult));
464
- const durationMs = Date.now() - startMs;
465
- (0, callSettlement_js_1.recordCallSettlement)(scope, {
466
- fileScript: operations.fileScript,
467
- tool,
468
- tc,
469
- iteration: batch.iteration,
470
- proposedProgram,
471
- execution,
472
- programOfCall: operations.programOfCall,
473
- callArguments,
474
- emitToolEnd: operations.emitToolEnd,
475
- capped,
476
- durationMs,
477
- outcome,
478
- modelResult,
479
- changedKeys,
480
- });
481
- const delivery = {
482
- resultStr: typeof modelResult === 'string' ? modelResult : (0, validators_js_1.safeStringify)(modelResult),
483
- };
484
- (0, deliveredResult_js_1.landCallResult)(scope, deps, {
485
- delivery,
486
- execution,
487
- tc,
488
- outcome,
489
- skillRoute,
490
- callArguments,
491
- readSkillStepIntroFor: operations.readSkillStepIntroFor,
492
- applyStepReturn: operations.applyStepReturn,
493
- iteration: batch.iteration,
494
- applyToolEffects: operations.applyToolEffects,
495
- transitionState: batch.transitionState,
496
- runFactsOf: operations.runFactsOf,
497
- tool,
498
- repeatLedgers: operations.repeatLedgers,
499
- inputs: batch.inputs,
500
- resolution,
501
- args,
502
- noteOptionsFor: operations.noteOptionsFor,
503
- newHistory: batch.newHistory,
504
- batchResults: batch.batchResults,
505
- });
506
- await (0, judgeLanded_js_1.judgeLanded)(scope, deps.findingsJudge, execution.executed && !execution.denied && !skillRoute.skillRejected, { toolName: tc.name, result: delivery.resultStr, toolCallId: tc.id }, batch.iteration, operations.turnStampOf(scope));
507
- (0, skillActivation_js_1.activateLandedSkill)(scope, deps, { tc, outcome, execution, skillRoute, callArguments });
508
- if (execution.haltContext) {
509
- (0, policyHalt_js_1.haltLandedCall)(scope, {
510
- haltContext: execution.haltContext,
511
- emitSecurity,
429
+ const durationMs = Date.now() - startMs;
430
+ (0, callSettlement_js_1.recordCallSettlement)(scope, {
431
+ fileScript: operations.fileScript,
432
+ tool,
512
433
  tc,
513
- newHistory: batch.newHistory,
514
434
  iteration: batch.iteration,
435
+ proposedProgram,
436
+ execution,
437
+ programOfCall: operations.programOfCall,
438
+ callArguments,
439
+ emitToolEnd: operations.emitToolEnd,
440
+ capped,
441
+ durationMs,
442
+ outcome,
443
+ modelResult,
444
+ changedKeys,
445
+ });
446
+ const delivery = {
447
+ resultStr: typeof modelResult === 'string' ? modelResult : (0, validators_js_1.safeStringify)(modelResult),
448
+ };
449
+ (0, deliveredResult_js_1.landCallResult)(scope, deps, {
450
+ delivery,
451
+ execution,
452
+ tc,
453
+ outcome,
454
+ skillRoute,
515
455
  callArguments,
456
+ readSkillStepIntroFor: operations.readSkillStepIntroFor,
457
+ applyStepReturn: operations.applyStepReturn,
458
+ iteration: batch.iteration,
459
+ applyToolEffects: operations.applyToolEffects,
460
+ transitionState: batch.transitionState,
461
+ runFactsOf: operations.runFactsOf,
462
+ tool,
463
+ repeatLedgers: operations.repeatLedgers,
464
+ inputs: batch.inputs,
465
+ resolution,
466
+ args,
467
+ noteOptionsFor: operations.noteOptionsFor,
468
+ newHistory: batch.newHistory,
469
+ batchResults: batch.batchResults,
516
470
  });
517
- return { kind: 'halted' };
471
+ await (0, judgeLanded_js_1.judgeLanded)(scope, deps.findingsJudge, execution.executed && !execution.denied && !skillRoute.skillRejected, { toolName: tc.name, result: delivery.resultStr, toolCallId: tc.id }, batch.iteration, operations.turnStampOf(scope));
472
+ (0, skillActivation_js_1.activateLandedSkill)(scope, deps, { tc, outcome, execution, skillRoute, callArguments });
473
+ if (execution.haltContext) {
474
+ (0, policyHalt_js_1.haltLandedCall)(scope, {
475
+ haltContext: execution.haltContext,
476
+ emitSecurity,
477
+ tc,
478
+ newHistory: batch.newHistory,
479
+ iteration: batch.iteration,
480
+ callArguments,
481
+ });
482
+ return { kind: 'halted' };
483
+ }
484
+ return { kind: 'landed' };
485
+ }
486
+ catch (error) {
487
+ execution.resultFinalizer?.withheld();
488
+ throw error;
489
+ }
490
+ finally {
491
+ execution.resultFinalizer?.close();
518
492
  }
519
- return { kind: 'landed' };
520
493
  };
521
494
  return dispatchCall;
522
495
  }