feat: merge main

This commit is contained in:
故璃
2026-06-17 14:43:13 +08:00
parent b01d35c246
commit 8cb24b719b
6 changed files with 48 additions and 32 deletions
+2 -2
View File
@@ -127,8 +127,6 @@ export default defineCommand({
const region = (flags.region as string) || "cn-beijing";
const format = detectOutputFormat(config.output);
const credential = await resolveConsoleGatewayCredential(config);
const requestData = {
input: { pageNo: page, pageSize },
};
@@ -138,6 +136,8 @@ export default defineCommand({
return;
}
const credential = await resolveConsoleGatewayCredential(config);
let result: unknown;
try {
result = await callConsoleGateway(config, credential.token, {
+2 -2
View File
@@ -183,8 +183,6 @@ export default defineCommand({
const region = (flags.region as string) || "cn-beijing";
const format = detectOutputFormat(config.output);
const credential = await resolveConsoleGatewayCredential(config);
if (config.dryRun) {
const input: Record<string, unknown> = {
pageNo: 1,
@@ -198,6 +196,8 @@ export default defineCommand({
return;
}
const credential = await resolveConsoleGatewayCredential(config);
let models = await fetchAllModelsWithQpm(config, credential.token, region, !showAll);
if (modelFlag) {
+11 -5
View File
@@ -126,6 +126,17 @@ export default defineCommand({
const region = (flags.region as string) || "cn-beijing";
const format = detectOutputFormat(config.output);
if (config.dryRun) {
const requestData = {
input: {
model: modelName,
limit: { usage_limit: tpmValue },
},
};
emitResult({ api: UPDATE_LIMITS_API, data: requestData, region }, format);
return;
}
const credential = await resolveConsoleGatewayCredential(config);
const modelInfo = await fetchModelQpmInfo(config, credential.token, region, modelName);
@@ -160,11 +171,6 @@ export default defineCommand({
} as Record<string, unknown>,
};
if (config.dryRun) {
emitResult({ api: UPDATE_LIMITS_API, data: requestData, region }, format);
return;
}
const submitRequest = async (confirmedDowngrade?: boolean): Promise<unknown> => {
if (confirmedDowngrade) {
requestData.input.confirmedDowngrade = true;
+22 -17
View File
@@ -229,8 +229,6 @@ export default defineCommand({
const region = (flags.region as string) || "cn-beijing";
const format = detectOutputFormat(config.output);
const credential = await resolveConsoleGatewayCredential(config);
let models: string[];
const typeMap = new Map<string, string>();
@@ -243,21 +241,8 @@ export default defineCommand({
.filter(Boolean),
),
];
const searchResults = await Promise.all(
models.map((name) => fetchModelList(config, credential.token, { name, pageSize: 50 })),
);
for (let idx = 0; idx < models.length; idx++) {
const matched = searchResults[idx].models.find((item) => item.model === models[idx]);
if (matched) {
typeMap.set(models[idx], resolveModelType((matched.capabilities as string[]) || []));
}
}
} else {
const modelInfos = await fetchAllModels(config, credential.token);
models = modelInfos.map((info) => info.name);
for (const info of modelInfos) {
typeMap.set(info.name, info.type);
}
models = [];
}
const requestData = {
@@ -270,13 +255,33 @@ export default defineCommand({
api: FREE_TIER_API,
data: requestData,
region,
token: credential.token.slice(0, 8) + "...",
},
format,
);
return;
}
const credential = await resolveConsoleGatewayCredential(config);
if (!modelFlag) {
const modelInfos = await fetchAllModels(config, credential.token);
models = modelInfos.map((info) => info.name);
for (const info of modelInfos) {
typeMap.set(info.name, info.type);
}
requestData.queryFreeTierQuotaRequest.models = models;
} else {
const searchResults = await Promise.all(
models.map((name) => fetchModelList(config, credential.token, { name, pageSize: 50 })),
);
for (let idx = 0; idx < models.length; idx++) {
const matched = searchResults[idx].models.find((item) => item.model === models[idx]);
if (matched) {
typeMap.set(models[idx], resolveModelType((matched.capabilities as string[]) || []));
}
}
}
const [quotaResult, stopResult] = await Promise.all([
callConsoleGateway(config, credential.token, {
api: FREE_TIER_API,
+7 -4
View File
@@ -151,8 +151,6 @@ export default defineCommand({
process.exit(1);
}
const credential = await resolveConsoleGatewayCredential(config);
let models: string[];
if (modelFlag) {
models = [
@@ -164,7 +162,7 @@ export default defineCommand({
),
];
} else {
models = await fetchAllModelNames(config, credential.token);
models = [];
}
const api = off ? DEACTIVATE_API : ACTIVATE_API;
@@ -178,13 +176,18 @@ export default defineCommand({
api,
data: { [requestKey]: { models } },
region,
token: credential.token.slice(0, 8) + "...",
},
format,
);
return;
}
const credential = await resolveConsoleGatewayCredential(config);
if (!modelFlag) {
models = await fetchAllModelNames(config, credential.token);
}
if (off) {
const [quotaResult, stopResult] = await Promise.all([
callConsoleGateway(config, credential.token, {
+4 -2
View File
@@ -330,8 +330,6 @@ export default defineCommand({
const flagWorkspaceId = (flags.workspaceId as string) || undefined;
const workspaceId = resolveWorkspaceId(config, flagWorkspaceId);
const credential = await resolveConsoleGatewayCredential(config);
const endTime = Date.now();
const startTime = endTime - daysFlag * 24 * 60 * 60 * 1000;
@@ -365,6 +363,8 @@ export default defineCommand({
return;
}
const credential = await resolveConsoleGatewayCredential(config);
const results = await Promise.all(
models.map((model) =>
pollTelemetryApi(config, credential.token, LIST_API, { ...baseReqDTO, model }, region),
@@ -415,6 +415,8 @@ export default defineCommand({
return;
}
const credential = await resolveConsoleGatewayCredential(config);
const result = await pollTelemetryApi(config, credential.token, OVERVIEW_API, reqDTO, region);
if (!result) {
process.stderr.write("Error: request timed out.\n");