| 249 | ) |
| 250 | |
| 251 | |
| 252 | def _api_update_roles(_query_params: Dict[str, Any], body: Dict[str, Any]) -> Dict[str, Any]: |
| 253 | action = str(body.get("action") or "").strip().lower() |
| 254 | if action == "create": |
| 255 | return agents.create_role( |
| 256 | role_name=str(body.get("role_name") or "").strip(), |
| 257 | description=str(body.get("description") or "").strip(), |
| 258 | feishu_chat_id=str(body.get("feishu_chat_id") or "").strip(), |
| 259 | ) |
| 260 | if action == "switch": |
| 261 | return agents.switch_role(str(body.get("role_name") or "").strip()) |
| 262 | if action == "delete": |
| 263 | return agents.delete_role(str(body.get("role_name") or "").strip()) |
| 264 | raise ValueError("action must be create, switch, or delete") |
| 265 | |
| 266 | |