Node.js VFS backend for deepagents.
Provides an in-memory virtual file system for agent operations, allowing agents to read/write files without affecting the real filesystem.
This implementation uses node-vfs-polyfill which implements the upcoming Node.js VFS feature. Files are stored entirely in-memory using the VFS.
import { VfsBackend } from "@langchain/node-vfs";
// Create and initialize a VFS backend
const backend = await VfsBackend.create({
initialFiles: {
"/src/index.js": "console.log('Hello')",
},
});
try {
// Read files directly
const result = await backend.read("/src/index.js");
console.log(result.content);
} finally {
await backend.stop();
}
import { createDeepAgent } from "deepagents";
import { VfsBackend } from "@langchain/node-vfs";
const backend = await VfsBackend.create();
const agent = createDeepAgent({
model: new ChatAnthropic({ model: "claude-sonnet-4-20250514" }),
systemPrompt: "You are a coding assistant with VFS access.",
backend,
});Download files from the backend.
Edit a file by replacing string occurrences.
Structured glob matching returning FileInfo objects.
Search for a literal text pattern in files.
Initialize the VFS backend.
This method sets up the virtual file system and populates it with any initial files specified in the options.
List files and directories in the specified directory.
Read file content.
Read file content as raw FileData.
Stop the backend and release all resources.
Upload files to the backend.
Files are written to the VFS. Parent directories are created automatically if they don't exist.
Create a new file with content.
Create and initialize a new VfsBackend in one step.
This is the recommended way to create a backend. It combines construction and initialization into a single async operation.