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
3290 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
export interface ChatOutputRenderer {
48
/**
49
* Given an output, render it into the provided webview.
50
*
51
* TODO: Figure out what to pass as context? Probably at least basic info such as chat location.
52
*
53
* @param data The data to render.
54
* @param webview The webview to render the data into.
55
* @param token A cancellation token that is cancelled if we no longer care about the rendering before this
56
* call completes.
57
*
58
* @returns A promise that resolves when the webview has been initialized and is ready to be presented to the user.
59
*/
60
renderChatOutput(data: ChatOutputDataItem, webview: Webview, ctx: {}, token: CancellationToken): Thenable<void>;
61
}
62
63
export namespace chat {
64
/**
65
* Registers a new renderer for a given mime type.
66
*
67
* Note: To use this API, you should also add a contribution point in your extension's
68
* package.json:
69
*
70
* ```json
71
* "contributes": {
72
* "chatOutputRenderer": [
73
* {
74
* "viewType": "myExt.myChatOutputRenderer",
75
* "mimeTypes": ["application/your-mime-type"]
76
* }
77
* ]
78
* }
79
* ```
80
*
81
* @param viewType Unique identifier for the renderer. This should match the `viewType` in your contribution point.
82
* @param renderer The renderer to register.
83
*/
84
export function registerChatOutputRenderer(viewType: string, renderer: ChatOutputRenderer): Disposable;
85
}
86
}
87
88