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 { IChatRequestModeInstructions, 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; /** * 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.`. * 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; /** * When true, uses the incoming request's mode instructions to populate the built-in pickers such as Agent and Model pickers. When false, the pickers are populated based on the session type as they have been before. This is useful for testing the new ChatRequestTurn2-based flow for populating pickers. */ readonly useRequestToPopulateBuiltInPickers?: 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; modeInstructions?: IChatRequestModeInstructions; } | { type: "response"; parts: IChatProgress[]; participant: string; }; export type IChatSessionRequestHistoryItem = Extract; /** * 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; readonly sessionResource: URI; readonly title?: string; readonly history: readonly IChatSessionHistoryItem[]; readonly options?: ReadonlyChatSessionOptionsMap; readonly progressObs?: IObservable; readonly isCompleteObs?: IObservable; readonly interruptActiveResponseCallback?: () => Promise; /** * Event fired when the server initiates a new request (e.g. from a consumed * queued message). The consumer should create a new request+response pair in * the model and prepare to receive progress via {@link progressObs}. */ readonly onDidStartServerRequest?: Event<{ prompt: string; }>; /** * 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; /** * 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; } export interface IChatSessionContentProvider { provideChatSessionContent(sessionResource: URI, token: CancellationToken): Promise; } 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; get items(): readonly IChatSessionItem[]; refresh(token: CancellationToken): Promise; newChatSessionItem?(request: IChatNewSessionRequest, token: CancellationToken): Promise; } export interface IChatSessionOptionsChangeEvent { readonly sessionResource: URI; readonly updates: ReadonlyMap; } export type ResolvedChatSessionsExtensionPoint = Omit & { 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; export declare namespace ChatSessionOptionsMap { function fromRecord(obj: { [key: string]: string | IChatSessionProviderOptionItem; }): ChatSessionOptionsMap; function toRecord(map: ReadonlyChatSessionOptionsMap): Record; function toStrValueArray(map: ReadonlyChatSessionOptionsMap | undefined): Array<{ optionId: string; value: string; }> | undefined; } /** * Readonly version of {@link ChatSessionOptionsMap} */ export type ReadonlyChatSessionOptionsMap = ReadonlyMap; export interface IChatSessionCustomizationItem { readonly label: string; readonly description?: string; readonly uri: URI; readonly storageLocation: number; readonly icon?: ThemeIcon; } export interface IChatSessionCustomizationItemGroup { readonly id: string; readonly items: IChatSessionCustomizationItem[]; readonly commands?: readonly { readonly id: string; readonly title: string; readonly arguments?: readonly unknown[]; }[]; readonly itemCommands?: readonly { readonly id: string; readonly title: string; readonly arguments?: readonly unknown[]; }[]; } export interface IChatSessionCustomizationsProvider { readonly onDidChangeCustomizations: Event; provideCustomizations(token: CancellationToken): Promise; } export interface IChatSessionCommitEvent { /** The original (untitled) session resource. */ readonly original: URI; /** The committed (real) session resource. */ readonly committed: URI; } export declare function isSessionInProgressStatus(state: ChatSessionStatus): boolean; export declare function isIChatSessionFileChange2(obj: unknown): obj is IChatSessionFileChange2;