/** * A {@link @nhtio/adk/batteries/media/contracts!ScratchWorkspace} implementation backed by the * local filesystem via `node:fs/promises`. * * @module @nhtio/adk/batteries/media/engines/fs_workspace * * @remarks * The bundled filesystem workspace. `node:fs/promises` is acquired through an async resolver * (default: a lazy dynamic import) so this module carries no static `node:*` import and the * builtin loads only when a workspace is actually minted. * * The factory requires an explicit `root` directory — there is no `os.tmpdir()` silent * default. Each minted workspace is a fresh unique subdirectory of `root`, removed on * `dispose()`. Any BYO implementation whose paths the paired `BinaryExecutor` can open * satisfies the same contract (tmpfs mounts, container volumes, sandbox dirs…). */ import type { ScratchWorkspaceFactory } from "../contracts"; /** The slice of `node:fs/promises` the workspace uses. */ export interface FsLike { /** Create a directory (recursively). */ mkdir(path: string, options: { recursive: true; }): Promise; /** Write bytes to a path. */ writeFile(path: string, data: Uint8Array): Promise; /** Read a file's bytes. */ readFile(path: string): Promise; /** List directory entries (basenames). */ readdir(path: string): Promise; /** Remove a path recursively, ignoring absence. */ rm(path: string, options: { recursive: true; force: true; }): Promise; } /** Resolver forms accepted for the fs module. */ export type FsResolver = FsLike | (() => FsLike | Promise); /** Options for {@link fsScratchWorkspace}. */ export interface FsScratchWorkspaceOptions { /** The directory all workspaces are minted under. Required — no platform default. */ root: string; /** The fs module or a resolver for it. Defaults to a lazy `import('node:fs/promises')`. */ fs?: FsResolver; } /** * Construct a {@link ScratchWorkspaceFactory} minting per-invocation directories under `root`. * * @param options - The root directory and fs resolver. * @returns A factory binary engines call once per invocation. */ export declare const fsScratchWorkspace: (options: FsScratchWorkspaceOptions) => ScratchWorkspaceFactory;