agents 0.0.0-d6a4eda → 0.0.0-d6d6d60

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 (77) hide show
  1. package/README.md +255 -27
  2. package/dist/ai-chat-agent.d.ts +20 -17
  3. package/dist/ai-chat-agent.js +532 -222
  4. package/dist/ai-chat-agent.js.map +1 -1
  5. package/dist/ai-chat-v5-migration-DBHGW4Hv.js +155 -0
  6. package/dist/ai-chat-v5-migration-DBHGW4Hv.js.map +1 -0
  7. package/dist/ai-chat-v5-migration.d.ts +155 -0
  8. package/dist/ai-chat-v5-migration.js +3 -0
  9. package/dist/ai-react.d.ts +73 -84
  10. package/dist/ai-react.js +266 -199
  11. package/dist/ai-react.js.map +1 -1
  12. package/dist/ai-types-B3aQaFv3.js +20 -0
  13. package/dist/ai-types-B3aQaFv3.js.map +1 -0
  14. package/dist/ai-types-D5YoPrBZ.d.ts +95 -0
  15. package/dist/ai-types.d.ts +6 -74
  16. package/dist/ai-types.js +3 -1
  17. package/dist/cli.d.ts +8 -0
  18. package/dist/cli.js +27 -0
  19. package/dist/cli.js.map +1 -0
  20. package/dist/client-BfiZ3HQd.js +117 -0
  21. package/dist/client-BfiZ3HQd.js.map +1 -0
  22. package/dist/client-Bws9q38u.d.ts +5427 -0
  23. package/dist/client-CbWe9FBd.d.ts +104 -0
  24. package/dist/client-DvK0u9vD.js +898 -0
  25. package/dist/client-DvK0u9vD.js.map +1 -0
  26. package/dist/client.d.ts +12 -87
  27. package/dist/client.js +4 -11
  28. package/dist/codemode/ai.d.ts +27 -0
  29. package/dist/codemode/ai.js +151 -0
  30. package/dist/codemode/ai.js.map +1 -0
  31. package/dist/do-oauth-client-provider-CcTno-25.d.ts +142 -0
  32. package/dist/do-oauth-client-provider-D2P1lSft.js +93 -0
  33. package/dist/do-oauth-client-provider-D2P1lSft.js.map +1 -0
  34. package/dist/index-Bdzb2feZ.d.ts +572 -0
  35. package/dist/index-DhJCaDWd.d.ts +58 -0
  36. package/dist/index.d.ts +62 -392
  37. package/dist/index.js +7 -22
  38. package/dist/mcp/client.d.ts +4 -783
  39. package/dist/mcp/client.js +4 -9
  40. package/dist/mcp/do-oauth-client-provider.d.ts +2 -41
  41. package/dist/mcp/do-oauth-client-provider.js +3 -7
  42. package/dist/mcp/index.d.ts +190 -81
  43. package/dist/mcp/index.js +1428 -767
  44. package/dist/mcp/index.js.map +1 -1
  45. package/dist/mcp/x402.d.ts +34 -0
  46. package/dist/mcp/x402.js +194 -0
  47. package/dist/mcp/x402.js.map +1 -0
  48. package/dist/mcp-Dw5vDrY8.d.ts +61 -0
  49. package/dist/observability/index.d.ts +3 -0
  50. package/dist/observability/index.js +7 -0
  51. package/dist/react-DFNXTQzy.d.ts +113 -0
  52. package/dist/react.d.ts +10 -53
  53. package/dist/react.js +183 -100
  54. package/dist/react.js.map +1 -1
  55. package/dist/schedule.d.ts +89 -12
  56. package/dist/schedule.js +46 -21
  57. package/dist/schedule.js.map +1 -1
  58. package/dist/serializable-CymX8ovI.d.ts +39 -0
  59. package/dist/serializable.d.ts +7 -0
  60. package/dist/serializable.js +1 -0
  61. package/dist/src-C1WWpbRo.js +1247 -0
  62. package/dist/src-C1WWpbRo.js.map +1 -0
  63. package/package.json +125 -71
  64. package/dist/ai-types.js.map +0 -1
  65. package/dist/chunk-BZXOAZUX.js +0 -106
  66. package/dist/chunk-BZXOAZUX.js.map +0 -1
  67. package/dist/chunk-QSGN3REV.js +0 -123
  68. package/dist/chunk-QSGN3REV.js.map +0 -1
  69. package/dist/chunk-RIYR6FR6.js +0 -777
  70. package/dist/chunk-RIYR6FR6.js.map +0 -1
  71. package/dist/chunk-Y67CHZBI.js +0 -464
  72. package/dist/chunk-Y67CHZBI.js.map +0 -1
  73. package/dist/client.js.map +0 -1
  74. package/dist/index.js.map +0 -1
  75. package/dist/mcp/client.js.map +0 -1
  76. package/dist/mcp/do-oauth-client-provider.js.map +0 -1
  77. package/src/index.ts +0 -1243
@@ -1,9 +1,4 @@
1
- import {
2
- MCPClientManager,
3
- getNamespacedData
4
- } from "../chunk-Y67CHZBI.js";
5
- export {
6
- MCPClientManager,
7
- getNamespacedData
8
- };
9
- //# sourceMappingURL=client.js.map
1
+ import { n as getNamespacedData, t as MCPClientManager } from "../client-DvK0u9vD.js";
2
+ import "../do-oauth-client-provider-D2P1lSft.js";
3
+
4
+ export { MCPClientManager, getNamespacedData };
@@ -1,41 +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
- }
9
- declare class DurableObjectOAuthClientProvider implements AgentsOAuthProvider {
10
- storage: DurableObjectStorage;
11
- clientName: string;
12
- baseRedirectUrl: string;
13
- private _authUrl_;
14
- private _serverId_;
15
- private _clientId_;
16
- constructor(storage: DurableObjectStorage, clientName: string, baseRedirectUrl: string);
17
- get clientMetadata(): OAuthClientMetadata;
18
- get redirectUrl(): string;
19
- get clientId(): string;
20
- set clientId(clientId_: string);
21
- get serverId(): string;
22
- set serverId(serverId_: string);
23
- keyPrefix(clientId: string): string;
24
- clientInfoKey(clientId: string): string;
25
- clientInformation(): Promise<OAuthClientInformation | undefined>;
26
- saveClientInformation(clientInformation: OAuthClientInformationFull): Promise<void>;
27
- tokenKey(clientId: string): string;
28
- tokens(): Promise<OAuthTokens | undefined>;
29
- saveTokens(tokens: OAuthTokens): Promise<void>;
30
- get authUrl(): string | undefined;
31
- /**
32
- * Because this operates on the server side (but we need browser auth), we send this url back to the user
33
- * and require user interact to initiate the redirect flow
34
- */
35
- redirectToAuthorization(authUrl: URL): Promise<void>;
36
- codeVerifierKey(clientId: string): string;
37
- saveCodeVerifier(verifier: string): Promise<void>;
38
- codeVerifier(): Promise<string>;
39
- }
40
-
41
- export { type AgentsOAuthProvider, DurableObjectOAuthClientProvider };
1
+ import { n as DurableObjectOAuthClientProvider, t as AgentsOAuthProvider } from "../do-oauth-client-provider-CcTno-25.js";
2
+ export { AgentsOAuthProvider, DurableObjectOAuthClientProvider };
@@ -1,7 +1,3 @@
1
- import {
2
- DurableObjectOAuthClientProvider
3
- } from "../chunk-BZXOAZUX.js";
4
- export {
5
- DurableObjectOAuthClientProvider
6
- };
7
- //# sourceMappingURL=do-oauth-client-provider.js.map
1
+ import { t as DurableObjectOAuthClientProvider } from "../do-oauth-client-provider-D2P1lSft.js";
2
+
3
+ export { DurableObjectOAuthClientProvider };
@@ -1,84 +1,193 @@
1
- import { MCPClientManager } from './client.js';
2
- import { DurableObject } from 'cloudflare:workers';
3
- import { Connection, WSMessage } from 'partyserver';
4
- import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
5
- import { Server } from '@modelcontextprotocol/sdk/server/index.js';
6
- import 'zod';
7
- import '@modelcontextprotocol/sdk/types.js';
8
- import '@modelcontextprotocol/sdk/client/index.js';
9
- import '@modelcontextprotocol/sdk/client/sse.js';
10
- import './do-oauth-client-provider.js';
11
- import '@modelcontextprotocol/sdk/client/auth.js';
12
- import '@modelcontextprotocol/sdk/shared/auth.js';
13
- import '@modelcontextprotocol/sdk/shared/protocol.js';
14
- import 'ai';
1
+ import { a as MCPConnectionResult, d as CORSOptions, f as MaybePromise, i as MCPClientOAuthResult, o as MCPServerOptions, p as ServeOptions, r as MCPClientOAuthCallbackConfig, u as BaseTransportType } from "../client-Bws9q38u.js";
2
+ import "../mcp-Dw5vDrY8.js";
3
+ import "../do-oauth-client-provider-CcTno-25.js";
4
+ import "../index-DhJCaDWd.js";
5
+ import "../ai-types-D5YoPrBZ.js";
6
+ import { c as ConnectionContext, s as Connection, t as Agent } from "../index-Bdzb2feZ.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";
10
+ import { Server } from "@modelcontextprotocol/sdk/server/index.js";
11
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
12
+ import { Transport } from "@modelcontextprotocol/sdk/shared/transport.js";
15
13
 
16
- interface CORSOptions {
17
- origin?: string;
18
- methods?: string;
19
- headers?: string;
20
- maxAge?: number;
21
- exposeHeaders?: string;
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);
22
20
  }
23
- type MaybePromise<T> = T | Promise<T>;
24
- declare abstract class McpAgent<Env = unknown, State = unknown, Props extends Record<string, unknown> = Record<string, unknown>> extends DurableObject<Env> {
25
- private _status;
26
- private _transport?;
27
- private _transportType;
28
- private _requestIdToConnectionId;
29
- /**
30
- * Since McpAgent's _aren't_ yet real "Agents", let's only expose a couple of the methods
31
- * to the outer class: initialState/state/setState/onStateUpdate/sql
32
- */
33
- private _agent;
34
- get mcp(): MCPClientManager;
35
- protected constructor(ctx: DurableObjectState, env: Env);
36
- /**
37
- * Agents API allowlist
38
- */
39
- initialState: State;
40
- get state(): State;
41
- sql<T = Record<string, string | number | boolean | null>>(strings: TemplateStringsArray, ...values: (string | number | boolean | null)[]): T[];
42
- setState(state: State): void;
43
- onStateUpdate(state: State | undefined, source: Connection | "server"): void;
44
- onStart(): Promise<void>;
45
- /**
46
- * McpAgent API
47
- */
48
- abstract server: MaybePromise<McpServer | Server>;
49
- props: Props;
50
- initRun: boolean;
51
- abstract init(): Promise<void>;
52
- _init(props: Props): Promise<void>;
53
- setInitialized(): Promise<void>;
54
- isInitialized(): Promise<boolean>;
55
- private _initialize;
56
- fetch(request: Request): Promise<Response>;
57
- getWebSocket(): WebSocket | null;
58
- getWebSocketForResponseID(id: string): WebSocket | null;
59
- onMessage(connection: Connection, event: WSMessage): Promise<void>;
60
- onSSEMcpMessage(sessionId: string, request: Request): Promise<Error | null>;
61
- webSocketMessage(ws: WebSocket, event: ArrayBuffer | string): Promise<void>;
62
- webSocketError(ws: WebSocket, error: unknown): Promise<void>;
63
- webSocketClose(ws: WebSocket, code: number, reason: string, wasClean: boolean): Promise<void>;
64
- static mount(path: string, { binding, corsOptions, }?: {
65
- binding?: string;
66
- corsOptions?: CORSOptions;
67
- }): {
68
- fetch<Env>(this: void, request: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
69
- };
70
- static serveSSE(path: string, { binding, corsOptions, }?: {
71
- binding?: string;
72
- corsOptions?: CORSOptions;
73
- }): {
74
- fetch<Env>(this: void, request: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
75
- };
76
- static serve(path: string, { binding, corsOptions, }?: {
77
- binding?: string;
78
- corsOptions?: CORSOptions;
79
- }): {
80
- fetch<Env>(this: void, request: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
81
- };
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);
82
26
  }
83
-
84
- export { McpAgent };
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): 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
128
+ //#region src/mcp/index.d.ts
129
+ declare abstract class McpAgent<Env = unknown, State = unknown, Props extends Record<string, unknown> = Record<string, unknown>> extends Agent<Env, State, Props> {
130
+ private _transport?;
131
+ props?: Props;
132
+ abstract server: MaybePromise<McpServer | Server>;
133
+ abstract init(): Promise<void>;
134
+ setInitializeRequest(initializeRequest: JSONRPCMessage): Promise<void>;
135
+ getInitializeRequest(): Promise<JSONRPCMessage | undefined>;
136
+ /** Read the transport type for this agent.
137
+ * This relies on the naming scheme being `sse:${sessionId}`
138
+ * or `streamable-http:${sessionId}`.
139
+ */
140
+ getTransportType(): BaseTransportType;
141
+ /** Read the sessionId for this agent.
142
+ * This relies on the naming scheme being `sse:${sessionId}`
143
+ * or `streamable-http:${sessionId}`.
144
+ */
145
+ getSessionId(): string;
146
+ /** Get the unique WebSocket. SSE transport only. */
147
+ private getWebSocket;
148
+ /** Returns a new transport matching the type of the Agent. */
149
+ private initTransport;
150
+ /** Update and store the props */
151
+ updateProps(props?: Props): Promise<void>;
152
+ reinitializeServer(): Promise<void>;
153
+ /** Sets up the MCP transport and server every time the Agent is started.*/
154
+ onStart(props?: Props): Promise<void>;
155
+ /** Validates new WebSocket connections. */
156
+ onConnect(conn: Connection, {
157
+ request: req
158
+ }: ConnectionContext): Promise<void>;
159
+ /** Handles MCP Messages for the legacy SSE transport. */
160
+ onSSEMcpMessage(_sessionId: string, messageBody: unknown): Promise<Error | null>;
161
+ /** Elicit user input with a message and schema */
162
+ elicitInput(params: {
163
+ message: string;
164
+ requestedSchema: unknown;
165
+ }): Promise<ElicitResult$1>;
166
+ /** Wait for elicitation response through storage polling */
167
+ private _waitForElicitationResponse;
168
+ /** Handle elicitation responses */
169
+ private _handleElicitationResponse;
170
+ /** Return a handler for the given path for this MCP.
171
+ * Defaults to Streamable HTTP transport.
172
+ */
173
+ static serve(path: string, {
174
+ binding,
175
+ corsOptions,
176
+ transport,
177
+ jurisdiction
178
+ }?: ServeOptions): {
179
+ fetch<Env>(this: void, request: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
180
+ };
181
+ /**
182
+ * Legacy api
183
+ **/
184
+ static mount(path: string, opts?: Omit<ServeOptions, "transport">): {
185
+ fetch<Env>(this: void, request: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
186
+ };
187
+ static serveSSE(path: string, opts?: Omit<ServeOptions, "transport">): {
188
+ fetch<Env>(this: void, request: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
189
+ };
190
+ }
191
+ //#endregion
192
+ export { type CreateMcpHandlerOptions, type ElicitRequest, ElicitRequestSchema, type ElicitResult, type MCPClientOAuthCallbackConfig, type MCPClientOAuthResult, type MCPConnectionResult, type MCPServerOptions, McpAgent, type McpAuthContext, SSEEdgeClientTransport, StreamableHTTPEdgeClientTransport, type TransportState, WorkerTransport, type WorkerTransportOptions, createMcpHandler, experimental_createMcpHandler, getMcpAuthContext };
193
+ //# sourceMappingURL=index.d.ts.map