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