import { type ResolvedAccount } from "./accounts.js"; import type { Config, RunnerName } from "./config.js"; import type { Secrets } from "./env.js"; import type { Events } from "./events.js"; export declare const RUNNER_NAMES: RunnerName[]; export interface RunnerReadiness { runner: RunnerName; found: boolean; path?: string; version?: string; /** null for the shell runner (nothing to log in to). */ authenticated: boolean | null; method?: "subscription" | "api_key" | "unknown"; detail: string; hint?: string; ready: boolean; /** The Claude Code configuration directory this answer is about, when a skill names its own (`claude.config_dir`). */ config_dir?: string; /** The account this answer is about (`skillhook accounts`), with who it is logged in as. */ account?: string; identity?: { email?: string; org?: string; }; /** A login that existed and ran out (Claude Code's `Login: Expired`), rather than none at all. */ expired?: boolean; checked_at: string; } export interface ReadinessOptions { refresh?: boolean; /** Probe the runner as this account runs it (its directory, token or key); `claudeConfigDir` is then ignored. */ account?: ResolvedAccount; /** Probe Claude Code as a skill with this `claude.config_dir` runs it (ignored for the other runners). */ claudeConfigDir?: string; } export declare function claudeMethod(method: string | undefined): RunnerReadiness["method"]; /** * The CLI did not answer the login check in time (it was killed). Nothing is known about the runner, so this is thrown * rather than returned as "not ready": the queue then runs the job anyway instead of failing it or falling back, as for * any check that could not be made. */ export declare class ReadinessProbeUnanswered extends Error { constructor(detail: string); } /** * Does Claude Code's stored login still work? `claude auth status` only reads the stored credentials: an access token * that expired and can no longer be refreshed still says "logged in", and every run then fails with a 401. The control * protocol (`initialize`, `get_status`; no prompt, no inference) uses the login the way a run does, and says `Login: * Expired` when the token is refused. `undefined` when the probe could not tell (an older CLI, a timeout), so a probe * that fails never marks a working login broken. */ export declare function claudeLoginWorks(command: string | string[], env: Record, timeoutMs?: number): Promise; export declare const CLAUDE_TOKEN_REFUSED = "login expired: Claude Code could not use or refresh the stored token"; export declare function checkReadiness(runner: RunnerName, config: Config, baseEnv: Record, claudeConfigDir?: string): Promise; /** * Is this account usable: the CLI is installed and the account's directory is logged in (`login`), or its token / key * is in `.env` (`token`, `api_key`). Probed with the account's environment, so it is exactly what a run would get. */ export declare function checkAccountReadiness(account: ResolvedAccount, config: Config, baseEnv: Record, secrets: Secrets): Promise; export interface ReadinessCacheDeps { config: () => Config; /** The environment the probes run with (`baseRunEnv`), re-read on every probe so a new `.env` value counts. */ env: () => Record; /** The merged secrets, for the token / key of an account (default: none). */ secrets?: () => Secrets; /** How long an answer is trusted (default 60 s). */ ttlMs?: () => number; /** How long one probe may go unanswered before `get` gives up on it (default: `probeDeadlineMs` of the config). */ deadlineMs?: () => number; /** The probe itself (default: `checkReadiness` / `checkAccountReadiness`); tests hand in one that hangs. */ check?: (runner: RunnerName, options: ReadinessOptions) => Promise; events?: Events; } /** * The longest a readiness probe legitimately takes: the quick CLI calls (two in parallel, then one more for an account * that is logged out) and the login try through the control protocol, each bounded by `health.probe_timeout_seconds`, * plus a margin for killing a stuck process. A probe still unanswered after this is given up on. */ export declare function probeDeadlineMs(config: Pick): number; export declare class ReadinessProbeTimeout extends Error { constructor(what: string, deadlineMs: number); } type KeyOptions = Pick; export declare class ReadinessCache { private readonly deps; /** Keyed by runner, for Claude Code by configuration directory too (`claude\0`), and by account (`account\0…`). */ private readonly cached; private readonly pending; constructor(deps: ReadinessCacheDeps); get(runner: RunnerName, options?: ReadinessOptions): Promise; all(options?: { refresh?: boolean; }): Promise; /** Stop trusting what is known about a runner or account (after a run failed to authenticate): the next `get` probes again. */ invalidate(runner: RunnerName, options?: KeyOptions): void; last(runner: RunnerName, options?: KeyOptions): RunnerReadiness | undefined; } export {};