agentgui 1.0.201 → 1.0.203

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/package.json +2 -2
  2. package/server.js +40 -19
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentgui",
3
- "version": "1.0.201",
3
+ "version": "1.0.203",
4
4
  "description": "Multi-agent ACP client with real-time communication",
5
5
  "type": "module",
6
6
  "main": "server.js",
@@ -27,7 +27,7 @@
27
27
  "better-sqlite3": "^12.6.2",
28
28
  "busboy": "^1.6.0",
29
29
  "express": "^5.2.1",
30
- "fsbrowse": "^0.2.13",
30
+ "fsbrowse": "^0.2.17",
31
31
  "google-auth-library": "^10.5.0",
32
32
  "onnxruntime-node": "^1.24.1",
33
33
  "webtalk": "github:AnEntrypoint/webtalk",
package/server.js CHANGED
@@ -149,7 +149,7 @@ expressApp.use(BASE_URL + '/files/:conversationId', (req, res, next) => {
149
149
  return res.status(404).json({ error: 'Conversation not found or no working directory' });
150
150
  }
151
151
  // Create a fresh fsbrowse router for this conversation's directory
152
- const router = fsbrowse({ baseDir: conv.workingDirectory });
152
+ const router = fsbrowse({ baseDir: conv.workingDirectory, name: 'Files' });
153
153
  // Strip the conversationId param from the path before passing to fsbrowse
154
154
  req.baseUrl = BASE_URL + '/files/' + req.params.conversationId;
155
155
  router(req, res, next);
@@ -189,36 +189,55 @@ const GEMINI_SCOPES = [
189
189
  'https://www.googleapis.com/auth/userinfo.profile',
190
190
  ];
191
191
 
192
- function getGeminiOAuthCreds() {
192
+ function extractOAuthFromFile(oauth2Path) {
193
193
  try {
194
- const geminiPath = execSync('which gemini', { encoding: 'utf8' }).trim();
195
- const realPath = fs.realpathSync(geminiPath);
196
- const pkgRoot = path.resolve(path.dirname(realPath), '..');
197
- const oauth2Path = path.join(pkgRoot, 'node_modules', '@google', 'gemini-cli-core', 'dist', 'src', 'code_assist', 'oauth2.js');
198
194
  const src = fs.readFileSync(oauth2Path, 'utf8');
199
195
  const idMatch = src.match(/OAUTH_CLIENT_ID\s*=\s*['"]([^'"]+)['"]/);
200
196
  const secretMatch = src.match(/OAUTH_CLIENT_SECRET\s*=\s*['"]([^'"]+)['"]/);
201
197
  if (idMatch && secretMatch) return { clientId: idMatch[1], clientSecret: secretMatch[1] };
202
198
  } catch {}
199
+ return null;
200
+ }
201
+
202
+ function getGeminiOAuthCreds() {
203
+ const oauthRelPath = path.join('node_modules', '@google', 'gemini-cli-core', 'dist', 'src', 'code_assist', 'oauth2.js');
204
+ try {
205
+ const geminiPath = execSync('which gemini', { encoding: 'utf8' }).trim();
206
+ const realPath = fs.realpathSync(geminiPath);
207
+ const pkgRoot = path.resolve(path.dirname(realPath), '..');
208
+ const result = extractOAuthFromFile(path.join(pkgRoot, oauthRelPath));
209
+ if (result) return result;
210
+ } catch (e) {
211
+ console.error('[gemini-oauth] which gemini lookup failed:', e.message);
212
+ }
203
213
  try {
204
- const npmCacheDirs = [
205
- path.join(os.homedir(), '.npm', '_npx'),
206
- path.join(os.homedir(), '.cache', '.npm', '_npx'),
207
- process.env.NPM_CACHE ? path.join(process.env.NPM_CACHE, '_npx') : null,
208
- ].filter(Boolean);
214
+ const npmCacheDirs = new Set();
215
+ const addDir = (d) => { if (d) npmCacheDirs.add(path.join(d, '_npx')); };
216
+ addDir(path.join(os.homedir(), '.npm'));
217
+ addDir(path.join(os.homedir(), '.cache', '.npm'));
218
+ if (process.env.NPM_CACHE) addDir(process.env.NPM_CACHE);
219
+ if (process.env.npm_config_cache) addDir(process.env.npm_config_cache);
220
+ try { addDir(execSync('npm config get cache', { encoding: 'utf8', timeout: 5000 }).trim()); } catch {}
209
221
  for (const cacheDir of npmCacheDirs) {
210
222
  if (!fs.existsSync(cacheDir)) continue;
211
223
  for (const d of fs.readdirSync(cacheDir).filter(d => !d.startsWith('.'))) {
212
- const oauth2Path = path.join(cacheDir, d, 'node_modules', '@google', 'gemini-cli-core', 'dist', 'src', 'code_assist', 'oauth2.js');
213
- if (fs.existsSync(oauth2Path)) {
214
- const src = fs.readFileSync(oauth2Path, 'utf8');
215
- const idMatch = src.match(/OAUTH_CLIENT_ID\s*=\s*['"]([^'"]+)['"]/);
216
- const secretMatch = src.match(/OAUTH_CLIENT_SECRET\s*=\s*['"]([^'"]+)['"]/);
217
- if (idMatch && secretMatch) return { clientId: idMatch[1], clientSecret: secretMatch[1] };
218
- }
224
+ const result = extractOAuthFromFile(path.join(cacheDir, d, oauthRelPath));
225
+ if (result) return result;
219
226
  }
220
227
  }
221
- } catch {}
228
+ } catch (e) {
229
+ console.error('[gemini-oauth] npm cache scan failed:', e.message);
230
+ }
231
+ try {
232
+ const found = execSync('find / -path "*/gemini-cli-core/dist/src/code_assist/oauth2.js" -maxdepth 10 2>/dev/null | head -1', { encoding: 'utf8', timeout: 10000 }).trim();
233
+ if (found) {
234
+ const result = extractOAuthFromFile(found);
235
+ if (result) return result;
236
+ }
237
+ } catch (e) {
238
+ console.error('[gemini-oauth] filesystem search failed:', e.message);
239
+ }
240
+ console.error('[gemini-oauth] Could not find Gemini CLI OAuth credentials in any known location');
222
241
  return null;
223
242
  }
224
243
  const GEMINI_DIR = path.join(os.homedir(), '.gemini');
@@ -1077,6 +1096,7 @@ const server = http.createServer(async (req, res) => {
1077
1096
  const authUrl = await startGeminiOAuth();
1078
1097
  sendJSON(req, res, 200, { authUrl });
1079
1098
  } catch (e) {
1099
+ console.error('[gemini-oauth] /api/gemini-oauth/start failed:', e);
1080
1100
  sendJSON(req, res, 500, { error: e.message });
1081
1101
  }
1082
1102
  return;
@@ -1118,6 +1138,7 @@ const server = http.createServer(async (req, res) => {
1118
1138
  sendJSON(req, res, 200, { ok: true, agentId, authUrl });
1119
1139
  return;
1120
1140
  } catch (e) {
1141
+ console.error('[gemini-oauth] /api/agents/gemini/auth failed:', e);
1121
1142
  sendJSON(req, res, 500, { error: e.message });
1122
1143
  return;
1123
1144
  }