agents 0.0.0-f5b5854 → 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 (48) hide show
  1. package/README.md +22 -22
  2. package/dist/ai-chat-agent.d.ts +47 -4
  3. package/dist/ai-chat-agent.js +167 -67
  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 +48 -37
  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 -126
  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 +14 -6
  23. package/dist/mcp/client.d.ts +313 -21
  24. package/dist/mcp/client.js +3 -402
  25. package/dist/mcp/client.js.map +1 -1
  26. package/dist/mcp/do-oauth-client-provider.d.ts +3 -3
  27. package/dist/mcp/do-oauth-client-provider.js +3 -103
  28. package/dist/mcp/do-oauth-client-provider.js.map +1 -1
  29. package/dist/mcp/index.d.ts +33 -10
  30. package/dist/mcp/index.js +181 -176
  31. package/dist/mcp/index.js.map +1 -1
  32. package/dist/observability/index.d.ts +12 -0
  33. package/dist/observability/index.js +10 -0
  34. package/dist/react.d.ts +85 -5
  35. package/dist/react.js +20 -8
  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 +76 -65
  44. package/src/index.ts +1102 -136
  45. package/dist/chunk-HMLY7DHA.js +0 -16
  46. package/dist/chunk-XG52S6YY.js +0 -591
  47. package/dist/chunk-XG52S6YY.js.map +0 -1
  48. /package/dist/{chunk-HMLY7DHA.js.map → observability/index.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 { AsyncLocalStorage } from "node:async_hooks";
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
- * Represents a scheduled task within an Agent
64
- * @template T Type of the payload data
65
- */
66
- type Schedule<T = string> = {
67
- /** Unique identifier for the schedule */
68
- id: string;
69
- /** Name of the method to be called */
70
- callback: string;
71
- /** Data to be passed to the callback */
72
- payload: T;
73
- } & (
74
- | {
75
- /** Type of schedule for one-time execution at a specific time */
76
- type: "scheduled";
77
- /** Timestamp when the task should execute */
78
- time: number;
79
- }
80
- | {
81
- /** Type of schedule for delayed execution */
82
- type: "delayed";
83
- /** Timestamp when the task should execute */
84
- time: number;
85
- /** Number of seconds to delay execution */
86
- delayInSeconds: number;
87
- }
88
- | {
89
- /** Type of schedule for recurring execution based on cron expression */
90
- type: "cron";
91
- /** Timestamp for the next execution */
92
- time: number;
93
- /** Cron expression defining the schedule */
94
- cron: string;
95
- }
96
- );
97
- declare const unstable_context: AsyncLocalStorage<{
98
- agent: Agent<unknown>;
99
- connection: Connection | undefined;
100
- request: Request | undefined;
101
- }>;
102
- /**
103
- * Base class for creating Agent implementations
104
- * @template Env Environment type containing bindings
105
- * @template State State type to store within the Agent
106
- */
107
- declare class Agent<Env, State = unknown> extends Server<Env> {
108
- #private;
109
- /**
110
- * Initial state for the Agent
111
- * Override to provide default state values
112
- */
113
- initialState: State;
114
- /**
115
- * Current state of the Agent
116
- */
117
- get state(): State;
118
- /**
119
- * Agent configuration options
120
- */
121
- static options: {
122
- /** Whether the Agent should hibernate when inactive */
123
- hibernate: boolean;
124
- };
125
- /**
126
- * Execute SQL queries against the Agent's database
127
- * @template T Type of the returned rows
128
- * @param strings SQL query template strings
129
- * @param values Values to be inserted into the query
130
- * @returns Array of query results
131
- */
132
- sql<T = Record<string, string | number | boolean | null>>(
133
- strings: TemplateStringsArray,
134
- ...values: (string | number | boolean | null)[]
135
- ): T[];
136
- constructor(ctx: AgentContext, env: Env);
137
- /**
138
- * Update the Agent's state
139
- * @param state New state to set
140
- */
141
- setState(state: State): void;
142
- /**
143
- * Called when the Agent's state is updated
144
- * @param state Updated state
145
- * @param source Source of the state update ("server" or a client connection)
146
- */
147
- onStateUpdate(state: State | undefined, source: Connection | "server"): void;
148
- /**
149
- * Called when the Agent receives an email
150
- * @param email Email message to process
151
- */
152
- onEmail(email: ForwardableEmailMessage): Promise<void>;
153
- onError(connection: Connection, error: unknown): void | Promise<void>;
154
- onError(error: unknown): void | Promise<void>;
155
- /**
156
- * Render content (not implemented in base class)
157
- */
158
- render(): void;
159
- /**
160
- * Schedule a task to be executed in the future
161
- * @template T Type of the payload data
162
- * @param when When to execute the task (Date, seconds delay, or cron expression)
163
- * @param callback Name of the method to call
164
- * @param payload Data to pass to the callback
165
- * @returns Schedule object representing the scheduled task
166
- */
167
- schedule<T = string>(
168
- when: Date | string | number,
169
- callback: keyof this,
170
- payload?: T
171
- ): Promise<Schedule<T>>;
172
- /**
173
- * Get a scheduled task by ID
174
- * @template T Type of the payload data
175
- * @param id ID of the scheduled task
176
- * @returns The Schedule object or undefined if not found
177
- */
178
- getSchedule<T = string>(id: string): Promise<Schedule<T> | undefined>;
179
- /**
180
- * Get scheduled tasks matching the given criteria
181
- * @template T Type of the payload data
182
- * @param criteria Criteria to filter schedules
183
- * @returns Array of matching Schedule objects
184
- */
185
- getSchedules<T = string>(criteria?: {
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
- getAgentByName,
298
- routeAgentEmail,
299
- routeAgentRequest,
300
- unstable_callable,
301
- unstable_context,
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,20 +1,28 @@
1
1
  import {
2
2
  Agent,
3
3
  StreamingResponse,
4
+ createAddressBasedEmailResolver,
5
+ createCatchAllEmailResolver,
6
+ createHeaderBasedEmailResolver,
4
7
  getAgentByName,
8
+ getCurrentAgent,
5
9
  routeAgentEmail,
6
10
  routeAgentRequest,
7
- unstable_callable,
8
- unstable_context
9
- } from "./chunk-XG52S6YY.js";
10
- import "./chunk-HMLY7DHA.js";
11
+ unstable_callable
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,
19
+ createAddressBasedEmailResolver,
20
+ createCatchAllEmailResolver,
21
+ createHeaderBasedEmailResolver,
14
22
  getAgentByName,
23
+ getCurrentAgent,
15
24
  routeAgentEmail,
16
25
  routeAgentRequest,
17
- unstable_callable,
18
- unstable_context
26
+ unstable_callable
19
27
  };
20
28
  //# sourceMappingURL=index.js.map