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

推荐订阅源

大猫的无限游戏
大猫的无限游戏
阮一峰的网络日志
阮一峰的网络日志
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
WordPress大学
WordPress大学
博客园 - 叶小钗
Hugging Face - Blog
Hugging Face - Blog
博客园 - 司徒正美
Last Week in AI
Last Week in AI
罗磊的独立博客
量子位
Jina AI
Jina AI
T
Tailwind CSS Blog
Apple Machine Learning Research
Apple Machine Learning Research
IT之家
IT之家
美团技术团队
雷峰网
雷峰网
爱范儿
爱范儿
S
SegmentFault 最新的问题
小众软件
小众软件
月光博客
月光博客
酷 壳 – CoolShell
酷 壳 – CoolShell
人人都是产品经理
人人都是产品经理
The Cloudflare Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报

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(config): use plugin channel schemas in dry-run · open...
giodl73-repo · 2026-05-14 · via Recent Commits to openclaw:main

@@ -4,6 +4,8 @@ import path from "node:path";

44

import { Command } from "commander";

55

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

66

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

7+

import type { PluginManifestRecord, PluginManifestRegistry } from "../plugins/manifest-registry.js";

8+

import type { PluginMetadataSnapshot } from "../plugins/plugin-metadata-snapshot.js";

79

import { createCliRuntimeCapture, mockRuntimeModule } from "./test-runtime-capture.js";

810911

/**

@@ -21,6 +23,7 @@ const mockWriteConfigFile = vi.fn<

2123

>(async () => {});

2224

const mockResolveSecretRefValue = vi.fn();

2325

const mockReadBestEffortRuntimeConfigSchema = vi.fn();

26+

const mockLoadPluginMetadataSnapshot = vi.fn(() => createPluginMetadataSnapshot());

24272528

vi.mock("../config/config.js", async (importOriginal) => {

2629

const actual = await importOriginal<typeof import("../config/config.js")>();

@@ -46,6 +49,14 @@ vi.mock("../config/runtime-schema.js", () => ({

4649

readBestEffortRuntimeConfigSchema: () => mockReadBestEffortRuntimeConfigSchema(),

4750

}));

485152+

vi.mock("../plugins/plugin-metadata-snapshot.js", async (importOriginal) => {

53+

const actual = await importOriginal<typeof import("../plugins/plugin-metadata-snapshot.js")>();

54+

return {

55+

...actual,

56+

loadPluginMetadataSnapshot: (...args: unknown[]) => mockLoadPluginMetadataSnapshot(...args),

57+

};

58+

});

59+4960

const { defaultRuntime, resetRuntimeCapture } = createCliRuntimeCapture();

5061

const mockLog = defaultRuntime.log;

5162

const mockError = defaultRuntime.error;

@@ -107,6 +118,98 @@ function withRuntimeDefaults(resolved: OpenClawConfig): OpenClawConfig {

107118

};

108119

}

109120121+

function createPluginManifestRecord(

122+

overrides: Partial<PluginManifestRecord> & Pick<PluginManifestRecord, "id">,

123+

): PluginManifestRecord {

124+

return {

125+

channels: [],

126+

cliBackends: [],

127+

hooks: [],

128+

manifestPath: `/tmp/${overrides.id}/openclaw.plugin.json`,

129+

origin: "bundled",

130+

providers: [],

131+

rootDir: `/tmp/${overrides.id}`,

132+

skills: [],

133+

source: `/tmp/${overrides.id}/index.js`,

134+

...overrides,

135+

};

136+

}

137+138+

function createPluginMetadataSnapshot(

139+

manifestRegistry: PluginManifestRegistry = { diagnostics: [], plugins: [] },

140+

): PluginMetadataSnapshot {

141+

const plugins = manifestRegistry.plugins;

142+

return {

143+

policyHash: "test-policy",

144+

index: {

145+

version: 1,

146+

hostContractVersion: "test",

147+

compatRegistryVersion: "test",

148+

migrationVersion: 1,

149+

policyHash: "test-policy",

150+

generatedAtMs: 0,

151+

installRecords: {},

152+

plugins: [],

153+

diagnostics: [],

154+

},

155+

registryDiagnostics: [],

156+

manifestRegistry,

157+

plugins,

158+

diagnostics: manifestRegistry.diagnostics,

159+

byPluginId: new Map(plugins.map((plugin) => [plugin.id, plugin])),

160+

normalizePluginId: (pluginId: string) => pluginId.trim().toLowerCase(),

161+

owners: {

162+

channels: new Map(),

163+

channelConfigs: new Map(),

164+

providers: new Map(),

165+

modelCatalogProviders: new Map(),

166+

cliBackends: new Map(),

167+

setupProviders: new Map(),

168+

commandAliases: new Map(),

169+

contracts: new Map(),

170+

},

171+

metrics: {

172+

registrySnapshotMs: 0,

173+

manifestRegistryMs: 0,

174+

ownerMapsMs: 0,

175+

totalMs: 0,

176+

indexPluginCount: 0,

177+

manifestPluginCount: plugins.length,

178+

},

179+

};

180+

}

181+182+

function setExternalFeishuSchema() {

183+

mockLoadPluginMetadataSnapshot.mockReturnValue(

184+

createPluginMetadataSnapshot({

185+

diagnostics: [],

186+

plugins: [

187+

createPluginManifestRecord({

188+

id: "openclaw-lark",

189+

origin: "external",

190+

channels: ["feishu"],

191+

channelConfigs: {

192+

feishu: {

193+

schema: {

194+

type: "object",

195+

properties: {

196+

appId: { type: "string" },

197+

appSecret: { type: "string" },

198+

replyMode: { type: "string", enum: ["thread", "direct"] },

199+

footer: { type: "string" },

200+

},

201+

required: ["appId", "appSecret"],

202+

additionalProperties: false,

203+

},

204+

uiHints: {},

205+

},

206+

},

207+

}),

208+

],

209+

}),

210+

);

211+

}

212+110213

function makeInvalidSnapshot(params: {

111214

issues: ConfigFileSnapshot["issues"];

112215

path?: string;

@@ -233,6 +336,7 @@ describe("config cli", () => {

233336

beforeEach(() => {

234337

vi.clearAllMocks();

235338

resetRuntimeCapture();

339+

mockLoadPluginMetadataSnapshot.mockReturnValue(createPluginMetadataSnapshot());

236340

mockReadBestEffortRuntimeConfigSchema.mockResolvedValue({

237341

schema: {

238342

$schema: "http://json-schema.org/draft-07/schema#",

@@ -1268,6 +1372,35 @@ describe("config cli", () => {

12681372

expectErrorIncludes("Dry run failed: config schema validation failed.");

12691373

});

127013741375+

it("dry-runs config patch channel fields against plugin-owned schemas", async () => {

1376+

setExternalFeishuSchema();

1377+

const resolved: OpenClawConfig = {

1378+

channels: {

1379+

feishu: {

1380+

appId: "app-id",

1381+

appSecret: "secret",

1382+

},

1383+

},

1384+

};

1385+

setSnapshot(resolved, resolved);

1386+

const pathname = writeTempJson5File("openclaw-config-plugin-channel-schema", {

1387+

channels: {

1388+

feishu: {

1389+

appId: "app-id",

1390+

appSecret: "secret",

1391+

replyMode: "thread",

1392+

footer: "OpenClaw",

1393+

},

1394+

},

1395+

});

1396+1397+

await runConfigCommand(["config", "patch", "--file", pathname, "--dry-run"]);

1398+1399+

expect(mockWriteConfigFile).not.toHaveBeenCalled();

1400+

expect(mockError).not.toHaveBeenCalledWith(expect.stringContaining("replyMode"));

1401+

expect(mockError).not.toHaveBeenCalledWith(expect.stringContaining("footer"));

1402+

});

1403+12711404

it("fails dry-run when unsupported mutable paths receive SecretRef objects in value/json mode", async () => {

12721405

const resolved: OpenClawConfig = {

12731406

gateway: { port: 18789 },