agentfootprint 10.3.1 → 10.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +2 -2
- package/CAPABILITIES.md +6 -0
- package/README.md +44 -0
- package/ai-instructions/claude-code/SKILL.md +2 -2
- package/dist/adapters/mcp/agentcoreRuntime/errorType.js +24 -0
- package/dist/adapters/mcp/agentcoreRuntime/errorType.js.map +1 -0
- package/dist/adapters/mcp/agentcoreRuntime/invoke.js +265 -0
- package/dist/adapters/mcp/agentcoreRuntime/invoke.js.map +1 -0
- package/dist/adapters/mcp/agentcoreRuntime/safeAnswer.js +415 -0
- package/dist/adapters/mcp/agentcoreRuntime/safeAnswer.js.map +1 -0
- package/dist/adapters/mcp/agentcoreRuntime/session.js +179 -0
- package/dist/adapters/mcp/agentcoreRuntime/session.js.map +1 -0
- package/dist/adapters/mcp/agentcoreRuntime/sessionBusy.js +117 -0
- package/dist/adapters/mcp/agentcoreRuntime/sessionBusy.js.map +1 -0
- package/dist/adapters/mcp/agentcoreRuntime/strictJson.js +220 -0
- package/dist/adapters/mcp/agentcoreRuntime/strictJson.js.map +1 -0
- package/dist/adapters/mcp/agentcoreRuntime/transport.js +204 -0
- package/dist/adapters/mcp/agentcoreRuntime/transport.js.map +1 -0
- package/dist/adapters/memory/agentcore.js +435 -20
- package/dist/adapters/memory/agentcore.js.map +1 -1
- package/dist/adapters/memory/memoryBank.js +16 -3
- package/dist/adapters/memory/memoryBank.js.map +1 -1
- package/dist/adapters/memory/pgVector.js +10 -4
- package/dist/adapters/memory/pgVector.js.map +1 -1
- package/dist/adapters/memory/redis.js +11 -3
- package/dist/adapters/memory/redis.js.map +1 -1
- package/dist/adapters/memory/s3Vectors.js +8 -3
- package/dist/adapters/memory/s3Vectors.js.map +1 -1
- package/dist/adapters/memory/sqliteVector.js +10 -4
- package/dist/adapters/memory/sqliteVector.js.map +1 -1
- package/dist/ag-ui/adapter.js +71 -0
- package/dist/ag-ui/adapter.js.map +1 -0
- package/dist/ag-ui/framing.js +66 -0
- package/dist/ag-ui/framing.js.map +1 -0
- package/dist/ag-ui/frontendTools.js +69 -0
- package/dist/ag-ui/frontendTools.js.map +1 -0
- package/dist/ag-ui/ids.js +54 -0
- package/dist/ag-ui/ids.js.map +1 -0
- package/dist/ag-ui/index.js +27 -0
- package/dist/ag-ui/index.js.map +1 -0
- package/dist/ag-ui/request.js +356 -0
- package/dist/ag-ui/request.js.map +1 -0
- package/dist/ag-ui/serializer.js +899 -0
- package/dist/ag-ui/serializer.js.map +1 -0
- package/dist/ag-ui/types.js +22 -0
- package/dist/ag-ui/types.js.map +1 -0
- package/dist/core/Agent.js +38 -5
- package/dist/core/Agent.js.map +1 -1
- package/dist/core/RunnerBase.js +16 -2
- package/dist/core/RunnerBase.js.map +1 -1
- package/dist/core/agent/buildAgentChart.js +4 -0
- package/dist/core/agent/buildAgentChart.js.map +1 -1
- package/dist/core/agent/buildDynamicAgentChart.js +4 -0
- package/dist/core/agent/buildDynamicAgentChart.js.map +1 -1
- package/dist/core/agent/callerIdentity.js +2 -1
- package/dist/core/agent/callerIdentity.js.map +1 -1
- package/dist/core/agent/stages/routeTurn.js +3 -3
- package/dist/core/agent/stages/routeTurn.js.map +1 -1
- package/dist/core/agent/stages/seed.js +49 -8
- package/dist/core/agent/stages/seed.js.map +1 -1
- package/dist/core/agent/stages/timeLayer.js +2 -2
- package/dist/core/agent/stages/timeLayer.js.map +1 -1
- package/dist/core/agent/stages/toolCalls.js +26 -5
- package/dist/core/agent/stages/toolCalls.js.map +1 -1
- package/dist/core/memberRun.js +244 -0
- package/dist/core/memberRun.js.map +1 -0
- package/dist/core/slots/buildToolsSlot.js +1 -1
- package/dist/core/slots/buildToolsSlot.js.map +1 -1
- package/dist/core-flow/Conditional.js +29 -8
- package/dist/core-flow/Conditional.js.map +1 -1
- package/dist/core-flow/Graph.js +38 -13
- package/dist/core-flow/Graph.js.map +1 -1
- package/dist/core-flow/Loop.js +29 -9
- package/dist/core-flow/Loop.js.map +1 -1
- package/dist/core-flow/Parallel.js +35 -14
- package/dist/core-flow/Parallel.js.map +1 -1
- package/dist/core-flow/Sequence.js +29 -8
- package/dist/core-flow/Sequence.js.map +1 -1
- package/dist/core-flow/Workflow.js +34 -10
- package/dist/core-flow/Workflow.js.map +1 -1
- package/dist/doors/ag-ui.js +36 -0
- package/dist/doors/ag-ui.js.map +1 -0
- package/dist/esm/adapters/mcp/agentcoreRuntime/errorType.d.ts +12 -0
- package/dist/esm/adapters/mcp/agentcoreRuntime/errorType.js +20 -0
- package/dist/esm/adapters/mcp/agentcoreRuntime/errorType.js.map +1 -0
- package/dist/esm/adapters/mcp/agentcoreRuntime/invoke.d.ts +116 -0
- package/dist/esm/adapters/mcp/agentcoreRuntime/invoke.js +260 -0
- package/dist/esm/adapters/mcp/agentcoreRuntime/invoke.js.map +1 -0
- package/dist/esm/adapters/mcp/agentcoreRuntime/safeAnswer.d.ts +49 -0
- package/dist/esm/adapters/mcp/agentcoreRuntime/safeAnswer.js +409 -0
- package/dist/esm/adapters/mcp/agentcoreRuntime/safeAnswer.js.map +1 -0
- package/dist/esm/adapters/mcp/agentcoreRuntime/session.d.ts +80 -0
- package/dist/esm/adapters/mcp/agentcoreRuntime/session.js +175 -0
- package/dist/esm/adapters/mcp/agentcoreRuntime/session.js.map +1 -0
- package/dist/esm/adapters/mcp/agentcoreRuntime/sessionBusy.d.ts +61 -0
- package/dist/esm/adapters/mcp/agentcoreRuntime/sessionBusy.js +112 -0
- package/dist/esm/adapters/mcp/agentcoreRuntime/sessionBusy.js.map +1 -0
- package/dist/esm/adapters/mcp/agentcoreRuntime/strictJson.d.ts +37 -0
- package/dist/esm/adapters/mcp/agentcoreRuntime/strictJson.js +215 -0
- package/dist/esm/adapters/mcp/agentcoreRuntime/strictJson.js.map +1 -0
- package/dist/esm/adapters/mcp/agentcoreRuntime/transport.d.ts +176 -0
- package/dist/esm/adapters/mcp/agentcoreRuntime/transport.js +199 -0
- package/dist/esm/adapters/mcp/agentcoreRuntime/transport.js.map +1 -0
- package/dist/esm/adapters/memory/agentcore.d.ts +152 -7
- package/dist/esm/adapters/memory/agentcore.js +433 -19
- package/dist/esm/adapters/memory/agentcore.js.map +1 -1
- package/dist/esm/adapters/memory/memoryBank.d.ts +3 -2
- package/dist/esm/adapters/memory/memoryBank.js +16 -3
- package/dist/esm/adapters/memory/memoryBank.js.map +1 -1
- package/dist/esm/adapters/memory/pgVector.js +10 -4
- package/dist/esm/adapters/memory/pgVector.js.map +1 -1
- package/dist/esm/adapters/memory/redis.d.ts +8 -3
- package/dist/esm/adapters/memory/redis.js +11 -3
- package/dist/esm/adapters/memory/redis.js.map +1 -1
- package/dist/esm/adapters/memory/s3Vectors.js +8 -3
- package/dist/esm/adapters/memory/s3Vectors.js.map +1 -1
- package/dist/esm/adapters/memory/sqliteVector.js +10 -4
- package/dist/esm/adapters/memory/sqliteVector.js.map +1 -1
- package/dist/esm/ag-ui/adapter.d.ts +68 -0
- package/dist/esm/ag-ui/adapter.js +67 -0
- package/dist/esm/ag-ui/adapter.js.map +1 -0
- package/dist/esm/ag-ui/framing.d.ts +51 -0
- package/dist/esm/ag-ui/framing.js +62 -0
- package/dist/esm/ag-ui/framing.js.map +1 -0
- package/dist/esm/ag-ui/frontendTools.d.ts +37 -0
- package/dist/esm/ag-ui/frontendTools.js +64 -0
- package/dist/esm/ag-ui/frontendTools.js.map +1 -0
- package/dist/esm/ag-ui/ids.d.ts +43 -0
- package/dist/esm/ag-ui/ids.js +49 -0
- package/dist/esm/ag-ui/ids.js.map +1 -0
- package/dist/esm/ag-ui/index.d.ts +17 -0
- package/dist/esm/ag-ui/index.js +17 -0
- package/dist/esm/ag-ui/index.js.map +1 -0
- package/dist/esm/ag-ui/request.d.ts +72 -0
- package/dist/esm/ag-ui/request.js +350 -0
- package/dist/esm/ag-ui/request.js.map +1 -0
- package/dist/esm/ag-ui/serializer.d.ts +173 -0
- package/dist/esm/ag-ui/serializer.js +895 -0
- package/dist/esm/ag-ui/serializer.js.map +1 -0
- package/dist/esm/ag-ui/types.d.ts +305 -0
- package/dist/esm/ag-ui/types.js +19 -0
- package/dist/esm/ag-ui/types.js.map +1 -0
- package/dist/esm/core/Agent.d.ts +2 -0
- package/dist/esm/core/Agent.js +38 -5
- package/dist/esm/core/Agent.js.map +1 -1
- package/dist/esm/core/RunnerBase.js +17 -3
- package/dist/esm/core/RunnerBase.js.map +1 -1
- package/dist/esm/core/agent/buildAgentChart.js +4 -0
- package/dist/esm/core/agent/buildAgentChart.js.map +1 -1
- package/dist/esm/core/agent/buildDynamicAgentChart.js +4 -0
- package/dist/esm/core/agent/buildDynamicAgentChart.js.map +1 -1
- package/dist/esm/core/agent/callerIdentity.js +2 -1
- package/dist/esm/core/agent/callerIdentity.js.map +1 -1
- package/dist/esm/core/agent/stages/routeTurn.d.ts +1 -1
- package/dist/esm/core/agent/stages/routeTurn.js +3 -3
- package/dist/esm/core/agent/stages/routeTurn.js.map +1 -1
- package/dist/esm/core/agent/stages/seed.d.ts +11 -1
- package/dist/esm/core/agent/stages/seed.js +49 -8
- package/dist/esm/core/agent/stages/seed.js.map +1 -1
- package/dist/esm/core/agent/stages/timeLayer.js +2 -2
- package/dist/esm/core/agent/stages/timeLayer.js.map +1 -1
- package/dist/esm/core/agent/stages/toolCalls.d.ts +11 -1
- package/dist/esm/core/agent/stages/toolCalls.js +26 -5
- package/dist/esm/core/agent/stages/toolCalls.js.map +1 -1
- package/dist/esm/core/agent/types.d.ts +16 -6
- package/dist/esm/core/memberRun.d.ts +132 -0
- package/dist/esm/core/memberRun.js +227 -0
- package/dist/esm/core/memberRun.js.map +1 -0
- package/dist/esm/core/slots/buildToolsSlot.d.ts +1 -1
- package/dist/esm/core/slots/buildToolsSlot.js +1 -1
- package/dist/esm/core/slots/buildToolsSlot.js.map +1 -1
- package/dist/esm/core-flow/Conditional.d.ts +8 -0
- package/dist/esm/core-flow/Conditional.js +29 -8
- package/dist/esm/core-flow/Conditional.js.map +1 -1
- package/dist/esm/core-flow/Graph.js +38 -13
- package/dist/esm/core-flow/Graph.js.map +1 -1
- package/dist/esm/core-flow/Loop.d.ts +8 -0
- package/dist/esm/core-flow/Loop.js +29 -9
- package/dist/esm/core-flow/Loop.js.map +1 -1
- package/dist/esm/core-flow/Parallel.d.ts +8 -0
- package/dist/esm/core-flow/Parallel.js +35 -14
- package/dist/esm/core-flow/Parallel.js.map +1 -1
- package/dist/esm/core-flow/Sequence.d.ts +8 -0
- package/dist/esm/core-flow/Sequence.js +29 -8
- package/dist/esm/core-flow/Sequence.js.map +1 -1
- package/dist/esm/core-flow/Workflow.js +34 -10
- package/dist/esm/core-flow/Workflow.js.map +1 -1
- package/dist/esm/doors/ag-ui.d.ts +19 -0
- package/dist/esm/doors/ag-ui.js +20 -0
- package/dist/esm/doors/ag-ui.js.map +1 -0
- package/dist/esm/hosting/envelope.js +5 -0
- package/dist/esm/hosting/envelope.js.map +1 -1
- package/dist/esm/hosting/httpHost.js +5 -78
- package/dist/esm/hosting/httpHost.js.map +1 -1
- package/dist/esm/hosting/index.d.ts +4 -1
- package/dist/esm/hosting/index.js +2 -0
- package/dist/esm/hosting/index.js.map +1 -1
- package/dist/esm/hosting/pendingAsk.d.ts +19 -0
- package/dist/esm/hosting/pendingAsk.js +38 -0
- package/dist/esm/hosting/pendingAsk.js.map +1 -0
- package/dist/esm/hosting/protocolAdapter.d.ts +229 -0
- package/dist/esm/hosting/protocolAdapter.js +23 -0
- package/dist/esm/hosting/protocolAdapter.js.map +1 -0
- package/dist/esm/hosting/refusalStatus.d.ts +30 -0
- package/dist/esm/hosting/refusalStatus.js +81 -0
- package/dist/esm/hosting/refusalStatus.js.map +1 -0
- package/dist/esm/hosting/standingAgent.js +1 -31
- package/dist/esm/hosting/standingAgent.js.map +1 -1
- package/dist/esm/hosting/stream.d.ts +39 -0
- package/dist/esm/hosting/stream.js +34 -2
- package/dist/esm/hosting/stream.js.map +1 -1
- package/dist/esm/hosting/streamHandler.d.ts +134 -0
- package/dist/esm/hosting/streamHandler.js +493 -0
- package/dist/esm/hosting/streamHandler.js.map +1 -0
- package/dist/esm/hosting/types.d.ts +15 -0
- package/dist/esm/hosting/types.js.map +1 -1
- package/dist/esm/hosting/verifiedThreads.d.ts +29 -0
- package/dist/esm/hosting/verifiedThreads.js +46 -0
- package/dist/esm/hosting/verifiedThreads.js.map +1 -0
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +3 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lib/humanizeLLMError.d.ts +15 -0
- package/dist/esm/lib/humanizeLLMError.js +22 -7
- package/dist/esm/lib/humanizeLLMError.js.map +1 -1
- package/dist/esm/mcp/throttleRetry.d.ts +51 -0
- package/dist/esm/mcp/throttleRetry.js +37 -4
- package/dist/esm/mcp/throttleRetry.js.map +1 -1
- package/dist/esm/memory/define.js +45 -1
- package/dist/esm/memory/define.js.map +1 -1
- package/dist/esm/memory/define.types.d.ts +24 -0
- package/dist/esm/memory/define.types.js.map +1 -1
- package/dist/esm/memory/stages/formatDefault.js +3 -1
- package/dist/esm/memory/stages/formatDefault.js.map +1 -1
- package/dist/esm/memory/store/InMemoryStore.d.ts +8 -3
- package/dist/esm/memory/store/InMemoryStore.js +12 -3
- package/dist/esm/memory/store/InMemoryStore.js.map +1 -1
- package/dist/esm/memory/store/index.d.ts +1 -0
- package/dist/esm/memory/store/index.js +5 -0
- package/dist/esm/memory/store/index.js.map +1 -1
- package/dist/esm/memory/store/types.d.ts +38 -4
- package/dist/esm/memory/store/writeOptions.d.ts +118 -0
- package/dist/esm/memory/store/writeOptions.js +242 -0
- package/dist/esm/memory/store/writeOptions.js.map +1 -0
- package/dist/esm/memory-providers.d.ts +1 -1
- package/dist/esm/memory-providers.js +4 -1
- package/dist/esm/memory-providers.js.map +1 -1
- package/dist/esm/patterns/MapReduce.js +8 -2
- package/dist/esm/patterns/MapReduce.js.map +1 -1
- package/dist/esm/tool-providers/index.d.ts +5 -0
- package/dist/esm/tool-providers/index.js +6 -0
- package/dist/esm/tool-providers/index.js.map +1 -1
- package/dist/esm/trace-toolpack/selfExplain.d.ts +8 -0
- package/dist/esm/trace-toolpack/selfExplain.js +25 -2
- package/dist/esm/trace-toolpack/selfExplain.js.map +1 -1
- package/dist/hosting/envelope.js +5 -0
- package/dist/hosting/envelope.js.map +1 -1
- package/dist/hosting/httpHost.js +5 -78
- package/dist/hosting/httpHost.js.map +1 -1
- package/dist/hosting/index.js +9 -3
- package/dist/hosting/index.js.map +1 -1
- package/dist/hosting/pendingAsk.js +42 -0
- package/dist/hosting/pendingAsk.js.map +1 -0
- package/dist/hosting/protocolAdapter.js +24 -0
- package/dist/hosting/protocolAdapter.js.map +1 -0
- package/dist/hosting/refusalStatus.js +84 -0
- package/dist/hosting/refusalStatus.js.map +1 -0
- package/dist/hosting/standingAgent.js +2 -32
- package/dist/hosting/standingAgent.js.map +1 -1
- package/dist/hosting/stream.js +35 -3
- package/dist/hosting/stream.js.map +1 -1
- package/dist/hosting/streamHandler.js +497 -0
- package/dist/hosting/streamHandler.js.map +1 -0
- package/dist/hosting/types.js.map +1 -1
- package/dist/hosting/verifiedThreads.js +50 -0
- package/dist/hosting/verifiedThreads.js.map +1 -0
- package/dist/index.js +9 -3
- package/dist/index.js.map +1 -1
- package/dist/lib/humanizeLLMError.js +23 -8
- package/dist/lib/humanizeLLMError.js.map +1 -1
- package/dist/mcp/throttleRetry.js +41 -6
- package/dist/mcp/throttleRetry.js.map +1 -1
- package/dist/memory/define.js +45 -1
- package/dist/memory/define.js.map +1 -1
- package/dist/memory/define.types.js.map +1 -1
- package/dist/memory/stages/formatDefault.js +3 -1
- package/dist/memory/stages/formatDefault.js.map +1 -1
- package/dist/memory/store/InMemoryStore.js +12 -3
- package/dist/memory/store/InMemoryStore.js.map +1 -1
- package/dist/memory/store/index.js +11 -1
- package/dist/memory/store/index.js.map +1 -1
- package/dist/memory/store/writeOptions.js +250 -0
- package/dist/memory/store/writeOptions.js.map +1 -0
- package/dist/memory-providers.js +4 -1
- package/dist/memory-providers.js.map +1 -1
- package/dist/patterns/MapReduce.js +8 -2
- package/dist/patterns/MapReduce.js.map +1 -1
- package/dist/tool-providers/index.js +10 -1
- package/dist/tool-providers/index.js.map +1 -1
- package/dist/trace-toolpack/selfExplain.js +25 -2
- package/dist/trace-toolpack/selfExplain.js.map +1 -1
- package/dist/types/adapters/mcp/agentcoreRuntime/errorType.d.ts +13 -0
- package/dist/types/adapters/mcp/agentcoreRuntime/errorType.d.ts.map +1 -0
- package/dist/types/adapters/mcp/agentcoreRuntime/invoke.d.ts +117 -0
- package/dist/types/adapters/mcp/agentcoreRuntime/invoke.d.ts.map +1 -0
- package/dist/types/adapters/mcp/agentcoreRuntime/safeAnswer.d.ts +50 -0
- package/dist/types/adapters/mcp/agentcoreRuntime/safeAnswer.d.ts.map +1 -0
- package/dist/types/adapters/mcp/agentcoreRuntime/session.d.ts +81 -0
- package/dist/types/adapters/mcp/agentcoreRuntime/session.d.ts.map +1 -0
- package/dist/types/adapters/mcp/agentcoreRuntime/sessionBusy.d.ts +62 -0
- package/dist/types/adapters/mcp/agentcoreRuntime/sessionBusy.d.ts.map +1 -0
- package/dist/types/adapters/mcp/agentcoreRuntime/strictJson.d.ts +38 -0
- package/dist/types/adapters/mcp/agentcoreRuntime/strictJson.d.ts.map +1 -0
- package/dist/types/adapters/mcp/agentcoreRuntime/transport.d.ts +177 -0
- package/dist/types/adapters/mcp/agentcoreRuntime/transport.d.ts.map +1 -0
- package/dist/types/adapters/memory/agentcore.d.ts +152 -7
- package/dist/types/adapters/memory/agentcore.d.ts.map +1 -1
- package/dist/types/adapters/memory/memoryBank.d.ts +3 -2
- package/dist/types/adapters/memory/memoryBank.d.ts.map +1 -1
- package/dist/types/adapters/memory/pgVector.d.ts.map +1 -1
- package/dist/types/adapters/memory/redis.d.ts +8 -3
- package/dist/types/adapters/memory/redis.d.ts.map +1 -1
- package/dist/types/adapters/memory/s3Vectors.d.ts.map +1 -1
- package/dist/types/adapters/memory/sqliteVector.d.ts.map +1 -1
- package/dist/types/ag-ui/adapter.d.ts +69 -0
- package/dist/types/ag-ui/adapter.d.ts.map +1 -0
- package/dist/types/ag-ui/framing.d.ts +52 -0
- package/dist/types/ag-ui/framing.d.ts.map +1 -0
- package/dist/types/ag-ui/frontendTools.d.ts +38 -0
- package/dist/types/ag-ui/frontendTools.d.ts.map +1 -0
- package/dist/types/ag-ui/ids.d.ts +44 -0
- package/dist/types/ag-ui/ids.d.ts.map +1 -0
- package/dist/types/ag-ui/index.d.ts +18 -0
- package/dist/types/ag-ui/index.d.ts.map +1 -0
- package/dist/types/ag-ui/request.d.ts +73 -0
- package/dist/types/ag-ui/request.d.ts.map +1 -0
- package/dist/types/ag-ui/serializer.d.ts +174 -0
- package/dist/types/ag-ui/serializer.d.ts.map +1 -0
- package/dist/types/ag-ui/types.d.ts +306 -0
- package/dist/types/ag-ui/types.d.ts.map +1 -0
- package/dist/types/core/Agent.d.ts +2 -0
- package/dist/types/core/Agent.d.ts.map +1 -1
- 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/callerIdentity.d.ts.map +1 -1
- package/dist/types/core/agent/stages/routeTurn.d.ts +1 -1
- package/dist/types/core/agent/stages/routeTurn.d.ts.map +1 -1
- package/dist/types/core/agent/stages/seed.d.ts +11 -1
- package/dist/types/core/agent/stages/seed.d.ts.map +1 -1
- package/dist/types/core/agent/stages/toolCalls.d.ts +11 -1
- package/dist/types/core/agent/stages/toolCalls.d.ts.map +1 -1
- package/dist/types/core/agent/types.d.ts +16 -6
- package/dist/types/core/agent/types.d.ts.map +1 -1
- package/dist/types/core/memberRun.d.ts +133 -0
- package/dist/types/core/memberRun.d.ts.map +1 -0
- package/dist/types/core/slots/buildToolsSlot.d.ts +1 -1
- package/dist/types/core/slots/buildToolsSlot.d.ts.map +1 -1
- package/dist/types/core-flow/Conditional.d.ts +8 -0
- package/dist/types/core-flow/Conditional.d.ts.map +1 -1
- package/dist/types/core-flow/Graph.d.ts.map +1 -1
- package/dist/types/core-flow/Loop.d.ts +8 -0
- package/dist/types/core-flow/Loop.d.ts.map +1 -1
- package/dist/types/core-flow/Parallel.d.ts +8 -0
- package/dist/types/core-flow/Parallel.d.ts.map +1 -1
- package/dist/types/core-flow/Sequence.d.ts +8 -0
- package/dist/types/core-flow/Sequence.d.ts.map +1 -1
- package/dist/types/core-flow/Workflow.d.ts.map +1 -1
- package/dist/types/doors/ag-ui.d.ts +20 -0
- package/dist/types/doors/ag-ui.d.ts.map +1 -0
- package/dist/types/hosting/httpHost.d.ts.map +1 -1
- package/dist/types/hosting/index.d.ts +4 -1
- package/dist/types/hosting/index.d.ts.map +1 -1
- package/dist/types/hosting/pendingAsk.d.ts +20 -0
- package/dist/types/hosting/pendingAsk.d.ts.map +1 -0
- package/dist/types/hosting/protocolAdapter.d.ts +230 -0
- package/dist/types/hosting/protocolAdapter.d.ts.map +1 -0
- package/dist/types/hosting/refusalStatus.d.ts +31 -0
- package/dist/types/hosting/refusalStatus.d.ts.map +1 -0
- package/dist/types/hosting/standingAgent.d.ts.map +1 -1
- package/dist/types/hosting/stream.d.ts +39 -0
- package/dist/types/hosting/stream.d.ts.map +1 -1
- package/dist/types/hosting/streamHandler.d.ts +135 -0
- package/dist/types/hosting/streamHandler.d.ts.map +1 -0
- package/dist/types/hosting/types.d.ts +15 -0
- package/dist/types/hosting/types.d.ts.map +1 -1
- package/dist/types/hosting/verifiedThreads.d.ts +30 -0
- package/dist/types/hosting/verifiedThreads.d.ts.map +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/lib/humanizeLLMError.d.ts +15 -0
- package/dist/types/lib/humanizeLLMError.d.ts.map +1 -1
- package/dist/types/mcp/throttleRetry.d.ts +51 -0
- package/dist/types/mcp/throttleRetry.d.ts.map +1 -1
- package/dist/types/memory/define.d.ts.map +1 -1
- package/dist/types/memory/define.types.d.ts +24 -0
- package/dist/types/memory/define.types.d.ts.map +1 -1
- package/dist/types/memory/stages/formatDefault.d.ts.map +1 -1
- package/dist/types/memory/store/InMemoryStore.d.ts +8 -3
- package/dist/types/memory/store/InMemoryStore.d.ts.map +1 -1
- package/dist/types/memory/store/index.d.ts +1 -0
- package/dist/types/memory/store/index.d.ts.map +1 -1
- package/dist/types/memory/store/types.d.ts +38 -4
- package/dist/types/memory/store/types.d.ts.map +1 -1
- package/dist/types/memory/store/writeOptions.d.ts +119 -0
- package/dist/types/memory/store/writeOptions.d.ts.map +1 -0
- package/dist/types/memory-providers.d.ts +1 -1
- package/dist/types/memory-providers.d.ts.map +1 -1
- package/dist/types/patterns/MapReduce.d.ts.map +1 -1
- package/dist/types/tool-providers/index.d.ts +5 -0
- package/dist/types/tool-providers/index.d.ts.map +1 -1
- package/dist/types/trace-toolpack/selfExplain.d.ts +8 -0
- package/dist/types/trace-toolpack/selfExplain.d.ts.map +1 -1
- package/package.json +25 -1
|
@@ -23,6 +23,8 @@
|
|
|
23
23
|
* "delete the whole session" call. This shapes the adapter:
|
|
24
24
|
*
|
|
25
25
|
* • `put` → `CreateEvent` (append; `actorId` + `eventTimestamp` are required). O(1)
|
|
26
|
+
* Its write options become CreateEvent's own fields: `extraction: 'skip'` →
|
|
27
|
+
* `extractionMode: 'SKIP'`, `namespaceScope` → `extractionConfig.namespaceVariables`.
|
|
26
28
|
* • `list` → `ListEvents` (paginated, `includePayloads`). ← window / episodic memory. O(page)
|
|
27
29
|
* • `get(id)` / `delete(id)` → list-then-find by the entry id stored in the blob, since
|
|
28
30
|
* AgentCore's ids are server-assigned. **O(events in session)** — fine for typical
|
|
@@ -42,10 +44,198 @@
|
|
|
42
44
|
* in use. Emits: N/A (storage adapters don't emit).
|
|
43
45
|
*/
|
|
44
46
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
-
exports.AgentCoreStore = exports.UnreadableMemoryEntryError = void 0;
|
|
47
|
+
exports.AgentCoreStore = exports.UnreadableMemoryEntryError = exports.agentCoreNamespaceValue = void 0;
|
|
46
48
|
const index_js_1 = require("../../memory/identity/index.js");
|
|
47
49
|
const lazyRequire_js_1 = require("../../lib/lazyRequire.js");
|
|
48
50
|
const storedPreview_js_1 = require("../../lib/storedPreview.js");
|
|
51
|
+
const writeOptions_js_1 = require("../../memory/store/writeOptions.js");
|
|
52
|
+
/** What this store honours when its client forwards CreateEvent's extraction fields. */
|
|
53
|
+
const AGENTCORE_WRITE_OPTIONS = Object.freeze([
|
|
54
|
+
'extraction',
|
|
55
|
+
'namespaceScope',
|
|
56
|
+
]);
|
|
57
|
+
/**
|
|
58
|
+
* ── Namespace variables: AgentCore's domain, checked here ──
|
|
59
|
+
*
|
|
60
|
+
* From the AgentCore API reference, `ExtractionConfig.namespaceVariables`: at
|
|
61
|
+
* most 5 entries; keys 1–32 characters matching
|
|
62
|
+
* `(?!memoryStrategyId$|actorId$|sessionId$)[a-z][a-z0-9]*`; values 1–64
|
|
63
|
+
* characters matching `[a-z0-9][a-z0-9-_]*`.
|
|
64
|
+
*
|
|
65
|
+
* Checked BEFORE the write rather than left to AgentCore, for one reason: its
|
|
66
|
+
* `ValidationException` may quote the rejected value, and the value names a
|
|
67
|
+
* tenant — a refusal here names the variable and the rule, never the value.
|
|
68
|
+
*/
|
|
69
|
+
const MAX_NAMESPACE_VARIABLES = 5;
|
|
70
|
+
/** The refusal of a scope-less write or search on a store that requires one. */
|
|
71
|
+
const MISSING_SCOPE = (what) => `AgentCoreStore: this ${what} carries no \`namespaceScope\`, and the store requires one — it ` +
|
|
72
|
+
'was built with `requireNamespaceScope: true`, or it has already served scoped calls. It is ' +
|
|
73
|
+
'refused rather than run under a namespace no tenant owns. Scope the memory that made it ' +
|
|
74
|
+
'(`defineMemory({ namespaceScope })`).';
|
|
75
|
+
/**
|
|
76
|
+
* Refuse, before any call, an identity this store cannot address: not an
|
|
77
|
+
* object, or no `conversationId` — an absent one would encode to ONE session
|
|
78
|
+
* every such identity shares.
|
|
79
|
+
*/
|
|
80
|
+
function assertAddressable(identity) {
|
|
81
|
+
if (identity === null || typeof identity !== 'object') {
|
|
82
|
+
throw new TypeError('AgentCoreStore: an identity is required — got none.');
|
|
83
|
+
}
|
|
84
|
+
const { conversationId, tenant, principal } = identity;
|
|
85
|
+
if (typeof conversationId !== 'string' || conversationId === '') {
|
|
86
|
+
throw new TypeError('AgentCoreStore: the identity has no `conversationId`. It is refused rather than filed ' +
|
|
87
|
+
'under one session every such identity would share.');
|
|
88
|
+
}
|
|
89
|
+
for (const [name, value] of [
|
|
90
|
+
['tenant', tenant],
|
|
91
|
+
['principal', principal],
|
|
92
|
+
]) {
|
|
93
|
+
if (value !== undefined && value !== null && typeof value !== 'string') {
|
|
94
|
+
throw new TypeError(`AgentCoreStore: the identity's \`${name}\` must be a string.`);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Refuse a search namespace that names no place: not a string, empty, or no
|
|
100
|
+
* path segment at all (`''`, `'/'`) — AgentCore matches a prefix, and an empty
|
|
101
|
+
* prefix is every record of the memory.
|
|
102
|
+
*/
|
|
103
|
+
function assertNamespace(namespace) {
|
|
104
|
+
if (typeof namespace !== 'string' || pathOf(namespace).replace(/^\//, '') === '') {
|
|
105
|
+
throw new TypeError('AgentCoreStore.search(): `searchNamespace` returned no namespace — an empty prefix ' +
|
|
106
|
+
'matches every record of the memory, so it is refused. Return a namespace with at ' +
|
|
107
|
+
'least one path segment.');
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
const NAMESPACE_KEY = /^(?!memoryStrategyId$|actorId$|sessionId$)[a-z][a-z0-9]{0,31}$/;
|
|
111
|
+
const NAMESPACE_VALUE = /^[a-z0-9][a-z0-9_-]{0,63}$/;
|
|
112
|
+
const NAMESPACE_VALUE_MAX = 64;
|
|
113
|
+
/** Refuse, by variable name and rule, a scope AgentCore would reject. */
|
|
114
|
+
function checkNamespaceVariables(scope) {
|
|
115
|
+
const keys = Object.keys(scope);
|
|
116
|
+
if (keys.length > MAX_NAMESPACE_VARIABLES) {
|
|
117
|
+
throw new TypeError(`AgentCoreStore: a namespaceScope may carry at most ${MAX_NAMESPACE_VARIABLES} variables ` +
|
|
118
|
+
`(AgentCore's limit); this one has ${keys.length}.`);
|
|
119
|
+
}
|
|
120
|
+
for (const key of keys) {
|
|
121
|
+
if (!NAMESPACE_KEY.test(key)) {
|
|
122
|
+
throw new TypeError(`AgentCoreStore: the namespace variable name ${JSON.stringify(key)} is not one ` +
|
|
123
|
+
'AgentCore admits — 1–32 characters, a lowercase letter then lowercase letters or ' +
|
|
124
|
+
'digits (and not memoryStrategyId / actorId / sessionId).');
|
|
125
|
+
}
|
|
126
|
+
const value = scope[key];
|
|
127
|
+
if (typeof value !== 'string' || !NAMESPACE_VALUE.test(value)) {
|
|
128
|
+
throw new TypeError(`AgentCoreStore: the value of namespace variable ${JSON.stringify(key)} is not one ` +
|
|
129
|
+
'AgentCore admits — 1–64 characters of [a-z0-9-_], starting with a letter or digit. ' +
|
|
130
|
+
'It is not quoted here: it names a tenant. Map your id with ' +
|
|
131
|
+
'`agentCoreNamespaceValue(...)`, which is one-to-one and fits this alphabet.');
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* A scope as the store uses it: read ONCE into a frozen plain copy, so the value
|
|
137
|
+
* that is checked is the value that is sent — a getter, or an object the
|
|
138
|
+
* caller's resolver reuses and edits, cannot change it between the two.
|
|
139
|
+
*/
|
|
140
|
+
function frozenScope(scope) {
|
|
141
|
+
return Object.freeze(Object.fromEntries(Object.entries(scope)));
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* A search under a namespace scope must stay inside it — checked by RENDERING,
|
|
145
|
+
* not by looking: `searchNamespace` is asked again with every value replaced
|
|
146
|
+
* by a canary, and the two namespaces must agree segment for segment — each
|
|
147
|
+
* canary's segment holding exactly that variable's real value, every other
|
|
148
|
+
* segment the same literal. So a namespace that ignores the scope, puts a
|
|
149
|
+
* variable inside a segment, or merely happens to contain a value elsewhere
|
|
150
|
+
* (a tenant named like a literal segment) is refused, naming the variable and
|
|
151
|
+
* never quoting its value.
|
|
152
|
+
*/
|
|
153
|
+
function assertSearchWithinScope(render, namespace, namespaceScope) {
|
|
154
|
+
const variables = Object.keys(namespaceScope);
|
|
155
|
+
const nonce = globalThis.crypto.randomUUID();
|
|
156
|
+
const canaries = variables.map((_, i) => `canary${i}-${nonce}`);
|
|
157
|
+
const canaryScope = Object.fromEntries(variables.map((v, i) => [v, canaries[i]]));
|
|
158
|
+
const real = namespace.split('/');
|
|
159
|
+
const probe = render(canaryScope).split('/');
|
|
160
|
+
const refuse = (variable) => {
|
|
161
|
+
throw new TypeError(`AgentCoreStore.search(): the namespace searched does not hold namespace variable ` +
|
|
162
|
+
`${JSON.stringify(variable)} as a path segment of its own, so it could read records ` +
|
|
163
|
+
'filed under another tenant’s scope. Build `searchNamespace` from the ' +
|
|
164
|
+
'`namespaceScope` it is handed, one variable per segment (e.g. ' +
|
|
165
|
+
'"/tenants/{tenantid}/actors/{actorId}/facts").');
|
|
166
|
+
};
|
|
167
|
+
const seen = new Set();
|
|
168
|
+
if (real.length !== probe.length)
|
|
169
|
+
refuse(variables[0] ?? 'namespaceScope');
|
|
170
|
+
probe.forEach((segment, i) => {
|
|
171
|
+
const at = canaries.indexOf(segment);
|
|
172
|
+
if (at === -1) {
|
|
173
|
+
if (real[i] !== segment)
|
|
174
|
+
refuse(variables[0] ?? 'namespaceScope');
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
const variable = variables[at];
|
|
178
|
+
if (real[i] !== namespaceScope[variable])
|
|
179
|
+
refuse(variable);
|
|
180
|
+
seen.add(variable);
|
|
181
|
+
});
|
|
182
|
+
for (const variable of variables)
|
|
183
|
+
if (!seen.has(variable))
|
|
184
|
+
refuse(variable);
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Does `namespace` hold `actorId` as whole path segments? (An actor id can
|
|
188
|
+
* itself contain `/`, its escape.)
|
|
189
|
+
*/
|
|
190
|
+
function holdsActor(namespace, actorId) {
|
|
191
|
+
return `/${pathOf(namespace).replace(/^\//, '')}/`.includes(`/${actorId}/`);
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* A caller's value — a tenant id — in the alphabet AgentCore admits for a
|
|
195
|
+
* namespace variable, ONE-TO-ONE.
|
|
196
|
+
*
|
|
197
|
+
* The alphabet is narrow (`[a-z0-9][a-z0-9-_]*`, at most 64 characters), so the
|
|
198
|
+
* easy mappings fold: lowercasing merges `Acme` with `acme`, stripping merges
|
|
199
|
+
* `a.b` with `ab`, truncating merges any two long ids that share a prefix — and
|
|
200
|
+
* a fold here files two tenants' derived records under one namespace. This is
|
|
201
|
+
* the same law as the actor and session ids above, in this alphabet:
|
|
202
|
+
*
|
|
203
|
+
* - `[a-z0-9-]` passes through; every other UTF-16 code unit becomes `_`
|
|
204
|
+
* plus its four lowercase hex digits (fixed width, so it decodes);
|
|
205
|
+
* - every value starts with `v`, so one whose first character had to be
|
|
206
|
+
* escaped still starts with a letter — and no two inputs share an output;
|
|
207
|
+
* - every value ENDS with `_z`, which cannot occur inside an encoding (an
|
|
208
|
+
* `_` there is always followed by four hex digits) — so no tenant's value
|
|
209
|
+
* is the beginning of another's (`1` and `12` would otherwise be `v1` and
|
|
210
|
+
* `v12`), and a prefix match over namespaces cannot reach a neighbour;
|
|
211
|
+
* - too long is REFUSED, never truncated.
|
|
212
|
+
*
|
|
213
|
+
* `agentCoreNamespaceValue('acme')` is `'vacme_z'`; `'Acme'` is `'v_0041cme_z'`.
|
|
214
|
+
* Use the same mapping wherever the namespace is read back (`searchNamespace`).
|
|
215
|
+
*
|
|
216
|
+
* @throws {TypeError} for an empty value — an absent tenant is not a tenant
|
|
217
|
+
* @throws {RangeError} when the encoding exceeds 64 characters (the value is
|
|
218
|
+
* not quoted: it names a tenant)
|
|
219
|
+
*/
|
|
220
|
+
function agentCoreNamespaceValue(raw) {
|
|
221
|
+
if (typeof raw !== 'string' || raw === '') {
|
|
222
|
+
throw new TypeError('agentCoreNamespaceValue: needs a non-empty string — an absent tenant is not a tenant, ' +
|
|
223
|
+
'and giving it a stand-in value would share that namespace with whoever is named it.');
|
|
224
|
+
}
|
|
225
|
+
let out = 'v';
|
|
226
|
+
for (let i = 0; i < raw.length; i++) {
|
|
227
|
+
const ch = raw[i];
|
|
228
|
+
out += /[a-z0-9-]/.test(ch) ? ch : `_${raw.charCodeAt(i).toString(16).padStart(4, '0')}`;
|
|
229
|
+
}
|
|
230
|
+
out += '_z';
|
|
231
|
+
if (out.length > NAMESPACE_VALUE_MAX) {
|
|
232
|
+
throw new RangeError(`agentCoreNamespaceValue: this value encodes to ${out.length} characters, over AgentCore's ` +
|
|
233
|
+
`${NAMESPACE_VALUE_MAX}. It is not truncated to fit — two ids truncated to one value ` +
|
|
234
|
+
'share a namespace. The value is not quoted here: it names a tenant.');
|
|
235
|
+
}
|
|
236
|
+
return out;
|
|
237
|
+
}
|
|
238
|
+
exports.agentCoreNamespaceValue = agentCoreNamespaceValue;
|
|
49
239
|
/**
|
|
50
240
|
* Thrown when an event carries a blob that is **present but unreadable** where a
|
|
51
241
|
* `MemoryEntry` should be.
|
|
@@ -257,11 +447,47 @@ class AgentCoreStore {
|
|
|
257
447
|
* anything.
|
|
258
448
|
*/
|
|
259
449
|
ranksBy = 'server-text';
|
|
450
|
+
/**
|
|
451
|
+
* **Both write options, translated to `CreateEvent`'s own fields:**
|
|
452
|
+
*
|
|
453
|
+
* `extraction: 'skip'` → `extractionMode: 'SKIP'` — the event stays in
|
|
454
|
+
* short-term memory and is excluded from
|
|
455
|
+
* long-term extraction.
|
|
456
|
+
* `namespaceScope` → `extractionConfig: { namespaceVariables }` —
|
|
457
|
+
* substituted into the memory's
|
|
458
|
+
* `namespaceTemplates` during extraction, which
|
|
459
|
+
* is how one tenant's derived records stay in
|
|
460
|
+
* that tenant's namespace.
|
|
461
|
+
*
|
|
462
|
+
* Absent — and both refused by name — when they could not reach AgentCore:
|
|
463
|
+
* an injected client that does not declare `forwardsWriteOptions`, or an
|
|
464
|
+
* installed SDK too old to MODEL the two fields (its serializer would drop
|
|
465
|
+
* them without a word). The variables are checked here against AgentCore's
|
|
466
|
+
* documented domain before anything is sent (see `checkNamespaceVariables`).
|
|
467
|
+
*
|
|
468
|
+
* A getter, not a field: a wrapper built by spreading this store
|
|
469
|
+
* (`{ ...store, put }`) does not copy it — and a wrapper that does not carry
|
|
470
|
+
* the third argument must not carry the declaration either.
|
|
471
|
+
*/
|
|
472
|
+
get writeOptions() {
|
|
473
|
+
return this.writeOptionsRefusal === undefined ? AGENTCORE_WRITE_OPTIONS : undefined;
|
|
474
|
+
}
|
|
260
475
|
client;
|
|
261
476
|
memoryId;
|
|
262
477
|
pageSize;
|
|
263
478
|
searchNamespace;
|
|
264
479
|
searchStrategyId;
|
|
480
|
+
requireNamespaceScope;
|
|
481
|
+
/**
|
|
482
|
+
* Set by the first write or search that carries a scope: from then on this
|
|
483
|
+
* store is a SCOPED store, and a call without one is refused — a second
|
|
484
|
+
* memory, a `defineRAG` or a direct call that forgot its scope never reads
|
|
485
|
+
* or files across the tenants the first one kept apart.
|
|
486
|
+
*/
|
|
487
|
+
servedScoped = false;
|
|
488
|
+
searchAcrossPrincipals;
|
|
489
|
+
/** Why the write options cannot be honoured — `undefined` when they can. */
|
|
490
|
+
writeOptionsRefusal;
|
|
265
491
|
closed = false;
|
|
266
492
|
// In-process shadow state for things AgentCore doesn't surface natively.
|
|
267
493
|
signatures = new Map();
|
|
@@ -275,12 +501,20 @@ class AgentCoreStore {
|
|
|
275
501
|
options.searchNamespace ??
|
|
276
502
|
(({ actorId, sessionId }) => `/actors/${actorId}/sessions/${sessionId}`);
|
|
277
503
|
this.searchStrategyId = options.searchStrategyId;
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
this.client
|
|
504
|
+
this.requireNamespaceScope = options.requireNamespaceScope === true;
|
|
505
|
+
this.searchAcrossPrincipals = options.searchAcrossPrincipals === true;
|
|
506
|
+
const injected = options._client ?? options.client;
|
|
507
|
+
this.client = injected ?? createAgentCoreClient(options.region, options._sdk);
|
|
508
|
+
this.writeOptionsRefusal =
|
|
509
|
+
this.client.forwardsWriteOptions === true
|
|
510
|
+
? undefined
|
|
511
|
+
: injected !== undefined
|
|
512
|
+
? 'its injected client does not declare `forwardsWriteOptions: true`, so it may drop ' +
|
|
513
|
+
"CreateEvent's `extractionMode` / `extractionConfig`. Declare it on the client once it " +
|
|
514
|
+
'forwards both fields unchanged'
|
|
515
|
+
: "the installed `@aws-sdk/client-bedrock-agentcore` does not model CreateEvent's " +
|
|
516
|
+
'`extractionMode` / `extractionConfig`, and its serializer drops a field it does not ' +
|
|
517
|
+
'model. Upgrade the SDK';
|
|
284
518
|
}
|
|
285
519
|
// MemoryIdentity → AgentCore (actorId, sessionId). The actor is the user/tenant; the
|
|
286
520
|
// session is the conversation. Both are derived deterministically, id-safe and
|
|
@@ -294,9 +528,10 @@ class AgentCoreStore {
|
|
|
294
528
|
sessionId(identity) {
|
|
295
529
|
// One field, so no joiner — but `sessionId` admits no `/`, so it escapes with
|
|
296
530
|
// `_` instead. `-` stays verbatim in both, which is what keeps a UUID a UUID.
|
|
297
|
-
return boundedId(escapeIdSegment(identity.conversationId
|
|
531
|
+
return boundedId(escapeIdSegment(identity.conversationId, '_'), SESSION_ID_MAX, 'session');
|
|
298
532
|
}
|
|
299
533
|
scope(identity) {
|
|
534
|
+
assertAddressable(identity);
|
|
300
535
|
return {
|
|
301
536
|
memoryId: this.memoryId,
|
|
302
537
|
actorId: this.actorId(identity),
|
|
@@ -309,6 +544,7 @@ class AgentCoreStore {
|
|
|
309
544
|
// a copy of the version where a `/` inside a tenant donated a field boundary
|
|
310
545
|
// — two different identities sharing one dedup set and one feedback bag.
|
|
311
546
|
shadowKey(identity) {
|
|
547
|
+
assertAddressable(identity);
|
|
312
548
|
return (0, index_js_1.identityNamespace)(identity);
|
|
313
549
|
}
|
|
314
550
|
feedbackKey(identity, id) {
|
|
@@ -345,25 +581,40 @@ class AgentCoreStore {
|
|
|
345
581
|
return null;
|
|
346
582
|
return found;
|
|
347
583
|
}
|
|
348
|
-
async put(identity, entry) {
|
|
584
|
+
async put(identity, entry, options) {
|
|
349
585
|
this.ensureOpen('put');
|
|
586
|
+
await this.createEvent(identity, entry, this.extractionFields(options));
|
|
587
|
+
}
|
|
588
|
+
/** One event, with the write options already turned into fields (and checked) once. */
|
|
589
|
+
async createEvent(identity, entry, extraction) {
|
|
350
590
|
if (entry.ttl !== undefined && entry.ttl <= Date.now())
|
|
351
591
|
return;
|
|
352
|
-
await this.client.createEvent({
|
|
592
|
+
await this.client.createEvent({
|
|
593
|
+
...this.scope(identity),
|
|
594
|
+
entry: entry,
|
|
595
|
+
...extraction,
|
|
596
|
+
});
|
|
353
597
|
}
|
|
354
|
-
async putMany(identity, entries) {
|
|
598
|
+
async putMany(identity, entries, options) {
|
|
355
599
|
this.ensureOpen('putMany');
|
|
356
600
|
// AgentCore has no batch-write API; per-session events are conceptually ordered, so
|
|
357
|
-
// sequentialize and let the SDK retry policy handle backoff.
|
|
601
|
+
// sequentialize and let the SDK retry policy handle backoff. The options ride
|
|
602
|
+
// every event of the batch — a batch is N writes, each asked the same thing,
|
|
603
|
+
// and turned into fields ONCE, so no await between events can change them.
|
|
604
|
+
if (entries.length === 0)
|
|
605
|
+
return;
|
|
606
|
+
const extraction = this.extractionFields(options);
|
|
358
607
|
for (const entry of entries)
|
|
359
|
-
await this.
|
|
608
|
+
await this.createEvent(identity, entry, extraction);
|
|
360
609
|
}
|
|
361
610
|
/**
|
|
362
611
|
* Emulated optimistic concurrency. AgentCore appends unconditionally; we read-then-write
|
|
363
612
|
* inside a JS critical section — adequate for single-writer-per-session deployments.
|
|
364
613
|
*/
|
|
365
|
-
async putIfVersion(identity, entry, expectedVersion) {
|
|
614
|
+
async putIfVersion(identity, entry, expectedVersion, options) {
|
|
366
615
|
this.ensureOpen('putIfVersion');
|
|
616
|
+
// Refused BEFORE the read, so an unhonoured option never costs a list.
|
|
617
|
+
const extraction = this.extractionFields(options);
|
|
367
618
|
const current = await this.get(identity, entry.id);
|
|
368
619
|
if (current === null) {
|
|
369
620
|
if (expectedVersion !== 0)
|
|
@@ -372,9 +623,86 @@ class AgentCoreStore {
|
|
|
372
623
|
else if (current.version !== expectedVersion) {
|
|
373
624
|
return { applied: false, currentVersion: current.version };
|
|
374
625
|
}
|
|
375
|
-
await this.
|
|
626
|
+
await this.createEvent(identity, entry, extraction);
|
|
376
627
|
return { applied: true };
|
|
377
628
|
}
|
|
629
|
+
/**
|
|
630
|
+
* The namespace one search reads — rendered by `searchNamespace` and refused
|
|
631
|
+
* by name when it could read beyond this identity: a wildcard, a namespace
|
|
632
|
+
* that does not hold the scope segment for segment, or one that stops above
|
|
633
|
+
* this identity's actor while the identity names a principal.
|
|
634
|
+
*/
|
|
635
|
+
namespaceFor(identity, ids, given) {
|
|
636
|
+
// An empty scope asks for nothing — the same rule writes follow
|
|
637
|
+
// (`requestedWriteOptions`) — so it is treated as no scope at all.
|
|
638
|
+
const copied = given === undefined ? undefined : frozenScope(given);
|
|
639
|
+
const namespaceScope = copied === undefined || Object.keys(copied).length === 0 ? undefined : copied;
|
|
640
|
+
if (namespaceScope === undefined && (this.requireNamespaceScope || this.servedScoped)) {
|
|
641
|
+
throw new TypeError(MISSING_SCOPE('search'));
|
|
642
|
+
}
|
|
643
|
+
if (namespaceScope !== undefined)
|
|
644
|
+
this.servedScoped = true;
|
|
645
|
+
if (namespaceScope !== undefined)
|
|
646
|
+
checkNamespaceVariables(namespaceScope);
|
|
647
|
+
const render = (scope) => this.searchNamespace({
|
|
648
|
+
actorId: ids.actorId,
|
|
649
|
+
sessionId: ids.sessionId,
|
|
650
|
+
identity,
|
|
651
|
+
...(scope !== undefined && { namespaceScope: scope }),
|
|
652
|
+
});
|
|
653
|
+
const namespace = render(namespaceScope);
|
|
654
|
+
assertNamespace(namespace);
|
|
655
|
+
if (namespace.includes('*')) {
|
|
656
|
+
throw new TypeError('AgentCoreStore.search(): `searchNamespace` returned a namespace containing `*`. ' +
|
|
657
|
+
'Results are kept only when they are filed at that namespace or under it, and a ' +
|
|
658
|
+
'wildcard cannot be checked that way — so it is refused rather than matching nothing. ' +
|
|
659
|
+
'Name the namespace exactly.');
|
|
660
|
+
}
|
|
661
|
+
if (namespaceScope !== undefined)
|
|
662
|
+
assertSearchWithinScope(render, namespace, namespaceScope);
|
|
663
|
+
// The actor is required when the identity names a principal — and on EVERY
|
|
664
|
+
// unscoped search: with no scope to confine it, the actor is the only thing
|
|
665
|
+
// that keeps the read on this identity (a namespace template rendered with
|
|
666
|
+
// no tenant collapses to a prefix every tenant shares).
|
|
667
|
+
// `searchAcrossPrincipals` widens a SCOPED search to the tenant's
|
|
668
|
+
// principals; with no scope there is no tenant to stay inside, so it never
|
|
669
|
+
// lifts the actor requirement there.
|
|
670
|
+
const actorRequired = namespaceScope === undefined ||
|
|
671
|
+
(identity.principal !== undefined && !this.searchAcrossPrincipals);
|
|
672
|
+
if (actorRequired && !holdsActor(namespace, ids.actorId)) {
|
|
673
|
+
throw new TypeError('AgentCoreStore.search(): the namespace searched does not hold this identity’s ' +
|
|
674
|
+
'`actorId`, so it would read records AgentCore derived from every principal it ' +
|
|
675
|
+
'covers. Put `{actorId}` in the strategy’s namespace template and in ' +
|
|
676
|
+
'`searchNamespace` (e.g. "/tenants/{tenantid}/actors/{actorId}/facts"), or set ' +
|
|
677
|
+
'`searchAcrossPrincipals: true` if the memory is shared on purpose.');
|
|
678
|
+
}
|
|
679
|
+
return namespace;
|
|
680
|
+
}
|
|
681
|
+
/**
|
|
682
|
+
* The write options as `CreateEvent`'s own fields — or a refusal by name for
|
|
683
|
+
* any this store's client cannot carry. The ONE place the vendor-neutral
|
|
684
|
+
* names become AWS's.
|
|
685
|
+
*/
|
|
686
|
+
extractionFields(options) {
|
|
687
|
+
(0, writeOptions_js_1.refuseUnhonouredWriteOptions)('AgentCoreStore', this.writeOptions, options, this.writeOptionsRefusal ?? '');
|
|
688
|
+
const asked = (0, writeOptions_js_1.requestedWriteOptions)(options);
|
|
689
|
+
// Copy FIRST, then decide on the copy — the same rule as a search: an empty
|
|
690
|
+
// copy is no scope, whatever the caller's object reported a moment earlier.
|
|
691
|
+
const given = options?.namespaceScope;
|
|
692
|
+
const copied = given === undefined ? undefined : frozenScope(given);
|
|
693
|
+
const scope = copied === undefined || Object.keys(copied).length === 0 ? undefined : copied;
|
|
694
|
+
if (scope === undefined && (this.requireNamespaceScope || this.servedScoped)) {
|
|
695
|
+
throw new TypeError(MISSING_SCOPE('write'));
|
|
696
|
+
}
|
|
697
|
+
if (scope !== undefined)
|
|
698
|
+
this.servedScoped = true;
|
|
699
|
+
if (scope !== undefined)
|
|
700
|
+
checkNamespaceVariables(scope);
|
|
701
|
+
return {
|
|
702
|
+
...(asked.includes('extraction') && { extractionMode: 'SKIP' }),
|
|
703
|
+
...(scope !== undefined && { extractionConfig: { namespaceVariables: scope } }),
|
|
704
|
+
};
|
|
705
|
+
}
|
|
378
706
|
async list(identity, options = {}) {
|
|
379
707
|
this.ensureOpen('list');
|
|
380
708
|
const page = await this.client.listEvents({
|
|
@@ -465,7 +793,8 @@ class AgentCoreStore {
|
|
|
465
793
|
* preferences. The ids therefore belong to AgentCore, not to entries you
|
|
466
794
|
* `put()`, and `store.get(entry.id)` will not find them. They arrive as
|
|
467
795
|
* entries so ranking code needs no special case, with `metadata.source`
|
|
468
|
-
* saying plainly where they came from
|
|
796
|
+
* saying plainly where they came from, and each value is `{ content }` —
|
|
797
|
+
* the record's text where every memory formatter reads it.
|
|
469
798
|
*
|
|
470
799
|
* Filters: `searchStrategyId` and the namespace reach AgentCore's own side;
|
|
471
800
|
* `k`, `minScore` and `tiers` are applied to what comes back.
|
|
@@ -489,15 +818,24 @@ class AgentCoreStore {
|
|
|
489
818
|
}
|
|
490
819
|
const scope = this.scope(identity);
|
|
491
820
|
const k = options.k ?? 10;
|
|
821
|
+
const namespace = this.namespaceFor(identity, scope, options.namespaceScope);
|
|
492
822
|
const page = await this.client.retrieveRecords({
|
|
493
823
|
memoryId: this.memoryId,
|
|
494
|
-
namespace
|
|
824
|
+
namespace,
|
|
495
825
|
searchQuery: text,
|
|
496
826
|
maxResults: k,
|
|
497
827
|
...(this.searchStrategyId !== undefined && { memoryStrategyId: this.searchStrategyId }),
|
|
498
828
|
});
|
|
499
829
|
const scored = [];
|
|
500
830
|
for (const record of page.records) {
|
|
831
|
+
// `namespace` is a PREFIX to AgentCore ("namespaces that start with the
|
|
832
|
+
// provided prefix"), so `/tenants/v1` also returns `/tenants/v12`'s
|
|
833
|
+
// records. Keep only what is filed AT the namespace asked for or under
|
|
834
|
+
// it — and drop a record that names no namespace, which cannot be shown
|
|
835
|
+
// to belong here, or that may be filed under ANOTHER actor (see
|
|
836
|
+
// `filedUnder`).
|
|
837
|
+
if (!filedUnder(record, namespace, scope.actorId))
|
|
838
|
+
continue;
|
|
501
839
|
const score = record.score ?? 0;
|
|
502
840
|
if (options.minScore !== undefined && score < options.minScore)
|
|
503
841
|
continue;
|
|
@@ -508,7 +846,13 @@ class AgentCoreStore {
|
|
|
508
846
|
const createdAt = record.createdAt ?? Date.now();
|
|
509
847
|
const entry = {
|
|
510
848
|
id: record.memoryRecordId,
|
|
511
|
-
|
|
849
|
+
// The store's record shape, `{ content }` — never the bare string.
|
|
850
|
+
// Both prompt formatters read the text off `.content` (the memory
|
|
851
|
+
// flavour as a message, the rag flavour as a passage), so a bare string
|
|
852
|
+
// rendered as an EMPTY block: the record was found and the model never
|
|
853
|
+
// saw it. No `role`: nobody said this; AgentCore derived it.
|
|
854
|
+
// Text only: a client outside the type hands back no non-string.
|
|
855
|
+
value: { content: typeof record.content === 'string' ? record.content : '' },
|
|
512
856
|
version: 1,
|
|
513
857
|
createdAt,
|
|
514
858
|
updatedAt: createdAt,
|
|
@@ -541,6 +885,24 @@ class AgentCoreStore {
|
|
|
541
885
|
}
|
|
542
886
|
}
|
|
543
887
|
exports.AgentCoreStore = AgentCoreStore;
|
|
888
|
+
/**
|
|
889
|
+
* Does the installed SDK model CreateEvent's `extractionMode` and
|
|
890
|
+
* `extractionConfig`? Its serializer drops a field it does not model, without a
|
|
891
|
+
* word, so an older SDK would accept the write options and send neither.
|
|
892
|
+
*
|
|
893
|
+
* Read off the SDK's own schema of the input (`CreateEventInput$`, whose member
|
|
894
|
+
* names include both in 3.1152.0); anything that cannot be read that way counts
|
|
895
|
+
* as "no" — the options are then refused by name, never sent into a drop.
|
|
896
|
+
*/
|
|
897
|
+
function sdkModelsExtraction(mod) {
|
|
898
|
+
const schema = mod.CreateEventInput$;
|
|
899
|
+
if (!Array.isArray(schema))
|
|
900
|
+
return false;
|
|
901
|
+
const members = schema.find((part) => Array.isArray(part) && part.includes('memoryId'));
|
|
902
|
+
return (members !== undefined &&
|
|
903
|
+
members.includes('extractionMode') &&
|
|
904
|
+
members.includes('extractionConfig'));
|
|
905
|
+
}
|
|
544
906
|
/**
|
|
545
907
|
* Pull the MemoryEntry out of an AgentCore event's `payload` (a single `blob`
|
|
546
908
|
* document) — this adapter's ONE decode step, and therefore the only place that
|
|
@@ -617,7 +979,10 @@ function createAgentCoreClient(region, injected) {
|
|
|
617
979
|
return sdk.send(new Ctor(input));
|
|
618
980
|
};
|
|
619
981
|
return {
|
|
620
|
-
|
|
982
|
+
// The two extraction fields below are forwarded as they are — but only an
|
|
983
|
+
// SDK that MODELS them sends them, so the declaration follows the SDK.
|
|
984
|
+
...(sdkModelsExtraction(mod) && { forwardsWriteOptions: true }),
|
|
985
|
+
async createEvent({ memoryId, actorId, sessionId, entry, extractionMode, extractionConfig }) {
|
|
621
986
|
// The entry is stored as a single `blob` document (PayloadType.blob =
|
|
622
987
|
// __DocumentType), and it goes in as JSON TEXT, not as the object.
|
|
623
988
|
// Field-learned on the session store and true of every blob this service
|
|
@@ -633,6 +998,13 @@ function createAgentCoreClient(region, injected) {
|
|
|
633
998
|
sessionId,
|
|
634
999
|
eventTimestamp: new Date(),
|
|
635
1000
|
payload: [{ blob: JSON.stringify(entry) }],
|
|
1001
|
+
// `CreateEventInput`'s own names (`ExtractionMode.SKIP`,
|
|
1002
|
+
// `ExtractionConfig.namespaceVariables`), present only when asked —
|
|
1003
|
+
// an event without them is extracted exactly as before.
|
|
1004
|
+
...(extractionMode !== undefined && { extractionMode }),
|
|
1005
|
+
...(extractionConfig !== undefined && {
|
|
1006
|
+
extractionConfig: { namespaceVariables: { ...extractionConfig.namespaceVariables } },
|
|
1007
|
+
}),
|
|
636
1008
|
});
|
|
637
1009
|
},
|
|
638
1010
|
async listEvents({ memoryId, actorId, sessionId, maxResults, nextToken }) {
|
|
@@ -676,7 +1048,14 @@ function createAgentCoreClient(region, injected) {
|
|
|
676
1048
|
}));
|
|
677
1049
|
const records = (r?.memoryRecordSummaries ?? []).map((s) => {
|
|
678
1050
|
const content = typeof s.content === 'string' ? s.content : s.content?.text ?? '';
|
|
679
|
-
const
|
|
1051
|
+
const namespaces = (Array.isArray(s.namespaces)
|
|
1052
|
+
? s.namespaces
|
|
1053
|
+
: Array.isArray(s.namespace)
|
|
1054
|
+
? s.namespace
|
|
1055
|
+
: typeof s.namespace === 'string'
|
|
1056
|
+
? [s.namespace]
|
|
1057
|
+
: []).filter((n) => typeof n === 'string');
|
|
1058
|
+
const namespaceValue = namespaces[0];
|
|
680
1059
|
const createdAt = s.createdAt === undefined ? undefined : new Date(s.createdAt).getTime();
|
|
681
1060
|
return {
|
|
682
1061
|
memoryRecordId: s.memoryRecordId ?? '',
|
|
@@ -684,6 +1063,7 @@ function createAgentCoreClient(region, injected) {
|
|
|
684
1063
|
...(typeof s.score === 'number' && { score: s.score }),
|
|
685
1064
|
...(s.memoryStrategyId !== undefined && { memoryStrategyId: s.memoryStrategyId }),
|
|
686
1065
|
...(typeof namespaceValue === 'string' && { namespace: namespaceValue }),
|
|
1066
|
+
...(namespaces.length > 0 && { namespaces }),
|
|
687
1067
|
...(createdAt !== undefined && Number.isFinite(createdAt) && { createdAt }),
|
|
688
1068
|
};
|
|
689
1069
|
});
|
|
@@ -691,4 +1071,39 @@ function createAgentCoreClient(region, injected) {
|
|
|
691
1071
|
},
|
|
692
1072
|
};
|
|
693
1073
|
}
|
|
1074
|
+
/** A namespace compared as a path: repeated `/` collapsed, a trailing one dropped. */
|
|
1075
|
+
function pathOf(namespace) {
|
|
1076
|
+
return namespace.replace(/\/{2,}/g, '/').replace(/\/$/, '');
|
|
1077
|
+
}
|
|
1078
|
+
/** What the start of another actor's id extending this one looks like. */
|
|
1079
|
+
const ACTOR_ESCAPE_AHEAD = /^[0-9A-F]{4}/;
|
|
1080
|
+
/**
|
|
1081
|
+
* Is `record` filed AT `asked` or under it? Compared on whole path segments —
|
|
1082
|
+
* repeated and trailing `/` ignored on both sides — because AgentCore's
|
|
1083
|
+
* `namespace` filter is a string prefix, and `/tenants/v1` must not admit
|
|
1084
|
+
* `/tenants/v12`.
|
|
1085
|
+
*
|
|
1086
|
+
* One more case, because an actor id can hold a `/`: its escape is `/` + four
|
|
1087
|
+
* hex digits (`bob@x.com` → `bob/0040x/002Ecom`), so another actor's id can
|
|
1088
|
+
* EXTEND this one by whole segments (`bob@x.com.au` adds `/002Eau`). When the
|
|
1089
|
+
* namespace asked for ends with this identity's `actorId`, a record filed under
|
|
1090
|
+
* a continuation that starts with four uppercase hex digits may be that other
|
|
1091
|
+
* actor's — and is dropped. A sub-namespace of your own that starts that way
|
|
1092
|
+
* is dropped too (put a literal segment after `{actorId}`), never served across
|
|
1093
|
+
* actors. That literal must not itself start with four uppercase hex digits,
|
|
1094
|
+
* or the guard cannot tell it from another actor's id.
|
|
1095
|
+
*/
|
|
1096
|
+
function filedUnder(record, asked, actorId) {
|
|
1097
|
+
const base = pathOf(asked);
|
|
1098
|
+
const guardActor = base.endsWith(actorId);
|
|
1099
|
+
const filed = record.namespaces ?? (record.namespace !== undefined ? [record.namespace] : []);
|
|
1100
|
+
return filed.some((ns) => {
|
|
1101
|
+
const n = pathOf(ns);
|
|
1102
|
+
if (n === base)
|
|
1103
|
+
return true;
|
|
1104
|
+
if (!n.startsWith(`${base}/`))
|
|
1105
|
+
return false;
|
|
1106
|
+
return !(guardActor && ACTOR_ESCAPE_AHEAD.test(n.slice(base.length + 1)));
|
|
1107
|
+
});
|
|
1108
|
+
}
|
|
694
1109
|
//# sourceMappingURL=agentcore.js.map
|