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,83 @@
1
+ /**
2
+ * routeRecorder — records the skill-graph route a run actually took.
3
+ *
4
+ * A passive observer that reconstructs, hop by hop, which skill the agent was in,
5
+ * where it went next, and WHY — by COMPOSING already-shipped events (no engine
6
+ * change): `agentfootprint.context.evaluated` (its `routing[]` carries via/from/
7
+ * label per active skill-graph injection) + `agentfootprint.skill.rejected` (an
8
+ * out-of-reach read_skill) + `stream.tool_start` (the tool that drove a hop).
9
+ *
10
+ * Also folds in the GREY-AREA GOVERNORS (observability tier): it detects
11
+ * oscillation (A→B→A→B within `pingPongWindow`) and a run of consecutive rejected
12
+ * `read_skill` jumps (`maxRejectedRetries`), reported via `getTrips()`. These LABEL
13
+ * the trace (`onTrip:'stay'` semantics) — the hard "always stops" guarantee remains
14
+ * the agent's iteration cap; a runtime force-stop is a deferred follow-on.
15
+ *
16
+ * Pattern: CombinedRecorder (Convention 1 — single purpose: route evidence). Owns a
17
+ * `SequenceStore<RouteHop>`. Convention 4: resets on a new `runId`.
18
+ * Role: Tier-3 /observe recorder — `Agent.create(...).recorder(routeRecorder())`.
19
+ * Powers the lens, the "Why this skill?" panel, and paper route figures.
20
+ */
21
+ import type { EmitEvent } from 'footprintjs';
22
+ interface RunBoundaryEvent {
23
+ readonly traversalContext?: {
24
+ readonly runId?: string;
25
+ };
26
+ }
27
+ /** How the graph arrived at a skill on a hop. */
28
+ export type RouteOutcome = 'entry' | 'route' | 'stay' | 'rejected';
29
+ /** One hop of the route — the skill the graph was in at one iteration + how. */
30
+ export interface RouteHop {
31
+ /** runtimeStageId of the iteration (the SequenceStore key). */
32
+ readonly runtimeStageId: string;
33
+ readonly iteration: number;
34
+ /** The skill before this hop (undefined at cold start). */
35
+ readonly fromSkill?: string;
36
+ /** The skill after this hop (undefined for a pure rejection). */
37
+ readonly toSkill?: string;
38
+ readonly outcome: RouteOutcome;
39
+ /** A human-readable reason for this hop (see `formatRouteHop`). */
40
+ readonly why: string;
41
+ /** The route edge's caption, when one drove the hop. */
42
+ readonly edgeLabel?: string;
43
+ /** The tool whose result drove the hop (most recent tool_start). */
44
+ readonly lastTool?: string;
45
+ /** Rejection only — the skill the model tried to jump to. */
46
+ readonly requestedSkill?: string;
47
+ /** Rejection only — the reachable set it was bounded to. */
48
+ readonly reachable?: readonly string[];
49
+ }
50
+ /** A governor trip — the route is misbehaving. */
51
+ export type RouteTripKind = 'ping-pong' | 'rejected-cap';
52
+ export interface RouteTrip {
53
+ readonly kind: RouteTripKind;
54
+ readonly iteration: number;
55
+ readonly skills: readonly string[];
56
+ readonly detail: string;
57
+ }
58
+ export interface RouteRecorderOptions {
59
+ readonly id?: string;
60
+ /** Window for oscillation detection (a [X,Y,X,Y] pattern trips). Default 4. */
61
+ readonly pingPongWindow?: number;
62
+ /** Consecutive rejected read_skill jumps before a `rejected-cap` trip. Default 3. */
63
+ readonly maxRejectedRetries?: number;
64
+ }
65
+ export interface RouteRecorderHandle {
66
+ readonly id: string;
67
+ /** The distinct skill sequence the run moved through (the "route"). */
68
+ getPath(): readonly string[];
69
+ /** Every hop, in order. */
70
+ getHops(): readonly RouteHop[];
71
+ /** The rejected read_skill attempts (out-of-reach jumps). */
72
+ getRejections(): readonly RouteHop[];
73
+ /** Governor trips (oscillation / rejected-retry cap). */
74
+ getTrips(): readonly RouteTrip[];
75
+ clear(): void;
76
+ onEmit(event: EmitEvent): void;
77
+ onRunStart(event: RunBoundaryEvent): void;
78
+ }
79
+ /** A human-readable one-line reason for a hop. Exported (pure). */
80
+ export declare function formatRouteHop(hop: RouteHop): string;
81
+ /** Build the route recorder. */
82
+ export declare function routeRecorder(options?: RouteRecorderOptions): RouteRecorderHandle;
83
+ export {};
@@ -0,0 +1,231 @@
1
+ /**
2
+ * RunStepRecorder — slider-ready ordered list of RunSteps, BUILT
3
+ * INCREMENTALLY during traversal. Real-time recorder, not a walker.
4
+ *
5
+ * Pattern: extends `SequenceStore<RunStep>` (shared storage shelf)
6
+ * and implements `CombinedRecorder` (FlowRecorder hooks).
7
+ * Subscribes to the agentfootprint typed-event dispatcher
8
+ * for actor-arrow events. Each event handler decides whether
9
+ * to emit a step; state lives on the instance and persists
10
+ * across the run.
11
+ * Role: The single source of truth for "what slider positions
12
+ * exist in this run, and what transitions does each light
13
+ * up." Lens consumers attach the recorder once and read
14
+ * `getSteps()` — no per-render re-derivation.
15
+ *
16
+ * Why this matters: the older `buildRunSteps(events)` walker violated
17
+ * footprintjs's core principle ("collect during traversal, never
18
+ * post-process"). Each call walked the full event log multiple times;
19
+ * the playground triggered a full walk on every flowchart update,
20
+ * yielding O(N²) total work for a streaming run. The recorder pattern
21
+ * is O(N) — one handler call per event — and matches BoundaryRecorder /
22
+ * FlowchartRecorder / KeyedStore idioms throughout the library.
23
+ *
24
+ * The `buildRunSteps(...)` function is RETAINED as a thin compatibility
25
+ * shim that constructs a fresh recorder, replays events through it,
26
+ * and returns the resulting entries. Useful for snapshot-from-saved-
27
+ * events use cases (replay, testing, post-hoc analysis). Live consumers
28
+ * should attach the recorder directly via `runner.attach(rec)`.
29
+ */
30
+ import type { CombinedRecorder, FlowDecisionEvent, FlowForkEvent, FlowLoopEvent, FlowSubflowEvent, TraversalContext } from 'footprintjs';
31
+ interface FlowRunEvent {
32
+ readonly payload?: unknown;
33
+ readonly traversalContext?: TraversalContext;
34
+ }
35
+ import type { AgentfootprintEvent } from '../../events/registry.js';
36
+ import type { EventDispatcher, Unsubscribe } from '../../events/dispatcher.js';
37
+ import type { BoundaryRecorder, DomainEvent } from './BoundaryRecorder.js';
38
+ /**
39
+ * One slider position. The smallest scrubable unit of the run.
40
+ *
41
+ * `transitions` is 1+ — fan-out / merge steps light up multiple
42
+ * transitions at once; sequential / decide / react steps light up
43
+ * exactly one. Renderers iterate `transitions` to highlight edges;
44
+ * details panels read `anchor.runtimeStageId`.
45
+ */
46
+ export interface RunStep {
47
+ /** 0-based slider index (matches array position in `getSteps()`). */
48
+ readonly seq: number;
49
+ readonly kind: RunStepKind;
50
+ readonly transitions: readonly RunStepTransition[];
51
+ /**
52
+ * Per-step key — required by `SequenceStore<T>` for time-travel
53
+ * utilities (`getEntriesForStep`, `getEntryRanges`). Mirrors
54
+ * `anchor.runtimeStageId`; both fields point at the same value.
55
+ * Top-level placement satisfies the recorder's storage contract.
56
+ */
57
+ readonly runtimeStageId: string;
58
+ /** Anchor for commentary highlight + details pane lookup. */
59
+ readonly anchor: {
60
+ readonly runtimeStageId: string;
61
+ readonly subflowPath: readonly string[];
62
+ };
63
+ /** Human label — short, kind-specific. */
64
+ readonly label: string;
65
+ /** Wall-clock ms at which this step occurred. */
66
+ readonly tsMs: number;
67
+ /** Kind-specific decoration. Discriminate on `kind`. */
68
+ readonly meta?: RunStepMeta;
69
+ }
70
+ export type RunStepKind = 'sequential' | 'fork' | 'merge' | 'decide' | 'iteration' | 'iteration-exit' | 'react';
71
+ export interface RunStepTransition {
72
+ readonly from: string;
73
+ readonly to: string;
74
+ readonly via: 'next' | 'fork-branch' | 'decision-branch' | 'loop-iteration' | 'actor-arrow';
75
+ readonly label?: string;
76
+ }
77
+ export type RunStepMeta = {
78
+ readonly kind: 'decide';
79
+ readonly chosen: string;
80
+ readonly rationale?: string;
81
+ } | {
82
+ readonly kind: 'iteration';
83
+ readonly index: number;
84
+ readonly target: string;
85
+ } | {
86
+ readonly kind: 'iteration-exit';
87
+ readonly index: number;
88
+ readonly reason?: string;
89
+ } | {
90
+ readonly kind: 'fork';
91
+ readonly parentSubflowId: string;
92
+ } | {
93
+ readonly kind: 'merge';
94
+ readonly mergedCount: number;
95
+ } | {
96
+ readonly kind: 'react';
97
+ readonly actorArrow: 'user→llm' | 'tool→llm' | 'llm→tool' | 'llm→user';
98
+ };
99
+ export interface RunStepRecorderOptions {
100
+ readonly id?: string;
101
+ }
102
+ /** Factory — matches the `boundaryRecorder()` / `topologyRecorder()` style. */
103
+ export declare function runStepRecorder(options?: RunStepRecorderOptions): RunStepRecorder;
104
+ /**
105
+ * Real-time slider-step recorder. Emits a `RunStep` whenever an event
106
+ * marks a meaningful slider transition. State persists on the instance
107
+ * so successive events update bookkeeping in O(1).
108
+ *
109
+ * Attach via `runner.attach(rec)` for FlowRecorder events; call
110
+ * `rec.subscribe(runner.dispatcher)` for actor-arrow events. The
111
+ * `getSteps(drillPath?)` method returns the already-built list (no
112
+ * walking) with optional drill-scope filtering.
113
+ */
114
+ export declare class RunStepRecorder implements CombinedRecorder {
115
+ readonly id: string;
116
+ /** Composition: storage shelf for the slider-step sequence. */
117
+ private readonly store;
118
+ /** Run-boundary observer — fires this.clear() when traversalContext.runId
119
+ * changes between events. THIS IS THE FIX for the Parallel multi-run
120
+ * aliasing bug — without it `forkKey = ${parent}@${rid}` collides
121
+ * because rid resets to `seed#0` on each run. */
122
+ private readonly runIdGuard;
123
+ /** Stack of currently-open boundaries. The recorder owns this
124
+ * directly because it's a simple stack and frames are recorder-
125
+ * shaped. */
126
+ private boundaryStack;
127
+ /** Fork-emission coalescing + branch-exit tally. */
128
+ private readonly forks;
129
+ /** Tracks the most-recent leaf exit per depth → "forwards" handoff. */
130
+ private readonly siblings;
131
+ /** Buffers a "this MIGHT be the answer" leaf until onRunEnd. */
132
+ private readonly answerBuffer;
133
+ /** Run-root inference state machine (leaf vs composition). */
134
+ private readonly rootInferrer;
135
+ /** llm.start / llm.end actor-arrow classifier. */
136
+ private readonly actorArrows;
137
+ /** Has the first `asks` step fired? */
138
+ private asksEmitted;
139
+ constructor(options?: RunStepRecorderOptions);
140
+ /**
141
+ * Emit a RunStep, auto-mirroring `anchor.runtimeStageId` to the
142
+ * top-level `runtimeStageId` field that the keyed index uses. Single
143
+ * source of truth (the anchor) — never inconsistent with the storage
144
+ * key.
145
+ */
146
+ private push;
147
+ /** Internal seq-numbering helper — mirrors the store size so each
148
+ * RunStep gets a unique 0-based index in emit order. */
149
+ private get entryCount();
150
+ clear(): void;
151
+ /** Internal — wipe all per-run state WITHOUT resetting the runIdGuard
152
+ * itself. Called by `clear()` (which then resets the guard) AND by
153
+ * the runIdGuard's onNewRun callback (where the guard is mid-update
154
+ * and must NOT be reset, only the recorder's data should be).
155
+ *
156
+ * Note: each sub-tracker owns its OWN clear; the orchestrator just
157
+ * fans out. Adding new state to a sub-tracker requires no edit here. */
158
+ private resetForNewRun;
159
+ private observeRunId;
160
+ onRunStart(event: FlowRunEvent): void;
161
+ onRunEnd(event: FlowRunEvent): void;
162
+ onSubflowEntry(event: FlowSubflowEvent): void;
163
+ onSubflowExit(event: FlowSubflowEvent): void;
164
+ onFork(event: FlowForkEvent): void;
165
+ onDecision(event: FlowDecisionEvent): void;
166
+ onLoop(event: FlowLoopEvent): void;
167
+ /**
168
+ * Subscribe to the runner's typed-event dispatcher and emit a
169
+ * `react` RunStep on every `llm.start` / `llm.end`. The recorder
170
+ * classifies `actorArrow` locally (mirrors BoundaryRecorder's
171
+ * pattern) so consumers don't have to depend on BoundaryRecorder's
172
+ * own subscription order.
173
+ */
174
+ subscribe(dispatcher: EventDispatcher): Unsubscribe;
175
+ /** Internal — also called by `ingestDomainEvent` for shim replay.
176
+ *
177
+ * NOTE: deliberately does NOT call observeRunId(event.meta.runId).
178
+ * The agentfootprint dispatcher's runId is a DIFFERENT generator
179
+ * than footprintjs's traversalContext.runId — mixing them would
180
+ * toggle lastRunId on every event and trigger a false reset.
181
+ * Run-boundary detection happens reliably on the FlowRecorder side
182
+ * (onRunStart fires FIRST in any new run before any typed event). */
183
+ protected ingestTypedEvent(event: AgentfootprintEvent): void;
184
+ /**
185
+ * Feed a single recorded `DomainEvent` (from BoundaryRecorder) into
186
+ * this recorder as if it had fired live. Used by `buildRunSteps`
187
+ * for snapshot replay; tests use it for fixture-driven projection.
188
+ *
189
+ * Live consumers should use `runner.attach(rec)` +
190
+ * `rec.subscribe(dispatcher)` instead — the recorder's hooks fire
191
+ * naturally during traversal.
192
+ */
193
+ ingestDomainEvent(e: DomainEvent): void;
194
+ /**
195
+ * Read-only query — returns the already-built step list filtered to
196
+ * `drillPath` scope. O(1) per call when scope is empty; O(N) filter
197
+ * otherwise. Composition-vs-leaf root filter is applied so the
198
+ * slider semantics match the user's mental model:
199
+ *
200
+ * - **Leaf root** (single Agent / LLMCall): show `react` steps only.
201
+ * - **Composition root** (Sequence / Parallel / Conditional / Loop):
202
+ * show composition steps; hide intra-leaf `react` steps.
203
+ *
204
+ * Drill-down filters by `anchor.subflowPath` prefix and re-applies
205
+ * the leaf-vs-composition rule for the drilled scope.
206
+ */
207
+ getSteps(drillPath?: readonly string[]): readonly RunStep[];
208
+ /** Flush any deferred answer-candidate from the buffer. Called by
209
+ * `onRunEnd` so a single `answers` step appears for runs that end
210
+ * on a leaf exit (no further leaf entries followed). */
211
+ private flushCandidateAnswer;
212
+ }
213
+ export interface RunStepGraph {
214
+ readonly steps: readonly RunStep[];
215
+ }
216
+ export interface BuildRunStepsOptions {
217
+ readonly drillPath?: readonly string[];
218
+ }
219
+ /**
220
+ * Compatibility shim for snapshot-from-events use cases (replay,
221
+ * post-hoc analysis, tests). For LIVE use, prefer attaching a
222
+ * `RunStepRecorder` directly via `runner.attach(rec)` —
223
+ * `buildRunSteps(events)` constructs a fresh recorder, replays the
224
+ * events through its handlers, and returns the resulting entries.
225
+ *
226
+ * @deprecated Prefer `runStepRecorder()` + `runner.attach(rec)` for
227
+ * live consumers. This shim remains for offline / testing
228
+ * scenarios where only a recorded event list is available.
229
+ */
230
+ export declare function buildRunSteps(source: BoundaryRecorder | readonly DomainEvent[], options?: BuildRunStepsOptions): RunStep[];
231
+ export {};
@@ -0,0 +1,36 @@
1
+ /**
2
+ * StatusRecorder — Claude Code-style live status line for Agent runs.
3
+ *
4
+ * Pattern: Facade over EventDispatcher's wildcard subscription.
5
+ * Role: Tier 3 observability — the low-level helper behind
6
+ * `attachStatus(dispatcher, { onStatus })` (exported from
7
+ * `agentfootprint/observe`). For the high-level, uniform path use
8
+ * `agent.enable.liveStatus({ strategy: chatBubbleLiveStatus({ onLine }) })`.
9
+ * One callback receives a human-readable status string at every
10
+ * meaningful moment.
11
+ * Emits: Does NOT emit; READS core events via the dispatcher and calls
12
+ * `onStatus`.
13
+ */
14
+ import type { EventDispatcher, Unsubscribe } from '../../events/dispatcher.js';
15
+ import type { AgentfootprintEventMap } from '../../events/registry.js';
16
+ export interface StatusOptions {
17
+ /**
18
+ * Called with a human-readable status string at each meaningful moment
19
+ * (iteration start, tool start/end, route decision, turn end).
20
+ */
21
+ readonly onStatus: (status: string) => void;
22
+ /**
23
+ * Custom formatter. Return `null` to skip an event; return a string
24
+ * to emit that status. Omit for the built-in renderer.
25
+ */
26
+ readonly format?: (event: StatusEvent) => string | null;
27
+ }
28
+ /**
29
+ * Subset of events the thinking renderer formats. Discriminated on `type`.
30
+ */
31
+ export type StatusEvent = AgentfootprintEventMap['agentfootprint.agent.turn_start'] | AgentfootprintEventMap['agentfootprint.agent.turn_end'] | AgentfootprintEventMap['agentfootprint.agent.iteration_start'] | AgentfootprintEventMap['agentfootprint.agent.route_decided'] | AgentfootprintEventMap['agentfootprint.stream.tool_start'] | AgentfootprintEventMap['agentfootprint.stream.tool_end'];
32
+ /**
33
+ * Attach a thinking-status subscription to the event dispatcher.
34
+ * Returns an Unsubscribe — call to detach.
35
+ */
36
+ export declare function attachStatus(dispatcher: EventDispatcher, options: StatusOptions): Unsubscribe;
@@ -0,0 +1,164 @@
1
+ /**
2
+ * toolChoiceRecorder — runtime tool-choice margins (RFC-002 tier 2,
3
+ * blocks C4–C6).
4
+ *
5
+ * Per LLM call that OFFERED tools, this recorder captures the menu the
6
+ * model saw (`stream.llm_start.tools`), what it actually invoked
7
+ * (`stream.tool_start`), and the choice context — then, LAZILY on first
8
+ * read, ranks the offered candidates against that context via
9
+ * influence-core's `scoreMargin` (C4):
10
+ *
11
+ * margin = score(best chosen) − score(best non-chosen)
12
+ *
13
+ * Small margin (`narrow`, < `marginThreshold`, default 0.05) = the
14
+ * choice was a close call under the proxy. Top-scored candidate not
15
+ * among the chosen (`proxyDisagreement`) is ALWAYS flagged — either a
16
+ * proxy miss or a genuinely surprising model choice; both are exactly
17
+ * what a debugger wants surfaced.
18
+ *
19
+ * ## The choice context (C4 — what is embedded, precisely)
20
+ *
21
+ * `buildChoiceContext` assembles the SAME two slots the model's
22
+ * tool-selection reasoning ran on:
23
+ *
24
+ * INCLUDED
25
+ * 1. the user message of the current turn (`agent.turn_start.userPrompt`)
26
+ * — the task the model is choosing a tool FOR (first
27
+ * `maxSlotChars` chars: the head states the task);
28
+ * 2. the latest assistant reasoning text — the most recent
29
+ * `stream.llm_end.content` of this turn, when present (last
30
+ * `maxSlotChars` chars: the tail is where "what next" lives).
31
+ * Iteration 1 has no assistant text; the slot is omitted.
32
+ *
33
+ * EXCLUDED (deliberately)
34
+ * - the system prompt: constant across every call of the run — zero
35
+ * per-call discrimination, it only dilutes the embedding;
36
+ * - older history turns: recency dominates tool choice, and the full
37
+ * transcript grows the embedding cost linearly with run length;
38
+ * - raw tool results: the model reads them, but their distilled
39
+ * effect on the NEXT choice is the assistant's own reasoning text,
40
+ * which IS included; raw payloads skew the embedding toward data
41
+ * vocabulary (the honest-proxy discipline: mirror the
42
+ * decision-relevant text, not every visible byte);
43
+ * - tool schemas: those are the CANDIDATES being ranked, not context.
44
+ *
45
+ * Candidate text per offered tool = `confusabilityText` (tokenized name
46
+ * + description) — the SAME construction the catalog lint (C1) embeds,
47
+ * so build-time confusability and runtime margins measure one geometry.
48
+ *
49
+ * ## Laziness (C5)
50
+ *
51
+ * Event hooks only RECORD (string copies into a KeyedStore). The
52
+ * embedder runs on the first `getCalls()` / `getFlagged()` /
53
+ * `getSummary()` — embedding I/O NEVER rides the hot path, even when
54
+ * the recorder is attached inline. Scores memoize per entry. Attach
55
+ * with `{ delivery: 'deferred' }` (footprintjs RFC-001) to move the
56
+ * bookkeeping off the hot path too — it is a normal CombinedRecorder.
57
+ *
58
+ * Pattern: CombinedRecorder (Convention 1 — single purpose: tool-choice
59
+ * margin evidence). Owns a `KeyedStore<ToolChoiceEntry>` keyed
60
+ * by the LLM call's `runtimeStageId`. Convention 4: resets on a
61
+ * new `runId` via `FlowRecorder.onRunStart`.
62
+ * Role: Tier-3 /observe recorder. Attach via `Agent.create(...)
63
+ * .recorder(handle)` or `executor.attachCombinedRecorder`.
64
+ *
65
+ * Honest claim (RFC-002 §2): margins are embedding geometry between the
66
+ * context and tool descriptions — a deterministic PROXY for the model's
67
+ * selection function, never "the model chose because". Tier 3
68
+ * (choice-entropy sampling) validates the proxy.
69
+ */
70
+ import type { EmitEvent } from 'footprintjs';
71
+ import { type Embedder, type MarginResult } from '../../lib/influence-core/index.js';
72
+ /** Minimal structural slice of footprintjs's FlowRunEvent (runId is all
73
+ * we read — Convention 4). */
74
+ interface RunBoundaryEvent {
75
+ readonly traversalContext?: {
76
+ readonly runId?: string;
77
+ };
78
+ }
79
+ /** One offered tool, as the model saw it on `llm_start`. */
80
+ export interface OfferedTool {
81
+ readonly name: string;
82
+ readonly description?: string;
83
+ }
84
+ /** Why an entry has no margin. */
85
+ export type ToolChoiceSkipReason =
86
+ /** The model answered without invoking any tool — no choice to score. */
87
+ 'nothing-chosen'
88
+ /** A chosen tool name was not in the offered catalog (wiring anomaly —
89
+ * surfaced, not silently massaged). */
90
+ | 'chosen-not-offered';
91
+ /** One LLM call that offered tools — the recorder's public row shape. */
92
+ export interface ToolChoiceCall {
93
+ /** runtimeStageId of the LLM-call stage (the KeyedStore key). */
94
+ readonly runtimeStageId: string;
95
+ readonly iteration: number;
96
+ /** The catalog the model saw, in request order. */
97
+ readonly offered: readonly OfferedTool[];
98
+ /** Unique tool names actually invoked, in first-call order. */
99
+ readonly chosen: readonly string[];
100
+ /** Every invocation (parallel calls + repeat calls of one tool visible). */
101
+ readonly toolCallIds: readonly string[];
102
+ /** The choice context that was (or will be) embedded. */
103
+ readonly contextText: string;
104
+ /** Ranked scores + margin + flags. Undefined until scored, or when
105
+ * `skipped` says why it never will be. */
106
+ readonly margin?: MarginResult;
107
+ readonly skipped?: ToolChoiceSkipReason;
108
+ }
109
+ /** Run-summary counts (C6). */
110
+ export interface ToolChoiceSummary {
111
+ /** LLM calls that offered tools (= recorded entries). */
112
+ readonly llmCallsWithTools: number;
113
+ /** Entries where the model invoked at least one tool. */
114
+ readonly choices: number;
115
+ /** Entries with a computed `margin`. */
116
+ readonly scored: number;
117
+ /** narrow OR proxy-disagreement. */
118
+ readonly flagged: number;
119
+ readonly narrow: number;
120
+ readonly proxyDisagreement: number;
121
+ /** Entries that will never score (`skipped` set). */
122
+ readonly skipped: number;
123
+ }
124
+ export interface ToolChoiceRecorderOptions {
125
+ /**
126
+ * Injected embedder — runs ONLY on first read (lazy). Wrap in
127
+ * `embeddingCache(...)` (agentfootprint/observe) so repeated tool
128
+ * descriptions embed once across calls and runs.
129
+ */
130
+ readonly embedder: Embedder;
131
+ /** Margins below this flag `narrow`. Default 0.05 (RFC-002 §4). */
132
+ readonly marginThreshold?: number;
133
+ /** Per-slot cap for the choice context. Default 2000 chars. */
134
+ readonly maxSlotChars?: number;
135
+ /** Recorder id (default 'tool-choice'). */
136
+ readonly id?: string;
137
+ }
138
+ export interface ToolChoiceRecorderHandle {
139
+ readonly id: string;
140
+ /** All recorded LLM calls (scored on demand — first call runs the
141
+ * embedder; results memoize). Entries still open mid-run stay
142
+ * unscored until they close. */
143
+ getCalls(): Promise<readonly ToolChoiceCall[]>;
144
+ /** Calls whose choice was fragile: `narrow` margin OR
145
+ * `proxyDisagreement` (always flagged) — C6. */
146
+ getFlagged(): Promise<readonly ToolChoiceCall[]>;
147
+ /** Run-summary counts (C6). Scores pending entries first. */
148
+ getSummary(): Promise<ToolChoiceSummary>;
149
+ clear(): void;
150
+ onEmit(event: EmitEvent): void;
151
+ onRunStart(event: RunBoundaryEvent): void;
152
+ onRunEnd(event: RunBoundaryEvent): void;
153
+ onRunFailed(event: RunBoundaryEvent): void;
154
+ }
155
+ /** C4: the precise choice-context construction (see module JSDoc for the
156
+ * include/exclude rationale). Exported so consumers can reproduce it. */
157
+ export declare function buildChoiceContext(args: {
158
+ readonly userPrompt: string;
159
+ readonly latestAssistantText?: string;
160
+ readonly maxSlotChars?: number;
161
+ }): string;
162
+ /** Build the tool-choice margin recorder (C5). */
163
+ export declare function toolChoiceRecorder(options: ToolChoiceRecorderOptions): ToolChoiceRecorderHandle;
164
+ export {};
@@ -0,0 +1,71 @@
1
+ /**
2
+ * ToolLineageRecorder — derives the tool→tool DATA-FLOW graph of a run.
3
+ *
4
+ * Why this exists: in a ReAct agent a tool's output flows back to the LLM as
5
+ * text, and the LLM decides the NEXT tool's arguments — so the data dependency
6
+ * between tools (e.g. FLOGI's FCID reused as io_profile's `initiator_id`) never
7
+ * touches footprintjs's shared scope, and `causalChain` can't reconstruct it.
8
+ * This recorder rebuilds that graph from the tool emit stream by VALUE
9
+ * PROVENANCE: when a tool call's argument value equals a distinctive value
10
+ * produced by an EARLIER iteration's tool result, it records an edge
11
+ * (producer → consumer).
12
+ *
13
+ * It is a HEURISTIC, not ground truth — it matches by value, so it is accurate
14
+ * for distinctive identifiers (FCIDs, WWPNs, ids, NAAs, hostnames) and
15
+ * deliberately conservative:
16
+ * - short / common values (below `minValueLength`) are ignored,
17
+ * - numbers are ignored by default (coincidental matches are likely),
18
+ * - same-iteration (parallel) tool calls never link to each other — the LLM
19
+ * chose all their args from the same prior context, before any of them ran.
20
+ *
21
+ * No core changes: it consumes the existing `agentfootprint.stream.tool_start`
22
+ * (args) and `agentfootprint.stream.tool_end` (result) emits. Attach via
23
+ * `.recorder(toolLineageRecorder())` and read `getLineage()` after the run; the
24
+ * lens (or any consumer) can render the returned graph.
25
+ *
26
+ * Convention 1 — one purpose: it derives ONE artifact (the lineage graph) from
27
+ * the emit channel. Convention 4 — run-scoped: it resets when a new run starts
28
+ * (the `pipelineId` changes).
29
+ */
30
+ import type { EmitRecorder } from 'footprintjs';
31
+ /** A single tool invocation in the run. */
32
+ export interface ToolCallRef {
33
+ /** The execution-step id this tool call ran under. */
34
+ readonly runtimeStageId: string;
35
+ /** The provider tool-call id (stable per call). */
36
+ readonly toolCallId: string;
37
+ /** The tool's name. */
38
+ readonly toolName: string;
39
+ /** The ReAct iteration the call belongs to (0-based). */
40
+ readonly iteration: number;
41
+ }
42
+ /** A value-derived data dependency: `from`'s result value reappeared in `to`'s args. */
43
+ export interface ToolLineageEdge {
44
+ readonly from: ToolCallRef;
45
+ readonly to: ToolCallRef;
46
+ /** The distinctive value that links them. */
47
+ readonly value: string;
48
+ }
49
+ /** The tool→tool data-flow graph for one run. */
50
+ export interface ToolLineageGraph {
51
+ readonly nodes: readonly ToolCallRef[];
52
+ readonly edges: readonly ToolLineageEdge[];
53
+ }
54
+ export interface ToolLineageOptions {
55
+ /** Recorder id (idempotent-by-id when attached). Default `'tool-lineage'`. */
56
+ readonly id?: string;
57
+ /** Minimum string length for a value to be matchable. Default 4. */
58
+ readonly minValueLength?: number;
59
+ /** Also match numeric values. Default false (coincidental matches likely). */
60
+ readonly matchNumbers?: boolean;
61
+ /** Max recursion depth when flattening args/results. Default 6. */
62
+ readonly maxDepth?: number;
63
+ }
64
+ /** An EmitRecorder that also exposes the derived lineage graph. */
65
+ export interface ToolLineageRecorderHandle extends EmitRecorder {
66
+ /** The tool→tool data-flow graph derived so far. Safe to call during or after a run. */
67
+ getLineage(): ToolLineageGraph;
68
+ /** Reset all accumulated state. */
69
+ clear(): void;
70
+ }
71
+ export declare function toolLineageRecorder(options?: ToolLineageOptions): ToolLineageRecorderHandle;