@strands-agents/sdk 1.7.0 → 1.9.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/dist/src/agent/agent.d.ts +32 -2
- package/dist/src/agent/agent.d.ts.map +1 -1
- package/dist/src/agent/agent.js +92 -4
- package/dist/src/agent/agent.js.map +1 -1
- package/dist/src/context-manager/modes/agentic/agentic-context.d.ts +3 -3
- package/dist/src/context-manager/modes/agentic/agentic-context.d.ts.map +1 -1
- package/dist/src/conversation-manager/sliding-window-conversation-manager.d.ts.map +1 -1
- package/dist/src/conversation-manager/sliding-window-conversation-manager.js +2 -0
- package/dist/src/conversation-manager/sliding-window-conversation-manager.js.map +1 -1
- package/dist/src/errors.d.ts +7 -0
- package/dist/src/errors.d.ts.map +1 -1
- package/dist/src/errors.js +10 -0
- package/dist/src/errors.js.map +1 -1
- package/dist/src/experimental/checkpoint.d.ts +118 -0
- package/dist/src/experimental/checkpoint.d.ts.map +1 -0
- package/dist/src/experimental/checkpoint.js +108 -0
- package/dist/src/experimental/checkpoint.js.map +1 -0
- package/dist/src/experimental/index.d.ts +10 -0
- package/dist/src/experimental/index.d.ts.map +1 -0
- package/dist/src/experimental/index.js +9 -0
- package/dist/src/experimental/index.js.map +1 -0
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/index.node.d.ts.map +1 -1
- package/dist/src/index.node.js +3 -0
- package/dist/src/index.node.js.map +1 -1
- package/dist/src/injection/message-injection.d.ts.map +1 -1
- package/dist/src/injection/message-injection.js +2 -0
- package/dist/src/injection/message-injection.js.map +1 -1
- package/dist/src/interventions/actions.d.ts.map +1 -1
- package/dist/src/interventions/actions.js.map +1 -1
- package/dist/src/{mcp.d.ts → mcp/client.d.ts} +13 -4
- package/dist/src/mcp/client.d.ts.map +1 -0
- package/dist/src/{mcp.js → mcp/client.js} +15 -3
- package/dist/src/mcp/client.js.map +1 -0
- package/dist/src/mcp/config.d.ts +52 -0
- package/dist/src/mcp/config.d.ts.map +1 -0
- package/dist/src/mcp/config.js +12 -0
- package/dist/src/mcp/config.js.map +1 -0
- package/dist/src/mcp/config.node.d.ts +16 -0
- package/dist/src/mcp/config.node.d.ts.map +1 -0
- package/dist/src/mcp/config.node.js +145 -0
- package/dist/src/mcp/config.node.js.map +1 -0
- package/dist/src/mcp/index.d.ts +3 -0
- package/dist/src/mcp/index.d.ts.map +1 -0
- package/dist/src/mcp/index.js +2 -0
- package/dist/src/mcp/index.js.map +1 -0
- package/dist/src/models/model.d.ts.map +1 -1
- package/dist/src/models/model.js +2 -1
- package/dist/src/models/model.js.map +1 -1
- package/dist/src/multiagent/graph.d.ts +7 -0
- package/dist/src/multiagent/graph.d.ts.map +1 -1
- package/dist/src/multiagent/graph.js +22 -1
- package/dist/src/multiagent/graph.js.map +1 -1
- package/dist/src/multiagent/multiagent.d.ts +2 -1
- package/dist/src/multiagent/multiagent.d.ts.map +1 -1
- package/dist/src/multiagent/multiagent.js.map +1 -1
- package/dist/src/multiagent/nodes.d.ts +5 -0
- package/dist/src/multiagent/nodes.d.ts.map +1 -1
- package/dist/src/multiagent/nodes.js +15 -0
- package/dist/src/multiagent/nodes.js.map +1 -1
- package/dist/src/multiagent/state.d.ts.map +1 -1
- package/dist/src/multiagent/state.js.map +1 -1
- package/dist/src/tools/function-tool.d.ts +1 -1
- package/dist/src/tools/function-tool.d.ts.map +1 -1
- package/dist/src/tools/function-tool.js +4 -12
- package/dist/src/tools/function-tool.js.map +1 -1
- package/dist/src/tools/mcp-tool.d.ts +2 -1
- package/dist/src/tools/mcp-tool.d.ts.map +1 -1
- package/dist/src/tools/mcp-tool.js +1 -0
- package/dist/src/tools/mcp-tool.js.map +1 -1
- package/dist/src/tools/tool-factory.d.ts +1 -1
- package/dist/src/tools/tool-factory.d.ts.map +1 -1
- package/dist/src/tools/types.d.ts +4 -0
- package/dist/src/tools/types.d.ts.map +1 -1
- package/dist/src/tools/zod-tool.d.ts +4 -2
- package/dist/src/tools/zod-tool.d.ts.map +1 -1
- package/dist/src/tools/zod-tool.js.map +1 -1
- package/dist/src/tsconfig.tsbuildinfo +1 -1
- package/dist/src/types/agent.d.ts +18 -1
- package/dist/src/types/agent.d.ts.map +1 -1
- package/dist/src/types/agent.js +12 -0
- package/dist/src/types/agent.js.map +1 -1
- package/dist/src/types/media.d.ts.map +1 -1
- package/dist/src/types/media.js.map +1 -1
- package/dist/src/types/messages.d.ts +22 -1
- package/dist/src/types/messages.d.ts.map +1 -1
- package/dist/src/types/messages.js +22 -0
- package/dist/src/types/messages.js.map +1 -1
- package/dist/src/vended-memory-stores/test-memory-store/index.d.ts +2 -0
- package/dist/src/vended-memory-stores/test-memory-store/index.d.ts.map +1 -0
- package/dist/src/vended-memory-stores/test-memory-store/index.js +2 -0
- package/dist/src/vended-memory-stores/test-memory-store/index.js.map +1 -0
- package/dist/src/vended-memory-stores/test-memory-store/store.d.ts +122 -0
- package/dist/src/vended-memory-stores/test-memory-store/store.d.ts.map +1 -0
- package/dist/src/vended-memory-stores/test-memory-store/store.js +281 -0
- package/dist/src/vended-memory-stores/test-memory-store/store.js.map +1 -0
- package/dist/src/vended-plugins/context-offloader/search.d.ts.map +1 -1
- package/dist/src/vended-plugins/context-offloader/search.js +4 -2
- package/dist/src/vended-plugins/context-offloader/search.js.map +1 -1
- package/dist/src/vended-plugins/context-offloader/storage.js +1 -1
- package/dist/src/vended-plugins/context-offloader/storage.js.map +1 -1
- package/dist/src/vended-plugins/skills/skill.d.ts.map +1 -1
- package/dist/src/vended-plugins/skills/skill.js.map +1 -1
- package/dist/src/vended-tools/notebook/notebook.d.ts +1 -1
- package/package.json +41 -30
- package/dist/src/__fixtures__/agent-helpers.d.ts +0 -136
- package/dist/src/__fixtures__/agent-helpers.d.ts.map +0 -1
- package/dist/src/__fixtures__/agent-helpers.js +0 -156
- package/dist/src/__fixtures__/agent-helpers.js.map +0 -1
- package/dist/src/__fixtures__/environment.d.ts +0 -12
- package/dist/src/__fixtures__/environment.d.ts.map +0 -1
- package/dist/src/__fixtures__/environment.js +0 -12
- package/dist/src/__fixtures__/environment.js.map +0 -1
- package/dist/src/__fixtures__/metrics-helpers.d.ts +0 -55
- package/dist/src/__fixtures__/metrics-helpers.d.ts.map +0 -1
- package/dist/src/__fixtures__/metrics-helpers.js +0 -57
- package/dist/src/__fixtures__/metrics-helpers.js.map +0 -1
- package/dist/src/__fixtures__/mock-message-model.d.ts +0 -103
- package/dist/src/__fixtures__/mock-message-model.d.ts.map +0 -1
- package/dist/src/__fixtures__/mock-message-model.js +0 -245
- package/dist/src/__fixtures__/mock-message-model.js.map +0 -1
- package/dist/src/__fixtures__/mock-meter.d.ts +0 -32
- package/dist/src/__fixtures__/mock-meter.d.ts.map +0 -1
- package/dist/src/__fixtures__/mock-meter.js +0 -47
- package/dist/src/__fixtures__/mock-meter.js.map +0 -1
- package/dist/src/__fixtures__/mock-plugin.d.ts +0 -13
- package/dist/src/__fixtures__/mock-plugin.d.ts.map +0 -1
- package/dist/src/__fixtures__/mock-plugin.js +0 -35
- package/dist/src/__fixtures__/mock-plugin.js.map +0 -1
- package/dist/src/__fixtures__/mock-span.d.ts +0 -78
- package/dist/src/__fixtures__/mock-span.d.ts.map +0 -1
- package/dist/src/__fixtures__/mock-span.js +0 -93
- package/dist/src/__fixtures__/mock-span.js.map +0 -1
- package/dist/src/__fixtures__/mock-storage-provider.d.ts +0 -42
- package/dist/src/__fixtures__/mock-storage-provider.d.ts.map +0 -1
- package/dist/src/__fixtures__/mock-storage-provider.js +0 -122
- package/dist/src/__fixtures__/mock-storage-provider.js.map +0 -1
- package/dist/src/__fixtures__/model-test-helpers.d.ts +0 -56
- package/dist/src/__fixtures__/model-test-helpers.d.ts.map +0 -1
- package/dist/src/__fixtures__/model-test-helpers.js +0 -85
- package/dist/src/__fixtures__/model-test-helpers.js.map +0 -1
- package/dist/src/__fixtures__/register-node-defaults.d.ts +0 -2
- package/dist/src/__fixtures__/register-node-defaults.d.ts.map +0 -1
- package/dist/src/__fixtures__/register-node-defaults.js +0 -6
- package/dist/src/__fixtures__/register-node-defaults.js.map +0 -1
- package/dist/src/__fixtures__/slim-types.d.ts +0 -51
- package/dist/src/__fixtures__/slim-types.d.ts.map +0 -1
- package/dist/src/__fixtures__/slim-types.js +0 -6
- package/dist/src/__fixtures__/slim-types.js.map +0 -1
- package/dist/src/__fixtures__/test-sandbox.node.d.ts +0 -15
- package/dist/src/__fixtures__/test-sandbox.node.d.ts.map +0 -1
- package/dist/src/__fixtures__/test-sandbox.node.js +0 -23
- package/dist/src/__fixtures__/test-sandbox.node.js.map +0 -1
- package/dist/src/__fixtures__/tool-helpers.d.ts +0 -45
- package/dist/src/__fixtures__/tool-helpers.d.ts.map +0 -1
- package/dist/src/__fixtures__/tool-helpers.js +0 -101
- package/dist/src/__fixtures__/tool-helpers.js.map +0 -1
- package/dist/src/__tests__/default-slot.test.d.ts +0 -2
- package/dist/src/__tests__/default-slot.test.d.ts.map +0 -1
- package/dist/src/__tests__/default-slot.test.js +0 -33
- package/dist/src/__tests__/default-slot.test.js.map +0 -1
- package/dist/src/__tests__/errors.test.d.ts +0 -2
- package/dist/src/__tests__/errors.test.d.ts.map +0 -1
- package/dist/src/__tests__/errors.test.js +0 -170
- package/dist/src/__tests__/errors.test.js.map +0 -1
- package/dist/src/__tests__/index.test.d.ts +0 -2
- package/dist/src/__tests__/index.test.d.ts.map +0 -1
- package/dist/src/__tests__/index.test.js +0 -48
- package/dist/src/__tests__/index.test.js.map +0 -1
- package/dist/src/__tests__/interrupt.test.d.ts +0 -2
- package/dist/src/__tests__/interrupt.test.d.ts.map +0 -1
- package/dist/src/__tests__/interrupt.test.js +0 -264
- package/dist/src/__tests__/interrupt.test.js.map +0 -1
- package/dist/src/__tests__/mcp.test.d.ts +0 -2
- package/dist/src/__tests__/mcp.test.d.ts.map +0 -1
- package/dist/src/__tests__/mcp.test.js +0 -1003
- package/dist/src/__tests__/mcp.test.js.map +0 -1
- package/dist/src/__tests__/mime.test.d.ts +0 -2
- package/dist/src/__tests__/mime.test.d.ts.map +0 -1
- package/dist/src/__tests__/mime.test.js +0 -83
- package/dist/src/__tests__/mime.test.js.map +0 -1
- package/dist/src/__tests__/state-store.test.d.ts +0 -2
- package/dist/src/__tests__/state-store.test.d.ts.map +0 -1
- package/dist/src/__tests__/state-store.test.js +0 -285
- package/dist/src/__tests__/state-store.test.js.map +0 -1
- package/dist/src/a2a/__tests__/a2a-agent.test.d.ts +0 -2
- package/dist/src/a2a/__tests__/a2a-agent.test.d.ts.map +0 -1
- package/dist/src/a2a/__tests__/a2a-agent.test.js +0 -383
- package/dist/src/a2a/__tests__/a2a-agent.test.js.map +0 -1
- package/dist/src/a2a/__tests__/adapters.test.d.ts +0 -2
- package/dist/src/a2a/__tests__/adapters.test.d.ts.map +0 -1
- package/dist/src/a2a/__tests__/adapters.test.js +0 -151
- package/dist/src/a2a/__tests__/adapters.test.js.map +0 -1
- package/dist/src/a2a/__tests__/async-lock.test.d.ts +0 -2
- package/dist/src/a2a/__tests__/async-lock.test.d.ts.map +0 -1
- package/dist/src/a2a/__tests__/async-lock.test.js +0 -137
- package/dist/src/a2a/__tests__/async-lock.test.js.map +0 -1
- package/dist/src/a2a/__tests__/events.test.d.ts +0 -2
- package/dist/src/a2a/__tests__/events.test.d.ts.map +0 -1
- package/dist/src/a2a/__tests__/events.test.js +0 -68
- package/dist/src/a2a/__tests__/events.test.js.map +0 -1
- package/dist/src/a2a/__tests__/executor.test.d.ts +0 -2
- package/dist/src/a2a/__tests__/executor.test.d.ts.map +0 -1
- package/dist/src/a2a/__tests__/executor.test.js +0 -345
- package/dist/src/a2a/__tests__/executor.test.js.map +0 -1
- package/dist/src/a2a/__tests__/server.test.d.ts +0 -2
- package/dist/src/a2a/__tests__/server.test.d.ts.map +0 -1
- package/dist/src/a2a/__tests__/server.test.js +0 -71
- package/dist/src/a2a/__tests__/server.test.js.map +0 -1
- package/dist/src/a2a/__tests__/server.test.node.d.ts +0 -2
- package/dist/src/a2a/__tests__/server.test.node.d.ts.map +0 -1
- package/dist/src/a2a/__tests__/server.test.node.js +0 -110
- package/dist/src/a2a/__tests__/server.test.node.js.map +0 -1
- package/dist/src/agent/__tests__/agent-as-tool.invocation-state.test.d.ts +0 -2
- package/dist/src/agent/__tests__/agent-as-tool.invocation-state.test.d.ts.map +0 -1
- package/dist/src/agent/__tests__/agent-as-tool.invocation-state.test.js +0 -23
- package/dist/src/agent/__tests__/agent-as-tool.invocation-state.test.js.map +0 -1
- package/dist/src/agent/__tests__/agent-as-tool.test.d.ts +0 -2
- package/dist/src/agent/__tests__/agent-as-tool.test.d.ts.map +0 -1
- package/dist/src/agent/__tests__/agent-as-tool.test.js +0 -347
- package/dist/src/agent/__tests__/agent-as-tool.test.js.map +0 -1
- package/dist/src/agent/__tests__/agent.cancel.test.d.ts +0 -2
- package/dist/src/agent/__tests__/agent.cancel.test.d.ts.map +0 -1
- package/dist/src/agent/__tests__/agent.cancel.test.js +0 -337
- package/dist/src/agent/__tests__/agent.cancel.test.js.map +0 -1
- package/dist/src/agent/__tests__/agent.concurrent.test.d.ts +0 -2
- package/dist/src/agent/__tests__/agent.concurrent.test.d.ts.map +0 -1
- package/dist/src/agent/__tests__/agent.concurrent.test.js +0 -488
- package/dist/src/agent/__tests__/agent.concurrent.test.js.map +0 -1
- package/dist/src/agent/__tests__/agent.context-manager.test.d.ts +0 -2
- package/dist/src/agent/__tests__/agent.context-manager.test.d.ts.map +0 -1
- package/dist/src/agent/__tests__/agent.context-manager.test.js +0 -106
- package/dist/src/agent/__tests__/agent.context-manager.test.js.map +0 -1
- package/dist/src/agent/__tests__/agent.hook.test.d.ts +0 -2
- package/dist/src/agent/__tests__/agent.hook.test.d.ts.map +0 -1
- package/dist/src/agent/__tests__/agent.hook.test.js +0 -1332
- package/dist/src/agent/__tests__/agent.hook.test.js.map +0 -1
- package/dist/src/agent/__tests__/agent.interrupt.test.d.ts +0 -2
- package/dist/src/agent/__tests__/agent.interrupt.test.d.ts.map +0 -1
- package/dist/src/agent/__tests__/agent.interrupt.test.js +0 -779
- package/dist/src/agent/__tests__/agent.interrupt.test.js.map +0 -1
- package/dist/src/agent/__tests__/agent.invocation-state.test.d.ts +0 -2
- package/dist/src/agent/__tests__/agent.invocation-state.test.d.ts.map +0 -1
- package/dist/src/agent/__tests__/agent.invocation-state.test.js +0 -219
- package/dist/src/agent/__tests__/agent.invocation-state.test.js.map +0 -1
- package/dist/src/agent/__tests__/agent.model-retry.test.d.ts +0 -2
- package/dist/src/agent/__tests__/agent.model-retry.test.d.ts.map +0 -1
- package/dist/src/agent/__tests__/agent.model-retry.test.js +0 -161
- package/dist/src/agent/__tests__/agent.model-retry.test.js.map +0 -1
- package/dist/src/agent/__tests__/agent.stateful-model.test.d.ts +0 -2
- package/dist/src/agent/__tests__/agent.stateful-model.test.d.ts.map +0 -1
- package/dist/src/agent/__tests__/agent.stateful-model.test.js +0 -169
- package/dist/src/agent/__tests__/agent.stateful-model.test.js.map +0 -1
- package/dist/src/agent/__tests__/agent.test.d.ts +0 -2
- package/dist/src/agent/__tests__/agent.test.d.ts.map +0 -1
- package/dist/src/agent/__tests__/agent.test.js +0 -1624
- package/dist/src/agent/__tests__/agent.test.js.map +0 -1
- package/dist/src/agent/__tests__/agent.tracer.test.node.d.ts +0 -2
- package/dist/src/agent/__tests__/agent.tracer.test.node.d.ts.map +0 -1
- package/dist/src/agent/__tests__/agent.tracer.test.node.js +0 -535
- package/dist/src/agent/__tests__/agent.tracer.test.node.js.map +0 -1
- package/dist/src/agent/__tests__/printer.test.d.ts +0 -2
- package/dist/src/agent/__tests__/printer.test.d.ts.map +0 -1
- package/dist/src/agent/__tests__/printer.test.js +0 -188
- package/dist/src/agent/__tests__/printer.test.js.map +0 -1
- package/dist/src/agent/__tests__/snapshot.test.d.ts +0 -2
- package/dist/src/agent/__tests__/snapshot.test.d.ts.map +0 -1
- package/dist/src/agent/__tests__/snapshot.test.js +0 -442
- package/dist/src/agent/__tests__/snapshot.test.js.map +0 -1
- package/dist/src/agent/__tests__/tool-caller.test.d.ts +0 -2
- package/dist/src/agent/__tests__/tool-caller.test.d.ts.map +0 -1
- package/dist/src/agent/__tests__/tool-caller.test.js +0 -459
- package/dist/src/agent/__tests__/tool-caller.test.js.map +0 -1
- package/dist/src/conversation-manager/__tests__/agentic-context.test.d.ts +0 -2
- package/dist/src/conversation-manager/__tests__/agentic-context.test.d.ts.map +0 -1
- package/dist/src/conversation-manager/__tests__/agentic-context.test.js +0 -332
- package/dist/src/conversation-manager/__tests__/agentic-context.test.js.map +0 -1
- package/dist/src/conversation-manager/__tests__/context-compression.test.d.ts +0 -2
- package/dist/src/conversation-manager/__tests__/context-compression.test.d.ts.map +0 -1
- package/dist/src/conversation-manager/__tests__/context-compression.test.js +0 -176
- package/dist/src/conversation-manager/__tests__/context-compression.test.js.map +0 -1
- package/dist/src/conversation-manager/__tests__/conversation-manager.test.d.ts +0 -2
- package/dist/src/conversation-manager/__tests__/conversation-manager.test.d.ts.map +0 -1
- package/dist/src/conversation-manager/__tests__/conversation-manager.test.js +0 -321
- package/dist/src/conversation-manager/__tests__/conversation-manager.test.js.map +0 -1
- package/dist/src/conversation-manager/__tests__/null-conversation-manager.test.d.ts +0 -2
- package/dist/src/conversation-manager/__tests__/null-conversation-manager.test.d.ts.map +0 -1
- package/dist/src/conversation-manager/__tests__/null-conversation-manager.test.js +0 -64
- package/dist/src/conversation-manager/__tests__/null-conversation-manager.test.js.map +0 -1
- package/dist/src/conversation-manager/__tests__/pin.test.d.ts +0 -2
- package/dist/src/conversation-manager/__tests__/pin.test.d.ts.map +0 -1
- package/dist/src/conversation-manager/__tests__/pin.test.js +0 -119
- package/dist/src/conversation-manager/__tests__/pin.test.js.map +0 -1
- package/dist/src/conversation-manager/__tests__/sliding-window-conversation-manager.test.d.ts +0 -2
- package/dist/src/conversation-manager/__tests__/sliding-window-conversation-manager.test.d.ts.map +0 -1
- package/dist/src/conversation-manager/__tests__/sliding-window-conversation-manager.test.js +0 -1080
- package/dist/src/conversation-manager/__tests__/sliding-window-conversation-manager.test.js.map +0 -1
- package/dist/src/conversation-manager/__tests__/summarizing-conversation-manager.test.d.ts +0 -2
- package/dist/src/conversation-manager/__tests__/summarizing-conversation-manager.test.d.ts.map +0 -1
- package/dist/src/conversation-manager/__tests__/summarizing-conversation-manager.test.js +0 -400
- package/dist/src/conversation-manager/__tests__/summarizing-conversation-manager.test.js.map +0 -1
- package/dist/src/conversation-manager/__tests__/token-usage-middleware.test.d.ts +0 -2
- package/dist/src/conversation-manager/__tests__/token-usage-middleware.test.d.ts.map +0 -1
- package/dist/src/conversation-manager/__tests__/token-usage-middleware.test.js +0 -138
- package/dist/src/conversation-manager/__tests__/token-usage-middleware.test.js.map +0 -1
- package/dist/src/hooks/__tests__/events.test.d.ts +0 -2
- package/dist/src/hooks/__tests__/events.test.d.ts.map +0 -1
- package/dist/src/hooks/__tests__/events.test.js +0 -1060
- package/dist/src/hooks/__tests__/events.test.js.map +0 -1
- package/dist/src/hooks/__tests__/registry.test.d.ts +0 -2
- package/dist/src/hooks/__tests__/registry.test.d.ts.map +0 -1
- package/dist/src/hooks/__tests__/registry.test.js +0 -325
- package/dist/src/hooks/__tests__/registry.test.js.map +0 -1
- package/dist/src/injection/__tests__/message-injection.test.d.ts +0 -2
- package/dist/src/injection/__tests__/message-injection.test.d.ts.map +0 -1
- package/dist/src/injection/__tests__/message-injection.test.js +0 -200
- package/dist/src/injection/__tests__/message-injection.test.js.map +0 -1
- package/dist/src/interventions/__tests__/handler.test.d.ts +0 -2
- package/dist/src/interventions/__tests__/handler.test.d.ts.map +0 -1
- package/dist/src/interventions/__tests__/handler.test.js +0 -35
- package/dist/src/interventions/__tests__/handler.test.js.map +0 -1
- package/dist/src/interventions/__tests__/registry.test.d.ts +0 -2
- package/dist/src/interventions/__tests__/registry.test.d.ts.map +0 -1
- package/dist/src/interventions/__tests__/registry.test.js +0 -692
- package/dist/src/interventions/__tests__/registry.test.js.map +0 -1
- package/dist/src/logging/__tests__/logger.test.d.ts +0 -2
- package/dist/src/logging/__tests__/logger.test.d.ts.map +0 -1
- package/dist/src/logging/__tests__/logger.test.js +0 -70
- package/dist/src/logging/__tests__/logger.test.js.map +0 -1
- package/dist/src/logging/__tests__/warn-once.test.d.ts +0 -2
- package/dist/src/logging/__tests__/warn-once.test.d.ts.map +0 -1
- package/dist/src/logging/__tests__/warn-once.test.js +0 -30
- package/dist/src/logging/__tests__/warn-once.test.js.map +0 -1
- package/dist/src/mcp.d.ts.map +0 -1
- package/dist/src/mcp.js.map +0 -1
- package/dist/src/memory/__tests__/memory-manager.test.d.ts +0 -2
- package/dist/src/memory/__tests__/memory-manager.test.d.ts.map +0 -1
- package/dist/src/memory/__tests__/memory-manager.test.js +0 -679
- package/dist/src/memory/__tests__/memory-manager.test.js.map +0 -1
- package/dist/src/memory/__tests__/memory-tracing.test.d.ts +0 -2
- package/dist/src/memory/__tests__/memory-tracing.test.d.ts.map +0 -1
- package/dist/src/memory/__tests__/memory-tracing.test.js +0 -250
- package/dist/src/memory/__tests__/memory-tracing.test.js.map +0 -1
- package/dist/src/memory/extraction/__tests__/extraction.test.d.ts +0 -2
- package/dist/src/memory/extraction/__tests__/extraction.test.d.ts.map +0 -1
- package/dist/src/memory/extraction/__tests__/extraction.test.js +0 -639
- package/dist/src/memory/extraction/__tests__/extraction.test.js.map +0 -1
- package/dist/src/memory/extraction/__tests__/model-extractor.test.d.ts +0 -2
- package/dist/src/memory/extraction/__tests__/model-extractor.test.d.ts.map +0 -1
- package/dist/src/memory/extraction/__tests__/model-extractor.test.js +0 -104
- package/dist/src/memory/extraction/__tests__/model-extractor.test.js.map +0 -1
- package/dist/src/memory/extraction/__tests__/resolve-extraction-config.test.d.ts +0 -2
- package/dist/src/memory/extraction/__tests__/resolve-extraction-config.test.d.ts.map +0 -1
- package/dist/src/memory/extraction/__tests__/resolve-extraction-config.test.js +0 -81
- package/dist/src/memory/extraction/__tests__/resolve-extraction-config.test.js.map +0 -1
- package/dist/src/middleware/__tests__/agent-middleware.test.d.ts +0 -2
- package/dist/src/middleware/__tests__/agent-middleware.test.d.ts.map +0 -1
- package/dist/src/middleware/__tests__/agent-middleware.test.js +0 -1206
- package/dist/src/middleware/__tests__/agent-middleware.test.js.map +0 -1
- package/dist/src/middleware/__tests__/copy-on-input.test.d.ts +0 -2
- package/dist/src/middleware/__tests__/copy-on-input.test.d.ts.map +0 -1
- package/dist/src/middleware/__tests__/copy-on-input.test.js +0 -379
- package/dist/src/middleware/__tests__/copy-on-input.test.js.map +0 -1
- package/dist/src/middleware/__tests__/custom-stages.test.d.ts +0 -2
- package/dist/src/middleware/__tests__/custom-stages.test.d.ts.map +0 -1
- package/dist/src/middleware/__tests__/custom-stages.test.js +0 -97
- package/dist/src/middleware/__tests__/custom-stages.test.js.map +0 -1
- package/dist/src/middleware/__tests__/middleware-interrupts.test.d.ts +0 -2
- package/dist/src/middleware/__tests__/middleware-interrupts.test.d.ts.map +0 -1
- package/dist/src/middleware/__tests__/middleware-interrupts.test.js +0 -267
- package/dist/src/middleware/__tests__/middleware-interrupts.test.js.map +0 -1
- package/dist/src/middleware/__tests__/registry.test.d.ts +0 -2
- package/dist/src/middleware/__tests__/registry.test.d.ts.map +0 -1
- package/dist/src/middleware/__tests__/registry.test.js +0 -525
- package/dist/src/middleware/__tests__/registry.test.js.map +0 -1
- package/dist/src/models/__tests__/anthropic.test.d.ts +0 -2
- package/dist/src/models/__tests__/anthropic.test.d.ts.map +0 -1
- package/dist/src/models/__tests__/anthropic.test.js +0 -793
- package/dist/src/models/__tests__/anthropic.test.js.map +0 -1
- package/dist/src/models/__tests__/bedrock.test.d.ts +0 -2
- package/dist/src/models/__tests__/bedrock.test.d.ts.map +0 -1
- package/dist/src/models/__tests__/bedrock.test.js +0 -3964
- package/dist/src/models/__tests__/bedrock.test.js.map +0 -1
- package/dist/src/models/__tests__/defaults.test.d.ts +0 -2
- package/dist/src/models/__tests__/defaults.test.d.ts.map +0 -1
- package/dist/src/models/__tests__/defaults.test.js +0 -36
- package/dist/src/models/__tests__/defaults.test.js.map +0 -1
- package/dist/src/models/__tests__/google.test.d.ts +0 -2
- package/dist/src/models/__tests__/google.test.d.ts.map +0 -1
- package/dist/src/models/__tests__/google.test.js +0 -1145
- package/dist/src/models/__tests__/google.test.js.map +0 -1
- package/dist/src/models/__tests__/model.test.d.ts +0 -2
- package/dist/src/models/__tests__/model.test.d.ts.map +0 -1
- package/dist/src/models/__tests__/model.test.js +0 -921
- package/dist/src/models/__tests__/model.test.js.map +0 -1
- package/dist/src/models/__tests__/streaming.test.d.ts +0 -2
- package/dist/src/models/__tests__/streaming.test.d.ts.map +0 -1
- package/dist/src/models/__tests__/streaming.test.js +0 -50
- package/dist/src/models/__tests__/streaming.test.js.map +0 -1
- package/dist/src/models/__tests__/test-utils.d.ts +0 -10
- package/dist/src/models/__tests__/test-utils.d.ts.map +0 -1
- package/dist/src/models/__tests__/test-utils.js +0 -17
- package/dist/src/models/__tests__/test-utils.js.map +0 -1
- package/dist/src/models/__tests__/vercel.test.d.ts +0 -2
- package/dist/src/models/__tests__/vercel.test.d.ts.map +0 -1
- package/dist/src/models/__tests__/vercel.test.js +0 -740
- package/dist/src/models/__tests__/vercel.test.js.map +0 -1
- package/dist/src/models/openai/__tests__/chat.test.d.ts +0 -2
- package/dist/src/models/openai/__tests__/chat.test.d.ts.map +0 -1
- package/dist/src/models/openai/__tests__/chat.test.js +0 -1586
- package/dist/src/models/openai/__tests__/chat.test.js.map +0 -1
- package/dist/src/models/openai/__tests__/errors.test.d.ts +0 -2
- package/dist/src/models/openai/__tests__/errors.test.d.ts.map +0 -1
- package/dist/src/models/openai/__tests__/errors.test.js +0 -39
- package/dist/src/models/openai/__tests__/errors.test.js.map +0 -1
- package/dist/src/models/openai/__tests__/mantle.test.d.ts +0 -2
- package/dist/src/models/openai/__tests__/mantle.test.d.ts.map +0 -1
- package/dist/src/models/openai/__tests__/mantle.test.js +0 -189
- package/dist/src/models/openai/__tests__/mantle.test.js.map +0 -1
- package/dist/src/models/openai/__tests__/responses.test.d.ts +0 -2
- package/dist/src/models/openai/__tests__/responses.test.d.ts.map +0 -1
- package/dist/src/models/openai/__tests__/responses.test.js +0 -709
- package/dist/src/models/openai/__tests__/responses.test.js.map +0 -1
- package/dist/src/multiagent/__tests__/events.test.d.ts +0 -2
- package/dist/src/multiagent/__tests__/events.test.d.ts.map +0 -1
- package/dist/src/multiagent/__tests__/events.test.js +0 -493
- package/dist/src/multiagent/__tests__/events.test.js.map +0 -1
- package/dist/src/multiagent/__tests__/graph.invocation-state.test.d.ts +0 -2
- package/dist/src/multiagent/__tests__/graph.invocation-state.test.d.ts.map +0 -1
- package/dist/src/multiagent/__tests__/graph.invocation-state.test.js +0 -95
- package/dist/src/multiagent/__tests__/graph.invocation-state.test.js.map +0 -1
- package/dist/src/multiagent/__tests__/graph.test.d.ts +0 -2
- package/dist/src/multiagent/__tests__/graph.test.d.ts.map +0 -1
- package/dist/src/multiagent/__tests__/graph.test.js +0 -698
- package/dist/src/multiagent/__tests__/graph.test.js.map +0 -1
- package/dist/src/multiagent/__tests__/graph.tracer.test.d.ts +0 -2
- package/dist/src/multiagent/__tests__/graph.tracer.test.d.ts.map +0 -1
- package/dist/src/multiagent/__tests__/graph.tracer.test.js +0 -218
- package/dist/src/multiagent/__tests__/graph.tracer.test.js.map +0 -1
- package/dist/src/multiagent/__tests__/interrupts.test.d.ts +0 -2
- package/dist/src/multiagent/__tests__/interrupts.test.d.ts.map +0 -1
- package/dist/src/multiagent/__tests__/interrupts.test.js +0 -390
- package/dist/src/multiagent/__tests__/interrupts.test.js.map +0 -1
- package/dist/src/multiagent/__tests__/nodes.test.d.ts +0 -2
- package/dist/src/multiagent/__tests__/nodes.test.d.ts.map +0 -1
- package/dist/src/multiagent/__tests__/nodes.test.js +0 -321
- package/dist/src/multiagent/__tests__/nodes.test.js.map +0 -1
- package/dist/src/multiagent/__tests__/queue.test.d.ts +0 -2
- package/dist/src/multiagent/__tests__/queue.test.d.ts.map +0 -1
- package/dist/src/multiagent/__tests__/queue.test.js +0 -118
- package/dist/src/multiagent/__tests__/queue.test.js.map +0 -1
- package/dist/src/multiagent/__tests__/snapshot.test.d.ts +0 -2
- package/dist/src/multiagent/__tests__/snapshot.test.d.ts.map +0 -1
- package/dist/src/multiagent/__tests__/snapshot.test.js +0 -161
- package/dist/src/multiagent/__tests__/snapshot.test.js.map +0 -1
- package/dist/src/multiagent/__tests__/state.test.d.ts +0 -2
- package/dist/src/multiagent/__tests__/state.test.d.ts.map +0 -1
- package/dist/src/multiagent/__tests__/state.test.js +0 -526
- package/dist/src/multiagent/__tests__/state.test.js.map +0 -1
- package/dist/src/multiagent/__tests__/swarm.invocation-state.test.d.ts +0 -2
- package/dist/src/multiagent/__tests__/swarm.invocation-state.test.d.ts.map +0 -1
- package/dist/src/multiagent/__tests__/swarm.invocation-state.test.js +0 -56
- package/dist/src/multiagent/__tests__/swarm.invocation-state.test.js.map +0 -1
- package/dist/src/multiagent/__tests__/swarm.test.d.ts +0 -2
- package/dist/src/multiagent/__tests__/swarm.test.d.ts.map +0 -1
- package/dist/src/multiagent/__tests__/swarm.test.js +0 -477
- package/dist/src/multiagent/__tests__/swarm.test.js.map +0 -1
- package/dist/src/multiagent/__tests__/swarm.tracer.test.d.ts +0 -2
- package/dist/src/multiagent/__tests__/swarm.tracer.test.d.ts.map +0 -1
- package/dist/src/multiagent/__tests__/swarm.tracer.test.js +0 -235
- package/dist/src/multiagent/__tests__/swarm.tracer.test.js.map +0 -1
- package/dist/src/plugins/__tests__/plugin.test.d.ts +0 -2
- package/dist/src/plugins/__tests__/plugin.test.d.ts.map +0 -1
- package/dist/src/plugins/__tests__/plugin.test.js +0 -114
- package/dist/src/plugins/__tests__/plugin.test.js.map +0 -1
- package/dist/src/plugins/__tests__/registry.test.d.ts +0 -2
- package/dist/src/plugins/__tests__/registry.test.d.ts.map +0 -1
- package/dist/src/plugins/__tests__/registry.test.js +0 -147
- package/dist/src/plugins/__tests__/registry.test.js.map +0 -1
- package/dist/src/registry/__tests__/tool-registry.test.d.ts +0 -2
- package/dist/src/registry/__tests__/tool-registry.test.d.ts.map +0 -1
- package/dist/src/registry/__tests__/tool-registry.test.js +0 -210
- package/dist/src/registry/__tests__/tool-registry.test.js.map +0 -1
- package/dist/src/retry/__tests__/backoff-strategy.test.d.ts +0 -2
- package/dist/src/retry/__tests__/backoff-strategy.test.d.ts.map +0 -1
- package/dist/src/retry/__tests__/backoff-strategy.test.js +0 -116
- package/dist/src/retry/__tests__/backoff-strategy.test.js.map +0 -1
- package/dist/src/retry/__tests__/default-model-retry-strategy.test.d.ts +0 -2
- package/dist/src/retry/__tests__/default-model-retry-strategy.test.d.ts.map +0 -1
- package/dist/src/retry/__tests__/default-model-retry-strategy.test.js +0 -225
- package/dist/src/retry/__tests__/default-model-retry-strategy.test.js.map +0 -1
- package/dist/src/sandbox/__tests__/default.test.browser.d.ts +0 -2
- package/dist/src/sandbox/__tests__/default.test.browser.d.ts.map +0 -1
- package/dist/src/sandbox/__tests__/default.test.browser.js +0 -11
- package/dist/src/sandbox/__tests__/default.test.browser.js.map +0 -1
- package/dist/src/sandbox/__tests__/default.test.node.d.ts +0 -2
- package/dist/src/sandbox/__tests__/default.test.node.d.ts.map +0 -1
- package/dist/src/sandbox/__tests__/default.test.node.js +0 -23
- package/dist/src/sandbox/__tests__/default.test.node.js.map +0 -1
- package/dist/src/sandbox/__tests__/docker.test.node.d.ts +0 -2
- package/dist/src/sandbox/__tests__/docker.test.node.d.ts.map +0 -1
- package/dist/src/sandbox/__tests__/docker.test.node.js +0 -89
- package/dist/src/sandbox/__tests__/docker.test.node.js.map +0 -1
- package/dist/src/sandbox/__tests__/errors.test.node.d.ts +0 -2
- package/dist/src/sandbox/__tests__/errors.test.node.d.ts.map +0 -1
- package/dist/src/sandbox/__tests__/errors.test.node.js +0 -33
- package/dist/src/sandbox/__tests__/errors.test.node.js.map +0 -1
- package/dist/src/sandbox/__tests__/not-a-sandbox-local-environment.test.node.d.ts +0 -2
- package/dist/src/sandbox/__tests__/not-a-sandbox-local-environment.test.node.d.ts.map +0 -1
- package/dist/src/sandbox/__tests__/not-a-sandbox-local-environment.test.node.js +0 -124
- package/dist/src/sandbox/__tests__/not-a-sandbox-local-environment.test.node.js.map +0 -1
- package/dist/src/sandbox/__tests__/posix-shell.test.node.d.ts +0 -2
- package/dist/src/sandbox/__tests__/posix-shell.test.node.d.ts.map +0 -1
- package/dist/src/sandbox/__tests__/posix-shell.test.node.js +0 -298
- package/dist/src/sandbox/__tests__/posix-shell.test.node.js.map +0 -1
- package/dist/src/sandbox/__tests__/ssh.test.node.d.ts +0 -2
- package/dist/src/sandbox/__tests__/ssh.test.node.d.ts.map +0 -1
- package/dist/src/sandbox/__tests__/ssh.test.node.js +0 -262
- package/dist/src/sandbox/__tests__/ssh.test.node.js.map +0 -1
- package/dist/src/session/__tests__/file-storage.test.node.d.ts +0 -2
- package/dist/src/session/__tests__/file-storage.test.node.d.ts.map +0 -1
- package/dist/src/session/__tests__/file-storage.test.node.js +0 -278
- package/dist/src/session/__tests__/file-storage.test.node.js.map +0 -1
- package/dist/src/session/__tests__/s3-storage.test.d.ts +0 -2
- package/dist/src/session/__tests__/s3-storage.test.d.ts.map +0 -1
- package/dist/src/session/__tests__/s3-storage.test.js +0 -461
- package/dist/src/session/__tests__/s3-storage.test.js.map +0 -1
- package/dist/src/session/__tests__/session-manager.test.d.ts +0 -2
- package/dist/src/session/__tests__/session-manager.test.d.ts.map +0 -1
- package/dist/src/session/__tests__/session-manager.test.js +0 -832
- package/dist/src/session/__tests__/session-manager.test.js.map +0 -1
- package/dist/src/session/__tests__/validation.test.d.ts +0 -2
- package/dist/src/session/__tests__/validation.test.d.ts.map +0 -1
- package/dist/src/session/__tests__/validation.test.js +0 -47
- package/dist/src/session/__tests__/validation.test.js.map +0 -1
- package/dist/src/telemetry/__tests__/config.test.d.ts +0 -2
- package/dist/src/telemetry/__tests__/config.test.d.ts.map +0 -1
- package/dist/src/telemetry/__tests__/config.test.js +0 -64
- package/dist/src/telemetry/__tests__/config.test.js.map +0 -1
- package/dist/src/telemetry/__tests__/config.test.node.d.ts +0 -2
- package/dist/src/telemetry/__tests__/config.test.node.d.ts.map +0 -1
- package/dist/src/telemetry/__tests__/config.test.node.js +0 -164
- package/dist/src/telemetry/__tests__/config.test.node.js.map +0 -1
- package/dist/src/telemetry/__tests__/json.test.d.ts +0 -2
- package/dist/src/telemetry/__tests__/json.test.d.ts.map +0 -1
- package/dist/src/telemetry/__tests__/json.test.js +0 -89
- package/dist/src/telemetry/__tests__/json.test.js.map +0 -1
- package/dist/src/telemetry/__tests__/local-trace.test.d.ts +0 -2
- package/dist/src/telemetry/__tests__/local-trace.test.d.ts.map +0 -1
- package/dist/src/telemetry/__tests__/local-trace.test.js +0 -158
- package/dist/src/telemetry/__tests__/local-trace.test.js.map +0 -1
- package/dist/src/telemetry/__tests__/meter.test.d.ts +0 -2
- package/dist/src/telemetry/__tests__/meter.test.d.ts.map +0 -1
- package/dist/src/telemetry/__tests__/meter.test.js +0 -695
- package/dist/src/telemetry/__tests__/meter.test.js.map +0 -1
- package/dist/src/telemetry/__tests__/tracer.test.node.d.ts +0 -2
- package/dist/src/telemetry/__tests__/tracer.test.node.d.ts.map +0 -1
- package/dist/src/telemetry/__tests__/tracer.test.node.js +0 -958
- package/dist/src/telemetry/__tests__/tracer.test.node.js.map +0 -1
- package/dist/src/tools/__tests__/structured-output-tool.test.d.ts +0 -2
- package/dist/src/tools/__tests__/structured-output-tool.test.d.ts.map +0 -1
- package/dist/src/tools/__tests__/structured-output-tool.test.js +0 -84
- package/dist/src/tools/__tests__/structured-output-tool.test.js.map +0 -1
- package/dist/src/tools/__tests__/tool-factory.test.d.ts +0 -2
- package/dist/src/tools/__tests__/tool-factory.test.d.ts.map +0 -1
- package/dist/src/tools/__tests__/tool-factory.test.js +0 -98
- package/dist/src/tools/__tests__/tool-factory.test.js.map +0 -1
- package/dist/src/tools/__tests__/tool.test.d.ts +0 -2
- package/dist/src/tools/__tests__/tool.test.d.ts.map +0 -1
- package/dist/src/tools/__tests__/tool.test.js +0 -1043
- package/dist/src/tools/__tests__/tool.test.js.map +0 -1
- package/dist/src/tools/__tests__/zod-tool.test-d.d.ts +0 -2
- package/dist/src/tools/__tests__/zod-tool.test-d.d.ts.map +0 -1
- package/dist/src/tools/__tests__/zod-tool.test-d.js +0 -227
- package/dist/src/tools/__tests__/zod-tool.test-d.js.map +0 -1
- package/dist/src/tools/__tests__/zod-tool.test.d.ts +0 -2
- package/dist/src/tools/__tests__/zod-tool.test.d.ts.map +0 -1
- package/dist/src/tools/__tests__/zod-tool.test.js +0 -563
- package/dist/src/tools/__tests__/zod-tool.test.js.map +0 -1
- package/dist/src/types/__tests__/agent.test.d.ts +0 -2
- package/dist/src/types/__tests__/agent.test.d.ts.map +0 -1
- package/dist/src/types/__tests__/agent.test.js +0 -476
- package/dist/src/types/__tests__/agent.test.js.map +0 -1
- package/dist/src/types/__tests__/citations.test.d.ts +0 -2
- package/dist/src/types/__tests__/citations.test.d.ts.map +0 -1
- package/dist/src/types/__tests__/citations.test.js +0 -104
- package/dist/src/types/__tests__/citations.test.js.map +0 -1
- package/dist/src/types/__tests__/json.test.d.ts +0 -2
- package/dist/src/types/__tests__/json.test.d.ts.map +0 -1
- package/dist/src/types/__tests__/json.test.js +0 -298
- package/dist/src/types/__tests__/json.test.js.map +0 -1
- package/dist/src/types/__tests__/media.test.d.ts +0 -2
- package/dist/src/types/__tests__/media.test.d.ts.map +0 -1
- package/dist/src/types/__tests__/media.test.js +0 -478
- package/dist/src/types/__tests__/media.test.js.map +0 -1
- package/dist/src/types/__tests__/messages.test.d.ts +0 -2
- package/dist/src/types/__tests__/messages.test.d.ts.map +0 -1
- package/dist/src/types/__tests__/messages.test.js +0 -681
- package/dist/src/types/__tests__/messages.test.js.map +0 -1
- package/dist/src/types/__tests__/validation.test.d.ts +0 -2
- package/dist/src/types/__tests__/validation.test.d.ts.map +0 -1
- package/dist/src/types/__tests__/validation.test.js +0 -30
- package/dist/src/types/__tests__/validation.test.js.map +0 -1
- package/dist/src/vended-interventions/cedar/__tests__/cedar.test.node.d.ts +0 -2
- package/dist/src/vended-interventions/cedar/__tests__/cedar.test.node.d.ts.map +0 -1
- package/dist/src/vended-interventions/cedar/__tests__/cedar.test.node.js +0 -756
- package/dist/src/vended-interventions/cedar/__tests__/cedar.test.node.js.map +0 -1
- package/dist/src/vended-interventions/hitl/__tests__/hitl.test.d.ts +0 -2
- package/dist/src/vended-interventions/hitl/__tests__/hitl.test.d.ts.map +0 -1
- package/dist/src/vended-interventions/hitl/__tests__/hitl.test.js +0 -358
- package/dist/src/vended-interventions/hitl/__tests__/hitl.test.js.map +0 -1
- package/dist/src/vended-interventions/steering/__tests__/handler.test.d.ts +0 -2
- package/dist/src/vended-interventions/steering/__tests__/handler.test.d.ts.map +0 -1
- package/dist/src/vended-interventions/steering/__tests__/handler.test.js +0 -163
- package/dist/src/vended-interventions/steering/__tests__/handler.test.js.map +0 -1
- package/dist/src/vended-interventions/steering/__tests__/llm.test.d.ts +0 -2
- package/dist/src/vended-interventions/steering/__tests__/llm.test.d.ts.map +0 -1
- package/dist/src/vended-interventions/steering/__tests__/llm.test.js +0 -60
- package/dist/src/vended-interventions/steering/__tests__/llm.test.js.map +0 -1
- package/dist/src/vended-interventions/steering/__tests__/tool-ledger.test.d.ts +0 -2
- package/dist/src/vended-interventions/steering/__tests__/tool-ledger.test.d.ts.map +0 -1
- package/dist/src/vended-interventions/steering/__tests__/tool-ledger.test.js +0 -94
- package/dist/src/vended-interventions/steering/__tests__/tool-ledger.test.js.map +0 -1
- package/dist/src/vended-memory-stores/bedrock-knowledge-base/__tests__/bedrock-knowledge-base-store.test.node.d.ts +0 -2
- package/dist/src/vended-memory-stores/bedrock-knowledge-base/__tests__/bedrock-knowledge-base-store.test.node.d.ts.map +0 -1
- package/dist/src/vended-memory-stores/bedrock-knowledge-base/__tests__/bedrock-knowledge-base-store.test.node.js +0 -758
- package/dist/src/vended-memory-stores/bedrock-knowledge-base/__tests__/bedrock-knowledge-base-store.test.node.js.map +0 -1
- package/dist/src/vended-plugins/context-injector/__tests__/plugin.test.d.ts +0 -2
- package/dist/src/vended-plugins/context-injector/__tests__/plugin.test.d.ts.map +0 -1
- package/dist/src/vended-plugins/context-injector/__tests__/plugin.test.js +0 -96
- package/dist/src/vended-plugins/context-injector/__tests__/plugin.test.js.map +0 -1
- package/dist/src/vended-plugins/context-offloader/__tests__/file-storage-sandbox.test.node.d.ts +0 -2
- package/dist/src/vended-plugins/context-offloader/__tests__/file-storage-sandbox.test.node.d.ts.map +0 -1
- package/dist/src/vended-plugins/context-offloader/__tests__/file-storage-sandbox.test.node.js +0 -68
- package/dist/src/vended-plugins/context-offloader/__tests__/file-storage-sandbox.test.node.js.map +0 -1
- package/dist/src/vended-plugins/context-offloader/__tests__/plugin.test.d.ts +0 -2
- package/dist/src/vended-plugins/context-offloader/__tests__/plugin.test.d.ts.map +0 -1
- package/dist/src/vended-plugins/context-offloader/__tests__/plugin.test.js +0 -539
- package/dist/src/vended-plugins/context-offloader/__tests__/plugin.test.js.map +0 -1
- package/dist/src/vended-plugins/context-offloader/__tests__/plugin.test.node.d.ts +0 -2
- package/dist/src/vended-plugins/context-offloader/__tests__/plugin.test.node.d.ts.map +0 -1
- package/dist/src/vended-plugins/context-offloader/__tests__/plugin.test.node.js +0 -97
- package/dist/src/vended-plugins/context-offloader/__tests__/plugin.test.node.js.map +0 -1
- package/dist/src/vended-plugins/context-offloader/__tests__/search.test.d.ts +0 -2
- package/dist/src/vended-plugins/context-offloader/__tests__/search.test.d.ts.map +0 -1
- package/dist/src/vended-plugins/context-offloader/__tests__/search.test.js +0 -149
- package/dist/src/vended-plugins/context-offloader/__tests__/search.test.js.map +0 -1
- package/dist/src/vended-plugins/context-offloader/__tests__/storage.test.d.ts +0 -2
- package/dist/src/vended-plugins/context-offloader/__tests__/storage.test.d.ts.map +0 -1
- package/dist/src/vended-plugins/context-offloader/__tests__/storage.test.js +0 -216
- package/dist/src/vended-plugins/context-offloader/__tests__/storage.test.js.map +0 -1
- package/dist/src/vended-plugins/context-offloader/__tests__/storage.test.node.d.ts +0 -2
- package/dist/src/vended-plugins/context-offloader/__tests__/storage.test.node.d.ts.map +0 -1
- package/dist/src/vended-plugins/context-offloader/__tests__/storage.test.node.js +0 -78
- package/dist/src/vended-plugins/context-offloader/__tests__/storage.test.node.js.map +0 -1
- package/dist/src/vended-plugins/goal/__tests__/plugin.test.d.ts +0 -2
- package/dist/src/vended-plugins/goal/__tests__/plugin.test.d.ts.map +0 -1
- package/dist/src/vended-plugins/goal/__tests__/plugin.test.js +0 -736
- package/dist/src/vended-plugins/goal/__tests__/plugin.test.js.map +0 -1
- package/dist/src/vended-plugins/skills/__tests__/agent-skills.test.node.d.ts +0 -2
- package/dist/src/vended-plugins/skills/__tests__/agent-skills.test.node.d.ts.map +0 -1
- package/dist/src/vended-plugins/skills/__tests__/agent-skills.test.node.js +0 -482
- package/dist/src/vended-plugins/skills/__tests__/agent-skills.test.node.js.map +0 -1
- package/dist/src/vended-plugins/skills/__tests__/skill.test.node.d.ts +0 -2
- package/dist/src/vended-plugins/skills/__tests__/skill.test.node.d.ts.map +0 -1
- package/dist/src/vended-plugins/skills/__tests__/skill.test.node.js +0 -476
- package/dist/src/vended-plugins/skills/__tests__/skill.test.node.js.map +0 -1
- package/dist/src/vended-tools/bash/__tests__/bash.test.node.d.ts +0 -2
- package/dist/src/vended-tools/bash/__tests__/bash.test.node.d.ts.map +0 -1
- package/dist/src/vended-tools/bash/__tests__/bash.test.node.js +0 -390
- package/dist/src/vended-tools/bash/__tests__/bash.test.node.js.map +0 -1
- package/dist/src/vended-tools/file-editor/__tests__/file-editor.test.node.d.ts +0 -2
- package/dist/src/vended-tools/file-editor/__tests__/file-editor.test.node.d.ts.map +0 -1
- package/dist/src/vended-tools/file-editor/__tests__/file-editor.test.node.js +0 -452
- package/dist/src/vended-tools/file-editor/__tests__/file-editor.test.node.js.map +0 -1
- package/dist/src/vended-tools/http-request/__tests__/http-request.test.d.ts +0 -2
- package/dist/src/vended-tools/http-request/__tests__/http-request.test.d.ts.map +0 -1
- package/dist/src/vended-tools/http-request/__tests__/http-request.test.js +0 -189
- package/dist/src/vended-tools/http-request/__tests__/http-request.test.js.map +0 -1
- package/dist/src/vended-tools/notebook/__tests__/notebook.test.d.ts +0 -2
- package/dist/src/vended-tools/notebook/__tests__/notebook.test.d.ts.map +0 -1
- package/dist/src/vended-tools/notebook/__tests__/notebook.test.js +0 -388
- package/dist/src/vended-tools/notebook/__tests__/notebook.test.js.map +0 -1
|
@@ -1,1003 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
|
|
2
|
-
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
|
|
3
|
-
import { McpError, ErrorCode, ElicitRequestSchema, UrlElicitationRequiredError, } from '@modelcontextprotocol/sdk/types.js';
|
|
4
|
-
import { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/streamableHttp.js';
|
|
5
|
-
import { ClientCredentialsProvider } from '@modelcontextprotocol/sdk/client/auth-extensions.js';
|
|
6
|
-
import { McpClient } from '../mcp.js';
|
|
7
|
-
import { McpTool } from '../tools/mcp-tool.js';
|
|
8
|
-
import { JsonBlock } from '../types/messages.js';
|
|
9
|
-
import { ImageBlock } from '../types/media.js';
|
|
10
|
-
import { context, propagation, trace, TraceFlags } from '@opentelemetry/api';
|
|
11
|
-
import { logger } from '../logging/index.js';
|
|
12
|
-
/**
|
|
13
|
-
* Helper to create a mock async generator that yields a result message.
|
|
14
|
-
* This simulates the behavior of callToolStream returning a stream that ends with a result.
|
|
15
|
-
*/
|
|
16
|
-
function createMockCallToolStream(result) {
|
|
17
|
-
return async function* () {
|
|
18
|
-
yield { type: 'result', result };
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
vi.mock('@modelcontextprotocol/sdk/client/streamableHttp.js', () => ({
|
|
22
|
-
StreamableHTTPClientTransport: vi.fn(function () {
|
|
23
|
-
return { start: vi.fn(), send: vi.fn(), close: vi.fn() };
|
|
24
|
-
}),
|
|
25
|
-
}));
|
|
26
|
-
vi.mock('@modelcontextprotocol/sdk/client/auth-extensions.js', () => ({
|
|
27
|
-
ClientCredentialsProvider: vi.fn(function () {
|
|
28
|
-
return { redirectUrl: undefined, clientMetadata: { client_id: 'test' } };
|
|
29
|
-
}),
|
|
30
|
-
}));
|
|
31
|
-
vi.mock('@modelcontextprotocol/sdk/client/index.js', () => ({
|
|
32
|
-
Client: vi.fn(function () {
|
|
33
|
-
return {
|
|
34
|
-
connect: vi.fn(),
|
|
35
|
-
close: vi.fn(),
|
|
36
|
-
listTools: vi.fn(),
|
|
37
|
-
callTool: vi.fn(),
|
|
38
|
-
setRequestHandler: vi.fn(),
|
|
39
|
-
setNotificationHandler: vi.fn(),
|
|
40
|
-
getServerCapabilities: vi.fn(),
|
|
41
|
-
getServerVersion: vi.fn(),
|
|
42
|
-
getInstructions: vi.fn(),
|
|
43
|
-
experimental: {
|
|
44
|
-
tasks: {
|
|
45
|
-
callToolStream: vi.fn(),
|
|
46
|
-
},
|
|
47
|
-
},
|
|
48
|
-
};
|
|
49
|
-
}),
|
|
50
|
-
}));
|
|
51
|
-
vi.mock('../tools/tool.js', () => ({
|
|
52
|
-
Tool: class {
|
|
53
|
-
},
|
|
54
|
-
createErrorResult: (err, toolUseId) => ({
|
|
55
|
-
type: 'toolResultBlock',
|
|
56
|
-
status: 'error',
|
|
57
|
-
toolUseId,
|
|
58
|
-
content: [{ type: 'textBlock', text: err instanceof Error ? err.message : String(err) }],
|
|
59
|
-
}),
|
|
60
|
-
}));
|
|
61
|
-
/**
|
|
62
|
-
* Executes a tool stream to completion and returns the final result.
|
|
63
|
-
*/
|
|
64
|
-
async function runTool(gen) {
|
|
65
|
-
let result = await gen.next();
|
|
66
|
-
while (!result.done) {
|
|
67
|
-
result = await gen.next();
|
|
68
|
-
}
|
|
69
|
-
return result.value;
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Mock an active span with a valid trace ID via trace.getSpan,
|
|
73
|
-
* and stub propagation.inject to populate the carrier with a traceparent.
|
|
74
|
-
*/
|
|
75
|
-
function mockActiveSpan(traceId = '1234567890abcdef1234567890abcdef', traceFlags = TraceFlags.SAMPLED) {
|
|
76
|
-
const mockSpan = {
|
|
77
|
-
spanContext: () => ({
|
|
78
|
-
traceId,
|
|
79
|
-
spanId: '1234567890abcdef',
|
|
80
|
-
traceFlags,
|
|
81
|
-
}),
|
|
82
|
-
};
|
|
83
|
-
vi.spyOn(trace, 'getSpan').mockReturnValue(mockSpan);
|
|
84
|
-
vi.spyOn(propagation, 'inject').mockImplementation((_context, carrier) => {
|
|
85
|
-
if (carrier && typeof carrier === 'object') {
|
|
86
|
-
;
|
|
87
|
-
carrier.traceparent = `00-${traceId}-1234567890abcdef-01`;
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
const mockTransport = {
|
|
92
|
-
connect: vi.fn(),
|
|
93
|
-
close: vi.fn(),
|
|
94
|
-
send: vi.fn(),
|
|
95
|
-
};
|
|
96
|
-
describe('MCP Integration', () => {
|
|
97
|
-
beforeEach(() => {
|
|
98
|
-
vi.clearAllMocks();
|
|
99
|
-
});
|
|
100
|
-
afterEach(() => {
|
|
101
|
-
vi.restoreAllMocks();
|
|
102
|
-
});
|
|
103
|
-
function createElicitationClient(callback) {
|
|
104
|
-
const resultsLengthBefore = vi.mocked(Client).mock.results.length;
|
|
105
|
-
const elicitClient = new McpClient({
|
|
106
|
-
applicationName: 'TestApp',
|
|
107
|
-
transport: mockTransport,
|
|
108
|
-
elicitationCallback: callback,
|
|
109
|
-
});
|
|
110
|
-
const elicitSdkClientMock = vi.mocked(Client).mock.results[resultsLengthBefore].value;
|
|
111
|
-
return { elicitClient, elicitSdkClientMock };
|
|
112
|
-
}
|
|
113
|
-
async function connectAndGetElicitationHandler(callback) {
|
|
114
|
-
const { elicitClient, elicitSdkClientMock } = createElicitationClient(callback);
|
|
115
|
-
await elicitClient.connect();
|
|
116
|
-
const handler = elicitSdkClientMock.setRequestHandler.mock.calls[0][1];
|
|
117
|
-
return { handler, elicitSdkClientMock };
|
|
118
|
-
}
|
|
119
|
-
describe('McpClient', () => {
|
|
120
|
-
let client;
|
|
121
|
-
let sdkClientMock;
|
|
122
|
-
beforeEach(() => {
|
|
123
|
-
client = new McpClient({
|
|
124
|
-
applicationName: 'TestApp',
|
|
125
|
-
transport: mockTransport,
|
|
126
|
-
});
|
|
127
|
-
sdkClientMock = vi.mocked(Client).mock.results[0].value;
|
|
128
|
-
});
|
|
129
|
-
it('initializes SDK client with correct configuration', () => {
|
|
130
|
-
expect(Client).toHaveBeenCalledWith({ name: 'TestApp', version: '0.0.1' }, expect.objectContaining({
|
|
131
|
-
listChanged: expect.objectContaining({
|
|
132
|
-
tools: expect.objectContaining({ autoRefresh: false, debounceMs: 300 }),
|
|
133
|
-
}),
|
|
134
|
-
}));
|
|
135
|
-
});
|
|
136
|
-
it('injects trace context into tool arguments when active span exists', async () => {
|
|
137
|
-
mockActiveSpan();
|
|
138
|
-
const tool = new McpTool({ name: 'calc', description: '', inputSchema: {}, client });
|
|
139
|
-
sdkClientMock.callTool.mockResolvedValue({ content: [] });
|
|
140
|
-
await client.callTool(tool, { op: 'add' });
|
|
141
|
-
const callArgs = sdkClientMock.callTool.mock.calls[0][0];
|
|
142
|
-
expect(callArgs.arguments).toStrictEqual({
|
|
143
|
-
op: 'add',
|
|
144
|
-
_meta: { traceparent: '00-1234567890abcdef1234567890abcdef-1234567890abcdef-01' },
|
|
145
|
-
});
|
|
146
|
-
});
|
|
147
|
-
it('merges trace context with existing _meta field', async () => {
|
|
148
|
-
mockActiveSpan();
|
|
149
|
-
const tool = new McpTool({ name: 'calc', description: '', inputSchema: {}, client });
|
|
150
|
-
sdkClientMock.callTool.mockResolvedValue({ content: [] });
|
|
151
|
-
await client.callTool(tool, { op: 'add', _meta: { progressToken: 'tok-1' } });
|
|
152
|
-
const callArgs = sdkClientMock.callTool.mock.calls[0][0];
|
|
153
|
-
expect(callArgs.arguments).toStrictEqual({
|
|
154
|
-
op: 'add',
|
|
155
|
-
_meta: {
|
|
156
|
-
progressToken: 'tok-1',
|
|
157
|
-
traceparent: '00-1234567890abcdef1234567890abcdef-1234567890abcdef-01',
|
|
158
|
-
},
|
|
159
|
-
});
|
|
160
|
-
});
|
|
161
|
-
it('passes args unchanged when no active span exists', async () => {
|
|
162
|
-
const tool = new McpTool({ name: 'calc', description: '', inputSchema: {}, client });
|
|
163
|
-
sdkClientMock.callTool.mockResolvedValue({ content: [] });
|
|
164
|
-
await client.callTool(tool, { op: 'add' });
|
|
165
|
-
const callArgs = sdkClientMock.callTool.mock.calls[0][0];
|
|
166
|
-
expect(callArgs.arguments).toStrictEqual({ op: 'add' });
|
|
167
|
-
});
|
|
168
|
-
it('passes args unchanged when span has empty trace ID', async () => {
|
|
169
|
-
mockActiveSpan('', TraceFlags.NONE);
|
|
170
|
-
const tool = new McpTool({ name: 'calc', description: '', inputSchema: {}, client });
|
|
171
|
-
sdkClientMock.callTool.mockResolvedValue({ content: [] });
|
|
172
|
-
await client.callTool(tool, { op: 'add' });
|
|
173
|
-
const callArgs = sdkClientMock.callTool.mock.calls[0][0];
|
|
174
|
-
expect(callArgs.arguments).toStrictEqual({ op: 'add' });
|
|
175
|
-
});
|
|
176
|
-
it('passes args unchanged when context injection fails', async () => {
|
|
177
|
-
vi.spyOn(context, 'active').mockImplementation(() => {
|
|
178
|
-
throw new Error('Context error');
|
|
179
|
-
});
|
|
180
|
-
const tool = new McpTool({ name: 'calc', description: '', inputSchema: {}, client });
|
|
181
|
-
sdkClientMock.callTool.mockResolvedValue({ content: [] });
|
|
182
|
-
await client.callTool(tool, { op: 'add' });
|
|
183
|
-
const callArgs = sdkClientMock.callTool.mock.calls[0][0];
|
|
184
|
-
expect(callArgs.arguments).toStrictEqual({ op: 'add' });
|
|
185
|
-
});
|
|
186
|
-
it('skips trace context injection when disableMcpInstrumentation is true', async () => {
|
|
187
|
-
mockActiveSpan();
|
|
188
|
-
const noInstrClient = new McpClient({
|
|
189
|
-
applicationName: 'TestApp',
|
|
190
|
-
transport: mockTransport,
|
|
191
|
-
disableMcpInstrumentation: true,
|
|
192
|
-
});
|
|
193
|
-
const noInstrSdkMock = vi.mocked(Client).mock.results.at(-1).value;
|
|
194
|
-
noInstrSdkMock.callTool.mockResolvedValue({ content: [] });
|
|
195
|
-
const tool = new McpTool({ name: 'calc', description: '', inputSchema: {}, client: noInstrClient });
|
|
196
|
-
await noInstrClient.callTool(tool, { op: 'add' });
|
|
197
|
-
const callArgs = noInstrSdkMock.callTool.mock.calls[0][0];
|
|
198
|
-
expect(callArgs.arguments).toStrictEqual({ op: 'add' });
|
|
199
|
-
});
|
|
200
|
-
it('manages connection state lazily', async () => {
|
|
201
|
-
await client.connect();
|
|
202
|
-
expect(sdkClientMock.connect).toHaveBeenCalledTimes(1);
|
|
203
|
-
await client.connect();
|
|
204
|
-
expect(sdkClientMock.connect).toHaveBeenCalledTimes(1);
|
|
205
|
-
});
|
|
206
|
-
it('supports forced reconnection', async () => {
|
|
207
|
-
await client.connect();
|
|
208
|
-
await client.connect(true);
|
|
209
|
-
expect(sdkClientMock.close).toHaveBeenCalled();
|
|
210
|
-
expect(sdkClientMock.connect).toHaveBeenCalledTimes(2);
|
|
211
|
-
});
|
|
212
|
-
it('converts SDK tool specs to McpTool instances', async () => {
|
|
213
|
-
sdkClientMock.listTools.mockResolvedValue({
|
|
214
|
-
tools: [{ name: 'weather', description: 'Get weather', inputSchema: {} }],
|
|
215
|
-
});
|
|
216
|
-
const tools = await client.listTools();
|
|
217
|
-
expect(sdkClientMock.connect).toHaveBeenCalled();
|
|
218
|
-
expect(tools).toHaveLength(1);
|
|
219
|
-
expect(tools[0]).toBeInstanceOf(McpTool);
|
|
220
|
-
expect(tools[0].name).toBe('weather');
|
|
221
|
-
});
|
|
222
|
-
it('paginates through all pages of tools', async () => {
|
|
223
|
-
sdkClientMock.listTools
|
|
224
|
-
.mockResolvedValueOnce({
|
|
225
|
-
tools: [{ name: 'tool_a', description: 'A', inputSchema: {} }],
|
|
226
|
-
nextCursor: 'page2',
|
|
227
|
-
})
|
|
228
|
-
.mockResolvedValueOnce({
|
|
229
|
-
tools: [{ name: 'tool_b', description: 'B', inputSchema: {} }],
|
|
230
|
-
nextCursor: 'page3',
|
|
231
|
-
})
|
|
232
|
-
.mockResolvedValueOnce({
|
|
233
|
-
tools: [{ name: 'tool_c', description: 'C', inputSchema: {} }],
|
|
234
|
-
});
|
|
235
|
-
const tools = await client.listTools();
|
|
236
|
-
expect(tools).toHaveLength(3);
|
|
237
|
-
expect(tools.map((t) => t.name)).toEqual(['tool_a', 'tool_b', 'tool_c']);
|
|
238
|
-
expect(sdkClientMock.listTools).toHaveBeenCalledTimes(3);
|
|
239
|
-
expect(sdkClientMock.listTools).toHaveBeenNthCalledWith(1, undefined);
|
|
240
|
-
expect(sdkClientMock.listTools).toHaveBeenNthCalledWith(2, { cursor: 'page2' });
|
|
241
|
-
expect(sdkClientMock.listTools).toHaveBeenNthCalledWith(3, { cursor: 'page3' });
|
|
242
|
-
});
|
|
243
|
-
it('generates description fallback when description is missing', async () => {
|
|
244
|
-
sdkClientMock.listTools.mockResolvedValue({
|
|
245
|
-
tools: [{ name: 'my_tool', inputSchema: {} }],
|
|
246
|
-
});
|
|
247
|
-
const tools = await client.listTools();
|
|
248
|
-
expect(tools[0].description).toBe('Tool which performs my_tool');
|
|
249
|
-
});
|
|
250
|
-
it('generates description fallback when description is empty string', async () => {
|
|
251
|
-
sdkClientMock.listTools.mockResolvedValue({
|
|
252
|
-
tools: [{ name: 'my_tool', description: '', inputSchema: {} }],
|
|
253
|
-
});
|
|
254
|
-
const tools = await client.listTools();
|
|
255
|
-
expect(tools[0].description).toBe('Tool which performs my_tool');
|
|
256
|
-
});
|
|
257
|
-
it('uses callTool when tasksConfig is undefined (default)', async () => {
|
|
258
|
-
const tool = new McpTool({ name: 'calc', description: '', inputSchema: {}, client });
|
|
259
|
-
sdkClientMock.callTool.mockResolvedValue({ content: [] });
|
|
260
|
-
await client.callTool(tool, { op: 'add' });
|
|
261
|
-
expect(sdkClientMock.connect).toHaveBeenCalled();
|
|
262
|
-
expect(sdkClientMock.callTool).toHaveBeenCalledWith({ name: 'calc', arguments: { op: 'add' } }, undefined, undefined);
|
|
263
|
-
expect(sdkClientMock.experimental.tasks.callToolStream).not.toHaveBeenCalled();
|
|
264
|
-
});
|
|
265
|
-
it('forwards abort signal to SDK callTool', async () => {
|
|
266
|
-
const tool = new McpTool({ name: 'calc', description: '', inputSchema: {}, client });
|
|
267
|
-
sdkClientMock.callTool.mockResolvedValue({ content: [] });
|
|
268
|
-
const controller = new AbortController();
|
|
269
|
-
await client.callTool(tool, { op: 'add' }, { signal: controller.signal });
|
|
270
|
-
expect(sdkClientMock.callTool).toHaveBeenCalledWith({ name: 'calc', arguments: { op: 'add' } }, undefined, {
|
|
271
|
-
signal: controller.signal,
|
|
272
|
-
});
|
|
273
|
-
});
|
|
274
|
-
it('forwards abort signal to callToolStream when tasksConfig is provided', async () => {
|
|
275
|
-
const resultsLengthBefore = vi.mocked(Client).mock.results.length;
|
|
276
|
-
const taskClient = new McpClient({
|
|
277
|
-
applicationName: 'TestApp',
|
|
278
|
-
transport: mockTransport,
|
|
279
|
-
tasksConfig: {},
|
|
280
|
-
});
|
|
281
|
-
const taskSdkClientMock = vi.mocked(Client).mock.results[resultsLengthBefore].value;
|
|
282
|
-
const tool = new McpTool({ name: 'calc', description: '', inputSchema: {}, client: taskClient });
|
|
283
|
-
taskSdkClientMock.experimental.tasks.callToolStream.mockReturnValue(createMockCallToolStream({ content: [] })());
|
|
284
|
-
const controller = new AbortController();
|
|
285
|
-
await taskClient.callTool(tool, { op: 'add' }, { signal: controller.signal });
|
|
286
|
-
expect(taskSdkClientMock.experimental.tasks.callToolStream).toHaveBeenCalledWith({ name: 'calc', arguments: { op: 'add' } }, undefined, { timeout: 60000, maxTotalTimeout: 300000, resetTimeoutOnProgress: true, signal: controller.signal });
|
|
287
|
-
});
|
|
288
|
-
it('uses callToolStream when tasksConfig is provided (empty object)', async () => {
|
|
289
|
-
const resultsLengthBefore = vi.mocked(Client).mock.results.length;
|
|
290
|
-
const taskClient = new McpClient({
|
|
291
|
-
applicationName: 'TestApp',
|
|
292
|
-
transport: mockTransport,
|
|
293
|
-
tasksConfig: {},
|
|
294
|
-
});
|
|
295
|
-
const taskSdkClientMock = vi.mocked(Client).mock.results[resultsLengthBefore].value;
|
|
296
|
-
const tool = new McpTool({ name: 'calc', description: '', inputSchema: {}, client: taskClient });
|
|
297
|
-
taskSdkClientMock.experimental.tasks.callToolStream.mockReturnValue(createMockCallToolStream({ content: [] })());
|
|
298
|
-
await taskClient.callTool(tool, { op: 'add' });
|
|
299
|
-
expect(taskSdkClientMock.connect).toHaveBeenCalled();
|
|
300
|
-
expect(taskSdkClientMock.experimental.tasks.callToolStream).toHaveBeenCalledWith({ name: 'calc', arguments: { op: 'add' } }, undefined, { timeout: 60000, maxTotalTimeout: 300000, resetTimeoutOnProgress: true });
|
|
301
|
-
expect(taskSdkClientMock.callTool).not.toHaveBeenCalled();
|
|
302
|
-
});
|
|
303
|
-
it('passes custom TTL and pollTimeout to callToolStream', async () => {
|
|
304
|
-
const resultsLengthBefore = vi.mocked(Client).mock.results.length;
|
|
305
|
-
const taskClient = new McpClient({
|
|
306
|
-
applicationName: 'TestApp',
|
|
307
|
-
transport: mockTransport,
|
|
308
|
-
tasksConfig: { ttl: 30000, pollTimeout: 120000 },
|
|
309
|
-
});
|
|
310
|
-
const taskSdkClientMock = vi.mocked(Client).mock.results[resultsLengthBefore].value;
|
|
311
|
-
const tool = new McpTool({ name: 'calc', description: '', inputSchema: {}, client: taskClient });
|
|
312
|
-
taskSdkClientMock.experimental.tasks.callToolStream.mockReturnValue(createMockCallToolStream({ content: [] })());
|
|
313
|
-
await taskClient.callTool(tool, { op: 'add' });
|
|
314
|
-
expect(taskSdkClientMock.experimental.tasks.callToolStream).toHaveBeenCalledWith({ name: 'calc', arguments: { op: 'add' } }, undefined, { timeout: 30000, maxTotalTimeout: 120000, resetTimeoutOnProgress: true });
|
|
315
|
-
});
|
|
316
|
-
it('validates tool arguments', async () => {
|
|
317
|
-
const tool = new McpTool({ name: 't', description: '', inputSchema: {}, client });
|
|
318
|
-
await expect(client.callTool(tool, ['invalid-array'])).rejects.toThrow(/JSON Object/);
|
|
319
|
-
});
|
|
320
|
-
it('cleans up resources', async () => {
|
|
321
|
-
await client.disconnect();
|
|
322
|
-
expect(sdkClientMock.close).toHaveBeenCalled();
|
|
323
|
-
expect(mockTransport.close).toHaveBeenCalled();
|
|
324
|
-
});
|
|
325
|
-
it('supports Symbol.asyncDispose for await using pattern', async () => {
|
|
326
|
-
await client[Symbol.asyncDispose]();
|
|
327
|
-
expect(sdkClientMock.close).toHaveBeenCalled();
|
|
328
|
-
expect(mockTransport.close).toHaveBeenCalled();
|
|
329
|
-
});
|
|
330
|
-
it('registers elicitation handler before connecting when callback is provided', async () => {
|
|
331
|
-
const resultsLengthBefore = vi.mocked(Client).mock.results.length;
|
|
332
|
-
const callback = vi.fn();
|
|
333
|
-
const elicitClient = new McpClient({
|
|
334
|
-
applicationName: 'TestApp',
|
|
335
|
-
transport: mockTransport,
|
|
336
|
-
elicitationCallback: callback,
|
|
337
|
-
});
|
|
338
|
-
const elicitSdkClientMock = vi.mocked(Client).mock.results[resultsLengthBefore].value;
|
|
339
|
-
await elicitClient.connect();
|
|
340
|
-
expect(elicitSdkClientMock.setRequestHandler).toHaveBeenCalledWith(ElicitRequestSchema, expect.any(Function));
|
|
341
|
-
const setHandlerOrder = elicitSdkClientMock.setRequestHandler.mock.invocationCallOrder[0];
|
|
342
|
-
const connectOrder = elicitSdkClientMock.connect.mock.invocationCallOrder[0];
|
|
343
|
-
expect(setHandlerOrder).toBeLessThan(connectOrder);
|
|
344
|
-
});
|
|
345
|
-
it('does not register elicitation handler when no callback is provided', async () => {
|
|
346
|
-
await client.connect();
|
|
347
|
-
expect(sdkClientMock.setRequestHandler).not.toHaveBeenCalled();
|
|
348
|
-
});
|
|
349
|
-
it('passes elicitation capabilities to Client when callback is provided', () => {
|
|
350
|
-
const callback = vi.fn();
|
|
351
|
-
new McpClient({
|
|
352
|
-
applicationName: 'TestApp',
|
|
353
|
-
transport: mockTransport,
|
|
354
|
-
elicitationCallback: callback,
|
|
355
|
-
});
|
|
356
|
-
const lastCall = vi.mocked(Client).mock.calls.at(-1);
|
|
357
|
-
expect(lastCall[1]).toEqual(expect.objectContaining({ capabilities: { elicitation: { form: {}, url: {} } } }));
|
|
358
|
-
});
|
|
359
|
-
it('elicitation handler returns accepted result with content', async () => {
|
|
360
|
-
const callbackResult = { action: 'accept', content: { username: 'alice' } };
|
|
361
|
-
const callback = vi.fn().mockResolvedValue(callbackResult);
|
|
362
|
-
const { handler } = await connectAndGetElicitationHandler(callback);
|
|
363
|
-
const request = {
|
|
364
|
-
method: 'elicitation/create',
|
|
365
|
-
params: { message: 'Enter username', requestedSchema: { type: 'object' } },
|
|
366
|
-
};
|
|
367
|
-
const extra = { signal: new AbortController().signal };
|
|
368
|
-
const result = await handler(request, extra);
|
|
369
|
-
expect(callback).toHaveBeenCalledWith(extra, request.params);
|
|
370
|
-
expect(result).toEqual({ action: 'accept', content: { username: 'alice' } });
|
|
371
|
-
});
|
|
372
|
-
it.each([{ action: 'decline' }, { action: 'cancel' }])('elicitation handler returns $action result', async (callbackResult) => {
|
|
373
|
-
const callback = vi.fn().mockResolvedValue(callbackResult);
|
|
374
|
-
const { handler } = await connectAndGetElicitationHandler(callback);
|
|
375
|
-
const request = {
|
|
376
|
-
method: 'elicitation/create',
|
|
377
|
-
params: { message: 'Enter username', requestedSchema: { type: 'object' } },
|
|
378
|
-
};
|
|
379
|
-
const extra = { signal: new AbortController().signal };
|
|
380
|
-
const result = await handler(request, extra);
|
|
381
|
-
expect(callback).toHaveBeenCalledWith(extra, request.params);
|
|
382
|
-
expect(result).toEqual({ action: callbackResult.action });
|
|
383
|
-
});
|
|
384
|
-
it('elicitation handler works for URL mode params', async () => {
|
|
385
|
-
const callbackResult = { action: 'accept' };
|
|
386
|
-
const callback = vi.fn().mockResolvedValue(callbackResult);
|
|
387
|
-
const { handler } = await connectAndGetElicitationHandler(callback);
|
|
388
|
-
const request = {
|
|
389
|
-
method: 'elicitation/create',
|
|
390
|
-
params: {
|
|
391
|
-
mode: 'url',
|
|
392
|
-
message: 'Please authenticate',
|
|
393
|
-
url: 'https://example.com/auth',
|
|
394
|
-
elicitationId: 'elicit-123',
|
|
395
|
-
},
|
|
396
|
-
};
|
|
397
|
-
const extra = { signal: new AbortController().signal };
|
|
398
|
-
const result = await handler(request, extra);
|
|
399
|
-
expect(callback).toHaveBeenCalledWith(extra, request.params);
|
|
400
|
-
expect(result).toEqual({ action: 'accept' });
|
|
401
|
-
});
|
|
402
|
-
it('elicitation callback errors propagate', async () => {
|
|
403
|
-
const callback = vi.fn().mockRejectedValue(new Error('User cancelled'));
|
|
404
|
-
const { handler } = await connectAndGetElicitationHandler(callback);
|
|
405
|
-
const request = {
|
|
406
|
-
method: 'elicitation/create',
|
|
407
|
-
params: { message: 'Confirm?' },
|
|
408
|
-
};
|
|
409
|
-
const extra = { signal: new AbortController().signal };
|
|
410
|
-
await expect(handler(request, extra)).rejects.toThrow('User cancelled');
|
|
411
|
-
});
|
|
412
|
-
});
|
|
413
|
-
describe('tools list changed', () => {
|
|
414
|
-
let client;
|
|
415
|
-
let sdkClientMock;
|
|
416
|
-
beforeEach(() => {
|
|
417
|
-
client = new McpClient({ applicationName: 'TestApp', transport: mockTransport });
|
|
418
|
-
sdkClientMock = vi.mocked(Client).mock.results.at(-1).value;
|
|
419
|
-
sdkClientMock.connect.mockResolvedValue(undefined);
|
|
420
|
-
});
|
|
421
|
-
function triggerToolsChanged() {
|
|
422
|
-
const ctorCall = vi.mocked(Client).mock.calls.at(-1);
|
|
423
|
-
ctorCall[1].listChanged.tools.onChanged(null, null);
|
|
424
|
-
}
|
|
425
|
-
it('calls onToolsChanged with old names and new tools when list changes', async () => {
|
|
426
|
-
sdkClientMock.listTools.mockResolvedValue({
|
|
427
|
-
tools: [{ name: 'tool_a', description: 'A', inputSchema: {} }],
|
|
428
|
-
});
|
|
429
|
-
await client.listTools();
|
|
430
|
-
const onToolsChanged = vi.fn();
|
|
431
|
-
client.onToolsChanged = onToolsChanged;
|
|
432
|
-
sdkClientMock.listTools.mockResolvedValue({
|
|
433
|
-
tools: [
|
|
434
|
-
{ name: 'tool_a', description: 'A', inputSchema: {} },
|
|
435
|
-
{ name: 'tool_b', description: 'B', inputSchema: {} },
|
|
436
|
-
],
|
|
437
|
-
});
|
|
438
|
-
triggerToolsChanged();
|
|
439
|
-
await vi.waitFor(() => expect(onToolsChanged).toHaveBeenCalled());
|
|
440
|
-
expect(onToolsChanged).toHaveBeenCalledWith(['tool_a'], expect.any(Array));
|
|
441
|
-
const newTools = onToolsChanged.mock.calls[0][1];
|
|
442
|
-
expect(newTools.map((t) => t.name)).toEqual(['tool_a', 'tool_b']);
|
|
443
|
-
});
|
|
444
|
-
it('updates registered tool names after each listTools call', async () => {
|
|
445
|
-
sdkClientMock.listTools.mockResolvedValue({
|
|
446
|
-
tools: [
|
|
447
|
-
{ name: 'x', description: 'X', inputSchema: {} },
|
|
448
|
-
{ name: 'y', description: 'Y', inputSchema: {} },
|
|
449
|
-
],
|
|
450
|
-
});
|
|
451
|
-
await client.listTools();
|
|
452
|
-
const onToolsChanged = vi.fn();
|
|
453
|
-
client.onToolsChanged = onToolsChanged;
|
|
454
|
-
sdkClientMock.listTools.mockResolvedValue({
|
|
455
|
-
tools: [{ name: 'z', description: 'Z', inputSchema: {} }],
|
|
456
|
-
});
|
|
457
|
-
triggerToolsChanged();
|
|
458
|
-
await vi.waitFor(() => expect(onToolsChanged).toHaveBeenCalled());
|
|
459
|
-
expect(onToolsChanged).toHaveBeenCalledWith(['x', 'y'], expect.any(Array));
|
|
460
|
-
const newTools = onToolsChanged.mock.calls[0][1];
|
|
461
|
-
expect(newTools.map((t) => t.name)).toEqual(['z']);
|
|
462
|
-
});
|
|
463
|
-
it('does not throw when onToolsChanged is not set', async () => {
|
|
464
|
-
sdkClientMock.listTools.mockResolvedValue({
|
|
465
|
-
tools: [{ name: 'tool_a', description: 'A', inputSchema: {} }],
|
|
466
|
-
});
|
|
467
|
-
await client.listTools();
|
|
468
|
-
sdkClientMock.listTools.mockResolvedValue({
|
|
469
|
-
tools: [{ name: 'tool_b', description: 'B', inputSchema: {} }],
|
|
470
|
-
});
|
|
471
|
-
triggerToolsChanged();
|
|
472
|
-
await new Promise((r) => setTimeout(r, 0));
|
|
473
|
-
});
|
|
474
|
-
it('logs warning and preserves registry when listTools fails during refresh', async () => {
|
|
475
|
-
sdkClientMock.listTools.mockResolvedValue({
|
|
476
|
-
tools: [{ name: 'tool_a', description: 'A', inputSchema: {} }],
|
|
477
|
-
});
|
|
478
|
-
await client.listTools();
|
|
479
|
-
const onToolsChanged = vi.fn();
|
|
480
|
-
client.onToolsChanged = onToolsChanged;
|
|
481
|
-
sdkClientMock.listTools.mockRejectedValue(new Error('server disconnected'));
|
|
482
|
-
const warnSpy = vi.spyOn(logger, 'warn');
|
|
483
|
-
triggerToolsChanged();
|
|
484
|
-
await vi.waitFor(() => expect(warnSpy).toHaveBeenCalled());
|
|
485
|
-
expect(onToolsChanged).not.toHaveBeenCalled();
|
|
486
|
-
expect(warnSpy).toHaveBeenCalledWith(expect.stringContaining('failed to refresh tools'));
|
|
487
|
-
});
|
|
488
|
-
it('coalesces notifications received during an in-flight refresh into one extra refresh', async () => {
|
|
489
|
-
sdkClientMock.listTools.mockResolvedValue({
|
|
490
|
-
tools: [{ name: 'tool_a', description: 'A', inputSchema: {} }],
|
|
491
|
-
});
|
|
492
|
-
await client.listTools();
|
|
493
|
-
const onToolsChanged = vi.fn();
|
|
494
|
-
client.onToolsChanged = onToolsChanged;
|
|
495
|
-
let resolveListTools;
|
|
496
|
-
sdkClientMock.listTools.mockReturnValue(new Promise((r) => (resolveListTools = r)));
|
|
497
|
-
triggerToolsChanged();
|
|
498
|
-
triggerToolsChanged();
|
|
499
|
-
triggerToolsChanged();
|
|
500
|
-
resolveListTools({ tools: [{ name: 'tool_b', description: 'B', inputSchema: {} }] });
|
|
501
|
-
await vi.waitFor(() => expect(onToolsChanged).toHaveBeenCalledTimes(2));
|
|
502
|
-
expect(sdkClientMock.listTools).toHaveBeenCalledTimes(3);
|
|
503
|
-
});
|
|
504
|
-
});
|
|
505
|
-
describe('McpTool', () => {
|
|
506
|
-
const mockClientWrapper = { callTool: vi.fn() };
|
|
507
|
-
const tool = new McpTool({
|
|
508
|
-
name: 'weather',
|
|
509
|
-
description: 'Get weather',
|
|
510
|
-
inputSchema: {},
|
|
511
|
-
client: mockClientWrapper,
|
|
512
|
-
});
|
|
513
|
-
const toolContext = {
|
|
514
|
-
toolUse: { toolUseId: 'id-123', name: 'weather', input: { city: 'NYC' } },
|
|
515
|
-
agent: { cancelSignal: new AbortController().signal },
|
|
516
|
-
invocationState: {},
|
|
517
|
-
interrupt: () => {
|
|
518
|
-
throw new Error('interrupt not available in mock context');
|
|
519
|
-
},
|
|
520
|
-
};
|
|
521
|
-
it('forwards agent cancelSignal to callTool', async () => {
|
|
522
|
-
vi.mocked(mockClientWrapper.callTool).mockResolvedValue({
|
|
523
|
-
content: [{ type: 'text', text: 'ok' }],
|
|
524
|
-
});
|
|
525
|
-
await runTool(tool.stream(toolContext));
|
|
526
|
-
expect(mockClientWrapper.callTool).toHaveBeenCalledWith(tool, { city: 'NYC' }, {
|
|
527
|
-
signal: toolContext.agent.cancelSignal,
|
|
528
|
-
});
|
|
529
|
-
});
|
|
530
|
-
it('returns text results on success', async () => {
|
|
531
|
-
vi.mocked(mockClientWrapper.callTool).mockResolvedValue({
|
|
532
|
-
content: [{ type: 'text', text: 'Sunny' }],
|
|
533
|
-
});
|
|
534
|
-
const result = await runTool(tool.stream(toolContext));
|
|
535
|
-
expect(result).toBeDefined();
|
|
536
|
-
expect(result.status).toBe('success');
|
|
537
|
-
expect(result.content[0].text).toBe('Sunny');
|
|
538
|
-
});
|
|
539
|
-
it('returns structured data results on success', async () => {
|
|
540
|
-
const data = { temperature: 72 };
|
|
541
|
-
vi.mocked(mockClientWrapper.callTool).mockResolvedValue({
|
|
542
|
-
content: [{ type: 'data', value: data }],
|
|
543
|
-
});
|
|
544
|
-
const result = await runTool(tool.stream(toolContext));
|
|
545
|
-
const content = result.content[0];
|
|
546
|
-
expect(content).toBeInstanceOf(JsonBlock);
|
|
547
|
-
expect(content.json).toEqual(expect.objectContaining({ value: data }));
|
|
548
|
-
});
|
|
549
|
-
it('provides default message for empty output', async () => {
|
|
550
|
-
vi.mocked(mockClientWrapper.callTool).mockResolvedValue({ content: [] });
|
|
551
|
-
const result = await runTool(tool.stream(toolContext));
|
|
552
|
-
expect(result.content[0].text).toContain('completed successfully');
|
|
553
|
-
});
|
|
554
|
-
it('handles protocol-level errors', async () => {
|
|
555
|
-
vi.mocked(mockClientWrapper.callTool).mockResolvedValue({
|
|
556
|
-
isError: true,
|
|
557
|
-
content: [{ type: 'text', text: 'Service Unavailable' }],
|
|
558
|
-
});
|
|
559
|
-
const result = await runTool(tool.stream(toolContext));
|
|
560
|
-
expect(result.status).toBe('error');
|
|
561
|
-
expect(result.content[0].text).toBe('Service Unavailable');
|
|
562
|
-
});
|
|
563
|
-
it('catches and wraps client exceptions', async () => {
|
|
564
|
-
vi.mocked(mockClientWrapper.callTool).mockRejectedValue(new Error('Network Error'));
|
|
565
|
-
const result = await runTool(tool.stream(toolContext));
|
|
566
|
-
expect(result.status).toBe('error');
|
|
567
|
-
expect(result.content[0].text).toBe('Network Error');
|
|
568
|
-
});
|
|
569
|
-
it('validates SDK response format', async () => {
|
|
570
|
-
vi.mocked(mockClientWrapper.callTool).mockResolvedValue({ content: null });
|
|
571
|
-
const result = await runTool(tool.stream(toolContext));
|
|
572
|
-
expect(result.status).toBe('error');
|
|
573
|
-
expect(result.content[0].text).toContain('missing content array');
|
|
574
|
-
});
|
|
575
|
-
it('maps MCP image content to ImageBlock', async () => {
|
|
576
|
-
// "iVBOR..." is a minimal base64 PNG prefix
|
|
577
|
-
const base64Data = 'iVBORw0KGgoAAAANSUhEUg==';
|
|
578
|
-
vi.mocked(mockClientWrapper.callTool).mockResolvedValue({
|
|
579
|
-
content: [{ type: 'image', data: base64Data, mimeType: 'image/png' }],
|
|
580
|
-
});
|
|
581
|
-
const result = await runTool(tool.stream(toolContext));
|
|
582
|
-
expect(result.status).toBe('success');
|
|
583
|
-
expect(result.content).toHaveLength(1);
|
|
584
|
-
const imageBlock = result.content[0];
|
|
585
|
-
expect(imageBlock).toBeInstanceOf(ImageBlock);
|
|
586
|
-
expect(imageBlock.format).toBe('png');
|
|
587
|
-
expect(imageBlock.source.type).toBe('imageSourceBytes');
|
|
588
|
-
});
|
|
589
|
-
it('falls back to JsonBlock for unsupported image mime type', async () => {
|
|
590
|
-
vi.mocked(mockClientWrapper.callTool).mockResolvedValue({
|
|
591
|
-
content: [{ type: 'image', data: 'abc123', mimeType: 'image/bmp' }],
|
|
592
|
-
});
|
|
593
|
-
const result = await runTool(tool.stream(toolContext));
|
|
594
|
-
expect(result.content[0]).toBeInstanceOf(JsonBlock);
|
|
595
|
-
});
|
|
596
|
-
it('falls back to JsonBlock for image content missing data', async () => {
|
|
597
|
-
vi.mocked(mockClientWrapper.callTool).mockResolvedValue({
|
|
598
|
-
content: [{ type: 'image', mimeType: 'image/png' }],
|
|
599
|
-
});
|
|
600
|
-
const result = await runTool(tool.stream(toolContext));
|
|
601
|
-
expect(result.content[0]).toBeInstanceOf(JsonBlock);
|
|
602
|
-
});
|
|
603
|
-
it('maps MCP text resource to TextBlock', async () => {
|
|
604
|
-
vi.mocked(mockClientWrapper.callTool).mockResolvedValue({
|
|
605
|
-
content: [
|
|
606
|
-
{ type: 'resource', resource: { uri: 'file:///doc.txt', text: 'hello world', mimeType: 'text/plain' } },
|
|
607
|
-
],
|
|
608
|
-
});
|
|
609
|
-
const result = await runTool(tool.stream(toolContext));
|
|
610
|
-
expect(result.status).toBe('success');
|
|
611
|
-
expect(result.content[0].text).toBe('hello world');
|
|
612
|
-
});
|
|
613
|
-
it('maps MCP blob resource with image mime type to ImageBlock', async () => {
|
|
614
|
-
const base64Data = 'iVBORw0KGgoAAAANSUhEUg==';
|
|
615
|
-
vi.mocked(mockClientWrapper.callTool).mockResolvedValue({
|
|
616
|
-
content: [{ type: 'resource', resource: { uri: 'file:///img.png', blob: base64Data, mimeType: 'image/jpeg' } }],
|
|
617
|
-
});
|
|
618
|
-
const result = await runTool(tool.stream(toolContext));
|
|
619
|
-
expect(result.content[0]).toBeInstanceOf(ImageBlock);
|
|
620
|
-
expect(result.content[0].format).toBe('jpeg');
|
|
621
|
-
});
|
|
622
|
-
it('falls back to JsonBlock for blob resource with non-image mime type', async () => {
|
|
623
|
-
vi.mocked(mockClientWrapper.callTool).mockResolvedValue({
|
|
624
|
-
content: [
|
|
625
|
-
{ type: 'resource', resource: { uri: 'file:///doc.pdf', blob: 'abc123', mimeType: 'application/pdf' } },
|
|
626
|
-
],
|
|
627
|
-
});
|
|
628
|
-
const result = await runTool(tool.stream(toolContext));
|
|
629
|
-
expect(result.content[0]).toBeInstanceOf(JsonBlock);
|
|
630
|
-
});
|
|
631
|
-
it('falls back to JsonBlock for resource with neither text nor blob', async () => {
|
|
632
|
-
vi.mocked(mockClientWrapper.callTool).mockResolvedValue({
|
|
633
|
-
content: [{ type: 'resource', resource: { uri: 'file:///unknown' } }],
|
|
634
|
-
});
|
|
635
|
-
const result = await runTool(tool.stream(toolContext));
|
|
636
|
-
expect(result.content[0]).toBeInstanceOf(JsonBlock);
|
|
637
|
-
});
|
|
638
|
-
it('handles mixed content types in a single result', async () => {
|
|
639
|
-
const base64Data = 'iVBORw0KGgoAAAANSUhEUg==';
|
|
640
|
-
vi.mocked(mockClientWrapper.callTool).mockResolvedValue({
|
|
641
|
-
content: [
|
|
642
|
-
{ type: 'text', text: 'Here is the image:' },
|
|
643
|
-
{ type: 'image', data: base64Data, mimeType: 'image/png' },
|
|
644
|
-
{ type: 'resource', resource: { uri: 'file:///notes.txt', text: 'Some notes' } },
|
|
645
|
-
],
|
|
646
|
-
});
|
|
647
|
-
const result = await runTool(tool.stream(toolContext));
|
|
648
|
-
expect(result.content).toHaveLength(3);
|
|
649
|
-
expect(result.content[0].text).toBe('Here is the image:');
|
|
650
|
-
expect(result.content[1]).toBeInstanceOf(ImageBlock);
|
|
651
|
-
expect(result.content[2].text).toBe('Some notes');
|
|
652
|
-
});
|
|
653
|
-
it('surfaces elicitation data for McpError with code -32042', async () => {
|
|
654
|
-
const elicitations = [
|
|
655
|
-
{
|
|
656
|
-
mode: 'url',
|
|
657
|
-
message: 'Please authorize with GitHub',
|
|
658
|
-
elicitationId: 'e-123',
|
|
659
|
-
url: 'https://github.com/login/oauth/authorize?client_id=abc',
|
|
660
|
-
},
|
|
661
|
-
];
|
|
662
|
-
const mcpError = new McpError(ErrorCode.UrlElicitationRequired, 'Authorization required', { elicitations });
|
|
663
|
-
vi.mocked(mockClientWrapper.callTool).mockRejectedValue(mcpError);
|
|
664
|
-
const result = await runTool(tool.stream(toolContext));
|
|
665
|
-
expect(result.status).toBe('error');
|
|
666
|
-
expect(result.content[0].text).toBe(`MCP Elicitation required: [${String(mcpError)}] with data ${JSON.stringify(elicitations)}`);
|
|
667
|
-
});
|
|
668
|
-
it('surfaces multiple elicitations for McpError with code -32042', async () => {
|
|
669
|
-
const elicitations = [
|
|
670
|
-
{
|
|
671
|
-
mode: 'url',
|
|
672
|
-
message: 'Authorize with GitHub',
|
|
673
|
-
elicitationId: 'e-1',
|
|
674
|
-
url: 'https://github.com/login/oauth/authorize',
|
|
675
|
-
},
|
|
676
|
-
{
|
|
677
|
-
mode: 'url',
|
|
678
|
-
message: 'Authorize with Google',
|
|
679
|
-
elicitationId: 'e-2',
|
|
680
|
-
url: 'https://accounts.google.com/o/oauth2/auth',
|
|
681
|
-
},
|
|
682
|
-
];
|
|
683
|
-
const mcpError = new McpError(ErrorCode.UrlElicitationRequired, 'Authorization required', { elicitations });
|
|
684
|
-
vi.mocked(mockClientWrapper.callTool).mockRejectedValue(mcpError);
|
|
685
|
-
const result = await runTool(tool.stream(toolContext));
|
|
686
|
-
expect(result.status).toBe('error');
|
|
687
|
-
expect(result.content[0].text).toBe(`MCP Elicitation required: [${String(mcpError)}] with data ${JSON.stringify(elicitations)}`);
|
|
688
|
-
});
|
|
689
|
-
it('falls through to generic error for McpError -32042 with malformed data', async () => {
|
|
690
|
-
const mcpError = new McpError(ErrorCode.UrlElicitationRequired, 'Authorization required', {
|
|
691
|
-
unexpected: 'shape',
|
|
692
|
-
});
|
|
693
|
-
vi.mocked(mockClientWrapper.callTool).mockRejectedValue(mcpError);
|
|
694
|
-
const result = await runTool(tool.stream(toolContext));
|
|
695
|
-
expect(result.status).toBe('error');
|
|
696
|
-
expect(result.content[0].text).toBe('MCP error -32042: Authorization required');
|
|
697
|
-
});
|
|
698
|
-
it('surfaces elicitation data for UrlElicitationRequiredError', async () => {
|
|
699
|
-
const elicitations = [
|
|
700
|
-
{
|
|
701
|
-
mode: 'url',
|
|
702
|
-
message: 'Please authorize',
|
|
703
|
-
elicitationId: 'e-1',
|
|
704
|
-
url: 'https://example.com/auth',
|
|
705
|
-
},
|
|
706
|
-
];
|
|
707
|
-
const error = new UrlElicitationRequiredError(elicitations, 'Auth required');
|
|
708
|
-
vi.mocked(mockClientWrapper.callTool).mockRejectedValue(error);
|
|
709
|
-
const result = await runTool(tool.stream(toolContext));
|
|
710
|
-
expect(result.status).toBe('error');
|
|
711
|
-
expect(result.content[0].text).toContain('MCP Elicitation required');
|
|
712
|
-
expect(result.content[0].text).toContain('https://example.com/auth');
|
|
713
|
-
});
|
|
714
|
-
it('falls through to generic error for McpError -32042 with undefined data', async () => {
|
|
715
|
-
const mcpError = new McpError(ErrorCode.UrlElicitationRequired, 'Auth required');
|
|
716
|
-
vi.mocked(mockClientWrapper.callTool).mockRejectedValue(mcpError);
|
|
717
|
-
const result = await runTool(tool.stream(toolContext));
|
|
718
|
-
expect(result.status).toBe('error');
|
|
719
|
-
expect(result.content[0].text).toBe('MCP error -32042: Auth required');
|
|
720
|
-
});
|
|
721
|
-
it('falls through to generic error for McpError -32042 with non-array elicitations', async () => {
|
|
722
|
-
const mcpError = new McpError(ErrorCode.UrlElicitationRequired, 'Auth required', {
|
|
723
|
-
elicitations: 'not-an-array',
|
|
724
|
-
});
|
|
725
|
-
vi.mocked(mockClientWrapper.callTool).mockRejectedValue(mcpError);
|
|
726
|
-
const result = await runTool(tool.stream(toolContext));
|
|
727
|
-
expect(result.status).toBe('error');
|
|
728
|
-
expect(result.content[0].text).toBe('MCP error -32042: Auth required');
|
|
729
|
-
});
|
|
730
|
-
it('falls through to generic error for McpError -32042 with empty elicitations', async () => {
|
|
731
|
-
const mcpError = new McpError(ErrorCode.UrlElicitationRequired, 'Auth required', {
|
|
732
|
-
elicitations: [],
|
|
733
|
-
});
|
|
734
|
-
vi.mocked(mockClientWrapper.callTool).mockRejectedValue(mcpError);
|
|
735
|
-
const result = await runTool(tool.stream(toolContext));
|
|
736
|
-
expect(result.status).toBe('error');
|
|
737
|
-
expect(result.content[0].text).toBe('MCP error -32042: Auth required');
|
|
738
|
-
});
|
|
739
|
-
it('falls through to generic error for McpError with a different code', async () => {
|
|
740
|
-
const mcpError = new McpError(ErrorCode.InvalidRequest, 'Bad request');
|
|
741
|
-
vi.mocked(mockClientWrapper.callTool).mockRejectedValue(mcpError);
|
|
742
|
-
const result = await runTool(tool.stream(toolContext));
|
|
743
|
-
expect(result.status).toBe('error');
|
|
744
|
-
expect(result.content[0].text).toBe('MCP error -32600: Bad request');
|
|
745
|
-
});
|
|
746
|
-
});
|
|
747
|
-
});
|
|
748
|
-
describe('server metadata getters', () => {
|
|
749
|
-
let client;
|
|
750
|
-
let sdkClientMock;
|
|
751
|
-
beforeEach(() => {
|
|
752
|
-
vi.clearAllMocks();
|
|
753
|
-
client = new McpClient({ applicationName: 'TestApp', transport: mockTransport });
|
|
754
|
-
sdkClientMock = vi.mocked(Client).mock.results.at(-1).value;
|
|
755
|
-
});
|
|
756
|
-
afterEach(() => {
|
|
757
|
-
vi.restoreAllMocks();
|
|
758
|
-
});
|
|
759
|
-
it('returns undefined for all getters before connect', () => {
|
|
760
|
-
sdkClientMock.getServerCapabilities.mockReturnValue(undefined);
|
|
761
|
-
sdkClientMock.getServerVersion.mockReturnValue(undefined);
|
|
762
|
-
sdkClientMock.getInstructions.mockReturnValue(undefined);
|
|
763
|
-
expect(client.serverCapabilities).toBeUndefined();
|
|
764
|
-
expect(client.serverVersion).toBeUndefined();
|
|
765
|
-
expect(client.serverInstructions).toBeUndefined();
|
|
766
|
-
});
|
|
767
|
-
it('returns serverCapabilities after connect', async () => {
|
|
768
|
-
const caps = { tools: {} };
|
|
769
|
-
sdkClientMock.getServerCapabilities.mockReturnValue(caps);
|
|
770
|
-
await client.connect();
|
|
771
|
-
expect(client.serverCapabilities).toBe(caps);
|
|
772
|
-
});
|
|
773
|
-
it('returns serverVersion after connect', async () => {
|
|
774
|
-
const version = { name: 'my-server', version: '1.2.3' };
|
|
775
|
-
sdkClientMock.getServerVersion.mockReturnValue(version);
|
|
776
|
-
await client.connect();
|
|
777
|
-
expect(client.serverVersion).toBe(version);
|
|
778
|
-
});
|
|
779
|
-
it('returns serverInstructions after connect', async () => {
|
|
780
|
-
sdkClientMock.getInstructions.mockReturnValue('Use this server for X.');
|
|
781
|
-
await client.connect();
|
|
782
|
-
expect(client.serverInstructions).toBe('Use this server for X.');
|
|
783
|
-
});
|
|
784
|
-
it('connectionState is disconnected before connect', () => {
|
|
785
|
-
expect(client.connectionState).toBe('disconnected');
|
|
786
|
-
});
|
|
787
|
-
it('connectionState is connected after successful connect', async () => {
|
|
788
|
-
await client.connect();
|
|
789
|
-
expect(client.connectionState).toBe('connected');
|
|
790
|
-
});
|
|
791
|
-
});
|
|
792
|
-
describe('continueOnError', () => {
|
|
793
|
-
let sdkClientMock;
|
|
794
|
-
beforeEach(() => {
|
|
795
|
-
vi.clearAllMocks();
|
|
796
|
-
});
|
|
797
|
-
afterEach(() => {
|
|
798
|
-
vi.restoreAllMocks();
|
|
799
|
-
});
|
|
800
|
-
it('throws on connection failure by default', async () => {
|
|
801
|
-
const client = new McpClient({ applicationName: 'TestApp', transport: mockTransport });
|
|
802
|
-
sdkClientMock = vi.mocked(Client).mock.results.at(-1).value;
|
|
803
|
-
sdkClientMock.connect.mockRejectedValue(new Error('connection refused'));
|
|
804
|
-
await expect(client.connect()).rejects.toThrow('connection refused');
|
|
805
|
-
});
|
|
806
|
-
it('swallows connection failure when continueOnError is true', async () => {
|
|
807
|
-
const client = new McpClient({ applicationName: 'TestApp', transport: mockTransport, continueOnError: true });
|
|
808
|
-
sdkClientMock = vi.mocked(Client).mock.results.at(-1).value;
|
|
809
|
-
sdkClientMock.connect.mockRejectedValue(new Error('connection refused'));
|
|
810
|
-
await expect(client.connect()).resolves.toBeUndefined();
|
|
811
|
-
});
|
|
812
|
-
it('logs a warning when continueOnError swallows a connection failure', async () => {
|
|
813
|
-
const warnSpy = vi.spyOn(logger, 'warn').mockImplementation(() => { });
|
|
814
|
-
const client = new McpClient({ applicationName: 'TestApp', transport: mockTransport, continueOnError: true });
|
|
815
|
-
sdkClientMock = vi.mocked(Client).mock.results.at(-1).value;
|
|
816
|
-
sdkClientMock.connect.mockRejectedValue(new Error('connection refused'));
|
|
817
|
-
await client.connect();
|
|
818
|
-
expect(warnSpy).toHaveBeenCalledWith(expect.stringContaining('MCP server failed to connect'));
|
|
819
|
-
});
|
|
820
|
-
it('listTools returns empty array when continueOnError and connection failed', async () => {
|
|
821
|
-
const client = new McpClient({ applicationName: 'TestApp', transport: mockTransport, continueOnError: true });
|
|
822
|
-
sdkClientMock = vi.mocked(Client).mock.results.at(-1).value;
|
|
823
|
-
sdkClientMock.connect.mockRejectedValue(new Error('connection refused'));
|
|
824
|
-
const tools = await client.listTools();
|
|
825
|
-
expect(tools).toEqual([]);
|
|
826
|
-
});
|
|
827
|
-
it('callTool throws when continueOnError and connection failed', async () => {
|
|
828
|
-
const client = new McpClient({ applicationName: 'TestApp', transport: mockTransport, continueOnError: true });
|
|
829
|
-
sdkClientMock = vi.mocked(Client).mock.results.at(-1).value;
|
|
830
|
-
sdkClientMock.connect.mockRejectedValue(new Error('connection refused'));
|
|
831
|
-
const tool = new McpTool({ name: 'my_tool', description: '', inputSchema: {}, client });
|
|
832
|
-
await expect(client.callTool(tool, {})).rejects.toThrow('MCP server failed to connect. Call connect(true) to retry.');
|
|
833
|
-
});
|
|
834
|
-
it('does not retry connection on subsequent calls after continueOnError failure', async () => {
|
|
835
|
-
const client = new McpClient({ applicationName: 'TestApp', transport: mockTransport, continueOnError: true });
|
|
836
|
-
sdkClientMock = vi.mocked(Client).mock.results.at(-1).value;
|
|
837
|
-
sdkClientMock.connect.mockRejectedValue(new Error('connection refused'));
|
|
838
|
-
await client.listTools();
|
|
839
|
-
await client.listTools();
|
|
840
|
-
expect(sdkClientMock.connect).toHaveBeenCalledTimes(1);
|
|
841
|
-
});
|
|
842
|
-
it('recovers after explicit connect(true) when server comes back', async () => {
|
|
843
|
-
const client = new McpClient({ applicationName: 'TestApp', transport: mockTransport, continueOnError: true });
|
|
844
|
-
sdkClientMock = vi.mocked(Client).mock.results.at(-1).value;
|
|
845
|
-
sdkClientMock.connect.mockRejectedValueOnce(new Error('connection refused'));
|
|
846
|
-
sdkClientMock.listTools.mockResolvedValue({ tools: [] });
|
|
847
|
-
const firstTools = await client.listTools();
|
|
848
|
-
expect(firstTools).toEqual([]);
|
|
849
|
-
expect(client.connectionState).toBe('failed');
|
|
850
|
-
await client.connect(true);
|
|
851
|
-
const secondTools = await client.listTools();
|
|
852
|
-
expect(secondTools).toEqual([]);
|
|
853
|
-
expect(client.connectionState).toBe('connected');
|
|
854
|
-
expect(sdkClientMock.connect).toHaveBeenCalledTimes(2);
|
|
855
|
-
});
|
|
856
|
-
});
|
|
857
|
-
describe('log routing', () => {
|
|
858
|
-
let notificationHandler;
|
|
859
|
-
let sdkClientMock;
|
|
860
|
-
beforeEach(() => {
|
|
861
|
-
vi.clearAllMocks();
|
|
862
|
-
new McpClient({ applicationName: 'TestApp', transport: mockTransport });
|
|
863
|
-
sdkClientMock = vi.mocked(Client).mock.results.at(-1).value;
|
|
864
|
-
// Handler is registered in the constructor — read it from the first setNotificationHandler call
|
|
865
|
-
notificationHandler = sdkClientMock.setNotificationHandler.mock.calls[0][1];
|
|
866
|
-
});
|
|
867
|
-
afterEach(() => {
|
|
868
|
-
vi.restoreAllMocks();
|
|
869
|
-
});
|
|
870
|
-
it('routes debug level to logger.debug', () => {
|
|
871
|
-
const spy = vi.spyOn(logger, 'debug').mockImplementation(() => { });
|
|
872
|
-
notificationHandler({ params: { level: 'debug', data: 'hello' } });
|
|
873
|
-
expect(spy).toHaveBeenCalledWith(expect.stringContaining('hello'));
|
|
874
|
-
});
|
|
875
|
-
it('routes info level to logger.info', () => {
|
|
876
|
-
const spy = vi.spyOn(logger, 'info').mockImplementation(() => { });
|
|
877
|
-
notificationHandler({ params: { level: 'info', data: 'hello' } });
|
|
878
|
-
expect(spy).toHaveBeenCalledWith(expect.stringContaining('hello'));
|
|
879
|
-
});
|
|
880
|
-
it('routes notice level to logger.info', () => {
|
|
881
|
-
const spy = vi.spyOn(logger, 'info').mockImplementation(() => { });
|
|
882
|
-
notificationHandler({ params: { level: 'notice', data: 'hello' } });
|
|
883
|
-
expect(spy).toHaveBeenCalledWith(expect.stringContaining('hello'));
|
|
884
|
-
});
|
|
885
|
-
it('routes warning level to logger.warn', () => {
|
|
886
|
-
const spy = vi.spyOn(logger, 'warn').mockImplementation(() => { });
|
|
887
|
-
notificationHandler({ params: { level: 'warning', data: 'hello' } });
|
|
888
|
-
expect(spy).toHaveBeenCalledWith(expect.stringContaining('hello'));
|
|
889
|
-
});
|
|
890
|
-
it('routes error level to logger.error', () => {
|
|
891
|
-
const spy = vi.spyOn(logger, 'error').mockImplementation(() => { });
|
|
892
|
-
notificationHandler({ params: { level: 'error', data: 'hello' } });
|
|
893
|
-
expect(spy).toHaveBeenCalledWith(expect.stringContaining('hello'));
|
|
894
|
-
});
|
|
895
|
-
it('routes critical level to logger.error', () => {
|
|
896
|
-
const spy = vi.spyOn(logger, 'error').mockImplementation(() => { });
|
|
897
|
-
notificationHandler({ params: { level: 'critical', data: 'hello' } });
|
|
898
|
-
expect(spy).toHaveBeenCalledWith(expect.stringContaining('hello'));
|
|
899
|
-
});
|
|
900
|
-
it('routes alert level to logger.error', () => {
|
|
901
|
-
const spy = vi.spyOn(logger, 'error').mockImplementation(() => { });
|
|
902
|
-
notificationHandler({ params: { level: 'alert', data: 'hello' } });
|
|
903
|
-
expect(spy).toHaveBeenCalledWith(expect.stringContaining('hello'));
|
|
904
|
-
});
|
|
905
|
-
it('routes emergency level to logger.error', () => {
|
|
906
|
-
const spy = vi.spyOn(logger, 'error').mockImplementation(() => { });
|
|
907
|
-
notificationHandler({ params: { level: 'emergency', data: 'hello' } });
|
|
908
|
-
expect(spy).toHaveBeenCalledWith(expect.stringContaining('hello'));
|
|
909
|
-
});
|
|
910
|
-
it('includes logger name and data in the message', () => {
|
|
911
|
-
const spy = vi.spyOn(logger, 'info').mockImplementation(() => { });
|
|
912
|
-
notificationHandler({ params: { level: 'info', logger: 'my-server', data: { key: 'val' } } });
|
|
913
|
-
expect(spy).toHaveBeenCalledWith(expect.stringContaining('my-server'));
|
|
914
|
-
expect(spy).toHaveBeenCalledWith(expect.stringContaining('key'));
|
|
915
|
-
});
|
|
916
|
-
it('calls custom logHandler when provided', () => {
|
|
917
|
-
const customHandler = vi.fn();
|
|
918
|
-
new McpClient({ applicationName: 'TestApp', transport: mockTransport, logHandler: customHandler });
|
|
919
|
-
const customSdkMock = vi.mocked(Client).mock.results.at(-1).value;
|
|
920
|
-
const capturedHandler = customSdkMock.setNotificationHandler.mock.calls[0][1];
|
|
921
|
-
const params = { level: 'info', data: 'test' };
|
|
922
|
-
capturedHandler({ params });
|
|
923
|
-
expect(customHandler).toHaveBeenCalledWith(params);
|
|
924
|
-
});
|
|
925
|
-
});
|
|
926
|
-
describe('McpClient transport resolution', () => {
|
|
927
|
-
beforeEach(() => {
|
|
928
|
-
vi.clearAllMocks();
|
|
929
|
-
});
|
|
930
|
-
it('constructs StreamableHTTPClientTransport when url is provided', () => {
|
|
931
|
-
new McpClient({ url: 'https://mcp.example.com' });
|
|
932
|
-
expect(StreamableHTTPClientTransport).toHaveBeenCalledWith(new URL('https://mcp.example.com'), {});
|
|
933
|
-
});
|
|
934
|
-
it('constructs ClientCredentialsProvider when auth is provided', () => {
|
|
935
|
-
new McpClient({ url: 'https://mcp.example.com', auth: { clientId: 'id', clientSecret: 'secret' } });
|
|
936
|
-
expect(ClientCredentialsProvider).toHaveBeenCalledWith({ clientId: 'id', clientSecret: 'secret' });
|
|
937
|
-
expect(StreamableHTTPClientTransport).toHaveBeenCalledWith(new URL('https://mcp.example.com'), {
|
|
938
|
-
authProvider: expect.anything(),
|
|
939
|
-
});
|
|
940
|
-
});
|
|
941
|
-
it('passes scopes as space-separated string', () => {
|
|
942
|
-
new McpClient({
|
|
943
|
-
url: 'https://mcp.example.com',
|
|
944
|
-
auth: { clientId: 'id', clientSecret: 'secret', scopes: ['read', 'write'] },
|
|
945
|
-
});
|
|
946
|
-
expect(ClientCredentialsProvider).toHaveBeenCalledWith({
|
|
947
|
-
clientId: 'id',
|
|
948
|
-
clientSecret: 'secret',
|
|
949
|
-
scope: 'read write',
|
|
950
|
-
});
|
|
951
|
-
});
|
|
952
|
-
it('passes custom authProvider to transport', () => {
|
|
953
|
-
const customProvider = { redirectUrl: undefined, clientMetadata: {} };
|
|
954
|
-
new McpClient({ url: 'https://mcp.example.com', authProvider: customProvider });
|
|
955
|
-
expect(StreamableHTTPClientTransport).toHaveBeenCalledWith(new URL('https://mcp.example.com'), {
|
|
956
|
-
authProvider: customProvider,
|
|
957
|
-
});
|
|
958
|
-
});
|
|
959
|
-
it('throws when both transport and url are provided', () => {
|
|
960
|
-
expect(() => new McpClient({ transport: mockTransport, url: 'https://mcp.example.com' })).toThrow('provide either "transport" or "url", not both');
|
|
961
|
-
});
|
|
962
|
-
it('throws when neither transport nor url is provided', () => {
|
|
963
|
-
expect(() => new McpClient({})).toThrow('either "transport" or "url" must be provided');
|
|
964
|
-
});
|
|
965
|
-
it('throws when auth is provided with transport', () => {
|
|
966
|
-
expect(() => new McpClient({ transport: mockTransport, auth: { clientId: 'x', clientSecret: 'y' } })).toThrow('"auth", "authProvider", and "headers" require "url"');
|
|
967
|
-
});
|
|
968
|
-
it('throws when both auth and authProvider are provided', () => {
|
|
969
|
-
const customProvider = {};
|
|
970
|
-
expect(() => new McpClient({
|
|
971
|
-
url: 'https://mcp.example.com',
|
|
972
|
-
auth: { clientId: 'x', clientSecret: 'y' },
|
|
973
|
-
authProvider: customProvider,
|
|
974
|
-
})).toThrow('provide either "auth" or "authProvider", not both');
|
|
975
|
-
});
|
|
976
|
-
it('accepts URL instance for url field', () => {
|
|
977
|
-
const url = new URL('https://mcp.example.com/path');
|
|
978
|
-
new McpClient({ url });
|
|
979
|
-
expect(StreamableHTTPClientTransport).toHaveBeenCalledWith(url, {});
|
|
980
|
-
});
|
|
981
|
-
it('passes headers as requestInit to transport', () => {
|
|
982
|
-
new McpClient({ url: 'https://mcp.example.com', headers: { 'X-Api-Key': 'abc' } });
|
|
983
|
-
expect(StreamableHTTPClientTransport).toHaveBeenCalledWith(new URL('https://mcp.example.com'), {
|
|
984
|
-
requestInit: { headers: { 'X-Api-Key': 'abc' } },
|
|
985
|
-
});
|
|
986
|
-
});
|
|
987
|
-
it('passes both auth and headers to transport', () => {
|
|
988
|
-
new McpClient({
|
|
989
|
-
url: 'https://mcp.example.com',
|
|
990
|
-
auth: { clientId: 'id', clientSecret: 'secret' },
|
|
991
|
-
headers: { 'X-Trace': '123' },
|
|
992
|
-
});
|
|
993
|
-
expect(ClientCredentialsProvider).toHaveBeenCalledWith({ clientId: 'id', clientSecret: 'secret' });
|
|
994
|
-
expect(StreamableHTTPClientTransport).toHaveBeenCalledWith(new URL('https://mcp.example.com'), {
|
|
995
|
-
authProvider: expect.anything(),
|
|
996
|
-
requestInit: { headers: { 'X-Trace': '123' } },
|
|
997
|
-
});
|
|
998
|
-
});
|
|
999
|
-
it('throws when headers is provided with transport', () => {
|
|
1000
|
-
expect(() => new McpClient({ transport: mockTransport, headers: { 'X-Foo': 'bar' } })).toThrow('"auth", "authProvider", and "headers" require "url"');
|
|
1001
|
-
});
|
|
1002
|
-
});
|
|
1003
|
-
//# sourceMappingURL=mcp.test.js.map
|