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

推荐订阅源

爱范儿
爱范儿
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
fix: stage bundled plugin runtime deps safely · openclaw/...
steipete · 2026-04-27 · via Recent Commits to openclaw:main

@@ -0,0 +1,191 @@

1+

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

2+3+

const applyPluginAutoEnable = vi.hoisted(() =>

4+

vi.fn((params: { config: unknown }) => ({

5+

config: params.config,

6+

changes: [],

7+

autoEnabledReasons: {},

8+

})),

9+

);

10+

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

11+

const loadGatewayStartupPlugins = vi.hoisted(() =>

12+

vi.fn((_params: unknown) => ({

13+

pluginRegistry: { diagnostics: [], gatewayHandlers: {}, plugins: [] },

14+

gatewayMethods: ["ping"],

15+

})),

16+

);

17+

const repairBundledRuntimeDepsInstallRootAsync = vi.hoisted(() =>

18+

vi.fn(async (_params: unknown) => ({})),

19+

);

20+

const resolveBundledRuntimeDependencyPackageInstallRoot = vi.hoisted(() =>

21+

vi.fn((_packageRoot: string, _params: unknown) => "/runtime"),

22+

);

23+

const resolveConfiguredDeferredChannelPluginIds = vi.hoisted(() => vi.fn((_params: unknown) => []));

24+

const resolveGatewayStartupPluginIds = vi.hoisted(() => vi.fn((_params: unknown) => ["telegram"]));

25+

const resolveOpenClawPackageRootSync = vi.hoisted(() => vi.fn((_params: unknown) => "/package"));

26+

const runChannelPluginStartupMaintenance = vi.hoisted(() =>

27+

vi.fn(async (_params: unknown) => undefined),

28+

);

29+

const runStartupSessionMigration = vi.hoisted(() => vi.fn(async (_params: unknown) => undefined));

30+

const scanBundledPluginRuntimeDeps = vi.hoisted(() =>

31+

vi.fn((_params: unknown) => ({

32+

deps: [{ name: "grammy", version: "1.37.0", pluginIds: ["telegram"] }],

33+

missing: [{ name: "grammy", version: "1.37.0", pluginIds: ["telegram"] }],

34+

conflicts: [],

35+

})),

36+

);

37+38+

vi.mock("../agents/agent-scope.js", () => ({

39+

resolveAgentWorkspaceDir: () => "/workspace",

40+

resolveDefaultAgentId: () => "default",

41+

}));

42+43+

vi.mock("../agents/subagent-registry.js", () => ({

44+

initSubagentRegistry: () => initSubagentRegistry(),

45+

}));

46+47+

vi.mock("../channels/plugins/lifecycle-startup.js", () => ({

48+

runChannelPluginStartupMaintenance: (params: unknown) =>

49+

runChannelPluginStartupMaintenance(params),

50+

}));

51+52+

vi.mock("../config/plugin-auto-enable.js", () => ({

53+

applyPluginAutoEnable: (params: { config: unknown }) => applyPluginAutoEnable(params),

54+

}));

55+56+

vi.mock("../infra/openclaw-root.js", () => ({

57+

resolveOpenClawPackageRootSync: (params: unknown) => resolveOpenClawPackageRootSync(params),

58+

}));

59+60+

vi.mock("../plugins/bundled-runtime-deps.js", () => ({

61+

repairBundledRuntimeDepsInstallRootAsync: (params: unknown) =>

62+

repairBundledRuntimeDepsInstallRootAsync(params),

63+

resolveBundledRuntimeDependencyPackageInstallRoot: (packageRoot: string, params: unknown) =>

64+

resolveBundledRuntimeDependencyPackageInstallRoot(packageRoot, params),

65+

scanBundledPluginRuntimeDeps: (params: unknown) => scanBundledPluginRuntimeDeps(params),

66+

}));

67+68+

vi.mock("../plugins/channel-plugin-ids.js", () => ({

69+

resolveConfiguredDeferredChannelPluginIds: (params: unknown) =>

70+

resolveConfiguredDeferredChannelPluginIds(params),

71+

resolveGatewayStartupPluginIds: (params: unknown) => resolveGatewayStartupPluginIds(params),

72+

}));

73+74+

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

75+

createEmptyPluginRegistry: () => ({ diagnostics: [], gatewayHandlers: {}, plugins: [] }),

76+

}));

77+78+

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

79+

getActivePluginRegistry: () => undefined,

80+

setActivePluginRegistry: vi.fn(),

81+

}));

82+83+

vi.mock("./server-methods-list.js", () => ({

84+

listGatewayMethods: () => ["ping"],

85+

}));

86+87+

vi.mock("./server-methods.js", () => ({

88+

coreGatewayHandlers: {},

89+

}));

90+91+

vi.mock("./server-plugin-bootstrap.js", () => ({

92+

loadGatewayStartupPlugins: (params: unknown) => loadGatewayStartupPlugins(params),

93+

}));

94+95+

vi.mock("./server-startup-session-migration.js", () => ({

96+

runStartupSessionMigration: (params: unknown) => runStartupSessionMigration(params),

97+

}));

98+99+

function createLog() {

100+

return {

101+

info: vi.fn(),

102+

warn: vi.fn(),

103+

error: vi.fn(),

104+

debug: vi.fn(),

105+

};

106+

}

107+108+

describe("prepareGatewayPluginBootstrap runtime-deps staging", () => {

109+

beforeEach(() => {

110+

applyPluginAutoEnable.mockClear();

111+

initSubagentRegistry.mockClear();

112+

loadGatewayStartupPlugins.mockClear();

113+

repairBundledRuntimeDepsInstallRootAsync.mockReset().mockResolvedValue({});

114+

resolveBundledRuntimeDependencyPackageInstallRoot.mockClear();

115+

resolveConfiguredDeferredChannelPluginIds.mockClear();

116+

resolveGatewayStartupPluginIds.mockClear().mockReturnValue(["telegram"]);

117+

resolveOpenClawPackageRootSync.mockClear().mockReturnValue("/package");

118+

runChannelPluginStartupMaintenance.mockClear();

119+

runStartupSessionMigration.mockClear();

120+

scanBundledPluginRuntimeDeps.mockClear().mockReturnValue({

121+

deps: [{ name: "grammy", version: "1.37.0", pluginIds: ["telegram"] }],

122+

missing: [{ name: "grammy", version: "1.37.0", pluginIds: ["telegram"] }],

123+

conflicts: [],

124+

});

125+

});

126+127+

it("falls back to per-plugin runtime-deps installs after failed pre-start staging", async () => {

128+

const installError = new Error("offline registry");

129+

repairBundledRuntimeDepsInstallRootAsync.mockRejectedValueOnce(installError);

130+

const log = createLog();

131+

const { prepareGatewayPluginBootstrap } = await import("./server-startup-plugins.js");

132+133+

await expect(

134+

prepareGatewayPluginBootstrap({

135+

cfgAtStart: {},

136+

startupRuntimeConfig: {},

137+

minimalTestGateway: false,

138+

log,

139+

}),

140+

).resolves.toMatchObject({

141+

baseGatewayMethods: ["ping"],

142+

startupPluginIds: ["telegram"],

143+

});

144+145+

expect(loadGatewayStartupPlugins).toHaveBeenCalledOnce();

146+

expect(scanBundledPluginRuntimeDeps).toHaveBeenCalledWith(

147+

expect.objectContaining({

148+

selectedPluginIds: ["telegram"],

149+

}),

150+

);

151+

expect(log.warn).toHaveBeenCalledWith(

152+

expect.stringContaining(

153+

"gateway startup will continue with per-plugin runtime-deps installs",

154+

),

155+

);

156+

expect(loadGatewayStartupPlugins.mock.calls[0]?.[0]).not.toHaveProperty(

157+

"bundledRuntimeDepsInstaller",

158+

);

159+

});

160+161+

it("falls back to per-plugin runtime-deps installs after failed pre-start scan", async () => {

162+

scanBundledPluginRuntimeDeps.mockImplementationOnce(() => {

163+

throw new Error("unsupported runtime dependency spec");

164+

});

165+

const log = createLog();

166+

const { prepareGatewayPluginBootstrap } = await import("./server-startup-plugins.js");

167+168+

await expect(

169+

prepareGatewayPluginBootstrap({

170+

cfgAtStart: {},

171+

startupRuntimeConfig: {},

172+

minimalTestGateway: false,

173+

log,

174+

}),

175+

).resolves.toMatchObject({

176+

baseGatewayMethods: ["ping"],

177+

startupPluginIds: ["telegram"],

178+

});

179+180+

expect(repairBundledRuntimeDepsInstallRootAsync).not.toHaveBeenCalled();

181+

expect(loadGatewayStartupPlugins).toHaveBeenCalledOnce();

182+

expect(log.warn).toHaveBeenCalledWith(

183+

expect.stringContaining(

184+

"failed to scan bundled runtime deps before gateway startup; gateway startup will continue with per-plugin runtime-deps installs",

185+

),

186+

);

187+

expect(loadGatewayStartupPlugins.mock.calls[0]?.[0]).not.toHaveProperty(

188+

"bundledRuntimeDepsInstaller",

189+

);

190+

});

191+

});