Skip to content

feat: rename the default provider to netGate and let manual keys name their own - #212

Merged
quickbeard merged 1 commit into
mainfrom
feat/custom-provider-identity
Jul 28, 2026
Merged

feat: rename the default provider to netGate and let manual keys name their own#212
quickbeard merged 1 commit into
mainfrom
feat/custom-provider-identity

Conversation

@quickbeard

Copy link
Copy Markdown
Owner

What

Splits the provider identity CoDev writes into the OpenAI-compatible agent configs into two cases:

  • SSO-issued keys — "Get a new API Key", and "Reuse existing API Key" when the saved key carries no provider of its own — now get netgate / netGate instead of aigateway / AI Gateway.
  • "I have my own API Key" gains an optional, ASCII-only Provider Name as its first field. The id is slugged from it, and a blank or unusable name falls back to ai-gateway / AI Gateway.

Claude Code is unaffected — it has no provider concept, only env vars.

Name: "Acme AI Gateway"  ->  id: acme-ai-gateway
Name: "My_Gateway 2.0"   ->  id: my-gateway-2-0
Name: "" or "!!!"        ->  ai-gateway / AI Gateway

codex config.toml        model_provider = "acme-ai-gateway"
                         [model_providers.acme-ai-gateway] name = "Acme AI Gateway"
opencode.json            "model": "acme-ai-gateway/m-alpha"
continue config.yaml     name: "CoDev (Acme AI Gateway)"

The slug charset is deliberately [a-z0-9-]: TOML-bare-key safe so [model_providers.<id>] needs no quoting, and slash-free so OpenCode's "<id>/<model>" stays parseable.

Why this touches more than the two constants

The provider id is CoDev's authorship marker for codex/opencode/codev-code. It gates detectConfiguredTools (whose configs codevhub model rewrites), isCodevAuthored (restore's delete-vs-kept-live decision), and readAgentConfig's base_url readback for uploads. A user-chosen id can't be a compile-time constant, so:

  • New src/lib/provider.ts owns the identities and codevProviderIds(), which returns the candidate set: the id saved in auth.json, then netgate, ai-gateway, and the pre-rename aigateway.
  • A new firstNestedKey helper resolves the live provider entry against that set in both the detectors and the readers.
  • Detection is saved-id-first. Without auth.json a custom-id config is unattributable, so restore keeps it rather than deleting it — matching the module's standing rule that a config we can't attribute is one we don't delete.

Back-compat

Nothing writes aigateway any more, but it stays recognized, so existing installs keep working: codevhub model still finds their tools, restore/remove still attribute their configs, uploads still read base_url. They converge on the new id at the next config rewrite (install / config / model switch / key refresh). No migration command. Covered by a dedicated legacy aigateway configs describe block.

Persistence hazard worth a review eye

The identity is persisted as provider_id / provider_name in ~/.codev-hub/auth.json. saveApiKey writes the whole api-key block, so an omitted provider pair clears it. Every re-save site had to thread it through — ModelApp's two re-auth branches and its model switch, refresh.ts#ensureFreshGatewayKey, and SetupApp's model-choice. Missing one would silently revert a manually-named provider to netGate on the next model switch or launch-time key refresh; tests/lib/refresh.test.ts pins that case.

Testing

  • pnpm fix, pnpm typecheck, pnpm test (999 passed / 64 files), pnpm build + Node smoke run — all green, plus the pre-commit hook's own full run.
  • New tests/lib/provider.test.ts (slug table, fallbacks, candidate set) and new describes in configure.test.ts for custom-provider writes across codex/opencode/codev-code/continue and for legacy aigateway detection + readback.
  • Manually verified end-to-end against a scratch HOME: SSO creds produce netgate/netGate; "Acme AI Gateway" produces the id above across all four configs, with detectConfiguredTools and readAgentConfig still resolving once the id is saved.

🤖 Generated with Claude Code

… their own

The provider identity written into every OpenAI-compatible agent config was a
single hardcoded pair. Split it in two:

- SSO-issued keys (new key, or a reused key with no provider of its own) now
  get netgate / netGate instead of aigateway / AI Gateway.
- "I have my own API Key" gains an optional, ASCII-only Provider Name as its
  first field. The id is slugged from it ([a-z0-9-], TOML-bare-key safe and
  slash-free so OpenCode's "<id>/<model>" stays parseable); a blank or unusable
  name falls back to ai-gateway / AI Gateway.

The provider id doubles as CoDev's authorship marker, so it can no longer be a
compile-time constant. codevProviderIds() now returns the candidate set (the id
saved in auth.json, then netgate, ai-gateway and the pre-rename aigateway) and
firstNestedKey resolves the live entry against it, keeping detectConfiguredTools,
restore's authorship gate and the base_url readback working. Legacy aigateway
configs stay recognized and converge on the new id at the next rewrite.

The identity is persisted as provider_id/provider_name and threaded through every
re-save site: saveApiKey writes the whole api-key block, so an omitted pair would
silently revert a named provider to the default on the next model switch or
launch-time key refresh.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@quickbeard
quickbeard merged commit 9026e72 into main Jul 28, 2026
5 of 7 checks passed
@quickbeard
quickbeard deleted the feat/custom-provider-identity branch July 28, 2026 04:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant