webfetchtool

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 4, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package webfetchtool implements the WebFetch tool — fetches a URL and returns its content as Markdown text.

Mirrors src/tools/WebFetchTool/WebFetchTool.ts + utils.ts.

M4 scope: HTTP GET with 30s timeout, HTML→Markdown via golang.org/x/net/html parser, 200KB content cap, User-Agent spoofing. The real tool also calls a secondary Haiku model to apply the caller's prompt against the fetched content; we do that inline with simple extraction for M4. Domain allowlist / permission checks land in M5.

Index

Constants

View Source
const HTTPTimeout = 30 * time.Second

HTTPTimeout is the total request timeout.

View Source
const MaxContentBytes = 200 * 1024 // 200 KB

MaxContentBytes caps the response body size.

Variables

This section is empty.

Functions

This section is empty.

Types

type Input

type Input struct {
	URL    string `json:"url"`
	Prompt string `json:"prompt"`
}

Input is the typed view of the JSON input.

type Tool

type Tool struct {
	// contains filtered or unexported fields
}

Tool implements the WebFetch tool.

func New

func New() *Tool

New returns a fresh WebFetch tool.

func (*Tool) Description

func (*Tool) Description() string

func (*Tool) Execute

func (t *Tool) Execute(ctx context.Context, raw json.RawMessage) (tool.Result, error)

Execute fetches the URL and returns processed content.

func (*Tool) InputSchema

func (*Tool) InputSchema() json.RawMessage

func (*Tool) IsConcurrencySafe

func (*Tool) IsConcurrencySafe(json.RawMessage) bool

func (*Tool) IsReadOnly

func (*Tool) IsReadOnly(json.RawMessage) bool

func (*Tool) Name

func (*Tool) Name() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL