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 ¶
const ( WorkReady = "ready" WorkInProgress = "in_progress" WorkInReview = "in_review" WorkBlocked = "blocked" WorkDone = "done" WorkCancelled = "cancelled" )
Work statuses.
const ( StepPending = "pending" StepInProgress = "in_progress" StepCompleted = "completed" )
Plan step statuses (at most one in_progress).
const MaxResultBytes = 16 << 10
MaxResultBytes bounds a tool result (ADR-0006).
Variables ¶
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.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry holds the 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 ¶
func (r *Registry) List(seat *store.Seat, org *store.Organization) []runtimeapi.ToolDescriptor
List returns the descriptors of the tools the seat may use.