惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Recent Announcements
Recent Announcements
V
Visual Studio Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
云风的 BLOG
云风的 BLOG
Microsoft Security Blog
Microsoft Security Blog
博客园 - 司徒正美
Y
Y Combinator Blog
Stack Overflow Blog
Stack Overflow Blog
雷峰网
雷峰网
小众软件
小众软件
GbyAI
GbyAI
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
aimingoo的专栏
aimingoo的专栏
MyScale Blog
MyScale Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
腾讯CDC
A
About on SuperTechFans
宝玉的分享
宝玉的分享
WordPress大学
WordPress大学
B
Blog RSS Feed
G
Google Developers Blog
量子位
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
博客园 - 三生石上(FineUI控件)

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix(qqbot): type active config provider · openclaw/opencl...
statxc · 2026-05-11 · via Recent Commits to openclaw:main

@@ -1,91 +1,84 @@

1+

import type { OpenClawConfig } from "openclaw/plugin-sdk/config-types";

12

import { describe, expect, it, vi } from "vitest";

2-

import {

3-

createActiveCfgProvider,

4-

resolveActiveCfg,

5-

type GatewayCfg,

6-

type GatewayCfgFetcher,

7-

} from "./active-cfg.js";

3+

import { createActiveCfgProvider, resolveActiveCfg, type GatewayCfgLoader } from "./active-cfg.js";

849-

const getRuntimeConfigMock = vi.hoisted(() => vi.fn<() => GatewayCfg | undefined>());

5+

const getRuntimeConfigMock = vi.hoisted(() => vi.fn<() => OpenClawConfig>());

106117

vi.mock("openclaw/plugin-sdk/runtime-config-snapshot", () => ({

128

getRuntimeConfig: getRuntimeConfigMock,

139

}));

141015-

describe("resolveActiveCfg", () => {

16-

it("returns the freshly fetched value when present", () => {

17-

const fresh = { bindings: [{ id: "fresh" }] };

18-

const fallback = { bindings: [{ id: "stale" }] };

19-

const fetch: GatewayCfgFetcher = () => fresh;

20-21-

expect(resolveActiveCfg(fetch, fallback)).toBe(fresh);

22-

});

11+

function asCfg(shape: { bindings: Array<{ id: string }> }): OpenClawConfig {

12+

return shape as unknown as OpenClawConfig;

13+

}

231424-

it("falls back when the fetcher returns undefined", () => {

25-

const fallback = { bindings: [{ id: "stale" }] };

26-

const fetch: GatewayCfgFetcher = () => undefined;

15+

describe("resolveActiveCfg", () => {

16+

it("returns the freshly loaded value when the loader succeeds", () => {

17+

const fresh = asCfg({ bindings: [{ id: "fresh" }] });

18+

const fallback = asCfg({ bindings: [{ id: "stale" }] });

19+

const loader: GatewayCfgLoader = () => fresh;

272028-

expect(resolveActiveCfg(fetch, fallback)).toBe(fallback);

21+

expect(resolveActiveCfg(loader, fallback)).toBe(fresh);

2922

});

302331-

it("falls back when the fetcher throws", () => {

32-

const fallback = { bindings: [{ id: "stale" }] };

33-

const fetch: GatewayCfgFetcher = () => {

24+

it("falls back when the loader throws", () => {

25+

const fallback = asCfg({ bindings: [{ id: "stale" }] });

26+

const loader: GatewayCfgLoader = () => {

3427

throw new Error("snapshot not initialised");

3528

};

362937-

expect(resolveActiveCfg(fetch, fallback)).toBe(fallback);

30+

expect(resolveActiveCfg(loader, fallback)).toBe(fallback);

3831

});

3932

});

40334134

describe("createActiveCfgProvider", () => {

42-

it("invokes the injected fetcher on every getActiveCfg call", () => {

43-

const fallback = { bindings: [] };

44-

const first = { bindings: [{ id: "first" }] };

45-

const second = { bindings: [{ id: "second" }] };

46-

const fetch = vi

47-

.fn<() => GatewayCfg | undefined>()

35+

it("invokes the injected loader on every getActiveCfg call", () => {

36+

const fallback = asCfg({ bindings: [] });

37+

const first = asCfg({ bindings: [{ id: "first" }] });

38+

const second = asCfg({ bindings: [{ id: "second" }] });

39+

const load = vi

40+

.fn<() => OpenClawConfig>()

4841

.mockReturnValueOnce(first)

4942

.mockReturnValueOnce(second);

504351-

const provider = createActiveCfgProvider({ fallback, fetch });

44+

const provider = createActiveCfgProvider({ fallback, load });

52455346

expect(provider.getActiveCfg()).toBe(first);

5447

expect(provider.getActiveCfg()).toBe(second);

55-

expect(fetch).toHaveBeenCalledTimes(2);

48+

expect(load).toHaveBeenCalledTimes(2);

5649

});

575058-

it("never caches a previously fetched value", () => {

59-

const fallback = { bindings: [] };

60-

const calls: GatewayCfg[] = [

61-

{ bindings: [{ id: "a" }] },

62-

{ bindings: [{ id: "b" }] },

63-

{ bindings: [{ id: "c" }] },

51+

it("never caches a previously loaded value", () => {

52+

const fallback = asCfg({ bindings: [] });

53+

const calls: OpenClawConfig[] = [

54+

asCfg({ bindings: [{ id: "a" }] }),

55+

asCfg({ bindings: [{ id: "b" }] }),

56+

asCfg({ bindings: [{ id: "c" }] }),

6457

];

6558

let index = 0;

6659

const provider = createActiveCfgProvider({

6760

fallback,

68-

fetch: () => calls[index++],

61+

load: () => calls[index++],

6962

});

70637164

expect(provider.getActiveCfg()).toBe(calls[0]);

7265

expect(provider.getActiveCfg()).toBe(calls[1]);

7366

expect(provider.getActiveCfg()).toBe(calls[2]);

7467

});

756876-

it("delegates to getRuntimeConfig when no fetcher is provided", () => {

77-

const live = { bindings: [{ id: "live" }] };

69+

it("delegates to getRuntimeConfig when no loader is provided", () => {

70+

const live = asCfg({ bindings: [{ id: "live" }] });

7871

getRuntimeConfigMock.mockReset();

7972

getRuntimeConfigMock.mockReturnValue(live);

807381-

const provider = createActiveCfgProvider({ fallback: { bindings: [] } });

74+

const provider = createActiveCfgProvider({ fallback: asCfg({ bindings: [] }) });

82758376

expect(provider.getActiveCfg()).toBe(live);

8477

expect(getRuntimeConfigMock).toHaveBeenCalledTimes(1);

8578

});

86798780

it("falls back to the supplied snapshot when the SDK getter throws", () => {

88-

const fallback = { bindings: [{ id: "snapshot" }] };

81+

const fallback = asCfg({ bindings: [{ id: "snapshot" }] });

8982

getRuntimeConfigMock.mockReset();

9083

getRuntimeConfigMock.mockImplementation(() => {

9184

throw new Error("not ready");