Skip to content

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

Merge remote-tracking branch 'origin/train/nov20-all' into train/nov20-x1

milind-sonif40f5789e322
diff --cc server/index.test.ts
index 29264bfaa3,8b62856c37..88856244e6
--- a/server/index.test.ts
+++ b/server/index.test.ts
@@@ -11169,6 -11171,30 +11186,30 @@@ describe("harness HTTP API", () =>
}
});
+ it.skipIf(process.platform === "win32")("replaces an unreachable VPS SSH alias without requiring the old host", async () => {
+ try {
+ expect((await api("PUT", "/api/config", { vps: { sshAlias: "" } })).status).toBe(200);
+ writeFileSync(fakeSshUnavailable, "");
+ rmSync(fakeSshLog, { force: true });
+
+ const saved = await api("PUT", "/api/config", { vps: { sshAlias: "rockpi4" } });
+ expect(saved.status, JSON.stringify(saved.body)).toBe(200);
+ expect((await api("GET", "/api/config")).body.vps.sshAlias).toBe("rockpi4");
+
+ const replaced = await api("PUT", "/api/config", { vps: { sshAlias: "dietpi" } });
+ expect(replaced.status, JSON.stringify(replaced.body)).toBe(200);
+ expect((await api("GET", "/api/config")).body.vps.sshAlias).toBe("dietpi");
+
+ const cleared = await api("PUT", "/api/config", { vps: { sshAlias: "" } });
- expect(cleared.status).toBe(503);
- expect(cleared.body.error).toContain("Keep the current SSH config alias");
- expect((await api("GET", "/api/config")).body.vps.sshAlias).toBe("dietpi");
++ expect(cleared.status, JSON.stringify(cleared.body)).toBe(200);
++ expect(cleared.body.notice).toContain("Removed. dietpi could not be reached");
++ expect((await api("GET", "/api/config")).body.vps.sshAlias).toBe("");
+ } finally {
+ rmSync(fakeSshUnavailable, { force: true });
+ expect((await api("PUT", "/api/config", { vps: { sshAlias: "" } })).status).toBe(200);
+ }
+ });
+
it("keeps an active turn alive when only the room timeout changes", async () => {
const created = await api("POST", "/api/bots", {});
const botId = created.body.bot.id;
diff --cc server/testing/fake-acp-cli.ts
index e7a15d0fd2,e11de882b9..ea6285a25c
--- a/server/testing/fake-acp-cli.ts
+++ b/server/testing/fake-acp-cli.ts
@@@ -983,11 -991,19 +995,20 @@@ function handle(msg: any)
break;
}
case "session/close":
+ // A failed close leaves the session, its woken steps and its jobs exactly as they were.
+ if (process.env.FAKE_ACP_SESSION_CLOSE === "error") {
+ out({ jsonrpc: "2.0", id: msg.id, error: { code: -32603, message: "close failed" } });
+ break;
+ }
endWokenStep(msg.params?.sessionId);
+ openCopies.delete(String(msg.params?.sessionId));
+ if (process.env.FAKE_ACP_CLOSE_ENDS_JOBS === "1") {
+ const job = backgroundJobs.get(String(msg.params?.sessionId))?.job;
+ if (job) clearTimeout(job);
+ backgroundJobs.delete(String(msg.params?.sessionId));
+ }
if (mode === "background-wake") detachedSessions.add(String(msg.params?.sessionId));
- if (process.env.FAKE_ACP_SESSION_CLOSE === "error") out({ jsonrpc: "2.0", id: msg.id, error: { code: -32603, message: "close failed" } });
- else if (process.env.FAKE_ACP_SESSION_CLOSE_MS) setTimeout(() => result(msg.id, {}), Number(process.env.FAKE_ACP_SESSION_CLOSE_MS));
+ if (process.env.FAKE_ACP_SESSION_CLOSE_MS) setTimeout(() => result(msg.id, {}), Number(process.env.FAKE_ACP_SESSION_CLOSE_MS));
else result(msg.id, {});
break;
case "session/delete": {
diff --cc server/turn-images.ts
index 27ad3416fb,eb4fb3c6ff..bf34260031
--- a/server/turn-images.ts
+++ b/server/turn-images.ts
@@@ -4,9 -4,9 +4,10 @@@ import { dirname, extname, resolve } fr
import { fromMarkdown } from "mdast-util-from-markdown";
import { ATTACHMENTS_DIR, FILE_MAX_BYTES, IMAGE_MAX_BYTES } from "./attachments.ts";
-import type { TurnImageInput, TurnVideoInput } from "./contracts.ts";
+import type { ProviderAdapter, TurnImageInput, TurnVideoInput } from "./contracts.ts";
+import { CHAT_IMAGE_BUDGET, chatMediaUrlBytes } from "./drivers/chat-images.ts";
import { decodeAttachmentAttribute } from "./message-file.ts";
+ import { escapeAttribute } from "../src/lib/composer-attachments.ts";
import { videoFrameImages } from "./turn-video.ts";
export const TURN_IMAGE_MAX_COUNT = 10;