| user | 5a7d60d | 2025-07-27 21:22:04 +0400 | [diff] [blame] | 1 | package commands |
| 2 | |
| 3 | import ( |
| 4 | "fmt" |
| 5 | "strings" |
| 6 | |
| 7 | "github.com/spf13/cobra" |
| 8 | ) |
| 9 | |
| 10 | var listAgentsCmd = &cobra.Command{ |
| 11 | Use: "list-agents", |
| 12 | Short: "List all configured agents", |
| 13 | Long: `List all configured agents with their settings and status. |
| 14 | |
| 15 | Examples: |
| 16 | staff list-agents`, |
| 17 | RunE: runListAgents, |
| 18 | } |
| 19 | |
| 20 | func runListAgents(cmd *cobra.Command, args []string) error { |
| 21 | if len(cfg.Agents) == 0 { |
| 22 | fmt.Println("No agents configured") |
| 23 | return nil |
| 24 | } |
| 25 | |
| 26 | fmt.Printf("Found %d configured agents:\n\n", len(cfg.Agents)) |
| 27 | |
| 28 | // Display agents in table format |
| 29 | fmt.Printf("%-20s %-15s %-12s %-10s %-30s\n", "Name", "Model", "Temperature", "Status", "Role/Description") |
| 30 | fmt.Printf("%s\n", strings.Repeat("-", 90)) |
| 31 | |
| 32 | for _, agent := range cfg.Agents { |
| 33 | status := "stopped" |
| 34 | if agentManager.IsAgentRunning(agent.Name) { |
| 35 | status = "running" |
| 36 | } |
| 37 | |
| 38 | role := agent.Role |
| 39 | if role == "" { |
| 40 | role = "general" |
| 41 | } |
| 42 | if len(role) > 27 { |
| 43 | role = role[:27] + "..." |
| 44 | } |
| 45 | |
| 46 | temp := 0.7 |
| 47 | if agent.Temperature != nil { |
| 48 | temp = *agent.Temperature |
| 49 | } |
| 50 | |
| iomodo | 50598c6 | 2025-07-27 22:06:32 +0400 | [diff] [blame] | 51 | fmt.Printf("%-20s %-15s %-12.1f %-10s %-30s\n", |
| 52 | agent.Name, |
| 53 | agent.Model, |
| 54 | temp, |
| user | 5a7d60d | 2025-07-27 21:22:04 +0400 | [diff] [blame] | 55 | status, |
| 56 | role) |
| 57 | } |
| 58 | |
| 59 | fmt.Printf("\nUse 'staff start-agent <agent-name>' to start an agent\n") |
| 60 | fmt.Printf("Use 'staff stop-agent <agent-name>' to stop a running agent\n") |
| 61 | |
| 62 | return nil |
| iomodo | 50598c6 | 2025-07-27 22:06:32 +0400 | [diff] [blame] | 63 | } |