config

package
v2.5.1 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MCPToolPolicyAsk               = "ask"
	MCPToolPolicyAutoRunInDM       = "auto_run_in_dm"
	MCPToolPolicyAutoRunEverywhere = "auto_run_everywhere"
)

Variables

This section is empty.

Functions

func DeepCopyJSON

func DeepCopyJSON[T any](src T) (T, error)

DeepCopyJSON creates a deep copy of JSON-serializable structs

func IsToolPolicyAutoRunEverywhere

func IsToolPolicyAutoRunEverywhere(policy string) bool

IsToolPolicyAutoRunEverywhere returns true only for policies that auto-execute without approval regardless of conversation context (DM or channel).

func IsToolPolicyAutoRunInDM

func IsToolPolicyAutoRunInDM(policy string) bool

IsToolPolicyAutoRunInDM returns true when the policy auto-executes in a DM without user approval. Both auto_run_in_dm (DM-only) and auto_run_everywhere satisfy this; the difference is whether the tool also auto-runs in channels.

Types

type Config

type Config struct {
	Services                        []llm.ServiceConfig              `json:"services"`
	Bots                            []llm.BotConfig                  `json:"bots"`
	DefaultBotName                  string                           `json:"defaultBotName"`
	TranscriptGenerator             string                           `json:"transcriptBackend"`
	EnableTokenUsageLogging         bool                             `json:"enableTokenUsageLogging"`
	EnableCallSummary               bool                             `json:"enableCallSummary"`
	EnableTokenUsageLogToPlugin     *bool                            `json:"enableTokenUsageLogToPlugin,omitempty"`
	EnableTokenUsageLogToFile       *bool                            `json:"enableTokenUsageLogToFile,omitempty"`
	AllowedUpstreamHostnames        string                           `json:"allowedUpstreamHostnames"`
	AllowUnsafeLinks                bool                             `json:"allowUnsafeLinks"`
	EnableChannelMentionToolCalling bool                             `json:"enableChannelMentionToolCalling"`
	AllowNativeWebSearchInChannels  bool                             `json:"allowNativeWebSearchInChannels"`
	EmbeddingSearchConfig           embeddings.EmbeddingSearchConfig `json:"embeddingSearchConfig"`
	MCP                             MCPConfig                        `json:"mcp"`
	WebSearch                       WebSearchConfig                  `json:"webSearch"`
	TelemetryOutput                 string                           `json:"telemetryOutput"`
	OpenTelemetryEndpoint           string                           `json:"openTelemetryEndpoint"`
}

func MigrateSeparateServicesFromBots

func MigrateSeparateServicesFromBots(cfg Config) (Config, bool, error)

MigrateSeparateServicesFromBots extracts embedded service configs from bots into standalone service entries, deduplicating identical services. Returns the updated config, whether any changes were made, and any error.

func MigrateServicesToBots

func MigrateServicesToBots(cfg Config, loadLegacyConfig func() (LegacyServiceConfig, error)) (Config, bool, error)

MigrateServicesToBots migrates legacy service configs (from old config.json format) to the new bots+services model. Returns the updated config, whether any changes were made, and any error.

loadLegacyConfig is a function that loads the legacy JSON configuration (e.g., from config.json via the plugin API). It is only called if migration appears necessary.

func RunAllLegacyMigrations

func RunAllLegacyMigrations(cfg Config, loadLegacyConfig func() (LegacyServiceConfig, error)) (Config, bool, error)

RunAllLegacyMigrations runs all legacy config migrations in order. Returns the final config, whether any changes were made, and any error.

loadLegacyConfig is passed through to MigrateServicesToBots; it is only called if that specific migration is needed.

func (*Config) Clone

func (c *Config) Clone() *Config

func (*Config) GetServiceByID

func (c *Config) GetServiceByID(id string) (llm.ServiceConfig, bool)

GetServiceByID returns the service configuration for the given ID

type Container

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

func (*Container) AllowNativeWebSearchInChannels

func (c *Container) AllowNativeWebSearchInChannels() bool
func (c *Container) AllowUnsafeLinks() bool

func (*Container) Config

func (c *Container) Config() *Config

Config retruns the whole configuration readonly. Avoid using this method, prefer using config though interfaces.

func (*Container) EmbeddingSearchConfig

func (c *Container) EmbeddingSearchConfig() embeddings.EmbeddingSearchConfig

func (*Container) EnableChannelMentionToolCalling

func (c *Container) EnableChannelMentionToolCalling() bool

func (*Container) EnableTokenUsageLogToFile

func (c *Container) EnableTokenUsageLogToFile() bool

func (*Container) EnableTokenUsageLogToPlugin

func (c *Container) EnableTokenUsageLogToPlugin() bool

func (*Container) EnableTokenUsageLogging

func (c *Container) EnableTokenUsageLogging() bool

func (*Container) GetBots

func (c *Container) GetBots() []llm.BotConfig

func (*Container) GetDefaultBotName

func (c *Container) GetDefaultBotName() string

func (*Container) GetServiceByID

func (c *Container) GetServiceByID(id string) (llm.ServiceConfig, bool)

GetServiceByID returns the service configuration for the given ID

func (*Container) GetTranscriptGenerator

func (c *Container) GetTranscriptGenerator() string

func (*Container) MCP

func (c *Container) MCP() MCPConfig

func (*Container) RegisterUpdateListener

func (c *Container) RegisterUpdateListener(listener UpdateListener)

func (*Container) StorePersistedConfigWithoutNotify

func (c *Container) StorePersistedConfigWithoutNotify(newConfig *Config) error

StorePersistedConfigWithoutNotify updates in-memory configuration from a value read back from persistent storage without notifying update listeners. Use when the current call stack may already be servicing a listener (for example after SaveConfig during legacy migration) to avoid re-entrant listener invocation and deadlocks.

func (*Container) Update

func (c *Container) Update(newConfig *Config)

Updates the current configuration The new configuration is deep-copied to ensure the new and old configurations are independent of each other.

type LegacyServiceConfig

type LegacyServiceConfig struct {
	Config struct {
		Services []struct {
			Name         string `json:"name"`
			ServiceName  string `json:"serviceName"`
			DefaultModel string `json:"defaultModel"`
			OrgID        string `json:"orgId"`
			URL          string `json:"url"`
			APIKey       string `json:"apiKey"`
			TokenLimit   int    `json:"tokenLimit"`
		} `json:"services"`
	} `json:"config"`
}

LegacyServiceConfig represents the old config.json format with the legacy service fields. This is used during the one-time migration from config.json to the database.

type MCPConfig

type MCPConfig struct {
	Enabled            bool                    `json:"enabled"`
	EnablePluginServer bool                    `json:"enablePluginServer"`
	Servers            []MCPServerConfig       `json:"servers"`
	PluginServers      []PluginServerConfig    `json:"plugin_servers,omitempty"`
	EmbeddedServer     MCPEmbeddedServerConfig `json:"embeddedServer"`
	IdleTimeoutMinutes int                     `json:"idleTimeoutMinutes"`
}

MCPConfig contains the configuration for the MCP servers

type MCPEmbeddedServerConfig

type MCPEmbeddedServerConfig struct {
	Enabled     bool            `json:"enabled"`
	ToolConfigs []MCPToolConfig `json:"tool_configs,omitempty"`
}

MCPEmbeddedServerConfig contains configuration for the embedded MCP server

type MCPServerConfig

type MCPServerConfig struct {
	Name         string            `json:"name"`
	Enabled      bool              `json:"enabled"`
	BaseURL      string            `json:"baseURL"`
	Headers      map[string]string `json:"headers,omitempty"`
	ClientID     string            `json:"clientID,omitempty"`
	ClientSecret string            `json:"clientSecret,omitempty"`
	ToolConfigs  []MCPToolConfig   `json:"tool_configs,omitempty"`
}

MCPServerConfig contains the configuration for a single MCP server

func (*MCPServerConfig) GetToolPolicy

func (s *MCPServerConfig) GetToolPolicy(toolName string) (string, bool)

GetToolPolicy returns the policy and enabled state for a tool. If the receiver is nil or the tool name is empty, it returns ("ask", false). If no matching config entry exists, it returns ("ask", true) — unconfigured tools default to enabled with ask policy. Invalid or empty policies are normalized to "ask". When duplicate entries exist the last matching entry wins.

func (*MCPServerConfig) IsToolAutoRunInDM

func (s *MCPServerConfig) IsToolAutoRunInDM(toolName string) bool

IsToolAutoRunInDM returns true when the tool is enabled and configured to auto-run in a DM (either the DM-only or everywhere policy).

type MCPToolConfig

type MCPToolConfig struct {
	Name                         string `json:"name"`
	Policy                       string `json:"policy"` // "auto_run_in_dm" | "auto_run_everywhere" | "ask"
	Enabled                      bool   `json:"enabled"`
	RetrievalDescriptionOverride string `json:"retrieval_description_override,omitempty"`
}

MCPToolConfig represents per-tool configuration for an MCP server.

type PluginServerConfig

type PluginServerConfig struct {
	PluginID       string          `json:"plugin_id"`
	Name           string          `json:"name"`
	Path           string          `json:"path"`
	Enabled        bool            `json:"enabled"`
	ExposeExternal bool            `json:"expose_external"`
	ToolConfigs    []MCPToolConfig `json:"tool_configs,omitempty"`
}

PluginServerConfig describes an MCP server registered by another plugin.

type UpdateListener

type UpdateListener func()

type WebSearchBraveConfig

type WebSearchBraveConfig struct {
	APIKey       string `json:"apiKey"`
	APIURL       string `json:"apiURL"`
	ResultLimit  int    `json:"resultLimit"`
	PollTimeout  int    `json:"pollTimeout"`
	PollInterval int    `json:"pollInterval"`
}

type WebSearchConfig

type WebSearchConfig struct {
	Enabled        bool                  `json:"enabled"`
	Provider       string                `json:"provider"`
	Google         WebSearchGoogleConfig `json:"google"`
	Brave          WebSearchBraveConfig  `json:"brave"`
	DomainDenylist []string              `json:"domainDenylist"`
}

type WebSearchGoogleConfig

type WebSearchGoogleConfig struct {
	APIKey         string `json:"apiKey"`
	SearchEngineID string `json:"searchEngineId"`
	ResultLimit    int    `json:"resultLimit"`
	APIURL         string `json:"apiURL"`
}

Jump to

Keyboard shortcuts

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