openclaw/src/gateway/protocol/client-info.ts
Manuel Jiménez f243179c6e fix: add legacy clawdbot/moltbot client IDs for backward compatibility
Adds legacy client IDs to GATEWAY_CLIENT_IDS for backward compatibility
after the clawdbot → moltbot → openclaw renames:

- clawdbot-control-ui, clawdbot-macos, clawdbot-ios, clawdbot-android, clawdbot-probe
- moltbot-control-ui, moltbot-macos, moltbot-ios, moltbot-android, moltbot-probe

This allows older apps with legacy client IDs to still connect to the gateway.
2026-01-30 13:14:52 +01:00

78 lines
2.6 KiB
TypeScript

export const GATEWAY_CLIENT_IDS = {
WEBCHAT_UI: "webchat-ui",
CONTROL_UI: "openclaw-control-ui",
WEBCHAT: "webchat",
CLI: "cli",
GATEWAY_CLIENT: "gateway-client",
MACOS_APP: "openclaw-macos",
IOS_APP: "openclaw-ios",
ANDROID_APP: "openclaw-android",
NODE_HOST: "node-host",
TEST: "test",
FINGERPRINT: "fingerprint",
PROBE: "openclaw-probe",
// Legacy client IDs (clawdbot/moltbot -> openclaw rename compat)
LEGACY_CLAWDBOT_CONTROL_UI: "clawdbot-control-ui",
LEGACY_CLAWDBOT_MACOS_APP: "clawdbot-macos",
LEGACY_CLAWDBOT_IOS_APP: "clawdbot-ios",
LEGACY_CLAWDBOT_ANDROID_APP: "clawdbot-android",
LEGACY_CLAWDBOT_PROBE: "clawdbot-probe",
LEGACY_MOLTBOT_CONTROL_UI: "moltbot-control-ui",
LEGACY_MOLTBOT_MACOS_APP: "moltbot-macos",
LEGACY_MOLTBOT_IOS_APP: "moltbot-ios",
LEGACY_MOLTBOT_ANDROID_APP: "moltbot-android",
LEGACY_MOLTBOT_PROBE: "moltbot-probe",
} as const;
export type GatewayClientId = (typeof GATEWAY_CLIENT_IDS)[keyof typeof GATEWAY_CLIENT_IDS];
// Back-compat naming (internal): these values are IDs, not display names.
export const GATEWAY_CLIENT_NAMES = GATEWAY_CLIENT_IDS;
export type GatewayClientName = GatewayClientId;
export const GATEWAY_CLIENT_MODES = {
WEBCHAT: "webchat",
CLI: "cli",
UI: "ui",
BACKEND: "backend",
NODE: "node",
PROBE: "probe",
TEST: "test",
} as const;
export type GatewayClientMode = (typeof GATEWAY_CLIENT_MODES)[keyof typeof GATEWAY_CLIENT_MODES];
export type GatewayClientInfo = {
id: GatewayClientId;
displayName?: string;
version: string;
platform: string;
deviceFamily?: string;
modelIdentifier?: string;
mode: GatewayClientMode;
instanceId?: string;
};
const GATEWAY_CLIENT_ID_SET = new Set<GatewayClientId>(Object.values(GATEWAY_CLIENT_IDS));
const GATEWAY_CLIENT_MODE_SET = new Set<GatewayClientMode>(Object.values(GATEWAY_CLIENT_MODES));
export function normalizeGatewayClientId(raw?: string | null): GatewayClientId | undefined {
const normalized = raw?.trim().toLowerCase();
if (!normalized) return undefined;
return GATEWAY_CLIENT_ID_SET.has(normalized as GatewayClientId)
? (normalized as GatewayClientId)
: undefined;
}
export function normalizeGatewayClientName(raw?: string | null): GatewayClientName | undefined {
return normalizeGatewayClientId(raw);
}
export function normalizeGatewayClientMode(raw?: string | null): GatewayClientMode | undefined {
const normalized = raw?.trim().toLowerCase();
if (!normalized) return undefined;
return GATEWAY_CLIENT_MODE_SET.has(normalized as GatewayClientMode)
? (normalized as GatewayClientMode)
: undefined;
}