Elffuss BraidHub

kikocis/continue public

c5e6566b8882 · 2.3 KiBRawPermalink
1import { ToolCallState } from "core";
2import { BuiltInToolNames } from "core/tools/builtIn";
3import { EditOperation } from "core/tools/definitions/multiEdit";
4import { CreateFile } from "./CreateFile";
5import { EditFile } from "./EditFile";
6import { FindAndReplaceDisplay } from "./FindAndReplace";
7import { RunTerminalCommand } from "./RunTerminalCommand";
8
9function FunctionSpecificToolCallDiv({
10 toolCallState,
11 historyIndex,
12}: {
13 toolCallState: ToolCallState;
14 historyIndex: number;
15}) {
16 const args = toolCallState.parsedArgs;
17 const toolCall = toolCallState.toolCall;
18
19 switch (toolCall.function?.name) {
20 case BuiltInToolNames.CreateNewFile:
21 return (
22 <CreateFile
23 relativeFilepath={args?.filepath ?? ""}
24 fileContents={args?.contents ?? ""}
25 historyIndex={historyIndex}
26 />
27 );
28 case BuiltInToolNames.EditExistingFile:
29 return (
30 <EditFile
31 relativeFilePath={args?.filepath ?? ""}
32 changes={args?.changes ?? ""}
33 toolCallId={toolCall.id}
34 historyIndex={historyIndex}
35 />
36 );
37 case BuiltInToolNames.SingleFindAndReplace:
38 const edits: EditOperation[] = [
39 {
40 old_string: args?.old_string ?? "",
41 new_string: args?.new_string ?? "",
42 replace_all: args?.replace_all,
43 },
44 ];
45 return (
46 <FindAndReplaceDisplay
47 editingFileContents={args?.editingFileContents}
48 fileUri={args?.fileUri}
49 relativeFilePath={args?.filepath ?? ""}
50 edits={edits}
51 toolCallId={toolCall.id}
52 historyIndex={historyIndex}
53 />
54 );
55 case BuiltInToolNames.MultiEdit:
56 return (
57 <FindAndReplaceDisplay
58 editingFileContents={args?.editingFileContents}
59 relativeFilePath={args?.filepath ?? ""}
60 fileUri={args?.fileUri}
61 edits={args?.edits ?? []}
62 toolCallId={toolCall.id}
63 historyIndex={historyIndex}
64 />
65 );
66 case BuiltInToolNames.RunTerminalCommand:
67 return (
68 <RunTerminalCommand
69 command={args?.command ?? ""}
70 toolCallState={toolCallState}
71 toolCallId={toolCall.id}
72 />
73 );
74 default:
75 return null;
76 }
77}
78
79export default FunctionSpecificToolCallDiv;