webfetch

package
v0.2.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(client *Client) []gollem.Tool

New returns the webfetch-backed agent tools. It returns nil (the tool is not registered) when client is nil or has no LLM client: the LLM screen is the only injection defense in this codebase — there is no HITL fallback — so webfetch fails closed rather than serving unscreened content.

Types

type Client

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

Client fetches web content over HTTP and screens it through an LLM-based pipeline (Markdown extraction + indirect-prompt-injection detection).

func NewClient

func NewClient(cfg ClientConfig) *Client

NewClient builds a Client whose HTTP transport rejects connections to non-public IP ranges (SSRF guard) unless cfg.AllowPrivateIP is set.

type ClientConfig

type ClientConfig struct {
	// Timeout bounds the whole HTTP request (dial + TLS + headers + body).
	Timeout time.Duration
	// MaxBytes caps how much of the response body is read; the remainder is
	// dropped and the result is marked truncated.
	MaxBytes int64
	// UserAgent is sent on every request.
	UserAgent string
	// LLM screens fetched bodies for indirect prompt injection and reformats
	// them to Markdown. Required: New returns no tools when it is nil.
	LLM gollem.LLMClient
	// AllowPrivateIP disables the SSRF guard. It exists only as a test seam so
	// the fetch path can be exercised against loopback httptest servers;
	// production callers always leave it false.
	AllowPrivateIP bool
}

ClientConfig carries every parameter needed to construct a Client. All values are supplied by the caller (CLI config) — the package embeds no defaults so timeout / size limits stay configurable from one place.

Jump to

Keyboard shortcuts

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