# -*- coding: utf-8 -*- """Read-only OpenClaw CLI FastAPI surface. COMPATIBILITY_SURFACE: deferred OWNER: runtime-team SEE: docs/legacy-inventory.md#openclaw-dual-integration This is the REST facade (port 8004) for OpenClaw integration. For the WebSocket gateway integration, see: - backend/services/gateway_openclaw_handlers.py - shared/client/openclaw_websocket_client.py Key differences: - REST facade: typed Pydantic models, request/response, polling - WebSocket: event-driven, real-time updates, bidirectional Decision needed: which surface becomes the long-term contract? """ from __future__ import annotations from fastapi import Depends, FastAPI from backend.api import openclaw_router from backend.apps.cors import add_cors_middleware from backend.api.openclaw import get_openclaw_cli_service def create_app() -> FastAPI: """Create the OpenClaw service app.""" app = FastAPI( title="大时代 OpenClaw Service", description="Read-only OpenClaw CLI integration service surface", version="0.1.0", ) add_cors_middleware(app) @app.get("/health") async def health_check( service=Depends(get_openclaw_cli_service), ) -> dict[str, object]: return service.health() @app.get("/api/status") async def api_status( service=Depends(get_openclaw_cli_service), ) -> dict[str, object]: return { "status": "operational", "service": "openclaw-service", "openclaw": service.health(), } app.include_router(openclaw_router) return app app = create_app() if __name__ == "__main__": import uvicorn uvicorn.run(app, host="0.0.0.0", port=8004)