Documentation
¶
Index ¶
- func ApplyRuntimeEnv(config Config)
- func ApplySearchKeys(config Config)
- func DefaultConfigPath() string
- func DetectProviderFromModel(model string) sdk.APIProvider
- func EffectiveAPIKeyAndProvider(config Config) (string, sdk.APIProvider)
- func EffectiveBackendSQLitePath(config Config) string
- func EffectiveDBPath(config Config) string
- func EffectiveRuntimeRoot(config Config) string
- func EffectiveSessionDBPath(config Config) string
- func EffectiveStorageLocalPath(config Config) string
- func ExpandShellValues(cfg *Config)
- func HasExplicitProviderPrefix(raw string) bool
- func IsKnownProvider(provider sdk.APIProvider) bool
- func LoadInto(config *Config) error
- func ParseModelIdentifier(raw string) sdk.ModelIdentifier
- func ProviderCredentialEnvVars(provider sdk.APIProvider) []string
- func ProviderForModel(model string) sdk.APIProvider
- func ProviderNames() []sdk.APIProvider
- func ResolveAPIKey(config Config, provider sdk.APIProvider) string
- func ResolveProvider(raw string) sdk.APIProvider
- func Save(config Config) error
- func SaveAt(path string, config Config) error
- func ValidateProviderSetup(config Config, provider sdk.APIProvider) error
- type Config
- type HookEntry
- type ModelInfo
- type ProviderInfo
- type ProviderSetupField
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyRuntimeEnv ¶
func ApplyRuntimeEnv(config Config)
ApplyRuntimeEnv exports parts of config to the environment: the runtime root and the settings of the selected provider that its client reads there (the region of Bedrock, the project and region of Vertex, the resource of Foundry, the account of Workers AI). Blank values are not exported.
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
DefaultConfigPath returns the path of the configuration file, config.yaml, under the runtime root.
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 ¶
EffectiveBackendSQLitePath returns the SQLite file used when the backend DB driver itself is SQLite.
func EffectiveDBPath ¶
EffectiveDBPath returns the legacy local SQLite path used by CLI/runtime code. For backend hosts, prefer EffectiveBackendSQLitePath and EffectiveSessionDBPath.
func EffectiveRuntimeRoot ¶
EffectiveRuntimeRoot returns the runtime root of a configuration: its RuntimeRoot when it is not blank, otherwise the SESHAT_RUNTIME_ROOT environment variable, otherwise ~/.config/seshat (a seshat directory under the temporary directory when no home can be found). A leading "~" is expanded and the path is cleaned.
func EffectiveSessionDBPath ¶
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 ¶
EffectiveStorageLocalPath returns the directory of the local storage of a configuration: its StorageLocalPath when it is set, with a leading "~" expanded, otherwise the storage directory under the runtime root.
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 ¶
HasExplicitProviderPrefix reports whether a model string explicitly carries a recognized provider prefix.
func IsKnownProvider ¶
func IsKnownProvider(provider sdk.APIProvider) bool
IsKnownProvider reports whether provider is in the catalogue.
func LoadInto ¶
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
ProviderCredentialEnvVars returns the environment variables that can carry the credentials of a provider (for example ANTHROPIC_API_KEY), or none for a provider that does not use an API key (Ollama, Bedrock, Vertex).
func ProviderForModel ¶
func ProviderForModel(model string) sdk.APIProvider
ProviderForModel returns the provider whose catalogue lists the model identifier, compared without regard to case, or an empty provider when no catalogue lists it.
func ProviderNames ¶
func ProviderNames() []sdk.APIProvider
ProviderNames returns the names of the providers of the catalogue, in catalogue order.
func ResolveAPIKey ¶
func ResolveAPIKey(config Config, provider sdk.APIProvider) string
ResolveAPIKey returns the API key to use for provider: the one in the environment when it is set, otherwise the key of config.
func ResolveProvider ¶
func ResolveProvider(raw string) sdk.APIProvider
ResolveProvider turns a provider name as a user may write it (for example "claude", "gpt", "aws", "z.ai") into a provider, or returns an empty provider when the name is not recognised.
func SaveAt ¶
SaveAt writes config as YAML to path, creating the directory if needed. The file is readable and writable by its owner only.
func ValidateProviderSetup ¶
func ValidateProviderSetup(config Config, provider sdk.APIProvider) error
ValidateProviderSetup checks that config holds what provider needs: an API key for most providers, a region for Bedrock, a project id and a region for Vertex, a key and an account id for Workers AI, a key and a base URL or resource id for Foundry, and nothing for Ollama. The error names what is missing.
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"`
TitleModel string `mapstructure:"title_model" yaml:"title_model,omitempty"`
TitleModelBaseURL string `mapstructure:"title_model_base_url" yaml:"title_model_base_url,omitempty"`
TitleModelAPIKey string `mapstructure:"title_model_api_key" yaml:"-"`
TitleLocalEnabled bool `mapstructure:"title_local_enabled" yaml:"title_local_enabled,omitempty"`
TitleLocalRuntime string `mapstructure:"title_local_runtime" yaml:"title_local_runtime,omitempty"`
TitleLocalExe string `mapstructure:"title_local_executable" yaml:"title_local_executable,omitempty"`
TitleLocalModel string `mapstructure:"title_local_model_path" yaml:"title_local_model_path,omitempty"`
TitleLocalHFRepo string `mapstructure:"title_local_hf_repo" yaml:"title_local_hf_repo,omitempty"`
TitleLocalHFFile string `mapstructure:"title_local_hf_file" yaml:"title_local_hf_file,omitempty"`
TitleLocalCache string `mapstructure:"title_local_cache_dir" yaml:"title_local_cache_dir,omitempty"`
TitleLocalArgs string `mapstructure:"title_local_args" yaml:"title_local_args,omitempty"`
TitleLocalTimeout string `mapstructure:"title_local_timeout" yaml:"title_local_timeout,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 (sqlite|pgvector|qdrant|opensearch|chroma|memory). Defaults to sqlite.
VectorStore string `mapstructure:"vector_store" yaml:"vector_store,omitempty"`
// Deprecated: use VectorStore / SESHAT_VECTOR_STORE.
VectorBackend string `mapstructure:"vector_backend" yaml:"-"`
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"`
OpenSearchAddresses string `mapstructure:"opensearch_addresses" yaml:"opensearch_addresses,omitempty"`
OpenSearchUsername string `mapstructure:"opensearch_username" yaml:"opensearch_username,omitempty"`
OpenSearchPassword string `mapstructure:"opensearch_password" yaml:"-"`
OpenSearchAPIKey string `mapstructure:"opensearch_api_key" yaml:"-"`
OpenSearchIndexPrefix string `mapstructure:"opensearch_index_prefix" yaml:"opensearch_index_prefix,omitempty"`
OpenSearchCreateIndex bool `mapstructure:"opensearch_create_index" yaml:"opensearch_create_index,omitempty"`
OpenSearchKNN bool `mapstructure:"opensearch_knn" yaml:"opensearch_knn,omitempty"`
OpenSearchInsecureSkipVerify bool `mapstructure:"opensearch_insecure_skip_verify" yaml:"opensearch_insecure_skip_verify,omitempty"`
OpenSearchBulkSize int `mapstructure:"opensearch_bulk_size" yaml:"opensearch_bulk_size,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"`
DocumentReaderURL string `mapstructure:"document_reader_url" yaml:"document_reader_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/KPO-Tech/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 config.yaml (the actual file LoadInto reads via viper - this
// comment used to say .seshat.yaml, which is not a name this loader ever
// looks for; M5d in TODO.md):
// 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.
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
}
ModelInfo describes a model of a provider: its identifier, its context window and maximum output in tokens, whether it supports prompt caching, its pricing and a description.
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
}
ProviderInfo describes a provider: its name, display name and description, how it authenticates (AuthType, and every accepted type in AuthTypes), whether it accepts images (SupportsCVMM) and supports prompt caching (SupportsPC), its models, the fields to set it up and a hint about the setup.
func AvailableProviders ¶
func AvailableProviders() []ProviderInfo
AvailableProviders returns the providers the runtime knows, in the order of the catalogue, with their models and setup fields.
func GetProviderInfo ¶
func GetProviderInfo(provider sdk.APIProvider) (ProviderInfo, bool)
GetProviderInfo returns the catalogue entry of a provider, and false when the provider is unknown.
type ProviderSetupField ¶
type ProviderSetupField struct {
Key string
Label string
Description string
EnvVar string
Secret bool
Required bool
}
ProviderSetupField is one value needed to set a provider up: its key, label and description, the environment variable that can carry it, whether it is a secret and whether it is required.