agents 0.0.0-569680f → 0.0.0-569e184
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 +257 -27
- package/dist/ai-chat-agent.d.ts +104 -20
- package/dist/ai-chat-agent.js +812 -260
- package/dist/ai-chat-agent.js.map +1 -1
- package/dist/ai-chat-v5-migration-DguhuLKF.js +155 -0
- package/dist/ai-chat-v5-migration-DguhuLKF.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 +79 -85
- package/dist/ai-react.js +411 -199
- package/dist/ai-react.js.map +1 -1
- package/dist/ai-types-CwgHzwUb.js +24 -0
- package/dist/ai-types-CwgHzwUb.js.map +1 -0
- package/dist/ai-types-D_hTbf25.d.ts +103 -0
- package/dist/ai-types.d.ts +6 -74
- package/dist/ai-types.js +3 -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-CcyhkGfN.js +117 -0
- package/dist/client-CcyhkGfN.js.map +1 -0
- package/dist/client-ClORm6f0.d.ts +104 -0
- 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 +12 -93
- package/dist/client.js +4 -11
- package/dist/codemode/ai.d.ts +27 -0
- package/dist/codemode/ai.js +152 -0
- package/dist/codemode/ai.js.map +1 -0
- 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-B-ryFIPr.d.ts +70 -0
- package/dist/do-oauth-client-provider-B1fVIshX.js +155 -0
- package/dist/do-oauth-client-provider-B1fVIshX.js.map +1 -0
- package/dist/index-CyDpAVHZ.d.ts +58 -0
- package/dist/{index-aBwVVXj7.d.ts → index-DPJ32qQn.d.ts} +219 -171
- package/dist/index.d.ts +69 -37
- package/dist/index.js +8 -30
- 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 +191 -81
- package/dist/mcp/index.js +1457 -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-CzbSsLfc.d.ts +61 -0
- package/dist/observability/index.d.ts +3 -12
- package/dist/observability/index.js +8 -10
- package/dist/react-DTzwSLAh.d.ts +137 -0
- package/dist/react.d.ts +15 -119
- package/dist/react.js +190 -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-C4GLimgv.d.ts +39 -0
- package/dist/serializable.d.ts +7 -32
- package/dist/serializable.js +1 -1
- package/dist/src-BmbDclOA.js +1181 -0
- package/dist/src-BmbDclOA.js.map +1 -0
- package/package.json +79 -30
- package/dist/ai-types.js.map +0 -1
- package/dist/chunk-767EASBA.js +0 -106
- package/dist/chunk-767EASBA.js.map +0 -1
- package/dist/chunk-NKZZ66QY.js +0 -116
- package/dist/chunk-NKZZ66QY.js.map +0 -1
- package/dist/chunk-RX76B6DL.js +0 -1025
- package/dist/chunk-RX76B6DL.js.map +0 -1
- package/dist/chunk-TN7QOY4S.js +0 -469
- package/dist/chunk-TN7QOY4S.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 -1538
|
@@ -1,87 +1,29 @@
|
|
|
1
|
+
import { n as AgentEmail } from "./context-_sPQqJWv.js";
|
|
2
|
+
import {
|
|
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";
|
|
9
|
+
import {
|
|
10
|
+
Connection,
|
|
11
|
+
Connection as Connection$1,
|
|
12
|
+
ConnectionContext,
|
|
13
|
+
PartyServerOptions,
|
|
14
|
+
Server,
|
|
15
|
+
WSMessage
|
|
16
|
+
} from "partyserver";
|
|
1
17
|
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
2
18
|
import {
|
|
3
|
-
ServerCapabilities,
|
|
4
|
-
Tool,
|
|
5
19
|
Prompt,
|
|
6
20
|
Resource,
|
|
21
|
+
ServerCapabilities,
|
|
22
|
+
Tool
|
|
7
23
|
} from "@modelcontextprotocol/sdk/types.js";
|
|
8
|
-
import {
|
|
9
|
-
import { MCPClientManager } from "./mcp/client.js";
|
|
10
|
-
import { Message } from "ai";
|
|
24
|
+
import { env } from "cloudflare:workers";
|
|
11
25
|
|
|
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;
|
|
26
|
+
//#region src/index.d.ts
|
|
85
27
|
|
|
86
28
|
/**
|
|
87
29
|
* RPC request message from client
|
|
@@ -96,14 +38,14 @@ type RPCRequest = {
|
|
|
96
38
|
* State update message from client
|
|
97
39
|
*/
|
|
98
40
|
type StateUpdateMessage = {
|
|
99
|
-
type:
|
|
41
|
+
type: MessageType.CF_AGENT_STATE;
|
|
100
42
|
state: unknown;
|
|
101
43
|
};
|
|
102
44
|
/**
|
|
103
45
|
* RPC response message to client
|
|
104
46
|
*/
|
|
105
47
|
type RPCResponse = {
|
|
106
|
-
type:
|
|
48
|
+
type: MessageType.RPC;
|
|
107
49
|
id: string;
|
|
108
50
|
} & (
|
|
109
51
|
| {
|
|
@@ -134,12 +76,24 @@ type CallableMetadata = {
|
|
|
134
76
|
* Decorator that marks a method as callable by clients
|
|
135
77
|
* @param metadata Optional metadata about the callable method
|
|
136
78
|
*/
|
|
137
|
-
declare function
|
|
79
|
+
declare function callable(
|
|
138
80
|
metadata?: CallableMetadata
|
|
139
81
|
): <This, Args extends unknown[], Return>(
|
|
140
82
|
target: (this: This, ...args: Args) => Return,
|
|
141
83
|
context: ClassMethodDecoratorContext
|
|
142
84
|
) => (this: This, ...args: Args) => Return;
|
|
85
|
+
/**
|
|
86
|
+
* Decorator that marks a method as callable by clients
|
|
87
|
+
* @deprecated this has been renamed to callable, and unstable_callable will be removed in the next major version
|
|
88
|
+
* @param metadata Optional metadata about the callable method
|
|
89
|
+
*/
|
|
90
|
+
declare const unstable_callable: (metadata?: CallableMetadata) => void;
|
|
91
|
+
type QueueItem<T = string> = {
|
|
92
|
+
id: string;
|
|
93
|
+
payload: T;
|
|
94
|
+
callback: keyof Agent<unknown>;
|
|
95
|
+
created_at: number;
|
|
96
|
+
};
|
|
143
97
|
/**
|
|
144
98
|
* Represents a scheduled task within an Agent
|
|
145
99
|
* @template T Type of the payload data
|
|
@@ -179,41 +133,54 @@ type Schedule<T = string> = {
|
|
|
179
133
|
* MCP Server state update message from server -> Client
|
|
180
134
|
*/
|
|
181
135
|
type MCPServerMessage = {
|
|
182
|
-
type:
|
|
136
|
+
type: MessageType.CF_AGENT_MCP_SERVERS;
|
|
183
137
|
mcp: MCPServersState;
|
|
184
138
|
};
|
|
185
139
|
type MCPServersState = {
|
|
186
140
|
servers: {
|
|
187
141
|
[id: string]: MCPServer;
|
|
188
142
|
};
|
|
189
|
-
tools: Tool
|
|
190
|
-
|
|
191
|
-
|
|
143
|
+
tools: (Tool & {
|
|
144
|
+
serverId: string;
|
|
145
|
+
})[];
|
|
146
|
+
prompts: (Prompt & {
|
|
147
|
+
serverId: string;
|
|
148
|
+
})[];
|
|
149
|
+
resources: (Resource & {
|
|
150
|
+
serverId: string;
|
|
151
|
+
})[];
|
|
192
152
|
};
|
|
193
153
|
type MCPServer = {
|
|
194
154
|
name: string;
|
|
195
155
|
server_url: string;
|
|
196
156
|
auth_url: string | null;
|
|
197
|
-
state:
|
|
157
|
+
state: MCPConnectionState;
|
|
198
158
|
instructions: string | null;
|
|
199
159
|
capabilities: ServerCapabilities | null;
|
|
200
160
|
};
|
|
201
161
|
declare function getCurrentAgent<
|
|
202
|
-
T extends Agent<unknown, unknown> = Agent<unknown, unknown
|
|
162
|
+
T extends Agent<unknown, unknown> = Agent<unknown, unknown>
|
|
203
163
|
>(): {
|
|
204
164
|
agent: T | undefined;
|
|
205
165
|
connection: Connection | undefined;
|
|
206
|
-
request: Request
|
|
166
|
+
request: Request | undefined;
|
|
167
|
+
email: AgentEmail | undefined;
|
|
207
168
|
};
|
|
208
169
|
/**
|
|
209
170
|
* Base class for creating Agent implementations
|
|
210
171
|
* @template Env Environment type containing bindings
|
|
211
172
|
* @template State State type to store within the Agent
|
|
212
173
|
*/
|
|
213
|
-
declare class Agent<
|
|
174
|
+
declare class Agent<
|
|
175
|
+
Env = typeof env,
|
|
176
|
+
State = unknown,
|
|
177
|
+
Props extends Record<string, unknown> = Record<string, unknown>
|
|
178
|
+
> extends Server<Env, Props> {
|
|
214
179
|
private _state;
|
|
180
|
+
private _disposables;
|
|
181
|
+
private _destroyed;
|
|
215
182
|
private _ParentClass;
|
|
216
|
-
mcp: MCPClientManager;
|
|
183
|
+
readonly mcp: MCPClientManager;
|
|
217
184
|
/**
|
|
218
185
|
* Initial state for the Agent
|
|
219
186
|
* Override to provide default state values
|
|
@@ -259,24 +226,75 @@ declare class Agent<Env, State = unknown> extends Server<Env> {
|
|
|
259
226
|
*/
|
|
260
227
|
onStateUpdate(state: State | undefined, source: Connection | "server"): void;
|
|
261
228
|
/**
|
|
262
|
-
* Called when the Agent receives an email
|
|
229
|
+
* Called when the Agent receives an email via routeAgentEmail()
|
|
263
230
|
* Override this method to handle incoming emails
|
|
264
231
|
* @param email Email message to process
|
|
265
232
|
*/
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
233
|
+
_onEmail(email: AgentEmail): Promise<void>;
|
|
234
|
+
/**
|
|
235
|
+
* Reply to an email
|
|
236
|
+
* @param email The email to reply to
|
|
237
|
+
* @param options Options for the reply
|
|
238
|
+
* @returns void
|
|
239
|
+
*/
|
|
240
|
+
replyToEmail(
|
|
241
|
+
email: AgentEmail,
|
|
242
|
+
options: {
|
|
243
|
+
fromName: string;
|
|
244
|
+
subject?: string | undefined;
|
|
245
|
+
body: string;
|
|
246
|
+
contentType?: string;
|
|
247
|
+
headers?: Record<string, string>;
|
|
248
|
+
}
|
|
272
249
|
): Promise<void>;
|
|
273
250
|
private _tryCatch;
|
|
251
|
+
/**
|
|
252
|
+
* Automatically wrap custom methods with agent context
|
|
253
|
+
* This ensures getCurrentAgent() works in all custom methods without decorators
|
|
254
|
+
*/
|
|
255
|
+
private _autoWrapCustomMethods;
|
|
274
256
|
onError(connection: Connection, error: unknown): void | Promise<void>;
|
|
275
257
|
onError(error: unknown): void | Promise<void>;
|
|
276
258
|
/**
|
|
277
259
|
* Render content (not implemented in base class)
|
|
278
260
|
*/
|
|
279
261
|
render(): void;
|
|
262
|
+
/**
|
|
263
|
+
* Queue a task to be executed in the future
|
|
264
|
+
* @param payload Payload to pass to the callback
|
|
265
|
+
* @param callback Name of the method to call
|
|
266
|
+
* @returns The ID of the queued task
|
|
267
|
+
*/
|
|
268
|
+
queue<T = unknown>(callback: keyof this, payload: T): Promise<string>;
|
|
269
|
+
private _flushingQueue;
|
|
270
|
+
private _flushQueue;
|
|
271
|
+
/**
|
|
272
|
+
* Dequeue a task by ID
|
|
273
|
+
* @param id ID of the task to dequeue
|
|
274
|
+
*/
|
|
275
|
+
dequeue(id: string): Promise<void>;
|
|
276
|
+
/**
|
|
277
|
+
* Dequeue all tasks
|
|
278
|
+
*/
|
|
279
|
+
dequeueAll(): Promise<void>;
|
|
280
|
+
/**
|
|
281
|
+
* Dequeue all tasks by callback
|
|
282
|
+
* @param callback Name of the callback to dequeue
|
|
283
|
+
*/
|
|
284
|
+
dequeueAllByCallback(callback: string): Promise<void>;
|
|
285
|
+
/**
|
|
286
|
+
* Get a queued task by ID
|
|
287
|
+
* @param id ID of the task to get
|
|
288
|
+
* @returns The task or undefined if not found
|
|
289
|
+
*/
|
|
290
|
+
getQueue(id: string): Promise<QueueItem<string> | undefined>;
|
|
291
|
+
/**
|
|
292
|
+
* Get all queues by key and value
|
|
293
|
+
* @param key Key to filter by
|
|
294
|
+
* @param value Value to filter by
|
|
295
|
+
* @returns Array of matching QueueItem objects
|
|
296
|
+
*/
|
|
297
|
+
getQueues(key: string, value: string): Promise<QueueItem<string>[]>;
|
|
280
298
|
/**
|
|
281
299
|
* Schedule a task to be executed in the future
|
|
282
300
|
* @template T Type of the payload data
|
|
@@ -314,7 +332,7 @@ declare class Agent<Env, State = unknown> extends Server<Env> {
|
|
|
314
332
|
/**
|
|
315
333
|
* Cancel a scheduled task
|
|
316
334
|
* @param id ID of the task to cancel
|
|
317
|
-
* @returns true if the task was cancelled, false
|
|
335
|
+
* @returns true if the task was cancelled, false if the task was not found
|
|
318
336
|
*/
|
|
319
337
|
cancelSchedule(id: string): Promise<boolean>;
|
|
320
338
|
private _scheduleNextAlarm;
|
|
@@ -339,55 +357,62 @@ declare class Agent<Env, State = unknown> extends Server<Env> {
|
|
|
339
357
|
/**
|
|
340
358
|
* Connect to a new MCP Server
|
|
341
359
|
*
|
|
360
|
+
* @param serverName Name of the MCP server
|
|
342
361
|
* @param url MCP Server SSE URL
|
|
343
|
-
* @param callbackHost Base host for the agent, used for the redirect URI.
|
|
362
|
+
* @param callbackHost Base host for the agent, used for the redirect URI. If not provided, will be derived from the current request.
|
|
344
363
|
* @param agentsPrefix agents routing prefix if not using `agents`
|
|
345
|
-
* @param options MCP client and transport
|
|
346
|
-
* @returns authUrl
|
|
364
|
+
* @param options MCP client and transport options
|
|
365
|
+
* @returns Server id and state - either "authenticating" with authUrl, or "ready"
|
|
366
|
+
* @throws If connection or discovery fails
|
|
347
367
|
*/
|
|
348
368
|
addMcpServer(
|
|
349
369
|
serverName: string,
|
|
350
370
|
url: string,
|
|
351
|
-
callbackHost
|
|
371
|
+
callbackHost?: string,
|
|
352
372
|
agentsPrefix?: string,
|
|
353
373
|
options?: {
|
|
354
374
|
client?: ConstructorParameters<typeof Client>[1];
|
|
355
|
-
transport?: {
|
|
356
|
-
headers: HeadersInit;
|
|
357
|
-
};
|
|
358
|
-
}
|
|
359
|
-
): Promise<{
|
|
360
|
-
id: string;
|
|
361
|
-
authUrl: string | undefined;
|
|
362
|
-
}>;
|
|
363
|
-
_connectToMcpServerInternal(
|
|
364
|
-
_serverName: string,
|
|
365
|
-
url: string,
|
|
366
|
-
callbackUrl: string,
|
|
367
|
-
options?: {
|
|
368
|
-
client?: ConstructorParameters<typeof Client>[1];
|
|
369
|
-
/**
|
|
370
|
-
* We don't expose the normal set of transport options because:
|
|
371
|
-
* 1) we can't serialize things like the auth provider or a fetch function into the DB for reconnection purposes
|
|
372
|
-
* 2) We probably want these options to be agnostic to the transport type (SSE vs Streamable)
|
|
373
|
-
*
|
|
374
|
-
* 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).
|
|
375
|
-
*/
|
|
376
375
|
transport?: {
|
|
377
376
|
headers?: HeadersInit;
|
|
377
|
+
type?: TransportType;
|
|
378
378
|
};
|
|
379
|
-
},
|
|
380
|
-
reconnect?: {
|
|
381
|
-
id: string;
|
|
382
|
-
oauthClientId?: string;
|
|
383
379
|
}
|
|
384
|
-
): Promise<
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
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
|
+
>;
|
|
389
392
|
removeMcpServer(id: string): Promise<void>;
|
|
390
393
|
getMcpServers(): MCPServersState;
|
|
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;
|
|
409
|
+
/**
|
|
410
|
+
* Handle OAuth callback response using MCPClientManager configuration
|
|
411
|
+
* @param result OAuth callback result
|
|
412
|
+
* @param request The original request (needed for base URL)
|
|
413
|
+
* @returns Response for the OAuth callback
|
|
414
|
+
*/
|
|
415
|
+
private handleOAuthCallbackResponse;
|
|
391
416
|
}
|
|
392
417
|
/**
|
|
393
418
|
* Namespace for creating Agent instances
|
|
@@ -427,17 +452,39 @@ type EmailResolver<Env> = (
|
|
|
427
452
|
agentName: string;
|
|
428
453
|
agentId: string;
|
|
429
454
|
} | null>;
|
|
430
|
-
|
|
431
|
-
|
|
455
|
+
/**
|
|
456
|
+
* Create a resolver that uses the message-id header to determine the agent to route the email to
|
|
457
|
+
* @returns A function that resolves the agent to route the email to
|
|
458
|
+
*/
|
|
459
|
+
declare function createHeaderBasedEmailResolver<Env>(): EmailResolver<Env>;
|
|
460
|
+
/**
|
|
461
|
+
* Create a resolver that uses the email address to determine the agent to route the email to
|
|
462
|
+
* @param defaultAgentName The default agent name to use if the email address does not contain a sub-address
|
|
463
|
+
* @returns A function that resolves the agent to route the email to
|
|
464
|
+
*/
|
|
465
|
+
declare function createAddressBasedEmailResolver<Env>(
|
|
432
466
|
defaultAgentName: string
|
|
433
467
|
): EmailResolver<Env>;
|
|
434
|
-
|
|
468
|
+
/**
|
|
469
|
+
* Create a resolver that uses the agentName and agentId to determine the agent to route the email to
|
|
470
|
+
* @param agentName The name of the agent to route the email to
|
|
471
|
+
* @param agentId The id of the agent to route the email to
|
|
472
|
+
* @returns A function that resolves the agent to route the email to
|
|
473
|
+
*/
|
|
474
|
+
declare function createCatchAllEmailResolver<Env>(
|
|
435
475
|
agentName: string,
|
|
436
476
|
agentId: string
|
|
437
477
|
): EmailResolver<Env>;
|
|
438
478
|
type EmailRoutingOptions<Env> = AgentOptions<Env> & {
|
|
439
479
|
resolver: EmailResolver<Env>;
|
|
440
480
|
};
|
|
481
|
+
/**
|
|
482
|
+
* Route an email to the appropriate Agent
|
|
483
|
+
* @param email The email to route
|
|
484
|
+
* @param env The environment containing the Agent bindings
|
|
485
|
+
* @param options The options for routing the email
|
|
486
|
+
* @returns A promise that resolves when the email has been routed
|
|
487
|
+
*/
|
|
441
488
|
declare function routeAgentEmail<Env>(
|
|
442
489
|
email: ForwardableEmailMessage,
|
|
443
490
|
env: Env,
|
|
@@ -454,12 +501,6 @@ type EmailSendOptions = {
|
|
|
454
501
|
agentId?: string;
|
|
455
502
|
domain?: string;
|
|
456
503
|
};
|
|
457
|
-
declare function sendEmailWithRouting(
|
|
458
|
-
emailBinding: SendEmail,
|
|
459
|
-
from: string,
|
|
460
|
-
fromName: string,
|
|
461
|
-
options: EmailSendOptions
|
|
462
|
-
): Promise<void>;
|
|
463
504
|
/**
|
|
464
505
|
* Get or create an Agent by name
|
|
465
506
|
* @template Env Environment type containing bindings
|
|
@@ -469,12 +510,17 @@ declare function sendEmailWithRouting(
|
|
|
469
510
|
* @param options Options for Agent creation
|
|
470
511
|
* @returns Promise resolving to an Agent instance stub
|
|
471
512
|
*/
|
|
472
|
-
declare function getAgentByName<
|
|
513
|
+
declare function getAgentByName<
|
|
514
|
+
Env,
|
|
515
|
+
T extends Agent<Env>,
|
|
516
|
+
Props extends Record<string, unknown> = Record<string, unknown>
|
|
517
|
+
>(
|
|
473
518
|
namespace: AgentNamespace<T>,
|
|
474
519
|
name: string,
|
|
475
520
|
options?: {
|
|
476
521
|
jurisdiction?: DurableObjectJurisdiction;
|
|
477
522
|
locationHint?: DurableObjectLocationHint;
|
|
523
|
+
props?: Props;
|
|
478
524
|
}
|
|
479
525
|
): Promise<DurableObjectStub<T>>;
|
|
480
526
|
/**
|
|
@@ -496,34 +542,36 @@ declare class StreamingResponse {
|
|
|
496
542
|
*/
|
|
497
543
|
end(finalChunk?: unknown): void;
|
|
498
544
|
}
|
|
499
|
-
|
|
545
|
+
//#endregion
|
|
500
546
|
export {
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
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,
|
|
565
|
+
AgentContext as n,
|
|
566
|
+
Connection$1 as o,
|
|
567
|
+
MCPServersState as p,
|
|
568
|
+
AgentNamespace as r,
|
|
569
|
+
ConnectionContext as s,
|
|
570
|
+
Agent as t,
|
|
571
|
+
EmailSendOptions as u,
|
|
572
|
+
StateUpdateMessage as v,
|
|
573
|
+
createHeaderBasedEmailResolver as w,
|
|
574
|
+
callable as x,
|
|
575
|
+
StreamingResponse as y
|
|
529
576
|
};
|
|
577
|
+
//# sourceMappingURL=index-DPJ32qQn.d.ts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,38 +1,70 @@
|
|
|
1
|
-
import "
|
|
2
|
-
import "
|
|
3
|
-
|
|
4
|
-
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";
|
|
7
|
+
import {
|
|
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
|
+
n as AgentContext,
|
|
27
|
+
o as Connection,
|
|
28
|
+
p as MCPServersState,
|
|
29
|
+
r as AgentNamespace,
|
|
30
|
+
s as ConnectionContext,
|
|
31
|
+
t as Agent,
|
|
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";
|
|
5
38
|
export {
|
|
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
|
-
import "@modelcontextprotocol/sdk/shared/auth.js";
|
|
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,30 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
routeAgentEmail,
|
|
10
|
-
routeAgentRequest,
|
|
11
|
-
sendEmailWithRouting,
|
|
12
|
-
unstable_callable
|
|
13
|
-
} from "./chunk-RX76B6DL.js";
|
|
14
|
-
import "./chunk-TN7QOY4S.js";
|
|
15
|
-
import "./chunk-767EASBA.js";
|
|
16
|
-
import "./chunk-NKZZ66QY.js";
|
|
17
|
-
export {
|
|
18
|
-
Agent,
|
|
19
|
-
StreamingResponse,
|
|
20
|
-
createAddressBasedResolver,
|
|
21
|
-
createCatchAllResolver,
|
|
22
|
-
createHeaderBasedResolver,
|
|
23
|
-
getAgentByName,
|
|
24
|
-
getCurrentAgent,
|
|
25
|
-
routeAgentEmail,
|
|
26
|
-
routeAgentRequest,
|
|
27
|
-
sendEmailWithRouting,
|
|
28
|
-
unstable_callable
|
|
29
|
-
};
|
|
30
|
-
//# sourceMappingURL=index.js.map
|
|
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";
|
|
7
|
+
|
|
8
|
+
export { Agent, StreamingResponse, callable, createAddressBasedEmailResolver, createCatchAllEmailResolver, createHeaderBasedEmailResolver, getAgentByName, getCurrentAgent, routeAgentEmail, routeAgentRequest, unstable_callable };
|