opencode-studio-server 1.12.5 → 1.12.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +36 -8
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -1883,13 +1883,17 @@ function importCurrentGoogleAuthToPool() {
1883
1883
  if (studio.activeGooglePlugin !== 'antigravity') return;
1884
1884
 
1885
1885
  const authCfg = loadAuthConfig();
1886
- if (!authCfg || !authCfg.google || !authCfg.google.email) return;
1886
+ if (!authCfg) return;
1887
+
1888
+ // Check google.antigravity first, then google
1889
+ const creds = authCfg['google.antigravity'] || authCfg.google;
1890
+ if (!creds || !creds.email) return;
1887
1891
 
1888
1892
  const namespace = 'google.antigravity';
1889
1893
  const profileDir = path.join(AUTH_PROFILES_DIR, namespace);
1890
1894
  if (!fs.existsSync(profileDir)) fs.mkdirSync(profileDir, { recursive: true });
1891
1895
 
1892
- const email = authCfg.google.email;
1896
+ const email = creds.email;
1893
1897
  const profilePath = path.join(profileDir, `${email}.json`);
1894
1898
 
1895
1899
  // Check if we need to sync (new account or updated tokens)
@@ -1897,7 +1901,7 @@ function importCurrentGoogleAuthToPool() {
1897
1901
  if (fs.existsSync(profilePath)) {
1898
1902
  try {
1899
1903
  const current = JSON.parse(fs.readFileSync(profilePath, 'utf8'));
1900
- if (current.access_token === authCfg.google.access_token) {
1904
+ if (current.access_token === creds.access_token) {
1901
1905
  shouldSync = false;
1902
1906
  }
1903
1907
  } catch {
@@ -1907,12 +1911,13 @@ function importCurrentGoogleAuthToPool() {
1907
1911
 
1908
1912
  if (shouldSync) {
1909
1913
  console.log(`[Auth] Syncing Google login for ${email} to Antigravity pool.`);
1910
- atomicWriteFileSync(profilePath, JSON.stringify(authCfg.google, null, 2));
1914
+ atomicWriteFileSync(profilePath, JSON.stringify(creds, null, 2));
1911
1915
 
1912
1916
  const metadata = loadPoolMetadata();
1913
1917
  if (!metadata[namespace]) metadata[namespace] = {};
1914
1918
 
1915
- // Only update metadata if it doesn't exist
1919
+ // Update metadata
1920
+ // Always update to ensure projectId is captured if added later
1916
1921
  if (!metadata[namespace][email]) {
1917
1922
  metadata[namespace][email] = {
1918
1923
  email: email,
@@ -1921,8 +1926,8 @@ function importCurrentGoogleAuthToPool() {
1921
1926
  usageCount: 0,
1922
1927
  imported: true
1923
1928
  };
1924
- savePoolMetadata(metadata);
1925
1929
  }
1930
+ savePoolMetadata(metadata);
1926
1931
  }
1927
1932
  }
1928
1933
 
@@ -2064,10 +2069,14 @@ function buildAccountPool(provider) {
2064
2069
  const name = file.replace('.json', '');
2065
2070
  const meta = providerMeta[name] || {};
2066
2071
  let profileEmail = null;
2072
+ let projectId = null;
2073
+ let tier = null;
2067
2074
  try {
2068
2075
  const raw = fs.readFileSync(path.join(profileDir, file), 'utf8');
2069
2076
  const parsed = JSON.parse(raw);
2070
2077
  profileEmail = parsed?.email || null;
2078
+ projectId = parsed?.projectId || null;
2079
+ tier = parsed?.tier || null;
2071
2080
  } catch {}
2072
2081
  let status = getAccountStatus(meta, now);
2073
2082
  if (name === activeProfile && status === 'ready') status = 'active';
@@ -2079,7 +2088,9 @@ function buildAccountPool(provider) {
2079
2088
  lastUsed: meta.lastUsed || 0,
2080
2089
  usageCount: meta.usageCount || 0,
2081
2090
  cooldownUntil: meta.cooldownUntil || null,
2082
- createdAt: meta.createdAt || 0
2091
+ createdAt: meta.createdAt || 0,
2092
+ projectId,
2093
+ tier
2083
2094
  });
2084
2095
  });
2085
2096
  }
@@ -2342,7 +2353,7 @@ app.post('/api/auth/pool/:name/usage', (req, res) => {
2342
2353
  // PUT /api/auth/pool/:name/metadata - Update account metadata (email, etc.)
2343
2354
  app.put('/api/auth/pool/:name/metadata', (req, res) => {
2344
2355
  const { name } = req.params;
2345
- const { provider = 'google', email, createdAt } = req.body;
2356
+ const { provider = 'google', email, createdAt, projectId, tier } = req.body;
2346
2357
 
2347
2358
  const activePlugin = getActiveGooglePlugin();
2348
2359
  const namespace = provider === 'google'
@@ -2357,6 +2368,23 @@ app.put('/api/auth/pool/:name/metadata', (req, res) => {
2357
2368
  if (createdAt !== undefined) metadata[namespace][name].createdAt = createdAt;
2358
2369
 
2359
2370
  savePoolMetadata(metadata);
2371
+
2372
+ // Update physical profile file if needed
2373
+ if (projectId !== undefined || tier !== undefined) {
2374
+ const profileDir = getProfileDir(provider, activePlugin);
2375
+ const profilePath = path.join(profileDir, `${name}.json`);
2376
+ if (fs.existsSync(profilePath)) {
2377
+ try {
2378
+ const content = JSON.parse(fs.readFileSync(profilePath, 'utf8'));
2379
+ if (projectId !== undefined) content.projectId = projectId;
2380
+ if (tier !== undefined) content.tier = tier;
2381
+ atomicWriteFileSync(profilePath, JSON.stringify(content, null, 2));
2382
+ } catch (e) {
2383
+ console.error('[Auth] Failed to update profile file:', e);
2384
+ }
2385
+ }
2386
+ }
2387
+
2360
2388
  res.json({ success: true });
2361
2389
  });
2362
2390
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-studio-server",
3
- "version": "1.12.5",
3
+ "version": "1.12.7",
4
4
  "description": "Backend server for OpenCode Studio - manages opencode configurations",
5
5
  "main": "index.js",
6
6
  "bin": {