Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/container-runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { logger } from './logger.js';
import { spawnBox } from './box-runtime.js';
import { validateAdditionalMounts } from './mount-security.js';
import { RegisteredGroup } from './types.js';
import { copyDirRecursive } from './utils.js';

// Lazy OneCLI — dynamically imported so it's not a hard dependency
let _onecli: any = null;
Expand Down Expand Up @@ -176,7 +177,7 @@ function buildVolumeMounts(
const srcDir = path.join(skillsSrc, skillDir);
if (!fs.statSync(srcDir).isDirectory()) continue;
const dstDir = path.join(skillsDst, skillDir);
fs.cpSync(srcDir, dstDir, { recursive: true });
copyDirRecursive(srcDir, dstDir);
}
}
mounts.push({
Expand Down Expand Up @@ -213,7 +214,7 @@ function buildVolumeMounts(
'agent-runner-src',
);
if (!fs.existsSync(groupAgentRunnerDir) && fs.existsSync(agentRunnerSrc)) {
fs.cpSync(agentRunnerSrc, groupAgentRunnerDir, { recursive: true });
copyDirRecursive(agentRunnerSrc, groupAgentRunnerDir);
}
mounts.push({
hostPath: groupAgentRunnerDir,
Expand Down
24 changes: 24 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import fs from 'fs';
import path from 'path';

/**
* Copy a directory recursively. Tries fs.cpSync first (fast native path),
* falls back to per-file readFileSync/writeFileSync for Electron asar
* compatibility (asar's cpSync override only handles files, not directories).
*/
export function copyDirRecursive(src: string, dst: string): void {
try {
fs.cpSync(src, dst, { recursive: true });
} catch {
fs.mkdirSync(dst, { recursive: true });
for (const entry of fs.readdirSync(src)) {
const srcPath = path.join(src, entry);
const dstPath = path.join(dst, entry);
if (fs.statSync(srcPath).isDirectory()) {
copyDirRecursive(srcPath, dstPath);
} else {
fs.writeFileSync(dstPath, fs.readFileSync(srcPath));
}
}
}
}
Loading