/**
 * Retry-from-checkpoint — relaunch the wizard from the current install dir
 * after an error or cancel outro, letting the new child process pick up the
 * existing checkpoint at `~/.amplitude/wizard/runs/<sha256(installDir)>/checkpoint.json`.
 *
 * The user-facing flow:
 *   1. Wizard hits an error / user cancels mid-run.
 *   2. OutroScreen renders the error/cancel view with a "Press R to retry" hint.
 *   3. User presses R. We spawn a detached-but-foreground child node process
 *      that re-runs the wizard binary with the same args (minus `--api-key`,
 *      and with `--install-dir` pinned to the session's installDir).
 *   4. The child reads the checkpoint and resumes from the post-detection
 *      step, skipping intro / region / org-project / framework selection.
 *   5. We wait for the child to exit and propagate its exit code.
 *
 * Why spawn rather than re-run in-process? The wizard's state is sprawled
 * across module-level singletons (UI registry, agent abort, OAuth client,
 * MCP server, etc.). A clean process restart is simpler and guaranteed
 * correct than trying to re-initialize all that state.
 *
 * Critical: do NOT call `process.exit` while the child is still running —
 * that would kill the inherited stdio. Wait for `child.on('exit', …)`.
 */
import { spawn } from 'node:child_process';
import type { WizardSession } from './wizard-session';
/**
 * Strip prefixed args (and their following value, if separated by space)
 * from an argv slice. Handles both `--foo=bar` and `--foo bar` forms.
 */
export declare function pruneArgs(args: readonly string[], prefixes?: readonly string[]): string[];
/**
 * Best-effort cleanup of stale agent-state snapshots owned by THIS process.
 * The new child gets a new pid + attemptId, so it can't collide; we delete
 * our own stragglers so they don't accumulate under `~/.amplitude/wizard/state/`.
 *
 * Files are named `<attemptId>-<pid>.json` (see `getStateFile` in
 * `storage-paths.ts`). We only touch files matching the current pid.
 */
export declare function clearStaleAgentState(pid?: number): void;
/**
 * Build the argv list for the retry child process.
 * Exposed for unit testing.
 */
export declare function buildRetryArgs(binPath: string, rawArgs: readonly string[], installDir: string): {
    node: string;
    args: string[];
};
/**
 * Spawn factory — extracted so tests can substitute a fake spawn without
 * patching `node:child_process` globally.
 */
export type SpawnFn = typeof spawn;
export interface RetryFromCheckpointOptions {
    /** Override `process.argv[1]` resolution (tests). */
    binPath?: string;
    /** Override `process.argv.slice(2)` (tests). */
    rawArgs?: readonly string[];
    /** Override the spawn function (tests). */
    spawnFn?: SpawnFn;
    /** Skip the actual `process.exit` call after child completes (tests). */
    skipExit?: boolean;
}
/**
 * Just enough of `WizardStore` for the retry call. Decoupling from the full
 * store keeps `lib/` from depending on `ui/tui/`.
 */
export interface RetryStoreLike {
    session: Pick<WizardSession, 'installDir' | 'outroData' | 'integration'>;
}
/**
 * Re-launch the wizard with the same install dir so it picks up the
 * checkpoint. Resolves with the child's exit code; the caller (OutroScreen)
 * does not normally need to inspect it because we propagate it via
 * `process.exit` here.
 *
 * This function is intentionally NOT async-throwing: any failure to spawn
 * is caught and surfaced as exit code 1, matching the "best-effort, not a
 * guarantee" contract of the retry hotkey.
 */
export declare function retryFromCheckpoint(store: RetryStoreLike, opts?: RetryFromCheckpointOptions): Promise<number>;
