agents 0.0.0-fbaa8f7 → 0.0.0-fbf5181

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/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Server, Connection, PartyServerOptions } from "partyserver";
2
2
  export { Connection, ConnectionContext, WSMessage } from "partyserver";
3
- import { WorkflowEntrypoint as WorkflowEntrypoint$1 } from "cloudflare:workers";
3
+ import { AsyncLocalStorage } from "node:async_hooks";
4
4
 
5
5
  /**
6
6
  * RPC request message from client
@@ -59,10 +59,6 @@ declare function unstable_callable(
59
59
  target: (this: This, ...args: Args) => Return,
60
60
  context: ClassMethodDecoratorContext
61
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
62
  /**
67
63
  * Represents a scheduled task within an Agent
68
64
  * @template T Type of the payload data
@@ -98,6 +94,11 @@ type Schedule<T = string> = {
98
94
  cron: string;
99
95
  }
100
96
  );
97
+ declare const unstable_context: AsyncLocalStorage<{
98
+ agent: Agent<unknown>;
99
+ connection: Connection | undefined;
100
+ request: Request | undefined;
101
+ }>;
101
102
  /**
102
103
  * Base class for creating Agent implementations
103
104
  * @template Env Environment type containing bindings
@@ -148,7 +149,9 @@ declare class Agent<Env, State = unknown> extends Server<Env> {
148
149
  * Called when the Agent receives an email
149
150
  * @param email Email message to process
150
151
  */
151
- onEmail(email: ForwardableEmailMessage): void;
152
+ onEmail(email: ForwardableEmailMessage): Promise<void>;
153
+ onError(connection: Connection, error: unknown): void | Promise<void>;
154
+ onError(error: unknown): void | Promise<void>;
152
155
  /**
153
156
  * Render content (not implemented in base class)
154
157
  */
@@ -180,7 +183,6 @@ declare class Agent<Env, State = unknown> extends Server<Env> {
180
183
  * @returns Array of matching Schedule objects
181
184
  */
182
185
  getSchedules<T = string>(criteria?: {
183
- description?: string;
184
186
  id?: string;
185
187
  type?: "scheduled" | "delayed" | "cron";
186
188
  timeRange?: {
@@ -194,7 +196,6 @@ declare class Agent<Env, State = unknown> extends Server<Env> {
194
196
  * @returns true if the task was cancelled, false otherwise
195
197
  */
196
198
  cancelSchedule(id: string): Promise<boolean>;
197
- private scheduleNextAlarm;
198
199
  /**
199
200
  * Method called when an alarm fires
200
201
  * Executes any scheduled tasks that are due
@@ -204,11 +205,6 @@ declare class Agent<Env, State = unknown> extends Server<Env> {
204
205
  * Destroy the Agent, removing all state and scheduled tasks
205
206
  */
206
207
  destroy(): Promise<void>;
207
- /**
208
- * Get all methods marked as callable on this Agent
209
- * @returns A map of method names to their metadata
210
- */
211
- private isCallable;
212
208
  }
213
209
  /**
214
210
  * Namespace for creating Agent instances
@@ -298,9 +294,9 @@ export {
298
294
  type Schedule,
299
295
  type StateUpdateMessage,
300
296
  StreamingResponse,
301
- WorkflowEntrypoint,
302
297
  getAgentByName,
303
298
  routeAgentEmail,
304
299
  routeAgentRequest,
305
300
  unstable_callable,
301
+ unstable_context,
306
302
  };
package/dist/index.js CHANGED
@@ -1,20 +1,20 @@
1
1
  import {
2
2
  Agent,
3
3
  StreamingResponse,
4
- WorkflowEntrypoint,
5
4
  getAgentByName,
6
5
  routeAgentEmail,
7
6
  routeAgentRequest,
8
- unstable_callable
9
- } from "./chunk-PDF5WEP4.js";
7
+ unstable_callable,
8
+ unstable_context
9
+ } from "./chunk-XG52S6YY.js";
10
10
  import "./chunk-HMLY7DHA.js";
11
11
  export {
12
12
  Agent,
13
13
  StreamingResponse,
14
- WorkflowEntrypoint,
15
14
  getAgentByName,
16
15
  routeAgentEmail,
17
16
  routeAgentRequest,
18
- unstable_callable
17
+ unstable_callable,
18
+ unstable_context
19
19
  };
20
20
  //# sourceMappingURL=index.js.map