import { z } from 'zod'; import { KosConnection, ConnectionState, CommandResult } from '../transport/kos-connection.js'; interface CpuPreference { cpuId?: number; cpuLabel?: string; } /** * Set runtime CPU preference for all subsequent connections. * This overrides config.kos.cpuId/cpuLabel until cleared or process stops. * * @param pref - CPU preference (cpuId or cpuLabel), or null to clear */ export declare function setCpuPreference(pref: CpuPreference | null): void; /** * Get current runtime CPU preference. */ export declare function getCpuPreference(): CpuPreference | null; /** * Clear runtime CPU preference (reverts to config defaults). */ export declare function clearCpuPreference(): void; export declare function getConnection(): KosConnection; export declare const connectInputSchema: z.ZodObject<{ host: z.ZodDefault>; port: z.ZodDefault>; cpuId: z.ZodOptional; cpuLabel: z.ZodOptional; transportType: z.ZodOptional>; }, "strip", z.ZodTypeAny, { host: string; port: number; cpuId?: number | undefined; cpuLabel?: string | undefined; transportType?: "socket" | "tmux" | undefined; }, { host?: string | undefined; port?: number | undefined; cpuId?: number | undefined; cpuLabel?: string | undefined; transportType?: "socket" | "tmux" | undefined; }>; export declare const executeInputSchema: z.ZodObject<{ command: z.ZodString; timeout: z.ZodDefault; }, "strip", z.ZodTypeAny, { command: string; timeout: number; }, { command: string; timeout?: number | undefined; }>; export declare function handleConnect(rawInput: z.input): Promise; export interface EnsureConnectedOptions { cpuId?: number; cpuLabel?: string; /** Enable retry loop (default: false for quick single attempt) */ retry?: boolean; /** Timeout for retry loop in ms (default: 120000 = 2 min) */ timeoutMs?: number; /** Poll interval for retry loop in ms (default: 2000) */ pollIntervalMs?: number; /** Progress callback during retry loop */ onProgress?: (elapsedMs: number) => void; } /** * Force close the connection and reset state. * Used when health check fails to ensure clean reconnection, * or when CPU preference is cleared to force auto-selection. */ export declare function forceDisconnect(): Promise; /** * Ensure connection is established, auto-connecting if needed. * * @param options Configuration options * @returns The connected KosConnection * @throws Error if connection fails (or timeout if retry enabled) * * Behavior: * - If not connected: connects to specified CPU or CPU 0 if not specified * - If connected and no options: verifies connection health, reconnects if stale * - If connected but different CPU requested: reconnects to requested CPU * - After new connection: waits 500ms for kOS to stabilize * - If retry=true: polls until success or timeout (for KSP startup scenarios) */ export declare function ensureConnected(options?: EnsureConnectedOptions): Promise; /** @deprecated Use ensureConnected({ retry: true }) instead */ export type WaitForKosOptions = EnsureConnectedOptions; /** * Wait for kOS to become ready, with retry logic. * * This is a convenience wrapper for ensureConnected({ retry: true }). * Use this when KSP/kOS might not be ready yet (e.g., after KSP startup). * * @param options Configuration options * @returns The connected KosConnection * @throws Error if timeout exceeded */ export declare function waitForKosReady(options?: EnsureConnectedOptions): Promise; /** * Check if kOS is currently reachable without throwing. * Returns true if kOS is ready, false otherwise. */ export declare function isKosReady(options?: EnsureConnectedOptions): Promise; export declare function handleDisconnect(): Promise<{ disconnected: boolean; }>; export declare function handleStatus(): Promise; export declare function handleExecute(input: z.infer): Promise; export declare const connectionToolDefinitions: { connect: { description: string; inputSchema: z.ZodObject<{ host: z.ZodDefault>; port: z.ZodDefault>; cpuId: z.ZodOptional; cpuLabel: z.ZodOptional; transportType: z.ZodOptional>; }, "strip", z.ZodTypeAny, { host: string; port: number; cpuId?: number | undefined; cpuLabel?: string | undefined; transportType?: "socket" | "tmux" | undefined; }, { host?: string | undefined; port?: number | undefined; cpuId?: number | undefined; cpuLabel?: string | undefined; transportType?: "socket" | "tmux" | undefined; }>; handler: typeof handleConnect; }; disconnect: { description: string; inputSchema: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>; handler: typeof handleDisconnect; }; status: { description: string; inputSchema: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>; handler: typeof handleStatus; }; execute: { description: string; inputSchema: z.ZodObject<{ command: z.ZodString; timeout: z.ZodDefault; }, "strip", z.ZodTypeAny, { command: string; timeout: number; }, { command: string; timeout?: number | undefined; }>; handler: typeof handleExecute; }; }; export {}; //# sourceMappingURL=connection-tools.d.ts.map