/**
 * IDE Integration Protocol
 *
 * Provides a standardized protocol for IDE/editor integration:
 * - JSON-RPC based communication
 * - WebSocket and stdio transports
 * - LSP-compatible message format
 * - Bidirectional async communication
 */
import { EventEmitter } from 'events';
export interface JSONRPCMessage {
    jsonrpc: '2.0';
    id?: number | string;
    method?: string;
    params?: unknown;
    result?: unknown;
    error?: JSONRPCError;
}
export interface JSONRPCError {
    code: number;
    message: string;
    data?: unknown;
}
export interface IDECapabilities {
    fileOperations: boolean;
    diagnostics: boolean;
    codeActions: boolean;
    completion: boolean;
    hover: boolean;
    formatting: boolean;
    semanticTokens: boolean;
    inlineValues: boolean;
}
export interface IDEState {
    activeFile?: string;
    selection?: Selection;
    visibleFiles: string[];
    workspaceFolders: string[];
    languageId?: string;
}
export interface Selection {
    startLine: number;
    startColumn: number;
    endLine: number;
    endColumn: number;
}
export interface Diagnostic {
    file: string;
    range: Selection;
    severity: 'error' | 'warning' | 'info' | 'hint';
    message: string;
    code?: string;
    source: string;
}
export interface CodeAction {
    title: string;
    kind: string;
    edit?: WorkspaceEdit;
    command?: Command;
    isPreferred?: boolean;
}
export interface WorkspaceEdit {
    changes: Record<string, TextEdit[]>;
}
export interface TextEdit {
    range: Selection;
    newText: string;
}
export interface Command {
    title: string;
    command: string;
    arguments?: unknown[];
}
export interface CompletionItem {
    label: string;
    kind: CompletionItemKind;
    detail?: string;
    documentation?: string;
    insertText?: string;
    insertTextFormat?: 'plaintext' | 'snippet';
    additionalTextEdits?: TextEdit[];
}
export type CompletionItemKind = 'text' | 'method' | 'function' | 'constructor' | 'field' | 'variable' | 'class' | 'interface' | 'module' | 'property' | 'unit' | 'value' | 'enum' | 'keyword' | 'snippet' | 'color' | 'file' | 'reference' | 'folder';
export interface HoverInfo {
    contents: string | MarkupContent;
    range?: Selection;
}
export interface MarkupContent {
    kind: 'plaintext' | 'markdown';
    value: string;
}
export declare const ErrorCodes: {
    readonly ParseError: -32700;
    readonly InvalidRequest: -32600;
    readonly MethodNotFound: -32601;
    readonly InvalidParams: -32602;
    readonly InternalError: -32603;
    readonly ServerNotInitialized: -32002;
    readonly UnknownErrorCode: -32001;
    readonly RequestCancelled: -32800;
    readonly ContentModified: -32801;
};
type MethodHandler = (params: unknown) => Promise<unknown>;
export declare class IDEProtocolServer extends EventEmitter {
    private handlers;
    private transport;
    private nextId;
    private pendingRequests;
    private initialized;
    private capabilities;
    constructor();
    /**
     * Register built-in methods
     */
    private registerBuiltinMethods;
    /**
     * Register a method handler
     */
    registerMethod(method: string, handler: MethodHandler): void;
    /**
     * Start with stdio transport
     */
    startStdio(): void;
    /**
     * Start with TCP transport
     */
    startTCP(port: number): Promise<void>;
    /**
     * Setup transport handlers
     */
    private setupTransport;
    /**
     * Handle incoming message
     */
    private handleMessage;
    /**
     * Send a request
     */
    request<T = unknown>(method: string, params?: unknown): Promise<T>;
    /**
     * Send a notification
     */
    notify(method: string, params?: unknown): void;
    /**
     * Send result
     */
    private sendResult;
    /**
     * Send error
     */
    private sendError;
    /**
     * Stop the server
     */
    stop(): void;
    /**
     * Send diagnostics to IDE
     */
    publishDiagnostics(file: string, diagnostics: Diagnostic[]): void;
    /**
     * Request code action from agent
     */
    requestCodeAction(file: string, range: Selection, context: unknown): Promise<CodeAction[]>;
    /**
     * Apply workspace edit
     */
    applyEdit(edit: WorkspaceEdit): Promise<boolean>;
    /**
     * Show message in IDE
     */
    showMessage(type: 'info' | 'warning' | 'error', message: string): void;
    /**
     * Request input from user
     */
    requestInput(prompt: string, placeholder?: string): Promise<string | null>;
    /**
     * Open file in IDE
     */
    openFile(file: string, line?: number, column?: number): Promise<boolean>;
    /**
     * Get current IDE state
     */
    getIDEState(): Promise<IDEState>;
    /**
     * Get file content from IDE
     */
    getFileContent(file: string): Promise<string>;
}
export declare class IDEProtocolClient extends EventEmitter {
    private socket;
    private buffer;
    private nextId;
    private pendingRequests;
    /**
     * Connect to server
     */
    connect(port: number): Promise<void>;
    private processBuffer;
    private handleMessage;
    /**
     * Send request
     */
    request<T = unknown>(method: string, params?: unknown): Promise<T>;
    /**
     * Send notification
     */
    notify(method: string, params?: unknown): void;
    /**
     * Disconnect
     */
    disconnect(): void;
}
/**
 * Create IDE protocol server
 */
export declare function createIDEServer(): IDEProtocolServer;
/**
 * Create IDE protocol client
 */
export declare function createIDEClient(): IDEProtocolClient;
export {};
