fix(providers): add Moonshot (Global) provider for api.moonshot.ai endpoint#839
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 67fd7d8532
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| }, | ||
| }, | ||
| { | ||
| id: 'moonshot-global', |
There was a problem hiding this comment.
Add moonshot-global to shared provider type lists
This new provider ID is registered here, but electron/shared/providers/types.ts still omits 'moonshot-global' from PROVIDER_TYPES/BUILTIN_PROVIDER_TYPES (lines 1-28), which backend code treats as the source of truth. In ProviderService.buildAccountsFromOpenClawEntries (electron/services/providers/provider-service.ts:161-163), that causes models.providers['moonshot-global'] entries to be classified as custom, so later key derivation/sync uses a custom-... runtime key instead of moonshot-global; users with config-seeded accounts can end up with mis-typed accounts and writes going to the wrong provider key.
Useful? React with 👍 / 👎.
|
LGTM |
…ueCell-ai#810 ValueCell-ai#839 ValueCell-ai#897 ValueCell-ai#907) Add DeepSeek provider, Moonshot Global endpoint, update Kimi to k2.6, fix API key validation trimming.
Fixes #822
Problem
The Moonshot provider only supports the Chinese endpoint (
api.moonshot.cn/v1). API keys issued for the international endpoint (api.moonshot.ai/v1) get rejected because requests are sent to the wrong host, resulting in auth errors for international users.Solution
Added a separate
moonshot-globalprovider entry pointing tohttps://api.moonshot.ai/v1, following the same CN/Global split pattern already used by MiniMax (minimax-portal/minimax-portal-cn).Changes:
electron/shared/providers/registry.ts: Newmoonshot-globalprovider entry withapi.moonshot.ai/v1base URL and its own env var (MOONSHOT_GLOBAL_API_KEY)electron/utils/provider-keys.ts: AddedOPENCLAW_PROVIDER_KEY_MOONSHOT_GLOBALconstantelectron/utils/openclaw-auth.ts: UpdatedupsertMoonshotWebSearchConfigto accept aproviderKeyandbaseUrlparameter;ensureMoonshotKimiWebSearchCnBaseUrlnow handles both CN and Global providers with correct endpointssrc/lib/providers.ts: Addedmoonshot-globaltoPROVIDER_TYPESandBUILTIN_PROVIDER_TYPES, plus UI metadata entrysrc/assets/providers/index.ts: Mappedmoonshot-globalto the existing moonshot SVG iconTesting
pnpm exec tsc -p tsconfig.json --noEmitpnpm exec vitest run tests/unit/provider-store-validation.test.ts