agents 0.0.0-5969a16 → 0.0.0-59ac254

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 (104) hide show
  1. package/README.md +5 -3
  2. package/dist/ai-chat-agent.d.ts +100 -19
  3. package/dist/ai-chat-agent.js +812 -352
  4. package/dist/ai-chat-agent.js.map +1 -1
  5. package/dist/ai-chat-v5-migration-DguhuLKF.js +155 -0
  6. package/dist/ai-chat-v5-migration-DguhuLKF.js.map +1 -0
  7. package/dist/ai-chat-v5-migration.d.ts +7 -4
  8. package/dist/ai-chat-v5-migration.js +3 -20
  9. package/dist/ai-react.d.ts +20 -23
  10. package/dist/ai-react.js +408 -349
  11. package/dist/ai-react.js.map +1 -1
  12. package/dist/ai-types-CwgHzwUb.js +24 -0
  13. package/dist/ai-types-CwgHzwUb.js.map +1 -0
  14. package/dist/ai-types-D_hTbf25.d.ts +103 -0
  15. package/dist/ai-types.d.ts +6 -92
  16. package/dist/ai-types.js +3 -8
  17. package/dist/cli/index.d.ts +1 -0
  18. package/dist/cli/index.js +28 -0
  19. package/dist/cli/index.js.map +1 -0
  20. package/dist/client-C_M5uPrn.d.ts +834 -0
  21. package/dist/client-CcyhkGfN.js +117 -0
  22. package/dist/client-CcyhkGfN.js.map +1 -0
  23. package/dist/client-ClORm6f0.d.ts +104 -0
  24. package/dist/client-QZa2Rq0l.js +1105 -0
  25. package/dist/client-QZa2Rq0l.js.map +1 -0
  26. package/dist/client.d.ts +11 -92
  27. package/dist/client.js +4 -13
  28. package/dist/codemode/ai.d.ts +27 -0
  29. package/dist/codemode/ai.js +152 -0
  30. package/dist/codemode/ai.js.map +1 -0
  31. package/dist/context-BkKbAa1R.js +8 -0
  32. package/dist/context-BkKbAa1R.js.map +1 -0
  33. package/dist/context-_sPQqJWv.d.ts +24 -0
  34. package/dist/context.d.ts +6 -0
  35. package/dist/context.js +3 -0
  36. package/dist/do-oauth-client-provider-B-ryFIPr.d.ts +70 -0
  37. package/dist/do-oauth-client-provider-B1fVIshX.js +155 -0
  38. package/dist/do-oauth-client-provider-B1fVIshX.js.map +1 -0
  39. package/dist/index-CyDpAVHZ.d.ts +58 -0
  40. package/dist/index-DUnsVDnf.d.ts +577 -0
  41. package/dist/index.d.ts +55 -556
  42. package/dist/index.js +8 -32
  43. package/dist/mcp/client.d.ts +4 -11
  44. package/dist/mcp/client.js +4 -10
  45. package/dist/mcp/do-oauth-client-provider.d.ts +2 -50
  46. package/dist/mcp/do-oauth-client-provider.js +3 -8
  47. package/dist/mcp/index.d.ts +200 -75
  48. package/dist/mcp/index.js +1423 -1080
  49. package/dist/mcp/index.js.map +1 -1
  50. package/dist/mcp/x402.d.ts +22 -25
  51. package/dist/mcp/x402.js +190 -3187
  52. package/dist/mcp/x402.js.map +1 -1
  53. package/dist/mcp-CzbSsLfc.d.ts +61 -0
  54. package/dist/observability/index.d.ts +3 -46
  55. package/dist/observability/index.js +8 -12
  56. package/dist/react-DbzUBop3.d.ts +131 -0
  57. package/dist/react.d.ts +15 -123
  58. package/dist/react.js +183 -113
  59. package/dist/react.js.map +1 -1
  60. package/dist/schedule.d.ts +13 -10
  61. package/dist/schedule.js +43 -33
  62. package/dist/schedule.js.map +1 -1
  63. package/dist/serializable-C4GLimgv.d.ts +39 -0
  64. package/dist/serializable.d.ts +7 -32
  65. package/dist/serializable.js +1 -1
  66. package/dist/src-BmbDclOA.js +1181 -0
  67. package/dist/src-BmbDclOA.js.map +1 -0
  68. package/package.json +65 -32
  69. package/dist/_esm-LV5FJ3HK.js +0 -3922
  70. package/dist/_esm-LV5FJ3HK.js.map +0 -1
  71. package/dist/ai-chat-v5-migration.js.map +0 -1
  72. package/dist/ai-types.js.map +0 -1
  73. package/dist/ccip-CMBYN64O.js +0 -15
  74. package/dist/ccip-CMBYN64O.js.map +0 -1
  75. package/dist/chunk-5Y6BEZDY.js +0 -276
  76. package/dist/chunk-5Y6BEZDY.js.map +0 -1
  77. package/dist/chunk-BER7KXUJ.js +0 -18
  78. package/dist/chunk-BER7KXUJ.js.map +0 -1
  79. package/dist/chunk-JJBFIGUC.js +0 -5202
  80. package/dist/chunk-JJBFIGUC.js.map +0 -1
  81. package/dist/chunk-PR4QN5HX.js +0 -43
  82. package/dist/chunk-PR4QN5HX.js.map +0 -1
  83. package/dist/chunk-QEPGNUG6.js +0 -650
  84. package/dist/chunk-QEPGNUG6.js.map +0 -1
  85. package/dist/chunk-QEVM4BVL.js +0 -116
  86. package/dist/chunk-QEVM4BVL.js.map +0 -1
  87. package/dist/chunk-RS5OCNEQ.js +0 -1323
  88. package/dist/chunk-RS5OCNEQ.js.map +0 -1
  89. package/dist/chunk-TYAY6AU6.js +0 -159
  90. package/dist/chunk-TYAY6AU6.js.map +0 -1
  91. package/dist/chunk-UJVEAURM.js +0 -150
  92. package/dist/chunk-UJVEAURM.js.map +0 -1
  93. package/dist/chunk-XFS5ERG3.js +0 -127
  94. package/dist/chunk-XFS5ERG3.js.map +0 -1
  95. package/dist/client-BohGLma8.d.ts +0 -5041
  96. package/dist/client.js.map +0 -1
  97. package/dist/index.js.map +0 -1
  98. package/dist/mcp/client.js.map +0 -1
  99. package/dist/mcp/do-oauth-client-provider.js.map +0 -1
  100. package/dist/observability/index.js.map +0 -1
  101. package/dist/secp256k1-M22GZP2U.js +0 -2193
  102. package/dist/secp256k1-M22GZP2U.js.map +0 -1
  103. package/dist/serializable.js.map +0 -1
  104. package/src/index.ts +0 -1987
@@ -1,50 +1,2 @@
1
- import { OAuthClientProvider } from '@modelcontextprotocol/sdk/client/auth.js';
2
- import { OAuthClientMetadata, OAuthClientInformation, OAuthClientInformationFull, OAuthTokens } from '@modelcontextprotocol/sdk/shared/auth.js';
3
-
4
- interface AgentsOAuthProvider extends OAuthClientProvider {
5
- authUrl: string | undefined;
6
- clientId: string | undefined;
7
- serverId: string | undefined;
8
- saveOAuthTransport(transportType: string): Promise<void>;
9
- getOAuthTransport(): Promise<string | undefined>;
10
- clearOAuthTransport(): Promise<void>;
11
- }
12
- declare class DurableObjectOAuthClientProvider implements AgentsOAuthProvider {
13
- storage: DurableObjectStorage;
14
- clientName: string;
15
- baseRedirectUrl: string;
16
- private _authUrl_;
17
- private _serverId_;
18
- private _clientId_;
19
- constructor(storage: DurableObjectStorage, clientName: string, baseRedirectUrl: string);
20
- get clientMetadata(): OAuthClientMetadata;
21
- get clientUri(): string;
22
- get redirectUrl(): string;
23
- get clientId(): string;
24
- set clientId(clientId_: string);
25
- get serverId(): string;
26
- set serverId(serverId_: string);
27
- keyPrefix(clientId: string): string;
28
- clientInfoKey(clientId: string): string;
29
- clientInformation(): Promise<OAuthClientInformation | undefined>;
30
- saveClientInformation(clientInformation: OAuthClientInformationFull): Promise<void>;
31
- tokenKey(clientId: string): string;
32
- tokens(): Promise<OAuthTokens | undefined>;
33
- saveTokens(tokens: OAuthTokens): Promise<void>;
34
- get authUrl(): string | undefined;
35
- /**
36
- * Because this operates on the server side (but we need browser auth), we send this url back to the user
37
- * and require user interact to initiate the redirect flow
38
- */
39
- redirectToAuthorization(authUrl: URL): Promise<void>;
40
- codeVerifierKey(clientId: string): string;
41
- saveCodeVerifier(verifier: string): Promise<void>;
42
- codeVerifier(): Promise<string>;
43
- /** Transport tracking for OAuth flow */
44
- oauthTransportKey(): string;
45
- saveOAuthTransport(transportType: string): Promise<void>;
46
- getOAuthTransport(): Promise<string | undefined>;
47
- clearOAuthTransport(): Promise<void>;
48
- }
49
-
50
- export { type AgentsOAuthProvider, DurableObjectOAuthClientProvider };
1
+ import { n as DurableObjectOAuthClientProvider, t as AgentsOAuthProvider } from "../do-oauth-client-provider-B-ryFIPr.js";
2
+ export { AgentsOAuthProvider, DurableObjectOAuthClientProvider };
@@ -1,8 +1,3 @@
1
- import {
2
- DurableObjectOAuthClientProvider
3
- } from "../chunk-XFS5ERG3.js";
4
- import "../chunk-PR4QN5HX.js";
5
- export {
6
- DurableObjectOAuthClientProvider
7
- };
8
- //# sourceMappingURL=do-oauth-client-provider.js.map
1
+ import { t as DurableObjectOAuthClientProvider } from "../do-oauth-client-provider-B1fVIshX.js";
2
+
3
+ export { DurableObjectOAuthClientProvider };
@@ -1,78 +1,203 @@
1
- import { Server } from '@modelcontextprotocol/sdk/server/index.js';
2
- import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
3
- import { JSONRPCMessage, ElicitResult } from '@modelcontextprotocol/sdk/types.js';
4
- export { ElicitRequest, ElicitRequestSchema, ElicitResult } from '@modelcontextprotocol/sdk/types.js';
5
- import { Agent } from '../index.js';
6
- import { M as MaybePromise, B as BaseTransportType, S as ServeOptions } from '../client-BohGLma8.js';
7
- export { a as SSEEdgeClientTransport, b as StreamableHTTPEdgeClientTransport } from '../client-BohGLma8.js';
8
- import { Connection, ConnectionContext } from 'partyserver';
9
- import 'cloudflare:workers';
10
- import '@modelcontextprotocol/sdk/client/index.js';
11
- import '../observability/index.js';
12
- import '../ai-types.js';
13
- import 'ai';
14
- import 'zod';
15
- import '@modelcontextprotocol/sdk/shared/protocol.js';
16
- import '@modelcontextprotocol/sdk/client/sse.js';
17
- import '@modelcontextprotocol/sdk/client/streamableHttp.js';
18
- import './do-oauth-client-provider.js';
19
- import '@modelcontextprotocol/sdk/client/auth.js';
20
- import '@modelcontextprotocol/sdk/shared/auth.js';
1
+ import "../context-_sPQqJWv.js";
2
+ 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-C_M5uPrn.js";
3
+ import "../mcp-CzbSsLfc.js";
4
+ import "../do-oauth-client-provider-B-ryFIPr.js";
5
+ import "../index-CyDpAVHZ.js";
6
+ import "../ai-types-D_hTbf25.js";
7
+ import { o as Connection, s as ConnectionContext, t as Agent } from "../index-DUnsVDnf.js";
8
+ import { SSEClientTransport, SSEClientTransportOptions } from "@modelcontextprotocol/sdk/client/sse.js";
9
+ import { StreamableHTTPClientTransport, StreamableHTTPClientTransportOptions } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
10
+ import { ElicitRequest, ElicitRequestSchema, ElicitResult, ElicitResult as ElicitResult$1, JSONRPCMessage, MessageExtraInfo } from "@modelcontextprotocol/sdk/types.js";
11
+ import { Server } from "@modelcontextprotocol/sdk/server/index.js";
12
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
13
+ import { Transport, TransportSendOptions } from "@modelcontextprotocol/sdk/shared/transport.js";
21
14
 
15
+ //#region src/mcp/client-transports.d.ts
16
+ /**
17
+ * @deprecated Use SSEClientTransport from @modelcontextprotocol/sdk/client/sse.js instead. This alias will be removed in the next major version.
18
+ */
19
+ declare class SSEEdgeClientTransport extends SSEClientTransport {
20
+ constructor(url: URL, options: SSEClientTransportOptions);
21
+ }
22
+ /**
23
+ * @deprecated Use StreamableHTTPClientTransport from @modelcontextprotocol/sdk/client/streamableHttp.js instead. This alias will be removed in the next major version.
24
+ */
25
+ declare class StreamableHTTPEdgeClientTransport extends StreamableHTTPClientTransport {
26
+ constructor(url: URL, options: StreamableHTTPClientTransportOptions);
27
+ }
28
+ //#endregion
29
+ //#region src/mcp/worker-transport.d.ts
30
+ interface MCPStorageApi {
31
+ get(): Promise<TransportState | undefined> | TransportState | undefined;
32
+ set(state: TransportState): Promise<void> | void;
33
+ }
34
+ interface TransportState {
35
+ sessionId?: string;
36
+ initialized: boolean;
37
+ }
38
+ interface WorkerTransportOptions {
39
+ sessionIdGenerator?: () => string;
40
+ /**
41
+ * Enable traditional Request/Response mode, this will disable streaming.
42
+ */
43
+ enableJsonResponse?: boolean;
44
+ onsessioninitialized?: (sessionId: string) => void;
45
+ corsOptions?: CORSOptions;
46
+ /**
47
+ * Optional storage api for persisting transport state.
48
+ * Use this to store session state in Durable Object/Agent storage
49
+ * so it survives hibernation/restart.
50
+ */
51
+ storage?: MCPStorageApi;
52
+ }
53
+ declare class WorkerTransport implements Transport {
54
+ started: boolean;
55
+ private initialized;
56
+ private sessionIdGenerator?;
57
+ private enableJsonResponse;
58
+ private onsessioninitialized?;
59
+ private standaloneSseStreamId;
60
+ private streamMapping;
61
+ private requestToStreamMapping;
62
+ private requestResponseMap;
63
+ private corsOptions?;
64
+ private storage?;
65
+ private stateRestored;
66
+ sessionId?: string;
67
+ onclose?: () => void;
68
+ onerror?: (error: Error) => void;
69
+ onmessage?: (message: JSONRPCMessage, extra?: MessageExtraInfo) => void;
70
+ constructor(options?: WorkerTransportOptions);
71
+ /**
72
+ * Restore transport state from persistent storage.
73
+ * This is automatically called on start.
74
+ */
75
+ private restoreState;
76
+ /**
77
+ * Persist current transport state to storage.
78
+ */
79
+ private saveState;
80
+ start(): Promise<void>;
81
+ /**
82
+ * Validates the MCP-Protocol-Version header on incoming requests.
83
+ *
84
+ * This performs a simple check: if a version header is present, it must be
85
+ * in the SUPPORTED_PROTOCOL_VERSIONS list. We do not track the negotiated
86
+ * version or enforce version consistency across requests - the SDK handles
87
+ * version negotiation during initialization, and we simply reject any
88
+ * explicitly unsupported versions.
89
+ *
90
+ * - Header present and supported: Accept
91
+ * - Header present and unsupported: 400 Bad Request
92
+ * - Header missing: Accept (version validation is optional)
93
+ */
94
+ private validateProtocolVersion;
95
+ private getHeaders;
96
+ handleRequest(request: Request, parsedBody?: unknown): Promise<Response>;
97
+ private handleGetRequest;
98
+ private handlePostRequest;
99
+ private handleDeleteRequest;
100
+ private handleOptionsRequest;
101
+ private handleUnsupportedRequest;
102
+ private validateSession;
103
+ close(): Promise<void>;
104
+ send(message: JSONRPCMessage, options?: TransportSendOptions): Promise<void>;
105
+ }
106
+ //#endregion
107
+ //#region src/mcp/auth-context.d.ts
108
+ interface McpAuthContext {
109
+ props: Record<string, unknown>;
110
+ }
111
+ declare function getMcpAuthContext(): McpAuthContext | undefined;
112
+ //#endregion
113
+ //#region src/mcp/handler.d.ts
114
+ interface CreateMcpHandlerOptions extends WorkerTransportOptions {
115
+ /**
116
+ * The route path that this MCP handler should respond to.
117
+ * If specified, the handler will only process requests that match this route.
118
+ * @default "/mcp"
119
+ */
120
+ route?: string;
121
+ /**
122
+ * An optional auth context to use for handling MCP requests.
123
+ * If not provided, the handler will look for props in the execution context.
124
+ */
125
+ authContext?: McpAuthContext;
126
+ /**
127
+ * An optional transport to use for handling MCP requests.
128
+ * If not provided, a WorkerTransport will be created with the provided WorkerTransportOptions.
129
+ */
130
+ transport?: WorkerTransport;
131
+ }
132
+ declare function createMcpHandler(server: McpServer | Server, options?: CreateMcpHandlerOptions): (request: Request, env: unknown, ctx: ExecutionContext) => Promise<Response>;
133
+ /**
134
+ * @deprecated This has been renamed to createMcpHandler, and experimental_createMcpHandler will be removed in the next major version
135
+ */
136
+ declare function experimental_createMcpHandler(server: McpServer | Server, options?: CreateMcpHandlerOptions): (request: Request, env: unknown, ctx: ExecutionContext) => Promise<Response>;
137
+ //#endregion
138
+ //#region src/mcp/index.d.ts
22
139
  declare abstract class McpAgent<Env = unknown, State = unknown, Props extends Record<string, unknown> = Record<string, unknown>> extends Agent<Env, State, Props> {
23
- private _transport?;
24
- props?: Props;
25
- abstract server: MaybePromise<McpServer | Server>;
26
- abstract init(): Promise<void>;
27
- setInitializeRequest(initializeRequest: JSONRPCMessage): Promise<void>;
28
- getInitializeRequest(): Promise<JSONRPCMessage | undefined>;
29
- /** Read the transport type for this agent.
30
- * This relies on the naming scheme being `sse:${sessionId}`
31
- * or `streamable-http:${sessionId}`.
32
- */
33
- getTransportType(): BaseTransportType;
34
- /** Read the sessionId for this agent.
35
- * This relies on the naming scheme being `sse:${sessionId}`
36
- * or `streamable-http:${sessionId}`.
37
- */
38
- getSessionId(): string;
39
- /** Get the unique WebSocket. SSE transport only. */
40
- private getWebSocket;
41
- /** Returns a new transport matching the type of the Agent. */
42
- private initTransport;
43
- /** Update and store the props */
44
- updateProps(props?: Props): Promise<void>;
45
- reinitializeServer(): Promise<void>;
46
- /** Sets up the MCP transport and server every time the Agent is started.*/
47
- onStart(props?: Props): Promise<void>;
48
- /** Validates new WebSocket connections. */
49
- onConnect(conn: Connection, { request: req }: ConnectionContext): Promise<void>;
50
- /** Handles MCP Messages for the legacy SSE transport. */
51
- onSSEMcpMessage(_sessionId: string, messageBody: unknown): Promise<Error | null>;
52
- /** Elicit user input with a message and schema */
53
- elicitInput(params: {
54
- message: string;
55
- requestedSchema: unknown;
56
- }): Promise<ElicitResult>;
57
- /** Wait for elicitation response through storage polling */
58
- private _waitForElicitationResponse;
59
- /** Handle elicitation responses */
60
- private _handleElicitationResponse;
61
- /** Return a handler for the given path for this MCP.
62
- * Defaults to Streamable HTTP transport.
63
- */
64
- static serve(path: string, { binding, corsOptions, transport }?: ServeOptions): {
65
- fetch<Env>(this: void, request: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
66
- };
67
- /**
68
- * Legacy api
69
- **/
70
- static mount(path: string, opts?: Omit<ServeOptions, "transport">): {
71
- fetch<Env>(this: void, request: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
72
- };
73
- static serveSSE(path: string, opts?: Omit<ServeOptions, "transport">): {
74
- fetch<Env>(this: void, request: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
75
- };
140
+ private _transport?;
141
+ props?: Props;
142
+ abstract server: MaybePromise<McpServer | Server>;
143
+ abstract init(): Promise<void>;
144
+ setInitializeRequest(initializeRequest: JSONRPCMessage): Promise<void>;
145
+ getInitializeRequest(): Promise<JSONRPCMessage | undefined>;
146
+ /** Read the transport type for this agent.
147
+ * This relies on the naming scheme being `sse:${sessionId}`
148
+ * or `streamable-http:${sessionId}`.
149
+ */
150
+ getTransportType(): BaseTransportType;
151
+ /** Read the sessionId for this agent.
152
+ * This relies on the naming scheme being `sse:${sessionId}`
153
+ * or `streamable-http:${sessionId}`.
154
+ */
155
+ getSessionId(): string;
156
+ /** Get the unique WebSocket. SSE transport only. */
157
+ getWebSocket(): Connection<unknown> | null;
158
+ /** Returns a new transport matching the type of the Agent. */
159
+ private initTransport;
160
+ /** Update and store the props */
161
+ updateProps(props?: Props): Promise<void>;
162
+ reinitializeServer(): Promise<void>;
163
+ /** Sets up the MCP transport and server every time the Agent is started.*/
164
+ onStart(props?: Props): Promise<void>;
165
+ /** Validates new WebSocket connections. */
166
+ onConnect(conn: Connection, {
167
+ request: req
168
+ }: ConnectionContext): Promise<void>;
169
+ /** Handles MCP Messages for the legacy SSE transport. */
170
+ onSSEMcpMessage(_sessionId: string, messageBody: unknown, extraInfo?: MessageExtraInfo): Promise<Error | null>;
171
+ /** Elicit user input with a message and schema */
172
+ elicitInput(params: {
173
+ message: string;
174
+ requestedSchema: unknown;
175
+ }): Promise<ElicitResult$1>;
176
+ /** Wait for elicitation response through storage polling */
177
+ private _waitForElicitationResponse;
178
+ /** Handle elicitation responses */
179
+ private _handleElicitationResponse;
180
+ /** Return a handler for the given path for this MCP.
181
+ * Defaults to Streamable HTTP transport.
182
+ */
183
+ static serve(path: string, {
184
+ binding,
185
+ corsOptions,
186
+ transport,
187
+ jurisdiction
188
+ }?: ServeOptions): {
189
+ fetch<Env>(this: void, request: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
190
+ };
191
+ /**
192
+ * Legacy api
193
+ **/
194
+ static mount(path: string, opts?: Omit<ServeOptions, "transport">): {
195
+ fetch<Env>(this: void, request: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
196
+ };
197
+ static serveSSE(path: string, opts?: Omit<ServeOptions, "transport">): {
198
+ fetch<Env>(this: void, request: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
199
+ };
76
200
  }
77
-
78
- export { McpAgent };
201
+ //#endregion
202
+ 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 };
203
+ //# sourceMappingURL=index.d.ts.map