import { ApiError } from "./api-client.js"; /** * The machine-first exit-code taxonomy shared by every command. A driver keys * its control flow on these numbers alone — stderr is for humans/logs. * * See the "Exit-code taxonomy" contract note for the full mapping. */ export declare const ExitCode: { readonly SUCCESS: 0; readonly FAILURE: 1; readonly BAD_ARGS: 2; readonly AUTH: 3; readonly SESSION_NOT_FOUND: 4; readonly AMBIGUOUS_SESSION: 5; readonly SESSION_BUSY: 6; readonly AWAITING_HUMAN_INPUT: 7; readonly AGENT_ERROR: 8; readonly TIMEOUT: 9; readonly NO_BROWSER_ATTACHED: 10; readonly SKILLS_INCOMPATIBLE: 11; readonly USAGE_LIMIT: 12; readonly VERSION_CONFLICT: 13; readonly MERGE_CONFLICTS: 14; }; export type ExitCodeValue = (typeof ExitCode)[keyof typeof ExitCode]; /** * A client-side usage error (bad flags, malformed stdin, conflicting options). * Maps to exit 2 so it is distinguishable from an unexpected failure (exit 1). */ export declare class UsageError extends Error { readonly name = "UsageError"; } /** * A pull request can't merge until its conflicts are answered. Maps to exit 14 * so a driver can tell "decide on these conflicts" apart from other failures. * Carries each conflict's key and summary for the stderr envelope. */ export declare class MergeConflictsError extends Error { readonly conflicts: { key: string; reason: string; summary: string; }[]; readonly hint: string; readonly name = "MergeConflictsError"; constructor(message: string, conflicts: { key: string; reason: string; summary: string; }[], hint: string); } /** * A branch moved after the merge preview the caller resolved conflicts * against. Maps to exit 13 like the API's own version conflicts: re-read, then * decide again. */ export declare class StalePreviewError extends Error { readonly hint: string; readonly name = "StalePreviewError"; constructor(message: string, hint: string); } /** * More than one live conversation in scope and no explicit `--conversation`. * Maps to exit 5. Carries the candidate roster so the handler can print it to * stderr. */ export declare class AmbiguousSessionError extends Error { readonly sessions: unknown[]; readonly name = "AmbiguousSessionError"; constructor(message: string, sessions?: unknown[]); } /** * Installed CloudCruise skills are incompatible with this CLI version (a breaking * skills/CLI change). Maps to exit 11. Only thrown when the skills gate is set to * "refuse" and a gated command runs. */ export declare class SkillsIncompatibleError extends Error { readonly packs: string[]; readonly name = "SkillsIncompatibleError"; constructor(message: string, packs?: string[]); } /** * Map a backend error to an exit code. The machine `code` wins (it disambiguates * same-status cases like 409 SESSION_BUSY vs ALREADY_ANSWERED); HTTP status is * the fallback for any error the backend has not (yet) given a specific code. */ export declare function exitCodeForApiError(err: ApiError): ExitCodeValue; /** * Map an observed conversation status to an exit code (for observe commands like * `status`). `processing` only reaches here when a long-poll expired without * settling — the driver ticks and re-arms (exit 9). */ export declare function exitCodeForStatus(status: string): ExitCodeValue; /** * The stderr envelope and exit code for an error, kept separate from `fail` so * the mapping can be checked without exiting the process. */ export declare function buildErrorEnvelope(err: unknown): { exitCode: ExitCodeValue; envelope: Record; }; /** * Terminal error handler for every command. Writes a machine-readable error * envelope to stderr (never stdout — stdout stays clean for parsers) and exits * with the mapped code. */ export declare function fail(err: unknown): never; /** * Echo the resolved conversation on stderr so a driver always knows which * conversation a command acted on and how it was resolved (stdout stays * reserved for the answer). Naming the source lets a driver tell it fell into * implicit roster resolution — the case a second live conversation breaks with * exit 5. */ export declare function echoSession(conversationId: string, source?: "flag" | "env" | "roster"): void;