/** * Thin launcher for `edsger` CLI commands, exposed to agents as fire-and- * forget tools. * * Design choice: we do NOT wait for the CLI to finish. CLI commands are * minutes-long workflows (AI analyses, Playwright scrapes, iOS builds) * and their real output lives in the Edsger database. The agent observes * effects through the normal query tools (`list_*` / `get_*`) on a later * poll cycle. A `get_cli_run` tool is provided for debugging — it returns * the tail of the log file and the exit status of the subprocess. */ export interface CliRunHandle { run_id: string; pid: number | null; log_path: string; started_at: string; cwd: string; } export interface SpawnOptions { /** * Working directory for the CLI subprocess. Needed for commands that * operate on a local git checkout (`pr-review`, `pr-resolve`, `build`, * `checklists`, `analyze-logs`). Resolution order: * 1. Explicit `cwd` argument * 2. EDSGER_CLI_WORKSPACE env var (operator-level default) * 3. process.cwd() (fallback — usually wrong for repo-scoped commands) */ cwd?: string; } export interface CliRunStatus extends CliRunHandle { exit_code: number | null; still_running: boolean; log_tail: string; log_bytes: number; } export declare class CliBinaryNotFoundError extends Error { readonly binary: string; readonly detail: string; constructor(binary: string, detail: string); } export declare function preflightCliBinary(): void; /** * Launch an `edsger [args...]` subprocess in detached mode and * return a handle immediately. The subprocess's stdout+stderr are merged * into a single log file the caller can tail via `getCliRunStatus`. * * The child is `unref`'d so it does not block the worker's event loop from * exiting — but since agents typically outlive any single CLI run, this is * mostly defensive. */ export declare class CliConcurrencyLimitError extends Error { readonly running: number; readonly limit: number; constructor(running: number, limit: number); } export declare function spawnEdsgerCli(command: string, args?: string[], options?: SpawnOptions): CliRunHandle; /** * Look up a run by id. Returns the current exit code (if the subprocess * has completed), whether it's still running, and the last few KB of log * output. If the run is not in the in-memory registry (e.g. worker was * restarted between the spawn and the status check) we fall back to just * reading the log file, with `still_running = null` semantics folded into * `pid = null, exit_code = null`. */ export declare function getCliRunStatus(runId: string): CliRunStatus | null; export interface ActiveCliRun { run_id: string; pid: number | null; log_path: string; started_at: string; command: string; args: string[]; cwd: string; } /** * Snapshot the runs we still consider in-flight from the in-memory registry. * * Used by the session-turn command to hand off long-running background work to * a persistent watcher (the desktop main process) after the ephemeral turn * process exits: the turn emits these handles on stdout, the watcher polls them * to completion, then re-engages the agent to report results — so the user * never has to ask "is it done yet?". */ export declare function listActiveCliRuns(): ActiveCliRun[]; /** Test hook — clear the in-memory registry and the preflight cache. */ export declare function __resetCliRunsForTests(): void;