Elffuss BraidHub

kikocis/continue public

8d79223bfeb8 · 1.7 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 const changes = args.diffs
37 ? Array.isArray(args.diffs)
38 ? args.diffs.join("\n\n---\n\n")
39 : args.diffs
40 : "";
41
42 return (
43 <EditFile
44 showToolCallStatusIcon={true}
45 status={toolCallState.status}
46 relativeFilePath={args?.filepath ?? ""}
47 changes={changes}
48 toolCallId={toolCall.id}
49 historyIndex={historyIndex}
50 />
51 );
52 case BuiltInToolNames.RunTerminalCommand:
53 return (
54 <RunTerminalCommand
55 command={args?.command ?? ""}
56 toolCallState={toolCallState}
57 toolCallId={toolCall.id}
58 />
59 );
60 default:
61 return null;
62 }
63}
64
65export default FunctionSpecificToolCallDiv;