Path: blob/main/src/vscode-dts/vscode.proposed.chatDebug.d.ts
13379 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45// version: 467declare module 'vscode' {8/**9* The severity level of a chat debug log event.10*/11export enum ChatDebugLogLevel {12Trace = 0,13Info = 1,14Warning = 2,15Error = 316}1718/**19* The outcome of a tool call.20*/21export enum ChatDebugToolCallResult {22Success = 0,23Error = 124}2526/**27* A tool call event in the chat debug log, representing the invocation28* of a tool (e.g., file search, terminal command, code edit).29*/30export class ChatDebugToolCallEvent {31/**32* A unique identifier for this event.33*/34id?: string;3536/**37* The chat session this event belongs to. When provided, the event38* is attributed to this session even if it arrives through a progress39* pipeline opened for a different session.40*/41sessionResource?: Uri;4243/**44* The timestamp when the event was created.45*/46created: Date;4748/**49* The id of a parent event, used to build a hierarchical tree50* (e.g., tool calls nested under a model turn).51*/52parentEventId?: string;5354/**55* The name of the tool that was called.56*/57toolName: string;5859/**60* An optional identifier for the tool call, as assigned by the model.61*/62toolCallId?: string;6364/**65* The serialized input (arguments) passed to the tool.66*/67input?: string;6869/**70* The serialized output (result) returned by the tool.71*/72output?: string;7374/**75* The outcome of the tool call.76*/77result?: ChatDebugToolCallResult;7879/**80* How long the tool call took to complete, in milliseconds.81*/82durationInMillis?: number;8384/**85* Create a new ChatDebugToolCallEvent.86* @param toolName The name of the tool that was called.87* @param created The timestamp when the event was created.88*/89constructor(toolName: string, created: Date);90}9192/**93* A model turn event in the chat debug log, representing a single94* request/response exchange with a language model.95*/96export class ChatDebugModelTurnEvent {97/**98* A unique identifier for this event.99*/100id?: string;101102/**103* The chat session this event belongs to. When provided, the event104* is attributed to this session even if it arrives through a progress105* pipeline opened for a different session.106*/107sessionResource?: Uri;108109/**110* The timestamp when the event was created.111*/112created: Date;113114/**115* The id of a parent event, used to build a hierarchical tree.116*/117parentEventId?: string;118119/**120* The identifier of the model used (e.g., "gpt-4o").121*/122model?: string;123124/**125* The number of tokens in the input/prompt.126*/127inputTokens?: number;128129/**130* The number of tokens in the model's output/completion.131*/132outputTokens?: number;133134/**135* The total number of tokens consumed (input + output).136*/137totalTokens?: number;138139/**140* How long the model turn took to complete, in milliseconds.141*/142durationInMillis?: number;143144/**145* The number of cached input tokens reused from a previous request.146*/147cachedTokens?: number;148149/**150* The time in milliseconds from sending the request to receiving the151* first response token.152*/153timeToFirstTokenInMillis?: number;154155/**156* The maximum number of prompt/input tokens allowed for this request.157*/158maxInputTokens?: number;159160/**161* The maximum number of response/output tokens allowed for this request.162*/163maxOutputTokens?: number;164165/**166* The short name or label identifying this request (e.g., "panel/editAgent").167*/168requestName?: string;169170/**171* The outcome status of the model turn (e.g., "success", "failure", "canceled").172*/173status?: string;174175/**176* Create a new ChatDebugModelTurnEvent.177* @param created The timestamp when the event was created.178*/179constructor(created: Date);180}181182/**183* A generic log event in the chat debug log, for unstructured or184* miscellaneous messages that don't fit a more specific event type.185*/186export class ChatDebugGenericEvent {187/**188* A unique identifier for this event.189*/190id?: string;191192/**193* The chat session this event belongs to. When provided, the event194* is attributed to this session even if it arrives through a progress195* pipeline opened for a different session.196*/197sessionResource?: Uri;198199/**200* The timestamp when the event was created.201*/202created: Date;203204/**205* The id of a parent event, used to build a hierarchical tree.206*/207parentEventId?: string;208209/**210* A short name describing the event (e.g., "Resolved skills (start)").211*/212name: string;213214/**215* Optional details of the event.216*/217details?: string;218219/**220* The severity level of the event.221*/222level: ChatDebugLogLevel;223224/**225* The category classifying the kind of event.226*/227category?: string;228229/**230* Create a new ChatDebugGenericEvent.231* @param name A short name describing the event.232* @param level The severity level.233* @param created The timestamp when the event was created.234*/235constructor(name: string, level: ChatDebugLogLevel, created: Date);236}237238/**239* The status of a sub-agent invocation.240*/241export enum ChatDebugSubagentStatus {242Running = 0,243Completed = 1,244Failed = 2245}246247/**248* A subagent invocation event in the chat debug log, representing249* a spawned sub-agent within a chat session.250*/251export class ChatDebugSubagentInvocationEvent {252/**253* A unique identifier for this event.254*/255id?: string;256257/**258* The chat session this event belongs to. When provided, the event259* is attributed to this session even if it arrives through a progress260* pipeline opened for a different session.261*/262sessionResource?: Uri;263264/**265* The timestamp when the event was created.266*/267created: Date;268269/**270* The id of a parent event, used to build a hierarchical tree.271*/272parentEventId?: string;273274/**275* The name of the sub-agent that was invoked.276*/277agentName: string;278279/**280* A short description of the task assigned to the sub-agent.281*/282description?: string;283284/**285* The current status of the sub-agent invocation.286*/287status?: ChatDebugSubagentStatus;288289/**290* How long the sub-agent took to complete, in milliseconds.291*/292durationInMillis?: number;293294/**295* The number of tool calls made by this sub-agent.296*/297toolCallCount?: number;298299/**300* The number of model turns within this sub-agent.301*/302modelTurnCount?: number;303304/**305* Create a new ChatDebugSubagentInvocationEvent.306* @param agentName The name of the sub-agent.307* @param created The timestamp when the event was created.308*/309constructor(agentName: string, created: Date);310}311312/**313* A user message event in the chat debug log, representing the prompt314* sent by the user (including system context, instructions, etc.).315*/316export class ChatDebugUserMessageEvent {317/**318* A unique identifier for this event.319*/320id?: string;321322/**323* The chat session this event belongs to. When provided, the event324* is attributed to this session even if it arrives through a progress325* pipeline opened for a different session.326*/327sessionResource?: Uri;328329/**330* The timestamp when the event was created.331*/332created: Date;333334/**335* The id of a parent event, used to build a hierarchical tree.336*/337parentEventId?: string;338339/**340* A short summary of the user's request for display in the event list.341*/342message: string;343344/**345* The structured sections of the full prompt (e.g., userRequest, context,346* reminderInstructions). Rendered as collapsible sections in the detail view.347*/348sections: ChatDebugMessageSection[];349350/**351* Create a new ChatDebugUserMessageEvent.352* @param message A short summary of the user's request.353* @param created The timestamp when the event was created.354*/355constructor(message: string, created: Date);356}357358/**359* An agent response event in the chat debug log, representing the360* response produced by the agent (including reasoning, if available).361*/362export class ChatDebugAgentResponseEvent {363/**364* A unique identifier for this event.365*/366id?: string;367368/**369* The chat session this event belongs to. When provided, the event370* is attributed to this session even if it arrives through a progress371* pipeline opened for a different session.372*/373sessionResource?: Uri;374375/**376* The timestamp when the event was created.377*/378created: Date;379380/**381* The id of a parent event, used to build a hierarchical tree.382*/383parentEventId?: string;384385/**386* A short summary of the agent's response for display in the event list.387*/388message: string;389390/**391* The structured sections of the response (e.g., response text, reasoning).392* Rendered as collapsible sections in the detail view.393*/394sections: ChatDebugMessageSection[];395396/**397* Create a new ChatDebugAgentResponseEvent.398* @param message A short summary of the agent's response.399* @param created The timestamp when the event was created.400*/401constructor(message: string, created: Date);402}403404/**405* A named section within a user message or agent response,406* used to display collapsible parts of the prompt or response.407*/408export class ChatDebugMessageSection {409/**410* The display name of the section (e.g., "User Request", "Context", "Reasoning").411*/412name: string;413414/**415* The text content of the section.416*/417content: string;418419/**420* Create a new ChatDebugMessageSection.421* @param name The display name of the section.422* @param content The text content.423*/424constructor(name: string, content: string);425}426427/**428* Plain text content for a resolved chat debug event.429*/430export class ChatDebugEventTextContent {431/**432* The text value.433*/434value: string;435436/**437* Create a new ChatDebugEventTextContent.438* @param value The text value.439*/440constructor(value: string);441}442443/**444* The type of a debug message content.445*/446export enum ChatDebugMessageContentType {447User = 0,448Agent = 1449}450451/**452* Structured message content for a resolved chat debug event,453* containing collapsible sections (e.g., prompt parts or response parts).454*/455export class ChatDebugEventMessageContent {456/**457* The type of message.458*/459type: ChatDebugMessageContentType;460461/**462* A short summary of the message.463*/464message: string;465466/**467* The structured sections of the message.468*/469sections: ChatDebugMessageSection[];470471/**472* Create a new ChatDebugEventMessageContent.473* @param type The type of message.474* @param message A short summary.475* @param sections The structured sections.476*/477constructor(type: ChatDebugMessageContentType, message: string, sections: ChatDebugMessageSection[]);478}479480/**481* Structured tool call content for a resolved chat debug event,482* containing the tool name, status, arguments, and output for rich rendering.483*/484export class ChatDebugEventToolCallContent {485/**486* The name of the tool that was called.487*/488toolName: string;489490/**491* The outcome of the tool call (e.g., "success" or "error").492*/493result?: ChatDebugToolCallResult;494495/**496* How long the tool call took to complete, in milliseconds.497*/498durationInMillis?: number;499500/**501* The serialized input (arguments) passed to the tool.502*/503input?: string;504505/**506* The serialized output (result) returned by the tool.507*/508output?: string;509510/**511* Create a new ChatDebugEventToolCallContent.512* @param toolName The name of the tool that was called.513*/514constructor(toolName: string);515}516517/**518* Structured model turn content for a resolved chat debug event,519* containing request metadata, token usage, and timing for rich rendering.520*/521export class ChatDebugEventModelTurnContent {522/**523* The short name or label identifying this request (e.g., "panel/editAgent").524*/525requestName: string;526527/**528* The identifier of the model used (e.g., "claude-sonnet-4.5").529*/530model?: string;531532/**533* The outcome status of the model turn (e.g., "success", "failure", "canceled").534*/535status?: string;536537/**538* How long the model turn took to complete, in milliseconds.539*/540durationInMillis?: number;541542/**543* The time in milliseconds from sending the request to receiving the544* first response token.545*/546timeToFirstTokenInMillis?: number;547548/**549* The maximum number of prompt/input tokens allowed for this request.550*/551maxInputTokens?: number;552553/**554* The maximum number of response/output tokens allowed for this request.555*/556maxOutputTokens?: number;557558/**559* The number of tokens in the input/prompt.560*/561inputTokens?: number;562563/**564* The number of tokens in the model's output/completion.565*/566outputTokens?: number;567568/**569* The number of cached input tokens reused from a previous request.570*/571cachedTokens?: number;572573/**574* The total number of tokens consumed (input + output).575*/576totalTokens?: number;577578/**579* An error message, if the model turn failed.580*/581errorMessage?: string;582583/**584* Optional structured sections containing the full request/response details585* (e.g., system prompt, user prompt, tools, response).586* Rendered as collapsible sections in the detail view alongside the metadata.587*/588sections?: ChatDebugMessageSection[];589590/**591* Create a new ChatDebugEventModelTurnContent.592* @param requestName The short name identifying this request.593*/594constructor(requestName: string);595}596597/**598* Structured hook execution content for a resolved chat debug event,599* containing the hook type, command, input, output, and result for rich rendering.600*/601export class ChatDebugEventHookContent {602/**603* The type of hook that was executed (e.g., "PreToolUse", "PostToolUse", "Stop").604*/605hookType: string;606607/**608* The shell command that was executed.609*/610command?: string;611612/**613* The outcome of the hook execution.614*/615result?: ChatDebugHookResult;616617/**618* How long the hook took to complete, in milliseconds.619*/620durationInMillis?: number;621622/**623* The serialized JSON input passed to the hook via stdin.624*/625input?: string;626627/**628* The serialized output (stdout/stderr) returned by the hook.629*/630output?: string;631632/**633* An error message, if the hook failed.634*/635errorMessage?: string;636637/**638* The raw exit code from the hook process, if it failed.639*/640exitCode?: number;641642/**643* Create a new ChatDebugEventHookContent.644* @param hookType The type of hook that was executed.645*/646constructor(hookType: string);647}648649/**650* The result of a hook execution.651*/652export enum ChatDebugHookResult {653/** The hook executed successfully (exit code 0). */654Success = 0,655/** The hook returned a blocking error (exit code 2). */656Error = 1,657/** The hook returned a non-blocking warning (other non-zero exit codes). */658NonBlockingError = 2659}660661/**662* Union of all resolved event content types.663* Extensions may also return {@link ChatDebugUserMessageEvent} or664* {@link ChatDebugAgentResponseEvent} from resolve, which will be665* automatically converted to structured message content.666*/667export type ChatDebugResolvedEventContent = ChatDebugEventTextContent | ChatDebugEventMessageContent | ChatDebugEventToolCallContent | ChatDebugEventModelTurnContent | ChatDebugEventHookContent | ChatDebugUserMessageEvent | ChatDebugAgentResponseEvent;668669/**670* Union of all chat debug event types. Each type is a class,671* following the same pattern as {@link ChatResponsePart}.672*/673export type ChatDebugEvent = ChatDebugToolCallEvent | ChatDebugModelTurnEvent | ChatDebugGenericEvent | ChatDebugSubagentInvocationEvent | ChatDebugUserMessageEvent | ChatDebugAgentResponseEvent;674675/**676* A provider that supplies debug events for a chat session.677*/678export interface ChatDebugLogProvider {679/**680* Called when the debug view is opened for a chat session.681* The provider should return initial events and can use682* the progress callback to stream additional events over time.683*684* @param sessionResource The resource URI of the chat session being debugged.685* @param progress A progress callback to stream events.686* @param token A cancellation token.687* @returns Initial events, if any.688*/689provideChatDebugLog(690sessionResource: Uri,691progress: Progress<ChatDebugEvent>,692token: CancellationToken693): ProviderResult<ChatDebugEvent[]>;694695/**696* Optionally resolve the full contents of a debug event by its id.697* Called when the user expands an event in the debug view, allowing698* the provider to defer expensive detail loading until needed.699*700* @param eventId The id of the event to resolve.701* @param token A cancellation token.702* @returns The resolved event content to be displayed in the debug detail view.703*/704resolveChatDebugLogEvent?(705eventId: string,706token: CancellationToken707): ProviderResult<ChatDebugResolvedEventContent>;708709/**710* Export the debug log for a chat session as a serialized byte array.711* The extension controls the format (e.g., OTLP JSON with Copilot extensions).712* Core provides the save dialog and writes the returned bytes to disk.713*714* @param sessionResource The resource URI of the chat session to export.715* @param options Export options including core events and session metadata.716* @param token A cancellation token.717* @returns The serialized debug log data, or undefined if export is not available.718*/719provideChatDebugLogExport?(720sessionResource: Uri,721options: ChatDebugLogExportOptions,722token: CancellationToken723): ProviderResult<Uint8Array>;724725/**726* Import a previously exported debug log from a serialized byte array.727* Core provides the open dialog and reads the file bytes.728* The extension deserializes the data and returns a session URI that can be729* opened in the debug panel via {@link provideChatDebugLog}.730*731* @param data The serialized debug log data (as returned by {@link provideChatDebugLogExport}).732* @param token A cancellation token.733* @returns The imported session info, or undefined if import failed.734*/735resolveChatDebugLogImport?(736data: Uint8Array,737token: CancellationToken738): ProviderResult<ChatDebugLogImportResult>;739740/**741* Return session resource URIs that have debug log data available,742* including historical sessions persisted on disk.743*744* @param token A cancellation token.745* @returns Session URIs with available debug data and optional titles.746*/747provideAvailableDebugSessionResources?(748token: CancellationToken749): ProviderResult<{ uri: Uri; title?: string }[]>;750}751752export namespace chat {753/**754* Register a provider that supplies debug events for chat sessions.755* Only one provider can be registered at a time.756*757* @param provider The chat debug log provider.758* @returns A disposable that unregisters the provider.759*/760export function registerChatDebugLogProvider(provider: ChatDebugLogProvider): Disposable;761762/**763* Fired when a core-originated debug event is received (e.g., prompt discovery,764* skill loading). Extensions can use this to capture events that originate765* inside Core.766*/767export const onDidReceiveChatDebugEvent: Event<ChatDebugEvent>;768}769770/**771* Options passed to {@link ChatDebugLogProvider.provideChatDebugLogExport}.772*/773export interface ChatDebugLogExportOptions {774/**775* Core-originated debug events (prompt discovery, skill loading, etc.)776* for the session. The extension may include these in the export alongside its own data.777*/778readonly coreEvents: readonly ChatDebugEvent[];779780/**781* Session title, if available.782* Used to provide a human-readable label in the exported file.783*/784readonly sessionTitle?: string;785}786787/**788* Result of importing a debug log via {@link ChatDebugLogProvider.resolveChatDebugLogImport}.789*/790export interface ChatDebugLogImportResult {791/**792* The session resource URI for the imported session.793*/794readonly uri: Uri;795796/**797* The session title from the imported file, if available.798*/799readonly sessionTitle?: string;800}801}802803804