urlfetch

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package urlfetch provides an Eino-compatible tool for fetching the raw text content of a file:// or https:// URL.

Unlike the fileops tools, urlfetch intentionally reaches outside any workspace boundary. The canonical use case is loading documentation assets from absolute filesystem paths (e.g. ~/docs/learning-output-style/index.html) or from HTTPS endpoints. The absence of workspace containment is deliberate; reviewers should not flag it as an oversight.

Result preserves the original decoded JSON object in RawJSON so consumers can inspect unknown top-level fields added by future versions. RawJSON is never emitted when marshaling results produced by this package.

Index

Constants

View Source
const (
	ErrCategoryValidation = "validation"
	ErrCategoryNotFound   = "not_found"
	ErrCategoryIO         = "io"
	ErrCategoryNetwork    = "network"
	ErrCategoryCanceled   = "canceled"
	ErrCategoryUnknown    = "unknown"
)
View Source
const Name = "url_fetch"

Name is the model-facing tool name.

Variables

This section is empty.

Functions

func Schema

func Schema() json.RawMessage

Schema returns a fresh JSON Schema copy for urlfetch arguments.

Types

type Args

type Args struct {
	URL string `json:"url"`
}

Args is the parsed input shape for the tool.

type Options

type Options struct {
	// HTTPClient overrides the default HTTP client used for https:// requests.
	// If nil, a client with a 30-second timeout is used.
	HTTPClient *http.Client
}

Options configures urlfetch tool behavior that is intentionally owned by the caller rather than hidden inside the tool.

type Result

type Result struct {
	Outcome result.Outcome  `json:"outcome"`
	Content string          `json:"content,omitempty"`
	Error   *ResultError    `json:"error,omitempty"`
	RawJSON json.RawMessage `json:"-"`
}

Result is the structured envelope returned to the model.

func (Result) IsRetryable

func (r Result) IsRetryable() bool

IsRetryable reports whether the agent loop should retry the same call.

func (*Result) UnmarshalJSON

func (r *Result) UnmarshalJSON(raw []byte) error

UnmarshalJSON decodes Result and preserves the original object in RawJSON.

type ResultError

type ResultError struct {
	Category string `json:"category"`
	Message  string `json:"message"`
}

ResultError is the structured failure envelope nested inside Result.

type Tool

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

Tool fetches URL content.

func New

func New(opts ...Options) (*Tool, error)

New constructs a Tool.

func (*Tool) Info

func (t *Tool) Info(_ context.Context) (*schema.ToolInfo, error)

Info returns the Eino ToolInfo for urlfetch.

func (*Tool) InvokableRun

func (t *Tool) InvokableRun(ctx context.Context, argsJSON string, _ ...tool.Option) (string, error)

InvokableRun is the Eino tool entry point.

func (*Tool) Run

func (t *Tool) Run(ctx context.Context, args Args) Result

Run executes the tool with parsed args.

Jump to

Keyboard shortcuts

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