2 import { BuiltInTool } from '$lib/enums';
9 import type { DatabaseMessageExtra } from '$lib/types';
10 import ChatMessageToolCallBlockDefault from './ChatMessageToolCallBlockDefault.svelte';
11 import ChatMessageToolCallBlockEditFile from './ChatMessageToolCallBlockEditFile.svelte';
12 import ChatMessageToolCallBlockExecShellCommand from './ChatMessageToolCallBlockExecShellCommand.svelte';
13 import ChatMessageToolCallBlockFileGlobSearch from './ChatMessageToolCallBlockFileGlobSearch.svelte';
14 import ChatMessageToolCallBlockGetDatetime from './ChatMessageToolCallBlockGetDatetime.svelte';
15 import ChatMessageToolCallBlockGrepSearch from './ChatMessageToolCallBlockGrepSearch.svelte';
16 import ChatMessageToolCallBlockReadFile from './ChatMessageToolCallBlockReadFile.svelte';
17 import ChatMessageToolCallBlockRunJavascript from './ChatMessageToolCallBlockRunJavascript.svelte';
18 import ChatMessageToolCallBlockSearchResults from './ChatMessageToolCallBlockSearchResults.svelte';
19 import ChatMessageToolCallBlockWriteFile from './ChatMessageToolCallBlockWriteFile.svelte';
22 section: AgenticSection;
23 attachments?: DatabaseMessageExtra[];
26 isExecuting?: boolean;
27 onToggle?: () => void;
30 let { section, attachments, open, isStreaming, isExecuting, onToggle }: Props = $props();
32 const searchResults = $derived(extractSearchResults(section.toolResult));
33 const searchQuery = $derived(extractSearchQuery(section.toolArgs));
34 const isSearchCall = $derived(
35 searchResults.length > 0 || (searchQuery.length > 0 && isWebSearchToolName(section.toolName))
40 <ChatMessageToolCallBlockSearchResults {section} {open} {isStreaming} {onToggle} />
41 {:else if section.toolName === BuiltInTool.GET_DATETIME}
42 <ChatMessageToolCallBlockGetDatetime {section} {isStreaming} />
43 {:else if section.toolName === BuiltInTool.READ_FILE}
44 <ChatMessageToolCallBlockReadFile {section} {open} {isStreaming} {onToggle} />
45 {:else if section.toolName === BuiltInTool.EDIT_FILE}
46 <ChatMessageToolCallBlockEditFile {section} {open} {isStreaming} {onToggle} />
47 {:else if section.toolName === BuiltInTool.WRITE_FILE}
48 <ChatMessageToolCallBlockWriteFile {section} {open} {isStreaming} {onToggle} />
49 {:else if section.toolName === BuiltInTool.EXEC_SHELL_COMMAND}
50 <ChatMessageToolCallBlockExecShellCommand
58 {:else if section.toolName === BuiltInTool.FILE_GLOB_SEARCH}
59 <ChatMessageToolCallBlockFileGlobSearch {section} {open} {isStreaming} {onToggle} />
60 {:else if section.toolName === BuiltInTool.GREP_SEARCH}
61 <ChatMessageToolCallBlockGrepSearch {section} {open} {isStreaming} {onToggle} />
62 {:else if section.toolName === BuiltInTool.RUN_JAVASCRIPT}
63 <ChatMessageToolCallBlockRunJavascript {section} {open} {isStreaming} {onToggle} />
65 <ChatMessageToolCallBlockDefault {section} {open} {isStreaming} {attachments} {onToggle} />