Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/workbench/contrib/chat/common/chatVariables.ts
3296 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
import { CancellationToken } from '../../../../base/common/cancellation.js';
7
import { ThemeIcon } from '../../../../base/common/themables.js';
8
import { URI } from '../../../../base/common/uri.js';
9
import { IRange } from '../../../../editor/common/core/range.js';
10
import { Location } from '../../../../editor/common/languages.js';
11
import { createDecorator } from '../../../../platform/instantiation/common/instantiation.js';
12
import { IChatModel } from './chatModel.js';
13
import { IChatContentReference, IChatProgressMessage } from './chatService.js';
14
import { IDiagnosticVariableEntryFilterData } from './chatVariableEntries.js';
15
import { IToolAndToolSetEnablementMap } from './languageModelToolsService.js';
16
17
export interface IChatVariableData {
18
id: string;
19
name: string;
20
icon?: ThemeIcon;
21
fullName?: string;
22
description: string;
23
modelDescription?: string;
24
canTakeArgument?: boolean;
25
}
26
27
export interface IChatRequestProblemsVariable {
28
id: 'vscode.problems';
29
filter: IDiagnosticVariableEntryFilterData;
30
}
31
32
export const isIChatRequestProblemsVariable = (obj: unknown): obj is IChatRequestProblemsVariable =>
33
typeof obj === 'object' && obj !== null && 'id' in obj && (obj as IChatRequestProblemsVariable).id === 'vscode.problems';
34
35
export type IChatRequestVariableValue = string | URI | Location | Uint8Array | IChatRequestProblemsVariable | unknown;
36
37
export type IChatVariableResolverProgress =
38
| IChatContentReference
39
| IChatProgressMessage;
40
41
export interface IChatVariableResolver {
42
(messageText: string, arg: string | undefined, model: IChatModel, progress: (part: IChatVariableResolverProgress) => void, token: CancellationToken): Promise<IChatRequestVariableValue | undefined>;
43
}
44
45
export const IChatVariablesService = createDecorator<IChatVariablesService>('IChatVariablesService');
46
47
export interface IChatVariablesService {
48
_serviceBrand: undefined;
49
getDynamicVariables(sessionId: string): ReadonlyArray<IDynamicVariable>;
50
getSelectedToolAndToolSets(sessionId: string): IToolAndToolSetEnablementMap;
51
}
52
53
export interface IDynamicVariable {
54
range: IRange;
55
id: string;
56
fullName?: string;
57
icon?: ThemeIcon;
58
modelDescription?: string;
59
isFile?: boolean;
60
isDirectory?: boolean;
61
data: IChatRequestVariableValue;
62
}
63
64