Elffuss BraidHub

kikocis/continue public

beec9aab9cdf · 1.5 KiBRawPermalink
1import { ToolCallState } from "core";
2import { BuiltInToolNames } from "core/tools/builtIn";
3import { CreateFile } from "./CreateFile";
4import { EditFile } from "./EditFile";
5import { RunTerminalCommand } from "./RunTerminalCommand";
6
7function FunctionSpecificToolCallDiv({
8 toolCallState,
9 historyIndex,
10}: {
11 toolCallState: ToolCallState;
12 historyIndex: number;
13}) {
14 const args = toolCallState.parsedArgs;
15 const toolCall = toolCallState.toolCall;
16
17 switch (toolCall.function?.name) {
18 case BuiltInToolNames.CreateNewFile:
19 return (
20 <CreateFile
21 relativeFilepath={args.filepath}
22 fileContents={args.contents}
23 historyIndex={historyIndex}
24 />
25 );
26 case BuiltInToolNames.EditExistingFile:
27 return (
28 <EditFile
29 relativeFilePath={args.filepath ?? ""}
30 changes={args.changes ?? ""}
31 toolCallId={toolCall.id}
32 historyIndex={historyIndex}
33 />
34 );
35 case BuiltInToolNames.SearchAndReplaceInFile:
36 return (
37 <EditFile
38 relativeFilePath={args.filepath ?? ""}
39 changes={args.diffs ? args.diffs.join("\n\n---\n\n") : ""}
40 toolCallId={toolCall.id}
41 historyIndex={historyIndex}
42 />
43 );
44 case BuiltInToolNames.RunTerminalCommand:
45 return (
46 <RunTerminalCommand
47 command={args.command}
48 toolCallState={toolCallState}
49 toolCallId={toolCall.id}
50 />
51 );
52 default:
53 return null;
54 }
55}
56
57export default FunctionSpecificToolCallDiv;