// In-memory roots that should be browsable in addition to roots derived from // persisted sessions. Stored on globalThis so Next.js hot-reload keeps them. declare global { var __piAllowedRootsCache: { roots: Set; expiresAt: number } | undefined; var __piAdditionalAllowedRoots: Set | undefined; } export function normalizeSlashes(filePath: string): string { return filePath.replace(/\\/g, "/"); } export function getAdditionalAllowedRoots(): Set { if (!globalThis.__piAdditionalAllowedRoots) { globalThis.__piAdditionalAllowedRoots = new Set(); } return globalThis.__piAdditionalAllowedRoots; } export function allowFileRoot(root: string): void { if (!root) return; const normalizedRoot = normalizeSlashes(root); getAdditionalAllowedRoots().add(normalizedRoot); globalThis.__piAllowedRootsCache?.roots.add(normalizedRoot); }