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

推荐订阅源

The Cloudflare Blog
L
LangChain Blog
WordPress大学
WordPress大学
V
V2EX
M
MIT News - Artificial intelligence
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Stack Overflow Blog
Stack Overflow Blog
J
Java Code Geeks
F
Fortinet All Blogs
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
腾讯CDC
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
D
Docker
Recent Announcements
Recent Announcements
GbyAI
GbyAI
博客园 - 叶小钗
小众软件
小众软件
Hugging Face - Blog
Hugging Face - Blog
T
The Blog of Author Tim Ferriss
人人都是产品经理
人人都是产品经理
Engineering at Meta
Engineering at Meta
Y
Y Combinator Blog
雷峰网
雷峰网
The GitHub Blog
The GitHub 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
fix(plugins): repair legacy npm declaration stubs · openc...
vincentkoc · 2026-05-14 · via Recent Commits to openclaw:main

@@ -1,4 +1,7 @@

1-

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

1+

import fs from "node:fs";

2+

import os from "node:os";

3+

import path from "node:path";

4+

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

25

import { resolveRegistryUpdateChannel } from "../../../infra/update-channels.js";

36

import { resolveNpmInstallSpecsForUpdateChannel } from "../../../plugins/install-channel-specs.js";

47

import { VERSION } from "../../../version.js";

@@ -48,11 +51,40 @@ const mocks = vi.hoisted(() => ({

4851

(entry: { label?: string; id?: string }) => entry.label ?? entry.id ?? "plugin",

4952

),

5053

resolveDefaultPluginExtensionsDir: vi.fn(() => "/tmp/openclaw-plugins"),

54+

resolvePluginInstallDir: vi.fn(

55+

(pluginId: string, extensionsDir = "/tmp/openclaw-plugins") => `${extensionsDir}/${pluginId}`,

56+

),

57+

validatePluginId: vi.fn(() => null),

5158

resolveProviderInstallCatalogEntries: vi.fn(),

5259

updateNpmInstalledPlugins: vi.fn(),

5360

writePersistedInstalledPluginIndexInstallRecords: vi.fn(),

5461

}));

556263+

const tempDirs: string[] = [];

64+65+

function makeTempDir(): string {

66+

const dir = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-plugin-stub-repair-"));

67+

tempDirs.push(dir);

68+

return dir;

69+

}

70+71+

function writeLegacyNpmDeclarationStub(params: {

72+

pluginDir: string;

73+

pluginId: string;

74+

npmSpec: string;

75+

}): void {

76+

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

77+

fs.writeFileSync(

78+

path.join(params.pluginDir, "openclaw.extension.json"),

79+

JSON.stringify({

80+

name: params.pluginId,

81+

type: "npm",

82+

npmSpec: params.npmSpec,

83+

}),

84+

"utf8",

85+

);

86+

}

87+5688

vi.mock("../../../channels/plugins/catalog.js", () => ({

5789

listChannelPluginCatalogEntries: mocks.listChannelPluginCatalogEntries,

5890

}));

@@ -70,6 +102,8 @@ vi.mock("../../../plugins/installed-plugin-index.js", async (importOriginal) =>

7010271103

vi.mock("../../../plugins/install-paths.js", () => ({

72104

resolveDefaultPluginExtensionsDir: mocks.resolveDefaultPluginExtensionsDir,

105+

resolvePluginInstallDir: mocks.resolvePluginInstallDir,

106+

validatePluginId: mocks.validatePluginId,

73107

}));

7410875109

vi.mock("../../../plugins/install.js", () => ({

@@ -155,6 +189,12 @@ describe("repairMissingConfiguredPluginInstalls", () => {

155189

});

156190

});

157191192+

afterEach(() => {

193+

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

194+

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

195+

}

196+

});

197+158198

it("installs a missing configured OpenClaw channel plugin from npm by default", async () => {

159199

mocks.listChannelPluginCatalogEntries.mockReturnValue([

160200

{

@@ -2311,6 +2351,66 @@ describe("repairMissingConfiguredPluginInstalls", () => {

23112351

]);

23122352

});

231323532354+

it("repairs a configured plugin from a legacy npm declaration stub", async () => {

2355+

const root = makeTempDir();

2356+

const pluginDir = path.join(root, "extensions", "guardrail-bridge");

2357+

writeLegacyNpmDeclarationStub({

2358+

pluginDir,

2359+

pluginId: "guardrail-bridge",

2360+

npmSpec: "@guardrail-bridge/guardrail-bridge@1.0.0",

2361+

});

2362+

mocks.installPluginFromNpmSpec.mockResolvedValueOnce({

2363+

ok: true,

2364+

pluginId: "guardrail-bridge",

2365+

targetDir: "/tmp/openclaw-plugins/guardrail-bridge",

2366+

version: "1.0.0",

2367+

npmResolution: {

2368+

name: "@guardrail-bridge/guardrail-bridge",

2369+

version: "1.0.0",

2370+

resolvedSpec: "@guardrail-bridge/guardrail-bridge@1.0.0",

2371+

integrity: "sha512-guardrail",

2372+

resolvedAt: "2026-05-01T00:00:00.000Z",

2373+

},

2374+

});

2375+2376+

const { repairMissingConfiguredPluginInstalls } =

2377+

await import("./missing-configured-plugin-install.js");

2378+

const result = await repairMissingConfiguredPluginInstalls({

2379+

cfg: {

2380+

plugins: {

2381+

load: {

2382+

paths: [pluginDir],

2383+

},

2384+

entries: {

2385+

"guardrail-bridge": { enabled: true },

2386+

},

2387+

},

2388+

},

2389+

env: {},

2390+

});

2391+2392+

expectRecordFields(mockCallArg(mocks.installPluginFromNpmSpec), {

2393+

spec: "@guardrail-bridge/guardrail-bridge@1.0.0",

2394+

expectedPluginId: "guardrail-bridge",

2395+

extensionsDir: "/tmp/openclaw-plugins",

2396+

});

2397+

expect(mockCallArg(mocks.installPluginFromNpmSpec).trustedSourceLinkedOfficialInstall).toBe(

2398+

undefined,

2399+

);

2400+

const records = mockCallArg(mocks.writePersistedInstalledPluginIndexInstallRecords);

2401+

expectRecordFields((records as Record<string, unknown>)["guardrail-bridge"], {

2402+

source: "npm",

2403+

spec: "@guardrail-bridge/guardrail-bridge@1.0.0",

2404+

installPath: "/tmp/openclaw-plugins/guardrail-bridge",

2405+

version: "1.0.0",

2406+

resolvedName: "@guardrail-bridge/guardrail-bridge",

2407+

});

2408+

expect(result.changes).toEqual([

2409+

'Installed missing configured plugin "guardrail-bridge" from @guardrail-bridge/guardrail-bridge@1.0.0.',

2410+

]);

2411+

expect(result.warnings).toStrictEqual([]);

2412+

});

2413+23142414

it("does not install a configured external web search plugin when search is disabled", async () => {

23152415

mocks.listOfficialExternalPluginCatalogEntries.mockReturnValue([

23162416

{