agents 0.0.0-d40512c → 0.0.0-d4257c1
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 +234 -6
- package/dist/ai-chat-agent.d.ts +20 -18
- 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 -85
- package/dist/ai-react.js +260 -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-CITGJflw.d.ts → index-CkQU40oY.d.ts} +219 -147
- package/dist/index-W4JUkafc.d.ts +54 -0
- 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 +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 +73 -82
- package/dist/mcp/index.js +836 -772
- package/dist/mcp/index.js.map +1 -1
- 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 -12
- package/dist/observability/index.js +7 -10
- package/dist/react-B4e1rDid.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-gtr9YMhp.d.ts +34 -0
- package/dist/serializable.d.ts +7 -32
- package/dist/serializable.js +1 -1
- package/dist/src-COfG--3R.js +1179 -0
- package/dist/src-COfG--3R.js.map +1 -0
- package/package.json +45 -10
- package/src/index.ts +853 -187
- 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
|
@@ -1,87 +1,28 @@
|
|
|
1
|
+
import {
|
|
2
|
+
MCPClientManager,
|
|
3
|
+
MCPConnectionState,
|
|
4
|
+
TransportType
|
|
5
|
+
} from "./client-C-nwz-3N.js";
|
|
6
|
+
import { Observability } from "./index-W4JUkafc.js";
|
|
7
|
+
import { MessageType } from "./ai-types-BWW4umHY.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,7 +132,7 @@ 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 = {
|
|
@@ -194,7 +147,7 @@ type MCPServer = {
|
|
|
194
147
|
name: string;
|
|
195
148
|
server_url: string;
|
|
196
149
|
auth_url: string | null;
|
|
197
|
-
state:
|
|
150
|
+
state: MCPConnectionState;
|
|
198
151
|
instructions: string | null;
|
|
199
152
|
capabilities: ServerCapabilities | null;
|
|
200
153
|
};
|
|
@@ -203,17 +156,23 @@ declare function getCurrentAgent<
|
|
|
203
156
|
>(): {
|
|
204
157
|
agent: T | undefined;
|
|
205
158
|
connection: Connection | undefined;
|
|
206
|
-
request: Request
|
|
159
|
+
request: Request | undefined;
|
|
160
|
+
email: AgentEmail | undefined;
|
|
207
161
|
};
|
|
208
162
|
/**
|
|
209
163
|
* Base class for creating Agent implementations
|
|
210
164
|
* @template Env Environment type containing bindings
|
|
211
165
|
* @template State State type to store within the Agent
|
|
212
166
|
*/
|
|
213
|
-
declare class Agent<
|
|
167
|
+
declare class Agent<
|
|
168
|
+
Env = typeof env,
|
|
169
|
+
State = unknown,
|
|
170
|
+
Props extends Record<string, unknown> = Record<string, unknown>
|
|
171
|
+
> extends Server<Env, Props> {
|
|
214
172
|
private _state;
|
|
173
|
+
private _disposables;
|
|
215
174
|
private _ParentClass;
|
|
216
|
-
mcp: MCPClientManager;
|
|
175
|
+
readonly mcp: MCPClientManager;
|
|
217
176
|
/**
|
|
218
177
|
* Initial state for the Agent
|
|
219
178
|
* Override to provide default state values
|
|
@@ -259,17 +218,75 @@ declare class Agent<Env, State = unknown> extends Server<Env> {
|
|
|
259
218
|
*/
|
|
260
219
|
onStateUpdate(state: State | undefined, source: Connection | "server"): void;
|
|
261
220
|
/**
|
|
262
|
-
* Called when the Agent receives an email
|
|
221
|
+
* Called when the Agent receives an email via routeAgentEmail()
|
|
222
|
+
* Override this method to handle incoming emails
|
|
263
223
|
* @param email Email message to process
|
|
264
224
|
*/
|
|
265
|
-
|
|
225
|
+
_onEmail(email: AgentEmail): Promise<void>;
|
|
226
|
+
/**
|
|
227
|
+
* Reply to an email
|
|
228
|
+
* @param email The email to reply to
|
|
229
|
+
* @param options Options for the reply
|
|
230
|
+
* @returns void
|
|
231
|
+
*/
|
|
232
|
+
replyToEmail(
|
|
233
|
+
email: AgentEmail,
|
|
234
|
+
options: {
|
|
235
|
+
fromName: string;
|
|
236
|
+
subject?: string | undefined;
|
|
237
|
+
body: string;
|
|
238
|
+
contentType?: string;
|
|
239
|
+
headers?: Record<string, string>;
|
|
240
|
+
}
|
|
241
|
+
): Promise<void>;
|
|
266
242
|
private _tryCatch;
|
|
243
|
+
/**
|
|
244
|
+
* Automatically wrap custom methods with agent context
|
|
245
|
+
* This ensures getCurrentAgent() works in all custom methods without decorators
|
|
246
|
+
*/
|
|
247
|
+
private _autoWrapCustomMethods;
|
|
267
248
|
onError(connection: Connection, error: unknown): void | Promise<void>;
|
|
268
249
|
onError(error: unknown): void | Promise<void>;
|
|
269
250
|
/**
|
|
270
251
|
* Render content (not implemented in base class)
|
|
271
252
|
*/
|
|
272
253
|
render(): void;
|
|
254
|
+
/**
|
|
255
|
+
* Queue a task to be executed in the future
|
|
256
|
+
* @param payload Payload to pass to the callback
|
|
257
|
+
* @param callback Name of the method to call
|
|
258
|
+
* @returns The ID of the queued task
|
|
259
|
+
*/
|
|
260
|
+
queue<T = unknown>(callback: keyof this, payload: T): Promise<string>;
|
|
261
|
+
private _flushingQueue;
|
|
262
|
+
private _flushQueue;
|
|
263
|
+
/**
|
|
264
|
+
* Dequeue a task by ID
|
|
265
|
+
* @param id ID of the task to dequeue
|
|
266
|
+
*/
|
|
267
|
+
dequeue(id: string): Promise<void>;
|
|
268
|
+
/**
|
|
269
|
+
* Dequeue all tasks
|
|
270
|
+
*/
|
|
271
|
+
dequeueAll(): Promise<void>;
|
|
272
|
+
/**
|
|
273
|
+
* Dequeue all tasks by callback
|
|
274
|
+
* @param callback Name of the callback to dequeue
|
|
275
|
+
*/
|
|
276
|
+
dequeueAllByCallback(callback: string): Promise<void>;
|
|
277
|
+
/**
|
|
278
|
+
* Get a queued task by ID
|
|
279
|
+
* @param id ID of the task to get
|
|
280
|
+
* @returns The task or undefined if not found
|
|
281
|
+
*/
|
|
282
|
+
getQueue(id: string): Promise<QueueItem<string> | undefined>;
|
|
283
|
+
/**
|
|
284
|
+
* Get all queues by key and value
|
|
285
|
+
* @param key Key to filter by
|
|
286
|
+
* @param value Value to filter by
|
|
287
|
+
* @returns Array of matching QueueItem objects
|
|
288
|
+
*/
|
|
289
|
+
getQueues(key: string, value: string): Promise<QueueItem<string>[]>;
|
|
273
290
|
/**
|
|
274
291
|
* Schedule a task to be executed in the future
|
|
275
292
|
* @template T Type of the payload data
|
|
@@ -332,55 +349,40 @@ declare class Agent<Env, State = unknown> extends Server<Env> {
|
|
|
332
349
|
/**
|
|
333
350
|
* Connect to a new MCP Server
|
|
334
351
|
*
|
|
352
|
+
* @param serverName Name of the MCP server
|
|
335
353
|
* @param url MCP Server SSE URL
|
|
336
|
-
* @param callbackHost Base host for the agent, used for the redirect URI.
|
|
354
|
+
* @param callbackHost Base host for the agent, used for the redirect URI. If not provided, will be derived from the current request.
|
|
337
355
|
* @param agentsPrefix agents routing prefix if not using `agents`
|
|
338
|
-
* @param options MCP client and transport
|
|
356
|
+
* @param options MCP client and transport options
|
|
339
357
|
* @returns authUrl
|
|
340
358
|
*/
|
|
341
359
|
addMcpServer(
|
|
342
360
|
serverName: string,
|
|
343
361
|
url: string,
|
|
344
|
-
callbackHost
|
|
362
|
+
callbackHost?: string,
|
|
345
363
|
agentsPrefix?: string,
|
|
346
364
|
options?: {
|
|
347
365
|
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
366
|
transport?: {
|
|
370
367
|
headers?: HeadersInit;
|
|
368
|
+
type?: TransportType;
|
|
371
369
|
};
|
|
372
|
-
},
|
|
373
|
-
reconnect?: {
|
|
374
|
-
id: string;
|
|
375
|
-
oauthClientId?: string;
|
|
376
370
|
}
|
|
377
371
|
): Promise<{
|
|
378
372
|
id: string;
|
|
379
373
|
authUrl: string | undefined;
|
|
380
|
-
clientId: string | undefined;
|
|
381
374
|
}>;
|
|
375
|
+
private _connectToMcpServerInternal;
|
|
382
376
|
removeMcpServer(id: string): Promise<void>;
|
|
383
377
|
getMcpServers(): MCPServersState;
|
|
378
|
+
private broadcastMcpServers;
|
|
379
|
+
/**
|
|
380
|
+
* Handle OAuth callback response using MCPClientManager configuration
|
|
381
|
+
* @param result OAuth callback result
|
|
382
|
+
* @param request The original request (needed for base URL)
|
|
383
|
+
* @returns Response for the OAuth callback
|
|
384
|
+
*/
|
|
385
|
+
private handleOAuthCallbackResponse;
|
|
384
386
|
}
|
|
385
387
|
/**
|
|
386
388
|
* Namespace for creating Agent instances
|
|
@@ -413,17 +415,72 @@ declare function routeAgentRequest<Env>(
|
|
|
413
415
|
env: Env,
|
|
414
416
|
options?: AgentOptions<Env>
|
|
415
417
|
): Promise<Response | null>;
|
|
418
|
+
type EmailResolver<Env> = (
|
|
419
|
+
email: ForwardableEmailMessage,
|
|
420
|
+
env: Env
|
|
421
|
+
) => Promise<{
|
|
422
|
+
agentName: string;
|
|
423
|
+
agentId: string;
|
|
424
|
+
} | null>;
|
|
425
|
+
/**
|
|
426
|
+
* Create a resolver that uses the message-id header to determine the agent to route the email to
|
|
427
|
+
* @returns A function that resolves the agent to route the email to
|
|
428
|
+
*/
|
|
429
|
+
declare function createHeaderBasedEmailResolver<Env>(): EmailResolver<Env>;
|
|
430
|
+
/**
|
|
431
|
+
* Create a resolver that uses the email address to determine the agent to route the email to
|
|
432
|
+
* @param defaultAgentName The default agent name to use if the email address does not contain a sub-address
|
|
433
|
+
* @returns A function that resolves the agent to route the email to
|
|
434
|
+
*/
|
|
435
|
+
declare function createAddressBasedEmailResolver<Env>(
|
|
436
|
+
defaultAgentName: string
|
|
437
|
+
): EmailResolver<Env>;
|
|
438
|
+
/**
|
|
439
|
+
* Create a resolver that uses the agentName and agentId to determine the agent to route the email to
|
|
440
|
+
* @param agentName The name of the agent to route the email to
|
|
441
|
+
* @param agentId The id of the agent to route the email to
|
|
442
|
+
* @returns A function that resolves the agent to route the email to
|
|
443
|
+
*/
|
|
444
|
+
declare function createCatchAllEmailResolver<Env>(
|
|
445
|
+
agentName: string,
|
|
446
|
+
agentId: string
|
|
447
|
+
): EmailResolver<Env>;
|
|
448
|
+
type EmailRoutingOptions<Env> = AgentOptions<Env> & {
|
|
449
|
+
resolver: EmailResolver<Env>;
|
|
450
|
+
};
|
|
416
451
|
/**
|
|
417
452
|
* Route an email to the appropriate Agent
|
|
418
|
-
* @param email
|
|
419
|
-
* @param env
|
|
420
|
-
* @param options
|
|
453
|
+
* @param email The email to route
|
|
454
|
+
* @param env The environment containing the Agent bindings
|
|
455
|
+
* @param options The options for routing the email
|
|
456
|
+
* @returns A promise that resolves when the email has been routed
|
|
421
457
|
*/
|
|
422
458
|
declare function routeAgentEmail<Env>(
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
459
|
+
email: ForwardableEmailMessage,
|
|
460
|
+
env: Env,
|
|
461
|
+
options: EmailRoutingOptions<Env>
|
|
426
462
|
): Promise<void>;
|
|
463
|
+
type AgentEmail = {
|
|
464
|
+
from: string;
|
|
465
|
+
to: string;
|
|
466
|
+
getRaw: () => Promise<Uint8Array>;
|
|
467
|
+
headers: Headers;
|
|
468
|
+
rawSize: number;
|
|
469
|
+
setReject: (reason: string) => void;
|
|
470
|
+
forward: (rcptTo: string, headers?: Headers) => Promise<void>;
|
|
471
|
+
reply: (options: { from: string; to: string; raw: string }) => Promise<void>;
|
|
472
|
+
};
|
|
473
|
+
type EmailSendOptions = {
|
|
474
|
+
to: string;
|
|
475
|
+
subject: string;
|
|
476
|
+
body: string;
|
|
477
|
+
contentType?: string;
|
|
478
|
+
headers?: Record<string, string>;
|
|
479
|
+
includeRoutingHeaders?: boolean;
|
|
480
|
+
agentName?: string;
|
|
481
|
+
agentId?: string;
|
|
482
|
+
domain?: string;
|
|
483
|
+
};
|
|
427
484
|
/**
|
|
428
485
|
* Get or create an Agent by name
|
|
429
486
|
* @template Env Environment type containing bindings
|
|
@@ -433,12 +490,17 @@ declare function routeAgentEmail<Env>(
|
|
|
433
490
|
* @param options Options for Agent creation
|
|
434
491
|
* @returns Promise resolving to an Agent instance stub
|
|
435
492
|
*/
|
|
436
|
-
declare function getAgentByName<
|
|
493
|
+
declare function getAgentByName<
|
|
494
|
+
Env,
|
|
495
|
+
T extends Agent<Env>,
|
|
496
|
+
Props extends Record<string, unknown> = Record<string, unknown>
|
|
497
|
+
>(
|
|
437
498
|
namespace: AgentNamespace<T>,
|
|
438
499
|
name: string,
|
|
439
500
|
options?: {
|
|
440
501
|
jurisdiction?: DurableObjectJurisdiction;
|
|
441
502
|
locationHint?: DurableObjectLocationHint;
|
|
503
|
+
props?: Props;
|
|
442
504
|
}
|
|
443
505
|
): Promise<DurableObjectStub<T>>;
|
|
444
506
|
/**
|
|
@@ -460,27 +522,37 @@ declare class StreamingResponse {
|
|
|
460
522
|
*/
|
|
461
523
|
end(finalChunk?: unknown): void;
|
|
462
524
|
}
|
|
463
|
-
|
|
525
|
+
//#endregion
|
|
464
526
|
export {
|
|
465
|
-
Agent
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
type
|
|
472
|
-
type
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
527
|
+
Agent,
|
|
528
|
+
AgentContext,
|
|
529
|
+
AgentEmail,
|
|
530
|
+
AgentNamespace,
|
|
531
|
+
AgentOptions,
|
|
532
|
+
CallableMetadata,
|
|
533
|
+
type Connection$1 as Connection,
|
|
534
|
+
type ConnectionContext,
|
|
535
|
+
EmailResolver,
|
|
536
|
+
EmailRoutingOptions,
|
|
537
|
+
EmailSendOptions,
|
|
538
|
+
MCPServer,
|
|
539
|
+
MCPServerMessage,
|
|
540
|
+
MCPServersState,
|
|
541
|
+
QueueItem,
|
|
542
|
+
RPCRequest,
|
|
543
|
+
RPCResponse,
|
|
544
|
+
Schedule,
|
|
545
|
+
StateUpdateMessage,
|
|
546
|
+
StreamingResponse,
|
|
547
|
+
type WSMessage,
|
|
548
|
+
callable,
|
|
549
|
+
createAddressBasedEmailResolver,
|
|
550
|
+
createCatchAllEmailResolver,
|
|
551
|
+
createHeaderBasedEmailResolver,
|
|
552
|
+
getAgentByName,
|
|
553
|
+
getCurrentAgent,
|
|
554
|
+
routeAgentEmail,
|
|
555
|
+
routeAgentRequest,
|
|
556
|
+
unstable_callable
|
|
486
557
|
};
|
|
558
|
+
//# sourceMappingURL=index-CkQU40oY.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,31 +1,70 @@
|
|
|
1
|
-
import "
|
|
2
|
-
import "
|
|
3
|
-
|
|
4
|
-
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
|
+
EmailResolver,
|
|
16
|
+
EmailRoutingOptions,
|
|
17
|
+
EmailSendOptions,
|
|
18
|
+
MCPServer,
|
|
19
|
+
MCPServerMessage,
|
|
20
|
+
MCPServersState,
|
|
21
|
+
QueueItem,
|
|
22
|
+
RPCRequest,
|
|
23
|
+
RPCResponse,
|
|
24
|
+
Schedule,
|
|
25
|
+
StateUpdateMessage,
|
|
26
|
+
StreamingResponse,
|
|
27
|
+
WSMessage,
|
|
28
|
+
callable,
|
|
29
|
+
createAddressBasedEmailResolver,
|
|
30
|
+
createCatchAllEmailResolver,
|
|
31
|
+
createHeaderBasedEmailResolver,
|
|
32
|
+
getAgentByName,
|
|
33
|
+
getCurrentAgent,
|
|
34
|
+
routeAgentEmail,
|
|
35
|
+
routeAgentRequest,
|
|
36
|
+
unstable_callable
|
|
37
|
+
} from "./index-CkQU40oY.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
|
-
|
|
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-UZlfLOYP.js";
|
|
2
|
+
import "./client-DjR-lC16.js";
|
|
3
|
+
import "./client-CZBVDDoO.js";
|
|
4
|
+
import "./do-oauth-client-provider-B2jr6UNq.js";
|
|
5
|
+
import { Agent, StreamingResponse, callable, createAddressBasedEmailResolver, createCatchAllEmailResolver, createHeaderBasedEmailResolver, getAgentByName, getCurrentAgent, routeAgentEmail, routeAgentRequest, unstable_callable } from "./src-COfG--3R.js";
|
|
6
|
+
|
|
7
|
+
export { Agent, StreamingResponse, callable, createAddressBasedEmailResolver, createCatchAllEmailResolver, createHeaderBasedEmailResolver, getAgentByName, getCurrentAgent, routeAgentEmail, routeAgentRequest, unstable_callable };
|