export interface ToolExecResult { code: number | null; stdout: string; stderr: string; timedOut: boolean; /** The command could not be started at all (ENOENT, EACCES). */ spawnError?: string; } /** The quick probes (`--version`, `auth status`, `login status`, `plugin list`) get this long, or the caller's `timeoutMs` when that is shorter. */ export declare const QUICK_PROBE_MS = 15000; /** * Runs one tool with the given environment (its PATH decides what is found); never throws, and always settles: a tool * that outlives `timeoutMs` is killed with SIGKILL (Claude Code's binary ignores the default SIGTERM, and a probe that * never ends once blocked the whole queue behind a stuck keychain dialog), and `timedOut` is reported even when the * process refuses to die or something it started keeps its output open. */ export declare function execTool(command: string, args: string[], options: { env: Record; timeoutMs?: number; cwd?: string; }): Promise; /** Where a configured command (`claude`, `/usr/local/bin/claude`, `["node", "/path/cli.js"]`) actually is, on the given PATH. */ export declare function resolveCommand(command: string | string[], pathVar: string | undefined): { command: string; lead: string[]; path?: string; }; export declare function parseVersion(text: string): string | undefined; export interface ToolAuth { loggedIn: boolean; /** `claude.ai`, `console`, `apiKey`, `none`, … as the CLI reports it; `chatgpt` / `api_key` for Codex. */ method?: string; provider?: string; /** Who is logged in, as the CLI reports it (Claude Code: the account's email and organisation). */ account?: string; email?: string; org?: string; /** Claude Code had a login that ran out (`claude auth status --text` says `Login: Expired`). */ expired?: boolean; /** The CLI gave no answer in time (and was killed): nothing is known about the login, which is not the same as logged out. */ timedOut?: boolean; detail: string; } export type McpServerState = "connected" | "needs_auth" | "failed" | "disabled" | "unknown"; export interface ClaudeMcpServer { name: string; /** The URL or the command line, as printed. */ target: string; transport?: string; state: McpServerState; detail?: string; } export interface ClaudePlugin { id: string; version?: string; scope?: string; enabled: boolean; mcp_servers: string[]; installed_at?: string; last_updated?: string; } export interface ClaudeProbe { found: boolean; path?: string; version?: string; auth: ToolAuth; /** Only with `deep`. */ mcp?: { servers: ClaudeMcpServer[]; warnings: string[]; error?: string; }; plugins?: { plugins: ClaudePlugin[]; error?: string; }; } /** `claude auth status` prints JSON and exits 0 whether or not anyone is logged in. */ export declare function parseClaudeAuth(result: Pick): ToolAuth; /** `claude auth status --text` prints `Login: Expired — log in again` for a login that ran out. */ export declare function claudeLoginExpired(text: string): boolean; /** * `claude mcp list` is text: one `name: target [(transport)] - ` line per server, then an optional * "MCP config diagnostics" block whose warnings are kept as plain strings. */ export declare function parseClaudeMcpList(text: string): { servers: ClaudeMcpServer[]; warnings: string[]; }; /** `claude plugin list --json`: an array of `{id, version, scope, enabled, installPath, installedAt, lastUpdated, mcpServers}`. */ export declare function parseClaudePlugins(text: string): ClaudePlugin[]; export interface ProbeOptions { /** The environment to run the CLI with (`baseRunEnv`; cut down to `probeEnv` before anything starts); its PATH decides what is found. */ env: Record; /** Also list MCP servers and plugins (Claude) / MCP servers and `codex doctor` (Codex): slower, one process each. */ deep?: boolean; /** For the slow listings (`claude mcp list` connects to every server); the quick calls get `QUICK_PROBE_MS`, or this when it is shorter. */ timeoutMs?: number; /** When Claude Code is not logged in, also ask whether a login expired (one more process). */ explainLogout?: boolean; } /** How long one quick probe may take under these options. */ export declare function quickProbeMs(options: Pick): number; export declare function probeClaude(command: string | string[], options: ProbeOptions): Promise; export interface CodexMcpServer { name: string; enabled: boolean; transport?: string; target: string; auth_status?: string; state: McpServerState; detail?: string; } export interface CodexDoctorCheck { id: string; category?: string; status: "ok" | "warn" | "fail" | "skip"; summary: string; remediation?: string; } export interface CodexProbe { found: boolean; path?: string; version?: string; auth: ToolAuth; mcp?: { servers: CodexMcpServer[]; error?: string; }; doctor?: { overall?: string; checks: CodexDoctorCheck[]; error?: string; }; } /** `codex login status` prints one line (`Logged in using ChatGPT`, `Logged in using an API key`, `Not logged in`) and exits non-zero when logged out. */ export declare function parseCodexLogin(result: Pick): ToolAuth; /** `codex mcp list --json`: `{name, enabled, disabled_reason, transport: {type, command, args | url}, auth_status}` per server. */ export declare function parseCodexMcpList(text: string): CodexMcpServer[]; /** `codex doctor --json`: `{overallStatus, codexVersion, checks: {: {id, category, status, summary, remediation}}}`. */ export declare function parseCodexDoctor(text: string): { version?: string; overall?: string; checks: CodexDoctorCheck[]; }; export interface CodexPlugin { /** `name@marketplace` */ id: string; name: string; marketplace: string; installed: boolean; enabled: boolean; version?: string; } /** `codex plugin list`: a table per marketplace, one row per plugin (`name@marketplace installed, enabled 1.2.3 source`). */ export declare function parseCodexPlugins(text: string): CodexPlugin[]; export declare function probeCodex(command: string | string[], options: ProbeOptions): Promise;