Merge branch 'openchamber:main' into github-usage-rework

This commit is contained in:
Jakub Syty
2026-08-26 13:58:58 +02:00
committed by GitHub
513 changed files with 31772 additions and 12940 deletions
@@ -3,7 +3,7 @@ import { asObject, buildResult, getAuthEntry, normalizeAuthEntry, toNumber, toUs
export const providerId = 'command-code';
export const providerName = 'Command Code';
export const aliases = ['command-code'];
export const aliases = ['command-code', 'commandcode', 'command_code', 'command code'];
const API_BASE_URL = 'https://api.commandcode.ai';
@@ -69,4 +69,17 @@ describe('Command Code quota provider', () => {
expect(fetchMock.mock.calls[0][1].headers.Authorization).toBe('Bearer test-token');
vi.unstubAllGlobals();
});
it('recognizes Command Code auth entries under supported provider ID variants', async () => {
for (const providerId of ['commandcode', 'command_code', 'command code']) {
const fetchMock = vi.fn()
.mockResolvedValueOnce(new Response(JSON.stringify({ org: { id: 'org-1' } })))
.mockResolvedValueOnce(new Response(JSON.stringify(creditsPayload)));
vi.stubGlobal('fetch', fetchMock);
const result = await fetchQuota({ [providerId]: { type: 'oauth', access: 'test-token' } });
expect(result).toMatchObject({ providerId: 'command-code', ok: true, configured: true });
vi.unstubAllGlobals();
}
});
});
@@ -160,6 +160,13 @@ const registry = {
const pendingFetches = new Map();
const normalizeQuotaProviderId = (providerId) => {
if (typeof providerId !== 'string') return providerId;
return ['command-code', 'commandcode', 'command_code', 'command code'].includes(providerId.trim().toLowerCase())
? 'command-code'
: providerId;
};
export const listConfiguredQuotaProviders = () => {
const configured = [];
@@ -203,13 +210,14 @@ const fetchQuotaForProviderUncoalesced = async (providerId) => {
};
export const fetchQuotaForProvider = (providerId) => {
const existing = pendingFetches.get(providerId);
const normalizedProviderId = normalizeQuotaProviderId(providerId);
const existing = pendingFetches.get(normalizedProviderId);
if (existing) return existing;
const pending = fetchQuotaForProviderUncoalesced(providerId).finally(() => {
if (pendingFetches.get(providerId) === pending) pendingFetches.delete(providerId);
const pending = fetchQuotaForProviderUncoalesced(normalizedProviderId).finally(() => {
if (pendingFetches.get(normalizedProviderId) === pending) pendingFetches.delete(normalizedProviderId);
});
pendingFetches.set(providerId, pending);
pendingFetches.set(normalizedProviderId, pending);
return pending;
};