diff --git a/backend/app/services/openclaw/gateway_rpc.py b/backend/app/services/openclaw/gateway_rpc.py index 85a67124..32abf1cb 100644 --- a/backend/app/services/openclaw/gateway_rpc.py +++ b/backend/app/services/openclaw/gateway_rpc.py @@ -9,6 +9,7 @@ from __future__ import annotations import asyncio import json +import platform as _platform import ssl from dataclasses import dataclass from time import perf_counter, time @@ -28,6 +29,9 @@ from app.services.openclaw.device_identity import ( ) PROTOCOL_VERSION = 3 +# Resolved once at import time; matches the value written by the openclaw CLI +# during pairing ("linux", "darwin", or "windows"). +_HOST_PLATFORM: str = _platform.system().lower() logger = get_logger(__name__) GATEWAY_OPERATOR_SCOPES = ( "operator.read", @@ -334,7 +338,7 @@ def _build_connect_params( "client": { "id": CONTROL_UI_CLIENT_ID if use_control_ui else DEFAULT_GATEWAY_CLIENT_ID, "version": "1.0.0", - "platform": "python", + "platform": _HOST_PLATFORM, "mode": CONTROL_UI_CLIENT_MODE if use_control_ui else DEFAULT_GATEWAY_CLIENT_MODE, }, } diff --git a/backend/tests/test_gateway_rpc_connect_scopes.py b/backend/tests/test_gateway_rpc_connect_scopes.py index 00a1db86..c37600a8 100644 --- a/backend/tests/test_gateway_rpc_connect_scopes.py +++ b/backend/tests/test_gateway_rpc_connect_scopes.py @@ -1,5 +1,7 @@ from __future__ import annotations +import platform + import pytest import app.services.openclaw.gateway_rpc as gateway_rpc @@ -57,6 +59,7 @@ def test_build_connect_params_defaults_to_device_pairing( assert params["scopes"] == list(GATEWAY_OPERATOR_SCOPES) assert params["client"]["id"] == DEFAULT_GATEWAY_CLIENT_ID assert params["client"]["mode"] == DEFAULT_GATEWAY_CLIENT_MODE + assert params["client"]["platform"] == platform.system().lower() assert params["device"] == expected_device_payload assert "auth" not in params assert captured["client_id"] == DEFAULT_GATEWAY_CLIENT_ID @@ -80,6 +83,7 @@ def test_build_connect_params_uses_control_ui_when_pairing_disabled() -> None: assert params["scopes"] == list(GATEWAY_OPERATOR_SCOPES) assert params["client"]["id"] == CONTROL_UI_CLIENT_ID assert params["client"]["mode"] == CONTROL_UI_CLIENT_MODE + assert params["client"]["platform"] == platform.system().lower() assert "device" not in params