import { CancellationToken } from "../../../../base/common/cancellation.js";
import { Event } from "../../../../base/common/event.js";
import { IMarkdownString } from "../../../../base/common/htmlContent.js";
import { IDisposable } from "../../../../base/common/lifecycle.js";
import { IObservable } from "../../../../base/common/observable.js";
import { ThemeIcon } from "../../../../base/common/themables.js";
import { URI } from "../../../../base/common/uri.js";
import { IChatAgentAttachmentCapabilities, IChatAgentRequest } from "./participants/chatAgents.js";
import { IChatEditingSession } from "./editing/chatEditingService.js";
import { IChatRequestVariableData, ISerializableChatModelInputState } from "./model/chatModel.js";
import { IChatProgress, IChatSessionTiming } from "./chatService/chatService.js";
import { Target } from "./promptSyntax/promptTypes.js";
export declare enum ChatSessionStatus {
    Failed = 0,
    Completed = 1,
    InProgress = 2,
    NeedsInput = 3
}
export interface IChatSessionCommandContribution {
    readonly name: string;
    readonly description: string;
    readonly when?: string;
}
export interface IChatSessionProviderOptionItem {
    readonly id: string;
    readonly name: string;
    readonly description?: string;
    readonly locked?: boolean;
    readonly icon?: ThemeIcon;
    readonly default?: boolean;
}
export interface IChatSessionProviderOptionGroupCommand {
    readonly command: string;
    readonly title: string;
    readonly tooltip?: string;
    readonly arguments?: readonly unknown[];
}
export interface IChatSessionProviderOptionGroup {
    readonly id: string;
    readonly name: string;
    readonly description?: string;
    readonly items: readonly IChatSessionProviderOptionItem[];
    readonly searchable?: boolean;
    readonly onSearch?: (query: string, token: CancellationToken) => Thenable<IChatSessionProviderOptionItem[]>;
    /**
     * A context key expression that controls visibility of this option group picker.
     * When specified, the picker is only visible when the expression evaluates to true.
     * The expression can reference other option group values via `chatSessionOption.<groupId>`.
     * Example: `"chatSessionOption.models == 'gpt-4'"`
     */
    readonly when?: string;
    readonly icon?: ThemeIcon;
    /**
     * Custom commands to show in the option group's picker UI.
     * These will be shown in a separate section at the end of the picker.
     */
    readonly commands?: readonly IChatSessionProviderOptionGroupCommand[];
}
export interface IChatSessionsExtensionPoint {
    readonly type: string;
    readonly name: string;
    readonly displayName: string;
    readonly description: string;
    readonly when?: string;
    readonly icon?: string | {
        light: string;
        dark: string;
    };
    readonly order?: number;
    readonly alternativeIds?: string[];
    readonly welcomeTitle?: string;
    readonly welcomeMessage?: string;
    readonly welcomeTips?: string;
    readonly inputPlaceholder?: string;
    readonly capabilities?: IChatAgentAttachmentCapabilities;
    readonly commands?: IChatSessionCommandContribution[];
    readonly canDelegate?: boolean;
    readonly isReadOnly?: boolean;
    /**
     * When set, the chat session will show a filtered mode picker with custom agents
     * that have a matching `target` property. This enables contributed chat sessions
     * to reuse the standard agent/mode dropdown with filtered custom agents.
     * Custom agents without a `target` property are also shown in all filtered lists
     */
    readonly customAgentTarget?: Target;
    readonly requiresCustomModels?: boolean;
    /**
     * When false, the delegation picker is hidden for this session type.
     * Defaults to true.
     */
    readonly supportsDelegation?: boolean;
    /**
     * Decides whether to automatically attach instruction files to chat requests
     * for this session type. Defaults to false when not specified.
     */
    readonly autoAttachReferences?: boolean;
}
export interface IChatSessionItem {
    readonly resource: URI;
    readonly label: string;
    readonly iconPath?: ThemeIcon;
    readonly badge?: string | IMarkdownString;
    readonly description?: string | IMarkdownString;
    readonly status?: ChatSessionStatus;
    readonly tooltip?: string | IMarkdownString;
    readonly timing: IChatSessionTiming;
    readonly changes?: {
        readonly files: number;
        readonly insertions: number;
        readonly deletions: number;
    } | readonly IChatSessionFileChange[] | readonly IChatSessionFileChange2[];
    readonly archived?: boolean;
    readonly metadata?: {
        readonly [key: string]: unknown;
    };
}
export interface IChatSessionFileChange {
    readonly modifiedUri: URI;
    readonly originalUri?: URI;
    readonly insertions: number;
    readonly deletions: number;
}
export interface IChatSessionFileChange2 {
    readonly uri: URI;
    readonly originalUri?: URI;
    readonly modifiedUri?: URI;
    readonly insertions: number;
    readonly deletions: number;
}
export type IChatSessionHistoryItem = {
    id?: string;
    type: "request";
    prompt: string;
    participant: string;
    command?: string;
    variableData?: IChatRequestVariableData;
    modelId?: string;
} | {
    type: "response";
    parts: IChatProgress[];
    participant: string;
};
export type IChatSessionRequestHistoryItem = Extract<IChatSessionHistoryItem, {
    type: "request";
}>;
/**
 * The session type used for local agent chat sessions.
 */
export declare const localChatSessionType = "local";
/**
 * The option ID used for selecting the agent in chat sessions.
 */
export declare const agentOptionId = "agent";
export interface IChatSession extends IDisposable {
    readonly onWillDispose: Event<void>;
    readonly sessionResource: URI;
    readonly title?: string;
    readonly history: readonly IChatSessionHistoryItem[];
    readonly options?: ReadonlyChatSessionOptionsMap;
    readonly progressObs?: IObservable<IChatProgress[]>;
    readonly isCompleteObs?: IObservable<boolean>;
    readonly interruptActiveResponseCallback?: () => Promise<boolean>;
    /**
     * Editing session transferred from a previously-untitled chat session in `onDidCommitChatSessionItem`.
     */
    transferredState?: {
        readonly editingSession: IChatEditingSession | undefined;
        readonly inputState: ISerializableChatModelInputState | undefined;
    };
    requestHandler?: (request: IChatAgentRequest, progress: (progress: IChatProgress[]) => void, history: any[], // TODO: Nail down types
    token: CancellationToken) => Promise<void>;
    /**
     * Forks the session from the given request point.
     * @param request The request history item to fork from, or undefined to fork from the end.
     * @param token Cancellation token.
     * @returns The forked session item. The promise is rejected if forking fails.
     */
    forkSession?: (request: IChatSessionRequestHistoryItem | undefined, token: CancellationToken) => Promise<IChatSessionItem>;
}
export interface IChatSessionContentProvider {
    provideChatSessionContent(sessionResource: URI, token: CancellationToken): Promise<IChatSession>;
}
export interface IChatNewSessionRequest {
    readonly prompt: string;
    readonly command?: string;
    readonly initialSessionOptions?: ReadonlyChatSessionOptionsMap;
}
export interface IChatSessionItemsDelta {
    readonly addedOrUpdated?: readonly IChatSessionItem[];
    readonly removed?: readonly URI[];
}
export interface IChatSessionItemController {
    readonly onDidChangeChatSessionItems: Event<IChatSessionItemsDelta>;
    get items(): readonly IChatSessionItem[];
    refresh(token: CancellationToken): Promise<void>;
    newChatSessionItem?(request: IChatNewSessionRequest, token: CancellationToken): Promise<IChatSessionItem | undefined>;
}
export interface IChatSessionOptionsChangeEvent {
    readonly sessionResource: URI;
    readonly updates: ReadonlyMap<string, string | IChatSessionProviderOptionItem | undefined>;
}
export type ResolvedChatSessionsExtensionPoint = Omit<IChatSessionsExtensionPoint, "icon"> & {
    readonly icon: ThemeIcon | URI | undefined;
};
/**
 * Session options as key-value pairs.
 *
 * Keys correspond to option group IDs (e.g., 'models', 'subagents') and values are either the selected option item IDs (string) or full option items (for locked state).
 */
export type ChatSessionOptionsMap = Map<string, string | IChatSessionProviderOptionItem>;
export declare namespace ChatSessionOptionsMap {
    function fromRecord(obj: {
        [key: string]: string | IChatSessionProviderOptionItem;
    }): ChatSessionOptionsMap;
    function toRecord(map: ReadonlyChatSessionOptionsMap): Record<string, string | IChatSessionProviderOptionItem>;
    function toStrValueArray(map: ReadonlyChatSessionOptionsMap | undefined): Array<{
        optionId: string;
        value: string;
    }> | undefined;
}
/**
 * Readonly version of {@link ChatSessionOptionsMap}
 */
export type ReadonlyChatSessionOptionsMap = ReadonlyMap<string, string | IChatSessionProviderOptionItem>;
export declare function isSessionInProgressStatus(state: ChatSessionStatus): boolean;
export declare function isIChatSessionFileChange2(obj: unknown): obj is IChatSessionFileChange2;
