refactor: unify agent startup with Manager pattern
- Create mayor.Manager for mayor lifecycle (Start/Stop/IsRunning/Status) - Create deacon.Manager for deacon lifecycle with respawn loop - Move session.Manager to polecat.SessionManager (clearer naming) - Add zombie session detection for mayor/deacon (kills tmux if Claude dead) - Remove duplicate session startup code from up.go, start.go, mayor.go - Rename sessMgr -> polecatMgr for consistency - Make witness/refinery SessionName() public for status display All agent types now follow the same Manager pattern: mgr := agent.NewManager(...) mgr.Start(...) mgr.Stop() mgr.IsRunning() mgr.Status() 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -58,8 +58,8 @@ func (m *Manager) stateFile() string {
|
||||
return filepath.Join(m.rig.Path, ".runtime", "refinery.json")
|
||||
}
|
||||
|
||||
// sessionName returns the tmux session name for this refinery.
|
||||
func (m *Manager) sessionName() string {
|
||||
// SessionName returns the tmux session name for this refinery.
|
||||
func (m *Manager) SessionName() string {
|
||||
return fmt.Sprintf("gt-%s-refinery", m.rig.Name)
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ func (m *Manager) Start(foreground bool) error {
|
||||
}
|
||||
|
||||
t := tmux.NewTmux()
|
||||
sessionID := m.sessionName()
|
||||
sessionID := m.SessionName()
|
||||
|
||||
if foreground {
|
||||
// In foreground mode, we're likely running inside the tmux session
|
||||
@@ -253,7 +253,7 @@ func (m *Manager) Stop() error {
|
||||
|
||||
// Check if tmux session exists
|
||||
t := tmux.NewTmux()
|
||||
sessionID := m.sessionName()
|
||||
sessionID := m.SessionName()
|
||||
sessionRunning, _ := t.HasSession(sessionID)
|
||||
|
||||
// If neither state nor session indicates running, it's not running
|
||||
|
||||
Reference in New Issue
Block a user