agents 0.0.0-4768b8d → 0.0.0-48849be

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