Setup
Usage with deepagents
Standalone usage
Configuration
| Option | Type | Default | Description |
|---|---|---|---|
mountPath | string | "/vfs" | Mount path for the virtual file system |
timeout | number | 30000 | Command execution timeout in milliseconds |
initialFiles | Record<string, string | Uint8Array> | - | Initial files to populate the VFS |
How it works
VFS uses a hybrid approach for maximum compatibility:- File storage: Files are stored in-memory using a virtual file system
- Command execution: When executing commands, files sync to a temp directory, the command runs, and changes sync back to VFS
- Fallback mode: If node-vfs-polyfill is unavailable, falls back to using a temp directory for both storage and execution
File operations
Factory functions
Error handling
Error codes
| Code | Description |
|---|---|
NOT_INITIALIZED | Sandbox not initialized |
ALREADY_INITIALIZED | Sandbox already initialized |
INITIALIZATION_FAILED | Failed to initialize VFS |
COMMAND_TIMEOUT | Command execution timed out |
COMMAND_FAILED | Command execution failed |
FILE_OPERATION_FAILED | File operation failed |
NOT_SUPPORTED | VFS not supported in environment |
When to use VFS
Best suited for:- Local development and testing
- CI/CD pipelines without Docker
- Quick prototyping without cloud setup
- Environments where external services aren’t available
- Production workloads requiring true container isolation
- Persistent storage across sessions
- Heavy computational tasks (no resource limits)
Future: Native Node.js VFS
This package uses node-vfs-polyfill which implements the upcoming Node.js VFS feature being developed in nodejs/node#61478. When the officialnode:vfs module lands in Node.js, this package will be updated to use the native implementation.