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,761 @@
1
+ /**
2
+ * Event payload types — the 45 typed event payloads across 13 domains.
3
+ *
4
+ * Pattern: Discriminated Union (Gang of Four inspired, TS-native).
5
+ * Role: Contract layer of Event-Driven Hexagonal Architecture.
6
+ * Emits: (types only).
7
+ */
8
+ import type { CompositionKind, ContextLifetime, ContextRecency, ContextRole, ContextSlot, ContextSource, LLMProviderName, ToolProtocol } from './types.js';
9
+ import type { ThinkingBlock } from '../thinking/types.js';
10
+ export interface CompositionEnterPayload {
11
+ readonly kind: CompositionKind;
12
+ readonly id: string;
13
+ readonly name: string;
14
+ readonly childCount: number;
15
+ }
16
+ export interface CompositionExitPayload {
17
+ readonly kind: CompositionKind;
18
+ readonly id: string;
19
+ /** Display name supplied at composition build time (e.g., the
20
+ * `Sequence.create({ name: 'IntakePipeline' })` arg). Mirrors the
21
+ * `name` field on `CompositionEnterPayload` so consumers narrating
22
+ * the exit moment can reference the same human-readable identity
23
+ * used at entry — no name-cache required across the start/stop
24
+ * pair. Optional for back-compat with pre-v2.14.5 emitters. */
25
+ readonly name?: string;
26
+ readonly status: 'ok' | 'err' | 'break' | 'budget_exhausted';
27
+ readonly durationMs: number;
28
+ }
29
+ export interface ParallelForkStartPayload {
30
+ readonly parentId: string;
31
+ readonly branches: readonly {
32
+ id: string;
33
+ name: string;
34
+ }[];
35
+ }
36
+ export interface ParallelBranchCompletePayload {
37
+ readonly parentId: string;
38
+ readonly branchId: string;
39
+ readonly status: 'ok' | 'err';
40
+ readonly durationMs: number;
41
+ }
42
+ export interface ParallelMergeEndPayload {
43
+ readonly parentId: string;
44
+ /**
45
+ * Which merge strategy ran. `'fn'` = `mergeWithFn` (strict, plain
46
+ * results map). `'llm'` = `mergeWithLLM` (strict, LLM synthesis).
47
+ * `'outcomes-fn'` = `mergeOutcomesWithFn` (tolerant, full
48
+ * `BranchOutcome` map). Distinct values so consumers can render
49
+ * tolerant vs strict merges differently in dashboards.
50
+ */
51
+ readonly strategy: 'llm' | 'fn' | 'outcomes-fn';
52
+ readonly resultSummary: string;
53
+ /** Number of branches whose result FED the merge — i.e., succeeded
54
+ * (or, in tolerant mode, those the merge fn actually consumed as
55
+ * `{ok: true}`). Failing branches are counted in `totalBranchCount
56
+ * - mergedBranchCount`. */
57
+ readonly mergedBranchCount: number;
58
+ /** Total number of branches declared on the Parallel — equals
59
+ * `mergedBranchCount` on all-success runs, larger on partial. */
60
+ readonly totalBranchCount: number;
61
+ }
62
+ export interface ConditionalRouteDecidedPayload {
63
+ readonly conditionalId: string;
64
+ readonly chosen: string;
65
+ readonly rationale?: string;
66
+ readonly evidence?: unknown;
67
+ }
68
+ export interface LoopIterationStartPayload {
69
+ readonly loopId: string;
70
+ readonly iteration: number;
71
+ }
72
+ export interface LoopIterationExitPayload {
73
+ readonly loopId: string;
74
+ readonly iteration: number;
75
+ readonly reason: 'budget' | 'guard_false' | 'break' | 'body_complete';
76
+ }
77
+ export interface AgentTurnStartPayload {
78
+ readonly turnIndex: number;
79
+ readonly userPrompt: string;
80
+ }
81
+ export interface AgentTurnEndPayload {
82
+ readonly turnIndex: number;
83
+ readonly finalContent: string;
84
+ readonly totalInputTokens: number;
85
+ readonly totalOutputTokens: number;
86
+ readonly iterationCount: number;
87
+ readonly durationMs: number;
88
+ }
89
+ export interface AgentIterationStartPayload {
90
+ readonly turnIndex: number;
91
+ readonly iterIndex: number;
92
+ }
93
+ export interface AgentIterationEndPayload {
94
+ readonly turnIndex: number;
95
+ readonly iterIndex: number;
96
+ readonly toolCallCount: number;
97
+ /** Conversation history (LLM messages) at the END of this
98
+ * iteration. Captured by `agent.run()` for fault-tolerant
99
+ * resume — `RunCheckpointError.checkpoint` snapshots this so
100
+ * `agent.resumeOnError(...)` can replay from the last good
101
+ * iteration. Optional for back-compat with v2.x recorders that
102
+ * subscribed without expecting this field. */
103
+ readonly history?: ReadonlyArray<unknown>;
104
+ }
105
+ export interface AgentRouteDecidedPayload {
106
+ readonly turnIndex: number;
107
+ readonly iterIndex: number;
108
+ readonly chosen: 'tool-calls' | 'final';
109
+ readonly rationale?: string;
110
+ }
111
+ export interface AgentHandoffPayload {
112
+ readonly fromAgentId: string;
113
+ readonly toAgentId: string;
114
+ readonly reason?: string;
115
+ readonly viaProtocol?: 'native' | 'mcp' | 'http';
116
+ }
117
+ export interface LLMStartPayload {
118
+ readonly iteration: number;
119
+ readonly provider: LLMProviderName;
120
+ readonly model: string;
121
+ readonly systemPromptChars: number;
122
+ readonly messagesCount: number;
123
+ readonly toolsCount: number;
124
+ /**
125
+ * The tool CATALOG the model saw for this call — what was at its disposal when
126
+ * it chose (the menu behind its tool-selection reasoning). One `{ name,
127
+ * description }` per tool sent to the provider, in request order. Absent when
128
+ * the call had no tools. The structured "what the model saw" payload: pair it
129
+ * with the iteration's reasoning to debug WHY a tool was (or wasn't) picked.
130
+ * Names + descriptions only — full input schemas live in the snapshot.
131
+ */
132
+ readonly tools?: readonly {
133
+ readonly name: string;
134
+ readonly description?: string;
135
+ }[];
136
+ readonly estimatedPromptTokens?: number;
137
+ readonly temperature?: number;
138
+ readonly providerRequestRef?: string;
139
+ }
140
+ export interface LLMEndPayload {
141
+ readonly iteration: number;
142
+ readonly content: string;
143
+ readonly toolCallCount: number;
144
+ readonly usage: {
145
+ readonly input: number;
146
+ readonly output: number;
147
+ readonly cacheRead?: number;
148
+ readonly cacheWrite?: number;
149
+ };
150
+ readonly stopReason: string;
151
+ readonly durationMs: number;
152
+ readonly providerResponseRef?: string;
153
+ }
154
+ export interface LLMTokenPayload {
155
+ readonly iteration: number;
156
+ readonly tokenIndex: number;
157
+ readonly content: string;
158
+ }
159
+ export interface ToolStartPayload {
160
+ readonly toolName: string;
161
+ readonly toolCallId: string;
162
+ readonly args: Readonly<Record<string, unknown>>;
163
+ readonly parallelCount?: number;
164
+ readonly protocol?: ToolProtocol;
165
+ }
166
+ export interface ToolEndPayload {
167
+ readonly toolCallId: string;
168
+ readonly result: unknown;
169
+ readonly error?: boolean;
170
+ readonly durationMs: number;
171
+ }
172
+ export interface ContextInjectedPayload {
173
+ readonly contentSummary: string;
174
+ readonly contentHash: string;
175
+ readonly rawContent?: string;
176
+ readonly slot: ContextSlot;
177
+ readonly asRole?: ContextRole;
178
+ readonly asRecency?: ContextRecency;
179
+ readonly position?: number;
180
+ readonly sectionTag?: string;
181
+ readonly source: ContextSource;
182
+ readonly sourceId?: string;
183
+ readonly upstreamRef?: string;
184
+ readonly reason: string;
185
+ readonly retrievalScore?: number;
186
+ readonly rankPosition?: number;
187
+ readonly threshold?: number;
188
+ readonly budgetSpent?: {
189
+ readonly tokens: number;
190
+ readonly fractionOfCap: number;
191
+ };
192
+ readonly expiresAfter?: ContextLifetime;
193
+ }
194
+ export interface ContextEvictedPayload {
195
+ readonly slot: ContextSlot;
196
+ readonly contentHash: string;
197
+ readonly reason: 'budget' | 'stale' | 'low_score' | 'policy' | 'user_revoked';
198
+ readonly survivalMs: number;
199
+ }
200
+ export interface ContextSlotComposedPayload {
201
+ readonly slot: ContextSlot;
202
+ readonly iteration: number;
203
+ readonly budget: {
204
+ readonly cap: number;
205
+ readonly used: number;
206
+ readonly headroomChars: number;
207
+ };
208
+ readonly sourceBreakdown: Readonly<Partial<Record<ContextSource, {
209
+ readonly chars: number;
210
+ readonly count: number;
211
+ }>>>;
212
+ readonly orderingStrategy?: string;
213
+ readonly droppedCount: number;
214
+ readonly droppedSummaries: readonly string[];
215
+ }
216
+ export interface ContextBudgetPressurePayload {
217
+ readonly slot: ContextSlot;
218
+ readonly capTokens: number;
219
+ readonly projectedTokens: number;
220
+ readonly overflowBy: number;
221
+ readonly planAction: 'evict' | 'summarize' | 'abort';
222
+ }
223
+ /**
224
+ * Fired once per iteration by the Injection Engine after it evaluates every
225
+ * Injection's trigger — BEFORE the Context fork routes the survivors into the
226
+ * three slots. This is the "what was considered, what won, what was skipped
227
+ * and why" signal; `context.slot_composed` is its downstream counterpart
228
+ * ("what actually landed in each slot"). Pure observability — no flow stage
229
+ * reads it.
230
+ */
231
+ export interface ContextEvaluatedPayload {
232
+ readonly iteration: number;
233
+ /** Number of injections active this iteration. */
234
+ readonly activeCount: number;
235
+ /** Number skipped (predicate false counts as neither — only errors/unknown land here). */
236
+ readonly skippedCount: number;
237
+ /** Total injections evaluated (the full declared list). */
238
+ readonly evaluatedTotal: number;
239
+ /** Ids of the active injections, in evaluation order. */
240
+ readonly activeIds: readonly string[];
241
+ /** Why each skipped injection was skipped (errors / unknown trigger kinds). */
242
+ readonly skippedDetails: readonly {
243
+ readonly id: string;
244
+ readonly reason: 'predicate-threw' | 'unknown-trigger-kind';
245
+ readonly error?: string;
246
+ }[];
247
+ /** Count of active injections by trigger kind (always / rule / on-tool-return / llm-activated). */
248
+ readonly triggerKindCounts: Readonly<Record<string, number>>;
249
+ /**
250
+ * The Skill CATALOG the LLM was offered this turn — every registered Skill's
251
+ * `id` + `description` (the same text that lands in the `read_skill` tool
252
+ * description). Lets observers pair "what was offered" against "what the LLM
253
+ * chose" (`read_skill` → `activatedInjectionIds`) when debugging a missed or
254
+ * wrong activation. Empty when no Skills are registered. Static across turns.
255
+ */
256
+ readonly skillCatalog: readonly {
257
+ readonly id: string;
258
+ readonly description: string;
259
+ }[];
260
+ /**
261
+ * Routing PROVENANCE for the active injections that came from a `skillGraph()`
262
+ * — *why* each was reached. One entry per active skill-graph injection (a
263
+ * decision-tree leaf, a flat entry, or a route edge); absent when no active
264
+ * injection carries skill-graph metadata. The structured counterpart to the
265
+ * `context.routed` commentary line — lets the lens show the decision path, the
266
+ * matched predicate, and the tools a route unlocked. Structural shape (mirrors
267
+ * `SkillRouting` from the injection engine; events stay decoupled from it).
268
+ */
269
+ readonly routing?: readonly {
270
+ readonly injectionId: string;
271
+ readonly flavor: string;
272
+ /** `'tree' | 'entry' | 'route' | 'model'`. */
273
+ readonly via: string;
274
+ /** Decision path (tree only): predicates root→leaf + branch taken. */
275
+ readonly path?: readonly {
276
+ readonly label: string;
277
+ readonly branch: string;
278
+ }[];
279
+ /** Entry/route edge caption. */
280
+ readonly label?: string;
281
+ /** Source skill id (route only). */
282
+ readonly from?: string;
283
+ /** Compiled trigger kind for a route. */
284
+ readonly triggerKind?: string;
285
+ /** Tool names this injection unlocked. */
286
+ readonly tools?: readonly string[];
287
+ }[];
288
+ }
289
+ export interface ErrorFatalPayload {
290
+ readonly error: string;
291
+ readonly stage: string;
292
+ readonly scope: string;
293
+ }
294
+ export interface PauseRequestPayload {
295
+ readonly reason: string;
296
+ readonly questionPayload: Readonly<Record<string, unknown>>;
297
+ }
298
+ export interface PauseResumePayload {
299
+ readonly resumeInput: Readonly<Record<string, unknown>>;
300
+ readonly pausedDurationMs: number;
301
+ }
302
+ export interface MemoryStrategyAppliedPayload {
303
+ readonly strategyId: string;
304
+ readonly strategyKind: 'sliding-window' | 'summarizing' | 'semantic' | 'fact-extraction' | 'hybrid';
305
+ readonly reason: string;
306
+ readonly scoreEvidence?: Readonly<Record<string, unknown>>;
307
+ readonly inputMemoryCount: number;
308
+ readonly outputMemoryCount: number;
309
+ readonly droppedIds: readonly string[];
310
+ readonly addedIds: readonly string[];
311
+ }
312
+ export interface MemoryAttachedPayload {
313
+ readonly memoryId: string;
314
+ readonly contentSummary: string;
315
+ readonly score?: number;
316
+ readonly rank?: number;
317
+ readonly source: 'store' | 'auto-extract' | 'manual';
318
+ readonly retriever?: 'pinecone' | 'weaviate' | 'qdrant' | 'chroma' | 'custom';
319
+ }
320
+ export interface MemoryDetachedPayload {
321
+ readonly memoryId: string;
322
+ readonly reason: 'stale' | 'budget' | 'score_low' | 'policy';
323
+ }
324
+ export interface MemoryWrittenPayload {
325
+ readonly memoryId: string;
326
+ readonly contentSummary: string;
327
+ readonly source: 'auto' | 'manual';
328
+ readonly actor?: string;
329
+ }
330
+ export interface ToolsOfferedPayload {
331
+ readonly availableIds: readonly string[];
332
+ readonly withheldIds: readonly string[];
333
+ readonly withheldReasons: Readonly<Record<string, 'permission' | 'skill_inactive' | 'gated' | 'cost_guard'>>;
334
+ readonly reason: string;
335
+ }
336
+ export interface ToolsActivatedPayload {
337
+ readonly toolId: string;
338
+ readonly reason: 'skill_activated' | 'autoActivate' | 'permission_granted';
339
+ readonly source?: string;
340
+ }
341
+ export interface ToolsDeactivatedPayload {
342
+ readonly toolId: string;
343
+ readonly reason: 'skill_deactivated' | 'permission_revoked';
344
+ }
345
+ /**
346
+ * Emitted at the start of a `ToolProvider.list(ctx)` call inside the
347
+ * Discover stage. Pairs with `tools.discovery_completed` (success) or
348
+ * `tools.discovery_failed` (error). Use the pair to measure async-
349
+ * provider latency per iteration without joining stages by hand.
350
+ */
351
+ export interface ToolsDiscoveryStartedPayload {
352
+ readonly providerId: string | undefined;
353
+ readonly iteration: number;
354
+ }
355
+ /**
356
+ * Emitted when `ToolProvider.list(ctx)` resolves successfully. The
357
+ * `durationMs` is the wall-clock between `tools.discovery_started` and
358
+ * resolution; `toolCount` is the size of the returned tool list. For
359
+ * sync providers `durationMs` is ~0; for async hub-backed providers
360
+ * this is your observability hook for catalog-fetch latency.
361
+ */
362
+ export interface ToolsDiscoveryCompletedPayload {
363
+ readonly providerId: string | undefined;
364
+ readonly iteration: number;
365
+ readonly durationMs: number;
366
+ readonly toolCount: number;
367
+ }
368
+ /**
369
+ * Emitted when a custom `ToolProvider.list(ctx)` throws or rejects.
370
+ * The iteration is aborted; a configured `reliability` rule decides
371
+ * whether to retry, fall back, or fail-fast. `providerId` lets
372
+ * consumers route alerts to the right hub adapter (rube / mcp /
373
+ * custom-discovery). `durationMs` measures how long the failed call
374
+ * spent before throwing, so timeouts vs immediate rejections are
375
+ * distinguishable.
376
+ */
377
+ export interface ToolsDiscoveryFailedPayload {
378
+ readonly providerId: string | undefined;
379
+ readonly error: string;
380
+ readonly errorName: string;
381
+ readonly iteration: number;
382
+ readonly durationMs: number;
383
+ }
384
+ /**
385
+ * Emitted when LLM-produced tool args fail validation against the tool's
386
+ * declared `inputSchema` (backlog #9). Fires for BOTH modes that validate:
387
+ * `enforced: true` means the call was rejected before dispatch and the
388
+ * model received a structured retry message as the tool result;
389
+ * `enforced: false` ('warn' mode) means the tool executed anyway.
390
+ * `issues` name paths, expectations, and received TYPES — never the
391
+ * supplied values (they can carry PII / injection payloads).
392
+ */
393
+ export interface ValidationArgsInvalidPayload {
394
+ readonly toolName: string;
395
+ readonly toolCallId: string;
396
+ readonly iteration: number;
397
+ readonly issues: ReadonlyArray<{
398
+ readonly path: string;
399
+ readonly expected: string;
400
+ readonly got: string;
401
+ }>;
402
+ readonly enforced: boolean;
403
+ }
404
+ export interface SkillActivatedPayload {
405
+ readonly skillId: string;
406
+ readonly reason: 'autoActivate' | 'read_skill_result' | 'manual';
407
+ readonly injectedTools?: readonly string[];
408
+ readonly injectedSystemPromptChars?: number;
409
+ }
410
+ export interface SkillDeactivatedPayload {
411
+ readonly skillId: string;
412
+ readonly reason: string;
413
+ }
414
+ /**
415
+ * Fired by the skill-graph read_skill GATE when the model tries to `read_skill`
416
+ * a skill that is NOT reachable from the current cursor. The jump is rejected
417
+ * (cursor/activations unchanged); the model gets a synthetic re-prompt naming
418
+ * `allowed`. Powers the lens / Why-panel "it tried to leave the graph here".
419
+ */
420
+ export interface SkillRejectedPayload {
421
+ /** The skill id the model requested via `read_skill`. */
422
+ readonly requestedId: string;
423
+ /** The cursor it was at (undefined = cold start, before any entry resolved). */
424
+ readonly currentSkillId?: string;
425
+ /** The reachable set it was bounded to (what the re-prompt offered). */
426
+ readonly allowed: readonly string[];
427
+ /** The ReAct iteration the rejection fired on. */
428
+ readonly iteration: number;
429
+ }
430
+ export interface PermissionCheckPayload {
431
+ readonly capability: 'tool_call' | 'memory_read' | 'memory_write' | 'external_net' | 'user_data';
432
+ readonly actor: string;
433
+ readonly target?: string;
434
+ readonly result: 'allow' | 'deny' | 'halt' | 'gate_open';
435
+ readonly policyEngine?: 'opa' | 'cerbos' | 'custom';
436
+ readonly policyRuleId?: string;
437
+ readonly rationale?: string;
438
+ /** v2.12 — telemetry tag carried through from PermissionDecision.reason. */
439
+ readonly reason?: string;
440
+ }
441
+ export interface PermissionGateOpenedPayload {
442
+ readonly gateId: string;
443
+ readonly openedBy: string;
444
+ readonly expiresAt?: number;
445
+ }
446
+ /** A tool's declared credential is being resolved before invocation. */
447
+ export interface CredentialRequestedPayload {
448
+ readonly service: string;
449
+ readonly mode?: 'machine' | 'user';
450
+ }
451
+ /** A credential was issued. Carries the `kind` only — NEVER the token/secret. */
452
+ export interface CredentialAcquiredPayload {
453
+ readonly service: string;
454
+ readonly kind: string;
455
+ readonly expiresAt?: number;
456
+ }
457
+ /** 3-legged consent is required (the tool is not run until the user authorizes).
458
+ * Carries `sessionId` for correlation, NOT the authorization URL. */
459
+ export interface CredentialAuthorizationRequiredPayload {
460
+ readonly service: string;
461
+ readonly sessionId: string;
462
+ }
463
+ /** Credential resolution failed (the tool is not run). Carries the reason only. */
464
+ export interface CredentialFailedPayload {
465
+ readonly service: string;
466
+ readonly reason: string;
467
+ }
468
+ export interface PermissionGateClosedPayload {
469
+ readonly gateId: string;
470
+ readonly reason: string;
471
+ }
472
+ /**
473
+ * Emitted (v2.12) when a `PermissionChecker.check()` returns
474
+ * `{ result: 'halt', ... }`. Pairs with the typed `PolicyHaltError`
475
+ * thrown by `Agent.run()` — the event is the OBSERVABILITY signal,
476
+ * the error is the RUNTIME signal. Both carry the same `reason` for
477
+ * routing (e.g. `'security:exfiltration'` → PagerDuty).
478
+ *
479
+ * Fires AFTER the synthetic tool_result has been written to scope.history
480
+ * but BEFORE the run terminates, so observability adapters see the
481
+ * halt while the conversation history is consistent for downstream
482
+ * audit/replay.
483
+ */
484
+ export interface PermissionHaltPayload {
485
+ readonly checkerId?: string;
486
+ readonly target: string;
487
+ readonly reason: string;
488
+ readonly tellLLM?: string;
489
+ readonly iteration: number;
490
+ readonly sequenceLength: number;
491
+ }
492
+ export interface RiskFlaggedPayload {
493
+ readonly severity: 'low' | 'medium' | 'high' | 'critical';
494
+ readonly category: 'pii' | 'prompt_injection' | 'runaway_loop' | 'cost_overrun' | 'hallucination_flag';
495
+ readonly detector: 'nemo_guardrails' | 'llama_guard' | 'custom' | 'heuristic';
496
+ readonly evidence: Readonly<Record<string, unknown>>;
497
+ readonly action: 'warn' | 'redact' | 'abort';
498
+ }
499
+ export interface FallbackTriggeredPayload {
500
+ readonly kind: 'provider' | 'tool' | 'skill';
501
+ readonly primary: string;
502
+ readonly fallback: string;
503
+ readonly reason: string;
504
+ }
505
+ export interface CostTickPayload {
506
+ readonly scope: 'iteration' | 'turn' | 'run';
507
+ readonly tokensInput: number;
508
+ readonly tokensOutput: number;
509
+ readonly estimatedUsd: number;
510
+ readonly cumulative: {
511
+ readonly tokensInput: number;
512
+ readonly tokensOutput: number;
513
+ readonly estimatedUsd: number;
514
+ };
515
+ }
516
+ export interface CostLimitHitPayload {
517
+ readonly kind: 'max_tokens' | 'max_cost' | 'max_iterations' | 'max_wallclock';
518
+ readonly limit: number;
519
+ readonly actual: number;
520
+ readonly action: 'abort' | 'warn' | 'degrade';
521
+ }
522
+ export interface EvalScorePayload {
523
+ readonly metricId: string;
524
+ readonly value: number;
525
+ readonly threshold?: number;
526
+ readonly target: 'iteration' | 'turn' | 'run' | 'toolCall';
527
+ readonly targetRef: string;
528
+ readonly evaluator?: 'llm' | 'fn' | 'heuristic';
529
+ readonly evidence?: Readonly<Record<string, unknown>>;
530
+ }
531
+ export interface EvalThresholdCrossedPayload {
532
+ readonly metricId: string;
533
+ readonly direction: 'above' | 'below';
534
+ readonly value: number;
535
+ readonly threshold: number;
536
+ readonly actionTaken?: string;
537
+ }
538
+ /**
539
+ * Emitted (v2.13) when the agent's final answer fails the agent's
540
+ * configured `outputSchema` (the parser passed to
541
+ * `Agent.create({...}).outputSchema(parser)`).
542
+ *
543
+ * Scope: ONLY agent-level final-answer validation. Tool-input validation
544
+ * (`LLMToolSchema.inputSchema`) is a different concern handled by
545
+ * provider-side type checks; this event does NOT fire for tool-arg
546
+ * validation failures.
547
+ *
548
+ * Lives in the `agent.*` domain (parallel to `agent.turn_end`) because
549
+ * final-answer validation is a turn-level concern, not a generic
550
+ * evaluation metric.
551
+ *
552
+ * Pairs with `agentfootprint.error.retried` (when a reliability rule
553
+ * routes the failure to retry with feedback) or
554
+ * `agentfootprint.reliability.fail_fast` (when retries are exhausted).
555
+ *
556
+ * The event is the OBSERVABILITY signal — it fires on EVERY validation
557
+ * failure, regardless of whether retries are configured. Use the
558
+ * `attempt` + `cumulativeRetries` fields to drive operator dashboards
559
+ * for retry-rate trending (a leading indicator for model drift).
560
+ *
561
+ * Fires BEFORE PostDecide rules evaluate, so observability sees the
562
+ * failure even if a buggy rule routes to fail-fast or swallows it.
563
+ */
564
+ export interface AgentOutputSchemaValidationFailedPayload {
565
+ /** Validation error message (from Zod / parser). */
566
+ readonly message: string;
567
+ /** Validation stage — JSON parse vs schema validate. Lets dashboards
568
+ * distinguish "model emitted prose" (`json-parse`) from "model emitted
569
+ * JSON but wrong shape" (`schema-validate`); they trend differently
570
+ * under model drift. */
571
+ readonly stage: 'json-parse' | 'schema-validate';
572
+ /** Failing field path when the parser exposes one (e.g. `'amount.currency'`).
573
+ * Only set when `stage === 'schema-validate'`. */
574
+ readonly path?: string;
575
+ /** The raw string output that failed — useful for narrative entries showing
576
+ * "what the model actually said" alongside the validation error. */
577
+ readonly rawOutput?: string;
578
+ /** 1-indexed attempt counter. `1` for the first failure, `2` for the
579
+ * retry that also failed, etc. */
580
+ readonly attempt: number;
581
+ /** Total output-schema failures in this gate execution. Same as
582
+ * `validationErrorHistory.length`. Distinct from `attempt` because a
583
+ * gate can also retry on non-validation errors (5xx, etc.) — this
584
+ * counts ONLY the schema-driven failures. */
585
+ readonly cumulativeRetries: number;
586
+ }
587
+ export interface ErrorRetriedPayload {
588
+ readonly attempt: number;
589
+ readonly maxAttempts: number;
590
+ readonly lastError: string;
591
+ readonly backoffMs: number;
592
+ readonly reason: string;
593
+ }
594
+ export interface ErrorRecoveredPayload {
595
+ readonly attempt: number;
596
+ readonly totalDurationMs: number;
597
+ }
598
+ /**
599
+ * Fired when the rules loop (or the reliability gate chart) gives up via
600
+ * a `fail-fast` decision. Superset shape: `phase`/`kind`/`attempt` are
601
+ * always present; the remaining fields are populated by whichever site
602
+ * emits (the loop carries `label`/`providerUsed`/`errorKind`; the gate
603
+ * chart carries `reason`).
604
+ */
605
+ export interface ReliabilityFailFastPayload {
606
+ readonly phase: 'pre-check' | 'post-decide';
607
+ /** The matched rule's `kind` (machine-readable bucket). */
608
+ readonly kind: string;
609
+ /** 1-indexed attempt counter at the point of failure. */
610
+ readonly attempt: number;
611
+ /** Human-readable label of the matched rule (loop sites). */
612
+ readonly label?: string;
613
+ /** Free-form reason string (gate-chart sites). */
614
+ readonly reason?: string;
615
+ /** Provider in use when the loop failed fast. */
616
+ readonly providerUsed?: string;
617
+ /** Classification of the failure being failed-fast on. */
618
+ readonly errorKind?: string;
619
+ /** Originating error message, when present. */
620
+ readonly errorMessage?: string;
621
+ }
622
+ /**
623
+ * Fired each time the rules loop decides to RETRY after a failed attempt
624
+ * — `action` distinguishes a same-provider retry from a provider failover.
625
+ */
626
+ export interface ReliabilityRetriedPayload {
627
+ /** 1-indexed counter of the attempt that just FAILED and is being retried. */
628
+ readonly attempt: number;
629
+ /** `retry` = same provider again; `retry-other` = switch provider. */
630
+ readonly action: 'retry' | 'retry-other';
631
+ /** Classification of the failure being retried. */
632
+ readonly errorKind: string;
633
+ /** Originating error message, when present. */
634
+ readonly errorMessage?: string;
635
+ /** Provider that just failed. */
636
+ readonly fromProvider: string;
637
+ /** Provider the NEXT attempt will use (equals `fromProvider` for `retry`). */
638
+ readonly toProvider: string;
639
+ }
640
+ /**
641
+ * Fired when the rules loop produces a successful response AFTER one or
642
+ * more failed attempts (self-healed). `recoveredVia` names the mechanism
643
+ * of the final successful step.
644
+ */
645
+ export interface ReliabilityRecoveredPayload {
646
+ /** 1-indexed attempt number that finally succeeded. */
647
+ readonly attempt: number;
648
+ /** How recovery happened. */
649
+ readonly recoveredVia: 'retry' | 'retry-other' | 'fallback';
650
+ /** How many attempts failed before this success. */
651
+ readonly priorFailures: number;
652
+ /** Classification of the LAST failure before recovery. */
653
+ readonly errorKind: string;
654
+ }
655
+ export interface EmbeddingGeneratedPayload {
656
+ readonly model: string;
657
+ readonly provider: 'openai' | 'cohere' | 'voyage' | 'local' | 'custom';
658
+ readonly inputKind: 'query' | 'document';
659
+ readonly dimension: number;
660
+ readonly count: number;
661
+ readonly durationMs: number;
662
+ readonly tokensSpent?: number;
663
+ }
664
+ /**
665
+ * Emitted (v2.14) per provider chunk that carries thinking-content
666
+ * tokens. Lives in `stream.*` domain — parallel to `stream.token` for
667
+ * visible-content tokens.
668
+ *
669
+ * **Provider behavior:**
670
+ * - Anthropic: fires for every `content_block_delta` with
671
+ * `delta.type === 'thinking_delta'`. May fire 100s of times per turn.
672
+ * - OpenAI o1/o3: NEVER fires (OpenAI doesn't stream reasoning content
673
+ * as of early 2026). Only `thinking_end` fires at response completion.
674
+ * - Custom providers: fire when `ThinkingHandler.parseChunk()` returns
675
+ * a non-empty `thinkingDelta`.
676
+ *
677
+ * **Default consumer behavior:** thinking_delta events are emitted but
678
+ * not surfaced to end users unless a consumer explicitly subscribes to
679
+ * this event (e.g. for reasoning-as-it-streams UIs).
680
+ *
681
+ * **Sensitive data:** `content` is raw model thinking text. Use
682
+ * `RedactionPolicy.thinkingPatterns` (Phase 3) to scrub before audit-log
683
+ * adapters fire. Same risk profile as `stream.token`.
684
+ */
685
+ export interface StreamThinkingDeltaPayload {
686
+ readonly iteration: number;
687
+ readonly tokenIndex: number;
688
+ /** Per-chunk delta text, NOT accumulated. ~10–50 chars typical. */
689
+ readonly content: string;
690
+ }
691
+ /**
692
+ * Emitted (v2.14) once per LLM call where thinking blocks were
693
+ * produced. Pairs with the leading `stream.thinking_delta` events when
694
+ * streaming, OR fires standalone for non-streaming providers (OpenAI).
695
+ *
696
+ * Use this event for live per-iteration UIs (chat-bubble reasoning
697
+ * pills, retry-rate dashboards, telemetry). The `blocks` field carries
698
+ * the same content that lands on `LLMMessage.thinkingBlocks` — read it
699
+ * here for live display instead of post-walking `scope.history` after
700
+ * the run completes (the framework's "collect during traversal" rule).
701
+ *
702
+ * **`tokens` field population:**
703
+ * - Anthropic: `undefined` currently — Anthropic's `response.usage`
704
+ * doesn't break out thinking tokens (bundled in `output_tokens`).
705
+ * May change in future Anthropic API revisions.
706
+ * - OpenAI o1/o3: populated from
707
+ * `response.usage.completion_tokens_details.reasoning_tokens`.
708
+ * - Custom providers: populated when handler computes it during
709
+ * `normalize()`.
710
+ *
711
+ * **Sensitive data:** the `blocks` field carries reasoning content.
712
+ * Same risk profile as `stream.token` — wildcard (`*`) recorders
713
+ * piping to external sinks (Datadog, CloudWatch, OTel) will see this.
714
+ * Treat thinking content with the same redaction posture you give
715
+ * visible response tokens. `providerMeta` is already stripped by the
716
+ * framework before persistence (Phase 6 invariant), so the blocks
717
+ * here match the audit-log surface bytes-exactly.
718
+ */
719
+ export interface StreamThinkingEndPayload {
720
+ readonly iteration: number;
721
+ readonly blockCount: number;
722
+ readonly totalChars: number;
723
+ readonly tokens?: number;
724
+ /**
725
+ * v2.14+ — the normalized thinking blocks for this LLM call.
726
+ *
727
+ * Same data the framework persists to `LLMMessage.thinkingBlocks`
728
+ * (post-`providerMeta` strip). Lets live consumers render the
729
+ * model's chain-of-thought per iteration without scope-walking
730
+ * after the run.
731
+ *
732
+ * Empty / undefined when no thinking content was produced this
733
+ * call (handler returned `[]`). Non-empty when at least one
734
+ * thinking or redacted_thinking block landed.
735
+ */
736
+ readonly blocks?: readonly ThinkingBlock[];
737
+ }
738
+ /**
739
+ * Emitted (v2.14) when a `ThinkingHandler.normalize()` call throws.
740
+ * The framework catches the throw, drops the thinking blocks (they
741
+ * don't land on `LLMMessage.thinkingBlocks`), and continues the agent
742
+ * run. Same graceful-failure pattern as v2.11.6
743
+ * `tools.discovery_failed`.
744
+ *
745
+ * Lives in `agent.*` domain (NOT `stream.*`) because parse failure is
746
+ * a turn-level error concern — recovery happens at the agent loop
747
+ * level, not at the SDK call level.
748
+ *
749
+ * **Anti-pattern (provider authors):** sanitize error messages before
750
+ * throwing. NEVER include raw unparsed thinking content in the error
751
+ * — the message ends up in audit logs and can leak reasoning content
752
+ * the consumer expected to be redacted. Same guidance as
753
+ * `tools.discovery_failed.error`.
754
+ */
755
+ export interface AgentThinkingParseFailedPayload {
756
+ readonly providerName: string;
757
+ readonly subflowId: string;
758
+ readonly error: string;
759
+ readonly errorName: string;
760
+ readonly iteration: number;
761
+ }