plugin

package
v0.5.23 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2026 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Overview

Package plugin provides LUA-based plugin support for extending switchAILocal functionality. It allows users to write custom scripts that can intercept and modify API requests/responses.

Index

Constants

View Source
const (
	HookOnRequest  = "on_request"
	HookOnResponse = "on_response"
)

Hook types for plugin execution points

View Source
const (
	// SkipLuaContextKey is a context key used to prevent recursive LUA execution.
	SkipLuaContextKey contextKey = "skip_lua"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Classifier

type Classifier interface {
	Classify(ctx context.Context, prompt string) (string, error)
}

Classifier defines the interface for LLM-based intent classification. It is used by the Lua engine to delegate classification requests back to the Go host.

type Config

type Config struct {
	// Enabled determines if the plugin engine is active
	Enabled bool `yaml:"enabled" json:"enabled"`
	// PluginDir is the directory containing LUA scripts
	PluginDir string `yaml:"plugin-dir" json:"plugin-dir"`
	// Intelligence holds settings for the Cortex routing engine
	Intelligence config.IntelligenceConfig
	// EnabledPlugins specifies a list of plugin IDs to load
	EnabledPlugins []string
}

type IntelligenceService

type IntelligenceService interface {
	IsEnabled() bool
	GetDiscoveryService() intelligence.DiscoveryServiceInterface
	GetMatrixBuilder() intelligence.MatrixBuilderInterface
	IsModelAvailable(modelID string) bool
	GetSkillRegistry() *skills.Registry
	GetEmbeddingEngine() *embedding.Engine
	GetSemanticTier() intelligence.SemanticTierInterface
	GetSemanticCache() intelligence.SemanticCacheInterface
	GetConfidenceScorer() *confidence.Scorer
	GetVerifier() *verification.Verifier
	GetCascadeManager() intelligence.CascadeManagerInterface
	GetFeedbackCollector() intelligence.FeedbackCollectorInterface
}

IntelligenceService defines the interface for Phase 2 intelligent routing features. It provides access to advanced capabilities like discovery, semantic matching, and skill registry.

type LuaEngine

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

func NewLuaEngine

func NewLuaEngine(cfg Config) *LuaEngine

NewLuaEngine creates a new LUA plugin engine with the given configuration.

func (*LuaEngine) Close

func (e *LuaEngine) Close()

Close shuts down the LUA engine and cleans up resources.

func (*LuaEngine) IsEnabled

func (e *LuaEngine) IsEnabled() bool

IsEnabled returns whether the LUA engine is enabled.

func (*LuaEngine) LoadPlugins

func (e *LuaEngine) LoadPlugins() error

LoadPlugins loads all plugin directories from the plugin dir.

func (*LuaEngine) RunHook

func (e *LuaEngine) RunHook(ctx context.Context, hookName string, data map[string]any) (map[string]any, error)

RunHook executes a specific hook function across all loaded plugins. Returns the modified data or the original if no modifications were made.

func (*LuaEngine) SetClassifier

func (e *LuaEngine) SetClassifier(c Classifier)

SetClassifier sets the classifier implementation for the engine.

func (*LuaEngine) SetIntelligenceService

func (e *LuaEngine) SetIntelligenceService(svc IntelligenceService)

SetIntelligenceService sets the intelligence service implementation for the engine. This allows Lua plugins to access Phase 2 intelligent routing features.

type SkillDefinition

type SkillDefinition struct {
	Name               string `yaml:"name"`
	Description        string `yaml:"description"`
	RequiredCapability string `yaml:"required-capability"`
	Content            string `yaml:"-"` // Full content of SKILL.md
}

SkillDefinition represents a parsed SKILL.md

Jump to

Keyboard shortcuts

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