Vibe.WebTools (vibe v0.2.0)

Copy Markdown View Source

Provider-neutral web search and fetch API exposed to eval as Web.

Web.search/2 and Web.fetch/2 keep agent-facing code stable while concrete providers handle vendor-specific APIs. Exa is the default search provider; a local Req implementation is the default fetch provider.

Summary

Functions

Fetches a URL through the configured fetch provider.

Raises on URL fetch errors.

Filters search results to URLs containing a domain substring.

Parses HTML from a fetch result or binary string with Floki.

Parses HTML from a fetch result or binary string with Floki, raising on failure.

Searches the web through the configured search provider.

Raises on web search errors.

Extracts matching HTML from a fetched page with a CSS selector.

Extracts matching HTML from a fetched page with a CSS selector, raising on failure.

Keeps at most count search results.

Truncates fetched content or plain text using the shared tool-output byte limit.

Types

fetch_result()

@type fetch_result() :: Vibe.WebTools.FetchResult.t()

search_result()

@type search_result() :: Vibe.WebTools.SearchResult.t()

Functions

fetch(url, opts \\ [])

@spec fetch(
  String.t(),
  keyword()
) :: {:ok, Vibe.WebTools.FetchResult.t()} | {:error, term()}

Fetches a URL through the configured fetch provider.

fetch!(url, opts \\ [])

@spec fetch!(
  String.t(),
  keyword()
) :: Vibe.WebTools.FetchResult.t()

Raises on URL fetch errors.

filter_domain(search, domain)

Filters search results to URLs containing a domain substring.

parse_html(value)

@spec parse_html(Vibe.WebTools.FetchResult.t() | String.t()) ::
  {:ok, Vibe.WebTools.HTML.html_tree()} | {:error, term()}

Parses HTML from a fetch result or binary string with Floki.

parse_html!(value)

Parses HTML from a fetch result or binary string with Floki, raising on failure.

search(query, opts \\ [])

@spec search(
  String.t(),
  keyword()
) :: {:ok, Vibe.WebTools.SearchResult.t()} | {:error, term()}

Searches the web through the configured search provider.

search!(query, opts \\ [])

@spec search!(
  String.t(),
  keyword()
) :: Vibe.WebTools.SearchResult.t()

Raises on web search errors.

select(result, selector)

@spec select(Vibe.WebTools.FetchResult.t(), String.t()) ::
  {:ok, Vibe.WebTools.FetchResult.t()} | {:error, term()}

Extracts matching HTML from a fetched page with a CSS selector.

select!(result, selector)

Extracts matching HTML from a fetched page with a CSS selector, raising on failure.

take(search, count)

Keeps at most count search results.

truncate(value, opts \\ [])

Truncates fetched content or plain text using the shared tool-output byte limit.