Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/workbench/contrib/chat/common/chat.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 type { IChatTerminalToolInvocationData, ILegacyChatTerminalToolInvocationData } from './chatService.js';
7
import { ChatModeKind } from './constants.js';
8
9
export function checkModeOption(mode: ChatModeKind, option: boolean | ((mode: ChatModeKind) => boolean) | undefined): boolean | undefined {
10
if (option === undefined) {
11
return undefined;
12
}
13
if (typeof option === 'function') {
14
return option(mode);
15
}
16
return option;
17
}
18
19
/**
20
* @deprecated This is the old API shape, we should support this for a while before removing it so
21
* we don't break existing chats
22
*/
23
export function migrateLegacyTerminalToolSpecificData(data: IChatTerminalToolInvocationData | ILegacyChatTerminalToolInvocationData): IChatTerminalToolInvocationData {
24
if ('command' in data) {
25
data = {
26
kind: 'terminal',
27
commandLine: {
28
original: data.command,
29
toolEdited: undefined,
30
userEdited: undefined
31
},
32
language: data.language
33
} satisfies IChatTerminalToolInvocationData;
34
}
35
return data;
36
}
37
38