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,203 @@
1
+ /**
2
+ * Runner — consumer-facing interface for every primitive/composition/pattern.
3
+ *
4
+ * Pattern: Facade (GoF) over the footprintjs FlowChart + EventDispatcher.
5
+ * Role: The one object consumers hold. Exposes:
6
+ * - `.run()` (execute)
7
+ * - `.getSpec()` (the design-time FlowChart blueprint —
8
+ * same value footprintjs's `addSubFlowChart*` accepts)
9
+ * - `.on() / .off() / .once()` (listener subscription)
10
+ * - `.attach()` (attach custom CombinedRecorder)
11
+ * - `.emit()` (consumer-defined custom events on the same
12
+ * dispatcher, matches DOM CustomEvent)
13
+ * Emits: N/A — this file defines the INTERFACE. Concrete runners
14
+ * (LLMCall, Agent, Sequence, etc.) implement it.
15
+ */
16
+ import type { CombinedRecorder, FlowChart, FlowchartCheckpoint, RunOptions } from 'footprintjs';
17
+ import type { RunnerPauseOutcome } from './pause.js';
18
+ import type { EventListener, ListenOptions, Unsubscribe, WildcardListener, WildcardSubscription } from '../events/dispatcher.js';
19
+ import type { AgentfootprintEvent, AgentfootprintEventType } from '../events/registry.js';
20
+ import type { FlowchartHandle, FlowchartOptions } from '../recorders/observability/FlowchartRecorder.js';
21
+ import type { LocalObservabilityHandle, LocalObservabilityOptions } from '../recorders/observability/localObservability.js';
22
+ import type { ObservabilityEnableOptions, CostEnableOptions, LiveStatusEnableOptions } from '../strategies/attach.js';
23
+ /**
24
+ * High-level feature-enable methods. Each attaches a pre-built observability
25
+ * recorder and returns an Unsubscribe function. Additional methods land in
26
+ * Phase 5 (lens, tracing, cost, guardrails, ...).
27
+ */
28
+ export interface EnableNamespace {
29
+ /**
30
+ * Live composition graph — subflow / fork-branch / decision-branch
31
+ * nodes accumulate as execution unfolds. Hook into any graph renderer
32
+ * (React Flow, Cytoscape, D3) without touching footprintjs internals.
33
+ *
34
+ * Returns a handle with `getSnapshot()` so the UI can query the graph
35
+ * at any time (not just via onUpdate).
36
+ */
37
+ flowchart(opts?: FlowchartOptions): FlowchartHandle;
38
+ /**
39
+ * Tier-3 / Debug — RETAIN a live run model: render it live via
40
+ * `<Lens recorder={handle} />` (the handle's `onUpdate` drives the UI) AND
41
+ * snapshot it for OFFLINE replay via `handle.getTrace()` / `onComplete`.
42
+ *
43
+ * Contrast `observability({ strategy })` below (Tier-4 / Monitor), which
44
+ * ships each event to a vendor and forgets. `localObservability` keeps the
45
+ * model so you can look at it — locally, with full content. The serialized
46
+ * `Trace` is redactable at the serialize boundary (`redact` / `getTrace`).
47
+ */
48
+ localObservability(opts?: LocalObservabilityOptions): LocalObservabilityHandle;
49
+ /**
50
+ * v2.8+ — grouped strategy enabler for observability. Pipes every
51
+ * typed event into a vendor strategy (Datadog, OTel, AgentCore,
52
+ * CloudWatch, …) or the default `consoleObservability()`. See
53
+ * `agentfootprint/strategies` + `docs/inspiration/strategy-everywhere.md`.
54
+ */
55
+ observability(opts?: ObservabilityEnableOptions): Unsubscribe;
56
+ /**
57
+ * v2.8+ — grouped strategy enabler for cost. Subscribes the strategy
58
+ * to `cost.tick` events; defaults to `inMemorySinkCost()` for
59
+ * read-back / test inspection.
60
+ */
61
+ cost(opts?: CostEnableOptions): Unsubscribe;
62
+ /**
63
+ * v2.8+ — grouped strategy enabler for chat-bubble live status.
64
+ * Maintains the thinking-state machine; calls strategy.renderStatus
65
+ * each time the rendered line changes (deduped — not on every token).
66
+ * Strategy is required (consumer must wire UI).
67
+ */
68
+ liveStatus(opts: LiveStatusEnableOptions): Unsubscribe;
69
+ }
70
+ /**
71
+ * Every primitive (LLMCall, Agent), every composition (Sequence, Parallel,
72
+ * Conditional, Loop), and every pattern factory result implements Runner.
73
+ * That makes them freely nestable: any runner can be a child of any
74
+ * composition.
75
+ */
76
+ export interface Runner<TIn = unknown, TOut = unknown> {
77
+ /**
78
+ * Return the footprintjs FlowChart for this runner — the canonical
79
+ * design-time blueprint. Stable across calls. Pairs with the run-time
80
+ * accessors (`getLastSnapshot`, `getCommitCount`) and matches
81
+ * `ExplainableShell.spec` + `specToReactFlow(spec, ...)` consumer
82
+ * conventions.
83
+ *
84
+ * Subflow mounting (footprintjs `addSubFlowChart*`) accepts the
85
+ * `FlowChart` value directly:
86
+ *
87
+ * parent.addSubFlowChartNext('sf-agent', child.getSpec(), 'Agent')
88
+ */
89
+ getSpec(): FlowChart;
90
+ /**
91
+ * Return the consumer-shaped UI group for this runner — produced by
92
+ * invoking the `groupTranslator` (if one was attached at constructor
93
+ * time) with this composition's metadata. Returns `undefined` when no
94
+ * translator was attached.
95
+ *
96
+ * Companion of `getSpec()`: `getSpec()` is the canonical (UI-
97
+ * agnostic) blueprint; `getUIGroup()` is the consumer-shaped view.
98
+ * Both are stable post-construction.
99
+ *
100
+ * See `core/translator.ts` for the `GroupTranslator` /
101
+ * `GroupMetadata` types.
102
+ */
103
+ getUIGroup<T = unknown>(): T | undefined;
104
+ /**
105
+ * Translate this runner's group metadata with a CALLER-SUPPLIED
106
+ * translator that OVERRIDES whatever translator (if any) the runner
107
+ * was constructed with. Used by parent compositions to apply
108
+ * per-method translator overrides (e.g.,
109
+ * `Parallel.create(...).branch('special', runner, { groupTranslator: ... })`
110
+ * — for the `'special'` branch only, this `override` runs against
111
+ * `runner`'s own `GroupMetadata` instead of the runner's default
112
+ * translator).
113
+ *
114
+ * NOT cached at the runner level. The caller invokes this exactly
115
+ * once per build (parent's `buildUIGroupMetadata`) and caches the
116
+ * resulting `uiGroup` via the parent's `RunnerBase.uiGroupCache`.
117
+ *
118
+ * Returns `undefined` when this runner has no group metadata to
119
+ * translate (i.e., `buildUIGroupMetadata()` returned `undefined`).
120
+ */
121
+ getUIGroupWith<T = unknown>(override: import('./translator.js').GroupTranslator): T | undefined;
122
+ /**
123
+ * Execute the runner. On happy-path completion, resolves with `TOut`.
124
+ * If any stage (Agent tool via `pauseHere`, nested runner, or consumer
125
+ * scope code) called `scope.$pause()`, resolves with a `RunnerPauseOutcome`
126
+ * carrying the serializable checkpoint. Discriminate with `isPaused()`.
127
+ */
128
+ run(input: TIn, options?: RunOptions): Promise<TOut | RunnerPauseOutcome>;
129
+ /**
130
+ * Resume a previously-paused execution from its checkpoint. `input` is
131
+ * delivered to the paused stage's resume handler. The same return shape
132
+ * as `run()`: `TOut` on completion, `RunnerPauseOutcome` if execution
133
+ * pauses again (e.g., a multi-step approval flow).
134
+ */
135
+ resume(checkpoint: FlowchartCheckpoint, input?: unknown, options?: RunOptions): Promise<TOut | RunnerPauseOutcome>;
136
+ /**
137
+ * Subscribe a typed listener. Returns unsubscribe.
138
+ *
139
+ * Lifecycle: the subscription lives until you call the returned
140
+ * Unsubscribe, the `{ signal }` you passed aborts, or
141
+ * `removeAllListeners()` runs. Nothing auto-expires per-run — pass a
142
+ * per-run AbortSignal for request-scoped listeners on long-lived
143
+ * runners (servers).
144
+ */
145
+ on<K extends AgentfootprintEventType>(type: K, listener: EventListener<K>, options?: ListenOptions): Unsubscribe;
146
+ /** Subscribe to a domain wildcard (e.g. 'agentfootprint.context.*') or '*'. */
147
+ on(type: WildcardSubscription, listener: WildcardListener, options?: ListenOptions): Unsubscribe;
148
+ /** Unsubscribe a previously-registered listener. */
149
+ off<K extends AgentfootprintEventType>(type: K, listener: EventListener<K>): void;
150
+ off(type: WildcardSubscription, listener: WildcardListener): void;
151
+ /** Subscribe a one-shot listener (fires once then auto-removes). Accepts `{ signal }`. */
152
+ once<K extends AgentfootprintEventType>(type: K, listener: EventListener<K>, options?: Omit<ListenOptions, 'once'>): Unsubscribe;
153
+ once(type: WildcardSubscription, listener: WildcardListener, options?: Omit<ListenOptions, 'once'>): Unsubscribe;
154
+ /**
155
+ * Drop every event listener on this runner in one call (typed,
156
+ * domain-wildcard, and `'*'`). Lifecycle escape hatch for server
157
+ * consumers that can't keep Unsubscribe handles. Also removes
158
+ * listeners wired by `enable.*` strategies; does NOT detach recorders
159
+ * added via `attach()`.
160
+ */
161
+ removeAllListeners(): void;
162
+ /**
163
+ * Diagnostic — listeners currently retained. No argument = total
164
+ * (the leak-detection number); with a subscription key = that exact
165
+ * bucket only (wildcards not folded in — use the dispatcher's
166
+ * `hasListenersFor` semantics for "would anything fire").
167
+ */
168
+ listenerCount(type?: AgentfootprintEventType | WildcardSubscription): number;
169
+ /**
170
+ * Attach a footprintjs CombinedRecorder to observe the execution.
171
+ * Returns an unsubscribe function — call it to detach the recorder
172
+ * from future runs. (Already-running executions continue using it.)
173
+ *
174
+ * Recorders live for the RUNNER's lifetime: nothing auto-expires
175
+ * per-run, and `removeAllListeners()` does not touch them. The caller
176
+ * owns cleanup via the returned Unsubscribe.
177
+ */
178
+ attach(recorder: CombinedRecorder): Unsubscribe;
179
+ /**
180
+ * Enable-namespace for high-level observability features. Each method
181
+ * attaches a pre-built CombinedRecorder and returns an unsubscribe
182
+ * function. Consumers write ONE line to enable rich observability,
183
+ * instead of N `.on()` subscriptions.
184
+ */
185
+ readonly enable: EnableNamespace;
186
+ /**
187
+ * Emit a consumer-defined custom event through the same dispatcher.
188
+ *
189
+ * Matches DOM CustomEvent. Useful for domain-specific events outside
190
+ * the 47-event registry (e.g. `myapp.billing.checkpoint`). Library
191
+ * events are reserved under the `agentfootprint.*` namespace.
192
+ */
193
+ emit(name: string, payload: Record<string, unknown>): void;
194
+ }
195
+ /** Kept for convenience — mirrors the RunOptions export from footprintjs. */
196
+ export type { RunOptions };
197
+ /**
198
+ * Union used in emit() for the `AgentfootprintEvent` type constraint. A
199
+ * consumer emitting a custom event passes a plain object payload; the
200
+ * dispatcher wraps it as AgentfootprintEvent only when the name is a
201
+ * registered type. Otherwise it flows through as an opaque custom event.
202
+ */
203
+ export type EmittedEvent = AgentfootprintEvent;
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Messages slot subflow builder
3
+ *
4
+ * Pattern: Builder (returns a FlowChart mountable via addSubFlowChartNext).
5
+ * Role: Layer-3 context engineering. Produces InjectionRecord[] from
6
+ * the current conversation history. For LLMCall, that's one
7
+ * user message. For Agent, it's user + assistant + tool-result
8
+ * messages accumulated over iterations.
9
+ * Emits: None directly; ContextRecorder sees the writes.
10
+ *
11
+ * Minimal scope for Phase 3e: pass-through of an input message history
12
+ * array. Full MessageStrategy (windowing, summarizing) arrives in Phase 5.
13
+ */
14
+ import type { FlowChart } from 'footprintjs';
15
+ import type { ContextRole } from '../../events/types.js';
16
+ /**
17
+ * A single message supplied by the caller. Structurally matches the
18
+ * LLMMessage adapter type but local-aliased to keep this file free of
19
+ * adapter-layer coupling.
20
+ */
21
+ export interface InputMessage {
22
+ readonly role: ContextRole;
23
+ readonly content: string;
24
+ readonly toolCallId?: string;
25
+ readonly toolName?: string;
26
+ }
27
+ export interface MessagesSlotConfig {
28
+ /** Budget cap (chars). Default: 10000. */
29
+ readonly budgetCap?: number;
30
+ }
31
+ /**
32
+ * Build the Messages slot subflow.
33
+ *
34
+ * Mount with:
35
+ * builder.addSubFlowChartNext(SUBFLOW_IDS.MESSAGES, buildMessagesSlot(cfg), 'Messages', {
36
+ * inputMapper: (parent) => ({ messages: parent.messages, iteration: parent.iteration }),
37
+ * outputMapper: (sf) => ({ messagesInjections: sf.messagesInjections }),
38
+ * })
39
+ */
40
+ export declare function buildMessagesSlot(config?: MessagesSlotConfig): FlowChart;
@@ -0,0 +1,41 @@
1
+ /**
2
+ * System-Prompt slot subflow builder
3
+ *
4
+ * Pattern: Builder (returns a FlowChart mountable via addSubFlowChartNext).
5
+ * Role: Layer-3 context engineering; inside Layer-5 primitives
6
+ * (LLMCall, Agent). Ported from v1's buildSystemPromptSubflow
7
+ * to InjectionRecord + SlotComposition shape.
8
+ * Emits: None directly. Writes to conventional scope keys; ContextRecorder
9
+ * observes and emits context.* events.
10
+ *
11
+ * Minimal scope for Phase 3e: static prompt string OR a dynamic function
12
+ * of the input. Full SystemPromptProvider / Skill / RAG integration
13
+ * arrives in Phase 5.
14
+ */
15
+ import type { FlowChart } from 'footprintjs';
16
+ /**
17
+ * Function that produces the system prompt string given runtime scope
18
+ * context. Receives the subflow's $getArgs() payload.
19
+ */
20
+ export type SystemPromptFn = (args: {
21
+ readonly userMessage?: string;
22
+ readonly iteration?: number;
23
+ }) => string | Promise<string>;
24
+ export interface SystemPromptSlotConfig {
25
+ /** Static string OR a function. Empty string → no injection, empty slot. */
26
+ readonly prompt: string | SystemPromptFn;
27
+ /** Budget cap (chars). Default: 4000. */
28
+ readonly budgetCap?: number;
29
+ /** Optional description — where this prompt originated (e.g. "agent.system()"). */
30
+ readonly reason?: string;
31
+ }
32
+ /**
33
+ * Build the System-Prompt slot subflow.
34
+ *
35
+ * Mount with:
36
+ * builder.addSubFlowChartNext(SUBFLOW_IDS.SYSTEM_PROMPT, buildSystemPromptSlot(cfg), 'System Prompt', {
37
+ * inputMapper: (parent) => ({ userMessage: parent.userMessage, iteration: parent.iteration }),
38
+ * outputMapper: (sf) => ({ systemPromptInjections: sf.systemPromptInjections }),
39
+ * })
40
+ */
41
+ export declare function buildSystemPromptSlot(config: SystemPromptSlotConfig): FlowChart;
@@ -0,0 +1,40 @@
1
+ /**
2
+ * NormalizeThinking sub-subflow — wraps a consumer's `ThinkingHandler`
3
+ * (function-pair contract) in a real footprintjs subflow at chart
4
+ * build time. Mounted as a stage AFTER CallLLM inside `sf-call-llm`
5
+ * when (and only when) a handler is configured.
6
+ *
7
+ * runtimeStageId format: `sf-call-llm/thinking-{handler.id}#N`
8
+ *
9
+ * Two-layer architecture (per Phase 1 panel decision):
10
+ * - CONSUMER-FACING: `ThinkingHandler` — simple function-pair
11
+ * (id, providerNames, normalize, parseChunk?)
12
+ * - FRAMEWORK-INTERNAL: this file wraps each handler in a real
13
+ * footprintjs subflow with own runtimeStageId,
14
+ * narrative entry, and InOutRecorder boundary.
15
+ *
16
+ * Failure isolation: handler `normalize()` throws are caught here.
17
+ * Framework emits `agentfootprint.agent.thinking_parse_failed`, sets
18
+ * `scope.thinkingBlocks` to empty, and the subflow exits cleanly. The
19
+ * agent run continues; the assistant message simply has no thinking
20
+ * blocks attached. Same graceful pattern as v2.11.6 `tools.discovery_failed`.
21
+ */
22
+ import type { FlowChart } from 'footprintjs';
23
+ import type { ThinkingHandler } from '../../thinking/types.js';
24
+ /**
25
+ * Build a thinking-normalization sub-subflow for a configured handler.
26
+ * Mounted as a single-stage subflow inside `sf-call-llm` AFTER CallLLM.
27
+ *
28
+ * The subflow:
29
+ * 1. Reads `scope.rawThinking` (set by CallLLM from `LLMResponse.rawThinking`)
30
+ * 2. If rawThinking is undefined → write empty array, exit (early-return)
31
+ * 3. Calls `handler.normalize(rawThinking)`
32
+ * 4. On success: writes `scope.thinkingBlocks` + emits `stream.thinking_end`
33
+ * 5. On throw: writes empty array + emits `agent.thinking_parse_failed`
34
+ *
35
+ * The result on `scope.thinkingBlocks` is read by toolCalls.ts and
36
+ * prepareFinal.ts when constructing the assistant message for
37
+ * `scope.history` — that's where the Anthropic signature round-trip
38
+ * actually flows from.
39
+ */
40
+ export declare function buildThinkingSubflow(handler: ThinkingHandler): FlowChart;
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Tools slot subflow builder
3
+ *
4
+ * Pattern: Builder (returns a FlowChart mountable via addSubFlowChartNext).
5
+ * Role: Layer-3 context engineering. Resolves the tools list the LLM
6
+ * sees on this iteration — one InjectionRecord per exposed tool.
7
+ * Emits: None directly; ContextRecorder sees the writes.
8
+ *
9
+ * Minimal scope for Phase 3e: static tool registry, all exposed every
10
+ * iteration. Full permission gating / skill activation / context-aware
11
+ * tool filtering arrives in Phase 5.
12
+ */
13
+ import type { FlowChart } from 'footprintjs';
14
+ import type { LLMToolSchema } from '../../adapters/types.js';
15
+ import type { Tool } from '../tools.js';
16
+ import type { ToolProvider } from '../../tool-providers/types.js';
17
+ /**
18
+ * Mutable cache shared between `buildToolsSlot` (writer) and
19
+ * `buildToolCallsHandler` (reader) within ONE run. The Tools slot
20
+ * resolves the provider's tools each iteration and stashes the
21
+ * Tool[] here; the toolCalls handler reads on dispatch — so async
22
+ * providers pay the discovery cost once, not twice. Scoped to the
23
+ * chart build so concurrent `agent.run()` calls each get their own
24
+ * cache.
25
+ */
26
+ export interface ProviderToolCache {
27
+ current: readonly Tool[];
28
+ }
29
+ export interface ToolsSlotConfig {
30
+ /** Tool registry exposed to the LLM. Empty → empty slot (LLMCall case). */
31
+ readonly tools: readonly LLMToolSchema[];
32
+ /**
33
+ * Optional `ToolProvider` consulted PER-ITERATION (Block A5 follow-up).
34
+ * When set, the slot calls `provider.list(ctx)` each iteration with
35
+ * the current `{ iteration, activeSkillId, identity, signal }`.
36
+ * Provider-supplied tool schemas are MERGED with the static `tools`
37
+ * registry — both flow to the LLM. This is what makes Dynamic ReAct's
38
+ * tool list reshape per iteration.
39
+ */
40
+ readonly toolProvider?: ToolProvider;
41
+ /**
42
+ * Mutable cache the slot writes to after resolving `toolProvider.list(ctx)`.
43
+ * The same cache reference is passed to `buildToolCallsHandler` so
44
+ * dispatch reads from this iteration's resolved Tool[] instead of
45
+ * calling `list()` a second time. Required when `toolProvider` is set.
46
+ */
47
+ readonly providerToolCache?: ProviderToolCache;
48
+ /** Budget cap (chars). Default: 2000. */
49
+ readonly budgetCap?: number;
50
+ }
51
+ /**
52
+ * Build the Tools slot subflow.
53
+ *
54
+ * Mount with:
55
+ * builder.addSubFlowChartNext(SUBFLOW_IDS.TOOLS, buildToolsSlot(cfg), 'Tools', {
56
+ * inputMapper: (parent) => ({ iteration: parent.iteration }),
57
+ * outputMapper: (sf) => ({ toolsInjections: sf.toolsInjections, toolSchemas: sf.toolSchemas }),
58
+ * })
59
+ */
60
+ export declare function buildToolsSlot(config: ToolsSlotConfig): FlowChart;
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Shared helpers for slot subflow builders.
3
+ *
4
+ * Pattern: utility module.
5
+ * Role: Tiny pure functions the slot builders share — hash, truncate,
6
+ * breakdown. Kept co-located to avoid cross-package import churn.
7
+ */
8
+ import type { ContextSource, ContextSlot } from '../../events/types.js';
9
+ import type { InjectionRecord, SlotComposition } from '../../recorders/core/types.js';
10
+ /** Non-cryptographic stable hash — sufficient for InjectionRecord dedup. */
11
+ export declare function fnv1a(input: string): string;
12
+ /** Truncate with ellipsis for contentSummary fields. */
13
+ export declare function truncate(s: string, n: number): string;
14
+ /** Aggregate injection chars/count per source — payload for SlotComposition. */
15
+ export declare function breakdown(injections: readonly InjectionRecord[]): Readonly<Partial<Record<ContextSource, {
16
+ chars: number;
17
+ count: number;
18
+ }>>>;
19
+ /**
20
+ * Build a SlotComposition summary record from injections + budget cap.
21
+ * Drop tracking is opt-in — pass `dropped` when the slot actually
22
+ * evicted anything during composition.
23
+ */
24
+ export declare function composeSlot(slot: ContextSlot, iteration: number, injections: readonly InjectionRecord[], budgetCap: number, orderingStrategy?: string, dropped?: {
25
+ count: number;
26
+ summaries: readonly string[];
27
+ }): SlotComposition;
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Agent ↔ tool-server contract check (proposal 009, the server-boundary extension).
3
+ *
4
+ * When an agent's tools call a remote tool-server (an MCP-ish sidecar, a function
5
+ * gateway), the agent's `inputSchema` and the server's real contract can drift —
6
+ * and the model then calls a tool that 404s, or omits an arg the server REQUIRES and
7
+ * gets a 501/400 "doesn't work." The server usually publishes its own catalog
8
+ * (e.g. `GET /tools` → `[{ name, inputSchema }]`), so the drift is checkable.
9
+ *
10
+ * `toolContractCheckup(agentTools, serverCatalog)` is a PURE diff (no I/O — the
11
+ * consumer fetches the catalog and passes it). It mirrors the `graph.checkup()`
12
+ * shape so both feed the same reporting.
13
+ */
14
+ import type { Tool } from './tools.js';
15
+ export type ToolContractCode = 'missing-on-server' | 'dead-endpoint' | 'required-divergence' | 'arg-divergence' | 'optional-drift';
16
+ /** One contract issue. `kind: 'error'` fails `ok`. */
17
+ export interface ToolContractProblem {
18
+ readonly kind: 'error' | 'warning';
19
+ readonly code: ToolContractCode;
20
+ readonly tool: string;
21
+ readonly message: string;
22
+ }
23
+ export interface ToolContractCheckup {
24
+ readonly ok: boolean;
25
+ readonly problems: readonly ToolContractProblem[];
26
+ }
27
+ /** A server-catalog entry — the shape of one item from `GET /tools`. */
28
+ export interface ServerToolEntry {
29
+ readonly name: string;
30
+ readonly inputSchema?: {
31
+ readonly required?: readonly string[];
32
+ readonly properties?: Readonly<Record<string, unknown>>;
33
+ };
34
+ }
35
+ /**
36
+ * Diff an agent's tools against a server's tool catalog. Pure + deterministic.
37
+ *
38
+ * @param agentTools the agent's tools (`Tool[]` or `{name, inputSchema}[]`)
39
+ * @param serverCatalog the server's catalog (e.g. `await (await fetch('/tools')).json()`)
40
+ */
41
+ export declare function toolContractCheckup(agentTools: ReadonlyArray<Tool | ServerToolEntry>, serverCatalog: ReadonlyArray<ServerToolEntry>): ToolContractCheckup;
42
+ /** Format a contract check-up for a thrown error / console warning. */
43
+ export declare function formatToolContractCheckup(checkup: ToolContractCheckup): string;
@@ -0,0 +1,90 @@
1
+ /**
2
+ * Tool types — Agent's tool-call contract.
3
+ *
4
+ * Pattern: Strategy (GoF) — each Tool is a strategy for "how to execute
5
+ * this named operation given these args".
6
+ * Role: Consumer-facing shape. Agent.tool(...) accepts these.
7
+ * Emits: N/A (types only).
8
+ */
9
+ import type { LLMToolSchema } from '../adapters/types.js';
10
+ import type { Credential, CredentialNeed, CredentialProvider } from '../identity/types.js';
11
+ /**
12
+ * One executable tool the Agent can call.
13
+ *
14
+ * - `schema` is what the LLM sees (name, description, JSON schema).
15
+ * - `execute` runs when the LLM requests this tool with the given args.
16
+ * Returns anything JSON-serializable; the framework forwards it back
17
+ * to the LLM as the tool result.
18
+ */
19
+ export interface Tool<TArgs = Record<string, unknown>, TResult = unknown> {
20
+ readonly schema: LLMToolSchema;
21
+ /** Declare-and-push: a credential this tool needs. The framework resolves it
22
+ * BEFORE invoking and injects `ctx.credential`; it is NOT in `schema`, so the
23
+ * LLM never sees or fills it. */
24
+ readonly needs?: CredentialNeed;
25
+ execute(args: TArgs, ctx: ToolExecutionContext): Promise<TResult> | TResult;
26
+ }
27
+ /** Runtime context passed to tool.execute(). */
28
+ export interface ToolExecutionContext {
29
+ /** Unique id of THIS tool invocation (matches stream.tool_start.toolCallId). */
30
+ readonly toolCallId: string;
31
+ /** Current iteration number of the ReAct loop. */
32
+ readonly iteration: number;
33
+ /** Abort signal propagated from run({ env: { signal } }). */
34
+ readonly signal?: AbortSignal;
35
+ /**
36
+ * The bound credential provider — the PULL escape hatch for dynamic needs.
37
+ * Always present: when none is attached it's a fail-closed provider that
38
+ * THROWS, so it never silently no-ops via optional chaining. Prefer the
39
+ * declarative `needs` + `ctx.credential` for the common case.
40
+ */
41
+ readonly credentials: CredentialProvider;
42
+ /** True when a real provider is attached. Branch on this for intentional
43
+ * degraded (no-credential) mode instead of relying on `undefined`. */
44
+ readonly hasCredentials: boolean;
45
+ /** The credential resolved for this tool's declared `needs` (declare-and-push).
46
+ * Present only when the tool declared a need and it resolved successfully. */
47
+ readonly credential?: Credential;
48
+ }
49
+ /**
50
+ * Internal: registry entry keyed by tool name.
51
+ * Consumer never sees this shape.
52
+ */
53
+ export interface ToolRegistryEntry {
54
+ readonly name: string;
55
+ readonly tool: Tool;
56
+ }
57
+ /**
58
+ * Convenience input for `defineTool` — flatter than `Tool` itself.
59
+ * Consumers describe the tool inline; the helper assembles `schema`.
60
+ *
61
+ * `inputSchema` is a JSON Schema object (the same one the LLM will
62
+ * see). For tools that take no arguments, pass `{ type: 'object',
63
+ * properties: {} }` or omit and we'll default to that.
64
+ */
65
+ export interface DefineToolOptions<TArgs, TResult> {
66
+ readonly name: string;
67
+ readonly description: string;
68
+ readonly inputSchema?: Readonly<Record<string, unknown>>;
69
+ /** Declare a credential this tool needs (declare-and-push). Resolved by the
70
+ * framework before `execute` and injected as `ctx.credential`. */
71
+ readonly needs?: CredentialNeed;
72
+ execute(args: TArgs, ctx: ToolExecutionContext): Promise<TResult> | TResult;
73
+ }
74
+ /**
75
+ * STRICT validation — throws a clear, actionable error if a tool name can't be
76
+ * sent to an LLM. Exposed for consumers who want to fail hard (e.g. in a build
77
+ * step or a test). The library itself only WARNS (see `warnIfInvalidToolName`),
78
+ * because a name is provider-specific: a mock or a name-sanitizing custom provider
79
+ * may accept dotted/namespaced names that OpenAI/Anthropic reject.
80
+ */
81
+ export declare function assertValidToolName(name: unknown): asserts name is string;
82
+ /**
83
+ * DEV-MODE heads-up (never throws): warns once-per-call if a tool name will be
84
+ * rejected by OpenAI/Anthropic. Production and non-dev runs pay nothing. This is
85
+ * the library's default guard (Convention: dev diagnostics warn, they don't throw)
86
+ * — keeping mock/custom-provider + namespaced-name setups working. Reach for
87
+ * `assertValidToolName` when you want a hard failure.
88
+ */
89
+ export declare function warnIfInvalidToolName(name: unknown): void;
90
+ export declare function defineTool<TArgs = Record<string, unknown>, TResult = unknown>(options: DefineToolOptions<TArgs, TResult>): Tool<TArgs, TResult>;
@@ -0,0 +1,94 @@
1
+ /**
2
+ * GroupTranslator — UI-agnostic composition-level translator hook.
3
+ *
4
+ * Pattern: Visitor (GoF) at the composition boundary. Consumer supplies
5
+ * a translator function; each agentfootprint composition
6
+ * (Parallel, Sequence, Loop, Conditional, Agent, LLMCall)
7
+ * invokes it with composition-level metadata to produce a
8
+ * consumer-shaped UI output.
9
+ * Role: The per-COMPOSITION hook alongside footprintjs's per-NODE
10
+ * `StructureRecorder`. The two are independent — a consumer
11
+ * can attach either, both, or neither.
12
+ *
13
+ * - StructureRecorder observes ONE spec node at a time (record).
14
+ * - GroupTranslator sees the WHOLE composition (compose).
15
+ *
16
+ * For Lens's compound rendering (Parallel-as-container,
17
+ * Agent-as-drillable-card, LLMCall-as-card-with-slots),
18
+ * this is the right granularity: the translator knows the
19
+ * composition KIND and its full member list at once, so it
20
+ * can emit a single group-level shape with children pre-laid.
21
+ *
22
+ * Cascade: each composition that runs nested compositions exposes its
23
+ * members' OWN translated outputs via `GroupMember.uiGroup`.
24
+ * The consumer threads the same translator through every
25
+ * composition's construction (or per-method override via
26
+ * L1c) to get end-to-end coverage. No automatic propagation
27
+ * — propagation requires footprintjs-level changes which
28
+ * we're not making for this hook.
29
+ */
30
+ import type { Runner } from './runner.js';
31
+ /**
32
+ * The composition KIND a translator sees in `GroupMetadata.kind`.
33
+ * Closed union — every agentfootprint composition declares exactly
34
+ * one of these via the literal string baked into its `buildChart()`
35
+ * description prefix and surfaced here in `GroupMetadata`.
36
+ */
37
+ export type GroupKind = 'Parallel' | 'Sequence' | 'Loop' | 'Conditional' | 'Agent' | 'LLMCall';
38
+ /**
39
+ * One member of a composition. Shape is uniform across composition
40
+ * kinds — Parallel branches, Sequence steps, Loop body, Conditional
41
+ * branches, Agent tools/slots, LLMCall slots all map to this.
42
+ *
43
+ * `memberId` is the stable id the composition assigned (e.g. `legal`
44
+ * for a Parallel branch, `step-classify` for a Sequence step,
45
+ * `body` for a Loop). Consumers can correlate this with the
46
+ * SpecNode's `subflowId` / `id` to drill in.
47
+ *
48
+ * `runner` is the underlying `Runner` instance — useful for the
49
+ * consumer to call `member.runner.getSpec()` for the nested chart or
50
+ * `member.runner.getUIGroup()` for the nested translation result
51
+ * (when the same translator was threaded through that runner's
52
+ * construction).
53
+ *
54
+ * `uiGroup` is the member's already-translated output. Populated
55
+ * when the consumer threaded the same `groupTranslator` reference
56
+ * into each member's construction; `undefined` otherwise.
57
+ */
58
+ export interface GroupMember {
59
+ readonly memberId: string;
60
+ readonly runner: Runner;
61
+ readonly uiGroup?: unknown;
62
+ }
63
+ /**
64
+ * What a composition hands to its `groupTranslator` at build time.
65
+ * All composition kinds emit the same shape — the `kind` discriminator
66
+ * + the `extra` bag carry per-composition specifics.
67
+ */
68
+ export interface GroupMetadata {
69
+ readonly kind: GroupKind;
70
+ readonly id: string;
71
+ readonly name: string;
72
+ readonly members: ReadonlyArray<GroupMember>;
73
+ /**
74
+ * Composition-specific extras. Carried verbatim from the
75
+ * composition's own state — `Parallel` puts the merge strategy
76
+ * here, `Loop` puts iteration budgets, `Conditional` puts the
77
+ * fallback branch id, etc. Closed enough per kind that consumers
78
+ * can switch on `kind` to read it safely.
79
+ */
80
+ readonly extra?: Readonly<Record<string, unknown>>;
81
+ }
82
+ /**
83
+ * The consumer-supplied translator. Pure function — no async, no
84
+ * side effects expected. Runs ONCE per composition at the moment
85
+ * `getUIGroup()` is first called (memoised behaviour is per
86
+ * composition's discretion).
87
+ *
88
+ * Output type `T` is whatever the consumer wants — a React Flow
89
+ * group node, a Mermaid string, a domain-specific layout object,
90
+ * anything. agentfootprint stays UI-agnostic.
91
+ */
92
+ export interface GroupTranslator<T = unknown> {
93
+ (group: GroupMetadata): T;
94
+ }