fetch

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package fetch implements the Fetch tool: one bounded HTTP GET or POST via an injected *http.Client, with no filesystem access. Preparation validates the URL once and emits one shared `network` capability requirement for the resolved endpoint — the same capability kind Bash network deltas and WebSearch use, so one saved workspace rule covers all three.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Fetch

type Fetch struct {
	// contains filtered or unexported fields
}

Fetch performs a single bounded HTTP request using an injected client. It has no filesystem access (least privilege).

func NewFetch

func NewFetch(client *http.Client) *Fetch

NewFetch constructs a Fetch tool bound to an injected *http.Client. The client is expected to carry an explicit Timeout and a TLS 1.2+ Transport (wired at the composition root / manifest). Fetch never constructs a client itself.

func (*Fetch) AuditSummary

func (f *Fetch) AuditSummary(argsJSON string) string

AuditSummary returns "<METHOD> <host>" ONLY — never the path, query, headers, or body (CLAUDE.md: log events, not secrets). An unparseable args document or an unparseable URL yields a generic, secret-free summary.

func (*Fetch) Info

func (f *Fetch) Info(context.Context) (*tool.ToolInfo, error)

Info returns Fetch's self-description. Name MUST equal "Fetch".

func (*Fetch) InvokableRun

func (f *Fetch) InvokableRun(ctx context.Context, _ string) (*tool.ToolResult, error)

InvokableRun executes the PREPARED artifact bound to this call — the raw argsJSON is never reparsed; without its artifact the tool fails closed. It performs the normalized request and returns status + header summary + capped body as a tool result. A redirect to any target not covered by the approved requirement (same scheme, host, AND port) is refused, never silently followed. Every failure maps to a tool-result error STRING; it never returns a Go error and never leaks the path/query/headers/body into an error.

func (*Fetch) PrepareCall

func (f *Fetch) PrepareCall(_ context.Context, executionID uuid.UUID, argsJSON string) (tool.Request, tool.PreparedArtifact, error)

PrepareCall decodes, validates, and normalizes one Fetch call — method, scheme, host, and port are normalized ONCE here — and emits the ONE shared `network` capability requirement for the target. The grant pair is EMPTY: Fetch is a direct tool and enforces the approved target itself, including refusing any redirect off it at run time. Durable v1 network rules are host/port-scoped (network.target.v1); HTTP method/path precision needs the Fetch-specific enforcement class the spec defers, so no narrower claim is encoded here.

Jump to

Keyboard shortcuts

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