/**
 * WebSocket server for VS Code extension communication
 */
import { ClientMessage, DiagnosticInfo, PendingChange } from './protocol.js';
export type MessageHandler = (message: ClientMessage) => void;
export type PromptHandler = (prompt: string, context?: {
    filePath?: string;
    selection?: string;
    cursorPosition?: {
        line: number;
        character: number;
    };
}) => void;
export interface VSCodeServerCallbacks {
    onPrompt?: PromptHandler;
    onChangeApplied?: (id: string) => void;
    onChangeRejected?: (id: string) => void;
    onContext?: (context: {
        workspaceFolder?: string;
        openFiles?: string[];
        activeFile?: string;
        diagnostics?: DiagnosticInfo[];
    }) => void;
    onDiagnosticsResponse?: (diagnostics: DiagnosticInfo[]) => void;
    onConnect?: () => void;
    onDisconnect?: () => void;
}
export declare class VSCodeServer {
    private port;
    private wss;
    private clients;
    private pendingChanges;
    private callbacks;
    private currentModel?;
    private currentProvider?;
    private cliVersion;
    constructor(port?: number);
    /**
     * Get the actual port the server is listening on
     */
    getPort(): number;
    /**
     * Try to start the WebSocket server on a specific port
     */
    private tryStartOnPort;
    /**
     * Start the WebSocket server with automatic port fallback
     * If the requested port is in use, tries up to 10 alternative ports
     */
    start(): Promise<boolean>;
    /**
     * Stop the WebSocket server
     */
    stop(): Promise<void>;
    /**
     * Register callbacks for client messages
     */
    onCallbacks(callbacks: VSCodeServerCallbacks): void;
    /**
     * Check if any clients are connected
     */
    hasConnections(): boolean;
    /**
     * Get number of connected clients
     */
    getConnectionCount(): number;
    /**
     * Send a file change notification to VS Code
     */
    sendFileChange(filePath: string, originalContent: string, newContent: string, toolName: string, toolArgs: Record<string, unknown>): string;
    /**
     * Send an assistant message to VS Code
     */
    sendAssistantMessage(content: string, isGenerating?: boolean): void;
    /**
     * Send status update to VS Code
     */
    sendStatus(model?: string, provider?: string): void;
    /**
     * Request diagnostics from VS Code
     */
    requestDiagnostics(filePath?: string): void;
    /**
     * Close diff preview in VS Code (when tool is confirmed/rejected in CLI)
     */
    closeDiff(id: string): void;
    /**
     * Close all pending diff previews
     */
    closeAllDiffs(): void;
    /**
     * Get a pending change by ID
     */
    getPendingChange(id: string): PendingChange | undefined;
    /**
     * Remove a pending change
     */
    removePendingChange(id: string): void;
    /**
     * Get all pending changes
     */
    getAllPendingChanges(): PendingChange[];
    private handleConnection;
    private handleMessage;
    private broadcast;
}
/**
 * Get or create the VS Code server singleton
 * Uses promise-based initialization to prevent race conditions
 */
export declare function getVSCodeServer(port?: number): Promise<VSCodeServer>;
/**
 * Get the VS Code server instance if it exists (synchronous)
 * Returns null if not yet initialized
 * Use this when you need synchronous access and the server may not be initialized
 */
export declare function getVSCodeServerSync(): VSCodeServer | null;
/**
 * Check if VS Code server is active and has connections
 */
export declare function isVSCodeConnected(): boolean;
/**
 * Send a file change to VS Code for preview/approval
 * This is the main entry point for tools to integrate with VS Code
 */
export declare function sendFileChangeToVSCode(filePath: string, originalContent: string, newContent: string, toolName: string, toolArgs: Record<string, unknown>): string | null;
/**
 * Close a diff preview in VS Code (when tool confirmed/rejected in CLI)
 */
export declare function closeDiffInVSCode(id: string | null): void;
/**
 * Close all pending diff previews in VS Code
 */
export declare function closeAllDiffsInVSCode(): void;
//# sourceMappingURL=vscode-server.d.ts.map