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,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* llmExtractor — LLM-backed beat extractor.
|
|
3
|
+
*
|
|
4
|
+
* Uses an LLMProvider (typically a cheap model like Claude Haiku or
|
|
5
|
+
* GPT-4o-mini) to produce semantically rich beats. One extraction LLM
|
|
6
|
+
* call per turn. Opt-in — default is `heuristicExtractor()` which is
|
|
7
|
+
* free.
|
|
8
|
+
*
|
|
9
|
+
* The extractor asks the LLM for a JSON response in this shape:
|
|
10
|
+
*
|
|
11
|
+
* ```json
|
|
12
|
+
* {
|
|
13
|
+
* "beats": [
|
|
14
|
+
* {
|
|
15
|
+
* "summary": "User revealed their name is Alice",
|
|
16
|
+
* "importance": 0.9,
|
|
17
|
+
* "refs": ["msg-1-0"],
|
|
18
|
+
* "category": "identity"
|
|
19
|
+
* }
|
|
20
|
+
* ]
|
|
21
|
+
* }
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* The extractor parses, clamps importance via `asImportance()`, and
|
|
25
|
+
* returns the beats. Malformed responses fall back to an empty array
|
|
26
|
+
* — a bad extraction should not break the agent turn.
|
|
27
|
+
*
|
|
28
|
+
* Usage:
|
|
29
|
+
* ```ts
|
|
30
|
+
* import { anthropic } from 'agentfootprint';
|
|
31
|
+
* import { llmExtractor, narrativePipeline, InMemoryStore } from 'agentfootprint/memory';
|
|
32
|
+
*
|
|
33
|
+
* const pipeline = narrativePipeline({
|
|
34
|
+
* store: new InMemoryStore(),
|
|
35
|
+
* extractor: llmExtractor({ provider: yourLLMProvider }),
|
|
36
|
+
* });
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
import type { LLMProvider } from '../../adapters/types.js';
|
|
40
|
+
import type { BeatExtractor } from './extractor.js';
|
|
41
|
+
export interface LLMExtractorConfig {
|
|
42
|
+
/** The provider used for extraction. Typically a cheap/fast model. */
|
|
43
|
+
readonly provider: LLMProvider;
|
|
44
|
+
/**
|
|
45
|
+
* Override the system prompt. Defaults to a one-paragraph instruction
|
|
46
|
+
* that elicits the JSON shape described in the module docs.
|
|
47
|
+
*/
|
|
48
|
+
readonly systemPrompt?: string;
|
|
49
|
+
/**
|
|
50
|
+
* Dev-mode logger invoked when the LLM response fails to parse.
|
|
51
|
+
* Defaults to `console.warn` — production consumers can route the
|
|
52
|
+
* signal to their telemetry pipeline.
|
|
53
|
+
*/
|
|
54
|
+
readonly onParseError?: (error: unknown, rawContent: string) => void;
|
|
55
|
+
}
|
|
56
|
+
export declare function llmExtractor(config: LLMExtractorConfig): BeatExtractor;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Narrative beats — the unit of narrative memory.
|
|
3
|
+
*
|
|
4
|
+
* A `NarrativeBeat` is a self-contained summary extracted from one or
|
|
5
|
+
* more messages during a turn. Instead of persisting raw conversation
|
|
6
|
+
* forever, a narrative pipeline compresses each turn into beats and
|
|
7
|
+
* recalls them by composing beats back into a coherent story.
|
|
8
|
+
*
|
|
9
|
+
* Core properties:
|
|
10
|
+
* - **Summary**: a single sentence describing what happened.
|
|
11
|
+
* - **Importance**: 0..1 score the picker uses to prefer salient
|
|
12
|
+
* beats when the context-token budget is tight.
|
|
13
|
+
* - **Refs**: ids of the source messages the beat was extracted
|
|
14
|
+
* from. Lets consumers walk backwards from a recalled beat to
|
|
15
|
+
* the raw source — the explainability story.
|
|
16
|
+
* - **Category**: optional free-form tag (e.g. `"identity"`,
|
|
17
|
+
* `"preference"`, `"fact"`). Extractors / consumers pick their
|
|
18
|
+
* own taxonomy.
|
|
19
|
+
*
|
|
20
|
+
* Beats are persisted via the ordinary `MemoryStore` interface —
|
|
21
|
+
* `MemoryEntry<NarrativeBeat>` slots in unchanged. No storage changes
|
|
22
|
+
* needed to support narrative memory.
|
|
23
|
+
*/
|
|
24
|
+
/** Importance score in the half-open range [0, 1]. */
|
|
25
|
+
export type BeatImportance = number;
|
|
26
|
+
export interface NarrativeBeat {
|
|
27
|
+
/** One-sentence summary of what happened in this beat. */
|
|
28
|
+
readonly summary: string;
|
|
29
|
+
/**
|
|
30
|
+
* Importance score in [0, 1]. Picker stages use this to prefer
|
|
31
|
+
* salient beats when the budget is tight. Default 0.5 (neutral).
|
|
32
|
+
* Values outside [0, 1] are clamped by `asImportance()`.
|
|
33
|
+
*/
|
|
34
|
+
readonly importance: BeatImportance;
|
|
35
|
+
/**
|
|
36
|
+
* Ids of the source messages this beat was extracted from. Consumers
|
|
37
|
+
* answer "why does the agent remember X?" by walking refs backwards
|
|
38
|
+
* to the raw message text. May be empty for synthesized beats
|
|
39
|
+
* (e.g., beats produced from prior beats during compaction).
|
|
40
|
+
*/
|
|
41
|
+
readonly refs: readonly string[];
|
|
42
|
+
/**
|
|
43
|
+
* Optional free-form category — `"identity"`, `"preference"`,
|
|
44
|
+
* `"task-status"`, etc. Extractors / consumers pick their own
|
|
45
|
+
* taxonomy. Useful for filtering recalls by type.
|
|
46
|
+
*/
|
|
47
|
+
readonly category?: string;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Clamp a value to the valid [0, 1] importance range. Non-finite
|
|
51
|
+
* inputs collapse to 0.5 (neutral) so extractors that produce NaN
|
|
52
|
+
* / ±Infinity don't poison the picker's comparisons.
|
|
53
|
+
*/
|
|
54
|
+
export declare function asImportance(value: unknown): BeatImportance;
|
|
55
|
+
/**
|
|
56
|
+
* Duck-typed guard — true iff `value` has the shape of a
|
|
57
|
+
* `NarrativeBeat`. Used by pipelines that handle mixed-payload stores
|
|
58
|
+
* (raw messages + beats) to route entries correctly.
|
|
59
|
+
*/
|
|
60
|
+
export declare function isNarrativeBeat(value: unknown): value is NarrativeBeat;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* writeBeats — persist extracted beats to the memory store.
|
|
3
|
+
*
|
|
4
|
+
* Reads from scope: `newBeats`, `identity`
|
|
5
|
+
* Writes to store: one MemoryEntry<NarrativeBeat> per beat via `putMany`
|
|
6
|
+
*
|
|
7
|
+
* Parallels `writeMessages` — same shape, but the payload is beats
|
|
8
|
+
* rather than raw messages. Uses `store.putMany` so N beats from a
|
|
9
|
+
* single turn become 1 round-trip on network-backed adapters
|
|
10
|
+
* (Redis / DynamoDB / Postgres).
|
|
11
|
+
*/
|
|
12
|
+
import type { TypedScope } from 'footprintjs';
|
|
13
|
+
import type { MemoryStore } from '../store/index.js';
|
|
14
|
+
import type { ExtractBeatsState } from './extractBeats.js';
|
|
15
|
+
export interface WriteBeatsConfig {
|
|
16
|
+
/** The store to persist to. Typically the same store as the pipeline's read side. */
|
|
17
|
+
readonly store: MemoryStore;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Build the `writeBeats` stage function.
|
|
21
|
+
*/
|
|
22
|
+
export declare function writeBeats(config: WriteBeatsConfig): (scope: TypedScope<ExtractBeatsState>) => Promise<void>;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* causalEvidenceRecorder — the evidence bridge (backlog Phase-1 #5).
|
|
3
|
+
*
|
|
4
|
+
* Harvests, DURING the run, everything a causal snapshot needs beyond
|
|
5
|
+
* (query, finalContent) — from events the engine already fires:
|
|
6
|
+
*
|
|
7
|
+
* stream.tool_start/tool_end → ToolCallRecord (name, args, resultPreview, errored)
|
|
8
|
+
* stream.llm_end → tokenUsage accumulation + iteration high-water
|
|
9
|
+
* agent.turn_start/turn_end → durationMs (+ authoritative totals when seen)
|
|
10
|
+
* FlowRecorder.onDecision → DecisionRecord with footprintjs decide()/select()
|
|
11
|
+
* operator-level evidence (rule, conditions, chosen)
|
|
12
|
+
* context.evaluated routing → DecisionRecord per skill the graph routed to
|
|
13
|
+
*
|
|
14
|
+
* Pattern: CombinedRecorder (Convention 1 — single purpose: evidence
|
|
15
|
+
* accumulation); per-turn reset anchored on `agent.turn_start`
|
|
16
|
+
* (Convention 4 — executor `clear()` resets between runs; same-
|
|
17
|
+
* executor pause/resume PRESERVES pre-pause evidence by design).
|
|
18
|
+
* PII note: tool args/results and decide() evidence persist into snapshots.
|
|
19
|
+
* footprintjs `RedactionPolicy.emitPatterns` redacts the emit channel
|
|
20
|
+
* BEFORE this recorder IF the consumer configures one on the executor
|
|
21
|
+
* — the Agent does NOT configure one by default. Values are bounded
|
|
22
|
+
* (`maxPreviewChars` for results, `maxFieldChars` for args/evidence);
|
|
23
|
+
* treat the snapshot store as PII-bearing and protect it accordingly.
|
|
24
|
+
*
|
|
25
|
+
* The Agent attaches this automatically when a CAUSAL memory is mounted and
|
|
26
|
+
* threads `collect` into the memory write mount (`evidenceSource`) — so
|
|
27
|
+
* `writeSnapshot` persists real evidence instead of zeros.
|
|
28
|
+
*/
|
|
29
|
+
import type { FlowDecisionEvent, FlowSelectedEvent } from 'footprintjs';
|
|
30
|
+
import type { DecisionRecord, ToolCallRecord } from './types.js';
|
|
31
|
+
/** What the bridge delivers to `writeSnapshot` for one run. */
|
|
32
|
+
export interface RunEvidence {
|
|
33
|
+
readonly iterations: number;
|
|
34
|
+
readonly decisions: ReadonlyArray<DecisionRecord>;
|
|
35
|
+
readonly toolCalls: ReadonlyArray<ToolCallRecord>;
|
|
36
|
+
readonly durationMs: number;
|
|
37
|
+
readonly tokenUsage: {
|
|
38
|
+
readonly input: number;
|
|
39
|
+
readonly output: number;
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
export interface CausalEvidenceRecorderOptions {
|
|
43
|
+
/** Recorder id (default 'causal-evidence'). */
|
|
44
|
+
readonly id?: string;
|
|
45
|
+
/** Max chars kept of each tool result preview. Default 200. */
|
|
46
|
+
readonly maxPreviewChars?: number;
|
|
47
|
+
/** Max serialized chars kept of tool ARGS and decision EVIDENCE (the
|
|
48
|
+
* PII-dense fields). Oversized values are replaced by a truncated
|
|
49
|
+
* preview marker. Default 2000. */
|
|
50
|
+
readonly maxFieldChars?: number;
|
|
51
|
+
}
|
|
52
|
+
export interface CausalEvidenceRecorderHandle {
|
|
53
|
+
readonly id: string;
|
|
54
|
+
/** Snapshot the evidence accumulated for the CURRENT run. */
|
|
55
|
+
collect(): RunEvidence;
|
|
56
|
+
clear(): void;
|
|
57
|
+
onEmit(event: {
|
|
58
|
+
name: string;
|
|
59
|
+
payload: unknown;
|
|
60
|
+
}): void;
|
|
61
|
+
onDecision(event: FlowDecisionEvent): void;
|
|
62
|
+
onSelected(event: FlowSelectedEvent): void;
|
|
63
|
+
}
|
|
64
|
+
/** Build the evidence-harvesting recorder. Attach via `.recorder(rec)` (the
|
|
65
|
+
* Agent does this automatically for CAUSAL memories). */
|
|
66
|
+
export declare function causalEvidenceRecorder(options?: CausalEvidenceRecorderOptions): CausalEvidenceRecorderHandle;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export type { SnapshotEntry, DecisionRecord, ToolCallRecord, ProjectedSnapshot, SnapshotMessage, } from './types.js';
|
|
2
|
+
export { DEFAULT_TOOL_RESULT_PREVIEW_LEN } from './types.js';
|
|
3
|
+
export { causalEvidenceRecorder, type CausalEvidenceRecorderHandle, type CausalEvidenceRecorderOptions, type RunEvidence, } from './evidenceRecorder.js';
|
|
4
|
+
export { writeSnapshot, type WriteSnapshotConfig } from './writeSnapshot.js';
|
|
5
|
+
export { loadSnapshot, type LoadSnapshotConfig } from './loadSnapshot.js';
|
|
6
|
+
export { snapshotPipeline, type SnapshotPipelineConfig } from './snapshotPipeline.js';
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* loadSnapshot — read-side stage for Causal memory.
|
|
3
|
+
*
|
|
4
|
+
* Embeds the user's current question, searches the store for the most
|
|
5
|
+
* similar past run, projects the snapshot per `SnapshotProjection`,
|
|
6
|
+
* and writes the formatted result to `scope.formatted` so the
|
|
7
|
+
* downstream slot subflow injects it as a system message.
|
|
8
|
+
*
|
|
9
|
+
* Reads from scope: `identity`, `messages` (or `newMessages` fallback)
|
|
10
|
+
* Writes to scope: `formatted` — array of `LLMMessage` to inject
|
|
11
|
+
*
|
|
12
|
+
* Strict-threshold semantics:
|
|
13
|
+
* When `minScore` is set and no past snapshot meets it, returns an
|
|
14
|
+
* empty `formatted`. NO fallback — garbage past context is worse than
|
|
15
|
+
* no context.
|
|
16
|
+
*
|
|
17
|
+
* Empty-query handling:
|
|
18
|
+
* No user message → no embedding → no search → empty result.
|
|
19
|
+
*/
|
|
20
|
+
import type { TypedScope } from 'footprintjs';
|
|
21
|
+
import type { MemoryStore } from '../store/index.js';
|
|
22
|
+
import type { Embedder } from '../embedding/index.js';
|
|
23
|
+
import type { MemoryState } from '../stages/index.js';
|
|
24
|
+
import { type SnapshotProjection } from '../define.types.js';
|
|
25
|
+
export interface LoadSnapshotConfig {
|
|
26
|
+
/** Vector-capable store. Must implement `search()`. */
|
|
27
|
+
readonly store: MemoryStore;
|
|
28
|
+
/** Embedder used to vectorize the current query. */
|
|
29
|
+
readonly embedder: Embedder;
|
|
30
|
+
/** Stable id of the embedder — filters cross-model results out. */
|
|
31
|
+
readonly embedderId?: string;
|
|
32
|
+
/** Top-k snapshots to retrieve. Default 1 (most-relevant past run). */
|
|
33
|
+
readonly topK?: number;
|
|
34
|
+
/**
|
|
35
|
+
* Minimum cosine score [-1, 1]. Strict — entries below this are
|
|
36
|
+
* dropped. When no entry meets the threshold, the stage emits no
|
|
37
|
+
* messages (no fallback). Default 0.7.
|
|
38
|
+
*/
|
|
39
|
+
readonly minScore?: number;
|
|
40
|
+
/**
|
|
41
|
+
* Slice of the snapshot to project. Default `'decisions'` —
|
|
42
|
+
* decision evidence is the highest-signal field for "why" follow-ups.
|
|
43
|
+
*/
|
|
44
|
+
readonly projection?: SnapshotProjection;
|
|
45
|
+
/**
|
|
46
|
+
* Optional override for query extraction. Default: last user
|
|
47
|
+
* message in `scope.messages` (current turn's question).
|
|
48
|
+
*/
|
|
49
|
+
readonly queryFrom?: (scope: TypedScope<MemoryState>) => string;
|
|
50
|
+
}
|
|
51
|
+
export declare function loadSnapshot(config: LoadSnapshotConfig): (scope: TypedScope<MemoryState>) => Promise<void>;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* snapshotPipeline — composes `loadSnapshot` + `writeSnapshot` into a
|
|
3
|
+
* `MemoryPipeline` ready to be mounted by `defineMemory({ type: CAUSAL })`.
|
|
4
|
+
*
|
|
5
|
+
* READ : LoadSnapshot — embed query → search → project → format
|
|
6
|
+
* WRITE : WriteSnapshot — embed query → store as MemoryEntry<SnapshotEntry>
|
|
7
|
+
*
|
|
8
|
+
* The pipeline emits the same `agentfootprint.context.injected` event
|
|
9
|
+
* (with `source: 'memory'`) as every other memory flavor, so Lens
|
|
10
|
+
* shows Causal injections as memory chips alongside Episodic /
|
|
11
|
+
* Semantic / Narrative without special UI.
|
|
12
|
+
*/
|
|
13
|
+
import type { MemoryStore } from '../store/index.js';
|
|
14
|
+
import type { Embedder } from '../embedding/index.js';
|
|
15
|
+
import type { MemoryPipeline } from '../pipeline/types.js';
|
|
16
|
+
import type { SnapshotProjection } from '../define.types.js';
|
|
17
|
+
export interface SnapshotPipelineConfig {
|
|
18
|
+
/** Vector-capable store for the snapshots. Must implement `search()`. */
|
|
19
|
+
readonly store: MemoryStore;
|
|
20
|
+
/** Embedder used for both write-side indexing and read-side query. */
|
|
21
|
+
readonly embedder: Embedder;
|
|
22
|
+
/** Stable id of the embedder — prevents cross-model similarity pollution. */
|
|
23
|
+
readonly embedderId?: string;
|
|
24
|
+
/** Top-k past snapshots to consider on read. Default 1. */
|
|
25
|
+
readonly topK?: number;
|
|
26
|
+
/** Cosine threshold below which matches are dropped. Default 0.7. */
|
|
27
|
+
readonly minScore?: number;
|
|
28
|
+
/** Slice of the snapshot to inject. Default `'decisions'`. */
|
|
29
|
+
readonly projection?: SnapshotProjection;
|
|
30
|
+
/** Optional TTL for snapshots in ms. Useful for compliance windows. */
|
|
31
|
+
readonly ttlMs?: number;
|
|
32
|
+
/** Optional tier tag for written snapshots. */
|
|
33
|
+
readonly tier?: 'hot' | 'warm' | 'cold';
|
|
34
|
+
}
|
|
35
|
+
export declare function snapshotPipeline(config: SnapshotPipelineConfig): MemoryPipeline;
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Causal memory — types.
|
|
3
|
+
*
|
|
4
|
+
* A `SnapshotEntry` is the value stored in a Causal `MemoryStore`. It
|
|
5
|
+
* captures one agent run's "what happened and why" so future turns can
|
|
6
|
+
* answer follow-up questions ("why did you reject this?") with EXACT
|
|
7
|
+
* past facts instead of LLM reconstruction.
|
|
8
|
+
*
|
|
9
|
+
* Differentiator: footprintjs's `decide()`/`select()` already capture
|
|
10
|
+
* decision evidence as first-class events during traversal — we just
|
|
11
|
+
* persist them. Other libraries can't do this without rebuilding their
|
|
12
|
+
* core to surface decision evidence.
|
|
13
|
+
*
|
|
14
|
+
* Stored as `MemoryEntry<SnapshotEntry>` so the existing store layer
|
|
15
|
+
* (`MemoryStore`, `InMemoryStore`, future Redis/Dynamo/Postgres
|
|
16
|
+
* adapters) handles persistence + identity isolation + TTL + vector
|
|
17
|
+
* search out of the box.
|
|
18
|
+
*/
|
|
19
|
+
import type { LLMMessage } from '../../adapters/types.js';
|
|
20
|
+
/**
|
|
21
|
+
* One stored agent run — the unit of causal memory.
|
|
22
|
+
*
|
|
23
|
+
* Field set is INTENTIONALLY MINIMAL for now: enough to demonstrate
|
|
24
|
+
* cross-run replay + cover RL/SFT export paths later. Richer fields
|
|
25
|
+
* (full commitLog, narrative entries with depth/path) get added when
|
|
26
|
+
* an out-of-band recorder integrates `executor.getSnapshot()` directly.
|
|
27
|
+
*/
|
|
28
|
+
export interface SnapshotEntry {
|
|
29
|
+
/**
|
|
30
|
+
* The user's message at the time of the run. THIS IS WHAT GETS
|
|
31
|
+
* EMBEDDED for retrieval — new queries are matched by cosine
|
|
32
|
+
* similarity against past queries.
|
|
33
|
+
*/
|
|
34
|
+
readonly query: string;
|
|
35
|
+
/**
|
|
36
|
+
* The agent's final answer for the run. Pairs with `query` to form
|
|
37
|
+
* the (prompt, completion) pair RL/SFT exports project on.
|
|
38
|
+
*/
|
|
39
|
+
readonly finalContent: string;
|
|
40
|
+
/**
|
|
41
|
+
* Iteration count — how many ReAct loop turns the agent used to
|
|
42
|
+
* produce `finalContent`. Useful for ranking "decisive" runs vs
|
|
43
|
+
* "thrashy" ones.
|
|
44
|
+
*/
|
|
45
|
+
readonly iterations: number;
|
|
46
|
+
/**
|
|
47
|
+
* Decision records collected via `decide()`/`select()` during the
|
|
48
|
+
* run. Empty when the agent's flowchart didn't use any decision
|
|
49
|
+
* primitives. THE killer field (by design): each entry carries the rule
|
|
50
|
+
* that matched + the evidence values that satisfied it. STATUS: persisted
|
|
51
|
+
* EMPTY today — the evidence bridge (backlog #5) wires it.
|
|
52
|
+
*/
|
|
53
|
+
readonly decisions: ReadonlyArray<DecisionRecord>;
|
|
54
|
+
/**
|
|
55
|
+
* Tool calls made during the run. Each entry: tool name, args,
|
|
56
|
+
* result (truncated). Surfaces the agent's tool-use trajectory for
|
|
57
|
+
* RL training of tool-use policies.
|
|
58
|
+
*/
|
|
59
|
+
readonly toolCalls: ReadonlyArray<ToolCallRecord>;
|
|
60
|
+
/**
|
|
61
|
+
* Optional rendered narrative — when an out-of-band recorder
|
|
62
|
+
* captures `executor.getNarrative()` at write time, the full
|
|
63
|
+
* human-readable trace lands here.
|
|
64
|
+
*/
|
|
65
|
+
readonly narrative?: string;
|
|
66
|
+
/**
|
|
67
|
+
* Wall-clock duration of the run in milliseconds.
|
|
68
|
+
*/
|
|
69
|
+
readonly durationMs: number;
|
|
70
|
+
/**
|
|
71
|
+
* Cumulative token usage at end of run. Used to skip expensive
|
|
72
|
+
* snapshots from training-data exports under cost caps.
|
|
73
|
+
*/
|
|
74
|
+
readonly tokenUsage: {
|
|
75
|
+
readonly input: number;
|
|
76
|
+
readonly output: number;
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* Optional eval score attached by an `evalRecorder`. When present,
|
|
80
|
+
* exports can filter to high-quality runs for SFT or rank for DPO.
|
|
81
|
+
*/
|
|
82
|
+
readonly evalScore?: number;
|
|
83
|
+
}
|
|
84
|
+
export interface DecisionRecord {
|
|
85
|
+
/** Stage id where the decision happened (`'classify-risk'`). */
|
|
86
|
+
readonly stageId: string;
|
|
87
|
+
/** Branch chosen (`'rejected'`, `'manual-review'`). */
|
|
88
|
+
readonly chosen: string;
|
|
89
|
+
/** Optional human label of the rule that matched. */
|
|
90
|
+
readonly rule?: string;
|
|
91
|
+
/** Evidence values that led to the choice (key→value). */
|
|
92
|
+
readonly evidence?: Readonly<Record<string, unknown>>;
|
|
93
|
+
}
|
|
94
|
+
export interface ToolCallRecord {
|
|
95
|
+
/** Tool name as registered on the agent. */
|
|
96
|
+
readonly name: string;
|
|
97
|
+
/** Arguments passed to the tool. */
|
|
98
|
+
readonly args: Readonly<Record<string, unknown>>;
|
|
99
|
+
/** Result returned by the tool — TRUNCATED to keep snapshots small. */
|
|
100
|
+
readonly resultPreview: string;
|
|
101
|
+
/** True when the tool threw and the result is the error message. */
|
|
102
|
+
readonly errored: boolean;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Default truncation when serializing tool results into the snapshot.
|
|
106
|
+
* Keeps snapshot entries small enough to fit many in context during
|
|
107
|
+
* retrieval. Override per-call via `writeSnapshot` config.
|
|
108
|
+
*/
|
|
109
|
+
export declare const DEFAULT_TOOL_RESULT_PREVIEW_LEN = 500;
|
|
110
|
+
/**
|
|
111
|
+
* What `loadSnapshot` returns to the formatter — the projection slice
|
|
112
|
+
* the consumer asked for via `defineMemory({ projection })`. Each
|
|
113
|
+
* projection produces a different `LLMMessage` content layout.
|
|
114
|
+
*/
|
|
115
|
+
export interface ProjectedSnapshot {
|
|
116
|
+
readonly query: string;
|
|
117
|
+
readonly content: string;
|
|
118
|
+
readonly source: {
|
|
119
|
+
readonly entryId: string;
|
|
120
|
+
readonly score: number;
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* The shape of a single message produced from a projected snapshot.
|
|
125
|
+
* Always `system` role so the LLM treats it as authoritative context
|
|
126
|
+
* about a past run.
|
|
127
|
+
*/
|
|
128
|
+
export type SnapshotMessage = LLMMessage & {
|
|
129
|
+
readonly role: 'system';
|
|
130
|
+
};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* writeSnapshot — write-side stage for Causal memory.
|
|
3
|
+
*
|
|
4
|
+
* Captures the current run's `(query, finalContent)` pair from
|
|
5
|
+
* `scope.newMessages` (populated by the Agent's PrepareFinal stage),
|
|
6
|
+
* embeds the query for retrieval, and persists a `SnapshotEntry` to
|
|
7
|
+
* the store. Future turns can match new questions against past
|
|
8
|
+
* queries via cosine similarity to replay decision evidence.
|
|
9
|
+
*
|
|
10
|
+
* Reads from scope: `identity`, `turnNumber`, `newMessages`
|
|
11
|
+
* Writes to store: one `SnapshotEntry` per call, id = `snap-{turn}`
|
|
12
|
+
*
|
|
13
|
+
* Why per-turn (not per-iteration)?
|
|
14
|
+
* Causal memory captures TURN outcomes — "user asked X, agent said Y."
|
|
15
|
+
* Mid-iteration state isn't useful for cross-run replay.
|
|
16
|
+
*
|
|
17
|
+
* Turn derivation — collisions are impossible by construction:
|
|
18
|
+
* The effective turn is `max(scope.turnNumber, maxStoredTurn + 1)` where
|
|
19
|
+
* `maxStoredTurn` is the highest `snap-{n}` already live in THIS
|
|
20
|
+
* conversation's namespace (`identityNamespace(identity)` — the durable
|
|
21
|
+
* conversation anchor across `run()` calls, Agent instances, and
|
|
22
|
+
* processes). Rationale:
|
|
23
|
+
* - Hosts that track `turnNumber` correctly keep their numbering
|
|
24
|
+
* (`turnNumber: 5` → `snap-5`, gaps preserved).
|
|
25
|
+
* - Hosts with a stale counter (the Agent seeds `turnNumber = 1` on
|
|
26
|
+
* every run) still get a fresh, ordered id — turn 2 of the same
|
|
27
|
+
* conversation lands `snap-2` instead of silently replacing
|
|
28
|
+
* `snap-1`.
|
|
29
|
+
* Causal snapshots are decision evidence (audit/replay data): when
|
|
30
|
+
* "stale counter" and "deliberate same-turn rewrite" are
|
|
31
|
+
* indistinguishable, never destroying a prior turn's evidence wins.
|
|
32
|
+
* TTL-expired snapshots are ignored by the scan (same as every read).
|
|
33
|
+
*
|
|
34
|
+
* Empty-newMessages handling:
|
|
35
|
+
* When `newMessages` is empty (no final answer produced — e.g.
|
|
36
|
+
* pause-resume mid-flight), the stage no-ops. Re-runs after resume
|
|
37
|
+
* capture the snapshot then.
|
|
38
|
+
*
|
|
39
|
+
* @see ./types.ts for the SnapshotEntry shape this writes
|
|
40
|
+
* @see ./loadSnapshot.ts for the read-side counterpart
|
|
41
|
+
*/
|
|
42
|
+
import type { TypedScope } from 'footprintjs';
|
|
43
|
+
import type { MemoryStore } from '../store/index.js';
|
|
44
|
+
import type { Embedder } from '../embedding/index.js';
|
|
45
|
+
import type { MemoryState } from '../stages/index.js';
|
|
46
|
+
export interface WriteSnapshotConfig {
|
|
47
|
+
/** The store to persist the snapshot to. */
|
|
48
|
+
readonly store: MemoryStore;
|
|
49
|
+
/**
|
|
50
|
+
* Embedder used to vectorize the query for later cosine-search.
|
|
51
|
+
* Required — Causal memory's value comes from semantic retrieval
|
|
52
|
+
* across past runs.
|
|
53
|
+
*/
|
|
54
|
+
readonly embedder: Embedder;
|
|
55
|
+
/**
|
|
56
|
+
* Stable id for the embedder. Stored on the entry so a later
|
|
57
|
+
* embedder swap doesn't cross-pollute similarity scores.
|
|
58
|
+
* Default: `'unknown-embedder'` — pass an explicit id when you
|
|
59
|
+
* may swap embedder instances over time.
|
|
60
|
+
*/
|
|
61
|
+
readonly embedderId?: string;
|
|
62
|
+
/**
|
|
63
|
+
* TTL in milliseconds — drop snapshots after this duration. Useful
|
|
64
|
+
* for compliance ("delete causal trace after 30 days").
|
|
65
|
+
*/
|
|
66
|
+
readonly ttlMs?: number;
|
|
67
|
+
/**
|
|
68
|
+
* Tier to tag the snapshot with — typical: `'hot'` for current,
|
|
69
|
+
* `'warm'`/`'cold'` for archived. Read stages can filter by tier.
|
|
70
|
+
*/
|
|
71
|
+
readonly tier?: 'hot' | 'warm' | 'cold';
|
|
72
|
+
}
|
|
73
|
+
export declare function writeSnapshot(config: WriteSnapshotConfig): (scope: TypedScope<MemoryState>) => Promise<void>;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* defineMemory — the single factory the consumer uses to register a
|
|
3
|
+
* memory subsystem on an Agent.
|
|
4
|
+
*
|
|
5
|
+
* defineMemory({ id, type, strategy, store }) → MemoryDefinition
|
|
6
|
+
*
|
|
7
|
+
* The factory's job:
|
|
8
|
+
* 1. Switch on `type` (Episodic / Semantic / Narrative / Causal)
|
|
9
|
+
* to pick the right family of pipelines.
|
|
10
|
+
* 2. Switch on `strategy.kind` within that family to wire stage
|
|
11
|
+
* configs (loadCount / topK / threshold / extractor / ...).
|
|
12
|
+
* 3. Return an opaque `MemoryDefinition` that step-4's
|
|
13
|
+
* `Agent.memory()` builder method consumes.
|
|
14
|
+
*
|
|
15
|
+
* Pattern: Factory + Strategy (GoF). One factory, N strategies, four
|
|
16
|
+
* types — all reduce to two compiled FlowCharts (`read`,
|
|
17
|
+
* `write?`) that mount as subflows.
|
|
18
|
+
*
|
|
19
|
+
* Role: Layer-2 of the memory stack. Sits between the const-objects
|
|
20
|
+
* contract (Layer 1) and the Agent builder method (Layer 4).
|
|
21
|
+
*
|
|
22
|
+
* Emits: Indirectly — the compiled subflows emit
|
|
23
|
+
* `agentfootprint.context.injected` with `source: 'memory'`
|
|
24
|
+
* when their formatter writes to the messages slot.
|
|
25
|
+
*
|
|
26
|
+
* @see ./define.types.ts for the const-objects + types
|
|
27
|
+
* @see ./pipeline/*.ts for the existing pipeline factories this dispatches to
|
|
28
|
+
*/
|
|
29
|
+
import { type DefineMemoryOptions } from './define.types.js';
|
|
30
|
+
import type { MemoryDefinition, ReadonlyMemoryFlowChart } from './define.types.js';
|
|
31
|
+
/**
|
|
32
|
+
* Build a `MemoryDefinition` from a high-level `{ type, strategy, store }`
|
|
33
|
+
* config. Internally dispatches to one of the existing pipeline factories
|
|
34
|
+
* (defaultPipeline / semanticPipeline / factPipeline / narrativePipeline /
|
|
35
|
+
* autoPipeline / ephemeralPipeline) and wires the compiled flowcharts
|
|
36
|
+
* into the opaque definition that `Agent.memory()` consumes.
|
|
37
|
+
*
|
|
38
|
+
* Supported combinations:
|
|
39
|
+
*
|
|
40
|
+
* | type | strategy.kind | underlying pipeline |
|
|
41
|
+
* | --------- | ------------- | ------------------------ |
|
|
42
|
+
* | EPISODIC | WINDOW | defaultPipeline |
|
|
43
|
+
* | EPISODIC | BUDGET | defaultPipeline |
|
|
44
|
+
* | EPISODIC | SUMMARIZE | defaultPipeline + summarize stage |
|
|
45
|
+
* | SEMANTIC | TOP_K | semanticPipeline |
|
|
46
|
+
* | SEMANTIC | EXTRACT | factPipeline |
|
|
47
|
+
* | SEMANTIC | WINDOW | factPipeline (recency-load) |
|
|
48
|
+
* | NARRATIVE | EXTRACT | narrativePipeline |
|
|
49
|
+
* | NARRATIVE | WINDOW | narrativePipeline (recency-load) |
|
|
50
|
+
* | (any) | HYBRID | autoPipeline (when sub-strategies map cleanly) |
|
|
51
|
+
*
|
|
52
|
+
* Unsupported combinations throw with a remediation hint pointing to a
|
|
53
|
+
* working alternative or to the raw `mountMemoryRead`/`mountMemoryWrite`
|
|
54
|
+
* helpers for power users.
|
|
55
|
+
*/
|
|
56
|
+
export declare function defineMemory(options: DefineMemoryOptions): MemoryDefinition;
|
|
57
|
+
/**
|
|
58
|
+
* Internal — unwrap the brand. Used by `Agent.memory()` (step 4)
|
|
59
|
+
* to mount the pipeline. NOT exported.
|
|
60
|
+
*
|
|
61
|
+
* @internal
|
|
62
|
+
*/
|
|
63
|
+
export declare function unwrapMemoryFlowChart<T>(branded: ReadonlyMemoryFlowChart<T>): unknown;
|