web

package
v2.10.2 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: MIT Imports: 18 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package web holds Scribe's web tools: web_search (SearXNG or DuckDuckGo HTML) and fetch_page (a readable-text fetch with an SSRF guard).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(r *tools.Registry, opts Options)

Register adds web_search and fetch_page to r.

func UserDeclined

func UserDeclined(what, reason string) string

UserDeclined is the tool result for an approval the user denied. The file, web, MCP and symbol-edit tools all use it, so the model reads the same decision whichever tool was refused. It follows the shell's wording (tools/exec userDeclined): the decision is the user's, not a sandbox rule, it stands for this request, and it covers only this call. Without that last clause a model takes a refusal as a reason to stop for good. The reason the user gave, if any, is appended last.

what names the action in the user's terms, e.g. "edit sensitive file: .github/workflows/ci.yml".

Types

type Options

type Options struct {
	// SearchURL is a SearXNG base URL (for example http://searx.internal:8888).
	// Empty selects the DuckDuckGo HTML backend. SearXNG is usually a local
	// service the user configured on purpose, so its address is not guarded.
	SearchURL string
	// BraveAPIKey, when set, makes web_search try the Brave Search API first
	// and fall back to the other backends when Brave fails or returns
	// nothing. Empty skips Brave.
	BraveAPIKey string
	// HTTPClient is optional. Search always uses it when set. fetch_page
	// uses a copy of it when set (with its redirect policy replaced by the
	// guard), so pass a client with a custom Transport only if you accept
	// that the dial-time address check is then the caller's responsibility.
	HTTPClient *http.Client
	// UserAgent is sent on every request. Empty uses a Scribe default.
	UserAgent string
	// AllowPrivate lets fetch_page reach loopback, private, link-local and
	// CGNAT addresses. Off by default. Tests use it with httptest.
	AllowPrivate bool
	// JinaAPIKey is sent as a bearer token to the Jina Reader. It is never
	// logged, never shown to the model and never placed in an error message.
	// Empty uses the Jina Reader's free tier.
	JinaAPIKey string
	// JinaReader, when true, reads pages through the Jina Reader
	// (r.jina.ai) before a local fetch. It sends each URL to a third party,
	// so it is off unless the user turned it on in settings.
	JinaReader bool
}

Options configures the web tools.

type Source

type Source struct {
	URL       string // final URL after redirects
	Title     string
	Text      string // readable text, Markdown for HTML
	Truncated bool
}

Source is a web page fetched for the read tool.

func FetchSource

func FetchSource(ctx context.Context, env *tools.Env, raw string) (Source, error)

FetchSource fetches raw for the read tool. It runs the same checks as fetch_page: http or https only, the private-address guard before the request and at dial time, the per-session web approval, and the download cap. The Jina Reader is never used, so the URL is not sent to a third party. Each call asks again, because the read tool has no web state of its own.

Jump to

Keyboard shortcuts

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