tool

package
v0.1.0 Latest Latest
Warning

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

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

Documentation

Overview

Package tool defines the unit of capability an agent execution node can invoke. A tool is a function over bytes plus a Runtime; it knows nothing about sandboxing, scheduling, or metrics. The control plane composes those concerns around it: the workspace view a tool receives is already scoped to its policy's areas, and the tasks it spawns are gated by its policy's spawn allowlist.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Registry

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

Registry holds the tools a deployment may dispatch to. It is safe for concurrent use.

func NewRegistry

func NewRegistry() *Registry

NewRegistry returns an empty registry.

func (*Registry) Get

func (r *Registry) Get(name string) (Tool, bool)

Get returns the tool registered under name.

func (*Registry) Names

func (r *Registry) Names() []string

Names returns all registered tool names in lexical order.

func (*Registry) Register

func (r *Registry) Register(t Tool) error

Register adds t to the registry. Registering a duplicate name is an error so a tool cannot silently shadow another.

type Runtime

type Runtime interface {
	// Workspace returns the tool's sandboxed view of the shared workspace.
	Workspace() workspace.Workspace
	// Spawn submits a sub-task back into the tool's own deployment and
	// returns its task ID without waiting for the result. This is how an
	// agent calls another agent: the child task competes for a node like
	// any other work. The policy's spawn allowlist gates which tools may
	// be targeted; the default is none.
	Spawn(ctx context.Context, t task.Task) (string, error)
}

Runtime is the capability surface a tool executes against. Both methods are confined by the tool's sandbox policy before the tool ever sees them.

type Tool

type Tool interface {
	// Name uniquely identifies the tool within a registry and is the key
	// its sandbox policy binds to.
	Name() string
	// Call executes the tool with input against rt.
	Call(ctx context.Context, rt Runtime, input []byte) ([]byte, error)
}

Tool is one named capability.

func Func

func Func(name string, fn func(ctx context.Context, rt Runtime, input []byte) ([]byte, error)) Tool

Func adapts a plain function into a Tool.

Jump to

Keyboard shortcuts

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