config

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: May 13, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultTokenQuota                    = 0
	DefaultMaxIterations                 = 64
	DefaultContextBudgetWarningRatio     = 0.85
	DefaultContextBudgetCriticalRatio    = 0.95
	DefaultContextBudgetMaxReactiveRetry = 1
	DefaultContextBudgetFallback         = 128000
	DefaultMCPSyncTTLSeconds             = 30
	DefaultMCPStartupTimeoutSeconds      = 20
	DefaultMCPCallTimeoutSeconds         = 60
	DefaultMCPMaxConcurrency             = 4
)
View Source
const (

	// EnvAllowAwayFullAccessCompat is a temporary migration gate that permits
	// approval_mode=away to map to full_access.
	EnvAllowAwayFullAccessCompat = "BYTEMIND_ALLOW_AWAY_FULL_ACCESS"
)

Variables

This section is empty.

Functions

func DeleteProviderRuntimeProvider added in v0.1.8

func DeleteProviderRuntimeProvider(runtimeCfg ProviderRuntimeConfig, providerID string) (ProviderRuntimeConfig, ProviderConfig, error)

func EnsureHomeLayout

func EnsureHomeLayout() (string, error)

func NormalizeApprovalMode

func NormalizeApprovalMode(value string) (string, error)

NormalizeApprovalMode validates and normalizes approval_mode values. By default, legacy away mode is blocked to prevent silent privilege escalation to full_access. Operators can temporarily enable migration by setting BYTEMIND_ALLOW_AWAY_FULL_ACCESS=true.

func ResolveHomeDir

func ResolveHomeDir() (string, error)

func ResolveWritableConfigPathForWorkspace

func ResolveWritableConfigPathForWorkspace(workspace, explicit string) (string, error)

func ResolveWritableMCPConfigPathForWorkspace

func ResolveWritableMCPConfigPathForWorkspace(workspace, explicit string) (string, error)

func SelectProviderRuntimeModel added in v0.1.8

func SelectProviderRuntimeModel(runtimeCfg ProviderRuntimeConfig, providerID, modelID string) (ProviderRuntimeConfig, ProviderConfig, error)

func SelectedModelID added in v0.1.8

func SelectedModelID(runtimeCfg ProviderRuntimeConfig) string

func SelectedProviderID added in v0.1.8

func SelectedProviderID(runtimeCfg ProviderRuntimeConfig) string

func UpsertProviderAPIKey

func UpsertProviderAPIKey(configPath, apiKey string) (string, error)

func UpsertProviderField

func UpsertProviderField(configPath, field, value string) (string, error)

func UpsertProviderRuntimeSelection added in v0.1.8

func UpsertProviderRuntimeSelection(configPath string, runtimeCfg ProviderRuntimeConfig) (string, error)

func WriteConfig added in v1.0.1

func WriteConfig(path string, cfg Config) error

WriteConfig writes a Config struct to a JSON file at the given path.

Types

type Config

type Config struct {
	Provider          ProviderConfig        `json:"provider"`
	ProviderRuntime   ProviderRuntimeConfig `json:"provider_runtime"`
	ApprovalPolicy    string                `json:"approval_policy"`
	ApprovalMode      string                `json:"approval_mode"`
	AwayPolicy        string                `json:"away_policy"`
	SandboxEnabled    bool                  `json:"sandbox_enabled"`
	SystemSandboxMode string                `json:"system_sandbox_mode"`
	WritableRoots     []string              `json:"writable_roots"`
	ExecAllowlist     []ExecAllowRule       `json:"exec_allowlist"`
	NetworkAllowlist  []NetworkAllowRule    `json:"network_allowlist"`
	Notifications     NotificationsConfig   `json:"notifications"`
	MaxIterations     int                   `json:"max_iterations"`
	Stream            bool                  `json:"stream"`
	UpdateCheck       UpdateCheckConfig     `json:"update_check"`
	TokenQuota        int                   `json:"token_quota"`
	ContextBudget     ContextBudgetConfig   `json:"context_budget"`
	MCP               MCPConfig             `json:"-"`
}

func Default

func Default(workspace string) Config

func Load

func Load(workspace, configPath string) (Config, error)

func LoadWithMCPConfigPath

func LoadWithMCPConfigPath(workspace, configPath, mcpConfigPath string) (Config, error)

func MutateMCPConfig

func MutateMCPConfig(workspace, explicitPath string, mutator func(*MCPConfig) error) (Config, string, error)

type ContextBudgetConfig

type ContextBudgetConfig struct {
	WarningRatio     float64 `json:"warning_ratio"`
	CriticalRatio    float64 `json:"critical_ratio"`
	MaxReactiveRetry int     `json:"max_reactive_retry"`
}

type DesktopNotificationConfig

type DesktopNotificationConfig struct {
	Enabled            bool `json:"enabled"`
	OnApprovalRequired bool `json:"on_approval_required"`
	OnRunCompleted     bool `json:"on_run_completed"`
	OnRunFailed        bool `json:"on_run_failed"`
	OnRunCanceled      bool `json:"on_run_canceled"`
	CooldownSeconds    int  `json:"cooldown_seconds"`
}

type ExecAllowRule

type ExecAllowRule struct {
	Command     string   `json:"command"`
	ArgsPattern []string `json:"args_pattern"`
}

type MCPConfig

type MCPConfig struct {
	Enabled        bool              `json:"enabled"`
	SyncTTLSeconds int               `json:"sync_ttl_s"`
	Servers        []MCPServerConfig `json:"servers"`
}

type MCPServerConfig

type MCPServerConfig struct {
	ID                    string                  `json:"id"`
	Name                  string                  `json:"name"`
	Enabled               *bool                   `json:"enabled,omitempty"`
	Transport             MCPTransportConfig      `json:"transport"`
	AutoStart             *bool                   `json:"auto_start,omitempty"`
	StartupTimeoutSeconds int                     `json:"startup_timeout_s"`
	CallTimeoutSeconds    int                     `json:"call_timeout_s"`
	MaxConcurrency        int                     `json:"max_concurrency"`
	ToolOverrides         []MCPToolOverrideConfig `json:"tool_overrides"`
	ProtocolVersion       string                  `json:"protocol_version"`
	ProtocolVersions      []string                `json:"protocol_versions"`
}

func (MCPServerConfig) AutoStartValue

func (s MCPServerConfig) AutoStartValue() bool

func (MCPServerConfig) EnabledValue

func (s MCPServerConfig) EnabledValue() bool

type MCPToolOverrideConfig

type MCPToolOverrideConfig struct {
	ToolName        string   `json:"tool_name"`
	SafetyClass     string   `json:"safety_class,omitempty"`
	ReadOnly        *bool    `json:"read_only,omitempty"`
	Destructive     *bool    `json:"destructive,omitempty"`
	AllowedModes    []string `json:"allowed_modes,omitempty"`
	DefaultTimeoutS int      `json:"default_timeout_s,omitempty"`
	MaxTimeoutS     int      `json:"max_timeout_s,omitempty"`
	MaxResultChars  int      `json:"max_result_chars,omitempty"`
}

type MCPTransportConfig

type MCPTransportConfig struct {
	Type    string            `json:"type"`
	Command string            `json:"command"`
	Args    []string          `json:"args"`
	Env     map[string]string `json:"env"`
	CWD     string            `json:"cwd"`
}

type NetworkAllowRule

type NetworkAllowRule struct {
	Host   string `json:"host"`
	Port   int    `json:"port"`
	Scheme string `json:"scheme"`
}

type NotificationsConfig

type NotificationsConfig struct {
	Desktop DesktopNotificationConfig `json:"desktop"`
}

type ProviderConfig

type ProviderConfig struct {
	Type             string            `json:"type"`
	Family           string            `json:"family"`
	AutoDetectType   bool              `json:"auto_detect_type"`
	BaseURL          string            `json:"base_url"`
	APIPath          string            `json:"api_path"`
	Model            string            `json:"model"`
	Models           []string          `json:"models,omitempty"`
	APIKey           string            `json:"api_key"`
	APIKeyEnv        string            `json:"api_key_env"`
	AuthHeader       string            `json:"auth_header"`
	AuthScheme       string            `json:"auth_scheme"`
	ExtraHeaders     map[string]string `json:"extra_headers"`
	AnthropicVersion string            `json:"anthropic_version"`
}

func SelectedProviderConfig added in v0.1.8

func SelectedProviderConfig(runtimeCfg ProviderRuntimeConfig) (string, ProviderConfig, bool)

func (ProviderConfig) ResolveAPIKey

func (p ProviderConfig) ResolveAPIKey() string

type ProviderHealthRuntimeConfig

type ProviderHealthRuntimeConfig struct {
	FailThreshold           int `json:"fail_threshold"`
	RecoverProbeSec         int `json:"recover_probe_sec"`
	RecoverSuccessThreshold int `json:"recover_success_threshold"`
	WindowSize              int `json:"window_size"`
}

type ProviderRuntimeConfig

type ProviderRuntimeConfig struct {
	CurrentProvider string                      `json:"current_provider,omitempty"`
	DefaultProvider string                      `json:"default_provider,omitempty"`
	DefaultModel    string                      `json:"default_model,omitempty"`
	AllowFallback   bool                        `json:"allow_fallback"`
	Providers       map[string]ProviderConfig   `json:"providers"`
	Health          ProviderHealthRuntimeConfig `json:"health"`
}

func LegacyProviderRuntimeConfig

func LegacyProviderRuntimeConfig(cfg ProviderConfig) ProviderRuntimeConfig

func SyncProviderRuntimeSelectionFields added in v0.1.8

func SyncProviderRuntimeSelectionFields(runtimeCfg ProviderRuntimeConfig) ProviderRuntimeConfig

func SyncProviderRuntimeWithProvider added in v0.1.8

func SyncProviderRuntimeWithProvider(runtimeCfg ProviderRuntimeConfig, providerCfg ProviderConfig) ProviderRuntimeConfig

type UpdateCheckConfig

type UpdateCheckConfig struct {
	Enabled bool `json:"enabled"`
}

Jump to

Keyboard shortcuts

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