vercel 58.8.0 → 58.9.1

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 (83) hide show
  1. package/dist/chunks/{add-RVZD257F.js → add-5NFS6DS7.js} +2 -2
  2. package/dist/chunks/{add-OJLNBYCB.js → add-NIBAFBPP.js} +6 -6
  3. package/dist/chunks/{add-GEI53S56.js → add-PJLLOYOB.js} +2 -2
  4. package/dist/chunks/{build-KAOW7IJ6.js → build-MF4TD2RD.js} +2 -2
  5. package/dist/chunks/{chunk-IFNTK75I.js → chunk-24TPLHEI.js} +9 -2
  6. package/dist/chunks/{chunk-IOBULT7M.js → chunk-4IFEBYTL.js} +216 -100
  7. package/dist/chunks/{chunk-N7C5X53Q.js → chunk-4RXXF7V7.js} +1 -1
  8. package/dist/chunks/{chunk-XTIQ7DV7.js → chunk-4XO6B3JD.js} +1 -1
  9. package/dist/chunks/{chunk-HJEZQCMB.js → chunk-6BEMCJFX.js} +2 -2
  10. package/dist/chunks/{chunk-7ZEPVL6J.js → chunk-6LBPHFMP.js} +2 -2
  11. package/dist/chunks/{chunk-55JM5YCD.js → chunk-BEKBCDTM.js} +1 -1
  12. package/dist/chunks/{chunk-4BQZVTJ2.js → chunk-DGDUIC5A.js} +1 -1
  13. package/dist/chunks/{chunk-FWZGQKRP.js → chunk-DJPFR2DG.js} +1 -1
  14. package/dist/chunks/{chunk-KPDA6YEP.js → chunk-GCSUBTKN.js} +8 -6
  15. package/dist/chunks/{chunk-ASSWFLX7.js → chunk-L7LKHLFB.js} +2 -2
  16. package/dist/chunks/{chunk-V3FYICX7.js → chunk-LIPSDQMJ.js} +1 -1
  17. package/dist/chunks/{chunk-AX2PTUXP.js → chunk-MAQ6U5X2.js} +1 -1
  18. package/dist/chunks/{chunk-YRYC7WDR.js → chunk-N6ZAAUNN.js} +4 -4
  19. package/dist/chunks/{chunk-SPQSJERL.js → chunk-NFIGIDOY.js} +1 -1
  20. package/dist/chunks/{chunk-LCZDGAXC.js → chunk-SHXS3ZJD.js} +1 -1
  21. package/dist/chunks/{chunk-4IVGF3OR.js → chunk-U6FXU4WS.js} +1 -1
  22. package/dist/chunks/{chunk-AF7S35K3.js → chunk-V3W6GV3A.js} +1 -1
  23. package/dist/chunks/{chunk-53LZ5BMD.js → chunk-VBAIEFLF.js} +2 -2
  24. package/dist/chunks/{chunk-EMD7HCIW.js → chunk-VNNVJGKE.js} +1 -1
  25. package/dist/chunks/{chunk-JFJGWMAL.js → chunk-VX6VORWT.js} +1 -1
  26. package/dist/chunks/{chunk-N2A6HWBD.js → chunk-W24ZG3GV.js} +1 -1
  27. package/dist/chunks/chunk-YRV4A73W.js +2910 -0
  28. package/dist/chunks/{clear-DWPIGPO2.js → clear-M3QWP3HM.js} +2 -2
  29. package/dist/chunks/{compile-vercel-config-FSU42P2X.js → compile-vercel-config-6DMGPMCK.js} +1 -1
  30. package/dist/chunks/{config-V42N5SNP.js → config-5D4R6677.js} +2 -2
  31. package/dist/chunks/{delete-5KRNKCYI.js → delete-CJG3FHU7.js} +2 -2
  32. package/dist/chunks/{delete-EQ5NJWPR.js → delete-ZWUWQT5H.js} +2 -2
  33. package/dist/chunks/{disable-KO6WDHRC.js → disable-CJKTITTQ.js} +2 -2
  34. package/dist/chunks/{discard-E7PLPNUL.js → discard-ABXIPZHK.js} +2 -2
  35. package/dist/chunks/{edit-OIXKTSXJ.js → edit-VJ43TKOX.js} +2 -2
  36. package/dist/chunks/{edit-55TQT6RK.js → edit-VNVPLLF7.js} +3 -3
  37. package/dist/chunks/{enable-UOEAVAUU.js → enable-L7ERJOO5.js} +2 -2
  38. package/dist/chunks/{export-X2XFUNPV.js → export-BDAKZGOD.js} +2 -2
  39. package/dist/chunks/{image-JAAMXTIA.js → image-MGZR4VEH.js} +3 -3
  40. package/dist/chunks/{import-builders-YDOLGBXS.js → import-builders-RBYAQIPN.js} +2 -2
  41. package/dist/chunks/{inspect-EYUJ32YM.js → inspect-3V6PPUA3.js} +3 -3
  42. package/dist/chunks/{inspect-W4AH3EKN.js → inspect-E6IHZHQI.js} +2 -2
  43. package/dist/chunks/{inspect-SQXG4BFZ.js → inspect-IO5JFCCX.js} +2 -2
  44. package/dist/chunks/{inspect-IP6EMMGZ.js → inspect-KQBV3ALQ.js} +2 -2
  45. package/dist/chunks/{inspect-S52AEYAQ.js → inspect-XDKWDIUB.js} +2 -2
  46. package/dist/chunks/{list-ZFHW4YYW.js → list-FTWJF5YO.js} +2 -2
  47. package/dist/chunks/{list-W2HMCZT7.js → list-RQB5Q7IJ.js} +16 -5
  48. package/dist/chunks/{list-KODWTHC2.js → list-S2ZEK7DX.js} +1 -1
  49. package/dist/chunks/{login-QA4765QP.js → login-AVIFCN4G.js} +2 -2
  50. package/dist/chunks/{ls-A3RJWHNR.js → ls-44QDBZEW.js} +2 -2
  51. package/dist/chunks/{ls-GZ5K57Y6.js → ls-BKZZIR53.js} +3 -3
  52. package/dist/chunks/{ls-GHFI6RDD.js → ls-FI4MV46I.js} +2 -2
  53. package/dist/chunks/{ls-GLFSM2NL.js → ls-JI2KIY4O.js} +2 -2
  54. package/dist/chunks/{ls-ESCK2JMH.js → ls-ZG43UJTR.js} +2 -2
  55. package/dist/chunks/{open-EE7WS2UB.js → open-FGSEFGJL.js} +2 -2
  56. package/dist/chunks/{permissions-L7NPGX2M.js → permissions-BDINZ7RC.js} +4 -4
  57. package/dist/chunks/{publish-7BIMCBQ6.js → publish-7FXAFWWN.js} +2 -2
  58. package/dist/chunks/{push-IKPIV52M.js → push-3P3NKZEG.js} +2 -2
  59. package/dist/chunks/{query-DFRPIOZM.js → query-7MQN4S3S.js} +1 -1
  60. package/dist/chunks/{reorder-GA5FVDKD.js → reorder-42YNZL7R.js} +2 -2
  61. package/dist/chunks/{reply-C3375THE.js → reply-36KQN23N.js} +2 -2
  62. package/dist/chunks/{resolve-MBWHKHSW.js → resolve-ESN7P6O3.js} +2 -2
  63. package/dist/chunks/{restore-WGSD5LXC.js → restore-RCNRC3YJ.js} +2 -2
  64. package/dist/chunks/{rm-KOUNSG5Y.js → rm-E2WEJZPW.js} +2 -2
  65. package/dist/chunks/{rm-XITL2VK4.js → rm-MMYOJPW4.js} +3 -3
  66. package/dist/chunks/{rm-PXBJERO4.js → rm-ODFQSS2C.js} +2 -2
  67. package/dist/chunks/{rm-UEFME3MH.js → rm-R77FI255.js} +2 -2
  68. package/dist/chunks/{rule-inspect-7MJ6F3H6.js → rule-inspect-FDBIBPKM.js} +3 -3
  69. package/dist/chunks/{rules-YBSW4TND.js → rules-3GSC27DA.js} +6 -6
  70. package/dist/chunks/{schema-JP4Z36AT.js → schema-QDU3FPNC.js} +1 -1
  71. package/dist/chunks/{tags-XEZOWSS3.js → tags-WZBKHB6D.js} +2 -2
  72. package/dist/chunks/{update-236TLBCO.js → update-KNN7C6KN.js} +6 -6
  73. package/dist/commands/build/index.js +16 -2718
  74. package/dist/commands/deploy/index.js +9 -9
  75. package/dist/commands/dev/index.js +8 -8
  76. package/dist/commands/env/index.js +4 -4
  77. package/dist/commands/link/index.js +6 -6
  78. package/dist/commands/list/index.js +2 -2
  79. package/dist/commands-bulk.js +1712 -745
  80. package/dist/index.js +64 -57
  81. package/dist/version.mjs +1 -1
  82. package/package.json +46 -46
  83. package/dist/chunks/chunk-ZGXTMIJX.js +0 -206
@@ -37,7 +37,7 @@ import {
37
37
  runInteractiveEditLoop,
38
38
  stripQuotes,
39
39
  validateActionFlags
40
- } from "./chunks/chunk-AX2PTUXP.js";
40
+ } from "./chunks/chunk-MAQ6U5X2.js";
41
41
  import {
42
42
  getRouteVersions
43
43
  } from "./chunks/chunk-AHU7WNL2.js";
@@ -57,7 +57,7 @@ import {
57
57
  requireProjectContext,
58
58
  validateRequiredArguments,
59
59
  withGlobalFlags as withGlobalFlags2
60
- } from "./chunks/chunk-4BQZVTJ2.js";
60
+ } from "./chunks/chunk-DGDUIC5A.js";
61
61
  import {
62
62
  canPrompt
63
63
  } from "./chunks/chunk-2473DUBR.js";
@@ -90,12 +90,12 @@ import {
90
90
  resolveOpenApiTagForTeamsCli,
91
91
  setAutoUpdate,
92
92
  tryOpenApiFallback
93
- } from "./chunks/chunk-YRYC7WDR.js";
93
+ } from "./chunks/chunk-N6ZAAUNN.js";
94
94
  import "./chunks/chunk-FGDKMNEN.js";
95
95
  import {
96
96
  getUpdateCommand,
97
97
  isGlobal
98
- } from "./chunks/chunk-EMD7HCIW.js";
98
+ } from "./chunks/chunk-VNNVJGKE.js";
99
99
  import {
100
100
  Now,
101
101
  addDomain,
@@ -116,7 +116,7 @@ import {
116
116
  require_cjs,
117
117
  require_jsonlines,
118
118
  setupDomain
119
- } from "./chunks/chunk-KPDA6YEP.js";
119
+ } from "./chunks/chunk-GCSUBTKN.js";
120
120
  import {
121
121
  require_format
122
122
  } from "./chunks/chunk-PRWJUY5U.js";
@@ -127,7 +127,7 @@ import {
127
127
  readLocalConfig,
128
128
  sleep,
129
129
  writeToConfigFile
130
- } from "./chunks/chunk-HJEZQCMB.js";
130
+ } from "./chunks/chunk-6BEMCJFX.js";
131
131
  import "./chunks/chunk-V5P25P7F.js";
132
132
  import {
133
133
  CHECKBOX_INSTRUCTIONS,
@@ -155,7 +155,7 @@ import {
155
155
  import {
156
156
  formatEnvironment,
157
157
  validateLsArgs
158
- } from "./chunks/chunk-LCZDGAXC.js";
158
+ } from "./chunks/chunk-SHXS3ZJD.js";
159
159
  import {
160
160
  validateJsonOutput
161
161
  } from "./chunks/chunk-KXDWXXJH.js";
@@ -465,7 +465,7 @@ import {
465
465
  webAnalyticsSubcommand,
466
466
  webhooksCommand,
467
467
  whoamiCommand
468
- } from "./chunks/chunk-IFNTK75I.js";
468
+ } from "./chunks/chunk-24TPLHEI.js";
469
469
  import {
470
470
  addSubcommand as addSubcommand12,
471
471
  buildSubcommand,
@@ -548,10 +548,12 @@ import {
548
548
  import "./chunks/chunk-7QVJTI5H.js";
549
549
  import "./chunks/chunk-O5GNPPTU.js";
550
550
  import {
551
+ dump,
552
+ load,
551
553
  main
552
- } from "./chunks/chunk-ZGXTMIJX.js";
554
+ } from "./chunks/chunk-YRV4A73W.js";
553
555
  import "./chunks/chunk-IB5L4LKZ.js";
554
- import "./chunks/chunk-55JM5YCD.js";
556
+ import "./chunks/chunk-BEKBCDTM.js";
555
557
  import {
556
558
  require_execa
557
559
  } from "./chunks/chunk-R6IGDGX3.js";
@@ -566,10 +568,10 @@ import {
566
568
  } from "./chunks/chunk-VXYGCOKL.js";
567
569
  import {
568
570
  ensureLink
569
- } from "./chunks/chunk-53LZ5BMD.js";
570
- import "./chunks/chunk-ASSWFLX7.js";
571
- import "./chunks/chunk-N2A6HWBD.js";
572
- import "./chunks/chunk-AF7S35K3.js";
571
+ } from "./chunks/chunk-VBAIEFLF.js";
572
+ import "./chunks/chunk-L7LKHLFB.js";
573
+ import "./chunks/chunk-W24ZG3GV.js";
574
+ import "./chunks/chunk-V3W6GV3A.js";
573
575
  import {
574
576
  help
575
577
  } from "./chunks/chunk-ZX2FSPWV.js";
@@ -632,7 +634,7 @@ import {
632
634
  selectOrg,
633
635
  toHost,
634
636
  ua_default
635
- } from "./chunks/chunk-IOBULT7M.js";
637
+ } from "./chunks/chunk-4IFEBYTL.js";
636
638
  import {
637
639
  TelemetryClient
638
640
  } from "./chunks/chunk-ECCWJHC6.js";
@@ -753,7 +755,7 @@ var require_tar_fs = __commonJS({
753
755
  var tar2 = require_tar_stream();
754
756
  var pump = require_pump();
755
757
  var mkdirp = require_mkdirp();
756
- var fs2 = __require("fs");
758
+ var fs4 = __require("fs");
757
759
  var path3 = __require("path");
758
760
  var os = __require("os");
759
761
  var win32 = os.platform() === "win32";
@@ -765,19 +767,19 @@ var require_tar_fs = __commonJS({
765
767
  var normalize = !win32 ? echo : function(name) {
766
768
  return name.replace(/\\/g, "/").replace(/[:?<>|]/g, "_");
767
769
  };
768
- var statAll = function(fs3, stat2, cwd, ignore, entries, sort) {
770
+ var statAll = function(fs5, stat4, cwd, ignore, entries, sort) {
769
771
  var queue = entries || ["."];
770
772
  return function loop(callback) {
771
773
  if (!queue.length)
772
774
  return callback();
773
775
  var next = queue.shift();
774
776
  var nextAbs = path3.join(cwd, next);
775
- stat2(nextAbs, function(err, stat3) {
777
+ stat4(nextAbs, function(err, stat5) {
776
778
  if (err)
777
779
  return callback(err);
778
- if (!stat3.isDirectory())
779
- return callback(null, next, stat3);
780
- fs3.readdir(nextAbs, function(err2, files) {
780
+ if (!stat5.isDirectory())
781
+ return callback(null, next, stat5);
782
+ fs5.readdir(nextAbs, function(err2, files) {
781
783
  if (err2)
782
784
  return callback(err2);
783
785
  if (sort)
@@ -786,7 +788,7 @@ var require_tar_fs = __commonJS({
786
788
  if (!ignore(path3.join(cwd, next, files[i])))
787
789
  queue.push(path3.join(next, files[i]));
788
790
  }
789
- callback(null, next, stat3);
791
+ callback(null, next, stat5);
790
792
  });
791
793
  });
792
794
  };
@@ -806,7 +808,7 @@ var require_tar_fs = __commonJS({
806
808
  cwd = ".";
807
809
  if (!opts)
808
810
  opts = {};
809
- var xfs = opts.fs || fs2;
811
+ var xfs = opts.fs || fs4;
810
812
  var ignore = opts.ignore || opts.filter || noop;
811
813
  var map = opts.map || noop;
812
814
  var mapStream = opts.mapStream || echo;
@@ -835,7 +837,7 @@ var require_tar_fs = __commonJS({
835
837
  pack.entry(header, onnextentry);
836
838
  });
837
839
  };
838
- var onstat = function(err, filename, stat2) {
840
+ var onstat = function(err, filename, stat4) {
839
841
  if (err)
840
842
  return pack.destroy(err);
841
843
  if (!filename) {
@@ -843,31 +845,31 @@ var require_tar_fs = __commonJS({
843
845
  pack.finalize();
844
846
  return finish(pack);
845
847
  }
846
- if (stat2.isSocket())
848
+ if (stat4.isSocket())
847
849
  return onnextentry();
848
850
  var header = {
849
851
  name: normalize(filename),
850
- mode: (stat2.mode | (stat2.isDirectory() ? dmode : fmode)) & umask,
851
- mtime: stat2.mtime,
852
- size: stat2.size,
852
+ mode: (stat4.mode | (stat4.isDirectory() ? dmode : fmode)) & umask,
853
+ mtime: stat4.mtime,
854
+ size: stat4.size,
853
855
  type: "file",
854
- uid: stat2.uid,
855
- gid: stat2.gid
856
+ uid: stat4.uid,
857
+ gid: stat4.gid
856
858
  };
857
- if (stat2.isDirectory()) {
859
+ if (stat4.isDirectory()) {
858
860
  header.size = 0;
859
861
  header.type = "directory";
860
862
  header = map(header) || header;
861
863
  return pack.entry(header, onnextentry);
862
864
  }
863
- if (stat2.isSymbolicLink()) {
865
+ if (stat4.isSymbolicLink()) {
864
866
  header.size = 0;
865
867
  header.type = "symlink";
866
868
  header = map(header) || header;
867
869
  return onsymlink(filename, header);
868
870
  }
869
871
  header = map(header) || header;
870
- if (!stat2.isFile()) {
872
+ if (!stat4.isFile()) {
871
873
  if (strict)
872
874
  return pack.destroy(new Error("unsupported type for " + filename));
873
875
  return onnextentry();
@@ -903,7 +905,7 @@ var require_tar_fs = __commonJS({
903
905
  cwd = ".";
904
906
  if (!opts)
905
907
  opts = {};
906
- var xfs = opts.fs || fs2;
908
+ var xfs = opts.fs || fs4;
907
909
  var ignore = opts.ignore || opts.filter || noop;
908
910
  var map = opts.map || noop;
909
911
  var mapStream = opts.mapStream || echo;
@@ -947,13 +949,13 @@ var require_tar_fs = __commonJS({
947
949
  });
948
950
  };
949
951
  var chperm = function(name, header, cb) {
950
- var link = header.type === "symlink";
951
- var chmod2 = link ? xfs.lchmod : xfs.chmod;
952
- var chown = link ? xfs.lchown : xfs.chown;
953
- if (!chmod2)
952
+ var link2 = header.type === "symlink";
953
+ var chmod3 = link2 ? xfs.lchmod : xfs.chmod;
954
+ var chown = link2 ? xfs.lchown : xfs.chown;
955
+ if (!chmod3)
954
956
  return cb();
955
957
  var mode = (header.mode | (header.type === "directory" ? dmode : fmode)) & umask;
956
- chmod2(name, mode, function(err) {
958
+ chmod3(name, mode, function(err) {
957
959
  if (err)
958
960
  return cb(err);
959
961
  if (!own)
@@ -971,7 +973,7 @@ var require_tar_fs = __commonJS({
971
973
  stream.resume();
972
974
  return next();
973
975
  }
974
- var stat2 = function(err) {
976
+ var stat4 = function(err) {
975
977
  if (err)
976
978
  return next(err);
977
979
  utimes(name, header, function(err2) {
@@ -989,7 +991,7 @@ var require_tar_fs = __commonJS({
989
991
  var dst = path3.resolve(path3.dirname(name), header.linkname);
990
992
  if (!dst.startsWith(path3.resolve(cwd)))
991
993
  return next(new Error(name + " is not a valid symlink"));
992
- xfs.symlink(header.linkname, name, stat2);
994
+ xfs.symlink(header.linkname, name, stat4);
993
995
  });
994
996
  };
995
997
  var onlink = function() {
@@ -1005,7 +1007,7 @@ var require_tar_fs = __commonJS({
1005
1007
  stream = xfs.createReadStream(srcpath);
1006
1008
  return onfile();
1007
1009
  }
1008
- stat2(err2);
1010
+ stat4(err2);
1009
1011
  });
1010
1012
  });
1011
1013
  });
@@ -1019,7 +1021,7 @@ var require_tar_fs = __commonJS({
1019
1021
  pump(rs, ws, function(err) {
1020
1022
  if (err)
1021
1023
  return next(err);
1022
- ws.on("close", stat2);
1024
+ ws.on("close", stat4);
1023
1025
  });
1024
1026
  };
1025
1027
  if (header.type === "directory") {
@@ -1029,7 +1031,7 @@ var require_tar_fs = __commonJS({
1029
1031
  own,
1030
1032
  uid: header.uid,
1031
1033
  gid: header.gid
1032
- }, stat2);
1034
+ }, stat4);
1033
1035
  }
1034
1036
  var dir = path3.dirname(name);
1035
1037
  validate(xfs, dir, path3.join(cwd, "."), function(err, valid) {
@@ -1064,14 +1066,14 @@ var require_tar_fs = __commonJS({
1064
1066
  extract.on("finish", opts.finish);
1065
1067
  return extract;
1066
1068
  };
1067
- function validate(fs3, name, root, cb) {
1069
+ function validate(fs5, name, root, cb) {
1068
1070
  if (name === root)
1069
1071
  return cb(null, true);
1070
- fs3.lstat(name, function(err, st) {
1072
+ fs5.lstat(name, function(err, st) {
1071
1073
  if (err && err.code !== "ENOENT")
1072
1074
  return cb(err);
1073
1075
  if (err || st.isDirectory())
1074
- return validate(fs3, path3.join(name, ".."), root, cb);
1076
+ return validate(fs5, path3.join(name, ".."), root, cb);
1075
1077
  cb(null, false);
1076
1078
  });
1077
1079
  }
@@ -2476,7 +2478,7 @@ async function activity(client) {
2476
2478
  return 0;
2477
2479
  }
2478
2480
  telemetry2.trackCliSubcommandLs(subcommandOriginal);
2479
- const listFn = (await import("./chunks/list-KODWTHC2.js")).default;
2481
+ const listFn = (await import("./chunks/list-S2ZEK7DX.js")).default;
2480
2482
  return listFn(client, telemetry2);
2481
2483
  }
2482
2484
  }
@@ -4839,14 +4841,14 @@ async function rules(client) {
4839
4841
  // src/commands/ai-gateway/coding-agents-setup.ts
4840
4842
  var import_chalk22 = __toESM(require_source(), 1);
4841
4843
  import { homedir } from "os";
4842
- import { existsSync as existsSync3 } from "fs";
4843
- import { dirname as dirname2, resolve } from "path";
4844
+ import { existsSync as existsSync2 } from "fs";
4845
+ import { dirname as dirname4, resolve } from "path";
4844
4846
 
4845
4847
  // src/util/ai-gateway/coding-agents/resolve.ts
4846
4848
  var import_chalk17 = __toESM(require_source(), 1);
4847
4849
 
4848
4850
  // src/util/ai-gateway/coding-agents/agents/claude-code.ts
4849
- import { join as join2 } from "path";
4851
+ import { join as join3 } from "path";
4850
4852
 
4851
4853
  // src/util/ai-gateway/coding-agents/config-files.ts
4852
4854
  init_main();
@@ -4856,7 +4858,9 @@ import {
4856
4858
  mkdir,
4857
4859
  copyFile,
4858
4860
  access,
4859
- lstat
4861
+ lstat,
4862
+ link,
4863
+ unlink
4860
4864
  } from "fs/promises";
4861
4865
  import { isDeepStrictEqual } from "util";
4862
4866
  import { dirname } from "path";
@@ -5137,6 +5141,20 @@ ${MANAGED_BLOCK_END}`;
5137
5141
  return `${existing}${prefix}${block2}
5138
5142
  `;
5139
5143
  }
5144
+ async function publishNoClobber(temporary, destination) {
5145
+ try {
5146
+ await link(temporary, destination);
5147
+ return true;
5148
+ } catch (error) {
5149
+ if (error.code === "EEXIST") {
5150
+ return false;
5151
+ }
5152
+ throw error;
5153
+ } finally {
5154
+ await unlink(temporary).catch(() => {
5155
+ });
5156
+ }
5157
+ }
5140
5158
  async function backupFile(path3) {
5141
5159
  const backupPath = `${path3}.bak`;
5142
5160
  await copyFile(path3, backupPath);
@@ -5148,9 +5166,11 @@ async function writeConfigFile(path3, content, mode) {
5148
5166
  }
5149
5167
 
5150
5168
  // src/util/ai-gateway/coding-agents/gateway.ts
5169
+ var GATEWAY_CODING_AGENT_BASE_URL = "https://ai-gateway.vercel.sh/coding-agent/v1";
5151
5170
  var GATEWAY_CODEX_BASE_URL = "https://ai-gateway.vercel.sh/codex/v1";
5152
5171
  var GATEWAY_CLAUDE_CODE_BASE_URL = "https://ai-gateway.vercel.sh/claude-code";
5153
5172
  var GATEWAY_API_KEY_ENV = "AI_GATEWAY_API_KEY";
5173
+ var GATEWAY_DEFAULT_MODEL = "anthropic/claude-fable-5";
5154
5174
  var KEY_PLACEHOLDER = "__AI_GATEWAY_API_KEY__";
5155
5175
  function resolveGatewayBaseUrl(override2, agentDefault) {
5156
5176
  const trimmed = override2?.trim();
@@ -5166,19 +5186,181 @@ function maskSecret(secret) {
5166
5186
  return `${secret.slice(0, 4)}\u2022\u2022\u2022\u2022${secret.slice(-4)}`;
5167
5187
  }
5168
5188
 
5189
+ // src/util/ai-gateway/coding-agents/migrations/claude-desktop-sessions.ts
5190
+ import { randomUUID } from "crypto";
5191
+ import * as fs from "fs/promises";
5192
+ import { dirname as dirname2, join as join2 } from "path";
5193
+ var MAX_RECORD_BYTES = 1024 * 1024;
5194
+ function codeSpan(value) {
5195
+ return `\`${value.replace(/[`\r\n]/g, "")}\``;
5196
+ }
5197
+ var RECORD_PATTERN = /\.json$/;
5198
+ function claudeAppSupportRoot(home) {
5199
+ if (process.platform === "darwin") {
5200
+ return join2(home, "Library", "Application Support");
5201
+ }
5202
+ if (process.platform === "win32") {
5203
+ return process.env.APPDATA || join2(home, "AppData", "Roaming");
5204
+ }
5205
+ return join2(home, ".config");
5206
+ }
5207
+ function toGatewayModelId(model) {
5208
+ return model.includes("/") ? model : `anthropic/${model}`;
5209
+ }
5210
+ async function listSubdirectories(path3) {
5211
+ try {
5212
+ const entries = await fs.readdir(path3, { withFileTypes: true });
5213
+ return entries.filter((e2) => e2.isDirectory()).map((e2) => e2.name);
5214
+ } catch {
5215
+ return [];
5216
+ }
5217
+ }
5218
+ async function findDestinationIdentity(root) {
5219
+ let best = null;
5220
+ for (const account of await listSubdirectories(root)) {
5221
+ for (const org of await listSubdirectories(join2(root, account))) {
5222
+ const path3 = join2(root, account, org);
5223
+ try {
5224
+ const stat4 = await fs.stat(path3);
5225
+ if (!best || stat4.mtimeMs > best.mtime) {
5226
+ best = { path: path3, mtime: stat4.mtimeMs };
5227
+ }
5228
+ } catch {
5229
+ }
5230
+ }
5231
+ }
5232
+ return best?.path ?? null;
5233
+ }
5234
+ async function readRecord2(path3) {
5235
+ let stat4;
5236
+ try {
5237
+ stat4 = await fs.stat(path3);
5238
+ } catch {
5239
+ return null;
5240
+ }
5241
+ if (!stat4.isFile() || stat4.size > MAX_RECORD_BYTES)
5242
+ return null;
5243
+ try {
5244
+ const raw = await fs.readFile(path3, "utf8");
5245
+ const record = JSON.parse(raw);
5246
+ if (typeof record !== "object" || record === null || Array.isArray(record)) {
5247
+ return null;
5248
+ }
5249
+ return { record, bytes: stat4.size };
5250
+ } catch {
5251
+ return null;
5252
+ }
5253
+ }
5254
+ async function writeRecordNoClobber(destination, contents) {
5255
+ if (await pathExists(destination))
5256
+ return "skipped";
5257
+ await fs.mkdir(dirname2(destination), { recursive: true });
5258
+ const temp = join2(dirname2(destination), `.migrate-${randomUUID()}.tmp`);
5259
+ await fs.writeFile(temp, contents, { mode: 384 });
5260
+ return await publishNoClobber(temp, destination) ? "copied" : "skipped";
5261
+ }
5262
+ async function planClaudeDesktopSessionMigration(home, appSupportRoot = claudeAppSupportRoot(home)) {
5263
+ const subscriptionRoot = join2(
5264
+ appSupportRoot,
5265
+ "Claude",
5266
+ "claude-code-sessions"
5267
+ );
5268
+ const gatewayRoot = join2(appSupportRoot, "Claude-3p", "claude-code-sessions");
5269
+ const destinationDir = await findDestinationIdentity(gatewayRoot);
5270
+ if (!destinationDir)
5271
+ return null;
5272
+ const copies = [];
5273
+ let totalBytes = 0;
5274
+ for (const account of await listSubdirectories(subscriptionRoot)) {
5275
+ for (const org of await listSubdirectories(
5276
+ join2(subscriptionRoot, account)
5277
+ )) {
5278
+ const identityDir = join2(subscriptionRoot, account, org);
5279
+ let names;
5280
+ try {
5281
+ names = await fs.readdir(identityDir);
5282
+ } catch {
5283
+ continue;
5284
+ }
5285
+ for (const name of names) {
5286
+ if (!RECORD_PATTERN.test(name))
5287
+ continue;
5288
+ const source = join2(identityDir, name);
5289
+ const destination = join2(destinationDir, name);
5290
+ if (await pathExists(destination))
5291
+ continue;
5292
+ const read = await readRecord2(source);
5293
+ if (!read)
5294
+ continue;
5295
+ copies.push({ source, destination, bytes: read.bytes });
5296
+ totalBytes += read.bytes;
5297
+ }
5298
+ }
5299
+ }
5300
+ if (copies.length === 0)
5301
+ return null;
5302
+ return {
5303
+ label: "Claude Desktop sessions",
5304
+ itemCount: copies.length,
5305
+ totalBytes,
5306
+ sourceRoots: [subscriptionRoot],
5307
+ destinationRoots: [destinationDir],
5308
+ prompt: [
5309
+ `Copy the ${copies.length} Claude Desktop session record${copies.length === 1 ? "" : "s"} (per-session \`.json\` files) under ${codeSpan(subscriptionRoot)} into ${codeSpan(destinationDir)}, keeping each filename.`,
5310
+ "In each copy, rewrite the top-level `model` field to its AI Gateway id by prefixing `anthropic/` when the value has no provider prefix (e.g. `claude-opus-4-8` \u2192 `anthropic/claude-opus-4-8`); keep any suffix such as `[1m]` intact. Leave every other field unchanged.",
5311
+ "Use atomic, no-clobber writes with mode 0600; skip records whose destination already exists. Never move, edit, delete, or overwrite an original record."
5312
+ ],
5313
+ async apply() {
5314
+ let copied = 0;
5315
+ let skipped = 0;
5316
+ const errors = [];
5317
+ for (const copy3 of copies) {
5318
+ try {
5319
+ const read = await readRecord2(copy3.source);
5320
+ if (!read) {
5321
+ skipped += 1;
5322
+ continue;
5323
+ }
5324
+ const record = { ...read.record };
5325
+ if (typeof record.model === "string") {
5326
+ record.model = toGatewayModelId(record.model);
5327
+ }
5328
+ const outcome = await writeRecordNoClobber(
5329
+ copy3.destination,
5330
+ `${JSON.stringify(record)}
5331
+ `
5332
+ );
5333
+ if (outcome === "copied")
5334
+ copied += 1;
5335
+ else
5336
+ skipped += 1;
5337
+ } catch (error) {
5338
+ errors.push(
5339
+ `${copy3.source}: ${error instanceof Error ? error.message : String(error)}`
5340
+ );
5341
+ }
5342
+ }
5343
+ return errors.length > 0 ? { copied, skipped, errors } : { copied, skipped };
5344
+ }
5345
+ };
5346
+ }
5347
+
5169
5348
  // src/util/ai-gateway/coding-agents/agents/claude-code.ts
5170
5349
  function claudeDir(home) {
5171
5350
  const dir = process.env.CLAUDE_CONFIG_DIR;
5172
- return dir && dir.trim() ? dir : join2(home, ".claude");
5351
+ return dir && dir.trim() ? dir : join3(home, ".claude");
5173
5352
  }
5174
5353
  var claudeCode = {
5175
5354
  id: "claude-code",
5176
5355
  displayName: "Claude Code",
5356
+ sessionMigration: {
5357
+ plan: ({ home }) => planClaudeDesktopSessionMigration(home)
5358
+ },
5177
5359
  async detect(home) {
5178
5360
  return pathExists(claudeDir(home));
5179
5361
  },
5180
5362
  configPath(ctx) {
5181
- return ctx.overrides?.["claude-code"] ?? join2(claudeDir(ctx.home), "settings.json");
5363
+ return ctx.overrides?.["claude-code"] ?? join3(claudeDir(ctx.home), "settings.json");
5182
5364
  },
5183
5365
  buildPlan(ctx) {
5184
5366
  const path3 = this.configPath(ctx);
@@ -5206,58 +5388,312 @@ var claudeCode = {
5206
5388
  }
5207
5389
  ],
5208
5390
  envExports,
5209
- notes: ctx.useKeychain ? [
5210
- "The Anthropic auth token is read from your shell environment (Keychain-backed).",
5211
- "Open a new terminal so ANTHROPIC_AUTH_TOKEN is loaded, then restart Claude Code."
5212
- ] : ["Restart Claude Code to pick up the new settings."]
5391
+ notes: [
5392
+ ...ctx.useKeychain ? [
5393
+ "The Anthropic auth token is read from your shell environment (Keychain-backed).",
5394
+ "Open a new terminal so ANTHROPIC_AUTH_TOKEN is loaded, then restart Claude Code."
5395
+ ] : ["Restart Claude Code to pick up the new settings."],
5396
+ "The Claude Desktop app switches providers in its own settings (Developer \u2192 Configure Third-Party Inference\u2026). After its first gateway launch, re-run this command to copy your existing desktop sessions over."
5397
+ ]
5213
5398
  };
5214
5399
  }
5215
5400
  };
5216
5401
 
5217
- // src/util/ai-gateway/coding-agents/agents/codex.ts
5402
+ // src/util/ai-gateway/coding-agents/agents/cline.ts
5218
5403
  import { join as join4 } from "path";
5404
+ var cline = {
5405
+ id: "cline",
5406
+ displayName: "Cline",
5407
+ experimental: true,
5408
+ async detect(home) {
5409
+ return pathExists(join4(home, ".cline"));
5410
+ },
5411
+ configPath(ctx) {
5412
+ return ctx.overrides?.["cline"] ?? join4(ctx.home, ".cline", "data", "settings", "providers.json");
5413
+ },
5414
+ buildPlan(ctx) {
5415
+ const path3 = this.configPath(ctx);
5416
+ return {
5417
+ fileChanges: [
5418
+ {
5419
+ path: path3,
5420
+ label: "Cline providers",
5421
+ format: "json",
5422
+ mode: 384,
5423
+ transform: (current) => {
5424
+ const isNew = !current || !current.trim();
5425
+ return mergeJson(current, {
5426
+ ...isNew ? { version: 1 } : {},
5427
+ lastUsedProvider: "vercel-ai-gateway",
5428
+ providers: {
5429
+ "vercel-ai-gateway": {
5430
+ settings: {
5431
+ provider: "vercel-ai-gateway",
5432
+ apiKey: ctx.apiKey,
5433
+ model: GATEWAY_DEFAULT_MODEL
5434
+ },
5435
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
5436
+ tokenSource: "manual"
5437
+ }
5438
+ }
5439
+ });
5440
+ }
5441
+ }
5442
+ ],
5443
+ envExports: [],
5444
+ notes: [
5445
+ `Cline will use its native Vercel AI Gateway provider with ${GATEWAY_DEFAULT_MODEL}; switch models in-session or with \`cline auth -p vercel-ai-gateway -m <gateway-model-id>\`.`,
5446
+ "In the VS Code extension, pick the Vercel AI Gateway provider under Settings \u2192 API Provider."
5447
+ ]
5448
+ };
5449
+ }
5450
+ };
5219
5451
 
5220
- // src/util/ai-gateway/coding-agents/desktop-apps.ts
5221
- import { existsSync } from "fs";
5222
- import { join as join3 } from "path";
5223
- function isMacAppInstalled(bundleName, home) {
5224
- if (process.platform !== "darwin") {
5452
+ // src/util/ai-gateway/coding-agents/agents/codex.ts
5453
+ import { join as join6 } from "path";
5454
+
5455
+ // src/util/ai-gateway/coding-agents/migrations/codex-sessions.ts
5456
+ import { createHash, randomUUID as randomUUID2 } from "crypto";
5457
+ import { v5 as uuidv5, validate as uuidValidate } from "uuid";
5458
+ import { createReadStream, createWriteStream } from "fs";
5459
+ import * as fs2 from "fs/promises";
5460
+ import { basename, dirname as dirname3, join as join5 } from "path";
5461
+ import { pipeline } from "stream/promises";
5462
+ var ROLLOUT_PATTERN = /^rollout-.*\.jsonl(?:\.zst)?$/;
5463
+ var MAX_METADATA_BYTES = 1024 * 1024;
5464
+ function hasCode(error, code2) {
5465
+ return error.code === code2;
5466
+ }
5467
+ async function readMeta(path3, gateway = false) {
5468
+ const handle = await fs2.open(path3, "r");
5469
+ const buffer = new Uint8Array(MAX_METADATA_BYTES + 1);
5470
+ let length = 0;
5471
+ let newline = -1;
5472
+ try {
5473
+ while (length < buffer.length && newline < 0) {
5474
+ const start = length;
5475
+ const read = await handle.read(
5476
+ buffer,
5477
+ start,
5478
+ buffer.length - start,
5479
+ start
5480
+ );
5481
+ if (read.bytesRead === 0)
5482
+ break;
5483
+ length += read.bytesRead;
5484
+ newline = buffer.indexOf(10, start);
5485
+ }
5486
+ } finally {
5487
+ await handle.close();
5488
+ }
5489
+ if (newline < 0 && length > MAX_METADATA_BYTES)
5490
+ throw new Error(`${basename(path3)} metadata exceeds 1 MiB`);
5491
+ const lineEnd = newline < 0 ? length : newline;
5492
+ const carriageReturn = buffer[lineEnd - 1] === 13;
5493
+ let record;
5494
+ try {
5495
+ record = JSON.parse(
5496
+ new TextDecoder().decode(
5497
+ buffer.subarray(0, carriageReturn ? lineEnd - 1 : lineEnd)
5498
+ )
5499
+ );
5500
+ } catch {
5501
+ return null;
5502
+ }
5503
+ const payload = record.payload;
5504
+ const id = typeof payload?.id === "string" ? payload.id : typeof payload?.session_id === "string" ? payload.session_id : "";
5505
+ if (record.type !== "session_meta" || !payload || !uuidValidate(id) || typeof payload.session_id === "string" && payload.session_id !== id || payload.originator !== "Codex Desktop" && !(payload.originator == null && payload.source === "vscode") || (gateway ? payload.model_provider !== "vercel" : payload.model_provider === "vercel")) {
5506
+ return null;
5507
+ }
5508
+ return {
5509
+ record,
5510
+ payload,
5511
+ id,
5512
+ delimiter: newline < 0 ? "" : carriageReturn ? "\r\n" : "\n",
5513
+ restOffset: newline < 0 ? length : newline + 1
5514
+ };
5515
+ }
5516
+ function codeSpan2(value) {
5517
+ return `\`${value.replace(/[`\r\n]/g, "")}\``;
5518
+ }
5519
+ async function findRollouts(root) {
5520
+ const files = [];
5521
+ async function visit(directory) {
5522
+ let entries;
5523
+ try {
5524
+ entries = await fs2.readdir(directory, { withFileTypes: true });
5525
+ } catch (error) {
5526
+ if (hasCode(error, "ENOENT"))
5527
+ return;
5528
+ throw error;
5529
+ }
5530
+ for (const entry of entries) {
5531
+ const path3 = join5(directory, entry.name);
5532
+ if (entry.isDirectory())
5533
+ await visit(path3);
5534
+ else if (entry.isFile() && ROLLOUT_PATTERN.test(entry.name))
5535
+ files.push(path3);
5536
+ }
5537
+ }
5538
+ await visit(root);
5539
+ return files;
5540
+ }
5541
+ async function planCopy(path3, root) {
5542
+ const metadata = await readMeta(path3);
5543
+ const filename = basename(path3);
5544
+ if (!metadata || !filename.toLowerCase().includes(metadata.id.toLowerCase()))
5545
+ return null;
5546
+ const destinationId = uuidv5(
5547
+ `vercel-ai-gateway/codex/${metadata.id.toLowerCase()}/vercel`,
5548
+ uuidv5.URL
5549
+ );
5550
+ const destination = join5(
5551
+ dirname3(path3),
5552
+ filename.replace(new RegExp(metadata.id, "i"), destinationId)
5553
+ );
5554
+ const item = {
5555
+ source: path3,
5556
+ destination,
5557
+ sourceId: metadata.id,
5558
+ destinationId,
5559
+ bytes: (await fs2.stat(path3)).size,
5560
+ root
5561
+ };
5562
+ try {
5563
+ await fs2.stat(destination);
5564
+ await validateDestination(item);
5565
+ return null;
5566
+ } catch (error) {
5567
+ if (!hasCode(error, "ENOENT"))
5568
+ throw error;
5569
+ }
5570
+ return item;
5571
+ }
5572
+ async function bodyHash(path3, start) {
5573
+ const hash = createHash("sha256");
5574
+ await pipeline(createReadStream(path3, { start }), hash);
5575
+ return hash.digest("hex");
5576
+ }
5577
+ async function validateDestination(item) {
5578
+ const [source, destination] = await Promise.all([
5579
+ readMeta(item.source),
5580
+ readMeta(item.destination, true)
5581
+ ]);
5582
+ const bodies = await Promise.all([
5583
+ bodyHash(item.source, source?.restOffset ?? 0),
5584
+ bodyHash(item.destination, destination?.restOffset ?? 0)
5585
+ ]);
5586
+ const valid = source && destination?.id === item.destinationId && bodies[0] === bodies[1];
5587
+ if (!valid)
5588
+ throw new Error(
5589
+ `Existing destination ${basename(item.destination)} is invalid`
5590
+ );
5591
+ }
5592
+ async function copySession(item) {
5593
+ const metadata = await readMeta(item.source);
5594
+ if (!metadata)
5595
+ throw new Error("Codex session metadata is no longer valid");
5596
+ if (metadata.id !== item.sourceId)
5597
+ throw new Error("Codex session metadata changed after planning");
5598
+ const updated = {
5599
+ ...metadata.record,
5600
+ payload: {
5601
+ ...metadata.payload,
5602
+ id: item.destinationId,
5603
+ session_id: item.destinationId,
5604
+ model_provider: "vercel"
5605
+ }
5606
+ };
5607
+ const temporary = `${item.destination}.tmp-${process.pid}-${randomUUID2()}`;
5608
+ try {
5609
+ await fs2.writeFile(
5610
+ temporary,
5611
+ `${JSON.stringify(updated)}${metadata.delimiter}`,
5612
+ { flag: "wx", mode: 384 }
5613
+ );
5614
+ await pipeline(
5615
+ createReadStream(item.source, { start: metadata.restOffset }),
5616
+ createWriteStream(temporary, { flags: "a", mode: 384 })
5617
+ );
5618
+ await fs2.chmod(temporary, 384);
5619
+ if (await publishNoClobber(temporary, item.destination)) {
5620
+ return true;
5621
+ }
5622
+ await validateDestination(item);
5225
5623
  return false;
5624
+ } finally {
5625
+ await fs2.unlink(temporary).catch((error) => {
5626
+ if (!hasCode(error, "ENOENT"))
5627
+ throw error;
5628
+ });
5629
+ }
5630
+ }
5631
+ async function planCodexSessionMigration(home) {
5632
+ const codexHome = process.env.CODEX_HOME || join5(home, ".codex");
5633
+ const roots = ["sessions", "archived_sessions"].map(
5634
+ (root) => join5(codexHome, root)
5635
+ );
5636
+ const files = [];
5637
+ for (const root of roots) {
5638
+ files.push(...(await findRollouts(root)).map((path3) => ({ path: path3, root })));
5226
5639
  }
5227
- return existsSync(join3("/Applications", bundleName)) || existsSync(join3(home, "Applications", bundleName));
5640
+ if (files.some((file) => file.path.endsWith(".jsonl.zst"))) {
5641
+ throw new Error(
5642
+ "Found compressed Codex sessions; decompress them first, or pass --no-session-migration to leave them unchanged"
5643
+ );
5644
+ }
5645
+ const copies = [];
5646
+ for (const file of files) {
5647
+ const copy3 = await planCopy(file.path, file.root);
5648
+ if (copy3)
5649
+ copies.push(copy3);
5650
+ }
5651
+ if (copies.length === 0)
5652
+ return null;
5653
+ const sourceRoots = [...new Set(copies.map((copy3) => copy3.root))];
5654
+ return {
5655
+ label: "Codex Desktop sessions",
5656
+ itemCount: copies.length,
5657
+ totalBytes: copies.reduce((total, copy3) => total + copy3.bytes, 0),
5658
+ sourceRoots,
5659
+ destinationRoots: sourceRoots,
5660
+ prompt: [
5661
+ `Before changing the provider, copy the ${copies.length} top-level Codex Desktop rollout${copies.length === 1 ? "" : "s"} with a non-\`vercel\` provider under ${sourceRoots.map(codeSpan2).join(", ")}. Do not copy subagent rollouts whose \`session_id\` differs from \`id\`.`,
5662
+ "For each copy, derive a deterministic UUID v5 using the URL namespace `6ba7b811-9dad-11d1-80b4-00c04fd430c8` and name `vercel-ai-gateway/codex/<source-id>/vercel`. Replace the filename UUID and `session_meta.payload.id`/`session_id`, set `model_provider` to `vercel`, and preserve every later JSONL byte.",
5663
+ "Use atomic, no-clobber writes with mode 0600; skip an existing deterministic destination only after validating its metadata and body. Never move, edit, delete, or overwrite an original session file."
5664
+ ],
5665
+ async apply() {
5666
+ let copied = 0;
5667
+ let skipped = 0;
5668
+ const errors = [];
5669
+ for (const item of copies) {
5670
+ try {
5671
+ await copySession(item) ? copied++ : skipped++;
5672
+ } catch (error) {
5673
+ errors.push(
5674
+ `${basename(item.source)}: ${error instanceof Error ? error.message : String(error)}`
5675
+ );
5676
+ }
5677
+ }
5678
+ return { copied, skipped, errors };
5679
+ }
5680
+ };
5228
5681
  }
5229
5682
 
5230
5683
  // src/util/ai-gateway/coding-agents/agents/codex.ts
5231
- var CODEX_DESKTOP_APP = "Codex.app";
5232
5684
  function codexDir(home) {
5233
5685
  const dir = process.env.CODEX_HOME;
5234
- return dir && dir.trim() ? dir : join4(home, ".codex");
5686
+ return dir && dir.trim() ? dir : join6(home, ".codex");
5235
5687
  }
5236
5688
  var codex = {
5237
5689
  id: "codex",
5238
5690
  displayName: "Codex",
5691
+ sessionMigration: { plan: ({ home }) => planCodexSessionMigration(home) },
5239
5692
  async detect(home) {
5240
5693
  return pathExists(codexDir(home));
5241
5694
  },
5242
- async warnings({ home, overrides }) {
5243
- const warnings = [];
5244
- if (isMacAppInstalled(CODEX_DESKTOP_APP, home)) {
5245
- const configPath = this.configPath({ apiKey: "", home, overrides });
5246
- warnings.push({
5247
- code: "desktop_app_breaks",
5248
- impact: "The Codex desktop app will stop working.",
5249
- why: [
5250
- 'The desktop app is installed and cannot use custom model providers, and connecting sets model_provider = "vercel" in the config.toml the app shares with the CLI.',
5251
- "The Codex CLI keeps working."
5252
- ],
5253
- undo: `remove the model_provider line from ${configPath}`,
5254
- confirm: "Configure Codex anyway?"
5255
- });
5256
- }
5257
- return warnings;
5258
- },
5259
5695
  configPath(ctx) {
5260
- return ctx.overrides?.["codex"] ?? join4(codexDir(ctx.home), "config.toml");
5696
+ return ctx.overrides?.["codex"] ?? join6(codexDir(ctx.home), "config.toml");
5261
5697
  },
5262
5698
  buildPlan(ctx) {
5263
5699
  const path3 = this.configPath(ctx);
@@ -5292,12 +5728,203 @@ var codex = {
5292
5728
  }
5293
5729
  };
5294
5730
 
5731
+ // src/util/ai-gateway/coding-agents/agents/cursor.ts
5732
+ import { join as join7 } from "path";
5733
+ var cursor = {
5734
+ id: "cursor",
5735
+ displayName: "Cursor",
5736
+ experimental: true,
5737
+ async detect(home) {
5738
+ return pathExists(join7(home, ".cursor"));
5739
+ },
5740
+ configPath(ctx) {
5741
+ return ctx.overrides?.["cursor"] ?? join7(ctx.home, ".cursor");
5742
+ },
5743
+ buildPlan(ctx) {
5744
+ return {
5745
+ fileChanges: [],
5746
+ envExports: [{ name: "AI_GATEWAY_API_KEY", value: ctx.apiKey }],
5747
+ notes: [
5748
+ "Cursor keeps its API-key settings in the app itself, so finish the setup there:",
5749
+ "1. Open Cursor \u2192 Settings (Cmd+Shift+J) \u2192 Models.",
5750
+ `2. Under OpenAI API Key: paste your gateway key, then enable "Override OpenAI Base URL" and set it to ${ctx.baseUrlOverride ?? GATEWAY_CODING_AGENT_BASE_URL}`,
5751
+ '3. Copy the key from a new terminal without echoing it: printf %s "$AI_GATEWAY_API_KEY" | pbcopy',
5752
+ '4. Use "Add model" to add gateway model ids you want in the picker (e.g. anthropic/claude-fable-5, openai/gpt-5.6-sol).',
5753
+ "While the override is on, Cursor's built-in non-OpenAI models stop working \u2014 use gateway model ids for everything, or toggle the override off to go back.",
5754
+ "Cursor chats are stored by its backend, so there are no local sessions to migrate.",
5755
+ "Cursor limitations: Tab completions never use custom keys, and Agent/Auto modes may bypass the override."
5756
+ ]
5757
+ };
5758
+ }
5759
+ };
5760
+
5761
+ // src/util/ai-gateway/coding-agents/agents/hermes.ts
5762
+ import { join as join8 } from "path";
5763
+ var PROVIDER_KEY = "vercel-ai-gateway";
5764
+ function asObject(value) {
5765
+ return value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
5766
+ }
5767
+ var hermes = {
5768
+ id: "hermes",
5769
+ displayName: "Hermes",
5770
+ experimental: true,
5771
+ async detect(home) {
5772
+ return pathExists(join8(home, ".hermes"));
5773
+ },
5774
+ configPath(ctx) {
5775
+ return ctx.overrides?.["hermes"] ?? join8(ctx.home, ".hermes", "config.yaml");
5776
+ },
5777
+ buildPlan(ctx) {
5778
+ const path3 = this.configPath(ctx);
5779
+ const api2 = ctx.baseUrlOverride ?? GATEWAY_CODING_AGENT_BASE_URL;
5780
+ return {
5781
+ fileChanges: [
5782
+ {
5783
+ path: path3,
5784
+ label: "Hermes config",
5785
+ format: "yaml",
5786
+ transform: (current) => {
5787
+ const config = asObject(load(current ?? "") ?? {});
5788
+ const providers2 = asObject(config.providers);
5789
+ providers2[PROVIDER_KEY] = {
5790
+ ...asObject(providers2[PROVIDER_KEY]),
5791
+ api: api2,
5792
+ key_env: "AI_GATEWAY_API_KEY",
5793
+ transport: "chat_completions",
5794
+ discover_models: true
5795
+ };
5796
+ config.providers = providers2;
5797
+ config.model = {
5798
+ ...asObject(config.model),
5799
+ provider: `custom:${PROVIDER_KEY}`,
5800
+ default: GATEWAY_DEFAULT_MODEL
5801
+ };
5802
+ return dump(config, { lineWidth: 120 });
5803
+ }
5804
+ }
5805
+ ],
5806
+ envExports: [{ name: "AI_GATEWAY_API_KEY", value: ctx.apiKey }],
5807
+ notes: [
5808
+ `Hermes will use the gateway with ${GATEWAY_DEFAULT_MODEL}; switch models in-session with /model custom:${PROVIDER_KEY}:<gateway-model-id>.`,
5809
+ "Open a new terminal first so AI_GATEWAY_API_KEY is loaded."
5810
+ ]
5811
+ };
5812
+ }
5813
+ };
5814
+
5815
+ // src/util/ai-gateway/coding-agents/agents/kilo.ts
5816
+ import { join as join9 } from "path";
5817
+ function kiloConfigDir(home) {
5818
+ const xdg = process.env.XDG_CONFIG_HOME;
5819
+ const base = xdg && xdg.startsWith("/") ? xdg : join9(home, ".config");
5820
+ return join9(base, "kilo");
5821
+ }
5822
+ var kilo = {
5823
+ id: "kilo",
5824
+ displayName: "Kilo Code",
5825
+ experimental: true,
5826
+ async detect(home) {
5827
+ return pathExists(kiloConfigDir(home));
5828
+ },
5829
+ configPath(ctx) {
5830
+ return ctx.overrides?.["kilo"] ?? join9(kiloConfigDir(ctx.home), "kilo.json");
5831
+ },
5832
+ buildPlan(ctx) {
5833
+ const path3 = this.configPath(ctx);
5834
+ const baseURL = ctx.baseUrlOverride ?? GATEWAY_CODING_AGENT_BASE_URL;
5835
+ return {
5836
+ fileChanges: [
5837
+ {
5838
+ path: path3,
5839
+ label: "Kilo Code config",
5840
+ format: "json",
5841
+ transform: (current) => mergeJson(current, {
5842
+ provider: {
5843
+ "openai-compatible": {
5844
+ options: {
5845
+ apiKey: "{env:AI_GATEWAY_API_KEY}",
5846
+ baseURL
5847
+ }
5848
+ }
5849
+ }
5850
+ })
5851
+ }
5852
+ ],
5853
+ envExports: [{ name: "AI_GATEWAY_API_KEY", value: ctx.apiKey }],
5854
+ notes: [
5855
+ "Kilo Code lists the gateway catalog automatically \u2014 pick a model with /models in a session (ids look like openai-compatible/anthropic/claude-fable-5).",
5856
+ "If you keep your Kilo config in kilo.jsonc instead of kilo.json, merge the new provider block into it manually."
5857
+ ]
5858
+ };
5859
+ }
5860
+ };
5861
+
5862
+ // src/util/ai-gateway/coding-agents/agents/openclaw.ts
5863
+ import { join as join10 } from "path";
5864
+ var PROVIDER_KEY2 = "vercel-ai-gateway";
5865
+ var STARTER_MODELS = [
5866
+ { id: "anthropic/claude-fable-5", name: "Claude Fable 5 (Gateway)" },
5867
+ { id: "anthropic/claude-opus-4.8", name: "Claude Opus 4.8 (Gateway)" },
5868
+ { id: "anthropic/claude-sonnet-4.6", name: "Claude Sonnet 4.6 (Gateway)" },
5869
+ { id: "openai/gpt-5.6-sol", name: "GPT-5.6 Sol (Gateway)" },
5870
+ { id: "google/gemini-3.6-flash", name: "Gemini 3.6 Flash (Gateway)" }
5871
+ ];
5872
+ var openclaw = {
5873
+ id: "openclaw",
5874
+ displayName: "OpenClaw",
5875
+ experimental: true,
5876
+ async detect(home) {
5877
+ return pathExists(join10(home, ".openclaw"));
5878
+ },
5879
+ configPath(ctx) {
5880
+ return ctx.overrides?.["openclaw"] ?? join10(ctx.home, ".openclaw", "openclaw.json");
5881
+ },
5882
+ buildPlan(ctx) {
5883
+ const path3 = this.configPath(ctx);
5884
+ const baseUrl = ctx.baseUrlOverride ?? GATEWAY_CODING_AGENT_BASE_URL;
5885
+ return {
5886
+ fileChanges: [
5887
+ {
5888
+ path: path3,
5889
+ label: "OpenClaw config",
5890
+ format: "json",
5891
+ transform: (current) => mergeJson(current, {
5892
+ models: {
5893
+ providers: {
5894
+ [PROVIDER_KEY2]: {
5895
+ baseUrl,
5896
+ // biome-ignore lint/suspicious/noTemplateCurlyInString: OpenClaw's own env-reference syntax, resolved by OpenClaw at load time
5897
+ apiKey: "${AI_GATEWAY_API_KEY}",
5898
+ api: "openai-completions",
5899
+ models: STARTER_MODELS
5900
+ }
5901
+ }
5902
+ },
5903
+ agents: {
5904
+ defaults: {
5905
+ model: {
5906
+ primary: `${PROVIDER_KEY2}/${GATEWAY_DEFAULT_MODEL}`
5907
+ }
5908
+ }
5909
+ }
5910
+ })
5911
+ }
5912
+ ],
5913
+ envExports: [{ name: "AI_GATEWAY_API_KEY", value: ctx.apiKey }],
5914
+ notes: [
5915
+ `OpenClaw will default to ${PROVIDER_KEY2}/${GATEWAY_DEFAULT_MODEL}; the starter model list is in openclaw.json \u2014 add any gateway model id there.`,
5916
+ "Restart the OpenClaw gateway process so the new provider loads."
5917
+ ]
5918
+ };
5919
+ }
5920
+ };
5921
+
5295
5922
  // src/util/ai-gateway/coding-agents/agents/opencode.ts
5296
- import { isAbsolute, join as join5 } from "path";
5923
+ import { isAbsolute, join as join11 } from "path";
5297
5924
  function defaultConfigPath(home) {
5298
5925
  const xdg = process.env.XDG_CONFIG_HOME;
5299
- const base = xdg && isAbsolute(xdg) ? xdg : join5(home, ".config");
5300
- return join5(base, "opencode", "opencode.json");
5926
+ const base = xdg && isAbsolute(xdg) ? xdg : join11(home, ".config");
5927
+ return join11(base, "opencode", "opencode.json");
5301
5928
  }
5302
5929
  var opencode = {
5303
5930
  id: "opencode",
@@ -5335,20 +5962,20 @@ var opencode = {
5335
5962
  };
5336
5963
 
5337
5964
  // src/util/ai-gateway/coding-agents/agents/pi.ts
5338
- import { join as join6 } from "path";
5965
+ import { join as join12 } from "path";
5339
5966
  function piAgentDir(home) {
5340
5967
  const dir = process.env.PI_CODING_AGENT_DIR;
5341
- return dir && dir.trim() ? dir : join6(home, ".pi", "agent");
5968
+ return dir && dir.trim() ? dir : join12(home, ".pi", "agent");
5342
5969
  }
5343
5970
  var pi = {
5344
5971
  id: "pi",
5345
5972
  displayName: "Pi",
5346
5973
  async detect(home) {
5347
5974
  const dir = process.env.PI_CODING_AGENT_DIR;
5348
- return pathExists(dir && dir.trim() ? dir : join6(home, ".pi"));
5975
+ return pathExists(dir && dir.trim() ? dir : join12(home, ".pi"));
5349
5976
  },
5350
5977
  configPath(ctx) {
5351
- return ctx.overrides?.["pi"] ?? join6(piAgentDir(ctx.home), "auth.json");
5978
+ return ctx.overrides?.["pi"] ?? join12(piAgentDir(ctx.home), "auth.json");
5352
5979
  },
5353
5980
  buildPlan(ctx) {
5354
5981
  const path3 = this.configPath(ctx);
@@ -5373,14 +6000,22 @@ var pi = {
5373
6000
  };
5374
6001
 
5375
6002
  // src/util/ai-gateway/coding-agents/agents/index.ts
5376
- var CODING_AGENTS = [claudeCode, codex, opencode, pi];
6003
+ var CODING_AGENTS = [
6004
+ claudeCode,
6005
+ cline,
6006
+ codex,
6007
+ cursor,
6008
+ hermes,
6009
+ kilo,
6010
+ openclaw,
6011
+ opencode,
6012
+ pi
6013
+ ];
5377
6014
  var DEFAULT_AGENTS = CODING_AGENTS.filter((a) => !a.experimental);
5378
6015
  function getAgentById(id) {
5379
6016
  return CODING_AGENTS.find((a) => a.id === id);
5380
6017
  }
5381
- var UNSUPPORTED_AGENTS = {
5382
- cursor: 'Cursor stores model settings in a SQLite database with no safely writable config, and its "Override OpenAI Base URL" GUI option is known to break other models. Set the base URL to https://ai-gateway.vercel.sh/v1 manually in Settings \u2192 Models if you want to try it.'
5383
- };
6018
+ var UNSUPPORTED_AGENTS = {};
5384
6019
 
5385
6020
  // src/util/ai-gateway/coding-agents/resolve.ts
5386
6021
  async function resolveAgents(args) {
@@ -5597,16 +6232,16 @@ async function createKey(client, opts) {
5597
6232
  }
5598
6233
 
5599
6234
  // src/util/ai-gateway/coding-agents/apply.ts
5600
- import { join as join7 } from "path";
6235
+ import { join as join13 } from "path";
5601
6236
 
5602
6237
  // src/util/ai-gateway/coding-agents/keychain.ts
5603
- import { existsSync as existsSync2 } from "fs";
6238
+ import { existsSync } from "fs";
5604
6239
  import { execFileSync } from "child_process";
5605
6240
  var SECURITY_BIN = "/usr/bin/security";
5606
6241
  var KEYCHAIN_SERVICE = "Vercel AI Gateway";
5607
6242
  var KEYCHAIN_ACCOUNT = "vercel-ai-gateway";
5608
6243
  function isKeychainAvailable() {
5609
- return process.platform === "darwin" && existsSync2(SECURITY_BIN);
6244
+ return process.platform === "darwin" && existsSync(SECURITY_BIN);
5610
6245
  }
5611
6246
  function storeKeyInKeychain(key) {
5612
6247
  try {
@@ -5647,26 +6282,42 @@ function copyToClipboard(text2) {
5647
6282
  }
5648
6283
 
5649
6284
  // src/util/ai-gateway/coding-agents/apply.ts
6285
+ async function planSessionMigrations(agents, ctx) {
6286
+ const migrations = [];
6287
+ for (const agent2 of agents) {
6288
+ if (!agent2.sessionMigration)
6289
+ continue;
6290
+ const migration = await agent2.sessionMigration.plan(ctx);
6291
+ if (migration && migration.itemCount > 0) {
6292
+ migrations.push({
6293
+ ...migration,
6294
+ agentId: agent2.id,
6295
+ agent: agent2.displayName
6296
+ });
6297
+ }
6298
+ }
6299
+ return migrations;
6300
+ }
5650
6301
  function detectShellRc(home, override2) {
5651
6302
  if (override2 && override2.trim())
5652
6303
  return override2;
5653
6304
  const shell = process.env.SHELL ?? "";
5654
6305
  if (shell.includes("fish")) {
5655
6306
  const xdg = process.env.XDG_CONFIG_HOME;
5656
- const base = xdg && xdg.startsWith("/") ? xdg : join7(home, ".config");
5657
- return join7(base, "fish", "config.fish");
6307
+ const base = xdg && xdg.startsWith("/") ? xdg : join13(home, ".config");
6308
+ return join13(base, "fish", "config.fish");
5658
6309
  }
5659
6310
  if (shell.includes("zsh")) {
5660
6311
  const zdot = process.env.ZDOTDIR;
5661
- return join7(zdot && zdot.trim() ? zdot : home, ".zshrc");
6312
+ return join13(zdot && zdot.trim() ? zdot : home, ".zshrc");
5662
6313
  }
5663
6314
  if (shell.includes("bash")) {
5664
- return join7(
6315
+ return join13(
5665
6316
  home,
5666
6317
  process.platform === "darwin" ? ".bash_profile" : ".bashrc"
5667
6318
  );
5668
6319
  }
5669
- return join7(home, ".profile");
6320
+ return join13(home, ".profile");
5670
6321
  }
5671
6322
  function shellQuote(value) {
5672
6323
  return `'${value.split("'").join("'\\''")}'`;
@@ -5691,6 +6342,23 @@ function envBlockBody(exports, useKeychain, fish) {
5691
6342
  }
5692
6343
  return lines.join("\n");
5693
6344
  }
6345
+ function preservedEnvLines(current, writtenNames) {
6346
+ if (!current)
6347
+ return [];
6348
+ const start = current.indexOf(MANAGED_BLOCK_START);
6349
+ const end = current.indexOf(MANAGED_BLOCK_END);
6350
+ if (start === -1 || end === -1 || end <= start)
6351
+ return [];
6352
+ const kept = [];
6353
+ for (const line2 of current.slice(start, end).split("\n")) {
6354
+ const match = /^(?:export|set -gx) ([A-Za-z_][A-Za-z0-9_]*)[ =]/.exec(
6355
+ line2.trim()
6356
+ );
6357
+ if (match && !writtenNames.has(match[1]))
6358
+ kept.push(line2.trim());
6359
+ }
6360
+ return kept;
6361
+ }
5694
6362
  function matchesWithStoredKey(current, templated) {
5695
6363
  const parts = templated.split(KEY_PLACEHOLDER);
5696
6364
  if (parts.length < 2) {
@@ -5700,7 +6368,7 @@ function matchesWithStoredKey(current, templated) {
5700
6368
  const pattern = `^${escaped[0]}([^\\s"'\\\\]+)${escaped.slice(1).join("\\1")}$`;
5701
6369
  return new RegExp(pattern).test(current);
5702
6370
  }
5703
- async function buildSetupPlan(agents, ctx) {
6371
+ async function buildSetupPlan(agents, ctx, migrations = []) {
5704
6372
  const pending = [];
5705
6373
  const envExports = [];
5706
6374
  const notes = [];
@@ -5738,12 +6406,20 @@ async function buildSetupPlan(agents, ctx) {
5738
6406
  ctx.useKeychain,
5739
6407
  shellRcPath.endsWith(".fish")
5740
6408
  );
6409
+ const writtenNames = new Set(envExports.map((e2) => e2.name));
5741
6410
  pending.push({
5742
6411
  path: shellRcPath,
5743
6412
  label: "Shell environment",
5744
6413
  format: "shell",
5745
6414
  owner: "Environment",
5746
- transform: (current) => upsertManagedBlock(current, body)
6415
+ transform: (current) => {
6416
+ const preserved = preservedEnvLines(current, writtenNames);
6417
+ return upsertManagedBlock(
6418
+ current,
6419
+ preserved.length > 0 ? `${body}
6420
+ ${preserved.join("\n")}` : body
6421
+ );
6422
+ }
5747
6423
  });
5748
6424
  }
5749
6425
  const byPath = /* @__PURE__ */ new Map();
@@ -5797,7 +6473,13 @@ async function buildSetupPlan(agents, ctx) {
5797
6473
  symlink
5798
6474
  });
5799
6475
  }
5800
- return { changes, notes, envExports, shellRcPath };
6476
+ return {
6477
+ changes,
6478
+ notes,
6479
+ envExports,
6480
+ shellRcPath,
6481
+ migrations
6482
+ };
5801
6483
  }
5802
6484
  async function applyPlan(plan, options) {
5803
6485
  const results = [];
@@ -5820,6 +6502,36 @@ async function applyPlan(plan, options) {
5820
6502
  }
5821
6503
  return results;
5822
6504
  }
6505
+ async function applySessionMigrations(plan) {
6506
+ const results = [];
6507
+ const errors = [];
6508
+ for (const migration of plan.migrations) {
6509
+ try {
6510
+ const result = await migration.apply();
6511
+ const { errors: copyErrors = [], ...counts } = result;
6512
+ results.push({
6513
+ agentId: migration.agentId,
6514
+ agent: migration.agent,
6515
+ label: migration.label,
6516
+ ...counts
6517
+ });
6518
+ errors.push(
6519
+ ...copyErrors.map((message) => ({
6520
+ agentId: migration.agentId,
6521
+ agent: migration.agent,
6522
+ message
6523
+ }))
6524
+ );
6525
+ } catch (error) {
6526
+ errors.push({
6527
+ agentId: migration.agentId,
6528
+ agent: migration.agent,
6529
+ message: error instanceof Error ? error.message : String(error)
6530
+ });
6531
+ }
6532
+ }
6533
+ return { results, errors };
6534
+ }
5823
6535
 
5824
6536
  // src/util/ai-gateway/coding-agents/render.ts
5825
6537
  var import_chalk20 = __toESM(require_source(), 1);
@@ -5933,6 +6645,11 @@ function printResolvedState(args) {
5933
6645
  const { selected, willCreate, name, budget, refreshPeriod, expiresAt } = args;
5934
6646
  output_manager_default.print(import_chalk20.default.bold(" Summary\n"));
5935
6647
  printAlignedLabel("Agents", selected.map((a) => a.displayName).join(", "));
6648
+ if (args.preserveKey) {
6649
+ printAlignedLabel("API key", "Existing configuration unchanged");
6650
+ output_manager_default.print("\n");
6651
+ return;
6652
+ }
5936
6653
  if (!willCreate) {
5937
6654
  printAlignedLabel("API key", "Using provided key");
5938
6655
  output_manager_default.print("\n");
@@ -5991,7 +6708,7 @@ function printPlan(plan, previewKey, opts = {}) {
5991
6708
  );
5992
6709
  if (change2.symlink) {
5993
6710
  output_manager_default.print(
5994
- ` ${import_chalk20.default.yellow("\u21B3 warning:")} this path is a symlink \u2014 the write will follow it to its target
6711
+ ` ${import_chalk20.default.yellow("\u21B3 warning:")} this path is a symlink; the write will follow it to its target
5995
6712
  `
5996
6713
  );
5997
6714
  }
@@ -6008,6 +6725,20 @@ function printPlan(plan, previewKey, opts = {}) {
6008
6725
  `);
6009
6726
  }
6010
6727
  }
6728
+ for (const migration of plan.migrations) {
6729
+ output_manager_default.print(
6730
+ ` ${import_chalk20.default.green("+")} ${import_chalk20.default.bold(migration.label)} (copy) ${import_chalk20.default.dim(
6731
+ `${migration.itemCount} ${migration.itemCount === 1 ? "session" : "sessions"}, ${formatBytes(migration.totalBytes)}`
6732
+ )}
6733
+ `
6734
+ );
6735
+ output_manager_default.print(
6736
+ import_chalk20.default.dim(
6737
+ ` \u21B3 copy only from ${migration.sourceRoots.join(", ")} to ${migration.destinationRoots.join(", ")}; originals remain unchanged
6738
+ `
6739
+ )
6740
+ );
6741
+ }
6011
6742
  output_manager_default.print("\n");
6012
6743
  }
6013
6744
  function printWarning(message) {
@@ -6046,12 +6777,29 @@ function printKey(key, opts = {}) {
6046
6777
  printKeyRow(key, opts);
6047
6778
  }
6048
6779
  function buildAgentPrompt(plan, apiKey) {
6049
- const sections = [
6780
+ const fileChanges = plan.changes.filter(
6781
+ (change2) => change2.status === "create" || change2.status === "update"
6782
+ );
6783
+ const sections = fileChanges.length > 0 ? [
6050
6784
  "Set up the Vercel AI Gateway for my coding agents by applying the file changes below.",
6051
6785
  "For each file, create it if missing or edit it to match the diff (lines starting with `+` are added, `-` are removed; `\u22EF` marks skipped unchanged lines).",
6052
6786
  `Any masked value (e.g. ${maskSecret(apiKey)}) is my AI Gateway API key, stored in my macOS Keychain; the config and shell already reference it with \`${"security find-generic-password"}\`, so leave those lookups as-is and do not ask me to paste the key.`,
6053
6787
  ""
6054
- ];
6788
+ ] : [];
6789
+ if (plan.migrations.length > 0) {
6790
+ sections.push(
6791
+ "# Existing Codex Desktop sessions",
6792
+ "Before editing the provider configuration, copy the sessions described below. Never move, delete, or overwrite the originals."
6793
+ );
6794
+ for (const migration of plan.migrations) {
6795
+ sections.push(
6796
+ "",
6797
+ `## ${migration.agent}: ${migration.label}`,
6798
+ ...migration.prompt
6799
+ );
6800
+ }
6801
+ sections.push("");
6802
+ }
6055
6803
  for (const change2 of plan.changes) {
6056
6804
  if (change2.status !== "create" && change2.status !== "update") {
6057
6805
  continue;
@@ -6070,6 +6818,13 @@ function buildAgentPrompt(plan, apiKey) {
6070
6818
  return `${sections.join("\n").trimEnd()}
6071
6819
  `;
6072
6820
  }
6821
+ function formatBytes(bytes5) {
6822
+ if (bytes5 < 1024)
6823
+ return `${bytes5} B`;
6824
+ if (bytes5 < 1024 ** 2)
6825
+ return `${(bytes5 / 1024).toFixed(1)} KiB`;
6826
+ return `${(bytes5 / 1024 ** 2).toFixed(1)} MiB`;
6827
+ }
6073
6828
 
6074
6829
  // src/util/ai-gateway/coding-agents/consent.ts
6075
6830
  var import_chalk21 = __toESM(require_source(), 1);
@@ -6145,13 +6900,22 @@ async function runMachine(args) {
6145
6900
  {
6146
6901
  status: AGENT_STATUS.OK,
6147
6902
  reason: "dry_run",
6148
- message: "Previewing AI Gateway coding-agent setup. No files written.",
6903
+ message: "Previewing AI Gateway coding-agent setup. No changes applied.",
6149
6904
  changes: previewPlan.changes.map((c) => ({
6150
6905
  agent: c.owners.join(", "),
6151
6906
  file: c.path,
6152
6907
  action: c.status === "create" ? "would_create" : c.status === "update" ? "would_update" : c.status,
6153
6908
  ...c.symlink ? { symlink: true } : {}
6154
6909
  })),
6910
+ migrations: previewPlan.migrations.map((m) => ({
6911
+ agent: m.agentId,
6912
+ label: m.label,
6913
+ action: "would_copy",
6914
+ sessions: m.itemCount,
6915
+ bytes: m.totalBytes,
6916
+ sourceRoots: m.sourceRoots,
6917
+ destinationRoots: m.destinationRoots
6918
+ })),
6155
6919
  skipped,
6156
6920
  warnings: args.warnings
6157
6921
  },
@@ -6202,10 +6966,36 @@ async function runMachine(args) {
6202
6966
  );
6203
6967
  return 0;
6204
6968
  }
6969
+ const sessionOnly = !args.keySource && !args.reconfigure && previewPlan.changes.every((c) => c.status === "unchanged") && previewPlan.migrations.length > 0;
6970
+ if (sessionOnly) {
6971
+ if (args.promptMode) {
6972
+ writeJson(client, {
6973
+ status: AGENT_STATUS.OK,
6974
+ reason: "agent_prompt",
6975
+ message: "Generated a Codex Desktop session migration prompt. No changes were applied.",
6976
+ prompt: buildAgentPrompt(previewPlan, ""),
6977
+ configured: [],
6978
+ skipped,
6979
+ warnings: args.warnings
6980
+ });
6981
+ return 0;
6982
+ }
6983
+ const migrated2 = await applySessionMigrations(previewPlan);
6984
+ writeJson(client, {
6985
+ status: migrated2.errors.length > 0 ? AGENT_STATUS.ERROR : AGENT_STATUS.OK,
6986
+ reason: migrated2.errors.length > 0 ? "session_migration_failed" : "sessions_migrated",
6987
+ message: migrated2.errors.length > 0 ? "One or more Codex Desktop session copies failed. Original sessions were left unchanged." : "Copied existing Codex Desktop sessions into the AI Gateway provider. Original sessions remain unchanged.",
6988
+ configured: [],
6989
+ migrated: migrated2.results,
6990
+ skipped: [...skipped, ...migrationSkips(migrated2.errors)],
6991
+ warnings: args.warnings
6992
+ });
6993
+ return migrated2.errors.length > 0 ? 1 : 0;
6994
+ }
6205
6995
  const applicable = previewPlan.changes.filter(
6206
6996
  (c) => (c.status === "create" || c.status === "update") && c.format !== "shell"
6207
6997
  );
6208
- if (applicable.length === 0 && errored.length > 0) {
6998
+ if (applicable.length === 0 && errored.length > 0 && (args.promptMode || previewPlan.migrations.length === 0)) {
6209
6999
  client.stdout.write(
6210
7000
  `${JSON.stringify(
6211
7001
  {
@@ -6222,6 +7012,31 @@ async function runMachine(args) {
6222
7012
  );
6223
7013
  return 1;
6224
7014
  }
7015
+ const migrated = args.promptMode ? { results: [], errors: [] } : await applySessionMigrations(previewPlan);
7016
+ if (migrated.errors.length > 0) {
7017
+ writeJson(client, {
7018
+ status: AGENT_STATUS.ERROR,
7019
+ reason: "session_migration_failed",
7020
+ message: "No agent configuration was changed because one or more Codex Desktop session copies failed. Original sessions were left unchanged.",
7021
+ configured: [],
7022
+ migrated: migrated.results,
7023
+ skipped: [...skipped, ...migrationSkips(migrated.errors)],
7024
+ warnings: args.warnings
7025
+ });
7026
+ return 1;
7027
+ }
7028
+ if (applicable.length === 0 && errored.length > 0) {
7029
+ writeJson(client, {
7030
+ status: AGENT_STATUS.ERROR,
7031
+ reason: "unparseable_config",
7032
+ message: "Copied the eligible sessions, but couldn't write any agent configurations.",
7033
+ configured: [],
7034
+ migrated: migrated.results,
7035
+ skipped,
7036
+ warnings: args.warnings
7037
+ });
7038
+ return 1;
7039
+ }
6225
7040
  let key;
6226
7041
  try {
6227
7042
  key = args.keySource ? args.keySource.key : await args.createKey();
@@ -6230,20 +7045,25 @@ async function runMachine(args) {
6230
7045
  outputAgentError(client, {
6231
7046
  status: AGENT_STATUS.ERROR,
6232
7047
  reason: err.status === 403 ? "forbidden" : AGENT_REASON.API_ERROR,
6233
- message: err.message
7048
+ message: err.message,
7049
+ hint: `Session migrations: ${JSON.stringify(migrated.results)}`
6234
7050
  });
6235
7051
  }
6236
7052
  throw err;
6237
7053
  }
6238
7054
  const useKeychain = args.useKeychain && storeKeyInKeychain(key);
6239
- const finalPlan = await buildSetupPlan(selected, {
6240
- apiKey: key,
6241
- home,
6242
- useKeychain,
6243
- overrides: args.overrides,
6244
- shellRcOverride: args.shellRcOverride,
6245
- baseUrlOverride: args.baseUrlOverride
6246
- });
7055
+ const finalPlan = await buildSetupPlan(
7056
+ selected,
7057
+ {
7058
+ apiKey: key,
7059
+ home,
7060
+ useKeychain,
7061
+ overrides: args.overrides,
7062
+ shellRcOverride: args.shellRcOverride,
7063
+ baseUrlOverride: args.baseUrlOverride
7064
+ },
7065
+ previewPlan.migrations
7066
+ );
6247
7067
  if (args.promptMode) {
6248
7068
  if (!useKeychain) {
6249
7069
  client.stdout.write(
@@ -6297,6 +7117,7 @@ async function runMachine(args) {
6297
7117
  action: r.action,
6298
7118
  backup: r.backupPath
6299
7119
  })),
7120
+ migrated: migrated.results,
6300
7121
  skipped,
6301
7122
  warnings: args.warnings,
6302
7123
  notes: finalPlan.notes.flatMap(
@@ -6310,6 +7131,17 @@ async function runMachine(args) {
6310
7131
  );
6311
7132
  return 0;
6312
7133
  }
7134
+ function migrationSkips(errors) {
7135
+ return errors.map((error) => ({
7136
+ target: error.agentId,
7137
+ reason: "session_migration_failed",
7138
+ message: error.message
7139
+ }));
7140
+ }
7141
+ function writeJson(client, value) {
7142
+ client.stdout.write(`${JSON.stringify(value, null, 2)}
7143
+ `);
7144
+ }
6313
7145
 
6314
7146
  // src/util/telemetry/commands/ai-gateway/coding-agents-setup.ts
6315
7147
  var AiGatewayCodingAgentsSetupTelemetryClient = class extends TelemetryClient {
@@ -6373,6 +7205,11 @@ var AiGatewayCodingAgentsSetupTelemetryClient = class extends TelemetryClient {
6373
7205
  this.trackCliFlag("no-backup");
6374
7206
  }
6375
7207
  }
7208
+ trackCliFlagNoSessionMigration(noSessionMigration) {
7209
+ if (noSessionMigration) {
7210
+ this.trackCliFlag("no-session-migration");
7211
+ }
7212
+ }
6376
7213
  trackCliFlagNoKeychain(noKeychain) {
6377
7214
  if (noKeychain) {
6378
7215
  this.trackCliFlag("no-keychain");
@@ -6433,6 +7270,7 @@ async function codingAgentsSetup(client, argv) {
6433
7270
  const reconfigure = opts["--reconfigure"];
6434
7271
  const dryRun = opts["--dry-run"];
6435
7272
  const noBackup = opts["--no-backup"];
7273
+ const noSessionMigration = opts["--no-session-migration"];
6436
7274
  const noKeychain = opts["--no-keychain"];
6437
7275
  const agentConfig = opts["--agent-config"];
6438
7276
  const shellRcOverride = opts["--shell-rc"];
@@ -6450,6 +7288,7 @@ async function codingAgentsSetup(client, argv) {
6450
7288
  telemetry2.trackCliFlagReconfigure(reconfigure);
6451
7289
  telemetry2.trackCliFlagDryRun(dryRun);
6452
7290
  telemetry2.trackCliFlagNoBackup(noBackup);
7291
+ telemetry2.trackCliFlagNoSessionMigration(noSessionMigration);
6453
7292
  telemetry2.trackCliFlagNoKeychain(noKeychain);
6454
7293
  telemetry2.trackCliOptionAgentConfig(agentConfig);
6455
7294
  telemetry2.trackCliOptionShellRc(shellRcOverride);
@@ -6492,14 +7331,6 @@ async function codingAgentsSetup(client, argv) {
6492
7331
  `Invalid --apply "${applyMode}". Must be "edit" or "prompt".`
6493
7332
  );
6494
7333
  }
6495
- if (applyMode === "prompt" && !wantKeychain) {
6496
- return failValidation(
6497
- client,
6498
- machine,
6499
- AGENT_REASON.INVALID_ARGUMENTS,
6500
- "The `--apply prompt` mode needs the macOS Keychain so the prompt never contains your plaintext key. Run on macOS without --no-keychain, or use `--apply edit`."
6501
- );
6502
- }
6503
7334
  if (baseUrl !== void 0 && !isValidBaseUrl(baseUrl)) {
6504
7335
  return failValidation(
6505
7336
  client,
@@ -6534,7 +7365,7 @@ async function codingAgentsSetup(client, argv) {
6534
7365
  }
6535
7366
  if (dryRun && !machine) {
6536
7367
  printStatus(
6537
- `${import_chalk22.default.bold("Dry run")} \u2014 previewing changes only. No files will be written and no API key will be created.`
7368
+ `${import_chalk22.default.bold("Dry run")}: previewing changes only. No files will be written and no API key will be created.`
6538
7369
  );
6539
7370
  }
6540
7371
  const selection = await resolveAgents({
@@ -6621,21 +7452,73 @@ async function codingAgentsSetup(client, argv) {
6621
7452
  }
6622
7453
  }
6623
7454
  }
7455
+ let sessionMigrations = [];
7456
+ if (!noSessionMigration) {
7457
+ try {
7458
+ sessionMigrations = await planSessionMigrations(agents, { home });
7459
+ } catch (error) {
7460
+ return failValidation(
7461
+ client,
7462
+ machine,
7463
+ "session_migration_failed",
7464
+ `${error instanceof Error ? error.message : String(error)}. No configuration was changed. Pass --no-session-migration to leave existing sessions untouched and continue.`
7465
+ );
7466
+ }
7467
+ if (sessionMigrations.length > 0 && canPrompt2 && !yes && !dryRun) {
7468
+ const count2 = sessionMigrations.reduce(
7469
+ (total, migration) => total + migration.itemCount,
7470
+ 0
7471
+ );
7472
+ const agentNames = [
7473
+ ...new Set(sessionMigrations.map((migration) => migration.agent))
7474
+ ].join(" and ");
7475
+ const migrate = await client.input.confirm(
7476
+ count2 === 1 ? `Copy your existing ${agentNames} Desktop session so it stays visible after switching to the AI Gateway? The original will be left unchanged.` : `Copy your ${count2} existing ${agentNames} Desktop sessions so they stay visible after switching to the AI Gateway? The originals will be left unchanged.`,
7477
+ true
7478
+ );
7479
+ if (!migrate) {
7480
+ sessionMigrations = [];
7481
+ printStatus(
7482
+ `Skipped ${agentNames} Desktop session migration. Your existing sessions were left unchanged.`
7483
+ );
7484
+ }
7485
+ }
7486
+ }
6624
7487
  const willCreate = !providedKey;
6625
7488
  let keyName = name;
6626
7489
  let keyBudget = budget;
6627
7490
  let keyRefresh = refreshPeriod;
6628
7491
  let keyExpiresAt = flagExpiresAt;
6629
- if (willCreate && agents.length > 0 && (!dryRun || canPrompt2)) {
7492
+ const preflightPlan = await buildSetupPlan(
7493
+ agents,
7494
+ {
7495
+ apiKey: previewKey,
7496
+ home,
7497
+ useKeychain: wantKeychain,
7498
+ overrides,
7499
+ shellRcOverride,
7500
+ baseUrlOverride: baseUrl
7501
+ },
7502
+ sessionMigrations
7503
+ );
7504
+ const preflightSessionOnly = !providedKey && !reconfigure && preflightPlan.changes.every((change2) => change2.status === "unchanged") && preflightPlan.migrations.length > 0;
7505
+ if (applyMode === "prompt" && !wantKeychain && !preflightSessionOnly) {
7506
+ return failValidation(
7507
+ client,
7508
+ machine,
7509
+ AGENT_REASON.INVALID_ARGUMENTS,
7510
+ "The `--apply prompt` mode needs the macOS Keychain so the prompt never contains your plaintext key. Run on macOS without --no-keychain, or use `--apply edit`."
7511
+ );
7512
+ }
7513
+ if (willCreate && !preflightSessionOnly && agents.length > 0 && (!dryRun || canPrompt2)) {
6630
7514
  const promptCreate = canPrompt2 && !yes;
6631
7515
  const teamError = await ensureTeam2(client, {
6632
7516
  machine,
6633
7517
  canPrompt: canPrompt2,
6634
7518
  yes: Boolean(yes)
6635
7519
  });
6636
- if (teamError) {
7520
+ if (teamError)
6637
7521
  return teamError;
6638
- }
6639
7522
  if (promptCreate && keyName === void 0) {
6640
7523
  keyName = await promptKeyName(client);
6641
7524
  }
@@ -6651,12 +7534,12 @@ async function codingAgentsSetup(client, argv) {
6651
7534
  }
6652
7535
  }
6653
7536
  let useKeychain = wantKeychain;
6654
- if (wantKeychain && canPrompt2 && !yes) {
7537
+ if (!preflightSessionOnly && wantKeychain && canPrompt2 && !yes) {
6655
7538
  useKeychain = await promptKeychain(client);
6656
7539
  }
6657
7540
  if (canPrompt2 && !yes) {
6658
7541
  const missing = agents.filter(
6659
- (a) => !overrides[a.id] && !existsSync3(dirname2(a.configPath({ apiKey: "", home })))
7542
+ (a) => !overrides[a.id] && !existsSync2(dirname4(a.configPath({ apiKey: "", home })))
6660
7543
  );
6661
7544
  if (missing.length > 0) {
6662
7545
  const customize = await client.input.confirm(
@@ -6686,19 +7569,25 @@ async function codingAgentsSetup(client, argv) {
6686
7569
  "--base-url has no effect for the selected agents; only Claude Code and Codex write a gateway base URL."
6687
7570
  );
6688
7571
  }
6689
- const previewPlan = await buildSetupPlan(agents, {
6690
- apiKey: previewKey,
6691
- home,
6692
- useKeychain,
6693
- overrides,
6694
- shellRcOverride,
6695
- baseUrlOverride: baseUrl
6696
- });
7572
+ const previewPlan = await buildSetupPlan(
7573
+ agents,
7574
+ {
7575
+ apiKey: previewKey,
7576
+ home,
7577
+ useKeychain,
7578
+ overrides,
7579
+ shellRcOverride,
7580
+ baseUrlOverride: baseUrl
7581
+ },
7582
+ sessionMigrations
7583
+ );
6697
7584
  const changed = previewPlan.changes.filter(
6698
7585
  (c) => c.status === "create" || c.status === "update"
6699
7586
  );
6700
7587
  const errored = previewPlan.changes.filter((c) => c.status === "error");
6701
- const alreadyConfigured = changed.length === 0 && errored.length === 0;
7588
+ const noConfigChanges = changed.length === 0 && errored.length === 0;
7589
+ const alreadyConfigured = noConfigChanges && previewPlan.migrations.length === 0;
7590
+ const sessionOnly = !providedKey && !reconfigure && noConfigChanges && previewPlan.migrations.length > 0;
6702
7591
  if (machine) {
6703
7592
  return runMachine({
6704
7593
  client,
@@ -6773,24 +7662,25 @@ async function codingAgentsSetup(client, argv) {
6773
7662
  budget: keyBudget,
6774
7663
  refreshPeriod: keyRefresh,
6775
7664
  expiresAt: keyExpiresAt,
6776
- keychain: wantKeychain ? useKeychain : void 0
7665
+ keychain: wantKeychain ? useKeychain : void 0,
7666
+ preserveKey: sessionOnly
6777
7667
  });
6778
7668
  printPlan(previewPlan, previewKey, { backup: !noBackup });
6779
7669
  if (dryRun) {
6780
7670
  printStatus(
6781
- `Dry run \u2014 no files written. Re-run without ${import_chalk22.default.bold("--dry-run")} to apply.`
7671
+ `Dry run: no files written. Re-run without ${import_chalk22.default.bold("--dry-run")} to apply.`
6782
7672
  );
6783
7673
  return 0;
6784
7674
  }
6785
7675
  const agentConfigChanged = changed.filter((c) => c.format !== "shell");
6786
- if (agentConfigChanged.length === 0 && errored.length > 0) {
7676
+ if (agentConfigChanged.length === 0 && errored.length > 0 && previewPlan.migrations.length === 0) {
6787
7677
  output_manager_default.error(
6788
7678
  "Couldn't write any agent configurations. Fix the files above, then re-run."
6789
7679
  );
6790
7680
  return 1;
6791
7681
  }
6792
7682
  let applyAction = applyMode === "prompt" ? "copy" : "apply";
6793
- if (applyMode === void 0 && changed.length > 0 && canPrompt2 && !yes) {
7683
+ if (applyMode === void 0 && (changed.length > 0 || previewPlan.migrations.length > 0) && canPrompt2 && !yes) {
6794
7684
  if (useKeychain) {
6795
7685
  const choice = await client.input.select({
6796
7686
  message: "Apply these changes?",
@@ -6817,6 +7707,41 @@ async function codingAgentsSetup(client, argv) {
6817
7707
  }
6818
7708
  }
6819
7709
  }
7710
+ if (sessionOnly) {
7711
+ if (applyAction === "copy" && previewPlan.migrations.length > 0) {
7712
+ const promptText = buildAgentPrompt(previewPlan, KEY_PLACEHOLDER);
7713
+ emitAgentPrompt(client, promptText, applyMode === "prompt", "migration");
7714
+ return 0;
7715
+ }
7716
+ const migrated2 = await applySessionMigrations(previewPlan);
7717
+ printSessionMigrationReceipt(migrated2, true);
7718
+ return migrated2.errors.length > 0 ? 1 : 0;
7719
+ }
7720
+ if (applyAction === "copy" && !useKeychain) {
7721
+ return failValidation(
7722
+ client,
7723
+ machine,
7724
+ AGENT_REASON.INVALID_ARGUMENTS,
7725
+ "The `--apply prompt` mode needs the macOS Keychain so the prompt never contains your plaintext key. Run on macOS without --no-keychain, or use `--apply edit`."
7726
+ );
7727
+ }
7728
+ const migrated = applyAction === "apply" ? await applySessionMigrations(previewPlan) : { results: [], errors: [] };
7729
+ if (migrated.errors.length > 0) {
7730
+ printSessionMigrationReceipt(migrated);
7731
+ output_manager_default.error(
7732
+ "Session migration did not complete, so no agent configuration was changed. Rerun the command to retry, or pass --no-session-migration to set up without copying sessions."
7733
+ );
7734
+ return 1;
7735
+ }
7736
+ if (migrated.results.length > 0) {
7737
+ printSessionMigrationReceipt(migrated, true);
7738
+ }
7739
+ if (applyAction === "apply" && agentConfigChanged.length === 0 && errored.length > 0) {
7740
+ output_manager_default.error(
7741
+ "Copied the eligible sessions, but couldn't write any agent configurations. Fix the files above, then re-run."
7742
+ );
7743
+ return 1;
7744
+ }
6820
7745
  let keySource;
6821
7746
  try {
6822
7747
  keySource = providedKey ? { key: providedKey, created: false } : {
@@ -6849,33 +7774,21 @@ async function codingAgentsSetup(client, argv) {
6849
7774
  );
6850
7775
  useKeychain = false;
6851
7776
  }
6852
- const applyPlanResult = await buildSetupPlan(agents, {
6853
- apiKey: keySource.key,
6854
- home,
6855
- useKeychain,
6856
- overrides,
6857
- shellRcOverride,
6858
- baseUrlOverride: baseUrl
6859
- });
7777
+ const applyPlanResult = await buildSetupPlan(
7778
+ agents,
7779
+ {
7780
+ apiKey: keySource.key,
7781
+ home,
7782
+ useKeychain,
7783
+ overrides,
7784
+ shellRcOverride,
7785
+ baseUrlOverride: baseUrl
7786
+ },
7787
+ sessionMigrations
7788
+ );
6860
7789
  if (applyAction === "copy") {
6861
7790
  const promptText = buildAgentPrompt(applyPlanResult, keySource.key);
6862
- if (applyMode === "prompt") {
6863
- const copied = copyToClipboard(promptText);
6864
- printStatus(
6865
- copied ? "Created the key and generated an agent prompt (copied to clipboard; also written to stdout)." : "Created the key and generated an agent prompt (written to stdout)."
6866
- );
6867
- client.stdout.write(`${promptText}
6868
- `);
6869
- } else if (copyToClipboard(promptText)) {
6870
- printStatus(
6871
- "Prompt copied to clipboard. Paste it into your coding agent to apply the changes."
6872
- );
6873
- } else {
6874
- output_manager_default.debug("pbcopy failed or unavailable");
6875
- printStatus("Could not access the clipboard \u2014 prompt printed below:");
6876
- client.stdout.write(`${promptText}
6877
- `);
6878
- }
7791
+ emitAgentPrompt(client, promptText, applyMode === "prompt", "setup");
6879
7792
  printKey(keySource.key, { keychain: true, created: keySource.created });
6880
7793
  return 0;
6881
7794
  }
@@ -6918,7 +7831,42 @@ async function codingAgentsSetup(client, argv) {
6918
7831
  client.stdout.write(`${keySource.key}
6919
7832
  `);
6920
7833
  }
6921
- return 0;
7834
+ return migrated.errors.length > 0 ? 1 : 0;
7835
+ }
7836
+ function printSessionMigrationReceipt(migration, gutter = false) {
7837
+ if (gutter)
7838
+ output_manager_default.print("\n");
7839
+ for (const result of migration.results) {
7840
+ printAlignedLabel(
7841
+ "Sessions",
7842
+ `Copied ${result.copied} ${result.copied === 1 ? "session" : "sessions"} for ${result.agent}; originals unchanged`,
7843
+ gutter ? { gutter: "\u2713" } : void 0
7844
+ );
7845
+ gutter = false;
7846
+ }
7847
+ for (const error of migration.errors) {
7848
+ printWarning(
7849
+ `Could not migrate ${error.agent} sessions: ${error.message}. Original sessions were left unchanged.`
7850
+ );
7851
+ }
7852
+ }
7853
+ function emitAgentPrompt(client, prompt, writeToStdout, subject) {
7854
+ const copied = copyToClipboard(prompt);
7855
+ if (writeToStdout) {
7856
+ printStatus(
7857
+ `Generated the ${subject} prompt${copied ? " (also copied to clipboard)" : ""}.`
7858
+ );
7859
+ client.stdout.write(`${prompt}
7860
+ `);
7861
+ } else if (copied) {
7862
+ printStatus(
7863
+ `Prompt copied. Paste it into your coding agent for the ${subject}.`
7864
+ );
7865
+ } else {
7866
+ printStatus("Could not access the clipboard. Prompt printed below:");
7867
+ client.stdout.write(`${prompt}
7868
+ `);
7869
+ }
6922
7870
  }
6923
7871
  function buildConsentCommand(argv, consentFlags) {
6924
7872
  const args = stripSensitiveAuthArgs(argv.slice(2));
@@ -7333,7 +8281,7 @@ async function models(client) {
7333
8281
 
7334
8282
  // src/commands/ai-gateway/leaderboard-shared.ts
7335
8283
  var import_chalk25 = __toESM(require_source(), 1);
7336
- import { writeFile as writeFile3 } from "fs/promises";
8284
+ import { writeFile as writeFile5 } from "fs/promises";
7337
8285
 
7338
8286
  // src/util/ai-gateway/leaderboard.ts
7339
8287
  var DEFAULT_LEADERBOARD_BASE = "https://vercel.com";
@@ -7447,7 +8395,7 @@ async function fetchWithSpinner(fetch3, spinnerText) {
7447
8395
  async function writeToFile(client, out, content, label) {
7448
8396
  const writeStamp = stamp_default();
7449
8397
  try {
7450
- await writeFile3(out, content);
8398
+ await writeFile5(out, content);
7451
8399
  } catch (err) {
7452
8400
  output_manager_default.error(
7453
8401
  `Failed to write ${out}: ${err instanceof Error ? err.message : String(err)}`
@@ -8376,17 +9324,17 @@ ${extra}` : helpOutput);
8376
9324
  switch (subcommand) {
8377
9325
  case "inspect": {
8378
9326
  telemetry2.trackCliSubcommandInspect(subcommandOriginal);
8379
- const inspectFn = (await import("./chunks/inspect-SQXG4BFZ.js")).default;
9327
+ const inspectFn = (await import("./chunks/inspect-IO5JFCCX.js")).default;
8380
9328
  return inspectFn(client, rawSubcommandArgs);
8381
9329
  }
8382
9330
  case "rules": {
8383
9331
  telemetry2.trackCliSubcommandRules(args[0] ?? "ls");
8384
- const rulesFn = (await import("./chunks/rules-YBSW4TND.js")).default;
9332
+ const rulesFn = (await import("./chunks/rules-3GSC27DA.js")).default;
8385
9333
  return rulesFn(client, rawSubcommandArgs);
8386
9334
  }
8387
9335
  default: {
8388
9336
  telemetry2.trackCliSubcommandLs(subcommandOriginal);
8389
- const listFn = (await import("./chunks/list-ZFHW4YYW.js")).default;
9337
+ const listFn = (await import("./chunks/list-FTWJF5YO.js")).default;
8390
9338
  return listFn(client, telemetry2);
8391
9339
  }
8392
9340
  }
@@ -8819,7 +9767,9 @@ async function fetchDeploymentsByAppName(client, appName) {
8819
9767
  async function getAppLastDeployment(client, appName, user, contextName) {
8820
9768
  output_manager_default.debug(`Looking for deployments matching app ${appName}`);
8821
9769
  const deployments = await fetchDeploymentsByAppName(client, appName);
8822
- const deploymentItem = deployments.sort((a, b) => b.created - a.created).filter((dep) => dep.state === "READY" && dep.creator.uid === user.id)[0];
9770
+ const deploymentItem = deployments.sort((a, b) => b.created - a.created).filter(
9771
+ (dep) => dep.state === "READY" && (!user || dep.creator.uid === user.id)
9772
+ )[0];
8823
9773
  if (deploymentItem) {
8824
9774
  return await getDeployment(client, contextName, deploymentItem.uid);
8825
9775
  }
@@ -9368,8 +10318,8 @@ var BisectTelemetryClient = class extends TelemetryClient {
9368
10318
  });
9369
10319
  }
9370
10320
  }
9371
- trackCliFlagOpen(open15) {
9372
- if (open15) {
10321
+ trackCliFlagOpen(open16) {
10322
+ if (open16) {
9373
10323
  this.trackCliFlag("open");
9374
10324
  }
9375
10325
  }
@@ -9662,11 +10612,11 @@ var BlobListTelemetryClient = class extends TelemetryClient {
9662
10612
  });
9663
10613
  }
9664
10614
  }
9665
- trackCliOptionCursor(cursor) {
9666
- if (cursor) {
10615
+ trackCliOptionCursor(cursor2) {
10616
+ if (cursor2) {
9667
10617
  this.trackCliOption({
9668
10618
  option: "cursor",
9669
- value: cursor
10619
+ value: cursor2
9670
10620
  });
9671
10621
  }
9672
10622
  }
@@ -9829,12 +10779,12 @@ async function list9(client, argv, auth) {
9829
10779
  }
9830
10780
  const {
9831
10781
  "--limit": limit,
9832
- "--cursor": cursor,
10782
+ "--cursor": cursor2,
9833
10783
  "--prefix": prefix,
9834
10784
  "--mode": modeFlag
9835
10785
  } = flags;
9836
10786
  telemetryClient.trackCliOptionLimit(limit);
9837
- telemetryClient.trackCliOptionCursor(cursor);
10787
+ telemetryClient.trackCliOptionCursor(cursor2);
9838
10788
  telemetryClient.trackCliOptionPrefix(prefix);
9839
10789
  telemetryClient.trackCliOptionMode(modeFlag);
9840
10790
  const mode = modeFlag ?? "expanded";
@@ -9851,7 +10801,7 @@ async function list9(client, argv, auth) {
9851
10801
  list21 = await blob.list({
9852
10802
  ...blobOpts(auth),
9853
10803
  limit: limit ?? 10,
9854
- cursor,
10804
+ cursor: cursor2,
9855
10805
  mode,
9856
10806
  prefix
9857
10807
  });
@@ -10160,8 +11110,8 @@ var BlobTelemetryClient = class extends TelemetryClient {
10160
11110
  import * as blob2 from "@vercel/blob";
10161
11111
  var import_error_utils = __toESM(require_dist(), 1);
10162
11112
  import { statSync } from "fs";
10163
- import { open as open2 } from "fs/promises";
10164
- import { basename } from "path";
11113
+ import { open as open3 } from "fs/promises";
11114
+ import { basename as basename2 } from "path";
10165
11115
  var import_chalk35 = __toESM(require_source(), 1);
10166
11116
 
10167
11117
  // src/util/telemetry/commands/blob/put.ts
@@ -10328,9 +11278,9 @@ async function put2(client, argv, auth) {
10328
11278
  const stats = statSync(filePath);
10329
11279
  const isFile = stats.isFile();
10330
11280
  if (isFile) {
10331
- const file = await open2(filePath, "r");
11281
+ const file = await open3(filePath, "r");
10332
11282
  putBody = file.createReadStream();
10333
- pathname = pathnameFlag ?? basename(filePath);
11283
+ pathname = pathnameFlag ?? basename2(filePath);
10334
11284
  } else {
10335
11285
  output_manager_default.error("Path to upload is not a file");
10336
11286
  return 1;
@@ -10419,9 +11369,9 @@ var BlobGetTelemetryClient = class extends TelemetryClient {
10419
11369
 
10420
11370
  // src/commands/blob/get.ts
10421
11371
  var import_bytes = __toESM(require_bytes(), 1);
10422
- import { createWriteStream } from "fs";
11372
+ import { createWriteStream as createWriteStream2 } from "fs";
10423
11373
  import { Readable } from "stream";
10424
- import { pipeline } from "stream/promises";
11374
+ import { pipeline as pipeline2 } from "stream/promises";
10425
11375
  async function get2(client, argv, auth) {
10426
11376
  const telemetryClient = new BlobGetTelemetryClient({
10427
11377
  opts: {
@@ -10478,14 +11428,14 @@ async function get2(client, argv, auth) {
10478
11428
  }
10479
11429
  const nodeStream = Readable.fromWeb(result.stream);
10480
11430
  if (outputPath) {
10481
- const writeStream = createWriteStream(outputPath);
10482
- await pipeline(nodeStream, writeStream);
11431
+ const writeStream = createWriteStream2(outputPath);
11432
+ await pipeline2(nodeStream, writeStream);
10483
11433
  output_manager_default.stopSpinner();
10484
11434
  const sizeInfo = result.blob.size ? ` (${(0, import_bytes.default)(result.blob.size)})` : "";
10485
11435
  const typeInfo = result.blob.contentType ? `, ${result.blob.contentType}` : "";
10486
11436
  output_manager_default.success(`Saved to ${outputPath}${sizeInfo}${typeInfo}`);
10487
11437
  } else {
10488
- await pipeline(nodeStream, client.stdout, { end: false });
11438
+ await pipeline2(nodeStream, client.stdout, { end: false });
10489
11439
  }
10490
11440
  } catch (err) {
10491
11441
  output_manager_default.stopSpinner();
@@ -10961,12 +11911,12 @@ async function addStore(client, argv) {
10961
11911
  telemetryClient.trackCliArgumentName(name);
10962
11912
  telemetryClient.trackCliOptionAccess(accessFlag);
10963
11913
  telemetryClient.trackCliOptionRegion(flags["--region"]);
10964
- const link = await getLinkedProject(client);
10965
- if (link.status === "linked" && client.nonInteractive && !yes && !environmentFlags?.length) {
11914
+ const link2 = await getLinkedProject(client);
11915
+ if (link2.status === "linked" && client.nonInteractive && !yes && !environmentFlags?.length) {
10966
11916
  outputAgentError(client, {
10967
11917
  status: "error",
10968
11918
  reason: "confirmation_required",
10969
- message: `Creating a blob store and linking it to ${link.project.name} requires confirmation. Re-run with --yes to create the store and link it to all environments, or pass --environment to choose which ones.`,
11919
+ message: `Creating a blob store and linking it to ${link2.project.name} requires confirmation. Re-run with --yes to create the store and link it to all environments, or pass --environment to choose which ones.`,
10970
11920
  next: [
10971
11921
  {
10972
11922
  command: buildCommandWithYes(client.argv),
@@ -10987,7 +11937,7 @@ async function addStore(client, argv) {
10987
11937
  method: "POST",
10988
11938
  headers: { "Content-Type": "application/json" },
10989
11939
  body: JSON.stringify({ name, region, access: access4 }),
10990
- accountId: link.status === "linked" ? link.org.id : void 0
11940
+ accountId: link2.status === "linked" ? link2.org.id : void 0
10991
11941
  }
10992
11942
  );
10993
11943
  storeId = res.store.id;
@@ -11001,17 +11951,17 @@ async function addStore(client, argv) {
11001
11951
  output_manager_default.success(`Blob store created: ${name} (${storeId})${regionInfo}`);
11002
11952
  const docsUrl = access4 === "public" ? "https://vercel.com/docs/vercel-blob/public-storage" : "https://vercel.com/docs/vercel-blob/private-storage";
11003
11953
  output_manager_default.log(`Access: ${access4}. Learn more: ${output_manager_default.link(docsUrl, docsUrl)}`);
11004
- if (link.status === "linked") {
11954
+ if (link2.status === "linked") {
11005
11955
  let shouldLink = yes || Boolean(environmentFlags?.length);
11006
11956
  if (!shouldLink && interactive) {
11007
11957
  shouldLink = await client.input.confirm(
11008
- `Would you like to link this blob store to ${link.project.name}?`,
11958
+ `Would you like to link this blob store to ${link2.project.name}?`,
11009
11959
  true
11010
11960
  );
11011
11961
  }
11012
11962
  if (!shouldLink && !interactive) {
11013
11963
  output_manager_default.log(
11014
- `Not linked to ${import_chalk37.default.bold(link.project.name)}. Pass --yes when creating to link the store to your project automatically.`
11964
+ `Not linked to ${import_chalk37.default.bold(link2.project.name)}. Pass --yes when creating to link the store to your project automatically.`
11015
11965
  );
11016
11966
  }
11017
11967
  if (shouldLink) {
@@ -11031,27 +11981,27 @@ async function addStore(client, argv) {
11031
11981
  environments = [...VALID_ENVIRONMENTS];
11032
11982
  }
11033
11983
  output_manager_default.spinner(
11034
- `Connecting ${import_chalk37.default.bold(name)} to ${import_chalk37.default.bold(link.project.name)}...`
11984
+ `Connecting ${import_chalk37.default.bold(name)} to ${import_chalk37.default.bold(link2.project.name)}...`
11035
11985
  );
11036
11986
  await connectResourceToProject(
11037
11987
  client,
11038
- link.project.id,
11988
+ link2.project.id,
11039
11989
  storeId,
11040
11990
  environments,
11041
- { accountId: link.org.id }
11991
+ { accountId: link2.org.id }
11042
11992
  );
11043
11993
  output_manager_default.success(
11044
11994
  `Blob store ${import_chalk37.default.bold(name)} linked to ${import_chalk37.default.bold(
11045
- link.project.name
11995
+ link2.project.name
11046
11996
  )}`
11047
11997
  );
11048
- client.config.currentTeam = link.org.type === "team" ? link.org.id : void 0;
11998
+ client.config.currentTeam = link2.org.type === "team" ? link2.org.id : void 0;
11049
11999
  await envPullCommandLogic(
11050
12000
  client,
11051
12001
  ".env.local",
11052
12002
  true,
11053
12003
  "development",
11054
- link,
12004
+ link2,
11055
12005
  void 0,
11056
12006
  client.cwd,
11057
12007
  "vercel-cli:blob:store-add"
@@ -11129,8 +12079,8 @@ async function removeStore(client, argv, rwToken) {
11129
12079
  return 1;
11130
12080
  }
11131
12081
  }
11132
- const link = await getLinkedProject(client);
11133
- const accountId = link.status === "linked" ? link.org.id : void 0;
12082
+ const link2 = await getLinkedProject(client);
12083
+ const accountId = link2.status === "linked" ? link2.org.id : void 0;
11134
12084
  try {
11135
12085
  const [store, connectionsResponse] = await Promise.all([
11136
12086
  client.fetch(
@@ -11195,14 +12145,14 @@ async function removeStore(client, argv, rwToken) {
11195
12145
  }
11196
12146
  output_manager_default.stopSpinner();
11197
12147
  output_manager_default.success("Blob store deleted");
11198
- if (link.status === "linked") {
11199
- client.config.currentTeam = link.org.type === "team" ? link.org.id : void 0;
12148
+ if (link2.status === "linked") {
12149
+ client.config.currentTeam = link2.org.type === "team" ? link2.org.id : void 0;
11200
12150
  await envPullCommandLogic(
11201
12151
  client,
11202
12152
  ".env.local",
11203
12153
  true,
11204
12154
  "development",
11205
- link,
12155
+ link2,
11206
12156
  void 0,
11207
12157
  client.cwd,
11208
12158
  "vercel-cli:blob:store-remove"
@@ -11250,8 +12200,8 @@ function formatStoreDetails(store, teamSlug) {
11250
12200
  );
11251
12201
  if (teamSlug) {
11252
12202
  const dashboardUrl = `https://vercel.com/${teamSlug}/~/stores/blob/${store.id}`;
11253
- const link = output_manager_default.link(dashboardUrl, dashboardUrl);
11254
- lines.push(`Dashboard: ${link || dashboardUrl}`);
12203
+ const link2 = output_manager_default.link(dashboardUrl, dashboardUrl);
12204
+ lines.push(`Dashboard: ${link2 || dashboardUrl}`);
11255
12205
  }
11256
12206
  lines.push(
11257
12207
  `Created At: ${(0, import_format5.default)(new Date(store.createdAt), dateTimeFormat)}`
@@ -11319,10 +12269,10 @@ async function getStore(client, argv, rwToken) {
11319
12269
  }
11320
12270
  telemetryClient.trackCliArgumentStoreId(storeId);
11321
12271
  try {
11322
- const link = await getLinkedProject(client);
12272
+ const link2 = await getLinkedProject(client);
11323
12273
  output_manager_default.debug("Getting blob store");
11324
12274
  output_manager_default.spinner("Getting blob store");
11325
- const accountId = link.status === "linked" ? link.org.id : void 0;
12275
+ const accountId = link2.status === "linked" ? link2.org.id : void 0;
11326
12276
  const store = await client.fetch(
11327
12277
  `/v1/storage/stores/${storeId}`,
11328
12278
  {
@@ -11330,7 +12280,7 @@ async function getStore(client, argv, rwToken) {
11330
12280
  accountId
11331
12281
  }
11332
12282
  );
11333
- let teamSlug = link.status === "linked" ? link.org.slug : void 0;
12283
+ let teamSlug = link2.status === "linked" ? link2.org.slug : void 0;
11334
12284
  if (!teamSlug) {
11335
12285
  const { team } = await getScope(client);
11336
12286
  teamSlug = team?.slug;
@@ -11613,8 +12563,8 @@ async function emptyStore(client, argv, auth) {
11613
12563
  return 1;
11614
12564
  }
11615
12565
  try {
11616
- const link = await getLinkedProject(client);
11617
- const accountId = link.status === "linked" ? link.org.id : void 0;
12566
+ const link2 = await getLinkedProject(client);
12567
+ const accountId = link2.status === "linked" ? link2.org.id : void 0;
11618
12568
  const [storeResponse, connectionsResponse, initialList] = await Promise.all(
11619
12569
  [
11620
12570
  client.fetch(
@@ -12470,22 +13420,22 @@ async function purchaseCustomEnvironmentCapacity(client, {
12470
13420
  commandName
12471
13421
  }) {
12472
13422
  const { cwd } = client;
12473
- const link = await ensureLink(commandName, client, cwd, {
13423
+ const link2 = await ensureLink(commandName, client, cwd, {
12474
13424
  autoConfirm: yes,
12475
13425
  projectName,
12476
13426
  failIfNotFound: Boolean(projectName)
12477
13427
  });
12478
- if (typeof link === "number") {
12479
- return link;
13428
+ if (typeof link2 === "number") {
13429
+ return link2;
12480
13430
  }
12481
- const projectId = link.project.id;
12482
- const projectNameResolved = link.project.name;
13431
+ const projectId = link2.project.id;
13432
+ const projectNameResolved = link2.project.name;
12483
13433
  output_manager_default.spinner("Fetching custom environment settings");
12484
13434
  let settings;
12485
13435
  try {
12486
13436
  settings = await client.fetch(
12487
13437
  `/v1/projects/custom-environments/settings?projectId=${encodeURIComponent(projectId)}`,
12488
- { accountId: link.org.id }
13438
+ { accountId: link2.org.id }
12489
13439
  );
12490
13440
  } catch (err) {
12491
13441
  output_manager_default.stopSpinner();
@@ -12534,7 +13484,7 @@ async function purchaseCustomEnvironmentCapacity(client, {
12534
13484
  {
12535
13485
  method: "POST",
12536
13486
  body: { purchasedAmount },
12537
- accountId: link.org.id
13487
+ accountId: link2.org.id
12538
13488
  }
12539
13489
  );
12540
13490
  output_manager_default.stopSpinner();
@@ -13146,20 +14096,20 @@ async function purge(client, argv) {
13146
14096
  }
13147
14097
  const projectName = parsedArgs.flags["--project"];
13148
14098
  telemetry2.trackCliOptionProject(projectName);
13149
- const link = await resolveProjectContext({
14099
+ const link2 = await resolveProjectContext({
13150
14100
  client,
13151
14101
  projectNameOrId: projectName
13152
14102
  });
13153
- if (link.status === "not_linked") {
14103
+ if (link2.status === "not_linked") {
13154
14104
  output_manager_default.error(
13155
14105
  "No project linked. Run `vercel link` to link a project to this directory."
13156
14106
  );
13157
14107
  return 1;
13158
14108
  }
13159
- if (link.status === "error") {
13160
- return link.exitCode;
14109
+ if (link2.status === "error") {
14110
+ return link2.exitCode;
13161
14111
  }
13162
- const { project, org } = link;
14112
+ const { project, org } = link2;
13163
14113
  client.config.currentTeam = org.type === "team" ? org.id : void 0;
13164
14114
  const yes = Boolean(parsedArgs.flags["--yes"]);
13165
14115
  telemetry2.trackCliFlagYes(yes);
@@ -13269,20 +14219,20 @@ async function invalidate(client, argv) {
13269
14219
  }
13270
14220
  const projectName = parsedArgs.flags["--project"];
13271
14221
  telemetry2.trackCliOptionProject(projectName);
13272
- const link = await resolveProjectContext({
14222
+ const link2 = await resolveProjectContext({
13273
14223
  client,
13274
14224
  projectNameOrId: projectName
13275
14225
  });
13276
- if (link.status === "not_linked") {
14226
+ if (link2.status === "not_linked") {
13277
14227
  output_manager_default.error(
13278
14228
  "No project linked. Run `vercel link` to link a project to this directory."
13279
14229
  );
13280
14230
  return 1;
13281
14231
  }
13282
- if (link.status === "error") {
13283
- return link.exitCode;
14232
+ if (link2.status === "error") {
14233
+ return link2.exitCode;
13284
14234
  }
13285
- const { project, org } = link;
14235
+ const { project, org } = link2;
13286
14236
  client.config.currentTeam = org.type === "team" ? org.id : void 0;
13287
14237
  const yes = Boolean(parsedArgs.flags["--yes"]);
13288
14238
  const tag = parsedArgs.flags["--tag"];
@@ -13399,20 +14349,20 @@ async function dangerouslyDelete(client, argv) {
13399
14349
  }
13400
14350
  const projectName = parsedArgs.flags["--project"];
13401
14351
  telemetry2.trackCliOptionProject(projectName);
13402
- const link = await resolveProjectContext({
14352
+ const link2 = await resolveProjectContext({
13403
14353
  client,
13404
14354
  projectNameOrId: projectName
13405
14355
  });
13406
- if (link.status === "not_linked") {
14356
+ if (link2.status === "not_linked") {
13407
14357
  output_manager_default.error(
13408
14358
  "No project linked. Run `vercel link` to link a project to this directory."
13409
14359
  );
13410
14360
  return 1;
13411
14361
  }
13412
- if (link.status === "error") {
13413
- return link.exitCode;
14362
+ if (link2.status === "error") {
14363
+ return link2.exitCode;
13414
14364
  }
13415
- const { project, org } = link;
14365
+ const { project, org } = link2;
13416
14366
  client.config.currentTeam = org.type === "team" ? org.id : void 0;
13417
14367
  const yes = Boolean(parsedArgs.flags["--yes"]);
13418
14368
  const tag = parsedArgs.flags["--tag"];
@@ -13750,43 +14700,43 @@ async function comments(client) {
13750
14700
  if (handleHelp(inspectSubcommand4))
13751
14701
  return 0;
13752
14702
  telemetry2.trackCliSubcommandInspect(subcommandOriginal);
13753
- return (await import("./chunks/inspect-EYUJ32YM.js")).default(client, telemetry2);
14703
+ return (await import("./chunks/inspect-3V6PPUA3.js")).default(client, telemetry2);
13754
14704
  }
13755
14705
  case "open": {
13756
14706
  if (handleHelp(openSubcommand))
13757
14707
  return 0;
13758
14708
  telemetry2.trackCliSubcommandOpen(subcommandOriginal);
13759
- return (await import("./chunks/open-EE7WS2UB.js")).default(client, telemetry2);
14709
+ return (await import("./chunks/open-FGSEFGJL.js")).default(client, telemetry2);
13760
14710
  }
13761
14711
  case "reply": {
13762
14712
  if (handleHelp(replySubcommand))
13763
14713
  return 0;
13764
14714
  telemetry2.trackCliSubcommandReply(subcommandOriginal);
13765
- return (await import("./chunks/reply-C3375THE.js")).default(client, telemetry2);
14715
+ return (await import("./chunks/reply-36KQN23N.js")).default(client, telemetry2);
13766
14716
  }
13767
14717
  case "resolve": {
13768
14718
  if (handleHelp(resolveSubcommand))
13769
14719
  return 0;
13770
14720
  telemetry2.trackCliSubcommandResolve(subcommandOriginal);
13771
- return (await import("./chunks/resolve-MBWHKHSW.js")).default(client, telemetry2, true);
14721
+ return (await import("./chunks/resolve-ESN7P6O3.js")).default(client, telemetry2, true);
13772
14722
  }
13773
14723
  case "reopen": {
13774
14724
  if (handleHelp(reopenSubcommand))
13775
14725
  return 0;
13776
14726
  telemetry2.trackCliSubcommandReopen(subcommandOriginal);
13777
- return (await import("./chunks/resolve-MBWHKHSW.js")).default(client, telemetry2, false);
14727
+ return (await import("./chunks/resolve-ESN7P6O3.js")).default(client, telemetry2, false);
13778
14728
  }
13779
14729
  case "edit": {
13780
14730
  if (handleHelp(editSubcommand))
13781
14731
  return 0;
13782
14732
  telemetry2.trackCliSubcommandEdit(subcommandOriginal);
13783
- return (await import("./chunks/edit-OIXKTSXJ.js")).default(client, telemetry2);
14733
+ return (await import("./chunks/edit-VJ43TKOX.js")).default(client, telemetry2);
13784
14734
  }
13785
14735
  case "delete": {
13786
14736
  if (handleHelp(deleteSubcommand))
13787
14737
  return 0;
13788
14738
  telemetry2.trackCliSubcommandDelete(subcommandOriginal);
13789
- return (await import("./chunks/delete-5KRNKCYI.js")).default(client, telemetry2);
14739
+ return (await import("./chunks/delete-CJG3FHU7.js")).default(client, telemetry2);
13790
14740
  }
13791
14741
  default: {
13792
14742
  if (needHelp) {
@@ -13802,7 +14752,7 @@ async function comments(client) {
13802
14752
  }
13803
14753
  telemetry2.trackCliSubcommandList(subcommandOriginal);
13804
14754
  const defaultInvocation = subcommandOriginal === "default";
13805
- return (await import("./chunks/list-W2HMCZT7.js")).default(
14755
+ return (await import("./chunks/list-RQB5Q7IJ.js")).default(
13806
14756
  client,
13807
14757
  telemetry2,
13808
14758
  defaultInvocation
@@ -14127,7 +15077,7 @@ var ConnexTelemetryClient = class extends TelemetryClient {
14127
15077
 
14128
15078
  // src/commands/connex/create.ts
14129
15079
  var import_open3 = __toESM(require_open(), 1);
14130
- import { readFile as readFile4 } from "fs/promises";
15080
+ import { readFile as readFile5 } from "fs/promises";
14131
15081
  import { resolve as resolve5 } from "path";
14132
15082
  import { text } from "stream/consumers";
14133
15083
 
@@ -14149,13 +15099,13 @@ async function selectConnexTeam(client, message) {
14149
15099
  }
14150
15100
 
14151
15101
  // src/util/connex/request-code.ts
14152
- import { randomBytes, createHash } from "crypto";
15102
+ import { randomBytes, createHash as createHash2 } from "crypto";
14153
15103
  var POLL_INTERVAL_MS = 2e3;
14154
15104
  var MAX_POLL_DURATION_MS = 115 * 60 * 1e3;
14155
15105
  var MAX_EARLY_404_COUNT = 3;
14156
15106
  function generateRequestCode() {
14157
15107
  const verifier = randomBytes(37).toString("base64url");
14158
- const requestCode = createHash("sha256").update(verifier).digest("base64url");
15108
+ const requestCode = createHash2("sha256").update(verifier).digest("base64url");
14159
15109
  return { verifier, requestCode };
14160
15110
  }
14161
15111
  async function awaitConnexResult(client, verifier) {
@@ -14210,9 +15160,9 @@ async function awaitConnexResult(client, verifier) {
14210
15160
  }
14211
15161
 
14212
15162
  // src/util/connex/upload-icon.ts
14213
- import { readFile as readFile3, stat } from "fs/promises";
15163
+ import { readFile as readFile4, stat as stat3 } from "fs/promises";
14214
15164
  import { resolve as resolve4 } from "path";
14215
- import { createHash as createHash2 } from "crypto";
15165
+ import { createHash as createHash3 } from "crypto";
14216
15166
  var MAX_ICON_BYTES = 5 * 1024 * 1024;
14217
15167
  var MIN_IMAGE_BYTES = 12;
14218
15168
  var IMAGE_SIGNATURES = [
@@ -14240,7 +15190,7 @@ async function prepareConnexIcon(filePath, cwd) {
14240
15190
  const absPath = resolve4(cwd, filePath);
14241
15191
  let size;
14242
15192
  try {
14243
- size = (await stat(absPath)).size;
15193
+ size = (await stat3(absPath)).size;
14244
15194
  } catch (err) {
14245
15195
  throw new Error(
14246
15196
  `Could not read icon file at "${filePath}": ${err.message}`
@@ -14253,7 +15203,7 @@ async function prepareConnexIcon(filePath, cwd) {
14253
15203
  }
14254
15204
  let buf;
14255
15205
  try {
14256
- buf = await readFile3(absPath);
15206
+ buf = await readFile4(absPath);
14257
15207
  } catch (err) {
14258
15208
  throw new Error(
14259
15209
  `Could not read icon file at "${filePath}": ${err.message}`
@@ -14262,7 +15212,7 @@ async function prepareConnexIcon(filePath, cwd) {
14262
15212
  if (!isImageBuffer(buf)) {
14263
15213
  throw new Error(`Icon file at "${filePath}" is not a PNG or JPEG.`);
14264
15214
  }
14265
- const sha = createHash2("sha1").update(new Uint8Array(buf)).digest("hex");
15215
+ const sha = createHash3("sha1").update(new Uint8Array(buf)).digest("hex");
14266
15216
  return { buf, sha };
14267
15217
  }
14268
15218
  async function uploadConnexIcon(client, prepared) {
@@ -14870,7 +15820,7 @@ async function create2(client, args, flags) {
14870
15820
  client,
14871
15821
  "Select the team where you want to create this connector"
14872
15822
  );
14873
- const link = await getProjectLink(client, client.cwd);
15823
+ const link2 = await getProjectLink(client, client.cwd);
14874
15824
  let triggerProjectId;
14875
15825
  if (triggerProject !== void 0) {
14876
15826
  output_manager_default.spinner("Looking up trigger destination project\u2026");
@@ -14894,7 +15844,7 @@ async function create2(client, args, flags) {
14894
15844
  return 1;
14895
15845
  }
14896
15846
  }
14897
- const destinationProjectId = triggerProjectId ?? link?.projectId;
15847
+ const destinationProjectId = triggerProjectId ?? link2?.projectId;
14898
15848
  if ((triggerPath !== void 0 || triggerProject !== void 0 || triggerBranch !== void 0 || triggerEnvironment !== void 0) && !destinationProjectId) {
14899
15849
  output_manager_default.error(
14900
15850
  "Trigger destination flags require a linked project. Run `vercel link` first."
@@ -15042,8 +15992,8 @@ async function create2(client, args, flags) {
15042
15992
  service,
15043
15993
  name
15044
15994
  };
15045
- if (link?.projectId) {
15046
- body.projectId = link.projectId;
15995
+ if (link2?.projectId) {
15996
+ body.projectId = link2.projectId;
15047
15997
  }
15048
15998
  body.triggers = { enabled: flags["--triggers"] === true };
15049
15999
  if (flags["--trigger-event"] !== void 0) {
@@ -15276,7 +16226,7 @@ async function resolveDataFlag(raw, client) {
15276
16226
  );
15277
16227
  }
15278
16228
  try {
15279
- return await readFile4(resolve5(client.cwd, source), "utf8");
16229
+ return await readFile5(resolve5(client.cwd, source), "utf8");
15280
16230
  } catch (err) {
15281
16231
  throw new Error(
15282
16232
  `Could not read --data file at "${source}": ${err.message}`
@@ -17414,6 +18364,7 @@ async function contract(client) {
17414
18364
  }
17415
18365
  const asJson = formatResult.jsonOutput;
17416
18366
  telemetry2.trackCliOptionFormat(parsedArgs.flags["--format"]);
18367
+ telemetry2.trackCliFlagJson(parsedArgs.flags["--json"]);
17417
18368
  let contextName;
17418
18369
  let teamId;
17419
18370
  try {
@@ -18349,7 +19300,7 @@ async function main6(client) {
18349
19300
  // src/commands/crons/add.ts
18350
19301
  var import_chalk62 = __toESM(require_source(), 1);
18351
19302
  import { resolve as resolve7 } from "path";
18352
- import { access as access2, readFile as readFile5, writeFile as writeFile4 } from "fs/promises";
19303
+ import { access as access2, readFile as readFile6, writeFile as writeFile6 } from "fs/promises";
18353
19304
 
18354
19305
  // src/util/telemetry/commands/crons/add.ts
18355
19306
  var CronsAddTelemetryClient = class extends TelemetryClient {
@@ -18516,7 +19467,7 @@ async function add3(client, argv) {
18516
19467
  const configPath = resolve7(client.cwd, "vercel.json");
18517
19468
  let config;
18518
19469
  try {
18519
- const content = await readFile5(configPath, "utf-8");
19470
+ const content = await readFile6(configPath, "utf-8");
18520
19471
  config = JSON.parse(content);
18521
19472
  } catch (err) {
18522
19473
  if (err instanceof SyntaxError) {
@@ -18544,7 +19495,7 @@ async function add3(client, argv) {
18544
19495
  existingCrons.push({ path: cronPath, schedule });
18545
19496
  config.crons = existingCrons;
18546
19497
  try {
18547
- await writeFile4(
19498
+ await writeFile6(
18548
19499
  configPath,
18549
19500
  JSON.stringify(config, null, 2) + "\n",
18550
19501
  "utf-8"
@@ -18618,20 +19569,20 @@ async function ls3(client, argv) {
18618
19569
  return 1;
18619
19570
  }
18620
19571
  const asJson = formatResult.jsonOutput;
18621
- const link = await resolveProjectContext({
19572
+ const link2 = await resolveProjectContext({
18622
19573
  client,
18623
19574
  projectNameOrId: projectName
18624
19575
  });
18625
- if (link.status === "error") {
18626
- return link.exitCode;
18627
- } else if (link.status === "not_linked") {
19576
+ if (link2.status === "error") {
19577
+ return link2.exitCode;
19578
+ } else if (link2.status === "not_linked") {
18628
19579
  output_manager_default.error(
18629
19580
  `Your codebase isn't linked to a project on Vercel. Pass --project <name>, or ${client.nonInteractive ? `run ${getCommandName("link --yes --team <team-id> --project <project-id>")} to link non-interactively.` : `run ${getCommandName("link")} to begin.`}`
18630
19581
  );
18631
19582
  return 1;
18632
19583
  }
18633
- client.config.currentTeam = link.org.type === "team" ? link.org.id : void 0;
18634
- const { project, org } = link;
19584
+ client.config.currentTeam = link2.org.type === "team" ? link2.org.id : void 0;
19585
+ const { project, org } = link2;
18635
19586
  const lsStamp = stamp_default();
18636
19587
  output_manager_default.spinner(
18637
19588
  `Fetching cron jobs for ${import_chalk63.default.bold(`${org.slug}/${project.name}`)}`
@@ -18769,20 +19720,20 @@ async function run(client, argv) {
18769
19720
  const projectName = opts["--project"];
18770
19721
  telemetry2.trackCliOptionProject(projectName);
18771
19722
  telemetry2.trackCliArgumentPath(cronPath);
18772
- const link = await resolveProjectContext({
19723
+ const link2 = await resolveProjectContext({
18773
19724
  client,
18774
19725
  projectNameOrId: projectName
18775
19726
  });
18776
- if (link.status === "error") {
18777
- return link.exitCode;
18778
- } else if (link.status === "not_linked") {
19727
+ if (link2.status === "error") {
19728
+ return link2.exitCode;
19729
+ } else if (link2.status === "not_linked") {
18779
19730
  output_manager_default.error(
18780
19731
  `Your codebase isn't linked to a project on Vercel. Pass --project <name>, or ${client.nonInteractive ? `run ${getCommandName("link --yes --team <team-id> --project <project-id>")} to link non-interactively.` : `run ${getCommandName("link")} to begin.`}`
18781
19732
  );
18782
19733
  return 1;
18783
19734
  }
18784
- client.config.currentTeam = link.org.type === "team" ? link.org.id : void 0;
18785
- const { project, org } = link;
19735
+ client.config.currentTeam = link2.org.type === "team" ? link2.org.id : void 0;
19736
+ const { project, org } = link2;
18786
19737
  const runStamp = stamp_default();
18787
19738
  output_manager_default.spinner(
18788
19739
  `Fetching cron jobs for ${import_chalk64.default.bold(`${org.slug}/${project.name}`)}`
@@ -18830,7 +19781,7 @@ async function run(client, argv) {
18830
19781
  return 1;
18831
19782
  }
18832
19783
  output_manager_default.spinner(`Triggering cron job ${import_chalk64.default.bold(cronPath)}`);
18833
- const teamId = link.org.type === "team" ? link.org.id : void 0;
19784
+ const teamId = link2.org.type === "team" ? link2.org.id : void 0;
18834
19785
  const qs = teamId ? `?teamId=${encodeURIComponent(teamId)}` : "";
18835
19786
  let result;
18836
19787
  try {
@@ -19461,13 +20412,13 @@ async function getFullUrlAndToken(client, fullUrl, protectionBypassFlag) {
19461
20412
  link: null
19462
20413
  };
19463
20414
  }
19464
- const link = await resolveProjectFromUrl(client, fullUrl);
20415
+ const link2 = await resolveProjectFromUrl(client, fullUrl);
19465
20416
  let deploymentProtectionToken = null;
19466
- if (link) {
20417
+ if (link2) {
19467
20418
  try {
19468
20419
  deploymentProtectionToken = await getOrCreateDeploymentProtectionToken(
19469
20420
  client,
19470
- link
20421
+ link2
19471
20422
  );
19472
20423
  } catch (err) {
19473
20424
  output_manager_default.debug(`Failed to get deployment protection bypass token: ${err}`);
@@ -19476,7 +20427,7 @@ async function getFullUrlAndToken(client, fullUrl, protectionBypassFlag) {
19476
20427
  return {
19477
20428
  fullUrl,
19478
20429
  deploymentProtectionToken,
19479
- link
20430
+ link: link2
19480
20431
  };
19481
20432
  }
19482
20433
  async function linkFromDeployment(client, deployment) {
@@ -19490,13 +20441,13 @@ async function linkFromDeployment(client, deployment) {
19490
20441
  }
19491
20442
  async function resolveTargetProject(client, deployment, deploymentFlag) {
19492
20443
  try {
19493
- const link = await linkFromDeployment(client, deployment);
19494
- if (!link) {
20444
+ const link2 = await linkFromDeployment(client, deployment);
20445
+ if (!link2) {
19495
20446
  output_manager_default.warn(
19496
20447
  `Deployment "${deploymentFlag}" is missing project metadata; proceeding without an automatic protection bypass token.`
19497
20448
  );
19498
20449
  }
19499
- return link;
20450
+ return link2;
19500
20451
  } catch (err) {
19501
20452
  output_manager_default.debug(`Failed to resolve deployment project: ${err}`);
19502
20453
  output_manager_default.warn(
@@ -19544,7 +20495,7 @@ async function getDeploymentUrlAndToken(client, commandName, path3, options) {
19544
20495
  resolveProjectForTrace
19545
20496
  } = options;
19546
20497
  const suppliedProtectionBypass = deploymentFlag ? protectionBypassFlag ?? (process.env.VERCEL_AUTOMATION_BYPASS_SECRET || void 0) : protectionBypassFlag;
19547
- let link = null;
20498
+ let link2 = null;
19548
20499
  let createProtectionBypassIfMissing = !deploymentFlag;
19549
20500
  let scope;
19550
20501
  try {
@@ -19558,7 +20509,7 @@ async function getDeploymentUrlAndToken(client, commandName, path3, options) {
19558
20509
  }
19559
20510
  let baseUrl;
19560
20511
  if (deploymentFlag) {
19561
- const accountId = scope.team?.id || scope.user.id;
20512
+ const accountId = scope.team?.id || scope.user?.id;
19562
20513
  const isDirectUrl = deploymentFlag.startsWith("http://") || deploymentFlag.startsWith("https://") || deploymentFlag.includes("vercel.app");
19563
20514
  const requestedBaseUrl = isDirectUrl ? await getDeploymentUrlById(client, deploymentFlag, accountId) : null;
19564
20515
  const deploymentSelector = deploymentFlag.includes(".") || deploymentFlag.startsWith("dpl_") ? deploymentFlag : `dpl_${deploymentFlag}`;
@@ -19569,7 +20520,7 @@ async function getDeploymentUrlAndToken(client, commandName, path3, options) {
19569
20520
  return 1;
19570
20521
  }
19571
20522
  if (resolveProjectForTrace) {
19572
- link = await tryLinkFromSelector(
20523
+ link2 = await tryLinkFromSelector(
19573
20524
  client,
19574
20525
  scope.contextName,
19575
20526
  deploymentSelector
@@ -19591,10 +20542,10 @@ async function getDeploymentUrlAndToken(client, commandName, path3, options) {
19591
20542
  `Could not resolve project information for deployment "${deploymentFlag}"; proceeding without an automatic protection bypass token.`
19592
20543
  );
19593
20544
  } else {
19594
- link = await resolveTargetProject(client, deployment, deploymentFlag);
19595
- if (link && !hasAutomationBypassToken(link.project)) {
20545
+ link2 = await resolveTargetProject(client, deployment, deploymentFlag);
20546
+ if (link2 && !hasAutomationBypassToken(link2.project)) {
19596
20547
  const linked = await getLinkedProjectOrNull(client);
19597
- createProtectionBypassIfMissing = linked?.project.id === link.project.id;
20548
+ createProtectionBypassIfMissing = linked?.project.id === link2.project.id;
19598
20549
  }
19599
20550
  }
19600
20551
  }
@@ -19624,7 +20575,7 @@ async function getDeploymentUrlAndToken(client, commandName, path3, options) {
19624
20575
  output_manager_default.error("Failed to get project information");
19625
20576
  return 1;
19626
20577
  }
19627
- link = ensuredLink;
20578
+ link2 = ensuredLink;
19628
20579
  const preferredAlias = linkedProject.project.targets?.production?.alias?.[0];
19629
20580
  const backupAlias = linkedProject.project.latestDeployments?.[0]?.url;
19630
20581
  const target = preferredAlias || backupAlias;
@@ -19636,11 +20587,11 @@ async function getDeploymentUrlAndToken(client, commandName, path3, options) {
19636
20587
  const fullUrl = `${baseUrl}${path3.startsWith("/") ? path3 : `/${path3}`}`;
19637
20588
  output_manager_default.debug(`${import_chalk66.default.cyan("Target URL:")} ${import_chalk66.default.bold(fullUrl)}`);
19638
20589
  let deploymentProtectionToken = suppliedProtectionBypass ?? null;
19639
- if (suppliedProtectionBypass === void 0 && link?.project.id) {
20590
+ if (suppliedProtectionBypass === void 0 && link2?.project.id) {
19640
20591
  try {
19641
20592
  deploymentProtectionToken = await getOrCreateDeploymentProtectionToken(
19642
20593
  client,
19643
- link,
20594
+ link2,
19644
20595
  { createIfMissing: createProtectionBypassIfMissing }
19645
20596
  );
19646
20597
  } catch (err) {
@@ -19653,7 +20604,7 @@ async function getDeploymentUrlAndToken(client, commandName, path3, options) {
19653
20604
  return {
19654
20605
  fullUrl,
19655
20606
  deploymentProtectionToken,
19656
- link
20607
+ link: link2
19657
20608
  };
19658
20609
  }
19659
20610
 
@@ -19661,8 +20612,8 @@ async function getDeploymentUrlAndToken(client, commandName, path3, options) {
19661
20612
  var import_error_utils8 = __toESM(require_dist(), 1);
19662
20613
  import { spawn } from "child_process";
19663
20614
  import { tmpdir } from "os";
19664
- import { join as join9 } from "path";
19665
- import { mkdtemp, readFile as readFile7, rm as rm3 } from "fs/promises";
20615
+ import { join as join15 } from "path";
20616
+ import { mkdtemp, readFile as readFile8, rm as rm3 } from "fs/promises";
19666
20617
 
19667
20618
  // src/commands/curl/confirm-production.ts
19668
20619
  async function confirmProduction(client, { deploymentTarget, yes, isTTY }) {
@@ -19686,28 +20637,28 @@ async function confirmProduction(client, { deploymentTarget, yes, isTTY }) {
19686
20637
  }
19687
20638
 
19688
20639
  // src/commands/curl/trace-session-token-provider.ts
19689
- import { createHash as createHash3 } from "crypto";
19690
- import { chmod, mkdir as mkdir2, readFile as readFile6, unlink, writeFile as writeFile5 } from "fs/promises";
19691
- import { dirname as dirname3, join as join8 } from "path";
20640
+ import { createHash as createHash4 } from "crypto";
20641
+ import { chmod as chmod2, mkdir as mkdir3, readFile as readFile7, unlink as unlink3, writeFile as writeFile7 } from "fs/promises";
20642
+ import { dirname as dirname5, join as join14 } from "path";
19692
20643
  var FALLBACK_TTL_MS = 5 * 60 * 1e3;
19693
20644
  var EXPIRY_BUFFER_MS = 30 * 1e3;
19694
20645
  var CACHE_SCHEMA_VERSION = 1;
19695
20646
  function resolveCacheDir(override2) {
19696
20647
  if (override2)
19697
20648
  return override2;
19698
- return join8(getGlobalPathConfig(), "cache", "traces");
20649
+ return join14(getGlobalPathConfig(), "cache", "traces");
19699
20650
  }
19700
20651
  function cacheFilename(teamId, host) {
19701
20652
  const key = `${teamId ?? ""}:${host}`;
19702
- return `${createHash3("sha256").update(key).digest("hex")}.json`;
20653
+ return `${createHash4("sha256").update(key).digest("hex")}.json`;
19703
20654
  }
19704
20655
  function cachePath(cacheDir, teamId, host) {
19705
- return join8(cacheDir, cacheFilename(teamId, host));
20656
+ return join14(cacheDir, cacheFilename(teamId, host));
19706
20657
  }
19707
20658
  async function readCache(path3) {
19708
20659
  let raw;
19709
20660
  try {
19710
- raw = await readFile6(path3, "utf8");
20661
+ raw = await readFile7(path3, "utf8");
19711
20662
  } catch {
19712
20663
  return null;
19713
20664
  }
@@ -19723,9 +20674,9 @@ async function readCache(path3) {
19723
20674
  }
19724
20675
  }
19725
20676
  async function writeCache(path3, entry) {
19726
- await mkdir2(dirname3(path3), { recursive: true });
19727
- await writeFile5(path3, JSON.stringify(entry), { mode: 384 });
19728
- await chmod(path3, 384);
20677
+ await mkdir3(dirname5(path3), { recursive: true });
20678
+ await writeFile7(path3, JSON.stringify(entry), { mode: 384 });
20679
+ await chmod2(path3, 384);
19729
20680
  }
19730
20681
  async function issueToken(client, {
19731
20682
  teamId,
@@ -19761,7 +20712,7 @@ async function getTraceSessionToken({
19761
20712
  const path3 = cachePath(dir, teamId, hostname2);
19762
20713
  const cached = await readCache(path3);
19763
20714
  if (cached && evictedToken && cached.token === evictedToken) {
19764
- await unlink(path3).catch(() => {
20715
+ await unlink3(path3).catch(() => {
19765
20716
  });
19766
20717
  } else if (cached && Date.now() < cached.expiresAt - EXPIRY_BUFFER_MS) {
19767
20718
  return {
@@ -19797,9 +20748,9 @@ async function lookupDeployment(client, fullUrl, accountId) {
19797
20748
  accountId ? { accountId } : {}
19798
20749
  );
19799
20750
  }
19800
- function resolveTeamId(link, deployment) {
19801
- if (link?.org.type === "team") {
19802
- return link.org.id;
20751
+ function resolveTeamId(link2, deployment) {
20752
+ if (link2?.org.type === "team") {
20753
+ return link2.org.id;
19803
20754
  }
19804
20755
  if (deployment.ownerId?.startsWith("team_")) {
19805
20756
  return deployment.ownerId;
@@ -19835,8 +20786,8 @@ function extractFinalStatus(headerDump) {
19835
20786
  return lastStatus;
19836
20787
  }
19837
20788
  async function runCurlAndCaptureHeaders(curlFlags, json) {
19838
- const tmpDir = await mkdtemp(join9(tmpdir(), "vc-curl-trace-"));
19839
- const headerFile = join9(tmpDir, "headers");
20789
+ const tmpDir = await mkdtemp(join15(tmpdir(), "vc-curl-trace-"));
20790
+ const headerFile = join15(tmpDir, "headers");
19840
20791
  const flags = ["--dump-header", headerFile, ...curlFlags];
19841
20792
  try {
19842
20793
  const { exitCode: exitCode2, capturedBody } = await new Promise((resolve10) => {
@@ -19865,7 +20816,7 @@ async function runCurlAndCaptureHeaders(curlFlags, json) {
19865
20816
  });
19866
20817
  let headerDump = "";
19867
20818
  try {
19868
- headerDump = await readFile7(headerFile, "utf8");
20819
+ headerDump = await readFile8(headerFile, "utf8");
19869
20820
  } catch (err) {
19870
20821
  output_manager_default.debug(`Failed to read curl header dump: ${err}`);
19871
20822
  }
@@ -19875,12 +20826,12 @@ async function runCurlAndCaptureHeaders(curlFlags, json) {
19875
20826
  });
19876
20827
  }
19877
20828
  }
19878
- async function trace2(client, { fullUrl, link, curlFlags, json, yes, telemetry: telemetry2 }) {
20829
+ async function trace2(client, { fullUrl, link: link2, curlFlags, json, yes, telemetry: telemetry2 }) {
19879
20830
  telemetry2.trackCliFlagTrace(true);
19880
20831
  if (json) {
19881
20832
  telemetry2.trackCliFlagJson(true);
19882
20833
  }
19883
- const accountId = link?.org.id;
20834
+ const accountId = link2?.org.id;
19884
20835
  let deployment;
19885
20836
  try {
19886
20837
  deployment = await lookupDeployment(client, fullUrl, accountId);
@@ -19890,14 +20841,14 @@ async function trace2(client, { fullUrl, link, curlFlags, json, yes, telemetry:
19890
20841
  );
19891
20842
  return 1;
19892
20843
  }
19893
- const projectId = link?.project.id ?? deployment.projectId;
20844
+ const projectId = link2?.project.id ?? deployment.projectId;
19894
20845
  if (!projectId) {
19895
20846
  output_manager_default.error(
19896
20847
  "Could not resolve project for trace session. Run `vercel link` and retry."
19897
20848
  );
19898
20849
  return 1;
19899
20850
  }
19900
- const teamId = resolveTeamId(link, deployment);
20851
+ const teamId = resolveTeamId(link2, deployment);
19901
20852
  let userId;
19902
20853
  try {
19903
20854
  userId = client.authConfig.userId ?? (await getUser(client)).id;
@@ -20096,11 +21047,11 @@ async function getProjectByCwdOrLink({
20096
21047
  const effectiveNonInteractive = nonInteractive ?? client.nonInteractive ?? argvHasNonInteractive(client.argv);
20097
21048
  if (forReadOnlyCommand && effectiveNonInteractive) {
20098
21049
  const resolvedCwd = await resolveProjectCwd(cwd ?? client.cwd);
20099
- const link = await getLinkedProject(client, { cwd: resolvedCwd });
20100
- if (link.status === "linked" && link.project) {
20101
- return link.project;
21050
+ const link2 = await getLinkedProject(client, { cwd: resolvedCwd });
21051
+ if (link2.status === "linked" && link2.project) {
21052
+ return link2.project;
20102
21053
  }
20103
- if (link.status === "error") {
21054
+ if (link2.status === "error") {
20104
21055
  const err = new Error("Link project error");
20105
21056
  err.code = "ERR_LINK_PROJECT";
20106
21057
  throw err;
@@ -21560,7 +22511,7 @@ async function ls5(client, argv) {
21560
22511
  const data = await getDomainDNSRecords(
21561
22512
  client,
21562
22513
  domainName,
21563
- 4,
22514
+ 5,
21564
22515
  ...paginationOptions
21565
22516
  );
21566
22517
  if (data instanceof DomainNotFound) {
@@ -21958,7 +22909,7 @@ function isRootDomain(domainName) {
21958
22909
  async function getDomainConfig(client, domainName) {
21959
22910
  try {
21960
22911
  const config = await client.fetch(
21961
- `/v4/domains/${domainName}/config`
22912
+ `/v6/domains/${domainName}/config`
21962
22913
  );
21963
22914
  return config;
21964
22915
  } catch (err) {
@@ -23641,7 +24592,7 @@ async function move(client, argv) {
23641
24592
  }
23642
24593
  const teams2 = await getTeams(client);
23643
24594
  const matchId = await findDestinationMatch(destination, user, teams2);
23644
- if (matchId && matchId === user.id && user.version === "northstar") {
24595
+ if (matchId && user && matchId === user.id && user.version === "northstar") {
23645
24596
  output_manager_default.error(`You may not move your domain to your user account.`);
23646
24597
  return 1;
23647
24598
  }
@@ -23755,7 +24706,7 @@ async function getArgs(client, args) {
23755
24706
  return { domainName, destination };
23756
24707
  }
23757
24708
  async function findDestinationMatch(destination, user, teams2) {
23758
- if (user.id === destination || user.username === destination) {
24709
+ if (user && (user.id === destination || user.username === destination)) {
23759
24710
  return user.id;
23760
24711
  }
23761
24712
  for (const team of teams2) {
@@ -23973,8 +24924,8 @@ async function search(client, argv) {
23973
24924
  output_manager_default.error(cursorResult.error);
23974
24925
  return 1;
23975
24926
  }
23976
- const cursor = cursorResult.cursor;
23977
- if (cursor && (cursor.query !== query || cursor.fragment !== fragment || cursor.order !== order || !areStringArraysEqual(cursor.tlds, tlds) || cursor.availableOnly !== availableOnly)) {
24927
+ const cursor2 = cursorResult.cursor;
24928
+ if (cursor2 && (cursor2.query !== query || cursor2.fragment !== fragment || cursor2.order !== order || !areStringArraysEqual(cursor2.tlds, tlds) || cursor2.availableOnly !== availableOnly)) {
23978
24929
  output_manager_default.error(
23979
24930
  "The continuation cursor does not match the current query, order, or filters."
23980
24931
  );
@@ -23983,7 +24934,7 @@ async function search(client, argv) {
23983
24934
  try {
23984
24935
  const supportedTlds = await getSupportedTlds(client, order);
23985
24936
  const matchingTlds = filterTlds(supportedTlds, fragment, tlds, order);
23986
- const offsetResult = getOffset(matchingTlds, cursor);
24937
+ const offsetResult = getOffset(matchingTlds, cursor2);
23987
24938
  if (!offsetResult.valid) {
23988
24939
  output_manager_default.error(offsetResult.error);
23989
24940
  return 1;
@@ -24096,8 +25047,8 @@ function isSupportedTldsCacheEntryFresh(fetchedAt, now = Date.now()) {
24096
25047
  const age = now - fetchedAt;
24097
25048
  return age >= 0 && age <= SUPPORTED_TLDS_CACHE_TTL_MS;
24098
25049
  }
24099
- function encodeCursor(cursor) {
24100
- return Buffer.from(JSON.stringify(cursor), "utf8").toString("base64url");
25050
+ function encodeCursor(cursor2) {
25051
+ return Buffer.from(JSON.stringify(cursor2), "utf8").toString("base64url");
24101
25052
  }
24102
25053
  function decodeCursor(value) {
24103
25054
  if (value === void 0) {
@@ -24107,13 +25058,13 @@ function decodeCursor(value) {
24107
25058
  if (!value || !/^[A-Za-z0-9_-]+$/.test(value)) {
24108
25059
  throw new Error("Invalid base64url value");
24109
25060
  }
24110
- const cursor = JSON.parse(
25061
+ const cursor2 = JSON.parse(
24111
25062
  Buffer.from(value, "base64url").toString("utf8")
24112
25063
  );
24113
- if (!isContinuationCursor(cursor)) {
25064
+ if (!isContinuationCursor(cursor2)) {
24114
25065
  throw new Error("Invalid cursor shape");
24115
25066
  }
24116
- return { valid: true, cursor };
25067
+ return { valid: true, cursor: cursor2 };
24117
25068
  } catch {
24118
25069
  return {
24119
25070
  valid: false,
@@ -24125,18 +25076,18 @@ function isContinuationCursor(value) {
24125
25076
  if (!value || typeof value !== "object" || Array.isArray(value)) {
24126
25077
  return false;
24127
25078
  }
24128
- const cursor = value;
24129
- const keys = Object.keys(cursor).sort();
25079
+ const cursor2 = value;
25080
+ const keys = Object.keys(cursor2).sort();
24130
25081
  if (keys.length !== 6 || keys.join(",") !== "availableOnly,fragment,lastTld,order,query,tlds") {
24131
25082
  return false;
24132
25083
  }
24133
- return typeof cursor.query === "string" && (typeof cursor.fragment === "string" || cursor.fragment === null) && typeof cursor.order === "string" && ORDERS.includes(cursor.order) && Array.isArray(cursor.tlds) && cursor.tlds.every((tld) => typeof tld === "string") && typeof cursor.availableOnly === "boolean" && typeof cursor.lastTld === "string" && cursor.lastTld.length > 0;
25084
+ return typeof cursor2.query === "string" && (typeof cursor2.fragment === "string" || cursor2.fragment === null) && typeof cursor2.order === "string" && ORDERS.includes(cursor2.order) && Array.isArray(cursor2.tlds) && cursor2.tlds.every((tld) => typeof tld === "string") && typeof cursor2.availableOnly === "boolean" && typeof cursor2.lastTld === "string" && cursor2.lastTld.length > 0;
24134
25085
  }
24135
- function getOffset(tlds, cursor) {
24136
- if (!cursor) {
25086
+ function getOffset(tlds, cursor2) {
25087
+ if (!cursor2) {
24137
25088
  return { valid: true, offset: 0 };
24138
25089
  }
24139
- const lastTldIndex = tlds.indexOf(cursor.lastTld);
25090
+ const lastTldIndex = tlds.indexOf(cursor2.lastTld);
24140
25091
  if (lastTldIndex === -1) {
24141
25092
  return {
24142
25093
  valid: false,
@@ -24209,7 +25160,7 @@ function getOrder(value) {
24209
25160
  }
24210
25161
  return { valid: true, order };
24211
25162
  }
24212
- function getContinuationCommand(query, order, tlds, availableOnly, cursor) {
25163
+ function getContinuationCommand(query, order, tlds, availableOnly, cursor2) {
24213
25164
  const flags = [];
24214
25165
  if (order !== DEFAULT_ORDER) {
24215
25166
  flags.push(`--order=${order}`);
@@ -24218,7 +25169,7 @@ function getContinuationCommand(query, order, tlds, availableOnly, cursor) {
24218
25169
  if (availableOnly) {
24219
25170
  flags.push("--available");
24220
25171
  }
24221
- flags.push(`--next ${cursor}`);
25172
+ flags.push(`--next ${cursor2}`);
24222
25173
  return `domains search ${query} ${flags.join(" ")}`;
24223
25174
  }
24224
25175
  function normalizeTldFilters(values) {
@@ -24462,20 +25413,20 @@ async function resolveRequestedProject(client, domainName, idOrName) {
24462
25413
  return { kind: "error", idOrName, error: result };
24463
25414
  }
24464
25415
  async function findLinkedProjectDomain(client, domainName) {
24465
- const link = await getLinkedProject(client);
24466
- if (link.status !== "linked") {
25416
+ const link2 = await getLinkedProject(client);
25417
+ if (link2.status !== "linked") {
24467
25418
  return null;
24468
25419
  }
24469
- const result = await getProjectDomain(client, link.project.id, domainName, {
25420
+ const result = await getProjectDomain(client, link2.project.id, domainName, {
24470
25421
  bailOn429: true
24471
25422
  });
24472
25423
  if (!isAPIError(result)) {
24473
- return attachedProject(link.project.id, link.project.name, result);
25424
+ return attachedProject(link2.project.id, link2.project.name, result);
24474
25425
  }
24475
25426
  if (result.status === 403 || result.status === 404) {
24476
25427
  return null;
24477
25428
  }
24478
- return { kind: "error", idOrName: link.project.id, error: result };
25429
+ return { kind: "error", idOrName: link2.project.id, error: result };
24479
25430
  }
24480
25431
  async function findProjectDomainByName(client, domainName) {
24481
25432
  const result = await getProjectDomainByName(client, domainName, {
@@ -25904,14 +26855,14 @@ async function resolveFirewallScope(client, flags) {
25904
26855
  }
25905
26856
  return { type: "team", teamId: team.id, displayName: team.slug };
25906
26857
  }
25907
- const link = await requireProjectContext(
26858
+ const link2 = await requireProjectContext(
25908
26859
  client,
25909
26860
  "firewall",
25910
26861
  flags["--project"]
25911
26862
  );
25912
- if (typeof link === "number")
25913
- return link;
25914
- const { project, org } = link;
26863
+ if (typeof link2 === "number")
26864
+ return link2;
26865
+ const { project, org } = link2;
25915
26866
  return {
25916
26867
  type: "project",
25917
26868
  projectId: project.id,
@@ -26736,14 +27687,14 @@ async function overview(client, argv) {
26736
27687
  const parsed = await parseSubcommandArgs2(argv, overviewSubcommand, client);
26737
27688
  if (typeof parsed === "number")
26738
27689
  return parsed;
26739
- const link = await requireProjectContext(
27690
+ const link2 = await requireProjectContext(
26740
27691
  client,
26741
27692
  "firewall",
26742
27693
  parsed.flags["--project"]
26743
27694
  );
26744
- if (typeof link === "number")
26745
- return link;
26746
- const { project, org } = link;
27695
+ if (typeof link2 === "number")
27696
+ return link2;
27697
+ const { project, org } = link2;
26747
27698
  const teamId = org.type === "team" ? org.id : void 0;
26748
27699
  output_manager_default.spinner(`Fetching firewall overview for ${import_chalk91.default.bold(project.name)}`);
26749
27700
  try {
@@ -26999,14 +27950,14 @@ async function list12(client, argv) {
26999
27950
  );
27000
27951
  if (typeof parsed === "number")
27001
27952
  return parsed;
27002
- const link = await requireProjectContext(
27953
+ const link2 = await requireProjectContext(
27003
27954
  client,
27004
27955
  "firewall",
27005
27956
  parsed.flags["--project"]
27006
27957
  );
27007
- if (typeof link === "number")
27008
- return link;
27009
- const { project, org } = link;
27958
+ if (typeof link2 === "number")
27959
+ return link2;
27960
+ const { project, org } = link2;
27010
27961
  const teamId = org.type === "team" ? org.id : void 0;
27011
27962
  output_manager_default.spinner(
27012
27963
  `Fetching system bypass rules for ${import_chalk95.default.bold(project.name)}`
@@ -27203,14 +28154,14 @@ async function add6(client, argv) {
27203
28154
  return 1;
27204
28155
  }
27205
28156
  }
27206
- const link = await requireProjectContext(
28157
+ const link2 = await requireProjectContext(
27207
28158
  client,
27208
28159
  "firewall",
27209
28160
  parsed.flags["--project"]
27210
28161
  );
27211
- if (typeof link === "number")
27212
- return link;
27213
- const { project, org } = link;
28162
+ if (typeof link2 === "number")
28163
+ return link2;
28164
+ const { project, org } = link2;
27214
28165
  const teamId = org.type === "team" ? org.id : void 0;
27215
28166
  const scopeLabel = domain2 || "all domains";
27216
28167
  const confirmed = await confirmAction(
@@ -27310,14 +28261,14 @@ async function remove6(client, argv) {
27310
28261
  return 1;
27311
28262
  }
27312
28263
  }
27313
- const link = await requireProjectContext(
28264
+ const link2 = await requireProjectContext(
27314
28265
  client,
27315
28266
  "firewall",
27316
28267
  parsed.flags["--project"]
27317
28268
  );
27318
- if (typeof link === "number")
27319
- return link;
27320
- const { project, org } = link;
28269
+ if (typeof link2 === "number")
28270
+ return link2;
28271
+ const { project, org } = link2;
27321
28272
  const teamId = org.type === "team" ? org.id : void 0;
27322
28273
  const scopeLabel = domain2 || "all domains";
27323
28274
  const confirmed = await confirmAction(
@@ -27524,14 +28475,14 @@ async function enable(client, argv) {
27524
28475
  );
27525
28476
  return 1;
27526
28477
  }
27527
- const link = await requireProjectContext(
28478
+ const link2 = await requireProjectContext(
27528
28479
  client,
27529
28480
  "firewall",
27530
28481
  parsed.flags["--project"]
27531
28482
  );
27532
- if (typeof link === "number")
27533
- return link;
27534
- const { project } = link;
28483
+ if (typeof link2 === "number")
28484
+ return link2;
28485
+ const { project } = link2;
27535
28486
  const confirmed = await confirmAction(
27536
28487
  client,
27537
28488
  parsed.flags["--yes"],
@@ -27597,14 +28548,14 @@ async function disable(client, argv) {
27597
28548
  );
27598
28549
  return 1;
27599
28550
  }
27600
- const link = await requireProjectContext(
28551
+ const link2 = await requireProjectContext(
27601
28552
  client,
27602
28553
  "firewall",
27603
28554
  parsed.flags["--project"]
27604
28555
  );
27605
- if (typeof link === "number")
27606
- return link;
27607
- const { project } = link;
28556
+ if (typeof link2 === "number")
28557
+ return link2;
28558
+ const { project } = link2;
27608
28559
  const confirmed = await confirmAction(
27609
28560
  client,
27610
28561
  parsed.flags["--yes"],
@@ -27749,14 +28700,14 @@ async function pause(client, argv) {
27749
28700
  );
27750
28701
  return 1;
27751
28702
  }
27752
- const link = await requireProjectContext(
28703
+ const link2 = await requireProjectContext(
27753
28704
  client,
27754
28705
  "firewall",
27755
28706
  parsed.flags["--project"]
27756
28707
  );
27757
- if (typeof link === "number")
27758
- return link;
27759
- const { project, org } = link;
28708
+ if (typeof link2 === "number")
28709
+ return link2;
28710
+ const { project, org } = link2;
27760
28711
  const teamId = org.type === "team" ? org.id : void 0;
27761
28712
  const confirmed = await confirmAction(
27762
28713
  client,
@@ -27830,14 +28781,14 @@ async function resume(client, argv) {
27830
28781
  );
27831
28782
  return 1;
27832
28783
  }
27833
- const link = await requireProjectContext(
28784
+ const link2 = await requireProjectContext(
27834
28785
  client,
27835
28786
  "firewall",
27836
28787
  parsed.flags["--project"]
27837
28788
  );
27838
- if (typeof link === "number")
27839
- return link;
27840
- const { project, org } = link;
28789
+ if (typeof link2 === "number")
28790
+ return link2;
28791
+ const { project, org } = link2;
27841
28792
  const teamId = org.type === "team" ? org.id : void 0;
27842
28793
  const confirmed = await confirmAction(
27843
28794
  client,
@@ -33928,12 +34879,12 @@ var GlobalConfigTelemetryClient = class extends TelemetryClient {
33928
34879
 
33929
34880
  // src/commands/global-config/apply-linked-project-team.ts
33930
34881
  async function applyLinkedProjectTeam(client) {
33931
- const link = await getLinkedProject(client);
33932
- if (link.status === "error") {
33933
- return link.exitCode;
34882
+ const link2 = await getLinkedProject(client);
34883
+ if (link2.status === "error") {
34884
+ return link2.exitCode;
33934
34885
  }
33935
- if (link.status === "linked") {
33936
- client.config.currentTeam = link.org.type === "team" ? link.org.id : void 0;
34886
+ if (link2.status === "linked") {
34887
+ client.config.currentTeam = link2.org.type === "team" ? link2.org.id : void 0;
33937
34888
  }
33938
34889
  return void 0;
33939
34890
  }
@@ -34224,7 +35175,7 @@ async function getFlags(client, projectId, options = {}) {
34224
35175
  createdBy,
34225
35176
  maintainerIds,
34226
35177
  limit,
34227
- cursor
35178
+ cursor: cursor2
34228
35179
  } = options;
34229
35180
  output_manager_default.debug(`Fetching feature flags for project ${projectId}`);
34230
35181
  const basePath = `/v2/projects/${encodeURIComponent(projectId)}/feature-flags/flags`;
@@ -34246,13 +35197,13 @@ async function getFlags(client, projectId, options = {}) {
34246
35197
  }
34247
35198
  return query.toString();
34248
35199
  };
34249
- if (limit !== void 0 || cursor !== void 0) {
35200
+ if (limit !== void 0 || cursor2 !== void 0) {
34250
35201
  const pageLimit = Math.min(
34251
35202
  limit ?? MAX_FLAGS_PAGE_LIMIT,
34252
35203
  MAX_FLAGS_PAGE_LIMIT
34253
35204
  );
34254
35205
  const response = await client.fetch(
34255
- `${basePath}?${buildQuery(pageLimit, cursor)}`
35206
+ `${basePath}?${buildQuery(pageLimit, cursor2)}`
34256
35207
  );
34257
35208
  return { flags: response.data, next: response.pagination?.next ?? null };
34258
35209
  }
@@ -34420,17 +35371,17 @@ async function ls7(client, argv) {
34420
35371
  );
34421
35372
  return 1;
34422
35373
  }
34423
- const link = await getLinkedFlagsProject(client, projectName);
34424
- if (link.status === "error") {
34425
- return link.exitCode;
34426
- } else if (link.status === "not_linked") {
35374
+ const link2 = await getLinkedFlagsProject(client, projectName);
35375
+ if (link2.status === "error") {
35376
+ return link2.exitCode;
35377
+ } else if (link2.status === "not_linked") {
34427
35378
  output_manager_default.error(
34428
35379
  `Your codebase isn't linked to a project on Vercel. Pass --project <name>, or run ${getCommandName("link")} to link it.`
34429
35380
  );
34430
35381
  return 1;
34431
35382
  }
34432
- client.config.currentTeam = link.org.type === "team" ? link.org.id : void 0;
34433
- const { project, org } = link;
35383
+ client.config.currentTeam = link2.org.type === "team" ? link2.org.id : void 0;
35384
+ const { project, org } = link2;
34434
35385
  const projectSlugLink = formatProject(org.slug, project.name);
34435
35386
  const lsStamp = stamp_default();
34436
35387
  output_manager_default.spinner(`Fetching ${state} feature flags for ${projectSlugLink}`);
@@ -34999,17 +35950,17 @@ async function inspect5(client, argv) {
34999
35950
  }
35000
35951
  telemetryClient.trackCliArgumentFlag(flagArg);
35001
35952
  telemetryClient.trackCliOptionProject(projectName);
35002
- const link = await getLinkedFlagsProject(client, projectName);
35003
- if (link.status === "error") {
35004
- return link.exitCode;
35005
- } else if (link.status === "not_linked") {
35953
+ const link2 = await getLinkedFlagsProject(client, projectName);
35954
+ if (link2.status === "error") {
35955
+ return link2.exitCode;
35956
+ } else if (link2.status === "not_linked") {
35006
35957
  output_manager_default.error(
35007
35958
  `Your codebase isn't linked to a project on Vercel. Pass --project <name>, or run ${getCommandName("link")} to link it.`
35008
35959
  );
35009
35960
  return 1;
35010
35961
  }
35011
- client.config.currentTeam = link.org.type === "team" ? link.org.id : void 0;
35012
- const { project, org } = link;
35962
+ client.config.currentTeam = link2.org.type === "team" ? link2.org.id : void 0;
35963
+ const { project, org } = link2;
35013
35964
  const projectSlugLink = formatProject(org.slug, project.name);
35014
35965
  try {
35015
35966
  const [flag, settings] = await Promise.all([
@@ -35074,8 +36025,8 @@ var FlagsVersionsTelemetryClient = class extends TelemetryClient {
35074
36025
  });
35075
36026
  }
35076
36027
  }
35077
- trackCliOptionCursor(cursor) {
35078
- if (cursor) {
36028
+ trackCliOptionCursor(cursor2) {
36029
+ if (cursor2) {
35079
36030
  this.trackCliOption({
35080
36031
  option: "cursor",
35081
36032
  value: this.redactedValue
@@ -35850,7 +36801,7 @@ async function listVersions(client, argv, telemetryClient) {
35850
36801
  const [flagArg] = args;
35851
36802
  const environment = flags["--environment"];
35852
36803
  const limit = flags["--limit"];
35853
- const cursor = flags["--cursor"];
36804
+ const cursor2 = flags["--cursor"];
35854
36805
  const json = flags["--json"];
35855
36806
  const projectName = getProjectNameFromFlags(flags);
35856
36807
  if (!flagArg) {
@@ -35863,7 +36814,7 @@ async function listVersions(client, argv, telemetryClient) {
35863
36814
  telemetryClient.trackCliOptionProject(projectName);
35864
36815
  telemetryClient.trackCliOptionEnvironment(environment);
35865
36816
  telemetryClient.trackCliOptionLimit(limit);
35866
- telemetryClient.trackCliOptionCursor(cursor);
36817
+ telemetryClient.trackCliOptionCursor(cursor2);
35867
36818
  telemetryClient.trackCliFlagJson(json);
35868
36819
  if (limit !== void 0 && (!Number.isInteger(limit) || limit < 1 || limit > MAX_FLAG_VERSIONS_PAGE_LIMIT)) {
35869
36820
  output_manager_default.error(
@@ -35871,10 +36822,10 @@ async function listVersions(client, argv, telemetryClient) {
35871
36822
  );
35872
36823
  return 1;
35873
36824
  }
35874
- const link = await resolveLinkedProject(client, projectName);
35875
- if (typeof link === "number")
35876
- return link;
35877
- const { project, org } = link;
36825
+ const link2 = await resolveLinkedProject(client, projectName);
36826
+ if (typeof link2 === "number")
36827
+ return link2;
36828
+ const { project, org } = link2;
35878
36829
  const projectSlugLink = formatProject(org.slug, project.name);
35879
36830
  const versionsStamp = stamp_default();
35880
36831
  const environmentLabel = environment ? ` in ${environment}` : "";
@@ -35889,7 +36840,7 @@ async function listVersions(client, argv, telemetryClient) {
35889
36840
  {
35890
36841
  environment,
35891
36842
  limit,
35892
- cursor
36843
+ cursor: cursor2
35893
36844
  }
35894
36845
  );
35895
36846
  output_manager_default.stopSpinner();
@@ -35950,10 +36901,10 @@ async function diffVersions(client, argv, telemetryClient) {
35950
36901
  output_manager_default.error("Revision 0 has no previous revision to compare.");
35951
36902
  return 1;
35952
36903
  }
35953
- const link = await resolveLinkedProject(client, projectName);
35954
- if (typeof link === "number")
35955
- return link;
35956
- const { project, org } = link;
36904
+ const link2 = await resolveLinkedProject(client, projectName);
36905
+ if (typeof link2 === "number")
36906
+ return link2;
36907
+ const { project, org } = link2;
35957
36908
  const projectSlugLink = formatProject(org.slug, project.name);
35958
36909
  const diffStamp = stamp_default();
35959
36910
  output_manager_default.spinner(
@@ -35999,27 +36950,27 @@ async function diffVersions(client, argv, telemetryClient) {
35999
36950
  return 0;
36000
36951
  }
36001
36952
  async function resolveLinkedProject(client, projectName) {
36002
- const link = await getLinkedFlagsProject(client, projectName);
36003
- if (link.status === "error") {
36004
- return link.exitCode;
36005
- } else if (link.status === "not_linked") {
36953
+ const link2 = await getLinkedFlagsProject(client, projectName);
36954
+ if (link2.status === "error") {
36955
+ return link2.exitCode;
36956
+ } else if (link2.status === "not_linked") {
36006
36957
  output_manager_default.error(
36007
36958
  `Your codebase isn't linked to a project on Vercel. Pass --project <name>, or run ${getCommandName("link")} to link it.`
36008
36959
  );
36009
36960
  return 1;
36010
36961
  }
36011
- client.config.currentTeam = link.org.type === "team" ? link.org.id : void 0;
36012
- return link;
36962
+ client.config.currentTeam = link2.org.type === "team" ? link2.org.id : void 0;
36963
+ return link2;
36013
36964
  }
36014
36965
  async function getVersionPair(client, projectId, flagArg, revision) {
36015
- let cursor;
36966
+ let cursor2;
36016
36967
  let version;
36017
36968
  let previousVersion;
36018
36969
  const availableRevisions = /* @__PURE__ */ new Set();
36019
36970
  do {
36020
36971
  const result = await getFlagVersions(client, projectId, flagArg, {
36021
36972
  limit: MAX_FLAG_VERSIONS_PAGE_LIMIT,
36022
- cursor
36973
+ cursor: cursor2
36023
36974
  });
36024
36975
  for (const candidate of result.versions) {
36025
36976
  availableRevisions.add(candidate.revision);
@@ -36033,8 +36984,8 @@ async function getVersionPair(client, projectId, flagArg, revision) {
36033
36984
  if (version && previousVersion) {
36034
36985
  break;
36035
36986
  }
36036
- cursor = result.next ?? void 0;
36037
- } while (cursor);
36987
+ cursor2 = result.next ?? void 0;
36988
+ } while (cursor2);
36038
36989
  return {
36039
36990
  version,
36040
36991
  previousVersion,
@@ -36385,29 +37336,29 @@ async function evaluations(client, argv) {
36385
37336
  if (!jsonOutput && resolvedGranularity.adjusted && resolvedGranularity.notice) {
36386
37337
  output_manager_default.log(`Notice: ${resolvedGranularity.notice}`);
36387
37338
  }
36388
- let link;
37339
+ let link2;
36389
37340
  try {
36390
- link = await getLinkedFlagsProject(client, projectName, {
37341
+ link2 = await getLinkedFlagsProject(client, projectName, {
36391
37342
  projectNotFoundHandling: jsonOutput ? "return" : "report"
36392
37343
  });
36393
37344
  } catch (error) {
36394
37345
  return handleCommandError(client, error, jsonOutput);
36395
37346
  }
36396
- if (link.status === "error") {
37347
+ if (link2.status === "error") {
36397
37348
  return jsonOutput ? outputError(
36398
37349
  client,
36399
37350
  true,
36400
37351
  "PROJECT_RESOLUTION_FAILED",
36401
37352
  "Unable to resolve the requested Vercel project."
36402
- ) : link.exitCode;
37353
+ ) : link2.exitCode;
36403
37354
  }
36404
- if (link.status === "not_linked") {
37355
+ if (link2.status === "not_linked") {
36405
37356
  const code2 = projectName ? "PROJECT_NOT_FOUND" : "NOT_LINKED";
36406
37357
  const message = projectName ? `Project "${projectName}" was not found in the current scope.` : `Your codebase isn't linked to a project on Vercel. Pass --project <name>, or run ${getCommandName("link")} to link it.`;
36407
37358
  return outputError(client, jsonOutput, code2, message);
36408
37359
  }
36409
- client.config.currentTeam = link.org.type === "team" ? link.org.id : void 0;
36410
- const { project, org } = link;
37360
+ client.config.currentTeam = link2.org.type === "team" ? link2.org.id : void 0;
37361
+ const { project, org } = link2;
36411
37362
  let flag;
36412
37363
  try {
36413
37364
  flag = await getFlag(client, project.id, flagArgument);
@@ -36715,18 +37666,18 @@ async function create4(client, argv) {
36715
37666
  );
36716
37667
  return 1;
36717
37668
  }
36718
- const link = await getLinkedFlagsProject(client, projectName);
36719
- if (link.status === "error") {
36720
- return link.exitCode;
36721
- } else if (link.status === "not_linked") {
37669
+ const link2 = await getLinkedFlagsProject(client, projectName);
37670
+ if (link2.status === "error") {
37671
+ return link2.exitCode;
37672
+ } else if (link2.status === "not_linked") {
36722
37673
  output_manager_default.error(
36723
37674
  `Your codebase isn't linked to a project on Vercel. Pass --project <name>, or run ${getCommandName("link")} to link it.`
36724
37675
  );
36725
37676
  return 1;
36726
37677
  }
36727
- client.config.currentTeam = link.org.type === "team" ? link.org.id : void 0;
36728
- const { project } = link;
36729
- const projectSlugLink = formatProject(link.org.slug, project.name);
37678
+ client.config.currentTeam = link2.org.type === "team" ? link2.org.id : void 0;
37679
+ const { project } = link2;
37680
+ const projectSlugLink = formatProject(link2.org.slug, project.name);
36730
37681
  let variants;
36731
37682
  try {
36732
37683
  variants = await getVariants(client, kind, variantInputs);
@@ -36763,7 +37714,7 @@ async function create4(client, argv) {
36763
37714
  printFlagDetails({
36764
37715
  flag,
36765
37716
  projectSlugLink,
36766
- orgSlug: link.org.slug,
37717
+ orgSlug: link2.org.slug,
36767
37718
  projectName: project.name,
36768
37719
  showTimestamps: false
36769
37720
  });
@@ -36909,17 +37860,17 @@ async function openFlag(client, argv) {
36909
37860
  }
36910
37861
  telemetryClient.trackCliArgumentFlag(flagArg);
36911
37862
  telemetryClient.trackCliOptionProject(projectName);
36912
- const link = await getLinkedFlagsProject(client, projectName);
36913
- if (link.status === "error") {
36914
- return link.exitCode;
36915
- } else if (link.status === "not_linked") {
37863
+ const link2 = await getLinkedFlagsProject(client, projectName);
37864
+ if (link2.status === "error") {
37865
+ return link2.exitCode;
37866
+ } else if (link2.status === "not_linked") {
36916
37867
  output_manager_default.error(
36917
37868
  `Your codebase isn't linked to a project on Vercel. Pass --project <name>, or run ${getCommandName("link")} to link it.`
36918
37869
  );
36919
37870
  return 1;
36920
37871
  }
36921
- client.config.currentTeam = link.org.type === "team" ? link.org.id : void 0;
36922
- const { project, org } = link;
37872
+ client.config.currentTeam = link2.org.type === "team" ? link2.org.id : void 0;
37873
+ const { project, org } = link2;
36923
37874
  try {
36924
37875
  let url = getFlagsDashboardUrl(org.slug, project.name);
36925
37876
  let label = "feature flags dashboard";
@@ -37224,17 +38175,17 @@ async function update2(client, argv) {
37224
38175
  );
37225
38176
  return 1;
37226
38177
  }
37227
- const link = await getLinkedFlagsProject(client, projectName);
37228
- if (link.status === "error") {
37229
- return link.exitCode;
37230
- } else if (link.status === "not_linked") {
38178
+ const link2 = await getLinkedFlagsProject(client, projectName);
38179
+ if (link2.status === "error") {
38180
+ return link2.exitCode;
38181
+ } else if (link2.status === "not_linked") {
37231
38182
  output_manager_default.error(
37232
38183
  `Your codebase isn't linked to a project on Vercel. Pass --project <name>, or run ${getCommandName("link")} to link it.`
37233
38184
  );
37234
38185
  return 1;
37235
38186
  }
37236
- client.config.currentTeam = link.org.type === "team" ? link.org.id : void 0;
37237
- const { project } = link;
38187
+ client.config.currentTeam = link2.org.type === "team" ? link2.org.id : void 0;
38188
+ const { project } = link2;
37238
38189
  try {
37239
38190
  if (hasVariantMutations) {
37240
38191
  return await updateFlagVariants(client, project.id, flagArg, {
@@ -37787,17 +38738,17 @@ async function set4(client, argv) {
37787
38738
  telemetryClient.trackCliOptionEnvironment(environment);
37788
38739
  telemetryClient.trackCliOptionVariant(variantSelector);
37789
38740
  telemetryClient.trackCliOptionMessage(message);
37790
- const link = await getLinkedFlagsProject(client, projectName);
37791
- if (link.status === "error") {
37792
- return link.exitCode;
37793
- } else if (link.status === "not_linked") {
38741
+ const link2 = await getLinkedFlagsProject(client, projectName);
38742
+ if (link2.status === "error") {
38743
+ return link2.exitCode;
38744
+ } else if (link2.status === "not_linked") {
37794
38745
  output_manager_default.error(
37795
38746
  `Your codebase isn't linked to a project on Vercel. Pass --project <name>, or run ${getCommandName("link")} to link it.`
37796
38747
  );
37797
38748
  return 1;
37798
38749
  }
37799
- client.config.currentTeam = link.org.type === "team" ? link.org.id : void 0;
37800
- const { project } = link;
38750
+ client.config.currentTeam = link2.org.type === "team" ? link2.org.id : void 0;
38751
+ const { project } = link2;
37801
38752
  try {
37802
38753
  output_manager_default.spinner("Fetching flag...");
37803
38754
  const flag = await getFlag(client, project.id, flagArg);
@@ -38196,17 +39147,17 @@ async function split(client, argv) {
38196
39147
  );
38197
39148
  telemetryClient.trackCliOptionDefaultVariant(defaultVariantSelector);
38198
39149
  telemetryClient.trackCliOptionMessage(message);
38199
- const link = await getLinkedFlagsProject(client, projectName);
38200
- if (link.status === "error") {
38201
- return link.exitCode;
38202
- } else if (link.status === "not_linked") {
39150
+ const link2 = await getLinkedFlagsProject(client, projectName);
39151
+ if (link2.status === "error") {
39152
+ return link2.exitCode;
39153
+ } else if (link2.status === "not_linked") {
38203
39154
  output_manager_default.error(
38204
39155
  `Your codebase isn't linked to a project on Vercel. Pass --project <name>, or run ${getCommandName("link")} to link it.`
38205
39156
  );
38206
39157
  return 1;
38207
39158
  }
38208
- client.config.currentTeam = link.org.type === "team" ? link.org.id : void 0;
38209
- const { project } = link;
39159
+ client.config.currentTeam = link2.org.type === "team" ? link2.org.id : void 0;
39160
+ const { project } = link2;
38210
39161
  try {
38211
39162
  output_manager_default.spinner("Fetching flag...");
38212
39163
  const [flag, settings] = await Promise.all([
@@ -38732,17 +39683,17 @@ async function rollout(client, argv) {
38732
39683
  );
38733
39684
  telemetryClient.trackCliOptionStart(start);
38734
39685
  telemetryClient.trackCliOptionMessage(message);
38735
- const link = await getLinkedFlagsProject(client, projectName);
38736
- if (link.status === "error") {
38737
- return link.exitCode;
38738
- } else if (link.status === "not_linked") {
39686
+ const link2 = await getLinkedFlagsProject(client, projectName);
39687
+ if (link2.status === "error") {
39688
+ return link2.exitCode;
39689
+ } else if (link2.status === "not_linked") {
38739
39690
  output_manager_default.error(
38740
39691
  `Your codebase isn't linked to a project on Vercel. Pass --project <name>, or run ${getCommandName("link")} to link it.`
38741
39692
  );
38742
39693
  return 1;
38743
39694
  }
38744
- client.config.currentTeam = link.org.type === "team" ? link.org.id : void 0;
38745
- const { project } = link;
39695
+ client.config.currentTeam = link2.org.type === "team" ? link2.org.id : void 0;
39696
+ const { project } = link2;
38746
39697
  try {
38747
39698
  output_manager_default.spinner("Fetching flag...");
38748
39699
  const [flag, settings] = await Promise.all([
@@ -38891,17 +39842,17 @@ async function rm7(client, argv) {
38891
39842
  telemetryClient.trackCliArgumentFlag(flagArg);
38892
39843
  telemetryClient.trackCliOptionProject(projectName);
38893
39844
  telemetryClient.trackCliFlagYes(skipConfirmation);
38894
- const link = await getLinkedFlagsProject(client, projectName);
38895
- if (link.status === "error") {
38896
- return link.exitCode;
38897
- } else if (link.status === "not_linked") {
39845
+ const link2 = await getLinkedFlagsProject(client, projectName);
39846
+ if (link2.status === "error") {
39847
+ return link2.exitCode;
39848
+ } else if (link2.status === "not_linked") {
38898
39849
  output_manager_default.error(
38899
39850
  `Your codebase isn't linked to a project on Vercel. Pass --project <name>, or run ${getCommandName("link")} to link it.`
38900
39851
  );
38901
39852
  return 1;
38902
39853
  }
38903
- client.config.currentTeam = link.org.type === "team" ? link.org.id : void 0;
38904
- const { project } = link;
39854
+ client.config.currentTeam = link2.org.type === "team" ? link2.org.id : void 0;
39855
+ const { project } = link2;
38905
39856
  try {
38906
39857
  output_manager_default.spinner("Fetching flag...");
38907
39858
  const flag = await getFlag(client, project.id, flagArg);
@@ -38987,17 +39938,17 @@ async function archive(client, argv) {
38987
39938
  telemetryClient.trackCliArgumentFlag(flagArg);
38988
39939
  telemetryClient.trackCliOptionProject(projectName);
38989
39940
  telemetryClient.trackCliFlagYes(skipConfirmation);
38990
- const link = await getLinkedFlagsProject(client, projectName);
38991
- if (link.status === "error") {
38992
- return link.exitCode;
38993
- } else if (link.status === "not_linked") {
39941
+ const link2 = await getLinkedFlagsProject(client, projectName);
39942
+ if (link2.status === "error") {
39943
+ return link2.exitCode;
39944
+ } else if (link2.status === "not_linked") {
38994
39945
  output_manager_default.error(
38995
39946
  `Your codebase isn't linked to a project on Vercel. Pass --project <name>, or run ${getCommandName("link")} to link it.`
38996
39947
  );
38997
39948
  return 1;
38998
39949
  }
38999
- client.config.currentTeam = link.org.type === "team" ? link.org.id : void 0;
39000
- const { project } = link;
39950
+ client.config.currentTeam = link2.org.type === "team" ? link2.org.id : void 0;
39951
+ const { project } = link2;
39001
39952
  try {
39002
39953
  output_manager_default.spinner("Fetching flag...");
39003
39954
  const flag = await getFlag(client, project.id, flagArg);
@@ -39088,17 +40039,17 @@ async function unarchive(client, argv) {
39088
40039
  telemetryClient.trackCliArgumentFlag(flagArg);
39089
40040
  telemetryClient.trackCliOptionProject(projectName);
39090
40041
  telemetryClient.trackCliFlagYes(skipConfirmation);
39091
- const link = await getLinkedFlagsProject(client, projectName);
39092
- if (link.status === "error") {
39093
- return link.exitCode;
39094
- } else if (link.status === "not_linked") {
40042
+ const link2 = await getLinkedFlagsProject(client, projectName);
40043
+ if (link2.status === "error") {
40044
+ return link2.exitCode;
40045
+ } else if (link2.status === "not_linked") {
39095
40046
  output_manager_default.error(
39096
40047
  `Your codebase isn't linked to a project on Vercel. Pass --project <name>, or run ${getCommandName("link")} to link it.`
39097
40048
  );
39098
40049
  return 1;
39099
40050
  }
39100
- client.config.currentTeam = link.org.type === "team" ? link.org.id : void 0;
39101
- const { project } = link;
40051
+ client.config.currentTeam = link2.org.type === "team" ? link2.org.id : void 0;
40052
+ const { project } = link2;
39102
40053
  try {
39103
40054
  output_manager_default.spinner("Fetching flag...");
39104
40055
  const flag = await getFlag(client, project.id, flagArg);
@@ -39282,10 +40233,10 @@ async function disable3(client, argv) {
39282
40233
  telemetryClient.trackCliOptionEnvironment(environment);
39283
40234
  telemetryClient.trackCliOptionVariant(variantId);
39284
40235
  telemetryClient.trackCliOptionMessage(message);
39285
- const link = await getLinkedFlagsProject(client, projectName);
39286
- if (link.status === "error") {
39287
- return link.exitCode;
39288
- } else if (link.status === "not_linked") {
40236
+ const link2 = await getLinkedFlagsProject(client, projectName);
40237
+ if (link2.status === "error") {
40238
+ return link2.exitCode;
40239
+ } else if (link2.status === "not_linked") {
39289
40240
  if (client.nonInteractive) {
39290
40241
  outputAgentError(
39291
40242
  client,
@@ -39309,8 +40260,8 @@ async function disable3(client, argv) {
39309
40260
  );
39310
40261
  return 1;
39311
40262
  }
39312
- client.config.currentTeam = link.org.type === "team" ? link.org.id : void 0;
39313
- const { project } = link;
40263
+ client.config.currentTeam = link2.org.type === "team" ? link2.org.id : void 0;
40264
+ const { project } = link2;
39314
40265
  try {
39315
40266
  output_manager_default.spinner("Fetching flag...");
39316
40267
  const flag = await getFlag(client, project.id, flagArg);
@@ -39326,7 +40277,7 @@ async function disable3(client, argv) {
39326
40277
  attemptedSubcommand: "disable",
39327
40278
  environment,
39328
40279
  isInteractive: Boolean(client.stdin.isTTY),
39329
- teamSlug: link.org.slug,
40280
+ teamSlug: link2.org.slug,
39330
40281
  projectName: project.name
39331
40282
  });
39332
40283
  return 0;
@@ -39495,17 +40446,17 @@ async function enable3(client, argv) {
39495
40446
  telemetryClient.trackCliOptionProject(projectName);
39496
40447
  telemetryClient.trackCliOptionEnvironment(environment);
39497
40448
  telemetryClient.trackCliOptionMessage(message);
39498
- const link = await getLinkedFlagsProject(client, projectName);
39499
- if (link.status === "error") {
39500
- return link.exitCode;
39501
- } else if (link.status === "not_linked") {
40449
+ const link2 = await getLinkedFlagsProject(client, projectName);
40450
+ if (link2.status === "error") {
40451
+ return link2.exitCode;
40452
+ } else if (link2.status === "not_linked") {
39502
40453
  output_manager_default.error(
39503
40454
  `Your codebase isn't linked to a project on Vercel. Pass --project <name>, or run ${getCommandName("link")} to link it.`
39504
40455
  );
39505
40456
  return 1;
39506
40457
  }
39507
- client.config.currentTeam = link.org.type === "team" ? link.org.id : void 0;
39508
- const { project } = link;
40458
+ client.config.currentTeam = link2.org.type === "team" ? link2.org.id : void 0;
40459
+ const { project } = link2;
39509
40460
  try {
39510
40461
  output_manager_default.spinner("Fetching flag...");
39511
40462
  const flag = await getFlag(client, project.id, flagArg);
@@ -39521,7 +40472,7 @@ async function enable3(client, argv) {
39521
40472
  attemptedSubcommand: "enable",
39522
40473
  environment,
39523
40474
  isInteractive: Boolean(client.stdin.isTTY),
39524
- teamSlug: link.org.slug,
40475
+ teamSlug: link2.org.slug,
39525
40476
  projectName: project.name
39526
40477
  });
39527
40478
  return 0;
@@ -39734,17 +40685,17 @@ async function sdkKeysLs(client, argv) {
39734
40685
  const projectName = getProjectNameFromFlags(flags);
39735
40686
  telemetryClient.trackCliOptionProject(projectName);
39736
40687
  telemetryClient.trackCliFlagJson(json);
39737
- const link = await getLinkedFlagsProject(client, projectName);
39738
- if (link.status === "error") {
39739
- return link.exitCode;
39740
- } else if (link.status === "not_linked") {
40688
+ const link2 = await getLinkedFlagsProject(client, projectName);
40689
+ if (link2.status === "error") {
40690
+ return link2.exitCode;
40691
+ } else if (link2.status === "not_linked") {
39741
40692
  output_manager_default.error(
39742
40693
  `Your codebase isn't linked to a project on Vercel. Pass --project <name>, or run ${getCommandName("link")} to link it.`
39743
40694
  );
39744
40695
  return 1;
39745
40696
  }
39746
- client.config.currentTeam = link.org.type === "team" ? link.org.id : void 0;
39747
- const { project, org } = link;
40697
+ client.config.currentTeam = link2.org.type === "team" ? link2.org.id : void 0;
40698
+ const { project, org } = link2;
39748
40699
  const projectSlugLink = formatProject(org.slug, project.name);
39749
40700
  try {
39750
40701
  output_manager_default.spinner("Fetching SDK keys...");
@@ -39856,10 +40807,10 @@ async function sdkKeysAdd(client, argv) {
39856
40807
  telemetryClient.trackCliOptionType(sdkKeyType);
39857
40808
  telemetryClient.trackCliOptionEnvironment(environment);
39858
40809
  telemetryClient.trackCliOptionLabel(label);
39859
- const link = await getLinkedFlagsProject(client, projectName);
39860
- if (link.status === "error") {
39861
- return link.exitCode;
39862
- } else if (link.status === "not_linked") {
40810
+ const link2 = await getLinkedFlagsProject(client, projectName);
40811
+ if (link2.status === "error") {
40812
+ return link2.exitCode;
40813
+ } else if (link2.status === "not_linked") {
39863
40814
  if (client.nonInteractive) {
39864
40815
  outputAgentError(
39865
40816
  client,
@@ -39883,8 +40834,8 @@ async function sdkKeysAdd(client, argv) {
39883
40834
  );
39884
40835
  return 1;
39885
40836
  }
39886
- client.config.currentTeam = link.org.type === "team" ? link.org.id : void 0;
39887
- const { project } = link;
40837
+ client.config.currentTeam = link2.org.type === "team" ? link2.org.id : void 0;
40838
+ const { project } = link2;
39888
40839
  if (!sdkKeyType) {
39889
40840
  if (client.nonInteractive) {
39890
40841
  const envPart = environment ? `--environment ${environment}` : "--environment <production|preview|development>";
@@ -40084,10 +41035,10 @@ async function sdkKeysRm(client, argv) {
40084
41035
  telemetryClient.trackCliArgumentKey(hashKey);
40085
41036
  telemetryClient.trackCliOptionProject(projectName);
40086
41037
  telemetryClient.trackCliFlagYes(skipConfirmation);
40087
- const link = await getLinkedFlagsProject(client, projectName);
40088
- if (link.status === "error") {
40089
- return link.exitCode;
40090
- } else if (link.status === "not_linked") {
41038
+ const link2 = await getLinkedFlagsProject(client, projectName);
41039
+ if (link2.status === "error") {
41040
+ return link2.exitCode;
41041
+ } else if (link2.status === "not_linked") {
40091
41042
  if (client.nonInteractive) {
40092
41043
  outputAgentError(
40093
41044
  client,
@@ -40111,8 +41062,8 @@ async function sdkKeysRm(client, argv) {
40111
41062
  );
40112
41063
  return 1;
40113
41064
  }
40114
- client.config.currentTeam = link.org.type === "team" ? link.org.id : void 0;
40115
- const { project } = link;
41065
+ client.config.currentTeam = link2.org.type === "team" ? link2.org.id : void 0;
41066
+ const { project } = link2;
40116
41067
  try {
40117
41068
  if (!hashKey) {
40118
41069
  if (client.nonInteractive) {
@@ -40555,17 +41506,17 @@ async function segmentsLs(client, argv) {
40555
41506
  const projectName = getProjectNameFromFlags(flags);
40556
41507
  telemetryClient.trackCliOptionProject(projectName);
40557
41508
  telemetryClient.trackCliFlagJson(json);
40558
- const link = await getLinkedFlagsProject(client, projectName);
40559
- if (link.status === "error") {
40560
- return link.exitCode;
40561
- } else if (link.status === "not_linked") {
41509
+ const link2 = await getLinkedFlagsProject(client, projectName);
41510
+ if (link2.status === "error") {
41511
+ return link2.exitCode;
41512
+ } else if (link2.status === "not_linked") {
40562
41513
  output_manager_default.error(
40563
41514
  `Your codebase isn't linked to a project on Vercel. Pass --project <name>, or run ${getCommandName("link")} to link it.`
40564
41515
  );
40565
41516
  return 1;
40566
41517
  }
40567
- client.config.currentTeam = link.org.type === "team" ? link.org.id : void 0;
40568
- const { project, org } = link;
41518
+ client.config.currentTeam = link2.org.type === "team" ? link2.org.id : void 0;
41519
+ const { project, org } = link2;
40569
41520
  const projectSlugLink = formatProject(org.slug, project.name);
40570
41521
  const lsStamp = stamp_default();
40571
41522
  output_manager_default.spinner(`Fetching feature flag segments for ${projectSlugLink}`);
@@ -40807,17 +41758,17 @@ async function segmentsInspect(client, argv) {
40807
41758
  telemetryClient.trackCliArgumentSegment(segmentArg);
40808
41759
  telemetryClient.trackCliOptionProject(projectName);
40809
41760
  telemetryClient.trackCliFlagJson(json);
40810
- const link = await getLinkedFlagsProject(client, projectName);
40811
- if (link.status === "error") {
40812
- return link.exitCode;
40813
- } else if (link.status === "not_linked") {
41761
+ const link2 = await getLinkedFlagsProject(client, projectName);
41762
+ if (link2.status === "error") {
41763
+ return link2.exitCode;
41764
+ } else if (link2.status === "not_linked") {
40814
41765
  output_manager_default.error(
40815
41766
  `Your codebase isn't linked to a project on Vercel. Pass --project <name>, or run ${getCommandName("link")} to link it.`
40816
41767
  );
40817
41768
  return 1;
40818
41769
  }
40819
- client.config.currentTeam = link.org.type === "team" ? link.org.id : void 0;
40820
- const { project, org } = link;
41770
+ client.config.currentTeam = link2.org.type === "team" ? link2.org.id : void 0;
41771
+ const { project, org } = link2;
40821
41772
  const projectSlugLink = formatProject(org.slug, project.name);
40822
41773
  try {
40823
41774
  output_manager_default.spinner("Fetching segment...");
@@ -41274,10 +42225,10 @@ async function segmentsCreate(client, argv) {
41274
42225
  );
41275
42226
  return 1;
41276
42227
  }
41277
- const link = await getLinkedFlagsProject(client, projectName);
41278
- if (link.status === "error") {
41279
- return link.exitCode;
41280
- } else if (link.status === "not_linked") {
42228
+ const link2 = await getLinkedFlagsProject(client, projectName);
42229
+ if (link2.status === "error") {
42230
+ return link2.exitCode;
42231
+ } else if (link2.status === "not_linked") {
41281
42232
  if (client.nonInteractive) {
41282
42233
  outputAgentError(
41283
42234
  client,
@@ -41301,8 +42252,8 @@ async function segmentsCreate(client, argv) {
41301
42252
  );
41302
42253
  return 1;
41303
42254
  }
41304
- client.config.currentTeam = link.org.type === "team" ? link.org.id : void 0;
41305
- const { project, org } = link;
42255
+ client.config.currentTeam = link2.org.type === "team" ? link2.org.id : void 0;
42256
+ const { project, org } = link2;
41306
42257
  const projectSlugLink = formatProject(org.slug, project.name);
41307
42258
  label = await resolveSegmentLabel(client, label, slug);
41308
42259
  hint = await resolveSegmentHint(client, hint, description, label);
@@ -41449,10 +42400,10 @@ async function segmentsUpdate(client, argv) {
41449
42400
  telemetryClient.trackCliOptionAdd(addInputs);
41450
42401
  telemetryClient.trackCliOptionRemove(removeInputs);
41451
42402
  telemetryClient.trackCliFlagJson(json);
41452
- const link = await getLinkedFlagsProject(client, projectName);
41453
- if (link.status === "error") {
41454
- return link.exitCode;
41455
- } else if (link.status === "not_linked") {
42403
+ const link2 = await getLinkedFlagsProject(client, projectName);
42404
+ if (link2.status === "error") {
42405
+ return link2.exitCode;
42406
+ } else if (link2.status === "not_linked") {
41456
42407
  if (client.nonInteractive) {
41457
42408
  outputAgentError(
41458
42409
  client,
@@ -41476,8 +42427,8 @@ async function segmentsUpdate(client, argv) {
41476
42427
  );
41477
42428
  return 1;
41478
42429
  }
41479
- client.config.currentTeam = link.org.type === "team" ? link.org.id : void 0;
41480
- const { project, org } = link;
42430
+ client.config.currentTeam = link2.org.type === "team" ? link2.org.id : void 0;
42431
+ const { project, org } = link2;
41481
42432
  const projectSlugLink = formatProject(org.slug, project.name);
41482
42433
  try {
41483
42434
  if (!segmentArg) {
@@ -41810,10 +42761,10 @@ async function segmentsRm(client, argv) {
41810
42761
  telemetryClient.trackCliArgumentSegment(segmentArg);
41811
42762
  telemetryClient.trackCliOptionProject(projectName);
41812
42763
  telemetryClient.trackCliFlagYes(skipConfirmation);
41813
- const link = await getLinkedFlagsProject(client, projectName);
41814
- if (link.status === "error") {
41815
- return link.exitCode;
41816
- } else if (link.status === "not_linked") {
42764
+ const link2 = await getLinkedFlagsProject(client, projectName);
42765
+ if (link2.status === "error") {
42766
+ return link2.exitCode;
42767
+ } else if (link2.status === "not_linked") {
41817
42768
  if (client.nonInteractive) {
41818
42769
  outputAgentError(
41819
42770
  client,
@@ -41837,8 +42788,8 @@ async function segmentsRm(client, argv) {
41837
42788
  );
41838
42789
  return 1;
41839
42790
  }
41840
- client.config.currentTeam = link.org.type === "team" ? link.org.id : void 0;
41841
- const { project } = link;
42791
+ client.config.currentTeam = link2.org.type === "team" ? link2.org.id : void 0;
42792
+ const { project } = link2;
41842
42793
  try {
41843
42794
  if (!segmentArg) {
41844
42795
  segmentArg = await resolveSegmentArg2(client, project.id);
@@ -42573,20 +43524,20 @@ function isRecord3(value) {
42573
43524
  // src/commands/flags/rules-common.ts
42574
43525
  var import_chalk154 = __toESM(require_source(), 1);
42575
43526
  async function resolveRulesCommandContext(client, options) {
42576
- const link = await resolveProjectContext({
43527
+ const link2 = await resolveProjectContext({
42577
43528
  client,
42578
43529
  projectNameOrId: options.projectName
42579
43530
  });
42580
- if (link.status === "error") {
42581
- return { exitCode: link.exitCode };
42582
- } else if (link.status === "not_linked") {
43531
+ if (link2.status === "error") {
43532
+ return { exitCode: link2.exitCode };
43533
+ } else if (link2.status === "not_linked") {
42583
43534
  output_manager_default.error(
42584
43535
  `Your codebase isn't linked to a project on Vercel. Run ${getCommandName("link")} to begin.`
42585
43536
  );
42586
43537
  return { exitCode: 1 };
42587
43538
  }
42588
- client.config.currentTeam = link.org.type === "team" ? link.org.id : void 0;
42589
- const { project } = link;
43539
+ client.config.currentTeam = link2.org.type === "team" ? link2.org.id : void 0;
43540
+ const { project } = link2;
42590
43541
  output_manager_default.spinner("Fetching flag...");
42591
43542
  const [flag, settings] = await Promise.all([
42592
43543
  getFlag(client, project.id, options.flagArg),
@@ -43623,7 +44574,7 @@ async function main17(client) {
43623
44574
 
43624
44575
  // src/commands/git/connect.ts
43625
44576
  var import_chalk160 = __toESM(require_source(), 1);
43626
- import { join as join10 } from "path";
44577
+ import { join as join16 } from "path";
43627
44578
 
43628
44579
  // src/util/telemetry/commands/git/connect.ts
43629
44580
  var GitConnectTelemetryClient = class extends TelemetryClient {
@@ -43694,7 +44645,7 @@ async function connect(client, argv) {
43694
44645
  const { project, org } = linkedProject;
43695
44646
  const gitProviderLink = project.link;
43696
44647
  client.config.currentTeam = org.type === "team" ? org.id : void 0;
43697
- const gitConfigPath = join10(cwd, ".git/config");
44648
+ const gitConfigPath = join16(cwd, ".git/config");
43698
44649
  const gitConfig = await parseGitConfig(gitConfigPath);
43699
44650
  if (repoArg) {
43700
44651
  const parsedUrlArg = parseRepoUrl(repoArg);
@@ -44257,7 +45208,7 @@ async function httpstat(client) {
44257
45208
  // src/commands/init/init.ts
44258
45209
  var import_tar_fs = __toESM(require_tar_fs(), 1);
44259
45210
  var import_chalk163 = __toESM(require_source(), 1);
44260
- import fs from "fs";
45211
+ import fs3 from "fs";
44261
45212
  import path2 from "path";
44262
45213
  var EXAMPLE_API = "https://examples.vercel.sh";
44263
45214
  async function init(client, opts, args, telemetry2) {
@@ -44359,15 +45310,15 @@ ${deployHint}`);
44359
45310
  }
44360
45311
  function prepareFolder(cwd, folder, force) {
44361
45312
  const dest = path2.join(cwd, folder);
44362
- if (fs.existsSync(dest)) {
44363
- if (!fs.lstatSync(dest).isDirectory()) {
45313
+ if (fs3.existsSync(dest)) {
45314
+ if (!fs3.lstatSync(dest).isDirectory()) {
44364
45315
  throw new Error(
44365
45316
  `Destination path "${import_chalk163.default.bold(
44366
45317
  folder
44367
45318
  )}" already exists and is not a directory.`
44368
45319
  );
44369
45320
  }
44370
- if (!force && fs.readdirSync(dest).length !== 0) {
45321
+ if (!force && fs3.readdirSync(dest).length !== 0) {
44371
45322
  throw new Error(
44372
45323
  `Destination path "${import_chalk163.default.bold(
44373
45324
  folder
@@ -44378,7 +45329,7 @@ function prepareFolder(cwd, folder, force) {
44378
45329
  }
44379
45330
  } else if (dest !== cwd) {
44380
45331
  try {
44381
- fs.mkdirSync(dest);
45332
+ fs3.mkdirSync(dest);
44382
45333
  } catch (_e) {
44383
45334
  throw new Error(`Could not create directory "${import_chalk163.default.bold(folder)}".`);
44384
45335
  }
@@ -45015,7 +45966,7 @@ async function printDetails({
45015
45966
  readyState,
45016
45967
  alias: aliases
45017
45968
  } = deployment;
45018
- const { print, link } = output_manager_default;
45969
+ const { print, link: link2 } = output_manager_default;
45019
45970
  const { builds } = deployment.version === 2 ? await client.fetch(`/v11/deployments/${id}/builds`) : { builds: [] };
45020
45971
  print("\n");
45021
45972
  print(import_chalk166.default.bold(" General\n\n"));
@@ -45027,7 +45978,7 @@ async function printDetails({
45027
45978
  const target = customEnvironmentSlug ?? deployment.target ?? "preview";
45028
45979
  print(` ${import_chalk166.default.cyan("target")} `);
45029
45980
  print(
45030
- deployment.customEnvironment && deployment.team?.slug ? `${link(
45981
+ deployment.customEnvironment && deployment.team?.slug ? `${link2(
45031
45982
  `${target}`,
45032
45983
  `https://vercel.com/${deployment.team.slug}/${name}/settings/environments/${deployment.customEnvironment.id}`,
45033
45984
  { fallback: () => target, color: false }
@@ -49700,28 +50651,28 @@ async function openIntegration(client, subArgs) {
49700
50651
  );
49701
50652
  return 1;
49702
50653
  }
49703
- const link2 = buildSSOLink(
50654
+ const link3 = buildSSOLink(
49704
50655
  team,
49705
50656
  configurationId,
49706
50657
  resource.externalResourceId
49707
50658
  );
49708
- outputLink(client, link2, asJson, resourceName, true);
50659
+ outputLink(client, link3, asJson, resourceName, true);
49709
50660
  return 0;
49710
50661
  }
49711
- const link = buildSSOLink(team, configurationId);
49712
- outputLink(client, link, asJson, integrationSlug, false);
50662
+ const link2 = buildSSOLink(team, configurationId);
50663
+ outputLink(client, link2, asJson, integrationSlug, false);
49713
50664
  return 0;
49714
50665
  }
49715
- function outputLink(client, link, json, name, isResource) {
50666
+ function outputLink(client, link2, json, name, isResource) {
49716
50667
  if (json) {
49717
- client.stdout.write(`${JSON.stringify({ url: link }, null, 2)}
50668
+ client.stdout.write(`${JSON.stringify({ url: link2 }, null, 2)}
49718
50669
  `);
49719
50670
  } else if (client.stdout.isTTY) {
49720
50671
  const label = isResource ? `Opening the ${import_chalk183.default.bold(name)} resource dashboard...` : `Opening the ${import_chalk183.default.bold(name)} dashboard...`;
49721
50672
  output_manager_default.print(label);
49722
- (0, import_open13.default)(link);
50673
+ (0, import_open13.default)(link2);
49723
50674
  } else {
49724
- client.stdout.write(`${link}
50675
+ client.stdout.write(`${link2}
49725
50676
  `);
49726
50677
  }
49727
50678
  }
@@ -50788,8 +51739,8 @@ function printGuide(client, product, guide2, snippets, resourceLinks) {
50788
51739
  function appendResourceLinks(links, lines) {
50789
51740
  lines.push("## Resources");
50790
51741
  lines.push("");
50791
- for (const link of links) {
50792
- lines.push(`- [${link.title}](${link.href})`);
51742
+ for (const link2 of links) {
51743
+ lines.push(`- [${link2.title}](${link2.href})`);
50793
51744
  }
50794
51745
  lines.push("");
50795
51746
  }
@@ -52097,11 +53048,11 @@ async function resolveLogsTarget(client, { contextName, deploymentOption, projec
52097
53048
  targetSource: "explicit-project"
52098
53049
  };
52099
53050
  }
52100
- const link = await getLinkedProject(client);
52101
- if (link.status === "error") {
52102
- return { exitCode: link.exitCode };
53051
+ const link2 = await getLinkedProject(client);
53052
+ if (link2.status === "error") {
53053
+ return { exitCode: link2.exitCode };
52103
53054
  }
52104
- if (link.status === "not_linked") {
53055
+ if (link2.status === "not_linked") {
52105
53056
  output_manager_default.error(
52106
53057
  `Your codebase isn't linked to a project on Vercel. Run ${getCommandName(
52107
53058
  "link"
@@ -52109,12 +53060,12 @@ async function resolveLogsTarget(client, { contextName, deploymentOption, projec
52109
53060
  );
52110
53061
  return { exitCode: 1 };
52111
53062
  }
52112
- client.config.currentTeam = link.org.type === "team" ? link.org.id : void 0;
53063
+ client.config.currentTeam = link2.org.type === "team" ? link2.org.id : void 0;
52113
53064
  return {
52114
- projectId: link.project.id,
52115
- projectSlug: link.project.name,
52116
- orgSlug: link.org.slug,
52117
- ownerId: link.org.id,
53065
+ projectId: link2.project.id,
53066
+ projectSlug: link2.project.name,
53067
+ orgSlug: link2.org.slug,
53068
+ ownerId: link2.org.id,
52118
53069
  targetSource: "linked-project"
52119
53070
  };
52120
53071
  }
@@ -52723,17 +53674,17 @@ async function mcp(client, opts = {}) {
52723
53674
  const cursorMcpPath = process.platform === "darwin" ? `${process.env.HOME}/.cursor/mcp.json` : process.platform === "win32" ? `${process.env.APPDATA}/Cursor/mcp.json` : `${process.env.HOME}/.cursor/mcp.json`;
52724
53675
  let cursorAlreadyConfigured = false;
52725
53676
  try {
52726
- const fs2 = __require("fs");
52727
- if (fs2.existsSync(cursorMcpPath)) {
52728
- const configContent = fs2.readFileSync(cursorMcpPath, "utf8");
53677
+ const fs4 = __require("fs");
53678
+ if (fs4.existsSync(cursorMcpPath)) {
53679
+ const configContent = fs4.readFileSync(cursorMcpPath, "utf8");
52729
53680
  const config2 = JSON.parse(configContent);
52730
53681
  const mcpServers = config2.mcpServers || {};
52731
53682
  cursorAlreadyConfigured = Object.values(mcpServers).some(
52732
53683
  (server) => server.url === mcpUrl || server.url === MCP_ENDPOINT
52733
53684
  );
52734
53685
  }
52735
- if (!cursorAlreadyConfigured && fs2.existsSync(cursorConfigPath)) {
52736
- const configContent = fs2.readFileSync(cursorConfigPath, "utf8");
53686
+ if (!cursorAlreadyConfigured && fs4.existsSync(cursorConfigPath)) {
53687
+ const configContent = fs4.readFileSync(cursorConfigPath, "utf8");
52737
53688
  const config2 = JSON.parse(configContent);
52738
53689
  const mcpServers = config2["mcp.servers"] || {};
52739
53690
  cursorAlreadyConfigured = Object.values(mcpServers).some(
@@ -52814,17 +53765,17 @@ async function mcp(client, opts = {}) {
52814
53765
  const vscodeMcpPath = process.platform === "darwin" ? `${process.env.HOME}/Library/Application Support/Code/User/mcp.json` : process.platform === "win32" ? `${process.env.APPDATA}/Code/User/mcp.json` : `${process.env.HOME}/.config/Code/User/mcp.json`;
52815
53766
  let vscodeAlreadyConfigured = false;
52816
53767
  try {
52817
- const fs2 = __require("fs");
52818
- if (fs2.existsSync(vscodeMcpPath)) {
52819
- const configContent = fs2.readFileSync(vscodeMcpPath, "utf8");
53768
+ const fs4 = __require("fs");
53769
+ if (fs4.existsSync(vscodeMcpPath)) {
53770
+ const configContent = fs4.readFileSync(vscodeMcpPath, "utf8");
52820
53771
  const config2 = JSON.parse(configContent);
52821
53772
  const mcpServers = config2.servers || {};
52822
53773
  vscodeAlreadyConfigured = Object.values(mcpServers).some(
52823
53774
  (server) => server.url === mcpUrl || server.url === MCP_ENDPOINT
52824
53775
  );
52825
53776
  }
52826
- if (!vscodeAlreadyConfigured && fs2.existsSync(vscodeConfigPath)) {
52827
- const configContent = fs2.readFileSync(vscodeConfigPath, "utf8");
53777
+ if (!vscodeAlreadyConfigured && fs4.existsSync(vscodeConfigPath)) {
53778
+ const configContent = fs4.readFileSync(vscodeConfigPath, "utf8");
52828
53779
  const config2 = JSON.parse(configContent);
52829
53780
  const mcpServers = config2["mcp.servers"] || {};
52830
53781
  vscodeAlreadyConfigured = Object.values(mcpServers).some(
@@ -53213,7 +54164,7 @@ async function metrics(client) {
53213
54164
  return 0;
53214
54165
  }
53215
54166
  telemetry2.trackCliSubcommandSchema(subcommandOriginal);
53216
- const schemaFn = (await import("./chunks/schema-JP4Z36AT.js")).default;
54167
+ const schemaFn = (await import("./chunks/schema-QDU3FPNC.js")).default;
53217
54168
  return schemaFn(client, telemetry2);
53218
54169
  }
53219
54170
  default: {
@@ -53226,7 +54177,7 @@ async function metrics(client) {
53226
54177
  output_manager_default.print(help(metricsCommand, { columns: client.stderr.columns }));
53227
54178
  return 2;
53228
54179
  }
53229
- const queryFn = (await import("./chunks/query-DFRPIOZM.js")).default;
54180
+ const queryFn = (await import("./chunks/query-7MQN4S3S.js")).default;
53230
54181
  return queryFn(client, telemetry2);
53231
54182
  }
53232
54183
  }
@@ -53234,7 +54185,7 @@ async function metrics(client) {
53234
54185
 
53235
54186
  // src/commands/microfrontends/pull.ts
53236
54187
  var import_chalk192 = __toESM(require_source(), 1);
53237
- import { join as join11 } from "path";
54188
+ import { join as join17 } from "path";
53238
54189
  var import_fs_extra = __toESM(require_lib(), 1);
53239
54190
  var VERCEL_DIR = ".vercel";
53240
54191
  var VERCEL_DIR_MICROFRONTENDS = "microfrontends.json";
@@ -53248,16 +54199,16 @@ async function pull2(client) {
53248
54199
  return 1;
53249
54200
  }
53250
54201
  const autoConfirm = !!parsedArgs.flags["--yes"];
53251
- const link = await ensureLink("microfrontends", client, client.cwd, {
54202
+ const link2 = await ensureLink("microfrontends", client, client.cwd, {
53252
54203
  autoConfirm
53253
54204
  });
53254
- if (typeof link === "number") {
53255
- return link;
54205
+ if (typeof link2 === "number") {
54206
+ return link2;
53256
54207
  }
53257
- const { project, org, repoRoot } = link;
54208
+ const { project, org, repoRoot } = link2;
53258
54209
  let currentDirectory;
53259
54210
  if (repoRoot) {
53260
- currentDirectory = join11(repoRoot, project.rootDirectory || "");
54211
+ currentDirectory = join17(repoRoot, project.rootDirectory || "");
53261
54212
  } else {
53262
54213
  currentDirectory = client.cwd;
53263
54214
  }
@@ -53295,7 +54246,7 @@ async function pull2(client) {
53295
54246
  )
53296
54247
  };
53297
54248
  output_manager_default.stopSpinner();
53298
- const path3 = join11(currentDirectory, VERCEL_DIR, VERCEL_DIR_MICROFRONTENDS);
54249
+ const path3 = join17(currentDirectory, VERCEL_DIR, VERCEL_DIR_MICROFRONTENDS);
53299
54250
  await (0, import_fs_extra.outputJSON)(path3, sanitizedConfig, {
53300
54251
  spaces: 2
53301
54252
  });
@@ -53304,7 +54255,7 @@ async function pull2(client) {
53304
54255
  `${prependEmoji(
53305
54256
  `Downloaded microfrontends configuration to ${import_chalk192.default.bold(
53306
54257
  humanizePath(
53307
- join11(currentDirectory, VERCEL_DIR, VERCEL_DIR_MICROFRONTENDS)
54258
+ join17(currentDirectory, VERCEL_DIR, VERCEL_DIR_MICROFRONTENDS)
53308
54259
  )
53309
54260
  )} ${import_chalk192.default.gray(microfrontendsStamp())}`,
53310
54261
  emoji("success")
@@ -53321,19 +54272,19 @@ async function pull2(client) {
53321
54272
 
53322
54273
  // src/commands/microfrontends/create-group.ts
53323
54274
  var import_chalk193 = __toESM(require_source(), 1);
53324
- import { writeFile as writeFile6 } from "fs/promises";
53325
- import { existsSync as existsSync4 } from "fs";
53326
- import { join as join12 } from "path";
54275
+ import { writeFile as writeFile8 } from "fs/promises";
54276
+ import { existsSync as existsSync3 } from "fs";
54277
+ import { join as join18 } from "path";
53327
54278
 
53328
54279
  // src/commands/microfrontends/utils.ts
53329
54280
  async function ensureMicrofrontendsContext(client, options) {
53330
- const link = await ensureLink("microfrontends", client, client.cwd, {
54281
+ const link2 = await ensureLink("microfrontends", client, client.cwd, {
53331
54282
  autoConfirm: options?.autoConfirm
53332
54283
  });
53333
- if (typeof link === "number") {
53334
- return link;
54284
+ if (typeof link2 === "number") {
54285
+ return link2;
53335
54286
  }
53336
- const { project, org, repoRoot } = link;
54287
+ const { project, org, repoRoot } = link2;
53337
54288
  if (org.type !== "team") {
53338
54289
  output_manager_default.error("Microfrontends are only available for teams.");
53339
54290
  return 1;
@@ -53743,13 +54694,13 @@ async function createGroup(client) {
53743
54694
  output_manager_default.log(
53744
54695
  `View microfrontends group: ${output_manager_default.link(settingsUrl, settingsUrl, { fallback: false })}`
53745
54696
  );
53746
- const link = await getLinkedProject(client, { cwd: client.cwd });
53747
- const linkedProject = link.status === "linked" ? link.project : void 0;
54697
+ const link2 = await getLinkedProject(client, { cwd: client.cwd });
54698
+ const linkedProject = link2.status === "linked" ? link2.project : void 0;
53748
54699
  if (linkedProject && linkedProject.id === defaultApp.id) {
53749
- const repoRoot = link.status === "linked" ? link.repoRoot : void 0;
53750
- const projectDir = repoRoot ? join12(repoRoot, linkedProject.rootDirectory || "") : client.cwd;
53751
- const configPath = join12(projectDir, "microfrontends.json");
53752
- if (!existsSync4(configPath)) {
54700
+ const repoRoot = link2.status === "linked" ? link2.repoRoot : void 0;
54701
+ const projectDir = repoRoot ? join18(repoRoot, linkedProject.rootDirectory || "") : client.cwd;
54702
+ const configPath = join18(projectDir, "microfrontends.json");
54703
+ if (!existsSync3(configPath)) {
53753
54704
  output_manager_default.log("");
53754
54705
  output_manager_default.log(
53755
54706
  `No changes to production traffic will take effect until a ${import_chalk193.default.bold("microfrontends.json")} is added to the default app. This configuration file specifies the path routing for the microfrontends group.`
@@ -53785,7 +54736,7 @@ async function createGroup(client) {
53785
54736
  routingPaths,
53786
54737
  productionAlias
53787
54738
  );
53788
- await writeFile6(configPath, config + "\n", "utf-8");
54739
+ await writeFile8(configPath, config + "\n", "utf-8");
53789
54740
  output_manager_default.success(`Created ${import_chalk193.default.bold("microfrontends.json")}`);
53790
54741
  output_manager_default.log(
53791
54742
  "Create a preview deployment to test microfrontends before deploying to production."
@@ -54293,8 +55244,8 @@ async function deleteGroup(client) {
54293
55244
  }
54294
55245
  selectedGroup = found;
54295
55246
  } else {
54296
- const link = await getLinkedProject(client, { cwd: client.cwd });
54297
- const linkedProject = link.status === "linked" ? link.project : void 0;
55247
+ const link2 = await getLinkedProject(client, { cwd: client.cwd });
55248
+ const linkedProject = link2.status === "linked" ? link2.project : void 0;
54298
55249
  const linkedGroup = linkedProject ? groups.find(
54299
55250
  (g) => g.projects.some(
54300
55251
  (p) => p.id === linkedProject.id && p.microfrontends?.isDefaultApp
@@ -54396,8 +55347,8 @@ async function deleteGroup(client) {
54396
55347
  }
54397
55348
 
54398
55349
  // src/commands/microfrontends/inspect-group.ts
54399
- import { existsSync as existsSync5 } from "fs";
54400
- import { join as join13 } from "path";
55350
+ import { existsSync as existsSync4 } from "fs";
55351
+ import { join as join19 } from "path";
54401
55352
  var import_chalk197 = __toESM(require_source(), 1);
54402
55353
  async function inspectGroup(client) {
54403
55354
  let parsedArgs;
@@ -54626,8 +55577,8 @@ async function enrichGroupProject(client, teamId, group, groupProject, localRepo
54626
55577
  }
54627
55578
  async function getLocalRepoContext(client) {
54628
55579
  try {
54629
- const link = await getLinkedProject(client, { cwd: client.cwd });
54630
- if (link.status !== "linked") {
55580
+ const link2 = await getLinkedProject(client, { cwd: client.cwd });
55581
+ if (link2.status !== "linked") {
54631
55582
  return {
54632
55583
  repoRoot: null,
54633
55584
  linkedProjectId: null,
@@ -54636,10 +55587,10 @@ async function getLocalRepoContext(client) {
54636
55587
  };
54637
55588
  }
54638
55589
  return {
54639
- repoRoot: link.repoRoot ?? null,
54640
- linkedProjectId: link.project.id,
54641
- linkedRepoOrg: link.project.link?.org ?? null,
54642
- linkedRepoName: link.project.link?.repo ?? null
55590
+ repoRoot: link2.repoRoot ?? null,
55591
+ linkedProjectId: link2.project.id,
55592
+ linkedRepoOrg: link2.project.link?.org ?? null,
55593
+ linkedRepoName: link2.project.link?.repo ?? null
54643
55594
  };
54644
55595
  } catch {
54645
55596
  return {
@@ -54663,8 +55614,8 @@ async function resolvePackageNameFromLocalRepo(localRepoContext, gitOrg, gitRepo
54663
55614
  if (!isProjectInLocalRepo(localRepoContext, gitOrg, gitRepo)) {
54664
55615
  return null;
54665
55616
  }
54666
- const projectDir = join13(localRepoContext.repoRoot, rootDirectory || "");
54667
- const packageJsonPath = join13(projectDir, "package.json");
55617
+ const projectDir = join19(localRepoContext.repoRoot, rootDirectory || "");
55618
+ const packageJsonPath = join19(projectDir, "package.json");
54668
55619
  const pkg = await readJSONFile(packageJsonPath);
54669
55620
  if (!pkg || pkg instanceof Error) {
54670
55621
  return null;
@@ -54683,23 +55634,23 @@ function resolveLocalConfigFilePath(projects2, localRepoContext, configuredConfi
54683
55634
  )) {
54684
55635
  return null;
54685
55636
  }
54686
- const projectDir = join13(
55637
+ const projectDir = join19(
54687
55638
  localRepoContext.repoRoot,
54688
55639
  defaultProject.git.rootDirectory || ""
54689
55640
  );
54690
55641
  const configuredName = configuredConfigFileName ?? null;
54691
55642
  if (configuredName) {
54692
- const configuredPath = join13(projectDir, configuredName);
54693
- if (existsSync5(configuredPath)) {
55643
+ const configuredPath = join19(projectDir, configuredName);
55644
+ if (existsSync4(configuredPath)) {
54694
55645
  return configuredPath;
54695
55646
  }
54696
55647
  }
54697
- const jsonPath = join13(projectDir, "microfrontends.json");
54698
- const jsoncPath = join13(projectDir, "microfrontends.jsonc");
54699
- if (existsSync5(jsonPath)) {
55648
+ const jsonPath = join19(projectDir, "microfrontends.json");
55649
+ const jsoncPath = join19(projectDir, "microfrontends.jsonc");
55650
+ if (existsSync4(jsonPath)) {
54700
55651
  return jsonPath;
54701
55652
  }
54702
- if (existsSync5(jsoncPath)) {
55653
+ if (existsSync4(jsoncPath)) {
54703
55654
  return jsoncPath;
54704
55655
  }
54705
55656
  return null;
@@ -54894,20 +55845,20 @@ async function openCommandHandler(client) {
54894
55845
  return 0;
54895
55846
  }
54896
55847
  const autoConfirm = !!parsedArgs.flags["--yes"];
54897
- const link = await ensureLink("open", client, client.cwd, {
55848
+ const link2 = await ensureLink("open", client, client.cwd, {
54898
55849
  autoConfirm
54899
55850
  });
54900
- if (typeof link === "number") {
54901
- return link;
55851
+ if (typeof link2 === "number") {
55852
+ return link2;
54902
55853
  }
54903
- if (link.status !== "linked" || !link.org || !link.project) {
55854
+ if (link2.status !== "linked" || !link2.org || !link2.project) {
54904
55855
  if (!client.nonInteractive) {
54905
55856
  output_manager_default.error("This command requires a linked project. Please run:");
54906
55857
  output_manager_default.print(" vercel link\n");
54907
55858
  }
54908
55859
  return 1;
54909
55860
  }
54910
- const { org, project } = link;
55861
+ const { org, project } = link2;
54911
55862
  const projectUrl = `https://vercel.com/${org.slug}/${project.name}`;
54912
55863
  output_manager_default.log(`Opening ${projectUrl} in your browser...`);
54913
55864
  await (0, import_open15.default)(projectUrl);
@@ -56478,6 +57429,7 @@ async function update4(client, argv) {
56478
57429
  flags["--auto-detect"]
56479
57430
  );
56480
57431
  telemetry2.trackCliOptionFormat(flags["--format"]);
57432
+ telemetry2.trackCliFlagJson(flags["--json"]);
56481
57433
  if (args.length > 1) {
56482
57434
  return printUsageError(
56483
57435
  client,
@@ -58529,14 +59481,14 @@ async function list17(client, argv) {
58529
59481
  const parsed = await parseSubcommandArgs3(argv, listSubcommand16);
58530
59482
  if (typeof parsed === "number")
58531
59483
  return parsed;
58532
- const link = await requireProjectContext(
59484
+ const link2 = await requireProjectContext(
58533
59485
  client,
58534
59486
  "redirects",
58535
59487
  parsed.flags["--project"]
58536
59488
  );
58537
- if (typeof link === "number")
58538
- return link;
58539
- const { project, org } = link;
59489
+ if (typeof link2 === "number")
59490
+ return link2;
59491
+ const { project, org } = link2;
58540
59492
  const { flags } = parsed;
58541
59493
  const teamId = org.type === "team" ? org.id : void 0;
58542
59494
  const search2 = flags["--search"];
@@ -58700,14 +59652,14 @@ async function listVersions2(client, argv) {
58700
59652
  const parsed = await parseSubcommandArgs3(argv, listVersionsSubcommand);
58701
59653
  if (typeof parsed === "number")
58702
59654
  return parsed;
58703
- const link = await requireProjectContext(
59655
+ const link2 = await requireProjectContext(
58704
59656
  client,
58705
59657
  "redirects",
58706
59658
  parsed.flags["--project"]
58707
59659
  );
58708
- if (typeof link === "number")
58709
- return link;
58710
- const { project, org } = link;
59660
+ if (typeof link2 === "number")
59661
+ return link2;
59662
+ const { project, org } = link2;
58711
59663
  const teamId = org.type === "team" ? org.id : void 0;
58712
59664
  const lsStamp = stamp_default();
58713
59665
  output_manager_default.spinner(`Fetching redirect versions for ${import_chalk216.default.bold(project.name)}`);
@@ -58817,14 +59769,14 @@ async function add10(client, argv) {
58817
59769
  const parsed = await parseSubcommandArgs3(argv, addSubcommand8);
58818
59770
  if (typeof parsed === "number")
58819
59771
  return parsed;
58820
- const link = await requireProjectContext(
59772
+ const link2 = await requireProjectContext(
58821
59773
  client,
58822
59774
  "redirects",
58823
59775
  parsed.flags["--project"]
58824
59776
  );
58825
- if (typeof link === "number")
58826
- return link;
58827
- const { project, org } = link;
59777
+ if (typeof link2 === "number")
59778
+ return link2;
59779
+ const { project, org } = link2;
58828
59780
  const teamId = org.type === "team" ? org.id : void 0;
58829
59781
  const { versions: versions2 } = await getRedirectVersions(client, project.id, teamId);
58830
59782
  const existingStagingVersion = versions2.find((v) => v.isStaging);
@@ -59115,7 +60067,7 @@ async function add10(client, argv) {
59115
60067
  // src/commands/redirects/upload.ts
59116
60068
  var import_chalk218 = __toESM(require_source(), 1);
59117
60069
  import { readFileSync as readFileSync4 } from "fs";
59118
- import { basename as basename2 } from "path";
60070
+ import { basename as basename3 } from "path";
59119
60071
 
59120
60072
  // src/commands/redirects/validate-redirects.ts
59121
60073
  import { statSync as statSync2 } from "fs";
@@ -59248,14 +60200,14 @@ async function upload(client, argv) {
59248
60200
  const parsed = await parseSubcommandArgs3(argv, uploadSubcommand);
59249
60201
  if (typeof parsed === "number")
59250
60202
  return parsed;
59251
- const link = await requireProjectContext(
60203
+ const link2 = await requireProjectContext(
59252
60204
  client,
59253
60205
  "redirects",
59254
60206
  parsed.flags["--project"]
59255
60207
  );
59256
- if (typeof link === "number")
59257
- return link;
59258
- const { project, org } = link;
60208
+ if (typeof link2 === "number")
60209
+ return link2;
60210
+ const { project, org } = link2;
59259
60211
  const teamId = org.type === "team" ? org.id : void 0;
59260
60212
  const { args, flags } = parsed;
59261
60213
  const skipPrompts = flags["--yes"] || false;
@@ -59313,7 +60265,7 @@ async function upload(client, argv) {
59313
60265
  const { versions: versions2 } = await getRedirectVersions(client, project.id, teamId);
59314
60266
  const existingStagingVersion = versions2.find((v) => v.isStaging);
59315
60267
  if (!skipPrompts) {
59316
- const fileName = basename2(filePath);
60268
+ const fileName = basename3(filePath);
59317
60269
  const fileType = filePath.endsWith(".csv") ? "CSV" : "JSON";
59318
60270
  const message = overwrite ? `Upload ${fileType} file "${fileName}" and replace all existing redirects?` : `Upload ${fileType} file "${fileName}"?`;
59319
60271
  const confirmed = await client.input.confirm(message, true);
@@ -59352,7 +60304,7 @@ async function upload(client, argv) {
59352
60304
  const url = "/v1/bulk-redirects";
59353
60305
  if (filePath.endsWith(".csv")) {
59354
60306
  const csvContent = readFileSync4(filePath);
59355
- const fileName = basename2(filePath);
60307
+ const fileName = basename3(filePath);
59356
60308
  const csvValidation = validateCSVStructure(csvContent.toString());
59357
60309
  if (!csvValidation.valid) {
59358
60310
  output_manager_default.error(`Invalid CSV: ${csvValidation.error}`);
@@ -59629,14 +60581,14 @@ async function remove10(client, argv) {
59629
60581
  output_manager_default.error(error);
59630
60582
  return 1;
59631
60583
  }
59632
- const link = await requireProjectContext(
60584
+ const link2 = await requireProjectContext(
59633
60585
  client,
59634
60586
  "redirects",
59635
60587
  parsed.flags["--project"]
59636
60588
  );
59637
- if (typeof link === "number")
59638
- return link;
59639
- const { project, org } = link;
60589
+ if (typeof link2 === "number")
60590
+ return link2;
60591
+ const { project, org } = link2;
59640
60592
  const teamId = org.type === "team" ? org.id : void 0;
59641
60593
  const { versions: versions2 } = await getRedirectVersions(client, project.id, teamId);
59642
60594
  const existingStagingVersion = versions2.find((v) => v.isStaging);
@@ -59836,14 +60788,14 @@ async function promote(client, argv) {
59836
60788
  output_manager_default.error(error);
59837
60789
  return 1;
59838
60790
  }
59839
- const link = await requireProjectContext(
60791
+ const link2 = await requireProjectContext(
59840
60792
  client,
59841
60793
  "redirects",
59842
60794
  parsed.flags["--project"]
59843
60795
  );
59844
- if (typeof link === "number")
59845
- return link;
59846
- const { project, org } = link;
60796
+ if (typeof link2 === "number")
60797
+ return link2;
60798
+ const { project, org } = link2;
59847
60799
  const teamId = org.type === "team" ? org.id : void 0;
59848
60800
  const [versionIdentifier] = parsed.args;
59849
60801
  output_manager_default.spinner(`Fetching redirect versions for ${import_chalk220.default.bold(project.name)}`);
@@ -60065,14 +61017,14 @@ async function restore(client, argv) {
60065
61017
  output_manager_default.error(error);
60066
61018
  return 1;
60067
61019
  }
60068
- const link = await requireProjectContext(
61020
+ const link2 = await requireProjectContext(
60069
61021
  client,
60070
61022
  "redirects",
60071
61023
  parsed.flags["--project"]
60072
61024
  );
60073
- if (typeof link === "number")
60074
- return link;
60075
- const { project, org } = link;
61025
+ if (typeof link2 === "number")
61026
+ return link2;
61027
+ const { project, org } = link2;
60076
61028
  const teamId = org.type === "team" ? org.id : void 0;
60077
61029
  const [versionIdentifier] = parsed.args;
60078
61030
  output_manager_default.spinner(`Fetching redirect versions for ${import_chalk221.default.bold(project.name)}`);
@@ -61649,14 +62601,14 @@ async function rollingRelease(client) {
61649
62601
  projectName = subcommandFlags.flags["--project"];
61650
62602
  telemetry2.trackCliOptionProject(projectName);
61651
62603
  }
61652
- const link = await resolveProjectContext({
62604
+ const link2 = await resolveProjectContext({
61653
62605
  client,
61654
62606
  projectNameOrId: projectName
61655
62607
  });
61656
- if (link.status === "error") {
61657
- return link.exitCode;
62608
+ if (link2.status === "error") {
62609
+ return link2.exitCode;
61658
62610
  }
61659
- if (link.status === "not_linked") {
62611
+ if (link2.status === "not_linked") {
61660
62612
  if (client.nonInteractive) {
61661
62613
  outputAgentError(
61662
62614
  client,
@@ -61674,7 +62626,7 @@ async function rollingRelease(client) {
61674
62626
  );
61675
62627
  return 1;
61676
62628
  }
61677
- const { project, org } = link;
62629
+ const { project, org } = link2;
61678
62630
  client.config.currentTeam = org.type === "team" ? org.id : void 0;
61679
62631
  if (!subcommandName || !subcommandFlags) {
61680
62632
  output_manager_default.debug(`Invalid subcommand: ${subcommand}`);
@@ -61891,14 +62843,14 @@ async function list18(client, argv) {
61891
62843
  const parsed = await parseSubcommandArgs(argv, listSubcommand17, client);
61892
62844
  if (typeof parsed === "number")
61893
62845
  return parsed;
61894
- const link = await requireProjectContext(
62846
+ const link2 = await requireProjectContext(
61895
62847
  client,
61896
62848
  "routes",
61897
62849
  parsed.flags["--project"]
61898
62850
  );
61899
- if (typeof link === "number")
61900
- return link;
61901
- const { project, org } = link;
62851
+ if (typeof link2 === "number")
62852
+ return link2;
62853
+ const { project, org } = link2;
61902
62854
  const { flags } = parsed;
61903
62855
  const teamId = org.type === "team" ? org.id : void 0;
61904
62856
  const search2 = flags["--search"];
@@ -62240,14 +63192,14 @@ async function listVersions3(client, argv) {
62240
63192
  );
62241
63193
  if (typeof parsed === "number")
62242
63194
  return parsed;
62243
- const link = await requireProjectContext(
63195
+ const link2 = await requireProjectContext(
62244
63196
  client,
62245
63197
  "routes",
62246
63198
  parsed.flags["--project"]
62247
63199
  );
62248
- if (typeof link === "number")
62249
- return link;
62250
- const { project, org } = link;
63200
+ if (typeof link2 === "number")
63201
+ return link2;
63202
+ const { project, org } = link2;
62251
63203
  const { flags } = parsed;
62252
63204
  const teamId = org.type === "team" ? org.id : void 0;
62253
63205
  const count2 = flags["--count"];
@@ -62326,14 +63278,14 @@ async function inspect9(client, argv) {
62326
63278
  const parsed = await parseSubcommandArgs(argv, inspectSubcommand9, client);
62327
63279
  if (typeof parsed === "number")
62328
63280
  return parsed;
62329
- const link = await requireProjectContext(
63281
+ const link2 = await requireProjectContext(
62330
63282
  client,
62331
63283
  "routes",
62332
63284
  parsed.flags["--project"]
62333
63285
  );
62334
- if (typeof link === "number")
62335
- return link;
62336
- const { project, org } = link;
63286
+ if (typeof link2 === "number")
63287
+ return link2;
63288
+ const { project, org } = link2;
62337
63289
  const { flags, args } = parsed;
62338
63290
  const teamId = org.type === "team" ? org.id : void 0;
62339
63291
  const showDiff = flags["--diff"];
@@ -62869,14 +63821,14 @@ async function add11(client, argv) {
62869
63821
  const parsed = await parseSubcommandArgs(argv, addSubcommand9, client);
62870
63822
  if (typeof parsed === "number")
62871
63823
  return parsed;
62872
- const link = await requireProjectContext(
63824
+ const link2 = await requireProjectContext(
62873
63825
  client,
62874
63826
  "routes",
62875
63827
  parsed.flags["--project"]
62876
63828
  );
62877
- if (typeof link === "number")
62878
- return link;
62879
- const { project, org } = link;
63829
+ if (typeof link2 === "number")
63830
+ return link2;
63831
+ const { project, org } = link2;
62880
63832
  const teamId = org.type === "team" ? org.id : void 0;
62881
63833
  const { args, flags } = parsed;
62882
63834
  const isAgentMode = client.nonInteractive;
@@ -63927,7 +64879,7 @@ async function main26(client) {
63927
64879
  return 2;
63928
64880
  }
63929
64881
  telemetry2.trackCliSubcommandEdit(subcommandOriginal);
63930
- return (await import("./chunks/edit-55TQT6RK.js")).default(client, args);
64882
+ return (await import("./chunks/edit-VNVPLLF7.js")).default(client, args);
63931
64883
  case "delete":
63932
64884
  if (needHelp) {
63933
64885
  telemetry2.trackCliFlagHelp("routes", subcommandOriginal);
@@ -63935,7 +64887,7 @@ async function main26(client) {
63935
64887
  return 2;
63936
64888
  }
63937
64889
  telemetry2.trackCliSubcommandDelete(subcommandOriginal);
63938
- return (await import("./chunks/delete-EQ5NJWPR.js")).default(client, args);
64890
+ return (await import("./chunks/delete-ZWUWQT5H.js")).default(client, args);
63939
64891
  case "enable":
63940
64892
  if (needHelp) {
63941
64893
  telemetry2.trackCliFlagHelp("routes", subcommandOriginal);
@@ -63943,7 +64895,7 @@ async function main26(client) {
63943
64895
  return 2;
63944
64896
  }
63945
64897
  telemetry2.trackCliSubcommandEnable(subcommandOriginal);
63946
- return (await import("./chunks/enable-UOEAVAUU.js")).default(client, args);
64898
+ return (await import("./chunks/enable-L7ERJOO5.js")).default(client, args);
63947
64899
  case "disable":
63948
64900
  if (needHelp) {
63949
64901
  telemetry2.trackCliFlagHelp("routes", subcommandOriginal);
@@ -63951,7 +64903,7 @@ async function main26(client) {
63951
64903
  return 2;
63952
64904
  }
63953
64905
  telemetry2.trackCliSubcommandDisable(subcommandOriginal);
63954
- return (await import("./chunks/disable-KO6WDHRC.js")).default(client, args);
64906
+ return (await import("./chunks/disable-CJKTITTQ.js")).default(client, args);
63955
64907
  case "reorder":
63956
64908
  if (needHelp) {
63957
64909
  telemetry2.trackCliFlagHelp("routes", subcommandOriginal);
@@ -63959,7 +64911,7 @@ async function main26(client) {
63959
64911
  return 2;
63960
64912
  }
63961
64913
  telemetry2.trackCliSubcommandReorder(subcommandOriginal);
63962
- return (await import("./chunks/reorder-GA5FVDKD.js")).default(client, args);
64914
+ return (await import("./chunks/reorder-42YNZL7R.js")).default(client, args);
63963
64915
  case "export":
63964
64916
  if (needHelp) {
63965
64917
  telemetry2.trackCliFlagHelp("routes", subcommandOriginal);
@@ -63967,7 +64919,7 @@ async function main26(client) {
63967
64919
  return 2;
63968
64920
  }
63969
64921
  telemetry2.trackCliSubcommandExport(subcommandOriginal);
63970
- return (await import("./chunks/export-X2XFUNPV.js")).default(client, args);
64922
+ return (await import("./chunks/export-BDAKZGOD.js")).default(client, args);
63971
64923
  case "publish":
63972
64924
  if (needHelp) {
63973
64925
  telemetry2.trackCliFlagHelp("routes", subcommandOriginal);
@@ -63975,7 +64927,7 @@ async function main26(client) {
63975
64927
  return 2;
63976
64928
  }
63977
64929
  telemetry2.trackCliSubcommandPublish(subcommandOriginal);
63978
- return (await import("./chunks/publish-7BIMCBQ6.js")).default(client, args);
64930
+ return (await import("./chunks/publish-7FXAFWWN.js")).default(client, args);
63979
64931
  case "restore":
63980
64932
  if (needHelp) {
63981
64933
  telemetry2.trackCliFlagHelp("routes", subcommandOriginal);
@@ -63983,7 +64935,7 @@ async function main26(client) {
63983
64935
  return 2;
63984
64936
  }
63985
64937
  telemetry2.trackCliSubcommandRestore(subcommandOriginal);
63986
- return (await import("./chunks/restore-WGSD5LXC.js")).default(client, args);
64938
+ return (await import("./chunks/restore-RCNRC3YJ.js")).default(client, args);
63987
64939
  case "discard-staging":
63988
64940
  if (needHelp) {
63989
64941
  telemetry2.trackCliFlagHelp("routes", subcommandOriginal);
@@ -63991,7 +64943,7 @@ async function main26(client) {
63991
64943
  return 2;
63992
64944
  }
63993
64945
  telemetry2.trackCliSubcommandDiscardStaging(subcommandOriginal);
63994
- return (await import("./chunks/discard-E7PLPNUL.js")).default(client, args);
64946
+ return (await import("./chunks/discard-ABXIPZHK.js")).default(client, args);
63995
64947
  default:
63996
64948
  output_manager_default.error(getInvalidSubcommand(COMMAND_CONFIG45));
63997
64949
  output_manager_default.print(help(routesCommand, { columns: client.stderr.columns }));
@@ -64065,8 +65017,8 @@ async function sandbox(client) {
64065
65017
  var import_chalk229 = __toESM(require_source(), 1);
64066
65018
  var import_frameworks3 = __toESM(require_frameworks(), 1);
64067
65019
  var import_fs_detectors = __toESM(require_dist3(), 1);
64068
- import { access as access3, readFile as readFile8 } from "fs/promises";
64069
- import { join as join14 } from "path";
65020
+ import { access as access3, readFile as readFile9 } from "fs/promises";
65021
+ import { join as join20 } from "path";
64070
65022
  import { homedir as homedir2 } from "os";
64071
65023
  import { spawn as spawn4 } from "child_process";
64072
65024
 
@@ -64158,8 +65110,8 @@ async function searchSkills(query) {
64158
65110
  }
64159
65111
  async function detectProjectFramework(cwd) {
64160
65112
  try {
64161
- const fs2 = new import_fs_detectors.LocalFileSystemDetector(cwd);
64162
- const detected = await (0, import_fs_detectors.detectFrameworks)({ fs: fs2, frameworkList: import_frameworks3.frameworkList });
65113
+ const fs4 = new import_fs_detectors.LocalFileSystemDetector(cwd);
65114
+ const detected = await (0, import_fs_detectors.detectFrameworks)({ fs: fs4, frameworkList: import_frameworks3.frameworkList });
64163
65115
  if (detected.length > 0) {
64164
65116
  return { name: detected[0].name, slug: detected[0].slug || "" };
64165
65117
  }
@@ -64169,7 +65121,7 @@ async function detectProjectFramework(cwd) {
64169
65121
  }
64170
65122
  async function readPackageDeps(cwd) {
64171
65123
  try {
64172
- const raw = await readFile8(join14(cwd, "package.json"), "utf8");
65124
+ const raw = await readFile9(join20(cwd, "package.json"), "utf8");
64173
65125
  const pkg = JSON.parse(raw);
64174
65126
  const allDeps = {
64175
65127
  ...pkg.dependencies,
@@ -64189,8 +65141,8 @@ function cleanDepName(dep) {
64189
65141
  async function isSkillInstalled(name, cwd) {
64190
65142
  const sanitized = name.toLowerCase().replace(/\s+/g, "-");
64191
65143
  const dirs = [
64192
- join14(cwd, ".agents", "skills", sanitized),
64193
- join14(homedir2(), ".agents", "skills", sanitized)
65144
+ join20(cwd, ".agents", "skills", sanitized),
65145
+ join20(homedir2(), ".agents", "skills", sanitized)
64194
65146
  ];
64195
65147
  for (const dir of dirs) {
64196
65148
  try {
@@ -64523,23 +65475,23 @@ async function list19(client, argv) {
64523
65475
  const projectName = parsedArgs.flags["--project"];
64524
65476
  telemetry2.trackCliOptionProject(projectName);
64525
65477
  const autoConfirm = !!parsedArgs.flags["--yes"];
64526
- const link = await ensureLink(targetCommand.name, client, cwd, {
65478
+ const link2 = await ensureLink(targetCommand.name, client, cwd, {
64527
65479
  autoConfirm,
64528
65480
  projectName,
64529
65481
  failIfNotFound: Boolean(projectName)
64530
65482
  });
64531
- if (typeof link === "number") {
64532
- return link;
65483
+ if (typeof link2 === "number") {
65484
+ return link2;
64533
65485
  }
64534
65486
  const start = Date.now();
64535
- const projectSlugLink = formatProject(link.org.slug, link.project.name);
65487
+ const projectSlugLink = formatProject(link2.org.slug, link2.project.name);
64536
65488
  output_manager_default.spinner(`Fetching custom environments for ${projectSlugLink}`);
64537
65489
  const url = `/projects/${encodeURIComponent(
64538
- link.project.id
65490
+ link2.project.id
64539
65491
  )}/custom-environments`;
64540
65492
  let { environments: result } = await client.fetch(url, {
64541
65493
  method: "GET",
64542
- accountId: link.org.id
65494
+ accountId: link2.org.id
64543
65495
  });
64544
65496
  output_manager_default.stopSpinner();
64545
65497
  const elapsed2 = (0, import_ms35.default)(Date.now() - start);
@@ -64570,8 +65522,8 @@ async function list19(client, argv) {
64570
65522
  ...result.flatMap((target) => {
64571
65523
  return [
64572
65524
  [
64573
- formatEnvironment(link.org.slug, link.project.name, target),
64574
- BRANCH_TRACKING_MAP[target.type](link.project, target),
65525
+ formatEnvironment(link2.org.slug, link2.project.name, target),
65526
+ BRANCH_TRACKING_MAP[target.type](link2.project, target),
64575
65527
  TYPE_MAP[target.type],
64576
65528
  import_chalk230.default.gray(
64577
65529
  target.updatedAt > 0 ? (0, import_ms35.default)(Date.now() - target.updatedAt) : "-"
@@ -65514,15 +66466,15 @@ var updateCurrentTeam = (config, team) => {
65514
66466
  writeToConfigFile(config);
65515
66467
  };
65516
66468
  async function warnIfStaleLinkExists(client, newOrgId) {
65517
- let link = null;
66469
+ let link2 = null;
65518
66470
  try {
65519
- link = await getLinkFromDir(
66471
+ link2 = await getLinkFromDir(
65520
66472
  getVercelDirectory(client.cwd)
65521
66473
  );
65522
66474
  } catch (_error) {
65523
- link = null;
66475
+ link2 = null;
65524
66476
  }
65525
- if (!link || link.orgId === newOrgId) {
66477
+ if (!link2 || link2.orgId === newOrgId) {
65526
66478
  return;
65527
66479
  }
65528
66480
  output_manager_default.warn(
@@ -66883,8 +67835,8 @@ var TracesTelemetryClient = class extends TelemetryClient {
66883
67835
  });
66884
67836
  }
66885
67837
  }
66886
- trackCliFlagOpen(open15) {
66887
- if (open15) {
67838
+ trackCliFlagOpen(open16) {
67839
+ if (open16) {
66888
67840
  this.trackCliFlag("open");
66889
67841
  }
66890
67842
  }
@@ -68219,6 +69171,7 @@ async function usage(client) {
68219
69171
  telemetry2.trackCliOptionFrom(fromFlag);
68220
69172
  telemetry2.trackCliOptionTo(toFlag);
68221
69173
  telemetry2.trackCliOptionFormat(parsedArgs.flags["--format"]);
69174
+ telemetry2.trackCliFlagJson(parsedArgs.flags["--json"]);
68222
69175
  telemetry2.trackCliOptionBreakdown(breakdownFlag);
68223
69176
  telemetry2.trackCliOptionGroupBy(groupByFlag);
68224
69177
  if (fromFlag) {
@@ -68732,37 +69685,37 @@ async function vcr(client) {
68732
69685
  switch (subcommand) {
68733
69686
  case "ls":
68734
69687
  telemetry2.trackCliSubcommandLs(subcommandOriginal);
68735
- return (await import("./chunks/ls-ESCK2JMH.js")).default(client, args, telemetry2);
69688
+ return (await import("./chunks/ls-ZG43UJTR.js")).default(client, args, telemetry2);
68736
69689
  case "inspect":
68737
69690
  telemetry2.trackCliSubcommandInspect(subcommandOriginal);
68738
- return (await import("./chunks/inspect-W4AH3EKN.js")).default(client, args, telemetry2);
69691
+ return (await import("./chunks/inspect-E6IHZHQI.js")).default(client, args, telemetry2);
68739
69692
  case "add":
68740
69693
  telemetry2.trackCliSubcommandAdd(subcommandOriginal);
68741
- return (await import("./chunks/add-RVZD257F.js")).default(client, args, telemetry2);
69694
+ return (await import("./chunks/add-5NFS6DS7.js")).default(client, args, telemetry2);
68742
69695
  case "config":
68743
69696
  telemetry2.trackCliSubcommandConfig(subcommandOriginal);
68744
- return (await import("./chunks/config-V42N5SNP.js")).default(client, args, telemetry2);
69697
+ return (await import("./chunks/config-5D4R6677.js")).default(client, args, telemetry2);
68745
69698
  case "rm":
68746
69699
  telemetry2.trackCliSubcommandRm(subcommandOriginal);
68747
- return (await import("./chunks/rm-PXBJERO4.js")).default(client, args, telemetry2);
69700
+ return (await import("./chunks/rm-ODFQSS2C.js")).default(client, args, telemetry2);
68748
69701
  case "login":
68749
69702
  telemetry2.trackCliSubcommandLogin(subcommandOriginal);
68750
- return (await import("./chunks/login-QA4765QP.js")).default(client, args, telemetry2);
69703
+ return (await import("./chunks/login-AVIFCN4G.js")).default(client, args, telemetry2);
68751
69704
  case "build":
68752
69705
  telemetry2.trackCliSubcommandBuild(subcommandOriginal);
68753
- return (await import("./chunks/build-KAOW7IJ6.js")).default(client, telemetry2);
69706
+ return (await import("./chunks/build-MF4TD2RD.js")).default(client, telemetry2);
68754
69707
  case "push":
68755
69708
  telemetry2.trackCliSubcommandPush(subcommandOriginal);
68756
- return (await import("./chunks/push-IKPIV52M.js")).default(client, telemetry2);
69709
+ return (await import("./chunks/push-3P3NKZEG.js")).default(client, telemetry2);
68757
69710
  case "tag":
68758
69711
  telemetry2.trackCliSubcommandTag(subcommandOriginal);
68759
- return (await import("./chunks/tags-XEZOWSS3.js")).default(client, args, telemetry2);
69712
+ return (await import("./chunks/tags-WZBKHB6D.js")).default(client, args, telemetry2);
68760
69713
  case "image":
68761
69714
  telemetry2.trackCliSubcommandImage(subcommandOriginal);
68762
- return (await import("./chunks/image-JAAMXTIA.js")).default(client, args, telemetry2);
69715
+ return (await import("./chunks/image-MGZR4VEH.js")).default(client, args, telemetry2);
68763
69716
  case "permissions":
68764
69717
  telemetry2.trackCliSubcommandPermissions(subcommandOriginal);
68765
- return (await import("./chunks/permissions-L7NPGX2M.js")).default(client, args, telemetry2);
69718
+ return (await import("./chunks/permissions-BDINZ7RC.js")).default(client, args, telemetry2);
68766
69719
  default:
68767
69720
  output_manager_default.error(getInvalidSubcommand(COMMAND_CONFIG51));
68768
69721
  output_manager_default.print(help(vcrCommand, { columns: client.stderr.columns }));
@@ -69734,17 +70687,22 @@ async function whoami(client) {
69734
70687
  const asJson = formatResult.jsonOutput;
69735
70688
  telemetry2.trackCliOptionFormat(parsedArgs.flags["--format"]);
69736
70689
  const scope = await getScope(client, { resolveLocalScope: true });
69737
- const { user, team, globalTeam } = scope;
70690
+ const { user, team, app, globalTeam } = scope;
69738
70691
  const hasLocalOverride = !scope.explicitScopeProvided && ((team?.id ?? null) !== (globalTeam?.id ?? null) || // `team` being null while a local project linked to personal scope
69739
70692
  // exists while a global team is selected is also a mismatch.
69740
70693
  scope.scopeMismatch);
69741
70694
  if (asJson) {
69742
70695
  const jsonOutput = {
69743
- username: user.username,
69744
- email: user.email,
69745
- name: user.name,
69746
70696
  team: team ? { id: team.id, slug: team.slug, name: team.name } : null
69747
70697
  };
70698
+ if (user) {
70699
+ jsonOutput.username = user.username;
70700
+ jsonOutput.email = user.email;
70701
+ jsonOutput.name = user.name;
70702
+ }
70703
+ if (app) {
70704
+ jsonOutput.app = app;
70705
+ }
69748
70706
  if (hasLocalOverride) {
69749
70707
  jsonOutput.localOverride = true;
69750
70708
  jsonOutput.globalTeam = globalTeam ? { id: globalTeam.id, slug: globalTeam.slug, name: globalTeam.name } : null;
@@ -69752,7 +70710,7 @@ async function whoami(client) {
69752
70710
  client.stdout.write(`${JSON.stringify(jsonOutput, null, 2)}
69753
70711
  `);
69754
70712
  } else if (client.stdout.isTTY) {
69755
- output_manager_default.log(`Logged in as ${import_chalk248.default.bold(user.username)}`);
70713
+ output_manager_default.log(`Logged in as ${import_chalk248.default.bold(formatUsername(scope))}`);
69756
70714
  if (team) {
69757
70715
  output_manager_default.log(
69758
70716
  `Active team: ${import_chalk248.default.bold(team.slug)}${team.name && team.name !== team.slug ? ` (${team.name})` : ""}`
@@ -69772,11 +70730,20 @@ async function whoami(client) {
69772
70730
  );
69773
70731
  }
69774
70732
  } else {
69775
- client.stdout.write(`${user.username}
70733
+ client.stdout.write(`${formatUsername(scope)}
69776
70734
  `);
69777
70735
  }
69778
70736
  return 0;
69779
70737
  }
70738
+ function formatUsername(scope) {
70739
+ if (scope.user) {
70740
+ return scope.user.username;
70741
+ }
70742
+ if (scope.app) {
70743
+ return scope.app.id;
70744
+ }
70745
+ throw new Error(`Could not format principal identity`);
70746
+ }
69780
70747
  export {
69781
70748
  activity,
69782
70749
  agent,