Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion desktop/src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion desktop/src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "opencodex-desktop"
version = "2.65.0-vadymhimself.20"
version = "2.65.0-vadymhimself.21"
description = "OpenCodex desktop shell"
authors = ["OpenCodex contributors"]
license = "MIT"
Expand Down
2 changes: 1 addition & 1 deletion desktop/src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "https://schema.tauri.app/config/2",
"productName": "OpenCodex",
"version": "2.65.0-vadymhimself.20",
"version": "2.65.0-vadymhimself.21",
"identifier": "com.opencodex.desktop",
"build": {
"frontendDist": "../ui",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bitkyc08/opencodex",
"version": "2.65.0-vadymhimself.20",
"version": "2.65.0-vadymhimself.21",
"description": "Universal provider proxy for OpenAI Codex & Claude Code — use any LLM with Codex CLI/App/SDK and Claude Code",
"type": "module",
"main": "./bin/package-main.mjs",
Expand Down
22 changes: 20 additions & 2 deletions src/providers/registry/entries-core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ const ANTHROPIC_FAST_MODELS: Readonly<Record<string, boolean>> = Object.freeze({
const ANTHROPIC_FAST_TIER_DESCRIPTION =
"Claude fast mode: faster output at 2x price; needs usage credits (subscription) or fast-mode access (API)";

export const PROVIDER_REGISTRY_CORE: readonly ProviderRegistryEntry[] = [
export const PROVIDER_REGISTRY_CORE: readonly ProviderRegistryEntry[] = withXaiKeyEntry([
{
id: "openai",
label: "OpenAI (Codex login)",
Expand Down Expand Up @@ -1408,4 +1408,22 @@ export const PROVIDER_REGISTRY_CORE: readonly ProviderRegistryEntry[] = [
},
note: "Serverless Inference subscription API. Live discovery exposes only kimi-k2-instruct because Vultr documents it as the sole tool-calling model.",
},
];
]);

/**
* AgentRadar image patch (AGE-2278): xAI by API key as its own provider, next to the OpenAI and
* Anthropic key rows. A company key on the `xai` row would replace the Grok sign-ins through
* allowKeyAuthOverride; here it stays separate. Same lineup and wire metadata as `xai`, and no
* default model, so a bare model id still reaches the sign-in.
*/
function withXaiKeyEntry(entries: ProviderRegistryEntry[]): ProviderRegistryEntry[] {
const {
oauthId: _oauthId, allowKeyAuthOverride: _override, keyAuthServiceTier: _keyTier, modelSupportsServiceTier: _oauthTier,
featured: _featured, jawcodeBundle: _jawcode, defaultModel: _defaultModel, ...shared
} = entries.find(entry => entry.id === "xai")!;
entries.splice(entries.findIndex(entry => entry.id === "openai-apikey") + 1, 0, {
...shared, id: "xai-apikey", label: "xAI (API key)", authKind: "key", supportsServiceTier: true,
dashboardUrl: "https://console.x.ai", note: "Direct xAI API billing, no Grok subscription",
});
return entries;
}
9 changes: 6 additions & 3 deletions src/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -509,9 +509,12 @@ export function routedProviderConfig(providerName: string, provider: OcxProvider
return resolved;
}

// AgentRadar image patch (AGE-2278): a bare model id reaches a signed-in provider before its `-apikey`
// twin, whatever order the config was written in, so adding an API key never takes the logins' traffic.
function activeProviderEntries(config: OcxConfig): [string, OcxProviderConfig][] {
return Object.entries(config.providers)
const active = Object.entries(config.providers)
.filter(([name, provider]) => name !== LEGACY_CHATGPT_PROVIDER_ID && provider.disabled !== true);
return [...active.filter(([name]) => !name.endsWith("-apikey")), ...active.filter(([name]) => name.endsWith("-apikey"))];
}

export class NoEnabledOpenAiProviderError extends Error {
Expand Down Expand Up @@ -960,8 +963,8 @@ export function routeConcreteModel(config: OcxConfig, modelId: string): RouteRes
function routeByKnownModelPattern(config: OcxConfig, modelId: string): RouteResult | undefined {
for (const { providerNames, prefixes } of MODEL_PROVIDER_PATTERNS) {
if (prefixes.some(prefix => modelId.startsWith(prefix))) {
const matchingProvider = Object.entries(config.providers).find(
([name, prov]) => prov.disabled !== true && providerNames.some(providerName => name === providerName || name.startsWith(`${providerName}-`))
const matchingProvider = activeProviderEntries(config).find(
([name]) => providerNames.some(providerName => name === providerName || name.startsWith(`${providerName}-`))
);
if (matchingProvider) {
const [provName, prov] = matchingProvider;
Expand Down
2 changes: 1 addition & 1 deletion tests/providers/provider-registry-parity.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function nativeTemplate(): Record<string, unknown> {
}

const EXPECTED_KEY_PROVIDER_IDS = [
"anthropic-apikey", "openai-apikey", "meta-model", "umans", "opencode-go", "neuralwatt", "openrouter", "cline-pass", "cline", "orcarouter", "packycode", "bizrouter", "groq", "google", "google-vertex", "azure-openai",
"anthropic-apikey", "openai-apikey", "xai-apikey", "meta-model", "umans", "opencode-go", "neuralwatt", "openrouter", "cline-pass", "cline", "orcarouter", "packycode", "bizrouter", "groq", "google", "google-vertex", "azure-openai",
"deepseek", "cerebras", "chutes", "deepinfra", "hyperbolic", "nscale", "vultr", "baseten", "commandcode", "sambanova", "nebius", "crusoe", "digitalocean", "scaleway", "featherless", "novita", "together", "fireworks", "firepass", "moonshot",
"huggingface", "nvidia", "venice", "zai", "zhipu-bigmodel", "zhipu-bigmodel-coding", "zhipu-bigmodel-responses", "nanogpt", "synthetic", "siliconflow", "qwen-cloud", "tencent-coding-plan",
"volcengine", "volcengine-coding-plan", "volcengine-agent-plan", "qianfan", "alibaba", "alibaba-token-plan", "alibaba-token-plan-intl", "parallel", "zenmux", "litellm", "ollama-cloud", "mistral",
Expand Down
33 changes: 33 additions & 0 deletions tests/routing/router.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { describe, expect, test } from "bun:test";
import { mapReasoningEffort } from "../../src/reasoning-effort";
import { NoEnabledOpenAiProviderError, routeCompactionModel, routeModel } from "../../src/router";
import { enrichProviderFromRegistry } from "../../src/providers/derive";
import type { OcxConfig, OcxProviderConfig } from "../../src/types";

describe("routeModel registry effort defaults", () => {
Expand Down Expand Up @@ -772,3 +773,35 @@ describe("routeCompactionModel (#2901)", () => {
expect(() => routeCompactionModel(openAiDefaultDisabled, "gpt-5.6-sol")).toThrow(NoEnabledOpenAiProviderError);
});
});

describe("AgentRadar: an API key never takes the sign-ins' traffic (AGE-2278)", () => {
// Enriched from the registry like a loaded config, so default models and model lists are live.
const providers = (entries: Record<string, OcxProviderConfig>): OcxConfig => {
for (const [name, prov] of Object.entries(entries)) enrichProviderFromRegistry(name, prov);
return { port: 10100, defaultProvider: "anthropic", providers: entries };
};
const anthropicKey = (): OcxProviderConfig => ({ adapter: "anthropic", baseUrl: "https://api.anthropic.com", apiKey: "sk-test" });
const xaiKey = (): OcxProviderConfig => ({ adapter: "openai-chat", baseUrl: "https://api.x.ai/v1", apiKey: "xai-test" });
const bare = ["claude-sonnet-5", "claude-opus-5", "grok-4.5", "grok-4.3"];

test("control: a key alone serves the bare ids", () => {
const keysOnly = providers({ "anthropic-apikey": anthropicKey(), "xai-apikey": xaiKey() });
expect(bare.map(model => routeModel(keysOnly, model).providerName))
.toEqual(["anthropic-apikey", "anthropic-apikey", "xai-apikey", "xai-apikey"]);
});

test("keys written before the sign-ins still leave every bare id on the sign-ins", () => {
const config = providers({
"anthropic-apikey": anthropicKey(),
"xai-apikey": xaiKey(),
anthropic: { adapter: "anthropic", baseUrl: "https://api.anthropic.com" },
xai: { adapter: "openai-chat", baseUrl: "https://api.x.ai/v1" },
});
expect(bare.map(model => routeModel(config, model).providerName)).toEqual(["anthropic", "anthropic", "xai", "xai"]);
expect(routeModel(config, "xai/grok-4.5").provider.authMode).toBe("oauth");
// The key is reached only by its own namespace.
expect(routeModel(config, "anthropic-apikey/claude-opus-5").providerName).toBe("anthropic-apikey");
const viaKey = routeModel(config, "xai-apikey/grok-4.5");
expect([viaKey.providerName, viaKey.provider.authMode ?? "key", viaKey.modelId]).toEqual(["xai-apikey", "key", "grok-4.5"]);
});
});
Loading