import { type Locale } from '../i18n/index.js'; import { type CliRuntimeConfig } from '../adapters/cli/runtime.js'; export declare const CLI_RUNTIME_UPDATE_CHECK_INTERVAL_MS: number; export declare const CLI_RUNTIME_UPDATE_TICK_MS: number; export declare const CLI_RUNTIME_UPDATE_INITIAL_DELAY_MS = 20000; export type CliRuntimeUpdateProvider = 'internal' | 'auto' | 'self' | 'npm'; export interface CliRuntimeUpdateTarget { cliId: 'codex'; runtimeId: string; displayName: string; binPath: string; provider: CliRuntimeUpdateProvider; /** Explicit npm source, or the exact owner discovered for an auto target. */ packageName?: string; /** Package root discovered for an auto target; never user-controlled. */ packageRoot?: string; } export interface ConfiguredCliRuntime { cliId: string; cliPathOverride?: string; wrapperCli?: string; cliRuntime?: CliRuntimeConfig; } export interface CliRuntimeUpdateEntry { cliId: 'codex'; runtimeId: string; displayName: string; /** Executable path as discovered at probe time. Display-only: it may be a * short-lived launcher symlink (e.g. FNM's per-shell `fnm_multishells`), so * it must never be part of the persisted identity. */ binPath: string; /** Canonical realpath of the installation this entry tracks, captured when * the entry was written. This is the stable persistence identity: a rotating * `binPath` that resolves here must reuse the same TTL/notification state * instead of minting a fresh row every tick. */ installationPath: string; provider: CliRuntimeUpdateProvider; /** Explicit npm source, when configured. Persisted so source changes can * invalidate the TTL/status cache instead of inheriting another package. */ packageName?: string; /** Stable identity of the configured update source (provider + npm package). */ sourceFingerprint: string; managed: boolean; current: string | null; latest: string | null; updateAvailable: boolean; updateCommand: string | null; installTarget?: string; lastCheckedAt: number; lastNotifiedVersion?: string; } export interface CliRuntimeUpdateStore { entries: Record; } export interface CliRuntimeUpdateProbeResult { current: string; latest: string | null; managed: boolean; updateCommand: string | null; /** Exact npm owner selected by auto provenance. */ packageName?: string; installTarget?: string; } /** Backward-compatible name retained for importers/tests written when only the * official Codex distribution was supported. */ export type CodexUpdateProbeResult = CliRuntimeUpdateProbeResult; export interface NpmPackageProvenance { packageName: string; packageRoot: string; } export interface CodexUpdateProbeDeps { runFile?: (bin: string, args: string[], timeoutMs: number) => Promise; /** Legacy official-Codex registry injection. */ fetchLatest?: () => Promise; fetchNpmLatest?: (packageName: string) => Promise; resolveNpmPackage?: (binPath: string) => NpmPackageProvenance | null; } export interface CliRuntimeUpdateAuditDeps { now: () => number; targets: () => CliRuntimeUpdateTarget[]; readStore: () => CliRuntimeUpdateStore; writeStore: (store: CliRuntimeUpdateStore) => void; probe: (target: CliRuntimeUpdateTarget) => Promise; /** Cheap local provenance refresh used before applying the 24h network TTL. */ resolveAutoPackage?: (binPath: string) => NpmPackageProvenance | null; notify?: (entry: CliRuntimeUpdateEntry) => Promise; log?: (message: string) => void; } export interface CliRuntimeUpdateMonitorWiring { dataDir: string; primaryLarkAppId: string; ownerOpenId: () => string | undefined; dashboardUrl?: () => string | undefined; targets: () => CliRuntimeUpdateTarget[]; sendCard: (openId: string, cardJson: string) => Promise; log?: (message: string) => void; } export declare function cliRuntimeUpdateStorePathIn(dataDir: string): string; export declare function readCliRuntimeUpdateStoreFrom(dataDir: string): CliRuntimeUpdateStore; export declare function writeCliRuntimeUpdateStoreTo(dataDir: string, store: CliRuntimeUpdateStore): void; export declare function listCliRuntimeUpdateEntries(dataDir: string): CliRuntimeUpdateEntry[]; /** Resolve an executable back to the npm package that actually owns its bin * entry. Merely finding a parent package.json is insufficient: global package * managers and monorepos contain unrelated manifests, so the package's `bin` * mapping must point at this exact real file. */ export declare function resolveNpmPackageForExecutable(binPath: string): NpmPackageProvenance | null; type AutoPackageResolver = (binPath: string) => NpmPackageProvenance | null; /** Read-only provider-aware probe. The official provider alone may fall back * to @openai/codex. `auto` requires exact npm-bin provenance; if provenance * cannot identify an update stream, it is reported unmanaged and remains * quiet. Only explicit `self` may trust a matching custom doctor. */ export declare function probeCliRuntimeUpdate(target: CliRuntimeUpdateTarget, deps?: CodexUpdateProbeDeps): Promise; /** Historical public entry point. */ export declare function probeCodexRuntimeUpdate(target: CliRuntimeUpdateTarget, deps?: CodexUpdateProbeDeps): Promise; /** Project persisted status onto the runtimes configured right now. The * monitor eventually prunes stale entries, but Dashboard reads can happen * immediately after an agent/runtime edit; filtering here prevents an old * official/provider badge from lingering until the next hourly audit. */ export declare function filterCliRuntimeUpdateEntriesForTargets(entries: CliRuntimeUpdateEntry[], targets: CliRuntimeUpdateTarget[], resolveAutoPackage?: AutoPackageResolver): CliRuntimeUpdateEntry[]; /** Resolve every configured Codex-protocol distribution. Old plain Codex * configs preserve the official fallback. A legacy/custom path is `auto` and * therefore must prove exact npm provenance; it can never inherit the official * release stream. */ export declare function selectCodexRuntimeUpdateTargets(configs: ConfiguredCliRuntime[], resolveBin: (cliPathOverride?: string) => string): CliRuntimeUpdateTarget[]; /** One audit pass. Each runtime+binary has its own TTL and notification * watermark. A successful unmanaged probe clears any stale latest version; * only a failed probe retains the last-known status. */ export declare function runCliRuntimeUpdateAudit(deps: CliRuntimeUpdateAuditDeps): Promise; export declare function buildCliRuntimeUpdateCard(entry: CliRuntimeUpdateEntry, opts?: { dashboardUrl?: string; locale?: Locale; }): string; /** Start the host monitor. Call only in the primary daemon. */ export declare function startCliRuntimeUpdateMonitor(wiring: CliRuntimeUpdateMonitorWiring): void; export declare function stopCliRuntimeUpdateMonitor(): void; export {}; //# sourceMappingURL=cli-runtime-update.d.ts.map