Expand description
WebFetch tool — Rust port of @agent-sh/harness-webfetch.
Conforms to agent-knowledge/design/webfetch.md. Same contract as the
TS package: HTTP GET/POST with tool-layer SSRF defense, manual
redirect loop with per-hop re-check, readability+markdown extraction,
3-tier size caps with spill-to-file, and an in-memory 5-min session
cache.
Structs§
- Cached
Response - Fetch
Error - Fetch
Metadata - Reqwest
Engine - WebFetch
Engine Input - WebFetch
Engine Result - WebFetch
Error - WebFetch
Http Error - WebFetch
Ok - WebFetch
Params - WebFetch
Permission Policy - Session permission policy plus the autonomous escape hatch for tests.
- WebFetch
Redirect Loop - WebFetch
Session Config
Enums§
Constants§
- CACHE_
TTL_ MS - DEFAULT_
MAX_ REDIRECTS - DEFAULT_
TIMEOUT_ MS - DEFAULT_
USER_ AGENT - HTML_
EXTRACTABLE_ TYPES - INLINE_
MARKDOWN_ CAP - INLINE_
RAW_ CAP - MANAGED_
HEADERS - Headers the tool manages; user-supplied copies are silently dropped.
- MAX_
MAX_ REDIRECTS - MAX_
URL_ LENGTH - MIN_
TIMEOUT_ MS - SESSION_
BACKSTOP_ MS - SPILL_
HARD_ CAP - SPILL_
HEAD_ BYTES - SPILL_
TAIL_ BYTES - TEXT_
PASSTHROUGH_ TYPES - Content-types that pass through as text. Anything else gets rejected with UNSUPPORTED_CONTENT_TYPE and a bash+curl hint.
- WEBFETCH_
TOOL_ DESCRIPTION - WEBFETCH_
TOOL_ NAME
Traits§
Functions§
- classify_
host - Resolve the host and run the IP classifier against each result.
Returns
Blockedif any resolved IP lands in a range not opted into. - classify_
ip - Synchronous helper — reads the input string as an IP if possible, classifies. Used by tests + by the host-resolver path (each resolved address is fed in here).
- default_
engine - format_
http_ error_ text - format_
ok_ text - format_
redirect_ loop_ text - head_
and_ tail - Return head (first N bytes) + tail (last N bytes) concatenated with an elision marker. Mirrors the bash head+tail spill pattern.
- render_
request_ block - safe_
parse_ webfetch_ params - spill_
to_ file - webfetch