agents 0.0.0-f641104 → 0.0.0-f6c26e4

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.
Files changed (51) hide show
  1. package/README.md +24 -28
  2. package/dist/ai-chat-agent.d.ts +51 -4
  3. package/dist/ai-chat-agent.js +179 -78
  4. package/dist/ai-chat-agent.js.map +1 -1
  5. package/dist/ai-react.d.ts +18 -5
  6. package/dist/ai-react.js +62 -48
  7. package/dist/ai-react.js.map +1 -1
  8. package/dist/ai-types.d.ts +5 -0
  9. package/dist/chunk-5YIRLLUX.js +1264 -0
  10. package/dist/chunk-5YIRLLUX.js.map +1 -0
  11. package/dist/chunk-KUH345EY.js +116 -0
  12. package/dist/chunk-KUH345EY.js.map +1 -0
  13. package/dist/chunk-MW5BQ2FW.js +469 -0
  14. package/dist/chunk-MW5BQ2FW.js.map +1 -0
  15. package/dist/chunk-PVQZBKN7.js +106 -0
  16. package/dist/chunk-PVQZBKN7.js.map +1 -0
  17. package/dist/client.d.ts +16 -2
  18. package/dist/client.js +6 -133
  19. package/dist/client.js.map +1 -1
  20. package/dist/index-BIJvkfYt.d.ts +614 -0
  21. package/dist/index.d.ts +37 -300
  22. package/dist/index.js +12 -4
  23. package/dist/mcp/client.d.ts +1055 -0
  24. package/dist/mcp/client.js +9 -0
  25. package/dist/mcp/do-oauth-client-provider.d.ts +41 -0
  26. package/dist/mcp/do-oauth-client-provider.js +7 -0
  27. package/dist/mcp/do-oauth-client-provider.js.map +1 -0
  28. package/dist/mcp/index.d.ts +84 -0
  29. package/dist/mcp/index.js +783 -0
  30. package/dist/mcp/index.js.map +1 -0
  31. package/dist/observability/index.d.ts +12 -0
  32. package/dist/observability/index.js +10 -0
  33. package/dist/observability/index.js.map +1 -0
  34. package/dist/react.d.ts +85 -5
  35. package/dist/react.js +50 -31
  36. package/dist/react.js.map +1 -1
  37. package/dist/schedule.d.ts +6 -6
  38. package/dist/schedule.js +4 -6
  39. package/dist/schedule.js.map +1 -1
  40. package/dist/serializable.d.ts +32 -0
  41. package/dist/serializable.js +1 -0
  42. package/dist/serializable.js.map +1 -0
  43. package/package.json +84 -52
  44. package/src/index.ts +1172 -182
  45. package/dist/chunk-HMLY7DHA.js +0 -16
  46. package/dist/chunk-X6BBKLSC.js +0 -568
  47. package/dist/chunk-X6BBKLSC.js.map +0 -1
  48. package/dist/mcp.d.ts +0 -58
  49. package/dist/mcp.js +0 -945
  50. package/dist/mcp.js.map +0 -1
  51. /package/dist/{chunk-HMLY7DHA.js.map → mcp/client.js.map} +0 -0
package/dist/index.d.ts CHANGED
@@ -1,302 +1,39 @@
1
- import { Server, Connection, PartyServerOptions } from "partyserver";
1
+ import "@modelcontextprotocol/sdk/client/index.js";
2
+ import "@modelcontextprotocol/sdk/types.js";
2
3
  export { Connection, ConnectionContext, WSMessage } from "partyserver";
3
- import { WorkflowEntrypoint as WorkflowEntrypoint$1 } from "cloudflare:workers";
4
-
5
- /**
6
- * RPC request message from client
7
- */
8
- type RPCRequest = {
9
- type: "rpc";
10
- id: string;
11
- method: string;
12
- args: unknown[];
13
- };
14
- /**
15
- * State update message from client
16
- */
17
- type StateUpdateMessage = {
18
- type: "cf_agent_state";
19
- state: unknown;
20
- };
21
- /**
22
- * RPC response message to client
23
- */
24
- type RPCResponse = {
25
- type: "rpc";
26
- id: string;
27
- } & (
28
- | {
29
- success: true;
30
- result: unknown;
31
- done?: false;
32
- }
33
- | {
34
- success: true;
35
- result: unknown;
36
- done: true;
37
- }
38
- | {
39
- success: false;
40
- error: string;
41
- }
42
- );
43
- /**
44
- * Metadata for a callable method
45
- */
46
- type CallableMetadata = {
47
- /** Optional description of what the method does */
48
- description?: string;
49
- /** Whether the method supports streaming responses */
50
- streaming?: boolean;
51
- };
52
- /**
53
- * Decorator that marks a method as callable by clients
54
- * @param metadata Optional metadata about the callable method
55
- */
56
- declare function unstable_callable(
57
- metadata?: CallableMetadata
58
- ): <This, Args extends unknown[], Return>(
59
- target: (this: This, ...args: Args) => Return,
60
- context: ClassMethodDecoratorContext
61
- ) => (this: This, ...args: Args) => Return;
62
- /**
63
- * A class for creating workflow entry points that can be used with Cloudflare Workers
64
- */
65
- declare class WorkflowEntrypoint extends WorkflowEntrypoint$1 {}
66
- /**
67
- * Represents a scheduled task within an Agent
68
- * @template T Type of the payload data
69
- */
70
- type Schedule<T = string> = {
71
- /** Unique identifier for the schedule */
72
- id: string;
73
- /** Name of the method to be called */
74
- callback: string;
75
- /** Data to be passed to the callback */
76
- payload: T;
77
- } & (
78
- | {
79
- /** Type of schedule for one-time execution at a specific time */
80
- type: "scheduled";
81
- /** Timestamp when the task should execute */
82
- time: number;
83
- }
84
- | {
85
- /** Type of schedule for delayed execution */
86
- type: "delayed";
87
- /** Timestamp when the task should execute */
88
- time: number;
89
- /** Number of seconds to delay execution */
90
- delayInSeconds: number;
91
- }
92
- | {
93
- /** Type of schedule for recurring execution based on cron expression */
94
- type: "cron";
95
- /** Timestamp for the next execution */
96
- time: number;
97
- /** Cron expression defining the schedule */
98
- cron: string;
99
- }
100
- );
101
- /**
102
- * Base class for creating Agent implementations
103
- * @template Env Environment type containing bindings
104
- * @template State State type to store within the Agent
105
- */
106
- declare class Agent<Env, State = unknown> extends Server<Env> {
107
- #private;
108
- /**
109
- * Initial state for the Agent
110
- * Override to provide default state values
111
- */
112
- initialState: State;
113
- /**
114
- * Current state of the Agent
115
- */
116
- get state(): State;
117
- /**
118
- * Agent configuration options
119
- */
120
- static options: {
121
- /** Whether the Agent should hibernate when inactive */
122
- hibernate: boolean;
123
- };
124
- /**
125
- * Execute SQL queries against the Agent's database
126
- * @template T Type of the returned rows
127
- * @param strings SQL query template strings
128
- * @param values Values to be inserted into the query
129
- * @returns Array of query results
130
- */
131
- sql<T = Record<string, string | number | boolean | null>>(
132
- strings: TemplateStringsArray,
133
- ...values: (string | number | boolean | null)[]
134
- ): T[];
135
- constructor(ctx: AgentContext, env: Env);
136
- /**
137
- * Update the Agent's state
138
- * @param state New state to set
139
- */
140
- setState(state: State): void;
141
- /**
142
- * Called when the Agent's state is updated
143
- * @param state Updated state
144
- * @param source Source of the state update ("server" or a client connection)
145
- */
146
- onStateUpdate(state: State | undefined, source: Connection | "server"): void;
147
- /**
148
- * Called when the Agent receives an email
149
- * @param email Email message to process
150
- */
151
- onEmail(email: ForwardableEmailMessage): void;
152
- onError(connection: Connection, error: unknown): void | Promise<void>;
153
- onError(error: unknown): void | Promise<void>;
154
- /**
155
- * Render content (not implemented in base class)
156
- */
157
- render(): void;
158
- /**
159
- * Schedule a task to be executed in the future
160
- * @template T Type of the payload data
161
- * @param when When to execute the task (Date, seconds delay, or cron expression)
162
- * @param callback Name of the method to call
163
- * @param payload Data to pass to the callback
164
- * @returns Schedule object representing the scheduled task
165
- */
166
- schedule<T = string>(
167
- when: Date | string | number,
168
- callback: keyof this,
169
- payload?: T
170
- ): Promise<Schedule<T>>;
171
- /**
172
- * Get a scheduled task by ID
173
- * @template T Type of the payload data
174
- * @param id ID of the scheduled task
175
- * @returns The Schedule object or undefined if not found
176
- */
177
- getSchedule<T = string>(id: string): Promise<Schedule<T> | undefined>;
178
- /**
179
- * Get scheduled tasks matching the given criteria
180
- * @template T Type of the payload data
181
- * @param criteria Criteria to filter schedules
182
- * @returns Array of matching Schedule objects
183
- */
184
- getSchedules<T = string>(criteria?: {
185
- description?: string;
186
- id?: string;
187
- type?: "scheduled" | "delayed" | "cron";
188
- timeRange?: {
189
- start?: Date;
190
- end?: Date;
191
- };
192
- }): Schedule<T>[];
193
- /**
194
- * Cancel a scheduled task
195
- * @param id ID of the task to cancel
196
- * @returns true if the task was cancelled, false otherwise
197
- */
198
- cancelSchedule(id: string): Promise<boolean>;
199
- /**
200
- * Method called when an alarm fires
201
- * Executes any scheduled tasks that are due
202
- */
203
- alarm(): Promise<void>;
204
- /**
205
- * Destroy the Agent, removing all state and scheduled tasks
206
- */
207
- destroy(): Promise<void>;
208
- }
209
- /**
210
- * Namespace for creating Agent instances
211
- * @template Agentic Type of the Agent class
212
- */
213
- type AgentNamespace<Agentic extends Agent<unknown>> =
214
- DurableObjectNamespace<Agentic>;
215
- /**
216
- * Agent's durable context
217
- */
218
- type AgentContext = DurableObjectState;
219
- /**
220
- * Configuration options for Agent routing
221
- */
222
- type AgentOptions<Env> = PartyServerOptions<Env> & {
223
- /**
224
- * Whether to enable CORS for the Agent
225
- */
226
- cors?: boolean | HeadersInit | undefined;
227
- };
228
- /**
229
- * Route a request to the appropriate Agent
230
- * @param request Request to route
231
- * @param env Environment containing Agent bindings
232
- * @param options Routing options
233
- * @returns Response from the Agent or undefined if no route matched
234
- */
235
- declare function routeAgentRequest<Env>(
236
- request: Request,
237
- env: Env,
238
- options?: AgentOptions<Env>
239
- ): Promise<Response | null>;
240
- /**
241
- * Route an email to the appropriate Agent
242
- * @param email Email message to route
243
- * @param env Environment containing Agent bindings
244
- * @param options Routing options
245
- */
246
- declare function routeAgentEmail<Env>(
247
- email: ForwardableEmailMessage,
248
- env: Env,
249
- options?: AgentOptions<Env>
250
- ): Promise<void>;
251
- /**
252
- * Get or create an Agent by name
253
- * @template Env Environment type containing bindings
254
- * @template T Type of the Agent class
255
- * @param namespace Agent namespace
256
- * @param name Name of the Agent instance
257
- * @param options Options for Agent creation
258
- * @returns Promise resolving to an Agent instance stub
259
- */
260
- declare function getAgentByName<Env, T extends Agent<Env>>(
261
- namespace: AgentNamespace<T>,
262
- name: string,
263
- options?: {
264
- jurisdiction?: DurableObjectJurisdiction;
265
- locationHint?: DurableObjectLocationHint;
266
- }
267
- ): Promise<DurableObjectStub<T>>;
268
- /**
269
- * A wrapper for streaming responses in callable methods
270
- */
271
- declare class StreamingResponse {
272
- #private;
273
- constructor(connection: Connection, id: string);
274
- /**
275
- * Send a chunk of data to the client
276
- * @param chunk The data to send
277
- */
278
- send(chunk: unknown): void;
279
- /**
280
- * End the stream and send the final chunk (if any)
281
- * @param finalChunk Optional final chunk of data to send
282
- */
283
- end(finalChunk?: unknown): void;
284
- }
285
-
4
+ import "./mcp/client.js";
286
5
  export {
287
- Agent,
288
- type AgentContext,
289
- type AgentNamespace,
290
- type AgentOptions,
291
- type CallableMetadata,
292
- type RPCRequest,
293
- type RPCResponse,
294
- type Schedule,
295
- type StateUpdateMessage,
296
- StreamingResponse,
297
- WorkflowEntrypoint,
298
- getAgentByName,
299
- routeAgentEmail,
300
- routeAgentRequest,
301
- unstable_callable,
302
- };
6
+ A as Agent,
7
+ a as AgentContext,
8
+ p as AgentEmail,
9
+ i as AgentNamespace,
10
+ j as AgentOptions,
11
+ C as CallableMetadata,
12
+ E as EmailResolver,
13
+ n as EmailRoutingOptions,
14
+ q as EmailSendOptions,
15
+ f as MCPServer,
16
+ e as MCPServerMessage,
17
+ M as MCPServersState,
18
+ Q as QueueItem,
19
+ R as RPCRequest,
20
+ c as RPCResponse,
21
+ d as Schedule,
22
+ S as StateUpdateMessage,
23
+ t as StreamingResponse,
24
+ l as createAddressBasedEmailResolver,
25
+ m as createCatchAllEmailResolver,
26
+ k as createHeaderBasedEmailResolver,
27
+ s as getAgentByName,
28
+ h as getCurrentAgent,
29
+ o as routeAgentEmail,
30
+ r as routeAgentRequest,
31
+ u as unstable_callable
32
+ } from "./index-BIJvkfYt.js";
33
+ import "zod";
34
+ import "@modelcontextprotocol/sdk/client/sse.js";
35
+ import "@modelcontextprotocol/sdk/shared/protocol.js";
36
+ import "ai";
37
+ import "./mcp/do-oauth-client-provider.js";
38
+ import "@modelcontextprotocol/sdk/client/auth.js";
39
+ import "@modelcontextprotocol/sdk/shared/auth.js";
package/dist/index.js CHANGED
@@ -1,18 +1,26 @@
1
1
  import {
2
2
  Agent,
3
3
  StreamingResponse,
4
- WorkflowEntrypoint,
4
+ createAddressBasedEmailResolver,
5
+ createCatchAllEmailResolver,
6
+ createHeaderBasedEmailResolver,
5
7
  getAgentByName,
8
+ getCurrentAgent,
6
9
  routeAgentEmail,
7
10
  routeAgentRequest,
8
11
  unstable_callable
9
- } from "./chunk-X6BBKLSC.js";
10
- import "./chunk-HMLY7DHA.js";
12
+ } from "./chunk-5YIRLLUX.js";
13
+ import "./chunk-MW5BQ2FW.js";
14
+ import "./chunk-PVQZBKN7.js";
15
+ import "./chunk-KUH345EY.js";
11
16
  export {
12
17
  Agent,
13
18
  StreamingResponse,
14
- WorkflowEntrypoint,
19
+ createAddressBasedEmailResolver,
20
+ createCatchAllEmailResolver,
21
+ createHeaderBasedEmailResolver,
15
22
  getAgentByName,
23
+ getCurrentAgent,
16
24
  routeAgentEmail,
17
25
  routeAgentRequest,
18
26
  unstable_callable