


















以下主要是一个简单的试用
包含了初始化fs,以及写入fs,因为@langchain/node-vfs 支持同步,所以写入之后ls 应该也是可以看到的
import { VfsSandbox } from "@langchain/node-vfs";
const sandbox = await VfsSandbox.create({
initialFiles: {
"/src/index.js": "console.log('Hello from VFS!')",
},
});
const result = await sandbox.execute("echo 'Hello, World!' > /src/hello.txt && cat /src/hello.txt");
console.log(result);
let fileLists = await sandbox.ls("/src");
console.log(fileLists);
从结果看也是符合上边的说明
{ output: 'Hello, World!\n', exitCode: 0, truncated: false }
{
files: [
{
path: 'src/index.js',
is_dir: false,
size: 30,
modified_at: '2026-04-26T08:06:56.000Z'
},
{
path: 'src/hello.txt',
is_dir: false,
size: 14,
modified_at: '2026-04-26T08:06:56.000Z'
}
]
}
@langchain/node-vfs 不太好的是,deepagents 需要作为一个peer 依赖
https://reference.langchain.com/javascript/langchain-node-vfs
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。