Help us shape the future of Go! Take the 2026 Go Developer Survey

tools

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2026 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Overview

Package tools implements the seat tool surface (contracts.md "Tools"). Every call is authorised server-side against the seat's committed policy revision, which is re-read for each call, so a sync that revokes a grant takes effect on the next call (A13). Mutating tools are fenced on the caller's lease generation inside the write transaction.

Index

Constants

View Source
const (
	WorkReady      = "ready"
	WorkInProgress = "in_progress"
	WorkInReview   = "in_review"
	WorkBlocked    = "blocked"
	WorkDone       = "done"
	WorkCancelled  = "cancelled"
)

Work statuses.

View Source
const (
	StepPending    = "pending"
	StepInProgress = "in_progress"
	StepCompleted  = "completed"
)

Plan step statuses (at most one in_progress).

View Source
const MaxResultBytes = 16 << 10

MaxResultBytes bounds a tool result (ADR-0006).

Variables

View Source
var (
	// ErrUnknownTool means no tool has the requested name.
	ErrUnknownTool = errors.New("unknown tool")
	// ErrFenced means a mutating call lacked the current lease generation.
	ErrFenced = store.ErrFenced
)

Functions

func OwnedWork added in v0.2.0

func OwnedWork(ctx context.Context, st *store.Store, seat *store.Seat) ([]runtimeapi.WorkSummary, error)

OwnedWork lists the unfinished work items a seat owns in the stores it can read, for its recovery context.

func Self

func Self(seat *store.Seat, org *store.Organization) runtimeapi.Self

Self describes the seat from its committed manifest.

Types

type Call

type Call struct {
	Seat *store.Seat
	Org  *store.Organization
	// Generation is the caller's lease generation; HasGeneration is false
	// when the header was absent.
	Generation    int64
	HasGeneration bool
	ExecutionID   string
	Args          json.RawMessage
}

Call is one authenticated tool invocation.

type Deps

type Deps struct {
	Store   *store.Store
	Gateway *gateway.Gateway
	Metrics *metrics.Metrics
	Log     *slog.Logger
}

Deps are the services tools use.

type Error

type Error struct {
	Code    string         `json:"error"`
	Message string         `json:"message"`
	Details map[string]any `json:"details,omitempty"`
}

Error is a tool-level failure returned to the agent as an error result.

func (*Error) Error

func (e *Error) Error() string

type Registry

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

Registry holds the tools.

func New

func New(d Deps) *Registry

New returns the registry of all platform tools.

func (*Registry) Call

func (r *Registry) Call(ctx context.Context, name string, c *Call) (runtimeapi.ToolCallResult, error)

Call runs a tool. Tool-level failures (denied, conflict, invalid) are returned as error results; fencing and internal failures as errors.

func (*Registry) List

List returns the descriptors of the tools the seat may use.

Jump to

Keyboard shortcuts

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