import { AsyncLocalStorage } from 'node:async_hooks'; import { registerContextVFSProvider } from '@/lib/vfs'; import type { VirtualFileSystem } from '@/lib/vfs'; const vfsStorage = new AsyncLocalStorage(); export function runWithVFS(vfs: VirtualFileSystem, fn: () => Promise): Promise { return vfsStorage.run(vfs, fn); } export function getContextVFS(): VirtualFileSystem | undefined { return vfsStorage.getStore(); } registerContextVFSProvider(getContextVFS);