config

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: MIT Imports: 14 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

Index

Constants

View Source
const (
	TransportModeLocal = "local"
	TransportModeTLS   = "tls"
	TransportModeMTLS  = "mtls"
)

TransportMode constants for the security.transport.mode field.

Variables

This section is empty.

Functions

func ExplicitLogging added in v1.4.3

func ExplicitLogging(path string) (level, format string, err error)

ExplicitLogging reports the logging.level and logging.format values exactly as set in a YAML config file, before Load applies its "info"/"json" defaults. This lets callers distinguish "the user configured this" from "Load filled in a default", so a CLI flag default doesn't silently shadow a value the user actually set in the file.

func HasExplicitServerListen

func HasExplicitServerListen(path string) (bool, error)

HasExplicitServerListen reports whether a YAML config file explicitly sets server.listen, before defaults are applied by Load.

func LoadDotEnv

func LoadDotEnv(path string) error

LoadDotEnv reads KEY=VALUE pairs from a .env file into the process environment. Existing environment variables are not overwritten.

func ParseByteSize

func ParseByteSize(value string) (int64, error)

ParseByteSize parses a positive human-readable SI or IEC byte size.

func ParseDuration

func ParseDuration(s string, fallback time.Duration) time.Duration

ParseDuration is a helper that parses a duration string with a fallback.

func ParsePortRange

func ParsePortRange(s string) (start, end int, err error)

ParsePortRange parses a "start-end" port range string and returns the start (inclusive) and end (exclusive) port numbers. For example, "4100-4199" returns (4100, 4200, nil).

func RequiredNodeMajor

func RequiredNodeMajor(projectRoot string) (int, error)

func RequiresNodeRuntime

func RequiresNodeRuntime(cfg *Config) bool

RequiresNodeRuntime reports whether cfg has at least one provider that invokes Node.js, detected by the provider binary base name being "node" or "nodejs". Providers that use non-Node binaries (e.g. native CLIs, /bin/cat) do not require the Node runtime and do not need .nvmrc validation.

func ValidateNodeRuntime

func ValidateNodeRuntime(projectRoot string) error

Types

type AuthConfig

type AuthConfig struct {
	JWTPublicKeys []JWTKeyConfig `yaml:"jwt_public_keys"`
	JWTAudience   string         `yaml:"jwt_audience"`
	JWTMaxTTL     string         `yaml:"jwt_max_ttl"`
}

type AuthorizationConfig

type AuthorizationConfig struct {
	// Mode is "jwt" or "none".
	Mode string `yaml:"mode"`
}

AuthorizationConfig controls the authorization mechanism.

type CertificatesConfig

type CertificatesConfig struct {
	// Provider is the certificate provider name: "filesystem", "auto", or "stepca".
	Provider   string                   `yaml:"provider"`
	Filesystem FilesystemCertConfig     `yaml:"filesystem"`
	StepCA     StepCACertProviderConfig `yaml:"stepca"`
}

CertificatesConfig controls where certificate material comes from.

type Config

type Config struct {
	// Name is the human-friendly server name used when enrolling with Bridge.
	// bridgectl login falls back to the OS hostname when it is empty.
	Name         string                    `yaml:"name"`
	Server       ServerConfig              `yaml:"server"`
	Security     SecurityConfig            `yaml:"security"`
	StepCA       StepCAYAMLConfig          `yaml:"step_ca"`
	TLS          TLSConfig                 `yaml:"tls"`
	Auth         AuthConfig                `yaml:"auth"`
	FeatureFlags FeatureFlagsConfig        `yaml:"feature_flags"`
	Sessions     SessionsConfig            `yaml:"sessions"`
	Input        InputConfig               `yaml:"input"`
	RateLimits   RateLimitsConfig          `yaml:"rate_limits"`
	Persistence  PersistenceConfig         `yaml:"persistence"`
	Runtime      RuntimeConfig             `yaml:"runtime"`
	RepoSetup    RepoSetupConfig           `yaml:"repo_setup"`
	Telemetry    TelemetryConfig           `yaml:"telemetry"`
	Control      ControlConfig             `yaml:"control"`
	Providers    map[string]ProviderConfig `yaml:"providers"`
	AllowedPaths []string                  `yaml:"allowed_paths"`
	Logging      LoggingConfig             `yaml:"logging"`
}

Config is the top-level bridge daemon configuration.

func Load

func Load(path string) (*Config, error)

Load reads and parses a YAML configuration file.

type ControlConfig

type ControlConfig struct {
	// Endpoint is the control-plane WebSocket URL (e.g.
	// "wss://control.bridge.orchael.dev/v1/control"), taken verbatim from
	// Bridge's enrollment response.
	Endpoint string `yaml:"endpoint"`
	// CredentialFile points at the JSON file holding the bri_ control
	// credential (never the brc_ telemetry credential).
	CredentialFile string `yaml:"credential_file"`
	// ManagedByBridge records that `bridgectl bridge login` wrote this
	// block, so `bridgectl bridge logout` knows it owns removing it.
	ManagedByBridge bool `yaml:"managed_by_bridge"`
}

ControlConfig holds bridgectl's optional outbound Bridge control-plane WebSocket client configuration. It is populated by `bridgectl bridge login` alongside the telemetry block (see cmd/bridgectl's configureBridgeTelemetry), never hand-written.

Unlike TelemetryConfig, Control has no local/offline fallback: an empty Endpoint or CredentialFile simply disables the control client entirely. This is the expected, non-error state for standalone bridgectl (no Bridge enrollment) and for an enrollment created before Bridge added control-plane support (schema_version < 2, no control_endpoint/ control_credential).

type FeatureFlagsConfig

type FeatureFlagsConfig struct {
	ProviderFallbacks bool `yaml:"provider_fallbacks"`
}

type FilesystemCertConfig

type FilesystemCertConfig struct {
	CA          string `yaml:"ca"`
	Certificate string `yaml:"certificate"`
	PrivateKey  string `yaml:"private_key"`
	ServerCert  string `yaml:"server_certificate"`
	ServerKey   string `yaml:"server_private_key"`
}

FilesystemCertConfig holds paths for the filesystem certificate provider.

type InputConfig

type InputConfig struct {
	MaxSizeBytes int `yaml:"max_size_bytes"`
}

type JWTKeyConfig

type JWTKeyConfig struct {
	Issuer  string `yaml:"issuer"`
	KeyPath string `yaml:"key_path"`
}

type LoggingConfig

type LoggingConfig struct {
	Level          string   `yaml:"level"`
	Format         string   `yaml:"format"`
	RedactPatterns []string `yaml:"redact_patterns"`
}

type PersistenceConfig

type PersistenceConfig struct {
	// DBPath is the path to the bbolt database file used to persist session
	// metadata and PTY output chunks across daemon restarts. An empty string
	// disables persistence.
	DBPath string `yaml:"db_path"`
	// ChunkStorageBytes is the soft upper bound on total chunk bytes stored per
	// session in the database. 0 means unlimited (the default). Enforcement is
	// planned for a future release; this field is reserved for configuration
	// compatibility.
	ChunkStorageBytes int `yaml:"chunk_storage_bytes"`
}

type ProviderConfig

type ProviderConfig struct {
	Binary          string   `yaml:"binary"`
	Mode            string   `yaml:"mode"` // deprecated: no longer supported; remove from config
	Args            []string `yaml:"args"`
	StartupTimeout  string   `yaml:"startup_timeout"`
	ValidateStartup *bool    `yaml:"validate_startup"`
	StartupProbe    string   `yaml:"startup_probe"`
	RequiredEnv     []string `yaml:"required_env"`
	PTY             *bool    `yaml:"pty"` // deprecated: PTY is the default; remove this field
	StreamJSON      bool     `yaml:"stream_json"`
	StripANSI       bool     `yaml:"strip_ansi"`
	// PromptPattern is a regex matched against PTY output lines. When it
	// matches the first time, AGENT_READY is emitted; on subsequent matches
	// after output, RESPONSE_COMPLETE is emitted.
	PromptPattern string `yaml:"prompt_pattern"`
	// Fallbacks is an ordered list of provider IDs to try when this provider
	// is unavailable at session start time. At most 2 entries are allowed.
	Fallbacks []string `yaml:"fallbacks"`
	// Transport selects the provider transport backend. Supported values are
	// "" (native provider with structured reporting where supported),
	// "stdio" (plain PTY/stdio), and "opencode_server" (OpenCode HTTP/SSE).
	Transport string `yaml:"transport"`
	// Hostname is the address to bind the OpenCode server to. Only used when
	// Transport is "opencode_server". Defaults to "127.0.0.1".
	Hostname string `yaml:"hostname"`
	// PortRange specifies the port range for the OpenCode server in
	// "start-end" format (e.g. "4100-4199"). Only used when Transport is
	// "opencode_server". Defaults to "4100-4199".
	PortRange string `yaml:"port_range"`
}

func (ProviderConfig) ShouldValidateStartup

func (p ProviderConfig) ShouldValidateStartup() bool

type RateLimitsConfig

type RateLimitsConfig struct {
	GlobalRPS                  float64 `yaml:"global_rps"`
	GlobalBurst                int     `yaml:"global_burst"`
	StartSessionPerClientRPS   float64 `yaml:"start_session_per_client_rps"`
	StartSessionPerClientBurst int     `yaml:"start_session_per_client_burst"`
	SendInputPerSessionRPS     float64 `yaml:"send_input_per_session_rps"`
	SendInputPerSessionBurst   int     `yaml:"send_input_per_session_burst"`
}

type RepoSetupConfig

type RepoSetupConfig struct {
	Enabled        *bool  `yaml:"enabled"`
	ConfigPath     string `yaml:"config_path"`
	DefaultTimeout string `yaml:"default_timeout"`
	MaxTimeout     string `yaml:"max_timeout"`
}

RepoSetupConfig controls repo-local pre-agent setup execution.

func (RepoSetupConfig) IsEnabled

func (r RepoSetupConfig) IsEnabled() bool

type RuntimeConfig

type RuntimeConfig struct {
	ProviderRoot string `yaml:"provider_root"`
}

RuntimeConfig controls how the bridge locates provider CLIs and the Node.js runtime. When ProviderRoot is set, Node version validation reads {provider_root}/.nvmrc and relative provider binary/arg paths are resolved relative to {provider_root} instead of the daemon working directory. When empty, existing CWD-relative behaviour is preserved.

type SecurityConfig

type SecurityConfig struct {
	Transport     TransportConfig     `yaml:"transport"`
	Certificates  CertificatesConfig  `yaml:"certificates"`
	Authorization AuthorizationConfig `yaml:"authorization"`
}

SecurityConfig holds the v1.1 security model: explicit transport mode, certificate provider, and authorization mode. When absent in the YAML file, it is synthesized from legacy fields (server.listen, step_ca, tls) for backward compatibility.

func (*SecurityConfig) IsSecurityConfigured

func (s *SecurityConfig) IsSecurityConfigured() bool

IsSecurityConfigured reports whether the security block was explicitly set in the YAML (i.e. has a non-empty transport mode).

func (*SecurityConfig) SecurityMode

func (s *SecurityConfig) SecurityMode() string

SecurityMode returns the resolved transport mode, falling back to "local" if not configured.

type ServerConfig

type ServerConfig struct {
	Listen                   string   `yaml:"listen"`
	SANs                     []string `yaml:"san"`
	CertValidity             string   `yaml:"cert_validity"`
	CertRenewalCheckInterval string   `yaml:"cert_renewal_check_interval"`
}

type SessionsConfig

type SessionsConfig struct {
	MaxPerProject            int    `yaml:"max_per_project"`
	MaxGlobal                int    `yaml:"max_global"`
	IdleTimeout              string `yaml:"idle_timeout"`
	StopGracePeriod          string `yaml:"stop_grace_period"`
	EventBufferSize          int    `yaml:"event_buffer_size"`
	MaxSubscribersPerSession int    `yaml:"max_subscribers_per_session"`
	SubscriberTTL            string `yaml:"subscriber_ttl"`
}

type StepCACertProviderConfig

type StepCACertProviderConfig struct {
	URL                     string `yaml:"url"`
	Root                    string `yaml:"root"`
	Provisioner             string `yaml:"provisioner"`
	ProvisionerPasswordFile string `yaml:"provisioner_password_file"`
}

StepCACertProviderConfig holds settings for the Step CA certificate provider.

type StepCAClientConfig

type StepCAClientConfig struct {
	Issuer   string `yaml:"issuer"`
	KeyPath  string `yaml:"key_path"`
	Required bool   `yaml:"required"`
}

StepCAClientConfig declares a Step CA-authenticated client whose bridge JWT public key should be loaded at startup when available.

type StepCAYAMLConfig

type StepCAYAMLConfig struct {
	URL                     string               `yaml:"url"`
	Root                    string               `yaml:"root"`
	Provisioner             string               `yaml:"provisioner"`
	ProvisionerPasswordFile string               `yaml:"provisioner_password_file"`
	Clients                 []StepCAClientConfig `yaml:"clients"`
}

StepCAYAMLConfig holds Step CA settings from the YAML config file.

type TLSConfig

type TLSConfig struct {
	CABundle string `yaml:"ca_bundle"`
	Cert     string `yaml:"cert"`
	Key      string `yaml:"key"`
}

type TelemetryConfig

type TelemetryConfig struct {
	Enabled                 bool               `yaml:"enabled"`
	SourceID                string             `yaml:"source_id"`
	ActorID                 string             `yaml:"actor_id"`
	SourceLabel             string             `yaml:"source_label"`
	IdentityKeyFile         string             `yaml:"identity_key_file"`
	SpoolDir                string             `yaml:"spool_dir"`
	CollectorTarget         string             `yaml:"collector_target"`
	CollectorInsecure       bool               `yaml:"collector_insecure"`
	CollectorCA             string             `yaml:"collector_ca"`
	CollectorServerName     string             `yaml:"collector_server_name"`
	CollectorURL            string             `yaml:"collector_url"`
	CollectorCredentialFile string             `yaml:"collector_credential_file"`
	CollectorManaged        bool               `yaml:"managed_by_bridge"`
	Kinds                   []string           `yaml:"kinds"`
	QueueSize               int                `yaml:"queue_size"`
	RollingWindow           string             `yaml:"rolling_window"`
	FlushInterval           string             `yaml:"flush_interval"`
	RetryInterval           string             `yaml:"retry_interval"`
	MaxSegmentBytes         int64              `yaml:"max_segment_bytes"`
	MaxDiskSpace            string             `yaml:"max_disk_space"`
	DeprecatedMaxSegments   removedConfigField `yaml:"-"`
	IncludeRedactedText     bool               `yaml:"include_redacted_text"`
}

func (*TelemetryConfig) UnmarshalYAML

func (c *TelemetryConfig) UnmarshalYAML(node *yaml.Node) error

type TransportConfig

type TransportConfig struct {
	// Mode is one of "local", "tls", or "mtls".
	Mode string `yaml:"mode"`
}

TransportConfig controls the transport security level.

Jump to

Keyboard shortcuts

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