#!/usr/bin/env node
/**
 * The command-line entry point — where an `argv` slice becomes a running agent.
 *
 * This module is the thin seam between the operating system and the shell app's
 * machinery. It owns exactly four concerns and delegates everything else:
 *
 *   1. Parse the raw `argv` into a structured {@link Invocation} (the
 *      {@link tokenizeInvocation} table-driven parser).
 *   2. Short-circuit the two output-only modes — `help` (rendered from the flag
 *      table) and `version` (read from `package.json`) — without ever standing up
 *      an agent.
 *   3. For every running mode, assemble a {@link BootContext} (settings, model,
 *      tools, agent factory, I/O streams, teardown list) and hand it to the
 *      {@link selectRunner | selected} runner, returning its exit code.
 *   4. Run the context's {@link BootContext.closables} on the way out — always,
 *      success or failure — so MCP fleets and other resources close cleanly.
 *
 * It calls neither `process.exit` (the runner resolves an exit code; we set
 * `process.exitCode` instead) nor any UI toolkit. The interactive surface is a
 * minimal readline view supplied by the REPL runner. When loaded as the process
 * entry point, the bottom of the file drives {@link main} and records its result.
 */
import type { Invocation } from "./invocation/parse";
import type { Closable } from "./boot";
import type { BootContext } from "./runners";
/** The raw stream pair the CLI feeds the runners. */
export interface CliStreams {
    /** Where the runner reads its input (stdin in production). */
    readonly input: NodeJS.ReadableStream;
    /** Where the runner writes its output (stdout in production). */
    readonly output: NodeJS.WritableStream;
    /** Where diagnostics are routed; defaults to stderr. */
    readonly error?: NodeJS.WritableStream;
}
/**
 * Assemble the {@link BootContext} a runner consumes from a parsed invocation and
 * the process streams.
 *
 * The boot pipeline (settings → model → tools → agent factory) is shared with the
 * line-seam boot module; this wrapper threads the real streams onto the resulting
 * context so the stream-oriented runners (one-shot, wire, repl) can drive it, and
 * carries the boot pipeline's {@link Closable} list through so the caller can tear
 * resources down on exit.
 *
 * @param invocation the parsed CLI invocation the stages read from.
 * @param streams the input/output (and optional error) streams the runner uses.
 * @returns a runner-ready boot context whose `closables` the caller must run.
 */
export declare function buildBootContext(invocation: Invocation, streams: CliStreams): Promise<BootContext & {
    readonly closables: Closable[];
}>;
/** Build the full `--help` text from the flag table and the brand name. */
export declare function renderUsage(): string;
/**
 * Resolve the package version, reading `package.json` next to the compiled
 * bundle and falling back to a constant when it cannot be found (e.g. when the
 * file is bundled away). Never throws.
 */
export declare function resolveVersion(): string;
/**
 * Drive one CLI invocation to an exit code.
 *
 * Parses `argv`, dispatches the output-only `help`/`version` modes directly, and
 * for every running mode assembles a {@link BootContext} and hands it to the
 * selected runner. The context's {@link BootContext.closables} are always run in
 * a `finally`, in reverse registration order, so teardown happens whether the run
 * succeeded, failed, or threw. Resolves the process exit code (never calls
 * `process.exit`).
 *
 * @param argv the argument slice after the runtime + script names. Defaults to
 *   `process.argv.slice(2)`.
 * @returns the exit code: 0 on success, non-zero on failure.
 */
export declare function main(argv?: readonly string[]): Promise<number>;
