Skip to content

Commit 0844054

Browse files
committed
fix(sandbox): create missing skill mount directories to enforce read-only protection
1 parent c79f1e5 commit 0844054

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

‎src/agents/sandbox/workspace-mounts.ts‎

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,26 @@ export function resolveMaterializedSandboxSkillsWorkspaceDir(rootDir: string): s
4141
return path.join(rootDir, ...MATERIALIZED_SANDBOX_SKILLS_WORKSPACE_PARTS);
4242
}
4343

44-
/** Returns true when a skill mount source exists inside the canonical mount root. */
44+
/** Returns true when a skill mount source exists inside the canonical mount root.
45+
* When the host directory does not exist yet (first agent creation), it is
46+
* created so the read-only mount is not silently skipped. (#94425) */
4547
export function isExistingWorkspaceSkillMountSource(params: {
4648
rootDir: string;
4749
hostPath: string;
4850
}): boolean {
51+
let stat: fs.Stats | undefined;
4952
try {
50-
if (!fs.lstatSync(params.hostPath).isDirectory()) {
53+
stat = fs.lstatSync(params.hostPath);
54+
} catch {
55+
// Directory does not exist yet — create it so the read-only mount applies.
56+
try {
57+
fs.mkdirSync(params.hostPath, { recursive: true });
58+
return true;
59+
} catch {
5160
return false;
5261
}
53-
} catch {
62+
}
63+
if (!stat.isDirectory()) {
5464
return false;
5565
}
5666

0 commit comments

Comments
 (0)