config

package
v0.140.0 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ResolveToolsDir added in v0.140.0

func ResolveToolsDir(configDir, configured string) string

ResolveToolsDir returns the configured privileged-tools directory, applying the same default and home expansion for both the wing and its remote MCP surface.

func SaveWingConfig added in v0.34.0

func SaveWingConfig(dir string, cfg *WingConfig) error

SaveWingConfig writes wing.yaml to dir. The file may contain the roost's JWT signing key, so it must never be readable by other local users.

func ToolNames added in v0.130.0

func ToolNames(tools []*ToolConfig) []string

ToolNames returns just the tool names from a slice of configs.

Types

type AllowKey added in v0.34.0

type AllowKey struct {
	Key    string `yaml:"key,omitempty"`     // base64 raw P-256 public key (optional)
	UserID string `yaml:"user_id,omitempty"` // relay user ID
	Email  string `yaml:"email,omitempty"`   // auto-set from relay, for display
}

AllowKey is an allowed user for wing access control.

type Config

type Config struct {
	Dir               string            `yaml:"-"`
	DefaultAgent      string            `yaml:"default_agent"`
	DefaultEmbedder   string            `yaml:"default_embedder"`
	WingID            string            `yaml:"wing_id"`
	Hostname          string            `yaml:"-"` // os.Hostname(), not persisted
	PollInterval      string            `yaml:"poll_interval"`
	DefaultMaxRetries int               `yaml:"max_retries"`
	RoostURL          string            `yaml:"roost_url"`
	Vars              map[string]string `yaml:"vars"`
}

func Load

func Load() (*Config, error)

func (*Config) DBPath

func (c *Config) DBPath() string

func (*Config) MemoryDir

func (c *Config) MemoryDir() string

func (*Config) RelayDBPath added in v0.16.1

func (c *Config) RelayDBPath() string

func (*Config) ResolveVars

func (c *Config) ResolveVars(s string) string

func (*Config) SkillsDir

func (c *Config) SkillsDir() string

type ICEServer added in v0.108.0

type ICEServer struct {
	URLs       []string `yaml:"urls" json:"urls"`
	Username   string   `yaml:"username,omitempty" json:"username,omitempty"`
	Credential string   `yaml:"credential,omitempty" json:"credential,omitempty"`
}

ICEServer is a STUN/TURN server configuration for WebRTC P2P connections.

type MCPConfig added in v0.140.0

type MCPConfig struct {
	Enabled         bool                      `yaml:"enabled"`
	DefaultAllowAll bool                      `yaml:"default_allow_all"`
	Roles           map[string]*MCPRoleConfig `yaml:"roles"`
}

MCPConfig configures the OAuth-gated MCP endpoint exposed by a roost.

func (*MCPConfig) AllowedAny added in v0.140.0

func (p *MCPConfig) AllowedAny(roles []string, tool string) bool

AllowedAny implements maximum-subset semantics: a tool is visible when any one of the caller's MCP-enabled roles allows it. Disabled roles contribute neither grants nor denies.

func (*MCPConfig) EnabledAny added in v0.140.0

func (p *MCPConfig) EnabledAny(roles []string) bool

EnabledAny reports whether at least one of the caller's roles enables MCP.

func (*MCPConfig) EnabledRoles added in v0.140.0

func (p *MCPConfig) EnabledRoles(roles []string) []string

EnabledRoles removes memberships that do not participate in the MCP surface.

func (*MCPConfig) RolesForEmail added in v0.140.0

func (p *MCPConfig) RolesForEmail(email string) []string

RolesForEmail returns every configured role an email belongs to in name order.

func (*MCPConfig) UnmarshalYAML added in v0.140.0

func (p *MCPConfig) UnmarshalYAML(value *yaml.Node) error

UnmarshalYAML keeps wing.yaml backwards-compatible at the top level while decoding the security-sensitive MCP section strictly. A typo in enabled/allow/deny must fail closed.

func (*MCPConfig) Validate added in v0.140.0

func (p *MCPConfig) Validate() error

Validate rejects ambiguous policy shapes and normalizes member emails.

type MCPRoleConfig added in v0.140.0

type MCPRoleConfig struct {
	Enabled bool     `yaml:"enabled"`
	Allow   []string `yaml:"allow,omitempty"`
	Deny    []string `yaml:"deny,omitempty"`
	Members []string `yaml:"members,omitempty"`
}

MCPRoleConfig controls which privileged tools one role may use over the remote MCP surface. It does not affect tools available to in-wing agents.

type PathEntry added in v0.56.0

type PathEntry struct {
	Path    string   `yaml:"path" json:"path"`
	Members []string `yaml:"members,omitempty" json:"members,omitempty"`
}

PathEntry is a directory path with optional per-folder member ACLs. When Members is nil/empty, the path is visible to all authenticated users (legacy behavior). When Members is set, only those emails + owner/admin can access the path.

type PathList added in v0.56.0

type PathList []PathEntry

PathList is a list of PathEntry values that supports mixed YAML formats: plain strings ("~/repos") and mappings ({path: ~/repos, members: [...]}).

func (PathList) MarshalYAML added in v0.56.0

func (pl PathList) MarshalYAML() (any, error)

MarshalYAML serializes PathList: entries without members become plain strings (backwards compat).

func (PathList) PathsForUser added in v0.56.0

func (pl PathList) PathsForUser(email, orgRole string) []string

PathsForUser returns paths accessible to the given email/orgRole. Owner/admin get all paths. Members get only entries where their email is in Members (case-insensitive) or where Members is empty/nil (legacy open entries).

func (PathList) Strings added in v0.56.0

func (pl PathList) Strings() []string

Strings returns just the path strings (drop-in for existing callers that need []string).

func (*PathList) UnmarshalYAML added in v0.56.0

func (pl *PathList) UnmarshalYAML(value *yaml.Node) error

UnmarshalYAML handles both scalar strings and mapping nodes in a YAML sequence.

type ToolConfig added in v0.130.0

type ToolConfig struct {
	Name          string            `yaml:"name"`
	Description   string            `yaml:"description,omitempty"`
	Params        []ToolParam       `yaml:"params,omitempty"`
	Run           string            `yaml:"run"`
	Env           map[string]string `yaml:"env,omitempty"`
	Timeout       string            `yaml:"timeout,omitempty"`
	MaxConcurrent int               `yaml:"max_concurrent,omitempty"`
}

ToolConfig defines a privileged tool that the wing daemon can execute on behalf of sandboxed agents.

func LoadToolsDir added in v0.130.0

func LoadToolsDir(dir string) ([]*ToolConfig, error)

LoadToolsDir reads all .yaml files from dir and returns parsed tool configs. Returns nil (no error) if dir doesn't exist. Warns on world-readable files.

func (*ToolConfig) TimeoutDuration added in v0.130.0

func (t *ToolConfig) TimeoutDuration() time.Duration

TimeoutDuration parses the Timeout field as a time.Duration. Returns 0 if empty or unparseable.

type ToolParam added in v0.140.0

type ToolParam struct {
	Name        string   `yaml:"name" json:"name"`
	Description string   `yaml:"description,omitempty" json:"description,omitempty"`
	Type        string   `yaml:"type,omitempty" json:"type,omitempty"`
	Required    bool     `yaml:"required,omitempty" json:"required,omitempty"`
	Enum        []string `yaml:"enum,omitempty" json:"enum,omitempty"`
	Examples    []any    `yaml:"examples,omitempty" json:"examples,omitempty"`
}

ToolParam optionally describes one positional tool argument as a named MCP parameter. Params remain ordered: the MCP adapter maps named arguments back to argv in this order so the existing tool runner and egg socket stay backwards-compatible.

type WingConfig added in v0.34.0

type WingConfig struct {
	WingID         string     `yaml:"wing_id"`
	Label          string     `yaml:"label,omitempty"` // display name shown in the web UI
	Roost          string     `yaml:"roost,omitempty"`
	Org            string     `yaml:"org,omitempty"`
	Paths          PathList   `yaml:"paths,omitempty"`
	Root           string     `yaml:"root,omitempty"` // compat: folded into Paths on load
	Labels         []string   `yaml:"labels,omitempty"`
	EggConfig      string     `yaml:"egg_config,omitempty"`
	Conv           string     `yaml:"conv,omitempty"`
	Audit          bool       `yaml:"audit,omitempty"`
	Debug          bool       `yaml:"debug,omitempty"`
	Locked         bool       `yaml:"locked,omitempty"`   // explicit lock mode toggle
	Spectate       bool       `yaml:"spectate,omitempty"` // allow spectator (read-only) session viewing
	AuthTTL        string     `yaml:"auth_ttl,omitempty"` // passkey auth token duration (default "1h")
	AllowKeys      []AllowKey `yaml:"allow_keys,omitempty"`
	Admins         []string   `yaml:"admins,omitempty"`          // emails with admin role (see all sessions, all paths)
	IdleTimeout    string     `yaml:"idle_timeout,omitempty"`    // kill sessions idle for this long (e.g. "4h")
	ConnectionMode string     `yaml:"connection_mode,omitempty"` // "relay" (default), "p2p", "p2p_only", "direct"

	// P2P / Direct mode settings
	ICEServers []ICEServer `yaml:"ice_servers,omitempty"` // STUN/TURN servers for WebRTC
	DirectPort int         `yaml:"direct_port,omitempty"` // port for direct WebSocket connections
	DirectTLS  bool        `yaml:"direct_tls,omitempty"`  // enable TLS for direct mode

	// JWT signing key for roost mode (base64-DER P-256 private key).
	// Auto-generated on first roost start. Server mode uses WT_JWT_KEY env instead.
	JWTKey string `yaml:"jwt_key,omitempty"`

	// ToolsDir is the directory containing privileged tool YAML configs.
	// Defaults to ~/.wingthing/tools/ if empty.
	ToolsDir string `yaml:"tools_dir,omitempty"`

	// MCP is the optional OAuth-gated remote surface over privileged tools.
	MCP *MCPConfig `yaml:"mcp,omitempty"`
}

WingConfig holds wing-specific settings persisted in ~/.wingthing/wing.yaml.

func LoadWingConfig added in v0.34.0

func LoadWingConfig(dir string) (*WingConfig, error)

LoadWingConfig reads wing.yaml from dir. If the file doesn't exist, it returns a zero-value config (no error). If a legacy wing-id file exists, the wing_id is seeded from it.

func (*WingConfig) IsAdmin added in v0.63.0

func (c *WingConfig) IsAdmin(email string) bool

IsAdmin returns true if email is in the Admins list (case-insensitive).

Jump to

Keyboard shortcuts

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