websearchd

command
v0.0.0-...-7c75ef6 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2026 License: Apache-2.0 Imports: 19 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

htmltotext.go reduces an HTML page's markup to plain text before fetch measures it against its size cap. Design R4 requires the reduction to happen BEFORE the cap is applied — otherwise markup consumes the byte budget the prose needs, and a page that is 90% tags returns almost no actual content.

This walks golang.org/x/net/html's parse tree — an existing DIRECT dependency (go.mod), already used for HTML manipulation elsewhere in this exact codebase (pkg/channels/channelassets/html) — rather than a hand-rolled tag-stripping regex, the shape CLAUDE.md's "prefer a library over a hand-rolled utility" rule explicitly rejects.

bluemonday (also already a dependency, and this repo's own choice for HTML sanitization) was the first candidate and was rejected for this specific job after a direct comparison: bluemonday.StrictPolicy().Sanitize strips every tag but inserts no whitespace at block boundaries, so "<p>A</p><p>B</p>" collapses to "AB" — two paragraphs glued into one unreadable word run. It also leaves HTML entities escaped ("&amp;" stays "&amp;"), because it sanitizes the token stream rather than parsing text nodes. Walking x/net/html's own tree costs a few more lines than a single Sanitize call, but keeps block-level elements from running into each other and gets entity decoding for free from the parser's own text nodes.

Command websearchd is ap-websearchd: a client-dispatched search-and-fetch sidecar. It exposes two MCP tools, search and fetch, over Streamable-HTTP, backed by a registry-selected github.com/authzed/openagentprimitives/pkg/tools/websearch provider.

It exists so that an agent's web access is CLIENT-dispatched rather than a model provider's own inline search: a server-side search/fetch result never becomes a tool.Result, so it never passes through the runner's untrusted-content wrapper, never reaches a content-guard subject, and never touches the toolguard byte budget — every control this platform has over tool output is absent by construction. Because this binary makes the HTTP request itself, its result IS a tool.Result like any other MCP tool call, and every one of those controls applies to it automatically.

It runs no user code: query and URL arguments are plain strings handed to a provider's own HTTP client (safehttp.Client() in production), never interpreted as a script — the same posture internal/cmd/apiadapter states for its own config-driven calls.

server.go turns one websearch.SearchExecutor into two MCP tools — search and fetch. This file never reads an environment variable — main.go owns the env contract and hands this Server an already-constructed executor and an already-opened (or nil) artifact store, exactly as internal/cmd/apiadapter's server.go takes an already-parsed Config and an already-resolved credential.

fetch is the entire security surface of this daemon (see the design doc's §3 R4 and §4): every check below runs in the stated order, and each one exists to close a specific gap the one before it leaves open.

Jump to

Keyboard shortcuts

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