agentfootprint 6.43.0 → 6.45.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 (397) hide show
  1. package/ai-instructions/setup.sh +0 -0
  2. package/dist/core/RunnerBase.js +7 -0
  3. package/dist/core/RunnerBase.js.map +1 -1
  4. package/dist/core/agent/buildAgentChart.js +2 -1
  5. package/dist/core/agent/buildAgentChart.js.map +1 -1
  6. package/dist/core/agent/buildDynamicAgentChart.js +3 -1
  7. package/dist/core/agent/buildDynamicAgentChart.js.map +1 -1
  8. package/dist/core/agent/stages/pickEntry.js +3 -1
  9. package/dist/core/agent/stages/pickEntry.js.map +1 -1
  10. package/dist/esm/adapters/identity/agentcore.d.ts +100 -0
  11. package/dist/esm/adapters/llm/AnthropicProvider.d.ts +130 -0
  12. package/dist/esm/adapters/llm/BedrockProvider.d.ts +100 -0
  13. package/dist/esm/adapters/llm/BrowserAnthropicProvider.d.ts +41 -0
  14. package/dist/esm/adapters/llm/BrowserOpenAIProvider.d.ts +95 -0
  15. package/dist/esm/adapters/llm/MockProvider.d.ts +153 -0
  16. package/dist/esm/adapters/llm/OpenAIProvider.d.ts +220 -0
  17. package/dist/esm/adapters/llm/createProvider.d.ts +85 -0
  18. package/dist/esm/adapters/memory/agentcore.d.ts +146 -0
  19. package/dist/esm/adapters/memory/bedrockAgentMemory.d.ts +95 -0
  20. package/dist/esm/adapters/memory/redis.d.ts +127 -0
  21. package/dist/esm/adapters/observability/agentcore.d.ts +67 -0
  22. package/dist/esm/adapters/observability/audit.d.ts +254 -0
  23. package/dist/esm/adapters/observability/cloudwatch.d.ts +96 -0
  24. package/dist/esm/adapters/observability/otel.d.ts +237 -0
  25. package/dist/esm/adapters/observability/xray.d.ts +88 -0
  26. package/dist/esm/adapters/types.d.ts +378 -0
  27. package/dist/esm/bridge/eventMeta.d.ts +59 -0
  28. package/dist/esm/cache/CacheDecisionSubflow.d.ts +85 -0
  29. package/dist/esm/cache/CacheGateDecider.d.ts +127 -0
  30. package/dist/esm/cache/applyCachePolicy.d.ts +37 -0
  31. package/dist/esm/cache/cacheRecorder.d.ts +85 -0
  32. package/dist/esm/cache/index.d.ts +33 -0
  33. package/dist/esm/cache/strategies/AnthropicCacheStrategy.d.ts +38 -0
  34. package/dist/esm/cache/strategies/BedrockCacheStrategy.d.ts +33 -0
  35. package/dist/esm/cache/strategies/NoOpCacheStrategy.d.ts +29 -0
  36. package/dist/esm/cache/strategies/OpenAICacheStrategy.d.ts +36 -0
  37. package/dist/esm/cache/strategyRegistry.d.ts +45 -0
  38. package/dist/esm/cache/types.d.ts +243 -0
  39. package/dist/esm/conventions.d.ts +203 -0
  40. package/dist/esm/core/Agent.d.ts +355 -0
  41. package/dist/esm/core/LLMCall.d.ts +139 -0
  42. package/dist/esm/core/RunnerBase.d.ts +267 -0
  43. package/dist/esm/core/RunnerBase.js +7 -0
  44. package/dist/esm/core/RunnerBase.js.map +1 -1
  45. package/dist/esm/core/agent/AgentBuilder.d.ts +565 -0
  46. package/dist/esm/core/agent/buildAgentChart.d.ts +109 -0
  47. package/dist/esm/core/agent/buildAgentChart.js +2 -1
  48. package/dist/esm/core/agent/buildAgentChart.js.map +1 -1
  49. package/dist/esm/core/agent/buildAgentMessageApiChart.d.ts +40 -0
  50. package/dist/esm/core/agent/buildCacheSubflow.d.ts +35 -0
  51. package/dist/esm/core/agent/buildDynamicAgentChart.d.ts +56 -0
  52. package/dist/esm/core/agent/buildDynamicAgentChart.js +3 -1
  53. package/dist/esm/core/agent/buildDynamicAgentChart.js.map +1 -1
  54. package/dist/esm/core/agent/buildMessageApiChart.d.ts +47 -0
  55. package/dist/esm/core/agent/buildToolRegistry.d.ts +61 -0
  56. package/dist/esm/core/agent/memoryRecallInjections.d.ts +8 -0
  57. package/dist/esm/core/agent/stages/breakFinal.d.ts +22 -0
  58. package/dist/esm/core/agent/stages/callLLM.d.ts +74 -0
  59. package/dist/esm/core/agent/stages/pickEntry.d.ts +19 -0
  60. package/dist/esm/core/agent/stages/pickEntry.js +3 -1
  61. package/dist/esm/core/agent/stages/pickEntry.js.map +1 -1
  62. package/dist/esm/core/agent/stages/prepareFinal.d.ts +19 -0
  63. package/dist/esm/core/agent/stages/reliabilityExecution.d.ts +135 -0
  64. package/dist/esm/core/agent/stages/route.d.ts +18 -0
  65. package/dist/esm/core/agent/stages/seed.d.ts +53 -0
  66. package/dist/esm/core/agent/stages/toolCalls.d.ts +76 -0
  67. package/dist/esm/core/agent/toolArgsValidation.d.ts +62 -0
  68. package/dist/esm/core/agent/types.d.ts +382 -0
  69. package/dist/esm/core/agent/validators.d.ts +52 -0
  70. package/dist/esm/core/cost.d.ts +38 -0
  71. package/dist/esm/core/flowchartAsTool.d.ts +200 -0
  72. package/dist/esm/core/humanizeLLMError.d.ts +23 -0
  73. package/dist/esm/core/outputFallback.d.ts +139 -0
  74. package/dist/esm/core/outputSchema.d.ts +127 -0
  75. package/dist/esm/core/pause.d.ts +74 -0
  76. package/dist/esm/core/runCheckpoint.d.ts +179 -0
  77. package/dist/esm/core/runner.d.ts +203 -0
  78. package/dist/esm/core/slots/buildMessagesSlot.d.ts +40 -0
  79. package/dist/esm/core/slots/buildSystemPromptSlot.d.ts +41 -0
  80. package/dist/esm/core/slots/buildThinkingSubflow.d.ts +40 -0
  81. package/dist/esm/core/slots/buildToolsSlot.d.ts +60 -0
  82. package/dist/esm/core/slots/helpers.d.ts +27 -0
  83. package/dist/esm/core/toolContract.d.ts +43 -0
  84. package/dist/esm/core/tools.d.ts +90 -0
  85. package/dist/esm/core/translator.d.ts +94 -0
  86. package/dist/esm/core-flow/Conditional.d.ts +119 -0
  87. package/dist/esm/core-flow/Loop.d.ts +160 -0
  88. package/dist/esm/core-flow/Parallel.d.ts +360 -0
  89. package/dist/esm/core-flow/Sequence.d.ts +133 -0
  90. package/dist/esm/events/dispatcher.d.ts +134 -0
  91. package/dist/esm/events/payloads.d.ts +761 -0
  92. package/dist/esm/events/registry.d.ts +198 -0
  93. package/dist/esm/events/types.d.ts +70 -0
  94. package/dist/esm/identity/kinds.d.ts +36 -0
  95. package/dist/esm/identity/staticTokens.d.ts +28 -0
  96. package/dist/esm/identity/types.d.ts +113 -0
  97. package/dist/esm/identity/withCredentialRetry.d.ts +64 -0
  98. package/dist/esm/identity.d.ts +31 -0
  99. package/dist/esm/index.d.ts +64 -0
  100. package/dist/esm/index.js +2 -0
  101. package/dist/esm/index.js.map +1 -1
  102. package/dist/esm/injection-engine.d.ts +4 -0
  103. package/dist/esm/lib/canonicalJson.d.ts +56 -0
  104. package/dist/esm/lib/context-bisect/ablation.d.ts +109 -0
  105. package/dist/esm/lib/context-bisect/bisect.d.ts +75 -0
  106. package/dist/esm/lib/context-bisect/cost.d.ts +37 -0
  107. package/dist/esm/lib/context-bisect/index.d.ts +31 -0
  108. package/dist/esm/lib/context-bisect/index.js +3 -0
  109. package/dist/esm/lib/context-bisect/index.js.map +1 -1
  110. package/dist/esm/lib/context-bisect/llmEdgeWeigher.d.ts +124 -0
  111. package/dist/esm/lib/context-bisect/localize.d.ts +152 -0
  112. package/dist/esm/lib/context-bisect/localize.js +2 -0
  113. package/dist/esm/lib/context-bisect/localize.js.map +1 -1
  114. package/dist/esm/lib/context-bisect/loop-recall.d.ts +97 -0
  115. package/dist/esm/lib/context-bisect/missingContext.d.ts +71 -0
  116. package/dist/esm/lib/context-bisect/restoration.d.ts +39 -0
  117. package/dist/esm/lib/context-bisect/toBacktrackTrace.d.ts +138 -0
  118. package/dist/esm/lib/context-bisect/trajectory.d.ts +168 -0
  119. package/dist/esm/lib/context-bisect/types.d.ts +448 -0
  120. package/dist/esm/lib/context-bisect/walk-to-root.d.ts +103 -0
  121. package/dist/esm/lib/influence-core/attributability.d.ts +72 -0
  122. package/dist/esm/lib/influence-core/cache.d.ts +94 -0
  123. package/dist/esm/lib/influence-core/contrastive.d.ts +26 -0
  124. package/dist/esm/lib/influence-core/index.d.ts +34 -0
  125. package/dist/esm/lib/influence-core/margin.d.ts +33 -0
  126. package/dist/esm/lib/influence-core/signals.d.ts +128 -0
  127. package/dist/esm/lib/influence-core/similarity.d.ts +25 -0
  128. package/dist/esm/lib/influence-core/types.d.ts +252 -0
  129. package/dist/esm/lib/injection-engine/SkillRegistry.d.ts +147 -0
  130. package/dist/esm/lib/injection-engine/buildInjectionEngineSubflow.d.ts +110 -0
  131. package/dist/esm/lib/injection-engine/buildInjectionEngineSubflow.js +1 -0
  132. package/dist/esm/lib/injection-engine/buildInjectionEngineSubflow.js.map +1 -1
  133. package/dist/esm/lib/injection-engine/entryScorer.d.ts +93 -0
  134. package/dist/esm/lib/injection-engine/entryScorer.js +172 -0
  135. package/dist/esm/lib/injection-engine/entryScorer.js.map +1 -0
  136. package/dist/esm/lib/injection-engine/evaluator.d.ts +24 -0
  137. package/dist/esm/lib/injection-engine/factories/defineFact.d.ts +60 -0
  138. package/dist/esm/lib/injection-engine/factories/defineInjection.d.ts +41 -0
  139. package/dist/esm/lib/injection-engine/factories/defineInstruction.d.ts +78 -0
  140. package/dist/esm/lib/injection-engine/factories/defineRelevanceHint.d.ts +26 -0
  141. package/dist/esm/lib/injection-engine/factories/defineSkill.d.ts +160 -0
  142. package/dist/esm/lib/injection-engine/factories/defineSteering.d.ts +39 -0
  143. package/dist/esm/lib/injection-engine/index.d.ts +22 -0
  144. package/dist/esm/lib/injection-engine/index.js +1 -0
  145. package/dist/esm/lib/injection-engine/index.js.map +1 -1
  146. package/dist/esm/lib/injection-engine/skillContract.d.ts +29 -0
  147. package/dist/esm/lib/injection-engine/skillGraph.d.ts +289 -0
  148. package/dist/esm/lib/injection-engine/skillGraph.js +35 -41
  149. package/dist/esm/lib/injection-engine/skillGraph.js.map +1 -1
  150. package/dist/esm/lib/injection-engine/skillGraphCheckup.d.ts +49 -0
  151. package/dist/esm/lib/injection-engine/skillTools.d.ts +72 -0
  152. package/dist/esm/lib/injection-engine/softmax.d.ts +11 -0
  153. package/dist/esm/lib/injection-engine/types.d.ts +229 -0
  154. package/dist/esm/lib/injection-engine/types.js.map +1 -1
  155. package/dist/esm/lib/lazyRequire.d.ts +29 -0
  156. package/dist/esm/lib/mcp/index.d.ts +9 -0
  157. package/dist/esm/lib/mcp/mcpClient.d.ts +46 -0
  158. package/dist/esm/lib/mcp/mockMcpClient.d.ts +65 -0
  159. package/dist/esm/lib/mcp/types.d.ts +133 -0
  160. package/dist/esm/lib/rag/defineRAG.d.ts +139 -0
  161. package/dist/esm/lib/rag/index.d.ts +7 -0
  162. package/dist/esm/lib/rag/indexDocuments.d.ts +105 -0
  163. package/dist/esm/lib/tool-lint/analyze.d.ts +83 -0
  164. package/dist/esm/lib/tool-lint/cli.d.ts +43 -0
  165. package/dist/esm/lib/tool-lint/format.d.ts +18 -0
  166. package/dist/esm/lib/tool-lint/index.d.ts +23 -0
  167. package/dist/esm/lib/tool-lint/rules.d.ts +85 -0
  168. package/dist/esm/lib/tool-lint/types.d.ts +155 -0
  169. package/dist/esm/lib/trace-toolpack/bounded.d.ts +47 -0
  170. package/dist/esm/lib/trace-toolpack/debugPrompt.d.ts +19 -0
  171. package/dist/esm/lib/trace-toolpack/index.d.ts +20 -0
  172. package/dist/esm/lib/trace-toolpack/lazyToolpack.d.ts +35 -0
  173. package/dist/esm/lib/trace-toolpack/selfExplain.d.ts +100 -0
  174. package/dist/esm/lib/trace-toolpack/traceDebugAgent.d.ts +42 -0
  175. package/dist/esm/lib/trace-toolpack/traceToolpack.d.ts +69 -0
  176. package/dist/esm/lib/trace-toolpack/types.d.ts +59 -0
  177. package/dist/esm/llm-providers.d.ts +26 -0
  178. package/dist/esm/locales/index.d.ts +132 -0
  179. package/dist/esm/memory/beats/extractBeats.d.ts +61 -0
  180. package/dist/esm/memory/beats/extractor.d.ts +47 -0
  181. package/dist/esm/memory/beats/formatAsNarrative.d.ts +62 -0
  182. package/dist/esm/memory/beats/heuristicExtractor.d.ts +37 -0
  183. package/dist/esm/memory/beats/index.d.ts +12 -0
  184. package/dist/esm/memory/beats/llmExtractor.d.ts +56 -0
  185. package/dist/esm/memory/beats/types.d.ts +60 -0
  186. package/dist/esm/memory/beats/writeBeats.d.ts +22 -0
  187. package/dist/esm/memory/causal/evidenceRecorder.d.ts +66 -0
  188. package/dist/esm/memory/causal/index.d.ts +6 -0
  189. package/dist/esm/memory/causal/loadSnapshot.d.ts +51 -0
  190. package/dist/esm/memory/causal/snapshotPipeline.d.ts +35 -0
  191. package/dist/esm/memory/causal/types.d.ts +130 -0
  192. package/dist/esm/memory/causal/writeSnapshot.d.ts +73 -0
  193. package/dist/esm/memory/define.d.ts +63 -0
  194. package/dist/esm/memory/define.types.d.ts +276 -0
  195. package/dist/esm/memory/define.types.js +1 -1
  196. package/dist/esm/memory/embedding/cosine.d.ts +18 -0
  197. package/dist/esm/memory/embedding/embedMessages.d.ts +58 -0
  198. package/dist/esm/memory/embedding/index.d.ts +8 -0
  199. package/dist/esm/memory/embedding/loadRelevant.d.ts +51 -0
  200. package/dist/esm/memory/embedding/mockEmbedder.d.ts +22 -0
  201. package/dist/esm/memory/embedding/types.d.ts +46 -0
  202. package/dist/esm/memory/entry/decay.d.ts +36 -0
  203. package/dist/esm/memory/entry/index.d.ts +2 -0
  204. package/dist/esm/memory/entry/types.d.ts +140 -0
  205. package/dist/esm/memory/facts/extractFacts.d.ts +50 -0
  206. package/dist/esm/memory/facts/extractor.d.ts +33 -0
  207. package/dist/esm/memory/facts/formatFacts.d.ts +60 -0
  208. package/dist/esm/memory/facts/index.d.ts +14 -0
  209. package/dist/esm/memory/facts/llmFactExtractor.d.ts +64 -0
  210. package/dist/esm/memory/facts/loadFacts.d.ts +43 -0
  211. package/dist/esm/memory/facts/patternFactExtractor.d.ts +2 -0
  212. package/dist/esm/memory/facts/types.d.ts +68 -0
  213. package/dist/esm/memory/facts/writeFacts.d.ts +19 -0
  214. package/dist/esm/memory/identity/index.d.ts +2 -0
  215. package/dist/esm/memory/identity/types.d.ts +49 -0
  216. package/dist/esm/memory/index.d.ts +19 -0
  217. package/dist/esm/memory/pipeline/auto.d.ts +59 -0
  218. package/dist/esm/memory/pipeline/default.d.ts +49 -0
  219. package/dist/esm/memory/pipeline/ephemeral.d.ts +28 -0
  220. package/dist/esm/memory/pipeline/fact.d.ts +26 -0
  221. package/dist/esm/memory/pipeline/index.d.ts +13 -0
  222. package/dist/esm/memory/pipeline/narrative.d.ts +35 -0
  223. package/dist/esm/memory/pipeline/semantic.d.ts +37 -0
  224. package/dist/esm/memory/pipeline/types.d.ts +31 -0
  225. package/dist/esm/memory/stages/formatDefault.d.ts +64 -0
  226. package/dist/esm/memory/stages/index.d.ts +13 -0
  227. package/dist/esm/memory/stages/loadRecent.d.ts +49 -0
  228. package/dist/esm/memory/stages/pickByBudget.d.ts +63 -0
  229. package/dist/esm/memory/stages/summarize.d.ts +87 -0
  230. package/dist/esm/memory/stages/tokenize.d.ts +43 -0
  231. package/dist/esm/memory/stages/types.d.ts +75 -0
  232. package/dist/esm/memory/stages/writeMessages.d.ts +71 -0
  233. package/dist/esm/memory/store/InMemoryStore.d.ts +62 -0
  234. package/dist/esm/memory/store/index.d.ts +2 -0
  235. package/dist/esm/memory/store/types.d.ts +223 -0
  236. package/dist/esm/memory/wire/index.d.ts +2 -0
  237. package/dist/esm/memory/wire/mountMemoryPipeline.d.ts +108 -0
  238. package/dist/esm/memory-providers.d.ts +37 -0
  239. package/dist/esm/observability/contextError/finders/compareFinders.d.ts +19 -0
  240. package/dist/esm/observability/contextError/finders/index.d.ts +22 -0
  241. package/dist/esm/observability/contextError/finders/rankSuspects.d.ts +2 -0
  242. package/dist/esm/observability/contextError/finders/removeAndRetry.d.ts +11 -0
  243. package/dist/esm/observability/contextError/finders/shrinkToCause.d.ts +11 -0
  244. package/dist/esm/observability/contextError/finders/testManyCombos.d.ts +11 -0
  245. package/dist/esm/observability/contextError/finders/traceSteps.d.ts +2 -0
  246. package/dist/esm/observability/contextError/finders/types.d.ts +88 -0
  247. package/dist/esm/observability-providers.d.ts +46 -0
  248. package/dist/esm/observe.d.ts +62 -0
  249. package/dist/esm/observe.js +7 -1
  250. package/dist/esm/observe.js.map +1 -1
  251. package/dist/esm/patterns/Debate.d.ts +39 -0
  252. package/dist/esm/patterns/MapReduce.d.ts +66 -0
  253. package/dist/esm/patterns/Reflection.d.ts +51 -0
  254. package/dist/esm/patterns/SelfConsistency.d.ts +43 -0
  255. package/dist/esm/patterns/Swarm.d.ts +60 -0
  256. package/dist/esm/patterns/ToT.d.ts +53 -0
  257. package/dist/esm/patterns/index.d.ts +22 -0
  258. package/dist/esm/providers.d.ts +33 -0
  259. package/dist/esm/recorders/core/AgentRecorder.d.ts +15 -0
  260. package/dist/esm/recorders/core/CompositionRecorder.d.ts +17 -0
  261. package/dist/esm/recorders/core/ContextEvaluatedRecorder.d.ts +23 -0
  262. package/dist/esm/recorders/core/ContextRecorder.d.ts +47 -0
  263. package/dist/esm/recorders/core/CostRecorder.d.ts +14 -0
  264. package/dist/esm/recorders/core/EmitBridge.d.ts +30 -0
  265. package/dist/esm/recorders/core/ErrorBridge.d.ts +38 -0
  266. package/dist/esm/recorders/core/EvalRecorder.d.ts +16 -0
  267. package/dist/esm/recorders/core/MemoryRecorder.d.ts +17 -0
  268. package/dist/esm/recorders/core/PermissionRecorder.d.ts +16 -0
  269. package/dist/esm/recorders/core/ReliabilityRecorder.d.ts +24 -0
  270. package/dist/esm/recorders/core/SkillRecorder.d.ts +14 -0
  271. package/dist/esm/recorders/core/StreamRecorder.d.ts +15 -0
  272. package/dist/esm/recorders/core/ToolsRecorder.d.ts +18 -0
  273. package/dist/esm/recorders/core/ValidationRecorder.d.ts +16 -0
  274. package/dist/esm/recorders/core/contextEngineering.d.ts +136 -0
  275. package/dist/esm/recorders/core/typedEmit.d.ts +34 -0
  276. package/dist/esm/recorders/core/types.d.ts +97 -0
  277. package/dist/esm/recorders/observability/AgentThinkingTraceRecorder.d.ts +117 -0
  278. package/dist/esm/recorders/observability/BoundaryRecorder.d.ts +546 -0
  279. package/dist/esm/recorders/observability/FlowchartRecorder.d.ts +220 -0
  280. package/dist/esm/recorders/observability/FlowchartRecorder.js +10 -2
  281. package/dist/esm/recorders/observability/FlowchartRecorder.js.map +1 -1
  282. package/dist/esm/recorders/observability/LiveStateRecorder.d.ts +250 -0
  283. package/dist/esm/recorders/observability/LoggingRecorder.d.ts +91 -0
  284. package/dist/esm/recorders/observability/RouteRecorder.d.ts +83 -0
  285. package/dist/esm/recorders/observability/RunStepRecorder.d.ts +231 -0
  286. package/dist/esm/recorders/observability/StatusRecorder.d.ts +36 -0
  287. package/dist/esm/recorders/observability/ToolChoiceRecorder.d.ts +164 -0
  288. package/dist/esm/recorders/observability/ToolLineageRecorder.d.ts +71 -0
  289. package/dist/esm/recorders/observability/commentary/commentaryTemplates.d.ts +105 -0
  290. package/dist/esm/recorders/observability/internal/ActorArrowClassifier.d.ts +25 -0
  291. package/dist/esm/recorders/observability/internal/CandidateAnswerBuffer.d.ts +28 -0
  292. package/dist/esm/recorders/observability/internal/ForkTracker.d.ts +60 -0
  293. package/dist/esm/recorders/observability/internal/RootInferrer.d.ts +51 -0
  294. package/dist/esm/recorders/observability/internal/SequenceSiblingTracker.d.ts +24 -0
  295. package/dist/esm/recorders/observability/localObservability.d.ts +48 -0
  296. package/dist/esm/recorders/observability/localObservability.js +54 -0
  297. package/dist/esm/recorders/observability/localObservability.js.map +1 -0
  298. package/dist/esm/recorders/observability/observeRunId.d.ts +36 -0
  299. package/dist/esm/recorders/observability/status/statusTemplates.d.ts +106 -0
  300. package/dist/esm/recorders/observability/trace.d.ts +119 -0
  301. package/dist/esm/recorders/observability/trace.js +99 -0
  302. package/dist/esm/recorders/observability/trace.js.map +1 -0
  303. package/dist/esm/reliability/CircuitBreaker.d.ts +75 -0
  304. package/dist/esm/reliability/buildReliabilityGateChart.d.ts +53 -0
  305. package/dist/esm/reliability/classifyError.d.ts +28 -0
  306. package/dist/esm/reliability/index.d.ts +35 -0
  307. package/dist/esm/reliability/types.d.ts +327 -0
  308. package/dist/esm/resilience/fallbackProvider.d.ts +33 -0
  309. package/dist/esm/resilience/index.d.ts +21 -0
  310. package/dist/esm/resilience/withCircuitBreaker.d.ts +129 -0
  311. package/dist/esm/resilience/withFallback.d.ts +45 -0
  312. package/dist/esm/resilience/withRetry.d.ts +71 -0
  313. package/dist/esm/security/PermissionPolicy.d.ts +124 -0
  314. package/dist/esm/security/PolicyHaltError.d.ts +72 -0
  315. package/dist/esm/security/extractSequence.d.ts +46 -0
  316. package/dist/esm/security/index.d.ts +44 -0
  317. package/dist/esm/security/thinkingRedaction.d.ts +50 -0
  318. package/dist/esm/status.d.ts +48 -0
  319. package/dist/esm/strategies/attach.d.ts +47 -0
  320. package/dist/esm/strategies/compose.d.ts +48 -0
  321. package/dist/esm/strategies/defaults/chatBubbleLiveStatus.d.ts +36 -0
  322. package/dist/esm/strategies/defaults/consoleObservability.d.ts +42 -0
  323. package/dist/esm/strategies/defaults/inMemorySinkCost.d.ts +50 -0
  324. package/dist/esm/strategies/defaults/index.d.ts +30 -0
  325. package/dist/esm/strategies/defaults/noopLens.d.ts +28 -0
  326. package/dist/esm/strategies/index.d.ts +36 -0
  327. package/dist/esm/strategies/registry.d.ts +70 -0
  328. package/dist/esm/strategies/types.d.ts +303 -0
  329. package/dist/esm/stream.d.ts +82 -0
  330. package/dist/esm/thinking/AnthropicThinkingHandler.d.ts +42 -0
  331. package/dist/esm/thinking/MockThinkingHandler.d.ts +50 -0
  332. package/dist/esm/thinking/OpenAIThinkingHandler.d.ts +37 -0
  333. package/dist/esm/thinking/index.d.ts +51 -0
  334. package/dist/esm/thinking/registry.d.ts +33 -0
  335. package/dist/esm/thinking/types.d.ts +162 -0
  336. package/dist/esm/tool-providers/gatedTools.d.ts +36 -0
  337. package/dist/esm/tool-providers/index.d.ts +41 -0
  338. package/dist/esm/tool-providers/skillScopedTools.d.ts +45 -0
  339. package/dist/esm/tool-providers/staticTools.d.ts +21 -0
  340. package/dist/esm/tool-providers/types.d.ts +138 -0
  341. package/dist/index.js +6 -2
  342. package/dist/index.js.map +1 -1
  343. package/dist/lib/context-bisect/index.js +3 -0
  344. package/dist/lib/context-bisect/index.js.map +1 -1
  345. package/dist/lib/context-bisect/localize.js +2 -0
  346. package/dist/lib/context-bisect/localize.js.map +1 -1
  347. package/dist/lib/injection-engine/buildInjectionEngineSubflow.js +1 -0
  348. package/dist/lib/injection-engine/buildInjectionEngineSubflow.js.map +1 -1
  349. package/dist/lib/injection-engine/entryScorer.js +178 -0
  350. package/dist/lib/injection-engine/entryScorer.js.map +1 -0
  351. package/dist/lib/injection-engine/index.js +5 -1
  352. package/dist/lib/injection-engine/index.js.map +1 -1
  353. package/dist/lib/injection-engine/skillGraph.js +35 -41
  354. package/dist/lib/injection-engine/skillGraph.js.map +1 -1
  355. package/dist/lib/injection-engine/types.js.map +1 -1
  356. package/dist/memory/define.types.js +1 -1
  357. package/dist/observe.js +14 -3
  358. package/dist/observe.js.map +1 -1
  359. package/dist/recorders/observability/FlowchartRecorder.js +12 -3
  360. package/dist/recorders/observability/FlowchartRecorder.js.map +1 -1
  361. package/dist/recorders/observability/localObservability.js +58 -0
  362. package/dist/recorders/observability/localObservability.js.map +1 -0
  363. package/dist/recorders/observability/trace.js +105 -0
  364. package/dist/recorders/observability/trace.js.map +1 -0
  365. package/dist/types/core/RunnerBase.d.ts.map +1 -1
  366. package/dist/types/core/agent/buildAgentChart.d.ts.map +1 -1
  367. package/dist/types/core/agent/buildDynamicAgentChart.d.ts.map +1 -1
  368. package/dist/types/core/agent/stages/pickEntry.d.ts.map +1 -1
  369. package/dist/types/core/agent/types.d.ts +8 -4
  370. package/dist/types/core/agent/types.d.ts.map +1 -1
  371. package/dist/types/core/runner.d.ts +12 -0
  372. package/dist/types/core/runner.d.ts.map +1 -1
  373. package/dist/types/index.d.ts +1 -1
  374. package/dist/types/index.d.ts.map +1 -1
  375. package/dist/types/lib/context-bisect/index.d.ts +3 -0
  376. package/dist/types/lib/context-bisect/index.d.ts.map +1 -1
  377. package/dist/types/lib/context-bisect/localize.d.ts +2 -0
  378. package/dist/types/lib/context-bisect/localize.d.ts.map +1 -1
  379. package/dist/types/lib/injection-engine/buildInjectionEngineSubflow.d.ts.map +1 -1
  380. package/dist/types/lib/injection-engine/entryScorer.d.ts +94 -0
  381. package/dist/types/lib/injection-engine/entryScorer.d.ts.map +1 -0
  382. package/dist/types/lib/injection-engine/index.d.ts +1 -0
  383. package/dist/types/lib/injection-engine/index.d.ts.map +1 -1
  384. package/dist/types/lib/injection-engine/skillGraph.d.ts +21 -24
  385. package/dist/types/lib/injection-engine/skillGraph.d.ts.map +1 -1
  386. package/dist/types/lib/injection-engine/types.d.ts +9 -4
  387. package/dist/types/lib/injection-engine/types.d.ts.map +1 -1
  388. package/dist/types/memory/define.types.d.ts +1 -1
  389. package/dist/types/observe.d.ts +3 -1
  390. package/dist/types/observe.d.ts.map +1 -1
  391. package/dist/types/recorders/observability/FlowchartRecorder.d.ts +8 -1
  392. package/dist/types/recorders/observability/FlowchartRecorder.d.ts.map +1 -1
  393. package/dist/types/recorders/observability/localObservability.d.ts +49 -0
  394. package/dist/types/recorders/observability/localObservability.d.ts.map +1 -0
  395. package/dist/types/recorders/observability/trace.d.ts +120 -0
  396. package/dist/types/recorders/observability/trace.d.ts.map +1 -0
  397. package/package.json +203 -56
@@ -0,0 +1,565 @@
1
+ /**
2
+ * AgentBuilder — fluent builder for Agent. Extracted from Agent.ts in
3
+ * v2.11.2 as part of the core/agent decomposition. Same surface, same
4
+ * behavior; just lives in its own file for readability.
5
+ *
6
+ * Re-exported by Agent.ts so external consumers importing
7
+ * `AgentBuilder` from `'../core/Agent.js'` continue to work.
8
+ */
9
+ import { type OutputSchemaOptions, type OutputSchemaParser } from '../outputSchema.js';
10
+ import { type OutputFallbackOptions } from '../outputFallback.js';
11
+ import type { CachePolicy } from '../../cache/types.js';
12
+ import type { Injection, InjectionContext } from '../../lib/injection-engine/types.js';
13
+ import type { EntryScoring } from '../../lib/injection-engine/skillGraph.js';
14
+ import type { MemoryDefinition } from '../../memory/define.types.js';
15
+ import type { ReliabilityConfig } from '../../reliability/types.js';
16
+ import type { ThinkingHandler } from '../../thinking/types.js';
17
+ import type { Tool } from '../tools.js';
18
+ import type { ToolProvider } from '../../tool-providers/types.js';
19
+ import { type SelfExplainOptions } from '../../lib/trace-toolpack/selfExplain.js';
20
+ import { Agent } from '../Agent.js';
21
+ import type { AgentOptions } from './types.js';
22
+ /**
23
+ * Fluent builder. `tool()` accepts any Tool<TArgs, TResult> and registers
24
+ * it by its schema.name. Duplicate names throw at build time.
25
+ */
26
+ export declare class AgentBuilder {
27
+ private readonly opts;
28
+ private systemPromptValue;
29
+ /**
30
+ * Cache policy for the base system prompt. Set via the optional
31
+ * 2nd argument to `.system(text, { cache })`. Default `'always'` —
32
+ * the base prompt is stable per-turn and an ideal cache anchor.
33
+ */
34
+ private systemPromptCachePolicy;
35
+ /**
36
+ * Global cache kill switch. Set via `Agent.create({ caching: 'off' })`
37
+ * (handled in `AgentOptions` propagation). Defaults to `false`
38
+ * (caching enabled). When `true`, the CacheGate decider routes to
39
+ * `'no-markers'` every iteration regardless of other rules.
40
+ */
41
+ private cachingDisabledValue;
42
+ /**
43
+ * Optional explicit CacheStrategy override. Default: undefined,
44
+ * which means the agent auto-resolves from
45
+ * `getDefaultCacheStrategy(provider.name)` at construction. Power
46
+ * users override here for custom backends or test mocks.
47
+ */
48
+ private cacheStrategyOverride?;
49
+ private readonly registry;
50
+ private readonly injectionList;
51
+ /** Captured from `.skillGraph(graph)` — the cursor resolver the Injection
52
+ * Engine uses to `from`-gate route triggers. Undefined unless a graph with
53
+ * route edges was mounted. */
54
+ private skillGraphNextSkill?;
55
+ /** Captured from `.skillGraph(graph)` — the reachable-set resolver the
56
+ * read_skill gate uses to reject out-of-set skill jumps. Undefined → the gate
57
+ * is off (plain read_skill agents are unaffected). */
58
+ private skillGraphReachable?;
59
+ /** Captured from `.skillGraph(graph)` — the relevance entry scorer
60
+ * (`graph.scoreEntries`), present only with `.entryByRelevance()`. When set, the
61
+ * PickEntry stage picks the starting skill by relevance once per turn. */
62
+ private skillGraphScoreEntries?;
63
+ private readonly memoryList;
64
+ /**
65
+ * Optional terminal contract — see `outputSchema()`. Stored on the
66
+ * builder, propagated to the Agent at `.build()` time.
67
+ */
68
+ private outputSchemaParser?;
69
+ /** 3-tier output fallback chain — set via `.outputFallback({...})`.
70
+ * Optional; absent = current throw-on-validation-failure behavior. */
71
+ private outputFallbackCfg?;
72
+ /**
73
+ * Optional `ToolProvider` set via `.toolProvider()`. Propagated to
74
+ * the Agent's Tools slot subflow + tool-call dispatcher; consulted
75
+ * per iteration so dynamic chains (`gatedTools`, `skillScopedTools`)
76
+ * react to current activation state.
77
+ */
78
+ private toolProviderRef?;
79
+ /**
80
+ * Optional override for `AgentOptions.maxIterations`. When set via
81
+ * the `.maxIterations()` builder method, takes precedence over the
82
+ * value passed to `Agent.create({ maxIterations })`.
83
+ */
84
+ private maxIterationsOverride?;
85
+ /**
86
+ * Recorders collected via `.recorder()`. Attached to the built Agent
87
+ * before `build()` returns (each via `agent.attach(rec)`).
88
+ */
89
+ private readonly recorderList;
90
+ private appNameValue;
91
+ private commentaryOverrides;
92
+ private thinkingOverrides;
93
+ /**
94
+ * Optional rules-based reliability config (v2.11.5+). Set via
95
+ * `.reliability({...})`. Wraps every `CallLLM` execution in a
96
+ * retry/fallback/fail-fast loop driven by `preCheck` and `postDecide`
97
+ * rules. See `ReliabilityConfig` for the rule shape.
98
+ */
99
+ private reliabilityConfig?;
100
+ /**
101
+ * Optional ThinkingHandler (v2.14+). Three states:
102
+ * - undefined (default): auto-wire by `provider.name` via
103
+ * `findThinkingHandler` from the registry
104
+ * - explicit handler: override the auto-wire
105
+ * - explicit `null`: opt out (no thinking handler mounted at all,
106
+ * even if the provider would auto-match)
107
+ *
108
+ * The framework wraps the configured handler in a real footprintjs
109
+ * sub-subflow at chart build time (see `buildThinkingSubflow`).
110
+ * Mounted as a stage AFTER CallLLM inside `sf-call-llm`. Build-time
111
+ * conditional — no stage when no handler resolves.
112
+ */
113
+ private thinkingHandlerValue?;
114
+ /**
115
+ * v2.14+ — request-side thinking activation. When set, every LLM
116
+ * call carries `LLMRequest.thinking = { budget }`, asking the
117
+ * provider (Anthropic) to emit reasoning blocks. Independent from
118
+ * `.thinkingHandler()` (response-side normalization choice).
119
+ */
120
+ private thinkingBudgetValue?;
121
+ private selfExplainConfig?;
122
+ constructor(opts: AgentOptions);
123
+ /**
124
+ * Set the base system prompt.
125
+ *
126
+ * @param prompt - The system prompt text. Stable per-turn.
127
+ * @param options - Optional config. `cache` controls how the
128
+ * CacheDecision subflow treats this prompt block:
129
+ * - `'always'` (default) — cache the base prompt as a stable
130
+ * prefix anchor. Highest cache-hit rate; recommended for
131
+ * production agents whose system prompt rarely changes.
132
+ * - `'never'` — skip caching. Use if the prompt contains volatile
133
+ * content (timestamps, per-request user IDs).
134
+ * - `'while-active'` — semantically equivalent to `'always'` for
135
+ * the base prompt (it's always active by definition).
136
+ * - `{ until }` — conditional invalidation (e.g., flush after iter 5).
137
+ */
138
+ system(prompt: string, options?: {
139
+ readonly cache?: CachePolicy;
140
+ }): this;
141
+ tool<TArgs, TResult>(tool: Tool<TArgs, TResult>): this;
142
+ /**
143
+ * Register many tools at once. Convenience for tool sources that
144
+ * return a list (e.g., `await mcpClient(...).tools()`). Each tool
145
+ * is registered via `.tool()` so duplicate-name validation still
146
+ * fires per-entry.
147
+ */
148
+ tools(tools: ReadonlyArray<Tool>): this;
149
+ /**
150
+ * Wire a chainable `ToolProvider` (from `agentfootprint/tool-providers`)
151
+ * as the agent's per-iteration tool source.
152
+ *
153
+ * The provider is consulted EVERY iteration via `provider.list(ctx)`
154
+ * with `ctx = { iteration, activeSkillId, identity }`. Tools the
155
+ * provider emits flow into the Tools slot alongside any static
156
+ * tools registered via `.tool()` / `.tools()`. The tool-call
157
+ * dispatcher also consults the provider so dynamic chains
158
+ * (`gatedTools`, `skillScopedTools`) dispatch correctly when their
159
+ * visible-set changes mid-turn.
160
+ *
161
+ * Throws if called more than once on the same builder (avoids
162
+ * silent override surprises).
163
+ *
164
+ * @example Permission-gated baseline
165
+ * import { gatedTools, staticTools } from 'agentfootprint/tool-providers';
166
+ * import { PermissionPolicy } from 'agentfootprint/security';
167
+ *
168
+ * const policy = PermissionPolicy.fromRoles({
169
+ * readonly: ['lookup', 'list_skills', 'read_skill'],
170
+ * admin: ['lookup', 'list_skills', 'read_skill', 'delete'],
171
+ * }, 'readonly');
172
+ *
173
+ * const provider = gatedTools(
174
+ * staticTools(allTools),
175
+ * (toolName) => policy.isAllowed(toolName),
176
+ * );
177
+ *
178
+ * const agent = Agent.create({ provider: llm, model })
179
+ * .system('You answer.')
180
+ * .toolProvider(provider)
181
+ * .build();
182
+ */
183
+ toolProvider(provider: ToolProvider): this;
184
+ /**
185
+ * Override the ReAct iteration cap set via `Agent.create({
186
+ * maxIterations })`. Convenience for builder-style code that prefers
187
+ * fluent setters over constructor opts. Last call wins.
188
+ *
189
+ * Throws if `n` is not a positive integer or exceeds the hard cap
190
+ * (`clampIterations`'s upper bound).
191
+ */
192
+ maxIterations(n: number): this;
193
+ /**
194
+ * Attach a footprintjs `CombinedRecorder` to the built Agent. Wired
195
+ * via `agent.attach(rec)` immediately after construction, so the
196
+ * recorder sees every event from the very first run.
197
+ *
198
+ * Equivalent to calling `agent.attach(rec)` post-build; the builder
199
+ * method is a convenience for codebases that prefer fully-fluent
200
+ * agent assembly. Multiple recorders are supported (each gets its
201
+ * own `attach()` call).
202
+ */
203
+ recorder(rec: import('footprintjs').CombinedRecorder): this;
204
+ /**
205
+ * Set the agent's display name — substituted as `{{appName}}` in
206
+ * commentary + thinking templates. Same place to brand a tenant
207
+ * ("Acme Bot"), distinguish multi-agent roles ("Triage" vs
208
+ * "Reviewer"), or localize ("Asistente"). Default: `'Chatbot'`.
209
+ */
210
+ appName(name: string): this;
211
+ /**
212
+ * Override agentfootprint's bundled commentary templates. Spread on
213
+ * top of `defaultCommentaryTemplates`; missing keys fall back. Same
214
+ * `Record<string, string>` shape with `{{vars}}` substitution as
215
+ * the bundled defaults — see `defaultCommentaryTemplates` for the
216
+ * full key list.
217
+ *
218
+ * Use cases: i18n (`'agent.turn_start': 'El usuario...'`), brand
219
+ * voice ("You: {{userPrompt}}"), per-tenant customization.
220
+ */
221
+ commentaryTemplates(templates: Readonly<Record<string, string>>): this;
222
+ /**
223
+ * Override agentfootprint's bundled thinking templates. Same
224
+ * contract shape as commentary; different vocabulary — first-person
225
+ * status the chat bubble shows mid-call. Per-tool overrides go via
226
+ * `tool.<toolName>` keys (e.g., `'tool.weather': 'Looking up the
227
+ * weather…'`). See `defaultStatusTemplates` for the full key list.
228
+ */
229
+ thinkingTemplates(templates: Readonly<Record<string, string>>): this;
230
+ /**
231
+ * Register any `Injection`. Use this for power-user / custom flavors;
232
+ * for built-in flavors use the typed sugar (`.skill`, `.steering`,
233
+ * `.instruction`, `.fact`).
234
+ */
235
+ injection(injection: Injection): this;
236
+ /**
237
+ * Register a Skill — LLM-activated, system-prompt + tools.
238
+ * Auto-attaches the `read_skill` activation tool to the agent.
239
+ * Skill stays active for the rest of the turn once activated.
240
+ */
241
+ skill(injection: Injection): this;
242
+ /**
243
+ * Bulk-register every Skill in a `SkillRegistry`. Use for shared
244
+ * skill catalogs across multiple Agents — register skills once on
245
+ * the registry; attach the same registry to every consumer Agent.
246
+ *
247
+ * @example
248
+ * const registry = new SkillRegistry();
249
+ * registry.register(billingSkill).register(refundSkill);
250
+ * const supportAgent = Agent.create({ provider }).skills(registry).build();
251
+ * const escalationAgent = Agent.create({ provider }).skills(registry).build();
252
+ */
253
+ skills(registry: {
254
+ list(): readonly Injection[];
255
+ }): this;
256
+ /**
257
+ * Mount a declarative **skill graph** (proposal 002) — each skill carries a
258
+ * graph-derived trigger (entry → always/rule, deterministic route → rule /
259
+ * on-tool-return), so dynamic token-efficient loading becomes *declared* and
260
+ * *drawable*. Pure sugar over `.injection()` — `graph.toMermaid()` renders the
261
+ * topology.
262
+ *
263
+ * @example
264
+ * const graph = skillGraph()
265
+ * .entry(triage)
266
+ * .route(triage, sfp, { when: (r) => r.toolName === 'get_counters' && JSON.parse(r.result).crc > 0 })
267
+ * .build();
268
+ * Agent.create({ provider }).skillGraph(graph).build();
269
+ */
270
+ skillGraph(graph: {
271
+ skills: readonly Injection[];
272
+ nextSkill: (ctx: InjectionContext) => string | undefined;
273
+ reachableSkills?: (currentSkillId?: string) => readonly string[];
274
+ scoreEntries?: (ctx: InjectionContext, signal?: AbortSignal) => Promise<EntryScoring>;
275
+ }): this;
276
+ /**
277
+ * Register a Steering doc — always-on system-prompt rule.
278
+ * Use for invariant guidance: output format, persona, safety policies.
279
+ */
280
+ steering(injection: Injection): this;
281
+ /**
282
+ * Register an Instruction — rule-based system-prompt guidance.
283
+ * Predicate runs each iteration. Use for context-dependent rules
284
+ * including the "Dynamic ReAct" `on-tool-return` pattern.
285
+ */
286
+ instruction(injection: Injection): this;
287
+ /**
288
+ * Bulk-register many instructions at once. Convenience for consumer
289
+ * code that organizes its instruction set in a flat array (`const
290
+ * instructions = [outputFormat, dataRouting, ...]`). Each element
291
+ * is registered via `.instruction()` so duplicate-id checks still
292
+ * fire per-entry.
293
+ */
294
+ instructions(injections: ReadonlyArray<Injection>): this;
295
+ /**
296
+ * Register a Fact — developer-supplied data the LLM should see.
297
+ * User profile, env info, computed summary, current time, …
298
+ * Distinct from Skills (LLM-activated guidance) and Steering
299
+ * (always-on rules) in INTENT — the engine treats them all alike.
300
+ */
301
+ fact(injection: Injection): this;
302
+ /**
303
+ * Register a Memory subsystem — load/persist conversation context,
304
+ * facts, narrative beats, or causal snapshots across runs.
305
+ *
306
+ * The `MemoryDefinition` is produced by `defineMemory({ type, strategy,
307
+ * store })`. Multiple memories layer cleanly via per-id scope keys
308
+ * (`memoryInjection_${id}`):
309
+ *
310
+ * ```ts
311
+ * Agent.create({ provider })
312
+ * .memory(defineMemory({ id: 'short', type: MEMORY_TYPES.EPISODIC,
313
+ * strategy: { kind: MEMORY_STRATEGIES.WINDOW, size: 10 },
314
+ * store }))
315
+ * .memory(defineMemory({ id: 'facts', type: MEMORY_TYPES.SEMANTIC,
316
+ * strategy: { kind: MEMORY_STRATEGIES.EXTRACT,
317
+ * extractor: 'pattern' }, store }))
318
+ * .build();
319
+ * ```
320
+ *
321
+ * The READ subflow runs at the configured `timing` (default
322
+ * `MEMORY_TIMING.TURN_START`) and writes its formatted output to the
323
+ * `memoryInjection_${id}` scope key for the slot subflows to consume.
324
+ */
325
+ memory(definition: MemoryDefinition): this;
326
+ /**
327
+ * Register a RAG retriever — semantic search over a vector-indexed
328
+ * corpus. Identical plumbing to `.memory()` (RAG resolves to a
329
+ * `MemoryDefinition` produced by `defineRAG()`); this alias exists
330
+ * so the consumer's intent reads clearly:
331
+ *
332
+ * ```ts
333
+ * agent
334
+ * .memory(shortTermConversation) // remembers what the USER said
335
+ * .rag(productDocs) // retrieves what the CORPUS says
336
+ * .build();
337
+ * ```
338
+ *
339
+ * Both end up as memory subflows, but the alias separates "user
340
+ * conversation memory" from "document corpus retrieval" in code
341
+ * intent, ids, and Lens chips.
342
+ */
343
+ rag(definition: MemoryDefinition): this;
344
+ /**
345
+ * Declarative terminal contract. The agent's final answer must be
346
+ * JSON matching `parser`. Auto-injects a system-prompt instruction
347
+ * telling the LLM the shape, and exposes `agent.runTyped()` /
348
+ * `agent.parseOutput()` for parse + validate at the call site.
349
+ *
350
+ * The `parser` is duck-typed: any object with a `parse(unknown): T`
351
+ * method works (Zod, Valibot, ArkType, hand-written). The optional
352
+ * `description` field on the parser drives the auto-generated
353
+ * instruction; consumers can also override via `opts.instruction`.
354
+ *
355
+ * Throws if called more than once on the same builder (avoids
356
+ * silent override surprises).
357
+ *
358
+ * @param parser Validation strategy that throws on shape failure.
359
+ * @param opts Optional `{ name, instruction }` to customize.
360
+ *
361
+ * @example
362
+ * import { z } from 'zod';
363
+ * const Output = z.object({
364
+ * status: z.enum(['ok', 'err']),
365
+ * items: z.array(z.string()),
366
+ * }).describe('A status enum + an array of strings.');
367
+ *
368
+ * const agent = Agent.create({...})
369
+ * .outputSchema(Output)
370
+ * .build();
371
+ *
372
+ * const typed = await agent.runTyped({ message: '...' });
373
+ * typed.status; // narrowed to 'ok' | 'err'
374
+ */
375
+ outputSchema<T>(parser: OutputSchemaParser<T>, opts?: OutputSchemaOptions): this;
376
+ /**
377
+ * 3-tier degradation for output-schema validation failures. Pairs
378
+ * with `.outputSchema()` — calling `.outputFallback()` without an
379
+ * `outputSchema` first throws (the fallback has nothing to validate).
380
+ *
381
+ * Three tiers:
382
+ *
383
+ * 1. **Primary** — LLM emitted schema-valid JSON. Caller gets it.
384
+ * 2. **Fallback** — `OutputSchemaError` thrown. The async
385
+ * `fallback(error, raw)` runs; its return is re-validated.
386
+ * 3. **Canned** — static safety-net value. NEVER throws when set.
387
+ *
388
+ * `canned` is validated against the schema at builder time —
389
+ * fail-fast on misconfig (a `canned` that doesn't validate would
390
+ * defeat the fail-open guarantee).
391
+ *
392
+ * Two typed events fire on tier transitions for observability:
393
+ * - `agentfootprint.resilience.output_fallback_triggered`
394
+ * - `agentfootprint.resilience.output_canned_used`
395
+ *
396
+ * @example
397
+ * ```ts
398
+ * import { z } from 'zod';
399
+ * const Refund = z.object({ amount: z.number(), reason: z.string() });
400
+ *
401
+ * const agent = Agent.create({...})
402
+ * .outputSchema(Refund)
403
+ * .outputFallback({
404
+ * fallback: async (err, raw) => ({ amount: 0, reason: 'manual review' }),
405
+ * canned: { amount: 0, reason: 'unable to process' },
406
+ * })
407
+ * .build();
408
+ * ```
409
+ */
410
+ outputFallback<T>(options: OutputFallbackOptions<T>): this;
411
+ /**
412
+ * Wire rules-based reliability around every `CallLLM` execution.
413
+ * The framework wraps the LLM call in a retry/fallback/fail-fast
414
+ * loop driven by `preCheck` and `postDecide` rules.
415
+ *
416
+ * Decision verbs the rules can emit (see `ReliabilityDecision` for
417
+ * the full list):
418
+ *
419
+ * • `continue` — pre-check OK, proceed to the call
420
+ * • `ok` — post-call OK, commit and return
421
+ * • `retry` — re-call same provider (bumps `attempt`)
422
+ * • `retry-other` — advance to next provider in `providers[]`
423
+ * • `fallback` — invoke `config.fallback(req, lastError)`
424
+ * • `fail-fast` — throw `ReliabilityFailFastError` at `agent.run()`
425
+ *
426
+ * **Streaming + reliability semantics — first-chunk arbitration:**
427
+ * Pre-first-chunk failures (connection/headers/breaker-open) honor
428
+ * the full rule set (retry, retry-other, fallback, fail-fast).
429
+ * Post-first-chunk failures (mid-stream) honor only `ok` and
430
+ * `fail-fast`; rules wanting `retry`/`retry-other`/`fallback` are
431
+ * escalated to fail-fast with kind `'mid-stream-not-retryable'`.
432
+ * This matches LangChain's `RunnableWithFallbacks` pattern and
433
+ * the prevailing industry default — see the streaming + reliability
434
+ * design memo for the full discussion.
435
+ *
436
+ * Throws if called more than once on the same builder.
437
+ *
438
+ * @example
439
+ * import { Agent } from 'agentfootprint';
440
+ * import { ReliabilityFailFastError } from 'agentfootprint/reliability';
441
+ *
442
+ * const agent = Agent.create({ provider, model: 'mock' })
443
+ * .system('Triage support tickets.')
444
+ * .reliability({
445
+ * postDecide: [
446
+ * { when: (s) => s.errorKind === '5xx-transient' && s.attempt < 3,
447
+ * then: 'retry', kind: 'transient-retry' },
448
+ * { when: (s) => s.error !== undefined,
449
+ * then: 'fail-fast', kind: 'unrecoverable' },
450
+ * ],
451
+ * circuitBreaker: { failureThreshold: 3 },
452
+ * })
453
+ * .build();
454
+ *
455
+ * try {
456
+ * await agent.run({ message: 'help' });
457
+ * } catch (e) {
458
+ * if (e instanceof ReliabilityFailFastError) {
459
+ * console.log(e.kind, e.reason);
460
+ * }
461
+ * }
462
+ */
463
+ reliability(config: ReliabilityConfig): this;
464
+ /**
465
+ * Wire a thinking handler (v2.14+). Three usage patterns:
466
+ *
467
+ * • OMITTED (default) — framework auto-wires by `provider.name` via
468
+ * `findThinkingHandler` from the registry. Most consumers using
469
+ * a shipped provider get thinking support for free.
470
+ *
471
+ * • EXPLICIT handler — override the auto-wire. For custom providers
472
+ * or for swapping in a custom Anthropic/OpenAI handler with
473
+ * different normalization (e.g. redacting blocks before they
474
+ * land).
475
+ *
476
+ * • EXPLICIT `null` — opt out entirely. The thinking subflow is NOT
477
+ * mounted even if the provider would auto-match. Use when you
478
+ * want to skip thinking parsing for this agent (cost / latency /
479
+ * UX reasons).
480
+ *
481
+ * Calling twice throws — same shape as `.reliability()` /
482
+ * `.outputSchema()` to enforce single-source intent.
483
+ *
484
+ * @example
485
+ * // Default — auto-wire AnthropicThinkingHandler for anthropic provider
486
+ * Agent.create({ provider: anthropic({...}), model: '...' }).build();
487
+ *
488
+ * @example
489
+ * // Custom handler that redacts thinking content
490
+ * Agent.create({...}).thinkingHandler(myRedactingHandler).build();
491
+ *
492
+ * @example
493
+ * // Opt out of thinking parsing entirely
494
+ * Agent.create({ provider: anthropic({...}), model: '...' })
495
+ * .thinkingHandler(null)
496
+ * .build();
497
+ */
498
+ thinkingHandler(handler: ThinkingHandler | null): this;
499
+ /**
500
+ * v2.14+ — REQUEST-side thinking activation. Tells the provider to
501
+ * emit reasoning blocks alongside its response.
502
+ *
503
+ * **What this does:** every LLM call carries
504
+ * `LLMRequest.thinking = { budget }`. The AnthropicProvider
505
+ * translates to `thinking: { type: 'enabled', budget_tokens: N }`
506
+ * on the wire. The model spends up to `budget` reasoning tokens
507
+ * before producing the visible response.
508
+ *
509
+ * **Distinct from `.thinkingHandler()`:**
510
+ * - `.thinking({ budget })` = ASK the model to think (request side)
511
+ * - `.thinkingHandler(h)` = NORMALIZE the response (response side)
512
+ *
513
+ * Most consumers want both; auto-wired handler covers the response
514
+ * side automatically when `.thinking()` is set on a thinking-capable
515
+ * provider. Setting `.thinking()` without `.thinkingHandler(null)`
516
+ * is the typical happy path.
517
+ *
518
+ * **Provider compatibility:**
519
+ * - Anthropic: requires claude-sonnet-4-5 / opus-4-5 (or newer).
520
+ * Older models reject with HTTP 400.
521
+ * - OpenAI: ignores. o1/o3 reasoning is selected at the model id
522
+ * level; this field is a no-op for OpenAIProvider.
523
+ *
524
+ * **Budget guidance:** Anthropic recommends 1024-32000 reasoning
525
+ * tokens. `budget` MUST be less than the request's `max_tokens`
526
+ * (defaults to 4096 in AnthropicProvider — bump via the request
527
+ * `maxTokens` if budget > ~3000).
528
+ *
529
+ * Calling twice throws — same shape as `.reliability()` /
530
+ * `.outputSchema()`.
531
+ *
532
+ * @example
533
+ * Agent.create({ provider: anthropic({...}), model: 'claude-sonnet-4-5' })
534
+ * .system('You are a careful reasoning agent.')
535
+ * .thinking({ budget: 5000 }) // ask Anthropic to think
536
+ * .build();
537
+ */
538
+ thinking(opts: {
539
+ budget: number;
540
+ }): this;
541
+ /**
542
+ * Let this agent answer why-questions about its OWN previous completed
543
+ * turn, from its recorded trace. Mounts one skill: day to day the tool
544
+ * catalog carries only the skill's activation row; when the user asks
545
+ * "why did you…", the LLM activates it and that iteration alone gets
546
+ * the trace tools (inline mode) or a single `explain_run` tool that
547
+ * runs a nested trace debugger on a cheaper model (delegate mode).
548
+ *
549
+ * Evidence binds LATE — always to the previous COMPLETED run, never
550
+ * the in-flight one — and includes control edges (a per-run
551
+ * control-dependence recorder is attached automatically).
552
+ *
553
+ * @example
554
+ * Agent.create({ provider, model })
555
+ * .system('You are a refunds assistant.')
556
+ * .tool(lookupOrder)
557
+ * .selfExplain() // inline, zero config
558
+ * .build();
559
+ *
560
+ * @example
561
+ * .selfExplain({ delegate: { provider: anthropic(), model: 'claude-haiku-4-5' } })
562
+ */
563
+ selfExplain(opts?: SelfExplainOptions): this;
564
+ build(): Agent;
565
+ }
@@ -0,0 +1,109 @@
1
+ /**
2
+ * buildAgentChart — assemble the agent's full footprintjs FlowChart
3
+ * from stage functions + slot subflows + memory wiring.
4
+ *
5
+ * This is the "chart composition" that used to live inline in
6
+ * `Agent.buildChart()`. Extracted for v2.11.2 so:
7
+ *
8
+ * 1. Agent.ts focuses on Agent class lifecycle (constructor, run,
9
+ * attach, getSpec) instead of chart wiring details.
10
+ * 2. The reliability gate chart (v2.11.x) wires into ONE focused
11
+ * file rather than surgically into Agent.ts's 250-line composition
12
+ * block.
13
+ * 3. The composition is independently readable + reviewable —
14
+ * consumers building custom agent shapes have a reference.
15
+ *
16
+ * Chart shape:
17
+ *
18
+ * Initialize
19
+ * → [memory READ subflows for each .memory()]
20
+ * → InjectionEngine (subflow) ← loop target (tool-calls loops here)
21
+ * → Context (selector, PARALLEL fan-out, failFast)
22
+ * ⇉ {System Prompt ‖ Messages ‖ Tools} (slot subflows)
23
+ * → converge
24
+ * → UpdateSkillHistory
25
+ * → Cache (sf-cache subflow: decideCacheMarkers → CacheGate
26
+ * → ApplyMarkers / SkipCaching)
27
+ * → CallLLM (also emits the per-iteration iteration_start marker)
28
+ * → [NormalizeThinking] (subflow, only when a ThinkingHandler resolved)
29
+ * → Route (decider)
30
+ * ├─ tool-calls (pausable) → loopTo(InjectionEngine) ← branch-sourced loop
31
+ * └─ final (subflow) → terminal leaf
32
+ * ┌────── PrepareFinal
33
+ * ├──── [memory WRITE subflows]
34
+ * └──── BreakFinal ($break)
35
+ *
36
+ * (When v2.11.x reliability is configured, the reliability gate chart
37
+ * mounts as a subflow before CallLLM with a TranslateFailFast stage
38
+ * after it. Lands in the next commit.)
39
+ */
40
+ import type { FlowChart, StructureRecorder } from 'footprintjs';
41
+ import type { CachePolicy } from '../../cache/types.js';
42
+ import type { MemoryDefinition } from '../../memory/define.types.js';
43
+ /**
44
+ * Stage handlers + slot subflows the chart composer needs. Mostly
45
+ * passed through verbatim from Agent.buildChart() — the chart shape
46
+ * is identical to what was inline before.
47
+ */
48
+ export interface AgentChartDeps {
49
+ /** Memory READ/WRITE pipeline definitions (one per `.memory()`). */
50
+ readonly memories: readonly MemoryDefinition[];
51
+ /** Evidence bridge (#5): `causalEvidenceRecorder().collect`, threaded into
52
+ * CAUSAL memories' write mounts so snapshots persist real evidence
53
+ * (decisions/toolCalls/iterations/duration/tokens) instead of zeros.
54
+ * Set by the Agent when any mounted memory is CAUSAL. */
55
+ readonly causalEvidenceSource?: () => import('../../memory/causal/evidenceRecorder.js').RunEvidence;
56
+ /** Cache policy for the system-prompt slot, threaded into
57
+ * CacheDecision's inputMapper so its decision rules can match. */
58
+ readonly systemPromptCachePolicy: CachePolicy;
59
+ /** Hard ReAct iteration cap, threaded into CacheDecision's
60
+ * inputMapper for max-iteration policies. */
61
+ readonly maxIterations: number;
62
+ readonly seed: (scope: never) => void;
63
+ readonly callLLM: (scope: never) => Promise<void>;
64
+ readonly routeDecider: (scope: never) => 'tool-calls' | 'final';
65
+ readonly toolCallsHandler: import('footprintjs').PausableHandler<never>;
66
+ readonly injectionEngineSubflow: FlowChart;
67
+ /** Relevance entry router (`entryByRelevance`) — a once-per-turn function stage
68
+ * mounted before the InjectionEngine (off the ReAct loop). Present only when the
69
+ * skill graph was built with a relevance scorer. */
70
+ readonly pickEntryStage?: (scope: never) => Promise<void>;
71
+ readonly systemPromptSubflow: FlowChart;
72
+ readonly messagesSubflow: FlowChart;
73
+ readonly toolsSubflow: FlowChart;
74
+ /**
75
+ * Optional thinking-normalization sub-subflow (v2.14+). Mounted as a
76
+ * stage AFTER CallLLM, BEFORE Route, only when a `ThinkingHandler`
77
+ * resolved (either auto-wired by `provider.name` or explicitly set
78
+ * via `.thinkingHandler()`). When undefined, the stage is NOT added —
79
+ * zero overhead for non-thinking agents (build-time conditional mount).
80
+ */
81
+ readonly thinkingSubflow?: FlowChart;
82
+ readonly updateSkillHistoryStage: (scope: never) => void;
83
+ /**
84
+ * Whether ≥1 Skill is registered. The `UpdateSkillHistory` stage (and
85
+ * therefore the cache's skill-churn rule) is mounted ONLY when true:
86
+ * with no skills the window would record "no skill" every iteration and
87
+ * `detectSkillChurn` could never fire, so the stage would be pure dead
88
+ * weight + a misleading box. Mirrors the `skills.length > 0` gate that
89
+ * auto-attaches `read_skill`, and the `thinkingSubflow` conditional mount.
90
+ */
91
+ readonly hasSkills: boolean;
92
+ /**
93
+ * ReAct loop semantics. `'dynamic'` (default) re-runs the InjectionEngine +
94
+ * all 3 slots every iteration (loop → InjectionEngine). `'classic'`
95
+ * engineers context ONCE (InjectionEngine + system-prompt + tools up front)
96
+ * and loops only the Messages slot (loop → Messages). See AgentOptions.reactMode.
97
+ */
98
+ readonly reactMode?: 'classic' | 'dynamic';
99
+ /** Structure recorders threaded into both `flowChart()` calls (the
100
+ * main chart and the PrepareFinal sub-chart). Each recorder
101
+ * observes per-node build events (`onStageAdded` /
102
+ * `onSubflowMounted` / etc.) for the Agent's chart. Undefined when
103
+ * the consumer didn't attach any. */
104
+ readonly structureRecorders?: readonly StructureRecorder[];
105
+ }
106
+ /**
107
+ * Build the agent's complete FlowChart from the supplied deps.
108
+ */
109
+ export declare function buildAgentChart(deps: AgentChartDeps): FlowChart;
@@ -148,8 +148,9 @@ export function buildAgentChart(deps) {
148
148
  // Skill-graph cursor as of the previous iteration — the `from`-gate the
149
149
  // route triggers compare against. Undefined on cold start / no graph.
150
150
  currentSkillId: parent.currentSkillId,
151
- // Relevance entry ranking (entryByRelevance) — read by defineRelevanceHint.
151
+ // Relevance entry ranking (from an entry scorer) — read by defineRelevanceHint.
152
152
  entryScores: parent.entryScores,
153
+ entryScorer: parent.entryScorer,
153
154
  }),
154
155
  // Carry activeByslot back to parent so next turn's inputMapper can
155
156
  // feed it as priorActiveByslot (the Delta round-trip). currentSkillId is