config

package
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AIPermissionReadonly         = "readonly"
	AIPermissionApprovalRequired = "approval_required"
	AIPermissionFullAccess       = "full_access"
)
View Source
const (
	AIProviderWebSearchModeDisabled      = "disabled"
	AIProviderWebSearchModeOpenAIBuiltin = "openai_builtin"
	AIProviderWebSearchModeBrave         = "brave"
)
View Source
const (
	AIInputModalityText  = "text"
	AIInputModalityImage = "image"
)
View Source
const (
	AIReasoningLevelDefault = flconfig.ReasoningLevelDefault
	AIReasoningLevelOff     = flconfig.ReasoningLevelOff
	AIReasoningLevelMinimal = flconfig.ReasoningLevelMinimal
	AIReasoningLevelLow     = flconfig.ReasoningLevelLow
	AIReasoningLevelMedium  = flconfig.ReasoningLevelMedium
	AIReasoningLevelHigh    = flconfig.ReasoningLevelHigh
	AIReasoningLevelXHigh   = flconfig.ReasoningLevelXHigh
	AIReasoningLevelMax     = flconfig.ReasoningLevelMax
)
View Source
const (
	DefaultLocalEnvironmentID = "local"
)
View Source
const FilesystemScopeSchemaVersionV1 = 1

Variables

View Source
var ErrHomeDirUnavailable = errors.New("user home directory is unavailable")

Functions

func BootstrapConfig

func BootstrapConfig(ctx context.Context, args BootstrapArgs) (writtenPath string, err error)

func DefaultConfigPath

func DefaultConfigPath() (string, error)

func IsCuratedNativeAIProviderModel

func IsCuratedNativeAIProviderModel(providerType string, modelName string) bool

func ResolveStateRoot

func ResolveStateRoot(override string) (string, error)

func RuntimeControlSocketPathFromConfigPath added in v0.6.8

func RuntimeControlSocketPathFromConfigPath(configPath string) string

func RuntimeMaintenancePathFromConfigPath added in v0.6.11

func RuntimeMaintenancePathFromConfigPath(configPath string) string

func Save

func Save(path string, cfg *Config) error

func ValidateAIReasoningLevel added in v0.7.2

func ValidateAIReasoningLevel(level AIReasoningLevel) bool

func ValidateAIReasoningSelection added in v0.7.2

func ValidateAIReasoningSelection(capability AIReasoningCapability, selection AIReasoningSelection) error

func WriteEnvironmentCatalogRecord

func WriteEnvironmentCatalogRecord(layout StateLayout, cfg *Config, localUIBind string, passwordConfigured bool) error

Types

type AIConfig

type AIConfig struct {
	// Providers is the provider registry available to the runtime and UI.
	//
	// Notes:
	// - Providers own their allowed model list (provider + model are always configured together).
	Providers []AIProvider `json:"providers,omitempty"`

	// CurrentModelID points to the model used by default for new chats.
	//
	// Format: <provider_id>/<model_name>
	CurrentModelID string `json:"current_model_id"`

	// PermissionType controls the Flower tool surface and approval behavior.
	//
	// Supported values:
	// - "readonly": safe readonly tools only
	// - "approval_required": standard tools with shell/mutation approval
	// - "full_access": standard tools without per-tool approval
	PermissionType string `json:"permission_type,omitempty"`

	// ToolRecoveryEnabled controls runtime-level recovery orchestration.
	//
	// When enabled, the Go runtime can continue attempts after recoverable tool failures
	// instead of ending the turn immediately.
	ToolRecoveryEnabled *bool `json:"tool_recovery_enabled,omitempty"`

	// ToolRecoveryAllowPathRewrite controls deterministic path normalization/rewrite strategies.
	ToolRecoveryAllowPathRewrite *bool `json:"tool_recovery_allow_path_rewrite,omitempty"`

	// ToolRecoveryAllowProbeTools is reserved for strategy diversification retries in runtime recovery.
	ToolRecoveryAllowProbeTools *bool `json:"tool_recovery_allow_probe_tools,omitempty"`

	// ToolRecoveryFailOnRepeatedSignature controls fail-fast behavior when the same failure signature
	// repeats across recovery attempts.
	ToolRecoveryFailOnRepeatedSignature *bool `json:"tool_recovery_fail_on_repeated_signature,omitempty"`
}

AIConfig configures the optional Flower (AI assistant) feature (model gateway).

Notes:

  • Secrets (api keys) must never be stored in this config. Keys are managed via a separate local secrets file.
  • Field names are snake_case to match the rest of the runtime config surface.

func (*AIConfig) EffectivePermissionType added in v0.7.2

func (c *AIConfig) EffectivePermissionType() string

func (*AIConfig) EffectiveToolRecoveryAllowPathRewrite

func (c *AIConfig) EffectiveToolRecoveryAllowPathRewrite() bool

func (*AIConfig) EffectiveToolRecoveryAllowProbeTools

func (c *AIConfig) EffectiveToolRecoveryAllowProbeTools() bool

func (*AIConfig) EffectiveToolRecoveryEnabled

func (c *AIConfig) EffectiveToolRecoveryEnabled() bool

func (*AIConfig) EffectiveToolRecoveryFailOnRepeatedSignature

func (c *AIConfig) EffectiveToolRecoveryFailOnRepeatedSignature() bool

func (*AIConfig) IsAllowedModelID

func (c *AIConfig) IsAllowedModelID(modelID string) bool

IsAllowedModelID reports whether the given model wire id (<provider_id>/<model_name>) exists in the config allow-list.

func (*AIConfig) ProviderModelByID added in v0.7.2

func (c *AIConfig) ProviderModelByID(modelID string) (AIProvider, AIProviderModel, bool)

func (*AIConfig) Validate

func (c *AIConfig) Validate() error

type AIProvider

type AIProvider struct {
	// ID is a stable internal id (primary key). It must not change once used for secrets/model routing.
	ID string `json:"id"`

	// Name is a human-friendly display name (safe to rename at any time).
	Name string `json:"name,omitempty"`

	// Type is one of:
	// - "openai"
	// - "anthropic"
	// - "moonshot"
	// - "chatglm"
	// - "deepseek"
	// - "qwen"
	// - "openrouter"
	// - "xai"
	// - "groq"
	// - "ollama"
	// - "openai_compatible"
	Type string `json:"type"`

	// BaseURL overrides the provider endpoint (example: "https://api.openai.com/v1").
	// When empty, provider defaults apply.
	//
	// Required provider types:
	// - moonshot
	// - chatglm
	// - deepseek
	// - qwen
	// - openrouter
	// - xai
	// - groq
	// - ollama
	// - openai_compatible
	BaseURL string `json:"base_url,omitempty"`

	// StrictToolSchema overrides provider tool schema strictness.
	//
	// When unset, runtime falls back to built-in policy:
	// - openai official endpoints: strict
	// - openai custom endpoints: non-strict
	// - openai_compatible: non-strict
	// - moonshot/chatglm/deepseek/qwen: non-strict
	StrictToolSchema *bool `json:"strict_tool_schema,omitempty"`

	// WebSearch configures optional web search behavior for generic OpenAI-compatible providers.
	//
	// Native providers (OpenAI, Moonshot, ChatGLM/GLM, DeepSeek, and Qwen) derive their web-search
	// behavior from the provider type and explicit model allow-list, so this field is ignored for them.
	WebSearch *AIProviderWebSearch `json:"web_search,omitempty"`

	// Models is the allowed model list for this provider (shown in the Chat UI).
	Models []AIProviderModel `json:"models,omitempty"`
}

type AIProviderModel

type AIProviderModel struct {
	ModelName                     string                `json:"model_name"`
	WireModelName                 string                `json:"wire_model_name,omitempty"`
	ContextWindow                 int                   `json:"context_window,omitempty"`
	MaxOutputTokens               int                   `json:"max_output_tokens,omitempty"`
	EffectiveContextWindowPercent int                   `json:"effective_context_window_percent,omitempty"`
	InputModalities               []string              `json:"input_modalities,omitempty"`
	ReasoningCapability           AIReasoningCapability `json:"reasoning_capability,omitempty"`
	DefaultReasoningSelection     AIReasoningSelection  `json:"default_reasoning_selection,omitempty"`
}

func (AIProviderModel) EffectiveContextWindowPercentValue

func (m AIProviderModel) EffectiveContextWindowPercentValue() int

func (AIProviderModel) EffectiveDefaultReasoningSelection added in v0.7.2

func (m AIProviderModel) EffectiveDefaultReasoningSelection(providerType string) AIReasoningSelection

func (AIProviderModel) EffectiveInputWindowTokens

func (m AIProviderModel) EffectiveInputWindowTokens() int

func (AIProviderModel) EffectiveReasoningCapability added in v0.7.2

func (m AIProviderModel) EffectiveReasoningCapability(providerType string) AIReasoningCapability

func (AIProviderModel) EffectiveWireModelName added in v0.7.2

func (m AIProviderModel) EffectiveWireModelName() string

func (AIProviderModel) NormalizedInputModalities added in v0.6.10

func (m AIProviderModel) NormalizedInputModalities() []string

func (AIProviderModel) SupportsImageInput added in v0.6.10

func (m AIProviderModel) SupportsImageInput() bool

type AIProviderWebSearch

type AIProviderWebSearch struct {
	// Mode is only honored for openai_compatible providers.
	//
	// Supported values:
	// - "disabled": do not expose any web-search capability
	// - "openai_builtin": attach OpenAI Responses-style hosted web search
	// - "brave": expose Flower's external Brave-backed web.search tool
	Mode string `json:"mode,omitempty"`
}

type AIReasoningCapability added in v0.7.2

type AIReasoningCapability struct {
	Kind                      string   `json:"kind"`
	SupportedLevels           []string `json:"supported_levels,omitempty"`
	DefaultLevel              string   `json:"default_level,omitempty"`
	DisableSupported          bool     `json:"disable_supported,omitempty"`
	DefaultEnabled            *bool    `json:"default_enabled,omitempty"`
	WireShape                 string   `json:"wire_shape"`
	DisableShape              string   `json:"disable_shape,omitempty"`
	BudgetShape               string   `json:"budget_shape,omitempty"`
	MinBudgetTokens           int      `json:"min_budget_tokens,omitempty"`
	MaxBudgetTokens           int      `json:"max_budget_tokens,omitempty"`
	DynamicProviderMetadata   bool     `json:"dynamic_provider_metadata,omitempty"`
	ResponseReasoningFields   []string `json:"response_reasoning_fields,omitempty"`
	HistoryReplayRequirements []string `json:"history_replay_requirements,omitempty"`
	SourceURLs                []string `json:"source_urls"`
	SourceCheckedAt           string   `json:"source_checked_at"`
	Fixture                   string   `json:"fixture"`
}

func AIReasoningCapabilityForModel added in v0.7.2

func AIReasoningCapabilityForModel(providerType string, modelName string) AIReasoningCapability

func (AIReasoningCapability) IsZero added in v0.7.2

func (c AIReasoningCapability) IsZero() bool

func (AIReasoningCapability) Normalize added in v0.7.2

func (AIReasoningCapability) SupportsBudget added in v0.7.2

func (c AIReasoningCapability) SupportsBudget() bool

func (AIReasoningCapability) SupportsLevel added in v0.7.2

func (c AIReasoningCapability) SupportsLevel(level AIReasoningLevel) bool

func (AIReasoningCapability) Validate added in v0.7.2

func (c AIReasoningCapability) Validate() error

type AIReasoningLevel added in v0.7.2

type AIReasoningLevel = flconfig.ReasoningLevel

type AIReasoningSelection added in v0.7.2

type AIReasoningSelection = flconfig.ReasoningSelection

func NormalizeAIReasoningSelection added in v0.7.2

func NormalizeAIReasoningSelection(in AIReasoningSelection) AIReasoningSelection

type BootstrapArgs

type BootstrapArgs struct {
	ProviderOrigin         string
	ControlplaneBaseURL    string
	ControlplaneProviderID string
	EnvironmentID          string
	BootstrapTicket        string
	RuntimeVersion         string

	StateRoot string

	AgentHomeDir string
	Shell        string
	LogFormat    string
	LogLevel     string
	// HTTPClient optionally supplies custom TLS trust roots while HTTPS and redirect policy remain enforced.
	HTTPClient *http.Client

	// PermissionPolicyPreset is an optional preset used to write permission_policy into the config.
	// If empty, bootstrap preserves the existing permission_policy when possible, otherwise uses defaults.
	PermissionPolicyPreset string
}

type Config

type Config struct {
	ProviderOrigin           string                      `json:"provider_origin"`
	ControlplaneBaseURL      string                      `json:"controlplane_base_url"`
	ControlplaneProviderID   string                      `json:"controlplane_provider_id,omitempty"`
	EnvironmentID            string                      `json:"environment_id"`
	LocalEnvironmentPublicID string                      `json:"local_environment_public_id"`
	BindingGeneration        int64                       `json:"binding_generation,omitempty"`
	AgentInstanceID          string                      `json:"agent_instance_id"`
	Direct                   *directv1.DirectConnectInfo `json:"direct"`

	// AI config controls optional Flower AI assistant features.
	AI *AIConfig `json:"ai,omitempty"`

	// PermissionPolicy is the local permission cap applied on the endpoint.
	// It is designed to limit the effective permissions even if the control-plane grants more.
	PermissionPolicy *PermissionPolicy `json:"permission_policy,omitempty"`

	// AgentHomeDir is the default home/working directory and the target of "~".
	// If empty, the runtime picks a safe default (the current user home dir).
	// Filesystem access boundaries are defined by FilesystemScope.
	AgentHomeDir string `json:"agent_home_dir,omitempty"`

	// FilesystemScope defines the endpoint-local filesystem roots exposed to
	// runtime capabilities. When omitted, the runtime derives a Home root from
	// AgentHomeDir and a read-only Computer root at the OS filesystem root.
	FilesystemScope *FilesystemScope `json:"filesystem_scope,omitempty"`

	// Shell is the shell command used for terminal sessions.
	// If empty, the runtime picks a default (SHELL or /bin/bash).
	Shell string `json:"shell,omitempty"`

	// LogFormat is "json" or "text".
	LogFormat string `json:"log_format,omitempty"`
	// LogLevel is "debug|info|warn|error".
	LogLevel string `json:"log_level,omitempty"`

	// CodeServerPortMin/Max configures the dynamic port range used for code-server processes.
	// If unset/invalid, the runtime uses a safe default range.
	CodeServerPortMin int `json:"code_server_port_min,omitempty"`
	CodeServerPortMax int `json:"code_server_port_max,omitempty"`
	// contains filtered or unexported fields
}

Config is the runtime configuration for Redeven. Secret material is loaded from secrets.json and is never serialized back into config.json.

func BootstrapProviderLink(ctx context.Context, args ProviderLinkBootstrapArgs) (*Config, error)

func Load

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

func ResolveProviderLinkConfig added in v0.6.8

func ResolveProviderLinkConfig(ctx context.Context, args ProviderLinkBootstrapArgs) (*Config, error)

func (Config) MarshalJSON added in v0.6.8

func (c Config) MarshalJSON() ([]byte, error)

func (*Config) UnmarshalJSON added in v0.6.8

func (c *Config) UnmarshalJSON(data []byte) error

func (*Config) ValidateLocalMinimal

func (c *Config) ValidateLocalMinimal() error

ValidateLocalMinimal validates config fields required to start the runtime in local-only mode.

Local-only mode is enabled by `redeven run --mode local` and must work even when the controlplane credentials are missing (no bootstrap yet).

func (*Config) ValidateRemoteStrict

func (c *Config) ValidateRemoteStrict() error

ValidateRemoteStrict validates the fields required to connect to the remote control channel.

This is the standard mode requirements: the runtime must be fully bootstrapped.

type FilesystemPermissionSet added in v0.6.8

type FilesystemPermissionSet struct {
	Read  bool `json:"read"`
	Write bool `json:"write"`
}

type FilesystemRootKind added in v0.6.8

type FilesystemRootKind string
const (
	FilesystemRootHome     FilesystemRootKind = "home"
	FilesystemRootComputer FilesystemRootKind = "computer"
	FilesystemRootCustom   FilesystemRootKind = "custom"
)

type FilesystemRootPolicy added in v0.6.8

type FilesystemRootPolicy struct {
	ID          string                  `json:"id"`
	Label       string                  `json:"label"`
	Path        string                  `json:"path"`
	Kind        FilesystemRootKind      `json:"kind"`
	Permissions FilesystemPermissionSet `json:"permissions"`
	Hidden      bool                    `json:"hidden,omitempty"`
	System      bool                    `json:"system,omitempty"`
}

type FilesystemScope added in v0.6.8

type FilesystemScope struct {
	SchemaVersion int                    `json:"schema_version"`
	DefaultRootID string                 `json:"default_root_id,omitempty"`
	Roots         []FilesystemRootPolicy `json:"roots"`
}

func (*FilesystemScope) Validate added in v0.6.8

func (s *FilesystemScope) Validate() error

type LocalEnvironmentBinding

type LocalEnvironmentBinding struct {
	LocalEnvironmentPublicID string `json:"local_environment_public_id"`
	UserPublicID             string `json:"user_public_id,omitempty"`
	EnvPublicID              string `json:"env_public_id"`
	Generation               int64  `json:"generation"`
	Hostname                 string `json:"hostname,omitempty"`
	OS                       string `json:"os,omitempty"`
	Arch                     string `json:"arch,omitempty"`
	RuntimeVersion           string `json:"runtime_version,omitempty"`
	LastSeenAtUnixMS         int64  `json:"last_seen_at_unix_ms,omitempty"`
}

type PermissionPolicy

type PermissionPolicy struct {
	SchemaVersion int `json:"schema_version"`

	// LocalMax is the global cap. It must be present for schema_version=1.
	LocalMax *PermissionSet `json:"local_max"`

	// ByUser and ByApp are optional additional caps. They can only further reduce LocalMax.
	ByUser map[string]*PermissionSet `json:"by_user,omitempty"`
	ByApp  map[string]*PermissionSet `json:"by_app,omitempty"`
}

PermissionPolicy is the local permission cap configuration stored on the runtime endpoint.

It is used to clamp control-plane granted permissions ("session_meta") to a user-approved maximum.

func ParsePermissionPolicyPreset

func ParsePermissionPolicyPreset(preset string) (*PermissionPolicy, error)

func (*PermissionPolicy) ResolveCap

func (p *PermissionPolicy) ResolveCap(userPublicID string, floeApp string) PermissionSet

ResolveCap returns the local cap to apply for the given user/app pair.

The resolution model is: - start from LocalMax - intersect with by_user[user_public_id] if present - intersect with by_app[floe_app] if present

func (*PermissionPolicy) Validate

func (p *PermissionPolicy) Validate() error

type PermissionSet

type PermissionSet struct {
	Read    bool `json:"read"`
	Write   bool `json:"write"`
	Execute bool `json:"execute"`
}

PermissionSet is the 3-bit permission model used by Redeven runtimes.

func ResolvePermissionCapFromConfigPath

func ResolvePermissionCapFromConfigPath(
	configPath string,
	userPublicID string,
	floeApp string,
	fallback PermissionSet,
) PermissionSet

ResolvePermissionCapFromConfigPath loads configPath and resolves the effective local cap for the given user/app pair. When the config cannot be loaded, it falls back to fallback.

func (PermissionSet) Intersect

func (p PermissionSet) Intersect(other PermissionSet) PermissionSet

type ProviderLinkBootstrapArgs added in v0.6.8

type ProviderLinkBootstrapArgs struct {
	ConfigPath string

	ProviderOrigin         string
	ControlplaneBaseURL    string
	ControlplaneProviderID string
	EnvironmentID          string
	BootstrapTicket        string
	RuntimeVersion         string
	PermissionPolicyPreset string
	AgentHomeDir           string
	Shell                  string
	LogFormat              string
	LogLevel               string
	// HTTPClient optionally supplies custom TLS trust roots while HTTPS and redirect policy remain enforced.
	HTTPClient *http.Client

	RuntimeHostname string
	RuntimeGOOS     string
	RuntimeGOARCH   string

	PreservePermissionPolicy bool
}

type StateLayout

type StateLayout struct {
	StateRoot                string
	ConfigPath               string
	SecretsPath              string
	LockPath                 string
	StateDir                 string
	RuntimeControlSocketPath string
	RuntimeMaintenancePath   string
	DiagnosticsDir           string
	AuditDir                 string
	AppsDir                  string
}

func DefaultStateLayout

func DefaultStateLayout() (StateLayout, error)

DefaultStateLayout returns the single Local Environment layout rooted under the resolved state root.

func LocalEnvironmentStateLayout

func LocalEnvironmentStateLayout(stateRoot string) (StateLayout, error)

Jump to

Keyboard shortcuts

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