skill

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: May 11, 2026 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

Variables

View Source
var ErrForkCapabilityUnavailable = errors.New(
	"skill requested fork/detach but ExecFn (used for both llm/agents:start and llm/agents:status) is not bound")

ErrForkCapabilityUnavailable signals that a skill requested fork or detach activation but the runtime executor (ExecFn) is not bound. ExecFn is the single function-pointer dependency for both `llm/agents:start` (kicks off the child conversation) and `llm/agents:status` (polls for terminal state); when nil, neither operation can run, so the skill cannot execute in a child context.

Callers receiving this error can degrade to inline activation, surface a configuration warning to the user, or fail the turn — runtime policy decision. The error is detectable via errors.Is so it survives wrapping.

View Source
var ExecFn func(ctx context.Context, name string, args map[string]interface{}) (string, error)

Functions

func ActiveSkillsFromHistory

func ActiveSkillsFromHistory(history *binding.History) []string

func ConstraintMetadata

func ConstraintMetadata(c *Constraints) map[string]interface{}

func ExpandDefinitionsForActiveSkills

func ExpandDefinitionsForActiveSkills(defs []*llm.ToolDefinition, reg tool.Registry, skills []*skillproto.Skill) []*llm.ToolDefinition

ExpandDefinitionsForActiveSkills returns the widened tool surface for the given active skills, ignoring any unmatched-pattern diagnostics. Existing callers that don't observe diagnostics use this.

func ExpandDefinitionsForActiveSkillsWithDiag

func ExpandDefinitionsForActiveSkillsWithDiag(defs []*llm.ToolDefinition, reg tool.Registry, skills []*skillproto.Skill) ([]*llm.ToolDefinition, []string)

ExpandDefinitionsForActiveSkillsWithDiag returns the widened tool surface AND a list of allowed-tools patterns from the active skills that did not resolve to any registered tool. Callers can convert the unmatched list into warn-level skillproto.Diagnostics surfaced on the activation event so the model and operators see "skill 'X' requested tool 'Y' which is not available in the current agent's tool registry."

Returns an empty unmatched slice when nothing is missing.

func ExpandDefinitionsForConstraints

func ExpandDefinitionsForConstraints(defs []*llm.ToolDefinition, reg tool.Registry, c *Constraints) []*llm.ToolDefinition

ExpandDefinitionsForConstraints rewrites the tool surface for the service families named by `allowed-tools` and preserves unrelated tool families.

Example: when a skill allows only `system/exec:execute`, the parent's `system/exec:start|cancel|status` tools are removed from the presented surface and only `execute` is re-added. Unrelated tools such as `prompt:list` or `llm/skills:list` remain available.

Wraps ExpandDefinitionsForConstraintsWithDiag and discards the unmatched pattern list. Callers that want to surface "skill requested an unavailable tool" diagnostics should call the WithDiag variant directly.

func ExpandDefinitionsForConstraintsWithDiag

func ExpandDefinitionsForConstraintsWithDiag(defs []*llm.ToolDefinition, reg tool.Registry, c *Constraints) (out []*llm.ToolDefinition, unmatched []string)

ExpandDefinitionsForConstraintsWithDiag is identical to ExpandDefinitionsForConstraints but additionally returns the list of allowed-tools patterns that did not match any registered tool. The runtime can convert these into warn-level skillproto.Diagnostics surfaced on the activation event so the model and operators see "skill 'X' requested tool 'Y' which is not available in the current agent's tool registry."

Returns an empty unmatched slice (not nil) when nothing is missing. Returns nil unmatched when c, reg, or c.ToolPatterns is empty (no expansion attempted).

func InlineActiveSkillsFromHistory

func InlineActiveSkillsFromHistory(history *binding.History, svc *Service, agent *agentmdl.Agent, overrideName, overrideMode string) []string

func ValidateExecution

func ValidateExecution(ctx context.Context, toolName string, args map[string]interface{}) error

func WithActivationModeOverride

func WithActivationModeOverride(ctx context.Context, name, mode string) context.Context

func WithConstraints

func WithConstraints(ctx context.Context, c *Constraints) context.Context

func WithRuntimeState

func WithRuntimeState(ctx context.Context, svc *Service, agent *agentmdl.Agent, activeNames []string) context.Context

Types

type ActivateInput

type ActivateInput struct {
	Name string `json:"name,omitempty"`
	Args string `json:"args,omitempty"`
	Mode string `json:"mode,omitempty"`
}

type ActivateOutput

type ActivateOutput struct {
	Name                string `json:"name,omitempty"`
	Body                string `json:"body,omitempty"`
	Mode                string `json:"mode,omitempty"`
	Started             bool   `json:"started,omitempty"`
	Terminal            bool   `json:"terminal,omitempty"`
	Status              string `json:"status,omitempty"`
	ChildConversationID string `json:"childConversationId,omitempty"`
	ChildAgentID        string `json:"childAgentId,omitempty"`
}

type Constraints

type Constraints struct {
	ToolPatterns        []string
	ExecFirstTokenAllow []string
}

func BuildConstraints

func BuildConstraints(skills []*skillproto.Skill) *Constraints

func ConstraintsFromContext

func ConstraintsFromContext(ctx context.Context) (*Constraints, bool)

type ListInput

type ListInput struct{}

type ListOutput

type ListOutput struct {
	Items       []skillproto.Metadata `json:"items,omitempty"`
	Diagnostics []string              `json:"diagnostics,omitempty"`
}

type RuntimeState

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

func RuntimeStateFromContext

func RuntimeStateFromContext(ctx context.Context) (*RuntimeState, bool)

func (*RuntimeState) Activate

func (s *RuntimeState) Activate(name string)

func (*RuntimeState) Constraints

func (s *RuntimeState) Constraints() *Constraints

type Service

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

func New

func New(defaults *execconfig.Defaults, conv apiconv.Client, finder agentmdl.Finder) *Service

func (*Service) Activate

func (s *Service) Activate(agent *agentmdl.Agent, name, args string) (string, error)

func (*Service) ActivateByPathForConversation

func (s *Service) ActivateByPathForConversation(ctx context.Context, conversationID, skillPath, args string) (string, error)

func (*Service) ActivateForConversation

func (s *Service) ActivateForConversation(ctx context.Context, conversationID, name, args string) (string, error)

func (*Service) ActivateForConversationWithAgent

func (s *Service) ActivateForConversationWithAgent(ctx context.Context, conversationID string, agent *agentmdl.Agent, name, args string) (string, error)

func (*Service) Diagnostics

func (s *Service) Diagnostics() []string

func (*Service) ListAll

func (s *Service) ListAll() []skillproto.Metadata

func (*Service) ListForConversation

func (s *Service) ListForConversation(ctx context.Context, conversationID string) ([]skillproto.Metadata, []string, error)

func (*Service) Load

func (s *Service) Load(ctx context.Context) error

func (*Service) Method

func (s *Service) Method(name string) (svc.Executable, error)

func (*Service) Methods

func (s *Service) Methods() svc.Signatures

func (*Service) Name

func (s *Service) Name() string

func (*Service) Resolve

func (s *Service) Resolve(agent *agentmdl.Agent, name string) (*skillproto.Skill, error)

func (*Service) SetStreamPublisher

func (s *Service) SetStreamPublisher(p streaming.Publisher)

func (*Service) Visible

func (s *Service) Visible(agent *agentmdl.Agent) ([]skillproto.Metadata, string)

func (*Service) VisibleSkillsByName

func (s *Service) VisibleSkillsByName(agent *agentmdl.Agent, names []string) []*skillproto.Skill

type Watcher

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

func NewWatcher

func NewWatcher(service *Service) *Watcher

func (*Watcher) Start

func (w *Watcher) Start(ctx context.Context) error

Jump to

Keyboard shortcuts

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