Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(usage): recognize Zhipu upstream trailing slash (#7407)

Zhao Dengfeng3e9d38177365
diff --git a/apps/desktop/src/renderer/hooks/__tests__/useProviderAccountUsage.test.ts b/apps/desktop/src/renderer/hooks/__tests__/useProviderAccountUsage.test.ts
index c9bae3a04f..db7788b6a0 100644
--- a/apps/desktop/src/renderer/hooks/__tests__/useProviderAccountUsage.test.ts
+++ b/apps/desktop/src/renderer/hooks/__tests__/useProviderAccountUsage.test.ts
@@ -83,6 +83,23 @@ it.each([
expect(hook.result.current.result).toEqual({ status: 'unavailable', error: 'auth' });
});
+it('supports the official Zhipu Anthropic upstream with a trailing slash and fetches usage', async () => {
+ const zhipuProvider = {
+ ...provider,
+ id: 'custom-zhipu',
+ routing: { 'claude-code': { upstream: 'https://open.bigmodel.cn/api/anthropic/' } },
+ } as ProviderView;
+ fetchUsage.mockResolvedValueOnce(ready);
+ const hook = renderHook(() => useProviderAccountUsage(zhipuProvider, 'claude-code'));
+ await act(async () => {});
+ expect(hook.result.current.supported).toBe(true);
+ expect(fetchUsage).toHaveBeenCalledWith({
+ providerId: 'custom-zhipu',
+ forceRefresh: false,
+ agent: 'claude-code',
+ });
+});
+
it('discards a pending result after the query becomes unsupported', async () => {
let resolvePending!: (result: ProviderAccountUsageResult) => void;
fetchUsage.mockImplementationOnce(
diff --git a/apps/desktop/src/renderer/lib/providerAccountUsageView.ts b/apps/desktop/src/renderer/lib/providerAccountUsageView.ts
index 4674c5ad9e..b7d6170061 100644
--- a/apps/desktop/src/renderer/lib/providerAccountUsageView.ts
+++ b/apps/desktop/src/renderer/lib/providerAccountUsageView.ts
@@ -24,7 +24,9 @@ export function getProviderAccountUsageDashboardUrlView(
const DEEPSEEK_ORIGIN = 'https://api.deepseek.com';
const ZHIPU_ANTHROPIC_BASES = [
'https://open.bigmodel.cn/api/anthropic',
+ 'https://open.bigmodel.cn/api/anthropic/',
'https://api.z.ai/api/anthropic',
+ 'https://api.z.ai/api/anthropic/',
];
const ZHIPU_CODING_PREFIXES = [
'https://open.bigmodel.cn/api/coding/',