diff --git a/extensions/bluebubbles/src/status-issues.ts b/extensions/bluebubbles/src/status-issues.ts index 5771acdbf2a..d02baa0da73 100644 --- a/extensions/bluebubbles/src/status-issues.ts +++ b/extensions/bluebubbles/src/status-issues.ts @@ -1,4 +1,5 @@ import { collectIssuesForEnabledAccounts } from "openclaw/plugin-sdk/status-helpers"; +import { asRecord } from "./monitor-normalize.js"; import type { ChannelAccountSnapshot } from "./runtime-api.js"; type BlueBubblesAccountStatus = { @@ -17,10 +18,6 @@ type BlueBubblesProbeResult = { error?: string | null; }; -function isRecord(value: unknown): value is Record { - return typeof value === "object" && value !== null; -} - function asString(value: unknown): string | null { return typeof value === "string" && value.length > 0 ? value : null; } @@ -28,28 +25,30 @@ function asString(value: unknown): string | null { function readBlueBubblesAccountStatus( value: ChannelAccountSnapshot, ): BlueBubblesAccountStatus | null { - if (!isRecord(value)) { + const record = asRecord(value); + if (!record) { return null; } return { - accountId: value.accountId, - enabled: value.enabled, - configured: value.configured, - running: value.running, - baseUrl: value.baseUrl, - lastError: value.lastError, - probe: value.probe, + accountId: record.accountId, + enabled: record.enabled, + configured: record.configured, + running: record.running, + baseUrl: record.baseUrl, + lastError: record.lastError, + probe: record.probe, }; } function readBlueBubblesProbeResult(value: unknown): BlueBubblesProbeResult | null { - if (!isRecord(value)) { + const record = asRecord(value); + if (!record) { return null; } return { - ok: typeof value.ok === "boolean" ? value.ok : undefined, - status: typeof value.status === "number" ? value.status : null, - error: asString(value.error) ?? null, + ok: typeof record.ok === "boolean" ? record.ok : undefined, + status: typeof record.status === "number" ? record.status : null, + error: asString(record.error) ?? null, }; }