Help us shape the future of Go! Take the 2026 Go Developer Survey

web

package
v0.4.7 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewWebFetchHTTP

func NewWebFetchHTTP(cfg WebFetchHTTPConfig) (agentkit.Tool, error)

func NewWebFetchScripted

func NewWebFetchScripted(cfg WebFetchScriptedConfig) (agentkit.Tool, error)

NewWebFetchScripted registers tool/web-fetch-scripted: Canned page bodies for tests and keyless smoke runs.

func NewWebSearchAuto added in v0.1.5

func NewWebSearchAuto(cfg WebSearchAutoConfig, deps WebSearchAutoDeps) (agentkit.Tool, error)

NewWebSearchAuto registers tool/web-search-auto: Tavily when keyed, otherwise DuckDuckGo (tool name: web_search).

func NewWebSearchDuckDuckGo added in v0.1.5

func NewWebSearchDuckDuckGo(cfg WebSearchDuckDuckGoConfig) (agentkit.Tool, error)

NewWebSearchDuckDuckGo registers tool/web-search-duckduckgo: Search via DuckDuckGo HTML (tool name: web_search).

No API key is required. Results come from html.duckduckgo.com and may be rate-limited by DuckDuckGo.

func NewWebSearchExa

func NewWebSearchExa(cfg WebSearchExaConfig, deps WebSearchExaDeps) (agentkit.Tool, error)

NewWebSearchExa registers tool/web-search-exa: Search the web through Exa (tool name: web_search).

Best practices:

  • A missing key is reported at call time, not at build time.
  • Search returns snippets; pair with tool/web-fetch-http when the model needs the full page.

func NewWebSearchScripted

func NewWebSearchScripted(cfg WebSearchScriptedConfig) (agentkit.Tool, error)

NewWebSearchScripted registers tool/web-search-scripted: Canned search results for tests and keyless smoke runs.

func NewWebSearchTavily added in v0.1.5

func NewWebSearchTavily(cfg WebSearchTavilyConfig, deps WebSearchTavilyDeps) (agentkit.Tool, error)

NewWebSearchTavily registers tool/web-search-tavily: Search the web through Tavily (tool name: web_search).

Best practices:

  • A missing key is reported at call time, not at build time.
  • Search returns snippets; pair with tool/web-fetch-http when the model needs the full page.

Types

type WebFetchHTTPConfig

type WebFetchHTTPConfig struct {
	// TimeoutSeconds is per-request wall clock; defaults to 30.
	TimeoutSeconds int `json:"timeoutSeconds,omitempty"`
	// MaxBytes is body read limit before extraction; defaults to 1 MiB.
	MaxBytes int `json:"maxBytes,omitempty"`
	// MaxRedirects is redirect chain limit; defaults to 5.
	MaxRedirects int `json:"maxRedirects,omitempty"`
	// UserAgent overrides the outgoing User-Agent.
	UserAgent string `json:"userAgent,omitempty"`
	// AllowPrivateHosts allows loopback / private / link-local targets; off by default.
	AllowPrivateHosts bool `json:"allowPrivateHosts,omitempty"`
	// AllowHosts, when non-empty, only these hosts (and their subdomains) may be fetched.
	AllowHosts []string `json:"allowHosts,omitempty"`
	// DenyHosts are hosts to refuse, applied after AllowHosts.
	DenyHosts []string `json:"denyHosts,omitempty"`
}

func (*WebFetchHTTPConfig) SetDefaults added in v0.3.48

func (c *WebFetchHTTPConfig) SetDefaults()

NewWebFetchHTTP registers tool/web-fetch-http: Fetch a URL over HTTP(S) and return readable text (tool name: web_fetch).

Best practices:

  • Needs no credentials, so it works without any API key.
  • Leave allowPrivateHosts off to block cloud metadata and internal admin endpoints.

SetDefaults implements pluginkit.Defaulter.

func (*WebFetchHTTPConfig) Validate added in v0.3.48

func (c *WebFetchHTTPConfig) Validate() error

Validate implements pluginkit.Validator.

type WebFetchInput

type WebFetchInput struct {
	URL string `json:"url" jsonschema:"Absolute http or https URL to fetch"`
	Raw bool   `json:"raw,omitempty" jsonschema:"Return the body as served instead of extracting readable text from HTML"`
}

type WebFetchOutput

type WebFetchOutput struct {
	URL         string `json:"url"`
	Status      int    `json:"status"`
	ContentType string `json:"contentType,omitempty"`
	Title       string `json:"title,omitempty"`
	Content     string `json:"content"`
	Truncated   bool   `json:"truncated,omitempty"`
}

type WebFetchScriptedConfig

type WebFetchScriptedConfig struct {
	// Pages maps URL substring to the HTML served for it.
	Pages map[string]string `json:"pages,omitempty"`
	// Default is body served when no Pages key matches; empty means not found.
	Default string `json:"default,omitempty"`
}

type WebSearchAutoConfig added in v0.1.5

type WebSearchAutoConfig struct {
	// MaxResults is cap on hits per call; defaults to 5.
	MaxResults int `json:"maxResults,omitempty"`
	// SnippetChars is snippet truncation limit; defaults to 800.
	SnippetChars int `json:"snippetChars,omitempty"`
	// Tavily holds Tavily provider settings; tried first when a key is available.
	Tavily WebSearchTavilyConfig `json:"tavily,omitempty"`
	// DuckDuckGo holds DuckDuckGo fallback settings.
	DuckDuckGo WebSearchDuckDuckGoConfig `json:"duckduckgo,omitempty"`
}

type WebSearchAutoDeps added in v0.1.5

type WebSearchAutoDeps struct {
	Credentials credentials.Store `json:"credentials,omitempty"`
}

type WebSearchDuckDuckGoConfig added in v0.1.5

type WebSearchDuckDuckGoConfig struct {
	// MaxResults is cap on hits per call; defaults to 5.
	MaxResults int `json:"maxResults,omitempty"`
	// TimeoutSeconds is per-request wall clock; defaults to 30.
	TimeoutSeconds int `json:"timeoutSeconds,omitempty"`
	// SnippetChars is snippet truncation limit; defaults to 800.
	SnippetChars int `json:"snippetChars,omitempty"`
}

type WebSearchExaConfig

type WebSearchExaConfig struct {
	// APIKeyRef is credential ref resolved via deps.credentials, e.g. "env:EXA_API_KEY".
	APIKeyRef string `json:"apiKeyRef,omitempty"`
	// APIKey is literal key; prefer APIKeyRef so the secret stays out of config files.
	APIKey string `json:"apiKey,omitempty"`
	// BaseURL overrides the API host; defaults to https://api.exa.ai.
	BaseURL string `json:"baseUrl,omitempty"`
	// MaxResults is cap on hits per call; defaults to 5.
	MaxResults int `json:"maxResults,omitempty"`
	// TimeoutSeconds is per-request wall clock; defaults to 30.
	TimeoutSeconds int `json:"timeoutSeconds,omitempty"`
	// Type is Exa search mode: auto (default), fast, instant, deep.
	Type string `json:"type,omitempty"`
	// Category narrows results, e.g. "news" or "research paper".
	Category string `json:"category,omitempty"`
	// IncludeText also requests page text; costs more tokens and money than highlights alone.
	IncludeText bool `json:"includeText,omitempty"`
	// SnippetChars is snippet truncation limit; defaults to 800.
	SnippetChars int `json:"snippetChars,omitempty"`
	// IncludeDomains restricts results to these domains.
	IncludeDomains []string `json:"includeDomains,omitempty"`
	// ExcludeDomains drops results from these domains.
	ExcludeDomains []string `json:"excludeDomains,omitempty"`
}

type WebSearchExaDeps

type WebSearchExaDeps struct {
	Credentials credentials.Store `json:"credentials,omitempty"`
}

type WebSearchHit

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

type WebSearchInput

type WebSearchInput struct {
	Query      string `json:"query" jsonschema:"What to search for, as a natural-language query"`
	MaxResults int    `json:"maxResults,omitempty" jsonschema:"Maximum hits to return"`
}

type WebSearchOutput

type WebSearchOutput struct {
	Query    string         `json:"query"`
	Provider string         `json:"provider,omitempty"`
	Results  []WebSearchHit `json:"results"`
}

type WebSearchScriptedConfig

type WebSearchScriptedConfig struct {
	// Results are hits returned for any query ByQuery does not match.
	Results []WebSearchHit `json:"results,omitempty"`
	// ByQuery maps case-insensitive query substring to hits; keep keys mutually exclusive.
	ByQuery map[string][]WebSearchHit `json:"byQuery,omitempty"`
	// MaxResults is default cap on hits per call when the model does not ask for one.
	MaxResults int `json:"maxResults,omitempty"`
}

type WebSearchTavilyConfig added in v0.1.5

type WebSearchTavilyConfig struct {
	// APIKeyRef is credential ref resolved via deps.credentials, e.g. "env:TAVILY_API_KEY".
	APIKeyRef string `json:"apiKeyRef,omitempty"`
	// APIKey is literal key; prefer APIKeyRef so the secret stays out of config files.
	APIKey string `json:"apiKey,omitempty"`
	// BaseURL overrides the API host; defaults to https://api.tavily.com.
	BaseURL string `json:"baseUrl,omitempty"`
	// MaxResults is cap on hits per call; defaults to 5.
	MaxResults int `json:"maxResults,omitempty"`
	// TimeoutSeconds is per-request wall clock; defaults to 30.
	TimeoutSeconds int `json:"timeoutSeconds,omitempty"`
	// SearchDepth is Tavily search mode: basic (default) or advanced.
	SearchDepth string `json:"searchDepth,omitempty"`
	// Topic narrows results, e.g. "general" or "news".
	Topic string `json:"topic,omitempty"`
	// IncludeAnswer also requests Tavily's synthesized answer; costs more tokens.
	IncludeAnswer bool `json:"includeAnswer,omitempty"`
	// SnippetChars is snippet truncation limit; defaults to 800.
	SnippetChars int `json:"snippetChars,omitempty"`
	// IncludeDomains restricts results to these domains.
	IncludeDomains []string `json:"includeDomains,omitempty"`
	// ExcludeDomains drops results from these domains.
	ExcludeDomains []string `json:"excludeDomains,omitempty"`
}

type WebSearchTavilyDeps added in v0.1.5

type WebSearchTavilyDeps struct {
	Credentials credentials.Store `json:"credentials,omitempty"`
}

Jump to

Keyboard shortcuts

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