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

推荐订阅源

爱范儿
爱范儿
H
Help Net Security
Jina AI
Jina AI
T
The Blog of Author Tim Ferriss
宝玉的分享
宝玉的分享
博客园 - 叶小钗
Y
Y Combinator Blog
罗磊的独立博客
大猫的无限游戏
大猫的无限游戏
WordPress大学
WordPress大学
C
Check Point Blog
Recent Announcements
Recent Announcements
IT之家
IT之家
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
美团技术团队
云风的 BLOG
云风的 BLOG
雷峰网
雷峰网
H
Hackread – Cybersecurity News, Data Breaches, AI and More
S
SegmentFault 最新的问题
MyScale Blog
MyScale Blog
Apple Machine Learning Research
Apple Machine Learning Research
Microsoft Azure Blog
Microsoft Azure Blog
V
Visual Studio Blog
B
Blog

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
feat: reuse current plugin metadata for provider discover...
shakkernerd · 2026-04-28 · via Recent Commits to openclaw:main

@@ -0,0 +1,114 @@

1+

import fs from "node:fs";

2+

import os from "node:os";

3+

import path from "node:path";

4+

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

5+

import {

6+

clearCurrentPluginMetadataSnapshot,

7+

getCurrentPluginMetadataSnapshot,

8+

setCurrentPluginMetadataSnapshot,

9+

} from "./current-plugin-metadata-snapshot.js";

10+

import { resolveInstalledPluginIndexPolicyHash } from "./installed-plugin-index-policy.js";

11+

import { writePersistedInstalledPluginIndexSync } from "./installed-plugin-index-store.js";

12+

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

13+14+

function createSnapshot(

15+

params: {

16+

config?: Parameters<typeof resolveInstalledPluginIndexPolicyHash>[0];

17+

workspaceDir?: string;

18+

} = {},

19+

): PluginMetadataSnapshot {

20+

return {

21+

policyHash: resolveInstalledPluginIndexPolicyHash(params.config),

22+

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

23+

index: {

24+

version: 1,

25+

hostContractVersion: "test",

26+

compatRegistryVersion: "test",

27+

migrationVersion: 1,

28+

policyHash: resolveInstalledPluginIndexPolicyHash(params.config),

29+

generatedAtMs: 1,

30+

installRecords: {},

31+

plugins: [],

32+

diagnostics: [],

33+

},

34+

registryDiagnostics: [],

35+

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

36+

plugins: [],

37+

diagnostics: [],

38+

byPluginId: new Map(),

39+

normalizePluginId: (pluginId) => pluginId,

40+

owners: {

41+

channels: new Map(),

42+

channelConfigs: new Map(),

43+

providers: new Map(),

44+

modelCatalogProviders: new Map(),

45+

cliBackends: new Map(),

46+

setupProviders: new Map(),

47+

commandAliases: new Map(),

48+

contracts: new Map(),

49+

},

50+

metrics: {

51+

registrySnapshotMs: 0,

52+

manifestRegistryMs: 0,

53+

ownerMapsMs: 0,

54+

totalMs: 0,

55+

indexPluginCount: 0,

56+

manifestPluginCount: 0,

57+

},

58+

};

59+

}

60+61+

describe("current plugin metadata snapshot", () => {

62+

it("returns the current snapshot only for matching config policy and workspace", () => {

63+

const config = { plugins: { allow: ["demo"] } };

64+

const snapshot = createSnapshot({ config, workspaceDir: "/workspace/a" });

65+

setCurrentPluginMetadataSnapshot(snapshot, { config });

66+67+

expect(getCurrentPluginMetadataSnapshot({ config, workspaceDir: "/workspace/a" })).toBe(

68+

snapshot,

69+

);

70+

expect(getCurrentPluginMetadataSnapshot({ config })).toBe(snapshot);

71+

expect(

72+

getCurrentPluginMetadataSnapshot({

73+

config: { plugins: { allow: ["other"] } },

74+

workspaceDir: "/workspace/a",

75+

}),

76+

).toBeUndefined();

77+

expect(

78+

getCurrentPluginMetadataSnapshot({ config, workspaceDir: "/workspace/b" }),

79+

).toBeUndefined();

80+

});

81+82+

it("rejects a current snapshot when plugin load paths change", () => {

83+

const config = { plugins: { load: { paths: ["/plugins/one"] } } };

84+

const snapshot = createSnapshot({ config });

85+

setCurrentPluginMetadataSnapshot(snapshot, { config });

86+87+

expect(getCurrentPluginMetadataSnapshot({ config })).toBe(snapshot);

88+

expect(

89+

getCurrentPluginMetadataSnapshot({

90+

config: { plugins: { load: { paths: ["/plugins/two"] } } },

91+

}),

92+

).toBeUndefined();

93+

});

94+95+

it("clears the current snapshot", () => {

96+

setCurrentPluginMetadataSnapshot(createSnapshot());

97+

clearCurrentPluginMetadataSnapshot();

98+99+

expect(getCurrentPluginMetadataSnapshot()).toBeUndefined();

100+

});

101+102+

it("clears the current snapshot when the persisted installed index changes", () => {

103+

const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-plugin-metadata-"));

104+

try {

105+

setCurrentPluginMetadataSnapshot(createSnapshot());

106+107+

writePersistedInstalledPluginIndexSync(createSnapshot().index, { stateDir: tempDir });

108+109+

expect(getCurrentPluginMetadataSnapshot()).toBeUndefined();

110+

} finally {

111+

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

112+

}

113+

});

114+

});