settings

package
v0.11.3 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultGnarAccount = "warren"

DefaultGnarAccount is the last-resort account label used when the host name cannot be converted to a gnar v1.7 account name. It is a label only; gnar owns the account token.

View Source
const DefaultRuntimeKind = RuntimeGhostline

DefaultRuntimeKind is used when neither the settings file nor --runtime selects one.

View Source
const MaxGnarAccountLength = 16

MaxGnarAccountLength is enforced by gnar v1.7 for account names.

View Source
const (
	RuntimeGhostline = "ghostline"
)

Runtime kinds supported by the headless daemon.

Variables

This section is empty.

Functions

func BuiltInGnarEdge

func BuiltInGnarEdge() string

BuiltInGnarEdge returns the Edge URL injected into the current Warren release. It is not persisted in settings, so upgrading Warren can change the default for users who have not configured an override.

func ConfiguredGnarAccount

func ConfiguredGnarAccount(value string) string

ConfiguredGnarAccount returns only the persisted user override. It never substitutes the system-name default, which lets callers distinguish an omitted account from an explicit override.

func DefaultGnarAccountForHost

func DefaultGnarAccountForHost(hostName string) string

DefaultGnarAccountForHost converts a Warren Host/system name into the account syntax accepted by gnar v1.7. Non-ASCII and punctuation runs become a single hyphen; the result is trimmed and capped at 16 characters.

func DefaultPath

func DefaultPath() string

DefaultPath returns the conventional settings file location.

func EffectiveGnarAccount

func EffectiveGnarAccount(configured, hostName string) string

EffectiveGnarAccount resolves a persisted override first, then the Warren Host/system name, and finally the safe fallback. HostName may be empty in embedded/test callers; os.Hostname supplies the platform value then.

func NormalizeConfiguredGnarAccount

func NormalizeConfiguredGnarAccount(value string) (string, error)

NormalizeConfiguredGnarAccount validates an explicitly configured account name against gnar v1.7's contract. gnar lowercases names itself, so Warren accepts uppercase input and stores the canonical lowercase form. Empty means that no user override is configured.

func NormalizedGnarAccount

func NormalizedGnarAccount(value string) string

NormalizedGnarAccount returns a safe account label for the gnar CLI. Empty or malformed values retain the historical safe fallback; callers handling explicit user input should use NormalizeConfiguredGnarAccount so invalid values can be reported instead of silently changed.

func Save

func Save(path string, value Settings) error

Save persists settings atomically.

Types

type Settings

type Settings struct {
	// DefaultRuntime is the engine used for sessions created without an
	// explicit runtimeKind. Ghostline is the only supported runtime.
	DefaultRuntime string `json:"defaultRuntime"`
	// RuntimeEnv overrides environment variables inherited by ghostline
	// runtime children. It is applied after the
	// daemon's built-in environment sanitization, so explicit values win;
	// an empty value unsets the variable instead of passing an empty string.
	RuntimeEnv map[string]string `json:"runtimeEnv,omitempty"`
	// GnarEdge is the optional user-selected gnar Edge URL used for Public
	// Access. Empty selects Warren's release/launcher default, which is
	// https://tunnel.example.com in source builds and can be replaced at link
	// time for a release.
	GnarEdge string `json:"gnarEdge,omitempty"`
	// GnarAccount is the non-secret account label passed to gnar login.
	GnarAccount string `json:"gnarAccount,omitempty"`
	// TunnelEnabled records which reachability adapters the user wants
	// running. The daemon restores them after a restart so Public Access
	// recovers until the user explicitly disables it.
	TunnelEnabled map[string]bool `json:"tunnelEnabled,omitempty"`
	// AutoOpenShell controls whether opening an empty workspace creates a
	// default Shell session. Explicit New Session/Shell actions are unaffected.
	AutoOpenShell bool `json:"autoOpenShell"`
	// AutoStartAI controls whether entering an empty workspace starts the first
	// AI preset. Explicit session actions are unaffected.
	AutoStartAI bool `json:"autoStartAI"`
}

Settings is the headless daemon configuration. Runtime selection is a headless-side decision: it controls which engine owns newly created sessions, not what clients render.

func Load

func Load(path string) (Settings, error)

Load reads settings from path. A missing file yields defaults.

func (Settings) ApplyRuntimeEnv

func (s Settings) ApplyRuntimeEnv()

ApplyRuntimeEnv applies RuntimeEnv to the current process environment so runtime children inherit the configured values. Empty values unset the variable, which matters for tools that treat an empty override (for example GIT_PAGER=) as "disable paging" rather than "use the default".

func (Settings) Normalized

func (s Settings) Normalized() string

Normalized returns the effective default runtime kind.

Jump to

Keyboard shortcuts

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