Skip to content

fix: use asar-safe recursive copy for container assets#13

Merged
DorianZheng merged 1 commit intomainfrom
fix/asar-recursive-dir-copy
Mar 26, 2026
Merged

fix: use asar-safe recursive copy for container assets#13
DorianZheng merged 1 commit intomainfrom
fix/asar-recursive-dir-copy

Conversation

@DorianZheng
Copy link
Copy Markdown
Member

Summary

  • Electron's asar shim patches fs.cpSync but the generic overrideAPISync wrapper only handles single-file extraction via archive.copyFileOut() — it returns null for directories, throwing NOT_FOUND
  • This breaks container skills and agent-runner copying when agentlite runs inside an Electron .asar archive
  • Adds copyDirRecursive() in src/utils.ts that tries fs.cpSync first (fast native path), then falls back to per-file readFileSync/writeFileSync walk (all properly asar-patched for individual files)

Test plan

  • npm run build passes
  • npm run dev — send a test message, confirm container/skills and agent-runner are copied without ENOENT
  • Verify in Electron host (Dune app) that asar directory copy works end-to-end

Electron's asar shim patches fs.cpSync but the override only handles
single-file extraction via archive.copyFileOut(). When cpSync is called
on a directory with { recursive: true }, copyFileOut returns null and
throws NOT_FOUND. This breaks skills and agent-runner copying when
agentlite is consumed inside an Electron app (.asar archive).

Add copyDirRecursive() in src/utils.ts that tries fs.cpSync first
(fast path for non-asar), then falls back to per-file walk using
readdirSync/statSync/readFileSync/writeFileSync (all properly
asar-patched for individual files).
@DorianZheng DorianZheng merged commit ac903d3 into main Mar 26, 2026
2 checks passed
@DorianZheng DorianZheng deleted the fix/asar-recursive-dir-copy branch March 26, 2026 13:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant