import type { SessionListEntry } from './types.js'; import type { ErrorClass } from './output/envelope.js'; export declare const EXIT: { readonly OK: 0; readonly ERROR: 1; readonly USAGE: 2; readonly NOT_FOUND: 3; readonly AUTH: 4; readonly RATE_LIMITED: 5; readonly PARTIAL: 10; readonly NO_CHANGES: 42; }; export type ExitCode = (typeof EXIT)[keyof typeof EXIT]; /** * Constructor options for SessionReaderError. * * Phase 3 (er/03): `errorClass` is REQUIRED at the type level. Phase 0 * shipped it as optional defaulting to 'internal'; Phase 1+2 swept every * production call-site to set it explicitly. Making it required now is * the compile-time guard that prevents new SessionReaderError sites from * regressing back to the 'internal' default. * * Phase 3 (er/04): `exitCode` is REQUIRED at the type level so every new * error throw must pick a semantic exit code (USAGE/NOT_FOUND/AUTH/...). * Phase 0 defaulted to ERROR/1, which silently classified validation * failures as internal errors for any code path that forgot to set one. */ export interface SessionReaderErrorOptions { /** Stable identifier, e.g. SESSION_NOT_FOUND. Defaults to UNKNOWN_ERROR. */ code?: string; /** Semantic exit code (er/04). Required so every error picks one explicitly. */ exitCode: ExitCode; /** Machine-readable error class (er/03). Required at the type level. */ errorClass: ErrorClass; detail?: Record; suggestion?: string; /** * Whether the operation can be retried (er/09). Optional, defaults to * false. Set to true only for transient/recoverable conditions (e.g. * NEW_SESSION_NOT_DETECTED, JOB_TIMEOUT, transient FS errors). */ retry?: boolean; cause?: unknown; } export declare class SessionReaderError extends Error { readonly code: string; readonly exitCode: ExitCode; readonly detail: Record; readonly suggestion?: string; readonly retry: boolean; /** * v2 envelope error class. Phase 3 (er/03) makes this REQUIRED at the * constructor type level via SessionReaderErrorOptions so the type checker * rejects any new throw site that omits the classification. */ readonly class: ErrorClass; constructor(message: string, opts: SessionReaderErrorOptions); toJSON(): Record; } export declare class SessionNotFoundError extends SessionReaderError { constructor(sessionId: string, context?: { totalSessions?: number; prefixMatches?: SessionListEntry[]; }); } export declare class ParseError extends SessionReaderError { constructor(filePath: string, reason: string); } export declare class InvalidRangeError extends SessionReaderError { constructor(from: number, to: number, total: number); } export declare class TokenBudgetExceededError extends SessionReaderError { constructor(requested: number, available: number, sessionId: string); } export declare function exitCodeForError(err: unknown): ExitCode; export declare function recordParserWarning(filePath: string, reason: string): void; export declare function consumeParserWarnings(): number; export declare function peekParserWarnings(): number; //# sourceMappingURL=errors.d.ts.map