agents 0.0.0-d4257c1 → 0.0.0-d520fe8

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 (62) hide show
  1. package/README.md +5 -3
  2. package/dist/ai-chat-agent.d.ts +86 -13
  3. package/dist/ai-chat-agent.js +340 -74
  4. package/dist/ai-chat-agent.js.map +1 -1
  5. package/dist/{ai-chat-v5-migration-gdyLiTd8.js → ai-chat-v5-migration-BSiGZmYU.js} +2 -2
  6. package/dist/{ai-chat-v5-migration-gdyLiTd8.js.map → ai-chat-v5-migration-BSiGZmYU.js.map} +1 -1
  7. package/dist/ai-chat-v5-migration.js +1 -1
  8. package/dist/ai-react.d.ts +14 -9
  9. package/dist/ai-react.js +172 -36
  10. package/dist/ai-react.js.map +1 -1
  11. package/dist/{ai-types-BWW4umHY.d.ts → ai-types-81H_-Uxh.d.ts} +16 -8
  12. package/dist/{ai-types-UZlfLOYP.js → ai-types-CrMqkwc_.js} +6 -2
  13. package/dist/ai-types-CrMqkwc_.js.map +1 -0
  14. package/dist/ai-types.d.ts +4 -4
  15. package/dist/ai-types.js +1 -1
  16. package/dist/cli.d.ts +8 -0
  17. package/dist/cli.js +27 -0
  18. package/dist/cli.js.map +1 -0
  19. package/dist/{client-DjR-lC16.js → client-B3SR12TQ.js} +3 -3
  20. package/dist/{client-DjR-lC16.js.map → client-B3SR12TQ.js.map} +1 -1
  21. package/dist/{client-CmMi85Sj.d.ts → client-BAQA84dr.d.ts} +10 -10
  22. package/dist/client-BZq9qau2.js +1093 -0
  23. package/dist/client-BZq9qau2.js.map +1 -0
  24. package/dist/client-CsaP9Irq.d.ts +1528 -0
  25. package/dist/client.d.ts +8 -8
  26. package/dist/client.js +2 -2
  27. package/dist/codemode/ai.js +5 -5
  28. package/dist/{do-oauth-client-provider-CCwGwnrA.d.ts → do-oauth-client-provider-C2CHH5x-.d.ts} +2 -2
  29. package/dist/{do-oauth-client-provider-B2jr6UNq.js → do-oauth-client-provider-CwqK5SXm.js} +3 -2
  30. package/dist/do-oauth-client-provider-CwqK5SXm.js.map +1 -0
  31. package/dist/{index-W4JUkafc.d.ts → index-BUle9RiP.d.ts} +7 -3
  32. package/dist/{index-CkQU40oY.d.ts → index-Bx5KK3VJ.d.ts} +75 -46
  33. package/dist/index.d.ts +36 -36
  34. package/dist/index.js +5 -5
  35. package/dist/mcp/client.d.ts +4 -4
  36. package/dist/mcp/client.js +2 -1
  37. package/dist/mcp/do-oauth-client-provider.d.ts +1 -1
  38. package/dist/mcp/do-oauth-client-provider.js +1 -1
  39. package/dist/mcp/index.d.ts +129 -11
  40. package/dist/mcp/index.js +632 -32
  41. package/dist/mcp/index.js.map +1 -1
  42. package/dist/mcp/x402.js +10 -6
  43. package/dist/mcp/x402.js.map +1 -1
  44. package/dist/{mcp-BEwaCsxO.d.ts → mcp-BwPscEiF.d.ts} +2 -2
  45. package/dist/observability/index.d.ts +2 -2
  46. package/dist/observability/index.js +5 -5
  47. package/dist/{react-B4e1rDid.d.ts → react-CbwD4fBf.d.ts} +17 -17
  48. package/dist/react.d.ts +9 -9
  49. package/dist/react.js +2 -2
  50. package/dist/react.js.map +1 -1
  51. package/dist/{serializable-gtr9YMhp.d.ts → serializable-faDkMCai.d.ts} +8 -3
  52. package/dist/serializable.d.ts +5 -5
  53. package/dist/{src-COfG--3R.js → src-D_KKH_4c.js} +125 -120
  54. package/dist/src-D_KKH_4c.js.map +1 -0
  55. package/package.json +55 -40
  56. package/dist/ai-types-UZlfLOYP.js.map +0 -1
  57. package/dist/client-C-nwz-3N.d.ts +0 -5313
  58. package/dist/client-CZBVDDoO.js +0 -786
  59. package/dist/client-CZBVDDoO.js.map +0 -1
  60. package/dist/do-oauth-client-provider-B2jr6UNq.js.map +0 -1
  61. package/dist/src-COfG--3R.js.map +0 -1
  62. package/src/index.ts +0 -2031
package/dist/client.d.ts CHANGED
@@ -1,12 +1,12 @@
1
- import "./serializable-gtr9YMhp.js";
1
+ import "./serializable-faDkMCai.js";
2
2
  import {
3
- AgentClient,
4
- AgentClientFetchOptions,
5
- AgentClientOptions,
6
- StreamOptions,
7
- agentFetch,
8
- camelCaseToKebabCase
9
- } from "./client-CmMi85Sj.js";
3
+ a as agentFetch,
4
+ i as StreamOptions,
5
+ n as AgentClientFetchOptions,
6
+ o as camelCaseToKebabCase,
7
+ r as AgentClientOptions,
8
+ t as AgentClient
9
+ } from "./client-BAQA84dr.js";
10
10
  export {
11
11
  AgentClient,
12
12
  AgentClientFetchOptions,
package/dist/client.js CHANGED
@@ -1,4 +1,4 @@
1
- import "./ai-types-UZlfLOYP.js";
2
- import { AgentClient, agentFetch, camelCaseToKebabCase } from "./client-DjR-lC16.js";
1
+ import "./ai-types-CrMqkwc_.js";
2
+ import { n as agentFetch, r as camelCaseToKebabCase, t as AgentClient } from "./client-B3SR12TQ.js";
3
3
 
4
4
  export { AgentClient, agentFetch, camelCaseToKebabCase };
@@ -1,8 +1,8 @@
1
- import "../ai-types-UZlfLOYP.js";
2
- import "../client-DjR-lC16.js";
3
- import "../client-CZBVDDoO.js";
4
- import "../do-oauth-client-provider-B2jr6UNq.js";
5
- import { getAgentByName } from "../src-COfG--3R.js";
1
+ import "../ai-types-CrMqkwc_.js";
2
+ import "../client-B3SR12TQ.js";
3
+ import "../client-BZq9qau2.js";
4
+ import "../do-oauth-client-provider-CwqK5SXm.js";
5
+ import { s as getAgentByName } from "../src-D_KKH_4c.js";
6
6
  import { generateObject, tool } from "ai";
7
7
  import { openai } from "@ai-sdk/openai";
8
8
  import { z } from "zod/v3";
@@ -51,5 +51,5 @@ declare class DurableObjectOAuthClientProvider implements AgentsOAuthProvider {
51
51
  codeVerifier(): Promise<string>;
52
52
  }
53
53
  //#endregion
54
- export { AgentsOAuthProvider, DurableObjectOAuthClientProvider };
55
- //# sourceMappingURL=do-oauth-client-provider-CCwGwnrA.d.ts.map
54
+ export { DurableObjectOAuthClientProvider as n, AgentsOAuthProvider as t };
55
+ //# sourceMappingURL=do-oauth-client-provider-C2CHH5x-.d.ts.map
@@ -6,6 +6,7 @@ var DurableObjectOAuthClientProvider = class {
6
6
  this.storage = storage;
7
7
  this.clientName = clientName;
8
8
  this.baseRedirectUrl = baseRedirectUrl;
9
+ if (!storage) throw new Error("DurableObjectOAuthClientProvider requires a valid DurableObjectStorage instance");
9
10
  }
10
11
  get clientMetadata() {
11
12
  return {
@@ -89,5 +90,5 @@ var DurableObjectOAuthClientProvider = class {
89
90
  };
90
91
 
91
92
  //#endregion
92
- export { DurableObjectOAuthClientProvider };
93
- //# sourceMappingURL=do-oauth-client-provider-B2jr6UNq.js.map
93
+ export { DurableObjectOAuthClientProvider as t };
94
+ //# sourceMappingURL=do-oauth-client-provider-CwqK5SXm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"do-oauth-client-provider-CwqK5SXm.js","names":["storage: DurableObjectStorage","clientName: string","baseRedirectUrl: string"],"sources":["../src/mcp/do-oauth-client-provider.ts"],"sourcesContent":["import type { OAuthClientProvider } from \"@modelcontextprotocol/sdk/client/auth.js\";\nimport type {\n OAuthClientInformation,\n OAuthClientInformationFull,\n OAuthClientMetadata,\n OAuthTokens\n} from \"@modelcontextprotocol/sdk/shared/auth.js\";\nimport { nanoid } from \"nanoid\";\n\n// A slight extension to the standard OAuthClientProvider interface because `redirectToAuthorization` doesn't give us the interface we need\n// This allows us to track authentication for a specific server and associated dynamic client registration\nexport interface AgentsOAuthProvider extends OAuthClientProvider {\n authUrl: string | undefined;\n clientId: string | undefined;\n serverId: string | undefined;\n}\n\nexport class DurableObjectOAuthClientProvider implements AgentsOAuthProvider {\n private _authUrl_: string | undefined;\n private _serverId_: string | undefined;\n private _clientId_: string | undefined;\n\n constructor(\n public storage: DurableObjectStorage,\n public clientName: string,\n public baseRedirectUrl: string\n ) {\n if (!storage) {\n throw new Error(\n \"DurableObjectOAuthClientProvider requires a valid DurableObjectStorage instance\"\n );\n }\n }\n\n get clientMetadata(): OAuthClientMetadata {\n return {\n client_name: this.clientName,\n client_uri: this.clientUri,\n grant_types: [\"authorization_code\", \"refresh_token\"],\n redirect_uris: [this.redirectUrl],\n response_types: [\"code\"],\n token_endpoint_auth_method: \"none\"\n };\n }\n\n get clientUri() {\n return new URL(this.redirectUrl).origin;\n }\n\n get redirectUrl() {\n return `${this.baseRedirectUrl}/${this.serverId}`;\n }\n\n get clientId() {\n if (!this._clientId_) {\n throw new Error(\"Trying to access clientId before it was set\");\n }\n return this._clientId_;\n }\n\n set clientId(clientId_: string) {\n this._clientId_ = clientId_;\n }\n\n get serverId() {\n if (!this._serverId_) {\n throw new Error(\"Trying to access serverId before it was set\");\n }\n return this._serverId_;\n }\n\n set serverId(serverId_: string) {\n this._serverId_ = serverId_;\n }\n\n keyPrefix(clientId: string) {\n return `/${this.clientName}/${this.serverId}/${clientId}`;\n }\n\n clientInfoKey(clientId: string) {\n return `${this.keyPrefix(clientId)}/client_info/`;\n }\n\n async clientInformation(): Promise<OAuthClientInformation | undefined> {\n if (!this._clientId_) {\n return undefined;\n }\n return (\n (await this.storage.get<OAuthClientInformation>(\n this.clientInfoKey(this.clientId)\n )) ?? undefined\n );\n }\n\n async saveClientInformation(\n clientInformation: OAuthClientInformationFull\n ): Promise<void> {\n await this.storage.put(\n this.clientInfoKey(clientInformation.client_id),\n clientInformation\n );\n this.clientId = clientInformation.client_id;\n }\n\n tokenKey(clientId: string) {\n return `${this.keyPrefix(clientId)}/token`;\n }\n\n async tokens(): Promise<OAuthTokens | undefined> {\n if (!this._clientId_) {\n return undefined;\n }\n return (\n (await this.storage.get<OAuthTokens>(this.tokenKey(this.clientId))) ??\n undefined\n );\n }\n\n async saveTokens(tokens: OAuthTokens): Promise<void> {\n await this.storage.put(this.tokenKey(this.clientId), tokens);\n }\n\n get authUrl() {\n return this._authUrl_;\n }\n\n /**\n * Because this operates on the server side (but we need browser auth), we send this url back to the user\n * and require user interact to initiate the redirect flow\n */\n async redirectToAuthorization(authUrl: URL): Promise<void> {\n // Generate secure random token for state parameter\n const stateToken = nanoid();\n authUrl.searchParams.set(\"state\", stateToken);\n this._authUrl_ = authUrl.toString();\n }\n\n codeVerifierKey(clientId: string) {\n return `${this.keyPrefix(clientId)}/code_verifier`;\n }\n\n async saveCodeVerifier(verifier: string): Promise<void> {\n const key = this.codeVerifierKey(this.clientId);\n\n // Don't overwrite existing verifier to preserve first PKCE verifier\n const existing = await this.storage.get<string>(key);\n if (existing) {\n return;\n }\n\n await this.storage.put(key, verifier);\n }\n\n async codeVerifier(): Promise<string> {\n const codeVerifier = await this.storage.get<string>(\n this.codeVerifierKey(this.clientId)\n );\n if (!codeVerifier) {\n throw new Error(\"No code verifier found\");\n }\n return codeVerifier;\n }\n}\n"],"mappings":";;;AAiBA,IAAa,mCAAb,MAA6E;CAK3E,YACE,AAAOA,SACP,AAAOC,YACP,AAAOC,iBACP;EAHO;EACA;EACA;AAEP,MAAI,CAAC,QACH,OAAM,IAAI,MACR,kFACD;;CAIL,IAAI,iBAAsC;AACxC,SAAO;GACL,aAAa,KAAK;GAClB,YAAY,KAAK;GACjB,aAAa,CAAC,sBAAsB,gBAAgB;GACpD,eAAe,CAAC,KAAK,YAAY;GACjC,gBAAgB,CAAC,OAAO;GACxB,4BAA4B;GAC7B;;CAGH,IAAI,YAAY;AACd,SAAO,IAAI,IAAI,KAAK,YAAY,CAAC;;CAGnC,IAAI,cAAc;AAChB,SAAO,GAAG,KAAK,gBAAgB,GAAG,KAAK;;CAGzC,IAAI,WAAW;AACb,MAAI,CAAC,KAAK,WACR,OAAM,IAAI,MAAM,8CAA8C;AAEhE,SAAO,KAAK;;CAGd,IAAI,SAAS,WAAmB;AAC9B,OAAK,aAAa;;CAGpB,IAAI,WAAW;AACb,MAAI,CAAC,KAAK,WACR,OAAM,IAAI,MAAM,8CAA8C;AAEhE,SAAO,KAAK;;CAGd,IAAI,SAAS,WAAmB;AAC9B,OAAK,aAAa;;CAGpB,UAAU,UAAkB;AAC1B,SAAO,IAAI,KAAK,WAAW,GAAG,KAAK,SAAS,GAAG;;CAGjD,cAAc,UAAkB;AAC9B,SAAO,GAAG,KAAK,UAAU,SAAS,CAAC;;CAGrC,MAAM,oBAAiE;AACrE,MAAI,CAAC,KAAK,WACR;AAEF,SACG,MAAM,KAAK,QAAQ,IAClB,KAAK,cAAc,KAAK,SAAS,CAClC,IAAK;;CAIV,MAAM,sBACJ,mBACe;AACf,QAAM,KAAK,QAAQ,IACjB,KAAK,cAAc,kBAAkB,UAAU,EAC/C,kBACD;AACD,OAAK,WAAW,kBAAkB;;CAGpC,SAAS,UAAkB;AACzB,SAAO,GAAG,KAAK,UAAU,SAAS,CAAC;;CAGrC,MAAM,SAA2C;AAC/C,MAAI,CAAC,KAAK,WACR;AAEF,SACG,MAAM,KAAK,QAAQ,IAAiB,KAAK,SAAS,KAAK,SAAS,CAAC,IAClE;;CAIJ,MAAM,WAAW,QAAoC;AACnD,QAAM,KAAK,QAAQ,IAAI,KAAK,SAAS,KAAK,SAAS,EAAE,OAAO;;CAG9D,IAAI,UAAU;AACZ,SAAO,KAAK;;;;;;CAOd,MAAM,wBAAwB,SAA6B;EAEzD,MAAM,aAAa,QAAQ;AAC3B,UAAQ,aAAa,IAAI,SAAS,WAAW;AAC7C,OAAK,YAAY,QAAQ,UAAU;;CAGrC,gBAAgB,UAAkB;AAChC,SAAO,GAAG,KAAK,UAAU,SAAS,CAAC;;CAGrC,MAAM,iBAAiB,UAAiC;EACtD,MAAM,MAAM,KAAK,gBAAgB,KAAK,SAAS;AAI/C,MADiB,MAAM,KAAK,QAAQ,IAAY,IAAI,CAElD;AAGF,QAAM,KAAK,QAAQ,IAAI,KAAK,SAAS;;CAGvC,MAAM,eAAgC;EACpC,MAAM,eAAe,MAAM,KAAK,QAAQ,IACtC,KAAK,gBAAgB,KAAK,SAAS,CACpC;AACD,MAAI,CAAC,aACH,OAAM,IAAI,MAAM,yBAAyB;AAE3C,SAAO"}
@@ -1,4 +1,4 @@
1
- import { BaseEvent, MCPObservabilityEvent } from "./mcp-BEwaCsxO.js";
1
+ import { n as BaseEvent, t as MCPObservabilityEvent } from "./mcp-BwPscEiF.js";
2
2
 
3
3
  //#region src/observability/agent.d.ts
4
4
 
@@ -50,5 +50,9 @@ interface Observability {
50
50
  */
51
51
  declare const genericObservability: Observability;
52
52
  //#endregion
53
- export { Observability, ObservabilityEvent, genericObservability };
54
- //# sourceMappingURL=index-W4JUkafc.d.ts.map
53
+ export {
54
+ ObservabilityEvent as n,
55
+ genericObservability as r,
56
+ Observability as t
57
+ };
58
+ //# sourceMappingURL=index-BUle9RiP.d.ts.map
@@ -1,10 +1,10 @@
1
1
  import {
2
- MCPClientManager,
3
- MCPConnectionState,
4
- TransportType
5
- } from "./client-C-nwz-3N.js";
6
- import { Observability } from "./index-W4JUkafc.js";
7
- import { MessageType } from "./ai-types-BWW4umHY.js";
2
+ h as TransportType,
3
+ t as MCPClientManager,
4
+ u as MCPConnectionState
5
+ } from "./client-CsaP9Irq.js";
6
+ import { t as Observability } from "./index-BUle9RiP.js";
7
+ import { n as MessageType } from "./ai-types-81H_-Uxh.js";
8
8
  import {
9
9
  Connection,
10
10
  Connection as Connection$1,
@@ -139,9 +139,15 @@ type MCPServersState = {
139
139
  servers: {
140
140
  [id: string]: MCPServer;
141
141
  };
142
- tools: Tool[];
143
- prompts: Prompt[];
144
- resources: Resource[];
142
+ tools: (Tool & {
143
+ serverId: string;
144
+ })[];
145
+ prompts: (Prompt & {
146
+ serverId: string;
147
+ })[];
148
+ resources: (Resource & {
149
+ serverId: string;
150
+ })[];
145
151
  };
146
152
  type MCPServer = {
147
153
  name: string;
@@ -171,6 +177,7 @@ declare class Agent<
171
177
  > extends Server<Env, Props> {
172
178
  private _state;
173
179
  private _disposables;
180
+ private _destroyed;
174
181
  private _ParentClass;
175
182
  readonly mcp: MCPClientManager;
176
183
  /**
@@ -354,7 +361,8 @@ declare class Agent<
354
361
  * @param callbackHost Base host for the agent, used for the redirect URI. If not provided, will be derived from the current request.
355
362
  * @param agentsPrefix agents routing prefix if not using `agents`
356
363
  * @param options MCP client and transport options
357
- * @returns authUrl
364
+ * @returns Server id and state - either "authenticating" with authUrl, or "ready"
365
+ * @throws If connection or discovery fails
358
366
  */
359
367
  addMcpServer(
360
368
  serverName: string,
@@ -368,14 +376,35 @@ declare class Agent<
368
376
  type?: TransportType;
369
377
  };
370
378
  }
371
- ): Promise<{
372
- id: string;
373
- authUrl: string | undefined;
374
- }>;
375
- private _connectToMcpServerInternal;
379
+ ): Promise<
380
+ | {
381
+ id: string;
382
+ state: typeof MCPConnectionState.AUTHENTICATING;
383
+ authUrl: string;
384
+ }
385
+ | {
386
+ id: string;
387
+ state: typeof MCPConnectionState.READY;
388
+ authUrl?: undefined;
389
+ }
390
+ >;
376
391
  removeMcpServer(id: string): Promise<void>;
377
392
  getMcpServers(): MCPServersState;
378
393
  private broadcastMcpServers;
394
+ /**
395
+ * Handle MCP OAuth callback request if it's an OAuth callback.
396
+ *
397
+ * This method encapsulates the entire OAuth callback flow:
398
+ * 1. Checks if the request is an MCP OAuth callback
399
+ * 2. Processes the OAuth code exchange
400
+ * 3. Establishes the connection if successful
401
+ * 4. Broadcasts MCP server state updates
402
+ * 5. Returns the appropriate HTTP response
403
+ *
404
+ * @param request The incoming HTTP request
405
+ * @returns Response if this was an OAuth callback, null otherwise
406
+ */
407
+ private handleMcpOAuthCallback;
379
408
  /**
380
409
  * Handle OAuth callback response using MCPClientManager configuration
381
410
  * @param result OAuth callback result
@@ -524,35 +553,35 @@ declare class StreamingResponse {
524
553
  }
525
554
  //#endregion
526
555
  export {
527
- Agent,
528
- AgentContext,
529
- AgentEmail,
530
- AgentNamespace,
531
- AgentOptions,
532
- CallableMetadata,
533
- type Connection$1 as Connection,
534
- type ConnectionContext,
535
- EmailResolver,
536
- EmailRoutingOptions,
537
- EmailSendOptions,
538
- MCPServer,
539
- MCPServerMessage,
540
- MCPServersState,
541
- QueueItem,
542
- RPCRequest,
543
- RPCResponse,
544
- Schedule,
545
- StateUpdateMessage,
546
- StreamingResponse,
547
- type WSMessage,
548
- callable,
549
- createAddressBasedEmailResolver,
550
- createCatchAllEmailResolver,
551
- createHeaderBasedEmailResolver,
552
- getAgentByName,
553
- getCurrentAgent,
554
- routeAgentEmail,
555
- routeAgentRequest,
556
- unstable_callable
556
+ unstable_callable as A,
557
+ createAddressBasedEmailResolver as C,
558
+ getCurrentAgent as D,
559
+ getAgentByName as E,
560
+ routeAgentEmail as O,
561
+ callable as S,
562
+ createHeaderBasedEmailResolver as T,
563
+ RPCResponse as _,
564
+ AgentOptions as a,
565
+ StreamingResponse as b,
566
+ ConnectionContext as c,
567
+ EmailSendOptions as d,
568
+ MCPServer as f,
569
+ RPCRequest as g,
570
+ QueueItem as h,
571
+ AgentNamespace as i,
572
+ routeAgentRequest as k,
573
+ EmailResolver as l,
574
+ MCPServersState as m,
575
+ AgentContext as n,
576
+ CallableMetadata as o,
577
+ MCPServerMessage as p,
578
+ AgentEmail as r,
579
+ Connection$1 as s,
580
+ Agent as t,
581
+ EmailRoutingOptions as u,
582
+ Schedule as v,
583
+ createCatchAllEmailResolver as w,
584
+ WSMessage as x,
585
+ StateUpdateMessage as y
557
586
  };
558
- //# sourceMappingURL=index-CkQU40oY.d.ts.map
587
+ //# sourceMappingURL=index-Bx5KK3VJ.d.ts.map
package/dist/index.d.ts CHANGED
@@ -1,40 +1,40 @@
1
- import { TransportType } from "./client-C-nwz-3N.js";
2
- import "./mcp-BEwaCsxO.js";
3
- import "./do-oauth-client-provider-CCwGwnrA.js";
4
- import "./index-W4JUkafc.js";
5
- import "./ai-types-BWW4umHY.js";
1
+ import { h as TransportType } from "./client-CsaP9Irq.js";
2
+ import "./mcp-BwPscEiF.js";
3
+ import "./do-oauth-client-provider-C2CHH5x-.js";
4
+ import "./index-BUle9RiP.js";
5
+ import "./ai-types-81H_-Uxh.js";
6
6
  import {
7
- Agent,
8
- AgentContext,
9
- AgentEmail,
10
- AgentNamespace,
11
- AgentOptions,
12
- CallableMetadata,
13
- Connection,
14
- ConnectionContext,
15
- EmailResolver,
16
- EmailRoutingOptions,
17
- EmailSendOptions,
18
- MCPServer,
19
- MCPServerMessage,
20
- MCPServersState,
21
- QueueItem,
22
- RPCRequest,
23
- RPCResponse,
24
- Schedule,
25
- StateUpdateMessage,
26
- StreamingResponse,
27
- WSMessage,
28
- callable,
29
- createAddressBasedEmailResolver,
30
- createCatchAllEmailResolver,
31
- createHeaderBasedEmailResolver,
32
- getAgentByName,
33
- getCurrentAgent,
34
- routeAgentEmail,
35
- routeAgentRequest,
36
- unstable_callable
37
- } from "./index-CkQU40oY.js";
7
+ A as unstable_callable,
8
+ C as createAddressBasedEmailResolver,
9
+ D as getCurrentAgent,
10
+ E as getAgentByName,
11
+ O as routeAgentEmail,
12
+ S as callable,
13
+ T as createHeaderBasedEmailResolver,
14
+ _ as RPCResponse,
15
+ a as AgentOptions,
16
+ b as StreamingResponse,
17
+ c as ConnectionContext,
18
+ d as EmailSendOptions,
19
+ f as MCPServer,
20
+ g as RPCRequest,
21
+ h as QueueItem,
22
+ i as AgentNamespace,
23
+ k as routeAgentRequest,
24
+ l as EmailResolver,
25
+ m as MCPServersState,
26
+ n as AgentContext,
27
+ o as CallableMetadata,
28
+ p as MCPServerMessage,
29
+ r as AgentEmail,
30
+ s as Connection,
31
+ t as Agent,
32
+ u as EmailRoutingOptions,
33
+ v as Schedule,
34
+ w as createCatchAllEmailResolver,
35
+ x as WSMessage,
36
+ y as StateUpdateMessage
37
+ } from "./index-Bx5KK3VJ.js";
38
38
  export {
39
39
  Agent,
40
40
  AgentContext,
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
- import "./ai-types-UZlfLOYP.js";
2
- import "./client-DjR-lC16.js";
3
- import "./client-CZBVDDoO.js";
4
- import "./do-oauth-client-provider-B2jr6UNq.js";
5
- import { Agent, StreamingResponse, callable, createAddressBasedEmailResolver, createCatchAllEmailResolver, createHeaderBasedEmailResolver, getAgentByName, getCurrentAgent, routeAgentEmail, routeAgentRequest, unstable_callable } from "./src-COfG--3R.js";
1
+ import "./ai-types-CrMqkwc_.js";
2
+ import "./client-B3SR12TQ.js";
3
+ import "./client-BZq9qau2.js";
4
+ import "./do-oauth-client-provider-CwqK5SXm.js";
5
+ import { a as createCatchAllEmailResolver, c as getCurrentAgent, d as unstable_callable, i as createAddressBasedEmailResolver, l as routeAgentEmail, n as StreamingResponse, o as createHeaderBasedEmailResolver, r as callable, s as getAgentByName, t as Agent, u as routeAgentRequest } from "./src-D_KKH_4c.js";
6
6
 
7
7
  export { Agent, StreamingResponse, callable, createAddressBasedEmailResolver, createCatchAllEmailResolver, createHeaderBasedEmailResolver, getAgentByName, getCurrentAgent, routeAgentEmail, routeAgentRequest, unstable_callable };
@@ -1,4 +1,4 @@
1
- import { MCPClientManager, MCPClientOAuthCallbackConfig, MCPClientOAuthResult, getNamespacedData } from "../client-C-nwz-3N.js";
2
- import "../mcp-BEwaCsxO.js";
3
- import "../do-oauth-client-provider-CCwGwnrA.js";
4
- export { MCPClientManager, MCPClientOAuthCallbackConfig, MCPClientOAuthResult, getNamespacedData };
1
+ import { a as MCPConnectionResult, c as RegisterServerOptions, i as MCPClientOAuthResult, l as getNamespacedData, n as MCPClientManagerOptions, o as MCPDiscoverResult, r as MCPClientOAuthCallbackConfig, s as MCPServerOptions, t as MCPClientManager } from "../client-CsaP9Irq.js";
2
+ import "../mcp-BwPscEiF.js";
3
+ import "../do-oauth-client-provider-C2CHH5x-.js";
4
+ export { MCPClientManager, MCPClientManagerOptions, MCPClientOAuthCallbackConfig, MCPClientOAuthResult, MCPConnectionResult, MCPDiscoverResult, MCPServerOptions, RegisterServerOptions, getNamespacedData };
@@ -1,3 +1,4 @@
1
- import { MCPClientManager, getNamespacedData } from "../client-CZBVDDoO.js";
1
+ import { n as getNamespacedData, t as MCPClientManager } from "../client-BZq9qau2.js";
2
+ import "../do-oauth-client-provider-CwqK5SXm.js";
2
3
 
3
4
  export { MCPClientManager, getNamespacedData };
@@ -1,2 +1,2 @@
1
- import { AgentsOAuthProvider, DurableObjectOAuthClientProvider } from "../do-oauth-client-provider-CCwGwnrA.js";
1
+ import { n as DurableObjectOAuthClientProvider, t as AgentsOAuthProvider } from "../do-oauth-client-provider-C2CHH5x-.js";
2
2
  export { AgentsOAuthProvider, DurableObjectOAuthClientProvider };
@@ -1,3 +1,3 @@
1
- import { DurableObjectOAuthClientProvider } from "../do-oauth-client-provider-B2jr6UNq.js";
1
+ import { t as DurableObjectOAuthClientProvider } from "../do-oauth-client-provider-CwqK5SXm.js";
2
2
 
3
3
  export { DurableObjectOAuthClientProvider };
@@ -1,13 +1,130 @@
1
- import { BaseTransportType, MCPClientOAuthCallbackConfig, MCPClientOAuthResult, MaybePromise, SSEEdgeClientTransport, ServeOptions, StreamableHTTPEdgeClientTransport } from "../client-C-nwz-3N.js";
2
- import "../mcp-BEwaCsxO.js";
3
- import "../do-oauth-client-provider-CCwGwnrA.js";
4
- import "../index-W4JUkafc.js";
5
- import "../ai-types-BWW4umHY.js";
6
- import { Agent, Connection, ConnectionContext } from "../index-CkQU40oY.js";
7
- import { ElicitRequest, ElicitRequestSchema, ElicitResult, ElicitResult as ElicitResult$1, JSONRPCMessage } from "@modelcontextprotocol/sdk/types.js";
1
+ import { a as MCPConnectionResult, d as BaseTransportType, f as CORSOptions, i as MCPClientOAuthResult, m as ServeOptions, o as MCPDiscoverResult, p as MaybePromise, r as MCPClientOAuthCallbackConfig, s as MCPServerOptions } from "../client-CsaP9Irq.js";
2
+ import "../mcp-BwPscEiF.js";
3
+ import "../do-oauth-client-provider-C2CHH5x-.js";
4
+ import "../index-BUle9RiP.js";
5
+ import "../ai-types-81H_-Uxh.js";
6
+ import { c as ConnectionContext, s as Connection, t as Agent } from "../index-Bx5KK3VJ.js";
7
+ import { SSEClientTransport, SSEClientTransportOptions } from "@modelcontextprotocol/sdk/client/sse.js";
8
+ import { StreamableHTTPClientTransport, StreamableHTTPClientTransportOptions } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
9
+ import { ElicitRequest, ElicitRequestSchema, ElicitResult, ElicitResult as ElicitResult$1, JSONRPCMessage, MessageExtraInfo } from "@modelcontextprotocol/sdk/types.js";
8
10
  import { Server } from "@modelcontextprotocol/sdk/server/index.js";
9
11
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
12
+ import { Transport, TransportSendOptions } from "@modelcontextprotocol/sdk/shared/transport.js";
10
13
 
14
+ //#region src/mcp/client-transports.d.ts
15
+ /**
16
+ * @deprecated Use SSEClientTransport from @modelcontextprotocol/sdk/client/sse.js instead. This alias will be removed in the next major version.
17
+ */
18
+ declare class SSEEdgeClientTransport extends SSEClientTransport {
19
+ constructor(url: URL, options: SSEClientTransportOptions);
20
+ }
21
+ /**
22
+ * @deprecated Use StreamableHTTPClientTransport from @modelcontextprotocol/sdk/client/streamableHttp.js instead. This alias will be removed in the next major version.
23
+ */
24
+ declare class StreamableHTTPEdgeClientTransport extends StreamableHTTPClientTransport {
25
+ constructor(url: URL, options: StreamableHTTPClientTransportOptions);
26
+ }
27
+ //#endregion
28
+ //#region src/mcp/worker-transport.d.ts
29
+ declare const SUPPORTED_PROTOCOL_VERSIONS: readonly ["2025-03-26", "2025-06-18"];
30
+ type ProtocolVersion = (typeof SUPPORTED_PROTOCOL_VERSIONS)[number];
31
+ interface MCPStorageApi {
32
+ get(): Promise<TransportState | undefined> | TransportState | undefined;
33
+ set(state: TransportState): Promise<void> | void;
34
+ }
35
+ interface TransportState {
36
+ sessionId?: string;
37
+ initialized: boolean;
38
+ protocolVersion?: ProtocolVersion;
39
+ }
40
+ interface WorkerTransportOptions {
41
+ sessionIdGenerator?: () => string;
42
+ /**
43
+ * Enable traditional Request/Response mode, this will disable streaming.
44
+ */
45
+ enableJsonResponse?: boolean;
46
+ onsessioninitialized?: (sessionId: string) => void;
47
+ corsOptions?: CORSOptions;
48
+ /**
49
+ * Optional storage api for persisting transport state.
50
+ * Use this to store session state in Durable Object/Agent storage
51
+ * so it survives hibernation/restart.
52
+ */
53
+ storage?: MCPStorageApi;
54
+ }
55
+ declare class WorkerTransport implements Transport {
56
+ started: boolean;
57
+ private initialized;
58
+ private sessionIdGenerator?;
59
+ private enableJsonResponse;
60
+ private onsessioninitialized?;
61
+ private standaloneSseStreamId;
62
+ private streamMapping;
63
+ private requestToStreamMapping;
64
+ private requestResponseMap;
65
+ private corsOptions?;
66
+ private protocolVersion?;
67
+ private storage?;
68
+ private stateRestored;
69
+ sessionId?: string;
70
+ onclose?: () => void;
71
+ onerror?: (error: Error) => void;
72
+ onmessage?: (message: JSONRPCMessage, extra?: MessageExtraInfo) => void;
73
+ constructor(options?: WorkerTransportOptions);
74
+ /**
75
+ * Restore transport state from persistent storage.
76
+ * This is automatically called on start.
77
+ */
78
+ private restoreState;
79
+ /**
80
+ * Persist current transport state to storage.
81
+ */
82
+ private saveState;
83
+ start(): Promise<void>;
84
+ private validateProtocolVersion;
85
+ private getHeaders;
86
+ handleRequest(request: Request, parsedBody?: unknown): Promise<Response>;
87
+ private handleGetRequest;
88
+ private handlePostRequest;
89
+ private handleDeleteRequest;
90
+ private handleOptionsRequest;
91
+ private handleUnsupportedRequest;
92
+ private validateSession;
93
+ close(): Promise<void>;
94
+ send(message: JSONRPCMessage, options?: TransportSendOptions): Promise<void>;
95
+ }
96
+ //#endregion
97
+ //#region src/mcp/auth-context.d.ts
98
+ interface McpAuthContext {
99
+ props: Record<string, unknown>;
100
+ }
101
+ declare function getMcpAuthContext(): McpAuthContext | undefined;
102
+ //#endregion
103
+ //#region src/mcp/handler.d.ts
104
+ interface CreateMcpHandlerOptions extends WorkerTransportOptions {
105
+ /**
106
+ * The route path that this MCP handler should respond to.
107
+ * If specified, the handler will only process requests that match this route.
108
+ * @default "/mcp"
109
+ */
110
+ route?: string;
111
+ /**
112
+ * An optional auth context to use for handling MCP requests.
113
+ * If not provided, the handler will look for props in the execution context.
114
+ */
115
+ authContext?: McpAuthContext;
116
+ /**
117
+ * An optional transport to use for handling MCP requests.
118
+ * If not provided, a WorkerTransport will be created with the provided WorkerTransportOptions.
119
+ */
120
+ transport?: WorkerTransport;
121
+ }
122
+ declare function createMcpHandler(server: McpServer | Server, options?: CreateMcpHandlerOptions): (request: Request, env: unknown, ctx: ExecutionContext) => Promise<Response>;
123
+ /**
124
+ * @deprecated This has been renamed to createMcpHandler, and experimental_createMcpHandler will be removed in the next major version
125
+ */
126
+ declare function experimental_createMcpHandler(server: McpServer | Server, options?: CreateMcpHandlerOptions): (request: Request, env: unknown, ctx: ExecutionContext) => Promise<Response>;
127
+ //#endregion
11
128
  //#region src/mcp/index.d.ts
12
129
  declare abstract class McpAgent<Env = unknown, State = unknown, Props extends Record<string, unknown> = Record<string, unknown>> extends Agent<Env, State, Props> {
13
130
  private _transport?;
@@ -27,7 +144,7 @@ declare abstract class McpAgent<Env = unknown, State = unknown, Props extends Re
27
144
  */
28
145
  getSessionId(): string;
29
146
  /** Get the unique WebSocket. SSE transport only. */
30
- private getWebSocket;
147
+ getWebSocket(): Connection<unknown> | null;
31
148
  /** Returns a new transport matching the type of the Agent. */
32
149
  private initTransport;
33
150
  /** Update and store the props */
@@ -40,7 +157,7 @@ declare abstract class McpAgent<Env = unknown, State = unknown, Props extends Re
40
157
  request: req
41
158
  }: ConnectionContext): Promise<void>;
42
159
  /** Handles MCP Messages for the legacy SSE transport. */
43
- onSSEMcpMessage(_sessionId: string, messageBody: unknown): Promise<Error | null>;
160
+ onSSEMcpMessage(_sessionId: string, messageBody: unknown, extraInfo?: MessageExtraInfo): Promise<Error | null>;
44
161
  /** Elicit user input with a message and schema */
45
162
  elicitInput(params: {
46
163
  message: string;
@@ -56,7 +173,8 @@ declare abstract class McpAgent<Env = unknown, State = unknown, Props extends Re
56
173
  static serve(path: string, {
57
174
  binding,
58
175
  corsOptions,
59
- transport
176
+ transport,
177
+ jurisdiction
60
178
  }?: ServeOptions): {
61
179
  fetch<Env>(this: void, request: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
62
180
  };
@@ -71,5 +189,5 @@ declare abstract class McpAgent<Env = unknown, State = unknown, Props extends Re
71
189
  };
72
190
  }
73
191
  //#endregion
74
- export { type ElicitRequest, ElicitRequestSchema, type ElicitResult, type MCPClientOAuthCallbackConfig, type MCPClientOAuthResult, McpAgent, SSEEdgeClientTransport, StreamableHTTPEdgeClientTransport };
192
+ export { type CreateMcpHandlerOptions, type ElicitRequest, ElicitRequestSchema, type ElicitResult, type MCPClientOAuthCallbackConfig, type MCPClientOAuthResult, type MCPConnectionResult, type MCPDiscoverResult, type MCPServerOptions, McpAgent, type McpAuthContext, SSEEdgeClientTransport, StreamableHTTPEdgeClientTransport, type TransportState, WorkerTransport, type WorkerTransportOptions, createMcpHandler, experimental_createMcpHandler, getMcpAuthContext };
75
193
  //# sourceMappingURL=index.d.ts.map