Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

fix(deepseek): say when Node.js is too old for DeepSeek Harness

AdityaUmale0bb823699381
diff --git a/server/chat-notices.ts b/server/chat-notices.ts
index 14cce420b9..8e1e20ca38 100644
--- a/server/chat-notices.ts
+++ b/server/chat-notices.ts
@@ -89,6 +89,7 @@ export const CHAT_NOTICE = {
"chat.notice.phone.write.PHONE_SEND_WHATSAPP": "Send whatsapp on {phone}",
"chat.notice.acpEmpty": "{provider} finished without replying.",
"chat.notice.acpNoReason": "{provider} stopped without saying why.",
+ "chat.notice.acpNodeTooOld": "{provider} needs Node.js {needed} or newer, but this computer has Node.js {found}. Update Node.js from nodejs.org, then send your message again.",
"chat.notice.acpMcpAppsFailed": "Connected apps couldn't be set up, so {provider} couldn't start this reply. Try again, or switch this bot to another AI.",
"chat.notice.acpMcpServerFailed": "The \"{server}\" MCP server couldn't be set up, so {provider} couldn't start this reply. Try again, or switch this bot to another AI.",
"chat.notice.stop.refusal": "{provider} refused to go on with this request (stop reason: {reason}). Try again, reword the request, or switch this bot to another AI.",
diff --git a/server/drivers/acp/acp.test.ts b/server/drivers/acp/acp.test.ts
index 1fc38ccb72..5316501d15 100644
--- a/server/drivers/acp/acp.test.ts
+++ b/server/drivers/acp/acp.test.ts
@@ -62,6 +62,10 @@ const EnvPolicyDriver = createAcpDriver({
},
});
+/** A CLI that needs a newer Node.js than any there is, and one that runs on every Node.js. */
+const NodeTooOldDriver = createAcpDriver({ ...SELECT_MODEL_SUPPORT, driverKind: "nodeTooOldTest", selectModel: undefined, minNodeVersion: "999.0.0" });
+const NodeOkDriver = createAcpDriver({ ...SELECT_MODEL_SUPPORT, driverKind: "nodeOkTest", selectModel: undefined, minNodeVersion: "1.0.0" });
+
const AsyncAuthDriver = createAcpDriver({
...SELECT_MODEL_SUPPORT,
driverKind: "asyncAuthTest",
@@ -2106,6 +2110,25 @@ describe("ACP turns (fake CLI)", () => {
expect(recorder.events.some((e) => e.type === "runtime.error")).toBe(true);
});
+ it("an exit before result on a Node.js older than the engine needs names both versions", async () => {
+ await create(NodeTooOldDriver, "exit-early");
+ await instance.adapter.sendTurn({ threadId: "t-old-node", text: "go" });
+ const failed = await recorder.until((e) => e.type === "runtime.error") as { message: string; text?: unknown };
+ expect(failed.text).toEqual({ key: "chat.notice.acpNodeTooOld",
+ params: { provider: SELECT_MODEL_SUPPORT.displayName, needed: "999.0.0", found: expect.stringMatching(/^\d+\.\d+\.\d+$/) } });
+ expect(failed.message).toMatch(/ needs Node\.js 999\.0\.0 or newer, but this computer has Node\.js \d+\.\d+\.\d+\. Update Node\.js/);
+ expect(await recorder.until((e) => e.type === "turn.completed")).toMatchObject({ ok: false });
+ });
+
+ it("an exit before result on a new enough Node.js keeps the exit words", async () => {
+ await create(NodeOkDriver, "exit-early");
+ await instance.adapter.sendTurn({ threadId: "t-ok-node", text: "go" });
+ const failed = await recorder.until((e) => e.type === "runtime.error") as { message: string; text?: unknown };
+ expect(failed.message).toMatch(/ exited 3 before the prompt result/);
+ expect(failed.text).toBeUndefined();
+ expect(await recorder.until((e) => e.type === "turn.completed")).toMatchObject({ ok: false });
+ });
+
it("an engine that aborts says so in plain words, with its last output masked", async () => {
await create(GrokAgentDriver, "abort-in-prompt");
await instance.adapter.sendTurn({ threadId: "t-abort", text: "go" });
diff --git a/server/drivers/acp/core.ts b/server/drivers/acp/core.ts
index ba995722ab..7c8df6d836 100644
--- a/server/drivers/acp/core.ts
+++ b/server/drivers/acp/core.ts
@@ -65,7 +65,7 @@ import { openQuestionRequest, questionRequestFor, type AcpQuestionRequest } from
import { commandSummary, toolDetailPreview } from "../../tool-summary.ts";
import { acpToolEndEvents } from "./tool-items.ts";
import { AcpHost } from "./host.ts"; import { SignInRequests, type AcpDriverHooks } from "./driver-hooks.ts";
-import { exitDetail } from "./exit-report.ts";
+import { exitBeforeResult } from "./exit-report.ts"; import { readNodeVersion } from "./node-version.ts";
import { endTurn, trackRunningTool, type AcpAskFinish, type AcpSession, type AcpTurn } from "./turn-state.ts";
import { recoveryPromptFor } from "../../resume-recovery.ts";
import { noticeFailure } from "../../chat-notices.ts";
@@ -101,6 +101,7 @@ export interface AcpSupport extends AcpDriverHooks {
toolScopeCacheKey?(context: { config: AcpConfig; env: Record<string, string | undefined>; cwd: string }): string;
driverKind: string;
displayName: string; /** What this CLI's own `--version` looks like: any other answer is another program behind the CLI path. */ cliVersion?: RegExp;
+ /** The oldest Node.js the CLI runs on: an exit before its reply on an older one names both versions. */ minNodeVersion?: string;
/** Omit for subscription CLIs. Custom-only CLIs have no first-party cloud catalog. */
access?: "subscription" | "custom";
models: ModelCatalog;
@@ -621,7 +622,7 @@ export function createAcpDriver(support: AcpSupport): ProviderDriver<AcpConfig>
const commandCwd = permissionLaunchCwd(cwd);
const host = hostFor(threadId, launch, argv, env, cwd, hostKey);
const acp = host.link(threadId, cwd);
- const send = (obj: unknown) => acp.send(obj);
+ const send = (obj: unknown) => acp.send(obj); const nodeVersion = support.minNodeVersion ? readNodeVersion(env) : undefined;
const handleClientFileRequest = async (msg: any, current: AcpTurn): Promise<void> => {
const fail = (error: unknown) => send({
@@ -931,16 +932,15 @@ export function createAcpDriver(support: AcpSupport): ProviderDriver<AcpConfig>
emit({ ...base(threadId, current.turnId), type: "runtime.error", ...describeSpawnFailure(e, launch.command, cwd) });
settle(threadId, session, false, "spawn_error");
},
- exit: (code, signal) => {
+ exit: function exit(code, signal, found?: string | null) {
session.dead = true;
+ // An engine with a Node.js minimum waits for the version read at launch, to say when that is too old.
+ if (nodeVersion && found === undefined) return void nodeVersion.then((version) => exit(code, signal, version ?? null));
const current = session.current;
if (current?.state.cancelling) return;
if (current) {
- if (!current.state.stopped) emit({
- ...base(threadId, current.turnId),
- type: "runtime.error",
- message: `${support.displayName} exited ${code ?? signal ?? "unexpectedly"} before the prompt result${exitDetail(code, signal, session.stderr)}`,
- });
+ if (!current.state.stopped) emit({ ...base(threadId, current.turnId), type: "runtime.error",
+ ...exitBeforeResult(support.displayName, code, signal, session.stderr, support.minNodeVersion, found) });
settle(threadId, session, current.state.stopped, current.state.stopped ? "cancelled" : "exit_before_result");
} else if (sessions.get(threadId) === session) {
// The identity check keeps an old child's exit from unlinking its replacement.
diff --git a/server/drivers/acp/deepseek.ts b/server/drivers/acp/deepseek.ts
index 4292d17bfe..b315ba7e55 100644
--- a/server/drivers/acp/deepseek.ts
+++ b/server/drivers/acp/deepseek.ts
@@ -306,6 +306,8 @@ export function fetchDeepSeekCatalog(
export const deepseekSupport: AcpSupport = {
driverKind: "deepseekAgent",
displayName: "DeepSeek Harness",
+ // @deepseek-ai/dsh declares engines.node ">=24.9.0"; on older Node it quits before answering.
+ minNodeVersion: "24.9.0",
models: DEEPSEEK_MODELS,
defaultCli: "dsh",
nativeSource: "deepseek.acp",
diff --git a/server/drivers/acp/exit-report.ts b/server/drivers/acp/exit-report.ts
index ddb6ae4824..91ab04141f 100644
--- a/server/drivers/acp/exit-report.ts
+++ b/server/drivers/acp/exit-report.ts
@@ -2,6 +2,9 @@
// The one description of an ACP engine's exit: a turn's (host.ts, core.ts) and Antigravity's setup (antigravity-acp.ts).
// Lines are masked as they arrive and only the last few are kept, so no raw sign-in code or key is held.
import { mask, redactSecretsInText } from "../../../shared/redact.ts";
+import { type ServerText } from "../../../shared/server-text.ts";
+import { noticeFailure } from "../../chat-notices.ts";
+import { nodeOlderThan } from "./node-version.ts";
const SIGNAL_WORDS: Partial<Record<NodeJS.Signals, string>> = {
SIGABRT: "it stopped itself (abort)",
@@ -129,3 +132,11 @@ export function exitDetail(code: number | null, signal: NodeJS.Signals | null, t
if (words) return `: ${words}`;
return tail ? `: ${tail}` : "";
}
+
+/** Why an engine stopped before its reply: on a Node.js (`found`) older than it needs (`needed`), that, in the
+ * person's language; otherwise its exit in words, with its last output. */
+export function exitBeforeResult(provider: string, code: number | null, signal: NodeJS.Signals | null, tail: string,
+ needed?: string, found?: string | null): { message: string; text?: ServerText } {
+ if (needed && found && nodeOlderThan(found, needed)) return noticeFailure("chat.notice.acpNodeTooOld", { provider, needed, found });
+ return { message: `${provider} exited ${code ?? signal ?? "unexpectedly"} before the prompt result${exitDetail(code, signal, tail)}` };
+}
diff --git a/server/drivers/acp/node-version.test.ts b/server/drivers/acp/node-version.test.ts
new file mode 100644
index 0000000000..7391417eb3
--- /dev/null
+++ b/server/drivers/acp/node-version.test.ts
@@ -0,0 +1,19 @@
+import { describe, expect, it } from "vitest";
+
+import { nodeOlderThan, readNodeVersion } from "./node-version.ts";
+
+describe("nodeOlderThan", () => {
+ it("compares major, then minor, then patch", () => {
+ expect(nodeOlderThan("20.19.4", "24.9.0")).toBe(true);
+ expect(nodeOlderThan("24.8.9", "24.9.0")).toBe(true);
+ expect(nodeOlderThan("24.9.0", "24.9.0")).toBe(false);
+ expect(nodeOlderThan("24.10.0", "24.9.0")).toBe(false);
+ expect(nodeOlderThan("25.0.0", "24.9.0")).toBe(false);
+ });
+});
+
+describe("readNodeVersion", () => {
+ it("reads the version of the node on the PATH", async () => {
+ expect(await readNodeVersion(process.env)).toMatch(/^\d+\.\d+\.\d+$/);
+ });
+});
diff --git a/server/drivers/acp/node-version.ts b/server/drivers/acp/node-version.ts
new file mode 100644
index 0000000000..a21c70c63a
--- /dev/null
+++ b/server/drivers/acp/node-version.ts
@@ -0,0 +1,20 @@
+import { execCli } from "../../procs.ts";
+
+/** The Node.js version the `node` on `env`'s PATH reports ("20.19.4"); undefined when it can't be read. */
+export function readNodeVersion(env: Record<string, string | undefined>): Promise<string | undefined> {
+ return new Promise((resolve) => {
+ execCli("node", ["--version"], { env: env as NodeJS.ProcessEnv, timeout: 5_000 }, (error, stdout) => {
+ resolve(error ? undefined : /^v?(\d+\.\d+\.\d+)/.exec(stdout.trim())?.[1]);
+ });
+ });
+}
+
+/** Whether `version` comes before `minimum` (both "major.minor.patch"). */
+export function nodeOlderThan(version: string, minimum: string): boolean {
+ const have = version.split(".").map(Number);
+ const need = minimum.split(".").map(Number);
+ for (let part = 0; part < 3; part++) {
+ if ((have[part] ?? 0) !== (need[part] ?? 0)) return (have[part] ?? 0) < (need[part] ?? 0);
+ }
+ return false;
+}
diff --git a/src/locales/de.json b/src/locales/de.json
index 083d1959bf..b3589339cb 100644
--- a/src/locales/de.json
+++ b/src/locales/de.json
@@ -2789,6 +2789,7 @@
"homeLine.local": "{name} startet frisch: ein eigener Bereich auf diesem Computer, mit eigenen Bots, Chats und Dateien.",
"native.places.profileFailed": "Der eigene Bereich dieses Computers wurde nicht geöffnet. Versuch es gleich noch einmal.",
"chat.notice.devinAccountRefused": "Devin hat diese Anfrage für das angemeldete Konto abgelehnt. Prüfe den Devin-Tarif und das Guthaben und versuche es dann erneut.",
+ "chat.notice.acpNodeTooOld": "{provider} braucht Node.js {needed} oder neuer, aber auf diesem Computer ist Node.js {found}. Aktualisiere Node.js von nodejs.org und sende deine Nachricht dann erneut.",
"rail.settingUp": "{name}: wird eingerichtet",
"rail.waiting": "{name}: wartet auf Zahlung",
"rail.attention": "{name}: braucht dich",
diff --git a/src/locales/en.json b/src/locales/en.json
index 5a95965375..a503ac7bc4 100644
--- a/src/locales/en.json
+++ b/src/locales/en.json
@@ -9780,6 +9780,7 @@
"serverError.engineCheck.timeout": "{name} didn't answer within {seconds} seconds.",
"chat.notice.acpEmpty": "{provider} finished without replying.",
"chat.notice.acpNoReason": "{provider} stopped without saying why.",
+ "chat.notice.acpNodeTooOld": "{provider} needs Node.js {needed} or newer, but this computer has Node.js {found}. Update Node.js from nodejs.org, then send your message again.",
"chat.notice.acpMcpAppsFailed": "Connected apps couldn't be set up, so {provider} couldn't start this reply. Try again, or switch this bot to another AI.",
"chat.notice.acpMcpServerFailed": "The \"{server}\" MCP server couldn't be set up, so {provider} couldn't start this reply. Try again, or switch this bot to another AI.",
"chat.notice.stop.refusal": "{provider} refused to go on with this request (stop reason: {reason}). Try again, reword the request, or switch this bot to another AI.",
diff --git a/src/locales/pt-br.json b/src/locales/pt-br.json
index 72b8fc96b8..50e82041f7 100644
--- a/src/locales/pt-br.json
+++ b/src/locales/pt-br.json
@@ -9695,6 +9695,7 @@
"serverError.engineCheck.timeout": "{name} não respondeu em {seconds} segundos.",
"chat.notice.acpEmpty": "{provider} terminou sem responder.",
"chat.notice.acpNoReason": "{provider} parou sem informar o motivo.",
+ "chat.notice.acpNodeTooOld": "{provider} precisa do Node.js {needed} ou mais recente, mas este computador tem o Node.js {found}. Atualize o Node.js em nodejs.org e envie sua mensagem de novo.",
"chat.notice.acpMcpAppsFailed": "Não foi possível configurar os apps conectados, então {provider} não conseguiu começar esta resposta. Tente de novo ou troque a IA deste bot.",
"chat.notice.acpMcpServerFailed": "Não foi possível configurar o servidor MCP \"{server}\", então {provider} não conseguiu começar esta resposta. Tente de novo ou troque a IA deste bot.",
"chat.notice.stop.refusal": "{provider} se recusou a continuar com este pedido (motivo da parada: {reason}). Tente novamente, reformule o pedido ou mude este bot para outra IA.",