tool_invocation

package
v0.1.0 Latest Latest
Warning

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

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

Documentation

Overview

Package tool_invocation provides a pipeline for routing tool invocations to appropriate backends (HTTP, registry) with sandboxing and timeout enforcement.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrUnsupportedToolType is returned for unknown tool types.
	ErrUnsupportedToolType = errors.New("tool_invocation: unsupported tool type")

	// ErrMissingToolName is returned when a tool name/URL is empty.
	ErrMissingToolName = errors.New("tool_invocation: tool name is required")

	// ErrNilHTTPClient is returned when HTTP tool is invoked without a configured client.
	ErrNilHTTPClient = errors.New("tool_invocation: HTTP client not configured")

	// ErrNilRegistryClient is returned when registry tool is invoked without a configured client.
	ErrNilRegistryClient = errors.New("tool_invocation: registry client not configured")
)

Functions

func WireHTTPFetch

func WireHTTPFetch(hf *wasm.HostFunctions, pipeline *ToolInvocationPipeline)

WireHTTPFetch connects the ToolInvocationPipeline to Wasm HostFunctions.HTTPFetch. After calling this, Wasm skills can make sandboxed HTTP requests via the host API.

Types

type ToolInvocation

type ToolInvocation struct {
	// Name is the tool name or URL.
	Name string

	// Type is the tool backend: "http", "registry".
	Type string

	// Arguments contains tool-specific parameters.
	Arguments map[string]any

	// Meta contains execution metadata for auditing.
	Meta ToolInvocationMeta
}

ToolInvocation represents a request to invoke a tool.

type ToolInvocationMeta

type ToolInvocationMeta struct {
	TenantID  string
	UserID    string
	RequestID string
	SessionID string
}

ToolInvocationMeta contains metadata for execution tracking.

type ToolInvocationPipeline

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

ToolInvocationPipeline routes tool invocations to the appropriate backend. Supported tool types: "http" (sandboxed HTTP via allowlist), "registry" (external registry).

func NewToolInvocationPipeline

func NewToolInvocationPipeline(
	httpClient *wasm.SandboxedHTTPClient,
	registryClient *toolrunner.RegistryClient,
	timeout time.Duration,
) *ToolInvocationPipeline

NewToolInvocationPipeline creates a new tool invocation pipeline. httpClient and registryClient may be nil; invoking a tool type with a nil client returns a descriptive error.

func (*ToolInvocationPipeline) Invoke

Invoke executes a tool invocation and returns the result.

type ToolResult

type ToolResult struct {
	Output     []byte
	StatusCode int
	Error      error
	Duration   time.Duration
}

ToolResult contains the output of a tool invocation.

Jump to

Keyboard shortcuts

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