agentfootprint 6.44.0 → 7.0.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 (442) hide show
  1. package/AGENTS.md +4 -0
  2. package/CLAUDE.md +4 -0
  3. package/README.md +141 -167
  4. package/ai-instructions/claude-code/SKILL.md +11 -0
  5. package/ai-instructions/setup.sh +0 -0
  6. package/dist/adapters/llm/BrowserOpenAIProvider.js +1 -1
  7. package/dist/adapters/llm/MockProvider.js +2 -1
  8. package/dist/adapters/llm/MockProvider.js.map +1 -1
  9. package/dist/core/agent/buildAgentChart.js +2 -1
  10. package/dist/core/agent/buildAgentChart.js.map +1 -1
  11. package/dist/core/agent/buildDynamicAgentChart.js +3 -1
  12. package/dist/core/agent/buildDynamicAgentChart.js.map +1 -1
  13. package/dist/core/agent/stages/pickEntry.js +3 -1
  14. package/dist/core/agent/stages/pickEntry.js.map +1 -1
  15. package/dist/debug/finders.js +29 -0
  16. package/dist/debug/finders.js.map +1 -0
  17. package/dist/debug.js +134 -0
  18. package/dist/debug.js.map +1 -0
  19. package/dist/esm/adapters/identity/agentcore.d.ts +100 -0
  20. package/dist/esm/adapters/llm/AnthropicProvider.d.ts +130 -0
  21. package/dist/esm/adapters/llm/BedrockProvider.d.ts +100 -0
  22. package/dist/esm/adapters/llm/BrowserAnthropicProvider.d.ts +41 -0
  23. package/dist/esm/adapters/llm/BrowserOpenAIProvider.d.ts +95 -0
  24. package/dist/esm/adapters/llm/BrowserOpenAIProvider.js +1 -1
  25. package/dist/esm/adapters/llm/MockProvider.d.ts +154 -0
  26. package/dist/esm/adapters/llm/MockProvider.js +2 -1
  27. package/dist/esm/adapters/llm/MockProvider.js.map +1 -1
  28. package/dist/esm/adapters/llm/OpenAIProvider.d.ts +220 -0
  29. package/dist/esm/adapters/llm/createProvider.d.ts +85 -0
  30. package/dist/esm/adapters/memory/agentcore.d.ts +146 -0
  31. package/dist/esm/adapters/memory/bedrockAgentMemory.d.ts +95 -0
  32. package/dist/esm/adapters/memory/redis.d.ts +127 -0
  33. package/dist/esm/adapters/observability/agentcore.d.ts +67 -0
  34. package/dist/esm/adapters/observability/audit.d.ts +254 -0
  35. package/dist/esm/adapters/observability/cloudwatch.d.ts +96 -0
  36. package/dist/esm/adapters/observability/otel.d.ts +237 -0
  37. package/dist/esm/adapters/observability/xray.d.ts +88 -0
  38. package/dist/esm/adapters/types.d.ts +378 -0
  39. package/dist/esm/bridge/eventMeta.d.ts +59 -0
  40. package/dist/esm/cache/CacheDecisionSubflow.d.ts +85 -0
  41. package/dist/esm/cache/CacheGateDecider.d.ts +127 -0
  42. package/dist/esm/cache/applyCachePolicy.d.ts +37 -0
  43. package/dist/esm/cache/cacheRecorder.d.ts +85 -0
  44. package/dist/esm/cache/index.d.ts +33 -0
  45. package/dist/esm/cache/strategies/AnthropicCacheStrategy.d.ts +38 -0
  46. package/dist/esm/cache/strategies/BedrockCacheStrategy.d.ts +33 -0
  47. package/dist/esm/cache/strategies/NoOpCacheStrategy.d.ts +29 -0
  48. package/dist/esm/cache/strategies/OpenAICacheStrategy.d.ts +36 -0
  49. package/dist/esm/cache/strategyRegistry.d.ts +45 -0
  50. package/dist/esm/cache/types.d.ts +243 -0
  51. package/dist/esm/conventions.d.ts +203 -0
  52. package/dist/esm/core/Agent.d.ts +355 -0
  53. package/dist/esm/core/LLMCall.d.ts +139 -0
  54. package/dist/esm/core/RunnerBase.d.ts +267 -0
  55. package/dist/esm/core/agent/AgentBuilder.d.ts +565 -0
  56. package/dist/esm/core/agent/buildAgentChart.d.ts +109 -0
  57. package/dist/esm/core/agent/buildAgentChart.js +2 -1
  58. package/dist/esm/core/agent/buildAgentChart.js.map +1 -1
  59. package/dist/esm/core/agent/buildAgentMessageApiChart.d.ts +40 -0
  60. package/dist/esm/core/agent/buildCacheSubflow.d.ts +35 -0
  61. package/dist/esm/core/agent/buildDynamicAgentChart.d.ts +56 -0
  62. package/dist/esm/core/agent/buildDynamicAgentChart.js +3 -1
  63. package/dist/esm/core/agent/buildDynamicAgentChart.js.map +1 -1
  64. package/dist/esm/core/agent/buildMessageApiChart.d.ts +47 -0
  65. package/dist/esm/core/agent/buildToolRegistry.d.ts +61 -0
  66. package/dist/esm/core/agent/memoryRecallInjections.d.ts +8 -0
  67. package/dist/esm/core/agent/stages/breakFinal.d.ts +22 -0
  68. package/dist/esm/core/agent/stages/callLLM.d.ts +74 -0
  69. package/dist/esm/core/agent/stages/pickEntry.d.ts +19 -0
  70. package/dist/esm/core/agent/stages/pickEntry.js +3 -1
  71. package/dist/esm/core/agent/stages/pickEntry.js.map +1 -1
  72. package/dist/esm/core/agent/stages/prepareFinal.d.ts +19 -0
  73. package/dist/esm/core/agent/stages/reliabilityExecution.d.ts +135 -0
  74. package/dist/esm/core/agent/stages/route.d.ts +18 -0
  75. package/dist/esm/core/agent/stages/seed.d.ts +53 -0
  76. package/dist/esm/core/agent/stages/toolCalls.d.ts +76 -0
  77. package/dist/esm/core/agent/toolArgsValidation.d.ts +62 -0
  78. package/dist/esm/core/agent/types.d.ts +382 -0
  79. package/dist/esm/core/agent/validators.d.ts +52 -0
  80. package/dist/esm/core/cost.d.ts +38 -0
  81. package/dist/esm/core/flowchartAsTool.d.ts +200 -0
  82. package/dist/esm/core/humanizeLLMError.d.ts +23 -0
  83. package/dist/esm/core/outputFallback.d.ts +139 -0
  84. package/dist/esm/core/outputSchema.d.ts +127 -0
  85. package/dist/esm/core/pause.d.ts +74 -0
  86. package/dist/esm/core/runCheckpoint.d.ts +179 -0
  87. package/dist/esm/core/runner.d.ts +203 -0
  88. package/dist/esm/core/slots/buildMessagesSlot.d.ts +40 -0
  89. package/dist/esm/core/slots/buildSystemPromptSlot.d.ts +41 -0
  90. package/dist/esm/core/slots/buildThinkingSubflow.d.ts +40 -0
  91. package/dist/esm/core/slots/buildToolsSlot.d.ts +60 -0
  92. package/dist/esm/core/slots/helpers.d.ts +27 -0
  93. package/dist/esm/core/toolContract.d.ts +43 -0
  94. package/dist/esm/core/tools.d.ts +90 -0
  95. package/dist/esm/core/translator.d.ts +94 -0
  96. package/dist/esm/core-flow/Conditional.d.ts +119 -0
  97. package/dist/esm/core-flow/Loop.d.ts +160 -0
  98. package/dist/esm/core-flow/Parallel.d.ts +360 -0
  99. package/dist/esm/core-flow/Sequence.d.ts +133 -0
  100. package/dist/esm/debug/finders.d.ts +12 -0
  101. package/dist/esm/debug/finders.js +13 -0
  102. package/dist/esm/debug/finders.js.map +1 -0
  103. package/dist/esm/debug.d.ts +25 -0
  104. package/dist/esm/debug.js +54 -0
  105. package/dist/esm/debug.js.map +1 -0
  106. package/dist/esm/events/dispatcher.d.ts +134 -0
  107. package/dist/esm/events/payloads.d.ts +761 -0
  108. package/dist/esm/events/registry.d.ts +198 -0
  109. package/dist/esm/events/types.d.ts +70 -0
  110. package/dist/esm/events.d.ts +18 -0
  111. package/dist/esm/events.js +22 -0
  112. package/dist/esm/events.js.map +1 -0
  113. package/dist/esm/identity/kinds.d.ts +36 -0
  114. package/dist/esm/identity/staticTokens.d.ts +28 -0
  115. package/dist/esm/identity/types.d.ts +113 -0
  116. package/dist/esm/identity/withCredentialRetry.d.ts +64 -0
  117. package/dist/esm/identity.d.ts +31 -0
  118. package/dist/esm/index.d.ts +44 -0
  119. package/dist/esm/index.js +7 -52
  120. package/dist/esm/index.js.map +1 -1
  121. package/dist/esm/injection-engine.d.ts +4 -0
  122. package/dist/esm/lib/canonicalJson.d.ts +56 -0
  123. package/dist/esm/lib/context-bisect/ablation.d.ts +109 -0
  124. package/dist/esm/lib/context-bisect/bisect.d.ts +75 -0
  125. package/dist/esm/lib/context-bisect/cost.d.ts +37 -0
  126. package/dist/esm/lib/context-bisect/index.d.ts +31 -0
  127. package/dist/esm/lib/context-bisect/index.js +3 -0
  128. package/dist/esm/lib/context-bisect/index.js.map +1 -1
  129. package/dist/esm/lib/context-bisect/llmEdgeWeigher.d.ts +124 -0
  130. package/dist/esm/lib/context-bisect/localize.d.ts +152 -0
  131. package/dist/esm/lib/context-bisect/localize.js +2 -0
  132. package/dist/esm/lib/context-bisect/localize.js.map +1 -1
  133. package/dist/esm/lib/context-bisect/loop-recall.d.ts +97 -0
  134. package/dist/esm/lib/context-bisect/missingContext.d.ts +71 -0
  135. package/dist/esm/lib/context-bisect/restoration.d.ts +39 -0
  136. package/dist/esm/lib/context-bisect/toBacktrackTrace.d.ts +138 -0
  137. package/dist/esm/lib/context-bisect/trajectory.d.ts +168 -0
  138. package/dist/esm/lib/context-bisect/types.d.ts +448 -0
  139. package/dist/esm/lib/context-bisect/walk-to-root.d.ts +103 -0
  140. package/dist/esm/lib/influence-core/attributability.d.ts +72 -0
  141. package/dist/esm/lib/influence-core/cache.d.ts +94 -0
  142. package/dist/esm/lib/influence-core/contrastive.d.ts +26 -0
  143. package/dist/esm/lib/influence-core/index.d.ts +34 -0
  144. package/dist/esm/lib/influence-core/margin.d.ts +33 -0
  145. package/dist/esm/lib/influence-core/signals.d.ts +128 -0
  146. package/dist/esm/lib/influence-core/similarity.d.ts +25 -0
  147. package/dist/esm/lib/influence-core/types.d.ts +252 -0
  148. package/dist/esm/lib/injection-engine/SkillRegistry.d.ts +147 -0
  149. package/dist/esm/lib/injection-engine/buildInjectionEngineSubflow.d.ts +110 -0
  150. package/dist/esm/lib/injection-engine/buildInjectionEngineSubflow.js +1 -0
  151. package/dist/esm/lib/injection-engine/buildInjectionEngineSubflow.js.map +1 -1
  152. package/dist/esm/lib/injection-engine/entryScorer.d.ts +93 -0
  153. package/dist/esm/lib/injection-engine/entryScorer.js +172 -0
  154. package/dist/esm/lib/injection-engine/entryScorer.js.map +1 -0
  155. package/dist/esm/lib/injection-engine/evaluator.d.ts +24 -0
  156. package/dist/esm/lib/injection-engine/factories/defineFact.d.ts +60 -0
  157. package/dist/esm/lib/injection-engine/factories/defineInjection.d.ts +41 -0
  158. package/dist/esm/lib/injection-engine/factories/defineInstruction.d.ts +78 -0
  159. package/dist/esm/lib/injection-engine/factories/defineRelevanceHint.d.ts +26 -0
  160. package/dist/esm/lib/injection-engine/factories/defineSkill.d.ts +160 -0
  161. package/dist/esm/lib/injection-engine/factories/defineSteering.d.ts +39 -0
  162. package/dist/esm/lib/injection-engine/index.d.ts +22 -0
  163. package/dist/esm/lib/injection-engine/index.js +2 -1
  164. package/dist/esm/lib/injection-engine/index.js.map +1 -1
  165. package/dist/esm/lib/injection-engine/skillContract.d.ts +29 -0
  166. package/dist/esm/lib/injection-engine/skillGraph.d.ts +290 -0
  167. package/dist/esm/lib/injection-engine/skillGraph.js +38 -43
  168. package/dist/esm/lib/injection-engine/skillGraph.js.map +1 -1
  169. package/dist/esm/lib/injection-engine/skillGraphCheckup.d.ts +49 -0
  170. package/dist/esm/lib/injection-engine/skillTools.d.ts +72 -0
  171. package/dist/esm/lib/injection-engine/softmax.d.ts +11 -0
  172. package/dist/esm/lib/injection-engine/types.d.ts +229 -0
  173. package/dist/esm/lib/injection-engine/types.js.map +1 -1
  174. package/dist/esm/lib/lazyRequire.d.ts +29 -0
  175. package/dist/esm/lib/mcp/index.d.ts +9 -0
  176. package/dist/esm/lib/mcp/mcpClient.d.ts +46 -0
  177. package/dist/esm/lib/mcp/mockMcpClient.d.ts +65 -0
  178. package/dist/esm/lib/mcp/types.d.ts +133 -0
  179. package/dist/esm/lib/rag/defineRAG.d.ts +139 -0
  180. package/dist/esm/lib/rag/defineRAG.js +3 -3
  181. package/dist/esm/lib/rag/index.d.ts +7 -0
  182. package/dist/esm/lib/rag/indexDocuments.d.ts +106 -0
  183. package/dist/esm/lib/rag/indexDocuments.js +2 -1
  184. package/dist/esm/lib/rag/indexDocuments.js.map +1 -1
  185. package/dist/esm/lib/tool-lint/analyze.d.ts +83 -0
  186. package/dist/esm/lib/tool-lint/cli.d.ts +43 -0
  187. package/dist/esm/lib/tool-lint/format.d.ts +18 -0
  188. package/dist/esm/lib/tool-lint/index.d.ts +23 -0
  189. package/dist/esm/lib/tool-lint/rules.d.ts +85 -0
  190. package/dist/esm/lib/tool-lint/types.d.ts +155 -0
  191. package/dist/esm/lib/trace-toolpack/bounded.d.ts +47 -0
  192. package/dist/esm/lib/trace-toolpack/debugPrompt.d.ts +19 -0
  193. package/dist/esm/lib/trace-toolpack/index.d.ts +20 -0
  194. package/dist/esm/lib/trace-toolpack/lazyToolpack.d.ts +35 -0
  195. package/dist/esm/lib/trace-toolpack/selfExplain.d.ts +100 -0
  196. package/dist/esm/lib/trace-toolpack/traceDebugAgent.d.ts +42 -0
  197. package/dist/esm/lib/trace-toolpack/traceToolpack.d.ts +69 -0
  198. package/dist/esm/lib/trace-toolpack/types.d.ts +59 -0
  199. package/dist/esm/llm-providers.d.ts +26 -0
  200. package/dist/esm/locales/index.d.ts +141 -0
  201. package/dist/esm/locales/index.js +7 -0
  202. package/dist/esm/locales/index.js.map +1 -1
  203. package/dist/esm/memory/beats/extractBeats.d.ts +61 -0
  204. package/dist/esm/memory/beats/extractor.d.ts +47 -0
  205. package/dist/esm/memory/beats/formatAsNarrative.d.ts +62 -0
  206. package/dist/esm/memory/beats/heuristicExtractor.d.ts +37 -0
  207. package/dist/esm/memory/beats/index.d.ts +12 -0
  208. package/dist/esm/memory/beats/llmExtractor.d.ts +56 -0
  209. package/dist/esm/memory/beats/types.d.ts +60 -0
  210. package/dist/esm/memory/beats/writeBeats.d.ts +22 -0
  211. package/dist/esm/memory/causal/evidenceRecorder.d.ts +66 -0
  212. package/dist/esm/memory/causal/index.d.ts +6 -0
  213. package/dist/esm/memory/causal/loadSnapshot.d.ts +51 -0
  214. package/dist/esm/memory/causal/snapshotPipeline.d.ts +35 -0
  215. package/dist/esm/memory/causal/types.d.ts +134 -0
  216. package/dist/esm/memory/causal/types.js.map +1 -1
  217. package/dist/esm/memory/causal/writeSnapshot.d.ts +73 -0
  218. package/dist/esm/memory/define.d.ts +63 -0
  219. package/dist/esm/memory/define.types.d.ts +278 -0
  220. package/dist/esm/memory/define.types.js +6 -4
  221. package/dist/esm/memory/define.types.js.map +1 -1
  222. package/dist/esm/memory/embedding/cosine.d.ts +18 -0
  223. package/dist/esm/memory/embedding/embedMessages.d.ts +58 -0
  224. package/dist/esm/memory/embedding/index.d.ts +8 -0
  225. package/dist/esm/memory/embedding/loadRelevant.d.ts +51 -0
  226. package/dist/esm/memory/embedding/mockEmbedder.d.ts +22 -0
  227. package/dist/esm/memory/embedding/types.d.ts +46 -0
  228. package/dist/esm/memory/entry/decay.d.ts +36 -0
  229. package/dist/esm/memory/entry/index.d.ts +2 -0
  230. package/dist/esm/memory/entry/types.d.ts +140 -0
  231. package/dist/esm/memory/facts/extractFacts.d.ts +50 -0
  232. package/dist/esm/memory/facts/extractor.d.ts +33 -0
  233. package/dist/esm/memory/facts/formatFacts.d.ts +60 -0
  234. package/dist/esm/memory/facts/index.d.ts +14 -0
  235. package/dist/esm/memory/facts/llmFactExtractor.d.ts +64 -0
  236. package/dist/esm/memory/facts/loadFacts.d.ts +43 -0
  237. package/dist/esm/memory/facts/patternFactExtractor.d.ts +2 -0
  238. package/dist/esm/memory/facts/types.d.ts +68 -0
  239. package/dist/esm/memory/facts/writeFacts.d.ts +19 -0
  240. package/dist/esm/memory/identity/index.d.ts +2 -0
  241. package/dist/esm/memory/identity/types.d.ts +49 -0
  242. package/dist/esm/memory/index.d.ts +19 -0
  243. package/dist/esm/memory/pipeline/auto.d.ts +59 -0
  244. package/dist/esm/memory/pipeline/default.d.ts +49 -0
  245. package/dist/esm/memory/pipeline/ephemeral.d.ts +28 -0
  246. package/dist/esm/memory/pipeline/fact.d.ts +26 -0
  247. package/dist/esm/memory/pipeline/index.d.ts +13 -0
  248. package/dist/esm/memory/pipeline/narrative.d.ts +35 -0
  249. package/dist/esm/memory/pipeline/semantic.d.ts +37 -0
  250. package/dist/esm/memory/pipeline/types.d.ts +31 -0
  251. package/dist/esm/memory/stages/formatDefault.d.ts +64 -0
  252. package/dist/esm/memory/stages/index.d.ts +13 -0
  253. package/dist/esm/memory/stages/loadRecent.d.ts +49 -0
  254. package/dist/esm/memory/stages/pickByBudget.d.ts +63 -0
  255. package/dist/esm/memory/stages/summarize.d.ts +87 -0
  256. package/dist/esm/memory/stages/tokenize.d.ts +43 -0
  257. package/dist/esm/memory/stages/types.d.ts +75 -0
  258. package/dist/esm/memory/stages/writeMessages.d.ts +71 -0
  259. package/dist/esm/memory/store/InMemoryStore.d.ts +62 -0
  260. package/dist/esm/memory/store/index.d.ts +2 -0
  261. package/dist/esm/memory/store/types.d.ts +223 -0
  262. package/dist/esm/memory/wire/index.d.ts +2 -0
  263. package/dist/esm/memory/wire/mountMemoryPipeline.d.ts +108 -0
  264. package/dist/esm/memory-providers.d.ts +37 -0
  265. package/dist/esm/observability/contextError/finders/compareFinders.d.ts +19 -0
  266. package/dist/esm/observability/contextError/finders/index.d.ts +22 -0
  267. package/dist/esm/observability/contextError/finders/rankSuspects.d.ts +2 -0
  268. package/dist/esm/observability/contextError/finders/removeAndRetry.d.ts +11 -0
  269. package/dist/esm/observability/contextError/finders/shrinkToCause.d.ts +11 -0
  270. package/dist/esm/observability/contextError/finders/testManyCombos.d.ts +11 -0
  271. package/dist/esm/observability/contextError/finders/traceSteps.d.ts +2 -0
  272. package/dist/esm/observability/contextError/finders/types.d.ts +88 -0
  273. package/dist/esm/observability-providers.d.ts +46 -0
  274. package/dist/esm/observe.d.ts +57 -0
  275. package/dist/esm/observe.js +7 -36
  276. package/dist/esm/observe.js.map +1 -1
  277. package/dist/esm/patterns/Debate.d.ts +39 -0
  278. package/dist/esm/patterns/MapReduce.d.ts +66 -0
  279. package/dist/esm/patterns/Reflection.d.ts +51 -0
  280. package/dist/esm/patterns/SelfConsistency.d.ts +43 -0
  281. package/dist/esm/patterns/Swarm.d.ts +60 -0
  282. package/dist/esm/patterns/ToT.d.ts +53 -0
  283. package/dist/esm/patterns/index.d.ts +22 -0
  284. package/dist/esm/providers.d.ts +33 -0
  285. package/dist/esm/providers.js +1 -1
  286. package/dist/esm/providers.js.map +1 -1
  287. package/dist/esm/recorders/core/AgentRecorder.d.ts +15 -0
  288. package/dist/esm/recorders/core/CompositionRecorder.d.ts +17 -0
  289. package/dist/esm/recorders/core/ContextEvaluatedRecorder.d.ts +23 -0
  290. package/dist/esm/recorders/core/ContextRecorder.d.ts +47 -0
  291. package/dist/esm/recorders/core/CostRecorder.d.ts +14 -0
  292. package/dist/esm/recorders/core/EmitBridge.d.ts +30 -0
  293. package/dist/esm/recorders/core/ErrorBridge.d.ts +38 -0
  294. package/dist/esm/recorders/core/EvalRecorder.d.ts +16 -0
  295. package/dist/esm/recorders/core/MemoryRecorder.d.ts +17 -0
  296. package/dist/esm/recorders/core/PermissionRecorder.d.ts +16 -0
  297. package/dist/esm/recorders/core/ReliabilityRecorder.d.ts +24 -0
  298. package/dist/esm/recorders/core/SkillRecorder.d.ts +14 -0
  299. package/dist/esm/recorders/core/StreamRecorder.d.ts +15 -0
  300. package/dist/esm/recorders/core/ToolsRecorder.d.ts +18 -0
  301. package/dist/esm/recorders/core/ValidationRecorder.d.ts +16 -0
  302. package/dist/esm/recorders/core/contextEngineering.d.ts +136 -0
  303. package/dist/esm/recorders/core/typedEmit.d.ts +34 -0
  304. package/dist/esm/recorders/core/types.d.ts +97 -0
  305. package/dist/esm/recorders/observability/AgentThinkingTraceRecorder.d.ts +117 -0
  306. package/dist/esm/recorders/observability/BoundaryRecorder.d.ts +546 -0
  307. package/dist/esm/recorders/observability/FlowchartRecorder.d.ts +220 -0
  308. package/dist/esm/recorders/observability/LiveStateRecorder.d.ts +250 -0
  309. package/dist/esm/recorders/observability/LoggingRecorder.d.ts +91 -0
  310. package/dist/esm/recorders/observability/RouteRecorder.d.ts +83 -0
  311. package/dist/esm/recorders/observability/RunStepRecorder.d.ts +231 -0
  312. package/dist/esm/recorders/observability/StatusRecorder.d.ts +36 -0
  313. package/dist/esm/recorders/observability/ToolChoiceRecorder.d.ts +164 -0
  314. package/dist/esm/recorders/observability/ToolLineageRecorder.d.ts +71 -0
  315. package/dist/esm/recorders/observability/commentary/commentaryTemplates.d.ts +105 -0
  316. package/dist/esm/recorders/observability/internal/ActorArrowClassifier.d.ts +25 -0
  317. package/dist/esm/recorders/observability/internal/CandidateAnswerBuffer.d.ts +28 -0
  318. package/dist/esm/recorders/observability/internal/ForkTracker.d.ts +60 -0
  319. package/dist/esm/recorders/observability/internal/RootInferrer.d.ts +51 -0
  320. package/dist/esm/recorders/observability/internal/SequenceSiblingTracker.d.ts +24 -0
  321. package/dist/esm/recorders/observability/localObservability.d.ts +48 -0
  322. package/dist/esm/recorders/observability/observeRunId.d.ts +36 -0
  323. package/dist/esm/recorders/observability/status/statusTemplates.d.ts +106 -0
  324. package/dist/esm/recorders/observability/trace.d.ts +119 -0
  325. package/dist/esm/reliability/CircuitBreaker.d.ts +75 -0
  326. package/dist/esm/reliability/buildReliabilityGateChart.d.ts +53 -0
  327. package/dist/esm/reliability/classifyError.d.ts +28 -0
  328. package/dist/esm/reliability/index.d.ts +35 -0
  329. package/dist/esm/reliability/types.d.ts +327 -0
  330. package/dist/esm/resilience/fallbackProvider.d.ts +33 -0
  331. package/dist/esm/resilience/index.d.ts +21 -0
  332. package/dist/esm/resilience/withCircuitBreaker.d.ts +129 -0
  333. package/dist/esm/resilience/withFallback.d.ts +45 -0
  334. package/dist/esm/resilience/withRetry.d.ts +71 -0
  335. package/dist/esm/security/PermissionPolicy.d.ts +124 -0
  336. package/dist/esm/security/PolicyHaltError.d.ts +72 -0
  337. package/dist/esm/security/extractSequence.d.ts +46 -0
  338. package/dist/esm/security/index.d.ts +44 -0
  339. package/dist/esm/security/thinkingRedaction.d.ts +50 -0
  340. package/dist/esm/status.d.ts +54 -0
  341. package/dist/esm/status.js +13 -4
  342. package/dist/esm/status.js.map +1 -1
  343. package/dist/esm/strategies/attach.d.ts +47 -0
  344. package/dist/esm/strategies/compose.d.ts +48 -0
  345. package/dist/esm/strategies/defaults/chatBubbleLiveStatus.d.ts +36 -0
  346. package/dist/esm/strategies/defaults/consoleObservability.d.ts +42 -0
  347. package/dist/esm/strategies/defaults/inMemorySinkCost.d.ts +50 -0
  348. package/dist/esm/strategies/defaults/index.d.ts +30 -0
  349. package/dist/esm/strategies/defaults/noopLens.d.ts +28 -0
  350. package/dist/esm/strategies/index.d.ts +36 -0
  351. package/dist/esm/strategies/registry.d.ts +70 -0
  352. package/dist/esm/strategies/types.d.ts +303 -0
  353. package/dist/esm/stream.d.ts +82 -0
  354. package/dist/esm/thinking/AnthropicThinkingHandler.d.ts +42 -0
  355. package/dist/esm/thinking/MockThinkingHandler.d.ts +50 -0
  356. package/dist/esm/thinking/OpenAIThinkingHandler.d.ts +37 -0
  357. package/dist/esm/thinking/index.d.ts +51 -0
  358. package/dist/esm/thinking/registry.d.ts +33 -0
  359. package/dist/esm/thinking/types.d.ts +162 -0
  360. package/dist/esm/tool-providers/gatedTools.d.ts +36 -0
  361. package/dist/esm/tool-providers/index.d.ts +41 -0
  362. package/dist/esm/tool-providers/skillScopedTools.d.ts +45 -0
  363. package/dist/esm/tool-providers/staticTools.d.ts +21 -0
  364. package/dist/esm/tool-providers/types.d.ts +138 -0
  365. package/dist/events.js +42 -0
  366. package/dist/events.js.map +1 -0
  367. package/dist/index.js +7 -117
  368. package/dist/index.js.map +1 -1
  369. package/dist/lib/context-bisect/index.js +3 -0
  370. package/dist/lib/context-bisect/index.js.map +1 -1
  371. package/dist/lib/context-bisect/localize.js +2 -0
  372. package/dist/lib/context-bisect/localize.js.map +1 -1
  373. package/dist/lib/injection-engine/buildInjectionEngineSubflow.js +1 -0
  374. package/dist/lib/injection-engine/buildInjectionEngineSubflow.js.map +1 -1
  375. package/dist/lib/injection-engine/entryScorer.js +178 -0
  376. package/dist/lib/injection-engine/entryScorer.js.map +1 -0
  377. package/dist/lib/injection-engine/index.js +6 -2
  378. package/dist/lib/injection-engine/index.js.map +1 -1
  379. package/dist/lib/injection-engine/skillGraph.js +40 -45
  380. package/dist/lib/injection-engine/skillGraph.js.map +1 -1
  381. package/dist/lib/injection-engine/types.js.map +1 -1
  382. package/dist/lib/rag/defineRAG.js +3 -3
  383. package/dist/lib/rag/indexDocuments.js +2 -1
  384. package/dist/lib/rag/indexDocuments.js.map +1 -1
  385. package/dist/locales/index.js +2 -1
  386. package/dist/locales/index.js.map +1 -1
  387. package/dist/memory/causal/types.js.map +1 -1
  388. package/dist/memory/define.types.js +6 -4
  389. package/dist/memory/define.types.js.map +1 -1
  390. package/dist/observe.js +22 -115
  391. package/dist/observe.js.map +1 -1
  392. package/dist/providers.js +3 -1
  393. package/dist/providers.js.map +1 -1
  394. package/dist/status.js +13 -5
  395. package/dist/status.js.map +1 -1
  396. package/dist/types/adapters/llm/BrowserOpenAIProvider.d.ts +1 -1
  397. package/dist/types/adapters/llm/MockProvider.d.ts +2 -1
  398. package/dist/types/adapters/llm/MockProvider.d.ts.map +1 -1
  399. package/dist/types/core/agent/buildAgentChart.d.ts.map +1 -1
  400. package/dist/types/core/agent/buildDynamicAgentChart.d.ts.map +1 -1
  401. package/dist/types/core/agent/stages/pickEntry.d.ts.map +1 -1
  402. package/dist/types/core/agent/types.d.ts +8 -4
  403. package/dist/types/core/agent/types.d.ts.map +1 -1
  404. package/dist/types/debug/finders.d.ts +13 -0
  405. package/dist/types/debug/finders.d.ts.map +1 -0
  406. package/dist/types/debug.d.ts +26 -0
  407. package/dist/types/debug.d.ts.map +1 -0
  408. package/dist/types/events.d.ts +19 -0
  409. package/dist/types/events.d.ts.map +1 -0
  410. package/dist/types/index.d.ts +4 -24
  411. package/dist/types/index.d.ts.map +1 -1
  412. package/dist/types/lib/context-bisect/index.d.ts +3 -0
  413. package/dist/types/lib/context-bisect/index.d.ts.map +1 -1
  414. package/dist/types/lib/context-bisect/localize.d.ts +2 -0
  415. package/dist/types/lib/context-bisect/localize.d.ts.map +1 -1
  416. package/dist/types/lib/injection-engine/buildInjectionEngineSubflow.d.ts.map +1 -1
  417. package/dist/types/lib/injection-engine/entryScorer.d.ts +94 -0
  418. package/dist/types/lib/injection-engine/entryScorer.d.ts.map +1 -0
  419. package/dist/types/lib/injection-engine/index.d.ts +2 -1
  420. package/dist/types/lib/injection-engine/index.d.ts.map +1 -1
  421. package/dist/types/lib/injection-engine/skillGraph.d.ts +24 -26
  422. package/dist/types/lib/injection-engine/skillGraph.d.ts.map +1 -1
  423. package/dist/types/lib/injection-engine/types.d.ts +9 -4
  424. package/dist/types/lib/injection-engine/types.d.ts.map +1 -1
  425. package/dist/types/lib/rag/defineRAG.d.ts +3 -3
  426. package/dist/types/lib/rag/indexDocuments.d.ts +2 -1
  427. package/dist/types/lib/rag/indexDocuments.d.ts.map +1 -1
  428. package/dist/types/locales/index.d.ts +9 -0
  429. package/dist/types/locales/index.d.ts.map +1 -1
  430. package/dist/types/memory/causal/types.d.ts +13 -9
  431. package/dist/types/memory/causal/types.d.ts.map +1 -1
  432. package/dist/types/memory/define.types.d.ts +6 -4
  433. package/dist/types/memory/define.types.d.ts.map +1 -1
  434. package/dist/types/observe.d.ts +1 -6
  435. package/dist/types/observe.d.ts.map +1 -1
  436. package/dist/types/providers.d.ts +2 -2
  437. package/dist/types/providers.d.ts.map +1 -1
  438. package/dist/types/status.d.ts +10 -4
  439. package/dist/types/status.d.ts.map +1 -1
  440. package/dist/types/tool-providers/index.d.ts +1 -1
  441. package/dist/types/tool-providers/index.d.ts.map +1 -1
  442. package/package.json +261 -57
@@ -0,0 +1,44 @@
1
+ /**
2
+ * agentfootprint — public barrel.
3
+ *
4
+ * Pattern: Facade (GoF) over the typed sublayers.
5
+ * Role: Single entry point consumers import from.
6
+ * Emits: N/A.
7
+ */
8
+ import './cache/strategies/AnthropicCacheStrategy.js';
9
+ import './cache/strategies/OpenAICacheStrategy.js';
10
+ import './cache/strategies/BedrockCacheStrategy.js';
11
+ export type { CombinedRecorder, ScopeRecorder, FlowRecorder, EmitRecorder, WriteEvent, ReadEvent, CommitEvent, StageEvent, ErrorEvent, FlowStageEvent, FlowNextEvent, FlowDecisionEvent, FlowForkEvent, FlowSelectedEvent, FlowSubflowEvent, FlowSubflowRegisteredEvent, FlowLoopEvent, FlowBreakEvent, FlowErrorEvent, TraversalContext, EmitEvent, RedactionPolicy, RedactionReport, } from 'footprintjs';
12
+ export * from './adapters/types.js';
13
+ export { INJECTION_KEYS, injectionKeyForSlot, isInjectionKey, type InjectionKey, stageRole, type StageRole, milestoneFor, type Milestone, type MilestoneKind, } from './conventions.js';
14
+ export { COMPOSITION_KEYS, type BudgetPressureRecord, type CompositionKey, type EvictionRecord, type InjectionRecord, type SlotComposition, } from './recorders/core/types.js';
15
+ export { type RunContext, } from './bridge/eventMeta.js';
16
+ export { contextEngineering, isEngineeredSource, isBaselineSource, ENGINEERED_SOURCES, BASELINE_SOURCES, type ContextEngineeringHandle, type ContextEngineeringUnsubscribe, type ContextInjectedEvent, type ContextInjectedListener, } from './recorders/core/contextEngineering.js';
17
+ export type { EmittedEvent, EnableNamespace, Runner } from './core/runner.js';
18
+ export { RunnerBase, makeRunId } from './core/RunnerBase.js';
19
+ export type { GroupKind, GroupMember, GroupMetadata, GroupTranslator } from './core/translator.js';
20
+ export { pauseHere, askHuman, isPauseRequest, isPaused, type RunnerPauseOutcome, } from './core/pause.js';
21
+ export type { FlowchartHandle, FlowchartOptions, } from './recorders/observability/FlowchartRecorder.js';
22
+ export { defaultCommentaryTemplates, extractAgentName, extractCommentaryVars, renderCommentary, selectCommentaryKey, type CommentaryContext, type CommentaryTemplates, } from './recorders/observability/commentary/commentaryTemplates.js';
23
+ export { LLMCall, LLMCallBuilder, type LLMCallInput, type LLMCallOptions, type LLMCallOutput, } from './core/LLMCall.js';
24
+ export { type MessageApiChartDeps, } from './core/agent/buildMessageApiChart.js';
25
+ export { buildAgentMessageApiChart, type AgentMessageApiChartDeps, } from './core/agent/buildAgentMessageApiChart.js';
26
+ export { Agent, AgentBuilder, type AgentInput, type AgentOptions, type AgentOutput, type ObserverDeliveryOptions, } from './core/Agent.js';
27
+ export type { SelfExplainOptions } from './lib/trace-toolpack/selfExplain.js';
28
+ export type { ObserverDrainResult, ObserverStats } from 'footprintjs';
29
+ export type { ToolArgValidationMode } from './core/agent/toolArgsValidation.js';
30
+ export type { ReadSummaryMarker, ReadTrackingMode } from 'footprintjs';
31
+ export { OutputSchemaError, applyOutputSchema, type OutputSchemaParser, type OutputSchemaOptions, } from './core/outputSchema.js';
32
+ export { type OutputFallbackOptions, type OutputFallbackFn } from './core/outputFallback.js';
33
+ export { RunCheckpointError, type AgentRunCheckpoint } from './core/runCheckpoint.js';
34
+ export { flowchartAsTool, type FlowchartAsToolOptions, type FlowchartResultMapper, type FlowchartToolSnapshot, } from './core/flowchartAsTool.js';
35
+ export type { Tool, ToolExecutionContext, ToolRegistryEntry, DefineToolOptions, } from './core/tools.js';
36
+ export { defineTool, assertValidToolName, warnIfInvalidToolName } from './core/tools.js';
37
+ export { toolContractCheckup, formatToolContractCheckup, type ToolContractCheckup, type ToolContractProblem, type ToolContractCode, type ServerToolEntry, } from './core/toolContract.js';
38
+ export { Sequence, SequenceBuilder, type SequenceInput, type SequenceOptions, type SequenceOutput, } from './core-flow/Sequence.js';
39
+ export { Parallel, ParallelBuilder, type BranchOutcome, type MergeFn, type MergeOutcomesFn, type MergeWithLLMOptions, type ParallelBranchOptions, type ParallelInput, type ParallelOptions, type ParallelOutput, } from './core-flow/Parallel.js';
40
+ export { Conditional, ConditionalBuilder, type ConditionalInput, type ConditionalOptions, type ConditionalOutput, type Predicate, } from './core-flow/Conditional.js';
41
+ export { Loop, LoopBuilder, type LoopInput, type LoopOptions, type LoopOutput, type UntilGuard, } from './core-flow/Loop.js';
42
+ export { providerFromEnv, type ProviderKind, type CreateProviderOptions, type ProviderFromEnv, } from './adapters/llm/createProvider.js';
43
+ export * from './patterns/index.js';
44
+ export { defineRAG, type DefineRAGOptions, indexDocuments, type IndexDocumentsOptions, type RagDocument, } from './lib/rag/index.js';
package/dist/esm/index.js CHANGED
@@ -14,11 +14,6 @@
14
14
  import './cache/strategies/AnthropicCacheStrategy.js';
15
15
  import './cache/strategies/OpenAICacheStrategy.js';
16
16
  import './cache/strategies/BedrockCacheStrategy.js';
17
- // Events — registry, types, payloads
18
- export * from './events/types.js';
19
- export { EVENT_NAMES, ALL_EVENT_TYPES, } from './events/registry.js';
20
- // Dispatcher
21
- export { EventDispatcher, } from './events/dispatcher.js';
22
17
  // Adapter interfaces (ports)
23
18
  export * from './adapters/types.js';
24
19
  // Injection keys + recorder authoring helpers — needed by anyone writing
@@ -40,8 +35,6 @@ milestoneFor, } from './conventions.js';
40
35
  // API. Library code reaches them via the relative `./conventions.js`
41
36
  // import; downstream code should never need them.
42
37
  export { COMPOSITION_KEYS, } from './recorders/core/types.js';
43
- // Bridge helper
44
- export { buildEventMeta, parseSubflowPath } from './bridge/eventMeta.js';
45
38
  // Context-engineering + emit primitives.
46
39
  //
47
40
  // The observability recorder FACTORIES (ContextRecorder, streamRecorder,
@@ -52,8 +45,6 @@ export { buildEventMeta, parseSubflowPath } from './bridge/eventMeta.js';
52
45
  // ONLY under `agentfootprint/observe` — the dedicated observability subpath —
53
46
  // so the main barrel stays focused on the core agent API.
54
47
  export { contextEngineering, isEngineeredSource, isBaselineSource, ENGINEERED_SOURCES, BASELINE_SOURCES, } from './recorders/core/contextEngineering.js';
55
- export { EmitBridge } from './recorders/core/EmitBridge.js';
56
- export { typedEmit } from './recorders/core/typedEmit.js';
57
48
  export { RunnerBase, makeRunId } from './core/RunnerBase.js';
58
49
  // Pause/Resume primitives — consumer API for human-in-the-loop tools.
59
50
  // `PauseRequest` (the throwable signal class) stays internal; consumers
@@ -64,7 +55,11 @@ export { pauseHere, askHuman, isPauseRequest, isPaused, } from './core/pause.js'
64
55
  // Commentary — bundled prose templates + engine for narrating a run.
65
56
  // Consumers ship their own JSON locale / brand voice via the same
66
57
  // shape; viewers (Lens, CLI tail, log file) consume this surface.
67
- export { defaultCommentaryTemplates, extractAgentName, extractCommentaryVars, renderCommentary, selectCommentaryKey, } from './recorders/observability/commentary/commentaryTemplates.js';
58
+ export { defaultCommentaryTemplates,
59
+ // Commentary engine helpers — advanced surface consumed by viewer
60
+ // libraries (agentfootprint-lens) to render run narration. Not the
61
+ // everyday API, but de-facto public: keep exported.
62
+ extractAgentName, extractCommentaryVars, renderCommentary, selectCommentaryKey, } from './recorders/observability/commentary/commentaryTemplates.js';
68
63
  // Status — chat-bubble surface (separate audience: the end user
69
64
  // chatting; renamed from "thinking" in 5.0.0 to disambiguate from the
70
65
  // MODEL's extended-thinking reasoning). State machine:
@@ -73,20 +68,15 @@ export { defaultCommentaryTemplates, extractAgentName, extractCommentaryVars, re
73
68
  // supported, missing keys ignored) but a different vocabulary —
74
69
  // first-person status, mid-call only. Per-tool keys (`tool.<toolName>`)
75
70
  // win over the generic `tool` key.
76
- export { defaultStatusTemplates, selectStatus, renderStatusLine, } from './recorders/observability/status/statusTemplates.js';
77
71
  // Primitives (core/)
78
72
  export { LLMCall, LLMCallBuilder, } from './core/LLMCall.js';
79
- // messageAPI merge-tree proof chart (LLM-only) — Context-selector → slot
80
- // subflows → messageAPI assembly stage → Call-LLM. The locked shape that
81
- // will later serve both Static and Dynamic agents. See buildMessageApiChart.
82
- export { buildMessageApiChart, } from './core/agent/buildMessageApiChart.js';
83
73
  // Agent (ReAct) form of the merge-tree — Context root selector → two-stage
84
74
  // convergence: [sf-message-api (system-prompt+messages → messageAPI), sf-tools]
85
75
  // → Call-LLM → route → [tool-exec → loop] / final. tools + the loop are the
86
76
  // only additions over buildMessageApiChart. See buildAgentMessageApiChart.
87
77
  export { buildAgentMessageApiChart, } from './core/agent/buildAgentMessageApiChart.js';
88
78
  export { Agent, AgentBuilder, } from './core/Agent.js';
89
- export { OutputSchemaError, applyOutputSchema, buildDefaultInstruction, } from './core/outputSchema.js';
79
+ export { OutputSchemaError, applyOutputSchema, } from './core/outputSchema.js';
90
80
  export { RunCheckpointError } from './core/runCheckpoint.js';
91
81
  export { flowchartAsTool, } from './core/flowchartAsTool.js';
92
82
  export { defineTool, assertValidToolName, warnIfInvalidToolName } from './core/tools.js';
@@ -119,25 +109,10 @@ export { Loop, LoopBuilder, } from './core-flow/Loop.js';
119
109
  //
120
110
  // import { AnthropicProvider } from 'agentfootprint'; // ❌ not exported
121
111
  // import { AnthropicProvider } from 'agentfootprint/llm-providers'; // ✓ canonical
122
- export { MockProvider, mock, } from './adapters/llm/MockProvider.js';
123
- export { browserAnthropic, BrowserAnthropicProvider, } from './adapters/llm/BrowserAnthropicProvider.js';
124
- export { browserOpenai, BrowserOpenAIProvider, browserAzureOpenai, BrowserAzureOpenAIProvider, } from './adapters/llm/BrowserOpenAIProvider.js';
125
- export { createProvider, providerFromEnv, } from './adapters/llm/createProvider.js';
112
+ export { providerFromEnv, } from './adapters/llm/createProvider.js';
126
113
  // Streaming helpers — agent events → SSE for browser delivery.
127
- export { toSSE, SSEFormatter, encodeSSE } from './stream.js';
128
114
  // Injection Engine — the unifying primitive of context engineering.
129
115
  // One Injection type, four sugar factories, one engine subflow.
130
- export {
131
- // Engine
132
- evaluateInjections, buildInjectionEngineSubflow, projectActiveInjection,
133
- // Sugar factories — one per injection flavor
134
- defineInstruction, defineRelevanceHint, defineSkill, resolveSurfaceMode, SkillRegistry, buildListSkillsTool, buildReadSkillTool, defineSteering, defineFact,
135
- // Unified factory (type-discriminant over the four named factories above)
136
- defineInjection,
137
- // Declarative skill graph (proposal 002)
138
- skillGraph, decide, SKILL_GRAPH_METADATA_KEY,
139
- // Proposal 009 Tier 1 — skill-body ↔ tool-contract consistency check
140
- checkSkillContract, checkSkillContracts, skillToolNames, } from './lib/injection-engine/index.js';
141
116
  // Patterns — factory functions composing primitives + core-flow into
142
117
  // well-known agent patterns from the research literature.
143
118
  export * from './patterns/index.js';
@@ -146,22 +121,6 @@ export * from './patterns/index.js';
146
121
  // the most-used factories; the full subsystem (including types that
147
122
  // would collide with adapter types like MemoryStore) is reachable via
148
123
  // the `agentfootprint/memory` subpath import.
149
- export {
150
- // Pipelines
151
- defaultPipeline, ephemeralPipeline, factPipeline, narrativePipeline, semanticPipeline, autoPipeline, } from './memory/pipeline/index.js';
152
- export {
153
- // Beat extractors
154
- heuristicExtractor, llmExtractor, } from './memory/beats/index.js';
155
- export {
156
- // Fact extractors
157
- patternFactExtractor, llmFactExtractor, } from './memory/facts/index.js';
158
- export {
159
- // Layered memory API — consumer-facing factory + const-objects
160
- defineMemory, MEMORY_TYPES, MEMORY_STRATEGIES, MEMORY_TIMING, SNAPSHOT_PROJECTIONS,
161
- // Reference implementations + helpers consumers reach for daily.
162
- // Real-backend adapters (Redis, Postgres, Pinecone, ...) ship as
163
- // separate subpath exports.
164
- InMemoryStore, mockEmbedder, identityNamespace, } from './memory/index.js';
165
124
  // RAG — retrieval-augmented generation as a context-engineering flavor.
166
125
  // Thin sugar over `defineMemory({ type: SEMANTIC, strategy: TOP_K })`
167
126
  // plus the `indexDocuments` helper for seeding the corpus at startup.
@@ -170,19 +129,15 @@ export { defineRAG, indexDocuments, } from './lib/rag/index.js';
170
129
  // expose their tools as agentfootprint Tool[] for `agent.tools(...)`.
171
130
  // `@modelcontextprotocol/sdk` is a lazy-required peer-dep (no runtime
172
131
  // cost when MCP isn't used).
173
- export { mcpClient, mockMcpClient, } from './lib/mcp/index.js';
174
132
  // Tool dispatch primitives (v2.5+). New `agentfootprint/tool-providers`
175
133
  // subpath bundles tool sources (mcpClient / mockMcpClient) with tool
176
134
  // dispatch primitives (staticTools / gatedTools) so consumers find
177
135
  // "everything tool-related" in one place. Top-level barrel re-exports
178
136
  // the dispatch primitives too — `mcpClient` already re-exports above.
179
- export { staticTools, gatedTools, skillScopedTools, } from './tool-providers/index.js';
180
137
  // Cross-cutting authorization (v2.5+). `agentfootprint/security` is the
181
138
  // dedicated subpath; the root barrel also re-exports `PermissionPolicy`
182
139
  // so existing v2.4 consumers find it at the top level.
183
- export { PermissionPolicy, PolicyHaltError, } from './security/index.js';
184
140
  // Message Catalog Pattern (v2.5+). `agentfootprint/locales` is the
185
141
  // dedicated subpath; the root barrel also re-exports the helpers so
186
142
  // existing v2.4 consumers find them at the top level.
187
- export { defaultCommentaryMessages, defaultThinkingMessages, composeMessages, validateMessages, } from './locales/index.js';
188
143
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,oEAAoE;AACpE,8DAA8D;AAC9D,uEAAuE;AACvE,kEAAkE;AAClE,sEAAsE;AACtE,sDAAsD;AACtD,OAAO,8CAA8C,CAAC;AACtD,OAAO,2CAA2C,CAAC;AACnD,OAAO,4CAA4C,CAAC;AAsCpD,qCAAqC;AACrC,cAAc,mBAAmB,CAAC;AAMlC,OAAO,EACL,WAAW,EACX,eAAe,GAIhB,MAAM,sBAAsB,CAAC;AAE9B,aAAa;AACb,OAAO,EACL,eAAe,GAQhB,MAAM,wBAAwB,CAAC;AAEhC,6BAA6B;AAC7B,cAAc,qBAAqB,CAAC;AAEpC,yEAAyE;AACzE,uDAAuD;AACvD,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,cAAc;AAEd,yEAAyE;AACzE,wEAAwE;AACxE,yEAAyE;AACzE,gBAAgB;AAChB,SAAS;AAET,2EAA2E;AAC3E,6EAA6E;AAC7E,6EAA6E;AAC7E,6DAA6D;AAC7D,YAAY,GAGb,MAAM,kBAAkB,CAAC;AAC1B,oEAAoE;AACpE,yEAAyE;AACzE,wEAAwE;AACxE,qEAAqE;AACrE,kDAAkD;AAClD,OAAO,EACL,gBAAgB,GAMjB,MAAM,2BAA2B,CAAC;AAEnC,gBAAgB;AAChB,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAmB,MAAM,uBAAuB,CAAC;AAE1F,yCAAyC;AACzC,EAAE;AACF,yEAAyE;AACzE,kEAAkE;AAClE,oEAAoE;AACpE,qEAAqE;AACrE,2EAA2E;AAC3E,8EAA8E;AAC9E,0DAA0D;AAC1D,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,gBAAgB,EAChB,kBAAkB,EAClB,gBAAgB,GAKjB,MAAM,wCAAwC,CAAC;AAChD,OAAO,EAAE,UAAU,EAA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AC;AACjC,OAAO,EACL,QAAQ,EACR,eAAe,GAShB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,WAAW,EACX,kBAAkB,GAKnB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,IAAI,EACJ,WAAW,GAKZ,MAAM,qBAAqB,CAAC;AAE7B,2BAA2B;AAC3B,8EAA8E;AAC9E,wEAAwE;AACxE,mEAAmE;AACnE,qEAAqE;AACrE,EAAE;AACF,kEAAkE;AAClE,qEAAqE;AACrE,wEAAwE;AACxE,gEAAgE;AAChE,gEAAgE;AAChE,6CAA6C;AAC7C,EAAE;AACF,2FAA2F;AAC3F,wFAAwF;AAExF,OAAO,EACL,eAAe,GAIhB,MAAM,kCAAkC,CAAC;AAE1C,+DAA+D;AAE/D,oEAAoE;AACpE,gEAAgE;AAEhE,qEAAqE;AACrE,0DAA0D;AAC1D,cAAc,qBAAqB,CAAC;AAEpC,uEAAuE;AACvE,uEAAuE;AACvE,oEAAoE;AACpE,sEAAsE;AACtE,8CAA8C;AAE9C,wEAAwE;AACxE,sEAAsE;AACtE,sEAAsE;AACtE,OAAO,EACL,SAAS,EAET,cAAc,GAGf,MAAM,oBAAoB,CAAC;AAE5B,kEAAkE;AAClE,sEAAsE;AACtE,sEAAsE;AACtE,6BAA6B;AAE7B,wEAAwE;AACxE,qEAAqE;AACrE,mEAAmE;AACnE,sEAAsE;AACtE,sEAAsE;AAEtE,wEAAwE;AACxE,wEAAwE;AACxE,uDAAuD;AAEvD,mEAAmE;AACnE,oEAAoE;AACpE,sDAAsD"}
@@ -0,0 +1,4 @@
1
+ /**
2
+ * agentfootprint/injection-engine — public re-export for the InjectionEngine subsystem.
3
+ */
4
+ export * from './lib/injection-engine/index.js';
@@ -0,0 +1,56 @@
1
+ /**
2
+ * canonicalJson — deterministic JSON serialization (`afp-cjson/1`).
3
+ *
4
+ * Pattern: Canonicalization function (RFC 8785 JCS-inspired, JS-native).
5
+ * Role: The byte contract under the tamper-evident audit chain
6
+ * (backlog #20). `AuditRecord.hash` = SHA-256 over the
7
+ * canonical serialization of the record — two parties that
8
+ * serialize the same VALUE must produce the same BYTES, or
9
+ * verification breaks. These rules ARE the contract; bump the
10
+ * identifier (`afp-cjson/2`) for ANY behavioral change.
11
+ *
12
+ * ## Canonicalization rules (`afp-cjson/1`)
13
+ *
14
+ * 1. **Objects** — own enumerable string-keyed properties only, keys
15
+ * sorted lexicographically by UTF-16 code unit (JavaScript's
16
+ * default `Array.prototype.sort()` comparison), serialized
17
+ * `{"k":v,...}` with no whitespace. Symbol keys are ignored.
18
+ * 2. **Arrays** — element order preserved, `[v,...]` no whitespace.
19
+ * 3. **Strings** — `JSON.stringify` escaping (deterministic per the
20
+ * ECMAScript spec: minimal escapes, lowercase `\uXXXX` hex).
21
+ * 4. **Numbers** — finite numbers via `JSON.stringify` (ECMAScript
22
+ * shortest round-trip formatting). `NaN` / `±Infinity` → `null`
23
+ * (JSON.stringify parity). `-0` serializes as `0`.
24
+ * 5. **`null`** → `null`. **`undefined`** — omitted as an object
25
+ * property, `null` as an array element or top-level value
26
+ * (JSON.stringify parity).
27
+ * 6. **Functions / symbols** — omitted as object properties, `null`
28
+ * in arrays (JSON.stringify parity).
29
+ * 7. **`toJSON`** — honored before serialization (so `Date` →
30
+ * ISO-8601 string, exactly like `JSON.stringify`).
31
+ * 8. **`bigint`** → `TypeError` (JSON.stringify parity). Sanitize
32
+ * upstream (the audit bounding layer converts bigint to string).
33
+ * 9. **Cycles** → `TypeError`. Canonicalization is defined over
34
+ * JSON-safe trees; the audit bounding layer breaks cycles first.
35
+ *
36
+ * The domain is "anything `JSON.parse` can produce" (the audit bundle
37
+ * is JSON); for other inputs the behavior mirrors `JSON.stringify`
38
+ * except that object keys are SORTED. Verification re-canonicalizes
39
+ * records that came through `JSON.parse(JSON.stringify(bundle))`, so
40
+ * round-tripping a bundle never changes its hashes.
41
+ *
42
+ * Browser-safe: no Node imports — pure computation.
43
+ */
44
+ /** Identifier of the canonicalization rules implemented by
45
+ * {@link canonicalJson}. Carried on `AuditBundleHeader.canonicalization`
46
+ * so offline verifiers can reject bundles produced under different
47
+ * rules instead of mis-verifying them. */
48
+ export declare const CANONICAL_JSON_VERSION = "afp-cjson/1";
49
+ /**
50
+ * Serialize `value` to canonical JSON (see module docs for the exact
51
+ * `afp-cjson/1` rules). Deterministic: equal values (after key
52
+ * reordering) always produce identical strings.
53
+ *
54
+ * @throws TypeError on circular references or bigint values.
55
+ */
56
+ export declare function canonicalJson(value: unknown): string;
@@ -0,0 +1,109 @@
1
+ /**
2
+ * Ablation — the counterfactual seam (RFC-003 Part B, D8 stage 4 + the
3
+ * D9 stats engine).
4
+ *
5
+ * Three pieces:
6
+ *
7
+ * 1. **Adapters** — `ablationForSuspect` maps a classified suspect to
8
+ * the spec that removes it (tool → drop from catalog; injection /
9
+ * fact / skill → exclude the `Injection.id`; memory → filter the
10
+ * `MemoryEntry.id`; arg → consumer-override note).
11
+ *
12
+ * 2. **The seam** — `applyAblations` filters the inputs an agent is
13
+ * BUILT from. Documented here because the seam did not previously
14
+ * exist: `AgentOptions` has no `ignoredTools` runtime kill-switch, so
15
+ * tool ablation happens at construction (the consumer's
16
+ * `AblationRunner` rebuilds the agent from filtered inputs). Same for
17
+ * injections and memory entries.
18
+ *
19
+ * 3. **The probe engine** — `runAblationProbe` calls the consumer's
20
+ * runner N seeded times, measures embedding similarity to the
21
+ * original output, counts outcome flips, and returns variance —
22
+ * never a single-run verdict (D9 discipline).
23
+ *
24
+ * §B2: only `runAblationProbe`-derived verdicts are causal claims; every
25
+ * score elsewhere is a correlational proxy.
26
+ */
27
+ import type { Embedder } from '../influence-core/index.js';
28
+ import type { AblationRerun, AblationRunStats, AblationSpec, AblationVerdict, CostStats, OutcomeComparator, SimilarityStats, Suspect } from './types.js';
29
+ /**
30
+ * The spec that removes one suspect — or `undefined` for kind `'stage'`
31
+ * (plain pipeline stages have no removable input; re-rank or refactor).
32
+ */
33
+ export declare function ablationForSuspect(suspect: Suspect): AblationSpec | undefined;
34
+ /** Anything with a stable id — `Injection` and `MemoryEntry` both fit. */
35
+ interface Identified {
36
+ readonly id: string;
37
+ }
38
+ /** Anything with a named schema — the library's `Tool` fits. */
39
+ interface NamedTool {
40
+ readonly schema: {
41
+ readonly name: string;
42
+ };
43
+ }
44
+ export interface AblationTargets<TTool extends NamedTool = NamedTool, TInjection extends Identified = Identified, TMemoryEntry extends Identified = Identified> {
45
+ readonly tools?: readonly TTool[];
46
+ readonly injections?: readonly TInjection[];
47
+ readonly memoryEntries?: readonly TMemoryEntry[];
48
+ }
49
+ /**
50
+ * Apply ablation specs to the inputs an agent is constructed from —
51
+ * THE documented seam (see module docs). Generic over the concrete tool /
52
+ * injection / memory-entry types so it filters without importing them.
53
+ *
54
+ * `'arg'` specs are deliberately NOT handled here: run input belongs to
55
+ * the consumer's runner (`spec.note` says so).
56
+ *
57
+ * @example inside an AblationRunner
58
+ * ```ts
59
+ * const { tools, injections } = applyAblations(specs, {
60
+ * tools: ALL_TOOLS, injections: ALL_FACTS,
61
+ * });
62
+ * const agent = Agent.create({ provider: freshProvider(), model })
63
+ * .tools([...tools]);
64
+ * for (const inj of injections) agent.fact(inj);
65
+ * ```
66
+ */
67
+ export declare function applyAblations<TTool extends NamedTool, TInjection extends Identified, TMemoryEntry extends Identified>(specs: readonly AblationSpec[], targets: AblationTargets<TTool, TInjection, TMemoryEntry>): {
68
+ tools: readonly TTool[];
69
+ injections: readonly TInjection[];
70
+ memoryEntries: readonly TMemoryEntry[];
71
+ };
72
+ /** Resolve the seeded-rerun count: default on non-finite, floor, clamp to >= 2
73
+ * (no single-run verdicts — D9). Shared by the ablation + restoration probes. */
74
+ export declare function resolveSamples(samples: number | undefined): number;
75
+ /** Median of a numeric sample (mean of the two middles for even length). */
76
+ export declare function median(values: readonly number[]): number;
77
+ /** Build a probe's CostStats from per-seed loop/token samples — undefined when
78
+ * the runner reported no cost (keeps quality-only behavior byte-identical). */
79
+ export declare function costStatsFrom(samples: number, loops: readonly number[], tokens: readonly number[]): CostStats | undefined;
80
+ export declare function similarityStats(values: readonly number[]): SimilarityStats;
81
+ /** The default comparator: embedding similarity below the threshold. */
82
+ export declare function defaultOutcomeComparator(embedder: Embedder, flipThreshold: number): OutcomeComparator;
83
+ /** Resolved probe configuration shared by D8 and D9. */
84
+ export interface ProbeConfig {
85
+ readonly rerun: AblationRerun;
86
+ readonly embedder: Embedder;
87
+ }
88
+ /**
89
+ * Run ONE probe: call the consumer's runner with `specs` once per seed
90
+ * (0..samples-1), measure each output's embedding similarity to the
91
+ * original, and count outcome flips. Variance is always reported.
92
+ *
93
+ * `samples` is clamped to ≥ 2 — D9: never single-run verdicts.
94
+ */
95
+ export declare function runAblationProbe(config: ProbeConfig, specs: readonly AblationSpec[]): Promise<AblationRunStats>;
96
+ /** Majority-flip rule shared by D8 verdicts and D9 probes. */
97
+ export declare function probeFlipped(stats: AblationRunStats): boolean;
98
+ /**
99
+ * Translate probe evidence into the verdict — the ONLY causal claim tier
100
+ * (§B2). `baselineStable=false` (the un-ablated scenario itself flipped)
101
+ * forces `'inconclusive'`: no ablation verdict is trustworthy on an
102
+ * unstable baseline.
103
+ */
104
+ export declare function verdictFor(label: string, stats: AblationRunStats, baselineStable: boolean,
105
+ /** The counterfactual intervention. `'ablating'` (default) for present
106
+ * suspects; `'restoring'` for missing-context candidates (interface #3).
107
+ * Default keeps every claim string byte-identical to before. */
108
+ action?: 'ablating' | 'restoring'): AblationVerdict;
109
+ export {};
@@ -0,0 +1,75 @@
1
+ /**
2
+ * bisectCulprits — multi-culprit bisection over the ranked suspect set
3
+ * (RFC-003 Part B, block D9). The "git bisect" of the localizer.
4
+ *
5
+ * When single-suspect ablations don't flip the outcome — redundant causes
6
+ * (two facts that EACH justify the wrong answer), or interacting ones —
7
+ * the culprit is a SET. This harness finds a minimal culprit set by
8
+ * recursive halving over the ranked suspects (delta-debugging style,
9
+ * Zeller's ddmin specialized to two-way splits), then keeps searching the
10
+ * remainder for INDEPENDENT culprits until the remainder stops flipping.
11
+ *
12
+ * Probe semantics (the D9 discipline):
13
+ * - every probe = N seeded reruns of the consumer's `AblationRunner`
14
+ * with the probe's combined specs; "flipped" = MAJORITY of runs
15
+ * changed outcome; similarity mean ± spread is always reported —
16
+ * never single-run verdicts;
17
+ * - probe 0 is the BASELINE (no ablation): if it flips, the scenario
18
+ * itself is unstable and the result is honestly `'inconclusive'`;
19
+ * - probes are cached by spec-set, and budgeted (`maxProbes`) — running
20
+ * out of budget yields `'inconclusive'`, never a partial claim
21
+ * dressed up as a finding.
22
+ *
23
+ * §B2: the returned `verdict`/`culprits` are CAUSAL claims — they rest
24
+ * exclusively on counterfactual reruns. The input ranking only chooses
25
+ * the SEARCH ORDER (better ranking = fewer probes), it never decides the
26
+ * outcome.
27
+ */
28
+ import type { AblationRerun, AblationRunStats, Embedder, Suspect } from './types.js';
29
+ /** One executed probe — full variance evidence, kept for the report. */
30
+ export interface BisectionProbe {
31
+ /** Labels of the suspects ablated together ([] = the baseline probe). */
32
+ readonly ablated: readonly string[];
33
+ readonly stats: AblationRunStats;
34
+ /** Majority-of-N outcome flip. */
35
+ readonly flipped: boolean;
36
+ }
37
+ export interface BisectionResult {
38
+ /**
39
+ * `'confirmed'` — a minimal culprit set was found and verified by
40
+ * counterfactual reruns. `'not-reproducible'` — ablating EVERY ranked
41
+ * suspect together does not flip the outcome: the bug's cause is not
42
+ * in the ranked set (look at the report's honesty flags — the slice
43
+ * may be incomplete). `'inconclusive'` — unstable baseline or probe
44
+ * budget exhausted.
45
+ */
46
+ readonly verdict: 'confirmed' | 'not-reproducible' | 'inconclusive';
47
+ /**
48
+ * Minimal culprit set(s): each inner array is one minimal set whose
49
+ * JOINT ablation flips the outcome. Independent culprits appear as
50
+ * separate sets; redundant/interacting causes appear together in one.
51
+ */
52
+ readonly culprits: readonly (readonly Suspect[])[];
53
+ /** Every probe executed, in order (baseline first). */
54
+ readonly probes: readonly BisectionProbe[];
55
+ /** Total consumer-runner invocations (probes × samples). */
56
+ readonly runsUsed: number;
57
+ }
58
+ export interface BisectCulpritsOptions {
59
+ /** Ranked suspects — only those carrying an applicable ablation spec
60
+ * participate ('arg' and 'stage' suspects are skipped: nothing the
61
+ * harness can remove for the consumer). */
62
+ readonly suspects: readonly Suspect[];
63
+ readonly rerun: AblationRerun;
64
+ /** Embedder for similarity stats (and the default flip comparator). */
65
+ readonly embedder: Embedder;
66
+ /** Probe budget. Default 24. Exhaustion → 'inconclusive'. */
67
+ readonly maxProbes?: number;
68
+ /** Max independent culprit sets to search for. Default 4. */
69
+ readonly maxCulprits?: number;
70
+ }
71
+ /**
72
+ * Find minimal culprit set(s) by seeded counterfactual bisection. See
73
+ * module docs for semantics and the §B2 claim tier.
74
+ */
75
+ export declare function bisectCulprits(options: BisectCulpritsOptions): Promise<BisectionResult>;
@@ -0,0 +1,37 @@
1
+ /**
2
+ * cost — the SECOND score of two-score localization (proposal 004).
3
+ *
4
+ * A context bug costs you twice: a wrong ANSWER (the flip `verdict`, the strong
5
+ * causal tier) OR extra COST — loops/tokens — even when a capable model recovers
6
+ * and answers correctly. This module reads the cost score from the SAME ablation
7
+ * reruns (`AblationRunStats.cost`, captured in `runAblationProbe`) and attaches a
8
+ * `CostVerdict` to each suspect, then classifies each on the 2×2.
9
+ *
10
+ * HONEST TIER (the two-lens review): the cost score is a WEAKER, gated tier than
11
+ * the flip. Removing a piece reducing cost shows **necessity for the cost, NOT
12
+ * that the work was "wasted"** (the piece could be load-bearing scaffolding). So:
13
+ * - PLACEBO control — a cost cause must beat the loops-saved of pieces whose
14
+ * removal did NOT flip the answer (benign path variance), leave-one-out;
15
+ * (v1 limitation: the placebo population is the non-flipping suspects, which
16
+ * may themselves include real cost causes — so the band's MAX is CONSERVATIVE
17
+ * and UNDER-detects when several pieces reduce cost by similar amounts. Safe
18
+ * direction for a causal-ish claim. A dedicated neutral-filler placebo is v2.)
19
+ * - STABILITY — every ablated rerun used no MORE loops than baseline
20
+ * (consistent reduction; an integer ±1 delta is brittle — determinism ≠
21
+ * robustness), AND a placebo band existed to clear.
22
+ */
23
+ import type { AblationRunStats, Suspect, SuspectClass } from './types.js';
24
+ /** Minimum loops saved (over the placebo band) to call a piece a cost cause. */
25
+ export declare const MIN_LOOPS_SAVED = 1;
26
+ /**
27
+ * Attach a `CostVerdict` to each suspect from the ablation reruns + a
28
+ * leave-one-out placebo control. Suspects without cost data are returned
29
+ * unchanged (quality-only). See the module honesty note.
30
+ */
31
+ export declare function assignCostVerdicts(suspects: readonly Suspect[], baseline: AblationRunStats): Suspect[];
32
+ /**
33
+ * Derive the 2×2 class from the flip verdict (quality) and the cost verdict.
34
+ * The no-bug cell is `'no-detected-effect'` — never "innocent" (a piece can
35
+ * matter in ways neither axis sees: overdetermination, same-loops-different-path).
36
+ */
37
+ export declare function classifySuspect(suspect: Suspect): SuspectClass;
@@ -0,0 +1,31 @@
1
+ /**
2
+ * context-bisect — RFC-003 Part B: the contextual-bug LOCALIZER,
3
+ * "git bisect for context".
4
+ *
5
+ * Assembly over shipped pieces: footprintjs 9.8.0's complete causal DAG
6
+ * (control edges, honesty markers, `EdgeWeigher` hook) × influence-core
7
+ * scoring (D6) × consumer-run counterfactual ablation.
8
+ *
9
+ * D7 — `llmEdgeWeigher` influence-weighted LLM-call slice edges
10
+ * D8 — `localizeContextBug` trigger → slice → ranked suspects → ablation
11
+ * D9 — `bisectCulprits` seeded multi-culprit bisection + variance
12
+ *
13
+ * §B2 claim tiers (spelled out on every type): weights/scores are
14
+ * embedding-geometry PROXIES; ablation verdicts are the ONLY causal
15
+ * claims; slice completeness is bounded by tracking — and says so.
16
+ *
17
+ * @beta Beta feature (RFC-003 Part B). The API works and is tested, but
18
+ * may change before GA.
19
+ */
20
+ export { llmEdgeWeigher, stepOutputText, type LlmEdgeWeigherHandle, type LlmEdgeWeigherOptions, type RankedParentEdge, } from './llmEdgeWeigher.js';
21
+ export { findDroppedContext, type ContextUnit, type DroppedUnit, type MissingContextResult, } from './missingContext.js';
22
+ export { runRestorationProbe, type RestorationProbeConfig, type RestorationRerun, type RestorationRunner, } from './restoration.js';
23
+ export { defaultSuspectClassifier, formatContextBugReport, llmCallIdsFromEvents, localizeContextBug, suspectLabel, type ClassifyContext, type LocalizeContextBugOptions, type SuspectClassifier, type SuspectSeed, } from './localize.js';
24
+ export { toBacktrackTrace, type BacktrackCustodyHop, type BacktrackHop, type BacktrackSuspectCard, type BacktrackTrace, type BacktrackTrail, type ToBacktrackTraceOptions, } from './toBacktrackTrace.js';
25
+ export { ablationForSuspect, applyAblations, costStatsFrom, defaultOutcomeComparator, median, probeFlipped, runAblationProbe, verdictFor, type AblationTargets, type ProbeConfig, } from './ablation.js';
26
+ export { assignCostVerdicts, classifySuspect, MIN_LOOPS_SAVED } from './cost.js';
27
+ export { shortlistEarlyCulprits, DEFAULT_RECENCY_DECAY, type LoopCandidate, type LoopRecallShortlist, type ShortlistEarlyCulpritsOptions, } from './loop-recall.js';
28
+ export { walkToRoot, walkTrajectory, buildWriterFrameIndex, type RootCauseHop, type RootCauseNote, type RootCausePath, type WalkToRootOptions, } from './walk-to-root.js';
29
+ export { assembleTrajectory, bucketByAnchors, findLoopHeads, type AnchorBucket, type AssembleTrajectoryOptions, type ContextSource, type LoopFrame, type SyntheticQuestionNode, type Trajectory, } from './trajectory.js';
30
+ export { bisectCulprits, type BisectCulpritsOptions, type BisectionProbe, type BisectionResult, } from './bisect.js';
31
+ export { CONTEXT_BISECT_DEFAULTS, type AblationRerun, type AblationRunner, type AblationRunStats, type AblationSpec, type AblationVerdict, type AblationVerdictKind, type CapturedEventLike, type ContextBugArtifacts, type ContextBugReport, type CostRange, type CostStats, type CostVerdict, type EdgePathStep, type HonestyFlag, type HonestyFlagKind, type OutcomeComparator, type QualityTriggerLookup, type RestoredCandidate, type RunCost, type SimilarityStats, type SliceStats, type Suspect, type SuspectClass, type SuspectDetail, type SuspectKind, } from './types.js';
@@ -13,6 +13,9 @@
13
13
  * §B2 claim tiers (spelled out on every type): weights/scores are
14
14
  * embedding-geometry PROXIES; ablation verdicts are the ONLY causal
15
15
  * claims; slice completeness is bounded by tracking — and says so.
16
+ *
17
+ * @beta Beta feature (RFC-003 Part B). The API works and is tested, but
18
+ * may change before GA.
16
19
  */
17
20
  export { llmEdgeWeigher, stepOutputText, } from './llmEdgeWeigher.js';
18
21
  // Interface #3 — missing-context finder (available − sent; confirm by restoration).
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/lib/context-bisect/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EACL,cAAc,EACd,cAAc,GAIf,MAAM,qBAAqB,CAAC;AAE7B,oFAAoF;AACpF,OAAO,EACL,kBAAkB,GAInB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,mBAAmB,GAIpB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,wBAAwB,EACxB,sBAAsB,EACtB,oBAAoB,EACpB,kBAAkB,EAClB,YAAY,GAKb,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,gBAAgB,GAOjB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACL,kBAAkB,EAClB,cAAc,EACd,aAAa,EACb,wBAAwB,EACxB,MAAM,EACN,YAAY,EACZ,gBAAgB,EAChB,UAAU,GAGX,MAAM,eAAe,CAAC;AAEvB,8EAA8E;AAC9E,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAEjF,gGAAgG;AAChG,OAAO,EACL,sBAAsB,EACtB,qBAAqB,GAItB,MAAM,kBAAkB,CAAC;AAE1B,qGAAqG;AACrG,OAAO,EACL,UAAU,EACV,cAAc,EACd,qBAAqB,GAKtB,MAAM,mBAAmB,CAAC;AAE3B,4EAA4E;AAC5E,6CAA6C;AAC7C,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,aAAa,GAOd,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,cAAc,GAIf,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,uBAAuB,GA0BxB,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/lib/context-bisect/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EACL,cAAc,EACd,cAAc,GAIf,MAAM,qBAAqB,CAAC;AAE7B,oFAAoF;AACpF,OAAO,EACL,kBAAkB,GAInB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,mBAAmB,GAIpB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,wBAAwB,EACxB,sBAAsB,EACtB,oBAAoB,EACpB,kBAAkB,EAClB,YAAY,GAKb,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,gBAAgB,GAOjB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACL,kBAAkB,EAClB,cAAc,EACd,aAAa,EACb,wBAAwB,EACxB,MAAM,EACN,YAAY,EACZ,gBAAgB,EAChB,UAAU,GAGX,MAAM,eAAe,CAAC;AAEvB,8EAA8E;AAC9E,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAEjF,gGAAgG;AAChG,OAAO,EACL,sBAAsB,EACtB,qBAAqB,GAItB,MAAM,kBAAkB,CAAC;AAE1B,qGAAqG;AACrG,OAAO,EACL,UAAU,EACV,cAAc,EACd,qBAAqB,GAKtB,MAAM,mBAAmB,CAAC;AAE3B,4EAA4E;AAC5E,6CAA6C;AAC7C,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,aAAa,GAOd,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,cAAc,GAIf,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,uBAAuB,GA0BxB,MAAM,YAAY,CAAC"}