Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

refactor(debug): extract child env merging into shared helper

Steven Enamakelde396d1086bd
diff --git a/scripts/debug/web-ui-lib.mjs b/scripts/debug/web-ui-lib.mjs
index 999d5175d5..9fd1343bcd 100644
--- a/scripts/debug/web-ui-lib.mjs
+++ b/scripts/debug/web-ui-lib.mjs
@@ -3,6 +3,16 @@
// browser, a core or Vite.
import net from "node:net";
+/** Merge child overrides into an inherited environment; null explicitly unsets a key. */
+export function mergeChildEnv(parent, overrides) {
+ const env = { ...parent };
+ for (const [key, value] of Object.entries(overrides)) {
+ if (value === null) delete env[key];
+ else env[key] = value;
+ }
+ return env;
+}
+
export const USAGE = `Usage: pnpm debug web [options]
Boots a throwaway stack — mock backend, a fresh \`openhuman-core serve\` on a
diff --git a/scripts/debug/web-ui.mjs b/scripts/debug/web-ui.mjs
index 419f4663ee..5f0665bb1f 100644
--- a/scripts/debug/web-ui.mjs
+++ b/scripts/debug/web-ui.mjs
@@ -24,6 +24,7 @@ import {
devConnectUrl,
freePort,
isLoopback,
+ mergeChildEnv,
parseArgs,
runStamp,
USAGE,
@@ -84,14 +85,9 @@ function startChild(name, command, args, env, cwd = repo) {
const launchArgs = largeStack
? ["-c", 'ulimit -s 65520 || exit 1; exec "$@"', "debug-web-core", command, ...args]
: args;
- const childEnv = { ...process.env };
- for (const [key, value] of Object.entries(env)) {
- if (value === null) delete childEnv[key];
- else childEnv[key] = value;
- }
const child = spawn(launchCommand, launchArgs, {
cwd,
- env: childEnv,
+ env: mergeChildEnv(process.env, env),
stdio: ["ignore", out, out],
detached: true,
});