Merge remote-tracking branch 'upstream/master'

This commit is contained in:
MUH. IQRAM BAHRING committed 2026-09-05 23:20:53 +08:00
commit c378f2dc90
97 files changed
+4245 -572

No files matched your search

+10 -3
View File
@@ -7,7 +7,7 @@ import {
extractApiKey,
isValidApiKey,
} from "../services/auth.js";
import { handleAntigravityQuotaError } from "../services/antigravityQuota.js";
import { handleAntigravityQuotaError, clearAntigravityStrikes } from "../services/antigravityQuota.js";
import { getSettings } from "@/lib/localDb";
import { getModelInfo, getComboModels } from "../services/model.js";
import { handleChatCore } from "open-sse/handlers/chatCore.js";
@@ -24,6 +24,7 @@ import { detectFormatByEndpoint } from "open-sse/translator/formats.js";
import * as log from "../utils/logger.js";
import { updateProviderCredentials, checkAndRefreshToken } from "../services/tokenRefresh.js";
import { getProjectIdForConnection } from "open-sse/services/projectId.js";
import { stripModelContextMarker } from "open-sse/utils/modelMarkers.js";
/**
* Handle chat completion request
@@ -48,7 +49,11 @@ export async function handleChat(request, clientRawRequest = null) {
headers: Object.fromEntries(request.headers.entries())
};
}
const modelStr = body.model;
// Claude Code marks a 1M-context request as `<model>[1m]`; the marker matches
// no combo, alias or provider/model pair, so it must not reach resolution.
// The capability travels in the anthropic-beta header, forwarded as-is.
const { model: modelStr, contextMarker } = stripModelContextMarker(body.model);
if (contextMarker) body.model = modelStr;
// Request summary is emitted as the unified "▶" line in chatCore (has fmt/thinking/account)
@@ -233,7 +238,7 @@ async function handleSingleModelChat(body, modelStr, clientRawRequest = null, re
if (!credentials || credentials.allRateLimited) {
if (credentials?.allRateLimited) {
const errorMsg = lastError || credentials.lastError || "Unavailable";
const status = lastStatus || Number(credentials.lastErrorCode) || HTTP_STATUS.SERVICE_UNAVAILABLE;
const status = HTTP_STATUS.SERVICE_UNAVAILABLE;
log.warn("CHAT", `[${provider}/${model}] ${errorMsg} (${credentials.retryAfterHuman})`);
return unavailableResponse(status, `[${provider}/${model}] ${errorMsg}`, credentials.retryAfter, credentials.retryAfterHuman);
}
@@ -315,6 +320,8 @@ async function handleSingleModelChat(body, modelStr, clientRawRequest = null, re
},
onRequestSuccess: async () => {
await clearAccountError(credentials.connectionId, credentials, model);
// "Consecutive" strikes: a success clears the breaker for this pair.
clearAntigravityStrikes(credentials.connectionId, model);
}
});