agents 0.0.0-ccbea72 → 0.0.0-cd8b7fd
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.
- package/README.md +5 -3
- package/dist/ai-chat-agent.d.ts +95 -13
- package/dist/ai-chat-agent.js +354 -74
- package/dist/ai-chat-agent.js.map +1 -1
- package/dist/{ai-chat-v5-migration-DBHGW4Hv.js → ai-chat-v5-migration-DguhuLKF.js} +1 -1
- package/dist/{ai-chat-v5-migration-DBHGW4Hv.js.map → ai-chat-v5-migration-DguhuLKF.js.map} +1 -1
- package/dist/ai-chat-v5-migration.js +1 -1
- package/dist/ai-react.d.ts +15 -9
- package/dist/ai-react.js +179 -29
- package/dist/ai-react.js.map +1 -1
- package/dist/{ai-types-B3aQaFv3.js → ai-types-CwgHzwUb.js} +5 -1
- package/dist/ai-types-CwgHzwUb.js.map +1 -0
- package/dist/{ai-types-D5YoPrBZ.d.ts → ai-types-D_hTbf25.d.ts} +15 -7
- package/dist/ai-types.d.ts +1 -1
- package/dist/ai-types.js +1 -1
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.js +28 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/{client-BfiZ3HQd.js → client-CcyhkGfN.js} +2 -2
- package/dist/{client-BfiZ3HQd.js.map → client-CcyhkGfN.js.map} +1 -1
- package/dist/{client-CbWe9FBd.d.ts → client-ClORm6f0.d.ts} +2 -2
- package/dist/client-DfIOsabL.d.ts +834 -0
- package/dist/client-QZa2Rq0l.js +1105 -0
- package/dist/client-QZa2Rq0l.js.map +1 -0
- package/dist/client.d.ts +2 -2
- package/dist/client.js +2 -2
- package/dist/codemode/ai.js +6 -5
- package/dist/codemode/ai.js.map +1 -1
- package/dist/context-BkKbAa1R.js +8 -0
- package/dist/context-BkKbAa1R.js.map +1 -0
- package/dist/context-_sPQqJWv.d.ts +24 -0
- package/dist/context.d.ts +6 -0
- package/dist/context.js +3 -0
- package/dist/{do-oauth-client-provider-DGc5pP0l.d.ts → do-oauth-client-provider-B-ryFIPr.d.ts} +20 -5
- package/dist/{do-oauth-client-provider-CswoD5Lu.js → do-oauth-client-provider-B1fVIshX.js} +70 -8
- package/dist/do-oauth-client-provider-B1fVIshX.js.map +1 -0
- package/dist/{index-DhJCaDWd.d.ts → index-CyDpAVHZ.d.ts} +2 -2
- package/dist/{index-D6iosdF4.d.ts → index-DPJ32qQn.d.ts} +83 -66
- package/dist/index.d.ts +34 -34
- package/dist/index.js +6 -5
- package/dist/mcp/client.d.ts +4 -4
- package/dist/mcp/client.js +2 -1
- package/dist/mcp/do-oauth-client-provider.d.ts +1 -1
- package/dist/mcp/do-oauth-client-provider.js +1 -1
- package/dist/mcp/index.d.ts +89 -24
- package/dist/mcp/index.js +294 -81
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/x402.js +10 -6
- package/dist/mcp/x402.js.map +1 -1
- package/dist/{mcp-Dw5vDrY8.d.ts → mcp-CzbSsLfc.d.ts} +1 -1
- package/dist/observability/index.d.ts +2 -2
- package/dist/observability/index.js +6 -5
- package/dist/{react-YzfC33jB.d.ts → react-MaOSl7Pr.d.ts} +33 -35
- package/dist/react.d.ts +10 -9
- package/dist/react.js +2 -2
- package/dist/react.js.map +1 -1
- package/dist/{serializable-CymX8ovI.d.ts → serializable-C4GLimgv.d.ts} +1 -1
- package/dist/serializable.d.ts +1 -1
- package/dist/{src-Dz0H9hSU.js → src-BmbDclOA.js} +128 -147
- package/dist/src-BmbDclOA.js.map +1 -0
- package/package.json +53 -38
- package/dist/ai-types-B3aQaFv3.js.map +0 -1
- package/dist/client-9Ld2_lnt.js +0 -786
- package/dist/client-9Ld2_lnt.js.map +0 -1
- package/dist/client-BmMRlvlM.d.ts +0 -5313
- package/dist/do-oauth-client-provider-CswoD5Lu.js.map +0 -1
- package/dist/src-Dz0H9hSU.js.map +0 -1
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { n as AgentEmail } from "./context-_sPQqJWv.js";
|
|
1
2
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
} from "./client-
|
|
6
|
-
import { t as Observability } from "./index-
|
|
7
|
-
import { n as MessageType } from "./ai-types-
|
|
3
|
+
h as TransportType,
|
|
4
|
+
t as MCPClientManager,
|
|
5
|
+
u as MCPConnectionState
|
|
6
|
+
} from "./client-DfIOsabL.js";
|
|
7
|
+
import { t as Observability } from "./index-CyDpAVHZ.js";
|
|
8
|
+
import { n as MessageType } from "./ai-types-D_hTbf25.js";
|
|
8
9
|
import {
|
|
9
10
|
Connection,
|
|
10
11
|
Connection as Connection$1,
|
|
@@ -87,9 +88,9 @@ declare function callable(
|
|
|
87
88
|
* @param metadata Optional metadata about the callable method
|
|
88
89
|
*/
|
|
89
90
|
declare const unstable_callable: (metadata?: CallableMetadata) => void;
|
|
90
|
-
type QueueItem<T
|
|
91
|
+
type QueueItem<T = string> = {
|
|
91
92
|
id: string;
|
|
92
|
-
payload: T
|
|
93
|
+
payload: T;
|
|
93
94
|
callback: keyof Agent<unknown>;
|
|
94
95
|
created_at: number;
|
|
95
96
|
};
|
|
@@ -97,13 +98,13 @@ type QueueItem<T$1 = string> = {
|
|
|
97
98
|
* Represents a scheduled task within an Agent
|
|
98
99
|
* @template T Type of the payload data
|
|
99
100
|
*/
|
|
100
|
-
type Schedule<T
|
|
101
|
+
type Schedule<T = string> = {
|
|
101
102
|
/** Unique identifier for the schedule */
|
|
102
103
|
id: string;
|
|
103
104
|
/** Name of the method to be called */
|
|
104
105
|
callback: string;
|
|
105
106
|
/** Data to be passed to the callback */
|
|
106
|
-
payload: T
|
|
107
|
+
payload: T;
|
|
107
108
|
} & (
|
|
108
109
|
| {
|
|
109
110
|
/** Type of schedule for one-time execution at a specific time */
|
|
@@ -139,9 +140,15 @@ type MCPServersState = {
|
|
|
139
140
|
servers: {
|
|
140
141
|
[id: string]: MCPServer;
|
|
141
142
|
};
|
|
142
|
-
tools: Tool
|
|
143
|
-
|
|
144
|
-
|
|
143
|
+
tools: (Tool & {
|
|
144
|
+
serverId: string;
|
|
145
|
+
})[];
|
|
146
|
+
prompts: (Prompt & {
|
|
147
|
+
serverId: string;
|
|
148
|
+
})[];
|
|
149
|
+
resources: (Resource & {
|
|
150
|
+
serverId: string;
|
|
151
|
+
})[];
|
|
145
152
|
};
|
|
146
153
|
type MCPServer = {
|
|
147
154
|
name: string;
|
|
@@ -152,9 +159,9 @@ type MCPServer = {
|
|
|
152
159
|
capabilities: ServerCapabilities | null;
|
|
153
160
|
};
|
|
154
161
|
declare function getCurrentAgent<
|
|
155
|
-
T
|
|
162
|
+
T extends Agent<unknown, unknown> = Agent<unknown, unknown>
|
|
156
163
|
>(): {
|
|
157
|
-
agent: T
|
|
164
|
+
agent: T | undefined;
|
|
158
165
|
connection: Connection | undefined;
|
|
159
166
|
request: Request | undefined;
|
|
160
167
|
email: AgentEmail | undefined;
|
|
@@ -171,7 +178,7 @@ declare class Agent<
|
|
|
171
178
|
> extends Server<Env, Props> {
|
|
172
179
|
private _state;
|
|
173
180
|
private _disposables;
|
|
174
|
-
private
|
|
181
|
+
private _destroyed;
|
|
175
182
|
private _ParentClass;
|
|
176
183
|
readonly mcp: MCPClientManager;
|
|
177
184
|
/**
|
|
@@ -325,7 +332,7 @@ declare class Agent<
|
|
|
325
332
|
/**
|
|
326
333
|
* Cancel a scheduled task
|
|
327
334
|
* @param id ID of the task to cancel
|
|
328
|
-
* @returns true if the task was cancelled, false
|
|
335
|
+
* @returns true if the task was cancelled, false if the task was not found
|
|
329
336
|
*/
|
|
330
337
|
cancelSchedule(id: string): Promise<boolean>;
|
|
331
338
|
private _scheduleNextAlarm;
|
|
@@ -347,7 +354,6 @@ declare class Agent<
|
|
|
347
354
|
* @returns A map of method names to their metadata
|
|
348
355
|
*/
|
|
349
356
|
private _isCallable;
|
|
350
|
-
private _ensureMcpStateRestored;
|
|
351
357
|
/**
|
|
352
358
|
* Connect to a new MCP Server
|
|
353
359
|
*
|
|
@@ -356,7 +362,8 @@ declare class Agent<
|
|
|
356
362
|
* @param callbackHost Base host for the agent, used for the redirect URI. If not provided, will be derived from the current request.
|
|
357
363
|
* @param agentsPrefix agents routing prefix if not using `agents`
|
|
358
364
|
* @param options MCP client and transport options
|
|
359
|
-
* @returns authUrl
|
|
365
|
+
* @returns Server id and state - either "authenticating" with authUrl, or "ready"
|
|
366
|
+
* @throws If connection or discovery fails
|
|
360
367
|
*/
|
|
361
368
|
addMcpServer(
|
|
362
369
|
serverName: string,
|
|
@@ -370,14 +377,35 @@ declare class Agent<
|
|
|
370
377
|
type?: TransportType;
|
|
371
378
|
};
|
|
372
379
|
}
|
|
373
|
-
): Promise<
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
380
|
+
): Promise<
|
|
381
|
+
| {
|
|
382
|
+
id: string;
|
|
383
|
+
state: typeof MCPConnectionState.AUTHENTICATING;
|
|
384
|
+
authUrl: string;
|
|
385
|
+
}
|
|
386
|
+
| {
|
|
387
|
+
id: string;
|
|
388
|
+
state: typeof MCPConnectionState.READY;
|
|
389
|
+
authUrl?: undefined;
|
|
390
|
+
}
|
|
391
|
+
>;
|
|
378
392
|
removeMcpServer(id: string): Promise<void>;
|
|
379
393
|
getMcpServers(): MCPServersState;
|
|
380
394
|
private broadcastMcpServers;
|
|
395
|
+
/**
|
|
396
|
+
* Handle MCP OAuth callback request if it's an OAuth callback.
|
|
397
|
+
*
|
|
398
|
+
* This method encapsulates the entire OAuth callback flow:
|
|
399
|
+
* 1. Checks if the request is an MCP OAuth callback
|
|
400
|
+
* 2. Processes the OAuth code exchange
|
|
401
|
+
* 3. Establishes the connection if successful
|
|
402
|
+
* 4. Broadcasts MCP server state updates
|
|
403
|
+
* 5. Returns the appropriate HTTP response
|
|
404
|
+
*
|
|
405
|
+
* @param request The incoming HTTP request
|
|
406
|
+
* @returns Response if this was an OAuth callback, null otherwise
|
|
407
|
+
*/
|
|
408
|
+
private handleMcpOAuthCallback;
|
|
381
409
|
/**
|
|
382
410
|
* Handle OAuth callback response using MCPClientManager configuration
|
|
383
411
|
* @param result OAuth callback result
|
|
@@ -462,16 +490,6 @@ declare function routeAgentEmail<Env>(
|
|
|
462
490
|
env: Env,
|
|
463
491
|
options: EmailRoutingOptions<Env>
|
|
464
492
|
): Promise<void>;
|
|
465
|
-
type AgentEmail = {
|
|
466
|
-
from: string;
|
|
467
|
-
to: string;
|
|
468
|
-
getRaw: () => Promise<Uint8Array>;
|
|
469
|
-
headers: Headers;
|
|
470
|
-
rawSize: number;
|
|
471
|
-
setReject: (reason: string) => void;
|
|
472
|
-
forward: (rcptTo: string, headers?: Headers) => Promise<void>;
|
|
473
|
-
reply: (options: { from: string; to: string; raw: string }) => Promise<void>;
|
|
474
|
-
};
|
|
475
493
|
type EmailSendOptions = {
|
|
476
494
|
to: string;
|
|
477
495
|
subject: string;
|
|
@@ -494,17 +512,17 @@ type EmailSendOptions = {
|
|
|
494
512
|
*/
|
|
495
513
|
declare function getAgentByName<
|
|
496
514
|
Env,
|
|
497
|
-
T
|
|
515
|
+
T extends Agent<Env>,
|
|
498
516
|
Props extends Record<string, unknown> = Record<string, unknown>
|
|
499
517
|
>(
|
|
500
|
-
namespace: AgentNamespace<T
|
|
518
|
+
namespace: AgentNamespace<T>,
|
|
501
519
|
name: string,
|
|
502
520
|
options?: {
|
|
503
521
|
jurisdiction?: DurableObjectJurisdiction;
|
|
504
522
|
locationHint?: DurableObjectLocationHint;
|
|
505
523
|
props?: Props;
|
|
506
524
|
}
|
|
507
|
-
): Promise<DurableObjectStub<T
|
|
525
|
+
): Promise<DurableObjectStub<T>>;
|
|
508
526
|
/**
|
|
509
527
|
* A wrapper for streaming responses in callable methods
|
|
510
528
|
*/
|
|
@@ -526,35 +544,34 @@ declare class StreamingResponse {
|
|
|
526
544
|
}
|
|
527
545
|
//#endregion
|
|
528
546
|
export {
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
getCurrentAgent as
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
RPCRequest as
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
MCPServersState as m,
|
|
547
|
+
createCatchAllEmailResolver as C,
|
|
548
|
+
routeAgentEmail as D,
|
|
549
|
+
getCurrentAgent as E,
|
|
550
|
+
routeAgentRequest as O,
|
|
551
|
+
createAddressBasedEmailResolver as S,
|
|
552
|
+
getAgentByName as T,
|
|
553
|
+
Schedule as _,
|
|
554
|
+
CallableMetadata as a,
|
|
555
|
+
WSMessage as b,
|
|
556
|
+
EmailResolver as c,
|
|
557
|
+
MCPServer as d,
|
|
558
|
+
MCPServerMessage as f,
|
|
559
|
+
RPCResponse as g,
|
|
560
|
+
RPCRequest as h,
|
|
561
|
+
AgentOptions as i,
|
|
562
|
+
unstable_callable as k,
|
|
563
|
+
EmailRoutingOptions as l,
|
|
564
|
+
QueueItem as m,
|
|
548
565
|
AgentContext as n,
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
566
|
+
Connection$1 as o,
|
|
567
|
+
MCPServersState as p,
|
|
568
|
+
AgentNamespace as r,
|
|
569
|
+
ConnectionContext as s,
|
|
553
570
|
Agent as t,
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
571
|
+
EmailSendOptions as u,
|
|
572
|
+
StateUpdateMessage as v,
|
|
573
|
+
createHeaderBasedEmailResolver as w,
|
|
574
|
+
callable as x,
|
|
575
|
+
StreamingResponse as y
|
|
559
576
|
};
|
|
560
|
-
//# sourceMappingURL=index-
|
|
577
|
+
//# sourceMappingURL=index-DPJ32qQn.d.ts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "./
|
|
3
|
-
import "./
|
|
4
|
-
import "./
|
|
5
|
-
import "./
|
|
1
|
+
import { n as AgentEmail } from "./context-_sPQqJWv.js";
|
|
2
|
+
import { h as TransportType } from "./client-DfIOsabL.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";
|
|
6
7
|
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
m as MCPServersState,
|
|
8
|
+
C as createCatchAllEmailResolver,
|
|
9
|
+
D as routeAgentEmail,
|
|
10
|
+
E as getCurrentAgent,
|
|
11
|
+
O as routeAgentRequest,
|
|
12
|
+
S as createAddressBasedEmailResolver,
|
|
13
|
+
T as getAgentByName,
|
|
14
|
+
_ as Schedule,
|
|
15
|
+
a as CallableMetadata,
|
|
16
|
+
b as WSMessage,
|
|
17
|
+
c as EmailResolver,
|
|
18
|
+
d as MCPServer,
|
|
19
|
+
f as MCPServerMessage,
|
|
20
|
+
g as RPCResponse,
|
|
21
|
+
h as RPCRequest,
|
|
22
|
+
i as AgentOptions,
|
|
23
|
+
k as unstable_callable,
|
|
24
|
+
l as EmailRoutingOptions,
|
|
25
|
+
m as QueueItem,
|
|
26
26
|
n as AgentContext,
|
|
27
|
-
o as
|
|
28
|
-
p as
|
|
29
|
-
r as
|
|
30
|
-
s as
|
|
27
|
+
o as Connection,
|
|
28
|
+
p as MCPServersState,
|
|
29
|
+
r as AgentNamespace,
|
|
30
|
+
s as ConnectionContext,
|
|
31
31
|
t as Agent,
|
|
32
|
-
u as
|
|
33
|
-
v as
|
|
34
|
-
w as
|
|
35
|
-
x as
|
|
36
|
-
y as
|
|
37
|
-
} from "./index-
|
|
32
|
+
u as EmailSendOptions,
|
|
33
|
+
v as StateUpdateMessage,
|
|
34
|
+
w as createHeaderBasedEmailResolver,
|
|
35
|
+
x as callable,
|
|
36
|
+
y as StreamingResponse
|
|
37
|
+
} from "./index-DPJ32qQn.js";
|
|
38
38
|
export {
|
|
39
39
|
Agent,
|
|
40
40
|
AgentContext,
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import "./
|
|
2
|
-
import "./
|
|
3
|
-
import "./client-
|
|
4
|
-
import "./
|
|
5
|
-
import
|
|
1
|
+
import "./context-BkKbAa1R.js";
|
|
2
|
+
import "./ai-types-CwgHzwUb.js";
|
|
3
|
+
import "./client-CcyhkGfN.js";
|
|
4
|
+
import "./client-QZa2Rq0l.js";
|
|
5
|
+
import "./do-oauth-client-provider-B1fVIshX.js";
|
|
6
|
+
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-BmbDclOA.js";
|
|
6
7
|
|
|
7
8
|
export { Agent, StreamingResponse, callable, createAddressBasedEmailResolver, createCatchAllEmailResolver, createHeaderBasedEmailResolver, getAgentByName, getCurrentAgent, routeAgentEmail, routeAgentRequest, unstable_callable };
|
package/dist/mcp/client.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as getNamespacedData, n as
|
|
2
|
-
import "../mcp-
|
|
3
|
-
import "../do-oauth-client-provider-
|
|
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-DfIOsabL.js";
|
|
2
|
+
import "../mcp-CzbSsLfc.js";
|
|
3
|
+
import "../do-oauth-client-provider-B-ryFIPr.js";
|
|
4
|
+
export { MCPClientManager, MCPClientManagerOptions, MCPClientOAuthCallbackConfig, MCPClientOAuthResult, MCPConnectionResult, MCPDiscoverResult, MCPServerOptions, RegisterServerOptions, getNamespacedData };
|
package/dist/mcp/client.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import { n as getNamespacedData, t as MCPClientManager } from "../client-
|
|
1
|
+
import { n as getNamespacedData, t as MCPClientManager } from "../client-QZa2Rq0l.js";
|
|
2
|
+
import "../do-oauth-client-provider-B1fVIshX.js";
|
|
2
3
|
|
|
3
4
|
export { MCPClientManager, getNamespacedData };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as DurableObjectOAuthClientProvider, t as AgentsOAuthProvider } from "../do-oauth-client-provider-
|
|
1
|
+
import { n as DurableObjectOAuthClientProvider, t as AgentsOAuthProvider } from "../do-oauth-client-provider-B-ryFIPr.js";
|
|
2
2
|
export { AgentsOAuthProvider, DurableObjectOAuthClientProvider };
|
package/dist/mcp/index.d.ts
CHANGED
|
@@ -1,22 +1,60 @@
|
|
|
1
|
-
import
|
|
2
|
-
import "../
|
|
3
|
-
import "../
|
|
4
|
-
import "../
|
|
5
|
-
import "../
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
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-DfIOsabL.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-DPJ32qQn.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";
|
|
8
11
|
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
9
12
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
10
|
-
import { Transport } from "@modelcontextprotocol/sdk/shared/transport.js";
|
|
13
|
+
import { Transport, TransportSendOptions } from "@modelcontextprotocol/sdk/shared/transport.js";
|
|
11
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
|
|
12
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
|
+
}
|
|
13
41
|
interface WorkerTransportOptions {
|
|
14
42
|
sessionIdGenerator?: () => string;
|
|
43
|
+
/**
|
|
44
|
+
* Enable traditional Request/Response mode, this will disable streaming.
|
|
45
|
+
*/
|
|
15
46
|
enableJsonResponse?: boolean;
|
|
16
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;
|
|
17
55
|
}
|
|
18
56
|
declare class WorkerTransport implements Transport {
|
|
19
|
-
|
|
57
|
+
started: boolean;
|
|
20
58
|
private initialized;
|
|
21
59
|
private sessionIdGenerator?;
|
|
22
60
|
private enableJsonResponse;
|
|
@@ -25,12 +63,27 @@ declare class WorkerTransport implements Transport {
|
|
|
25
63
|
private streamMapping;
|
|
26
64
|
private requestToStreamMapping;
|
|
27
65
|
private requestResponseMap;
|
|
66
|
+
private corsOptions?;
|
|
67
|
+
private protocolVersion?;
|
|
68
|
+
private storage?;
|
|
69
|
+
private stateRestored;
|
|
28
70
|
sessionId?: string;
|
|
29
71
|
onclose?: () => void;
|
|
30
72
|
onerror?: (error: Error) => void;
|
|
31
|
-
onmessage?: (message: JSONRPCMessage) => void;
|
|
73
|
+
onmessage?: (message: JSONRPCMessage, extra?: MessageExtraInfo) => void;
|
|
32
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;
|
|
33
84
|
start(): Promise<void>;
|
|
85
|
+
private validateProtocolVersion;
|
|
86
|
+
private getHeaders;
|
|
34
87
|
handleRequest(request: Request, parsedBody?: unknown): Promise<Response>;
|
|
35
88
|
private handleGetRequest;
|
|
36
89
|
private handlePostRequest;
|
|
@@ -39,8 +92,14 @@ declare class WorkerTransport implements Transport {
|
|
|
39
92
|
private handleUnsupportedRequest;
|
|
40
93
|
private validateSession;
|
|
41
94
|
close(): Promise<void>;
|
|
42
|
-
send(message: JSONRPCMessage): 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>;
|
|
43
101
|
}
|
|
102
|
+
declare function getMcpAuthContext(): McpAuthContext | undefined;
|
|
44
103
|
//#endregion
|
|
45
104
|
//#region src/mcp/handler.d.ts
|
|
46
105
|
interface CreateMcpHandlerOptions extends WorkerTransportOptions {
|
|
@@ -50,18 +109,23 @@ interface CreateMcpHandlerOptions extends WorkerTransportOptions {
|
|
|
50
109
|
* @default "/mcp"
|
|
51
110
|
*/
|
|
52
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;
|
|
53
122
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
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
|
+
*/
|
|
57
127
|
declare function experimental_createMcpHandler(server: McpServer | Server, options?: CreateMcpHandlerOptions): (request: Request, env: unknown, ctx: ExecutionContext) => Promise<Response>;
|
|
58
128
|
//#endregion
|
|
59
|
-
//#region src/mcp/auth-context.d.ts
|
|
60
|
-
interface McpAuthContext {
|
|
61
|
-
props: Record<string, unknown>;
|
|
62
|
-
}
|
|
63
|
-
declare function getMcpAuthContext(): McpAuthContext | undefined;
|
|
64
|
-
//#endregion
|
|
65
129
|
//#region src/mcp/index.d.ts
|
|
66
130
|
declare abstract class McpAgent<Env = unknown, State = unknown, Props extends Record<string, unknown> = Record<string, unknown>> extends Agent<Env, State, Props> {
|
|
67
131
|
private _transport?;
|
|
@@ -81,7 +145,7 @@ declare abstract class McpAgent<Env = unknown, State = unknown, Props extends Re
|
|
|
81
145
|
*/
|
|
82
146
|
getSessionId(): string;
|
|
83
147
|
/** Get the unique WebSocket. SSE transport only. */
|
|
84
|
-
|
|
148
|
+
getWebSocket(): Connection<unknown> | null;
|
|
85
149
|
/** Returns a new transport matching the type of the Agent. */
|
|
86
150
|
private initTransport;
|
|
87
151
|
/** Update and store the props */
|
|
@@ -94,7 +158,7 @@ declare abstract class McpAgent<Env = unknown, State = unknown, Props extends Re
|
|
|
94
158
|
request: req
|
|
95
159
|
}: ConnectionContext): Promise<void>;
|
|
96
160
|
/** Handles MCP Messages for the legacy SSE transport. */
|
|
97
|
-
onSSEMcpMessage(_sessionId: string, messageBody: unknown): Promise<Error | null>;
|
|
161
|
+
onSSEMcpMessage(_sessionId: string, messageBody: unknown, extraInfo?: MessageExtraInfo): Promise<Error | null>;
|
|
98
162
|
/** Elicit user input with a message and schema */
|
|
99
163
|
elicitInput(params: {
|
|
100
164
|
message: string;
|
|
@@ -110,7 +174,8 @@ declare abstract class McpAgent<Env = unknown, State = unknown, Props extends Re
|
|
|
110
174
|
static serve(path: string, {
|
|
111
175
|
binding,
|
|
112
176
|
corsOptions,
|
|
113
|
-
transport
|
|
177
|
+
transport,
|
|
178
|
+
jurisdiction
|
|
114
179
|
}?: ServeOptions): {
|
|
115
180
|
fetch<Env>(this: void, request: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
|
|
116
181
|
};
|
|
@@ -125,5 +190,5 @@ declare abstract class McpAgent<Env = unknown, State = unknown, Props extends Re
|
|
|
125
190
|
};
|
|
126
191
|
}
|
|
127
192
|
//#endregion
|
|
128
|
-
export { type CreateMcpHandlerOptions, type ElicitRequest, ElicitRequestSchema, type ElicitResult, type MCPClientOAuthCallbackConfig, type MCPClientOAuthResult,
|
|
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 };
|
|
129
194
|
//# sourceMappingURL=index.d.ts.map
|