Render Anything Engine: tell your AI what to make. Videos, motion graphics, 3D and games as React and TypeScript, rendered on your own GPU. Rust + Bevy, macOS, Linux and Windows.
TypeScript 3dagent-skillsai-agentsai-videobevyclaude-codegame-enginegpulinuxmacosmotion-designmotion-graphicsreactrusttypescriptvideo-editingvideo-renderingwgpuwindows
raea cloud's box on Windows: the shell's own cat, ls and grep are on its PATH
shinyobjectz3b24037ceb43
diff --git a/sdk/cloud/server/main.ts b/sdk/cloud/server/main.tsindex 06ae1cd3..48dbbe54 100644--- a/sdk/cloud/server/main.ts+++ b/sdk/cloud/server/main.ts@@ -117,9 +117,9 @@ async function shell(req: IncomingMessage, res: ServerResponse) {mkdirSync(dir, { recursive: true })res.writeHead(200, { "content-type": "application/x-ndjson" })// the shell on any OS: bash and a process group here, RAEA_CLOUD_BASH and taskkill on Windows (shell-os.ts)- const { bash, groupOpts, stopTree } = await import("./shell-os.ts")+ const { bash, groupOpts, shellEnv, stopTree } = await import("./shell-os.ts")// in a process group of its own, so a timeout or a caller leaving stops what the command started too- const child = spawn(bash(), ["-c", command], { cwd: dir, env: childEnv(), stdio: ["ignore", "pipe", "pipe"], ...groupOpts() })+ const child = spawn(bash(), ["-c", command], { cwd: dir, env: shellEnv(childEnv()), stdio: ["ignore", "pipe", "pipe"], ...groupOpts() })const line = (v: unknown) => res.write(JSON.stringify(v) + "\n")const stop = () => stopTree(child)let timedOut = falsediff --git a/sdk/cloud/server/shell-os.ts b/sdk/cloud/server/shell-os.tsindex a491c729..6358b8f9 100644--- a/sdk/cloud/server/shell-os.ts+++ b/sdk/cloud/server/shell-os.ts@@ -3,6 +3,7 @@// where there's no /bin/sh: RAEA_CLOUD_BASH names a bash (the one beside Git for Windows, or raea's own Git's), and a// run is stopped with its children by taskkill, as Windows has no process groups to signal.import { spawn, type ChildProcess } from "node:child_process"+import path from "node:path"const win = process.platform === "win32"@@ -12,6 +13,15 @@ export const bash = () => process.env.RAEA_CLOUD_BASH || "bash"/** the POSIX shell an agent's own command line runs in (RAEA_AGENT_CMD): /bin/sh, or that bash on Windows */export const sh = () => (win ? bash() : "/bin/sh")+/** the environment that shell runs with: on Windows RAEA_CLOUD_BASH's own folder first on PATH, where its cat, ls and+ * grep are (raea's own Git has a bare sh.exe there; Git for Windows' bash adds its own). PATH by whatever case Windows+ * gave its name in. */+export function shellEnv(env: NodeJS.ProcessEnv, on = win, shell = bash()): NodeJS.ProcessEnv {+ if (!on || !/[\\/]/.test(shell)) return env+ const key = Object.keys(env).find((k) => k.toUpperCase() === "PATH") ?? "PATH"+ return { ...env, [key]: `${path.win32.dirname(shell)};${env[key] ?? ""}` }+}+/** spawn options for a run that's stopped with everything it started: its own process group (not on Windows, where a* detached child gets a console window of its own) */export const groupOpts = () => (win ? { windowsHide: true } : { detached: true })diff --git a/sdk/cloud/test/units.ts b/sdk/cloud/test/units.tsindex d80ac6f0..bd249f08 100644--- a/sdk/cloud/test/units.ts+++ b/sdk/cloud/test/units.ts@@ -8,6 +8,7 @@ import os from "node:os"import path from "node:path"import { parseSummary, pick } from "../server/gpu.ts"import { plan, projectRoot } from "../server/offload.ts"+import { shellEnv } from "../server/shell-os.ts"const L4 = `Devices:========@@ -69,4 +70,9 @@ try {} finally {rmSync(root, { recursive: true, force: true })}++// the box's shell on Windows: its own folder first on PATH, whatever case Windows gave the name; untouched elsewhere+assert.deepEqual(shellEnv({ Path: "C:\\w" }, true, "C:\\g\\usr\\bin\\sh.exe"), { Path: "C:\\g\\usr\\bin;C:\\w" })+assert.deepEqual(shellEnv({ PATH: "C:\\w" }, true, "bash"), { PATH: "C:\\w" })+assert.deepEqual(shellEnv({ PATH: "/usr/bin" }, false, "/bin/bash"), { PATH: "/usr/bin" })console.log("units: ok")