Documentation
¶
Index ¶
- Constants
- Variables
- type BuiltinExecutor
- type ConfigProperty
- type ConfigSchema
- type DefaultSkillLoader
- type IntentPattern
- type LoadedSkill
- type Permission
- type PermissionType
- type ProcessSkill
- func (p *ProcessSkill) CanHandle(intent VoiceIntent) bool
- func (p *ProcessSkill) GetConfig() (*SkillConfig, error)
- func (p *ProcessSkill) GetManifest() (*SkillManifest, error)
- func (p *ProcessSkill) GetStatus() SkillStatus
- func (p *ProcessSkill) HandleIntent(ctx context.Context, intent *VoiceIntent) (*SkillResponse, error)
- func (p *ProcessSkill) HealthCheck(ctx context.Context) error
- func (p *ProcessSkill) Initialize(ctx context.Context, config *SkillConfig) error
- func (p *ProcessSkill) Teardown(ctx context.Context) error
- func (p *ProcessSkill) UpdateConfig(ctx context.Context, config *SkillConfig) error
- type SandboxMode
- type SkillAction
- type SkillConfig
- type SkillExecutor
- type SkillFactory
- type SkillInfo
- type SkillLoader
- type SkillManager
- func (sm *SkillManager) DisableSkill(ctx context.Context, skillID string) error
- func (sm *SkillManager) EnableSkill(ctx context.Context, skillID string) error
- func (sm *SkillManager) GetSkill(skillID string) (*SkillInfo, error)
- func (sm *SkillManager) HandleIntent(ctx context.Context, intent *VoiceIntent) (*SkillResponse, error)
- func (sm *SkillManager) ListSkills() []*SkillInfo
- func (sm *SkillManager) LoadSkill(ctx context.Context, skillPath string) error
- func (sm *SkillManager) Start(ctx context.Context) error
- func (sm *SkillManager) Stop(ctx context.Context) error
- func (sm *SkillManager) UnloadSkill(ctx context.Context, skillID string) error
- type SkillManagerConfig
- type SkillManifest
- type SkillPlugin
- type SkillResponse
- type SkillState
- type SkillStatus
- type TrustLevel
- type VoiceIntent
Constants ¶
const SkillsRootDir = "./skills"
SkillsRootDir defines the root directory for all skills
Variables ¶
var ( ErrSkillNotFound = errors.New("skill not found") ErrSkillAlreadyLoaded = errors.New("skill already loaded") ErrInvalidManifest = errors.New("invalid skill manifest") ErrPermissionDenied = errors.New("permission denied") ErrSkillInitFailed = errors.New("skill initialization failed") ErrNoSkillCanHandle = errors.New("no skill can handle this intent") ErrInvalidSkillID = security.ErrInvalidSkillID )
Functions ¶
This section is empty.
Types ¶
type BuiltinExecutor ¶
type BuiltinExecutor struct {
// contains filtered or unexported fields
}
BuiltinExecutor handles loading and execution of built-in skills
func NewBuiltinExecutor ¶
func NewBuiltinExecutor(logger *zap.Logger) *BuiltinExecutor
NewBuiltinExecutor creates a new built-in skill executor
func (*BuiltinExecutor) ListLoadedSkills ¶
func (e *BuiltinExecutor) ListLoadedSkills() []string
ListLoadedSkills returns a list of loaded skill IDs
func (*BuiltinExecutor) LoadSkill ¶
func (e *BuiltinExecutor) LoadSkill(manifest *SkillManifest, config *SkillConfig) (SkillPlugin, error)
LoadSkill loads a built-in skill
func (*BuiltinExecutor) RegisterSkill ¶
func (e *BuiltinExecutor) RegisterSkill(skillID string, factory SkillFactory)
RegisterSkill registers a built-in skill factory
func (*BuiltinExecutor) UnloadSkill ¶
func (e *BuiltinExecutor) UnloadSkill(skillID string) error
UnloadSkill unloads a built-in skill
type ConfigProperty ¶
type ConfigProperty struct { Type string `json:"type"` Description string `json:"description"` Default interface{} `json:"default,omitempty"` Enum []string `json:"enum,omitempty"` Format string `json:"format,omitempty"` Sensitive bool `json:"sensitive,omitempty"` }
ConfigProperty defines a single configuration property
type ConfigSchema ¶
type ConfigSchema struct { Properties map[string]ConfigProperty `json:"properties"` Required []string `json:"required,omitempty"` }
ConfigSchema defines the configuration schema for a skill
type DefaultSkillLoader ¶
type DefaultSkillLoader struct {
// contains filtered or unexported fields
}
DefaultSkillLoader is the default implementation of SkillLoader
func NewDefaultSkillLoader ¶
func NewDefaultSkillLoader() *DefaultSkillLoader
NewDefaultSkillLoader creates a new default skill loader
func (*DefaultSkillLoader) LoadSkill ¶
func (l *DefaultSkillLoader) LoadSkill(ctx context.Context, skillPath string) (SkillPlugin, error)
LoadSkill loads a skill from the specified path
func (*DefaultSkillLoader) SupportedModes ¶
func (l *DefaultSkillLoader) SupportedModes() []SandboxMode
SupportedModes returns the sandbox modes supported by this loader
func (*DefaultSkillLoader) UnloadSkill ¶
func (l *DefaultSkillLoader) UnloadSkill(ctx context.Context, plugin SkillPlugin) error
UnloadSkill unloads a skill plugin
type IntentPattern ¶
type IntentPattern struct { Name string `json:"name"` Examples []string `json:"examples"` Confidence float64 `json:"min_confidence"` Priority int `json:"priority"` Enabled bool `json:"enabled"` Categories []string `json:"categories,omitempty"` Languages []string `json:"languages,omitempty"` }
IntentPattern defines patterns this skill can handle
type LoadedSkill ¶
type LoadedSkill struct { Plugin SkillPlugin Info *SkillInfo // contains filtered or unexported fields }
LoadedSkill wraps a SkillPlugin with additional runtime information
type Permission ¶
type Permission struct { Type PermissionType `json:"type"` Resource string `json:"resource,omitempty"` Actions []string `json:"actions,omitempty"` Description string `json:"description"` }
Permission defines what a skill is allowed to access
type PermissionType ¶
type PermissionType string
PermissionType defines the types of permissions
const ( PermissionMicrophone PermissionType = "microphone" PermissionSpeaker PermissionType = "speaker" PermissionNetwork PermissionType = "network" PermissionFileSystem PermissionType = "filesystem" PermissionDeviceControl PermissionType = "device_control" PermissionUserData PermissionType = "user_data" PermissionSystemInfo PermissionType = "system_info" )
type ProcessSkill ¶
type ProcessSkill struct {
// contains filtered or unexported fields
}
ProcessSkill wraps a skill running as a separate process
func (*ProcessSkill) CanHandle ¶
func (p *ProcessSkill) CanHandle(intent VoiceIntent) bool
CanHandle determines if this skill can handle the given intent
func (*ProcessSkill) GetConfig ¶
func (p *ProcessSkill) GetConfig() (*SkillConfig, error)
GetConfig returns the skill configuration
func (*ProcessSkill) GetManifest ¶
func (p *ProcessSkill) GetManifest() (*SkillManifest, error)
GetManifest returns the skill manifest
func (*ProcessSkill) GetStatus ¶
func (p *ProcessSkill) GetStatus() SkillStatus
GetStatus returns the skill status
func (*ProcessSkill) HandleIntent ¶
func (p *ProcessSkill) HandleIntent(ctx context.Context, intent *VoiceIntent) (*SkillResponse, error)
HandleIntent processes an intent
func (*ProcessSkill) HealthCheck ¶
func (p *ProcessSkill) HealthCheck(ctx context.Context) error
HealthCheck verifies the skill is functioning properly
func (*ProcessSkill) Initialize ¶
func (p *ProcessSkill) Initialize(ctx context.Context, config *SkillConfig) error
Initialize initializes the process skill
func (*ProcessSkill) Teardown ¶
func (p *ProcessSkill) Teardown(ctx context.Context) error
Teardown shuts down the process skill
func (*ProcessSkill) UpdateConfig ¶
func (p *ProcessSkill) UpdateConfig(ctx context.Context, config *SkillConfig) error
UpdateConfig updates the skill configuration
type SandboxMode ¶
type SandboxMode string
SandboxMode defines how the skill should be executed
const ( SandboxNone SandboxMode = "none" // No sandboxing SandboxProcess SandboxMode = "process" // Run in separate process SandboxWASM SandboxMode = "wasm" // Run in WASM runtime SandboxDocker SandboxMode = "docker" // Run in Docker container )
type SkillAction ¶
type SkillAction struct { Type string `json:"type"` Target string `json:"target"` Parameters map[string]interface{} `json:"parameters,omitempty"` Success bool `json:"success"` Error string `json:"error,omitempty"` }
SkillAction represents an action taken by a skill
type SkillConfig ¶
type SkillConfig struct { // Skill identification SkillID string `json:"skill_id"` Name string `json:"name"` Version string `json:"version"` // Configuration Config map[string]interface{} `json:"config"` // Permissions and security Permissions []Permission `json:"permissions"` Enabled bool `json:"enabled"` // Runtime settings Timeout time.Duration `json:"timeout"` MaxRetries int `json:"max_retries"` }
SkillConfig holds configuration for a skill instance
type SkillExecutor ¶
type SkillExecutor interface { LoadSkill(manifest *SkillManifest, config *SkillConfig) (SkillPlugin, error) UnloadSkill(skillID string) error ListLoadedSkills() []string }
SkillExecutor defines how skills are executed (for different plugin types)
type SkillFactory ¶
type SkillFactory func(logger *zap.Logger) SkillPlugin
SkillFactory is a function that creates a new skill instance
type SkillInfo ¶
type SkillInfo struct { Manifest *SkillManifest `json:"manifest"` Config *SkillConfig `json:"config"` Status SkillStatus `json:"status"` LoadedAt time.Time `json:"loaded_at"` LastUsed *time.Time `json:"last_used,omitempty"` ErrorCount int `json:"error_count"` LastError string `json:"last_error,omitempty"` PluginPath string `json:"plugin_path"` }
SkillInfo contains information about a loaded skill
type SkillLoader ¶
type SkillLoader interface { LoadSkill(ctx context.Context, skillPath string) (SkillPlugin, error) UnloadSkill(ctx context.Context, plugin SkillPlugin) error SupportedModes() []SandboxMode }
SkillLoader defines the interface for loading skills
type SkillManager ¶
type SkillManager struct {
// contains filtered or unexported fields
}
SkillManager manages the lifecycle of skills
func NewSkillManager ¶
func NewSkillManager(config SkillManagerConfig, loader SkillLoader) *SkillManager
NewSkillManager creates a new skill manager
func (*SkillManager) DisableSkill ¶
func (sm *SkillManager) DisableSkill(ctx context.Context, skillID string) error
DisableSkill disables a skill
func (*SkillManager) EnableSkill ¶
func (sm *SkillManager) EnableSkill(ctx context.Context, skillID string) error
EnableSkill enables a skill
func (*SkillManager) GetSkill ¶
func (sm *SkillManager) GetSkill(skillID string) (*SkillInfo, error)
GetSkill returns information about a loaded skill
func (*SkillManager) HandleIntent ¶
func (sm *SkillManager) HandleIntent(ctx context.Context, intent *VoiceIntent) (*SkillResponse, error)
HandleIntent routes an intent to the appropriate skill
func (*SkillManager) ListSkills ¶
func (sm *SkillManager) ListSkills() []*SkillInfo
ListSkills returns information about all loaded skills
func (*SkillManager) LoadSkill ¶
func (sm *SkillManager) LoadSkill(ctx context.Context, skillPath string) error
LoadSkill loads a skill from the specified path
func (*SkillManager) Start ¶
func (sm *SkillManager) Start(ctx context.Context) error
Start initializes the skill manager and loads skills
func (*SkillManager) Stop ¶
func (sm *SkillManager) Stop(ctx context.Context) error
Stop gracefully shuts down the skill manager
func (*SkillManager) UnloadSkill ¶
func (sm *SkillManager) UnloadSkill(ctx context.Context, skillID string) error
UnloadSkill unloads a skill
type SkillManagerConfig ¶
type SkillManagerConfig struct { SkillsDir string `json:"skills_dir"` AutoLoad bool `json:"auto_load"` MaxSkills int `json:"max_skills"` LoadTimeout time.Duration `json:"load_timeout"` DefaultTrust TrustLevel `json:"default_trust"` AllowedModes []SandboxMode `json:"allowed_sandbox_modes"` ConfigStore string `json:"config_store"` }
SkillManagerConfig holds configuration for the skill manager
type SkillManifest ¶
type SkillManifest struct { // Basic information ID string `json:"id"` Name string `json:"name"` Version string `json:"version"` Description string `json:"description"` Author string `json:"author"` License string `json:"license"` // Capabilities IntentPatterns []IntentPattern `json:"intent_patterns"` Languages []string `json:"languages"` Categories []string `json:"categories"` // Requirements Permissions []Permission `json:"permissions"` Dependencies []string `json:"dependencies,omitempty"` MinVersion string `json:"min_loqa_version"` ConfigSchema *ConfigSchema `json:"config_schema,omitempty"` // Runtime behavior LoadOnStartup bool `json:"load_on_startup"` Singleton bool `json:"singleton"` Timeout string `json:"timeout"` SandboxMode SandboxMode `json:"sandbox_mode"` TrustLevel TrustLevel `json:"trust_level"` // Metadata Homepage string `json:"homepage,omitempty"` Repository string `json:"repository,omitempty"` Keywords []string `json:"keywords,omitempty"` Tags []string `json:"tags,omitempty"` }
SkillManifest describes a skill's metadata and capabilities
type SkillPlugin ¶
type SkillPlugin interface { // Lifecycle hooks Initialize(ctx context.Context, config *SkillConfig) error Teardown(ctx context.Context) error // Core functionality CanHandle(intent VoiceIntent) bool HandleIntent(ctx context.Context, intent *VoiceIntent) (*SkillResponse, error) // Metadata GetManifest() (*SkillManifest, error) GetStatus() SkillStatus // Configuration GetConfig() (*SkillConfig, error) UpdateConfig(ctx context.Context, config *SkillConfig) error // Health checking HealthCheck(ctx context.Context) error }
SkillPlugin defines the interface that all Loqa skills must implement
type SkillResponse ¶
type SkillResponse struct { // Response data Success bool `json:"success"` Message string `json:"message,omitempty"` SpeechText string `json:"speech_text,omitempty"` AudioURL string `json:"audio_url,omitempty"` // Actions performed Actions []SkillAction `json:"actions,omitempty"` // Response metadata ResponseTime time.Duration `json:"response_time"` Metadata map[string]interface{} `json:"metadata,omitempty"` // Error information Error string `json:"error,omitempty"` ErrorCode string `json:"error_code,omitempty"` }
SkillResponse represents the response from a skill
type SkillState ¶
type SkillState string
SkillState defines the possible states of a skill
const ( SkillStateLoading SkillState = "loading" SkillStateReady SkillState = "ready" SkillStateError SkillState = "error" SkillStateDisabled SkillState = "disabled" SkillStateShutdown SkillState = "shutdown" )
type SkillStatus ¶
type SkillStatus struct { State SkillState `json:"state"` Healthy bool `json:"healthy"` LastError string `json:"last_error,omitempty"` LastUsed time.Time `json:"last_used"` UsageCount int64 `json:"usage_count"` }
SkillStatus represents the current status of a skill
type TrustLevel ¶
type TrustLevel string
TrustLevel defines the trust level of the skill
const ( TrustSystem TrustLevel = "system" // System/built-in skills TrustVerified TrustLevel = "verified" // Verified by Loqa Labs TrustCommunity TrustLevel = "community" // Community contributions TrustUnknown TrustLevel = "unknown" // Unverified/local skills )
type VoiceIntent ¶
type VoiceIntent struct { // Core intent data ID string `json:"id"` Transcript string `json:"transcript"` Intent string `json:"intent"` Confidence float64 `json:"confidence"` Entities map[string]interface{} `json:"entities"` // Metadata UserID string `json:"user_id,omitempty"` DeviceID string `json:"device_id"` Timestamp time.Time `json:"timestamp"` // Context SessionID string `json:"session_id,omitempty"` Context map[string]interface{} `json:"context,omitempty"` }
VoiceIntent represents a parsed voice command intent