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

推荐订阅源

让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
V
V2EX
WordPress大学
WordPress大学
U
Unit 42
I
InfoQ
A
About on SuperTechFans
宝玉的分享
宝玉的分享
J
Java Code Geeks
博客园 - 司徒正美
爱范儿
爱范儿
Engineering at Meta
Engineering at Meta
G
Google Developers Blog
人人都是产品经理
人人都是产品经理
小众软件
小众软件
Microsoft Security Blog
Microsoft Security Blog
L
LangChain Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Hugging Face - Blog
Hugging Face - Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
aimingoo的专栏
aimingoo的专栏
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Last Week in AI
Last Week in AI
腾讯CDC
Recent Announcements
Recent Announcements

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
refactor: unify plugin metadata snapshot callers · opencl...
steipete · 2026-05-02 · via Recent Commits to openclaw:main
Original file line numberDiff line numberDiff line change

@@ -6,6 +6,20 @@ const pluginRegistryMocks = vi.hoisted(() => {

66

loadPluginManifestRegistryForInstalledIndex: loadManifestRegistry,

77

loadPluginManifestRegistryForPluginRegistry: loadManifestRegistry,

88

loadPluginRegistrySnapshot: vi.fn(() => ({ plugins: [] })),

9+

loadPluginMetadataSnapshot: vi.fn((params: unknown) => {

10+

const registry = loadManifestRegistry(params) ?? { plugins: [], diagnostics: [] };

11+

return {

12+

index: {

13+

plugins: registry.plugins.map((plugin: { id: string; origin?: string }) => ({

14+

pluginId: plugin.id,

15+

origin: plugin.origin ?? "global",

16+

enabled: true,

17+

enabledByDefault: true,

18+

})),

19+

},

20+

plugins: registry.plugins,

21+

};

22+

}),

923

};

1024

});

1125

@@ -20,6 +34,10 @@ vi.mock("../plugins/plugin-registry.js", () => ({

2034

loadPluginRegistrySnapshot: pluginRegistryMocks.loadPluginRegistrySnapshot,

2135

}));

2236
37+

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

38+

loadPluginMetadataSnapshot: pluginRegistryMocks.loadPluginMetadataSnapshot,

39+

}));

40+
2341

import {

2442

resetProviderAuthAliasMapCacheForTest,

2543

resolveProviderIdForAuth,

@@ -32,6 +50,7 @@ describe("provider auth aliases", () => {

3250

pluginRegistryMocks.loadPluginManifestRegistryForPluginRegistry.mockReset();

3351

pluginRegistryMocks.loadPluginRegistrySnapshot.mockReset();

3452

pluginRegistryMocks.loadPluginRegistrySnapshot.mockReturnValue({ plugins: [] });

53+

pluginRegistryMocks.loadPluginMetadataSnapshot.mockClear();

3554

});

3655
3756

it("treats deprecated auth choice ids as provider auth aliases", () => {

Original file line numberDiff line numberDiff line change

@@ -5,8 +5,8 @@ import {

55

normalizePluginConfigId,

66

} from "../plugins/plugin-config-trust.js";

77

import { resolvePluginControlPlaneFingerprint } from "../plugins/plugin-control-plane-context.js";

8+

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

89

import type { PluginOrigin } from "../plugins/plugin-origin.types.js";

9-

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

1010

import { normalizeProviderId } from "./provider-id.js";

1111
1212

export type ProviderAuthAliasLookupParams = {

@@ -118,15 +118,14 @@ export function resolveProviderAuthAliasMap(

118118

if (cached) {

119119

return cached;

120120

}

121-

const registry = loadPluginManifestRegistryForPluginRegistry({

122-

config: params?.config,

121+

const snapshot = loadPluginMetadataSnapshot({

122+

config: params?.config ?? {},

123123

workspaceDir: params?.workspaceDir,

124124

env,

125-

includeDisabled: true,

126125

});

127126

const preferredAliases = new Map<string, ProviderAuthAliasCandidate>();

128127

const aliases: Record<string, string> = Object.create(null) as Record<string, string>;

129-

for (const plugin of registry.plugins) {

128+

for (const plugin of snapshot.plugins) {

130129

if (!shouldUsePluginAuthAliases(plugin, params)) {

131130

continue;

132131

}

Original file line numberDiff line numberDiff line change

@@ -0,0 +1,68 @@

1+

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

2+
3+

const loadPluginMetadataSnapshot = vi.hoisted(() => vi.fn());

4+
5+

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

6+

loadPluginMetadataSnapshot,

7+

}));

8+
9+

import { resolveReadOnlyChannelCommandDefaults } from "./read-only-command-defaults.js";

10+
11+

describe("resolveReadOnlyChannelCommandDefaults", () => {

12+

beforeEach(() => {

13+

loadPluginMetadataSnapshot.mockReset();

14+

loadPluginMetadataSnapshot.mockReturnValue({

15+

index: { plugins: [] },

16+

plugins: [],

17+

});

18+

});

19+
20+

it("resolves command defaults from the shared metadata snapshot", () => {

21+

const env = { HOME: "/home/demo" } as NodeJS.ProcessEnv;

22+

loadPluginMetadataSnapshot.mockReturnValue({

23+

index: {

24+

plugins: [

25+

{

26+

pluginId: "demo",

27+

origin: "global",

28+

enabled: true,

29+

enabledByDefault: true,

30+

},

31+

],

32+

},

33+

plugins: [

34+

{

35+

id: "demo",

36+

origin: "global",

37+

channels: ["demo"],

38+

channelConfigs: {

39+

demo: {

40+

commands: {

41+

nativeCommandsAutoEnabled: true,

42+

nativeSkillsAutoEnabled: false,

43+

},

44+

},

45+

},

46+

},

47+

],

48+

});

49+
50+

expect(

51+

resolveReadOnlyChannelCommandDefaults("demo", {

52+

config: {},

53+

env,

54+

stateDir: "/state",

55+

workspaceDir: "/workspace",

56+

}),

57+

).toEqual({

58+

nativeCommandsAutoEnabled: true,

59+

nativeSkillsAutoEnabled: false,

60+

});

61+

expect(loadPluginMetadataSnapshot).toHaveBeenCalledWith({

62+

config: {},

63+

env,

64+

stateDir: "/state",

65+

workspaceDir: "/workspace",

66+

});

67+

});

68+

});

Original file line numberDiff line numberDiff line change

@@ -1,9 +1,8 @@

11

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

22

import { isBlockedObjectKey } from "../../infra/prototype-keys.js";

33

import { isInstalledPluginEnabled } from "../../plugins/installed-plugin-index.js";

4-

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

54

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

6-

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

5+

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

76

import { normalizeOptionalString } from "../../shared/string-coerce.js";

87

import type { ChannelPlugin } from "./types.plugin.js";

98

@@ -65,20 +64,13 @@ export function resolveReadOnlyChannelCommandDefaults(

6564

if (!normalizedChannelId || !isSafeManifestChannelId(normalizedChannelId)) {

6665

return undefined;

6766

}

68-

const index = loadPluginRegistrySnapshot({

67+

const snapshot = loadPluginMetadataSnapshot({

6968

config: options.config,

7069

stateDir: options.stateDir,

7170

workspaceDir: options.workspaceDir,

7271

env: options.env ?? process.env,

7372

});

74-

const registry = loadPluginManifestRegistryForInstalledIndex({

75-

index,

76-

config: options.config,

77-

workspaceDir: options.workspaceDir,

78-

env: options.env ?? process.env,

79-

includeDisabled: true,

80-

});

81-

for (const record of registry.plugins) {

73+

for (const record of snapshot.plugins) {

8274

if (!record.channels.includes(normalizedChannelId)) {

8375

continue;

8476

}

@@ -88,7 +80,7 @@ export function resolveReadOnlyChannelCommandDefaults(

8880

) {

8981

continue;

9082

}

91-

if (!isInstalledPluginEnabled(index, record.id, options.config)) {

83+

if (!isInstalledPluginEnabled(snapshot.index, record.id, options.config)) {

9284

continue;

9385

}

9486

const channelConfigValue = record.channelConfigs

Original file line numberDiff line numberDiff line change

@@ -0,0 +1,68 @@

1+

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

2+
3+

const loadPluginMetadataSnapshot = vi.hoisted(() => vi.fn());

4+
5+

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

6+

loadPluginMetadataSnapshot,

7+

}));

8+
9+

import { resolveManifestContractRuntimePluginResolution } from "./manifest-contract-runtime.js";

10+
11+

describe("resolveManifestContractRuntimePluginResolution", () => {

12+

beforeEach(() => {

13+

loadPluginMetadataSnapshot.mockReset();

14+

loadPluginMetadataSnapshot.mockReturnValue({

15+

index: { plugins: [] },

16+

plugins: [],

17+

});

18+

});

19+
20+

it("resolves contract plugins from the shared metadata snapshot", () => {

21+

loadPluginMetadataSnapshot.mockReturnValue({

22+

index: {

23+

plugins: [

24+

{

25+

pluginId: "bundled-search",

26+

origin: "bundled",

27+

enabled: true,

28+

enabledByDefault: true,

29+

},

30+

{

31+

pluginId: "external-search",

32+

origin: "global",

33+

enabled: true,

34+

enabledByDefault: true,

35+

},

36+

],

37+

},

38+

plugins: [

39+

{

40+

id: "bundled-search",

41+

origin: "bundled",

42+

contracts: { webSearchProviders: ["search"] },

43+

},

44+

{

45+

id: "external-search",

46+

origin: "global",

47+

contracts: { webSearchProviders: ["search"] },

48+

},

49+

],

50+

});

51+
52+

expect(

53+

resolveManifestContractRuntimePluginResolution({

54+

cfg: {},

55+

contract: "webSearchProviders",

56+

value: "search",

57+

}),

58+

).toEqual({

59+

pluginIds: ["bundled-search", "external-search"],

60+

bundledCompatPluginIds: ["bundled-search"],

61+

});

62+

expect(loadPluginMetadataSnapshot).toHaveBeenCalledWith({

63+

config: {},

64+

env: process.env,

65+

preferPersisted: false,

66+

});

67+

});

68+

});

Original file line numberDiff line numberDiff line change

@@ -3,9 +3,8 @@ import {

33

hasManifestContractValue,

44

listAvailableManifestContractPlugins,

55

} from "./manifest-contract-eligibility.js";

6-

import { loadPluginManifestRegistryForInstalledIndex } from "./manifest-registry-installed.js";

76

import type { PluginManifestContractListKey } from "./manifest-registry.js";

8-

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

7+

import { loadPluginMetadataSnapshot } from "./plugin-metadata-snapshot.js";

98
109

export type ManifestContractRuntimePluginResolution = {

1110

pluginIds: string[];

@@ -21,17 +20,12 @@ export function resolveManifestContractRuntimePluginResolution(params: {

2120

contract: PluginManifestContractListKey;

2221

value?: string;

2322

}): ManifestContractRuntimePluginResolution {

24-

const index = loadPluginRegistrySnapshot({

25-

config: params.cfg,

23+

const snapshot = loadPluginMetadataSnapshot({

24+

config: params.cfg ?? {},

2625

env: process.env,

2726

...DEMAND_ONLY_CONTRACT_LOOKUP_OPTIONS,

2827

});

29-

const allContractPlugins = loadPluginManifestRegistryForInstalledIndex({

30-

index,

31-

config: params.cfg,

32-

env: process.env,

33-

includeDisabled: true,

34-

}).plugins.filter((plugin) =>

28+

const allContractPlugins = snapshot.plugins.filter((plugin) =>

3529

hasManifestContractValue({

3630

plugin,

3731

contract: params.contract,

@@ -42,7 +36,7 @@ export function resolveManifestContractRuntimePluginResolution(params: {

4236

.filter((plugin) => plugin.origin === "bundled")

4337

.map((plugin) => plugin.id);

4438

const pluginIds = listAvailableManifestContractPlugins({

45-

snapshot: { index, plugins: allContractPlugins },

39+

snapshot: { index: snapshot.index, plugins: allContractPlugins },

4640

contract: params.contract,

4741

value: params.value,

4842

config: params.cfg,

Original file line numberDiff line numberDiff line change

@@ -180,7 +180,9 @@ function loadPluginMetadataSnapshotImpl(

180180

const registryResult = loadPluginRegistrySnapshotWithMetadata({

181181

config: params.config,

182182

workspaceDir: params.workspaceDir,

183+

...(params.stateDir ? { stateDir: params.stateDir } : {}),

183184

env: params.env,

185+

...(params.preferPersisted !== undefined ? { preferPersisted: params.preferPersisted } : {}),

184186

...(params.index ? { index: params.index } : {}),

185187

});

186188

const registrySnapshotMs = performance.now() - registryStartedAt;

Original file line numberDiff line numberDiff line change

@@ -55,6 +55,8 @@ export type PluginMetadataManifestView = Pick<PluginMetadataSnapshot, "index" |

5555

export type LoadPluginMetadataSnapshotParams = {

5656

config: OpenClawConfig;

5757

workspaceDir?: string;

58+

stateDir?: string;

5859

env: NodeJS.ProcessEnv;

5960

index?: InstalledPluginIndex;

61+

preferPersisted?: boolean;

6062

};