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

推荐订阅源

J
Java Code Geeks
腾讯CDC
M
MIT News - Artificial intelligence
Y
Y Combinator Blog
L
LangChain Blog
Vercel News
Vercel News
云风的 BLOG
云风的 BLOG
GbyAI
GbyAI
Stack Overflow Blog
Stack Overflow Blog
Microsoft Azure Blog
Microsoft Azure Blog
B
Blog RSS Feed
The GitHub Blog
The GitHub Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
B
Blog
P
Proofpoint News Feed
H
Hackread – Cybersecurity News, Data Breaches, AI and More
博客园_首页
Google DeepMind News
Google DeepMind News
WordPress大学
WordPress大学
aimingoo的专栏
aimingoo的专栏
小众软件
小众软件
IT之家
IT之家
A
About on SuperTechFans
H
Help Net Security

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 command cold registry paths · opencl...
vincentkoc · 2026-04-27 · via Recent Commits to openclaw:main

@@ -0,0 +1,186 @@

1+

import fs from "node:fs";

2+

import os from "node:os";

3+

import path from "node:path";

4+

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

5+

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

6+

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

7+

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

8+

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

9+

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

10+

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

11+

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

12+13+

const tempDirs: string[] = [];

14+15+

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+

};

105+

}

106+107+

afterEach(() => {

108+

clearPluginDiscoveryCache();

109+

clearPluginManifestRegistryCache();

110+

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

111+

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

112+

}

113+

});

114+115+

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

116+

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

117+

const plugin = createColdControlPlanePlugin();

118+

const workspaceDir = makeTempDir();

119+

const cfg = createColdConfig(plugin.rootDir);

120+

const env = hermeticEnv(workspaceDir);

121+122+

expect(

123+

listManifestInstalledChannelIds({

124+

cfg,

125+

workspaceDir,

126+

env,

127+

}),

128+

).toContain("cold-channel");

129+

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

130+

});

131+132+

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

133+

const plugin = createColdControlPlanePlugin();

134+

const workspaceDir = makeTempDir();

135+

const cfg = createColdConfig(plugin.rootDir);

136+

const env = hermeticEnv(workspaceDir);

137+138+

expect(

139+

buildAuthChoiceOptions({

140+

store: {} as never,

141+

includeSkip: false,

142+

config: cfg,

143+

workspaceDir,

144+

env,

145+

}),

146+

).toContainEqual(

147+

expect.objectContaining({

148+

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

149+

label: "Cold Provider API key",

150+

groupId: "cold-model-provider",

151+

}),

152+

);

153+

expect(

154+

formatAuthChoiceChoicesForCli({

155+

config: cfg,

156+

workspaceDir,

157+

env,

158+

}).split("|"),

159+

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

160+

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

161+

});

162+163+

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

164+

const plugin = createColdControlPlanePlugin();

165+

const workspaceDir = makeTempDir();

166+

const cfg = createColdConfig(plugin.rootDir);

167+

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

168+169+

await refreshPluginRegistry({

170+

config: cfg,

171+

workspaceDir,

172+

env,

173+

reason: "manual",

174+

});

175+

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

176+177+

await expect(

178+

resolveProviderCatalogPluginIdsForFilter({

179+

cfg,

180+

env,

181+

providerFilter: "cold-model-provider",

182+

}),

183+

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

184+

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

185+

});

186+

});