agents 0.7.6 → 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-WBy5hmm3.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,
@@ -2837,4 +2837,4 @@ export {
2837
2837
  Schedule as y,
2838
2838
  MCPServerOptions as z
2839
2839
  };
2840
- //# sourceMappingURL=index-WBy5hmm3.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-WBy5hmm3.js";
37
+ } from "./index-BOdpK2Ni.js";
38
38
  import {
39
39
  n as AgentsOAuthProvider,
40
40
  r as DurableObjectOAuthClientProvider,
package/dist/index.js CHANGED
@@ -1365,6 +1365,7 @@ var Agent = class Agent extends Server {
1365
1365
  `;
1366
1366
  if (existing.length > 0) {
1367
1367
  const row = existing[0];
1368
+ await this._scheduleNextAlarm();
1368
1369
  return {
1369
1370
  callback: row.callback,
1370
1371
  id: row.id,
@@ -1529,15 +1530,30 @@ var Agent = class Agent extends Server {
1529
1530
  */
1530
1531
  async _cf_keepAliveHeartbeat() {}
1531
1532
  async _scheduleNextAlarm() {
1532
- const result = this.sql`
1533
+ const nowMs = Date.now();
1534
+ const hungCutoffSeconds = Math.floor(nowMs / 1e3) - this._resolvedOptions.hungScheduleTimeoutSeconds;
1535
+ const readySchedules = this.sql`
1533
1536
  SELECT time FROM cf_agents_schedules
1534
- WHERE time >= ${Math.floor(Date.now() / 1e3)}
1537
+ WHERE type != 'interval'
1538
+ OR running = 0
1539
+ OR coalesce(execution_started_at, 0) <= ${hungCutoffSeconds}
1535
1540
  ORDER BY time ASC
1536
1541
  LIMIT 1
1537
1542
  `;
1538
- if (!result) return;
1543
+ const recoveringIntervals = this.sql`
1544
+ SELECT execution_started_at FROM cf_agents_schedules
1545
+ WHERE type = 'interval'
1546
+ AND running = 1
1547
+ AND coalesce(execution_started_at, 0) > ${hungCutoffSeconds}
1548
+ ORDER BY execution_started_at ASC
1549
+ LIMIT 1
1550
+ `;
1539
1551
  let nextTimeMs = null;
1540
- if (result.length > 0 && "time" in result[0]) nextTimeMs = result[0].time * 1e3;
1552
+ if (readySchedules.length > 0 && "time" in readySchedules[0]) nextTimeMs = Math.max(readySchedules[0].time * 1e3, nowMs + 1);
1553
+ if (recoveringIntervals.length > 0 && recoveringIntervals[0].execution_started_at !== null) {
1554
+ const recoveryTimeMs = (recoveringIntervals[0].execution_started_at + this._resolvedOptions.hungScheduleTimeoutSeconds) * 1e3;
1555
+ nextTimeMs = nextTimeMs === null ? recoveryTimeMs : Math.min(nextTimeMs, recoveryTimeMs);
1556
+ }
1541
1557
  if (nextTimeMs !== null) await this.ctx.storage.setAlarm(nextTimeMs);
1542
1558
  else await this.ctx.storage.deleteAlarm();
1543
1559
  }