agents 0.0.0-dd6a9e3 → 0.0.0-de1d9aa
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 +255 -27
- package/dist/ai-chat-agent.d.ts +59 -10
- package/dist/ai-chat-agent.js +532 -159
- package/dist/ai-chat-agent.js.map +1 -1
- package/dist/ai-chat-v5-migration-DBHGW4Hv.js +155 -0
- package/dist/ai-chat-v5-migration-DBHGW4Hv.js.map +1 -0
- package/dist/ai-chat-v5-migration.d.ts +155 -0
- package/dist/ai-chat-v5-migration.js +3 -0
- package/dist/ai-react.d.ts +73 -72
- package/dist/ai-react.js +261 -185
- package/dist/ai-react.js.map +1 -1
- package/dist/ai-types-B3aQaFv3.js +20 -0
- package/dist/ai-types-B3aQaFv3.js.map +1 -0
- package/dist/ai-types-D5YoPrBZ.d.ts +95 -0
- package/dist/ai-types.d.ts +6 -69
- package/dist/ai-types.js +3 -1
- package/dist/client-BfiZ3HQd.js +117 -0
- package/dist/client-BfiZ3HQd.js.map +1 -0
- package/dist/client-C1R7IU9g.d.ts +5313 -0
- package/dist/client-CIvp_OWw.js +786 -0
- package/dist/client-CIvp_OWw.js.map +1 -0
- package/dist/client-CbWe9FBd.d.ts +104 -0
- package/dist/client.d.ts +12 -79
- package/dist/client.js +3 -137
- package/dist/codemode/ai.d.ts +27 -0
- package/dist/codemode/ai.js +151 -0
- package/dist/codemode/ai.js.map +1 -0
- package/dist/do-oauth-client-provider-CswoD5Lu.js +93 -0
- package/dist/do-oauth-client-provider-CswoD5Lu.js.map +1 -0
- package/dist/do-oauth-client-provider-DGc5pP0l.d.ts +55 -0
- package/dist/index-CaUf7Wsc.d.ts +568 -0
- package/dist/index-DhJCaDWd.d.ts +58 -0
- package/dist/index.d.ts +63 -295
- package/dist/index.js +7 -20
- package/dist/mcp/client.d.ts +4 -0
- package/dist/mcp/client.js +3 -0
- package/dist/mcp/do-oauth-client-provider.d.ts +2 -0
- package/dist/mcp/do-oauth-client-provider.js +3 -0
- package/dist/mcp/index.d.ts +129 -0
- package/dist/mcp/index.js +1235 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/x402.d.ts +34 -0
- package/dist/mcp/x402.js +194 -0
- package/dist/mcp/x402.js.map +1 -0
- package/dist/mcp-Dw5vDrY8.d.ts +61 -0
- package/dist/observability/index.d.ts +3 -0
- package/dist/observability/index.js +7 -0
- package/dist/react-BWIluznB.d.ts +115 -0
- package/dist/react.d.ts +10 -39
- package/dist/react.js +185 -93
- package/dist/react.js.map +1 -1
- package/dist/schedule.d.ts +89 -12
- package/dist/schedule.js +46 -23
- package/dist/schedule.js.map +1 -1
- package/dist/serializable-CymX8ovI.d.ts +39 -0
- package/dist/serializable.d.ts +7 -0
- package/dist/serializable.js +1 -0
- package/dist/src-CTtjSFyX.js +1231 -0
- package/dist/src-CTtjSFyX.js.map +1 -0
- package/package.json +117 -50
- package/dist/ai-types.js.map +0 -1
- package/dist/chunk-HMLY7DHA.js +0 -16
- package/dist/chunk-HMLY7DHA.js.map +0 -1
- package/dist/chunk-X6BBKLSC.js +0 -568
- package/dist/chunk-X6BBKLSC.js.map +0 -1
- package/dist/client.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/mcp.d.ts +0 -58
- package/dist/mcp.js +0 -945
- package/dist/mcp.js.map +0 -1
- package/src/index.ts +0 -888
package/dist/index.d.ts
CHANGED
|
@@ -1,302 +1,70 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
| {
|
|
39
|
-
success: false;
|
|
40
|
-
error: string;
|
|
41
|
-
}
|
|
42
|
-
);
|
|
43
|
-
/**
|
|
44
|
-
* Metadata for a callable method
|
|
45
|
-
*/
|
|
46
|
-
type CallableMetadata = {
|
|
47
|
-
/** Optional description of what the method does */
|
|
48
|
-
description?: string;
|
|
49
|
-
/** Whether the method supports streaming responses */
|
|
50
|
-
streaming?: boolean;
|
|
51
|
-
};
|
|
52
|
-
/**
|
|
53
|
-
* Decorator that marks a method as callable by clients
|
|
54
|
-
* @param metadata Optional metadata about the callable method
|
|
55
|
-
*/
|
|
56
|
-
declare function unstable_callable(
|
|
57
|
-
metadata?: CallableMetadata
|
|
58
|
-
): <This, Args extends unknown[], Return>(
|
|
59
|
-
target: (this: This, ...args: Args) => Return,
|
|
60
|
-
context: ClassMethodDecoratorContext
|
|
61
|
-
) => (this: This, ...args: Args) => Return;
|
|
62
|
-
/**
|
|
63
|
-
* A class for creating workflow entry points that can be used with Cloudflare Workers
|
|
64
|
-
*/
|
|
65
|
-
declare class WorkflowEntrypoint extends WorkflowEntrypoint$1 {}
|
|
66
|
-
/**
|
|
67
|
-
* Represents a scheduled task within an Agent
|
|
68
|
-
* @template T Type of the payload data
|
|
69
|
-
*/
|
|
70
|
-
type Schedule<T = string> = {
|
|
71
|
-
/** Unique identifier for the schedule */
|
|
72
|
-
id: string;
|
|
73
|
-
/** Name of the method to be called */
|
|
74
|
-
callback: string;
|
|
75
|
-
/** Data to be passed to the callback */
|
|
76
|
-
payload: T;
|
|
77
|
-
} & (
|
|
78
|
-
| {
|
|
79
|
-
/** Type of schedule for one-time execution at a specific time */
|
|
80
|
-
type: "scheduled";
|
|
81
|
-
/** Timestamp when the task should execute */
|
|
82
|
-
time: number;
|
|
83
|
-
}
|
|
84
|
-
| {
|
|
85
|
-
/** Type of schedule for delayed execution */
|
|
86
|
-
type: "delayed";
|
|
87
|
-
/** Timestamp when the task should execute */
|
|
88
|
-
time: number;
|
|
89
|
-
/** Number of seconds to delay execution */
|
|
90
|
-
delayInSeconds: number;
|
|
91
|
-
}
|
|
92
|
-
| {
|
|
93
|
-
/** Type of schedule for recurring execution based on cron expression */
|
|
94
|
-
type: "cron";
|
|
95
|
-
/** Timestamp for the next execution */
|
|
96
|
-
time: number;
|
|
97
|
-
/** Cron expression defining the schedule */
|
|
98
|
-
cron: string;
|
|
99
|
-
}
|
|
100
|
-
);
|
|
101
|
-
/**
|
|
102
|
-
* Base class for creating Agent implementations
|
|
103
|
-
* @template Env Environment type containing bindings
|
|
104
|
-
* @template State State type to store within the Agent
|
|
105
|
-
*/
|
|
106
|
-
declare class Agent<Env, State = unknown> extends Server<Env> {
|
|
107
|
-
#private;
|
|
108
|
-
/**
|
|
109
|
-
* Initial state for the Agent
|
|
110
|
-
* Override to provide default state values
|
|
111
|
-
*/
|
|
112
|
-
initialState: State;
|
|
113
|
-
/**
|
|
114
|
-
* Current state of the Agent
|
|
115
|
-
*/
|
|
116
|
-
get state(): State;
|
|
117
|
-
/**
|
|
118
|
-
* Agent configuration options
|
|
119
|
-
*/
|
|
120
|
-
static options: {
|
|
121
|
-
/** Whether the Agent should hibernate when inactive */
|
|
122
|
-
hibernate: boolean;
|
|
123
|
-
};
|
|
124
|
-
/**
|
|
125
|
-
* Execute SQL queries against the Agent's database
|
|
126
|
-
* @template T Type of the returned rows
|
|
127
|
-
* @param strings SQL query template strings
|
|
128
|
-
* @param values Values to be inserted into the query
|
|
129
|
-
* @returns Array of query results
|
|
130
|
-
*/
|
|
131
|
-
sql<T = Record<string, string | number | boolean | null>>(
|
|
132
|
-
strings: TemplateStringsArray,
|
|
133
|
-
...values: (string | number | boolean | null)[]
|
|
134
|
-
): T[];
|
|
135
|
-
constructor(ctx: AgentContext, env: Env);
|
|
136
|
-
/**
|
|
137
|
-
* Update the Agent's state
|
|
138
|
-
* @param state New state to set
|
|
139
|
-
*/
|
|
140
|
-
setState(state: State): void;
|
|
141
|
-
/**
|
|
142
|
-
* Called when the Agent's state is updated
|
|
143
|
-
* @param state Updated state
|
|
144
|
-
* @param source Source of the state update ("server" or a client connection)
|
|
145
|
-
*/
|
|
146
|
-
onStateUpdate(state: State | undefined, source: Connection | "server"): void;
|
|
147
|
-
/**
|
|
148
|
-
* Called when the Agent receives an email
|
|
149
|
-
* @param email Email message to process
|
|
150
|
-
*/
|
|
151
|
-
onEmail(email: ForwardableEmailMessage): void;
|
|
152
|
-
onError(connection: Connection, error: unknown): void | Promise<void>;
|
|
153
|
-
onError(error: unknown): void | Promise<void>;
|
|
154
|
-
/**
|
|
155
|
-
* Render content (not implemented in base class)
|
|
156
|
-
*/
|
|
157
|
-
render(): void;
|
|
158
|
-
/**
|
|
159
|
-
* Schedule a task to be executed in the future
|
|
160
|
-
* @template T Type of the payload data
|
|
161
|
-
* @param when When to execute the task (Date, seconds delay, or cron expression)
|
|
162
|
-
* @param callback Name of the method to call
|
|
163
|
-
* @param payload Data to pass to the callback
|
|
164
|
-
* @returns Schedule object representing the scheduled task
|
|
165
|
-
*/
|
|
166
|
-
schedule<T = string>(
|
|
167
|
-
when: Date | string | number,
|
|
168
|
-
callback: keyof this,
|
|
169
|
-
payload?: T
|
|
170
|
-
): Promise<Schedule<T>>;
|
|
171
|
-
/**
|
|
172
|
-
* Get a scheduled task by ID
|
|
173
|
-
* @template T Type of the payload data
|
|
174
|
-
* @param id ID of the scheduled task
|
|
175
|
-
* @returns The Schedule object or undefined if not found
|
|
176
|
-
*/
|
|
177
|
-
getSchedule<T = string>(id: string): Promise<Schedule<T> | undefined>;
|
|
178
|
-
/**
|
|
179
|
-
* Get scheduled tasks matching the given criteria
|
|
180
|
-
* @template T Type of the payload data
|
|
181
|
-
* @param criteria Criteria to filter schedules
|
|
182
|
-
* @returns Array of matching Schedule objects
|
|
183
|
-
*/
|
|
184
|
-
getSchedules<T = string>(criteria?: {
|
|
185
|
-
description?: string;
|
|
186
|
-
id?: string;
|
|
187
|
-
type?: "scheduled" | "delayed" | "cron";
|
|
188
|
-
timeRange?: {
|
|
189
|
-
start?: Date;
|
|
190
|
-
end?: Date;
|
|
191
|
-
};
|
|
192
|
-
}): Schedule<T>[];
|
|
193
|
-
/**
|
|
194
|
-
* Cancel a scheduled task
|
|
195
|
-
* @param id ID of the task to cancel
|
|
196
|
-
* @returns true if the task was cancelled, false otherwise
|
|
197
|
-
*/
|
|
198
|
-
cancelSchedule(id: string): Promise<boolean>;
|
|
199
|
-
/**
|
|
200
|
-
* Method called when an alarm fires
|
|
201
|
-
* Executes any scheduled tasks that are due
|
|
202
|
-
*/
|
|
203
|
-
alarm(): Promise<void>;
|
|
204
|
-
/**
|
|
205
|
-
* Destroy the Agent, removing all state and scheduled tasks
|
|
206
|
-
*/
|
|
207
|
-
destroy(): Promise<void>;
|
|
208
|
-
}
|
|
209
|
-
/**
|
|
210
|
-
* Namespace for creating Agent instances
|
|
211
|
-
* @template Agentic Type of the Agent class
|
|
212
|
-
*/
|
|
213
|
-
type AgentNamespace<Agentic extends Agent<unknown>> =
|
|
214
|
-
DurableObjectNamespace<Agentic>;
|
|
215
|
-
/**
|
|
216
|
-
* Agent's durable context
|
|
217
|
-
*/
|
|
218
|
-
type AgentContext = DurableObjectState;
|
|
219
|
-
/**
|
|
220
|
-
* Configuration options for Agent routing
|
|
221
|
-
*/
|
|
222
|
-
type AgentOptions<Env> = PartyServerOptions<Env> & {
|
|
223
|
-
/**
|
|
224
|
-
* Whether to enable CORS for the Agent
|
|
225
|
-
*/
|
|
226
|
-
cors?: boolean | HeadersInit | undefined;
|
|
227
|
-
};
|
|
228
|
-
/**
|
|
229
|
-
* Route a request to the appropriate Agent
|
|
230
|
-
* @param request Request to route
|
|
231
|
-
* @param env Environment containing Agent bindings
|
|
232
|
-
* @param options Routing options
|
|
233
|
-
* @returns Response from the Agent or undefined if no route matched
|
|
234
|
-
*/
|
|
235
|
-
declare function routeAgentRequest<Env>(
|
|
236
|
-
request: Request,
|
|
237
|
-
env: Env,
|
|
238
|
-
options?: AgentOptions<Env>
|
|
239
|
-
): Promise<Response | null>;
|
|
240
|
-
/**
|
|
241
|
-
* Route an email to the appropriate Agent
|
|
242
|
-
* @param email Email message to route
|
|
243
|
-
* @param env Environment containing Agent bindings
|
|
244
|
-
* @param options Routing options
|
|
245
|
-
*/
|
|
246
|
-
declare function routeAgentEmail<Env>(
|
|
247
|
-
email: ForwardableEmailMessage,
|
|
248
|
-
env: Env,
|
|
249
|
-
options?: AgentOptions<Env>
|
|
250
|
-
): Promise<void>;
|
|
251
|
-
/**
|
|
252
|
-
* Get or create an Agent by name
|
|
253
|
-
* @template Env Environment type containing bindings
|
|
254
|
-
* @template T Type of the Agent class
|
|
255
|
-
* @param namespace Agent namespace
|
|
256
|
-
* @param name Name of the Agent instance
|
|
257
|
-
* @param options Options for Agent creation
|
|
258
|
-
* @returns Promise resolving to an Agent instance stub
|
|
259
|
-
*/
|
|
260
|
-
declare function getAgentByName<Env, T extends Agent<Env>>(
|
|
261
|
-
namespace: AgentNamespace<T>,
|
|
262
|
-
name: string,
|
|
263
|
-
options?: {
|
|
264
|
-
jurisdiction?: DurableObjectJurisdiction;
|
|
265
|
-
locationHint?: DurableObjectLocationHint;
|
|
266
|
-
}
|
|
267
|
-
): Promise<DurableObjectStub<T>>;
|
|
268
|
-
/**
|
|
269
|
-
* A wrapper for streaming responses in callable methods
|
|
270
|
-
*/
|
|
271
|
-
declare class StreamingResponse {
|
|
272
|
-
#private;
|
|
273
|
-
constructor(connection: Connection, id: string);
|
|
274
|
-
/**
|
|
275
|
-
* Send a chunk of data to the client
|
|
276
|
-
* @param chunk The data to send
|
|
277
|
-
*/
|
|
278
|
-
send(chunk: unknown): void;
|
|
279
|
-
/**
|
|
280
|
-
* End the stream and send the final chunk (if any)
|
|
281
|
-
* @param finalChunk Optional final chunk of data to send
|
|
282
|
-
*/
|
|
283
|
-
end(finalChunk?: unknown): void;
|
|
284
|
-
}
|
|
285
|
-
|
|
1
|
+
import { l as TransportType } from "./client-C1R7IU9g.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-CaUf7Wsc.js";
|
|
286
38
|
export {
|
|
287
39
|
Agent,
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
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,
|
|
296
58
|
StreamingResponse,
|
|
297
|
-
|
|
59
|
+
TransportType,
|
|
60
|
+
WSMessage,
|
|
61
|
+
callable,
|
|
62
|
+
createAddressBasedEmailResolver,
|
|
63
|
+
createCatchAllEmailResolver,
|
|
64
|
+
createHeaderBasedEmailResolver,
|
|
298
65
|
getAgentByName,
|
|
66
|
+
getCurrentAgent,
|
|
299
67
|
routeAgentEmail,
|
|
300
68
|
routeAgentRequest,
|
|
301
|
-
unstable_callable
|
|
69
|
+
unstable_callable
|
|
302
70
|
};
|
package/dist/index.js
CHANGED
|
@@ -1,20 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
unstable_callable
|
|
9
|
-
} from "./chunk-X6BBKLSC.js";
|
|
10
|
-
import "./chunk-HMLY7DHA.js";
|
|
11
|
-
export {
|
|
12
|
-
Agent,
|
|
13
|
-
StreamingResponse,
|
|
14
|
-
WorkflowEntrypoint,
|
|
15
|
-
getAgentByName,
|
|
16
|
-
routeAgentEmail,
|
|
17
|
-
routeAgentRequest,
|
|
18
|
-
unstable_callable
|
|
19
|
-
};
|
|
20
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
import "./ai-types-B3aQaFv3.js";
|
|
2
|
+
import "./client-BfiZ3HQd.js";
|
|
3
|
+
import "./client-CIvp_OWw.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-CTtjSFyX.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-C1R7IU9g.js";
|
|
2
|
+
import "../mcp-Dw5vDrY8.js";
|
|
3
|
+
import "../do-oauth-client-provider-DGc5pP0l.js";
|
|
4
|
+
export { MCPClientManager, MCPClientOAuthCallbackConfig, MCPClientOAuthResult, getNamespacedData };
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { c as ServeOptions, d as SSEEdgeClientTransport, n as MCPClientOAuthCallbackConfig, o as BaseTransportType, r as MCPClientOAuthResult, s as MaybePromise, u as StreamableHTTPEdgeClientTransport } from "../client-C1R7IU9g.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-CaUf7Wsc.js";
|
|
7
|
+
import { ElicitRequest, ElicitRequestSchema, ElicitResult, ElicitResult as ElicitResult$1, JSONRPCMessage } from "@modelcontextprotocol/sdk/types.js";
|
|
8
|
+
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
9
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
10
|
+
import { Transport } from "@modelcontextprotocol/sdk/shared/transport.js";
|
|
11
|
+
|
|
12
|
+
//#region src/mcp/worker-transport.d.ts
|
|
13
|
+
interface WorkerTransportOptions {
|
|
14
|
+
sessionIdGenerator?: () => string;
|
|
15
|
+
enableJsonResponse?: boolean;
|
|
16
|
+
onsessioninitialized?: (sessionId: string) => void;
|
|
17
|
+
}
|
|
18
|
+
declare class WorkerTransport implements Transport {
|
|
19
|
+
private started;
|
|
20
|
+
private initialized;
|
|
21
|
+
private sessionIdGenerator?;
|
|
22
|
+
private enableJsonResponse;
|
|
23
|
+
private onsessioninitialized?;
|
|
24
|
+
private standaloneSseStreamId;
|
|
25
|
+
private streamMapping;
|
|
26
|
+
private requestToStreamMapping;
|
|
27
|
+
private requestResponseMap;
|
|
28
|
+
sessionId?: string;
|
|
29
|
+
onclose?: () => void;
|
|
30
|
+
onerror?: (error: Error) => void;
|
|
31
|
+
onmessage?: (message: JSONRPCMessage) => void;
|
|
32
|
+
constructor(options?: WorkerTransportOptions);
|
|
33
|
+
start(): Promise<void>;
|
|
34
|
+
handleRequest(request: Request, parsedBody?: unknown): Promise<Response>;
|
|
35
|
+
private handleGetRequest;
|
|
36
|
+
private handlePostRequest;
|
|
37
|
+
private handleDeleteRequest;
|
|
38
|
+
private handleOptionsRequest;
|
|
39
|
+
private handleUnsupportedRequest;
|
|
40
|
+
private validateSession;
|
|
41
|
+
close(): Promise<void>;
|
|
42
|
+
send(message: JSONRPCMessage): Promise<void>;
|
|
43
|
+
}
|
|
44
|
+
//#endregion
|
|
45
|
+
//#region src/mcp/handler.d.ts
|
|
46
|
+
interface CreateMcpHandlerOptions extends WorkerTransportOptions {
|
|
47
|
+
/**
|
|
48
|
+
* The route path that this MCP handler should respond to.
|
|
49
|
+
* If specified, the handler will only process requests that match this route.
|
|
50
|
+
* @default "/mcp"
|
|
51
|
+
*/
|
|
52
|
+
route?: string;
|
|
53
|
+
}
|
|
54
|
+
type OAuthExecutionContext = ExecutionContext & {
|
|
55
|
+
props?: Record<string, unknown>;
|
|
56
|
+
};
|
|
57
|
+
declare function experimental_createMcpHandler(server: McpServer | Server, options?: CreateMcpHandlerOptions): (request: Request, env: unknown, ctx: ExecutionContext) => Promise<Response>;
|
|
58
|
+
//#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
|
+
//#region src/mcp/index.d.ts
|
|
66
|
+
declare abstract class McpAgent<Env = unknown, State = unknown, Props extends Record<string, unknown> = Record<string, unknown>> extends Agent<Env, State, Props> {
|
|
67
|
+
private _transport?;
|
|
68
|
+
props?: Props;
|
|
69
|
+
abstract server: MaybePromise<McpServer | Server>;
|
|
70
|
+
abstract init(): Promise<void>;
|
|
71
|
+
setInitializeRequest(initializeRequest: JSONRPCMessage): Promise<void>;
|
|
72
|
+
getInitializeRequest(): Promise<JSONRPCMessage | undefined>;
|
|
73
|
+
/** Read the transport type for this agent.
|
|
74
|
+
* This relies on the naming scheme being `sse:${sessionId}`
|
|
75
|
+
* or `streamable-http:${sessionId}`.
|
|
76
|
+
*/
|
|
77
|
+
getTransportType(): BaseTransportType;
|
|
78
|
+
/** Read the sessionId for this agent.
|
|
79
|
+
* This relies on the naming scheme being `sse:${sessionId}`
|
|
80
|
+
* or `streamable-http:${sessionId}`.
|
|
81
|
+
*/
|
|
82
|
+
getSessionId(): string;
|
|
83
|
+
/** Get the unique WebSocket. SSE transport only. */
|
|
84
|
+
private getWebSocket;
|
|
85
|
+
/** Returns a new transport matching the type of the Agent. */
|
|
86
|
+
private initTransport;
|
|
87
|
+
/** Update and store the props */
|
|
88
|
+
updateProps(props?: Props): Promise<void>;
|
|
89
|
+
reinitializeServer(): Promise<void>;
|
|
90
|
+
/** Sets up the MCP transport and server every time the Agent is started.*/
|
|
91
|
+
onStart(props?: Props): Promise<void>;
|
|
92
|
+
/** Validates new WebSocket connections. */
|
|
93
|
+
onConnect(conn: Connection, {
|
|
94
|
+
request: req
|
|
95
|
+
}: ConnectionContext): Promise<void>;
|
|
96
|
+
/** Handles MCP Messages for the legacy SSE transport. */
|
|
97
|
+
onSSEMcpMessage(_sessionId: string, messageBody: unknown): Promise<Error | null>;
|
|
98
|
+
/** Elicit user input with a message and schema */
|
|
99
|
+
elicitInput(params: {
|
|
100
|
+
message: string;
|
|
101
|
+
requestedSchema: unknown;
|
|
102
|
+
}): Promise<ElicitResult$1>;
|
|
103
|
+
/** Wait for elicitation response through storage polling */
|
|
104
|
+
private _waitForElicitationResponse;
|
|
105
|
+
/** Handle elicitation responses */
|
|
106
|
+
private _handleElicitationResponse;
|
|
107
|
+
/** Return a handler for the given path for this MCP.
|
|
108
|
+
* Defaults to Streamable HTTP transport.
|
|
109
|
+
*/
|
|
110
|
+
static serve(path: string, {
|
|
111
|
+
binding,
|
|
112
|
+
corsOptions,
|
|
113
|
+
transport
|
|
114
|
+
}?: ServeOptions): {
|
|
115
|
+
fetch<Env>(this: void, request: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
|
|
116
|
+
};
|
|
117
|
+
/**
|
|
118
|
+
* Legacy api
|
|
119
|
+
**/
|
|
120
|
+
static mount(path: string, opts?: Omit<ServeOptions, "transport">): {
|
|
121
|
+
fetch<Env>(this: void, request: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
|
|
122
|
+
};
|
|
123
|
+
static serveSSE(path: string, opts?: Omit<ServeOptions, "transport">): {
|
|
124
|
+
fetch<Env>(this: void, request: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
//#endregion
|
|
128
|
+
export { type CreateMcpHandlerOptions, type ElicitRequest, ElicitRequestSchema, type ElicitResult, type MCPClientOAuthCallbackConfig, type MCPClientOAuthResult, McpAgent, type McpAuthContext, type OAuthExecutionContext, SSEEdgeClientTransport, StreamableHTTPEdgeClientTransport, WorkerTransport, type WorkerTransportOptions, experimental_createMcpHandler, getMcpAuthContext };
|
|
129
|
+
//# sourceMappingURL=index.d.ts.map
|