Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
Fix DeepSeek Harness desktop CLI launch on Windows
bore64d9a1c607b6
diff --git a/server/drivers/acp/deepseek.ts b/server/drivers/acp/deepseek.tsindex 094de2f6e9..4c9e663c5a 100644--- a/server/drivers/acp/deepseek.ts+++ b/server/drivers/acp/deepseek.ts@@ -201,7 +201,7 @@ export function fetchDeepSeekCatalog(try {// Security: while the bot box is on, dsh runs in it, as a bot's turn does: it reads ~/.dsh, which a bot can write.const resolved = resolveCli(cli, ["--profile", "acp"], env as NodeJS.ProcessEnv);- child = spawnCli(resolved.command, resolved.args, { stdio: ["pipe", "pipe", "ignore"], env: env as NodeJS.ProcessEnv, box: { allowEnv } });+ child = spawnCli(resolved.command, resolved.args, { stdio: ["pipe", "pipe", "ignore"], env: { ...env, ...resolved.env }, box: { allowEnv } });} catch (error) {return reject(error instanceof Error ? error : new Error(String(error)));}diff --git a/server/env-path.test.ts b/server/env-path.test.tsindex 1c068208e3..792e2132e9 100644--- a/server/env-path.test.ts+++ b/server/env-path.test.ts@@ -441,6 +441,26 @@ winOnly("resolveCli (Windows)", () => {expect(resolveCli("ombfake", [], { PATH: "", PATHEXT: ".CMD" })).toEqual({ command: "ombfake", args: [] });});+ it("preserves the DeepSeek desktop shim's Electron CLI entry point", () => {+ const exe = join(dir, "DeepSeek Harness.exe");+ const archive = join(dir, "resources", "app.asar");+ const shim = join(dir, "dsh.cmd");+ writeFileSync(exe, "MZ");+ mkdirSync(join(dir, "resources"));+ writeFileSync(archive, "");+ writeFileSync(shim, [+ "@echo off",+ 'set "ELECTRON_RUN_AS_NODE=1"',+ '"%~dp0DeepSeek Harness.exe" --expose-internals "%~dp0resources\\app.asar\\dsh\\cli.js" %*',+ "exit /b %errorlevel%",+ ].join("\r\n"));+ expect(resolveCli(shim, ["--profile", "acp"])).toEqual({+ command: exe,+ args: ["--expose-internals", join(archive, "dsh", "cli.js"), "--profile", "acp"],+ env: { ELECTRON_RUN_AS_NODE: "1" },+ });+ });+it("parses an npm .cmd shim down to `node <cli.js>`, never the shim's own node.exe", async () => {shimWith("ombfake.cmd", JS_SHIM, "ombfake.js", "console.log('js target ' + process.argv.slice(2).join(','));\n");onPath();diff --git a/server/env-path.ts b/server/env-path.tsindex e6782957a7..304dc0f5a2 100644--- a/server/env-path.ts+++ b/server/env-path.ts@@ -197,6 +197,7 @@ export function findCliCandidates(name: string, path: string = augmentedPath()):export interface ResolvedSpawn {command: string;args: string[];+ env?: NodeJS.ProcessEnv;}/** A mini tokenizer, never a shell: quotes group segments; no escapes, no substitution, nothing evaluated. */@@ -337,6 +338,18 @@ function parseCmdShim(shim: string, env?: NodeJS.ProcessEnv): ResolvedSpawn | nureturn null;}const dir = dirname(shim);+ if (basename(shim).toLowerCase() === "dsh.cmd" && /^set "ELECTRON_RUN_AS_NODE=1"\r?$/im.test(text)) {+ const desktop = /^"%~dp0([^"\r\n]+\.exe)" --expose-internals "%~dp0((?:[^"\r\n]+\\)?app\.asar)\\([^"\r\n]+\.js)" %\*\r?$/im.exec(text);+ if (desktop) {+ const command = join(dir, desktop[1]);+ const archive = join(dir, desktop[2]);+ const script = join(archive, desktop[3]);+ if (isFile(command) && isFile(archive)) {+ return { command, args: ["--expose-internals", script], env: { ELECTRON_RUN_AS_NODE: "1" } };+ }+ }+ return null;+ }const portableHermes = resolvePortableHermes(shim, text);if (portableHermes) return portableHermes;// npm's own npm.cmd/npx.cmd name their entry as SET "NPX_CLI_JS=%~dp0\…"; a launcher switch to a global npm is not followed.@@ -389,7 +402,7 @@ function resolveWord(cli: string, args: string[], env?: NodeJS.ProcessEnv): Resoconst ext = extname(file).toLowerCase();if (ext === ".cmd" || ext === ".bat") {const direct = parseCmdShim(file, env);- return direct ? { command: direct.command, args: [...direct.args, ...args] } : { command: file, args };+ return direct ? { ...direct, args: [...direct.args, ...args] } : { command: file, args };}if (ext === ".exe" || ext === ".com") return { command: file, args };const viaNode = parseNodeShebang(file, env);diff --git a/server/procs.ts b/server/procs.tsindex 375b53abd6..065602ee76 100644--- a/server/procs.ts+++ b/server/procs.ts@@ -224,7 +224,10 @@ export function spawnCli(const resolved = resolveCli(cli, args);assertSafeCliArgv(resolved);const homed = owner === "bot" || opts.engineHome ? engineHomes.forSpawn(opts.env ?? process.env) : null;- const options: CliSpawnOptions = homed ? { ...opts, env: homed.env } : opts;+ const env = homed?.env ?? opts.env;+ const options: CliSpawnOptions = resolved.env+ ? { ...opts, env: { ...(env ?? process.env), ...resolved.env } }+ : homed ? { ...opts, env } : opts;const boxed = boxedSpawn(resolved, options, owner, homed);const { box: _box, engineHome: _engineHome, botWork, ...spawnOpts } = boxed ? options : outsideBoxOptions(resolved.command, options);// The box's extra descriptors (its seccomp filter) follow stdio; only a plain three-entry stdio can take them.@@ -322,7 +325,8 @@ export function execCli(let escalate: NodeJS.Timeout | undefined;let deadline: NodeJS.Timeout | undefined;let timedOut = false;- const child = execFile(resolved.command, resolved.args, { ...opts, windowsHide: true, encoding: "utf8" }, (err, stdout, stderr) => {+ const env = resolved.env ? { ...(opts.env ?? process.env), ...resolved.env } : opts.env;+ const child = execFile(resolved.command, resolved.args, { ...opts, env, windowsHide: true, encoding: "utf8" }, (err, stdout, stderr) => {clearTimeout(escalate);clearTimeout(deadline);cb(err ?? (timedOut ? cutOffError(cli, opts.timeout) : null), stdout, stderr);