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 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 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.