openskynet / src /agents /sandbox /path-utils.ts
Darochin's picture
Mirror OpenSkyNet workspace snapshot from Git HEAD
fc93158 verified
import path from "node:path";
export function normalizeContainerPath(value: string): string {
const normalized = path.posix.normalize(value);
return normalized === "." ? "/" : normalized;
}
export function isPathInsideContainerRoot(root: string, target: string): boolean {
const normalizedRoot = normalizeContainerPath(root);
const normalizedTarget = normalizeContainerPath(target);
if (normalizedRoot === "/") {
return true;
}
return normalizedTarget === normalizedRoot || normalizedTarget.startsWith(`${normalizedRoot}/`);
}