import type { ExtensionContext } from "@earendil-works/pi-coding-agent"; import type { ConsentManager } from "./consent-manager.ts"; import type { McpLifecycleManager } from "./lifecycle.ts"; import type { McpServerManager } from "./server-manager.ts"; import type { AuthStorageOptions } from "./mcp-auth.ts"; import type { ToolMetadata, PromptMetadata, McpConfig, UiSessionMessages, UiStreamSummary } from "./types.ts"; import type { UiResourceHandler } from "./ui-resource-handler.ts"; import type { UiServerHandle } from "./ui-server.ts"; import type { McpRuntimeOwner } from "./runtime-owner.ts"; import type { McpOAuthRuntime } from "./mcp-auth-flow.ts"; import type { McpStatusEventBus } from "./mcp-status.ts"; export interface CompletedUiSession { serverName: string; toolName: string; completedAt: Date; reason: string; messages: UiSessionMessages; stream?: UiStreamSummary; } export type SendMessageFn = ( message: { customType: string; content: Array<{ type: "text"; text: string }>; display?: string; details?: unknown; }, options?: { triggerTurn?: boolean } ) => void; export interface McpExtensionState { owner: McpRuntimeOwner; manager: McpServerManager; lifecycle: McpLifecycleManager; toolMetadata: Map; /** Resource counts retained separately because tool metadata includes resource tools. */ resourceCounts: Map; promptMetadata: Map; /** Servers whose prompt inventory came from successful live discovery. */ promptMetadataLive: Set; serverInstructions: Map; config: McpConfig; programmaticConfig?: boolean; oauthRuntime: McpOAuthRuntime; authStorageOptions: AuthStorageOptions; failureTracker: Map; failureMessages: Map; uiResourceHandler: UiResourceHandler; consentManager: ConsentManager; uiServer: UiServerHandle | null; completedUiSessions: CompletedUiSession[]; openBrowser: (url: string) => Promise; ui?: ExtensionContext["ui"]; sendMessage?: SendMessageFn; onToolMetadataUpdated?: (serverName: string, reason: string) => void | Promise; statusEvents?: McpStatusEventBus; }