import { Event } from "../../../../../base/common/event.js"; import { IMarkdownString } from "../../../../../base/common/htmlContent.js"; import { Disposable } 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 { IInstantiationService } from "../../../../../platform/instantiation/common/instantiation.js"; import { IChatRequestVariableEntry } from "../attachments/chatVariableEntries.js"; import { ChatAgentVoteDirection, ChatAgentVoteDownReason, ChatRequestQueueKind, IChatCodeCitation, IChatContentReference, IChatDisabledClaudeHooksPart, IChatFollowup, IChatMcpServersStarting, IChatProgressMessage, IChatQuestionCarousel, IChatResponseErrorDetails, IChatTask, IChatUsedContext } from "../chatService/chatService.js"; import { IChatAgentCommand, IChatAgentData, IChatAgentResult } from "../participants/chatAgents.js"; import { IChatAgentNameService } from "../participants/chatAgents.service.js"; import { IParsedChatRequest } from "../requestParser/chatParserTypes.js"; import { CodeBlockModelCollection } from "@codingame/monaco-vscode-katex-common/vscode/vs/workbench/contrib/chat/common/widget/codeBlockModelCollection"; import { IChatModel, IChatProgressRenderableResponseContent, IChatRequestDisablement, IChatRequestModel, IChatResponseModel, IChatTextEditGroup, IResponse } from "./chatModel.js"; import { IChatStreamStats } from "./chatStreamStats.js"; export declare function isRequestVM(item: unknown): item is IChatRequestViewModel; export declare function isResponseVM(item: unknown): item is IChatResponseViewModel; export declare function isPendingDividerVM(item: unknown): item is IChatPendingDividerViewModel; export declare function isChatTreeItem(item: unknown): item is IChatRequestViewModel | IChatResponseViewModel; export declare function assertIsResponseVM(item: unknown): asserts item is IChatResponseViewModel; export type IChatViewModelChangeEvent = IChatAddRequestEvent | IChangePlaceholderEvent | IChatSessionInitEvent | IChatSetHiddenEvent | null; export interface IChatAddRequestEvent { kind: "addRequest"; } export interface IChangePlaceholderEvent { kind: "changePlaceholder"; } export interface IChatSessionInitEvent { kind: "initialize"; } export interface IChatSetHiddenEvent { kind: "setHidden"; } export interface IChatViewModel { readonly model: IChatModel; readonly sessionResource: URI; readonly onDidDisposeModel: Event; readonly onDidChange: Event; readonly inputPlaceholder?: string; getItems(): (IChatRequestViewModel | IChatResponseViewModel | IChatPendingDividerViewModel)[]; setInputPlaceholder(text: string): void; resetInputPlaceholder(): void; editing?: IChatRequestViewModel; setEditing(editing: IChatRequestViewModel): void; } export interface IChatRequestViewModel { readonly id: string; readonly sessionResource: URI; /** This ID updates every time the underlying data changes */ readonly dataId: string; readonly username: string; readonly avatarIcon?: URI | ThemeIcon; readonly message: IParsedChatRequest | IChatFollowup; readonly messageText: string; readonly attempt: number; readonly variables: readonly IChatRequestVariableEntry[]; currentRenderedHeight: number | undefined; readonly contentReferences?: ReadonlyArray; readonly confirmation?: string; readonly shouldBeRemovedOnSend: IChatRequestDisablement | undefined; readonly isComplete: boolean; readonly isCompleteAddedRequest: boolean; readonly slashCommand: IChatAgentCommand | undefined; readonly agentOrSlashCommandDetected: boolean; readonly shouldBeBlocked: IObservable; readonly modelId?: string; readonly timestamp: number; /** The kind of pending request, or undefined if not pending */ readonly pendingKind?: ChatRequestQueueKind; } export interface IChatResponseMarkdownRenderData { renderedWordCount: number; lastRenderTime: number; isFullyRendered: boolean; originalMarkdown: IMarkdownString; } export interface IChatResponseMarkdownRenderData2 { renderedWordCount: number; lastRenderTime: number; isFullyRendered: boolean; originalMarkdown: IMarkdownString; } export interface IChatProgressMessageRenderData { progressMessage: IChatProgressMessage; /** * Indicates whether this is part of a group of progress messages that are at the end of the response. * (Not whether this particular item is the very last one in the response). * Need to re-render and add to partsToRender when this changes. */ isAtEndOfResponse: boolean; /** * Whether this progress message the very last item in the response. * Need to re-render to update spinner vs check when this changes. */ isLast: boolean; } export interface IChatTaskRenderData { task: IChatTask; isSettled: boolean; progressLength: number; } export interface IChatResponseRenderData { renderedParts: IChatRendererContent[]; renderedWordCount: number; lastRenderTime: number; } /** * Content type for references used during rendering, not in the model */ export interface IChatReferences { references: ReadonlyArray; kind: "references"; } /** * Content type for the "Working" progress message */ export interface IChatWorkingProgress { kind: "working"; } /** * Content type for citations used during rendering, not in the model */ export interface IChatCodeCitations { citations: ReadonlyArray; kind: "codeCitations"; } export interface IChatErrorDetailsPart { kind: "errorDetails"; errorDetails: IChatResponseErrorDetails; isLast: boolean; } export interface IChatChangesSummaryPart { readonly kind: "changesSummary"; readonly requestId: string; readonly sessionResource: URI; } /** * Type for content parts rendered by IChatListRenderer (not necessarily in the model) */ export type IChatRendererContent = IChatProgressRenderableResponseContent | IChatReferences | IChatCodeCitations | IChatErrorDetailsPart | IChatChangesSummaryPart | IChatWorkingProgress | IChatMcpServersStarting | IChatQuestionCarousel | IChatDisabledClaudeHooksPart; export interface IChatResponseViewModel { readonly model: IChatResponseModel; readonly id: string; readonly session: IChatViewModel; readonly sessionResource: URI; /** This ID updates every time the underlying data changes */ readonly dataId: string; /** The ID of the associated IChatRequestViewModel */ readonly requestId: string; readonly username: string; readonly agent?: IChatAgentData; readonly slashCommand?: IChatAgentCommand; readonly agentOrSlashCommandDetected: boolean; readonly response: IResponse; readonly usedContext: IChatUsedContext | undefined; readonly contentReferences: ReadonlyArray; readonly codeCitations: ReadonlyArray; readonly progressMessages: ReadonlyArray; readonly isComplete: boolean; readonly isCanceled: boolean; readonly isStale: boolean; readonly vote: ChatAgentVoteDirection | undefined; readonly voteDownReason: ChatAgentVoteDownReason | undefined; readonly replyFollowups?: IChatFollowup[]; readonly errorDetails?: IChatResponseErrorDetails; readonly result?: IChatAgentResult; readonly contentUpdateTimings?: IChatStreamStats; readonly shouldBeRemovedOnSend: IChatRequestDisablement | undefined; readonly isCompleteAddedRequest: boolean; renderData?: IChatResponseRenderData; currentRenderedHeight: number | undefined; setVote(vote: ChatAgentVoteDirection): void; setVoteDownReason(reason: ChatAgentVoteDownReason | undefined): void; usedReferencesExpanded?: boolean; vulnerabilitiesListExpanded: boolean; setEditApplied(edit: IChatTextEditGroup, editCount: number): void; readonly shouldBeBlocked: IObservable; } export interface IChatPendingDividerViewModel { readonly kind: "pendingDivider"; readonly id: string; readonly sessionResource: URI; readonly isComplete: true; readonly dividerKind: ChatRequestQueueKind; currentRenderedHeight: number | undefined; } export interface IChatViewModelOptions { /** * Maximum number of items to return from getItems(). * When set, only the last N items are returned (most recent request/response pairs). */ readonly maxVisibleItems?: number; } export declare class ChatViewModel extends Disposable implements IChatViewModel { private readonly _model; readonly codeBlockModelCollection: CodeBlockModelCollection; private readonly _options; private readonly instantiationService; private readonly _onDidDisposeModel; readonly onDidDisposeModel: Event; private readonly _onDidChange; readonly onDidChange: Event; private readonly _items; private _inputPlaceholder; get inputPlaceholder(): string | undefined; get model(): IChatModel; setInputPlaceholder(text: string): void; resetInputPlaceholder(): void; get sessionResource(): URI; constructor(_model: IChatModel, codeBlockModelCollection: CodeBlockModelCollection, _options: IChatViewModelOptions | undefined, instantiationService: IInstantiationService); private onAddResponse; getItems(): (IChatRequestViewModel | IChatResponseViewModel | IChatPendingDividerViewModel)[]; private _editing; get editing(): IChatRequestViewModel | undefined; setEditing(editing: IChatRequestViewModel | undefined): void; dispose(): void; } export declare class ChatRequestViewModel implements IChatRequestViewModel { private readonly _model; private readonly _pendingKind?; get id(): string; /** * An ID that changes when the request should be re-rendered. */ get dataId(): string; get sessionResource(): URI; get username(): string; get avatarIcon(): ThemeIcon; get message(): IParsedChatRequest; get messageText(): string; get attempt(): number; get variables(): readonly IChatRequestVariableEntry[]; get contentReferences(): readonly IChatContentReference[] | undefined; get confirmation(): string | undefined; get isComplete(): boolean; get isCompleteAddedRequest(): boolean; get shouldBeRemovedOnSend(): IChatRequestDisablement | undefined; get shouldBeBlocked(): IObservable; get slashCommand(): IChatAgentCommand | undefined; get agentOrSlashCommandDetected(): boolean; currentRenderedHeight: number | undefined; get modelId(): string | undefined; get timestamp(): number; get pendingKind(): ChatRequestQueueKind | undefined; constructor(_model: IChatRequestModel, _pendingKind?: ChatRequestQueueKind | undefined); } export declare class ChatResponseViewModel extends Disposable implements IChatResponseViewModel { private readonly _model; readonly session: IChatViewModel; private readonly instantiationService; private readonly chatAgentNameService; private _modelChangeCount; private readonly _onDidChange; readonly onDidChange: Event; get model(): IChatResponseModel; get id(): string; get dataId(): string; get sessionResource(): URI; get username(): string; get agent(): IChatAgentData | undefined; get slashCommand(): IChatAgentCommand | undefined; get agentOrSlashCommandDetected(): boolean; get response(): IResponse; get usedContext(): IChatUsedContext | undefined; get contentReferences(): ReadonlyArray; get codeCitations(): ReadonlyArray; get progressMessages(): ReadonlyArray; get isComplete(): boolean; get isCanceled(): boolean; get shouldBeBlocked(): IObservable; get shouldBeRemovedOnSend(): IChatRequestDisablement | undefined; get isCompleteAddedRequest(): boolean; get replyFollowups(): IChatFollowup[] | undefined; get result(): IChatAgentResult | undefined; get errorDetails(): IChatResponseErrorDetails | undefined; get vote(): ChatAgentVoteDirection | undefined; get voteDownReason(): ChatAgentVoteDownReason | undefined; get requestId(): string; get isStale(): boolean; get isLast(): boolean; renderData: IChatResponseRenderData | undefined; currentRenderedHeight: number | undefined; private _usedReferencesExpanded; get usedReferencesExpanded(): boolean | undefined; set usedReferencesExpanded(v: boolean); private _vulnerabilitiesListExpanded; get vulnerabilitiesListExpanded(): boolean; set vulnerabilitiesListExpanded(v: boolean); private readonly liveUpdateTracker; get contentUpdateTimings(): IChatStreamStats | undefined; constructor(_model: IChatResponseModel, session: IChatViewModel, instantiationService: IInstantiationService, chatAgentNameService: IChatAgentNameService); setVote(vote: ChatAgentVoteDirection): void; setVoteDownReason(reason: ChatAgentVoteDownReason | undefined): void; setEditApplied(edit: IChatTextEditGroup, editCount: number): void; }