import type { access } from "node:fs/promises"; import type { AssetCatalogEntry } from "../types.js"; /** * Defines the supported extension install operation values. */ export type ExtensionInstallOperation = "install" | "verify" | "remove"; /** * Describes extension install action data exchanged by the lifecycle pipeline. */ export interface ExtensionInstallAction { host: string; extensionId: string; executable: string; installArgs: string[]; verifyArgs: string[]; removeArgs: string[]; command: string; verifyCommand: string; removeCommand: string; } /** * Describes native install result data exchanged by the lifecycle pipeline. */ export interface NativeInstallResult { host: string; extensionId: string; operation: ExtensionInstallOperation; success: boolean; installed: boolean; exitCode: number; stdout: string; stderr: string; message: string; } /** * Describes native command result data exchanged by the lifecycle pipeline. */ export interface NativeCommandResult { exitCode: number; stdout: string; stderr: string; } /** * Defines the supported native command executor values. */ export type NativeCommandExecutor = (executable: string, args: string[]) => Promise; /** * Builds vs code extension install actions from the provided inputs. */ export declare function buildVsCodeExtensionInstallActions(extensionIds: string[]): ExtensionInstallAction[]; /** * Builds extension install actions from the provided inputs. */ export declare function buildExtensionInstallActions(options: { extensionIds: string[]; executable: string; host: string; }): ExtensionInstallAction[]; /** * Returns whether the provided value matches valid vs code extension id. */ export declare function isValidVsCodeExtensionId(extensionId: string): boolean; /** * Resolves vs code extension id from the provided inputs. */ export declare function resolveVsCodeExtensionId(asset: AssetCatalogEntry): string | undefined; /** * Formats extension install actions for user-facing output. */ export declare function formatExtensionInstallActions(actions: ExtensionInstallAction[]): string[]; /** * Executes execute extension install action through the configured runtime executor. */ export declare function executeExtensionInstallAction(action: ExtensionInstallAction, operation: ExtensionInstallOperation, executor?: NativeCommandExecutor): Promise; /** * Verifies verify extension install action using host runtime output. */ export declare function verifyExtensionInstallAction(action: ExtensionInstallAction, executor?: NativeCommandExecutor, expectedInstalled?: boolean): Promise; /** * Verifies verify vs code extension installed using host runtime output. */ export declare function verifyVsCodeExtensionInstalled(listExtensionsOutput: string, extensionId: string): boolean; declare function executeNativeCommand(executable: string, args: string[], platform?: NodeJS.Platform): Promise; /** * Returns the spawn spec for a native host command (#448): direct execution * for regular executables, or a PowerShell single-quoted invocation for * Windows .cmd/.bat wrappers. Node's `shell: true` option concatenates * arguments unescaped (DEP0190) and cmd.exe re-parses the raw command line; * PowerShell keeps every token a single-quoted literal, so no shell * interpretation occurs and no deprecation warning is emitted. Callers must * still run the fail-closed metacharacter refusal before executing. */ export declare function buildNativeCommandSpec(executable: string, args: string[], platform?: NodeJS.Platform): { executable: string; args: string[]; }; /** * Resolves a Windows shell-wrapper candidate to its absolute PATH * location, or returns the candidate unchanged when it is not a wrapper, * is already absolute, or cannot be found (the invocation then fails with * ENOENT exactly like today). * * Exposed through {@link extensionInstallerInternals} so tests can pin the * resolution→refusal and resolution→PowerShell-command chains on any * platform with an injected env and an injected access probe (the * composed win32-style candidates only exist on a real Windows * filesystem otherwise). */ export declare function resolveWrapperExecutable(candidateExecutable: string, platform?: NodeJS.Platform, options?: { env?: NodeJS.ProcessEnv; accessPath?: typeof access; }): Promise; /** * Returns the fail-closed refusal for a Windows shell wrapper invoked with * shell-metacharacter arguments, or null when the command is safe to run. * * The executable path checked here MUST be the RESOLVED absolute location * (see {@link resolveWrapperExecutable}) — a bare name has no path * metacharacters by definition, while cmd.exe sees the expanded path at * invocation time. * * Extracted from {@link executeNativeCommand} so the refusal payload is * exercised on every platform: the guard is parameterized by platform, * letting tests force the win32 wrapper branch on non-Windows runners. * Extension ids are strict-pattern filtered upstream; any metacharacter * reaching this point must be refused, not executed (cmd.exe re-parses the * raw command line, so quoting cannot make it safe). */ export declare function buildShellWrapperRefusal(executablePath: string, args: string[], platform?: NodeJS.Platform): { exitCode: number; stdout: string; stderr: string; } | null; declare function buildExecutableCandidates(executable: string, platform?: NodeJS.Platform): string[]; declare function toNativeCommandResult(error: unknown): NativeCommandResult; declare function formatCommand(executable: string, args: string[]): string; /** * Exposes pure extension-installer helpers for focused behavioral coverage. */ export declare const extensionInstallerInternals: { buildExecutableCandidates: typeof buildExecutableCandidates; buildNativeCommandSpec: typeof buildNativeCommandSpec; buildShellWrapperRefusal: typeof buildShellWrapperRefusal; executeNativeCommand: typeof executeNativeCommand; formatCommand: typeof formatCommand; resolveWrapperExecutable: typeof resolveWrapperExecutable; toNativeCommandResult: typeof toNativeCommandResult; }; export {};