import { t as WorkspaceEgressPolicy } from "../../shared-3MpgXJDw.js"; import { C as WorkspaceRuntimePendingCall, a as WorkspaceModuleBackendHandle, i as WorkspaceModuleBackend, o as WorkspaceModuleBackendHost, p as WorkspaceRuntimeAccess, r as WorkspaceModule, x as WorkspaceRuntimeLoader, y as WorkspaceRuntimeInterruptPolicy } from "../../shared-BP8PrtyI.js"; //#region src/backends/worker-javascript/worker-javascript.d.ts interface WorkerJavaScriptBackendOptions { loader: WorkspaceRuntimeLoader; id?: string; root?: string; access?: WorkspaceRuntimeAccess; /** * Modules caller source can import by specifier. * * A string value is JavaScript source bundled into the isolate, such as * a library build. An object of functions, or a factory that builds * one, is a host module: it runs in the Durable Object under a `ws:*` * specifier, and each function becomes a named export. * * ```ts * modules: { * "tar-stream": TAR_STREAM_BUNDLE, * "ws:git": createGitModule(), * "ws:weather": { forecast: ([city]) => lookUpForecast(String(city)) }, * } * ``` * * `node:fs` and `node:fs/promises` are always installed and cannot be * replaced. The constructor throws when a specifier is not allowed, and * connecting throws when a host module's export names are not allowed. */ modules?: Record; defaultTimeoutMs?: number; maxTimeoutMs?: number; /** * The most CPU time one execution can use, in milliseconds. Each * execution's CPU limit is the smaller of its timeout and this value. * Defaults to `maxTimeoutMs`, which makes the CPU limit the timeout. * * CPU time adds up over the whole execution, however much of it is spent * waiting. Cloudflare currently stops a Dynamic Worker call at about five * minutes of CPU whatever the limit, so values above 300000 have no * effect. */ maxCpuMs?: number; /** * What happens to a run if the Durable Object restarts under it, as on * a deploy or crash. A run's own `onInterrupt` overrides it. Defaults * to `"fail"`. * * - `"fail"` settles the run as failed. * - `"restart"` runs it again from the start, once the backend * reconnects. Its output so far stays, so the run's output repeats. * - `"replay"` runs it again from the start, but answers every * filesystem, host module and `fetch` call it already made from a * journal instead of running it again, in the order the responses * first arrived. Its clock, timers and random numbers replay too. * Output already recorded isn't repeated. If the run takes a * different path, it fails. * * A run is resumed when the backend reconnects, which the next * runtime call, `ready({ all: true })` or `runtime.recover()` * triggers. It gets three attempts, counted again each time it * journals a call, and must finish within its original timeout. A * call in flight at the interruption runs again, unless it's marked * with `unsafeToRepeat()`. * * `"restart"` and `"replay"` are experimental and may change in any * release. */ onInterrupt?: WorkspaceRuntimeInterruptPolicy; /** * Called when a host module call starts waiting in `ctx.interrupt()`, * with the fields `runtime.pending()` lists, for example to ask someone * for the answer. It's called once the wait is saved, and at most once * per wait: a crash in between loses the call. Treat `pending()` as the * source of truth, for example by checking it when the object starts. * What it throws is logged and otherwise ignored. Experimental: it may * change in any release. */ onWait?: (call: WorkspaceRuntimePendingCall) => void | Promise; /** * How often to schedule a timer while any execution is running, in * milliseconds. Set it to 0 to turn the timer off. Defaults to 60 * seconds. * * From compatibility date 2026-10-01, each piece of pending work keeps * a Durable Object in memory for at most 15 minutes from when it starts. * An execution is one call into a Dynamic Worker, so one that goes * quiet, making no host calls and printing nothing, is evicted about 15 * minutes after it starts, and the eviction ends it. Host calls and * output also keep the object in memory while they keep coming, but an * execution can't be relied on to make them. Every timer counts as new * pending work, so a timer that keeps rescheduling holds the object in * memory for as long as an execution is running. The interval must be * under 15 minutes. * * The backend reads the host Worker's compatibility flags and schedules * the timer only where it helps, from 2026-10-01 or with * `durable_object_io_tasks_prevent_eviction`. * * An execution stops counting once its timeout plus `maxHostCallMs` has * passed, even if it is still waiting for a host call to settle, so a * host module that never settles can't keep the object in memory * indefinitely. While the timer runs, the object is billed for duration * and can't hibernate. * * On earlier compatibility dates, pending work and timers do not keep a * Durable Object in memory, so no timer is scheduled, and an execution * that outlives the request that started it is evicted after about a * minute. A host on an earlier date needs its own keep-alive, such as an * alarm. */ keepAliveIntervalMs?: number; maxSourceBytes?: number; maxInputBytes?: number; maxStdinBytes?: number; maxEnvBytes?: number; maxResultBytes?: number; maxStdioBytes?: number; maxCapabilityBytes?: number; /** Caller-visible deadline for one host capability call. */ maxHostCallMs?: number; maxConcurrentCapabilityCalls?: number; maxCapabilityCalls?: number; maxCapabilityRequestBytes?: number; maxCapabilityResponseBytes?: number; /** Maximum entries returned by one isolated directory read. Defaults to 1024. */ maxDirectoryEntries?: number; /** Maximum live replay subscribers per execution. Defaults to 8. */ maxExecutionSubscribers?: number; /** Completed execution retention window. Defaults to 60 minutes. */ retentionMs?: number; /** Maximum completed executions retained per backend. Defaults to 100. */ maxRetainedExecutions?: number; compatibilityDate?: string; compatibilityFlags?: string[]; egress?: WorkspaceEgressPolicy; globalOutbound?: Fetcher | null; } declare class WorkerJavaScriptBackend implements WorkspaceModuleBackend { #private; readonly protocol: "module"; readonly type = "worker-javascript"; readonly callable = true; readonly id: string; constructor(options: WorkerJavaScriptBackendOptions); /** What this backend tells a model: the source language and every importable module. */ get description(): string; connect(host: WorkspaceModuleBackendHost): Promise; } //#endregion export { WorkerJavaScriptBackend, type WorkerJavaScriptBackendOptions, type WorkspaceEgressPolicy }; //# sourceMappingURL=index.d.ts.map