config

package
v0.2.6 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2026 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package config loads akari-server configuration.

The server is a container workload, so it reads its configuration from the environment by convention. (The akari client, by contrast, uses a config file and defines no environment variables of its own; see docs/DESIGN.md.)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultClientPath

func DefaultClientPath() (string, error)

DefaultClientPath returns the platform-standard config file path: ~/.config/akari/config.toml on Linux, ~/Library/Application Support/akari/config.toml on macOS, %AppData%\akari\config.toml on Windows.

func SaveClient

func SaveClient(path string, c Client) error

SaveClient writes the config to path (creating parent directories) with owner-only permissions since it holds an API token. It writes to a temporary file and atomically renames it into place, so a crash or write error cannot truncate or destroy an existing config.

Types

type Client

type Client struct {
	// ServerURL is the base URL of the akari server, e.g. https://akari.example.
	ServerURL string `toml:"server_url"`
	// Token is an API token (ingest or full scope) used as a Bearer credential.
	Token string `toml:"token"`
	// ExtraRoots are additional session directories to discover beyond each
	// agent's standard roots.
	ExtraRoots []ExtraRoot `toml:"extra_roots"`
	// Excludes are glob patterns of paths to skip during discovery, applied to
	// both `akari sync` and `akari watch`. Patterns match the full path with
	// forward slashes and `*`/`**` span separators (see discover.Excluder), so
	// `**/tmp/**` ignores any path with a `tmp` segment. Empty means discover
	// everything.
	Excludes []string `toml:"excludes"`
}

Client holds the akari client configuration. All of it lives in one TOML file at the platform per-user config location; the client keeps no other on-disk state and defines no environment variables of its own.

func LoadClient

func LoadClient(path string) (Client, error)

LoadClient reads and validates the client config. An empty path uses DefaultClientPath. A missing file is a usable error directing the user to log in.

func ReadClient

func ReadClient(path string) (cfg Client, exists bool, err error)

ReadClient decodes the config without validating it. It reports whether the file existed (a missing file is not an error: callers like login start from a blank config) and returns an error only on a genuine read or parse failure, so a corrupt file is never silently treated as empty.

type ExtraRoot

type ExtraRoot struct {
	Agent string `toml:"agent"` // claude | codex | pi
	Path  string `toml:"path"`
}

ExtraRoot is a user-configured session directory for one agent.

type Server

type Server struct {
	// DatabaseURL is the Postgres connection string (AKARI_DATABASE_URL).
	DatabaseURL string
	// Listen is the address the HTTP server binds (AKARI_LISTEN), e.g. ":8080".
	Listen string
	// CookieSecure marks session cookies Secure. Defaults true; set
	// AKARI_COOKIE_INSECURE=1 for plain-HTTP local development.
	CookieSecure bool
	// PublicURL is the externally reachable base URL of the server (scheme and
	// host, no trailing slash), e.g. "https://akari.example.com". It is the OAuth
	// issuer and the base of every absolute URL the MCP authorization flow
	// advertises (the discovery documents, the authorize and token endpoints, the
	// MCP resource identifier). Read from AKARI_PUBLIC_URL, falling back to
	// AKARI_URL (which eph already exports for the dev stack). When neither is set,
	// it is empty and the OAuth handlers derive the base from each request's scheme
	// and Host header, which is correct for a single-origin deployment behind a
	// well-behaved proxy.
	PublicURL string
	// SweepInterval is how often the server reclaims orphaned CAS blobs
	// (AKARI_SWEEP_INTERVAL, a Go duration like "1h"). Defaults to 1h; set "0" to
	// disable the background sweep (for example to run it only via the subcommand).
	SweepInterval time.Duration
	// OGCacheTTL is how long a rendered Open Graph preview card is served from the
	// cache before the next request re-renders it (AKARI_OG_CACHE_TTL, a Go duration
	// like "1h"). A published overview's card is rendered lazily on first request and
	// cached; once it ages past this TTL a later request renders a fresh one in its
	// place. Defaults to 1h and must be positive (the card is always cached).
	OGCacheTTL time.Duration
	// OGCleanupInterval is how often the server sweeps expired preview cards from the
	// cache (AKARI_OG_CLEANUP_INTERVAL, a Go duration). Each pass deletes cards older
	// than OGCacheTTL, so a card for an overview nobody shares does not linger. It is
	// pure housekeeping: a live share re-renders its card on demand regardless.
	// Defaults to 24h; set "0" to disable the sweep.
	OGCleanupInterval time.Duration
	// ProxyAuthHeader is the request header a trusted reverse proxy sets to the
	// authenticated username (AKARI_PROXY_AUTH_HEADER, e.g.
	// "X-Auth-Request-Preferred-Username"). Setting it turns on proxy-header auth:
	// the server trusts the header's value as the signed-in user and provisions the
	// account on first sight. It is empty (disabled) by default, because trusting a
	// header is only safe when akari is reachable ONLY through the proxy that sets
	// it. Leave it unset for a direct deployment. See auth.go's proxyPrincipal and
	// the deployment notes in docs/development.md.
	ProxyAuthHeader string
	// ProxyAuthSecret, when set (AKARI_PROXY_AUTH_SECRET), is a shared secret the
	// proxy must echo in ProxyAuthSecretHeader for the identity header to be
	// trusted. It is defense in depth for when network isolation alone is not
	// enough: a client that reaches akari directly cannot forge an identity without
	// also knowing the secret. Empty means the identity header is trusted on
	// network isolation alone.
	ProxyAuthSecret string
	// ProxyAuthSecretHeader is the header carrying ProxyAuthSecret
	// (AKARI_PROXY_AUTH_SECRET_HEADER). Defaults to "X-Akari-Proxy-Secret". Only
	// consulted when ProxyAuthSecret is set.
	ProxyAuthSecretHeader string
	// SignalsSettleInterval is how often the server wakes to compute per-session
	// signals for sessions that have settled (AKARI_SIGNALS_SETTLE_INTERVAL). The
	// ingest append path deliberately does not recompute signals per message (that
	// would be quadratic and would grade a still-running session with a
	// time-dependent outcome), so a settled session's grade is filled in here, once,
	// after it has been idle past the abandoned threshold. Defaults to 5m; set "0"
	// to disable the background pass (signals then land only on reparse or via the
	// subcommand).
	SignalsSettleInterval time.Duration
}

Server holds the akari-server runtime configuration.

func LoadServer

func LoadServer() (Server, error)

LoadServer reads server configuration from the environment, applying defaults and validating required values.

Jump to

Keyboard shortcuts

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