import { VSBuffer } from "../../../../base/common/buffer.js";
import { CancellationToken } from "../../../../base/common/cancellation.js";
import { IStringDictionary } from "../../../../base/common/collections.js";
import { Event } from "../../../../base/common/event.js";
import { IJSONSchema, TypeFromJsonSchema } from "../../../../base/common/jsonSchema.js";
import { IDisposable } from "../../../../base/common/lifecycle.js";
import { IObservable } from "../../../../base/common/observable.js";
import Severity from "../../../../base/common/severity.js";
import { ThemeIcon } from "../../../../base/common/themables.js";
import { IAction } from "../../../../base/common/actions.js";
import { URI } from "../../../../base/common/uri.js";
import { IContextKeyService } from "../../../../platform/contextkey/common/contextkey.service.js";
import { ExtensionIdentifier } from "../../../../platform/extensions/common/extensions.js";
import { ILogService } from "../../../../platform/log/common/log.service.js";
import { IProductService } from "../../../../platform/product/common/productService.service.js";
import { IRequestService } from "../../../../platform/request/common/request.service.js";
import { IQuickInputService } from "../../../../platform/quickinput/common/quickInput.service.js";
import { ISecretStorageService } from "../../../../platform/secrets/common/secrets.service.js";
import { IStorageService } from "../../../../platform/storage/common/storage.service.js";
import { IExtensionService } from "../../../services/extensions/common/extensions.service.js";
import { ChatAgentLocation } from "./constants.js";
import { ILanguageModelsProviderGroup } from "./languageModelsConfiguration.js";
import { ILanguageModelsConfigurationService } from "./languageModelsConfiguration.service.js";
import { ILanguageModelsService } from "./languageModels.service.js";
/**
 * Vendor id used for the built-in GitHub Copilot language model provider. Treated as the default
 * vendor across the chat stack (see `ILanguageModelProviderDescriptor.isDefault`).
 */
export declare const COPILOT_VENDOR_ID = "copilot";
export declare enum ChatMessageRole {
    System = 0,
    User = 1,
    Assistant = 2
}
export declare enum LanguageModelPartAudience {
    Assistant = 0,
    User = 1,
    Extension = 2
}
export interface IChatMessageTextPart {
    type: "text";
    value: string;
    audience?: LanguageModelPartAudience[];
}
export interface IChatMessageImagePart {
    type: "image_url";
    value: IChatImageURLPart;
}
export interface IChatMessageThinkingPart {
    type: "thinking";
    value: string | string[];
    id?: string;
    metadata?: {
        readonly [key: string]: any;
    };
}
export interface IChatMessageDataPart {
    type: "data";
    mimeType: string;
    data: VSBuffer;
    audience?: LanguageModelPartAudience[];
}
export interface IChatImageURLPart {
    /**
     * The image's MIME type (e.g., "image/png", "image/jpeg").
     */
    mimeType: ChatImageMimeType;
    /**
     * The raw binary data of the image, encoded as a Uint8Array. Note: do not use base64 encoding. Maximum image size is 5MB.
     */
    data: VSBuffer;
}
/**
 * Enum for supported image MIME types.
 */
export declare enum ChatImageMimeType {
    PNG = "image/png",
    JPEG = "image/jpeg",
    GIF = "image/gif",
    WEBP = "image/webp",
    BMP = "image/bmp"
}
/**
 * Specifies the detail level of the image.
 */
export declare enum ImageDetailLevel {
    Low = "low",
    High = "high"
}
export interface IChatMessageToolResultPart {
    type: "tool_result";
    toolCallId: string;
    value: (IChatResponseTextPart | IChatResponsePromptTsxPart | IChatResponseDataPart)[];
    isError?: boolean;
}
export type IChatMessagePart = IChatMessageTextPart | IChatMessageToolResultPart | IChatResponseToolUsePart | IChatMessageImagePart | IChatMessageDataPart | IChatMessageThinkingPart;
export interface IChatMessage {
    readonly name?: string | undefined;
    readonly role: ChatMessageRole;
    readonly content: IChatMessagePart[];
}
export interface IChatResponseTextPart {
    type: "text";
    value: string;
    audience?: LanguageModelPartAudience[];
}
export interface IChatResponsePromptTsxPart {
    type: "prompt_tsx";
    value: unknown;
}
export interface IChatResponseDataPart {
    type: "data";
    mimeType: string;
    data: VSBuffer;
    audience?: LanguageModelPartAudience[];
}
export interface IChatResponseToolUsePart {
    type: "tool_use";
    name: string;
    toolCallId: string;
    parameters: any;
}
export interface IChatResponseThinkingPart {
    type: "thinking";
    value: string | string[];
    id?: string;
    metadata?: {
        readonly [key: string]: any;
    };
}
export interface IChatResponsePullRequestPart {
    type: "pullRequest";
    uri: URI;
    title: string;
    description: string;
    author: string;
    linkTag: string;
}
export type IChatResponsePart = IChatResponseTextPart | IChatResponseToolUsePart | IChatResponseDataPart | IChatResponseThinkingPart;
export type IExtendedChatResponsePart = IChatResponsePullRequestPart;
export interface ILanguageModelConfigurationSchema extends IJSONSchema {
    properties?: {
        [key: string]: IJSONSchema & {
            /** When set to `'navigation'`, the property is shown as a primary action in the model picker. */
            group?: string;
            /** Labels for enum values. If provided, these are shown instead of the raw enum values. */
            enumItemLabels?: string[];
        };
    };
}
export interface ILanguageModelChatMetadata {
    readonly extension: ExtensionIdentifier;
    readonly name: string;
    readonly id: string;
    readonly vendor: string;
    readonly version: string;
    readonly tooltip?: string;
    readonly detail?: string;
    readonly multiplierNumeric?: number;
    readonly pricing?: string;
    readonly inputCost?: number;
    readonly cacheCost?: number;
    readonly outputCost?: number;
    readonly longContextInputCost?: number;
    readonly longContextCacheCost?: number;
    readonly longContextOutputCost?: number;
    readonly priceCategory?: string;
    readonly family: string;
    readonly maxInputTokens: number;
    readonly maxOutputTokens: number;
    readonly isDefaultForLocation: {
        [K in ChatAgentLocation]?: boolean;
    };
    readonly isUserSelectable?: boolean;
    readonly statusIcon?: ThemeIcon;
    readonly auth?: {
        readonly providerLabel: string;
        readonly accountLabel?: string;
    };
    readonly capabilities?: {
        readonly vision?: boolean;
        readonly toolCalling?: boolean;
        readonly agentMode?: boolean;
        readonly editTools?: ReadonlyArray<string>;
    };
    /**
     * When set, this model is only shown in the model picker for the specified chat session type.
     * Models with this property are excluded from the general model picker and only appear
     * when the user is in a session matching this type.
     */
    readonly targetChatSessionType?: string;
    /**
     * An optional JSON schema describing the per-model configuration options.
     * Used to validate user-provided per-model configuration in `chatLanguageModels.json`.
     */
    readonly configurationSchema?: ILanguageModelConfigurationSchema;
}
export declare namespace ILanguageModelChatMetadata {
    function suitableForAgentMode(metadata: ILanguageModelChatMetadata): boolean;
    function asQualifiedName(metadata: ILanguageModelChatMetadata): string;
    function matchesQualifiedName(name: string, metadata: ILanguageModelChatMetadata): boolean;
}
export interface ILanguageModelChatResponse {
    stream: AsyncIterable<IChatResponsePart | IChatResponsePart[]>;
    result: Promise<any>;
}
export declare function getTextResponseFromStream(response: ILanguageModelChatResponse): Promise<string>;
export interface ILanguageModelChatProvider {
    readonly onDidChange: Event<void>;
    provideLanguageModelChatInfo(options: ILanguageModelChatInfoOptions, token: CancellationToken): Promise<ILanguageModelChatMetadataAndIdentifier[]>;
    sendChatRequest(modelId: string, messages: IChatMessage[], from: ExtensionIdentifier | undefined, options: ILanguageModelChatRequestOptions, token: CancellationToken): Promise<ILanguageModelChatResponse>;
    provideTokenCount(modelId: string, message: string | IChatMessage, token: CancellationToken): Promise<number>;
}
export interface ILanguageModelChat {
    metadata: ILanguageModelChatMetadata;
    sendChatRequest(messages: IChatMessage[], from: ExtensionIdentifier | undefined, options: ILanguageModelChatRequestOptions, token: CancellationToken): Promise<ILanguageModelChatResponse>;
    provideTokenCount(message: string | IChatMessage, token: CancellationToken): Promise<number>;
}
export interface ILanguageModelChatSelector {
    readonly name?: string;
    readonly id?: string;
    readonly vendor?: string;
    readonly version?: string;
    readonly family?: string;
    readonly tokens?: number;
    readonly extension?: ExtensionIdentifier;
}
export declare function isILanguageModelChatSelector(value: unknown): value is ILanguageModelChatSelector;
export interface ILanguageModelChatMetadataAndIdentifier {
    metadata: ILanguageModelChatMetadata;
    identifier: string;
}
export interface ILanguageModelChatInfoOptions {
    readonly group?: string;
    readonly silent: boolean;
    readonly configuration?: IStringDictionary<unknown>;
}
export interface ILanguageModelChatRequestOptions {
    readonly modelOptions?: IStringDictionary<unknown>;
    readonly configuration?: IStringDictionary<unknown>;
    readonly [name: string]: any;
}
export interface ILanguageModelsGroup {
    readonly group?: ILanguageModelsProviderGroup;
    readonly modelIdentifiers: string[];
    readonly status?: {
        readonly message: string;
        readonly severity: Severity;
    };
}
export interface IModelControlEntry {
    readonly label: string;
    readonly featured?: boolean;
    readonly minVSCodeVersion?: string;
    readonly exists: boolean;
}
export interface IModelsControlManifest {
    readonly free: IStringDictionary<IModelControlEntry>;
    readonly paid: IStringDictionary<IModelControlEntry>;
}
declare const languageModelChatProviderType: {
    readonly type: "object";
    readonly required: [
        "vendor",
        "displayName"
    ];
    readonly properties: {
        readonly vendor: {
            readonly type: "string";
            readonly description: string;
        };
        readonly displayName: {
            readonly type: "string";
            readonly description: string;
        };
        readonly configuration: {
            readonly type: "object";
            readonly description: string;
            readonly anyOf: [
                {
                    readonly $ref: "http://json-schema.org/draft-07/schema#";
                },
                {
                    readonly properties: {
                        readonly properties: {
                            readonly type: "object";
                            readonly additionalProperties: {
                                readonly $ref: "http://json-schema.org/draft-07/schema#";
                                readonly properties: {
                                    readonly secret: {
                                        readonly type: "boolean";
                                        readonly description: string;
                                    };
                                };
                            };
                        };
                        readonly additionalProperties: {
                            readonly $ref: "http://json-schema.org/draft-07/schema#";
                            readonly properties: {
                                readonly secret: {
                                    readonly type: "boolean";
                                    readonly description: string;
                                };
                            };
                        };
                    };
                }
            ];
        };
        readonly managementCommand: {
            readonly type: "string";
            readonly description: string;
            readonly deprecated: true;
            readonly deprecationMessage: string;
        };
        readonly when: {
            readonly type: "string";
            readonly description: string;
        };
    };
};
export type IUserFriendlyLanguageModel = TypeFromJsonSchema<typeof languageModelChatProviderType>;
export interface ILanguageModelProviderDescriptor extends IUserFriendlyLanguageModel {
    readonly isDefault: boolean;
}
export declare const languageModelChatProviderExtensionPoint: import("../../../services/extensions/common/extensionsRegistry.js").IExtensionPoint<{
    readonly vendor: string;
    readonly displayName: string;
    readonly configuration: undefined;
    readonly managementCommand: string | undefined;
    readonly when: string | undefined;
} | {
    readonly vendor: string;
    readonly displayName: string;
    readonly configuration: undefined;
    readonly managementCommand: string | undefined;
    readonly when: string | undefined;
}[]>;
export declare class LanguageModelsService implements ILanguageModelsService {
    private readonly _extensionService;
    private readonly _logService;
    private readonly _storageService;
    private readonly _contextKeyService;
    private readonly _languageModelsConfigurationService;
    private readonly _quickInputService;
    private readonly _secretStorageService;
    private readonly _productService;
    private readonly _requestService;
    private static SECRET_KEY_PREFIX;
    private static SECRET_INPUT;
    readonly _serviceBrand: undefined;
    private readonly _store;
    private readonly _providers;
    private readonly _vendors;
    private readonly _onDidChangeLanguageModelVendors;
    readonly onDidChangeLanguageModelVendors: Event<string[]>;
    private readonly _modelsGroups;
    private readonly _modelCache;
    private readonly _resolveLMSequencer;
    private readonly _modelConfigurations;
    private readonly _hasUserSelectableModels;
    private readonly _hasNonCopilotUserSelectableModels;
    private readonly _onLanguageModelChange;
    readonly onDidChangeLanguageModels: Event<string>;
    private _recentlyUsedModelIds;
    private _pinnedModelIds;
    private _hiddenModelIds;
    private readonly _onDidChangeModelsControlManifest;
    readonly onDidChangeModelsControlManifest: Event<IModelsControlManifest>;
    private readonly _onDidChangePinnedModels;
    readonly onDidChangePinnedModels: Event<void>;
    private readonly _onDidChangeModelVisibility;
    readonly onDidChangeModelVisibility: Event<void>;
    private _modelsControlManifest;
    private _modelsControlRawResponse;
    private _chatControlUrl;
    private _chatControlDisposed;
    private readonly _restrictedChatParticipants;
    readonly restrictedChatParticipants: IObservable<{
        [name: string]: string[];
    }>;
    constructor(_extensionService: IExtensionService, _logService: ILogService, _storageService: IStorageService, _contextKeyService: IContextKeyService, _languageModelsConfigurationService: ILanguageModelsConfigurationService, _quickInputService: IQuickInputService, _secretStorageService: ISecretStorageService, _productService: IProductService, _requestService: IRequestService);
    deltaLanguageModelChatProviderDescriptors(added: IUserFriendlyLanguageModel[], removed: IUserFriendlyLanguageModel[]): void;
    private _onDidChangeLanguageModelGroups;
    getVendors(): ILanguageModelProviderDescriptor[];
    getLanguageModelIds(): string[];
    lookupLanguageModel(modelIdentifier: string): ILanguageModelChatMetadata | undefined;
    lookupLanguageModelByQualifiedName(referenceName: string): ILanguageModelChatMetadataAndIdentifier | undefined;
    private _resolveAllLanguageModels;
    private _hasGroupStructureChanged;
    getLanguageModelGroups(vendor: string): ILanguageModelsGroup[];
    hasResolvedVendor(vendor: string): boolean;
    selectLanguageModels(selector: ILanguageModelChatSelector): Promise<string[]>;
    registerLanguageModelProvider(vendor: string, provider: ILanguageModelChatProvider): IDisposable;
    sendChatRequest(modelId: string, from: ExtensionIdentifier | undefined, messages: IChatMessage[], options: ILanguageModelChatRequestOptions, token: CancellationToken): Promise<ILanguageModelChatResponse>;
    private _resolveModelConfigurationWithDefaults;
    computeTokenLength(modelId: string, message: string | IChatMessage, token: CancellationToken): Promise<number>;
    getModelConfiguration(modelId: string): IStringDictionary<unknown> | undefined;
    setModelConfiguration(modelId: string, values: IStringDictionary<unknown>): Promise<void>;
    getModelConfigurationActions(modelId: string): IAction[];
    configureLanguageModelsProviderGroup(vendorId: string, providerGroupName?: string): Promise<void>;
    renameLanguageModelsProviderGroup(vendorId: string, providerGroupName: string): Promise<void>;
    updateLanguageModelsProviderGroupApiKey(vendorId: string, providerGroupName: string): Promise<void>;
    addLanguageModelsProviderGroupModel(vendorId: string, providerGroupName: string): Promise<void>;
    openLanguageModelsProviderGroupSettings(vendorId: string, providerGroupName: string): Promise<void>;
    configureModel(modelId: string): Promise<void>;
    private _getModelConfigurationSnippet;
    addLanguageModelsProviderGroup(name: string, vendorId: string, configuration: IStringDictionary<unknown> | undefined): Promise<void>;
    removeLanguageModelsProviderGroup(vendorId: string, providerGroupName: string): Promise<void>;
    private requireConfiguring;
    private getSnippetForFirstUnconfiguredProperty;
    private getSnippetForProperty;
    private getSnippetForArrayItem;
    private getDefaultSnippetBodyText;
    private promptForName;
    private promptForConfiguration;
    private promptForValue;
    private canPromptForProperty;
    private getDescriptionPlaintext;
    private promptForArray;
    private promptForEnum;
    private promptForInput;
    private encodeSecretKey;
    private decodeSecretKey;
    private _clearModelCache;
    private _clearModelConfigurations;
    private _resolveConfiguration;
    private _resolveLanguageModelProviderGroup;
    private _deleteSecretsInConfiguration;
    migrateLanguageModelsProviderGroup(languageModelsProviderGroup: ILanguageModelsProviderGroup): Promise<void>;
    private _readRecentlyUsedModels;
    private _saveRecentlyUsedModels;
    getRecentlyUsedModelIds(): string[];
    addToRecentlyUsedList(modelIdentifier: string): void;
    clearRecentlyUsedList(): void;
    private _readPinnedModels;
    private _savePinnedModels;
    getPinnedModelIds(): string[];
    pinModel(modelIdentifier: string): void;
    unpinModel(modelIdentifier: string): void;
    isModelPinned(modelIdentifier: string): boolean;
    private _getGroupNameForVendor;
    private _getModelIdsInGroup;
    private _readVisibility;
    private _saveVisibility;
    isGroupHidden(vendor: string, groupName: string): boolean;
    isModelHidden(modelIdentifier: string): boolean;
    setGroupHidden(vendor: string, groupName: string, hidden: boolean): void;
    setModelHidden(modelIdentifier: string, hidden: boolean): void;
    getHiddenModelIds(): string[];
    getModelsControlManifest(): IModelsControlManifest;
    private _setModelsControlManifest;
    private _refreshModelsControlManifest;
    private _initChatControlData;
    private _refreshChatControlData;
    private _fetchChatControlData;
    dispose(): void;
}
export {};
