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
Merge remote-tracking branch 'refs/remotes/upstream/main' into pr/6243
Steven Enamakelf85533f7d28d
diff --cc .github/workflows/ci-lite.ymlindex eb8be8fa0a,f8d2e0759d..5551040aba--- a/.github/workflows/ci-lite.yml+++ b/.github/workflows/ci-lite.yml@@@ -246,11 -199,11 +199,16 @@@ jobs- 'scripts/ci/check-module-pins.mjs'- 'scripts/ci/check-submodule-monotonic.mjs'- 'scripts/ci/module-pin-exemptions.json'- # The web E2E harness scripts, and the Vite `emptyOutDir` setting- # their bundle marker depends on (e2e-web-bundle-guard.test.mjs).+ # The ignored-test ratchet has node --test coverage in+ # scripts/__tests__/ — editing the gate must run the tests that+ # pin its clauses, or the counter's anchoring and its+ # cfg_attr guard can be loosened with nothing watching.+ - 'scripts/ci/check-ignored-tests.mjs'++ # The web E2E build/session contract has script-level regression++ # tests; run them when either participant or Vite changes.+ - 'app/scripts/e2e-web-build.sh'+ - 'app/scripts/e2e-web-session.sh'+ - 'app/vite.config.*'# Test-wiring surface: a change here can orphan a test or add an# untested controller domain → run the inventory guard.inventory:diff --cc app/scripts/e2e-web-build.shindex e0b3d31118,4851b52067..3b52ea948b--- a/app/scripts/e2e-web-build.sh+++ b/app/scripts/e2e-web-build.sh@@@ -15,33 -15,51 +15,53 @@@ fRUST_HOST_TRIPLE="${RUST_HOST_TRIPLE:-$("$RUSTC_BIN" -vV | awk '/^host: / { print $2 }')}"E2E_WEB_CORE_TARGET_DIR="${E2E_WEB_CORE_TARGET_DIR:-$REPO_ROOT/target/e2e-web-${RUST_HOST_TRIPLE}}"--export VITE_BACKEND_URL="http://127.0.0.1:${E2E_MOCK_PORT:-18473}"--export VITE_OPENHUMAN_TARGET="web"--export VITE_OPENHUMAN_E2E_DEFAULT_CORE_MODE="cloud"--export VITE_OPENHUMAN_E2E_RESTART_APP_AS_RELOAD="true"--export VITE_OPENHUMAN_CORE_RPC_URL="http://127.0.0.1:${OPENHUMAN_CORE_PORT:-17788}/rpc"--export VITE_CHAT_ATTACHMENTS="true"++# Preserve explicit harness ports before loading a developer .env. That file++# may configure normal development, but must not change an E2E bundle's baked++# endpoint or its E2E-only affordances.++E2E_MOCK_PORT="${E2E_MOCK_PORT:-18473}"++OPENHUMAN_CORE_PORT="${OPENHUMAN_CORE_PORT:-17788}"if [ -f "$REPO_ROOT/.env" ]; then# shellcheck source=/dev/nullsource "$REPO_ROOT/scripts/load-dotenv.sh"fi++# Apply E2E settings after .env so it cannot produce a non-E2E bundle with a++# valid marker. Keep this immediately before the build that consumes them.++export VITE_BACKEND_URL="http://127.0.0.1:${E2E_MOCK_PORT}"++export VITE_OPENHUMAN_TARGET="web"++export VITE_OPENHUMAN_E2E_DEFAULT_CORE_MODE="cloud"++export VITE_OPENHUMAN_E2E_RESTART_APP_AS_RELOAD="true"++export VITE_OPENHUMAN_CORE_RPC_URL="http://127.0.0.1:${OPENHUMAN_CORE_PORT}/rpc"++export VITE_CHAT_ATTACHMENTS="true"++echo "Building web E2E bundle with backend ${VITE_BACKEND_URL}"-# Drop the previous marker first. `build:web` runs `tsc`, so a failed build-# leaves the OLD `dist-web` in place; without this the old marker would survive-# beside it and the session would happily serve a stale bundle that merely-# happens to agree about ports. No marker means the session refuses.-rm -f "$APP_DIR/dist-web/.e2e-build-ports.json"++# Drop all build markers before compiling. A failed `build:web` leaves the++# preceding dist-web intact, and the session must not accept that stale bundle.++rm -f "$APP_DIR/dist-web/.openhuman-e2e-bundle" "$APP_DIR/dist-web/.e2e-build-ports.json"pnpm run build:web--# Record what got baked, so the session can refuse a bundle built for other-# ports (#6478).-#-# `VITE_BACKEND_URL` above is substituted into the bundle by Vite at BUILD time-# and has no runtime override in web mode: `utils/config.ts` reads-# `import.meta.env.VITE_BACKEND_URL || DEFAULT_BACKEND_URL`, and-# `services/backendUrl.ts`'s web path falls back to `window.location.origin` —-# which is the web HOST port, not the mock's, so it cannot reconcile a-# mismatch. Set the ports for the session but not the build (the natural thing-# to do, since ports are a session concern) and the frontend's own API calls go-# to a mock that is not listening, while the core — which reads `api_url` from-# the `config.toml` the session generates at runtime — talks to the right one.-# Some specs then fail and others pass, for a reason nothing reports.-#-# `VITE_OPENHUMAN_CORE_RPC_URL` is baked too but is NOT part of this problem: a-# stored URL wins over it (`coreRpcClient.ts`, `storedUrl ?? CORE_RPC_URL`) and-# the Playwright helper seeds that from the runtime port on every boot. It is-# recorded here anyway so a future divergence is visible rather than inferred.-cat > "$APP_DIR/dist-web/.e2e-build-ports.json" <<JSON+# Mark dist-web as an E2E bundle for e2e-web-session.sh. `pnpm build:web` on its+# own compiles in the wrong backend and none of the E2E affordances, and Vite+# empties dist-web on every build, so any later non-E2E build removes this+# marker and the session refuses that bundle instead of serving it (#5920).+# The recorded values are for diagnosing a bundle, not read back.+cat >"$APP_DIR/dist-web/.openhuman-e2e-bundle" <<MARKER+VITE_BACKEND_URL=${VITE_BACKEND_URL}+VITE_OPENHUMAN_TARGET=${VITE_OPENHUMAN_TARGET}+VITE_OPENHUMAN_E2E_DEFAULT_CORE_MODE=${VITE_OPENHUMAN_E2E_DEFAULT_CORE_MODE}+VITE_OPENHUMAN_E2E_RESTART_APP_AS_RELOAD=${VITE_OPENHUMAN_E2E_RESTART_APP_AS_RELOAD}+VITE_OPENHUMAN_CORE_RPC_URL=${VITE_OPENHUMAN_CORE_RPC_URL}+VITE_CHAT_ATTACHMENTS=${VITE_CHAT_ATTACHMENTS}+MARKER++# Also retain the ports baked into the bundle. The session validates this++# contract before serving: a web bundle cannot change its backend at runtime.++cat >"$APP_DIR/dist-web/.e2e-build-ports.json" <<JSON+ {+ "e2e_mock_port": "${E2E_MOCK_PORT:-18473}",+ "openhuman_core_port": "${OPENHUMAN_CORE_PORT:-17788}",+ "vite_backend_url": "${VITE_BACKEND_URL}"+ }+ JSONecho "Building standalone openhuman-core for web E2E into ${E2E_WEB_CORE_TARGET_DIR}..."# A bare core build uses the contributor feature set, which intentionally# omits product domains such as voice, web3, documents and crash reporting.diff --cc app/scripts/e2e-web-session.shindex a8a98ecb49,7458396a42..9125bd9dda--- a/app/scripts/e2e-web-session.sh+++ b/app/scripts/e2e-web-session.sh@@@ -131,23 -156,41 +156,51 @@@ endpoint = "http://127.0.0.1:${E2E_MOCKauth_style = "openhumanjwt"EOF+# The bundle must come from `pnpm test:e2e:web:build`, which compiles in the mock+# backend URL and the E2E affordances. A plain `pnpm build:web` exits 0 with a+# bundle this harness cannot drive, and every spec then fails as though the+# product had regressed. Refuse it before starting anything (#5920).+E2E_BUNDLE_MARKER="$APP_DIR/dist-web/.openhuman-e2e-bundle"+if [ ! -f "$E2E_BUNDLE_MARKER" ]; then- echo "ERROR: $APP_DIR/dist-web was not built for E2E (no $(basename "$E2E_BUNDLE_MARKER")). Run pnpm test:e2e:web:build first; pnpm build:web alone omits the E2E backend and affordances." >&2++ echo "ERROR: $APP_DIR/dist-web was not built for E2E (no $(basename "$E2E_BUNDLE_MARKER")). Run pnpm --filter openhuman-app test:e2e:web:build first; pnpm build:web alone omits the E2E backend and affordances." >&2+ exit 1+fi+node "$REPO_ROOT/scripts/mock-api-server.mjs" --port "$E2E_MOCK_PORT" >"$OPENHUMAN_WORKSPACE/mock.log" 2>&1 &MOCK_PID=$!wait_for_http "http://127.0.0.1:${E2E_MOCK_PORT}/__admin/health" "mock backend"+ # Refuse a bundle built for different ports (#6478).+ #+ # `VITE_BACKEND_URL` is substituted into the bundle at BUILD time and has no+ # runtime override in web mode, so a bundle built on one `E2E_MOCK_PORT` and+ # served against another sends the frontend's own API calls to a mock that is+ # not listening — while the core, reading `api_url` from the `config.toml`+ # generated below, reaches the right one. Some specs fail and others pass, with+ # nothing reporting why. Checked before anything is started so the failure is a+ # one-line message rather than a debugging session.+ BUILD_PORTS_FILE="$APP_DIR/dist-web/.e2e-build-ports.json"+ if [ ! -f "$BUILD_PORTS_FILE" ]; then+ echo "ERROR: $APP_DIR/dist-web has no .e2e-build-ports.json, so the ports it was built for are unknown." >&2- echo " It predates this check. Rebuild with: pnpm test:e2e:web:build" >&2++ echo " It predates this check. Rebuild with: pnpm --filter openhuman-app test:e2e:web:build" >&2+ exit 1+ fi+ BUILT_MOCK_PORT="$(sed -n 's/.*"e2e_mock_port"[[:space:]]*:[[:space:]]*"\([0-9]*\)".*/\1/p' "$BUILD_PORTS_FILE")"+ if [ -z "$BUILT_MOCK_PORT" ]; then- echo "ERROR: could not read e2e_mock_port from $BUILD_PORTS_FILE. Rebuild with: pnpm test:e2e:web:build" >&2++ echo "ERROR: could not read e2e_mock_port from $BUILD_PORTS_FILE. Rebuild with: pnpm --filter openhuman-app test:e2e:web:build" >&2+ exit 1+ fi+ if [ "$BUILT_MOCK_PORT" != "$E2E_MOCK_PORT" ]; then+ echo "ERROR: dist-web was built for E2E_MOCK_PORT=$BUILT_MOCK_PORT but this session uses $E2E_MOCK_PORT." >&2+ echo " The backend URL is baked into the bundle and cannot be changed at run time," >&2+ echo " so the app would call a mock that is not listening while the core called the right one." >&2- echo " Rebuild with the ports this session uses: E2E_MOCK_PORT=$E2E_MOCK_PORT pnpm test:e2e:web:build" >&2++ echo " Rebuild with the ports this session uses: E2E_MOCK_PORT=$E2E_MOCK_PORT pnpm --filter openhuman-app test:e2e:web:build" >&2+ exit 1+ fi+export OPENHUMAN_CORE_BIN="$E2E_WEB_CORE_TARGET_DIR/debug/openhuman-core"if [ ! -x "$OPENHUMAN_CORE_BIN" ]; then-- echo "ERROR: standalone core binary is missing at $OPENHUMAN_CORE_BIN. Run pnpm test:e2e:web:build first." >&2++ echo "ERROR: standalone core binary is missing at $OPENHUMAN_CORE_BIN. Run pnpm --filter openhuman-app test:e2e:web:build first." >&2exit 1fidiff --cc scripts/__tests__/e2e-web-bundle-guard.test.mjsindex 691aab8cae,0000000000..7116b35c95mode 100644,000000..100644--- a/scripts/__tests__/e2e-web-bundle-guard.test.mjs+++ b/scripts/__tests__/e2e-web-bundle-guard.test.mjs@@@ -1,204 -1,0 +1,213 @@@+// Regression tests for the web E2E bundle guard (#5920).+//+// `pnpm build:web` exits 0 with a bundle that points at the wrong backend and+// has the E2E affordances compiled out. e2e-web-session.sh used to serve it+// anyway, and every Playwright spec then failed as though the product had+// regressed. e2e-web-build.sh now marks the bundles it builds, and the session+// refuses to start without that mark.+//+// These run the REAL scripts, copied into a temporary tree so that their+// `SCRIPT_DIR`/`APP_DIR`/`REPO_ROOT` resolve there, with every external command+// they reach (node, curl, pnpm, rustc, cargo) replaced by a stub on PATH. No+// Rust build, pnpm install or network is needed.++import assert from "node:assert/strict";+import { execFileSync } from "node:child_process";+import fs from "node:fs";+import os from "node:os";+import path from "node:path";+import test from "node:test";+import { fileURLToPath } from "node:url";++const repoRoot = path.join(+ path.dirname(fileURLToPath(import.meta.url)),+ "..",+ "..",+);+const MARKER = ".openhuman-e2e-bundle";++function writeExecutable(file, body) {+ fs.mkdirSync(path.dirname(file), { recursive: true });+ fs.writeFileSync(file, body, { mode: 0o755 });+}++/**+ * A temporary checkout holding a copy of one real app script, plus stubs.+ *+ * @param {string} script path of the script under app/scripts/+ */+function makeTree(script) {+ const root = fs.mkdtempSync(path.join(os.tmpdir(), "e2e-web-bundle-guard-"));+ const bin = path.join(root, "bin");+ const log = path.join(root, "calls.log");+ fs.mkdirSync(path.join(root, "app", "scripts"), { recursive: true });+ fs.copyFileSync(+ path.join(repoRoot, "app", "scripts", script),+ path.join(root, "app", "scripts", script),+ );++ // Every stub records that it ran, so a test can prove what was reached.+ const record = (name) => `echo "${name} $*" >> "${log}"`;++ // The mock backend "starts" and exits at once; curl reports every health+ // probe as ready, so the session moves straight on to its next check.+ writeExecutable(path.join(bin, "node"), `#!/usr/bin/env bash\n${record("node")}\n`);+ writeExecutable(path.join(bin, "curl"), `#!/usr/bin/env bash\n${record("curl")}\n`);++ // `pnpm run build:web` behaves like Vite's `emptyOutDir: true`: it replaces+ // dist-web wholesale, taking any marker from a previous build with it.+ writeExecutable(+ path.join(bin, "pnpm"),+ `#!/usr/bin/env bash+${record("pnpm")}+if [ "$1 $2" = "run build:web" ]; then+ rm -rf dist-web && mkdir -p dist-web && echo '<!doctype html>' > dist-web/index.html+fi+`,+ );+ writeExecutable(path.join(bin, "rustc"), `#!/usr/bin/env bash\necho 'host: test-triple'\n`);+ writeExecutable(path.join(bin, "cargo"), `#!/usr/bin/env bash\n${record("cargo")}\n`);++ // The repo-level helpers e2e-web-build.sh shells out to.+ writeExecutable(+ path.join(root, "scripts", "ci", "product-features.sh"),+ "#!/usr/bin/env bash\necho voice\n",+ );+ writeExecutable(+ path.join(root, "scripts", "ci-cancel-aware.sh"),+ '#!/usr/bin/env bash\nexec "$@"\n',+ );++ const calls = () =>+ fs.existsSync(log)+ ? fs.readFileSync(log, "utf8").split("\n").filter(Boolean)+ : [];+ const cleanup = () => fs.rmSync(root, { recursive: true, force: true });+ return { root, bin, calls, cleanup };+}++function run(tree, script) {+ const env = {+ ...process.env,+ PATH: `${tree.bin}:${process.env.PATH}`,++ // Do not let a developer's shell select real build tools or different++ // harness ports; the assertions exercise the fixed contract below.++ CARGO_BIN: path.join(tree.bin, "cargo"),++ E2E_MOCK_PORT: "18473",++ OPENHUMAN_CORE_PORT: "17788",+ RUST_HOST_TRIPLE: "test-triple",+ OPENHUMAN_WORKSPACE: path.join(tree.root, "workspace"),+ E2E_WEB_CORE_TARGET_DIR: path.join(tree.root, "target"),+ };+ const file = path.join(tree.root, "app", "scripts", script);+ try {+ const output = execFileSync("bash", [file], {+ encoding: "utf8",+ env,+ stdio: ["ignore", "pipe", "pipe"],+ });+ return { status: 0, output };+ } catch (err) {+ return { status: err.status, output: `${err.stdout ?? ""}${err.stderr ?? ""}` };+ }+}++test("the session refuses a dist-web that e2e-web-build.sh did not produce", () => {+ // Exactly #5920: a bundle is present — as after `pnpm build:web` — but it+ // carries no E2E marker.+ const tree = makeTree("e2e-web-session.sh");+ try {+ fs.mkdirSync(path.join(tree.root, "app", "dist-web"), { recursive: true });+ fs.writeFileSync(path.join(tree.root, "app", "dist-web", "index.html"), "<!doctype html>");++ const res = run(tree, "e2e-web-session.sh");++ assert.equal(res.status, 1, res.output);+ assert.match(res.output, /was not built for E2E/);- assert.match(res.output, /pnpm test:e2e:web:build/);++ assert.match(res.output, /pnpm --filter openhuman-app test:e2e:web:build/);+ // Refused before anything was started, not after.+ assert.deepEqual(+ tree.calls().filter((c) => c.startsWith("node ")),+ [],+ "the mock backend must not be started for a bundle that will be refused",+ );+ } finally {+ tree.cleanup();+ }+});++test("the session accepts a marked bundle and proceeds past the guard", () => {+ // Pins that the guard is not simply always-fail. With the marker present the+ // session starts the mock backend and reaches its next precondition — the+ // standalone core binary, deliberately absent here.+ const tree = makeTree("e2e-web-session.sh");+ try {+ const distWeb = path.join(tree.root, "app", "dist-web");+ fs.mkdirSync(distWeb, { recursive: true });+ fs.writeFileSync(path.join(distWeb, MARKER), "VITE_OPENHUMAN_TARGET=web\n");++ fs.writeFileSync(++ path.join(distWeb, ".e2e-build-ports.json"),++ '{"e2e_mock_port":"18473","openhuman_core_port":"17788"}\n',++ );++ const res = run(tree, "e2e-web-session.sh");++ assert.doesNotMatch(res.output, /was not built for E2E/);+ assert.match(res.output, /standalone core binary is missing/);+ assert.ok(+ tree.calls().some((c) => c.includes("mock-api-server.mjs")),+ `expected the mock backend to be started:\n${tree.calls().join("\n")}`,+ );+ } finally {+ tree.cleanup();+ }+});++test("e2e-web-build.sh marks the bundle it builds, recording the E2E settings", () => {+ const tree = makeTree("e2e-web-build.sh");+ try {+ const res = run(tree, "e2e-web-build.sh");+ assert.equal(res.status, 0, res.output);++ const marker = path.join(tree.root, "app", "dist-web", MARKER);+ assert.ok(fs.existsSync(marker), `no ${MARKER} after the E2E build:\n${res.output}`);+ const recorded = fs.readFileSync(marker, "utf8");+ assert.match(recorded, /^VITE_OPENHUMAN_TARGET=web$/m);+ assert.match(recorded, /^VITE_OPENHUMAN_E2E_DEFAULT_CORE_MODE=cloud$/m);+ assert.match(recorded, /^VITE_BACKEND_URL=http:\/\/127\.0\.0\.1:18473$/m);+ } finally {+ tree.cleanup();+ }+});++test("a later plain build:web leaves no marker, so the session refuses it", () => {+ // The whole mechanism rests on this: an E2E build followed by an ordinary+ // `pnpm build:web` must not keep the old marker next to the new bundle.+ const tree = makeTree("e2e-web-build.sh");+ try {+ assert.equal(run(tree, "e2e-web-build.sh").status, 0);+ const appDir = path.join(tree.root, "app");+ const marker = path.join(appDir, "dist-web", MARKER);+ // Precondition, so this cannot pass against a build that never marked anything.+ assert.ok(fs.existsSync(marker), "the E2E build should have left a marker");++ execFileSync(path.join(tree.bin, "pnpm"), ["run", "build:web"], { cwd: appDir });++ assert.equal(fs.existsSync(marker), false, "a plain build:web must not keep the E2E marker");+ } finally {+ tree.cleanup();+ }+});++test("the web build empties its output directory, which the marker relies on", () => {+ // The stub above models `emptyOutDir: true`. If the real config stopped+ // emptying dist-web, a stale marker would survive a plain build and the guard+ // would wave through exactly the bundle it exists to refuse.+ const configs = fs+ .readdirSync(path.join(repoRoot, "app"))+ .filter((f) => /^vite\.config\.[cm]?[jt]s$/.test(f));+ assert.equal(configs.length, 1, `expected one app/vite.config.*, found: ${configs}`);+ const source = fs.readFileSync(path.join(repoRoot, "app", configs[0]), "utf8");+ assert.match(source, /outDir:\s*isWebTarget\s*\?\s*["']\.\.\/dist-web["']/);+ assert.match(source, /emptyOutDir:\s*true/);+});