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

推荐订阅源

Microsoft Security Blog
Microsoft Security Blog
量子位
大猫的无限游戏
大猫的无限游戏
酷 壳 – CoolShell
酷 壳 – CoolShell
IT之家
IT之家
博客园 - 三生石上(FineUI控件)
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
博客园 - Franky
美团技术团队
Last Week in AI
Last Week in AI
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
人人都是产品经理
人人都是产品经理
罗磊的独立博客
Jina AI
Jina AI
小众软件
小众软件
S
SegmentFault 最新的问题
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
雷峰网
雷峰网
博客园 - 聂微东
博客园_首页
The Cloudflare Blog
WordPress大学
WordPress大学
Apple Machine Learning Research
Apple Machine Learning Research
有赞技术团队
有赞技术团队

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
perf(test): remove docker from fs bridge smoke · openclaw...
steipete · 2026-04-23 · via Recent Commits to openclaw:main

@@ -0,0 +1,125 @@

1+

import { spawn } from "node:child_process";

2+

import fs from "node:fs/promises";

3+

import os from "node:os";

4+

import path from "node:path";

5+

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

6+

import type {

7+

SandboxBackendHandle,

8+

SandboxBackendCommandParams,

9+

SandboxBackendCommandResult,

10+

} from "./backend-handle.types.js";

11+12+

async function runLocalShellCommand(

13+

params: SandboxBackendCommandParams,

14+

): Promise<SandboxBackendCommandResult> {

15+

return await new Promise<SandboxBackendCommandResult>((resolve, reject) => {

16+

const child = spawn(

17+

"sh",

18+

["-c", params.script, "openclaw-sandbox-fs", ...(params.args ?? [])],

19+

{

20+

stdio: ["pipe", "pipe", "pipe"],

21+

},

22+

);

23+24+

const stdoutChunks: Buffer[] = [];

25+

const stderrChunks: Buffer[] = [];

26+

let aborted = false;

27+28+

const onAbort = () => {

29+

if (aborted) {

30+

return;

31+

}

32+

aborted = true;

33+

child.kill("SIGTERM");

34+

};

35+

params.signal?.addEventListener("abort", onAbort);

36+37+

child.stdout?.on("data", (chunk) => {

38+

stdoutChunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));

39+

});

40+

child.stderr?.on("data", (chunk) => {

41+

stderrChunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));

42+

});

43+44+

child.on("error", reject);

45+

child.on("close", (code) => {

46+

params.signal?.removeEventListener("abort", onAbort);

47+

if (aborted || params.signal?.aborted) {

48+

const error = new Error("Aborted");

49+

error.name = "AbortError";

50+

reject(error);

51+

return;

52+

}

53+54+

const result = {

55+

stdout: Buffer.concat(stdoutChunks),

56+

stderr: Buffer.concat(stderrChunks),

57+

code: code ?? 0,

58+

};

59+

if (result.code !== 0 && !params.allowFailure) {

60+

reject(new Error(result.stderr.toString("utf8").trim() || `shell exited ${result.code}`));

61+

return;

62+

}

63+

resolve(result);

64+

});

65+66+

if (child.stdin) {

67+

child.stdin.end(params.stdin);

68+

}

69+

});

70+

}

71+72+

describe("sandbox fs bridge local backend e2e", () => {

73+

it.runIf(process.platform !== "win32")(

74+

"writes through backend shell commands using the pinned mutation helper",

75+

async () => {

76+

const stateDir = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-fsbridge-e2e-"));

77+

const workspacePath = path.join(stateDir, "workspace");

78+

await fs.mkdir(workspacePath, { recursive: true });

79+

const workspaceDir = await fs.realpath(workspacePath);

80+

const scripts: string[] = [];

81+

const backend: SandboxBackendHandle = {

82+

id: "local-test",

83+

runtimeId: "local-backend-fsbridge",

84+

runtimeLabel: "local-backend-fsbridge",

85+

workdir: workspaceDir,

86+

buildExecSpec: async ({ command, env }) => ({

87+

argv: ["sh", "-c", command],

88+

env,

89+

stdinMode: "pipe-closed",

90+

}),

91+

runShellCommand: async (params) => {

92+

scripts.push(params.script);

93+

return await runLocalShellCommand(params);

94+

},

95+

};

96+97+

try {

98+

const [{ createSandboxFsBridge }, { createSandboxTestContext }] = await Promise.all([

99+

import("./fs-bridge.js"),

100+

import("./test-fixtures.js"),

101+

]);

102+103+

const sandbox = createSandboxTestContext({

104+

overrides: {

105+

workspaceDir,

106+

agentWorkspaceDir: workspaceDir,

107+

containerName: "local-backend-fsbridge",

108+

containerWorkdir: workspaceDir,

109+

backend,

110+

},

111+

});

112+113+

const bridge = createSandboxFsBridge({ sandbox });

114+

await bridge.writeFile({ filePath: "nested/hello.txt", data: "from-backend" });

115+116+

await expect(

117+

fs.readFile(path.join(workspaceDir, "nested", "hello.txt"), "utf8"),

118+

).resolves.toBe("from-backend");

119+

expect(scripts.some((script) => script.includes("operation = sys.argv[1]"))).toBe(true);

120+

} finally {

121+

await fs.rm(stateDir, { recursive: true, force: true });

122+

}

123+

},

124+

);

125+

});