@google/gemini-cli 0.65.0-preview.0 → 0.66.0-nightly.20261017.ged96faedf

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 (75) hide show
  1. package/README.md +21 -56
  2. package/bundle/{chunk-NL7ZHGCH.js → chunk-464WBVYM.js} +1 -1
  3. package/bundle/{chunk-QJK54DSE.js → chunk-5VQUE3OF.js} +1 -1
  4. package/bundle/{chunk-VF5WQSOE.js → chunk-7ARQMEMX.js} +1 -1
  5. package/bundle/{chunk-2WVLIJA5.js → chunk-BUG4N6U5.js} +145 -77
  6. package/bundle/{chunk-F6AJM4WN.js → chunk-DPV3ZEOC.js} +3 -3
  7. package/bundle/{chunk-GSQEBEGC.js → chunk-ERBSM2HU.js} +3 -3
  8. package/bundle/{chunk-WTRK3NVX.js → chunk-GEUFOF2X.js} +106 -1500
  9. package/bundle/{chunk-V2R74WAG.js → chunk-H4U2CWBQ.js} +151 -81
  10. package/bundle/chunk-HDP6V6JI.js +1956 -0
  11. package/bundle/{chunk-RPHDSDL6.js → chunk-IDCWFZU3.js} +1 -1
  12. package/bundle/{chunk-SN7QZKXC.js → chunk-IGOTAEJY.js} +170 -1551
  13. package/bundle/chunk-J5QPCO3J.js +101859 -0
  14. package/bundle/{chunk-H2CZXS7F.js → chunk-JY3DYBJT.js} +1 -1
  15. package/bundle/{chunk-HLOOE7YN.js → chunk-LDGJJCVW.js} +9 -8
  16. package/bundle/chunk-MH4KAY5W.js +512 -0
  17. package/bundle/{chunk-LLE5Z636.js → chunk-NAPT3FAL.js} +106 -1500
  18. package/bundle/chunk-NOSWGXRT.js +1956 -0
  19. package/bundle/{chunk-43EXRO7A.js → chunk-NU74STQ5.js} +145 -77
  20. package/bundle/{chunk-K7NOVQ6G.js → chunk-QCWGLPCO.js} +376 -231
  21. package/bundle/{chunk-WGL5FJOS.js → chunk-QF3ALSJN.js} +3 -3
  22. package/bundle/{chunk-K4G5D5ZZ.js → chunk-R4KPURFC.js} +1 -1
  23. package/bundle/chunk-R6XDLHLP.js +1956 -0
  24. package/bundle/chunk-R7UPATQC.js +1956 -0
  25. package/bundle/chunk-RACMC24X.js +118 -0
  26. package/bundle/{chunk-4JGVVJGK.js → chunk-RE4V6I3G.js} +1 -1
  27. package/bundle/{chunk-S7BCRBI4.js → chunk-UTTFPWGQ.js} +1 -1
  28. package/bundle/chunk-VXYA6LA4.js +1571 -0
  29. package/bundle/chunk-XY2QSBID.js +17603 -0
  30. package/bundle/{chunk-K7AA35SP.js → chunk-YOI4DS3V.js} +365 -230
  31. package/bundle/chunk-YP27UYI4.js +154 -0
  32. package/bundle/{chunk-TP236FKO.js → chunk-YPLMNSM4.js} +8243 -15166
  33. package/bundle/chunk-ZFQ347ZN.js +402181 -0
  34. package/bundle/{cleanup-HPADDONA.js → cleanup-6FAZDCL3.js} +2 -2
  35. package/bundle/{cleanup-JOMSXKMP.js → cleanup-GNZLZG55.js} +2 -2
  36. package/bundle/{cleanup-LYRJHMMO.js → cleanup-RX3AC5ET.js} +2 -2
  37. package/bundle/cleanup-WAU2KYGS.js +32 -0
  38. package/bundle/{core-NCJTYARO.js → core-AGGXDQOT.js} +13 -1
  39. package/bundle/{devtoolsService-WP2OPVPB.js → devtoolsService-6XOCGTLC.js} +2 -2
  40. package/bundle/{devtoolsService-JFJBTZ4B.js → devtoolsService-FBTSVQ57.js} +4 -3
  41. package/bundle/{devtoolsService-HIZA3JGR.js → devtoolsService-UO6ZB72B.js} +2 -2
  42. package/bundle/devtoolsService-W5QGZ3SW.js +4359 -0
  43. package/bundle/{dist-GQKLLBDW.js → dist-2ELAEESC.js} +13 -1
  44. package/bundle/{core-IVQAI4S6.js → dist-2R7C2WHA.js} +13 -1
  45. package/bundle/dist-PALH7PJS.js +2280 -0
  46. package/bundle/docs/changelogs/index.md +22 -0
  47. package/bundle/docs/changelogs/latest.md +64 -54
  48. package/bundle/docs/changelogs/preview.md +91 -55
  49. package/bundle/docs/reference/configuration.md +8 -3
  50. package/bundle/docs/reference/keyboard-shortcuts.md +18 -4
  51. package/bundle/{gemini-5TUKZVGS.js → gemini-6MH55Y7F.js} +37 -18
  52. package/bundle/{gemini-7CHJYSHM.js → gemini-DOXUDJDY.js} +37 -18
  53. package/bundle/{gemini-546WMAHG.js → gemini-OHYXI52N.js} +237 -202
  54. package/bundle/gemini-OUEDCH4P.js +17970 -0
  55. package/bundle/gemini.js +14 -15
  56. package/bundle/{interactiveCli-E3PUPYMZ.js → interactiveCli-7LIKGDTJ.js} +1061 -989
  57. package/bundle/{interactiveCli-5XIAIY74.js → interactiveCli-EGQYN3KR.js} +1371 -1280
  58. package/bundle/{interactiveCli-L4PK7YY3.js → interactiveCli-TG7PGV4V.js} +1061 -989
  59. package/bundle/interactiveCli-YEXCUIFZ.js +35601 -0
  60. package/bundle/{liteRtServerManager-JCTYJBV5.js → liteRtServerManager-KAPXZ3EU.js} +4 -4
  61. package/bundle/{liteRtServerManager-JERG6KYC.js → liteRtServerManager-MSJIWMWP.js} +4 -4
  62. package/bundle/{liteRtServerManager-22ISMNN2.js → liteRtServerManager-PD2N3GLD.js} +4 -4
  63. package/bundle/liteRtServerManager-X5SCFYXM.js +65 -0
  64. package/bundle/{oauth2-provider-XRUER2XR.js → oauth2-provider-IUN6Z4IO.js} +1 -1
  65. package/bundle/{oauth2-provider-477UJQX6.js → oauth2-provider-MKJIQNWP.js} +41 -79
  66. package/bundle/{oauth2-provider-MKWWBW4K.js → oauth2-provider-RMF7U2UN.js} +1 -1
  67. package/bundle/oauth2-provider-ZM5GWCNX.js +273 -0
  68. package/bundle/{start-MVIPJNQ5.js → start-5GIUIER3.js} +6 -6
  69. package/bundle/{start-RZWSVT55.js → start-APIVGXZ3.js} +6 -6
  70. package/bundle/{start-AGMBPY3O.js → start-GJ4TH4KZ.js} +6 -6
  71. package/bundle/start-WDS52ZNE.js +18 -0
  72. package/package.json +1 -1
  73. package/bundle/chunk-4DCA4L53.js +0 -425
  74. package/bundle/chunk-BFIV7GTA.js +0 -425
  75. package/bundle/chunk-V72FRESD.js +0 -425
@@ -0,0 +1,1956 @@
1
+ const require = (await import('node:module')).createRequire(import.meta.url); const __chunk_filename = (await import('node:url')).fileURLToPath(import.meta.url); const __chunk_dirname = (await import('node:path')).dirname(__chunk_filename);
2
+ import {
3
+ runExitCleanup
4
+ } from "./chunk-YP27UYI4.js";
5
+ import {
6
+ RELEASE_CHANNEL_STABILITY,
7
+ debugLogger,
8
+ getChannelFromVersion,
9
+ getPackageJson,
10
+ isGitRepository,
11
+ require_clean,
12
+ require_constants,
13
+ require_debug,
14
+ require_identifiers,
15
+ require_parse,
16
+ require_parse_options,
17
+ require_re,
18
+ require_semver,
19
+ require_valid
20
+ } from "./chunk-QCWGLPCO.js";
21
+ import {
22
+ __commonJS,
23
+ __toESM
24
+ } from "./chunk-34MYV7JD.js";
25
+
26
+ // node_modules/semver/functions/inc.js
27
+ var require_inc = __commonJS({
28
+ "node_modules/semver/functions/inc.js"(exports, module) {
29
+ "use strict";
30
+ var SemVer = require_semver();
31
+ var inc = (version, release, options, identifier, identifierBase) => {
32
+ if (typeof options === "string") {
33
+ identifierBase = identifier;
34
+ identifier = options;
35
+ options = void 0;
36
+ }
37
+ try {
38
+ return new SemVer(
39
+ version instanceof SemVer ? version.version : version,
40
+ options
41
+ ).inc(release, identifier, identifierBase).version;
42
+ } catch (er) {
43
+ return null;
44
+ }
45
+ };
46
+ module.exports = inc;
47
+ }
48
+ });
49
+
50
+ // node_modules/semver/functions/diff.js
51
+ var require_diff = __commonJS({
52
+ "node_modules/semver/functions/diff.js"(exports, module) {
53
+ "use strict";
54
+ var parse = require_parse();
55
+ var diff = (version1, version2) => {
56
+ const v1 = parse(version1, null, true);
57
+ const v2 = parse(version2, null, true);
58
+ const comparison = v1.compare(v2);
59
+ if (comparison === 0) {
60
+ return null;
61
+ }
62
+ const v1Higher = comparison > 0;
63
+ const highVersion = v1Higher ? v1 : v2;
64
+ const lowVersion = v1Higher ? v2 : v1;
65
+ const highHasPre = !!highVersion.prerelease.length;
66
+ const lowHasPre = !!lowVersion.prerelease.length;
67
+ if (lowHasPre && !highHasPre) {
68
+ if (!lowVersion.patch && !lowVersion.minor) {
69
+ return "major";
70
+ }
71
+ if (lowVersion.compareMain(highVersion) === 0) {
72
+ if (lowVersion.minor && !lowVersion.patch) {
73
+ return "minor";
74
+ }
75
+ return "patch";
76
+ }
77
+ }
78
+ const prefix = highHasPre ? "pre" : "";
79
+ if (v1.major !== v2.major) {
80
+ return prefix + "major";
81
+ }
82
+ if (v1.minor !== v2.minor) {
83
+ return prefix + "minor";
84
+ }
85
+ if (v1.patch !== v2.patch) {
86
+ return prefix + "patch";
87
+ }
88
+ return "prerelease";
89
+ };
90
+ module.exports = diff;
91
+ }
92
+ });
93
+
94
+ // node_modules/semver/functions/major.js
95
+ var require_major = __commonJS({
96
+ "node_modules/semver/functions/major.js"(exports, module) {
97
+ "use strict";
98
+ var SemVer = require_semver();
99
+ var major = (a, loose) => new SemVer(a, loose).major;
100
+ module.exports = major;
101
+ }
102
+ });
103
+
104
+ // node_modules/semver/functions/minor.js
105
+ var require_minor = __commonJS({
106
+ "node_modules/semver/functions/minor.js"(exports, module) {
107
+ "use strict";
108
+ var SemVer = require_semver();
109
+ var minor = (a, loose) => new SemVer(a, loose).minor;
110
+ module.exports = minor;
111
+ }
112
+ });
113
+
114
+ // node_modules/semver/functions/patch.js
115
+ var require_patch = __commonJS({
116
+ "node_modules/semver/functions/patch.js"(exports, module) {
117
+ "use strict";
118
+ var SemVer = require_semver();
119
+ var patch = (a, loose) => new SemVer(a, loose).patch;
120
+ module.exports = patch;
121
+ }
122
+ });
123
+
124
+ // node_modules/semver/functions/prerelease.js
125
+ var require_prerelease = __commonJS({
126
+ "node_modules/semver/functions/prerelease.js"(exports, module) {
127
+ "use strict";
128
+ var parse = require_parse();
129
+ var prerelease = (version, options) => {
130
+ const parsed = parse(version, options);
131
+ return parsed && parsed.prerelease.length ? parsed.prerelease : null;
132
+ };
133
+ module.exports = prerelease;
134
+ }
135
+ });
136
+
137
+ // node_modules/semver/functions/compare.js
138
+ var require_compare = __commonJS({
139
+ "node_modules/semver/functions/compare.js"(exports, module) {
140
+ "use strict";
141
+ var SemVer = require_semver();
142
+ var compare = (a, b, loose) => new SemVer(a, loose).compare(new SemVer(b, loose));
143
+ module.exports = compare;
144
+ }
145
+ });
146
+
147
+ // node_modules/semver/functions/rcompare.js
148
+ var require_rcompare = __commonJS({
149
+ "node_modules/semver/functions/rcompare.js"(exports, module) {
150
+ "use strict";
151
+ var compare = require_compare();
152
+ var rcompare = (a, b, loose) => compare(b, a, loose);
153
+ module.exports = rcompare;
154
+ }
155
+ });
156
+
157
+ // node_modules/semver/functions/compare-loose.js
158
+ var require_compare_loose = __commonJS({
159
+ "node_modules/semver/functions/compare-loose.js"(exports, module) {
160
+ "use strict";
161
+ var compare = require_compare();
162
+ var compareLoose = (a, b) => compare(a, b, true);
163
+ module.exports = compareLoose;
164
+ }
165
+ });
166
+
167
+ // node_modules/semver/functions/compare-build.js
168
+ var require_compare_build = __commonJS({
169
+ "node_modules/semver/functions/compare-build.js"(exports, module) {
170
+ "use strict";
171
+ var SemVer = require_semver();
172
+ var compareBuild = (a, b, loose) => {
173
+ const versionA = new SemVer(a, loose);
174
+ const versionB = new SemVer(b, loose);
175
+ return versionA.compare(versionB) || versionA.compareBuild(versionB);
176
+ };
177
+ module.exports = compareBuild;
178
+ }
179
+ });
180
+
181
+ // node_modules/semver/functions/sort.js
182
+ var require_sort = __commonJS({
183
+ "node_modules/semver/functions/sort.js"(exports, module) {
184
+ "use strict";
185
+ var compareBuild = require_compare_build();
186
+ var sort = (list, loose) => list.sort((a, b) => compareBuild(a, b, loose));
187
+ module.exports = sort;
188
+ }
189
+ });
190
+
191
+ // node_modules/semver/functions/rsort.js
192
+ var require_rsort = __commonJS({
193
+ "node_modules/semver/functions/rsort.js"(exports, module) {
194
+ "use strict";
195
+ var compareBuild = require_compare_build();
196
+ var rsort = (list, loose) => list.sort((a, b) => compareBuild(b, a, loose));
197
+ module.exports = rsort;
198
+ }
199
+ });
200
+
201
+ // node_modules/semver/functions/gt.js
202
+ var require_gt = __commonJS({
203
+ "node_modules/semver/functions/gt.js"(exports, module) {
204
+ "use strict";
205
+ var compare = require_compare();
206
+ var gt = (a, b, loose) => compare(a, b, loose) > 0;
207
+ module.exports = gt;
208
+ }
209
+ });
210
+
211
+ // node_modules/semver/functions/lt.js
212
+ var require_lt = __commonJS({
213
+ "node_modules/semver/functions/lt.js"(exports, module) {
214
+ "use strict";
215
+ var compare = require_compare();
216
+ var lt = (a, b, loose) => compare(a, b, loose) < 0;
217
+ module.exports = lt;
218
+ }
219
+ });
220
+
221
+ // node_modules/semver/functions/eq.js
222
+ var require_eq = __commonJS({
223
+ "node_modules/semver/functions/eq.js"(exports, module) {
224
+ "use strict";
225
+ var compare = require_compare();
226
+ var eq = (a, b, loose) => compare(a, b, loose) === 0;
227
+ module.exports = eq;
228
+ }
229
+ });
230
+
231
+ // node_modules/semver/functions/neq.js
232
+ var require_neq = __commonJS({
233
+ "node_modules/semver/functions/neq.js"(exports, module) {
234
+ "use strict";
235
+ var compare = require_compare();
236
+ var neq = (a, b, loose) => compare(a, b, loose) !== 0;
237
+ module.exports = neq;
238
+ }
239
+ });
240
+
241
+ // node_modules/semver/functions/gte.js
242
+ var require_gte = __commonJS({
243
+ "node_modules/semver/functions/gte.js"(exports, module) {
244
+ "use strict";
245
+ var compare = require_compare();
246
+ var gte = (a, b, loose) => compare(a, b, loose) >= 0;
247
+ module.exports = gte;
248
+ }
249
+ });
250
+
251
+ // node_modules/semver/functions/lte.js
252
+ var require_lte = __commonJS({
253
+ "node_modules/semver/functions/lte.js"(exports, module) {
254
+ "use strict";
255
+ var compare = require_compare();
256
+ var lte = (a, b, loose) => compare(a, b, loose) <= 0;
257
+ module.exports = lte;
258
+ }
259
+ });
260
+
261
+ // node_modules/semver/functions/cmp.js
262
+ var require_cmp = __commonJS({
263
+ "node_modules/semver/functions/cmp.js"(exports, module) {
264
+ "use strict";
265
+ var eq = require_eq();
266
+ var neq = require_neq();
267
+ var gt = require_gt();
268
+ var gte = require_gte();
269
+ var lt = require_lt();
270
+ var lte = require_lte();
271
+ var cmp = (a, op, b, loose) => {
272
+ switch (op) {
273
+ case "===":
274
+ if (typeof a === "object") {
275
+ a = a.version;
276
+ }
277
+ if (typeof b === "object") {
278
+ b = b.version;
279
+ }
280
+ return a === b;
281
+ case "!==":
282
+ if (typeof a === "object") {
283
+ a = a.version;
284
+ }
285
+ if (typeof b === "object") {
286
+ b = b.version;
287
+ }
288
+ return a !== b;
289
+ case "":
290
+ case "=":
291
+ case "==":
292
+ return eq(a, b, loose);
293
+ case "!=":
294
+ return neq(a, b, loose);
295
+ case ">":
296
+ return gt(a, b, loose);
297
+ case ">=":
298
+ return gte(a, b, loose);
299
+ case "<":
300
+ return lt(a, b, loose);
301
+ case "<=":
302
+ return lte(a, b, loose);
303
+ default:
304
+ throw new TypeError(`Invalid operator: ${op}`);
305
+ }
306
+ };
307
+ module.exports = cmp;
308
+ }
309
+ });
310
+
311
+ // node_modules/semver/functions/coerce.js
312
+ var require_coerce = __commonJS({
313
+ "node_modules/semver/functions/coerce.js"(exports, module) {
314
+ "use strict";
315
+ var SemVer = require_semver();
316
+ var parse = require_parse();
317
+ var { safeRe: re, t } = require_re();
318
+ var coerce = (version, options) => {
319
+ if (version instanceof SemVer) {
320
+ return version;
321
+ }
322
+ if (typeof version === "number") {
323
+ version = String(version);
324
+ }
325
+ if (typeof version !== "string") {
326
+ return null;
327
+ }
328
+ options = options || {};
329
+ let match = null;
330
+ if (!options.rtl) {
331
+ match = version.match(options.includePrerelease ? re[t.COERCEFULL] : re[t.COERCE]);
332
+ } else {
333
+ const coerceRtlRegex = options.includePrerelease ? re[t.COERCERTLFULL] : re[t.COERCERTL];
334
+ let next;
335
+ while ((next = coerceRtlRegex.exec(version)) && (!match || match.index + match[0].length !== version.length)) {
336
+ if (!match || next.index + next[0].length !== match.index + match[0].length) {
337
+ match = next;
338
+ }
339
+ coerceRtlRegex.lastIndex = next.index + next[1].length + next[2].length;
340
+ }
341
+ coerceRtlRegex.lastIndex = -1;
342
+ }
343
+ if (match === null) {
344
+ return null;
345
+ }
346
+ const major = match[2];
347
+ const minor = match[3] || "0";
348
+ const patch = match[4] || "0";
349
+ const prerelease = options.includePrerelease && match[5] ? `-${match[5]}` : "";
350
+ const build = options.includePrerelease && match[6] ? `+${match[6]}` : "";
351
+ return parse(`${major}.${minor}.${patch}${prerelease}${build}`, options);
352
+ };
353
+ module.exports = coerce;
354
+ }
355
+ });
356
+
357
+ // node_modules/semver/internal/lrucache.js
358
+ var require_lrucache = __commonJS({
359
+ "node_modules/semver/internal/lrucache.js"(exports, module) {
360
+ "use strict";
361
+ var LRUCache = class {
362
+ constructor() {
363
+ this.max = 1e3;
364
+ this.map = /* @__PURE__ */ new Map();
365
+ }
366
+ get(key) {
367
+ const value = this.map.get(key);
368
+ if (value === void 0) {
369
+ return void 0;
370
+ } else {
371
+ this.map.delete(key);
372
+ this.map.set(key, value);
373
+ return value;
374
+ }
375
+ }
376
+ delete(key) {
377
+ return this.map.delete(key);
378
+ }
379
+ set(key, value) {
380
+ const deleted = this.delete(key);
381
+ if (!deleted && value !== void 0) {
382
+ if (this.map.size >= this.max) {
383
+ const firstKey = this.map.keys().next().value;
384
+ this.delete(firstKey);
385
+ }
386
+ this.map.set(key, value);
387
+ }
388
+ return this;
389
+ }
390
+ };
391
+ module.exports = LRUCache;
392
+ }
393
+ });
394
+
395
+ // node_modules/semver/classes/range.js
396
+ var require_range = __commonJS({
397
+ "node_modules/semver/classes/range.js"(exports, module) {
398
+ "use strict";
399
+ var SPACE_CHARACTERS = /\s+/g;
400
+ var Range = class _Range {
401
+ constructor(range, options) {
402
+ options = parseOptions(options);
403
+ if (range instanceof _Range) {
404
+ if (range.loose === !!options.loose && range.includePrerelease === !!options.includePrerelease) {
405
+ return range;
406
+ } else {
407
+ return new _Range(range.raw, options);
408
+ }
409
+ }
410
+ if (range instanceof Comparator) {
411
+ this.raw = range.value;
412
+ this.set = [[range]];
413
+ this.formatted = void 0;
414
+ return this;
415
+ }
416
+ this.options = options;
417
+ this.loose = !!options.loose;
418
+ this.includePrerelease = !!options.includePrerelease;
419
+ this.raw = range.trim().replace(SPACE_CHARACTERS, " ");
420
+ this.set = this.raw.split("||").map((r) => this.parseRange(r.trim())).filter((c) => c.length);
421
+ if (!this.set.length) {
422
+ throw new TypeError(`Invalid SemVer Range: ${this.raw}`);
423
+ }
424
+ if (this.set.length > 1) {
425
+ const first = this.set[0];
426
+ this.set = this.set.filter((c) => !isNullSet(c[0]));
427
+ if (this.set.length === 0) {
428
+ this.set = [first];
429
+ } else if (this.set.length > 1) {
430
+ for (const c of this.set) {
431
+ if (c.length === 1 && isAny(c[0])) {
432
+ this.set = [c];
433
+ break;
434
+ }
435
+ }
436
+ }
437
+ }
438
+ this.formatted = void 0;
439
+ }
440
+ get range() {
441
+ if (this.formatted === void 0) {
442
+ this.formatted = "";
443
+ for (let i = 0; i < this.set.length; i++) {
444
+ if (i > 0) {
445
+ this.formatted += "||";
446
+ }
447
+ const comps = this.set[i];
448
+ for (let k = 0; k < comps.length; k++) {
449
+ if (k > 0) {
450
+ this.formatted += " ";
451
+ }
452
+ this.formatted += comps[k].toString().trim();
453
+ }
454
+ }
455
+ }
456
+ return this.formatted;
457
+ }
458
+ format() {
459
+ return this.range;
460
+ }
461
+ toString() {
462
+ return this.range;
463
+ }
464
+ parseRange(range) {
465
+ const memoOpts = (this.options.includePrerelease && FLAG_INCLUDE_PRERELEASE) | (this.options.loose && FLAG_LOOSE);
466
+ const memoKey = memoOpts + ":" + range;
467
+ const cached = cache.get(memoKey);
468
+ if (cached) {
469
+ return cached;
470
+ }
471
+ const loose = this.options.loose;
472
+ const hr = loose ? re[t.HYPHENRANGELOOSE] : re[t.HYPHENRANGE];
473
+ range = range.replace(hr, hyphenReplace(this.options.includePrerelease));
474
+ debug("hyphen replace", range);
475
+ range = range.replace(re[t.COMPARATORTRIM], comparatorTrimReplace);
476
+ debug("comparator trim", range);
477
+ range = range.replace(re[t.TILDETRIM], tildeTrimReplace);
478
+ debug("tilde trim", range);
479
+ range = range.replace(re[t.CARETTRIM], caretTrimReplace);
480
+ debug("caret trim", range);
481
+ let rangeList = range.split(" ").map((comp) => parseComparator(comp, this.options)).join(" ").split(/\s+/).map((comp) => replaceGTE0(comp, this.options));
482
+ if (loose) {
483
+ rangeList = rangeList.filter((comp) => {
484
+ debug("loose invalid filter", comp, this.options);
485
+ return !!comp.match(re[t.COMPARATORLOOSE]);
486
+ });
487
+ }
488
+ debug("range list", rangeList);
489
+ const rangeMap = /* @__PURE__ */ new Map();
490
+ const comparators = rangeList.map((comp) => new Comparator(comp, this.options));
491
+ for (const comp of comparators) {
492
+ if (isNullSet(comp)) {
493
+ return [comp];
494
+ }
495
+ rangeMap.set(comp.value, comp);
496
+ }
497
+ if (rangeMap.size > 1 && rangeMap.has("")) {
498
+ rangeMap.delete("");
499
+ }
500
+ const result = [...rangeMap.values()];
501
+ cache.set(memoKey, result);
502
+ return result;
503
+ }
504
+ intersects(range, options) {
505
+ if (!(range instanceof _Range)) {
506
+ throw new TypeError("a Range is required");
507
+ }
508
+ return this.set.some((thisComparators) => {
509
+ return isSatisfiable(thisComparators, options) && range.set.some((rangeComparators) => {
510
+ return isSatisfiable(rangeComparators, options) && thisComparators.every((thisComparator) => {
511
+ return rangeComparators.every((rangeComparator) => {
512
+ return thisComparator.intersects(rangeComparator, options);
513
+ });
514
+ });
515
+ });
516
+ });
517
+ }
518
+ // if ANY of the sets match ALL of its comparators, then pass
519
+ test(version) {
520
+ if (!version) {
521
+ return false;
522
+ }
523
+ if (typeof version === "string") {
524
+ try {
525
+ version = new SemVer(version, this.options);
526
+ } catch (er) {
527
+ return false;
528
+ }
529
+ }
530
+ for (let i = 0; i < this.set.length; i++) {
531
+ if (testSet(this.set[i], version, this.options)) {
532
+ return true;
533
+ }
534
+ }
535
+ return false;
536
+ }
537
+ };
538
+ module.exports = Range;
539
+ var LRU = require_lrucache();
540
+ var cache = new LRU();
541
+ var parseOptions = require_parse_options();
542
+ var Comparator = require_comparator();
543
+ var debug = require_debug();
544
+ var SemVer = require_semver();
545
+ var {
546
+ safeRe: re,
547
+ t,
548
+ comparatorTrimReplace,
549
+ tildeTrimReplace,
550
+ caretTrimReplace
551
+ } = require_re();
552
+ var { FLAG_INCLUDE_PRERELEASE, FLAG_LOOSE } = require_constants();
553
+ var isNullSet = (c) => c.value === "<0.0.0-0";
554
+ var isAny = (c) => c.value === "";
555
+ var isSatisfiable = (comparators, options) => {
556
+ let result = true;
557
+ const remainingComparators = comparators.slice();
558
+ let testComparator = remainingComparators.pop();
559
+ while (result && remainingComparators.length) {
560
+ result = remainingComparators.every((otherComparator) => {
561
+ return testComparator.intersects(otherComparator, options);
562
+ });
563
+ testComparator = remainingComparators.pop();
564
+ }
565
+ return result;
566
+ };
567
+ var parseComparator = (comp, options) => {
568
+ debug("comp", comp, options);
569
+ comp = replaceCarets(comp, options);
570
+ debug("caret", comp);
571
+ comp = replaceTildes(comp, options);
572
+ debug("tildes", comp);
573
+ comp = replaceXRanges(comp, options);
574
+ debug("xrange", comp);
575
+ comp = replaceStars(comp, options);
576
+ debug("stars", comp);
577
+ return comp;
578
+ };
579
+ var isX = (id) => !id || id.toLowerCase() === "x" || id === "*";
580
+ var replaceTildes = (comp, options) => {
581
+ return comp.trim().split(/\s+/).map((c) => replaceTilde(c, options)).join(" ");
582
+ };
583
+ var replaceTilde = (comp, options) => {
584
+ const r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE];
585
+ return comp.replace(r, (_, M, m, p, pr) => {
586
+ debug("tilde", comp, _, M, m, p, pr);
587
+ let ret;
588
+ if (isX(M)) {
589
+ ret = "";
590
+ } else if (isX(m)) {
591
+ ret = `>=${M}.0.0 <${+M + 1}.0.0-0`;
592
+ } else if (isX(p)) {
593
+ ret = `>=${M}.${m}.0 <${M}.${+m + 1}.0-0`;
594
+ } else if (pr) {
595
+ debug("replaceTilde pr", pr);
596
+ ret = `>=${M}.${m}.${p}-${pr} <${M}.${+m + 1}.0-0`;
597
+ } else {
598
+ ret = `>=${M}.${m}.${p} <${M}.${+m + 1}.0-0`;
599
+ }
600
+ debug("tilde return", ret);
601
+ return ret;
602
+ });
603
+ };
604
+ var replaceCarets = (comp, options) => {
605
+ return comp.trim().split(/\s+/).map((c) => replaceCaret(c, options)).join(" ");
606
+ };
607
+ var replaceCaret = (comp, options) => {
608
+ debug("caret", comp, options);
609
+ const r = options.loose ? re[t.CARETLOOSE] : re[t.CARET];
610
+ const z = options.includePrerelease ? "-0" : "";
611
+ return comp.replace(r, (_, M, m, p, pr) => {
612
+ debug("caret", comp, _, M, m, p, pr);
613
+ let ret;
614
+ if (isX(M)) {
615
+ ret = "";
616
+ } else if (isX(m)) {
617
+ ret = `>=${M}.0.0${z} <${+M + 1}.0.0-0`;
618
+ } else if (isX(p)) {
619
+ if (M === "0") {
620
+ ret = `>=${M}.${m}.0${z} <${M}.${+m + 1}.0-0`;
621
+ } else {
622
+ ret = `>=${M}.${m}.0${z} <${+M + 1}.0.0-0`;
623
+ }
624
+ } else if (pr) {
625
+ debug("replaceCaret pr", pr);
626
+ if (M === "0") {
627
+ if (m === "0") {
628
+ ret = `>=${M}.${m}.${p}-${pr} <${M}.${m}.${+p + 1}-0`;
629
+ } else {
630
+ ret = `>=${M}.${m}.${p}-${pr} <${M}.${+m + 1}.0-0`;
631
+ }
632
+ } else {
633
+ ret = `>=${M}.${m}.${p}-${pr} <${+M + 1}.0.0-0`;
634
+ }
635
+ } else {
636
+ debug("no pr");
637
+ if (M === "0") {
638
+ if (m === "0") {
639
+ ret = `>=${M}.${m}.${p}${z} <${M}.${m}.${+p + 1}-0`;
640
+ } else {
641
+ ret = `>=${M}.${m}.${p}${z} <${M}.${+m + 1}.0-0`;
642
+ }
643
+ } else {
644
+ ret = `>=${M}.${m}.${p} <${+M + 1}.0.0-0`;
645
+ }
646
+ }
647
+ debug("caret return", ret);
648
+ return ret;
649
+ });
650
+ };
651
+ var replaceXRanges = (comp, options) => {
652
+ debug("replaceXRanges", comp, options);
653
+ return comp.split(/\s+/).map((c) => replaceXRange(c, options)).join(" ");
654
+ };
655
+ var replaceXRange = (comp, options) => {
656
+ comp = comp.trim();
657
+ const r = options.loose ? re[t.XRANGELOOSE] : re[t.XRANGE];
658
+ return comp.replace(r, (ret, gtlt, M, m, p, pr) => {
659
+ debug("xRange", comp, ret, gtlt, M, m, p, pr);
660
+ const xM = isX(M);
661
+ const xm = xM || isX(m);
662
+ const xp = xm || isX(p);
663
+ const anyX = xp;
664
+ if (gtlt === "=" && anyX) {
665
+ gtlt = "";
666
+ }
667
+ pr = options.includePrerelease ? "-0" : "";
668
+ if (xM) {
669
+ if (gtlt === ">" || gtlt === "<") {
670
+ ret = "<0.0.0-0";
671
+ } else {
672
+ ret = "*";
673
+ }
674
+ } else if (gtlt && anyX) {
675
+ if (xm) {
676
+ m = 0;
677
+ }
678
+ p = 0;
679
+ if (gtlt === ">") {
680
+ gtlt = ">=";
681
+ if (xm) {
682
+ M = +M + 1;
683
+ m = 0;
684
+ p = 0;
685
+ } else {
686
+ m = +m + 1;
687
+ p = 0;
688
+ }
689
+ } else if (gtlt === "<=") {
690
+ gtlt = "<";
691
+ if (xm) {
692
+ M = +M + 1;
693
+ } else {
694
+ m = +m + 1;
695
+ }
696
+ }
697
+ if (gtlt === "<") {
698
+ pr = "-0";
699
+ }
700
+ ret = `${gtlt + M}.${m}.${p}${pr}`;
701
+ } else if (xm) {
702
+ ret = `>=${M}.0.0${pr} <${+M + 1}.0.0-0`;
703
+ } else if (xp) {
704
+ ret = `>=${M}.${m}.0${pr} <${M}.${+m + 1}.0-0`;
705
+ }
706
+ debug("xRange return", ret);
707
+ return ret;
708
+ });
709
+ };
710
+ var replaceStars = (comp, options) => {
711
+ debug("replaceStars", comp, options);
712
+ return comp.trim().replace(re[t.STAR], "");
713
+ };
714
+ var replaceGTE0 = (comp, options) => {
715
+ debug("replaceGTE0", comp, options);
716
+ return comp.trim().replace(re[options.includePrerelease ? t.GTE0PRE : t.GTE0], "");
717
+ };
718
+ var hyphenReplace = (incPr) => ($0, from, fM, fm, fp, fpr, fb, to, tM, tm, tp, tpr) => {
719
+ if (isX(fM)) {
720
+ from = "";
721
+ } else if (isX(fm)) {
722
+ from = `>=${fM}.0.0${incPr ? "-0" : ""}`;
723
+ } else if (isX(fp)) {
724
+ from = `>=${fM}.${fm}.0${incPr ? "-0" : ""}`;
725
+ } else if (fpr) {
726
+ from = `>=${from}`;
727
+ } else {
728
+ from = `>=${from}${incPr ? "-0" : ""}`;
729
+ }
730
+ if (isX(tM)) {
731
+ to = "";
732
+ } else if (isX(tm)) {
733
+ to = `<${+tM + 1}.0.0-0`;
734
+ } else if (isX(tp)) {
735
+ to = `<${tM}.${+tm + 1}.0-0`;
736
+ } else if (tpr) {
737
+ to = `<=${tM}.${tm}.${tp}-${tpr}`;
738
+ } else if (incPr) {
739
+ to = `<${tM}.${tm}.${+tp + 1}-0`;
740
+ } else {
741
+ to = `<=${to}`;
742
+ }
743
+ return `${from} ${to}`.trim();
744
+ };
745
+ var testSet = (set, version, options) => {
746
+ for (let i = 0; i < set.length; i++) {
747
+ if (!set[i].test(version)) {
748
+ return false;
749
+ }
750
+ }
751
+ if (version.prerelease.length && !options.includePrerelease) {
752
+ for (let i = 0; i < set.length; i++) {
753
+ debug(set[i].semver);
754
+ if (set[i].semver === Comparator.ANY) {
755
+ continue;
756
+ }
757
+ if (set[i].semver.prerelease.length > 0) {
758
+ const allowed = set[i].semver;
759
+ if (allowed.major === version.major && allowed.minor === version.minor && allowed.patch === version.patch) {
760
+ return true;
761
+ }
762
+ }
763
+ }
764
+ return false;
765
+ }
766
+ return true;
767
+ };
768
+ }
769
+ });
770
+
771
+ // node_modules/semver/classes/comparator.js
772
+ var require_comparator = __commonJS({
773
+ "node_modules/semver/classes/comparator.js"(exports, module) {
774
+ "use strict";
775
+ var ANY = Symbol("SemVer ANY");
776
+ var Comparator = class _Comparator {
777
+ static get ANY() {
778
+ return ANY;
779
+ }
780
+ constructor(comp, options) {
781
+ options = parseOptions(options);
782
+ if (comp instanceof _Comparator) {
783
+ if (comp.loose === !!options.loose) {
784
+ return comp;
785
+ } else {
786
+ comp = comp.value;
787
+ }
788
+ }
789
+ comp = comp.trim().split(/\s+/).join(" ");
790
+ debug("comparator", comp, options);
791
+ this.options = options;
792
+ this.loose = !!options.loose;
793
+ this.parse(comp);
794
+ if (this.semver === ANY) {
795
+ this.value = "";
796
+ } else {
797
+ this.value = this.operator + this.semver.version;
798
+ }
799
+ debug("comp", this);
800
+ }
801
+ parse(comp) {
802
+ const r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR];
803
+ const m = comp.match(r);
804
+ if (!m) {
805
+ throw new TypeError(`Invalid comparator: ${comp}`);
806
+ }
807
+ this.operator = m[1] !== void 0 ? m[1] : "";
808
+ if (this.operator === "=") {
809
+ this.operator = "";
810
+ }
811
+ if (!m[2]) {
812
+ this.semver = ANY;
813
+ } else {
814
+ this.semver = new SemVer(m[2], this.options.loose);
815
+ }
816
+ }
817
+ toString() {
818
+ return this.value;
819
+ }
820
+ test(version) {
821
+ debug("Comparator.test", version, this.options.loose);
822
+ if (this.semver === ANY || version === ANY) {
823
+ return true;
824
+ }
825
+ if (typeof version === "string") {
826
+ try {
827
+ version = new SemVer(version, this.options);
828
+ } catch (er) {
829
+ return false;
830
+ }
831
+ }
832
+ return cmp(version, this.operator, this.semver, this.options);
833
+ }
834
+ intersects(comp, options) {
835
+ if (!(comp instanceof _Comparator)) {
836
+ throw new TypeError("a Comparator is required");
837
+ }
838
+ if (this.operator === "") {
839
+ if (this.value === "") {
840
+ return true;
841
+ }
842
+ return new Range(comp.value, options).test(this.value);
843
+ } else if (comp.operator === "") {
844
+ if (comp.value === "") {
845
+ return true;
846
+ }
847
+ return new Range(this.value, options).test(comp.semver);
848
+ }
849
+ options = parseOptions(options);
850
+ if (options.includePrerelease && (this.value === "<0.0.0-0" || comp.value === "<0.0.0-0")) {
851
+ return false;
852
+ }
853
+ if (!options.includePrerelease && (this.value.startsWith("<0.0.0") || comp.value.startsWith("<0.0.0"))) {
854
+ return false;
855
+ }
856
+ if (this.operator.startsWith(">") && comp.operator.startsWith(">")) {
857
+ return true;
858
+ }
859
+ if (this.operator.startsWith("<") && comp.operator.startsWith("<")) {
860
+ return true;
861
+ }
862
+ if (this.semver.version === comp.semver.version && this.operator.includes("=") && comp.operator.includes("=")) {
863
+ return true;
864
+ }
865
+ if (cmp(this.semver, "<", comp.semver, options) && this.operator.startsWith(">") && comp.operator.startsWith("<")) {
866
+ return true;
867
+ }
868
+ if (cmp(this.semver, ">", comp.semver, options) && this.operator.startsWith("<") && comp.operator.startsWith(">")) {
869
+ return true;
870
+ }
871
+ return false;
872
+ }
873
+ };
874
+ module.exports = Comparator;
875
+ var parseOptions = require_parse_options();
876
+ var { safeRe: re, t } = require_re();
877
+ var cmp = require_cmp();
878
+ var debug = require_debug();
879
+ var SemVer = require_semver();
880
+ var Range = require_range();
881
+ }
882
+ });
883
+
884
+ // node_modules/semver/functions/satisfies.js
885
+ var require_satisfies = __commonJS({
886
+ "node_modules/semver/functions/satisfies.js"(exports, module) {
887
+ "use strict";
888
+ var Range = require_range();
889
+ var satisfies = (version, range, options) => {
890
+ try {
891
+ range = new Range(range, options);
892
+ } catch (er) {
893
+ return false;
894
+ }
895
+ return range.test(version);
896
+ };
897
+ module.exports = satisfies;
898
+ }
899
+ });
900
+
901
+ // node_modules/semver/ranges/to-comparators.js
902
+ var require_to_comparators = __commonJS({
903
+ "node_modules/semver/ranges/to-comparators.js"(exports, module) {
904
+ "use strict";
905
+ var Range = require_range();
906
+ var toComparators = (range, options) => new Range(range, options).set.map((comp) => comp.map((c) => c.value).join(" ").trim().split(" "));
907
+ module.exports = toComparators;
908
+ }
909
+ });
910
+
911
+ // node_modules/semver/ranges/max-satisfying.js
912
+ var require_max_satisfying = __commonJS({
913
+ "node_modules/semver/ranges/max-satisfying.js"(exports, module) {
914
+ "use strict";
915
+ var SemVer = require_semver();
916
+ var Range = require_range();
917
+ var maxSatisfying = (versions, range, options) => {
918
+ let max = null;
919
+ let maxSV = null;
920
+ let rangeObj = null;
921
+ try {
922
+ rangeObj = new Range(range, options);
923
+ } catch (er) {
924
+ return null;
925
+ }
926
+ versions.forEach((v) => {
927
+ if (rangeObj.test(v)) {
928
+ if (!max || maxSV.compare(v) === -1) {
929
+ max = v;
930
+ maxSV = new SemVer(max, options);
931
+ }
932
+ }
933
+ });
934
+ return max;
935
+ };
936
+ module.exports = maxSatisfying;
937
+ }
938
+ });
939
+
940
+ // node_modules/semver/ranges/min-satisfying.js
941
+ var require_min_satisfying = __commonJS({
942
+ "node_modules/semver/ranges/min-satisfying.js"(exports, module) {
943
+ "use strict";
944
+ var SemVer = require_semver();
945
+ var Range = require_range();
946
+ var minSatisfying = (versions, range, options) => {
947
+ let min = null;
948
+ let minSV = null;
949
+ let rangeObj = null;
950
+ try {
951
+ rangeObj = new Range(range, options);
952
+ } catch (er) {
953
+ return null;
954
+ }
955
+ versions.forEach((v) => {
956
+ if (rangeObj.test(v)) {
957
+ if (!min || minSV.compare(v) === 1) {
958
+ min = v;
959
+ minSV = new SemVer(min, options);
960
+ }
961
+ }
962
+ });
963
+ return min;
964
+ };
965
+ module.exports = minSatisfying;
966
+ }
967
+ });
968
+
969
+ // node_modules/semver/ranges/min-version.js
970
+ var require_min_version = __commonJS({
971
+ "node_modules/semver/ranges/min-version.js"(exports, module) {
972
+ "use strict";
973
+ var SemVer = require_semver();
974
+ var Range = require_range();
975
+ var gt = require_gt();
976
+ var minVersion = (range, loose) => {
977
+ range = new Range(range, loose);
978
+ let minver = new SemVer("0.0.0");
979
+ if (range.test(minver)) {
980
+ return minver;
981
+ }
982
+ minver = new SemVer("0.0.0-0");
983
+ if (range.test(minver)) {
984
+ return minver;
985
+ }
986
+ minver = null;
987
+ for (let i = 0; i < range.set.length; ++i) {
988
+ const comparators = range.set[i];
989
+ let setMin = null;
990
+ comparators.forEach((comparator) => {
991
+ const compver = new SemVer(comparator.semver.version);
992
+ switch (comparator.operator) {
993
+ case ">":
994
+ if (compver.prerelease.length === 0) {
995
+ compver.patch++;
996
+ } else {
997
+ compver.prerelease.push(0);
998
+ }
999
+ compver.raw = compver.format();
1000
+ /* fallthrough */
1001
+ case "":
1002
+ case ">=":
1003
+ if (!setMin || gt(compver, setMin)) {
1004
+ setMin = compver;
1005
+ }
1006
+ break;
1007
+ case "<":
1008
+ case "<=":
1009
+ break;
1010
+ /* istanbul ignore next */
1011
+ default:
1012
+ throw new Error(`Unexpected operation: ${comparator.operator}`);
1013
+ }
1014
+ });
1015
+ if (setMin && (!minver || gt(minver, setMin))) {
1016
+ minver = setMin;
1017
+ }
1018
+ }
1019
+ if (minver && range.test(minver)) {
1020
+ return minver;
1021
+ }
1022
+ return null;
1023
+ };
1024
+ module.exports = minVersion;
1025
+ }
1026
+ });
1027
+
1028
+ // node_modules/semver/ranges/valid.js
1029
+ var require_valid2 = __commonJS({
1030
+ "node_modules/semver/ranges/valid.js"(exports, module) {
1031
+ "use strict";
1032
+ var Range = require_range();
1033
+ var validRange = (range, options) => {
1034
+ try {
1035
+ return new Range(range, options).range || "*";
1036
+ } catch (er) {
1037
+ return null;
1038
+ }
1039
+ };
1040
+ module.exports = validRange;
1041
+ }
1042
+ });
1043
+
1044
+ // node_modules/semver/ranges/outside.js
1045
+ var require_outside = __commonJS({
1046
+ "node_modules/semver/ranges/outside.js"(exports, module) {
1047
+ "use strict";
1048
+ var SemVer = require_semver();
1049
+ var Comparator = require_comparator();
1050
+ var { ANY } = Comparator;
1051
+ var Range = require_range();
1052
+ var satisfies = require_satisfies();
1053
+ var gt = require_gt();
1054
+ var lt = require_lt();
1055
+ var lte = require_lte();
1056
+ var gte = require_gte();
1057
+ var outside = (version, range, hilo, options) => {
1058
+ version = new SemVer(version, options);
1059
+ range = new Range(range, options);
1060
+ let gtfn, ltefn, ltfn, comp, ecomp;
1061
+ switch (hilo) {
1062
+ case ">":
1063
+ gtfn = gt;
1064
+ ltefn = lte;
1065
+ ltfn = lt;
1066
+ comp = ">";
1067
+ ecomp = ">=";
1068
+ break;
1069
+ case "<":
1070
+ gtfn = lt;
1071
+ ltefn = gte;
1072
+ ltfn = gt;
1073
+ comp = "<";
1074
+ ecomp = "<=";
1075
+ break;
1076
+ default:
1077
+ throw new TypeError('Must provide a hilo val of "<" or ">"');
1078
+ }
1079
+ if (satisfies(version, range, options)) {
1080
+ return false;
1081
+ }
1082
+ for (let i = 0; i < range.set.length; ++i) {
1083
+ const comparators = range.set[i];
1084
+ let high = null;
1085
+ let low = null;
1086
+ comparators.forEach((comparator) => {
1087
+ if (comparator.semver === ANY) {
1088
+ comparator = new Comparator(">=0.0.0");
1089
+ }
1090
+ high = high || comparator;
1091
+ low = low || comparator;
1092
+ if (gtfn(comparator.semver, high.semver, options)) {
1093
+ high = comparator;
1094
+ } else if (ltfn(comparator.semver, low.semver, options)) {
1095
+ low = comparator;
1096
+ }
1097
+ });
1098
+ if (high.operator === comp || high.operator === ecomp) {
1099
+ return false;
1100
+ }
1101
+ if ((!low.operator || low.operator === comp) && ltefn(version, low.semver)) {
1102
+ return false;
1103
+ } else if (low.operator === ecomp && ltfn(version, low.semver)) {
1104
+ return false;
1105
+ }
1106
+ }
1107
+ return true;
1108
+ };
1109
+ module.exports = outside;
1110
+ }
1111
+ });
1112
+
1113
+ // node_modules/semver/ranges/gtr.js
1114
+ var require_gtr = __commonJS({
1115
+ "node_modules/semver/ranges/gtr.js"(exports, module) {
1116
+ "use strict";
1117
+ var outside = require_outside();
1118
+ var gtr = (version, range, options) => outside(version, range, ">", options);
1119
+ module.exports = gtr;
1120
+ }
1121
+ });
1122
+
1123
+ // node_modules/semver/ranges/ltr.js
1124
+ var require_ltr = __commonJS({
1125
+ "node_modules/semver/ranges/ltr.js"(exports, module) {
1126
+ "use strict";
1127
+ var outside = require_outside();
1128
+ var ltr = (version, range, options) => outside(version, range, "<", options);
1129
+ module.exports = ltr;
1130
+ }
1131
+ });
1132
+
1133
+ // node_modules/semver/ranges/intersects.js
1134
+ var require_intersects = __commonJS({
1135
+ "node_modules/semver/ranges/intersects.js"(exports, module) {
1136
+ "use strict";
1137
+ var Range = require_range();
1138
+ var intersects = (r1, r2, options) => {
1139
+ r1 = new Range(r1, options);
1140
+ r2 = new Range(r2, options);
1141
+ return r1.intersects(r2, options);
1142
+ };
1143
+ module.exports = intersects;
1144
+ }
1145
+ });
1146
+
1147
+ // node_modules/semver/ranges/simplify.js
1148
+ var require_simplify = __commonJS({
1149
+ "node_modules/semver/ranges/simplify.js"(exports, module) {
1150
+ "use strict";
1151
+ var satisfies = require_satisfies();
1152
+ var compare = require_compare();
1153
+ module.exports = (versions, range, options) => {
1154
+ const set = [];
1155
+ let first = null;
1156
+ let prev = null;
1157
+ const v = versions.sort((a, b) => compare(a, b, options));
1158
+ for (const version of v) {
1159
+ const included = satisfies(version, range, options);
1160
+ if (included) {
1161
+ prev = version;
1162
+ if (!first) {
1163
+ first = version;
1164
+ }
1165
+ } else {
1166
+ if (prev) {
1167
+ set.push([first, prev]);
1168
+ }
1169
+ prev = null;
1170
+ first = null;
1171
+ }
1172
+ }
1173
+ if (first) {
1174
+ set.push([first, null]);
1175
+ }
1176
+ const ranges = [];
1177
+ for (const [min, max] of set) {
1178
+ if (min === max) {
1179
+ ranges.push(min);
1180
+ } else if (!max && min === v[0]) {
1181
+ ranges.push("*");
1182
+ } else if (!max) {
1183
+ ranges.push(`>=${min}`);
1184
+ } else if (min === v[0]) {
1185
+ ranges.push(`<=${max}`);
1186
+ } else {
1187
+ ranges.push(`${min} - ${max}`);
1188
+ }
1189
+ }
1190
+ const simplified = ranges.join(" || ");
1191
+ const original = typeof range.raw === "string" ? range.raw : String(range);
1192
+ return simplified.length < original.length ? simplified : range;
1193
+ };
1194
+ }
1195
+ });
1196
+
1197
+ // node_modules/semver/ranges/subset.js
1198
+ var require_subset = __commonJS({
1199
+ "node_modules/semver/ranges/subset.js"(exports, module) {
1200
+ "use strict";
1201
+ var Range = require_range();
1202
+ var Comparator = require_comparator();
1203
+ var { ANY } = Comparator;
1204
+ var satisfies = require_satisfies();
1205
+ var compare = require_compare();
1206
+ var subset = (sub, dom, options = {}) => {
1207
+ if (sub === dom) {
1208
+ return true;
1209
+ }
1210
+ sub = new Range(sub, options);
1211
+ dom = new Range(dom, options);
1212
+ let sawNonNull = false;
1213
+ OUTER: for (const simpleSub of sub.set) {
1214
+ for (const simpleDom of dom.set) {
1215
+ const isSub = simpleSubset(simpleSub, simpleDom, options);
1216
+ sawNonNull = sawNonNull || isSub !== null;
1217
+ if (isSub) {
1218
+ continue OUTER;
1219
+ }
1220
+ }
1221
+ if (sawNonNull) {
1222
+ return false;
1223
+ }
1224
+ }
1225
+ return true;
1226
+ };
1227
+ var minimumVersionWithPreRelease = [new Comparator(">=0.0.0-0")];
1228
+ var minimumVersion = [new Comparator(">=0.0.0")];
1229
+ var simpleSubset = (sub, dom, options) => {
1230
+ if (sub === dom) {
1231
+ return true;
1232
+ }
1233
+ if (sub.length === 1 && sub[0].semver === ANY) {
1234
+ if (dom.length === 1 && dom[0].semver === ANY) {
1235
+ return true;
1236
+ } else if (options.includePrerelease) {
1237
+ sub = minimumVersionWithPreRelease;
1238
+ } else {
1239
+ sub = minimumVersion;
1240
+ }
1241
+ }
1242
+ if (dom.length === 1 && dom[0].semver === ANY) {
1243
+ if (options.includePrerelease) {
1244
+ return true;
1245
+ } else {
1246
+ dom = minimumVersion;
1247
+ }
1248
+ }
1249
+ const eqSet = /* @__PURE__ */ new Set();
1250
+ let gt, lt;
1251
+ for (const c of sub) {
1252
+ if (c.operator === ">" || c.operator === ">=") {
1253
+ gt = higherGT(gt, c, options);
1254
+ } else if (c.operator === "<" || c.operator === "<=") {
1255
+ lt = lowerLT(lt, c, options);
1256
+ } else {
1257
+ eqSet.add(c.semver);
1258
+ }
1259
+ }
1260
+ if (eqSet.size > 1) {
1261
+ return null;
1262
+ }
1263
+ let gtltComp;
1264
+ if (gt && lt) {
1265
+ gtltComp = compare(gt.semver, lt.semver, options);
1266
+ if (gtltComp > 0) {
1267
+ return null;
1268
+ } else if (gtltComp === 0 && (gt.operator !== ">=" || lt.operator !== "<=")) {
1269
+ return null;
1270
+ }
1271
+ }
1272
+ for (const eq of eqSet) {
1273
+ if (gt && !satisfies(eq, String(gt), options)) {
1274
+ return null;
1275
+ }
1276
+ if (lt && !satisfies(eq, String(lt), options)) {
1277
+ return null;
1278
+ }
1279
+ for (const c of dom) {
1280
+ if (!satisfies(eq, String(c), options)) {
1281
+ return false;
1282
+ }
1283
+ }
1284
+ return true;
1285
+ }
1286
+ let higher, lower;
1287
+ let hasDomLT, hasDomGT;
1288
+ let needDomLTPre = lt && !options.includePrerelease && lt.semver.prerelease.length ? lt.semver : false;
1289
+ let needDomGTPre = gt && !options.includePrerelease && gt.semver.prerelease.length ? gt.semver : false;
1290
+ if (needDomLTPre && needDomLTPre.prerelease.length === 1 && lt.operator === "<" && needDomLTPre.prerelease[0] === 0) {
1291
+ needDomLTPre = false;
1292
+ }
1293
+ for (const c of dom) {
1294
+ hasDomGT = hasDomGT || c.operator === ">" || c.operator === ">=";
1295
+ hasDomLT = hasDomLT || c.operator === "<" || c.operator === "<=";
1296
+ if (gt) {
1297
+ if (needDomGTPre) {
1298
+ if (c.semver.prerelease && c.semver.prerelease.length && c.semver.major === needDomGTPre.major && c.semver.minor === needDomGTPre.minor && c.semver.patch === needDomGTPre.patch) {
1299
+ needDomGTPre = false;
1300
+ }
1301
+ }
1302
+ if (c.operator === ">" || c.operator === ">=") {
1303
+ higher = higherGT(gt, c, options);
1304
+ if (higher === c && higher !== gt) {
1305
+ return false;
1306
+ }
1307
+ } else if (gt.operator === ">=" && !satisfies(gt.semver, String(c), options)) {
1308
+ return false;
1309
+ }
1310
+ }
1311
+ if (lt) {
1312
+ if (needDomLTPre) {
1313
+ if (c.semver.prerelease && c.semver.prerelease.length && c.semver.major === needDomLTPre.major && c.semver.minor === needDomLTPre.minor && c.semver.patch === needDomLTPre.patch) {
1314
+ needDomLTPre = false;
1315
+ }
1316
+ }
1317
+ if (c.operator === "<" || c.operator === "<=") {
1318
+ lower = lowerLT(lt, c, options);
1319
+ if (lower === c && lower !== lt) {
1320
+ return false;
1321
+ }
1322
+ } else if (lt.operator === "<=" && !satisfies(lt.semver, String(c), options)) {
1323
+ return false;
1324
+ }
1325
+ }
1326
+ if (!c.operator && (lt || gt) && gtltComp !== 0) {
1327
+ return false;
1328
+ }
1329
+ }
1330
+ if (gt && hasDomLT && !lt && gtltComp !== 0) {
1331
+ return false;
1332
+ }
1333
+ if (lt && hasDomGT && !gt && gtltComp !== 0) {
1334
+ return false;
1335
+ }
1336
+ if (needDomGTPre || needDomLTPre) {
1337
+ return false;
1338
+ }
1339
+ return true;
1340
+ };
1341
+ var higherGT = (a, b, options) => {
1342
+ if (!a) {
1343
+ return b;
1344
+ }
1345
+ const comp = compare(a.semver, b.semver, options);
1346
+ return comp > 0 ? a : comp < 0 ? b : b.operator === ">" && a.operator === ">=" ? b : a;
1347
+ };
1348
+ var lowerLT = (a, b, options) => {
1349
+ if (!a) {
1350
+ return b;
1351
+ }
1352
+ const comp = compare(a.semver, b.semver, options);
1353
+ return comp < 0 ? a : comp > 0 ? b : b.operator === "<" && a.operator === "<=" ? b : a;
1354
+ };
1355
+ module.exports = subset;
1356
+ }
1357
+ });
1358
+
1359
+ // node_modules/semver/index.js
1360
+ var require_semver2 = __commonJS({
1361
+ "node_modules/semver/index.js"(exports, module) {
1362
+ "use strict";
1363
+ var internalRe = require_re();
1364
+ var constants = require_constants();
1365
+ var SemVer = require_semver();
1366
+ var identifiers = require_identifiers();
1367
+ var parse = require_parse();
1368
+ var valid = require_valid();
1369
+ var clean = require_clean();
1370
+ var inc = require_inc();
1371
+ var diff = require_diff();
1372
+ var major = require_major();
1373
+ var minor = require_minor();
1374
+ var patch = require_patch();
1375
+ var prerelease = require_prerelease();
1376
+ var compare = require_compare();
1377
+ var rcompare = require_rcompare();
1378
+ var compareLoose = require_compare_loose();
1379
+ var compareBuild = require_compare_build();
1380
+ var sort = require_sort();
1381
+ var rsort = require_rsort();
1382
+ var gt = require_gt();
1383
+ var lt = require_lt();
1384
+ var eq = require_eq();
1385
+ var neq = require_neq();
1386
+ var gte = require_gte();
1387
+ var lte = require_lte();
1388
+ var cmp = require_cmp();
1389
+ var coerce = require_coerce();
1390
+ var Comparator = require_comparator();
1391
+ var Range = require_range();
1392
+ var satisfies = require_satisfies();
1393
+ var toComparators = require_to_comparators();
1394
+ var maxSatisfying = require_max_satisfying();
1395
+ var minSatisfying = require_min_satisfying();
1396
+ var minVersion = require_min_version();
1397
+ var validRange = require_valid2();
1398
+ var outside = require_outside();
1399
+ var gtr = require_gtr();
1400
+ var ltr = require_ltr();
1401
+ var intersects = require_intersects();
1402
+ var simplifyRange = require_simplify();
1403
+ var subset = require_subset();
1404
+ module.exports = {
1405
+ parse,
1406
+ valid,
1407
+ clean,
1408
+ inc,
1409
+ diff,
1410
+ major,
1411
+ minor,
1412
+ patch,
1413
+ prerelease,
1414
+ compare,
1415
+ rcompare,
1416
+ compareLoose,
1417
+ compareBuild,
1418
+ sort,
1419
+ rsort,
1420
+ gt,
1421
+ lt,
1422
+ eq,
1423
+ neq,
1424
+ gte,
1425
+ lte,
1426
+ cmp,
1427
+ coerce,
1428
+ Comparator,
1429
+ Range,
1430
+ satisfies,
1431
+ toComparators,
1432
+ maxSatisfying,
1433
+ minSatisfying,
1434
+ minVersion,
1435
+ validRange,
1436
+ outside,
1437
+ gtr,
1438
+ ltr,
1439
+ intersects,
1440
+ simplifyRange,
1441
+ subset,
1442
+ SemVer,
1443
+ re: internalRe.re,
1444
+ src: internalRe.src,
1445
+ tokens: internalRe.t,
1446
+ SEMVER_SPEC_VERSION: constants.SEMVER_SPEC_VERSION,
1447
+ RELEASE_TYPES: constants.RELEASE_TYPES,
1448
+ compareIdentifiers: identifiers.compareIdentifiers,
1449
+ rcompareIdentifiers: identifiers.rcompareIdentifiers
1450
+ };
1451
+ }
1452
+ });
1453
+
1454
+ // packages/cli/src/utils/installationInfo.ts
1455
+ import * as fs from "node:fs";
1456
+ import * as path from "node:path";
1457
+ import * as childProcess from "node:child_process";
1458
+ import process2 from "node:process";
1459
+ var isDevelopment = process2.env["NODE_ENV"] === "development";
1460
+ function getInstallationInfo(projectRoot, isAutoUpdateEnabled) {
1461
+ const cliPath = process2.argv[1];
1462
+ if (!cliPath) {
1463
+ return { packageManager: "unknown" /* UNKNOWN */, isGlobal: false };
1464
+ }
1465
+ try {
1466
+ if (process2.env["IS_BINARY"] === "true") {
1467
+ return {
1468
+ packageManager: "binary" /* BINARY */,
1469
+ isGlobal: true,
1470
+ updateMessage: "Running as a standalone binary. Please update by downloading the latest version from GitHub."
1471
+ };
1472
+ }
1473
+ const realPath = fs.realpathSync(cliPath).replace(/\\/g, "/");
1474
+ const normalizedProjectRoot = projectRoot?.replace(/\\/g, "/");
1475
+ const isGit = isGitRepository(process2.cwd());
1476
+ if (isGit && normalizedProjectRoot && realPath.startsWith(normalizedProjectRoot) && !realPath.includes("/node_modules/")) {
1477
+ return {
1478
+ packageManager: "unknown" /* UNKNOWN */,
1479
+ // Not managed by a package manager in this sense
1480
+ isGlobal: false,
1481
+ updateMessage: 'Running from a local git clone. Please update with "git pull".'
1482
+ };
1483
+ }
1484
+ if (realPath.includes("/.npm/_npx") || realPath.includes("/npm/_npx")) {
1485
+ return {
1486
+ packageManager: "npx" /* NPX */,
1487
+ isGlobal: false,
1488
+ updateMessage: "Running via npx, update not applicable."
1489
+ };
1490
+ }
1491
+ if (realPath.includes("/.pnpm/_pnpx") || realPath.includes("/.cache/pnpm/dlx")) {
1492
+ return {
1493
+ packageManager: "pnpx" /* PNPX */,
1494
+ isGlobal: false,
1495
+ updateMessage: "Running via pnpx, update not applicable."
1496
+ };
1497
+ }
1498
+ if (process2.platform === "darwin") {
1499
+ try {
1500
+ const brewPrefix = childProcess.execSync("brew --prefix gemini-cli", {
1501
+ encoding: "utf8",
1502
+ stdio: ["ignore", "pipe", "ignore"]
1503
+ }).trim();
1504
+ const brewRealPath = fs.realpathSync(brewPrefix);
1505
+ if (realPath.startsWith(brewRealPath)) {
1506
+ return {
1507
+ packageManager: "homebrew" /* HOMEBREW */,
1508
+ isGlobal: true,
1509
+ updateMessage: 'Installed via Homebrew. Please update with "brew upgrade gemini-cli".'
1510
+ };
1511
+ }
1512
+ } catch {
1513
+ }
1514
+ }
1515
+ if (realPath.includes("/.volta/") || realPath.includes("/Volta/")) {
1516
+ const updateCommand2 = "volta install @google/gemini-cli@latest";
1517
+ return {
1518
+ packageManager: "volta" /* VOLTA */,
1519
+ isGlobal: true,
1520
+ updateCommand: updateCommand2,
1521
+ updateMessage: isAutoUpdateEnabled ? "Installed with Volta. Attempting to automatically update now..." : `Please run ${updateCommand2} to update`
1522
+ };
1523
+ }
1524
+ if (realPath.includes("/.pnpm/global") || realPath.includes("/.local/share/pnpm") || realPath.includes("/Library/pnpm/global/") || realPath.includes("/AppData/Local/pnpm/global/")) {
1525
+ const updateCommand2 = "pnpm add -g @google/gemini-cli@latest";
1526
+ return {
1527
+ packageManager: "pnpm" /* PNPM */,
1528
+ isGlobal: true,
1529
+ updateCommand: updateCommand2,
1530
+ updateMessage: isAutoUpdateEnabled ? "Installed with pnpm. Attempting to automatically update now..." : `Please run ${updateCommand2} to update`
1531
+ };
1532
+ }
1533
+ if (realPath.includes("/.yarn/global")) {
1534
+ const updateCommand2 = "yarn global add @google/gemini-cli@latest";
1535
+ return {
1536
+ packageManager: "yarn" /* YARN */,
1537
+ isGlobal: true,
1538
+ updateCommand: updateCommand2,
1539
+ updateMessage: isAutoUpdateEnabled ? "Installed with yarn. Attempting to automatically update now..." : `Please run ${updateCommand2} to update`
1540
+ };
1541
+ }
1542
+ if (realPath.includes("/.bun/install/cache")) {
1543
+ return {
1544
+ packageManager: "bunx" /* BUNX */,
1545
+ isGlobal: false,
1546
+ updateMessage: "Running via bunx, update not applicable."
1547
+ };
1548
+ }
1549
+ if (realPath.includes("/.bun/install/global")) {
1550
+ const updateCommand2 = "bun add -g @google/gemini-cli@latest";
1551
+ return {
1552
+ packageManager: "bun" /* BUN */,
1553
+ isGlobal: true,
1554
+ updateCommand: updateCommand2,
1555
+ updateMessage: isAutoUpdateEnabled ? "Installed with bun. Attempting to automatically update now..." : `Please run ${updateCommand2} to update`
1556
+ };
1557
+ }
1558
+ if (normalizedProjectRoot && realPath.startsWith(`${normalizedProjectRoot}/node_modules`)) {
1559
+ let pm = "npm" /* NPM */;
1560
+ if (fs.existsSync(path.join(projectRoot, "yarn.lock"))) {
1561
+ pm = "yarn" /* YARN */;
1562
+ } else if (fs.existsSync(path.join(projectRoot, "pnpm-lock.yaml"))) {
1563
+ pm = "pnpm" /* PNPM */;
1564
+ } else if (fs.existsSync(path.join(projectRoot, "bun.lockb"))) {
1565
+ pm = "bun" /* BUN */;
1566
+ }
1567
+ return {
1568
+ packageManager: pm,
1569
+ isGlobal: false,
1570
+ updateMessage: "Locally installed. Please update via your project's package.json."
1571
+ };
1572
+ }
1573
+ const updateCommand = "npm install -g @google/gemini-cli@latest";
1574
+ return {
1575
+ packageManager: "npm" /* NPM */,
1576
+ isGlobal: true,
1577
+ updateCommand,
1578
+ updateMessage: isAutoUpdateEnabled ? "Installed with npm. Attempting to automatically update now..." : `Please run ${updateCommand} to update`
1579
+ };
1580
+ } catch (error) {
1581
+ debugLogger.log(error);
1582
+ return { packageManager: "unknown" /* UNKNOWN */, isGlobal: false };
1583
+ }
1584
+ }
1585
+
1586
+ // packages/cli/src/utils/updateEventEmitter.ts
1587
+ import { EventEmitter } from "node:events";
1588
+ var updateEventEmitter = new EventEmitter();
1589
+
1590
+ // packages/cli/src/utils/spawnWrapper.ts
1591
+ import { spawn } from "node:child_process";
1592
+ var spawnWrapper = spawn;
1593
+
1594
+ // packages/cli/src/utils/handleAutoUpdate.ts
1595
+ var import_semver = __toESM(require_semver2(), 1);
1596
+ import * as fs2 from "node:fs";
1597
+ import * as path2 from "node:path";
1598
+ var _updateInProgress = false;
1599
+ async function waitForUpdateCompletion(timeoutMs = 3e4) {
1600
+ if (!_updateInProgress) {
1601
+ return;
1602
+ }
1603
+ debugLogger.log(
1604
+ "\nGemini CLI is waiting for a background update to complete before restarting..."
1605
+ );
1606
+ return new Promise((resolve2) => {
1607
+ if (!_updateInProgress) {
1608
+ resolve2();
1609
+ return;
1610
+ }
1611
+ const timer = setTimeout(cleanup, timeoutMs);
1612
+ function cleanup() {
1613
+ clearTimeout(timer);
1614
+ updateEventEmitter.off("update-success", cleanup);
1615
+ updateEventEmitter.off("update-failed", cleanup);
1616
+ resolve2();
1617
+ }
1618
+ updateEventEmitter.once("update-success", cleanup);
1619
+ updateEventEmitter.once("update-failed", cleanup);
1620
+ });
1621
+ }
1622
+ function handleAutoUpdate(info, settings, projectRoot, isSandboxEnabled, spawnFn = spawnWrapper, getPackageJsonFn = getPackageJson) {
1623
+ if (!info) {
1624
+ return;
1625
+ }
1626
+ const rawCliPath = process.argv[1];
1627
+ let resolvedCliPath;
1628
+ if (rawCliPath) {
1629
+ try {
1630
+ resolvedCliPath = fs2.realpathSync(rawCliPath);
1631
+ } catch {
1632
+ resolvedCliPath = path2.resolve(rawCliPath);
1633
+ }
1634
+ }
1635
+ const latestVersion = info.update?.latest ?? "";
1636
+ if (!latestVersion || !import_semver.default.valid(latestVersion)) {
1637
+ debugLogger.warn(
1638
+ "Update check: latest version is missing or invalid. Skipping automatic update for safety."
1639
+ );
1640
+ return;
1641
+ }
1642
+ if (isSandboxEnabled) {
1643
+ updateEventEmitter.emit("update-info", {
1644
+ message: `${info.message}
1645
+ Automatic update is not available in sandbox mode.`
1646
+ });
1647
+ return;
1648
+ }
1649
+ if (!settings.merged.general.enableAutoUpdateNotification) {
1650
+ return;
1651
+ }
1652
+ const installationInfo = getInstallationInfo(
1653
+ projectRoot,
1654
+ settings.merged.general.enableAutoUpdate
1655
+ );
1656
+ if ([
1657
+ "npx" /* NPX */,
1658
+ "pnpx" /* PNPX */,
1659
+ "bunx" /* BUNX */,
1660
+ "binary" /* BINARY */
1661
+ ].includes(installationInfo.packageManager)) {
1662
+ return;
1663
+ }
1664
+ let combinedMessage = info.message;
1665
+ if (installationInfo.updateMessage) {
1666
+ combinedMessage += `
1667
+ ${installationInfo.updateMessage}`;
1668
+ }
1669
+ if (!installationInfo.updateCommand || !settings.merged.general.enableAutoUpdate) {
1670
+ updateEventEmitter.emit("update-received", {
1671
+ ...info,
1672
+ message: combinedMessage,
1673
+ isUpdating: false
1674
+ });
1675
+ return;
1676
+ }
1677
+ updateEventEmitter.emit("update-received", {
1678
+ ...info,
1679
+ message: combinedMessage,
1680
+ isUpdating: true
1681
+ });
1682
+ if (_updateInProgress) {
1683
+ return;
1684
+ }
1685
+ const currentVersion = info.update.current;
1686
+ if (!currentVersion) {
1687
+ debugLogger.warn(
1688
+ "Update check: current version is missing. Skipping automatic update for safety."
1689
+ );
1690
+ return;
1691
+ }
1692
+ const currentChannel = getChannelFromVersion(currentVersion);
1693
+ const targetChannel = getChannelFromVersion(info.update.latest);
1694
+ if (RELEASE_CHANNEL_STABILITY[targetChannel] < RELEASE_CHANNEL_STABILITY[currentChannel]) {
1695
+ return;
1696
+ }
1697
+ const isNightly = info.update.latest.includes("nightly");
1698
+ const updateCommand = installationInfo.updateCommand.replace(
1699
+ "@latest",
1700
+ isNightly ? "@nightly" : `@${info.update.latest}`
1701
+ );
1702
+ const updateProcess = spawnFn(updateCommand, {
1703
+ stdio: "ignore",
1704
+ shell: true,
1705
+ detached: true
1706
+ });
1707
+ _updateInProgress = true;
1708
+ updateProcess.unref();
1709
+ updateProcess.on("close", async (code) => {
1710
+ _updateInProgress = false;
1711
+ if (code === 0) {
1712
+ let isVerified = true;
1713
+ try {
1714
+ if (resolvedCliPath && info.update.latest) {
1715
+ const checkDir = path2.dirname(resolvedCliPath);
1716
+ const updatedPkg = await getPackageJsonFn(checkDir);
1717
+ if (updatedPkg?.version && info.update.name && updatedPkg.name === info.update.name && import_semver.default.valid(updatedPkg.version) && import_semver.default.valid(info.update.latest) && import_semver.default.lt(updatedPkg.version, info.update.latest)) {
1718
+ isVerified = false;
1719
+ }
1720
+ }
1721
+ } catch (err) {
1722
+ debugLogger.log("Failed to verify binary update version:", err);
1723
+ }
1724
+ if (!isVerified) {
1725
+ updateEventEmitter.emit("update-failed", {
1726
+ message: `Automatic update completed, but the active binary (${resolvedCliPath ?? process.argv[1] ?? "unknown path"}) was not updated. It may be shadowed by another installation in your PATH. Please try updating manually:
1727
+
1728
+ ${updateCommand}`
1729
+ });
1730
+ return;
1731
+ }
1732
+ updateEventEmitter.emit("update-success", {
1733
+ message: "Update successful! The new version will be used on your next run."
1734
+ });
1735
+ } else {
1736
+ updateEventEmitter.emit("update-failed", {
1737
+ message: `Automatic update failed. Please try updating manually:
1738
+
1739
+ ${updateCommand}`
1740
+ });
1741
+ }
1742
+ });
1743
+ updateProcess.on("error", (err) => {
1744
+ _updateInProgress = false;
1745
+ updateEventEmitter.emit("update-failed", {
1746
+ message: `Automatic update failed. Please try updating manually. (error: ${err.message})
1747
+
1748
+ ${updateCommand}`
1749
+ });
1750
+ });
1751
+ return updateProcess;
1752
+ }
1753
+ function setUpdateHandler(addItem, setUpdateInfo) {
1754
+ let successfullyInstalled = false;
1755
+ const handleUpdateReceived = (info) => {
1756
+ setUpdateInfo(info);
1757
+ const savedMessage = info.message;
1758
+ setTimeout(() => {
1759
+ if (!successfullyInstalled) {
1760
+ addItem(
1761
+ {
1762
+ type: "info" /* INFO */,
1763
+ text: savedMessage
1764
+ },
1765
+ Date.now()
1766
+ );
1767
+ }
1768
+ setUpdateInfo(null);
1769
+ }, 6e4);
1770
+ };
1771
+ const handleUpdateFailed = (data) => {
1772
+ setUpdateInfo(null);
1773
+ addItem(
1774
+ {
1775
+ type: "error" /* ERROR */,
1776
+ text: data?.message || `Automatic update failed. Please try updating manually`
1777
+ },
1778
+ Date.now()
1779
+ );
1780
+ };
1781
+ const handleUpdateSuccess = () => {
1782
+ successfullyInstalled = true;
1783
+ setUpdateInfo(null);
1784
+ addItem(
1785
+ {
1786
+ type: "info" /* INFO */,
1787
+ text: `Update successful! The new version will be used on your next run.`
1788
+ },
1789
+ Date.now()
1790
+ );
1791
+ };
1792
+ const handleUpdateInfo = (data) => {
1793
+ addItem(
1794
+ {
1795
+ type: "info" /* INFO */,
1796
+ text: data.message
1797
+ },
1798
+ Date.now()
1799
+ );
1800
+ };
1801
+ updateEventEmitter.on("update-received", handleUpdateReceived);
1802
+ updateEventEmitter.on("update-failed", handleUpdateFailed);
1803
+ updateEventEmitter.on("update-success", handleUpdateSuccess);
1804
+ updateEventEmitter.on("update-info", handleUpdateInfo);
1805
+ return () => {
1806
+ updateEventEmitter.off("update-received", handleUpdateReceived);
1807
+ updateEventEmitter.off("update-failed", handleUpdateFailed);
1808
+ updateEventEmitter.off("update-success", handleUpdateSuccess);
1809
+ updateEventEmitter.off("update-info", handleUpdateInfo);
1810
+ };
1811
+ }
1812
+
1813
+ // packages/cli/src/utils/processUtils.ts
1814
+ var FORWARDED_SIGNALS = [
1815
+ "SIGTERM",
1816
+ "SIGHUP",
1817
+ "SIGINT",
1818
+ "SIGQUIT",
1819
+ "SIGUSR1",
1820
+ "SIGUSR2"
1821
+ ];
1822
+ function setupSignalForwarding(child) {
1823
+ const forwarders = /* @__PURE__ */ new Map();
1824
+ for (const sig of FORWARDED_SIGNALS) {
1825
+ const handler = () => {
1826
+ if (process.platform === "win32" && (sig === "SIGINT" || sig === "SIGQUIT")) {
1827
+ return;
1828
+ }
1829
+ try {
1830
+ child.kill(sig);
1831
+ } catch {
1832
+ }
1833
+ };
1834
+ forwarders.set(sig, handler);
1835
+ process.on(sig, handler);
1836
+ }
1837
+ return () => {
1838
+ for (const [sig, handler] of forwarders) {
1839
+ process.off(sig, handler);
1840
+ }
1841
+ forwarders.clear();
1842
+ };
1843
+ }
1844
+ function handleChildProcessClose(code, signal, removeForwarders, resolve2) {
1845
+ removeForwarders();
1846
+ process.stdin.resume();
1847
+ if (signal) {
1848
+ try {
1849
+ process.kill(process.pid, signal);
1850
+ } catch {
1851
+ resolve2(1);
1852
+ return;
1853
+ }
1854
+ setTimeout(() => {
1855
+ resolve2(1);
1856
+ }, 100);
1857
+ return;
1858
+ }
1859
+ resolve2(code ?? 1);
1860
+ }
1861
+ var RELAUNCH_EXIT_CODE = 199;
1862
+ var isRelaunching = false;
1863
+ async function relaunchApp(options) {
1864
+ if (isRelaunching) return;
1865
+ isRelaunching = true;
1866
+ await waitForUpdateCompletion();
1867
+ if (process.send && !process.env["VITEST"] && options?.overrideAuthType) {
1868
+ await new Promise((resolve2) => {
1869
+ let resolved = false;
1870
+ const done = () => {
1871
+ if (!resolved) {
1872
+ resolved = true;
1873
+ resolve2();
1874
+ }
1875
+ };
1876
+ const timeout = setTimeout(done, 500);
1877
+ try {
1878
+ process.send(
1879
+ {
1880
+ type: "auth-selected-type",
1881
+ authType: options.overrideAuthType
1882
+ },
1883
+ () => {
1884
+ clearTimeout(timeout);
1885
+ done();
1886
+ }
1887
+ );
1888
+ } catch {
1889
+ clearTimeout(timeout);
1890
+ done();
1891
+ }
1892
+ });
1893
+ }
1894
+ await runExitCleanup();
1895
+ process.exit(RELAUNCH_EXIT_CODE);
1896
+ }
1897
+ function isStandardSea() {
1898
+ return process.argv[0] !== process.argv[1] && (process.env["IS_BINARY"] === "true" || process.isSea?.() === true);
1899
+ }
1900
+ function getScriptArgs() {
1901
+ return process.argv.slice(isStandardSea() ? 1 : 2);
1902
+ }
1903
+ function isSeaEnvironment() {
1904
+ return process.env["IS_BINARY"] === "true" || process.isSea?.() === true || process.argv[0] === process.argv[1];
1905
+ }
1906
+ function getSpawnConfig(nodeArgs, scriptArgs) {
1907
+ const isBinary = isSeaEnvironment();
1908
+ const newEnv = {
1909
+ ...process.env,
1910
+ GEMINI_CLI_NO_RELAUNCH: "true"
1911
+ };
1912
+ const finalSpawnArgs = [];
1913
+ if (isBinary) {
1914
+ if (nodeArgs.length > 0) {
1915
+ for (const arg of nodeArgs) {
1916
+ if (/[\s"'\\]/.test(arg)) {
1917
+ throw new Error(
1918
+ `Unsupported node argument for SEA relaunch: ${arg}. Complex escaping is not supported.`
1919
+ );
1920
+ }
1921
+ }
1922
+ const existingNodeOptions = process.env["NODE_OPTIONS"] || "";
1923
+ newEnv["NODE_OPTIONS"] = `${existingNodeOptions} ${nodeArgs.join(" ")}`.trim();
1924
+ }
1925
+ finalSpawnArgs.push(process.execPath, ...scriptArgs);
1926
+ } else {
1927
+ finalSpawnArgs.push(
1928
+ ...process.execArgv,
1929
+ ...nodeArgs,
1930
+ process.argv[1],
1931
+ ...scriptArgs
1932
+ );
1933
+ }
1934
+ return {
1935
+ spawnArgs: finalSpawnArgs,
1936
+ env: newEnv
1937
+ };
1938
+ }
1939
+
1940
+ export {
1941
+ isDevelopment,
1942
+ require_semver2 as require_semver,
1943
+ handleAutoUpdate,
1944
+ setUpdateHandler,
1945
+ setupSignalForwarding,
1946
+ handleChildProcessClose,
1947
+ RELAUNCH_EXIT_CODE,
1948
+ relaunchApp,
1949
+ getScriptArgs,
1950
+ getSpawnConfig
1951
+ };
1952
+ /**
1953
+ * @license
1954
+ * Copyright 2025 Google LLC
1955
+ * SPDX-License-Identifier: Apache-2.0
1956
+ */