2 import ChatMessageToolCallBlockDefault from './ChatMessageToolCallBlockDefault.svelte';
3 import ChatMessageToolCallBlockEditFile from './ChatMessageToolCallBlockEditFile.svelte';
4 import ChatMessageToolCallBlockExecShellCommand from './ChatMessageToolCallBlockExecShellCommand.svelte';
5 import ChatMessageToolCallBlockFileGlobSearch from './ChatMessageToolCallBlockFileGlobSearch.svelte';
6 import ChatMessageToolCallBlockGetDatetime from './ChatMessageToolCallBlockGetDatetime.svelte';
7 import ChatMessageToolCallBlockGetInfo from './ChatMessageToolCallBlockGetInfo.svelte';
8 import ChatMessageToolCallBlockGrepSearch from './ChatMessageToolCallBlockGrepSearch.svelte';
9 import ChatMessageToolCallBlockReadFile from './ChatMessageToolCallBlockReadFile.svelte';
10 import ChatMessageToolCallBlockReadMedia from './ChatMessageToolCallBlockReadMedia.svelte';
11 import ChatMessageToolCallBlockRunJavascript from './ChatMessageToolCallBlockRunJavascript.svelte';
12 import ChatMessageToolCallBlockSearchResults from './ChatMessageToolCallBlockSearchResults.svelte';
13 import ChatMessageToolCallBlockWriteFile from './ChatMessageToolCallBlockWriteFile.svelte';
14 import { BuiltInTool } from '$lib/enums';
15 import type { AgenticSection } from '$lib/types';
16 import type { DatabaseMessageExtra } from '$lib/types';
17 import { extractSearchQuery, extractSearchResults, isWebSearchToolName } from '$lib/utils';
20 section: AgenticSection;
21 attachments?: DatabaseMessageExtra[];
24 isExecuting?: boolean;
25 onToggle?: () => void;
28 let { attachments, isExecuting, isStreaming, onToggle, open, section }: Props = $props();
30 const searchResults = $derived(extractSearchResults(section.toolResult));
31 const searchQuery = $derived(extractSearchQuery(section.toolArgs));
32 const isSearchCall = $derived(
33 searchResults.length > 0 || (searchQuery.length > 0 && isWebSearchToolName(section.toolName))
38 <ChatMessageToolCallBlockSearchResults {section} {open} {isStreaming} {onToggle} />
39 {:else if section.toolName === BuiltInTool.GET_DATETIME}
40 <ChatMessageToolCallBlockGetDatetime {section} {isStreaming} />
41 {:else if section.toolName === BuiltInTool.GET_INFO}
42 <ChatMessageToolCallBlockGetInfo {section} {isStreaming} />
43 {:else if section.toolName === BuiltInTool.READ_FILE}
44 <ChatMessageToolCallBlockReadFile {section} {open} {isStreaming} {onToggle} />
45 {:else if section.toolName === BuiltInTool.READ_MEDIA}
46 <ChatMessageToolCallBlockReadMedia {section} {open} {isStreaming} {onToggle} />
47 {:else if section.toolName === BuiltInTool.EDIT_FILE}
48 <ChatMessageToolCallBlockEditFile {section} {open} {isStreaming} {onToggle} />
49 {:else if section.toolName === BuiltInTool.WRITE_FILE}
50 <ChatMessageToolCallBlockWriteFile {section} {open} {isStreaming} {onToggle} />
51 {:else if section.toolName === BuiltInTool.EXEC_SHELL_COMMAND}
52 <ChatMessageToolCallBlockExecShellCommand
60 {:else if section.toolName === BuiltInTool.FILE_GLOB_SEARCH}
61 <ChatMessageToolCallBlockFileGlobSearch {section} {open} {isStreaming} {onToggle} />
62 {:else if section.toolName === BuiltInTool.GREP_SEARCH}
63 <ChatMessageToolCallBlockGrepSearch {section} {open} {isStreaming} {onToggle} />
64 {:else if section.toolName === BuiltInTool.RUN_JAVASCRIPT}
65 <ChatMessageToolCallBlockRunJavascript {section} {open} {isStreaming} {onToggle} />
67 <ChatMessageToolCallBlockDefault {section} {open} {isStreaming} {attachments} {onToggle} />