import type { AgentInstallSpec } from "../../protocol/wire/acp-agent-management.js";
export type InstallEvent = {
    type: "state";
    state: "installing" | "verifying" | "installed" | "failed";
} | {
    type: "log";
    stream: "stdout" | "stderr";
    chunk: string;
} | {
    type: "done";
    ok: boolean;
    error?: string;
};
/** A child process shaped like node's, so tests can inject a fake. */
export interface InstallProc {
    stdout?: {
        on(ev: "data", cb: (c: Buffer | string) => void): void;
    } | null;
    stderr?: {
        on(ev: "data", cb: (c: Buffer | string) => void): void;
    } | null;
    on(ev: "close", cb: (code: number | null) => void): void;
    on(ev: "error", cb: (err: Error) => void): void;
}
export type InstallSpawn = (command: string, shell: boolean) => InstallProc;
/**
 * Choose the best official install command for the current platform.
 * Preference: brew (macOS only) → npm → pip → curl (POSIX shell only). Returns the raw
 * command + whether it must run through a shell (curl pipelines / shell metachars).
 */
export declare function pickInstallCommand(install: AgentInstallSpec, platform: NodeJS.Platform): {
    command: string;
    shell: boolean;
} | null;
/**
 * Inject a package-registry mirror into an install command, for users behind slow or blocked public
 * registries (e.g. PyPI / npm from mainland China, where the default index frequently times out).
 *
 * Opt-in via `mirror`: "cn" applies curated China mirrors per package manager; off (undefined) by
 * default so other users are unaffected. Only rewrites a command that hasn't already pinned a
 * registry/index, and never touches brew/curl. Returns the command unchanged when not applicable.
 */
export declare function applyInstallMirror(command: string, mirror: string | undefined): string;
/** Default spawner: split into argv (or run via shell for pipelines). */
export declare const defaultInstallSpawn: InstallSpawn;
/**
 * Run an install spec end-to-end, streaming progress via onEvent. Emits state →
 * log(s) → (verify) → done. Resolves with the final outcome.
 */
export declare function runAgentInstall(install: AgentInstallSpec, onEvent: (e: InstallEvent) => void, opts?: {
    platform?: NodeJS.Platform;
    spawnImpl?: InstallSpawn;
    mirror?: string;
}): Promise<{
    ok: boolean;
    error?: string;
}>;
