fix: resolve extension type errors and harden probe mocks

This commit is contained in:
Peter Steinberger
2026-02-22 12:25:48 +01:00
parent 3bbbe33a1b
commit 26763d1910
4 changed files with 11 additions and 10 deletions

View File

@@ -1,6 +1,7 @@
import type { PluginRuntime } from "openclaw/plugin-sdk";
let runtime: PluginRuntime | null = null;
type LegacyRuntimeLogShape = { log?: (message: string) => void };
export function setBlueBubblesRuntime(next: PluginRuntime): void {
runtime = next;
@@ -23,7 +24,8 @@ export function getBlueBubblesRuntime(): PluginRuntime {
export function warnBlueBubbles(message: string): void {
const formatted = `[bluebubbles] ${message}`;
const log = runtime?.log;
// Backward-compatible with tests/legacy injections that pass { log }.
const log = (runtime as unknown as LegacyRuntimeLogShape | null)?.log;
if (typeof log === "function") {
log(formatted);
return;

View File

@@ -2,10 +2,10 @@ import type { Mock } from "vitest";
import { afterEach, beforeEach, vi } from "vitest";
export const BLUE_BUBBLES_PRIVATE_API_STATUS = {
enabled: true as const,
disabled: false as const,
unknown: null as const,
};
enabled: true,
disabled: false,
unknown: null,
} as const;
type BlueBubblesPrivateApiStatusMock = {
mockReturnValue: (value: boolean | null) => unknown;
@@ -47,6 +47,7 @@ export function createBlueBubblesAccountsMockModule() {
type BlueBubblesProbeMockModule = {
getCachedBlueBubblesPrivateApiStatus: Mock<() => boolean | null>;
isBlueBubblesPrivateApiStatusEnabled: Mock<(status: boolean | null) => boolean>;
};
export function createBlueBubblesProbeMockModule(): BlueBubblesProbeMockModule {
@@ -54,6 +55,7 @@ export function createBlueBubblesProbeMockModule(): BlueBubblesProbeMockModule {
getCachedBlueBubblesPrivateApiStatus: vi
.fn()
.mockReturnValue(BLUE_BUBBLES_PRIVATE_API_STATUS.unknown),
isBlueBubblesPrivateApiStatusEnabled: vi.fn((status: boolean | null) => status === true),
};
}

View File

@@ -225,9 +225,7 @@ export const feishuPlugin: ChannelPlugin<ResolvedFeishuAccount> = {
collectWarnings: ({ cfg, accountId }) => {
const account = resolveFeishuAccount({ cfg, accountId });
const feishuCfg = account.config;
const defaultGroupPolicy = (
cfg.channels as Record<string, { groupPolicy?: string }> | undefined
)?.defaults?.groupPolicy;
const defaultGroupPolicy = cfg.channels?.defaults?.groupPolicy;
const { groupPolicy } = resolveRuntimeGroupPolicy({
providerConfigPresent: cfg.channels?.feishu !== undefined,
groupPolicy: feishuCfg?.groupPolicy,

View File

@@ -162,8 +162,7 @@ export const linePlugin: ChannelPlugin<ResolvedLineAccount> = {
};
},
collectWarnings: ({ account, cfg }) => {
const defaultGroupPolicy = (cfg.channels?.defaults as { groupPolicy?: string } | undefined)
?.groupPolicy;
const defaultGroupPolicy = cfg.channels?.defaults?.groupPolicy;
const { groupPolicy } = resolveRuntimeGroupPolicy({
providerConfigPresent: cfg.channels?.line !== undefined,
groupPolicy: account.config.groupPolicy,