import type { Accessor } from '../accessor/base.ts'; import type { IndexConfig } from '../cache/index/config.ts'; import { type CommandIO } from '../commands/builtin/generic_bind/index.ts'; import type { ProvisionFn, RegisteredCommand } from '../commands/config.ts'; import type { RegisteredOp } from '../ops/registry.ts'; import type { FileStat, PathSpec } from '../types.ts'; import { BaseResource, type FindOptions, type Resource, type ResourceStateBase } from './base.ts'; export interface GenericResourceOptions { /** * Resource name the commands and ops register under, and the `type` * key `getState` writes into a snapshot. Also the registry key when * the backend is exposed through `registerResourceFactory`. */ name: string; /** Backend handle passed to every core fn on the table. */ accessor: A; /** The backend's IO table. */ io: CommandIO; /** LLM-facing description of the mounted layout. */ prompt?: string; /** Appended to `prompt` when the mount is writable. */ writePrompt?: string; /** * Generic command names the backend replaces. Pass the replacements * through `commands`. */ overrides?: ReadonlySet; /** * Extra commands, from `command({...})`: bespoke verbs, or the * replacements for whatever `overrides` suppressed. */ commands?: readonly RegisteredCommand[]; /** * Irregular VFS/FUSE handlers, layered over the auto-derived set. One * carrying no filetype shadows the derived op of the same name. * * Plain records rather than Python's decorated functions: TypeScript's * `op` is a *method* decorator, so a standalone handler has no * decorator form to carry its registration. */ ops?: readonly RegisteredOp[]; /** Per-command cost estimators replacing the catalog default. */ provisionOverrides?: Record>; /** * Derive the VFS/FUSE op set from the table (read/readdir/stat plus * whatever mutations the table carries). Set false to register only * the explicit `ops`. */ autoOps?: boolean; /** Serve repeat reads from the file cache. Read-mostly content only. */ cachesReads?: boolean; /** * Whether `io.stat` sizes every regular file without fetching it. A * backend that renders its content on read leaves this false and rides * the unknown-size machinery; a byte store sets it, which is also what * makes the mount legal on FSKit. */ sizesAlwaysKnown?: boolean; /** * Whether `io.stat` fills `FileStat.fingerprint` with a stable * per-path version marker. Setting it without that is not drift * detection, it is a snapshot that claims to have one. */ supportsSnapshot?: boolean; /** Cache-index configuration. Omitted leaves the lazy RAM default. */ index?: IndexConfig; } /** * A whole backend generated from one {@link CommandIO} table. * * The one-file path for a custom backend: supply an accessor and the * core functions on a table (readdir/readBytes/readStream/stat at * minimum) and the generic command set arrives wired, along with glob * resolution and the VFS/FUSE ops. Optional fields on the table unlock * more surface (`write` enables the byte-mutation family, `find` and * `du` become native fast paths), and a command whose requirements the * table cannot meet is never registered rather than registered and * broken. * * The escape hatches are the ones the builtins use, because this class * assembles exactly what they assemble by hand: `overrides` drops a * generic command, `commands` appends a bespoke verb, `ops` layers an * irregular handler over the derived set. * * Mirrors Python `mirage.resource.generic.GenericResource`. The accessor * generic is the one thing it does not mirror: it type-checks the table * against the accessor the core fns actually take, which Python leaves * as `Any` for contravariance reasons documented on its own op * protocols. */ export declare class GenericResource extends BaseResource implements Resource { #private; readonly kind: string; readonly accessor: A; readonly io: CommandIO; readonly prompt: string; readonly writePrompt: string; readonly cachesReads: boolean; readonly sizesAlwaysKnown: boolean; readonly supportsSnapshot: boolean; writeFile?: (path: PathSpec, data: Uint8Array) => Promise; appendFile?: (path: PathSpec, data: Uint8Array) => Promise; exists?: (path: PathSpec) => Promise; mkdir?: (path: PathSpec, options?: { recursive?: boolean; }) => Promise; rmdir?: (path: PathSpec) => Promise; unlink?: (path: PathSpec) => Promise; rename?: (src: PathSpec, dst: PathSpec) => Promise; truncate?: (path: PathSpec, length: number) => Promise; copy?: (src: PathSpec, dst: PathSpec) => Promise; rmR?: (path: PathSpec) => Promise; du?: (path: PathSpec) => Promise; find?: (path: PathSpec, options?: FindOptions) => Promise; constructor(options: GenericResourceOptions); open(): Promise; getState(): ResourceStateBase; commands(): readonly RegisteredCommand[]; ops(): readonly RegisteredOp[]; glob(paths: readonly PathSpec[], _prefix?: string): Promise; readFile(path: PathSpec): Promise; readdir(path: PathSpec): Promise; stat(path: PathSpec): Promise; streamPath(path: PathSpec): AsyncIterable; } //# sourceMappingURL=generic.d.ts.map