Documentation
¶
Index ¶
- Constants
- Variables
- func ActiveSandboxBackend(plugins []Plugin) string
- func BuiltinPluginIDs() []string
- func CachePath() string
- func DBPath() string
- func DefaultAgentModelRef(providers []Provider) string
- func DefaultModelIDForProviderType(providerType string) string
- func DefaultModelRefForProvider(provider Provider) string
- func DefaultModelRefForProviderType(providerType string) string
- func IsBuiltinPlugin(id string) bool
- func ModelConfigToAI(provider string, m ModelConfig) ai.Model
- func ModelsCachePath() string
- func ParseModelRef(ref string) (provider, model string)
- func PluginID(kind, name string) string
- func ResetStellaHome()
- func SandboxBackendEnvOverride() string
- func SandboxDockerImage() string
- func SandboxDockerImageIsDev() bool
- func SaveModelsCache(cache *ModelsCache) error
- func ServerURL() string
- func StellaHome() string
- type Agent
- type BuiltinPlugin
- type CLITool
- type CachedModel
- type Channel
- type CompactionConfig
- type ManifestPluginOverride
- type ModelConfig
- type ModelCostConfig
- type ModelsCache
- type Plugin
- type Provider
- type ProviderCreds
- type ProviderModel
- type ProviderModelCost
- type RunnerConfig
- type SandboxConfig
- type SandboxNetworkConfig
- type SchedulerConfig
- type Snapshot
- func (s *Snapshot) LogPath() string
- func (s *Snapshot) ResolveModel() ai.Model
- func (s *Snapshot) ResolveModelID(tier string) string
- func (s *Snapshot) ResolveModelTier(tier string) ai.Model
- func (s *Snapshot) ResolveProviderCreds(providerID string) ProviderCreds
- func (s *Snapshot) ResolveThinkingLevel(tier string) ai.ThinkingLevel
- func (s *Snapshot) SkillsPath() string
- type Store
Constants ¶
const ( DefaultAnthropicModelID = "claude-sonnet-4-6" DefaultOpenAIModelID = "gpt-4o" DefaultOpenAIResponseModelID = "gpt-4o" )
const ( ModelTierStrong = "strong" ModelTierFast = "fast" )
Model tier constants.
const ( PluginKindTool = "tool" PluginKindCLI = "cli" PluginKindChannel = "channel" PluginKindHook = "hook" PluginKindProvider = "provider" PluginKindSandbox = "sandbox" PluginKindAuth = "auth" )
Plugin kind constants.
const ( SandboxBackendDocker = "docker" SandboxBackendLocal = "local" SandboxBackendNone = "none" SandboxNetworkDisabled = "disabled" SandboxNetworkAllowAll = "allow_all" )
const ( AgentScopeSystem = "system" // all users can access AgentScopeRestricted = "restricted" // only assigned users can access )
AgentScope constants define the access scope for an agent.
Variables ¶
var BuiltinChannelNames = []string{"telegram", "qq", "feishu", "weixin"}
BuiltinChannelNames lists the 4 built-in channel plugins.
var BuiltinHookNames = []string{"rtk"}
BuiltinHookNames lists the built-in hook plugins.
var BuiltinProviderNames = []string{"anthropic", "openai", "openai-response"}
BuiltinProviderNames lists the built-in provider types.
var BuiltinSandboxNames = []string{SandboxBackendDocker, SandboxBackendLocal, SandboxBackendNone}
BuiltinSandboxNames lists the built-in sandbox backend plugins.
var BuiltinToolNames = []string{"gh", "lark-cli", "mise", "tap-web", "webfetch"}
BuiltinToolNames lists the built-in tool plugins. Core tools (read, bash, edit, write) are always-on and no longer managed as plugins.
Functions ¶
func ActiveSandboxBackend ¶
ActiveSandboxBackend returns the name of the enabled sandbox backend plugin. STELLA_SANDBOX_BACKEND takes precedence; otherwise the DB-enabled plugin wins, defaulting to SandboxBackendLocal.
func BuiltinPluginIDs ¶
func BuiltinPluginIDs() []string
BuiltinPluginIDs returns all built-in plugin IDs in deterministic order. Provider instances are stored separately in provider.
func CachePath ¶
func CachePath() string
CachePath returns the cache directory inside the stella home.
func DefaultAgentModelRef ¶
DefaultAgentModelRef picks the preferred starter model ref from the configured providers. It prefers Anthropic, then OpenAI, then OpenAI Responses, and falls back to the Anthropic compatibility alias.
func DefaultModelIDForProviderType ¶
DefaultModelIDForProviderType returns the preferred starter model ID for a built-in provider type.
func DefaultModelRefForProvider ¶
DefaultModelRefForProvider returns the default provider/model ref for a concrete provider instance.
func DefaultModelRefForProviderType ¶
DefaultModelRefForProviderType returns the default provider/model ref for the given provider type using the provider type as the prefix.
func IsBuiltinPlugin ¶ added in v0.38.0
IsBuiltinPlugin reports whether the given ID is a code-defined builtin.
func ModelConfigToAI ¶
func ModelConfigToAI(provider string, m ModelConfig) ai.Model
ModelConfigToAI converts a ModelConfig to an ai.Model.
func ModelsCachePath ¶
func ModelsCachePath() string
ModelsCachePath returns the path to the models.json cache file.
func ParseModelRef ¶
ParseModelRef splits a "provider/model" string into its parts. If the string contains no "/", it returns ("", ref) as fallback.
func ResetStellaHome ¶
func ResetStellaHome()
ResetStellaHome clears the cached StellaHome value (for testing).
func SandboxBackendEnvOverride ¶ added in v0.44.1
func SandboxBackendEnvOverride() string
SandboxBackendEnvOverride returns the env-forced sandbox backend name, or "" when the operator has not set STELLA_SANDBOX_BACKEND.
func SandboxDockerImage ¶
func SandboxDockerImage() string
SandboxDockerImage returns the sandbox container image tag for the current stella build. Dev builds use a local `stella-sandbox:dev` tag (produced by `mise run sandbox:docker:build`); tagged releases pull `ghcr.io/cherryhq/stella-sandbox:<version>` from GHCR. The version is normalized to strip any leading "v" so "v1.2.3" and "1.2.3" resolve to the same image tag.
func SandboxDockerImageIsDev ¶
func SandboxDockerImageIsDev() bool
SandboxDockerImageIsDev reports whether SandboxDockerImage resolves to the local dev tag. Callers use this to surface a build-image hint when the image is missing locally.
func SaveModelsCache ¶
func SaveModelsCache(cache *ModelsCache) error
SaveModelsCache writes the models cache to the cache directory.
func ServerURL ¶
func ServerURL() string
ServerURL returns the URL CLI commands should use to talk to the local stella server. Priority: STELLA_SERVER_URL env -> http://127.0.0.1:25678 (the default admin port from cmd/stella/gateway.go).
func StellaHome ¶
func StellaHome() string
StellaHome returns the stella home directory. Priority: STELLA_HOME env -> ~/.stella The result is cached after the first call.
Types ¶
type Agent ¶
type Agent struct {
ID string `json:"id"`
Name string `json:"name"`
Model string `json:"model"`
ModelThinking string `json:"model_thinking"`
ModelStrong string `json:"model_strong"`
ModelStrongThinking string `json:"model_strong_thinking"`
ModelFast string `json:"model_fast"`
ModelFastThinking string `json:"model_fast_thinking"`
SystemPrompt string `json:"system_prompt"`
Soul string `json:"soul"`
Workspace string `json:"workspace"`
Sandbox SandboxConfig `json:"sandbox"`
Scope string `json:"scope"`
CreatorID string `json:"creator_id"`
Enabled bool `json:"enabled"`
LastActive *time.Time `json:"last_active,omitempty"`
}
Agent represents an agent definition. Model fields use {provider}/{model} format (e.g. "anthropic/claude-sonnet-4-6").
type BuiltinPlugin ¶ added in v0.38.0
BuiltinPlugin describes a code-defined plugin with its default enabled state.
func BuiltinPluginByID ¶ added in v0.38.0
func BuiltinPluginByID(id string) (BuiltinPlugin, bool)
BuiltinPluginByID returns the builtin definition for the given ID.
func BuiltinPlugins ¶ added in v0.38.0
func BuiltinPlugins() []BuiltinPlugin
BuiltinPlugins returns the authoritative list of code-defined plugins. DB rows in plugin are optional overrides of enabled/config.
type CLITool ¶ added in v0.38.0
type CLITool struct {
Name string // plugin Name; also the shim/binary name on PATH
Tool string // mise tool key, e.g. "github:owner/repo", "npm:pkg", "uv"
Version string // mise version spec; empty means "latest"
Options map[string]any // extra mise tool options, using mise.toml option names
Enabled bool
}
CLITool is a CLI tool provisioned through mise. It is stored as a plugin row with kind=cli; the mise-specific fields live in the plugin's Config JSON under "mise_tool", "version", and "options".
Unlike builtin tool plugins, cli plugins are purely DB-driven — they never appear in BuiltinPlugins(). The plugin Name doubles as the binary (mise shim) name exposed on PATH.
func CLIToolFromPlugin ¶ added in v0.38.0
CLIToolFromPlugin decodes a kind=cli plugin row into a CLITool. The second return is false when the plugin is not a cli plugin or lacks a mise tool key.
func CLIToolsFromPlugins ¶ added in v0.38.0
CLIToolsFromPlugins maps plugin rows (typically from ListPluginsByKind with PluginKindCLI) to CLITool specs, skipping malformed entries.
type CachedModel ¶
type CachedModel struct {
Provider string `json:"provider"`
ProviderName string `json:"provider_name,omitempty"`
Model string `json:"model"`
}
CachedModel is the on-disk representation of a model in models.json.
type Channel ¶
type Channel struct {
ID string `json:"id"`
Name string `json:"name"`
Type string `json:"type"`
AgentID string `json:"agent_id,omitempty"`
Enabled bool `json:"enabled"`
Config string `json:"config"`
}
Channel represents a platform channel configuration.
type CompactionConfig ¶
type CompactionConfig struct {
// MaxTokens triggers compaction when the estimated token count exceeds this.
// 0 (or omitted) uses the default of 80000. Negative values disable
// automatic compaction. Manual /compact still works.
MaxTokens int `json:"max_tokens"`
// KeepTail is the number of recent user turns to preserve verbatim
// after compaction. Default: 6.
KeepTail int `json:"keep_tail"`
}
CompactionConfig controls automatic session compaction.
type ManifestPluginOverride ¶ added in v0.38.0
type ManifestPluginOverride struct {
PluginID string
Enabled *bool // nil = fallback to manifest default; non-nil = override
SessionEnvVaultKey string // empty = fallback; non-empty = vault blob with session_env override map
Config string // JSON manifest plugin definition override; empty = fallback to builtin
UpdatedAt string
}
Plugin represents a unified plugin entry stored in plugin. IDs follow "kind/name" format, e.g. "tool/webfetch" or "channel/telegram". ManifestPluginOverride is an override of a manifest-declared plugin. Both Enabled and SessionEnvVaultKey are nullable / empty-as-sentinel so the row can express "fallback to manifest default" without losing the row itself.
type ModelConfig ¶
type ModelConfig struct {
ID string `json:"id"`
Name string `json:"name"`
API string `json:"api"`
Reasoning bool `json:"reasoning"`
Input []string `json:"input"`
ContextWindow int `json:"context_window"`
MaxTokens int `json:"max_tokens"`
Headers map[string]string `json:"headers"`
Cost *ModelCostConfig `json:"cost"`
}
ModelConfig describes a model's metadata (used in model listing/caching).
type ModelCostConfig ¶
type ModelCostConfig struct {
Input float64 `json:"input"`
Output float64 `json:"output"`
CacheRead float64 `json:"cache_read"`
CacheWrite float64 `json:"cache_write"`
}
ModelCostConfig describes the cost of a model per million tokens.
type ModelsCache ¶
type ModelsCache struct {
UpdatedAt time.Time `json:"updated_at"`
Models []CachedModel `json:"models"`
}
ModelsCache is the top-level structure for models.json in the cache directory.
func LoadModelsCache ¶
func LoadModelsCache() (*ModelsCache, error)
LoadModelsCache reads the cached models from the workspace models.json.
type Provider ¶
type Provider struct {
ID string `json:"id"`
Type string `json:"type"`
Name string `json:"name"`
Enabled bool `json:"enabled"`
APIKey string `json:"api_key"`
BaseURL string `json:"base_url"`
Models map[string]ProviderModel `json:"models,omitempty"`
}
Provider represents an LLM API provider.
type ProviderCreds ¶
ProviderCreds holds credentials for a single provider.
type ProviderModel ¶
type ProviderModel struct {
ID string `json:"id,omitempty"`
Name string `json:"name,omitempty"`
Enabled bool `json:"enabled"`
Reasoning bool `json:"reasoning,omitempty"`
Input []string `json:"input,omitempty"`
Output []string `json:"output,omitempty"`
ContextWindow int `json:"contextWindow,omitempty"`
MaxTokens int `json:"maxTokens,omitempty"`
Cost ProviderModelCost `json:"cost,omitzero"`
}
type ProviderModelCost ¶
type RunnerConfig ¶
type RunnerConfig struct {
System string `json:"system"`
IdleTimeout int `json:"idle_timeout"`
DelegateTimeout int `json:"delegate_timeout"` // minutes; 0 = use default (15m)
Compaction CompactionConfig `json:"compaction"`
}
RunnerConfig configures the agent runner.
func (RunnerConfig) DelegateTimeoutDuration ¶ added in v0.33.0
func (c RunnerConfig) DelegateTimeoutDuration() time.Duration
DelegateTimeoutDuration returns the configured delegate timeout as a time.Duration. Zero means "use the built-in default" (15 minutes).
type SandboxConfig ¶
type SandboxConfig struct {
Network SandboxNetworkConfig `json:"network"`
}
SandboxConfig configures the sandbox backend. The active backend is selected globally on the Plugins page.
func (SandboxConfig) NetworkMode ¶
func (c SandboxConfig) NetworkMode() string
NetworkMode returns the configured network mode with defaults applied.
func (SandboxConfig) Validate ¶
func (c SandboxConfig) Validate() error
Validate returns an error when the sandbox configuration is invalid.
type SandboxNetworkConfig ¶
type SandboxNetworkConfig struct {
Mode string `json:"mode"`
Allowlist []string `json:"allowlist"`
}
SandboxNetworkConfig configures sandbox network access.
type SchedulerConfig ¶
SchedulerConfig configures the scheduler subsystem.
func (SchedulerConfig) IsEnabled ¶
func (c SchedulerConfig) IsEnabled() bool
IsEnabled returns whether the scheduler is enabled (defaults to true).
type Snapshot ¶
type Snapshot struct {
AgentID string // the agent ID this snapshot belongs to
// Provider, APIKey, BaseURL are the default provider credentials derived
// from the Model field's provider prefix. Kept for backward compatibility.
Provider string
Model string
ModelThinking string
ModelStrong string
ModelStrongThinking string
ModelFast string
ModelFastThinking string
Workspace string
Sandbox SandboxConfig
APIKey string
BaseURL string
SystemPrompt string // agent's base system prompt from DB
Soul string // agent's default soul from DB (fallback for all users)
Runner RunnerConfig
Compaction CompactionConfig
Scheduler SchedulerConfig
Plugins []Plugin
// Providers maps provider ID to credentials, enabling per-tier provider
// resolution when model_strong or model_fast use a different provider.
Providers map[string]ProviderCreds
}
Snapshot is a read-only config snapshot assembled from DB for downstream consumption. It replaces the old *Config for code that needs provider/model information for a specific agent.
func (*Snapshot) ResolveModel ¶
ResolveModel returns the ai.Model for the default (strong) tier.
func (*Snapshot) ResolveModelID ¶
ResolveModelID returns the model ID string for the given tier, falling back to Model if the tier-specific value is not set.
func (*Snapshot) ResolveModelTier ¶
ResolveModelTier returns the ai.Model for the given tier, constructing a minimal Model from the snapshot's provider and model information. It parses the provider from the model ref and looks up per-provider credentials from the Providers map.
func (*Snapshot) ResolveProviderCreds ¶
func (s *Snapshot) ResolveProviderCreds(providerID string) ProviderCreds
ResolveProviderCreds returns the API key and base URL for the given provider ID, falling back to the default Provider credentials.
func (*Snapshot) ResolveThinkingLevel ¶ added in v0.45.0
func (s *Snapshot) ResolveThinkingLevel(tier string) ai.ThinkingLevel
ResolveThinkingLevel returns the thinking level for the given tier, falling back to the default model's setting when a tier-specific setting is unset.
func (*Snapshot) SkillsPath ¶
SkillsPath returns the per-workspace agent-level skills directory.
type Store ¶
type Store interface {
// Providers
ListProviders(ctx context.Context) ([]Provider, error)
GetProvider(ctx context.Context, id string) (Provider, error)
CreateProvider(ctx context.Context, p Provider) error
UpdateProvider(ctx context.Context, p Provider) error
DeleteProvider(ctx context.Context, id string) error
// Agents
ListAgents(ctx context.Context) ([]Agent, error)
ListEnabledAgents(ctx context.Context) ([]Agent, error)
ListAccessibleAgents(ctx context.Context, userID string) ([]Agent, error)
GetAgent(ctx context.Context, id string) (Agent, error)
CreateAgent(ctx context.Context, a Agent) error
UpdateAgent(ctx context.Context, a Agent) error
DeleteAgent(ctx context.Context, id string) error
// Channels
ListChannels(ctx context.Context) ([]Channel, error)
ListChannelsByType(ctx context.Context, channelType string) ([]Channel, error)
GetChannel(ctx context.Context, id string) (Channel, error)
UpsertChannel(ctx context.Context, ch Channel) error
DeleteChannel(ctx context.Context, id string) error
// Manifest plugin overrides — tunables for manifest-declared plugins.
// Reads merge the builtin manifest defaults with these rows.
GetManifestPluginOverride(ctx context.Context, pluginID string) (ManifestPluginOverride, bool, error)
ListManifestPluginOverrides(ctx context.Context) ([]ManifestPluginOverride, error)
UpsertManifestPluginOverride(ctx context.Context, override ManifestPluginOverride) error
DeleteManifestPluginOverride(ctx context.Context, pluginID string) error
// Plugins — read paths merge BuiltinPlugins() with DB override rows.
ListPlugins(ctx context.Context) ([]Plugin, error)
ListPluginOverrides(ctx context.Context) ([]Plugin, error)
ListPluginsByKind(ctx context.Context, kind string) ([]Plugin, error)
ListEnabledPlugins(ctx context.Context) ([]Plugin, error)
GetPlugin(ctx context.Context, id string) (Plugin, error)
UpsertPlugin(ctx context.Context, p Plugin) error
SetPluginEnabled(ctx context.Context, id string, enabled bool) error
SetPluginConfig(ctx context.Context, id string, config map[string]any) error
DeletePlugin(ctx context.Context, id string) error
// Chat Agents (group -> agent mapping)
GetChatAgent(ctx context.Context, channelID, platform, chatID string) (string, error) // returns agentID
SetChatAgent(ctx context.Context, channelID, platform, chatID, agentID string) error
DeleteChatAgent(ctx context.Context, channelID, platform, chatID string) error
// Settings (key-value JSON)
GetSetting(ctx context.Context, key string) (string, error) // returns JSON string
SetSetting(ctx context.Context, key, value string) error
// Snapshot assembles a read-only config snapshot for an agent.
Snapshot(ctx context.Context, agentID string) (*Snapshot, error)
// Bootstrap seeds default config for a fresh install.
Seed(ctx context.Context) error
}
Store provides typed access to configuration stored in the database.