mirror of
https://github.com/tiennm99/ccs.git
synced 2026-10-12 20:15:40 +00:00
fix(websearch): format status.ts
This commit is contained in:
1 parent
f4911694e3
commit
c0c36991d6
2 files changed
+42
-27
No files matched your search
@@ -115,15 +115,17 @@ function applyCooldownStatus(
|
|||||||
|
|
||||||
function getLegacyProviderStatuses(
|
function getLegacyProviderStatuses(
|
||||||
wsConfig: WebSearchConfigSnapshot,
|
wsConfig: WebSearchConfigSnapshot,
|
||||||
options?: { includeVersions?: boolean }
|
options?: { includeVersions?: boolean; probeDisabled?: boolean }
|
||||||
): WebSearchCliInfo[] {
|
): WebSearchCliInfo[] {
|
||||||
const fetchVersion = options?.includeVersions !== false;
|
const probeAll = options?.probeDisabled ?? true;
|
||||||
const agyEnabled = wsConfig.providers?.agy?.enabled ?? false;
|
const fetchVersion = options?.includeVersions ?? true;
|
||||||
const geminiEnabled = wsConfig.providers?.gemini?.enabled ?? false;
|
const agyEnabled = probeAll || (wsConfig.providers?.agy?.enabled ?? false);
|
||||||
const grokEnabled = wsConfig.providers?.grok?.enabled ?? false;
|
const geminiEnabled = probeAll || (wsConfig.providers?.gemini?.enabled ?? false);
|
||||||
const opencodeEnabled = wsConfig.providers?.opencode?.enabled ?? false;
|
const grokEnabled = probeAll || (wsConfig.providers?.grok?.enabled ?? false);
|
||||||
|
const opencodeEnabled = probeAll || (wsConfig.providers?.opencode?.enabled ?? false);
|
||||||
|
|
||||||
const agyStatus = agyEnabled ? getAgyCliStatus({ fetchVersion }) : { installed: false };
|
// agy detail renders its version on launch and in dashboard, so always fetch version when probed
|
||||||
|
const agyStatus = agyEnabled ? getAgyCliStatus({ fetchVersion: true }) : { installed: false };
|
||||||
const geminiStatus = geminiEnabled ? getGeminiCliStatus({ fetchVersion }) : { installed: false };
|
const geminiStatus = geminiEnabled ? getGeminiCliStatus({ fetchVersion }) : { installed: false };
|
||||||
const grokStatus = grokEnabled ? getGrokCliStatus({ fetchVersion }) : { installed: false };
|
const grokStatus = grokEnabled ? getGrokCliStatus({ fetchVersion }) : { installed: false };
|
||||||
const opencodeStatus = opencodeEnabled
|
const opencodeStatus = opencodeEnabled
|
||||||
@@ -143,11 +145,13 @@ function getLegacyProviderStatuses(
|
|||||||
docsUrl: 'https://antigravity.google/cli',
|
docsUrl: 'https://antigravity.google/cli',
|
||||||
requiresApiKey: false,
|
requiresApiKey: false,
|
||||||
description: 'Recommended LLM CLI fallback with Google web search (Gemini CLI successor).',
|
description: 'Recommended LLM CLI fallback with Google web search (Gemini CLI successor).',
|
||||||
detail: agyStatus.installed
|
detail: !agyEnabled
|
||||||
? agyStatus.version
|
? 'Disabled'
|
||||||
? `Installed (${agyStatus.version})`
|
: agyStatus.installed
|
||||||
: 'Installed'
|
? agyStatus.version
|
||||||
: 'Not installed',
|
? `Installed (${agyStatus.version})`
|
||||||
|
: 'Installed'
|
||||||
|
: 'Not installed',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'gemini',
|
id: 'gemini',
|
||||||
@@ -162,11 +166,13 @@ function getLegacyProviderStatuses(
|
|||||||
requiresApiKey: false,
|
requiresApiKey: false,
|
||||||
description:
|
description:
|
||||||
'Deprecated legacy fallback (Google retired the gemini CLI). Prefer Antigravity.',
|
'Deprecated legacy fallback (Google retired the gemini CLI). Prefer Antigravity.',
|
||||||
detail: geminiStatus.installed
|
detail: !geminiEnabled
|
||||||
? geminiAuthed
|
? 'Disabled'
|
||||||
? 'Authenticated'
|
: geminiStatus.installed
|
||||||
: "Run 'gemini' to login"
|
? geminiAuthed
|
||||||
: 'Not installed (retired - use Antigravity)',
|
? 'Authenticated'
|
||||||
|
: "Run 'gemini' to login"
|
||||||
|
: 'Not installed (retired - use Antigravity)',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'opencode',
|
id: 'opencode',
|
||||||
@@ -180,7 +186,11 @@ function getLegacyProviderStatuses(
|
|||||||
docsUrl: 'https://github.com/sst/opencode',
|
docsUrl: 'https://github.com/sst/opencode',
|
||||||
requiresApiKey: false,
|
requiresApiKey: false,
|
||||||
description: 'Optional legacy LLM fallback via OpenCode.',
|
description: 'Optional legacy LLM fallback via OpenCode.',
|
||||||
detail: opencodeStatus.installed ? 'Installed' : 'Not installed',
|
detail: !opencodeEnabled
|
||||||
|
? 'Disabled'
|
||||||
|
: opencodeStatus.installed
|
||||||
|
? 'Installed'
|
||||||
|
: 'Not installed',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'grok',
|
id: 'grok',
|
||||||
@@ -195,11 +205,13 @@ function getLegacyProviderStatuses(
|
|||||||
requiresApiKey: true,
|
requiresApiKey: true,
|
||||||
apiKeyEnvVar: 'GROK_API_KEY',
|
apiKeyEnvVar: 'GROK_API_KEY',
|
||||||
description: 'Optional legacy LLM fallback with xAI Grok.',
|
description: 'Optional legacy LLM fallback with xAI Grok.',
|
||||||
detail: grokStatus.installed
|
detail: !grokEnabled
|
||||||
? hasEnvValue('GROK_API_KEY')
|
? 'Disabled'
|
||||||
? 'Ready'
|
: grokStatus.installed
|
||||||
: 'Set GROK_API_KEY'
|
? hasEnvValue('GROK_API_KEY')
|
||||||
: 'Not installed',
|
? 'Ready'
|
||||||
|
: 'Set GROK_API_KEY'
|
||||||
|
: 'Not installed',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@@ -209,7 +221,7 @@ function getLegacyProviderStatuses(
|
|||||||
*/
|
*/
|
||||||
export function getWebSearchCliProviders(
|
export function getWebSearchCliProviders(
|
||||||
wsConfig: WebSearchConfigSnapshot = getWebSearchConfig(),
|
wsConfig: WebSearchConfigSnapshot = getWebSearchConfig(),
|
||||||
options?: { includeVersions?: boolean }
|
options?: { includeVersions?: boolean; probeDisabled?: boolean }
|
||||||
): WebSearchCliInfo[] {
|
): WebSearchCliInfo[] {
|
||||||
const apiKeyStates = getWebSearchApiKeyStates();
|
const apiKeyStates = getWebSearchApiKeyStates();
|
||||||
const cooldowns = readProviderCooldowns();
|
const cooldowns = readProviderCooldowns();
|
||||||
@@ -370,7 +382,10 @@ export function buildWebSearchReadiness(
|
|||||||
export function getWebSearchReadiness(
|
export function getWebSearchReadiness(
|
||||||
wsConfig: WebSearchConfigSnapshot = getWebSearchConfig()
|
wsConfig: WebSearchConfigSnapshot = getWebSearchConfig()
|
||||||
): WebSearchStatus {
|
): WebSearchStatus {
|
||||||
const providers = getWebSearchCliProviders(wsConfig, { includeVersions: false });
|
const providers = getWebSearchCliProviders(wsConfig, {
|
||||||
|
includeVersions: false,
|
||||||
|
probeDisabled: false,
|
||||||
|
});
|
||||||
return buildWebSearchReadiness(wsConfig.enabled, providers);
|
return buildWebSearchReadiness(wsConfig.enabled, providers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -336,7 +336,7 @@ describe('websearch readiness', () => {
|
|||||||
} as any);
|
} as any);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
getWebSearchCliProviders();
|
getWebSearchCliProviders(undefined, { probeDisabled: false });
|
||||||
expect(agyStatusSpy).not.toHaveBeenCalled();
|
expect(agyStatusSpy).not.toHaveBeenCalled();
|
||||||
expect(geminiStatusSpy).not.toHaveBeenCalled();
|
expect(geminiStatusSpy).not.toHaveBeenCalled();
|
||||||
expect(geminiAuthSpy).not.toHaveBeenCalled();
|
expect(geminiAuthSpy).not.toHaveBeenCalled();
|
||||||
@@ -394,7 +394,7 @@ describe('websearch readiness', () => {
|
|||||||
getWebSearchCliProviders(wsConfig as Parameters<typeof getWebSearchCliProviders>[0], {
|
getWebSearchCliProviders(wsConfig as Parameters<typeof getWebSearchCliProviders>[0], {
|
||||||
includeVersions: false,
|
includeVersions: false,
|
||||||
});
|
});
|
||||||
expect(agyStatusSpy).toHaveBeenCalledWith({ fetchVersion: false });
|
expect(agyStatusSpy).toHaveBeenCalledWith({ fetchVersion: true });
|
||||||
expect(geminiStatusSpy).toHaveBeenCalledWith({ fetchVersion: false });
|
expect(geminiStatusSpy).toHaveBeenCalledWith({ fetchVersion: false });
|
||||||
expect(grokStatusSpy).toHaveBeenCalledWith({ fetchVersion: false });
|
expect(grokStatusSpy).toHaveBeenCalledWith({ fetchVersion: false });
|
||||||
expect(opencodeStatusSpy).toHaveBeenCalledWith({ fetchVersion: false });
|
expect(opencodeStatusSpy).toHaveBeenCalledWith({ fetchVersion: false });
|
||||||
|
|||||||
Reference in new issue
Block a user