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,95 @@
1
+ /**
2
+ * BrowserOpenAIProvider — fetch-based OpenAI adapter for browsers.
3
+ *
4
+ * Pattern: Adapter (GoF). Zero peer dependencies — uses global `fetch`.
5
+ * Role: Outer ring. Same `LLMProvider` contract as `OpenAIProvider`
6
+ * but skips the `openai` SDK. For prototypes / playgrounds.
7
+ * Production apps should proxy through a backend.
8
+ * Emits: N/A.
9
+ *
10
+ * Also works with OpenAI-compatible endpoints (Ollama, Together, vLLM)
11
+ * via `apiUrl`.
12
+ *
13
+ * ─── Limitations ────────────────────────────────────────────────────
14
+ *
15
+ * • Multi-modal NOT supported.
16
+ * • CORS depends on the endpoint — OpenAI requires the user-supplied
17
+ * key in the Authorization header, which they'll do explicitly.
18
+ */
19
+ import type { LLMChunk, LLMProvider, LLMRequest, LLMResponse } from '../types.js';
20
+ export interface BrowserOpenAIProviderOptions {
21
+ /** API key. REQUIRED. */
22
+ readonly apiKey: string;
23
+ /** Default model when `LLMRequest.model` is `'openai'`. */
24
+ readonly defaultModel?: string;
25
+ /** Default max tokens. */
26
+ readonly defaultMaxTokens?: number;
27
+ /** Override the API URL (Ollama, Together, vLLM, OpenAI proxies). */
28
+ readonly apiUrl?: string;
29
+ /** Optional `Organization` header. */
30
+ readonly organization?: string;
31
+ /** Auth header scheme. `'bearer'` (default) → `Authorization: Bearer <key>`;
32
+ * `'api-key'` → the `api-key` header (Azure OpenAI). */
33
+ readonly authScheme?: 'bearer' | 'api-key';
34
+ /** Treat the target as a **reasoning model** (o-series): omit `temperature` and send
35
+ * the `developer` role. Standard o-series ids are auto-detected; set for arbitrary
36
+ * Azure deployment names. */
37
+ readonly reasoning?: boolean;
38
+ /** @internal Custom fetch implementation for tests. */
39
+ readonly _fetch?: typeof fetch;
40
+ }
41
+ export declare function browserOpenai(options: BrowserOpenAIProviderOptions): LLMProvider;
42
+ export declare class BrowserOpenAIProvider implements LLMProvider {
43
+ readonly name = "browser-openai";
44
+ private readonly inner;
45
+ constructor(options: BrowserOpenAIProviderOptions);
46
+ complete(req: LLMRequest): Promise<LLMResponse>;
47
+ stream(req: LLMRequest): AsyncIterable<LLMChunk>;
48
+ }
49
+ export interface BrowserAzureOpenAIProviderOptions {
50
+ /** Resource endpoint, e.g. `https://my-co.openai.azure.com` (or a same-origin
51
+ * proxy path like `/azure` to sidestep CORS in dev). REQUIRED. */
52
+ readonly endpoint: string;
53
+ /** API key (Azure `api-key`). REQUIRED. */
54
+ readonly apiKey: string;
55
+ /** Azure API version, e.g. `2024-12-01-preview`. REQUIRED. */
56
+ readonly apiVersion: string;
57
+ /** The DEPLOYMENT name (Azure's "model"), e.g. `gpt-4o-128k`. REQUIRED. */
58
+ readonly deployment: string;
59
+ /** Default max tokens. */
60
+ readonly defaultMaxTokens?: number;
61
+ /** Set when the Azure deployment is a **reasoning model** (o1/o3/o4-mini) — omits
62
+ * `temperature` and sends the `developer` role. */
63
+ readonly reasoning?: boolean;
64
+ /** @internal Custom fetch implementation for tests. */
65
+ readonly _fetch?: typeof fetch;
66
+ }
67
+ /**
68
+ * Fetch-based **Azure OpenAI** provider for the browser/edge — no SDK, no Node.
69
+ *
70
+ * The browser can't use the Node `azureOpenai()` (it needs the `openai` SDK), so
71
+ * use this in a browser "bring your own (company) key" flow. Builds the
72
+ * deployment-scoped Azure URL + `api-key` header + `api-version`, and reuses all
73
+ * of `browserOpenai()`'s body/streaming/tool logic. The request `model` is the
74
+ * deployment; `'azure'` resolves to the configured `deployment`.
75
+ *
76
+ * **CORS:** an `*.openai.azure.com` resource may not allow direct browser calls;
77
+ * if blocked, point `endpoint` at a same-origin proxy (e.g. a Vite `/azure`
78
+ * proxy) or a backend. Same trade-off as `browserOpenai`.
79
+ *
80
+ * @example
81
+ * import { browserAzureOpenai } from 'agentfootprint';
82
+ * const provider = browserAzureOpenai({
83
+ * endpoint: 'https://my-co.openai.azure.com',
84
+ * apiKey: userKey, apiVersion: '2024-12-01-preview', deployment: 'gpt-4o-128k',
85
+ * });
86
+ * // Agent.create({ provider, model: 'azure' })
87
+ */
88
+ export declare function browserAzureOpenai(options: BrowserAzureOpenAIProviderOptions): LLMProvider;
89
+ export declare class BrowserAzureOpenAIProvider implements LLMProvider {
90
+ readonly name = "browser-azure-openai";
91
+ private readonly inner;
92
+ constructor(options: BrowserAzureOpenAIProviderOptions);
93
+ complete(req: LLMRequest): Promise<LLMResponse>;
94
+ stream(req: LLMRequest): AsyncIterable<LLMChunk>;
95
+ }
@@ -0,0 +1,153 @@
1
+ /**
2
+ * MockProvider — deterministic LLMProvider for tests + examples.
3
+ *
4
+ * Pattern: Adapter (GoF, Design Patterns ch. 4).
5
+ * Role: Ports-and-Adapters outer ring (Cockburn, 2005) — implements the
6
+ * LLMProvider port without calling out to a real LLM service.
7
+ * Emits: N/A (adapters don't emit; recorders observe them).
8
+ *
9
+ * Two modes, same provider:
10
+ * • DEFAULT (no latency options) — instant `complete()`, no streaming.
11
+ * Use in unit tests; behavior unchanged from earlier revisions.
12
+ * • REALISTIC (`thinkingMs` set) — randomised "thinking" latency before
13
+ * the response, plus a `stream()` implementation that emits the
14
+ * content word-by-word with `chunkDelayMs` between chunks. Lets
15
+ * consumers SEE the run unfold (pauses, streaming tokens, tool
16
+ * dispatch) instead of having every step finish in microseconds.
17
+ *
18
+ * Realistic mode is the right default for the playground / Lens demos:
19
+ * a real OpenAI / Anthropic call takes 3–8 s, so the UX you build for
20
+ * that timing is what matters. Use `MockProvider.realistic()` for the
21
+ * common 3–8 s thinking + 30–80 ms per word streaming preset.
22
+ */
23
+ import type { LLMChunk, LLMProvider, LLMRequest, LLMResponse } from '../types.js';
24
+ /** Either a fixed value (in ms) or a random `[min, max]` range (inclusive). */
25
+ export type LatencyMs = number | readonly [number, number];
26
+ /**
27
+ * One scripted reply consumed in order from `MockProviderOptions.replies`.
28
+ * String → plain text content; Partial<LLMResponse> → can include
29
+ * `toolCalls`, `usage`, `stopReason` for tool-using ReAct loops.
30
+ */
31
+ export type MockReply = string | Partial<LLMResponse>;
32
+ export interface MockProviderOptions {
33
+ readonly name?: string;
34
+ /** Fixed response content. Overrides `respond` when set. */
35
+ readonly reply?: string;
36
+ /**
37
+ * Scripted replies for multi-turn / tool-using agents. Each entry
38
+ * is consumed in order — iteration 1 reads `replies[0]`, iteration
39
+ * 2 reads `replies[1]`, and so on. Use Partial<LLMResponse> to
40
+ * inject `toolCalls`:
41
+ *
42
+ * ```ts
43
+ * mock({
44
+ * replies: [
45
+ * { toolCalls: [{ id: '1', name: 'lookup', args: { id: 42 } }] },
46
+ * { content: 'Found it: refunds take 3 business days.' },
47
+ * ],
48
+ * });
49
+ * ```
50
+ *
51
+ * **Exhaustion semantics:** if the agent calls the LLM more times
52
+ * than there are replies, `complete()` / `stream()` throw a clear
53
+ * error. This makes mock-script bugs loud, not silent. Tune the
54
+ * agent's `maxIterations` to bound the call count.
55
+ *
56
+ * Takes precedence over `reply` and `respond` when set.
57
+ */
58
+ readonly replies?: readonly MockReply[];
59
+ /**
60
+ * Build the response from the request. Returns either a plain
61
+ * string (renders as content with no tool calls) or a partial
62
+ * `LLMResponse` so consumers can simulate tool calls + multi-turn
63
+ * loops without needing a separate `scripted()` helper.
64
+ *
65
+ * Default: echoes the last user message.
66
+ */
67
+ readonly respond?: (req: LLMRequest) => string | Partial<LLMResponse>;
68
+ /**
69
+ * Simulated wall-clock delay per request (ms).
70
+ * Pass a single number for a fixed delay or a `[min, max]` tuple for
71
+ * a uniformly random delay (e.g. `[3000, 8000]` for "real LLM"
72
+ * thinking time). Default 0 (instant).
73
+ *
74
+ * Aliased via `delayMs` for backward compatibility.
75
+ */
76
+ readonly thinkingMs?: LatencyMs;
77
+ /** Alias for `thinkingMs`. Kept for back-compat with prior revisions. */
78
+ readonly delayMs?: LatencyMs;
79
+ /**
80
+ * For `stream()`: delay between successive chunks (ms). Pass a
81
+ * single number for a fixed delay or a `[min, max]` tuple for a
82
+ * uniformly random delay per chunk (e.g. `[30, 80]` for typing-like
83
+ * cadence). Default 30ms.
84
+ *
85
+ * Has no effect on `complete()`.
86
+ */
87
+ readonly chunkDelayMs?: LatencyMs;
88
+ /** Fixed stop reason to return. Default 'stop'. */
89
+ readonly stopReason?: string;
90
+ /** Override usage counts returned. Default: chars/4 heuristic. */
91
+ readonly usage?: Readonly<{
92
+ input?: number;
93
+ output?: number;
94
+ cacheRead?: number;
95
+ cacheWrite?: number;
96
+ }>;
97
+ }
98
+ export declare class MockProvider implements LLMProvider {
99
+ readonly name: string;
100
+ private readonly reply?;
101
+ private readonly replies?;
102
+ private repliesCursor;
103
+ private readonly respond;
104
+ private readonly thinkingMs;
105
+ private readonly chunkDelayMs;
106
+ private readonly stopReason;
107
+ private readonly usageOverride;
108
+ constructor(options?: MockProviderOptions);
109
+ /**
110
+ * Reset the scripted-replies cursor. Useful when reusing one
111
+ * `MockProvider` instance across multiple test scenarios — each
112
+ * scenario can `provider.resetReplies()` to start from `replies[0]`
113
+ * again. No-op when `replies` was not supplied.
114
+ */
115
+ resetReplies(): void;
116
+ /**
117
+ * Convenience factory for the playground / Lens demo defaults: a
118
+ * real-feel mock with 3–8 s of "thinking" before the response and
119
+ * 30–80 ms per streamed word. Lets users observe pause/resume,
120
+ * streaming, and tool dispatch happening live without hitting a
121
+ * paid API.
122
+ */
123
+ static realistic(options?: MockProviderOptions): MockProvider;
124
+ complete(req: LLMRequest): Promise<LLMResponse>;
125
+ /**
126
+ * Streaming mode — emits the response content word-by-word so
127
+ * consumers (Lens commentary, chat UIs) can render tokens as they
128
+ * arrive. Tool calls land all at once on the final chunk because
129
+ * that is how real providers (OpenAI, Anthropic) deliver them too.
130
+ */
131
+ stream(req: LLMRequest): AsyncIterable<LLMChunk>;
132
+ private buildResponse;
133
+ /**
134
+ * Resolve the next reply source for one `complete()` / `stream()` call.
135
+ * Priority: `replies` (scripted, throws on exhaustion) → `reply` (single
136
+ * fixed string) → `respond` (callback default). Replies are consumed
137
+ * in order; the cursor is per-instance, not per-request.
138
+ */
139
+ private consumeNextReply;
140
+ }
141
+ /**
142
+ * Lowercase factory for `MockProvider` — matches the v1 `mock()` import
143
+ * shape so docs and quick-starts stay copy-pasteable. Equivalent to
144
+ * `new MockProvider(options)`.
145
+ *
146
+ * @example
147
+ * import { Agent, mock, defineTool } from 'agentfootprint';
148
+ *
149
+ * const agent = Agent.create({ provider: mock({ reply: 'hello' }) })
150
+ * .tool(defineTool({ name: 'echo', ... }))
151
+ * .build();
152
+ */
153
+ export declare function mock(options?: MockProviderOptions): MockProvider;
@@ -0,0 +1,220 @@
1
+ /**
2
+ * OpenAIProvider — wraps the `openai` SDK as an `LLMProvider`.
3
+ *
4
+ * Pattern: Adapter (GoF) + Ports-and-Adapters (Cockburn 2005).
5
+ * Role: Outer ring — translates `LLMRequest`/`LLMResponse` to/from
6
+ * OpenAI's Chat Completions API. Knows nothing about agents,
7
+ * recorders, or compositions.
8
+ * Emits: N/A.
9
+ *
10
+ * ─── Limitations ────────────────────────────────────────────────────
11
+ *
12
+ * • Multi-modal NOT supported (`LLMMessage.content` is
13
+ * `string`). May extend in a future release.
14
+ * • `responseFormat` (JSON-mode) NOT exposed — pass schema
15
+ * instructions via `systemPrompt` for now.
16
+ *
17
+ * The `baseURL` option enables OpenAI-compatible APIs (Ollama, Together,
18
+ * Groq, vLLM, LM Studio) without a separate adapter — see the `ollama()`
19
+ * convenience factory below.
20
+ */
21
+ import type { LLMChunk, LLMProvider, LLMRequest, LLMResponse } from '../types.js';
22
+ interface OpenAIClient {
23
+ chat: {
24
+ completions: {
25
+ create(params: OpenAICreateParams): Promise<OpenAIChatCompletion> | AsyncIterable<OpenAIStreamChunk>;
26
+ };
27
+ };
28
+ }
29
+ interface OpenAICreateParams {
30
+ model: string;
31
+ messages: OpenAIMessage[];
32
+ tools?: OpenAITool[];
33
+ /** Legacy token cap — DEPRECATED by OpenAI and REJECTED by o-series reasoning
34
+ * models. Kept only for custom OpenAI-compatible endpoints (Ollama/vLLM/…). */
35
+ max_tokens?: number;
36
+ /** Current token cap — accepted by all OpenAI/Azure chat models incl. o-series. */
37
+ max_completion_tokens?: number;
38
+ temperature?: number;
39
+ stop?: string[];
40
+ stream?: boolean;
41
+ /** Ask OpenAI/Azure to emit a final usage chunk while streaming. */
42
+ stream_options?: {
43
+ include_usage: boolean;
44
+ };
45
+ }
46
+ interface OpenAIMessage {
47
+ role: 'system' | 'developer' | 'user' | 'assistant' | 'tool';
48
+ content: string | null;
49
+ tool_calls?: OpenAIToolCall[];
50
+ tool_call_id?: string;
51
+ }
52
+ interface OpenAIToolCall {
53
+ id: string;
54
+ type: 'function';
55
+ function: {
56
+ name: string;
57
+ arguments: string;
58
+ };
59
+ }
60
+ interface OpenAITool {
61
+ type: 'function';
62
+ function: {
63
+ name: string;
64
+ description: string;
65
+ parameters: Record<string, unknown>;
66
+ };
67
+ }
68
+ interface OpenAIChatCompletion {
69
+ id: string;
70
+ model: string;
71
+ choices: Array<{
72
+ index: number;
73
+ message: {
74
+ role: 'assistant';
75
+ content: string | null;
76
+ tool_calls?: OpenAIToolCall[];
77
+ };
78
+ finish_reason: 'stop' | 'tool_calls' | 'length' | 'content_filter' | string;
79
+ }>;
80
+ usage?: {
81
+ prompt_tokens: number;
82
+ completion_tokens: number;
83
+ };
84
+ }
85
+ interface OpenAIStreamChunk {
86
+ id: string;
87
+ model: string;
88
+ choices: Array<{
89
+ index: number;
90
+ delta: {
91
+ role?: string;
92
+ content?: string | null;
93
+ tool_calls?: Array<{
94
+ index: number;
95
+ id?: string;
96
+ type?: string;
97
+ function?: {
98
+ name?: string;
99
+ arguments?: string;
100
+ };
101
+ }>;
102
+ };
103
+ finish_reason: string | null;
104
+ }>;
105
+ usage?: {
106
+ prompt_tokens: number;
107
+ completion_tokens: number;
108
+ };
109
+ }
110
+ export interface OpenAIProviderOptions {
111
+ /** API key. Defaults to `OPENAI_API_KEY` env var. */
112
+ readonly apiKey?: string;
113
+ /** Base URL — set for OpenAI-compatible APIs (Ollama, Together, vLLM). */
114
+ readonly baseURL?: string;
115
+ /**
116
+ * Default model used when `LLMRequest.model` is `'openai'` (the
117
+ * shorthand). Full model ids pass through unchanged.
118
+ */
119
+ readonly defaultModel?: string;
120
+ /** Default max tokens when the request doesn't set it. Optional. */
121
+ readonly defaultMaxTokens?: number;
122
+ /**
123
+ * Treat the target as a **reasoning model** (o-series: o1 / o3 / o4-mini, or an
124
+ * Azure reasoning deployment). Reasoning models reject `max_tokens` and an explicit
125
+ * `temperature`, and use the `developer` role in place of `system`. Standard o-series
126
+ * model ids are auto-detected; set this explicitly for Azure deployments whose name
127
+ * does not reveal the underlying model.
128
+ */
129
+ readonly reasoning?: boolean;
130
+ /** @internal Pre-built client for testing. Skips SDK import. */
131
+ readonly _client?: OpenAIClient;
132
+ }
133
+ /**
134
+ * Build an `LLMProvider` backed by OpenAI's Chat Completions API.
135
+ *
136
+ * @example
137
+ * import { Agent } from 'agentfootprint';
138
+ * import { openai } from 'agentfootprint/llm-providers';
139
+ *
140
+ * const agent = Agent.create({
141
+ * provider: openai({ defaultModel: 'gpt-4o' }),
142
+ * model: 'openai',
143
+ * })
144
+ * .tool(searchTool)
145
+ * .build();
146
+ */
147
+ export declare function openai(options?: OpenAIProviderOptions): LLMProvider;
148
+ /**
149
+ * Class form for consumers who prefer `new OpenAIProvider(...)`.
150
+ */
151
+ export declare class OpenAIProvider implements LLMProvider {
152
+ readonly name = "openai";
153
+ private readonly inner;
154
+ constructor(options?: OpenAIProviderOptions);
155
+ complete(req: LLMRequest): Promise<LLMResponse>;
156
+ stream(req: LLMRequest): AsyncIterable<LLMChunk>;
157
+ }
158
+ export interface AzureOpenAIProviderOptions {
159
+ /** Resource endpoint, e.g. `https://my-co.openai.azure.com`. Env fallbacks:
160
+ * `AZURE_OPENAI_ENDPOINT`, then `OPENAI_BASE_URL`. */
161
+ readonly endpoint?: string;
162
+ /** API key. Env fallbacks: `AZURE_OPENAI_API_KEY`, then `OPENAI_API_KEY`. */
163
+ readonly apiKey?: string;
164
+ /** Azure API version, e.g. `2024-12-01-preview`. Env fallback:
165
+ * `AZURE_OPENAI_API_VERSION`. Required. */
166
+ readonly apiVersion?: string;
167
+ /** The DEPLOYMENT name (Azure's "model"), e.g. `gpt-4o-128k`. Env fallbacks:
168
+ * `AZURE_OPENAI_DEPLOYMENT`, then `MODEL_NAME`. Required. */
169
+ readonly deployment?: string;
170
+ /** Default max tokens when the request doesn't set it. Optional. */
171
+ readonly defaultMaxTokens?: number;
172
+ /**
173
+ * Set when the Azure DEPLOYMENT is a **reasoning model** (o1/o3/o4-mini). Azure
174
+ * deployment names are arbitrary, so this cannot be auto-detected — declare it to
175
+ * omit `temperature` and send the `developer` role. (`max_completion_tokens` is used
176
+ * for all Azure deployments regardless.)
177
+ */
178
+ readonly reasoning?: boolean;
179
+ /** @internal Pre-built client for testing. Skips SDK import. */
180
+ readonly _client?: OpenAIClient;
181
+ }
182
+ /**
183
+ * Build an `LLMProvider` for **Azure OpenAI**.
184
+ *
185
+ * Azure is NOT a drop-in OpenAI-compatible URL — it uses a deployment-scoped
186
+ * path, `api-key` header auth, and an `api-version` query param. This wraps the
187
+ * `openai` SDK's `AzureOpenAI` client (which handles all that) and reuses the
188
+ * exact same completion/streaming/tool-call logic as `openai()`.
189
+ *
190
+ * The request's `model` is the Azure **deployment** name. Pass a deployment id
191
+ * to target it; the shorthands `'azure'` / `'azure-openai'` resolve to the
192
+ * configured default `deployment`.
193
+ *
194
+ * @example
195
+ * import { azureOpenai } from 'agentfootprint/llm-providers';
196
+ *
197
+ * const agent = Agent.create({
198
+ * provider: azureOpenai({
199
+ * endpoint: process.env.OPENAI_BASE_URL, // *.openai.azure.com
200
+ * apiKey: process.env.AZURE_OPENAI_API_KEY,
201
+ * apiVersion: process.env.AZURE_OPENAI_API_VERSION, // 2024-12-01-preview
202
+ * deployment: process.env.MODEL_NAME, // gpt-4o-128k
203
+ * }),
204
+ * model: 'azure',
205
+ * }).build();
206
+ */
207
+ export declare function azureOpenai(options?: AzureOpenAIProviderOptions): LLMProvider;
208
+ /**
209
+ * Convenience factory for Ollama (OpenAI-compatible endpoint).
210
+ *
211
+ * @example
212
+ * import { ollama } from 'agentfootprint/llm-providers';
213
+ *
214
+ * const provider = ollama({ defaultModel: 'llama3.2' });
215
+ * // Talks to http://localhost:11434/v1 by default.
216
+ */
217
+ export declare function ollama(options?: OpenAIProviderOptions & {
218
+ readonly host?: string;
219
+ }): LLMProvider;
220
+ export {};
@@ -0,0 +1,85 @@
1
+ /**
2
+ * createProvider — by-name factory for any built-in LLMProvider.
3
+ *
4
+ * Pattern: Abstract Factory (GoF) over the concrete provider factories.
5
+ * Role: Convenience entry point. Useful for config-driven setups
6
+ * where the provider is chosen at runtime (env var, feature
7
+ * flag, tenant preference).
8
+ * Emits: N/A.
9
+ *
10
+ * @example
11
+ * const kind = (process.env.LLM_PROVIDER ?? 'anthropic') as ProviderKind;
12
+ * const provider = createProvider({
13
+ * kind,
14
+ * apiKey: process.env.LLM_API_KEY,
15
+ * defaultModel: process.env.LLM_MODEL,
16
+ * } as CreateProviderOptions);
17
+ *
18
+ * For provider-specific options (Bedrock region, Ollama host, Browser
19
+ * apiUrl, etc.) construct the underlying factory directly — this
20
+ * helper deliberately exposes only the common subset.
21
+ */
22
+ import type { LLMProvider } from '../types.js';
23
+ import { type MockProviderOptions } from './MockProvider.js';
24
+ import { type AnthropicProviderOptions } from './AnthropicProvider.js';
25
+ import { type OpenAIProviderOptions } from './OpenAIProvider.js';
26
+ import { type BedrockProviderOptions } from './BedrockProvider.js';
27
+ import { type BrowserAnthropicProviderOptions } from './BrowserAnthropicProvider.js';
28
+ import { type BrowserOpenAIProviderOptions } from './BrowserOpenAIProvider.js';
29
+ /** Built-in provider kinds. Custom providers don't go through this factory. */
30
+ export type ProviderKind = 'mock' | 'anthropic' | 'openai' | 'ollama' | 'bedrock' | 'browser-anthropic' | 'browser-openai';
31
+ /**
32
+ * Common subset of options accepted across all built-in providers.
33
+ * Provider-specific keys (region for Bedrock, host for Ollama,
34
+ * organization for OpenAI, apiUrl for browser) are passed through
35
+ * verbatim — TypeScript narrows by `kind`.
36
+ */
37
+ export type CreateProviderOptions = ({
38
+ readonly kind: 'mock';
39
+ } & MockProviderOptions) | ({
40
+ readonly kind: 'anthropic';
41
+ } & AnthropicProviderOptions) | ({
42
+ readonly kind: 'openai';
43
+ } & OpenAIProviderOptions) | ({
44
+ readonly kind: 'ollama';
45
+ } & OpenAIProviderOptions & {
46
+ readonly host?: string;
47
+ }) | ({
48
+ readonly kind: 'bedrock';
49
+ } & BedrockProviderOptions) | ({
50
+ readonly kind: 'browser-anthropic';
51
+ } & BrowserAnthropicProviderOptions) | ({
52
+ readonly kind: 'browser-openai';
53
+ } & BrowserOpenAIProviderOptions);
54
+ /**
55
+ * Build any built-in LLMProvider from a tagged options object.
56
+ */
57
+ export declare function createProvider(options: CreateProviderOptions): LLMProvider;
58
+ /** What `providerFromEnv()` resolved: the provider + the `model` to pass to
59
+ * `Agent.create({ provider, model })`, and which `kind` was detected. */
60
+ export interface ProviderFromEnv {
61
+ readonly provider: LLMProvider;
62
+ readonly model: string;
63
+ readonly kind: 'azure-openai' | 'anthropic' | 'openai' | 'mock';
64
+ }
65
+ /**
66
+ * Resolve an `LLMProvider` from environment variables — drop your company's
67
+ * values in `.env` and the right provider is configured automatically, with no
68
+ * code branching. (Node only — reads `process.env`; the vendor SDK is lazy-loaded
69
+ * only for the detected provider.)
70
+ *
71
+ * Detection order (first match wins):
72
+ * 1. **Azure OpenAI** — `AZURE_OPENAI_API_KEY` + (`AZURE_OPENAI_ENDPOINT` |
73
+ * `OPENAI_BASE_URL`) [+ `AZURE_OPENAI_API_VERSION`, `AZURE_OPENAI_DEPLOYMENT`|`MODEL_NAME`]
74
+ * 2. **Anthropic** — `ANTHROPIC_API_KEY`
75
+ * 3. **OpenAI** — `OPENAI_API_KEY`
76
+ * Otherwise throws (or returns the mock when `{ fallbackToMock: true }`).
77
+ *
78
+ * @example
79
+ * import { providerFromEnv } from 'agentfootprint';
80
+ * const { provider, model, kind } = providerFromEnv({ fallbackToMock: true });
81
+ * const agent = Agent.create({ provider, model }).build();
82
+ */
83
+ export declare function providerFromEnv(opts?: {
84
+ readonly fallbackToMock?: boolean;
85
+ }): ProviderFromEnv;