agents 0.7.7 → 0.7.8

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,4 +1,4 @@
1
- import { r as Agent } from "../index-DBW341gU.js";
1
+ import { r as Agent } from "../index-BOdpK2Ni.js";
2
2
  //#region src/experimental/forever.d.ts
3
3
  type FiberState = {
4
4
  id: string;
@@ -5,7 +5,7 @@ import {
5
5
  n as Observability,
6
6
  r as ObservabilityEvent,
7
7
  s as MCPObservabilityEvent
8
- } from "./index-BS_jL8MI.js";
8
+ } from "./index-D9AuAMOt.js";
9
9
  import { t as AgentMcpOAuthProvider } from "./do-oauth-client-provider-C2jurFjW.js";
10
10
  import {
11
11
  _ as WorkflowPage,
@@ -707,7 +707,7 @@ declare class MCPClientConnection {
707
707
  */
708
708
  getTransport(
709
709
  transportType: BaseTransportType
710
- ): SSEClientTransport | StreamableHTTPClientTransport | RPCClientTransport;
710
+ ): StreamableHTTPClientTransport | SSEClientTransport | RPCClientTransport;
711
711
  private tryConnect;
712
712
  private _capabilityErrorHandler;
713
713
  }
@@ -2837,4 +2837,4 @@ export {
2837
2837
  Schedule as y,
2838
2838
  MCPServerOptions as z
2839
2839
  };
2840
- //# sourceMappingURL=index-DBW341gU.d.ts.map
2840
+ //# sourceMappingURL=index-BOdpK2Ni.d.ts.map
@@ -271,98 +271,11 @@ type AgentObservabilityEvent =
271
271
  }
272
272
  >;
273
273
  //#endregion
274
- //#region src/observability/workspace.d.ts
275
- /**
276
- * Workspace-specific observability events.
277
- * These track file operations, directory changes, and bash execution
278
- * within a Workspace instance.
279
- */
280
- type WorkspaceObservabilityEvent =
281
- | BaseEvent<
282
- "workspace:read",
283
- {
284
- namespace: string;
285
- path: string;
286
- storage: "inline" | "r2";
287
- }
288
- >
289
- | BaseEvent<
290
- "workspace:write",
291
- {
292
- namespace: string;
293
- path: string;
294
- size: number;
295
- storage: "inline" | "r2";
296
- update: boolean;
297
- }
298
- >
299
- | BaseEvent<
300
- "workspace:delete",
301
- {
302
- namespace: string;
303
- path: string;
304
- }
305
- >
306
- | BaseEvent<
307
- "workspace:mkdir",
308
- {
309
- namespace: string;
310
- path: string;
311
- recursive: boolean;
312
- }
313
- >
314
- | BaseEvent<
315
- "workspace:rm",
316
- {
317
- namespace: string;
318
- path: string;
319
- recursive: boolean;
320
- }
321
- >
322
- | BaseEvent<
323
- "workspace:cp",
324
- {
325
- namespace: string;
326
- src: string;
327
- dest: string;
328
- recursive: boolean;
329
- }
330
- >
331
- | BaseEvent<
332
- "workspace:mv",
333
- {
334
- namespace: string;
335
- src: string;
336
- dest: string;
337
- }
338
- >
339
- | BaseEvent<
340
- "workspace:bash",
341
- {
342
- namespace: string;
343
- command: string;
344
- exitCode: number;
345
- durationMs: number;
346
- }
347
- >
348
- | BaseEvent<
349
- "workspace:error",
350
- {
351
- namespace: string;
352
- operation: string;
353
- path: string;
354
- error: string;
355
- }
356
- >;
357
- //#endregion
358
274
  //#region src/observability/index.d.ts
359
275
  /**
360
276
  * Union of all observability event types from different domains
361
277
  */
362
- type ObservabilityEvent =
363
- | AgentObservabilityEvent
364
- | MCPObservabilityEvent
365
- | WorkspaceObservabilityEvent;
278
+ type ObservabilityEvent = AgentObservabilityEvent | MCPObservabilityEvent;
366
279
  interface Observability {
367
280
  /**
368
281
  * Emit an event for the Agent's observability implementation to handle.
@@ -394,7 +307,6 @@ declare const channels: {
394
307
  readonly workflow: Channel<unknown, unknown>;
395
308
  readonly mcp: Channel<unknown, unknown>;
396
309
  readonly email: Channel<unknown, unknown>;
397
- readonly workspace: Channel<unknown, unknown>;
398
310
  };
399
311
  /**
400
312
  * The default observability implementation.
@@ -455,12 +367,6 @@ type ChannelEventMap = {
455
367
  type: `email:${string}`;
456
368
  }
457
369
  >;
458
- workspace: Extract<
459
- ObservabilityEvent,
460
- {
461
- type: `workspace:${string}`;
462
- }
463
- >;
464
370
  };
465
371
  /**
466
372
  * Subscribe to a typed observability channel.
@@ -489,4 +395,4 @@ export {
489
395
  MCPObservabilityEvent as s,
490
396
  ChannelEventMap as t
491
397
  };
492
- //# sourceMappingURL=index-BS_jL8MI.d.ts.map
398
+ //# sourceMappingURL=index-D9AuAMOt.d.ts.map
package/dist/index.d.ts CHANGED
@@ -34,7 +34,7 @@ import {
34
34
  w as SubAgentStub,
35
35
  x as StateUpdateMessage,
36
36
  y as Schedule
37
- } from "./index-DBW341gU.js";
37
+ } from "./index-BOdpK2Ni.js";
38
38
  import {
39
39
  n as AgentsOAuthProvider,
40
40
  r as DurableObjectOAuthClientProvider,
@@ -1,2 +1,2 @@
1
- import { B as RegisterServerOptions, F as MCPClientOAuthResult, I as MCPConnectionResult, L as MCPDiscoverResult, M as MCPClientManager, N as MCPClientManagerOptions, P as MCPClientOAuthCallbackConfig, R as MCPOAuthCallbackResult, V as getNamespacedData, z as MCPServerOptions } from "../index-DBW341gU.js";
1
+ import { B as RegisterServerOptions, F as MCPClientOAuthResult, I as MCPConnectionResult, L as MCPDiscoverResult, M as MCPClientManager, N as MCPClientManagerOptions, P as MCPClientOAuthCallbackConfig, R as MCPOAuthCallbackResult, V as getNamespacedData, z as MCPServerOptions } from "../index-BOdpK2Ni.js";
2
2
  export { MCPClientManager, MCPClientManagerOptions, MCPClientOAuthCallbackConfig, MCPClientOAuthResult, MCPConnectionResult, MCPDiscoverResult, MCPOAuthCallbackResult, MCPServerOptions, RegisterServerOptions, getNamespacedData };
@@ -1,2 +1,2 @@
1
- import { $ as experimental_createMcpHandler, F as MCPClientOAuthResult, G as RPCServerTransportOptions, H as RPCClientTransport, I as MCPConnectionResult, J as ElicitRequestSchema, K as RPC_DO_PREFIX, L as MCPDiscoverResult, P as MCPClientOAuthCallbackConfig, Q as createMcpHandler, U as RPCClientTransportOptions, W as RPCServerTransport, X as McpAgent, Y as ElicitResult, Z as CreateMcpHandlerOptions, at as SSEEdgeClientTransport, et as McpAuthContext, it as WorkerTransportOptions, nt as TransportState, ot as StreamableHTTPEdgeClientTransport, q as ElicitRequest, rt as WorkerTransport, st as McpClientOptions, tt as getMcpAuthContext, z as MCPServerOptions } from "../index-DBW341gU.js";
1
+ import { $ as experimental_createMcpHandler, F as MCPClientOAuthResult, G as RPCServerTransportOptions, H as RPCClientTransport, I as MCPConnectionResult, J as ElicitRequestSchema, K as RPC_DO_PREFIX, L as MCPDiscoverResult, P as MCPClientOAuthCallbackConfig, Q as createMcpHandler, U as RPCClientTransportOptions, W as RPCServerTransport, X as McpAgent, Y as ElicitResult, Z as CreateMcpHandlerOptions, at as SSEEdgeClientTransport, et as McpAuthContext, it as WorkerTransportOptions, nt as TransportState, ot as StreamableHTTPEdgeClientTransport, q as ElicitRequest, rt as WorkerTransport, st as McpClientOptions, tt as getMcpAuthContext, z as MCPServerOptions } from "../index-BOdpK2Ni.js";
2
2
  export { CreateMcpHandlerOptions, ElicitRequest, ElicitRequestSchema, ElicitResult, MCPClientOAuthCallbackConfig, MCPClientOAuthResult, MCPConnectionResult, MCPDiscoverResult, MCPServerOptions, McpAgent, McpAuthContext, McpClientOptions, RPCClientTransport, RPCClientTransportOptions, RPCServerTransport, RPCServerTransportOptions, RPC_DO_PREFIX, SSEEdgeClientTransport, StreamableHTTPEdgeClientTransport, TransportState, WorkerTransport, WorkerTransportOptions, createMcpHandler, experimental_createMcpHandler, getMcpAuthContext };
@@ -1,2 +1,2 @@
1
- import { a as genericObservability, i as channels, n as Observability, o as subscribe, r as ObservabilityEvent, t as ChannelEventMap } from "../index-BS_jL8MI.js";
1
+ import { a as genericObservability, i as channels, n as Observability, o as subscribe, r as ObservabilityEvent, t as ChannelEventMap } from "../index-D9AuAMOt.js";
2
2
  export { ChannelEventMap, Observability, ObservabilityEvent, channels, genericObservability, subscribe };
@@ -23,8 +23,7 @@ const channels = {
23
23
  lifecycle: channel("agents:lifecycle"),
24
24
  workflow: channel("agents:workflow"),
25
25
  mcp: channel("agents:mcp"),
26
- email: channel("agents:email"),
27
- workspace: channel("agents:workspace")
26
+ email: channel("agents:email")
28
27
  };
29
28
  /**
30
29
  * Map event type prefixes to their diagnostics channel.
@@ -37,7 +36,6 @@ function getChannel(type) {
37
36
  if (type === "rpc" || type.startsWith("rpc:")) return channels.rpc;
38
37
  if (type.startsWith("state:")) return channels.state;
39
38
  if (type.startsWith("email:")) return channels.email;
40
- if (type.startsWith("workspace:")) return channels.workspace;
41
39
  return channels.lifecycle;
42
40
  }
43
41
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["dcUnsubscribe"],"sources":["../../src/observability/index.ts"],"sourcesContent":["import {\n channel,\n subscribe as dcSubscribe,\n unsubscribe as dcUnsubscribe,\n type Channel\n} from \"node:diagnostics_channel\";\nimport type { AgentObservabilityEvent } from \"./agent\";\nimport type { MCPObservabilityEvent } from \"./mcp\";\nimport type { WorkspaceObservabilityEvent } from \"./workspace\";\n\n/**\n * Union of all observability event types from different domains\n */\nexport type ObservabilityEvent =\n | AgentObservabilityEvent\n | MCPObservabilityEvent\n | WorkspaceObservabilityEvent;\n\nexport interface Observability {\n /**\n * Emit an event for the Agent's observability implementation to handle.\n * @param event - The event to emit\n */\n emit(event: ObservabilityEvent): void;\n}\n\n/**\n * Diagnostics channels for agent observability.\n *\n * Events are published to named channels using the Node.js diagnostics_channel API.\n * By default, publishing to a channel with no subscribers is a no-op (zero overhead).\n *\n * To observe events, subscribe to the channels you care about:\n * ```ts\n * import { subscribe } from \"node:diagnostics_channel\";\n * subscribe(\"agents:rpc\", (event) => console.log(event));\n * ```\n *\n * In production, all published messages are automatically forwarded to\n * Tail Workers via `event.diagnosticsChannelEvents` — no subscription needed.\n */\nexport const channels = {\n state: channel(\"agents:state\"),\n rpc: channel(\"agents:rpc\"),\n message: channel(\"agents:message\"),\n schedule: channel(\"agents:schedule\"),\n lifecycle: channel(\"agents:lifecycle\"),\n workflow: channel(\"agents:workflow\"),\n mcp: channel(\"agents:mcp\"),\n email: channel(\"agents:email\"),\n workspace: channel(\"agents:workspace\")\n} as const;\n\n/**\n * Map event type prefixes to their diagnostics channel.\n */\nfunction getChannel(type: string): Channel {\n if (type.startsWith(\"mcp:\")) return channels.mcp;\n if (type.startsWith(\"workflow:\")) return channels.workflow;\n if (type.startsWith(\"schedule:\") || type.startsWith(\"queue:\"))\n return channels.schedule;\n if (type.startsWith(\"message:\") || type.startsWith(\"tool:\"))\n return channels.message;\n if (type === \"rpc\" || type.startsWith(\"rpc:\")) return channels.rpc;\n if (type.startsWith(\"state:\")) return channels.state;\n if (type.startsWith(\"email:\")) return channels.email;\n if (type.startsWith(\"workspace:\")) return channels.workspace;\n // connect, disconnect, destroy\n return channels.lifecycle;\n}\n\n/**\n * The default observability implementation.\n *\n * Publishes events to diagnostics_channel. Events are silent unless\n * a subscriber is registered or a Tail Worker is attached.\n */\nexport const genericObservability: Observability = {\n emit(event) {\n getChannel(event.type).publish(event);\n }\n};\n\n/**\n * Maps each channel key to the observability events it carries.\n */\nexport type ChannelEventMap = {\n state: Extract<ObservabilityEvent, { type: `state:${string}` }>;\n rpc: Extract<ObservabilityEvent, { type: \"rpc\" | `rpc:${string}` }>;\n message: Extract<\n ObservabilityEvent,\n { type: `message:${string}` | `tool:${string}` }\n >;\n schedule: Extract<\n ObservabilityEvent,\n { type: `schedule:${string}` | `queue:${string}` }\n >;\n lifecycle: Extract<\n ObservabilityEvent,\n { type: \"connect\" | \"disconnect\" | \"destroy\" }\n >;\n workflow: Extract<ObservabilityEvent, { type: `workflow:${string}` }>;\n mcp: Extract<ObservabilityEvent, { type: `mcp:${string}` }>;\n email: Extract<ObservabilityEvent, { type: `email:${string}` }>;\n workspace: Extract<ObservabilityEvent, { type: `workspace:${string}` }>;\n};\n\n/**\n * Subscribe to a typed observability channel.\n *\n * ```ts\n * import { subscribe } from \"agents/observability\";\n *\n * const unsub = subscribe(\"rpc\", (event) => {\n * console.log(event.payload.method); // fully typed\n * });\n * ```\n *\n * @returns A function that unsubscribes the callback.\n */\nexport function subscribe<K extends keyof ChannelEventMap>(\n channelKey: K,\n callback: (event: ChannelEventMap[K]) => void\n): () => void {\n const name = `agents:${channelKey}`;\n const handler = (message: unknown, _name: string | symbol) =>\n callback(message as ChannelEventMap[K]);\n dcSubscribe(name, handler);\n return () => dcUnsubscribe(name, handler);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAyCA,MAAa,WAAW;CACtB,OAAO,QAAQ,eAAe;CAC9B,KAAK,QAAQ,aAAa;CAC1B,SAAS,QAAQ,iBAAiB;CAClC,UAAU,QAAQ,kBAAkB;CACpC,WAAW,QAAQ,mBAAmB;CACtC,UAAU,QAAQ,kBAAkB;CACpC,KAAK,QAAQ,aAAa;CAC1B,OAAO,QAAQ,eAAe;CAC9B,WAAW,QAAQ,mBAAmB;CACvC;;;;AAKD,SAAS,WAAW,MAAuB;AACzC,KAAI,KAAK,WAAW,OAAO,CAAE,QAAO,SAAS;AAC7C,KAAI,KAAK,WAAW,YAAY,CAAE,QAAO,SAAS;AAClD,KAAI,KAAK,WAAW,YAAY,IAAI,KAAK,WAAW,SAAS,CAC3D,QAAO,SAAS;AAClB,KAAI,KAAK,WAAW,WAAW,IAAI,KAAK,WAAW,QAAQ,CACzD,QAAO,SAAS;AAClB,KAAI,SAAS,SAAS,KAAK,WAAW,OAAO,CAAE,QAAO,SAAS;AAC/D,KAAI,KAAK,WAAW,SAAS,CAAE,QAAO,SAAS;AAC/C,KAAI,KAAK,WAAW,SAAS,CAAE,QAAO,SAAS;AAC/C,KAAI,KAAK,WAAW,aAAa,CAAE,QAAO,SAAS;AAEnD,QAAO,SAAS;;;;;;;;AASlB,MAAa,uBAAsC,EACjD,KAAK,OAAO;AACV,YAAW,MAAM,KAAK,CAAC,QAAQ,MAAM;GAExC;;;;;;;;;;;;;;AAuCD,SAAgB,UACd,YACA,UACY;CACZ,MAAM,OAAO,UAAU;CACvB,MAAM,WAAW,SAAkB,UACjC,SAAS,QAA8B;AACzC,aAAY,MAAM,QAAQ;AAC1B,cAAaA,YAAc,MAAM,QAAQ"}
1
+ {"version":3,"file":"index.js","names":["dcUnsubscribe"],"sources":["../../src/observability/index.ts"],"sourcesContent":["import {\n channel,\n subscribe as dcSubscribe,\n unsubscribe as dcUnsubscribe,\n type Channel\n} from \"node:diagnostics_channel\";\nimport type { AgentObservabilityEvent } from \"./agent\";\nimport type { MCPObservabilityEvent } from \"./mcp\";\n\n/**\n * Union of all observability event types from different domains\n */\nexport type ObservabilityEvent =\n | AgentObservabilityEvent\n | MCPObservabilityEvent;\n\nexport interface Observability {\n /**\n * Emit an event for the Agent's observability implementation to handle.\n * @param event - The event to emit\n */\n emit(event: ObservabilityEvent): void;\n}\n\n/**\n * Diagnostics channels for agent observability.\n *\n * Events are published to named channels using the Node.js diagnostics_channel API.\n * By default, publishing to a channel with no subscribers is a no-op (zero overhead).\n *\n * To observe events, subscribe to the channels you care about:\n * ```ts\n * import { subscribe } from \"node:diagnostics_channel\";\n * subscribe(\"agents:rpc\", (event) => console.log(event));\n * ```\n *\n * In production, all published messages are automatically forwarded to\n * Tail Workers via `event.diagnosticsChannelEvents` — no subscription needed.\n */\nexport const channels = {\n state: channel(\"agents:state\"),\n rpc: channel(\"agents:rpc\"),\n message: channel(\"agents:message\"),\n schedule: channel(\"agents:schedule\"),\n lifecycle: channel(\"agents:lifecycle\"),\n workflow: channel(\"agents:workflow\"),\n mcp: channel(\"agents:mcp\"),\n email: channel(\"agents:email\")\n} as const;\n\n/**\n * Map event type prefixes to their diagnostics channel.\n */\nfunction getChannel(type: string): Channel {\n if (type.startsWith(\"mcp:\")) return channels.mcp;\n if (type.startsWith(\"workflow:\")) return channels.workflow;\n if (type.startsWith(\"schedule:\") || type.startsWith(\"queue:\"))\n return channels.schedule;\n if (type.startsWith(\"message:\") || type.startsWith(\"tool:\"))\n return channels.message;\n if (type === \"rpc\" || type.startsWith(\"rpc:\")) return channels.rpc;\n if (type.startsWith(\"state:\")) return channels.state;\n if (type.startsWith(\"email:\")) return channels.email;\n // connect, disconnect, destroy\n return channels.lifecycle;\n}\n\n/**\n * The default observability implementation.\n *\n * Publishes events to diagnostics_channel. Events are silent unless\n * a subscriber is registered or a Tail Worker is attached.\n */\nexport const genericObservability: Observability = {\n emit(event) {\n getChannel(event.type).publish(event);\n }\n};\n\n/**\n * Maps each channel key to the observability events it carries.\n */\nexport type ChannelEventMap = {\n state: Extract<ObservabilityEvent, { type: `state:${string}` }>;\n rpc: Extract<ObservabilityEvent, { type: \"rpc\" | `rpc:${string}` }>;\n message: Extract<\n ObservabilityEvent,\n { type: `message:${string}` | `tool:${string}` }\n >;\n schedule: Extract<\n ObservabilityEvent,\n { type: `schedule:${string}` | `queue:${string}` }\n >;\n lifecycle: Extract<\n ObservabilityEvent,\n { type: \"connect\" | \"disconnect\" | \"destroy\" }\n >;\n workflow: Extract<ObservabilityEvent, { type: `workflow:${string}` }>;\n mcp: Extract<ObservabilityEvent, { type: `mcp:${string}` }>;\n email: Extract<ObservabilityEvent, { type: `email:${string}` }>;\n};\n\n/**\n * Subscribe to a typed observability channel.\n *\n * ```ts\n * import { subscribe } from \"agents/observability\";\n *\n * const unsub = subscribe(\"rpc\", (event) => {\n * console.log(event.payload.method); // fully typed\n * });\n * ```\n *\n * @returns A function that unsubscribes the callback.\n */\nexport function subscribe<K extends keyof ChannelEventMap>(\n channelKey: K,\n callback: (event: ChannelEventMap[K]) => void\n): () => void {\n const name = `agents:${channelKey}`;\n const handler = (message: unknown, _name: string | symbol) =>\n callback(message as ChannelEventMap[K]);\n dcSubscribe(name, handler);\n return () => dcUnsubscribe(name, handler);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAuCA,MAAa,WAAW;CACtB,OAAO,QAAQ,eAAe;CAC9B,KAAK,QAAQ,aAAa;CAC1B,SAAS,QAAQ,iBAAiB;CAClC,UAAU,QAAQ,kBAAkB;CACpC,WAAW,QAAQ,mBAAmB;CACtC,UAAU,QAAQ,kBAAkB;CACpC,KAAK,QAAQ,aAAa;CAC1B,OAAO,QAAQ,eAAe;CAC/B;;;;AAKD,SAAS,WAAW,MAAuB;AACzC,KAAI,KAAK,WAAW,OAAO,CAAE,QAAO,SAAS;AAC7C,KAAI,KAAK,WAAW,YAAY,CAAE,QAAO,SAAS;AAClD,KAAI,KAAK,WAAW,YAAY,IAAI,KAAK,WAAW,SAAS,CAC3D,QAAO,SAAS;AAClB,KAAI,KAAK,WAAW,WAAW,IAAI,KAAK,WAAW,QAAQ,CACzD,QAAO,SAAS;AAClB,KAAI,SAAS,SAAS,KAAK,WAAW,OAAO,CAAE,QAAO,SAAS;AAC/D,KAAI,KAAK,WAAW,SAAS,CAAE,QAAO,SAAS;AAC/C,KAAI,KAAK,WAAW,SAAS,CAAE,QAAO,SAAS;AAE/C,QAAO,SAAS;;;;;;;;AASlB,MAAa,uBAAsC,EACjD,KAAK,OAAO;AACV,YAAW,MAAM,KAAK,CAAC,QAAQ,MAAM;GAExC;;;;;;;;;;;;;;AAsCD,SAAgB,UACd,YACA,UACY;CACZ,MAAM,OAAO,UAAU;CACvB,MAAM,WAAW,SAAkB,UACjC,SAAS,QAA8B;AACzC,aAAY,MAAM,QAAQ;AAC1B,cAAaA,YAAc,MAAM,QAAQ"}
package/dist/react.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Method, RPCMethod } from "./serializable.js";
2
2
  import { StreamOptions } from "./client.js";
3
- import { h as MCPServersState, r as Agent } from "./index-DBW341gU.js";
3
+ import { h as MCPServersState, r as Agent } from "./index-BOdpK2Ni.js";
4
4
  import { PartySocket } from "partysocket";
5
5
  import { usePartySocket } from "partysocket/react";
6
6
 
@@ -1,4 +1,4 @@
1
- import { r as Agent } from "./index-DBW341gU.js";
1
+ import { r as Agent } from "./index-BOdpK2Ni.js";
2
2
  import {
3
3
  S as WorkflowTrackingRow,
4
4
  _ as WorkflowPage,
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "durable objects"
10
10
  ],
11
11
  "type": "module",
12
- "version": "0.7.7",
12
+ "version": "0.7.8",
13
13
  "license": "MIT",
14
14
  "repository": {
15
15
  "directory": "packages/agents",
@@ -39,7 +39,6 @@
39
39
  "devDependencies": {
40
40
  "@ai-sdk/openai": "^3.0.41",
41
41
  "@ai-sdk/react": "^3.0.118",
42
- "@cloudflare/shell": "^0.0.2",
43
42
  "@cloudflare/workers-oauth-provider": "^0.3.0",
44
43
  "@types/react": "^19.2.14",
45
44
  "@types/yargs": "^17.0.35",
@@ -54,8 +53,7 @@
54
53
  "@ai-sdk/openai": "^3.0.0",
55
54
  "@ai-sdk/react": "^3.0.0",
56
55
  "@cloudflare/ai-chat": "^0.1.9",
57
- "@cloudflare/codemode": "^0.2.1",
58
- "@cloudflare/shell": "^0.0.2",
56
+ "@cloudflare/codemode": "^0.2.2",
59
57
  "@x402/core": "^2.0.0",
60
58
  "@x402/evm": "^2.0.0",
61
59
  "ai": "^6.0.0",
@@ -76,9 +74,6 @@
76
74
  "@cloudflare/codemode": {
77
75
  "optional": true
78
76
  },
79
- "@cloudflare/shell": {
80
- "optional": true
81
- },
82
77
  "@x402/core": {
83
78
  "optional": true
84
79
  },
@@ -185,11 +180,6 @@
185
180
  "types": "./dist/email.d.ts",
186
181
  "import": "./dist/email.js",
187
182
  "require": "./dist/email.js"
188
- },
189
- "./experimental/workspace": {
190
- "types": "./dist/experimental/workspace.d.ts",
191
- "import": "./dist/experimental/workspace.js",
192
- "require": "./dist/experimental/workspace.js"
193
183
  }
194
184
  },
195
185
  "publishConfig": {
@@ -1,273 +0,0 @@
1
- import { Command, CommandContext, CustomCommand, ExecResult, NetworkConfig, defineCommand } from "@cloudflare/shell";
2
-
3
- //#region src/experimental/workspace.d.ts
4
- /**
5
- * Workspace — durable file storage for any Agent.
6
- *
7
- * Hybrid storage:
8
- * - Files < threshold: stored inline in SQLite (fast, no external calls)
9
- * - Files ≥ threshold: metadata in SQLite, content in R2 (avoids row limit)
10
- *
11
- * Usage:
12
- * ```ts
13
- * import { Agent } from "agents";
14
- * import { Workspace } from "agents/experimental/workspace";
15
- *
16
- * class MyAgent extends Agent<Env> {
17
- * workspace = new Workspace(this, {
18
- * r2: this.env.WORKSPACE_FILES,
19
- * // r2Prefix defaults to this.name (the Durable Object ID)
20
- * });
21
- *
22
- * async onMessage(conn, msg) {
23
- * await this.workspace.writeFile("/hello.txt", "world");
24
- * const content = await this.workspace.readFile("/hello.txt");
25
- * }
26
- * }
27
- * ```
28
- *
29
- * R2 is optional — if the configured binding isn't present, all files are
30
- * stored inline regardless of size (with a warning for large files).
31
- *
32
- * @module agents/workspace
33
- */
34
- interface WorkspaceHost {
35
- sql: <T = Record<string, string | number | boolean | null>>(strings: TemplateStringsArray, ...values: (string | number | boolean | null)[]) => T[];
36
- /** Durable Object ID / name — used as the default R2 key prefix when r2Prefix is not set. Read lazily (not at construction time). */
37
- name?: string;
38
- }
39
- interface WorkspaceOptions {
40
- /** Namespace to isolate this workspace's tables (default: "default"). */
41
- namespace?: string;
42
- /** R2 bucket for large-file storage (optional). */
43
- r2?: R2Bucket;
44
- /** Prefix for R2 object keys. Defaults to `host.name` (the Durable Object ID) when omitted. */
45
- r2Prefix?: string;
46
- /** Byte threshold for spilling files to R2 (default: 1_500_000 = 1.5 MB). */
47
- inlineThreshold?: number;
48
- /** Bash execution limits (requires @cloudflare/shell). */
49
- bashLimits?: {
50
- maxCommandCount?: number;
51
- maxLoopIterations?: number;
52
- maxCallDepth?: number;
53
- };
54
- /** Custom commands available in every bash() call. */
55
- commands?: CustomCommand[];
56
- /** Environment variables available in every bash() call. */
57
- env?: Record<string, string>;
58
- /** Network configuration for curl (URL allow-list, methods, timeouts). */
59
- network?: NetworkConfig;
60
- /** Called when files/directories change. Wire to agent.broadcast() for real-time sync. */
61
- onChange?: (event: WorkspaceChangeEvent) => void;
62
- }
63
- type EntryType = "file" | "directory" | "symlink";
64
- type FileInfo = {
65
- path: string;
66
- name: string;
67
- type: EntryType;
68
- mimeType: string;
69
- size: number;
70
- createdAt: number;
71
- updatedAt: number;
72
- target?: string;
73
- };
74
- type FileStat = FileInfo;
75
- type BashResult = {
76
- stdout: string;
77
- stderr: string;
78
- exitCode: number;
79
- };
80
- interface BashOptions {
81
- cwd?: string;
82
- commands?: CustomCommand[];
83
- env?: Record<string, string>;
84
- network?: NetworkConfig;
85
- }
86
- /** @deprecated Use {@link BashOptions} instead. */
87
- type BashSessionOptions = BashOptions;
88
- type WorkspaceChangeType = "create" | "update" | "delete";
89
- type WorkspaceChangeEvent = {
90
- type: WorkspaceChangeType;
91
- path: string;
92
- entryType: EntryType;
93
- };
94
- declare class Workspace {
95
- private readonly host;
96
- private readonly namespace;
97
- private readonly tableName;
98
- private readonly indexName;
99
- private readonly r2;
100
- private readonly r2Prefix;
101
- private readonly threshold;
102
- private readonly bashLimits;
103
- private readonly commands;
104
- private readonly env;
105
- private readonly network;
106
- private readonly onChange;
107
- private initialized;
108
- private readonly sqlCache;
109
- /**
110
- * @param host - Any object with a `sql` tagged-template method (typically your Agent: `this`).
111
- * @param options - Optional configuration (namespace, R2 bucket, thresholds, etc.).
112
- *
113
- * ```ts
114
- * class MyAgent extends Agent<Env> {
115
- * workspace = new Workspace(this, {
116
- * r2: this.env.WORKSPACE_FILES,
117
- * // r2Prefix defaults to this.name (the Durable Object ID)
118
- * });
119
- * }
120
- * ```
121
- */
122
- constructor(host: WorkspaceHost, options?: WorkspaceOptions);
123
- private emit;
124
- private _observe;
125
- private sql;
126
- private ensureInit;
127
- private getR2;
128
- private resolveR2Prefix;
129
- private r2Key;
130
- private resolveSymlink;
131
- symlink(target: string, linkPath: string): void;
132
- readlink(path: string): string;
133
- lstat(path: string): FileStat | null;
134
- stat(path: string): FileStat | null;
135
- readFile(path: string): Promise<string | null>;
136
- readFileBytes(path: string): Promise<Uint8Array | null>;
137
- writeFileBytes(path: string, data: Uint8Array | ArrayBuffer, mimeType?: string): Promise<void>;
138
- writeFile(path: string, content: string, mimeType?: string): Promise<void>;
139
- readFileStream(path: string): Promise<ReadableStream<Uint8Array> | null>;
140
- writeFileStream(path: string, stream: ReadableStream<Uint8Array>, mimeType?: string): Promise<void>;
141
- appendFile(path: string, content: string, mimeType?: string): Promise<void>;
142
- deleteFile(path: string): Promise<boolean>;
143
- fileExists(path: string): boolean;
144
- exists(path: string): boolean;
145
- readDir(dir?: string, opts?: {
146
- limit?: number;
147
- offset?: number;
148
- }): FileInfo[];
149
- glob(pattern: string): FileInfo[];
150
- mkdir(path: string, opts?: {
151
- recursive?: boolean;
152
- }, _depth?: number): void;
153
- rm(path: string, opts?: {
154
- recursive?: boolean;
155
- force?: boolean;
156
- }): Promise<void>;
157
- cp(src: string, dest: string, opts?: {
158
- recursive?: boolean;
159
- }): Promise<void>;
160
- mv(src: string, dest: string, opts?: {
161
- recursive?: boolean;
162
- }): Promise<void>;
163
- diff(pathA: string, pathB: string): Promise<string>;
164
- diffContent(path: string, newContent: string): Promise<string>;
165
- private _resolveBashConfig;
166
- bash(command: string, options?: BashOptions): Promise<BashResult>;
167
- createBashSession(options?: BashOptions): BashSession;
168
- getWorkspaceInfo(): {
169
- fileCount: number;
170
- directoryCount: number;
171
- totalBytes: number;
172
- r2FileCount: number;
173
- };
174
- /** @internal */
175
- _getAllPaths(): string[];
176
- /** @internal */
177
- _updateModifiedAt(path: string, mtime: Date): void;
178
- private ensureParentDir;
179
- private deleteDescendants;
180
- }
181
- interface BashSessionInit {
182
- ws: Workspace;
183
- fs: WorkspaceFileSystem;
184
- bashLimits: {
185
- maxCommandCount: number;
186
- maxLoopIterations: number;
187
- maxCallDepth: number;
188
- };
189
- commands: CustomCommand[] | undefined;
190
- env: Record<string, string>;
191
- network: NetworkConfig | undefined;
192
- cwd: string;
193
- observe: (type: string, payload: Record<string, unknown>) => void;
194
- }
195
- declare class BashSession {
196
- private readonly _ws;
197
- private readonly _fs;
198
- private readonly _bashLimits;
199
- private readonly _customCommands;
200
- private readonly _networkConfig;
201
- private readonly _observe;
202
- private _currentCwd;
203
- private _currentEnv;
204
- private _closed;
205
- /** @internal — use workspace.createBashSession() instead */
206
- constructor(init: BashSessionInit);
207
- exec(command: string): Promise<BashResult>;
208
- get cwd(): string;
209
- get env(): Record<string, string>;
210
- get isClosed(): boolean;
211
- close(): void;
212
- [Symbol.dispose](): void;
213
- }
214
- interface FsStat {
215
- isFile: boolean;
216
- isDirectory: boolean;
217
- isSymbolicLink: boolean;
218
- mode: number;
219
- size: number;
220
- mtime: Date;
221
- }
222
- interface DirentEntry {
223
- name: string;
224
- isFile: boolean;
225
- isDirectory: boolean;
226
- isSymbolicLink: boolean;
227
- }
228
- type FileContent = string | Uint8Array;
229
- type BufferEncoding = "utf-8" | "utf8" | "ascii" | "base64" | "hex" | "latin1";
230
- type ReadFileOptions = {
231
- encoding?: BufferEncoding | null;
232
- };
233
- type WriteFileOptions = {
234
- encoding?: BufferEncoding;
235
- };
236
- type MkdirOptions = {
237
- recursive?: boolean;
238
- };
239
- type RmOptions = {
240
- recursive?: boolean;
241
- force?: boolean;
242
- };
243
- type CpOptions = {
244
- recursive?: boolean;
245
- };
246
- declare class WorkspaceFileSystem {
247
- private ws;
248
- constructor(ws: Workspace);
249
- readFile(path: string, _options?: ReadFileOptions | BufferEncoding): Promise<string>;
250
- readFileBuffer(path: string): Promise<Uint8Array>;
251
- writeFile(path: string, content: FileContent, _options?: WriteFileOptions | BufferEncoding): Promise<void>;
252
- appendFile(path: string, content: FileContent, _options?: WriteFileOptions | BufferEncoding): Promise<void>;
253
- exists(path: string): Promise<boolean>;
254
- stat(path: string): Promise<FsStat>;
255
- lstat(path: string): Promise<FsStat>;
256
- mkdir(path: string, options?: MkdirOptions): Promise<void>;
257
- readdir(path: string): Promise<string[]>;
258
- readdirWithFileTypes(path: string): Promise<DirentEntry[]>;
259
- rm(path: string, options?: RmOptions): Promise<void>;
260
- cp(src: string, dest: string, options?: CpOptions): Promise<void>;
261
- mv(src: string, dest: string): Promise<void>;
262
- resolvePath(base: string, path: string): string;
263
- getAllPaths(): string[];
264
- chmod(_path: string, _mode: number): Promise<void>;
265
- symlink(target: string, linkPath: string): Promise<void>;
266
- link(_existingPath: string, _newPath: string): Promise<void>;
267
- readlink(path: string): Promise<string>;
268
- realpath(path: string): Promise<string>;
269
- utimes(_path: string, _atime: Date, mtime: Date): Promise<void>;
270
- }
271
- //#endregion
272
- export { BashOptions, BashResult, BashSession, BashSessionOptions, type Command, type CommandContext, EntryType, type ExecResult, FileInfo, FileStat, type NetworkConfig, Workspace, WorkspaceChangeEvent, WorkspaceChangeType, WorkspaceHost, WorkspaceOptions, defineCommand };
273
- //# sourceMappingURL=workspace.d.ts.map