agentfootprint 6.44.0 → 6.45.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (366) hide show
  1. package/ai-instructions/setup.sh +0 -0
  2. package/dist/core/agent/buildAgentChart.js +2 -1
  3. package/dist/core/agent/buildAgentChart.js.map +1 -1
  4. package/dist/core/agent/buildDynamicAgentChart.js +3 -1
  5. package/dist/core/agent/buildDynamicAgentChart.js.map +1 -1
  6. package/dist/core/agent/stages/pickEntry.js +3 -1
  7. package/dist/core/agent/stages/pickEntry.js.map +1 -1
  8. package/dist/esm/adapters/identity/agentcore.d.ts +100 -0
  9. package/dist/esm/adapters/llm/AnthropicProvider.d.ts +130 -0
  10. package/dist/esm/adapters/llm/BedrockProvider.d.ts +100 -0
  11. package/dist/esm/adapters/llm/BrowserAnthropicProvider.d.ts +41 -0
  12. package/dist/esm/adapters/llm/BrowserOpenAIProvider.d.ts +95 -0
  13. package/dist/esm/adapters/llm/MockProvider.d.ts +153 -0
  14. package/dist/esm/adapters/llm/OpenAIProvider.d.ts +220 -0
  15. package/dist/esm/adapters/llm/createProvider.d.ts +85 -0
  16. package/dist/esm/adapters/memory/agentcore.d.ts +146 -0
  17. package/dist/esm/adapters/memory/bedrockAgentMemory.d.ts +95 -0
  18. package/dist/esm/adapters/memory/redis.d.ts +127 -0
  19. package/dist/esm/adapters/observability/agentcore.d.ts +67 -0
  20. package/dist/esm/adapters/observability/audit.d.ts +254 -0
  21. package/dist/esm/adapters/observability/cloudwatch.d.ts +96 -0
  22. package/dist/esm/adapters/observability/otel.d.ts +237 -0
  23. package/dist/esm/adapters/observability/xray.d.ts +88 -0
  24. package/dist/esm/adapters/types.d.ts +378 -0
  25. package/dist/esm/bridge/eventMeta.d.ts +59 -0
  26. package/dist/esm/cache/CacheDecisionSubflow.d.ts +85 -0
  27. package/dist/esm/cache/CacheGateDecider.d.ts +127 -0
  28. package/dist/esm/cache/applyCachePolicy.d.ts +37 -0
  29. package/dist/esm/cache/cacheRecorder.d.ts +85 -0
  30. package/dist/esm/cache/index.d.ts +33 -0
  31. package/dist/esm/cache/strategies/AnthropicCacheStrategy.d.ts +38 -0
  32. package/dist/esm/cache/strategies/BedrockCacheStrategy.d.ts +33 -0
  33. package/dist/esm/cache/strategies/NoOpCacheStrategy.d.ts +29 -0
  34. package/dist/esm/cache/strategies/OpenAICacheStrategy.d.ts +36 -0
  35. package/dist/esm/cache/strategyRegistry.d.ts +45 -0
  36. package/dist/esm/cache/types.d.ts +243 -0
  37. package/dist/esm/conventions.d.ts +203 -0
  38. package/dist/esm/core/Agent.d.ts +355 -0
  39. package/dist/esm/core/LLMCall.d.ts +139 -0
  40. package/dist/esm/core/RunnerBase.d.ts +267 -0
  41. package/dist/esm/core/agent/AgentBuilder.d.ts +565 -0
  42. package/dist/esm/core/agent/buildAgentChart.d.ts +109 -0
  43. package/dist/esm/core/agent/buildAgentChart.js +2 -1
  44. package/dist/esm/core/agent/buildAgentChart.js.map +1 -1
  45. package/dist/esm/core/agent/buildAgentMessageApiChart.d.ts +40 -0
  46. package/dist/esm/core/agent/buildCacheSubflow.d.ts +35 -0
  47. package/dist/esm/core/agent/buildDynamicAgentChart.d.ts +56 -0
  48. package/dist/esm/core/agent/buildDynamicAgentChart.js +3 -1
  49. package/dist/esm/core/agent/buildDynamicAgentChart.js.map +1 -1
  50. package/dist/esm/core/agent/buildMessageApiChart.d.ts +47 -0
  51. package/dist/esm/core/agent/buildToolRegistry.d.ts +61 -0
  52. package/dist/esm/core/agent/memoryRecallInjections.d.ts +8 -0
  53. package/dist/esm/core/agent/stages/breakFinal.d.ts +22 -0
  54. package/dist/esm/core/agent/stages/callLLM.d.ts +74 -0
  55. package/dist/esm/core/agent/stages/pickEntry.d.ts +19 -0
  56. package/dist/esm/core/agent/stages/pickEntry.js +3 -1
  57. package/dist/esm/core/agent/stages/pickEntry.js.map +1 -1
  58. package/dist/esm/core/agent/stages/prepareFinal.d.ts +19 -0
  59. package/dist/esm/core/agent/stages/reliabilityExecution.d.ts +135 -0
  60. package/dist/esm/core/agent/stages/route.d.ts +18 -0
  61. package/dist/esm/core/agent/stages/seed.d.ts +53 -0
  62. package/dist/esm/core/agent/stages/toolCalls.d.ts +76 -0
  63. package/dist/esm/core/agent/toolArgsValidation.d.ts +62 -0
  64. package/dist/esm/core/agent/types.d.ts +382 -0
  65. package/dist/esm/core/agent/validators.d.ts +52 -0
  66. package/dist/esm/core/cost.d.ts +38 -0
  67. package/dist/esm/core/flowchartAsTool.d.ts +200 -0
  68. package/dist/esm/core/humanizeLLMError.d.ts +23 -0
  69. package/dist/esm/core/outputFallback.d.ts +139 -0
  70. package/dist/esm/core/outputSchema.d.ts +127 -0
  71. package/dist/esm/core/pause.d.ts +74 -0
  72. package/dist/esm/core/runCheckpoint.d.ts +179 -0
  73. package/dist/esm/core/runner.d.ts +203 -0
  74. package/dist/esm/core/slots/buildMessagesSlot.d.ts +40 -0
  75. package/dist/esm/core/slots/buildSystemPromptSlot.d.ts +41 -0
  76. package/dist/esm/core/slots/buildThinkingSubflow.d.ts +40 -0
  77. package/dist/esm/core/slots/buildToolsSlot.d.ts +60 -0
  78. package/dist/esm/core/slots/helpers.d.ts +27 -0
  79. package/dist/esm/core/toolContract.d.ts +43 -0
  80. package/dist/esm/core/tools.d.ts +90 -0
  81. package/dist/esm/core/translator.d.ts +94 -0
  82. package/dist/esm/core-flow/Conditional.d.ts +119 -0
  83. package/dist/esm/core-flow/Loop.d.ts +160 -0
  84. package/dist/esm/core-flow/Parallel.d.ts +360 -0
  85. package/dist/esm/core-flow/Sequence.d.ts +133 -0
  86. package/dist/esm/events/dispatcher.d.ts +134 -0
  87. package/dist/esm/events/payloads.d.ts +761 -0
  88. package/dist/esm/events/registry.d.ts +198 -0
  89. package/dist/esm/events/types.d.ts +70 -0
  90. package/dist/esm/identity/kinds.d.ts +36 -0
  91. package/dist/esm/identity/staticTokens.d.ts +28 -0
  92. package/dist/esm/identity/types.d.ts +113 -0
  93. package/dist/esm/identity/withCredentialRetry.d.ts +64 -0
  94. package/dist/esm/identity.d.ts +31 -0
  95. package/dist/esm/index.d.ts +64 -0
  96. package/dist/esm/index.js +2 -0
  97. package/dist/esm/index.js.map +1 -1
  98. package/dist/esm/injection-engine.d.ts +4 -0
  99. package/dist/esm/lib/canonicalJson.d.ts +56 -0
  100. package/dist/esm/lib/context-bisect/ablation.d.ts +109 -0
  101. package/dist/esm/lib/context-bisect/bisect.d.ts +75 -0
  102. package/dist/esm/lib/context-bisect/cost.d.ts +37 -0
  103. package/dist/esm/lib/context-bisect/index.d.ts +31 -0
  104. package/dist/esm/lib/context-bisect/index.js +3 -0
  105. package/dist/esm/lib/context-bisect/index.js.map +1 -1
  106. package/dist/esm/lib/context-bisect/llmEdgeWeigher.d.ts +124 -0
  107. package/dist/esm/lib/context-bisect/localize.d.ts +152 -0
  108. package/dist/esm/lib/context-bisect/localize.js +2 -0
  109. package/dist/esm/lib/context-bisect/localize.js.map +1 -1
  110. package/dist/esm/lib/context-bisect/loop-recall.d.ts +97 -0
  111. package/dist/esm/lib/context-bisect/missingContext.d.ts +71 -0
  112. package/dist/esm/lib/context-bisect/restoration.d.ts +39 -0
  113. package/dist/esm/lib/context-bisect/toBacktrackTrace.d.ts +138 -0
  114. package/dist/esm/lib/context-bisect/trajectory.d.ts +168 -0
  115. package/dist/esm/lib/context-bisect/types.d.ts +448 -0
  116. package/dist/esm/lib/context-bisect/walk-to-root.d.ts +103 -0
  117. package/dist/esm/lib/influence-core/attributability.d.ts +72 -0
  118. package/dist/esm/lib/influence-core/cache.d.ts +94 -0
  119. package/dist/esm/lib/influence-core/contrastive.d.ts +26 -0
  120. package/dist/esm/lib/influence-core/index.d.ts +34 -0
  121. package/dist/esm/lib/influence-core/margin.d.ts +33 -0
  122. package/dist/esm/lib/influence-core/signals.d.ts +128 -0
  123. package/dist/esm/lib/influence-core/similarity.d.ts +25 -0
  124. package/dist/esm/lib/influence-core/types.d.ts +252 -0
  125. package/dist/esm/lib/injection-engine/SkillRegistry.d.ts +147 -0
  126. package/dist/esm/lib/injection-engine/buildInjectionEngineSubflow.d.ts +110 -0
  127. package/dist/esm/lib/injection-engine/buildInjectionEngineSubflow.js +1 -0
  128. package/dist/esm/lib/injection-engine/buildInjectionEngineSubflow.js.map +1 -1
  129. package/dist/esm/lib/injection-engine/entryScorer.d.ts +93 -0
  130. package/dist/esm/lib/injection-engine/entryScorer.js +172 -0
  131. package/dist/esm/lib/injection-engine/entryScorer.js.map +1 -0
  132. package/dist/esm/lib/injection-engine/evaluator.d.ts +24 -0
  133. package/dist/esm/lib/injection-engine/factories/defineFact.d.ts +60 -0
  134. package/dist/esm/lib/injection-engine/factories/defineInjection.d.ts +41 -0
  135. package/dist/esm/lib/injection-engine/factories/defineInstruction.d.ts +78 -0
  136. package/dist/esm/lib/injection-engine/factories/defineRelevanceHint.d.ts +26 -0
  137. package/dist/esm/lib/injection-engine/factories/defineSkill.d.ts +160 -0
  138. package/dist/esm/lib/injection-engine/factories/defineSteering.d.ts +39 -0
  139. package/dist/esm/lib/injection-engine/index.d.ts +22 -0
  140. package/dist/esm/lib/injection-engine/index.js +1 -0
  141. package/dist/esm/lib/injection-engine/index.js.map +1 -1
  142. package/dist/esm/lib/injection-engine/skillContract.d.ts +29 -0
  143. package/dist/esm/lib/injection-engine/skillGraph.d.ts +289 -0
  144. package/dist/esm/lib/injection-engine/skillGraph.js +35 -41
  145. package/dist/esm/lib/injection-engine/skillGraph.js.map +1 -1
  146. package/dist/esm/lib/injection-engine/skillGraphCheckup.d.ts +49 -0
  147. package/dist/esm/lib/injection-engine/skillTools.d.ts +72 -0
  148. package/dist/esm/lib/injection-engine/softmax.d.ts +11 -0
  149. package/dist/esm/lib/injection-engine/types.d.ts +229 -0
  150. package/dist/esm/lib/injection-engine/types.js.map +1 -1
  151. package/dist/esm/lib/lazyRequire.d.ts +29 -0
  152. package/dist/esm/lib/mcp/index.d.ts +9 -0
  153. package/dist/esm/lib/mcp/mcpClient.d.ts +46 -0
  154. package/dist/esm/lib/mcp/mockMcpClient.d.ts +65 -0
  155. package/dist/esm/lib/mcp/types.d.ts +133 -0
  156. package/dist/esm/lib/rag/defineRAG.d.ts +139 -0
  157. package/dist/esm/lib/rag/index.d.ts +7 -0
  158. package/dist/esm/lib/rag/indexDocuments.d.ts +105 -0
  159. package/dist/esm/lib/tool-lint/analyze.d.ts +83 -0
  160. package/dist/esm/lib/tool-lint/cli.d.ts +43 -0
  161. package/dist/esm/lib/tool-lint/format.d.ts +18 -0
  162. package/dist/esm/lib/tool-lint/index.d.ts +23 -0
  163. package/dist/esm/lib/tool-lint/rules.d.ts +85 -0
  164. package/dist/esm/lib/tool-lint/types.d.ts +155 -0
  165. package/dist/esm/lib/trace-toolpack/bounded.d.ts +47 -0
  166. package/dist/esm/lib/trace-toolpack/debugPrompt.d.ts +19 -0
  167. package/dist/esm/lib/trace-toolpack/index.d.ts +20 -0
  168. package/dist/esm/lib/trace-toolpack/lazyToolpack.d.ts +35 -0
  169. package/dist/esm/lib/trace-toolpack/selfExplain.d.ts +100 -0
  170. package/dist/esm/lib/trace-toolpack/traceDebugAgent.d.ts +42 -0
  171. package/dist/esm/lib/trace-toolpack/traceToolpack.d.ts +69 -0
  172. package/dist/esm/lib/trace-toolpack/types.d.ts +59 -0
  173. package/dist/esm/llm-providers.d.ts +26 -0
  174. package/dist/esm/locales/index.d.ts +132 -0
  175. package/dist/esm/memory/beats/extractBeats.d.ts +61 -0
  176. package/dist/esm/memory/beats/extractor.d.ts +47 -0
  177. package/dist/esm/memory/beats/formatAsNarrative.d.ts +62 -0
  178. package/dist/esm/memory/beats/heuristicExtractor.d.ts +37 -0
  179. package/dist/esm/memory/beats/index.d.ts +12 -0
  180. package/dist/esm/memory/beats/llmExtractor.d.ts +56 -0
  181. package/dist/esm/memory/beats/types.d.ts +60 -0
  182. package/dist/esm/memory/beats/writeBeats.d.ts +22 -0
  183. package/dist/esm/memory/causal/evidenceRecorder.d.ts +66 -0
  184. package/dist/esm/memory/causal/index.d.ts +6 -0
  185. package/dist/esm/memory/causal/loadSnapshot.d.ts +51 -0
  186. package/dist/esm/memory/causal/snapshotPipeline.d.ts +35 -0
  187. package/dist/esm/memory/causal/types.d.ts +130 -0
  188. package/dist/esm/memory/causal/writeSnapshot.d.ts +73 -0
  189. package/dist/esm/memory/define.d.ts +63 -0
  190. package/dist/esm/memory/define.types.d.ts +276 -0
  191. package/dist/esm/memory/define.types.js +1 -1
  192. package/dist/esm/memory/embedding/cosine.d.ts +18 -0
  193. package/dist/esm/memory/embedding/embedMessages.d.ts +58 -0
  194. package/dist/esm/memory/embedding/index.d.ts +8 -0
  195. package/dist/esm/memory/embedding/loadRelevant.d.ts +51 -0
  196. package/dist/esm/memory/embedding/mockEmbedder.d.ts +22 -0
  197. package/dist/esm/memory/embedding/types.d.ts +46 -0
  198. package/dist/esm/memory/entry/decay.d.ts +36 -0
  199. package/dist/esm/memory/entry/index.d.ts +2 -0
  200. package/dist/esm/memory/entry/types.d.ts +140 -0
  201. package/dist/esm/memory/facts/extractFacts.d.ts +50 -0
  202. package/dist/esm/memory/facts/extractor.d.ts +33 -0
  203. package/dist/esm/memory/facts/formatFacts.d.ts +60 -0
  204. package/dist/esm/memory/facts/index.d.ts +14 -0
  205. package/dist/esm/memory/facts/llmFactExtractor.d.ts +64 -0
  206. package/dist/esm/memory/facts/loadFacts.d.ts +43 -0
  207. package/dist/esm/memory/facts/patternFactExtractor.d.ts +2 -0
  208. package/dist/esm/memory/facts/types.d.ts +68 -0
  209. package/dist/esm/memory/facts/writeFacts.d.ts +19 -0
  210. package/dist/esm/memory/identity/index.d.ts +2 -0
  211. package/dist/esm/memory/identity/types.d.ts +49 -0
  212. package/dist/esm/memory/index.d.ts +19 -0
  213. package/dist/esm/memory/pipeline/auto.d.ts +59 -0
  214. package/dist/esm/memory/pipeline/default.d.ts +49 -0
  215. package/dist/esm/memory/pipeline/ephemeral.d.ts +28 -0
  216. package/dist/esm/memory/pipeline/fact.d.ts +26 -0
  217. package/dist/esm/memory/pipeline/index.d.ts +13 -0
  218. package/dist/esm/memory/pipeline/narrative.d.ts +35 -0
  219. package/dist/esm/memory/pipeline/semantic.d.ts +37 -0
  220. package/dist/esm/memory/pipeline/types.d.ts +31 -0
  221. package/dist/esm/memory/stages/formatDefault.d.ts +64 -0
  222. package/dist/esm/memory/stages/index.d.ts +13 -0
  223. package/dist/esm/memory/stages/loadRecent.d.ts +49 -0
  224. package/dist/esm/memory/stages/pickByBudget.d.ts +63 -0
  225. package/dist/esm/memory/stages/summarize.d.ts +87 -0
  226. package/dist/esm/memory/stages/tokenize.d.ts +43 -0
  227. package/dist/esm/memory/stages/types.d.ts +75 -0
  228. package/dist/esm/memory/stages/writeMessages.d.ts +71 -0
  229. package/dist/esm/memory/store/InMemoryStore.d.ts +62 -0
  230. package/dist/esm/memory/store/index.d.ts +2 -0
  231. package/dist/esm/memory/store/types.d.ts +223 -0
  232. package/dist/esm/memory/wire/index.d.ts +2 -0
  233. package/dist/esm/memory/wire/mountMemoryPipeline.d.ts +108 -0
  234. package/dist/esm/memory-providers.d.ts +37 -0
  235. package/dist/esm/observability/contextError/finders/compareFinders.d.ts +19 -0
  236. package/dist/esm/observability/contextError/finders/index.d.ts +22 -0
  237. package/dist/esm/observability/contextError/finders/rankSuspects.d.ts +2 -0
  238. package/dist/esm/observability/contextError/finders/removeAndRetry.d.ts +11 -0
  239. package/dist/esm/observability/contextError/finders/shrinkToCause.d.ts +11 -0
  240. package/dist/esm/observability/contextError/finders/testManyCombos.d.ts +11 -0
  241. package/dist/esm/observability/contextError/finders/traceSteps.d.ts +2 -0
  242. package/dist/esm/observability/contextError/finders/types.d.ts +88 -0
  243. package/dist/esm/observability-providers.d.ts +46 -0
  244. package/dist/esm/observe.d.ts +62 -0
  245. package/dist/esm/patterns/Debate.d.ts +39 -0
  246. package/dist/esm/patterns/MapReduce.d.ts +66 -0
  247. package/dist/esm/patterns/Reflection.d.ts +51 -0
  248. package/dist/esm/patterns/SelfConsistency.d.ts +43 -0
  249. package/dist/esm/patterns/Swarm.d.ts +60 -0
  250. package/dist/esm/patterns/ToT.d.ts +53 -0
  251. package/dist/esm/patterns/index.d.ts +22 -0
  252. package/dist/esm/providers.d.ts +33 -0
  253. package/dist/esm/recorders/core/AgentRecorder.d.ts +15 -0
  254. package/dist/esm/recorders/core/CompositionRecorder.d.ts +17 -0
  255. package/dist/esm/recorders/core/ContextEvaluatedRecorder.d.ts +23 -0
  256. package/dist/esm/recorders/core/ContextRecorder.d.ts +47 -0
  257. package/dist/esm/recorders/core/CostRecorder.d.ts +14 -0
  258. package/dist/esm/recorders/core/EmitBridge.d.ts +30 -0
  259. package/dist/esm/recorders/core/ErrorBridge.d.ts +38 -0
  260. package/dist/esm/recorders/core/EvalRecorder.d.ts +16 -0
  261. package/dist/esm/recorders/core/MemoryRecorder.d.ts +17 -0
  262. package/dist/esm/recorders/core/PermissionRecorder.d.ts +16 -0
  263. package/dist/esm/recorders/core/ReliabilityRecorder.d.ts +24 -0
  264. package/dist/esm/recorders/core/SkillRecorder.d.ts +14 -0
  265. package/dist/esm/recorders/core/StreamRecorder.d.ts +15 -0
  266. package/dist/esm/recorders/core/ToolsRecorder.d.ts +18 -0
  267. package/dist/esm/recorders/core/ValidationRecorder.d.ts +16 -0
  268. package/dist/esm/recorders/core/contextEngineering.d.ts +136 -0
  269. package/dist/esm/recorders/core/typedEmit.d.ts +34 -0
  270. package/dist/esm/recorders/core/types.d.ts +97 -0
  271. package/dist/esm/recorders/observability/AgentThinkingTraceRecorder.d.ts +117 -0
  272. package/dist/esm/recorders/observability/BoundaryRecorder.d.ts +546 -0
  273. package/dist/esm/recorders/observability/FlowchartRecorder.d.ts +220 -0
  274. package/dist/esm/recorders/observability/LiveStateRecorder.d.ts +250 -0
  275. package/dist/esm/recorders/observability/LoggingRecorder.d.ts +91 -0
  276. package/dist/esm/recorders/observability/RouteRecorder.d.ts +83 -0
  277. package/dist/esm/recorders/observability/RunStepRecorder.d.ts +231 -0
  278. package/dist/esm/recorders/observability/StatusRecorder.d.ts +36 -0
  279. package/dist/esm/recorders/observability/ToolChoiceRecorder.d.ts +164 -0
  280. package/dist/esm/recorders/observability/ToolLineageRecorder.d.ts +71 -0
  281. package/dist/esm/recorders/observability/commentary/commentaryTemplates.d.ts +105 -0
  282. package/dist/esm/recorders/observability/internal/ActorArrowClassifier.d.ts +25 -0
  283. package/dist/esm/recorders/observability/internal/CandidateAnswerBuffer.d.ts +28 -0
  284. package/dist/esm/recorders/observability/internal/ForkTracker.d.ts +60 -0
  285. package/dist/esm/recorders/observability/internal/RootInferrer.d.ts +51 -0
  286. package/dist/esm/recorders/observability/internal/SequenceSiblingTracker.d.ts +24 -0
  287. package/dist/esm/recorders/observability/localObservability.d.ts +48 -0
  288. package/dist/esm/recorders/observability/observeRunId.d.ts +36 -0
  289. package/dist/esm/recorders/observability/status/statusTemplates.d.ts +106 -0
  290. package/dist/esm/recorders/observability/trace.d.ts +119 -0
  291. package/dist/esm/reliability/CircuitBreaker.d.ts +75 -0
  292. package/dist/esm/reliability/buildReliabilityGateChart.d.ts +53 -0
  293. package/dist/esm/reliability/classifyError.d.ts +28 -0
  294. package/dist/esm/reliability/index.d.ts +35 -0
  295. package/dist/esm/reliability/types.d.ts +327 -0
  296. package/dist/esm/resilience/fallbackProvider.d.ts +33 -0
  297. package/dist/esm/resilience/index.d.ts +21 -0
  298. package/dist/esm/resilience/withCircuitBreaker.d.ts +129 -0
  299. package/dist/esm/resilience/withFallback.d.ts +45 -0
  300. package/dist/esm/resilience/withRetry.d.ts +71 -0
  301. package/dist/esm/security/PermissionPolicy.d.ts +124 -0
  302. package/dist/esm/security/PolicyHaltError.d.ts +72 -0
  303. package/dist/esm/security/extractSequence.d.ts +46 -0
  304. package/dist/esm/security/index.d.ts +44 -0
  305. package/dist/esm/security/thinkingRedaction.d.ts +50 -0
  306. package/dist/esm/status.d.ts +48 -0
  307. package/dist/esm/strategies/attach.d.ts +47 -0
  308. package/dist/esm/strategies/compose.d.ts +48 -0
  309. package/dist/esm/strategies/defaults/chatBubbleLiveStatus.d.ts +36 -0
  310. package/dist/esm/strategies/defaults/consoleObservability.d.ts +42 -0
  311. package/dist/esm/strategies/defaults/inMemorySinkCost.d.ts +50 -0
  312. package/dist/esm/strategies/defaults/index.d.ts +30 -0
  313. package/dist/esm/strategies/defaults/noopLens.d.ts +28 -0
  314. package/dist/esm/strategies/index.d.ts +36 -0
  315. package/dist/esm/strategies/registry.d.ts +70 -0
  316. package/dist/esm/strategies/types.d.ts +303 -0
  317. package/dist/esm/stream.d.ts +82 -0
  318. package/dist/esm/thinking/AnthropicThinkingHandler.d.ts +42 -0
  319. package/dist/esm/thinking/MockThinkingHandler.d.ts +50 -0
  320. package/dist/esm/thinking/OpenAIThinkingHandler.d.ts +37 -0
  321. package/dist/esm/thinking/index.d.ts +51 -0
  322. package/dist/esm/thinking/registry.d.ts +33 -0
  323. package/dist/esm/thinking/types.d.ts +162 -0
  324. package/dist/esm/tool-providers/gatedTools.d.ts +36 -0
  325. package/dist/esm/tool-providers/index.d.ts +41 -0
  326. package/dist/esm/tool-providers/skillScopedTools.d.ts +45 -0
  327. package/dist/esm/tool-providers/staticTools.d.ts +21 -0
  328. package/dist/esm/tool-providers/types.d.ts +138 -0
  329. package/dist/index.js +6 -2
  330. package/dist/index.js.map +1 -1
  331. package/dist/lib/context-bisect/index.js +3 -0
  332. package/dist/lib/context-bisect/index.js.map +1 -1
  333. package/dist/lib/context-bisect/localize.js +2 -0
  334. package/dist/lib/context-bisect/localize.js.map +1 -1
  335. package/dist/lib/injection-engine/buildInjectionEngineSubflow.js +1 -0
  336. package/dist/lib/injection-engine/buildInjectionEngineSubflow.js.map +1 -1
  337. package/dist/lib/injection-engine/entryScorer.js +178 -0
  338. package/dist/lib/injection-engine/entryScorer.js.map +1 -0
  339. package/dist/lib/injection-engine/index.js +5 -1
  340. package/dist/lib/injection-engine/index.js.map +1 -1
  341. package/dist/lib/injection-engine/skillGraph.js +35 -41
  342. package/dist/lib/injection-engine/skillGraph.js.map +1 -1
  343. package/dist/lib/injection-engine/types.js.map +1 -1
  344. package/dist/memory/define.types.js +1 -1
  345. package/dist/types/core/agent/buildAgentChart.d.ts.map +1 -1
  346. package/dist/types/core/agent/buildDynamicAgentChart.d.ts.map +1 -1
  347. package/dist/types/core/agent/stages/pickEntry.d.ts.map +1 -1
  348. package/dist/types/core/agent/types.d.ts +8 -4
  349. package/dist/types/core/agent/types.d.ts.map +1 -1
  350. package/dist/types/index.d.ts +1 -1
  351. package/dist/types/index.d.ts.map +1 -1
  352. package/dist/types/lib/context-bisect/index.d.ts +3 -0
  353. package/dist/types/lib/context-bisect/index.d.ts.map +1 -1
  354. package/dist/types/lib/context-bisect/localize.d.ts +2 -0
  355. package/dist/types/lib/context-bisect/localize.d.ts.map +1 -1
  356. package/dist/types/lib/injection-engine/buildInjectionEngineSubflow.d.ts.map +1 -1
  357. package/dist/types/lib/injection-engine/entryScorer.d.ts +94 -0
  358. package/dist/types/lib/injection-engine/entryScorer.d.ts.map +1 -0
  359. package/dist/types/lib/injection-engine/index.d.ts +1 -0
  360. package/dist/types/lib/injection-engine/index.d.ts.map +1 -1
  361. package/dist/types/lib/injection-engine/skillGraph.d.ts +21 -24
  362. package/dist/types/lib/injection-engine/skillGraph.d.ts.map +1 -1
  363. package/dist/types/lib/injection-engine/types.d.ts +9 -4
  364. package/dist/types/lib/injection-engine/types.d.ts.map +1 -1
  365. package/dist/types/memory/define.types.d.ts +1 -1
  366. package/package.json +203 -56
@@ -0,0 +1,94 @@
1
+ /**
2
+ * EmbeddingCache — content-hash embedding cache (RFC-002 §3).
3
+ *
4
+ * Pattern: transparent Decorator — implements `Embedder` itself, so
5
+ * every influence-core function (and any other embedder
6
+ * consumer) takes a plain `Embedder` and the cache is pure
7
+ * injection: wrap once, thread the SAME instance through
8
+ * lint + margins + edge weights, and a description embedded
9
+ * for the catalog lint is free for the margin scorer.
10
+ * Role: `src/lib/influence-core/` leaf. No agent/runtime imports.
11
+ *
12
+ * ## Bounded honesty (the library convention)
13
+ *
14
+ * The cache is BOUNDED — `maxEntries` caps memory (LRU eviction), and
15
+ * the eviction count is VISIBLE via `stats()`. A consumer seeing
16
+ * `evictions > 0` knows the cache is thrashing and can size it up;
17
+ * nothing silently degrades out of view.
18
+ *
19
+ * ## Keying
20
+ *
21
+ * Entries are keyed by `contentHash(text)` — a fast non-cryptographic
22
+ * 64-bit FNV-1a (length-qualified). NOT a security boundary: it
23
+ * deduplicates embedding calls, it does not authenticate content.
24
+ * Collisions are astronomically unlikely at cache scale (≤ maxEntries
25
+ * live keys) but would silently return the colliding text's vector —
26
+ * acceptable for a similarity proxy, never rely on it for exact-match
27
+ * semantics. One cache per embedder instance: keys do NOT encode the
28
+ * model, so sharing one cache across different embedders would mix
29
+ * vector spaces (the same reason `MemoryStore` rejects mixed
30
+ * dimensions).
31
+ *
32
+ * ## Concurrency
33
+ *
34
+ * In-flight requests coalesce: N concurrent `embed()` calls for the
35
+ * same text issue ONE inner call (single-flight). Rejections are NOT
36
+ * cached — a failed embedding retries on the next request.
37
+ */
38
+ import type { Embedder, EmbedArgs, EmbedBatchArgs } from './types.js';
39
+ /**
40
+ * Fast, deterministic, browser-safe content hash (FNV-1a, two 32-bit
41
+ * lanes + length qualifier → "len-xxxxxxxxyyyyyyyy"). Non-cryptographic
42
+ * — cache keying only.
43
+ */
44
+ export declare function contentHash(text: string): string;
45
+ export interface EmbeddingCacheOptions {
46
+ /**
47
+ * Maximum cached vectors. Oldest (least recently used) entries are
48
+ * evicted past the cap; evictions are counted in `stats()`.
49
+ * Default 1024 — a 30-tool catalog plus a long run's reasoning
50
+ * steps fit with a wide margin.
51
+ */
52
+ readonly maxEntries?: number;
53
+ }
54
+ /** Visible cache health — the bounded-honesty surface. */
55
+ export interface EmbeddingCacheStats {
56
+ /** Vectors currently held. */
57
+ readonly size: number;
58
+ /** The configured cap. */
59
+ readonly maxEntries: number;
60
+ /** Served from cache (includes coalesced in-flight joins). */
61
+ readonly hits: number;
62
+ /** Forwarded to the inner embedder. */
63
+ readonly misses: number;
64
+ /** Entries dropped to respect `maxEntries`. >0 = consider sizing up. */
65
+ readonly evictions: number;
66
+ }
67
+ /**
68
+ * Wrap an embedder with a bounded, content-hash-keyed LRU cache.
69
+ * See module docs for keying, bounds, and concurrency semantics.
70
+ */
71
+ export declare class EmbeddingCache implements Embedder {
72
+ readonly dimensions: number;
73
+ private readonly inner;
74
+ private readonly maxEntries;
75
+ /** LRU store — Map iteration order is recency (refreshed on hit). */
76
+ private readonly vectors;
77
+ /** Single-flight joins — promises live here until settled. */
78
+ private readonly inflight;
79
+ private hits;
80
+ private misses;
81
+ private evictions;
82
+ constructor(inner: Embedder, options?: EmbeddingCacheOptions);
83
+ embed(args: EmbedArgs): Promise<number[]>;
84
+ embedBatch(args: EmbedBatchArgs): Promise<number[][]>;
85
+ /** Visible cache health (bounded honesty — see module docs). */
86
+ stats(): EmbeddingCacheStats;
87
+ /** Drop all cached vectors. Stats counters are preserved. */
88
+ clear(): void;
89
+ private refresh;
90
+ private store;
91
+ private embedSequential;
92
+ }
93
+ /** Factory sugar — `embeddingCache(embedder)` reads like the built-ins. */
94
+ export declare function embeddingCache(inner: Embedder, options?: EmbeddingCacheOptions): EmbeddingCache;
@@ -0,0 +1,26 @@
1
+ import type { Embedder, EvidenceInput, InfluenceScore, InfluenceWeights } from './types.js';
2
+ export interface ScoreContrastiveInfluenceArgs {
3
+ /** Evidence items (context sources) with their reasoning ancestors. */
4
+ readonly evidence: readonly EvidenceInput[];
5
+ /** The ACTUAL (e.g. buggy) output the evidence is scored against. */
6
+ readonly answerText: string;
7
+ /** A REFERENCE output to contrast against — a known-good / expected / prior
8
+ * run. The shared-with-both similarity (topical innocents) cancels out. */
9
+ readonly referenceText: string;
10
+ /** Injected embedder. Wrap in an `EmbeddingCache` to share embeddings. */
11
+ readonly embedder: Embedder;
12
+ /** Composite weights. Default: paper priors 0.40/0.30/0.20/0.10. */
13
+ readonly weights?: InfluenceWeights;
14
+ /** PERSIST threshold T. Default 0.3. */
15
+ readonly persistenceThreshold?: number;
16
+ readonly signal?: AbortSignal;
17
+ }
18
+ /**
19
+ * Score evidence by CONTRASTIVE influence: `sim(e, answer) − sim(e, reference)`
20
+ * for the FA term, the four-signal composite otherwise. Returns `InfluenceScore[]`
21
+ * sorted descending — drop-in compatible with `scoreInfluence` consumers
22
+ * (`rankingConfidence`, etc.).
23
+ *
24
+ * @throws when an evidence id is duplicated (same contract as `scoreInfluence`).
25
+ */
26
+ export declare function scoreContrastiveInfluence(args: ScoreContrastiveInfluenceArgs): Promise<InfluenceScore[]>;
@@ -0,0 +1,34 @@
1
+ /**
2
+ * influence-core — the ONE embedding-based scoring engine
3
+ * (RFC-002/003 block D6).
4
+ *
5
+ * Extracted from the Visible Reasoning paper's FDL influence pipeline
6
+ * (Eq. 1–6: four signals + adaptive weighted composite) so that three
7
+ * consumers share one engine and one embedding cache:
8
+ *
9
+ * a) RFC-002 — tool-catalog lint (C1 ← `pairwiseSimilarity`) and the
10
+ * margin recorder (C4/C5 ← `scoreMargin`),
11
+ * b) RFC-003 Part B — the LLM-edge weigher (D7 ← `scoreInfluence` /
12
+ * the signal scorers),
13
+ * c) the FDL paper pipeline itself (stages 4–6 ← `EmbeddingCache` +
14
+ * `scoreInfluence`).
15
+ *
16
+ * Leaf module: zero agent/runtime imports — the only dependency is the
17
+ * `Embedder` interface (re-exported from memory/embedding, the one
18
+ * existing contract) and the shared `cosineSimilarity`.
19
+ *
20
+ * Plug-and-play: the frame and formulas are the library's; the
21
+ * embedder, weights, and thresholds are consumer-injected.
22
+ *
23
+ * Honest claim (RFC-002 §2): every score here is a deterministic
24
+ * embedding-geometry PROXY — semantic alignment, never model internals
25
+ * and never causal attribution.
26
+ */
27
+ export type { CandidateScore, ConfidenceStrategy, EmbedArgs, EmbedBatchArgs, Embedder, EvidenceInput, InfluenceScore, InfluenceWeights, MarginCandidate, MarginResult, PairwiseSimilarityResult, RankingConfidence, SignalScores, SimilarityItem, SimilarityPair, } from './types.js';
28
+ export { DEFAULT_CLEAR_WINNER_MARGIN, DEFAULT_CLEAR_WINNER_RATIO, DEFAULT_INFLUENCE_WEIGHTS, DEFAULT_MARGIN_THRESHOLD, DEFAULT_PERSISTENCE_THRESHOLD, DEFAULT_SHORTLIST_BAND, } from './types.js';
29
+ export { marginStrategy, rankingConfidence, ratioStrategy, type RankingConfidenceOptions, } from './attributability.js';
30
+ export { scoreContrastiveInfluence, type ScoreContrastiveInfluenceArgs } from './contrastive.js';
31
+ export { contentHash, EmbeddingCache, embeddingCache, type EmbeddingCacheOptions, type EmbeddingCacheStats, } from './cache.js';
32
+ export { adaptWeights, averageRelevancy, compositeScore, finalAnswerSimilarity, persistence, scoreInfluence, structuralProximity, type InfluenceScorer, type ScoreInfluenceArgs, } from './signals.js';
33
+ export { pairwiseSimilarity, type PairwiseSimilarityArgs } from './similarity.js';
34
+ export { scoreMargin, type ScoreMarginArgs } from './margin.js';
@@ -0,0 +1,33 @@
1
+ import type { Embedder, MarginCandidate, MarginResult } from './types.js';
2
+ export interface ScoreMarginArgs {
3
+ /** The offered candidates (e.g. the tool catalog on `llm_start`). */
4
+ readonly candidates: readonly MarginCandidate[];
5
+ /** The choice context — the text the chooser ranked against. */
6
+ readonly contextText: string;
7
+ /** Names of the chosen candidate(s). Must exist in `candidates`. */
8
+ readonly chosen: readonly string[];
9
+ /**
10
+ * Injected embedder. Wrap in an `EmbeddingCache` so descriptions
11
+ * embed once across calls (RFC-002 §3 — the same cache the catalog
12
+ * lint already filled).
13
+ */
14
+ readonly embedder: Embedder;
15
+ /** Margins below this flag `narrow`. Default 0.05 (RFC-002 §4). */
16
+ readonly marginThreshold?: number;
17
+ /** Abort signal threaded to the embedder (network backends). */
18
+ readonly signal?: AbortSignal;
19
+ }
20
+ /**
21
+ * Rank candidates by cosine similarity to the choice context and
22
+ * measure how decisively the chosen one(s) won.
23
+ *
24
+ * Returns ranked `scores` (descending; ties keep candidate input
25
+ * order), the `topScored` name, the `margin` (undefined when every
26
+ * candidate was chosen — no competition to measure; `narrow` is false
27
+ * in that case), and the two flags.
28
+ *
29
+ * Fail-loud validation: empty candidates/chosen, duplicate candidate
30
+ * names, or a chosen name missing from the candidates throw — those
31
+ * are wiring bugs in the caller, not runtime conditions.
32
+ */
33
+ export declare function scoreMargin(args: ScoreMarginArgs): Promise<MarginResult>;
@@ -0,0 +1,128 @@
1
+ import type { Embedder, EvidenceInput, InfluenceScore, InfluenceWeights, SignalScores } from './types.js';
2
+ /**
3
+ * FA — Final Answer Similarity (paper Eq. 1).
4
+ *
5
+ * `FA(d) = sim(e_d, e_f)` — cosine between the evidence embedding and
6
+ * the final-answer embedding. The strongest prior: verbatim or
7
+ * paraphrased reuse of a tool result scores high. Proxy: semantic
8
+ * overlap, not provenance.
9
+ */
10
+ export declare function finalAnswerSimilarity(evidenceVec: readonly number[], finalAnswerVec: readonly number[]): number;
11
+ /**
12
+ * AVG — Average Relevancy (paper Eq. 2).
13
+ *
14
+ * Mean cosine between the evidence and each LLM reasoning ancestor;
15
+ * 0 when there are no ancestors (structurally zero — see
16
+ * `adaptWeights`). Proxy: consistent semantic closeness across the
17
+ * chain, not actual consultation.
18
+ */
19
+ export declare function averageRelevancy(evidenceVec: readonly number[], ancestorVecs: ReadonlyArray<readonly number[]>): number;
20
+ /**
21
+ * PERSIST — Persistence (paper Eq. 3).
22
+ *
23
+ * Fraction of ancestors whose similarity to the evidence EXCEEDS the
24
+ * threshold T (strict `>`, default 0.30); 0 when there are no
25
+ * ancestors. Unlike AVG it measures BREADTH: referenced in 4 of 5
26
+ * steps (0.8) beats referenced intensely in 1. Proxy: similarity
27
+ * above a tunable bar, not counted citations.
28
+ */
29
+ export declare function persistence(evidenceVec: readonly number[], ancestorVecs: ReadonlyArray<readonly number[]>, threshold?: number): number;
30
+ /**
31
+ * DEPTH — Structural Proximity (paper Eq. 4).
32
+ *
33
+ * `DEPTH(d) = 1 / (1 + n)` where n counts LLM reasoning ancestors
34
+ * ONLY (not pipeline plumbing — callers decide what counts as an
35
+ * ancestor when building `EvidenceInput.ancestorTexts`). Direct
36
+ * evidence with no intermediaries gets exactly 1.0. The only
37
+ * content-blind signal: pure trace structure.
38
+ */
39
+ export declare function structuralProximity(ancestorCount: number): number;
40
+ /**
41
+ * Adaptive weight redistribution (paper Eq. 6, §5.3).
42
+ *
43
+ * When an item has NO LLM ancestors, AVG and PERSIST are structurally
44
+ * zero — not because the evidence was uninfluential, but because there
45
+ * is nothing to measure against. Without adaptation its score is
46
+ * capped at α+δ (≈0.50 under defaults). Eq. 6 moves the β+γ mass onto
47
+ * FA and DEPTH preserving their ratio:
48
+ *
49
+ * α′ = α + (β+γ)·α/(α+δ), δ′ = δ + (β+γ)·δ/(α+δ), β′ = γ′ = 0
50
+ *
51
+ * Defaults → α′=0.80, δ′=0.20 (the 4:1 FA:DEPTH ratio kept).
52
+ * Per-evidence-item: in a multi-tool pipeline some items adapt while
53
+ * others keep standard weights; `adapted` says which (surface it — the
54
+ * paper's UI marks adapted items).
55
+ *
56
+ * Degenerate guard: if α+δ = 0 there is no defined ratio to preserve —
57
+ * weights return unchanged with `adapted: false`, and the composite is
58
+ * honestly 0 for a no-ancestor item.
59
+ */
60
+ export declare function adaptWeights(weights: InfluenceWeights, ancestorCount: number): {
61
+ weights: InfluenceWeights;
62
+ adapted: boolean;
63
+ };
64
+ /**
65
+ * Composite score S(d) (paper Eq. 5).
66
+ *
67
+ * `S = α·FA + β·AVG + γ·PERSIST + δ·DEPTH` under the given weights —
68
+ * pass the EFFECTIVE weights from `adaptWeights` for no-ancestor
69
+ * items. With weights summing to 1, S ∈ [−(α+β), 1] (FA/AVG are
70
+ * cosines and may go negative; PERSIST/DEPTH are non-negative).
71
+ */
72
+ export declare function compositeScore(signals: SignalScores, weights: InfluenceWeights): number;
73
+ export interface ScoreInfluenceArgs {
74
+ /** Evidence items (tool results / context sources) with ancestors. */
75
+ readonly evidence: readonly EvidenceInput[];
76
+ /** The final answer text the evidence is scored against. */
77
+ readonly finalAnswerText: string;
78
+ /**
79
+ * Injected embedder. Wrap in an `EmbeddingCache` to share embeddings
80
+ * with the catalog lint / margin scorer (RFC-002 §3 — one cache
81
+ * serves all three consumers).
82
+ */
83
+ readonly embedder: Embedder;
84
+ /** Composite weights. Default: paper priors 0.40/0.30/0.20/0.10. */
85
+ readonly weights?: InfluenceWeights;
86
+ /** PERSIST threshold T. Default 0.30. */
87
+ readonly persistenceThreshold?: number;
88
+ /** Abort signal threaded to the embedder (network backends). */
89
+ readonly signal?: AbortSignal;
90
+ }
91
+ /**
92
+ * Score every evidence item on the four FDL signals and rank by
93
+ * composite, descending (paper pipeline stages 4–6 in one call:
94
+ * embed → score → rank). Ties keep input order (stable sort).
95
+ *
96
+ * Deterministic for a deterministic embedder: same inputs → same
97
+ * scores. All texts are embedded in ONE deduplicated batch — with an
98
+ * `EmbeddingCache` injected, repeat calls embed nothing.
99
+ *
100
+ * Honest claim: ranked semantic-alignment proxies. NOT causal
101
+ * attribution — see module docs.
102
+ */
103
+ export declare function scoreInfluence(args: ScoreInfluenceArgs): Promise<InfluenceScore[]>;
104
+ /**
105
+ * A pluggable influence scorer — the RANK stage's extension point.
106
+ *
107
+ * It takes the same `ScoreInfluenceArgs` the localizer assembles for a
108
+ * slice (the evidence items, the wrong-output text, an embedder) and
109
+ * returns one `InfluenceScore` per item, ranked descending. The shipped
110
+ * default is `scoreInfluence` (the FDL four-signal composite); pass your
111
+ * own to `localizeContextBug({ scorer })` to change the ranking ORDER —
112
+ * e.g. `scoreContrastiveInfluence` (wrap it to supply a `referenceText`),
113
+ * or a non-embedding scorer of your own that ignores `args.embedder`.
114
+ *
115
+ * Claim-ladder guarantee: a scorer only reorders suspects (how FAST
116
+ * ablation finds a culprit), never whether a claim counts as causal —
117
+ * ablation alone convicts. So any scorer is safe to swap in; the worst a
118
+ * bad one does is make confirmation slower, never wrong.
119
+ */
120
+ export type InfluenceScorer = (args: ScoreInfluenceArgs) => Promise<InfluenceScore[]>;
121
+ /** Embed distinct texts via batch API when available, else sequentially. */
122
+ export declare function embedAll(embedder: Embedder, texts: readonly string[], signal?: AbortSignal): Promise<Map<string, readonly number[]>>;
123
+ /**
124
+ * Validate composite weights: every weight finite & non-negative, and not all
125
+ * zero. Shared by `scoreInfluence` and `scoreContrastiveInfluence` — `fnName`
126
+ * attributes the error to the actual caller.
127
+ */
128
+ export declare function assertValidWeights(weights: InfluenceWeights, fnName?: string): void;
@@ -0,0 +1,25 @@
1
+ import type { Embedder, PairwiseSimilarityResult, SimilarityItem } from './types.js';
2
+ export interface PairwiseSimilarityArgs {
3
+ /** The texts to compare — e.g. `{ id: toolName, text: description }`. */
4
+ readonly items: readonly SimilarityItem[];
5
+ /**
6
+ * Injected embedder. Wrap in an `EmbeddingCache` so catalog
7
+ * descriptions embed once across lint runs (RFC-002 §3).
8
+ */
9
+ readonly embedder: Embedder;
10
+ /** Abort signal threaded to the embedder (network backends). */
11
+ readonly signal?: AbortSignal;
12
+ }
13
+ /**
14
+ * Embed every item once (deduplicated batch) and compute the full
15
+ * cosine matrix plus ranked upper-triangle pairs (descending; ties
16
+ * keep input pair order).
17
+ *
18
+ * Invariants (pinned by property tests):
19
+ * - `matrix[i][j] === matrix[j][i]` — computed once, mirrored.
20
+ * - `matrix[i][i] === 1` EXACTLY — set by definition, so
21
+ * self-similarity is an invariant rather than a float artifact
22
+ * (and duplicate texts at different ids still compare via cosine).
23
+ * - N items → N·(N−1)/2 pairs.
24
+ */
25
+ export declare function pairwiseSimilarity(args: PairwiseSimilarityArgs): Promise<PairwiseSimilarityResult>;
@@ -0,0 +1,252 @@
1
+ /**
2
+ * influence-core types — the ONE embedding-based scoring contract.
3
+ *
4
+ * Pattern: Strategy seam (plug-and-play meta-pattern) — the frame and
5
+ * rule engine are the library's; the `Embedder` is consumer-
6
+ * injected, exactly like NarrativeFormatter / reliability /
7
+ * permission / commentary strategies.
8
+ * Role: `src/lib/` leaf module. Shared by the FDL paper pipeline
9
+ * (Visible Reasoning, Eq. 1–6), RFC-002's tool-catalog lint +
10
+ * margin recorder (C1/C4/C5), and RFC-003 Part B's LLM-edge
11
+ * weigher (D7). Extracted as RFC-003 block D6 so all three
12
+ * consumers share one scoring engine and one embedding cache.
13
+ *
14
+ * ## Honest claim (RFC-002 §2, the FDL discipline)
15
+ *
16
+ * Every score produced under these types is a PROXY computed from
17
+ * embedding geometry — cosine similarity over consumer-injected
18
+ * embeddings. None of it reads model internals. Scores mean "high
19
+ * semantic alignment", never "the model chose/answered BECAUSE".
20
+ * Scores are not additive across items and are not causal attribution
21
+ * — counterfactual ablation (RFC-003 stage 4) is where causal claims
22
+ * live.
23
+ */
24
+ export type { Embedder, EmbedArgs, EmbedBatchArgs } from '../../memory/embedding/types.js';
25
+ /**
26
+ * Weights for the four-signal composite (paper Eq. 5).
27
+ *
28
+ * Configurable PRIORS, not learned parameters (paper §8). Defaults
29
+ * encode: direct semantic similarity (fa) strongest, then consistency
30
+ * across reasoning (avg), breadth of reference (persist), structural
31
+ * proximity (depth).
32
+ */
33
+ export interface InfluenceWeights {
34
+ /** α — Final Answer Similarity weight. */
35
+ readonly fa: number;
36
+ /** β — Average Relevancy weight. */
37
+ readonly avg: number;
38
+ /** γ — Persistence weight. */
39
+ readonly persist: number;
40
+ /** δ — Structural Proximity weight. */
41
+ readonly depth: number;
42
+ }
43
+ /** Paper defaults: α=0.40, β=0.30, γ=0.20, δ=0.10 (sum to 1.0). */
44
+ export declare const DEFAULT_INFLUENCE_WEIGHTS: InfluenceWeights;
45
+ /** Paper default for the PERSIST threshold T (Eq. 3). */
46
+ export declare const DEFAULT_PERSISTENCE_THRESHOLD = 0.3;
47
+ /** RFC-002 §4 default: margins below this flag the choice as `narrow`. */
48
+ export declare const DEFAULT_MARGIN_THRESHOLD = 0.05;
49
+ /**
50
+ * RFC-003 default: an influence ranking whose top-1 vs top-2 score margin is
51
+ * below this has NO clear winner — a shortlist, not a verdict. Escalate to
52
+ * ablation.
53
+ *
54
+ * UNCALIBRATED proxy starting point, chosen for interpretability. `margin`
55
+ * is an ABSOLUTE difference on the same scale as `scoreInfluence`'s composite
56
+ * (S ∈ ≈[−0.7, 1]), so this threshold is EMBEDDER-RELATIVE — recalibrate by
57
+ * sweeping clear-winner vs flat rankings on your embedder. The numeric
58
+ * coincidence with `DEFAULT_MARGIN_THRESHOLD` is NOT a shared derivation: that
59
+ * one measures `scoreMargin`'s chosen-vs-not-chosen distribution, a different
60
+ * statistic.
61
+ */
62
+ export declare const DEFAULT_CLEAR_WINNER_MARGIN = 0.05;
63
+ /**
64
+ * RFC-003 default: when there is no clear winner, suspects scoring within this
65
+ * band of the top form the shortlist ablation should COVER (the culprit may be
66
+ * any of them — or, for absence bugs, none). UNCALIBRATED proxy; embedder-
67
+ * relative (see `DEFAULT_CLEAR_WINNER_MARGIN`).
68
+ */
69
+ export declare const DEFAULT_SHORTLIST_BAND = 0.1;
70
+ /**
71
+ * RFC-003 default for `ratioStrategy`: the top-2 gap as a FRACTION of the top
72
+ * score `(s0 − s1) / |s0|`. Unlike the absolute margin this is scale-invariant,
73
+ * so it transfers across embedders / answer lengths. UNCALIBRATED proxy.
74
+ */
75
+ export declare const DEFAULT_CLEAR_WINNER_RATIO = 0.05;
76
+ /**
77
+ * Pluggable rule for "does one source clearly win this ranking?" — the
78
+ * decisiveness test inside `rankingConfidence`. The library ships
79
+ * `marginStrategy` (default, absolute gap) and `ratioStrategy` (scale-
80
+ * invariant); consumers may bring their own (e.g. entropy / dispersion). The
81
+ * framework around it — always shortlisting the lead, covering the runner-up
82
+ * when there is no clear winner, malformed-score robustness — is NOT the
83
+ * strategy's concern; the strategy only judges the clean, all-finite case.
84
+ */
85
+ export interface ConfidenceStrategy {
86
+ /** Identifies the rule — shown in `reason`, and the key on a benchmark
87
+ * leaderboard of strategies. */
88
+ readonly name: string;
89
+ /**
90
+ * Given the FINITE scores sorted DESCENDING (length >= 2), decide whether
91
+ * one source clearly dominates. Pure and deterministic.
92
+ */
93
+ isClearWinner(rankedScores: readonly number[]): boolean;
94
+ }
95
+ /**
96
+ * Confidence in an influence ranking (`scoreInfluence` output) — the honesty
97
+ * companion to the scorer.
98
+ *
99
+ * Output-similarity influence is a PROXY: it ranks sources by how much they
100
+ * resemble the final answer. It is structurally BLIND to absence/crowding bugs
101
+ * — a culprit that caused the error by *displacing* context (history
102
+ * truncation, context dilution) need not resemble the answer at all, so it can
103
+ * rank low or off the top. This result makes that honesty explicit: when no
104
+ * source clearly dominates, the ranking is a SHORTLIST to confirm by ablation,
105
+ * never a verdict. Mirrors the causal slice's incompleteness markers — the
106
+ * library says what its proxy cannot see.
107
+ */
108
+ export interface RankingConfidence {
109
+ /**
110
+ * True when one source clearly dominates (`margin >= clearWinnerMargin`),
111
+ * so the ranking can be trusted as a LEAD. False = treat as shortlist +
112
+ * ablate. (A single suspect is trivially a clear winner — by absence of
113
+ * alternatives, not strength of signal.) NOTE: this is the inverse of the
114
+ * sibling `MarginResult.flags.narrow`. Honesty: a clear winner means the
115
+ * proxy has a clear top, NOT that the top is the cause — a high-similarity
116
+ * innocent the answer rationalizes over can win; ablation is the only causal
117
+ * confirmation in either branch.
118
+ */
119
+ readonly clearWinner: boolean;
120
+ /**
121
+ * `score(#1) − score(#2)`, an ABSOLUTE difference on the composite-score
122
+ * scale (embedder-relative). `undefined` when fewer than 2 suspects, when
123
+ * all scores are malformed, or when the runner-up score is unavailable
124
+ * (a clean top over a malformed #2). Read `clearWinner` to disambiguate.
125
+ */
126
+ readonly margin: number | undefined;
127
+ /** Id of the top-ranked suspect (the lead). `undefined` only when there are
128
+ * none. Under an exact top tie this is the input-order first and not
129
+ * meaningful (there is no clear winner anyway). */
130
+ readonly lead: string | undefined;
131
+ /**
132
+ * Suspects within the band of the top score — the set ablation should COVER.
133
+ * CONSUME ONLY WHEN `clearWinner` IS FALSE; when there is a clear winner this
134
+ * is informational (the band near the top), not an ablation worklist. Always
135
+ * includes `lead` when present, and — when no clear winner with ≥2 suspects —
136
+ * the runner-up too. De-duplicated.
137
+ */
138
+ readonly shortlist: readonly string[];
139
+ /** Human-readable explanation for narratives / reports. PRESENTATION ONLY —
140
+ * read `clearWinner` / `margin` / `shortlist` as data, never parse this
141
+ * string. */
142
+ readonly reason: string;
143
+ }
144
+ /** The four signal values for one evidence item (paper Eq. 1–4). */
145
+ export interface SignalScores {
146
+ /** FA — cosine(evidence, finalAnswer). Range [-1, 1]. */
147
+ readonly fa: number;
148
+ /** AVG — mean cosine(evidence, ancestor_i); 0 when no ancestors. */
149
+ readonly avg: number;
150
+ /** PERSIST — fraction of ancestors with similarity > T; 0 when none. */
151
+ readonly persist: number;
152
+ /** DEPTH — 1 / (1 + ancestorCount). Range (0, 1]. */
153
+ readonly depth: number;
154
+ }
155
+ /** One evidence item to score: a tool result (or any context source)
156
+ * plus the texts of the LLM reasoning steps that referenced it. */
157
+ export interface EvidenceInput {
158
+ /** Stable identifier — e.g. a runtimeStageId or tool-call id. */
159
+ readonly id: string;
160
+ /** The evidence text (tool result content). */
161
+ readonly text: string;
162
+ /**
163
+ * Texts of the item's LLM reasoning ANCESTORS — only stages with
164
+ * model text output, not pipeline plumbing (paper §5.1, DEPTH).
165
+ * Empty array = direct evidence with no intermediaries.
166
+ */
167
+ readonly ancestorTexts: readonly string[];
168
+ }
169
+ /** Scored evidence item — the per-item output of `scoreInfluence`. */
170
+ export interface InfluenceScore {
171
+ readonly id: string;
172
+ /** The four raw signals (proxies — see module honest claim). */
173
+ readonly signals: SignalScores;
174
+ /**
175
+ * The EFFECTIVE weights used for this item — equals the configured
176
+ * weights normally; the Eq. 6 redistribution when `adapted` is true.
177
+ */
178
+ readonly weights: InfluenceWeights;
179
+ /**
180
+ * True when adaptive weight redistribution (paper Eq. 6) applied —
181
+ * the item had no LLM ancestors, so AVG/PERSIST were structurally
182
+ * zero and their weight mass moved onto FA/DEPTH. Per-item: a
183
+ * multi-tool pipeline may mix adapted and standard items.
184
+ */
185
+ readonly adapted: boolean;
186
+ /** Composite S(d) (Eq. 5) under the effective weights. */
187
+ readonly score: number;
188
+ }
189
+ /** A text item for pairwise comparison (e.g. a tool description). */
190
+ export interface SimilarityItem {
191
+ /** Stable identifier — e.g. the tool name. Must be unique. */
192
+ readonly id: string;
193
+ readonly text: string;
194
+ }
195
+ /** One ranked pair from `pairwiseSimilarity`. */
196
+ export interface SimilarityPair {
197
+ /** id of the first item (lower input index). */
198
+ readonly a: string;
199
+ /** id of the second item (higher input index). */
200
+ readonly b: string;
201
+ /** cosine(embed(a.text), embed(b.text)). */
202
+ readonly similarity: number;
203
+ }
204
+ export interface PairwiseSimilarityResult {
205
+ /** Item ids in input order — the matrix axes. */
206
+ readonly ids: readonly string[];
207
+ /**
208
+ * Full similarity matrix, `matrix[i][j] = cosine(item_i, item_j)`.
209
+ * Symmetric by construction; the diagonal is EXACTLY 1 by definition
210
+ * (self-similarity is an invariant, not a float approximation).
211
+ */
212
+ readonly matrix: ReadonlyArray<readonly number[]>;
213
+ /** Upper-triangle pairs ranked by similarity, descending. */
214
+ readonly pairs: readonly SimilarityPair[];
215
+ }
216
+ /** A candidate in a choice competition (e.g. an offered tool). */
217
+ export interface MarginCandidate {
218
+ /** Unique name — the identifier the chooser used. */
219
+ readonly name: string;
220
+ /** The text the chooser saw (the tool description). */
221
+ readonly text: string;
222
+ }
223
+ /** One candidate's proximity to the choice context, ranked. */
224
+ export interface CandidateScore {
225
+ readonly name: string;
226
+ /** cosine(embed(contextText), embed(candidate.text)). */
227
+ readonly score: number;
228
+ }
229
+ export interface MarginResult {
230
+ /** All candidates ranked by score, descending. */
231
+ readonly scores: readonly CandidateScore[];
232
+ /** The chosen candidate names, echoed from the input. */
233
+ readonly chosen: readonly string[];
234
+ /** Name of the highest-scoring candidate (by the proxy). */
235
+ readonly topScored: string;
236
+ /**
237
+ * score(best chosen) − score(best non-chosen). Small margin =
238
+ * fragile choice. `undefined` when every candidate was chosen
239
+ * (no competition to measure).
240
+ */
241
+ readonly margin: number | undefined;
242
+ readonly flags: {
243
+ /** margin < marginThreshold — the choice was a close call. */
244
+ readonly narrow: boolean;
245
+ /**
246
+ * The top-scored candidate was NOT among the chosen. Either a
247
+ * proxy miss or a genuinely surprising choice — both are exactly
248
+ * what a debugger wants surfaced (RFC-002 §4).
249
+ */
250
+ readonly proxyDisagreement: boolean;
251
+ };
252
+ }