import type { AuthMethod } from "@agentclientprotocol/sdk"; import type { AuthProfile } from "./auth-profiles.js"; /** The SDK `AuthMethod.type` discriminants (ACP schema 1.21.0: `agent` | `terminal`; the former * `env_var` variant was removed upstream — agentclientprotocol/agent-client-protocol #1796/#2000). */ export type AuthMethodType = "agent" | "terminal"; /** The two credential classes (§2.1): * "disk" -> disk-persisted; apply on a fresh connection = NOTHING. * "in-process" -> per-spawn via authenticate RPC replay (§2.5). * Host-supplied env values (`AuthIntent.envValues`) ride a `disk` intent and are injected at spawn * via the §2.8 overlay; the former `spawn-env` class went with the removed `env_var` method. */ export type CredentialClass = "disk" | "in-process"; /** Type-driven, agent-agnostic classification (§2.1). Keys ONLY on the method type + whether the * advertised `_meta` is gateway-shaped — never on an agent id. */ export declare function classifyCredential(methodType: AuthMethodType, advertisedMeta: Record | null | undefined): { klass: CredentialClass; diskBacked: boolean; }; /** The host's completed auth choice, recorded as ONE immutable intent. This is the only place * credential material lives in the library — never written to a journal, emitted in an event, or * logged (§2.14). */ export interface AuthIntent { readonly backendId: string; readonly poolKey: string; readonly methodId: string; readonly methodType: AuthMethodType; readonly klass: CredentialClass; /** SECRET. The `_meta` payload for the chosen method (e.g. claude `{ gateway: { baseUrl, headers } }` * or codex `{ "api-key": { apiKey } }`). Populated for BOTH in-process and disk intents; how it is * consumed depends on `klass`, not on whether it is set. */ readonly authenticateMeta?: Record; /** SECRET; `env` resolutions only. Env values injected at agent spawn (§2.8 overlay). */ readonly envValues?: Record; /** klass === "disk": a fresh process re-reads the native store; survives cold resume (§2.13). */ readonly diskBacked: boolean; } /** The connection-level record of which intent-generation THIS process reflects (§2.4). */ export interface ConnectionAuthStamp { appliedGeneration: number; applied: boolean; trippedAuthRequired: boolean; } export type BackendAuthState = "unauthenticated" | "credentials_held" | "authenticated" | "auth_required"; export type AuthEvent = { t: "initialize_ok"; connectionId: string; advertised: readonly AuthMethod[]; } | { t: "host_authenticate"; intent: AuthIntent; } | { t: "apply_ok"; connectionId: string; generation: number; } | { t: "apply_failed"; connectionId: string; generation: number; error: unknown; } | { t: "auth_required_tripped"; connectionId: string; error: unknown; } | { t: "logout"; } | { t: "process_death"; connectionId: string; }; /** Redacted, secret-free projection of an intent — ids/types/klass only (§2.14). */ export type RedactedIntent = Readonly>; /** One state machine per `poolKey`, owned by the `AuthStore`. The single source of auth truth. */ export declare class BackendAuthMachine { private _state; private _generation; private _intent; private _advertised; get state(): BackendAuthState; get generation(): number; /** The advertised methods most recently observed at `initialize` (redaction source for status). */ get advertised(): readonly AuthMethod[]; get authenticated(): boolean; /** Redacted view — ids/types/klass only, NEVER authenticateMeta/envValues. */ intentView(): RedactedIntent | undefined; /** SECRET accessor — connection-internal only (used by applyAuthIntent, §2.5). */ applyMeta(): Record | undefined; /** SECRET accessor — pool/connection-internal only (used by spawnEnvFor, §2.8). */ spawnEnv(): Record | undefined; /** SECRET accessor — module-internal only (AuthStore.spawnEnvFor passes it to a profile). */ rawIntent(): AuthIntent | undefined; /** Cold-resume re-arm predicate (§2.13): resumable iff creds are held/applied OR disk-backed. */ canResume(): boolean; isStale(stamp: ConnectionAuthStamp): boolean; /** true iff the current intent is an in-process (gateway) cred that can be live-re-applied on an * idle connection via an authenticate RPC replay, rather than requiring a process recycle. */ currentKlassIsInProcess(): boolean; send(ev: AuthEvent): void; } /** The single per-runner auth store. Owns one `BackendAuthMachine` per `poolKey` and records the * (optional) per-backend `AuthProfile` so `spawnEnvFor` can consult it. */ export declare class AuthStore { private readonly machines; private readonly profiles; /** Get/create the machine for a `poolKey`, recording the backend's profile the first time. */ machineFor(poolKey: string, profile?: AuthProfile): BackendAuthMachine; /** The machine for a `poolKey`, or undefined if none has been created yet (read-only lookup). */ existing(poolKey: string): BackendAuthMachine | undefined; /** Every `poolKey` that has a machine (the touched backends). */ poolKeys(): string[]; /** The spawn-env overlay (§2.8): the machine's host-collected `envValues` merged with the backend * profile's `spawnAuthEnv(intent)` contribution. Undefined when neither applies. Secret — passed * straight to `spawn`, never logged. */ spawnEnvFor(poolKey: string): Record | undefined; } export declare function redactSecrets(text: string): string; //# sourceMappingURL=auth-store.d.ts.map