import { a as ArtifactsCLIInput, d as ArtifactImportSource, f as ArtifactRepoSummary, l as ArtifactClient, m as ArtifactScope, o as ArtifactsCLIResult, u as ArtifactImportOptions } from "./shared-C9CTqSgh.js"; import { a as ShareOptions, t as AssetsClient } from "./shared-DwuIaYac.js"; import { t as WorkspaceEgressPolicy } from "./shared-3MpgXJDw.js"; import { St as DurableObjectStorageLike, _t as SQLiteWorkspaceProviderOptions, bt as MkdirOptions, gt as SQLiteWorkspaceProvider, ht as GitCliResult, i as GitIdentity, mt as GitCliInput, n as GitClient, r as GitClientFactory, vt as WriteFileContent, xt as Database, yt as WriteFileOptions } from "./shared-BTtKnEVB.js"; import { a as WorkspaceFilesystem, c as ReadFileOptions, d as GrepOptions, f as WorkspaceGrepMatch, i as ChangeCursor, l as ReaddirOptions, m as WorkspaceFoundEntry, n as WorkspaceBackend, o as WorkspaceStatResult, p as FindOptions, s as RmOptions, t as BackendHandle, u as WorkspaceDirentResult } from "./shared-C-sNJ-xg.js"; import { A as KillSignal, C as WorkspaceRuntimePendingCall, D as WorkspaceRuntimeValue, E as WorkspaceRuntimeTruncation, F as ApplyResult, I as SkippedEntry, M as WorkspaceBackendInfo, N as WorkspaceRuntime, O as ExecEncoding, P as TruncatedOutput, S as WorkspaceRuntimeOutputOptions, T as WorkspaceRuntimeStatus, _ as WorkspaceRuntimeExecOptions, a as WorkspaceModuleBackendHandle, b as WorkspaceRuntimeKillOptions, c as WorkspaceModuleFactory, d as WorkspaceModuleHost, f as WorkspaceRegisteredBackend, g as WorkspaceRuntimeExecHandle, h as WorkspaceRuntimeEvent, i as WorkspaceModuleBackend, j as WorkspaceExecEvent, k as ExecSyncResult, l as WorkspaceModuleFunction, m as WorkspaceRuntimeDisposeOptions, n as ModuleExecutionInput, o as WorkspaceModuleBackendHost, p as WorkspaceRuntimeAccess, r as WorkspaceModule, s as WorkspaceModuleCallContext, t as ModuleExecutionEnvelope, u as WorkspaceModuleFunctions, v as WorkspaceRuntimeGetOptions, w as WorkspaceRuntimeResult, x as WorkspaceRuntimeLoader, y as WorkspaceRuntimeInterruptPolicy } from "./shared-BP8PrtyI.js"; import { a as noopObserver, i as WorkspaceSpan, n as WorkspaceAttributes, r as WorkspaceObserver, t as WorkspaceAttributeValue } from "./shared-DYgflRlD.js"; import { a as WorkspaceServiceProxyProps, i as WorkspaceServiceProxy, n as WorkspaceProxy, r as WorkspaceProxyProps, t as ArtifactsCLITarget } from "./shared-C4j1mCMr.js"; import { a as MutableFileStore, i as FileStore, r as FileStat, t as WorkspaceFileStore } from "./shared-Byn69p18.js"; import { RpcTarget } from "capnweb"; //#region ../dofs/dist/sync/operations.d.ts type SyncDirection = "pull" | "push"; type SyncMode = "entries" | "pack"; //#endregion //#region ../rpc/dist/sync-engine.d.ts interface SyncProgress { readonly operationId: string; readonly generation: string; readonly backend: string; readonly direction: SyncDirection; readonly mode: SyncMode; readonly cursor: ChangeCursor; readonly targetCursor: ChangeCursor; readonly entries: number; readonly bytes: number; readonly skipped: number; readonly complete: boolean; } //#endregion //#region src/backends/test.d.ts interface TestBackendOptions { url: string; id?: string; } declare class TestBackend implements WorkspaceBackend { #private; readonly type = "test"; readonly id: string; constructor(options: TestBackendOptions); connect(): Promise; } //#endregion //#region src/sh.d.ts interface RawShellValue { raw: string; } type ShellValue = string | number | RawShellValue | ReadonlyArray; declare function shellQuote(arg: string): string; declare function sh(strings: TemplateStringsArray, ...values: ShellValue[]): string; //#endregion //#region src/mounts/types.d.ts interface MountBase { readonly kind: string; readonly mode: "read-only" | "read-write"; readonly maxBytes?: number; readonly maxEntries?: number; readonly version?: string | (() => Promise); } interface EagerMount extends MountBase { readonly strategy: "eager"; materialize(api: MountWriteAPI): Promise; } type Mount = EagerMount; type MountFactory = (ctx: MountContext) => Mount; interface MountContext { sessionId: string; root: string; vfs: SQLiteWorkspaceProvider; } interface MountWriteAPI { readonly root: string; writeFile(absPath: string, source: ReadableStream, mode?: number): Promise; mkdir(absPath: string, mode?: number): Promise; } //#endregion //#region src/mounts/registry.d.ts type MountValue = Mount | MountFactory; //#endregion //#region src/observe/sync-telemetry.d.ts /** Default Durable Object active-CPU allowance, in milliseconds. */ declare const DEFAULT_CPU_LIMIT_MS = 30000; interface SyncBlockTelemetry { readonly backend: string; readonly direction: "pull" | "push"; readonly mode: "entries" | "pack"; readonly operationId: string; readonly generation: string; readonly entries: number; readonly bytes: number; readonly skipped: number; readonly complete: boolean; /** Wall time for this block, which for a sync block tracks CPU closely. */ readonly blockMs: number; readonly cursorRev: number; readonly targetRev: number; readonly cpuLimitMs?: number; } interface SyncOperationTelemetry { readonly backend: string; readonly direction: "pull" | "push"; readonly mode: "entries" | "pack"; readonly operationId: string; readonly generation: string; readonly blocks: number; readonly entries: number; readonly bytes: number; readonly skipped: number; readonly totalMs: number; readonly worstBlockMs: number; /** How many blocks ran from a recreated iterable rather than a reused one. */ readonly restarts: number; } type TelemetryRecord = Record; /** * Build the flat record for one committed block. * * `headroom` is the ratio of the CPU allowance to what this block * actually spent, so `min(headroom)` over a session is the direct * answer to whether block sizing is safe in production. It is omitted * for a zero-duration block, where the ratio is meaningless rather than * infinite. */ declare function syncBlockLog(input: SyncBlockTelemetry): TelemetryRecord; /** * Build the flat record for a completed operation. * * `bytesPerSecond` here is the field that closes the open question * behind the pack thresholds. The benchmarks could only price the * bytes/CPU trade against hypothetical link speeds; this measures what * the real hop achieves. */ declare function syncOperationLog(input: SyncOperationTelemetry): TelemetryRecord; interface SyncLoggerOptions { /** * Set false to silence emission. Present so a caller can keep the * wiring in place and turn the volume off, rather than branching at * every call site. */ readonly enabled?: boolean; /** Sink for one serialized record. Defaults to console.log. */ readonly log?: (line: string) => void; } interface SyncLogger { block(input: SyncBlockTelemetry): void; operation(input: SyncOperationTelemetry): void; } /** * Emit sync telemetry as single-line JSON. * * A throwing sink is swallowed. Telemetry exists to observe sync, and * an observability failure must not be able to fail the sync it is * watching. */ declare function createSyncLogger(options?: SyncLoggerOptions): SyncLogger; //#endregion //#region src/runtime/output-files.d.ts /** How a Workspace cuts command output and where it saves the rest. */ interface WorkspaceOutputOptions { /** The most lines a result keeps per stream. Defaults to 2000. */ readonly maxLines?: number; /** The most bytes a result keeps per stream. Defaults to 64 KiB. */ readonly maxBytes?: number; /** The absolute Workspace directory full output is saved in. Defaults to `/.computer/output`. */ readonly dir?: string; /** How many saved output files to keep, newest first. Defaults to 50. */ readonly keep?: number; } //#endregion //#region src/workspace.d.ts interface WorkspaceOptions { storage: DurableObjectStorageLike; backends?: WorkspaceRegisteredBackend[]; now?: () => number; sessionId?: string; mounts?: Record; observer?: WorkspaceObserver; syncTelemetry?: SyncLogger; syncTelemetryEnabled?: boolean; git?: WorkspaceGitFactory; defaultGitIdentity?: GitIdentity; assets?: AssetsClient | ((ws: Workspace) => AssetsClient); artifacts?: { binding: Artifacts; sessionId?: string | null; }; output?: WorkspaceOutputOptions | false; } type WorkspaceGitFactory = GitClientFactory; declare class Workspace { #private; constructor(options: WorkspaceOptions); ensureMountsIndexed(): Promise; mounts(): Map; get db(): Database; get observer(): WorkspaceObserver; get fs(): WorkspaceFilesystem; get sessionId(): string; get assets(): AssetsClient | undefined; get git(): GitClient; get artifacts(): ArtifactClient; get runtime(): WorkspaceRuntime; /** * Underlying dofs `SQLiteWorkspaceProvider` over the local store. * * This is the `@platformatic/vfs`-shaped provider — a node:fs * surface with full symlink support. Callers that want a * `VirtualFileSystem` (e.g. to hand to isomorphic-git) wrap it * themselves to keep `@platformatic/vfs` out of this package's * dependency tree: * * ```ts * import { create, VirtualProvider } from "@platformatic/vfs"; * import type { SQLiteWorkspaceProvider } from "@cloudflare/dofs"; * * class Glue extends VirtualProvider { * constructor(private inner: SQLiteWorkspaceProvider) { super(); } * override get readonly() { return this.inner.readonly; } * override get supportsSymlinks() { return this.inner.supportsSymlinks; } * override get supportsWatch() { return this.inner.supportsWatch; } * } * // Forward every node:fs method to `inner` via a * // `for (const name of [...]) Object.defineProperty(...)` loop. * const vfs = create(new Glue(workspace.provider())); * ``` * * Available immediately; doesn't need `ready()` because the * provider only reads/writes the local store, not the wire. */ provider(): SQLiteWorkspaceProvider; ready(options?: string | { all?: boolean; }): Promise; stub(): WorkspaceStub; pull(id?: string): AsyncIterable; push(id?: string): AsyncIterable; close(): Promise; } //#endregion //#region src/stub.d.ts declare class WorkspaceFilesystemStub extends RpcTarget { #private; constructor(ws: Workspace); [Symbol.dispose](): void; readFile(path: string): Promise>; readFile(path: string, encoding: "utf8"): Promise; readFile(path: string, options: ReadFileOptions & { encoding?: undefined; }): Promise>; readFile(path: string, options: ReadFileOptions & { encoding: "utf8"; }): Promise; readFile(path: string, options: ReadFileOptions): Promise>; exists(path: string): Promise; stat(path: string): Promise; statOrNull(path: string): Promise; lstat(path: string): Promise; lstatOrNull(path: string): Promise; readlink(path: string): Promise; readdir(path: string, options?: ReaddirOptions): Promise; find(directory: string, pattern?: string, options?: FindOptions): Promise; ls(prefix: string): Promise; grep(pattern: string, path: string, options?: GrepOptions): Promise; writeFile(path: string, content: WriteFileContent, options?: WriteFileOptions): Promise; mkdir(path: string, options?: MkdirOptions): Promise; rm(path: string, options?: RmOptions): Promise; rename(oldPath: string, newPath: string): Promise; chmod(path: string, mode: number): Promise; symlink(target: string, path: string): Promise; } declare class WorkspaceRuntimeExecHandleStub extends RpcTarget { #private; constructor(handle: WorkspaceRuntimeExecHandle); [Symbol.dispose](): void; get id(): string; get backend(): string; result(): Promise>; stream(): ReadableStream; kill(signal?: WorkspaceRuntimeKillOptions["signal"]): Promise; } declare class WorkspaceRuntimeStub extends RpcTarget { #private; constructor(ws: Workspace); [Symbol.dispose](): void; /** What each backend says about itself. A client snapshots this when it is created. */ backends(): WorkspaceBackendInfo[]; exec(source: string): Promise>; exec(source: string, options: WorkspaceRuntimeExecOptions<"utf8">): Promise>; exec(source: string, options: WorkspaceRuntimeExecOptions): Promise>; getExec(id: string): Promise>; getExec(id: string, options: WorkspaceRuntimeGetOptions<"utf8">): Promise>; getExec(id: string, options: WorkspaceRuntimeGetOptions): Promise>; killExec(id: string, options?: WorkspaceRuntimeKillOptions): Promise; disposeExec(id: string, options?: { backend?: string; }): Promise; pending(): Promise; respond(id: string, callId: string, answer: WorkspaceRuntimeValue, options?: { backend?: string; }): Promise; } declare class WorkspaceAssetsStub extends RpcTarget { #private; constructor(ws: Workspace); [Symbol.dispose](): void; publish(path: string, options: Pick): Promise; } declare class WorkspaceArtifactsStub extends RpcTarget { #private; constructor(artifacts: ArtifactClient); [Symbol.dispose](): void; create(name: string, opts?: { readOnly?: boolean; description?: string; setDefaultBranch?: string; }): Promise; get(name: string): Promise; list(): Promise; import(name: string, source: ArtifactImportSource, opts?: ArtifactImportOptions): Promise; delete(name: string): Promise; createToken(name: string, scope?: ArtifactScope, ttl?: number): Promise; listTokens(name: string): Promise; getToken(name: string, id: string): Promise; revokeToken(name: string, tokenOrId: string): Promise; cli(input: ArtifactsCLIInput): Promise; } declare class WorkspaceGitStub extends RpcTarget { #private; constructor(ws: Workspace); [Symbol.dispose](): void; cli(input: GitCliInput): Promise; } declare class WorkspaceStub extends RpcTarget { #private; constructor(ws: Workspace); [Symbol.dispose](): void; get fs(): WorkspaceFilesystemStub; get runtime(): WorkspaceRuntimeStub; get git(): WorkspaceGitStub; get assets(): WorkspaceAssetsStub | undefined; get hasAssets(): boolean; get artifacts(): WorkspaceArtifactsStub; } //#endregion //#region src/with-workspace.d.ts declare const WORKSPACE: unique symbol; interface WorkspaceStubHost { __getWorkspaceStub(): Promise; } interface WorkspaceLocalHost { [WORKSPACE]: Workspace; } type DOCtor = new (...args: any[]) => object; type WithWorkspaceCtor = TBase & (new (...args: any[]) => InstanceType & WorkspaceStubHost & WorkspaceLocalHost); declare function withWorkspace(Base: TBase, options: (self: InstanceType) => WorkspaceOptions): WithWorkspaceCtor; //#endregion //#region src/client.d.ts interface WorkspaceRuntimeClient { exec(strings: TemplateStringsArray, ...values: ShellValue[]): Promise>; exec(source: string): Promise>; exec(source: string, options: RuntimeExecOptions & { encoding: "utf8"; }): Promise>; exec(source: string, options: RuntimeExecOptions & { encoding?: undefined; }): Promise>; exec(source: string, options: RuntimeExecOptions): Promise>; getExec(id: string): Promise>; getExec(id: string, options: RuntimeGetOptions & { encoding: "utf8"; }): Promise>; getExec(id: string, options?: RuntimeGetOptions): Promise>; killExec(id: string, options?: RuntimeKillOptions): Promise; disposeExec(id: string, options?: { backend?: string; }): Promise; /** What each backend says about itself, as of when the client was created. */ backends(): readonly WorkspaceBackendInfo[]; } interface RuntimeExecOptions { cwd?: string; encoding?: "utf8"; backend?: string; id?: string; timeoutMs?: number; input?: WorkspaceRuntimeValue; env?: Record; stdin?: Uint8Array | string; /** Output limits for this run; see `WorkspaceRuntimeExecOptions.output`. */ output?: WorkspaceRuntimeOutputOptions | false; } interface RuntimeGetOptions { encoding?: "utf8"; backend?: string; resume?: "tail" | "full" | number; /** Output limits for this replay; see `WorkspaceRuntimeExecOptions.output`. */ output?: WorkspaceRuntimeOutputOptions | false; } interface RuntimeKillOptions { backend?: string; signal?: "SIGTERM" | "SIGKILL" | "SIGINT" | "SIGHUP"; } interface WorkspaceClient { readonly fs: WorkspaceFilesystem; readonly runtime: WorkspaceRuntimeClient; readonly git: any; readonly assets: any; readonly artifacts: any; [Symbol.dispose](): void; } type WorkspaceHandle = { [WORKSPACE]?: unknown; } | { __getWorkspaceStub(): PromiseLike; }; type AsyncMethods = { [K in keyof T as T[K] extends ((...args: never[]) => PromiseLike) ? K : never]: T[K] }; /** * What `getWorkspace` returns. Use it straight away: the durable object * is reached on the first call, and once per client. Await it for the * loaded client, which also knows the Workspace's backends and assets. */ interface LazyWorkspaceClient extends PromiseLike { readonly fs: AsyncMethods; /** `backends()` is empty until the client is awaited. */ readonly runtime: WorkspaceRuntimeClient; readonly git: any; readonly artifacts: any; /** Undefined until the client is awaited. */ readonly assets: undefined; [Symbol.dispose](): void; } /** * Where a lazy client finds its Workspace: a handle, or a function that * returns one. A function runs on the first call, and again after a * failed load, so it can use state that is only ready later, such as * an agent's parent. */ type WorkspaceSource = WorkspaceHandle | (() => WorkspaceHandle | PromiseLike); declare function getWorkspace(source: WorkspaceSource): LazyWorkspaceClient; //#endregion //#region src/exec-wire.d.ts declare function encodeExecEvents(events: ReadableStream>): ReadableStream; declare function decodeExecEvents(bytes: ReadableStream): ReadableStream>; //#endregion //#region src/mounts/providers/r2.d.ts interface R2BucketBinding { list(options?: { prefix?: string; cursor?: string; limit?: number; }): Promise<{ objects: Array<{ key: string; size: number; }>; truncated: boolean; cursor?: string; }>; get(key: string): Promise<{ body: ReadableStream; size: number; } | null>; } interface R2BucketOptions { prefix?: string; mode?: "read-only" | "read-write"; listLimit?: number; concurrency?: number; maxBytes?: number; maxEntries?: number; } declare function R2Bucket(bucket: R2BucketBinding, options?: R2BucketOptions): EagerMount; //#endregion //#region src/mounts/providers/worker-bundle.d.ts interface WorkerBundleEntry { readonly path: string; readonly type: "file" | "dir"; } type WorkerBundleFile = string | Uint8Array; type WorkerBundleTree = Readonly Promise)>>; interface WorkerBundleSource { readonly files: WorkerBundleTree; readonly version?: string; } interface WorkerBundleOptions { filter?: (entry: WorkerBundleEntry) => boolean; fileMode?: (path: string, bytes: Uint8Array) => number | undefined; version?: string | false; maxBytes?: number; maxEntries?: number; } declare function WorkerBundle(source: string | WorkerBundleTree | WorkerBundleSource, options?: WorkerBundleOptions): EagerMount; //#endregion //#region src/runtime/replay-safety.d.ts /** * Mark a host module function as unsafe to run twice. * * A replayable run interrupted while one of its calls was in flight runs * that call again when it resumes, since its response never reached the * code. That's fine for reads and idempotent writes. A function that * charges a card or sends a message once per call should be marked, so * an interruption during it fails the run instead. A function that can * deduplicate with `context.callId` doesn't need marking. * * ```ts * modules: { * "ws:billing": { charge: unsafeToRepeat(async ([order, cents]) => ...) }, * } * ``` */ declare function unsafeToRepeat(fn: F): F; //#endregion //#region src/runtime/wire.d.ts declare function encodeRuntimeEvent(event: WorkspaceRuntimeEvent): Uint8Array; declare function decodeRuntimeEvents(source: ReadableStream): ReadableStream>; //#endregion //#region src/workspace-root.d.ts /** The directory Computer's backends and tools treat as the working root. */ declare const WORKSPACE_ROOT = "/workspace"; //#endregion export { type ApplyResult, ArtifactsCLITarget, type BackendHandle, DEFAULT_CPU_LIMIT_MS, type DurableObjectStorageLike, type EagerMount, type ExecEncoding, type ExecSyncResult, type FileStat, type FileStore, type KillSignal, type LazyWorkspaceClient, type ModuleExecutionEnvelope, type ModuleExecutionInput, type Mount, type MountBase, type MountContext, type MountFactory, type MountWriteAPI, type MutableFileStore, R2Bucket, type R2BucketBinding, type R2BucketOptions, type RawShellValue, type RuntimeExecOptions, type RuntimeGetOptions, type RuntimeKillOptions, SQLiteWorkspaceProvider, type SQLiteWorkspaceProviderOptions, type ShellValue, type SkippedEntry, type SyncBlockTelemetry, type SyncLogger, type SyncLoggerOptions, type SyncOperationTelemetry, type SyncProgress, type TelemetryRecord, TestBackend, type TestBackendOptions, type TruncatedOutput, WORKSPACE_ROOT, type WithWorkspaceCtor, WorkerBundle, type WorkerBundleEntry, type WorkerBundleFile, type WorkerBundleOptions, type WorkerBundleSource, type WorkerBundleTree, Workspace, WorkspaceAssetsStub, type WorkspaceAttributeValue, type WorkspaceAttributes, type WorkspaceBackend, type WorkspaceBackendInfo, type WorkspaceClient, type WorkspaceEgressPolicy, WorkspaceFileStore, WorkspaceFilesystemStub, type WorkspaceGitFactory, WorkspaceGitStub, type WorkspaceHandle, type WorkspaceLocalHost, type WorkspaceModule, type WorkspaceModuleBackend, type WorkspaceModuleBackendHandle, type WorkspaceModuleBackendHost, type WorkspaceModuleCallContext, type WorkspaceModuleFactory, type WorkspaceModuleFunction, type WorkspaceModuleFunctions, type WorkspaceModuleHost, type WorkspaceObserver, type WorkspaceOptions, type WorkspaceOutputOptions, WorkspaceProxy, type WorkspaceProxyProps, type WorkspaceRegisteredBackend, type WorkspaceRuntimeAccess, type WorkspaceRuntimeClient, type WorkspaceRuntimeDisposeOptions, type WorkspaceRuntimeEvent, type WorkspaceRuntimeExecHandle, WorkspaceRuntimeExecHandleStub, type WorkspaceRuntimeExecOptions, type WorkspaceRuntimeGetOptions, type WorkspaceRuntimeInterruptPolicy, type WorkspaceRuntimeKillOptions, type WorkspaceRuntimeLoader, type WorkspaceRuntimeOutputOptions, type WorkspaceRuntimePendingCall, type WorkspaceRuntimeResult, type WorkspaceRuntimeStatus, WorkspaceRuntimeStub, type WorkspaceRuntimeTruncation, type WorkspaceRuntimeValue, WorkspaceServiceProxy, type WorkspaceServiceProxyProps, type WorkspaceSource, type WorkspaceSpan, WorkspaceStub, type WorkspaceStubHost, createSyncLogger, decodeExecEvents, decodeRuntimeEvents, encodeExecEvents, encodeRuntimeEvent, getWorkspace, noopObserver, sh, shellQuote, syncBlockLog, syncOperationLog, unsafeToRepeat, withWorkspace }; //# sourceMappingURL=index.d.ts.map