diff --git a/routes/bot_manager.py b/routes/bot_manager.py index c069bca..786af64 100644 --- a/routes/bot_manager.py +++ b/routes/bot_manager.py @@ -373,6 +373,8 @@ class BotResponse(BaseModel): owner: Optional[dict] = None # {id, username} role: Optional[str] = None # 'viewer', 'editor', None for owner shared_at: Optional[str] = None + description: Optional[str] = None # 从 settings 中提取 + avatar_url: Optional[str] = None # 从 settings 中提取 created_at: str updated_at: str @@ -1180,7 +1182,7 @@ async def get_bots(authorization: Optional[str] = Header(None)): if admin_valid: # 管理员可以看到所有 Bot await cursor.execute(""" - SELECT b.id, b.name, b.bot_id, b.created_at, b.updated_at, + SELECT b.id, b.name, b.bot_id, b.created_at, b.updated_at, b.settings, u.id as owner_id, u.username as owner_username FROM agent_bots b LEFT JOIN agent_user u ON b.owner_id = u.id @@ -1195,8 +1197,10 @@ async def get_bots(authorization: Optional[str] = Header(None)): bot_id=row[2], is_owner=True, is_shared=False, - owner={"id": str(row[5]), "username": row[6]} if row[5] else None, + owner={"id": str(row[6]), "username": row[7]} if row[6] else None, role=None, + description=row[5].get('description') if row[5] else None, + avatar_url=row[5].get('avatar_url') if row[5] else None, created_at=datetime_to_str(row[3]), updated_at=datetime_to_str(row[4]) ) @@ -1205,7 +1209,7 @@ async def get_bots(authorization: Optional[str] = Header(None)): else: # 用户只能看到拥有的 Bot 和分享给自己的 Bot await cursor.execute(""" - SELECT b.id, b.name, b.bot_id, b.created_at, b.updated_at, + SELECT b.id, b.name, b.bot_id, b.created_at, b.updated_at, b.settings, u.id as owner_id, u.username as owner_username, s.role, s.shared_at FROM agent_bots b @@ -1221,11 +1225,13 @@ async def get_bots(authorization: Optional[str] = Header(None)): id=str(row[0]), name=row[1], bot_id=row[2], - is_owner=(str(row[5]) == user_id if row[5] else False), - is_shared=(str(row[5]) != user_id and row[7] is not None) if row[5] else False, - owner={"id": str(row[5]), "username": row[6]} if row[5] else None, - role=row[7] if row[7] else None, - shared_at=datetime_to_str(row[8]) if row[8] else None, + is_owner=(str(row[6]) == user_id if row[6] else False), + is_shared=(str(row[6]) != user_id and row[8] is not None) if row[6] else False, + owner={"id": str(row[6]), "username": row[7]} if row[6] else None, + role=row[8] if row[8] else None, + shared_at=datetime_to_str(row[9]) if row[9] else None, + description=row[5].get('description') if row[5] else None, + avatar_url=row[5].get('avatar_url') if row[5] else None, created_at=datetime_to_str(row[3]), updated_at=datetime_to_str(row[4]) )