/** * Claude Code authentication: status, and the interactive login. * * The load-bearing finding behind this module (verified 2026-08-08 against * claude v2.1.226): `claude auth login --claudeai` needs NO PTY. Run with plain * pipes it prints the OAuth URL on stdout and reads the code from stdin. So the * login touches none of the screen heuristics — no `detectDialog`, no * `screenShowsWork`, nothing from the fragile family invariant nº 2 warns * about. It is a spawn, a stdout parser and one write to stdin. * * See docs/superpowers/specs/2026-08-08-claude-onboarding-design.md. */ /** * Three states, not two. * * "I observed that it is signed out" and "I could not look" are different * facts, and collapsing them was a real bug: `claude auth status` takes ~850ms * and can fail (timeout, truncated output, a busy machine), which produced an * empty stdout, which read as *signed out* — so the cockpit popped its sign-in * card and spawned a `claude auth login` child on an instance that was * perfectly signed in. Only `signed-out` is ever asserted; `unknown` is * reported as such and acted on conservatively but never announced to the user. */ export type AuthState = "signed-in" | "signed-out" | "unknown"; export interface AuthStatus { /** True only for `signed-in`. Kept for callers that just need a boolean. */ loggedIn: boolean; state: AuthState; authMethod?: string; email?: string; subscriptionType?: string; } /** Pure: `claude auth status --json`. Unreadable output is `unknown`, NOT signed out. */ export declare function parseAuthStatus(stdout: string): AuthStatus; /** Pure: the OAuth URL the CLI printed, or null if it hasn't printed one yet. */ export declare function parseLoginUrl(chunk: string): string | null; /** * Pure: the refusal the CLI printed for the code we submitted, if any. * * There is deliberately no "success" case. The invalid-code wording was * captured from the real CLI; a success wording never was, and a parser that * guessed one would produce a sign-in that silently never completes. Success is * the child exiting cleanly — see `startLogin`. */ export declare function parseLoginOutcome(chunk: string): "invalid-code" | null; export declare function invalidateAuthStatus(): void; export declare function authStatus(force?: boolean): Promise; export declare function loginPending(): boolean; export declare function cancelLogin(): void; export declare function startLogin(): Promise<{ url: string; } | { alreadySignedIn: true; } | { error: string; }>; export declare function submitLoginCode(code: string): Promise<{ ok: true; } | { ok: false; error: string; }>;