Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
import { createElement } from "react";
import { renderToStaticMarkup } from "react-dom/server";
import { describe, expect, it } from "vitest";
import type { InstanceInfo } from "@/state/store";
import { EngineCard, EngineSections, engineReady } from "./EngineLibrary";
import { CursorMark, HermesMark, InstanceProviderMark } from "./ProviderIcons";
const instance = (overrides: Partial<InstanceInfo> = {}): InstanceInfo => ({
instanceId: "claude", driverKind: "claudeAgent", displayName: "Claude",
snapshot: { state: "available", authenticated: true },
models: { default: "test", options: [] }, ...overrides,
});
describe("engine library", () => {
it("keeps monochrome provider logos legible in light and dark skins", () => {
for (const Mark of [CursorMark, HermesMark]) {
const html = renderToStaticMarkup(createElement(Mark));
expect(html).not.toContain("#F5F5F5");
expect(html).toContain("ink");
}
});
it("draws Cursor's cube mark for the Cursor engine, not a pointer arrow", () => {
const html = renderToStaticMarkup(createElement(InstanceProviderMark, { instance: instance({ driverKind: "cursorAgent" }) }));
expect(html).toContain('viewBox="0 0 466.73 532.09"');
expect(html).toContain("fill-[var(--color-ink)]");
expect(html).not.toContain("M4 2.2");
});
it("uses an instance icon without changing the driver's default mark", () => {
const preset = renderToStaticMarkup(createElement(InstanceProviderMark, { instance: instance({ icon: { kind: "preset", preset: "azure" } }) }));
const custom = renderToStaticMarkup(createElement(InstanceProviderMark, { instance: instance({ icon: { kind: "custom", dataUrl: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNk+A8AAQUBAScY42YAAAAASUVORK5CYII=" } }) }));
const fallback = renderToStaticMarkup(createElement(InstanceProviderMark, { instance: instance() }));
expect(preset).toContain("#0089D6");
expect(custom).toContain("data:image/png;base64,iVBORw0KGgo");
expect(fallback).toContain("viewBox=\"0 0 256 257\"");
});
it("preserves readiness semantics without mistaking installation for sign-in", () => {
expect(engineReady(instance())).toBe(true);
expect(engineReady(instance({ snapshot: { state: "available" } }))).toBe(true);
expect(engineReady(instance({ snapshot: { state: "available", authenticated: false } }))).toBe(false);
expect(engineReady(instance({ access: "custom", snapshot: { state: "available", authenticated: false } }))).toBe(true);
expect(engineReady(instance({ access: "custom", snapshot: { state: "unavailable", authenticated: true } }))).toBe(false);
});
it("keeps an installed Cline engine in setup until its provider is configured", () => {
const cline = instance({ driverKind: "clineAgent", displayName: "Cline", snapshot: { state: "available", authenticated: false } });
expect(engineReady(cline)).toBe(false);
expect(engineReady({ ...cline, snapshot: { state: "available" } })).toBe(false);
expect(renderToStaticMarkup(createElement(EngineCard, { instance: cline, children: null }))).toContain("Sign-in required");
expect(engineReady({ ...cline, snapshot: { state: "available", authenticated: true } })).toBe(true);
});
it("uses an accessible disclosure and keeps controls mounted while collapsed", () => {
const html = renderToStaticMarkup(createElement(EngineCard, { instance: instance(), children: createElement("input", { "aria-label": "Path draft" }) }));
expect(html).toContain('<details data-engine-card="claude"');
expect(html).toContain("<summary");
expect(html).toContain('aria-label="Path draft"');
expect(html).toContain("focus-visible:ring-2");
expect(html).not.toContain('open=""');
});
it("never displays a stale signed-out account identity", () => {
const row = instance({ snapshot: { state: "available", authenticated: false, account: { email: "[email protected]" } } });
const render = (value: InstanceInfo) => renderToStaticMarkup(createElement(EngineCard, { instance: value, children: null }));
expect(render(row)).not.toContain("[email protected]");
expect(render(row)).toContain("Sign-in required");
expect(render({ ...row, snapshot: { ...row.snapshot, authenticated: true } })).toContain("[email protected]");
});
it("does not present executable names as versions", () => {
const render = (version: string) => renderToStaticMarkup(createElement(EngineCard, { instance: instance({ snapshot: { state: "available", version } }), children: null }));
expect(render("claude")).not.toContain("vclaude");
expect(render("Claude Code 2.1.8")).toContain("v2.1.8");
});
it("keeps cards under the same keyed parent when a refreshed status regroups them", () => {
const other = instance({ instanceId: "work" });
const renderEngine = (value: InstanceInfo) => createElement(EngineCard, { instance: value, children: null });
const ready = EngineSections({ instances: [instance(), other], renderEngine });
const signedOut = EngineSections({ instances: [instance({ snapshot: { state: "available", authenticated: false } }), other], renderEngine });
for (const tree of [ready, signedOut]) {
expect(tree.type).toBe("div");
const card = tree.props.children[0].find((node: { key: string }) => node.key === "claude");
expect(card.type).toBe("div");
expect(card.props.children.type).toBe(EngineCard);
const html = renderToStaticMarkup(tree);
expect(html.match(/data-engine-card=/g)).toHaveLength(2);
}
});
});