Documentation
¶
Index ¶
- Constants
- func EnsureConfigFile(path string) (bool, error)
- func SkillDirectories() []string
- func ValidateMCPServerName(name string) error
- func ValidateMCPToolName(name string) error
- func ValidateMCPType(kind string) error
- func ValidateProviderType(kind string) error
- type Agent
- type ApprovalConfig
- type BuiltinProvider
- type ConfLoader
- type Config
- func (c *Config) AddProviderModels(providerName string, ids []string) ([]string, error)
- func (c *Config) AgentDisplayName(key string) string
- func (c *Config) AgentUsesDefaultModel(agentName string) bool
- func (c *Config) DefaultModelName() string
- func (c *Config) EmitPluginEvent(ctx context.Context, event plugins.Event) error
- func (c *Config) HasPluginHook(event string) bool
- func (c *Config) SetProviderAPIKey(providerName, key string) error
- type LangfuseConfig
- type MCPServer
- type Model
- type Provider
- type Settings
- type Skill
- type Tool
- type ToolParameter
- type Value
- func (v *Value) Array() []*Value
- func (v *Value) Bool() bool
- func (v *Value) Get(key string) *Value
- func (v *Value) GetBool(key string) bool
- func (v *Value) GetInt(key string) int
- func (v *Value) GetString(key string) string
- func (v *Value) Int() int
- func (v *Value) IsArray() bool
- func (v *Value) IsEmpty() bool
- func (v *Value) IsMap() bool
- func (v *Value) IsScalar() bool
- func (v *Value) Location() string
- func (v *Value) Map() map[string]*Value
- func (v *Value) Parse(target interface{}) error
- func (v *Value) String() string
- func (v *Value) UnmarshalYAML(value *yaml.Node) error
Constants ¶
const ( MCPTypeStdio = "stdio" MCPTypeSSE = "sse" MCPTypeStreamableHTTP = "streamable_http" )
MCP transport types use exact lowercase identifiers with snake_case for multiple words. No aliases, case folding, whitespace trimming, or default apply.
const ( ProviderTypeOpenAI = "openai" ProviderTypeAnthropic = "anthropic" ProviderTypeGemini = "gemini" ProviderTypeQwen = "qwen" ProviderTypeQianfan = "qianfan" ProviderTypeArk = "ark" ProviderTypeDeepSeek = "deepseek" ProviderTypeOllama = "ollama" )
Canonical provider types are exact lowercase identifiers. Aliases, case variants, and surrounding whitespace are rejected. Supported types are openai, anthropic, gemini, qwen, qianfan, ark, deepseek, and ollama. User-defined provider names and remote model IDs are independent of these identifiers.
const DefaultMaxSteps = 1000
DefaultMaxSteps is the ReAct loop cap used when an agent does not set max_steps. Eino's own default (12) is far too low once tools are involved.
const MCPToolNameMaxLength = 64
MCPToolNameMaxLength bounds runtime names including the server__ prefix.
const StarterConfig = `` /* 569-byte string literal not displayed */
StarterConfig is the configuration written on the first run. Oni3 already ships the common providers (OpenAI, Anthropic, Gemini, DeepSeek, Qwen, Kimi, Zhipu, MiniMax, Ollama and more), so this file only needs entries for custom endpoints. Models are imported from the provider at runtime and API keys are never stored here.
Variables ¶
This section is empty.
Functions ¶
func EnsureConfigFile ¶ added in v0.1.1
EnsureConfigFile creates a starter configuration file at path when none exists yet. It reports whether the file was created.
func SkillDirectories ¶
func SkillDirectories() []string
SkillDirectories returns the directories scanned for skill markdown files in priority order: on name clashes the first directory wins.
func ValidateMCPServerName ¶
ValidateMCPServerName reserves room for "__" and at least one remote name character. Names are used verbatim; case and punctuation are never normalized.
func ValidateMCPToolName ¶
ValidateMCPToolName checks the actual runtime name after converting the remote name to a local identifier and adding the server namespace.
func ValidateMCPType ¶
ValidateMCPType accepts only the canonical MCP transport type constants.
func ValidateProviderType ¶
ValidateProviderType accepts only the canonical provider type constants. Call with Provider.EffectiveType() when the empty OpenAI default applies.
Types ¶
type Agent ¶
type Agent struct {
// Name is the label shown in the interface. It is optional: when it is
// empty the configuration key is used as the label.
Name string `yaml:"name,omitempty"`
Description string `yaml:"description,omitempty"`
System string `yaml:"system"`
Model string `yaml:"model"`
Tools []string `yaml:"tools,omitempty"`
MCPServers []string `yaml:"mcp_servers,omitempty"`
// MaxSteps caps the ReAct loop (model + tool rounds). It defaults to
// DefaultMaxSteps when unset.
MaxSteps int `yaml:"max_steps,omitempty"`
}
Agent represents AI agent configuration
type ApprovalConfig ¶
type ApprovalConfig struct {
Mode string `yaml:"mode,omitempty"`
Allow []string `yaml:"allow,omitempty"`
Always []string `yaml:"always,omitempty"`
}
ApprovalConfig controls which tool calls must be confirmed by the user in interactive sessions (agent/chat TUI).
Mode is one of:
- off: never ask
- dangerous: ask only for calls a tool flags as mutating (default)
- all: ask before every tool call
Allow lists tool names that never need approval; Always lists tools that always do (useful for MCP tools, which cannot be classified).
type BuiltinProvider ¶ added in v0.3.0
type BuiltinProvider struct {
Name string // configuration key, also the /provider value
Type string // canonical provider type
BaseURL string
Description string
KeyURL string // where to create an API key
APIKeyOptional bool // local servers need no key
}
BuiltinProvider is a provider preset that ships with Oni3. Presets are only added to the in-memory configuration when the user's file does not define a provider with the same name, so the configuration file always wins.
func BuiltinProviders ¶ added in v0.3.0
func BuiltinProviders() []BuiltinProvider
BuiltinProviders returns the provider presets shown on the first run and in the /provider palette. The catalog mirrors the vendors commonly used with Oni3; OpenAI-compatible endpoints use the openai type so a single client can talk to them.
type ConfLoader ¶
type Config ¶
type Config struct {
Agents map[string]Agent `yaml:"agents,omitempty"`
Providers map[string]Provider `yaml:"providers,omitempty"`
Models map[string]Model `yaml:"models,omitempty"`
DefaultModel string `yaml:"default_model,omitempty"`
MCPServers map[string]MCPServer `yaml:"mcp_servers,omitempty"`
Tools map[string]Tool `yaml:"tools,omitempty"`
Skills map[string]Skill `yaml:"skills,omitempty"`
Settings Settings `yaml:"settings,omitempty"`
Plugins map[string]plugins.Config `yaml:"plugins,omitempty"`
PluginThemes map[string]plugins.Theme `yaml:"-"`
LoadedPlugins []*plugins.Plugin `yaml:"-"`
SourcePath string `yaml:"-"`
// contains filtered or unexported fields
}
Config represents the configuration for Oni3
func LoadConfig ¶
LoadConfig loads configuration from file and saves to global variable
func (*Config) AddProviderModels ¶
AddProviderModels imports a batch atomically and returns usable model names in input order. Existing aliases and their generation settings are preserved.
func (*Config) AgentDisplayName ¶
AgentDisplayName returns the label of the agent with the given configuration key. It falls back to the key itself when no name is set.
func (*Config) AgentUsesDefaultModel ¶
AgentUsesDefaultModel reports whether the agent follows the effective default model (its model is unset or equal to it). Agents that pin their own model in the config keep it, so they are not "default model" agents.
func (*Config) DefaultModelName ¶
DefaultModelName returns the effective default model: `default_model` when it names a configured model, otherwise the alphabetically first configured model. It returns "" when no model is configured.
func (*Config) EmitPluginEvent ¶
EmitPluginEvent invokes subscribers in configured plugin-name order. A hook error is returned to the caller, so failures cannot silently disappear.
func (*Config) HasPluginHook ¶
HasPluginHook reports whether an event has subscribers.
func (*Config) SetProviderAPIKey ¶
SetProviderAPIKey saves a successfully verified key before updating memory. An explicit key in the source YAML/plugin continues to win on the next load.
type LangfuseConfig ¶
type LangfuseConfig struct {
Host string `yaml:"host"`
PublicKey string `yaml:"public_key"`
SecretKey string `yaml:"secret_key"`
Threads int `yaml:"threads,omitempty"`
Timeout time.Duration `yaml:"timeout,omitempty"`
MaxTaskQueueSize int `yaml:"max_task_queue_size,omitempty"`
FlushAt int `yaml:"flush_at,omitempty"`
FlushInterval time.Duration `yaml:"flush_interval,omitempty"`
SampleRate float64 `yaml:"sample_rate,omitempty"`
LogMessage string `yaml:"log_message,omitempty"`
MaxRetry uint64 `yaml:"max_retry,omitempty"`
Name string `yaml:"name,omitempty"`
UserID string `yaml:"user_id,omitempty"`
SessionID string `yaml:"session_id,omitempty"`
Release string `yaml:"release,omitempty"`
Tags []string `yaml:"tags,omitempty"`
Public bool `yaml:"public,omitempty"`
}
LangfuseConfig owns the YAML schema instead of relying on the SDK's untagged Go fields. Duration values include units, e.g. timeout: 30s.
func (*LangfuseConfig) SDKConfig ¶
func (c *LangfuseConfig) SDKConfig() *langfuse.Config
SDKConfig converts the application schema to the upstream callback options.
type MCPServer ¶
type MCPServer struct {
// Type must be exactly stdio, sse, or streamable_http; it has no default.
Type string `yaml:"type"`
// Description is an optional label shown in the interface (e.g. the /mcp
// palette). When it is empty a summary of the endpoint is shown instead.
Description string `yaml:"description,omitempty"`
// for stdio
Cmd string `yaml:"cmd,omitempty"`
Args []string `yaml:"args,omitempty"`
Env map[string]string `yaml:"env,omitempty"`
// for sse & streamable_http
URL string `yaml:"url,omitempty"`
Headers map[string]string `yaml:"headers,omitempty"`
}
MCPServer represents MCP server configuration
type Model ¶
type Model struct {
Provider string `yaml:"provider"`
Model string `yaml:"model"`
MaxTokens int `yaml:"max_tokens,omitempty"`
Temperature float64 `yaml:"temperature,omitempty"`
TopP float64 `yaml:"top_p,omitempty"`
TopK int `yaml:"top_k,omitempty"`
}
Model represents AI model configuration
type Provider ¶
type Provider struct {
// Type is an exact canonical identifier (see ProviderType constants).
// Only the empty string defaults to openai; aliases and case variants fail.
Type string `yaml:"type,omitempty"`
BaseURL string `yaml:"base_url,omitempty"`
APIKey string `yaml:"api_key,omitempty"`
Description string `yaml:"description,omitempty"`
// KeyURL points at the page that issues an API key for this provider. It is
// shown by the API key prompt; built-in presets fill it in.
KeyURL string `yaml:"key_url,omitempty"`
// ModelsURL may be absolute or relative to BaseURL. A relative path such as
// "models" appends to its base path; "/models" replaces the base path.
ModelsURL string `yaml:"models_url,omitempty"`
ModelsPath string `yaml:"models_path,omitempty"`
ModelIDPath string `yaml:"model_id_path,omitempty"`
ModelNamePath string `yaml:"model_name_path,omitempty"`
ModelHeaders map[string]string `yaml:"model_headers,omitempty"`
APIKeyOptional bool `yaml:"api_key_optional,omitempty"`
}
Provider represents AI provider configuration
func (Provider) EffectiveType ¶
EffectiveType applies the OpenAI default only to an empty Type. It preserves all nonempty values so validation can reject noncanonical spellings.
type Settings ¶
type Settings struct {
Langfuse *LangfuseConfig `yaml:"langfuse,omitempty"`
Approval *ApprovalConfig `yaml:"approval,omitempty"`
}
Settings global settings
type Skill ¶
type Skill struct {
Description string `yaml:"description,omitempty"`
System string `yaml:"system,omitempty"`
Tools []string `yaml:"tools,omitempty"`
}
Skill represents an optional capability preset that can be switched on at runtime (via the /skill command in the TUI). A skill extends the active agent's system prompt and can add extra tools.
type Tool ¶
type Tool struct {
Type string `yaml:"type"`
Description string `yaml:"description,omitempty"`
Config map[string]Value `yaml:"config,omitempty"`
Parameters []ToolParameter `yaml:"parameters,omitempty"`
PluginTool *plugins.Tool `yaml:"-"`
}
Tool represents tool configuration
type ToolParameter ¶
type ToolParameter struct {
Name string `yaml:"name"`
Type string `yaml:"type"`
Description string `yaml:"description,omitempty"`
Required bool `yaml:"required,omitempty"`
}
ToolParameter represents tool parameter configuration.