minovative-mind-cli 2.13.1 → 2.13.3

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.
@@ -178,6 +178,15 @@ export class ProxyClient {
178
178
  }
179
179
  if (!response.ok) {
180
180
  const errorData = await response.json().catch(() => ({}));
181
+ const errorMsg = JSON.stringify(errorData) || response.statusText;
182
+ if (errorMsg.includes('is expired') || errorMsg.includes('Cache content')) {
183
+ if (attempt < MAX_RETRIES) {
184
+ debugLog(`Gemini Context Cache expired on server. Retrying request to refresh cache (Attempt ${attempt + 1}/${MAX_RETRIES})...`);
185
+ await delay(500, abortSignal);
186
+ attempt++;
187
+ continue retryLoop;
188
+ }
189
+ }
181
190
  throw new Error(`Proxy error ${response.status}: ${errorData.error || response.statusText}`);
182
191
  }
183
192
  if (!response.body) {
@@ -269,6 +278,8 @@ export class ProxyClient {
269
278
  err.name = 'AbortError';
270
279
  throw err;
271
280
  }
281
+ const isCacheExpired = streamError.message?.includes('is expired') ||
282
+ streamError.message?.includes('Cache content');
272
283
  if (streamError.message?.includes('429') ||
273
284
  streamError.message?.includes('502') ||
274
285
  streamError.message?.includes('503') ||
@@ -276,13 +287,18 @@ export class ProxyClient {
276
287
  streamError.message?.includes('504') ||
277
288
  streamError.message?.includes('Bad Gateway') ||
278
289
  streamError.message?.includes('RESOURCE_EXHAUSTED') ||
279
- streamError.message?.includes('Too Many Requests')) {
290
+ streamError.message?.includes('Too Many Requests') ||
291
+ isCacheExpired) {
280
292
  if (attempt < MAX_RETRIES) {
281
- const exponentialDelay = Math.min(MAX_DELAY_MS, BASE_DELAY_MS * Math.pow(2, attempt));
293
+ const exponentialDelay = isCacheExpired
294
+ ? 500
295
+ : Math.min(MAX_DELAY_MS, BASE_DELAY_MS * Math.pow(2, attempt));
282
296
  const delayTime = Math.round(exponentialDelay * (1.0 + Math.random() * 0.5));
283
297
  if (isDebugOn()) {
284
298
  process.stdout.write('\n');
285
- console.warn(`Server error or rate limit hit during stream. Retrying in ${(delayTime / 1000).toFixed(1)}s... (Attempt ${attempt + 1}/${MAX_RETRIES})`);
299
+ console.warn(isCacheExpired
300
+ ? `Gemini Context Cache expired on server. Refreshing and retrying in ${(delayTime / 1000).toFixed(1)}s... (Attempt ${attempt + 1}/${MAX_RETRIES})`
301
+ : `Server error or rate limit hit during stream. Retrying in ${(delayTime / 1000).toFixed(1)}s... (Attempt ${attempt + 1}/${MAX_RETRIES})`);
286
302
  }
287
303
  await delay(delayTime, abortSignal);
288
304
  if (abortSignal?.aborted) {
@@ -400,7 +416,15 @@ export class ProxyClient {
400
416
  catch {
401
417
  // ignore parsing error
402
418
  }
403
- const errorMsg = errorData.error?.message || response.statusText;
419
+ const errorMsg = errorData.error?.message || JSON.stringify(errorData) || response.statusText;
420
+ if (errorMsg.includes('is expired') || errorMsg.includes('Cache content')) {
421
+ if (attempt < MAX_RETRIES) {
422
+ debugLog(`BYOK Gemini Context Cache expired on server. Retrying request to refresh cache (Attempt ${attempt + 1}/${MAX_RETRIES})...`);
423
+ await delay(500, abortSignal);
424
+ attempt++;
425
+ continue retryLoop;
426
+ }
427
+ }
404
428
  if (response.status === 401 ||
405
429
  response.status === 403 ||
406
430
  errorMsg.includes('API_KEY_INVALID') ||
@@ -484,6 +508,8 @@ export class ProxyClient {
484
508
  err.name = 'AbortError';
485
509
  throw err;
486
510
  }
511
+ const isCacheExpired = streamError.message?.includes('is expired') ||
512
+ streamError.message?.includes('Cache content');
487
513
  if (streamError.message?.includes('429') ||
488
514
  streamError.message?.includes('502') ||
489
515
  streamError.message?.includes('503') ||
@@ -491,13 +517,18 @@ export class ProxyClient {
491
517
  streamError.message?.includes('504') ||
492
518
  streamError.message?.includes('Bad Gateway') ||
493
519
  streamError.message?.includes('RESOURCE_EXHAUSTED') ||
494
- streamError.message?.includes('Too Many Requests')) {
520
+ streamError.message?.includes('Too Many Requests') ||
521
+ isCacheExpired) {
495
522
  if (attempt < MAX_RETRIES) {
496
- const exponentialDelay = Math.min(MAX_DELAY_MS, BASE_DELAY_MS * Math.pow(2, attempt));
523
+ const exponentialDelay = isCacheExpired
524
+ ? 500
525
+ : Math.min(MAX_DELAY_MS, BASE_DELAY_MS * Math.pow(2, attempt));
497
526
  const delayTime = Math.round(exponentialDelay * (1.0 + Math.random() * 0.5));
498
527
  if (isDebugOn()) {
499
528
  process.stdout.write('\n');
500
- console.warn(`Server error or rate limit hit during BYOK stream. Retrying in ${(delayTime / 1000).toFixed(1)}s... (Attempt ${attempt + 1}/${MAX_RETRIES})`);
529
+ console.warn(isCacheExpired
530
+ ? `BYOK Gemini Context Cache expired on server. Refreshing and retrying in ${(delayTime / 1000).toFixed(1)}s... (Attempt ${attempt + 1}/${MAX_RETRIES})`
531
+ : `Server error or rate limit hit during BYOK stream. Retrying in ${(delayTime / 1000).toFixed(1)}s... (Attempt ${attempt + 1}/${MAX_RETRIES})`);
501
532
  }
502
533
  await delay(delayTime, abortSignal);
503
534
  if (abortSignal?.aborted) {
@@ -201,5 +201,5 @@
201
201
  ]
202
202
  }
203
203
  },
204
- "version": "2.13.1"
204
+ "version": "2.13.3"
205
205
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "minovative-mind-cli",
3
3
  "description": "An automated AI agent powered by Vertex AI that helps you write software",
4
- "version": "2.13.1",
4
+ "version": "2.13.3",
5
5
  "author": "Daniel Ward",
6
6
  "bin": {
7
7
  "minovative-mind-cli": "bin/run.js"