import type { ContextItem } from '../../codebase-context/messages'; import type { Message } from '../../sourcegraph-api'; import type { SerializedChatTranscript } from '.'; export interface ChatMessage extends Message { contextFiles?: ContextItem[]; error?: ChatError; /** * For messages composed in a rich text editor field, this is the representation of the editor * state that can be used to instantiate the editor to edit the message or to render the * message. This field's value is opaque to all but the rich editor, and it must validate and * version the value so that it can (1) support backward- and forward-compatibility and (2) fall * back to editing the text for invalid values. */ editorState?: unknown; /** * The model used to generate this chat message response. Not set on human messages. * * NOTE: The chat model used to be a property of the entire chat session and was not changeable * after the chat session had begun. Now that field, {@link SerializedChatTranscript.chatModel}, * is deprecated, and this field should be used instead. */ model?: string; } export interface SerializedChatMessage { contextFiles?: ContextItem[]; error?: ChatError; editorState?: unknown; speaker: 'human' | 'assistant' | 'system'; text?: string; model?: string; } export interface ChatError { kind?: string; name: string; message: string; retryAfter?: string | null; limit?: number; userMessage?: string; retryAfterDate?: Date; retryAfterDateString?: string; retryMessage?: string; feature?: string; upgradeIsAvailable?: boolean; isChatErrorGuard: 'isChatErrorGuard'; } export interface UserLocalHistory { chat: ChatHistory; } export interface ChatHistory { [chatID: string]: SerializedChatTranscript; } /** * We need to specific a default event source as some commands can be * executed directly through VS Code where we cannot provide a custom source. * For example: Commands executed through the command palette, right-click menu or through keyboard shortcuts. */ export declare const DEFAULT_EVENT_SOURCE = "editor"; export type EventSource = typeof DEFAULT_EVENT_SOURCE | 'chat' | 'menu' | 'sidebar' | 'code-action:explain' | 'code-action:document' | 'code-action:edit' | 'code-action:fix' | 'code-action:generate' | 'code-action:test' | 'custom-commands' | 'code-lens' | 'hover' | 'terminal'; /** * Create a mapping of all source types to numerical values, so telemetry can be recorded on `metadata`. */ export declare const EventSourceTelemetryMetadataMapping: Record; /** * Converts an Error to a ChatError. Note that this cannot be done naively, * because some of the Error object's keys are typically not enumerable, and so * would be omitted during serialization. */ export declare function errorToChatError(error: Error): ChatError; //# sourceMappingURL=messages.d.ts.map