agents 0.0.0-8c2713f → 0.0.0-8c9aadd
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 +129 -7
- package/dist/ai-chat-agent.d.ts +20 -20
- package/dist/ai-chat-agent.js +532 -260
- package/dist/ai-chat-agent.js.map +1 -1
- package/dist/ai-chat-v5-migration-gdyLiTd8.js +155 -0
- package/dist/ai-chat-v5-migration-gdyLiTd8.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 -87
- package/dist/ai-react.js +261 -199
- package/dist/ai-react.js.map +1 -1
- package/dist/ai-types-BWW4umHY.d.ts +95 -0
- package/dist/ai-types-UZlfLOYP.js +20 -0
- package/dist/ai-types-UZlfLOYP.js.map +1 -0
- package/dist/ai-types.d.ts +6 -74
- package/dist/ai-types.js +3 -1
- package/dist/client-C-nwz-3N.d.ts +5313 -0
- package/dist/client-CZBVDDoO.js +786 -0
- package/dist/client-CZBVDDoO.js.map +1 -0
- package/dist/client-CmMi85Sj.d.ts +104 -0
- package/dist/client-DjR-lC16.js +117 -0
- package/dist/client-DjR-lC16.js.map +1 -0
- package/dist/client.d.ts +11 -92
- package/dist/client.js +4 -11
- 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-B2jr6UNq.js +93 -0
- package/dist/do-oauth-client-provider-B2jr6UNq.js.map +1 -0
- package/dist/do-oauth-client-provider-CCwGwnrA.d.ts +55 -0
- package/dist/{index-BCJclX6q.d.ts → index-DWJSBMbz.d.ts} +265 -144
- package/dist/index-W4JUkafc.d.ts +54 -0
- package/dist/index.d.ts +83 -40
- package/dist/index.js +7 -28
- package/dist/mcp/client.d.ts +4 -11
- package/dist/mcp/client.js +3 -9
- package/dist/mcp/do-oauth-client-provider.d.ts +2 -41
- package/dist/mcp/do-oauth-client-provider.js +3 -7
- package/dist/mcp/index.d.ts +7 -112
- package/dist/mcp/index.js +6 -954
- 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-BEwaCsxO.d.ts +61 -0
- package/dist/observability/index.d.ts +3 -14
- package/dist/observability/index.js +7 -10
- package/dist/react-GnTP-a01.d.ts +113 -0
- package/dist/react.d.ts +10 -121
- package/dist/react.js +183 -110
- package/dist/react.js.map +1 -1
- package/dist/schedule.d.ts +87 -10
- package/dist/schedule.js +46 -21
- package/dist/schedule.js.map +1 -1
- package/dist/serializable-gtr9YMhp.d.ts +34 -0
- package/dist/serializable.d.ts +7 -32
- package/dist/serializable.js +1 -1
- package/dist/src-tpG9NtHy.js +2457 -0
- package/dist/src-tpG9NtHy.js.map +1 -0
- package/package.json +45 -11
- package/dist/ai-types.js.map +0 -1
- package/dist/chunk-HY7ZLHJB.js +0 -598
- package/dist/chunk-HY7ZLHJB.js.map +0 -1
- package/dist/chunk-JXN5WZFQ.js +0 -1287
- package/dist/chunk-JXN5WZFQ.js.map +0 -1
- package/dist/chunk-KUH345EY.js +0 -116
- package/dist/chunk-KUH345EY.js.map +0 -1
- package/dist/chunk-PVQZBKN7.js +0 -106
- package/dist/chunk-PVQZBKN7.js.map +0 -1
- package/dist/client-DgyzBU_8.d.ts +0 -4601
- package/dist/client.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/mcp/client.js.map +0 -1
- package/dist/mcp/do-oauth-client-provider.js.map +0 -1
- package/dist/mcp/index.js.map +0 -1
- package/dist/observability/index.js.map +0 -1
- package/dist/serializable.js.map +0 -1
- package/src/index.ts +0 -1917
|
@@ -1,89 +1,186 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
BaseTransportType,
|
|
3
|
+
MCPClientManager,
|
|
4
|
+
MCPConnectionState,
|
|
5
|
+
MaybePromise,
|
|
6
|
+
ServeOptions,
|
|
7
|
+
TransportType
|
|
8
|
+
} from "./client-C-nwz-3N.js";
|
|
9
|
+
import { Observability } from "./index-W4JUkafc.js";
|
|
10
|
+
import { MessageType } from "./ai-types-BWW4umHY.js";
|
|
11
|
+
import {
|
|
12
|
+
Connection,
|
|
13
|
+
Connection as Connection$1,
|
|
14
|
+
ConnectionContext,
|
|
15
|
+
PartyServerOptions,
|
|
16
|
+
Server,
|
|
17
|
+
WSMessage
|
|
18
|
+
} from "partyserver";
|
|
2
19
|
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
3
20
|
import {
|
|
4
|
-
|
|
5
|
-
|
|
21
|
+
ElicitRequest as ElicitRequest$1,
|
|
22
|
+
ElicitRequestSchema as ElicitRequestSchema$1,
|
|
23
|
+
ElicitResult,
|
|
24
|
+
ElicitResult as ElicitResult$1,
|
|
25
|
+
JSONRPCMessage,
|
|
6
26
|
Prompt,
|
|
7
|
-
Resource
|
|
27
|
+
Resource,
|
|
28
|
+
ServerCapabilities,
|
|
29
|
+
Tool
|
|
8
30
|
} from "@modelcontextprotocol/sdk/types.js";
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
31
|
+
import { env } from "cloudflare:workers";
|
|
32
|
+
import { Server as Server$1 } from "@modelcontextprotocol/sdk/server/index.js";
|
|
33
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
34
|
+
import { Transport } from "@modelcontextprotocol/sdk/shared/transport.js";
|
|
12
35
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
36
|
+
//#region src/mcp/worker-transport.d.ts
|
|
37
|
+
interface WorkerTransportOptions {
|
|
38
|
+
sessionIdGenerator?: () => string;
|
|
39
|
+
enableJsonResponse?: boolean;
|
|
40
|
+
onsessioninitialized?: (sessionId: string) => void;
|
|
41
|
+
}
|
|
42
|
+
declare class WorkerTransport implements Transport {
|
|
43
|
+
private started;
|
|
44
|
+
private initialized;
|
|
45
|
+
private sessionIdGenerator?;
|
|
46
|
+
private enableJsonResponse;
|
|
47
|
+
private onsessioninitialized?;
|
|
48
|
+
private standaloneSseStreamId;
|
|
49
|
+
private streamMapping;
|
|
50
|
+
private requestToStreamMapping;
|
|
51
|
+
private requestResponseMap;
|
|
52
|
+
sessionId?: string;
|
|
53
|
+
onclose?: () => void;
|
|
54
|
+
onerror?: (error: Error) => void;
|
|
55
|
+
onmessage?: (message: JSONRPCMessage) => void;
|
|
56
|
+
constructor(options?: WorkerTransportOptions);
|
|
57
|
+
start(): Promise<void>;
|
|
58
|
+
handleRequest(request: Request, parsedBody?: unknown): Promise<Response>;
|
|
59
|
+
private handleGetRequest;
|
|
60
|
+
private handlePostRequest;
|
|
61
|
+
private handleDeleteRequest;
|
|
62
|
+
private handleOptionsRequest;
|
|
63
|
+
private handleUnsupportedRequest;
|
|
64
|
+
private validateSession;
|
|
65
|
+
close(): Promise<void>;
|
|
66
|
+
send(message: JSONRPCMessage): Promise<void>;
|
|
67
|
+
}
|
|
68
|
+
//#endregion
|
|
69
|
+
//#region src/mcp/handler.d.ts
|
|
70
|
+
interface CreateMcpHandlerOptions extends WorkerTransportOptions {
|
|
31
71
|
/**
|
|
32
|
-
* The
|
|
72
|
+
* The route path that this MCP handler should respond to.
|
|
73
|
+
* If specified, the handler will only process requests that match this route.
|
|
74
|
+
* @default "/mcp"
|
|
33
75
|
*/
|
|
34
|
-
|
|
76
|
+
route?: string;
|
|
77
|
+
}
|
|
78
|
+
type OAuthExecutionContext = ExecutionContext & {
|
|
79
|
+
props?: Record<string, unknown>;
|
|
35
80
|
};
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
previousState: unknown;
|
|
45
|
-
}
|
|
46
|
-
>
|
|
47
|
-
| BaseEvent<
|
|
48
|
-
"rpc",
|
|
49
|
-
{
|
|
50
|
-
method: string;
|
|
51
|
-
args: unknown[];
|
|
52
|
-
streaming?: boolean;
|
|
53
|
-
success: boolean;
|
|
54
|
-
}
|
|
55
|
-
>
|
|
56
|
-
| BaseEvent<
|
|
57
|
-
"message:request" | "message:response",
|
|
58
|
-
{
|
|
59
|
-
message: Message[];
|
|
60
|
-
}
|
|
61
|
-
>
|
|
62
|
-
| BaseEvent<"message:clear">
|
|
63
|
-
| BaseEvent<
|
|
64
|
-
"schedule:create" | "schedule:execute" | "schedule:cancel",
|
|
65
|
-
Schedule<unknown>
|
|
66
|
-
>
|
|
67
|
-
| BaseEvent<"destroy">
|
|
68
|
-
| BaseEvent<
|
|
69
|
-
"connect",
|
|
70
|
-
{
|
|
71
|
-
connectionId: string;
|
|
72
|
-
}
|
|
73
|
-
>;
|
|
74
|
-
interface Observability {
|
|
75
|
-
/**
|
|
76
|
-
* Emit an event for the Agent's observability implementation to handle.
|
|
77
|
-
* @param event - The event to emit
|
|
78
|
-
* @param ctx - The execution context of the invocation
|
|
79
|
-
*/
|
|
80
|
-
emit(event: ObservabilityEvent, ctx: DurableObjectState): void;
|
|
81
|
+
declare function experimental_createMcpHandler(
|
|
82
|
+
server: McpServer | Server$1,
|
|
83
|
+
options?: CreateMcpHandlerOptions
|
|
84
|
+
): (request: Request, env: unknown, ctx: ExecutionContext) => Promise<Response>;
|
|
85
|
+
//#endregion
|
|
86
|
+
//#region src/mcp/auth-context.d.ts
|
|
87
|
+
interface McpAuthContext {
|
|
88
|
+
props: Record<string, unknown>;
|
|
81
89
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
declare
|
|
86
|
-
|
|
90
|
+
declare function getMcpAuthContext(): McpAuthContext | undefined;
|
|
91
|
+
//#endregion
|
|
92
|
+
//#region src/mcp/index.d.ts
|
|
93
|
+
declare abstract class McpAgent<
|
|
94
|
+
Env = unknown,
|
|
95
|
+
State = unknown,
|
|
96
|
+
Props extends Record<string, unknown> = Record<string, unknown>
|
|
97
|
+
> extends Agent<Env, State, Props> {
|
|
98
|
+
private _transport?;
|
|
99
|
+
props?: Props;
|
|
100
|
+
abstract server: MaybePromise<McpServer | Server$1>;
|
|
101
|
+
abstract init(): Promise<void>;
|
|
102
|
+
setInitializeRequest(initializeRequest: JSONRPCMessage): Promise<void>;
|
|
103
|
+
getInitializeRequest(): Promise<JSONRPCMessage | undefined>;
|
|
104
|
+
/** Read the transport type for this agent.
|
|
105
|
+
* This relies on the naming scheme being `sse:${sessionId}`
|
|
106
|
+
* or `streamable-http:${sessionId}`.
|
|
107
|
+
*/
|
|
108
|
+
getTransportType(): BaseTransportType;
|
|
109
|
+
/** Read the sessionId for this agent.
|
|
110
|
+
* This relies on the naming scheme being `sse:${sessionId}`
|
|
111
|
+
* or `streamable-http:${sessionId}`.
|
|
112
|
+
*/
|
|
113
|
+
getSessionId(): string;
|
|
114
|
+
/** Get the unique WebSocket. SSE transport only. */
|
|
115
|
+
private getWebSocket;
|
|
116
|
+
/** Returns a new transport matching the type of the Agent. */
|
|
117
|
+
private initTransport;
|
|
118
|
+
/** Update and store the props */
|
|
119
|
+
updateProps(props?: Props): Promise<void>;
|
|
120
|
+
reinitializeServer(): Promise<void>;
|
|
121
|
+
/** Sets up the MCP transport and server every time the Agent is started.*/
|
|
122
|
+
onStart(props?: Props): Promise<void>;
|
|
123
|
+
/** Validates new WebSocket connections. */
|
|
124
|
+
onConnect(
|
|
125
|
+
conn: Connection$1,
|
|
126
|
+
{ request: req }: ConnectionContext
|
|
127
|
+
): Promise<void>;
|
|
128
|
+
/** Handles MCP Messages for the legacy SSE transport. */
|
|
129
|
+
onSSEMcpMessage(
|
|
130
|
+
_sessionId: string,
|
|
131
|
+
messageBody: unknown
|
|
132
|
+
): Promise<Error | null>;
|
|
133
|
+
/** Elicit user input with a message and schema */
|
|
134
|
+
elicitInput(params: {
|
|
135
|
+
message: string;
|
|
136
|
+
requestedSchema: unknown;
|
|
137
|
+
}): Promise<ElicitResult>;
|
|
138
|
+
/** Wait for elicitation response through storage polling */
|
|
139
|
+
private _waitForElicitationResponse;
|
|
140
|
+
/** Handle elicitation responses */
|
|
141
|
+
private _handleElicitationResponse;
|
|
142
|
+
/** Return a handler for the given path for this MCP.
|
|
143
|
+
* Defaults to Streamable HTTP transport.
|
|
144
|
+
*/
|
|
145
|
+
static serve(
|
|
146
|
+
path: string,
|
|
147
|
+
{ binding, corsOptions, transport }?: ServeOptions
|
|
148
|
+
): {
|
|
149
|
+
fetch<Env>(
|
|
150
|
+
this: void,
|
|
151
|
+
request: Request,
|
|
152
|
+
env: Env,
|
|
153
|
+
ctx: ExecutionContext
|
|
154
|
+
): Promise<Response>;
|
|
155
|
+
};
|
|
156
|
+
/**
|
|
157
|
+
* Legacy api
|
|
158
|
+
**/
|
|
159
|
+
static mount(
|
|
160
|
+
path: string,
|
|
161
|
+
opts?: Omit<ServeOptions, "transport">
|
|
162
|
+
): {
|
|
163
|
+
fetch<Env>(
|
|
164
|
+
this: void,
|
|
165
|
+
request: Request,
|
|
166
|
+
env: Env,
|
|
167
|
+
ctx: ExecutionContext
|
|
168
|
+
): Promise<Response>;
|
|
169
|
+
};
|
|
170
|
+
static serveSSE(
|
|
171
|
+
path: string,
|
|
172
|
+
opts?: Omit<ServeOptions, "transport">
|
|
173
|
+
): {
|
|
174
|
+
fetch<Env>(
|
|
175
|
+
this: void,
|
|
176
|
+
request: Request,
|
|
177
|
+
env: Env,
|
|
178
|
+
ctx: ExecutionContext
|
|
179
|
+
): Promise<Response>;
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
//#endregion
|
|
183
|
+
//#region src/index.d.ts
|
|
87
184
|
/**
|
|
88
185
|
* RPC request message from client
|
|
89
186
|
*/
|
|
@@ -97,14 +194,14 @@ type RPCRequest = {
|
|
|
97
194
|
* State update message from client
|
|
98
195
|
*/
|
|
99
196
|
type StateUpdateMessage = {
|
|
100
|
-
type:
|
|
197
|
+
type: MessageType.CF_AGENT_STATE;
|
|
101
198
|
state: unknown;
|
|
102
199
|
};
|
|
103
200
|
/**
|
|
104
201
|
* RPC response message to client
|
|
105
202
|
*/
|
|
106
203
|
type RPCResponse = {
|
|
107
|
-
type:
|
|
204
|
+
type: MessageType.RPC;
|
|
108
205
|
id: string;
|
|
109
206
|
} & (
|
|
110
207
|
| {
|
|
@@ -135,12 +232,18 @@ type CallableMetadata = {
|
|
|
135
232
|
* Decorator that marks a method as callable by clients
|
|
136
233
|
* @param metadata Optional metadata about the callable method
|
|
137
234
|
*/
|
|
138
|
-
declare function
|
|
235
|
+
declare function callable(
|
|
139
236
|
metadata?: CallableMetadata
|
|
140
237
|
): <This, Args extends unknown[], Return>(
|
|
141
238
|
target: (this: This, ...args: Args) => Return,
|
|
142
239
|
context: ClassMethodDecoratorContext
|
|
143
240
|
) => (this: This, ...args: Args) => Return;
|
|
241
|
+
/**
|
|
242
|
+
* Decorator that marks a method as callable by clients
|
|
243
|
+
* @deprecated this has been renamed to callable, and unstable_callable will be removed in the next major version
|
|
244
|
+
* @param metadata Optional metadata about the callable method
|
|
245
|
+
*/
|
|
246
|
+
declare const unstable_callable: (metadata?: CallableMetadata) => void;
|
|
144
247
|
type QueueItem<T = string> = {
|
|
145
248
|
id: string;
|
|
146
249
|
payload: T;
|
|
@@ -186,7 +289,7 @@ type Schedule<T = string> = {
|
|
|
186
289
|
* MCP Server state update message from server -> Client
|
|
187
290
|
*/
|
|
188
291
|
type MCPServerMessage = {
|
|
189
|
-
type:
|
|
292
|
+
type: MessageType.CF_AGENT_MCP_SERVERS;
|
|
190
293
|
mcp: MCPServersState;
|
|
191
294
|
};
|
|
192
295
|
type MCPServersState = {
|
|
@@ -201,7 +304,7 @@ type MCPServer = {
|
|
|
201
304
|
name: string;
|
|
202
305
|
server_url: string;
|
|
203
306
|
auth_url: string | null;
|
|
204
|
-
state:
|
|
307
|
+
state: MCPConnectionState;
|
|
205
308
|
instructions: string | null;
|
|
206
309
|
capabilities: ServerCapabilities | null;
|
|
207
310
|
};
|
|
@@ -218,10 +321,15 @@ declare function getCurrentAgent<
|
|
|
218
321
|
* @template Env Environment type containing bindings
|
|
219
322
|
* @template State State type to store within the Agent
|
|
220
323
|
*/
|
|
221
|
-
declare class Agent<
|
|
324
|
+
declare class Agent<
|
|
325
|
+
Env = typeof env,
|
|
326
|
+
State = unknown,
|
|
327
|
+
Props extends Record<string, unknown> = Record<string, unknown>
|
|
328
|
+
> extends Server<Env, Props> {
|
|
222
329
|
private _state;
|
|
330
|
+
private _disposables;
|
|
223
331
|
private _ParentClass;
|
|
224
|
-
mcp: MCPClientManager;
|
|
332
|
+
readonly mcp: MCPClientManager;
|
|
225
333
|
/**
|
|
226
334
|
* Initial state for the Agent
|
|
227
335
|
* Override to provide default state values
|
|
@@ -398,55 +506,50 @@ declare class Agent<Env = typeof env, State = unknown> extends Server<Env> {
|
|
|
398
506
|
/**
|
|
399
507
|
* Connect to a new MCP Server
|
|
400
508
|
*
|
|
509
|
+
* @param serverName Name of the MCP server
|
|
401
510
|
* @param url MCP Server SSE URL
|
|
402
|
-
* @param callbackHost Base host for the agent, used for the redirect URI.
|
|
511
|
+
* @param callbackHost Base host for the agent, used for the redirect URI. If not provided, will be derived from the current request.
|
|
403
512
|
* @param agentsPrefix agents routing prefix if not using `agents`
|
|
404
|
-
* @param options MCP client and transport
|
|
513
|
+
* @param options MCP client and transport options
|
|
405
514
|
* @returns authUrl
|
|
406
515
|
*/
|
|
407
516
|
addMcpServer(
|
|
408
517
|
serverName: string,
|
|
409
518
|
url: string,
|
|
410
|
-
callbackHost
|
|
519
|
+
callbackHost?: string,
|
|
411
520
|
agentsPrefix?: string,
|
|
412
521
|
options?: {
|
|
413
522
|
client?: ConstructorParameters<typeof Client>[1];
|
|
414
|
-
transport?: {
|
|
415
|
-
headers: HeadersInit;
|
|
416
|
-
};
|
|
417
|
-
}
|
|
418
|
-
): Promise<{
|
|
419
|
-
id: string;
|
|
420
|
-
authUrl: string | undefined;
|
|
421
|
-
}>;
|
|
422
|
-
_connectToMcpServerInternal(
|
|
423
|
-
_serverName: string,
|
|
424
|
-
url: string,
|
|
425
|
-
callbackUrl: string,
|
|
426
|
-
options?: {
|
|
427
|
-
client?: ConstructorParameters<typeof Client>[1];
|
|
428
|
-
/**
|
|
429
|
-
* We don't expose the normal set of transport options because:
|
|
430
|
-
* 1) we can't serialize things like the auth provider or a fetch function into the DB for reconnection purposes
|
|
431
|
-
* 2) We probably want these options to be agnostic to the transport type (SSE vs Streamable)
|
|
432
|
-
*
|
|
433
|
-
* This has the limitation that you can't override fetch, but I think headers should handle nearly all cases needed (i.e. non-standard bearer auth).
|
|
434
|
-
*/
|
|
435
523
|
transport?: {
|
|
436
524
|
headers?: HeadersInit;
|
|
525
|
+
type?: TransportType;
|
|
437
526
|
};
|
|
438
|
-
},
|
|
439
|
-
reconnect?: {
|
|
440
|
-
id: string;
|
|
441
|
-
oauthClientId?: string;
|
|
442
527
|
}
|
|
443
528
|
): Promise<{
|
|
444
529
|
id: string;
|
|
445
530
|
authUrl: string | undefined;
|
|
446
|
-
clientId: string | undefined;
|
|
447
531
|
}>;
|
|
532
|
+
/**
|
|
533
|
+
* Handle potential OAuth callback requests after DO hibernation.
|
|
534
|
+
* Detects OAuth callbacks, restores state from database, and processes the callback.
|
|
535
|
+
* Returns a Response if this was an OAuth callback, otherwise returns undefined.
|
|
536
|
+
*/
|
|
537
|
+
private _handlePotentialOAuthCallback;
|
|
538
|
+
/**
|
|
539
|
+
* Process an OAuth callback request (assumes state is already restored)
|
|
540
|
+
*/
|
|
541
|
+
private _processOAuthCallback;
|
|
542
|
+
private _connectToMcpServerInternal;
|
|
448
543
|
removeMcpServer(id: string): Promise<void>;
|
|
449
544
|
getMcpServers(): MCPServersState;
|
|
545
|
+
private broadcastMcpServers;
|
|
546
|
+
/**
|
|
547
|
+
* Handle OAuth callback response using MCPClientManager configuration
|
|
548
|
+
* @param result OAuth callback result
|
|
549
|
+
* @param request The original request (needed for base URL)
|
|
550
|
+
* @returns Response for the OAuth callback
|
|
551
|
+
*/
|
|
552
|
+
private handleOAuthCallbackResponse;
|
|
450
553
|
}
|
|
451
554
|
/**
|
|
452
555
|
* Namespace for creating Agent instances
|
|
@@ -554,12 +657,17 @@ type EmailSendOptions = {
|
|
|
554
657
|
* @param options Options for Agent creation
|
|
555
658
|
* @returns Promise resolving to an Agent instance stub
|
|
556
659
|
*/
|
|
557
|
-
declare function getAgentByName<
|
|
660
|
+
declare function getAgentByName<
|
|
661
|
+
Env,
|
|
662
|
+
T extends Agent<Env>,
|
|
663
|
+
Props extends Record<string, unknown> = Record<string, unknown>
|
|
664
|
+
>(
|
|
558
665
|
namespace: AgentNamespace<T>,
|
|
559
666
|
name: string,
|
|
560
667
|
options?: {
|
|
561
668
|
jurisdiction?: DurableObjectJurisdiction;
|
|
562
669
|
locationHint?: DurableObjectLocationHint;
|
|
670
|
+
props?: Props;
|
|
563
671
|
}
|
|
564
672
|
): Promise<DurableObjectStub<T>>;
|
|
565
673
|
/**
|
|
@@ -581,35 +689,48 @@ declare class StreamingResponse {
|
|
|
581
689
|
*/
|
|
582
690
|
end(finalChunk?: unknown): void;
|
|
583
691
|
}
|
|
584
|
-
|
|
692
|
+
//#endregion
|
|
585
693
|
export {
|
|
586
|
-
Agent
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
type
|
|
593
|
-
type
|
|
594
|
-
type
|
|
595
|
-
type
|
|
596
|
-
|
|
597
|
-
type
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
694
|
+
Agent,
|
|
695
|
+
AgentContext,
|
|
696
|
+
AgentEmail,
|
|
697
|
+
AgentNamespace,
|
|
698
|
+
AgentOptions,
|
|
699
|
+
CallableMetadata,
|
|
700
|
+
type Connection$1 as Connection,
|
|
701
|
+
type ConnectionContext,
|
|
702
|
+
type CreateMcpHandlerOptions,
|
|
703
|
+
type ElicitRequest$1 as ElicitRequest,
|
|
704
|
+
ElicitRequestSchema$1 as ElicitRequestSchema,
|
|
705
|
+
type ElicitResult$1 as ElicitResult,
|
|
706
|
+
EmailResolver,
|
|
707
|
+
EmailRoutingOptions,
|
|
708
|
+
EmailSendOptions,
|
|
709
|
+
MCPServer,
|
|
710
|
+
MCPServerMessage,
|
|
711
|
+
MCPServersState,
|
|
712
|
+
McpAgent,
|
|
713
|
+
type McpAuthContext,
|
|
714
|
+
type OAuthExecutionContext,
|
|
715
|
+
QueueItem,
|
|
716
|
+
RPCRequest,
|
|
717
|
+
RPCResponse,
|
|
718
|
+
Schedule,
|
|
719
|
+
StateUpdateMessage,
|
|
720
|
+
StreamingResponse,
|
|
721
|
+
type WSMessage,
|
|
722
|
+
WorkerTransport,
|
|
723
|
+
type WorkerTransportOptions,
|
|
724
|
+
callable,
|
|
725
|
+
createAddressBasedEmailResolver,
|
|
726
|
+
createCatchAllEmailResolver,
|
|
727
|
+
createHeaderBasedEmailResolver,
|
|
728
|
+
experimental_createMcpHandler,
|
|
729
|
+
getAgentByName,
|
|
730
|
+
getCurrentAgent,
|
|
731
|
+
getMcpAuthContext,
|
|
732
|
+
routeAgentEmail,
|
|
733
|
+
routeAgentRequest,
|
|
734
|
+
unstable_callable
|
|
615
735
|
};
|
|
736
|
+
//# sourceMappingURL=index-DWJSBMbz.d.ts.map
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { BaseEvent, MCPObservabilityEvent } from "./mcp-BEwaCsxO.js";
|
|
2
|
+
|
|
3
|
+
//#region src/observability/agent.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Agent-specific observability events
|
|
7
|
+
* These track the lifecycle and operations of an Agent
|
|
8
|
+
*/
|
|
9
|
+
type AgentObservabilityEvent =
|
|
10
|
+
| BaseEvent<"state:update", {}>
|
|
11
|
+
| BaseEvent<
|
|
12
|
+
"rpc",
|
|
13
|
+
{
|
|
14
|
+
method: string;
|
|
15
|
+
streaming?: boolean;
|
|
16
|
+
}
|
|
17
|
+
>
|
|
18
|
+
| BaseEvent<"message:request" | "message:response", {}>
|
|
19
|
+
| BaseEvent<"message:clear">
|
|
20
|
+
| BaseEvent<
|
|
21
|
+
"schedule:create" | "schedule:execute" | "schedule:cancel",
|
|
22
|
+
{
|
|
23
|
+
callback: string;
|
|
24
|
+
id: string;
|
|
25
|
+
}
|
|
26
|
+
>
|
|
27
|
+
| BaseEvent<"destroy">
|
|
28
|
+
| BaseEvent<
|
|
29
|
+
"connect",
|
|
30
|
+
{
|
|
31
|
+
connectionId: string;
|
|
32
|
+
}
|
|
33
|
+
>;
|
|
34
|
+
//#endregion
|
|
35
|
+
//#region src/observability/index.d.ts
|
|
36
|
+
/**
|
|
37
|
+
* Union of all observability event types from different domains
|
|
38
|
+
*/
|
|
39
|
+
type ObservabilityEvent = AgentObservabilityEvent | MCPObservabilityEvent;
|
|
40
|
+
interface Observability {
|
|
41
|
+
/**
|
|
42
|
+
* Emit an event for the Agent's observability implementation to handle.
|
|
43
|
+
* @param event - The event to emit
|
|
44
|
+
* @param ctx - The execution context of the invocation (optional)
|
|
45
|
+
*/
|
|
46
|
+
emit(event: ObservabilityEvent, ctx?: DurableObjectState): void;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* A generic observability implementation that logs events to the console.
|
|
50
|
+
*/
|
|
51
|
+
declare const genericObservability: Observability;
|
|
52
|
+
//#endregion
|
|
53
|
+
export { Observability, ObservabilityEvent, genericObservability };
|
|
54
|
+
//# sourceMappingURL=index-W4JUkafc.d.ts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,41 +1,84 @@
|
|
|
1
|
-
import "
|
|
2
|
-
import "
|
|
3
|
-
import "
|
|
4
|
-
|
|
5
|
-
import "./
|
|
1
|
+
import { TransportType } from "./client-C-nwz-3N.js";
|
|
2
|
+
import "./mcp-BEwaCsxO.js";
|
|
3
|
+
import "./do-oauth-client-provider-CCwGwnrA.js";
|
|
4
|
+
import "./index-W4JUkafc.js";
|
|
5
|
+
import "./ai-types-BWW4umHY.js";
|
|
6
|
+
import {
|
|
7
|
+
Agent,
|
|
8
|
+
AgentContext,
|
|
9
|
+
AgentEmail,
|
|
10
|
+
AgentNamespace,
|
|
11
|
+
AgentOptions,
|
|
12
|
+
CallableMetadata,
|
|
13
|
+
Connection,
|
|
14
|
+
ConnectionContext,
|
|
15
|
+
CreateMcpHandlerOptions,
|
|
16
|
+
EmailResolver,
|
|
17
|
+
EmailRoutingOptions,
|
|
18
|
+
EmailSendOptions,
|
|
19
|
+
MCPServer,
|
|
20
|
+
MCPServerMessage,
|
|
21
|
+
MCPServersState,
|
|
22
|
+
McpAuthContext,
|
|
23
|
+
OAuthExecutionContext,
|
|
24
|
+
QueueItem,
|
|
25
|
+
RPCRequest,
|
|
26
|
+
RPCResponse,
|
|
27
|
+
Schedule,
|
|
28
|
+
StateUpdateMessage,
|
|
29
|
+
StreamingResponse,
|
|
30
|
+
WSMessage,
|
|
31
|
+
WorkerTransport,
|
|
32
|
+
WorkerTransportOptions,
|
|
33
|
+
callable,
|
|
34
|
+
createAddressBasedEmailResolver,
|
|
35
|
+
createCatchAllEmailResolver,
|
|
36
|
+
createHeaderBasedEmailResolver,
|
|
37
|
+
experimental_createMcpHandler,
|
|
38
|
+
getAgentByName,
|
|
39
|
+
getCurrentAgent,
|
|
40
|
+
getMcpAuthContext,
|
|
41
|
+
routeAgentEmail,
|
|
42
|
+
routeAgentRequest,
|
|
43
|
+
unstable_callable
|
|
44
|
+
} from "./index-DWJSBMbz.js";
|
|
6
45
|
export {
|
|
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
|
-
|
|
40
|
-
|
|
41
|
-
|
|
46
|
+
Agent,
|
|
47
|
+
AgentContext,
|
|
48
|
+
AgentEmail,
|
|
49
|
+
AgentNamespace,
|
|
50
|
+
AgentOptions,
|
|
51
|
+
CallableMetadata,
|
|
52
|
+
Connection,
|
|
53
|
+
ConnectionContext,
|
|
54
|
+
CreateMcpHandlerOptions,
|
|
55
|
+
EmailResolver,
|
|
56
|
+
EmailRoutingOptions,
|
|
57
|
+
EmailSendOptions,
|
|
58
|
+
MCPServer,
|
|
59
|
+
MCPServerMessage,
|
|
60
|
+
MCPServersState,
|
|
61
|
+
McpAuthContext,
|
|
62
|
+
OAuthExecutionContext,
|
|
63
|
+
QueueItem,
|
|
64
|
+
RPCRequest,
|
|
65
|
+
RPCResponse,
|
|
66
|
+
Schedule,
|
|
67
|
+
StateUpdateMessage,
|
|
68
|
+
StreamingResponse,
|
|
69
|
+
TransportType,
|
|
70
|
+
WSMessage,
|
|
71
|
+
WorkerTransport,
|
|
72
|
+
WorkerTransportOptions,
|
|
73
|
+
callable,
|
|
74
|
+
createAddressBasedEmailResolver,
|
|
75
|
+
createCatchAllEmailResolver,
|
|
76
|
+
createHeaderBasedEmailResolver,
|
|
77
|
+
experimental_createMcpHandler,
|
|
78
|
+
getAgentByName,
|
|
79
|
+
getCurrentAgent,
|
|
80
|
+
getMcpAuthContext,
|
|
81
|
+
routeAgentEmail,
|
|
82
|
+
routeAgentRequest,
|
|
83
|
+
unstable_callable
|
|
84
|
+
};
|