//#region src/tools/common/fs/types.d.ts /** * File-store boundary used by the workspace file tools. Stores are * cheap to construct and safe to share across concurrent tool * invocations. Streaming methods MUST NOT load the full file into * memory at any single point — that is the whole reason the boundary * exists. */ interface FileStat { /** Size in bytes. */ size: number; /** Last-modified epoch milliseconds. */ mtime: number; /** * POSIX-style mode bits (e.g. 0o100644 for a regular file, 0o100755 * for an executable). Omitted by stores that don't track modes. */ mode?: number; } interface FileStore { /** Shared identity used to coordinate mutations across adapters. */ readonly lockIdentity?: object; /** Return file metadata, or null if the path does not exist or is not a file. */ stat(path: string): Promise; /** * Stream the file (or a byte range of it) in chunks. The total * bytes yielded MUST equal min(byteLength ?? size - byteOffset, * size - byteOffset). Throws if the path does not exist. */ readChunks(path: string, byteOffset?: number, byteLength?: number): AsyncIterable; /** * Read the entire file into memory. Used for images and for the * edit tool where fuzzy matching needs the whole buffer. Returns * null if missing. */ readAll(path: string): Promise; /** * Overwrite (or create) a file with the given bytes. `opts.mode` * lets the caller pin the resulting file's POSIX mode — used by * `edit` and `write` to preserve the executable bit across an * overwrite. */ write(path: string, content: Uint8Array, opts?: { mode?: number; }): Promise; } interface MutableFileStore extends FileStore { /** Remove a file or directory. */ remove(path: string, opts?: { recursive?: boolean; force?: boolean; }): Promise; } //#endregion //#region src/tools/common/fs/store.d.ts /** * Structural subset of `@cloudflare/computer.Workspace` the tools * depend on. */ interface WorkspaceLike { fs: { stat(path: string): Promise<{ size: number; mtime: number; mode: number; isFile: boolean; isDirectory: boolean; }>; readFile(path: string, options?: { byteOffset?: number; byteLength?: number; }): Promise>; writeFile(path: string, content: Uint8Array, options?: { mode?: number; }): Promise; mkdir(path: string, options?: { recursive?: boolean; }): Promise; rm(path: string, options?: { recursive?: boolean; force?: boolean; }): Promise; find(directory: string, pattern?: string, options?: { limit?: number; offset?: number; }): Promise>; grep(pattern: string, path: string, options?: { regex?: boolean; ignoreCase?: boolean; context?: number; limit?: number; offset?: number; include?: string; exclude?: string[]; }): Promise; }>>; readdir(path: string, options?: { limit?: number; offset?: number; }): Promise>; }; } type WorkspaceFileStoreLike = { fs: Pick; }; declare class WorkspaceFileStore implements MutableFileStore { private readonly ws; readonly lockIdentity: object; constructor(ws: WorkspaceFileStoreLike); stat(path: string): Promise; readAll(path: string): Promise; write(path: string, content: Uint8Array, opts?: { mode?: number; }): Promise; remove(path: string, opts?: { recursive?: boolean; force?: boolean; }): Promise; readChunks(path: string, byteOffset?: number, byteLength?: number): AsyncIterable; } //#endregion export { MutableFileStore as a, FileStore as i, WorkspaceLike as n, FileStat as r, WorkspaceFileStore as t }; //# sourceMappingURL=shared-Byn69p18.d.ts.map