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,254 @@
1
+ /**
2
+ * auditExport — tamper-evident audit bundle (backlog #20, compliance
3
+ * wedge item 2; pairs with #19's `otelObservability` GenAI spans).
4
+ *
5
+ * Consumes the typed `agentfootprint.*` event stream and accumulates an
6
+ * append-only, HASH-CHAINED record log: every record carries the SHA-256
7
+ * of its own canonical serialization plus the hash of the previous
8
+ * record. Flipping a single byte anywhere in an exported bundle makes
9
+ * `verifyAuditBundle` name the exact record that broke — the
10
+ * record-keeping shape EU AI Act Art. 12 asks for (events the system
11
+ * logged, in order, demonstrably unmodified since capture).
12
+ *
13
+ * Pattern: Observability strategy (one purpose — chain accumulation)
14
+ * + pure offline verifier.
15
+ * Role: Outer ring (Hexagonal). Attach via
16
+ * `agent.enable.observability({ strategy: auditExport() })`.
17
+ * Emits: nothing — terminal sink.
18
+ *
19
+ * ## What lands in the chain
20
+ *
21
+ * One record per typed event, in dispatch order: decisions
22
+ * (`agent.route_decided`, `composition.route_decided` incl. decide()
23
+ * evidence), tool calls (`stream.tool_start/_end`), validation
24
+ * rejections (#9), permission verdicts and halts, credential lifecycle,
25
+ * costs, errors, skill/memory/context activity. Each new `meta.runId`
26
+ * is anchored by a GENESIS record (`audit.genesis`) carrying the runId,
27
+ * the agent identity, and library versions — runs chain back-to-back in
28
+ * one log, so silently DROPPING a whole run breaks the chain too.
29
+ *
30
+ * High-volume content deltas (`stream.token`, `stream.thinking_delta`)
31
+ * are excluded by default (`includeTokenEvents: true` to include).
32
+ *
33
+ * ## Record / bundle schema
34
+ *
35
+ * ```
36
+ * AuditRecord = { seq, timestamp, eventType, payload, meta, prevHash, hash }
37
+ * hash = SHA-256 hex over canonicalJson(record minus `hash`)
38
+ * prevHash = previous record's `hash` (ZERO_HASH at chain start)
39
+ * AuditBundle = { header, records, finalHash }
40
+ * header = { format, hashAlgorithm, canonicalization, chainHead,
41
+ * firstSeq, recordCount, exportedAt, library }
42
+ * ```
43
+ *
44
+ * Canonicalization is `afp-cjson/1` (see `lib/canonicalJson.ts` — those
45
+ * rules ARE the contract; the header names them so independent
46
+ * verifiers can re-implement byte-exactly).
47
+ *
48
+ * ## Persistence + long runs
49
+ *
50
+ * Persistence is the CONSUMER's job — the bundle is plain JSON
51
+ * (`JSON.stringify(strategy.bundle())`, store anywhere). For long runs,
52
+ * `drain()` returns the records accumulated since the last drain while
53
+ * keeping the chain intact ACROSS drains: each segment's
54
+ * `header.chainHead` equals the previous segment's `finalHash`, so
55
+ * `verifyAuditBundle([seg1, seg2, ...])` re-verifies the concatenation
56
+ * end-to-end.
57
+ *
58
+ * ## PII discipline (mirrors #19's otelObservability)
59
+ *
60
+ * Payloads enter records through a bounding layer — by default
61
+ * (`payloadMode: 'bounded'`) record payloads NEVER carry raw runtime
62
+ * values that can echo PII:
63
+ *
64
+ * - tool args → `'[keys: …]'` (top-level key NAMES only)
65
+ * - tool results → `'[type: …]'` (typeof only)
66
+ * - userPrompt / LLM content / thinking blocks / history
67
+ * → `'[N chars]'` / `'[N messages]'` markers
68
+ * - content PREVIEWS (`contentSummary` on context/memory events,
69
+ * `rawContent`, `resultSummary`, `droppedSummaries`) → markers
70
+ * (for short content a preview IS the content; `contentHash`
71
+ * stays — it links identical content without echoing it)
72
+ * - error MESSAGE strings (`error`, `errorMessage`, `lastError`,
73
+ * `rawOutput`) → `'[N chars]'` (messages can echo values)
74
+ * - free-form Records (`questionPayload`, `resumeInput`, risk/eval
75
+ * `evidence`, memory `scoreEvidence`) → `'[keys: …]'`
76
+ *
77
+ * Everything else is embedded as the registry payload (sanitized:
78
+ * strings capped at 256 chars, lists at 32 items, cycles broken) —
79
+ * those payloads are bounded by construction: identifiers, counts,
80
+ * enums, decide() evidence (engine-bounded + redaction-aware),
81
+ * validation issues (paths/TYPES per #9), credential events (no
82
+ * secrets by contract).
83
+ *
84
+ * `payloadMode: 'verbatim'` embeds full payloads (still
85
+ * JSON-sanitized). For Art. 12 completeness on an access-controlled
86
+ * store that is often the point — but the bundle then carries prompts,
87
+ * tool args/results and model output. Treat it as PII-bearing, and
88
+ * remember the Agent sets NO footprintjs RedactionPolicy by default
89
+ * (policies you do set redact the emit channel UPSTREAM of this
90
+ * strategy, so redacted events arrive here already redacted).
91
+ *
92
+ * ## Tamper-EVIDENT, not tamper-PROOF (honest threat model)
93
+ *
94
+ * The chain proves INTERNAL consistency: any partial modification —
95
+ * edit, insert, delete, reorder, drop-a-run — is detected and named.
96
+ * It does NOT prove provenance: an adversary holding the only copy can
97
+ * recompute every hash from the mutation onward and present a
98
+ * self-consistent forgery. For non-repudiation, anchor `finalHash`
99
+ * externally as part of your retention process (write-once/WORM store,
100
+ * signed log, RFC 3161 timestamping, or simply a second party) — then
101
+ * a whole-suffix recomputation no longer matches the anchor.
102
+ *
103
+ * ## Runtime requirements
104
+ *
105
+ * Hashing uses `node:crypto` (`createHash('sha256')`) — zero new
106
+ * dependencies, imported lazily at first use (same gating as the
107
+ * optional vendor SDKs in this folder, so merely importing this module
108
+ * stays browser-safe). `auditExport` and `verifyAuditBundle` therefore
109
+ * run anywhere `node:crypto` exists: Node ≥ 20, Bun, Deno,
110
+ * edge runtimes with Node compat (e.g. Cloudflare `nodejs_compat`).
111
+ * In a browser there is no SYNC SHA-256 (WebCrypto is async-only), so
112
+ * both throw a descriptive error — verify server-side, or re-implement
113
+ * verification from the documented contract (it is pure: recompute
114
+ * SHA-256 over `afp-cjson/1` canonicalization and walk the chain).
115
+ *
116
+ * @example Capture → export → verify
117
+ * ```ts
118
+ * import { auditExport, verifyAuditBundle } from 'agentfootprint/observability-providers';
119
+ *
120
+ * const audit = auditExport({ agent: 'loan-officer' });
121
+ * const stop = agent.enable.observability({ strategy: audit });
122
+ * await agent.run({ message: 'assess application A-17' });
123
+ * stop();
124
+ *
125
+ * const bundle = audit.bundle(); // JSON-serializable
126
+ * await fs.writeFile('run.audit.json', JSON.stringify(bundle));
127
+ *
128
+ * const check = verifyAuditBundle(bundle); // offline — no agent needed
129
+ * // check.valid === true; tamper with one byte → { valid: false, brokenAt: <seq> }
130
+ * ```
131
+ */
132
+ import { CANONICAL_JSON_VERSION } from '../../lib/canonicalJson.js';
133
+ import type { ObservabilityStrategy } from '../../strategies/types.js';
134
+ /** SHA-256 of "nothing" — the `prevHash` of the first record in a
135
+ * chain and the `chainHead` of a chain's first segment. */
136
+ export declare const AUDIT_ZERO_HASH: string;
137
+ /** `eventType` of the per-run genesis record. Deliberately OUTSIDE the
138
+ * `agentfootprint.*` registry namespace — it is a chain-level record,
139
+ * not a dispatched event (#20 ships zero new typed events). */
140
+ export declare const AUDIT_GENESIS_EVENT_TYPE = "audit.genesis";
141
+ /** Format identifier carried on every bundle header. */
142
+ export declare const AUDIT_BUNDLE_FORMAT = "agentfootprint.audit/1";
143
+ /**
144
+ * One link of the hash chain.
145
+ *
146
+ * `hash` = SHA-256 hex over `canonicalJson` of the record WITHOUT the
147
+ * `hash` field (i.e. `{ seq, timestamp, eventType, payload, meta,
148
+ * prevHash }` — canonical key order makes field order irrelevant).
149
+ * Because the preimage is "everything but `hash`", ADDING a field to a
150
+ * record is detected exactly like mutating one.
151
+ */
152
+ export interface AuditRecord {
153
+ /** 0-based position in the chain (monotonic across drains). */
154
+ readonly seq: number;
155
+ /** Wall-clock ms of the source event (`meta.wallClockMs`). */
156
+ readonly timestamp: number;
157
+ /** Registry event name verbatim, or {@link AUDIT_GENESIS_EVENT_TYPE}. */
158
+ readonly eventType: string;
159
+ /** Bounded / sanitized event payload (see module PII docs). */
160
+ readonly payload: unknown;
161
+ /** Sanitized event meta (runId, runtimeStageId, paths, indices). */
162
+ readonly meta: {
163
+ readonly runId: string;
164
+ } & Readonly<Record<string, unknown>>;
165
+ /** `hash` of the previous record ({@link AUDIT_ZERO_HASH} at chain start). */
166
+ readonly prevHash: string;
167
+ /** SHA-256 hex of this record's canonical preimage. */
168
+ readonly hash: string;
169
+ }
170
+ export interface AuditBundleHeader {
171
+ readonly format: typeof AUDIT_BUNDLE_FORMAT;
172
+ readonly hashAlgorithm: 'sha-256';
173
+ readonly canonicalization: typeof CANONICAL_JSON_VERSION;
174
+ /** `prevHash` of `records[0]` — {@link AUDIT_ZERO_HASH} for the first
175
+ * segment, the previous segment's `finalHash` after a `drain()`. */
176
+ readonly chainHead: string;
177
+ /** `seq` of `records[0]` (continues across drains). */
178
+ readonly firstSeq: number;
179
+ readonly recordCount: number;
180
+ /** Wall-clock ms when `bundle()` / `drain()` produced this export. */
181
+ readonly exportedAt: number;
182
+ readonly library: {
183
+ readonly name: 'agentfootprint';
184
+ readonly version: string;
185
+ };
186
+ }
187
+ /** JSON-serializable export of the chain (or one drained segment). */
188
+ export interface AuditBundle {
189
+ readonly header: AuditBundleHeader;
190
+ readonly records: readonly AuditRecord[];
191
+ /** `hash` of the last record (= `chainHead` when `records` is empty).
192
+ * The next drained segment's `chainHead` equals this value. */
193
+ readonly finalHash: string;
194
+ }
195
+ export interface AuditVerifyResult {
196
+ readonly valid: boolean;
197
+ /** Records whose hashes were recomputed and matched. */
198
+ readonly recordsChecked: number;
199
+ /** `seq` of the first record that fails (or the expected seq at the
200
+ * failure point, when the stored seq itself was tampered). */
201
+ readonly brokenAt?: number;
202
+ /** Human-readable cause — names the failed check. */
203
+ readonly reason?: string;
204
+ }
205
+ export interface AuditExportOptions {
206
+ /** Agent identity recorded in every run's genesis record (service /
207
+ * agent name as your compliance review knows it). */
208
+ readonly agent?: string;
209
+ /**
210
+ * `'bounded'` (default) — payloads pass the PII bounding layer (see
211
+ * module docs). `'verbatim'` — full payloads, JSON-sanitized only.
212
+ *
213
+ * @remarks Verbatim bundles carry prompts, tool args/results and
214
+ * model output. Treat the store as PII-bearing; the Agent applies NO
215
+ * RedactionPolicy by default.
216
+ */
217
+ readonly payloadMode?: 'bounded' | 'verbatim';
218
+ /** Include `stream.token` / `stream.thinking_delta` events (high
219
+ * volume; content still bounded under `payloadMode: 'bounded'`).
220
+ * Default `false`. */
221
+ readonly includeTokenEvents?: boolean;
222
+ /** Extra version pins for the genesis record (your app, model
223
+ * config revision, policy bundle hash, …). */
224
+ readonly versions?: Readonly<Record<string, string>>;
225
+ }
226
+ /** The strategy returned by {@link auditExport}. */
227
+ export interface AuditExportStrategy extends ObservabilityStrategy {
228
+ /** Snapshot the retained records WITHOUT draining. Safe mid-run. */
229
+ bundle(): AuditBundle;
230
+ /** Return the records accumulated since the last drain and clear
231
+ * them from memory. Chain state persists — consecutive drained
232
+ * segments re-verify end-to-end via `verifyAuditBundle([...])`. */
233
+ drain(): AuditBundle;
234
+ /** Records currently retained (since last drain). */
235
+ recordCount(): number;
236
+ }
237
+ export declare function auditExport(opts?: AuditExportOptions): AuditExportStrategy;
238
+ /**
239
+ * Recompute the hash chain of a bundle (or of consecutive drained
240
+ * segments, in order) and report the exact record where integrity
241
+ * breaks. Pure function over JSON data — runs offline, long after the
242
+ * run, with no agent and no strategy instance.
243
+ *
244
+ * Checks, in order, per segment:
245
+ * 1. header format / algorithm / canonicalization are supported
246
+ * 2. `recordCount` matches `records.length`
247
+ * 3. segment continuity (`chainHead`/`firstSeq` extend the previous
248
+ * segment's `finalHash`/seq range)
249
+ * 4. per record: `seq` is contiguous, `prevHash` links the previous
250
+ * record, and SHA-256 over the canonical preimage (the record
251
+ * minus `hash` — so ADDED fields are caught too) matches `hash`
252
+ * 5. `finalHash` equals the last record's hash
253
+ */
254
+ export declare function verifyAuditBundle(input: AuditBundle | readonly AuditBundle[]): AuditVerifyResult;
@@ -0,0 +1,96 @@
1
+ /**
2
+ * cloudwatchObservability — Generic AWS CloudWatch Logs adapter.
3
+ *
4
+ * Ships every `AgentfootprintEvent` to a CloudWatch Logs stream. Use
5
+ * when you want agent telemetry alongside the rest of your AWS
6
+ * observability stack — CloudWatch Insights queries, alarms,
7
+ * cross-service correlation. Same SDK as `agentcoreObservability`
8
+ * but **without** the AgentCore-specific defaults (log-stream
9
+ * convention, format opinions). Use this when:
10
+ *
11
+ * 1. You're shipping to CloudWatch but NOT running inside Bedrock
12
+ * AgentCore (most common case).
13
+ * 2. You want full control over log group / stream / format and
14
+ * don't need AgentCore's hosted-agent telemetry conventions.
15
+ *
16
+ * Subpath: `agentfootprint/observability-providers`
17
+ * Peer dep: `@aws-sdk/client-cloudwatch-logs` (OPTIONAL — installed
18
+ * only when this adapter is used; declared via
19
+ * `peerDependenciesMeta.{name}.optional = true`).
20
+ *
21
+ * This module also exports the underlying base function used by
22
+ * `agentcoreObservability` — keeps the per-event hot path in one
23
+ * place so improvements (batching, retry, backpressure) flow to
24
+ * every CloudWatch-shaped adapter automatically.
25
+ *
26
+ * @example
27
+ * ```ts
28
+ * import { cloudwatchObservability } from 'agentfootprint/observability-providers';
29
+ * import { microtaskBatchDriver } from 'footprintjs/detach';
30
+ *
31
+ * agent.enable.observability({
32
+ * strategy: cloudwatchObservability({
33
+ * region: 'us-east-1',
34
+ * logGroupName: '/myapp/agent-prod',
35
+ * logStreamName: `${process.env.HOSTNAME}/${Date.now()}`,
36
+ * }),
37
+ * detach: { driver: microtaskBatchDriver, mode: 'forget' },
38
+ * });
39
+ * ```
40
+ */
41
+ import type { ObservabilityStrategy } from '../../strategies/types.js';
42
+ export interface CloudwatchObservabilityOptions {
43
+ /** AWS region. Falls back to AWS_REGION / AWS_DEFAULT_REGION env. */
44
+ readonly region?: string;
45
+ /** CloudWatch Logs log group. **Required.** Must exist or your IAM
46
+ * role must allow `logs:CreateLogGroup`. */
47
+ readonly logGroupName: string;
48
+ /** CloudWatch Logs log stream within the group. Conventionally
49
+ * `<host>/<startTime>` so multi-instance deployments don't
50
+ * collide. Created on first put if it doesn't exist (or your
51
+ * role must allow `logs:CreateLogStream`). Defaults to
52
+ * `agentfootprint`. */
53
+ readonly logStreamName?: string;
54
+ /** Max events buffered before forced flush. Default 100. */
55
+ readonly maxBatchEvents?: number;
56
+ /** Max payload bytes (UTF-8) buffered before forced flush. Default
57
+ * 10240 (10 KB). CloudWatch hard caps at 1 MB / batch but we keep
58
+ * the default low so latency stays bounded. */
59
+ readonly maxBatchBytes?: number;
60
+ /** Forced-flush interval when traffic is sparse. Default 1000ms.
61
+ * `0` disables time-based flush — only size triggers fire. */
62
+ readonly flushIntervalMs?: number;
63
+ /** Test injection — bypasses SDK lazy-require entirely. When set,
64
+ * `region` / IAM are ignored. */
65
+ readonly _client?: CloudWatchLikeClient;
66
+ }
67
+ export interface CloudWatchLikeClient {
68
+ putLogEvents(input: {
69
+ logGroupName: string;
70
+ logStreamName: string;
71
+ logEvents: ReadonlyArray<{
72
+ timestamp: number;
73
+ message: string;
74
+ }>;
75
+ }): Promise<unknown>;
76
+ }
77
+ /**
78
+ * Internal: shared CloudWatch Logs base used by every adapter that
79
+ * ships to CWL. `cloudwatchObservability` is the public generic
80
+ * factory; `agentcoreObservability` calls this with AgentCore-flavored
81
+ * defaults.
82
+ *
83
+ * Exported for adapter authors only — consumers should call
84
+ * `cloudwatchObservability` or `agentcoreObservability` directly.
85
+ *
86
+ * @internal
87
+ */
88
+ export declare function _buildCloudWatchObservability(opts: CloudwatchObservabilityOptions, strategyName: string): ObservabilityStrategy;
89
+ /**
90
+ * Generic CloudWatch Logs observability adapter. See
91
+ * `CloudwatchObservabilityOptions` for the per-option contract.
92
+ *
93
+ * For AgentCore-specific conventions, use `agentcoreObservability`
94
+ * which thin-wraps this with AgentCore-flavored defaults.
95
+ */
96
+ export declare function cloudwatchObservability(opts: CloudwatchObservabilityOptions): ObservabilityStrategy;
@@ -0,0 +1,237 @@
1
+ /**
2
+ * otelObservability — OpenTelemetry distributed-tracing adapter.
3
+ *
4
+ * Ships every agentfootprint event as OpenTelemetry spans + span events
5
+ * via a consumer-supplied OTel API, following the OpenTelemetry **GenAI
6
+ * semantic conventions** (`gen_ai.*` attribute namespace) plus
7
+ * agentfootprint-specific explainability attributes (`agentfootprint.*`).
8
+ * Same hierarchical mapping as the X-Ray adapter, but the destination is
9
+ * whichever OTel-compat backend the consumer's SDK exports to:
10
+ *
11
+ * - **Honeycomb** (OTLP/HTTP)
12
+ * - **Grafana Cloud / Tempo / Mimir** (OTLP)
13
+ * - **AWS Distro for OTel** → AWS X-Ray (alternative to xrayObservability)
14
+ * - **Datadog APM** (OTLP endpoint)
15
+ * - **Splunk Observability Cloud** (OTLP)
16
+ * - **New Relic** (OTLP endpoint)
17
+ * - **Lightstep / ServiceNow Cloud Observability** (OTLP)
18
+ * - any custom OTel collector / processor pipeline
19
+ *
20
+ * Subpath: `agentfootprint/observability-providers`
21
+ * Peer dep: `@opentelemetry/api` (OPTIONAL — installed only when
22
+ * this adapter is used. The consumer ALSO installs the
23
+ * OTel SDK + exporter of their choice — that's the BYO
24
+ * contract that makes this adapter backend-agnostic.).
25
+ *
26
+ * **Why BYO SDK:** OTel's SDK is heavyweight and exporter-specific
27
+ * (each backend has its own exporter package). Forcing a particular
28
+ * exporter would defeat the "OTel is portable" guarantee. Consumers
29
+ * configure the SDK + exporter once at app startup; we just speak
30
+ * the typed OTel API.
31
+ *
32
+ * ## Event → span/attribute mapping
33
+ *
34
+ * agent.turn_start ↦ start root span (one trace per turn) —
35
+ * `gen_ai.operation.name: 'invoke_agent'`
36
+ * agent.turn_end ↦ end root span (+ turn-total `gen_ai.usage.*`)
37
+ * agent.iteration_start ↦ start child span under root
38
+ * agent.iteration_end ↦ end iteration span
39
+ * stream.llm_start ↦ start child span (inference) — `gen_ai.*`
40
+ * request attrs (`chat` operation)
41
+ * stream.llm_end ↦ end llm span (+ `gen_ai.usage.*`,
42
+ * `gen_ai.response.*`)
43
+ * stream.tool_start ↦ start child span — `execute_tool` operation,
44
+ * `gen_ai.tool.name` / `gen_ai.tool.call.id`
45
+ * stream.tool_end ↦ end tool span (ERROR status + `error.type`
46
+ * if errored). Correlated by toolCallId so
47
+ * PARALLEL tool calls close the right span.
48
+ * cost.tick ↦ setAttribute on topmost active span
49
+ * error.fatal ↦ ERROR status on root + defensive unwind
50
+ * context.evaluated ↦ N span events `agentfootprint.skill.routing`
51
+ * — SYNTHESIZED name (one per routing entry),
52
+ * not a registry-verbatim forward; all other
53
+ * span events use the registry name verbatim
54
+ *
55
+ * ## Decisions = SPAN EVENTS, not attributes (design decision)
56
+ *
57
+ * Explainability signals (route decisions, skill routing, validation
58
+ * rejections, permission checks, credential lifecycle) are emitted as
59
+ * **span events** on the currently-active span rather than attributes:
60
+ *
61
+ * 1. MULTIPLICITY — an iteration span can carry several decisions
62
+ * (route + N skill routings + M permission checks). Attributes are
63
+ * last-write-wins and would clobber; span events accumulate.
64
+ * 2. ORDERING — span events carry their own timestamps, preserving the
65
+ * decision sequence inside one span. Compliance review (EU AI Act
66
+ * Art. 12 record-keeping) needs the order decisions were made.
67
+ * 3. ROUND-TRIP — OTLP backends (and agentThinkingUI's `fromOTLP`
68
+ * ingestion) surface span events as first-class timeline entries.
69
+ *
70
+ * When the consumer-injected tracer's spans don't implement `addEvent`
71
+ * (minimal test doubles), the adapter falls back to flattened
72
+ * `${eventName}.${key}` attributes — degraded (last-write-wins) but
73
+ * never silently dropped.
74
+ *
75
+ * ## PII discipline
76
+ *
77
+ * Mirrors the #9 validation contract: attribute values NEVER echo
78
+ * runtime VALUES that can carry PII —
79
+ * - tool args → top-level key NAMES only (`agentfootprint.tool.args.keys`)
80
+ * - tool results → `typeof` only (`agentfootprint.tool.result.type`)
81
+ * - validation issues → path / expected / got TYPES (bounded upstream)
82
+ * - decide() evidence → rule labels, operators, thresholds (developer
83
+ * constants) and the engine's redaction-aware value SUMMARIES
84
+ * - userPrompt / llm content / thinking → never emitted
85
+ * - error.fatal → stage + scope only (error MESSAGES can echo values)
86
+ * - credential events carry no secrets by construction (registry contract)
87
+ *
88
+ * @example Basic — Honeycomb via OTLP
89
+ * ```ts
90
+ * import { NodeTracerProvider } from '@opentelemetry/sdk-trace-node';
91
+ * import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';
92
+ * import { BatchSpanProcessor } from '@opentelemetry/sdk-trace-base';
93
+ * import { otelObservability } from 'agentfootprint/observability-providers';
94
+ *
95
+ * // Set up OTel ONCE at app startup.
96
+ * const provider = new NodeTracerProvider();
97
+ * provider.addSpanProcessor(new BatchSpanProcessor(new OTLPTraceExporter({
98
+ * url: 'https://api.honeycomb.io/v1/traces',
99
+ * headers: { 'x-honeycomb-team': process.env.HONEYCOMB_KEY },
100
+ * })));
101
+ * provider.register();
102
+ *
103
+ * const otel = otelObservability({
104
+ * serviceName: 'my-agent',
105
+ * // genAiSpanNames: true, // opt-in spec span names ('chat gpt-4', …)
106
+ * });
107
+ * agent.enable.observability({ strategy: otel });
108
+ * // Optional — operator-level decide()/select() evidence as span events:
109
+ * // Agent.create({...}).recorder(otel.decisionEvidenceRecorder())
110
+ * ```
111
+ *
112
+ * @example Test injection
113
+ * ```ts
114
+ * otelObservability({
115
+ * serviceName: 'test',
116
+ * tracer: mockTracer, // anything matching the OTel Tracer interface
117
+ * });
118
+ * ```
119
+ */
120
+ import type { FlowDecisionEvent, FlowSelectedEvent } from 'footprintjs';
121
+ import type { ObservabilityStrategy } from '../../strategies/types.js';
122
+ export interface OtelObservabilityOptions {
123
+ /** Service name on every emitted span. Surfaces in your OTel
124
+ * backend's service map. Required. */
125
+ readonly serviceName: string;
126
+ /** OTel Tracer to use. Defaults to
127
+ * `trace.getTracer('agentfootprint', AGENTFOOTPRINT_VERSION)`
128
+ * (where `trace` is the lazy-imported `@opentelemetry/api`). */
129
+ readonly tracer?: OtelTracerLike;
130
+ /** 0..1 — sample rate for turn-level spans. Default `1.0`.
131
+ * Sampling decisions are normally an OTel SDK concern (via
132
+ * `Sampler`); this option is a per-strategy override for cases
133
+ * where the consumer wants agentfootprint to drop spans BEFORE
134
+ * they reach the SDK (e.g., aggressive cost control). */
135
+ readonly sampleRate?: number;
136
+ /**
137
+ * Opt-in OTel GenAI semconv SPAN NAMES (default `false`):
138
+ *
139
+ * root → `invoke_agent {serviceName}` (was `{serviceName}`)
140
+ * llm → `chat {model}` (was `llm`)
141
+ * tool → `execute_tool {toolName}` (was `tool:{toolName}`)
142
+ *
143
+ * Off by default because existing consumers' dashboards / alerts key
144
+ * on the legacy span names — renames would break them. All `gen_ai.*`
145
+ * ATTRIBUTES are emitted regardless of this flag (purely additive),
146
+ * so semconv-aware backends can already group by
147
+ * `gen_ai.operation.name` with the flag off.
148
+ */
149
+ readonly genAiSpanNames?: boolean;
150
+ /**
151
+ * Explainability span events (default `true`): route decisions, skill
152
+ * routing provenance, validation rejections, permission decisions,
153
+ * credential lifecycle. Set `false` to emit only the span tree +
154
+ * `gen_ai.*` attributes (e.g., aggressive per-byte vendor billing).
155
+ */
156
+ readonly explainability?: boolean;
157
+ }
158
+ /** Attribute value union we emit. Matches OTel's `AttributeValue`
159
+ * subset: primitives + homogeneous string arrays
160
+ * (`gen_ai.response.finish_reasons`, issue lists, …). */
161
+ export type OtelAttributeValue = string | number | boolean | readonly string[];
162
+ /** Subset of `@opentelemetry/api`'s `Tracer` we depend on. */
163
+ export interface OtelTracerLike {
164
+ startSpan(name: string, options?: OtelSpanOptions, context?: unknown): OtelSpanLike;
165
+ }
166
+ /** Subset of `@opentelemetry/api`'s `SpanOptions`. */
167
+ export interface OtelSpanOptions {
168
+ attributes?: Record<string, OtelAttributeValue>;
169
+ startTime?: number;
170
+ kind?: number;
171
+ }
172
+ /** Subset of `@opentelemetry/api`'s `Span` we depend on. */
173
+ export interface OtelSpanLike {
174
+ setAttribute(key: string, value: OtelAttributeValue): unknown;
175
+ setStatus(status: {
176
+ code: number;
177
+ message?: string;
178
+ }): unknown;
179
+ end(endTime?: number): void;
180
+ spanContext(): {
181
+ traceId: string;
182
+ spanId: string;
183
+ traceFlags: number;
184
+ };
185
+ /** OTel `Span.addEvent` — optional in the duck-typed surface so
186
+ * minimal test doubles still satisfy the interface. Explainability
187
+ * signals degrade to flattened attributes when absent. */
188
+ addEvent?(name: string, attributes?: Record<string, OtelAttributeValue>): unknown;
189
+ }
190
+ /**
191
+ * footprintjs CombinedRecorder (FlowRecorder channel) that forwards
192
+ * decide()/select() operator-level evidence into the paired
193
+ * otelObservability strategy as span events. Attach via
194
+ * `Agent.create({...}).recorder(...)` or
195
+ * `executor.attachCombinedRecorder(...)`.
196
+ */
197
+ export interface OtelDecisionEvidenceRecorder {
198
+ readonly id: string;
199
+ onDecision(event: FlowDecisionEvent): void;
200
+ onSelected(event: FlowSelectedEvent): void;
201
+ }
202
+ /** Return type of {@link otelObservability} — the base
203
+ * ObservabilityStrategy plus the decide()/select() evidence bridge. */
204
+ export interface OtelObservabilityStrategy extends ObservabilityStrategy {
205
+ /**
206
+ * Build the decide()/select() evidence bridge for this strategy.
207
+ *
208
+ * Operator-level decision evidence (which rule fired, the
209
+ * `key op threshold → actual` conditions) travels on footprintjs's
210
+ * FlowRecorder channel (`onDecision` / `onSelected`) — it never
211
+ * reaches the typed event dispatcher, so the strategy alone can't
212
+ * see it. This recorder is the bridge (same pattern as the #5
213
+ * causal-evidence bridge in `memory/causal/evidenceRecorder.ts`).
214
+ *
215
+ * Decisions WITHOUT structured evidence are skipped — they already
216
+ * arrive via the `agent.route_decided` / `composition.route_decided`
217
+ * typed events, so forwarding them here would double-report.
218
+ *
219
+ * @remarks PII: attaching this recorder EXPORTS bounded actual scope
220
+ * values to your OTel collector — each condition renders as
221
+ * `key op threshold → actualSummary (bool)`, where `actualSummary` is
222
+ * the engine's redaction-aware ≤80-char value summary (e.g.
223
+ * `creditScore gt 700 → 750 (true)`). Keys covered by a footprintjs
224
+ * `RedactionPolicy` render `[REDACTED]`; everything else leaves the
225
+ * process. For compliance record-keeping that disclosure is usually
226
+ * the point — but treat the collector as PII-bearing, or redact the
227
+ * relevant keys upstream, before attaching.
228
+ *
229
+ * @remarks Attach ONCE per executor. Every instance carries the
230
+ * well-known id `'otel-decision-evidence'`, so re-attaching is
231
+ * idempotent-by-ID (the replacement prevents double-reported span
232
+ * events); instances from the same strategy share its turn state by
233
+ * design.
234
+ */
235
+ decisionEvidenceRecorder(): OtelDecisionEvidenceRecorder;
236
+ }
237
+ export declare function otelObservability(opts: OtelObservabilityOptions): OtelObservabilityStrategy;
@@ -0,0 +1,88 @@
1
+ /**
2
+ * xrayObservability — AWS X-Ray distributed-tracing adapter.
3
+ *
4
+ * Maps agentfootprint's event taxonomy onto AWS X-Ray segment trees:
5
+ *
6
+ * agent.turn_start ↦ root segment (one trace per turn)
7
+ * agent.turn_end ↦ close root segment + flush
8
+ * agent.iteration_start ↦ push subsegment under root
9
+ * agent.iteration_end ↦ close iteration subsegment
10
+ * stream.llm_start ↦ push leaf subsegment (model call)
11
+ * stream.llm_end ↦ close llm subsegment
12
+ * stream.tool_start ↦ push leaf subsegment (tool call)
13
+ * stream.tool_end ↦ close tool subsegment (correlated
14
+ * by toolCallId — parallel-safe)
15
+ * error.fatal ↦ fault on root + close the whole
16
+ * tree (turn_end never arrives)
17
+ *
18
+ * Events are anchored on `meta.runId` (the dispatcher envelope),
19
+ * with a `payload.runId` fallback for hand-built events.
20
+ *
21
+ * The result in the X-Ray Trace Map: a hierarchical timeline of every
22
+ * agent run — turn → iteration → llm-call/tool-call — queryable in
23
+ * X-Ray Insights, joinable with the rest of your AWS distributed
24
+ * trace via `AWSTraceHeader` propagation (consumer's responsibility
25
+ * to wire upstream/downstream IDs).
26
+ *
27
+ * Subpath: `agentfootprint/observability-providers`
28
+ * Peer dep: `@aws-sdk/client-xray` (OPTIONAL — installed only when
29
+ * this adapter is used).
30
+ *
31
+ * Sampling:
32
+ * By default every turn produces one trace. Pass `sampleRate: 0.1`
33
+ * to sample 10% of turns — sampling decisions are made at
34
+ * `turn_start` and persist for the whole turn (so partial traces
35
+ * never reach X-Ray).
36
+ *
37
+ * @example
38
+ * ```ts
39
+ * import { xrayObservability } from 'agentfootprint/observability-providers';
40
+ * import { microtaskBatchDriver } from 'footprintjs/detach';
41
+ *
42
+ * agent.enable.observability({
43
+ * strategy: xrayObservability({
44
+ * region: 'us-east-1',
45
+ * serviceName: 'my-agent',
46
+ * sampleRate: 0.1, // 10% sampling
47
+ * }),
48
+ * detach: { driver: microtaskBatchDriver, mode: 'forget' },
49
+ * });
50
+ * ```
51
+ *
52
+ * @example Test injection
53
+ * ```ts
54
+ * xrayObservability({
55
+ * serviceName: 'test',
56
+ * _client: {
57
+ * putTraceSegments: async (input) => { capturedDocs.push(input); },
58
+ * },
59
+ * });
60
+ * ```
61
+ */
62
+ import type { ObservabilityStrategy } from '../../strategies/types.js';
63
+ export interface XrayObservabilityOptions {
64
+ /** AWS region. Falls back to AWS_REGION / AWS_DEFAULT_REGION env. */
65
+ readonly region?: string;
66
+ /** Service name on every emitted segment. Surfaces in X-Ray's
67
+ * service map. Required. */
68
+ readonly serviceName: string;
69
+ /** 0..1 — fraction of turns to sample. Default `1.0` (every turn).
70
+ * Decisions are made at `turn_start` and persist for the whole
71
+ * turn so partial traces never reach X-Ray. */
72
+ readonly sampleRate?: number;
73
+ /** Max segments buffered before forced flush. X-Ray's
74
+ * `PutTraceSegments` API accepts up to 50 segments per call;
75
+ * default 25 keeps latency tight. */
76
+ readonly maxBatchSegments?: number;
77
+ /** Forced flush window for low-traffic agents. Default 1000ms.
78
+ * `0` disables time-based flush. */
79
+ readonly flushIntervalMs?: number;
80
+ /** Test injection — bypasses SDK lazy-require entirely. */
81
+ readonly _client?: XRayLikeClient;
82
+ }
83
+ export interface XRayLikeClient {
84
+ putTraceSegments(input: {
85
+ TraceSegmentDocuments: ReadonlyArray<string>;
86
+ }): Promise<unknown>;
87
+ }
88
+ export declare function xrayObservability(opts: XrayObservabilityOptions): ObservabilityStrategy;