config

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: Apache-2.0 Imports: 18 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

Overview

Package config loads and validates actp.yaml.

Index

Constants

View Source
const CurrentVersion = 1

CurrentVersion is the config file format version this build writes and reads.

View Source
const TokenPrefix = "actp_"

TokenPrefix marks actp tokens so they are easy to spot in logs and secret scanners.

Variables

View Source
var Presets = map[string]Preset{
	"claude-code": {Name: "Claude Code", Command: "claude-agent-acp"},
	"codex":       {Name: "Codex", Command: "codex-acp"},
	"droid":       {Name: "Droid", Command: "droid", Args: []string{"exec", "--output-format", "acp"}},
	"gemini":      {Name: "Gemini CLI", Command: "gemini", Args: []string{"--acp"}},
	"opencode":    {Name: "OpenCode", Command: "opencode", Args: []string{"acp"}},
	"grok":        {Name: "Grok", Command: "grok", Args: []string{"agent", "stdio"}},
	"pi":          {Name: "Pi", Command: "pi-acp"},
	"prime-agent": {Name: "Prime Agent", Command: "prime-agent", Args: []string{"--mode", "acp"}},
}

Presets are built from docs/agents.md. Keep both in step.

Functions

func AgentBinDir added in v0.1.1

func AgentBinDir() string

AgentBinDir is the folder with the commands of agents the dashboard installed.

func AgentsPrefix added in v0.1.1

func AgentsPrefix() string

AgentsPrefix is where the dashboard installs agents (an npm prefix).

func ApplyTokenDefaults

func ApplyTokenDefaults(t *Token)

ApplyTokenDefaults fills in default values for a token entry.

func DefaultPath

func DefaultPath() string

DefaultPath is ~/.actp/actp.yaml, or %APPDATA%\actp\actp.yaml on Windows.

func DeleteRemoteToken

func DeleteRemoteToken(c *Config, r *Remote)

DeleteRemoteToken removes a token actp stored for a remote. Tokens the user pointed at (token_env, a token_file of their own) are left alone.

func Dir

func Dir() string

Dir is the actp home folder.

func ExpandHome

func ExpandHome(p string) string

ExpandHome replaces a leading ~ with the user's home folder.

func HashToken

func HashToken(token string) string

HashToken is the form tokens are stored in.

func NewToken

func NewToken() (token, hash string, err error)

NewToken returns a fresh token and its stored hash.

func ParseByteSize

func ParseByteSize(s string) (int64, error)

ParseByteSize reads sizes such as "512", "8KB", "8MB" or "1GB" (powers of 1024).

func PresetID added in v0.1.1

func PresetID(preset string) string

PresetID is the agent id actp gives a preset it adds to the config.

func ReadServerList

func ReadServerList(path, key string) ([]yaml.MapSlice, error)

ReadServerList reads a list under server: (for example "agents") exactly as written, without defaults, keeping key order.

func RemoteToken

func RemoteToken(r *Remote) (string, error)

RemoteToken reads a remote's token from wherever it is kept.

func RemoteTokenPath

func RemoteTokenPath(c *Config, name string) string

RemoteTokenPath is where a saved remote's token lives when actp stores it (next to the remotes file, readable only by this user).

func SaveRemoteToken

func SaveRemoteToken(c *Config, r *Remote, token string) error

SaveRemoteToken stores a remote's token in the OS keychain, or, when there is none, in a file only this user can read. It updates r to point at it.

func SetPresetEnabled added in v0.1.1

func SetPresetEnabled(path, preset string, on bool) (bool, error)

SetPresetEnabled adds an agent for the preset to the server section of the config file, or removes the agents using it. Agents without a preset are left alone. It reports whether the file changed.

func SetServerList

func SetServerList(path, key string, value any) error

SetServerList replaces a list under server: in the config file and keeps the rest of the file, comments included, as it was. If the result does not load, the file is put back and the error returned.

func WriteRemotesFile

func WriteRemotesFile(path string, rf *RemotesFile) error

WriteRemotesFile replaces a remotes file, readable only by the current user.

func WriteTokensFile

func WriteTokensFile(path string, tf *TokensFile) error

WriteTokensFile replaces a tokens file, readable only by the current user.

Types

type Agent

type Agent struct {
	ID            string            `yaml:"id"`
	Name          string            `yaml:"name"`
	Description   string            `yaml:"description"`
	Preset        string            `yaml:"preset"`
	Command       string            `yaml:"command"`
	Args          []string          `yaml:"args"`
	Env           map[string]string `yaml:"env"`
	EnvRemove     []string          `yaml:"env_remove"`
	Permissions   string            `yaml:"permissions"`
	MaxLinks      int               `yaml:"max_links"`
	OnClientExit  string            `yaml:"on_client_exit"`
	MaxUnattended Duration          `yaml:"max_unattended"`
	// KeepSessionMeta lists top-level _meta keys kept in session requests; the
	// rest of _meta is dropped (design 3.3).
	KeepSessionMeta []string `yaml:"keep_session_meta,omitempty"`
	// AllowedModes lists the session modes a client may switch to; empty means
	// the modes that keep permission prompts (design 3.3).
	AllowedModes []string `yaml:"allowed_modes,omitempty"`
}

type Audit

type Audit struct {
	LogPrompts bool `yaml:"log_prompts"`
}

type ByteSize

type ByteSize int64

ByteSize is a size written as "8MB", "1GB" or a plain number of bytes.

func (ByteSize) MarshalYAML

func (b ByteSize) MarshalYAML() (any, error)

func (*ByteSize) UnmarshalYAML

func (b *ByteSize) UnmarshalYAML(unmarshal func(any) error) error

type Config

type Config struct {
	Version int      `yaml:"version"`
	Server  *Server  `yaml:"server"`
	Remotes []Remote `yaml:"remotes"`
	// RemotesFile holds remotes saved by `actp remote`, apart from this hand-edited file.
	RemotesFile string    `yaml:"remotes_file"`
	Dashboard   Dashboard `yaml:"dashboard"`
	// contains filtered or unexported fields
}

func Load

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

Load reads, defaults and validates a config file. A missing file at the default path is an empty config, not an error.

func LoadOrEmpty

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

LoadOrEmpty is Load, except that a missing file is an empty config even when the path was given. For tools that create the file, like the dashboard.

func Parse

func Parse(data []byte) (*Config, error)

Parse decodes and defaults a config without touching the file system.

func (*Config) Path

func (c *Config) Path() string

Path is the file the config was loaded from ("" when built in code).

func (*Config) Remote

func (c *Config) Remote(name string) *Remote

Remote returns the saved remote with this name, or nil.

func (*Config) Validate

func (c *Config) Validate() error

Validate checks references and enum values.

type Dashboard added in v0.1.1

type Dashboard struct {
	// Terminal adds a shell in the browser. Off by default: whoever opens the
	// dashboard gets a shell as this user.
	Terminal bool `yaml:"terminal"`
}

Dashboard holds settings of the local dashboard.

type Duration

type Duration time.Duration

Duration is a time.Duration written as "10m", "24h" or "90s".

func (Duration) D

func (d Duration) D() time.Duration

func (Duration) MarshalYAML

func (d Duration) MarshalYAML() (any, error)

func (*Duration) UnmarshalYAML

func (d *Duration) UnmarshalYAML(unmarshal func(any) error) error

type Preset

type Preset struct {
	Name    string
	Command string
	Args    []string
}

Preset is a known ACP agent launch. See docs/agents.md.

type Remote

type Remote struct {
	Name      string `yaml:"name"`
	URL       string `yaml:"url"`
	TokenEnv  string `yaml:"token_env"`
	TokenFile string `yaml:"token_file"`
	// TokenKeychain means the token is in the OS keychain (service "actp", account "remote:<name>").
	TokenKeychain bool `yaml:"token_keychain,omitempty"`
}

type RemotesFile

type RemotesFile struct {
	Remotes []Remote `yaml:"remotes"`
}

RemotesFile is the CLI-managed list of saved remotes.

func ReadRemotesFile

func ReadRemotesFile(path string) (*RemotesFile, error)

ReadRemotesFile reads a remotes file. A missing file is empty.

type Server

type Server struct {
	Name           string      `yaml:"name"`
	Listen         string      `yaml:"listen"`
	TLSCert        string      `yaml:"tls_cert"`
	TLSKey         string      `yaml:"tls_key"`
	InsecureListen bool        `yaml:"insecure_listen"`
	IdleClose      Duration    `yaml:"idle_close"`
	PromptTimeout  Duration    `yaml:"prompt_timeout"`
	SpoolLimit     ByteSize    `yaml:"spool_limit"`
	LogDir         string      `yaml:"log_dir"`
	StateDir       string      `yaml:"state_dir"`
	ShellEnv       *bool       `yaml:"shell_env"`
	Audit          Audit       `yaml:"audit"`
	Tunnel         Tunnel      `yaml:"tunnel"`
	Workspaces     []Workspace `yaml:"workspaces"`
	Agents         []Agent     `yaml:"agents"`
	Tokens         []Token     `yaml:"tokens"`
	TokensFile     string      `yaml:"tokens_file"`
}

func (*Server) Agent

func (s *Server) Agent(id string) *Agent

Agent returns the agent with this id, or nil.

func (*Server) FindToken

func (s *Server) FindToken(presented string) *Token

FindToken returns the token entry matching a presented token, or nil.

func (*Server) Workspace

func (s *Server) Workspace(name string) *Workspace

Workspace returns the workspace with this name, or nil.

type Token

type Token struct {
	Name             string            `yaml:"name"`
	Hash             string            `yaml:"hash"`
	Agents           []string          `yaml:"agents"`
	Workspaces       []string          `yaml:"workspaces"`
	DefaultWorkspace string            `yaml:"default_workspace"`
	CwdFallback      bool              `yaml:"cwd_fallback"`
	MCPServers       string            `yaml:"mcp_servers"`
	Permissions      string            `yaml:"permissions"`
	MaxLinks         int               `yaml:"max_links"`
	Map              map[string]string `yaml:"map"`
}

func (*Token) AllowedWorkspaces

func (t *Token) AllowedWorkspaces(s *Server) []string

AllowedWorkspaces lists the workspace names the token may use.

func (*Token) AllowsAgent

func (t *Token) AllowsAgent(id string) bool

AllowsAgent reports whether the token may use the agent.

func (*Token) EffectivePermissions

func (t *Token) EffectivePermissions(a *Agent) string

EffectivePermissions is the token override, else the agent setting.

type TokensFile

type TokensFile struct {
	Tokens []Token `yaml:"tokens"`
}

TokensFile is the CLI-managed list of tokens, kept apart from the hand-edited config.

func ReadTokensFile

func ReadTokensFile(path string) (*TokensFile, error)

ReadTokensFile reads a tokens file. A missing file is empty.

type Tunnel

type Tunnel struct {
	Provider string     `yaml:"provider"`
	Mode     TunnelMode `yaml:"mode"`
	TokenEnv string     `yaml:"token_env"`
}

type TunnelMode

type TunnelMode string

TunnelMode accepts `off` even when a YAML parser reads it as a boolean.

func (*TunnelMode) UnmarshalYAML

func (m *TunnelMode) UnmarshalYAML(unmarshal func(any) error) error

type Workspace

type Workspace struct {
	Name string `yaml:"name" json:"name"`
	Path string `yaml:"path" json:"path"`
}

Jump to

Keyboard shortcuts

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