mirror of
https://github.com/tiennm99/ccs.git
synced 2026-10-19 00:14:49 +00:00
feat(cliproxy): add xAI Grok provider
This commit is contained in:
1 parent
1b67c7840b
commit
54a2b4759b
37 files changed
+510
-54
No files matched your search
@@ -0,0 +1,30 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { MODEL_CATALOGS } from '@/lib/model-catalogs';
|
||||
|
||||
describe('xAI model catalog defaults', () => {
|
||||
it('mirrors the CLIProxyAPI text catalog and default tier routing', () => {
|
||||
const catalog = MODEL_CATALOGS.xai;
|
||||
const ids = catalog.models.map((model) => model.id);
|
||||
const defaultModel = catalog.models.find((model) => model.id === catalog.defaultModel);
|
||||
|
||||
expect(catalog.displayName).toBe('xAI (Grok)');
|
||||
expect(catalog.defaultModel).toBe('grok-build-0.1');
|
||||
expect(ids).toEqual([
|
||||
'grok-build-0.1',
|
||||
'grok-4.5',
|
||||
'grok-4.3',
|
||||
'grok-4.20-0309-reasoning',
|
||||
'grok-4.20-0309-non-reasoning',
|
||||
'grok-4.20-multi-agent-0309',
|
||||
'grok-3-mini',
|
||||
'grok-3-mini-fast',
|
||||
'grok-composer-2.5-fast',
|
||||
]);
|
||||
expect(defaultModel?.presetMapping).toEqual({
|
||||
default: 'grok-build-0.1',
|
||||
opus: 'grok-4.5',
|
||||
sonnet: 'grok-build-0.1',
|
||||
haiku: 'grok-composer-2.5-fast',
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -2,6 +2,7 @@ import { describe, expect, it } from 'vitest';
|
||||
|
||||
import {
|
||||
CLIPROXY_PROVIDER_SECTIONS,
|
||||
CLIPROXY_PROVIDERS,
|
||||
CORE_CLIPROXY_PROVIDERS,
|
||||
formatRequestedUpstreamModelRules,
|
||||
getProviderDescription,
|
||||
@@ -19,6 +20,7 @@ import {
|
||||
PROVIDER_COLORS,
|
||||
variantUsesPlusExtraProvider,
|
||||
} from '@/lib/provider-config';
|
||||
import { PROVIDERS as WIZARD_PROVIDERS } from '@/components/setup/wizard/constants';
|
||||
|
||||
describe('provider model mapping helpers', () => {
|
||||
it('parses requested=upstream rules into stored upstream+alias pairs', () => {
|
||||
@@ -61,6 +63,7 @@ describe('provider presentation metadata', () => {
|
||||
expect(CLIPROXY_PROVIDER_SECTIONS.map((section) => section.id)).toEqual(['core', 'plus-extra']);
|
||||
expect(CORE_CLIPROXY_PROVIDERS).toContain('gemini');
|
||||
expect(CORE_CLIPROXY_PROVIDERS).toContain('kimi');
|
||||
expect(CORE_CLIPROXY_PROVIDERS).toContain('xai');
|
||||
expect(PLUS_EXTRA_CLIPROXY_PROVIDERS).toEqual([
|
||||
'kiro',
|
||||
'ghcp',
|
||||
@@ -76,6 +79,12 @@ describe('provider presentation metadata', () => {
|
||||
expect(isPlusExtraProvider('gemini')).toBe(false);
|
||||
});
|
||||
|
||||
it('keeps every non-deprecated canonical provider available in the setup wizard', () => {
|
||||
expect(WIZARD_PROVIDERS.map((provider) => provider.id).sort()).toEqual(
|
||||
CLIPROXY_PROVIDERS.filter((provider) => provider !== 'ghcp').sort()
|
||||
);
|
||||
});
|
||||
|
||||
it('groups provider-backed data by shared section metadata', () => {
|
||||
const grouped = groupProvidersBySection(
|
||||
[
|
||||
@@ -96,6 +105,7 @@ describe('provider presentation metadata', () => {
|
||||
expect(isDeviceCodeProvider('cursor')).toBe(false);
|
||||
expect(isDeviceCodeProvider('ghcp')).toBe(true);
|
||||
expect(isDeviceCodeProvider('qwen')).toBe(true);
|
||||
expect(isDeviceCodeProvider('xai')).toBe(true);
|
||||
});
|
||||
|
||||
it('detects plus-extra providers inside composite variants', () => {
|
||||
@@ -120,6 +130,7 @@ describe('provider presentation metadata', () => {
|
||||
});
|
||||
|
||||
it.each([
|
||||
['xai', 'xAI (Grok)', 'Grok coding and reasoning models', '/assets/providers/xai.svg'],
|
||||
['cursor', 'Cursor', 'Cursor browser-authenticated provider', '/assets/sidebar/cursor.svg'],
|
||||
['gitlab', 'GitLab Duo', 'GitLab Duo with OAuth or PAT auth', '/assets/providers/gitlab.svg'],
|
||||
[
|
||||
@@ -153,10 +164,15 @@ describe('provider presentation metadata', () => {
|
||||
textClass: 'text-rose-600',
|
||||
letter: 'K',
|
||||
});
|
||||
expect(getProviderFallbackVisual('xai')).toEqual({
|
||||
textClass: 'text-slate-900',
|
||||
letter: 'X',
|
||||
});
|
||||
|
||||
expect(PROVIDER_COLORS.cursor).toBe('#111827');
|
||||
expect(PROVIDER_COLORS.gitlab).toBe('#FC6D26');
|
||||
expect(PROVIDER_COLORS.codebuddy).toBe('#2563EB');
|
||||
expect(PROVIDER_COLORS.kilo).toBe('#E11D48');
|
||||
expect(PROVIDER_COLORS.xai).toBe('#111827');
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user