polydev-ai 1.8.12 → 1.8.14

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/lib/cliManager.js CHANGED
@@ -183,6 +183,7 @@ class CLIManager {
183
183
  }
184
184
 
185
185
  let authenticated = false;
186
+ let quotaExhausted = false;
186
187
 
187
188
  // For Claude Code, skip command-based auth check and use file-based detection directly
188
189
  // This avoids the recursion issue when running from within Claude Code
@@ -211,6 +212,12 @@ class CLIManager {
211
212
 
212
213
  authenticated = this.parseAuthenticationStatus(provider.id, authOutput);
213
214
 
215
+ // Check for quota exhaustion (authenticated but rate limited)
216
+ if (provider.id === 'gemini_cli') {
217
+ quotaExhausted = authOutput.includes('exhausted your daily quota') ||
218
+ authOutput.includes('quota') && authOutput.includes('exhausted');
219
+ }
220
+
214
221
  } catch (authError) {
215
222
  if (process.env.POLYDEV_CLI_DEBUG) {
216
223
  console.log(`[CLI Debug] Auth check failed for ${provider.id}:`, authError);
@@ -262,6 +269,7 @@ This is a known issue with @google/gemini-cli@0.3.4 and older Node.js versions.`
262
269
  return {
263
270
  available: true,
264
271
  authenticated,
272
+ quota_exhausted: quotaExhausted,
265
273
  version,
266
274
  path: cliPath,
267
275
  last_checked: new Date(),
@@ -369,9 +377,22 @@ This is a known issue with @google/gemini-cli@0.3.4 and older Node.js versions.`
369
377
  return false; // CLI is broken due to Node.js compatibility
370
378
  }
371
379
 
372
- return !authOutput.includes('not authenticated') &&
373
- !authOutput.includes('please login') &&
374
- (authOutput.includes('authenticated') || authOutput.includes('logged in'));
380
+ // Check for positive auth indicators
381
+ // Gemini CLI outputs "Loaded cached credentials" when authenticated
382
+ const hasCredentials = authOutput.toLowerCase().includes('cached credentials') ||
383
+ authOutput.toLowerCase().includes('loaded cached');
384
+ const hasAuth = authOutput.includes('authenticated') || authOutput.includes('logged in');
385
+
386
+ // Quota exhaustion still means authenticated (just rate limited)
387
+ const hasQuotaError = authOutput.includes('exhausted your daily quota') ||
388
+ authOutput.includes('quota');
389
+
390
+ // Not authenticated indicators
391
+ const notAuth = authOutput.includes('not authenticated') ||
392
+ authOutput.includes('please login') ||
393
+ authOutput.includes('authentication required');
394
+
395
+ return !notAuth && (hasCredentials || hasAuth || hasQuotaError);
375
396
 
376
397
  default:
377
398
  return authOutput.includes('authenticated') || authOutput.includes('logged in');
@@ -424,6 +445,19 @@ This is a known issue with @google/gemini-cli@0.3.4 and older Node.js versions.`
424
445
  };
425
446
  }
426
447
 
448
+ // Check if CLI has quota exhausted - skip and suggest API fallback
449
+ if (providerStatus.quota_exhausted) {
450
+ console.log(`[Polydev CLI] ${provider.name} has exhausted daily quota, skipping CLI (use API fallback)`);
451
+ return {
452
+ success: false,
453
+ error: `${provider.name} has exhausted daily quota. Use API fallback.`,
454
+ error_code: 'QUOTA_EXHAUSTED',
455
+ latency_ms: Date.now() - startTime,
456
+ provider: providerId,
457
+ timestamp: new Date()
458
+ };
459
+ }
460
+
427
461
  // Log model being used
428
462
  if (model) {
429
463
  console.log(`[Polydev CLI] Using model for ${providerId}: ${model}`);
@@ -598,6 +632,22 @@ This is a known issue with @google/gemini-cli@0.3.4 and older Node.js versions.`
598
632
  }
599
633
 
600
634
  lastErrorMessage = result.error;
635
+
636
+ // Check for quota exhaustion error during execution
637
+ const combinedOutput = ((result.stdout || '') + ' ' + (result.stderr || '') + ' ' + (result.error || '')).toLowerCase();
638
+ if (combinedOutput.includes('exhausted') && combinedOutput.includes('quota') ||
639
+ combinedOutput.includes('rate limit') ||
640
+ combinedOutput.includes('too many requests')) {
641
+ console.log(`[Polydev CLI] ${providerId} quota/rate limit error detected during execution`);
642
+ return {
643
+ success: false,
644
+ error: `${provider.name} quota/rate limit exceeded. Use API fallback.`,
645
+ error_code: 'QUOTA_EXHAUSTED',
646
+ latency_ms: Date.now() - startTime,
647
+ provider: providerId,
648
+ timestamp: new Date()
649
+ };
650
+ }
601
651
  } catch (error) {
602
652
  lastErrorMessage = error instanceof Error ? error.message : String(error);
603
653
 
@@ -559,6 +559,11 @@ class StdioMCPWrapper {
559
559
  for (const providerId of priorityOrder) {
560
560
  const status = results[providerId];
561
561
  if (status && status.available && status.authenticated) {
562
+ // Skip providers with quota exhausted - they'll use API fallback
563
+ if (status.quota_exhausted) {
564
+ console.error(`[Stdio Wrapper] Skipping ${providerId} - quota exhausted, will use API fallback`);
565
+ continue;
566
+ }
562
567
  availableProviders.push(providerId);
563
568
  }
564
569
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "polydev-ai",
3
- "version": "1.8.12",
3
+ "version": "1.8.14",
4
4
  "description": "Agentic workflow assistant with CLI integration - get diverse perspectives from multiple LLMs when stuck or need enhanced reasoning",
5
5
  "keywords": [
6
6
  "mcp",