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