Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vscode-dts/vscode.proposed.chatDebug.d.ts
13379 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
// version: 4
7
8
declare module 'vscode' {
9
/**
10
* The severity level of a chat debug log event.
11
*/
12
export enum ChatDebugLogLevel {
13
Trace = 0,
14
Info = 1,
15
Warning = 2,
16
Error = 3
17
}
18
19
/**
20
* The outcome of a tool call.
21
*/
22
export enum ChatDebugToolCallResult {
23
Success = 0,
24
Error = 1
25
}
26
27
/**
28
* A tool call event in the chat debug log, representing the invocation
29
* of a tool (e.g., file search, terminal command, code edit).
30
*/
31
export class ChatDebugToolCallEvent {
32
/**
33
* A unique identifier for this event.
34
*/
35
id?: string;
36
37
/**
38
* The chat session this event belongs to. When provided, the event
39
* is attributed to this session even if it arrives through a progress
40
* pipeline opened for a different session.
41
*/
42
sessionResource?: Uri;
43
44
/**
45
* The timestamp when the event was created.
46
*/
47
created: Date;
48
49
/**
50
* The id of a parent event, used to build a hierarchical tree
51
* (e.g., tool calls nested under a model turn).
52
*/
53
parentEventId?: string;
54
55
/**
56
* The name of the tool that was called.
57
*/
58
toolName: string;
59
60
/**
61
* An optional identifier for the tool call, as assigned by the model.
62
*/
63
toolCallId?: string;
64
65
/**
66
* The serialized input (arguments) passed to the tool.
67
*/
68
input?: string;
69
70
/**
71
* The serialized output (result) returned by the tool.
72
*/
73
output?: string;
74
75
/**
76
* The outcome of the tool call.
77
*/
78
result?: ChatDebugToolCallResult;
79
80
/**
81
* How long the tool call took to complete, in milliseconds.
82
*/
83
durationInMillis?: number;
84
85
/**
86
* Create a new ChatDebugToolCallEvent.
87
* @param toolName The name of the tool that was called.
88
* @param created The timestamp when the event was created.
89
*/
90
constructor(toolName: string, created: Date);
91
}
92
93
/**
94
* A model turn event in the chat debug log, representing a single
95
* request/response exchange with a language model.
96
*/
97
export class ChatDebugModelTurnEvent {
98
/**
99
* A unique identifier for this event.
100
*/
101
id?: string;
102
103
/**
104
* The chat session this event belongs to. When provided, the event
105
* is attributed to this session even if it arrives through a progress
106
* pipeline opened for a different session.
107
*/
108
sessionResource?: Uri;
109
110
/**
111
* The timestamp when the event was created.
112
*/
113
created: Date;
114
115
/**
116
* The id of a parent event, used to build a hierarchical tree.
117
*/
118
parentEventId?: string;
119
120
/**
121
* The identifier of the model used (e.g., "gpt-4o").
122
*/
123
model?: string;
124
125
/**
126
* The number of tokens in the input/prompt.
127
*/
128
inputTokens?: number;
129
130
/**
131
* The number of tokens in the model's output/completion.
132
*/
133
outputTokens?: number;
134
135
/**
136
* The total number of tokens consumed (input + output).
137
*/
138
totalTokens?: number;
139
140
/**
141
* How long the model turn took to complete, in milliseconds.
142
*/
143
durationInMillis?: number;
144
145
/**
146
* The number of cached input tokens reused from a previous request.
147
*/
148
cachedTokens?: number;
149
150
/**
151
* The time in milliseconds from sending the request to receiving the
152
* first response token.
153
*/
154
timeToFirstTokenInMillis?: number;
155
156
/**
157
* The maximum number of prompt/input tokens allowed for this request.
158
*/
159
maxInputTokens?: number;
160
161
/**
162
* The maximum number of response/output tokens allowed for this request.
163
*/
164
maxOutputTokens?: number;
165
166
/**
167
* The short name or label identifying this request (e.g., "panel/editAgent").
168
*/
169
requestName?: string;
170
171
/**
172
* The outcome status of the model turn (e.g., "success", "failure", "canceled").
173
*/
174
status?: string;
175
176
/**
177
* Create a new ChatDebugModelTurnEvent.
178
* @param created The timestamp when the event was created.
179
*/
180
constructor(created: Date);
181
}
182
183
/**
184
* A generic log event in the chat debug log, for unstructured or
185
* miscellaneous messages that don't fit a more specific event type.
186
*/
187
export class ChatDebugGenericEvent {
188
/**
189
* A unique identifier for this event.
190
*/
191
id?: string;
192
193
/**
194
* The chat session this event belongs to. When provided, the event
195
* is attributed to this session even if it arrives through a progress
196
* pipeline opened for a different session.
197
*/
198
sessionResource?: Uri;
199
200
/**
201
* The timestamp when the event was created.
202
*/
203
created: Date;
204
205
/**
206
* The id of a parent event, used to build a hierarchical tree.
207
*/
208
parentEventId?: string;
209
210
/**
211
* A short name describing the event (e.g., "Resolved skills (start)").
212
*/
213
name: string;
214
215
/**
216
* Optional details of the event.
217
*/
218
details?: string;
219
220
/**
221
* The severity level of the event.
222
*/
223
level: ChatDebugLogLevel;
224
225
/**
226
* The category classifying the kind of event.
227
*/
228
category?: string;
229
230
/**
231
* Create a new ChatDebugGenericEvent.
232
* @param name A short name describing the event.
233
* @param level The severity level.
234
* @param created The timestamp when the event was created.
235
*/
236
constructor(name: string, level: ChatDebugLogLevel, created: Date);
237
}
238
239
/**
240
* The status of a sub-agent invocation.
241
*/
242
export enum ChatDebugSubagentStatus {
243
Running = 0,
244
Completed = 1,
245
Failed = 2
246
}
247
248
/**
249
* A subagent invocation event in the chat debug log, representing
250
* a spawned sub-agent within a chat session.
251
*/
252
export class ChatDebugSubagentInvocationEvent {
253
/**
254
* A unique identifier for this event.
255
*/
256
id?: string;
257
258
/**
259
* The chat session this event belongs to. When provided, the event
260
* is attributed to this session even if it arrives through a progress
261
* pipeline opened for a different session.
262
*/
263
sessionResource?: Uri;
264
265
/**
266
* The timestamp when the event was created.
267
*/
268
created: Date;
269
270
/**
271
* The id of a parent event, used to build a hierarchical tree.
272
*/
273
parentEventId?: string;
274
275
/**
276
* The name of the sub-agent that was invoked.
277
*/
278
agentName: string;
279
280
/**
281
* A short description of the task assigned to the sub-agent.
282
*/
283
description?: string;
284
285
/**
286
* The current status of the sub-agent invocation.
287
*/
288
status?: ChatDebugSubagentStatus;
289
290
/**
291
* How long the sub-agent took to complete, in milliseconds.
292
*/
293
durationInMillis?: number;
294
295
/**
296
* The number of tool calls made by this sub-agent.
297
*/
298
toolCallCount?: number;
299
300
/**
301
* The number of model turns within this sub-agent.
302
*/
303
modelTurnCount?: number;
304
305
/**
306
* Create a new ChatDebugSubagentInvocationEvent.
307
* @param agentName The name of the sub-agent.
308
* @param created The timestamp when the event was created.
309
*/
310
constructor(agentName: string, created: Date);
311
}
312
313
/**
314
* A user message event in the chat debug log, representing the prompt
315
* sent by the user (including system context, instructions, etc.).
316
*/
317
export class ChatDebugUserMessageEvent {
318
/**
319
* A unique identifier for this event.
320
*/
321
id?: string;
322
323
/**
324
* The chat session this event belongs to. When provided, the event
325
* is attributed to this session even if it arrives through a progress
326
* pipeline opened for a different session.
327
*/
328
sessionResource?: Uri;
329
330
/**
331
* The timestamp when the event was created.
332
*/
333
created: Date;
334
335
/**
336
* The id of a parent event, used to build a hierarchical tree.
337
*/
338
parentEventId?: string;
339
340
/**
341
* A short summary of the user's request for display in the event list.
342
*/
343
message: string;
344
345
/**
346
* The structured sections of the full prompt (e.g., userRequest, context,
347
* reminderInstructions). Rendered as collapsible sections in the detail view.
348
*/
349
sections: ChatDebugMessageSection[];
350
351
/**
352
* Create a new ChatDebugUserMessageEvent.
353
* @param message A short summary of the user's request.
354
* @param created The timestamp when the event was created.
355
*/
356
constructor(message: string, created: Date);
357
}
358
359
/**
360
* An agent response event in the chat debug log, representing the
361
* response produced by the agent (including reasoning, if available).
362
*/
363
export class ChatDebugAgentResponseEvent {
364
/**
365
* A unique identifier for this event.
366
*/
367
id?: string;
368
369
/**
370
* The chat session this event belongs to. When provided, the event
371
* is attributed to this session even if it arrives through a progress
372
* pipeline opened for a different session.
373
*/
374
sessionResource?: Uri;
375
376
/**
377
* The timestamp when the event was created.
378
*/
379
created: Date;
380
381
/**
382
* The id of a parent event, used to build a hierarchical tree.
383
*/
384
parentEventId?: string;
385
386
/**
387
* A short summary of the agent's response for display in the event list.
388
*/
389
message: string;
390
391
/**
392
* The structured sections of the response (e.g., response text, reasoning).
393
* Rendered as collapsible sections in the detail view.
394
*/
395
sections: ChatDebugMessageSection[];
396
397
/**
398
* Create a new ChatDebugAgentResponseEvent.
399
* @param message A short summary of the agent's response.
400
* @param created The timestamp when the event was created.
401
*/
402
constructor(message: string, created: Date);
403
}
404
405
/**
406
* A named section within a user message or agent response,
407
* used to display collapsible parts of the prompt or response.
408
*/
409
export class ChatDebugMessageSection {
410
/**
411
* The display name of the section (e.g., "User Request", "Context", "Reasoning").
412
*/
413
name: string;
414
415
/**
416
* The text content of the section.
417
*/
418
content: string;
419
420
/**
421
* Create a new ChatDebugMessageSection.
422
* @param name The display name of the section.
423
* @param content The text content.
424
*/
425
constructor(name: string, content: string);
426
}
427
428
/**
429
* Plain text content for a resolved chat debug event.
430
*/
431
export class ChatDebugEventTextContent {
432
/**
433
* The text value.
434
*/
435
value: string;
436
437
/**
438
* Create a new ChatDebugEventTextContent.
439
* @param value The text value.
440
*/
441
constructor(value: string);
442
}
443
444
/**
445
* The type of a debug message content.
446
*/
447
export enum ChatDebugMessageContentType {
448
User = 0,
449
Agent = 1
450
}
451
452
/**
453
* Structured message content for a resolved chat debug event,
454
* containing collapsible sections (e.g., prompt parts or response parts).
455
*/
456
export class ChatDebugEventMessageContent {
457
/**
458
* The type of message.
459
*/
460
type: ChatDebugMessageContentType;
461
462
/**
463
* A short summary of the message.
464
*/
465
message: string;
466
467
/**
468
* The structured sections of the message.
469
*/
470
sections: ChatDebugMessageSection[];
471
472
/**
473
* Create a new ChatDebugEventMessageContent.
474
* @param type The type of message.
475
* @param message A short summary.
476
* @param sections The structured sections.
477
*/
478
constructor(type: ChatDebugMessageContentType, message: string, sections: ChatDebugMessageSection[]);
479
}
480
481
/**
482
* Structured tool call content for a resolved chat debug event,
483
* containing the tool name, status, arguments, and output for rich rendering.
484
*/
485
export class ChatDebugEventToolCallContent {
486
/**
487
* The name of the tool that was called.
488
*/
489
toolName: string;
490
491
/**
492
* The outcome of the tool call (e.g., "success" or "error").
493
*/
494
result?: ChatDebugToolCallResult;
495
496
/**
497
* How long the tool call took to complete, in milliseconds.
498
*/
499
durationInMillis?: number;
500
501
/**
502
* The serialized input (arguments) passed to the tool.
503
*/
504
input?: string;
505
506
/**
507
* The serialized output (result) returned by the tool.
508
*/
509
output?: string;
510
511
/**
512
* Create a new ChatDebugEventToolCallContent.
513
* @param toolName The name of the tool that was called.
514
*/
515
constructor(toolName: string);
516
}
517
518
/**
519
* Structured model turn content for a resolved chat debug event,
520
* containing request metadata, token usage, and timing for rich rendering.
521
*/
522
export class ChatDebugEventModelTurnContent {
523
/**
524
* The short name or label identifying this request (e.g., "panel/editAgent").
525
*/
526
requestName: string;
527
528
/**
529
* The identifier of the model used (e.g., "claude-sonnet-4.5").
530
*/
531
model?: string;
532
533
/**
534
* The outcome status of the model turn (e.g., "success", "failure", "canceled").
535
*/
536
status?: string;
537
538
/**
539
* How long the model turn took to complete, in milliseconds.
540
*/
541
durationInMillis?: number;
542
543
/**
544
* The time in milliseconds from sending the request to receiving the
545
* first response token.
546
*/
547
timeToFirstTokenInMillis?: number;
548
549
/**
550
* The maximum number of prompt/input tokens allowed for this request.
551
*/
552
maxInputTokens?: number;
553
554
/**
555
* The maximum number of response/output tokens allowed for this request.
556
*/
557
maxOutputTokens?: number;
558
559
/**
560
* The number of tokens in the input/prompt.
561
*/
562
inputTokens?: number;
563
564
/**
565
* The number of tokens in the model's output/completion.
566
*/
567
outputTokens?: number;
568
569
/**
570
* The number of cached input tokens reused from a previous request.
571
*/
572
cachedTokens?: number;
573
574
/**
575
* The total number of tokens consumed (input + output).
576
*/
577
totalTokens?: number;
578
579
/**
580
* An error message, if the model turn failed.
581
*/
582
errorMessage?: string;
583
584
/**
585
* Optional structured sections containing the full request/response details
586
* (e.g., system prompt, user prompt, tools, response).
587
* Rendered as collapsible sections in the detail view alongside the metadata.
588
*/
589
sections?: ChatDebugMessageSection[];
590
591
/**
592
* Create a new ChatDebugEventModelTurnContent.
593
* @param requestName The short name identifying this request.
594
*/
595
constructor(requestName: string);
596
}
597
598
/**
599
* Structured hook execution content for a resolved chat debug event,
600
* containing the hook type, command, input, output, and result for rich rendering.
601
*/
602
export class ChatDebugEventHookContent {
603
/**
604
* The type of hook that was executed (e.g., "PreToolUse", "PostToolUse", "Stop").
605
*/
606
hookType: string;
607
608
/**
609
* The shell command that was executed.
610
*/
611
command?: string;
612
613
/**
614
* The outcome of the hook execution.
615
*/
616
result?: ChatDebugHookResult;
617
618
/**
619
* How long the hook took to complete, in milliseconds.
620
*/
621
durationInMillis?: number;
622
623
/**
624
* The serialized JSON input passed to the hook via stdin.
625
*/
626
input?: string;
627
628
/**
629
* The serialized output (stdout/stderr) returned by the hook.
630
*/
631
output?: string;
632
633
/**
634
* An error message, if the hook failed.
635
*/
636
errorMessage?: string;
637
638
/**
639
* The raw exit code from the hook process, if it failed.
640
*/
641
exitCode?: number;
642
643
/**
644
* Create a new ChatDebugEventHookContent.
645
* @param hookType The type of hook that was executed.
646
*/
647
constructor(hookType: string);
648
}
649
650
/**
651
* The result of a hook execution.
652
*/
653
export enum ChatDebugHookResult {
654
/** The hook executed successfully (exit code 0). */
655
Success = 0,
656
/** The hook returned a blocking error (exit code 2). */
657
Error = 1,
658
/** The hook returned a non-blocking warning (other non-zero exit codes). */
659
NonBlockingError = 2
660
}
661
662
/**
663
* Union of all resolved event content types.
664
* Extensions may also return {@link ChatDebugUserMessageEvent} or
665
* {@link ChatDebugAgentResponseEvent} from resolve, which will be
666
* automatically converted to structured message content.
667
*/
668
export type ChatDebugResolvedEventContent = ChatDebugEventTextContent | ChatDebugEventMessageContent | ChatDebugEventToolCallContent | ChatDebugEventModelTurnContent | ChatDebugEventHookContent | ChatDebugUserMessageEvent | ChatDebugAgentResponseEvent;
669
670
/**
671
* Union of all chat debug event types. Each type is a class,
672
* following the same pattern as {@link ChatResponsePart}.
673
*/
674
export type ChatDebugEvent = ChatDebugToolCallEvent | ChatDebugModelTurnEvent | ChatDebugGenericEvent | ChatDebugSubagentInvocationEvent | ChatDebugUserMessageEvent | ChatDebugAgentResponseEvent;
675
676
/**
677
* A provider that supplies debug events for a chat session.
678
*/
679
export interface ChatDebugLogProvider {
680
/**
681
* Called when the debug view is opened for a chat session.
682
* The provider should return initial events and can use
683
* the progress callback to stream additional events over time.
684
*
685
* @param sessionResource The resource URI of the chat session being debugged.
686
* @param progress A progress callback to stream events.
687
* @param token A cancellation token.
688
* @returns Initial events, if any.
689
*/
690
provideChatDebugLog(
691
sessionResource: Uri,
692
progress: Progress<ChatDebugEvent>,
693
token: CancellationToken
694
): ProviderResult<ChatDebugEvent[]>;
695
696
/**
697
* Optionally resolve the full contents of a debug event by its id.
698
* Called when the user expands an event in the debug view, allowing
699
* the provider to defer expensive detail loading until needed.
700
*
701
* @param eventId The id of the event to resolve.
702
* @param token A cancellation token.
703
* @returns The resolved event content to be displayed in the debug detail view.
704
*/
705
resolveChatDebugLogEvent?(
706
eventId: string,
707
token: CancellationToken
708
): ProviderResult<ChatDebugResolvedEventContent>;
709
710
/**
711
* Export the debug log for a chat session as a serialized byte array.
712
* The extension controls the format (e.g., OTLP JSON with Copilot extensions).
713
* Core provides the save dialog and writes the returned bytes to disk.
714
*
715
* @param sessionResource The resource URI of the chat session to export.
716
* @param options Export options including core events and session metadata.
717
* @param token A cancellation token.
718
* @returns The serialized debug log data, or undefined if export is not available.
719
*/
720
provideChatDebugLogExport?(
721
sessionResource: Uri,
722
options: ChatDebugLogExportOptions,
723
token: CancellationToken
724
): ProviderResult<Uint8Array>;
725
726
/**
727
* Import a previously exported debug log from a serialized byte array.
728
* Core provides the open dialog and reads the file bytes.
729
* The extension deserializes the data and returns a session URI that can be
730
* opened in the debug panel via {@link provideChatDebugLog}.
731
*
732
* @param data The serialized debug log data (as returned by {@link provideChatDebugLogExport}).
733
* @param token A cancellation token.
734
* @returns The imported session info, or undefined if import failed.
735
*/
736
resolveChatDebugLogImport?(
737
data: Uint8Array,
738
token: CancellationToken
739
): ProviderResult<ChatDebugLogImportResult>;
740
741
/**
742
* Return session resource URIs that have debug log data available,
743
* including historical sessions persisted on disk.
744
*
745
* @param token A cancellation token.
746
* @returns Session URIs with available debug data and optional titles.
747
*/
748
provideAvailableDebugSessionResources?(
749
token: CancellationToken
750
): ProviderResult<{ uri: Uri; title?: string }[]>;
751
}
752
753
export namespace chat {
754
/**
755
* Register a provider that supplies debug events for chat sessions.
756
* Only one provider can be registered at a time.
757
*
758
* @param provider The chat debug log provider.
759
* @returns A disposable that unregisters the provider.
760
*/
761
export function registerChatDebugLogProvider(provider: ChatDebugLogProvider): Disposable;
762
763
/**
764
* Fired when a core-originated debug event is received (e.g., prompt discovery,
765
* skill loading). Extensions can use this to capture events that originate
766
* inside Core.
767
*/
768
export const onDidReceiveChatDebugEvent: Event<ChatDebugEvent>;
769
}
770
771
/**
772
* Options passed to {@link ChatDebugLogProvider.provideChatDebugLogExport}.
773
*/
774
export interface ChatDebugLogExportOptions {
775
/**
776
* Core-originated debug events (prompt discovery, skill loading, etc.)
777
* for the session. The extension may include these in the export alongside its own data.
778
*/
779
readonly coreEvents: readonly ChatDebugEvent[];
780
781
/**
782
* Session title, if available.
783
* Used to provide a human-readable label in the exported file.
784
*/
785
readonly sessionTitle?: string;
786
}
787
788
/**
789
* Result of importing a debug log via {@link ChatDebugLogProvider.resolveChatDebugLogImport}.
790
*/
791
export interface ChatDebugLogImportResult {
792
/**
793
* The session resource URI for the imported session.
794
*/
795
readonly uri: Uri;
796
797
/**
798
* The session title from the imported file, if available.
799
*/
800
readonly sessionTitle?: string;
801
}
802
}
803
804