feat: rename the default provider to netGate and let manual keys name their own - #212
Merged
Merged
Conversation
… 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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Splits the provider identity CoDev writes into the OpenAI-compatible agent configs into two cases:
netgate/netGateinstead ofaigateway/AI Gateway.ai-gateway/AI Gateway.Claude Code is unaffected — it has no provider concept, only env vars.
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 configscodevhub modelrewrites),isCodevAuthored(restore's delete-vs-kept-livedecision), andreadAgentConfig's base_url readback for uploads. A user-chosen id can't be a compile-time constant, so:src/lib/provider.tsowns the identities andcodevProviderIds(), which returns the candidate set: the id saved inauth.json, thennetgate,ai-gateway, and the pre-renameaigateway.firstNestedKeyhelper resolves the live provider entry against that set in both the detectors and the readers.auth.jsona 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
aigatewayany more, but it stays recognized, so existing installs keep working:codevhub modelstill finds their tools,restore/removestill 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 dedicatedlegacy aigateway configsdescribe block.Persistence hazard worth a review eye
The identity is persisted as
provider_id/provider_namein~/.codev-hub/auth.json.saveApiKeywrites 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, andSetupApp'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.tspins 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.tests/lib/provider.test.ts(slug table, fallbacks, candidate set) and new describes inconfigure.test.tsfor custom-provider writes across codex/opencode/codev-code/continue and for legacyaigatewaydetection + readback.HOME: SSO creds producenetgate/netGate;"Acme AI Gateway"produces the id above across all four configs, withdetectConfiguredToolsandreadAgentConfigstill resolving once the id is saved.🤖 Generated with Claude Code