agentfootprint 6.43.0 → 6.45.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ai-instructions/setup.sh +0 -0
- package/dist/core/RunnerBase.js +7 -0
- package/dist/core/RunnerBase.js.map +1 -1
- package/dist/core/agent/buildAgentChart.js +2 -1
- package/dist/core/agent/buildAgentChart.js.map +1 -1
- package/dist/core/agent/buildDynamicAgentChart.js +3 -1
- package/dist/core/agent/buildDynamicAgentChart.js.map +1 -1
- package/dist/core/agent/stages/pickEntry.js +3 -1
- package/dist/core/agent/stages/pickEntry.js.map +1 -1
- package/dist/esm/adapters/identity/agentcore.d.ts +100 -0
- package/dist/esm/adapters/llm/AnthropicProvider.d.ts +130 -0
- package/dist/esm/adapters/llm/BedrockProvider.d.ts +100 -0
- package/dist/esm/adapters/llm/BrowserAnthropicProvider.d.ts +41 -0
- package/dist/esm/adapters/llm/BrowserOpenAIProvider.d.ts +95 -0
- package/dist/esm/adapters/llm/MockProvider.d.ts +153 -0
- package/dist/esm/adapters/llm/OpenAIProvider.d.ts +220 -0
- package/dist/esm/adapters/llm/createProvider.d.ts +85 -0
- package/dist/esm/adapters/memory/agentcore.d.ts +146 -0
- package/dist/esm/adapters/memory/bedrockAgentMemory.d.ts +95 -0
- package/dist/esm/adapters/memory/redis.d.ts +127 -0
- package/dist/esm/adapters/observability/agentcore.d.ts +67 -0
- package/dist/esm/adapters/observability/audit.d.ts +254 -0
- package/dist/esm/adapters/observability/cloudwatch.d.ts +96 -0
- package/dist/esm/adapters/observability/otel.d.ts +237 -0
- package/dist/esm/adapters/observability/xray.d.ts +88 -0
- package/dist/esm/adapters/types.d.ts +378 -0
- package/dist/esm/bridge/eventMeta.d.ts +59 -0
- package/dist/esm/cache/CacheDecisionSubflow.d.ts +85 -0
- package/dist/esm/cache/CacheGateDecider.d.ts +127 -0
- package/dist/esm/cache/applyCachePolicy.d.ts +37 -0
- package/dist/esm/cache/cacheRecorder.d.ts +85 -0
- package/dist/esm/cache/index.d.ts +33 -0
- package/dist/esm/cache/strategies/AnthropicCacheStrategy.d.ts +38 -0
- package/dist/esm/cache/strategies/BedrockCacheStrategy.d.ts +33 -0
- package/dist/esm/cache/strategies/NoOpCacheStrategy.d.ts +29 -0
- package/dist/esm/cache/strategies/OpenAICacheStrategy.d.ts +36 -0
- package/dist/esm/cache/strategyRegistry.d.ts +45 -0
- package/dist/esm/cache/types.d.ts +243 -0
- package/dist/esm/conventions.d.ts +203 -0
- package/dist/esm/core/Agent.d.ts +355 -0
- package/dist/esm/core/LLMCall.d.ts +139 -0
- package/dist/esm/core/RunnerBase.d.ts +267 -0
- package/dist/esm/core/RunnerBase.js +7 -0
- package/dist/esm/core/RunnerBase.js.map +1 -1
- package/dist/esm/core/agent/AgentBuilder.d.ts +565 -0
- package/dist/esm/core/agent/buildAgentChart.d.ts +109 -0
- package/dist/esm/core/agent/buildAgentChart.js +2 -1
- package/dist/esm/core/agent/buildAgentChart.js.map +1 -1
- package/dist/esm/core/agent/buildAgentMessageApiChart.d.ts +40 -0
- package/dist/esm/core/agent/buildCacheSubflow.d.ts +35 -0
- package/dist/esm/core/agent/buildDynamicAgentChart.d.ts +56 -0
- package/dist/esm/core/agent/buildDynamicAgentChart.js +3 -1
- package/dist/esm/core/agent/buildDynamicAgentChart.js.map +1 -1
- package/dist/esm/core/agent/buildMessageApiChart.d.ts +47 -0
- package/dist/esm/core/agent/buildToolRegistry.d.ts +61 -0
- package/dist/esm/core/agent/memoryRecallInjections.d.ts +8 -0
- package/dist/esm/core/agent/stages/breakFinal.d.ts +22 -0
- package/dist/esm/core/agent/stages/callLLM.d.ts +74 -0
- package/dist/esm/core/agent/stages/pickEntry.d.ts +19 -0
- package/dist/esm/core/agent/stages/pickEntry.js +3 -1
- package/dist/esm/core/agent/stages/pickEntry.js.map +1 -1
- package/dist/esm/core/agent/stages/prepareFinal.d.ts +19 -0
- package/dist/esm/core/agent/stages/reliabilityExecution.d.ts +135 -0
- package/dist/esm/core/agent/stages/route.d.ts +18 -0
- package/dist/esm/core/agent/stages/seed.d.ts +53 -0
- package/dist/esm/core/agent/stages/toolCalls.d.ts +76 -0
- package/dist/esm/core/agent/toolArgsValidation.d.ts +62 -0
- package/dist/esm/core/agent/types.d.ts +382 -0
- package/dist/esm/core/agent/validators.d.ts +52 -0
- package/dist/esm/core/cost.d.ts +38 -0
- package/dist/esm/core/flowchartAsTool.d.ts +200 -0
- package/dist/esm/core/humanizeLLMError.d.ts +23 -0
- package/dist/esm/core/outputFallback.d.ts +139 -0
- package/dist/esm/core/outputSchema.d.ts +127 -0
- package/dist/esm/core/pause.d.ts +74 -0
- package/dist/esm/core/runCheckpoint.d.ts +179 -0
- package/dist/esm/core/runner.d.ts +203 -0
- package/dist/esm/core/slots/buildMessagesSlot.d.ts +40 -0
- package/dist/esm/core/slots/buildSystemPromptSlot.d.ts +41 -0
- package/dist/esm/core/slots/buildThinkingSubflow.d.ts +40 -0
- package/dist/esm/core/slots/buildToolsSlot.d.ts +60 -0
- package/dist/esm/core/slots/helpers.d.ts +27 -0
- package/dist/esm/core/toolContract.d.ts +43 -0
- package/dist/esm/core/tools.d.ts +90 -0
- package/dist/esm/core/translator.d.ts +94 -0
- package/dist/esm/core-flow/Conditional.d.ts +119 -0
- package/dist/esm/core-flow/Loop.d.ts +160 -0
- package/dist/esm/core-flow/Parallel.d.ts +360 -0
- package/dist/esm/core-flow/Sequence.d.ts +133 -0
- package/dist/esm/events/dispatcher.d.ts +134 -0
- package/dist/esm/events/payloads.d.ts +761 -0
- package/dist/esm/events/registry.d.ts +198 -0
- package/dist/esm/events/types.d.ts +70 -0
- package/dist/esm/identity/kinds.d.ts +36 -0
- package/dist/esm/identity/staticTokens.d.ts +28 -0
- package/dist/esm/identity/types.d.ts +113 -0
- package/dist/esm/identity/withCredentialRetry.d.ts +64 -0
- package/dist/esm/identity.d.ts +31 -0
- package/dist/esm/index.d.ts +64 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/injection-engine.d.ts +4 -0
- package/dist/esm/lib/canonicalJson.d.ts +56 -0
- package/dist/esm/lib/context-bisect/ablation.d.ts +109 -0
- package/dist/esm/lib/context-bisect/bisect.d.ts +75 -0
- package/dist/esm/lib/context-bisect/cost.d.ts +37 -0
- package/dist/esm/lib/context-bisect/index.d.ts +31 -0
- package/dist/esm/lib/context-bisect/index.js +3 -0
- package/dist/esm/lib/context-bisect/index.js.map +1 -1
- package/dist/esm/lib/context-bisect/llmEdgeWeigher.d.ts +124 -0
- package/dist/esm/lib/context-bisect/localize.d.ts +152 -0
- package/dist/esm/lib/context-bisect/localize.js +2 -0
- package/dist/esm/lib/context-bisect/localize.js.map +1 -1
- package/dist/esm/lib/context-bisect/loop-recall.d.ts +97 -0
- package/dist/esm/lib/context-bisect/missingContext.d.ts +71 -0
- package/dist/esm/lib/context-bisect/restoration.d.ts +39 -0
- package/dist/esm/lib/context-bisect/toBacktrackTrace.d.ts +138 -0
- package/dist/esm/lib/context-bisect/trajectory.d.ts +168 -0
- package/dist/esm/lib/context-bisect/types.d.ts +448 -0
- package/dist/esm/lib/context-bisect/walk-to-root.d.ts +103 -0
- package/dist/esm/lib/influence-core/attributability.d.ts +72 -0
- package/dist/esm/lib/influence-core/cache.d.ts +94 -0
- package/dist/esm/lib/influence-core/contrastive.d.ts +26 -0
- package/dist/esm/lib/influence-core/index.d.ts +34 -0
- package/dist/esm/lib/influence-core/margin.d.ts +33 -0
- package/dist/esm/lib/influence-core/signals.d.ts +128 -0
- package/dist/esm/lib/influence-core/similarity.d.ts +25 -0
- package/dist/esm/lib/influence-core/types.d.ts +252 -0
- package/dist/esm/lib/injection-engine/SkillRegistry.d.ts +147 -0
- package/dist/esm/lib/injection-engine/buildInjectionEngineSubflow.d.ts +110 -0
- package/dist/esm/lib/injection-engine/buildInjectionEngineSubflow.js +1 -0
- package/dist/esm/lib/injection-engine/buildInjectionEngineSubflow.js.map +1 -1
- package/dist/esm/lib/injection-engine/entryScorer.d.ts +93 -0
- package/dist/esm/lib/injection-engine/entryScorer.js +172 -0
- package/dist/esm/lib/injection-engine/entryScorer.js.map +1 -0
- package/dist/esm/lib/injection-engine/evaluator.d.ts +24 -0
- package/dist/esm/lib/injection-engine/factories/defineFact.d.ts +60 -0
- package/dist/esm/lib/injection-engine/factories/defineInjection.d.ts +41 -0
- package/dist/esm/lib/injection-engine/factories/defineInstruction.d.ts +78 -0
- package/dist/esm/lib/injection-engine/factories/defineRelevanceHint.d.ts +26 -0
- package/dist/esm/lib/injection-engine/factories/defineSkill.d.ts +160 -0
- package/dist/esm/lib/injection-engine/factories/defineSteering.d.ts +39 -0
- package/dist/esm/lib/injection-engine/index.d.ts +22 -0
- package/dist/esm/lib/injection-engine/index.js +1 -0
- package/dist/esm/lib/injection-engine/index.js.map +1 -1
- package/dist/esm/lib/injection-engine/skillContract.d.ts +29 -0
- package/dist/esm/lib/injection-engine/skillGraph.d.ts +289 -0
- package/dist/esm/lib/injection-engine/skillGraph.js +35 -41
- package/dist/esm/lib/injection-engine/skillGraph.js.map +1 -1
- package/dist/esm/lib/injection-engine/skillGraphCheckup.d.ts +49 -0
- package/dist/esm/lib/injection-engine/skillTools.d.ts +72 -0
- package/dist/esm/lib/injection-engine/softmax.d.ts +11 -0
- package/dist/esm/lib/injection-engine/types.d.ts +229 -0
- package/dist/esm/lib/injection-engine/types.js.map +1 -1
- package/dist/esm/lib/lazyRequire.d.ts +29 -0
- package/dist/esm/lib/mcp/index.d.ts +9 -0
- package/dist/esm/lib/mcp/mcpClient.d.ts +46 -0
- package/dist/esm/lib/mcp/mockMcpClient.d.ts +65 -0
- package/dist/esm/lib/mcp/types.d.ts +133 -0
- package/dist/esm/lib/rag/defineRAG.d.ts +139 -0
- package/dist/esm/lib/rag/index.d.ts +7 -0
- package/dist/esm/lib/rag/indexDocuments.d.ts +105 -0
- package/dist/esm/lib/tool-lint/analyze.d.ts +83 -0
- package/dist/esm/lib/tool-lint/cli.d.ts +43 -0
- package/dist/esm/lib/tool-lint/format.d.ts +18 -0
- package/dist/esm/lib/tool-lint/index.d.ts +23 -0
- package/dist/esm/lib/tool-lint/rules.d.ts +85 -0
- package/dist/esm/lib/tool-lint/types.d.ts +155 -0
- package/dist/esm/lib/trace-toolpack/bounded.d.ts +47 -0
- package/dist/esm/lib/trace-toolpack/debugPrompt.d.ts +19 -0
- package/dist/esm/lib/trace-toolpack/index.d.ts +20 -0
- package/dist/esm/lib/trace-toolpack/lazyToolpack.d.ts +35 -0
- package/dist/esm/lib/trace-toolpack/selfExplain.d.ts +100 -0
- package/dist/esm/lib/trace-toolpack/traceDebugAgent.d.ts +42 -0
- package/dist/esm/lib/trace-toolpack/traceToolpack.d.ts +69 -0
- package/dist/esm/lib/trace-toolpack/types.d.ts +59 -0
- package/dist/esm/llm-providers.d.ts +26 -0
- package/dist/esm/locales/index.d.ts +132 -0
- package/dist/esm/memory/beats/extractBeats.d.ts +61 -0
- package/dist/esm/memory/beats/extractor.d.ts +47 -0
- package/dist/esm/memory/beats/formatAsNarrative.d.ts +62 -0
- package/dist/esm/memory/beats/heuristicExtractor.d.ts +37 -0
- package/dist/esm/memory/beats/index.d.ts +12 -0
- package/dist/esm/memory/beats/llmExtractor.d.ts +56 -0
- package/dist/esm/memory/beats/types.d.ts +60 -0
- package/dist/esm/memory/beats/writeBeats.d.ts +22 -0
- package/dist/esm/memory/causal/evidenceRecorder.d.ts +66 -0
- package/dist/esm/memory/causal/index.d.ts +6 -0
- package/dist/esm/memory/causal/loadSnapshot.d.ts +51 -0
- package/dist/esm/memory/causal/snapshotPipeline.d.ts +35 -0
- package/dist/esm/memory/causal/types.d.ts +130 -0
- package/dist/esm/memory/causal/writeSnapshot.d.ts +73 -0
- package/dist/esm/memory/define.d.ts +63 -0
- package/dist/esm/memory/define.types.d.ts +276 -0
- package/dist/esm/memory/define.types.js +1 -1
- package/dist/esm/memory/embedding/cosine.d.ts +18 -0
- package/dist/esm/memory/embedding/embedMessages.d.ts +58 -0
- package/dist/esm/memory/embedding/index.d.ts +8 -0
- package/dist/esm/memory/embedding/loadRelevant.d.ts +51 -0
- package/dist/esm/memory/embedding/mockEmbedder.d.ts +22 -0
- package/dist/esm/memory/embedding/types.d.ts +46 -0
- package/dist/esm/memory/entry/decay.d.ts +36 -0
- package/dist/esm/memory/entry/index.d.ts +2 -0
- package/dist/esm/memory/entry/types.d.ts +140 -0
- package/dist/esm/memory/facts/extractFacts.d.ts +50 -0
- package/dist/esm/memory/facts/extractor.d.ts +33 -0
- package/dist/esm/memory/facts/formatFacts.d.ts +60 -0
- package/dist/esm/memory/facts/index.d.ts +14 -0
- package/dist/esm/memory/facts/llmFactExtractor.d.ts +64 -0
- package/dist/esm/memory/facts/loadFacts.d.ts +43 -0
- package/dist/esm/memory/facts/patternFactExtractor.d.ts +2 -0
- package/dist/esm/memory/facts/types.d.ts +68 -0
- package/dist/esm/memory/facts/writeFacts.d.ts +19 -0
- package/dist/esm/memory/identity/index.d.ts +2 -0
- package/dist/esm/memory/identity/types.d.ts +49 -0
- package/dist/esm/memory/index.d.ts +19 -0
- package/dist/esm/memory/pipeline/auto.d.ts +59 -0
- package/dist/esm/memory/pipeline/default.d.ts +49 -0
- package/dist/esm/memory/pipeline/ephemeral.d.ts +28 -0
- package/dist/esm/memory/pipeline/fact.d.ts +26 -0
- package/dist/esm/memory/pipeline/index.d.ts +13 -0
- package/dist/esm/memory/pipeline/narrative.d.ts +35 -0
- package/dist/esm/memory/pipeline/semantic.d.ts +37 -0
- package/dist/esm/memory/pipeline/types.d.ts +31 -0
- package/dist/esm/memory/stages/formatDefault.d.ts +64 -0
- package/dist/esm/memory/stages/index.d.ts +13 -0
- package/dist/esm/memory/stages/loadRecent.d.ts +49 -0
- package/dist/esm/memory/stages/pickByBudget.d.ts +63 -0
- package/dist/esm/memory/stages/summarize.d.ts +87 -0
- package/dist/esm/memory/stages/tokenize.d.ts +43 -0
- package/dist/esm/memory/stages/types.d.ts +75 -0
- package/dist/esm/memory/stages/writeMessages.d.ts +71 -0
- package/dist/esm/memory/store/InMemoryStore.d.ts +62 -0
- package/dist/esm/memory/store/index.d.ts +2 -0
- package/dist/esm/memory/store/types.d.ts +223 -0
- package/dist/esm/memory/wire/index.d.ts +2 -0
- package/dist/esm/memory/wire/mountMemoryPipeline.d.ts +108 -0
- package/dist/esm/memory-providers.d.ts +37 -0
- package/dist/esm/observability/contextError/finders/compareFinders.d.ts +19 -0
- package/dist/esm/observability/contextError/finders/index.d.ts +22 -0
- package/dist/esm/observability/contextError/finders/rankSuspects.d.ts +2 -0
- package/dist/esm/observability/contextError/finders/removeAndRetry.d.ts +11 -0
- package/dist/esm/observability/contextError/finders/shrinkToCause.d.ts +11 -0
- package/dist/esm/observability/contextError/finders/testManyCombos.d.ts +11 -0
- package/dist/esm/observability/contextError/finders/traceSteps.d.ts +2 -0
- package/dist/esm/observability/contextError/finders/types.d.ts +88 -0
- package/dist/esm/observability-providers.d.ts +46 -0
- package/dist/esm/observe.d.ts +62 -0
- package/dist/esm/observe.js +7 -1
- package/dist/esm/observe.js.map +1 -1
- package/dist/esm/patterns/Debate.d.ts +39 -0
- package/dist/esm/patterns/MapReduce.d.ts +66 -0
- package/dist/esm/patterns/Reflection.d.ts +51 -0
- package/dist/esm/patterns/SelfConsistency.d.ts +43 -0
- package/dist/esm/patterns/Swarm.d.ts +60 -0
- package/dist/esm/patterns/ToT.d.ts +53 -0
- package/dist/esm/patterns/index.d.ts +22 -0
- package/dist/esm/providers.d.ts +33 -0
- package/dist/esm/recorders/core/AgentRecorder.d.ts +15 -0
- package/dist/esm/recorders/core/CompositionRecorder.d.ts +17 -0
- package/dist/esm/recorders/core/ContextEvaluatedRecorder.d.ts +23 -0
- package/dist/esm/recorders/core/ContextRecorder.d.ts +47 -0
- package/dist/esm/recorders/core/CostRecorder.d.ts +14 -0
- package/dist/esm/recorders/core/EmitBridge.d.ts +30 -0
- package/dist/esm/recorders/core/ErrorBridge.d.ts +38 -0
- package/dist/esm/recorders/core/EvalRecorder.d.ts +16 -0
- package/dist/esm/recorders/core/MemoryRecorder.d.ts +17 -0
- package/dist/esm/recorders/core/PermissionRecorder.d.ts +16 -0
- package/dist/esm/recorders/core/ReliabilityRecorder.d.ts +24 -0
- package/dist/esm/recorders/core/SkillRecorder.d.ts +14 -0
- package/dist/esm/recorders/core/StreamRecorder.d.ts +15 -0
- package/dist/esm/recorders/core/ToolsRecorder.d.ts +18 -0
- package/dist/esm/recorders/core/ValidationRecorder.d.ts +16 -0
- package/dist/esm/recorders/core/contextEngineering.d.ts +136 -0
- package/dist/esm/recorders/core/typedEmit.d.ts +34 -0
- package/dist/esm/recorders/core/types.d.ts +97 -0
- package/dist/esm/recorders/observability/AgentThinkingTraceRecorder.d.ts +117 -0
- package/dist/esm/recorders/observability/BoundaryRecorder.d.ts +546 -0
- package/dist/esm/recorders/observability/FlowchartRecorder.d.ts +220 -0
- package/dist/esm/recorders/observability/FlowchartRecorder.js +10 -2
- package/dist/esm/recorders/observability/FlowchartRecorder.js.map +1 -1
- package/dist/esm/recorders/observability/LiveStateRecorder.d.ts +250 -0
- package/dist/esm/recorders/observability/LoggingRecorder.d.ts +91 -0
- package/dist/esm/recorders/observability/RouteRecorder.d.ts +83 -0
- package/dist/esm/recorders/observability/RunStepRecorder.d.ts +231 -0
- package/dist/esm/recorders/observability/StatusRecorder.d.ts +36 -0
- package/dist/esm/recorders/observability/ToolChoiceRecorder.d.ts +164 -0
- package/dist/esm/recorders/observability/ToolLineageRecorder.d.ts +71 -0
- package/dist/esm/recorders/observability/commentary/commentaryTemplates.d.ts +105 -0
- package/dist/esm/recorders/observability/internal/ActorArrowClassifier.d.ts +25 -0
- package/dist/esm/recorders/observability/internal/CandidateAnswerBuffer.d.ts +28 -0
- package/dist/esm/recorders/observability/internal/ForkTracker.d.ts +60 -0
- package/dist/esm/recorders/observability/internal/RootInferrer.d.ts +51 -0
- package/dist/esm/recorders/observability/internal/SequenceSiblingTracker.d.ts +24 -0
- package/dist/esm/recorders/observability/localObservability.d.ts +48 -0
- package/dist/esm/recorders/observability/localObservability.js +54 -0
- package/dist/esm/recorders/observability/localObservability.js.map +1 -0
- package/dist/esm/recorders/observability/observeRunId.d.ts +36 -0
- package/dist/esm/recorders/observability/status/statusTemplates.d.ts +106 -0
- package/dist/esm/recorders/observability/trace.d.ts +119 -0
- package/dist/esm/recorders/observability/trace.js +99 -0
- package/dist/esm/recorders/observability/trace.js.map +1 -0
- package/dist/esm/reliability/CircuitBreaker.d.ts +75 -0
- package/dist/esm/reliability/buildReliabilityGateChart.d.ts +53 -0
- package/dist/esm/reliability/classifyError.d.ts +28 -0
- package/dist/esm/reliability/index.d.ts +35 -0
- package/dist/esm/reliability/types.d.ts +327 -0
- package/dist/esm/resilience/fallbackProvider.d.ts +33 -0
- package/dist/esm/resilience/index.d.ts +21 -0
- package/dist/esm/resilience/withCircuitBreaker.d.ts +129 -0
- package/dist/esm/resilience/withFallback.d.ts +45 -0
- package/dist/esm/resilience/withRetry.d.ts +71 -0
- package/dist/esm/security/PermissionPolicy.d.ts +124 -0
- package/dist/esm/security/PolicyHaltError.d.ts +72 -0
- package/dist/esm/security/extractSequence.d.ts +46 -0
- package/dist/esm/security/index.d.ts +44 -0
- package/dist/esm/security/thinkingRedaction.d.ts +50 -0
- package/dist/esm/status.d.ts +48 -0
- package/dist/esm/strategies/attach.d.ts +47 -0
- package/dist/esm/strategies/compose.d.ts +48 -0
- package/dist/esm/strategies/defaults/chatBubbleLiveStatus.d.ts +36 -0
- package/dist/esm/strategies/defaults/consoleObservability.d.ts +42 -0
- package/dist/esm/strategies/defaults/inMemorySinkCost.d.ts +50 -0
- package/dist/esm/strategies/defaults/index.d.ts +30 -0
- package/dist/esm/strategies/defaults/noopLens.d.ts +28 -0
- package/dist/esm/strategies/index.d.ts +36 -0
- package/dist/esm/strategies/registry.d.ts +70 -0
- package/dist/esm/strategies/types.d.ts +303 -0
- package/dist/esm/stream.d.ts +82 -0
- package/dist/esm/thinking/AnthropicThinkingHandler.d.ts +42 -0
- package/dist/esm/thinking/MockThinkingHandler.d.ts +50 -0
- package/dist/esm/thinking/OpenAIThinkingHandler.d.ts +37 -0
- package/dist/esm/thinking/index.d.ts +51 -0
- package/dist/esm/thinking/registry.d.ts +33 -0
- package/dist/esm/thinking/types.d.ts +162 -0
- package/dist/esm/tool-providers/gatedTools.d.ts +36 -0
- package/dist/esm/tool-providers/index.d.ts +41 -0
- package/dist/esm/tool-providers/skillScopedTools.d.ts +45 -0
- package/dist/esm/tool-providers/staticTools.d.ts +21 -0
- package/dist/esm/tool-providers/types.d.ts +138 -0
- package/dist/index.js +6 -2
- package/dist/index.js.map +1 -1
- package/dist/lib/context-bisect/index.js +3 -0
- package/dist/lib/context-bisect/index.js.map +1 -1
- package/dist/lib/context-bisect/localize.js +2 -0
- package/dist/lib/context-bisect/localize.js.map +1 -1
- package/dist/lib/injection-engine/buildInjectionEngineSubflow.js +1 -0
- package/dist/lib/injection-engine/buildInjectionEngineSubflow.js.map +1 -1
- package/dist/lib/injection-engine/entryScorer.js +178 -0
- package/dist/lib/injection-engine/entryScorer.js.map +1 -0
- package/dist/lib/injection-engine/index.js +5 -1
- package/dist/lib/injection-engine/index.js.map +1 -1
- package/dist/lib/injection-engine/skillGraph.js +35 -41
- package/dist/lib/injection-engine/skillGraph.js.map +1 -1
- package/dist/lib/injection-engine/types.js.map +1 -1
- package/dist/memory/define.types.js +1 -1
- package/dist/observe.js +14 -3
- package/dist/observe.js.map +1 -1
- package/dist/recorders/observability/FlowchartRecorder.js +12 -3
- package/dist/recorders/observability/FlowchartRecorder.js.map +1 -1
- package/dist/recorders/observability/localObservability.js +58 -0
- package/dist/recorders/observability/localObservability.js.map +1 -0
- package/dist/recorders/observability/trace.js +105 -0
- package/dist/recorders/observability/trace.js.map +1 -0
- package/dist/types/core/RunnerBase.d.ts.map +1 -1
- package/dist/types/core/agent/buildAgentChart.d.ts.map +1 -1
- package/dist/types/core/agent/buildDynamicAgentChart.d.ts.map +1 -1
- package/dist/types/core/agent/stages/pickEntry.d.ts.map +1 -1
- package/dist/types/core/agent/types.d.ts +8 -4
- package/dist/types/core/agent/types.d.ts.map +1 -1
- package/dist/types/core/runner.d.ts +12 -0
- package/dist/types/core/runner.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/lib/context-bisect/index.d.ts +3 -0
- package/dist/types/lib/context-bisect/index.d.ts.map +1 -1
- package/dist/types/lib/context-bisect/localize.d.ts +2 -0
- package/dist/types/lib/context-bisect/localize.d.ts.map +1 -1
- package/dist/types/lib/injection-engine/buildInjectionEngineSubflow.d.ts.map +1 -1
- package/dist/types/lib/injection-engine/entryScorer.d.ts +94 -0
- package/dist/types/lib/injection-engine/entryScorer.d.ts.map +1 -0
- package/dist/types/lib/injection-engine/index.d.ts +1 -0
- package/dist/types/lib/injection-engine/index.d.ts.map +1 -1
- package/dist/types/lib/injection-engine/skillGraph.d.ts +21 -24
- package/dist/types/lib/injection-engine/skillGraph.d.ts.map +1 -1
- package/dist/types/lib/injection-engine/types.d.ts +9 -4
- package/dist/types/lib/injection-engine/types.d.ts.map +1 -1
- package/dist/types/memory/define.types.d.ts +1 -1
- package/dist/types/observe.d.ts +3 -1
- package/dist/types/observe.d.ts.map +1 -1
- package/dist/types/recorders/observability/FlowchartRecorder.d.ts +8 -1
- package/dist/types/recorders/observability/FlowchartRecorder.d.ts.map +1 -1
- package/dist/types/recorders/observability/localObservability.d.ts +49 -0
- package/dist/types/recorders/observability/localObservability.d.ts.map +1 -0
- package/dist/types/recorders/observability/trace.d.ts +120 -0
- package/dist/types/recorders/observability/trace.d.ts.map +1 -0
- package/package.json +203 -56
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* writeMessages — write-side stage that persists new turn messages as
|
|
3
|
+
* `MemoryEntry`s.
|
|
4
|
+
*
|
|
5
|
+
* Reads from scope: `identity`, `turnNumber`, `newMessages`
|
|
6
|
+
* Writes to store: one entry per message, id = `msg-{turnNumber}-{index}`
|
|
7
|
+
*
|
|
8
|
+
* Every written entry carries `source.turn` + `source.identity` so
|
|
9
|
+
* retrieval stages can later show "recalled from turn 5" with correct
|
|
10
|
+
* cross-session provenance. A content-hash signature is also registered
|
|
11
|
+
* via `store.recordSignature` so subsequent `seen()` calls recognize
|
|
12
|
+
* near-duplicate content without loading the full entries.
|
|
13
|
+
*
|
|
14
|
+
* Why a deterministic `id` format?
|
|
15
|
+
* `msg-{turn}-{index}` lets write-then-re-write be idempotent: a stage
|
|
16
|
+
* that re-runs in the same turn (retries, resumable turns) overwrites
|
|
17
|
+
* the same id instead of growing history. For non-turn-scoped writes,
|
|
18
|
+
* pass a custom `idFrom` that produces whatever shape your app needs.
|
|
19
|
+
*
|
|
20
|
+
* PII / redaction:
|
|
21
|
+
* Message content is stored VERBATIM. If your messages contain PII
|
|
22
|
+
* (names, addresses, secrets), redact BEFORE writing — either by
|
|
23
|
+
* mutating `scope.newMessages` upstream or by wrapping the call site
|
|
24
|
+
* with a redaction helper. The storage layer does NOT scrub for you.
|
|
25
|
+
* Pair with footprintjs's `RedactionPolicy` for end-to-end coverage.
|
|
26
|
+
*
|
|
27
|
+
* Extended thinking blocks (Anthropic) / reasoning tokens (OpenAI):
|
|
28
|
+
* Persisting reasoning blocks is expensive — they can be 10-100× the
|
|
29
|
+
* size of the final message. Strip them from `scope.newMessages` before
|
|
30
|
+
* calling this stage UNLESS you plan to recall them (e.g. for debugging
|
|
31
|
+
* replay). A common pattern: write reasoning to `tier: 'cold'` with a
|
|
32
|
+
* short `ttlMs` so they age out quickly.
|
|
33
|
+
*/
|
|
34
|
+
import type { TypedScope } from 'footprintjs';
|
|
35
|
+
import type { MemoryStore } from '../store/index.js';
|
|
36
|
+
import type { LLMMessage as Message } from '../../adapters/types.js';
|
|
37
|
+
import type { MemoryState } from './types.js';
|
|
38
|
+
export interface WriteMessagesConfig {
|
|
39
|
+
/** The store to persist to. */
|
|
40
|
+
readonly store: MemoryStore;
|
|
41
|
+
/**
|
|
42
|
+
* Optional id producer — receives (turn, index, message) and returns
|
|
43
|
+
* the `MemoryEntry.id`. Defaults to `msg-{turn}-{index}` which makes
|
|
44
|
+
* re-runs of the same turn idempotent. Override for app-level ids
|
|
45
|
+
* (e.g. use a message's server-side id).
|
|
46
|
+
*/
|
|
47
|
+
readonly idFrom?: (turn: number, index: number, message: Message) => string;
|
|
48
|
+
/**
|
|
49
|
+
* Optional signature producer for the recognition set. When present,
|
|
50
|
+
* each message produces a signature that is registered via
|
|
51
|
+
* `store.recordSignature`; `seen()` later returns `true` for the same
|
|
52
|
+
* content. Default: skip (many apps don't need recognition).
|
|
53
|
+
*/
|
|
54
|
+
readonly signatureFrom?: (message: Message) => string;
|
|
55
|
+
/**
|
|
56
|
+
* Optional TTL in milliseconds from `Date.now()`. When set, written
|
|
57
|
+
* entries expire this long after they were stored. Useful for
|
|
58
|
+
* compliance retention windows ("delete chat history after 30 days").
|
|
59
|
+
*/
|
|
60
|
+
readonly ttlMs?: number;
|
|
61
|
+
/**
|
|
62
|
+
* Optional tier for the entries. Typical pattern:
|
|
63
|
+
* - `'hot'` for the last few turns
|
|
64
|
+
* - `'warm'` for older turns
|
|
65
|
+
* - `'cold'` for archived
|
|
66
|
+
* Stages in Layer 3+ can filter on tier. Omitting leaves entries
|
|
67
|
+
* untiered (read stages still see them; tier-filtered reads skip them).
|
|
68
|
+
*/
|
|
69
|
+
readonly tier?: 'hot' | 'warm' | 'cold';
|
|
70
|
+
}
|
|
71
|
+
export declare function writeMessages(config: WriteMessagesConfig): (scope: TypedScope<MemoryState>) => Promise<void>;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* InMemoryStore — reference `MemoryStore` implementation, zero dependencies.
|
|
3
|
+
*
|
|
4
|
+
* Kept deliberately small — ~200 lines. Its job is to validate the
|
|
5
|
+
* interface contract: every stage and pipeline is tested against this
|
|
6
|
+
* adapter, so any bug in the store shape surfaces here first.
|
|
7
|
+
*
|
|
8
|
+
* Internal structure:
|
|
9
|
+
* namespace (string) → Map<entryId, MemoryEntry>
|
|
10
|
+
* + Set<signature> (for seen)
|
|
11
|
+
* + Map<id, usefulnessSum, usefulnessCount> (for feedback)
|
|
12
|
+
*
|
|
13
|
+
* TTL is enforced lazily on read (cheapest; no background sweeper needed).
|
|
14
|
+
* Pagination cursor is a monotonic integer — entries sorted by updatedAt desc.
|
|
15
|
+
*/
|
|
16
|
+
import type { MemoryIdentity } from '../identity/index.js';
|
|
17
|
+
import type { MemoryEntry } from '../entry/index.js';
|
|
18
|
+
import type { ListOptions, ListResult, MemoryStore, PutIfVersionResult, ScoredEntry, SearchOptions } from './types.js';
|
|
19
|
+
export declare class InMemoryStore implements MemoryStore {
|
|
20
|
+
/**
|
|
21
|
+
* Top-level namespace → slot. Using `Map` rather than a plain object
|
|
22
|
+
* avoids prototype-pollution surface AND preserves insertion order
|
|
23
|
+
* (needed for deterministic list pagination).
|
|
24
|
+
*/
|
|
25
|
+
private readonly namespaces;
|
|
26
|
+
private slot;
|
|
27
|
+
/** True if the entry's TTL has elapsed. Centralized so both `get` and `list` agree. */
|
|
28
|
+
private isExpired;
|
|
29
|
+
get<T = unknown>(identity: MemoryIdentity, id: string): Promise<MemoryEntry<T> | null>;
|
|
30
|
+
put<T = unknown>(identity: MemoryIdentity, entry: MemoryEntry<T>): Promise<void>;
|
|
31
|
+
/**
|
|
32
|
+
* Batched write — resolves the slot once and writes each entry into the
|
|
33
|
+
* same Map. Saves N-1 slot lookups vs. calling `put()` in a loop, and
|
|
34
|
+
* gives network-backed adapters a place to pipeline round-trips.
|
|
35
|
+
*/
|
|
36
|
+
putMany<T = unknown>(identity: MemoryIdentity, entries: readonly MemoryEntry<T>[]): Promise<void>;
|
|
37
|
+
putIfVersion<T = unknown>(identity: MemoryIdentity, entry: MemoryEntry<T>, expectedVersion: number): Promise<PutIfVersionResult>;
|
|
38
|
+
list<T = unknown>(identity: MemoryIdentity, options?: ListOptions): Promise<ListResult<T>>;
|
|
39
|
+
delete(identity: MemoryIdentity, id: string): Promise<void>;
|
|
40
|
+
seen(identity: MemoryIdentity, signature: string): Promise<boolean>;
|
|
41
|
+
recordSignature(identity: MemoryIdentity, signature: string): Promise<void>;
|
|
42
|
+
feedback(identity: MemoryIdentity, id: string, usefulness: number): Promise<void>;
|
|
43
|
+
getFeedback(identity: MemoryIdentity, id: string): Promise<{
|
|
44
|
+
average: number;
|
|
45
|
+
count: number;
|
|
46
|
+
} | null>;
|
|
47
|
+
forget(identity: MemoryIdentity): Promise<void>;
|
|
48
|
+
/**
|
|
49
|
+
* O(n) linear scan over identity-scoped entries. Fine for dev / tests
|
|
50
|
+
* — for production, plug in a real vector backend (pgvector, Pinecone,
|
|
51
|
+
* Qdrant) that implements the same interface.
|
|
52
|
+
*
|
|
53
|
+
* Semantics per the `MemoryStore.search?` contract:
|
|
54
|
+
* - Entries without `embedding` are skipped (ignored, not errored).
|
|
55
|
+
* - Entries with `embedding.length` mismatching the query are
|
|
56
|
+
* skipped (cosine would throw — silent-skip avoids poisoning top-k).
|
|
57
|
+
* - TTL-expired entries are omitted.
|
|
58
|
+
* - Optional `tiers` / `minScore` / `embedderId` filters applied.
|
|
59
|
+
* - Returns descending by score; ties broken by id for determinism.
|
|
60
|
+
*/
|
|
61
|
+
search<T = unknown>(identity: MemoryIdentity, query: readonly number[], options?: SearchOptions): Promise<readonly ScoredEntry<T>[]>;
|
|
62
|
+
}
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MemoryStore — the I/O boundary.
|
|
3
|
+
*
|
|
4
|
+
* Every storage backend (InMemory, Redis, DynamoDB, Postgres, Bedrock
|
|
5
|
+
* AgentCore) implements this interface. Stages above the store layer never
|
|
6
|
+
* talk to a concrete backend — they invoke these methods and trust the
|
|
7
|
+
* adapter to handle durability, consistency, encryption, pagination, etc.
|
|
8
|
+
*
|
|
9
|
+
* Design principles:
|
|
10
|
+
*
|
|
11
|
+
* 1. **Identity is always the first argument.** Every call takes
|
|
12
|
+
* `MemoryIdentity` so stores enforce tenant / principal isolation at
|
|
13
|
+
* the boundary. A bug passing the wrong identity surfaces as "no data"
|
|
14
|
+
* rather than a cross-tenant leak.
|
|
15
|
+
*
|
|
16
|
+
* 2. **Methods return Promises uniformly.** Even InMemoryStore's sync ops
|
|
17
|
+
* are wrapped — stages can await every call and adapters are free to
|
|
18
|
+
* swap sync ↔ async without breaking callers.
|
|
19
|
+
*
|
|
20
|
+
* 3. **Writes are optimistic-concurrency-aware.** `putIfVersion` is the
|
|
21
|
+
* default for multi-writer correctness; `put` is convenience for "I
|
|
22
|
+
* know I'm the only writer" callers (single-server, tests).
|
|
23
|
+
*
|
|
24
|
+
* 4. **Reads return cursors, not unbounded arrays.** `list` takes
|
|
25
|
+
* `{ cursor?, limit? }` so large namespaces never OOM. Stages iterate
|
|
26
|
+
* as long as they need.
|
|
27
|
+
*
|
|
28
|
+
* 5. **Recognition is separate from recall.** `seen(signature)` is a
|
|
29
|
+
* boolean check — cheaper than `get` when the caller only needs
|
|
30
|
+
* "have we processed this before?" (cognitive-arch reviewer ask).
|
|
31
|
+
*
|
|
32
|
+
* 6. **Feedback flows back.** `feedback(id, usefulness)` lets retrieval
|
|
33
|
+
* stages signal "this entry was actually used / wasn't used" so
|
|
34
|
+
* adapters can drive their own learning / eviction (RAG-theory ask).
|
|
35
|
+
*/
|
|
36
|
+
import type { MemoryIdentity } from '../identity/index.js';
|
|
37
|
+
import type { MemoryEntry } from '../entry/index.js';
|
|
38
|
+
/** Pagination cursor — opaque string, adapter-specific encoding. */
|
|
39
|
+
export type MemoryCursor = string;
|
|
40
|
+
/** Options for listing entries in a namespace. */
|
|
41
|
+
export interface ListOptions {
|
|
42
|
+
/** Continuation token from a previous `list` call. Omit for the first page. */
|
|
43
|
+
readonly cursor?: MemoryCursor;
|
|
44
|
+
/** Maximum entries to return in this page. Adapters may cap this lower. */
|
|
45
|
+
readonly limit?: number;
|
|
46
|
+
/** Optional filter — only return entries matching these tiers. */
|
|
47
|
+
readonly tiers?: ReadonlyArray<'hot' | 'warm' | 'cold'>;
|
|
48
|
+
}
|
|
49
|
+
/** Result of a paginated `list` call. */
|
|
50
|
+
export interface ListResult<T = unknown> {
|
|
51
|
+
readonly entries: readonly MemoryEntry<T>[];
|
|
52
|
+
/** Present iff more pages exist. Pass back into `list.cursor` to continue. */
|
|
53
|
+
readonly cursor?: MemoryCursor;
|
|
54
|
+
}
|
|
55
|
+
/** Outcome of a `putIfVersion` attempt. */
|
|
56
|
+
export interface PutIfVersionResult {
|
|
57
|
+
/** True iff the write succeeded. */
|
|
58
|
+
readonly applied: boolean;
|
|
59
|
+
/**
|
|
60
|
+
* When `applied === false`, the current version stored — caller can
|
|
61
|
+
* decide whether to retry, merge, or abort. Absent if the entry did
|
|
62
|
+
* not exist at all.
|
|
63
|
+
*/
|
|
64
|
+
readonly currentVersion?: number;
|
|
65
|
+
}
|
|
66
|
+
/** Options for a vector similarity search. */
|
|
67
|
+
export interface SearchOptions {
|
|
68
|
+
/**
|
|
69
|
+
* How many top-scoring entries to return. Default 10. Adapters may
|
|
70
|
+
* cap this lower (Pinecone: 10000, pgvector: user-defined, etc.).
|
|
71
|
+
*/
|
|
72
|
+
readonly k?: number;
|
|
73
|
+
/** Filter results by tier (e.g. `['hot']`) before ranking. */
|
|
74
|
+
readonly tiers?: ReadonlyArray<'hot' | 'warm' | 'cold'>;
|
|
75
|
+
/**
|
|
76
|
+
* Drop entries whose similarity score is below this threshold. Useful
|
|
77
|
+
* when "no match" is a valid outcome (vs. always returning the k
|
|
78
|
+
* nearest no matter how far away). Range [-1, 1] for cosine.
|
|
79
|
+
*/
|
|
80
|
+
readonly minScore?: number;
|
|
81
|
+
/**
|
|
82
|
+
* Embedder id the query was produced with. When present, adapters MAY
|
|
83
|
+
* skip entries whose `embeddingModel` doesn't match — prevents silent
|
|
84
|
+
* cross-model similarity pollution. Absent = trust caller knows what
|
|
85
|
+
* they're doing.
|
|
86
|
+
*/
|
|
87
|
+
readonly embedderId?: string;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* A `MemoryEntry` annotated with its similarity score. Returned by
|
|
91
|
+
* `store.search()`. Score semantics are adapter-defined but SHOULD
|
|
92
|
+
* use cosine similarity by default ([-1, 1], higher = closer).
|
|
93
|
+
*/
|
|
94
|
+
export interface ScoredEntry<T = unknown> {
|
|
95
|
+
readonly entry: MemoryEntry<T>;
|
|
96
|
+
readonly score: number;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Common surface for all backends. Every method takes `MemoryIdentity`
|
|
100
|
+
* as the scoping argument; stores MUST prefix their internal keys with
|
|
101
|
+
* `identityNamespace(identity)` to prevent cross-tenant access.
|
|
102
|
+
*/
|
|
103
|
+
export interface MemoryStore {
|
|
104
|
+
/**
|
|
105
|
+
* Fetch one entry by id within the given identity's namespace.
|
|
106
|
+
* Returns `null` when the entry doesn't exist OR has expired (TTL).
|
|
107
|
+
* Callers should not distinguish — both mean "no data."
|
|
108
|
+
*
|
|
109
|
+
* Side effect: adapters MAY increment `accessCount` and update
|
|
110
|
+
* `lastAccessedAt` when returning the entry (decay signals).
|
|
111
|
+
*/
|
|
112
|
+
get<T = unknown>(identity: MemoryIdentity, id: string): Promise<MemoryEntry<T> | null>;
|
|
113
|
+
/**
|
|
114
|
+
* Unconditional write — overwrites any existing entry with the same id.
|
|
115
|
+
* Prefer `putIfVersion` in multi-writer scenarios.
|
|
116
|
+
*/
|
|
117
|
+
put<T = unknown>(identity: MemoryIdentity, entry: MemoryEntry<T>): Promise<void>;
|
|
118
|
+
/**
|
|
119
|
+
* Batched unconditional write. Semantically equivalent to N sequential
|
|
120
|
+
* `put()` calls but gives adapters a chance to batch the round-trip.
|
|
121
|
+
*
|
|
122
|
+
* - **InMemoryStore**: no-op optimization — loops internally.
|
|
123
|
+
* - **Redis**: pipelined MSET / MULTI-EXEC.
|
|
124
|
+
* - **DynamoDB**: `BatchWriteItem` (25-entry limit enforced by caller
|
|
125
|
+
* or adapter — adapters MAY chunk).
|
|
126
|
+
* - **Postgres**: multi-row INSERT … ON CONFLICT DO UPDATE.
|
|
127
|
+
*
|
|
128
|
+
* Atomicity is NOT guaranteed across the batch — a partial failure
|
|
129
|
+
* may leave some entries written, some not. Stages that need
|
|
130
|
+
* transactional semantics should use `putIfVersion` per entry with
|
|
131
|
+
* application-level rollback. Most memory flows are append-idempotent
|
|
132
|
+
* (ids are deterministic like `msg-{turn}-{idx}`), so the batch model
|
|
133
|
+
* matches the common case.
|
|
134
|
+
*
|
|
135
|
+
* **Empty batch (`entries.length === 0`): MUST be a no-op.** Callers
|
|
136
|
+
* rely on this to skip a round-trip when there's nothing to persist
|
|
137
|
+
* (e.g., a turn that produced no new messages). Adapters must not
|
|
138
|
+
* reject empty batches — return a resolved Promise immediately.
|
|
139
|
+
*
|
|
140
|
+
* Default implementation for adapters that don't override: sequentially
|
|
141
|
+
* calls `put()` for each entry. Adapters SHOULD override for
|
|
142
|
+
* performance-critical paths.
|
|
143
|
+
*/
|
|
144
|
+
putMany<T = unknown>(identity: MemoryIdentity, entries: readonly MemoryEntry<T>[]): Promise<void>;
|
|
145
|
+
/**
|
|
146
|
+
* Optimistic-concurrency write. Writes only if the stored version equals
|
|
147
|
+
* `expectedVersion`, OR if no entry exists at all AND `expectedVersion`
|
|
148
|
+
* is `0` (first-write sentinel).
|
|
149
|
+
*
|
|
150
|
+
* Returns `{ applied: true }` on success, `{ applied: false, currentVersion }`
|
|
151
|
+
* when the caller's assumed version is stale.
|
|
152
|
+
*/
|
|
153
|
+
putIfVersion<T = unknown>(identity: MemoryIdentity, entry: MemoryEntry<T>, expectedVersion: number): Promise<PutIfVersionResult>;
|
|
154
|
+
/**
|
|
155
|
+
* Page through entries in the identity's namespace. Ordered by adapter's
|
|
156
|
+
* choice (usually most-recently-updated first) — consumers that care
|
|
157
|
+
* about order should filter client-side.
|
|
158
|
+
*/
|
|
159
|
+
list<T = unknown>(identity: MemoryIdentity, options?: ListOptions): Promise<ListResult<T>>;
|
|
160
|
+
/** Remove one entry. No-op if the entry doesn't exist. */
|
|
161
|
+
delete(identity: MemoryIdentity, id: string): Promise<void>;
|
|
162
|
+
/**
|
|
163
|
+
* Cheap "have we processed this signature before?" check. Useful for
|
|
164
|
+
* deduplication, idempotent writes, and cognitive-arch-style recognition
|
|
165
|
+
* vs. recall. Signature is an opaque string the caller controls
|
|
166
|
+
* (content hash, canonicalized fact, etc.).
|
|
167
|
+
*/
|
|
168
|
+
seen(identity: MemoryIdentity, signature: string): Promise<boolean>;
|
|
169
|
+
/**
|
|
170
|
+
* Write-side of the recognition set — adds a signature so subsequent
|
|
171
|
+
* `seen()` calls return `true`. Stages register signatures as entries
|
|
172
|
+
* are written (content hashes, canonicalized facts). Separate from the
|
|
173
|
+
* entry store: a signature outlives the entry that produced it, so
|
|
174
|
+
* dedup survives garbage collection.
|
|
175
|
+
*/
|
|
176
|
+
recordSignature(identity: MemoryIdentity, signature: string): Promise<void>;
|
|
177
|
+
/**
|
|
178
|
+
* Record usefulness feedback for an entry. `usefulness` in `[-1, 1]`:
|
|
179
|
+
* -1 = retrieved but harmful / misleading
|
|
180
|
+
* 0 = retrieved but not used (neutral)
|
|
181
|
+
* 1 = retrieved AND used in the final answer
|
|
182
|
+
*
|
|
183
|
+
* Non-finite values (NaN / ±Infinity) MUST be rejected by adapters —
|
|
184
|
+
* they poison the aggregate. Caller should pass a finite number in
|
|
185
|
+
* `[-1, 1]`; adapters clamp to the valid range for hardening.
|
|
186
|
+
*/
|
|
187
|
+
feedback(identity: MemoryIdentity, id: string, usefulness: number): Promise<void>;
|
|
188
|
+
/**
|
|
189
|
+
* Read-side of feedback — aggregated usefulness for an entry. Returns
|
|
190
|
+
* `null` when no feedback has been recorded (distinct from "neutral
|
|
191
|
+
* average of 0" — callers often want to treat the two differently).
|
|
192
|
+
* Retrieval stages consume this to feedback-weight rankings.
|
|
193
|
+
*/
|
|
194
|
+
getFeedback(identity: MemoryIdentity, id: string): Promise<{
|
|
195
|
+
average: number;
|
|
196
|
+
count: number;
|
|
197
|
+
} | null>;
|
|
198
|
+
/**
|
|
199
|
+
* GDPR — remove ALL entries for the given identity.
|
|
200
|
+
* Must be implementable in one operation per backend (DELETE WHERE prefix).
|
|
201
|
+
*/
|
|
202
|
+
forget(identity: MemoryIdentity): Promise<void>;
|
|
203
|
+
/**
|
|
204
|
+
* Optional — similarity search over entries that carry an
|
|
205
|
+
* `embedding` field. Returns the top-k entries by cosine similarity
|
|
206
|
+
* (descending). Adapters that don't support vector search should
|
|
207
|
+
* OMIT this method; callers feature-detect via `if (store.search)`.
|
|
208
|
+
*
|
|
209
|
+
* Semantics:
|
|
210
|
+
* - Entries with no `embedding` field are ignored (not errored).
|
|
211
|
+
* - Entries with `embedding` of mismatched length are skipped
|
|
212
|
+
* (cosine would throw — silent-skip avoids poisoning the top-k).
|
|
213
|
+
* - TTL-expired entries are omitted (same as `get`/`list`).
|
|
214
|
+
* - Ordering: descending by score. Ties broken by adapter choice.
|
|
215
|
+
*
|
|
216
|
+
* Reference backends:
|
|
217
|
+
* - **InMemoryStore**: O(n) linear scan over identity-scoped entries.
|
|
218
|
+
* Fine for dev / tests. Production needs a real vector DB.
|
|
219
|
+
* - **pgvector**: `ORDER BY embedding <=> query LIMIT k`.
|
|
220
|
+
* - **Pinecone / Qdrant / Weaviate**: native vector query API.
|
|
221
|
+
*/
|
|
222
|
+
search?<T = unknown>(identity: MemoryIdentity, query: readonly number[], options?: SearchOptions): Promise<readonly ScoredEntry<T>[]>;
|
|
223
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* mountMemoryPipeline — mount a MemoryPipeline's read + write subflows
|
|
3
|
+
* into an arbitrary agent flowchart.
|
|
4
|
+
*
|
|
5
|
+
* Given:
|
|
6
|
+
* - a `FlowChartBuilder<AgentState>` the caller has been assembling,
|
|
7
|
+
* - a `MemoryPipeline { read, write }` (typically from a preset),
|
|
8
|
+
* - identity + turn + budget inputs sourced from agent scope,
|
|
9
|
+
* - mount points (which stage id to insert the read subflow before),
|
|
10
|
+
*
|
|
11
|
+
* returns the builder with:
|
|
12
|
+
* 1. the `read` subflow mounted BEFORE the given anchor stage, with an
|
|
13
|
+
* inputMapper that reads identity/turn/budget from agent scope and
|
|
14
|
+
* an outputMapper that writes `formatted` messages back,
|
|
15
|
+
* 2. the `write` subflow (if present) appended AT THE END, with an
|
|
16
|
+
* inputMapper that reads `newMessages` from agent scope.
|
|
17
|
+
*
|
|
18
|
+
* The agent's existing stages are responsible for:
|
|
19
|
+
* - populating `identity`, `turnNumber`, `contextTokensRemaining`,
|
|
20
|
+
* `newMessages` in scope BEFORE the relevant memory subflow runs,
|
|
21
|
+
* - consuming the injected `formatted` messages (merge into the
|
|
22
|
+
* agent's outgoing LLM prompt).
|
|
23
|
+
*
|
|
24
|
+
* This helper does NOT own any of those concerns — it owns only the
|
|
25
|
+
* mechanical subflow mounting. Consumer-facing API
|
|
26
|
+
* (`AgentBuilder.memoryPipeline()`) is layered on top.
|
|
27
|
+
*
|
|
28
|
+
* Why a standalone helper, not a direct `AgentBuilder` patch?
|
|
29
|
+
* - Lets us test the wire mechanism end-to-end in isolation (Layer 6)
|
|
30
|
+
* without changing the existing AgentRunner path (100+ tests).
|
|
31
|
+
* - The wire is a small, reviewable unit; the AgentBuilder refactor is
|
|
32
|
+
* a larger concern that can ship separately.
|
|
33
|
+
* - Future non-Agent concepts (Swarm, Parallel) can use the same helper
|
|
34
|
+
* — memory isn't tied to Agent conceptually.
|
|
35
|
+
*/
|
|
36
|
+
import type { FlowChartBuilder } from 'footprintjs';
|
|
37
|
+
import type { MemoryPipeline } from '../pipeline/types.js';
|
|
38
|
+
/**
|
|
39
|
+
* Keys this helper reads from / writes to on the parent agent scope.
|
|
40
|
+
* Kept as fields on the config so consumers with non-standard field names
|
|
41
|
+
* can override without renaming scope properties.
|
|
42
|
+
*/
|
|
43
|
+
export interface MountMemoryPipelineConfig<ParentState> {
|
|
44
|
+
/** The compiled read + write subflows from a pipeline preset. */
|
|
45
|
+
readonly pipeline: MemoryPipeline;
|
|
46
|
+
/**
|
|
47
|
+
* Scope field name the read subflow reads identity from. Default
|
|
48
|
+
* `'identity'` — matches `MemoryState.identity`. Override when the
|
|
49
|
+
* host flowchart uses a different name.
|
|
50
|
+
*/
|
|
51
|
+
readonly identityKey?: keyof ParentState & string;
|
|
52
|
+
/** Scope field name for the turn counter. Default `'turnNumber'`. */
|
|
53
|
+
readonly turnNumberKey?: keyof ParentState & string;
|
|
54
|
+
/**
|
|
55
|
+
* Scope field name for the context-tokens-remaining signal.
|
|
56
|
+
* Default `'contextTokensRemaining'`.
|
|
57
|
+
*/
|
|
58
|
+
readonly contextTokensKey?: keyof ParentState & string;
|
|
59
|
+
/**
|
|
60
|
+
* Scope field the read subflow writes its `formatted` output to.
|
|
61
|
+
* Default `'memoryInjection'` — agent stages consume this to prepend
|
|
62
|
+
* to the LLM prompt. Distinct from the pipeline's own `formatted`
|
|
63
|
+
* field so there's no ambiguity between subflow-local and parent scope.
|
|
64
|
+
*/
|
|
65
|
+
readonly injectionKey?: keyof ParentState & string;
|
|
66
|
+
/**
|
|
67
|
+
* Scope field the write subflow reads messages to persist from.
|
|
68
|
+
* Default `'newMessages'` — populated by the agent at turn end.
|
|
69
|
+
*/
|
|
70
|
+
readonly newMessagesKey?: keyof ParentState & string;
|
|
71
|
+
/** Subflow id for the read mount. Default `'sf-memory-read'`. */
|
|
72
|
+
readonly readSubflowId?: string;
|
|
73
|
+
/** Subflow id for the write mount. Default `'sf-memory-write'`. */
|
|
74
|
+
readonly writeSubflowId?: string;
|
|
75
|
+
/**
|
|
76
|
+
* Evidence source for CAUSAL pipelines (the evidence bridge, backlog #5).
|
|
77
|
+
* Called by the write mount's inputMapper at write time; its result lands on
|
|
78
|
+
* `MemoryState.runEvidence` so `writeSnapshot` persists real decisions /
|
|
79
|
+
* tool calls / iterations / duration / token usage instead of zeros. The
|
|
80
|
+
* Agent threads `causalEvidenceRecorder().collect` here automatically when a
|
|
81
|
+
* CAUSAL memory is mounted. Omit for non-causal pipelines.
|
|
82
|
+
*/
|
|
83
|
+
readonly evidenceSource?: () => import('../causal/evidenceRecorder.js').RunEvidence;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Mount only the READ subflow. Appends at the current builder tail, so
|
|
87
|
+
* callers typically invoke this BEFORE their LLM-call stage:
|
|
88
|
+
*
|
|
89
|
+
* let b = flowChart('Seed', seedFn, 'seed');
|
|
90
|
+
* b = mountMemoryRead(b, { pipeline });
|
|
91
|
+
* b = b.addFunction('CallLLM', llmStage, 'call-llm'); // reads memoryInjection
|
|
92
|
+
* b = mountMemoryWrite(b, { pipeline }); // persists newMessages
|
|
93
|
+
*
|
|
94
|
+
* Returns the same builder reference (fluent).
|
|
95
|
+
*/
|
|
96
|
+
export declare function mountMemoryRead<ParentState>(builder: FlowChartBuilder<ParentState>, config: MountMemoryPipelineConfig<ParentState>): FlowChartBuilder<ParentState>;
|
|
97
|
+
/**
|
|
98
|
+
* Mount only the WRITE subflow. No-op when the pipeline has no `write`
|
|
99
|
+
* (e.g., ephemeral pipelines) — returns the builder unchanged.
|
|
100
|
+
*/
|
|
101
|
+
export declare function mountMemoryWrite<ParentState>(builder: FlowChartBuilder<ParentState>, config: MountMemoryPipelineConfig<ParentState>): FlowChartBuilder<ParentState>;
|
|
102
|
+
/**
|
|
103
|
+
* Convenience: mount both read and write subflows back-to-back.
|
|
104
|
+
* Appropriate ONLY when the host flowchart has no stages between memory
|
|
105
|
+
* read and memory write (rare — most agents have the LLM call between).
|
|
106
|
+
* Prefer `mountMemoryRead` + stages + `mountMemoryWrite` for typical agents.
|
|
107
|
+
*/
|
|
108
|
+
export declare function mountMemoryPipeline<ParentState>(builder: FlowChartBuilder<ParentState>, config: MountMemoryPipelineConfig<ParentState>): FlowChartBuilder<ParentState>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* agentfootprint/memory-providers — memory store adapters (canonical subpath).
|
|
3
|
+
*
|
|
4
|
+
* The Block B canonical name. Mirrors the parallel structure shipped in
|
|
5
|
+
* v2.5:
|
|
6
|
+
*
|
|
7
|
+
* agentfootprint/llm-providers ← LLM provider adapters
|
|
8
|
+
* agentfootprint/tool-providers ← tool dispatch + tool sources
|
|
9
|
+
* agentfootprint/memory-providers ← memory store adapters (this file)
|
|
10
|
+
* agentfootprint/security ← cross-cutting authorization
|
|
11
|
+
*
|
|
12
|
+
* One subpath that grows — RedisStore, AgentCoreStore, and future
|
|
13
|
+
* stores (DynamoDB, Postgres, Pinecone, …) all live here. No more
|
|
14
|
+
* adding `agentfootprint/memory-<vendor>` per-adapter subpath each
|
|
15
|
+
* time a new store ships.
|
|
16
|
+
*
|
|
17
|
+
* Per-adapter aliases (`agentfootprint/memory-redis`,
|
|
18
|
+
* `agentfootprint/memory-agentcore`) stay available through the v2.x
|
|
19
|
+
* line — they point at the same files. New code SHOULD import from
|
|
20
|
+
* `agentfootprint/memory-providers`:
|
|
21
|
+
*
|
|
22
|
+
* import { RedisStore, AgentCoreStore } from 'agentfootprint/memory-providers';
|
|
23
|
+
*
|
|
24
|
+
* Pattern: Adapter (GoF) — each store translates the `MemoryStore`
|
|
25
|
+
* interface onto a specific backend (Redis, DynamoDB-style
|
|
26
|
+
* AWS Bedrock AgentCore Memory, etc.).
|
|
27
|
+
* Role: Outer ring (Hexagonal). All store adapters lazy-require
|
|
28
|
+
* their vendor SDKs at construction time, so importing this
|
|
29
|
+
* barrel costs ZERO peer-dep load — only the stores you
|
|
30
|
+
* actually instantiate pull their SDK in.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* import { RedisStore, AgentCoreStore } from 'agentfootprint/memory-providers';
|
|
34
|
+
*/
|
|
35
|
+
export { RedisStore, type RedisStoreOptions, type RedisLikeClient, type RedisLikePipeline, } from './adapters/memory/redis.js';
|
|
36
|
+
export { AgentCoreStore, type AgentCoreStoreOptions, type AgentCoreLikeClient, } from './adapters/memory/agentcore.js';
|
|
37
|
+
export { BedrockAgentMemory, type BedrockAgentMemoryOptions, type BedrockAgentMemoryLikeClient, type BedrockAgentSummary, } from './adapters/memory/bedrockAgentMemory.js';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* compareFinders — run several finders on the same case and collect their answers
|
|
3
|
+
* side by side (a leaderboard row per finder). PARAMETRIC: you pass the finders to
|
|
4
|
+
* compare, so nothing is auto-discovered or retained — unused finders stay
|
|
5
|
+
* tree-shakeable.
|
|
6
|
+
*/
|
|
7
|
+
import type { Finder, FindInput, FindResult } from './types.js';
|
|
8
|
+
/** One finder's result in a comparison (or the error it threw). */
|
|
9
|
+
export interface CompareRow {
|
|
10
|
+
readonly finder: string;
|
|
11
|
+
readonly result: FindResult | null;
|
|
12
|
+
readonly error?: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Run each finder on `input`; a finder that throws (e.g. missing a dep it needs)
|
|
16
|
+
* becomes a row with `result: null` and `error` set, so one finder cannot abort
|
|
17
|
+
* the comparison.
|
|
18
|
+
*/
|
|
19
|
+
export declare function compareFinders(finders: readonly Finder[], input: FindInput): Promise<CompareRow[]>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* observability / contextError / finders — pluggable context-bug localization.
|
|
3
|
+
*
|
|
4
|
+
* "Which piece of context made the agent's answer wrong?" Pick a finder and call
|
|
5
|
+
* `find(input)`. Each finder is a thin, self-explaining adapter over the engines in
|
|
6
|
+
* `src/lib/context-bisect` + `src/lib/influence-core`; the academic method + citation
|
|
7
|
+
* live in `meta`, never in the import name.
|
|
8
|
+
*
|
|
9
|
+
* import { rankSuspects } from 'agentfootprint/observability/contextError/finders';
|
|
10
|
+
* const r = await rankSuspects.find(input); // r.lead, r.evidence ('guessed'|'proven')
|
|
11
|
+
*
|
|
12
|
+
* Tree-shakeable: one finder = one file = one named export. Importing one finder does
|
|
13
|
+
* not pull the others (or the heavy ablation path behind removeAndRetry). This barrel
|
|
14
|
+
* is re-export-only — no runtime code, no registry.
|
|
15
|
+
*/
|
|
16
|
+
export type { ContextPiece, Evidence, Finder, FinderMeta, FindInput, FindResult, Granularity, ScoredSuspect, StepInput, } from './types.js';
|
|
17
|
+
export { rankSuspects } from './rankSuspects.js';
|
|
18
|
+
export { removeAndRetry } from './removeAndRetry.js';
|
|
19
|
+
export { traceSteps } from './traceSteps.js';
|
|
20
|
+
export { testManyCombos } from './testManyCombos.js';
|
|
21
|
+
export { shrinkToCause } from './shrinkToCause.js';
|
|
22
|
+
export { compareFinders, type CompareRow } from './compareFinders.js';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* removeAndRetry — the thorough finder. Removes each context piece, re-runs the
|
|
3
|
+
* agent, and a piece is the cause iff its removal flips the outcome back. No
|
|
4
|
+
* embedder, no heuristic: pure counterfactual. Exact, but pays one re-run per
|
|
5
|
+
* piece (`checks`), and on multi-loop runs it can over-attribute (several pieces
|
|
6
|
+
* each flip) — narrow with a slice first when that happens.
|
|
7
|
+
*
|
|
8
|
+
* Method: leave-one-out ablation (counterfactual necessity).
|
|
9
|
+
*/
|
|
10
|
+
import type { Finder } from './types.js';
|
|
11
|
+
export declare const removeAndRetry: Finder;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* shrinkToCause — keeps cutting the suspect set down until the smallest subset whose
|
|
3
|
+
* removal still fixes the answer. For a single dominant cause it converges in fewer
|
|
4
|
+
* re-runs than leave-one-out (delta-debugging minimization); for co-necessary causes it
|
|
5
|
+
* still returns the minimal recovering set, but may cost more probes than leave-one-out.
|
|
6
|
+
* The returned set is verified to recover by construction.
|
|
7
|
+
*
|
|
8
|
+
* Method: delta-debugging minimization (ddmin) over the removal set that recovers.
|
|
9
|
+
*/
|
|
10
|
+
import type { Finder } from './types.js';
|
|
11
|
+
export declare const shrinkToCause: Finder;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* testManyCombos — turns context pieces on and off in many combinations, re-runs each,
|
|
3
|
+
* and learns which pieces drive the wrong answer (a linear-surrogate attribution), then
|
|
4
|
+
* confirms the top candidate with one clean ablation. The sampling one: it estimates an
|
|
5
|
+
* influence weight per piece from counterfactual data rather than ranking by similarity.
|
|
6
|
+
*
|
|
7
|
+
* Method: random-subset ablation + linear-surrogate attribution. Deterministic
|
|
8
|
+
* pseudo-random masking (a reproducible reimplementation of ContextCite's random subsets).
|
|
9
|
+
*/
|
|
10
|
+
import type { Finder } from './types.js';
|
|
11
|
+
export declare const testManyCombos: Finder;
|