/** * Model mapping and Claude executable resolution. */ export type ClaudeModel = "sonnet" | "sonnet[1m]" | "opus" | "opus[1m]" | "haiku"; /** * Current canonical pins for the `sonnet`/`opus`/`haiku` SDK aliases. * * mapModelToClaudeModel collapses every requested model to one of these * aliases; the Claude Agent SDK then resolves the alias to a concrete * version via ANTHROPIC_DEFAULT_{TYPE}_MODEL env vars. When those env * vars are unset the SDK falls back to its own bundled defaults, which * lag real Claude Max availability — users end up routed to stale * versions (this was the root cause of #419: opus-* requests silently * answering as sonnet-4). * * Meridian now pins these defaults itself at the SDK subprocess boundary * so fresh installs behave correctly out of the box. Users can still * override via MERIDIAN_DEFAULT_{TYPE}_MODEL (proxy-side) or * ANTHROPIC_DEFAULT_{TYPE}_MODEL (shell env, wins over Meridian's pin). */ export declare const CANONICAL_OPUS_MODEL = "claude-opus-4-7"; export declare const CANONICAL_SONNET_MODEL = "claude-sonnet-4-6"; export declare const CANONICAL_HAIKU_MODEL = "claude-haiku-4-5"; /** * Build the ANTHROPIC_DEFAULT_{TYPE}_MODEL env record to apply before the * inherited process env, so user-set shell values still win but unset * variables get Meridian's canonical pins. * * Accepts an optional `env` arg so unit tests can pass a synthetic env * map instead of mutating process.env (which leaks between parallel * test files). */ export declare function resolveSdkModelDefaults(env?: NodeJS.ProcessEnv): Record; export interface ClaudeAuthStatus { loggedIn?: boolean; subscriptionType?: string; email?: string; } export declare function mapModelToClaudeModel(model: string, subscriptionType?: string | null, agentMode?: string | null): ClaudeModel; /** * Record that Extra Usage is not enabled on this subscription. * For the next hour, mapModelToClaudeModel will return the base model * directly — no failed [1m] attempt per request. After the cooldown * the next request probes [1m] once; if Extra Usage was enabled in the * meantime it succeeds and the flag is never set again. */ export declare function recordExtendedContextUnavailable(): void; /** * Returns true while within the cooldown window after a confirmed * Extra Usage failure. After the window expires this returns false, * allowing one probe to check whether Extra Usage has been enabled. */ export declare function isExtendedContextKnownUnavailable(): boolean; /** Reset the Extended Context unavailability timer — for testing only. */ export declare function resetExtendedContextUnavailable(): void; /** * Strip the [1m] suffix from a model, returning the base variant. * Used for fallback when the 1M context window is rate-limited. */ export declare function stripExtendedContext(model: ClaudeModel): ClaudeModel; /** * Check whether a model is using extended (1M) context. */ export declare function hasExtendedContext(model: ClaudeModel): boolean; /** Get the last successful auth check timestamp for a profile. * @param profileId - Profile ID to look up (uses default cache when omitted) */ export declare function getAuthCacheInfo(profileId?: string): { lastCheckedAt: number; lastSuccessAt: number; isFailure: boolean; }; /** * @param profileId - Profile ID for per-profile cache keying (e.g. "work", "personal"). * When undefined, uses the default (global) auth context. * @param envOverrides - Optional env vars for per-profile auth (e.g. CLAUDE_CONFIG_DIR). */ export declare function getClaudeAuthStatusAsync(profileId?: string, envOverrides?: Record): Promise; /** * Tag identifying which resolver step produced the path. Surfaced at startup * and in `/health` so users can self-diagnose "wrong claude got picked" * without having to inspect their PATH manually (closes the diagnostic gap * from #478, where a Bun-shimmed `claude` on PATH led to silent failures * that looked indistinguishable from any other SDK error). */ export type ClaudeExecutableSource = "env" | "bundled" | "platform-package" | "path-lookup" | "legacy-cli-js"; export interface ClaudeExecutableInfo { path: string; source: ClaudeExecutableSource; } /** * Resolve the Claude executable path asynchronously (non-blocking). * * Uses a three-tier cache: * 1. cachedClaudePath — resolved path, returned immediately on subsequent calls * 2. cachedClaudePathPromise — deduplicates concurrent calls during resolution * 3. Falls through to resolution logic (SDK cli.js → system `which claude`) * * The promise is cleared in `finally` to allow retry on failure while * cachedClaudePath prevents re-resolution on success. */ /** * Resolver step contract — each tries one source, returns a path on success * or null on miss. Failures (thrown errors) are caught by the caller and * treated as misses so unresolved sources never block subsequent steps. */ type ResolverDeps = { existsSync: (p: string) => boolean; statSync: (p: string) => { size: number; }; exec: (cmd: string) => Promise<{ stdout: string; }>; resolvePackage: (specifier: string) => string; envGet: (name: string) => string | undefined; platform: NodeJS.Platform; arch: string; isBun: boolean; }; /** * Pure resolver, source-aware variant — runs each step and returns the * first hit (path + source tag), or null when all steps miss. * * Order matters: `env` wins unconditionally (operator escape hatch), then * `bundled` (the path the SDK expects), then `platform-package` (postinstall * fallback), then `path-lookup` (system PATH — most likely to surface * unintended shims, see #478), then `legacy-cli-js` (only matters on stale * Bun installs of SDK < 0.2.98). */ export declare function resolveClaudeExecutableWithSource(deps?: ResolverDeps): Promise; /** * Pure resolver — returns the path string only. Kept for callers that * don't need the source tag (existing behavior; preserves the existing * test surface in claude-executable-resolver.test.ts). */ export declare function resolveClaudeExecutable(deps?: ResolverDeps): Promise; /** * Synchronous subset of the resolver. Used by CLI commands * (`meridian profile list`, `profileAdd`, etc.) that can't await before * spawning `claude auth status`. * * Skips two steps that the async resolver runs: * - `path-lookup` — running `which`/`where` synchronously is awkward * and platform-fragile; the audit showed bundled + platform-package * covers every supported install layout (npm-global, npx/bunx * download, Docker, NixOS). * - `legacy-cli-js` — only matters for stale Bun installs of SDK < 0.2.98. * * Closes the diagnostic gap from #478: `getAuthStatus` in profileCli.ts * and `getClaudeAuthStatusAsync` in this file previously called * `claude auth status` via shell, which fails when `claude` isn't on * PATH (Stefan's case — bunx-installed meridian under systemd, no * global claude). Both call sites now route through resolved paths. */ export declare function resolveClaudeExecutableSync(deps?: ResolverDeps): ClaudeExecutableInfo | null; /** * Returns the cached resolved-executable info — `null` if * `resolveClaudeExecutableAsync` hasn't run yet. Used by `/health` and the * startup log so the resolver only runs once and both surfaces see the * same answer. */ export declare function getResolvedClaudeExecutableInfo(): ClaudeExecutableInfo | null; export declare function resolveClaudeExecutableAsync(): Promise; /** Reset cached path — for testing only */ export declare function resetCachedClaudePath(): void; /** Reset cached auth status — for testing only */ export declare function resetCachedClaudeAuthStatus(): void; /** Expire the auth status cache without clearing lastKnownGoodAuthStatus — for testing only. * This simulates the TTL expiring so the next call re-executes `claude auth status`, * while preserving the "last known good" fallback state. */ export declare function expireAuthStatusCache(): void; /** * Check if an error is a "Controller is already closed" error. * This happens when the client disconnects mid-stream. */ export declare function isClosedControllerError(error: unknown): boolean; export {}; //# sourceMappingURL=models.d.ts.map