import { access } from "node:fs/promises"; import type { collectActivatedAssetPrerequisiteDiagnostics } from "./asset-prerequisites.js"; import type { HostAdapter } from "../host-adapters/registry.js"; import { buildWindowsPowerShellCommand, containsShellMetaCharacters, isWindowsShellWrapperPath, quotePowerShellLiteral } from "./windows-shell.js"; /** * Defines the supported preflight severity values. */ export type PreflightSeverity = "info" | "warning" | "error"; /** * Describes preflight diagnostic data exchanged by the lifecycle pipeline. */ export interface PreflightDiagnostic { severity: PreflightSeverity; code: string; message: string; action?: string; } /** * Discriminated result from a runtime command execution. * Uses a `cancelled` flag rather than string matching so callers * can reliably distinguish timeout/abort from genuine command failures * even when stderr happens to contain the word "cancelled". */ export interface RuntimeCommandResult { /** True when the command was cancelled by an AbortSignal. */ cancelled: boolean; exitCode: number | null; message: string; } /** * Injection seam for the preflight function family used by the setup-doctor * and workspace runners. Tests override individual members to drive * deterministic preflight outcomes without depending on installed host * CLIs; every member falls back to the real implementation when absent. */ export interface PreflightFunctionOverrides { runHostPreflight?: typeof runHostPreflight; runAdapterPreflight?: typeof runAdapterPreflight; collectActivatedAssetPrerequisiteDiagnostics?: typeof collectActivatedAssetPrerequisiteDiagnostics; } /** * Dispatches the config preflight CLI command group. */ export declare function runConfigPreflight(): Promise; /** * Runs adapter-specific readiness checks such as optional host CLI detection. */ export declare function runAdapterPreflight(adapter: HostAdapter, abortSignal?: AbortSignal): Promise; /** * Runs runtime checks required before native install operations execute. */ export declare function runNativeInstallPreflight(adapter: HostAdapter): Promise; /** * Runs lifecycle-host preflight checks, optionally enforcing writable host * paths for operations that mutate host-native settings. */ export declare function runHostPreflight(host: string, options?: { requireHostPaths?: boolean; }): Promise; /** * Validates unknown data as no preflight errors. */ export declare function assertNoPreflightErrors(diagnostics: PreflightDiagnostic[]): void; /** * Formats preflight diagnostics for user-facing output. */ export declare function formatPreflightDiagnostics(diagnostics: PreflightDiagnostic[]): string; /** * Builds a diagnostic that reports whether a host executable is available. */ export declare function checkExecutableOnPath(executableName: string, code: string, missingSeverity?: PreflightSeverity, guidance?: string): Promise; /** * Searches PATH for an executable, honoring PATHEXT on Windows. */ interface FindExecutableOptions { accessPath?: typeof access; abortSignal?: AbortSignal; env?: NodeJS.ProcessEnv; platform?: NodeJS.Platform; } declare function getExecutableSearchExtensions(platform: NodeJS.Platform, env: NodeJS.ProcessEnv): string[]; declare function getExecutableAccessMode(platform: NodeJS.Platform): number; /** * Searches PATH for an executable, honoring PATHEXT on Windows. * * Exported for shared use by host-command executors (extension installer) * that must validate the RESOLVED executable — a bare wrapper name is * only PATH-resolved at invocation time by cmd.exe, so path-level checks * (e.g. cmd-expansion metacharacters in a PATH directory) must run * against the resolved absolute location (review). */ export declare function findExecutableOnPath(executableName: string, options?: FindExecutableOptions): Promise; /** * Checks file-system accessibility for a path with the requested access mode. */ interface RuntimeCommandCheckOptions { executable: string; args: string[]; code: string; failureSeverity: PreflightSeverity; successMessage: string; failureAction: string; } declare function checkRuntimeCommand(options: RuntimeCommandCheckOptions & { abortSignal?: AbortSignal; }): Promise; /** * Returns true when the provided AbortSignal is aborted. */ export declare function isAborted(signal: AbortSignal | undefined): boolean; declare function runRuntimeCommand(executable: string, args: string[], abortSignal?: AbortSignal, platform?: NodeJS.Platform): Promise; declare function resolveRuntimeExecutable(executable: string, platform?: NodeJS.Platform, findExecutable?: typeof findExecutableOnPath, abortSignal?: AbortSignal): Promise; declare function resolveFoundExecutable(executable: string, foundExecutable: string | null): string; /** * Returns the fail-closed refusal for a Windows shell wrapper invoked with * shell-metacharacter arguments, or null when the command is safe to run. * * Extracted from {@link runRuntimeCommand} so the refusal decision (and the * exact refusal payload) is exercised on every platform: the guard is * parameterized by platform, letting tests force the win32 wrapper branch on * non-Windows runners. callers keep passing `process.platform`. */ export declare function buildWrapperRefusal(resolvedExecutable: string, args: string[], platform?: NodeJS.Platform): { cancelled: false; exitCode: number; message: string; } | null; interface RuntimeCommandSpawnSpecOptions { executable: string; args: string[]; resolvedExecutable: string; platform?: NodeJS.Platform; } declare function buildRuntimeCommandSpawnSpec(options: RuntimeCommandSpawnSpecOptions): { executable: string; args: string[]; }; /** * Provides check path exists for the lifecycle pipeline. */ export declare function checkPathExists(pathValue: string, code: string, mode?: number): Promise; /** * Exposes focused preflight helpers for deterministic platform-branch tests. */ export declare const preflightInternals: { buildRuntimeCommandSpawnSpec: typeof buildRuntimeCommandSpawnSpec; buildWindowsPowerShellCommand: typeof buildWindowsPowerShellCommand; buildWrapperRefusal: typeof buildWrapperRefusal; checkRuntimeCommand: typeof checkRuntimeCommand; containsShellMetaCharacters: typeof containsShellMetaCharacters; findExecutableOnPath: typeof findExecutableOnPath; getExecutableAccessMode: typeof getExecutableAccessMode; getExecutableSearchExtensions: typeof getExecutableSearchExtensions; isAborted: typeof isAborted; isWindowsShellWrapperPath: typeof isWindowsShellWrapperPath; quotePowerShellLiteral: typeof quotePowerShellLiteral; resolveFoundExecutable: typeof resolveFoundExecutable; resolveRuntimeExecutable: typeof resolveRuntimeExecutable; runRuntimeCommand: typeof runRuntimeCommand; }; export {};