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

推荐订阅源

IT之家
IT之家
博客园_首页
S
SegmentFault 最新的问题
罗磊的独立博客
博客园 - 【当耐特】
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
阮一峰的网络日志
阮一峰的网络日志
D
Docker
雷峰网
雷峰网
Google DeepMind News
Google DeepMind News
博客园 - 司徒正美
V
V2EX
大猫的无限游戏
大猫的无限游戏
V
Visual Studio Blog
腾讯CDC
宝玉的分享
宝玉的分享
酷 壳 – CoolShell
酷 壳 – CoolShell
人人都是产品经理
人人都是产品经理
T
Tailwind CSS Blog
Vercel News
Vercel News
H
Help Net Security
博客园 - Franky
D
DataBreaches.Net
aimingoo的专栏
aimingoo的专栏

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(plugins): recover managed-npm external plugins after ...
p3nchan · 2026-05-05 · via Recent Commits to openclaw:main

@@ -1,6 +1,8 @@

11

import fs from "node:fs";

22

import path from "node:path";

33

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

4+

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

5+

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

46

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

57

import { buildPluginRegistrySnapshotReport, buildPluginSnapshotReport } from "./status.js";

68

import {

@@ -17,11 +19,120 @@ function makeTempDir() {

1719

return makeTrackedTempDir("openclaw-plugin-status", tempDirs);

1820

}

192122+

function writeManagedNpmPlugin(params: {

23+

stateDir: string;

24+

packageName: string;

25+

pluginId: string;

26+

version: string;

27+

dependencySpec?: string;

28+

}): string {

29+

const npmRoot = path.join(params.stateDir, "npm");

30+

const rootManifestPath = path.join(npmRoot, "package.json");

31+

fs.mkdirSync(npmRoot, { recursive: true });

32+

const rootManifest = fs.existsSync(rootManifestPath)

33+

? (JSON.parse(fs.readFileSync(rootManifestPath, "utf8")) as {

34+

dependencies?: Record<string, string>;

35+

})

36+

: {};

37+

fs.writeFileSync(

38+

rootManifestPath,

39+

JSON.stringify(

40+

{

41+

...rootManifest,

42+

private: true,

43+

dependencies: {

44+

...rootManifest.dependencies,

45+

[params.packageName]: params.dependencySpec ?? params.version,

46+

},

47+

},

48+

null,

49+

2,

50+

),

51+

"utf8",

52+

);

53+54+

const packageDir = path.join(npmRoot, "node_modules", params.packageName);

55+

fs.mkdirSync(path.join(packageDir, "dist"), { recursive: true });

56+

fs.writeFileSync(

57+

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

58+

JSON.stringify({

59+

name: params.packageName,

60+

version: params.version,

61+

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

62+

}),

63+

"utf8",

64+

);

65+

fs.writeFileSync(

66+

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

67+

JSON.stringify({

68+

id: params.pluginId,

69+

name: "WhatsApp",

70+

configSchema: { type: "object" },

71+

}),

72+

"utf8",

73+

);

74+

fs.writeFileSync(path.join(packageDir, "dist", "index.js"), "export {};\n", "utf8");

75+

return packageDir;

76+

}

77+2078

afterEach(() => {

2179

cleanupTrackedTempDirs(tempDirs);

2280

});

23812482

describe("buildPluginRegistrySnapshotReport", () => {

83+

it("keeps recovered managed npm plugins visible when the persisted registry is stale", () => {

84+

const tempRoot = makeTempDir();

85+

const stateDir = path.join(tempRoot, "state");

86+

const env = {

87+

...createColdPluginHermeticEnv(tempRoot, {

88+

bundledPluginsDir: makeTempDir(),

89+

disablePersistedRegistry: false,

90+

}),

91+

OPENCLAW_DISABLE_BUNDLED_PLUGINS: "1",

92+

OPENCLAW_STATE_DIR: stateDir,

93+

};

94+

const config = {

95+

plugins: {

96+

entries: {

97+

whatsapp: { enabled: true },

98+

},

99+

},

100+

};

101+

const whatsappDir = writeManagedNpmPlugin({

102+

stateDir,

103+

packageName: "@openclaw/whatsapp",

104+

pluginId: "whatsapp",

105+

version: "2026.5.2",

106+

});

107+

const staleIndex = loadInstalledPluginIndex({

108+

config,

109+

env,

110+

installRecords: {},

111+

});

112+

expect(staleIndex.plugins.some((plugin) => plugin.pluginId === "whatsapp")).toBe(false);

113+

writePersistedInstalledPluginIndexSync(staleIndex, { stateDir });

114+115+

const report = buildPluginRegistrySnapshotReport({

116+

config,

117+

env,

118+

});

119+120+

expect(report.registrySource).toBe("derived");

121+

expect(report.registryDiagnostics).toContainEqual(

122+

expect.objectContaining({ code: "persisted-registry-stale-source" }),

123+

);

124+

expect(report.plugins).toEqual(

125+

expect.arrayContaining([

126+

expect.objectContaining({

127+

id: "whatsapp",

128+

name: "WhatsApp",

129+

source: fs.realpathSync(path.join(whatsappDir, "dist", "index.js")),

130+

status: "loaded",

131+

}),

132+

]),

133+

);

134+

});

135+25136

it("reconstructs list metadata from indexed manifests without importing plugin runtime", () => {

26137

const fixture = createColdPluginFixture({

27138

rootDir: makeTempDir(),