config

package
v0.2.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyRuntimeEnv

func ApplyRuntimeEnv(config Config)

func ApplySearchKeys

func ApplySearchKeys(config Config)

ApplySearchKeys sets search-provider env vars from config fields so that the search tool sub-packages pick them up via os.Getenv.

func DefaultConfigPath

func DefaultConfigPath() string

func DetectProviderFromModel

func DetectProviderFromModel(model string) sdk.APIProvider

DetectProviderFromModel infers the provider from the requested model name.

func EffectiveAPIKeyAndProvider

func EffectiveAPIKeyAndProvider(config Config) (string, sdk.APIProvider)

EffectiveAPIKeyAndProvider resolves the configured provider credentials in priority order.

func EffectiveBackendSQLitePath

func EffectiveBackendSQLitePath(config Config) string

EffectiveBackendSQLitePath returns the SQLite file used when the backend DB driver itself is SQLite.

func EffectiveDBPath

func EffectiveDBPath(config Config) string

EffectiveDBPath returns the legacy local SQLite path used by CLI/runtime code. For backend hosts, prefer EffectiveBackendSQLitePath and EffectiveSessionDBPath.

func EffectiveRuntimeRoot

func EffectiveRuntimeRoot(config Config) string

func EffectiveSessionDBPath

func EffectiveSessionDBPath(config Config) string

EffectiveSessionDBPath returns the SQLite file used for runtime session/core persistence. It is independent from the backend DB driver so a Postgres backend can still keep the runtime session store in SQLite.

func EffectiveStorageLocalPath

func EffectiveStorageLocalPath(config Config) string

func ExpandShellValues

func ExpandShellValues(cfg *Config)

ExpandShellValues walks a Config and evaluates any field value of the form "$(command args)" by running the command in a shell. This mirrors crush's config shell-eval feature. The expansion runs at config load time and is memoized by storing the result back into the config.

Only string fields that contain "$(" are processed. Failed expansions leave the original string intact and log a warning — they don't abort startup.

func HasExplicitProviderPrefix

func HasExplicitProviderPrefix(raw string) bool

HasExplicitProviderPrefix reports whether a model string explicitly carries a recognized provider prefix.

func IsKnownProvider

func IsKnownProvider(provider sdk.APIProvider) bool

func LoadInto

func LoadInto(config *Config) error

LoadInto refreshes a caller-owned config from env files, env vars, and config files.

func ParseModelIdentifier

func ParseModelIdentifier(raw string) sdk.ModelIdentifier

ParseModelIdentifier normalizes optional provider prefixes like "openai:gpt-4o". Returns an empty ModelIdentifier when raw is empty — callers that need a concrete default should apply sdk.DefaultClientConfig().Model themselves.

func ProviderCredentialEnvVars

func ProviderCredentialEnvVars(provider sdk.APIProvider) []string

func ProviderForModel

func ProviderForModel(model string) sdk.APIProvider

func ProviderNames

func ProviderNames() []sdk.APIProvider

func ResolveAPIKey

func ResolveAPIKey(config Config, provider sdk.APIProvider) string

func ResolveProvider

func ResolveProvider(raw string) sdk.APIProvider

func Save

func Save(config Config) error

func SaveAt

func SaveAt(path string, config Config) error

func ValidateProviderSetup

func ValidateProviderSetup(config Config, provider sdk.APIProvider) error

Types

type Config

type Config struct {
	RuntimeRoot       string  `mapstructure:"runtime_root" yaml:"runtime_root,omitempty"`
	Cwd               string  `mapstructure:"cwd" yaml:"cwd,omitempty"`
	Model             string  `mapstructure:"model" yaml:"model,omitempty"`
	MaxTokens         int     `mapstructure:"max_tokens" yaml:"max_tokens,omitempty"`
	Temperature       float64 `mapstructure:"temperature" yaml:"temperature,omitempty"`
	MCPEnabled        bool    `mapstructure:"mcp_enabled" yaml:"mcp_enabled,omitempty"`
	SkillsEnabled     bool    `mapstructure:"skills_enabled" yaml:"skills_enabled,omitempty"`
	Debug             bool    `mapstructure:"debug" yaml:"debug,omitempty"`
	APIKey            string  `mapstructure:"api_key" yaml:"api_key,omitempty"`
	DBPath            string  `mapstructure:"db_path" yaml:"db_path,omitempty"`
	SessionDBPath     string  `mapstructure:"session_db_path" yaml:"session_db_path,omitempty"`
	ProviderBaseURL   string  `mapstructure:"provider_base_url" yaml:"provider_base_url,omitempty"`
	ProviderRegion    string  `mapstructure:"provider_region" yaml:"provider_region,omitempty"`
	ProviderProjectID string  `mapstructure:"provider_project_id" yaml:"provider_project_id,omitempty"`
	ProviderResource  string  `mapstructure:"provider_resource" yaml:"provider_resource,omitempty"`
	AdminEmail        string  `mapstructure:"admin_email" yaml:"admin_email,omitempty"`
	AdminPassword     string  `mapstructure:"admin_password" yaml:"-"`
	AdminPasswordHash string  `mapstructure:"admin_password_hash" yaml:"admin_password_hash,omitempty"`

	// Database driver configuration (multi-driver support)
	DBDriver      string `mapstructure:"db_driver" yaml:"db_driver,omitempty"`
	DBDSN         string `mapstructure:"db_dsn" yaml:"db_dsn,omitempty"`
	DBAutoMigrate bool   `mapstructure:"db_auto_migrate" yaml:"db_auto_migrate,omitempty"`

	// Embedder configuration for the RAG / knowledge domain
	EmbedderBaseURL  string `mapstructure:"embedder_base_url" yaml:"embedder_base_url,omitempty"`
	EmbedderAPIKey   string `mapstructure:"embedder_api_key" yaml:"embedder_api_key,omitempty"`
	EmbedderModel    string `mapstructure:"embedder_model" yaml:"embedder_model,omitempty"`
	EmbedderProvider string `mapstructure:"embedder_provider" yaml:"embedder_provider,omitempty"`

	// Vector store backend (sqlite|pgvector|qdrant|chroma|memory). Defaults to sqlite.
	VectorBackend           string `mapstructure:"vector_backend" yaml:"vector_backend,omitempty"`
	QdrantHost              string `mapstructure:"qdrant_host" yaml:"qdrant_host,omitempty"`
	QdrantPort              int    `mapstructure:"qdrant_port" yaml:"qdrant_port,omitempty"`
	QdrantAPIKey            string `mapstructure:"qdrant_api_key" yaml:"qdrant_api_key,omitempty"`
	QdrantPrefix            string `mapstructure:"qdrant_prefix" yaml:"qdrant_prefix,omitempty"`
	PgVectorCreateExtension bool   `mapstructure:"pgvector_create_extension" yaml:"pgvector_create_extension,omitempty"`
	PgVectorDSN             string `mapstructure:"pgvector_dsn" yaml:"pgvector_dsn,omitempty"`
	PgVectorIndexMethod     string `mapstructure:"pgvector_index_method" yaml:"pgvector_index_method,omitempty"`
	PgVectorHNSWM           int    `mapstructure:"pgvector_hnsw_m" yaml:"pgvector_hnsw_m,omitempty"`
	PgVectorHNSWEF          int    `mapstructure:"pgvector_hnsw_ef_construction" yaml:"pgvector_hnsw_ef_construction,omitempty"`
	PgVectorIVFFlatLists    int    `mapstructure:"pgvector_ivfflat_lists" yaml:"pgvector_ivfflat_lists,omitempty"`
	ChromaURL               string `mapstructure:"chroma_url" yaml:"chroma_url,omitempty"`
	ChromaAPIKey            string `mapstructure:"chroma_api_key" yaml:"chroma_api_key,omitempty"`
	ChromaTenant            string `mapstructure:"chroma_tenant" yaml:"chroma_tenant,omitempty"`
	ChromaDatabase          string `mapstructure:"chroma_database" yaml:"chroma_database,omitempty"`

	// Storage configuration
	StorageProvider         string `mapstructure:"storage_provider" yaml:"storage_provider,omitempty"`
	StorageLocalPath        string `mapstructure:"storage_local_path" yaml:"storage_local_path,omitempty"`
	S3Endpoint              string `mapstructure:"s3_endpoint" yaml:"s3_endpoint,omitempty"`
	S3Bucket                string `mapstructure:"s3_bucket" yaml:"s3_bucket,omitempty"`
	S3AccessKeyID           string `mapstructure:"s3_access_key_id" yaml:"s3_access_key_id,omitempty"`
	S3SecretAccessKey       string `mapstructure:"s3_secret_access_key" yaml:"s3_secret_access_key,omitempty"`
	S3Region                string `mapstructure:"s3_region" yaml:"s3_region,omitempty"`
	S3KeyPrefix             string `mapstructure:"s3_key_prefix" yaml:"s3_key_prefix,omitempty"`
	StorageGCEnabled        bool   `mapstructure:"storage_gc_enabled" yaml:"storage_gc_enabled,omitempty"`
	StorageGCInterval       string `mapstructure:"storage_gc_interval" yaml:"storage_gc_interval,omitempty"`
	StorageGCLimit          int    `mapstructure:"storage_gc_limit" yaml:"storage_gc_limit,omitempty"`
	StorageGCNamespaces     string `mapstructure:"storage_gc_namespaces" yaml:"storage_gc_namespaces,omitempty"`
	BrowserRemoteControlURL string `mapstructure:"browser_remote_control_url" yaml:"browser_remote_control_url,omitempty"`
	BrowserExecutablePath   string `mapstructure:"browser_executable_path" yaml:"browser_executable_path,omitempty"`
	DoclingURL              string `mapstructure:"docling_url" yaml:"docling_url,omitempty"`
	AutomationServiceURL    string `mapstructure:"automation_service_url" yaml:"automation_service_url,omitempty"`
	AutomationAPIKey        string `mapstructure:"-" yaml:"-"` // loaded from env only, never persisted

	// Search tool integration keys — loaded from the credentials DB at runtime,
	// never stored in the YAML config file.
	TavilyAPIKey      string `mapstructure:"-" yaml:"-"`
	ExaAPIKey         string `mapstructure:"-" yaml:"-"`
	JinaAPIKey        string `mapstructure:"-" yaml:"-"`
	WebSearchProvider string `mapstructure:"web_search_provider" yaml:"web_search_provider,omitempty"`

	// API rate limiting — max requests per minute per authenticated user (0 = disabled)
	RateLimitPerMinute int `mapstructure:"rate_limit_per_minute" yaml:"rate_limit_per_minute,omitempty"`

	// User management flags
	EnableSignup    bool   `mapstructure:"enable_signup" yaml:"enable_signup,omitempty"`
	DefaultUserRole string `mapstructure:"default_user_role" yaml:"default_user_role,omitempty"`
	EnableAPIKeys   bool   `mapstructure:"enable_api_keys" yaml:"enable_api_keys,omitempty"`

	// Skill repository collections — comma-separated git URLs cloned at startup.
	// Example: SESHAT_SKILL_REPOS=https://github.com/romainsimon/paperasse
	SkillRepos string `mapstructure:"skill_repos" yaml:"skill_repos,omitempty"`

	// FeaturedSkillRepos — comma-separated git URLs shown as installable catalog entries in the UI.
	// Example: SESHAT_FEATURED_SKILL_REPOS=https://github.com/romainsimon/paperasse
	FeaturedSkillRepos string `mapstructure:"featured_skill_repos" yaml:"featured_skill_repos,omitempty"`

	// TrustedProxies — comma-separated CIDR ranges (or bare IPs) of reverse proxies whose
	// X-Forwarded-For / X-Real-Ip headers should be trusted for IP resolution.
	// Leave empty (the default) for a desktop deployment without a reverse proxy.
	// Example: SESHAT_TRUSTED_PROXIES=10.0.0.0/8,172.16.0.0/12
	TrustedProxies string `mapstructure:"trusted_proxies" yaml:"trusted_proxies,omitempty"`

	// SkillRepoHosts — comma-separated list of git hosting domains allowed when installing
	// a skill repo via the API. Defaults to github.com, gitlab.com, bitbucket.org, codeberg.org.
	// Example: SESHAT_SKILL_REPO_HOSTS=github.com,mygitlab.company.com
	SkillRepoHosts string `mapstructure:"skill_repo_hosts" yaml:"skill_repo_hosts,omitempty"`

	// DefaultSkillRepo — git URL of the official Seshat skills collection cloned
	// silently in the background on first boot. Defaults to the canonical seshat-skills
	// repo. Set to "none" to disable automatic install.
	// Example: SESHAT_DEFAULT_SKILL_REPO=https://github.com/EngineerProjects/seshat-skills
	DefaultSkillRepo string `mapstructure:"default_skill_repo" yaml:"default_skill_repo,omitempty"`

	// Hooks — user-defined shell commands that fire on lifecycle events.
	// Currently supported event: pre_tool_use (fires before every tool call).
	//
	// Example .seshat.yaml:
	//   hooks:
	//     pre_tool_use:
	//       - command: "jq '.command' && exit 0"
	//         matcher: "bash"
	//         timeout: 10
	Hooks map[string][]HookEntry `mapstructure:"hooks" yaml:"hooks,omitempty"`
}

Config contains host-level runtime settings shared by CLI and server entrypoints.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns the shared defaults used by host applications.

func Load

func Load() (Config, error)

Load returns a fully initialized shared runtime config.

type HookEntry

type HookEntry struct {
	Matcher string `mapstructure:"matcher" yaml:"matcher,omitempty"`
	Command string `mapstructure:"command" yaml:"command"`
	Timeout int    `mapstructure:"timeout" yaml:"timeout,omitempty"`
}

HookEntry mirrors hooks.HookConfig but lives in pkg/config to avoid import cycles.

type ModelInfo

type ModelInfo struct {
	Identifier    string
	ContextWindow int
	MaxOutput     int
	SupportsPC    bool
	Pricing       string
	Description   string
}

type ProviderInfo

type ProviderInfo struct {
	Name         sdk.APIProvider
	DisplayName  string
	Description  string
	AuthType     string
	AuthTypes    []string
	SupportsCVMM bool
	SupportsPC   bool
	Models       []ModelInfo
	SetupFields  []ProviderSetupField
	SetupHint    string
}

func AvailableProviders

func AvailableProviders() []ProviderInfo

func GetProviderInfo

func GetProviderInfo(provider sdk.APIProvider) (ProviderInfo, bool)

type ProviderSetupField

type ProviderSetupField struct {
	Key         string
	Label       string
	Description string
	EnvVar      string
	Secret      bool
	Required    bool
}

Jump to

Keyboard shortcuts

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