GUI-configurable agent settings + hide paused agents

This commit is contained in:
2026-04-13 01:48:56 +00:00
parent 1dcfc9f46e
commit b299ea701a
4 changed files with 237 additions and 164 deletions
+20 -1
View File
@@ -80,12 +80,14 @@ class AgentCreate(BaseModel):
name: str
description: str = ""
schedule: str = "manual"
config: dict = {}
class AgentUpdate(BaseModel):
name: Optional[str] = None
description: Optional[str] = None
schedule: Optional[str] = None
status: Optional[str] = None
config: Optional[dict] = None
class RunCreate(BaseModel):
status: str = "running"
@@ -108,6 +110,15 @@ def health():
return {"status": "ok", "service": "agent-command-center"}
@app.get("/api/agents/{agent_id}/config")
def get_agent_config(agent_id: str, db: Session = Depends(get_db)):
"""Internal endpoint for agents to fetch their config. No auth required."""
agent = db.query(Agent).filter(Agent.id == agent_id).first()
if not agent:
raise HTTPException(status_code=404, detail="Agent not found")
return agent.config or {}
@app.get("/api/agents")
def list_agents(user: str = Depends(require_auth), db: Session = Depends(get_db)):
agents = db.query(Agent).all()
@@ -127,6 +138,7 @@ def list_agents(user: str = Depends(require_auth), db: Session = Depends(get_db)
"description": a.description,
"schedule": a.schedule,
"status": a.status,
"config": a.config or {},
"created_at": a.created_at.isoformat() if a.created_at else None,
"last_run": {
"status": last_run.status,
@@ -149,6 +161,7 @@ def create_agent(agent: AgentCreate, db: Session = Depends(get_db)):
name=agent.name,
description=agent.description,
schedule=agent.schedule,
config=agent.config,
)
db.add(new_agent)
db.commit()
@@ -167,6 +180,7 @@ def get_agent(agent_id: str, user: str = Depends(require_auth), db: Session = De
"description": agent.description,
"schedule": agent.schedule,
"status": agent.status,
"config": agent.config or {},
"created_at": agent.created_at.isoformat() if agent.created_at else None,
"runs": [{
"id": r.id,
@@ -185,7 +199,12 @@ def update_agent(agent_id: str, update: AgentUpdate, db: Session = Depends(get_d
agent = db.query(Agent).filter(Agent.id == agent_id).first()
if not agent:
raise HTTPException(status_code=404, detail="Agent not found")
for field, value in update.model_dump(exclude_none=True).items():
updates = update.model_dump(exclude_none=True)
if "config" in updates:
current_config = agent.config or {}
current_config.update(updates.pop("config"))
agent.config = current_config
for field, value in updates.items():
setattr(agent, field, value)
db.commit()
return {"id": agent.id, "status": "updated"}