Skip to content

Commit dc3aad6

Browse files
committed
Simple web search tool renderer
1 parent 955df38 commit dc3aad6

2 files changed

Lines changed: 35 additions & 0 deletions

File tree

cli/src/components/tools/registry.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { ReadFilesComponent } from './read-files'
88
import { ReadSubtreeComponent } from './read-subtree'
99
import { ReadURLComponent } from './read-url'
1010
import { RenderUIComponent } from './render-ui'
11+
import { WebSearchComponent } from './web-search'
1112
import { RunTerminalCommandComponent } from './run-terminal-command'
1213
import { SkillComponent } from './skill'
1314
import { StrReplaceComponent } from './str-replace'
@@ -41,6 +42,7 @@ const toolComponentRegistry = new Map<ToolName, ToolComponent>([
4142
[ReadSubtreeComponent.toolName, ReadSubtreeComponent],
4243
[ReadURLComponent.toolName, ReadURLComponent],
4344
[RenderUIComponent.toolName, RenderUIComponent],
45+
[WebSearchComponent.toolName, WebSearchComponent],
4446
[WriteTodosComponent.toolName, WriteTodosComponent],
4547
[StrReplaceComponent.toolName, StrReplaceComponent],
4648
[SuggestFollowupsComponent.toolName, SuggestFollowupsComponent],
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { SimpleToolCallItem } from './tool-call-item'
2+
import { defineToolComponent } from './types'
3+
4+
import type { ChatTheme } from '../../types/theme-system'
5+
import type { ToolRenderConfig } from './types'
6+
7+
/**
8+
* UI component for web_search tool.
9+
* Displays the search query in a compact format.
10+
*/
11+
export const WebSearchComponent = defineToolComponent({
12+
toolName: 'web_search',
13+
14+
render(toolBlock, theme): ToolRenderConfig {
15+
const input = toolBlock.input as { query?: string } | undefined
16+
17+
const query = typeof input?.query === 'string' ? input.query.trim() : ''
18+
19+
if (!query) {
20+
return { content: null }
21+
}
22+
23+
return {
24+
content: (
25+
<SimpleToolCallItem
26+
name="Web Search"
27+
description={query}
28+
descriptionColor={theme.muted}
29+
/>
30+
),
31+
}
32+
},
33+
})

0 commit comments

Comments
 (0)