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
@@ -0,0 +1,43 @@
1
+ /**
2
+ * AutomaticCacheStrategy — for a provider that caches repeated prefixes on
3
+ * its own (`promptCaching.mode: 'automatic'`; OpenAI, Azure OpenAI).
4
+ *
5
+ * Chosen by CAPABILITY (`cacheStrategyFor`), never by provider name.
6
+ *
7
+ * - **prepareRequest**: pass-through. The provider decides what to cache;
8
+ * a marker would mean nothing on its wire. The `cache:` policies on
9
+ * injections still matter — they travel with the agent and take effect
10
+ * the moment it runs on a breakpoint provider — but here they have no
11
+ * local effect, and `cache: 'never'` cannot stop the provider caching.
12
+ * - **extractMetrics**: the port usage when the adapter declares it
13
+ * reports cache tokens; `not applicable` when it declares it does not
14
+ * (the OpenAI adapter does not lift `prompt_tokens_details.cached_tokens`
15
+ * yet — named, rather than hidden behind a per-call `unknown` that would
16
+ * suggest the measurement was attempted).
17
+ */
18
+ import { notApplicable } from '../../lib/claim/claim.js';
19
+ import { readPortCacheUsage } from '../portUsage.js';
20
+ export class AutomaticCacheStrategy {
21
+ name = 'automatic';
22
+ reportsUsage;
23
+ who;
24
+ /**
25
+ * @param declared the provider's `promptCaching` declaration
26
+ * @param who names the adapter in the meter's evidence sentences
27
+ */
28
+ constructor(declared, who = 'the provider') {
29
+ this.reportsUsage = declared.reportsUsage;
30
+ this.who = who;
31
+ }
32
+ async prepareRequest(req, _candidates, _ctx) {
33
+ return { request: req, markersApplied: [] };
34
+ }
35
+ extractMetrics(usage) {
36
+ if (!this.reportsUsage) {
37
+ return notApplicable(`${this.who} caches automatically but declares that it does not report cache ` +
38
+ 'token counts (promptCaching.reportsUsage: false)');
39
+ }
40
+ return readPortCacheUsage(usage, this.who);
41
+ }
42
+ }
43
+ //# sourceMappingURL=AutomaticCacheStrategy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AutomaticCacheStrategy.js","sourceRoot":"","sources":["../../../../src/cache/strategies/AutomaticCacheStrategy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAUH,OAAO,EAAE,aAAa,EAAc,MAAM,0BAA0B,CAAC;AACrE,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAGrD,MAAM,OAAO,sBAAsB;IACxB,IAAI,GAAG,WAAW,CAAC;IACX,YAAY,CAAU;IACtB,GAAG,CAAS;IAE7B;;;OAGG;IACH,YAAY,QAAuD,EAAE,GAAG,GAAG,cAAc;QACvF,IAAI,CAAC,YAAY,GAAG,QAAQ,CAAC,YAAY,CAAC;QAC1C,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACjB,CAAC;IAED,KAAK,CAAC,cAAc,CAClB,GAAe,EACf,WAAmC,EACnC,IAA0B;QAK1B,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,cAAc,EAAE,EAAE,EAAE,CAAC;IAC9C,CAAC;IAED,cAAc,CAAC,KAA6B;QAC1C,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC;YACvB,OAAO,aAAa,CAClB,GAAG,IAAI,CAAC,GAAG,mEAAmE;gBAC5E,kDAAkD,CACrD,CAAC;QACJ,CAAC;QACD,OAAO,kBAAkB,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;IAC7C,CAAC;CACF"}
@@ -0,0 +1,40 @@
1
+ /**
2
+ * BreakpointCacheStrategy — for a provider that caches a prefix only where
3
+ * the request marks it (`promptCaching.mode: 'breakpoints'`; Anthropic's
4
+ * `cache_control`).
5
+ *
6
+ * Chosen by CAPABILITY (`cacheStrategyFor`), never by provider name: built
7
+ * from the provider's own declaration, so `withRetry(anthropic())` or an
8
+ * application's routing wrapper caches exactly like the adapter it wraps.
9
+ *
10
+ * What it DOES:
11
+ * - clamp the candidate markers to the declared `maxBreakpoints`, keeping
12
+ * the first N in slot order (the most stable prefixes first);
13
+ * - put them on `LLMRequest.cacheMarkers`, where the adapter reads them;
14
+ * - read cache metrics off the PORT usage the adapter normalised —
15
+ * `not applicable` when the declaration says the adapter reports none.
16
+ * What it does NOT: touch the wire. The adapter owns `cache_control`
17
+ * (`adapters/llm/anthropicCacheWire.ts`), and content is never edited.
18
+ */
19
+ import type { CacheMarker, CacheMetrics, CacheStrategy, CacheStrategyContext, CacheUsage, PromptCaching } from '../types.js';
20
+ import { type Claim } from '../../lib/claim/claim.js';
21
+ import type { LLMRequest } from '../../adapters/types.js';
22
+ export declare class BreakpointCacheStrategy implements CacheStrategy {
23
+ readonly name = "breakpoints";
24
+ private readonly maxBreakpoints;
25
+ private readonly reportsUsage;
26
+ private readonly who;
27
+ /**
28
+ * @param declared the provider's `promptCaching` declaration
29
+ * @param who names the adapter in the meter's evidence sentences,
30
+ * e.g. `"the 'anthropic' provider"`
31
+ */
32
+ constructor(declared: Extract<PromptCaching, {
33
+ mode: 'breakpoints';
34
+ }>, who?: string);
35
+ prepareRequest(req: LLMRequest, candidates: readonly CacheMarker[], ctx: CacheStrategyContext): Promise<{
36
+ readonly request: LLMRequest;
37
+ readonly markersApplied: readonly CacheMarker[];
38
+ }>;
39
+ extractMetrics(usage: CacheUsage | undefined): Claim<CacheMetrics>;
40
+ }
@@ -0,0 +1,56 @@
1
+ /**
2
+ * BreakpointCacheStrategy — for a provider that caches a prefix only where
3
+ * the request marks it (`promptCaching.mode: 'breakpoints'`; Anthropic's
4
+ * `cache_control`).
5
+ *
6
+ * Chosen by CAPABILITY (`cacheStrategyFor`), never by provider name: built
7
+ * from the provider's own declaration, so `withRetry(anthropic())` or an
8
+ * application's routing wrapper caches exactly like the adapter it wraps.
9
+ *
10
+ * What it DOES:
11
+ * - clamp the candidate markers to the declared `maxBreakpoints`, keeping
12
+ * the first N in slot order (the most stable prefixes first);
13
+ * - put them on `LLMRequest.cacheMarkers`, where the adapter reads them;
14
+ * - read cache metrics off the PORT usage the adapter normalised —
15
+ * `not applicable` when the declaration says the adapter reports none.
16
+ * What it does NOT: touch the wire. The adapter owns `cache_control`
17
+ * (`adapters/llm/anthropicCacheWire.ts`), and content is never edited.
18
+ */
19
+ import { notApplicable } from '../../lib/claim/claim.js';
20
+ import { readPortCacheUsage } from '../portUsage.js';
21
+ export class BreakpointCacheStrategy {
22
+ name = 'breakpoints';
23
+ maxBreakpoints;
24
+ reportsUsage;
25
+ who;
26
+ /**
27
+ * @param declared the provider's `promptCaching` declaration
28
+ * @param who names the adapter in the meter's evidence sentences,
29
+ * e.g. `"the 'anthropic' provider"`
30
+ */
31
+ constructor(declared, who = 'the provider') {
32
+ this.maxBreakpoints = declared.maxBreakpoints;
33
+ this.reportsUsage = declared.reportsUsage;
34
+ this.who = who;
35
+ }
36
+ async prepareRequest(req, candidates, ctx) {
37
+ // The agent-side kill switch, honoured here too: the CacheGate should
38
+ // already have emptied the candidates, but a buggy gate must not be able
39
+ // to put markers on a request whose run said caching is off.
40
+ if (ctx.cachingDisabled || candidates.length === 0) {
41
+ return { request: req, markersApplied: [] };
42
+ }
43
+ const markersApplied = candidates.length <= this.maxBreakpoints
44
+ ? candidates
45
+ : candidates.slice(0, this.maxBreakpoints);
46
+ return { request: { ...req, cacheMarkers: markersApplied }, markersApplied };
47
+ }
48
+ extractMetrics(usage) {
49
+ if (!this.reportsUsage) {
50
+ return notApplicable(`${this.who} declares that it does not report cache token counts ` +
51
+ '(promptCaching.reportsUsage: false)');
52
+ }
53
+ return readPortCacheUsage(usage, this.who);
54
+ }
55
+ }
56
+ //# sourceMappingURL=BreakpointCacheStrategy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BreakpointCacheStrategy.js","sourceRoot":"","sources":["../../../../src/cache/strategies/BreakpointCacheStrategy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAUH,OAAO,EAAE,aAAa,EAAc,MAAM,0BAA0B,CAAC;AACrE,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAGrD,MAAM,OAAO,uBAAuB;IACzB,IAAI,GAAG,aAAa,CAAC;IACb,cAAc,CAAS;IACvB,YAAY,CAAU;IACtB,GAAG,CAAS;IAE7B;;;;OAIG;IACH,YAAY,QAAyD,EAAE,GAAG,GAAG,cAAc;QACzF,IAAI,CAAC,cAAc,GAAG,QAAQ,CAAC,cAAc,CAAC;QAC9C,IAAI,CAAC,YAAY,GAAG,QAAQ,CAAC,YAAY,CAAC;QAC1C,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACjB,CAAC;IAED,KAAK,CAAC,cAAc,CAClB,GAAe,EACf,UAAkC,EAClC,GAAyB;QAKzB,sEAAsE;QACtE,yEAAyE;QACzE,6DAA6D;QAC7D,IAAI,GAAG,CAAC,eAAe,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACnD,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,cAAc,EAAE,EAAE,EAAE,CAAC;QAC9C,CAAC;QACD,MAAM,cAAc,GAClB,UAAU,CAAC,MAAM,IAAI,IAAI,CAAC,cAAc;YACtC,CAAC,CAAC,UAAU;YACZ,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC;QAC/C,OAAO,EAAE,OAAO,EAAE,EAAE,GAAG,GAAG,EAAE,YAAY,EAAE,cAAc,EAAE,EAAE,cAAc,EAAE,CAAC;IAC/E,CAAC;IAED,cAAc,CAAC,KAA6B;QAC1C,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC;YACvB,OAAO,aAAa,CAClB,GAAG,IAAI,CAAC,GAAG,uDAAuD;gBAChE,qCAAqC,CACxC,CAAC;QACJ,CAAC;QACD,OAAO,kBAAkB,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;IAC7C,CAAC;CACF"}
@@ -1,27 +1,17 @@
1
1
  /**
2
- * NoOpCacheStrategy — fallback strategy for providers without cache
3
- * support (Mock, unknown providers, intentional opt-out).
2
+ * NoOpCacheStrategy — for a provider that declares no prompt caching
3
+ * (`LLMProvider.promptCaching` absent): Mock, Ollama, Bedrock Converse,
4
+ * any adapter that has not said, or an intentional opt-out.
4
5
  *
5
- * Returns the request unchanged; reports no metrics. The
6
- * `capabilities.enabled` flag is `false` so the CacheDecision subflow
7
- * could choose to skip emitting markers entirely (potential v2.7
8
- * optimization), though current Phase 4+5 always emit markers and
9
- * let the strategy decide what to do with them.
10
- *
11
- * Always-available default. Registered against the special wildcard
12
- * `'*'` so any unrecognized provider name falls back to NoOp.
6
+ * Returns the request unchanged and reports *not applicable* — never a zero.
7
+ * Chosen by `cacheStrategyFor` when the declaration is absent; one shared
8
+ * instance serves every such provider (it holds no state).
13
9
  */
14
- import type { CacheCapabilities, CacheMarker, CacheMetrics, CacheStrategy, CacheStrategyContext, CacheUsage } from '../types.js';
10
+ import type { CacheMarker, CacheMetrics, CacheStrategy, CacheStrategyContext, CacheUsage } from '../types.js';
15
11
  import { type Claim } from '../../lib/claim/claim.js';
16
12
  import type { LLMRequest } from '../../adapters/types.js';
17
13
  export declare class NoOpCacheStrategy implements CacheStrategy {
18
- /**
19
- * Wildcard provider name. The strategy registry treats this as the
20
- * fallback for any provider that doesn't have a specific strategy
21
- * registered.
22
- */
23
- readonly providerName = "*";
24
- readonly capabilities: CacheCapabilities;
14
+ readonly name = "none";
25
15
  prepareRequest(req: LLMRequest, _candidates: readonly CacheMarker[], _ctx: CacheStrategyContext): Promise<{
26
16
  readonly request: LLMRequest;
27
17
  readonly markersApplied: readonly CacheMarker[];
@@ -1,37 +1,21 @@
1
1
  /**
2
- * NoOpCacheStrategy — fallback strategy for providers without cache
3
- * support (Mock, unknown providers, intentional opt-out).
2
+ * NoOpCacheStrategy — for a provider that declares no prompt caching
3
+ * (`LLMProvider.promptCaching` absent): Mock, Ollama, Bedrock Converse,
4
+ * any adapter that has not said, or an intentional opt-out.
4
5
  *
5
- * Returns the request unchanged; reports no metrics. The
6
- * `capabilities.enabled` flag is `false` so the CacheDecision subflow
7
- * could choose to skip emitting markers entirely (potential v2.7
8
- * optimization), though current Phase 4+5 always emit markers and
9
- * let the strategy decide what to do with them.
10
- *
11
- * Always-available default. Registered against the special wildcard
12
- * `'*'` so any unrecognized provider name falls back to NoOp.
6
+ * Returns the request unchanged and reports *not applicable* — never a zero.
7
+ * Chosen by `cacheStrategyFor` when the declaration is absent; one shared
8
+ * instance serves every such provider (it holds no state).
13
9
  */
14
10
  import { notApplicable } from '../../lib/claim/claim.js';
15
- const NOOP_CAPABILITIES = Object.freeze({
16
- enabled: false,
17
- maxMarkers: 0,
18
- ttls: [],
19
- fields: [],
20
- automatic: false,
21
- });
22
11
  export class NoOpCacheStrategy {
23
- /**
24
- * Wildcard provider name. The strategy registry treats this as the
25
- * fallback for any provider that doesn't have a specific strategy
26
- * registered.
27
- */
28
- providerName = '*';
29
- capabilities = NOOP_CAPABILITIES;
12
+ name = 'none';
30
13
  async prepareRequest(req, _candidates, _ctx) {
31
14
  return { request: req, markersApplied: [] };
32
15
  }
33
16
  extractMetrics(_usage) {
34
- return notApplicable('the NoOp strategy stands in for providers with no cache reporting at all');
17
+ return notApplicable('the provider declares no prompt caching (LLMProvider.promptCaching is absent), so no ' +
18
+ 'cache traffic is driven or reported');
35
19
  }
36
20
  }
37
21
  //# sourceMappingURL=NoOpCacheStrategy.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"NoOpCacheStrategy.js","sourceRoot":"","sources":["../../../../src/cache/strategies/NoOpCacheStrategy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAUH,OAAO,EAAE,aAAa,EAAc,MAAM,0BAA0B,CAAC;AAGrE,MAAM,iBAAiB,GAAsB,MAAM,CAAC,MAAM,CAAC;IACzD,OAAO,EAAE,KAAK;IACd,UAAU,EAAE,CAAC;IACb,IAAI,EAAE,EAAmC;IACzC,MAAM,EAAE,EAAkD;IAC1D,SAAS,EAAE,KAAK;CACjB,CAAC,CAAC;AAEH,MAAM,OAAO,iBAAiB;IAC5B;;;;OAIG;IACM,YAAY,GAAG,GAAG,CAAC;IACnB,YAAY,GAAG,iBAAiB,CAAC;IAE1C,KAAK,CAAC,cAAc,CAClB,GAAe,EACf,WAAmC,EACnC,IAA0B;QAK1B,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,cAAc,EAAE,EAAE,EAAE,CAAC;IAC9C,CAAC;IAED,cAAc,CAAC,MAA8B;QAC3C,OAAO,aAAa,CAClB,0EAA0E,CAC3E,CAAC;IACJ,CAAC;CACF"}
1
+ {"version":3,"file":"NoOpCacheStrategy.js","sourceRoot":"","sources":["../../../../src/cache/strategies/NoOpCacheStrategy.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AASH,OAAO,EAAE,aAAa,EAAc,MAAM,0BAA0B,CAAC;AAGrE,MAAM,OAAO,iBAAiB;IACnB,IAAI,GAAG,MAAM,CAAC;IAEvB,KAAK,CAAC,cAAc,CAClB,GAAe,EACf,WAAmC,EACnC,IAA0B;QAK1B,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,cAAc,EAAE,EAAE,EAAE,CAAC;IAC9C,CAAC;IAED,cAAc,CAAC,MAA8B;QAC3C,OAAO,aAAa,CAClB,uFAAuF;YACrF,qCAAqC,CACxC,CAAC;IACJ,CAAC;CACF"}
@@ -11,10 +11,11 @@
11
11
  * `CacheDecision` subflow at runtime. Provider-independent
12
12
  * identification of "cacheable prefix in field X up to index Y".
13
13
  *
14
- * 3. PROVIDER STRATEGY — one `CacheStrategy` implementation per
15
- * provider (Anthropic / OpenAI / Bedrock / NoOp). Translates
16
- * agnostic markers to provider-specific wire format AND extracts
17
- * cache metrics from the provider's response.
14
+ * 3. STRATEGY — one `CacheStrategy` per CAPABILITY, chosen from what the
15
+ * provider DECLARES (`LLMProvider.promptCaching`), never from its name:
16
+ * explicit breakpoints, automatic prefix caching, or none. Decides
17
+ * which markers reach the request AND reads cache metrics off the
18
+ * port usage. The adapter owns the wire format.
18
19
  *
19
20
  * The interfaces are read-only / immutable by convention. Strategies
20
21
  * MUST be stateless across runs; per-run state lives in the
@@ -110,14 +111,16 @@ export interface CachePolicyContext {
110
111
  *
111
112
  * The CacheDecision subflow walks `activeInjections` and emits one
112
113
  * marker per slot whose entries from index 0..boundaryIndex form a
113
- * stable, contiguous, cacheable prefix.
114
+ * stable, contiguous, cacheable prefix — and one more on the conversation
115
+ * tail when everything before it is cacheable (the moving breakpoint).
114
116
  *
115
- * `field` is the request field this marker targets. Each provider
116
- * strategy translates it differently:
117
- * - `'system'` → Anthropic puts `cache_control` on a system block
118
- * - `'tools'` → Anthropic puts `cache_control` on a tools array entry
119
- * - `'messages'` → Anthropic puts `cache_control` on the LAST content
120
- * block of the LAST message (Anthropic-specific positional rule)
117
+ * `field` is the request field this marker targets. An adapter that declares
118
+ * `promptCaching.mode: 'breakpoints'` encodes it on its wire; the Anthropic
119
+ * one does:
120
+ * - `'system'` → `cache_control` on a system block
121
+ * - `'tools'` → `cache_control` on a tools array entry
122
+ * - `'messages'` → `cache_control` on the LAST content block of the
123
+ * message the index names (Anthropic's positional rule)
121
124
  */
122
125
  export interface CacheMarker {
123
126
  readonly field: 'system' | 'tools' | 'messages';
@@ -126,12 +129,11 @@ export interface CacheMarker {
126
129
  * cached prefix. Everything from index 0..boundaryIndex (inclusive)
127
130
  * is cacheable.
128
131
  *
129
- * **Provider note for `field: 'messages'`**: Anthropic's `cache_control`
130
- * on `messages` is positional — it only takes effect on the LAST
131
- * content block of the LAST message in the cacheable prefix. The
132
- * AnthropicCacheStrategy translates `boundaryIndex` to the right
133
- * positional placement; consumers and CacheDecision subflow don't
134
- * see this complexity.
132
+ * **Provider note for `field: 'messages'`**: the index is a position in
133
+ * `LLMRequest.messages`. Anthropic's `cache_control` on `messages` is
134
+ * positional — it takes effect on the LAST content block of a message —
135
+ * and the adapter translates the index into its own (coalesced) message
136
+ * array; consumers and the CacheDecision subflow don't see this.
135
137
  */
136
138
  readonly boundaryIndex: number;
137
139
  /**
@@ -147,31 +149,68 @@ export interface CacheMarker {
147
149
  readonly reason: string;
148
150
  }
149
151
  /**
150
- * Per-provider cache implementation. One strategy per provider name;
151
- * registered in a default map keyed by `LLMProvider.name`.
152
+ * How an adapter's wire caches a repeated prompt prefix — DECLARED by the
153
+ * adapter, read by the agent to choose its cache strategy
154
+ * (`agentfootprint/cache` · `cacheStrategyFor`).
152
155
  *
153
- * Strategies MUST be stateless across runs. Any per-run state (handle
154
- * cache, hit-rate tracking) lives inside the strategy instance.
156
+ * - `'breakpoints'` — the provider caches a prefix only where the request
157
+ * marks it (Anthropic's `cache_control`). The adapter reads
158
+ * `LLMRequest.cacheMarkers` and writes them on its wire, at most
159
+ * `maxBreakpoints` per request.
160
+ * - `'automatic'` — the provider caches repeated prefixes on its own (OpenAI).
161
+ * Markers are inert; nothing the request says changes what is cached.
162
+ *
163
+ * `reportsUsage` says whether the adapter lifts the provider's cache token
164
+ * counts onto `LLMResponse.usage.cacheRead` / `cacheWrite`. The cache meter
165
+ * reads it: `false` makes every call's cache claim *not applicable*, never a
166
+ * zero.
167
+ *
168
+ * @example
169
+ * ```ts
170
+ * // A wrapper forwards what it wraps, like every other capability:
171
+ * const wrapped: LLMProvider = {
172
+ * name: `my-app/${inner.name}`,
173
+ * ...(inner.promptCaching !== undefined && { promptCaching: inner.promptCaching }),
174
+ * complete: (req, hooks) => inner.complete(req, hooks),
175
+ * };
176
+ * ```
177
+ */
178
+ export type PromptCaching = {
179
+ readonly mode: 'breakpoints';
180
+ /** Breakpoints the wire honours on one request (Anthropic: 4). */
181
+ readonly maxBreakpoints: number;
182
+ readonly reportsUsage: boolean;
183
+ } | {
184
+ readonly mode: 'automatic';
185
+ readonly reportsUsage: boolean;
186
+ };
187
+ /**
188
+ * The cache strategy an agent runs between request assembly and the provider.
189
+ *
190
+ * Chosen by CAPABILITY: `cacheStrategyFor(provider)` reads the provider's
191
+ * declared `promptCaching` and returns `BreakpointCacheStrategy`,
192
+ * `AutomaticCacheStrategy` or `NoOpCacheStrategy`. Pass your own as
193
+ * `Agent.create({ cacheStrategy })` to override it.
194
+ *
195
+ * Strategies MUST be stateless across runs; per-run state arrives in the
196
+ * {@link CacheStrategyContext}.
155
197
  */
156
198
  export interface CacheStrategy {
157
- /** Provider name match. e.g. `'anthropic'`, `'openai'`, `'bedrock'`. */
158
- readonly providerName: string;
159
199
  /**
160
- * Static description of what this strategy can do. Read by the
161
- * CacheDecision subflow to know whether to bother emitting markers,
162
- * and how many to emit before clamping to provider limits.
200
+ * What the run's receipt records as the strategy that stood between
201
+ * assembly and the port (`Receipt.cache.strategy`). The built-ins name the
202
+ * capability they serve: `'breakpoints'`, `'automatic'`, `'none'`.
163
203
  */
164
- readonly capabilities: CacheCapabilities;
204
+ readonly name: string;
165
205
  /**
166
- * Translate agnostic markers to provider-specific wire format.
206
+ * Decide which agnostic markers reach the request.
167
207
  *
168
- * Async to support handle-based caching (Gemini does
169
- * `createCachedContent` and references handles; not in v2.6 but
170
- * the interface is async-ready for v2.7+).
208
+ * Async to support handle-based caching (Gemini's `createCachedContent`
209
+ * references handles) without another interface change.
171
210
  *
172
- * Returns the modified request AND the markers actually applied
173
- * (after capability-clamping). `markersApplied` flows into the
174
- * cacheRecorder for diagnostic surfacing.
211
+ * Returns the request (with `cacheMarkers` set for the adapter to encode)
212
+ * AND the markers actually applied, after clamping. `markersApplied` flows
213
+ * into the receipt and the cacheRecorder.
175
214
  */
176
215
  prepareRequest(req: LLMRequest, candidates: readonly CacheMarker[], ctx: CacheStrategyContext): Promise<{
177
216
  readonly request: LLMRequest;
@@ -191,49 +230,12 @@ export interface CacheStrategy {
191
230
  * - `unknown(reason, …)` — nothing measured this call (no usage payload,
192
231
  * or the provider reported no cache fields). The
193
232
  * report renders this as *unmeasured*, never 0.
194
- * - `notApplicable(…)` — this provider/adapter cannot report cache
195
- * usage at all (NoOp; Bedrock until its adapter
196
- * grows the read half).
233
+ * - `notApplicable(…)` — this provider cannot report cache usage at
234
+ * all (it declares no `promptCaching`, or
235
+ * declares `reportsUsage: false`).
197
236
  */
198
237
  extractMetrics(usage: CacheUsage | undefined): Claim<CacheMetrics>;
199
238
  }
200
- /**
201
- * Static description of a strategy's capabilities. The CacheDecision
202
- * subflow reads this BEFORE calling `prepareRequest` so it can clamp
203
- * candidates to a count the strategy can actually use.
204
- */
205
- export interface CacheCapabilities {
206
- /**
207
- * `true` if this strategy actually does anything. `false` for NoOp,
208
- * Mock, or providers we haven't built yet. CacheDecision subflow
209
- * skips entirely when `enabled` is `false`.
210
- */
211
- readonly enabled: boolean;
212
- /**
213
- * Maximum number of cache markers per request. Anthropic enforces 4
214
- * cache breakpoints per request; OpenAI is automatic (∞); Gemini
215
- * is per-handle (∞ effectively). Strategies clamp internally.
216
- */
217
- readonly maxMarkers: number;
218
- /**
219
- * TTL values this strategy can map to. Anthropic supports both;
220
- * OpenAI is fixed (~5min); some providers may only support one.
221
- */
222
- readonly ttls: ReadonlyArray<'short' | 'long'>;
223
- /**
224
- * Which request fields this strategy can mark. Most providers support
225
- * all three (system / tools / messages); some are field-restricted.
226
- */
227
- readonly fields: ReadonlyArray<'system' | 'tools' | 'messages'>;
228
- /**
229
- * `true` if the provider auto-caches without explicit markers (OpenAI).
230
- * In that case `prepareRequest` is a pass-through; only
231
- * `extractMetrics` does meaningful work. Surfaced for documentation
232
- * (so consumers know `cache: 'never'` may not actually disable caching
233
- * on auto-caching providers).
234
- */
235
- readonly automatic: boolean;
236
- }
237
239
  /**
238
240
  * Per-run state passed into `prepareRequest`. Strategies use this to
239
241
  * make per-iteration decisions (rate of cache invalidation, current
@@ -243,10 +245,9 @@ export interface CacheStrategyContext {
243
245
  readonly iteration: number;
244
246
  readonly iterationsRemaining: number;
245
247
  /**
246
- * Hit rate across previous iterations of this run (0..1). Strategies
247
- * use this for self-disable behaviors (e.g., AnthropicCacheStrategy
248
- * auto-skips markers when hit rate < 30% to avoid the cache-write
249
- * penalty without recoup).
248
+ * Hit rate across previous iterations of this run (0..1), when something
249
+ * supplied one. Nothing in the library writes it today, so it arrives
250
+ * `undefined`; the CacheGate's hit-rate rule reads the same value.
250
251
  */
251
252
  readonly recentHitRate: number | undefined;
252
253
  /**
@@ -11,10 +11,11 @@
11
11
  * `CacheDecision` subflow at runtime. Provider-independent
12
12
  * identification of "cacheable prefix in field X up to index Y".
13
13
  *
14
- * 3. PROVIDER STRATEGY — one `CacheStrategy` implementation per
15
- * provider (Anthropic / OpenAI / Bedrock / NoOp). Translates
16
- * agnostic markers to provider-specific wire format AND extracts
17
- * cache metrics from the provider's response.
14
+ * 3. STRATEGY — one `CacheStrategy` per CAPABILITY, chosen from what the
15
+ * provider DECLARES (`LLMProvider.promptCaching`), never from its name:
16
+ * explicit breakpoints, automatic prefix caching, or none. Decides
17
+ * which markers reach the request AND reads cache metrics off the
18
+ * port usage. The adapter owns the wire format.
18
19
  *
19
20
  * The interfaces are read-only / immutable by convention. Strategies
20
21
  * MUST be stateless across runs; per-run state lives in the
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/cache/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG"}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/cache/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG"}
@@ -27,6 +27,7 @@ import { type CheckInBuilderOptions } from './checkin.js';
27
27
  import type { MemoryDefinition } from '../memory/define.types.js';
28
28
  import type { MemoryIdentity } from '../memory/identity/types.js';
29
29
  import type { SelfExplainBinding } from '../lib/trace-toolpack/selfExplain.js';
30
+ import { type ChildOutcome } from './terminalVerdict.js';
30
31
  import type { ResolvedEvidenceGate } from './agent/evidence/types.js';
31
32
  import type { Injection, InjectionContext } from '../lib/injection-engine/types.js';
32
33
  import type { CursorMove, EntryScoring, TurnRoutingPlan } from '../lib/injection-engine/skillGraph.js';
@@ -137,11 +138,9 @@ export declare class Agent extends RunnerBase<AgentInput, AgentOutput> {
137
138
  */
138
139
  private readonly cachingDisabledValue;
139
140
  /**
140
- * Provider-specific CacheStrategy. Auto-resolved from
141
- * `getDefaultCacheStrategy(provider.name)` at agent build time
142
- * unless the consumer explicitly passes one via builder option.
143
- * Phase 7+ implementations (Anthropic, OpenAI, Bedrock) register
144
- * themselves in the strategyRegistry on import.
141
+ * The CacheStrategy this agent runs. Chosen at build time from the
142
+ * provider's declared `promptCaching` (`cacheStrategyFor`) unless the
143
+ * consumer passes one explicitly.
145
144
  */
146
145
  private readonly cacheStrategy;
147
146
  private readonly registry;
@@ -493,6 +492,10 @@ export declare class Agent extends RunnerBase<AgentInput, AgentOutput> {
493
492
  * kept here rather than read back from the recording. Undefined after a run
494
493
  * that failed or paused. */
495
494
  private lastRunAnswer?;
495
+ /** Whether any run on this instance got past input admission — so a
496
+ * refused FIRST turn is reported as 'never-run', never as "continue from
497
+ * your earlier accepted checkpoint" when there is none. */
498
+ private hadAdmittedRun;
496
499
  /** The id the CONSUMER chose, or undefined when they took the default.
497
500
  * `this.id` cannot answer that question — it is `'agent'` either way — and
498
501
  * the stored-conversation fingerprint refuses only on ids somebody picked
@@ -550,8 +553,8 @@ export declare class Agent extends RunnerBase<AgentInput, AgentOutput> {
550
553
  */
551
554
  private readonly reliabilityConfig?;
552
555
  /**
553
- * Resolved ThinkingHandler (v2.14+). Auto-wired by `provider.name`
554
- * via `findThinkingHandler` UNLESS the builder explicitly set one
556
+ * Resolved ThinkingHandler (v2.14+). The provider's DECLARED one
557
+ * (`thinkingHandlerFor`) UNLESS the builder explicitly set one
555
558
  * (or `null` to opt out). When undefined, the NormalizeThinking
556
559
  * sub-subflow is NOT mounted at chart build time — zero overhead
557
560
  * for non-thinking agents.
@@ -1046,7 +1049,10 @@ export declare class Agent extends RunnerBase<AgentInput, AgentOutput> {
1046
1049
  * hand it back next turn, and the agent continues where it left off — across
1047
1050
  * a restart, a deploy, or a different machine.
1048
1051
  *
1049
- * Returns `undefined` before any run has completed.
1052
+ * Returns `undefined` before any run has completed or when the latest run
1053
+ * was refused by input middleware. A refused input is not an admitted
1054
+ * conversation. Keep an earlier accepted checkpoint to continue explicitly;
1055
+ * `followUp()` after input denial raises `NoConversationError`.
1050
1056
  *
1051
1057
  * **Read from the run's own recording, not from a second copy.** The history
1052
1058
  * comes from `getLastSnapshot().sharedState.history` — the state the run
@@ -1076,11 +1082,16 @@ export declare class Agent extends RunnerBase<AgentInput, AgentOutput> {
1076
1082
  * const conversation = agent.checkpoint(); // persist anywhere
1077
1083
  * // …a restart later, on a fresh Agent:
1078
1084
  * await agent.run({ message: 'Make it three.', continueFrom: conversation });
1079
- * // `continueFrom` runs the 'input' middleware chain on the new turn; a user
1080
- * // entry appended to `history` by hand and passed to `resumeOnError` skips it.
1085
+ * // `continueFrom` admits the new turn through the 'input' middleware chain.
1086
+ * // `resumeOnError` rechecks originalInput but replays stored history as-is;
1087
+ * // it does not rewrite entries manually appended to that history.
1081
1088
  * ```
1082
1089
  */
1083
1090
  checkpoint(): AgentRunCheckpoint | undefined;
1091
+ /** Called as each run/resume ends: remember a run that got past input admission. */
1092
+ private noteAdmittedRun;
1093
+ /** Whether input middleware refused the last run's message — the one reading both doors ask. */
1094
+ private lastInputRefused;
1084
1095
  /** Both checkpoint doors keep the repair budget separately from conversation text. */
1085
1096
  private evidenceRecoveryOf;
1086
1097
  /**
@@ -1664,6 +1675,21 @@ export declare class Agent extends RunnerBase<AgentInput, AgentOutput> {
1664
1675
  * ```
1665
1676
  */
1666
1677
  assessment(declarations?: AssessmentDeclarations): Promise<AnswerAssessment | undefined>;
1678
+ /**
1679
+ * @internal What a mount of this agent's chart handed back
1680
+ * (`core/terminalVerdict.ts` · `ReadsItsOwnOutcome`, read by every
1681
+ * composition): the ANSWER, or the terminal verdict the chart ended on. A
1682
+ * string, or the validated answer's `{ finalContent, answerValidationCommitted }`,
1683
+ * is the answer; a verdict is read ONLY from the chart's state — handed over
1684
+ * when the chart returned no result — with the one translation this agent's
1685
+ * own run boundary (`finalizeResult`) uses. The `'tell-model'` consent record
1686
+ * travels off tracked state, so it is raised by the run boundary only.
1687
+ */
1688
+ outcomeOf(sfOutput: unknown): ChildOutcome;
1689
+ /** The records a run ends on in place of an answer, in the order the boundary raises them. */
1690
+ private refusalVerdictOf;
1691
+ /** Answer validation's verdict on a run that reached the end (7.24): blocked, or never committed. */
1692
+ private validationVerdictOf;
1667
1693
  private finalizeResult;
1668
1694
  private buildChart;
1669
1695
  }