agents 0.0.0-c5e3a32 → 0.0.0-c69f616

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.
@@ -1,3 +1,4 @@
1
+ import { env } from "cloudflare:workers";
1
2
  import { Client } from "@modelcontextprotocol/sdk/client/index.js";
2
3
  import {
3
4
  ServerCapabilities,
@@ -6,7 +7,7 @@ import {
6
7
  Resource
7
8
  } from "@modelcontextprotocol/sdk/types.js";
8
9
  import { Server, Connection, PartyServerOptions } from "partyserver";
9
- import { MCPClientManager } from "./mcp/client.js";
10
+ import { M as MCPClientManager } from "./client-CH-eFIfq.js";
10
11
  import { Message } from "ai";
11
12
 
12
13
  type BaseEvent<
@@ -140,6 +141,12 @@ declare function unstable_callable(
140
141
  target: (this: This, ...args: Args) => Return,
141
142
  context: ClassMethodDecoratorContext
142
143
  ) => (this: This, ...args: Args) => Return;
144
+ type QueueItem<T = string> = {
145
+ id: string;
146
+ payload: T;
147
+ callback: keyof Agent<unknown>;
148
+ created_at: number;
149
+ };
143
150
  /**
144
151
  * Represents a scheduled task within an Agent
145
152
  * @template T Type of the payload data
@@ -211,7 +218,7 @@ declare function getCurrentAgent<
211
218
  * @template Env Environment type containing bindings
212
219
  * @template State State type to store within the Agent
213
220
  */
214
- declare class Agent<Env, State = unknown> extends Server<Env> {
221
+ declare class Agent<Env = typeof env, State = unknown> extends Server<Env> {
215
222
  private _state;
216
223
  private _ParentClass;
217
224
  mcp: MCPClientManager;
@@ -293,6 +300,42 @@ declare class Agent<Env, State = unknown> extends Server<Env> {
293
300
  * Render content (not implemented in base class)
294
301
  */
295
302
  render(): void;
303
+ /**
304
+ * Queue a task to be executed in the future
305
+ * @param payload Payload to pass to the callback
306
+ * @param callback Name of the method to call
307
+ * @returns The ID of the queued task
308
+ */
309
+ queue<T = unknown>(callback: keyof this, payload: T): Promise<string>;
310
+ private _flushingQueue;
311
+ private _flushQueue;
312
+ /**
313
+ * Dequeue a task by ID
314
+ * @param id ID of the task to dequeue
315
+ */
316
+ dequeue(id: string): Promise<void>;
317
+ /**
318
+ * Dequeue all tasks
319
+ */
320
+ dequeueAll(): Promise<void>;
321
+ /**
322
+ * Dequeue all tasks by callback
323
+ * @param callback Name of the callback to dequeue
324
+ */
325
+ dequeueAllByCallback(callback: string): Promise<void>;
326
+ /**
327
+ * Get a queued task by ID
328
+ * @param id ID of the task to get
329
+ * @returns The task or undefined if not found
330
+ */
331
+ getQueue(id: string): Promise<QueueItem<string> | undefined>;
332
+ /**
333
+ * Get all queues by key and value
334
+ * @param key Key to filter by
335
+ * @param value Value to filter by
336
+ * @returns Array of matching QueueItem objects
337
+ */
338
+ getQueues(key: string, value: string): Promise<QueueItem<string>[]>;
296
339
  /**
297
340
  * Schedule a task to be executed in the future
298
341
  * @template T Type of the payload data
@@ -545,6 +588,7 @@ export {
545
588
  type EmailResolver as E,
546
589
  type MCPServersState as M,
547
590
  type ObservabilityEvent as O,
591
+ type QueueItem as Q,
548
592
  type RPCRequest as R,
549
593
  type StateUpdateMessage as S,
550
594
  type AgentContext as a,
package/dist/index.d.ts CHANGED
@@ -1,7 +1,8 @@
1
+ import "cloudflare:workers";
1
2
  import "@modelcontextprotocol/sdk/client/index.js";
2
3
  import "@modelcontextprotocol/sdk/types.js";
3
4
  export { Connection, ConnectionContext, WSMessage } from "partyserver";
4
- import "./mcp/client.js";
5
+ import "./client-CH-eFIfq.js";
5
6
  export {
6
7
  A as Agent,
7
8
  a as AgentContext,
@@ -15,6 +16,7 @@ export {
15
16
  f as MCPServer,
16
17
  e as MCPServerMessage,
17
18
  M as MCPServersState,
19
+ Q as QueueItem,
18
20
  R as RPCRequest,
19
21
  c as RPCResponse,
20
22
  d as Schedule,
@@ -28,11 +30,12 @@ export {
28
30
  o as routeAgentEmail,
29
31
  r as routeAgentRequest,
30
32
  u as unstable_callable
31
- } from "./index-DukU3sIa.js";
33
+ } from "./index-BVoermIz.js";
32
34
  import "zod";
33
- import "@modelcontextprotocol/sdk/client/sse.js";
34
35
  import "@modelcontextprotocol/sdk/shared/protocol.js";
35
36
  import "ai";
37
+ import "@modelcontextprotocol/sdk/client/sse.js";
38
+ import "@modelcontextprotocol/sdk/client/streamableHttp.js";
36
39
  import "./mcp/do-oauth-client-provider.js";
37
40
  import "@modelcontextprotocol/sdk/client/auth.js";
38
41
  import "@modelcontextprotocol/sdk/shared/auth.js";
package/dist/index.js CHANGED
@@ -9,8 +9,8 @@ import {
9
9
  routeAgentEmail,
10
10
  routeAgentRequest,
11
11
  unstable_callable
12
- } from "./chunk-EDUDXISR.js";
13
- import "./chunk-MW5BQ2FW.js";
12
+ } from "./chunk-OJFA7RKX.js";
13
+ import "./chunk-HY7ZLHJB.js";
14
14
  import "./chunk-PVQZBKN7.js";
15
15
  import "./chunk-KUH345EY.js";
16
16
  export {