* server: rename built-in tools to server tools * ui: rename built-in tools to server/browser tools
61 lines
1.8 KiB
TypeScript
61 lines
1.8 KiB
TypeScript
// Registry of server and browser tools whose renderer
|
|
// shows a recognizable icon and friendly label inline in the chat UI.
|
|
//
|
|
// To add a new tool, add an entry to TOOL_UI. To give a
|
|
// tool a custom title or body renderer, add a dedicated component under
|
|
// ChatMessageToolCall/ and route it in ChatMessageToolCallBlock.svelte
|
|
// (see ChatMessageToolCallBlockGetDatetime and
|
|
// ChatMessageToolCallBlockSearchResults for prior art).
|
|
|
|
import {
|
|
Braces,
|
|
Clock,
|
|
Eye,
|
|
FilePen,
|
|
FilePlus,
|
|
FileSearch,
|
|
FileText,
|
|
Info,
|
|
SearchCode,
|
|
Terminal
|
|
} from '@lucide/svelte';
|
|
import { BuiltInTool, ToolSource } from '$lib/enums';
|
|
import type { ToolUiEntry } from '$lib/types';
|
|
|
|
export const TOOL_UI: Readonly<Record<BuiltInTool, ToolUiEntry>> = {
|
|
[BuiltInTool.BROWSER_GET_DATETIME]: {
|
|
icon: Clock,
|
|
label: 'Current time',
|
|
source: ToolSource.BROWSER
|
|
},
|
|
[BuiltInTool.BROWSER_READ_MEDIA]: { icon: Eye, label: 'Read media', source: ToolSource.BROWSER },
|
|
[BuiltInTool.BROWSER_RUN_JAVASCRIPT]: {
|
|
icon: Braces,
|
|
label: 'Run JavaScript',
|
|
source: ToolSource.BROWSER
|
|
},
|
|
[BuiltInTool.SERVER_EDIT_FILE]: { icon: FilePen, label: 'Edit file', source: ToolSource.SERVER },
|
|
[BuiltInTool.SERVER_EXEC_SHELL_COMMAND]: {
|
|
icon: Terminal,
|
|
label: 'Run command',
|
|
source: ToolSource.SERVER
|
|
},
|
|
[BuiltInTool.SERVER_FILE_GLOB_SEARCH]: {
|
|
icon: FileSearch,
|
|
label: 'Search files',
|
|
source: ToolSource.SERVER
|
|
},
|
|
[BuiltInTool.SERVER_GET_INFO]: { icon: Info, label: 'Runtime info', source: ToolSource.SERVER },
|
|
[BuiltInTool.SERVER_GREP_SEARCH]: {
|
|
icon: SearchCode,
|
|
label: 'Search in files',
|
|
source: ToolSource.SERVER
|
|
},
|
|
[BuiltInTool.SERVER_READ_FILE]: { icon: FileText, label: 'Read file', source: ToolSource.SERVER },
|
|
[BuiltInTool.SERVER_WRITE_FILE]: {
|
|
icon: FilePlus,
|
|
label: 'Write file',
|
|
source: ToolSource.SERVER
|
|
}
|
|
} as const;
|