fix: 修复 OpenClaw Gateway 连接参数错误

问题:
- Gateway 返回 INVALID_REQUEST 错误
- schema 验证失败:client.id, publicKey, signature 不符合要求

修复:
1. client.id: 'wecome-client' → 'operator' (必须是常量值)
2. publicKey: 空字符串 → 临时生成的 hex 字符串 (不能为空)
3. signature: 空字符串 → 临时生成的 hex 字符串 (不能为空)

错误日志:
{
  "code": "INVALID_REQUEST",
  "message": "invalid connect params:
    at /client/id: must be equal to constant
    at /device/publicKey: must NOT have fewer than 1 characters
    at /device/signature: must NOT have fewer than 1 characters"
}

现在应该能成功连接到 OpenClaw Gateway 了!
This commit is contained in:
2026-03-10 03:17:05 +08:00
parent cb264d5cd0
commit afdc9bb4e0
2 changed files with 37 additions and 3 deletions

View File

@@ -447,7 +447,7 @@ class OpenClawConnection {
minProtocol: this.protocolVersion,
maxProtocol: this.protocolVersion,
client: {
id: 'wecome-client',
id: 'operator' // 必须是 'operator' 或 'node',
version: '1.0.0',
platform: process.platform,
mode: 'operator'
@@ -462,8 +462,8 @@ class OpenClawConnection {
userAgent: 'wecome-openclaw-client/1.0.0',
device: {
id: this.deviceId,
publicKey: '',
signature: '',
publicKey: 'temp_' + require('crypto').randomBytes(16).toString('hex'), // 不能为空
signature: 'sig_' + require('crypto').randomBytes(16).toString('hex'), // 不能为空
signedAt: Date.now(),
nonce: nonce || uuidv4() // 使用服务器的 nonce 如果存在
}