Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vscode-dts/vscode.proposed.chatOutputRenderer.d.ts
5262 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
declare module 'vscode' {
7
8
/**
9
* Data returned from a tool.
10
*
11
* This is an opaque binary blob that can be rendered by a {@link ChatOutputRenderer}.
12
*/
13
export interface ToolResultDataOutput {
14
/**
15
* The MIME type of the data.
16
*/
17
mime: string;
18
19
/**
20
* The contents of the data.
21
*/
22
value: Uint8Array;
23
}
24
25
export interface ExtendedLanguageModelToolResult2 extends ExtendedLanguageModelToolResult {
26
// Temporary to allow `toolResultDetails` to return a ToolResultDataOutput
27
// TODO: Should this live here? Or should we be able to mark each `content` items as user/lm specific?
28
// TODO: Should we allow multiple per tool result?
29
toolResultDetails2?: Array<Uri | Location> | ToolResultDataOutput;
30
}
31
32
/**
33
* The data to be rendered by a {@link ChatOutputRenderer}.
34
*/
35
export interface ChatOutputDataItem {
36
/**
37
* The MIME type of the data.
38
*/
39
readonly mime: string;
40
41
/**
42
* The contents of the data.
43
*/
44
readonly value: Uint8Array;
45
}
46
47
/**
48
* A webview used to render chat output.
49
*/
50
export interface ChatOutputWebview {
51
/**
52
* The webview to render content into.
53
*/
54
readonly webview: Webview;
55
56
/**
57
* Fired when the webview is disposed.
58
*/
59
readonly onDidDispose: Event<void>;
60
}
61
62
export interface ChatOutputRenderer {
63
/**
64
* Given an output, render it into the provided webview.
65
*
66
* TODO: Figure out what to pass as context? Probably at least basic info such as chat location.
67
*
68
* @param data The data to render.
69
* @param webview The webview to render the data into.
70
* @param token A cancellation token that is cancelled if we no longer care about the rendering before this
71
* call completes.
72
*
73
* @returns A promise that resolves when the webview has been initialized and is ready to be presented to the user.
74
*/
75
renderChatOutput(data: ChatOutputDataItem, webview: ChatOutputWebview, ctx: {}, token: CancellationToken): Thenable<void>;
76
}
77
78
export namespace chat {
79
/**
80
* Registers a new renderer for a given mime type.
81
*
82
* Note: To use this API, you should also add a contribution point in your extension's
83
* package.json:
84
*
85
* ```json
86
* "contributes": {
87
* "chatOutputRenderer": [
88
* {
89
* "viewType": "myExt.myChatOutputRenderer",
90
* "mimeTypes": ["application/your-mime-type"]
91
* }
92
* ]
93
* }
94
* ```
95
*
96
* @param viewType Unique identifier for the renderer. This should match the `viewType` in your contribution point.
97
* @param renderer The renderer to register.
98
*/
99
export function registerChatOutputRenderer(viewType: string, renderer: ChatOutputRenderer): Disposable;
100
}
101
}
102
103