Skip to content

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

feat(cline): free and ClinePass models in the picker, ClinePass limit as a usage limit

Krishna Dobhalc28070901d58
diff --git a/docs/verification/cline.md b/docs/verification/cline.md
index e9039c11c3..16f4c39640 100644
--- a/docs/verification/cline.md
+++ b/docs/verification/cline.md
@@ -1,9 +1,14 @@
# Cline engine
-Install the standalone Cline CLI (`npm install -g cline`) and run `cline auth`
-in a terminal to choose its provider, model and account. OpenMausBot's **Cline**
-model provider uses **Cline default (configured)**; provider/model selection
-stays in Cline. A missing CLI or unconfigured account remains unavailable.
+Install the standalone Cline CLI (`npm install -g cline`) and sign in with
+`cline auth` in a terminal; OpenMausBot reads that saved login and has no sign-in
+of its own. The picker offers **Cline default (configured)** plus Cline's
+ClinePass and free models, read from Cline's public recommended-models list
+(a bundled list when it can't be reached). A tier model switches the session's `provider` option to `cline-pass` or
+`cline`; the default puts the saved provider back. A ClinePass limit
+("You have reached your weekly Clinepass limit. The limit resets in 8h 30m")
+is a usage limit held until the stated reset plus a minute.
+A missing CLI or unconfigured account remains unavailable.
Use **Set CLI** for a wrapper with `--config` or `--data-dir` when needed.
The driver reads only the selected entry of Cline's version-1
diff --git a/server/drivers/acp/cline-models.ts b/server/drivers/acp/cline-models.ts
new file mode 100644
index 0000000000..9b53e94ad1
--- /dev/null
+++ b/server/drivers/acp/cline-models.ts
@@ -0,0 +1,75 @@
+// Cline's free and ClinePass models, which `cline --acp` does not list: its ACP agent lists only the models of the
+// session's provider, yet takes a model it did not list. Cline's recommended-models list is public; the CLI reads it
+// without the account.
+import type { ModelCatalog } from "../../contracts.ts";
+
+export const CLINE_RECOMMENDED_MODELS_URL = "https://api.cline.bot/api/v1/ai/cline/recommended-models";
+const FETCH_TIMEOUT_MS = 3_000;
+
+type Entry = { id: string; name?: string };
+type Option = ModelCatalog["options"][number];
+
+const FREE_FALLBACK: Entry[] = [
+ { id: "cline-free/minimax-m3.1-flash", name: "Minimax M3.1 Flash" },
+ { id: "cline-free/nemotron-3.5-super-vl", name: "Nemotron 3.5 Super VL" },
+ { id: "cline-free/mimo-v2.6-flash", name: "Mimo V2.6 Flash" },
+ { id: "cline-free/muse-spark-1.3-contributor", name: "Muse Spark 1.3 Contributor" },
+ { id: "cline-free/solar-mini4", name: "Solar Mini 4" },
+];
+
+const PASS_FALLBACK: Entry[] = [
+ "cline-pass/deepseek-v4.1-flash-1017",
+ "cline-pass/deepseek-v4-pro",
+ "cline-pass/glm-5.3",
+ "cline-pass/glm-5.3-flash",
+ "cline-pass/kimi-k3.1-pro",
+ "cline-pass/muse-spark-1.3-contributor",
+ "cline-pass/kimi-k3",
+ "cline-pass/qwen3.8-max",
+ "cline-pass/minimax-m3.1-flash",
+].map((id) => ({ id }));
+
+/** The Cline provider a tier model runs on: ClinePass on the subscription, the free tier on Cline's own account. */
+export function clineTierProvider(model: string | undefined): "cline-pass" | "cline" | undefined {
+ return model?.startsWith("cline-pass/") ? "cline-pass" : model?.startsWith("cline-free/") ? "cline" : undefined;
+}
+
+function option(entry: Entry, tier: string): Option {
+ const given = entry.name?.trim();
+ const name = given && given !== entry.id ? given : entry.id.slice(entry.id.indexOf("/") + 1);
+ return { id: entry.id, label: name.toLowerCase().endsWith(`(${tier.toLowerCase()})`) ? name : `${name} (${tier})` };
+}
+
+function tierOptions(pass: Entry[], free: Entry[]): Option[] {
+ return [
+ ...pass.filter((entry) => clineTierProvider(entry.id) === "cline-pass").map((entry) => option(entry, "ClinePass")),
+ ...free.filter((entry) => clineTierProvider(entry.id) === "cline").map((entry) => option(entry, "free")),
+ ];
+}
+
+function entries(value: unknown): Entry[] | null {
+ if (!Array.isArray(value)) return null;
+ const list = value.filter((entry): entry is Entry => typeof entry?.id === "string" && (entry.name === undefined || typeof entry.name === "string"));
+ return list.length === value.length ? list : null;
+}
+
+let last: Option[] = tierOptions(PASS_FALLBACK, FREE_FALLBACK);
+
+/** The free and ClinePass models, ClinePass first. A list that cannot be read gives the last one that could, then the
+ * bundled one; never throws. */
+export async function clineTierModels(fetchImpl: typeof fetch = fetch): Promise<Option[]> {
+ try {
+ const response = await fetchImpl(CLINE_RECOMMENDED_MODELS_URL, {
+ headers: { accept: "application/json" },
+ signal: AbortSignal.timeout(FETCH_TIMEOUT_MS),
+ });
+ if (!response.ok) return last;
+ const body = await response.json() as { free?: unknown; clinePass?: unknown };
+ const free = entries(body?.free);
+ const pass = body?.clinePass === undefined ? [] : entries(body.clinePass);
+ if (!free || !pass) return last;
+ // An empty tier is an answer: Cline can end one, and the picker must not keep the old list.
+ last = tierOptions(pass, free);
+ } catch {}
+ return last;
+}
diff --git a/server/drivers/acp/cline.test.ts b/server/drivers/acp/cline.test.ts
index 524966869d..ccfa994015 100644
--- a/server/drivers/acp/cline.test.ts
+++ b/server/drivers/acp/cline.test.ts
@@ -9,7 +9,8 @@ import type { ProviderInstance } from "../../contracts.ts";
import { recordEvents, type EventRecorder } from "../../testing/events.ts";
import { removeTempDir } from "../../testing/cleanup.ts";
import { BUILT_IN_DRIVERS } from "../builtIn.ts";
-import { ClineAgentDriver } from "./cline.ts";
+import { CLINE_SUPPORT, ClineAgentDriver, clinePlanLimit } from "./cline.ts";
+import { clineTierModels } from "./cline-models.ts";
import { supportsApprovalMode } from "../../../shared/approval-mode.ts";
import { assertToolScopeSupported } from "../../../shared/tool-scope-support.ts";
@@ -88,8 +89,7 @@ describe("Cline ACP driver", () => {
const { turnId } = await instance.adapter.sendTurn({ threadId: "cline-saved", text: "hello" });
await recorder.until((event) => event.type === "turn.completed" && event.turnId === turnId);
const launch = JSON.parse(readFileSync(join(scratch, "launch.json"), "utf8"));
- expect(launch.env.CLINE_PROVIDER).toBe("openai-compatible");
- expect(launch.env.CLINE_MODEL).toBe("fixture-model");
+ expect(launch.env.CLINE_PROVIDER).toBeUndefined();
expect(launch.env.CLINE_API_KEY).toBe("saved-fixture-key");
const calls = JSON.parse(readFileSync(join(scratch, "launch.json.config.json"), "utf8"));
expect(calls).toContainEqual({ method: "session/set_model", params: { sessionId: expect.any(String), modelId: "fixture-model" } });
@@ -128,6 +128,54 @@ describe("Cline ACP driver", () => {
expect(existsSync(second.path)).toBe(false);
});
+ it("lists ClinePass then free models, keeping the last list Cline answered", async () => {
+ const answer = (body: unknown, ok = true) => (async () => ({ ok, json: async () => body })) as unknown as typeof fetch;
+ const live = await clineTierModels(answer({
+ free: [{ id: "cline-free/solar-mini4", name: "Solar Mini 4" }, { id: "openai/gpt-x" }],
+ clinePass: [{ id: "cline-pass/glm-5.3", name: "cline-pass/glm-5.3" }],
+ }));
+ expect(live).toEqual([
+ { id: "cline-pass/glm-5.3", label: "glm-5.3 (ClinePass)" },
+ { id: "cline-free/solar-mini4", label: "Solar Mini 4 (free)" },
+ ]);
+ expect(await clineTierModels(answer({}, false))).toEqual(live);
+ expect(await clineTierModels(answer({ free: "nope" }))).toEqual(live);
+ expect(await clineTierModels((async () => { throw new Error("offline"); }) as typeof fetch)).toEqual(live);
+ });
+
+ it("runs a tier model on its Cline provider and puts the saved provider back afterwards", async () => {
+ const calls: Array<[string, unknown]> = [];
+ const request = async (method: string, params: unknown) => { calls.push([method, params]); return {}; };
+ const configOptions = [{ id: "provider", currentValue: "openai-compatible" }, { id: "model", currentValue: "fixture-model" }];
+ const base = { request, sessionId: "s", config: { cli: "cline" }, sessionModels: [], currentModelId: "fixture-model", configOptions, notice() {} } as any;
+ expect(CLINE_SUPPORT.resolveTurnModel!("cline-pass/glm-5.3", {}, ClineAgentDriver.models)).toBe("cline-pass/glm-5.3");
+ expect(() => CLINE_SUPPORT.resolveTurnModel!("openai/gpt-x", {}, ClineAgentDriver.models)).toThrow(/Pick a Cline model/);
+ await CLINE_SUPPORT.configureSession!({ ...base, env: {}, turn: { model: "cline-pass/glm-5.3" } });
+ await CLINE_SUPPORT.configureSession!({ ...base, env: {}, turn: { model: "cline-free/solar-mini4" } });
+ expect(calls).toEqual([
+ ["session/set_config_option", { sessionId: "s", configId: "provider", value: "cline-pass" }],
+ ["session/set_config_option", { sessionId: "s", configId: "model", value: "cline-pass/glm-5.3" }],
+ ["session/set_config_option", { sessionId: "s", configId: "provider", value: "cline" }],
+ ["session/set_config_option", { sessionId: "s", configId: "model", value: "cline-free/solar-mini4" }],
+ ]);
+ calls.length = 0;
+ const switched = [{ id: "provider", currentValue: "cline-pass" }, { id: "model", currentValue: "cline-pass/glm-5.3" }];
+ await CLINE_SUPPORT.configureSession!({ ...base, configOptions: switched, env: { CLINE_PROVIDER: "openai-compatible", CLINE_MODEL: "fixture-model" }, turn: { model: "cline-default" } });
+ expect(calls).toEqual([
+ ["session/set_config_option", { sessionId: "s", configId: "provider", value: "openai-compatible" }],
+ ["session/set_model", { sessionId: "s", modelId: "fixture-model" }],
+ ]);
+ });
+
+ it("reads a ClinePass limit as a usage limit with its reset", () => {
+ const now = Date.UTC(2026, 10, 18);
+ const limit = clinePlanLimit(new Error("Internal error: You have reached your weekly Clinepass limit. The limit resets in 8h 30m, please try again later. (session/prompt)"), now);
+ expect(limit).toMatchObject({ acpUsageLimit: true, facts: { limitResetsAt: now + (8 * 60 + 31) * 60_000 } });
+ expect(clinePlanLimit(new Error("You have reached your daily Clinepass limit."), now)?.facts.limitResetsAt).toBeUndefined();
+ expect(clinePlanLimit(new Error("You hit your rate limit"), now)).toBeUndefined();
+ expect(clinePlanLimit(new Error("reached your context window limit"), now)).toBeUndefined();
+ });
+
it("fails the turn rather than silently using a fallback model", async () => {
const { instance, recorder } = await create("set-model-invalid-params");
await instance.adapter.sendTurn({ threadId: "cline-model-refused", text: "hello", model: "cline-default" });
diff --git a/server/drivers/acp/cline.ts b/server/drivers/acp/cline.ts
index f5d699eec8..f3c2407b1a 100644
--- a/server/drivers/acp/cline.ts
+++ b/server/drivers/acp/cline.ts
@@ -1,22 +1,24 @@
-// Cline owns its saved provider/model configuration; no static OMB catalog switches providers.
+// Cline owns its saved provider/model configuration. Its free and ClinePass models run on Cline's own `cline` and
+// `cline-pass` providers, which a turn switches the session to.
import { mkdtempSync, readFileSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";
import { homedir, tmpdir } from "node:os";
import { join } from "node:path";
import { createHash } from "node:crypto";
import { resolveCli } from "../../procs.ts";
-import { createAcpDriver, type AcpConfig, type AcpSupport } from "./core.ts";
+import { createAcpDriver, type AcpSupport } from "./core.ts";
import type { ModelCatalog } from "../../contracts.ts";
+import { engineFailure } from "../engine-errors.ts";
+import { AcpReportedFailure } from "./failure-words.ts";
+import { clineTierModels, clineTierProvider } from "./cline-models.ts";
-const MODELS: ModelCatalog = {
- default: "cline-default",
- options: [{ id: "cline-default", label: "Cline default (configured)" }],
-};
+const DEFAULT_OPTION = { id: "cline-default", label: "Cline default (configured)" };
+const MODELS: ModelCatalog = { default: DEFAULT_OPTION.id, options: [DEFAULT_OPTION] };
type ClineSettings = { provider: string; model?: string; apiKey?: string; auth?: { accessToken?: string; apiKey?: string } };
-function savedProvider(env: Record<string, string | undefined>, config: AcpConfig): { settings: ClineSettings; fingerprint: string } | null {
+function savedProvider(env: Record<string, string | undefined>, cli: string): { settings: ClineSettings; fingerprint: string } | null {
try {
- const args = resolveCli(config.cli, [], env).args;
+ const args = resolveCli(cli, [], env).args;
const flag = (name: string) => {
const index = args.lastIndexOf(name);
return index >= 0 ? args[index + 1] : args.find((arg) => arg.startsWith(`${name}=`))?.slice(name.length + 1);
@@ -49,9 +51,35 @@ function savedProvider(env: Record<string, string | undefined>, config: AcpConfi
const OAUTH = new Set(["cline", "cline-pass", "openai-codex"]);
+function oauthSignedIn(settings: ClineSettings | undefined): boolean {
+ return Boolean(settings && OAUTH.has(settings.provider) &&
+ (settings.auth?.accessToken?.trim() || settings.apiKey?.trim() || settings.auth?.apiKey?.trim()));
+}
+
const LOGIN_NOTE = "Cline is not configured. Run cline auth in a terminal, then try again.";
-const SUPPORT: AcpSupport = {
+/** Cline 3.0.74: "You have reached your weekly Clinepass limit. The limit resets in 8h 30m, please try again later." */
+const PLAN_LIMIT = /\breached your (?:session|daily|weekly|monthly|\d+-hour) [\w-]+ limit\b/i;
+const RESET_IN = /\bresets in ((?:\s*\d+\s*[dhm]\b)+)/i;
+const UNIT_MS: Record<string, number> = { d: 86_400_000, h: 3_600_000, m: 60_000 };
+
+export function clinePlanLimit(error: unknown, now = Date.now()): AcpReportedFailure | undefined {
+ const text = error instanceof Error ? error.message : typeof error === "string" ? error : "";
+ if (!PLAN_LIMIT.test(text)) return undefined;
+ let delayMs = 0;
+ for (const [, amount, unit] of RESET_IN.exec(text)?.[1]?.matchAll(/(\d+)\s*([dhm])/gi) ?? []) {
+ delayMs += Number(amount) * UNIT_MS[unit!.toLowerCase()]!;
+ }
+ // holds the whole engine, free models too; hold only the ClinePass models via limitFacts if that bites.
+ // Cline rounds the wait down to the minute.
+ const resetsAt = delayMs > 0 ? now + delayMs + 60_000 : undefined;
+ const failure = engineFailure("Cline", "", { kind: "usage_limit", status: null, resetsAt })!;
+ return new AcpReportedFailure({ ...failure, ...(resetsAt === undefined ? {} : { limitResetsAt: resetsAt }) }, true);
+}
+
+type ConfigOption = { id?: string; currentValue?: unknown };
+
+export const CLINE_SUPPORT: AcpSupport = {
driverKind: "clineAgent",
displayName: "Cline",
models: MODELS,
@@ -70,42 +98,61 @@ const SUPPORT: AcpSupport = {
restartOnMcpChange: true,
credentialEnv: ["CLINE_API_KEY"],
transformEnv(env, config) {
- const saved = savedProvider(env, config)?.settings;
+ const saved = savedProvider(env, config.cli)?.settings;
+ // Not CLINE_PROVIDER: Cline 3.0.74 refuses session/set_config_option `provider` while it is set.
if (!saved) return;
- env.CLINE_PROVIDER ||= saved.provider;
- env.CLINE_MODEL ||= saved.model;
// ACP restores OAuth accounts itself but needs CLINE_API_KEY for BYOK; never another account's key.
if (!OAUTH.has(saved.provider)) env.CLINE_API_KEY ||= saved.apiKey || saved.auth?.apiKey;
},
- spawnFingerprint: (env, config) => savedProvider(env, config)?.fingerprint ?? "unconfigured",
- pickAuthMethod: (methods, env) => !env.CLINE_API_KEY && OAUTH.has(env.CLINE_PROVIDER ?? "")
- && methods.some((method) => method.id === env.CLINE_PROVIDER) ? env.CLINE_PROVIDER! : null,
+ spawnFingerprint: (env, config) => savedProvider(env, config.cli)?.fingerprint ?? "unconfigured",
+ pickAuthMethod: (methods, env) => {
+ const provider = env.CLINE_PROVIDER || savedProvider(env, "cline")?.settings.provider || "";
+ return !env.CLINE_API_KEY && OAUTH.has(provider) && methods.some((method) => method.id === provider) ? provider : null;
+ },
authFailure: "fail-request",
// Missing credentials are rejected by session/new; never launch an interactive sign-in during a turn.
isAuthenticated: (env, config) => {
if (env.CLINE_API_KEY?.trim()) return true;
- const saved = savedProvider(env, config)?.settings;
- return Boolean(saved && OAUTH.has(saved.provider) &&
- (saved.auth?.accessToken?.trim() || saved.apiKey?.trim() || saved.auth?.apiKey?.trim()));
+ return oauthSignedIn(savedProvider(env, config.cli)?.settings);
},
requireAuthenticationBeforeSpawn: true,
+ resolveModels: async () => ({ default: DEFAULT_OPTION.id, options: [DEFAULT_OPTION, ...await clineTierModels()] }),
resolveTurnModel(model, env) {
- if (model && model !== "cline-default") {
- throw new Error("Select Cline default (configured). Change Cline's provider or model with cline auth in a terminal.");
+ if (clineTierProvider(model)) return model;
+ if (model && model !== DEFAULT_OPTION.id) {
+ throw new Error("Pick a Cline model from the list, or Cline default (configured).");
}
return env.CLINE_MODEL?.trim();
},
- async configureSession({ request, sessionId, env, currentModelId }) {
+ async configureSession({ request, sessionId, env, config, turn, currentModelId, configOptions }) {
+ const options = configOptions as ConfigOption[];
+ const option = (id: string) => options.find((entry) => entry.id === id);
+ const setOption = async (configId: string, value: string) => {
+ const current = option(configId);
+ if (current && current.currentValue !== value) await request("session/set_config_option", { sessionId, configId, value });
+ };
+ const tier = clineTierProvider(turn.model);
+ if (tier) {
+ // The agent lists only its provider's models, but runs a model it did not list.
+ await setOption("provider", tier);
+ if (option("model")) await setOption("model", turn.model!);
+ else if (turn.model !== currentModelId) await request("session/set_model", { sessionId, modelId: turn.model });
+ return;
+ }
+ const saved = savedProvider(env, config.cli)?.settings;
+ const provider = env.CLINE_PROVIDER || saved?.provider;
+ if (provider) await setOption("provider", provider);
// session/new falls back when a saved custom model is missing from Cline's built-in catalog.
- const model = env.CLINE_MODEL?.trim();
- if (model && model !== currentModelId) {
+ const model = env.CLINE_MODEL?.trim() || saved?.model?.trim();
+ if (model && model !== (option("model")?.currentValue ?? currentModelId)) {
await request("session/set_model", { sessionId, modelId: model });
}
},
+ reportedFailure: (error) => clinePlanLimit(error),
};
export const ClineAgentDriver = {
- ...createAcpDriver(SUPPORT),
+ ...createAcpDriver(CLINE_SUPPORT),
async create(input: Parameters<ReturnType<typeof createAcpDriver>["create"]>[0]) {
// Cline 3.0.70 records ACP mcpServers without connecting them; its native settings override connects
// the scoped stdio servers instead, without rewriting the user's MCP file.
@@ -115,7 +162,7 @@ export const ClineAgentDriver = {
};
try {
const driver = createAcpDriver({
- ...SUPPORT,
+ ...CLINE_SUPPORT,
applyTurnEnv(env, { threadId, mcpServers }) {
const path = join(directory, `${createHash("sha256").update(threadId).digest("hex")}.json`);
const mcp = Object.fromEntries(mcpServers.flatMap((server) => "command" in server ? [server] : []).map(({ name, command, args, env: serverEnv }) => [name, {
diff --git a/server/drivers/acp/core.ts b/server/drivers/acp/core.ts
index 5e35ad53b7..dd5e83fe9c 100644
--- a/server/drivers/acp/core.ts
+++ b/server/drivers/acp/core.ts
@@ -1323,6 +1323,9 @@ export function createAcpDriver(support: AcpSupport): ProviderDriver<AcpConfig>
models: { ...session.sessionConfigResult?.models, currentModelId: params.modelId },
};
}
+ if (method === "session/set_config_option" && Array.isArray(result?.configOptions)) {
+ session.sessionConfigResult = { ...session.sessionConfigResult, configOptions: result.configOptions };
+ }
return result;
},
sessionId,
@@ -1456,7 +1459,7 @@ export function createAcpDriver(support: AcpSupport): ProviderDriver<AcpConfig>
});
settle(threadId, session, false, reason ?? "failed");
}
- } catch (raw) { const e = signIn.asked(raw) ?? raw;
+ } catch (raw) { const e = signIn.asked(raw) ?? support.reportedFailure?.(raw) ?? raw;
if (pendingSplitReceipt && state.promptSent && state.usageCompacted) {
deletePromptSplitReceipt(DRIVER_KIND, pendingSplitReceipt.key);
}
diff --git a/server/drivers/acp/driver-hooks.ts b/server/drivers/acp/driver-hooks.ts
index 22f85d44ee..a6985b9c6b 100644
--- a/server/drivers/acp/driver-hooks.ts
+++ b/server/drivers/acp/driver-hooks.ts
@@ -23,6 +23,9 @@ export interface AcpDriverHooks {
/** Called before each session/prompt. The check it returns gets that prompt's result and names the failure the agent
* reported as an ordinary reply, which then fails the turn. Neither may throw. */
promptOutcome?(instanceId: string, sessionId: string): Promise<(result: unknown) => Promise<Error | undefined>>;
+ /** The failure a turn's thrown error stands for, in the person's words (a usage limit with its reset), or undefined to
+ * keep the error as it is. Must not throw. */
+ reportedFailure?(error: unknown): Error | undefined;
}
const MAX_LINE_CHARS = 64 * 1024;