Documentation
¶
Index ¶
- Constants
- Variables
- func Compile(opts CompileOptions) error
- func FilesToSecretData(files []ManagedFile) map[string][]byte
- func MarshalYAML(settings *SessionSettings) ([]byte, error)
- func Setup(opts SetupOptions) error
- type ClaudeConfig
- type CompileOptions
- type GithubConfig
- type ManagedFile
- type OtelCollectorConfig
- type RepositoryConfig
- type SessionMeta
- type SessionSettings
- type SetupOptions
- type SlackParams
- type StartupConfig
Constants ¶
const FileTypeClaudeCredentials = "claude_credentials"
FileTypeClaudeCredentials is the type name for ~/.claude/.credentials.json (Claude Code credentials).
const FileTypeCodexAuth = "codex_auth"
FileTypeCodexAuth is the type name for ~/.codex/auth.json (Codex CLI credentials).
Variables ¶
var ManagedFileTypeOrder = []string{ FileTypeCodexAuth, FileTypeClaudeCredentials, }
ManagedFileTypeOrder defines the canonical ordering of file types used when serialising ManagedFile slices to/from Kubernetes Secret data.
var ManagedFileTypes = map[string]string{ FileTypeCodexAuth: "/home/agentapi/.codex/auth.json", FileTypeClaudeCredentials: "/home/agentapi/.claude/.credentials.json", }
ManagedFileTypes maps a file type name to its absolute path inside the agent container. This is the single source of truth shared by the provisioner (runFilesSync) and the credentials controller (PUT /credentials/{name}).
Functions ¶
func Compile ¶
func Compile(opts CompileOptions) error
Compile reads the settings YAML and generates all output files.
func FilesToSecretData ¶ added in v1.363.0
func FilesToSecretData(files []ManagedFile) map[string][]byte
FilesToSecretData converts a slice of ManagedFile into a flat map suitable for storing in a Kubernetes Secret. The format is index-based:
"0.path" → files[0].Path "0.content" → files[0].Content "1.path" → files[1].Path …
func MarshalYAML ¶
func MarshalYAML(settings *SessionSettings) ([]byte, error)
MarshalYAML marshals SessionSettings to YAML bytes.
func Setup ¶ added in v1.238.0
func Setup(opts SetupOptions) error
Setup runs the full init-container setup sequence for a session Pod:
- write-pem : writes GITHUB_APP_PEM env var to a file on disk
- clone-repo : clones the repository (if session.repository is set)
- compile : generates all Claude config files from settings.yaml
- sync-extra : copies credentials, notification subscriptions
Types ¶
type ClaudeConfig ¶
type ClaudeConfig struct {
ClaudeJSON map[string]interface{} `yaml:"claude_json,omitempty" json:"claude_json,omitempty"`
SettingsJSON map[string]interface{} `yaml:"settings_json,omitempty" json:"settings_json,omitempty"`
MCPServers map[string]interface{} `yaml:"mcp_servers,omitempty" json:"mcp_servers,omitempty"`
}
ClaudeConfig holds Claude-related configuration data.
type CompileOptions ¶
type CompileOptions struct {
InputPath string // Path to settings YAML (default: /session-settings/settings.yaml)
OutputDir string // Base output directory (default: /home/agentapi)
EnvFilePath string // Path for env file output (default: /session-settings/env)
StartupPath string // Path for startup script (default: /session-settings/startup.sh)
}
CompileOptions configures the compile-settings behavior.
func DefaultCompileOptions ¶
func DefaultCompileOptions() CompileOptions
DefaultCompileOptions returns the default compile options.
type GithubConfig ¶
type GithubConfig struct {
Token string `yaml:"token,omitempty" json:"token,omitempty"`
SecretName string `yaml:"secret_name,omitempty" json:"secret_name,omitempty"`
ConfigSecretName string `yaml:"config_secret_name,omitempty" json:"config_secret_name,omitempty"`
}
GithubConfig holds GitHub authentication configuration reference info.
type ManagedFile ¶ added in v1.363.0
type ManagedFile struct {
Path string `yaml:"path" json:"path"`
Content string `yaml:"content" json:"content"`
}
ManagedFile represents a file path and its contents, used to persist arbitrary files across sessions via the agentapi-agent-files-{userID} Kubernetes Secret.
func SecretDataToFiles ¶ added in v1.363.0
func SecretDataToFiles(data map[string][]byte) []ManagedFile
SecretDataToFiles reconstructs a slice of ManagedFile from the flat index-based map produced by FilesToSecretData. Entries that do not match the expected format are silently skipped. The result is ordered by ascending index so that the output is deterministic regardless of Go's map iteration order.
type OtelCollectorConfig ¶ added in v1.335.0
type OtelCollectorConfig struct {
Enabled bool `yaml:"enabled" json:"enabled"`
ScrapeInterval string `yaml:"scrape_interval" json:"scrape_interval"`
ClaudeCodePort int `yaml:"claude_code_port" json:"claude_code_port"`
ExporterPort int `yaml:"exporter_port" json:"exporter_port"`
// Label values resolved at session creation time (not startup time)
SessionID string `yaml:"session_id" json:"session_id"`
UserID string `yaml:"user_id" json:"user_id"`
TeamID string `yaml:"team_id" json:"team_id"`
ScheduleID string `yaml:"schedule_id" json:"schedule_id"`
WebhookID string `yaml:"webhook_id" json:"webhook_id"`
AgentType string `yaml:"agent_type" json:"agent_type"`
}
OtelCollectorConfig holds OpenTelemetry Collector configuration for in-process mode. When set, the provisioner will launch otelcol as a subprocess after user context is established, ensuring metrics labels (user_id, session_id, etc.) are correct even when using the stock inventory feature.
type RepositoryConfig ¶
type RepositoryConfig struct {
FullName string `yaml:"fullname" json:"fullname"`
CloneDir string `yaml:"clone_dir" json:"clone_dir"`
}
RepositoryConfig holds repository information.
type SessionMeta ¶
type SessionMeta struct {
ID string `yaml:"id" json:"id"`
UserID string `yaml:"user_id" json:"user_id"`
Scope string `yaml:"scope" json:"scope"`
TeamID string `yaml:"team_id,omitempty" json:"team_id,omitempty"`
AgentType string `yaml:"agent_type,omitempty" json:"agent_type,omitempty"`
Oneshot bool `yaml:"oneshot,omitempty" json:"oneshot,omitempty"`
Teams []string `yaml:"teams,omitempty" json:"teams,omitempty"`
MemoryKey map[string]string `yaml:"memory_key,omitempty" json:"memory_key,omitempty"`
}
SessionMeta contains session identification metadata.
type SessionSettings ¶
type SessionSettings struct {
Session SessionMeta `yaml:"session" json:"session"`
Env map[string]string `yaml:"env,omitempty" json:"env,omitempty"`
Claude ClaudeConfig `yaml:"claude,omitempty" json:"claude,omitempty"`
Repository *RepositoryConfig `yaml:"repository,omitempty" json:"repository,omitempty"`
InitialMessage string `yaml:"initial_message,omitempty" json:"initial_message,omitempty"`
WebhookPayload string `yaml:"webhook_payload,omitempty" json:"webhook_payload,omitempty"`
Startup StartupConfig `yaml:"startup,omitempty" json:"startup,omitempty"`
Github *GithubConfig `yaml:"github,omitempty" json:"github,omitempty"`
SlackParams *SlackParams `yaml:"slack_params,omitempty" json:"slack_params,omitempty"`
OtelCollector *OtelCollectorConfig `yaml:"otel_collector,omitempty" json:"otel_collector,omitempty"`
// Files holds the managed files to be restored at session startup.
// They are read from the agentapi-agent-files-{userID} Secret at session creation
// time and written to their respective paths by the provisioner.
// The runFilesSync goroutine watches those paths and syncs changes back to the Secret.
Files []ManagedFile `yaml:"files,omitempty" json:"files,omitempty"`
// Credentials is deprecated: use Files instead.
// Kept for backward compatibility with sessions provisioned before the Files field
// was introduced. The provisioner falls back to this field when Files is empty.
Credentials string `yaml:"credentials,omitempty" json:"credentials,omitempty"`
}
SessionSettings is the top-level unified settings YAML structure. It consolidates all configuration needed for a session Pod.
func LoadSettings ¶
func LoadSettings(path string) (*SessionSettings, error)
LoadSettings reads and parses a SessionSettings from a YAML file.
func LoadSettingsFromBytes ¶ added in v1.324.0
func LoadSettingsFromBytes(data []byte) (*SessionSettings, error)
LoadSettingsFromBytes parses a SessionSettings from YAML bytes.
type SetupOptions ¶ added in v1.238.0
type SetupOptions struct {
// InputPath is the path to the session settings YAML file.
// Defaults to /session-settings/settings.yaml.
InputPath string
// CompileOptions controls file generation (Compile step).
CompileOptions CompileOptions
// CredentialsFile is the path to the credentials.json mounted from Secret (optional).
CredentialsFile string
// NotificationSubscriptions is the source directory for notification subscription files (optional).
NotificationSubscriptions string
// NotificationsDir is the destination directory for notification files (optional).
NotificationsDir string
// RegisterMarketplaces registers cloned marketplace repos via claude CLI.
RegisterMarketplaces bool
// SettingsFile is the path to the user settings.json (from claude-config-user ConfigMap).
// Contains marketplace and plugin configuration. Optional.
SettingsFile string
// PEMOutputPath is where GITHUB_APP_PEM content is written.
// Defaults to /tmp/github-app/app.pem.
PEMOutputPath string
}
SetupOptions configures the Setup behavior.
func DefaultSetupOptions ¶ added in v1.238.0
func DefaultSetupOptions() SetupOptions
DefaultSetupOptions returns the default Setup options.
type SlackParams ¶ added in v1.331.0
type SlackParams struct {
Channel string `yaml:"channel" json:"channel"`
ThreadTS string `yaml:"thread_ts,omitempty" json:"thread_ts,omitempty"`
BotToken string `yaml:"bot_token" json:"bot_token"`
}
SlackParams holds Slack integration parameters for the provisioner subprocess. When set, the provisioner will launch claude-posts as a subprocess to forward agent output to the specified Slack channel/thread.
type StartupConfig ¶
type StartupConfig struct {
Command []string `yaml:"command,omitempty" json:"command,omitempty"`
Args []string `yaml:"args,omitempty" json:"args,omitempty"`
}
StartupConfig holds the startup command configuration.