opencode-studio-server 1.14.7 → 1.15.0

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.
package/index.js CHANGED
@@ -2008,11 +2008,41 @@ function importCurrentGoogleAuthToPool() {
2008
2008
  }
2009
2009
 
2010
2010
  function syncAntigravityPool() {
2011
- const accounts = listAntigravityAccounts();
2012
2011
  const namespace = 'google.antigravity';
2013
2012
  const profileDir = path.join(AUTH_PROFILES_DIR, namespace);
2014
2013
 
2015
- if (!accounts.length) {
2014
+ // Collect accounts from multiple sources
2015
+ const allAccounts = [];
2016
+
2017
+ // Source 1: antigravity-accounts.json (antigravity plugin format)
2018
+ const antigravityAccounts = listAntigravityAccounts();
2019
+ antigravityAccounts.forEach(acc => {
2020
+ if (acc.email) allAccounts.push({ email: acc.email, source: 'antigravity' });
2021
+ });
2022
+
2023
+ // Source 2: CLIProxyAPI auth directory (~/.cli-proxy-api/)
2024
+ const CLIPROXY_AUTH_DIR = path.join(HOME_DIR, '.cli-proxy-api');
2025
+ if (fs.existsSync(CLIPROXY_AUTH_DIR)) {
2026
+ try {
2027
+ const files = fs.readdirSync(CLIPROXY_AUTH_DIR).filter(f => f.endsWith('.json') && f.startsWith('antigravity-'));
2028
+ files.forEach(f => {
2029
+ // Format: antigravity-email_at_gmail_com.json
2030
+ const parts = f.replace('.json', '').split('-');
2031
+ if (parts.length > 1) {
2032
+ const emailPart = parts.slice(1).join('-');
2033
+ // Convert underscore notation back to email
2034
+ const email = emailPart.replace(/_/g, '.').replace('.gmail.com', '@gmail.com').replace('.googlemail.com', '@googlemail.com');
2035
+ if (email && !allAccounts.find(a => a.email === email)) {
2036
+ allAccounts.push({ email, source: 'cliproxy', file: f });
2037
+ }
2038
+ }
2039
+ });
2040
+ } catch (e) {
2041
+ console.error('[Pool] Error reading CLIProxy auth dir:', e.message);
2042
+ }
2043
+ }
2044
+
2045
+ if (!allAccounts.length) {
2016
2046
  return;
2017
2047
  }
2018
2048
 
@@ -2022,12 +2052,12 @@ function syncAntigravityPool() {
2022
2052
  if (!metadata[namespace]) metadata[namespace] = {};
2023
2053
 
2024
2054
  const seen = new Set();
2025
- accounts.forEach((account, idx) => {
2055
+ allAccounts.forEach((account, idx) => {
2026
2056
  const name = account.email || `account-${idx + 1}`;
2027
2057
  seen.add(name);
2028
2058
  const profilePath = path.join(profileDir, `${name}.json`);
2029
2059
  if (!fs.existsSync(profilePath)) {
2030
- atomicWriteFileSync(profilePath, JSON.stringify({ email: account.email }, null, 2));
2060
+ atomicWriteFileSync(profilePath, JSON.stringify({ email: account.email, source: account.source }, null, 2));
2031
2061
  }
2032
2062
  if (!metadata[namespace][name]) {
2033
2063
  metadata[namespace][name] = {
@@ -2039,15 +2069,8 @@ function syncAntigravityPool() {
2039
2069
  }
2040
2070
  });
2041
2071
 
2042
- const profileFiles = fs.existsSync(profileDir) ? fs.readdirSync(profileDir).filter(f => f.endsWith('.json')) : [];
2043
- profileFiles.forEach(file => {
2044
- const name = file.replace('.json', '');
2045
- if (!seen.has(name)) {
2046
- fs.unlinkSync(path.join(profileDir, file));
2047
- if (metadata[namespace]?.[name]) delete metadata[namespace][name];
2048
- }
2049
- });
2050
-
2072
+ // Don't delete profiles that aren't in current sources - they might have been manually added
2073
+ // Only update metadata for accounts we found
2051
2074
  savePoolMetadata(metadata);
2052
2075
  }
2053
2076
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-studio-server",
3
- "version": "1.14.7",
3
+ "version": "1.15.0",
4
4
  "description": "Backend server for OpenCode Studio - manages opencode configurations",
5
5
  "main": "index.js",
6
6
  "bin": {
package/proxy-manager.js CHANGED
@@ -185,11 +185,28 @@ const runLogin = async (provider) => {
185
185
  };
186
186
  };
187
187
 
188
+ const listAccounts = () => {
189
+ if (!fs.existsSync(PROXY_AUTH_DIR)) return [];
190
+ try {
191
+ return fs.readdirSync(PROXY_AUTH_DIR)
192
+ .filter(f => f.endsWith('.json'))
193
+ .map(f => {
194
+ const parts = f.replace('.json', '').split('-');
195
+ const provider = parts[0];
196
+ const email = parts.slice(1).join('-').replace(/_/g, '.').replace('.gmail.com', '@gmail.com');
197
+ return { id: f, provider, email: email || f };
198
+ });
199
+ } catch {
200
+ return [];
201
+ }
202
+ };
203
+
188
204
  module.exports = {
189
205
  startProxy,
190
206
  stopProxy,
191
207
  getStatus,
192
208
  loadProxyConfig,
193
209
  saveProxyConfig,
194
- runLogin
210
+ runLogin,
211
+ listAccounts
195
212
  };