Documentation
¶
Overview ¶
Package web_fetch provides a public URL content fetcher with SSRF protection.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FetchURLContent ¶
FetchURLContent preserves the existing package-level API for the chat pipeline.
func PageFetchTimeout ¶ added in v0.9.0
PageFetchTimeout is the shared budget for one agent web_fetch page read. The HTTP client, the fetch context, and chromedp all use this value. Chromedp's deadline is a child of the fetch context, so the budgets do not add.
WEKNORA_WEB_FETCH_TIMEOUT accepts a Go duration (150s, 3m) or a bare positive number of seconds (180), the same pattern as WEKNORA_AGENT_LLM_TIMEOUT. Empty, invalid, and non-positive values use defaultPageFetchTimeout.
Types ¶
type ErrorCode ¶
type ErrorCode string
ErrorCode identifies the stage and class of a fetch failure.
const ( ErrorInvalidURL ErrorCode = "invalid_url" ErrorDNS ErrorCode = "dns_failed" ErrorTimeout ErrorCode = "connection_timeout" ErrorTLS ErrorCode = "tls_failed" ErrorHTTP403 ErrorCode = "http_403" ErrorHTTP429 ErrorCode = "http_429" ErrorHTTP5xx ErrorCode = "http_5xx" ErrorHTTPStatus ErrorCode = "http_status" ErrorSSRFRejected ErrorCode = "ssrf_rejected" ErrorRedirectRejected ErrorCode = "redirect_rejected" ErrorRead ErrorCode = "read_failed" ErrorHTMLParse ErrorCode = "html_parse_failed" ErrorEmptyContent ErrorCode = "empty_content" ErrorConnection ErrorCode = "connection_failed" ErrorBodyTooLarge ErrorCode = "body_too_large" ErrorUnsupportedContent ErrorCode = "unsupported_content" ErrorSnapshotExpired ErrorCode = "snapshot_expired" )
Fetch failure codes distinguish retryable network errors from permanent failures.
type FetchError ¶
FetchError carries stable, machine-readable failure details.
func (*FetchError) Error ¶
func (e *FetchError) Error() string
func (*FetchError) Unwrap ¶
func (e *FetchError) Unwrap() error
type Fetcher ¶
type Fetcher struct {
// contains filtered or unexported fields
}
Fetcher fetches and extracts public web pages through an SSRF-safe client.
func NewFetcher ¶
func NewFetcher() *Fetcher
NewFetcher creates a production fetcher with DNS and redirect SSRF guards.
func NewPipelineFetcher ¶
func NewPipelineFetcher() *Fetcher
NewPipelineFetcher creates an HTTP-only fetcher for the chat pipeline. It keeps the pre-refactor 15s timeout and does not launch Chromium.