The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
refactor(debug): extract core launch spec into web-ui-lib
Steven Enamakeldd9f0340ecae
diff --git a/scripts/__tests__/debug-web-ui.test.mjs b/scripts/__tests__/debug-web-ui.test.mjsindex 0a914606fe..f5de269940 100644--- a/scripts/__tests__/debug-web-ui.test.mjs+++ b/scripts/__tests__/debug-web-ui.test.mjs@@ -3,6 +3,7 @@ import net from "node:net";import test from "node:test";import {+ coreLaunchSpec,devConnectUrl,mergeChildEnv,freePort,@@ -12,6 +13,33 @@ import {waitFor,} from "../debug/web-ui-lib.mjs";+test("coreLaunchSpec isolates the core from operator credentials, storage, and dotenv", () => {+ const spec = coreLaunchSpec(+ {+ OPENHUMAN_BACKEND_API_KEY: "inherited",+ OPENHUMAN_BACKEND_SESSION_TOKEN: "inherited",+ OPENHUMAN_STORAGE_URL: "inherited",+ OPENHUMAN_DOTENV_PATH: "/operator/.env",+ RUST_LOG: "trace",+ },+ {+ workspace: "/private/run/workspace",+ mockUrl: "http://127.0.0.1:18500",+ token: "test-core-token",+ },+ );+ assert.equal(spec.cwd, "/private/run/workspace");+ assert.equal(spec.env.OPENHUMAN_WORKSPACE, spec.cwd);+ assert.equal(spec.env.OPENHUMAN_DOTENV_PATH, "/private/run/workspace/empty.env");+ assert.equal(spec.env.BACKEND_URL, "http://127.0.0.1:18500");+ assert.equal(spec.env.VITE_BACKEND_URL, "http://127.0.0.1:18500");+ assert.equal(spec.env.OPENHUMAN_CORE_TOKEN, "test-core-token");+ assert.equal(spec.env.OPENHUMAN_BACKEND_API_KEY, undefined);+ assert.equal(spec.env.OPENHUMAN_BACKEND_SESSION_TOKEN, undefined);+ assert.equal(spec.env.OPENHUMAN_STORAGE_URL, undefined);+ assert.equal(spec.env.RUST_LOG, "info");+});+test("mergeChildEnv overrides and removes inherited variables", () => {assert.deepEqual(mergeChildEnv(diff --git a/scripts/debug/web-ui-lib.mjs b/scripts/debug/web-ui-lib.mjsindex 9fd1343bcd..8bbed7eac7 100644--- a/scripts/debug/web-ui-lib.mjs+++ b/scripts/debug/web-ui-lib.mjs@@ -2,6 +2,7 @@// `scripts/__tests__/debug-web-ui.test.mjs` can cover them without booting a// browser, a core or Vite.import net from "node:net";+import path from "node:path";/** Merge child overrides into an inherited environment; null explicitly unsets a key. */export function mergeChildEnv(parent, overrides) {@@ -13,6 +14,26 @@ export function mergeChildEnv(parent, overrides) {return env;}+/** Isolated environment and working directory for the throwaway core process. */+export function coreLaunchSpec(parentEnv, { workspace, mockUrl, token, logLevel = "info" }) {+ return {+ cwd: workspace,+ env: mergeChildEnv(parentEnv, {+ OPENHUMAN_WORKSPACE: workspace,+ OPENHUMAN_DOTENV_PATH: path.join(workspace, "empty.env"),+ OPENHUMAN_CORE_TOKEN: token,+ BACKEND_URL: mockUrl,+ VITE_BACKEND_URL: mockUrl,+ OPENHUMAN_COMPOSIO_MODE: "disabled",+ OPENHUMAN_SANDBOX: "off",+ OPENHUMAN_BACKEND_API_KEY: null,+ OPENHUMAN_BACKEND_SESSION_TOKEN: null,+ OPENHUMAN_STORAGE_URL: null,+ RUST_LOG: logLevel,+ }),+ };+}+export const USAGE = `Usage: pnpm debug web [options]Boots a throwaway stack — mock backend, a fresh \`openhuman-core serve\` on adiff --git a/scripts/debug/web-ui.mjs b/scripts/debug/web-ui.mjsindex 5f0665bb1f..8fe126eea9 100644--- a/scripts/debug/web-ui.mjs+++ b/scripts/debug/web-ui.mjs@@ -22,6 +22,7 @@ import { fileURLToPath, pathToFileURL } from "node:url";import {devConnectUrl,+ coreLaunchSpec,freePort,isLoopback,mergeChildEnv,@@ -162,25 +163,13 @@ async function main() {await mockModule.startMockServer(mockPort);log(`mock backend ${mockUrl}`);- startChild(- "core",- core,- ["serve", "--port", String(corePort)],- {- OPENHUMAN_WORKSPACE: workspace,- OPENHUMAN_DOTENV_PATH: emptyDotenv,- OPENHUMAN_CORE_TOKEN: token,- BACKEND_URL: mockUrl,- VITE_BACKEND_URL: mockUrl,- OPENHUMAN_COMPOSIO_MODE: "disabled",- OPENHUMAN_SANDBOX: "off",- OPENHUMAN_BACKEND_API_KEY: null,- OPENHUMAN_BACKEND_SESSION_TOKEN: null,- OPENHUMAN_STORAGE_URL: null,- RUST_LOG: process.env.RUST_LOG ?? "info",- },+ const coreLaunch = coreLaunchSpec(process.env, {workspace,- );+ mockUrl,+ token,+ logLevel: process.env.RUST_LOG ?? "info",+ });+ startChild("core", core, ["serve", "--port", String(corePort)], coreLaunch.env, coreLaunch.cwd);await waitFor(async () => (await fetch(`http://127.0.0.1:${corePort}/health`)).ok, {timeoutMs: 120_000,what: "the core's /health",