/** * @license * Copyright 2026 Qwen * SPDX-License-Identifier: Apache-2.0 */ import * as fs from 'node:fs/promises'; import { type LiveDiscoveryRecord } from './host/types.js'; export type StartupErrorCode = 'runtime_missing' | 'runtime_invalid' | 'runtime_unavailable' | 'config_missing' | 'discovery_invalid' | 'daemon_unresponsive' | 'daemon_mismatch' | 'daemon_start_failed' | 'startup_timeout' | 'startup_aborted' | 'startup_cleanup_failed' | 'startup_busy'; /** A stable code keeps shared process-management errors localizable in both UIs. */ export declare class StartupError extends Error { readonly code: StartupErrorCode; readonly logPath?: string; /** Kept only in memory so Quit can retry cleaning up this exact owned child. */ readonly retryCleanup?: () => Promise; constructor(code: StartupErrorCode, options?: { cause?: unknown; logPath?: string; retryCleanup?: () => Promise; }); } export interface RuntimeRegistration { schemaVersion: 1; nodePath: string; cliPath: string; version: string; dataDir: string; discoveryDir: string; cwd: string; path: string; } export interface RegisterRuntimeOptions { nodePath: string; cliPath: string; version: string; dataDir: string; discoveryDir: string; cwd?: string; path?: string; } export interface StartupOptions { signal?: AbortSignal; timeoutMs?: number; } export interface ReadyDaemon { kind: 'ready'; record: LiveDiscoveryRecord; version: string; } declare function errorCode(error: unknown): string | undefined; declare function assertNotAborted(signal?: AbortSignal): void; declare function isOwned(stat: Awaited>): boolean; declare function prepareRunDirectory(discoveryPath: string): Promise; export declare function getRuntimeRegistrationPath(discoveryPath: string): string; export declare function registerRuntime(options: RegisterRuntimeOptions): Promise; export declare function probeDaemon(discoveryPath: string, options?: StartupOptions & { expectedVersion?: string; }): Promise; declare function delay(milliseconds: number, signal?: AbortSignal): Promise; /** @internal Shared only with the CLI lock module; carries no lock dependency. */ export declare const startupInternals: { assertNotAborted: typeof assertNotAborted; prepareRunDirectory: typeof prepareRunDirectory; errorCode: typeof errorCode; isOwned: typeof isOwned; delay: typeof delay; timeoutMs: number; }; export declare function launchRegisteredDaemon(options: StartupOptions & { discoveryPath: string; expectedVersion: string; debug?: boolean; startIfMissing?: boolean; }): Promise; export {};