Documentation
¶
Overview ¶
Package web provides portable Web Search, Fetch, OpenPage and FindInPage tools.
The package owns provider protocols, extraction, caching and model-facing coordination. A Host must inject a retrieval.Preparer and remains the sole owner of outbound policy, proxy, redirect validation, credentials and audit persistence.
Index ¶
- Constants
- func FindInPageDefinition() toolcontract.Definition
- func NewFetchHandler(opts FetchOptions) toolcontract.Handler
- func NewFindInPageHandler() toolcontract.Handler
- func NewOpenPageHandler(opts FetchOptions) toolcontract.Handler
- func NewSearchHandler(name string, opts SearchOptions) toolcontract.Handler
- func OpenPageDefinition() toolcontract.Definition
- func Register(reg toolcontract.Registrar, opts Options)
- func RegisterFetch(reg toolcontract.Registrar, opts FetchOptions)
- func RegisterFindInPage(reg toolcontract.Registrar)
- func RegisterOpenPage(reg toolcontract.Registrar, opts FetchOptions)
- func RegisterSearch(reg toolcontract.Registrar, opts SearchOptions)
- func RunFetch(ctx context.Context, request FetchRequest, opts FetchOptions) (retrieval.WebFetchExecutionResult, error)
- func RunFindInPage(request FindRequest) retrieval.FindInPageResult
- func RunOpenPage(ctx context.Context, request FetchRequest, opts FetchOptions) (retrieval.Page, bool, error)
- func RunSearch(ctx context.Context, request SearchRequest, opts SearchOptions) (retrieval.SearchPayload, error)
- func SearchDefinition() toolcontract.Definition
- func WebFetchDefinition() toolcontract.Definition
- func WebSearchDefinition() toolcontract.Definition
- type FetchOptions
- type FetchRequest
- type FindRequest
- type Options
- type ProviderConfig
- type SearchOptions
- type SearchRequest
Constants ¶
const ( SearchName = "search" WebSearchName = "web_search" WebFetchName = "web_fetch" OpenPageName = "open_page" FindInPageName = "find_in_page" )
Variables ¶
This section is empty.
Functions ¶
func FindInPageDefinition ¶
func FindInPageDefinition() toolcontract.Definition
FindInPageDefinition returns the cache-only page search schema.
func NewFetchHandler ¶
func NewFetchHandler(opts FetchOptions) toolcontract.Handler
NewFetchHandler returns a model-facing web_fetch handler.
func NewFindInPageHandler ¶
func NewFindInPageHandler() toolcontract.Handler
NewFindInPageHandler returns a cache-only find_in_page handler.
func NewOpenPageHandler ¶
func NewOpenPageHandler(opts FetchOptions) toolcontract.Handler
NewOpenPageHandler returns a model-facing open_page handler.
func NewSearchHandler ¶
func NewSearchHandler(name string, opts SearchOptions) toolcontract.Handler
NewSearchHandler returns a model-facing search handler.
func OpenPageDefinition ¶
func OpenPageDefinition() toolcontract.Definition
OpenPageDefinition returns the readable-page schema.
func Register ¶
func Register(reg toolcontract.Registrar, opts Options)
Register adds all web tools whose required Host ports are configured.
func RegisterFetch ¶
func RegisterFetch(reg toolcontract.Registrar, opts FetchOptions)
RegisterFetch adds the low-level web_fetch tool.
func RegisterFindInPage ¶
func RegisterFindInPage(reg toolcontract.Registrar)
RegisterFindInPage adds the cache-only page search tool.
func RegisterOpenPage ¶
func RegisterOpenPage(reg toolcontract.Registrar, opts FetchOptions)
RegisterOpenPage adds the readable-page tool.
func RegisterSearch ¶
func RegisterSearch(reg toolcontract.Registrar, opts SearchOptions)
RegisterSearch adds search and web_search aliases.
func RunFetch ¶
func RunFetch(ctx context.Context, request FetchRequest, opts FetchOptions) (retrieval.WebFetchExecutionResult, error)
RunFetch executes direct retrieval and extraction.
func RunFindInPage ¶
func RunFindInPage(request FindRequest) retrieval.FindInPageResult
RunFindInPage searches a cached page without network access.
func RunOpenPage ¶
func RunOpenPage(ctx context.Context, request FetchRequest, opts FetchOptions) (retrieval.Page, bool, error)
RunOpenPage fetches a readable page and stores it for FindInPage.
func RunSearch ¶
func RunSearch(ctx context.Context, request SearchRequest, opts SearchOptions) (retrieval.SearchPayload, error)
RunSearch executes a configured provider without environment discovery or implicit product fallback policy.
func SearchDefinition ¶
func SearchDefinition() toolcontract.Definition
SearchDefinition returns the preferred web search schema.
func WebFetchDefinition ¶
func WebFetchDefinition() toolcontract.Definition
WebFetchDefinition returns the low-level fetch schema.
func WebSearchDefinition ¶
func WebSearchDefinition() toolcontract.Definition
WebSearchDefinition returns the compatibility web_search schema.
Types ¶
type FetchOptions ¶
type FetchOptions struct {
Prepare retrieval.Preparer
ClassifyNetworkError retrieval.NetworkErrorClassifier
TimeoutMs int
MaxChars int
MaxResponseBytes int
MaxRedirects int
CacheTTL time.Duration
UserAgent string
RequestSignature string
Firecrawl retrieval.WebFetchFirecrawlConfig
}
FetchOptions configures direct page retrieval and optional Firecrawl fallback.
type FetchRequest ¶
type FetchRequest struct {
URL string `json:"url"`
MaxChars int `json:"max_chars,omitempty"`
MaxResponseBytes int `json:"max_response_bytes,omitempty"`
TimeoutMs int `json:"timeout_ms,omitempty"`
ExtractMode string `json:"extract_mode,omitempty"`
}
FetchRequest is the Go-facing input shared by WebFetch and OpenPage.
type FindRequest ¶
type FindRequest struct {
PageID string `json:"page_id"`
Query string `json:"query"`
MaxMatches int `json:"max_matches,omitempty"`
ContextChars int `json:"context_chars,omitempty"`
}
FindRequest searches a page previously cached by OpenPage.
type Options ¶
type Options struct {
Search SearchOptions
Fetch FetchOptions
}
Options configures the complete portable web tool cohort.
type ProviderConfig ¶
ProviderConfig explicitly supplies one search provider's credentials and endpoint. This package never discovers credentials from the environment.
type SearchOptions ¶
type SearchOptions struct {
DefaultProvider string
Providers map[string]ProviderConfig
Prepare retrieval.Preparer
ClassifyNetworkError retrieval.NetworkErrorClassifier
Audit func(retrieval.SearchAuditEvent)
TimeoutMs int
CacheTTL time.Duration
TrustedProxyVariant bool
}
SearchOptions configures the portable provider protocol implementation.
type SearchRequest ¶
type SearchRequest struct {
Query string `json:"query"`
Provider string `json:"provider,omitempty"`
MaxResults int `json:"max_results,omitempty"`
Count int `json:"count,omitempty"`
Country string `json:"country,omitempty"`
SearchLang string `json:"search_lang,omitempty"`
UILang string `json:"ui_lang,omitempty"`
Freshness string `json:"freshness,omitempty"`
DateAfter string `json:"date_after,omitempty"`
DateBefore string `json:"date_before,omitempty"`
DomainFilter []string `json:"domain_filter,omitempty"`
TimeoutMs int `json:"timeout_ms,omitempty"`
}
SearchRequest is the model- and Go-facing portable search input.