






















@@ -232,6 +232,56 @@ describe("remote sandbox fs bridge", () => {
232232});
233233});
234234});
235+236+it("does not reject malformed non-decimal hardlink counts", async () => {
237+await withTempDir("openclaw-remote-fs-bridge-hardlink-", async (stateDir) => {
238+const workspaceDir = path.join(stateDir, "workspace");
239+await fs.mkdir(workspaceDir, { recursive: true });
240+const runtime: RemoteShellSandboxHandle = {
241+remoteWorkspaceDir: workspaceDir,
242+remoteAgentWorkspaceDir: workspaceDir,
243+runRemoteShellScript: async (command) => {
244+if (command.script.includes('if [ -e "$1" ] || [ -L "$1" ]')) {
245+return { stdout: Buffer.from("1\n"), stderr: Buffer.alloc(0), code: 0 };
246+}
247+if (command.script.includes('readlink -f -- "$cursor"')) {
248+return {
249+stdout: Buffer.from(`${workspaceDir}/note.txt\n`),
250+stderr: Buffer.alloc(0),
251+code: 0,
252+};
253+}
254+if (command.script.includes('stat -c "%F|%h"')) {
255+return {
256+stdout: Buffer.from("regular file|0x2\n"),
257+stderr: Buffer.alloc(0),
258+code: 0,
259+};
260+}
261+if (command.script.includes('stat -c "%F|%s|%y"')) {
262+return {
263+stdout: Buffer.from("regular file|12|2026-05-29 12:00:00.000000000 +0000\n"),
264+stderr: Buffer.alloc(0),
265+code: 0,
266+};
267+}
268+throw new Error(`unexpected remote script: ${command.script}`);
269+},
270+};
271+const bridge = createRemoteShellSandboxFsBridge({
272+sandbox: createSandbox({
273+ workspaceDir,
274+agentWorkspaceDir: workspaceDir,
275+}),
276+ runtime,
277+});
278+279+await expect(bridge.stat({ filePath: "note.txt" })).resolves.toMatchObject({
280+type: "file",
281+size: 12,
282+});
283+});
284+});
235285});
236286237287async function withTempDir<T>(prefix: string, run: (stateDir: string) => Promise<T>): Promise<T> {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。