Skip to main content

Crate harness_webfetch

Crate harness_webfetch 

Source
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§

CachedResponse
FetchError
FetchMetadata
ReqwestEngine
WebFetchEngineInput
WebFetchEngineResult
WebFetchError
WebFetchHttpError
WebFetchOk
WebFetchParams
WebFetchPermissionPolicy
Session permission policy plus the autonomous escape hatch for tests.
WebFetchRedirectLoop
WebFetchSessionConfig

Enums§

BlockClass
SsrfDecision
WebFetchExtract
WebFetchMethod
WebFetchParseError
WebFetchResult

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§

WebFetchEngine

Functions§

classify_host
Resolve the host and run the IP classifier against each result. Returns Blocked if 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

Type Aliases§

WebFetchCache