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,56 @@
1
+ /**
2
+ * llmExtractor — LLM-backed beat extractor.
3
+ *
4
+ * Uses an LLMProvider (typically a cheap model like Claude Haiku or
5
+ * GPT-4o-mini) to produce semantically rich beats. One extraction LLM
6
+ * call per turn. Opt-in — default is `heuristicExtractor()` which is
7
+ * free.
8
+ *
9
+ * The extractor asks the LLM for a JSON response in this shape:
10
+ *
11
+ * ```json
12
+ * {
13
+ * "beats": [
14
+ * {
15
+ * "summary": "User revealed their name is Alice",
16
+ * "importance": 0.9,
17
+ * "refs": ["msg-1-0"],
18
+ * "category": "identity"
19
+ * }
20
+ * ]
21
+ * }
22
+ * ```
23
+ *
24
+ * The extractor parses, clamps importance via `asImportance()`, and
25
+ * returns the beats. Malformed responses fall back to an empty array
26
+ * — a bad extraction should not break the agent turn.
27
+ *
28
+ * Usage:
29
+ * ```ts
30
+ * import { anthropic } from 'agentfootprint';
31
+ * import { llmExtractor, narrativePipeline, InMemoryStore } from 'agentfootprint/memory';
32
+ *
33
+ * const pipeline = narrativePipeline({
34
+ * store: new InMemoryStore(),
35
+ * extractor: llmExtractor({ provider: yourLLMProvider }),
36
+ * });
37
+ * ```
38
+ */
39
+ import type { LLMProvider } from '../../adapters/types.js';
40
+ import type { BeatExtractor } from './extractor.js';
41
+ export interface LLMExtractorConfig {
42
+ /** The provider used for extraction. Typically a cheap/fast model. */
43
+ readonly provider: LLMProvider;
44
+ /**
45
+ * Override the system prompt. Defaults to a one-paragraph instruction
46
+ * that elicits the JSON shape described in the module docs.
47
+ */
48
+ readonly systemPrompt?: string;
49
+ /**
50
+ * Dev-mode logger invoked when the LLM response fails to parse.
51
+ * Defaults to `console.warn` — production consumers can route the
52
+ * signal to their telemetry pipeline.
53
+ */
54
+ readonly onParseError?: (error: unknown, rawContent: string) => void;
55
+ }
56
+ export declare function llmExtractor(config: LLMExtractorConfig): BeatExtractor;
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Narrative beats — the unit of narrative memory.
3
+ *
4
+ * A `NarrativeBeat` is a self-contained summary extracted from one or
5
+ * more messages during a turn. Instead of persisting raw conversation
6
+ * forever, a narrative pipeline compresses each turn into beats and
7
+ * recalls them by composing beats back into a coherent story.
8
+ *
9
+ * Core properties:
10
+ * - **Summary**: a single sentence describing what happened.
11
+ * - **Importance**: 0..1 score the picker uses to prefer salient
12
+ * beats when the context-token budget is tight.
13
+ * - **Refs**: ids of the source messages the beat was extracted
14
+ * from. Lets consumers walk backwards from a recalled beat to
15
+ * the raw source — the explainability story.
16
+ * - **Category**: optional free-form tag (e.g. `"identity"`,
17
+ * `"preference"`, `"fact"`). Extractors / consumers pick their
18
+ * own taxonomy.
19
+ *
20
+ * Beats are persisted via the ordinary `MemoryStore` interface —
21
+ * `MemoryEntry<NarrativeBeat>` slots in unchanged. No storage changes
22
+ * needed to support narrative memory.
23
+ */
24
+ /** Importance score in the half-open range [0, 1]. */
25
+ export type BeatImportance = number;
26
+ export interface NarrativeBeat {
27
+ /** One-sentence summary of what happened in this beat. */
28
+ readonly summary: string;
29
+ /**
30
+ * Importance score in [0, 1]. Picker stages use this to prefer
31
+ * salient beats when the budget is tight. Default 0.5 (neutral).
32
+ * Values outside [0, 1] are clamped by `asImportance()`.
33
+ */
34
+ readonly importance: BeatImportance;
35
+ /**
36
+ * Ids of the source messages this beat was extracted from. Consumers
37
+ * answer "why does the agent remember X?" by walking refs backwards
38
+ * to the raw message text. May be empty for synthesized beats
39
+ * (e.g., beats produced from prior beats during compaction).
40
+ */
41
+ readonly refs: readonly string[];
42
+ /**
43
+ * Optional free-form category — `"identity"`, `"preference"`,
44
+ * `"task-status"`, etc. Extractors / consumers pick their own
45
+ * taxonomy. Useful for filtering recalls by type.
46
+ */
47
+ readonly category?: string;
48
+ }
49
+ /**
50
+ * Clamp a value to the valid [0, 1] importance range. Non-finite
51
+ * inputs collapse to 0.5 (neutral) so extractors that produce NaN
52
+ * / ±Infinity don't poison the picker's comparisons.
53
+ */
54
+ export declare function asImportance(value: unknown): BeatImportance;
55
+ /**
56
+ * Duck-typed guard — true iff `value` has the shape of a
57
+ * `NarrativeBeat`. Used by pipelines that handle mixed-payload stores
58
+ * (raw messages + beats) to route entries correctly.
59
+ */
60
+ export declare function isNarrativeBeat(value: unknown): value is NarrativeBeat;
@@ -0,0 +1,22 @@
1
+ /**
2
+ * writeBeats — persist extracted beats to the memory store.
3
+ *
4
+ * Reads from scope: `newBeats`, `identity`
5
+ * Writes to store: one MemoryEntry<NarrativeBeat> per beat via `putMany`
6
+ *
7
+ * Parallels `writeMessages` — same shape, but the payload is beats
8
+ * rather than raw messages. Uses `store.putMany` so N beats from a
9
+ * single turn become 1 round-trip on network-backed adapters
10
+ * (Redis / DynamoDB / Postgres).
11
+ */
12
+ import type { TypedScope } from 'footprintjs';
13
+ import type { MemoryStore } from '../store/index.js';
14
+ import type { ExtractBeatsState } from './extractBeats.js';
15
+ export interface WriteBeatsConfig {
16
+ /** The store to persist to. Typically the same store as the pipeline's read side. */
17
+ readonly store: MemoryStore;
18
+ }
19
+ /**
20
+ * Build the `writeBeats` stage function.
21
+ */
22
+ export declare function writeBeats(config: WriteBeatsConfig): (scope: TypedScope<ExtractBeatsState>) => Promise<void>;
@@ -0,0 +1,66 @@
1
+ /**
2
+ * causalEvidenceRecorder — the evidence bridge (backlog Phase-1 #5).
3
+ *
4
+ * Harvests, DURING the run, everything a causal snapshot needs beyond
5
+ * (query, finalContent) — from events the engine already fires:
6
+ *
7
+ * stream.tool_start/tool_end → ToolCallRecord (name, args, resultPreview, errored)
8
+ * stream.llm_end → tokenUsage accumulation + iteration high-water
9
+ * agent.turn_start/turn_end → durationMs (+ authoritative totals when seen)
10
+ * FlowRecorder.onDecision → DecisionRecord with footprintjs decide()/select()
11
+ * operator-level evidence (rule, conditions, chosen)
12
+ * context.evaluated routing → DecisionRecord per skill the graph routed to
13
+ *
14
+ * Pattern: CombinedRecorder (Convention 1 — single purpose: evidence
15
+ * accumulation); per-turn reset anchored on `agent.turn_start`
16
+ * (Convention 4 — executor `clear()` resets between runs; same-
17
+ * executor pause/resume PRESERVES pre-pause evidence by design).
18
+ * PII note: tool args/results and decide() evidence persist into snapshots.
19
+ * footprintjs `RedactionPolicy.emitPatterns` redacts the emit channel
20
+ * BEFORE this recorder IF the consumer configures one on the executor
21
+ * — the Agent does NOT configure one by default. Values are bounded
22
+ * (`maxPreviewChars` for results, `maxFieldChars` for args/evidence);
23
+ * treat the snapshot store as PII-bearing and protect it accordingly.
24
+ *
25
+ * The Agent attaches this automatically when a CAUSAL memory is mounted and
26
+ * threads `collect` into the memory write mount (`evidenceSource`) — so
27
+ * `writeSnapshot` persists real evidence instead of zeros.
28
+ */
29
+ import type { FlowDecisionEvent, FlowSelectedEvent } from 'footprintjs';
30
+ import type { DecisionRecord, ToolCallRecord } from './types.js';
31
+ /** What the bridge delivers to `writeSnapshot` for one run. */
32
+ export interface RunEvidence {
33
+ readonly iterations: number;
34
+ readonly decisions: ReadonlyArray<DecisionRecord>;
35
+ readonly toolCalls: ReadonlyArray<ToolCallRecord>;
36
+ readonly durationMs: number;
37
+ readonly tokenUsage: {
38
+ readonly input: number;
39
+ readonly output: number;
40
+ };
41
+ }
42
+ export interface CausalEvidenceRecorderOptions {
43
+ /** Recorder id (default 'causal-evidence'). */
44
+ readonly id?: string;
45
+ /** Max chars kept of each tool result preview. Default 200. */
46
+ readonly maxPreviewChars?: number;
47
+ /** Max serialized chars kept of tool ARGS and decision EVIDENCE (the
48
+ * PII-dense fields). Oversized values are replaced by a truncated
49
+ * preview marker. Default 2000. */
50
+ readonly maxFieldChars?: number;
51
+ }
52
+ export interface CausalEvidenceRecorderHandle {
53
+ readonly id: string;
54
+ /** Snapshot the evidence accumulated for the CURRENT run. */
55
+ collect(): RunEvidence;
56
+ clear(): void;
57
+ onEmit(event: {
58
+ name: string;
59
+ payload: unknown;
60
+ }): void;
61
+ onDecision(event: FlowDecisionEvent): void;
62
+ onSelected(event: FlowSelectedEvent): void;
63
+ }
64
+ /** Build the evidence-harvesting recorder. Attach via `.recorder(rec)` (the
65
+ * Agent does this automatically for CAUSAL memories). */
66
+ export declare function causalEvidenceRecorder(options?: CausalEvidenceRecorderOptions): CausalEvidenceRecorderHandle;
@@ -0,0 +1,6 @@
1
+ export type { SnapshotEntry, DecisionRecord, ToolCallRecord, ProjectedSnapshot, SnapshotMessage, } from './types.js';
2
+ export { DEFAULT_TOOL_RESULT_PREVIEW_LEN } from './types.js';
3
+ export { causalEvidenceRecorder, type CausalEvidenceRecorderHandle, type CausalEvidenceRecorderOptions, type RunEvidence, } from './evidenceRecorder.js';
4
+ export { writeSnapshot, type WriteSnapshotConfig } from './writeSnapshot.js';
5
+ export { loadSnapshot, type LoadSnapshotConfig } from './loadSnapshot.js';
6
+ export { snapshotPipeline, type SnapshotPipelineConfig } from './snapshotPipeline.js';
@@ -0,0 +1,51 @@
1
+ /**
2
+ * loadSnapshot — read-side stage for Causal memory.
3
+ *
4
+ * Embeds the user's current question, searches the store for the most
5
+ * similar past run, projects the snapshot per `SnapshotProjection`,
6
+ * and writes the formatted result to `scope.formatted` so the
7
+ * downstream slot subflow injects it as a system message.
8
+ *
9
+ * Reads from scope: `identity`, `messages` (or `newMessages` fallback)
10
+ * Writes to scope: `formatted` — array of `LLMMessage` to inject
11
+ *
12
+ * Strict-threshold semantics:
13
+ * When `minScore` is set and no past snapshot meets it, returns an
14
+ * empty `formatted`. NO fallback — garbage past context is worse than
15
+ * no context.
16
+ *
17
+ * Empty-query handling:
18
+ * No user message → no embedding → no search → empty result.
19
+ */
20
+ import type { TypedScope } from 'footprintjs';
21
+ import type { MemoryStore } from '../store/index.js';
22
+ import type { Embedder } from '../embedding/index.js';
23
+ import type { MemoryState } from '../stages/index.js';
24
+ import { type SnapshotProjection } from '../define.types.js';
25
+ export interface LoadSnapshotConfig {
26
+ /** Vector-capable store. Must implement `search()`. */
27
+ readonly store: MemoryStore;
28
+ /** Embedder used to vectorize the current query. */
29
+ readonly embedder: Embedder;
30
+ /** Stable id of the embedder — filters cross-model results out. */
31
+ readonly embedderId?: string;
32
+ /** Top-k snapshots to retrieve. Default 1 (most-relevant past run). */
33
+ readonly topK?: number;
34
+ /**
35
+ * Minimum cosine score [-1, 1]. Strict — entries below this are
36
+ * dropped. When no entry meets the threshold, the stage emits no
37
+ * messages (no fallback). Default 0.7.
38
+ */
39
+ readonly minScore?: number;
40
+ /**
41
+ * Slice of the snapshot to project. Default `'decisions'` —
42
+ * decision evidence is the highest-signal field for "why" follow-ups.
43
+ */
44
+ readonly projection?: SnapshotProjection;
45
+ /**
46
+ * Optional override for query extraction. Default: last user
47
+ * message in `scope.messages` (current turn's question).
48
+ */
49
+ readonly queryFrom?: (scope: TypedScope<MemoryState>) => string;
50
+ }
51
+ export declare function loadSnapshot(config: LoadSnapshotConfig): (scope: TypedScope<MemoryState>) => Promise<void>;
@@ -0,0 +1,35 @@
1
+ /**
2
+ * snapshotPipeline — composes `loadSnapshot` + `writeSnapshot` into a
3
+ * `MemoryPipeline` ready to be mounted by `defineMemory({ type: CAUSAL })`.
4
+ *
5
+ * READ : LoadSnapshot — embed query → search → project → format
6
+ * WRITE : WriteSnapshot — embed query → store as MemoryEntry<SnapshotEntry>
7
+ *
8
+ * The pipeline emits the same `agentfootprint.context.injected` event
9
+ * (with `source: 'memory'`) as every other memory flavor, so Lens
10
+ * shows Causal injections as memory chips alongside Episodic /
11
+ * Semantic / Narrative without special UI.
12
+ */
13
+ import type { MemoryStore } from '../store/index.js';
14
+ import type { Embedder } from '../embedding/index.js';
15
+ import type { MemoryPipeline } from '../pipeline/types.js';
16
+ import type { SnapshotProjection } from '../define.types.js';
17
+ export interface SnapshotPipelineConfig {
18
+ /** Vector-capable store for the snapshots. Must implement `search()`. */
19
+ readonly store: MemoryStore;
20
+ /** Embedder used for both write-side indexing and read-side query. */
21
+ readonly embedder: Embedder;
22
+ /** Stable id of the embedder — prevents cross-model similarity pollution. */
23
+ readonly embedderId?: string;
24
+ /** Top-k past snapshots to consider on read. Default 1. */
25
+ readonly topK?: number;
26
+ /** Cosine threshold below which matches are dropped. Default 0.7. */
27
+ readonly minScore?: number;
28
+ /** Slice of the snapshot to inject. Default `'decisions'`. */
29
+ readonly projection?: SnapshotProjection;
30
+ /** Optional TTL for snapshots in ms. Useful for compliance windows. */
31
+ readonly ttlMs?: number;
32
+ /** Optional tier tag for written snapshots. */
33
+ readonly tier?: 'hot' | 'warm' | 'cold';
34
+ }
35
+ export declare function snapshotPipeline(config: SnapshotPipelineConfig): MemoryPipeline;
@@ -0,0 +1,130 @@
1
+ /**
2
+ * Causal memory — types.
3
+ *
4
+ * A `SnapshotEntry` is the value stored in a Causal `MemoryStore`. It
5
+ * captures one agent run's "what happened and why" so future turns can
6
+ * answer follow-up questions ("why did you reject this?") with EXACT
7
+ * past facts instead of LLM reconstruction.
8
+ *
9
+ * Differentiator: footprintjs's `decide()`/`select()` already capture
10
+ * decision evidence as first-class events during traversal — we just
11
+ * persist them. Other libraries can't do this without rebuilding their
12
+ * core to surface decision evidence.
13
+ *
14
+ * Stored as `MemoryEntry<SnapshotEntry>` so the existing store layer
15
+ * (`MemoryStore`, `InMemoryStore`, future Redis/Dynamo/Postgres
16
+ * adapters) handles persistence + identity isolation + TTL + vector
17
+ * search out of the box.
18
+ */
19
+ import type { LLMMessage } from '../../adapters/types.js';
20
+ /**
21
+ * One stored agent run — the unit of causal memory.
22
+ *
23
+ * Field set is INTENTIONALLY MINIMAL for now: enough to demonstrate
24
+ * cross-run replay + cover RL/SFT export paths later. Richer fields
25
+ * (full commitLog, narrative entries with depth/path) get added when
26
+ * an out-of-band recorder integrates `executor.getSnapshot()` directly.
27
+ */
28
+ export interface SnapshotEntry {
29
+ /**
30
+ * The user's message at the time of the run. THIS IS WHAT GETS
31
+ * EMBEDDED for retrieval — new queries are matched by cosine
32
+ * similarity against past queries.
33
+ */
34
+ readonly query: string;
35
+ /**
36
+ * The agent's final answer for the run. Pairs with `query` to form
37
+ * the (prompt, completion) pair RL/SFT exports project on.
38
+ */
39
+ readonly finalContent: string;
40
+ /**
41
+ * Iteration count — how many ReAct loop turns the agent used to
42
+ * produce `finalContent`. Useful for ranking "decisive" runs vs
43
+ * "thrashy" ones.
44
+ */
45
+ readonly iterations: number;
46
+ /**
47
+ * Decision records collected via `decide()`/`select()` during the
48
+ * run. Empty when the agent's flowchart didn't use any decision
49
+ * primitives. THE killer field (by design): each entry carries the rule
50
+ * that matched + the evidence values that satisfied it. STATUS: persisted
51
+ * EMPTY today — the evidence bridge (backlog #5) wires it.
52
+ */
53
+ readonly decisions: ReadonlyArray<DecisionRecord>;
54
+ /**
55
+ * Tool calls made during the run. Each entry: tool name, args,
56
+ * result (truncated). Surfaces the agent's tool-use trajectory for
57
+ * RL training of tool-use policies.
58
+ */
59
+ readonly toolCalls: ReadonlyArray<ToolCallRecord>;
60
+ /**
61
+ * Optional rendered narrative — when an out-of-band recorder
62
+ * captures `executor.getNarrative()` at write time, the full
63
+ * human-readable trace lands here.
64
+ */
65
+ readonly narrative?: string;
66
+ /**
67
+ * Wall-clock duration of the run in milliseconds.
68
+ */
69
+ readonly durationMs: number;
70
+ /**
71
+ * Cumulative token usage at end of run. Used to skip expensive
72
+ * snapshots from training-data exports under cost caps.
73
+ */
74
+ readonly tokenUsage: {
75
+ readonly input: number;
76
+ readonly output: number;
77
+ };
78
+ /**
79
+ * Optional eval score attached by an `evalRecorder`. When present,
80
+ * exports can filter to high-quality runs for SFT or rank for DPO.
81
+ */
82
+ readonly evalScore?: number;
83
+ }
84
+ export interface DecisionRecord {
85
+ /** Stage id where the decision happened (`'classify-risk'`). */
86
+ readonly stageId: string;
87
+ /** Branch chosen (`'rejected'`, `'manual-review'`). */
88
+ readonly chosen: string;
89
+ /** Optional human label of the rule that matched. */
90
+ readonly rule?: string;
91
+ /** Evidence values that led to the choice (key→value). */
92
+ readonly evidence?: Readonly<Record<string, unknown>>;
93
+ }
94
+ export interface ToolCallRecord {
95
+ /** Tool name as registered on the agent. */
96
+ readonly name: string;
97
+ /** Arguments passed to the tool. */
98
+ readonly args: Readonly<Record<string, unknown>>;
99
+ /** Result returned by the tool — TRUNCATED to keep snapshots small. */
100
+ readonly resultPreview: string;
101
+ /** True when the tool threw and the result is the error message. */
102
+ readonly errored: boolean;
103
+ }
104
+ /**
105
+ * Default truncation when serializing tool results into the snapshot.
106
+ * Keeps snapshot entries small enough to fit many in context during
107
+ * retrieval. Override per-call via `writeSnapshot` config.
108
+ */
109
+ export declare const DEFAULT_TOOL_RESULT_PREVIEW_LEN = 500;
110
+ /**
111
+ * What `loadSnapshot` returns to the formatter — the projection slice
112
+ * the consumer asked for via `defineMemory({ projection })`. Each
113
+ * projection produces a different `LLMMessage` content layout.
114
+ */
115
+ export interface ProjectedSnapshot {
116
+ readonly query: string;
117
+ readonly content: string;
118
+ readonly source: {
119
+ readonly entryId: string;
120
+ readonly score: number;
121
+ };
122
+ }
123
+ /**
124
+ * The shape of a single message produced from a projected snapshot.
125
+ * Always `system` role so the LLM treats it as authoritative context
126
+ * about a past run.
127
+ */
128
+ export type SnapshotMessage = LLMMessage & {
129
+ readonly role: 'system';
130
+ };
@@ -0,0 +1,73 @@
1
+ /**
2
+ * writeSnapshot — write-side stage for Causal memory.
3
+ *
4
+ * Captures the current run's `(query, finalContent)` pair from
5
+ * `scope.newMessages` (populated by the Agent's PrepareFinal stage),
6
+ * embeds the query for retrieval, and persists a `SnapshotEntry` to
7
+ * the store. Future turns can match new questions against past
8
+ * queries via cosine similarity to replay decision evidence.
9
+ *
10
+ * Reads from scope: `identity`, `turnNumber`, `newMessages`
11
+ * Writes to store: one `SnapshotEntry` per call, id = `snap-{turn}`
12
+ *
13
+ * Why per-turn (not per-iteration)?
14
+ * Causal memory captures TURN outcomes — "user asked X, agent said Y."
15
+ * Mid-iteration state isn't useful for cross-run replay.
16
+ *
17
+ * Turn derivation — collisions are impossible by construction:
18
+ * The effective turn is `max(scope.turnNumber, maxStoredTurn + 1)` where
19
+ * `maxStoredTurn` is the highest `snap-{n}` already live in THIS
20
+ * conversation's namespace (`identityNamespace(identity)` — the durable
21
+ * conversation anchor across `run()` calls, Agent instances, and
22
+ * processes). Rationale:
23
+ * - Hosts that track `turnNumber` correctly keep their numbering
24
+ * (`turnNumber: 5` → `snap-5`, gaps preserved).
25
+ * - Hosts with a stale counter (the Agent seeds `turnNumber = 1` on
26
+ * every run) still get a fresh, ordered id — turn 2 of the same
27
+ * conversation lands `snap-2` instead of silently replacing
28
+ * `snap-1`.
29
+ * Causal snapshots are decision evidence (audit/replay data): when
30
+ * "stale counter" and "deliberate same-turn rewrite" are
31
+ * indistinguishable, never destroying a prior turn's evidence wins.
32
+ * TTL-expired snapshots are ignored by the scan (same as every read).
33
+ *
34
+ * Empty-newMessages handling:
35
+ * When `newMessages` is empty (no final answer produced — e.g.
36
+ * pause-resume mid-flight), the stage no-ops. Re-runs after resume
37
+ * capture the snapshot then.
38
+ *
39
+ * @see ./types.ts for the SnapshotEntry shape this writes
40
+ * @see ./loadSnapshot.ts for the read-side counterpart
41
+ */
42
+ import type { TypedScope } from 'footprintjs';
43
+ import type { MemoryStore } from '../store/index.js';
44
+ import type { Embedder } from '../embedding/index.js';
45
+ import type { MemoryState } from '../stages/index.js';
46
+ export interface WriteSnapshotConfig {
47
+ /** The store to persist the snapshot to. */
48
+ readonly store: MemoryStore;
49
+ /**
50
+ * Embedder used to vectorize the query for later cosine-search.
51
+ * Required — Causal memory's value comes from semantic retrieval
52
+ * across past runs.
53
+ */
54
+ readonly embedder: Embedder;
55
+ /**
56
+ * Stable id for the embedder. Stored on the entry so a later
57
+ * embedder swap doesn't cross-pollute similarity scores.
58
+ * Default: `'unknown-embedder'` — pass an explicit id when you
59
+ * may swap embedder instances over time.
60
+ */
61
+ readonly embedderId?: string;
62
+ /**
63
+ * TTL in milliseconds — drop snapshots after this duration. Useful
64
+ * for compliance ("delete causal trace after 30 days").
65
+ */
66
+ readonly ttlMs?: number;
67
+ /**
68
+ * Tier to tag the snapshot with — typical: `'hot'` for current,
69
+ * `'warm'`/`'cold'` for archived. Read stages can filter by tier.
70
+ */
71
+ readonly tier?: 'hot' | 'warm' | 'cold';
72
+ }
73
+ export declare function writeSnapshot(config: WriteSnapshotConfig): (scope: TypedScope<MemoryState>) => Promise<void>;
@@ -0,0 +1,63 @@
1
+ /**
2
+ * defineMemory — the single factory the consumer uses to register a
3
+ * memory subsystem on an Agent.
4
+ *
5
+ * defineMemory({ id, type, strategy, store }) → MemoryDefinition
6
+ *
7
+ * The factory's job:
8
+ * 1. Switch on `type` (Episodic / Semantic / Narrative / Causal)
9
+ * to pick the right family of pipelines.
10
+ * 2. Switch on `strategy.kind` within that family to wire stage
11
+ * configs (loadCount / topK / threshold / extractor / ...).
12
+ * 3. Return an opaque `MemoryDefinition` that step-4's
13
+ * `Agent.memory()` builder method consumes.
14
+ *
15
+ * Pattern: Factory + Strategy (GoF). One factory, N strategies, four
16
+ * types — all reduce to two compiled FlowCharts (`read`,
17
+ * `write?`) that mount as subflows.
18
+ *
19
+ * Role: Layer-2 of the memory stack. Sits between the const-objects
20
+ * contract (Layer 1) and the Agent builder method (Layer 4).
21
+ *
22
+ * Emits: Indirectly — the compiled subflows emit
23
+ * `agentfootprint.context.injected` with `source: 'memory'`
24
+ * when their formatter writes to the messages slot.
25
+ *
26
+ * @see ./define.types.ts for the const-objects + types
27
+ * @see ./pipeline/*.ts for the existing pipeline factories this dispatches to
28
+ */
29
+ import { type DefineMemoryOptions } from './define.types.js';
30
+ import type { MemoryDefinition, ReadonlyMemoryFlowChart } from './define.types.js';
31
+ /**
32
+ * Build a `MemoryDefinition` from a high-level `{ type, strategy, store }`
33
+ * config. Internally dispatches to one of the existing pipeline factories
34
+ * (defaultPipeline / semanticPipeline / factPipeline / narrativePipeline /
35
+ * autoPipeline / ephemeralPipeline) and wires the compiled flowcharts
36
+ * into the opaque definition that `Agent.memory()` consumes.
37
+ *
38
+ * Supported combinations:
39
+ *
40
+ * | type | strategy.kind | underlying pipeline |
41
+ * | --------- | ------------- | ------------------------ |
42
+ * | EPISODIC | WINDOW | defaultPipeline |
43
+ * | EPISODIC | BUDGET | defaultPipeline |
44
+ * | EPISODIC | SUMMARIZE | defaultPipeline + summarize stage |
45
+ * | SEMANTIC | TOP_K | semanticPipeline |
46
+ * | SEMANTIC | EXTRACT | factPipeline |
47
+ * | SEMANTIC | WINDOW | factPipeline (recency-load) |
48
+ * | NARRATIVE | EXTRACT | narrativePipeline |
49
+ * | NARRATIVE | WINDOW | narrativePipeline (recency-load) |
50
+ * | (any) | HYBRID | autoPipeline (when sub-strategies map cleanly) |
51
+ *
52
+ * Unsupported combinations throw with a remediation hint pointing to a
53
+ * working alternative or to the raw `mountMemoryRead`/`mountMemoryWrite`
54
+ * helpers for power users.
55
+ */
56
+ export declare function defineMemory(options: DefineMemoryOptions): MemoryDefinition;
57
+ /**
58
+ * Internal — unwrap the brand. Used by `Agent.memory()` (step 4)
59
+ * to mount the pipeline. NOT exported.
60
+ *
61
+ * @internal
62
+ */
63
+ export declare function unwrapMemoryFlowChart<T>(branded: ReadonlyMemoryFlowChart<T>): unknown;