agents 0.0.0-d40512c → 0.0.0-d520fe8
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 +236 -6
- package/dist/ai-chat-agent.d.ts +95 -20
- package/dist/ai-chat-agent.js +798 -260
- package/dist/ai-chat-agent.js.map +1 -1
- package/dist/ai-chat-v5-migration-BSiGZmYU.js +155 -0
- package/dist/ai-chat-v5-migration-BSiGZmYU.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 +78 -85
- package/dist/ai-react.js +396 -199
- package/dist/ai-react.js.map +1 -1
- package/dist/ai-types-81H_-Uxh.d.ts +103 -0
- package/dist/ai-types-CrMqkwc_.js +24 -0
- package/dist/ai-types-CrMqkwc_.js.map +1 -0
- package/dist/ai-types.d.ts +6 -74
- package/dist/ai-types.js +3 -1
- package/dist/cli.d.ts +8 -0
- package/dist/cli.js +27 -0
- package/dist/cli.js.map +1 -0
- package/dist/client-B3SR12TQ.js +117 -0
- package/dist/client-B3SR12TQ.js.map +1 -0
- package/dist/client-BAQA84dr.d.ts +104 -0
- package/dist/client-BZq9qau2.js +1093 -0
- package/dist/client-BZq9qau2.js.map +1 -0
- package/dist/client-CsaP9Irq.d.ts +1528 -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-C2CHH5x-.d.ts +55 -0
- package/dist/do-oauth-client-provider-CwqK5SXm.js +94 -0
- package/dist/do-oauth-client-provider-CwqK5SXm.js.map +1 -0
- package/dist/index-BUle9RiP.d.ts +58 -0
- package/dist/{index-CITGJflw.d.ts → index-Bx5KK3VJ.d.ts} +256 -155
- package/dist/index.d.ts +69 -30
- package/dist/index.js +7 -22
- package/dist/mcp/client.d.ts +4 -1055
- package/dist/mcp/client.js +4 -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 +190 -81
- package/dist/mcp/index.js +1434 -770
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/x402.d.ts +34 -0
- package/dist/mcp/x402.js +198 -0
- package/dist/mcp/x402.js.map +1 -0
- package/dist/mcp-BwPscEiF.d.ts +61 -0
- package/dist/observability/index.d.ts +3 -12
- package/dist/observability/index.js +7 -10
- package/dist/react-CbwD4fBf.d.ts +113 -0
- package/dist/react.d.ts +10 -119
- package/dist/react.js +183 -110
- package/dist/react.js.map +1 -1
- package/dist/schedule.d.ts +91 -14
- package/dist/schedule.js +46 -21
- package/dist/schedule.js.map +1 -1
- package/dist/serializable-faDkMCai.d.ts +39 -0
- package/dist/serializable.d.ts +7 -32
- package/dist/serializable.js +1 -1
- package/dist/src-D_KKH_4c.js +1184 -0
- package/dist/src-D_KKH_4c.js.map +1 -0
- package/package.json +78 -28
- package/dist/ai-types.js.map +0 -1
- package/dist/chunk-4RBEYCWK.js +0 -469
- package/dist/chunk-4RBEYCWK.js.map +0 -1
- package/dist/chunk-KUH345EY.js +0 -116
- package/dist/chunk-KUH345EY.js.map +0 -1
- package/dist/chunk-LU2RSO54.js +0 -910
- package/dist/chunk-LU2RSO54.js.map +0 -1
- package/dist/chunk-PVQZBKN7.js +0 -106
- package/dist/chunk-PVQZBKN7.js.map +0 -1
- 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/observability/index.js.map +0 -1
- package/dist/serializable.js.map +0 -1
- package/src/index.ts +0 -1365
|
@@ -1,87 +1,28 @@
|
|
|
1
|
+
import {
|
|
2
|
+
h as TransportType,
|
|
3
|
+
t as MCPClientManager,
|
|
4
|
+
u as MCPConnectionState
|
|
5
|
+
} from "./client-CsaP9Irq.js";
|
|
6
|
+
import { t as Observability } from "./index-BUle9RiP.js";
|
|
7
|
+
import { n as MessageType } from "./ai-types-81H_-Uxh.js";
|
|
8
|
+
import {
|
|
9
|
+
Connection,
|
|
10
|
+
Connection as Connection$1,
|
|
11
|
+
ConnectionContext,
|
|
12
|
+
PartyServerOptions,
|
|
13
|
+
Server,
|
|
14
|
+
WSMessage
|
|
15
|
+
} from "partyserver";
|
|
1
16
|
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
2
17
|
import {
|
|
3
|
-
ServerCapabilities,
|
|
4
|
-
Tool,
|
|
5
18
|
Prompt,
|
|
6
|
-
Resource
|
|
19
|
+
Resource,
|
|
20
|
+
ServerCapabilities,
|
|
21
|
+
Tool
|
|
7
22
|
} from "@modelcontextprotocol/sdk/types.js";
|
|
8
|
-
import {
|
|
9
|
-
import { MCPClientManager } from "./mcp/client.js";
|
|
10
|
-
import { Message } from "ai";
|
|
23
|
+
import { env } from "cloudflare:workers";
|
|
11
24
|
|
|
12
|
-
|
|
13
|
-
T extends string,
|
|
14
|
-
Payload extends Record<string, unknown> = {}
|
|
15
|
-
> = {
|
|
16
|
-
type: T;
|
|
17
|
-
/**
|
|
18
|
-
* The unique identifier for the event
|
|
19
|
-
*/
|
|
20
|
-
id: string;
|
|
21
|
-
/**
|
|
22
|
-
* The message to display in the logs for this event, should the implementation choose to display
|
|
23
|
-
* a human-readable message.
|
|
24
|
-
*/
|
|
25
|
-
displayMessage: string;
|
|
26
|
-
/**
|
|
27
|
-
* The payload of the event
|
|
28
|
-
*/
|
|
29
|
-
payload: Payload;
|
|
30
|
-
/**
|
|
31
|
-
* The timestamp of the event in milliseconds since epoch
|
|
32
|
-
*/
|
|
33
|
-
timestamp: number;
|
|
34
|
-
};
|
|
35
|
-
/**
|
|
36
|
-
* The type of events that can be emitted by an Agent
|
|
37
|
-
*/
|
|
38
|
-
type ObservabilityEvent =
|
|
39
|
-
| BaseEvent<
|
|
40
|
-
"state:update",
|
|
41
|
-
{
|
|
42
|
-
state: unknown;
|
|
43
|
-
previousState: unknown;
|
|
44
|
-
}
|
|
45
|
-
>
|
|
46
|
-
| BaseEvent<
|
|
47
|
-
"rpc",
|
|
48
|
-
{
|
|
49
|
-
method: string;
|
|
50
|
-
args: unknown[];
|
|
51
|
-
streaming?: boolean;
|
|
52
|
-
success: boolean;
|
|
53
|
-
}
|
|
54
|
-
>
|
|
55
|
-
| BaseEvent<
|
|
56
|
-
"message:request" | "message:response",
|
|
57
|
-
{
|
|
58
|
-
message: Message[];
|
|
59
|
-
}
|
|
60
|
-
>
|
|
61
|
-
| BaseEvent<"message:clear">
|
|
62
|
-
| BaseEvent<
|
|
63
|
-
"schedule:create" | "schedule:execute" | "schedule:cancel",
|
|
64
|
-
Schedule<unknown>
|
|
65
|
-
>
|
|
66
|
-
| BaseEvent<"destroy">
|
|
67
|
-
| BaseEvent<
|
|
68
|
-
"connect",
|
|
69
|
-
{
|
|
70
|
-
connectionId: string;
|
|
71
|
-
}
|
|
72
|
-
>;
|
|
73
|
-
interface Observability {
|
|
74
|
-
/**
|
|
75
|
-
* Emit an event for the Agent's observability implementation to handle.
|
|
76
|
-
* @param event - The event to emit
|
|
77
|
-
* @param ctx - The execution context of the invocation
|
|
78
|
-
*/
|
|
79
|
-
emit(event: ObservabilityEvent, ctx: DurableObjectState): void;
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* A generic observability implementation that logs events to the console.
|
|
83
|
-
*/
|
|
84
|
-
declare const genericObservability: Observability;
|
|
25
|
+
//#region src/index.d.ts
|
|
85
26
|
|
|
86
27
|
/**
|
|
87
28
|
* RPC request message from client
|
|
@@ -96,14 +37,14 @@ type RPCRequest = {
|
|
|
96
37
|
* State update message from client
|
|
97
38
|
*/
|
|
98
39
|
type StateUpdateMessage = {
|
|
99
|
-
type:
|
|
40
|
+
type: MessageType.CF_AGENT_STATE;
|
|
100
41
|
state: unknown;
|
|
101
42
|
};
|
|
102
43
|
/**
|
|
103
44
|
* RPC response message to client
|
|
104
45
|
*/
|
|
105
46
|
type RPCResponse = {
|
|
106
|
-
type:
|
|
47
|
+
type: MessageType.RPC;
|
|
107
48
|
id: string;
|
|
108
49
|
} & (
|
|
109
50
|
| {
|
|
@@ -134,12 +75,24 @@ type CallableMetadata = {
|
|
|
134
75
|
* Decorator that marks a method as callable by clients
|
|
135
76
|
* @param metadata Optional metadata about the callable method
|
|
136
77
|
*/
|
|
137
|
-
declare function
|
|
78
|
+
declare function callable(
|
|
138
79
|
metadata?: CallableMetadata
|
|
139
80
|
): <This, Args extends unknown[], Return>(
|
|
140
81
|
target: (this: This, ...args: Args) => Return,
|
|
141
82
|
context: ClassMethodDecoratorContext
|
|
142
83
|
) => (this: This, ...args: Args) => Return;
|
|
84
|
+
/**
|
|
85
|
+
* Decorator that marks a method as callable by clients
|
|
86
|
+
* @deprecated this has been renamed to callable, and unstable_callable will be removed in the next major version
|
|
87
|
+
* @param metadata Optional metadata about the callable method
|
|
88
|
+
*/
|
|
89
|
+
declare const unstable_callable: (metadata?: CallableMetadata) => void;
|
|
90
|
+
type QueueItem<T = string> = {
|
|
91
|
+
id: string;
|
|
92
|
+
payload: T;
|
|
93
|
+
callback: keyof Agent<unknown>;
|
|
94
|
+
created_at: number;
|
|
95
|
+
};
|
|
143
96
|
/**
|
|
144
97
|
* Represents a scheduled task within an Agent
|
|
145
98
|
* @template T Type of the payload data
|
|
@@ -179,22 +132,28 @@ type Schedule<T = string> = {
|
|
|
179
132
|
* MCP Server state update message from server -> Client
|
|
180
133
|
*/
|
|
181
134
|
type MCPServerMessage = {
|
|
182
|
-
type:
|
|
135
|
+
type: MessageType.CF_AGENT_MCP_SERVERS;
|
|
183
136
|
mcp: MCPServersState;
|
|
184
137
|
};
|
|
185
138
|
type MCPServersState = {
|
|
186
139
|
servers: {
|
|
187
140
|
[id: string]: MCPServer;
|
|
188
141
|
};
|
|
189
|
-
tools: Tool
|
|
190
|
-
|
|
191
|
-
|
|
142
|
+
tools: (Tool & {
|
|
143
|
+
serverId: string;
|
|
144
|
+
})[];
|
|
145
|
+
prompts: (Prompt & {
|
|
146
|
+
serverId: string;
|
|
147
|
+
})[];
|
|
148
|
+
resources: (Resource & {
|
|
149
|
+
serverId: string;
|
|
150
|
+
})[];
|
|
192
151
|
};
|
|
193
152
|
type MCPServer = {
|
|
194
153
|
name: string;
|
|
195
154
|
server_url: string;
|
|
196
155
|
auth_url: string | null;
|
|
197
|
-
state:
|
|
156
|
+
state: MCPConnectionState;
|
|
198
157
|
instructions: string | null;
|
|
199
158
|
capabilities: ServerCapabilities | null;
|
|
200
159
|
};
|
|
@@ -203,17 +162,24 @@ declare function getCurrentAgent<
|
|
|
203
162
|
>(): {
|
|
204
163
|
agent: T | undefined;
|
|
205
164
|
connection: Connection | undefined;
|
|
206
|
-
request: Request
|
|
165
|
+
request: Request | undefined;
|
|
166
|
+
email: AgentEmail | undefined;
|
|
207
167
|
};
|
|
208
168
|
/**
|
|
209
169
|
* Base class for creating Agent implementations
|
|
210
170
|
* @template Env Environment type containing bindings
|
|
211
171
|
* @template State State type to store within the Agent
|
|
212
172
|
*/
|
|
213
|
-
declare class Agent<
|
|
173
|
+
declare class Agent<
|
|
174
|
+
Env = typeof env,
|
|
175
|
+
State = unknown,
|
|
176
|
+
Props extends Record<string, unknown> = Record<string, unknown>
|
|
177
|
+
> extends Server<Env, Props> {
|
|
214
178
|
private _state;
|
|
179
|
+
private _disposables;
|
|
180
|
+
private _destroyed;
|
|
215
181
|
private _ParentClass;
|
|
216
|
-
mcp: MCPClientManager;
|
|
182
|
+
readonly mcp: MCPClientManager;
|
|
217
183
|
/**
|
|
218
184
|
* Initial state for the Agent
|
|
219
185
|
* Override to provide default state values
|
|
@@ -259,17 +225,75 @@ declare class Agent<Env, State = unknown> extends Server<Env> {
|
|
|
259
225
|
*/
|
|
260
226
|
onStateUpdate(state: State | undefined, source: Connection | "server"): void;
|
|
261
227
|
/**
|
|
262
|
-
* Called when the Agent receives an email
|
|
228
|
+
* Called when the Agent receives an email via routeAgentEmail()
|
|
229
|
+
* Override this method to handle incoming emails
|
|
263
230
|
* @param email Email message to process
|
|
264
231
|
*/
|
|
265
|
-
|
|
232
|
+
_onEmail(email: AgentEmail): Promise<void>;
|
|
233
|
+
/**
|
|
234
|
+
* Reply to an email
|
|
235
|
+
* @param email The email to reply to
|
|
236
|
+
* @param options Options for the reply
|
|
237
|
+
* @returns void
|
|
238
|
+
*/
|
|
239
|
+
replyToEmail(
|
|
240
|
+
email: AgentEmail,
|
|
241
|
+
options: {
|
|
242
|
+
fromName: string;
|
|
243
|
+
subject?: string | undefined;
|
|
244
|
+
body: string;
|
|
245
|
+
contentType?: string;
|
|
246
|
+
headers?: Record<string, string>;
|
|
247
|
+
}
|
|
248
|
+
): Promise<void>;
|
|
266
249
|
private _tryCatch;
|
|
250
|
+
/**
|
|
251
|
+
* Automatically wrap custom methods with agent context
|
|
252
|
+
* This ensures getCurrentAgent() works in all custom methods without decorators
|
|
253
|
+
*/
|
|
254
|
+
private _autoWrapCustomMethods;
|
|
267
255
|
onError(connection: Connection, error: unknown): void | Promise<void>;
|
|
268
256
|
onError(error: unknown): void | Promise<void>;
|
|
269
257
|
/**
|
|
270
258
|
* Render content (not implemented in base class)
|
|
271
259
|
*/
|
|
272
260
|
render(): void;
|
|
261
|
+
/**
|
|
262
|
+
* Queue a task to be executed in the future
|
|
263
|
+
* @param payload Payload to pass to the callback
|
|
264
|
+
* @param callback Name of the method to call
|
|
265
|
+
* @returns The ID of the queued task
|
|
266
|
+
*/
|
|
267
|
+
queue<T = unknown>(callback: keyof this, payload: T): Promise<string>;
|
|
268
|
+
private _flushingQueue;
|
|
269
|
+
private _flushQueue;
|
|
270
|
+
/**
|
|
271
|
+
* Dequeue a task by ID
|
|
272
|
+
* @param id ID of the task to dequeue
|
|
273
|
+
*/
|
|
274
|
+
dequeue(id: string): Promise<void>;
|
|
275
|
+
/**
|
|
276
|
+
* Dequeue all tasks
|
|
277
|
+
*/
|
|
278
|
+
dequeueAll(): Promise<void>;
|
|
279
|
+
/**
|
|
280
|
+
* Dequeue all tasks by callback
|
|
281
|
+
* @param callback Name of the callback to dequeue
|
|
282
|
+
*/
|
|
283
|
+
dequeueAllByCallback(callback: string): Promise<void>;
|
|
284
|
+
/**
|
|
285
|
+
* Get a queued task by ID
|
|
286
|
+
* @param id ID of the task to get
|
|
287
|
+
* @returns The task or undefined if not found
|
|
288
|
+
*/
|
|
289
|
+
getQueue(id: string): Promise<QueueItem<string> | undefined>;
|
|
290
|
+
/**
|
|
291
|
+
* Get all queues by key and value
|
|
292
|
+
* @param key Key to filter by
|
|
293
|
+
* @param value Value to filter by
|
|
294
|
+
* @returns Array of matching QueueItem objects
|
|
295
|
+
*/
|
|
296
|
+
getQueues(key: string, value: string): Promise<QueueItem<string>[]>;
|
|
273
297
|
/**
|
|
274
298
|
* Schedule a task to be executed in the future
|
|
275
299
|
* @template T Type of the payload data
|
|
@@ -332,55 +356,62 @@ declare class Agent<Env, State = unknown> extends Server<Env> {
|
|
|
332
356
|
/**
|
|
333
357
|
* Connect to a new MCP Server
|
|
334
358
|
*
|
|
359
|
+
* @param serverName Name of the MCP server
|
|
335
360
|
* @param url MCP Server SSE URL
|
|
336
|
-
* @param callbackHost Base host for the agent, used for the redirect URI.
|
|
361
|
+
* @param callbackHost Base host for the agent, used for the redirect URI. If not provided, will be derived from the current request.
|
|
337
362
|
* @param agentsPrefix agents routing prefix if not using `agents`
|
|
338
|
-
* @param options MCP client and transport
|
|
339
|
-
* @returns authUrl
|
|
363
|
+
* @param options MCP client and transport options
|
|
364
|
+
* @returns Server id and state - either "authenticating" with authUrl, or "ready"
|
|
365
|
+
* @throws If connection or discovery fails
|
|
340
366
|
*/
|
|
341
367
|
addMcpServer(
|
|
342
368
|
serverName: string,
|
|
343
369
|
url: string,
|
|
344
|
-
callbackHost
|
|
370
|
+
callbackHost?: string,
|
|
345
371
|
agentsPrefix?: string,
|
|
346
372
|
options?: {
|
|
347
373
|
client?: ConstructorParameters<typeof Client>[1];
|
|
348
|
-
transport?: {
|
|
349
|
-
headers: HeadersInit;
|
|
350
|
-
};
|
|
351
|
-
}
|
|
352
|
-
): Promise<{
|
|
353
|
-
id: string;
|
|
354
|
-
authUrl: string | undefined;
|
|
355
|
-
}>;
|
|
356
|
-
_connectToMcpServerInternal(
|
|
357
|
-
_serverName: string,
|
|
358
|
-
url: string,
|
|
359
|
-
callbackUrl: string,
|
|
360
|
-
options?: {
|
|
361
|
-
client?: ConstructorParameters<typeof Client>[1];
|
|
362
|
-
/**
|
|
363
|
-
* We don't expose the normal set of transport options because:
|
|
364
|
-
* 1) we can't serialize things like the auth provider or a fetch function into the DB for reconnection purposes
|
|
365
|
-
* 2) We probably want these options to be agnostic to the transport type (SSE vs Streamable)
|
|
366
|
-
*
|
|
367
|
-
* 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).
|
|
368
|
-
*/
|
|
369
374
|
transport?: {
|
|
370
375
|
headers?: HeadersInit;
|
|
376
|
+
type?: TransportType;
|
|
371
377
|
};
|
|
372
|
-
},
|
|
373
|
-
reconnect?: {
|
|
374
|
-
id: string;
|
|
375
|
-
oauthClientId?: string;
|
|
376
378
|
}
|
|
377
|
-
): Promise<
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
379
|
+
): Promise<
|
|
380
|
+
| {
|
|
381
|
+
id: string;
|
|
382
|
+
state: typeof MCPConnectionState.AUTHENTICATING;
|
|
383
|
+
authUrl: string;
|
|
384
|
+
}
|
|
385
|
+
| {
|
|
386
|
+
id: string;
|
|
387
|
+
state: typeof MCPConnectionState.READY;
|
|
388
|
+
authUrl?: undefined;
|
|
389
|
+
}
|
|
390
|
+
>;
|
|
382
391
|
removeMcpServer(id: string): Promise<void>;
|
|
383
392
|
getMcpServers(): MCPServersState;
|
|
393
|
+
private broadcastMcpServers;
|
|
394
|
+
/**
|
|
395
|
+
* Handle MCP OAuth callback request if it's an OAuth callback.
|
|
396
|
+
*
|
|
397
|
+
* This method encapsulates the entire OAuth callback flow:
|
|
398
|
+
* 1. Checks if the request is an MCP OAuth callback
|
|
399
|
+
* 2. Processes the OAuth code exchange
|
|
400
|
+
* 3. Establishes the connection if successful
|
|
401
|
+
* 4. Broadcasts MCP server state updates
|
|
402
|
+
* 5. Returns the appropriate HTTP response
|
|
403
|
+
*
|
|
404
|
+
* @param request The incoming HTTP request
|
|
405
|
+
* @returns Response if this was an OAuth callback, null otherwise
|
|
406
|
+
*/
|
|
407
|
+
private handleMcpOAuthCallback;
|
|
408
|
+
/**
|
|
409
|
+
* Handle OAuth callback response using MCPClientManager configuration
|
|
410
|
+
* @param result OAuth callback result
|
|
411
|
+
* @param request The original request (needed for base URL)
|
|
412
|
+
* @returns Response for the OAuth callback
|
|
413
|
+
*/
|
|
414
|
+
private handleOAuthCallbackResponse;
|
|
384
415
|
}
|
|
385
416
|
/**
|
|
386
417
|
* Namespace for creating Agent instances
|
|
@@ -413,17 +444,72 @@ declare function routeAgentRequest<Env>(
|
|
|
413
444
|
env: Env,
|
|
414
445
|
options?: AgentOptions<Env>
|
|
415
446
|
): Promise<Response | null>;
|
|
447
|
+
type EmailResolver<Env> = (
|
|
448
|
+
email: ForwardableEmailMessage,
|
|
449
|
+
env: Env
|
|
450
|
+
) => Promise<{
|
|
451
|
+
agentName: string;
|
|
452
|
+
agentId: string;
|
|
453
|
+
} | null>;
|
|
454
|
+
/**
|
|
455
|
+
* Create a resolver that uses the message-id header to determine the agent to route the email to
|
|
456
|
+
* @returns A function that resolves the agent to route the email to
|
|
457
|
+
*/
|
|
458
|
+
declare function createHeaderBasedEmailResolver<Env>(): EmailResolver<Env>;
|
|
459
|
+
/**
|
|
460
|
+
* Create a resolver that uses the email address to determine the agent to route the email to
|
|
461
|
+
* @param defaultAgentName The default agent name to use if the email address does not contain a sub-address
|
|
462
|
+
* @returns A function that resolves the agent to route the email to
|
|
463
|
+
*/
|
|
464
|
+
declare function createAddressBasedEmailResolver<Env>(
|
|
465
|
+
defaultAgentName: string
|
|
466
|
+
): EmailResolver<Env>;
|
|
467
|
+
/**
|
|
468
|
+
* Create a resolver that uses the agentName and agentId to determine the agent to route the email to
|
|
469
|
+
* @param agentName The name of the agent to route the email to
|
|
470
|
+
* @param agentId The id of the agent to route the email to
|
|
471
|
+
* @returns A function that resolves the agent to route the email to
|
|
472
|
+
*/
|
|
473
|
+
declare function createCatchAllEmailResolver<Env>(
|
|
474
|
+
agentName: string,
|
|
475
|
+
agentId: string
|
|
476
|
+
): EmailResolver<Env>;
|
|
477
|
+
type EmailRoutingOptions<Env> = AgentOptions<Env> & {
|
|
478
|
+
resolver: EmailResolver<Env>;
|
|
479
|
+
};
|
|
416
480
|
/**
|
|
417
481
|
* Route an email to the appropriate Agent
|
|
418
|
-
* @param email
|
|
419
|
-
* @param env
|
|
420
|
-
* @param options
|
|
482
|
+
* @param email The email to route
|
|
483
|
+
* @param env The environment containing the Agent bindings
|
|
484
|
+
* @param options The options for routing the email
|
|
485
|
+
* @returns A promise that resolves when the email has been routed
|
|
421
486
|
*/
|
|
422
487
|
declare function routeAgentEmail<Env>(
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
488
|
+
email: ForwardableEmailMessage,
|
|
489
|
+
env: Env,
|
|
490
|
+
options: EmailRoutingOptions<Env>
|
|
426
491
|
): Promise<void>;
|
|
492
|
+
type AgentEmail = {
|
|
493
|
+
from: string;
|
|
494
|
+
to: string;
|
|
495
|
+
getRaw: () => Promise<Uint8Array>;
|
|
496
|
+
headers: Headers;
|
|
497
|
+
rawSize: number;
|
|
498
|
+
setReject: (reason: string) => void;
|
|
499
|
+
forward: (rcptTo: string, headers?: Headers) => Promise<void>;
|
|
500
|
+
reply: (options: { from: string; to: string; raw: string }) => Promise<void>;
|
|
501
|
+
};
|
|
502
|
+
type EmailSendOptions = {
|
|
503
|
+
to: string;
|
|
504
|
+
subject: string;
|
|
505
|
+
body: string;
|
|
506
|
+
contentType?: string;
|
|
507
|
+
headers?: Record<string, string>;
|
|
508
|
+
includeRoutingHeaders?: boolean;
|
|
509
|
+
agentName?: string;
|
|
510
|
+
agentId?: string;
|
|
511
|
+
domain?: string;
|
|
512
|
+
};
|
|
427
513
|
/**
|
|
428
514
|
* Get or create an Agent by name
|
|
429
515
|
* @template Env Environment type containing bindings
|
|
@@ -433,12 +519,17 @@ declare function routeAgentEmail<Env>(
|
|
|
433
519
|
* @param options Options for Agent creation
|
|
434
520
|
* @returns Promise resolving to an Agent instance stub
|
|
435
521
|
*/
|
|
436
|
-
declare function getAgentByName<
|
|
522
|
+
declare function getAgentByName<
|
|
523
|
+
Env,
|
|
524
|
+
T extends Agent<Env>,
|
|
525
|
+
Props extends Record<string, unknown> = Record<string, unknown>
|
|
526
|
+
>(
|
|
437
527
|
namespace: AgentNamespace<T>,
|
|
438
528
|
name: string,
|
|
439
529
|
options?: {
|
|
440
530
|
jurisdiction?: DurableObjectJurisdiction;
|
|
441
531
|
locationHint?: DurableObjectLocationHint;
|
|
532
|
+
props?: Props;
|
|
442
533
|
}
|
|
443
534
|
): Promise<DurableObjectStub<T>>;
|
|
444
535
|
/**
|
|
@@ -460,27 +551,37 @@ declare class StreamingResponse {
|
|
|
460
551
|
*/
|
|
461
552
|
end(finalChunk?: unknown): void;
|
|
462
553
|
}
|
|
463
|
-
|
|
554
|
+
//#endregion
|
|
464
555
|
export {
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
556
|
+
unstable_callable as A,
|
|
557
|
+
createAddressBasedEmailResolver as C,
|
|
558
|
+
getCurrentAgent as D,
|
|
559
|
+
getAgentByName as E,
|
|
560
|
+
routeAgentEmail as O,
|
|
561
|
+
callable as S,
|
|
562
|
+
createHeaderBasedEmailResolver as T,
|
|
563
|
+
RPCResponse as _,
|
|
564
|
+
AgentOptions as a,
|
|
565
|
+
StreamingResponse as b,
|
|
566
|
+
ConnectionContext as c,
|
|
567
|
+
EmailSendOptions as d,
|
|
568
|
+
MCPServer as f,
|
|
569
|
+
RPCRequest as g,
|
|
570
|
+
QueueItem as h,
|
|
571
|
+
AgentNamespace as i,
|
|
572
|
+
routeAgentRequest as k,
|
|
573
|
+
EmailResolver as l,
|
|
574
|
+
MCPServersState as m,
|
|
575
|
+
AgentContext as n,
|
|
576
|
+
CallableMetadata as o,
|
|
577
|
+
MCPServerMessage as p,
|
|
578
|
+
AgentEmail as r,
|
|
579
|
+
Connection$1 as s,
|
|
580
|
+
Agent as t,
|
|
581
|
+
EmailRoutingOptions as u,
|
|
582
|
+
Schedule as v,
|
|
583
|
+
createCatchAllEmailResolver as w,
|
|
584
|
+
WSMessage as x,
|
|
585
|
+
StateUpdateMessage as y
|
|
486
586
|
};
|
|
587
|
+
//# sourceMappingURL=index-Bx5KK3VJ.d.ts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,31 +1,70 @@
|
|
|
1
|
-
import "
|
|
2
|
-
import "
|
|
3
|
-
|
|
4
|
-
import "./
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import { h as TransportType } from "./client-CsaP9Irq.js";
|
|
2
|
+
import "./mcp-BwPscEiF.js";
|
|
3
|
+
import "./do-oauth-client-provider-C2CHH5x-.js";
|
|
4
|
+
import "./index-BUle9RiP.js";
|
|
5
|
+
import "./ai-types-81H_-Uxh.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,
|
|
11
19
|
f as MCPServer,
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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-Bx5KK3VJ.js";
|
|
38
|
+
export {
|
|
39
|
+
Agent,
|
|
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,
|
|
58
|
+
StreamingResponse,
|
|
59
|
+
TransportType,
|
|
60
|
+
WSMessage,
|
|
61
|
+
callable,
|
|
62
|
+
createAddressBasedEmailResolver,
|
|
63
|
+
createCatchAllEmailResolver,
|
|
64
|
+
createHeaderBasedEmailResolver,
|
|
65
|
+
getAgentByName,
|
|
66
|
+
getCurrentAgent,
|
|
67
|
+
routeAgentEmail,
|
|
68
|
+
routeAgentRequest,
|
|
69
|
+
unstable_callable
|
|
70
|
+
};
|
package/dist/index.js
CHANGED
|
@@ -1,22 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
unstable_callable
|
|
9
|
-
} from "./chunk-LU2RSO54.js";
|
|
10
|
-
import "./chunk-4RBEYCWK.js";
|
|
11
|
-
import "./chunk-PVQZBKN7.js";
|
|
12
|
-
import "./chunk-KUH345EY.js";
|
|
13
|
-
export {
|
|
14
|
-
Agent,
|
|
15
|
-
StreamingResponse,
|
|
16
|
-
getAgentByName,
|
|
17
|
-
getCurrentAgent,
|
|
18
|
-
routeAgentEmail,
|
|
19
|
-
routeAgentRequest,
|
|
20
|
-
unstable_callable
|
|
21
|
-
};
|
|
22
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
import "./ai-types-CrMqkwc_.js";
|
|
2
|
+
import "./client-B3SR12TQ.js";
|
|
3
|
+
import "./client-BZq9qau2.js";
|
|
4
|
+
import "./do-oauth-client-provider-CwqK5SXm.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-D_KKH_4c.js";
|
|
6
|
+
|
|
7
|
+
export { Agent, StreamingResponse, callable, createAddressBasedEmailResolver, createCatchAllEmailResolver, createHeaderBasedEmailResolver, getAgentByName, getCurrentAgent, routeAgentEmail, routeAgentRequest, unstable_callable };
|