agents 0.27.0 → 0.28.0
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/abortable-C1SpfVoi.js +21 -0
- package/dist/abortable-C1SpfVoi.js.map +1 -0
- package/dist/{agent-routing-Bhdbvf7s.d.ts → agent-routing-QDcchcQP.d.ts} +10 -15
- package/dist/agent-routing.d.ts +1 -1
- package/dist/agent-tool-types.d.ts +1 -1
- package/dist/{agent-tools-bJZwBMfq.d.ts → agent-tools-DHL2XI7u.d.ts} +2 -2
- package/dist/agent-tools.d.ts +1 -1
- package/dist/ai-ahruGw7e.d.ts +239 -0
- package/dist/{ai-sdk-OoGkFy3s.js → ai-sdk-Bdsf6mSA.js} +2 -2
- package/dist/{ai-sdk-OoGkFy3s.js.map → ai-sdk-Bdsf6mSA.js.map} +1 -1
- package/dist/browser/ai.d.ts +8 -227
- package/dist/browser/ai.js +259 -1
- package/dist/browser/ai.js.map +1 -0
- package/dist/browser/index.d.ts +56 -46
- package/dist/browser/index.js +4 -361
- package/dist/browser/{ai-sdk.d.ts → tools/ai-sdk.d.ts} +7 -7
- package/dist/browser/{ai-sdk.js → tools/ai-sdk.js} +5 -4
- package/dist/browser/tools/ai-sdk.js.map +1 -0
- package/dist/browser/tools/pi.d.ts +111 -0
- package/dist/browser/tools/pi.js +119 -0
- package/dist/browser/tools/pi.js.map +1 -0
- package/dist/browser/{tanstack-ai.d.ts → tools/tanstack-ai.d.ts} +39 -37
- package/dist/browser/{tanstack-ai.js → tools/tanstack-ai.js} +73 -59
- package/dist/browser/tools/tanstack-ai.js.map +1 -0
- package/dist/browser-CEdNlsaD.js +481 -0
- package/dist/browser-CEdNlsaD.js.map +1 -0
- package/dist/{browser-tmkcAAI3.d.ts → browser-D30VlpcA.d.ts} +63 -37
- package/dist/{browser-tool-CBqs6hqa.js → browser-tool-4iomavs_.js} +145 -49
- package/dist/browser-tool-4iomavs_.js.map +1 -0
- package/dist/{browser-tool-Bn-nzJQI.d.ts → browser-tool-vtrPOV8e.d.ts} +24 -5
- package/dist/{capability-B4WbF81e.js → capability-DBAKc6UZ.js} +1 -3
- package/dist/capability-DBAKc6UZ.js.map +1 -0
- package/dist/{capability-runner-O5VbQzqg.d.ts → capability-runner-BiVUtjqC.d.ts} +1 -7
- package/dist/chat/index.d.ts +4 -4
- package/dist/chat/index.js +1 -1
- package/dist/chat-sdk/index.d.ts +1 -1
- package/dist/chat-sdk/index.js +1 -1
- package/dist/{client-DS3Dz9l0.d.ts → client-BGIQKJhX.d.ts} +2 -2
- package/dist/{client-1tEQ1Oqz.js → client-BnYbNT3z.js} +3 -4
- package/dist/client-BnYbNT3z.js.map +1 -0
- package/dist/client.d.ts +1 -1
- package/dist/{connector-58XDGvc3.js → connector-CtZylXdk.js} +3 -603
- package/dist/connector-CtZylXdk.js.map +1 -0
- package/dist/{connector-Cl-VqPmA.d.ts → connector-DEXzVoaY.d.ts} +9 -374
- package/dist/{conversations-DH0ut_8n.d.ts → conversations-FjHDRZyD.d.ts} +4 -4
- package/dist/{current-agent-C07C5o5Y.d.ts → current-agent-CKgT5d1O.d.ts} +3 -5
- package/dist/current-agent-DhoDkSnH.js.map +1 -1
- package/dist/{durable-object-lifecycle-DRqp475_.d.ts → durable-object-lifecycle-DOI_bzCH.d.ts} +2 -2
- package/dist/experimental/channels/index.d.ts +2 -2
- package/dist/experimental/channels/index.js +2 -2
- package/dist/experimental/channels/web/index.d.ts +2 -2
- package/dist/experimental/channels/web/index.js +1 -1
- package/dist/{gateway-BDC07gYO.d.ts → gateway-BFO6vRDn.d.ts} +2 -2
- package/dist/harness/ai-sdk/index.d.ts +2 -2
- package/dist/harness/ai-sdk/index.js +1 -1
- package/dist/harness/container/index.d.ts +2 -2
- package/dist/harness/container/index.js +3 -3
- package/dist/harness/opencode/index.d.ts +1 -1
- package/dist/harness/opencode/index.js +2 -2
- package/dist/harness/pi/index.d.ts +2 -2
- package/dist/harness/pi/index.js +3 -3
- package/dist/harness/store/index.d.ts +1 -1
- package/dist/harness/store/index.js +1 -1
- package/dist/harness/think/index.d.ts +2 -2
- package/dist/harness/think/index.js +363 -171
- package/dist/harness/think/index.js.map +1 -1
- package/dist/{index-D0A5tbWu.d.ts → index-BEL3ZV-s.d.ts} +2 -6
- package/dist/{index-Ib_4dwOo.d.ts → index-CBt8oRJt.d.ts} +3 -5
- package/dist/index.d.ts +4 -4
- package/dist/index.js +2 -2
- package/dist/input-schema-BQykTEp_.js +20 -0
- package/dist/input-schema-BQykTEp_.js.map +1 -0
- package/dist/{input-schema-DNrpTu49.js → input-schema-D2QAtHZH.js} +3 -3
- package/dist/input-schema-D2QAtHZH.js.map +1 -0
- package/dist/internal_context.d.ts +1 -1
- package/dist/lifecycle/index.d.ts +3 -3
- package/dist/lifecycle/index.js +2 -2
- package/dist/{lifecycle-CFu6OV03.js → lifecycle-DGorpAmA.js} +2 -4
- package/dist/lifecycle-DGorpAmA.js.map +1 -0
- package/dist/mcp/client/index.d.ts +1 -1
- package/dist/mcp/client/index.js +1 -1
- package/dist/mcp/index.d.ts +1 -1
- package/dist/mcp/index.js +2 -2
- package/dist/models/ai-sdk/index.js +1 -1
- package/dist/models/opencode/index.js +1 -1
- package/dist/models/pi-ai/index.js +1 -1
- package/dist/{options-pwTNq9z6.d.ts → options-CiIsJHXR.d.ts} +2 -6
- package/dist/queue/index.d.ts +1 -1
- package/dist/queue/index.js +1 -1
- package/dist/{queue-BB-zfIYF.js → queue-CcIjVYTE.js} +2 -2
- package/dist/{queue-BB-zfIYF.js.map → queue-CcIjVYTE.js.map} +1 -1
- package/dist/react.d.ts +2 -2
- package/dist/routing/index.d.ts +2 -2
- package/dist/routing/index.js +1 -1
- package/dist/{scheduler-CrFCnv_J.d.ts → scheduler-BCLESHSC.d.ts} +2 -12
- package/dist/{scheduler-DZ3xQfeK.js → scheduler-FIHv2-kJ.js} +2 -4
- package/dist/scheduler-FIHv2-kJ.js.map +1 -0
- package/dist/schedules/index.d.ts +1 -1
- package/dist/schedules/index.js +1 -1
- package/dist/serializable.d.ts +1 -1
- package/dist/session-store-Do4xkDcf.js +606 -0
- package/dist/session-store-Do4xkDcf.js.map +1 -0
- package/dist/session-store-DoPY12xM.d.ts +383 -0
- package/dist/sessions/index.d.ts +1 -1
- package/dist/sessions/index.js +1 -1
- package/dist/{sessions-B9pNuxdT.js → sessions-_vN5BEZX.js} +2 -2
- package/dist/{sessions-B9pNuxdT.js.map → sessions-_vN5BEZX.js.map} +1 -1
- package/dist/{src-DgCbZtIR.js → src-CQxJFv4l.js} +8 -8
- package/dist/src-CQxJFv4l.js.map +1 -0
- package/dist/state/index.d.ts +1 -1
- package/dist/state/index.js +1 -3
- package/dist/state/index.js.map +1 -1
- package/dist/{store-DLeqKuj3.d.ts → store-BKM4Xm9M.d.ts} +23 -1
- package/dist/{store-vgcPYo8K.js → store-CslVzfN7.js} +28 -2
- package/dist/store-CslVzfN7.js.map +1 -0
- package/dist/streams/index.d.ts +1 -1
- package/dist/streams/index.js +1 -1
- package/dist/{streams-CITClVer.js → streams-lsHMJhRW.js} +2 -2
- package/dist/{streams-CITClVer.js.map → streams-lsHMJhRW.js.map} +1 -1
- package/dist/{streams-fbG61qM8.d.ts → streams-vrCtbUIn.d.ts} +2 -2
- package/dist/sub-routing.d.ts +1 -1
- package/dist/tasks/index.d.ts +1 -1
- package/dist/tasks/index.js +1 -1
- package/dist/{tasks-CkTZNaV1.js → tasks-BN_5AWqI.js} +2 -2
- package/dist/{tasks-CkTZNaV1.js.map → tasks-BN_5AWqI.js.map} +1 -1
- package/dist/{tasks-PtlB4Uyn.d.ts → tasks-E89KdwkS.d.ts} +2 -2
- package/dist/{tool-BPJEbwaX.d.ts → tool-CTp72Jb_.d.ts} +4 -4
- package/dist/tool-CxKsvxjm.js +1126 -0
- package/dist/tool-CxKsvxjm.js.map +1 -0
- package/dist/tool-DoVberpN.d.ts +301 -0
- package/dist/{tool-3PA8xjB_.js → tool-cQRkwSZZ.js} +6 -17
- package/dist/tool-cQRkwSZZ.js.map +1 -0
- package/dist/tool-helpers-O5BDVEAY.js +58 -0
- package/dist/tool-helpers-O5BDVEAY.js.map +1 -0
- package/dist/voice/index.d.ts +2 -2
- package/dist/web/fetch/index.d.ts +89 -0
- package/dist/web/fetch/index.js +20 -0
- package/dist/web/fetch/index.js.map +1 -0
- package/dist/web/fetch/tools/ai-sdk.d.ts +80 -0
- package/dist/web/fetch/tools/ai-sdk.js +47 -0
- package/dist/web/fetch/tools/ai-sdk.js.map +1 -0
- package/dist/web/fetch/tools/pi.d.ts +84 -0
- package/dist/web/fetch/tools/pi.js +88 -0
- package/dist/web/fetch/tools/pi.js.map +1 -0
- package/dist/web/fetch/tools/tanstack-ai.d.ts +78 -0
- package/dist/web/fetch/tools/tanstack-ai.js +45 -0
- package/dist/web/fetch/tools/tanstack-ai.js.map +1 -0
- package/dist/{websearch → web/search}/index.d.ts +1 -1
- package/dist/{websearch → web/search}/index.js +1 -1
- package/dist/{websearch → web/search}/tools/ai-sdk.d.ts +2 -2
- package/dist/{websearch → web/search}/tools/ai-sdk.js +3 -3
- package/dist/web/search/tools/ai-sdk.js.map +1 -0
- package/dist/{websearch → web/search}/tools/pi.d.ts +3 -3
- package/dist/{websearch → web/search}/tools/pi.js +2 -2
- package/dist/web/search/tools/pi.js.map +1 -0
- package/dist/{websearch → web/search}/tools/tanstack-ai.d.ts +2 -2
- package/dist/{websearch → web/search}/tools/tanstack-ai.js +3 -3
- package/dist/web/search/tools/tanstack-ai.js.map +1 -0
- package/dist/websockets/index.d.ts +2 -2
- package/dist/websockets/index.js +1 -1
- package/dist/{websockets-CmENGb-Z.js → websockets-C3zy8YR0.js} +3 -5
- package/dist/websockets-C3zy8YR0.js.map +1 -0
- package/dist/workflow-types.d.ts +1 -1
- package/dist/workflows.d.ts +1 -1
- package/dist/workflows.js +1 -1
- package/docs/browse-the-web.md +26 -1
- package/docs/fetch-the-web.md +276 -0
- package/docs/harnesses/pi.md +25 -0
- package/docs/index.md +99 -76
- package/docs/lifecycle.md +2 -3
- package/docs/queue.md +2 -3
- package/docs/scheduling.md +2 -6
- package/docs/search-the-web.md +2 -0
- package/package.json +44 -19
- package/dist/ai-fm7xx1BK.js +0 -312
- package/dist/ai-fm7xx1BK.js.map +0 -1
- package/dist/browser/ai-sdk.js.map +0 -1
- package/dist/browser/index.js.map +0 -1
- package/dist/browser/tanstack-ai.js.map +0 -1
- package/dist/browser-tool-CBqs6hqa.js.map +0 -1
- package/dist/capability-B4WbF81e.js.map +0 -1
- package/dist/client-1tEQ1Oqz.js.map +0 -1
- package/dist/connector-58XDGvc3.js.map +0 -1
- package/dist/input-schema-DNrpTu49.js.map +0 -1
- package/dist/lifecycle-CFu6OV03.js.map +0 -1
- package/dist/scheduler-DZ3xQfeK.js.map +0 -1
- package/dist/src-DgCbZtIR.js.map +0 -1
- package/dist/store-vgcPYo8K.js.map +0 -1
- package/dist/tool-3PA8xjB_.js.map +0 -1
- package/dist/websearch/tools/ai-sdk.js.map +0 -1
- package/dist/websearch/tools/pi.js.map +0 -1
- package/dist/websearch/tools/tanstack-ai.js.map +0 -1
- package/dist/websockets-CmENGb-Z.js.map +0 -1
package/dist/queue/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
d as LifecycleRouteContext,
|
|
4
4
|
s as LifecycleCapability,
|
|
5
5
|
v as LifecycleJobOutcome
|
|
6
|
-
} from "../capability-runner-
|
|
6
|
+
} from "../capability-runner-BiVUtjqC.js";
|
|
7
7
|
import { t as RetryOptions } from "../retries-CV6AkXmQ.js";
|
|
8
8
|
import {
|
|
9
9
|
a as QueuePayload,
|
package/dist/queue/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as Queue } from "../queue-
|
|
1
|
+
import { t as Queue } from "../queue-CcIjVYTE.js";
|
|
2
2
|
export { Queue };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { i as _classPrivateFieldInitSpec, n as _classPrivateFieldSet2, r as _assertClassBrand, t as _classPrivateFieldGet2 } from "./classPrivateFieldGet2-DZBYAB34.js";
|
|
2
2
|
import { t as _classPrivateMethodInitSpec } from "./classPrivateMethodInitSpec-qMjJ6sHQ.js";
|
|
3
|
-
import { t as LifecycleCapability } from "./capability-
|
|
3
|
+
import { t as LifecycleCapability } from "./capability-DBAKc6UZ.js";
|
|
4
4
|
import { isDurableObjectCodeUpdateReset, isPlatformFailure, resolveRetryConfig, tryN, validateRetryOptions } from "./retries.js";
|
|
5
5
|
//#region src/queue/queue.ts
|
|
6
6
|
/**
|
|
@@ -403,4 +403,4 @@ function _emit(type, payload) {
|
|
|
403
403
|
//#endregion
|
|
404
404
|
export { setQueueCallbackResolver as n, Queue as t };
|
|
405
405
|
|
|
406
|
-
//# sourceMappingURL=queue-
|
|
406
|
+
//# sourceMappingURL=queue-CcIjVYTE.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queue-BB-zfIYF.js","names":[],"sources":["../src/queue/queue.ts"],"sourcesContent":["/**\n * Lifecycle background-work vocabulary. Queue validates items, resolves\n * named callbacks, and pushes jobs due immediately into the Lifecycle-owned\n * job queue; Lifecycle runs the alarm event loop, retry policy, and physical\n * alarm arming. Queue owns no storage of its own — each item is one job\n * whose `fn` is the callback name and whose payload carries the item's\n * payload and owner.\n */\n\nimport {\n LifecycleCapability,\n type LifecycleRouteAddress,\n type LifecycleRouteContext\n} from \"../lifecycle/capability\";\nimport type {\n LifecycleJob,\n LifecycleJobContext,\n LifecycleJobOutcome\n} from \"../lifecycle/job-queue\";\nimport {\n isDurableObjectCodeUpdateReset,\n isPlatformFailure,\n resolveRetryConfig,\n tryN,\n validateRetryOptions\n} from \"../retries\";\nimport type { RetryOptions } from \"../retries\";\nimport type { QueueEventType, QueueOptions } from \"./options\";\nimport type {\n QueueCallbacks,\n QueueCriteria,\n QueueHandlers,\n QueueItem,\n QueuePayload,\n QueuePushOptions,\n QueueStorageRow\n} from \"./types\";\n\n/** A resolved fallback handler for a callback name outside the registered map. */\ntype ResolvedQueueCallback = (\n payload: unknown,\n item: QueueItem<unknown>\n) => unknown;\n\nconst queueCallbackResolvers = new WeakMap<\n object,\n (name: string) => ResolvedQueueCallback | undefined\n>();\n\n/**\n * @internal Supply a composition-root fallback for callback names outside the\n * registered map. Agent uses this to keep its historical name-based queue\n * API (`this.queue(\"methodName\", payload)`) working: the resolver looks the\n * method up on the Agent, and the resolved handler still runs inside the\n * Lifecycle host boundary.\n */\nexport function setQueueCallbackResolver(\n queue: Queue<never>,\n resolver: (name: string) => ResolvedQueueCallback | undefined\n): void {\n queueCallbackResolvers.set(queue, resolver);\n}\n\nconst QUEUE_SCHEMA_VERSION_KEY = \"cf_agents:queue_schema_version\";\n/** Version 1: queue items live in the Lifecycle job queue. */\nconst CURRENT_QUEUE_SCHEMA_VERSION = 1;\n\nconst DEFAULT_RETRY: Required<RetryOptions> = {\n maxAttempts: 3,\n baseDelayMs: 100,\n maxDelayMs: 3000\n};\n\n/** What a Queue job's payload carries: the item payload and its owner. */\ntype QueueJobPayload = {\n readonly payload: unknown;\n readonly owner_path: string | null;\n readonly owner_path_key: string | null;\n};\n\ntype QueueRouteMessage =\n | {\n readonly type: \"push\";\n readonly callback: string;\n readonly payload: unknown;\n readonly options?: QueuePushOptions;\n }\n | { readonly type: \"get\" | \"cancel\"; readonly id: string }\n | { readonly type: \"list\"; readonly criteria?: QueueCriteria }\n | { readonly type: \"cancelAll\"; readonly callback?: string }\n | {\n readonly type: \"dispatch\";\n readonly item: QueueItem<unknown>;\n };\n\nfunction isQueueJobPayload(value: unknown): value is QueueJobPayload {\n // `payload` is absent after a JSON round trip when the item carried none.\n return typeof value === \"object\" && value !== null && \"owner_path\" in value;\n}\n\n/**\n * Durable background work for a Lifecycle Object.\n *\n * Register callbacks in the constructor and install the instance with\n * `Lifecycle.use()`. Each pushed item becomes a job due immediately in the\n * Lifecycle job queue; Lifecycle owns the physical alarm and the alarm event\n * loop, drives items one at a time in push order, retries a throwing\n * callback per its retry policy, and Queue runs registered callbacks through\n * Lifecycle's host invocation boundary. An item that still fails after its\n * last attempt is dropped after `queue:error` and the `onError` hook.\n *\n * Items survive the Durable Object leaving memory: an isolate that dies mid\n * callback wakes again on the Lifecycle deadman alarm and resumes the queue.\n * Callbacks should therefore be idempotent.\n *\n * @experimental The API surface may change before stabilizing.\n */\nexport class Queue<\n Handlers extends QueueHandlers = QueueCallbacks\n> extends LifecycleCapability {\n readonly #handlers: QueueHandlers;\n readonly #retryDefaults: Required<RetryOptions>;\n readonly #onError: ((error: unknown) => void | Promise<void>) | undefined;\n /**\n * Last due time handed to a job. The Lifecycle driver dispatches due jobs\n * in due-time order, so pushes get strictly increasing times to keep push\n * order (FIFO) even within one millisecond. Seeded from the persisted\n * queue tail on first use so a fresh instance never sorts a new item ahead\n * of items an earlier instance already queued.\n */\n #lastTime: number | null = null;\n\n /**\n * Create a durable Queue.\n *\n * @param options - Registered callbacks plus optional retry and error\n * policy. Registering `callbacks` types {@link push} against the map —\n * names and payloads are checked where the handlers are declared and where\n * they are pushed. Names outside the map are rejected unless a\n * composition-root resolver supplies them — the internal aperture behind\n * `Agent`'s name-based queue API.\n */\n constructor(options: QueueOptions<Handlers> = {}) {\n super(\"queue\");\n this.#handlers = options.callbacks ?? {};\n // Retry defaults are resolved, not validated, here: invalid defaults\n // surface per execution as queue:error instead of bricking the object at\n // construction. Per-item retry overrides are validated when pushed.\n this.#retryDefaults = resolveRetryConfig(options.retry, DEFAULT_RETRY);\n this.#onError = options.onError;\n }\n\n // ── Lifecycle capability hooks ───────────────────────────────────────────\n\n /** Migrate legacy `cf_agents_queues` rows into the Lifecycle job queue. */\n async onStart(): Promise<void> {\n const storage = this.lifecycle.storage;\n const version = (await storage.get<number>(QUEUE_SCHEMA_VERSION_KEY)) ?? 0;\n if (version >= CURRENT_QUEUE_SCHEMA_VERSION) return;\n\n await this.#migrateLegacyQueueTable(storage);\n await storage.put(QUEUE_SCHEMA_VERSION_KEY, CURRENT_QUEUE_SCHEMA_VERSION);\n }\n\n /**\n * Move every `cf_agents_queues` row into the job queue and drop the\n * table. Idempotent: a missing table means a fresh object or a completed\n * migration. Rows keep their insertion order.\n *\n * TEMPORARY: one-shot upgrade path for objects that had queued items when\n * this release landed. Remove in the next minor release (with the schema\n * version bump that gates it), once every deployed object has migrated.\n */\n async #migrateLegacyQueueTable(storage: DurableObjectStorage): Promise<void> {\n const tables = storage.sql\n .exec(\n \"SELECT name FROM sqlite_master WHERE type='table' AND name='cf_agents_queues'\"\n )\n .toArray();\n if (tables.length === 0) return;\n\n const rows = storage.sql\n .exec(\"SELECT * FROM cf_agents_queues ORDER BY created_at ASC, rowid ASC\")\n .toArray() as unknown as QueueStorageRow[];\n for (const row of rows) {\n let payload: unknown;\n try {\n payload =\n typeof row.payload === \"string\" ? JSON.parse(row.payload) : undefined;\n } catch (error) {\n console.error(\n `Skipping queue item \"${row.id}\" during job-queue migration: ` +\n \"its payload is not valid JSON\",\n error\n );\n continue;\n }\n let retry: RetryOptions | undefined;\n try {\n retry =\n typeof row.retry_options === \"string\"\n ? (JSON.parse(row.retry_options) as RetryOptions)\n : undefined;\n } catch {\n retry = undefined;\n }\n await this.lifecycle.jobs.push({\n id: row.id,\n fn: row.callback,\n time: this.#nextTime(),\n payload: {\n payload,\n owner_path: null,\n owner_path_key: null\n } satisfies QueueJobPayload,\n retry: resolveRetryConfig(retry, this.#retryDefaults)\n });\n }\n storage.sql.exec(\"DROP TABLE cf_agents_queues\");\n }\n\n /** Drive one due item dispatched by the Lifecycle event loop. */\n async onJob(\n context: LifecycleJobContext\n ): Promise<LifecycleJobOutcome | void> {\n const { job, attempt } = context;\n if (!isQueueJobPayload(job.payload)) {\n console.error(`Malformed queue item ${job.id}; dropping it`);\n return undefined;\n }\n const item = this.#jobToItem(job, job.payload);\n\n if (attempt > 1) {\n this.#emit(\"queue:retry\", {\n callback: job.fn,\n id: job.id,\n attempt,\n maxAttempts: resolveRetryConfig(job.retry, this.#retryDefaults)\n .maxAttempts\n });\n }\n\n if (job.payload.owner_path) {\n // A routed item executes inside its owning Lifecycle; retries run\n // there too, so this dispatch is a single routed attempt.\n try {\n await this.lifecycle.routes.to(\n {\n key: job.payload.owner_path_key ?? job.payload.owner_path,\n data: job.payload.owner_path\n },\n { type: \"dispatch\", item } satisfies QueueRouteMessage\n );\n } catch (error) {\n if (isPlatformFailure(error)) {\n // Preserve the item; Lifecycle defers platform-class failures to\n // a fresh invocation or the memory-limit breaker.\n throw error;\n }\n console.error(`error dispatching queue callback \"${job.fn}\"`, error);\n this.#emit(\"queue:error\", {\n callback: job.fn,\n id: job.id,\n error: error instanceof Error ? error.message : String(error),\n attempts: 0\n });\n try {\n await this.#onError?.(error);\n } catch {\n // swallow onError errors\n }\n // Leave the item due so a later alarm cycle can retry dispatch, for\n // example once a transport can resolve its owner again.\n return \"yield\";\n }\n return undefined;\n }\n\n const handler = this.#resolveCallback(job.fn);\n if (!handler) {\n console.error(`callback ${job.fn} not found`);\n return undefined;\n }\n await this.lifecycle.runInHostContext(() => handler(item.payload, item));\n return undefined;\n }\n\n /** Observe one item's terminal application failure; the item is dropped. */\n async onJobError(\n context: LifecycleJobContext,\n error: unknown\n ): Promise<LifecycleJobOutcome | void> {\n const { job } = context;\n const { maxAttempts } = resolveRetryConfig(job.retry, this.#retryDefaults);\n console.error(\n `queue callback \"${job.fn}\" failed after ${maxAttempts} attempts`,\n error\n );\n this.#emit(\"queue:error\", {\n callback: job.fn,\n id: job.id,\n error: error instanceof Error ? error.message : String(error),\n attempts: maxAttempts\n });\n try {\n await this.#onError?.(error);\n } catch {\n // swallow onError errors\n }\n return undefined;\n }\n\n /** Handle Queue protocol messages routed by another Lifecycle. */\n async onRoute(context: LifecycleRouteContext): Promise<unknown> {\n const message = context.payload as QueueRouteMessage;\n const owner = context.source ?? null;\n switch (message.type) {\n case \"push\":\n return this.#insert(\n owner,\n message.callback,\n message.payload,\n message.options\n );\n case \"get\":\n return this.#getForOwner(owner, message.id);\n case \"list\":\n return this.#listForOwner(owner, message.criteria);\n case \"cancel\":\n return this.#cancelForOwner(owner, message.id);\n case \"cancelAll\":\n return this.#cancelAllForOwner(owner, message.callback);\n case \"dispatch\":\n await this.#executeRouted(message.item);\n return true;\n default:\n throw new Error(\"Unknown routed Queue message\");\n }\n }\n\n /**\n * Execute a routed item locally with the historical retry handling. Runs\n * on the owning (facet) Queue, outside the root's event loop, so it applies\n * its own in-process retry budget. Platform-class failures re-throw so the\n * root preserves the item and the durable alarm retries on a fresh\n * invocation.\n */\n async #executeRouted(item: QueueItem<unknown>): Promise<void> {\n const handler = this.#resolveCallback(item.callback);\n if (!handler) {\n console.error(`callback ${item.callback} not found`);\n return;\n }\n const { maxAttempts, baseDelayMs, maxDelayMs } = resolveRetryConfig(\n item.retry,\n this.#retryDefaults\n );\n try {\n await tryN(\n maxAttempts,\n async (attempt) => {\n if (attempt > 1) {\n this.#emit(\"queue:retry\", {\n callback: item.callback,\n id: item.id,\n attempt,\n maxAttempts\n });\n }\n await this.lifecycle.runInHostContext(() =>\n handler(item.payload, item)\n );\n },\n {\n baseDelayMs,\n maxDelayMs,\n shouldRetry: (error) => !isDurableObjectCodeUpdateReset(error)\n }\n );\n } catch (error) {\n if (isPlatformFailure(error)) {\n throw error;\n }\n console.error(\n `queue callback \"${item.callback}\" failed after ${maxAttempts} attempts`,\n error\n );\n this.#emit(\"queue:error\", {\n callback: item.callback,\n id: item.id,\n error: error instanceof Error ? error.message : String(error),\n attempts: maxAttempts\n });\n try {\n await this.#onError?.(error);\n } catch {\n // swallow onError errors\n }\n }\n }\n\n // ── Queue API ────────────────────────────────────────────────────────────\n\n /**\n * Push one item for a registered callback. The item is due immediately;\n * the Lifecycle alarm event loop runs it in push order after this call\n * returns.\n *\n * Once the Lifecycle has started (and this Queue is not routed through\n * another Lifecycle), the item row is written synchronously before this\n * method's promise is even returned, so a caller may pair a push with its\n * own writes in one synchronous block — the item then commits atomically\n * with them.\n */\n async push<Name extends keyof Handlers & string>(\n callback: Name,\n payload?: QueuePayload<Handlers[Name]>,\n options?: QueuePushOptions\n ): Promise<QueueItem<QueuePayload<Handlers[Name]>>> {\n if (this.lifecycle.status() !== \"started\") await this.lifecycle.ready();\n this.#validatePush(callback, options);\n const item = this.lifecycle.routes.source\n ? ((await this.lifecycle.routes.toRoot({\n type: \"push\",\n callback,\n payload,\n options\n } satisfies QueueRouteMessage)) as QueueItem<\n QueuePayload<Handlers[Name]>\n >)\n : await this.#insert<QueuePayload<Handlers[Name]>>(\n null,\n callback,\n payload,\n options\n );\n this.#emit(\"queue:create\", { callback, id: item.id });\n return item;\n }\n\n /** Cancel one pending item. Returns false when no item matched. */\n async cancel(id: string): Promise<boolean> {\n await this.lifecycle.ready();\n if (this.lifecycle.routes.source) {\n return (await this.lifecycle.routes.toRoot({\n type: \"cancel\",\n id\n } satisfies QueueRouteMessage)) as boolean;\n }\n return this.#cancelForOwner(null, id);\n }\n\n /** Cancel every pending item, or every item for one callback. Returns the count. */\n async cancelAll(callback?: string): Promise<number> {\n await this.lifecycle.ready();\n if (this.lifecycle.routes.source) {\n return (await this.lifecycle.routes.toRoot({\n type: \"cancelAll\",\n callback\n } satisfies QueueRouteMessage)) as number;\n }\n return this.#cancelAllForOwner(null, callback);\n }\n\n /** Read one pending item. */\n async get<T = unknown>(id: string): Promise<QueueItem<T> | undefined> {\n await this.lifecycle.ready();\n if (this.lifecycle.routes.source) {\n return (await this.lifecycle.routes.toRoot({\n type: \"get\",\n id\n } satisfies QueueRouteMessage)) as QueueItem<T> | undefined;\n }\n return this.#getForOwner<T>(null, id);\n }\n\n /** List pending items in push order, optionally filtered by callback. */\n async list<T = unknown>(criteria?: QueueCriteria): Promise<QueueItem<T>[]> {\n await this.lifecycle.ready();\n if (this.lifecycle.routes.source) {\n return (await this.lifecycle.routes.toRoot({\n type: \"list\",\n criteria\n } satisfies QueueRouteMessage)) as QueueItem<T>[];\n }\n return this.#listForOwner<T>(null, criteria);\n }\n\n // ── Internals ────────────────────────────────────────────────────────────\n\n #validatePush(callback: string, options?: QueuePushOptions): void {\n if (typeof callback !== \"string\") {\n throw new Error(\"Callback must be a string\");\n }\n if (!this.#hasCallback(callback)) {\n throw new Error(\n `Unknown queue callback \"${callback}\": not registered on this Queue`\n );\n }\n if (options?.retry)\n validateRetryOptions(options.retry, this.#retryDefaults);\n if (options?.id !== undefined && options.id.trim() === \"\") {\n throw new Error(\"Queue item ids must be non-empty\");\n }\n }\n\n /** Resolve a name to its registered or composition-root-supplied handler. */\n #resolveCallback(name: string): ResolvedQueueCallback | undefined {\n const handler = this.#handlers[name];\n if (handler) {\n // SAFETY: registered handlers are constrained with `never` parameters\n // so concrete handler types satisfy the map under contravariance; the\n // payload passed at dispatch was persisted with this handler's name.\n return handler as ResolvedQueueCallback;\n }\n return queueCallbackResolvers.get(this)?.(name);\n }\n\n #hasCallback(name: string): boolean {\n return this.#resolveCallback(name) !== undefined;\n }\n\n /** The next strictly increasing due time, never before now. */\n #nextTime(): number {\n if (this.#lastTime === null) {\n this.#lastTime = this.#ownedJobs().reduce(\n (lastTime, { job }) => Math.max(lastTime, job.time),\n 0\n );\n }\n const time = Math.max(Date.now(), this.#lastTime + 1);\n this.#lastTime = time;\n return time;\n }\n\n async #insert<T>(\n owner: LifecycleRouteAddress | null,\n callback: string,\n payload: unknown,\n options?: QueuePushOptions\n ): Promise<QueueItem<T>> {\n // A stable-id push replaces the item in place: it keeps the existing\n // item's due time, and so its position in the queue.\n const existing =\n options?.id !== undefined\n ? this.lifecycle.jobs.get(options.id)\n : undefined;\n const keepTime =\n existing !== undefined &&\n this.#getForOwner(owner, existing.id) !== undefined;\n const job = await this.lifecycle.jobs.push({\n id: options?.id,\n fn: callback,\n time: keepTime ? existing.time : this.#nextTime(),\n payload: {\n payload,\n owner_path: owner?.data ?? null,\n owner_path_key: owner?.key ?? null\n } satisfies QueueJobPayload,\n retry: resolveRetryConfig(options?.retry, this.#retryDefaults)\n });\n return this.#jobToItem<T>(job, job.payload as QueueJobPayload);\n }\n\n #jobToItem<T>(job: LifecycleJob, envelope: QueueJobPayload): QueueItem<T> {\n return {\n id: job.id,\n callback: job.fn,\n payload: envelope.payload as T,\n createdAt: job.createdAt,\n retry: job.retry\n };\n }\n\n /** Every queue job this Queue owns, in push order. */\n #ownedJobs(): Array<{ job: LifecycleJob; envelope: QueueJobPayload }> {\n const owned: Array<{ job: LifecycleJob; envelope: QueueJobPayload }> = [];\n for (const job of this.lifecycle.jobs.list()) {\n if (isQueueJobPayload(job.payload)) {\n owned.push({ job, envelope: job.payload });\n }\n }\n return owned;\n }\n\n #getForOwner<T>(\n owner: LifecycleRouteAddress | null,\n id: string\n ): QueueItem<T> | undefined {\n const ownerKey = owner?.key ?? null;\n const job = this.lifecycle.jobs.get(id);\n if (!job || !isQueueJobPayload(job.payload)) return undefined;\n if ((job.payload.owner_path_key ?? null) !== ownerKey) return undefined;\n return this.#jobToItem<T>(job, job.payload);\n }\n\n #listForOwner<T>(\n owner: LifecycleRouteAddress | null,\n criteria: QueueCriteria = {}\n ): QueueItem<T>[] {\n const ownerKey = owner?.key ?? null;\n const items: QueueItem<T>[] = [];\n for (const { job, envelope } of this.#ownedJobs()) {\n if ((envelope.owner_path_key ?? null) !== ownerKey) continue;\n if (criteria.callback && job.fn !== criteria.callback) continue;\n items.push(this.#jobToItem<T>(job, envelope));\n }\n return items;\n }\n\n async #cancelForOwner(\n owner: LifecycleRouteAddress | null,\n id: string\n ): Promise<boolean> {\n if (!this.#getForOwner(owner, id)) return false;\n return this.lifecycle.jobs.cancel(id);\n }\n\n async #cancelAllForOwner(\n owner: LifecycleRouteAddress | null,\n callback?: string\n ): Promise<number> {\n let cancelled = 0;\n for (const item of this.#listForOwner(owner, { callback })) {\n if (await this.lifecycle.jobs.cancel(item.id)) cancelled++;\n }\n return cancelled;\n }\n\n /** @internal Remove items owned by one routed Lifecycle subtree. */\n async __DO_NOT_USE_WILL_BREAK__cleanupRoutePrefix(\n prefix: string\n ): Promise<void> {\n for (const { job, envelope } of this.#ownedJobs()) {\n const ownerKey = envelope.owner_path_key ?? envelope.owner_path;\n if (!envelope.owner_path || ownerKey === null) continue;\n if (ownerKey !== prefix && !ownerKey.startsWith(`${prefix}/`)) continue;\n await this.lifecycle.jobs.cancel(job.id);\n }\n }\n\n // ── Events ───────────────────────────────────────────────────────────────\n\n #emit(type: QueueEventType, payload: Record<string, unknown>): void {\n this.lifecycle.events.emit(type, payload);\n }\n}\n"],"mappings":";;;;;;;;;;;;;AA4CA,MAAM,yCAAyB,IAAI,QAGjC;;;;;;;;AASF,SAAgB,yBACd,OACA,UACM;CACN,uBAAuB,IAAI,OAAO,QAAQ;AAC5C;AAEA,MAAM,2BAA2B;;AAEjC,MAAM,+BAA+B;AAErC,MAAM,gBAAwC;CAC5C,aAAa;CACb,aAAa;CACb,YAAY;AACd;AAwBA,SAAS,kBAAkB,OAA0C;CAEnE,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,gBAAgB;AACxE;;;;;;;;;;;;;;;;;;;;;;;AAmBA,IAAa,QAAb,cAEU,oBAAoB;;;;;;;;;;;CAuB5B,YAAY,UAAkC,CAAC,GAAG;EAChD,MAAM,OAAO;;;;;8CAbY,IAAA;EAczB,uBAAA,WAAA,MAAiB,QAAQ,aAAa,CAAC,CAAA;EAIvC,uBAAA,gBAAA,MAAsB,mBAAmB,QAAQ,OAAO,aAAa,CAAA;EACrE,uBAAA,UAAA,MAAgB,QAAQ,OAAA;CAC1B;;CAKA,MAAM,UAAyB;EAC7B,MAAM,UAAU,KAAK,UAAU;EAE/B,KADiB,MAAM,QAAQ,IAAY,wBAAwB,KAAM,MAC1D,8BAA8B;EAE7C,MAAA,kBAAA,cAAM,MAAA,wBAAA,CAAA,CAAA,KAAA,MAA8B,OAAO;EAC3C,MAAM,QAAQ,IAAI,0BAA0B,4BAA4B;CAC1E;;CA4DA,MAAM,MACJ,SACqC;EACrC,MAAM,EAAE,KAAK,YAAY;EACzB,IAAI,CAAC,kBAAkB,IAAI,OAAO,GAAG;GACnC,QAAQ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9C;CACA,OAAO;AACT;AAEA,eAAA,gBACE,OACA,IACkB;CAClB,IAAI,CAAA,kBAAA,cAAC,MAAA,YAAA,CAAA,CAAA,KAAA,MAAkB,OAAO,EAAE,GAAG,OAAO;CAC1C,OAAO,KAAK,UAAU,KAAK,OAAO,EAAE;AACtC;AAEA,eAAA,mBACE,OACA,UACiB;CACjB,IAAI,YAAY;CAChB,KAAK,MAAM,QAAA,kBAAA,cAAQ,MAAA,aAAA,CAAA,CAAA,KAAA,MAAmB,OAAO,EAAE,SAAS,CAAC,GACvD,IAAI,MAAM,KAAK,UAAU,KAAK,OAAO,KAAK,EAAE,GAAG;CAEjD,OAAO;AACT;AAgBA,SAAA,MAAM,MAAsB,SAAwC;CAClE,KAAK,UAAU,OAAO,KAAK,MAAM,OAAO;AAC1C"}
|
|
1
|
+
{"version":3,"file":"queue-CcIjVYTE.js","names":[],"sources":["../src/queue/queue.ts"],"sourcesContent":["/**\n * Lifecycle background-work vocabulary. Queue validates items, resolves\n * named callbacks, and pushes jobs due immediately into the Lifecycle-owned\n * job queue; Lifecycle runs the alarm event loop, retry policy, and physical\n * alarm arming. Queue owns no storage of its own — each item is one job\n * whose `fn` is the callback name and whose payload carries the item's\n * payload and owner.\n */\n\nimport {\n LifecycleCapability,\n type LifecycleRouteAddress,\n type LifecycleRouteContext\n} from \"../lifecycle/capability\";\nimport type {\n LifecycleJob,\n LifecycleJobContext,\n LifecycleJobOutcome\n} from \"../lifecycle/job-queue\";\nimport {\n isDurableObjectCodeUpdateReset,\n isPlatformFailure,\n resolveRetryConfig,\n tryN,\n validateRetryOptions\n} from \"../retries\";\nimport type { RetryOptions } from \"../retries\";\nimport type { QueueEventType, QueueOptions } from \"./options\";\nimport type {\n QueueCallbacks,\n QueueCriteria,\n QueueHandlers,\n QueueItem,\n QueuePayload,\n QueuePushOptions,\n QueueStorageRow\n} from \"./types\";\n\n/** A resolved fallback handler for a callback name outside the registered map. */\ntype ResolvedQueueCallback = (\n payload: unknown,\n item: QueueItem<unknown>\n) => unknown;\n\nconst queueCallbackResolvers = new WeakMap<\n object,\n (name: string) => ResolvedQueueCallback | undefined\n>();\n\n/**\n * @internal Supply a composition-root fallback for callback names outside the\n * registered map. Agent uses this to keep its historical name-based queue\n * API (`this.queue(\"methodName\", payload)`) working: the resolver looks the\n * method up on the Agent, and the resolved handler still runs inside the\n * Lifecycle host boundary.\n */\nexport function setQueueCallbackResolver(\n queue: Queue<never>,\n resolver: (name: string) => ResolvedQueueCallback | undefined\n): void {\n queueCallbackResolvers.set(queue, resolver);\n}\n\nconst QUEUE_SCHEMA_VERSION_KEY = \"cf_agents:queue_schema_version\";\n/** Version 1: queue items live in the Lifecycle job queue. */\nconst CURRENT_QUEUE_SCHEMA_VERSION = 1;\n\nconst DEFAULT_RETRY: Required<RetryOptions> = {\n maxAttempts: 3,\n baseDelayMs: 100,\n maxDelayMs: 3000\n};\n\n/** What a Queue job's payload carries: the item payload and its owner. */\ntype QueueJobPayload = {\n readonly payload: unknown;\n readonly owner_path: string | null;\n readonly owner_path_key: string | null;\n};\n\ntype QueueRouteMessage =\n | {\n readonly type: \"push\";\n readonly callback: string;\n readonly payload: unknown;\n readonly options?: QueuePushOptions;\n }\n | { readonly type: \"get\" | \"cancel\"; readonly id: string }\n | { readonly type: \"list\"; readonly criteria?: QueueCriteria }\n | { readonly type: \"cancelAll\"; readonly callback?: string }\n | {\n readonly type: \"dispatch\";\n readonly item: QueueItem<unknown>;\n };\n\nfunction isQueueJobPayload(value: unknown): value is QueueJobPayload {\n // `payload` is absent after a JSON round trip when the item carried none.\n return typeof value === \"object\" && value !== null && \"owner_path\" in value;\n}\n\n/**\n * Durable background work for a Lifecycle Object.\n *\n * Register callbacks in the constructor and install the instance with\n * `Lifecycle.use()`. Each pushed item becomes a job due immediately in the\n * Lifecycle job queue; Lifecycle owns the physical alarm and the alarm event\n * loop, drives items one at a time in push order, retries a throwing\n * callback per its retry policy, and Queue runs registered callbacks through\n * Lifecycle's host invocation boundary. An item that still fails after its\n * last attempt is dropped after `queue:error` and the `onError` hook.\n *\n * Items survive the Durable Object leaving memory: an isolate that dies mid\n * callback wakes again on the Lifecycle deadman alarm and resumes the queue.\n * Callbacks should therefore be idempotent.\n *\n * @experimental The API surface may change before stabilizing.\n */\nexport class Queue<\n Handlers extends QueueHandlers = QueueCallbacks\n> extends LifecycleCapability {\n readonly #handlers: QueueHandlers;\n readonly #retryDefaults: Required<RetryOptions>;\n readonly #onError: ((error: unknown) => void | Promise<void>) | undefined;\n /**\n * Last due time handed to a job. The Lifecycle driver dispatches due jobs\n * in due-time order, so pushes get strictly increasing times to keep push\n * order (FIFO) even within one millisecond. Seeded from the persisted\n * queue tail on first use so a fresh instance never sorts a new item ahead\n * of items an earlier instance already queued.\n */\n #lastTime: number | null = null;\n\n /**\n * Create a durable Queue.\n *\n * @param options - Registered callbacks plus optional retry and error\n * policy. Registering `callbacks` types {@link push} against the map —\n * names and payloads are checked where the handlers are declared and where\n * they are pushed. Names outside the map are rejected unless a\n * composition-root resolver supplies them — the internal aperture behind\n * `Agent`'s name-based queue API.\n */\n constructor(options: QueueOptions<Handlers> = {}) {\n super(\"queue\");\n this.#handlers = options.callbacks ?? {};\n // Retry defaults are resolved, not validated, here: invalid defaults\n // surface per execution as queue:error instead of bricking the object at\n // construction. Per-item retry overrides are validated when pushed.\n this.#retryDefaults = resolveRetryConfig(options.retry, DEFAULT_RETRY);\n this.#onError = options.onError;\n }\n\n // ── Lifecycle capability hooks ───────────────────────────────────────────\n\n /** Migrate legacy `cf_agents_queues` rows into the Lifecycle job queue. */\n async onStart(): Promise<void> {\n const storage = this.lifecycle.storage;\n const version = (await storage.get<number>(QUEUE_SCHEMA_VERSION_KEY)) ?? 0;\n if (version >= CURRENT_QUEUE_SCHEMA_VERSION) return;\n\n await this.#migrateLegacyQueueTable(storage);\n await storage.put(QUEUE_SCHEMA_VERSION_KEY, CURRENT_QUEUE_SCHEMA_VERSION);\n }\n\n /**\n * Move every `cf_agents_queues` row into the job queue and drop the\n * table. Idempotent: a missing table means a fresh object or a completed\n * migration. Rows keep their insertion order.\n *\n * TEMPORARY: one-shot upgrade path for objects that had queued items when\n * this release landed. Remove in the next minor release (with the schema\n * version bump that gates it), once every deployed object has migrated.\n */\n async #migrateLegacyQueueTable(storage: DurableObjectStorage): Promise<void> {\n const tables = storage.sql\n .exec(\n \"SELECT name FROM sqlite_master WHERE type='table' AND name='cf_agents_queues'\"\n )\n .toArray();\n if (tables.length === 0) return;\n\n const rows = storage.sql\n .exec(\"SELECT * FROM cf_agents_queues ORDER BY created_at ASC, rowid ASC\")\n .toArray() as unknown as QueueStorageRow[];\n for (const row of rows) {\n let payload: unknown;\n try {\n payload =\n typeof row.payload === \"string\" ? JSON.parse(row.payload) : undefined;\n } catch (error) {\n console.error(\n `Skipping queue item \"${row.id}\" during job-queue migration: ` +\n \"its payload is not valid JSON\",\n error\n );\n continue;\n }\n let retry: RetryOptions | undefined;\n try {\n retry =\n typeof row.retry_options === \"string\"\n ? (JSON.parse(row.retry_options) as RetryOptions)\n : undefined;\n } catch {\n retry = undefined;\n }\n await this.lifecycle.jobs.push({\n id: row.id,\n fn: row.callback,\n time: this.#nextTime(),\n payload: {\n payload,\n owner_path: null,\n owner_path_key: null\n } satisfies QueueJobPayload,\n retry: resolveRetryConfig(retry, this.#retryDefaults)\n });\n }\n storage.sql.exec(\"DROP TABLE cf_agents_queues\");\n }\n\n /** Drive one due item dispatched by the Lifecycle event loop. */\n async onJob(\n context: LifecycleJobContext\n ): Promise<LifecycleJobOutcome | void> {\n const { job, attempt } = context;\n if (!isQueueJobPayload(job.payload)) {\n console.error(`Malformed queue item ${job.id}; dropping it`);\n return undefined;\n }\n const item = this.#jobToItem(job, job.payload);\n\n if (attempt > 1) {\n this.#emit(\"queue:retry\", {\n callback: job.fn,\n id: job.id,\n attempt,\n maxAttempts: resolveRetryConfig(job.retry, this.#retryDefaults)\n .maxAttempts\n });\n }\n\n if (job.payload.owner_path) {\n // A routed item executes inside its owning Lifecycle; retries run\n // there too, so this dispatch is a single routed attempt.\n try {\n await this.lifecycle.routes.to(\n {\n key: job.payload.owner_path_key ?? job.payload.owner_path,\n data: job.payload.owner_path\n },\n { type: \"dispatch\", item } satisfies QueueRouteMessage\n );\n } catch (error) {\n if (isPlatformFailure(error)) {\n // Preserve the item; Lifecycle defers platform-class failures to\n // a fresh invocation or the memory-limit breaker.\n throw error;\n }\n console.error(`error dispatching queue callback \"${job.fn}\"`, error);\n this.#emit(\"queue:error\", {\n callback: job.fn,\n id: job.id,\n error: error instanceof Error ? error.message : String(error),\n attempts: 0\n });\n try {\n await this.#onError?.(error);\n } catch {\n // swallow onError errors\n }\n // Leave the item due so a later alarm cycle can retry dispatch, for\n // example once a transport can resolve its owner again.\n return \"yield\";\n }\n return undefined;\n }\n\n const handler = this.#resolveCallback(job.fn);\n if (!handler) {\n console.error(`callback ${job.fn} not found`);\n return undefined;\n }\n await this.lifecycle.runInHostContext(() => handler(item.payload, item));\n return undefined;\n }\n\n /** Observe one item's terminal application failure; the item is dropped. */\n async onJobError(\n context: LifecycleJobContext,\n error: unknown\n ): Promise<LifecycleJobOutcome | void> {\n const { job } = context;\n const { maxAttempts } = resolveRetryConfig(job.retry, this.#retryDefaults);\n console.error(\n `queue callback \"${job.fn}\" failed after ${maxAttempts} attempts`,\n error\n );\n this.#emit(\"queue:error\", {\n callback: job.fn,\n id: job.id,\n error: error instanceof Error ? error.message : String(error),\n attempts: maxAttempts\n });\n try {\n await this.#onError?.(error);\n } catch {\n // swallow onError errors\n }\n return undefined;\n }\n\n /** Handle Queue protocol messages routed by another Lifecycle. */\n async onRoute(context: LifecycleRouteContext): Promise<unknown> {\n const message = context.payload as QueueRouteMessage;\n const owner = context.source ?? null;\n switch (message.type) {\n case \"push\":\n return this.#insert(\n owner,\n message.callback,\n message.payload,\n message.options\n );\n case \"get\":\n return this.#getForOwner(owner, message.id);\n case \"list\":\n return this.#listForOwner(owner, message.criteria);\n case \"cancel\":\n return this.#cancelForOwner(owner, message.id);\n case \"cancelAll\":\n return this.#cancelAllForOwner(owner, message.callback);\n case \"dispatch\":\n await this.#executeRouted(message.item);\n return true;\n default:\n throw new Error(\"Unknown routed Queue message\");\n }\n }\n\n /**\n * Execute a routed item locally with the historical retry handling. Runs\n * on the owning (facet) Queue, outside the root's event loop, so it applies\n * its own in-process retry budget. Platform-class failures re-throw so the\n * root preserves the item and the durable alarm retries on a fresh\n * invocation.\n */\n async #executeRouted(item: QueueItem<unknown>): Promise<void> {\n const handler = this.#resolveCallback(item.callback);\n if (!handler) {\n console.error(`callback ${item.callback} not found`);\n return;\n }\n const { maxAttempts, baseDelayMs, maxDelayMs } = resolveRetryConfig(\n item.retry,\n this.#retryDefaults\n );\n try {\n await tryN(\n maxAttempts,\n async (attempt) => {\n if (attempt > 1) {\n this.#emit(\"queue:retry\", {\n callback: item.callback,\n id: item.id,\n attempt,\n maxAttempts\n });\n }\n await this.lifecycle.runInHostContext(() =>\n handler(item.payload, item)\n );\n },\n {\n baseDelayMs,\n maxDelayMs,\n shouldRetry: (error) => !isDurableObjectCodeUpdateReset(error)\n }\n );\n } catch (error) {\n if (isPlatformFailure(error)) {\n throw error;\n }\n console.error(\n `queue callback \"${item.callback}\" failed after ${maxAttempts} attempts`,\n error\n );\n this.#emit(\"queue:error\", {\n callback: item.callback,\n id: item.id,\n error: error instanceof Error ? error.message : String(error),\n attempts: maxAttempts\n });\n try {\n await this.#onError?.(error);\n } catch {\n // swallow onError errors\n }\n }\n }\n\n // ── Queue API ────────────────────────────────────────────────────────────\n\n /**\n * Push one item for a registered callback. The item is due immediately;\n * the Lifecycle alarm event loop runs it in push order after this call\n * returns.\n *\n * Once the Lifecycle has started (and this Queue is not routed through\n * another Lifecycle), the item row is written synchronously before this\n * method's promise is even returned, so a caller may pair a push with its\n * own writes in one synchronous block — the item then commits atomically\n * with them.\n */\n async push<Name extends keyof Handlers & string>(\n callback: Name,\n payload?: QueuePayload<Handlers[Name]>,\n options?: QueuePushOptions\n ): Promise<QueueItem<QueuePayload<Handlers[Name]>>> {\n if (this.lifecycle.status() !== \"started\") await this.lifecycle.ready();\n this.#validatePush(callback, options);\n const item = this.lifecycle.routes.source\n ? ((await this.lifecycle.routes.toRoot({\n type: \"push\",\n callback,\n payload,\n options\n } satisfies QueueRouteMessage)) as QueueItem<\n QueuePayload<Handlers[Name]>\n >)\n : await this.#insert<QueuePayload<Handlers[Name]>>(\n null,\n callback,\n payload,\n options\n );\n this.#emit(\"queue:create\", { callback, id: item.id });\n return item;\n }\n\n /** Cancel one pending item. Returns false when no item matched. */\n async cancel(id: string): Promise<boolean> {\n await this.lifecycle.ready();\n if (this.lifecycle.routes.source) {\n return (await this.lifecycle.routes.toRoot({\n type: \"cancel\",\n id\n } satisfies QueueRouteMessage)) as boolean;\n }\n return this.#cancelForOwner(null, id);\n }\n\n /** Cancel every pending item, or every item for one callback. Returns the count. */\n async cancelAll(callback?: string): Promise<number> {\n await this.lifecycle.ready();\n if (this.lifecycle.routes.source) {\n return (await this.lifecycle.routes.toRoot({\n type: \"cancelAll\",\n callback\n } satisfies QueueRouteMessage)) as number;\n }\n return this.#cancelAllForOwner(null, callback);\n }\n\n /** Read one pending item. */\n async get<T = unknown>(id: string): Promise<QueueItem<T> | undefined> {\n await this.lifecycle.ready();\n if (this.lifecycle.routes.source) {\n return (await this.lifecycle.routes.toRoot({\n type: \"get\",\n id\n } satisfies QueueRouteMessage)) as QueueItem<T> | undefined;\n }\n return this.#getForOwner<T>(null, id);\n }\n\n /** List pending items in push order, optionally filtered by callback. */\n async list<T = unknown>(criteria?: QueueCriteria): Promise<QueueItem<T>[]> {\n await this.lifecycle.ready();\n if (this.lifecycle.routes.source) {\n return (await this.lifecycle.routes.toRoot({\n type: \"list\",\n criteria\n } satisfies QueueRouteMessage)) as QueueItem<T>[];\n }\n return this.#listForOwner<T>(null, criteria);\n }\n\n // ── Internals ────────────────────────────────────────────────────────────\n\n #validatePush(callback: string, options?: QueuePushOptions): void {\n if (typeof callback !== \"string\") {\n throw new Error(\"Callback must be a string\");\n }\n if (!this.#hasCallback(callback)) {\n throw new Error(\n `Unknown queue callback \"${callback}\": not registered on this Queue`\n );\n }\n if (options?.retry)\n validateRetryOptions(options.retry, this.#retryDefaults);\n if (options?.id !== undefined && options.id.trim() === \"\") {\n throw new Error(\"Queue item ids must be non-empty\");\n }\n }\n\n /** Resolve a name to its registered or composition-root-supplied handler. */\n #resolveCallback(name: string): ResolvedQueueCallback | undefined {\n const handler = this.#handlers[name];\n if (handler) {\n // SAFETY: registered handlers are constrained with `never` parameters\n // so concrete handler types satisfy the map under contravariance; the\n // payload passed at dispatch was persisted with this handler's name.\n return handler as ResolvedQueueCallback;\n }\n return queueCallbackResolvers.get(this)?.(name);\n }\n\n #hasCallback(name: string): boolean {\n return this.#resolveCallback(name) !== undefined;\n }\n\n /** The next strictly increasing due time, never before now. */\n #nextTime(): number {\n if (this.#lastTime === null) {\n this.#lastTime = this.#ownedJobs().reduce(\n (lastTime, { job }) => Math.max(lastTime, job.time),\n 0\n );\n }\n const time = Math.max(Date.now(), this.#lastTime + 1);\n this.#lastTime = time;\n return time;\n }\n\n async #insert<T>(\n owner: LifecycleRouteAddress | null,\n callback: string,\n payload: unknown,\n options?: QueuePushOptions\n ): Promise<QueueItem<T>> {\n // A stable-id push replaces the item in place: it keeps the existing\n // item's due time, and so its position in the queue.\n const existing =\n options?.id !== undefined\n ? this.lifecycle.jobs.get(options.id)\n : undefined;\n const keepTime =\n existing !== undefined &&\n this.#getForOwner(owner, existing.id) !== undefined;\n const job = await this.lifecycle.jobs.push({\n id: options?.id,\n fn: callback,\n time: keepTime ? existing.time : this.#nextTime(),\n payload: {\n payload,\n owner_path: owner?.data ?? null,\n owner_path_key: owner?.key ?? null\n } satisfies QueueJobPayload,\n retry: resolveRetryConfig(options?.retry, this.#retryDefaults)\n });\n return this.#jobToItem<T>(job, job.payload as QueueJobPayload);\n }\n\n #jobToItem<T>(job: LifecycleJob, envelope: QueueJobPayload): QueueItem<T> {\n return {\n id: job.id,\n callback: job.fn,\n payload: envelope.payload as T,\n createdAt: job.createdAt,\n retry: job.retry\n };\n }\n\n /** Every queue job this Queue owns, in push order. */\n #ownedJobs(): Array<{ job: LifecycleJob; envelope: QueueJobPayload }> {\n const owned: Array<{ job: LifecycleJob; envelope: QueueJobPayload }> = [];\n for (const job of this.lifecycle.jobs.list()) {\n if (isQueueJobPayload(job.payload)) {\n owned.push({ job, envelope: job.payload });\n }\n }\n return owned;\n }\n\n #getForOwner<T>(\n owner: LifecycleRouteAddress | null,\n id: string\n ): QueueItem<T> | undefined {\n const ownerKey = owner?.key ?? null;\n const job = this.lifecycle.jobs.get(id);\n if (!job || !isQueueJobPayload(job.payload)) return undefined;\n if ((job.payload.owner_path_key ?? null) !== ownerKey) return undefined;\n return this.#jobToItem<T>(job, job.payload);\n }\n\n #listForOwner<T>(\n owner: LifecycleRouteAddress | null,\n criteria: QueueCriteria = {}\n ): QueueItem<T>[] {\n const ownerKey = owner?.key ?? null;\n const items: QueueItem<T>[] = [];\n for (const { job, envelope } of this.#ownedJobs()) {\n if ((envelope.owner_path_key ?? null) !== ownerKey) continue;\n if (criteria.callback && job.fn !== criteria.callback) continue;\n items.push(this.#jobToItem<T>(job, envelope));\n }\n return items;\n }\n\n async #cancelForOwner(\n owner: LifecycleRouteAddress | null,\n id: string\n ): Promise<boolean> {\n if (!this.#getForOwner(owner, id)) return false;\n return this.lifecycle.jobs.cancel(id);\n }\n\n async #cancelAllForOwner(\n owner: LifecycleRouteAddress | null,\n callback?: string\n ): Promise<number> {\n let cancelled = 0;\n for (const item of this.#listForOwner(owner, { callback })) {\n if (await this.lifecycle.jobs.cancel(item.id)) cancelled++;\n }\n return cancelled;\n }\n\n /** @internal Remove items owned by one routed Lifecycle subtree. */\n async __DO_NOT_USE_WILL_BREAK__cleanupRoutePrefix(\n prefix: string\n ): Promise<void> {\n for (const { job, envelope } of this.#ownedJobs()) {\n const ownerKey = envelope.owner_path_key ?? envelope.owner_path;\n if (!envelope.owner_path || ownerKey === null) continue;\n if (ownerKey !== prefix && !ownerKey.startsWith(`${prefix}/`)) continue;\n await this.lifecycle.jobs.cancel(job.id);\n }\n }\n\n // ── Events ───────────────────────────────────────────────────────────────\n\n #emit(type: QueueEventType, payload: Record<string, unknown>): void {\n this.lifecycle.events.emit(type, payload);\n }\n}\n"],"mappings":";;;;;;;;;;;;;AA4CA,MAAM,yCAAyB,IAAI,QAGjC;;;;;;;;AASF,SAAgB,yBACd,OACA,UACM;CACN,uBAAuB,IAAI,OAAO,QAAQ;AAC5C;AAEA,MAAM,2BAA2B;;AAEjC,MAAM,+BAA+B;AAErC,MAAM,gBAAwC;CAC5C,aAAa;CACb,aAAa;CACb,YAAY;AACd;AAwBA,SAAS,kBAAkB,OAA0C;CAEnE,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,gBAAgB;AACxE;;;;;;;;;;;;;;;;;;;;;;;AAmBA,IAAa,QAAb,cAEU,oBAAoB;;;;;;;;;;;CAuB5B,YAAY,UAAkC,CAAC,GAAG;EAChD,MAAM,OAAO;;;;;8CAbY,IAAA;EAczB,uBAAA,WAAA,MAAiB,QAAQ,aAAa,CAAC,CAAA;EAIvC,uBAAA,gBAAA,MAAsB,mBAAmB,QAAQ,OAAO,aAAa,CAAA;EACrE,uBAAA,UAAA,MAAgB,QAAQ,OAAA;CAC1B;;CAKA,MAAM,UAAyB;EAC7B,MAAM,UAAU,KAAK,UAAU;EAE/B,KADiB,MAAM,QAAQ,IAAY,wBAAwB,KAAM,MAC1D,8BAA8B;EAE7C,MAAA,kBAAA,cAAM,MAAA,wBAAA,CAAA,CAAA,KAAA,MAA8B,OAAO;EAC3C,MAAM,QAAQ,IAAI,0BAA0B,4BAA4B;CAC1E;;CA4DA,MAAM,MACJ,SACqC;EACrC,MAAM,EAAE,KAAK,YAAY;EACzB,IAAI,CAAC,kBAAkB,IAAI,OAAO,GAAG;GACnC,QAAQ,MAAM,wBAAwB,IAAI,GAAG,cAAc;GAC3D;EACF;EAC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CAClB,IAAI,CAAA,kBAAA,cAAC,MAAA,YAAA,CAAA,CAAA,KAAA,MAAkB,OAAO,EAAE,GAAG,OAAO;CAC1C,OAAO,KAAK,UAAU,KAAK,OAAO,EAAE;AACtC;AAEA,eAAA,mBACE,OACA,UACiB;CACjB,IAAI,YAAY;CAChB,KAAK,MAAM,QAAA,kBAAA,cAAQ,MAAA,aAAA,CAAA,CAAA,KAAA,MAAmB,OAAO,EAAE,SAAS,CAAC,GACvD,IAAI,MAAM,KAAK,UAAU,KAAK,OAAO,KAAK,EAAE,GAAG;CAEjD,OAAO;AACT;AAgBA,SAAA,MAAM,MAAsB,SAAwC;CAClE,KAAK,UAAU,OAAO,KAAK,MAAM,OAAO;AAC1C"}
|
package/dist/react.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
C as MCPServersState,
|
|
3
3
|
J as AgentToolRunPart,
|
|
4
4
|
Y as AgentToolRunState
|
|
5
|
-
} from "./agent-routing-
|
|
5
|
+
} from "./agent-routing-QDcchcQP.js";
|
|
6
6
|
import { ClientParameters } from "./serializable.js";
|
|
7
7
|
import { t as AgentTransport } from "./transport-protocol-ZTew5Wso.js";
|
|
8
8
|
import {
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
p as RequiredAgentMethods,
|
|
16
16
|
s as AgentStub,
|
|
17
17
|
v as createStubProxy
|
|
18
|
-
} from "./client-
|
|
18
|
+
} from "./client-BGIQKJhX.js";
|
|
19
19
|
import { PartySocket } from "partysocket";
|
|
20
20
|
import { usePartySocket } from "partysocket/react";
|
|
21
21
|
|
package/dist/routing/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
r as CapabilityWebSocketUpgradeContext,
|
|
3
3
|
s as LifecycleCapability,
|
|
4
4
|
t as CapabilityRequestContext
|
|
5
|
-
} from "../capability-runner-
|
|
5
|
+
} from "../capability-runner-BiVUtjqC.js";
|
|
6
6
|
import {
|
|
7
7
|
a as routeAgentRequest,
|
|
8
8
|
c as Agent,
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
n as AgentOptions,
|
|
11
11
|
r as RoutingRetryOptions,
|
|
12
12
|
t as AgentGetOptions
|
|
13
|
-
} from "../agent-routing-
|
|
13
|
+
} from "../agent-routing-QDcchcQP.js";
|
|
14
14
|
|
|
15
15
|
//#region src/routing/routed-agents.d.ts
|
|
16
16
|
/** A public entry in an {@link RoutedAgents}. */
|
package/dist/routing/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getAgentByName, routeAgentRequest } from "../agent-routing.js";
|
|
2
2
|
import { i as _classPrivateFieldInitSpec, n as _classPrivateFieldSet2, r as _assertClassBrand, t as _classPrivateFieldGet2 } from "../classPrivateFieldGet2-DZBYAB34.js";
|
|
3
3
|
import { t as _classPrivateMethodInitSpec } from "../classPrivateMethodInitSpec-qMjJ6sHQ.js";
|
|
4
|
-
import { t as LifecycleCapability } from "../capability-
|
|
4
|
+
import { t as LifecycleCapability } from "../capability-DBAKc6UZ.js";
|
|
5
5
|
//#region src/routing/routed-agents.ts
|
|
6
6
|
/**
|
|
7
7
|
* Catalog of the entries an owning Durable Object has created, keyed by
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
d as LifecycleRouteContext,
|
|
4
4
|
s as LifecycleCapability,
|
|
5
5
|
v as LifecycleJobOutcome
|
|
6
|
-
} from "./capability-runner-
|
|
6
|
+
} from "./capability-runner-BiVUtjqC.js";
|
|
7
7
|
import { t as RetryOptions } from "./retries-CV6AkXmQ.js";
|
|
8
8
|
|
|
9
9
|
//#region src/schedules/types.d.ts
|
|
@@ -41,8 +41,6 @@ type Schedule<T = string> = {
|
|
|
41
41
|
/**
|
|
42
42
|
* Constraint for a Scheduler's registered callback map: named handlers
|
|
43
43
|
* receiving the parsed payload and the schedule that fired.
|
|
44
|
-
*
|
|
45
|
-
* @experimental The API surface may change before stabilizing.
|
|
46
44
|
*/
|
|
47
45
|
type SchedulerHandlers = Record<
|
|
48
46
|
string,
|
|
@@ -54,8 +52,6 @@ type SchedulerHandlers = Record<
|
|
|
54
52
|
* must be registered or supplied by a composition-root resolver (the
|
|
55
53
|
* aperture behind Agent's name-based scheduling API); a bare Scheduler
|
|
56
54
|
* rejects it otherwise.
|
|
57
|
-
*
|
|
58
|
-
* @experimental The API surface may change before stabilizing.
|
|
59
55
|
*/
|
|
60
56
|
type SchedulerCallbacks = Record<
|
|
61
57
|
string,
|
|
@@ -63,8 +59,6 @@ type SchedulerCallbacks = Record<
|
|
|
63
59
|
>;
|
|
64
60
|
/**
|
|
65
61
|
* The payload type a registered scheduler callback accepts.
|
|
66
|
-
*
|
|
67
|
-
* @experimental The API surface may change before stabilizing.
|
|
68
62
|
*/
|
|
69
63
|
type SchedulerPayload<Handler> = Handler extends (
|
|
70
64
|
payload: infer Payload,
|
|
@@ -103,8 +97,6 @@ type SchedulerEventType =
|
|
|
103
97
|
| "schedule:duplicate_warning";
|
|
104
98
|
/**
|
|
105
99
|
* Optional callbacks and policy for a Scheduler capability.
|
|
106
|
-
*
|
|
107
|
-
* @experimental The API surface may change before stabilizing.
|
|
108
100
|
*/
|
|
109
101
|
interface SchedulerOptions<
|
|
110
102
|
Handlers extends SchedulerHandlers = SchedulerCallbacks
|
|
@@ -134,8 +126,6 @@ interface SchedulerOptions<
|
|
|
134
126
|
* Lifecycle job queue; Lifecycle owns the physical alarm and the alarm
|
|
135
127
|
* event loop, and Scheduler runs registered callbacks through Lifecycle's
|
|
136
128
|
* host invocation boundary when its jobs come due.
|
|
137
|
-
*
|
|
138
|
-
* @experimental The API surface may change before stabilizing.
|
|
139
129
|
*/
|
|
140
130
|
declare class Scheduler<
|
|
141
131
|
Handlers extends SchedulerHandlers = SchedulerCallbacks
|
|
@@ -220,4 +210,4 @@ export {
|
|
|
220
210
|
SchedulerCallbacks as s,
|
|
221
211
|
Scheduler as t
|
|
222
212
|
};
|
|
223
|
-
//# sourceMappingURL=scheduler-
|
|
213
|
+
//# sourceMappingURL=scheduler-BCLESHSC.d.ts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { i as _classPrivateFieldInitSpec, n as _classPrivateFieldSet2, r as _assertClassBrand, t as _classPrivateFieldGet2 } from "./classPrivateFieldGet2-DZBYAB34.js";
|
|
2
2
|
import { t as _classPrivateMethodInitSpec } from "./classPrivateMethodInitSpec-qMjJ6sHQ.js";
|
|
3
|
-
import { t as LifecycleCapability } from "./capability-
|
|
3
|
+
import { t as LifecycleCapability } from "./capability-DBAKc6UZ.js";
|
|
4
4
|
import { isDurableObjectCodeUpdateReset, isPlatformFailure, resolveRetryConfig, tryN, validateRetryOptions } from "./retries.js";
|
|
5
5
|
import { parseCronExpression } from "cron-schedule";
|
|
6
6
|
//#region src/schedules/schedule-timing.ts
|
|
@@ -138,8 +138,6 @@ var _Scheduler_brand = /* @__PURE__ */ new WeakSet();
|
|
|
138
138
|
* Lifecycle job queue; Lifecycle owns the physical alarm and the alarm
|
|
139
139
|
* event loop, and Scheduler runs registered callbacks through Lifecycle's
|
|
140
140
|
* host invocation boundary when its jobs come due.
|
|
141
|
-
*
|
|
142
|
-
* @experimental The API surface may change before stabilizing.
|
|
143
141
|
*/
|
|
144
142
|
var Scheduler = class extends LifecycleCapability {
|
|
145
143
|
/**
|
|
@@ -655,4 +653,4 @@ function _emitCreated(result) {
|
|
|
655
653
|
//#endregion
|
|
656
654
|
export { setSchedulerCallbackResolver as n, Scheduler as t };
|
|
657
655
|
|
|
658
|
-
//# sourceMappingURL=scheduler-
|
|
656
|
+
//# sourceMappingURL=scheduler-FIHv2-kJ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scheduler-FIHv2-kJ.js","names":[],"sources":["../src/schedules/schedule-timing.ts","../src/schedules/scheduler.ts"],"sourcesContent":["/**\n * Pure timing rules for persistent schedules.\n *\n * A `ScheduleTiming` is the parsed \"when and how it runs\" half of a\n * `Schedule` — everything except identity, callback, and payload. Parsing\n * user-facing inputs here keeps Scheduler's storage code to one insert path.\n */\n\nimport { parseCronExpression } from \"cron-schedule\";\n\n/** Longest allowed gap between interval executions: 30 days. */\nexport const MAX_INTERVAL_SECONDS = 30 * 24 * 60 * 60;\n\n/** When and how one schedule runs; a `Schedule` minus identity and payload. */\nexport type ScheduleTiming =\n | {\n /** One-time execution at a specific date. */\n readonly type: \"scheduled\";\n /** Unix timestamp in seconds. */\n readonly time: number;\n }\n | {\n /** One-time execution after a relative delay. */\n readonly type: \"delayed\";\n /** Unix timestamp in seconds. */\n readonly time: number;\n /** Delay from creation in seconds. */\n readonly delayInSeconds: number;\n }\n | {\n /** Recurring execution from a cron expression. */\n readonly type: \"cron\";\n /** Unix timestamp in seconds for the next execution. */\n readonly time: number;\n /** Cron expression defining the recurrence. */\n readonly cron: string;\n }\n | {\n /** Recurring execution at a fixed interval. */\n readonly type: \"interval\";\n /** Unix timestamp in seconds for the next execution. */\n readonly time: number;\n /** Number of seconds between executions. */\n readonly intervalSeconds: number;\n };\n\n/** True when this timing repeats and therefore deduplicates by default. */\nexport function isRecurring(timing: ScheduleTiming): boolean {\n return timing.type === \"cron\" || timing.type === \"interval\";\n}\n\n/**\n * Next wall-clock execution time for a cron expression.\n *\n * @param cron - A standard cron expression.\n * @param nowMs - Current epoch time in milliseconds.\n * @returns The next execution epoch time in milliseconds.\n * @throws For an unparseable cron expression.\n */\nexport function nextCronTimeMs(cron: string, nowMs: number): number {\n return parseCronExpression(cron).getNextDate(new Date(nowMs)).getTime();\n}\n\n/**\n * Parse a user-facing `when` into schedule timing.\n *\n * A `Date` runs once at that date, a number runs once after that many\n * seconds, and a string is a recurring cron expression.\n *\n * @param when - The requested execution time or recurrence.\n * @param nowMs - Current epoch time in milliseconds.\n * @param callback - Callback name, used only in error messages.\n * @returns The parsed timing.\n * @throws For a `when` value that is not a `Date`, number, or string.\n */\nexport function parseWhen(\n when: Date | string | number,\n nowMs: number,\n callback: string\n): ScheduleTiming {\n if (when instanceof Date) {\n return { type: \"scheduled\", time: Math.floor(when.getTime() / 1000) };\n }\n if (typeof when === \"number\") {\n return {\n type: \"delayed\",\n time: Math.floor((nowMs + when * 1000) / 1000),\n delayInSeconds: when\n };\n }\n if (typeof when === \"string\") {\n return {\n type: \"cron\",\n time: Math.floor(nextCronTimeMs(when, nowMs) / 1000),\n cron: when\n };\n }\n throw new Error(\n `Invalid schedule type: ${JSON.stringify(when)}(${typeof when}) trying to schedule ${callback}`\n );\n}\n\n/**\n * Reject an interval outside the supported range.\n *\n * @param intervalSeconds - The requested gap between executions.\n * @throws For a non-positive interval or one longer than 30 days.\n */\nexport function validateIntervalSeconds(intervalSeconds: number): void {\n if (typeof intervalSeconds !== \"number\" || intervalSeconds <= 0) {\n throw new Error(\"intervalSeconds must be a positive number\");\n }\n if (intervalSeconds > MAX_INTERVAL_SECONDS) {\n throw new Error(\n `intervalSeconds cannot exceed ${MAX_INTERVAL_SECONDS} seconds (30 days)`\n );\n }\n}\n\n/**\n * Parse a fixed interval into schedule timing.\n *\n * @param intervalSeconds - Seconds between executions.\n * @param nowMs - Current epoch time in milliseconds.\n * @returns The parsed timing with the first execution one interval from now.\n * @throws For an interval outside the supported range.\n */\nexport function parseInterval(\n intervalSeconds: number,\n nowMs: number\n): ScheduleTiming {\n validateIntervalSeconds(intervalSeconds);\n return {\n type: \"interval\",\n time: Math.floor((nowMs + intervalSeconds * 1000) / 1000),\n intervalSeconds\n };\n}\n","/**\n * Lifecycle scheduling vocabulary. Scheduler validates schedules, resolves\n * named callbacks, and pushes jobs into the Lifecycle-owned job queue;\n * Lifecycle runs the alarm event loop, retry policy, and physical alarm\n * arming. Scheduler owns no storage of its own — each schedule is one job\n * whose `fn` is the callback name and whose payload carries the schedule's\n * timing vocabulary.\n */\n\nimport {\n LifecycleCapability,\n type LifecycleRouteAddress,\n type LifecycleRouteContext\n} from \"../lifecycle/capability\";\nimport type {\n LifecycleJob,\n LifecycleJobContext,\n LifecycleJobOutcome\n} from \"../lifecycle/job-queue\";\nimport {\n isDurableObjectCodeUpdateReset,\n isPlatformFailure,\n resolveRetryConfig,\n tryN,\n validateRetryOptions\n} from \"../retries\";\nimport type { RetryOptions } from \"../retries\";\nimport type { SchedulerEventType, SchedulerOptions } from \"./options\";\nimport {\n isRecurring,\n nextCronTimeMs,\n parseInterval,\n parseWhen,\n validateIntervalSeconds,\n type ScheduleTiming\n} from \"./schedule-timing\";\nimport type {\n RecoveryLoopScheduleOptions,\n Schedule,\n ScheduleCriteria,\n ScheduleOptions,\n ScheduleStorageRow,\n SchedulerCallbacks,\n SchedulerHandlers,\n SchedulerPayload\n} from \"./types\";\n\n/**\n * A resolved fallback handler for a callback name outside the registered map.\n */\ntype ResolvedSchedulerCallback = (\n payload: unknown,\n schedule: Schedule<unknown>\n) => unknown;\n\nconst schedulerCallbackResolvers = new WeakMap<\n object,\n (name: string) => ResolvedSchedulerCallback | undefined\n>();\n\n/**\n * @internal Supply a composition-root fallback for callback names outside the\n * registered map. Agent uses this to keep its historical name-based\n * scheduling API (`this.schedule(60, \"methodName\")`) working: the resolver\n * looks the method up on the Agent, and the resolved handler still runs\n * inside the Lifecycle host boundary.\n */\nexport function setSchedulerCallbackResolver(\n scheduler: Scheduler<never>,\n resolver: (name: string) => ResolvedSchedulerCallback | undefined\n): void {\n schedulerCallbackResolvers.set(scheduler, resolver);\n}\n\nconst SCHEDULE_SCHEMA_VERSION_KEY = \"cf_agents:schedules_schema_version\";\n/** Version 2: schedule rows live in the Lifecycle job queue. */\nconst CURRENT_SCHEDULE_SCHEMA_VERSION = 2;\n\n/**\n * Legacy schedule callbacks whose rows drive chat recovery loops from before\n * the job queue carried breaker membership. The migration is the one place\n * allowed to know legacy names (it already drops `_cf_keepAliveHeartbeat`\n * rows by name): a recovery row migrated without its `recoveryLoop` flag\n * would escape the alarm memory-limit breaker (#1825) and could re-trigger\n * a doomed loop on an upgraded object.\n */\nconst LEGACY_RECOVERY_LOOP_CALLBACKS = new Set([\n \"_chatRecoveryContinue\",\n \"_chatRecoveryRetry\"\n]);\n\nconst DEFAULT_RETRY: Required<RetryOptions> = {\n maxAttempts: 3,\n baseDelayMs: 100,\n maxDelayMs: 3000\n};\n\n/**\n * The schedule timing vocabulary carried in one job's payload. The callback\n * name is the job's `fn`; the user payload rides in `payload`.\n */\ntype SchedulerJobPayload = {\n readonly payload: unknown;\n readonly type: \"scheduled\" | \"delayed\" | \"cron\" | \"interval\";\n /** The caller-supplied retry override, unresolved, for public projection.\n The job's own retry options are fully resolved against the Scheduler\n defaults at push so the Lifecycle driver applies the configured\n policy. */\n readonly retry?: RetryOptions;\n readonly delayInSeconds?: number;\n readonly cron?: string;\n readonly intervalSeconds?: number;\n readonly owner_path?: string | null;\n readonly owner_path_key?: string | null;\n};\n\ntype SchedulerRouteMessage =\n | {\n readonly type: \"schedule\";\n readonly when: Date | string | number;\n readonly callback: string;\n readonly payload?: unknown;\n readonly options?: ScheduleOptions;\n }\n | {\n readonly type: \"every\";\n readonly intervalSeconds: number;\n readonly callback: string;\n readonly payload?: unknown;\n readonly options?: ScheduleOptions;\n }\n | { readonly type: \"get\" | \"cancel\"; readonly id: string }\n | { readonly type: \"list\"; readonly criteria?: ScheduleCriteria }\n | {\n readonly type: \"dispatch\";\n readonly id: string;\n readonly fn: string;\n readonly job: SchedulerJobPayload;\n readonly retry?: RetryOptions;\n };\n\ntype InsertResult<T> = {\n readonly schedule: Schedule<T>;\n readonly created: boolean;\n};\n\nfunction isSchedulerJobPayload(value: unknown): value is SchedulerJobPayload {\n return (\n typeof value === \"object\" &&\n value !== null &&\n typeof (value as SchedulerJobPayload).type === \"string\"\n );\n}\n\n/**\n * Persistent task scheduling for a Lifecycle Object.\n *\n * Register callbacks in the constructor and install the instance with\n * `Lifecycle.use()`. Scheduler validates schedules and pushes them into the\n * Lifecycle job queue; Lifecycle owns the physical alarm and the alarm\n * event loop, and Scheduler runs registered callbacks through Lifecycle's\n * host invocation boundary when its jobs come due.\n */\nexport class Scheduler<\n Handlers extends SchedulerHandlers = SchedulerCallbacks\n> extends LifecycleCapability {\n readonly #handlers: SchedulerHandlers;\n readonly #retryDefaults: Required<RetryOptions>;\n readonly #hungScheduleTimeoutSeconds: number;\n readonly #onError: ((error: unknown) => void | Promise<void>) | undefined;\n readonly #warnedStartupCallbacks = new Set<string>();\n\n /**\n * Create a persistent Scheduler.\n *\n * @param options - Registered callbacks plus optional retry,\n * hung-interval, and error policy. Registering `callbacks` types\n * {@link set} and {@link every} against the map — names and\n * payloads are checked where the handlers are declared and where they are\n * scheduled. Names outside the map are rejected unless a composition-root\n * resolver supplies them — the internal aperture behind `Agent`'s\n * name-based scheduling API.\n */\n constructor(options: SchedulerOptions<Handlers> = {}) {\n super(\"scheduler\");\n this.#handlers = options.callbacks ?? {};\n // Retry defaults are resolved, not validated, here: a host whose\n // historically tolerated invalid retry config throws at construction\n // would brick every entry point of its Durable Object. Invalid defaults\n // surface per execution as schedule:error instead, and per-schedule\n // retry overrides are still validated when each schedule is created.\n this.#retryDefaults = resolveRetryConfig(options.retry, DEFAULT_RETRY);\n this.#hungScheduleTimeoutSeconds = options.hungScheduleTimeoutSeconds ?? 30;\n this.#onError = options.onError;\n }\n\n // ── Lifecycle capability hooks ───────────────────────────────────────────\n\n /** Migrate legacy schedule storage into the Lifecycle job queue. */\n async onStart(): Promise<void> {\n this.#warnedStartupCallbacks.clear();\n const storage = this.lifecycle.storage;\n const version =\n (await storage.get<number>(SCHEDULE_SCHEMA_VERSION_KEY)) ?? 0;\n if (version >= CURRENT_SCHEDULE_SCHEMA_VERSION) return;\n\n await this.#migrateLegacyScheduleTable(storage);\n await storage.put(\n SCHEDULE_SCHEMA_VERSION_KEY,\n CURRENT_SCHEDULE_SCHEMA_VERSION\n );\n }\n\n /**\n * Move every `cf_agents_schedules` row into the job queue and drop the\n * table. Idempotent: a missing table means a fresh object or a completed\n * migration. Times convert from epoch seconds to epoch milliseconds.\n */\n async #migrateLegacyScheduleTable(\n storage: DurableObjectStorage\n ): Promise<void> {\n const tables = storage.sql\n .exec(\n \"SELECT name FROM sqlite_master WHERE type='table' AND name='cf_agents_schedules'\"\n )\n .toArray();\n if (tables.length === 0) return;\n\n const rows = storage.sql\n .exec(\"SELECT * FROM cf_agents_schedules\")\n .toArray() as unknown as ScheduleStorageRow[];\n for (const row of rows) {\n // Keep-alive heartbeats stopped using schedule rows long ago; drop\n // orphans instead of migrating them.\n if (row.callback === \"_cf_keepAliveHeartbeat\") continue;\n let payload: unknown;\n try {\n payload =\n typeof row.payload === \"string\" ? JSON.parse(row.payload) : undefined;\n } catch (error) {\n console.error(\n `Skipping schedule \"${row.id}\" during job-queue migration: ` +\n \"its payload is not valid JSON\",\n error\n );\n continue;\n }\n let retry: RetryOptions | undefined;\n try {\n retry =\n typeof row.retry_options === \"string\"\n ? (JSON.parse(row.retry_options) as RetryOptions)\n : undefined;\n } catch {\n retry = undefined;\n }\n await this.lifecycle.jobs.push({\n id: row.id,\n fn: row.callback,\n time: row.time * 1000,\n payload: {\n payload,\n retry,\n type: row.type,\n delayInSeconds: row.delayInSeconds ?? undefined,\n cron: row.cron ?? undefined,\n intervalSeconds: row.intervalSeconds ?? undefined,\n owner_path: row.owner_path ?? null,\n owner_path_key: row.owner_path_key ?? null\n } satisfies SchedulerJobPayload,\n retry: resolveRetryConfig(retry, this.#retryDefaults),\n singleflight: row.type === \"interval\",\n hungTimeoutSeconds: this.#hungScheduleTimeoutSeconds,\n recoveryLoop: LEGACY_RECOVERY_LOOP_CALLBACKS.has(row.callback)\n });\n }\n storage.sql.exec(\"DROP TABLE cf_agents_schedules\");\n }\n\n /** Drive one due schedule job dispatched by the Lifecycle event loop. */\n async onJob(\n context: LifecycleJobContext\n ): Promise<LifecycleJobOutcome | void> {\n const { job, attempt } = context;\n const timing = job.payload;\n if (!isSchedulerJobPayload(timing)) {\n console.error(`Malformed schedule job ${job.id}; dropping it`);\n return undefined;\n }\n\n if (attempt === 1) {\n this.#emit(\"schedule:execute\", { callback: job.fn, id: job.id });\n } else {\n this.#emit(\"schedule:retry\", {\n callback: job.fn,\n id: job.id,\n attempt,\n maxAttempts: resolveRetryConfig(job.retry, this.#retryDefaults)\n .maxAttempts\n });\n }\n\n if (timing.owner_path) {\n // A routed schedule executes inside its owning Lifecycle; retries run\n // there too, so this dispatch is a single routed attempt.\n try {\n await this.lifecycle.routes.to(\n {\n key: timing.owner_path_key ?? timing.owner_path,\n data: timing.owner_path\n },\n {\n type: \"dispatch\",\n id: job.id,\n fn: job.fn,\n job: timing,\n retry: job.retry\n } satisfies SchedulerRouteMessage\n );\n } catch (error) {\n if (isPlatformFailure(error)) {\n // Preserve the job; Lifecycle defers platform-class failures to a\n // fresh invocation or the memory-limit breaker.\n throw error;\n }\n console.error(\n `error dispatching scheduled callback \"${job.fn}\"`,\n error\n );\n this.#emit(\"schedule:error\", {\n callback: job.fn,\n id: job.id,\n error: error instanceof Error ? error.message : String(error),\n attempts: 0\n });\n try {\n await this.#onError?.(error);\n } catch {\n // swallow onError errors\n }\n // Leave the job due so a later alarm cycle can retry dispatch, for\n // example once a transport can resolve its owner again.\n return \"yield\";\n }\n return this.#recurrenceOutcome(timing);\n }\n\n const handler = this.#resolveCallback(job.fn);\n if (!handler) {\n console.error(`callback ${job.fn} not found`);\n return this.#recurrenceOutcome(timing);\n }\n const schedule = this.#jobToSchedule<unknown>(job, timing);\n await this.lifecycle.runInHostContext(() =>\n handler(timing.payload, schedule)\n );\n return this.#recurrenceOutcome(timing);\n }\n\n /** Observe one schedule's terminal application failure. */\n async onJobError(\n context: LifecycleJobContext,\n error: unknown\n ): Promise<LifecycleJobOutcome | void> {\n const { job } = context;\n const timing = job.payload;\n if (!isSchedulerJobPayload(timing)) return undefined;\n const { maxAttempts } = resolveRetryConfig(job.retry, this.#retryDefaults);\n console.error(\n `error executing callback \"${job.fn}\" after ${maxAttempts} attempts`,\n error\n );\n this.#emit(\"schedule:error\", {\n callback: job.fn,\n id: job.id,\n error: error instanceof Error ? error.message : String(error),\n attempts: maxAttempts\n });\n try {\n await this.#onError?.(error);\n } catch {\n // swallow onError errors\n }\n return this.#recurrenceOutcome(timing);\n }\n\n /** Advance a recurring schedule; complete a one-shot. */\n #recurrenceOutcome(timing: SchedulerJobPayload): LifecycleJobOutcome {\n if (timing.type === \"cron\") {\n return { rescheduleAt: nextCronTimeMs(timing.cron ?? \"\", Date.now()) };\n }\n if (timing.type === \"interval\") {\n return {\n rescheduleAt: Date.now() + (timing.intervalSeconds ?? 0) * 1000\n };\n }\n return undefined;\n }\n\n /** Handle Scheduler protocol messages routed by another Lifecycle. */\n async onRoute(context: LifecycleRouteContext): Promise<unknown> {\n const message = context.payload as SchedulerRouteMessage;\n const owner = context.source ?? null;\n switch (message.type) {\n case \"schedule\":\n return this.#insert(\n owner,\n parseWhen(message.when, Date.now(), message.callback),\n message.callback,\n message.payload,\n message.options\n );\n case \"every\":\n return this.#insert(\n owner,\n parseInterval(message.intervalSeconds, Date.now()),\n message.callback,\n message.payload,\n message.options\n );\n case \"get\":\n return this.#getForOwner(owner, message.id);\n case \"list\":\n return this.#listForOwner(owner, message.criteria);\n case \"cancel\":\n return this.#cancelForOwner(owner, message.id);\n case \"dispatch\":\n await this.#executeRouted(\n message.id,\n message.fn,\n message.job,\n message.retry\n );\n return true;\n default:\n throw new Error(\"Unknown routed Scheduler message\");\n }\n }\n\n /**\n * Execute a routed schedule locally with the historical retry handling.\n * Runs on the owning (facet) Scheduler, outside the root's event loop, so\n * it applies its own in-process retry budget. Platform-class failures on a\n * one-shot re-throw so the root preserves the job and the durable alarm\n * retries on a fresh invocation.\n */\n async #executeRouted(\n id: string,\n fn: string,\n timing: SchedulerJobPayload,\n retry: RetryOptions | undefined\n ): Promise<void> {\n const handler = this.#resolveCallback(fn);\n if (!handler) {\n console.error(`callback ${fn} not found`);\n return;\n }\n const { maxAttempts, baseDelayMs, maxDelayMs } = resolveRetryConfig(\n retry,\n this.#retryDefaults\n );\n const isOneShot = timing.type === \"delayed\" || timing.type === \"scheduled\";\n const schedule = this.#payloadToSchedule<unknown>(id, fn, timing);\n try {\n await tryN(\n maxAttempts,\n async (attempt) => {\n if (attempt > 1) {\n this.#emit(\"schedule:retry\", {\n callback: fn,\n id,\n attempt,\n maxAttempts\n });\n }\n await this.lifecycle.runInHostContext(() =>\n handler(timing.payload, schedule)\n );\n },\n {\n baseDelayMs,\n maxDelayMs,\n shouldRetry: (error) =>\n !(isOneShot && isDurableObjectCodeUpdateReset(error))\n }\n );\n } catch (error) {\n if (isOneShot && isPlatformFailure(error)) {\n throw error;\n }\n console.error(\n `error executing callback \"${fn}\" after ${maxAttempts} attempts`,\n error\n );\n this.#emit(\"schedule:error\", {\n callback: fn,\n id,\n error: error instanceof Error ? error.message : String(error),\n attempts: maxAttempts\n });\n try {\n await this.#onError?.(error);\n } catch {\n // swallow onError errors\n }\n }\n }\n\n // ── Scheduling API ───────────────────────────────────────────────────────\n\n /** Set a delayed, dated, or cron schedule for a registered callback. */\n async set<Name extends keyof Handlers & string>(\n when: Date | string | number,\n callback: Name,\n payload?: SchedulerPayload<Handlers[Name]>,\n options?: ScheduleOptions\n ): Promise<Schedule<SchedulerPayload<Handlers[Name]>>> {\n await this.lifecycle.ready();\n this.#validateSchedule(when, callback, options);\n const result = this.lifecycle.routes.source\n ? ((await this.lifecycle.routes.toRoot({\n type: \"schedule\",\n when,\n callback,\n payload,\n options\n } satisfies SchedulerRouteMessage)) as InsertResult<\n SchedulerPayload<Handlers[Name]>\n >)\n : await this.#insert<SchedulerPayload<Handlers[Name]>>(\n null,\n parseWhen(when, Date.now(), callback),\n callback,\n payload,\n options\n );\n this.#emitCreated(result);\n return result.schedule;\n }\n\n /** Set a fixed-interval schedule for a registered callback. */\n async every<Name extends keyof Handlers & string>(\n intervalSeconds: number,\n callback: Name,\n payload?: SchedulerPayload<Handlers[Name]>,\n options?: ScheduleOptions\n ): Promise<Schedule<SchedulerPayload<Handlers[Name]>>> {\n await this.lifecycle.ready();\n this.#validateInterval(intervalSeconds, callback, options?.retry);\n const result = this.lifecycle.routes.source\n ? ((await this.lifecycle.routes.toRoot({\n type: \"every\",\n intervalSeconds,\n callback,\n payload,\n options\n } satisfies SchedulerRouteMessage)) as InsertResult<\n SchedulerPayload<Handlers[Name]>\n >)\n : await this.#insert<SchedulerPayload<Handlers[Name]>>(\n null,\n parseInterval(intervalSeconds, Date.now()),\n callback,\n payload,\n options\n );\n this.#emitCreated(result);\n return result.schedule;\n }\n\n /** Get a schedule by ID. Works inside routed sub-agents. */\n async get(id: string): Promise<Schedule<unknown> | undefined> {\n await this.lifecycle.ready();\n return this.lifecycle.routes.source\n ? ((await this.lifecycle.routes.toRoot({\n type: \"get\",\n id\n } satisfies SchedulerRouteMessage)) as Schedule<unknown> | undefined)\n : this.#getForOwner(null, id);\n }\n\n /** List schedules matching criteria. Works inside routed sub-agents. */\n async list(criteria: ScheduleCriteria = {}): Promise<Schedule<unknown>[]> {\n await this.lifecycle.ready();\n return this.lifecycle.routes.source\n ? ((await this.lifecycle.routes.toRoot({\n type: \"list\",\n criteria\n } satisfies SchedulerRouteMessage)) as Schedule<unknown>[])\n : this.#listForOwner(null, criteria);\n }\n\n /**\n * Cancel one schedule owned by this Scheduler.\n *\n * @param id - ID of the schedule to cancel.\n * @returns True when a schedule was cancelled, false when none matched.\n */\n async cancel(id: string): Promise<boolean> {\n await this.lifecycle.ready();\n const result = this.lifecycle.routes.source\n ? ((await this.lifecycle.routes.toRoot({\n type: \"cancel\",\n id\n } satisfies SchedulerRouteMessage)) as {\n ok: boolean;\n callback?: string;\n })\n : await this.#cancelForOwner(null, id);\n if (result.ok && result.callback) {\n this.#emit(\"schedule:cancel\", { callback: result.callback, id });\n }\n return result.ok;\n }\n\n // ── Host-owned policy apertures ──────────────────────────────────────────\n\n /**\n * @internal Synchronous read backing Agent's deprecated `getSchedule()`.\n * Not part of the primitive's contract — use {@link get}. Cannot cross\n * Durable Object boundaries and throws inside routed sub-agents.\n */\n __DO_NOT_USE_WILL_REMOVE__getSchedule<T = string>(\n id: string\n ): Schedule<T> | undefined {\n if (this.lifecycle.routes.source) {\n throw new Error(\n \"getSchedule() is synchronous and cannot read routed schedule storage. \" +\n \"Use await getScheduleById(id) on Agent, or await scheduler.get(id) \" +\n \"on a standalone Scheduler.\"\n );\n }\n return this.#getForOwner(null, id);\n }\n\n /**\n * @internal Synchronous read backing Agent's deprecated `getSchedules()`.\n * Not part of the primitive's contract — use {@link list}. Cannot cross\n * Durable Object boundaries and throws inside routed sub-agents.\n */\n __DO_NOT_USE_WILL_REMOVE__getSchedules<T = string>(\n criteria: ScheduleCriteria = {}\n ): Schedule<T>[] {\n if (this.lifecycle.routes.source) {\n throw new Error(\n \"getSchedules() is synchronous and cannot read routed schedule storage. \" +\n \"Use await listSchedules(criteria) on Agent, or await \" +\n \"scheduler.list(criteria) on a standalone Scheduler.\"\n );\n }\n return this.#listForOwner(null, criteria);\n }\n\n /** @internal Remove schedules owned by one routed Lifecycle subtree. */\n async __DO_NOT_USE_WILL_BREAK__cleanupRoutePrefix(\n prefix: string\n ): Promise<void> {\n for (const { job, timing } of this.#ownedJobs()) {\n const ownerKey = timing.owner_path_key ?? timing.owner_path;\n if (!timing.owner_path || ownerKey === null || ownerKey === undefined) {\n continue;\n }\n if (ownerKey !== prefix && !ownerKey.startsWith(`${prefix}/`)) continue;\n this.#emit(\"schedule:cancel\", { callback: job.fn, id: job.id });\n await this.lifecycle.jobs.cancel(job.id);\n }\n }\n\n // ── Validation ───────────────────────────────────────────────────────────\n\n #validateSchedule(\n when: Date | string | number,\n callback: string,\n options?: ScheduleOptions\n ): void {\n if (typeof callback !== \"string\") {\n throw new Error(\"Callback must be a string\");\n }\n if (!this.#hasCallback(callback)) {\n throw new Error(\n `Unknown scheduled callback \"${callback}\": not registered on this Scheduler`\n );\n }\n if (options?.retry) {\n validateRetryOptions(options.retry, this.#retryDefaults);\n }\n if (\n !(when instanceof Date) &&\n typeof when !== \"number\" &&\n typeof when !== \"string\"\n ) {\n throw new Error(\n `Invalid schedule type: ${JSON.stringify(when)}(${typeof when}) trying to schedule ${callback}`\n );\n }\n this.#warnWhenScheduledDuringStartup(when, callback, options);\n }\n\n #validateInterval(\n intervalSeconds: number,\n callback: string,\n retry?: RetryOptions\n ): void {\n validateIntervalSeconds(intervalSeconds);\n if (typeof callback !== \"string\") {\n throw new Error(\"Callback must be a string\");\n }\n if (!this.#hasCallback(callback)) {\n throw new Error(\n `Unknown scheduled callback \"${callback}\": not registered on this Scheduler`\n );\n }\n if (retry) validateRetryOptions(retry, this.#retryDefaults);\n }\n\n /**\n * A non-idempotent one-shot created during startup accumulates one row per\n * Durable Object wake, whether it came from the host's onStart or another\n * startup hook. Warn once per callback; an explicit `idempotent` choice\n * (either value) opts out.\n */\n #warnWhenScheduledDuringStartup(\n when: Date | string | number,\n callback: string,\n options?: ScheduleOptions\n ): void {\n if (this.lifecycle.status() !== \"starting\") return;\n if (options?.idempotent !== undefined) return;\n if (typeof when === \"string\") return;\n if (this.#warnedStartupCallbacks.has(callback)) return;\n this.#warnedStartupCallbacks.add(callback);\n console.warn(\n `Scheduling \"${callback}\" during startup (e.g. onStart()) without ` +\n `{ idempotent: true } creates a new row on every Durable Object ` +\n `restart, which can cause duplicate executions. Pass ` +\n `{ idempotent: true } to deduplicate, or use an interval schedule ` +\n `for recurring tasks.`\n );\n }\n\n /** Resolve a name to its registered or composition-root-supplied handler. */\n #resolveCallback(name: string): ResolvedSchedulerCallback | undefined {\n const handler = this.#handlers[name];\n if (handler) {\n // SAFETY: registered handlers are constrained with `never` parameters\n // so concrete handler types satisfy the map under contravariance; the\n // payload passed at dispatch was persisted with this handler's name.\n return handler as ResolvedSchedulerCallback;\n }\n return schedulerCallbackResolvers.get(this)?.(name);\n }\n\n /** True when a name resolves to a runnable callback. */\n #hasCallback(name: string): boolean {\n return this.#resolveCallback(name) !== undefined;\n }\n\n // ── Jobs ─────────────────────────────────────────────────────────────────\n\n /** Every schedule job this Scheduler owns, with its parsed vocabulary. */\n #ownedJobs(): Array<{ job: LifecycleJob; timing: SchedulerJobPayload }> {\n const owned: Array<{ job: LifecycleJob; timing: SchedulerJobPayload }> = [];\n for (const job of this.lifecycle.jobs.list()) {\n if (isSchedulerJobPayload(job.payload)) {\n owned.push({ job, timing: job.payload });\n }\n }\n return owned;\n }\n\n /**\n * Push a schedule job for the given owner, or return the existing job\n * when an idempotent request matches one. One-shot timings deduplicate only\n * when `idempotent: true` is passed; recurring timings deduplicate unless\n * `idempotent: false` opts out. `created: false` marks a dedup hit so\n * callers suppress the `schedule:create` event.\n */\n async #insert<T = string>(\n owner: LifecycleRouteAddress | null,\n timing: ScheduleTiming,\n callback: string,\n payload: unknown,\n options?: ScheduleOptions\n ): Promise<InsertResult<T>> {\n // Recurring timings deduplicate unless explicitly opted out; one-shot\n // timings deduplicate on any truthy value (historic Agent behavior).\n const idempotent = isRecurring(timing)\n ? options?.idempotent !== false\n : Boolean(options?.idempotent);\n // Not part of public ScheduleOptions. See RecoveryLoopScheduleOptions.\n const recoveryLoop = (\n options as Partial<RecoveryLoopScheduleOptions> | undefined\n )?.recoveryLoop;\n\n if (idempotent) {\n const existing = this.#findMatchingJob(\n owner?.key ?? null,\n timing,\n callback,\n JSON.stringify(payload)\n );\n if (existing) {\n // A dedup hit onto a row without breaker membership the caller asks\n // for (a row migrated from the legacy schedule table) re-pushes the\n // same durable intent in place with the flag — otherwise the row\n // would escape the alarm memory-limit breaker (#1825) forever.\n if (recoveryLoop && !existing.job.recoveryLoop) {\n await this.lifecycle.jobs.push({\n id: existing.job.id,\n fn: existing.job.fn,\n time: existing.job.time,\n payload: existing.job.payload,\n retry: existing.job.retry,\n singleflight: existing.job.singleflight,\n exclusive: existing.job.exclusive,\n hungTimeoutSeconds: this.#hungScheduleTimeoutSeconds,\n recoveryLoop: true\n });\n }\n // A dedup hit still re-arms so a lost physical alarm recovers, as\n // idempotent re-scheduling on startup historically guaranteed.\n await this.lifecycle.jobs.rearm();\n return {\n schedule: this.#jobToSchedule<T>(existing.job, existing.timing),\n created: false\n };\n }\n }\n\n const jobPayload: SchedulerJobPayload = {\n payload,\n retry: options?.retry,\n type: timing.type,\n delayInSeconds:\n timing.type === \"delayed\" ? timing.delayInSeconds : undefined,\n cron: timing.type === \"cron\" ? timing.cron : undefined,\n intervalSeconds:\n timing.type === \"interval\" ? timing.intervalSeconds : undefined,\n owner_path: owner?.data ?? null,\n owner_path_key: owner?.key ?? null\n };\n const job = await this.lifecycle.jobs.push({\n fn: callback,\n time: timing.time * 1000,\n payload: jobPayload,\n retry: resolveRetryConfig(options?.retry, this.#retryDefaults),\n singleflight: timing.type === \"interval\",\n hungTimeoutSeconds: this.#hungScheduleTimeoutSeconds,\n recoveryLoop\n });\n\n return {\n schedule: {\n id: job.id,\n callback,\n // SAFETY: payload is optional at the call site; historical API shape\n // types an omitted payload as the schedule's payload type.\n payload: payload as T,\n retry: options?.retry,\n ...timing\n },\n created: true\n };\n }\n\n /** Find the job an idempotent insert deduplicates onto, if any. */\n #findMatchingJob(\n ownerKey: string | null,\n timing: ScheduleTiming,\n callback: string,\n payloadJson: string\n ): { job: LifecycleJob; timing: SchedulerJobPayload } | undefined {\n for (const owned of this.#ownedJobs()) {\n const { job, timing: candidate } = owned;\n if (candidate.type !== timing.type) continue;\n if (job.fn !== callback) continue;\n if ((candidate.owner_path_key ?? null) !== ownerKey) continue;\n if (JSON.stringify(candidate.payload) !== payloadJson) continue;\n if (timing.type === \"cron\" && candidate.cron !== timing.cron) continue;\n if (\n timing.type === \"interval\" &&\n candidate.intervalSeconds !== timing.intervalSeconds\n ) {\n continue;\n }\n return owned;\n }\n return undefined;\n }\n\n #jobToSchedule<T>(\n job: LifecycleJob,\n timing: SchedulerJobPayload\n ): Schedule<T> {\n return this.#payloadToSchedule<T>(\n job.id,\n job.fn,\n timing,\n Math.floor(job.time / 1000)\n );\n }\n\n #payloadToSchedule<T>(\n id: string,\n fn: string,\n timing: SchedulerJobPayload,\n timeSeconds?: number\n ): Schedule<T> {\n const base = {\n callback: fn,\n id,\n payload: timing.payload as T,\n retry: timing.retry\n };\n const time = timeSeconds ?? 0;\n switch (timing.type) {\n case \"scheduled\":\n return { ...base, time, type: \"scheduled\" };\n case \"delayed\":\n return {\n ...base,\n delayInSeconds: timing.delayInSeconds ?? 0,\n time,\n type: \"delayed\"\n };\n case \"cron\":\n return { ...base, cron: timing.cron ?? \"\", time, type: \"cron\" };\n case \"interval\":\n return {\n ...base,\n intervalSeconds: timing.intervalSeconds ?? 0,\n time,\n type: \"interval\"\n };\n }\n }\n\n #getForOwner<T = string>(\n owner: LifecycleRouteAddress | null,\n id: string\n ): Schedule<T> | undefined {\n const ownerKey = owner?.key ?? null;\n const job = this.lifecycle.jobs.get(id);\n if (!job || !isSchedulerJobPayload(job.payload)) return undefined;\n if ((job.payload.owner_path_key ?? null) !== ownerKey) return undefined;\n return this.#jobToSchedule<T>(job, job.payload);\n }\n\n #listForOwner<T = string>(\n owner: LifecycleRouteAddress | null,\n criteria: ScheduleCriteria = {}\n ): Schedule<T>[] {\n const ownerKey = owner?.key ?? null;\n const startSeconds = criteria.timeRange\n ? Math.floor((criteria.timeRange.start ?? new Date(0)).getTime() / 1000)\n : null;\n const endSeconds = criteria.timeRange\n ? Math.floor(\n (criteria.timeRange.end ?? new Date(999999999999999)).getTime() / 1000\n )\n : null;\n\n const schedules: Schedule<T>[] = [];\n for (const { job, timing } of this.#ownedJobs()) {\n if ((timing.owner_path_key ?? null) !== ownerKey) continue;\n if (criteria.id && job.id !== criteria.id) continue;\n if (criteria.type && timing.type !== criteria.type) continue;\n const timeSeconds = Math.floor(job.time / 1000);\n if (startSeconds !== null && timeSeconds < startSeconds) continue;\n if (endSeconds !== null && timeSeconds > endSeconds) continue;\n schedules.push(this.#jobToSchedule<T>(job, timing));\n }\n return schedules;\n }\n\n async #cancelForOwner(\n owner: LifecycleRouteAddress | null,\n id: string\n ): Promise<{ ok: boolean; callback?: string }> {\n const ownerKey = owner?.key ?? null;\n const job = this.lifecycle.jobs.get(id);\n if (!job || !isSchedulerJobPayload(job.payload)) return { ok: false };\n if ((job.payload.owner_path_key ?? null) !== ownerKey) {\n return { ok: false };\n }\n const callback = job.fn;\n await this.lifecycle.jobs.cancel(id);\n return { ok: true, callback };\n }\n\n // ── Events ───────────────────────────────────────────────────────────────\n\n #emit(type: SchedulerEventType, payload: Record<string, unknown>): void {\n this.lifecycle.events.emit(type, payload);\n }\n\n #emitCreated(result: InsertResult<unknown>): void {\n if (!result.created) return;\n this.#emit(\"schedule:create\", {\n callback: result.schedule.callback,\n id: result.schedule.id\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAWA,MAAa,uBAAuB,MAAU,KAAK;;AAoCnD,SAAgB,YAAY,QAAiC;CAC3D,OAAO,OAAO,SAAS,UAAU,OAAO,SAAS;AACnD;;;;;;;;;AAUA,SAAgB,eAAe,MAAc,OAAuB;CAClE,OAAO,oBAAoB,IAAI,CAAC,CAAC,YAAY,IAAI,KAAK,KAAK,CAAC,CAAC,CAAC,QAAQ;AACxE;;;;;;;;;;;;;AAcA,SAAgB,UACd,MACA,OACA,UACgB;CAChB,IAAI,gBAAgB,MAClB,OAAO;EAAE,MAAM;EAAa,MAAM,KAAK,MAAM,KAAK,QAAQ,IAAI,GAAI;CAAE;CAEtE,IAAI,OAAO,SAAS,UAClB,OAAO;EACL,MAAM;EACN,MAAM,KAAK,OAAO,QAAQ,OAAO,OAAQ,GAAI;EAC7C,gBAAgB;CAClB;CAEF,IAAI,OAAO,SAAS,UAClB,OAAO;EACL,MAAM;EACN,MAAM,KAAK,MAAM,eAAe,MAAM,KAAK,IAAI,GAAI;EACnD,MAAM;CACR;CAEF,MAAM,IAAI,MACR,0BAA0B,KAAK,UAAU,IAAI,EAAE,GAAG,OAAO,KAAK,uBAAuB,UACvF;AACF;;;;;;;AAQA,SAAgB,wBAAwB,iBAA+B;CACrE,IAAI,OAAO,oBAAoB,YAAY,mBAAmB,GAC5D,MAAM,IAAI,MAAM,2CAA2C;CAE7D,IAAI,kBAAA,QACF,MAAM,IAAI,MACR,iCAAiC,qBAAqB,m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W,IAAI;CACrB,MAAM,KAAK,UAAU,KAAK,OAAO,EAAE;CACnC,OAAO;EAAE,IAAI;EAAM;CAAS;AAC9B;AAIA,SAAA,MAAM,MAA0B,SAAwC;CACtE,KAAK,UAAU,OAAO,KAAK,MAAM,OAAO;AAC1C;AAEA,SAAA,aAAa,QAAqC;CAChD,IAAI,CAAC,OAAO,SAAS;CACrB,kBAAA,kBAAA,MAAA,KAAA,CAAA,CAAA,KAAA,MAAW,mBAAmB;EAC5B,UAAU,OAAO,SAAS;EAC1B,IAAI,OAAO,SAAS;CACtB,CAAC;AACH"}
|
package/dist/schedules/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as Scheduler } from "../scheduler-
|
|
1
|
+
import { t as Scheduler } from "../scheduler-FIHv2-kJ.js";
|
|
2
2
|
export { Scheduler };
|
package/dist/serializable.d.ts
CHANGED