refactor: enhance gateway agent handling with dedicated OpenClaw agent IDs
This commit is contained in:
@@ -8,6 +8,7 @@ from app.models.gateways import Gateway
|
||||
|
||||
_GATEWAY_AGENT_PREFIX = "agent:gateway-"
|
||||
_GATEWAY_AGENT_SUFFIX = ":main"
|
||||
_GATEWAY_OPENCLAW_AGENT_PREFIX = "mc-gateway-"
|
||||
|
||||
|
||||
def gateway_agent_session_key_for_id(gateway_id: UUID) -> str:
|
||||
@@ -20,6 +21,16 @@ def gateway_agent_session_key(gateway: Gateway) -> str:
|
||||
return gateway_agent_session_key_for_id(gateway.id)
|
||||
|
||||
|
||||
def gateway_openclaw_agent_id_for_id(gateway_id: UUID) -> str:
|
||||
"""Return the dedicated OpenClaw config `agentId` for a gateway agent."""
|
||||
return f"{_GATEWAY_OPENCLAW_AGENT_PREFIX}{gateway_id}"
|
||||
|
||||
|
||||
def gateway_openclaw_agent_id(gateway: Gateway) -> str:
|
||||
"""Return the dedicated OpenClaw config `agentId` for a gateway agent."""
|
||||
return gateway_openclaw_agent_id_for_id(gateway.id)
|
||||
|
||||
|
||||
def parse_gateway_agent_session_key(session_key: str | None) -> UUID | None:
|
||||
"""Parse a gateway id from a dedicated gateway-agent session key."""
|
||||
value = (session_key or "").strip()
|
||||
|
||||
Reference in New Issue
Block a user