Documentation
¶
Overview ¶
Package config loads and validates actp.yaml.
Index ¶
- Constants
- Variables
- func ApplyTokenDefaults(t *Token)
- func DefaultPath() string
- func DeleteRemoteToken(c *Config, r *Remote)
- func Dir() string
- func ExpandHome(p string) string
- func HashToken(token string) string
- func NewToken() (token, hash string, err error)
- func ParseByteSize(s string) (int64, error)
- func ReadServerList(path, key string) ([]yaml.MapSlice, error)
- func RemoteToken(r *Remote) (string, error)
- func RemoteTokenPath(c *Config, name string) string
- func SaveRemoteToken(c *Config, r *Remote, token string) error
- func SetServerList(path, key string, value any) error
- func WriteRemotesFile(path string, rf *RemotesFile) error
- func WriteTokensFile(path string, tf *TokensFile) error
- type Agent
- type Audit
- type ByteSize
- type Config
- type Duration
- type Preset
- type Remote
- type RemotesFile
- type Server
- type Token
- type TokensFile
- type Tunnel
- type TunnelMode
- type Workspace
Constants ¶
const CurrentVersion = 1
CurrentVersion is the config file format version this build writes and reads.
const TokenPrefix = "actp_"
TokenPrefix marks actp tokens so they are easy to spot in logs and secret scanners.
Variables ¶
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 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 ¶
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 ExpandHome ¶
ExpandHome replaces a leading ~ with the user's home folder.
func ParseByteSize ¶
ParseByteSize reads sizes such as "512", "8KB", "8MB" or "1GB" (powers of 1024).
func ReadServerList ¶
ReadServerList reads a list under server: (for example "agents") exactly as written, without defaults, keeping key order.
func RemoteToken ¶
RemoteToken reads a remote's token from wherever it is kept.
func RemoteTokenPath ¶
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 ¶
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 SetServerList ¶
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"`
}
type ByteSize ¶
type ByteSize int64
ByteSize is a size written as "8MB", "1GB" or a plain number of bytes.
func (ByteSize) MarshalYAML ¶
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"`
// contains filtered or unexported fields
}
func Load ¶
Load reads, defaults and validates a config file. A missing file at the default path is an empty config, not an error.
func LoadOrEmpty ¶
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.
type Duration ¶
Duration is a time.Duration written as "10m", "24h" or "90s".
func (Duration) MarshalYAML ¶
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"`
}
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 ¶
AllowedWorkspaces lists the workspace names the token may use.
func (*Token) AllowsAgent ¶
AllowsAgent reports whether the token may use the agent.
func (*Token) EffectivePermissions ¶
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