import { type ChildProcess } from 'node:child_process'; import type { RuntimeHost } from '../host.js'; export interface LocalTerminalHostOptions { /** * Resolve the agent-supplied `cwd` (which can be relative, absolute, or omitted) * into an absolute filesystem path. Implement your own sandbox/root check here. * * Defaults to requiring an absolute path. */ resolveCwd?: (cwd: string | undefined) => string; /** Extra env vars merged on top of `process.env`. */ env?: NodeJS.ProcessEnv; /** * Maximum number of bytes of combined stdout+stderr kept in memory per * terminal. Older bytes are dropped (FIFO). Defaults to 1 MiB. The * agent-supplied `outputByteLimit` overrides this per call. */ defaultOutputByteLimit?: number; } export type LocalTerminalHost = Required> & { /** * Live map of terminalId → child process. Useful for forced cleanup on * session teardown (e.g. iterate and `kill` every entry). Not part of the * ACP `RuntimeHost` contract — exposed as an escape hatch. */ readonly terminals: ReadonlyMap; }; /** * Build a `RuntimeHost` partial implementing ACP's terminal capability against * the local OS via `node:child_process.spawn`. * * - Accumulates stdout/stderr in a bounded ring buffer (`outputByteLimit`). * - `releaseTerminal` releases host-side bookkeeping but does NOT kill the * process — call `killTerminal` first if you want it gone (matches ACP spec). * - `waitForTerminalExit` honours the request `timeout` and resolves with the * last known exit code (`-1` if still running at timeout). * * Compose with your own permission/fs handlers; this helper has no opinions * about authorization. If you need a sandboxed cwd, supply `resolveCwd`. * * Not appropriate when: * - Your host has its own terminal UI (e.g. VS Code) — use that API instead so * the user can interact with the terminal. * - You need to run commands inside a container/jail — wrap your own spawner. */ export declare function createLocalTerminalHost(options?: LocalTerminalHostOptions): LocalTerminalHost;