import type { RuntimeHost } from '../host.js'; export interface LocalFileSystemAccessEvent { op: 'read' | 'write'; /** Resolved absolute path on disk. */ path: string; /** Path relative to the sandbox root. */ relativePath: string; } export interface LocalFileSystemHostOptions { /** Absolute path to the sandbox root. All accesses must resolve under this directory. */ root: string; /** * Called after each successful IO. Use this to wire your own logging/audit; * the helper itself does not log. Errors thrown here propagate to the caller. */ onAccess?: (event: LocalFileSystemAccessEvent) => void; /** * If true, allow paths whose realpath escapes `root` via symlinks. Defaults * to `false` — symlinked-out paths are rejected the same way as `..` escapes. */ followSymlinksOutsideRoot?: boolean; } export type LocalFileSystemHost = Required>; /** * Build a `RuntimeHost` partial that implements ACP `fs/read_text_file` and * `fs/write_text_file` against the local filesystem, sandboxed to a single * `root` directory. * * Compose with your own permission/terminal handlers: * * ```ts * const fsHost = createLocalFileSystemHost({ root: workingDirectory }); * const runtime = createAcpRuntime({ * profile, * host: { ...fsHost, requestPermission: myPrompt }, * }); * ``` * * Security model: * - `root` must be an absolute path; relative roots are rejected. * - Every requested path is resolved against `root`, then `realpath`-checked * to ensure it still lives under `root`. `..` traversal and (by default) * symlinks pointing outside the sandbox throw before any IO happens. * * Not appropriate when: * - Your host serves multiple workspace roots (e.g. a VS Code multi-root window) — * write a host that picks the right root per request instead. * - The agent runs on a different machine than the files (use a transport * that proxies `fs/*` to the real client). */ export declare function createLocalFileSystemHost(options: LocalFileSystemHostOptions): LocalFileSystemHost;