-
Notifications
You must be signed in to change notification settings - Fork 39.7k
Expand file tree
/
Copy pathbuiltInToolGroupHandler.spec.ts
More file actions
43 lines (38 loc) · 1.84 KB
/
builtInToolGroupHandler.spec.ts
File metadata and controls
43 lines (38 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { describe, expect, it } from 'vitest';
import type { LanguageModelToolInformation } from 'vscode';
import { ToolName } from '../../../common/toolNames';
import { BuiltInToolGroupHandler } from '../../../common/virtualTools/builtInToolGroupHandler';
import { VirtualTool, VIRTUAL_TOOL_NAME_PREFIX } from '../../../common/virtualTools/virtualTool';
function makeTool(name: string): LanguageModelToolInformation {
return {
name,
description: `Tool for ${name}`,
inputSchema: undefined,
source: undefined,
tags: [],
};
}
describe('BuiltInToolGroupHandler', () => {
it('keeps memory available as an individual core tool', () => {
const handler = new BuiltInToolGroupHandler();
const tools = [
makeTool(ToolName.Memory),
makeTool(ToolName.InstallExtension),
makeTool(ToolName.RunVscodeCmd),
makeTool(ToolName.ReadFile),
];
const result = handler.createBuiltInToolGroups(tools);
const groupedVsCodeInteraction = result.find((tool): tool is VirtualTool => tool instanceof VirtualTool && tool.name === `${VIRTUAL_TOOL_NAME_PREFIX}vs_code_interaction`);
expect(groupedVsCodeInteraction).toBeDefined();
expect(groupedVsCodeInteraction?.contents.map(tool => tool.name)).toEqual([
ToolName.InstallExtension,
ToolName.RunVscodeCmd,
]);
expect(result.some((tool): boolean => !(tool instanceof VirtualTool) && tool.name === ToolName.Memory)).toBe(true);
expect(result.some((tool): boolean => !(tool instanceof VirtualTool) && tool.name === ToolName.ReadFile)).toBe(true);
});
});