agentfootprint 6.44.0 → 6.45.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ai-instructions/setup.sh +0 -0
- package/dist/core/agent/buildAgentChart.js +2 -1
- package/dist/core/agent/buildAgentChart.js.map +1 -1
- package/dist/core/agent/buildDynamicAgentChart.js +3 -1
- package/dist/core/agent/buildDynamicAgentChart.js.map +1 -1
- package/dist/core/agent/stages/pickEntry.js +3 -1
- package/dist/core/agent/stages/pickEntry.js.map +1 -1
- package/dist/esm/adapters/identity/agentcore.d.ts +100 -0
- package/dist/esm/adapters/llm/AnthropicProvider.d.ts +130 -0
- package/dist/esm/adapters/llm/BedrockProvider.d.ts +100 -0
- package/dist/esm/adapters/llm/BrowserAnthropicProvider.d.ts +41 -0
- package/dist/esm/adapters/llm/BrowserOpenAIProvider.d.ts +95 -0
- package/dist/esm/adapters/llm/MockProvider.d.ts +153 -0
- package/dist/esm/adapters/llm/OpenAIProvider.d.ts +220 -0
- package/dist/esm/adapters/llm/createProvider.d.ts +85 -0
- package/dist/esm/adapters/memory/agentcore.d.ts +146 -0
- package/dist/esm/adapters/memory/bedrockAgentMemory.d.ts +95 -0
- package/dist/esm/adapters/memory/redis.d.ts +127 -0
- package/dist/esm/adapters/observability/agentcore.d.ts +67 -0
- package/dist/esm/adapters/observability/audit.d.ts +254 -0
- package/dist/esm/adapters/observability/cloudwatch.d.ts +96 -0
- package/dist/esm/adapters/observability/otel.d.ts +237 -0
- package/dist/esm/adapters/observability/xray.d.ts +88 -0
- package/dist/esm/adapters/types.d.ts +378 -0
- package/dist/esm/bridge/eventMeta.d.ts +59 -0
- package/dist/esm/cache/CacheDecisionSubflow.d.ts +85 -0
- package/dist/esm/cache/CacheGateDecider.d.ts +127 -0
- package/dist/esm/cache/applyCachePolicy.d.ts +37 -0
- package/dist/esm/cache/cacheRecorder.d.ts +85 -0
- package/dist/esm/cache/index.d.ts +33 -0
- package/dist/esm/cache/strategies/AnthropicCacheStrategy.d.ts +38 -0
- package/dist/esm/cache/strategies/BedrockCacheStrategy.d.ts +33 -0
- package/dist/esm/cache/strategies/NoOpCacheStrategy.d.ts +29 -0
- package/dist/esm/cache/strategies/OpenAICacheStrategy.d.ts +36 -0
- package/dist/esm/cache/strategyRegistry.d.ts +45 -0
- package/dist/esm/cache/types.d.ts +243 -0
- package/dist/esm/conventions.d.ts +203 -0
- package/dist/esm/core/Agent.d.ts +355 -0
- package/dist/esm/core/LLMCall.d.ts +139 -0
- package/dist/esm/core/RunnerBase.d.ts +267 -0
- package/dist/esm/core/agent/AgentBuilder.d.ts +565 -0
- package/dist/esm/core/agent/buildAgentChart.d.ts +109 -0
- package/dist/esm/core/agent/buildAgentChart.js +2 -1
- package/dist/esm/core/agent/buildAgentChart.js.map +1 -1
- package/dist/esm/core/agent/buildAgentMessageApiChart.d.ts +40 -0
- package/dist/esm/core/agent/buildCacheSubflow.d.ts +35 -0
- package/dist/esm/core/agent/buildDynamicAgentChart.d.ts +56 -0
- package/dist/esm/core/agent/buildDynamicAgentChart.js +3 -1
- package/dist/esm/core/agent/buildDynamicAgentChart.js.map +1 -1
- package/dist/esm/core/agent/buildMessageApiChart.d.ts +47 -0
- package/dist/esm/core/agent/buildToolRegistry.d.ts +61 -0
- package/dist/esm/core/agent/memoryRecallInjections.d.ts +8 -0
- package/dist/esm/core/agent/stages/breakFinal.d.ts +22 -0
- package/dist/esm/core/agent/stages/callLLM.d.ts +74 -0
- package/dist/esm/core/agent/stages/pickEntry.d.ts +19 -0
- package/dist/esm/core/agent/stages/pickEntry.js +3 -1
- package/dist/esm/core/agent/stages/pickEntry.js.map +1 -1
- package/dist/esm/core/agent/stages/prepareFinal.d.ts +19 -0
- package/dist/esm/core/agent/stages/reliabilityExecution.d.ts +135 -0
- package/dist/esm/core/agent/stages/route.d.ts +18 -0
- package/dist/esm/core/agent/stages/seed.d.ts +53 -0
- package/dist/esm/core/agent/stages/toolCalls.d.ts +76 -0
- package/dist/esm/core/agent/toolArgsValidation.d.ts +62 -0
- package/dist/esm/core/agent/types.d.ts +382 -0
- package/dist/esm/core/agent/validators.d.ts +52 -0
- package/dist/esm/core/cost.d.ts +38 -0
- package/dist/esm/core/flowchartAsTool.d.ts +200 -0
- package/dist/esm/core/humanizeLLMError.d.ts +23 -0
- package/dist/esm/core/outputFallback.d.ts +139 -0
- package/dist/esm/core/outputSchema.d.ts +127 -0
- package/dist/esm/core/pause.d.ts +74 -0
- package/dist/esm/core/runCheckpoint.d.ts +179 -0
- package/dist/esm/core/runner.d.ts +203 -0
- package/dist/esm/core/slots/buildMessagesSlot.d.ts +40 -0
- package/dist/esm/core/slots/buildSystemPromptSlot.d.ts +41 -0
- package/dist/esm/core/slots/buildThinkingSubflow.d.ts +40 -0
- package/dist/esm/core/slots/buildToolsSlot.d.ts +60 -0
- package/dist/esm/core/slots/helpers.d.ts +27 -0
- package/dist/esm/core/toolContract.d.ts +43 -0
- package/dist/esm/core/tools.d.ts +90 -0
- package/dist/esm/core/translator.d.ts +94 -0
- package/dist/esm/core-flow/Conditional.d.ts +119 -0
- package/dist/esm/core-flow/Loop.d.ts +160 -0
- package/dist/esm/core-flow/Parallel.d.ts +360 -0
- package/dist/esm/core-flow/Sequence.d.ts +133 -0
- package/dist/esm/events/dispatcher.d.ts +134 -0
- package/dist/esm/events/payloads.d.ts +761 -0
- package/dist/esm/events/registry.d.ts +198 -0
- package/dist/esm/events/types.d.ts +70 -0
- package/dist/esm/identity/kinds.d.ts +36 -0
- package/dist/esm/identity/staticTokens.d.ts +28 -0
- package/dist/esm/identity/types.d.ts +113 -0
- package/dist/esm/identity/withCredentialRetry.d.ts +64 -0
- package/dist/esm/identity.d.ts +31 -0
- package/dist/esm/index.d.ts +64 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/injection-engine.d.ts +4 -0
- package/dist/esm/lib/canonicalJson.d.ts +56 -0
- package/dist/esm/lib/context-bisect/ablation.d.ts +109 -0
- package/dist/esm/lib/context-bisect/bisect.d.ts +75 -0
- package/dist/esm/lib/context-bisect/cost.d.ts +37 -0
- package/dist/esm/lib/context-bisect/index.d.ts +31 -0
- package/dist/esm/lib/context-bisect/index.js +3 -0
- package/dist/esm/lib/context-bisect/index.js.map +1 -1
- package/dist/esm/lib/context-bisect/llmEdgeWeigher.d.ts +124 -0
- package/dist/esm/lib/context-bisect/localize.d.ts +152 -0
- package/dist/esm/lib/context-bisect/localize.js +2 -0
- package/dist/esm/lib/context-bisect/localize.js.map +1 -1
- package/dist/esm/lib/context-bisect/loop-recall.d.ts +97 -0
- package/dist/esm/lib/context-bisect/missingContext.d.ts +71 -0
- package/dist/esm/lib/context-bisect/restoration.d.ts +39 -0
- package/dist/esm/lib/context-bisect/toBacktrackTrace.d.ts +138 -0
- package/dist/esm/lib/context-bisect/trajectory.d.ts +168 -0
- package/dist/esm/lib/context-bisect/types.d.ts +448 -0
- package/dist/esm/lib/context-bisect/walk-to-root.d.ts +103 -0
- package/dist/esm/lib/influence-core/attributability.d.ts +72 -0
- package/dist/esm/lib/influence-core/cache.d.ts +94 -0
- package/dist/esm/lib/influence-core/contrastive.d.ts +26 -0
- package/dist/esm/lib/influence-core/index.d.ts +34 -0
- package/dist/esm/lib/influence-core/margin.d.ts +33 -0
- package/dist/esm/lib/influence-core/signals.d.ts +128 -0
- package/dist/esm/lib/influence-core/similarity.d.ts +25 -0
- package/dist/esm/lib/influence-core/types.d.ts +252 -0
- package/dist/esm/lib/injection-engine/SkillRegistry.d.ts +147 -0
- package/dist/esm/lib/injection-engine/buildInjectionEngineSubflow.d.ts +110 -0
- package/dist/esm/lib/injection-engine/buildInjectionEngineSubflow.js +1 -0
- package/dist/esm/lib/injection-engine/buildInjectionEngineSubflow.js.map +1 -1
- package/dist/esm/lib/injection-engine/entryScorer.d.ts +93 -0
- package/dist/esm/lib/injection-engine/entryScorer.js +172 -0
- package/dist/esm/lib/injection-engine/entryScorer.js.map +1 -0
- package/dist/esm/lib/injection-engine/evaluator.d.ts +24 -0
- package/dist/esm/lib/injection-engine/factories/defineFact.d.ts +60 -0
- package/dist/esm/lib/injection-engine/factories/defineInjection.d.ts +41 -0
- package/dist/esm/lib/injection-engine/factories/defineInstruction.d.ts +78 -0
- package/dist/esm/lib/injection-engine/factories/defineRelevanceHint.d.ts +26 -0
- package/dist/esm/lib/injection-engine/factories/defineSkill.d.ts +160 -0
- package/dist/esm/lib/injection-engine/factories/defineSteering.d.ts +39 -0
- package/dist/esm/lib/injection-engine/index.d.ts +22 -0
- package/dist/esm/lib/injection-engine/index.js +1 -0
- package/dist/esm/lib/injection-engine/index.js.map +1 -1
- package/dist/esm/lib/injection-engine/skillContract.d.ts +29 -0
- package/dist/esm/lib/injection-engine/skillGraph.d.ts +289 -0
- package/dist/esm/lib/injection-engine/skillGraph.js +35 -41
- package/dist/esm/lib/injection-engine/skillGraph.js.map +1 -1
- package/dist/esm/lib/injection-engine/skillGraphCheckup.d.ts +49 -0
- package/dist/esm/lib/injection-engine/skillTools.d.ts +72 -0
- package/dist/esm/lib/injection-engine/softmax.d.ts +11 -0
- package/dist/esm/lib/injection-engine/types.d.ts +229 -0
- package/dist/esm/lib/injection-engine/types.js.map +1 -1
- package/dist/esm/lib/lazyRequire.d.ts +29 -0
- package/dist/esm/lib/mcp/index.d.ts +9 -0
- package/dist/esm/lib/mcp/mcpClient.d.ts +46 -0
- package/dist/esm/lib/mcp/mockMcpClient.d.ts +65 -0
- package/dist/esm/lib/mcp/types.d.ts +133 -0
- package/dist/esm/lib/rag/defineRAG.d.ts +139 -0
- package/dist/esm/lib/rag/index.d.ts +7 -0
- package/dist/esm/lib/rag/indexDocuments.d.ts +105 -0
- package/dist/esm/lib/tool-lint/analyze.d.ts +83 -0
- package/dist/esm/lib/tool-lint/cli.d.ts +43 -0
- package/dist/esm/lib/tool-lint/format.d.ts +18 -0
- package/dist/esm/lib/tool-lint/index.d.ts +23 -0
- package/dist/esm/lib/tool-lint/rules.d.ts +85 -0
- package/dist/esm/lib/tool-lint/types.d.ts +155 -0
- package/dist/esm/lib/trace-toolpack/bounded.d.ts +47 -0
- package/dist/esm/lib/trace-toolpack/debugPrompt.d.ts +19 -0
- package/dist/esm/lib/trace-toolpack/index.d.ts +20 -0
- package/dist/esm/lib/trace-toolpack/lazyToolpack.d.ts +35 -0
- package/dist/esm/lib/trace-toolpack/selfExplain.d.ts +100 -0
- package/dist/esm/lib/trace-toolpack/traceDebugAgent.d.ts +42 -0
- package/dist/esm/lib/trace-toolpack/traceToolpack.d.ts +69 -0
- package/dist/esm/lib/trace-toolpack/types.d.ts +59 -0
- package/dist/esm/llm-providers.d.ts +26 -0
- package/dist/esm/locales/index.d.ts +132 -0
- package/dist/esm/memory/beats/extractBeats.d.ts +61 -0
- package/dist/esm/memory/beats/extractor.d.ts +47 -0
- package/dist/esm/memory/beats/formatAsNarrative.d.ts +62 -0
- package/dist/esm/memory/beats/heuristicExtractor.d.ts +37 -0
- package/dist/esm/memory/beats/index.d.ts +12 -0
- package/dist/esm/memory/beats/llmExtractor.d.ts +56 -0
- package/dist/esm/memory/beats/types.d.ts +60 -0
- package/dist/esm/memory/beats/writeBeats.d.ts +22 -0
- package/dist/esm/memory/causal/evidenceRecorder.d.ts +66 -0
- package/dist/esm/memory/causal/index.d.ts +6 -0
- package/dist/esm/memory/causal/loadSnapshot.d.ts +51 -0
- package/dist/esm/memory/causal/snapshotPipeline.d.ts +35 -0
- package/dist/esm/memory/causal/types.d.ts +130 -0
- package/dist/esm/memory/causal/writeSnapshot.d.ts +73 -0
- package/dist/esm/memory/define.d.ts +63 -0
- package/dist/esm/memory/define.types.d.ts +276 -0
- package/dist/esm/memory/define.types.js +1 -1
- package/dist/esm/memory/embedding/cosine.d.ts +18 -0
- package/dist/esm/memory/embedding/embedMessages.d.ts +58 -0
- package/dist/esm/memory/embedding/index.d.ts +8 -0
- package/dist/esm/memory/embedding/loadRelevant.d.ts +51 -0
- package/dist/esm/memory/embedding/mockEmbedder.d.ts +22 -0
- package/dist/esm/memory/embedding/types.d.ts +46 -0
- package/dist/esm/memory/entry/decay.d.ts +36 -0
- package/dist/esm/memory/entry/index.d.ts +2 -0
- package/dist/esm/memory/entry/types.d.ts +140 -0
- package/dist/esm/memory/facts/extractFacts.d.ts +50 -0
- package/dist/esm/memory/facts/extractor.d.ts +33 -0
- package/dist/esm/memory/facts/formatFacts.d.ts +60 -0
- package/dist/esm/memory/facts/index.d.ts +14 -0
- package/dist/esm/memory/facts/llmFactExtractor.d.ts +64 -0
- package/dist/esm/memory/facts/loadFacts.d.ts +43 -0
- package/dist/esm/memory/facts/patternFactExtractor.d.ts +2 -0
- package/dist/esm/memory/facts/types.d.ts +68 -0
- package/dist/esm/memory/facts/writeFacts.d.ts +19 -0
- package/dist/esm/memory/identity/index.d.ts +2 -0
- package/dist/esm/memory/identity/types.d.ts +49 -0
- package/dist/esm/memory/index.d.ts +19 -0
- package/dist/esm/memory/pipeline/auto.d.ts +59 -0
- package/dist/esm/memory/pipeline/default.d.ts +49 -0
- package/dist/esm/memory/pipeline/ephemeral.d.ts +28 -0
- package/dist/esm/memory/pipeline/fact.d.ts +26 -0
- package/dist/esm/memory/pipeline/index.d.ts +13 -0
- package/dist/esm/memory/pipeline/narrative.d.ts +35 -0
- package/dist/esm/memory/pipeline/semantic.d.ts +37 -0
- package/dist/esm/memory/pipeline/types.d.ts +31 -0
- package/dist/esm/memory/stages/formatDefault.d.ts +64 -0
- package/dist/esm/memory/stages/index.d.ts +13 -0
- package/dist/esm/memory/stages/loadRecent.d.ts +49 -0
- package/dist/esm/memory/stages/pickByBudget.d.ts +63 -0
- package/dist/esm/memory/stages/summarize.d.ts +87 -0
- package/dist/esm/memory/stages/tokenize.d.ts +43 -0
- package/dist/esm/memory/stages/types.d.ts +75 -0
- package/dist/esm/memory/stages/writeMessages.d.ts +71 -0
- package/dist/esm/memory/store/InMemoryStore.d.ts +62 -0
- package/dist/esm/memory/store/index.d.ts +2 -0
- package/dist/esm/memory/store/types.d.ts +223 -0
- package/dist/esm/memory/wire/index.d.ts +2 -0
- package/dist/esm/memory/wire/mountMemoryPipeline.d.ts +108 -0
- package/dist/esm/memory-providers.d.ts +37 -0
- package/dist/esm/observability/contextError/finders/compareFinders.d.ts +19 -0
- package/dist/esm/observability/contextError/finders/index.d.ts +22 -0
- package/dist/esm/observability/contextError/finders/rankSuspects.d.ts +2 -0
- package/dist/esm/observability/contextError/finders/removeAndRetry.d.ts +11 -0
- package/dist/esm/observability/contextError/finders/shrinkToCause.d.ts +11 -0
- package/dist/esm/observability/contextError/finders/testManyCombos.d.ts +11 -0
- package/dist/esm/observability/contextError/finders/traceSteps.d.ts +2 -0
- package/dist/esm/observability/contextError/finders/types.d.ts +88 -0
- package/dist/esm/observability-providers.d.ts +46 -0
- package/dist/esm/observe.d.ts +62 -0
- package/dist/esm/patterns/Debate.d.ts +39 -0
- package/dist/esm/patterns/MapReduce.d.ts +66 -0
- package/dist/esm/patterns/Reflection.d.ts +51 -0
- package/dist/esm/patterns/SelfConsistency.d.ts +43 -0
- package/dist/esm/patterns/Swarm.d.ts +60 -0
- package/dist/esm/patterns/ToT.d.ts +53 -0
- package/dist/esm/patterns/index.d.ts +22 -0
- package/dist/esm/providers.d.ts +33 -0
- package/dist/esm/recorders/core/AgentRecorder.d.ts +15 -0
- package/dist/esm/recorders/core/CompositionRecorder.d.ts +17 -0
- package/dist/esm/recorders/core/ContextEvaluatedRecorder.d.ts +23 -0
- package/dist/esm/recorders/core/ContextRecorder.d.ts +47 -0
- package/dist/esm/recorders/core/CostRecorder.d.ts +14 -0
- package/dist/esm/recorders/core/EmitBridge.d.ts +30 -0
- package/dist/esm/recorders/core/ErrorBridge.d.ts +38 -0
- package/dist/esm/recorders/core/EvalRecorder.d.ts +16 -0
- package/dist/esm/recorders/core/MemoryRecorder.d.ts +17 -0
- package/dist/esm/recorders/core/PermissionRecorder.d.ts +16 -0
- package/dist/esm/recorders/core/ReliabilityRecorder.d.ts +24 -0
- package/dist/esm/recorders/core/SkillRecorder.d.ts +14 -0
- package/dist/esm/recorders/core/StreamRecorder.d.ts +15 -0
- package/dist/esm/recorders/core/ToolsRecorder.d.ts +18 -0
- package/dist/esm/recorders/core/ValidationRecorder.d.ts +16 -0
- package/dist/esm/recorders/core/contextEngineering.d.ts +136 -0
- package/dist/esm/recorders/core/typedEmit.d.ts +34 -0
- package/dist/esm/recorders/core/types.d.ts +97 -0
- package/dist/esm/recorders/observability/AgentThinkingTraceRecorder.d.ts +117 -0
- package/dist/esm/recorders/observability/BoundaryRecorder.d.ts +546 -0
- package/dist/esm/recorders/observability/FlowchartRecorder.d.ts +220 -0
- package/dist/esm/recorders/observability/LiveStateRecorder.d.ts +250 -0
- package/dist/esm/recorders/observability/LoggingRecorder.d.ts +91 -0
- package/dist/esm/recorders/observability/RouteRecorder.d.ts +83 -0
- package/dist/esm/recorders/observability/RunStepRecorder.d.ts +231 -0
- package/dist/esm/recorders/observability/StatusRecorder.d.ts +36 -0
- package/dist/esm/recorders/observability/ToolChoiceRecorder.d.ts +164 -0
- package/dist/esm/recorders/observability/ToolLineageRecorder.d.ts +71 -0
- package/dist/esm/recorders/observability/commentary/commentaryTemplates.d.ts +105 -0
- package/dist/esm/recorders/observability/internal/ActorArrowClassifier.d.ts +25 -0
- package/dist/esm/recorders/observability/internal/CandidateAnswerBuffer.d.ts +28 -0
- package/dist/esm/recorders/observability/internal/ForkTracker.d.ts +60 -0
- package/dist/esm/recorders/observability/internal/RootInferrer.d.ts +51 -0
- package/dist/esm/recorders/observability/internal/SequenceSiblingTracker.d.ts +24 -0
- package/dist/esm/recorders/observability/localObservability.d.ts +48 -0
- package/dist/esm/recorders/observability/observeRunId.d.ts +36 -0
- package/dist/esm/recorders/observability/status/statusTemplates.d.ts +106 -0
- package/dist/esm/recorders/observability/trace.d.ts +119 -0
- package/dist/esm/reliability/CircuitBreaker.d.ts +75 -0
- package/dist/esm/reliability/buildReliabilityGateChart.d.ts +53 -0
- package/dist/esm/reliability/classifyError.d.ts +28 -0
- package/dist/esm/reliability/index.d.ts +35 -0
- package/dist/esm/reliability/types.d.ts +327 -0
- package/dist/esm/resilience/fallbackProvider.d.ts +33 -0
- package/dist/esm/resilience/index.d.ts +21 -0
- package/dist/esm/resilience/withCircuitBreaker.d.ts +129 -0
- package/dist/esm/resilience/withFallback.d.ts +45 -0
- package/dist/esm/resilience/withRetry.d.ts +71 -0
- package/dist/esm/security/PermissionPolicy.d.ts +124 -0
- package/dist/esm/security/PolicyHaltError.d.ts +72 -0
- package/dist/esm/security/extractSequence.d.ts +46 -0
- package/dist/esm/security/index.d.ts +44 -0
- package/dist/esm/security/thinkingRedaction.d.ts +50 -0
- package/dist/esm/status.d.ts +48 -0
- package/dist/esm/strategies/attach.d.ts +47 -0
- package/dist/esm/strategies/compose.d.ts +48 -0
- package/dist/esm/strategies/defaults/chatBubbleLiveStatus.d.ts +36 -0
- package/dist/esm/strategies/defaults/consoleObservability.d.ts +42 -0
- package/dist/esm/strategies/defaults/inMemorySinkCost.d.ts +50 -0
- package/dist/esm/strategies/defaults/index.d.ts +30 -0
- package/dist/esm/strategies/defaults/noopLens.d.ts +28 -0
- package/dist/esm/strategies/index.d.ts +36 -0
- package/dist/esm/strategies/registry.d.ts +70 -0
- package/dist/esm/strategies/types.d.ts +303 -0
- package/dist/esm/stream.d.ts +82 -0
- package/dist/esm/thinking/AnthropicThinkingHandler.d.ts +42 -0
- package/dist/esm/thinking/MockThinkingHandler.d.ts +50 -0
- package/dist/esm/thinking/OpenAIThinkingHandler.d.ts +37 -0
- package/dist/esm/thinking/index.d.ts +51 -0
- package/dist/esm/thinking/registry.d.ts +33 -0
- package/dist/esm/thinking/types.d.ts +162 -0
- package/dist/esm/tool-providers/gatedTools.d.ts +36 -0
- package/dist/esm/tool-providers/index.d.ts +41 -0
- package/dist/esm/tool-providers/skillScopedTools.d.ts +45 -0
- package/dist/esm/tool-providers/staticTools.d.ts +21 -0
- package/dist/esm/tool-providers/types.d.ts +138 -0
- package/dist/index.js +6 -2
- package/dist/index.js.map +1 -1
- package/dist/lib/context-bisect/index.js +3 -0
- package/dist/lib/context-bisect/index.js.map +1 -1
- package/dist/lib/context-bisect/localize.js +2 -0
- package/dist/lib/context-bisect/localize.js.map +1 -1
- package/dist/lib/injection-engine/buildInjectionEngineSubflow.js +1 -0
- package/dist/lib/injection-engine/buildInjectionEngineSubflow.js.map +1 -1
- package/dist/lib/injection-engine/entryScorer.js +178 -0
- package/dist/lib/injection-engine/entryScorer.js.map +1 -0
- package/dist/lib/injection-engine/index.js +5 -1
- package/dist/lib/injection-engine/index.js.map +1 -1
- package/dist/lib/injection-engine/skillGraph.js +35 -41
- package/dist/lib/injection-engine/skillGraph.js.map +1 -1
- package/dist/lib/injection-engine/types.js.map +1 -1
- package/dist/memory/define.types.js +1 -1
- package/dist/types/core/agent/buildAgentChart.d.ts.map +1 -1
- package/dist/types/core/agent/buildDynamicAgentChart.d.ts.map +1 -1
- package/dist/types/core/agent/stages/pickEntry.d.ts.map +1 -1
- package/dist/types/core/agent/types.d.ts +8 -4
- package/dist/types/core/agent/types.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/lib/context-bisect/index.d.ts +3 -0
- package/dist/types/lib/context-bisect/index.d.ts.map +1 -1
- package/dist/types/lib/context-bisect/localize.d.ts +2 -0
- package/dist/types/lib/context-bisect/localize.d.ts.map +1 -1
- package/dist/types/lib/injection-engine/buildInjectionEngineSubflow.d.ts.map +1 -1
- package/dist/types/lib/injection-engine/entryScorer.d.ts +94 -0
- package/dist/types/lib/injection-engine/entryScorer.d.ts.map +1 -0
- package/dist/types/lib/injection-engine/index.d.ts +1 -0
- package/dist/types/lib/injection-engine/index.d.ts.map +1 -1
- package/dist/types/lib/injection-engine/skillGraph.d.ts +21 -24
- package/dist/types/lib/injection-engine/skillGraph.d.ts.map +1 -1
- package/dist/types/lib/injection-engine/types.d.ts +9 -4
- package/dist/types/lib/injection-engine/types.d.ts.map +1 -1
- package/dist/types/memory/define.types.d.ts +1 -1
- package/package.json +203 -56
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BedrockAgentMemory — read the **auto-generated session-summary memory** of a
|
|
3
|
+
* (legacy) Amazon **Bedrock Agents** agent (peer-dep `@aws-sdk/client-bedrock-agent-runtime`).
|
|
4
|
+
*
|
|
5
|
+
* import { BedrockAgentMemory } from 'agentfootprint/memory-providers';
|
|
6
|
+
*
|
|
7
|
+
* const mem = new BedrockAgentMemory({ agentId, agentAliasId, region: 'us-west-2' });
|
|
8
|
+
* const summaries = await mem.readSummaries(userMemoryId); // string summaries Bedrock wrote
|
|
9
|
+
*
|
|
10
|
+
* **This is NOT a `MemoryStore`** — and intentionally so. Bedrock Agents *owns the writes*:
|
|
11
|
+
* the agent generates `SESSION_SUMMARY` records itself (`GetAgentMemory` reads them,
|
|
12
|
+
* `DeleteAgentMemory` clears them). There is no "put an arbitrary entry" operation, so wrapping
|
|
13
|
+
* it as a `defineMemory({ store })` would be a "store that can't store." Instead it's a small
|
|
14
|
+
* **reader** you use to *surface* Bedrock's built-in memory — e.g. inject the summaries as a
|
|
15
|
+
* Fact/context block into an agentfootprint agent.
|
|
16
|
+
*
|
|
17
|
+
* For a real read/write agent memory store on AWS, use `AgentCoreStore` (the newer
|
|
18
|
+
* Bedrock **AgentCore** platform) — that's the go-forward path; this targets the prior-gen
|
|
19
|
+
* Bedrock Agents product and exists for teams migrating off it.
|
|
20
|
+
*
|
|
21
|
+
* Role: Outer ring. Lazy-requires the AWS SDK; zero cost when unused.
|
|
22
|
+
*/
|
|
23
|
+
/** One auto-generated session summary from Bedrock Agents memory. */
|
|
24
|
+
export interface BedrockAgentSummary {
|
|
25
|
+
readonly sessionId: string;
|
|
26
|
+
readonly summaryText: string;
|
|
27
|
+
/** ISO timestamps (the SDK returns Date; serialized here for portability). */
|
|
28
|
+
readonly sessionStartTime?: string;
|
|
29
|
+
readonly sessionExpiryTime?: string;
|
|
30
|
+
}
|
|
31
|
+
/** Minimal surface the reader uses; tests inject a mock via `_client`. */
|
|
32
|
+
export interface BedrockAgentMemoryLikeClient {
|
|
33
|
+
getSessionSummaries(input: {
|
|
34
|
+
agentId: string;
|
|
35
|
+
agentAliasId: string;
|
|
36
|
+
memoryId: string;
|
|
37
|
+
maxItems?: number;
|
|
38
|
+
nextToken?: string;
|
|
39
|
+
}): Promise<{
|
|
40
|
+
summaries: readonly BedrockAgentSummary[];
|
|
41
|
+
nextToken?: string;
|
|
42
|
+
}>;
|
|
43
|
+
deleteMemory(input: {
|
|
44
|
+
agentId: string;
|
|
45
|
+
agentAliasId: string;
|
|
46
|
+
memoryId: string;
|
|
47
|
+
sessionId?: string;
|
|
48
|
+
}): Promise<void>;
|
|
49
|
+
}
|
|
50
|
+
export interface BedrockAgentMemoryOptions {
|
|
51
|
+
/** The Bedrock Agent id whose memory to read. Required. */
|
|
52
|
+
readonly agentId: string;
|
|
53
|
+
/** The Bedrock Agent alias id. Required. */
|
|
54
|
+
readonly agentAliasId: string;
|
|
55
|
+
/** AWS region (when constructing the SDK client internally). */
|
|
56
|
+
readonly region?: string;
|
|
57
|
+
/** Pre-built client (shares one SDK config across the host app). */
|
|
58
|
+
readonly client?: BedrockAgentMemoryLikeClient;
|
|
59
|
+
/** Default page size for `readSummaries`. Default 20. */
|
|
60
|
+
readonly maxItems?: number;
|
|
61
|
+
/** @internal Test injection — skips the SDK require. */
|
|
62
|
+
readonly _client?: BedrockAgentMemoryLikeClient;
|
|
63
|
+
/** @internal Test injection — the AWS SDK module. */
|
|
64
|
+
readonly _sdk?: BedrockAgentRuntimeSdkModule;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Read-only reader for Bedrock Agents' auto session-summary memory.
|
|
68
|
+
*
|
|
69
|
+
* @throws when `@aws-sdk/client-bedrock-agent-runtime` is not installed and no
|
|
70
|
+
* `_client`/`_sdk` is supplied.
|
|
71
|
+
*/
|
|
72
|
+
export declare class BedrockAgentMemory {
|
|
73
|
+
private readonly client;
|
|
74
|
+
private readonly agentId;
|
|
75
|
+
private readonly agentAliasId;
|
|
76
|
+
private readonly maxItems;
|
|
77
|
+
constructor(options: BedrockAgentMemoryOptions);
|
|
78
|
+
/** All session summaries Bedrock generated for `memoryId` (paginated). */
|
|
79
|
+
readSummaries(memoryId: string, opts?: {
|
|
80
|
+
maxItems?: number;
|
|
81
|
+
}): Promise<BedrockAgentSummary[]>;
|
|
82
|
+
/** The concatenated summary text — handy to inject as a single context/Fact block. */
|
|
83
|
+
readText(memoryId: string): Promise<string>;
|
|
84
|
+
/** Clear Bedrock's memory for `memoryId` (optionally a single `sessionId`). */
|
|
85
|
+
forget(memoryId: string, sessionId?: string): Promise<void>;
|
|
86
|
+
}
|
|
87
|
+
export interface BedrockAgentRuntimeSdkModule {
|
|
88
|
+
readonly BedrockAgentRuntimeClient?: new (config: {
|
|
89
|
+
region?: string;
|
|
90
|
+
}) => {
|
|
91
|
+
send(cmd: unknown): Promise<unknown>;
|
|
92
|
+
};
|
|
93
|
+
readonly GetAgentMemoryCommand?: new (input: unknown) => unknown;
|
|
94
|
+
readonly DeleteAgentMemoryCommand?: new (input: unknown) => unknown;
|
|
95
|
+
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RedisStore — Redis-backed `MemoryStore` adapter (peer-dep `ioredis`).
|
|
3
|
+
*
|
|
4
|
+
* Import from the canonical subpath (the `agentfootprint/memory-redis` alias
|
|
5
|
+
* was removed in 4.0.0):
|
|
6
|
+
*
|
|
7
|
+
* import { RedisStore } from 'agentfootprint/memory-providers';
|
|
8
|
+
*
|
|
9
|
+
* const store = new RedisStore({ url: 'redis://localhost:6379' });
|
|
10
|
+
*
|
|
11
|
+
* Pattern: Adapter (GoF) — translates the `MemoryStore` interface onto
|
|
12
|
+
* Redis primitives (key/value for entries, set for signatures,
|
|
13
|
+
* hash for feedback aggregates).
|
|
14
|
+
* Role: Outer ring. Lazy-requires `ioredis`; no runtime cost when
|
|
15
|
+
* another adapter is in use.
|
|
16
|
+
* Emits: N/A (storage adapters don't emit; recorders observe the
|
|
17
|
+
* memory pipeline that calls them).
|
|
18
|
+
*
|
|
19
|
+
* Vector search (`search()`) is NOT implemented in this adapter — RedisSearch
|
|
20
|
+
* is a separate Redis module with its own API surface. A `RedisSearchStore`
|
|
21
|
+
* may ship in a future release. RAG users with v2.3 should use
|
|
22
|
+
* `InMemoryStore` until the search-capable adapter lands.
|
|
23
|
+
*
|
|
24
|
+
* Concurrency model:
|
|
25
|
+
* - `put` / `putMany` use simple SET / pipelined SET (last-write-wins).
|
|
26
|
+
* - `putIfVersion` uses a small Lua script for atomic version compare-and-swap.
|
|
27
|
+
* - Multi-writer correctness ⇒ prefer `putIfVersion` in stage code.
|
|
28
|
+
*/
|
|
29
|
+
import type { ListOptions, ListResult, MemoryStore, PutIfVersionResult } from '../../memory/store/types.js';
|
|
30
|
+
import type { MemoryEntry } from '../../memory/entry/index.js';
|
|
31
|
+
import type { MemoryIdentity } from '../../memory/identity/index.js';
|
|
32
|
+
/**
|
|
33
|
+
* Minimal `ioredis` client surface this adapter needs. Defined locally so
|
|
34
|
+
* we don't take a hard import on `ioredis` (lazy peer-dep) and tests can
|
|
35
|
+
* inject a mock implementation via `_client`.
|
|
36
|
+
*/
|
|
37
|
+
export interface RedisLikeClient {
|
|
38
|
+
get(key: string): Promise<string | null>;
|
|
39
|
+
set(key: string, value: string, ...args: ReadonlyArray<string | number>): Promise<unknown>;
|
|
40
|
+
del(...keys: ReadonlyArray<string>): Promise<number>;
|
|
41
|
+
sadd(key: string, ...members: ReadonlyArray<string>): Promise<number>;
|
|
42
|
+
srem(key: string, ...members: ReadonlyArray<string>): Promise<number>;
|
|
43
|
+
sismember(key: string, member: string): Promise<number>;
|
|
44
|
+
smembers(key: string): Promise<readonly string[]>;
|
|
45
|
+
hgetall(key: string): Promise<Record<string, string>>;
|
|
46
|
+
hset(key: string, ...args: ReadonlyArray<string | number>): Promise<number>;
|
|
47
|
+
scan(cursor: string, match: 'MATCH', pattern: string, count: 'COUNT', n: number): Promise<readonly [string, readonly string[]]>;
|
|
48
|
+
eval(script: string, numKeys: number, ...args: ReadonlyArray<string | number>): Promise<unknown>;
|
|
49
|
+
pipeline(): RedisLikePipeline;
|
|
50
|
+
quit(): Promise<unknown>;
|
|
51
|
+
}
|
|
52
|
+
export interface RedisLikePipeline {
|
|
53
|
+
set(key: string, value: string, ...args: ReadonlyArray<string | number>): RedisLikePipeline;
|
|
54
|
+
sadd(key: string, ...members: ReadonlyArray<string>): RedisLikePipeline;
|
|
55
|
+
exec(): Promise<unknown>;
|
|
56
|
+
}
|
|
57
|
+
export interface RedisStoreOptions {
|
|
58
|
+
/**
|
|
59
|
+
* Connection URL (e.g. `redis://default:password@host:6379/0`). Required
|
|
60
|
+
* unless `_client` is supplied.
|
|
61
|
+
*/
|
|
62
|
+
readonly url?: string;
|
|
63
|
+
/**
|
|
64
|
+
* Pre-built `ioredis` client. Use this when the host app already manages
|
|
65
|
+
* a Redis connection pool. Adapter does NOT call `quit()` on a borrowed
|
|
66
|
+
* client — caller owns the lifecycle.
|
|
67
|
+
*/
|
|
68
|
+
readonly client?: RedisLikeClient;
|
|
69
|
+
/** Key prefix for namespace isolation across apps sharing one Redis. Default `'agentfootprint'`. */
|
|
70
|
+
readonly prefix?: string;
|
|
71
|
+
/**
|
|
72
|
+
* SCAN page size when iterating keys. Default 100. Larger = fewer
|
|
73
|
+
* round-trips but more memory per response. Adapter never uses `KEYS *`
|
|
74
|
+
* (which blocks Redis).
|
|
75
|
+
*/
|
|
76
|
+
readonly scanCount?: number;
|
|
77
|
+
/**
|
|
78
|
+
* @internal Test injection point. When provided, skips the SDK require.
|
|
79
|
+
*/
|
|
80
|
+
readonly _client?: RedisLikeClient;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Redis-backed `MemoryStore`. Implements every method except `search()`.
|
|
84
|
+
*
|
|
85
|
+
* @throws when `ioredis` is not installed and no `_client` is supplied.
|
|
86
|
+
*/
|
|
87
|
+
export declare class RedisStore implements MemoryStore {
|
|
88
|
+
private readonly client;
|
|
89
|
+
private readonly prefix;
|
|
90
|
+
private readonly scanCount;
|
|
91
|
+
private readonly ownsClient;
|
|
92
|
+
private closed;
|
|
93
|
+
constructor(options?: RedisStoreOptions);
|
|
94
|
+
private nsKey;
|
|
95
|
+
private entryKey;
|
|
96
|
+
private indexKey;
|
|
97
|
+
private sigKey;
|
|
98
|
+
private feedbackKey;
|
|
99
|
+
get<T = unknown>(identity: MemoryIdentity, id: string): Promise<MemoryEntry<T> | null>;
|
|
100
|
+
put<T = unknown>(identity: MemoryIdentity, entry: MemoryEntry<T>): Promise<void>;
|
|
101
|
+
putMany<T = unknown>(identity: MemoryIdentity, entries: readonly MemoryEntry<T>[]): Promise<void>;
|
|
102
|
+
/**
|
|
103
|
+
* Optimistic concurrency via a small Lua script — atomic
|
|
104
|
+
* compare-and-swap on the JSON-encoded `version` field.
|
|
105
|
+
*/
|
|
106
|
+
putIfVersion<T = unknown>(identity: MemoryIdentity, entry: MemoryEntry<T>, expectedVersion: number): Promise<PutIfVersionResult>;
|
|
107
|
+
list<T = unknown>(identity: MemoryIdentity, options?: ListOptions): Promise<ListResult<T>>;
|
|
108
|
+
delete(identity: MemoryIdentity, id: string): Promise<void>;
|
|
109
|
+
seen(identity: MemoryIdentity, signature: string): Promise<boolean>;
|
|
110
|
+
recordSignature(identity: MemoryIdentity, signature: string): Promise<void>;
|
|
111
|
+
feedback(identity: MemoryIdentity, id: string, usefulness: number): Promise<void>;
|
|
112
|
+
getFeedback(identity: MemoryIdentity, id: string): Promise<{
|
|
113
|
+
average: number;
|
|
114
|
+
count: number;
|
|
115
|
+
} | null>;
|
|
116
|
+
/**
|
|
117
|
+
* GDPR — drop every key under this identity's namespace.
|
|
118
|
+
*/
|
|
119
|
+
forget(identity: MemoryIdentity): Promise<void>;
|
|
120
|
+
/**
|
|
121
|
+
* Close the underlying Redis connection — only when this adapter
|
|
122
|
+
* owns it. Borrowed clients (passed via `client` option) are left to
|
|
123
|
+
* the caller. Idempotent.
|
|
124
|
+
*/
|
|
125
|
+
close(): Promise<void>;
|
|
126
|
+
private ensureOpen;
|
|
127
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* agentcoreObservability — AWS Bedrock AgentCore observability adapter.
|
|
3
|
+
*
|
|
4
|
+
* Ships every `AgentfootprintEvent` to **CloudWatch Logs** in a
|
|
5
|
+
* structured-JSON shape AgentCore's hosted-agent telemetry layer
|
|
6
|
+
* understands. Use when:
|
|
7
|
+
*
|
|
8
|
+
* 1. Your agent runs INSIDE AgentCore — events show up alongside
|
|
9
|
+
* AgentCore's own runtime telemetry in the same log group.
|
|
10
|
+
* 2. Your agent runs OUTSIDE AgentCore but you want to query agent
|
|
11
|
+
* behavior in CloudWatch Insights / X-Ray traces using the same
|
|
12
|
+
* schema AgentCore uses internally.
|
|
13
|
+
*
|
|
14
|
+
* Subpath: `agentfootprint/observability-providers`
|
|
15
|
+
* Peer dep: `@aws-sdk/client-cloudwatch-logs` (OPTIONAL — installed
|
|
16
|
+
* only when this adapter is used; declared via
|
|
17
|
+
* `peerDependenciesMeta.{name}.optional = true`).
|
|
18
|
+
*
|
|
19
|
+
* **Implementation:** thin wrapper over `cloudwatchObservability`'s
|
|
20
|
+
* shared base. The only difference is the strategy `name` (used for
|
|
21
|
+
* registry lookup + diagnostics). All batching, flush, error-routing,
|
|
22
|
+
* and SDK-loading behavior is identical. As we evolve the CloudWatch
|
|
23
|
+
* shipping path (retry, sequence tokens, metrics emission), every
|
|
24
|
+
* CloudWatch-shaped adapter inherits the improvement.
|
|
25
|
+
*
|
|
26
|
+
* @example Basic
|
|
27
|
+
* ```ts
|
|
28
|
+
* import { agentcoreObservability } from 'agentfootprint/observability-providers';
|
|
29
|
+
* import { microtaskBatchDriver } from 'footprintjs/detach';
|
|
30
|
+
*
|
|
31
|
+
* agent.enable.observability({
|
|
32
|
+
* strategy: agentcoreObservability({
|
|
33
|
+
* region: 'us-east-1',
|
|
34
|
+
* logGroupName: '/agentfootprint/my-agent',
|
|
35
|
+
* logStreamName: `${process.env.HOSTNAME}/${Date.now()}`,
|
|
36
|
+
* }),
|
|
37
|
+
* detach: { driver: microtaskBatchDriver, mode: 'forget' },
|
|
38
|
+
* });
|
|
39
|
+
* ```
|
|
40
|
+
*
|
|
41
|
+
* @example Test injection (skip SDK require entirely)
|
|
42
|
+
* ```ts
|
|
43
|
+
* agentcoreObservability({
|
|
44
|
+
* logGroupName: '/agentfootprint/test',
|
|
45
|
+
* _client: {
|
|
46
|
+
* putLogEvents: async (input) => { capturedBatches.push(input); },
|
|
47
|
+
* },
|
|
48
|
+
* });
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
import type { ObservabilityStrategy } from '../../strategies/types.js';
|
|
52
|
+
import { type CloudwatchObservabilityOptions } from './cloudwatch.js';
|
|
53
|
+
/**
|
|
54
|
+
* AgentCore-specific options. Currently identical to the generic
|
|
55
|
+
* `CloudwatchObservabilityOptions` — kept as a separate type for
|
|
56
|
+
* future-proofing (AgentCore-specific knobs like
|
|
57
|
+
* `agentcoreSessionId` propagation could land here without a
|
|
58
|
+
* breaking change).
|
|
59
|
+
*/
|
|
60
|
+
export type AgentcoreObservabilityOptions = CloudwatchObservabilityOptions;
|
|
61
|
+
/**
|
|
62
|
+
* Build an AgentCore-flavored CloudWatch Logs observability strategy.
|
|
63
|
+
* Functionally identical to `cloudwatchObservability` except for the
|
|
64
|
+
* strategy `name`, which lets registry-lookup + diagnostics
|
|
65
|
+
* distinguish AgentCore-targeted shipping from generic CloudWatch.
|
|
66
|
+
*/
|
|
67
|
+
export declare function agentcoreObservability(opts: AgentcoreObservabilityOptions): ObservabilityStrategy;
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* auditExport — tamper-evident audit bundle (backlog #20, compliance
|
|
3
|
+
* wedge item 2; pairs with #19's `otelObservability` GenAI spans).
|
|
4
|
+
*
|
|
5
|
+
* Consumes the typed `agentfootprint.*` event stream and accumulates an
|
|
6
|
+
* append-only, HASH-CHAINED record log: every record carries the SHA-256
|
|
7
|
+
* of its own canonical serialization plus the hash of the previous
|
|
8
|
+
* record. Flipping a single byte anywhere in an exported bundle makes
|
|
9
|
+
* `verifyAuditBundle` name the exact record that broke — the
|
|
10
|
+
* record-keeping shape EU AI Act Art. 12 asks for (events the system
|
|
11
|
+
* logged, in order, demonstrably unmodified since capture).
|
|
12
|
+
*
|
|
13
|
+
* Pattern: Observability strategy (one purpose — chain accumulation)
|
|
14
|
+
* + pure offline verifier.
|
|
15
|
+
* Role: Outer ring (Hexagonal). Attach via
|
|
16
|
+
* `agent.enable.observability({ strategy: auditExport() })`.
|
|
17
|
+
* Emits: nothing — terminal sink.
|
|
18
|
+
*
|
|
19
|
+
* ## What lands in the chain
|
|
20
|
+
*
|
|
21
|
+
* One record per typed event, in dispatch order: decisions
|
|
22
|
+
* (`agent.route_decided`, `composition.route_decided` incl. decide()
|
|
23
|
+
* evidence), tool calls (`stream.tool_start/_end`), validation
|
|
24
|
+
* rejections (#9), permission verdicts and halts, credential lifecycle,
|
|
25
|
+
* costs, errors, skill/memory/context activity. Each new `meta.runId`
|
|
26
|
+
* is anchored by a GENESIS record (`audit.genesis`) carrying the runId,
|
|
27
|
+
* the agent identity, and library versions — runs chain back-to-back in
|
|
28
|
+
* one log, so silently DROPPING a whole run breaks the chain too.
|
|
29
|
+
*
|
|
30
|
+
* High-volume content deltas (`stream.token`, `stream.thinking_delta`)
|
|
31
|
+
* are excluded by default (`includeTokenEvents: true` to include).
|
|
32
|
+
*
|
|
33
|
+
* ## Record / bundle schema
|
|
34
|
+
*
|
|
35
|
+
* ```
|
|
36
|
+
* AuditRecord = { seq, timestamp, eventType, payload, meta, prevHash, hash }
|
|
37
|
+
* hash = SHA-256 hex over canonicalJson(record minus `hash`)
|
|
38
|
+
* prevHash = previous record's `hash` (ZERO_HASH at chain start)
|
|
39
|
+
* AuditBundle = { header, records, finalHash }
|
|
40
|
+
* header = { format, hashAlgorithm, canonicalization, chainHead,
|
|
41
|
+
* firstSeq, recordCount, exportedAt, library }
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* Canonicalization is `afp-cjson/1` (see `lib/canonicalJson.ts` — those
|
|
45
|
+
* rules ARE the contract; the header names them so independent
|
|
46
|
+
* verifiers can re-implement byte-exactly).
|
|
47
|
+
*
|
|
48
|
+
* ## Persistence + long runs
|
|
49
|
+
*
|
|
50
|
+
* Persistence is the CONSUMER's job — the bundle is plain JSON
|
|
51
|
+
* (`JSON.stringify(strategy.bundle())`, store anywhere). For long runs,
|
|
52
|
+
* `drain()` returns the records accumulated since the last drain while
|
|
53
|
+
* keeping the chain intact ACROSS drains: each segment's
|
|
54
|
+
* `header.chainHead` equals the previous segment's `finalHash`, so
|
|
55
|
+
* `verifyAuditBundle([seg1, seg2, ...])` re-verifies the concatenation
|
|
56
|
+
* end-to-end.
|
|
57
|
+
*
|
|
58
|
+
* ## PII discipline (mirrors #19's otelObservability)
|
|
59
|
+
*
|
|
60
|
+
* Payloads enter records through a bounding layer — by default
|
|
61
|
+
* (`payloadMode: 'bounded'`) record payloads NEVER carry raw runtime
|
|
62
|
+
* values that can echo PII:
|
|
63
|
+
*
|
|
64
|
+
* - tool args → `'[keys: …]'` (top-level key NAMES only)
|
|
65
|
+
* - tool results → `'[type: …]'` (typeof only)
|
|
66
|
+
* - userPrompt / LLM content / thinking blocks / history
|
|
67
|
+
* → `'[N chars]'` / `'[N messages]'` markers
|
|
68
|
+
* - content PREVIEWS (`contentSummary` on context/memory events,
|
|
69
|
+
* `rawContent`, `resultSummary`, `droppedSummaries`) → markers
|
|
70
|
+
* (for short content a preview IS the content; `contentHash`
|
|
71
|
+
* stays — it links identical content without echoing it)
|
|
72
|
+
* - error MESSAGE strings (`error`, `errorMessage`, `lastError`,
|
|
73
|
+
* `rawOutput`) → `'[N chars]'` (messages can echo values)
|
|
74
|
+
* - free-form Records (`questionPayload`, `resumeInput`, risk/eval
|
|
75
|
+
* `evidence`, memory `scoreEvidence`) → `'[keys: …]'`
|
|
76
|
+
*
|
|
77
|
+
* Everything else is embedded as the registry payload (sanitized:
|
|
78
|
+
* strings capped at 256 chars, lists at 32 items, cycles broken) —
|
|
79
|
+
* those payloads are bounded by construction: identifiers, counts,
|
|
80
|
+
* enums, decide() evidence (engine-bounded + redaction-aware),
|
|
81
|
+
* validation issues (paths/TYPES per #9), credential events (no
|
|
82
|
+
* secrets by contract).
|
|
83
|
+
*
|
|
84
|
+
* `payloadMode: 'verbatim'` embeds full payloads (still
|
|
85
|
+
* JSON-sanitized). For Art. 12 completeness on an access-controlled
|
|
86
|
+
* store that is often the point — but the bundle then carries prompts,
|
|
87
|
+
* tool args/results and model output. Treat it as PII-bearing, and
|
|
88
|
+
* remember the Agent sets NO footprintjs RedactionPolicy by default
|
|
89
|
+
* (policies you do set redact the emit channel UPSTREAM of this
|
|
90
|
+
* strategy, so redacted events arrive here already redacted).
|
|
91
|
+
*
|
|
92
|
+
* ## Tamper-EVIDENT, not tamper-PROOF (honest threat model)
|
|
93
|
+
*
|
|
94
|
+
* The chain proves INTERNAL consistency: any partial modification —
|
|
95
|
+
* edit, insert, delete, reorder, drop-a-run — is detected and named.
|
|
96
|
+
* It does NOT prove provenance: an adversary holding the only copy can
|
|
97
|
+
* recompute every hash from the mutation onward and present a
|
|
98
|
+
* self-consistent forgery. For non-repudiation, anchor `finalHash`
|
|
99
|
+
* externally as part of your retention process (write-once/WORM store,
|
|
100
|
+
* signed log, RFC 3161 timestamping, or simply a second party) — then
|
|
101
|
+
* a whole-suffix recomputation no longer matches the anchor.
|
|
102
|
+
*
|
|
103
|
+
* ## Runtime requirements
|
|
104
|
+
*
|
|
105
|
+
* Hashing uses `node:crypto` (`createHash('sha256')`) — zero new
|
|
106
|
+
* dependencies, imported lazily at first use (same gating as the
|
|
107
|
+
* optional vendor SDKs in this folder, so merely importing this module
|
|
108
|
+
* stays browser-safe). `auditExport` and `verifyAuditBundle` therefore
|
|
109
|
+
* run anywhere `node:crypto` exists: Node ≥ 20, Bun, Deno,
|
|
110
|
+
* edge runtimes with Node compat (e.g. Cloudflare `nodejs_compat`).
|
|
111
|
+
* In a browser there is no SYNC SHA-256 (WebCrypto is async-only), so
|
|
112
|
+
* both throw a descriptive error — verify server-side, or re-implement
|
|
113
|
+
* verification from the documented contract (it is pure: recompute
|
|
114
|
+
* SHA-256 over `afp-cjson/1` canonicalization and walk the chain).
|
|
115
|
+
*
|
|
116
|
+
* @example Capture → export → verify
|
|
117
|
+
* ```ts
|
|
118
|
+
* import { auditExport, verifyAuditBundle } from 'agentfootprint/observability-providers';
|
|
119
|
+
*
|
|
120
|
+
* const audit = auditExport({ agent: 'loan-officer' });
|
|
121
|
+
* const stop = agent.enable.observability({ strategy: audit });
|
|
122
|
+
* await agent.run({ message: 'assess application A-17' });
|
|
123
|
+
* stop();
|
|
124
|
+
*
|
|
125
|
+
* const bundle = audit.bundle(); // JSON-serializable
|
|
126
|
+
* await fs.writeFile('run.audit.json', JSON.stringify(bundle));
|
|
127
|
+
*
|
|
128
|
+
* const check = verifyAuditBundle(bundle); // offline — no agent needed
|
|
129
|
+
* // check.valid === true; tamper with one byte → { valid: false, brokenAt: <seq> }
|
|
130
|
+
* ```
|
|
131
|
+
*/
|
|
132
|
+
import { CANONICAL_JSON_VERSION } from '../../lib/canonicalJson.js';
|
|
133
|
+
import type { ObservabilityStrategy } from '../../strategies/types.js';
|
|
134
|
+
/** SHA-256 of "nothing" — the `prevHash` of the first record in a
|
|
135
|
+
* chain and the `chainHead` of a chain's first segment. */
|
|
136
|
+
export declare const AUDIT_ZERO_HASH: string;
|
|
137
|
+
/** `eventType` of the per-run genesis record. Deliberately OUTSIDE the
|
|
138
|
+
* `agentfootprint.*` registry namespace — it is a chain-level record,
|
|
139
|
+
* not a dispatched event (#20 ships zero new typed events). */
|
|
140
|
+
export declare const AUDIT_GENESIS_EVENT_TYPE = "audit.genesis";
|
|
141
|
+
/** Format identifier carried on every bundle header. */
|
|
142
|
+
export declare const AUDIT_BUNDLE_FORMAT = "agentfootprint.audit/1";
|
|
143
|
+
/**
|
|
144
|
+
* One link of the hash chain.
|
|
145
|
+
*
|
|
146
|
+
* `hash` = SHA-256 hex over `canonicalJson` of the record WITHOUT the
|
|
147
|
+
* `hash` field (i.e. `{ seq, timestamp, eventType, payload, meta,
|
|
148
|
+
* prevHash }` — canonical key order makes field order irrelevant).
|
|
149
|
+
* Because the preimage is "everything but `hash`", ADDING a field to a
|
|
150
|
+
* record is detected exactly like mutating one.
|
|
151
|
+
*/
|
|
152
|
+
export interface AuditRecord {
|
|
153
|
+
/** 0-based position in the chain (monotonic across drains). */
|
|
154
|
+
readonly seq: number;
|
|
155
|
+
/** Wall-clock ms of the source event (`meta.wallClockMs`). */
|
|
156
|
+
readonly timestamp: number;
|
|
157
|
+
/** Registry event name verbatim, or {@link AUDIT_GENESIS_EVENT_TYPE}. */
|
|
158
|
+
readonly eventType: string;
|
|
159
|
+
/** Bounded / sanitized event payload (see module PII docs). */
|
|
160
|
+
readonly payload: unknown;
|
|
161
|
+
/** Sanitized event meta (runId, runtimeStageId, paths, indices). */
|
|
162
|
+
readonly meta: {
|
|
163
|
+
readonly runId: string;
|
|
164
|
+
} & Readonly<Record<string, unknown>>;
|
|
165
|
+
/** `hash` of the previous record ({@link AUDIT_ZERO_HASH} at chain start). */
|
|
166
|
+
readonly prevHash: string;
|
|
167
|
+
/** SHA-256 hex of this record's canonical preimage. */
|
|
168
|
+
readonly hash: string;
|
|
169
|
+
}
|
|
170
|
+
export interface AuditBundleHeader {
|
|
171
|
+
readonly format: typeof AUDIT_BUNDLE_FORMAT;
|
|
172
|
+
readonly hashAlgorithm: 'sha-256';
|
|
173
|
+
readonly canonicalization: typeof CANONICAL_JSON_VERSION;
|
|
174
|
+
/** `prevHash` of `records[0]` — {@link AUDIT_ZERO_HASH} for the first
|
|
175
|
+
* segment, the previous segment's `finalHash` after a `drain()`. */
|
|
176
|
+
readonly chainHead: string;
|
|
177
|
+
/** `seq` of `records[0]` (continues across drains). */
|
|
178
|
+
readonly firstSeq: number;
|
|
179
|
+
readonly recordCount: number;
|
|
180
|
+
/** Wall-clock ms when `bundle()` / `drain()` produced this export. */
|
|
181
|
+
readonly exportedAt: number;
|
|
182
|
+
readonly library: {
|
|
183
|
+
readonly name: 'agentfootprint';
|
|
184
|
+
readonly version: string;
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
/** JSON-serializable export of the chain (or one drained segment). */
|
|
188
|
+
export interface AuditBundle {
|
|
189
|
+
readonly header: AuditBundleHeader;
|
|
190
|
+
readonly records: readonly AuditRecord[];
|
|
191
|
+
/** `hash` of the last record (= `chainHead` when `records` is empty).
|
|
192
|
+
* The next drained segment's `chainHead` equals this value. */
|
|
193
|
+
readonly finalHash: string;
|
|
194
|
+
}
|
|
195
|
+
export interface AuditVerifyResult {
|
|
196
|
+
readonly valid: boolean;
|
|
197
|
+
/** Records whose hashes were recomputed and matched. */
|
|
198
|
+
readonly recordsChecked: number;
|
|
199
|
+
/** `seq` of the first record that fails (or the expected seq at the
|
|
200
|
+
* failure point, when the stored seq itself was tampered). */
|
|
201
|
+
readonly brokenAt?: number;
|
|
202
|
+
/** Human-readable cause — names the failed check. */
|
|
203
|
+
readonly reason?: string;
|
|
204
|
+
}
|
|
205
|
+
export interface AuditExportOptions {
|
|
206
|
+
/** Agent identity recorded in every run's genesis record (service /
|
|
207
|
+
* agent name as your compliance review knows it). */
|
|
208
|
+
readonly agent?: string;
|
|
209
|
+
/**
|
|
210
|
+
* `'bounded'` (default) — payloads pass the PII bounding layer (see
|
|
211
|
+
* module docs). `'verbatim'` — full payloads, JSON-sanitized only.
|
|
212
|
+
*
|
|
213
|
+
* @remarks Verbatim bundles carry prompts, tool args/results and
|
|
214
|
+
* model output. Treat the store as PII-bearing; the Agent applies NO
|
|
215
|
+
* RedactionPolicy by default.
|
|
216
|
+
*/
|
|
217
|
+
readonly payloadMode?: 'bounded' | 'verbatim';
|
|
218
|
+
/** Include `stream.token` / `stream.thinking_delta` events (high
|
|
219
|
+
* volume; content still bounded under `payloadMode: 'bounded'`).
|
|
220
|
+
* Default `false`. */
|
|
221
|
+
readonly includeTokenEvents?: boolean;
|
|
222
|
+
/** Extra version pins for the genesis record (your app, model
|
|
223
|
+
* config revision, policy bundle hash, …). */
|
|
224
|
+
readonly versions?: Readonly<Record<string, string>>;
|
|
225
|
+
}
|
|
226
|
+
/** The strategy returned by {@link auditExport}. */
|
|
227
|
+
export interface AuditExportStrategy extends ObservabilityStrategy {
|
|
228
|
+
/** Snapshot the retained records WITHOUT draining. Safe mid-run. */
|
|
229
|
+
bundle(): AuditBundle;
|
|
230
|
+
/** Return the records accumulated since the last drain and clear
|
|
231
|
+
* them from memory. Chain state persists — consecutive drained
|
|
232
|
+
* segments re-verify end-to-end via `verifyAuditBundle([...])`. */
|
|
233
|
+
drain(): AuditBundle;
|
|
234
|
+
/** Records currently retained (since last drain). */
|
|
235
|
+
recordCount(): number;
|
|
236
|
+
}
|
|
237
|
+
export declare function auditExport(opts?: AuditExportOptions): AuditExportStrategy;
|
|
238
|
+
/**
|
|
239
|
+
* Recompute the hash chain of a bundle (or of consecutive drained
|
|
240
|
+
* segments, in order) and report the exact record where integrity
|
|
241
|
+
* breaks. Pure function over JSON data — runs offline, long after the
|
|
242
|
+
* run, with no agent and no strategy instance.
|
|
243
|
+
*
|
|
244
|
+
* Checks, in order, per segment:
|
|
245
|
+
* 1. header format / algorithm / canonicalization are supported
|
|
246
|
+
* 2. `recordCount` matches `records.length`
|
|
247
|
+
* 3. segment continuity (`chainHead`/`firstSeq` extend the previous
|
|
248
|
+
* segment's `finalHash`/seq range)
|
|
249
|
+
* 4. per record: `seq` is contiguous, `prevHash` links the previous
|
|
250
|
+
* record, and SHA-256 over the canonical preimage (the record
|
|
251
|
+
* minus `hash` — so ADDED fields are caught too) matches `hash`
|
|
252
|
+
* 5. `finalHash` equals the last record's hash
|
|
253
|
+
*/
|
|
254
|
+
export declare function verifyAuditBundle(input: AuditBundle | readonly AuditBundle[]): AuditVerifyResult;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* cloudwatchObservability — Generic AWS CloudWatch Logs adapter.
|
|
3
|
+
*
|
|
4
|
+
* Ships every `AgentfootprintEvent` to a CloudWatch Logs stream. Use
|
|
5
|
+
* when you want agent telemetry alongside the rest of your AWS
|
|
6
|
+
* observability stack — CloudWatch Insights queries, alarms,
|
|
7
|
+
* cross-service correlation. Same SDK as `agentcoreObservability`
|
|
8
|
+
* but **without** the AgentCore-specific defaults (log-stream
|
|
9
|
+
* convention, format opinions). Use this when:
|
|
10
|
+
*
|
|
11
|
+
* 1. You're shipping to CloudWatch but NOT running inside Bedrock
|
|
12
|
+
* AgentCore (most common case).
|
|
13
|
+
* 2. You want full control over log group / stream / format and
|
|
14
|
+
* don't need AgentCore's hosted-agent telemetry conventions.
|
|
15
|
+
*
|
|
16
|
+
* Subpath: `agentfootprint/observability-providers`
|
|
17
|
+
* Peer dep: `@aws-sdk/client-cloudwatch-logs` (OPTIONAL — installed
|
|
18
|
+
* only when this adapter is used; declared via
|
|
19
|
+
* `peerDependenciesMeta.{name}.optional = true`).
|
|
20
|
+
*
|
|
21
|
+
* This module also exports the underlying base function used by
|
|
22
|
+
* `agentcoreObservability` — keeps the per-event hot path in one
|
|
23
|
+
* place so improvements (batching, retry, backpressure) flow to
|
|
24
|
+
* every CloudWatch-shaped adapter automatically.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```ts
|
|
28
|
+
* import { cloudwatchObservability } from 'agentfootprint/observability-providers';
|
|
29
|
+
* import { microtaskBatchDriver } from 'footprintjs/detach';
|
|
30
|
+
*
|
|
31
|
+
* agent.enable.observability({
|
|
32
|
+
* strategy: cloudwatchObservability({
|
|
33
|
+
* region: 'us-east-1',
|
|
34
|
+
* logGroupName: '/myapp/agent-prod',
|
|
35
|
+
* logStreamName: `${process.env.HOSTNAME}/${Date.now()}`,
|
|
36
|
+
* }),
|
|
37
|
+
* detach: { driver: microtaskBatchDriver, mode: 'forget' },
|
|
38
|
+
* });
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
import type { ObservabilityStrategy } from '../../strategies/types.js';
|
|
42
|
+
export interface CloudwatchObservabilityOptions {
|
|
43
|
+
/** AWS region. Falls back to AWS_REGION / AWS_DEFAULT_REGION env. */
|
|
44
|
+
readonly region?: string;
|
|
45
|
+
/** CloudWatch Logs log group. **Required.** Must exist or your IAM
|
|
46
|
+
* role must allow `logs:CreateLogGroup`. */
|
|
47
|
+
readonly logGroupName: string;
|
|
48
|
+
/** CloudWatch Logs log stream within the group. Conventionally
|
|
49
|
+
* `<host>/<startTime>` so multi-instance deployments don't
|
|
50
|
+
* collide. Created on first put if it doesn't exist (or your
|
|
51
|
+
* role must allow `logs:CreateLogStream`). Defaults to
|
|
52
|
+
* `agentfootprint`. */
|
|
53
|
+
readonly logStreamName?: string;
|
|
54
|
+
/** Max events buffered before forced flush. Default 100. */
|
|
55
|
+
readonly maxBatchEvents?: number;
|
|
56
|
+
/** Max payload bytes (UTF-8) buffered before forced flush. Default
|
|
57
|
+
* 10240 (10 KB). CloudWatch hard caps at 1 MB / batch but we keep
|
|
58
|
+
* the default low so latency stays bounded. */
|
|
59
|
+
readonly maxBatchBytes?: number;
|
|
60
|
+
/** Forced-flush interval when traffic is sparse. Default 1000ms.
|
|
61
|
+
* `0` disables time-based flush — only size triggers fire. */
|
|
62
|
+
readonly flushIntervalMs?: number;
|
|
63
|
+
/** Test injection — bypasses SDK lazy-require entirely. When set,
|
|
64
|
+
* `region` / IAM are ignored. */
|
|
65
|
+
readonly _client?: CloudWatchLikeClient;
|
|
66
|
+
}
|
|
67
|
+
export interface CloudWatchLikeClient {
|
|
68
|
+
putLogEvents(input: {
|
|
69
|
+
logGroupName: string;
|
|
70
|
+
logStreamName: string;
|
|
71
|
+
logEvents: ReadonlyArray<{
|
|
72
|
+
timestamp: number;
|
|
73
|
+
message: string;
|
|
74
|
+
}>;
|
|
75
|
+
}): Promise<unknown>;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Internal: shared CloudWatch Logs base used by every adapter that
|
|
79
|
+
* ships to CWL. `cloudwatchObservability` is the public generic
|
|
80
|
+
* factory; `agentcoreObservability` calls this with AgentCore-flavored
|
|
81
|
+
* defaults.
|
|
82
|
+
*
|
|
83
|
+
* Exported for adapter authors only — consumers should call
|
|
84
|
+
* `cloudwatchObservability` or `agentcoreObservability` directly.
|
|
85
|
+
*
|
|
86
|
+
* @internal
|
|
87
|
+
*/
|
|
88
|
+
export declare function _buildCloudWatchObservability(opts: CloudwatchObservabilityOptions, strategyName: string): ObservabilityStrategy;
|
|
89
|
+
/**
|
|
90
|
+
* Generic CloudWatch Logs observability adapter. See
|
|
91
|
+
* `CloudwatchObservabilityOptions` for the per-option contract.
|
|
92
|
+
*
|
|
93
|
+
* For AgentCore-specific conventions, use `agentcoreObservability`
|
|
94
|
+
* which thin-wraps this with AgentCore-flavored defaults.
|
|
95
|
+
*/
|
|
96
|
+
export declare function cloudwatchObservability(opts: CloudwatchObservabilityOptions): ObservabilityStrategy;
|