Skip to content

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

Add per-bot Claude endpoints for DeepSeek and GLM

fanxing1158b71e30ff6d
diff --git a/apps/docs/content/docs/providers/model-providers.mdx b/apps/docs/content/docs/providers/model-providers.mdx
index e0f83cd090..82087fb535 100644
--- a/apps/docs/content/docs/providers/model-providers.mdx
+++ b/apps/docs/content/docs/providers/model-providers.mdx
@@ -155,11 +155,25 @@ broker, including Full Access. Native Cline tool selection is not supported.
### Claude Code
-The app has no place yet to point Claude Code at another provider. The
-**Anthropic API key** in Connections is for Anthropic only.
-
-You can point Claude Code itself at OpenRouter, Fireworks AI or DeepSeek,
-and your Claude bots follow it:
+The **Anthropic API key** in Connections is for Anthropic only.
+
+To run Claude bots on DeepSeek, GLM or another host that speaks Claude
+Code's API, add a **custom endpoint** in Settings → Engines, in the Claude
+card:
+
+- **Add endpoint** takes a name, the endpoint's base URL, its token and the
+ model id the endpoint serves. Model mappings for Opus, Sonnet and Haiku
+ are optional.
+- Each endpoint is its own engine with its own directory, so a bot chooses
+ it like any other AI. It never reads or writes this computer's
+ `~/.claude`, and the Claude Code on this computer keeps its own sign-in.
+- Its bots run the model the endpoint serves. A bot that still has a Claude
+ model selected runs the endpoint's main model instead.
+- The token is saved in OpenMausBot's own `config.json`, never sent to
+ Anthropic. Removing an endpoint removes only that entry.
+
+You can also point Claude Code itself at OpenRouter, Fireworks AI or
+DeepSeek, and your Claude bots follow it:
- Put `ANTHROPIC_BASE_URL` and your key in the `env` block of
`~/.claude/settings.json`. Fireworks' FireConnect does this for you.
diff --git a/docs/verification/README.md b/docs/verification/README.md
index 0e3222533e..5683f2998a 100644
--- a/docs/verification/README.md
+++ b/docs/verification/README.md
@@ -295,6 +295,11 @@ responsive layouts, theme contrast, and status refreshes without losing drafts.
The [Claude account recipe](claude-account.md) checks sign-out, cancellation and
retry against an offline Claude CLI confined to a disposable home.
+The [Claude custom endpoints](claude-endpoint.md) checks a per-bot DeepSeek/GLM
+endpoint in Settings and its turn against the fake Claude CLI: its own
+directory, its model and routing, the token kept out of the engine list, and
+edits that keep the saved token.
+
The [provider recovery recipe](provider-recovery.md) verifies real Grok image
transport and Claude authentication against loopback APIs, plus scoped thread
approvals and provider safety errors in an isolated desktop UI.
diff --git a/docs/verification/claude-endpoint.md b/docs/verification/claude-endpoint.md
new file mode 100644
index 0000000000..0c6af9bf11
--- /dev/null
+++ b/docs/verification/claude-endpoint.md
@@ -0,0 +1,95 @@
+# Claude custom endpoints
+
+A custom endpoint is a Claude bot engine of its own: it points Claude Code at
+DeepSeek, GLM or another host that speaks Claude Code's API, with its own
+directory, while the Claude Code on this computer keeps its sign-in. This
+recipe uses only the disposable fixture and the fake Claude CLI; it never
+calls a real provider and never reads or writes a real `~/.claude`.
+
+Launch the fixture and keep its printed `url`, `dataDir` and `logPath`:
+
+```sh
+node --experimental-strip-types scripts/control-omb.ts launch
+```
+
+Its `config.json` has one **Verification fixture** Claude account whose CLI is
+the repository's fake Claude CLI. The launcher always writes the latest turn's
+spawn record to `<dataDir>/fake-claude-dump.json`; caller-supplied
+`FAKE_CLAUDE_DUMP` is replaced, so read that path.
+
+## Settings section
+
+Open `previewUrl` from the launch evidence, then Settings → Engines. Expand the
+Claude card.
+
+1. **Add endpoint** opens a form inside the card: name, base URL, token, model,
+ and an optional **Model mappings** disclosure for Opus, Sonnet and Haiku.
+ Save stays disabled until name, URL, model and (for a new endpoint) token
+ are filled. A rejected save shows an alert in the form and leaves the
+ fields editable.
+2. Save a name, `https://api.deepseek.com/anthropic`, a fake token and
+ `deepseek-chat`. A row appears with the address and models and its own
+ **Edit** and **Remove** actions. The token is not shown anywhere.
+3. **Edit** shows the saved address and models, with the token field empty and
+ labelled to keep the saved token. Change the model and save: the row and
+ the bot's picker show only the new model. Leave the token empty; the saved
+ token still runs the bot.
+4. Create a bot on the endpoint. Its model picker offers the endpoint's models
+ only (here `deepseek-chat`), with the first as the default.
+5. Try **Remove** while a bot still uses the endpoint: the button is disabled
+ and its tooltip says how many bots use it. Move the bot to another model,
+ then remove it: only the row disappears, and Claude's own sign-in stays.
+
+## HTTP and turn evidence
+
+Against the printed `url` (loopback owner trust in the fixture):
+
+```sh
+curl -s -X POST "$URL/api/instances/claude-endpoint" \
+ -H 'content-type: application/json' \
+ -d '{"displayName":"DeepSeek verify","baseUrl":"https://api.deepseek.com/anthropic","token":"sk-verify-secret","model":"deepseek-chat","opusModel":"deepseek-reasoner"}'
+```
+
+The response is `201` with `instanceId` and the engine list; the endpoint row
+carries `access: "custom"`, `url`, and `claudeEndpoint` with `baseUrl`,
+`models` and `tokenSaved` — never the token. `GET $URL/api/instances` must not
+contain `sk-verify-secret` either. `<dataDir>/config.json` now holds:
+
+- `config.configDir` = `<dataDir>/providers/<instanceId>`
+- `config.requireApiKey` = `true` and `config.endpointModels` = the served models
+- `environment.ANTHROPIC_BASE_URL`, `ANTHROPIC_AUTH_TOKEN`, `ANTHROPIC_API_KEY`,
+ `ANTHROPIC_MODEL`, and a tier value for each non-empty mapping
+
+Create a bot on the endpoint (`POST /api/bots` with
+`modelSelection.model = "deepseek-chat"`), send a message and wait for idle.
+`<dataDir>/fake-claude-dump.json` then shows the turn's `env` and `argv`:
+`CLAUDE_CONFIG_DIR` is the endpoint's own directory, `ANTHROPIC_BASE_URL` and
+`ANTHROPIC_MODEL` are the endpoint's, `ANTHROPIC_AUTH_TOKEN` is the fake token,
+and `--model` is the endpoint's model. Nothing in the dump reads the
+fixture's home `~/.claude`.
+
+`PATCH $URL/api/instances/<instanceId>/claude-endpoint` with a new `model` and
+`"opusModel": ""` keeps the saved token, replaces `ANTHROPIC_MODEL`, drops the
+cleared tier, and shrinks `config.endpointModels` to the served models. A
+missing instance is `404`; a named Claude account is `400`; an endpoint whose saved
+token is gone is `400` and asks for the token.
+
+`DELETE $URL/api/instances/<instanceId>` removes only the saved entry after the
+bot moves off it; deliberately created files under its `providers/<id>`
+directory stay (the fixture's fake CLI does not create the directory by itself).
+
+## Regression suites
+
+```sh
+pnpm exec vitest run --no-file-parallelism server/claude-endpoints.test.ts server/claude-account-api.test.ts server/model-providers-docs.test.ts server/default-model-selection.test.ts src/components/ClaudeEndpoints.test.ts
+pnpm typecheck
+pnpm i18n:check
+pnpm lint
+```
+
+## Limitations
+
+This proves the wiring, isolation and API behavior with the fake CLI. It does
+not prove that a real DeepSeek or GLM endpoint answers, because no real token
+is used; do that once by hand with your own key. The Settings surface is
+driven by hand; `control-omb` cannot drive Settings yet.
\ No newline at end of file
diff --git a/server/claude-account-api.test.ts b/server/claude-account-api.test.ts
index 528475a221..73501a5f24 100644
--- a/server/claude-account-api.test.ts
+++ b/server/claude-account-api.test.ts
@@ -48,6 +48,14 @@ async function addBot(instanceId: string) {
return response.body.bot;
}
+async function addBotOn(instanceId: string, model: string) {
+ const response = await api("POST", "/api/bots", {
+ name: "Endpoint bot", modelSelection: { instanceId, model }, requireAvailableModel: true,
+ });
+ expect(response.status, JSON.stringify(response.body)).toBe(201);
+ return response.body.bot;
+}
+
async function bot(id: string) {
return (await api("GET", "/api/bots?messages=30")).body.bots.find((row: any) => row.id === id);
}
@@ -237,6 +245,81 @@ describe("Claude account HTTP API", () => {
}
});
+ it("creates a custom endpoint as its own engine, keeps its token server-side, and runs its model against its host", async () => {
+ // A settings.json the person's own Claude Code uses: an endpoint must not inherit any of it.
+ mkdirSync(join(home, ".claude"), { recursive: true });
+ writeFileSync(join(home, ".claude", "settings.json"), JSON.stringify({
+ env: { ANTHROPIC_BASE_URL: "https://user-settings.test", ANTHROPIC_AUTH_TOKEN: "user-settings-secret", ANTHROPIC_MODEL: "claude-from-settings" },
+ }));
+ const endpoint = {
+ displayName: "DeepSeek", baseUrl: "https://api.deepseek.test/anthropic/", token: "sk-endpoint-secret",
+ model: "deepseek-chat", opusModel: "deepseek-reasoner",
+ };
+ const created = await api("POST", "/api/instances/claude-endpoint", endpoint);
+ expect(created.status, JSON.stringify(created.body)).toBe(201);
+ const id = created.body.instanceId as string;
+ const row = created.body.instances.find((candidate: any) => candidate.instanceId === id);
+ expect(row).toMatchObject({
+ displayName: "DeepSeek",
+ driverKind: "claudeAgent",
+ access: "custom",
+ url: "https://api.deepseek.test/anthropic",
+ claudeEndpoint: { baseUrl: "https://api.deepseek.test/anthropic", models: ["deepseek-chat", "deepseek-reasoner"], tokenSaved: true },
+ });
+ expect(JSON.stringify(created.body)).not.toContain("sk-endpoint-secret");
+ expect(JSON.stringify((await api("GET", "/api/instances")).body)).not.toContain("sk-endpoint-secret");
+ expect(saved().instances[id]).toMatchObject({
+ driver: "claudeAgent", access: "custom",
+ config: { cli, requireApiKey: true, endpointModels: ["deepseek-chat", "deepseek-reasoner"] },
+ environment: {
+ ANTHROPIC_BASE_URL: "https://api.deepseek.test/anthropic",
+ ANTHROPIC_AUTH_TOKEN: "sk-endpoint-secret", ANTHROPIC_API_KEY: "sk-endpoint-secret",
+ ANTHROPIC_MODEL: "deepseek-chat", ANTHROPIC_DEFAULT_OPUS_MODEL: "deepseek-reasoner",
+ },
+ });
+
+ const endpointBot = await addBotOn(id, "deepseek-chat");
+ expect((await api("POST", `/api/bots/${endpointBot.id}/messages`, { text: "which host" })).status).toBe(202);
+ await idle(endpointBot.id);
+ const directory = saved().instances[id].config.configDir as string;
+ const spawn = JSON.parse(readFileSync(join(directory, "spawn.json"), "utf8"));
+ expect(spawn.env).toMatchObject({
+ ANTHROPIC_BASE_URL: "https://api.deepseek.test/anthropic",
+ ANTHROPIC_MODEL: "deepseek-chat",
+ ANTHROPIC_AUTH_TOKEN: "sk-endpoint-secret",
+ });
+ expect(spawn.env.ANTHROPIC_AUTH_TOKEN).not.toBe("user-settings-secret");
+ expect(spawn.env.ANTHROPIC_BASE_URL).not.toBe("https://user-settings.test");
+ const model = spawn.argv[spawn.argv.indexOf("--model") + 1];
+ expect(model).toBe("deepseek-chat");
+ expect((await bot(endpointBot.id)).messages.some((message: any) => message.text === `account:${basename(directory)}`)).toBe(true);
+
+ const edited = await api("PATCH", `/api/instances/${id}/claude-endpoint`, { model: "deepseek-reasoner", opusModel: "" });
+ expect(edited.status, JSON.stringify(edited.body)).toBe(200);
+ const afterEdit = saved().instances[id];
+ expect(afterEdit.environment).toMatchObject({
+ ANTHROPIC_AUTH_TOKEN: "sk-endpoint-secret",
+ ANTHROPIC_BASE_URL: "https://api.deepseek.test/anthropic",
+ ANTHROPIC_MODEL: "deepseek-reasoner",
+ });
+ expect(afterEdit.environment).not.toHaveProperty("ANTHROPIC_DEFAULT_OPUS_MODEL");
+ expect(afterEdit.config.endpointModels).toEqual(["deepseek-reasoner"]);
+ expect(edited.body.instances.find((candidate: any) => candidate.instanceId === id).claudeEndpoint.models).toEqual(["deepseek-reasoner"]);
+
+ expect((await api("PATCH", "/api/instances/claude/claude-endpoint", { model: "deepseek-chat" })).status).toBe(400);
+ expect((await api("PATCH", "/api/instances/missing/claude-endpoint", { model: "deepseek-chat" })).status).toBe(404);
+ for (const invalid of [{}, { displayName: "Only" }, { ...endpoint, baseUrl: "ftp://api.deepseek.test" }, { ...endpoint, model: "has space" }, { ...endpoint, token: "" }]) {
+ expect((await api("POST", "/api/instances/claude-endpoint", invalid)).status, JSON.stringify(invalid)).toBe(400);
+ }
+ mkdirSync(directory, { recursive: true });
+ const marker = join(directory, "user-owned-marker.txt");
+ writeFileSync(marker, "Keep the endpoint's own files");
+ expect((await api("PATCH", `/api/bots/${endpointBot.id}/model`, { instanceId: "claude", model: MODEL })).status).toBe(200);
+ expect((await api("DELETE", `/api/instances/${id}`)).status).toBe(200);
+ expect(saved().instances).not.toHaveProperty(id);
+ expect(readFileSync(marker, "utf8")).toBe("Keep the endpoint's own files");
+ });
+
it("enforces JSON, validation, duplicate-directory and admin-only mutation gates", async () => {
const target = await addAccount("Validation account");
for (const [method, path, body] of [
diff --git a/server/claude-endpoints.test.ts b/server/claude-endpoints.test.ts
new file mode 100644
index 0000000000..ba2d8b11be
--- /dev/null
+++ b/server/claude-endpoints.test.ts
@@ -0,0 +1,165 @@
+import { describe, expect, it } from "vitest";
+
+import { DATA_DIR } from "./config.ts";
+import {
+ claudeEndpointSchema,
+ claudeEndpointUpdateSchema,
+ claudeEndpointInfo,
+ isClaudeEndpoint,
+ newClaudeEndpoint,
+ updateClaudeEndpoint,
+ withClaudeEndpointInfo,
+} from "./claude-endpoints.ts";
+import { ClaudeDriver } from "./drivers/claude.ts";
+
+const BASE = {
+ displayName: "DeepSeek",
+ baseUrl: "https://api.deepseek.com/anthropic/",
+ token: "sk-fixture-secret",
+ model: "deepseek-chat",
+};
+
+const cfg = () => ({
+ instances: {
+ claude: { driver: "claudeAgent", environment: { ANTHROPIC_AUTH_TOKEN: "parent-secret" }, config: { cli: "claude-wrapper" } },
+ other: { driver: "codex", config: { cli: "codex-wrapper" } },
+ },
+}) as never;
+
+describe("custom Claude endpoint", () => {
+ it("creates its own instance with the endpoint's routing, its own directory and no parent credentials", () => {
+ const source = cfg();
+ const { instanceId, instances } = newClaudeEndpoint(source, { ...BASE, opusModel: "deepseek-reasoner", sonnetModel: "" });
+ const entry = instances[instanceId];
+
+ expect(instanceId).toMatch(/^claude-[0-9a-f-]{36}$/);
+ expect(entry).toMatchObject({
+ driver: "claudeAgent",
+ displayName: "DeepSeek",
+ access: "custom",
+ config: {
+ cli: "claude-wrapper",
+ configDir: `${DATA_DIR}/providers/${instanceId}`,
+ requireApiKey: true,
+ endpointModels: ["deepseek-chat", "deepseek-reasoner"],
+ },
+ environment: {
+ ANTHROPIC_BASE_URL: "https://api.deepseek.com/anthropic",
+ ANTHROPIC_AUTH_TOKEN: "sk-fixture-secret",
+ ANTHROPIC_API_KEY: "sk-fixture-secret",
+ ANTHROPIC_MODEL: "deepseek-chat",
+ ANTHROPIC_DEFAULT_OPUS_MODEL: "deepseek-reasoner",
+ },
+ });
+ expect(entry.environment).not.toHaveProperty("ANTHROPIC_DEFAULT_SONNET_MODEL");
+ // The caller's config is left as it was: the fleet is copied, not edited.
+ expect(Object.keys((source as { instances: object }).instances)).toEqual(["claude", "other"]);
+ expect((source as { instances: Record<string, { environment?: object }> }).instances.claude.environment).toEqual({ ANTHROPIC_AUTH_TOKEN: "parent-secret" });
+ // A second endpoint never shares the account's executable environment or directory.
+ const second = newClaudeEndpoint({ instances }, BASE);
+ expect(second.instanceId).not.toBe(instanceId);
+ expect((second.instances[instanceId] as { environment: object }).environment).toEqual(entry.environment);
+ });
+
+ it("reports only the address and models to a client, never the token", () => {
+ const { instanceId, instances } = newClaudeEndpoint(cfg(), BASE);
+ const info = claudeEndpointInfo(instances[instanceId]);
+ expect(info).toEqual({
+ baseUrl: BASE.baseUrl.replace(/\/$/u, ""),
+ models: ["deepseek-chat"],
+ tokenSaved: true,
+ opusModel: "", sonnetModel: "", haikuModel: "", smallFastModel: "",
+ });
+ const described = withClaudeEndpointInfo([{ instanceId }, { instanceId: "claude" }], instances) as Array<Record<string, unknown>>;
+ expect(JSON.stringify(described)).not.toContain("sk-fixture-secret");
+ expect(described[0]).toMatchObject({ url: "https://api.deepseek.com/anthropic", claudeEndpoint: { tokenSaved: true } });
+ expect(described[1]).not.toHaveProperty("claudeEndpoint");
+ expect(isClaudeEndpoint(instances[instanceId])).toBe(true);
+ expect(isClaudeEndpoint(instances.claude)).toBe(false);
+ });
+
+ it("edits in place, keeps an omitted token, and clears a model mapping left empty", () => {
+ const { instanceId, instances } = newClaudeEndpoint(cfg(), { ...BASE, opusModel: "deepseek-reasoner" });
+ const updated = updateClaudeEndpoint({ instances }, instanceId, {
+ model: "deepseek-reasoner",
+ opusModel: "",
+ baseUrl: "https://api.example.test/anthropic",
+ });
+ const entry = updated.instances[instanceId];
+ expect(entry.environment).toMatchObject({
+ ANTHROPIC_BASE_URL: "https://api.example.test/anthropic",
+ ANTHROPIC_AUTH_TOKEN: "sk-fixture-secret",
+ ANTHROPIC_MODEL: "deepseek-reasoner",
+ });
+ expect(entry.environment).not.toHaveProperty("ANTHROPIC_DEFAULT_OPUS_MODEL");
+ expect((entry.config as { endpointModels: string[] }).endpointModels).toEqual(["deepseek-reasoner"]);
+ expect(updateClaudeEndpoint({ instances: updated.instances }, instanceId, { token: "sk-replaced" })
+ .instances[instanceId].environment).toMatchObject({ ANTHROPIC_AUTH_TOKEN: "sk-replaced", ANTHROPIC_API_KEY: "sk-replaced" });
+ // Nothing else in the fleet moves.
+ expect(updated.instances.claude).toEqual(instances.claude);
+ });
+
+ it("rejects a non-endpoint Claude instance, an unknown id and an endpoint with no token", () => {
+ const { instances } = newClaudeEndpoint(cfg(), BASE);
+ expect(() => updateClaudeEndpoint({ instances }, "claude", { model: "deepseek-chat" })).toThrow(/not a custom endpoint/);
+ expect(() => updateClaudeEndpoint({ instances }, "missing", { model: "deepseek-chat" })).toThrow(/unknown instance/);
+ const stripped = { instances: { ...instances, ghost: { driver: "claudeAgent", config: { endpointModels: ["m"] }, environment: { ANTHROPIC_BASE_URL: "https://x.test" } } } };
+ expect(() => updateClaudeEndpoint(stripped as never, "ghost", { model: "m" })).toThrow(/token/i);
+ });
+
+ it("validates the address, token and model ids before anything is saved", () => {
+ for (const body of [
+ { ...BASE, baseUrl: "ftp://api.example.test" },
+ { ...BASE, baseUrl: "https://user:[email protected]" },
+ { ...BASE, baseUrl: "not a url" },
+ { ...BASE, token: "" },
+ { ...BASE, token: "has\nnewline" },
+ { ...BASE, model: "has space" },
+ { ...BASE, model: "" },
+ { ...BASE, displayName: "Bad\nname" },
+ { ...BASE, environment: { ANTHROPIC_BASE_URL: "https://x.test" } },
+ ]) {
+ expect(claudeEndpointSchema.safeParse(body).success, JSON.stringify(body)).toBe(false);
+ }
+ expect(claudeEndpointSchema.safeParse(BASE).success).toBe(true);
+ expect(claudeEndpointUpdateSchema.safeParse({}).success).toBe(false);
+ expect(claudeEndpointUpdateSchema.safeParse({ token: "" }).success).toBe(false);
+ expect(claudeEndpointUpdateSchema.safeParse({ model: "deepseek-reasoner" }).success).toBe(true);
+ });
+
+});
+
+describe("Claude endpoint catalog", () => {
+ const decoded = (raw: Record<string, unknown>) => ClaudeDriver.decodeConfig(raw);
+
+ it("serves only the endpoint's models, the first one the default", async () => {
+ const instance = await ClaudeDriver.create({
+ instanceId: "claude-endpoint-fixture",
+ displayName: "DeepSeek",
+ enabled: true,
+ environment: {
+ ANTHROPIC_BASE_URL: "https://api.deepseek.com/anthropic",
+ ANTHROPIC_AUTH_TOKEN: "sk-fixture",
+ ANTHROPIC_API_KEY: "sk-fixture",
+ ANTHROPIC_MODEL: "deepseek-chat",
+ },
+ config: decoded({ configDir: "/tmp/omb-endpoint-fixture", requireApiKey: true, endpointModels: ["deepseek-chat", "deepseek-reasoner"] }),
+ });
+ try {
+ expect(instance.models).toEqual({
+ default: "deepseek-chat",
+ options: [{ id: "deepseek-chat", label: "deepseek-chat" }, { id: "deepseek-reasoner", label: "deepseek-reasoner" }],
+ });
+ } finally {
+ await instance.dispose();
+ }
+ });
+
+ it("keeps hosted model assignment and endpoint models apart", () => {
+ expect(() => decoded({ managed: true, endpointModels: ["deepseek-chat"] })).toThrow(/Invalid Claude endpoint models/);
+ expect(() => decoded({ managedModels: ["claude-sonnet-5"], endpointModels: ["deepseek-chat"] })).toThrow(/Invalid hosted Claude models/);
+ expect(() => decoded({ endpointModels: [] })).toThrow(/Invalid Claude endpoint models/);
+ expect(() => decoded({ endpointModels: ["has space"] })).toThrow(/Invalid Claude endpoint models/);
+ expect(decoded({ endpointModels: ["deepseek-chat[1m]"] }).endpointModels).toEqual(["deepseek-chat[1m]"]);
+ });
+});
\ No newline at end of file
diff --git a/server/claude-endpoints.ts b/server/claude-endpoints.ts
new file mode 100644
index 0000000000..08b2d82a7e
--- /dev/null
+++ b/server/claude-endpoints.ts
@@ -0,0 +1,186 @@
+// A Claude endpoint the person configures: its own base URL, token and models, in its own instance,
+// so the Claude Code on this computer keeps its own sign-in. The token lives in the instance
+// environment like every other provider key, and the entry is never read by ~/.claude.
+import { randomUUID } from "node:crypto";
+import { join } from "node:path";
+import { z } from "zod";
+
+import { assertSeparateClaudeAccount } from "./claude-accounts.ts";
+import { DATA_DIR, persistableInstanceConfigs, type AppConfig } from "./config.ts";
+import type { InstanceConfig, InstanceConfigMap } from "./contracts.ts";
+import { CLAUDE_MODEL_ID } from "./drivers/claude-model-extras.ts";
+
+const displayName = z.string().trim().min(1).max(80).refine((value) => !/\p{Cc}/u.test(value), "Name cannot contain control characters");
+const model = z.string().trim().max(160).regex(CLAUDE_MODEL_ID, "Use the model id the endpoint serves.");
+const optionalModel = z.union([model, z.literal("")]);
+const token = z.string().trim().min(1).max(4096).refine((value) => !/[\p{Cc}\p{Cf}]/u.test(value), "Token cannot contain control characters");
+const baseUrl = z.string().trim().max(2048).refine((value) => endpointUrl(value) !== null, "Enter an http(s) base URL.");
+
+/** A normalized endpoint address: http(s), no credentials, no trailing slash; null when unusable. */
+function endpointUrl(value: string): string | null {
+ try {
+ const url = new URL(value);
+ if (url.protocol !== "http:" && url.protocol !== "https:") return null;
+ if (url.username || url.password) return null;
+ return value.replace(/\/+$/u, "");
+ } catch {
+ return null;
+ }
+}
+
+export const claudeEndpointSchema = z.object({
+ displayName,
+ baseUrl,
+ token,
+ model,
+ opusModel: optionalModel.optional(),
+ sonnetModel: optionalModel.optional(),
+ haikuModel: optionalModel.optional(),
+ smallFastModel: optionalModel.optional(),
+}).strict();
+
+export const claudeEndpointUpdateSchema = z.object({
+ displayName: displayName.optional(),
+ /** An empty token keeps the saved one. */
+ token: token.optional(),
+ baseUrl: baseUrl.optional(),
+ model: model.optional(),
+ opusModel: optionalModel.optional(),
+ sonnetModel: optionalModel.optional(),
+ haikuModel: optionalModel.optional(),
+ smallFastModel: optionalModel.optional(),
+}).strict().refine((value) => Object.keys(value).length > 0, "No settings supplied");
+
+type EndpointFields = z.infer<typeof claudeEndpointUpdateSchema>;
+
+const TIERS = [
+ ["opusModel", "ANTHROPIC_DEFAULT_OPUS_MODEL"],
+ ["sonnetModel", "ANTHROPIC_DEFAULT_SONNET_MODEL"],
+ ["haikuModel", "ANTHROPIC_DEFAULT_HAIKU_MODEL"],
+ ["smallFastModel", "ANTHROPIC_SMALL_FAST_MODEL"],
+] as const;
+
+function rawConfig(entry: InstanceConfig): Record<string, unknown> {
+ return entry.config && typeof entry.config === "object" && !Array.isArray(entry.config)
+ ? entry.config as Record<string, unknown> : {};
+}
+
+/** A Claude instance the person pointed at another host, rather than a named Claude account. */
+export function isClaudeEndpoint(entry: InstanceConfig | undefined): boolean {
+ return entry?.driver === "claudeAgent" && Array.isArray(rawConfig(entry).endpointModels);
+}
+
+export interface ClaudeEndpointInfo {
+ baseUrl: string;
+ models: string[];
+ tokenSaved: boolean;
+ opusModel: string;
+ sonnetModel: string;
+ haikuModel: string;
+ smallFastModel: string;
+}
+
+/** What the settings UI may know about an endpoint: where it points and which models, never the token. */
+export function claudeEndpointInfo(entry: InstanceConfig): ClaudeEndpointInfo {
+ const config = rawConfig(entry);
+ const environment = entry.environment ?? {};
+ return {
+ baseUrl: environment.ANTHROPIC_BASE_URL ?? "",
+ models: Array.isArray(config.endpointModels) ? [...config.endpointModels] : [],
+ tokenSaved: Boolean(environment.ANTHROPIC_AUTH_TOKEN || environment.ANTHROPIC_API_KEY),
+ opusModel: environment.ANTHROPIC_DEFAULT_OPUS_MODEL ?? "",
+ sonnetModel: environment.ANTHROPIC_DEFAULT_SONNET_MODEL ?? "",
+ haikuModel: environment.ANTHROPIC_DEFAULT_HAIKU_MODEL ?? "",
+ smallFastModel: environment.ANTHROPIC_SMALL_FAST_MODEL ?? "",
+ };
+}
+
+/** Adds each endpoint's address and models to the engine list; the token stays on the server. */
+export function withClaudeEndpointInfo(described: unknown, configs: InstanceConfigMap): unknown {
+ if (!Array.isArray(described)) return described;
+ return described.map((instance: { instanceId?: string }) => {
+ const entry = instance.instanceId ? configs[instance.instanceId] : undefined;
+ return entry && isClaudeEndpoint(entry)
+ ? { ...instance, url: claudeEndpointInfo(entry).baseUrl, claudeEndpoint: claudeEndpointInfo(entry) }
+ : instance;
+ });
+}
+
+function endpointEnvironment(url: string, secret: string, fields: EndpointFields): Record<string, string> {
+ const address = endpointUrl(url);
+ if (!address) throw Object.assign(new Error("Enter an http(s) base URL."), { status: 400 });
+ const environment: Record<string, string> = {
+ ANTHROPIC_BASE_URL: address,
+ ANTHROPIC_AUTH_TOKEN: secret,
+ // Claude Code's own auth probe and a turn both need a key they recognize; the endpoint's token is that key.
+ ANTHROPIC_API_KEY: secret,
+ ANTHROPIC_MODEL: (fields.model ?? "").trim(),
+ };
+ for (const [field, key] of TIERS) {
+ const value = fields[field]?.trim();
+ if (value) environment[key] = value;
+ }
+ return environment;
+}
+
+function endpointModels(fields: EndpointFields): string[] {
+ const tiers = TIERS.map(([field]) => fields[field]?.trim() ?? "").filter(Boolean);
+ return [...new Set([(fields.model ?? "").trim(), ...tiers].filter(Boolean))];
+}
+
+/** The installed binary, not another account's environment: an endpoint has no login of its own. */
+function inheritedCli(instances: InstanceConfigMap): string | undefined {
+ const existing = Object.values(instances).find((entry) => entry.driver === "claudeAgent" && !isClaudeEndpoint(entry));
+ const cli = existing ? rawConfig(existing).cli : undefined;
+ return typeof cli === "string" && cli ? cli : undefined;
+}
+
+export function newClaudeEndpoint(cfg: AppConfig, body: z.infer<typeof claudeEndpointSchema>) {
+ const instances = persistableInstanceConfigs(cfg);
+ const instanceId = `claude-${randomUUID()}`;
+ const cli = inheritedCli(instances);
+ const entry: InstanceConfig = {
+ driver: "claudeAgent",
+ displayName: body.displayName,
+ // Its own credential: the sign-in state of this Claude instance must not gate it.
+ access: "custom",
+ config: {
+ ...(cli ? { cli } : {}),
+ configDir: join(DATA_DIR, "providers", instanceId),
+ requireApiKey: true,
+ endpointModels: endpointModels(body),
+ },
+ environment: endpointEnvironment(body.baseUrl, body.token, body),
+ };
+ assertSeparateClaudeAccount(instances, instanceId, entry);
+ instances[instanceId] = entry;
+ return { instanceId, instances };
+}
+
+/** Changes the endpoint in place; the token is replaced only when one is given. */
+export function updateClaudeEndpoint(cfg: AppConfig, instanceId: string, body: EndpointFields) {
+ const instances = persistableInstanceConfigs(cfg);
+ const entry = instances[instanceId];
+ if (!entry) throw Object.assign(new Error("unknown instance"), { status: 404 });
+ if (!isClaudeEndpoint(entry)) throw Object.assign(new Error("This Claude instance is not a custom endpoint."), { status: 400 });
+ const saved = claudeEndpointInfo(entry);
+ if (!saved.baseUrl || !saved.models.length) throw Object.assign(new Error("This endpoint is missing its address or model. Remove it and add it again."), { status: 409 });
+ const fields: EndpointFields = {
+ baseUrl: body.baseUrl ?? saved.baseUrl,
+ model: body.model ?? saved.models[0],
+ };
+ if (body.displayName !== undefined) fields.displayName = body.displayName;
+ for (const [field, key] of TIERS) {
+ const value = body[field] !== undefined ? body[field] : entry.environment?.[key];
+ if (value !== undefined) fields[field] = value;
+ }
+ const secret = body.token ?? entry.environment?.ANTHROPIC_AUTH_TOKEN ?? entry.environment?.ANTHROPIC_API_KEY;
+ if (!secret) throw Object.assign(new Error("Enter the endpoint's token."), { status: 400 });
+ instances[instanceId] = {
+ ...entry,
+ ...(fields.displayName ? { displayName: fields.displayName } : {}),
+ environment: endpointEnvironment(fields.baseUrl!, secret, fields),
+ config: { ...rawConfig(entry), endpointModels: endpointModels(fields) },
+ };
+ return { instances };
+}
\ No newline at end of file
diff --git a/server/default-model-selection.test.ts b/server/default-model-selection.test.ts
index 89c9ef724d..82478a03e3 100644
--- a/server/default-model-selection.test.ts
+++ b/server/default-model-selection.test.ts
@@ -29,6 +29,14 @@ describe("new bot default model selection", () => {
const preferred = { instanceId: "mistral", model: "selected-model" };
expect(selectDefaultModelSelection([instance], preferred)).toEqual(preferred);
});
+ it("starts a new bot on the person's own plan, not a custom endpoint on the same driver", () => {
+ const endpoint = { ...claude, instanceId: "claude-endpoint", access: "custom" as const,
+ models: { default: "deepseek-chat", options: [{ id: "deepseek-chat", label: "deepseek-chat" }] } };
+ // Listed first, so only the rank keeps the plan ahead of it.
+ expect(selectDefaultModelSelection([endpoint, claude])).toEqual({ instanceId: "claude", model: "claude-default" });
+ // Alone it is still the engine a new bot starts on.
+ expect(selectDefaultModelSelection([endpoint])).toEqual({ instanceId: "claude-endpoint", model: "deepseek-chat" });
+ });
it("keeps a saved custom endpoint even when its account sign-in is false", () => {
const instance = { ...codex, access: "custom" as const, snapshot: { state: "available", authenticated: false } satisfies ProviderSnapshot };
const preferred = { instanceId: "codex", model: "selected-model" };
diff --git a/server/drivers/claude-model-extras.ts b/server/drivers/claude-model-extras.ts
index 02e5891790..97bebef6d4 100644
--- a/server/drivers/claude-model-extras.ts
+++ b/server/drivers/claude-model-extras.ts
@@ -1,5 +1,5 @@
// Claude Code's `[1m]` suffix selects a model's 1M-token context.
-const CLAUDE_MODEL_ID = /^[a-z0-9][a-z0-9._:/-]*(?:\[1m\])?$/i;
+export const CLAUDE_MODEL_ID = /^[a-z0-9][a-z0-9._:/-]*(?:\[1m\])?$/i;
const OFFICIAL_CLAUDE_ID = /^claude-[a-z0-9.-]+$/;
const official = (id: string) => OFFICIAL_CLAUDE_ID.test(id.replace(/\[1m\]$/i, ""));
diff --git a/server/drivers/claude.ts b/server/drivers/claude.ts
index 4443c71ccd..a21ae01f9f 100644
--- a/server/drivers/claude.ts
+++ b/server/drivers/claude.ts
@@ -16,7 +16,7 @@ import { projectMcpServers } from "./claude-project-mcp.ts";
import { botSettingsFor, withBotSettings } from "./claude-bot-settings.ts";
import { claudeBilling, claudeCallUsage } from "./claude-billing.ts";
import { claudeAuthFailure, claudeAuthRecovery } from "./claude-auth-recovery.ts";
-import { claudeModelExtras } from "./claude-model-extras.ts";
+import { CLAUDE_MODEL_ID, claudeModelExtras } from "./claude-model-extras.ts";
import { claudeToolSearchSetting } from "./claude-tool-search.ts";
import { classifyResumeFailure, mayReplay, rebuiltSessionNotice, recoveryPromptFor } from "../resume-recovery.ts";
import { ClaudeLoginController } from "./claude-login-auth.ts";
@@ -265,6 +265,8 @@ export interface ClaudeConfig {
configDir?: string;
managed?: boolean;
managedModels?: string[];
+ /** A custom endpoint's own models: the whole catalog, first one the default. No Claude model is offered. */
+ endpointModels?: string[];
permissionMode: "acceptEdits" | "auto" | "bypassPermissions";
tools?: string[];
disallowedTools?: string[];
@@ -297,6 +299,12 @@ async function resolveClaudeTurnModel(
return resolveInjectId(model, await probeLocalInjects(env)) ?? model;
}
+/** A custom endpoint serves only its own models: a saved model it does not list runs on its main one. */
+function endpointTurnModel(model: string | null | undefined, endpointModels: string[] | undefined): string | null | undefined {
+ if (!endpointModels) return model;
+ return model && endpointModels.includes(model) ? model : endpointModels[0];
+}
+
/** Extra ids from ~/.claude/settings.json's extraModels. Its `model` is Claude Code's last-used
* slug, not a catalog entry. */
export function readClaudeModelCatalog(env: Record<string, string | undefined> = process.env) {
@@ -638,11 +646,13 @@ function decodeConfig(raw: unknown): ClaudeConfig {
const configDir = typeof o.configDir === "string" ? o.configDir.trim() : undefined;
if (configDir) resolveClaudeConfigDir(configDir);
if (o.managedModels !== undefined && (o.managed !== true || !Array.isArray(o.managedModels) || !o.managedModels.length || o.managedModels.some(model => typeof model !== "string" || !/^[A-Za-z0-9][A-Za-z0-9._-]{0,159}$/.test(model)))) throw new Error("Invalid hosted Claude models.");
+ if (o.endpointModels !== undefined && ((o.managed === true || o.managedModels !== undefined) || !Array.isArray(o.endpointModels) || !o.endpointModels.length || o.endpointModels.some(model => typeof model !== "string" || !CLAUDE_MODEL_ID.test(model)))) throw new Error("Invalid Claude endpoint models.");
return {
cli: typeof o.cli === "string" ? o.cli : "claude",
...(configDir ? { configDir } : {}),
...(o.managed === true ? { managed: true } : {}),
...(o.managedModels ? { managedModels: o.managedModels as string[] } : {}),
+ ...(o.endpointModels ? { endpointModels: o.endpointModels as string[] } : {}),
permissionMode: (mode as ClaudeConfig["permissionMode"]) ?? "acceptEdits",
...(tools !== undefined ? { tools } : {}),
...(disallowedTools !== undefined ? { disallowedTools } : {}),
@@ -816,10 +826,12 @@ export const ClaudeDriver: ProviderDriver<ClaudeConfig> = {
if (inheritsUserConfig(catalogEnv)) {
console.error(`claude (${instanceId}): OMB_CLAUDE_INHERIT_USER_CONFIG=1 — bots inherit this machine's Claude Code MCP servers, skills, hooks and CLAUDE.md on every turn; remove it unless a bot needs a user-scope server`);
}
- let models = config.managedModels ? { default: config.managedModels[0], options: config.managedModels.map(id => ({ id, label: id })) } : STATIC_CLAUDE_MODELS;
+ let models = config.managedModels ? { default: config.managedModels[0], options: config.managedModels.map(id => ({ id, label: id })) }
+ : config.endpointModels ? { default: config.endpointModels[0], options: config.endpointModels.map(id => ({ id, label: id })) }
+ : STATIC_CLAUDE_MODELS;
const orgBlocks = createOrgModelBlocks(() => engineHomes.everyHome(catalogEnv), (blocked) => { models = withOrgBlocks(models, blocked); });
const refreshModels = async () => {
- if (config.managed) return;
+ if (config.managed || config.endpointModels) return;
try {
const resolved = await mergeLocalInject(readClaudeModelCatalog(catalogEnv), catalogEnv);
if (resolved.options.length) models = resolved; else unconfirmedModelCatalog(models);
@@ -827,7 +839,7 @@ export const ClaudeDriver: ProviderDriver<ClaudeConfig> = {
} catch { unconfirmedModelCatalog(models); }
try { writeStartupModelCache(instanceId, models); } catch {}
};
- const startupModelRefresh = config.managed ? null : (await openStartupModelCatalog({
+ const startupModelRefresh = config.managed || config.endpointModels ? null : (await openStartupModelCatalog({
instanceId,
use: (catalog) => { models = catalog; },
current: () => models,
@@ -1080,7 +1092,7 @@ export const ClaudeDriver: ProviderDriver<ClaudeConfig> = {
if (cliVersionChecked && claudeCliSupports(cliVersion, "--system-prompt-snapshot")) {
args.push("--system-prompt-snapshot", "off");
}
- const turnModel = config.managed ? turn.model : await resolveClaudeTurnModel(turn.model, turnEnvironment);
+ const turnModel = config.managed ? turn.model : await resolveClaudeTurnModel(endpointTurnModel(turn.model, config.endpointModels), turnEnvironment);
const injected = config.managed ? { model: turnModel ?? null, injected: false } : applyClaudeInject({ ...turnEnvironment }, turnModel);
if (injected.model) args.push("--model", injected.model);
if (turn.effort) args.push("--effort", turn.effort);
@@ -1964,7 +1976,7 @@ export const ClaudeDriver: ProviderDriver<ClaudeConfig> = {
reject(new Error(NO_ANTHROPIC_KEY));
return;
}
- const model = named ?? config.managedModels?.[0] ?? "claude-haiku-5-5";
+ const model = named ?? config.managedModels?.[0] ?? config.endpointModels?.[0] ?? "claude-haiku-5-5";
const env = environment(model);
const args = backgroundCallArgs({ model, outputFormat: onUsage ? "json" : "text", supports: (flag) => cliVersion !== null && claudeCliSupports(cliVersion, flag), isolated: !inheritsUserConfig(env) });
const { child, removeCwd } = spawnBackgroundCall(config.cli, args, env);
diff --git a/server/model-providers-docs.test.ts b/server/model-providers-docs.test.ts
index b8efc61031..6e98f241a4 100644
--- a/server/model-providers-docs.test.ts
+++ b/server/model-providers-docs.test.ts
@@ -5,7 +5,8 @@ import { dirname, join } from "node:path";
import { fileURLToPath } from "node:url";
import { afterEach, describe, expect, it } from "vitest";
-import { OPENCODE_PROVIDER_ENV, PROVIDER_CREDENTIAL_ENV, WORKSPACE_CREDENTIAL_ENV, stripWorkspaceCredentialEnv } from "./config.ts";
+import { DATA_DIR, OPENCODE_PROVIDER_ENV, PROVIDER_CREDENTIAL_ENV, WORKSPACE_CREDENTIAL_ENV, stripWorkspaceCredentialEnv } from "./config.ts";
+import { newClaudeEndpoint } from "./claude-endpoints.ts";
import { discoverOpenCodeModels, ensureOpenCodeInjectModel, resetOpenCodeModelCache } from "./drivers/acp/opencode-go.ts";
import { readClaudeAuthSettings, readClaudeModelCatalog } from "./drivers/claude.ts";
import { OPENROUTER_FAILURES, freeLabel } from "./drivers/openrouter-free.ts";
@@ -99,6 +100,27 @@ describe("Claude Code section", () => {
expect(readClaudeAuthSettings({ HOME: home }, { ANTHROPIC_API_KEY: "connections-fake-key" })).toEqual({});
expect(section("### Claude Code")).toContain("It applies only while no Anthropic API key is saved in Connections.");
});
+
+ it("runs a bot on a custom endpoint without this computer's Claude settings", () => {
+ const home = settingsHome(providerEnv);
+ const created = newClaudeEndpoint({ instances: {} } as never, {
+ displayName: "DeepSeek", baseUrl: "https://api.deepseek.com/anthropic", token: "sk-fake", model: "deepseek-chat",
+ });
+ const entry = created.instances[created.instanceId] as {
+ config: { configDir: string; endpointModels: string[] };
+ environment: Record<string, string>;
+ };
+ expect(entry.config.configDir).toBe(join(DATA_DIR, "providers", created.instanceId));
+ expect(readClaudeAuthSettings({ HOME: home }, entry.environment)).toEqual({});
+ expect(entry.environment.ANTHROPIC_MODEL).toBe("deepseek-chat");
+ expect(entry.config.endpointModels).toEqual(["deepseek-chat"]);
+
+ const text = section("### Claude Code");
+ expect(text).toContain("add a **custom endpoint** in Settings → Engines, in the Claude card");
+ expect(text).toContain("It never reads or writes this computer's `~/.claude`, and the Claude Code on this computer keeps its own sign-in.");
+ expect(text).toContain("Its bots run the model the endpoint serves. A bot that still has a Claude model selected runs the endpoint's main model instead.");
+ expect(text).toContain("The token is saved in OpenMausBot's own `config.json`, never sent to Anthropic. Removing an endpoint removes only that entry.");
+ });
});
describe("OpenCode 2.x section", () => {
diff --git a/server/routes/instances.ts b/server/routes/instances.ts
index 8dc54c2038..159da52600 100644
--- a/server/routes/instances.ts
+++ b/server/routes/instances.ts
@@ -7,6 +7,13 @@ import {
instanceSettingsSchema,
newClaudeAccount,
} from "../claude-accounts.ts";
+import {
+ claudeEndpointSchema,
+ claudeEndpointUpdateSchema,
+ newClaudeEndpoint,
+ updateClaudeEndpoint,
+ withClaudeEndpointInfo,
+} from "../claude-endpoints.ts";
import { updateClaudeCli } from "../claude-update.ts";
import { persistableInstanceConfigs, saveConfig, withInstanceCli, type AppConfig } from "../config.ts";
import { addEndpoint, addEndpointSchema, isAddedEndpoint, withEndpointUrls } from "../openai-compat-endpoints.ts";
@@ -53,7 +60,8 @@ export function createInstanceRoutes(deps: InstanceRouteDeps): RouteHandler {
persistProviderInstance, configStatus, broadcast, testCliBinary, cliProbeEnvironment, threadBusy,
botForThread, activeGroupTurnForBot,
} = deps;
- const describeInstances = async () => hostedModels ? deps.describeInstances() : withEndpointUrls(await deps.describeInstances(), cfg.instances ?? {});
+ const describeInstances = async () => hostedModels ? deps.describeInstances()
+ : withEndpointUrls(withClaudeEndpointInfo(await deps.describeInstances(), cfg.instances ?? {}), cfg.instances ?? {});
/** Bots, their backups and threads, the new-bot default, or a turn running on it: a provider in use can't go away. */
const providerInUse = (instanceId: string): boolean => cfg.defaultModelSelection?.instanceId === instanceId || store.bots.some((bot) =>
bot.modelSelection.instanceId === instanceId || bot.fallback?.some(candidate => candidate.instanceId === instanceId) || store.tasks(bot.id).some((task) => task.modelSelection?.instanceId === instanceId)) ||
@@ -158,6 +166,48 @@ export function createInstanceRoutes(deps: InstanceRouteDeps): RouteHandler {
} finally { providerConfigBusy.set(false); }
}
+ if (method === "POST" && path === "/api/instances/claude-endpoint") {
+ if (!String(req.headers["content-type"] ?? "").toLowerCase().startsWith("application/json")) {
+ return json(res, 415, { error: "content-type must be application/json" });
+ }
+ const parsed = claudeEndpointSchema.safeParse(await readBody(req, 16384));
+ if (!parsed.success) return json(res, 400, { error: "Enter a name, an http(s) base URL, a token and the model the endpoint serves." });
+ if (providerConfigBusy.get()) return json(res, 409, { error: "provider settings are already being updated" });
+ providerConfigBusy.set(true);
+ try {
+ const { instanceId, instances } = newClaudeEndpoint(cfg, parsed.data);
+ await persistProviderInstance(instanceId, instances);
+ return json(res, 201, { instanceId, instances: await describeInstances() });
+ } catch (error) {
+ const status = (error as { status?: unknown }).status;
+ return json(res, typeof status === "number" ? status : 400, { error: error instanceof Error ? error.message : String(error) });
+ } finally { providerConfigBusy.set(false); }
+ }
+
+ const endpointPatch = /^\/api\/instances\/([\w.-]+)\/claude-endpoint$/.exec(path);
+ if (method === "PATCH" && endpointPatch) {
+ if (!String(req.headers["content-type"] ?? "").toLowerCase().startsWith("application/json")) {
+ return json(res, 415, { error: "content-type must be application/json" });
+ }
+ const instanceId = endpointPatch[1];
+ const parsed = claudeEndpointUpdateSchema.safeParse(await readBody(req, 16384));
+ if (!parsed.success) return json(res, 400, { error: "Check the address, token and model ids." });
+ if (providerConfigBusy.get()) return json(res, 409, { error: "provider settings are already being updated" });
+ providerConfigBusy.set(true);
+ providerInstancesChanging.add(instanceId);
+ try {
+ const { instances } = updateClaudeEndpoint(cfg, instanceId, parsed.data);
+ await persistProviderInstance(instanceId, instances);
+ return json(res, 200, { instances: await describeInstances() });
+ } catch (error) {
+ const status = (error as { status?: unknown }).status;
+ return json(res, typeof status === "number" ? status : 400, { error: error instanceof Error ? error.message : String(error) });
+ } finally {
+ providerInstancesChanging.delete(instanceId);
+ providerConfigBusy.set(false);
+ }
+ }
+
if (method === "POST" && path === "/api/instances/claude-accounts") {
if (!String(req.headers["content-type"] ?? "").toLowerCase().startsWith("application/json")) {
return json(res, 415, { error: "content-type must be application/json" });
diff --git a/shared/ai-ranking.ts b/shared/ai-ranking.ts
index b91e57451e..7764703ffc 100644
--- a/shared/ai-ranking.ts
+++ b/shared/ai-ranking.ts
@@ -4,6 +4,8 @@
export interface RankableAi {
driverKind: string;
+ /** A custom endpoint someone configured is a bring-your-own engine, not the provider's own plan. */
+ access?: string;
snapshot?: { freeFallback?: boolean };
}
@@ -27,7 +29,10 @@ export function freeFallback(instance: RankableAi): boolean {
}
function tier(instance: RankableAi): number {
- return freeFallback(instance) ? FREE_FALLBACK : TIERS[instance.driverKind] ?? OTHER;
+ if (freeFallback(instance)) return FREE_FALLBACK;
+ // Same driver, but not the provider's own plan: a new bot still starts on the plan someone already has.
+ if (instance.access === "custom") return OTHER;
+ return TIERS[instance.driverKind] ?? OTHER;
}
/** A new list, best first; AIs of one kind keep the order they came in. */
diff --git a/src/components/ClaudeEndpoints.test.ts b/src/components/ClaudeEndpoints.test.ts
new file mode 100644
index 0000000000..74a1e07d4e
--- /dev/null
+++ b/src/components/ClaudeEndpoints.test.ts
@@ -0,0 +1,69 @@
+import { createElement } from "react";
+import { renderToStaticMarkup } from "react-dom/server";
+import { afterEach, describe, expect, it, vi } from "vitest";
+
+import * as store from "@/state/store";
+import { ClaudeEndpoints } from "./ClaudeEndpoints";
+
+const endpoint = (extra: Record<string, unknown> = {}) => ({
+ instanceId: "claude-endpoint-fixture",
+ driverKind: "claudeAgent",
+ displayName: "DeepSeek",
+ access: "custom",
+ snapshot: { state: "available" },
+ models: { default: "deepseek-chat", options: [] },
+ claudeEndpoint: {
+ baseUrl: "https://api.deepseek.test/anthropic",
+ models: ["deepseek-chat", "deepseek-reasoner"],
+ tokenSaved: true, opusModel: "deepseek-reasoner", sonnetModel: "", haikuModel: "", smallFastModel: "",
+ },
+ ...extra,
+}) as unknown as store.InstanceInfo;
+
+function render(instances: store.InstanceInfo[]) {
+ vi.stubGlobal("window", {});
+ vi.spyOn(store, "useStore").mockReturnValue({
+ state: { ...store.initialState, instances, bots: [] },
+ dispatch: vi.fn(),
+ flushBotPatches: vi.fn(),
+ refreshInstances: vi.fn(),
+ refreshModels: vi.fn(),
+ } as unknown as ReturnType<typeof store.useStore>);
+ return renderToStaticMarkup(createElement(ClaudeEndpoints));
+}
+
+afterEach(() => { vi.unstubAllGlobals(); vi.restoreAllMocks(); });
+
+describe("Claude custom endpoints settings", () => {
+ it("offers the section with nothing configured yet", () => {
+ const html = render([]);
+ expect(html).toContain("Custom endpoint");
+ expect(html).toContain("Run this account&#x27;s bots on DeepSeek, GLM or another host");
+ expect(html).toContain("No custom endpoints yet.");
+ expect(html).toContain("Add endpoint");
+ });
+
+ it("lists each endpoint's address and models, and never its token", () => {
+ const html = render([endpoint()]);
+ expect(html).toContain("DeepSeek");
+ expect(html).toContain("https://api.deepseek.test/anthropic");
+ expect(html).toContain("deepseek-chat");
+ expect(html).toContain("deepseek-reasoner");
+ expect(html).toContain("Edit");
+ expect(html).toContain("Remove DeepSeek");
+ // The API answer carries only whether a token is saved, so no field holds one.
+ expect(html).not.toMatch(/tokenSaved|sk-/u);
+ });
+
+ it("waits for bots to move off an endpoint before offering its removal", () => {
+ const bot = { id: "bot-1", modelSelection: { instanceId: "claude-endpoint-fixture", model: "deepseek-chat" } };
+ vi.stubGlobal("window", {});
+ vi.spyOn(store, "useStore").mockReturnValue({
+ state: { ...store.initialState, instances: [endpoint()], bots: [bot] },
+ dispatch: vi.fn(), flushBotPatches: vi.fn(), refreshInstances: vi.fn(), refreshModels: vi.fn(),
+ } as unknown as ReturnType<typeof store.useStore>);
+ const html = renderToStaticMarkup(createElement(ClaudeEndpoints));
+ expect(html).toContain("1 bot(s) use this account");
+ expect(html).toContain("disabled");
+ });
+});
\ No newline at end of file
diff --git a/src/components/ClaudeEndpoints.tsx b/src/components/ClaudeEndpoints.tsx
new file mode 100644
index 0000000000..99d9e87fc8
--- /dev/null
+++ b/src/components/ClaudeEndpoints.tsx
@@ -0,0 +1,188 @@
+import { useState } from "react";
+import { Loader2, Plus, Trash2 } from "lucide-react";
+
+import { api, useStore, type InstanceInfo } from "@/state/store";
+import { t } from "@/lib/i18n";
+import { cn } from "@/lib/cn";
+import { ConfirmDialog } from "./ConfirmDialog";
+import { KEY_FIELD } from "./keys/KeyRow";
+
+const INPUT = cn(KEY_FIELD, "font-sans");
+const MAPPINGS = [
+ ["opusModel", "claudeEndpoints.opus"],
+ ["sonnetModel", "claudeEndpoints.sonnet"],
+ ["haikuModel", "claudeEndpoints.haiku"],
+] as const;
+
+interface Draft {
+ name: string;
+ url: string;
+ token: string;
+ model: string;
+ opusModel: string;
+ sonnetModel: string;
+ haikuModel: string;
+}
+
+const EMPTY: Draft = { name: "", url: "", token: "", model: "", opusModel: "", sonnetModel: "", haikuModel: "" };
+
+const draftOf = (instance: InstanceInfo): Draft => ({
+ name: instance.displayName,
+ url: instance.claudeEndpoint?.baseUrl ?? "",
+ token: "",
+ model: instance.claudeEndpoint?.models[0] ?? "",
+ opusModel: instance.claudeEndpoint?.opusModel ?? "",
+ sonnetModel: instance.claudeEndpoint?.sonnetModel ?? "",
+ haikuModel: instance.claudeEndpoint?.haikuModel ?? "",
+});
+
+function EndpointForm({ instance, onDone }: { instance?: InstanceInfo; onDone: () => void }) {
+ const { dispatch } = useStore();
+ const [draft, setDraft] = useState<Draft>(instance ? draftOf(instance) : EMPTY);
+ const [saving, setSaving] = useState(false);
+ const [error, setError] = useState<string | null>(null);
+ const field = (key: keyof Draft) => ({
+ value: draft[key],
+ onChange: (event: { target: { value: string } }) => setDraft((current) => ({ ...current, [key]: event.target.value })),
+ spellCheck: false,
+ disabled: saving,
+ });
+ const ready = Boolean(draft.name.trim() && draft.url.trim() && draft.model.trim() && (instance || draft.token.trim()));
+
+ const save = async () => {
+ if (saving || !ready) return;
+ setSaving(true);
+ setError(null);
+ const body = {
+ displayName: draft.name.trim(),
+ baseUrl: draft.url.trim(),
+ model: draft.model.trim(),
+ opusModel: draft.opusModel.trim(),
+ sonnetModel: draft.sonnetModel.trim(),
+ haikuModel: draft.haikuModel.trim(),
+ ...(draft.token.trim() ? { token: draft.token.trim() } : {}),
+ };
+ try {
+ const result = instance
+ ? await api(`/api/instances/${encodeURIComponent(instance.instanceId)}/claude-endpoint`, { method: "PATCH", body: JSON.stringify(body) })
+ : await api("/api/instances/claude-endpoint", { method: "POST", body: JSON.stringify(body) });
+ if (Array.isArray(result.instances)) dispatch({ type: "instances", instances: result.instances });
+ onDone();
+ } catch (cause) {
+ setError(cause instanceof Error && cause.message ? cause.message : t("claudeEndpoints.failed"));
+ } finally {
+ setSaving(false);
+ }
+ };
+
+ return (
+ <form data-claude-endpoint-form={instance?.instanceId ?? "new"} className="flex flex-col gap-2 rounded-xl border border-hairline/50 bg-inset p-3"
+ onSubmit={(event) => { event.preventDefault(); void save(); }}>
+ <label className="flex flex-col gap-1 text-[12px] font-medium text-ink">
+ {t("claudeEndpoints.name")}
+ <input {...field("name")} maxLength={80} autoFocus aria-label={t("claudeEndpoints.name")} className={INPUT} />
+ </label>
+ <label className="flex flex-col gap-1 text-[12px] font-medium text-ink">
+ {t("claudeEndpoints.baseUrl")}
+ <input {...field("url")} type="url" maxLength={2048} placeholder="https://api.example.com/anthropic" aria-label={t("claudeEndpoints.baseUrl")} className={cn(INPUT, "font-mono")} />
+ </label>
+ <label className="flex flex-col gap-1 text-[12px] font-medium text-ink">
+ {t("claudeEndpoints.token")}
+ <input {...field("token")} type="password" maxLength={4096} autoComplete="off" aria-label={t("claudeEndpoints.token")} className={cn(INPUT, "font-mono")}
+ placeholder={instance ? t("claudeEndpoints.tokenKeep") : ""} />
+ </label>
+ <label className="flex flex-col gap-1 text-[12px] font-medium text-ink">
+ {t("claudeEndpoints.model")}
+ <input {...field("model")} maxLength={160} placeholder="deepseek-chat" aria-label={t("claudeEndpoints.model")} className={cn(INPUT, "font-mono")} />
+ </label>
+ <p className="text-[12px] leading-4 text-ink-secondary">{t("claudeEndpoints.modelHint")}</p>
+ <details className="text-[12px] text-ink-secondary">
+ <summary className="cursor-pointer select-none hover:text-ink">{t("claudeEndpoints.mappings")}</summary>
+ <div className="mt-2 flex flex-col gap-1.5">
+ {MAPPINGS.map(([key, label]) => (
+ <input key={key} {...field(key)} maxLength={160} aria-label={t(label)} placeholder={t(label)} className={cn(INPUT, "font-mono")} />
+ ))}
+ <p className="leading-relaxed">{t("claudeEndpoints.mappingsHint")}</p>
+ </div>
+ </details>
+ {error && <p role="alert" className="text-[12px] text-danger">{error}</p>}
+ <div className="flex justify-end gap-2">
+ <button type="button" onClick={onDone} disabled={saving} className="rounded-lg px-3 py-1.5 text-[12px] text-ink-secondary hover:bg-control disabled:opacity-50">{t("common.cancel")}</button>
+ <button type="submit" disabled={saving || !ready} className="flex items-center gap-1.5 rounded-lg bg-accent px-3 py-1.5 text-[12px] font-semibold text-white hover:brightness-110 disabled:opacity-50">
+ {saving && <Loader2 size={13} className="animate-spin" />}{t("common.save")}
+ </button>
+ </div>
+ </form>
+ );
+}
+
+function EndpointRow({ instance, onEdit }: { instance: InstanceInfo; onEdit: () => void }) {
+ const { state, dispatch } = useStore();
+ const [confirming, setConfirming] = useState(false);
+ const [removing, setRemoving] = useState(false);
+ const [error, setError] = useState<string | null>(null);
+ const usedBy = state.bots.filter((bot) => bot.modelSelection.instanceId === instance.instanceId).length;
+ const endpoint = instance.claudeEndpoint;
+ const remove = async () => {
+ setConfirming(false);
+ setRemoving(true);
+ setError(null);
+ try {
+ const result = await api(`/api/instances/${encodeURIComponent(instance.instanceId)}`, { method: "DELETE" });
+ if (Array.isArray(result.instances)) dispatch({ type: "instances", instances: result.instances });
+ } catch (cause) {
+ setError(cause instanceof Error ? cause.message : String(cause));
+ } finally {
+ setRemoving(false);
+ }
+ };
+ return (
+ <li data-claude-endpoint={instance.instanceId} className="px-3 py-2.5">
+ <div className="flex min-h-9 items-center gap-3">
+ <div className="min-w-0 flex-1">
+ <div className="truncate text-[13px] font-medium text-ink" title={instance.displayName}>{instance.displayName}</div>
+ <div className="truncate font-mono text-[11px] text-ink-secondary" title={endpoint?.baseUrl}>{endpoint?.baseUrl}</div>
+ <div className="truncate text-[12px] text-ink-secondary">{endpoint?.models.join(" · ")}</div>
+ </div>
+ <button type="button" onClick={onEdit} disabled={removing} className="shrink-0 rounded-lg px-2.5 py-1.5 text-[12px] font-medium text-ink-secondary hover:bg-control hover:text-ink disabled:opacity-50">
+ {t("claudeEndpoints.edit")}
+ </button>
+ <button type="button" disabled={removing || usedBy > 0} onClick={() => setConfirming(true)}
+ title={usedBy > 0 ? t("accounts.inUse", { count: String(usedBy) }) : t("accounts.remove")}
+ aria-label={t("claudeEndpoints.remove", { name: instance.displayName })}
+ className="flex size-8 shrink-0 items-center justify-center rounded-lg text-danger hover:bg-danger/10 disabled:cursor-not-allowed disabled:opacity-50">
+ {removing ? <Loader2 size={14} className="animate-spin" /> : <Trash2 size={14} />}
+ </button>
+ </div>
+ {error && <p role="alert" className="mt-1 text-[12px] text-danger">{error}</p>}
+ <ConfirmDialog open={confirming} title={t("accounts.removeTitle", { name: instance.displayName })}
+ body={t("claudeEndpoints.removeBody")} confirmLabel={t("accounts.remove")} tone="neutral" pending={removing}
+ onCancel={() => setConfirming(false)} onConfirm={() => void remove()} />
+ </li>
+ );
+}
+
+/** Custom Claude endpoints: their own engines, so this computer's Claude Code and its sign-in stay as they are. */
+export function ClaudeEndpoints() {
+ const { state } = useStore();
+ const endpoints = state.instances.filter((instance) => instance.claudeEndpoint);
+ const [open, setOpen] = useState<string | null>(null);
+ return (
+ <div data-claude-endpoints className="mt-3 space-y-2">
+ <div className="text-[13px] leading-[18px] text-ink">{t("claudeEndpoints.title")}</div>
+ <p className="text-[12px] leading-4 text-ink-secondary">{t("claudeEndpoints.hint")}</p>
+ {endpoints.length === 0
+ ? <p className="text-[12px] leading-4 text-ink-secondary">{t("claudeEndpoints.empty")}</p>
+ : <ul className="divide-y divide-hairline/40 rounded-xl border border-hairline/50 bg-panel/40">
+ {endpoints.map((instance) => open === instance.instanceId
+ ? <li key={instance.instanceId} className="p-3"><EndpointForm instance={instance} onDone={() => setOpen(null)} /></li>
+ : <EndpointRow key={instance.instanceId} instance={instance} onEdit={() => setOpen(instance.instanceId)} />)}
+ </ul>}
+ {open === "new"
+ ? <EndpointForm onDone={() => setOpen(null)} />
+ : <button type="button" onClick={() => setOpen("new")} className="flex min-h-8 w-fit items-center gap-1.5 rounded-lg px-2 py-1.5 text-[13px] font-medium text-ink-secondary outline-none hover:bg-control hover:text-ink focus-visible:ring-2 focus-visible:ring-accent">
+ <Plus size={14} />{t("claudeEndpoints.add")}
+ </button>}
+ </div>
+ );
+}
\ No newline at end of file
diff --git a/src/components/EnginesSettings.tsx b/src/components/EnginesSettings.tsx
index 5648fcea7f..14818c73f4 100644
--- a/src/components/EnginesSettings.tsx
+++ b/src/components/EnginesSettings.tsx
@@ -10,6 +10,7 @@ import { ApiKeyEngineManage, EngineSetup, EngineUpdateNotice, EngineWarningNotic
import { AppCopyNotice } from "./EngineAppCopy";
import { forgetAppCopySwitches } from "@/state/engine-install";
import { AccountsCard, AddAccount, accountGroupOf, accountsReady, type AccountGroup } from "./EngineAccounts";
+import { ClaudeEndpoints } from "./ClaudeEndpoints";
import { DEVICE_SIGN_IN_COPY, deviceSignInProvider } from "./DeviceSignIn";
import { AntigravityFreeSpace } from "./AntigravityFreeSpace";
import { CacheKeepWarmSettings } from "./CacheKeepWarmSettings";
@@ -523,7 +524,8 @@ export function EnginesSettings({ simple = false, more }: { simple?: boolean; mo
const renderEngine = (instance: InstanceInfo, bare = false) => {
const group = groupOf(instance);
return group
- ? <AccountsCard group={group} accounts={groups.get(group)!} advanced={<EngineAdvanced instance={instance} />} bare={bare} />
+ ? <AccountsCard group={group} accounts={groups.get(group)!} bare={bare}
+ advanced={<>{group === "claude" && <ClaudeEndpoints />}<EngineAdvanced instance={instance} /></>} />
: <EngineRow instance={instance} bare={bare} />;
};
diff --git a/src/locales/en.json b/src/locales/en.json
index b29bddd68b..5b17059ffa 100644
--- a/src/locales/en.json
+++ b/src/locales/en.json
@@ -4215,6 +4215,25 @@
"accounts.claude.codePlaceholder": "Paste code",
"accounts.claude.finish": "Finish",
"accounts.claude.security": "The code goes to Claude Code once and is never saved.",
+ "claudeEndpoints.title": "Custom endpoint",
+ "claudeEndpoints.hint": "Run this account's bots on DeepSeek, GLM or another host that speaks Claude Code's API. It is its own engine, so the Claude Code on this computer and its sign-in stay as they are.",
+ "claudeEndpoints.empty": "No custom endpoints yet.",
+ "claudeEndpoints.add": "Add endpoint",
+ "claudeEndpoints.edit": "Edit",
+ "claudeEndpoints.name": "Name",
+ "claudeEndpoints.baseUrl": "Base URL",
+ "claudeEndpoints.token": "Token",
+ "claudeEndpoints.tokenKeep": "Leave empty to keep the saved token",
+ "claudeEndpoints.model": "Model",
+ "claudeEndpoints.modelHint": "The model id the endpoint serves, such as deepseek-chat. Bots on this endpoint use it unless you pick another of its models.",
+ "claudeEndpoints.mappings": "Model mappings (optional)",
+ "claudeEndpoints.mappingsHint": "Which model the endpoint uses for Opus, Sonnet and Haiku work.",
+ "claudeEndpoints.opus": "Opus model",
+ "claudeEndpoints.sonnet": "Sonnet model",
+ "claudeEndpoints.haiku": "Haiku model",
+ "claudeEndpoints.remove": "Remove {name}",
+ "claudeEndpoints.removeBody": "This removes the endpoint from app settings. The bots that used it need another model.",
+ "claudeEndpoints.failed": "Couldn't save the endpoint. Check the fields and try again.",
"engines.none": "No model provider apps detected yet.",
"engines.footer": "Set CLI points a model provider at a specific binary: a versioned build, a wrapper script, or an absolute path. Changes are saved only when the selected provider is idle. Other providers keep running.",
"engines.freeSpace.title": "Leftover files",
diff --git a/src/locales/source-hashes.json b/src/locales/source-hashes.json
index 10b63f9bf7..4b6b5cd204 100644
--- a/src/locales/source-hashes.json
+++ b/src/locales/source-hashes.json
@@ -34125,7 +34125,26 @@
"botAccess.overview.botCount.other": "fc1da572d3f0b2c7e2cdfa7f85a2c1f6b2aceb1969b9cac6ec4391422887a64b",
"botAccess.overview.noBotsForPerson": "cc4af4309f397df0ddf1e4f33040d9ef1035a14ecd1e63b38f4d929c57550556",
"botAccess.overview.allPeople": "7e3e7ca9ed866b1ad11f9e5aadc0aa053c87306eb1b321076a5e49f0a35f6e4f",
- "botAccess.overview.toastRemoved": "aa0a68dbd73099db4ae1d856ecfad7d842144ee7744e4df54a60717476bdb7e8"
+ "botAccess.overview.toastRemoved": "aa0a68dbd73099db4ae1d856ecfad7d842144ee7744e4df54a60717476bdb7e8",
+ "claudeEndpoints.title": "5fb0795eaf2ee446b929b73b8c78d7c2c15d3aa3cbaf6cc1e5df78e855450393",
+ "claudeEndpoints.hint": "85cb5bca4fd639b875402e3fdf9edb1f21d4b9ab8a64c2f8e0ac4aeea05d769f",
+ "claudeEndpoints.empty": "bf73fc943131b6a738dfc035d64f53bf2d19ac092ddaf8457cf82e9641f74d55",
+ "claudeEndpoints.add": "ad897090864f2a622971da41fc664317ad8c887f54b23b81b125ac048b1dd643",
+ "claudeEndpoints.edit": "464c4ffd019e1e9691dcf0537c797353ef2b1c1d4833d3d463e5b74ae4547344",
+ "claudeEndpoints.name": "dcd1d5223f73b3a965c07e3ff5dbee3eedcfedb806686a05b9b3868a2c3d6d50",
+ "claudeEndpoints.baseUrl": "70589413a3c9793339fcf764276727ac652fa7dfe2f15fb5671251303a52ca49",
+ "claudeEndpoints.token": "d2089be672953d1136faa84079af1b6f3967fed8932dabffba3032d30e3c0618",
+ "claudeEndpoints.tokenKeep": "9ed9a81a29067877a6745d445b0af73c94f943474ba461ab6a8b2ea92fd0b121",
+ "claudeEndpoints.model": "5e2c614c23f02239bc03c6c04fcb681950f9e72bf8fdff6be79c79841cbb10c0",
+ "claudeEndpoints.modelHint": "d9c4b5f7fe88cdbb0b21fdd08122a186287346b8a283e7b22258dc7b9695b2be",
+ "claudeEndpoints.mappings": "9ef9eba4097d66d36a5705cd4d51b7044b0e07da1829eb759c359ffcde40c7ec",
+ "claudeEndpoints.mappingsHint": "2a55beedc91b232870585095ee96868e2f878dc29b9cfcc6a78ce825c618b7ff",
+ "claudeEndpoints.opus": "c334b99f1817421f9371293c418140e85b28ec64c9992be616ea4efb8364c0a4",
+ "claudeEndpoints.sonnet": "eb6b6ff737149c08931be2fa7184c20f08eaaa281992025147ff36efbd5de0b1",
+ "claudeEndpoints.haiku": "6275ec98e4372829ff07608e3ff2c70957bf0cd823377423eba90f0e37eef94e",
+ "claudeEndpoints.remove": "e6a3c4a1250a6ad3f10faa22333e5e50a6ba78e5b28a3b26f5743d9f8c7ede93",
+ "claudeEndpoints.removeBody": "fc84f5c7a7fa50f0ba3f5da12122720a6734648e3e064307acb81b31b0ed9f8d",
+ "claudeEndpoints.failed": "15a9f1ef0847ed09b54853610591188340a5c6a95ec6173ae17ebe50932dcdfb"
},
"zh-tw": {
"whop.description": "1a07cf04ef17029448d3781415cbac16d54e66b821907a40d94e0e6349710e70",
diff --git a/src/locales/zh.json b/src/locales/zh.json
index f8d4b6cca3..cf6022098e 100644
--- a/src/locales/zh.json
+++ b/src/locales/zh.json
@@ -4125,6 +4125,25 @@
"accounts.claude.codePlaceholder": "粘贴代码",
"accounts.claude.finish": "完成",
"accounts.claude.security": "代码只会发送给 Claude Code 一次,不会被保存。",
+ "claudeEndpoints.title": "自定义端点",
+ "claudeEndpoints.hint": "让这个账户的 bot 使用 DeepSeek、GLM 或其他兼容 Claude Code 接口的服务。它是独立的引擎,本机 Claude Code 及其登录状态不受影响。",
+ "claudeEndpoints.empty": "还没有自定义端点。",
+ "claudeEndpoints.add": "添加端点",
+ "claudeEndpoints.edit": "编辑",
+ "claudeEndpoints.name": "名称",
+ "claudeEndpoints.baseUrl": "接口地址",
+ "claudeEndpoints.token": "令牌",
+ "claudeEndpoints.tokenKeep": "留空则保留已保存的令牌",
+ "claudeEndpoints.model": "模型",
+ "claudeEndpoints.modelHint": "端点提供的模型 ID,例如 deepseek-chat。这个端点上的 bot 默认使用它,也可以选择它的其他模型。",
+ "claudeEndpoints.mappings": "模型映射(可选)",
+ "claudeEndpoints.mappingsHint": "指定端点用于 Opus、Sonnet 和 Haiku 工作的模型。",
+ "claudeEndpoints.opus": "Opus 模型",
+ "claudeEndpoints.sonnet": "Sonnet 模型",
+ "claudeEndpoints.haiku": "Haiku 模型",
+ "claudeEndpoints.remove": "移除 {name}",
+ "claudeEndpoints.removeBody": "这会从应用设置中移除该端点。使用它的 bot 需要换一个模型。",
+ "claudeEndpoints.failed": "无法保存端点。请检查填写内容后重试。",
"engines.none": "尚未检测到模型提供方应用。",
"engines.footer": "「设置 CLI」可将模型提供方指向特定的可执行文件——特定版本的构建、包装脚本或绝对路径。只有在所选提供方闲置时才会保存变更,其他提供方会继续运行。",
"engines.freeSpace.title": "残留文件",
diff --git a/src/state/store.tsx b/src/state/store.tsx
index f3dfd54cf8..b15f13d0a9 100644
--- a/src/state/store.tsx
+++ b/src/state/store.tsx
@@ -504,6 +504,12 @@ export interface InstanceInfo {
cliDefault?: string;
cliCandidates?: string[];
claudeAccount?: { configDir: string; signInCommand: string; signInShell: "powershell" | "sh"; isDefault: boolean };
+ /** Where a Claude custom endpoint points and what it serves; its token stays on the server. */
+ claudeEndpoint?: {
+ baseUrl: string; models: string[]; tokenSaved: boolean;
+ opusModel: string; sonnetModel: string; haikuModel: string; smallFastModel: string;
+ };
+ url?: string;
freeUpSpace?: boolean; replyWaitMinutes?: number;
}