/** * CowFs - Copy-on-Write filesystem wrapper for multi-agent coordination. * * Wraps any IFileSystem and intercepts writes into a local memory layer. * Reads first check the local layer, then fall through to the parent. * This enables isolated agent workspaces that can be diffed and merged. * * Key properties: * - Reads delegate to parent if the path has not been locally written * - Writes go exclusively to the local layer (never touch parent) * - Deletions are tracked via tombstones * - The set of modified paths is available for conflict detection */ import type { BufferEncoding, CpOptions, DirentEntry, FileContent, FileSystemSnapshot, FsStat, IFileSystem, MkdirOptions, ReadFileOptions, RmOptions, WriteFileOptions } from "./interface.js"; export declare class CowFs implements IFileSystem { private readonly parent; private readonly local; private readonly deleted; private readonly modifiedPaths; constructor(parent: IFileSystem); /** * Returns the set of paths that have been locally modified or created. */ getModifiedPaths(): ReadonlySet; /** * Returns the set of paths that have been locally deleted. */ getDeletedPaths(): ReadonlySet; /** * Returns the parent filesystem for conflict detection. */ getParent(): IFileSystem; readFile(path: string, options?: ReadFileOptions | BufferEncoding): Promise; readFileBuffer(path: string): Promise; writeFile(path: string, content: FileContent, options?: WriteFileOptions | BufferEncoding): Promise; appendFile(path: string, content: FileContent, options?: WriteFileOptions | BufferEncoding): Promise; exists(path: string): Promise; stat(path: string): Promise; lstat(path: string): Promise; mkdir(path: string, options?: MkdirOptions): Promise; /** * Synchronous mkdir into the local overlay. CowFs stores everything in an * in-memory Map, so this is sound. Providing mkdirSync/writeFileSync makes * isSyncInitFs(cowFs) true, so initFilesystem() actually sets up /bin, /tmp, * /dev, etc. in a spawned sub-agent's overlay (it previously skipped init for * CowFs because only async methods existed, breaking sub-agent spawn). */ mkdirSync(path: string, options?: { recursive?: boolean; }): void; /** Synchronous writeFile into the local overlay (see mkdirSync). */ writeFileSync(path: string, content: string | Uint8Array): void; readdir(path: string): Promise; readdirWithFileTypes(path: string): Promise; rm(path: string, options?: RmOptions): Promise; cp(src: string, dest: string, options?: CpOptions): Promise; mv(src: string, dest: string): Promise; resolvePath(base: string, rel: string): string; getAllPaths(): string[]; chmod(path: string, mode: number): Promise; symlink(target: string, linkPath: string): Promise; link(existingPath: string, newPath: string): Promise; readlink(path: string): Promise; realpath(path: string): Promise; utimes(path: string, _atime: Date, mtime: Date): Promise; snapshot(): Promise; restore(snapshot: FileSystemSnapshot): Promise; /** * Ensure parent directories exist in the local layer. */ private ensureParentDirs; }