toolregistry

package
v0.2.6 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2026 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CatalogSchemaV1      = protocol.ToolCatalogSchemaVersion
	FeatureDomainEpochV1 = protocol.FeatureDomainEpochV1
	FeatureToolCatalogV1 = protocol.FeatureToolCatalogV1
	ContractStrict       = "strict"
	ContractLegacy       = "legacy"
)

Variables

View Source
var (
	ErrCatalogHashMismatch = errors.New("tool catalog hash mismatch")
	ErrCacheInvalid        = errors.New("tool catalog cache is invalid")
	ErrCacheMiss           = errors.New("tool catalog cache miss")
	ErrUnsupportedProfile  = errors.New("tool profile is unsupported")
)

Functions

func IsNormalProfile

func IsNormalProfile(profile string) bool

func IsSeedProfile

func IsSeedProfile(profile string) bool

func ProjectID

func ProjectID(projectPath string) (string, error)

func ToolHasArbitraryCode

func ToolHasArbitraryCode(tool Tool) bool

Types

type Action

type Action struct {
	Name         string          `json:"name"`
	Description  string          `json:"description"`
	Aliases      []string        `json:"aliases"`
	InputSchema  json.RawMessage `json:"input_schema"`
	OutputSchema json.RawMessage `json:"output_schema"`
	Safety       Safety          `json:"safety"`
}

type CacheKey

type CacheKey struct {
	ProjectID   string   `json:"project_id"`
	Features    []string `json:"features"`
	DomainEpoch string   `json:"domain_epoch"`
	CatalogHash string   `json:"catalog_hash"`
}

func (CacheKey) String

func (key CacheKey) String() string

type CacheOptions

type CacheOptions struct {
	Root                 string
	MaxEntriesPerProject int
	Schemas              *schema.CompilerCache
}

type Catalog

type Catalog struct {
	SchemaVersion string `json:"schema_version"`
	CatalogHash   string `json:"catalog_hash"`
	DomainEpoch   string `json:"domain_epoch"`
	ProjectID     string `json:"project_id"`
	Tools         []Tool `json:"tools"`
}

func ParseCatalog

func ParseCatalog(data []byte) (*Catalog, error)

func (*Catalog) SchemaDefinitions

func (catalog *Catalog) SchemaDefinitions() []schema.Definition

func (*Catalog) ToolsForProfile

func (catalog *Catalog) ToolsForProfile(profile string) ([]Tool, error)

type CatalogCache

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

func NewCatalogCache

func NewCatalogCache(options CacheOptions) *CatalogCache

func (*CatalogCache) Load

func (cache *CatalogCache) Load(key CacheKey) (*Catalog, error)

func (*CatalogCache) LoadMatching

func (cache *CatalogCache) LoadMatching(lookup CacheKey) (*Catalog, CacheKey, error)

func (*CatalogCache) Store

func (cache *CatalogCache) Store(key CacheKey, catalog *Catalog) error

type Example

type Example struct {
	Call        string `json:"call"`
	Description string `json:"description"`
}

type Exposure

type Exposure string
const (
	ExposureProfile     Exposure = "profile"
	ExposureCompactOnly Exposure = "compact_only"
)

type LegacyProvider

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

func NewLegacyProvider

func NewLegacyProvider(sender Sender) *LegacyProvider

func (*LegacyProvider) Load

func (provider *LegacyProvider) Load(
	ctx context.Context,
	instance *client.Instance,
) (*Snapshot, error)

type Provider

type Provider interface {
	Load(context.Context, *client.Instance) (*Snapshot, error)
}

type ProviderError

type ProviderError struct {
	Code    string
	Message string
}

func (*ProviderError) Error

func (err *ProviderError) Error() string

type Registry

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

func NewRegistry

func NewRegistry(options RegistryOptions) *Registry

func (*Registry) Load

func (registry *Registry) Load(
	ctx context.Context,
	instance *client.Instance,
) (*Snapshot, error)

type RegistryOptions

type RegistryOptions struct {
	Sender  Sender
	Cache   *CatalogCache
	Schemas *schema.CompilerCache
}

type Safety

type Safety struct {
	RiskClass            string       `json:"risk_class"`
	ReadOnly             bool         `json:"read_only"`
	Destructive          bool         `json:"destructive"`
	Idempotent           bool         `json:"idempotent"`
	MayReloadDomain      bool         `json:"may_reload_domain"`
	RequiresPlayMode     bool         `json:"requires_play_mode"`
	RequiresConfirmation bool         `json:"requires_confirmation"`
	Reversible           bool         `json:"reversible"`
	SupportsCancellation bool         `json:"supports_cancellation"`
	SideEffectScope      string       `json:"side_effect_scope"`
	Rules                []SafetyRule `json:"rules"`
}

type SafetyRule

type SafetyRule struct {
	Operation string          `json:"operation"`
	When      json.RawMessage `json:"when"`
	Safety
}

type Sender

type Sender interface {
	Send(
		context.Context,
		*client.Instance,
		string,
		any,
		int,
	) (*client.CommandResponse, error)
}

type Snapshot

type Snapshot struct {
	Catalog   *Catalog
	Schemas   *schema.CompiledCatalog
	Exposure  Exposure
	FromCache bool
}

type Source

type Source struct {
	Kind     string `json:"kind"`
	Assembly string `json:"assembly"`
	Type     string `json:"type"`
}

type Tool

type Tool struct {
	Name         string          `json:"name"`
	Title        string          `json:"title"`
	Description  string          `json:"description"`
	Source       Source          `json:"source"`
	ContractMode string          `json:"contract_mode"`
	Profiles     []string        `json:"profiles"`
	Aliases      []string        `json:"aliases"`
	Examples     []Example       `json:"examples"`
	InputSchema  json.RawMessage `json:"input_schema"`
	OutputSchema json.RawMessage `json:"output_schema"`
	Actions      []Action        `json:"actions"`
	Safety       Safety          `json:"safety"`
}

type UnityProvider

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

func NewUnityProvider

func NewUnityProvider(sender Sender) *UnityProvider

func (*UnityProvider) Load

func (provider *UnityProvider) Load(
	ctx context.Context,
	instance *client.Instance,
) (*Snapshot, error)

Jump to

Keyboard shortcuts

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