implemenation on the ai agents and registry
This commit is contained in:
@@ -8,16 +8,18 @@ from core.types import (
|
||||
AgentTask, MessageType, Priority, OrderStatus, ZoneType
|
||||
)
|
||||
from core.logger import logger
|
||||
from core.http_client import api_get, api_post, api_patch
|
||||
from config.system_config import GO_API_BASE_URL
|
||||
|
||||
|
||||
class OrderAgent(SpecializedAgent):
|
||||
"""
|
||||
Order Agent - Manages the entire order lifecycle from intake to validation.
|
||||
|
||||
Writes go to the Doormile Go backend (POST /api/v1/admin/crmbooking).
|
||||
Reads and status updates also go through the Go API.
|
||||
NOT CONNECTED to the Doormile backend (agent registry status: broken).
|
||||
It was written against /api/v1/admin/crmbooking, which was renamed to
|
||||
/admin/expressbooking, and every /admin/* route needs a console login's
|
||||
JWT — this engine holds only the internal key, which /admin/* refuses. So
|
||||
the helpers below refuse up front instead of sending requests that can only
|
||||
fail. Wiring it needs an /internal/* booking route on the backend first.
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
@@ -70,23 +72,22 @@ class OrderAgent(SpecializedAgent):
|
||||
# Go API helpers (use shared session + retry from http_client) #
|
||||
# ------------------------------------------------------------------ #
|
||||
|
||||
# Returns None (what every caller already treats as "no backend result").
|
||||
NO_BACKEND_ROUTE = ("OrderAgent has no working backend route: /admin/* needs a console JWT "
|
||||
"and /admin/crmbooking no longer exists")
|
||||
|
||||
def _refuse(self, method: str, path: str) -> None:
|
||||
logger.warning(f"OrderAgent: not calling {method} {path} — {self.NO_BACKEND_ROUTE}")
|
||||
return None
|
||||
|
||||
async def _api_post(self, path: str, payload: Dict) -> Optional[Dict]:
|
||||
result = await api_post(f"{GO_API_BASE_URL}{path}", json=payload)
|
||||
if result is None:
|
||||
logger.error(f"Go API POST {path} returned no response")
|
||||
return result
|
||||
return self._refuse("POST", path)
|
||||
|
||||
async def _api_get(self, path: str, params: Dict = None) -> Optional[Dict]:
|
||||
result = await api_get(f"{GO_API_BASE_URL}{path}", params=params)
|
||||
if result is None:
|
||||
logger.error(f"Go API GET {path} returned no response")
|
||||
return result
|
||||
return self._refuse("GET", path)
|
||||
|
||||
async def _api_patch(self, path: str, payload: Dict) -> Optional[Dict]:
|
||||
result = await api_patch(f"{GO_API_BASE_URL}{path}", json=payload)
|
||||
if result is None:
|
||||
logger.error(f"Go API PATCH {path} returned no response")
|
||||
return result
|
||||
return self._refuse("PATCH", path)
|
||||
|
||||
# ------------------------------------------------------------------ #
|
||||
# Task handlers #
|
||||
|
||||
Reference in New Issue
Block a user