import { spawnSync } from 'node:child_process'; import type { UserInstallStamp } from '../scripts/postinstall-advisory.js'; export type PackageManager = 'npm' | 'bun'; type SpawnSyncLike = typeof spawnSync; type SpawnSyncOptions = NonNullable[2]>; /** The validated executable and fixed launcher arguments for an npm transaction. */ export type NpmCommand = { kind: 'node-script'; command: string; commandArgs: string[]; }; export type PackageManagerOwnership = { manager: 'npm'; npmCommand: NpmCommand; npmPrefix: string; globalInstallRoot: string; packageRoot: string; environment: NodeJS.ProcessEnv; } | { manager: 'bun'; bunCommand: string; bunGlobalBin: string; bunShim: string; /** Canonical configured BUN_INSTALL root when it defines this install. */ bunInstallRoot?: string; npmPrefix: string; globalInstallRoot: string; packageRoot: string; environment: NodeJS.ProcessEnv; }; /** Reject incomplete or malformed serialized ownership before any package-manager spawn. */ export declare function isCompletePackageManagerOwnership(ownership: unknown): ownership is PackageManagerOwnership; /** Revalidate the frozen manager, root, package, and bin before transaction advancement. */ export declare function validatePackageManagerOwnership(ownership: PackageManagerOwnership): Promise; export interface PackageManagerOwnershipDependencies { currentExecutable: string; currentPackageRoot: string; readInstallStamp: () => Promise; realpath: (path: string) => string; resolveBunGlobalBin: (command: string, environment: NodeJS.ProcessEnv) => string | null; resolveBunCommand: () => string | null; resolveNpmCommand: () => NpmCommand | null; resolveNpmGlobalInstallRoot: (command: NpmCommand) => string | null; resolveNpmPrefix: (command: NpmCommand) => string | null; platform: NodeJS.Platform; environment?: NodeJS.ProcessEnv; currentNodeExecutable: string; bunInstallRoot?: string; } /** Never resolve a manager through PATH after ownership has been established. */ export declare function runNpmCommand(npmCommand: NpmCommand, args: string[], options: SpawnSyncOptions, spawnProcess?: SpawnSyncLike): ReturnType; /** npm's lifecycle script is executed by this Node binary, not an ambient npm on PATH. */ export declare function resolveNpmCommand(): NpmCommand | null; export declare function resolveNpmGlobalInstallRoot(spawnProcess?: SpawnSyncLike, _platform?: NodeJS.Platform, command?: NpmCommand | null): string | null; export declare function resolveNpmPrefix(spawnProcess?: SpawnSyncLike, _platform?: NodeJS.Platform, command?: NpmCommand | null): string | null; /** Bun's configured global bin must be queried through its validated executable and frozen environment. */ export declare function resolveBunGlobalBin(command: string, environment?: NodeJS.ProcessEnv, spawnProcess?: SpawnSyncLike): string | null; /** Only accept Bun provenance from the current runtime, lifecycle launcher, or configured install root, never PATH. */ export declare function resolveBunCommand(): string | null; export declare function resolvePackageManagerOwnership(dependencies?: Partial): Promise; export declare function packageManagerOwnershipError(): string; export {}; //# sourceMappingURL=package-manager-ownership.d.ts.map