Documentation
¶
Overview ¶
Package compiled provides interfaces for compiled Go skills.
Compiled skills are Go packages that implement the Skill interface, providing callable tools that the agent can use. Unlike markdown skills (SKILL.md files) which inject instructions into the system prompt, compiled skills register actual functions that the LLM can invoke.
Example Usage ¶
// Import your skill package
import "example.com/myskill"
skill, _ := myskill.New(myskill.Config{...})
agent, _ := agent.New(config,
agent.WithCompiledSkill(skill),
)
Index ¶
- type Parameter
- type Registry
- func (r *Registry) All() []Skill
- func (r *Registry) AllTools() []Tool
- func (r *Registry) CloseAll() error
- func (r *Registry) Count() int
- func (r *Registry) FindTool(name string) (*Tool, Skill, bool)
- func (r *Registry) Get(name string) (Skill, bool)
- func (r *Registry) InitAll(ctx context.Context) error
- func (r *Registry) InjectStorage(storage Storage)
- func (r *Registry) Register(s Skill) error
- func (r *Registry) ToolCount() int
- type Skill
- type SkillInfo
- type Storage
- type StorageAware
- type Tool
- type ToolHandler
- type ToolInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Parameter ¶
type Parameter struct {
// Type is the JSON Schema type: "string", "number", "integer", "boolean", "array", "object".
Type string `json:"type"`
// Description explains the parameter. Shown to the LLM.
Description string `json:"description,omitempty"`
// Required indicates if this parameter must be provided.
Required bool `json:"-"`
// Default is the default value if not provided.
Default any `json:"default,omitempty"`
// Enum restricts values to a specific set.
Enum []any `json:"enum,omitempty"`
// Items defines the schema for array elements (when Type is "array").
Items *Parameter `json:"items,omitempty"`
// Properties defines object properties (when Type is "object").
Properties map[string]Parameter `json:"properties,omitempty"`
}
Parameter defines a tool parameter.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry manages compiled skills.
func (*Registry) InjectStorage ¶
InjectStorage injects storage into all storage-aware skills.
type Skill ¶
type Skill interface {
// Name returns the skill identifier (e.g., "invest", "weather").
Name() string
// Description returns a human-readable description of the skill.
Description() string
// Tools returns the tools provided by this skill.
Tools() []Tool
// Init initializes the skill. Called once when the agent starts.
Init(ctx context.Context) error
// Close releases resources. Called when the agent shuts down.
Close() error
}
Skill is the interface that compiled skills implement.
type Storage ¶
type Storage interface {
Get(ctx context.Context, key string) ([]byte, error)
Set(ctx context.Context, key string, value []byte, ttl time.Duration) error
Delete(ctx context.Context, key string) error
}
Storage is the storage interface that skills can use. This is a subset of the full storage.Storage interface.
type StorageAware ¶
type StorageAware interface {
SetStorage(s Storage)
}
StorageAware is an optional interface for skills that need storage. If a skill implements this interface, the agent will inject the storage backend after creation and before Init() is called.
type Tool ¶
type Tool struct {
// Name is the tool identifier (e.g., "analyze_stock").
Name string
// Description explains what the tool does. This is shown to the LLM.
Description string
// Parameters defines the tool's input parameters using JSON Schema.
Parameters map[string]Parameter
// Handler is the function that executes the tool.
Handler ToolHandler
}
Tool represents a callable function that the LLM can invoke.
func (*Tool) ToJSONSchema ¶
ToJSONSchema converts a tool's parameters to JSON Schema format compatible with OpenAI/Anthropic function calling.
type ToolHandler ¶
ToolHandler is the function signature for tool implementations.