commands.list_agents
List agents command for the Agent Runtimes CLI.
This module provides the list-agents command that queries running agents from an agent-runtimes server. It can be used directly by other libraries or through the CLI.
Usage as library: ```python from agent_runtimes.commands.list_agents import ( list_agents_from_server, OutputFormat, ListAgentsError, )
# Get agents as dict
result = list_agents_from_server(host="localhost", port=8000)
agents = result["agents"]
# Print formatted output
list_agents_from_server(host="localhost", port=8000, output=OutputFormat.table)
```
OutputFormat Objects
class OutputFormat(str, Enum)
Output format options.
ListAgentsError Objects
class ListAgentsError(Exception)
Error raised during list-agents command execution.
list_agents_from_server
def list_agents_from_server(
host: str = "127.0.0.1",
port: int = 8000,
output: Optional[OutputFormat] = None) -> dict[str, Any]
Query running agents from an agent-runtimes server.
This is the core logic of the list-agents command, usable by other libraries.
Arguments:
host- Server host to queryport- Server port to queryoutput- If provided, print formatted output (table or json). If None, just return the data without printing.
Returns:
Dictionary containing the agents response from the server.
Format-{"agents": [{"id": "...", "name": "...", "status": "..."}, ...]}
Raises:
ListAgentsError- If the server cannot be reached or returns an error