agentfootprint 6.43.0 → 6.45.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (397) hide show
  1. package/ai-instructions/setup.sh +0 -0
  2. package/dist/core/RunnerBase.js +7 -0
  3. package/dist/core/RunnerBase.js.map +1 -1
  4. package/dist/core/agent/buildAgentChart.js +2 -1
  5. package/dist/core/agent/buildAgentChart.js.map +1 -1
  6. package/dist/core/agent/buildDynamicAgentChart.js +3 -1
  7. package/dist/core/agent/buildDynamicAgentChart.js.map +1 -1
  8. package/dist/core/agent/stages/pickEntry.js +3 -1
  9. package/dist/core/agent/stages/pickEntry.js.map +1 -1
  10. package/dist/esm/adapters/identity/agentcore.d.ts +100 -0
  11. package/dist/esm/adapters/llm/AnthropicProvider.d.ts +130 -0
  12. package/dist/esm/adapters/llm/BedrockProvider.d.ts +100 -0
  13. package/dist/esm/adapters/llm/BrowserAnthropicProvider.d.ts +41 -0
  14. package/dist/esm/adapters/llm/BrowserOpenAIProvider.d.ts +95 -0
  15. package/dist/esm/adapters/llm/MockProvider.d.ts +153 -0
  16. package/dist/esm/adapters/llm/OpenAIProvider.d.ts +220 -0
  17. package/dist/esm/adapters/llm/createProvider.d.ts +85 -0
  18. package/dist/esm/adapters/memory/agentcore.d.ts +146 -0
  19. package/dist/esm/adapters/memory/bedrockAgentMemory.d.ts +95 -0
  20. package/dist/esm/adapters/memory/redis.d.ts +127 -0
  21. package/dist/esm/adapters/observability/agentcore.d.ts +67 -0
  22. package/dist/esm/adapters/observability/audit.d.ts +254 -0
  23. package/dist/esm/adapters/observability/cloudwatch.d.ts +96 -0
  24. package/dist/esm/adapters/observability/otel.d.ts +237 -0
  25. package/dist/esm/adapters/observability/xray.d.ts +88 -0
  26. package/dist/esm/adapters/types.d.ts +378 -0
  27. package/dist/esm/bridge/eventMeta.d.ts +59 -0
  28. package/dist/esm/cache/CacheDecisionSubflow.d.ts +85 -0
  29. package/dist/esm/cache/CacheGateDecider.d.ts +127 -0
  30. package/dist/esm/cache/applyCachePolicy.d.ts +37 -0
  31. package/dist/esm/cache/cacheRecorder.d.ts +85 -0
  32. package/dist/esm/cache/index.d.ts +33 -0
  33. package/dist/esm/cache/strategies/AnthropicCacheStrategy.d.ts +38 -0
  34. package/dist/esm/cache/strategies/BedrockCacheStrategy.d.ts +33 -0
  35. package/dist/esm/cache/strategies/NoOpCacheStrategy.d.ts +29 -0
  36. package/dist/esm/cache/strategies/OpenAICacheStrategy.d.ts +36 -0
  37. package/dist/esm/cache/strategyRegistry.d.ts +45 -0
  38. package/dist/esm/cache/types.d.ts +243 -0
  39. package/dist/esm/conventions.d.ts +203 -0
  40. package/dist/esm/core/Agent.d.ts +355 -0
  41. package/dist/esm/core/LLMCall.d.ts +139 -0
  42. package/dist/esm/core/RunnerBase.d.ts +267 -0
  43. package/dist/esm/core/RunnerBase.js +7 -0
  44. package/dist/esm/core/RunnerBase.js.map +1 -1
  45. package/dist/esm/core/agent/AgentBuilder.d.ts +565 -0
  46. package/dist/esm/core/agent/buildAgentChart.d.ts +109 -0
  47. package/dist/esm/core/agent/buildAgentChart.js +2 -1
  48. package/dist/esm/core/agent/buildAgentChart.js.map +1 -1
  49. package/dist/esm/core/agent/buildAgentMessageApiChart.d.ts +40 -0
  50. package/dist/esm/core/agent/buildCacheSubflow.d.ts +35 -0
  51. package/dist/esm/core/agent/buildDynamicAgentChart.d.ts +56 -0
  52. package/dist/esm/core/agent/buildDynamicAgentChart.js +3 -1
  53. package/dist/esm/core/agent/buildDynamicAgentChart.js.map +1 -1
  54. package/dist/esm/core/agent/buildMessageApiChart.d.ts +47 -0
  55. package/dist/esm/core/agent/buildToolRegistry.d.ts +61 -0
  56. package/dist/esm/core/agent/memoryRecallInjections.d.ts +8 -0
  57. package/dist/esm/core/agent/stages/breakFinal.d.ts +22 -0
  58. package/dist/esm/core/agent/stages/callLLM.d.ts +74 -0
  59. package/dist/esm/core/agent/stages/pickEntry.d.ts +19 -0
  60. package/dist/esm/core/agent/stages/pickEntry.js +3 -1
  61. package/dist/esm/core/agent/stages/pickEntry.js.map +1 -1
  62. package/dist/esm/core/agent/stages/prepareFinal.d.ts +19 -0
  63. package/dist/esm/core/agent/stages/reliabilityExecution.d.ts +135 -0
  64. package/dist/esm/core/agent/stages/route.d.ts +18 -0
  65. package/dist/esm/core/agent/stages/seed.d.ts +53 -0
  66. package/dist/esm/core/agent/stages/toolCalls.d.ts +76 -0
  67. package/dist/esm/core/agent/toolArgsValidation.d.ts +62 -0
  68. package/dist/esm/core/agent/types.d.ts +382 -0
  69. package/dist/esm/core/agent/validators.d.ts +52 -0
  70. package/dist/esm/core/cost.d.ts +38 -0
  71. package/dist/esm/core/flowchartAsTool.d.ts +200 -0
  72. package/dist/esm/core/humanizeLLMError.d.ts +23 -0
  73. package/dist/esm/core/outputFallback.d.ts +139 -0
  74. package/dist/esm/core/outputSchema.d.ts +127 -0
  75. package/dist/esm/core/pause.d.ts +74 -0
  76. package/dist/esm/core/runCheckpoint.d.ts +179 -0
  77. package/dist/esm/core/runner.d.ts +203 -0
  78. package/dist/esm/core/slots/buildMessagesSlot.d.ts +40 -0
  79. package/dist/esm/core/slots/buildSystemPromptSlot.d.ts +41 -0
  80. package/dist/esm/core/slots/buildThinkingSubflow.d.ts +40 -0
  81. package/dist/esm/core/slots/buildToolsSlot.d.ts +60 -0
  82. package/dist/esm/core/slots/helpers.d.ts +27 -0
  83. package/dist/esm/core/toolContract.d.ts +43 -0
  84. package/dist/esm/core/tools.d.ts +90 -0
  85. package/dist/esm/core/translator.d.ts +94 -0
  86. package/dist/esm/core-flow/Conditional.d.ts +119 -0
  87. package/dist/esm/core-flow/Loop.d.ts +160 -0
  88. package/dist/esm/core-flow/Parallel.d.ts +360 -0
  89. package/dist/esm/core-flow/Sequence.d.ts +133 -0
  90. package/dist/esm/events/dispatcher.d.ts +134 -0
  91. package/dist/esm/events/payloads.d.ts +761 -0
  92. package/dist/esm/events/registry.d.ts +198 -0
  93. package/dist/esm/events/types.d.ts +70 -0
  94. package/dist/esm/identity/kinds.d.ts +36 -0
  95. package/dist/esm/identity/staticTokens.d.ts +28 -0
  96. package/dist/esm/identity/types.d.ts +113 -0
  97. package/dist/esm/identity/withCredentialRetry.d.ts +64 -0
  98. package/dist/esm/identity.d.ts +31 -0
  99. package/dist/esm/index.d.ts +64 -0
  100. package/dist/esm/index.js +2 -0
  101. package/dist/esm/index.js.map +1 -1
  102. package/dist/esm/injection-engine.d.ts +4 -0
  103. package/dist/esm/lib/canonicalJson.d.ts +56 -0
  104. package/dist/esm/lib/context-bisect/ablation.d.ts +109 -0
  105. package/dist/esm/lib/context-bisect/bisect.d.ts +75 -0
  106. package/dist/esm/lib/context-bisect/cost.d.ts +37 -0
  107. package/dist/esm/lib/context-bisect/index.d.ts +31 -0
  108. package/dist/esm/lib/context-bisect/index.js +3 -0
  109. package/dist/esm/lib/context-bisect/index.js.map +1 -1
  110. package/dist/esm/lib/context-bisect/llmEdgeWeigher.d.ts +124 -0
  111. package/dist/esm/lib/context-bisect/localize.d.ts +152 -0
  112. package/dist/esm/lib/context-bisect/localize.js +2 -0
  113. package/dist/esm/lib/context-bisect/localize.js.map +1 -1
  114. package/dist/esm/lib/context-bisect/loop-recall.d.ts +97 -0
  115. package/dist/esm/lib/context-bisect/missingContext.d.ts +71 -0
  116. package/dist/esm/lib/context-bisect/restoration.d.ts +39 -0
  117. package/dist/esm/lib/context-bisect/toBacktrackTrace.d.ts +138 -0
  118. package/dist/esm/lib/context-bisect/trajectory.d.ts +168 -0
  119. package/dist/esm/lib/context-bisect/types.d.ts +448 -0
  120. package/dist/esm/lib/context-bisect/walk-to-root.d.ts +103 -0
  121. package/dist/esm/lib/influence-core/attributability.d.ts +72 -0
  122. package/dist/esm/lib/influence-core/cache.d.ts +94 -0
  123. package/dist/esm/lib/influence-core/contrastive.d.ts +26 -0
  124. package/dist/esm/lib/influence-core/index.d.ts +34 -0
  125. package/dist/esm/lib/influence-core/margin.d.ts +33 -0
  126. package/dist/esm/lib/influence-core/signals.d.ts +128 -0
  127. package/dist/esm/lib/influence-core/similarity.d.ts +25 -0
  128. package/dist/esm/lib/influence-core/types.d.ts +252 -0
  129. package/dist/esm/lib/injection-engine/SkillRegistry.d.ts +147 -0
  130. package/dist/esm/lib/injection-engine/buildInjectionEngineSubflow.d.ts +110 -0
  131. package/dist/esm/lib/injection-engine/buildInjectionEngineSubflow.js +1 -0
  132. package/dist/esm/lib/injection-engine/buildInjectionEngineSubflow.js.map +1 -1
  133. package/dist/esm/lib/injection-engine/entryScorer.d.ts +93 -0
  134. package/dist/esm/lib/injection-engine/entryScorer.js +172 -0
  135. package/dist/esm/lib/injection-engine/entryScorer.js.map +1 -0
  136. package/dist/esm/lib/injection-engine/evaluator.d.ts +24 -0
  137. package/dist/esm/lib/injection-engine/factories/defineFact.d.ts +60 -0
  138. package/dist/esm/lib/injection-engine/factories/defineInjection.d.ts +41 -0
  139. package/dist/esm/lib/injection-engine/factories/defineInstruction.d.ts +78 -0
  140. package/dist/esm/lib/injection-engine/factories/defineRelevanceHint.d.ts +26 -0
  141. package/dist/esm/lib/injection-engine/factories/defineSkill.d.ts +160 -0
  142. package/dist/esm/lib/injection-engine/factories/defineSteering.d.ts +39 -0
  143. package/dist/esm/lib/injection-engine/index.d.ts +22 -0
  144. package/dist/esm/lib/injection-engine/index.js +1 -0
  145. package/dist/esm/lib/injection-engine/index.js.map +1 -1
  146. package/dist/esm/lib/injection-engine/skillContract.d.ts +29 -0
  147. package/dist/esm/lib/injection-engine/skillGraph.d.ts +289 -0
  148. package/dist/esm/lib/injection-engine/skillGraph.js +35 -41
  149. package/dist/esm/lib/injection-engine/skillGraph.js.map +1 -1
  150. package/dist/esm/lib/injection-engine/skillGraphCheckup.d.ts +49 -0
  151. package/dist/esm/lib/injection-engine/skillTools.d.ts +72 -0
  152. package/dist/esm/lib/injection-engine/softmax.d.ts +11 -0
  153. package/dist/esm/lib/injection-engine/types.d.ts +229 -0
  154. package/dist/esm/lib/injection-engine/types.js.map +1 -1
  155. package/dist/esm/lib/lazyRequire.d.ts +29 -0
  156. package/dist/esm/lib/mcp/index.d.ts +9 -0
  157. package/dist/esm/lib/mcp/mcpClient.d.ts +46 -0
  158. package/dist/esm/lib/mcp/mockMcpClient.d.ts +65 -0
  159. package/dist/esm/lib/mcp/types.d.ts +133 -0
  160. package/dist/esm/lib/rag/defineRAG.d.ts +139 -0
  161. package/dist/esm/lib/rag/index.d.ts +7 -0
  162. package/dist/esm/lib/rag/indexDocuments.d.ts +105 -0
  163. package/dist/esm/lib/tool-lint/analyze.d.ts +83 -0
  164. package/dist/esm/lib/tool-lint/cli.d.ts +43 -0
  165. package/dist/esm/lib/tool-lint/format.d.ts +18 -0
  166. package/dist/esm/lib/tool-lint/index.d.ts +23 -0
  167. package/dist/esm/lib/tool-lint/rules.d.ts +85 -0
  168. package/dist/esm/lib/tool-lint/types.d.ts +155 -0
  169. package/dist/esm/lib/trace-toolpack/bounded.d.ts +47 -0
  170. package/dist/esm/lib/trace-toolpack/debugPrompt.d.ts +19 -0
  171. package/dist/esm/lib/trace-toolpack/index.d.ts +20 -0
  172. package/dist/esm/lib/trace-toolpack/lazyToolpack.d.ts +35 -0
  173. package/dist/esm/lib/trace-toolpack/selfExplain.d.ts +100 -0
  174. package/dist/esm/lib/trace-toolpack/traceDebugAgent.d.ts +42 -0
  175. package/dist/esm/lib/trace-toolpack/traceToolpack.d.ts +69 -0
  176. package/dist/esm/lib/trace-toolpack/types.d.ts +59 -0
  177. package/dist/esm/llm-providers.d.ts +26 -0
  178. package/dist/esm/locales/index.d.ts +132 -0
  179. package/dist/esm/memory/beats/extractBeats.d.ts +61 -0
  180. package/dist/esm/memory/beats/extractor.d.ts +47 -0
  181. package/dist/esm/memory/beats/formatAsNarrative.d.ts +62 -0
  182. package/dist/esm/memory/beats/heuristicExtractor.d.ts +37 -0
  183. package/dist/esm/memory/beats/index.d.ts +12 -0
  184. package/dist/esm/memory/beats/llmExtractor.d.ts +56 -0
  185. package/dist/esm/memory/beats/types.d.ts +60 -0
  186. package/dist/esm/memory/beats/writeBeats.d.ts +22 -0
  187. package/dist/esm/memory/causal/evidenceRecorder.d.ts +66 -0
  188. package/dist/esm/memory/causal/index.d.ts +6 -0
  189. package/dist/esm/memory/causal/loadSnapshot.d.ts +51 -0
  190. package/dist/esm/memory/causal/snapshotPipeline.d.ts +35 -0
  191. package/dist/esm/memory/causal/types.d.ts +130 -0
  192. package/dist/esm/memory/causal/writeSnapshot.d.ts +73 -0
  193. package/dist/esm/memory/define.d.ts +63 -0
  194. package/dist/esm/memory/define.types.d.ts +276 -0
  195. package/dist/esm/memory/define.types.js +1 -1
  196. package/dist/esm/memory/embedding/cosine.d.ts +18 -0
  197. package/dist/esm/memory/embedding/embedMessages.d.ts +58 -0
  198. package/dist/esm/memory/embedding/index.d.ts +8 -0
  199. package/dist/esm/memory/embedding/loadRelevant.d.ts +51 -0
  200. package/dist/esm/memory/embedding/mockEmbedder.d.ts +22 -0
  201. package/dist/esm/memory/embedding/types.d.ts +46 -0
  202. package/dist/esm/memory/entry/decay.d.ts +36 -0
  203. package/dist/esm/memory/entry/index.d.ts +2 -0
  204. package/dist/esm/memory/entry/types.d.ts +140 -0
  205. package/dist/esm/memory/facts/extractFacts.d.ts +50 -0
  206. package/dist/esm/memory/facts/extractor.d.ts +33 -0
  207. package/dist/esm/memory/facts/formatFacts.d.ts +60 -0
  208. package/dist/esm/memory/facts/index.d.ts +14 -0
  209. package/dist/esm/memory/facts/llmFactExtractor.d.ts +64 -0
  210. package/dist/esm/memory/facts/loadFacts.d.ts +43 -0
  211. package/dist/esm/memory/facts/patternFactExtractor.d.ts +2 -0
  212. package/dist/esm/memory/facts/types.d.ts +68 -0
  213. package/dist/esm/memory/facts/writeFacts.d.ts +19 -0
  214. package/dist/esm/memory/identity/index.d.ts +2 -0
  215. package/dist/esm/memory/identity/types.d.ts +49 -0
  216. package/dist/esm/memory/index.d.ts +19 -0
  217. package/dist/esm/memory/pipeline/auto.d.ts +59 -0
  218. package/dist/esm/memory/pipeline/default.d.ts +49 -0
  219. package/dist/esm/memory/pipeline/ephemeral.d.ts +28 -0
  220. package/dist/esm/memory/pipeline/fact.d.ts +26 -0
  221. package/dist/esm/memory/pipeline/index.d.ts +13 -0
  222. package/dist/esm/memory/pipeline/narrative.d.ts +35 -0
  223. package/dist/esm/memory/pipeline/semantic.d.ts +37 -0
  224. package/dist/esm/memory/pipeline/types.d.ts +31 -0
  225. package/dist/esm/memory/stages/formatDefault.d.ts +64 -0
  226. package/dist/esm/memory/stages/index.d.ts +13 -0
  227. package/dist/esm/memory/stages/loadRecent.d.ts +49 -0
  228. package/dist/esm/memory/stages/pickByBudget.d.ts +63 -0
  229. package/dist/esm/memory/stages/summarize.d.ts +87 -0
  230. package/dist/esm/memory/stages/tokenize.d.ts +43 -0
  231. package/dist/esm/memory/stages/types.d.ts +75 -0
  232. package/dist/esm/memory/stages/writeMessages.d.ts +71 -0
  233. package/dist/esm/memory/store/InMemoryStore.d.ts +62 -0
  234. package/dist/esm/memory/store/index.d.ts +2 -0
  235. package/dist/esm/memory/store/types.d.ts +223 -0
  236. package/dist/esm/memory/wire/index.d.ts +2 -0
  237. package/dist/esm/memory/wire/mountMemoryPipeline.d.ts +108 -0
  238. package/dist/esm/memory-providers.d.ts +37 -0
  239. package/dist/esm/observability/contextError/finders/compareFinders.d.ts +19 -0
  240. package/dist/esm/observability/contextError/finders/index.d.ts +22 -0
  241. package/dist/esm/observability/contextError/finders/rankSuspects.d.ts +2 -0
  242. package/dist/esm/observability/contextError/finders/removeAndRetry.d.ts +11 -0
  243. package/dist/esm/observability/contextError/finders/shrinkToCause.d.ts +11 -0
  244. package/dist/esm/observability/contextError/finders/testManyCombos.d.ts +11 -0
  245. package/dist/esm/observability/contextError/finders/traceSteps.d.ts +2 -0
  246. package/dist/esm/observability/contextError/finders/types.d.ts +88 -0
  247. package/dist/esm/observability-providers.d.ts +46 -0
  248. package/dist/esm/observe.d.ts +62 -0
  249. package/dist/esm/observe.js +7 -1
  250. package/dist/esm/observe.js.map +1 -1
  251. package/dist/esm/patterns/Debate.d.ts +39 -0
  252. package/dist/esm/patterns/MapReduce.d.ts +66 -0
  253. package/dist/esm/patterns/Reflection.d.ts +51 -0
  254. package/dist/esm/patterns/SelfConsistency.d.ts +43 -0
  255. package/dist/esm/patterns/Swarm.d.ts +60 -0
  256. package/dist/esm/patterns/ToT.d.ts +53 -0
  257. package/dist/esm/patterns/index.d.ts +22 -0
  258. package/dist/esm/providers.d.ts +33 -0
  259. package/dist/esm/recorders/core/AgentRecorder.d.ts +15 -0
  260. package/dist/esm/recorders/core/CompositionRecorder.d.ts +17 -0
  261. package/dist/esm/recorders/core/ContextEvaluatedRecorder.d.ts +23 -0
  262. package/dist/esm/recorders/core/ContextRecorder.d.ts +47 -0
  263. package/dist/esm/recorders/core/CostRecorder.d.ts +14 -0
  264. package/dist/esm/recorders/core/EmitBridge.d.ts +30 -0
  265. package/dist/esm/recorders/core/ErrorBridge.d.ts +38 -0
  266. package/dist/esm/recorders/core/EvalRecorder.d.ts +16 -0
  267. package/dist/esm/recorders/core/MemoryRecorder.d.ts +17 -0
  268. package/dist/esm/recorders/core/PermissionRecorder.d.ts +16 -0
  269. package/dist/esm/recorders/core/ReliabilityRecorder.d.ts +24 -0
  270. package/dist/esm/recorders/core/SkillRecorder.d.ts +14 -0
  271. package/dist/esm/recorders/core/StreamRecorder.d.ts +15 -0
  272. package/dist/esm/recorders/core/ToolsRecorder.d.ts +18 -0
  273. package/dist/esm/recorders/core/ValidationRecorder.d.ts +16 -0
  274. package/dist/esm/recorders/core/contextEngineering.d.ts +136 -0
  275. package/dist/esm/recorders/core/typedEmit.d.ts +34 -0
  276. package/dist/esm/recorders/core/types.d.ts +97 -0
  277. package/dist/esm/recorders/observability/AgentThinkingTraceRecorder.d.ts +117 -0
  278. package/dist/esm/recorders/observability/BoundaryRecorder.d.ts +546 -0
  279. package/dist/esm/recorders/observability/FlowchartRecorder.d.ts +220 -0
  280. package/dist/esm/recorders/observability/FlowchartRecorder.js +10 -2
  281. package/dist/esm/recorders/observability/FlowchartRecorder.js.map +1 -1
  282. package/dist/esm/recorders/observability/LiveStateRecorder.d.ts +250 -0
  283. package/dist/esm/recorders/observability/LoggingRecorder.d.ts +91 -0
  284. package/dist/esm/recorders/observability/RouteRecorder.d.ts +83 -0
  285. package/dist/esm/recorders/observability/RunStepRecorder.d.ts +231 -0
  286. package/dist/esm/recorders/observability/StatusRecorder.d.ts +36 -0
  287. package/dist/esm/recorders/observability/ToolChoiceRecorder.d.ts +164 -0
  288. package/dist/esm/recorders/observability/ToolLineageRecorder.d.ts +71 -0
  289. package/dist/esm/recorders/observability/commentary/commentaryTemplates.d.ts +105 -0
  290. package/dist/esm/recorders/observability/internal/ActorArrowClassifier.d.ts +25 -0
  291. package/dist/esm/recorders/observability/internal/CandidateAnswerBuffer.d.ts +28 -0
  292. package/dist/esm/recorders/observability/internal/ForkTracker.d.ts +60 -0
  293. package/dist/esm/recorders/observability/internal/RootInferrer.d.ts +51 -0
  294. package/dist/esm/recorders/observability/internal/SequenceSiblingTracker.d.ts +24 -0
  295. package/dist/esm/recorders/observability/localObservability.d.ts +48 -0
  296. package/dist/esm/recorders/observability/localObservability.js +54 -0
  297. package/dist/esm/recorders/observability/localObservability.js.map +1 -0
  298. package/dist/esm/recorders/observability/observeRunId.d.ts +36 -0
  299. package/dist/esm/recorders/observability/status/statusTemplates.d.ts +106 -0
  300. package/dist/esm/recorders/observability/trace.d.ts +119 -0
  301. package/dist/esm/recorders/observability/trace.js +99 -0
  302. package/dist/esm/recorders/observability/trace.js.map +1 -0
  303. package/dist/esm/reliability/CircuitBreaker.d.ts +75 -0
  304. package/dist/esm/reliability/buildReliabilityGateChart.d.ts +53 -0
  305. package/dist/esm/reliability/classifyError.d.ts +28 -0
  306. package/dist/esm/reliability/index.d.ts +35 -0
  307. package/dist/esm/reliability/types.d.ts +327 -0
  308. package/dist/esm/resilience/fallbackProvider.d.ts +33 -0
  309. package/dist/esm/resilience/index.d.ts +21 -0
  310. package/dist/esm/resilience/withCircuitBreaker.d.ts +129 -0
  311. package/dist/esm/resilience/withFallback.d.ts +45 -0
  312. package/dist/esm/resilience/withRetry.d.ts +71 -0
  313. package/dist/esm/security/PermissionPolicy.d.ts +124 -0
  314. package/dist/esm/security/PolicyHaltError.d.ts +72 -0
  315. package/dist/esm/security/extractSequence.d.ts +46 -0
  316. package/dist/esm/security/index.d.ts +44 -0
  317. package/dist/esm/security/thinkingRedaction.d.ts +50 -0
  318. package/dist/esm/status.d.ts +48 -0
  319. package/dist/esm/strategies/attach.d.ts +47 -0
  320. package/dist/esm/strategies/compose.d.ts +48 -0
  321. package/dist/esm/strategies/defaults/chatBubbleLiveStatus.d.ts +36 -0
  322. package/dist/esm/strategies/defaults/consoleObservability.d.ts +42 -0
  323. package/dist/esm/strategies/defaults/inMemorySinkCost.d.ts +50 -0
  324. package/dist/esm/strategies/defaults/index.d.ts +30 -0
  325. package/dist/esm/strategies/defaults/noopLens.d.ts +28 -0
  326. package/dist/esm/strategies/index.d.ts +36 -0
  327. package/dist/esm/strategies/registry.d.ts +70 -0
  328. package/dist/esm/strategies/types.d.ts +303 -0
  329. package/dist/esm/stream.d.ts +82 -0
  330. package/dist/esm/thinking/AnthropicThinkingHandler.d.ts +42 -0
  331. package/dist/esm/thinking/MockThinkingHandler.d.ts +50 -0
  332. package/dist/esm/thinking/OpenAIThinkingHandler.d.ts +37 -0
  333. package/dist/esm/thinking/index.d.ts +51 -0
  334. package/dist/esm/thinking/registry.d.ts +33 -0
  335. package/dist/esm/thinking/types.d.ts +162 -0
  336. package/dist/esm/tool-providers/gatedTools.d.ts +36 -0
  337. package/dist/esm/tool-providers/index.d.ts +41 -0
  338. package/dist/esm/tool-providers/skillScopedTools.d.ts +45 -0
  339. package/dist/esm/tool-providers/staticTools.d.ts +21 -0
  340. package/dist/esm/tool-providers/types.d.ts +138 -0
  341. package/dist/index.js +6 -2
  342. package/dist/index.js.map +1 -1
  343. package/dist/lib/context-bisect/index.js +3 -0
  344. package/dist/lib/context-bisect/index.js.map +1 -1
  345. package/dist/lib/context-bisect/localize.js +2 -0
  346. package/dist/lib/context-bisect/localize.js.map +1 -1
  347. package/dist/lib/injection-engine/buildInjectionEngineSubflow.js +1 -0
  348. package/dist/lib/injection-engine/buildInjectionEngineSubflow.js.map +1 -1
  349. package/dist/lib/injection-engine/entryScorer.js +178 -0
  350. package/dist/lib/injection-engine/entryScorer.js.map +1 -0
  351. package/dist/lib/injection-engine/index.js +5 -1
  352. package/dist/lib/injection-engine/index.js.map +1 -1
  353. package/dist/lib/injection-engine/skillGraph.js +35 -41
  354. package/dist/lib/injection-engine/skillGraph.js.map +1 -1
  355. package/dist/lib/injection-engine/types.js.map +1 -1
  356. package/dist/memory/define.types.js +1 -1
  357. package/dist/observe.js +14 -3
  358. package/dist/observe.js.map +1 -1
  359. package/dist/recorders/observability/FlowchartRecorder.js +12 -3
  360. package/dist/recorders/observability/FlowchartRecorder.js.map +1 -1
  361. package/dist/recorders/observability/localObservability.js +58 -0
  362. package/dist/recorders/observability/localObservability.js.map +1 -0
  363. package/dist/recorders/observability/trace.js +105 -0
  364. package/dist/recorders/observability/trace.js.map +1 -0
  365. package/dist/types/core/RunnerBase.d.ts.map +1 -1
  366. package/dist/types/core/agent/buildAgentChart.d.ts.map +1 -1
  367. package/dist/types/core/agent/buildDynamicAgentChart.d.ts.map +1 -1
  368. package/dist/types/core/agent/stages/pickEntry.d.ts.map +1 -1
  369. package/dist/types/core/agent/types.d.ts +8 -4
  370. package/dist/types/core/agent/types.d.ts.map +1 -1
  371. package/dist/types/core/runner.d.ts +12 -0
  372. package/dist/types/core/runner.d.ts.map +1 -1
  373. package/dist/types/index.d.ts +1 -1
  374. package/dist/types/index.d.ts.map +1 -1
  375. package/dist/types/lib/context-bisect/index.d.ts +3 -0
  376. package/dist/types/lib/context-bisect/index.d.ts.map +1 -1
  377. package/dist/types/lib/context-bisect/localize.d.ts +2 -0
  378. package/dist/types/lib/context-bisect/localize.d.ts.map +1 -1
  379. package/dist/types/lib/injection-engine/buildInjectionEngineSubflow.d.ts.map +1 -1
  380. package/dist/types/lib/injection-engine/entryScorer.d.ts +94 -0
  381. package/dist/types/lib/injection-engine/entryScorer.d.ts.map +1 -0
  382. package/dist/types/lib/injection-engine/index.d.ts +1 -0
  383. package/dist/types/lib/injection-engine/index.d.ts.map +1 -1
  384. package/dist/types/lib/injection-engine/skillGraph.d.ts +21 -24
  385. package/dist/types/lib/injection-engine/skillGraph.d.ts.map +1 -1
  386. package/dist/types/lib/injection-engine/types.d.ts +9 -4
  387. package/dist/types/lib/injection-engine/types.d.ts.map +1 -1
  388. package/dist/types/memory/define.types.d.ts +1 -1
  389. package/dist/types/observe.d.ts +3 -1
  390. package/dist/types/observe.d.ts.map +1 -1
  391. package/dist/types/recorders/observability/FlowchartRecorder.d.ts +8 -1
  392. package/dist/types/recorders/observability/FlowchartRecorder.d.ts.map +1 -1
  393. package/dist/types/recorders/observability/localObservability.d.ts +49 -0
  394. package/dist/types/recorders/observability/localObservability.d.ts.map +1 -0
  395. package/dist/types/recorders/observability/trace.d.ts +120 -0
  396. package/dist/types/recorders/observability/trace.d.ts.map +1 -0
  397. package/package.json +203 -56
@@ -0,0 +1,23 @@
1
+ /**
2
+ * ContextEvaluatedRecorder — forwards the `agentfootprint.context.evaluated`
3
+ * emit to the dispatcher.
4
+ *
5
+ * Pattern: Factory (GoF) returning an EmitBridge instance.
6
+ * Role: The InjectionEngine `typedEmit`s `context.evaluated` (the
7
+ * "what was considered / active / skipped + why" summary). Unlike the
8
+ * other `context.*` events — which `ContextRecorder` DISPATCHES by
9
+ * observing scope writes — this one is emitted complete by the stage,
10
+ * so it just needs forwarding (the EmitBridge pass-through pattern,
11
+ * same as StreamRecorder / AgentRecorder).
12
+ * Why a full-name prefix: scoped to EXACTLY `agentfootprint.context.evaluated`
13
+ * (not the whole `context.*` domain) so it never double-dispatches
14
+ * `context.slot_composed`, which IS `typedEmit`'d in the viz chart
15
+ * (`buildMessageApiChart`) while ALSO being dispatched by
16
+ * `ContextRecorder` from writes in the runtime charts.
17
+ * Emits: agentfootprint.context.evaluated
18
+ */
19
+ import { EmitBridge, type EmitBridgeOptions } from './EmitBridge.js';
20
+ export type ContextEvaluatedRecorderOptions = Omit<EmitBridgeOptions, 'id' | 'prefix'> & {
21
+ readonly id?: string;
22
+ };
23
+ export declare function contextEvaluatedRecorder(options: ContextEvaluatedRecorderOptions): EmitBridge;
@@ -0,0 +1,47 @@
1
+ /**
2
+ * ContextRecorder — observes footprintjs subflow + scope events, emits
3
+ * grouped `context.*` domain events via the EventDispatcher.
4
+ *
5
+ * Pattern: Observer (GoF) + Pipes & Filters (Hohpe & Woolf, 2003).
6
+ * Role: Core semantic grouping layer for the 3-slot model. Watches
7
+ * slot subflows (sf-system-prompt / sf-messages / sf-tools) and
8
+ * translates raw writes into context.injected / evicted /
9
+ * slot_composed / budget_pressure events.
10
+ * Emits: agentfootprint.context.injected
11
+ * agentfootprint.context.evicted
12
+ * agentfootprint.context.slot_composed
13
+ * agentfootprint.context.budget_pressure
14
+ */
15
+ import type { CombinedRecorder, FlowSubflowEvent, WriteEvent } from 'footprintjs';
16
+ import type { EventDispatcher } from '../../events/dispatcher.js';
17
+ import { type RunContext } from '../../bridge/eventMeta.js';
18
+ /**
19
+ * Supplies the recorder with run-level context. Passed at construction
20
+ * time (static fields) OR updated via `updateRunContext` between runs
21
+ * when reusing one recorder across multiple executor runs.
22
+ */
23
+ export interface ContextRecorderOptions {
24
+ readonly dispatcher: EventDispatcher;
25
+ readonly id?: string;
26
+ readonly getRunContext: () => RunContext;
27
+ }
28
+ export declare class ContextRecorder implements CombinedRecorder {
29
+ readonly id: string;
30
+ private readonly dispatcher;
31
+ private readonly getRunContext;
32
+ private readonly seenInjections;
33
+ constructor(options: ContextRecorderOptions);
34
+ onSubflowEntry(event: FlowSubflowEvent): void;
35
+ onSubflowExit(event: FlowSubflowEvent): void;
36
+ onWrite(event: WriteEvent): void;
37
+ private handleInjectionsWrite;
38
+ private handleSlotComposedWrite;
39
+ private handleEvictionsWrite;
40
+ private handleBudgetPressureWrite;
41
+ private emitInjected;
42
+ private dispatch;
43
+ private asInjectionArray;
44
+ private asSlotComposition;
45
+ private asEvictionArray;
46
+ private asPressureArray;
47
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * CostRecorder — forwards `agentfootprint.cost.*` emits to the dispatcher.
3
+ *
4
+ * Pattern: Factory (GoF) returning an EmitBridge instance.
5
+ * Role: Bridges `cost.tick` + `cost.limit_hit` emits from LLMCall / Agent
6
+ * stages (via `emitCostTick`) to the EventDispatcher so typed
7
+ * consumer listeners fire.
8
+ * Emits: agentfootprint.cost.tick / cost.limit_hit
9
+ */
10
+ import { EmitBridge, type EmitBridgeOptions } from './EmitBridge.js';
11
+ export type CostRecorderOptions = Omit<EmitBridgeOptions, 'id' | 'prefix'> & {
12
+ readonly id?: string;
13
+ };
14
+ export declare function costRecorder(options: CostRecorderOptions): EmitBridge;
@@ -0,0 +1,30 @@
1
+ /**
2
+ * EmitBridge — forwards footprintjs emits whose name starts with a given
3
+ * prefix to the EventDispatcher, enriched with EventMeta.
4
+ *
5
+ * Pattern: Adapter (GoF) + Pipes & Filters (Hohpe & Woolf, 2003).
6
+ * Role: Single reusable translation layer for every "pass-through"
7
+ * prefix recorder (StreamRecorder, AgentRecorder, and any
8
+ * future domain whose events are emitted via typedEmit()).
9
+ * Emits: Any event whose name matches `prefix` — type derived from the
10
+ * emit name and validated by the consumer's EventMap subscription.
11
+ */
12
+ import type { CombinedRecorder, EmitEvent } from 'footprintjs';
13
+ import type { EventDispatcher } from '../../events/dispatcher.js';
14
+ import { type RunContext } from '../../bridge/eventMeta.js';
15
+ export interface EmitBridgeOptions {
16
+ readonly dispatcher: EventDispatcher;
17
+ /** Recorder id — must be unique among attached recorders. */
18
+ readonly id: string;
19
+ /** Event-name prefix this bridge forwards (e.g. 'agentfootprint.stream.'). */
20
+ readonly prefix: string;
21
+ readonly getRunContext: () => RunContext;
22
+ }
23
+ export declare class EmitBridge implements CombinedRecorder {
24
+ readonly id: string;
25
+ private readonly dispatcher;
26
+ private readonly prefix;
27
+ private readonly getRunContext;
28
+ constructor(options: EmitBridgeOptions);
29
+ onEmit(event: EmitEvent): void;
30
+ }
@@ -0,0 +1,38 @@
1
+ /**
2
+ * ErrorBridge — translates footprintjs's STRUCTURAL `onRunFailed` (the
3
+ * terminal run-boundary event fired when a run throws a non-pause error)
4
+ * into agentfootprint's TYPED `agentfootprint.error.fatal` domain event.
5
+ *
6
+ * Pattern: Adapter (GoF) — same role as EmitBridge, different channel.
7
+ * Role: Close the "failed run is invisible" gap. footprintjs fires
8
+ * `onError` (stage-level) + `onRunFailed` (run-level) on the
9
+ * FlowRecorder channel, but agentfootprint's typed consumers
10
+ * (LiveStateRecorder clearing in-flight, monitors setting
11
+ * status) listen on the DISPATCHER. Without a bridge, a thrown
12
+ * LLM call left `isLLMInFlight()` stuck true ("Chatbot is
13
+ * thinking…" forever) and downstream STATUS showed "ok". This
14
+ * re-dispatches one terminal typed event so every consumer
15
+ * reacts uniformly.
16
+ * Emits: agentfootprint.error.fatal (once per failed top-level run).
17
+ *
18
+ * Fires at the TOP LEVEL only — footprintjs `onRunFailed` is a run
19
+ * boundary, not a per-stage event. Subflow errors propagate up and
20
+ * surface here once.
21
+ */
22
+ import type { CombinedRecorder, FlowRunFailedEvent } from 'footprintjs';
23
+ import type { EventDispatcher } from '../../events/dispatcher.js';
24
+ import { type RunContext } from '../../bridge/eventMeta.js';
25
+ export interface ErrorBridgeOptions {
26
+ readonly dispatcher: EventDispatcher;
27
+ /** Recorder id — must be unique among attached recorders. */
28
+ readonly id?: string;
29
+ readonly getRunContext: () => RunContext;
30
+ }
31
+ export declare class ErrorBridge implements CombinedRecorder {
32
+ readonly id: string;
33
+ private readonly dispatcher;
34
+ private readonly getRunContext;
35
+ constructor(options: ErrorBridgeOptions);
36
+ onRunFailed(event: FlowRunFailedEvent): void;
37
+ }
38
+ export declare function errorBridge(options: ErrorBridgeOptions): ErrorBridge;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * EvalRecorder — forwards `agentfootprint.eval.*` emits to the dispatcher.
3
+ *
4
+ * Pattern: Factory over EmitBridge.
5
+ * Role: Bridges consumer-emitted `eval.score` + `eval.threshold_crossed`
6
+ * events to typed listeners. Evaluation is a consumer concern
7
+ * (LLM-based grading, heuristic checks, reference-output diffs),
8
+ * so the library only provides transport — not any built-in
9
+ * evaluators.
10
+ * Emits: agentfootprint.eval.score / eval.threshold_crossed
11
+ */
12
+ import { EmitBridge, type EmitBridgeOptions } from './EmitBridge.js';
13
+ export type EvalRecorderOptions = Omit<EmitBridgeOptions, 'id' | 'prefix'> & {
14
+ readonly id?: string;
15
+ };
16
+ export declare function evalRecorder(options: EvalRecorderOptions): EmitBridge;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * MemoryRecorder — forwards `agentfootprint.memory.*` emits to the dispatcher.
3
+ *
4
+ * Pattern: Factory over EmitBridge.
5
+ * Role: Bridges memory-layer events (strategy_applied, attached,
6
+ * detached, written) emitted by consumer memory adapters.
7
+ * The library does not ship a memory implementation; consumers
8
+ * plug in their own store and emit these events where relevant
9
+ * (e.g., before/after sliding-window summarization).
10
+ * Emits: agentfootprint.memory.strategy_applied / attached /
11
+ * detached / written
12
+ */
13
+ import { EmitBridge, type EmitBridgeOptions } from './EmitBridge.js';
14
+ export type MemoryRecorderOptions = Omit<EmitBridgeOptions, 'id' | 'prefix'> & {
15
+ readonly id?: string;
16
+ };
17
+ export declare function memoryRecorder(options: MemoryRecorderOptions): EmitBridge;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * PermissionRecorder — forwards `agentfootprint.permission.*` emits
3
+ * to the dispatcher.
4
+ *
5
+ * Pattern: Factory over EmitBridge.
6
+ * Role: Bridges permission.check, permission.gate_opened, and
7
+ * permission.gate_closed emits into the typed dispatcher so
8
+ * consumer `.on('agentfootprint.permission.check', ...)`
9
+ * listeners fire.
10
+ * Emits: agentfootprint.permission.check / gate_opened / gate_closed
11
+ */
12
+ import { EmitBridge, type EmitBridgeOptions } from './EmitBridge.js';
13
+ export type PermissionRecorderOptions = Omit<EmitBridgeOptions, 'id' | 'prefix'> & {
14
+ readonly id?: string;
15
+ };
16
+ export declare function permissionRecorder(options: PermissionRecorderOptions): EmitBridge;
@@ -0,0 +1,24 @@
1
+ /**
2
+ * ReliabilityRecorder — forwards `agentfootprint.reliability.*` emits to
3
+ * the dispatcher.
4
+ *
5
+ * Pattern: Factory (GoF) returning an EmitBridge instance.
6
+ * Role: Bridges the rules-based reliability loop's telemetry
7
+ * (`reliability.fail_fast` / `reliability.retried` /
8
+ * `reliability.recovered`, emitted from `executeWithReliability`
9
+ * via `typedEmit`) to the EventDispatcher so typed consumer
10
+ * listeners (`agent.on('agentfootprint.reliability.retried', …)`)
11
+ * fire. Without this bridge those emits hit the footprintjs emit
12
+ * channel but never reach the dispatcher.
13
+ * Emits: agentfootprint.reliability.fail_fast / retried / recovered
14
+ *
15
+ * NOTE: this is the RULES-LOOP family. The generic `error.retried` /
16
+ * `error.recovered` events are reserved for the standalone provider
17
+ * decorators (withRetry/withFallback) and are NOT bridged here — see
18
+ * docs/MENTAL_MODEL.md §14.
19
+ */
20
+ import { EmitBridge, type EmitBridgeOptions } from './EmitBridge.js';
21
+ export type ReliabilityRecorderOptions = Omit<EmitBridgeOptions, 'id' | 'prefix'> & {
22
+ readonly id?: string;
23
+ };
24
+ export declare function reliabilityRecorder(options: ReliabilityRecorderOptions): EmitBridge;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * SkillRecorder — forwards `agentfootprint.skill.*` emits to the dispatcher.
3
+ *
4
+ * Pattern: Factory over EmitBridge.
5
+ * Role: Bridges skill lifecycle events (activated, deactivated) emitted
6
+ * by consumer skill-management code. Skills are a consumer-owned
7
+ * context-engineering concern; the library only provides transport.
8
+ * Emits: agentfootprint.skill.activated / skill.deactivated
9
+ */
10
+ import { EmitBridge, type EmitBridgeOptions } from './EmitBridge.js';
11
+ export type SkillRecorderOptions = Omit<EmitBridgeOptions, 'id' | 'prefix'> & {
12
+ readonly id?: string;
13
+ };
14
+ export declare function skillRecorder(options: SkillRecorderOptions): EmitBridge;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * StreamRecorder — forwards `agentfootprint.stream.*` emits to the dispatcher.
3
+ *
4
+ * Pattern: Factory (GoF) returning an EmitBridge instance.
5
+ * Role: Convenience constructor for the stream-domain bridge recorder.
6
+ * Stage code in LLMCall/Agent calls `typedEmit(scope, 'agentfootprint.stream.llm_start', {...})`;
7
+ * this recorder observes via footprintjs's EmitRecorder channel
8
+ * and re-dispatches with typed payloads + enriched meta.
9
+ * Emits: agentfootprint.stream.llm_start / llm_end / token / tool_start / tool_end
10
+ */
11
+ import { EmitBridge, type EmitBridgeOptions } from './EmitBridge.js';
12
+ export type StreamRecorderOptions = Omit<EmitBridgeOptions, 'id' | 'prefix'> & {
13
+ readonly id?: string;
14
+ };
15
+ export declare function streamRecorder(options: StreamRecorderOptions): EmitBridge;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * ToolsRecorder — forwards `agentfootprint.tools.*` emits to the dispatcher.
3
+ *
4
+ * Pattern: Factory over EmitBridge.
5
+ * Role: Bridges tool-domain events. Today: discovery_failed (emitted by
6
+ * buildToolsSlot when an external `ToolProvider.list(ctx)` throws
7
+ * or rejects). The other tools.* events (offered/activated/
8
+ * deactivated) are declared in the registry for consumer code
9
+ * that wants to emit them; the same prefix bridge forwards all
10
+ * of them.
11
+ * Emits: agentfootprint.tools.offered / tools.activated / tools.deactivated
12
+ * / tools.discovery_failed
13
+ */
14
+ import { EmitBridge, type EmitBridgeOptions } from './EmitBridge.js';
15
+ export type ToolsRecorderOptions = Omit<EmitBridgeOptions, 'id' | 'prefix'> & {
16
+ readonly id?: string;
17
+ };
18
+ export declare function toolsRecorder(options: ToolsRecorderOptions): EmitBridge;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * ValidationRecorder — forwards `agentfootprint.validation.*` emits to the
3
+ * dispatcher.
4
+ *
5
+ * Pattern: Factory over EmitBridge.
6
+ * Role: Bridges tool-args validation events (#9) emitted by the
7
+ * toolCalls stage when LLM-produced args fail the tool's declared
8
+ * `inputSchema` — so consumers observe rejected/warned calls via
9
+ * `agent.on('agentfootprint.validation.args_invalid', ...)`.
10
+ * Emits: agentfootprint.validation.args_invalid
11
+ */
12
+ import { EmitBridge, type EmitBridgeOptions } from './EmitBridge.js';
13
+ export type ValidationRecorderOptions = Omit<EmitBridgeOptions, 'id' | 'prefix'> & {
14
+ readonly id?: string;
15
+ };
16
+ export declare function validationRecorder(options: ValidationRecorderOptions): EmitBridge;
@@ -0,0 +1,136 @@
1
+ /**
2
+ * contextEngineering(agent) — first-class handle on the engineered
3
+ * subset of `context.injected` events.
4
+ *
5
+ * The Block A8 piece. agentfootprint already emits `context.injected`
6
+ * for EVERY piece of content that lands in a slot — including the
7
+ * baseline flow (the user message, every tool result, the static
8
+ * system prompt). For a developer who wants to inspect what their
9
+ * RAG / Skills / Memory / Instructions / Steering / Facts ARE
10
+ * INJECTING (the actual context-engineering work), the baseline flow
11
+ * is noise.
12
+ *
13
+ * `contextEngineering(agent)` filters the stream to ONLY the
14
+ * engineered injections and gives consumers two cleaner subscriptions:
15
+ *
16
+ * - `onEngineered(cb)` — fires for `source` ∈ {rag, skill, memory,
17
+ * instructions, steering, fact, custom}. The actual
18
+ * context-engineering work.
19
+ * - `onBaseline(cb)` — fires for `source` ∈ {user, tool-result,
20
+ * assistant, base, registry}. The baseline message-history flow.
21
+ *
22
+ * Use cases:
23
+ * - **Lens UI**: render only engineered injections in the "context
24
+ * bin"; show the baseline flow as edges between iterations.
25
+ * - **Eval pipelines**: count how many RAG chunks vs Memory entries
26
+ * vs Skill bodies entered the prompt for an eval-set query.
27
+ * - **Cost attribution**: sum tokens by `source` to know what
28
+ * fraction of spend is RAG vs Skills vs baseline.
29
+ * - **Debug logging**: tail just the engineered signals to spot
30
+ * surprising activations during dev.
31
+ *
32
+ * Pattern: Strategy + Filter (GoF) — pure classifier function over
33
+ * the existing `context.injected` event payload, paired with
34
+ * a thin subscription helper.
35
+ *
36
+ * Role: Layer-2 (event taxonomy) consumer-side helper. Doesn't
37
+ * emit new events; doesn't change the agent's flowchart.
38
+ * Pure observation.
39
+ *
40
+ * @example
41
+ * import { contextEngineering } from 'agentfootprint';
42
+ *
43
+ * const ce = contextEngineering(agent);
44
+ * ce.onEngineered((e) => {
45
+ * console.log(`[${e.payload.source}] ${e.payload.contentSummary}`);
46
+ * });
47
+ * ce.onBaseline((e) => {
48
+ * console.log(`[baseline:${e.payload.source}]`);
49
+ * });
50
+ *
51
+ * await agent.run({ message: 'help me' });
52
+ * // ... runs; engineered + baseline streams fire separately
53
+ *
54
+ * ce.detach(); // stops both subscriptions; the agent itself is fine
55
+ */
56
+ import type { AgentfootprintEventMap } from '../../events/registry.js';
57
+ import type { ContextSource } from '../../events/types.js';
58
+ /**
59
+ * Public set of "engineered" sources — the context-engineering
60
+ * primitives that consumers configure (RAG, Skills, Memory,
61
+ * Instructions, Steering, Facts) plus user-defined `custom`.
62
+ *
63
+ * Frozen so consumers can `.has(value)` directly without copy.
64
+ */
65
+ export declare const ENGINEERED_SOURCES: ReadonlySet<ContextSource>;
66
+ /**
67
+ * Public set of "baseline" sources — the message-history flow that
68
+ * exists regardless of context engineering: user input, tool results,
69
+ * assistant outputs, the always-on system prompt anchor (`base`), and
70
+ * the agent's static tool registry advertisement (`registry`).
71
+ */
72
+ export declare const BASELINE_SOURCES: ReadonlySet<ContextSource>;
73
+ /**
74
+ * Pure classifier: given a `ContextSource`, is it engineered?
75
+ *
76
+ * Useful for ad-hoc filtering on a raw `agent.on('agentfootprint.context.injected', ...)`
77
+ * subscription when you don't need the wrapper helper.
78
+ */
79
+ export declare function isEngineeredSource(source: ContextSource): boolean;
80
+ /**
81
+ * Pure classifier: given a `ContextSource`, is it baseline?
82
+ */
83
+ export declare function isBaselineSource(source: ContextSource): boolean;
84
+ /**
85
+ * The shape of the event passed to `onEngineered` / `onBaseline`
86
+ * callbacks. Same as `agentfootprint.context.injected`'s envelope —
87
+ * we don't transform it, just route by source.
88
+ */
89
+ export type ContextInjectedEvent = AgentfootprintEventMap['agentfootprint.context.injected'];
90
+ /** Listener signature for the wrapper helper. */
91
+ export type ContextInjectedListener = (event: ContextInjectedEvent) => void;
92
+ /** Unsubscribe handle. */
93
+ export type ContextEngineeringUnsubscribe = () => void;
94
+ /**
95
+ * Minimal subset of the agent surface this helper depends on.
96
+ * Lets us accept any runner (Agent, LLMCall, Sequence, etc.) that
97
+ * implements the typed `on(type, cb)` subscription API.
98
+ */
99
+ interface RunnerWithEvents {
100
+ on(type: 'agentfootprint.context.injected', listener: ContextInjectedListener): ContextEngineeringUnsubscribe;
101
+ }
102
+ /**
103
+ * Handle returned by `contextEngineering(agent)`. Lets consumers
104
+ * subscribe to engineered / baseline streams and detach cleanly.
105
+ */
106
+ export interface ContextEngineeringHandle {
107
+ /**
108
+ * Fires for `context.injected` events whose source is in
109
+ * `ENGINEERED_SOURCES`. Returns an unsubscribe function.
110
+ */
111
+ onEngineered(listener: ContextInjectedListener): ContextEngineeringUnsubscribe;
112
+ /**
113
+ * Fires for `context.injected` events whose source is in
114
+ * `BASELINE_SOURCES`. Returns an unsubscribe function.
115
+ */
116
+ onBaseline(listener: ContextInjectedListener): ContextEngineeringUnsubscribe;
117
+ /**
118
+ * Detach all subscriptions registered through this handle. After
119
+ * calling, no further callbacks will fire. Idempotent (safe to
120
+ * call multiple times).
121
+ */
122
+ detach(): void;
123
+ }
124
+ /**
125
+ * Wrap a runner's `agentfootprint.context.injected` stream into two
126
+ * filtered subscriptions: engineered + baseline. Multiple listeners
127
+ * per stream are allowed; `detach()` removes all of them.
128
+ *
129
+ * The classifier inspects `event.payload.source`. Unknown sources
130
+ * (forward-compat: `ContextSource` is open-extensible) are routed
131
+ * to NEITHER stream — preferring under-firing over miscategorizing.
132
+ * Use `agent.on('agentfootprint.context.injected', ...)` directly
133
+ * if you need to observe sources that aren't (yet) classified.
134
+ */
135
+ export declare function contextEngineering(agent: RunnerWithEvents): ContextEngineeringHandle;
136
+ export {};
@@ -0,0 +1,34 @@
1
+ /**
2
+ * typedEmit — typed facade over footprintjs's `scope.$emit(name, payload)`.
3
+ *
4
+ * Pattern: Facade (GoF) over an untyped API.
5
+ * Role: Stage code inside LLMCall/Agent/slot subflows calls this helper
6
+ * to emit events. The EventMap + TS generics reject typos and
7
+ * payload drift at compile time; the runtime call is identical
8
+ * to footprintjs's `$emit`.
9
+ * Emits: Whatever `T` is — the consumer passes the type and payload.
10
+ */
11
+ import type { AgentfootprintEventMap, AgentfootprintEventType } from '../../events/registry.js';
12
+ /**
13
+ * Minimal scope surface we need to emit — structurally compatible with
14
+ * footprintjs's `TypedScope<T>`, whose `$emit(name, payload?: unknown)` is
15
+ * wider than this.
16
+ */
17
+ interface EmitableScope {
18
+ $emit(name: string, payload?: unknown): void;
19
+ }
20
+ /**
21
+ * Emit a typed event from inside stage code.
22
+ *
23
+ * @example
24
+ * typedEmit(scope, 'agentfootprint.stream.llm_start', {
25
+ * iteration: 1,
26
+ * provider: 'anthropic',
27
+ * model: 'claude-opus-4-8',
28
+ * systemPromptChars: 800,
29
+ * messagesCount: 2,
30
+ * toolsCount: 0,
31
+ * });
32
+ */
33
+ export declare function typedEmit<K extends AgentfootprintEventType>(scope: EmitableScope, type: K, payload: AgentfootprintEventMap[K]['payload']): void;
34
+ export {};
@@ -0,0 +1,97 @@
1
+ /**
2
+ * Recorder-layer types — shapes builders use to communicate with recorders.
3
+ *
4
+ * Pattern: Data Transfer Object (Fowler, PoEAA).
5
+ * Role: Shared vocabulary between builders (which WRITE injections) and
6
+ * recorders (which OBSERVE those writes and emit grouped events).
7
+ */
8
+ import type { ContextLifetime, ContextRecency, ContextRole, ContextSlot, ContextSource } from '../../events/types.js';
9
+ /**
10
+ * An injection record written by a slot subflow into `scope[INJECTION_KEYS[slot]]`.
11
+ * ContextRecorder reads this to construct the corresponding event payload.
12
+ *
13
+ * Builders write arrays of these; recorders diff old-vs-new to detect NEW
14
+ * injections.
15
+ */
16
+ export interface InjectionRecord {
17
+ /** Short human-readable content summary. */
18
+ readonly contentSummary: string;
19
+ /** Full content (may be redacted downstream). Optional. */
20
+ readonly rawContent?: string;
21
+ /** Stable hash of the content — enables duplicate detection. */
22
+ readonly contentHash: string;
23
+ /** The 3-slot target (sanity-checked against the subflow ID). */
24
+ readonly slot: ContextSlot;
25
+ /** Where this content came from. */
26
+ readonly source: ContextSource;
27
+ /** Optional source-specific identifier (retriever id, skill id, ...). */
28
+ readonly sourceId?: string;
29
+ /** Upstream event reference (runtimeStageId that produced the content). */
30
+ readonly upstreamRef?: string;
31
+ /** Why this was injected. */
32
+ readonly reason: string;
33
+ /** Role, when injecting into messages slot. */
34
+ readonly asRole?: ContextRole;
35
+ /** Recency, when injecting into messages slot. */
36
+ readonly asRecency?: ContextRecency;
37
+ /** Position within the slot (messages index, system-prompt section order). */
38
+ readonly position?: number;
39
+ /** Section tag for structured system prompts (e.g. "<skill>", "<retrieved>"). */
40
+ readonly sectionTag?: string;
41
+ /** Retrieval / ranking evidence. */
42
+ readonly retrievalScore?: number;
43
+ readonly rankPosition?: number;
44
+ readonly threshold?: number;
45
+ readonly budgetSpent?: {
46
+ readonly tokens: number;
47
+ readonly fractionOfCap: number;
48
+ };
49
+ /** How long this injection is expected to persist. */
50
+ readonly expiresAfter?: ContextLifetime;
51
+ }
52
+ /**
53
+ * Slot composition summary — written by a slot subflow at the END of its
54
+ * composition pass. ContextRecorder emits one `context.slot_composed`
55
+ * event per slot exit, built from this record.
56
+ */
57
+ export interface SlotComposition {
58
+ readonly slot: ContextSlot;
59
+ readonly iteration: number;
60
+ readonly budget: {
61
+ readonly cap: number;
62
+ readonly used: number;
63
+ readonly headroomChars: number;
64
+ };
65
+ readonly sourceBreakdown: Readonly<Partial<Record<ContextSource, {
66
+ readonly chars: number;
67
+ readonly count: number;
68
+ }>>>;
69
+ readonly orderingStrategy?: string;
70
+ readonly droppedCount: number;
71
+ readonly droppedSummaries: readonly string[];
72
+ }
73
+ /**
74
+ * Eviction record — a piece that was removed from a slot under pressure.
75
+ */
76
+ export interface EvictionRecord {
77
+ readonly slot: ContextSlot;
78
+ readonly contentHash: string;
79
+ readonly reason: 'budget' | 'stale' | 'low_score' | 'policy' | 'user_revoked';
80
+ readonly survivalMs: number;
81
+ }
82
+ /**
83
+ * Budget-pressure warning — emitted before evictions fire.
84
+ */
85
+ export interface BudgetPressureRecord {
86
+ readonly slot: ContextSlot;
87
+ readonly capTokens: number;
88
+ readonly projectedTokens: number;
89
+ readonly overflowBy: number;
90
+ readonly planAction: 'evict' | 'summarize' | 'abort';
91
+ }
92
+ export declare const COMPOSITION_KEYS: {
93
+ readonly SLOT_COMPOSED: "slotCompositions";
94
+ readonly EVICTED: "slotEvictions";
95
+ readonly BUDGET_PRESSURE: "slotBudgetPressures";
96
+ };
97
+ export type CompositionKey = (typeof COMPOSITION_KEYS)[keyof typeof COMPOSITION_KEYS];