Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
Rapid-MLX discovery: ask port 8000 only on a Mac
milind-sonibc215cdec1ef
diff --git a/server/drivers/local-inject.test.ts b/server/drivers/local-inject.test.tsindex c1fc9cc7aa..ede8135f35 100644--- a/server/drivers/local-inject.test.ts+++ b/server/drivers/local-inject.test.ts@@ -81,6 +81,7 @@ describe("Rapid-MLX discovery", () => {],}));},+ "darwin",);expect(rapidRequests).toEqual(["http://127.0.0.1:8000/v1/models"]);expect(catalog.options).toEqual([@@ -109,7 +110,7 @@ describe("Rapid-MLX discovery", () => {rapidRequests.push([String(url), new Headers(init?.headers).get("Authorization")]);if (String(url).endsWith("/health")) return Response.json(health);return new Response("unauthorized", { status: 401 });- });+ }, "darwin");expect(models).toEqual([]);expect(rapidRequests).toEqual([["http://127.0.0.1:8000/v1/models", null],@@ -126,7 +127,7 @@ describe("Rapid-MLX discovery", () => {return new Response(null, { status: 302, headers: { Location: "http://127.0.0.1:9999/health" } });}return new Response("unauthorized", { status: 401 });- });+ }, "darwin");expect(models).toEqual([]);expect(rapidRequests).toEqual([["http://127.0.0.1:8000/v1/models", null, "manual"],@@ -145,7 +146,7 @@ describe("Rapid-MLX discovery", () => {}if (!authorization) return new Response("unauthorized", { status: 401 });return Response.json({ data: [{ id: "nomic-ai/chat", owned_by: "rapid-mlx", capabilities: ["text"] }] });- });+ }, "darwin");expect(rapidRequests).toEqual([["http://127.0.0.1:8000/v1/models", null],["http://127.0.0.1:8000/health", null],@@ -161,9 +162,19 @@ describe("Rapid-MLX discovery", () => {default_model: "other-chat",data: [{ id: "other-chat", owned_by: ownedBy, loaded: true }],}));- });+ }, "darwin");expect(models).toEqual([]);});++ it.each(["linux", "win32"] as const)("never asks port 8000 on %s", async (platform) => {+ const asked: string[] = [];+ await probeLocalInjects({ RAPID_MLX_API_KEY: "rapid-secret" }, async (url) => {+ asked.push(String(url));+ return new Response("nope", { status: 500 });+ }, platform);+ expect(asked.filter((url) => url.startsWith("http://127.0.0.1:8000/"))).toEqual([]);+ expect(asked.length).toBeGreaterThan(0);+ });});describe("contextWindowsFromPs", () => {diff --git a/server/drivers/local-inject.ts b/server/drivers/local-inject.tsindex ab45eccb3f..aeef7ff0a4 100644--- a/server/drivers/local-inject.ts+++ b/server/drivers/local-inject.ts@@ -384,9 +384,12 @@ export function lmStudioV1Catalog(export async function probeLocalInjects(env: Record<string, string | undefined> = process.env,fetchImpl: typeof fetch = fetch,+ platform: NodeJS.Platform = process.platform,): Promise<InjectedModel[]> {const seenHosts = new Set<string>();const hosts = LOCAL_HOSTS.filter((host) => {+ // Rapid-MLX runs only on a Mac, so nothing else asks port 8000 (a common port for other local servers).+ if (host.id === "rapid_mlx" && platform !== "darwin") return false;const key = host.baseUrl.replace(/\/$/, "");if (seenHosts.has(key)) return false;seenHosts.add(key);@@ -436,13 +439,14 @@ export async function mergeLocalInject(catalog: ModelCatalog,env: Record<string, string | undefined> = process.env,fetchImpl: typeof fetch = fetch,+ platform: NodeJS.Platform = process.platform,): Promise<ModelCatalog> {const vitest = env.VITEST ?? process.env.VITEST;const probe = env.OPENMAUSBOT_PROBE_LOCAL_INJECT ?? process.env.OPENMAUSBOT_PROBE_LOCAL_INJECT;if (vitest === "true" && probe !== "1") return catalog;// An engine's own config lists whatever it was last told to run, which may be a name that carries a window.catalog = { ...catalog, options: catalog.options.filter((option) => !isContextName(option.id)) };- const extras = await probeLocalInjects(env, fetchImpl);+ const extras = await probeLocalInjects(env, fetchImpl, platform);if (!extras.length) return catalog;const liveApiIds = new Set(extras.map((extra) => extra.model));const options = catalog.options