Help us shape the future of Go! Take the 2026 Go Developer Survey

webfetch

package
v1.11.3 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const Description = `` /* 2116-byte string literal not displayed */

Description is the tool description.

View Source
const MaxPromptPreviewLength = 4000

MaxPromptPreviewLength limits the amount of source content included in the extracted result.

View Source
const SearchHint = "fetch web pages and extract information"
View Source
const ToolName = "web_fetch"

ToolName is the tool name.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache = fetchcore.Cache

func DefaultCache

func DefaultCache() *Cache

DefaultCache keeps the old wrapper-level constructor available while delegating to the shared fetch core.

type Config

type Config = fetchcore.Config

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns the shared fetch-core defaults through the tool package for backward compatibility.

func DefaultToolConfig

func DefaultToolConfig() *Config

DefaultToolConfig returns default configuration.

type FetchedContent

type FetchedContent = fetchcore.FetchedContent

type HTTPClient

type HTTPClient = fetchcore.HTTPClient

type Input

type Input struct {
	URL        string `json:"url"`
	Prompt     string `json:"prompt"`
	RenderMode string `json:"render_mode,omitempty"`
}

Input represents the tool input.

func (*Input) Validate

func (i *Input) Validate() error

Validate validates the input.

type Output

type Output struct {
	Bytes         int    `json:"bytes"`
	Code          int    `json:"code"`
	CodeText      string `json:"codeText"`
	Result        string `json:"result"`
	DurationMs    int64  `json:"durationMs"`
	URL           string `json:"url"`
	Mode          string `json:"mode,omitempty"`
	PersistedPath string `json:"persisted_path,omitempty"`
	PersistedSize int    `json:"persisted_size,omitempty"`
}

Output represents the tool output.

type RedirectInfo

type RedirectInfo = fetchcore.RedirectInfo

type Tool

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

Tool represents the WebFetch tool.

func NewTool

func NewTool(config *Config) *Tool

NewTool creates a new WebFetch tool.

func (*Tool) BackfillInput

func (t *Tool) BackfillInput(ctx context.Context, input map[string]any) map[string]any

BackfillInput adds derived fields so downstream permission and transcript code sees normalized values.

func (*Tool) Call

func (t *Tool) Call(
	ctx context.Context,
	input tool.CallInput,
	permissionCheck types.CanUseToolFn,
) (tool.CallResult, error)

Call executes the tool end-to-end while keeping the orchestration logic separate from the fetch backends.

func (*Tool) CheckPermissions

func (t *Tool) CheckPermissions(ctx context.Context, input map[string]any, toolCtx tool.ToolUseContext) types.PermissionResult

func (*Tool) Definition

func (t *Tool) Definition() tool.Definition

Definition returns the tool definition.

func (*Tool) Description

func (t *Tool) Description(ctx context.Context) (string, error)

Description returns human-readable description.

func (*Tool) FormatResult

func (t *Tool) FormatResult(data any) string

FormatResult serialises the tool output into the tool_result content string.

func (*Tool) IsConcurrencySafe

func (t *Tool) IsConcurrencySafe(input map[string]any) bool

IsConcurrencySafe reports that WebFetch requests can run concurrently.

func (*Tool) IsEnabled

func (t *Tool) IsEnabled() bool

IsEnabled returns whether this tool is currently active.

func (*Tool) IsReadOnly

func (t *Tool) IsReadOnly(input map[string]any) bool

IsReadOnly reports that WebFetch does not modify state.

func (*Tool) PreparePermissionMatcher

func (t *Tool) PreparePermissionMatcher(ctx context.Context, input map[string]any) (func(string) bool, error)

PreparePermissionMatcher compiles content-specific permission matching for fetch URL, host, and render mode rules.

func (*Tool) ValidateInput

func (t *Tool) ValidateInput(ctx context.Context, input map[string]any) (map[string]any, error)

ValidateInput validates and normalizes WebFetch input.

Jump to

Keyboard shortcuts

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