agents 0.19.0 → 0.20.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 (49) hide show
  1. package/README.md +24 -19
  2. package/dist/{agent-tool-types-BNUGGBzQ.d.ts → agent-tool-types-Btk9ETS-.d.ts} +997 -356
  3. package/dist/agent-tool-types.d.ts +1 -1
  4. package/dist/{agent-tools-BFbzVLFc.d.ts → agent-tools-UuScsJg3.d.ts} +2 -2
  5. package/dist/agent-tools.d.ts +1 -1
  6. package/dist/browser/ai.js +1 -1
  7. package/dist/browser/index.js +1 -1
  8. package/dist/chat/index.d.ts +2 -2
  9. package/dist/chat-sdk/index.d.ts +1 -1
  10. package/dist/client-invoker-BNSZxAkv.d.ts +20 -0
  11. package/dist/client-invoker-VNZ7X0nn.js +57 -0
  12. package/dist/client-invoker-VNZ7X0nn.js.map +1 -0
  13. package/dist/{client-CcjiFpTf.js → client-zqKcsyFa.js} +434 -168
  14. package/dist/client-zqKcsyFa.js.map +1 -0
  15. package/dist/client.d.ts +1 -1
  16. package/dist/{connector-CdldGF3h.js → connector-KEJnl6e5.js} +2 -2
  17. package/dist/connector-KEJnl6e5.js.map +1 -0
  18. package/dist/{do-oauth-client-provider-D4ZwyBDu.d.ts → do-oauth-client-provider-VTZj2VtM.d.ts} +23 -11
  19. package/dist/experimental/webmcp.js +1 -1
  20. package/dist/handler-stateless-8hQN_kC3.js +367 -0
  21. package/dist/handler-stateless-8hQN_kC3.js.map +1 -0
  22. package/dist/handler-stateless-C_bo-Ytq.d.ts +107 -0
  23. package/dist/index.d.ts +12 -12
  24. package/dist/index.js +3 -2
  25. package/dist/index.js.map +1 -1
  26. package/dist/mcp/client.d.ts +22 -18
  27. package/dist/mcp/client.js +1 -1
  28. package/dist/mcp/do-oauth-client-provider.d.ts +1 -1
  29. package/dist/mcp/do-oauth-client-provider.js +25 -12
  30. package/dist/mcp/do-oauth-client-provider.js.map +1 -1
  31. package/dist/mcp/index.d.ts +48 -34
  32. package/dist/mcp/index.js +84 -79
  33. package/dist/mcp/index.js.map +1 -1
  34. package/dist/mcp/server.d.ts +17 -0
  35. package/dist/mcp/server.js +2 -0
  36. package/dist/mcp/x402.d.ts +21 -9
  37. package/dist/mcp/x402.js +8 -7
  38. package/dist/mcp/x402.js.map +1 -1
  39. package/dist/react.d.ts +1 -1
  40. package/dist/serializable.d.ts +1 -1
  41. package/dist/sub-routing.d.ts +6 -6
  42. package/dist/workflows.d.ts +1 -1
  43. package/docs/human-in-the-loop.md +63 -82
  44. package/docs/mcp-client.md +31 -7
  45. package/docs/mcp-servers.md +125 -88
  46. package/docs/securing-mcp-servers.md +9 -6
  47. package/package.json +28 -7
  48. package/dist/client-CcjiFpTf.js.map +0 -1
  49. package/dist/connector-CdldGF3h.js.map +0 -1
@@ -24,7 +24,7 @@ import {
24
24
  w as RunAgentToolOptions,
25
25
  x as ChatCapableAgentClass,
26
26
  y as AgentToolStoredChunk
27
- } from "./agent-tool-types-BNUGGBzQ.js";
27
+ } from "./agent-tool-types-Btk9ETS-.js";
28
28
  export {
29
29
  AGENT_TOOL_MILESTONE_PART,
30
30
  AGENT_TOOL_PROGRESS_PART,
@@ -4,7 +4,7 @@ import {
4
4
  o as AgentToolEventMessage,
5
5
  s as AgentToolEventState,
6
6
  y as AgentToolStoredChunk
7
- } from "./agent-tool-types-BNUGGBzQ.js";
7
+ } from "./agent-tool-types-Btk9ETS-.js";
8
8
 
9
9
  //#region src/chat/agent-tools.d.ts
10
10
  type AgentToolProgressEmitResult = "emitted" | "coalesced" | "inactive";
@@ -130,4 +130,4 @@ export {
130
130
  interceptAgentToolBroadcast as s,
131
131
  AgentToolBroadcastHooks as t
132
132
  };
133
- //# sourceMappingURL=agent-tools-BFbzVLFc.d.ts.map
133
+ //# sourceMappingURL=agent-tools-UuScsJg3.d.ts.map
@@ -19,7 +19,7 @@ import {
19
19
  w as RunAgentToolOptions,
20
20
  x as ChatCapableAgentClass,
21
21
  y as AgentToolStoredChunk
22
- } from "./agent-tool-types-BNUGGBzQ.js";
22
+ } from "./agent-tool-types-Btk9ETS-.js";
23
23
  import { Tool } from "ai";
24
24
 
25
25
  //#region src/agent-tools.d.ts
@@ -1,5 +1,5 @@
1
1
  import { __DO_NOT_USE_WILL_BREAK__agentContext } from "../internal_context.js";
2
- import { c as browserLinks, d as browserScrape, i as DurableBrowserSessionStore, l as browserMarkdown, o as browserContent, s as browserExtract, t as BrowserConnector } from "../connector-CdldGF3h.js";
2
+ import { c as browserLinks, d as browserScrape, i as DurableBrowserSessionStore, l as browserMarkdown, o as browserContent, s as browserExtract, t as BrowserConnector } from "../connector-KEJnl6e5.js";
3
3
  import { tool } from "ai";
4
4
  import { z } from "zod";
5
5
  import { DynamicWorkerExecutor, createCodemodeRuntime, truncateResult } from "@cloudflare/codemode";
@@ -1,3 +1,3 @@
1
- import { C as connectUrl, S as CdpSession, _ as connectBrowserSession, a as loadCdpSpec, b as getBrowserRecording, c as browserLinks, d as browserScrape, f as browserScreenshot, g as connectBrowser, h as BrowserRenderingError, i as DurableBrowserSessionStore, l as browserMarkdown, m as runQuickAction, n as DEFAULT_EXEC_SWEEP_IDLE_MS, o as browserContent, p as browserSnapshot, r as DEFAULT_SWEEP_IDLE_MS, s as browserExtract, t as BrowserConnector, u as browserPdf, v as createBrowserSession, x as listBrowserTargets, y as deleteBrowserSession } from "../connector-CdldGF3h.js";
1
+ import { C as connectUrl, S as CdpSession, _ as connectBrowserSession, a as loadCdpSpec, b as getBrowserRecording, c as browserLinks, d as browserScrape, f as browserScreenshot, g as connectBrowser, h as BrowserRenderingError, i as DurableBrowserSessionStore, l as browserMarkdown, m as runQuickAction, n as DEFAULT_EXEC_SWEEP_IDLE_MS, o as browserContent, p as browserSnapshot, r as DEFAULT_SWEEP_IDLE_MS, s as browserExtract, t as BrowserConnector, u as browserPdf, v as createBrowserSession, x as listBrowserTargets, y as deleteBrowserSession } from "../connector-KEJnl6e5.js";
2
2
  import { CodemodeRuntime } from "@cloudflare/codemode";
3
3
  export { BrowserConnector, BrowserRenderingError, CdpSession, CodemodeRuntime, DEFAULT_EXEC_SWEEP_IDLE_MS, DEFAULT_SWEEP_IDLE_MS, DurableBrowserSessionStore, browserContent, browserExtract, browserLinks, browserMarkdown, browserPdf, browserScrape, browserScreenshot, browserSnapshot, connectBrowser, connectBrowserSession, connectUrl, createBrowserSession, deleteBrowserSession, getBrowserRecording, listBrowserTargets, loadCdpSpec, runQuickAction };
@@ -4,7 +4,7 @@ import {
4
4
  a as AgentToolEvent,
5
5
  o as AgentToolEventMessage,
6
6
  s as AgentToolEventState
7
- } from "../agent-tool-types-BNUGGBzQ.js";
7
+ } from "../agent-tool-types-Btk9ETS-.js";
8
8
  import {
9
9
  n as ClientToolSchema,
10
10
  r as createToolsFromClientSchemas,
@@ -18,7 +18,7 @@ import {
18
18
  r as AgentToolProgressEmitResult,
19
19
  s as interceptAgentToolBroadcast,
20
20
  t as AgentToolBroadcastHooks
21
- } from "../agent-tools-BFbzVLFc.js";
21
+ } from "../agent-tools-UuScsJg3.js";
22
22
  import { JSONSchema7, UIMessage } from "ai";
23
23
  import { Connection } from "agents";
24
24
 
@@ -2,7 +2,7 @@ import {
2
2
  O as Agent,
3
3
  ct as SubAgentClass,
4
4
  lt as SubAgentStub
5
- } from "../agent-tool-types-BNUGGBzQ.js";
5
+ } from "../agent-tool-types-Btk9ETS-.js";
6
6
  import { Lock, QueueEntry, StateAdapter } from "chat";
7
7
 
8
8
  //#region src/chat-sdk/agent.d.ts
@@ -0,0 +1,20 @@
1
+ import {
2
+ CallToolRequest,
3
+ CallToolRequestOptions,
4
+ Client
5
+ } from "@modelcontextprotocol/client";
6
+ import {
7
+ CallToolResult,
8
+ CallToolResultSchema,
9
+ CompatibilityCallToolResultSchema
10
+ } from "@modelcontextprotocol/sdk/types.js";
11
+ import { Client as Client$1 } from "@modelcontextprotocol/sdk/client/index.js";
12
+
13
+ //#region src/mcp/client-invoker.d.ts
14
+ type LegacyCallToolResultSchema =
15
+ | typeof CallToolResultSchema
16
+ | typeof CompatibilityCallToolResultSchema;
17
+ type CompatibleMcpClient = Client | Client$1;
18
+ //#endregion
19
+ export { LegacyCallToolResultSchema as n, CompatibleMcpClient as t };
20
+ //# sourceMappingURL=client-invoker-BNSZxAkv.d.ts.map
@@ -0,0 +1,57 @@
1
+ //#region src/mcp/client-invoker.ts
2
+ function isLegacyResultSchema(value) {
3
+ return typeof value?.parse === "function";
4
+ }
5
+ function normalizeCallToolArguments(schemaOrOptions, options) {
6
+ return isLegacyResultSchema(schemaOrOptions) ? {
7
+ schema: schemaOrOptions,
8
+ options
9
+ } : { options: schemaOrOptions ?? options };
10
+ }
11
+ /**
12
+ * Invoke SDK v2 while preserving the deprecated v1 result-schema overload.
13
+ * The v2 request funnel still owns decoding and automatic MRTR.
14
+ */
15
+ function callV2Tool(client, params, schemaOrOptions, options) {
16
+ const normalized = normalizeCallToolArguments(schemaOrOptions, options);
17
+ if (normalized.schema) return client.request({
18
+ method: "tools/call",
19
+ params
20
+ }, normalized.schema, normalized.options);
21
+ return client.callTool(params, normalized.options);
22
+ }
23
+ /**
24
+ * Bind the original methods before decorators such as x402 replace them. All
25
+ * generation-specific calling conventions stay behind this small interface.
26
+ */
27
+ function bindMcpClient(client) {
28
+ if ("getProtocolEra" in client && typeof client.getProtocolEra === "function") {
29
+ const v2Client = client;
30
+ const listTools = v2Client.listTools.bind(v2Client);
31
+ const callTool = v2Client.callTool.bind(v2Client);
32
+ return {
33
+ listTools: (params, options) => listTools(params, options),
34
+ callTool: (params, schemaOrOptions, options) => {
35
+ const normalized = normalizeCallToolArguments(schemaOrOptions, options);
36
+ return normalized.schema ? v2Client.request({
37
+ method: "tools/call",
38
+ params
39
+ }, normalized.schema, normalized.options) : callTool(params, normalized.options);
40
+ }
41
+ };
42
+ }
43
+ const legacy = client;
44
+ const listTools = legacy.listTools.bind(legacy);
45
+ const callTool = legacy.callTool.bind(legacy);
46
+ return {
47
+ listTools: (params, options) => listTools(params, options),
48
+ callTool: (params, schemaOrOptions, options) => {
49
+ const normalized = normalizeCallToolArguments(schemaOrOptions, options);
50
+ return callTool(params, normalized.schema, normalized.options);
51
+ }
52
+ };
53
+ }
54
+ //#endregion
55
+ export { callV2Tool as n, bindMcpClient as t };
56
+
57
+ //# sourceMappingURL=client-invoker-VNZ7X0nn.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client-invoker-VNZ7X0nn.js","names":[],"sources":["../src/mcp/client-invoker.ts"],"sourcesContent":["import type {\n CallToolRequest,\n CallToolRequestOptions,\n CallToolResult,\n Client,\n ListToolsResult\n} from \"@modelcontextprotocol/client\";\nimport type { Client as LegacyClient } from \"@modelcontextprotocol/sdk/client/index.js\";\nimport type {\n CallToolResult as LegacyCallToolResult,\n CallToolResultSchema,\n CompatibilityCallToolResultSchema,\n ListToolsRequest\n} from \"@modelcontextprotocol/sdk/types.js\";\nimport type { RequestOptions as LegacyRequestOptions } from \"@modelcontextprotocol/sdk/shared/protocol.js\";\n\nexport type LegacyCallToolResultSchema =\n | typeof CallToolResultSchema\n | typeof CompatibilityCallToolResultSchema;\n\nexport type CallToolSchemaOrOptions =\n | LegacyCallToolResultSchema\n | CallToolRequestOptions;\n\nexport type CompatibleMcpClient = Client | LegacyClient;\n\nexport interface BoundMcpClientInvoker {\n listTools(\n params?: ListToolsRequest[\"params\"],\n options?: CallToolRequestOptions\n ): Promise<ListToolsResult>;\n callTool(\n params: CallToolRequest[\"params\"],\n schemaOrOptions?: CallToolSchemaOrOptions,\n options?: CallToolRequestOptions\n ): Promise<LegacyCallToolResult>;\n}\n\nfunction isLegacyResultSchema(\n value: CallToolSchemaOrOptions | undefined\n): value is LegacyCallToolResultSchema {\n return (\n typeof (value as { parse?: unknown } | undefined)?.parse === \"function\"\n );\n}\n\nfunction normalizeCallToolArguments(\n schemaOrOptions?: CallToolSchemaOrOptions,\n options?: CallToolRequestOptions\n): {\n schema?: LegacyCallToolResultSchema;\n options?: CallToolRequestOptions;\n} {\n return isLegacyResultSchema(schemaOrOptions)\n ? { schema: schemaOrOptions, options }\n : { options: schemaOrOptions ?? options };\n}\n\n/**\n * Invoke SDK v2 while preserving the deprecated v1 result-schema overload.\n * The v2 request funnel still owns decoding and automatic MRTR.\n */\nexport function callV2Tool(\n client: Client,\n params: CallToolRequest[\"params\"],\n schemaOrOptions?: CallToolSchemaOrOptions,\n options?: CallToolRequestOptions\n): Promise<CallToolResult> {\n const normalized = normalizeCallToolArguments(schemaOrOptions, options);\n if (normalized.schema) {\n return client.request(\n { method: \"tools/call\", params },\n normalized.schema as never,\n normalized.options\n ) as Promise<CallToolResult>;\n }\n return client.callTool(params, normalized.options);\n}\n\n/**\n * Bind the original methods before decorators such as x402 replace them. All\n * generation-specific calling conventions stay behind this small interface.\n */\nexport function bindMcpClient(\n client: CompatibleMcpClient\n): BoundMcpClientInvoker {\n const isV2 =\n \"getProtocolEra\" in client &&\n typeof (client as { getProtocolEra?: unknown }).getProtocolEra ===\n \"function\";\n\n if (isV2) {\n const v2Client = client as Client;\n const listTools = v2Client.listTools.bind(v2Client);\n const callTool = v2Client.callTool.bind(v2Client);\n return {\n listTools: (params, options) => listTools(params, options),\n callTool: (params, schemaOrOptions, options) => {\n const normalized = normalizeCallToolArguments(schemaOrOptions, options);\n const pending = normalized.schema\n ? v2Client.request(\n { method: \"tools/call\", params },\n normalized.schema as never,\n normalized.options\n )\n : callTool(params, normalized.options);\n return pending as Promise<LegacyCallToolResult>;\n }\n };\n }\n\n const legacy = client as LegacyClient;\n const listTools = legacy.listTools.bind(legacy);\n const callTool = legacy.callTool.bind(legacy);\n return {\n listTools: (params, options) =>\n listTools(\n params,\n options as LegacyRequestOptions\n ) as Promise<ListToolsResult>,\n callTool: (params, schemaOrOptions, options) => {\n const normalized = normalizeCallToolArguments(schemaOrOptions, options);\n return callTool(\n params as Parameters<LegacyClient[\"callTool\"]>[0],\n normalized.schema,\n normalized.options as LegacyRequestOptions\n ) as Promise<LegacyCallToolResult>;\n }\n };\n}\n"],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