import { IMarkdownString } from "../../../../../base/common/htmlContent.js"; import { ThemeIcon } from "../../../../../base/common/themables.js"; import { URI } from "../../../../../base/common/uri.js"; import { IRange } from "../../../../../editor/common/core/range.js"; import { IOffsetRange } from "../../../../../editor/common/core/ranges/offsetRange.js"; import { Location, SymbolKind } from "../../../../../editor/common/languages.js"; import { MarkerSeverity, IMarker } from "../../../../../platform/markers/common/markers.js"; import type { IFeedbackPullRequest } from "../../../../../platform/agentHost/common/meta/agentFeedbackAnnotations.js"; import { ISCMHistoryItem } from "../../../scm/common/history.js"; import { IChatContentReference } from "../chatService/chatService.js"; import { IChatRequestVariableValue } from "./chatVariables.js"; import { IToolData, IToolSet } from "../tools/languageModelToolsService.js"; import type { ILanguageModelChatMetadata } from "../languageModels.js"; /** * An icon for a chat context item. Mirrors the `IconPath` type from the extension API: * either a {@link ThemeIcon theme icon}, a single {@link URI} or separate light/dark {@link URI uris}. */ export type ChatContextIconPath = ThemeIcon | URI | { light: URI; dark: URI; }; /** * Type guard for {@link ChatContextIconPath}. Accepts a {@link ThemeIcon theme icon}, a single * {@link URI} or an object with both `light` and `dark` {@link URI uris}. Rejects `null`, `undefined` * and partially-specified light/dark objects. */ export declare function isChatContextIconPath(value: unknown): value is ChatContextIconPath; /** * Resolve a {@link ChatContextIconPath} into a value that can be passed to the `iconPath` * option of an icon label, picking the light or dark uri based on the current theme. * * @param iconPath The icon path to resolve. * @param useDark Whether the current theme is a dark theme. */ export declare function resolveChatContextIcon(iconPath: ChatContextIconPath, useDark: boolean): ThemeIcon | URI; interface IBaseChatRequestVariableEntry { readonly id: string; readonly fullName?: string; readonly icon?: ThemeIcon; readonly name: string; readonly modelDescription?: string; /** * The offset-range in the prompt. This means this entry has been explicitly typed out * by the user. */ readonly range?: IOffsetRange; readonly value: IChatRequestVariableValue; readonly references?: IChatContentReference[]; /** * Implementation-defined metadata that providers attach to a variable * entry. Used to round-trip provider-specific data (e.g. agent-host * `_meta`) when an entry is sent back to the provider as part of a * request attachment. */ readonly _meta?: Record; omittedState?: OmittedState; } export interface IGenericChatRequestVariableEntry extends IBaseChatRequestVariableEntry { kind: "generic"; tooltip?: IMarkdownString; /** * A provider-supplied icon that may be a {@link ThemeIcon theme icon}, a single uri or light/dark uris. * Takes precedence over the {@link IBaseChatRequestVariableEntry.icon base theme icon} when rendering. */ iconPath?: ChatContextIconPath; } export declare const ChatPasteAttachmentMetadata: { readonly Kind: "vscode.chat.attachment.kind"; readonly Language: "vscode.chat.attachment.language"; readonly FileName: "vscode.chat.attachment.fileName"; readonly PastedLines: "vscode.chat.attachment.pastedLines"; readonly TextArtifact: "vscode.chat.attachment.textArtifact"; /** Preserves explicit-file sendability when its content is snapshotted as text. */ readonly FileSnapshot: "vscode.chat.attachment.fileSnapshot"; }; export declare const ChatTranscriptContextAttachmentDisplayKind = "transcriptContext"; export interface IRestorablePasteAttachment { readonly label: string; readonly displayKind?: string; readonly modelRepresentation?: string; readonly _meta?: Record; } export declare enum AgentHostCompletionReferenceKind { Skill = "skill", Command = "command" } export interface IAgentHostCompletionVariableValue { readonly $mid: "agentHostCompletion"; readonly kind: AgentHostCompletionReferenceKind; } export declare function toAgentHostCompletionVariableEntry(kind: AgentHostCompletionReferenceKind, name: string, reference: URI | string | undefined, _meta: Record | undefined): IGenericChatRequestVariableEntry & { value: IAgentHostCompletionVariableValue; }; export declare function toAgentHostCompletionVariableEntryFromMetadata(kind: AgentHostCompletionReferenceKind, name: string, _meta: Record | undefined): IGenericChatRequestVariableEntry & { value: IAgentHostCompletionVariableValue; }; export declare function getAgentHostCompletionReferenceKind(entry: IChatRequestVariableEntry): AgentHostCompletionReferenceKind | undefined; export declare function getAgentHostCompletionReferenceKindFromValue(value: IChatRequestVariableValue): AgentHostCompletionReferenceKind | undefined; export declare function isAgentHostCompletionVariableEntry(entry: IChatRequestVariableEntry): entry is IGenericChatRequestVariableEntry & { value: IAgentHostCompletionVariableValue; }; export interface IChatRequestDirectoryEntry extends IBaseChatRequestVariableEntry { kind: "directory"; imageCount?: number; } export interface IChatRequestFileEntry extends IBaseChatRequestVariableEntry { kind: "file"; } export declare enum OmittedState { NotOmitted = 0, Partial = 1, Full = 2, ImageLimitExceeded = 3 } /** * Returns the image-attachment limit for the selected model. * * Claude-family models use a max of 20 (Messages API), Gemini-family models use * a max of 10. Other models do not have a UI-enforced image count limit. */ export declare function getImageAttachmentLimit(model: Pick | undefined): number | undefined; export interface IChatRequestToolEntry extends IBaseChatRequestVariableEntry { readonly kind: "tool"; } export interface IChatRequestToolSetEntry extends IBaseChatRequestVariableEntry { readonly kind: "toolset"; readonly value: IChatRequestToolEntry[]; } export type ChatRequestToolReferenceEntry = IChatRequestToolEntry | IChatRequestToolSetEntry; export interface StringChatContextValue { value?: string; name?: string; modelDescription?: string; iconPath?: ChatContextIconPath; uri: URI; resourceUri?: URI; tooltip?: IMarkdownString; /** * Command ID to execute when this context item is clicked. */ readonly commandId?: string; readonly handle: number; } export interface IChatRequestImplicitVariableEntry extends IBaseChatRequestVariableEntry { readonly kind: "implicit"; readonly isFile: true; readonly value: URI | Location | StringChatContextValue | undefined; readonly uri: URI | undefined; readonly isSelection: boolean; enabled: boolean; } export interface IChatRequestStringVariableEntry extends IBaseChatRequestVariableEntry { readonly kind: "string"; readonly value: string | undefined; readonly modelDescription?: string; readonly iconPath?: ChatContextIconPath; readonly uri: URI; readonly resourceUri?: URI; readonly tooltip?: IMarkdownString; /** * Command ID to execute when this context item is clicked. */ readonly commandId?: string; readonly handle: number; } export interface IChatRequestTranscriptContextVariableEntry extends IBaseChatRequestVariableEntry { readonly kind: "transcriptContext"; readonly value: string; readonly uri: URI; readonly tooltip?: string; /** Message shown when hidden transcript preparation for this context completes. */ readonly readyMessage?: string; } export interface IChatRequestWorkspaceVariableEntry extends IBaseChatRequestVariableEntry { readonly kind: "workspace"; readonly value: string; readonly modelDescription?: string; } export interface IChatRequestPasteVariableEntry extends IBaseChatRequestVariableEntry { readonly kind: "paste"; readonly code: string; readonly language: string; readonly pastedLines: string; readonly fileName: string; readonly copiedFrom: { readonly uri: URI; readonly range: IRange; } | undefined; } export declare function toPasteVariableEntry(name: string, code: string, options?: { readonly id?: string; readonly icon?: ThemeIcon; readonly language?: string; readonly fileName?: string; readonly pastedLines?: string; readonly _meta?: Record; }): IChatRequestPasteVariableEntry; export declare function restorePasteVariableEntryFromAttachment(attachment: IRestorablePasteAttachment): IChatRequestPasteVariableEntry | undefined; export interface ISymbolVariableEntry extends IBaseChatRequestVariableEntry { readonly kind: "symbol"; readonly value: Location; readonly symbolKind: SymbolKind; } export interface ICommandResultVariableEntry extends IBaseChatRequestVariableEntry { readonly kind: "command"; } export interface IImageVariableEntry extends IBaseChatRequestVariableEntry { readonly kind: "image"; readonly isPasted?: boolean; readonly isURL?: boolean; readonly mimeType?: string; } export interface INotebookOutputVariableEntry extends IBaseChatRequestVariableEntry { readonly kind: "notebookOutput"; readonly outputIndex?: number; readonly mimeType?: string; } export interface IDiagnosticVariableEntryFilterData { readonly owner?: string; readonly problemMessage?: string; readonly filterUri?: URI; readonly filterSeverity?: MarkerSeverity; readonly filterRange?: IRange; } export declare namespace IDiagnosticVariableEntryFilterData { const icon: ThemeIcon; function fromMarker(marker: IMarker): IDiagnosticVariableEntryFilterData; function toEntry(data: IDiagnosticVariableEntryFilterData): IDiagnosticVariableEntry; function id(data: IDiagnosticVariableEntryFilterData): string; function label(data: IDiagnosticVariableEntryFilterData): string; } export interface IDiagnosticVariableEntry extends IBaseChatRequestVariableEntry, IDiagnosticVariableEntryFilterData { readonly kind: "diagnostic"; } export interface IElementAncestorData { readonly tagName: string; readonly id?: string; readonly classNames?: string[]; } export interface IElementVariableEntry extends IBaseChatRequestVariableEntry { readonly kind: "element"; readonly value: string; readonly imageData?: IChatRequestVariableValue; readonly imageMimeType?: string; readonly ancestors?: IElementAncestorData[]; readonly attributes?: Record; readonly computedStyles?: Record; readonly dimensions?: { readonly top: number; readonly left: number; readonly width: number; readonly height: number; }; readonly innerText?: string; } export interface IPromptFileVariableEntry extends IBaseChatRequestVariableEntry { readonly kind: "promptFile"; readonly value: URI; readonly isRoot: boolean; readonly originLabel?: string; readonly modelDescription: string; readonly automaticallyAdded: boolean; readonly toolReferences?: readonly ChatRequestToolReferenceEntry[]; } export interface IPromptTextVariableEntry extends IBaseChatRequestVariableEntry { readonly kind: "promptText"; readonly value: string; readonly settingId?: string; readonly modelDescription: string; readonly automaticallyAdded: boolean; readonly toolReferences?: readonly ChatRequestToolReferenceEntry[]; } export interface ISCMHistoryItemVariableEntry extends IBaseChatRequestVariableEntry { readonly kind: "scmHistoryItem"; readonly value: URI; readonly historyItem: ISCMHistoryItem; } export interface ISCMHistoryItemChangeVariableEntry extends IBaseChatRequestVariableEntry { readonly kind: "scmHistoryItemChange"; readonly value: URI; readonly historyItem: ISCMHistoryItem; } export interface ISCMHistoryItemChangeRangeVariableEntry extends IBaseChatRequestVariableEntry { readonly kind: "scmHistoryItemChangeRange"; readonly value: URI; readonly historyItemChangeStart: { readonly uri: URI; readonly historyItem: ISCMHistoryItem; }; readonly historyItemChangeEnd: { readonly uri: URI; readonly historyItem: ISCMHistoryItem; }; } export interface ITerminalVariableEntry extends IBaseChatRequestVariableEntry { readonly kind: "terminalCommand"; readonly value: string; readonly resource: URI; readonly command: string; readonly output?: string; readonly exitCode?: number; } export interface IDebugVariableEntry extends IBaseChatRequestVariableEntry { readonly kind: "debugVariable"; readonly value: string; readonly expression: string; readonly type?: string; } export interface IAgentFeedbackVariableEntry extends IBaseChatRequestVariableEntry { readonly kind: "agentFeedback"; readonly sessionResource: URI; /** * The agent-host annotations channel URI that backs these feedback items * (each item id is an annotation id on this channel). Set only for * agent-host sessions; used to emit {@link MessageAnnotationsAttachment}s * referencing the specific comments on the wire. */ readonly annotationsResource?: URI; readonly feedbackItems: ReadonlyArray<{ readonly id: string; readonly text: string; readonly resourceUri: URI; readonly range: IRange; readonly codeSelection?: string; readonly diffHunks?: string; /** When this item was converted from a PR review comment, the original thread ID. */ readonly sourcePRReviewCommentId?: string; /** Pull request that originated this PR review comment. */ readonly sourcePullRequest?: IFeedbackPullRequest; /** Additional replies that belong to the same comment thread as {@link text}. */ readonly replies?: readonly string[]; }>; } export interface IChatRequestDebugEventsVariableEntry extends IBaseChatRequestVariableEntry { readonly kind: "debugEvents"; /** Timestamp when the debug events were snapshotted. */ readonly snapshotTime: number; /** The session resource these debug events belong to. */ readonly sessionResource: URI; } export interface IChatRequestSessionReferenceVariableEntry extends IBaseChatRequestVariableEntry { readonly kind: "sessionReference"; readonly value: URI; } export interface IBrowserViewVariableEntry extends IBaseChatRequestVariableEntry { readonly kind: "browserView"; readonly value: URI; readonly browserId: string; } export declare function isBrowserViewVariableEntry(entry: IChatRequestVariableEntry): entry is IBrowserViewVariableEntry; /** * A first-class reference to another agent-host chat, produced when the user * types `#chat:` in an agent-host chat input or drops a chat tab onto the * input. Carries everything needed to render the reference chip and to send an * agent-host chat attachment: the referenced chat's opaque backend chat URI * ({@link value}) and, when pinned, the {@link endTurn last completed turn} * included in the transcript. The display title lives on * {@link IBaseChatRequestVariableEntry.name name}. */ export interface IChatRequestChatReferenceVariableEntry extends IBaseChatRequestVariableEntry { readonly kind: "chatReference"; /** * The referenced chat's **opaque backend chat URI** — the exact value carried * on `MessageChatAttachment.resource` on the wire. It is provider-defined and * opaque: generic code MUST only store it, compare it by equality, and pass it * to agent-host-owned helpers (e.g. the chat-reference widget's link builder); * it MUST NOT parse or construct it. Send and restore are therefore pure * identity, and the client-side chat is resolved lazily (only when the user * clicks the reference chip). Because a reference can never cross agent hosts, * the URI always names a chat on a connected host. */ readonly value: URI; /** * Last completed turn included in the referenced transcript. Omitted for * references that do not pin a turn (e.g. a dropped chat/session), in which * case the host resolves the referenced chat's latest completed turn when it * accepts the message. */ readonly endTurn?: string; } /** * Type guard for a {@link IChatRequestChatReferenceVariableEntry chat-reference entry}. */ export declare function isChatReferenceVariableEntry(entry: IChatRequestVariableEntry): entry is IChatRequestChatReferenceVariableEntry; /** * Stable, dedupe-friendly id for a chat reference, derived from the referenced * chat resource and — when the reference pins a turn — the last completed turn. * Re-accepting the same reference therefore produces the same id. A pinned * reference (with {@link endTurn}) and an unpinned one to the same chat produce * distinct ids so they never collide. * * @param chatResource The opaque backend chat URI of the referenced chat. Stored * verbatim in the id; never parsed. * @param endTurn The last completed turn included in the referenced transcript, if pinned. */ export declare function chatReferenceVariableEntryId(chatResource: URI, endTurn?: string): string; /** * Build the first-class {@link IChatRequestChatReferenceVariableEntry chat-reference entry} * (the input pill) for a referenced chat. * * @param chatResource The opaque backend chat URI of the referenced chat (the * value carried on `MessageChatAttachment.resource`). Stored verbatim; never parsed. * @param endTurn The last completed turn included in the referenced transcript, if pinned. * @param title The chat title used as the display label. * @param _meta Provider-supplied `_meta` to preserve on the entry. * @param range The offset-range of the reference in the prompt, when typed out. */ export declare function createChatReferenceVariableEntry(chatResource: URI, endTurn: string | undefined, title: string, _meta?: Record<string, unknown>, range?: IOffsetRange): IChatRequestChatReferenceVariableEntry; /** * Transient value carried on a chat-reference dynamic variable (via its `data` * channel) so the request parser can rebuild the first-class * {@link IChatRequestChatReferenceVariableEntry} without an out-of-band `_meta` * bag. This never becomes the entry's `value` — see * {@link chatReferenceVariableEntryFromDynamicValue}. */ export interface IChatReferenceDynamicVariableValue { readonly $mid: "agentHostChatReference"; /** * The referenced chat's **opaque backend chat URI** as a string — the exact * value carried on `MessageChatAttachment.resource`. Becomes the rebuilt * entry's {@link IChatRequestChatReferenceVariableEntry.value}. Never parsed * by generic code. */ readonly chatResource: string; /** Last completed turn included in the referenced transcript, if pinned. */ readonly endTurn?: string; } /** * Build the {@link IChatReferenceDynamicVariableValue dynamic-variable transport} * for a chat reference. */ export declare function toChatReferenceDynamicVariableValue(chatResource: URI, endTurn?: string): IChatReferenceDynamicVariableValue; /** * Type guard for a {@link IChatReferenceDynamicVariableValue}. */ export declare function isChatReferenceDynamicVariableValue(value: IChatRequestVariableValue): value is IChatReferenceDynamicVariableValue; /** * Rebuild a first-class {@link IChatRequestChatReferenceVariableEntry} from a * chat-reference {@link IChatReferenceDynamicVariableValue dynamic-variable value} * carried through the request parser. Returns `undefined` when the resource * cannot be parsed. * * @param value The dynamic-variable transport value. * @param id The stable dynamic-variable id. * @param name The display title for the reference. * @param range The offset-range of the reference in the prompt. * @param _meta Provider-supplied `_meta` to preserve on the entry. */ export declare function chatReferenceVariableEntryFromDynamicValue(value: IChatReferenceDynamicVariableValue, id: string, name: string, range: IOffsetRange | undefined, _meta: Record<string, unknown> | undefined): IChatRequestChatReferenceVariableEntry | undefined; export type IChatRequestVariableEntry = IGenericChatRequestVariableEntry | IChatRequestImplicitVariableEntry | IChatRequestPasteVariableEntry | ISymbolVariableEntry | ICommandResultVariableEntry | IDiagnosticVariableEntry | IImageVariableEntry | IChatRequestToolEntry | IChatRequestToolSetEntry | IChatRequestDirectoryEntry | IChatRequestFileEntry | INotebookOutputVariableEntry | IElementVariableEntry | IPromptFileVariableEntry | IPromptTextVariableEntry | ISCMHistoryItemVariableEntry | ISCMHistoryItemChangeVariableEntry | ISCMHistoryItemChangeRangeVariableEntry | ITerminalVariableEntry | IChatRequestStringVariableEntry | IChatRequestWorkspaceVariableEntry | IDebugVariableEntry | IAgentFeedbackVariableEntry | IChatRequestDebugEventsVariableEntry | IChatRequestSessionReferenceVariableEntry | IBrowserViewVariableEntry | IChatRequestChatReferenceVariableEntry | IChatRequestTranscriptContextVariableEntry; export declare namespace IChatRequestVariableEntry { /** * Returns URI of the passed variant entry. Return undefined if not found. */ function toUri(entry: IChatRequestVariableEntry): URI | undefined; function toExport(v: IChatRequestVariableEntry): IChatRequestVariableEntry; function fromExport(v: IChatRequestVariableEntry): IChatRequestVariableEntry; } export declare function isImplicitVariableEntry(obj: IChatRequestVariableEntry): obj is IChatRequestImplicitVariableEntry; export declare function isStringVariableEntry(obj: IChatRequestVariableEntry): obj is IChatRequestStringVariableEntry; export declare function isChatTranscriptContextVariableEntry(obj: IChatRequestVariableEntry): obj is IChatRequestTranscriptContextVariableEntry; export declare function toChatTranscriptContextAttachmentMeta(entry: IChatRequestTranscriptContextVariableEntry): Record<string, unknown>; export declare function restoreChatTranscriptContextVariableEntry(label: string, value: string, meta: Record<string, unknown> | undefined): IChatRequestTranscriptContextVariableEntry | undefined; export declare function isTerminalVariableEntry(obj: IChatRequestVariableEntry): obj is ITerminalVariableEntry; export declare function isDebugVariableEntry(obj: IChatRequestVariableEntry): obj is IDebugVariableEntry; export declare function isAgentFeedbackVariableEntry(obj: IChatRequestVariableEntry): obj is IAgentFeedbackVariableEntry; export declare function isPasteVariableEntry(obj: IChatRequestVariableEntry): obj is IChatRequestPasteVariableEntry; export declare function isPastedTextArtifact(obj: IChatRequestVariableEntry): obj is IChatRequestPasteVariableEntry; export declare function isWorkspaceVariableEntry(obj: IChatRequestVariableEntry): obj is IChatRequestWorkspaceVariableEntry; export declare function isImageVariableEntry(obj: IChatRequestVariableEntry): obj is IImageVariableEntry; export declare function isExplicitFileOrImageVariableEntry(obj: IChatRequestVariableEntry): obj is IChatRequestFileEntry | IChatRequestDirectoryEntry | IImageVariableEntry | IChatRequestPasteVariableEntry; export declare function getExplicitFileOrImageAttachmentSummary(entries: readonly IChatRequestVariableEntry[]): string | undefined; export declare function isNotebookOutputVariableEntry(obj: IChatRequestVariableEntry): obj is INotebookOutputVariableEntry; export declare function isElementVariableEntry(obj: IChatRequestVariableEntry): obj is IElementVariableEntry; export declare function isDiagnosticsVariableEntry(obj: IChatRequestVariableEntry): obj is IDiagnosticVariableEntry; export declare function isChatRequestFileEntry(obj: IChatRequestVariableEntry): obj is IChatRequestFileEntry; export declare function isPromptFileVariableEntry(obj: IChatRequestVariableEntry): obj is IPromptFileVariableEntry; export declare function isPromptTextVariableEntry(obj: IChatRequestVariableEntry): obj is IPromptTextVariableEntry; export declare function isChatRequestVariableEntry(obj: unknown): obj is IChatRequestVariableEntry; export declare function isSCMHistoryItemVariableEntry(obj: IChatRequestVariableEntry): obj is ISCMHistoryItemVariableEntry; export declare function isSCMHistoryItemChangeVariableEntry(obj: IChatRequestVariableEntry): obj is ISCMHistoryItemChangeVariableEntry; export declare function isSCMHistoryItemChangeRangeVariableEntry(obj: IChatRequestVariableEntry): obj is ISCMHistoryItemChangeRangeVariableEntry; export declare function isStringImplicitContextValue(value: unknown): value is StringChatContextValue; export declare enum PromptFileVariableKind { Instruction = "vscode.instructions.file.root", InstructionReference = "vscode.instructions.file.reference", PromptFile = "vscode.prompt.file" } /** * Utility to convert a {@link uri} to a chat variable entry. * The `id` of the chat variable can be one of the following: * * - `vscode.instructions.file.reference__<URI>`: for all non-root prompt instructions references * - `vscode.instructions.file.root__<URI>`: for *root* prompt instructions references * - `vscode.prompt.file__<URI>`: for prompt file references * * @param uri A resource URI that points to a prompt instructions file. * @param kind The kind of the prompt file variable entry. */ export declare function toPromptFileVariableEntry(uri: URI, kind: PromptFileVariableKind, originLabel?: string, automaticallyAdded?: boolean, toolReferences?: ChatRequestToolReferenceEntry[]): IPromptFileVariableEntry; export declare function toPromptTextVariableEntry(content: string, automaticallyAdded?: boolean, toolReferences?: ChatRequestToolReferenceEntry[]): IPromptTextVariableEntry; export declare function toFileVariableEntry(uri: URI, range?: IRange): IChatRequestFileEntry; export declare function toToolVariableEntry(entry: IToolData, range?: IOffsetRange): IChatRequestToolEntry; export declare function toToolSetVariableEntry(entry: IToolSet, range?: IOffsetRange): IChatRequestToolSetEntry; export declare class ChatRequestVariableSet { private _ids; private _entries; constructor(entries?: IChatRequestVariableEntry[]); add(...entry: IChatRequestVariableEntry[]): void; insertFirst(entry: IChatRequestVariableEntry): void; remove(entry: IChatRequestVariableEntry): void; has(entry: IChatRequestVariableEntry): boolean; asArray(): IChatRequestVariableEntry[]; get length(): number; } export {};