agents 0.0.0-dfa677f → 0.0.0-e135cf5

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 (74) hide show
  1. package/README.md +255 -27
  2. package/dist/ai-chat-agent.d.ts +59 -11
  3. package/dist/ai-chat-agent.js +532 -159
  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 -72
  10. package/dist/ai-react.js +261 -185
  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 -69
  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-CbWe9FBd.d.ts +104 -0
  23. package/dist/client-DZhjV_XA.js +719 -0
  24. package/dist/client-DZhjV_XA.js.map +1 -0
  25. package/dist/client-DZuq0CXm.d.ts +5283 -0
  26. package/dist/client.d.ts +12 -79
  27. package/dist/client.js +3 -137
  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-CswoD5Lu.js +93 -0
  32. package/dist/do-oauth-client-provider-CswoD5Lu.js.map +1 -0
  33. package/dist/do-oauth-client-provider-DGc5pP0l.d.ts +55 -0
  34. package/dist/index-DHakc8tU.d.ts +566 -0
  35. package/dist/index-DhJCaDWd.d.ts +58 -0
  36. package/dist/index.d.ts +63 -302
  37. package/dist/index.js +7 -22
  38. package/dist/mcp/client.d.ts +4 -0
  39. package/dist/mcp/client.js +3 -0
  40. package/dist/mcp/do-oauth-client-provider.d.ts +2 -0
  41. package/dist/mcp/do-oauth-client-provider.js +3 -0
  42. package/dist/mcp/index.d.ts +193 -0
  43. package/dist/mcp/index.js +1440 -0
  44. package/dist/mcp/index.js.map +1 -0
  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-Ce7gmqP6.d.ts +113 -0
  52. package/dist/react.d.ts +10 -39
  53. package/dist/react.js +185 -93
  54. package/dist/react.js.map +1 -1
  55. package/dist/schedule.d.ts +89 -12
  56. package/dist/schedule.js +46 -23
  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-C8K3lu37.js +1231 -0
  62. package/dist/src-C8K3lu37.js.map +1 -0
  63. package/package.json +133 -51
  64. package/dist/ai-types.js.map +0 -1
  65. package/dist/chunk-HMLY7DHA.js +0 -16
  66. package/dist/chunk-HMLY7DHA.js.map +0 -1
  67. package/dist/chunk-KRBQHBPA.js +0 -599
  68. package/dist/chunk-KRBQHBPA.js.map +0 -1
  69. package/dist/client.js.map +0 -1
  70. package/dist/index.js.map +0 -1
  71. package/dist/mcp.d.ts +0 -58
  72. package/dist/mcp.js +0 -945
  73. package/dist/mcp.js.map +0 -1
  74. package/src/index.ts +0 -925
package/dist/index.d.ts CHANGED
@@ -1,309 +1,70 @@
1
- import { Server, Connection, PartyServerOptions } from "partyserver";
2
- export { Connection, ConnectionContext, WSMessage } from "partyserver";
3
- import { AsyncLocalStorage } from "node:async_hooks";
4
- import { WorkflowEntrypoint as WorkflowEntrypoint$1 } from "cloudflare:workers";
5
-
6
- /**
7
- * RPC request message from client
8
- */
9
- type RPCRequest = {
10
- type: "rpc";
11
- id: string;
12
- method: string;
13
- args: unknown[];
14
- };
15
- /**
16
- * State update message from client
17
- */
18
- type StateUpdateMessage = {
19
- type: "cf_agent_state";
20
- state: unknown;
21
- };
22
- /**
23
- * RPC response message to client
24
- */
25
- type RPCResponse = {
26
- type: "rpc";
27
- id: string;
28
- } & (
29
- | {
30
- success: true;
31
- result: unknown;
32
- done?: false;
33
- }
34
- | {
35
- success: true;
36
- result: unknown;
37
- done: true;
38
- }
39
- | {
40
- success: false;
41
- error: string;
42
- }
43
- );
44
- /**
45
- * Metadata for a callable method
46
- */
47
- type CallableMetadata = {
48
- /** Optional description of what the method does */
49
- description?: string;
50
- /** Whether the method supports streaming responses */
51
- streaming?: boolean;
52
- };
53
- /**
54
- * Decorator that marks a method as callable by clients
55
- * @param metadata Optional metadata about the callable method
56
- */
57
- declare function unstable_callable(
58
- metadata?: CallableMetadata
59
- ): <This, Args extends unknown[], Return>(
60
- target: (this: This, ...args: Args) => Return,
61
- context: ClassMethodDecoratorContext
62
- ) => (this: This, ...args: Args) => Return;
63
- /**
64
- * A class for creating workflow entry points that can be used with Cloudflare Workers
65
- */
66
- declare class WorkflowEntrypoint extends WorkflowEntrypoint$1 {}
67
- /**
68
- * Represents a scheduled task within an Agent
69
- * @template T Type of the payload data
70
- */
71
- type Schedule<T = string> = {
72
- /** Unique identifier for the schedule */
73
- id: string;
74
- /** Name of the method to be called */
75
- callback: string;
76
- /** Data to be passed to the callback */
77
- payload: T;
78
- } & (
79
- | {
80
- /** Type of schedule for one-time execution at a specific time */
81
- type: "scheduled";
82
- /** Timestamp when the task should execute */
83
- time: number;
84
- }
85
- | {
86
- /** Type of schedule for delayed execution */
87
- type: "delayed";
88
- /** Timestamp when the task should execute */
89
- time: number;
90
- /** Number of seconds to delay execution */
91
- delayInSeconds: number;
92
- }
93
- | {
94
- /** Type of schedule for recurring execution based on cron expression */
95
- type: "cron";
96
- /** Timestamp for the next execution */
97
- time: number;
98
- /** Cron expression defining the schedule */
99
- cron: string;
100
- }
101
- );
102
- declare const unstable_context: AsyncLocalStorage<{
103
- agent: Agent<unknown>;
104
- connection: Connection | undefined;
105
- request: Request | undefined;
106
- }>;
107
- /**
108
- * Base class for creating Agent implementations
109
- * @template Env Environment type containing bindings
110
- * @template State State type to store within the Agent
111
- */
112
- declare class Agent<Env, State = unknown> extends Server<Env> {
113
- #private;
114
- /**
115
- * Initial state for the Agent
116
- * Override to provide default state values
117
- */
118
- initialState: State;
119
- /**
120
- * Current state of the Agent
121
- */
122
- get state(): State;
123
- /**
124
- * Agent configuration options
125
- */
126
- static options: {
127
- /** Whether the Agent should hibernate when inactive */
128
- hibernate: boolean;
129
- };
130
- /**
131
- * Execute SQL queries against the Agent's database
132
- * @template T Type of the returned rows
133
- * @param strings SQL query template strings
134
- * @param values Values to be inserted into the query
135
- * @returns Array of query results
136
- */
137
- sql<T = Record<string, string | number | boolean | null>>(
138
- strings: TemplateStringsArray,
139
- ...values: (string | number | boolean | null)[]
140
- ): T[];
141
- constructor(ctx: AgentContext, env: Env);
142
- /**
143
- * Update the Agent's state
144
- * @param state New state to set
145
- */
146
- setState(state: State): void;
147
- /**
148
- * Called when the Agent's state is updated
149
- * @param state Updated state
150
- * @param source Source of the state update ("server" or a client connection)
151
- */
152
- onStateUpdate(state: State | undefined, source: Connection | "server"): void;
153
- /**
154
- * Called when the Agent receives an email
155
- * @param email Email message to process
156
- */
157
- onEmail(email: ForwardableEmailMessage): Promise<void>;
158
- onError(connection: Connection, error: unknown): void | Promise<void>;
159
- onError(error: unknown): void | Promise<void>;
160
- /**
161
- * Render content (not implemented in base class)
162
- */
163
- render(): void;
164
- /**
165
- * Schedule a task to be executed in the future
166
- * @template T Type of the payload data
167
- * @param when When to execute the task (Date, seconds delay, or cron expression)
168
- * @param callback Name of the method to call
169
- * @param payload Data to pass to the callback
170
- * @returns Schedule object representing the scheduled task
171
- */
172
- schedule<T = string>(
173
- when: Date | string | number,
174
- callback: keyof this,
175
- payload?: T
176
- ): Promise<Schedule<T>>;
177
- /**
178
- * Get a scheduled task by ID
179
- * @template T Type of the payload data
180
- * @param id ID of the scheduled task
181
- * @returns The Schedule object or undefined if not found
182
- */
183
- getSchedule<T = string>(id: string): Promise<Schedule<T> | undefined>;
184
- /**
185
- * Get scheduled tasks matching the given criteria
186
- * @template T Type of the payload data
187
- * @param criteria Criteria to filter schedules
188
- * @returns Array of matching Schedule objects
189
- */
190
- getSchedules<T = string>(criteria?: {
191
- description?: string;
192
- id?: string;
193
- type?: "scheduled" | "delayed" | "cron";
194
- timeRange?: {
195
- start?: Date;
196
- end?: Date;
197
- };
198
- }): Schedule<T>[];
199
- /**
200
- * Cancel a scheduled task
201
- * @param id ID of the task to cancel
202
- * @returns true if the task was cancelled, false otherwise
203
- */
204
- cancelSchedule(id: string): Promise<boolean>;
205
- /**
206
- * Method called when an alarm fires
207
- * Executes any scheduled tasks that are due
208
- */
209
- alarm(): Promise<void>;
210
- /**
211
- * Destroy the Agent, removing all state and scheduled tasks
212
- */
213
- destroy(): Promise<void>;
214
- }
215
- /**
216
- * Namespace for creating Agent instances
217
- * @template Agentic Type of the Agent class
218
- */
219
- type AgentNamespace<Agentic extends Agent<unknown>> =
220
- DurableObjectNamespace<Agentic>;
221
- /**
222
- * Agent's durable context
223
- */
224
- type AgentContext = DurableObjectState;
225
- /**
226
- * Configuration options for Agent routing
227
- */
228
- type AgentOptions<Env> = PartyServerOptions<Env> & {
229
- /**
230
- * Whether to enable CORS for the Agent
231
- */
232
- cors?: boolean | HeadersInit | undefined;
233
- };
234
- /**
235
- * Route a request to the appropriate Agent
236
- * @param request Request to route
237
- * @param env Environment containing Agent bindings
238
- * @param options Routing options
239
- * @returns Response from the Agent or undefined if no route matched
240
- */
241
- declare function routeAgentRequest<Env>(
242
- request: Request,
243
- env: Env,
244
- options?: AgentOptions<Env>
245
- ): Promise<Response | null>;
246
- /**
247
- * Route an email to the appropriate Agent
248
- * @param email Email message to route
249
- * @param env Environment containing Agent bindings
250
- * @param options Routing options
251
- */
252
- declare function routeAgentEmail<Env>(
253
- email: ForwardableEmailMessage,
254
- env: Env,
255
- options?: AgentOptions<Env>
256
- ): Promise<void>;
257
- /**
258
- * Get or create an Agent by name
259
- * @template Env Environment type containing bindings
260
- * @template T Type of the Agent class
261
- * @param namespace Agent namespace
262
- * @param name Name of the Agent instance
263
- * @param options Options for Agent creation
264
- * @returns Promise resolving to an Agent instance stub
265
- */
266
- declare function getAgentByName<Env, T extends Agent<Env>>(
267
- namespace: AgentNamespace<T>,
268
- name: string,
269
- options?: {
270
- jurisdiction?: DurableObjectJurisdiction;
271
- locationHint?: DurableObjectLocationHint;
272
- }
273
- ): Promise<DurableObjectStub<T>>;
274
- /**
275
- * A wrapper for streaming responses in callable methods
276
- */
277
- declare class StreamingResponse {
278
- #private;
279
- constructor(connection: Connection, id: string);
280
- /**
281
- * Send a chunk of data to the client
282
- * @param chunk The data to send
283
- */
284
- send(chunk: unknown): void;
285
- /**
286
- * End the stream and send the final chunk (if any)
287
- * @param finalChunk Optional final chunk of data to send
288
- */
289
- end(finalChunk?: unknown): void;
290
- }
291
-
1
+ import { u as TransportType } from "./client-DZuq0CXm.js";
2
+ import "./mcp-Dw5vDrY8.js";
3
+ import "./do-oauth-client-provider-DGc5pP0l.js";
4
+ import "./index-DhJCaDWd.js";
5
+ import "./ai-types-D5YoPrBZ.js";
6
+ import {
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-DHakc8tU.js";
292
38
  export {
293
39
  Agent,
294
- type AgentContext,
295
- type AgentNamespace,
296
- type AgentOptions,
297
- type CallableMetadata,
298
- type RPCRequest,
299
- type RPCResponse,
300
- type Schedule,
301
- type StateUpdateMessage,
40
+ AgentContext,
41
+ AgentEmail,
42
+ AgentNamespace,
43
+ AgentOptions,
44
+ CallableMetadata,
45
+ Connection,
46
+ ConnectionContext,
47
+ EmailResolver,
48
+ EmailRoutingOptions,
49
+ EmailSendOptions,
50
+ MCPServer,
51
+ MCPServerMessage,
52
+ MCPServersState,
53
+ QueueItem,
54
+ RPCRequest,
55
+ RPCResponse,
56
+ Schedule,
57
+ StateUpdateMessage,
302
58
  StreamingResponse,
303
- WorkflowEntrypoint,
59
+ TransportType,
60
+ WSMessage,
61
+ callable,
62
+ createAddressBasedEmailResolver,
63
+ createCatchAllEmailResolver,
64
+ createHeaderBasedEmailResolver,
304
65
  getAgentByName,
66
+ getCurrentAgent,
305
67
  routeAgentEmail,
306
68
  routeAgentRequest,
307
- unstable_callable,
308
- unstable_context,
69
+ unstable_callable
309
70
  };
package/dist/index.js CHANGED
@@ -1,22 +1,7 @@
1
- import {
2
- Agent,
3
- StreamingResponse,
4
- WorkflowEntrypoint,
5
- getAgentByName,
6
- routeAgentEmail,
7
- routeAgentRequest,
8
- unstable_callable,
9
- unstable_context
10
- } from "./chunk-KRBQHBPA.js";
11
- import "./chunk-HMLY7DHA.js";
12
- export {
13
- Agent,
14
- StreamingResponse,
15
- WorkflowEntrypoint,
16
- getAgentByName,
17
- routeAgentEmail,
18
- routeAgentRequest,
19
- unstable_callable,
20
- unstable_context
21
- };
22
- //# sourceMappingURL=index.js.map
1
+ import "./ai-types-B3aQaFv3.js";
2
+ import "./client-BfiZ3HQd.js";
3
+ import "./client-DZhjV_XA.js";
4
+ import "./do-oauth-client-provider-CswoD5Lu.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-C8K3lu37.js";
6
+
7
+ export { Agent, StreamingResponse, callable, createAddressBasedEmailResolver, createCatchAllEmailResolver, createHeaderBasedEmailResolver, getAgentByName, getCurrentAgent, routeAgentEmail, routeAgentRequest, unstable_callable };
@@ -0,0 +1,4 @@
1
+ import { i as getNamespacedData, n as MCPClientOAuthCallbackConfig, r as MCPClientOAuthResult, t as MCPClientManager } from "../client-DZuq0CXm.js";
2
+ import "../mcp-Dw5vDrY8.js";
3
+ import "../do-oauth-client-provider-DGc5pP0l.js";
4
+ export { MCPClientManager, MCPClientOAuthCallbackConfig, MCPClientOAuthResult, getNamespacedData };
@@ -0,0 +1,3 @@
1
+ import { n as getNamespacedData, t as MCPClientManager } from "../client-DZhjV_XA.js";
2
+
3
+ export { MCPClientManager, getNamespacedData };
@@ -0,0 +1,2 @@
1
+ import { n as DurableObjectOAuthClientProvider, t as AgentsOAuthProvider } from "../do-oauth-client-provider-DGc5pP0l.js";
2
+ export { AgentsOAuthProvider, DurableObjectOAuthClientProvider };
@@ -0,0 +1,3 @@
1
+ import { t as DurableObjectOAuthClientProvider } from "../do-oauth-client-provider-CswoD5Lu.js";
2
+
3
+ export { DurableObjectOAuthClientProvider };
@@ -0,0 +1,193 @@
1
+ import { c as MaybePromise, l as ServeOptions, n as MCPClientOAuthCallbackConfig, o as BaseTransportType, r as MCPClientOAuthResult, s as CORSOptions } from "../client-DZuq0CXm.js";
2
+ import "../mcp-Dw5vDrY8.js";
3
+ import "../do-oauth-client-provider-DGc5pP0l.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-DHakc8tU.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";
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): 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, McpAgent, type McpAuthContext, SSEEdgeClientTransport, StreamableHTTPEdgeClientTransport, type TransportState, WorkerTransport, type WorkerTransportOptions, createMcpHandler, experimental_createMcpHandler, getMcpAuthContext };
193
+ //# sourceMappingURL=index.d.ts.map