Skip to content

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

Address review on custom Claude endpoints

fanxing11b98ccd185ce4
diff --git a/apps/docs/content/docs/providers/model-providers.mdx b/apps/docs/content/docs/providers/model-providers.mdx
index 82087fb535..03033679c3 100644
--- a/apps/docs/content/docs/providers/model-providers.mdx
+++ b/apps/docs/content/docs/providers/model-providers.mdx
@@ -11,12 +11,12 @@ differences with OpenCode 2.x.
| Provider | OpenCode | Chat engine | Claude Code | Codex |
|---|---|---|---|---|
-| OpenRouter | Yes | Yes | Only through Claude Code's own settings | Not yet |
-| Fireworks AI | Yes | Yes | Only through Claude Code's own settings | Not yet |
-| DeepSeek | Yes | Yes | Only through Claude Code's own settings | Not yet |
+| OpenRouter | Yes | Yes | Custom endpoint, or Claude Code's own settings | Not yet |
+| Fireworks AI | Yes | Yes | Custom endpoint, or Claude Code's own settings | Not yet |
+| DeepSeek | Yes | Yes | Custom endpoint, or Claude Code's own settings | Not yet |
| Cline | Yes | Yes | No | No |
| Your own OpenAI-compatible address | Yes, in OpenCode's config file | Yes | No | Not yet |
-| Your own Anthropic-compatible address | Not tested | No | Only through Claude Code's own settings | No |
+| Your own Anthropic-compatible address | Not tested | No | Custom endpoint, or Claude Code's own settings | No |
"Chat engine" is OpenMausBot's built-in engine for OpenAI-compatible services.
In a bot's model picker it is called **OpenAI-compatible (OpenRouter / Groq)**
@@ -169,8 +169,8 @@ card:
`~/.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.
+- The token is saved in OpenMausBot's own `config.json` and sent only to the
+ base URL you enter. 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:
diff --git a/docs/verification/claude-endpoint.md b/docs/verification/claude-endpoint.md
index 0c6af9bf11..fcf42dfcfd 100644
--- a/docs/verification/claude-endpoint.md
+++ b/docs/verification/claude-endpoint.md
@@ -31,18 +31,20 @@ Claude card.
`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
+ labelled to keep the saved token. Change the model to `deepseek-reasoner`
+ 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.
+ only (here `deepseek-reasoner`), 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):
+Against the printed `url` (loopback owner trust in the fixture). Set
+`URL=<printed url>` in the same shell first:
```sh
curl -s -X POST "$URL/api/instances/claude-endpoint" \
diff --git a/server/claude-endpoints.test.ts b/server/claude-endpoints.test.ts
index ba2d8b11be..f83294a8ce 100644
--- a/server/claude-endpoints.test.ts
+++ b/server/claude-endpoints.test.ts
@@ -61,6 +61,16 @@ describe("custom Claude endpoint", () => {
expect((second.instances[instanceId] as { environment: object }).environment).toEqual(entry.environment);
});
+ it("inherits the installed binary from whichever Claude account sets one", () => {
+ const { instanceId, instances } = newClaudeEndpoint({
+ instances: {
+ claude: { driver: "claudeAgent", config: {} },
+ "claude-work": { driver: "claudeAgent", config: { cli: "/opt/claude/bin/claude" } },
+ },
+ } as never, BASE);
+ expect((instances[instanceId].config as { cli?: string }).cli).toBe("/opt/claude/bin/claude");
+ });
+
it("reports only the address and models to a client, never the token", () => {
const { instanceId, instances } = newClaudeEndpoint(cfg(), BASE);
const info = claudeEndpointInfo(instances[instanceId]);
diff --git a/server/claude-endpoints.ts b/server/claude-endpoints.ts
index 08b2d82a7e..43a7ffc7e7 100644
--- a/server/claude-endpoints.ts
+++ b/server/claude-endpoints.ts
@@ -130,9 +130,12 @@ function endpointModels(fields: EndpointFields): string[] {
/** 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;
+ for (const entry of Object.values(instances)) {
+ if (entry.driver !== "claudeAgent" || isClaudeEndpoint(entry)) continue;
+ const cli = rawConfig(entry).cli;
+ if (typeof cli === "string" && cli) return cli;
+ }
+ return undefined;
}
export function newClaudeEndpoint(cfg: AppConfig, body: z.infer<typeof claudeEndpointSchema>) {
diff --git a/server/drivers/claude.ts b/server/drivers/claude.ts
index a21ae01f9f..005258991c 100644
--- a/server/drivers/claude.ts
+++ b/server/drivers/claude.ts
@@ -1092,8 +1092,10 @@ 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(endpointTurnModel(turn.model, config.endpointModels), turnEnvironment);
- const injected = config.managed ? { model: turnModel ?? null, injected: false } : applyClaudeInject({ ...turnEnvironment }, turnModel);
+ const turnModel = config.managed ? turn.model
+ : config.endpointModels ? endpointTurnModel(turn.model, config.endpointModels)
+ : await resolveClaudeTurnModel(turn.model, turnEnvironment);
+ const injected = config.managed || config.endpointModels ? { model: turnModel ?? null, injected: false } : applyClaudeInject({ ...turnEnvironment }, turnModel);
if (injected.model) args.push("--model", injected.model);
if (turn.effort) args.push("--effort", turn.effort);
diff --git a/server/model-providers-docs.test.ts b/server/model-providers-docs.test.ts
index 6e98f241a4..abcf96d544 100644
--- a/server/model-providers-docs.test.ts
+++ b/server/model-providers-docs.test.ts
@@ -119,7 +119,7 @@ describe("Claude Code section", () => {
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.");
+ expect(text).toContain("The token is saved in OpenMausBot's own `config.json` and sent only to the base URL you enter. Removing an endpoint removes only that entry.");
});
});
diff --git a/server/routes/instances.ts b/server/routes/instances.ts
index 159da52600..a3fb4505e4 100644
--- a/server/routes/instances.ts
+++ b/server/routes/instances.ts
@@ -193,6 +193,9 @@ export function createInstanceRoutes(deps: InstanceRouteDeps): RouteHandler {
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" });
+ if (busyProviderSelections().some((selection) => selection.instanceId === instanceId)) {
+ return json(res, 409, { error: "Wait for bots using this endpoint to finish before changing its settings." });
+ }
providerConfigBusy.set(true);
providerInstancesChanging.add(instanceId);
try {
diff --git a/src/components/ClaudeEndpoints.test.ts b/src/components/ClaudeEndpoints.test.ts
index 74a1e07d4e..88fff2ed7b 100644
--- a/src/components/ClaudeEndpoints.test.ts
+++ b/src/components/ClaudeEndpoints.test.ts
@@ -55,6 +55,18 @@ describe("Claude custom endpoints settings", () => {
expect(html).not.toMatch(/tokenSaved|sk-/u);
});
+ it("counts a bot that keeps the endpoint as a fallback", () => {
+ const bot = { id: "bot-2", modelSelection: { instanceId: "claude", model: "claude-sonnet-5" },
+ fallback: [{ 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");
+ });
+
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", {});
diff --git a/src/components/ClaudeEndpoints.tsx b/src/components/ClaudeEndpoints.tsx
index 99d9e87fc8..4aa27c556b 100644
--- a/src/components/ClaudeEndpoints.tsx
+++ b/src/components/ClaudeEndpoints.tsx
@@ -121,7 +121,8 @@ function EndpointRow({ instance, onEdit }: { instance: InstanceInfo; onEdit: ()
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 usedBy = state.bots.filter((bot) => bot.modelSelection.instanceId === instance.instanceId
+ || bot.fallback?.some((candidate) => candidate.instanceId === instance.instanceId)).length;
const endpoint = instance.claudeEndpoint;
const remove = async () => {
setConfirming(false);
diff --git a/src/components/EnginesSettings.tsx b/src/components/EnginesSettings.tsx
index 14818c73f4..4ff4375003 100644
--- a/src/components/EnginesSettings.tsx
+++ b/src/components/EnginesSettings.tsx
@@ -508,7 +508,7 @@ export function EnginesSettings({ simple = false, more }: { simple?: boolean; mo
const { state } = useStore();
// Leaving Settings ends the "now uses the copy OpenMausBot installed" lines.
useEffect(() => forgetAppCopySwitches, []);
- const listed = state.instances.filter((i) => i.readOnly || i.cli !== undefined || i.cliDefault !== undefined || i.snapshot.state === "unavailable" || isApiKeyEngine(i));
+ const listed = state.instances.filter((i) => i.readOnly || i.cli !== undefined || i.cliDefault !== undefined || i.snapshot.state === "unavailable" || isApiKeyEngine(i) || i.claudeEndpoint !== undefined);
// A provider's accounts share one card, which takes the place of its first account.
const groups = new Map<AccountGroup, InstanceInfo[]>();
for (const instance of listed) {
@@ -520,6 +520,8 @@ export function EnginesSettings({ simple = false, more }: { simple?: boolean; mo
return group && groups.get(group)?.[0] === instance ? group : null;
};
const rows = listed.filter((instance) => !accountGroupOf(instance) || groupOf(instance));
+ // A hidden ordinary Claude instance takes its card, and the endpoint section inside it, away.
+ const orphanEndpoints = !groups.has("claude") && rows.some((instance) => instance.claudeEndpoint !== undefined);
const isReady = (instance: InstanceInfo) => { const group = groupOf(instance); return group ? accountsReady(groups.get(group)!) : engineReady(instance); };
const renderEngine = (instance: InstanceInfo, bare = false) => {
const group = groupOf(instance);
@@ -529,7 +531,10 @@ export function EnginesSettings({ simple = false, more }: { simple?: boolean; mo
: <EngineRow instance={instance} bare={bare} />;
};
- if (simple && more) return <SimpleEngines rows={rows} isReady={isReady} renderEngine={renderEngine} more={more} />;
+ if (simple && more) return <>
+ <SimpleEngines rows={rows} isReady={isReady} renderEngine={renderEngine} more={more} />
+ {orphanEndpoints && <div className="px-4"><ClaudeEndpoints /></div>}
+ </>;
return (
<div className="flex min-w-0 flex-col gap-6 pb-2">
@@ -541,6 +546,7 @@ export function EnginesSettings({ simple = false, more }: { simple?: boolean; mo
<RefreshEngines />
</div>
<EngineSections instances={rows} isReady={isReady} renderEngine={renderEngine} />
+ {orphanEndpoints && <div className="px-4"><ClaudeEndpoints /></div>}
<HiddenEngines />
<CacheKeepWarmSettings />
</div>