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.
- package/ai-instructions/setup.sh +0 -0
- 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/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/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/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/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/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/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/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/package.json +203 -56
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import type { MemoryIdentity } from '../identity/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* MemoryEntry — a single stored item with decay-, version-, and source-aware
|
|
4
|
+
* metadata.
|
|
5
|
+
*
|
|
6
|
+
* Entry shape is generic over `T` so stores can hold messages, facts,
|
|
7
|
+
* narrative traces, or anything else JSON-serializable. The metadata fields
|
|
8
|
+
* around `value` are what make entries first-class objects instead of raw
|
|
9
|
+
* blobs:
|
|
10
|
+
*
|
|
11
|
+
* - `version` — optimistic concurrency (`putIfVersion`) + migration
|
|
12
|
+
* - `tier` — MemGPT-style hot/warm/cold classification
|
|
13
|
+
* - `source` — provenance — "where did this memory come from?"
|
|
14
|
+
* - `lastAccessedAt` / `accessCount` — decay signals
|
|
15
|
+
* - `ttl` — absolute expiry at the storage layer
|
|
16
|
+
* - `embeddingModel`— compatibility check for semantic search
|
|
17
|
+
*
|
|
18
|
+
* Entries are **immutable in spirit** — a "mutation" is a new entry with the
|
|
19
|
+
* same `id` and an incremented `version`. Storage adapters may implement
|
|
20
|
+
* this as an in-place update or an append-only log, but the library treats
|
|
21
|
+
* entries as values.
|
|
22
|
+
*
|
|
23
|
+
* NOTE: `readonly` modifiers are a TypeScript compile-time hint only. At
|
|
24
|
+
* runtime, nothing prevents a consumer from mutating an entry they received.
|
|
25
|
+
* The library's internal code never mutates entries; adapters that wish to
|
|
26
|
+
* enforce this at runtime may `Object.freeze(entry)` before returning.
|
|
27
|
+
*/
|
|
28
|
+
export interface MemoryEntry<T = unknown> {
|
|
29
|
+
/** Stable id within the identity namespace. */
|
|
30
|
+
readonly id: string;
|
|
31
|
+
/** The actual stored payload. JSON-serializable. */
|
|
32
|
+
readonly value: T;
|
|
33
|
+
/**
|
|
34
|
+
* Free-form metadata — tags, labels, user-supplied annotations. Kept
|
|
35
|
+
* separate from the decay / version fields so those stay typed.
|
|
36
|
+
*/
|
|
37
|
+
readonly metadata?: Record<string, unknown>;
|
|
38
|
+
/**
|
|
39
|
+
* Monotonic version number. Stores use this for `putIfVersion` optimistic
|
|
40
|
+
* concurrency — write only if the entry is still at the version the
|
|
41
|
+
* writer expected. Defaults to 1 on first write; callers increment.
|
|
42
|
+
*/
|
|
43
|
+
readonly version: number;
|
|
44
|
+
/** Unix ms. */
|
|
45
|
+
readonly createdAt: number;
|
|
46
|
+
/** Unix ms. Equal to createdAt on first write. */
|
|
47
|
+
readonly updatedAt: number;
|
|
48
|
+
/** Unix ms. Updated by `store.get` / retrieval stages. Decay input. */
|
|
49
|
+
readonly lastAccessedAt: number;
|
|
50
|
+
/** Number of times this entry has been read. Decay input. */
|
|
51
|
+
readonly accessCount: number;
|
|
52
|
+
/**
|
|
53
|
+
* Optional absolute expiry (unix ms). Storage adapters MUST refuse to
|
|
54
|
+
* return entries past their ttl. Implementations: InMemory filters on
|
|
55
|
+
* read, Redis uses native EXPIRE, DynamoDB uses TTL attribute.
|
|
56
|
+
*/
|
|
57
|
+
readonly ttl?: number;
|
|
58
|
+
/**
|
|
59
|
+
* Optional decay policy applied at retrieval time. When present, stages
|
|
60
|
+
* that rank entries (picker, reranker) decrease relevance for entries
|
|
61
|
+
* whose `lastAccessedAt` is far in the past. See `decay.ts`.
|
|
62
|
+
*/
|
|
63
|
+
readonly decayPolicy?: DecayPolicy;
|
|
64
|
+
/**
|
|
65
|
+
* Tier classification — enables MemGPT-style page-in/page-out policies.
|
|
66
|
+
* Stages can filter by tier (e.g. "load hot entries first, consult cold
|
|
67
|
+
* only under pressure"). Omitting the field means "untiered."
|
|
68
|
+
*/
|
|
69
|
+
readonly tier?: 'hot' | 'warm' | 'cold';
|
|
70
|
+
/**
|
|
71
|
+
* Provenance — which turn / runtime stage / message produced this entry.
|
|
72
|
+
* Lets retrieval cite sources ("remembered from turn 5") and lets
|
|
73
|
+
* `causalChain` cross session boundaries.
|
|
74
|
+
*/
|
|
75
|
+
readonly source?: MemorySource;
|
|
76
|
+
/**
|
|
77
|
+
* Optional dense vector embedding of this entry's value. Populated
|
|
78
|
+
* by semantic-memory pipelines (see `embedMessages` / `embedBeats`
|
|
79
|
+
* stages) when an `Embedder` is configured. Stores that support
|
|
80
|
+
* vector search index on this field; stores that don't ignore it.
|
|
81
|
+
*
|
|
82
|
+
* Vector length MUST match the configured embedder's `dimensions`.
|
|
83
|
+
* Mixing embedders of different sizes within the same identity
|
|
84
|
+
* namespace will break cosine similarity — `store.search()` uses
|
|
85
|
+
* `cosineSimilarity()` which throws on length mismatch.
|
|
86
|
+
*/
|
|
87
|
+
readonly embedding?: readonly number[];
|
|
88
|
+
/**
|
|
89
|
+
* Identifier of the embedder that produced `embedding`. Search
|
|
90
|
+
* stages compare this against the active embedder's id before
|
|
91
|
+
* trusting distance scores — prevents silent retrieval corruption
|
|
92
|
+
* when an embedding model is swapped but old entries are still
|
|
93
|
+
* indexed with the previous vector space.
|
|
94
|
+
*/
|
|
95
|
+
readonly embeddingModel?: string;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Where a memory entry came from. The library populates this automatically
|
|
99
|
+
* when entries are written from inside a memory stage (writeMessages,
|
|
100
|
+
* extractFacts, etc.); consumers can populate it when writing programmatically.
|
|
101
|
+
*
|
|
102
|
+
* When searching across sessions ("did we learn this in a previous session?"),
|
|
103
|
+
* `identity` + `turn` + `runtimeStageId` form a globally-unique causal coordinate
|
|
104
|
+
* — you can replay exactly what the agent was doing when the entry was born.
|
|
105
|
+
*/
|
|
106
|
+
export interface MemorySource {
|
|
107
|
+
/** Run-local turn counter. */
|
|
108
|
+
readonly turn?: number;
|
|
109
|
+
/** footprintjs runtime stage id (`stageId#executionIndex`). */
|
|
110
|
+
readonly runtimeStageId?: string;
|
|
111
|
+
/** Originating message id, if the entry came from a conversation turn. */
|
|
112
|
+
readonly messageId?: string;
|
|
113
|
+
/**
|
|
114
|
+
* Cross-session provenance — the `MemoryIdentity` that produced this entry.
|
|
115
|
+
* Lets retrieval stages show "remembered from session X, user Y, turn 5"
|
|
116
|
+
* instead of anonymous citation. Storage adapters MUST preserve this field
|
|
117
|
+
* verbatim on every read/write.
|
|
118
|
+
*/
|
|
119
|
+
readonly identity?: MemoryIdentity;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Natural-forgetting policy. Decay applies at retrieval time: the entry's
|
|
123
|
+
* stored value is never mutated; only its computed "relevance" is adjusted.
|
|
124
|
+
*
|
|
125
|
+
* Consumers choose half-life + access boost to match their domain:
|
|
126
|
+
* - Fast-moving (news, tickets) — halfLifeMs ≈ 1 day, accessBoost ≈ 1.5
|
|
127
|
+
* - Stable (user profile, facts)— halfLifeMs ≈ 30 days, accessBoost ≈ 1.1
|
|
128
|
+
*/
|
|
129
|
+
export interface DecayPolicy {
|
|
130
|
+
/**
|
|
131
|
+
* How long for relevance to halve when never accessed. Milliseconds.
|
|
132
|
+
*/
|
|
133
|
+
readonly halfLifeMs: number;
|
|
134
|
+
/**
|
|
135
|
+
* Multiplier applied per access (clamped to a reasonable ceiling inside
|
|
136
|
+
* `applyDecay`). Values > 1.0 boost frequently-used entries; values in
|
|
137
|
+
* (0, 1.0) would *reduce* relevance with use (rarely desired).
|
|
138
|
+
*/
|
|
139
|
+
readonly accessBoost: number;
|
|
140
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* extractFacts — write-side stage that distills `scope.newMessages` into
|
|
3
|
+
* `Fact`s via a pluggable `FactExtractor`.
|
|
4
|
+
*
|
|
5
|
+
* Reads from scope: `newMessages`, `turnNumber`, optional `loadedFacts`
|
|
6
|
+
* Writes to scope: `newFacts` (MemoryEntry<Fact>[], ready for writeFacts)
|
|
7
|
+
*
|
|
8
|
+
* The extractor is called ONCE per turn on the turn's new messages. If
|
|
9
|
+
* `scope.loadedFacts` is populated (the write subflow ran `loadFacts`
|
|
10
|
+
* first), existing facts are passed to the extractor so LLM-based
|
|
11
|
+
* extractors can update rather than duplicate.
|
|
12
|
+
*
|
|
13
|
+
* **Stable ids**: each produced entry gets id `fact:${fact.key}`. When
|
|
14
|
+
* the same key is written again in a future turn, the storage layer
|
|
15
|
+
* overwrites in place — no duplicate accumulation. This is the core
|
|
16
|
+
* property that makes facts different from beats (append-only) and
|
|
17
|
+
* messages (append-only).
|
|
18
|
+
*
|
|
19
|
+
* Empty-extraction behavior: `newFacts = []`. Downstream `writeFacts`
|
|
20
|
+
* short-circuits on empty — no store round-trip.
|
|
21
|
+
*/
|
|
22
|
+
import type { TypedScope } from 'footprintjs';
|
|
23
|
+
import type { MemoryEntry } from '../entry/index.js';
|
|
24
|
+
import type { MemoryState } from '../stages/index.js';
|
|
25
|
+
import type { FactExtractor } from './extractor.js';
|
|
26
|
+
import type { Fact } from './types.js';
|
|
27
|
+
export interface ExtractFactsConfig {
|
|
28
|
+
/** The extractor to call. See `patternFactExtractor` / `llmFactExtractor`. */
|
|
29
|
+
readonly extractor: FactExtractor;
|
|
30
|
+
/**
|
|
31
|
+
* Optional tier for the persisted facts. Typical pattern: `'hot'` for
|
|
32
|
+
* current identity / preferences, `'warm'` for older commitments.
|
|
33
|
+
* Omit for no tier.
|
|
34
|
+
*/
|
|
35
|
+
readonly tier?: 'hot' | 'warm' | 'cold';
|
|
36
|
+
/**
|
|
37
|
+
* Optional TTL in ms from `Date.now()` applied to persisted fact
|
|
38
|
+
* entries. Useful for facts that should decay (task statuses,
|
|
39
|
+
* short-term preferences). Identity facts typically have no TTL.
|
|
40
|
+
*/
|
|
41
|
+
readonly ttlMs?: number;
|
|
42
|
+
}
|
|
43
|
+
/** State added to `MemoryState` by the fact pipeline stages. */
|
|
44
|
+
export interface FactPipelineState extends MemoryState {
|
|
45
|
+
/** Produced by `extractFacts`, consumed by `writeFacts`. */
|
|
46
|
+
newFacts?: readonly MemoryEntry<Fact>[];
|
|
47
|
+
/** Produced by `loadFacts`, consumed by `formatFacts` and `extractFacts`. */
|
|
48
|
+
loadedFacts?: readonly MemoryEntry<Fact>[];
|
|
49
|
+
}
|
|
50
|
+
export declare function extractFacts(config: ExtractFactsConfig): (scope: TypedScope<FactPipelineState>) => Promise<void>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FactExtractor — interface for distilling stable claims out of a turn.
|
|
3
|
+
*
|
|
4
|
+
* Complements `BeatExtractor`: a beat summarizes what happened, a
|
|
5
|
+
* fact captures what's *currently true*. Different extractors produce
|
|
6
|
+
* different levels of structure (pattern-based for quick identity /
|
|
7
|
+
* contact info; LLM-based for rich open-ended extraction).
|
|
8
|
+
*
|
|
9
|
+
* Built-in extractors:
|
|
10
|
+
* - `patternFactExtractor()` — zero-dep regex heuristics for
|
|
11
|
+
* common identity / location / contact patterns.
|
|
12
|
+
* - `llmFactExtractor({ provider })` — one LLM call per turn for
|
|
13
|
+
* open-ended extraction. Opt-in.
|
|
14
|
+
*/
|
|
15
|
+
import type { LLMMessage as Message } from '../../adapters/types.js';
|
|
16
|
+
import type { Fact } from './types.js';
|
|
17
|
+
export interface FactExtractArgs {
|
|
18
|
+
/** New-turn messages. */
|
|
19
|
+
readonly messages: readonly Message[];
|
|
20
|
+
/** Current turn number. Useful for extractors that want it in a source tag. */
|
|
21
|
+
readonly turnNumber: number;
|
|
22
|
+
/**
|
|
23
|
+
* Facts already in the store (if caller has a cheap way to fetch).
|
|
24
|
+
* Passed to extractors that merge / dedupe at extraction time.
|
|
25
|
+
* May be empty even when facts exist — not every pipeline pre-loads.
|
|
26
|
+
*/
|
|
27
|
+
readonly existing?: readonly Fact[];
|
|
28
|
+
/** Optional abort signal for LLM-based extractors. */
|
|
29
|
+
readonly signal?: AbortSignal;
|
|
30
|
+
}
|
|
31
|
+
export interface FactExtractor {
|
|
32
|
+
extract(args: FactExtractArgs): Promise<readonly Fact[]>;
|
|
33
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* formatFacts — render loaded `Fact` entries into a single system
|
|
3
|
+
* message for prompt injection.
|
|
4
|
+
*
|
|
5
|
+
* Reads from scope: `loadedFacts`
|
|
6
|
+
* Writes to scope: `formatted` (Message[] — one system message, or empty)
|
|
7
|
+
*
|
|
8
|
+
* Facts are tiny and semantically distinct from beats/messages, so they
|
|
9
|
+
* render as a compact key/value block rather than a narrative paragraph
|
|
10
|
+
* or per-entry `<memory>` tags. The default shape:
|
|
11
|
+
*
|
|
12
|
+
* Known facts about the user:
|
|
13
|
+
*
|
|
14
|
+
* - user.name: Alice
|
|
15
|
+
* - user.email: alice@example.com
|
|
16
|
+
* - user.preferences.color: blue
|
|
17
|
+
*
|
|
18
|
+
* Why one block, not one message per fact?
|
|
19
|
+
* LLMs parse key/value lists efficiently; splitting would waste
|
|
20
|
+
* tokens on per-message system overhead and break up the list's
|
|
21
|
+
* visual grouping.
|
|
22
|
+
*
|
|
23
|
+
* Why NOT run facts through `pickByBudget`?
|
|
24
|
+
* Facts are typically 10-50 items, each a handful of tokens. Picking
|
|
25
|
+
* subsets is rarely useful — the user either knows your name or
|
|
26
|
+
* they don't. Consumers who *do* want budget-based fact pruning can
|
|
27
|
+
* copy-paste this stage and wrap it with a picker.
|
|
28
|
+
*/
|
|
29
|
+
import type { TypedScope } from 'footprintjs';
|
|
30
|
+
import type { MemoryEntry } from '../entry/index.js';
|
|
31
|
+
import type { Fact } from './types.js';
|
|
32
|
+
import type { FactPipelineState } from './extractFacts.js';
|
|
33
|
+
export interface FormatFactsConfig {
|
|
34
|
+
/**
|
|
35
|
+
* Header prepended to the injected message. Explains to the LLM what
|
|
36
|
+
* follows and what it's for. Override if your app has specific
|
|
37
|
+
* phrasing guidance.
|
|
38
|
+
*/
|
|
39
|
+
readonly header?: string;
|
|
40
|
+
/** Footer appended after the fact list. Empty by default. */
|
|
41
|
+
readonly footer?: string;
|
|
42
|
+
/**
|
|
43
|
+
* When `true`, appends `(conf 0.xx)` after each fact's value. Off by
|
|
44
|
+
* default — confidence is usually noise for the LLM and only useful
|
|
45
|
+
* in audit / debug flows.
|
|
46
|
+
*/
|
|
47
|
+
readonly showConfidence?: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Custom per-fact renderer. Receives the entry; returns the block
|
|
50
|
+
* string (without the leading `- ` bullet). Use for app-specific
|
|
51
|
+
* formatting: custom attribution, hiding category info, etc.
|
|
52
|
+
*/
|
|
53
|
+
readonly renderFact?: (entry: MemoryEntry<Fact>) => string;
|
|
54
|
+
/**
|
|
55
|
+
* Inject the message even when `loadedFacts` is empty. Usually
|
|
56
|
+
* undesired — an empty list is noise. Off by default.
|
|
57
|
+
*/
|
|
58
|
+
readonly emitWhenEmpty?: boolean;
|
|
59
|
+
}
|
|
60
|
+
export declare function formatFacts(config?: FormatFactsConfig): (scope: TypedScope<FactPipelineState>) => Promise<void>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type { Fact } from './types.js';
|
|
2
|
+
export { factId, isFactId, isFact, asConfidence } from './types.js';
|
|
3
|
+
export type { FactExtractor, FactExtractArgs } from './extractor.js';
|
|
4
|
+
export { patternFactExtractor } from './patternFactExtractor.js';
|
|
5
|
+
export { llmFactExtractor } from './llmFactExtractor.js';
|
|
6
|
+
export type { LLMFactExtractorConfig } from './llmFactExtractor.js';
|
|
7
|
+
export { extractFacts } from './extractFacts.js';
|
|
8
|
+
export type { ExtractFactsConfig, FactPipelineState } from './extractFacts.js';
|
|
9
|
+
export { writeFacts } from './writeFacts.js';
|
|
10
|
+
export type { WriteFactsConfig } from './writeFacts.js';
|
|
11
|
+
export { loadFacts } from './loadFacts.js';
|
|
12
|
+
export type { LoadFactsConfig } from './loadFacts.js';
|
|
13
|
+
export { formatFacts } from './formatFacts.js';
|
|
14
|
+
export type { FormatFactsConfig } from './formatFacts.js';
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* llmFactExtractor — LLM-backed fact extractor.
|
|
3
|
+
*
|
|
4
|
+
* Uses an LLMProvider (typically a cheap model like Claude Haiku or
|
|
5
|
+
* GPT-4o-mini) to pull stable, timeless claims out of a conversation
|
|
6
|
+
* turn. Complements `patternFactExtractor` — regex catches the obvious
|
|
7
|
+
* self-disclosures, the LLM catches the open-ended ones.
|
|
8
|
+
*
|
|
9
|
+
* The extractor asks the LLM for a JSON response in this shape:
|
|
10
|
+
*
|
|
11
|
+
* ```json
|
|
12
|
+
* {
|
|
13
|
+
* "facts": [
|
|
14
|
+
* {
|
|
15
|
+
* "key": "user.name",
|
|
16
|
+
* "value": "Alice",
|
|
17
|
+
* "confidence": 0.95,
|
|
18
|
+
* "category": "identity",
|
|
19
|
+
* "refs": ["msg-1-0"]
|
|
20
|
+
* }
|
|
21
|
+
* ]
|
|
22
|
+
* }
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* The extractor parses, clamps confidence via `asConfidence()`, dedups
|
|
26
|
+
* by `key` (last occurrence wins, matching `patternFactExtractor`),
|
|
27
|
+
* and returns the facts. Malformed responses fall back to `[]` — a bad
|
|
28
|
+
* extraction should not break the agent turn.
|
|
29
|
+
*
|
|
30
|
+
* Usage:
|
|
31
|
+
* ```ts
|
|
32
|
+
* import { anthropic } from 'agentfootprint';
|
|
33
|
+
* import { llmFactExtractor, factPipeline, InMemoryStore } from 'agentfootprint/memory';
|
|
34
|
+
*
|
|
35
|
+
* const pipeline = factPipeline({
|
|
36
|
+
* store: new InMemoryStore(),
|
|
37
|
+
* extractor: llmFactExtractor({ provider: yourLLMProvider }),
|
|
38
|
+
* });
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
import type { LLMProvider } from '../../adapters/types.js';
|
|
42
|
+
import type { FactExtractor } from './extractor.js';
|
|
43
|
+
export interface LLMFactExtractorConfig {
|
|
44
|
+
/** The provider used for extraction. Typically a cheap/fast model. */
|
|
45
|
+
readonly provider: LLMProvider;
|
|
46
|
+
/**
|
|
47
|
+
* Override the system prompt. Defaults to a one-paragraph instruction
|
|
48
|
+
* that elicits the JSON shape described in the module docs.
|
|
49
|
+
*/
|
|
50
|
+
readonly systemPrompt?: string;
|
|
51
|
+
/**
|
|
52
|
+
* Dev-mode logger invoked when the LLM response fails to parse.
|
|
53
|
+
* Defaults to `console.warn` — production consumers can route the
|
|
54
|
+
* signal to their telemetry pipeline.
|
|
55
|
+
*/
|
|
56
|
+
readonly onParseError?: (error: unknown, rawContent: string) => void;
|
|
57
|
+
/**
|
|
58
|
+
* Include up to this many existing facts in the user prompt so the
|
|
59
|
+
* model can update / refine rather than duplicate. Set to `0` to
|
|
60
|
+
* skip — cheaper but loses update awareness. Default `16`.
|
|
61
|
+
*/
|
|
62
|
+
readonly includeExistingLimit?: number;
|
|
63
|
+
}
|
|
64
|
+
export declare function llmFactExtractor(config: LLMFactExtractorConfig): FactExtractor;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* loadFacts — read-side stage that loads stored `Fact` entries into
|
|
3
|
+
* `scope.loadedFacts`.
|
|
4
|
+
*
|
|
5
|
+
* Reads from scope: `identity`
|
|
6
|
+
* Writes to scope: `loadedFacts` (appends — does not replace)
|
|
7
|
+
*
|
|
8
|
+
* Unlike `loadRecent` (which returns ALL entries and lets downstream
|
|
9
|
+
* stages filter), `loadFacts` queries the store and keeps only entries
|
|
10
|
+
* whose id matches the `fact:` prefix. Facts are typically few dozen
|
|
11
|
+
* at most per identity — a linear scan after a bounded `list` call is
|
|
12
|
+
* cheap.
|
|
13
|
+
*
|
|
14
|
+
* Why append, not replace?
|
|
15
|
+
* Same contract as `loadRecent` — pipelines may combine multiple
|
|
16
|
+
* load stages (e.g. facts + recent messages + beats). Appending lets
|
|
17
|
+
* each contribute without coordination.
|
|
18
|
+
*
|
|
19
|
+
* Note: this stage writes `loadedFacts` (a separate field from
|
|
20
|
+
* `loaded`) because fact entries have a different payload type
|
|
21
|
+
* (`MemoryEntry<Fact>`) than message entries (`MemoryEntry<Message>`).
|
|
22
|
+
* Keeping them separate prevents format stages from misrouting entries.
|
|
23
|
+
*/
|
|
24
|
+
import type { TypedScope } from 'footprintjs';
|
|
25
|
+
import type { MemoryStore } from '../store/index.js';
|
|
26
|
+
import type { FactPipelineState } from './extractFacts.js';
|
|
27
|
+
export interface LoadFactsConfig {
|
|
28
|
+
/** The store to read from. */
|
|
29
|
+
readonly store: MemoryStore;
|
|
30
|
+
/**
|
|
31
|
+
* Upper bound on the `list` call's page size. Adapters may cap this
|
|
32
|
+
* lower. Defaults to 100 — enough for typical identity/preference
|
|
33
|
+
* inventories. Fact pipelines that accumulate task statuses or
|
|
34
|
+
* commitments should raise this.
|
|
35
|
+
*/
|
|
36
|
+
readonly limit?: number;
|
|
37
|
+
/**
|
|
38
|
+
* Optional tier filter. When set, only loads facts tagged with one
|
|
39
|
+
* of these tiers. Matches the `loadRecent` / `loadRelevant` API.
|
|
40
|
+
*/
|
|
41
|
+
readonly tiers?: ReadonlyArray<'hot' | 'warm' | 'cold'>;
|
|
42
|
+
}
|
|
43
|
+
export declare function loadFacts(config: LoadFactsConfig): (scope: TypedScope<FactPipelineState>) => Promise<void>;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Facts — stable, timeless claims about the user or world.
|
|
3
|
+
*
|
|
4
|
+
* Unlike beats (which summarize what happened in a turn) and messages
|
|
5
|
+
* (which are the raw conversation), facts capture *what's currently
|
|
6
|
+
* true*:
|
|
7
|
+
* - Identity: "user.name" = "Alice"
|
|
8
|
+
* - Preferences: "user.favorite_color" = "blue"
|
|
9
|
+
* - Commitments: "task.ORD-123.status" = "refunded"
|
|
10
|
+
*
|
|
11
|
+
* Facts dedupe by `key`. The storage layer uses stable ids of the form
|
|
12
|
+
* `fact:${key}`, so a second write to the same key overwrites the
|
|
13
|
+
* first. This is the difference from beats/messages (which are
|
|
14
|
+
* append-only log entries).
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* A single fact — a key/value claim with optional confidence +
|
|
18
|
+
* category metadata.
|
|
19
|
+
*
|
|
20
|
+
* **Key convention**: dotted path for nested taxonomies
|
|
21
|
+
* (`user.name`, `user.preferences.color`, `task.ORD-123.status`).
|
|
22
|
+
* The library doesn't enforce any structure — extractors define their
|
|
23
|
+
* own key namespaces.
|
|
24
|
+
*/
|
|
25
|
+
export interface Fact<V = unknown> {
|
|
26
|
+
/** Stable key — used to dedupe. */
|
|
27
|
+
readonly key: string;
|
|
28
|
+
/** The claimed value. JSON-serializable. */
|
|
29
|
+
readonly value: V;
|
|
30
|
+
/**
|
|
31
|
+
* Extractor's confidence in `[0, 1]`. Used by `pickByBudget` to
|
|
32
|
+
* prefer high-confidence facts when the budget is tight. Optional
|
|
33
|
+
* — extractors that can't estimate confidence may omit it, in
|
|
34
|
+
* which case consumers default to a neutral 0.5.
|
|
35
|
+
*/
|
|
36
|
+
readonly confidence?: number;
|
|
37
|
+
/**
|
|
38
|
+
* Optional taxonomy tag — free-form string like `"identity"`,
|
|
39
|
+
* `"preference"`, `"commitment"`, `"fact"`. Useful for filtering
|
|
40
|
+
* recall by category.
|
|
41
|
+
*/
|
|
42
|
+
readonly category?: string;
|
|
43
|
+
/**
|
|
44
|
+
* Ids of the source messages this fact was extracted from. Mirrors
|
|
45
|
+
* `NarrativeBeat.refs` — consumers answer "why does the agent think
|
|
46
|
+
* `user.name` is Alice?" by walking back to the raw message text.
|
|
47
|
+
* Optional because some extractors (pattern-based, aggregate) can't
|
|
48
|
+
* reliably trace a fact to a specific message. LLM-based extractors
|
|
49
|
+
* should populate it.
|
|
50
|
+
*/
|
|
51
|
+
readonly refs?: readonly string[];
|
|
52
|
+
}
|
|
53
|
+
/** Build the stable `MemoryStore` id for a fact with the given key. */
|
|
54
|
+
export declare function factId(key: string): string;
|
|
55
|
+
/** True iff the string is a fact id (starts with the `fact:` prefix). */
|
|
56
|
+
export declare function isFactId(id: string): boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Duck-typed guard — true iff `value` has the shape of a `Fact`.
|
|
59
|
+
* Used by pipelines that handle mixed-payload stores (facts +
|
|
60
|
+
* beats + raw messages) to route entries correctly.
|
|
61
|
+
*/
|
|
62
|
+
export declare function isFact(value: unknown): value is Fact;
|
|
63
|
+
/**
|
|
64
|
+
* Clamp a value to `[0, 1]`; non-finite → 0.5 (neutral). Matches the
|
|
65
|
+
* `asImportance` convention in the beats layer so pickers can treat
|
|
66
|
+
* `confidence` and `importance` the same way.
|
|
67
|
+
*/
|
|
68
|
+
export declare function asConfidence(value: unknown): number;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* writeFacts — persist extracted facts to the memory store.
|
|
3
|
+
*
|
|
4
|
+
* Reads from scope: `newFacts`, `identity`
|
|
5
|
+
* Writes to store: MemoryEntry<Fact> per fact via `store.putMany`
|
|
6
|
+
*
|
|
7
|
+
* Ids are `fact:${key}` (set by `extractFacts` via `factId`). Because
|
|
8
|
+
* `putMany` overwrites on id collision, a second turn writing the same
|
|
9
|
+
* key REPLACES the prior entry. This is the contract for facts — they
|
|
10
|
+
* dedup by key, unlike beats and messages which are append-only.
|
|
11
|
+
*/
|
|
12
|
+
import type { TypedScope } from 'footprintjs';
|
|
13
|
+
import type { MemoryStore } from '../store/index.js';
|
|
14
|
+
import type { FactPipelineState } from './extractFacts.js';
|
|
15
|
+
export interface WriteFactsConfig {
|
|
16
|
+
/** The store to persist to. Typically the same store as the pipeline's read side. */
|
|
17
|
+
readonly store: MemoryStore;
|
|
18
|
+
}
|
|
19
|
+
export declare function writeFacts(config: WriteFactsConfig): (scope: TypedScope<FactPipelineState>) => Promise<void>;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MemoryIdentity — hierarchical scoping for everything memory-related.
|
|
3
|
+
*
|
|
4
|
+
* The library enforces isolation at every storage call: no cross-tenant
|
|
5
|
+
* reads, no cross-principal writes, period. Enterprise deploys (Azure Entra,
|
|
6
|
+
* AWS SSO, etc.) surface tenant + principal from the incoming request;
|
|
7
|
+
* simpler deploys just use `conversationId`.
|
|
8
|
+
*
|
|
9
|
+
* Why three fields instead of one "key"?
|
|
10
|
+
* - `tenant` — organization / workspace / account boundary
|
|
11
|
+
* - `principal` — user / service-account identity within the tenant
|
|
12
|
+
* - `conversationId` — a single thread / session for that principal
|
|
13
|
+
*
|
|
14
|
+
* Storage adapters prefix namespaces with the full identity tuple. A bug in
|
|
15
|
+
* a multi-tenant app that passes the wrong `tenant` can't accidentally read
|
|
16
|
+
* another customer's memory — the tuple mismatch surfaces as "no data"
|
|
17
|
+
* rather than a silent leak.
|
|
18
|
+
*
|
|
19
|
+
* Fields after `conversationId` are reserved for future expansion (agent id,
|
|
20
|
+
* role, etc.) without breaking existing stores.
|
|
21
|
+
*/
|
|
22
|
+
export interface MemoryIdentity {
|
|
23
|
+
/**
|
|
24
|
+
* Optional organization / workspace / account boundary. Omit for
|
|
25
|
+
* single-tenant deploys. Storage adapters MUST refuse cross-tenant reads
|
|
26
|
+
* when this field is set.
|
|
27
|
+
*/
|
|
28
|
+
readonly tenant?: string;
|
|
29
|
+
/**
|
|
30
|
+
* Optional user / service-account identity within the tenant. Isolates
|
|
31
|
+
* memory per end-user inside a shared tenant.
|
|
32
|
+
*/
|
|
33
|
+
readonly principal?: string;
|
|
34
|
+
/**
|
|
35
|
+
* Required — the conversation / session / thread id. Stable across
|
|
36
|
+
* multiple `agent.run()` calls so history accumulates correctly.
|
|
37
|
+
*/
|
|
38
|
+
readonly conversationId: string;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Encode a MemoryIdentity as a deterministic storage namespace. Used by
|
|
42
|
+
* storage adapters that need a single string key (Redis, localStorage,
|
|
43
|
+
* filesystem paths). Format is stable across library versions — adapters
|
|
44
|
+
* can safely use it for long-lived keys.
|
|
45
|
+
*
|
|
46
|
+
* Empty `tenant` / `principal` collapse to `_` so the format has a constant
|
|
47
|
+
* shape (easy to parse, easy to list by prefix).
|
|
48
|
+
*/
|
|
49
|
+
export declare function identityNamespace(identity: MemoryIdentity): string;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Memory subsystem — narrative beats, fact extraction, embedding-based
|
|
3
|
+
* retrieval, and pipelines that compose them.
|
|
4
|
+
*
|
|
5
|
+
* Re-exported from agentfootprint's main entry. See individual module
|
|
6
|
+
* READMEs for usage.
|
|
7
|
+
*/
|
|
8
|
+
export * from './beats/index.js';
|
|
9
|
+
export * from './causal/index.js';
|
|
10
|
+
export * from './embedding/index.js';
|
|
11
|
+
export * from './entry/index.js';
|
|
12
|
+
export * from './facts/index.js';
|
|
13
|
+
export * from './identity/index.js';
|
|
14
|
+
export * from './pipeline/index.js';
|
|
15
|
+
export * from './stages/index.js';
|
|
16
|
+
export * from './store/index.js';
|
|
17
|
+
export * from './wire/index.js';
|
|
18
|
+
export { MEMORY_TYPES, MEMORY_STRATEGIES, MEMORY_TIMING, SNAPSHOT_PROJECTIONS, MEMORY_INJECTION_KEY_PREFIX, isMemoryType, isMemoryStrategyKind, isMemoryTiming, isSnapshotProjection, memoryInjectionKey, isMemoryInjectionKey, type MemoryType, type MemoryStrategyKind, type MemoryTiming, type SnapshotProjection, type Strategy, type WindowStrategy, type BudgetStrategy, type SummarizeStrategy, type TopKStrategy, type ExtractStrategy, type DecayStrategy, type HybridStrategy, type MemoryDefinition, type DefineMemoryOptions, type DefineEpisodicOptions, type DefineSemanticOptions, type DefineNarrativeOptions, type DefineCausalOptions, type MemoryRedactionPolicy, } from './define.types.js';
|
|
19
|
+
export { defineMemory } from './define.js';
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { LLMProvider } from '../../adapters/types.js';
|
|
2
|
+
import type { MemoryStore } from '../store/index.js';
|
|
3
|
+
import type { MemoryEntry } from '../entry/index.js';
|
|
4
|
+
import type { MemoryPipeline } from './types.js';
|
|
5
|
+
import { type FactPipelineState, type FactExtractor } from '../facts/index.js';
|
|
6
|
+
import { type NarrativeBeat, type BeatExtractor, type ExtractBeatsState } from '../beats/index.js';
|
|
7
|
+
export interface AutoPipelineConfig {
|
|
8
|
+
/** The store both extractors share. */
|
|
9
|
+
readonly store: MemoryStore;
|
|
10
|
+
/**
|
|
11
|
+
* When present, upgrades both fact AND beat extraction to LLM-backed
|
|
12
|
+
* variants. Typically a cheap/fast model like Claude Haiku. Omit to
|
|
13
|
+
* use the free heuristic + regex defaults.
|
|
14
|
+
*/
|
|
15
|
+
readonly provider?: LLMProvider;
|
|
16
|
+
/**
|
|
17
|
+
* Override the fact extractor explicitly. Takes precedence over
|
|
18
|
+
* `provider`. Use when you want facts via LLM but beats via heuristic,
|
|
19
|
+
* or vice-versa.
|
|
20
|
+
*/
|
|
21
|
+
readonly factExtractor?: FactExtractor;
|
|
22
|
+
/**
|
|
23
|
+
* Override the beat extractor explicitly. Takes precedence over
|
|
24
|
+
* `provider`.
|
|
25
|
+
*/
|
|
26
|
+
readonly beatExtractor?: BeatExtractor;
|
|
27
|
+
/**
|
|
28
|
+
* Upper bound on the `store.list` page size during read. Large enough
|
|
29
|
+
* to fit typical identity+history; raise for long-lived agents with
|
|
30
|
+
* dozens of fact categories and hundreds of beats. Default `200`.
|
|
31
|
+
*/
|
|
32
|
+
readonly loadLimit?: number;
|
|
33
|
+
/** Tier filter for read. */
|
|
34
|
+
readonly tiers?: ReadonlyArray<'hot' | 'warm' | 'cold'>;
|
|
35
|
+
/** Tier to tag newly written entries (both facts and beats). */
|
|
36
|
+
readonly writeTier?: 'hot' | 'warm' | 'cold';
|
|
37
|
+
/** TTL in ms applied to newly written entries. */
|
|
38
|
+
readonly writeTtlMs?: number;
|
|
39
|
+
/** Header for the facts block in the injected system message. */
|
|
40
|
+
readonly factsHeader?: string;
|
|
41
|
+
/** Lead-in phrase for the narrative paragraph. Default `"From earlier: "`. */
|
|
42
|
+
readonly narrativeLeadIn?: string;
|
|
43
|
+
/**
|
|
44
|
+
* When `true`, appends `(conf 0.xx)` after each fact. Off by default
|
|
45
|
+
* — confidence is noise for the LLM in typical flows.
|
|
46
|
+
*/
|
|
47
|
+
readonly showConfidence?: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* When `true`, appends `(refs: msg-x-y, ...)` after each beat line.
|
|
50
|
+
* Off by default.
|
|
51
|
+
*/
|
|
52
|
+
readonly showRefs?: boolean;
|
|
53
|
+
}
|
|
54
|
+
/** State used by the auto pipeline's subflows. */
|
|
55
|
+
export interface AutoPipelineState extends FactPipelineState, ExtractBeatsState {
|
|
56
|
+
/** Beats loaded from the store during auto-READ. */
|
|
57
|
+
loadedBeats?: readonly MemoryEntry<NarrativeBeat>[];
|
|
58
|
+
}
|
|
59
|
+
export declare function autoPipeline(config: AutoPipelineConfig): MemoryPipeline;
|