agents 0.16.2 → 0.17.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.
Files changed (122) hide show
  1. package/README.md +11 -8
  2. package/dist/{agent-tool-types-CTw3UJUP.d.ts → agent-tool-types-Cd1TZPfB.d.ts} +587 -137
  3. package/dist/agent-tool-types.d.ts +34 -18
  4. package/dist/agent-tool-types.js +20 -1
  5. package/dist/agent-tool-types.js.map +1 -0
  6. package/dist/agent-tools-BXlsuX0d.js +304 -0
  7. package/dist/agent-tools-BXlsuX0d.js.map +1 -0
  8. package/dist/agent-tools-_E8wxUIK.d.ts +119 -0
  9. package/dist/agent-tools.d.ts +24 -18
  10. package/dist/agent-tools.js.map +1 -1
  11. package/dist/ai-chat-agent.d.ts +1 -1
  12. package/dist/ai-chat-agent.js +1 -2
  13. package/dist/ai-chat-agent.js.map +1 -1
  14. package/dist/ai-chat-v5-migration.d.ts +1 -1
  15. package/dist/ai-chat-v5-migration.js +1 -2
  16. package/dist/ai-chat-v5-migration.js.map +1 -1
  17. package/dist/ai-react.d.ts +1 -1
  18. package/dist/ai-react.js +1 -2
  19. package/dist/ai-react.js.map +1 -1
  20. package/dist/ai-types.d.ts +1 -7
  21. package/dist/ai-types.js +2 -8
  22. package/dist/ai-types.js.map +1 -1
  23. package/dist/browser/ai.js +1 -1
  24. package/dist/browser/index.js +1 -1
  25. package/dist/chat/index.d.ts +1918 -72
  26. package/dist/chat/index.js +1730 -245
  27. package/dist/chat/index.js.map +1 -1
  28. package/dist/chat/react.d.ts +602 -0
  29. package/dist/chat/react.js +1506 -0
  30. package/dist/chat/react.js.map +1 -0
  31. package/dist/chat-sdk/index.d.ts +4 -4
  32. package/dist/{classPrivateFieldGet2-CZ7QjTXN.js → classPrivateFieldGet2-DZBYAB34.js} +5 -5
  33. package/dist/{classPrivateMethodInitSpec-D-0__zd9.js → classPrivateMethodInitSpec-qMjJ6sHQ.js} +2 -2
  34. package/dist/{client-BXJ9n2f7.js → client-BZ-B3NhC.js} +2 -2
  35. package/dist/client-BZ-B3NhC.js.map +1 -0
  36. package/dist/client-tools-aIBO0Fk7.d.ts +53 -0
  37. package/dist/client.d.ts +76 -57
  38. package/dist/client.js +33 -5
  39. package/dist/client.js.map +1 -1
  40. package/dist/{connector-CrKhowfD.js → connector-CdldGF3h.js} +5 -5
  41. package/dist/{connector-CrKhowfD.js.map → connector-CdldGF3h.js.map} +1 -1
  42. package/dist/email.js +1 -1
  43. package/dist/email.js.map +1 -1
  44. package/dist/{index-B7IbEeze.d.ts → index-CcbnKkNh.d.ts} +188 -14
  45. package/dist/index.d.ts +91 -71
  46. package/dist/index.js +562 -24
  47. package/dist/index.js.map +1 -1
  48. package/dist/mcp/client.d.ts +18 -14
  49. package/dist/mcp/client.js +1 -1
  50. package/dist/mcp/index.d.ts +30 -30
  51. package/dist/mcp/index.js +7 -7
  52. package/dist/mcp/index.js.map +1 -1
  53. package/dist/{agent-tools-3zLG7MgA.js → message-builder-BymO4N_D.js} +45 -126
  54. package/dist/message-builder-BymO4N_D.js.map +1 -0
  55. package/dist/observability/index.d.ts +1 -1
  56. package/dist/observability/index.js +4 -2
  57. package/dist/observability/index.js.map +1 -1
  58. package/dist/react.d.ts +123 -110
  59. package/dist/react.js +44 -11
  60. package/dist/react.js.map +1 -1
  61. package/dist/serializable.d.ts +1 -1
  62. package/dist/skills/compile.js +1 -1
  63. package/dist/skills/compile.js.map +1 -1
  64. package/dist/skills/index.js +5 -5
  65. package/dist/skills/index.js.map +1 -1
  66. package/dist/sub-routing.d.ts +6 -6
  67. package/dist/utils.js +1 -1
  68. package/dist/utils.js.map +1 -1
  69. package/dist/vite.js +5 -5
  70. package/dist/vite.js.map +1 -1
  71. package/dist/wire-types-nflOzNuU.js +240 -0
  72. package/dist/wire-types-nflOzNuU.js.map +1 -0
  73. package/dist/{workflow-types-SrZK_o9p.d.ts → workflow-types-Baz_PO5v.d.ts} +42 -22
  74. package/dist/workflow-types.d.ts +25 -21
  75. package/dist/workflow-types.js.map +1 -1
  76. package/dist/workflows.d.ts +22 -21
  77. package/dist/workflows.js +31 -7
  78. package/dist/workflows.js.map +1 -1
  79. package/docs/adding-to-existing-project.md +450 -0
  80. package/docs/agent-class.md +503 -0
  81. package/docs/agent-tools.md +552 -0
  82. package/docs/browse-the-web.md +430 -0
  83. package/docs/callable-methods.md +627 -0
  84. package/docs/chat-agents.md +1687 -0
  85. package/docs/chat-sdk.md +181 -0
  86. package/docs/client-sdk.md +520 -0
  87. package/docs/client-tools-continuation.md +177 -0
  88. package/docs/codemode.md +440 -0
  89. package/docs/configuration.md +775 -0
  90. package/docs/cross-domain-authentication.md +171 -0
  91. package/docs/durable-execution.md +537 -0
  92. package/docs/email.md +663 -0
  93. package/docs/get-current-agent.md +204 -0
  94. package/docs/getting-started.md +305 -0
  95. package/docs/http-websockets.md +668 -0
  96. package/docs/human-in-the-loop.md +661 -0
  97. package/docs/index.md +151 -0
  98. package/docs/long-running-agents.md +730 -0
  99. package/docs/mcp-client.md +620 -0
  100. package/docs/mcp-servers.md +526 -0
  101. package/docs/mcp-transports.md +308 -0
  102. package/docs/migration-to-ai-sdk-v5.md +96 -0
  103. package/docs/migration-to-ai-sdk-v6.md +163 -0
  104. package/docs/observability.md +261 -0
  105. package/docs/push-notifications.md +367 -0
  106. package/docs/queue.md +329 -0
  107. package/docs/readonly-connections.md +278 -0
  108. package/docs/resumable-streaming.md +127 -0
  109. package/docs/retries.md +444 -0
  110. package/docs/routing.md +749 -0
  111. package/docs/scheduling.md +898 -0
  112. package/docs/securing-mcp-servers.md +359 -0
  113. package/docs/server-driven-messages.md +477 -0
  114. package/docs/sessions.md +1024 -0
  115. package/docs/state.md +512 -0
  116. package/docs/sub-agents.md +389 -0
  117. package/docs/webhooks.md +604 -0
  118. package/docs/workflows.md +877 -0
  119. package/package.json +41 -14
  120. package/dist/agent-tools-3zLG7MgA.js.map +0 -1
  121. package/dist/agent-tools-DZhI5F6Q.d.ts +0 -14
  122. package/dist/client-BXJ9n2f7.js.map +0 -1
@@ -1,19 +1,23 @@
1
1
  import {
2
- _t as MCPServerOptions,
3
- bt as getNamespacedData,
4
- dt as MCPClientOAuthCallbackConfig,
5
- ft as MCPClientOAuthResult,
6
- gt as MCPServerFilter,
7
- ht as MCPOAuthCallbackResult,
8
- lt as MCPClientManager,
9
- mt as MCPDiscoverResult,
10
- pt as MCPConnectionResult,
11
- ut as MCPClientManagerOptions,
12
- vt as MCP_SERVER_ID_MAX_LENGTH,
13
- xt as normalizeServerId,
14
- yt as RegisterServerOptions
15
- } from "../agent-tool-types-CTw3UJUP.js";
2
+ At as getNamespacedData,
3
+ Ct as MCPConnectionResult,
4
+ Dt as MCPServerOptions,
5
+ Et as MCPServerFilter,
6
+ Ot as MCP_SERVER_ID_MAX_LENGTH,
7
+ St as MCPClientOAuthResult,
8
+ Tt as MCPOAuthCallbackResult,
9
+ _t as MCPAITool,
10
+ bt as MCPClientManagerOptions,
11
+ jt as normalizeServerId,
12
+ kt as RegisterServerOptions,
13
+ vt as MCPAIToolSet,
14
+ wt as MCPDiscoverResult,
15
+ xt as MCPClientOAuthCallbackConfig,
16
+ yt as MCPClientManager
17
+ } from "../agent-tool-types-Cd1TZPfB.js";
16
18
  export {
19
+ MCPAITool,
20
+ MCPAIToolSet,
17
21
  MCPClientManager,
18
22
  MCPClientManagerOptions,
19
23
  MCPClientOAuthCallbackConfig,
@@ -1,2 +1,2 @@
1
- import { i as normalizeServerId, n as MCP_SERVER_ID_MAX_LENGTH, r as getNamespacedData, t as MCPClientManager } from "../client-BXJ9n2f7.js";
1
+ import { i as normalizeServerId, n as MCP_SERVER_ID_MAX_LENGTH, r as getNamespacedData, t as MCPClientManager } from "../client-BZ-B3NhC.js";
2
2
  export { MCPClientManager, MCP_SERVER_ID_MAX_LENGTH, getNamespacedData, normalizeServerId };
@@ -1,34 +1,34 @@
1
1
  import {
2
- At as McpAgent,
3
- Bt as WorkerTransportOptions,
4
- Ct as RPCClientTransportOptions,
5
- Dt as ElicitRequest,
6
- Et as RPC_DO_PREFIX,
7
- Ft as experimental_createMcpHandler,
8
- Ht as StreamableHTTPEdgeClientTransport,
9
- It as McpAuthContext,
10
- Lt as getMcpAuthContext,
11
- Mt as DurableObjectEventStore,
12
- Nt as CreateMcpHandlerOptions,
13
- Ot as ElicitRequestSchema,
14
- Pt as createMcpHandler,
15
- Rt as TransportState,
16
- St as RPCClientTransport,
17
- Tt as RPCServerTransportOptions,
18
- Ut as McpClientOptions,
19
- Vt as SSEEdgeClientTransport,
20
- _t as MCPServerOptions,
21
- dt as MCPClientOAuthCallbackConfig,
22
- ft as MCPClientOAuthResult,
23
- jt as ClearableEventStore,
24
- kt as ElicitResult,
25
- mt as MCPDiscoverResult,
26
- pt as MCPConnectionResult,
27
- vt as MCP_SERVER_ID_MAX_LENGTH,
28
- wt as RPCServerTransport,
29
- xt as normalizeServerId,
30
- zt as WorkerTransport
31
- } from "../agent-tool-types-CTw3UJUP.js";
2
+ $t as McpClientOptions,
3
+ Bt as McpAgent,
4
+ Ct as MCPConnectionResult,
5
+ Dt as MCPServerOptions,
6
+ Ft as RPCServerTransportOptions,
7
+ Gt as experimental_createMcpHandler,
8
+ Ht as DurableObjectEventStore,
9
+ It as RPC_DO_PREFIX,
10
+ Jt as TransportState,
11
+ Kt as McpAuthContext,
12
+ Lt as ElicitRequest,
13
+ Mt as RPCClientTransport,
14
+ Nt as RPCClientTransportOptions,
15
+ Ot as MCP_SERVER_ID_MAX_LENGTH,
16
+ Pt as RPCServerTransport,
17
+ Qt as StreamableHTTPEdgeClientTransport,
18
+ Rt as ElicitRequestSchema,
19
+ St as MCPClientOAuthResult,
20
+ Ut as CreateMcpHandlerOptions,
21
+ Vt as ClearableEventStore,
22
+ Wt as createMcpHandler,
23
+ Xt as WorkerTransportOptions,
24
+ Yt as WorkerTransport,
25
+ Zt as SSEEdgeClientTransport,
26
+ jt as normalizeServerId,
27
+ qt as getMcpAuthContext,
28
+ wt as MCPDiscoverResult,
29
+ xt as MCPClientOAuthCallbackConfig,
30
+ zt as ElicitResult
31
+ } from "../agent-tool-types-Cd1TZPfB.js";
32
32
  export {
33
33
  type ClearableEventStore,
34
34
  type CreateMcpHandlerOptions,
package/dist/mcp/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import "../types.js";
2
- import { c as RPC_DO_PREFIX, i as normalizeServerId, n as MCP_SERVER_ID_MAX_LENGTH, o as RPCClientTransport, s as RPCServerTransport } from "../client-BXJ9n2f7.js";
2
+ import { c as RPC_DO_PREFIX, i as normalizeServerId, n as MCP_SERVER_ID_MAX_LENGTH, o as RPCClientTransport, s as RPCServerTransport } from "../client-BZ-B3NhC.js";
3
3
  import { Agent, getAgentByName, getCurrentAgent } from "../index.js";
4
4
  import { AsyncLocalStorage } from "node:async_hooks";
5
5
  import { SSEClientTransport } from "@modelcontextprotocol/sdk/client/sse.js";
@@ -588,6 +588,7 @@ var StreamableHTTPServerTransport = class {
588
588
  this._streamResponseIds = /* @__PURE__ */ new Map();
589
589
  const { agent } = getCurrentAgent();
590
590
  if (!agent) throw new Error("McpAgent was not found in Transport constructor");
591
+ this._agent = agent;
591
592
  this.sessionId = agent.getSessionId();
592
593
  this._eventStore = options.eventStore;
593
594
  }
@@ -747,8 +748,7 @@ var StreamableHTTPServerTransport = class {
747
748
  }
748
749
  }
749
750
  async close() {
750
- const { agent } = getCurrentAgent();
751
- if (!agent) throw new Error("Agent was not found in close");
751
+ const agent = this._agent;
752
752
  for (const conn of agent.getConnections()) conn.close(1e3, "Session closed");
753
753
  this.onclose?.();
754
754
  }
@@ -803,8 +803,7 @@ var StreamableHTTPServerTransport = class {
803
803
  * there is at most one to send on.
804
804
  */
805
805
  async sendStandalone(message) {
806
- const { agent } = getCurrentAgent();
807
- if (!agent) throw new Error("Agent was not found in send");
806
+ const agent = this._agent;
808
807
  const eventId = await this._eventStore?.storeEvent(STANDALONE_STREAM_ID, message);
809
808
  const standalone = Array.from(agent.getConnections()).find((conn) => conn.state?._standaloneSse);
810
809
  if (standalone) this.writeSSEEvent(standalone, message, eventId);
@@ -817,8 +816,9 @@ var StreamableHTTPServerTransport = class {
817
816
  * {@link sendOnStream} for the actual store / write / cleanup.
818
817
  */
819
818
  async sendForRequest(message, requestId) {
820
- const { agent, connection: originatingConnection } = getCurrentAgent();
821
- if (!agent) throw new Error("Agent was not found in send");
819
+ const agent = this._agent;
820
+ const context = getCurrentAgent();
821
+ const originatingConnection = context.agent === agent ? context.connection : void 0;
822
822
  const matchingConnections = Array.from(agent.getConnections()).filter((conn) => conn.state?.requestIds?.includes(requestId));
823
823
  const liveConnection = matchingConnections.find((conn) => conn.id === originatingConnection?.id) ?? (matchingConnections.length === 1 ? matchingConnections[0] : null);
824
824
  if (!liveConnection && matchingConnections.length > 1) {