/** * Launcher Utilities * * General utility functions for launcher operations. */ import type fs from 'node:fs'; import type path from 'node:path'; import { spawnSync } from 'node:child_process'; /** * Resolve binary path from command name */ export declare function resolveBinary(options: { fsImpl: typeof fs; pathImpl: typeof path; homedir: () => string; command: string; }): string; /** * Parse server URL into components */ export declare function parseServerUrl(raw: string): { protocol: 'http' | 'https'; host: string; port: number | null; basePath: string; }; /** * Resolve boolean from environment variable */ export declare function resolveBoolFromEnv(value: unknown, fallback: boolean): boolean; /** * Resolve integer from environment variable with bounds */ export declare function resolveIntFromEnv(value: unknown, fallback: number, min: number, max: number): number; /** * Resolve Tmux self-heal policy from environment */ export declare function resolveTmuxSelfHealPolicy(env: NodeJS.ProcessEnv): { enabled: boolean; maxRetries: number; retryDelaySec: number; }; /** * Read API key from config file */ export declare function readConfigApiKey(fsImpl: typeof fs, configPath: string): string | null; /** * Normalize connect host. * * When the server binds to 0.0.0.0/::, clients must connect via a concrete * address (typically 127.0.0.1 for local usage). */ export declare function normalizeConnectHost(host: string): string; /** * Convert value to integer port */ export declare function toIntegerPort(value: unknown): number | null; /** * Try to read host/port from config file */ export declare function tryReadConfigHostPort(fsImpl: typeof fs, configPath: string): { host: string | null; port: number | null; }; /** * Rotate log file when it exceeds max size */ export declare function rotateLogFile(fsImpl: typeof fs, filePath: string, maxBytes?: number, maxBackups?: number): void; /** * Check if tmux is available */ export declare function isTmuxAvailable(spawnSyncImpl?: typeof spawnSync): boolean; /** * Normalize path for comparison */ export declare function normalizePathForComparison(candidate: string, pathImpl?: typeof path): string; /** * Check if command is an idle shell (reusable) */ export declare function isReusableIdlePaneCommand(command: string): boolean; /** * Normalize session token for tmux session name */ export declare function normalizeSessionToken(value: string): string; /** * Quote string for shell */ export declare function shellQuote(value: string): string; /** * Build shell command from tokens */ export declare function buildShellCommand(tokens: string[]): string; /** * Collect environment differences */ export declare function collectChangedEnv(baseEnv: NodeJS.ProcessEnv, nextEnv: NodeJS.ProcessEnv): { set: Array<[string, string]>; unset: string[]; }; /** * Resolve working directory */ export declare function resolveWorkingDirectory(cwdFn: (() => string) | undefined, fsImpl: typeof fs, pathImpl: typeof path, requested?: string): string; /** * Collect pass-through arguments */ export declare function collectPassThroughArgs(args: { rawArgv: string[]; commandName: string; knownOptions: Set; requiredValueOptions: Set; extraArgsFromCommander: string[]; }): string[]; /** * Normalize OpenAI base URL */ export declare function normalizeOpenAiBaseUrl(baseUrl: string): string;