import { CancellationToken } from "../../../../base/common/cancellation.js";
import { IDisposable } from "../../../../base/common/lifecycle.js";
import { IObservable } from "../../../../base/common/observable.js";
import { URI, UriComponents } from "../../../../base/common/uri.js";
import { Location } from "../../../../editor/common/languages.js";
import { ConfigurationTarget } from "../../../../platform/configuration/common/configuration.js";
import { ExtensionIdentifier } from "../../../../platform/extensions/common/extensions.js";
import { StorageScope } from "../../../../platform/storage/common/storage.js";
import { IWorkspaceFolderData } from "../../../../platform/workspace/common/workspace.js";
import { McpServerRequestHandler } from "@codingame/monaco-vscode-mcp-service-override/vscode/vs/workbench/contrib/mcp/common/mcpServerRequestHandler";
import { MCP } from "@codingame/monaco-vscode-mcp-service-override/vscode/vs/workbench/contrib/mcp/common/modelContextProtocol";
export declare const extensionMcpCollectionPrefix = "ext.";
export declare function extensionPrefixedIdentifier(identifier: ExtensionIdentifier, id: string): string;
export interface McpCollectionDefinition {
    readonly remoteAuthority: string | null;
    readonly id: string;
    readonly label: string;
    readonly serverDefinitions: IObservable<readonly McpServerDefinition[]>;
    readonly isTrustedByDefault: boolean;
    readonly scope: StorageScope;
    readonly lazy?: {
        isCached: boolean;
        load(): Promise<void>;
        removed?(): void;
    };
    readonly presentation?: {
        readonly order?: number;
        readonly origin?: URI;
    };
}
export declare enum McpCollectionSortOrder {
    WorkspaceFolder = 0,
    Workspace = 100,
    User = 200,
    Extension = 300,
    Filesystem = 400,
    RemoteBoost = -50
}
export declare namespace McpCollectionDefinition {
    interface FromExtHost {
        readonly id: string;
        readonly label: string;
        readonly isTrustedByDefault: boolean;
        readonly scope: StorageScope;
    }
    function equals(a: McpCollectionDefinition, b: McpCollectionDefinition): boolean;
}
export interface McpServerDefinition {
    readonly id: string;
    readonly label: string;
    readonly launch: McpServerLaunch;
    readonly roots?: URI[] | undefined;
    readonly variableReplacement?: McpServerDefinitionVariableReplacement;
    readonly presentation?: {
        readonly order?: number;
        readonly origin?: Location;
    };
}
export declare namespace McpServerDefinition {
    interface Serialized {
        readonly id: string;
        readonly label: string;
        readonly launch: McpServerLaunch.Serialized;
        readonly variableReplacement?: McpServerDefinitionVariableReplacement.Serialized;
    }
    function toSerialized(def: McpServerDefinition): McpServerDefinition.Serialized;
    function fromSerialized(def: McpServerDefinition.Serialized): McpServerDefinition;
    function equals(a: McpServerDefinition, b: McpServerDefinition): boolean;
}
export interface McpServerDefinitionVariableReplacement {
    section?: string;
    folder?: IWorkspaceFolderData;
    target: ConfigurationTarget;
}
export declare namespace McpServerDefinitionVariableReplacement {
    interface Serialized {
        target: ConfigurationTarget;
        section?: string;
        folder?: {
            name: string;
            index: number;
            uri: UriComponents;
        };
    }
    function toSerialized(def: McpServerDefinitionVariableReplacement): McpServerDefinitionVariableReplacement.Serialized;
    function fromSerialized(def: McpServerDefinitionVariableReplacement.Serialized): McpServerDefinitionVariableReplacement;
}
export declare enum LazyCollectionState {
    HasUnknown = 0,
    LoadingUnknown = 1,
    AllKnown = 2
}
export interface McpCollectionReference {
    id: string;
    label: string;
    presentation?: McpCollectionDefinition["presentation"];
}
export interface McpDefinitionReference {
    id: string;
    label: string;
}
export interface IMcpServer extends IDisposable {
    readonly collection: McpCollectionReference;
    readonly definition: McpDefinitionReference;
    readonly connection: IObservable<IMcpServerConnection | undefined>;
    readonly connectionState: IObservable<McpConnectionState>;
    readonly trusted: IObservable<boolean | undefined>;
    showOutput(): void;
    start(isFromInteraction?: boolean): Promise<McpConnectionState>;
    stop(): Promise<void>;
    readonly toolsState: IObservable<McpServerToolsState>;
    readonly tools: IObservable<readonly IMcpTool[]>;
}
export declare enum McpServerToolsState {
    Unknown = 0,
    Cached = 1,
    RefreshingFromUnknown = 2,
    RefreshingFromCached = 3,
    Live = 4
}
export interface IMcpTool {
    readonly id: string;
    readonly definition: MCP.Tool;
    call(params: Record<string, unknown>, token?: CancellationToken): Promise<MCP.CallToolResult>;
}
export declare enum McpServerTransportType {
    Stdio = 1,
    SSE = 2
}
export interface McpServerTransportStdio {
    readonly type: McpServerTransportType.Stdio;
    readonly cwd: URI | undefined;
    readonly command: string;
    readonly args: readonly string[];
    readonly env: Record<string, string | number | null>;
    readonly envFile: string | undefined;
}
export interface McpServerTransportSSE {
    readonly type: McpServerTransportType.SSE;
    readonly uri: URI;
    readonly headers: [
        string,
        string
    ][];
}
export type McpServerLaunch = McpServerTransportStdio | McpServerTransportSSE;
export declare namespace McpServerLaunch {
    type Serialized = {
        type: McpServerTransportType.SSE;
        uri: UriComponents;
        headers: [
            string,
            string
        ][];
    } | {
        type: McpServerTransportType.Stdio;
        cwd: UriComponents | undefined;
        command: string;
        args: readonly string[];
        env: Record<string, string | number | null>;
        envFile: string | undefined;
    };
    function toSerialized(launch: McpServerLaunch): McpServerLaunch.Serialized;
    function fromSerialized(launch: McpServerLaunch.Serialized): McpServerLaunch;
}
export interface IMcpServerConnection extends IDisposable {
    readonly definition: McpServerDefinition;
    readonly state: IObservable<McpConnectionState>;
    readonly handler: IObservable<McpServerRequestHandler | undefined>;
    start(): Promise<McpConnectionState>;
    stop(): Promise<void>;
}
export declare namespace McpConnectionState {
    enum Kind {
        Stopped = 0,
        Starting = 1,
        Running = 2,
        Error = 3
    }
    const toString: (s: McpConnectionState) => string;
    const toKindString: (s: McpConnectionState.Kind) => string;
    const canBeStarted: (s: Kind) => s is Kind.Stopped | Kind.Error;
    const isRunning: (s: McpConnectionState) => boolean;
    interface Stopped {
        readonly state: Kind.Stopped;
    }
    interface Starting {
        readonly state: Kind.Starting;
    }
    interface Running {
        readonly state: Kind.Running;
    }
    interface Error {
        readonly state: Kind.Error;
        readonly message: string;
    }
}
export type McpConnectionState = McpConnectionState.Stopped | McpConnectionState.Starting | McpConnectionState.Running | McpConnectionState.Error;
export declare class MpcResponseError extends Error {
    readonly code: number;
    readonly data: unknown;
    constructor(message: string, code: number, data: unknown);
}
export declare class McpConnectionFailedError extends Error {
}
