Self-improving AI Employees for everyone
Python ai-agentsai-employeeai-employeesassistantautonomous-agentsco-employeescompanygrok-botinstinctloop-agentsmuseown-your-datapersonalself-hosted
feat(desktop): bundle bun instead of Node
trohitg683d1b249851
diff --git a/.github/workflows/desktop-ci.yml b/.github/workflows/desktop-ci.ymlindex 165cb153..359585ac 100644--- a/.github/workflows/desktop-ci.yml+++ b/.github/workflows/desktop-ci.yml@@ -40,7 +40,7 @@ jobs:- name: Install workspace dependenciesrun: bun install --frozen-lockfile- - name: Build client and Node sidecar+ - name: Build client and JS executor sidecarrun: |bun run --filter react-flow-client buildbun run --filter opencompany-nodejs-executor builddiff --git a/.github/workflows/desktop-release.yml b/.github/workflows/desktop-release.ymlindex e1244603..1c06ff82 100644--- a/.github/workflows/desktop-release.yml+++ b/.github/workflows/desktop-release.yml@@ -1,6 +1,6 @@# Desktop installers for Windows, macOS and Linux, attached to the GitHub-# Release for the tag. Kept separate from release.yml (npm publish) so a-# desktop failure never blocks the npm release and the strings that+# Release for the tag. Kept separate from release.yml (registry publish) so a+# desktop failure never blocks the package release and the strings that# cli/tests/test_release_pipeline_config.py locks stay untouched.## Unsigned first release: no certificates are read here. Signing is wired@@ -63,7 +63,7 @@ jobs:- name: Install workspace dependenciesrun: bun install --frozen-lockfile- - name: Build client and Node sidecar+ - name: Build client and JS executor sidecar# Targeted builds only: `bun run build` would also uv-sync a server# venv and download the Temporal binary, neither of which ships.run: |diff --git a/desktop/README.md b/desktop/README.mdindex 79cc4ec5..0f879db6 100644--- a/desktop/README.md+++ b/desktop/README.md@@ -1,9 +1,9 @@# OpenCompany desktop shellElectron host for the OpenCompany backend. It ships `uv`, a standalone-Python and Node inside the installer, provisions the backend's virtual-environment in the user's data directory on first launch, spawns uvicorn,-and shows the backend-served UI in a native window.+Python and bun inside the installer (no Node, no npm), provisions the+backend's virtual environment in the user's data directory on first+launch, spawns uvicorn, and shows the backend-served UI in a native window.Full documentation: [docs-internal/desktop_app.md](../docs-internal/desktop_app.md)and the backend contract indiff --git a/desktop/electron-builder.yml b/desktop/electron-builder.ymlindex 640f56a6..5435313e 100644--- a/desktop/electron-builder.yml+++ b/desktop/electron-builder.yml@@ -4,7 +4,7 @@# copied verbatim outside the asar, because Python needs real files:# resources/app-root/ the backend sibling layout (server/, client/dist,# .env.template, package.json, .opencompany/workflows)-# resources/runtime/ uv, python, node for THIS os/arch+# resources/runtime/ uv, python, bun for THIS os/arch# Both come from desktop/stage/ (scripts/stage.ts). The ${os}-${arch}# macro selects the per-target runtime dir so one config serves every# platform and both macOS architectures.@@ -36,8 +36,8 @@ extraResources:to: runtime/- from: ../LICENSEto: licenses/OpenCompany-LICENSE- - from: stage/runtime/${os}-${arch}/node/LICENSE- to: licenses/Node-LICENSE+ - from: stage/runtime/${os}-${arch}/bun/LICENSE.md+ to: licenses/Bun-LICENSE.md- from: stage/runtime/${os}-${arch}/python/LICENSE.txtto: licenses/Python-LICENSE.txt@@ -86,7 +86,7 @@ linux:category: Officemaintainer: OpenCompany contributorssynopsis: Agent-first workflow automation, running locally- description: OpenCompany desktop app. Bundles uv, Python and Node; provisions the backend on first launch.+ description: OpenCompany desktop app. Bundles uv, Python and bun; provisions the backend on first launch.deb:depends:- libgtk-3-0diff --git a/desktop/runtimes.json b/desktop/runtimes.jsonindex 70b0661e..ded28075 100644--- a/desktop/runtimes.json+++ b/desktop/runtimes.json@@ -1,5 +1,5 @@{- "_comment": "Pinned third-party runtimes bundled into the desktop app. Target keys are <os>-<arch> using electron-builder's ${os}/${arch} spellings (win|mac|linux, x64|arm64). Every archive is verified against the upstream checksum manifest at fetch time (scripts/fetch-runtimes.ts); bump a version here and nowhere else. The Python pin must satisfy server/pyproject.toml requires-python and match the root .python-version major.minor.",+ "_comment": "Pinned third-party runtimes bundled into the desktop app. Target keys are <os>-<arch> using electron-builder's ${os}/${arch} spellings (win|mac|linux, x64|arm64). Every archive is verified against the upstream checksum manifest at fetch time (scripts/fetch-runtimes.ts); bump a version here and nowhere else. The Python pin must satisfy server/pyproject.toml requires-python and match the root .python-version major.minor. bun is the only JavaScript runtime shipped: it runs the JS executor sidecar and installs + runs the npm-registry CLIs the plugins need (no Node, no npm).","uv": {"version": "0.12.13","base": "https://github.com/astral-sh/uv/releases/download/{version}/",@@ -23,15 +23,16 @@"linux-x64": { "file": "cpython-3.12.14+20260901-x86_64-unknown-linux-gnu-install_only_stripped.tar.gz", "strip": 1 }}},- "node": {- "version": "22.23.2",- "base": "https://nodejs.org/dist/v{version}/",+ "bun": {+ "version": "1.4.0",+ "base": "https://github.com/oven-sh/bun/releases/download/bun-v{version}/","checksum": "SHASUMS256.txt",+ "license": "https://raw.githubusercontent.com/oven-sh/bun/bun-v{version}/LICENSE.md","assets": {- "win-x64": { "file": "node-v22.23.2-win-x64.zip", "strip": 1 },- "mac-arm64": { "file": "node-v22.23.2-darwin-arm64.tar.gz", "strip": 1 },- "mac-x64": { "file": "node-v22.23.2-darwin-x64.tar.gz", "strip": 1 },- "linux-x64": { "file": "node-v22.23.2-linux-x64.tar.xz", "strip": 1 }+ "win-x64": { "file": "bun-windows-x64.zip", "strip": 1 },+ "mac-arm64": { "file": "bun-darwin-aarch64.zip", "strip": 1 },+ "mac-x64": { "file": "bun-darwin-x64.zip", "strip": 1 },+ "linux-x64": { "file": "bun-linux-x64.zip", "strip": 1 }}}}diff --git a/desktop/scripts/fetch-runtimes.ts b/desktop/scripts/fetch-runtimes.tsindex 7df6d0d0..a6b13afd 100644--- a/desktop/scripts/fetch-runtimes.ts+++ b/desktop/scripts/fetch-runtimes.ts@@ -1,7 +1,7 @@/*** Download + verify + extract the pinned third-party runtimes (uv,- * python-build-standalone, Node) for one or more targets into- * `stage/runtime/<os>-<arch>/{uv,python,node}`.+ * python-build-standalone, bun) for one or more targets into+ * `stage/runtime/<os>-<arch>/{uv,python,bun}`.** bun run scripts/fetch-runtimes.ts # host target* bun run scripts/fetch-runtimes.ts --target mac-arm64,mac-x64@@ -10,17 +10,18 @@* checked against the upstream checksum manifest before extraction:* uv -> `<asset>.sha256` sidecar files on the GitHub release* python -> the release's `SHA256SUMS`- * node -> `SHASUMS256.txt` in the dist directory+ * bun -> `SHASUMS256.txt` on the GitHub release* Downloads are cached in `vendor/<name>/<version>/` so CI can restore* them; a cache hit is still re-verified.** Resulting layout (what src/main/paths.ts expects):* runtime/uv/uv[.exe]* runtime/python/python.exe (win) | runtime/python/bin/python3 (posix)- * runtime/node/node.exe, npm.cmd (win) | runtime/node/bin/{node,npm,npx} (posix)+ * runtime/bun/bun.exe (win) | runtime/bun/bun (posix)+ * runtime/bun/LICENSE.md (the release ships no license file inside the zip)*/-import { chmodSync, existsSync, readdirSync, rmSync } from "node:fs";+import { chmodSync, copyFileSync, existsSync, readdirSync, rmSync, writeFileSync } from "node:fs";import { join } from "node:path";import {@@ -50,12 +51,14 @@ interface RuntimeSpec {release?: string;base: string;checksum: "sidecar" | string;+ /** URL of the license text to drop into the runtime dir when the archive carries none. */+ license?: string;assets: Record<string, Asset>;}interface Runtimes {uv: RuntimeSpec;python: RuntimeSpec;- node: RuntimeSpec;+ bun: RuntimeSpec;}const RUNTIMES = readJson<Runtimes>(join(DESKTOP_DIR, "runtimes.json"));@@ -104,6 +107,13 @@ async function fetchOne(name: keyof Runtimes, spec: RuntimeSpec, target: TargetKconst dest = join(STAGE_DIR, "runtime", target, name);rmSync(dest, { recursive: true, force: true });extractArchive(archive, dest, asset.strip);+ if (spec.license) {+ // Cached next to the archive so an offline re-stage still has it.+ const licenseUrl = spec.license.replace("{version}", spec.version ?? "").replace("{release}", spec.release ?? "");+ const cached = join(cacheDir, "LICENSE.md");+ if (!existsSync(cached)) writeFileSync(cached, await fetchText(licenseUrl));+ copyFileSync(cached, join(dest, "LICENSE.md"));+ }return dest;}@@ -124,36 +134,50 @@ function verifyLayout(target: TargetKey, dirs: Record<keyof Runtimes, string>):const checks: Array<[string, string]> = [["uv", join(dirs.uv, win ? "uv.exe" : "uv")],["python", win ? join(dirs.python, "python.exe") : join(dirs.python, "bin", "python3")],- ["node", win ? join(dirs.node, "node.exe") : join(dirs.node, "bin", "node")],- ["npm", win ? join(dirs.node, "npm.cmd") : join(dirs.node, "bin", "npm")],+ ["bun", join(dirs.bun, win ? "bun.exe" : "bun")],+ ["bun license", join(dirs.bun, "LICENSE.md")],];for (const [label, path] of checks) {if (!existsSync(path)) fail(`${label} missing after extraction: ${path}`);}}+/** Drop runtime dirs a previous stage left behind that runtimes.json no longer lists (e.g. node/). */+function pruneStaleRuntimes(target: TargetKey): void {+ const root = join(STAGE_DIR, "runtime", target);+ if (!existsSync(root)) return;+ const known = new Set(Object.keys(RUNTIMES));+ for (const entry of readdirSync(root)) {+ if (!known.has(entry)) {+ rmSync(join(root, entry), { recursive: true, force: true });+ log(`pruned stale runtime dir ${target}/${entry}`);+ }+ }+}+export async function fetchRuntimes(targets: TargetKey[]): Promise<void> {for (const target of targets) {+ pruneStaleRuntimes(target);const dirs = {uv: await fetchOne("uv", RUNTIMES.uv, target),python: await fetchOne("python", RUNTIMES.python, target),- node: await fetchOne("node", RUNTIMES.node, target),+ bun: await fetchOne("bun", RUNTIMES.bun, target),};if (target.startsWith(process.platform === "win32" ? "win" : process.platform === "darwin" ? "mac" : "linux")) {markExecutable(dirs.uv);markExecutable(dirs.python);- markExecutable(dirs.node);+ markExecutable(dirs.bun);}verifyLayout(target, dirs);log(`runtime staged for ${target} -> ${join(STAGE_DIR, "runtime", target)}`);}}-export function pinnedVersions(): { uv: string; python: string; node: string } {+export function pinnedVersions(): { uv: string; python: string; bun: string } {return {uv: RUNTIMES.uv.version!,python: RUNTIMES.python.version!,- node: RUNTIMES.node.version!,+ bun: RUNTIMES.bun.version!,};}diff --git a/desktop/scripts/stage.ts b/desktop/scripts/stage.tsindex ce7d86eb..3b638001 100644--- a/desktop/scripts/stage.ts+++ b/desktop/scripts/stage.ts@@ -2,22 +2,21 @@* Assemble `stage/` — everything electron-builder ships as extraResources.** stage/app-root/ the backend tree in the sibling layout core.approot expects- * stage/runtime/<t>/ uv, python, node for target <t> (see fetch-runtimes.ts)+ * stage/runtime/<t>/ uv, python, bun for target <t> (see fetch-runtimes.ts)* stage/manifest.json what was staged, for the invariant test + release notes*- * The app-root file list is NOT hand-maintained. `npm pack --dry-run --json`- * at the repo root yields exactly the files the published npm package ships- * (the root package.json `files` allowlist filtered by .npmignore), which is- * the same sibling layout `company start` already runs from. We take that- * list, drop what a desktop bundle never needs (the CLI, install scripts,- * client sources, backend tests) and force-include the few files the- * .npmignore hides but the desktop needs (server/uv.lock).+ * The app-root file list is NOT hand-maintained. `bun pm pack --dry-run` at+ * the repo root lists exactly the files the published package ships (the+ * root package.json `files` allowlist filtered by .npmignore), which is the+ * same sibling layout `company start` already runs from. We take that list,+ * drop what a desktop bundle never needs (the CLI, install scripts, client+ * sources, backend tests) and force-include the few files the .npmignore+ * hides but the desktop needs (server/uv.lock).*- * The Node executor sidecar is re-bundled here with its dependencies- * inlined: server/nodejs/dist/index.js is built with `--packages=external`,- * and under bun's isolated linker `server/nodejs/node_modules/express` is a- * symlink into <repo>/node_modules/.bun/ — copying it verbatim would ship a- * dangling link and the JS executor would fail on first use.+ * The JS executor sidecar is built here with the sidecar package's own+ * `bun build` script (a self-contained bundle with express inlined, run by+ * the bundled bun at runtime) rather than copied from the checkout, so a+ * stale or missing dist/ in the working tree can never reach a release.** bun run scripts/stage.ts # host target runtime* bun run scripts/stage.ts --target mac-arm64,mac-x64@@ -41,7 +40,7 @@ const DROP_PREFIXES = ["client/public/","server/tests/","server/scripts/",- "server/nodejs/", // re-bundled below+ "server/nodejs/", // built below with the sidecar's own bun build"server/experiments/","server/.venv/",];@@ -55,13 +54,18 @@ const DROP_SUFFIXES = [".db", ".db-journal", ".db-shm", ".db-wal", ".sqlite", "./** Files the .npmignore hides (lockfiles) but the desktop must ship. */const FORCE_INCLUDE = ["server/uv.lock", "server/pyproject.toml", "server/nodejs/package.json", ".env.template", "package.json"];-function npmPackFileList(): string[] {- const out = run(process.platform === "win32" ? "npm.cmd" : "npm", ["pack", "--dry-run", "--json", "--ignore-scripts"], { cwd: REPO_ROOT });- const start = out.indexOf("[");- const parsed = JSON.parse(out.slice(start)) as Array<{ files: Array<{ path: string }> }>;- const first = parsed[0];- if (!first) fail("npm pack --dry-run returned no package");- return first.files.map((f) => f.path.replace(/\\/g, "/"));+const BUN = process.platform === "win32" ? "bun.exe" : "bun";++/** The published file list, from bun's own packer (`packed <size> <path>` lines). */+function packFileList(): string[] {+ const out = run(BUN, ["pm", "pack", "--dry-run", "--ignore-scripts"], { cwd: REPO_ROOT });+ const files: string[] = [];+ for (const line of out.split(/\r?\n/)) {+ const m = /^packed\s+\S+\s+(.+?)\s*$/.exec(line);+ if (m) files.push(m[1]!.replace(/\\/g, "/"));+ }+ if (files.length === 0) fail("bun pm pack --dry-run listed no files");+ return files;}function keep(path: string): boolean {@@ -83,28 +87,15 @@ function copyInto(rel: string): void {function bundleSidecar(): void {const sidecarDir = join(REPO_ROOT, "server", "nodejs");+ const built = join(sidecarDir, "dist", "index.js");const outfile = join(APP_ROOT, "server", "nodejs", "dist", "index.js");+ // One definition of the build: the sidecar package's own script+ // (`bun build --target=bun`, which inlines express). It resolves through+ // the sidecar's node_modules, so run it from there.+ run(BUN, ["run", "build"], { cwd: sidecarDir });+ if (!existsSync(built)) fail(`sidecar build produced no ${built}`);mkdirSync(dirname(outfile), { recursive: true });- // esbuild resolves through the sidecar's own node_modules (bun symlinks- // are followed), so run it from there. The banner restores `require`- // for the CJS-style dynamic requires inside express/body-parser once- // they are inlined into an ESM output.- const esbuild = process.platform === "win32" ? "bun.exe" : "bun";- run(- esbuild,- [- "x",- "esbuild",- "src/index.ts",- "--bundle",- "--platform=node",- "--target=node22",- "--format=esm",- "--banner:js=import { createRequire as __oc_createRequire } from 'node:module'; const require = __oc_createRequire(import.meta.url);",- `--outfile=${outfile}`,- ],- { cwd: sidecarDir },- );+ copyFileSync(built, outfile);const text = readFileSync(outfile, "utf-8");if (/^\s*(import|export)[^\n]*['"]express['"]/m.test(text) || /require\(["']express["']\)/.test(text)) {fail("sidecar bundle still references express externally; inlining failed");@@ -116,7 +107,7 @@ function stageAppRoot(): { files: number } {rmSync(APP_ROOT, { recursive: true, force: true });mkdirSync(APP_ROOT, { recursive: true });- const listed = npmPackFileList();+ const listed = packFileList();const kept = listed.filter(keep);const all = new Set<string>([...kept, ...FORCE_INCLUDE]);for (const rel of all) copyInto(rel);diff --git a/desktop/src/main/env.ts b/desktop/src/main/env.tsindex bb151e4a..9729fdfe 100644--- a/desktop/src/main/env.ts+++ b/desktop/src/main/env.ts@@ -12,7 +12,7 @@*/import { existsSync, readFileSync } from "node:fs";-import { delimiter } from "node:path";+import { delimiter, join } from "node:path";import type { Layout } from "./paths";@@ -110,18 +110,24 @@ export function buildBackendEnv(opts: BackendEnvOptions): NodeJS.ProcessEnv {UV_SYSTEM_CERTS: "1",};if (existsSync(layout.uvBin)) contract.OPENCOMPANY_UV_BIN = layout.uvBin;- if (existsSync(layout.nodeBin)) contract.OPENCOMPANY_NODE_BIN = layout.nodeBin;+ if (existsSync(layout.bunBin)) {+ contract.OPENCOMPANY_BUN_BIN = layout.bunBin;+ // Keep bun's own package cache and global state inside the app's data+ // dir rather than the user's ~/.bun, which may belong to a dev install.+ contract.BUN_INSTALL = layout.bunHomeDir;+ contract.BUN_INSTALL_CACHE_DIR = join(layout.bunHomeDir, "install", "cache");+ }const user = readUserEnvFile(layout.userEnvFile);for (const [k, v] of Object.entries(user)) {if (!LOCKED_KEYS.has(k)) contract[k] = v;}- // PATH: bundled node (node/npm/npx) and uv first; the bundled bare Python- // is deliberately NOT added so plugins never pick it over the venv.+ // PATH: bundled bun and uv first; the bundled bare Python is deliberately+ // NOT added so plugins never pick it over the venv.const pathKey = Object.keys(base).find((k) => k.toUpperCase() === "PATH") ?? "PATH";const uvDir = existsSync(layout.uvBin) ? layout.uvBin.slice(0, layout.uvBin.lastIndexOf(layout.uvBin.includes("\\") ? "\\" : "/")) : "";- contract[pathKey] = prependPath(base[pathKey], existsSync(layout.nodeBin) ? layout.nodeBinDir : "", uvDir, layout.uvToolBinDir);+ contract[pathKey] = prependPath(base[pathKey], existsSync(layout.bunBin) ? layout.bunDir : "", uvDir, layout.uvToolBinDir);return { ...base, ...contract };}diff --git a/desktop/src/main/paths.ts b/desktop/src/main/paths.tsindex f1e6e522..9437cc05 100644--- a/desktop/src/main/paths.ts+++ b/desktop/src/main/paths.ts@@ -4,7 +4,7 @@* resources/ read-only, shipped inside the app bundle (electron-builder* extraResources) or, in development, `desktop/stage/`.* app-root/ backend sibling layout -> OPENCOMPANY_APP_ROOT- * runtime/{uv,python,node}+ * runtime/{uv,python,bun}* userData/ Electron's per-user writable dir (%APPDATA%/OpenCompany,* ~/Library/Application Support/OpenCompany, ~/.config/OpenCompany)* pyenv/venv UV_PROJECT_ENVIRONMENT (the backend interpreter)@@ -12,6 +12,7 @@* pyenv/cache UV_CACHE_DIR* pyenv/tools UV_TOOL_DIR / bin (browser-harness etc.)* pycache/ PYTHONPYCACHEPREFIX (the bundle is read-only)+ * bun/ BUN_INSTALL (bun's package cache for the plugin CLIs)* logs/* desktop-state.json persisted port etc.* desktop.env operator overrides -> OPENCOMPANY_ENV_FILE@@ -34,9 +35,11 @@ export interface Layout {runtimeDir: string;uvBin: string;pythonBin: string;- nodeDir: string;- nodeBinDir: string;- nodeBin: string;+ /** The bundled bun: the JS executor runtime and the installer for the npm-registry CLIs. */+ bunDir: string;+ bunBin: string;+ /** BUN_INSTALL for the backend: bun's package cache and global state, under userData. */+ bunHomeDir: string;userData: string;pyenvDir: string;venvDir: string;@@ -83,8 +86,7 @@ export function resolveLayout(opts: LayoutOptions): Layout {const appRoot = opts.appRoot ?? join(resources, "app-root");const runtimeDir = opts.runtimeDir ?? join(resources, "runtime");const win = platform === "win32";- const nodeDir = join(runtimeDir, "node");- const nodeBinDir = win ? nodeDir : join(nodeDir, "bin");+ const bunDir = join(runtimeDir, "bun");const pyenvDir = join(opts.userData, "pyenv");return {platform,@@ -95,9 +97,9 @@ export function resolveLayout(opts: LayoutOptions): Layout {runtimeDir,uvBin: join(runtimeDir, "uv", win ? "uv.exe" : "uv"),pythonBin: bundledPython(runtimeDir, platform),- nodeDir,- nodeBinDir,- nodeBin: join(nodeBinDir, win ? "node.exe" : "node"),+ bunDir,+ bunBin: join(bunDir, win ? "bun.exe" : "bun"),+ bunHomeDir: join(opts.userData, "bun"),userData: opts.userData,pyenvDir,venvDir: join(pyenvDir, "venv"),@@ -121,6 +123,6 @@ export function layoutReport(layout: Layout): Record<string, boolean> {envTemplate: existsSync(join(layout.appRoot, ".env.template")),uv: existsSync(layout.uvBin),python: existsSync(layout.pythonBin),- node: existsSync(layout.nodeBin),+ bun: existsSync(layout.bunBin),};}diff --git a/desktop/tests/invariants/staged-tree.test.ts b/desktop/tests/invariants/staged-tree.test.tsindex 2e96b517..749a1b00 100644--- a/desktop/tests/invariants/staged-tree.test.ts+++ b/desktop/tests/invariants/staged-tree.test.ts@@ -68,12 +68,11 @@ describe.skipIf(!staged)("staged app-root", () => {expect(leaked).toEqual([]);});- it("re-bundled the Node sidecar with express inlined", () => {+ it("bundled the JS executor sidecar with express inlined", () => {const js = readFileSync(join(APP_ROOT, "server", "nodejs", "dist", "index.js"), "utf-8");expect(js.length).toBeGreaterThan(50_000);expect(/from\s+["']express["']/.test(js)).toBe(false);expect(/require\(["']express["']\)/.test(js)).toBe(false);- expect(js).toContain("createRequire");});it("carries the version the root package.json declares", () => {@@ -83,38 +82,45 @@ describe.skipIf(!staged)("staged app-root", () => {const manifest = JSON.parse(readFileSync(join(STAGE, "manifest.json"), "utf-8")) as { appVersion: string; runtimes: Record<string, string> };expect(manifest.appVersion).toBe(root.version);expect(manifest.runtimes.python ?? "").toMatch(/^3\.12\./);+ expect(manifest.runtimes.bun ?? "").toMatch(/^\d+\.\d+\.\d+$/);+ expect(manifest.runtimes.node).toBeUndefined();});});describe.skipIf(!staged || !runtimesStaged)("staged runtimes", () => {const layout = resolveLayout({ resources: STAGE, userData: join(STAGE, "_ud"), runtimeDir: RUNTIME });- it("has uv, python and node where paths.ts looks", () => {+ it("has uv, python and bun where paths.ts looks, and no node or npm", () => {expect(existsSync(layout.uvBin), layout.uvBin).toBe(true);expect(existsSync(layout.pythonBin), layout.pythonBin).toBe(true);- expect(existsSync(layout.nodeBin), layout.nodeBin).toBe(true);- const npm = process.platform === "win32" ? join(layout.nodeDir, "npm.cmd") : join(layout.nodeBinDir, "npm");- expect(existsSync(npm), npm).toBe(true);+ expect(existsSync(layout.bunBin), layout.bunBin).toBe(true);+ expect(existsSync(join(layout.bunDir, "LICENSE.md"))).toBe(true);+ expect(existsSync(join(layout.runtimeDir, "node"))).toBe(false);});it("runs the bundled interpreters", () => {const py = spawnSync(layout.pythonBin, ["--version"], { encoding: "utf-8" });expect(py.status, py.stderr).toBe(0);expect(`${py.stdout}${py.stderr}`).toMatch(/Python 3\.12\./);- const node = spawnSync(layout.nodeBin, ["--version"], { encoding: "utf-8" });- expect(node.status).toBe(0);- expect(node.stdout.trim()).toMatch(/^v22\./);+ const bun = spawnSync(layout.bunBin, ["--version"], { encoding: "utf-8" });+ expect(bun.status).toBe(0);+ expect(bun.stdout.trim()).toMatch(/^\d+\.\d+\.\d+$/);const uv = spawnSync(layout.uvBin, ["--version"], { encoding: "utf-8" });expect(uv.status).toBe(0);expect(uv.stdout).toMatch(/^uv \d+\.\d+\.\d+/);});- it("the re-bundled sidecar boots on the bundled node", async () => {+ it("the bundled sidecar boots on the bundled bun with no node on PATH", async () => {const { spawn } = await import("node:child_process");const port = 5600 + Math.floor(Math.random() * 300);- const child = spawn(layout.nodeBin, [join(APP_ROOT, "server", "nodejs", "dist", "index.js")], {+ const pathKey = Object.keys(process.env).find((k) => k.toUpperCase() === "PATH") ?? "PATH";+ const strippedPath = (process.env[pathKey] ?? "")+ .split(process.platform === "win32" ? ";" : ":")+ .filter((p) => !/nodejs|[\\/]npm|pnpm|\.nvm|fnm|volta/i.test(p))+ .join(process.platform === "win32" ? ";" : ":");+ const child = spawn(layout.bunBin, [join(APP_ROOT, "server", "nodejs", "dist", "index.js")], {cwd: join(APP_ROOT, "server", "nodejs"),- env: { ...process.env, NODEJS_EXECUTOR_PORT: String(port), NODEJS_EXECUTOR_HOST: "127.0.0.1" },+ env: { ...process.env, [pathKey]: strippedPath, NODEJS_EXECUTOR_PORT: String(port), NODEJS_EXECUTOR_HOST: "127.0.0.1" },stdio: ["ignore", "pipe", "pipe"],});let output = "";diff --git a/desktop/tests/unit/env.test.ts b/desktop/tests/unit/env.test.tsindex a53979c2..f74f9109 100644--- a/desktop/tests/unit/env.test.ts+++ b/desktop/tests/unit/env.test.ts@@ -13,7 +13,7 @@ function fakeLayout(withBinaries: boolean) {const userData = join(root, "ud");const layout = resolveLayout({ resources, userData, platform: process.platform });if (withBinaries) {- for (const p of [layout.uvBin, layout.nodeBin, layout.pythonBin]) {+ for (const p of [layout.uvBin, layout.bunBin, layout.pythonBin]) {mkdirSync(join(p, ".."), { recursive: true });writeFileSync(p, "");}@@ -62,18 +62,21 @@ describe("buildBackendEnv", () => {expect(env.UV_NATIVE_TLS).toBeUndefined();expect(env.LOG_FORMAT).toBe("json");expect(env.OPENCOMPANY_UV_BIN).toBe(layout.uvBin);- expect(env.OPENCOMPANY_NODE_BIN).toBe(layout.nodeBin);+ expect(env.OPENCOMPANY_BUN_BIN).toBe(layout.bunBin);+ expect(env.BUN_INSTALL).toBe(layout.bunHomeDir);+ expect(env.BUN_INSTALL_CACHE_DIR).toBe(join(layout.bunHomeDir, "install", "cache"));+ expect(env.OPENCOMPANY_NODE_BIN).toBeUndefined();expect(env.VIRTUAL_ENV).toBeUndefined();expect(env.PYTHONPATH).toBeUndefined();expect(env.ELECTRON_RUN_AS_NODE).toBeUndefined();expect(env.HOME).toBe("/home/u");});- it("prepends bundled node and uv to PATH but never the bare python dir", () => {+ it("prepends bundled bun and uv to PATH but never the bare python dir", () => {const layout = fakeLayout(true);const env = buildBackendEnv({ layout, port: 1, token: "t", parentPid: 1, baseEnv: { PATH: "/usr/bin" } });const parts = (env.PATH as string).split(delimiter);- expect(parts[0]).toBe(layout.nodeBinDir);+ expect(parts[0]).toBe(layout.bunDir);expect(parts[1]).toBe(join(layout.uvBin, ".."));expect(parts).toContain(layout.uvToolBinDir);expect(parts.some((p) => p.includes(join("runtime", "python")))).toBe(false);@@ -83,7 +86,8 @@ describe("buildBackendEnv", () => {const layout = fakeLayout(false);const env = buildBackendEnv({ layout, port: 1, token: "t", parentPid: 1, baseEnv: { PATH: "/usr/bin" } });expect(env.OPENCOMPANY_UV_BIN).toBeUndefined();- expect(env.OPENCOMPANY_NODE_BIN).toBeUndefined();+ expect(env.OPENCOMPANY_BUN_BIN).toBeUndefined();+ expect(env.BUN_INSTALL).toBeUndefined();expect((env.PATH as string).split(delimiter)[0]).toBe(layout.uvToolBinDir);});diff --git a/desktop/tests/unit/paths.test.ts b/desktop/tests/unit/paths.test.tsindex bd7649ca..54f4b8c1 100644--- a/desktop/tests/unit/paths.test.ts+++ b/desktop/tests/unit/paths.test.ts@@ -13,7 +13,8 @@ describe("resolveLayout", () => {expect(l.runtimeDir).toBe(join("/res", "runtime"));expect(l.uvBin).toBe(join("/res", "runtime", "uv", "uv"));expect(l.pythonBin).toBe(join("/res", "runtime", "python", "bin", "python3"));- expect(l.nodeBin).toBe(join("/res", "runtime", "node", "bin", "node"));+ expect(l.bunBin).toBe(join("/res", "runtime", "bun", "bun"));+ expect(l.bunHomeDir).toBe(join("/ud", "bun"));expect(l.venvDir).toBe(join("/ud", "pyenv", "venv"));expect(l.userEnvFile).toBe(join("/ud", "desktop.env"));expect(l.logsDir).toBe(join("/ud", "logs"));@@ -23,8 +24,8 @@ describe("resolveLayout", () => {const l = resolveLayout({ resources: "C:\\res", userData: "C:\\ud", platform: "win32" });expect(l.uvBin.endsWith(join("uv", "uv.exe"))).toBe(true);expect(l.pythonBin.endsWith(join("python", "python.exe"))).toBe(true);- expect(l.nodeBin.endsWith(join("node", "node.exe"))).toBe(true);- expect(l.nodeBinDir).toBe(l.nodeDir);+ expect(l.bunBin.endsWith(join("bun", "bun.exe"))).toBe(true);+ expect(l.bunBin.startsWith(l.bunDir)).toBe(true);});it("honours app-root and runtime overrides independently", () => {