1313from vibepod .utils .console import console , error
1414
1515
16- def _running_map (containers : list [Any ]) -> dict [str , Any ]:
17- by_agent : dict [str , Any ] = {}
16+ def _configured_agent_rows () -> list [dict [str , str ]]:
17+ rows : list [dict [str , str ]] = []
18+ for agent in SUPPORTED_AGENTS :
19+ rows .append (
20+ {
21+ "short" : get_agent_shortcut (agent ) or "-" ,
22+ "agent" : agent ,
23+ "image" : DEFAULT_IMAGES [agent ],
24+ }
25+ )
26+ return rows
27+
28+
29+ def _running_rows (containers : list [Any ]) -> list [dict [str , str ]]:
30+ rows : list [dict [str , str ]] = []
1831 for container in containers :
19- agent = container .labels .get ("vibepod.agent" )
20- if agent and agent not in by_agent :
21- by_agent [agent ] = container
22- return by_agent
32+ labels = getattr (container , "labels" , {}) or {}
33+ agent = labels .get ("vibepod.agent" )
34+ status = getattr (container , "status" , "-" )
35+ if not agent or status != "running" :
36+ continue
37+ rows .append (
38+ {
39+ "agent" : agent ,
40+ "container" : getattr (container , "name" , "-" ),
41+ "context" : labels .get ("vibepod.workspace" , "-" ),
42+ }
43+ )
44+ return sorted (rows , key = lambda row : (row ["agent" ], row ["container" ]))
2345
2446
2547def list_agents (
@@ -38,36 +60,38 @@ def list_agents(
3860 raise typer .Exit (EXIT_DOCKER_NOT_RUNNING ) from exc
3961 containers = []
4062
41- mapped = _running_map (containers )
42- rows : list [dict [str , str ]] = []
43- for agent in SUPPORTED_AGENTS :
44- container = mapped .get (agent )
45- shortcut = get_agent_shortcut (agent ) or "-"
46- rows .append (
47- {
48- "short" : shortcut ,
49- "agent" : agent ,
50- "image" : DEFAULT_IMAGES [agent ],
51- "status" : container .status if container else "stopped" ,
52- "workspace" : container .labels .get ("vibepod.workspace" , "-" ) if container else "-" ,
53- }
54- )
55-
56- if running :
57- rows = [r for r in rows if r ["status" ] == "running" ]
63+ running_rows = _running_rows (containers )
64+ configured_rows = _configured_agent_rows ()
5865
5966 if as_json :
6067 import json
6168
62- print (json .dumps (rows , indent = 2 ))
69+ payload : dict [str , Any ] = {"running" : running_rows }
70+ if not running :
71+ payload ["agents" ] = configured_rows
72+ print (json .dumps (payload , indent = 2 ))
73+ return
74+
75+ running_table = Table (title = "Running Agents" , title_justify = "left" )
76+ running_table .add_column ("AGENT" , style = "cyan" )
77+ running_table .add_column ("CONTAINER" , style = "magenta" )
78+ running_table .add_column ("CONTEXT" )
79+
80+ if running_rows :
81+ for row in running_rows :
82+ running_table .add_row (row ["agent" ], row ["container" ], row ["context" ])
83+ console .print (running_table )
84+ else :
85+ console .print ("No running agents." )
86+
87+ if running :
6388 return
6489
65- table = Table (title = "VibePod Agents" )
66- table .add_column ("SHORT" , style = "green" )
67- table .add_column ("AGENT" , style = "cyan" )
68- table .add_column ("IMAGE" , style = "magenta" )
69- table .add_column ("STATUS" )
70- table .add_column ("WORKSPACE" )
71- for row in rows :
72- table .add_row (row ["short" ], row ["agent" ], row ["image" ], row ["status" ], row ["workspace" ])
73- console .print (table )
90+ console .print ()
91+ reference_table = Table (title = "Configured Agents" , title_justify = "left" )
92+ reference_table .add_column ("SHORT" , style = "green" )
93+ reference_table .add_column ("AGENT" , style = "cyan" )
94+ reference_table .add_column ("BASE IMAGE" , style = "magenta" )
95+ for row in configured_rows :
96+ reference_table .add_row (row ["short" ], row ["agent" ], row ["image" ])
97+ console .print (reference_table )
0 commit comments