Skip to content

Commit 26763d1

Browse files
committed
fix: resolve extension type errors and harden probe mocks
1 parent 3bbbe33 commit 26763d1

4 files changed

Lines changed: 11 additions & 10 deletions

File tree

extensions/bluebubbles/src/runtime.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { PluginRuntime } from "openclaw/plugin-sdk";
22

33
let runtime: PluginRuntime | null = null;
4+
type LegacyRuntimeLogShape = { log?: (message: string) => void };
45

56
export function setBlueBubblesRuntime(next: PluginRuntime): void {
67
runtime = next;
@@ -23,7 +24,8 @@ export function getBlueBubblesRuntime(): PluginRuntime {
2324

2425
export function warnBlueBubbles(message: string): void {
2526
const formatted = `[bluebubbles] ${message}`;
26-
const log = runtime?.log;
27+
// Backward-compatible with tests/legacy injections that pass { log }.
28+
const log = (runtime as unknown as LegacyRuntimeLogShape | null)?.log;
2729
if (typeof log === "function") {
2830
log(formatted);
2931
return;

extensions/bluebubbles/src/test-harness.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ import type { Mock } from "vitest";
22
import { afterEach, beforeEach, vi } from "vitest";
33

44
export const BLUE_BUBBLES_PRIVATE_API_STATUS = {
5-
enabled: true as const,
6-
disabled: false as const,
7-
unknown: null as const,
8-
};
5+
enabled: true,
6+
disabled: false,
7+
unknown: null,
8+
} as const;
99

1010
type BlueBubblesPrivateApiStatusMock = {
1111
mockReturnValue: (value: boolean | null) => unknown;
@@ -47,13 +47,15 @@ export function createBlueBubblesAccountsMockModule() {
4747

4848
type BlueBubblesProbeMockModule = {
4949
getCachedBlueBubblesPrivateApiStatus: Mock<() => boolean | null>;
50+
isBlueBubblesPrivateApiStatusEnabled: Mock<(status: boolean | null) => boolean>;
5051
};
5152

5253
export function createBlueBubblesProbeMockModule(): BlueBubblesProbeMockModule {
5354
return {
5455
getCachedBlueBubblesPrivateApiStatus: vi
5556
.fn()
5657
.mockReturnValue(BLUE_BUBBLES_PRIVATE_API_STATUS.unknown),
58+
isBlueBubblesPrivateApiStatusEnabled: vi.fn((status: boolean | null) => status === true),
5759
};
5860
}
5961

extensions/feishu/src/channel.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,9 +225,7 @@ export const feishuPlugin: ChannelPlugin<ResolvedFeishuAccount> = {
225225
collectWarnings: ({ cfg, accountId }) => {
226226
const account = resolveFeishuAccount({ cfg, accountId });
227227
const feishuCfg = account.config;
228-
const defaultGroupPolicy = (
229-
cfg.channels as Record<string, { groupPolicy?: string }> | undefined
230-
)?.defaults?.groupPolicy;
228+
const defaultGroupPolicy = cfg.channels?.defaults?.groupPolicy;
231229
const { groupPolicy } = resolveRuntimeGroupPolicy({
232230
providerConfigPresent: cfg.channels?.feishu !== undefined,
233231
groupPolicy: feishuCfg?.groupPolicy,

extensions/line/src/channel.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,7 @@ export const linePlugin: ChannelPlugin<ResolvedLineAccount> = {
162162
};
163163
},
164164
collectWarnings: ({ account, cfg }) => {
165-
const defaultGroupPolicy = (cfg.channels?.defaults as { groupPolicy?: string } | undefined)
166-
?.groupPolicy;
165+
const defaultGroupPolicy = cfg.channels?.defaults?.groupPolicy;
167166
const { groupPolicy } = resolveRuntimeGroupPolicy({
168167
providerConfigPresent: cfg.channels?.line !== undefined,
169168
groupPolicy: account.config.groupPolicy,

0 commit comments

Comments
 (0)