Give the launcher and shared command worker one lightweight owner for package-version binding, Windows empty-home handling and Android browser-cache defaults. Preserve per-command preparation and environment restoration, package the owner explicitly, and retain its package and JavaScript recovery CI scopes. Validation: dispatcher/version/shared-session, home fallback, evaluator/MCP/process cleanup and CI scope tests passed. Functional archive/install/repack, installed static CLI analysis and MCP checks passed; no real Codex/model trial or Windows/Termux runtime qualification was performed.
27 lines
967 B
JavaScript
27 lines
967 B
JavaScript
import { join } from "node:path";
|
|
|
|
/** Prepare the selected process environment before importing CLI or MCP dependencies. */
|
|
export const prepareCliProcessEnvironment = (
|
|
environment,
|
|
platform,
|
|
packageVersion,
|
|
) => {
|
|
environment.REA_PACKAGE_VERSION = packageVersion;
|
|
// Windows home lookup throws for an empty USERPROFILE. Dependencies resolve
|
|
// home during import, before REA's own resolver can apply its account fallback.
|
|
if (platform === "win32" && environment.USERPROFILE === "") {
|
|
delete environment.USERPROFILE;
|
|
}
|
|
|
|
// Playwright's registry assumes a desktop host while choosing its cache.
|
|
// Termux needs an explicit path before the registry initializes.
|
|
if (
|
|
platform === "android" &&
|
|
environment.PLAYWRIGHT_BROWSERS_PATH === undefined
|
|
) {
|
|
const cacheRoot =
|
|
environment.XDG_CACHE_HOME ?? join(environment.HOME ?? ".", ".cache");
|
|
environment.PLAYWRIGHT_BROWSERS_PATH = join(cacheRoot, "ms-playwright");
|
|
}
|
|
};
|