Weave documentation
Rust referenceweave-browser-engine

weave-browser-engine · serve

Source declarations, signatures and documentation for serve.

Reviewed implementation boundary: The serve path warns but still binds when WEAVE_API_KEY is absent; the authentication check then allows requests. Configure and verify authorization before exposing a server. See /libraries/weave-browser-engine/research-server.

Source: sigil/weave/libs/weave-browser-engine/src/serve.rs. SHA-256: 63265b8913ab2bacb4ca2b8d3951d3aaabe25faa525d840343dc965f441edf0f.

This reference follows declared source modules, retains conditional attributes, and includes public declarations and implementation methods. Private-module re-exports and trait resolution require the compiler; this is a source reference, not a claim that every listed item is a root import. Function bodies and constant values are omitted.

serve::FetchRequest

Request body for POST /fetch.

#[derive(Debug, Deserialize)]
pub struct FetchRequest {
/// The URL to fetch.

pub url: String,
/// Include raw HTML in the response.

#[serde(default)]
pub raw: bool,
/// Extract all links from the page.

#[serde(default)]
pub links: bool,
/// Extract all images from the page.

#[serde(default)]
pub images: bool,
/// A CSS selector to extract specific elements.

pub selector: Option<String>
}

Source line: 73.

serve::ObserveRequest

Request body for POST /observe.

#[derive(Debug, Deserialize)]
pub struct ObserveRequest {
/// The page URL that produced the HTML.

pub url: String,
/// Raw HTML to observe.

pub html: String,
/// Active browser profile.

pub profile_id: Option<String>,
/// Browser tab being observed.

pub tab_id: Option<String>,
/// Frame identifier within the tab.

pub frame_id: Option<String>,
/// Navigation identifier for this document.

pub navigation_id: Option<String>,
/// Monotonic frame generation.

pub generation: Option<u64>,
/// Observation timestamp in Unix milliseconds.

pub timestamp_ms: Option<u64>
}

Source line: 91.

serve::SearchRequest

Request body for POST /search.

#[derive(Debug, Deserialize)]
pub struct SearchRequest {
/// The search query.

pub query: String,
/// Maximum number of results (defaults to 10, capped at 100).

pub top: Option<usize>,
/// Search engine name (defaults to `"duckduckgo"`).

pub engine: Option<String>
}

Source line: 112.

serve::PerceiveRequest

Request body for POST /perceive.

#[derive(Debug, Deserialize)]
pub struct PerceiveRequest {
/// The local file path to analyze.

pub path: String
}

Source line: 123.

serve::ResearchRequest

Request body for POST /research.

#[derive(Debug, Deserialize)]
pub struct ResearchRequest {
/// The topic or question to research.

pub topic: String,
/// Research depth (1..=5, defaults to 2).

pub depth: Option<u8>,
/// Maximum sources per iteration (defaults to 10, capped at 50).

pub sources: Option<usize>,
/// Whether to cross-verify claims (defaults to false).

#[serde(default)]
pub verify: bool
}

Source line: 130.

serve::router

Create the axum [Router] with all browser engine endpoints.

Includes security middleware:

  • API key authentication (if WEAVE_API_KEY env var is set)
  • Request body size limit (1 MiB)
  • Request timeout (120s)
pub fn router() -> Router;

Source line: 430.

serve::serve

Start the browser engine HTTP API server on the given address.

When WEAVE_API_KEY is not set, logs a security warning and only binds to localhost addresses. Set the env var for production use.

pub async fn serve(addr: &str) -> Result<(), BrowserError>;

Source line: 452.

On this page