fix(gemini-cli): use backend project ID from onboarding response
- Simplify project ID selection to always use the backend project ID returned by Gemini onboarding - Update Gemini CLI version from 0.31.0 to 0.34.0 - Add 'terminal' to User-Agent string for better client identification Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -49,3 +49,4 @@ _bmad-output/*
|
|||||||
# macOS
|
# macOS
|
||||||
.DS_Store
|
.DS_Store
|
||||||
._*
|
._*
|
||||||
|
.gocache/
|
||||||
|
|||||||
@@ -2566,20 +2566,9 @@ func performGeminiCLISetup(ctx context.Context, httpClient *http.Client, storage
|
|||||||
finalProjectID := projectID
|
finalProjectID := projectID
|
||||||
if responseProjectID != "" {
|
if responseProjectID != "" {
|
||||||
if explicitProject && !strings.EqualFold(responseProjectID, projectID) {
|
if explicitProject && !strings.EqualFold(responseProjectID, projectID) {
|
||||||
// Check if this is a free user (gen-lang-client projects or free/legacy tier)
|
log.Infof("Gemini onboarding: requested project %s maps to backend project %s", projectID, responseProjectID)
|
||||||
isFreeUser := strings.HasPrefix(projectID, "gen-lang-client-") ||
|
log.Infof("Using backend project ID: %s", responseProjectID)
|
||||||
strings.EqualFold(tierID, "FREE") ||
|
finalProjectID = responseProjectID
|
||||||
strings.EqualFold(tierID, "LEGACY")
|
|
||||||
|
|
||||||
if isFreeUser {
|
|
||||||
// For free users, use backend project ID for preview model access
|
|
||||||
log.Infof("Gemini onboarding: frontend project %s maps to backend project %s", projectID, responseProjectID)
|
|
||||||
log.Infof("Using backend project ID: %s (recommended for preview model access)", responseProjectID)
|
|
||||||
finalProjectID = responseProjectID
|
|
||||||
} else {
|
|
||||||
// Pro users: keep requested project ID (original behavior)
|
|
||||||
log.Warnf("Gemini onboarding returned project %s instead of requested %s; keeping requested project ID.", responseProjectID, projectID)
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
finalProjectID = responseProjectID
|
finalProjectID = responseProjectID
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-33
@@ -333,39 +333,9 @@ func performGeminiCLISetup(ctx context.Context, httpClient *http.Client, storage
|
|||||||
finalProjectID := projectID
|
finalProjectID := projectID
|
||||||
if responseProjectID != "" {
|
if responseProjectID != "" {
|
||||||
if explicitProject && !strings.EqualFold(responseProjectID, projectID) {
|
if explicitProject && !strings.EqualFold(responseProjectID, projectID) {
|
||||||
// Check if this is a free user (gen-lang-client projects or free/legacy tier)
|
log.Infof("Gemini onboarding: requested project %s maps to backend project %s", projectID, responseProjectID)
|
||||||
isFreeUser := strings.HasPrefix(projectID, "gen-lang-client-") ||
|
log.Infof("Using backend project ID: %s", responseProjectID)
|
||||||
strings.EqualFold(tierID, "FREE") ||
|
finalProjectID = responseProjectID
|
||||||
strings.EqualFold(tierID, "LEGACY")
|
|
||||||
|
|
||||||
if isFreeUser {
|
|
||||||
// Interactive prompt for free users
|
|
||||||
fmt.Printf("\nGoogle returned a different project ID:\n")
|
|
||||||
fmt.Printf(" Requested (frontend): %s\n", projectID)
|
|
||||||
fmt.Printf(" Returned (backend): %s\n\n", responseProjectID)
|
|
||||||
fmt.Printf(" Backend project IDs have access to preview models (gemini-3-*).\n")
|
|
||||||
fmt.Printf(" This is normal for free tier users.\n\n")
|
|
||||||
fmt.Printf("Which project ID would you like to use?\n")
|
|
||||||
fmt.Printf(" [1] Backend (recommended): %s\n", responseProjectID)
|
|
||||||
fmt.Printf(" [2] Frontend: %s\n\n", projectID)
|
|
||||||
fmt.Printf("Enter choice [1]: ")
|
|
||||||
|
|
||||||
reader := bufio.NewReader(os.Stdin)
|
|
||||||
choice, _ := reader.ReadString('\n')
|
|
||||||
choice = strings.TrimSpace(choice)
|
|
||||||
|
|
||||||
if choice == "2" {
|
|
||||||
log.Infof("Using frontend project ID: %s", projectID)
|
|
||||||
fmt.Println(". Warning: Frontend project IDs may not have access to preview models.")
|
|
||||||
finalProjectID = projectID
|
|
||||||
} else {
|
|
||||||
log.Infof("Using backend project ID: %s (recommended)", responseProjectID)
|
|
||||||
finalProjectID = responseProjectID
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// Pro users: keep requested project ID (original behavior)
|
|
||||||
log.Warnf("Gemini onboarding returned project %s instead of requested %s; keeping requested project ID.", responseProjectID, projectID)
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
finalProjectID = responseProjectID
|
finalProjectID = responseProjectID
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import (
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
// GeminiCLIVersion is the version string reported in the User-Agent for upstream requests.
|
// GeminiCLIVersion is the version string reported in the User-Agent for upstream requests.
|
||||||
GeminiCLIVersion = "0.31.0"
|
GeminiCLIVersion = "0.34.0"
|
||||||
|
|
||||||
// GeminiCLIApiClientHeader is the value for the X-Goog-Api-Client header sent to the Gemini CLI upstream.
|
// GeminiCLIApiClientHeader is the value for the X-Goog-Api-Client header sent to the Gemini CLI upstream.
|
||||||
GeminiCLIApiClientHeader = "google-genai-sdk/1.41.0 gl-node/v22.19.0"
|
GeminiCLIApiClientHeader = "google-genai-sdk/1.41.0 gl-node/v22.19.0"
|
||||||
@@ -46,7 +46,7 @@ func GeminiCLIUserAgent(model string) string {
|
|||||||
if model == "" {
|
if model == "" {
|
||||||
model = "unknown"
|
model = "unknown"
|
||||||
}
|
}
|
||||||
return fmt.Sprintf("GeminiCLI/%s/%s (%s; %s)", GeminiCLIVersion, model, geminiCLIOS(), geminiCLIArch())
|
return fmt.Sprintf("GeminiCLI/%s/%s (%s; %s; terminal)", GeminiCLIVersion, model, geminiCLIOS(), geminiCLIArch())
|
||||||
}
|
}
|
||||||
|
|
||||||
// ScrubProxyAndFingerprintHeaders removes all headers that could reveal
|
// ScrubProxyAndFingerprintHeaders removes all headers that could reveal
|
||||||
|
|||||||
Reference in New Issue
Block a user