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,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* selfExplain — the IN-CONVERSATION door over the agent's own trace.
|
|
3
|
+
*
|
|
4
|
+
* `.selfExplain()` on the builder mounts ONE skill plus ONE scoped tool
|
|
5
|
+
* provider. Day to day the tool catalog carries only the skill's
|
|
6
|
+
* activation row — the trace tools are NOT in the skill (skill `tools`
|
|
7
|
+
* land in the static registry, exposed every iteration); they ride a
|
|
8
|
+
* `skillScopedTools` provider gated on the skill's activation, composed
|
|
9
|
+
* with whatever provider the consumer already set. When the user asks a
|
|
10
|
+
* why-question the LLM activates the skill, and the NEXT iteration's
|
|
11
|
+
* catalog gains the trace tools, bound to the agent's own PREVIOUS
|
|
12
|
+
* COMPLETED run.
|
|
13
|
+
*
|
|
14
|
+
* The two pieces here:
|
|
15
|
+
*
|
|
16
|
+
* 1. `SelfExplainBinding` — the late-binding seam, a plain CombinedRecorder
|
|
17
|
+
* attached like any consumer recorder (zero engine changes):
|
|
18
|
+
*
|
|
19
|
+
* - capture at `onRunEnd`/`onRunFailed`: the just-finished run's
|
|
20
|
+
* snapshot becomes the explainable evidence (a FAILED run is
|
|
21
|
+
* still a completed trace — "why did you fail?" works);
|
|
22
|
+
* - rotate at `onRunStart`: a FRESH ControlDepRecorder per run. The
|
|
23
|
+
* retired instance never sees the new run's events, so its live
|
|
24
|
+
* `asLookup()` survives Convention-4's runId reset — the captured
|
|
25
|
+
* control edges stay valid for the whole next turn.
|
|
26
|
+
*
|
|
27
|
+
* B13 safety lives here: `Agent.run()` reassigns its executor at run
|
|
28
|
+
* START, so resolving artifacts mid-run through `getLastSnapshot()`
|
|
29
|
+
* would expose the IN-FLIGHT run. Capturing only at terminal flush
|
|
30
|
+
* means the binding can never serve anything but a completed run.
|
|
31
|
+
*
|
|
32
|
+
* 2. `buildSelfExplainSkill` — the skill in two modes:
|
|
33
|
+
*
|
|
34
|
+
* - INLINE (default): the skill unlocks the 5 trace tools in the
|
|
35
|
+
* main agent's own loop (same model).
|
|
36
|
+
* - DELEGATE: the skill unlocks ONE tool — `explain_run(question)` —
|
|
37
|
+
* whose execute runs a nested `traceDebugAgent` on the consumer's
|
|
38
|
+
* chosen (cheaper) provider/model and returns its evidence-cited
|
|
39
|
+
* answer. The main conversation pays for one tool call; the
|
|
40
|
+
* trace-walking loop happens at the delegate's price. Loaded via
|
|
41
|
+
* dynamic import so the builder never statically pulls Agent
|
|
42
|
+
* through this module (no core ↔ lib cycle).
|
|
43
|
+
*/
|
|
44
|
+
import { type CombinedRecorder, type RuntimeSnapshot } from 'footprintjs';
|
|
45
|
+
import type { Injection } from '../injection-engine/types.js';
|
|
46
|
+
import type { AgentOptions } from '../../core/agent/types.js';
|
|
47
|
+
import type { ToolProvider } from '../../tool-providers/types.js';
|
|
48
|
+
import type { TraceToolpackArtifacts, TraceToolpackOptions } from './types.js';
|
|
49
|
+
/** Consumer surface for `.selfExplain()` on the Agent builder. */
|
|
50
|
+
export interface SelfExplainOptions {
|
|
51
|
+
/** Appended to the recommended skill body (ours stays; yours adds). */
|
|
52
|
+
readonly instruction?: string;
|
|
53
|
+
/**
|
|
54
|
+
* Answer why-questions on a SEPARATE (typically cheaper) model: the
|
|
55
|
+
* skill unlocks one `explain_run` tool that runs a nested
|
|
56
|
+
* `traceDebugAgent` and returns its evidence-cited answer.
|
|
57
|
+
*/
|
|
58
|
+
readonly delegate?: {
|
|
59
|
+
readonly provider: AgentOptions['provider'];
|
|
60
|
+
readonly model: string;
|
|
61
|
+
readonly maxIterations?: number;
|
|
62
|
+
};
|
|
63
|
+
/** Skill id (activation key for `read_skill`). Default 'self-explain'. */
|
|
64
|
+
readonly id?: string;
|
|
65
|
+
/** Bounding dials forwarded to the toolpack. */
|
|
66
|
+
readonly toolpack?: TraceToolpackOptions;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* The late-binding seam. Create one per built Agent, attach
|
|
70
|
+
* `binding.recorder()` via `agent.attach()`, and point `bindTo()` at the
|
|
71
|
+
* agent's `getLastSnapshot`. `artifacts` then always answers with the
|
|
72
|
+
* previous COMPLETED run — never the in-flight one.
|
|
73
|
+
*/
|
|
74
|
+
export declare class SelfExplainBinding {
|
|
75
|
+
private getSnapshot;
|
|
76
|
+
private ctrl;
|
|
77
|
+
private captured;
|
|
78
|
+
bindTo(getSnapshot: () => RuntimeSnapshot | undefined): void;
|
|
79
|
+
/** Evidence of the previous completed run, or undefined before the first. */
|
|
80
|
+
get artifacts(): TraceToolpackArtifacts | undefined;
|
|
81
|
+
/** The recorder to attach — forwards flow events to the per-run ctrl. */
|
|
82
|
+
recorder(): CombinedRecorder;
|
|
83
|
+
}
|
|
84
|
+
/** The default skill id — the activation key the LLM passes to read_skill. */
|
|
85
|
+
export declare const SELF_EXPLAIN_SKILL_ID = "self-explain";
|
|
86
|
+
/**
|
|
87
|
+
* The skill `.selfExplain()` mounts — methodology body ONLY. The trace
|
|
88
|
+
* tools deliberately do NOT ride the skill: skill `tools` land in the
|
|
89
|
+
* static registry (exposed every iteration); catalog gating is the
|
|
90
|
+
* ToolProvider's job — see {@link buildSelfExplainToolProvider}.
|
|
91
|
+
*/
|
|
92
|
+
export declare function buildSelfExplainSkill(options: SelfExplainOptions): Injection;
|
|
93
|
+
/**
|
|
94
|
+
* The gated tool delivery — `skillScopedTools` (the shipped primitive)
|
|
95
|
+
* scoped to the skill's id, composed with the consumer's own provider
|
|
96
|
+
* when they set one. The iteration after activation, `ctx.activeSkillId`
|
|
97
|
+
* matches and the catalog gains the trace tools (inline) or the single
|
|
98
|
+
* `explain_run` tool (delegate).
|
|
99
|
+
*/
|
|
100
|
+
export declare function buildSelfExplainToolProvider(binding: SelfExplainBinding, options: SelfExplainOptions, existing?: ToolProvider): ToolProvider;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* traceDebugAgent — the DEDICATED conversational door over a completed
|
|
3
|
+
* run's trace. One call returns a ready Agent whose entire catalog is
|
|
4
|
+
* the trace toolpack and whose system prompt is the proven debugging
|
|
5
|
+
* methodology (overview → drill by id → cite evidence → respect ⚠).
|
|
6
|
+
*
|
|
7
|
+
* The counterpart doors over the same evidence:
|
|
8
|
+
* - the UI (BacktrackView / Lens) for humans who LOOK,
|
|
9
|
+
* - `.selfExplain()` for why-questions INSIDE the main conversation
|
|
10
|
+
* (which, in delegate mode, runs one of these under the hood).
|
|
11
|
+
*
|
|
12
|
+
* Why dedicated (B13 posture): trace views can replay adversarial text
|
|
13
|
+
* from the original run — a SEPARATE session over a COMPLETED run keeps
|
|
14
|
+
* that out of the production conversation. It is also the cheap-model
|
|
15
|
+
* story made real: debug a Sonnet/Opus run with a Haiku-priced session
|
|
16
|
+
* that reads only what it opens, by id (~9% of the trace in the
|
|
17
|
+
* example-01 fixture; the gap widens with run size).
|
|
18
|
+
*/
|
|
19
|
+
import { Agent } from '../../core/Agent.js';
|
|
20
|
+
import type { AgentOptions } from '../../core/agent/types.js';
|
|
21
|
+
import type { TraceToolpackArtifacts, TraceToolpackOptions } from './types.js';
|
|
22
|
+
export interface TraceDebugAgentOptions {
|
|
23
|
+
/** The completed run's evidence — `{ snapshot, controlDeps?, narrative? }`. */
|
|
24
|
+
readonly artifacts: TraceToolpackArtifacts;
|
|
25
|
+
/** Any provider — `mock()` in tests, a cheap model in production. */
|
|
26
|
+
readonly provider: AgentOptions['provider'];
|
|
27
|
+
readonly model: string;
|
|
28
|
+
/** ReAct budget for one debugging question. Default 8. */
|
|
29
|
+
readonly maxIterations?: number;
|
|
30
|
+
/** Appended to the methodology system prompt (domain hints, tone). */
|
|
31
|
+
readonly instruction?: string;
|
|
32
|
+
/** Bounding dials forwarded to the toolpack. */
|
|
33
|
+
readonly toolpack?: TraceToolpackOptions;
|
|
34
|
+
/** Display name in events/metrics. Default 'TraceDebugAgent'. */
|
|
35
|
+
readonly name?: string;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Build the dedicated trace debugger. The returned Agent is a normal
|
|
39
|
+
* Agent — `await debuggerAi.run({ message: 'Why was the refund approved?' })`
|
|
40
|
+
* answers from the recorded evidence, citing runtimeStageIds.
|
|
41
|
+
*/
|
|
42
|
+
export declare function traceDebugAgent(options: TraceDebugAgentOptions): Agent;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* traceToolpack — footprintjs trace evidence exposed as TOOLS an LLM calls
|
|
3
|
+
* (RFC-003 Part C: the introspection toolpack).
|
|
4
|
+
*
|
|
5
|
+
* "The framework's internal tool for itself": after a run completes, a
|
|
6
|
+
* debugging LLM (a cheap model in a SEPARATE session) navigates the run's
|
|
7
|
+
* evidence by ids instead of reading dumps — the same just-in-time,
|
|
8
|
+
* token-efficient loading pattern as `read_skill`. Feed the slice, not the
|
|
9
|
+
* trace; the LLM ranks by navigating, so no embedder is needed.
|
|
10
|
+
*
|
|
11
|
+
* Pattern: Factory over frozen artifacts. `traceToolpack(artifacts)` returns
|
|
12
|
+
* plain `Tool[]` — mount them on any Agent, or drive them scripted
|
|
13
|
+
* via `callTraceTool` (the offline auditor pattern, like
|
|
14
|
+
* examples/features/20). Nothing re-runs; every tool is a bounded
|
|
15
|
+
* read-only VIEW over a COMPLETED run's snapshot + commit log.
|
|
16
|
+
*
|
|
17
|
+
* The toolpack's three contracts (B13 posture):
|
|
18
|
+
*
|
|
19
|
+
* 1. BOUNDED BY DEFAULT — every output is capped (previews, slice
|
|
20
|
+
* depth/nodes, value chars, narrative lines). Per-call params raise
|
|
21
|
+
* the budget only up to hard caps the LLM cannot exceed.
|
|
22
|
+
* 2. HONEST — truncation and incompleteness are ALWAYS marked (⚠), never
|
|
23
|
+
* silent: truncated slices, untracked sources (args/env/silent reads),
|
|
24
|
+
* missing read tracking, missing control-dependence lookup, values the
|
|
25
|
+
* commit log cannot see (pre-run state, closures).
|
|
26
|
+
* 3. REDACTION-RESPECTING — the commit log already carries redacted
|
|
27
|
+
* payloads (footprintjs scrubs at commit time); the toolpack passes
|
|
28
|
+
* placeholders through verbatim and flags redacted keys. It never
|
|
29
|
+
* reconstructs around a redaction.
|
|
30
|
+
*
|
|
31
|
+
* Why ids: every view names steps by `runtimeStageId`
|
|
32
|
+
* (`stageId#executionIndex`) — the universal key linking the commit log,
|
|
33
|
+
* the execution tree, and recorder events. The LLM drills like a debugger:
|
|
34
|
+
* overview → slice → node → value, paying only for what it opens.
|
|
35
|
+
*/
|
|
36
|
+
import { type Tool } from '../../core/tools.js';
|
|
37
|
+
import { type TraceToolpackArtifacts, type TraceToolpackOptions } from './types.js';
|
|
38
|
+
/**
|
|
39
|
+
* Build the introspection toolpack over a COMPLETED run's artifacts.
|
|
40
|
+
*
|
|
41
|
+
* Returns plain `Tool[]`:
|
|
42
|
+
*
|
|
43
|
+
* | Tool | Question it answers |
|
|
44
|
+
* |------------------|-----------------------------------------------------------|
|
|
45
|
+
* | `run_overview` | What happened, broadly? (the entry point) |
|
|
46
|
+
* | `trace_node` | What did step X read/write, and where did its inputs come from? |
|
|
47
|
+
* | `trace_slice` | Which chain of steps produced the data at X? (causal slice) |
|
|
48
|
+
* | `who_wrote` | Which step last wrote key K? |
|
|
49
|
+
* | `get_value` | The full value of K as of step X (capped, truncation-marked) |
|
|
50
|
+
* | `read_narrative` | The human-readable story, paginated (only when narrative provided) |
|
|
51
|
+
*
|
|
52
|
+
* Mount on an Agent (`Agent.create({...}).tool(...tools)`) or drive scripted
|
|
53
|
+
* via {@link callTraceTool}. The tools NEVER throw on bad ids/keys — they
|
|
54
|
+
* return corrective, model-visible messages (the #9 philosophy), and their
|
|
55
|
+
* strict input schemas give Agent-dispatched calls free arg validation.
|
|
56
|
+
*
|
|
57
|
+
* Security note (B13 posture): trace content can carry adversarial text from
|
|
58
|
+
* the original run (tool results, user input). Serve these tools to a
|
|
59
|
+
* SEPARATE debugging session over completed runs — not to the production
|
|
60
|
+
* agent mid-run — and treat tool outputs as data, not instructions.
|
|
61
|
+
*/
|
|
62
|
+
export declare function traceToolpack(artifacts: TraceToolpackArtifacts, options?: TraceToolpackOptions): Tool[];
|
|
63
|
+
/**
|
|
64
|
+
* Invoke a toolpack tool OUTSIDE an Agent (scripted debug sessions, tests,
|
|
65
|
+
* offline auditors). Mirrors the Agent's #9 boundary: args are validated
|
|
66
|
+
* against the tool's inputSchema first, and an invalid call returns the same
|
|
67
|
+
* model-visible correction string instead of executing.
|
|
68
|
+
*/
|
|
69
|
+
export declare function callTraceTool(tools: readonly Tool[], name: string, args?: Record<string, unknown>): Promise<string>;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Trace toolpack types — RFC-003 Part C (the introspection toolpack).
|
|
3
|
+
*
|
|
4
|
+
* Pattern: artifact bag — everything a debugging LLM needs to navigate a
|
|
5
|
+
* COMPLETED run, captured once and handed to `traceToolpack()`.
|
|
6
|
+
* Role: Input contract. The toolpack never re-runs anything; it serves
|
|
7
|
+
* bounded, id-addressed views over these frozen artifacts.
|
|
8
|
+
*/
|
|
9
|
+
import type { RuntimeSnapshot } from 'footprintjs';
|
|
10
|
+
import type { ControlDepLookup } from 'footprintjs/trace';
|
|
11
|
+
/**
|
|
12
|
+
* The frozen evidence of one completed run.
|
|
13
|
+
*
|
|
14
|
+
* - `snapshot` — `executor.getSnapshot()`. Carries the commit log (what every
|
|
15
|
+
* step wrote, with verbs + redaction + `untrackedSources` honesty markers),
|
|
16
|
+
* the execution tree (per-step name/description/reads/errors), the final
|
|
17
|
+
* shared state, and the `commitValues` mode discriminant.
|
|
18
|
+
* - `controlDeps` — OPTIONAL `controlDepRecorder().asLookup()` from the run.
|
|
19
|
+
* With it, causal slices include `[control: <rule label>]` edges to the
|
|
20
|
+
* decider that routed execution. Without it, slices say so explicitly.
|
|
21
|
+
* - `narrative` — OPTIONAL narrative lines (e.g. rendered from
|
|
22
|
+
* `executor.getNarrativeEntries()`). When present, a `read_narrative` tool
|
|
23
|
+
* is added for bounded, paginated access to the human-readable story.
|
|
24
|
+
*/
|
|
25
|
+
export interface TraceToolpackArtifacts {
|
|
26
|
+
readonly snapshot: RuntimeSnapshot;
|
|
27
|
+
readonly controlDeps?: ControlDepLookup;
|
|
28
|
+
readonly narrative?: readonly string[];
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Bounding dials. Every output is bounded BY DEFAULT — these set the
|
|
32
|
+
* defaults; per-call params (`maxDepth`, `maxNodes`, `maxChars`, `maxLines`)
|
|
33
|
+
* let the LLM ask for more up to hard caps the consumer cannot exceed.
|
|
34
|
+
*/
|
|
35
|
+
export interface TraceToolpackOptions {
|
|
36
|
+
/** Value-preview length in chars (trace_node / who_wrote). Default 160. */
|
|
37
|
+
readonly previewChars?: number;
|
|
38
|
+
/** Default causal-slice depth for trace_slice. Default 6 (hard cap 20). */
|
|
39
|
+
readonly sliceMaxDepth?: number;
|
|
40
|
+
/** Default causal-slice node budget for trace_slice. Default 25 (hard cap 100). */
|
|
41
|
+
readonly sliceMaxNodes?: number;
|
|
42
|
+
/** Default char budget for get_value. Default 2000 (hard cap 8000). */
|
|
43
|
+
readonly valueMaxChars?: number;
|
|
44
|
+
}
|
|
45
|
+
/** Resolved options with defaults applied (internal). */
|
|
46
|
+
export interface ResolvedToolpackOptions {
|
|
47
|
+
readonly previewChars: number;
|
|
48
|
+
readonly sliceMaxDepth: number;
|
|
49
|
+
readonly sliceMaxNodes: number;
|
|
50
|
+
readonly valueMaxChars: number;
|
|
51
|
+
}
|
|
52
|
+
/** Hard caps — per-call params clamp to these regardless of what the LLM asks for. */
|
|
53
|
+
export declare const TOOLPACK_HARD_CAPS: {
|
|
54
|
+
readonly sliceMaxDepth: 20;
|
|
55
|
+
readonly sliceMaxNodes: 100;
|
|
56
|
+
readonly valueMaxChars: 8000;
|
|
57
|
+
readonly narrativeMaxLines: 200;
|
|
58
|
+
};
|
|
59
|
+
export declare function resolveToolpackOptions(options?: TraceToolpackOptions): ResolvedToolpackOptions;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* agentfootprint/llm-providers — LLM provider adapters (canonical subpath).
|
|
3
|
+
*
|
|
4
|
+
* The Block B canonical name. Mirrors the parallel structure shipped in
|
|
5
|
+
* v2.5:
|
|
6
|
+
*
|
|
7
|
+
* agentfootprint/llm-providers ← LLM provider adapters (this file)
|
|
8
|
+
* agentfootprint/tool-providers ← tool dispatch + tool sources
|
|
9
|
+
* agentfootprint/memory-providers ← memory store adapters
|
|
10
|
+
* agentfootprint/security ← cross-cutting authorization
|
|
11
|
+
*
|
|
12
|
+
* The legacy `agentfootprint/providers` subpath stays available as an
|
|
13
|
+
* alias through the v2.x line — it points at the same exports. New
|
|
14
|
+
* code SHOULD import from `agentfootprint/llm-providers` for clarity:
|
|
15
|
+
* grep'ing for "llm-providers" finds every LLM-side import in one
|
|
16
|
+
* shot, parallel to "tool-providers" and "memory-providers".
|
|
17
|
+
*
|
|
18
|
+
* Pattern: Adapter (GoF) — concrete `LLMProvider` implementations that
|
|
19
|
+
* translate the agentfootprint port to a specific vendor SDK.
|
|
20
|
+
* Role: Outer ring (Hexagonal). Swappable at runtime; the Agent
|
|
21
|
+
* knows nothing about vendor specifics.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* import { mock, AnthropicProvider } from 'agentfootprint/llm-providers';
|
|
25
|
+
*/
|
|
26
|
+
export * from './providers.js';
|
|
@@ -0,0 +1,132 @@
|
|
|
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
|
+
export type { CommentaryTemplates as MessageCatalog } from '../recorders/observability/commentary/commentaryTemplates.js';
|
|
63
|
+
/**
|
|
64
|
+
* Canonical English commentary bundle. Alias of v2.4's
|
|
65
|
+
* `defaultCommentaryTemplates` — same symbol, friendlier framing.
|
|
66
|
+
*
|
|
67
|
+
* Keys mirror agentfootprint event types; values may contain
|
|
68
|
+
* `{{var}}` placeholders for runtime substitution.
|
|
69
|
+
*/
|
|
70
|
+
export declare const defaultCommentaryMessages: Readonly<Record<string, string>>;
|
|
71
|
+
/**
|
|
72
|
+
* Canonical English thinking bundle. Alias of v2.4's
|
|
73
|
+
* `defaultStatusTemplates`.
|
|
74
|
+
*
|
|
75
|
+
* Keys mirror agentfootprint event types; values may contain
|
|
76
|
+
* `{{var}}` placeholders for runtime substitution.
|
|
77
|
+
*/
|
|
78
|
+
export declare const defaultThinkingMessages: Readonly<Record<string, string>>;
|
|
79
|
+
/**
|
|
80
|
+
* Spread `overrides` on top of `defaults` so every key in `defaults`
|
|
81
|
+
* has a value (the override or the original). The result is a fresh
|
|
82
|
+
* object — neither input is mutated.
|
|
83
|
+
*
|
|
84
|
+
* Missing override keys fall back to the default; extra override
|
|
85
|
+
* keys are preserved (forward-compat for consumer-defined keys).
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* const merged = composeMessages(defaultCommentaryMessages, {
|
|
89
|
+
* 'stream.llm_start.iter1': 'My custom thinking line',
|
|
90
|
+
* });
|
|
91
|
+
*/
|
|
92
|
+
export declare function composeMessages<T extends Readonly<Record<string, string>>>(defaults: T, overrides?: Readonly<Record<string, string>>): Readonly<Record<string, string>>;
|
|
93
|
+
/**
|
|
94
|
+
* Validation options for `validateMessages`.
|
|
95
|
+
*/
|
|
96
|
+
export interface ValidateMessagesOptions {
|
|
97
|
+
/**
|
|
98
|
+
* Optional label for the error message (e.g., `'es-MX commentary'`).
|
|
99
|
+
* Defaults to `'message catalog'`.
|
|
100
|
+
*/
|
|
101
|
+
readonly label?: string;
|
|
102
|
+
/**
|
|
103
|
+
* When `true`, empty-string values FAIL validation (treated like a
|
|
104
|
+
* missing key). When `false` (default), empty strings are valid —
|
|
105
|
+
* the framework's default catalogs intentionally use empty values
|
|
106
|
+
* for events the consumer should skip rendering for.
|
|
107
|
+
*/
|
|
108
|
+
readonly forbidEmpty?: boolean;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Assert that every key in `requiredKeys` is present in `catalog`.
|
|
112
|
+
* Throws an Error listing every missing key — batched so consumers
|
|
113
|
+
* fix all at once instead of error-by-error.
|
|
114
|
+
*
|
|
115
|
+
* Useful at boot to catch drift between a consumer's locale pack and
|
|
116
|
+
* the framework's required key set.
|
|
117
|
+
*
|
|
118
|
+
* Empty-string values are VALID by default — the framework's default
|
|
119
|
+
* catalogs use `''` to signal "render nothing for this event."
|
|
120
|
+
* Pass `{ forbidEmpty: true }` to also reject empty values.
|
|
121
|
+
*
|
|
122
|
+
* @param catalog The (composed) message catalog to validate.
|
|
123
|
+
* @param requiredKeys The keys consumers must define. Typically
|
|
124
|
+
* `Object.keys(defaultCommentaryMessages)` or
|
|
125
|
+
* `Object.keys(defaultThinkingMessages)`.
|
|
126
|
+
* @param opts Optional `{ label, forbidEmpty }` (or a bare
|
|
127
|
+
* string label for back-compat with simple use).
|
|
128
|
+
*
|
|
129
|
+
* @throws Error when any required key is missing (or empty under
|
|
130
|
+
* `forbidEmpty`).
|
|
131
|
+
*/
|
|
132
|
+
export declare function validateMessages(catalog: Readonly<Record<string, string>>, requiredKeys: readonly string[], opts?: ValidateMessagesOptions | string): void;
|
|
@@ -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';
|