refactor(openclaw): remove REST facade (port 8004), unify on WebSocket

Remove the redundant OpenClaw REST service (port 8004) since frontend
already uses WebSocket via Gateway (port 8765) → OpenClaw (port 18789).

Deleted:
- backend/apps/openclaw_service.py
- backend/api/openclaw.py
- backend/tests/test_openclaw_service_app.py
- backend/tests/test_service_clients.py
- shared/client/openclaw_client.py

Updated:
- backend/apps/__init__.py — remove openclaw_app exports
- backend/api/__init__.py — remove openclaw_router
- shared/client/__init__.py — remove OpenClawServiceClient
- backend/services/gateway_openclaw_handlers.py — update docstring
- start.sh — remove port 8004 service startup

Architecture:
- Before: Frontend → HTTP :8004 → subprocess openclaw CLI
- After: Frontend → WS :8765 → Gateway → WS :18789 → OpenClaw

Constraint: Frontend already uses WebSocket exclusively
Confidence: high
Scope-risk: low (frontend unchanged)
This commit is contained in:
2026-04-02 11:04:06 +08:00
parent 45c3996434
commit ecc7623093
10 changed files with 4 additions and 1625 deletions

View File

@@ -1,22 +1,12 @@
# -*- coding: utf-8 -*-
"""OpenClaw WebSocket handlers — gateway calls OpenClaw Gateway via WebSocket.
COMPATIBILITY_SURFACE: deferred
COMPATIBILITY_SURFACE: stable
OWNER: runtime-team
SEE: docs/legacy-inventory.md#openclaw-dual-integration
This is the WebSocket gateway integration for OpenClaw (port 18789).
For the REST facade, see:
- backend/apps/openclaw_service.py (port 8004)
- backend/api/openclaw.py
Key differences:
- WebSocket: event-driven, real-time updates, bidirectional
- REST facade: typed Pydantic models, request/response, polling
Decision needed: which surface becomes the long-term contract?
Frontend connects via Gateway WebSocket (port 8765) → OpenClaw Gateway (port 18789).
"""
from __future__ import annotations
import json