Websearch 工具
Websearch 工具用于在 Web 上搜索信息。
概述
Websearch 工具允许 AI 助手在互联网上搜索信息。它支持:
- Web 搜索查询
- 搜索结果解析
- 多提供商支持
定义位置
packages/opencode/src/tool/websearch.ts
参数说明
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
query | string | 是 | 搜索查询字符串 |
TypeScript 类型定义
export type WebsearchInput = {
query: string
}
export type WebsearchOutput = {
title: string
output: string
metadata: {
sources?: string[] // 搜索来源
}
}
典型使用场景
搜索技术问题
await WebsearchTool.execute({
query: "how to use React hooks with TypeScript",
}, ctx)
搜索最佳实践
await WebsearchTool.execute({
query: "JavaScript async await best practices",
}, ctx)
限制和注意事项
搜索限制
- 搜索结果可能随时间变化
- 依赖外部服务可用性
- 需要网络连接
权限要求
| 权限类型 | 说明 |
|---|---|
websearch | Web 搜索权限 |
相关文档
- Webfetch - Web 内容获取
- Tool System - Tool 系统实现机制