feat(agentci): package dispatch system for multi-agent deployment
Config-driven agent targets replace hardcoded map so new agents
can be added via CLI instead of recompiling. Includes setup script
for bootstrapping agent machines and CLI commands for management.
- Add pkg/agentci with config types and CRUD (LoadAgents, SaveAgent, etc.)
- Add CLI: core ai agent {add,list,status,logs,setup,remove}
- Add scripts/agent-setup.sh (SSH bootstrap: dirs, cron, prereq check)
- Headless loads agents from ~/.core/config.yaml
- Dispatch ticket includes forgejo_user for dynamic clone URLs
- agent-runner.sh reads username from ticket JSON, not hardcoded
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-09 10:36:23 +00:00
|
|
|
// Package agentci provides configuration and management for AgentCI dispatch targets.
|
|
|
|
|
package agentci
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
|
|
"github.com/host-uk/core/pkg/config"
|
|
|
|
|
"github.com/host-uk/core/pkg/jobrunner/handlers"
|
2026-02-09 11:15:00 +00:00
|
|
|
"github.com/host-uk/core/pkg/log"
|
feat(agentci): package dispatch system for multi-agent deployment
Config-driven agent targets replace hardcoded map so new agents
can be added via CLI instead of recompiling. Includes setup script
for bootstrapping agent machines and CLI commands for management.
- Add pkg/agentci with config types and CRUD (LoadAgents, SaveAgent, etc.)
- Add CLI: core ai agent {add,list,status,logs,setup,remove}
- Add scripts/agent-setup.sh (SSH bootstrap: dirs, cron, prereq check)
- Headless loads agents from ~/.core/config.yaml
- Dispatch ticket includes forgejo_user for dynamic clone URLs
- agent-runner.sh reads username from ticket JSON, not hardcoded
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-09 10:36:23 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// AgentConfig represents a single agent machine in the config file.
|
|
|
|
|
type AgentConfig struct {
|
2026-02-09 10:58:46 +00:00
|
|
|
Host string `yaml:"host" mapstructure:"host"`
|
|
|
|
|
QueueDir string `yaml:"queue_dir" mapstructure:"queue_dir"`
|
feat(agentci): package dispatch system for multi-agent deployment
Config-driven agent targets replace hardcoded map so new agents
can be added via CLI instead of recompiling. Includes setup script
for bootstrapping agent machines and CLI commands for management.
- Add pkg/agentci with config types and CRUD (LoadAgents, SaveAgent, etc.)
- Add CLI: core ai agent {add,list,status,logs,setup,remove}
- Add scripts/agent-setup.sh (SSH bootstrap: dirs, cron, prereq check)
- Headless loads agents from ~/.core/config.yaml
- Dispatch ticket includes forgejo_user for dynamic clone URLs
- agent-runner.sh reads username from ticket JSON, not hardcoded
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-09 10:36:23 +00:00
|
|
|
ForgejoUser string `yaml:"forgejo_user" mapstructure:"forgejo_user"`
|
2026-02-09 10:58:46 +00:00
|
|
|
Model string `yaml:"model" mapstructure:"model"` // claude model: sonnet, haiku, opus (default: sonnet)
|
|
|
|
|
Runner string `yaml:"runner" mapstructure:"runner"` // runner binary: claude, codex (default: claude)
|
|
|
|
|
Active bool `yaml:"active" mapstructure:"active"`
|
feat(agentci): package dispatch system for multi-agent deployment
Config-driven agent targets replace hardcoded map so new agents
can be added via CLI instead of recompiling. Includes setup script
for bootstrapping agent machines and CLI commands for management.
- Add pkg/agentci with config types and CRUD (LoadAgents, SaveAgent, etc.)
- Add CLI: core ai agent {add,list,status,logs,setup,remove}
- Add scripts/agent-setup.sh (SSH bootstrap: dirs, cron, prereq check)
- Headless loads agents from ~/.core/config.yaml
- Dispatch ticket includes forgejo_user for dynamic clone URLs
- agent-runner.sh reads username from ticket JSON, not hardcoded
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-09 10:36:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// LoadAgents reads agent targets from config and returns a map suitable for the dispatch handler.
|
|
|
|
|
// Returns an empty map (not an error) if no agents are configured.
|
|
|
|
|
func LoadAgents(cfg *config.Config) (map[string]handlers.AgentTarget, error) {
|
|
|
|
|
var agents map[string]AgentConfig
|
|
|
|
|
if err := cfg.Get("agentci.agents", &agents); err != nil {
|
|
|
|
|
// No config is fine — just no agents.
|
|
|
|
|
return map[string]handlers.AgentTarget{}, nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
targets := make(map[string]handlers.AgentTarget)
|
|
|
|
|
for name, ac := range agents {
|
|
|
|
|
if !ac.Active {
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
if ac.Host == "" {
|
2026-02-09 11:15:00 +00:00
|
|
|
return nil, log.E("agentci.LoadAgents", fmt.Sprintf("agent %q: host is required", name), nil)
|
feat(agentci): package dispatch system for multi-agent deployment
Config-driven agent targets replace hardcoded map so new agents
can be added via CLI instead of recompiling. Includes setup script
for bootstrapping agent machines and CLI commands for management.
- Add pkg/agentci with config types and CRUD (LoadAgents, SaveAgent, etc.)
- Add CLI: core ai agent {add,list,status,logs,setup,remove}
- Add scripts/agent-setup.sh (SSH bootstrap: dirs, cron, prereq check)
- Headless loads agents from ~/.core/config.yaml
- Dispatch ticket includes forgejo_user for dynamic clone URLs
- agent-runner.sh reads username from ticket JSON, not hardcoded
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-09 10:36:23 +00:00
|
|
|
}
|
|
|
|
|
queueDir := ac.QueueDir
|
|
|
|
|
if queueDir == "" {
|
|
|
|
|
queueDir = "/home/claude/ai-work/queue"
|
|
|
|
|
}
|
2026-02-09 10:58:46 +00:00
|
|
|
model := ac.Model
|
|
|
|
|
if model == "" {
|
|
|
|
|
model = "sonnet"
|
|
|
|
|
}
|
|
|
|
|
runner := ac.Runner
|
|
|
|
|
if runner == "" {
|
|
|
|
|
runner = "claude"
|
|
|
|
|
}
|
feat(agentci): package dispatch system for multi-agent deployment
Config-driven agent targets replace hardcoded map so new agents
can be added via CLI instead of recompiling. Includes setup script
for bootstrapping agent machines and CLI commands for management.
- Add pkg/agentci with config types and CRUD (LoadAgents, SaveAgent, etc.)
- Add CLI: core ai agent {add,list,status,logs,setup,remove}
- Add scripts/agent-setup.sh (SSH bootstrap: dirs, cron, prereq check)
- Headless loads agents from ~/.core/config.yaml
- Dispatch ticket includes forgejo_user for dynamic clone URLs
- agent-runner.sh reads username from ticket JSON, not hardcoded
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-09 10:36:23 +00:00
|
|
|
targets[name] = handlers.AgentTarget{
|
|
|
|
|
Host: ac.Host,
|
|
|
|
|
QueueDir: queueDir,
|
2026-02-09 10:58:46 +00:00
|
|
|
Model: model,
|
|
|
|
|
Runner: runner,
|
feat(agentci): package dispatch system for multi-agent deployment
Config-driven agent targets replace hardcoded map so new agents
can be added via CLI instead of recompiling. Includes setup script
for bootstrapping agent machines and CLI commands for management.
- Add pkg/agentci with config types and CRUD (LoadAgents, SaveAgent, etc.)
- Add CLI: core ai agent {add,list,status,logs,setup,remove}
- Add scripts/agent-setup.sh (SSH bootstrap: dirs, cron, prereq check)
- Headless loads agents from ~/.core/config.yaml
- Dispatch ticket includes forgejo_user for dynamic clone URLs
- agent-runner.sh reads username from ticket JSON, not hardcoded
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-09 10:36:23 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return targets, nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// SaveAgent writes an agent config entry to the config file.
|
|
|
|
|
func SaveAgent(cfg *config.Config, name string, ac AgentConfig) error {
|
|
|
|
|
key := fmt.Sprintf("agentci.agents.%s", name)
|
2026-02-09 10:58:46 +00:00
|
|
|
data := map[string]any{
|
feat(agentci): package dispatch system for multi-agent deployment
Config-driven agent targets replace hardcoded map so new agents
can be added via CLI instead of recompiling. Includes setup script
for bootstrapping agent machines and CLI commands for management.
- Add pkg/agentci with config types and CRUD (LoadAgents, SaveAgent, etc.)
- Add CLI: core ai agent {add,list,status,logs,setup,remove}
- Add scripts/agent-setup.sh (SSH bootstrap: dirs, cron, prereq check)
- Headless loads agents from ~/.core/config.yaml
- Dispatch ticket includes forgejo_user for dynamic clone URLs
- agent-runner.sh reads username from ticket JSON, not hardcoded
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-09 10:36:23 +00:00
|
|
|
"host": ac.Host,
|
|
|
|
|
"queue_dir": ac.QueueDir,
|
|
|
|
|
"forgejo_user": ac.ForgejoUser,
|
|
|
|
|
"active": ac.Active,
|
2026-02-09 10:58:46 +00:00
|
|
|
}
|
|
|
|
|
if ac.Model != "" {
|
|
|
|
|
data["model"] = ac.Model
|
|
|
|
|
}
|
|
|
|
|
if ac.Runner != "" {
|
|
|
|
|
data["runner"] = ac.Runner
|
|
|
|
|
}
|
|
|
|
|
return cfg.Set(key, data)
|
feat(agentci): package dispatch system for multi-agent deployment
Config-driven agent targets replace hardcoded map so new agents
can be added via CLI instead of recompiling. Includes setup script
for bootstrapping agent machines and CLI commands for management.
- Add pkg/agentci with config types and CRUD (LoadAgents, SaveAgent, etc.)
- Add CLI: core ai agent {add,list,status,logs,setup,remove}
- Add scripts/agent-setup.sh (SSH bootstrap: dirs, cron, prereq check)
- Headless loads agents from ~/.core/config.yaml
- Dispatch ticket includes forgejo_user for dynamic clone URLs
- agent-runner.sh reads username from ticket JSON, not hardcoded
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-09 10:36:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// RemoveAgent removes an agent from the config file.
|
|
|
|
|
func RemoveAgent(cfg *config.Config, name string) error {
|
|
|
|
|
var agents map[string]AgentConfig
|
|
|
|
|
if err := cfg.Get("agentci.agents", &agents); err != nil {
|
2026-02-09 11:15:00 +00:00
|
|
|
return log.E("agentci.RemoveAgent", "no agents configured", err)
|
feat(agentci): package dispatch system for multi-agent deployment
Config-driven agent targets replace hardcoded map so new agents
can be added via CLI instead of recompiling. Includes setup script
for bootstrapping agent machines and CLI commands for management.
- Add pkg/agentci with config types and CRUD (LoadAgents, SaveAgent, etc.)
- Add CLI: core ai agent {add,list,status,logs,setup,remove}
- Add scripts/agent-setup.sh (SSH bootstrap: dirs, cron, prereq check)
- Headless loads agents from ~/.core/config.yaml
- Dispatch ticket includes forgejo_user for dynamic clone URLs
- agent-runner.sh reads username from ticket JSON, not hardcoded
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-09 10:36:23 +00:00
|
|
|
}
|
|
|
|
|
if _, ok := agents[name]; !ok {
|
2026-02-09 11:15:00 +00:00
|
|
|
return log.E("agentci.RemoveAgent", fmt.Sprintf("agent %q not found", name), nil)
|
feat(agentci): package dispatch system for multi-agent deployment
Config-driven agent targets replace hardcoded map so new agents
can be added via CLI instead of recompiling. Includes setup script
for bootstrapping agent machines and CLI commands for management.
- Add pkg/agentci with config types and CRUD (LoadAgents, SaveAgent, etc.)
- Add CLI: core ai agent {add,list,status,logs,setup,remove}
- Add scripts/agent-setup.sh (SSH bootstrap: dirs, cron, prereq check)
- Headless loads agents from ~/.core/config.yaml
- Dispatch ticket includes forgejo_user for dynamic clone URLs
- agent-runner.sh reads username from ticket JSON, not hardcoded
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-09 10:36:23 +00:00
|
|
|
}
|
|
|
|
|
delete(agents, name)
|
|
|
|
|
return cfg.Set("agentci.agents", agents)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ListAgents returns all configured agents (active and inactive).
|
|
|
|
|
func ListAgents(cfg *config.Config) (map[string]AgentConfig, error) {
|
|
|
|
|
var agents map[string]AgentConfig
|
|
|
|
|
if err := cfg.Get("agentci.agents", &agents); err != nil {
|
|
|
|
|
return map[string]AgentConfig{}, nil
|
|
|
|
|
}
|
|
|
|
|
return agents, nil
|
|
|
|
|
}
|