feat: consolidate /accounts into /account-limits endpoint
- Remove redundant /accounts endpoint - Enhance /account-limits table output with account status, last used time, and quota reset time - Filter model list to show only Claude models - Use local time format for timestamps - Update documentation (README.md, CLAUDE.md, index.js) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -947,8 +947,72 @@ export function listModels() {
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch available models with quota info from Cloud Code API
|
||||
* Returns model quotas including remaining fraction and reset time
|
||||
*
|
||||
* @param {string} token - OAuth access token
|
||||
* @returns {Promise<Object>} Raw response from fetchAvailableModels API
|
||||
*/
|
||||
export async function fetchAvailableModels(token) {
|
||||
const headers = {
|
||||
'Authorization': `Bearer ${token}`,
|
||||
'Content-Type': 'application/json',
|
||||
...ANTIGRAVITY_HEADERS
|
||||
};
|
||||
|
||||
for (const endpoint of ANTIGRAVITY_ENDPOINT_FALLBACKS) {
|
||||
try {
|
||||
const url = `${endpoint}/v1internal:fetchAvailableModels`;
|
||||
const response = await fetch(url, {
|
||||
method: 'POST',
|
||||
headers,
|
||||
body: JSON.stringify({})
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
const errorText = await response.text();
|
||||
console.log(`[CloudCode] fetchAvailableModels error at ${endpoint}: ${response.status}`);
|
||||
continue;
|
||||
}
|
||||
|
||||
return await response.json();
|
||||
} catch (error) {
|
||||
console.log(`[CloudCode] fetchAvailableModels failed at ${endpoint}:`, error.message);
|
||||
}
|
||||
}
|
||||
|
||||
throw new Error('Failed to fetch available models from all endpoints');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get model quotas for an account
|
||||
* Extracts quota info (remaining fraction and reset time) for each model
|
||||
*
|
||||
* @param {string} token - OAuth access token
|
||||
* @returns {Promise<Object>} Map of modelId -> { remainingFraction, resetTime }
|
||||
*/
|
||||
export async function getModelQuotas(token) {
|
||||
const data = await fetchAvailableModels(token);
|
||||
if (!data || !data.models) return {};
|
||||
|
||||
const quotas = {};
|
||||
for (const [modelId, modelData] of Object.entries(data.models)) {
|
||||
if (modelData.quotaInfo) {
|
||||
quotas[modelId] = {
|
||||
remainingFraction: modelData.quotaInfo.remainingFraction ?? null,
|
||||
resetTime: modelData.quotaInfo.resetTime ?? null
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
return quotas;
|
||||
}
|
||||
|
||||
export default {
|
||||
sendMessage,
|
||||
sendMessageStream,
|
||||
listModels
|
||||
listModels,
|
||||
fetchAvailableModels,
|
||||
getModelQuotas
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user