config

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultTeamName = "default"
	DefaultModel    = "opus"
	MergeModeAuto   = "auto"
	MergeModeManual = "manual"
)
View Source
const DefaultGatewayURL = "http://127.0.0.1:18789"
View Source
const DefaultShell = "zsh"

Variables

This section is empty.

Functions

func AgentSessionName

func AgentSessionName(team, agent string) string

AgentSessionName returns the tmux session name for an agent. Convention: "ttal-<team>-<agent>" (e.g. "ttal-default-athena", "ttal-guion-mira").

This is distinct from worker sessions which use "w-<uuid[:8]>-<slug>" (e.g. "w-e9d4b7c1-fix-auth"). See taskwarrior.Task.SessionName().

func DefaultDataDir

func DefaultDataDir() string

DefaultDataDir returns the default data directory (~/.ttal).

func DefaultTaskRC

func DefaultTaskRC() string

DefaultTaskRC returns the default taskrc path (~/.taskrc).

func DotEnvParts

func DotEnvParts() []string

DotEnvParts loads .env and returns "KEY=VALUE" strings suitable for appending to an environment variable slice. All errors (missing file, parse failures, unreadable path) are silently ignored — returns nil.

func DotEnvPath

func DotEnvPath() (string, error)

DotEnvPath returns the path to the .env file: ~/.config/ttal/.env

func ExpandHome

func ExpandHome(path string) string

ExpandHome replaces a leading ~ or ~/ with the user's home directory. Does NOT expand ~username syntax (that would require OS-specific user lookup).

func LoadDotEnv

func LoadDotEnv() (map[string]string, error)

LoadDotEnv reads ~/.config/ttal/.env and returns key-value pairs. Returns empty map (not error) if file doesn't exist.

func Path

func Path() (string, error)

Path returns the default path to config.toml.

func ResolveDBPath

func ResolveDBPath() string

ResolveDBPath returns the database path for the active team without requiring a full config load. Used by db.DefaultPath() and hook code.

func ResolveDBPathForTeam

func ResolveDBPathForTeam(teamName string) (string, error)

ResolveDBPathForTeam returns the database path for a specific team name. Unlike ResolveDBPath (which caches), this loads fresh config for the given team.

func ResolveDataDir

func ResolveDataDir() string

ResolveDataDir returns the data directory for the active team without requiring a full config load. Falls back to ~/.ttal if config is unavailable. Used by path helpers that need to work before config is loaded (e.g. db.DefaultPath). Result is cached after first call.

func WriteTemplate

func WriteTemplate() error

WriteTemplate creates a starter config.toml with example config.

Types

type AgentConfig

type AgentConfig struct {
	// BotToken is resolved from ~/.config/ttal/.env at load time (not stored in TOML).
	BotToken    string `toml:"-" jsonschema:"-"`                                                                                             //nolint:lll
	BotTokenEnv string `toml:"bot_token_env" jsonschema:"description=Override env var name for bot token (default: {UPPER_NAME}_BOT_TOKEN)"` //nolint:lll
	Port        int    `toml:"port" jsonschema:"description=API server port for opencode/codex runtimes"`
	Runtime     string `` //nolint:lll
	/* 157-byte string literal not displayed */
	Model string `toml:"model" jsonschema:"enum=haiku,enum=sonnet,enum=opus,description=Claude model tier (falls back to opus)"` //nolint:lll
}

AgentConfig holds per-agent Telegram credentials and runtime settings.

type Config

type Config struct {
	// Resolved fields — populated from active team after Load(). Not directly settable in TOML.
	ChatID         string                 `toml:"-" json:"-"`
	LifecycleAgent string                 `toml:"-" json:"-"`
	Agents         map[string]AgentConfig `toml:"-" json:"-"`
	Voice          VoiceConfig            `toml:"-" json:"-"`

	// Global fields — not per-team.
	Shell   string        `toml:"shell" jsonschema:"enum=zsh,enum=fish,description=Shell for spawning workers"`
	Sync    SyncConfig    `toml:"sync" jsonschema:"description=Paths for subagent and skill deployment"`
	Prompts PromptsConfig `toml:"prompts" jsonschema:"description=Prompt templates for task routing"`

	// Team-aware fields.
	DefaultTeam string                `toml:"default_team" jsonschema:"description=Active team when TTAL_TEAM env is not set"` //nolint:lll
	Teams       map[string]TeamConfig `toml:"teams" jsonschema:"description=Per-team configuration sections"`
	// contains filtered or unexported fields
}

Config is the top-level structure for ~/.config/ttal/config.toml.

Requires [teams] sections. After Load(), resolved fields are populated from the active team. Callers access ChatID, Agents, etc. without caring about which team is active.

func Load

func Load() (*Config, error)

Load reads and validates ~/.config/ttal/config.toml. If the config uses [teams], the active team is resolved and its fields are promoted to the top-level Config fields for backward compatibility.

func (*Config) AgentModelFor

func (c *Config) AgentModelFor(agentName string) string

AgentModelFor returns the effective model for an agent (default: "opus").

func (*Config) AgentPath

func (c *Config) AgentPath(agentName string) string

AgentPath returns the workspace path for an agent, derived from team_path.

func (*Config) AgentRuntime

func (c *Config) AgentRuntime() runtime.Runtime

AgentRuntime returns the team's agent runtime ("claude-code" if unset).

func (*Config) AgentRuntimeFor

func (c *Config) AgentRuntimeFor(agentName string) runtime.Runtime

AgentRuntimeFor returns the effective runtime for an agent: per-agent override > team agent_runtime > claude-code.

func (*Config) BuildEnvShellCommand

func (c *Config) BuildEnvShellCommand(envParts []string, cmd string) string

func (*Config) DBPath

func (c *Config) DBPath() string

DBPath returns the resolved database path for the active team.

func (*Config) DataDir

func (c *Config) DataDir() string

DataDir returns the resolved data directory for the active team.

func (*Config) DesignAgent

func (c *Config) DesignAgent() string

DesignAgent returns the team's design agent name.

func (*Config) GatewayURL

func (c *Config) GatewayURL() string

GatewayURL returns the OpenClaw Gateway URL for the active team.

func (*Config) GetMergeMode

func (c *Config) GetMergeMode() string

GetMergeMode returns the resolved merge mode ("auto" if unset). "auto" merges immediately; "manual" sends a notification instead.

func (*Config) GetShell

func (c *Config) GetShell() string

func (*Config) HooksToken

func (c *Config) HooksToken() string

HooksToken returns the OpenClaw hooks auth token for the active team.

func (*Config) Prompt

func (c *Config) Prompt(key string) string

Prompt returns the prompt template for a given key, falling back to defaults.

func (*Config) RenderPrompt

func (c *Config) RenderPrompt(key, taskID string) string

RenderPrompt returns a prompt with {{task-id}} replaced by the actual task ID.

func (*Config) ResearchAgent

func (c *Config) ResearchAgent() string

ResearchAgent returns the team's research agent name.

func (*Config) ShellCommand

func (c *Config) ShellCommand(cmd string) string

func (*Config) TaskData

func (c *Config) TaskData() string

TaskData returns the resolved taskwarrior data directory for the active team.

func (*Config) TaskRC

func (c *Config) TaskRC() string

TaskRC returns the resolved taskrc path for the active team.

func (*Config) TaskSyncURL

func (c *Config) TaskSyncURL() string

TaskSyncURL returns the TaskChampion sync server URL for the active team.

func (*Config) TeamName

func (c *Config) TeamName() string

TeamName returns the resolved active team name.

func (*Config) TeamPath

func (c *Config) TeamPath() string

TeamPath returns the resolved team path for the active team.

func (*Config) TestAgent

func (c *Config) TestAgent() string

TestAgent returns the team's test agent name.

func (*Config) WorkerRuntime

func (c *Config) WorkerRuntime() runtime.Runtime

WorkerRuntime returns the team's worker runtime ("claude-code" if unset).

type DaemonConfig

type DaemonConfig struct {
	Global *Config                  // Raw config (Sync, Shell, Prompts, etc.)
	Teams  map[string]*ResolvedTeam // team name -> resolved team config
}

DaemonConfig holds all teams' resolved configurations.

func LoadAll

func LoadAll() (*DaemonConfig, error)

LoadAll loads config.toml and resolves ALL teams. Used by the daemon to serve all teams from a single process.

func (*DaemonConfig) AgentModelForTeam

func (m *DaemonConfig) AgentModelForTeam(teamName, agentName string) string

AgentModelForTeam resolves effective model for an agent in a team.

func (*DaemonConfig) AgentRuntimeForTeam

func (m *DaemonConfig) AgentRuntimeForTeam(teamName, agentName string) runtime.Runtime

AgentRuntimeForTeam resolves effective runtime for an agent in a team.

func (*DaemonConfig) AllAgents

func (m *DaemonConfig) AllAgents() []TeamAgent

AllAgents returns all agents across all teams, sorted by team then agent name.

func (*DaemonConfig) FindAgent

func (m *DaemonConfig) FindAgent(agentName string) (*TeamAgent, bool)

FindAgent looks up which team an agent belongs to. Returns the first match if agent names are unique across teams.

func (*DaemonConfig) FindAgentInTeam

func (m *DaemonConfig) FindAgentInTeam(teamName, agentName string) (*TeamAgent, bool)

FindAgentInTeam looks up an agent within a specific team.

type PromptsConfig

type PromptsConfig struct {
	Design   string `toml:"design" jsonschema:"description=Prompt for design agent"`
	Research string `toml:"research" jsonschema:"description=Prompt for research agent"`
	Test     string `toml:"test" jsonschema:"description=Prompt for test agent"`
	Execute  string `toml:"execute" jsonschema:"description=Prompt prefix for worker spawn"`
}

PromptsConfig holds configurable prompt templates for task routing and worker spawn. Supports {{task-id}} template variable (replaced with the task's short UUID at runtime).

func DefaultPrompts

func DefaultPrompts() PromptsConfig

DefaultPrompts returns sensible defaults for all prompt templates.

type ResolvedTeam

type ResolvedTeam struct {
	Name           string
	TeamPath       string
	DataDir        string
	TaskRC         string
	ChatID         string
	LifecycleAgent string
	AgentRuntime   string
	WorkerRuntime  string
	MergeMode      string
	GatewayURL     string
	HooksToken     string
	Voice          VoiceConfig
	Agents         map[string]AgentConfig
}

ResolvedTeam holds a single team's fully resolved config.

type SyncConfig

type SyncConfig struct {
	SubagentsPaths []string `toml:"subagents_paths" jsonschema:"description=Directories to scan for subagent definitions"`
	SkillsPaths    []string `toml:"skills_paths" jsonschema:"description=Directories to scan for skill definitions"`
	CommandsPaths  []string `toml:"commands_paths" jsonschema:"description=Directories to scan for command definitions"`
}

SyncConfig holds paths for subagent, skill, and command deployment.

type TeamAgent

type TeamAgent struct {
	TeamName  string
	AgentName string
	Config    AgentConfig
	ChatID    string // team chat ID (all agents in a team share one chat)
	TeamPath  string
}

TeamAgent pairs an agent with its team context.

type TeamConfig

type TeamConfig struct {
	TeamPath       string `toml:"team_path" jsonschema:"description=Root path for agent workspaces. Agent path = team_path/agent_name."`         //nolint:lll
	DBPath         string `toml:"db_path" jsonschema:"description=Path to ttal.db (default: <data_dir>/ttal.db). Set to share DB across teams."` //nolint:lll
	DataDir        string `toml:"data_dir" jsonschema:"description=ttal data directory (default: ~/.ttal/<team>)"`                               //nolint:lll
	TaskRC         string `toml:"taskrc" jsonschema:"description=Taskwarrior config file path (default: <data_dir>/taskrc)"`                     //nolint:lll
	ChatID         string `toml:"chat_id" jsonschema:"description=Telegram chat ID for this team"`
	LifecycleAgent string `toml:"lifecycle_agent" jsonschema:"description=Agent responsible for worker lifecycle"` //nolint:lll
	AgentRuntime   string ``                                                                                       //nolint:lll
	/* 128-byte string literal not displayed */
	WorkerRuntime   string                 `toml:"worker_runtime" jsonschema:"enum=claude-code,enum=opencode,enum=codex,description=Runtime for spawned workers"` //nolint:lll
	GatewayURL      string                 `toml:"gateway_url" jsonschema:"description=OpenClaw Gateway URL"`
	HooksToken      string                 `toml:"hooks_token" jsonschema:"description=OpenClaw hooks auth token"`
	MergeMode       string                 `toml:"merge_mode" jsonschema:"enum=auto,enum=manual,description=PR merge mode override for this team"`                  //nolint:lll
	VoiceLanguage   string                 `toml:"voice_language" jsonschema:"description=ISO 639-1 language code for Whisper (default: en; auto for auto-detect)"` //nolint:lll
	DesignAgent     string                 `toml:"design_agent" jsonschema:"description=Design/brainstorm agent"`
	ResearchAgent   string                 `toml:"research_agent" jsonschema:"description=Research agent"`
	TestAgent       string                 `toml:"test_agent" jsonschema:"description=Test writing agent"`
	Agents          map[string]AgentConfig `toml:"agents" jsonschema:"description=Per-agent credentials for this team"`
	VoiceVocabulary []string               `toml:"voice_vocabulary" jsonschema:"description=Custom vocabulary words for Whisper transcription accuracy"` //nolint:lll
	TaskSyncURL     string                 `toml:"task_sync_url" jsonschema:"description=TaskChampion sync server URL for ttal doctor --fix"`            //nolint:lll
}

TeamConfig holds per-team configuration.

type VoiceConfig

type VoiceConfig struct {
	Vocabulary []string `toml:"vocabulary" jsonschema:"description=Custom vocabulary words for Whisper"`
	Language   string   `toml:"language" jsonschema:"description=ISO 639-1 language code (default: en)"`
}

VoiceConfig holds voice-related settings resolved from the active team.

Jump to

Keyboard shortcuts

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