agentfootprint 6.43.0 → 6.45.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ai-instructions/setup.sh +0 -0
- package/dist/core/RunnerBase.js +7 -0
- package/dist/core/RunnerBase.js.map +1 -1
- package/dist/core/agent/buildAgentChart.js +2 -1
- package/dist/core/agent/buildAgentChart.js.map +1 -1
- package/dist/core/agent/buildDynamicAgentChart.js +3 -1
- package/dist/core/agent/buildDynamicAgentChart.js.map +1 -1
- package/dist/core/agent/stages/pickEntry.js +3 -1
- package/dist/core/agent/stages/pickEntry.js.map +1 -1
- package/dist/esm/adapters/identity/agentcore.d.ts +100 -0
- package/dist/esm/adapters/llm/AnthropicProvider.d.ts +130 -0
- package/dist/esm/adapters/llm/BedrockProvider.d.ts +100 -0
- package/dist/esm/adapters/llm/BrowserAnthropicProvider.d.ts +41 -0
- package/dist/esm/adapters/llm/BrowserOpenAIProvider.d.ts +95 -0
- package/dist/esm/adapters/llm/MockProvider.d.ts +153 -0
- package/dist/esm/adapters/llm/OpenAIProvider.d.ts +220 -0
- package/dist/esm/adapters/llm/createProvider.d.ts +85 -0
- package/dist/esm/adapters/memory/agentcore.d.ts +146 -0
- package/dist/esm/adapters/memory/bedrockAgentMemory.d.ts +95 -0
- package/dist/esm/adapters/memory/redis.d.ts +127 -0
- package/dist/esm/adapters/observability/agentcore.d.ts +67 -0
- package/dist/esm/adapters/observability/audit.d.ts +254 -0
- package/dist/esm/adapters/observability/cloudwatch.d.ts +96 -0
- package/dist/esm/adapters/observability/otel.d.ts +237 -0
- package/dist/esm/adapters/observability/xray.d.ts +88 -0
- package/dist/esm/adapters/types.d.ts +378 -0
- package/dist/esm/bridge/eventMeta.d.ts +59 -0
- package/dist/esm/cache/CacheDecisionSubflow.d.ts +85 -0
- package/dist/esm/cache/CacheGateDecider.d.ts +127 -0
- package/dist/esm/cache/applyCachePolicy.d.ts +37 -0
- package/dist/esm/cache/cacheRecorder.d.ts +85 -0
- package/dist/esm/cache/index.d.ts +33 -0
- package/dist/esm/cache/strategies/AnthropicCacheStrategy.d.ts +38 -0
- package/dist/esm/cache/strategies/BedrockCacheStrategy.d.ts +33 -0
- package/dist/esm/cache/strategies/NoOpCacheStrategy.d.ts +29 -0
- package/dist/esm/cache/strategies/OpenAICacheStrategy.d.ts +36 -0
- package/dist/esm/cache/strategyRegistry.d.ts +45 -0
- package/dist/esm/cache/types.d.ts +243 -0
- package/dist/esm/conventions.d.ts +203 -0
- package/dist/esm/core/Agent.d.ts +355 -0
- package/dist/esm/core/LLMCall.d.ts +139 -0
- package/dist/esm/core/RunnerBase.d.ts +267 -0
- package/dist/esm/core/RunnerBase.js +7 -0
- package/dist/esm/core/RunnerBase.js.map +1 -1
- package/dist/esm/core/agent/AgentBuilder.d.ts +565 -0
- package/dist/esm/core/agent/buildAgentChart.d.ts +109 -0
- package/dist/esm/core/agent/buildAgentChart.js +2 -1
- package/dist/esm/core/agent/buildAgentChart.js.map +1 -1
- package/dist/esm/core/agent/buildAgentMessageApiChart.d.ts +40 -0
- package/dist/esm/core/agent/buildCacheSubflow.d.ts +35 -0
- package/dist/esm/core/agent/buildDynamicAgentChart.d.ts +56 -0
- package/dist/esm/core/agent/buildDynamicAgentChart.js +3 -1
- package/dist/esm/core/agent/buildDynamicAgentChart.js.map +1 -1
- package/dist/esm/core/agent/buildMessageApiChart.d.ts +47 -0
- package/dist/esm/core/agent/buildToolRegistry.d.ts +61 -0
- package/dist/esm/core/agent/memoryRecallInjections.d.ts +8 -0
- package/dist/esm/core/agent/stages/breakFinal.d.ts +22 -0
- package/dist/esm/core/agent/stages/callLLM.d.ts +74 -0
- package/dist/esm/core/agent/stages/pickEntry.d.ts +19 -0
- package/dist/esm/core/agent/stages/pickEntry.js +3 -1
- package/dist/esm/core/agent/stages/pickEntry.js.map +1 -1
- package/dist/esm/core/agent/stages/prepareFinal.d.ts +19 -0
- package/dist/esm/core/agent/stages/reliabilityExecution.d.ts +135 -0
- package/dist/esm/core/agent/stages/route.d.ts +18 -0
- package/dist/esm/core/agent/stages/seed.d.ts +53 -0
- package/dist/esm/core/agent/stages/toolCalls.d.ts +76 -0
- package/dist/esm/core/agent/toolArgsValidation.d.ts +62 -0
- package/dist/esm/core/agent/types.d.ts +382 -0
- package/dist/esm/core/agent/validators.d.ts +52 -0
- package/dist/esm/core/cost.d.ts +38 -0
- package/dist/esm/core/flowchartAsTool.d.ts +200 -0
- package/dist/esm/core/humanizeLLMError.d.ts +23 -0
- package/dist/esm/core/outputFallback.d.ts +139 -0
- package/dist/esm/core/outputSchema.d.ts +127 -0
- package/dist/esm/core/pause.d.ts +74 -0
- package/dist/esm/core/runCheckpoint.d.ts +179 -0
- package/dist/esm/core/runner.d.ts +203 -0
- package/dist/esm/core/slots/buildMessagesSlot.d.ts +40 -0
- package/dist/esm/core/slots/buildSystemPromptSlot.d.ts +41 -0
- package/dist/esm/core/slots/buildThinkingSubflow.d.ts +40 -0
- package/dist/esm/core/slots/buildToolsSlot.d.ts +60 -0
- package/dist/esm/core/slots/helpers.d.ts +27 -0
- package/dist/esm/core/toolContract.d.ts +43 -0
- package/dist/esm/core/tools.d.ts +90 -0
- package/dist/esm/core/translator.d.ts +94 -0
- package/dist/esm/core-flow/Conditional.d.ts +119 -0
- package/dist/esm/core-flow/Loop.d.ts +160 -0
- package/dist/esm/core-flow/Parallel.d.ts +360 -0
- package/dist/esm/core-flow/Sequence.d.ts +133 -0
- package/dist/esm/events/dispatcher.d.ts +134 -0
- package/dist/esm/events/payloads.d.ts +761 -0
- package/dist/esm/events/registry.d.ts +198 -0
- package/dist/esm/events/types.d.ts +70 -0
- package/dist/esm/identity/kinds.d.ts +36 -0
- package/dist/esm/identity/staticTokens.d.ts +28 -0
- package/dist/esm/identity/types.d.ts +113 -0
- package/dist/esm/identity/withCredentialRetry.d.ts +64 -0
- package/dist/esm/identity.d.ts +31 -0
- package/dist/esm/index.d.ts +64 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/injection-engine.d.ts +4 -0
- package/dist/esm/lib/canonicalJson.d.ts +56 -0
- package/dist/esm/lib/context-bisect/ablation.d.ts +109 -0
- package/dist/esm/lib/context-bisect/bisect.d.ts +75 -0
- package/dist/esm/lib/context-bisect/cost.d.ts +37 -0
- package/dist/esm/lib/context-bisect/index.d.ts +31 -0
- package/dist/esm/lib/context-bisect/index.js +3 -0
- package/dist/esm/lib/context-bisect/index.js.map +1 -1
- package/dist/esm/lib/context-bisect/llmEdgeWeigher.d.ts +124 -0
- package/dist/esm/lib/context-bisect/localize.d.ts +152 -0
- package/dist/esm/lib/context-bisect/localize.js +2 -0
- package/dist/esm/lib/context-bisect/localize.js.map +1 -1
- package/dist/esm/lib/context-bisect/loop-recall.d.ts +97 -0
- package/dist/esm/lib/context-bisect/missingContext.d.ts +71 -0
- package/dist/esm/lib/context-bisect/restoration.d.ts +39 -0
- package/dist/esm/lib/context-bisect/toBacktrackTrace.d.ts +138 -0
- package/dist/esm/lib/context-bisect/trajectory.d.ts +168 -0
- package/dist/esm/lib/context-bisect/types.d.ts +448 -0
- package/dist/esm/lib/context-bisect/walk-to-root.d.ts +103 -0
- package/dist/esm/lib/influence-core/attributability.d.ts +72 -0
- package/dist/esm/lib/influence-core/cache.d.ts +94 -0
- package/dist/esm/lib/influence-core/contrastive.d.ts +26 -0
- package/dist/esm/lib/influence-core/index.d.ts +34 -0
- package/dist/esm/lib/influence-core/margin.d.ts +33 -0
- package/dist/esm/lib/influence-core/signals.d.ts +128 -0
- package/dist/esm/lib/influence-core/similarity.d.ts +25 -0
- package/dist/esm/lib/influence-core/types.d.ts +252 -0
- package/dist/esm/lib/injection-engine/SkillRegistry.d.ts +147 -0
- package/dist/esm/lib/injection-engine/buildInjectionEngineSubflow.d.ts +110 -0
- package/dist/esm/lib/injection-engine/buildInjectionEngineSubflow.js +1 -0
- package/dist/esm/lib/injection-engine/buildInjectionEngineSubflow.js.map +1 -1
- package/dist/esm/lib/injection-engine/entryScorer.d.ts +93 -0
- package/dist/esm/lib/injection-engine/entryScorer.js +172 -0
- package/dist/esm/lib/injection-engine/entryScorer.js.map +1 -0
- package/dist/esm/lib/injection-engine/evaluator.d.ts +24 -0
- package/dist/esm/lib/injection-engine/factories/defineFact.d.ts +60 -0
- package/dist/esm/lib/injection-engine/factories/defineInjection.d.ts +41 -0
- package/dist/esm/lib/injection-engine/factories/defineInstruction.d.ts +78 -0
- package/dist/esm/lib/injection-engine/factories/defineRelevanceHint.d.ts +26 -0
- package/dist/esm/lib/injection-engine/factories/defineSkill.d.ts +160 -0
- package/dist/esm/lib/injection-engine/factories/defineSteering.d.ts +39 -0
- package/dist/esm/lib/injection-engine/index.d.ts +22 -0
- package/dist/esm/lib/injection-engine/index.js +1 -0
- package/dist/esm/lib/injection-engine/index.js.map +1 -1
- package/dist/esm/lib/injection-engine/skillContract.d.ts +29 -0
- package/dist/esm/lib/injection-engine/skillGraph.d.ts +289 -0
- package/dist/esm/lib/injection-engine/skillGraph.js +35 -41
- package/dist/esm/lib/injection-engine/skillGraph.js.map +1 -1
- package/dist/esm/lib/injection-engine/skillGraphCheckup.d.ts +49 -0
- package/dist/esm/lib/injection-engine/skillTools.d.ts +72 -0
- package/dist/esm/lib/injection-engine/softmax.d.ts +11 -0
- package/dist/esm/lib/injection-engine/types.d.ts +229 -0
- package/dist/esm/lib/injection-engine/types.js.map +1 -1
- package/dist/esm/lib/lazyRequire.d.ts +29 -0
- package/dist/esm/lib/mcp/index.d.ts +9 -0
- package/dist/esm/lib/mcp/mcpClient.d.ts +46 -0
- package/dist/esm/lib/mcp/mockMcpClient.d.ts +65 -0
- package/dist/esm/lib/mcp/types.d.ts +133 -0
- package/dist/esm/lib/rag/defineRAG.d.ts +139 -0
- package/dist/esm/lib/rag/index.d.ts +7 -0
- package/dist/esm/lib/rag/indexDocuments.d.ts +105 -0
- package/dist/esm/lib/tool-lint/analyze.d.ts +83 -0
- package/dist/esm/lib/tool-lint/cli.d.ts +43 -0
- package/dist/esm/lib/tool-lint/format.d.ts +18 -0
- package/dist/esm/lib/tool-lint/index.d.ts +23 -0
- package/dist/esm/lib/tool-lint/rules.d.ts +85 -0
- package/dist/esm/lib/tool-lint/types.d.ts +155 -0
- package/dist/esm/lib/trace-toolpack/bounded.d.ts +47 -0
- package/dist/esm/lib/trace-toolpack/debugPrompt.d.ts +19 -0
- package/dist/esm/lib/trace-toolpack/index.d.ts +20 -0
- package/dist/esm/lib/trace-toolpack/lazyToolpack.d.ts +35 -0
- package/dist/esm/lib/trace-toolpack/selfExplain.d.ts +100 -0
- package/dist/esm/lib/trace-toolpack/traceDebugAgent.d.ts +42 -0
- package/dist/esm/lib/trace-toolpack/traceToolpack.d.ts +69 -0
- package/dist/esm/lib/trace-toolpack/types.d.ts +59 -0
- package/dist/esm/llm-providers.d.ts +26 -0
- package/dist/esm/locales/index.d.ts +132 -0
- package/dist/esm/memory/beats/extractBeats.d.ts +61 -0
- package/dist/esm/memory/beats/extractor.d.ts +47 -0
- package/dist/esm/memory/beats/formatAsNarrative.d.ts +62 -0
- package/dist/esm/memory/beats/heuristicExtractor.d.ts +37 -0
- package/dist/esm/memory/beats/index.d.ts +12 -0
- package/dist/esm/memory/beats/llmExtractor.d.ts +56 -0
- package/dist/esm/memory/beats/types.d.ts +60 -0
- package/dist/esm/memory/beats/writeBeats.d.ts +22 -0
- package/dist/esm/memory/causal/evidenceRecorder.d.ts +66 -0
- package/dist/esm/memory/causal/index.d.ts +6 -0
- package/dist/esm/memory/causal/loadSnapshot.d.ts +51 -0
- package/dist/esm/memory/causal/snapshotPipeline.d.ts +35 -0
- package/dist/esm/memory/causal/types.d.ts +130 -0
- package/dist/esm/memory/causal/writeSnapshot.d.ts +73 -0
- package/dist/esm/memory/define.d.ts +63 -0
- package/dist/esm/memory/define.types.d.ts +276 -0
- package/dist/esm/memory/define.types.js +1 -1
- package/dist/esm/memory/embedding/cosine.d.ts +18 -0
- package/dist/esm/memory/embedding/embedMessages.d.ts +58 -0
- package/dist/esm/memory/embedding/index.d.ts +8 -0
- package/dist/esm/memory/embedding/loadRelevant.d.ts +51 -0
- package/dist/esm/memory/embedding/mockEmbedder.d.ts +22 -0
- package/dist/esm/memory/embedding/types.d.ts +46 -0
- package/dist/esm/memory/entry/decay.d.ts +36 -0
- package/dist/esm/memory/entry/index.d.ts +2 -0
- package/dist/esm/memory/entry/types.d.ts +140 -0
- package/dist/esm/memory/facts/extractFacts.d.ts +50 -0
- package/dist/esm/memory/facts/extractor.d.ts +33 -0
- package/dist/esm/memory/facts/formatFacts.d.ts +60 -0
- package/dist/esm/memory/facts/index.d.ts +14 -0
- package/dist/esm/memory/facts/llmFactExtractor.d.ts +64 -0
- package/dist/esm/memory/facts/loadFacts.d.ts +43 -0
- package/dist/esm/memory/facts/patternFactExtractor.d.ts +2 -0
- package/dist/esm/memory/facts/types.d.ts +68 -0
- package/dist/esm/memory/facts/writeFacts.d.ts +19 -0
- package/dist/esm/memory/identity/index.d.ts +2 -0
- package/dist/esm/memory/identity/types.d.ts +49 -0
- package/dist/esm/memory/index.d.ts +19 -0
- package/dist/esm/memory/pipeline/auto.d.ts +59 -0
- package/dist/esm/memory/pipeline/default.d.ts +49 -0
- package/dist/esm/memory/pipeline/ephemeral.d.ts +28 -0
- package/dist/esm/memory/pipeline/fact.d.ts +26 -0
- package/dist/esm/memory/pipeline/index.d.ts +13 -0
- package/dist/esm/memory/pipeline/narrative.d.ts +35 -0
- package/dist/esm/memory/pipeline/semantic.d.ts +37 -0
- package/dist/esm/memory/pipeline/types.d.ts +31 -0
- package/dist/esm/memory/stages/formatDefault.d.ts +64 -0
- package/dist/esm/memory/stages/index.d.ts +13 -0
- package/dist/esm/memory/stages/loadRecent.d.ts +49 -0
- package/dist/esm/memory/stages/pickByBudget.d.ts +63 -0
- package/dist/esm/memory/stages/summarize.d.ts +87 -0
- package/dist/esm/memory/stages/tokenize.d.ts +43 -0
- package/dist/esm/memory/stages/types.d.ts +75 -0
- package/dist/esm/memory/stages/writeMessages.d.ts +71 -0
- package/dist/esm/memory/store/InMemoryStore.d.ts +62 -0
- package/dist/esm/memory/store/index.d.ts +2 -0
- package/dist/esm/memory/store/types.d.ts +223 -0
- package/dist/esm/memory/wire/index.d.ts +2 -0
- package/dist/esm/memory/wire/mountMemoryPipeline.d.ts +108 -0
- package/dist/esm/memory-providers.d.ts +37 -0
- package/dist/esm/observability/contextError/finders/compareFinders.d.ts +19 -0
- package/dist/esm/observability/contextError/finders/index.d.ts +22 -0
- package/dist/esm/observability/contextError/finders/rankSuspects.d.ts +2 -0
- package/dist/esm/observability/contextError/finders/removeAndRetry.d.ts +11 -0
- package/dist/esm/observability/contextError/finders/shrinkToCause.d.ts +11 -0
- package/dist/esm/observability/contextError/finders/testManyCombos.d.ts +11 -0
- package/dist/esm/observability/contextError/finders/traceSteps.d.ts +2 -0
- package/dist/esm/observability/contextError/finders/types.d.ts +88 -0
- package/dist/esm/observability-providers.d.ts +46 -0
- package/dist/esm/observe.d.ts +62 -0
- package/dist/esm/observe.js +7 -1
- package/dist/esm/observe.js.map +1 -1
- package/dist/esm/patterns/Debate.d.ts +39 -0
- package/dist/esm/patterns/MapReduce.d.ts +66 -0
- package/dist/esm/patterns/Reflection.d.ts +51 -0
- package/dist/esm/patterns/SelfConsistency.d.ts +43 -0
- package/dist/esm/patterns/Swarm.d.ts +60 -0
- package/dist/esm/patterns/ToT.d.ts +53 -0
- package/dist/esm/patterns/index.d.ts +22 -0
- package/dist/esm/providers.d.ts +33 -0
- package/dist/esm/recorders/core/AgentRecorder.d.ts +15 -0
- package/dist/esm/recorders/core/CompositionRecorder.d.ts +17 -0
- package/dist/esm/recorders/core/ContextEvaluatedRecorder.d.ts +23 -0
- package/dist/esm/recorders/core/ContextRecorder.d.ts +47 -0
- package/dist/esm/recorders/core/CostRecorder.d.ts +14 -0
- package/dist/esm/recorders/core/EmitBridge.d.ts +30 -0
- package/dist/esm/recorders/core/ErrorBridge.d.ts +38 -0
- package/dist/esm/recorders/core/EvalRecorder.d.ts +16 -0
- package/dist/esm/recorders/core/MemoryRecorder.d.ts +17 -0
- package/dist/esm/recorders/core/PermissionRecorder.d.ts +16 -0
- package/dist/esm/recorders/core/ReliabilityRecorder.d.ts +24 -0
- package/dist/esm/recorders/core/SkillRecorder.d.ts +14 -0
- package/dist/esm/recorders/core/StreamRecorder.d.ts +15 -0
- package/dist/esm/recorders/core/ToolsRecorder.d.ts +18 -0
- package/dist/esm/recorders/core/ValidationRecorder.d.ts +16 -0
- package/dist/esm/recorders/core/contextEngineering.d.ts +136 -0
- package/dist/esm/recorders/core/typedEmit.d.ts +34 -0
- package/dist/esm/recorders/core/types.d.ts +97 -0
- package/dist/esm/recorders/observability/AgentThinkingTraceRecorder.d.ts +117 -0
- package/dist/esm/recorders/observability/BoundaryRecorder.d.ts +546 -0
- package/dist/esm/recorders/observability/FlowchartRecorder.d.ts +220 -0
- package/dist/esm/recorders/observability/FlowchartRecorder.js +10 -2
- package/dist/esm/recorders/observability/FlowchartRecorder.js.map +1 -1
- package/dist/esm/recorders/observability/LiveStateRecorder.d.ts +250 -0
- package/dist/esm/recorders/observability/LoggingRecorder.d.ts +91 -0
- package/dist/esm/recorders/observability/RouteRecorder.d.ts +83 -0
- package/dist/esm/recorders/observability/RunStepRecorder.d.ts +231 -0
- package/dist/esm/recorders/observability/StatusRecorder.d.ts +36 -0
- package/dist/esm/recorders/observability/ToolChoiceRecorder.d.ts +164 -0
- package/dist/esm/recorders/observability/ToolLineageRecorder.d.ts +71 -0
- package/dist/esm/recorders/observability/commentary/commentaryTemplates.d.ts +105 -0
- package/dist/esm/recorders/observability/internal/ActorArrowClassifier.d.ts +25 -0
- package/dist/esm/recorders/observability/internal/CandidateAnswerBuffer.d.ts +28 -0
- package/dist/esm/recorders/observability/internal/ForkTracker.d.ts +60 -0
- package/dist/esm/recorders/observability/internal/RootInferrer.d.ts +51 -0
- package/dist/esm/recorders/observability/internal/SequenceSiblingTracker.d.ts +24 -0
- package/dist/esm/recorders/observability/localObservability.d.ts +48 -0
- package/dist/esm/recorders/observability/localObservability.js +54 -0
- package/dist/esm/recorders/observability/localObservability.js.map +1 -0
- package/dist/esm/recorders/observability/observeRunId.d.ts +36 -0
- package/dist/esm/recorders/observability/status/statusTemplates.d.ts +106 -0
- package/dist/esm/recorders/observability/trace.d.ts +119 -0
- package/dist/esm/recorders/observability/trace.js +99 -0
- package/dist/esm/recorders/observability/trace.js.map +1 -0
- package/dist/esm/reliability/CircuitBreaker.d.ts +75 -0
- package/dist/esm/reliability/buildReliabilityGateChart.d.ts +53 -0
- package/dist/esm/reliability/classifyError.d.ts +28 -0
- package/dist/esm/reliability/index.d.ts +35 -0
- package/dist/esm/reliability/types.d.ts +327 -0
- package/dist/esm/resilience/fallbackProvider.d.ts +33 -0
- package/dist/esm/resilience/index.d.ts +21 -0
- package/dist/esm/resilience/withCircuitBreaker.d.ts +129 -0
- package/dist/esm/resilience/withFallback.d.ts +45 -0
- package/dist/esm/resilience/withRetry.d.ts +71 -0
- package/dist/esm/security/PermissionPolicy.d.ts +124 -0
- package/dist/esm/security/PolicyHaltError.d.ts +72 -0
- package/dist/esm/security/extractSequence.d.ts +46 -0
- package/dist/esm/security/index.d.ts +44 -0
- package/dist/esm/security/thinkingRedaction.d.ts +50 -0
- package/dist/esm/status.d.ts +48 -0
- package/dist/esm/strategies/attach.d.ts +47 -0
- package/dist/esm/strategies/compose.d.ts +48 -0
- package/dist/esm/strategies/defaults/chatBubbleLiveStatus.d.ts +36 -0
- package/dist/esm/strategies/defaults/consoleObservability.d.ts +42 -0
- package/dist/esm/strategies/defaults/inMemorySinkCost.d.ts +50 -0
- package/dist/esm/strategies/defaults/index.d.ts +30 -0
- package/dist/esm/strategies/defaults/noopLens.d.ts +28 -0
- package/dist/esm/strategies/index.d.ts +36 -0
- package/dist/esm/strategies/registry.d.ts +70 -0
- package/dist/esm/strategies/types.d.ts +303 -0
- package/dist/esm/stream.d.ts +82 -0
- package/dist/esm/thinking/AnthropicThinkingHandler.d.ts +42 -0
- package/dist/esm/thinking/MockThinkingHandler.d.ts +50 -0
- package/dist/esm/thinking/OpenAIThinkingHandler.d.ts +37 -0
- package/dist/esm/thinking/index.d.ts +51 -0
- package/dist/esm/thinking/registry.d.ts +33 -0
- package/dist/esm/thinking/types.d.ts +162 -0
- package/dist/esm/tool-providers/gatedTools.d.ts +36 -0
- package/dist/esm/tool-providers/index.d.ts +41 -0
- package/dist/esm/tool-providers/skillScopedTools.d.ts +45 -0
- package/dist/esm/tool-providers/staticTools.d.ts +21 -0
- package/dist/esm/tool-providers/types.d.ts +138 -0
- package/dist/index.js +6 -2
- package/dist/index.js.map +1 -1
- package/dist/lib/context-bisect/index.js +3 -0
- package/dist/lib/context-bisect/index.js.map +1 -1
- package/dist/lib/context-bisect/localize.js +2 -0
- package/dist/lib/context-bisect/localize.js.map +1 -1
- package/dist/lib/injection-engine/buildInjectionEngineSubflow.js +1 -0
- package/dist/lib/injection-engine/buildInjectionEngineSubflow.js.map +1 -1
- package/dist/lib/injection-engine/entryScorer.js +178 -0
- package/dist/lib/injection-engine/entryScorer.js.map +1 -0
- package/dist/lib/injection-engine/index.js +5 -1
- package/dist/lib/injection-engine/index.js.map +1 -1
- package/dist/lib/injection-engine/skillGraph.js +35 -41
- package/dist/lib/injection-engine/skillGraph.js.map +1 -1
- package/dist/lib/injection-engine/types.js.map +1 -1
- package/dist/memory/define.types.js +1 -1
- package/dist/observe.js +14 -3
- package/dist/observe.js.map +1 -1
- package/dist/recorders/observability/FlowchartRecorder.js +12 -3
- package/dist/recorders/observability/FlowchartRecorder.js.map +1 -1
- package/dist/recorders/observability/localObservability.js +58 -0
- package/dist/recorders/observability/localObservability.js.map +1 -0
- package/dist/recorders/observability/trace.js +105 -0
- package/dist/recorders/observability/trace.js.map +1 -0
- package/dist/types/core/RunnerBase.d.ts.map +1 -1
- package/dist/types/core/agent/buildAgentChart.d.ts.map +1 -1
- package/dist/types/core/agent/buildDynamicAgentChart.d.ts.map +1 -1
- package/dist/types/core/agent/stages/pickEntry.d.ts.map +1 -1
- package/dist/types/core/agent/types.d.ts +8 -4
- package/dist/types/core/agent/types.d.ts.map +1 -1
- package/dist/types/core/runner.d.ts +12 -0
- package/dist/types/core/runner.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/lib/context-bisect/index.d.ts +3 -0
- package/dist/types/lib/context-bisect/index.d.ts.map +1 -1
- package/dist/types/lib/context-bisect/localize.d.ts +2 -0
- package/dist/types/lib/context-bisect/localize.d.ts.map +1 -1
- package/dist/types/lib/injection-engine/buildInjectionEngineSubflow.d.ts.map +1 -1
- package/dist/types/lib/injection-engine/entryScorer.d.ts +94 -0
- package/dist/types/lib/injection-engine/entryScorer.d.ts.map +1 -0
- package/dist/types/lib/injection-engine/index.d.ts +1 -0
- package/dist/types/lib/injection-engine/index.d.ts.map +1 -1
- package/dist/types/lib/injection-engine/skillGraph.d.ts +21 -24
- package/dist/types/lib/injection-engine/skillGraph.d.ts.map +1 -1
- package/dist/types/lib/injection-engine/types.d.ts +9 -4
- package/dist/types/lib/injection-engine/types.d.ts.map +1 -1
- package/dist/types/memory/define.types.d.ts +1 -1
- package/dist/types/observe.d.ts +3 -1
- package/dist/types/observe.d.ts.map +1 -1
- package/dist/types/recorders/observability/FlowchartRecorder.d.ts +8 -1
- package/dist/types/recorders/observability/FlowchartRecorder.d.ts.map +1 -1
- package/dist/types/recorders/observability/localObservability.d.ts +49 -0
- package/dist/types/recorders/observability/localObservability.d.ts.map +1 -0
- package/dist/types/recorders/observability/trace.d.ts +120 -0
- package/dist/types/recorders/observability/trace.d.ts.map +1 -0
- package/package.json +203 -56
|
@@ -0,0 +1,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>;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* summarize — stage that compresses old loaded entries into a single
|
|
3
|
+
* summary entry, preserving the most-recent N verbatim.
|
|
4
|
+
*
|
|
5
|
+
* Reads from scope: `loaded`
|
|
6
|
+
* Writes to scope: `loaded` (mutated: oldest entries replaced by one
|
|
7
|
+
* synthetic summary entry)
|
|
8
|
+
*
|
|
9
|
+
* Where this fits in the pipeline:
|
|
10
|
+
*
|
|
11
|
+
* loadRecent → summarize → pickByBudget → formatDefault
|
|
12
|
+
*
|
|
13
|
+
* After `summarize` runs, `loaded` is smaller (fewer entries, one of
|
|
14
|
+
* which is a synthetic summary). The picker then selects from this
|
|
15
|
+
* reduced set using the standard budget logic.
|
|
16
|
+
*
|
|
17
|
+
* ## Determinism contract (Anthropic-reviewer ask)
|
|
18
|
+
*
|
|
19
|
+
* For prompt caching to stay stable across runs, the summary content
|
|
20
|
+
* MUST be the same each time for the same input. This requires:
|
|
21
|
+
*
|
|
22
|
+
* 1. Temperature = 0 on the provided LLM.
|
|
23
|
+
* 2. A stable seed if the provider supports it (Anthropic: omit;
|
|
24
|
+
* OpenAI: pass a fixed `seed` in the request).
|
|
25
|
+
* 3. Same system prompt + message set produces same output.
|
|
26
|
+
*
|
|
27
|
+
* The stage CANNOT enforce this — it just calls the caller-supplied
|
|
28
|
+
* `llm` function. Callers are responsible for configuring determinism.
|
|
29
|
+
* Non-deterministic summarizers still work but invalidate prompt caches
|
|
30
|
+
* on every turn (~5× token-cost increase on cache-enabled providers).
|
|
31
|
+
*
|
|
32
|
+
* ## When summarize does NOT fire
|
|
33
|
+
*
|
|
34
|
+
* - `loaded.length < triggerMinEntries` → no-op (not enough history).
|
|
35
|
+
* - `loaded.length <= preserveRecent` → no-op (nothing to summarize; all
|
|
36
|
+
* entries would be preserved verbatim anyway).
|
|
37
|
+
* - LLM call throws → error propagates to the pipeline's executor
|
|
38
|
+
* (fail-loud, per loadRecent / writeMessages convention).
|
|
39
|
+
*
|
|
40
|
+
* ## Config guidance
|
|
41
|
+
*
|
|
42
|
+
* Choose `triggerMinEntries - preserveRecent >= 2`. Below that, a firing
|
|
43
|
+
* summarizer would compress just one entry — wasted LLM call with no
|
|
44
|
+
* real compression. Defaults (trigger 20, preserve 5) summarize 15
|
|
45
|
+
* entries when firing, which is a meaningful compression ratio.
|
|
46
|
+
*
|
|
47
|
+
* ## Summary entry shape
|
|
48
|
+
*
|
|
49
|
+
* The synthetic entry replaces the summarized range. It has:
|
|
50
|
+
* - `id`: `summary-{earliest_turn}-to-{latest_turn}`
|
|
51
|
+
* - `value`: a `{role: 'system', content: summaryText}` message
|
|
52
|
+
* - `source.turn`: the LATEST turn that was summarized (for sorting)
|
|
53
|
+
* - `tier`: 'cold' (marks it as "condensed, may not be recent")
|
|
54
|
+
* - `source.identity`: carried over from the summarized range's first entry
|
|
55
|
+
*/
|
|
56
|
+
import type { TypedScope } from 'footprintjs';
|
|
57
|
+
import type { LLMMessage as Message } from '../../adapters/types.js';
|
|
58
|
+
import type { MemoryState } from './types.js';
|
|
59
|
+
export interface SummarizeConfig {
|
|
60
|
+
/**
|
|
61
|
+
* LLM callback. Receives the chronological messages to summarize;
|
|
62
|
+
* must return the summary text. Caller is responsible for configuring
|
|
63
|
+
* the underlying model (temperature=0, seed, system prompt, etc.) to
|
|
64
|
+
* keep the output deterministic — see "Determinism contract" above.
|
|
65
|
+
*/
|
|
66
|
+
readonly llm: (messages: readonly Message[]) => Promise<string>;
|
|
67
|
+
/**
|
|
68
|
+
* Minimum `loaded.length` before summarization triggers. Below this,
|
|
69
|
+
* no-op — the conversation is short enough to keep verbatim. Default 20.
|
|
70
|
+
*/
|
|
71
|
+
readonly triggerMinEntries?: number;
|
|
72
|
+
/**
|
|
73
|
+
* Number of most-recent entries to preserve verbatim (NOT summarized).
|
|
74
|
+
* The oldest `loaded.length - preserveRecent` entries become a single
|
|
75
|
+
* summary entry. Default 5 — keeps recent turns intact so the agent
|
|
76
|
+
* can reference specific phrasing.
|
|
77
|
+
*/
|
|
78
|
+
readonly preserveRecent?: number;
|
|
79
|
+
/**
|
|
80
|
+
* Optional custom system prompt for the summarizer. Default is a
|
|
81
|
+
* neutral "summarize the following conversation..." instruction.
|
|
82
|
+
* Override for domain-specific summaries (e.g., "preserve all
|
|
83
|
+
* refund-related details").
|
|
84
|
+
*/
|
|
85
|
+
readonly systemPrompt?: string;
|
|
86
|
+
}
|
|
87
|
+
export declare function summarize(config: SummarizeConfig): (scope: TypedScope<MemoryState>) => Promise<void>;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* tokenize — approximate token counter for budget-aware memory stages.
|
|
3
|
+
*
|
|
4
|
+
* Memory stages need to answer "how many tokens does this content cost?"
|
|
5
|
+
* to decide what fits in a budget. A real tokenizer (tiktoken, Anthropic's
|
|
6
|
+
* tokenizer, etc.) is accurate but:
|
|
7
|
+
*
|
|
8
|
+
* - Adds a dependency (tiktoken is ~2MB, has WASM loading quirks).
|
|
9
|
+
* - Differs per model family (Claude counts differently from GPT).
|
|
10
|
+
* - Pulls frontend bundles from small to huge.
|
|
11
|
+
*
|
|
12
|
+
* Phase 1 uses a deterministic approximation: 1 token ≈ 4 characters of
|
|
13
|
+
* English text. The constant comes from OpenAI's own documentation and
|
|
14
|
+
* is within ~15% for typical chat content. For "how much memory can I
|
|
15
|
+
* inject into an 8K context", 15% is fine.
|
|
16
|
+
*
|
|
17
|
+
* Consumers who need exact counts pass their own `TokenCounter` through
|
|
18
|
+
* the pipeline config. When that lands (Phase 2), this default stays as
|
|
19
|
+
* the dependency-free baseline.
|
|
20
|
+
*/
|
|
21
|
+
import type { LLMMessage as Message } from '../../adapters/types.js';
|
|
22
|
+
/** A function that returns the token count of a string. */
|
|
23
|
+
export type TokenCounter = (text: string) => number;
|
|
24
|
+
/**
|
|
25
|
+
* Default approximation — 1 token per ~4 characters. Low-accuracy,
|
|
26
|
+
* zero-dependency, deterministic (same input → same count). Good enough
|
|
27
|
+
* for budget-based decisions; replace via pipeline config for accuracy.
|
|
28
|
+
*
|
|
29
|
+
* Accuracy notes:
|
|
30
|
+
* - ASCII English: within ~15% of tiktoken.
|
|
31
|
+
* - CJK / emoji / heavy unicode: can undercount by ~2× because
|
|
32
|
+
* `String.length` counts UTF-16 code units, and CJK chars often
|
|
33
|
+
* take multiple tokens each. Use a real tokenizer for these workloads.
|
|
34
|
+
* - Code / JSON: reasonably accurate (punctuation-heavy is ~4 chars/tok).
|
|
35
|
+
*/
|
|
36
|
+
export declare const approximateTokenCounter: TokenCounter;
|
|
37
|
+
/**
|
|
38
|
+
* Count tokens in a single message. Handles string content and the
|
|
39
|
+
* content-block array variant (where each block has its own text field).
|
|
40
|
+
* Non-text blocks (tool calls, images) contribute a small constant to
|
|
41
|
+
* reflect their structural cost.
|
|
42
|
+
*/
|
|
43
|
+
export declare function countMessageTokens(message: Message, counter?: TokenCounter): number;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MemoryState — shared scope for every stage in a memory pipeline.
|
|
3
|
+
*
|
|
4
|
+
* Each stage reads some fields and writes others; the pipeline's narrative
|
|
5
|
+
* shows who wrote what. Fields are added as layers need them — this is the
|
|
6
|
+
* minimal shape for Layer 2 (load + write stages). Layer 3 will add
|
|
7
|
+
* `candidates`, `selected`, `formatted`; Layer 8 will add summarization
|
|
8
|
+
* fields. Every field is optional so pipelines can mix stages freely.
|
|
9
|
+
*
|
|
10
|
+
* Shape design: fields cluster by pipeline direction.
|
|
11
|
+
* - `identity` / `turnNumber` / `contextTokensRemaining` are INPUTS
|
|
12
|
+
* set by the wire layer before the pipeline runs.
|
|
13
|
+
* - `loaded` is the READ-SIDE output.
|
|
14
|
+
* - `newMessages` is the WRITE-SIDE input.
|
|
15
|
+
* - (later layers: `candidates`, `selected`, `formatted`, `saveBatch`)
|
|
16
|
+
*/
|
|
17
|
+
import type { MemoryIdentity } from '../identity/index.js';
|
|
18
|
+
import type { MemoryEntry } from '../entry/index.js';
|
|
19
|
+
import type { LLMMessage as Message } from '../../adapters/types.js';
|
|
20
|
+
export interface MemoryState {
|
|
21
|
+
/**
|
|
22
|
+
* Scoping for every storage call this pipeline makes. Wire layer
|
|
23
|
+
* populates this before the pipeline runs; stages MUST NOT mutate it.
|
|
24
|
+
*/
|
|
25
|
+
readonly identity: MemoryIdentity;
|
|
26
|
+
/**
|
|
27
|
+
* Run-local turn counter — 1 for the first `agent.run`, 2 for the second,
|
|
28
|
+
* and so on within the same conversationId. Written into `MemoryEntry.source`
|
|
29
|
+
* by write-side stages for provenance.
|
|
30
|
+
*/
|
|
31
|
+
readonly turnNumber: number;
|
|
32
|
+
/**
|
|
33
|
+
* Context-window pressure signal (MemGPT-reviewer ask). Populated by the
|
|
34
|
+
* wire layer with `model.contextWindow - tokensUsedSoFar`. Picker stages
|
|
35
|
+
* (Layer 3) use this to decide how much memory to inject.
|
|
36
|
+
*
|
|
37
|
+
* 0 or negative values should be treated by consumers as "no headroom" —
|
|
38
|
+
* stages typically skip or truncate memory injection in that case.
|
|
39
|
+
*/
|
|
40
|
+
readonly contextTokensRemaining: number;
|
|
41
|
+
/**
|
|
42
|
+
* Read-side output: entries loaded from the store this turn. Stages
|
|
43
|
+
* typically APPEND rather than replace so multiple load stages can
|
|
44
|
+
* contribute (e.g. recent-messages + semantic-retrieval + facts).
|
|
45
|
+
*/
|
|
46
|
+
loaded: MemoryEntry<Message>[];
|
|
47
|
+
/**
|
|
48
|
+
* Picker output — the subset of `loaded` that fits the context budget,
|
|
49
|
+
* in chronological order (oldest first). Format stages consume this.
|
|
50
|
+
* Empty array when the picker decided NOT to inject memory (budget
|
|
51
|
+
* below minimum, or no entries loaded).
|
|
52
|
+
*/
|
|
53
|
+
selected: MemoryEntry<Message>[];
|
|
54
|
+
/**
|
|
55
|
+
* Formatter output — the `Message[]` that will be injected into the
|
|
56
|
+
* LLM's prompt this turn. The wire layer merges this into the agent's
|
|
57
|
+
* messages array (typically as `system` messages before the user turn).
|
|
58
|
+
*/
|
|
59
|
+
formatted: Message[];
|
|
60
|
+
/**
|
|
61
|
+
* Write-side input: messages to persist at the end of this turn. The
|
|
62
|
+
* wire layer populates from the agent's final message state;
|
|
63
|
+
* `writeMessages` wraps each as a `MemoryEntry` and calls `store.put`.
|
|
64
|
+
*/
|
|
65
|
+
newMessages: Message[];
|
|
66
|
+
/**
|
|
67
|
+
* Write-side input (CAUSAL pipelines): evidence harvested during the run by
|
|
68
|
+
* `causalEvidenceRecorder` — decisions, tool calls, iterations, duration,
|
|
69
|
+
* token usage. Populated by the wire layer via the mount's `evidenceSource`;
|
|
70
|
+
* undefined for non-causal pipelines (writeSnapshot falls back to zeros).
|
|
71
|
+
*/
|
|
72
|
+
runEvidence?: import('../causal/evidenceRecorder.js').RunEvidence;
|
|
73
|
+
/** Escape hatch for pipeline-specific fields. Typed per-pipeline as needed. */
|
|
74
|
+
[key: string]: unknown;
|
|
75
|
+
}
|