import { type ShellProbeRunner } from '../env/shell-probe.js'; /** * The network wait, named BEFORE it starts and never skipped silently. * * The size is not quoted as a figure the way `INSTALL_SIZE_WARNING` quotes * chromium's 704 MiB: this package's download size is not measured here, and a * guessed number in a warning is worse than no number. What the user needs to * know before the block is that this touches the network and is one-time. */ export declare const ACQUIRE_NETWORK_WARNING = "fetching @alibaba-group/open-code-review@1.13.1 from the npm registry (needs network, one time)"; /** Which shell the acquisition runs through, in preference order. */ export type AcquireShellKind = 'bash' | 'powershell' | 'direct'; export interface AcquireShell { readonly kind: AcquireShellKind; /** Absolute path to the shell, or `null` for `direct` (nothing is spawned). */ readonly path: string | null; /** * ALWAYS populated: which shell was chosen, and when it is not the first * choice, why. A caller that drops this makes the choice silent again. */ readonly note: string; } export interface AcquireOutcome { readonly ok: boolean; /** `''` on success, else `OCR18_ACQUIRE_BUSY` | `OCR18_ACQUIRE_FAILED` | `OCR18_ACQUIRE_TIMEOUT`. */ readonly code: string; readonly message: string; /** Which shell ran it, and whether that was the preferred one. */ readonly shell: AcquireShell; readonly durationMs: number; /** `[ACQUIRE_NETWORK_WARNING]` whenever this call actually spawned the installer. */ readonly warnings: readonly string[]; } /** * `/.peaks/ocr/install.lock` — the OCR acquisition lock. * * MACHINE-GLOBAL, like the web install lock and for the same reason: what it * guards is npm's per-user exec cache (`~/.npm/_npx`, `%LOCALAPPDATA% * \npm-cache\_npx`), which every project and every session of this user * shares. A per-project lock would serialize nothing. */ export declare function ocrAcquireLockPath(): string; /** * Take the OCR acquire lock (O_EXCL create), reclaiming a STALE one — dead * owner, unreadable body, or older than `ACQUIRE_LOCK_STALE_MS`. `false` when * another process holds a live lock. * * Same protocol as `web-install-service.acquireInstallLock`, deliberately * including the R15 detail that **the reclaim is a rename, not an unlink**: * `O_EXCL` serializes the create only if the removal before it cannot be * replayed against a fresh file — `A unlink → A create → B unlink (A's FRESH * lock) → B create` leaves both holders. A file can only be moved once, so * exactly one reclaimer wins and the create that follows decides. * * The two copies are not shared because the web module's lock is bound to its * own artifact root and this change does not reach into it. If a third * acquirer appears, lift the pair into a shared helper with a lock-path * parameter rather than writing a third copy. */ export declare function acquireOcrLock(): boolean; /** Release the OCR acquire lock, but only when this process is its owner. */ export declare function releaseOcrLock(): void; export interface ResolveAcquireShellOptions { /** Override `process.platform` (tests simulate a host without Git Bash). */ readonly platform?: NodeJS.Platform; /** Override `process.env` (the `PEAKS_GIT_BASH` pin and `SystemRoot` live here). */ readonly env?: NodeJS.ProcessEnv; /** * Test seam for BOTH lookups: it answers the Git Bash default paths inside * `probeShell` and the PowerShell path below, so one injected map can * simulate "Windows with no Git Bash" on a host that has it. */ readonly probeFile?: (absPath: string) => boolean | Promise; /** Test seam forwarded to `probeShell` for its `where bash` PATH sweep. */ readonly runner?: ShellProbeRunner; } /** * Resolve the shell the acquisition runs through: Git Bash → PowerShell → * no shell. Never throws, and never returns a shell without a `note`. */ export declare function resolveAcquireShell(options?: ResolveAcquireShellOptions): Promise; /** * The exact argv of the one-time acquisition. Exported so a unit test can * assert the arguments WITHOUT spawning anything — an install is not a test's * side effect (same rule as `installCommandLine`). * * `--yes` is what makes this non-interactive: without it `npx` stops to ask * "Ok to proceed?" on a machine that has not cached the package, which is the * hang this verb exists to avoid. */ export declare function acquireCommandArgs(): readonly string[]; /** * The same argv as ONE shell line, for the bash / PowerShell branches. * * Every token is double-quoted, and that is load-bearing rather than * cosmetic: a bare `@alibaba-group/…` is PowerShell's array syntax. Every * token here is a module constant built from `OCR_18_PACKAGE`, so quoting is * sufficient — no token carries a `"`, `\`, `$` or backtick that the two * shells would escape differently, and none is caller-supplied. */ export declare function acquireCommandLine(): string; export interface AcquireOcr18Options { /** True when the caller prints a JSON envelope to stdout and must not be handed npm's. */ readonly asJson?: boolean; /** Pre-resolved shell. Production callers omit it; tests inject one. */ readonly shell?: AcquireShell; } /** * Run the acquisition once, under the lock. Returns an outcome on every path — * a held lock, a non-zero exit, a timeout, a thrown spawn — so no caller ever * sees an exception from here, and never a silent no-op. */ export declare function acquireOcr18(options?: AcquireOcr18Options): Promise;