agents 0.0.0-e03246e → 0.0.0-e173b41

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