agentfootprint 6.44.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 (366) hide show
  1. package/ai-instructions/setup.sh +0 -0
  2. package/dist/core/agent/buildAgentChart.js +2 -1
  3. package/dist/core/agent/buildAgentChart.js.map +1 -1
  4. package/dist/core/agent/buildDynamicAgentChart.js +3 -1
  5. package/dist/core/agent/buildDynamicAgentChart.js.map +1 -1
  6. package/dist/core/agent/stages/pickEntry.js +3 -1
  7. package/dist/core/agent/stages/pickEntry.js.map +1 -1
  8. package/dist/esm/adapters/identity/agentcore.d.ts +100 -0
  9. package/dist/esm/adapters/llm/AnthropicProvider.d.ts +130 -0
  10. package/dist/esm/adapters/llm/BedrockProvider.d.ts +100 -0
  11. package/dist/esm/adapters/llm/BrowserAnthropicProvider.d.ts +41 -0
  12. package/dist/esm/adapters/llm/BrowserOpenAIProvider.d.ts +95 -0
  13. package/dist/esm/adapters/llm/MockProvider.d.ts +153 -0
  14. package/dist/esm/adapters/llm/OpenAIProvider.d.ts +220 -0
  15. package/dist/esm/adapters/llm/createProvider.d.ts +85 -0
  16. package/dist/esm/adapters/memory/agentcore.d.ts +146 -0
  17. package/dist/esm/adapters/memory/bedrockAgentMemory.d.ts +95 -0
  18. package/dist/esm/adapters/memory/redis.d.ts +127 -0
  19. package/dist/esm/adapters/observability/agentcore.d.ts +67 -0
  20. package/dist/esm/adapters/observability/audit.d.ts +254 -0
  21. package/dist/esm/adapters/observability/cloudwatch.d.ts +96 -0
  22. package/dist/esm/adapters/observability/otel.d.ts +237 -0
  23. package/dist/esm/adapters/observability/xray.d.ts +88 -0
  24. package/dist/esm/adapters/types.d.ts +378 -0
  25. package/dist/esm/bridge/eventMeta.d.ts +59 -0
  26. package/dist/esm/cache/CacheDecisionSubflow.d.ts +85 -0
  27. package/dist/esm/cache/CacheGateDecider.d.ts +127 -0
  28. package/dist/esm/cache/applyCachePolicy.d.ts +37 -0
  29. package/dist/esm/cache/cacheRecorder.d.ts +85 -0
  30. package/dist/esm/cache/index.d.ts +33 -0
  31. package/dist/esm/cache/strategies/AnthropicCacheStrategy.d.ts +38 -0
  32. package/dist/esm/cache/strategies/BedrockCacheStrategy.d.ts +33 -0
  33. package/dist/esm/cache/strategies/NoOpCacheStrategy.d.ts +29 -0
  34. package/dist/esm/cache/strategies/OpenAICacheStrategy.d.ts +36 -0
  35. package/dist/esm/cache/strategyRegistry.d.ts +45 -0
  36. package/dist/esm/cache/types.d.ts +243 -0
  37. package/dist/esm/conventions.d.ts +203 -0
  38. package/dist/esm/core/Agent.d.ts +355 -0
  39. package/dist/esm/core/LLMCall.d.ts +139 -0
  40. package/dist/esm/core/RunnerBase.d.ts +267 -0
  41. package/dist/esm/core/agent/AgentBuilder.d.ts +565 -0
  42. package/dist/esm/core/agent/buildAgentChart.d.ts +109 -0
  43. package/dist/esm/core/agent/buildAgentChart.js +2 -1
  44. package/dist/esm/core/agent/buildAgentChart.js.map +1 -1
  45. package/dist/esm/core/agent/buildAgentMessageApiChart.d.ts +40 -0
  46. package/dist/esm/core/agent/buildCacheSubflow.d.ts +35 -0
  47. package/dist/esm/core/agent/buildDynamicAgentChart.d.ts +56 -0
  48. package/dist/esm/core/agent/buildDynamicAgentChart.js +3 -1
  49. package/dist/esm/core/agent/buildDynamicAgentChart.js.map +1 -1
  50. package/dist/esm/core/agent/buildMessageApiChart.d.ts +47 -0
  51. package/dist/esm/core/agent/buildToolRegistry.d.ts +61 -0
  52. package/dist/esm/core/agent/memoryRecallInjections.d.ts +8 -0
  53. package/dist/esm/core/agent/stages/breakFinal.d.ts +22 -0
  54. package/dist/esm/core/agent/stages/callLLM.d.ts +74 -0
  55. package/dist/esm/core/agent/stages/pickEntry.d.ts +19 -0
  56. package/dist/esm/core/agent/stages/pickEntry.js +3 -1
  57. package/dist/esm/core/agent/stages/pickEntry.js.map +1 -1
  58. package/dist/esm/core/agent/stages/prepareFinal.d.ts +19 -0
  59. package/dist/esm/core/agent/stages/reliabilityExecution.d.ts +135 -0
  60. package/dist/esm/core/agent/stages/route.d.ts +18 -0
  61. package/dist/esm/core/agent/stages/seed.d.ts +53 -0
  62. package/dist/esm/core/agent/stages/toolCalls.d.ts +76 -0
  63. package/dist/esm/core/agent/toolArgsValidation.d.ts +62 -0
  64. package/dist/esm/core/agent/types.d.ts +382 -0
  65. package/dist/esm/core/agent/validators.d.ts +52 -0
  66. package/dist/esm/core/cost.d.ts +38 -0
  67. package/dist/esm/core/flowchartAsTool.d.ts +200 -0
  68. package/dist/esm/core/humanizeLLMError.d.ts +23 -0
  69. package/dist/esm/core/outputFallback.d.ts +139 -0
  70. package/dist/esm/core/outputSchema.d.ts +127 -0
  71. package/dist/esm/core/pause.d.ts +74 -0
  72. package/dist/esm/core/runCheckpoint.d.ts +179 -0
  73. package/dist/esm/core/runner.d.ts +203 -0
  74. package/dist/esm/core/slots/buildMessagesSlot.d.ts +40 -0
  75. package/dist/esm/core/slots/buildSystemPromptSlot.d.ts +41 -0
  76. package/dist/esm/core/slots/buildThinkingSubflow.d.ts +40 -0
  77. package/dist/esm/core/slots/buildToolsSlot.d.ts +60 -0
  78. package/dist/esm/core/slots/helpers.d.ts +27 -0
  79. package/dist/esm/core/toolContract.d.ts +43 -0
  80. package/dist/esm/core/tools.d.ts +90 -0
  81. package/dist/esm/core/translator.d.ts +94 -0
  82. package/dist/esm/core-flow/Conditional.d.ts +119 -0
  83. package/dist/esm/core-flow/Loop.d.ts +160 -0
  84. package/dist/esm/core-flow/Parallel.d.ts +360 -0
  85. package/dist/esm/core-flow/Sequence.d.ts +133 -0
  86. package/dist/esm/events/dispatcher.d.ts +134 -0
  87. package/dist/esm/events/payloads.d.ts +761 -0
  88. package/dist/esm/events/registry.d.ts +198 -0
  89. package/dist/esm/events/types.d.ts +70 -0
  90. package/dist/esm/identity/kinds.d.ts +36 -0
  91. package/dist/esm/identity/staticTokens.d.ts +28 -0
  92. package/dist/esm/identity/types.d.ts +113 -0
  93. package/dist/esm/identity/withCredentialRetry.d.ts +64 -0
  94. package/dist/esm/identity.d.ts +31 -0
  95. package/dist/esm/index.d.ts +64 -0
  96. package/dist/esm/index.js +2 -0
  97. package/dist/esm/index.js.map +1 -1
  98. package/dist/esm/injection-engine.d.ts +4 -0
  99. package/dist/esm/lib/canonicalJson.d.ts +56 -0
  100. package/dist/esm/lib/context-bisect/ablation.d.ts +109 -0
  101. package/dist/esm/lib/context-bisect/bisect.d.ts +75 -0
  102. package/dist/esm/lib/context-bisect/cost.d.ts +37 -0
  103. package/dist/esm/lib/context-bisect/index.d.ts +31 -0
  104. package/dist/esm/lib/context-bisect/index.js +3 -0
  105. package/dist/esm/lib/context-bisect/index.js.map +1 -1
  106. package/dist/esm/lib/context-bisect/llmEdgeWeigher.d.ts +124 -0
  107. package/dist/esm/lib/context-bisect/localize.d.ts +152 -0
  108. package/dist/esm/lib/context-bisect/localize.js +2 -0
  109. package/dist/esm/lib/context-bisect/localize.js.map +1 -1
  110. package/dist/esm/lib/context-bisect/loop-recall.d.ts +97 -0
  111. package/dist/esm/lib/context-bisect/missingContext.d.ts +71 -0
  112. package/dist/esm/lib/context-bisect/restoration.d.ts +39 -0
  113. package/dist/esm/lib/context-bisect/toBacktrackTrace.d.ts +138 -0
  114. package/dist/esm/lib/context-bisect/trajectory.d.ts +168 -0
  115. package/dist/esm/lib/context-bisect/types.d.ts +448 -0
  116. package/dist/esm/lib/context-bisect/walk-to-root.d.ts +103 -0
  117. package/dist/esm/lib/influence-core/attributability.d.ts +72 -0
  118. package/dist/esm/lib/influence-core/cache.d.ts +94 -0
  119. package/dist/esm/lib/influence-core/contrastive.d.ts +26 -0
  120. package/dist/esm/lib/influence-core/index.d.ts +34 -0
  121. package/dist/esm/lib/influence-core/margin.d.ts +33 -0
  122. package/dist/esm/lib/influence-core/signals.d.ts +128 -0
  123. package/dist/esm/lib/influence-core/similarity.d.ts +25 -0
  124. package/dist/esm/lib/influence-core/types.d.ts +252 -0
  125. package/dist/esm/lib/injection-engine/SkillRegistry.d.ts +147 -0
  126. package/dist/esm/lib/injection-engine/buildInjectionEngineSubflow.d.ts +110 -0
  127. package/dist/esm/lib/injection-engine/buildInjectionEngineSubflow.js +1 -0
  128. package/dist/esm/lib/injection-engine/buildInjectionEngineSubflow.js.map +1 -1
  129. package/dist/esm/lib/injection-engine/entryScorer.d.ts +93 -0
  130. package/dist/esm/lib/injection-engine/entryScorer.js +172 -0
  131. package/dist/esm/lib/injection-engine/entryScorer.js.map +1 -0
  132. package/dist/esm/lib/injection-engine/evaluator.d.ts +24 -0
  133. package/dist/esm/lib/injection-engine/factories/defineFact.d.ts +60 -0
  134. package/dist/esm/lib/injection-engine/factories/defineInjection.d.ts +41 -0
  135. package/dist/esm/lib/injection-engine/factories/defineInstruction.d.ts +78 -0
  136. package/dist/esm/lib/injection-engine/factories/defineRelevanceHint.d.ts +26 -0
  137. package/dist/esm/lib/injection-engine/factories/defineSkill.d.ts +160 -0
  138. package/dist/esm/lib/injection-engine/factories/defineSteering.d.ts +39 -0
  139. package/dist/esm/lib/injection-engine/index.d.ts +22 -0
  140. package/dist/esm/lib/injection-engine/index.js +1 -0
  141. package/dist/esm/lib/injection-engine/index.js.map +1 -1
  142. package/dist/esm/lib/injection-engine/skillContract.d.ts +29 -0
  143. package/dist/esm/lib/injection-engine/skillGraph.d.ts +289 -0
  144. package/dist/esm/lib/injection-engine/skillGraph.js +35 -41
  145. package/dist/esm/lib/injection-engine/skillGraph.js.map +1 -1
  146. package/dist/esm/lib/injection-engine/skillGraphCheckup.d.ts +49 -0
  147. package/dist/esm/lib/injection-engine/skillTools.d.ts +72 -0
  148. package/dist/esm/lib/injection-engine/softmax.d.ts +11 -0
  149. package/dist/esm/lib/injection-engine/types.d.ts +229 -0
  150. package/dist/esm/lib/injection-engine/types.js.map +1 -1
  151. package/dist/esm/lib/lazyRequire.d.ts +29 -0
  152. package/dist/esm/lib/mcp/index.d.ts +9 -0
  153. package/dist/esm/lib/mcp/mcpClient.d.ts +46 -0
  154. package/dist/esm/lib/mcp/mockMcpClient.d.ts +65 -0
  155. package/dist/esm/lib/mcp/types.d.ts +133 -0
  156. package/dist/esm/lib/rag/defineRAG.d.ts +139 -0
  157. package/dist/esm/lib/rag/index.d.ts +7 -0
  158. package/dist/esm/lib/rag/indexDocuments.d.ts +105 -0
  159. package/dist/esm/lib/tool-lint/analyze.d.ts +83 -0
  160. package/dist/esm/lib/tool-lint/cli.d.ts +43 -0
  161. package/dist/esm/lib/tool-lint/format.d.ts +18 -0
  162. package/dist/esm/lib/tool-lint/index.d.ts +23 -0
  163. package/dist/esm/lib/tool-lint/rules.d.ts +85 -0
  164. package/dist/esm/lib/tool-lint/types.d.ts +155 -0
  165. package/dist/esm/lib/trace-toolpack/bounded.d.ts +47 -0
  166. package/dist/esm/lib/trace-toolpack/debugPrompt.d.ts +19 -0
  167. package/dist/esm/lib/trace-toolpack/index.d.ts +20 -0
  168. package/dist/esm/lib/trace-toolpack/lazyToolpack.d.ts +35 -0
  169. package/dist/esm/lib/trace-toolpack/selfExplain.d.ts +100 -0
  170. package/dist/esm/lib/trace-toolpack/traceDebugAgent.d.ts +42 -0
  171. package/dist/esm/lib/trace-toolpack/traceToolpack.d.ts +69 -0
  172. package/dist/esm/lib/trace-toolpack/types.d.ts +59 -0
  173. package/dist/esm/llm-providers.d.ts +26 -0
  174. package/dist/esm/locales/index.d.ts +132 -0
  175. package/dist/esm/memory/beats/extractBeats.d.ts +61 -0
  176. package/dist/esm/memory/beats/extractor.d.ts +47 -0
  177. package/dist/esm/memory/beats/formatAsNarrative.d.ts +62 -0
  178. package/dist/esm/memory/beats/heuristicExtractor.d.ts +37 -0
  179. package/dist/esm/memory/beats/index.d.ts +12 -0
  180. package/dist/esm/memory/beats/llmExtractor.d.ts +56 -0
  181. package/dist/esm/memory/beats/types.d.ts +60 -0
  182. package/dist/esm/memory/beats/writeBeats.d.ts +22 -0
  183. package/dist/esm/memory/causal/evidenceRecorder.d.ts +66 -0
  184. package/dist/esm/memory/causal/index.d.ts +6 -0
  185. package/dist/esm/memory/causal/loadSnapshot.d.ts +51 -0
  186. package/dist/esm/memory/causal/snapshotPipeline.d.ts +35 -0
  187. package/dist/esm/memory/causal/types.d.ts +130 -0
  188. package/dist/esm/memory/causal/writeSnapshot.d.ts +73 -0
  189. package/dist/esm/memory/define.d.ts +63 -0
  190. package/dist/esm/memory/define.types.d.ts +276 -0
  191. package/dist/esm/memory/define.types.js +1 -1
  192. package/dist/esm/memory/embedding/cosine.d.ts +18 -0
  193. package/dist/esm/memory/embedding/embedMessages.d.ts +58 -0
  194. package/dist/esm/memory/embedding/index.d.ts +8 -0
  195. package/dist/esm/memory/embedding/loadRelevant.d.ts +51 -0
  196. package/dist/esm/memory/embedding/mockEmbedder.d.ts +22 -0
  197. package/dist/esm/memory/embedding/types.d.ts +46 -0
  198. package/dist/esm/memory/entry/decay.d.ts +36 -0
  199. package/dist/esm/memory/entry/index.d.ts +2 -0
  200. package/dist/esm/memory/entry/types.d.ts +140 -0
  201. package/dist/esm/memory/facts/extractFacts.d.ts +50 -0
  202. package/dist/esm/memory/facts/extractor.d.ts +33 -0
  203. package/dist/esm/memory/facts/formatFacts.d.ts +60 -0
  204. package/dist/esm/memory/facts/index.d.ts +14 -0
  205. package/dist/esm/memory/facts/llmFactExtractor.d.ts +64 -0
  206. package/dist/esm/memory/facts/loadFacts.d.ts +43 -0
  207. package/dist/esm/memory/facts/patternFactExtractor.d.ts +2 -0
  208. package/dist/esm/memory/facts/types.d.ts +68 -0
  209. package/dist/esm/memory/facts/writeFacts.d.ts +19 -0
  210. package/dist/esm/memory/identity/index.d.ts +2 -0
  211. package/dist/esm/memory/identity/types.d.ts +49 -0
  212. package/dist/esm/memory/index.d.ts +19 -0
  213. package/dist/esm/memory/pipeline/auto.d.ts +59 -0
  214. package/dist/esm/memory/pipeline/default.d.ts +49 -0
  215. package/dist/esm/memory/pipeline/ephemeral.d.ts +28 -0
  216. package/dist/esm/memory/pipeline/fact.d.ts +26 -0
  217. package/dist/esm/memory/pipeline/index.d.ts +13 -0
  218. package/dist/esm/memory/pipeline/narrative.d.ts +35 -0
  219. package/dist/esm/memory/pipeline/semantic.d.ts +37 -0
  220. package/dist/esm/memory/pipeline/types.d.ts +31 -0
  221. package/dist/esm/memory/stages/formatDefault.d.ts +64 -0
  222. package/dist/esm/memory/stages/index.d.ts +13 -0
  223. package/dist/esm/memory/stages/loadRecent.d.ts +49 -0
  224. package/dist/esm/memory/stages/pickByBudget.d.ts +63 -0
  225. package/dist/esm/memory/stages/summarize.d.ts +87 -0
  226. package/dist/esm/memory/stages/tokenize.d.ts +43 -0
  227. package/dist/esm/memory/stages/types.d.ts +75 -0
  228. package/dist/esm/memory/stages/writeMessages.d.ts +71 -0
  229. package/dist/esm/memory/store/InMemoryStore.d.ts +62 -0
  230. package/dist/esm/memory/store/index.d.ts +2 -0
  231. package/dist/esm/memory/store/types.d.ts +223 -0
  232. package/dist/esm/memory/wire/index.d.ts +2 -0
  233. package/dist/esm/memory/wire/mountMemoryPipeline.d.ts +108 -0
  234. package/dist/esm/memory-providers.d.ts +37 -0
  235. package/dist/esm/observability/contextError/finders/compareFinders.d.ts +19 -0
  236. package/dist/esm/observability/contextError/finders/index.d.ts +22 -0
  237. package/dist/esm/observability/contextError/finders/rankSuspects.d.ts +2 -0
  238. package/dist/esm/observability/contextError/finders/removeAndRetry.d.ts +11 -0
  239. package/dist/esm/observability/contextError/finders/shrinkToCause.d.ts +11 -0
  240. package/dist/esm/observability/contextError/finders/testManyCombos.d.ts +11 -0
  241. package/dist/esm/observability/contextError/finders/traceSteps.d.ts +2 -0
  242. package/dist/esm/observability/contextError/finders/types.d.ts +88 -0
  243. package/dist/esm/observability-providers.d.ts +46 -0
  244. package/dist/esm/observe.d.ts +62 -0
  245. package/dist/esm/patterns/Debate.d.ts +39 -0
  246. package/dist/esm/patterns/MapReduce.d.ts +66 -0
  247. package/dist/esm/patterns/Reflection.d.ts +51 -0
  248. package/dist/esm/patterns/SelfConsistency.d.ts +43 -0
  249. package/dist/esm/patterns/Swarm.d.ts +60 -0
  250. package/dist/esm/patterns/ToT.d.ts +53 -0
  251. package/dist/esm/patterns/index.d.ts +22 -0
  252. package/dist/esm/providers.d.ts +33 -0
  253. package/dist/esm/recorders/core/AgentRecorder.d.ts +15 -0
  254. package/dist/esm/recorders/core/CompositionRecorder.d.ts +17 -0
  255. package/dist/esm/recorders/core/ContextEvaluatedRecorder.d.ts +23 -0
  256. package/dist/esm/recorders/core/ContextRecorder.d.ts +47 -0
  257. package/dist/esm/recorders/core/CostRecorder.d.ts +14 -0
  258. package/dist/esm/recorders/core/EmitBridge.d.ts +30 -0
  259. package/dist/esm/recorders/core/ErrorBridge.d.ts +38 -0
  260. package/dist/esm/recorders/core/EvalRecorder.d.ts +16 -0
  261. package/dist/esm/recorders/core/MemoryRecorder.d.ts +17 -0
  262. package/dist/esm/recorders/core/PermissionRecorder.d.ts +16 -0
  263. package/dist/esm/recorders/core/ReliabilityRecorder.d.ts +24 -0
  264. package/dist/esm/recorders/core/SkillRecorder.d.ts +14 -0
  265. package/dist/esm/recorders/core/StreamRecorder.d.ts +15 -0
  266. package/dist/esm/recorders/core/ToolsRecorder.d.ts +18 -0
  267. package/dist/esm/recorders/core/ValidationRecorder.d.ts +16 -0
  268. package/dist/esm/recorders/core/contextEngineering.d.ts +136 -0
  269. package/dist/esm/recorders/core/typedEmit.d.ts +34 -0
  270. package/dist/esm/recorders/core/types.d.ts +97 -0
  271. package/dist/esm/recorders/observability/AgentThinkingTraceRecorder.d.ts +117 -0
  272. package/dist/esm/recorders/observability/BoundaryRecorder.d.ts +546 -0
  273. package/dist/esm/recorders/observability/FlowchartRecorder.d.ts +220 -0
  274. package/dist/esm/recorders/observability/LiveStateRecorder.d.ts +250 -0
  275. package/dist/esm/recorders/observability/LoggingRecorder.d.ts +91 -0
  276. package/dist/esm/recorders/observability/RouteRecorder.d.ts +83 -0
  277. package/dist/esm/recorders/observability/RunStepRecorder.d.ts +231 -0
  278. package/dist/esm/recorders/observability/StatusRecorder.d.ts +36 -0
  279. package/dist/esm/recorders/observability/ToolChoiceRecorder.d.ts +164 -0
  280. package/dist/esm/recorders/observability/ToolLineageRecorder.d.ts +71 -0
  281. package/dist/esm/recorders/observability/commentary/commentaryTemplates.d.ts +105 -0
  282. package/dist/esm/recorders/observability/internal/ActorArrowClassifier.d.ts +25 -0
  283. package/dist/esm/recorders/observability/internal/CandidateAnswerBuffer.d.ts +28 -0
  284. package/dist/esm/recorders/observability/internal/ForkTracker.d.ts +60 -0
  285. package/dist/esm/recorders/observability/internal/RootInferrer.d.ts +51 -0
  286. package/dist/esm/recorders/observability/internal/SequenceSiblingTracker.d.ts +24 -0
  287. package/dist/esm/recorders/observability/localObservability.d.ts +48 -0
  288. package/dist/esm/recorders/observability/observeRunId.d.ts +36 -0
  289. package/dist/esm/recorders/observability/status/statusTemplates.d.ts +106 -0
  290. package/dist/esm/recorders/observability/trace.d.ts +119 -0
  291. package/dist/esm/reliability/CircuitBreaker.d.ts +75 -0
  292. package/dist/esm/reliability/buildReliabilityGateChart.d.ts +53 -0
  293. package/dist/esm/reliability/classifyError.d.ts +28 -0
  294. package/dist/esm/reliability/index.d.ts +35 -0
  295. package/dist/esm/reliability/types.d.ts +327 -0
  296. package/dist/esm/resilience/fallbackProvider.d.ts +33 -0
  297. package/dist/esm/resilience/index.d.ts +21 -0
  298. package/dist/esm/resilience/withCircuitBreaker.d.ts +129 -0
  299. package/dist/esm/resilience/withFallback.d.ts +45 -0
  300. package/dist/esm/resilience/withRetry.d.ts +71 -0
  301. package/dist/esm/security/PermissionPolicy.d.ts +124 -0
  302. package/dist/esm/security/PolicyHaltError.d.ts +72 -0
  303. package/dist/esm/security/extractSequence.d.ts +46 -0
  304. package/dist/esm/security/index.d.ts +44 -0
  305. package/dist/esm/security/thinkingRedaction.d.ts +50 -0
  306. package/dist/esm/status.d.ts +48 -0
  307. package/dist/esm/strategies/attach.d.ts +47 -0
  308. package/dist/esm/strategies/compose.d.ts +48 -0
  309. package/dist/esm/strategies/defaults/chatBubbleLiveStatus.d.ts +36 -0
  310. package/dist/esm/strategies/defaults/consoleObservability.d.ts +42 -0
  311. package/dist/esm/strategies/defaults/inMemorySinkCost.d.ts +50 -0
  312. package/dist/esm/strategies/defaults/index.d.ts +30 -0
  313. package/dist/esm/strategies/defaults/noopLens.d.ts +28 -0
  314. package/dist/esm/strategies/index.d.ts +36 -0
  315. package/dist/esm/strategies/registry.d.ts +70 -0
  316. package/dist/esm/strategies/types.d.ts +303 -0
  317. package/dist/esm/stream.d.ts +82 -0
  318. package/dist/esm/thinking/AnthropicThinkingHandler.d.ts +42 -0
  319. package/dist/esm/thinking/MockThinkingHandler.d.ts +50 -0
  320. package/dist/esm/thinking/OpenAIThinkingHandler.d.ts +37 -0
  321. package/dist/esm/thinking/index.d.ts +51 -0
  322. package/dist/esm/thinking/registry.d.ts +33 -0
  323. package/dist/esm/thinking/types.d.ts +162 -0
  324. package/dist/esm/tool-providers/gatedTools.d.ts +36 -0
  325. package/dist/esm/tool-providers/index.d.ts +41 -0
  326. package/dist/esm/tool-providers/skillScopedTools.d.ts +45 -0
  327. package/dist/esm/tool-providers/staticTools.d.ts +21 -0
  328. package/dist/esm/tool-providers/types.d.ts +138 -0
  329. package/dist/index.js +6 -2
  330. package/dist/index.js.map +1 -1
  331. package/dist/lib/context-bisect/index.js +3 -0
  332. package/dist/lib/context-bisect/index.js.map +1 -1
  333. package/dist/lib/context-bisect/localize.js +2 -0
  334. package/dist/lib/context-bisect/localize.js.map +1 -1
  335. package/dist/lib/injection-engine/buildInjectionEngineSubflow.js +1 -0
  336. package/dist/lib/injection-engine/buildInjectionEngineSubflow.js.map +1 -1
  337. package/dist/lib/injection-engine/entryScorer.js +178 -0
  338. package/dist/lib/injection-engine/entryScorer.js.map +1 -0
  339. package/dist/lib/injection-engine/index.js +5 -1
  340. package/dist/lib/injection-engine/index.js.map +1 -1
  341. package/dist/lib/injection-engine/skillGraph.js +35 -41
  342. package/dist/lib/injection-engine/skillGraph.js.map +1 -1
  343. package/dist/lib/injection-engine/types.js.map +1 -1
  344. package/dist/memory/define.types.js +1 -1
  345. package/dist/types/core/agent/buildAgentChart.d.ts.map +1 -1
  346. package/dist/types/core/agent/buildDynamicAgentChart.d.ts.map +1 -1
  347. package/dist/types/core/agent/stages/pickEntry.d.ts.map +1 -1
  348. package/dist/types/core/agent/types.d.ts +8 -4
  349. package/dist/types/core/agent/types.d.ts.map +1 -1
  350. package/dist/types/index.d.ts +1 -1
  351. package/dist/types/index.d.ts.map +1 -1
  352. package/dist/types/lib/context-bisect/index.d.ts +3 -0
  353. package/dist/types/lib/context-bisect/index.d.ts.map +1 -1
  354. package/dist/types/lib/context-bisect/localize.d.ts +2 -0
  355. package/dist/types/lib/context-bisect/localize.d.ts.map +1 -1
  356. package/dist/types/lib/injection-engine/buildInjectionEngineSubflow.d.ts.map +1 -1
  357. package/dist/types/lib/injection-engine/entryScorer.d.ts +94 -0
  358. package/dist/types/lib/injection-engine/entryScorer.d.ts.map +1 -0
  359. package/dist/types/lib/injection-engine/index.d.ts +1 -0
  360. package/dist/types/lib/injection-engine/index.d.ts.map +1 -1
  361. package/dist/types/lib/injection-engine/skillGraph.d.ts +21 -24
  362. package/dist/types/lib/injection-engine/skillGraph.d.ts.map +1 -1
  363. package/dist/types/lib/injection-engine/types.d.ts +9 -4
  364. package/dist/types/lib/injection-engine/types.d.ts.map +1 -1
  365. package/dist/types/memory/define.types.d.ts +1 -1
  366. package/package.json +203 -56
@@ -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;
@@ -0,0 +1,105 @@
1
+ /**
2
+ * Commentary templates — bundled English prose for narrating an
3
+ * agentfootprint run, plus the small engine that picks the right
4
+ * template per event and substitutes payload values.
5
+ *
6
+ * Audience split (load-bearing):
7
+ * • COMMENTARY — pure prose for the bottom panel of any viewer
8
+ * (Lens, CLI tail, log file). NO technical numbers,
9
+ * NO field dumps, NO library terms.
10
+ * • DETAILS — token counts, durations, args, IDs. The right
11
+ * panel / DevTools / structured-log territory.
12
+ *
13
+ * Architecture (3 pieces):
14
+ * 1. `defaultCommentaryTemplates` — flat `key → string` map.
15
+ * i18n-ready: ship a Spanish/Japanese/etc. version with the same
16
+ * keys, pass via `commentaryTemplates` on the renderer.
17
+ * 2. `selectCommentaryKey(event)` — per-event-type routing fn.
18
+ * Returns `string` (render this key), `null` (skip — too
19
+ * low-signal for prose), or `undefined` (fall through to a
20
+ * caller-supplied default humanizer).
21
+ * 3. `extractCommentaryVars(event, ctx)` — builds the
22
+ * `{ appName, userPrompt, toolName, descClause, ... }` bag the
23
+ * template will be rendered with.
24
+ *
25
+ * Plus a tiny non-recursive `renderCommentary(template, vars)`.
26
+ *
27
+ * Why this lives in agentfootprint (not Lens):
28
+ * The keys ARE agentfootprint event types. The prose teaches
29
+ * agentfootprint concepts (slot composition, ReAct, tool-calling).
30
+ * Consumers building agentfootprint Agents ship their voice / locale
31
+ * alongside their system prompt and tool registry. Lens (or any
32
+ * other viewer) is just a renderer that consumes this surface.
33
+ *
34
+ * Verb discipline (encoded in the prose):
35
+ * • `{{appName}}` (active actor) — called, dispatched, returned,
36
+ * decided, read, built
37
+ * • LLM (passive actor) — suggested, responded, produced,
38
+ * asked for, gave
39
+ * The split reflects the architectural truth: LLMs don't act, the
40
+ * orchestrating system does.
41
+ */
42
+ import type { AgentfootprintEvent } from '../../../events/registry.js';
43
+ /** Flat map of template keys to template strings. Keys use a dotted
44
+ * hierarchy mirroring event types + payload branches
45
+ * (`'stream.llm_start.iter1'`, `'context.injected.rag'`). Values may
46
+ * contain `{{name}}` placeholders that `renderCommentary` substitutes. */
47
+ export type CommentaryTemplates = Readonly<Record<string, string>>;
48
+ /**
49
+ * The bundled English templates. Override per-key via the renderer's
50
+ * `templates` option — partial overrides are spread on top of these
51
+ * defaults so consumers only ship what they want to change.
52
+ */
53
+ export declare const defaultCommentaryTemplates: CommentaryTemplates;
54
+ /** Context the var-extractor reads from. Anything that's NOT in the
55
+ * event payload (consumer-supplied appName, tool registry lookup) goes
56
+ * here. Pure data — no closures, no I/O. */
57
+ export interface CommentaryContext {
58
+ /** The system that orchestrates the LLM. Substituted as the active
59
+ * actor in every line ("Acme called the LLM"). Default: `'Chatbot'`. */
60
+ readonly appName: string;
61
+ /** Resolves a tool name to its registered description ("Get current
62
+ * weather for a city"). Used to compose the optional `descClause`
63
+ * for `stream.tool_start`. Sync — Lens-style consumers precompute
64
+ * the lookup map from `context.injected source='registry'` events. */
65
+ readonly getToolDescription?: (toolName: string) => string | undefined;
66
+ }
67
+ /**
68
+ * Pick the template key for an event. Branches encoded in the key
69
+ * suffix (no conditional logic in the templates themselves).
70
+ *
71
+ * `null` → explicit skip (baseline injections, low-signal events)
72
+ * `undefined` → fall through to caller's default humanizer
73
+ * `string` → render `templates[key]` with `extractCommentaryVars`
74
+ */
75
+ export declare function selectCommentaryKey(event: AgentfootprintEvent): string | null | undefined;
76
+ /**
77
+ * Build the variable bag for a given event. Flat `name → string` map;
78
+ * `renderCommentary` substitutes by name. Templates use whatever names
79
+ * this function produces.
80
+ *
81
+ * Two-step composition for `stream.tool_start`: the optional
82
+ * `descClause` is a rendered sub-template. We pre-render it here so
83
+ * the outer template stays a single non-recursive substitution pass.
84
+ */
85
+ export declare function extractCommentaryVars(event: AgentfootprintEvent, ctx: CommentaryContext, templates?: CommentaryTemplates): Record<string, string>;
86
+ /**
87
+ * Resolve the agent name from an event's `meta.subflowPath`.
88
+ *
89
+ * Walks the path right-to-left, skipping library-internal segments
90
+ * (slot subflows, agent-routing subflows, thinking handlers), and
91
+ * returns the FIRST meaningful segment with the optional `step-`
92
+ * Sequence prefix stripped. For events with no meaningful path
93
+ * (single-Agent runners, top-level events), falls back to `appName`.
94
+ */
95
+ export declare function extractAgentName(event: AgentfootprintEvent, ctx: CommentaryContext): string;
96
+ /**
97
+ * Render a template by substituting `{{name}}` placeholders from the
98
+ * vars bag. Missing keys render as empty string — keeps prose
99
+ * forgiving when an optional field isn't present.
100
+ *
101
+ * Non-recursive: a substituted value is NOT itself processed for
102
+ * placeholders. Compose sub-templates upstream (see
103
+ * `extractCommentaryVars`).
104
+ */
105
+ export declare function renderCommentary(template: string, vars: Record<string, string>): string;
@@ -0,0 +1,25 @@
1
+ /**
2
+ * @internal — not part of the public agentfootprint API. Imported only
3
+ * by RunStepRecorder. Subject to change without notice.
4
+ *
5
+ * ActorArrowClassifier — classifies the next `llm.start` as
6
+ * `'user→llm'` (no pending tool result) vs `'tool→llm'` (after a
7
+ * tool result), and the next `llm.end` as `'llm→tool'` vs `'llm→user'`
8
+ * based on the call's `toolCallCount`.
9
+ *
10
+ * Extracted from RunStepRecorder per Convention 1. Keeps a single
11
+ * boolean of state — `prevLLMEndHadTools` — and consumes-then-resets
12
+ * it on each `llm.start`.
13
+ */
14
+ export type StartArrow = 'user→llm' | 'tool→llm';
15
+ export type EndArrow = 'llm→tool' | 'llm→user';
16
+ export declare class ActorArrowClassifier {
17
+ private prevLLMEndHadTools;
18
+ /** Classify the next `llm.start`. Consumes + resets the pending
19
+ * flag after returning. */
20
+ classifyStart(): StartArrow;
21
+ /** Classify an `llm.end` based on its tool-call count, and update
22
+ * the pending flag for the NEXT llm.start. */
23
+ classifyEnd(toolCallCount: number): EndArrow;
24
+ clear(): void;
25
+ }
@@ -0,0 +1,28 @@
1
+ /**
2
+ * @internal — not part of the public agentfootprint API. Imported only
3
+ * by RunStepRecorder. Subject to change without notice.
4
+ *
5
+ * CandidateAnswerBuffer — buffers a "this leaf MIGHT be the run's
6
+ * answer" candidate that's only confirmed on `onRunEnd`. Replaced
7
+ * by every later leaf exit at run scope; the last one wins.
8
+ *
9
+ * Extracted from RunStepRecorder per Convention 1.
10
+ *
11
+ * Use:
12
+ * - On leaf EXIT at run scope: `set(frame, ts, runtimeStageId)`.
13
+ * - On `onRunEnd`: `flush()` returns the buffered candidate (or
14
+ * undefined if none), and clears the buffer.
15
+ */
16
+ export interface CandidateAnswer<TFrame> {
17
+ readonly frame: TFrame;
18
+ readonly tsMs: number;
19
+ readonly runtimeStageId: string;
20
+ }
21
+ export declare class CandidateAnswerBuffer<TFrame> {
22
+ private candidate;
23
+ /** Buffer a new candidate, replacing any prior one. */
24
+ set(frame: TFrame, tsMs: number, runtimeStageId: string): void;
25
+ /** Return + clear the buffered candidate (or undefined if empty). */
26
+ flush(): CandidateAnswer<TFrame> | undefined;
27
+ clear(): void;
28
+ }