Documentation
¶
Overview ¶
Package config loads MemSpace configuration from TOML and environment variables.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ResolvePath ¶
ResolvePath picks the config file: the explicit path, then $MEMSPACE_CONFIG, then <home>/config.toml if it exists. Returns "" when there is none.
Types ¶
type AuthConfig ¶
type AuthConfig struct {
// OwnerUserID is the single owner for v0.1.
OwnerUserID string `toml:"owner_user_id"`
}
type ClientConfig ¶
type ClientConfig struct {
// Home is the client state directory (default $MEMSPACE_HOME or ~/.memspace).
Home string `toml:"home"`
// ServerURL overrides the server URL saved by `memspace client connect`.
ServerURL string `toml:"server_url"`
// SpoolMaxEvents caps the number of unsent events kept locally.
SpoolMaxEvents int `toml:"spool_max_events"`
// SpoolMaxBytes caps the total size of unsent events kept locally.
SpoolMaxBytes int64 `toml:"spool_max_bytes"`
// BatchSize is the maximum number of events per upload request.
BatchSize int `toml:"batch_size"`
// BackoffBase and BackoffMax bound the exponential retry delay after a
// failed sync.
BackoffBase Duration `toml:"backoff_base"`
BackoffMax Duration `toml:"backoff_max"`
// Inject controls context injection into agent sessions: "on"
// (default) or "off".
Inject string `toml:"inject"`
// AutoUpgrade controls whether the client replaces itself with the
// server's version when the server is newer: "on" (default) or "off"
// (doctor and the web UI still show that it is behind).
AutoUpgrade string `toml:"auto_upgrade"`
}
ClientConfig controls the per-device client: credentials, spool and sync.
All client state lives under Home, which must be an absolute path: hooks run with the agent's project directory as cwd, so relative paths would scatter state across repositories.
func (ClientConfig) CredentialsPath ¶
func (c ClientConfig) CredentialsPath() string
func (ClientConfig) LogDir ¶
func (c ClientConfig) LogDir() string
func (ClientConfig) SpoolDir ¶
func (c ClientConfig) SpoolDir() string
Paths derived from ClientConfig.Home.
func (ClientConfig) StateDir ¶
func (c ClientConfig) StateDir() string
type Config ¶
type Config struct {
Server ServerConfig `toml:"server"`
Database DatabaseConfig `toml:"database"`
Auth AuthConfig `toml:"auth"`
Client ClientConfig `toml:"client"`
Embedding EmbeddingConfig `toml:"embedding"`
}
Config is the top-level configuration structure.
func Load ¶
Load reads configuration from a TOML file at path (see ResolvePath). If path is empty or the file does not exist, defaults are returned. Environment variables override file values:
MEMSPACE_ADDRESS → server.address MEMSPACE_DB_PATH → database.path MEMSPACE_OWNER_USER_ID → auth.owner_user_id MEMSPACE_HOME → client.home MEMSPACE_SERVER_URL → client.server_url MEMSPACE_BACKOFF_BASE → client.backoff_base MEMSPACE_INJECT → client.inject MEMSPACE_AUTO_UPGRADE → client.auto_upgrade MEMSPACE_UPDATE_CHECK → server.update_check MEMSPACE_EMBEDDING_URL → embedding.url MEMSPACE_EMBEDDING_MODEL → embedding.model
type DatabaseConfig ¶
type DatabaseConfig struct {
// Path is the SQLite database file path.
Path string `toml:"path"`
}
type Duration ¶
Duration is a time.Duration that decodes from a TOML string like "30s".
func (*Duration) UnmarshalText ¶
type EmbeddingConfig ¶
type EmbeddingConfig struct {
// URL of the embeddings endpoint, e.g. http://127.0.0.1:8090/v1/embeddings.
// Empty disables semantic search.
URL string `toml:"url"`
Model string `toml:"model"`
// APIKeyEnv names an environment variable holding a bearer key.
APIKeyEnv string `toml:"api_key_env"`
// Dimensions requests Matryoshka-truncated vectors (0 = native).
Dimensions int `toml:"dimensions"`
// QueryPrefix is prepended to queries ("" = automatic: "query: " for
// Snowflake arctic-embed models).
QueryPrefix string `toml:"query_prefix"`
BatchSize int `toml:"batch_size"`
QueryTimeout Duration `toml:"query_timeout"`
// MinSimilarity is the cosine similarity a meaning-only match needs to
// be injected into an agent's context; SearchMinSimilarity is the floor
// below which semantic hits are dropped from search. 0 = the model's
// calibrated value (bge-m3 0.60 / 0.45, arctic-embed 0.35 / 0.20).
MinSimilarity float64 `toml:"min_similarity"`
SearchMinSimilarity float64 `toml:"search_min_similarity"`
}
EmbeddingConfig enables semantic search through an OpenAI-compatible embeddings service (e.g. embeddings.cpp's embeddings_server). The server calls it, so the URL must be reachable from the server.
type ServerConfig ¶
type ServerConfig struct {
// Address is the listen address, e.g. "127.0.0.1:8765".
// Default binds to localhost only (security: remote access must be explicit).
Address string `toml:"address"`
// PublicURL is how browsers reach the server (e.g. behind a reverse
// proxy); used for login links printed by `memspace server login-link`.
// Default: http://<address>.
PublicURL string `toml:"public_url"`
// DownloadsDir holds client binaries (memspace-<os>-<arch>[.exe]) served
// at /downloads/ for setting up new devices. Empty: no downloads.
DownloadsDir string `toml:"downloads_dir"`
// UpdateCheck asks GitHub once a day for the latest release, so the web
// UI can show that a newer server is available: "on" (default) or "off".
UpdateCheck string `toml:"update_check"`
}