Code Reader
首页
帮助
设计文档
首页
帮助
设计文档
  • Webfetch 工具

Webfetch 工具

Webfetch 工具用于从 Web 获取内容。

概述

Webfetch 工具允许 AI 助手从 URL 获取 Web 内容。它支持:

  • HTTP/HTTPS 请求
  • 自动内容类型检测
  • 超时限制

定义位置

  • packages/opencode/src/tool/webfetch.ts

参数说明

参数名类型必填说明
urlstring是要获取的 URL

TypeScript 类型定义

export type WebfetchInput = {
  url: string
}

export type WebfetchOutput = {
  title: string
  output: string
  metadata: {
    url: string
    truncated?: boolean
  }
}

典型使用场景

获取 HTML 内容

await WebfetchTool.execute({
  url: "https://example.com",
}, ctx)

获取 API 响应

await WebfetchTool.execute({
  url: "https://api.example.com/data",
}, ctx)

相关文档

  • Websearch - Web 搜索