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