toolkit

package
v0.0.0-...-17a0321 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2026 License: BSD-3-Clause Imports: 17 Imported by: 0

Documentation

Overview

Package toolkit defines the runtime Tool and ToolKit model used by agents.

Tools are persisted configuration resources backed directly by pkgs/store/kv. A ToolKit is a per-agent runtime view filtered by RuntimeProfile, ownership, enabled state, optional workspace policy, and executor availability.

Index

Constants

View Source
const (
	MaxHTTPTimeout       = 60 * time.Second
	MaxHTTPResponseBytes = 4 << 20
)

Variables

View Source
var (
	ErrNotConfigured = errors.New("toolkit: not configured")
	ErrInvalidTool   = errors.New("toolkit: invalid tool")
	ErrToolNotFound  = errors.New("toolkit: tool not found")
)

Functions

func NormalizePolicy

func NormalizePolicy(policy *apitypes.ToolkitPolicy) (*apitypes.ToolkitPolicy, error)

NormalizePolicy validates and returns a copy of a ToolKit exposure policy.

func ToRedactedSpec

func ToRedactedSpec(tool Tool) (apitypes.ToolSpec, error)

ToRedactedSpec returns the Admin read representation without direct secrets.

func ToSpec

func ToSpec(tool Tool) (apitypes.ToolSpec, error)

Types

type BuildRequest

type BuildRequest struct {
	CallerPublicKey string
	ProfileTools    []string
	AllowedTools    []string
	RestrictTools   bool
}

type Builder

type Builder struct {
	Tools *Server
}

func (*Builder) Build

func (b *Builder) Build(ctx context.Context, req BuildRequest) (ToolKit, error)

func (*Builder) ResolveInvoke

func (b *Builder) ResolveInvoke(ctx context.Context, req InvokeRequest) (Tool, json.RawMessage, error)

ResolveInvoke re-reads and reauthorizes a Tool immediately before dispatch.

type HTTPArgumentBinding

type HTTPArgumentBinding struct {
	ArgumentPointer string `json:"argument_pointer"`
	Target          string `json:"target"`
	Required        bool   `json:"required"`
}

type HTTPAuth

type HTTPAuth struct {
	Method      string  `json:"method"`
	BearerToken *string `json:"bearer_token,omitempty"`
	Header      *string `json:"header,omitempty"`
	APIKey      *string `json:"api_key,omitempty"`
	Credential  *string `json:"credential,omitempty"`
	Region      *string `json:"region,omitempty"`
	Service     *string `json:"service,omitempty"`
	Action      *string `json:"action,omitempty"`
	Version     *string `json:"version,omitempty"`
}

type HTTPRequest

type HTTPRequest struct {
	URL                string                `json:"url"`
	Method             string                `json:"method"`
	Auth               HTTPAuth              `json:"auth"`
	Headers            map[string]string     `json:"headers,omitempty"`
	Query              []HTTPArgumentBinding `json:"query,omitempty"`
	Body               []HTTPArgumentBinding `json:"body,omitempty"`
	ResponsePointer    *string               `json:"response_pointer,omitempty"`
	SuccessStatusCodes []int                 `json:"success_status_codes,omitempty"`
	Timeout            time.Duration         `json:"timeout"`
	MaxResponseBytes   int64                 `json:"max_response_bytes"`
}

type InvokeRequest

type InvokeRequest struct {
	Build BuildRequest
	Name  string
	Args  json.RawMessage
}

type Server

type Server struct {
	Store kv.Store
	Now   func() time.Time
}

func (*Server) DeleteTool

func (s *Server) DeleteTool(ctx context.Context, name string) error

func (*Server) GetTool

func (s *Server) GetTool(ctx context.Context, name string) (Tool, error)

func (*Server) ListTools

func (s *Server) ListTools(ctx context.Context) ([]Tool, error)

func (*Server) PutTool

func (s *Server) PutTool(ctx context.Context, tool Tool) (Tool, error)

type Tool

type Tool struct {
	Name        string            `json:"name"`
	Type        ToolType          `json:"type"`
	Description *string           `json:"description,omitempty"`
	Enabled     bool              `json:"enabled"`
	Version     *string           `json:"version,omitempty"`
	InputSchema jsonschema.Schema `json:"input_schema"`
	Triggers    []ToolTrigger     `json:"triggers,omitempty"`
	Metadata    json.RawMessage   `json:"metadata,omitempty"`
	HTTP        *HTTPRequest      `json:"http,omitempty"`
	CreatedAt   time.Time         `json:"created_at"`
	UpdatedAt   time.Time         `json:"updated_at"`
}

Tool is the persisted configuration for one canonically named capability.

func FromSpec

func FromSpec(name string, spec apitypes.ToolSpec) (Tool, error)

func MergeDirectSecrets

func MergeDirectSecrets(desired, existing Tool) (Tool, error)

MergeDirectSecrets retains omitted direct secrets only when the auth method is unchanged. It returns an independently owned, executable declaration.

func NormalizeTool

func NormalizeTool(tool Tool) (Tool, error)

type ToolKit

type ToolKit struct {
	Tools []Tool
}

func (ToolKit) Find

func (tk ToolKit) Find(name string) (Tool, bool)

type ToolTrigger

type ToolTrigger struct {
	Name        string               `json:"name"`
	Description *string              `json:"description,omitempty"`
	Patterns    []string             `json:"patterns,omitempty"`
	Examples    []ToolTriggerExample `json:"examples,omitempty"`
	Metadata    json.RawMessage      `json:"metadata,omitempty"`
}

type ToolTriggerExample

type ToolTriggerExample struct {
	Input  string          `json:"input"`
	Args   json.RawMessage `json:"args,omitempty"`
	Output *string         `json:"output,omitempty"`
}

type ToolType

type ToolType string
const (
	ToolTypeHTTPRequest ToolType = "http_request"
	ToolTypeClientRPC   ToolType = "client_rpc"
)

Jump to

Keyboard shortcuts

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