WebBackend
Defined in: tools/builtin/builtin.types.ts:443
The read-only web capability seam — implement this against an online service.
Remarks
Backs the two read-only web tools (web_search and web_fetch). It is the
network counterpart to FileReadBackend: both bundle two read-only
lookups (there: read + glob; here: search + fetch) over a resource the
core knows nothing about, hence a seam rather than a shipped implementation.
Wire search to e.g. Brave / Tavily / Exa / Bing, and fetch to an HTTP
client plus an HTML-to-text extractor.
SECURITY: fetch dereferences a model-supplied URL, so it can reach internal
addresses (SSRF) and exfiltrate via the request. The backend owns allow-listing
and redirect limits; route the resulting web_fetch tool through the
permission gate (../../permissions) before granting it to a model you do not
fully trust — the same advice as for ShellBackend. search is inert by
comparison, like SearchBackend.
See
- FileReadBackend — its filesystem analog; back this the same way.
- webSearchTool and webFetchTool which wrap this seam in model-facing tools.
Methods
fetch()
fetch(request, ctx): Promise<WebFetchResult>;Defined in: tools/builtin/builtin.types.ts:459
Fetch one URL and return its extracted contents.
Parameters
| Parameter | Type | Description |
|---|---|---|
request | WebFetchRequest | The URL plus an optional byte cap. |
ctx | ToolContext | Per-call context; ctx.signal may be used to abort the fetch. |
Returns
Promise<WebFetchResult>
The final URL, status, content type, and extracted text.
search()
search(query, ctx): Promise<WebSearchResult[]>;Defined in: tools/builtin/builtin.types.ts:451
Run a web search and return the ranked hits.
Parameters
| Parameter | Type | Description |
|---|---|---|
query | WebSearchQuery | The search request (query string and optional cap). |
ctx | ToolContext | Per-call context; ctx.signal may be used to abort the search. |
Returns
Promise<WebSearchResult[]>
The ranked results.