Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
Usage menu: Antigravity's windows read as Gemini's
laijsg15cc8586a9fce
diff --git a/packages/phone-protocol/src/limit-reset.ts b/packages/phone-protocol/src/limit-reset.tsindex a0b0461980..aec23c9de6 100644--- a/packages/phone-protocol/src/limit-reset.ts+++ b/packages/phone-protocol/src/limit-reset.ts@@ -50,6 +50,9 @@ export interface EngineLimit {blocked: boolean;/** Blocked only by a refusal's hold, which "Try again now" can end; absent when a window at its limit blocks it. */held?: boolean;+ /** Whose allowance the windows measure when it is not the whole engine's: "Gemini" on Antigravity, whose other models+ * draw on allowances of their own. Such windows never hold the engine. Absent when the windows are the engine's. */+ meter?: string;/** Every window the engine reported, in the engine's order. A server that predates it sends only the deciding window above. */windows?: LimitWindowUsage[];}diff --git a/server/limit-resets.test.ts b/server/limit-resets.test.tsindex 0557b16c32..e89ae2e957 100644--- a/server/limit-resets.test.ts+++ b/server/limit-resets.test.ts@@ -263,7 +263,7 @@ describe("an Antigravity account's usage", () => {await instance.refresh(true);expect(load.mock.calls.map(([asked]) => asked.map((account) => account.id))).toEqual([["claude", "antigravity"]]);expect(instance.limit("antigravity")).toEqual({- engine: "antigravity", name: "Antigravity", driver: "antigravity", window: "5-hour", usedPercent: 50, resetsAt: NOW + 2 * HOUR, blocked: false,+ engine: "antigravity", name: "Antigravity", driver: "antigravity", meter: "Gemini", window: "5-hour", usedPercent: 50, resetsAt: NOW + 2 * HOUR, blocked: false,windows: [{ window: "5-hour", usedPercent: 50, resetsAt: NOW + 2 * HOUR }, { window: "weekly", usedPercent: 25, resetsAt: NOW + 60 * HOUR }],});});diff --git a/server/limit-resets.ts b/server/limit-resets.tsindex ef9d1cdd3c..0507225600 100644--- a/server/limit-resets.ts+++ b/server/limit-resets.ts@@ -19,9 +19,11 @@ type Driver = EngineLimit["driver"];/** The drivers whose plan usage gives a limit to show. */const REPORTED_DRIVERS: ReadonlySet<string> = new Set(["claude", "codex", "grok", "opencode", "antigravity"]);-/** The drivers whose usage is the whole engine's, so a window at its limit holds the engine and its turns go to another- * AI. Antigravity's leading windows are Gemini's alone, and its other models draw on allowances of their own. */-const ENGINE_WIDE_DRIVERS: ReadonlySet<string> = new Set(["claude", "codex", "grok", "opencode"]);+/** Whose allowance a driver's windows measure when it is not the whole engine's (EngineLimit.meter). Antigravity's+ * leading windows are Gemini's alone. Every other driver's windows are the engine's: at its limit they hold the engine,+ * and its turns go to another AI. */+const PARTIAL_METERS: Readonly<Record<string, string>> = { antigravity: "Gemini" };+const engineWide = (driver: string) => !Object.hasOwn(PARTIAL_METERS, driver);function windowLine(name: LimitWindowName, window: PlanWindow): { window: LimitWindowName; used: number; resetsAt: number | null } | null {if (!window.available || window.usedPercent === null) return null;@@ -34,14 +36,14 @@ function windowLine(name: LimitWindowName, window: PlanWindow): { window: LimitWexport function engineLimitFromUsage(row: PlanProviderRow): EngineLimit | null {if (!row.ok || !REPORTED_DRIVERS.has(row.driver)) return null;const windows = [windowLine("5-hour", row.fiveHour), windowLine("weekly", row.weekly)].filter((line) => line !== null);- const base = { engine: row.id, name: row.name, driver: row.driver as Driver,+ const base = { engine: row.id, name: row.name, driver: row.driver as Driver, ...(engineWide(row.driver) ? {} : { meter: PARTIAL_METERS[row.driver] }),windows: windows.map(({ window, used, resetsAt }) => ({ window, usedPercent: used, resetsAt })) };if (!windows.length) return { ...base, window: null, usedPercent: null, resetsAt: null, blocked: false };const full = windows.filter((line) => line.used >= 100);if (full.length) {const latest = full.reduce((left, right) => (right.resetsAt ?? 0) > (left.resetsAt ?? 0) ? right : left);// Claude goes on past a full window on its paid extra usage while that has room; its own refusal still holds it.- return { ...base, window: latest.window, usedPercent: 100, resetsAt: full.some((line) => line.resetsAt === null) ? null : latest.resetsAt, blocked: ENGINE_WIDE_DRIVERS.has(row.driver) && !claudeHasExtraUsageRoom(row) };+ return { ...base, window: latest.window, usedPercent: 100, resetsAt: full.some((line) => line.resetsAt === null) ? null : latest.resetsAt, blocked: engineWide(row.driver) && !claudeHasExtraUsageRoom(row) };}const fullest = [...windows].sort((left, right) => right.used - left.used || (left.resetsAt ?? Infinity) - (right.resetsAt ?? Infinity))[0]!;return { ...base, window: fullest.window, usedPercent: fullest.used, resetsAt: fullest.resetsAt, blocked: false };@@ -71,7 +73,7 @@ export function engineLabel(engine: string, instance?: { displayName?: string; d/** A line for the turn's text when its engine is nearly out of usage, so the bot can set up its own continuation. */export function nearLimitNote(limit: EngineLimit | undefined, name: string, timeZone: string): string {- if (!limit || !ENGINE_WIDE_DRIVERS.has(limit.driver) || limit.usedPercent === null || limit.usedPercent < NEAR_LIMIT_PERCENT) return "";+ if (!limit || !engineWide(limit.driver) || limit.usedPercent === null || limit.usedPercent < NEAR_LIMIT_PERCENT) return "";let resets = "";if (limit.resetsAt !== null) {try { resets = `; it resets ${new Date(limit.resetsAt).toLocaleString("en-US", { weekday: "short", hour: "numeric", minute: "2-digit", timeZone })} (${timeZone})`; }diff --git a/src/components/EngineUsage.tsx b/src/components/EngineUsage.tsxindex a385cbc28a..96187648b4 100644--- a/src/components/EngineUsage.tsx+++ b/src/components/EngineUsage.tsx@@ -137,7 +137,7 @@ export function UsageRows({ limit }: { limit: EngineLimit }) {{usageRows(limit).map((row) => (<div key={row.window} data-usage-row={row.window} className="flex flex-col gap-1.5"><div className="flex items-baseline gap-3 text-[12px] leading-4">- <span className="shrink-0 text-ink-secondary">{windowLabel(row.window)}</span>+ <span className="shrink-0 text-ink-secondary">{windowLabel(row.window, limit.meter)}</span><span className={cn("ms-auto min-w-0 truncate text-end tabular-nums", row.tone === "fine" ? "text-ink" : TONE_INK[row.tone])}><span className="font-medium">{row.tone === "out" ? t("limits.windowAtLimit") : t("planUsage.left", { remaining: row.left })}</span>{row.resetsAt !== null && row.resetsAt > now && ` · ${t("limits.resets", { time: resetTime(row.resetsAt, now) })}`}diff --git a/src/components/ModelPicker.usage.test.ts b/src/components/ModelPicker.usage.test.tsindex 0db1a9a794..3083269c58 100644--- a/src/components/ModelPicker.usage.test.ts+++ b/src/components/ModelPicker.usage.test.ts@@ -216,8 +216,8 @@ describe("the model menu's usage rings", () => {expect(shownRows(menu)).toEqual(["5-hour", "weekly"]);});- it("show Antigravity's full Gemini window as at its limit, with nothing to retry since it holds no turns", async () => {- remember([usage(38), { ...usage(100), engine: "antigravity", name: "Antigravity", driver: "antigravity",+ it("name Antigravity's windows as Gemini's, and show a full one at its limit with nothing to retry since it holds no turns", async () => {+ remember([usage(38), { ...usage(100), engine: "antigravity", name: "Antigravity", driver: "antigravity", meter: "Gemini",windows: [{ window: "5-hour", usedPercent: 100, resetsAt: RESET }, { window: "weekly", usedPercent: 40, resetsAt: RESET }] }]);const menu = await openMenu();expect(rings(menu).map((ring) => [ring.dataset.usageEngine, ring.querySelector("[data-usage-ring]")?.getAttribute("data-usage-ring")]))@@ -225,6 +225,7 @@ describe("the model menu's usage rings", () => {flushSync(() => rings(menu)[1]!.click());expect(shownRows(menu)).toEqual(["5-hour", "weekly"]);expect(menu.querySelector("[data-usage-rows]")?.textContent).toContain("Antigravity usage");+ expect([...menu.querySelectorAll("[data-usage-row] > div > span:first-child")].map((label) => label.textContent)).toEqual(["Gemini 5-hour", "Gemini Weekly"]);expect(menu.querySelector("[data-usage-row='5-hour'] [data-usage-track]")?.getAttribute("class")).toContain("bg-danger");expect(menu.querySelector("[data-usage-check]")).toBeNull();expect(menu.querySelector("[data-usage-release]")).toBeNull();diff --git a/src/lib/limit-resets.ts b/src/lib/limit-resets.tsindex af67eb383e..b292efe51e 100644--- a/src/lib/limit-resets.ts+++ b/src/lib/limit-resets.ts@@ -125,8 +125,10 @@ export function usageRows(limit: EngineLimit): UsageRow[] {});}-export function windowLabel(window: LimitWindowName): string {- return window === "5-hour" ? t("planUsage.fiveHour") : window === "weekly" ? t("planUsage.weekly") : t("usage.title");+/** "5-hour", or "Gemini 5-hour" when the windows measure one allowance of the engine's (EngineLimit.meter). */+export function windowLabel(window: LimitWindowName, meter?: string): string {+ const label = window === "5-hour" ? t("planUsage.fiveHour") : window === "weekly" ? t("planUsage.weekly") : t("usage.title");+ return meter ? t("limits.meterWindow", { meter, window: label }) : label;}export interface ResetMarker { engine: string; name: string; at: number }diff --git a/src/locales/en.json b/src/locales/en.jsonindex 0d6d584246..dbe23c4826 100644--- a/src/locales/en.json+++ b/src/locales/en.json@@ -5509,6 +5509,7 @@"limits.atLimit": "{engine}: at its limit","limits.resets": "resets {time}","limits.windowAtLimit": "At its limit",+ "limits.meterWindow": "{meter} {window}","limits.clearsOnReply": "Clears by itself once {engine} replies again.","limits.tryAgainNow": "Try again now","limits.cardTitle": "{engine} usage",diff --git a/src/locales/pt-br.json b/src/locales/pt-br.jsonindex bc9e871815..7f60e25efe 100644--- a/src/locales/pt-br.json+++ b/src/locales/pt-br.json@@ -8160,6 +8160,7 @@"model.fallback.uses": "O bot usa os modelos de reserva nesta ordem, sem outra configuração, quando a IA dele atinge o limite de uso ou o provedor comprova que um pedido nem começou. Se um trabalho pode ter sido executado, ele não é repetido. Só essa conversa troca de IA. As configurações padrão do bot e as outras conversas continuam iguais. O provedor reserva pode cobrar pelo uso.","settings.recovery.ownBackups": "Bots com modelos de reserva próprios (Modelo → Modelos de reserva deste bot) usam essas opções, esteja esta configuração ligada ou não.","limits.windowAtLimit": "No limite",+ "limits.meterWindow": "{meter} {window}","limits.clearsOnReply": "O bloqueio termina automaticamente quando {engine} voltar a responder.","limits.tryAgainNow": "Tentar agora","limits.cardTitle": "Uso do {engine}",diff --git a/src/locales/zh-tw.json b/src/locales/zh-tw.jsonindex fbff8656ad..c9785fb867 100644--- a/src/locales/zh-tw.json+++ b/src/locales/zh-tw.json@@ -4957,6 +4957,7 @@"limits.atLimit": "{engine}:已達上限","limits.resets": "{time} 重置","limits.windowAtLimit": "已達上限",+ "limits.meterWindow": "{meter} {window}","limits.clearsOnReply": "等 {engine} 能再次回覆後會自動解除。","limits.cardTitle": "{engine} 用量","limits.checked": "{when}檢查",diff --git a/src/locales/zh.json b/src/locales/zh.jsonindex 10b7519897..ffc52bc1fe 100644--- a/src/locales/zh.json+++ b/src/locales/zh.json@@ -4971,6 +4971,7 @@"limits.atLimit": "{engine}:已达上限","limits.resets": "{time} 重置","limits.windowAtLimit": "已达上限",+ "limits.meterWindow": "{meter} {window}","limits.clearsOnReply": "等 {engine} 能再次回复后会自动解除。","limits.cardTitle": "{engine} 用量","limits.checked": "{when}检查",