agentfootprint 9.136.0 → 9.138.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 (576) hide show
  1. package/AGENTS.md +1 -1
  2. package/CAPABILITIES.md +5 -0
  3. package/ai-instructions/claude-code/SKILL.md +1 -1
  4. package/dist/adapters/llm/AnthropicProvider.js +10 -2
  5. package/dist/adapters/llm/AnthropicProvider.js.map +1 -1
  6. package/dist/adapters/llm/BrowserAnthropicProvider.js +8 -0
  7. package/dist/adapters/llm/BrowserAnthropicProvider.js.map +1 -1
  8. package/dist/adapters/llm/BrowserOpenAIProvider.js +30 -0
  9. package/dist/adapters/llm/BrowserOpenAIProvider.js.map +1 -1
  10. package/dist/adapters/llm/FoundryProvider.js +2 -0
  11. package/dist/adapters/llm/FoundryProvider.js.map +1 -1
  12. package/dist/adapters/llm/InvokeModelGatewayProvider.js +16 -0
  13. package/dist/adapters/llm/InvokeModelGatewayProvider.js.map +1 -1
  14. package/dist/adapters/llm/MockProvider.js +3 -0
  15. package/dist/adapters/llm/MockProvider.js.map +1 -1
  16. package/dist/adapters/llm/OllamaProvider.js +7 -0
  17. package/dist/adapters/llm/OllamaProvider.js.map +1 -1
  18. package/dist/adapters/llm/OpenAIProvider.js +25 -0
  19. package/dist/adapters/llm/OpenAIProvider.js.map +1 -1
  20. package/dist/adapters/llm/anthropicCacheWire.js +32 -10
  21. package/dist/adapters/llm/anthropicCacheWire.js.map +1 -1
  22. package/dist/adapters/llm/anthropicMessagesWire.js +12 -11
  23. package/dist/adapters/llm/anthropicMessagesWire.js.map +1 -1
  24. package/dist/adapters/types.js.map +1 -1
  25. package/dist/bridge/eventMeta.js +5 -1
  26. package/dist/bridge/eventMeta.js.map +1 -1
  27. package/dist/bridge/eventSourcePosition.js +63 -0
  28. package/dist/bridge/eventSourcePosition.js.map +1 -0
  29. package/dist/cache/CacheDecisionSubflow.js +79 -21
  30. package/dist/cache/CacheDecisionSubflow.js.map +1 -1
  31. package/dist/cache/cacheStrategyFor.js +77 -0
  32. package/dist/cache/cacheStrategyFor.js.map +1 -0
  33. package/dist/cache/index.js +26 -38
  34. package/dist/cache/index.js.map +1 -1
  35. package/dist/cache/strategies/AutomaticCacheStrategy.js +47 -0
  36. package/dist/cache/strategies/AutomaticCacheStrategy.js.map +1 -0
  37. package/dist/cache/strategies/BreakpointCacheStrategy.js +60 -0
  38. package/dist/cache/strategies/BreakpointCacheStrategy.js.map +1 -0
  39. package/dist/cache/strategies/NoOpCacheStrategy.js +9 -25
  40. package/dist/cache/strategies/NoOpCacheStrategy.js.map +1 -1
  41. package/dist/cache/types.js +5 -4
  42. package/dist/cache/types.js.map +1 -1
  43. package/dist/core/Agent.js +209 -146
  44. package/dist/core/Agent.js.map +1 -1
  45. package/dist/core/LLMCall.js +14 -17
  46. package/dist/core/LLMCall.js.map +1 -1
  47. package/dist/core/RunnerBase.js +17 -1
  48. package/dist/core/RunnerBase.js.map +1 -1
  49. package/dist/core/agent/AgentBuilder.js +24 -33
  50. package/dist/core/agent/AgentBuilder.js.map +1 -1
  51. package/dist/core/agent/act.js +3 -19
  52. package/dist/core/agent/act.js.map +1 -1
  53. package/dist/core/agent/assessment/stage.js +8 -0
  54. package/dist/core/agent/assessment/stage.js.map +1 -1
  55. package/dist/core/agent/buildAgentChart.js +8 -9
  56. package/dist/core/agent/buildAgentChart.js.map +1 -1
  57. package/dist/core/agent/buildCacheSubflow.js +4 -3
  58. package/dist/core/agent/buildCacheSubflow.js.map +1 -1
  59. package/dist/core/agent/buildDynamicAgentChart.js +16 -8
  60. package/dist/core/agent/buildDynamicAgentChart.js.map +1 -1
  61. package/dist/core/agent/honesty/mounts.js.map +1 -1
  62. package/dist/core/agent/middleware/ledger.js +1 -1
  63. package/dist/core/agent/middleware/messagePhase.js +24 -0
  64. package/dist/core/agent/middleware/messagePhase.js.map +1 -0
  65. package/dist/core/agent/skillBrains.js +3 -3
  66. package/dist/core/agent/skillBrains.js.map +1 -1
  67. package/dist/core/agent/stages/answerValidation.js +6 -3
  68. package/dist/core/agent/stages/answerValidation.js.map +1 -1
  69. package/dist/core/agent/stages/breakFinal.js +30 -1
  70. package/dist/core/agent/stages/breakFinal.js.map +1 -1
  71. package/dist/core/agent/stages/callLLM.js +15 -9
  72. package/dist/core/agent/stages/callLLM.js.map +1 -1
  73. package/dist/core/agent/stages/outputAdmission.js +14 -0
  74. package/dist/core/agent/stages/outputAdmission.js.map +1 -0
  75. package/dist/core/agent/stages/prepareFinal.js +96 -27
  76. package/dist/core/agent/stages/prepareFinal.js.map +1 -1
  77. package/dist/core/agent/stages/reliabilityExecution.js +46 -7
  78. package/dist/core/agent/stages/reliabilityExecution.js.map +1 -1
  79. package/dist/core/agent/stages/seed.js +8 -10
  80. package/dist/core/agent/stages/seed.js.map +1 -1
  81. package/dist/core/agent/stages/toolCalls.js +63 -42
  82. package/dist/core/agent/stages/toolCalls.js.map +1 -1
  83. package/dist/core/agent/toolArgsValidation.js +35 -11
  84. package/dist/core/agent/toolArgsValidation.js.map +1 -1
  85. package/dist/core/agent/toolDispatch.js +8 -2
  86. package/dist/core/agent/toolDispatch.js.map +1 -1
  87. package/dist/core/agent/toolSecurityEvents.js +23 -0
  88. package/dist/core/agent/toolSecurityEvents.js.map +1 -0
  89. package/dist/core/codeRunnerTool.js +1 -0
  90. package/dist/core/codeRunnerTool.js.map +1 -1
  91. package/dist/core/conversation.js +21 -6
  92. package/dist/core/conversation.js.map +1 -1
  93. package/dist/core/slots/buildThinkingSubflow.js +2 -3
  94. package/dist/core/slots/buildThinkingSubflow.js.map +1 -1
  95. package/dist/core/terminalVerdict.js +48 -0
  96. package/dist/core/terminalVerdict.js.map +1 -0
  97. package/dist/core-flow/Conditional.js +14 -5
  98. package/dist/core-flow/Conditional.js.map +1 -1
  99. package/dist/core-flow/Graph.js +20 -3
  100. package/dist/core-flow/Graph.js.map +1 -1
  101. package/dist/core-flow/Loop.js +13 -6
  102. package/dist/core-flow/Loop.js.map +1 -1
  103. package/dist/core-flow/Parallel.js +16 -7
  104. package/dist/core-flow/Parallel.js.map +1 -1
  105. package/dist/core-flow/Sequence.js +16 -5
  106. package/dist/core-flow/Sequence.js.map +1 -1
  107. package/dist/core-flow/Workflow.js +20 -3
  108. package/dist/core-flow/Workflow.js.map +1 -1
  109. package/dist/core-flow/childOutcome.js +64 -0
  110. package/dist/core-flow/childOutcome.js.map +1 -0
  111. package/dist/esm/adapters/llm/AnthropicProvider.d.ts +3 -1
  112. package/dist/esm/adapters/llm/AnthropicProvider.js +11 -3
  113. package/dist/esm/adapters/llm/AnthropicProvider.js.map +1 -1
  114. package/dist/esm/adapters/llm/BrowserAnthropicProvider.d.ts +2 -0
  115. package/dist/esm/adapters/llm/BrowserAnthropicProvider.js +8 -0
  116. package/dist/esm/adapters/llm/BrowserAnthropicProvider.js.map +1 -1
  117. package/dist/esm/adapters/llm/BrowserOpenAIProvider.d.ts +8 -0
  118. package/dist/esm/adapters/llm/BrowserOpenAIProvider.js +30 -0
  119. package/dist/esm/adapters/llm/BrowserOpenAIProvider.js.map +1 -1
  120. package/dist/esm/adapters/llm/FoundryProvider.js +2 -0
  121. package/dist/esm/adapters/llm/FoundryProvider.js.map +1 -1
  122. package/dist/esm/adapters/llm/InvokeModelGatewayProvider.d.ts +1 -0
  123. package/dist/esm/adapters/llm/InvokeModelGatewayProvider.js +16 -0
  124. package/dist/esm/adapters/llm/InvokeModelGatewayProvider.js.map +1 -1
  125. package/dist/esm/adapters/llm/MockProvider.d.ts +2 -0
  126. package/dist/esm/adapters/llm/MockProvider.js +3 -0
  127. package/dist/esm/adapters/llm/MockProvider.js.map +1 -1
  128. package/dist/esm/adapters/llm/OllamaProvider.d.ts +1 -0
  129. package/dist/esm/adapters/llm/OllamaProvider.js +7 -0
  130. package/dist/esm/adapters/llm/OllamaProvider.js.map +1 -1
  131. package/dist/esm/adapters/llm/OpenAIProvider.d.ts +5 -0
  132. package/dist/esm/adapters/llm/OpenAIProvider.js +25 -0
  133. package/dist/esm/adapters/llm/OpenAIProvider.js.map +1 -1
  134. package/dist/esm/adapters/llm/anthropicCacheWire.d.ts +27 -9
  135. package/dist/esm/adapters/llm/anthropicCacheWire.js +31 -9
  136. package/dist/esm/adapters/llm/anthropicCacheWire.js.map +1 -1
  137. package/dist/esm/adapters/llm/anthropicMessagesWire.d.ts +1 -1
  138. package/dist/esm/adapters/llm/anthropicMessagesWire.js +12 -11
  139. package/dist/esm/adapters/llm/anthropicMessagesWire.js.map +1 -1
  140. package/dist/esm/adapters/types.d.ts +13 -0
  141. package/dist/esm/adapters/types.js.map +1 -1
  142. package/dist/esm/bridge/eventMeta.d.ts +5 -1
  143. package/dist/esm/bridge/eventMeta.js +5 -1
  144. package/dist/esm/bridge/eventMeta.js.map +1 -1
  145. package/dist/esm/bridge/eventSourcePosition.d.ts +10 -0
  146. package/dist/esm/bridge/eventSourcePosition.js +59 -0
  147. package/dist/esm/bridge/eventSourcePosition.js.map +1 -0
  148. package/dist/esm/cache/CacheDecisionSubflow.d.ts +44 -8
  149. package/dist/esm/cache/CacheDecisionSubflow.js +77 -19
  150. package/dist/esm/cache/CacheDecisionSubflow.js.map +1 -1
  151. package/dist/esm/cache/cacheStrategyFor.d.ts +42 -0
  152. package/dist/esm/cache/cacheStrategyFor.js +73 -0
  153. package/dist/esm/cache/cacheStrategyFor.js.map +1 -0
  154. package/dist/esm/cache/index.d.ts +20 -29
  155. package/dist/esm/cache/index.js +22 -31
  156. package/dist/esm/cache/index.js.map +1 -1
  157. package/dist/esm/cache/strategies/AutomaticCacheStrategy.d.ts +37 -0
  158. package/dist/esm/cache/strategies/AutomaticCacheStrategy.js +43 -0
  159. package/dist/esm/cache/strategies/AutomaticCacheStrategy.js.map +1 -0
  160. package/dist/esm/cache/strategies/BreakpointCacheStrategy.d.ts +40 -0
  161. package/dist/esm/cache/strategies/BreakpointCacheStrategy.js +56 -0
  162. package/dist/esm/cache/strategies/BreakpointCacheStrategy.js.map +1 -0
  163. package/dist/esm/cache/strategies/NoOpCacheStrategy.d.ts +8 -18
  164. package/dist/esm/cache/strategies/NoOpCacheStrategy.js +9 -25
  165. package/dist/esm/cache/strategies/NoOpCacheStrategy.js.map +1 -1
  166. package/dist/esm/cache/types.d.ts +79 -78
  167. package/dist/esm/cache/types.js +5 -4
  168. package/dist/esm/cache/types.js.map +1 -1
  169. package/dist/esm/core/Agent.d.ts +36 -10
  170. package/dist/esm/core/Agent.js +210 -147
  171. package/dist/esm/core/Agent.js.map +1 -1
  172. package/dist/esm/core/LLMCall.d.ts +3 -4
  173. package/dist/esm/core/LLMCall.js +15 -18
  174. package/dist/esm/core/LLMCall.js.map +1 -1
  175. package/dist/esm/core/RunnerBase.d.ts +11 -0
  176. package/dist/esm/core/RunnerBase.js +15 -0
  177. package/dist/esm/core/RunnerBase.js.map +1 -1
  178. package/dist/esm/core/agent/AgentBuilder.d.ts +24 -33
  179. package/dist/esm/core/agent/AgentBuilder.js +24 -33
  180. package/dist/esm/core/agent/AgentBuilder.js.map +1 -1
  181. package/dist/esm/core/agent/act.d.ts +5 -2
  182. package/dist/esm/core/agent/act.js +3 -19
  183. package/dist/esm/core/agent/act.js.map +1 -1
  184. package/dist/esm/core/agent/assessment/stage.d.ts +2 -0
  185. package/dist/esm/core/agent/assessment/stage.js +8 -0
  186. package/dist/esm/core/agent/assessment/stage.js.map +1 -1
  187. package/dist/esm/core/agent/buildAgentChart.d.ts +5 -1
  188. package/dist/esm/core/agent/buildAgentChart.js +9 -10
  189. package/dist/esm/core/agent/buildAgentChart.js.map +1 -1
  190. package/dist/esm/core/agent/buildCacheSubflow.d.ts +4 -2
  191. package/dist/esm/core/agent/buildCacheSubflow.js +5 -4
  192. package/dist/esm/core/agent/buildCacheSubflow.js.map +1 -1
  193. package/dist/esm/core/agent/buildDynamicAgentChart.js +17 -9
  194. package/dist/esm/core/agent/buildDynamicAgentChart.js.map +1 -1
  195. package/dist/esm/core/agent/honesty/mounts.d.ts +2 -0
  196. package/dist/esm/core/agent/honesty/mounts.js.map +1 -1
  197. package/dist/esm/core/agent/middleware/ledger.d.ts +1 -1
  198. package/dist/esm/core/agent/middleware/ledger.js +1 -1
  199. package/dist/esm/core/agent/middleware/messagePhase.d.ts +5 -0
  200. package/dist/esm/core/agent/middleware/messagePhase.js +19 -0
  201. package/dist/esm/core/agent/middleware/messagePhase.js.map +1 -0
  202. package/dist/esm/core/agent/skillBrains.d.ts +5 -3
  203. package/dist/esm/core/agent/skillBrains.js +3 -3
  204. package/dist/esm/core/agent/skillBrains.js.map +1 -1
  205. package/dist/esm/core/agent/stages/answerValidation.d.ts +6 -1
  206. package/dist/esm/core/agent/stages/answerValidation.js +6 -3
  207. package/dist/esm/core/agent/stages/answerValidation.js.map +1 -1
  208. package/dist/esm/core/agent/stages/breakFinal.d.ts +16 -0
  209. package/dist/esm/core/agent/stages/breakFinal.js +27 -0
  210. package/dist/esm/core/agent/stages/breakFinal.js.map +1 -1
  211. package/dist/esm/core/agent/stages/callLLM.d.ts +3 -1
  212. package/dist/esm/core/agent/stages/callLLM.js +15 -9
  213. package/dist/esm/core/agent/stages/callLLM.js.map +1 -1
  214. package/dist/esm/core/agent/stages/outputAdmission.d.ts +6 -0
  215. package/dist/esm/core/agent/stages/outputAdmission.js +10 -0
  216. package/dist/esm/core/agent/stages/outputAdmission.js.map +1 -0
  217. package/dist/esm/core/agent/stages/prepareFinal.d.ts +18 -41
  218. package/dist/esm/core/agent/stages/prepareFinal.js +93 -25
  219. package/dist/esm/core/agent/stages/prepareFinal.js.map +1 -1
  220. package/dist/esm/core/agent/stages/reliabilityExecution.d.ts +8 -1
  221. package/dist/esm/core/agent/stages/reliabilityExecution.js +46 -7
  222. package/dist/esm/core/agent/stages/reliabilityExecution.js.map +1 -1
  223. package/dist/esm/core/agent/stages/seed.js +8 -10
  224. package/dist/esm/core/agent/stages/seed.js.map +1 -1
  225. package/dist/esm/core/agent/stages/toolCalls.js +63 -42
  226. package/dist/esm/core/agent/stages/toolCalls.js.map +1 -1
  227. package/dist/esm/core/agent/toolArgsValidation.d.ts +9 -5
  228. package/dist/esm/core/agent/toolArgsValidation.js +35 -11
  229. package/dist/esm/core/agent/toolArgsValidation.js.map +1 -1
  230. package/dist/esm/core/agent/toolDispatch.d.ts +3 -2
  231. package/dist/esm/core/agent/toolDispatch.js +8 -2
  232. package/dist/esm/core/agent/toolDispatch.js.map +1 -1
  233. package/dist/esm/core/agent/toolSecurityEvents.d.ts +18 -0
  234. package/dist/esm/core/agent/toolSecurityEvents.js +19 -0
  235. package/dist/esm/core/agent/toolSecurityEvents.js.map +1 -0
  236. package/dist/esm/core/agent/types.d.ts +4 -4
  237. package/dist/esm/core/codeRunnerTool.js +1 -0
  238. package/dist/esm/core/codeRunnerTool.js.map +1 -1
  239. package/dist/esm/core/conversation.d.ts +16 -1
  240. package/dist/esm/core/conversation.js +20 -5
  241. package/dist/esm/core/conversation.js.map +1 -1
  242. package/dist/esm/core/slots/buildThinkingSubflow.d.ts +2 -2
  243. package/dist/esm/core/slots/buildThinkingSubflow.js +2 -3
  244. package/dist/esm/core/slots/buildThinkingSubflow.js.map +1 -1
  245. package/dist/esm/core/terminalVerdict.d.ts +56 -0
  246. package/dist/esm/core/terminalVerdict.js +43 -0
  247. package/dist/esm/core/terminalVerdict.js.map +1 -0
  248. package/dist/esm/core-flow/Conditional.js +15 -6
  249. package/dist/esm/core-flow/Conditional.js.map +1 -1
  250. package/dist/esm/core-flow/Graph.js +21 -4
  251. package/dist/esm/core-flow/Graph.js.map +1 -1
  252. package/dist/esm/core-flow/Loop.js +14 -7
  253. package/dist/esm/core-flow/Loop.js.map +1 -1
  254. package/dist/esm/core-flow/Parallel.js +17 -8
  255. package/dist/esm/core-flow/Parallel.js.map +1 -1
  256. package/dist/esm/core-flow/Sequence.js +17 -6
  257. package/dist/esm/core-flow/Sequence.js.map +1 -1
  258. package/dist/esm/core-flow/Workflow.js +21 -4
  259. package/dist/esm/core-flow/Workflow.js.map +1 -1
  260. package/dist/esm/core-flow/childOutcome.d.ts +47 -0
  261. package/dist/esm/core-flow/childOutcome.js +57 -0
  262. package/dist/esm/core-flow/childOutcome.js.map +1 -0
  263. package/dist/esm/events/payloads.d.ts +33 -11
  264. package/dist/esm/events/types.d.ts +32 -2
  265. package/dist/esm/index.d.ts +1 -11
  266. package/dist/esm/index.js +5 -10
  267. package/dist/esm/index.js.map +1 -1
  268. package/dist/esm/lib/injection-engine/skillToolDescriptors.js +1 -0
  269. package/dist/esm/lib/injection-engine/skillToolDescriptors.js.map +1 -1
  270. package/dist/esm/lib/mcp/mcpServe.js +11 -4
  271. package/dist/esm/lib/mcp/mcpServe.js.map +1 -1
  272. package/dist/esm/lib/time-travel/receipt.d.ts +5 -5
  273. package/dist/esm/lib/trace-toolpack/debugPrompt.d.ts +1 -1
  274. package/dist/esm/lib/trace-toolpack/debugPrompt.js +1 -0
  275. package/dist/esm/lib/trace-toolpack/debugPrompt.js.map +1 -1
  276. package/dist/esm/lib/trace-toolpack/innerDescent.d.ts +58 -0
  277. package/dist/esm/lib/trace-toolpack/innerDescent.js +68 -0
  278. package/dist/esm/lib/trace-toolpack/innerDescent.js.map +1 -0
  279. package/dist/esm/lib/trace-toolpack/subflowRecords.d.ts +55 -0
  280. package/dist/esm/lib/trace-toolpack/subflowRecords.js +124 -0
  281. package/dist/esm/lib/trace-toolpack/subflowRecords.js.map +1 -0
  282. package/dist/esm/lib/trace-toolpack/traceToolNames.d.ts +1 -1
  283. package/dist/esm/lib/trace-toolpack/traceToolNames.js +1 -0
  284. package/dist/esm/lib/trace-toolpack/traceToolNames.js.map +1 -1
  285. package/dist/esm/lib/trace-toolpack/traceToolpack.d.ts +1 -0
  286. package/dist/esm/lib/trace-toolpack/traceToolpack.js +282 -56
  287. package/dist/esm/lib/trace-toolpack/traceToolpack.js.map +1 -1
  288. package/dist/esm/lib/trust-boundaries/capture.d.ts +6 -0
  289. package/dist/esm/lib/trust-boundaries/capture.js +161 -0
  290. package/dist/esm/lib/trust-boundaries/capture.js.map +1 -0
  291. package/dist/esm/lib/trust-boundaries/index.d.ts +2 -0
  292. package/dist/esm/lib/trust-boundaries/index.js +2 -0
  293. package/dist/esm/lib/trust-boundaries/index.js.map +1 -0
  294. package/dist/esm/lib/trust-boundaries/project.d.ts +13 -0
  295. package/dist/esm/lib/trust-boundaries/project.js +170 -0
  296. package/dist/esm/lib/trust-boundaries/project.js.map +1 -0
  297. package/dist/esm/lib/trust-boundaries/types.d.ts +81 -0
  298. package/dist/esm/lib/trust-boundaries/types.js +2 -0
  299. package/dist/esm/lib/trust-boundaries/types.js.map +1 -0
  300. package/dist/esm/observe.d.ts +1 -0
  301. package/dist/esm/observe.js +3 -0
  302. package/dist/esm/observe.js.map +1 -1
  303. package/dist/esm/package.json +1 -1
  304. package/dist/esm/patterns/LlmRouter.js +6 -3
  305. package/dist/esm/patterns/LlmRouter.js.map +1 -1
  306. package/dist/esm/recorders/core/EmitBridge.js +7 -1
  307. package/dist/esm/recorders/core/EmitBridge.js.map +1 -1
  308. package/dist/esm/recorders/observability/recordRun.d.ts +29 -4
  309. package/dist/esm/recorders/observability/recordRun.js +144 -70
  310. package/dist/esm/recorders/observability/recordRun.js.map +1 -1
  311. package/dist/esm/recorders/observability/recordingEnvelope.js +5 -3
  312. package/dist/esm/recorders/observability/recordingEnvelope.js.map +1 -1
  313. package/dist/esm/reliability/failFastRecord.d.ts +28 -0
  314. package/dist/esm/reliability/failFastRecord.js +45 -0
  315. package/dist/esm/reliability/failFastRecord.js.map +1 -0
  316. package/dist/esm/resilience/withCircuitBreaker.js +3 -0
  317. package/dist/esm/resilience/withCircuitBreaker.js.map +1 -1
  318. package/dist/esm/resilience/withFallback.js +101 -11
  319. package/dist/esm/resilience/withFallback.js.map +1 -1
  320. package/dist/esm/resilience/withRetry.js +8 -0
  321. package/dist/esm/resilience/withRetry.js.map +1 -1
  322. package/dist/esm/thinking/AnthropicThinkingHandler.js +5 -5
  323. package/dist/esm/thinking/AnthropicThinkingHandler.js.map +1 -1
  324. package/dist/esm/thinking/MockThinkingHandler.js +2 -3
  325. package/dist/esm/thinking/MockThinkingHandler.js.map +1 -1
  326. package/dist/esm/thinking/OllamaThinkingHandler.js +0 -1
  327. package/dist/esm/thinking/OllamaThinkingHandler.js.map +1 -1
  328. package/dist/esm/thinking/OpenAIThinkingHandler.js +0 -1
  329. package/dist/esm/thinking/OpenAIThinkingHandler.js.map +1 -1
  330. package/dist/esm/thinking/index.d.ts +8 -7
  331. package/dist/esm/thinking/index.js +8 -7
  332. package/dist/esm/thinking/index.js.map +1 -1
  333. package/dist/esm/thinking/registry.d.ts +13 -23
  334. package/dist/esm/thinking/registry.js +13 -29
  335. package/dist/esm/thinking/registry.js.map +1 -1
  336. package/dist/esm/thinking/thinkingHandlerFor.d.ts +27 -0
  337. package/dist/esm/thinking/thinkingHandlerFor.js +36 -0
  338. package/dist/esm/thinking/thinkingHandlerFor.js.map +1 -0
  339. package/dist/esm/thinking/types.d.ts +7 -15
  340. package/dist/esm/thinking/types.js +3 -3
  341. package/dist/index.js +5 -10
  342. package/dist/index.js.map +1 -1
  343. package/dist/lib/injection-engine/skillToolDescriptors.js +1 -0
  344. package/dist/lib/injection-engine/skillToolDescriptors.js.map +1 -1
  345. package/dist/lib/mcp/mcpServe.js +11 -4
  346. package/dist/lib/mcp/mcpServe.js.map +1 -1
  347. package/dist/lib/trace-toolpack/debugPrompt.js +1 -0
  348. package/dist/lib/trace-toolpack/debugPrompt.js.map +1 -1
  349. package/dist/lib/trace-toolpack/innerDescent.js +74 -0
  350. package/dist/lib/trace-toolpack/innerDescent.js.map +1 -0
  351. package/dist/lib/trace-toolpack/subflowRecords.js +134 -0
  352. package/dist/lib/trace-toolpack/subflowRecords.js.map +1 -0
  353. package/dist/lib/trace-toolpack/traceToolNames.js +1 -0
  354. package/dist/lib/trace-toolpack/traceToolNames.js.map +1 -1
  355. package/dist/lib/trace-toolpack/traceToolpack.js +282 -56
  356. package/dist/lib/trace-toolpack/traceToolpack.js.map +1 -1
  357. package/dist/lib/trust-boundaries/capture.js +165 -0
  358. package/dist/lib/trust-boundaries/capture.js.map +1 -0
  359. package/dist/lib/trust-boundaries/index.js +6 -0
  360. package/dist/lib/trust-boundaries/index.js.map +1 -0
  361. package/dist/lib/trust-boundaries/project.js +174 -0
  362. package/dist/lib/trust-boundaries/project.js.map +1 -0
  363. package/dist/lib/trust-boundaries/types.js +3 -0
  364. package/dist/lib/trust-boundaries/types.js.map +1 -0
  365. package/dist/observe.js +17 -13
  366. package/dist/observe.js.map +1 -1
  367. package/dist/patterns/LlmRouter.js +5 -2
  368. package/dist/patterns/LlmRouter.js.map +1 -1
  369. package/dist/recorders/core/EmitBridge.js +7 -1
  370. package/dist/recorders/core/EmitBridge.js.map +1 -1
  371. package/dist/recorders/observability/recordRun.js +144 -70
  372. package/dist/recorders/observability/recordRun.js.map +1 -1
  373. package/dist/recorders/observability/recordingEnvelope.js +5 -3
  374. package/dist/recorders/observability/recordingEnvelope.js.map +1 -1
  375. package/dist/reliability/failFastRecord.js +50 -0
  376. package/dist/reliability/failFastRecord.js.map +1 -0
  377. package/dist/resilience/withCircuitBreaker.js +3 -0
  378. package/dist/resilience/withCircuitBreaker.js.map +1 -1
  379. package/dist/resilience/withFallback.js +101 -11
  380. package/dist/resilience/withFallback.js.map +1 -1
  381. package/dist/resilience/withRetry.js +8 -0
  382. package/dist/resilience/withRetry.js.map +1 -1
  383. package/dist/thinking/AnthropicThinkingHandler.js +5 -5
  384. package/dist/thinking/AnthropicThinkingHandler.js.map +1 -1
  385. package/dist/thinking/MockThinkingHandler.js +2 -3
  386. package/dist/thinking/MockThinkingHandler.js.map +1 -1
  387. package/dist/thinking/OllamaThinkingHandler.js +0 -1
  388. package/dist/thinking/OllamaThinkingHandler.js.map +1 -1
  389. package/dist/thinking/OpenAIThinkingHandler.js +0 -1
  390. package/dist/thinking/OpenAIThinkingHandler.js.map +1 -1
  391. package/dist/thinking/index.js +9 -8
  392. package/dist/thinking/index.js.map +1 -1
  393. package/dist/thinking/registry.js +14 -31
  394. package/dist/thinking/registry.js.map +1 -1
  395. package/dist/thinking/thinkingHandlerFor.js +40 -0
  396. package/dist/thinking/thinkingHandlerFor.js.map +1 -0
  397. package/dist/thinking/types.js +3 -3
  398. package/dist/types/adapters/llm/AnthropicProvider.d.ts +3 -1
  399. package/dist/types/adapters/llm/AnthropicProvider.d.ts.map +1 -1
  400. package/dist/types/adapters/llm/BrowserAnthropicProvider.d.ts +2 -0
  401. package/dist/types/adapters/llm/BrowserAnthropicProvider.d.ts.map +1 -1
  402. package/dist/types/adapters/llm/BrowserOpenAIProvider.d.ts +8 -0
  403. package/dist/types/adapters/llm/BrowserOpenAIProvider.d.ts.map +1 -1
  404. package/dist/types/adapters/llm/FoundryProvider.d.ts.map +1 -1
  405. package/dist/types/adapters/llm/InvokeModelGatewayProvider.d.ts +1 -0
  406. package/dist/types/adapters/llm/InvokeModelGatewayProvider.d.ts.map +1 -1
  407. package/dist/types/adapters/llm/MockProvider.d.ts +2 -0
  408. package/dist/types/adapters/llm/MockProvider.d.ts.map +1 -1
  409. package/dist/types/adapters/llm/OllamaProvider.d.ts +1 -0
  410. package/dist/types/adapters/llm/OllamaProvider.d.ts.map +1 -1
  411. package/dist/types/adapters/llm/OpenAIProvider.d.ts +5 -0
  412. package/dist/types/adapters/llm/OpenAIProvider.d.ts.map +1 -1
  413. package/dist/types/adapters/llm/anthropicCacheWire.d.ts +27 -9
  414. package/dist/types/adapters/llm/anthropicCacheWire.d.ts.map +1 -1
  415. package/dist/types/adapters/llm/anthropicMessagesWire.d.ts +1 -1
  416. package/dist/types/adapters/llm/anthropicMessagesWire.d.ts.map +1 -1
  417. package/dist/types/adapters/types.d.ts +13 -0
  418. package/dist/types/adapters/types.d.ts.map +1 -1
  419. package/dist/types/bridge/eventMeta.d.ts +5 -1
  420. package/dist/types/bridge/eventMeta.d.ts.map +1 -1
  421. package/dist/types/bridge/eventSourcePosition.d.ts +11 -0
  422. package/dist/types/bridge/eventSourcePosition.d.ts.map +1 -0
  423. package/dist/types/cache/CacheDecisionSubflow.d.ts +44 -8
  424. package/dist/types/cache/CacheDecisionSubflow.d.ts.map +1 -1
  425. package/dist/types/cache/cacheStrategyFor.d.ts +43 -0
  426. package/dist/types/cache/cacheStrategyFor.d.ts.map +1 -0
  427. package/dist/types/cache/index.d.ts +20 -29
  428. package/dist/types/cache/index.d.ts.map +1 -1
  429. package/dist/types/cache/strategies/AutomaticCacheStrategy.d.ts +38 -0
  430. package/dist/types/cache/strategies/AutomaticCacheStrategy.d.ts.map +1 -0
  431. package/dist/types/cache/strategies/BreakpointCacheStrategy.d.ts +41 -0
  432. package/dist/types/cache/strategies/BreakpointCacheStrategy.d.ts.map +1 -0
  433. package/dist/types/cache/strategies/NoOpCacheStrategy.d.ts +8 -18
  434. package/dist/types/cache/strategies/NoOpCacheStrategy.d.ts.map +1 -1
  435. package/dist/types/cache/types.d.ts +79 -78
  436. package/dist/types/cache/types.d.ts.map +1 -1
  437. package/dist/types/core/Agent.d.ts +36 -10
  438. package/dist/types/core/Agent.d.ts.map +1 -1
  439. package/dist/types/core/LLMCall.d.ts +3 -4
  440. package/dist/types/core/LLMCall.d.ts.map +1 -1
  441. package/dist/types/core/RunnerBase.d.ts +11 -0
  442. package/dist/types/core/RunnerBase.d.ts.map +1 -1
  443. package/dist/types/core/agent/AgentBuilder.d.ts +24 -33
  444. package/dist/types/core/agent/AgentBuilder.d.ts.map +1 -1
  445. package/dist/types/core/agent/act.d.ts +5 -2
  446. package/dist/types/core/agent/act.d.ts.map +1 -1
  447. package/dist/types/core/agent/assessment/stage.d.ts +2 -0
  448. package/dist/types/core/agent/assessment/stage.d.ts.map +1 -1
  449. package/dist/types/core/agent/buildAgentChart.d.ts +5 -1
  450. package/dist/types/core/agent/buildAgentChart.d.ts.map +1 -1
  451. package/dist/types/core/agent/buildCacheSubflow.d.ts +4 -2
  452. package/dist/types/core/agent/buildCacheSubflow.d.ts.map +1 -1
  453. package/dist/types/core/agent/buildDynamicAgentChart.d.ts.map +1 -1
  454. package/dist/types/core/agent/honesty/mounts.d.ts +2 -0
  455. package/dist/types/core/agent/honesty/mounts.d.ts.map +1 -1
  456. package/dist/types/core/agent/middleware/ledger.d.ts +1 -1
  457. package/dist/types/core/agent/middleware/messagePhase.d.ts +6 -0
  458. package/dist/types/core/agent/middleware/messagePhase.d.ts.map +1 -0
  459. package/dist/types/core/agent/skillBrains.d.ts +5 -3
  460. package/dist/types/core/agent/skillBrains.d.ts.map +1 -1
  461. package/dist/types/core/agent/stages/answerValidation.d.ts +6 -1
  462. package/dist/types/core/agent/stages/answerValidation.d.ts.map +1 -1
  463. package/dist/types/core/agent/stages/breakFinal.d.ts +16 -0
  464. package/dist/types/core/agent/stages/breakFinal.d.ts.map +1 -1
  465. package/dist/types/core/agent/stages/callLLM.d.ts +3 -1
  466. package/dist/types/core/agent/stages/callLLM.d.ts.map +1 -1
  467. package/dist/types/core/agent/stages/outputAdmission.d.ts +7 -0
  468. package/dist/types/core/agent/stages/outputAdmission.d.ts.map +1 -0
  469. package/dist/types/core/agent/stages/prepareFinal.d.ts +18 -41
  470. package/dist/types/core/agent/stages/prepareFinal.d.ts.map +1 -1
  471. package/dist/types/core/agent/stages/reliabilityExecution.d.ts +8 -1
  472. package/dist/types/core/agent/stages/reliabilityExecution.d.ts.map +1 -1
  473. package/dist/types/core/agent/stages/seed.d.ts.map +1 -1
  474. package/dist/types/core/agent/stages/toolCalls.d.ts.map +1 -1
  475. package/dist/types/core/agent/toolArgsValidation.d.ts +9 -5
  476. package/dist/types/core/agent/toolArgsValidation.d.ts.map +1 -1
  477. package/dist/types/core/agent/toolDispatch.d.ts +3 -2
  478. package/dist/types/core/agent/toolDispatch.d.ts.map +1 -1
  479. package/dist/types/core/agent/toolSecurityEvents.d.ts +19 -0
  480. package/dist/types/core/agent/toolSecurityEvents.d.ts.map +1 -0
  481. package/dist/types/core/agent/types.d.ts +4 -4
  482. package/dist/types/core/codeRunnerTool.d.ts.map +1 -1
  483. package/dist/types/core/conversation.d.ts +16 -1
  484. package/dist/types/core/conversation.d.ts.map +1 -1
  485. package/dist/types/core/slots/buildThinkingSubflow.d.ts +2 -2
  486. package/dist/types/core/slots/buildThinkingSubflow.d.ts.map +1 -1
  487. package/dist/types/core/terminalVerdict.d.ts +57 -0
  488. package/dist/types/core/terminalVerdict.d.ts.map +1 -0
  489. package/dist/types/core-flow/Conditional.d.ts.map +1 -1
  490. package/dist/types/core-flow/Graph.d.ts.map +1 -1
  491. package/dist/types/core-flow/Loop.d.ts.map +1 -1
  492. package/dist/types/core-flow/Parallel.d.ts.map +1 -1
  493. package/dist/types/core-flow/Sequence.d.ts.map +1 -1
  494. package/dist/types/core-flow/Workflow.d.ts.map +1 -1
  495. package/dist/types/core-flow/childOutcome.d.ts +48 -0
  496. package/dist/types/core-flow/childOutcome.d.ts.map +1 -0
  497. package/dist/types/events/payloads.d.ts +33 -11
  498. package/dist/types/events/payloads.d.ts.map +1 -1
  499. package/dist/types/events/types.d.ts +32 -2
  500. package/dist/types/events/types.d.ts.map +1 -1
  501. package/dist/types/index.d.ts +1 -11
  502. package/dist/types/index.d.ts.map +1 -1
  503. package/dist/types/lib/injection-engine/skillToolDescriptors.d.ts.map +1 -1
  504. package/dist/types/lib/mcp/mcpServe.d.ts.map +1 -1
  505. package/dist/types/lib/time-travel/receipt.d.ts +5 -5
  506. package/dist/types/lib/trace-toolpack/debugPrompt.d.ts +1 -1
  507. package/dist/types/lib/trace-toolpack/debugPrompt.d.ts.map +1 -1
  508. package/dist/types/lib/trace-toolpack/innerDescent.d.ts +59 -0
  509. package/dist/types/lib/trace-toolpack/innerDescent.d.ts.map +1 -0
  510. package/dist/types/lib/trace-toolpack/subflowRecords.d.ts +56 -0
  511. package/dist/types/lib/trace-toolpack/subflowRecords.d.ts.map +1 -0
  512. package/dist/types/lib/trace-toolpack/traceToolNames.d.ts +1 -1
  513. package/dist/types/lib/trace-toolpack/traceToolNames.d.ts.map +1 -1
  514. package/dist/types/lib/trace-toolpack/traceToolpack.d.ts +1 -0
  515. package/dist/types/lib/trace-toolpack/traceToolpack.d.ts.map +1 -1
  516. package/dist/types/lib/trust-boundaries/capture.d.ts +7 -0
  517. package/dist/types/lib/trust-boundaries/capture.d.ts.map +1 -0
  518. package/dist/types/lib/trust-boundaries/index.d.ts +3 -0
  519. package/dist/types/lib/trust-boundaries/index.d.ts.map +1 -0
  520. package/dist/types/lib/trust-boundaries/project.d.ts +14 -0
  521. package/dist/types/lib/trust-boundaries/project.d.ts.map +1 -0
  522. package/dist/types/lib/trust-boundaries/types.d.ts +82 -0
  523. package/dist/types/lib/trust-boundaries/types.d.ts.map +1 -0
  524. package/dist/types/observe.d.ts +1 -0
  525. package/dist/types/observe.d.ts.map +1 -1
  526. package/dist/types/patterns/LlmRouter.d.ts.map +1 -1
  527. package/dist/types/recorders/core/EmitBridge.d.ts.map +1 -1
  528. package/dist/types/recorders/observability/recordRun.d.ts +29 -4
  529. package/dist/types/recorders/observability/recordRun.d.ts.map +1 -1
  530. package/dist/types/recorders/observability/recordingEnvelope.d.ts.map +1 -1
  531. package/dist/types/reliability/failFastRecord.d.ts +29 -0
  532. package/dist/types/reliability/failFastRecord.d.ts.map +1 -0
  533. package/dist/types/resilience/withCircuitBreaker.d.ts.map +1 -1
  534. package/dist/types/resilience/withFallback.d.ts.map +1 -1
  535. package/dist/types/resilience/withRetry.d.ts.map +1 -1
  536. package/dist/types/thinking/AnthropicThinkingHandler.d.ts.map +1 -1
  537. package/dist/types/thinking/MockThinkingHandler.d.ts.map +1 -1
  538. package/dist/types/thinking/OllamaThinkingHandler.d.ts.map +1 -1
  539. package/dist/types/thinking/OpenAIThinkingHandler.d.ts.map +1 -1
  540. package/dist/types/thinking/index.d.ts +8 -7
  541. package/dist/types/thinking/index.d.ts.map +1 -1
  542. package/dist/types/thinking/registry.d.ts +13 -23
  543. package/dist/types/thinking/registry.d.ts.map +1 -1
  544. package/dist/types/thinking/thinkingHandlerFor.d.ts +28 -0
  545. package/dist/types/thinking/thinkingHandlerFor.d.ts.map +1 -0
  546. package/dist/types/thinking/types.d.ts +7 -15
  547. package/dist/types/thinking/types.d.ts.map +1 -1
  548. package/package.json +1 -5
  549. package/dist/cache/strategies/AnthropicCacheStrategy.js +0 -90
  550. package/dist/cache/strategies/AnthropicCacheStrategy.js.map +0 -1
  551. package/dist/cache/strategies/BedrockCacheStrategy.js +0 -97
  552. package/dist/cache/strategies/BedrockCacheStrategy.js.map +0 -1
  553. package/dist/cache/strategies/OpenAICacheStrategy.js +0 -76
  554. package/dist/cache/strategies/OpenAICacheStrategy.js.map +0 -1
  555. package/dist/cache/strategyRegistry.js +0 -81
  556. package/dist/cache/strategyRegistry.js.map +0 -1
  557. package/dist/esm/cache/strategies/AnthropicCacheStrategy.d.ts +0 -41
  558. package/dist/esm/cache/strategies/AnthropicCacheStrategy.js +0 -86
  559. package/dist/esm/cache/strategies/AnthropicCacheStrategy.js.map +0 -1
  560. package/dist/esm/cache/strategies/BedrockCacheStrategy.d.ts +0 -62
  561. package/dist/esm/cache/strategies/BedrockCacheStrategy.js +0 -93
  562. package/dist/esm/cache/strategies/BedrockCacheStrategy.js.map +0 -1
  563. package/dist/esm/cache/strategies/OpenAICacheStrategy.d.ts +0 -47
  564. package/dist/esm/cache/strategies/OpenAICacheStrategy.js +0 -72
  565. package/dist/esm/cache/strategies/OpenAICacheStrategy.js.map +0 -1
  566. package/dist/esm/cache/strategyRegistry.d.ts +0 -45
  567. package/dist/esm/cache/strategyRegistry.js +0 -74
  568. package/dist/esm/cache/strategyRegistry.js.map +0 -1
  569. package/dist/types/cache/strategies/AnthropicCacheStrategy.d.ts +0 -42
  570. package/dist/types/cache/strategies/AnthropicCacheStrategy.d.ts.map +0 -1
  571. package/dist/types/cache/strategies/BedrockCacheStrategy.d.ts +0 -63
  572. package/dist/types/cache/strategies/BedrockCacheStrategy.d.ts.map +0 -1
  573. package/dist/types/cache/strategies/OpenAICacheStrategy.d.ts +0 -48
  574. package/dist/types/cache/strategies/OpenAICacheStrategy.d.ts.map +0 -1
  575. package/dist/types/cache/strategyRegistry.d.ts +0 -46
  576. package/dist/types/cache/strategyRegistry.d.ts.map +0 -1
@@ -44,7 +44,7 @@ const types_js_1 = require("../reliability/types.js");
44
44
  const extractSequence_js_1 = require("../security/extractSequence.js");
45
45
  const PolicyHaltError_js_1 = require("../security/PolicyHaltError.js");
46
46
  const CacheGateDecider_js_1 = require("../cache/CacheGateDecider.js");
47
- const strategyRegistry_js_1 = require("../cache/strategyRegistry.js");
47
+ const cacheStrategyFor_js_1 = require("../cache/cacheStrategyFor.js");
48
48
  const skillBrains_js_1 = require("./agent/skillBrains.js");
49
49
  const conventions_js_1 = require("../conventions.js");
50
50
  const pause_js_1 = require("./pause.js");
@@ -140,6 +140,9 @@ const stepNudge_js_1 = require("./agent/stages/stepNudge.js");
140
140
  const evidenceRecheck_js_1 = require("./agent/stages/evidenceRecheck.js");
141
141
  const stagedRefs_js_1 = require("./agent/stagedRefs.js");
142
142
  const wrapUp_js_1 = require("./agent/stages/wrapUp.js");
143
+ const failFastRecord_js_1 = require("../reliability/failFastRecord.js");
144
+ const terminalVerdict_js_1 = require("./terminalVerdict.js");
145
+ const breakFinal_js_1 = require("./agent/stages/breakFinal.js");
143
146
  const gate_js_1 = require("./agent/evidence/gate.js");
144
147
  const errors_js_2 = require("./agent/evidence/errors.js");
145
148
  const types_js_2 = require("../adapters/types.js");
@@ -160,10 +163,10 @@ const RunnerBase_js_1 = require("./RunnerBase.js");
160
163
  const validators_js_1 = require("./agent/validators.js");
161
164
  const route_js_1 = require("./agent/stages/route.js");
162
165
  const answerValidation_js_1 = require("./agent/stages/answerValidation.js");
166
+ const messagePhase_js_1 = require("./agent/middleware/messagePhase.js");
163
167
  const answerCoverage_js_1 = require("./agent/stages/answerCoverage.js");
164
168
  const index_js_1 = require("../answer-validation/index.js");
165
169
  const seed_js_1 = require("./agent/stages/seed.js");
166
- const errors_js_3 = require("./agent/middleware/errors.js");
167
170
  const callLLM_js_1 = require("./agent/stages/callLLM.js");
168
171
  const toolCalls_js_1 = require("./agent/stages/toolCalls.js");
169
172
  const toolResolver_js_1 = require("./agent/stages/toolResolver.js");
@@ -180,7 +183,7 @@ const buildToolRegistry_js_1 = require("./agent/buildToolRegistry.js");
180
183
  const AgentBuilder_js_1 = require("./agent/AgentBuilder.js");
181
184
  Object.defineProperty(exports, "AgentBuilder", { enumerable: true, get: function () { return AgentBuilder_js_1.AgentBuilder; } });
182
185
  const buildThinkingSubflow_js_1 = require("./slots/buildThinkingSubflow.js");
183
- const registry_js_1 = require("../thinking/registry.js");
186
+ const thinkingHandlerFor_js_1 = require("../thinking/thinkingHandlerFor.js");
184
187
  // Public types (AgentOptions, AgentInput, AgentOutput) extracted to
185
188
  // ./agent/types.ts and re-exported above (v2.11.1).
186
189
  // AgentState extracted to ./agent/types.ts (v2.11.1).
@@ -237,11 +240,9 @@ class Agent extends RunnerBase_js_1.RunnerBase {
237
240
  */
238
241
  cachingDisabledValue;
239
242
  /**
240
- * Provider-specific CacheStrategy. Auto-resolved from
241
- * `getDefaultCacheStrategy(provider.name)` at agent build time
242
- * unless the consumer explicitly passes one via builder option.
243
- * Phase 7+ implementations (Anthropic, OpenAI, Bedrock) register
244
- * themselves in the strategyRegistry on import.
243
+ * The CacheStrategy this agent runs. Chosen at build time from the
244
+ * provider's declared `promptCaching` (`cacheStrategyFor`) unless the
245
+ * consumer passes one explicitly.
245
246
  */
246
247
  cacheStrategy;
247
248
  registry;
@@ -609,6 +610,10 @@ class Agent extends RunnerBase_js_1.RunnerBase {
609
610
  * kept here rather than read back from the recording. Undefined after a run
610
611
  * that failed or paused. */
611
612
  lastRunAnswer;
613
+ /** Whether any run on this instance got past input admission — so a
614
+ * refused FIRST turn is reported as 'never-run', never as "continue from
615
+ * your earlier accepted checkpoint" when there is none. */
616
+ hadAdmittedRun = false;
612
617
  /** The id the CONSUMER chose, or undefined when they took the default.
613
618
  * `this.id` cannot answer that question — it is `'agent'` either way — and
614
619
  * the stored-conversation fingerprint refuses only on ids somebody picked
@@ -666,8 +671,8 @@ class Agent extends RunnerBase_js_1.RunnerBase {
666
671
  */
667
672
  reliabilityConfig;
668
673
  /**
669
- * Resolved ThinkingHandler (v2.14+). Auto-wired by `provider.name`
670
- * via `findThinkingHandler` UNLESS the builder explicitly set one
674
+ * Resolved ThinkingHandler (v2.14+). The provider's DECLARED one
675
+ * (`thinkingHandlerFor`) UNLESS the builder explicitly set one
671
676
  * (or `null` to opt out). When undefined, the NormalizeThinking
672
677
  * sub-subflow is NOT mounted at chart build time — zero overhead
673
678
  * for non-thinking agents.
@@ -743,9 +748,11 @@ class Agent extends RunnerBase_js_1.RunnerBase {
743
748
  this.systemPromptValue = systemPromptValue;
744
749
  this.systemPromptCachePolicy = systemPromptCachePolicy;
745
750
  this.cachingDisabledValue = cachingDisabled;
746
- // Auto-resolve strategy from provider.name unless caller overrides.
747
- // NoOp is the wildcard fallback so unknown providers stay safe.
748
- this.cacheStrategy = cacheStrategy ?? (0, strategyRegistry_js_1.getDefaultCacheStrategy)(opts.provider.name);
751
+ // The strategy the provider's DECLARED prompt caching selects, unless the
752
+ // caller overrides it — never one looked up by `provider.name`, which a
753
+ // renaming decorator (`withRetry`, an app's own wrapper) rewrites. A
754
+ // provider that declares nothing gets the no-op strategy.
755
+ this.cacheStrategy = cacheStrategy ?? (0, cacheStrategyFor_js_1.cacheStrategyFor)(opts.provider);
749
756
  this.registry = registry;
750
757
  this.injections = injections;
751
758
  this.skillGraphNextSkill = skillGraphNextSkill;
@@ -1076,12 +1083,12 @@ class Agent extends RunnerBase_js_1.RunnerBase {
1076
1083
  if (reliabilityConfig !== undefined)
1077
1084
  this.reliabilityConfig = reliabilityConfig;
1078
1085
  // v2.14 — Resolve thinking handler. Three states:
1079
- // - thinkingHandlerValue === undefined → auto-wire by provider.name
1086
+ // - thinkingHandlerValue === undefined → the provider's DECLARED handler
1080
1087
  // - thinkingHandlerValue === null → opt out (no handler)
1081
1088
  // - thinkingHandlerValue: ThinkingHandler → explicit override
1082
- // Auto-wire returns undefined for providers without a registered
1083
- // handler (gpt-4o, mistral, etc.), in which case the subflow is NOT
1084
- // mounted at chart build time.
1089
+ // A provider that declares none gets no subflow at chart build time.
1090
+ // Never chosen by `provider.name`: a renaming wrapper that forwards the
1091
+ // declaration keeps it.
1085
1092
  if (thinkingHandlerValue === null) {
1086
1093
  // explicit opt-out
1087
1094
  }
@@ -1089,9 +1096,9 @@ class Agent extends RunnerBase_js_1.RunnerBase {
1089
1096
  this.thinkingHandler = thinkingHandlerValue;
1090
1097
  }
1091
1098
  else {
1092
- const auto = (0, registry_js_1.findThinkingHandler)(opts.provider.name);
1093
- if (auto)
1094
- this.thinkingHandler = auto;
1099
+ const declared = (0, thinkingHandlerFor_js_1.thinkingHandlerFor)(opts.provider);
1100
+ if (declared)
1101
+ this.thinkingHandler = declared;
1095
1102
  }
1096
1103
  if (thinkingBudgetValue !== undefined)
1097
1104
  this.thinkingBudget = thinkingBudgetValue;
@@ -1525,7 +1532,7 @@ class Agent extends RunnerBase_js_1.RunnerBase {
1525
1532
  // starts — a run with no zone anywhere runs with its zone UNKNOWN (G15),
1526
1533
  // never on the server's zone.
1527
1534
  const clockDraft = this.clockDraftFor(runInput.time ?? options?.time, 'Agent.run');
1528
- const engineOptions = withoutTime(options);
1535
+ const engineOptions = (0, RunnerBase_js_1.withRunSignalInEnv)(withoutTime(options));
1529
1536
  // Timing next, and before the executor exists: both of these refuse a call
1530
1537
  // that would have SUCCEEDED into corrupted per-instance state or an
1531
1538
  // orphaned human question. See ./conversation.ts for why they are throws.
@@ -1709,6 +1716,7 @@ class Agent extends RunnerBase_js_1.RunnerBase {
1709
1716
  this.fileIntegrityDisposition();
1710
1717
  // Always released: a recording left subscribed would keep listening
1711
1718
  // through the next run and grow a tail nobody reads.
1719
+ this.noteAdmittedRun();
1712
1720
  recording?.stop();
1713
1721
  stopTracking();
1714
1722
  this.inFlightRunId = undefined;
@@ -1759,12 +1767,12 @@ class Agent extends RunnerBase_js_1.RunnerBase {
1759
1767
  // Refuse BEFORE the timing guards, so "there is nothing to follow up on"
1760
1768
  // is never reported as "a run is in flight" for an agent that has simply
1761
1769
  // not run yet.
1762
- if (this.getLastSnapshot() === undefined) {
1770
+ if (this.getLastSnapshot() === undefined || (this.lastInputRefused() && !this.hadAdmittedRun)) {
1763
1771
  throw new conversation_js_1.NoConversationError('Agent.followUp', 'never-run');
1764
1772
  }
1765
1773
  const conversation = this.checkpoint();
1766
1774
  if (conversation === undefined || conversation.history.length === 0) {
1767
- throw new conversation_js_1.NoConversationError('Agent.followUp', 'last-run-unfinished');
1775
+ throw new conversation_js_1.NoConversationError('Agent.followUp', this.lastInputRefused() ? 'last-input-refused' : 'last-run-unfinished');
1768
1776
  }
1769
1777
  return this.run({ message, continueFrom: conversation }, options);
1770
1778
  }
@@ -2040,7 +2048,7 @@ class Agent extends RunnerBase_js_1.RunnerBase {
2040
2048
  // moves; it is never applied — the paused turn's clock is kept, and a
2041
2049
  // differing value is recorded by the ToolCalls resume door.
2042
2050
  const passedTime = this.passedTimeFor(options?.time, 'Agent.resume');
2043
- options = withoutTime(options);
2051
+ options = (0, RunnerBase_js_1.withRunSignalInEnv)(withoutTime(options));
2044
2052
  const gate = (0, pause_js_1.pauseDemandsDecision)(checkpoint.pauseData);
2045
2053
  if (gate && !(0, checkin_js_1.isCheckInDecision)(input))
2046
2054
  throw new pause_js_1.DecisionRequiredError(gate, input);
@@ -2179,6 +2187,7 @@ class Agent extends RunnerBase_js_1.RunnerBase {
2179
2187
  // Same terms as the fresh-run path: rows on every exit, before the
2180
2188
  // recording stops (9.60.0).
2181
2189
  this.fileIntegrityDisposition();
2190
+ this.noteAdmittedRun();
2182
2191
  recording?.stop();
2183
2192
  this.inFlightRunId = undefined;
2184
2193
  }
@@ -2223,7 +2232,10 @@ class Agent extends RunnerBase_js_1.RunnerBase {
2223
2232
  * hand it back next turn, and the agent continues where it left off — across
2224
2233
  * a restart, a deploy, or a different machine.
2225
2234
  *
2226
- * Returns `undefined` before any run has completed.
2235
+ * Returns `undefined` before any run has completed or when the latest run
2236
+ * was refused by input middleware. A refused input is not an admitted
2237
+ * conversation. Keep an earlier accepted checkpoint to continue explicitly;
2238
+ * `followUp()` after input denial raises `NoConversationError`.
2227
2239
  *
2228
2240
  * **Read from the run's own recording, not from a second copy.** The history
2229
2241
  * comes from `getLastSnapshot().sharedState.history` — the state the run
@@ -2253,8 +2265,9 @@ class Agent extends RunnerBase_js_1.RunnerBase {
2253
2265
  * const conversation = agent.checkpoint(); // persist anywhere
2254
2266
  * // …a restart later, on a fresh Agent:
2255
2267
  * await agent.run({ message: 'Make it three.', continueFrom: conversation });
2256
- * // `continueFrom` runs the 'input' middleware chain on the new turn; a user
2257
- * // entry appended to `history` by hand and passed to `resumeOnError` skips it.
2268
+ * // `continueFrom` admits the new turn through the 'input' middleware chain.
2269
+ * // `resumeOnError` rechecks originalInput but replays stored history as-is;
2270
+ * // it does not rewrite entries manually appended to that history.
2258
2271
  * ```
2259
2272
  */
2260
2273
  checkpoint() {
@@ -2262,6 +2275,10 @@ class Agent extends RunnerBase_js_1.RunnerBase {
2262
2275
  if (!snapshot)
2263
2276
  return undefined;
2264
2277
  const state = snapshot.sharedState;
2278
+ // Admission is decided by seed, before any conversation state is written.
2279
+ // Do not manufacture a blank replay carrier for an unadmitted attempt.
2280
+ if (this.lastInputRefused())
2281
+ return undefined;
2265
2282
  const recorded = (state?.history ?? []);
2266
2283
  const history = structuredClone(recorded);
2267
2284
  if (this.lastRunAnswer !== undefined && this.lastRunAnswer.length > 0) {
@@ -2300,6 +2317,17 @@ class Agent extends RunnerBase_js_1.RunnerBase {
2300
2317
  ...(turnNumber !== undefined && { turnNumber }),
2301
2318
  };
2302
2319
  }
2320
+ /** Called as each run/resume ends: remember a run that got past input admission. */
2321
+ noteAdmittedRun() {
2322
+ if (this.getLastSnapshot() !== undefined && !this.lastInputRefused()) {
2323
+ this.hadAdmittedRun = true;
2324
+ }
2325
+ }
2326
+ /** Whether input middleware refused the last run's message — the one reading both doors ask. */
2327
+ lastInputRefused() {
2328
+ const state = this.getLastSnapshot()?.sharedState;
2329
+ return state?.messageDeniedPhase === 'input';
2330
+ }
2303
2331
  /** Both checkpoint doors keep the repair budget separately from conversation text. */
2304
2332
  evidenceRecoveryOf(state) {
2305
2333
  if (state?.evidenceRevisionSpent !== true)
@@ -3570,110 +3598,158 @@ class Agent extends RunnerBase_js_1.RunnerBase {
3570
3598
  const { assessAnswer } = await Promise.resolve().then(() => __importStar(require('./agent/assessment/assess.js')));
3571
3599
  return assessAnswer({ snapshot }, declarations);
3572
3600
  }
3573
- finalizeResult(executor, result) {
3574
- const paused = this.detectPause(executor, result);
3575
- if (paused)
3576
- return paused;
3577
- // Reliability fail-fast translation (v2.11.5+) — when the
3578
- // reliability retry loop in callLLM hits a `fail-fast` decision,
3579
- // it writes scope.reliabilityFailKind + payload and calls $break.
3580
- // The chart stops; the executor returns the last finalContent
3581
- // (typically empty). At the API boundary we surface the typed
3582
- // error so consumers can `instanceof ReliabilityFailFastError`
3583
- // and branch on `.kind`.
3601
+ /**
3602
+ * @internal What a mount of this agent's chart handed back
3603
+ * (`core/terminalVerdict.ts` · `ReadsItsOwnOutcome`, read by every
3604
+ * composition): the ANSWER, or the terminal verdict the chart ended on. A
3605
+ * string, or the validated answer's `{ finalContent, answerValidationCommitted }`,
3606
+ * is the answer; a verdict is read ONLY from the chart's state — handed over
3607
+ * when the chart returned no result — with the one translation this agent's
3608
+ * own run boundary (`finalizeResult`) uses. The `'tell-model'` consent record
3609
+ * travels off tracked state, so it is raised by the run boundary only.
3610
+ */
3611
+ outcomeOf(sfOutput) {
3612
+ if (typeof sfOutput === 'string')
3613
+ return { answer: sfOutput };
3614
+ if ((0, breakFinal_js_1.isValidatedDelivery)(sfOutput))
3615
+ return { answer: sfOutput.finalContent };
3616
+ if (typeof sfOutput === 'object' && sfOutput !== null) {
3617
+ const state = sfOutput;
3618
+ const verdict = this.refusalVerdictOf(state) ?? this.validationVerdictOf(state);
3619
+ if (verdict !== undefined)
3620
+ return { verdict };
3621
+ }
3622
+ return { answer: sfOutput };
3623
+ }
3624
+ /** The records a run ends on in place of an answer, in the order the boundary raises them. */
3625
+ refusalVerdictOf(state) {
3626
+ // Reliability fail-fast (v2.11.5+) — the loop in callLLM writes the record
3627
+ // and calls $break (`reliability/failFastRecord.ts`).
3584
3628
  if (this.reliabilityConfig !== undefined) {
3585
- const snap = executor.getSnapshot();
3586
- // Read via Pick<AgentState, …> so the read shape cannot drift from
3587
- // the typed write side (the fields are declared once on AgentState).
3588
- const state = snap.sharedState;
3589
- if (state.reliabilityFailKind !== undefined) {
3590
- // Reconstruct the cause Error from the captured message+name —
3591
- // see the matching note in reliabilityExecution.failFast about
3592
- // why we don't keep the original Error in scope.
3593
- let cause;
3594
- if (state.reliabilityFailCauseMessage !== undefined) {
3595
- cause = new Error(state.reliabilityFailCauseMessage);
3596
- if (state.reliabilityFailCauseName !== undefined) {
3597
- cause.name = state.reliabilityFailCauseName;
3598
- }
3599
- }
3600
- throw new types_js_1.ReliabilityFailFastError({
3601
- kind: state.reliabilityFailKind,
3602
- reason: state.reliabilityFailReason ?? state.reliabilityFailKind,
3603
- ...(cause !== undefined && { cause }),
3604
- ...(state.reliabilityFailPayload !== undefined && {
3605
- payload: state.reliabilityFailPayload,
3606
- }),
3607
- snapshot: snap,
3608
- });
3609
- }
3629
+ const record = (0, failFastRecord_js_1.failFastRecordOf)(state);
3630
+ if (record !== undefined)
3631
+ return { kind: 'reliability-fail-fast', record };
3610
3632
  }
3611
- // Policy-halt translation (v2.12+) — when a `PermissionChecker` returns
3612
- // `{ result: 'halt', ... }`, the toolCalls handler writes a synthetic
3613
- // tool_result, emits `agentfootprint.permission.halt`, sets
3614
- // scope.policyHalt* fields, and calls $break. The chart stops; we
3615
- // surface the typed error here so callers can `instanceof PolicyHaltError`
3616
- // and branch on `.reason` for alert routing.
3617
- {
3618
- const snap = executor.getSnapshot();
3619
- const state = snap.sharedState;
3620
- if (state.policyHaltReason !== undefined && state.policyHaltTarget !== undefined) {
3621
- const history = state.history ?? [];
3622
- const iteration = state.policyHaltIteration ?? 1;
3623
- // Sequence at halt time — derived from history. Includes the
3624
- // proposed call (which DID land in history as the synthetic
3625
- // tool_result for protocol compliance, but the policy denied
3626
- // execution). Filter it out so callers see only dispatched
3627
- // calls, then append the proposed entry as a hint.
3628
- const sequenceWithoutProposed = (0, extractSequence_js_1.extractSequence)(history.slice(0, -1), iteration);
3629
- throw new PolicyHaltError_js_1.PolicyHaltError({
3630
- reason: state.policyHaltReason,
3631
- ...(state.policyHaltTellLLM !== undefined && { tellLLM: state.policyHaltTellLLM }),
3633
+ // Policy halt (v2.12+) — a `PermissionChecker` returned `halt`; the
3634
+ // toolCalls handler wrote a synthetic tool_result and the policyHalt*
3635
+ // fields, and called $break.
3636
+ const halt = state;
3637
+ if (halt.policyHaltReason !== undefined && halt.policyHaltTarget !== undefined) {
3638
+ const history = halt.history ?? [];
3639
+ const iteration = halt.policyHaltIteration ?? 1;
3640
+ // Sequence at halt time — derived from history. Includes the
3641
+ // proposed call (which DID land in history as the synthetic
3642
+ // tool_result for protocol compliance, but the policy denied
3643
+ // execution). Filter it out so callers see only dispatched
3644
+ // calls, then append the proposed entry as a hint.
3645
+ const sequenceWithoutProposed = (0, extractSequence_js_1.extractSequence)(history.slice(0, -1), iteration);
3646
+ return {
3647
+ kind: 'policy-halt',
3648
+ halt: {
3649
+ reason: halt.policyHaltReason,
3650
+ ...(halt.policyHaltTellLLM !== undefined && { tellLLM: halt.policyHaltTellLLM }),
3632
3651
  sequence: [
3633
3652
  ...sequenceWithoutProposed,
3634
- { name: state.policyHaltTarget, args: state.policyHaltArgs, iteration },
3653
+ { name: halt.policyHaltTarget, args: halt.policyHaltArgs, iteration },
3635
3654
  ],
3636
3655
  iteration,
3637
3656
  history,
3638
- proposed: { name: state.policyHaltTarget, args: state.policyHaltArgs ?? {} },
3639
- ...(state.policyHaltCheckerId !== undefined && { checkerId: state.policyHaltCheckerId }),
3640
- });
3641
- }
3657
+ proposed: { name: halt.policyHaltTarget, args: halt.policyHaltArgs ?? {} },
3658
+ ...(halt.policyHaltCheckerId !== undefined && { checkerId: halt.policyHaltCheckerId }),
3659
+ },
3660
+ };
3642
3661
  }
3643
3662
  // Message-boundary refusal (7.18+) — a `messageMiddleware` returned
3644
- // `deny`. The stage wrote the flags and (at 'input') broke the chart. We
3645
- // surface the typed error here, the same way a policy halt is surfaced,
3646
- // because a refusal must never be mistaken for an answer: at 'input' no
3647
- // model was ever asked, and at 'output' the middleware has just declined
3648
- // to release what the model said.
3663
+ // `deny`; a refusal must never be mistaken for an answer: at 'input' no
3664
+ // model was asked, and at 'output' the middleware declined to release it.
3649
3665
  if (this.messageMiddleware.length > 0) {
3650
- const state = executor.getSnapshot().sharedState;
3651
- if (state.messageDeniedReason !== undefined) {
3652
- throw new errors_js_3.MessageDeniedError({
3653
- reason: state.messageDeniedReason,
3654
- phase: state.messageDeniedPhase ?? 'output',
3655
- middleware: state.messageDeniedBy ?? 'middleware',
3656
- });
3666
+ const denied = state;
3667
+ if (denied.messageDeniedReason !== undefined) {
3668
+ return {
3669
+ kind: 'message-denied',
3670
+ denial: {
3671
+ reason: denied.messageDeniedReason,
3672
+ phase: denied.messageDeniedPhase ?? 'output',
3673
+ middleware: denied.messageDeniedBy ?? 'middleware',
3674
+ },
3675
+ };
3657
3676
  }
3658
3677
  }
3659
- // Evidence refusal (9.35.0, `posture: 'rails'` only) — the final answer
3660
- // still states values that appear in no tool result, after the one
3661
- // revision the posture allows. Surfaced the way a denied message is, and
3662
- // for the same reason: `rails` was chosen precisely so an answer carrying
3663
- // invented identifiers cannot reach the caller as a string they are free
3664
- // to ignore. `'assist'` and `'guard'` never reach here — their verdict is
3665
- // committed state and an event, and `run()` returns the answer.
3678
+ // Evidence rails (9.35.0) — the answer still states values no tool result
3679
+ // carried, after the one revision the posture allows. `'assist'` and
3680
+ // `'guard'` never end here: their verdict is committed state and an event.
3666
3681
  if (this.evidenceGate?.posture === 'rails') {
3667
- const state = executor.getSnapshot().sharedState;
3668
3682
  const verdict = state.unsupportedValues;
3669
3683
  if (verdict !== undefined && verdict.refused) {
3670
- throw new errors_js_2.UnsupportedValuesError({
3671
- values: verdict.values,
3672
- candidates: verdict.candidates,
3673
- revised: verdict.revised,
3674
- message: (0, gate_js_1.evidenceRefusalSentence)(verdict.values, 'rails', verdict.revised),
3684
+ return {
3685
+ kind: 'unsupported-values',
3686
+ refusal: {
3687
+ values: verdict.values,
3688
+ candidates: verdict.candidates,
3689
+ revised: verdict.revised,
3690
+ message: (0, gate_js_1.evidenceRefusalSentence)(verdict.values, 'rails', verdict.revised),
3691
+ },
3692
+ };
3693
+ }
3694
+ }
3695
+ return undefined;
3696
+ }
3697
+ /** Answer validation's verdict on a run that reached the end (7.24): blocked, or never committed. */
3698
+ validationVerdictOf(state) {
3699
+ const config = this.answerValidationConfig;
3700
+ if (config === undefined)
3701
+ return undefined;
3702
+ const s = state;
3703
+ if (s.answerValidationBlocked === true && s.answerValidation !== undefined) {
3704
+ return { kind: 'answer-validation', report: s.answerValidation };
3705
+ }
3706
+ if (s.answerValidation === undefined ||
3707
+ s.answerValidationCommitted !== true ||
3708
+ typeof s.finalContent !== 'string') {
3709
+ return {
3710
+ kind: 'answer-validation',
3711
+ report: {
3712
+ validatorId: config.id,
3713
+ validatorVersion: config.version,
3714
+ mode: config.mode,
3715
+ status: 'unverified',
3716
+ checked: 0,
3717
+ failed: 0,
3718
+ unreachable: 0,
3719
+ notApplicable: 0,
3720
+ checks: [],
3721
+ resolvedRefs: [],
3722
+ schemaAccepted: false,
3723
+ reason: 'delivery-incomplete',
3724
+ },
3725
+ };
3726
+ }
3727
+ return undefined;
3728
+ }
3729
+ finalizeResult(executor, result) {
3730
+ const paused = this.detectPause(executor, result);
3731
+ if (paused)
3732
+ return paused;
3733
+ const snap = executor.getSnapshot();
3734
+ const state = snap.sharedState;
3735
+ const refusal = this.refusalVerdictOf(state);
3736
+ if (refusal !== undefined) {
3737
+ if (refusal.kind === 'message-denied' && refusal.denial.phase === 'output') {
3738
+ // The chart stopped cleanly, so ErrorBridge's onRunFailed cannot
3739
+ // close public streams. This API boundary owns the refusal on both
3740
+ // run and resume. Name it as a virtual stage, not a fabricated
3741
+ // engine failure, and never echo policy text into a public stream.
3742
+ this.dispatcher.dispatch({
3743
+ type: 'agentfootprint.error.fatal',
3744
+ payload: {
3745
+ error: 'The output policy withheld this answer.',
3746
+ stage: '__output_admission__',
3747
+ scope: 'run',
3748
+ },
3749
+ meta: (0, eventMeta_js_1.buildEventMeta)({ runtimeStageId: '__output_admission__' }, this.currentRunContext),
3675
3750
  });
3676
3751
  }
3752
+ throw (0, terminalVerdict_js_1.terminalErrorOf)(refusal, snap);
3677
3753
  }
3678
3754
  // Credential-consent translation (8.6.0, `'tell-model'` only) — a tool
3679
3755
  // DECLARED a credential, the provider answered `authorization-required`,
@@ -3697,38 +3773,18 @@ class Agent extends RunnerBase_js_1.RunnerBase {
3697
3773
  }
3698
3774
  if (result instanceof Error)
3699
3775
  throw result;
3700
- if (this.answerValidationConfig !== undefined) {
3701
- const state = executor.getSnapshot().sharedState;
3702
- if (state.answerValidationBlocked === true && state.answerValidation !== undefined) {
3703
- throw new index_js_1.AnswerValidationError(state.answerValidation);
3704
- }
3705
- if (state.answerValidation === undefined ||
3706
- state.answerValidationCommitted !== true ||
3707
- typeof state.finalContent !== 'string') {
3708
- const config = this.answerValidationConfig;
3709
- throw new index_js_1.AnswerValidationError({
3710
- validatorId: config.id,
3711
- validatorVersion: config.version,
3712
- mode: config.mode,
3713
- status: 'unverified',
3714
- checked: 0,
3715
- failed: 0,
3716
- unreachable: 0,
3717
- notApplicable: 0,
3718
- checks: [],
3719
- resolvedRefs: [],
3720
- schemaAccepted: false,
3721
- reason: 'delivery-incomplete',
3722
- });
3723
- }
3776
+ const invalid = this.validationVerdictOf(state);
3777
+ if (invalid !== undefined)
3778
+ throw (0, terminalVerdict_js_1.terminalErrorOf)(invalid);
3779
+ if (this.answerValidationConfig !== undefined)
3724
3780
  return state.finalContent;
3725
- }
3726
3781
  if (typeof result === 'string')
3727
3782
  return result;
3728
3783
  throw new Error('Agent: unexpected result shape — expected final-answer string');
3729
3784
  }
3730
3785
  // ─── Chart assembly ────────────────────────────────────────────
3731
3786
  buildChart() {
3787
+ const governsOutput = (0, messagePhase_js_1.hasOutputMiddleware)(this.messageMiddleware);
3732
3788
  const provider = this.provider;
3733
3789
  const model = this.model;
3734
3790
  const temperature = this.temperature;
@@ -4358,7 +4414,10 @@ class Agent extends RunnerBase_js_1.RunnerBase {
4358
4414
  // seam peels `_findings` where the served schema carries it (ruled
4359
4415
  // tools only) — value-conditional, the same grammar.
4360
4416
  ...(argumentSources && { argumentSources: true }),
4361
- ...(this.answerValidationConfig !== undefined && { suppressDraftTokens: true }),
4417
+ ...((this.answerValidationConfig !== undefined || governsOutput) && {
4418
+ suppressDraftTokens: true,
4419
+ }),
4420
+ ...(governsOutput && { withholdDraftContent: true }),
4362
4421
  // Tool choice by classifier (9.105.0): the outcome row after the reply.
4363
4422
  ...(this.toolChoiceOptions !== undefined && { toolChoice: true }),
4364
4423
  // The declared ontology (9.106.0): the piece served from the run
@@ -4428,14 +4487,15 @@ class Agent extends RunnerBase_js_1.RunnerBase {
4428
4487
  // brain or an escalation exists, so every other agent's stage reads no
4429
4488
  // new scope key and resolves on the exact line it always did. The
4430
4489
  // per-brain cache strategies resolve HERE, once, where the agent's own
4431
- // strategy (override included) is known: same-name brains keep it,
4432
- // foreign providers get their registry default (markers are
4433
- // provider-aware — the one genuinely risky seam, resolved statically).
4490
+ // strategy (override included) is known: a brain on the agent's own
4491
+ // provider keeps it, any other provider gets the strategy its declared
4492
+ // `promptCaching` selects (markers are provider-aware — the one
4493
+ // genuinely risky seam, resolved statically).
4434
4494
  ...(this.skillBrains !== undefined &&
4435
4495
  (this.skillBrains.bySkill.size > 0 || this.skillBrains.escalation !== undefined) && {
4436
4496
  brainFor: (0, skillBrains_js_1.buildBrainFor)({
4437
4497
  brains: this.skillBrains,
4438
- agentProviderName: provider.name,
4498
+ agentProvider: provider,
4439
4499
  agentCacheStrategy: cacheStrategy,
4440
4500
  }),
4441
4501
  }),
@@ -4759,12 +4819,12 @@ class Agent extends RunnerBase_js_1.RunnerBase {
4759
4819
  },
4760
4820
  });
4761
4821
  // v2.14 — Build the NormalizeThinking sub-subflow only when a
4762
- // ThinkingHandler resolved (auto-wired by provider.name OR
4822
+ // ThinkingHandler resolved (declared by the provider OR
4763
4823
  // explicitly set via .thinkingHandler()). Conditional mount ensures
4764
4824
  // zero overhead for non-thinking agents — the chart has zero extra
4765
4825
  // stages when undefined.
4766
4826
  const thinkingSubflow = this.thinkingHandler
4767
- ? (0, buildThinkingSubflow_js_1.buildThinkingSubflow)(this.thinkingHandler)
4827
+ ? (0, buildThinkingSubflow_js_1.buildThinkingSubflow)(this.thinkingHandler, this.provider.name)
4768
4828
  : undefined;
4769
4829
  // Chart composition extracted to ./agent/buildAgentChart.ts (v2.11.2).
4770
4830
  // The deps object is identical for both chart shapes — only the
@@ -4885,6 +4945,7 @@ class Agent extends RunnerBase_js_1.RunnerBase {
4885
4945
  toolMiddleware: this.toolMiddleware.length > 0,
4886
4946
  }),
4887
4947
  ...(this.answerLayerOption.standingLine === true && { standingLine: true }),
4948
+ ...(this.answerValidationConfig !== undefined && { validated: true }),
4888
4949
  },
4889
4950
  }),
4890
4951
  // Tool choice by classifier (9.105.0): the mount args on the Tools
@@ -4909,6 +4970,8 @@ class Agent extends RunnerBase_js_1.RunnerBase {
4909
4970
  ...(this.timeOptions !== undefined && { timeWindows: true }),
4910
4971
  ...(inputsArmed && this.timeOptions !== undefined && { timeLimits: true }),
4911
4972
  ...(this.answerValidationConfig !== undefined && { hasAnswerValidation: true }),
4973
+ ...(governsOutput && { releaseOutputTokens: true }),
4974
+ ...(this.evidenceGate?.posture === 'rails' && { evidenceRails: true }),
4912
4975
  // The out-of-budget wrap-up branch (9.56.0) — the conditional-mount law
4913
4976
  // above, decided once beside the Route decider that routes to it so the
4914
4977
  // two can never disagree about whether the branch exists.