fix: improve loadCodeAssist for Google One AI Pro accounts

- Add separate LOAD_CODE_ASSIST_ENDPOINTS (prod first) and
  LOAD_CODE_ASSIST_HEADERS (google-api-nodejs-client User-Agent)
- Add duetProject to metadata for project discovery
- Silent fallback when API returns success but no project
  (matches opencode-antigravity-auth behavior)
- Only warn when all endpoints fail with actual errors

Fixes #114, addresses discussion #113

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Badri Narayanan S
2026-01-13 18:11:45 +05:30
parent 99a06632ea
commit 70fd1baaa8
3 changed files with 57 additions and 13 deletions

View File

@@ -4,7 +4,13 @@
* Handles model listing and quota retrieval from the Cloud Code API.
*/
import { ANTIGRAVITY_ENDPOINT_FALLBACKS, ANTIGRAVITY_HEADERS, getModelFamily } from '../constants.js';
import {
ANTIGRAVITY_ENDPOINT_FALLBACKS,
ANTIGRAVITY_HEADERS,
LOAD_CODE_ASSIST_ENDPOINTS,
LOAD_CODE_ASSIST_HEADERS,
getModelFamily
} from '../constants.js';
import { logger } from '../utils/logger.js';
/**
@@ -122,10 +128,10 @@ export async function getSubscriptionTier(token) {
const headers = {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json',
...ANTIGRAVITY_HEADERS
...LOAD_CODE_ASSIST_HEADERS
};
for (const endpoint of ANTIGRAVITY_ENDPOINT_FALLBACKS) {
for (const endpoint of LOAD_CODE_ASSIST_ENDPOINTS) {
try {
const url = `${endpoint}/v1internal:loadCodeAssist`;
const response = await fetch(url, {
@@ -135,7 +141,8 @@ export async function getSubscriptionTier(token) {
metadata: {
ideType: 'IDE_UNSPECIFIED',
platform: 'PLATFORM_UNSPECIFIED',
pluginType: 'GEMINI'
pluginType: 'GEMINI',
duetProject: 'rising-fact-p41fc'
}
})
});