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,546 @@
1
+ /**
2
+ * BoundaryRecorder — unified domain event log for an agentfootprint run.
3
+ *
4
+ * The single source of truth Lens (and any other consumer) reads to
5
+ * render a run. Every observable moment in a run is captured as one
6
+ * `DomainEvent` in a single ordered stream:
7
+ *
8
+ * - `run.entry` / `run.exit` — top-level executor.run()
9
+ * - `subflow.entry` / `subflow.exit` — every subflow boundary
10
+ * - `fork.branch` — one per parallel child
11
+ * - `decision.branch` — chosen branch of a Conditional
12
+ * - `loop.iteration` — one per back-edge traversal
13
+ * - `llm.start` / `llm.end` — LLM provider call lifecycle
14
+ * - `tool.start` / `tool.end` — tool execution lifecycle
15
+ * - `context.injected` — anything injected into a slot
16
+ *
17
+ * All events carry `runtimeStageId` (binds with footprintjs Trace view +
18
+ * with each other), `subflowPath`, `depth`, and `ts` (wall-clock ms).
19
+ * Subflow events are domain-tagged (`slotKind` / `primitiveKind` /
20
+ * `isAgentInternal`) so consumers dispatch on tag without re-parsing.
21
+ *
22
+ * Architecture:
23
+ *
24
+ * ┌──── footprintjs (domain-agnostic) ────┐
25
+ * │ FlowRecorder events (run/subflow/ │ ──┐
26
+ * │ fork/decision/loop) │ │
27
+ * └───────────────────────────────────────┘ │
28
+ * │
29
+ * ┌──── agentfootprint dispatcher ─────────┐ │ consumed by
30
+ * │ Typed events (llm/tool/context) │ ──┤
31
+ * └────────────────────────────────────────┘ │
32
+ * ▼
33
+ * ┌─── BoundaryRecorder ───┐
34
+ * │ one tagged stream of │
35
+ * │ DomainEvent │
36
+ * └────────────────────────┘
37
+ * │
38
+ * ▼ consumed by
39
+ * ┌────── Lens (UI) ──────┐
40
+ * │ Slider / RunFlow / │
41
+ * │ NodeDetail / etc. │
42
+ * └───────────────────────┘
43
+ *
44
+ * Why ONE recorder: Lens scrub axis, run-flow graph, slot rows inside
45
+ * the LLM card, right-pane detail panel, commentary panel — every UI
46
+ * surface reads from the SAME stream. Adding a new domain event = one
47
+ * tagged emit + one render shape. No state machines spread across
48
+ * renderers, no merging of multiple sources, no name-based filter lists.
49
+ *
50
+ * Naming: `runtimeStageId` is footprintjs's primitive (path-prefixed +
51
+ * `#executionIndex`). `subflowPath` is rooted under the synthetic
52
+ * `'__root__'`. `slotKind` / `primitiveKind` are agent-domain. The
53
+ * design follows the React Fiber + OpenTelemetry pattern:
54
+ * **producers self-describe; consumers dispatch on type**.
55
+ *
56
+ * @example
57
+ * ```typescript
58
+ * import { boundaryRecorder, EventDispatcher } from 'agentfootprint';
59
+ *
60
+ * const boundary = boundaryRecorder();
61
+ * const dispatcher = new EventDispatcher();
62
+ * executor.attachCombinedRecorder(boundary); // wires FlowRecorder side
63
+ * boundary.subscribe(dispatcher); // wires typed-event side
64
+ *
65
+ * await executor.run({ input });
66
+ *
67
+ * for (const e of boundary.getEvents()) {
68
+ * switch (e.type) {
69
+ * case 'run.entry': renderRoot(e); break;
70
+ * case 'subflow.entry': if (e.slotKind) renderSlotRow(e);
71
+ * else if (e.primitiveKind) renderPrimitive(e);
72
+ * break;
73
+ * case 'llm.start': renderLLMCall(e); break;
74
+ * // ...
75
+ * }
76
+ * }
77
+ * ```
78
+ */
79
+ import { CommitRangeIndex } from 'footprintjs/trace';
80
+ import type { CombinedRecorder, FlowDecisionEvent, FlowForkEvent, FlowLoopEvent, FlowSubflowEvent, TraversalContext } from 'footprintjs';
81
+ interface FlowRunEvent {
82
+ readonly payload?: unknown;
83
+ readonly traversalContext?: TraversalContext;
84
+ }
85
+ interface FlowRunFailedEvent {
86
+ readonly structuredError: {
87
+ readonly message: string;
88
+ };
89
+ readonly traversalContext?: TraversalContext;
90
+ }
91
+ import type { EventDispatcher, Unsubscribe } from '../../events/dispatcher.js';
92
+ import type { ContextSlot } from '../../events/types.js';
93
+ /** Fields every domain event carries. */
94
+ interface DomainEventBase {
95
+ /** Stable per-execution key (footprintjs primitive). For run events it
96
+ * is `'__root__#0'`; subflow events use the parent stage's runtimeStageId
97
+ * at mount; typed events use the firing stage's runtimeStageId. */
98
+ readonly runtimeStageId: string;
99
+ /** Decomposition of `subflowId` into segments, rooted under `'__root__'`. */
100
+ readonly subflowPath: readonly string[];
101
+ /** Depth in the run tree — root = 0, top-level subflow = 1, etc. */
102
+ readonly depth: number;
103
+ /** Wall-clock ms at capture time. */
104
+ readonly ts: number;
105
+ /** Commit count when this event fired. 0 if the recorder was
106
+ * constructed without `getCommitCount` (legacy mode). The boundary
107
+ * RANGE for an (entry, exit) pair is `[entry.commitIdxBefore,
108
+ * exit.commitIdxBefore]`. Phase 5 Layer 2 — see
109
+ * `docs/design/boundary-commit-ranges.md`. */
110
+ readonly commitIdxBefore: number;
111
+ /** RESERVED for future event types that trigger engine writes.
112
+ * CURRENT BEHAVIOR: always equals `commitIdxBefore` for every event
113
+ * emitted by today's BoundaryRecorder. Observer events don't write
114
+ * to scope, so the executor's commit count doesn't change between
115
+ * the moment the event is sampled and the moment it's recorded.
116
+ * Consumers should currently treat this as identical to
117
+ * `commitIdxBefore`; do NOT rely on it being strictly greater.
118
+ * The field exists for forward compatibility — if a future
119
+ * observer pattern triggers commits during its handler, this is
120
+ * where the post-effect count will land. */
121
+ readonly commitIdxAfter: number;
122
+ }
123
+ export interface DomainRunEvent extends DomainEventBase {
124
+ readonly type: 'run.entry' | 'run.exit';
125
+ readonly payload?: unknown;
126
+ /** Always `true` for run events — convenience flag for filter callers. */
127
+ readonly isRoot: true;
128
+ }
129
+ export interface DomainSubflowEvent extends DomainEventBase {
130
+ readonly type: 'subflow.entry' | 'subflow.exit';
131
+ /** Path-prefixed engine id (matches `FlowSubflowEvent.subflowId`). */
132
+ readonly subflowId: string;
133
+ /** Last segment of `subflowId` — convenience for leaf-name grouping. */
134
+ readonly localSubflowId: string;
135
+ readonly subflowName: string;
136
+ /** Build-time description from the subflow root (`'<Kind>: <detail>'`). */
137
+ readonly description?: string;
138
+ /** Parsed `'<Kind>:'` prefix — `'Agent'`, `'LLMCall'`, `'Sequence'`, etc. */
139
+ readonly primitiveKind?: string;
140
+ /** Set ONLY for the 3 input-slot subflows (sf-system-prompt / sf-messages / sf-tools). */
141
+ readonly slotKind?: ContextSlot;
142
+ /** True for Agent state-machine routing/wrapper subflows (route, tool-calls, final, merge). */
143
+ readonly isAgentInternal: boolean;
144
+ /** `inputMapper` result on entry; subflow shared state on exit. */
145
+ readonly payload?: unknown;
146
+ }
147
+ export interface DomainForkBranchEvent extends DomainEventBase {
148
+ readonly type: 'fork.branch';
149
+ readonly parentSubflowId: string;
150
+ readonly childName: string;
151
+ }
152
+ export interface DomainDecisionBranchEvent extends DomainEventBase {
153
+ readonly type: 'decision.branch';
154
+ readonly decider: string;
155
+ readonly chosen: string;
156
+ readonly rationale?: string;
157
+ /**
158
+ * `true` when this decision comes from one of the Agent's internal
159
+ * routing stages (e.g., the ReAct `Route` decider that picks
160
+ * `tool-calls` vs `final`). Filtered out of the timeline by
161
+ * `buildStepGraph` — the actor arrows that follow already encode
162
+ * the routing observably (`llm→tool` vs `llm→user`).
163
+ *
164
+ * `false` when the decision comes from a consumer-defined
165
+ * `Conditional` primitive — those ARE meaningful timeline steps.
166
+ */
167
+ readonly isAgentInternal: boolean;
168
+ }
169
+ export interface DomainLoopIterationEvent extends DomainEventBase {
170
+ readonly type: 'loop.iteration';
171
+ readonly target: string;
172
+ readonly iteration: number;
173
+ }
174
+ /**
175
+ * Composition boundary event — fired for every composition primitive
176
+ * (Parallel / Sequence / Loop / Conditional). Mirrors `subflow.entry/exit`
177
+ * but for the COMPOSITION wrapper itself (the box that contains the
178
+ * branches / steps / iterations / chosen-branch).
179
+ *
180
+ * This pair OPENS and CLOSES a boundary range in `boundaryIndex`. Child
181
+ * subflows that fire between the pair nest naturally inside the
182
+ * composition's range.
183
+ *
184
+ * The `runtimeStageId` is the composition's own per-execution id —
185
+ * SAME format as any other runtimeStageId, with `#executionIndex`. The
186
+ * `kind` discriminates which composition primitive this is.
187
+ *
188
+ * For the Lens compound time axis, this group is what collapses
189
+ * parallel branches into ONE slider position at the parent's drill
190
+ * level. Drill into the composition to see its children as positions.
191
+ */
192
+ export interface DomainCompositionEvent extends DomainEventBase {
193
+ readonly type: 'composition.start' | 'composition.end';
194
+ readonly kind: 'Parallel' | 'Sequence' | 'Loop' | 'Conditional';
195
+ readonly compositionId: string;
196
+ readonly name: string;
197
+ /** On `composition.end`, the exit status reported by the composition. */
198
+ readonly status?: 'ok' | 'err' | 'break' | 'budget_exhausted';
199
+ readonly durationMs?: number;
200
+ }
201
+ /**
202
+ * The 4 actor arrows of a ReAct cycle. Tagged on `llm.start` / `llm.end`
203
+ * at capture time so consumers (slider, run-flow renderer) dispatch by
204
+ * `event.actorArrow` instead of running their own state machine.
205
+ *
206
+ * - `'user→llm'` — first LLM call, or any LLM call NOT preceded by a
207
+ * tool result (assembled-context delivery to the model).
208
+ * - `'tool→llm'` — LLM call that follows a tool's result (the next
209
+ * iteration of a ReAct loop).
210
+ * - `'llm→tool'` — `llm.end` whose `toolCallCount > 0` (the LLM is
211
+ * requesting tool execution).
212
+ * - `'llm→user'` — `llm.end` with `toolCallCount === 0` (terminal
213
+ * response delivered to the user).
214
+ */
215
+ export type ActorArrow = 'user→llm' | 'tool→llm' | 'llm→tool' | 'llm→user';
216
+ export interface DomainLLMStartEvent extends DomainEventBase {
217
+ readonly type: 'llm.start';
218
+ readonly model: string;
219
+ readonly provider: string;
220
+ readonly systemPromptChars?: number;
221
+ readonly messagesCount?: number;
222
+ readonly toolsCount?: number;
223
+ /** Capture-time classification: `'user→llm'` for the first call or any
224
+ * call not preceded by a tool result; `'tool→llm'` after a tool result. */
225
+ readonly actorArrow: 'user→llm' | 'tool→llm';
226
+ }
227
+ export interface DomainLLMEndEvent extends DomainEventBase {
228
+ readonly type: 'llm.end';
229
+ readonly content: string;
230
+ readonly toolCallCount: number;
231
+ readonly usage: {
232
+ readonly input: number;
233
+ readonly output: number;
234
+ };
235
+ readonly stopReason?: string;
236
+ /** Capture-time classification: `'llm→tool'` when the LLM requested
237
+ * tools (`toolCallCount > 0`); `'llm→user'` for terminal delivery. */
238
+ readonly actorArrow: 'llm→tool' | 'llm→user';
239
+ }
240
+ export interface DomainToolStartEvent extends DomainEventBase {
241
+ readonly type: 'tool.start';
242
+ readonly toolName: string;
243
+ readonly toolCallId: string;
244
+ readonly args?: unknown;
245
+ }
246
+ export interface DomainToolEndEvent extends DomainEventBase {
247
+ readonly type: 'tool.end';
248
+ readonly toolCallId: string;
249
+ readonly result?: unknown;
250
+ readonly durationMs?: number;
251
+ readonly error?: boolean;
252
+ }
253
+ export interface DomainContextInjectedEvent extends DomainEventBase {
254
+ readonly type: 'context.injected';
255
+ readonly slot: ContextSlot;
256
+ readonly source: string;
257
+ readonly sourceId?: string;
258
+ readonly asRole?: 'system' | 'user' | 'assistant' | 'tool';
259
+ readonly contentSummary?: string;
260
+ readonly reason?: string;
261
+ readonly sectionTag?: string;
262
+ readonly upstreamRef?: string;
263
+ readonly retrievalScore?: number;
264
+ readonly rankPosition?: number;
265
+ /** Tokens consumed by this injection (from `budgetSpent.tokens`). */
266
+ readonly budgetTokens?: number;
267
+ /** Fraction of slot cap consumed (from `budgetSpent.fractionOfCap`). */
268
+ readonly budgetFraction?: number;
269
+ }
270
+ /** Discriminated union covering every observable moment in a run. */
271
+ export type DomainEvent = DomainRunEvent | DomainSubflowEvent | DomainCompositionEvent | DomainForkBranchEvent | DomainDecisionBranchEvent | DomainLoopIterationEvent | DomainLLMStartEvent | DomainLLMEndEvent | DomainToolStartEvent | DomainToolEndEvent | DomainContextInjectedEvent;
272
+ /**
273
+ * Per-boundary rollup returned by
274
+ * `BoundaryRecorder.aggregateForBoundary` and
275
+ * `BoundaryRecorder.aggregateAllBoundaries`. Same shape regardless of
276
+ * primitive kind — UIs render the same chip set for every Agent /
277
+ * LLMCall / Sequence / Parallel / Conditional / Loop.
278
+ *
279
+ * Events count toward this rollup when their `subflowPath` is a
280
+ * prefix-match of the boundary's `subflowPath`. Nested boundaries
281
+ * (e.g., LLMCall inside an Agent) contribute to BOTH rollups.
282
+ *
283
+ * In-flight boundaries (no `subflow.exit` yet) get partial values;
284
+ * `endedAtMs` and `durationMs` are undefined until close.
285
+ */
286
+ export interface BoundaryAggregate {
287
+ readonly runtimeStageId: string;
288
+ readonly subflowId: string;
289
+ readonly subflowPath: readonly string[];
290
+ /** `'Agent'` / `'LLMCall'` / `'Sequence'` / `'Parallel'` /
291
+ * `'Conditional'` / `'Loop'`. Always set on rollups returned by
292
+ * `aggregateAllBoundaries` (which filters to primitive boundaries).
293
+ * Optional on `aggregateForBoundary` results because the caller may
294
+ * request rollup for a non-primitive subflow (rare). */
295
+ readonly primitiveKind?: string;
296
+ /** Subflow display name (e.g., 'Triage', 'Billing'). */
297
+ readonly label: string;
298
+ /** Token usage summed across every `llm.end` inside this boundary. */
299
+ readonly tokens: {
300
+ readonly input: number;
301
+ readonly output: number;
302
+ };
303
+ /** Count of `llm.start` events inside this boundary. */
304
+ readonly llmCalls: number;
305
+ /** Count of `tool.start` events inside this boundary. */
306
+ readonly toolCalls: number;
307
+ /** Count of `agent.iteration_start` events scoped to this boundary —
308
+ * ReAct-loop iterations. Always `0` for non-Agent primitives. */
309
+ readonly iterations: number;
310
+ /** Wall-clock ms of `subflow.entry`. */
311
+ readonly startedAtMs: number;
312
+ /** Wall-clock ms of `subflow.exit`. Undefined while in flight. */
313
+ readonly endedAtMs?: number;
314
+ /** `endedAtMs - startedAtMs`. Undefined while in flight. */
315
+ readonly durationMs?: number;
316
+ }
317
+ export interface BoundaryRecorderOptions {
318
+ readonly id?: string;
319
+ /**
320
+ * Live commit-count accessor — typically `() => executor.getCommitCount()`
321
+ * from footprintjs 5.1+. Inject from your runner. When provided:
322
+ * - Every DomainEvent gains `commitIdxBefore` / `commitIdxAfter`.
323
+ * - `recorder.boundaryIndex` is populated with open/close ranges
324
+ * keyed on each subflow's entry event.
325
+ * When omitted (legacy / pre-5.1 footprintjs): both fields are 0 on
326
+ * every event; `boundaryIndex` exists but is empty. Phase 5 Layer 2.
327
+ */
328
+ readonly getCommitCount?: () => number;
329
+ }
330
+ /**
331
+ * Stripped projection used as the LABEL for the commit-range index.
332
+ * Intentionally OMITS `payload` (security panel review YELLOW #1):
333
+ * `boundaryIndex.enclosing()` queries should not bypass redaction by
334
+ * exposing raw scope payloads through the range index. Consumers
335
+ * needing payload can join on `runtimeStageId` with the full event
336
+ * stream via `getEvents()` (which IS subject to redaction policy).
337
+ */
338
+ export interface BoundaryRangeLabel {
339
+ readonly type: 'subflow.entry' | 'run.entry' | 'composition.start';
340
+ readonly runtimeStageId: string;
341
+ readonly subflowPath: readonly string[];
342
+ readonly depth: number;
343
+ readonly ts: number;
344
+ /** Set on subflow entries; undefined on the synthetic run-root entry. */
345
+ readonly subflowId?: string;
346
+ readonly localSubflowId?: string;
347
+ readonly subflowName?: string;
348
+ readonly description?: string;
349
+ readonly primitiveKind?: string;
350
+ readonly slotKind?: ContextSlot;
351
+ readonly isAgentInternal?: boolean;
352
+ /** Composition primitive (Parallel/Sequence/Loop/Conditional) when the
353
+ * range was opened by a `composition.start` event. */
354
+ readonly compositionKind?: 'Parallel' | 'Sequence' | 'Loop' | 'Conditional';
355
+ readonly compositionName?: string;
356
+ }
357
+ /** Factory — matches the `inOutRecorder()` / `topologyRecorder()` style. */
358
+ export declare function boundaryRecorder(options?: BoundaryRecorderOptions): BoundaryRecorder;
359
+ /**
360
+ * Unified domain event recorder. Implements `CombinedRecorder` so it can
361
+ * attach to the executor's FlowRecorder channel; exposes `subscribe()`
362
+ * to wire to the agentfootprint typed-event dispatcher.
363
+ *
364
+ * v5: composes a `SequenceStore<DomainEvent>` (storage) instead of
365
+ * extending the deprecated `SequenceStore<T>` base. Time-travel
366
+ * utilities (`getEntryRanges`, `accumulate`) are accessed through the
367
+ * store via the public read API on this class.
368
+ */
369
+ export declare class BoundaryRecorder implements CombinedRecorder {
370
+ readonly id: string;
371
+ /** Composition: storage shelf. */
372
+ private readonly store;
373
+ /**
374
+ * Phase 5 Layer 2 — interval index over commit indices, populated
375
+ * live as boundary entry/exit pairs fire. Consumers (Lens) read
376
+ * `enclosing(commitIdx)` for breadcrumbs and `overlapping(slice)`
377
+ * for time-range queries. Empty when `getCommitCount` is not
378
+ * injected. See `docs/design/boundary-commit-ranges.md`.
379
+ */
380
+ readonly boundaryIndex: CommitRangeIndex<BoundaryRangeLabel>;
381
+ /** Open-range tokens keyed by `runtimeStageId` so the matching exit
382
+ * can close the correct range. Pure side-table; cleared on runId
383
+ * reset. Not exposed externally. */
384
+ private readonly openTokens;
385
+ /** Live commit-count accessor injected by the runner. Sanitized
386
+ * (NaN/Infinity/negative → 0) before use. */
387
+ private readonly getCommitCount;
388
+ /** True when `getCommitCount` was explicitly injected. In LEGACY
389
+ * MODE (false), `boundaryIndex` is intentionally NOT populated —
390
+ * zero-width [0,0] ranges would mislead consumers querying the
391
+ * index. Multi-panel review flagged this footgun. */
392
+ private readonly hasCommitTracking;
393
+ /**
394
+ * Tracks whether the most recent `llm.end` had toolCalls. Used to
395
+ * classify the NEXT `llm.start` as `'tool→llm'` (vs `'user→llm'` if
396
+ * there's no pending tool result). Reset on `clear()` and on every
397
+ * `llm.start` event after the classification is applied.
398
+ */
399
+ private prevLLMEndHadTools;
400
+ /**
401
+ * Run-boundary observer — fires resetForNewRun() when
402
+ * traversalContext.runId changes between events AND no boundary is
403
+ * currently open. The "no open boundary" gate distinguishes:
404
+ *
405
+ * - **Legitimate new run** — consumer reuses one recorder across
406
+ * sequential `executor.run()` calls. All prior boundaries closed
407
+ * before the second run began; openTokens is empty when the new
408
+ * runId arrives → safe to wipe state so the second run doesn't
409
+ * alias with the first.
410
+ * - **Composition sub-run** — primitives like `LLMCall`, `Sequence`,
411
+ * and `Parallel` internally spawn their own `FlowChartExecutor`
412
+ * instances. Each sub-executor mints a NEW runId. When that
413
+ * sub-executor fires events on the SHARED recorder, the recorder
414
+ * is still inside the parent run — `openTokens` is non-empty.
415
+ * Resetting here would wipe the parent's boundary index mid-run
416
+ * (the bug Layer 4 surfaced in agentfootprint-lens fanout).
417
+ *
418
+ * The `openTokens.size === 0` check is the cleanest semantic signal:
419
+ * if nothing is in-flight, a runId change means "the consumer started
420
+ * fresh"; if something is open, the new runId is from a sub-executor
421
+ * nested inside the still-ongoing parent.
422
+ */
423
+ private readonly runIdGuard;
424
+ constructor(options?: BoundaryRecorderOptions);
425
+ /**
426
+ * Reset all transient state.
427
+ *
428
+ * **Composition-safe gate (Phase 5 Layer 4):** if `openTokens.size > 0`
429
+ * the call is a no-op. Rationale: `FlowChartExecutor.run()` calls
430
+ * `r.clear?.()` on every attached recorder during its pre-run loop.
431
+ * When agentfootprint composition primitives (LLMCall, Sequence,
432
+ * Parallel, etc.) propagate the parent's recorders to nested
433
+ * sub-executors, EACH sub-executor's pre-run clear loop calls
434
+ * `clear()` on the SHARED parent recorder mid-run — wiping live
435
+ * parent state. The `openTokens.size > 0` check distinguishes:
436
+ *
437
+ * - **Legitimate reset** — consumer or executor calls `clear()`
438
+ * when no boundary is in-flight (`openTokens` empty). Safe to
439
+ * wipe; the recorder is idle.
440
+ * - **Composition wipe** — sub-executor's pre-run clear fires
441
+ * while the parent has open boundaries (`openTokens` non-empty).
442
+ * Skip the wipe; the parent's state must be preserved.
443
+ *
444
+ * If a consumer needs to forcibly wipe state even with open tokens
445
+ * (e.g., manual recovery after a crashed run), pair `clear()` with
446
+ * an explicit `forceClear()` (TODO — add when the use case shows up;
447
+ * today the recorder lifecycle pattern is "one recorder per logical
448
+ * run" so leaked tokens shouldn't occur).
449
+ */
450
+ clear(): void;
451
+ private observeRunId;
452
+ onRunStart(event: FlowRunEvent): void;
453
+ onRunEnd(event: FlowRunEvent): void;
454
+ onRunFailed(event: FlowRunFailedEvent): void;
455
+ onSubflowEntry(event: FlowSubflowEvent): void;
456
+ onSubflowExit(event: FlowSubflowEvent): void;
457
+ onFork(event: FlowForkEvent): void;
458
+ onDecision(event: FlowDecisionEvent): void;
459
+ onLoop(event: FlowLoopEvent): void;
460
+ /**
461
+ * Subscribe to the runner's typed-event dispatcher and emit a domain
462
+ * event for each `llm.*` / `tool.*` / `context.injected` event.
463
+ *
464
+ * Returns an unsubscribe function; safe to call multiple times (each
465
+ * call adds a new subscription). Most consumers call this once at
466
+ * recorder construction and dispose with the returned function.
467
+ */
468
+ subscribe(dispatcher: EventDispatcher): Unsubscribe;
469
+ private ingestTypedEvent;
470
+ /** All events in capture order (the canonical projection). */
471
+ getEvents(): DomainEvent[];
472
+ /** Type-narrowed lookup: all events of one kind. */
473
+ getEventsByType<T extends DomainEvent['type']>(type: T): Extract<DomainEvent, {
474
+ type: T;
475
+ }>[];
476
+ /** All boundary events (run + subflow, entry + exit interleaved). */
477
+ getBoundaries(): (DomainRunEvent | DomainSubflowEvent)[];
478
+ /** Just the entry-phase boundary events — the "step list" timeline. */
479
+ getSteps(): (DomainRunEvent | DomainSubflowEvent)[];
480
+ /** Subset of `getSteps()` excluding agent-internal routing subflows. */
481
+ getVisibleSteps(): (DomainRunEvent | DomainSubflowEvent)[];
482
+ /** Entry/exit pair for one chart execution by `runtimeStageId`. */
483
+ getBoundary(runtimeStageId: string): {
484
+ entry?: DomainRunEvent | DomainSubflowEvent;
485
+ exit?: DomainRunEvent | DomainSubflowEvent;
486
+ };
487
+ /** Convenience for the outermost `__root__` pair. */
488
+ getRootBoundary(): {
489
+ entry?: DomainRunEvent;
490
+ exit?: DomainRunEvent;
491
+ };
492
+ /** Subflow events grouped by the 3 input slots — for slot-row rendering. */
493
+ getSlotBoundaries(): {
494
+ systemPrompt: DomainSubflowEvent[];
495
+ messages: DomainSubflowEvent[];
496
+ tools: DomainSubflowEvent[];
497
+ };
498
+ /**
499
+ * Roll up the event stream for ONE primitive boundary (Agent /
500
+ * LLMCall / Sequence / Parallel / Conditional / Loop) into per-
501
+ * boundary totals — tokens, llm calls, tool calls, iterations,
502
+ * cache hits, duration.
503
+ *
504
+ * Pure projection over `getEvents()`. Events are attributed to a
505
+ * boundary when their `subflowPath` is a **prefix-match** of the
506
+ * boundary's path — so a nested `LLMCall` inside an `Agent` rolls
507
+ * up into BOTH (LLMCall total + Agent total).
508
+ *
509
+ * Works mid-run (the boundary's `subflow.exit` may not have fired
510
+ * yet — `endedAtMs` / `durationMs` are undefined in that case).
511
+ * Works post-run.
512
+ *
513
+ * Multi-consumer story: this is the single source of rollup truth
514
+ * for Lens, CLI live monitors, Sentry breadcrumbs, OTel exporters,
515
+ * dashboards. Domain math (what counts as an "iteration"? does
516
+ * cache hit count separately from llmCalls?) lives HERE — every
517
+ * consumer hooks up; nobody re-implements.
518
+ *
519
+ * @param runtimeStageId The boundary's runtimeStageId (the same id
520
+ * carried by `StepNode.runtimeStageId` for primitive subflows).
521
+ * @returns The rollup, or `undefined` if no `subflow.entry` event
522
+ * matches `runtimeStageId`.
523
+ */
524
+ aggregateForBoundary(runtimeStageId: string): BoundaryAggregate | undefined;
525
+ /**
526
+ * Roll up every primitive boundary in the run into one rollup each,
527
+ * in the order their `subflow.entry` events fired. Top-level multi-
528
+ * agent UIs call this once per render to populate per-agent chips.
529
+ *
530
+ * Filters to `primitiveKind`-tagged subflows ONLY (Agent / LLMCall /
531
+ * Sequence / Parallel / Conditional / Loop). Slot subflows
532
+ * (`sf-system-prompt` / `sf-messages` / `sf-tools`) are NOT
533
+ * boundaries in this sense — they're context-engineering machinery,
534
+ * not user-facing rollup units.
535
+ */
536
+ aggregateAllBoundaries(): readonly BoundaryAggregate[];
537
+ /** Snapshot bundle — included in `executor.getSnapshot()` if the
538
+ * executor implements the snapshot extension protocol. */
539
+ toSnapshot(): {
540
+ name: string;
541
+ description: string;
542
+ preferredOperation: "translate";
543
+ data: DomainEvent[];
544
+ };
545
+ }
546
+ export {};