browser

package
v0.10.1 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: MIT Imports: 17 Imported by: 1 module, 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.

README

Browser

Enter a URL or search words in the address bar. DuckDuckGo home and query URLs render a local search view: the server parses its HTML endpoint into up to 15 results with titles, URLs and snippets. Selecting a result uses the same window history as ordinary navigation. Search failures are shown with the system-browser action still available; no search iframe is loaded.

Reader mode selects a marked main/article region, or scores paragraph-rich containers while penalizing link-heavy navigation. It renders Markdown through the shared registry component, retaining heading levels, links, emphasis, lists and images. Scripts, forms, navigation and source HTML are excluded. Links and image sources must resolve to HTTP(S) URLs; images load lazily without a referrer. Content without a readable article shows an explicit empty state. Search and reader requests do not use a browser session or cookie jar.

This is static HTML extraction: JavaScript-only pages still need the system browser, and DuckDuckGo may rate-limit or challenge automated searches. Existing frame mode still honors the fetched framing headers. A server-side proxied frame is a separate design-reviewed phase; this module does not rewrite or proxy page scripts/assets.

Tests use fixture HTML and an injected HTTP transport; they do not depend on live search service availability. Run go test -race ./modules/browser and the page's typecheck/lint.

Fetch policy

Agent reads, link lists, searches and background context use a separate public-only fetcher/cache. Each request (including redirects) resolves all addresses, rejects mixed public/private answers and local interface networks, then dials a validated numeric address. Host/SNI and ordinary TLS certificate verification retain the original hostname. Connections are not reused across requests. The transport ignores environment proxies, cookies and credentials. Requests are GET-only; DuckDuckGo uses its HTML endpoint's GET query.

The owner's Reader uses POST /read with the core's owner context; it intentionally permits internal services. GET /read, outside-client POSTs and public=true always select the public policy. Agent-opened windows carry public_only and use guarded Reader without direct frames or image requests. Deliberate owner navigation returns to the owner policy. Owner and public caches never mix. The existing local API actor/origin model is not authentication against a hostile local process; this policy constrains Browser's agent tools and automatic fetches.

Both server paths reject credential-bearing URLs and add no cookie/authentication headers. Limits for bytes (compressed and decoded), redirects, time and concurrency are centralized in limits.go; public responses are limited to 2 MiB. Snapshot pipeline limits are declared there for the next slice. Snapshot rendering itself is not part of this fetcher change.

Documentation

Overview

Package browser is the Browser module: web pages in windows, for the owner and the agent.

A window shows a page in a frame when the site allows it, and otherwise (or on request) in reader mode: the page as the server read it, words and links only. The agent reads pages on the server (browser_read), never through the owner's frame, so what it sees is the same whether a window is open or not, and a page's scripts never reach it.

A window's state lives in its args: url, history (a list of URLs) and at (the position in it), so back and forward survive a reload and a saved layout reopens the same pages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Link struct {
	Text string `json:"text"`
	URL  string `json:"url"`
}

Link is one link on a page.

type Page

type Page struct {
	Public   bool     `json:"public_only,omitempty"`
	URL      string   `json:"url"`
	FinalURL string   `json:"final_url"`
	Title    string   `json:"title"`
	Text     string   `json:"text"`
	Search   bool     `json:"search,omitempty"`
	Query    string   `json:"query,omitempty"`
	Results  []Result `json:"results,omitempty"`
	Links    []Link   `json:"links,omitempty"`
	// Framable says whether the site lets another page show it in a frame.
	Framable bool   `json:"framable"`
	Fetched  string `json:"fetched"`
}

Page is a web page as the server read it: its words and its links, without its scripts.

type Result

type Result struct {
	Title   string `json:"title"`
	URL     string `json:"url"`
	Snippet string `json:"snippet,omitempty"`
}

Result is one search result.

Jump to

Keyboard shortcuts

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