import type { AccountPoolState, AccountSlot, SelectionStrategy } from "./accounts.js"; /** * Account pools are persisted inside senpi's own `auth.json`, under the * provider's key, using the same field names stock senpi uses for the Claude * Agent SDK (`accounts`, `pinned`). Senpi treats the record as an opaque OAuth * credential, so the sentinel `access`/`refresh` keep it a valid credential * while the real per-account material lives in `accounts`. */ export declare const SENTINEL: { readonly access: "senpi-accounts-managed"; readonly refresh: "senpi-accounts-managed"; /** 2100-01-01: far enough out that senpi never tries to refresh the sentinel. */ readonly expires: 4102444800000; }; export interface StoredPool { type: "oauth"; access: string; refresh: string; expires: number; accounts?: AccountSlot[]; pinned?: string; strategy?: SelectionStrategy; cursor?: number; mode?: AccountPoolState["mode"]; bindings?: Record; migration?: AccountPoolState["migration"]; } export declare function emptyPool(): StoredPool; /** Read a provider's account pool. Returns an empty pool when absent. */ export declare function readPool(agentDir: string, providerId: string): AccountPoolState; /** Persist a provider's account pool, leaving every other provider untouched. */ export declare function writePool(agentDir: string, providerId: string, state: AccountPoolState): void; /** Delete a provider credential while preserving every adjacent provider. */ export declare function deletePool(agentDir: string, providerId: string): boolean; /** * Persist state only while the credential still matches the request's baseline. * * A logout or account edit in another process changes that baseline. The stale * request must then lose instead of recreating removed credentials. */ export declare function writePoolIfCurrent(agentDir: string, providerId: string, expected: AccountPoolState, next: AccountPoolState): boolean; /** * Apply only the fields changed by one request to the latest persisted pool. * * Each stream starts from `base`, but another stream may persist a block, * binding, logout or token refresh before this stream finishes. Replacing the * whole pool with `next` would erase that concurrent transition. */ export declare function mergePoolTransition(base: AccountPoolState, next: AccountPoolState, current: AccountPoolState): AccountPoolState; /** Persist one request's transition without replacing concurrent pool changes. */ export declare function writePoolTransition(agentDir: string, providerId: string, base: AccountPoolState, next: AccountPoolState): AccountPoolState; /** Read-modify-write a pool in one step. */ export declare function updatePool(agentDir: string, providerId: string, update: (state: AccountPoolState) => AccountPoolState): AccountPoolState;