refactor: 拆分 agent 模块为 commands/agent/ 和 api/agent.py

This commit is contained in:
gitea committed 2026-04-06 00:14:16 +08:00
1 parent 3c4ad6256a
commit cd78261cae
7 files changed
+44 -12

No files matched your search

+12
View File
@@ -0,0 +1,12 @@
"""agent 子命令组"""
import typer
from ekb_cli.commands.agent.list import cmd_list
from ekb_cli.commands.agent.detail import cmd_detail
from ekb_cli.commands.agent.logs import cmd_logs
app = typer.Typer(help="智能审核 Agent 管理")
app.command("list")(cmd_list)
app.command("get")(cmd_detail)
app.command("logs")(cmd_logs)
+8
View File
@@ -0,0 +1,8 @@
"""ekb agent get <id>:查看 Agent 详情(待实现)"""
from rich import print as rprint
def cmd_detail(agent_id: str):
"""查看 Agent 详情"""
rprint(f"[yellow]待实现:agent get {agent_id}[/yellow]")
+40
View File
@@ -0,0 +1,40 @@
"""ekb agent list:列出所有智能审核 Agent"""
import typer
from rich.console import Console
from rich.table import Table
from rich import print as rprint
from ekb_cli.api import get_client
from ekb_cli.api.agent import list_agents
console = Console()
STATE_MAP = {0: "[green]启用[/green]", 1: "[red]禁用[/red]"}
def cmd_list():
"""列出所有智能审核 Agent"""
with get_client() as client:
resp = list_agents(client)
items = resp.get("data", {}).get("items") or []
if not items:
rprint("[yellow]暂无 Agent[/yellow]")
raise typer.Exit()
table = Table(title="智能审核 Agent 列表")
table.add_column("ID", style="dim")
table.add_column("名称")
table.add_column("模式")
table.add_column("状态")
table.add_column("更新时间")
for item in items:
table.add_row(
str(item.get("id", "")),
item.get("name", ""),
"自动" if item.get("mode") == 2 else str(item.get("mode", "")),
STATE_MAP.get(item.get("state"), str(item.get("state", ""))),
item.get("updateTime", ""),
)
console.print(table)
+8
View File
@@ -0,0 +1,8 @@
"""ekb agent logs <id>:查看 Agent 审核日志(待实现)"""
from rich import print as rprint
def cmd_logs(agent_id: str):
"""查看 Agent 审核日志"""
rprint(f"[yellow]待实现:agent logs {agent_id}[/yellow]")