Documentation
¶
Overview ¶
Package web hosts web tools: web_search (Tavily-backed) and web_fetch (HTTP GET + readable-text extraction).
Tools hold a *config.Config pointer captured at construction so their Execute methods can read the live FETCH_MAX_BYTES / TAVILY_API_KEY (mutated by the /config form) without falling back to a global singleton.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type FetchTool ¶
type FetchTool struct {
// contains filtered or unexported fields
}
FetchTool implements web_fetch — GET a URL, render readable text. The cfg pointer is read at Execute time so runtime mutations of FetchMaxBytes via the /config form take effect on the next call.
func NewFetch ¶
NewFetch builds a fetch tool bound to cfg. cfg may be nil — Execute falls back to the default 100k byte cap.
func (*FetchTool) Description ¶
func (*FetchTool) Schema ¶
func (t *FetchTool) Schema() json.RawMessage
type HTTPRequestTool ¶ added in v1.4.4
type HTTPRequestTool struct {
// contains filtered or unexported fields
}
HTTPRequestTool implements http_request: a generic HTTP client for driving JSON/HTTP APIs with structured input/output, instead of hand-built curl strings piped through jq/python. It is the general ergonomics primitive a swarm uses to operate an external HTTP system (Sunday's motivating case): the model gets the status code + parsed body directly, with no shell quoting.
Unlike web_fetch (which renders a page and treats non-2xx as an error), this returns the response for ANY status — a 4xx/409 body is exactly what an API client needs to read and react to (e.g. an optimistic-concurrency 409).
func NewHTTPRequest ¶ added in v1.4.4
func NewHTTPRequest(cfg *config.Config) *HTTPRequestTool
NewHTTPRequest builds an http_request tool bound to cfg. cfg may be nil — Execute falls back to the default 100k body cap.
func (*HTTPRequestTool) Description ¶ added in v1.4.4
func (t *HTTPRequestTool) Description() string
func (*HTTPRequestTool) Execute ¶ added in v1.4.4
func (t *HTTPRequestTool) Execute(ctx context.Context, logger *slog.Logger, input json.RawMessage) (tools.Result, error)
func (*HTTPRequestTool) Name ¶ added in v1.4.4
func (t *HTTPRequestTool) Name() string
func (*HTTPRequestTool) Schema ¶ added in v1.4.4
func (t *HTTPRequestTool) Schema() json.RawMessage
type SearchTool ¶
type SearchTool struct {
// contains filtered or unexported fields
}
SearchTool implements web_search via the Tavily API. The cfg pointer is read at Execute time so the /config form's TavilyAPIKey rotation takes effect on the next call.
func NewSearch ¶
func NewSearch(cfg *config.Config) *SearchTool
NewSearch builds a search tool bound to cfg. cfg may be nil — Execute surfaces a "not configured" error when no API key is reachable.
func (*SearchTool) Description ¶
func (t *SearchTool) Description() string
func (*SearchTool) Execute ¶
func (t *SearchTool) Execute(ctx context.Context, logger *slog.Logger, input json.RawMessage) (tools.Result, error)
func (*SearchTool) Name ¶
func (t *SearchTool) Name() string
func (*SearchTool) Schema ¶
func (t *SearchTool) Schema() json.RawMessage