agents 0.7.7 → 0.7.9

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-B6xYRT3K.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
+ ): RPCClientTransport | SSEClientTransport | StreamableHTTPClientTransport;
711
711
  private tryConnect;
712
712
  private _capabilityErrorHandler;
713
713
  }
@@ -1672,6 +1672,24 @@ declare class Agent<
1672
1672
  * Override to provide default state values
1673
1673
  */
1674
1674
  initialState: State;
1675
+ /**
1676
+ * Stable key for Workers AI session affinity (prefix-cache optimization).
1677
+ *
1678
+ * Uses the Durable Object ID, which is globally unique across all agent
1679
+ * classes and stable for the lifetime of the instance. Pass this value as
1680
+ * the `sessionAffinity` option when creating a Workers AI model so that
1681
+ * requests from the same agent instance are routed to the same backend
1682
+ * replica, improving KV-prefix-cache hit rates across conversation turns.
1683
+ *
1684
+ * @example
1685
+ * ```typescript
1686
+ * const workersai = createWorkersAI({ binding: this.env.AI });
1687
+ * const model = workersai("@cf/meta/llama-3.3-70b-instruct-fp8-fast", {
1688
+ * sessionAffinity: this.sessionAffinity,
1689
+ * });
1690
+ * ```
1691
+ */
1692
+ get sessionAffinity(): string;
1675
1693
  /**
1676
1694
  * Current state of the Agent
1677
1695
  */
@@ -2837,4 +2855,4 @@ export {
2837
2855
  Schedule as y,
2838
2856
  MCPServerOptions as z
2839
2857
  };
2840
- //# sourceMappingURL=index-DBW341gU.d.ts.map
2858
+ //# sourceMappingURL=index-B6xYRT3K.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-B6xYRT3K.js";
38
38
  import {
39
39
  n as AgentsOAuthProvider,
40
40
  r as DurableObjectOAuthClientProvider,
package/dist/index.js CHANGED
@@ -212,6 +212,26 @@ function withAgentContext(method) {
212
212
  * @template State State type to store within the Agent
213
213
  */
214
214
  var Agent = class Agent extends Server {
215
+ /**
216
+ * Stable key for Workers AI session affinity (prefix-cache optimization).
217
+ *
218
+ * Uses the Durable Object ID, which is globally unique across all agent
219
+ * classes and stable for the lifetime of the instance. Pass this value as
220
+ * the `sessionAffinity` option when creating a Workers AI model so that
221
+ * requests from the same agent instance are routed to the same backend
222
+ * replica, improving KV-prefix-cache hit rates across conversation turns.
223
+ *
224
+ * @example
225
+ * ```typescript
226
+ * const workersai = createWorkersAI({ binding: this.env.AI });
227
+ * const model = workersai("@cf/meta/llama-3.3-70b-instruct-fp8-fast", {
228
+ * sessionAffinity: this.sessionAffinity,
229
+ * });
230
+ * ```
231
+ */
232
+ get sessionAffinity() {
233
+ return this.ctx.id.toString();
234
+ }
215
235
  /**
216
236
  * Current state of the Agent
217
237
  */