config

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2026 License: AGPL-3.0 Imports: 8 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package config loads runtime configuration from a JSON file, with environment variables taking precedence. Currently it carries the PostgreSQL connection.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BaseDir

func BaseDir() string

BaseDir is the directory that anchors all runtime artifacts (config.json and the data/ store). It is the directory the running binary lives in, so a distributed executable keeps its files next to itself on any OS (Windows, Linux, …) regardless of the working directory it is launched from.

When launched via `go run`, the binary is throwaway: it sits either in a temp build dir (cache miss → fresh link) OR straight inside the Go build cache (cache hit → run from $GOCACHE/.../...-d). We detect both and fall back to the current working directory so dev artifacts (data/, transcripts) and config resolve against the project dir, not the throwaway binary's location.

func LLMEnv

func LLMEnv(suffix string) (string, bool)

LLMEnv recognizes an explicitly empty modern value as an override too.

func LocalLLMPolicy

func LocalLLMPolicy() (bool, []string)

LocalLLMPolicy resolves file and modern/legacy environment settings. It is opt-in.

func Path

func Path() string

Path returns the config file path. Resolution order:

  1. env ARTEX_CONFIG (explicit override)
  2. ./config.json in the current working directory (running from the project dir — robust no matter where `go run` placed the temp/cached binary)
  3. config.json next to the executable (a distributed binary keeps it beside)

The first existing file wins. If none exist, the CWD path is returned so the "not found" message points at the project dir the user most likely expected.

func PostgresDSN

func PostgresDSN() (dsn, source string, err error)

PostgresDSN resolves the connection string with precedence:

env ARTEX_PG_DSN  >  config file (database.dsn, or assembled from fields)

There is NO built-in fallback: when neither source supplies a database config, it returns an error naming the config path it inspected, so startup fails loudly instead of silently connecting to a wrong default. source describes where the DSN came from (for startup logging).

func Redact

func Redact(dsn string) string

String is a redacted view of the resolved DSN (password masked) for logging.

func SkillDir

func SkillDir() string

SkillDir returns the skill root directory with precedence:

env ARTEX_SKILL_DIR  >  config file (skill_dir)  >  BaseDir()/skills

The directory is created if it does not exist.

Types

type Config

type Config struct {
	Database             Database `json:"database"`
	SkillDir             string   `json:"skill_dir"`
	LLM                  LLM      `json:"llm"`
	LocalLLMOnly         bool     `json:"local_llm_only"`
	LocalLLMAllowedCIDRs []string `json:"local_llm_allowed_cidrs"`
}

Config is the on-disk config file shape.

func Load

func Load() Config

Load reads and parses the config file. A missing/unreadable file yields a zero Config (so callers fall back to defaults) rather than an error.

type Database

type Database struct {
	DSN      string `json:"dsn"`
	Host     string `json:"host"`
	Port     int    `json:"port"`
	User     string `json:"user"`
	Password string `json:"password"`
	DBName   string `json:"dbname"`
	SSLMode  string `json:"sslmode"`
}

Database is the PostgreSQL connection config. Either set DSN directly, or set the component fields and a DSN is assembled from them.

type LLM

type LLM struct {
	Provider        string `json:"provider"`
	Model           string `json:"model"`
	BaseURL         string `json:"base_url"`
	APIKey          string `json:"api_key"`
	Proxy           string `json:"proxy"`
	ContextWindowK  int    `json:"context_window_k"`
	KeepAlive       string `json:"keep_alive"`
	MaxConcurrent   int    `json:"llm_max_concurrent"`
	MaxTokens       int    `json:"max_tokens"`
	ThinkingType    string `json:"thinking_type"`
	ReasoningEffort string `json:"reasoning_effort"`
	Stream          *bool  `json:"stream"`
}

LLM is the optional config.json bootstrap profile. Environment values win over file values.

func ResolveLLM

func ResolveLLM() LLM

Jump to

Keyboard shortcuts

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