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

推荐订阅源

博客园 - Franky
U
Unit 42
MyScale Blog
MyScale Blog
B
Blog
阮一峰的网络日志
阮一峰的网络日志
量子位
IT之家
IT之家
The GitHub Blog
The GitHub Blog
F
Fortinet All Blogs
Recent Announcements
Recent Announcements
V
Visual Studio Blog
G
Google Developers Blog
Last Week in AI
Last Week in AI
雷峰网
雷峰网
博客园 - 聂微东
博客园 - 叶小钗
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
J
Java Code Geeks
博客园 - 司徒正美
Y
Y Combinator Blog
T
The Blog of Author Tim Ferriss
月光博客
月光博客
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: prepare public artifact runtime deps · openclaw/open...
steipete · 2026-04-28 · via Recent Commits to openclaw:main

@@ -3,28 +3,111 @@ import os from "node:os";

33

import path from "node:path";

44

import { importFreshModule } from "openclaw/plugin-sdk/test-fixtures";

55

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

6+

import {

7+

clearBundledRuntimeDependencyNodePaths,

8+

resolveBundledRuntimeDependencyInstallRoot,

9+

} from "./bundled-runtime-deps.js";

610711

const tempDirs: string[] = [];

812

const originalBundledPluginsDir = process.env.OPENCLAW_BUNDLED_PLUGINS_DIR;

13+

const originalPluginStageDir = process.env.OPENCLAW_PLUGIN_STAGE_DIR;

9141015

function createTempDir(): string {

1116

const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-public-surface-loader-"));

1217

tempDirs.push(tempDir);

1318

return tempDir;

1419

}

152021+

function createPackagedPublicArtifactWithStagedRuntimeDep(): {

22+

bundledPluginsDir: string;

23+

pluginRoot: string;

24+

stageRoot: string;

25+

} {

26+

const packageRoot = createTempDir();

27+

const pluginRoot = path.join(packageRoot, "dist", "extensions", "demo");

28+

const stageRoot = path.join(packageRoot, "stage");

29+

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

30+

fs.writeFileSync(

31+

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

32+

JSON.stringify({ name: "openclaw", version: "0.0.0", type: "module" }, null, 2),

33+

"utf8",

34+

);

35+

fs.writeFileSync(

36+

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

37+

JSON.stringify(

38+

{

39+

name: "@openclaw/plugin-demo",

40+

version: "0.0.0",

41+

type: "module",

42+

dependencies: {

43+

"public-artifact-runtime-dep": "1.0.0",

44+

},

45+

},

46+

null,

47+

2,

48+

),

49+

"utf8",

50+

);

51+

fs.writeFileSync(

52+

path.join(pluginRoot, "provider-policy-api.js"),

53+

[

54+

'import { marker as depMarker } from "public-artifact-runtime-dep";',

55+

"export const marker = `artifact:${depMarker}`;",

56+

"",

57+

].join("\n"),

58+

"utf8",

59+

);

60+61+

const installRoot = resolveBundledRuntimeDependencyInstallRoot(pluginRoot, {

62+

env: {

63+

...process.env,

64+

OPENCLAW_PLUGIN_STAGE_DIR: stageRoot,

65+

},

66+

});

67+

const depRoot = path.join(installRoot, "node_modules", "public-artifact-runtime-dep");

68+

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

69+

fs.writeFileSync(

70+

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

71+

JSON.stringify(

72+

{

73+

name: "public-artifact-runtime-dep",

74+

version: "1.0.0",

75+

type: "module",

76+

exports: "./index.js",

77+

},

78+

null,

79+

2,

80+

),

81+

"utf8",

82+

);

83+

fs.writeFileSync(path.join(depRoot, "index.js"), 'export const marker = "staged";\n', "utf8");

84+85+

return {

86+

bundledPluginsDir: path.join(packageRoot, "dist", "extensions"),

87+

pluginRoot,

88+

stageRoot,

89+

};

90+

}

91+1692

afterEach(() => {

1793

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

1894

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

1995

}

2096

vi.restoreAllMocks();

2197

vi.resetModules();

2298

vi.doUnmock("jiti");

99+

vi.doUnmock("node:module");

100+

clearBundledRuntimeDependencyNodePaths();

23101

if (originalBundledPluginsDir === undefined) {

24102

delete process.env.OPENCLAW_BUNDLED_PLUGINS_DIR;

25103

} else {

26104

process.env.OPENCLAW_BUNDLED_PLUGINS_DIR = originalBundledPluginsDir;

27105

}

106+

if (originalPluginStageDir === undefined) {

107+

delete process.env.OPENCLAW_PLUGIN_STAGE_DIR;

108+

} else {

109+

process.env.OPENCLAW_PLUGIN_STAGE_DIR = originalPluginStageDir;

110+

}

28111

});

2911230113

describe("bundled plugin public surface loader", () => {

@@ -140,6 +223,25 @@ describe("bundled plugin public surface loader", () => {

140223

expect(createJiti).toHaveBeenCalledTimes(1);

141224

});

142225226+

it("loads built public artifacts through staged runtime deps", async () => {

227+

const publicSurfaceLoader = await importFreshModule<

228+

typeof import("./public-surface-loader.js")

229+

>(import.meta.url, "./public-surface-loader.js?scope=runtime-deps");

230+

const fixture = createPackagedPublicArtifactWithStagedRuntimeDep();

231+

process.env.OPENCLAW_BUNDLED_PLUGINS_DIR = fixture.bundledPluginsDir;

232+

process.env.OPENCLAW_PLUGIN_STAGE_DIR = fixture.stageRoot;

233+234+

const loaded = publicSurfaceLoader.loadBundledPluginPublicArtifactModuleSync<{

235+

marker: string;

236+

}>({

237+

dirName: "demo",

238+

artifactBasename: "provider-policy-api.js",

239+

});

240+241+

expect(loaded.marker).toBe("artifact:staged");

242+

expect(fs.existsSync(path.join(fixture.pluginRoot, "node_modules"))).toBe(false);

243+

});

244+143245

it("rejects public artifacts that change after boundary validation", async () => {

144246

const createJiti = vi.fn(() => vi.fn(() => ({ marker: "should-not-load" })));

145247

vi.doMock("jiti", () => ({