mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 19:44:59 +00:00
fix(sandbox): honor explicit bind mounts over workspace defaults
Co-authored-by: tasaankaeris <tasaankaeris@users.noreply.github.com>
This commit is contained in:
@@ -134,10 +134,8 @@ export function resolveSandboxFsPathWithMounts(params: {
|
||||
defaultContainerRoot: string;
|
||||
mounts: SandboxFsMount[];
|
||||
}): SandboxResolvedFsPath {
|
||||
const mountsByContainer = [...params.mounts].toSorted(
|
||||
(a, b) => b.containerRoot.length - a.containerRoot.length,
|
||||
);
|
||||
const mountsByHost = [...params.mounts].toSorted((a, b) => b.hostRoot.length - a.hostRoot.length);
|
||||
const mountsByContainer = [...params.mounts].toSorted(compareMountsByContainerPath);
|
||||
const mountsByHost = [...params.mounts].toSorted(compareMountsByHostPath);
|
||||
const input = params.filePath;
|
||||
const inputPosix = normalizePosixInput(input);
|
||||
|
||||
@@ -192,6 +190,34 @@ export function resolveSandboxFsPathWithMounts(params: {
|
||||
throw new Error(`Path escapes sandbox root (${params.defaultWorkspaceRoot}): ${input}`);
|
||||
}
|
||||
|
||||
function compareMountsByContainerPath(a: SandboxFsMount, b: SandboxFsMount): number {
|
||||
const byLength = b.containerRoot.length - a.containerRoot.length;
|
||||
if (byLength !== 0) {
|
||||
return byLength;
|
||||
}
|
||||
// Keep resolver ordering aligned with docker mount precedence: custom binds can
|
||||
// intentionally shadow default workspace mounts at the same container path.
|
||||
return mountSourcePriority(b.source) - mountSourcePriority(a.source);
|
||||
}
|
||||
|
||||
function compareMountsByHostPath(a: SandboxFsMount, b: SandboxFsMount): number {
|
||||
const byLength = b.hostRoot.length - a.hostRoot.length;
|
||||
if (byLength !== 0) {
|
||||
return byLength;
|
||||
}
|
||||
return mountSourcePriority(b.source) - mountSourcePriority(a.source);
|
||||
}
|
||||
|
||||
function mountSourcePriority(source: SandboxFsMount["source"]): number {
|
||||
if (source === "bind") {
|
||||
return 2;
|
||||
}
|
||||
if (source === "agent") {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
function dedupeMounts(mounts: SandboxFsMount[]): SandboxFsMount[] {
|
||||
const seen = new Set<string>();
|
||||
const deduped: SandboxFsMount[] = [];
|
||||
|
||||
Reference in New Issue
Block a user