#!/usr/bin/env node import type { TapiDevSession } from "./types.js"; export declare const PORTABLE_STUDIO_SERVER_READY_TIMEOUT_MS = 120000; export type StudioChannel = "pilot" | "stable" | "nightly"; export interface StudioReleaseManifest { product?: string; version: string; channel: string; platform: string; artifactName: string; url: string; sha256: string; sizeBytes?: number; minSdkVersion?: string; builtAt?: string; commit?: string; commitShort?: string; ref?: string; installerKind?: string; serverExecutable?: string; bundledService?: { product?: string; version?: string; source?: string; manifestUrl?: string; mobileChrome?: { source?: string; executable?: string; }; }; } export interface ServiceReleaseManifest { product?: string; version: string; channel: string; platform: string; artifactName: string; url: string; sha256: string; sizeBytes?: number; serviceHostExecutable?: string; workerExecutable?: string; installer?: string; uninstaller?: string; builtAt?: string; commit?: string; commitShort?: string; ref?: string; mobileChrome?: Record; contents?: string[]; } export interface StudioCliOptions { channel: StudioChannel; apiBaseUrl: string; manifestUrl: string; manifestUrlOverride?: string; cacheDir: string; installDir: string; downloadOnly: boolean; silent: boolean; exePath?: string; installToken?: string; installTokenSource?: "option" | "env" | "minted"; projectId?: string; projectSlug?: string; projectIdSource?: "option" | "env" | "selection"; workspaceMode: boolean; launchUrlQuery?: string; tappSelectionMode: "auto" | "select" | "last" | "none"; } export interface RunnerSetupCliOptions { apiBaseUrl: string; authToken?: string; runnerId: string; port: number; openBrowser: boolean; } export interface RunnerSetupAction { queueId?: string; displayName?: string; maxSlots?: number; slotStart?: number; slotCount?: number; } export interface RunnerSetupActionResult { queueId: string; queue: Record; slots: Record[]; } export interface RunnerSetupServerHandle { url: string; port: number; close: () => Promise; } export interface ServiceStatus { installed: boolean; name?: string; status?: string; pathName?: string; installedVersion?: string; } export type FetchLike = typeof fetch; type StudioPortAvailable = (port: number) => Promise; type StudioPortReaper = (preferred: number, count: number) => Promise; export declare function runCli(argv?: string[]): Promise; export declare function parseStudioOptions(args: string[]): StudioCliOptions; export declare function parseRunnerSetupOptions(args: string[]): RunnerSetupCliOptions; export declare function startRunnerSetupServer(options: RunnerSetupCliOptions, fetchImpl?: FetchLike): Promise; export declare function executeRunnerSetupAction(options: RunnerSetupCliOptions, action: RunnerSetupAction, fetchImpl?: FetchLike): Promise; export declare function trySelectDevSessionInOpenStudio(session: TapiDevSession, options: StudioCliOptions, fetchImpl?: FetchLike): Promise<{ selected: boolean; baseUrl?: string; reason?: string; }>; export declare function servicePowerShell(action: string): string; export declare function installedServiceVersionFromPathName(pathName: string): string | undefined; export declare function serviceNeedsInstall(status: ServiceStatus, manifest: ServiceReleaseManifest): boolean; export declare function getDefaultStudioCacheDir(): string; export declare function getDefaultServiceCacheDir(): string; export declare function getDefaultMachineServiceReleasesDir(): string | undefined; interface ServiceInstallLogPaths { logPath: string; resultPath: string; } export declare function getDefaultServiceInstallLogDir(): string; export declare function serviceInstallLogPaths(version: string, now?: Date): ServiceInstallLogPaths; export declare function formatServiceInstallFailure(error: unknown, paths: ServiceInstallLogPaths): Promise; export declare class CliWideEvent { private readonly filePath; private readonly startedAt; private readonly data; private readonly phases; private constructor(); static create(eventName: string, initialFields?: Record): Promise; phase(phase: string, fields?: Record): Promise; finish(success: boolean, fields?: Record): Promise; private write; } export declare function createCliWideEvent(eventName: string, initialFields?: Record): Promise; export declare function getCliWideEventRoot(): string; export declare function getStudioExecutableCandidates(): string[]; export declare function validateStudioManifest(input: unknown): StudioReleaseManifest; export declare function validateServiceReleaseManifest(input: unknown): ServiceReleaseManifest; export declare function compareVersions(left: string, right: string): number; export declare function memoizeStudioInstallToken(options: StudioCliOptions, installToken?: string, source?: StudioCliOptions["installTokenSource"]): string; export declare function resolveStudioTappSelection(options: StudioCliOptions): Promise; export declare function closeExistingPortableStudioServersForFreshLaunch(stopProcesses?: () => Promise): Promise<{ stopped: number; recordsRemoved: number; }>; export declare function studioServerLaunchArgs(): string[]; export declare function findPortablePlaywrightBrowsersDir(exePath: string): string | undefined; export declare function waitForHttpOk(url: string, timeoutMs?: number, intervalMs?: number, fetchImpl?: FetchLike): Promise; export declare function chooseStudioPort(preferred?: number, options?: { count?: number; portAvailable?: StudioPortAvailable; reapBlockedPorts?: StudioPortReaper; }): Promise; export declare function downloadAndVerify(url: string, destination: string, expectedSha256: string, label?: string, options?: { stallTimeoutMs?: number; }): Promise; export declare function studioInstanceRecordPathForOptions(options: StudioCliOptions): string; export declare function findPortableStudioServerExe(releaseDir: string, manifest: StudioReleaseManifest): string | undefined; export declare function estimateRequiredExtractionBytes(zipBytes: number): number; export declare function formatInsufficientExtractionSpace(zipPath: string, destination: string, availableBytes: number, requiredBytes: number): string; export declare function buildExpandArchiveCommand(zipPath: string, destination: string): string; export declare function formatZipExtractionFailure(zipPath: string, destination: string, error: unknown): string; export declare function pruneManagedFiles(directory: string, keepPaths: string[], isManagedFileName: (name: string) => boolean, maxNoncurrentEntries?: number, label?: string): Promise; export declare function pruneTapiReleaseDirs(directory: string, keepPaths: string[], isManagedDirName: (name: string) => boolean, maxNoncurrentEntries?: number, label?: string): Promise; export declare function isTapiStudioDownloadArtifact(fileName: string): boolean; export declare function isTapiServiceDownloadArtifact(fileName: string): boolean; export {};