refactor: replace direct calls to provisioning functions with OpenClawProvisioningService methods

This commit is contained in:
Abhimanyu Saharan
2026-02-10 22:30:14 +05:30
parent d9199f8d8d
commit ad75871e61
12 changed files with 703 additions and 844 deletions

View File

@@ -30,7 +30,7 @@ from app.schemas.pagination import DefaultLimitOffsetPage
from app.schemas.view_models import BoardGroupSnapshot
from app.services.board_group_snapshot import build_group_snapshot
from app.services.openclaw.constants import DEFAULT_HEARTBEAT_CONFIG
from app.services.openclaw.provisioning import sync_gateway_agent_heartbeats
from app.services.openclaw.provisioning import OpenClawProvisioningService
from app.services.openclaw.shared import GatewayTransportError
from app.services.organizations import (
OrganizationContext,
@@ -269,7 +269,10 @@ async def _sync_gateway_heartbeats(
failed_agent_ids.extend([agent.id for agent in gateway_agents])
continue
try:
await sync_gateway_agent_heartbeats(gateway, gateway_agents)
await OpenClawProvisioningService().sync_gateway_agent_heartbeats(
gateway,
gateway_agents,
)
except GatewayTransportError:
failed_agent_ids.extend([agent.id for agent in gateway_agents])
return failed_agent_ids

View File

@@ -38,7 +38,7 @@ from app.services.openclaw.policies import OpenClawAuthorizationPolicy
from app.services.openclaw.provisioning import (
LeadAgentOptions,
LeadAgentRequest,
ensure_board_lead_agent,
OpenClawProvisioningService,
)
from app.services.openclaw.shared import require_gateway_config_for_board
@@ -401,8 +401,7 @@ async def confirm_onboarding(
session.add(onboarding)
await session.commit()
await session.refresh(board)
await ensure_board_lead_agent(
session,
await OpenClawProvisioningService(session).ensure_board_lead_agent(
request=LeadAgentRequest(
board=board,
gateway=gateway,

View File

@@ -39,7 +39,7 @@ from app.schemas.pagination import DefaultLimitOffsetPage
from app.schemas.view_models import BoardGroupSnapshot, BoardSnapshot
from app.services.board_group_snapshot import build_board_group_snapshot
from app.services.board_snapshot import build_board_snapshot
from app.services.openclaw.provisioning import cleanup_agent
from app.services.openclaw.provisioning import OpenClawProvisioningService
from app.services.openclaw.shared import GatewayTransportError
from app.services.organizations import OrganizationContext, board_access_filter
@@ -287,7 +287,10 @@ async def delete_board(
if config:
try:
for agent in agents:
await cleanup_agent(agent, config)
await OpenClawProvisioningService().delete_agent_lifecycle(
agent=agent,
gateway=config,
)
except GatewayTransportError as exc:
raise HTTPException(
status_code=status.HTTP_502_BAD_GATEWAY,