agents 0.0.0-8dac62c → 0.0.0-8f03865

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 (90) hide show
  1. package/README.md +130 -6
  2. package/dist/ai-chat-agent.d.ts +100 -19
  3. package/dist/ai-chat-agent.js +812 -329
  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 -19
  9. package/dist/ai-react.d.ts +26 -23
  10. package/dist/ai-react.js +409 -304
  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 -91
  16. package/dist/ai-types.js +3 -7
  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 -12
  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 +56 -541
  42. package/dist/index.js +8 -31
  43. package/dist/mcp/client.d.ts +4 -11
  44. package/dist/mcp/client.js +4 -9
  45. package/dist/mcp/do-oauth-client-provider.d.ts +2 -41
  46. package/dist/mcp/do-oauth-client-provider.js +3 -7
  47. package/dist/mcp/index.d.ts +191 -109
  48. package/dist/mcp/index.js +1435 -943
  49. package/dist/mcp/index.js.map +1 -1
  50. package/dist/mcp/x402.d.ts +34 -0
  51. package/dist/mcp/x402.js +198 -0
  52. package/dist/mcp/x402.js.map +1 -0
  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 -11
  56. package/dist/react-DIGWa87z.d.ts +137 -0
  57. package/dist/react.d.ts +15 -123
  58. package/dist/react.js +190 -112
  59. package/dist/react.js.map +1 -1
  60. package/dist/schedule.d.ts +13 -10
  61. package/dist/schedule.js +43 -31
  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 +72 -31
  69. package/dist/ai-chat-v5-migration.js.map +0 -1
  70. package/dist/ai-types.js.map +0 -1
  71. package/dist/chunk-AVYJQSLW.js +0 -17
  72. package/dist/chunk-AVYJQSLW.js.map +0 -1
  73. package/dist/chunk-PUJ7PRRT.js +0 -1299
  74. package/dist/chunk-PUJ7PRRT.js.map +0 -1
  75. package/dist/chunk-PVQZBKN7.js +0 -106
  76. package/dist/chunk-PVQZBKN7.js.map +0 -1
  77. package/dist/chunk-QEVM4BVL.js +0 -116
  78. package/dist/chunk-QEVM4BVL.js.map +0 -1
  79. package/dist/chunk-UJVEAURM.js +0 -150
  80. package/dist/chunk-UJVEAURM.js.map +0 -1
  81. package/dist/chunk-VYENMKFS.js +0 -612
  82. package/dist/chunk-VYENMKFS.js.map +0 -1
  83. package/dist/client-B9tFv5gX.d.ts +0 -4607
  84. package/dist/client.js.map +0 -1
  85. package/dist/index.js.map +0 -1
  86. package/dist/mcp/client.js.map +0 -1
  87. package/dist/mcp/do-oauth-client-provider.js.map +0 -1
  88. package/dist/observability/index.js.map +0 -1
  89. package/dist/serializable.js.map +0 -1
  90. package/src/index.ts +0 -1937
@@ -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-B-ryFIPr.js";
2
+ export { AgentsOAuthProvider, DurableObjectOAuthClientProvider };
@@ -1,7 +1,3 @@
1
- import {
2
- DurableObjectOAuthClientProvider
3
- } from "../chunk-PVQZBKN7.js";
4
- export {
5
- DurableObjectOAuthClientProvider
6
- };
7
- //# sourceMappingURL=do-oauth-client-provider.js.map
1
+ import { t as DurableObjectOAuthClientProvider } from "../do-oauth-client-provider-B1fVIshX.js";
2
+
3
+ export { DurableObjectOAuthClientProvider };
@@ -1,112 +1,194 @@
1
- import { M as MCPClientManager } from '../client-B9tFv5gX.js';
2
- export { S as SSEEdgeClientTransport, a as StreamableHTTPEdgeClientTransport } from '../client-B9tFv5gX.js';
3
- import { DurableObject } from 'cloudflare:workers';
4
- import { Server } from '@modelcontextprotocol/sdk/server/index.js';
5
- import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
6
- import { ElicitResult } from '@modelcontextprotocol/sdk/types.js';
7
- export { ElicitRequest, ElicitRequestSchema, ElicitResult } from '@modelcontextprotocol/sdk/types.js';
8
- import { Connection, WSMessage } from 'partyserver';
9
- import 'zod';
10
- import '@modelcontextprotocol/sdk/client/index.js';
11
- import '@modelcontextprotocol/sdk/shared/protocol.js';
12
- import 'ai';
13
- import '@modelcontextprotocol/sdk/client/sse.js';
14
- import '@modelcontextprotocol/sdk/client/streamableHttp.js';
15
- import './do-oauth-client-provider.js';
16
- import '@modelcontextprotocol/sdk/client/auth.js';
17
- 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";
18
14
 
19
- interface CORSOptions {
20
- origin?: string;
21
- methods?: string;
22
- headers?: string;
23
- maxAge?: number;
24
- exposeHeaders?: string;
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);
25
21
  }
26
- type MaybePromise<T> = T | Promise<T>;
27
- declare abstract class McpAgent<Env = unknown, State = unknown, Props extends Record<string, unknown> = Record<string, unknown>> extends DurableObject<Env> {
28
- private _status;
29
- private _transport?;
30
- private _transportType;
31
- private _requestIdToConnectionId;
32
- /**
33
- * Since McpAgent's _aren't_ yet real "Agents", let's only expose a couple of the methods
34
- * to the outer class: initialState/state/setState/onStateUpdate/sql
35
- */
36
- private _agent;
37
- get mcp(): MCPClientManager;
38
- protected constructor(ctx: DurableObjectState, env: Env);
39
- /**
40
- * Agents API allowlist
41
- */
42
- initialState: State;
43
- get state(): State;
44
- sql<T = Record<string, string | number | boolean | null>>(strings: TemplateStringsArray, ...values: (string | number | boolean | null)[]): T[];
45
- setState(state: State): void;
46
- /**
47
- * Elicit user input with a message and schema
48
- */
49
- elicitInput(params: {
50
- message: string;
51
- requestedSchema: unknown;
52
- }): Promise<ElicitResult>;
53
- onStateUpdate(state: State | undefined, source: Connection | "server"): void;
54
- onStart(): Promise<void>;
55
- /**
56
- * McpAgent API
57
- */
58
- abstract server: MaybePromise<McpServer | Server>;
59
- props: Props;
60
- initRun: boolean;
61
- abstract init(): Promise<void>;
62
- /**
63
- * Handle errors that occur during initialization or operation.
64
- * Override this method to provide custom error handling.
65
- * @param error - The error that occurred
66
- * @returns An error response object with status code and message
67
- */
68
- onError(error: Error): {
69
- status: number;
70
- message: string;
71
- };
72
- _init(props: Props): Promise<void>;
73
- setInitialized(): Promise<void>;
74
- isInitialized(): Promise<boolean>;
75
- updateProps(props: Props): Promise<void>;
76
- private _initialize;
77
- fetch(request: Request): Promise<Response>;
78
- getWebSocket(): WebSocket | null;
79
- getWebSocketForResponseID(id: string): WebSocket | null;
80
- onMessage(connection: Connection, event: WSMessage): Promise<void>;
81
- /**
82
- * Wait for elicitation response through storage polling
83
- */
84
- private _waitForElicitationResponse;
85
- /**
86
- * Handle elicitation responses */
87
- private _handleElicitationResponse;
88
- onSSEMcpMessage(_sessionId: string, messageBody: unknown): Promise<Error | null>;
89
- webSocketMessage(ws: WebSocket, event: ArrayBuffer | string): Promise<void>;
90
- webSocketError(ws: WebSocket, error: unknown): Promise<void>;
91
- webSocketClose(ws: WebSocket, code: number, reason: string, wasClean: boolean): Promise<void>;
92
- static mount(path: string, { binding, corsOptions }?: {
93
- binding?: string;
94
- corsOptions?: CORSOptions;
95
- }): {
96
- fetch<Env>(this: void, request: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
97
- };
98
- static serveSSE(path: string, { binding, corsOptions }?: {
99
- binding?: string;
100
- corsOptions?: CORSOptions;
101
- }): {
102
- fetch<Env>(this: void, request: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
103
- };
104
- static serve(path: string, { binding, corsOptions }?: {
105
- binding?: string;
106
- corsOptions?: CORSOptions;
107
- }): {
108
- fetch<Env>(this: void, request: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
109
- };
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);
110
27
  }
111
-
112
- export { McpAgent };
28
+ //#endregion
29
+ //#region src/mcp/worker-transport.d.ts
30
+ declare const SUPPORTED_PROTOCOL_VERSIONS: readonly ["2025-03-26", "2025-06-18"];
31
+ type ProtocolVersion = (typeof SUPPORTED_PROTOCOL_VERSIONS)[number];
32
+ interface MCPStorageApi {
33
+ get(): Promise<TransportState | undefined> | TransportState | undefined;
34
+ set(state: TransportState): Promise<void> | void;
35
+ }
36
+ interface TransportState {
37
+ sessionId?: string;
38
+ initialized: boolean;
39
+ protocolVersion?: ProtocolVersion;
40
+ }
41
+ interface WorkerTransportOptions {
42
+ sessionIdGenerator?: () => string;
43
+ /**
44
+ * Enable traditional Request/Response mode, this will disable streaming.
45
+ */
46
+ enableJsonResponse?: boolean;
47
+ onsessioninitialized?: (sessionId: string) => void;
48
+ corsOptions?: CORSOptions;
49
+ /**
50
+ * Optional storage api for persisting transport state.
51
+ * Use this to store session state in Durable Object/Agent storage
52
+ * so it survives hibernation/restart.
53
+ */
54
+ storage?: MCPStorageApi;
55
+ }
56
+ declare class WorkerTransport implements Transport {
57
+ started: boolean;
58
+ private initialized;
59
+ private sessionIdGenerator?;
60
+ private enableJsonResponse;
61
+ private onsessioninitialized?;
62
+ private standaloneSseStreamId;
63
+ private streamMapping;
64
+ private requestToStreamMapping;
65
+ private requestResponseMap;
66
+ private corsOptions?;
67
+ private protocolVersion?;
68
+ private storage?;
69
+ private stateRestored;
70
+ sessionId?: string;
71
+ onclose?: () => void;
72
+ onerror?: (error: Error) => void;
73
+ onmessage?: (message: JSONRPCMessage, extra?: MessageExtraInfo) => void;
74
+ constructor(options?: WorkerTransportOptions);
75
+ /**
76
+ * Restore transport state from persistent storage.
77
+ * This is automatically called on start.
78
+ */
79
+ private restoreState;
80
+ /**
81
+ * Persist current transport state to storage.
82
+ */
83
+ private saveState;
84
+ start(): Promise<void>;
85
+ private validateProtocolVersion;
86
+ private getHeaders;
87
+ handleRequest(request: Request, parsedBody?: unknown): Promise<Response>;
88
+ private handleGetRequest;
89
+ private handlePostRequest;
90
+ private handleDeleteRequest;
91
+ private handleOptionsRequest;
92
+ private handleUnsupportedRequest;
93
+ private validateSession;
94
+ close(): Promise<void>;
95
+ send(message: JSONRPCMessage, options?: TransportSendOptions): Promise<void>;
96
+ }
97
+ //#endregion
98
+ //#region src/mcp/auth-context.d.ts
99
+ interface McpAuthContext {
100
+ props: Record<string, unknown>;
101
+ }
102
+ declare function getMcpAuthContext(): McpAuthContext | undefined;
103
+ //#endregion
104
+ //#region src/mcp/handler.d.ts
105
+ interface CreateMcpHandlerOptions extends WorkerTransportOptions {
106
+ /**
107
+ * The route path that this MCP handler should respond to.
108
+ * If specified, the handler will only process requests that match this route.
109
+ * @default "/mcp"
110
+ */
111
+ route?: string;
112
+ /**
113
+ * An optional auth context to use for handling MCP requests.
114
+ * If not provided, the handler will look for props in the execution context.
115
+ */
116
+ authContext?: McpAuthContext;
117
+ /**
118
+ * An optional transport to use for handling MCP requests.
119
+ * If not provided, a WorkerTransport will be created with the provided WorkerTransportOptions.
120
+ */
121
+ transport?: WorkerTransport;
122
+ }
123
+ declare function createMcpHandler(server: McpServer | Server, options?: CreateMcpHandlerOptions): (request: Request, env: unknown, ctx: ExecutionContext) => Promise<Response>;
124
+ /**
125
+ * @deprecated This has been renamed to createMcpHandler, and experimental_createMcpHandler will be removed in the next major version
126
+ */
127
+ declare function experimental_createMcpHandler(server: McpServer | Server, options?: CreateMcpHandlerOptions): (request: Request, env: unknown, ctx: ExecutionContext) => Promise<Response>;
128
+ //#endregion
129
+ //#region src/mcp/index.d.ts
130
+ declare abstract class McpAgent<Env = unknown, State = unknown, Props extends Record<string, unknown> = Record<string, unknown>> extends Agent<Env, State, Props> {
131
+ private _transport?;
132
+ props?: Props;
133
+ abstract server: MaybePromise<McpServer | Server>;
134
+ abstract init(): Promise<void>;
135
+ setInitializeRequest(initializeRequest: JSONRPCMessage): Promise<void>;
136
+ getInitializeRequest(): Promise<JSONRPCMessage | undefined>;
137
+ /** Read the transport type for this agent.
138
+ * This relies on the naming scheme being `sse:${sessionId}`
139
+ * or `streamable-http:${sessionId}`.
140
+ */
141
+ getTransportType(): BaseTransportType;
142
+ /** Read the sessionId for this agent.
143
+ * This relies on the naming scheme being `sse:${sessionId}`
144
+ * or `streamable-http:${sessionId}`.
145
+ */
146
+ getSessionId(): string;
147
+ /** Get the unique WebSocket. SSE transport only. */
148
+ getWebSocket(): Connection<unknown> | null;
149
+ /** Returns a new transport matching the type of the Agent. */
150
+ private initTransport;
151
+ /** Update and store the props */
152
+ updateProps(props?: Props): Promise<void>;
153
+ reinitializeServer(): Promise<void>;
154
+ /** Sets up the MCP transport and server every time the Agent is started.*/
155
+ onStart(props?: Props): Promise<void>;
156
+ /** Validates new WebSocket connections. */
157
+ onConnect(conn: Connection, {
158
+ request: req
159
+ }: ConnectionContext): Promise<void>;
160
+ /** Handles MCP Messages for the legacy SSE transport. */
161
+ onSSEMcpMessage(_sessionId: string, messageBody: unknown, extraInfo?: MessageExtraInfo): Promise<Error | null>;
162
+ /** Elicit user input with a message and schema */
163
+ elicitInput(params: {
164
+ message: string;
165
+ requestedSchema: unknown;
166
+ }): Promise<ElicitResult$1>;
167
+ /** Wait for elicitation response through storage polling */
168
+ private _waitForElicitationResponse;
169
+ /** Handle elicitation responses */
170
+ private _handleElicitationResponse;
171
+ /** Return a handler for the given path for this MCP.
172
+ * Defaults to Streamable HTTP transport.
173
+ */
174
+ static serve(path: string, {
175
+ binding,
176
+ corsOptions,
177
+ transport,
178
+ jurisdiction
179
+ }?: ServeOptions): {
180
+ fetch<Env>(this: void, request: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
181
+ };
182
+ /**
183
+ * Legacy api
184
+ **/
185
+ static mount(path: string, opts?: Omit<ServeOptions, "transport">): {
186
+ fetch<Env>(this: void, request: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
187
+ };
188
+ static serveSSE(path: string, opts?: Omit<ServeOptions, "transport">): {
189
+ fetch<Env>(this: void, request: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
190
+ };
191
+ }
192
+ //#endregion
193
+ 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 };
194
+ //# sourceMappingURL=index.d.ts.map