Merge remote-tracking branch 'origin/master' into gitea/feature/end
Resolved conflicts taking origin/master (v0.5.55) as canonical, with local features re-applied: - runtime log level (LOG_LEVEL env + dashboard Settings → Logging, applied immediately and persisted across restarts) - free/noAuth provider enable/disable toggle via providerStrategies.enabled - parallel model testing (Test All Models / Test Selected Keys)
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
* This significantly reduces the risk of being flagged by Google's anti-abuse systems.
|
||||
*/
|
||||
|
||||
import { CLOUD_CODE_API, LOAD_CODE_ASSIST_HEADERS, LOAD_CODE_ASSIST_METADATA } from "../config/appConstants.js";
|
||||
import { CLOUD_CODE_API, LOAD_CODE_ASSIST_HEADERS, ANTIGRAVITY_LOAD_CODE_ASSIST_HEADERS, LOAD_CODE_ASSIST_METADATA } from "../config/appConstants.js";
|
||||
|
||||
// ─── Cache ────────────────────────────────────────────────────────────────────
|
||||
// connectionId -> { projectId: string, fetchedAt: number }
|
||||
@@ -83,7 +83,7 @@ startCacheCleanup();
|
||||
* @param {string} accessToken - Valid OAuth access token
|
||||
* @returns {Promise<string|null>} Real project ID or null
|
||||
*/
|
||||
export async function getProjectIdForConnection(connectionId, accessToken) {
|
||||
export async function getProjectIdForConnection(connectionId, accessToken, provider = "gemini-cli") {
|
||||
if (!connectionId || !accessToken) return null;
|
||||
|
||||
// Return cached value if still fresh
|
||||
@@ -102,7 +102,7 @@ export async function getProjectIdForConnection(connectionId, accessToken) {
|
||||
|
||||
const promise = (async () => {
|
||||
try {
|
||||
const projectId = await fetchProjectId(accessToken, controller.signal);
|
||||
const projectId = await fetchProjectId(accessToken, controller.signal, provider);
|
||||
if (projectId) {
|
||||
projectIdCache.set(connectionId, {projectId, fetchedAt: Date.now()});
|
||||
return projectId;
|
||||
@@ -155,10 +155,12 @@ export function removeConnection(connectionId) {
|
||||
* @param {AbortSignal} signal
|
||||
* @returns {Promise<string|null>}
|
||||
*/
|
||||
async function fetchProjectId(accessToken, signal) {
|
||||
const response = await fetch(CLOUD_CODE_API.loadCodeAssist, {
|
||||
async function fetchProjectId(accessToken, signal, provider) {
|
||||
const endpoints = CLOUD_CODE_API[provider] || CLOUD_CODE_API["gemini-cli"];
|
||||
const headers = provider === "antigravity" ? ANTIGRAVITY_LOAD_CODE_ASSIST_HEADERS : LOAD_CODE_ASSIST_HEADERS;
|
||||
const response = await fetch(endpoints.loadCodeAssist, {
|
||||
method: "POST",
|
||||
headers: { ...LOAD_CODE_ASSIST_HEADERS, "Authorization": `Bearer ${accessToken}` },
|
||||
headers: { ...headers, "Authorization": `Bearer ${accessToken}` },
|
||||
body: JSON.stringify({ metadata: LOAD_CODE_ASSIST_METADATA }),
|
||||
signal
|
||||
});
|
||||
@@ -185,7 +187,7 @@ async function fetchProjectId(accessToken, signal) {
|
||||
}
|
||||
}
|
||||
|
||||
return onboardUser(accessToken, tierID, signal);
|
||||
return onboardUser(accessToken, tierID, signal, endpoints, provider);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -196,10 +198,11 @@ async function fetchProjectId(accessToken, signal) {
|
||||
* @param {AbortSignal} externalSignal – propagated from the connection's AbortController
|
||||
* @returns {Promise<string|null>}
|
||||
*/
|
||||
async function onboardUser(accessToken, tierID, externalSignal) {
|
||||
async function onboardUser(accessToken, tierID, externalSignal, endpoints, provider) {
|
||||
console.log(`[ProjectId] Onboarding user with tier: ${tierID}`);
|
||||
|
||||
const reqBody = { tierId: tierID, metadata: LOAD_CODE_ASSIST_METADATA };
|
||||
const headers = provider === "antigravity" ? ANTIGRAVITY_LOAD_CODE_ASSIST_HEADERS : LOAD_CODE_ASSIST_HEADERS;
|
||||
const MAX_ATTEMPTS = 5;
|
||||
|
||||
for (let attempt = 1; attempt <= MAX_ATTEMPTS; attempt++) {
|
||||
@@ -213,9 +216,9 @@ async function onboardUser(accessToken, tierID, externalSignal) {
|
||||
externalSignal?.addEventListener("abort", forwardAbort);
|
||||
|
||||
try {
|
||||
const response = await fetch(CLOUD_CODE_API.onboardUser, {
|
||||
const response = await fetch(endpoints.onboardUser, {
|
||||
method: "POST",
|
||||
headers: { ...LOAD_CODE_ASSIST_HEADERS, "Authorization": `Bearer ${accessToken}` },
|
||||
headers: { ...headers, "Authorization": `Bearer ${accessToken}` },
|
||||
body: JSON.stringify(reqBody),
|
||||
signal: localCtrl.signal
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user