mirror of
https://github.com/eigent-ai/eigent.git
synced 2026-05-23 04:17:45 +00:00
# Conflicts: # .github/workflows/build.yml # backend/app/agent/agent_model.py # backend/app/agent/factory/browser.py # backend/app/agent/factory/developer.py # backend/app/agent/factory/document.py # backend/app/agent/factory/mcp.py # backend/app/model/chat.py # backend/app/router.py # backend/app/service/chat_service.py # src/components/ChatBox/BottomBox/index.tsx # src/components/ChatBox/index.tsx # src/pages/Agents/Models.tsx # src/pages/Agents/index.tsx # src/store/chatStore.ts
122 lines
3.9 KiB
Python
122 lines
3.9 KiB
Python
# ========= Copyright 2025-2026 @ Eigent.ai All Rights Reserved. =========
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
# ========= Copyright 2025-2026 @ Eigent.ai All Rights Reserved. =========
|
|
"""
|
|
Centralized router registration for the Eigent API.
|
|
All routers are explicitly registered here
|
|
for better visibility and maintainability.
|
|
"""
|
|
|
|
import logging
|
|
|
|
from fastapi import FastAPI
|
|
|
|
from app.controller import (
|
|
chat_controller,
|
|
file_controller,
|
|
health_controller,
|
|
mcp_controller,
|
|
message_controller,
|
|
model_controller,
|
|
remote_sub_agent_controller,
|
|
skill_controller,
|
|
task_controller,
|
|
tool_controller,
|
|
)
|
|
|
|
logger = logging.getLogger("router")
|
|
|
|
|
|
def register_routers(app: FastAPI, prefix: str = "") -> None:
|
|
"""
|
|
Register all API routers with their respective prefixes and tags.
|
|
|
|
This replaces the auto-discovery mechanism for better:
|
|
- Visibility: See all routes in one place
|
|
- Maintainability: Easy to add/remove routes
|
|
- Debugging: Clear registration order and configuration
|
|
|
|
Args:
|
|
app: FastAPI application instance
|
|
prefix: Optional global prefix for all routes (e.g., "/api")
|
|
"""
|
|
routers_config = [
|
|
{
|
|
"router": health_controller.router,
|
|
"tags": ["Health"],
|
|
"description": "Health check endpoint for service readiness",
|
|
},
|
|
{
|
|
"router": file_controller.router,
|
|
"tags": ["Files"],
|
|
"description": "File upload for Web/Channel clients",
|
|
},
|
|
{
|
|
"router": mcp_controller.router,
|
|
"tags": ["MCP"],
|
|
"description": "MCP config (list, install, remove, update)",
|
|
},
|
|
{
|
|
"router": skill_controller.router,
|
|
"tags": ["Skills"],
|
|
"description": "Skills scan, write, read, delete",
|
|
},
|
|
{
|
|
"router": chat_controller.router,
|
|
"tags": ["chat"],
|
|
"description": "Chat session management, improvements, and human interactions",
|
|
},
|
|
{
|
|
"router": message_controller.router,
|
|
"tags": ["Message Router"],
|
|
"description": "Phase 2 Message Router - /messages endpoint (prefix-aware)",
|
|
},
|
|
{
|
|
"router": model_controller.router,
|
|
"tags": ["model"],
|
|
"description": "Model validation and configuration",
|
|
},
|
|
{
|
|
"router": remote_sub_agent_controller.router,
|
|
"tags": ["remote-sub-agent"],
|
|
"description": "Remote sub-agent validation",
|
|
},
|
|
{
|
|
"router": task_controller.router,
|
|
"tags": ["task"],
|
|
"description": "Task lifecycle management (start, stop, update, control)",
|
|
},
|
|
{
|
|
"router": tool_controller.router,
|
|
"tags": ["tool"],
|
|
"description": "Tool installation and management",
|
|
},
|
|
]
|
|
|
|
app.include_router(health_controller.router, tags=["Health"])
|
|
logger.info(
|
|
"Registered Health router at root level for Docker health checks"
|
|
)
|
|
|
|
for config in routers_config:
|
|
app.include_router(
|
|
config["router"], prefix=prefix, tags=config["tags"]
|
|
)
|
|
route_count = len(config["router"].routes)
|
|
logger.info(
|
|
f"Registered {config['tags'][0]} router:"
|
|
f" {route_count} routes -"
|
|
f" {config['description']}"
|
|
)
|
|
|
|
logger.info(f"Total routers registered: {len(routers_config)}")
|