import { type ConfigContext, type RelayConsoleSession, type RelayConsoleOAuthSession, type RelayConsoleOrganizationKey } from "./config.js"; import { type InteractivePrompts } from "./interactive.js"; import { type AgentImageUploadResult } from "./agent-image-upload.js"; /** The device flow ends in a Relay-Auth session: the bearer plus the person it belongs to. */ interface DeviceToken { user: { id: string; email: string; name?: string; }; access_token: string; expires_at: number; } export interface ConsoleAuthDependencies { context: ConfigContext; apiURL?: string; fetch?: typeof globalThis.fetch; prompts?: InteractivePrompts; stderr?: (value: string) => void; openBrowser?: (url: string) => Promise; website?: string; nonInteractive?: boolean; /** A person at a terminal: gh's `auth login --web` lines instead of an agent's. */ human?: boolean; } export interface ConsoleRequestDependencies { context: ConfigContext; apiURL?: string; fetch?: typeof globalThis.fetch; } /** The Console's own name for a refused create whose handle is taken * (Relay-Console apps/api/src/error-copy.ts, HANDLE_TAKEN_CODE). */ export declare const HANDLE_TAKEN = "handle_taken"; /** A Console refusal, carrying its status and the Console's short code and * nothing else from the body: an upstream message can hold a token. */ export declare class ConsoleRefusal extends Error { readonly status: number; readonly code?: string | undefined; readonly appleIdEmail?: string | undefined; constructor(message: string, status: number, code?: string | undefined, appleIdEmail?: string | undefined); } export declare const saveSession: (context: ConfigContext, session: RelayConsoleSession) => Promise; /** The person the bearer belongs to, and when the session ends. */ export declare const fetchSession: (deps: ConsoleAuthDependencies, accessToken: string) => Promise; /** * Relay Console names a person's first organization itself (Relay-Console * apps/api/src/routes/me.ts, firstOrganization): GET /me creates it on the * first call and answers 409 organization_selection_required when the person * belongs to several and has not chosen one. The 409 body carries no list, so * the choice is made in Console, not here. */ export declare const readOrganization: (deps: ConsoleAuthDependencies, token: DeviceToken) => Promise; /** Ends the Relay-Auth session server-side; a failure is not fatal, the local copy is still removed. */ export declare const consoleSignOut: (deps: ConsoleRequestDependencies) => Promise; /** * One line that turns in place (ora, as gh and vercel draw it): a carriage * return and erase-line per frame, never a screen clear, and the line is * erased when the wait ends so only the result stays. */ export declare const waitingLine: (write: (value: string) => void, text: string, everyMs?: number) => { stop: () => void; }; export declare const consoleLogin: (deps: ConsoleAuthDependencies) => Promise; /** Validate the real key with Console before replacing any saved credentials. */ export declare const consoleLoginWithKey: (deps: ConsoleRequestDependencies, raw: string) => Promise; export declare const consoleLoginOrReuse: (deps: ConsoleAuthDependencies) => Promise; export interface ConsoleAgentCreateInput { handle?: string; displayName?: string; subtitle?: string; description?: string; image?: string; imageRecipe?: import("@relaymessenger/sdk").AgentImageRecipe; cwd?: string; home?: string; } export interface ConsoleAgentCreateResult { agent: { handle: string; first_name: string; image_url: string | null; }; token: string; image?: AgentImageUploadResult; } /** * The handle derived from a name the person typed: the display name in * handle letters. Relay refuses a collision rather than renaming, so the handle * sent is the handle created (server console.ts, POST /agents). */ export declare const inventedHandle: (displayName: string) => string; export declare const inventedHandleAttempts: (base: string) => string[]; export declare const createConsoleAgent: (deps: ConsoleRequestDependencies, input: ConsoleAgentCreateInput) => Promise; export declare const consoleRequest: (deps: ConsoleRequestDependencies, path: string, init?: RequestInit) => Promise; /** Console owns organization Agents; the SDK delete route owns developer Agents. */ export declare const deleteConsoleAgent: (deps: ConsoleRequestDependencies, handle: string, agentToken: string) => Promise; export {}; //# sourceMappingURL=console-auth.d.ts.map