config

package
v2.6.2 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2026 License: MIT Imports: 6 Imported by: 0 modules, 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 holds every knob lectern reads from the environment.

Values are resolved once at startup into a Config, then passed explicitly. Tests build their own Config instead of mutating globals, which is what makes the whole suite able to run in parallel against isolated databases.

Index

Constants

View Source
const EnvPrefix = "LECTERN_"

EnvPrefix is the prefix every setting carries now.

View Source
const LegacyEnvPrefix = "AGENTDECK_"

LegacyEnvPrefix is the prefix every setting carried before the project was renamed. An installed instance still has its unit file, drop-ins and shell profiles written with it, and a session launched by the previous binary still exports its identity under it.

Variables

This section is empty.

Functions

func AliasLegacyEnv

func AliasLegacyEnv() []string

AliasLegacyEnv makes every AGENTDECK_* variable readable under its LECTERN_* name for the rest of this process, without overriding a LECTERN_* value that is already set. It returns the names it aliased so the server can say so once at startup; the CLI and the MCP child stay quiet.

func LegacyEnvAliased

func LegacyEnvAliased() []string

LegacyEnvAliased lists the AGENTDECK_* names this process is reading through their LECTERN_* equivalents.

Types

type Config

type Config struct {
	DBPath  string
	Port    int
	Host    string
	BaseURL string // what a target uses to reach the control plane (hook callbacks)
	// HookBase is the host part an agent's own hooks/statusline call back to
	// (LECTERN_HOOK_URL is built from it). Defaults to BaseURL; only needs
	// its own value when a remote target cannot reach the control plane the
	// same way the operator's browser does.
	HookBase string
	// WorktreeNamespace scopes automatically-created local worktrees and
	// branches to one durable local runtime. Empty preserves hosted behavior.
	WorktreeNamespace string

	// Mock swaps every executor for the scripted MockExecutor: no real git,
	// tmux or agent binary. Powers the hermetic suite and the UI demo mode.
	Mock bool

	AuthToken string // single bearer for the API/PWA; empty = open

	// Auth is LECTERN_AUTH: "", "auto" (default), "none", "token", or
	// "tailscale" — see internal/auth. TailscaleSocket overrides tailscaled's
	// LocalAPI socket path; TailscaleUsers/TailscaleTags are comma-separated
	// allowlists (LECTERN_TAILSCALE_USERS / LECTERN_TAILSCALE_TAGS).
	Auth            string
	TailscaleSocket string
	TailscaleUsers  string
	TailscaleTags   string

	// TrustServeHeaders is LECTERN_TRUST_SERVE_HEADERS — see its doc comment
	// on auth.Settings. Off by default: unsafe wherever an untrusted process
	// (an agent included) can reach this host's loopback interface.
	TrustServeHeaders bool
	// PluginsAllowUnauthenticated is LECTERN_PLUGINS_ALLOW_UNAUTHENTICATED=1.
	// With LECTERN_AUTH=none nobody has an identity, so any process that can
	// reach Lectern — an agent included — would count as the operator. Plugin
	// changes are refused in that mode unless this is set (docs/plugins.md).
	PluginsAllowUnauthenticated bool

	// DevicePairing is LECTERN_DEVICE_PAIRING=1 — turns on internal/pairing
	// (Settings → Devices, "Pair a phone" / /pair) regardless of what the
	// "pairing_enabled" setting says; see pairing.Enabled. Off by default:
	// it is a second, always-available way into the API (a paired device
	// authenticates in every auth mode, see auth.Resolver.Authenticate), so
	// an operator opts in deliberately rather than getting it from a bare
	// upgrade.
	DevicePairing bool

	// RelayURL (LECTERN_RELAY_URL) turns on the end-to-end encrypted relay:
	// Lectern connects out to this relay and serves paired phones through it
	// (internal/relay/host, docs/relay.md). RelayHostSecret
	// (LECTERN_RELAY_HOST_SECRET) must match the relay's. RelayShellURL
	// (LECTERN_RELAY_SHELL_URL) is the origin a phone installs the app from
	// when pairing; empty means whatever origin Settings was opened on.
	RelayURL        string
	RelayHostSecret string
	RelayShellURL   string

	// TLS turns on a second listener bound to this node's tailnet addresses,
	// so a phone gets a secure context without needing `tailscale serve` to
	// front it. LECTERN_TLS: "" (off) or "tailscale". TLSPort
	// (LECTERN_TLS_PORT) is required for it to actually start — "tailscale"
	// with no port configured is a no-op, same as leaving TLS unset. It is
	// also auto-enabled when the resolved auth mode is tailscale and TLSPort
	// is set, so setting just LECTERN_TLS_PORT is enough in the common case.
	TLS     string
	TLSPort int

	TickInterval time.Duration
	// HandoffPoll is how often a session switch checks for the agent's wrap;
	// zero keeps the session manager's default. Tests shorten it.
	HandoffPoll time.Duration
	// LimitSettle is how long a usage-limit resume nudge has to show a result
	// before it is judged (docs/rate-limits.md); zero keeps the default.
	// Tests shorten it.
	LimitSettle    time.Duration
	ApprovalPoll   time.Duration
	ApprovalExpire time.Duration
	// SessionApprovalHold is LECTERN_APPROVAL_HOLD (default 120s): how long a
	// session's PermissionRequest hook is held open waiting for a phone/UI
	// decision before the handler answers `{}` and marks the approval
	// expired, letting the agent fall back to its own terminal prompt
	// (docs/agent-events.md section 3). Distinct from ApprovalExpire, which
	// governs the older task-hook long-poll's much longer default (900s) —
	// a session's hook is one held HTTP request, not a repeated poll loop,
	// so it needs its own, much shorter budget.
	SessionApprovalHold time.Duration
	JanitorDays         float64
	// ScratchDays is how long an empty, unowned scratch workspace sits idle
	// before the sweep trashes it (0 disables the sweep); ScratchTrashDays is how
	// long it stays recoverable after that.
	ScratchDays      float64
	ScratchTrashDays float64
	// Live turns on forwarded ports and live desktops. They open listening
	// ports of their own and let an agent start a desktop that can be driven
	// from the network, so an operator asks for them; they are not a default.
	Live           bool
	MockAgentDelay time.Duration

	VAPIDPrivateKey string
	VAPIDPublicKey  string
	VAPIDEmail      string

	// HostClaudeConfig is the control plane user's own Claude Code config. It is
	// read ONLY to learn which MCP servers a local-target agent already inherits,
	// so the parity profile can grant permission to call them. Never copied
	// anywhere — it holds live credentials.
	HostClaudeConfig string

	ClaudeBin string
	// Agent binaries often live in ~/.local/bin, which a systemd unit's PATH does
	// not include — set these when a probe reports an agent missing that you know
	// is installed.
	CodexBin  string
	GeminiBin string

	// AnthropicAPIKey is rotation-proof agent auth. When set it is injected as
	// ANTHROPIC_API_KEY into every launch and no OAuth credentials are pushed to
	// targets. When empty, the control plane's current OAuth creds are pushed at
	// dispatch instead.
	AnthropicAPIKey string

	// ClaudeCredsPath / CodexCredsPath are where the control plane keeps agent
	// OAuth credentials. Overridable so tests never depend on a real ~/.claude.
	ClaudeCredsPath string
	CodexCredsPath  string

	// GrimoireURL points at a Grimoire instance for durable project memory.
	// Empty means lectern runs with no memory provider, which is a supported
	// configuration and not a degraded one — the two tools compose, they do not
	// depend on each other.
	GrimoireURL             string
	GrimoireToken           string
	GrimoireContextMode     string
	GrimoireContextProjects string

	// SessionPoll is how often live interactive sessions are refreshed. It is
	// separate from TickInterval because a session poll costs one exec per
	// target, whether or not anything is dispatched.
	SessionPoll time.Duration
	// TargetPollTimeout bounds one machine's status poll; a machine that does
	// not answer in time is shown as unreachable and retried with backoff,
	// without holding up the others.
	TargetPollTimeout time.Duration
	// TerminalsMax caps how many web terminals (ttyd processes) run at once;
	// 0 keeps internal/terminal's default.
	TerminalsMax int

	// MediaPath overrides MediaDir; MediaMaxBytes caps one posted file.
	MediaPath     string
	MediaMaxBytes int64

	// CheckTimeout bounds one run of a project's check command
	// (internal/checks), for both a session's Stop-triggered check and a
	// task's auto-verify. LECTERN_CHECK_TIMEOUT, seconds; zero means the
	// package's own 15-minute default (checks.DefaultTimeout).
	CheckTimeout time.Duration
}

Config is the fully resolved runtime configuration.

func Load

func Load() *Config

Load resolves configuration from the process environment.

func (*Config) DiffDir

func (c *Config) DiffDir() string

DiffDir is where captured patches live — derived from the DB path so each database (including every test's temp DB) gets its own store. Attempt ids collide across databases, and a shared store once let a mock run overwrite production diffs.

func (*Config) MediaDir

func (c *Config) MediaDir() string

MediaDir holds what agents post back for the operator to look at: recordings, screenshots, reports. It sits beside the database for the same reason DiffDir does, but is overridable because a demo video is far larger than a patch and an operator may want it on a bulk volume.

func (*Config) MediaLimit

func (c *Config) MediaLimit() int64

MediaLimit is the largest single file an agent may post. A Config built by hand, as tests do, gets the same default Load applies.

func (*Config) PluginDir added in v2.6.0

func (c *Config) PluginDir() string

PluginDir holds installed plugins' content store (internal/plugins). It sits beside the database for the same reason DiffDir does: a test's temp database gets its own plugins.

Jump to

Keyboard shortcuts

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