capability

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2026 License: MIT Imports: 33 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CredentialFault

func CredentialFault(err error) error

CredentialFault converts a deliberately redacted credential error into the common machine-readable envelope. Backend stderr never becomes a cause.

func Encode

func Encode(data any, err error) []byte

func ErrorDetails

func ErrorDetails(err error) (code, hint string)

func InvalidArgument

func InvalidArgument(message string) error

func NewFault

func NewFault(code, message, hint string, cause error) error

func OAuthManager

func OAuthManager(name string, p ProviderConfig, store credentials.Store) (*oauthclient.Manager, error)

func ValidateSearchAliases

func ValidateSearchAliases(aliases map[string][]string) error

Types

type ActionMetrics

type ActionMetrics struct {
	Count          uint64  `json:"count"`
	Errors         uint64  `json:"errors"`
	Inflight       uint64  `json:"inflight"`
	DurationMillis float64 `json:"duration_ms"`
}

type CallPlan

type CallPlan struct {
	Target       string         `json:"target"`
	Args         map[string]any `json:"args"`
	ContractHash string         `json:"contractHash"`
	Contract     Capability     `json:"contract"`
	Valid        bool           `json:"valid"`
	Invoked      bool           `json:"invoked"`
}

type Capability

type Capability struct {
	ID           string `json:"id"`
	Description  string `json:"description,omitempty"`
	Protocol     string `json:"protocol"`
	InputSchema  any    `json:"inputSchema,omitempty"`
	OutputSchema any    `json:"outputSchema,omitempty"`
	Annotations  any    `json:"annotations,omitempty"`
}

type Config

type Config struct {
	SchemaVersion int                               `json:"schema_version,omitempty"`
	Providers     map[string]ProviderConfig         `json:"providers"`
	Credentials   map[string]credentials.Definition `json:"credentials,omitempty"`
	SearchAliases map[string][]string               `json:"search_aliases,omitempty"`
}

func LoadConfig

func LoadConfig(path string) (c Config, err error)

func LoadConfigContext

func LoadConfigContext(ctx context.Context, path string) (c Config, err error)

type DiscoveryFailure

type DiscoveryFailure struct {
	Provider string `json:"provider"`
	Code     string `json:"code"`
	Hint     string `json:"hint"`
}

type DiscoveryResult

type DiscoveryResult struct {
	Items    []Capability       `json:"items"`
	Complete bool               `json:"complete"`
	Failures []DiscoveryFailure `json:"failures"`
}

type Envelope

type Envelope struct {
	OK    bool   `json:"ok"`
	Data  any    `json:"data,omitempty"`
	Error string `json:"error,omitempty"`
	Code  string `json:"code,omitempty"`
	Hint  string `json:"hint,omitempty"`
}

type Fault

type Fault struct {
	Code, Message, Hint string
	Cause               error
}

Fault adds a stable code and recovery hint while preserving the original cause.

func (*Fault) Error

func (e *Fault) Error() string

func (*Fault) Unwrap

func (e *Fault) Unwrap() error

type HTTPResult

type HTTPResult struct {
	Status      int    `json:"status"`
	ContentType string `json:"contentType,omitempty"`
	Body        any    `json:"body"`
}

type Provider

type Provider interface {
	Discover(context.Context) ([]Capability, error)
	Invoke(context.Context, string, map[string]any) (any, error)
	Close() error
}

type ProviderConfig

type ProviderConfig struct {
	Type              string              `json:"type"`
	Transport         string              `json:"transport,omitempty"`
	Command           []string            `json:"command,omitempty"`
	URL               string              `json:"url,omitempty"`
	Spec              string              `json:"spec,omitempty"`
	Headers           map[string]string   `json:"headers,omitempty"`
	Env               map[string]string   `json:"env,omitempty"`
	Allow             []string            `json:"allow,omitempty"`
	Description       string              `json:"description,omitempty"`
	Keywords          []string            `json:"keywords,omitempty"`
	SkillFiles        []string            `json:"skill_files,omitempty"`
	SkillDescriptions []string            `json:"skill_descriptions,omitempty"`
	BearerCredential  string              `json:"bearer_credential,omitempty"`
	HeaderCredentials map[string]string   `json:"header_credentials,omitempty"`
	EnvCredentials    map[string]string   `json:"env_credentials,omitempty"`
	OAuth             *oauthclient.Config `json:"oauth,omitempty"`
	OAuthProfile      string              `json:"-"`
	CatalogSource     string              `json:"catalog_source,omitempty"`
	// contains filtered or unexported fields
}

type ProviderSummary

type ProviderSummary struct {
	Name        string `json:"name"`
	Type        string `json:"type"`
	Description string `json:"description,omitempty"`
}

type Request

type Request struct {
	Action           string              `json:"action"`
	Target           string              `json:"target,omitempty"`
	Query            string              `json:"query,omitempty"`
	Args             map[string]any      `json:"args,omitempty"`
	Method           string              `json:"method,omitempty"`
	Path             string              `json:"path,omitempty"`
	Limit            int                 `json:"limit,omitempty"`
	Match            string              `json:"match,omitempty"`
	Full             bool                `json:"full,omitempty"`
	BestEffort       bool                `json:"bestEffort,omitempty"`
	Refresh          bool                `json:"refresh,omitempty"`
	ProvidersOnly    bool                `json:"providersOnly,omitempty"`
	AllTools         bool                `json:"allTools,omitempty"`
	ExpectedContract string              `json:"expectedContract,omitempty"`
	HTTPQuery        map[string][]string `json:"httpQuery,omitempty"`
	Headers          map[string]string   `json:"headers,omitempty"`
	Body             json.RawMessage     `json:"body,omitempty"`
}

type Runtime

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

func New

func New(c Config, maxBytes int64) *Runtime

func NewWithCredentials

func NewWithCredentials(c Config, maxBytes int64, resolver *credentials.Resolver) *Runtime

func NewWithOptions

func NewWithOptions(c Config, maxBytes int64, resolver *credentials.Resolver, opts RuntimeOptions) *Runtime

func (*Runtime) Close

func (r *Runtime) Close()

func (*Runtime) Execute

func (r *Runtime) Execute(ctx context.Context, req Request) (data any, err error)

func (*Runtime) Stats

func (r *Runtime) Stats() map[string]ActionMetrics

Stats is a bounded, process-local snapshot. It contains no provider, query or argument labels.

type RuntimeOptions

type RuntimeOptions struct {
	CatalogTTL           time.Duration
	DiscoveryConcurrency int
	ProviderTimeout      time.Duration
	CatalogMaxBytes      int64
}

RuntimeOptions belongs to one immutable config and one security principal. A zero TTL preserves live discovery; concurrency defaults to four providers.

type SearchIndex

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

func NewSearchIndex

func NewSearchIndex(caps []Capability, providers map[string]ProviderConfig) *SearchIndex

func NewSearchIndexWithAliases

func NewSearchIndexWithAliases(caps []Capability, providers map[string]ProviderConfig, aliases map[string][]string) (*SearchIndex, error)

NewSearchIndexWithAliases adds bounded, one-pass query aliases from trusted local metadata. It does not alter operation authority or argument values.

func (*SearchIndex) Search

func (index *SearchIndex) Search(query string) []Capability

Search preserves exact IDs as the strongest evidence. Scores are ranking values, not probabilities; fuzzy fallback is used only with no lexical hits.

Jump to

Keyboard shortcuts

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