import type { AgentTool, AgentToolContext, AgentToolResult, AgentToolUpdateCallback } from "@oh-my-pi/pi-agent-core"; import type { BunFile } from "bun"; import { type Theme } from "../modes/theme/theme"; import type { ToolSession } from "../tools"; import { type LspServerStatus } from "./client"; import { renderCall, renderResult } from "./render"; import { type LspParams, type LspToolDetails, lspSchema } from "./types"; export type { LspServerStatus } from "./client"; export type { LspToolDetails } from "./types"; export interface LspStartupServerInfo { name: string; status: "connecting" | "ready" | "error"; fileTypes: string[]; error?: string; } /** Result from warming up LSP servers */ export interface LspWarmupResult { servers: Array; } /** Options for warming up LSP servers */ export interface LspWarmupOptions { /** Called when starting to connect to servers */ onConnecting?: (serverNames: string[]) => void; } export declare function discoverStartupLspServers(cwd: string): LspStartupServerInfo[]; /** * Warm up LSP servers for a directory by connecting to all detected servers. * This should be called at startup to avoid cold-start delays. * * @param cwd - Working directory to detect and start servers for * @param options - Optional callbacks for progress reporting * @returns Status of each server that was started */ export declare function warmupLspServers(cwd: string, options?: LspWarmupOptions): Promise; /** * Get status of currently active LSP servers. */ export declare function getLspStatus(): LspServerStatus[]; /** Result from getDiagnosticsForFile */ export interface FileDiagnosticsResult { /** Name of the LSP server used (if available) */ server?: string; /** Formatted diagnostic messages */ messages: string[]; /** Summary string (e.g., "2 error(s), 1 warning(s)") */ summary: string; /** Whether there are any errors (severity 1) */ errored: boolean; /** Whether the file was formatted */ formatter?: FileFormatResult; } export declare enum FileFormatResult { UNCHANGED = "unchanged", FORMATTED = "formatted" } /** Options for creating the LSP writethrough callback */ export interface WritethroughOptions { /** Whether to format the file using LSP after writing */ enableFormat?: boolean; /** Whether to get LSP diagnostics after writing */ enableDiagnostics?: boolean; /** Called when diagnostics arrive after the main timeout. */ onDeferredDiagnostics?: (diagnostics: FileDiagnosticsResult) => void; /** Signal to cancel a pending deferred diagnostics fetch. */ deferredSignal?: AbortSignal; } /** Per-file deferred LSP diagnostics wiring for {@link WritethroughCallback}. */ export type WritethroughDeferredHandle = { onDeferredDiagnostics: (diagnostics: FileDiagnosticsResult) => void; signal: AbortSignal; finalize: (diagnostics: FileDiagnosticsResult | undefined) => void; }; /** Callback type for the LSP writethrough */ export type WritethroughCallback = (dst: string, content: string, signal?: AbortSignal, file?: BunFile, batch?: LspWritethroughBatchRequest, getDeferred?: (dst: string) => WritethroughDeferredHandle | undefined) => Promise; /** No-op writethrough callback */ export declare function writethroughNoop(dst: string, content: string, _signal?: AbortSignal, file?: BunFile, _batch?: LspWritethroughBatchRequest, _getDeferred?: (dst: string) => WritethroughDeferredHandle | undefined): Promise; interface LspWritethroughBatchRequest { id: string; flush: boolean; } export declare function flushLspWritethroughBatch(id: string, cwd: string, signal?: AbortSignal): Promise; /** Create a writethrough callback for LSP aware write operations */ export declare function createLspWritethrough(cwd: string, options?: WritethroughOptions): WritethroughCallback; /** * LSP tool for language server protocol operations. */ export declare class LspTool implements AgentTool { private readonly session; readonly name = "lsp"; readonly label = "LSP"; readonly loadMode = "discoverable"; readonly summary = "Query LSP (language server) for diagnostics, hover info, and references"; readonly description: string; readonly parameters: import("zod/v4").ZodObject<{ action: import("zod/v4").ZodEnum<{ capabilities: "capabilities"; code_actions: "code_actions"; definition: "definition"; diagnostics: "diagnostics"; hover: "hover"; implementation: "implementation"; references: "references"; reload: "reload"; rename: "rename"; rename_file: "rename_file"; request: "request"; status: "status"; symbols: "symbols"; type_definition: "type_definition"; }>; file: import("zod/v4").ZodOptional; line: import("zod/v4").ZodOptional; symbol: import("zod/v4").ZodOptional; query: import("zod/v4").ZodOptional; new_name: import("zod/v4").ZodOptional; apply: import("zod/v4").ZodOptional; timeout: import("zod/v4").ZodOptional; payload: import("zod/v4").ZodOptional; }, import("zod/v4/core").$strip>; readonly renderCall: typeof renderCall; readonly renderResult: typeof renderResult; readonly mergeCallAndResult = true; readonly inline = true; readonly strict = true; constructor(session: ToolSession); static createIf(session: ToolSession): LspTool | null; execute(_toolCallId: string, params: LspParams, signal?: AbortSignal, _onUpdate?: AgentToolUpdateCallback, _context?: AgentToolContext): Promise>; }