agentfootprint 6.44.0 → 7.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +4 -0
- package/CLAUDE.md +4 -0
- package/README.md +141 -167
- package/ai-instructions/claude-code/SKILL.md +11 -0
- package/ai-instructions/setup.sh +0 -0
- package/dist/adapters/llm/BrowserOpenAIProvider.js +1 -1
- package/dist/adapters/llm/MockProvider.js +2 -1
- package/dist/adapters/llm/MockProvider.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/debug/finders.js +29 -0
- package/dist/debug/finders.js.map +1 -0
- package/dist/debug.js +134 -0
- package/dist/debug.js.map +1 -0
- 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/BrowserOpenAIProvider.js +1 -1
- package/dist/esm/adapters/llm/MockProvider.d.ts +154 -0
- package/dist/esm/adapters/llm/MockProvider.js +2 -1
- package/dist/esm/adapters/llm/MockProvider.js.map +1 -1
- 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/debug/finders.d.ts +12 -0
- package/dist/esm/debug/finders.js +13 -0
- package/dist/esm/debug/finders.js.map +1 -0
- package/dist/esm/debug.d.ts +25 -0
- package/dist/esm/debug.js +54 -0
- package/dist/esm/debug.js.map +1 -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/events.d.ts +18 -0
- package/dist/esm/events.js +22 -0
- package/dist/esm/events.js.map +1 -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 +44 -0
- package/dist/esm/index.js +7 -52
- 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 +2 -1
- 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 +290 -0
- package/dist/esm/lib/injection-engine/skillGraph.js +38 -43
- 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/defineRAG.js +3 -3
- package/dist/esm/lib/rag/index.d.ts +7 -0
- package/dist/esm/lib/rag/indexDocuments.d.ts +106 -0
- package/dist/esm/lib/rag/indexDocuments.js +2 -1
- package/dist/esm/lib/rag/indexDocuments.js.map +1 -1
- 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 +141 -0
- package/dist/esm/locales/index.js +7 -0
- package/dist/esm/locales/index.js.map +1 -1
- 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 +134 -0
- package/dist/esm/memory/causal/types.js.map +1 -1
- 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 +278 -0
- package/dist/esm/memory/define.types.js +6 -4
- package/dist/esm/memory/define.types.js.map +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 +57 -0
- package/dist/esm/observe.js +7 -36
- 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/providers.js +1 -1
- package/dist/esm/providers.js.map +1 -1
- 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 +54 -0
- package/dist/esm/status.js +13 -4
- package/dist/esm/status.js.map +1 -1
- 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/events.js +42 -0
- package/dist/events.js.map +1 -0
- package/dist/index.js +7 -117
- 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 +6 -2
- package/dist/lib/injection-engine/index.js.map +1 -1
- package/dist/lib/injection-engine/skillGraph.js +40 -45
- package/dist/lib/injection-engine/skillGraph.js.map +1 -1
- package/dist/lib/injection-engine/types.js.map +1 -1
- package/dist/lib/rag/defineRAG.js +3 -3
- package/dist/lib/rag/indexDocuments.js +2 -1
- package/dist/lib/rag/indexDocuments.js.map +1 -1
- package/dist/locales/index.js +2 -1
- package/dist/locales/index.js.map +1 -1
- package/dist/memory/causal/types.js.map +1 -1
- package/dist/memory/define.types.js +6 -4
- package/dist/memory/define.types.js.map +1 -1
- package/dist/observe.js +22 -115
- package/dist/observe.js.map +1 -1
- package/dist/providers.js +3 -1
- package/dist/providers.js.map +1 -1
- package/dist/status.js +13 -5
- package/dist/status.js.map +1 -1
- package/dist/types/adapters/llm/BrowserOpenAIProvider.d.ts +1 -1
- package/dist/types/adapters/llm/MockProvider.d.ts +2 -1
- package/dist/types/adapters/llm/MockProvider.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/debug/finders.d.ts +13 -0
- package/dist/types/debug/finders.d.ts.map +1 -0
- package/dist/types/debug.d.ts +26 -0
- package/dist/types/debug.d.ts.map +1 -0
- package/dist/types/events.d.ts +19 -0
- package/dist/types/events.d.ts.map +1 -0
- package/dist/types/index.d.ts +4 -24
- 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 +2 -1
- package/dist/types/lib/injection-engine/index.d.ts.map +1 -1
- package/dist/types/lib/injection-engine/skillGraph.d.ts +24 -26
- 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/lib/rag/defineRAG.d.ts +3 -3
- package/dist/types/lib/rag/indexDocuments.d.ts +2 -1
- package/dist/types/lib/rag/indexDocuments.d.ts.map +1 -1
- package/dist/types/locales/index.d.ts +9 -0
- package/dist/types/locales/index.d.ts.map +1 -1
- package/dist/types/memory/causal/types.d.ts +13 -9
- package/dist/types/memory/causal/types.d.ts.map +1 -1
- package/dist/types/memory/define.types.d.ts +6 -4
- package/dist/types/memory/define.types.d.ts.map +1 -1
- package/dist/types/observe.d.ts +1 -6
- package/dist/types/observe.d.ts.map +1 -1
- package/dist/types/providers.d.ts +2 -2
- package/dist/types/providers.d.ts.map +1 -1
- package/dist/types/status.d.ts +10 -4
- package/dist/types/status.d.ts.map +1 -1
- package/dist/types/tool-providers/index.d.ts +1 -1
- package/dist/types/tool-providers/index.d.ts.map +1 -1
- package/package.json +261 -57
|
@@ -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;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { MemoryStore } from '../store/index.js';
|
|
2
|
+
import type { MemoryPipeline } from './types.js';
|
|
3
|
+
export interface DefaultPipelineConfig {
|
|
4
|
+
/** The store both subflows share. */
|
|
5
|
+
readonly store: MemoryStore;
|
|
6
|
+
/** How many recent entries to load per turn. Default 20 (see loadRecent). */
|
|
7
|
+
readonly loadCount?: number;
|
|
8
|
+
/**
|
|
9
|
+
* Token reserve for prompt headers / new user message / safety margin.
|
|
10
|
+
* Default 256.
|
|
11
|
+
*/
|
|
12
|
+
readonly reserveTokens?: number;
|
|
13
|
+
/** Minimum memory-token budget before the picker skips injection. Default 100. */
|
|
14
|
+
readonly minimumTokens?: number;
|
|
15
|
+
/**
|
|
16
|
+
* Hard cap on entries selected per turn, independent of tokens. Helps
|
|
17
|
+
* with "lost-in-the-middle" degradation. Default: no cap.
|
|
18
|
+
*/
|
|
19
|
+
readonly maxEntries?: number;
|
|
20
|
+
/**
|
|
21
|
+
* Optional tier constraint — e.g. `['hot']` to read only entries
|
|
22
|
+
* marked `hot` by the write side. Combines with `loadCount` (cap
|
|
23
|
+
* AFTER filter).
|
|
24
|
+
*/
|
|
25
|
+
readonly tiers?: ReadonlyArray<'hot' | 'warm' | 'cold'>;
|
|
26
|
+
/**
|
|
27
|
+
* Optional tier written entries are tagged with. Matches the `tiers`
|
|
28
|
+
* read filter when both sides want to coordinate tier policy.
|
|
29
|
+
*/
|
|
30
|
+
readonly writeTier?: 'hot' | 'warm' | 'cold';
|
|
31
|
+
/**
|
|
32
|
+
* Optional write-side TTL in milliseconds from `now`. Every written
|
|
33
|
+
* entry expires this long after storage. Useful for compliance
|
|
34
|
+
* retention windows.
|
|
35
|
+
*/
|
|
36
|
+
readonly writeTtlMs?: number;
|
|
37
|
+
/**
|
|
38
|
+
* Override for the formatter's header text. Omit to use the default
|
|
39
|
+
* "Relevant context from prior conversations..." phrasing.
|
|
40
|
+
*/
|
|
41
|
+
readonly formatHeader?: string;
|
|
42
|
+
/** Override for the formatter's footer text. Default: empty. */
|
|
43
|
+
readonly formatFooter?: string;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Build the default read + write pipelines sharing a single store.
|
|
47
|
+
* Returns two FlowChart subflows ready to be mounted by the wire layer.
|
|
48
|
+
*/
|
|
49
|
+
export declare function defaultPipeline(config: DefaultPipelineConfig): MemoryPipeline;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { MemoryStore } from '../store/index.js';
|
|
2
|
+
import type { MemoryPipeline } from './types.js';
|
|
3
|
+
export interface EphemeralPipelineConfig {
|
|
4
|
+
/** The store to read from. Writes never happen — backend can be read-only. */
|
|
5
|
+
readonly store: MemoryStore;
|
|
6
|
+
/** How many recent entries to load per turn. Default 20. */
|
|
7
|
+
readonly loadCount?: number;
|
|
8
|
+
/** Token reserve for prompt headers / safety margin. Default 256. */
|
|
9
|
+
readonly reserveTokens?: number;
|
|
10
|
+
/** Minimum memory-token budget before the picker skips injection. Default 100. */
|
|
11
|
+
readonly minimumTokens?: number;
|
|
12
|
+
/** Hard cap on entries selected per turn. Default: no cap. */
|
|
13
|
+
readonly maxEntries?: number;
|
|
14
|
+
/**
|
|
15
|
+
* Optional tier filter — e.g. `['hot']` to load only pre-seeded "hot"
|
|
16
|
+
* entries. Omitted means all tiers.
|
|
17
|
+
*/
|
|
18
|
+
readonly tiers?: ReadonlyArray<'hot' | 'warm' | 'cold'>;
|
|
19
|
+
/** Override for the formatter's header text. */
|
|
20
|
+
readonly formatHeader?: string;
|
|
21
|
+
/** Override for the formatter's footer text. */
|
|
22
|
+
readonly formatFooter?: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Build an ephemeral (read-only) pipeline. The returned object has
|
|
26
|
+
* `write: undefined`; wire helpers no-op on it.
|
|
27
|
+
*/
|
|
28
|
+
export declare function ephemeralPipeline(config: EphemeralPipelineConfig): MemoryPipeline;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { MemoryStore } from '../store/index.js';
|
|
2
|
+
import type { MemoryPipeline } from './types.js';
|
|
3
|
+
import type { FactExtractor } from '../facts/extractor.js';
|
|
4
|
+
export interface FactPipelineConfig {
|
|
5
|
+
/** The store both subflows share. */
|
|
6
|
+
readonly store: MemoryStore;
|
|
7
|
+
/**
|
|
8
|
+
* Fact extractor. Defaults to `patternFactExtractor()` — zero-dep,
|
|
9
|
+
* zero-cost, baseline quality. Swap for
|
|
10
|
+
* `llmFactExtractor({ provider })` for semantic quality.
|
|
11
|
+
*/
|
|
12
|
+
readonly extractor?: FactExtractor;
|
|
13
|
+
/** Forwarded to `loadFacts` (upper bound on `list` page size). */
|
|
14
|
+
readonly loadLimit?: number;
|
|
15
|
+
/** Tier filter for read (e.g. `['hot']`). */
|
|
16
|
+
readonly tiers?: ReadonlyArray<'hot' | 'warm' | 'cold'>;
|
|
17
|
+
/** Tier to tag written facts with. */
|
|
18
|
+
readonly writeTier?: 'hot' | 'warm' | 'cold';
|
|
19
|
+
/** Optional TTL for written facts (ms from write time). */
|
|
20
|
+
readonly writeTtlMs?: number;
|
|
21
|
+
/** Forwarded to `formatFacts`. */
|
|
22
|
+
readonly formatHeader?: string;
|
|
23
|
+
readonly formatFooter?: string;
|
|
24
|
+
readonly formatShowConfidence?: boolean;
|
|
25
|
+
}
|
|
26
|
+
export declare function factPipeline(config: FactPipelineConfig): MemoryPipeline;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type { MemoryPipeline } from './types.js';
|
|
2
|
+
export { defaultPipeline } from './default.js';
|
|
3
|
+
export type { DefaultPipelineConfig } from './default.js';
|
|
4
|
+
export { ephemeralPipeline } from './ephemeral.js';
|
|
5
|
+
export type { EphemeralPipelineConfig } from './ephemeral.js';
|
|
6
|
+
export { narrativePipeline } from './narrative.js';
|
|
7
|
+
export type { NarrativePipelineConfig } from './narrative.js';
|
|
8
|
+
export { semanticPipeline } from './semantic.js';
|
|
9
|
+
export type { SemanticPipelineConfig } from './semantic.js';
|
|
10
|
+
export { factPipeline } from './fact.js';
|
|
11
|
+
export type { FactPipelineConfig } from './fact.js';
|
|
12
|
+
export { autoPipeline } from './auto.js';
|
|
13
|
+
export type { AutoPipelineConfig, AutoPipelineState } from './auto.js';
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { MemoryStore } from '../store/index.js';
|
|
2
|
+
import type { MemoryPipeline } from './types.js';
|
|
3
|
+
import type { BeatExtractor } from '../beats/extractor.js';
|
|
4
|
+
export interface NarrativePipelineConfig {
|
|
5
|
+
/** The store both subflows share. */
|
|
6
|
+
readonly store: MemoryStore;
|
|
7
|
+
/**
|
|
8
|
+
* Beat extractor. Defaults to `heuristicExtractor()` — zero-dep,
|
|
9
|
+
* zero-cost, baseline quality. Swap for `llmExtractor({ provider })`
|
|
10
|
+
* for semantic quality.
|
|
11
|
+
*/
|
|
12
|
+
readonly extractor?: BeatExtractor;
|
|
13
|
+
/** Forwarded to `loadRecent` (how many beats to consider per turn). */
|
|
14
|
+
readonly loadCount?: number;
|
|
15
|
+
/** Forwarded to `pickByBudget`. */
|
|
16
|
+
readonly reserveTokens?: number;
|
|
17
|
+
readonly minimumTokens?: number;
|
|
18
|
+
readonly maxEntries?: number;
|
|
19
|
+
/** Tier filter for read (e.g. `['hot']`). */
|
|
20
|
+
readonly tiers?: ReadonlyArray<'hot' | 'warm' | 'cold'>;
|
|
21
|
+
/** Tier to tag written beats with. */
|
|
22
|
+
readonly writeTier?: 'hot' | 'warm' | 'cold';
|
|
23
|
+
/** Optional TTL for written beats (ms from write time). */
|
|
24
|
+
readonly writeTtlMs?: number;
|
|
25
|
+
/** Forwarded to `formatAsNarrative`. */
|
|
26
|
+
readonly formatHeader?: string;
|
|
27
|
+
readonly formatFooter?: string;
|
|
28
|
+
readonly formatShowRefs?: boolean;
|
|
29
|
+
readonly formatLeadIn?: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Build the narrative read + write pipelines sharing a single store.
|
|
33
|
+
* Returns `{ read, write }` ready to be passed to `Agent.memory()` via the appropriate `defineMemory` config (or used directly via `mountMemoryRead`/`mountMemoryWrite`).
|
|
34
|
+
*/
|
|
35
|
+
export declare function narrativePipeline(config: NarrativePipelineConfig): MemoryPipeline;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { MemoryStore } from '../store/index.js';
|
|
2
|
+
import type { MemoryPipeline } from './types.js';
|
|
3
|
+
import type { Embedder } from '../embedding/types.js';
|
|
4
|
+
export interface SemanticPipelineConfig {
|
|
5
|
+
/** Vector-capable store. Must implement `search()`. */
|
|
6
|
+
readonly store: MemoryStore;
|
|
7
|
+
/** Embedder used for both write-side indexing and read-side query. */
|
|
8
|
+
readonly embedder: Embedder;
|
|
9
|
+
/**
|
|
10
|
+
* Stable id for the embedder — attached to written entries and used
|
|
11
|
+
* as a filter at read time so a later embedder swap doesn't produce
|
|
12
|
+
* cross-model similarity pollution. Example: `"openai-text-embedding-3-small"`.
|
|
13
|
+
*/
|
|
14
|
+
readonly embedderId?: string;
|
|
15
|
+
/** Top-k entries to consider per turn. Default 20; picker narrows further. */
|
|
16
|
+
readonly k?: number;
|
|
17
|
+
/** Cosine threshold below which matches are dropped. Default none. */
|
|
18
|
+
readonly minScore?: number;
|
|
19
|
+
/** Tier filter for retrieval. */
|
|
20
|
+
readonly tiers?: ReadonlyArray<'hot' | 'warm' | 'cold'>;
|
|
21
|
+
/** Tier to tag writes with. */
|
|
22
|
+
readonly writeTier?: 'hot' | 'warm' | 'cold';
|
|
23
|
+
/** TTL for written entries (ms from write time). */
|
|
24
|
+
readonly writeTtlMs?: number;
|
|
25
|
+
/** Forwarded to `pickByBudget`. */
|
|
26
|
+
readonly reserveTokens?: number;
|
|
27
|
+
readonly minimumTokens?: number;
|
|
28
|
+
readonly maxEntries?: number;
|
|
29
|
+
/** Forwarded to `formatDefault`. */
|
|
30
|
+
readonly formatHeader?: string;
|
|
31
|
+
readonly formatFooter?: string;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Build the semantic read + write pipelines sharing a single store.
|
|
35
|
+
* Returns `{ read, write }` ready to pass to `Agent.memory()` via the appropriate `defineMemory` config (or used directly via `mountMemoryRead`/`mountMemoryWrite`).
|
|
36
|
+
*/
|
|
37
|
+
export declare function semanticPipeline(config: SemanticPipelineConfig): MemoryPipeline;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pipeline types — what a memory pipeline preset returns to the wire layer.
|
|
3
|
+
*
|
|
4
|
+
* The wire layer (Layer 5) mounts these two flowcharts as subflows inside
|
|
5
|
+
* the agent's main flowchart:
|
|
6
|
+
* - `read` runs beforeTurn — produces `scope.formatted` for injection
|
|
7
|
+
* - `write` runs afterTurn — persists `scope.newMessages`
|
|
8
|
+
*
|
|
9
|
+
* Having BOTH returned as a bundle keeps the two sides coupled to a
|
|
10
|
+
* single store/config choice: you can't accidentally use
|
|
11
|
+
* `.memory(definition)` with `preset2.write` and end up
|
|
12
|
+
* writing to a different store than you read from.
|
|
13
|
+
*/
|
|
14
|
+
import type { FlowChart } from 'footprintjs';
|
|
15
|
+
import type { MemoryState } from '../stages/index.js';
|
|
16
|
+
/**
|
|
17
|
+
* The two flowcharts that together form a memory pipeline. Either may be
|
|
18
|
+
* `undefined` for one-sided pipelines (e.g. `ephemeral` has no `write`).
|
|
19
|
+
*/
|
|
20
|
+
export interface MemoryPipeline {
|
|
21
|
+
/**
|
|
22
|
+
* Read subflow — runs before each agent turn to populate
|
|
23
|
+
* `scope.formatted` with memory content to inject.
|
|
24
|
+
*/
|
|
25
|
+
readonly read: FlowChart<MemoryState>;
|
|
26
|
+
/**
|
|
27
|
+
* Write subflow — runs after each turn to persist `scope.newMessages`.
|
|
28
|
+
* Optional: `ephemeral` and `readonly` pipelines omit this.
|
|
29
|
+
*/
|
|
30
|
+
readonly write?: FlowChart<MemoryState>;
|
|
31
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* formatDefault — render picked entries into injection-ready messages.
|
|
3
|
+
*
|
|
4
|
+
* Reads from scope: `selected`
|
|
5
|
+
* Writes to scope: `formatted` (messages to inject into the LLM prompt)
|
|
6
|
+
*
|
|
7
|
+
* Why a separate stage from the picker?
|
|
8
|
+
* Retrieval and presentation are orthogonal concerns (MemGPT-reviewer
|
|
9
|
+
* ask). A picker decides WHICH memories survive the budget; a formatter
|
|
10
|
+
* decides HOW they appear to the LLM. Consumers can swap either without
|
|
11
|
+
* touching the other. In research settings, format variations ("JSON
|
|
12
|
+
* envelope" vs "XML tags" vs "natural paragraphs") are worth ablating.
|
|
13
|
+
*
|
|
14
|
+
* Default format:
|
|
15
|
+
* One `system` message containing a citation-tagged block per entry:
|
|
16
|
+
*
|
|
17
|
+
* <memory source="turn:5" updated="2026-04-18T06:00:00Z">
|
|
18
|
+
* User said: I live in San Francisco.
|
|
19
|
+
* </memory>
|
|
20
|
+
*
|
|
21
|
+
* Citation tags let the LLM reference sources in its response; the
|
|
22
|
+
* Anthropic-reviewer ask ("recall should carry source").
|
|
23
|
+
*
|
|
24
|
+
* Role chosen: `system`. Reasoning: this is NOT the ongoing dialogue,
|
|
25
|
+
* it's context we're adding. A `user` role would confuse turn-taking;
|
|
26
|
+
* `assistant` would be a false claim. `system` matches the semantic
|
|
27
|
+
* of "context injected by the application, not part of the conversation."
|
|
28
|
+
*
|
|
29
|
+
* Wrapping: entries are grouped into ONE system message rather than N
|
|
30
|
+
* separate messages. One message is easier for LLMs to reason about
|
|
31
|
+
* and avoids breaking up the conversational flow.
|
|
32
|
+
*/
|
|
33
|
+
import type { TypedScope } from 'footprintjs';
|
|
34
|
+
import type { MemoryEntry } from '../entry/index.js';
|
|
35
|
+
import type { LLMMessage as Message } from '../../adapters/types.js';
|
|
36
|
+
import type { MemoryState } from './types.js';
|
|
37
|
+
export interface FormatDefaultConfig {
|
|
38
|
+
/**
|
|
39
|
+
* Header prepended to the injected message. Explains to the LLM what
|
|
40
|
+
* follows and what it's for. Override if your app has specific phrasing
|
|
41
|
+
* guidance ("long-term memory" vs "user preferences", etc.).
|
|
42
|
+
*/
|
|
43
|
+
readonly header?: string;
|
|
44
|
+
/**
|
|
45
|
+
* Footer appended after all entries. Empty by default. Useful for
|
|
46
|
+
* explicit guidance ("Use this context only when relevant. Do not
|
|
47
|
+
* mention retrieval unless asked.").
|
|
48
|
+
*/
|
|
49
|
+
readonly footer?: string;
|
|
50
|
+
/**
|
|
51
|
+
* Custom per-entry renderer. Receives the entry; returns the block
|
|
52
|
+
* string (without outer tags — the default wrapper adds those). Use
|
|
53
|
+
* for app-specific formatting: custom source attributions, hiding
|
|
54
|
+
* tier info, etc.
|
|
55
|
+
*/
|
|
56
|
+
readonly renderEntry?: (entry: MemoryEntry<Message>) => string;
|
|
57
|
+
/**
|
|
58
|
+
* When `true`, inject even if `selected` is empty (emits only header
|
|
59
|
+
* and footer). Usually NOT desired — an empty memory block is noise.
|
|
60
|
+
* Default: skip emitting when selected is empty.
|
|
61
|
+
*/
|
|
62
|
+
readonly emitWhenEmpty?: boolean;
|
|
63
|
+
}
|
|
64
|
+
export declare function formatDefault(config?: FormatDefaultConfig): (scope: TypedScope<MemoryState>) => Promise<void>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type { MemoryState } from './types.js';
|
|
2
|
+
export { loadRecent } from './loadRecent.js';
|
|
3
|
+
export type { LoadRecentConfig } from './loadRecent.js';
|
|
4
|
+
export { writeMessages } from './writeMessages.js';
|
|
5
|
+
export type { WriteMessagesConfig } from './writeMessages.js';
|
|
6
|
+
export { pickByBudget } from './pickByBudget.js';
|
|
7
|
+
export type { PickByBudgetConfig } from './pickByBudget.js';
|
|
8
|
+
export { formatDefault } from './formatDefault.js';
|
|
9
|
+
export type { FormatDefaultConfig } from './formatDefault.js';
|
|
10
|
+
export { approximateTokenCounter, countMessageTokens } from './tokenize.js';
|
|
11
|
+
export type { TokenCounter } from './tokenize.js';
|
|
12
|
+
export { summarize } from './summarize.js';
|
|
13
|
+
export type { SummarizeConfig } from './summarize.js';
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* loadRecent — read-side stage that injects the N most recent stored
|
|
3
|
+
* messages into scope.loaded.
|
|
4
|
+
*
|
|
5
|
+
* Simplest possible retrieval: "what did we say last?" — no scoring,
|
|
6
|
+
* no ranking, no decay, just chronological tail. Appropriate for small
|
|
7
|
+
* conversations or as the warm-tier component of a hybrid pipeline.
|
|
8
|
+
*
|
|
9
|
+
* Reads from scope: `identity`
|
|
10
|
+
* Writes to scope: `loaded` (appends — does not replace)
|
|
11
|
+
*
|
|
12
|
+
* Why append, not replace?
|
|
13
|
+
* Pipelines typically run multiple load stages (recent + semantic +
|
|
14
|
+
* facts). Appending lets each contribute without coordination. The
|
|
15
|
+
* picker stage (Layer 3) deduplicates + ranks the combined set.
|
|
16
|
+
*
|
|
17
|
+
* Why `count` primary, tokens secondary?
|
|
18
|
+
* Token counting needs a tokenizer — adds a dependency. `count` is
|
|
19
|
+
* universally available and "most recent N" is the most common ask.
|
|
20
|
+
* Token-budget enforcement happens in the picker stage where it
|
|
21
|
+
* naturally composes with other signals.
|
|
22
|
+
*/
|
|
23
|
+
import type { TypedScope } from 'footprintjs';
|
|
24
|
+
import type { MemoryStore } from '../store/index.js';
|
|
25
|
+
import type { MemoryState } from './types.js';
|
|
26
|
+
export interface LoadRecentConfig {
|
|
27
|
+
/** The store to read from. */
|
|
28
|
+
readonly store: MemoryStore;
|
|
29
|
+
/**
|
|
30
|
+
* Maximum number of entries to return. Defaults to 20 — large enough
|
|
31
|
+
* for typical chat recency, small enough to fit most context windows.
|
|
32
|
+
* Stores may cap this lower; in that case you get whatever fits.
|
|
33
|
+
*/
|
|
34
|
+
readonly count?: number;
|
|
35
|
+
/**
|
|
36
|
+
* Optional tier filter. When set, only loads entries marked with one
|
|
37
|
+
* of these tiers (e.g. `['hot']` for aggressive context management).
|
|
38
|
+
* Omitted filter = all tiers, consistent with MemoryStore.list default.
|
|
39
|
+
*/
|
|
40
|
+
readonly tiers?: ReadonlyArray<'hot' | 'warm' | 'cold'>;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Build a stage function that loads recent entries into `scope.loaded`.
|
|
44
|
+
*
|
|
45
|
+
* The returned stage is async and side-effect-free on failure: if the
|
|
46
|
+
* store throws, the stage re-throws (fail-loud) — callers wrap with
|
|
47
|
+
* `withRetry` / `withFallback` if they want degrade-to-empty behavior.
|
|
48
|
+
*/
|
|
49
|
+
export declare function loadRecent(config: LoadRecentConfig): (scope: TypedScope<MemoryState>) => Promise<void>;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { FlowChartBuilder } from 'footprintjs';
|
|
2
|
+
import type { MemoryState } from './types.js';
|
|
3
|
+
import { type TokenCounter } from './tokenize.js';
|
|
4
|
+
/**
|
|
5
|
+
* Reusable shape for a **composable pipeline segment** — a function that
|
|
6
|
+
* appends one or more stages to a builder and returns the builder. This
|
|
7
|
+
* is the memory layer's convention for packaging multi-stage work
|
|
8
|
+
* (decider + branches, multi-stage sub-pipelines) as a single unit that
|
|
9
|
+
* consumers can drop into any flowchart:
|
|
10
|
+
*
|
|
11
|
+
* ```ts
|
|
12
|
+
* let b = flowChart<MyState>('Seed', seed, 'seed');
|
|
13
|
+
* b = pickByBudget(config)(b); // appends a decider + 3 branches
|
|
14
|
+
* b = b.addFunction('Format', fmt, ...);
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* Generic in `T` so segments targeting the memory layer can be composed
|
|
18
|
+
* into host flowcharts whose state extends `MemoryState`. Future
|
|
19
|
+
* segments (NarrativeMemory, SemanticRetrieval, FactExtraction) follow
|
|
20
|
+
* the same shape for uniform composition ergonomics.
|
|
21
|
+
*/
|
|
22
|
+
export type PipelineSegment<T extends object> = (builder: FlowChartBuilder<T>) => FlowChartBuilder<T>;
|
|
23
|
+
export interface PickByBudgetConfig {
|
|
24
|
+
/**
|
|
25
|
+
* Tokens to keep in reserve — not used for memory. Default 256.
|
|
26
|
+
* Covers system-prompt overhead, new user message headroom, and safety
|
|
27
|
+
* margin against token-counter approximation error. Tune per model.
|
|
28
|
+
*/
|
|
29
|
+
readonly reserveTokens?: number;
|
|
30
|
+
/**
|
|
31
|
+
* Hard floor on memory tokens. If the budget minus reserve is less than
|
|
32
|
+
* this, NO memory is injected (better to skip than inject a fragment).
|
|
33
|
+
* Default 100 — under 100 tokens of memory is usually worse than none.
|
|
34
|
+
*/
|
|
35
|
+
readonly minimumTokens?: number;
|
|
36
|
+
/**
|
|
37
|
+
* Pluggable token counter — defaults to `approximateTokenCounter`
|
|
38
|
+
* (1 token ≈ 4 chars). Swap for a real tokenizer when accuracy matters.
|
|
39
|
+
*/
|
|
40
|
+
readonly countTokens?: TokenCounter;
|
|
41
|
+
/**
|
|
42
|
+
* Optional cap on the NUMBER of entries, independent of tokens.
|
|
43
|
+
* Useful when the budget is large enough to include hundreds of
|
|
44
|
+
* entries but the LLM's "lost-in-the-middle" effect degrades quality
|
|
45
|
+
* past ~20. Default: no cap (budget is the only limit).
|
|
46
|
+
*/
|
|
47
|
+
readonly maxEntries?: number;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Append the pick-by-budget decider + branches to `builder`. Returns
|
|
51
|
+
* the builder so calls chain naturally:
|
|
52
|
+
*
|
|
53
|
+
* ```ts
|
|
54
|
+
* let b = flowChart<MemoryState>('LoadRecent', loadRecent(config), 'load-recent');
|
|
55
|
+
* b = pickByBudget(pickConfig)(b);
|
|
56
|
+
* b = b.addFunction('Format', formatDefault(formatConfig), 'format-default');
|
|
57
|
+
* ```
|
|
58
|
+
*
|
|
59
|
+
* Generic in `T` so consumers whose scope extends `MemoryState` (e.g.,
|
|
60
|
+
* an AgentLoopState that embeds memory fields) can compose this into
|
|
61
|
+
* their own pipeline without casting.
|
|
62
|
+
*/
|
|
63
|
+
export declare function pickByBudget<T extends MemoryState = MemoryState>(config?: PickByBudgetConfig): PipelineSegment<T>;
|