agentfootprint 6.44.0 → 7.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +4 -0
- package/CLAUDE.md +4 -0
- package/README.md +141 -167
- package/ai-instructions/claude-code/SKILL.md +11 -0
- package/ai-instructions/setup.sh +0 -0
- package/dist/adapters/llm/BrowserOpenAIProvider.js +1 -1
- package/dist/adapters/llm/MockProvider.js +2 -1
- package/dist/adapters/llm/MockProvider.js.map +1 -1
- package/dist/core/agent/buildAgentChart.js +2 -1
- package/dist/core/agent/buildAgentChart.js.map +1 -1
- package/dist/core/agent/buildDynamicAgentChart.js +3 -1
- package/dist/core/agent/buildDynamicAgentChart.js.map +1 -1
- package/dist/core/agent/stages/pickEntry.js +3 -1
- package/dist/core/agent/stages/pickEntry.js.map +1 -1
- package/dist/debug/finders.js +29 -0
- package/dist/debug/finders.js.map +1 -0
- package/dist/debug.js +134 -0
- package/dist/debug.js.map +1 -0
- package/dist/esm/adapters/identity/agentcore.d.ts +100 -0
- package/dist/esm/adapters/llm/AnthropicProvider.d.ts +130 -0
- package/dist/esm/adapters/llm/BedrockProvider.d.ts +100 -0
- package/dist/esm/adapters/llm/BrowserAnthropicProvider.d.ts +41 -0
- package/dist/esm/adapters/llm/BrowserOpenAIProvider.d.ts +95 -0
- package/dist/esm/adapters/llm/BrowserOpenAIProvider.js +1 -1
- package/dist/esm/adapters/llm/MockProvider.d.ts +154 -0
- package/dist/esm/adapters/llm/MockProvider.js +2 -1
- package/dist/esm/adapters/llm/MockProvider.js.map +1 -1
- package/dist/esm/adapters/llm/OpenAIProvider.d.ts +220 -0
- package/dist/esm/adapters/llm/createProvider.d.ts +85 -0
- package/dist/esm/adapters/memory/agentcore.d.ts +146 -0
- package/dist/esm/adapters/memory/bedrockAgentMemory.d.ts +95 -0
- package/dist/esm/adapters/memory/redis.d.ts +127 -0
- package/dist/esm/adapters/observability/agentcore.d.ts +67 -0
- package/dist/esm/adapters/observability/audit.d.ts +254 -0
- package/dist/esm/adapters/observability/cloudwatch.d.ts +96 -0
- package/dist/esm/adapters/observability/otel.d.ts +237 -0
- package/dist/esm/adapters/observability/xray.d.ts +88 -0
- package/dist/esm/adapters/types.d.ts +378 -0
- package/dist/esm/bridge/eventMeta.d.ts +59 -0
- package/dist/esm/cache/CacheDecisionSubflow.d.ts +85 -0
- package/dist/esm/cache/CacheGateDecider.d.ts +127 -0
- package/dist/esm/cache/applyCachePolicy.d.ts +37 -0
- package/dist/esm/cache/cacheRecorder.d.ts +85 -0
- package/dist/esm/cache/index.d.ts +33 -0
- package/dist/esm/cache/strategies/AnthropicCacheStrategy.d.ts +38 -0
- package/dist/esm/cache/strategies/BedrockCacheStrategy.d.ts +33 -0
- package/dist/esm/cache/strategies/NoOpCacheStrategy.d.ts +29 -0
- package/dist/esm/cache/strategies/OpenAICacheStrategy.d.ts +36 -0
- package/dist/esm/cache/strategyRegistry.d.ts +45 -0
- package/dist/esm/cache/types.d.ts +243 -0
- package/dist/esm/conventions.d.ts +203 -0
- package/dist/esm/core/Agent.d.ts +355 -0
- package/dist/esm/core/LLMCall.d.ts +139 -0
- package/dist/esm/core/RunnerBase.d.ts +267 -0
- package/dist/esm/core/agent/AgentBuilder.d.ts +565 -0
- package/dist/esm/core/agent/buildAgentChart.d.ts +109 -0
- package/dist/esm/core/agent/buildAgentChart.js +2 -1
- package/dist/esm/core/agent/buildAgentChart.js.map +1 -1
- package/dist/esm/core/agent/buildAgentMessageApiChart.d.ts +40 -0
- package/dist/esm/core/agent/buildCacheSubflow.d.ts +35 -0
- package/dist/esm/core/agent/buildDynamicAgentChart.d.ts +56 -0
- package/dist/esm/core/agent/buildDynamicAgentChart.js +3 -1
- package/dist/esm/core/agent/buildDynamicAgentChart.js.map +1 -1
- package/dist/esm/core/agent/buildMessageApiChart.d.ts +47 -0
- package/dist/esm/core/agent/buildToolRegistry.d.ts +61 -0
- package/dist/esm/core/agent/memoryRecallInjections.d.ts +8 -0
- package/dist/esm/core/agent/stages/breakFinal.d.ts +22 -0
- package/dist/esm/core/agent/stages/callLLM.d.ts +74 -0
- package/dist/esm/core/agent/stages/pickEntry.d.ts +19 -0
- package/dist/esm/core/agent/stages/pickEntry.js +3 -1
- package/dist/esm/core/agent/stages/pickEntry.js.map +1 -1
- package/dist/esm/core/agent/stages/prepareFinal.d.ts +19 -0
- package/dist/esm/core/agent/stages/reliabilityExecution.d.ts +135 -0
- package/dist/esm/core/agent/stages/route.d.ts +18 -0
- package/dist/esm/core/agent/stages/seed.d.ts +53 -0
- package/dist/esm/core/agent/stages/toolCalls.d.ts +76 -0
- package/dist/esm/core/agent/toolArgsValidation.d.ts +62 -0
- package/dist/esm/core/agent/types.d.ts +382 -0
- package/dist/esm/core/agent/validators.d.ts +52 -0
- package/dist/esm/core/cost.d.ts +38 -0
- package/dist/esm/core/flowchartAsTool.d.ts +200 -0
- package/dist/esm/core/humanizeLLMError.d.ts +23 -0
- package/dist/esm/core/outputFallback.d.ts +139 -0
- package/dist/esm/core/outputSchema.d.ts +127 -0
- package/dist/esm/core/pause.d.ts +74 -0
- package/dist/esm/core/runCheckpoint.d.ts +179 -0
- package/dist/esm/core/runner.d.ts +203 -0
- package/dist/esm/core/slots/buildMessagesSlot.d.ts +40 -0
- package/dist/esm/core/slots/buildSystemPromptSlot.d.ts +41 -0
- package/dist/esm/core/slots/buildThinkingSubflow.d.ts +40 -0
- package/dist/esm/core/slots/buildToolsSlot.d.ts +60 -0
- package/dist/esm/core/slots/helpers.d.ts +27 -0
- package/dist/esm/core/toolContract.d.ts +43 -0
- package/dist/esm/core/tools.d.ts +90 -0
- package/dist/esm/core/translator.d.ts +94 -0
- package/dist/esm/core-flow/Conditional.d.ts +119 -0
- package/dist/esm/core-flow/Loop.d.ts +160 -0
- package/dist/esm/core-flow/Parallel.d.ts +360 -0
- package/dist/esm/core-flow/Sequence.d.ts +133 -0
- package/dist/esm/debug/finders.d.ts +12 -0
- package/dist/esm/debug/finders.js +13 -0
- package/dist/esm/debug/finders.js.map +1 -0
- package/dist/esm/debug.d.ts +25 -0
- package/dist/esm/debug.js +54 -0
- package/dist/esm/debug.js.map +1 -0
- package/dist/esm/events/dispatcher.d.ts +134 -0
- package/dist/esm/events/payloads.d.ts +761 -0
- package/dist/esm/events/registry.d.ts +198 -0
- package/dist/esm/events/types.d.ts +70 -0
- package/dist/esm/events.d.ts +18 -0
- package/dist/esm/events.js +22 -0
- package/dist/esm/events.js.map +1 -0
- package/dist/esm/identity/kinds.d.ts +36 -0
- package/dist/esm/identity/staticTokens.d.ts +28 -0
- package/dist/esm/identity/types.d.ts +113 -0
- package/dist/esm/identity/withCredentialRetry.d.ts +64 -0
- package/dist/esm/identity.d.ts +31 -0
- package/dist/esm/index.d.ts +44 -0
- package/dist/esm/index.js +7 -52
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/injection-engine.d.ts +4 -0
- package/dist/esm/lib/canonicalJson.d.ts +56 -0
- package/dist/esm/lib/context-bisect/ablation.d.ts +109 -0
- package/dist/esm/lib/context-bisect/bisect.d.ts +75 -0
- package/dist/esm/lib/context-bisect/cost.d.ts +37 -0
- package/dist/esm/lib/context-bisect/index.d.ts +31 -0
- package/dist/esm/lib/context-bisect/index.js +3 -0
- package/dist/esm/lib/context-bisect/index.js.map +1 -1
- package/dist/esm/lib/context-bisect/llmEdgeWeigher.d.ts +124 -0
- package/dist/esm/lib/context-bisect/localize.d.ts +152 -0
- package/dist/esm/lib/context-bisect/localize.js +2 -0
- package/dist/esm/lib/context-bisect/localize.js.map +1 -1
- package/dist/esm/lib/context-bisect/loop-recall.d.ts +97 -0
- package/dist/esm/lib/context-bisect/missingContext.d.ts +71 -0
- package/dist/esm/lib/context-bisect/restoration.d.ts +39 -0
- package/dist/esm/lib/context-bisect/toBacktrackTrace.d.ts +138 -0
- package/dist/esm/lib/context-bisect/trajectory.d.ts +168 -0
- package/dist/esm/lib/context-bisect/types.d.ts +448 -0
- package/dist/esm/lib/context-bisect/walk-to-root.d.ts +103 -0
- package/dist/esm/lib/influence-core/attributability.d.ts +72 -0
- package/dist/esm/lib/influence-core/cache.d.ts +94 -0
- package/dist/esm/lib/influence-core/contrastive.d.ts +26 -0
- package/dist/esm/lib/influence-core/index.d.ts +34 -0
- package/dist/esm/lib/influence-core/margin.d.ts +33 -0
- package/dist/esm/lib/influence-core/signals.d.ts +128 -0
- package/dist/esm/lib/influence-core/similarity.d.ts +25 -0
- package/dist/esm/lib/influence-core/types.d.ts +252 -0
- package/dist/esm/lib/injection-engine/SkillRegistry.d.ts +147 -0
- package/dist/esm/lib/injection-engine/buildInjectionEngineSubflow.d.ts +110 -0
- package/dist/esm/lib/injection-engine/buildInjectionEngineSubflow.js +1 -0
- package/dist/esm/lib/injection-engine/buildInjectionEngineSubflow.js.map +1 -1
- package/dist/esm/lib/injection-engine/entryScorer.d.ts +93 -0
- package/dist/esm/lib/injection-engine/entryScorer.js +172 -0
- package/dist/esm/lib/injection-engine/entryScorer.js.map +1 -0
- package/dist/esm/lib/injection-engine/evaluator.d.ts +24 -0
- package/dist/esm/lib/injection-engine/factories/defineFact.d.ts +60 -0
- package/dist/esm/lib/injection-engine/factories/defineInjection.d.ts +41 -0
- package/dist/esm/lib/injection-engine/factories/defineInstruction.d.ts +78 -0
- package/dist/esm/lib/injection-engine/factories/defineRelevanceHint.d.ts +26 -0
- package/dist/esm/lib/injection-engine/factories/defineSkill.d.ts +160 -0
- package/dist/esm/lib/injection-engine/factories/defineSteering.d.ts +39 -0
- package/dist/esm/lib/injection-engine/index.d.ts +22 -0
- package/dist/esm/lib/injection-engine/index.js +2 -1
- package/dist/esm/lib/injection-engine/index.js.map +1 -1
- package/dist/esm/lib/injection-engine/skillContract.d.ts +29 -0
- package/dist/esm/lib/injection-engine/skillGraph.d.ts +290 -0
- package/dist/esm/lib/injection-engine/skillGraph.js +38 -43
- package/dist/esm/lib/injection-engine/skillGraph.js.map +1 -1
- package/dist/esm/lib/injection-engine/skillGraphCheckup.d.ts +49 -0
- package/dist/esm/lib/injection-engine/skillTools.d.ts +72 -0
- package/dist/esm/lib/injection-engine/softmax.d.ts +11 -0
- package/dist/esm/lib/injection-engine/types.d.ts +229 -0
- package/dist/esm/lib/injection-engine/types.js.map +1 -1
- package/dist/esm/lib/lazyRequire.d.ts +29 -0
- package/dist/esm/lib/mcp/index.d.ts +9 -0
- package/dist/esm/lib/mcp/mcpClient.d.ts +46 -0
- package/dist/esm/lib/mcp/mockMcpClient.d.ts +65 -0
- package/dist/esm/lib/mcp/types.d.ts +133 -0
- package/dist/esm/lib/rag/defineRAG.d.ts +139 -0
- package/dist/esm/lib/rag/defineRAG.js +3 -3
- package/dist/esm/lib/rag/index.d.ts +7 -0
- package/dist/esm/lib/rag/indexDocuments.d.ts +106 -0
- package/dist/esm/lib/rag/indexDocuments.js +2 -1
- package/dist/esm/lib/rag/indexDocuments.js.map +1 -1
- package/dist/esm/lib/tool-lint/analyze.d.ts +83 -0
- package/dist/esm/lib/tool-lint/cli.d.ts +43 -0
- package/dist/esm/lib/tool-lint/format.d.ts +18 -0
- package/dist/esm/lib/tool-lint/index.d.ts +23 -0
- package/dist/esm/lib/tool-lint/rules.d.ts +85 -0
- package/dist/esm/lib/tool-lint/types.d.ts +155 -0
- package/dist/esm/lib/trace-toolpack/bounded.d.ts +47 -0
- package/dist/esm/lib/trace-toolpack/debugPrompt.d.ts +19 -0
- package/dist/esm/lib/trace-toolpack/index.d.ts +20 -0
- package/dist/esm/lib/trace-toolpack/lazyToolpack.d.ts +35 -0
- package/dist/esm/lib/trace-toolpack/selfExplain.d.ts +100 -0
- package/dist/esm/lib/trace-toolpack/traceDebugAgent.d.ts +42 -0
- package/dist/esm/lib/trace-toolpack/traceToolpack.d.ts +69 -0
- package/dist/esm/lib/trace-toolpack/types.d.ts +59 -0
- package/dist/esm/llm-providers.d.ts +26 -0
- package/dist/esm/locales/index.d.ts +141 -0
- package/dist/esm/locales/index.js +7 -0
- package/dist/esm/locales/index.js.map +1 -1
- package/dist/esm/memory/beats/extractBeats.d.ts +61 -0
- package/dist/esm/memory/beats/extractor.d.ts +47 -0
- package/dist/esm/memory/beats/formatAsNarrative.d.ts +62 -0
- package/dist/esm/memory/beats/heuristicExtractor.d.ts +37 -0
- package/dist/esm/memory/beats/index.d.ts +12 -0
- package/dist/esm/memory/beats/llmExtractor.d.ts +56 -0
- package/dist/esm/memory/beats/types.d.ts +60 -0
- package/dist/esm/memory/beats/writeBeats.d.ts +22 -0
- package/dist/esm/memory/causal/evidenceRecorder.d.ts +66 -0
- package/dist/esm/memory/causal/index.d.ts +6 -0
- package/dist/esm/memory/causal/loadSnapshot.d.ts +51 -0
- package/dist/esm/memory/causal/snapshotPipeline.d.ts +35 -0
- package/dist/esm/memory/causal/types.d.ts +134 -0
- package/dist/esm/memory/causal/types.js.map +1 -1
- package/dist/esm/memory/causal/writeSnapshot.d.ts +73 -0
- package/dist/esm/memory/define.d.ts +63 -0
- package/dist/esm/memory/define.types.d.ts +278 -0
- package/dist/esm/memory/define.types.js +6 -4
- package/dist/esm/memory/define.types.js.map +1 -1
- package/dist/esm/memory/embedding/cosine.d.ts +18 -0
- package/dist/esm/memory/embedding/embedMessages.d.ts +58 -0
- package/dist/esm/memory/embedding/index.d.ts +8 -0
- package/dist/esm/memory/embedding/loadRelevant.d.ts +51 -0
- package/dist/esm/memory/embedding/mockEmbedder.d.ts +22 -0
- package/dist/esm/memory/embedding/types.d.ts +46 -0
- package/dist/esm/memory/entry/decay.d.ts +36 -0
- package/dist/esm/memory/entry/index.d.ts +2 -0
- package/dist/esm/memory/entry/types.d.ts +140 -0
- package/dist/esm/memory/facts/extractFacts.d.ts +50 -0
- package/dist/esm/memory/facts/extractor.d.ts +33 -0
- package/dist/esm/memory/facts/formatFacts.d.ts +60 -0
- package/dist/esm/memory/facts/index.d.ts +14 -0
- package/dist/esm/memory/facts/llmFactExtractor.d.ts +64 -0
- package/dist/esm/memory/facts/loadFacts.d.ts +43 -0
- package/dist/esm/memory/facts/patternFactExtractor.d.ts +2 -0
- package/dist/esm/memory/facts/types.d.ts +68 -0
- package/dist/esm/memory/facts/writeFacts.d.ts +19 -0
- package/dist/esm/memory/identity/index.d.ts +2 -0
- package/dist/esm/memory/identity/types.d.ts +49 -0
- package/dist/esm/memory/index.d.ts +19 -0
- package/dist/esm/memory/pipeline/auto.d.ts +59 -0
- package/dist/esm/memory/pipeline/default.d.ts +49 -0
- package/dist/esm/memory/pipeline/ephemeral.d.ts +28 -0
- package/dist/esm/memory/pipeline/fact.d.ts +26 -0
- package/dist/esm/memory/pipeline/index.d.ts +13 -0
- package/dist/esm/memory/pipeline/narrative.d.ts +35 -0
- package/dist/esm/memory/pipeline/semantic.d.ts +37 -0
- package/dist/esm/memory/pipeline/types.d.ts +31 -0
- package/dist/esm/memory/stages/formatDefault.d.ts +64 -0
- package/dist/esm/memory/stages/index.d.ts +13 -0
- package/dist/esm/memory/stages/loadRecent.d.ts +49 -0
- package/dist/esm/memory/stages/pickByBudget.d.ts +63 -0
- package/dist/esm/memory/stages/summarize.d.ts +87 -0
- package/dist/esm/memory/stages/tokenize.d.ts +43 -0
- package/dist/esm/memory/stages/types.d.ts +75 -0
- package/dist/esm/memory/stages/writeMessages.d.ts +71 -0
- package/dist/esm/memory/store/InMemoryStore.d.ts +62 -0
- package/dist/esm/memory/store/index.d.ts +2 -0
- package/dist/esm/memory/store/types.d.ts +223 -0
- package/dist/esm/memory/wire/index.d.ts +2 -0
- package/dist/esm/memory/wire/mountMemoryPipeline.d.ts +108 -0
- package/dist/esm/memory-providers.d.ts +37 -0
- package/dist/esm/observability/contextError/finders/compareFinders.d.ts +19 -0
- package/dist/esm/observability/contextError/finders/index.d.ts +22 -0
- package/dist/esm/observability/contextError/finders/rankSuspects.d.ts +2 -0
- package/dist/esm/observability/contextError/finders/removeAndRetry.d.ts +11 -0
- package/dist/esm/observability/contextError/finders/shrinkToCause.d.ts +11 -0
- package/dist/esm/observability/contextError/finders/testManyCombos.d.ts +11 -0
- package/dist/esm/observability/contextError/finders/traceSteps.d.ts +2 -0
- package/dist/esm/observability/contextError/finders/types.d.ts +88 -0
- package/dist/esm/observability-providers.d.ts +46 -0
- package/dist/esm/observe.d.ts +57 -0
- package/dist/esm/observe.js +7 -36
- package/dist/esm/observe.js.map +1 -1
- package/dist/esm/patterns/Debate.d.ts +39 -0
- package/dist/esm/patterns/MapReduce.d.ts +66 -0
- package/dist/esm/patterns/Reflection.d.ts +51 -0
- package/dist/esm/patterns/SelfConsistency.d.ts +43 -0
- package/dist/esm/patterns/Swarm.d.ts +60 -0
- package/dist/esm/patterns/ToT.d.ts +53 -0
- package/dist/esm/patterns/index.d.ts +22 -0
- package/dist/esm/providers.d.ts +33 -0
- package/dist/esm/providers.js +1 -1
- package/dist/esm/providers.js.map +1 -1
- package/dist/esm/recorders/core/AgentRecorder.d.ts +15 -0
- package/dist/esm/recorders/core/CompositionRecorder.d.ts +17 -0
- package/dist/esm/recorders/core/ContextEvaluatedRecorder.d.ts +23 -0
- package/dist/esm/recorders/core/ContextRecorder.d.ts +47 -0
- package/dist/esm/recorders/core/CostRecorder.d.ts +14 -0
- package/dist/esm/recorders/core/EmitBridge.d.ts +30 -0
- package/dist/esm/recorders/core/ErrorBridge.d.ts +38 -0
- package/dist/esm/recorders/core/EvalRecorder.d.ts +16 -0
- package/dist/esm/recorders/core/MemoryRecorder.d.ts +17 -0
- package/dist/esm/recorders/core/PermissionRecorder.d.ts +16 -0
- package/dist/esm/recorders/core/ReliabilityRecorder.d.ts +24 -0
- package/dist/esm/recorders/core/SkillRecorder.d.ts +14 -0
- package/dist/esm/recorders/core/StreamRecorder.d.ts +15 -0
- package/dist/esm/recorders/core/ToolsRecorder.d.ts +18 -0
- package/dist/esm/recorders/core/ValidationRecorder.d.ts +16 -0
- package/dist/esm/recorders/core/contextEngineering.d.ts +136 -0
- package/dist/esm/recorders/core/typedEmit.d.ts +34 -0
- package/dist/esm/recorders/core/types.d.ts +97 -0
- package/dist/esm/recorders/observability/AgentThinkingTraceRecorder.d.ts +117 -0
- package/dist/esm/recorders/observability/BoundaryRecorder.d.ts +546 -0
- package/dist/esm/recorders/observability/FlowchartRecorder.d.ts +220 -0
- package/dist/esm/recorders/observability/LiveStateRecorder.d.ts +250 -0
- package/dist/esm/recorders/observability/LoggingRecorder.d.ts +91 -0
- package/dist/esm/recorders/observability/RouteRecorder.d.ts +83 -0
- package/dist/esm/recorders/observability/RunStepRecorder.d.ts +231 -0
- package/dist/esm/recorders/observability/StatusRecorder.d.ts +36 -0
- package/dist/esm/recorders/observability/ToolChoiceRecorder.d.ts +164 -0
- package/dist/esm/recorders/observability/ToolLineageRecorder.d.ts +71 -0
- package/dist/esm/recorders/observability/commentary/commentaryTemplates.d.ts +105 -0
- package/dist/esm/recorders/observability/internal/ActorArrowClassifier.d.ts +25 -0
- package/dist/esm/recorders/observability/internal/CandidateAnswerBuffer.d.ts +28 -0
- package/dist/esm/recorders/observability/internal/ForkTracker.d.ts +60 -0
- package/dist/esm/recorders/observability/internal/RootInferrer.d.ts +51 -0
- package/dist/esm/recorders/observability/internal/SequenceSiblingTracker.d.ts +24 -0
- package/dist/esm/recorders/observability/localObservability.d.ts +48 -0
- package/dist/esm/recorders/observability/observeRunId.d.ts +36 -0
- package/dist/esm/recorders/observability/status/statusTemplates.d.ts +106 -0
- package/dist/esm/recorders/observability/trace.d.ts +119 -0
- package/dist/esm/reliability/CircuitBreaker.d.ts +75 -0
- package/dist/esm/reliability/buildReliabilityGateChart.d.ts +53 -0
- package/dist/esm/reliability/classifyError.d.ts +28 -0
- package/dist/esm/reliability/index.d.ts +35 -0
- package/dist/esm/reliability/types.d.ts +327 -0
- package/dist/esm/resilience/fallbackProvider.d.ts +33 -0
- package/dist/esm/resilience/index.d.ts +21 -0
- package/dist/esm/resilience/withCircuitBreaker.d.ts +129 -0
- package/dist/esm/resilience/withFallback.d.ts +45 -0
- package/dist/esm/resilience/withRetry.d.ts +71 -0
- package/dist/esm/security/PermissionPolicy.d.ts +124 -0
- package/dist/esm/security/PolicyHaltError.d.ts +72 -0
- package/dist/esm/security/extractSequence.d.ts +46 -0
- package/dist/esm/security/index.d.ts +44 -0
- package/dist/esm/security/thinkingRedaction.d.ts +50 -0
- package/dist/esm/status.d.ts +54 -0
- package/dist/esm/status.js +13 -4
- package/dist/esm/status.js.map +1 -1
- package/dist/esm/strategies/attach.d.ts +47 -0
- package/dist/esm/strategies/compose.d.ts +48 -0
- package/dist/esm/strategies/defaults/chatBubbleLiveStatus.d.ts +36 -0
- package/dist/esm/strategies/defaults/consoleObservability.d.ts +42 -0
- package/dist/esm/strategies/defaults/inMemorySinkCost.d.ts +50 -0
- package/dist/esm/strategies/defaults/index.d.ts +30 -0
- package/dist/esm/strategies/defaults/noopLens.d.ts +28 -0
- package/dist/esm/strategies/index.d.ts +36 -0
- package/dist/esm/strategies/registry.d.ts +70 -0
- package/dist/esm/strategies/types.d.ts +303 -0
- package/dist/esm/stream.d.ts +82 -0
- package/dist/esm/thinking/AnthropicThinkingHandler.d.ts +42 -0
- package/dist/esm/thinking/MockThinkingHandler.d.ts +50 -0
- package/dist/esm/thinking/OpenAIThinkingHandler.d.ts +37 -0
- package/dist/esm/thinking/index.d.ts +51 -0
- package/dist/esm/thinking/registry.d.ts +33 -0
- package/dist/esm/thinking/types.d.ts +162 -0
- package/dist/esm/tool-providers/gatedTools.d.ts +36 -0
- package/dist/esm/tool-providers/index.d.ts +41 -0
- package/dist/esm/tool-providers/skillScopedTools.d.ts +45 -0
- package/dist/esm/tool-providers/staticTools.d.ts +21 -0
- package/dist/esm/tool-providers/types.d.ts +138 -0
- package/dist/events.js +42 -0
- package/dist/events.js.map +1 -0
- package/dist/index.js +7 -117
- package/dist/index.js.map +1 -1
- package/dist/lib/context-bisect/index.js +3 -0
- package/dist/lib/context-bisect/index.js.map +1 -1
- package/dist/lib/context-bisect/localize.js +2 -0
- package/dist/lib/context-bisect/localize.js.map +1 -1
- package/dist/lib/injection-engine/buildInjectionEngineSubflow.js +1 -0
- package/dist/lib/injection-engine/buildInjectionEngineSubflow.js.map +1 -1
- package/dist/lib/injection-engine/entryScorer.js +178 -0
- package/dist/lib/injection-engine/entryScorer.js.map +1 -0
- package/dist/lib/injection-engine/index.js +6 -2
- package/dist/lib/injection-engine/index.js.map +1 -1
- package/dist/lib/injection-engine/skillGraph.js +40 -45
- package/dist/lib/injection-engine/skillGraph.js.map +1 -1
- package/dist/lib/injection-engine/types.js.map +1 -1
- package/dist/lib/rag/defineRAG.js +3 -3
- package/dist/lib/rag/indexDocuments.js +2 -1
- package/dist/lib/rag/indexDocuments.js.map +1 -1
- package/dist/locales/index.js +2 -1
- package/dist/locales/index.js.map +1 -1
- package/dist/memory/causal/types.js.map +1 -1
- package/dist/memory/define.types.js +6 -4
- package/dist/memory/define.types.js.map +1 -1
- package/dist/observe.js +22 -115
- package/dist/observe.js.map +1 -1
- package/dist/providers.js +3 -1
- package/dist/providers.js.map +1 -1
- package/dist/status.js +13 -5
- package/dist/status.js.map +1 -1
- package/dist/types/adapters/llm/BrowserOpenAIProvider.d.ts +1 -1
- package/dist/types/adapters/llm/MockProvider.d.ts +2 -1
- package/dist/types/adapters/llm/MockProvider.d.ts.map +1 -1
- package/dist/types/core/agent/buildAgentChart.d.ts.map +1 -1
- package/dist/types/core/agent/buildDynamicAgentChart.d.ts.map +1 -1
- package/dist/types/core/agent/stages/pickEntry.d.ts.map +1 -1
- package/dist/types/core/agent/types.d.ts +8 -4
- package/dist/types/core/agent/types.d.ts.map +1 -1
- package/dist/types/debug/finders.d.ts +13 -0
- package/dist/types/debug/finders.d.ts.map +1 -0
- package/dist/types/debug.d.ts +26 -0
- package/dist/types/debug.d.ts.map +1 -0
- package/dist/types/events.d.ts +19 -0
- package/dist/types/events.d.ts.map +1 -0
- package/dist/types/index.d.ts +4 -24
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/lib/context-bisect/index.d.ts +3 -0
- package/dist/types/lib/context-bisect/index.d.ts.map +1 -1
- package/dist/types/lib/context-bisect/localize.d.ts +2 -0
- package/dist/types/lib/context-bisect/localize.d.ts.map +1 -1
- package/dist/types/lib/injection-engine/buildInjectionEngineSubflow.d.ts.map +1 -1
- package/dist/types/lib/injection-engine/entryScorer.d.ts +94 -0
- package/dist/types/lib/injection-engine/entryScorer.d.ts.map +1 -0
- package/dist/types/lib/injection-engine/index.d.ts +2 -1
- package/dist/types/lib/injection-engine/index.d.ts.map +1 -1
- package/dist/types/lib/injection-engine/skillGraph.d.ts +24 -26
- package/dist/types/lib/injection-engine/skillGraph.d.ts.map +1 -1
- package/dist/types/lib/injection-engine/types.d.ts +9 -4
- package/dist/types/lib/injection-engine/types.d.ts.map +1 -1
- package/dist/types/lib/rag/defineRAG.d.ts +3 -3
- package/dist/types/lib/rag/indexDocuments.d.ts +2 -1
- package/dist/types/lib/rag/indexDocuments.d.ts.map +1 -1
- package/dist/types/locales/index.d.ts +9 -0
- package/dist/types/locales/index.d.ts.map +1 -1
- package/dist/types/memory/causal/types.d.ts +13 -9
- package/dist/types/memory/causal/types.d.ts.map +1 -1
- package/dist/types/memory/define.types.d.ts +6 -4
- package/dist/types/memory/define.types.d.ts.map +1 -1
- package/dist/types/observe.d.ts +1 -6
- package/dist/types/observe.d.ts.map +1 -1
- package/dist/types/providers.d.ts +2 -2
- package/dist/types/providers.d.ts.map +1 -1
- package/dist/types/status.d.ts +10 -4
- package/dist/types/status.d.ts.map +1 -1
- package/dist/types/tool-providers/index.d.ts +1 -1
- package/dist/types/tool-providers/index.d.ts.map +1 -1
- package/package.json +261 -57
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* agentfootprint/locales — Message Catalog Pattern.
|
|
3
|
+
*
|
|
4
|
+
* The Block D piece. agentfootprint emits user-facing prose at two
|
|
5
|
+
* audience levels:
|
|
6
|
+
*
|
|
7
|
+
* - **Commentary** — third-person prose for the bottom panel of any
|
|
8
|
+
* viewer (Lens, CLI tail, log files). "The agent dispatched the
|
|
9
|
+
* refund tool, which returned successfully."
|
|
10
|
+
* - **Thinking** — first-person status for chat-bubble UIs.
|
|
11
|
+
* "Looking up your order…"
|
|
12
|
+
*
|
|
13
|
+
* v2.4 shipped these as `defaultCommentaryTemplates` and
|
|
14
|
+
* `defaultStatusTemplates` (flat `Record<string, string>` maps with
|
|
15
|
+
* `{{var}}` substitution). The names worked but the framing was
|
|
16
|
+
* generic — "templates" collides with TypeScript / templating-engine
|
|
17
|
+
* terminology, and there was no first-class place to ship locale
|
|
18
|
+
* packs.
|
|
19
|
+
*
|
|
20
|
+
* **Block D formalizes this as the Message Catalog Pattern:**
|
|
21
|
+
*
|
|
22
|
+
* - `defaultCommentaryMessages` / `defaultThinkingMessages` —
|
|
23
|
+
* canonical English bundles. Aliases of the v2.4 names; symbol
|
|
24
|
+
* identity preserved (`defaultCommentaryMessages ===
|
|
25
|
+
* defaultCommentaryTemplates`).
|
|
26
|
+
* - `composeMessages(defaults, overrides)` — spread overrides on
|
|
27
|
+
* top of defaults; missing keys fall back to the default bundle.
|
|
28
|
+
* - `validateMessages(catalog, requiredKeys)` — assert every
|
|
29
|
+
* required key is present (and non-empty). Catches drift between
|
|
30
|
+
* a consumer's locale pack and the framework's required key set.
|
|
31
|
+
*
|
|
32
|
+
* The natural consumer pattern is to ship locale packs alongside the
|
|
33
|
+
* agent code:
|
|
34
|
+
*
|
|
35
|
+
* import { defaultCommentaryMessages, composeMessages } from 'agentfootprint/locales';
|
|
36
|
+
* import { esCommentaryMessages } from './locales/es.js';
|
|
37
|
+
*
|
|
38
|
+
* const merged = composeMessages(defaultCommentaryMessages, esCommentaryMessages);
|
|
39
|
+
*
|
|
40
|
+
* const agent = Agent.create({...})
|
|
41
|
+
* .commentaryTemplates(merged)
|
|
42
|
+
* .build();
|
|
43
|
+
*
|
|
44
|
+
* Pattern: i18n locale resolution (Resource Bundle, Fowler 2002) +
|
|
45
|
+
* plain object merge for overrides. No catalog inheritance
|
|
46
|
+
* chain — overrides win OR fall back to defaults.
|
|
47
|
+
*
|
|
48
|
+
* @example Locale pack drop-in
|
|
49
|
+
* const esThinking = composeMessages(defaultThinkingMessages, {
|
|
50
|
+
* idle: '{{appName}} está pensando…',
|
|
51
|
+
* tool: 'Trabajando en `{{toolName}}`…',
|
|
52
|
+
* });
|
|
53
|
+
* const agent = Agent.create({...}).thinkingTemplates(esThinking).build();
|
|
54
|
+
*
|
|
55
|
+
* @example Validate a locale pack against the framework's required keys
|
|
56
|
+
* import { defaultCommentaryMessages, composeMessages, validateMessages } from 'agentfootprint/locales';
|
|
57
|
+
*
|
|
58
|
+
* const myCatalog = composeMessages(defaultCommentaryMessages, customOverrides);
|
|
59
|
+
* validateMessages(myCatalog, Object.keys(defaultCommentaryMessages));
|
|
60
|
+
* // throws on first missing OR empty key — fail-fast at boot
|
|
61
|
+
*/
|
|
62
|
+
import { defaultStatusTemplates } from '../recorders/observability/status/statusTemplates.js';
|
|
63
|
+
export type { CommentaryTemplates as MessageCatalog } from '../recorders/observability/commentary/commentaryTemplates.js';
|
|
64
|
+
/**
|
|
65
|
+
* Canonical English commentary bundle. Alias of v2.4's
|
|
66
|
+
* `defaultCommentaryTemplates` — same symbol, friendlier framing.
|
|
67
|
+
*
|
|
68
|
+
* Keys mirror agentfootprint event types; values may contain
|
|
69
|
+
* `{{var}}` placeholders for runtime substitution.
|
|
70
|
+
*/
|
|
71
|
+
export declare const defaultCommentaryMessages: Readonly<Record<string, string>>;
|
|
72
|
+
/**
|
|
73
|
+
* Canonical English thinking bundle. Alias of v2.4's
|
|
74
|
+
* `defaultStatusTemplates`.
|
|
75
|
+
*
|
|
76
|
+
* Keys mirror agentfootprint event types; values may contain
|
|
77
|
+
* `{{var}}` placeholders for runtime substitution.
|
|
78
|
+
*/
|
|
79
|
+
export declare const defaultThinkingMessages: Readonly<Record<string, string>>;
|
|
80
|
+
/**
|
|
81
|
+
* Canonical English status bundle — the chat-bubble prose. `/locales` is the
|
|
82
|
+
* single i18n home for ALL prose catalogs; `agentfootprint/status` keeps the
|
|
83
|
+
* status LOGIC (`selectStatus` / `renderStatusLine`) and renders with these
|
|
84
|
+
* words. Same object as `defaultThinkingMessages`.
|
|
85
|
+
*/
|
|
86
|
+
export { defaultStatusTemplates };
|
|
87
|
+
export type { StatusTemplates } from '../recorders/observability/status/statusTemplates.js';
|
|
88
|
+
/**
|
|
89
|
+
* Spread `overrides` on top of `defaults` so every key in `defaults`
|
|
90
|
+
* has a value (the override or the original). The result is a fresh
|
|
91
|
+
* object — neither input is mutated.
|
|
92
|
+
*
|
|
93
|
+
* Missing override keys fall back to the default; extra override
|
|
94
|
+
* keys are preserved (forward-compat for consumer-defined keys).
|
|
95
|
+
*
|
|
96
|
+
* @example
|
|
97
|
+
* const merged = composeMessages(defaultCommentaryMessages, {
|
|
98
|
+
* 'stream.llm_start.iter1': 'My custom thinking line',
|
|
99
|
+
* });
|
|
100
|
+
*/
|
|
101
|
+
export declare function composeMessages<T extends Readonly<Record<string, string>>>(defaults: T, overrides?: Readonly<Record<string, string>>): Readonly<Record<string, string>>;
|
|
102
|
+
/**
|
|
103
|
+
* Validation options for `validateMessages`.
|
|
104
|
+
*/
|
|
105
|
+
export interface ValidateMessagesOptions {
|
|
106
|
+
/**
|
|
107
|
+
* Optional label for the error message (e.g., `'es-MX commentary'`).
|
|
108
|
+
* Defaults to `'message catalog'`.
|
|
109
|
+
*/
|
|
110
|
+
readonly label?: string;
|
|
111
|
+
/**
|
|
112
|
+
* When `true`, empty-string values FAIL validation (treated like a
|
|
113
|
+
* missing key). When `false` (default), empty strings are valid —
|
|
114
|
+
* the framework's default catalogs intentionally use empty values
|
|
115
|
+
* for events the consumer should skip rendering for.
|
|
116
|
+
*/
|
|
117
|
+
readonly forbidEmpty?: boolean;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Assert that every key in `requiredKeys` is present in `catalog`.
|
|
121
|
+
* Throws an Error listing every missing key — batched so consumers
|
|
122
|
+
* fix all at once instead of error-by-error.
|
|
123
|
+
*
|
|
124
|
+
* Useful at boot to catch drift between a consumer's locale pack and
|
|
125
|
+
* the framework's required key set.
|
|
126
|
+
*
|
|
127
|
+
* Empty-string values are VALID by default — the framework's default
|
|
128
|
+
* catalogs use `''` to signal "render nothing for this event."
|
|
129
|
+
* Pass `{ forbidEmpty: true }` to also reject empty values.
|
|
130
|
+
*
|
|
131
|
+
* @param catalog The (composed) message catalog to validate.
|
|
132
|
+
* @param requiredKeys The keys consumers must define. Typically
|
|
133
|
+
* `Object.keys(defaultCommentaryMessages)` or
|
|
134
|
+
* `Object.keys(defaultThinkingMessages)`.
|
|
135
|
+
* @param opts Optional `{ label, forbidEmpty }` (or a bare
|
|
136
|
+
* string label for back-compat with simple use).
|
|
137
|
+
*
|
|
138
|
+
* @throws Error when any required key is missing (or empty under
|
|
139
|
+
* `forbidEmpty`).
|
|
140
|
+
*/
|
|
141
|
+
export declare function validateMessages(catalog: Readonly<Record<string, string>>, requiredKeys: readonly string[], opts?: ValidateMessagesOptions | string): void;
|
|
@@ -77,6 +77,13 @@ export const defaultCommentaryMessages = defaultCommentaryTemplates;
|
|
|
77
77
|
* `{{var}}` placeholders for runtime substitution.
|
|
78
78
|
*/
|
|
79
79
|
export const defaultThinkingMessages = defaultStatusTemplates;
|
|
80
|
+
/**
|
|
81
|
+
* Canonical English status bundle — the chat-bubble prose. `/locales` is the
|
|
82
|
+
* single i18n home for ALL prose catalogs; `agentfootprint/status` keeps the
|
|
83
|
+
* status LOGIC (`selectStatus` / `renderStatusLine`) and renders with these
|
|
84
|
+
* words. Same object as `defaultThinkingMessages`.
|
|
85
|
+
*/
|
|
86
|
+
export { defaultStatusTemplates };
|
|
80
87
|
/**
|
|
81
88
|
* Spread `overrides` on top of `defaults` so every key in `defaults`
|
|
82
89
|
* has a value (the override or the original). The result is a fresh
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/locales/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4DG;AAEH,OAAO,EAAE,0BAA0B,EAAE,MAAM,8DAA8D,CAAC;AAC1G,OAAO,EAAE,sBAAsB,EAAE,MAAM,sDAAsD,CAAC;AAI9F;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,0BAA0B,CAAC;AAEpE;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,sBAAsB,CAAC;AAE9D;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,eAAe,CAC7B,QAAW,EACX,YAA8C,EAAE;IAEhD,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,QAAQ,EAAE,GAAG,SAAS,EAAE,CAAC,CAAC;AACtD,CAAC;AAoBD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,UAAU,gBAAgB,CAC9B,OAAyC,EACzC,YAA+B,EAC/B,OAAyC,EAAE;IAE3C,MAAM,QAAQ,GAA4B,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;IAC5F,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,IAAI,iBAAiB,CAAC;IAClD,MAAM,WAAW,GAAG,QAAQ,CAAC,WAAW,IAAI,KAAK,CAAC;IAElD,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,KAAK,MAAM,GAAG,IAAI,YAAY,EAAE,CAAC;QAC/B,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;QAC3B,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACpB,CAAC;aAAM,IAAI,WAAW,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC7C,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAClB,CAAC;IACH,CAAC;IACD,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO;IACvD,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACvB,KAAK,CAAC,IAAI,CAAC,iBAAiB,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACpD,CAAC;IACD,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACrB,KAAK,CAAC,IAAI,CAAC,iBAAiB,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAClD,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,oBAAoB,KAAK,MAAM,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACtE,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/locales/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4DG;AAEH,OAAO,EAAE,0BAA0B,EAAE,MAAM,8DAA8D,CAAC;AAC1G,OAAO,EAAE,sBAAsB,EAAE,MAAM,sDAAsD,CAAC;AAI9F;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,0BAA0B,CAAC;AAEpE;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,sBAAsB,CAAC;AAE9D;;;;;GAKG;AACH,OAAO,EAAE,sBAAsB,EAAE,CAAC;AAGlC;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,eAAe,CAC7B,QAAW,EACX,YAA8C,EAAE;IAEhD,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,QAAQ,EAAE,GAAG,SAAS,EAAE,CAAC,CAAC;AACtD,CAAC;AAoBD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,UAAU,gBAAgB,CAC9B,OAAyC,EACzC,YAA+B,EAC/B,OAAyC,EAAE;IAE3C,MAAM,QAAQ,GAA4B,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;IAC5F,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,IAAI,iBAAiB,CAAC;IAClD,MAAM,WAAW,GAAG,QAAQ,CAAC,WAAW,IAAI,KAAK,CAAC;IAElD,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,KAAK,MAAM,GAAG,IAAI,YAAY,EAAE,CAAC;QAC/B,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;QAC3B,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACpB,CAAC;aAAM,IAAI,WAAW,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC7C,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAClB,CAAC;IACH,CAAC;IACD,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO;IACvD,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACvB,KAAK,CAAC,IAAI,CAAC,iBAAiB,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACpD,CAAC;IACD,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACrB,KAAK,CAAC,IAAI,CAAC,iBAAiB,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAClD,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,oBAAoB,KAAK,MAAM,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACtE,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* extractBeats — write-side stage that compresses `scope.newMessages`
|
|
3
|
+
* into `NarrativeBeat`s via a pluggable `BeatExtractor`.
|
|
4
|
+
*
|
|
5
|
+
* Reads from scope: `newMessages`, `turnNumber`
|
|
6
|
+
* Writes to scope: `newBeats` (MemoryEntry<NarrativeBeat>[])
|
|
7
|
+
*
|
|
8
|
+
* This stage produces full `MemoryEntry<NarrativeBeat>` records so the
|
|
9
|
+
* downstream write stage (a thin adapter over `writeMessages`) can
|
|
10
|
+
* persist them via the ordinary `MemoryStore.putMany` batched API.
|
|
11
|
+
* Entry ids are `beat-{turn}-{index}` — deterministic, idempotent on
|
|
12
|
+
* re-run within the same turn (matches the `writeMessages` convention).
|
|
13
|
+
*
|
|
14
|
+
* The extractor is called ONCE per turn on the turn's new messages.
|
|
15
|
+
* Returning an empty array is valid — not every turn produces a beat.
|
|
16
|
+
*/
|
|
17
|
+
import type { TypedScope } from 'footprintjs';
|
|
18
|
+
import type { MemoryEntry } from '../entry/index.js';
|
|
19
|
+
import type { MemoryState } from '../stages/index.js';
|
|
20
|
+
import type { BeatExtractor } from './extractor.js';
|
|
21
|
+
import type { NarrativeBeat } from './types.js';
|
|
22
|
+
export interface ExtractBeatsConfig {
|
|
23
|
+
/** The extractor to call. See `heuristicExtractor` / `llmExtractor`. */
|
|
24
|
+
readonly extractor: BeatExtractor;
|
|
25
|
+
/**
|
|
26
|
+
* Optional tier for the persisted beats (passed through to the write
|
|
27
|
+
* stage downstream). Typical pattern: `'hot'` for recent turns,
|
|
28
|
+
* `'warm'` for older, `'cold'` for archival. Omit for no tier.
|
|
29
|
+
*/
|
|
30
|
+
readonly tier?: 'hot' | 'warm' | 'cold';
|
|
31
|
+
/**
|
|
32
|
+
* Optional TTL in ms from `Date.now()` applied to persisted beat
|
|
33
|
+
* entries. Useful for retention windows — `'hot'` beats expire in 7
|
|
34
|
+
* days, `'cold'` beats live indefinitely, etc.
|
|
35
|
+
*/
|
|
36
|
+
readonly ttlMs?: number;
|
|
37
|
+
/**
|
|
38
|
+
* Optional id producer — receives `(turn, index, beat)` and returns
|
|
39
|
+
* the MemoryEntry id. Defaults to `beat-{turn}-{index}` which makes
|
|
40
|
+
* re-runs of the same turn idempotent.
|
|
41
|
+
*/
|
|
42
|
+
readonly idFrom?: (turn: number, index: number, beat: NarrativeBeat) => string;
|
|
43
|
+
}
|
|
44
|
+
/** State added to `MemoryState` by this stage. */
|
|
45
|
+
export interface ExtractBeatsState extends MemoryState {
|
|
46
|
+
/**
|
|
47
|
+
* Extracted beats as complete `MemoryEntry` records, ready for a
|
|
48
|
+
* downstream write stage to persist via `store.putMany`.
|
|
49
|
+
*/
|
|
50
|
+
newBeats?: readonly MemoryEntry<NarrativeBeat>[];
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Build the `extractBeats` stage function.
|
|
54
|
+
*
|
|
55
|
+
* ```ts
|
|
56
|
+
* let b = flowChart<ExtractBeatsState>('Seed', seed, 'seed');
|
|
57
|
+
* b = b.addFunction('ExtractBeats', extractBeats({ extractor }), 'extract-beats');
|
|
58
|
+
* b = b.addFunction('WriteBeats', writeBeats({ store }), 'write-beats');
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
export declare function extractBeats(config: ExtractBeatsConfig): (scope: TypedScope<ExtractBeatsState>) => Promise<void>;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BeatExtractor — interface for compressing turn messages into narrative beats.
|
|
3
|
+
*
|
|
4
|
+
* The write-side `extractBeats` stage calls a BeatExtractor to turn
|
|
5
|
+
* raw turn messages into zero or more `NarrativeBeat`s. The stage
|
|
6
|
+
* persists the beats via the ordinary `MemoryStore` interface — beats
|
|
7
|
+
* are a payload type, not a storage concern.
|
|
8
|
+
*
|
|
9
|
+
* Built-in extractors:
|
|
10
|
+
* - `heuristicExtractor()` — zero-dep, zero-cost. Extracts simple
|
|
11
|
+
* "User said X / Assistant answered Y" beats from the raw text.
|
|
12
|
+
* Default for out-of-the-box narrativePipeline().
|
|
13
|
+
* - `llmExtractor({ provider, importance? })` — uses a provider
|
|
14
|
+
* (typically a cheap model like Haiku) to produce high-quality
|
|
15
|
+
* beats with importance scores and categories. Opt-in.
|
|
16
|
+
*
|
|
17
|
+
* Consumers can implement their own BeatExtractor — e.g. a
|
|
18
|
+
* rules-based extractor for a specific domain, or a hybrid that
|
|
19
|
+
* combines heuristics with LLM rescoring.
|
|
20
|
+
*/
|
|
21
|
+
import type { LLMMessage as Message } from '../../adapters/types.js';
|
|
22
|
+
import type { NarrativeBeat } from './types.js';
|
|
23
|
+
export interface ExtractArgs {
|
|
24
|
+
/**
|
|
25
|
+
* New-turn messages (user / assistant / tool). Extractors should
|
|
26
|
+
* produce beats that summarize these — NOT prior-turn messages,
|
|
27
|
+
* which were already compacted at their own turn boundary.
|
|
28
|
+
*/
|
|
29
|
+
readonly messages: readonly Message[];
|
|
30
|
+
/**
|
|
31
|
+
* Current turn number. Useful for extractors that want to include
|
|
32
|
+
* the turn index in beat refs (e.g., `"turn-5-msg-2"`).
|
|
33
|
+
*/
|
|
34
|
+
readonly turnNumber: number;
|
|
35
|
+
/**
|
|
36
|
+
* Optional abort signal — extractors that make LLM calls should
|
|
37
|
+
* thread this through to the provider to respect run-level timeouts.
|
|
38
|
+
*/
|
|
39
|
+
readonly signal?: AbortSignal;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* A BeatExtractor compresses a turn's messages into beats. Returning
|
|
43
|
+
* an empty array is valid (not every turn produces a salient beat).
|
|
44
|
+
*/
|
|
45
|
+
export interface BeatExtractor {
|
|
46
|
+
extract(args: ExtractArgs): Promise<readonly NarrativeBeat[]>;
|
|
47
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* formatAsNarrative — render selected NarrativeBeats into a single
|
|
3
|
+
* cohesive paragraph for prompt injection.
|
|
4
|
+
*
|
|
5
|
+
* Reads from scope: `selected` (MemoryEntry<NarrativeBeat>[])
|
|
6
|
+
* Writes to scope: `formatted` (Message[] — single system message, or empty)
|
|
7
|
+
*
|
|
8
|
+
* Contrasts with `formatDefault` which produces per-entry `<memory>`
|
|
9
|
+
* blocks for raw-message recall. `formatAsNarrative` composes beats
|
|
10
|
+
* into a story paragraph:
|
|
11
|
+
*
|
|
12
|
+
* Relevant context from prior conversations:
|
|
13
|
+
*
|
|
14
|
+
* From earlier: User revealed their name is Alice. User asked about
|
|
15
|
+
* refunds for order ORD-123. Assistant confirmed the refund was
|
|
16
|
+
* processed.
|
|
17
|
+
*
|
|
18
|
+
* Why a paragraph vs per-beat blocks?
|
|
19
|
+
* Beats are already summaries — wrapping each in its own tag adds
|
|
20
|
+
* boilerplate tokens without adding information. A connected
|
|
21
|
+
* paragraph flows more naturally into the LLM's context.
|
|
22
|
+
*
|
|
23
|
+
* Source citations:
|
|
24
|
+
* When `showRefs` is enabled, the rendered line appends `(refs: msg-1-0, msg-1-2)`
|
|
25
|
+
* so the LLM (and consumer debugging) can walk beats back to source
|
|
26
|
+
* messages. Off by default — cites add tokens and some LLMs parrot them.
|
|
27
|
+
*
|
|
28
|
+
* Empty-input behavior:
|
|
29
|
+
* `selected.length === 0` → writes `formatted: []` (no system message).
|
|
30
|
+
* Matches `formatDefault`'s "skip empty" behavior — injecting an
|
|
31
|
+
* empty header-only block is worse than no injection at all.
|
|
32
|
+
*/
|
|
33
|
+
import type { TypedScope } from 'footprintjs';
|
|
34
|
+
import type { MemoryState } from '../stages/index.js';
|
|
35
|
+
export interface FormatAsNarrativeConfig {
|
|
36
|
+
/**
|
|
37
|
+
* Header prepended to the injected message. Defaults to
|
|
38
|
+
* `"Relevant context from prior conversations. Use when it helps
|
|
39
|
+
* answer the current turn."` — matches `formatDefault`.
|
|
40
|
+
*/
|
|
41
|
+
readonly header?: string;
|
|
42
|
+
/** Footer appended after the beats paragraph. Empty by default. */
|
|
43
|
+
readonly footer?: string;
|
|
44
|
+
/**
|
|
45
|
+
* When `true`, each beat line appends `(refs: msg-x-y, ...)`. Off
|
|
46
|
+
* by default — saves tokens and avoids LLMs echoing the refs in
|
|
47
|
+
* their replies. Turn on for audit / debug use cases.
|
|
48
|
+
*/
|
|
49
|
+
readonly showRefs?: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Connective phrase inserted before the beats paragraph. Defaults
|
|
52
|
+
* to `"From earlier: "`. Set to `""` to disable.
|
|
53
|
+
*/
|
|
54
|
+
readonly leadIn?: string;
|
|
55
|
+
/**
|
|
56
|
+
* Inject the message even when `selected` is empty. Usually
|
|
57
|
+
* undesired — empty memory noise displaces real context. Off by
|
|
58
|
+
* default.
|
|
59
|
+
*/
|
|
60
|
+
readonly emitWhenEmpty?: boolean;
|
|
61
|
+
}
|
|
62
|
+
export declare function formatAsNarrative(config?: FormatAsNarrativeConfig): (scope: TypedScope<MemoryState>) => Promise<void>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* heuristicExtractor — zero-dep, zero-cost beat extractor.
|
|
3
|
+
*
|
|
4
|
+
* Produces one beat per non-system message with a simple
|
|
5
|
+
* `"{role} said: {text}"` summary. Importance defaults to 0.5 except
|
|
6
|
+
* for messages that trip obvious salience signals (questions from the
|
|
7
|
+
* user, assistant tool-use, etc.) where a higher score fires.
|
|
8
|
+
*
|
|
9
|
+
* Why ship this as a default?
|
|
10
|
+
* Users who enable `narrativePipeline()` without configuring an
|
|
11
|
+
* extractor still get sensible behavior — compressed per-turn beats
|
|
12
|
+
* with provenance — without paying for an LLM call. The beats are
|
|
13
|
+
* less semantic than an LLM extractor's but still useful for recall.
|
|
14
|
+
* Users who want higher-quality beats opt into `llmExtractor()`.
|
|
15
|
+
*
|
|
16
|
+
* Heuristic rules (intentionally simple — this is a baseline, not
|
|
17
|
+
* state-of-the-art):
|
|
18
|
+
* - User messages → importance 0.6 (users are generally salient)
|
|
19
|
+
* - User questions (ending in '?') → importance 0.75
|
|
20
|
+
* - Messages containing "my name is" / "i am" → importance 0.9
|
|
21
|
+
* (identity beats are high-value for recall)
|
|
22
|
+
* - Assistant tool-use → importance 0.5 (process step)
|
|
23
|
+
* - Assistant final answers → importance 0.5
|
|
24
|
+
* - Tool results → importance 0.3 (noise for recall most of the time)
|
|
25
|
+
*
|
|
26
|
+
* Category hints:
|
|
27
|
+
* - `"identity"` for name / role assertions
|
|
28
|
+
* - `"question"` for user questions
|
|
29
|
+
* - `"tool-result"` for tool outputs
|
|
30
|
+
* - undefined otherwise (category is optional)
|
|
31
|
+
*
|
|
32
|
+
* This is heuristic. It will miss nuances the LLM extractor catches.
|
|
33
|
+
* Swap for `llmExtractor({ provider })` when quality matters.
|
|
34
|
+
*/
|
|
35
|
+
import type { BeatExtractor } from './extractor.js';
|
|
36
|
+
/** Default heuristic. Takes no config; factory function for consistency. */
|
|
37
|
+
export declare function heuristicExtractor(): BeatExtractor;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type { NarrativeBeat, BeatImportance } from './types.js';
|
|
2
|
+
export { asImportance, isNarrativeBeat } from './types.js';
|
|
3
|
+
export type { BeatExtractor, ExtractArgs } from './extractor.js';
|
|
4
|
+
export { heuristicExtractor } from './heuristicExtractor.js';
|
|
5
|
+
export { llmExtractor } from './llmExtractor.js';
|
|
6
|
+
export type { LLMExtractorConfig } from './llmExtractor.js';
|
|
7
|
+
export { extractBeats } from './extractBeats.js';
|
|
8
|
+
export type { ExtractBeatsConfig, ExtractBeatsState } from './extractBeats.js';
|
|
9
|
+
export { writeBeats } from './writeBeats.js';
|
|
10
|
+
export type { WriteBeatsConfig } from './writeBeats.js';
|
|
11
|
+
export { formatAsNarrative } from './formatAsNarrative.js';
|
|
12
|
+
export type { FormatAsNarrativeConfig } from './formatAsNarrative.js';
|
|
@@ -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>;
|