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

推荐订阅源

Jina AI
Jina AI
S
SegmentFault 最新的问题
D
DataBreaches.Net
H
Help Net Security
有赞技术团队
有赞技术团队
M
MIT News - Artificial intelligence
Martin Fowler
Martin Fowler
IT之家
IT之家
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
腾讯CDC
罗磊的独立博客
Y
Y Combinator Blog
阮一峰的网络日志
阮一峰的网络日志
云风的 BLOG
云风的 BLOG
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
WordPress大学
WordPress大学
Microsoft Security Blog
Microsoft Security Blog
J
Java Code Geeks
Vercel News
Vercel News
Hugging Face - Blog
Hugging Face - Blog
aimingoo的专栏
aimingoo的专栏
Stack Overflow Blog
Stack Overflow Blog
Recent Announcements
Recent Announcements
博客园 - 三生石上(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
test(plugins): guard cold status snapshots · openclaw/ope...
vincentkoc · 2026-04-27 · via Recent Commits to openclaw:main

@@ -1,139 +1,52 @@

1-

import fs from "node:fs";

2-

import os from "node:os";

3-

import path from "node:path";

41

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

5-

import type { OpenClawConfig } from "../config/types.openclaw.js";

62

import { clearPluginDiscoveryCache } from "../plugins/discovery.js";

73

import { clearPluginManifestRegistryCache } from "../plugins/manifest-registry.js";

84

import { refreshPluginRegistry } from "../plugins/plugin-registry.js";

5+

import {

6+

createColdPluginConfig,

7+

createColdPluginFixture,

8+

createColdPluginHermeticEnv,

9+

isColdPluginRuntimeLoaded,

10+

} from "../plugins/test-helpers/cold-plugin-fixtures.js";

11+

import { cleanupTrackedTempDirs, makeTrackedTempDir } from "../plugins/test-helpers/fs-fixtures.js";

912

import { buildAuthChoiceOptions, formatAuthChoiceChoicesForCli } from "./auth-choice-options.js";

1013

import { listManifestInstalledChannelIds } from "./channel-setup/discovery.js";

1114

import { resolveProviderCatalogPluginIdsForFilter } from "./models/list.provider-catalog.js";

12151316

const tempDirs: string[] = [];

14171518

function makeTempDir() {

16-

const dir = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-command-cold-imports-"));

17-

tempDirs.push(dir);

18-

return dir;

19-

}

20-21-

function hermeticEnv(

22-

homeDir: string,

23-

options: { disablePersistedRegistry?: boolean } = {},

24-

): NodeJS.ProcessEnv {

25-

return {

26-

...process.env,

27-

OPENCLAW_HOME: path.join(homeDir, "home"),

28-

OPENCLAW_BUNDLED_PLUGINS_DIR: undefined,

29-

OPENCLAW_DISABLE_PERSISTED_PLUGIN_REGISTRY:

30-

options.disablePersistedRegistry === false ? undefined : "1",

31-

OPENCLAW_DISABLE_PLUGIN_DISCOVERY_CACHE: "1",

32-

OPENCLAW_DISABLE_PLUGIN_MANIFEST_CACHE: "1",

33-

OPENCLAW_VERSION: "2026.4.25",

34-

VITEST: "true",

35-

};

36-

}

37-38-

function createColdControlPlanePlugin() {

39-

const rootDir = makeTempDir();

40-

const runtimeMarker = path.join(rootDir, "runtime-loaded.txt");

41-

fs.writeFileSync(

42-

path.join(rootDir, "package.json"),

43-

JSON.stringify(

44-

{

45-

name: "@example/openclaw-cold-control-plane",

46-

version: "1.0.0",

47-

openclaw: { extensions: ["./index.cjs"] },

48-

},

49-

null,

50-

2,

51-

),

52-

"utf8",

53-

);

54-

fs.writeFileSync(

55-

path.join(rootDir, "openclaw.plugin.json"),

56-

JSON.stringify(

57-

{

58-

id: "cold-control-plane",

59-

name: "Cold Control Plane",

60-

configSchema: { type: "object" },

61-

providers: ["cold-model-provider"],

62-

channels: ["cold-channel"],

63-

channelConfigs: {

64-

"cold-channel": {

65-

schema: { type: "object" },

66-

},

67-

},

68-

providerAuthChoices: [

69-

{

70-

provider: "cold-model-provider",

71-

method: "api-key",

72-

choiceId: "cold-provider-api-key",

73-

choiceLabel: "Cold Provider API key",

74-

groupId: "cold-model-provider",

75-

groupLabel: "Cold Provider",

76-

optionKey: "coldProviderApiKey",

77-

cliFlag: "--cold-provider-api-key",

78-

cliOption: "--cold-provider-api-key <key>",

79-

onboardingScopes: ["text-inference"],

80-

},

81-

],

82-

},

83-

null,

84-

2,

85-

),

86-

"utf8",

87-

);

88-

fs.writeFileSync(

89-

path.join(rootDir, "index.cjs"),

90-

`require("node:fs").writeFileSync(${JSON.stringify(runtimeMarker)}, "loaded", "utf8");\nthrow new Error("runtime entry should not load for command control-plane discovery");\n`,

91-

"utf8",

92-

);

93-

return { rootDir, runtimeMarker };

94-

}

95-96-

function createColdConfig(pluginDir: string): OpenClawConfig {

97-

return {

98-

plugins: {

99-

load: { paths: [pluginDir] },

100-

entries: {

101-

"cold-control-plane": { enabled: true },

102-

},

103-

},

104-

};

19+

return makeTrackedTempDir("openclaw-command-cold-imports", tempDirs);

10520

}

1062110722

afterEach(() => {

10823

clearPluginDiscoveryCache();

10924

clearPluginManifestRegistryCache();

110-

for (const dir of tempDirs.splice(0)) {

111-

fs.rmSync(dir, { recursive: true, force: true });

112-

}

25+

cleanupTrackedTempDirs(tempDirs);

11326

});

1142711528

describe("command control-plane plugin discovery", () => {

11629

it("resolves channel setup metadata without importing plugin runtime", () => {

117-

const plugin = createColdControlPlanePlugin();

30+

const plugin = createColdPluginFixture({ rootDir: makeTempDir() });

11831

const workspaceDir = makeTempDir();

119-

const cfg = createColdConfig(plugin.rootDir);

120-

const env = hermeticEnv(workspaceDir);

32+

const cfg = createColdPluginConfig(plugin.rootDir, plugin.pluginId);

33+

const env = createColdPluginHermeticEnv(workspaceDir);

1213412235

expect(

12336

listManifestInstalledChannelIds({

12437

cfg,

12538

workspaceDir,

12639

env,

12740

}),

128-

).toContain("cold-channel");

129-

expect(fs.existsSync(plugin.runtimeMarker)).toBe(false);

41+

).toContain(plugin.channelId);

42+

expect(isColdPluginRuntimeLoaded(plugin)).toBe(false);

13043

});

1314413245

it("builds onboarding auth choices from manifest metadata without importing plugin runtime", () => {

133-

const plugin = createColdControlPlanePlugin();

46+

const plugin = createColdPluginFixture({ rootDir: makeTempDir() });

13447

const workspaceDir = makeTempDir();

135-

const cfg = createColdConfig(plugin.rootDir);

136-

const env = hermeticEnv(workspaceDir);

48+

const cfg = createColdPluginConfig(plugin.rootDir, plugin.pluginId);

49+

const env = createColdPluginHermeticEnv(workspaceDir);

1375013851

expect(

13952

buildAuthChoiceOptions({

@@ -145,9 +58,9 @@ describe("command control-plane plugin discovery", () => {

14558

}),

14659

).toContainEqual(

14760

expect.objectContaining({

148-

value: "cold-provider-api-key",

61+

value: plugin.authChoiceId,

14962

label: "Cold Provider API key",

150-

groupId: "cold-model-provider",

63+

groupId: plugin.providerId,

15164

}),

15265

);

15366

expect(

@@ -156,31 +69,31 @@ describe("command control-plane plugin discovery", () => {

15669

workspaceDir,

15770

env,

15871

}).split("|"),

159-

).toContain("cold-provider-api-key");

160-

expect(fs.existsSync(plugin.runtimeMarker)).toBe(false);

72+

).toContain(plugin.authChoiceId);

73+

expect(isColdPluginRuntimeLoaded(plugin)).toBe(false);

16174

});

1627516376

it("resolves models-list provider ownership without importing plugin runtime", async () => {

164-

const plugin = createColdControlPlanePlugin();

77+

const plugin = createColdPluginFixture({ rootDir: makeTempDir() });

16578

const workspaceDir = makeTempDir();

166-

const cfg = createColdConfig(plugin.rootDir);

167-

const env = hermeticEnv(workspaceDir, { disablePersistedRegistry: false });

79+

const cfg = createColdPluginConfig(plugin.rootDir, plugin.pluginId);

80+

const env = createColdPluginHermeticEnv(workspaceDir, { disablePersistedRegistry: false });

1688116982

await refreshPluginRegistry({

17083

config: cfg,

17184

workspaceDir,

17285

env,

17386

reason: "manual",

17487

});

175-

expect(fs.existsSync(plugin.runtimeMarker)).toBe(false);

88+

expect(isColdPluginRuntimeLoaded(plugin)).toBe(false);

1768917790

await expect(

17891

resolveProviderCatalogPluginIdsForFilter({

17992

cfg,

18093

env,

181-

providerFilter: "cold-model-provider",

94+

providerFilter: plugin.providerId,

18295

}),

183-

).resolves.toEqual(["cold-control-plane"]);

184-

expect(fs.existsSync(plugin.runtimeMarker)).toBe(false);

96+

).resolves.toEqual([plugin.pluginId]);

97+

expect(isColdPluginRuntimeLoaded(plugin)).toBe(false);

18598

});

18699

});