import type { McpServerConfig } from "@cursor/sdk"; import type { Context, ToolResultMessage } from "@earendil-works/pi-ai"; import type { CursorSdkEventDebugRecorder } from "./sdk-event-debug.js"; import type { ExtensionAPI, ExtensionHandler, SessionShutdownEvent, ToolCallEvent, ToolCallEventResult, ToolInfo, ToolResultEvent, } from "@earendil-works/pi-coding-agent"; export type CursorPiToolBridgeSnapshotApi = Pick; export type CursorPiToolBridgeExtensionApi = CursorPiToolBridgeSnapshotApi & { on(event: "tool_call", handler: ExtensionHandler): void; on(event: "tool_result", handler: ExtensionHandler): void; on(event: "session_shutdown", handler: ExtensionHandler): void; }; export interface CursorPiMcpInputSchema { type: "object"; properties?: Record; required?: string[]; [key: string]: unknown; } export interface CursorPiBridgeToolDefinition { piToolName: string; mcpToolName: string; description: string; promptGuidelines?: ToolInfo["promptGuidelines"]; inputSchema: CursorPiMcpInputSchema; sourceInfo: ToolInfo["sourceInfo"]; } export interface CursorPiToolBridgeSnapshot { tools: CursorPiBridgeToolDefinition[]; mcpToolNameToPiToolName: ReadonlyMap; } export interface CursorPiToolBridgeSnapshotOptions { exposeOverlappingBuiltins?: boolean; /** Pi tool names hidden from the bridge. */ excludedToolNames?: ReadonlySet; } export interface CursorPiBridgeToolRequest { runId: string; bridgeCallId: string; cursorMcpCallId?: string; piToolCallId: string; piToolName: string; mcpToolName: string; args: Record; } export interface CursorPiToolBridgeRun { id: string; enabled: boolean; mcpServers?: Record; snapshot: CursorPiToolBridgeSnapshot; takeQueuedToolRequests(): CursorPiBridgeToolRequest[]; resolveToolResults(toolResults: readonly ToolResultMessage[]): Promise; resolveToolResultsFromContext(context: Context): Promise; hasPendingCalls(): boolean; hasPendingPiToolCallId(piToolCallId: string): boolean; isBridgeMcpToolCall(toolCall: unknown): boolean; setOnToolRequest(handler?: (request: CursorPiBridgeToolRequest) => void): void; setDebugRecorder(recorder?: CursorSdkEventDebugRecorder): void; cancel(reason: string): void; dispose(): Promise; } export interface CursorPiToolBridge { isEnabled(): boolean; getToolSurfaceSignature(excludedToolNames?: ReadonlySet): string; createRun(options?: CursorPiToolBridgeRunOptions): Promise; disposeAll(reason?: string): Promise; } export interface CursorPiToolBridgeRunOptions { onToolRequest?: (request: CursorPiBridgeToolRequest) => void; debugRecorder?: CursorSdkEventDebugRecorder; /** Pi tool names hidden from this run's bridge snapshot. */ excludeToolNames?: ReadonlySet; }