From 69cbdca0096cc64416ac4dcc00ba080ad3026b34 Mon Sep 17 00:00:00 2001 From: Neil <4138956+nwparker@users.noreply.github.com> Date: Tue, 13 Oct 2026 18:05:05 -0700 Subject: [PATCH] fix(packaging): include Codex TOML parser in copied runtime (#28416) --- config/packaged-runtime-node-modules.cjs | 1 + .../scripts/electron-builder-config.test.mjs | 33 ++++++++++++++++++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/config/packaged-runtime-node-modules.cjs b/config/packaged-runtime-node-modules.cjs index e400956ddf5..63556ad3b6d 100644 --- a/config/packaged-runtime-node-modules.cjs +++ b/config/packaged-runtime-node-modules.cjs @@ -27,6 +27,7 @@ const PACKAGED_RUNTIME_PACKAGE_ROOTS = [ 'posthog-node', 'proper-lockfile', 'qrcode', + 'smol-toml', 'ssh2', 'tweetnacl', 'ws', diff --git a/config/scripts/electron-builder-config.test.mjs b/config/scripts/electron-builder-config.test.mjs index f08898ea94a..78d3cde2a32 100644 --- a/config/scripts/electron-builder-config.test.mjs +++ b/config/scripts/electron-builder-config.test.mjs @@ -1,5 +1,5 @@ import { existsSync } from 'node:fs' -import { chmod, lstat, mkdir, mkdtemp, readFile, rm, writeFile } from 'node:fs/promises' +import { chmod, lstat, mkdir, mkdtemp, readFile, realpath, rm, writeFile } from 'node:fs/promises' import { createRequire } from 'node:module' import { tmpdir } from 'node:os' import { dirname, join } from 'node:path' @@ -269,6 +269,37 @@ describe('electron-builder config', () => { ]) }) + it.each(['mac', 'linux'])( + 'loads Codex TOML parsing after %s runtime pruning', + async (platform) => { + const resourcesDir = await mkdtemp(join(tmpdir(), 'orca-packaged-codex-toml-')) + try { + const resource = electronBuilderConfig[platform].extraResources.find( + (entry) => entry.to === join('node_modules', 'smol-toml') + ) + expect(resource).toBeDefined() + await copyFiles([ + new FileMatcher(resource.from, join(resourcesDir, resource.to), (value) => value) + ]) + require('../packaged-runtime-node-modules.cjs').prunePackagedRuntimeNodeModules( + resourcesDir, + platform === 'mac' ? 'darwin' : 'linux', + process.arch + ) + const stagedRequire = createRequire(join(resourcesDir, 'out', 'main', 'codex', 'trust.cjs')) + expect(await realpath(stagedRequire.resolve('smol-toml'))).toBe( + await realpath(join(resourcesDir, resource.to, 'dist', 'index.cjs')) + ) + const { parse } = stagedRequire('smol-toml') + expect(parse('[projects."/workspace"]\ntrust_level = "trusted"\n')).toEqual({ + projects: { '/workspace': { trust_level: 'trusted' } } + }) + } finally { + await rm(resourcesDir, { recursive: true, force: true }) + } + } + ) + // Why: serve-sim's addon is a Mach-O, and Windows signing rejects every *.node that is not PE. it('keeps serve-sim out of the Windows and Linux runtime closures', () => { const {