vercel 56.2.1 → 56.3.0

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 (86) hide show
  1. package/dist/chunks/{add-YIAPBLSF.js → add-CF5SQESQ.js} +10 -13
  2. package/dist/chunks/{add-ZAQLTF5W.js → add-DMRGZN3Z.js} +9 -12
  3. package/dist/chunks/{chunk-75PKWYOS.js → chunk-22G26AIX.js} +99 -74
  4. package/dist/chunks/{chunk-7OJJKCSW.js → chunk-2C2JJTAM.js} +6 -10
  5. package/dist/chunks/{chunk-DDEPCAGE.js → chunk-2MXGTALG.js} +529 -164
  6. package/dist/chunks/{chunk-5AJNUXWP.js → chunk-3PKFXNJZ.js} +2 -4
  7. package/dist/chunks/{chunk-5OT26JZN.js → chunk-3VS4DTAU.js} +4 -6
  8. package/dist/chunks/{chunk-JJWESW5Y.js → chunk-4G6QZSBL.js} +2 -4
  9. package/dist/chunks/{chunk-NULWLKT7.js → chunk-4YOCOUDN.js} +4 -4
  10. package/dist/chunks/{chunk-GXBDQRHJ.js → chunk-4Z5LC2CI.js} +1 -1
  11. package/dist/chunks/{chunk-CMJMYVQM.js → chunk-6OMC3HOW.js} +1 -1
  12. package/dist/chunks/{chunk-JF7LPEBD.js → chunk-A6LE5VAN.js} +1 -1
  13. package/dist/chunks/{chunk-QY63UKTP.js → chunk-DMSLNAVH.js} +2 -2
  14. package/dist/chunks/{chunk-52V5NDUN.js → chunk-DZHRFBKE.js} +2 -2
  15. package/dist/chunks/{chunk-MYD7N6MH.js → chunk-ERPZJ4SX.js} +13 -3
  16. package/dist/chunks/{chunk-YKJA5TVC.js → chunk-EYNXG3FO.js} +3 -5
  17. package/dist/chunks/{chunk-RLJA2KI7.js → chunk-FYQPTH5C.js} +2 -4
  18. package/dist/chunks/{chunk-7TJLLZPN.js → chunk-G4PG5HVE.js} +6 -10
  19. package/dist/chunks/{chunk-7C7MMT4J.js → chunk-GIL3VAUR.js} +2 -4
  20. package/dist/chunks/{chunk-GPVU6JRS.js → chunk-HUKYQKVQ.js} +9 -7
  21. package/dist/chunks/{chunk-EPBUWIAO.js → chunk-I2IICWBW.js} +48 -24
  22. package/dist/chunks/{chunk-KXVQEPTA.js → chunk-ICSIFPXG.js} +3 -5
  23. package/dist/chunks/{chunk-P6AK7SVK.js → chunk-KSSNLCL4.js} +360 -25
  24. package/dist/chunks/{chunk-HIO4M75R.js → chunk-KXKQQIUS.js} +6 -10
  25. package/dist/chunks/{chunk-HA7C7SDO.js → chunk-LHFNIZ2P.js} +2 -4
  26. package/dist/chunks/{chunk-2I34TRQZ.js → chunk-NP32PAKT.js} +2 -2
  27. package/dist/chunks/{chunk-QEEGXNFK.js → chunk-NZRWTCRM.js} +1 -1
  28. package/dist/chunks/{chunk-IDMKFYEA.js → chunk-OGG6UBXK.js} +2 -4
  29. package/dist/chunks/{chunk-PASZMRTZ.js → chunk-PRO4S2KV.js} +5 -5
  30. package/dist/chunks/{chunk-DD6D5J7E.js → chunk-Q5ADSH7D.js} +8 -12
  31. package/dist/chunks/{chunk-6ZVIC6FL.js → chunk-QP3C5YS5.js} +8 -8
  32. package/dist/chunks/{chunk-5HNYJHOB.js → chunk-SDK7R4WO.js} +1 -1
  33. package/dist/chunks/{chunk-22GUZ5KG.js → chunk-STJJ3DFO.js} +2 -4
  34. package/dist/chunks/{chunk-EHTPDXTS.js → chunk-SZXT3PDQ.js} +3 -294
  35. package/dist/chunks/{chunk-CB3I3QIT.js → chunk-UDWRZXIT.js} +193 -85
  36. package/dist/chunks/{chunk-DREO3DFB.js → chunk-VZSZBD4V.js} +16 -6
  37. package/dist/chunks/{chunk-VOBBH2SB.js → chunk-W346YNDN.js} +0 -49
  38. package/dist/chunks/{chunk-7S3QUMIG.js → chunk-YS6EDZHB.js} +3 -5
  39. package/dist/chunks/{chunk-UESEGACQ.js → chunk-ZDCS54ZZ.js} +3 -3
  40. package/dist/chunks/{chunk-4RGSUV5C.js → chunk-ZVLPUREX.js} +2 -2
  41. package/dist/chunks/{compile-vercel-config-4NKPN3EG.js → compile-vercel-config-RPPL7W56.js} +4 -4
  42. package/dist/chunks/{delete-NCMDC3IU.js → delete-QBVZ5X6B.js} +14 -14
  43. package/dist/chunks/{disable-Z7DXY4AY.js → disable-YYGXPXBI.js} +14 -13
  44. package/dist/chunks/{discard-4ILK3ULP.js → discard-X2MSUFGI.js} +13 -12
  45. package/dist/chunks/{edit-ROJQCTWR.js → edit-3ABZQYUU.js} +17 -18
  46. package/dist/chunks/{enable-TAVCLAEC.js → enable-HUMYCGKA.js} +14 -13
  47. package/dist/chunks/{export-YTSIGJFX.js → export-KGHH4WAT.js} +15 -14
  48. package/dist/chunks/{image-LORSHERP.js → image-OO3WWKZV.js} +6 -8
  49. package/dist/chunks/{inspect-5C4UHSCT.js → inspect-5TNHHD2M.js} +10 -12
  50. package/dist/chunks/{inspect-OHDU2SVS.js → inspect-FNUCB7Y3.js} +8 -10
  51. package/dist/chunks/{inspect-L4UIWOXO.js → inspect-KSSQEAW7.js} +11 -15
  52. package/dist/chunks/{inspect-A2X7RTP4.js → inspect-Z6SSD2SR.js} +8 -10
  53. package/dist/chunks/{list-FGVDMSFN.js → list-TXNYRVJG.js} +8 -10
  54. package/dist/chunks/{list-P2B5MHON.js → list-X2AD3HCX.js} +10 -13
  55. package/dist/chunks/{login-4BK3VGII.js → login-SLPCZ2OF.js} +11 -14
  56. package/dist/chunks/{ls-YXKRRYTL.js → ls-2YSINRJ3.js} +10 -13
  57. package/dist/chunks/{ls-NU4D6TLG.js → ls-4QMJLQQL.js} +10 -13
  58. package/dist/chunks/{ls-WDRFGE2J.js → ls-C7MNQ4IK.js} +12 -15
  59. package/dist/chunks/{ls-RAC5LMTR.js → ls-QLTOY23G.js} +9 -12
  60. package/dist/chunks/{publish-DGF2TQCQ.js → publish-GV4LLLXP.js} +13 -12
  61. package/dist/chunks/{query-NWW6RDHK.js → query-3AHRMAPA.js} +10 -12
  62. package/dist/chunks/{reorder-TTZBKCEB.js → reorder-VSVOPNM4.js} +17 -16
  63. package/dist/chunks/{restore-DG3LZMHQ.js → restore-FKYCF73P.js} +19 -18
  64. package/dist/chunks/{rm-7WXXLTXF.js → rm-4QCXZRC2.js} +10 -13
  65. package/dist/chunks/{rm-U2DFRDKE.js → rm-UTFG42FN.js} +8 -11
  66. package/dist/chunks/{rm-2VBE4C2V.js → rm-YV5WQKQM.js} +9 -12
  67. package/dist/chunks/{rule-inspect-4NL3GGDB.js → rule-inspect-IONN4MTP.js} +9 -12
  68. package/dist/chunks/{rules-DABNOUNG.js → rules-S2KPV7HY.js} +9 -11
  69. package/dist/chunks/{schema-4RRRUUOO.js → schema-3LX3V2HE.js} +11 -12
  70. package/dist/chunks/{tags-MLX3AHHK.js → tags-CQ4FRIJ4.js} +5 -7
  71. package/dist/chunks/{types-2TPA6J4G.js → types-QKLIFDDP.js} +5 -5
  72. package/dist/chunks/{update-YXH7WWTN.js → update-U7OGHCP5.js} +9 -12
  73. package/dist/commands/build/index.js +26 -31
  74. package/dist/commands/deploy/index.js +57 -75
  75. package/dist/commands/dev/index.js +193 -159
  76. package/dist/commands/env/index.js +70 -47
  77. package/dist/commands/link/index.js +25 -29
  78. package/dist/commands/list/index.js +13 -17
  79. package/dist/commands-bulk.js +637 -620
  80. package/dist/index.js +23 -25
  81. package/dist/version.mjs +1 -1
  82. package/package.json +20 -20
  83. package/dist/chunks/chunk-DWU7JOO6.js +0 -158
  84. package/dist/chunks/chunk-IC4YEIGW.js +0 -101
  85. package/dist/chunks/chunk-IMUF5MGV.js +0 -81
  86. package/dist/chunks/chunk-SGL3NMOP.js +0 -86
@@ -5,13 +5,11 @@ const require = __createRequire(import.meta.url);
5
5
  const __filename = __fileURLToPath(import.meta.url);
6
6
  const __dirname = __dirname_(__filename);
7
7
  import {
8
+ arg_common_default,
8
9
  getCommandName,
9
- getCommandNamePlain,
10
- normalizeFlagName,
11
10
  parseRetryAfterHeaderAsMillis,
12
- require_bytes,
13
- stripSensitiveAuthArgs
14
- } from "./chunk-P6AK7SVK.js";
11
+ require_bytes
12
+ } from "./chunk-KSSNLCL4.js";
15
13
  import {
16
14
  output_manager_default
17
15
  } from "./chunk-OX7KI3LF.js";
@@ -239,277 +237,6 @@ var require_string_width = __commonJS({
239
237
  }
240
238
  });
241
239
 
242
- // src/util/get-flags-specification.ts
243
- function getFlagsSpecification(options) {
244
- const flagsSpecification = {};
245
- for (const option of options) {
246
- flagsSpecification[`--${option.name}`] = option.type;
247
- if (option.shorthand) {
248
- flagsSpecification[`-${option.shorthand}`] = `--${option.name}`;
249
- }
250
- }
251
- return flagsSpecification;
252
- }
253
-
254
- // src/util/arg-common.ts
255
- var globalCommandOptions = [
256
- {
257
- name: "help",
258
- shorthand: "h",
259
- type: Boolean,
260
- description: "Output usage information",
261
- deprecated: false
262
- },
263
- {
264
- name: "version",
265
- shorthand: "v",
266
- type: Boolean,
267
- description: "Output the version number",
268
- deprecated: false
269
- },
270
- {
271
- name: "cwd",
272
- shorthand: null,
273
- type: String,
274
- argument: "DIR",
275
- description: "Sets the current working directory for a single run of a command",
276
- deprecated: false
277
- },
278
- {
279
- name: "local-config",
280
- shorthand: "A",
281
- type: String,
282
- argument: "FILE",
283
- description: "Path to the local `vercel.json` file",
284
- deprecated: false
285
- },
286
- {
287
- name: "global-config",
288
- shorthand: "Q",
289
- type: String,
290
- argument: "DIR",
291
- description: "Path to the global `.vercel` directory",
292
- deprecated: false
293
- },
294
- {
295
- name: "debug",
296
- shorthand: "d",
297
- type: Boolean,
298
- description: "Debug mode (default off)",
299
- deprecated: false
300
- },
301
- {
302
- name: "no-color",
303
- shorthand: null,
304
- type: Boolean,
305
- description: "No color mode (default off)",
306
- deprecated: false
307
- },
308
- {
309
- name: "non-interactive",
310
- shorthand: null,
311
- type: Boolean,
312
- description: "Run without interactive prompts; when an agent is detected this is the default",
313
- deprecated: false
314
- },
315
- {
316
- name: "scope",
317
- shorthand: "S",
318
- type: String,
319
- description: "Set a custom scope",
320
- deprecated: false
321
- },
322
- {
323
- name: "token",
324
- shorthand: "t",
325
- type: String,
326
- argument: "TOKEN",
327
- description: "Login token",
328
- deprecated: false
329
- },
330
- { name: "team", shorthand: "T", type: String, deprecated: false },
331
- { name: "api", shorthand: null, type: String, deprecated: false }
332
- ];
333
- var GLOBAL_CLI_FLAG_NAMES = (() => {
334
- const set = /* @__PURE__ */ new Set();
335
- for (const opt of globalCommandOptions) {
336
- set.add(`--${opt.name}`);
337
- if (opt.shorthand) {
338
- set.add(`-${opt.shorthand}`);
339
- }
340
- }
341
- return set;
342
- })();
343
- function globalCliFlagTakesValue(flagName) {
344
- const normalized = normalizeFlagName(flagName);
345
- for (const opt of globalCommandOptions) {
346
- if (`--${opt.name}` === normalized) {
347
- return opt.type === String;
348
- }
349
- if (opt.shorthand && `-${opt.shorthand}` === normalized) {
350
- return opt.type === String;
351
- }
352
- }
353
- return false;
354
- }
355
- var SUBCOMMAND_FLAG_TAKES_VALUE = /* @__PURE__ */ new Set([
356
- "--status",
357
- "--name",
358
- "--slug",
359
- "--version",
360
- // redirects list --version
361
- "--search",
362
- "--format",
363
- "--project",
364
- "--page",
365
- "--per-page"
366
- ]);
367
- function suggestionFlagTakesSeparateValue(flagName) {
368
- const name = normalizeFlagName(flagName);
369
- if (globalCliFlagTakesValue(name))
370
- return true;
371
- return SUBCOMMAND_FLAG_TAKES_VALUE.has(name);
372
- }
373
- function getSameSubcommandSuggestionFlags(args) {
374
- const safeArgs = stripSensitiveAuthArgs(args);
375
- const out = [];
376
- for (let i = 0; i < safeArgs.length; i++) {
377
- const a = safeArgs[i];
378
- if (!a.startsWith("-"))
379
- continue;
380
- out.push(a);
381
- if (a.includes("="))
382
- continue;
383
- const name = a;
384
- if (suggestionFlagTakesSeparateValue(name) && i + 1 < safeArgs.length && !safeArgs[i + 1].startsWith("-")) {
385
- out.push(safeArgs[++i]);
386
- }
387
- }
388
- return out;
389
- }
390
- var GLOBAL_OPTIONS = getFlagsSpecification(globalCommandOptions);
391
- var arg_common_default = () => GLOBAL_OPTIONS;
392
- var yesOption = {
393
- name: "yes",
394
- shorthand: "y",
395
- type: Boolean,
396
- deprecated: false,
397
- description: "Accept default value for all prompts"
398
- };
399
- var nextOption = {
400
- name: "next",
401
- shorthand: "N",
402
- type: Number,
403
- deprecated: false,
404
- description: "Show next page of results",
405
- argument: "MS"
406
- };
407
- var confirmOption = {
408
- name: "confirm",
409
- shorthand: "c",
410
- type: Boolean,
411
- deprecated: true
412
- };
413
- var limitOption = {
414
- name: "limit",
415
- shorthand: null,
416
- type: Number,
417
- deprecated: false,
418
- description: "Number of results to return per page (default: 20, max: 100)",
419
- argument: "NUMBER"
420
- };
421
- var forceOption = {
422
- name: "force",
423
- shorthand: "f",
424
- type: Boolean,
425
- deprecated: false
426
- };
427
- var formatOption = {
428
- name: "format",
429
- shorthand: "F",
430
- type: String,
431
- argument: "FORMAT",
432
- description: "Specify the output format (json)",
433
- deprecated: false
434
- };
435
- var jsonOption = {
436
- name: "json",
437
- shorthand: null,
438
- type: Boolean,
439
- deprecated: true,
440
- description: "DEPRECATED: Use --format=json instead"
441
- };
442
- var allOption = {
443
- name: "all",
444
- shorthand: "a",
445
- type: Boolean,
446
- deprecated: false,
447
- description: "List resources across all projects"
448
- };
449
- var projectOption = {
450
- name: "project",
451
- shorthand: null,
452
- type: String,
453
- argument: "NAME_OR_ID",
454
- description: "Project name or ID (defaults to the linked project)",
455
- deprecated: false
456
- };
457
- var deploymentOption = {
458
- name: "deployment",
459
- shorthand: null,
460
- type: String,
461
- deprecated: false,
462
- description: "The deployment ID or URL to target",
463
- argument: "ID|URL"
464
- };
465
- var protectionBypassOption = {
466
- name: "protection-bypass",
467
- shorthand: null,
468
- type: String,
469
- deprecated: false,
470
- description: "Protection bypass secret for accessing protected deployments",
471
- argument: "SECRET"
472
- };
473
- var GLOBAL_LONG_TO_OPT = /* @__PURE__ */ new Map();
474
- var GLOBAL_SHORT_TO_OPT = /* @__PURE__ */ new Map();
475
- for (const opt of globalCommandOptions) {
476
- GLOBAL_LONG_TO_OPT.set(`--${opt.name}`, opt);
477
- if (opt.shorthand) {
478
- GLOBAL_SHORT_TO_OPT.set(`-${opt.shorthand}`, opt);
479
- }
480
- }
481
- function getGlobalFlagsOnlyFromArgs(args) {
482
- const safeArgs = stripSensitiveAuthArgs(args);
483
- const out = [];
484
- for (let i = 0; i < safeArgs.length; i++) {
485
- const a = safeArgs[i];
486
- let opt;
487
- if (a.startsWith("--") && a.includes("=")) {
488
- const name = a.slice(2).split("=")[0];
489
- opt = GLOBAL_LONG_TO_OPT.get(`--${name}`);
490
- if (opt)
491
- out.push(a);
492
- continue;
493
- }
494
- opt = GLOBAL_LONG_TO_OPT.get(a) || GLOBAL_SHORT_TO_OPT.get(a);
495
- if (!opt)
496
- continue;
497
- out.push(a);
498
- if (opt.type === String && !a.includes("=")) {
499
- const next = safeArgs[i + 1];
500
- if (next && !next.startsWith("-")) {
501
- out.push(next);
502
- i++;
503
- }
504
- }
505
- }
506
- return out;
507
- }
508
- function getCommandNameWithGlobalFlags(commandTemplate, argv) {
509
- const flags = getGlobalFlagsOnlyFromArgs(argv.slice(2));
510
- return getCommandNamePlain(`${commandTemplate} ${flags.join(" ")}`.trim());
511
- }
512
-
513
240
  // src/util/get-args.ts
514
241
  var import_arg = __toESM(require_arg(), 1);
515
242
  function getArgs(argv, argsOptions, argOptions = {}) {
@@ -606,24 +333,6 @@ function printError(error2) {
606
333
  }
607
334
 
608
335
  export {
609
- getFlagsSpecification,
610
- globalCommandOptions,
611
- GLOBAL_CLI_FLAG_NAMES,
612
- globalCliFlagTakesValue,
613
- getSameSubcommandSuggestionFlags,
614
- yesOption,
615
- nextOption,
616
- confirmOption,
617
- limitOption,
618
- forceOption,
619
- formatOption,
620
- jsonOption,
621
- allOption,
622
- projectOption,
623
- deploymentOption,
624
- protectionBypassOption,
625
- getGlobalFlagsOnlyFromArgs,
626
- getCommandNameWithGlobalFlags,
627
336
  getArgs,
628
337
  parseArguments,
629
338
  require_strip_ansi,
@@ -7,10 +7,12 @@ const __dirname = __dirname_(__filename);
7
7
  import {
8
8
  LinkRequiredError,
9
9
  ProjectNotFound,
10
+ getGlobalFlagsFromArgs,
10
11
  isAPIError,
11
12
  packageName,
12
- stripSensitiveAuthArgs
13
- } from "./chunk-P6AK7SVK.js";
13
+ stripSensitiveAuthArgs,
14
+ suggestionFlagTakesSeparateValue
15
+ } from "./chunk-KSSNLCL4.js";
14
16
  import {
15
17
  require_dist
16
18
  } from "./chunk-OX7KI3LF.js";
@@ -38,7 +40,6 @@ var GLOBAL_FLAG_NAMES = /* @__PURE__ */ new Set([
38
40
  "-T"
39
41
  // --token/-t are intentionally excluded and stripped via stripSensitiveAuthArgs.
40
42
  ]);
41
- var GLOBAL_FLAGS_BOOLEAN = /* @__PURE__ */ new Set(["--yes", "-y", "--non-interactive"]);
42
43
  var GLOBAL_FLAG_SHORTHANDS = {
43
44
  "-y": "--yes",
44
45
  "-S": "--scope",
@@ -48,14 +49,17 @@ function canonicalGlobalFlagName(name) {
48
49
  return GLOBAL_FLAG_SHORTHANDS[name] ?? name;
49
50
  }
50
51
  function getGlobalFlagsFromArgv(argv) {
51
- const args = stripSensitiveAuthArgs(argv.slice(2));
52
+ const args = getGlobalFlagsFromArgs(argv.slice(2), {
53
+ preserveConfig: true,
54
+ preserveYes: true
55
+ });
52
56
  const out = [];
53
57
  for (let i = 0; i < args.length; i++) {
54
58
  const arg = args[i];
55
59
  const name = arg.startsWith("--") ? arg.split("=")[0] : arg;
56
60
  if (GLOBAL_FLAG_NAMES.has(name)) {
57
61
  out.push(arg);
58
- const takesSeparateValue = !GLOBAL_FLAGS_BOOLEAN.has(name) && !arg.includes("=") && i + 1 < args.length && !args[i + 1].startsWith("-");
62
+ const takesSeparateValue = suggestionFlagTakesSeparateValue(name) && !arg.includes("=") && i + 1 < args.length && !args[i + 1].startsWith("-");
59
63
  if (takesSeparateValue) {
60
64
  out.push(args[i + 1]);
61
65
  i++;
@@ -71,7 +75,7 @@ function omitGlobalFlagsFromArgs(args) {
71
75
  const arg = safeArgs[i];
72
76
  const name = arg.startsWith("--") ? arg.split("=")[0] : arg;
73
77
  if (GLOBAL_FLAG_NAMES.has(name)) {
74
- const skipSeparateValue = !GLOBAL_FLAGS_BOOLEAN.has(name) && !arg.includes("=") && i + 1 < safeArgs.length && !safeArgs[i + 1].startsWith("-");
78
+ const skipSeparateValue = suggestionFlagTakesSeparateValue(name) && !arg.includes("=") && i + 1 < safeArgs.length && !safeArgs[i + 1].startsWith("-");
75
79
  if (skipSeparateValue) {
76
80
  i++;
77
81
  }
@@ -90,7 +94,16 @@ function buildIntegrationCommandTailFromArgv(argv) {
90
94
  return omitGlobalFlagsFromArgs(args.slice(idx)).join(" ");
91
95
  }
92
96
  function buildCommandWithGlobalFlags(argv, commandTemplate, pkgName = packageName, options) {
93
- let preserved = getGlobalFlagsFromArgv(argv);
97
+ let preserved = options?.globalFlags === "all" ? getGlobalFlagsFromArgs(argv.slice(2), {
98
+ preserveProject: options.preserveProject
99
+ }) : getGlobalFlagsFromArgv(argv);
100
+ if (options?.globalFlags !== "all" && options?.preserveProject) {
101
+ const globalArgs = getGlobalFlagsFromArgs(argv.slice(2));
102
+ const contextArgs = getGlobalFlagsFromArgs(argv.slice(2), {
103
+ preserveProject: true
104
+ });
105
+ preserved.push(...contextArgs.slice(globalArgs.length));
106
+ }
94
107
  const exclude = new Set(
95
108
  commandTemplate.split(/\s+/).filter((token) => token.startsWith("-")).map((token) => canonicalGlobalFlagName(token.split("=")[0]))
96
109
  );
@@ -121,106 +134,108 @@ function buildCommandWithGlobalFlags(argv, commandTemplate, pkgName = packageNam
121
134
  }
122
135
  return `${base} ${preserved.join(" ")}`;
123
136
  }
124
- function getPreservedArgsForEnvAdd(argv) {
125
- const args = argv.slice(2);
126
- const addIdx = args.indexOf("add");
127
- if (addIdx === -1 || args[addIdx - 1] !== "env")
128
- return stripSensitiveAuthArgs(args);
129
- let i = addIdx + 1;
130
- let positionals = 0;
131
- while (i < args.length && positionals < 3 && !args[i].startsWith("-")) {
132
- positionals++;
133
- i++;
134
- }
135
- return stripSensitiveAuthArgs(args.slice(i));
137
+ function withGlobalFlags(client, commandTemplate, options = {}) {
138
+ return buildCommandWithGlobalFlags(
139
+ client.argv,
140
+ commandTemplate,
141
+ packageName,
142
+ {
143
+ globalFlags: "all",
144
+ preserveProject: options.preserveProject
145
+ }
146
+ );
136
147
  }
137
- function buildEnvAddCommandWithPreservedArgs(argv, commandTemplate, pkgName = packageName) {
138
- let preserved = getPreservedArgsForEnvAdd(argv);
139
- if (commandTemplate.includes("--yes")) {
140
- preserved = preserved.filter((a) => a !== "--yes" && a !== "-y");
148
+ function getPreservedArgsAfterEnvSubcommand(argv, subcommands, positionalCount) {
149
+ const args = stripSensitiveAuthArgs(argv.slice(2));
150
+ const envIdx = args.findIndex(
151
+ (arg, index) => arg === "env" && subcommands.includes(args[index + 1])
152
+ );
153
+ const subcommandIdx = envIdx + 1;
154
+ if (envIdx === -1) {
155
+ return args;
141
156
  }
142
- if (commandTemplate.includes("--value")) {
143
- const out = [];
144
- for (let j = 0; j < preserved.length; j++) {
145
- if (preserved[j] === "--value" && j + 1 < preserved.length) {
146
- j++;
147
- continue;
157
+ const preserved = [];
158
+ let positionals = 0;
159
+ let optionsEnded = false;
160
+ for (let i = subcommandIdx + 1; i < args.length; i++) {
161
+ const arg = args[i];
162
+ if (arg === "--" && !optionsEnded) {
163
+ optionsEnded = true;
164
+ continue;
165
+ }
166
+ if (!optionsEnded && arg.startsWith("-")) {
167
+ preserved.push(arg);
168
+ if (!arg.includes("=") && suggestionFlagTakesSeparateValue(arg) && i + 1 < args.length && !args[i + 1].startsWith("-")) {
169
+ preserved.push(args[++i]);
148
170
  }
149
- if (preserved[j].startsWith("--value="))
150
- continue;
151
- out.push(preserved[j]);
171
+ continue;
152
172
  }
153
- preserved = out;
173
+ if (positionals < positionalCount) {
174
+ positionals++;
175
+ continue;
176
+ }
177
+ if (optionsEnded && !preserved.includes("--")) {
178
+ preserved.push("--");
179
+ }
180
+ preserved.push(arg);
154
181
  }
182
+ return preserved;
183
+ }
184
+ function omitPreservedFlagsAlreadyInTemplate(args, commandTemplate) {
185
+ const templateFlags = new Set(
186
+ commandTemplate.split(/\s+/).filter((token) => token.startsWith("-")).map((token) => canonicalGlobalFlagName(token.split("=")[0]))
187
+ );
188
+ const out = [];
189
+ for (let i = 0; i < args.length; i++) {
190
+ const arg = args[i];
191
+ const name = arg.startsWith("-") ? arg.split("=")[0] : arg;
192
+ if (!templateFlags.has(canonicalGlobalFlagName(name))) {
193
+ out.push(arg);
194
+ continue;
195
+ }
196
+ if (!arg.includes("=") && suggestionFlagTakesSeparateValue(name) && i + 1 < args.length && !args[i + 1].startsWith("-")) {
197
+ i++;
198
+ }
199
+ }
200
+ return out;
201
+ }
202
+ function getPreservedArgsForEnvAdd(argv) {
203
+ return getPreservedArgsAfterEnvSubcommand(argv, ["add"], 3);
204
+ }
205
+ function buildEnvAddCommandWithPreservedArgs(argv, commandTemplate, pkgName = packageName) {
206
+ const preserved = omitPreservedFlagsAlreadyInTemplate(
207
+ getPreservedArgsForEnvAdd(argv),
208
+ commandTemplate
209
+ );
155
210
  const base = `${pkgName} ${commandTemplate}`;
156
211
  if (preserved.length === 0)
157
212
  return base;
158
213
  return `${base} ${preserved.join(" ")}`;
159
214
  }
160
215
  function getPreservedArgsForEnvPull(argv) {
161
- const args = argv.slice(2);
162
- const pullIdx = args.indexOf("pull");
163
- if (pullIdx === -1 || args[pullIdx - 1] !== "env")
164
- return stripSensitiveAuthArgs(args);
165
- let i = pullIdx + 1;
166
- if (i < args.length && !args[i].startsWith("-"))
167
- i++;
168
- return stripSensitiveAuthArgs(args.slice(i));
216
+ return getPreservedArgsAfterEnvSubcommand(argv, ["pull"], 1);
169
217
  }
170
218
  function getPreservedArgsForEnvRm(argv) {
171
- const args = argv.slice(2);
172
- const rmIdx = args.indexOf("rm");
173
- if (rmIdx === -1 || args[rmIdx - 1] !== "env")
174
- return stripSensitiveAuthArgs(args);
175
- let i = rmIdx + 1;
176
- let positionals = 0;
177
- while (i < args.length && positionals < 3 && !args[i].startsWith("-")) {
178
- positionals++;
179
- i++;
180
- }
181
- return stripSensitiveAuthArgs(args.slice(i));
219
+ return getPreservedArgsAfterEnvSubcommand(argv, ["rm", "remove"], 3);
182
220
  }
183
221
  function buildEnvRmCommandWithPreservedArgs(argv, commandTemplate, pkgName = packageName) {
184
- let preserved = getPreservedArgsForEnvRm(argv);
185
- if (commandTemplate.includes("--yes")) {
186
- preserved = preserved.filter((a) => a !== "--yes" && a !== "-y");
187
- }
222
+ const preserved = omitPreservedFlagsAlreadyInTemplate(
223
+ getPreservedArgsForEnvRm(argv),
224
+ commandTemplate
225
+ );
188
226
  const base = `${pkgName} ${commandTemplate}`;
189
227
  if (preserved.length === 0)
190
228
  return base;
191
229
  return `${base} ${preserved.join(" ")}`;
192
230
  }
193
231
  function getPreservedArgsForEnvUpdate(argv) {
194
- const args = argv.slice(2);
195
- const updateIdx = args.indexOf("update");
196
- if (updateIdx === -1 || args[updateIdx - 1] !== "env")
197
- return stripSensitiveAuthArgs(args);
198
- let i = updateIdx + 1;
199
- let positionals = 0;
200
- while (i < args.length && positionals < 3 && !args[i].startsWith("-")) {
201
- positionals++;
202
- i++;
203
- }
204
- return stripSensitiveAuthArgs(args.slice(i));
232
+ return getPreservedArgsAfterEnvSubcommand(argv, ["update"], 3);
205
233
  }
206
234
  function buildEnvUpdateCommandWithPreservedArgs(argv, commandTemplate, pkgName = packageName) {
207
- let preserved = getPreservedArgsForEnvUpdate(argv);
208
- if (commandTemplate.includes("--yes")) {
209
- preserved = preserved.filter((a) => a !== "--yes" && a !== "-y");
210
- }
211
- if (commandTemplate.includes("--value")) {
212
- const out = [];
213
- for (let i = 0; i < preserved.length; i++) {
214
- if (preserved[i] === "--value" && i + 1 < preserved.length) {
215
- i++;
216
- continue;
217
- }
218
- if (preserved[i].startsWith("--value="))
219
- continue;
220
- out.push(preserved[i]);
221
- }
222
- preserved = out;
223
- }
235
+ const preserved = omitPreservedFlagsAlreadyInTemplate(
236
+ getPreservedArgsForEnvUpdate(argv),
237
+ commandTemplate
238
+ );
224
239
  const base = `${pkgName} ${commandTemplate}`;
225
240
  if (preserved.length === 0)
226
241
  return base;
@@ -527,11 +542,101 @@ function openUrlInBrowserCommand(url) {
527
542
  return `xdg-open '${url}'`;
528
543
  }
529
544
 
545
+ // src/util/agent-output-constants.ts
546
+ var AGENT_STATUS = {
547
+ ERROR: "error",
548
+ ACTION_REQUIRED: "action_required",
549
+ OK: "ok"
550
+ };
551
+ var AGENT_REASON = {
552
+ // Common (use across dns, flags, routes, env, domains, link)
553
+ MISSING_ARGUMENTS: "missing_arguments",
554
+ INVALID_ARGUMENTS: "invalid_arguments",
555
+ CONFIRMATION_REQUIRED: "confirmation_required",
556
+ LOGIN_REQUIRED: "login_required",
557
+ PROJECT_SETTINGS_REQUIRED: "project_settings_required",
558
+ NOT_LINKED: "not_linked",
559
+ NOT_FOUND: "not_found",
560
+ PROJECT_NOT_FOUND: "project_not_found",
561
+ MISSING_SCOPE: "missing_scope",
562
+ SCOPE_NOT_ACCESSIBLE: "scope_not_accessible",
563
+ API_ERROR: "api_error",
564
+ // Flags
565
+ SEGMENT_IN_USE: "segment_in_use",
566
+ // Env
567
+ MISSING_REQUIREMENTS: "missing_requirements",
568
+ MISSING_NAME: "missing_name",
569
+ MISSING_VALUE: "missing_value",
570
+ MISSING_ENVIRONMENT: "missing_environment",
571
+ ENV_NOT_FOUND: "env_not_found",
572
+ MULTIPLE_ENVS: "multiple_envs",
573
+ ENV_FILE_EXISTS: "env_file_exists",
574
+ GIT_BRANCH_REQUIRED: "git_branch_required",
575
+ ENV_KEY_SENSITIVE: "env_key_sensitive",
576
+ // Routes
577
+ AMBIGUOUS_ROUTE: "ambiguous_route",
578
+ ROUTE_CREATE_FAILED: "route_create_failed",
579
+ ROUTE_GENERATION_FAILED: "route_generation_failed",
580
+ // DNS
581
+ DOMAIN_NOT_FOUND: "domain_not_found",
582
+ DNS_RECORD_NOT_FOUND: "dns_record_not_found",
583
+ INCOMPLETE_RECORD: "incomplete_record",
584
+ PERMISSION_DENIED: "permission_denied",
585
+ INVALID_PORT: "invalid_port",
586
+ INVALID_DNS_TYPE: "invalid_dns_type",
587
+ DNS_ADD_FAILED: "dns_add_failed",
588
+ INVALID_DOMAIN: "invalid_domain",
589
+ CONFIGURED_CORRECTLY: "configured_correctly",
590
+ VERIFICATION_NEEDED: "verification_needed",
591
+ INVALID_CONFIGURATION: "invalid_configuration",
592
+ DNS_CHANGE_REQUIRED: "dns_change_required",
593
+ DNS_CHANGE_RECOMMENDED: "dns_change_recommended",
594
+ DNSSEC_NEEDS_TO_BE_DISABLED: "dnssec_needs_to_be_disabled",
595
+ PROJECT_ATTACHMENT_RECOMMENDED: "project_attachment_recommended",
596
+ PROJECT_DOMAIN_MISSING: "project_domain_missing",
597
+ /** User must accept marketplace integration terms in the browser before install can continue. */
598
+ INTEGRATION_TERMS_ACCEPTANCE_REQUIRED: "integration_terms_acceptance_required",
599
+ /** Integration uninstall blocked because team-scoped resources still exist. */
600
+ HAS_RESOURCES: "has_resources",
601
+ /** User must claim a sandbox marketplace resource (e.g. Stripe, Shopify) in the browser. */
602
+ INTEGRATION_SANDBOX_CLAIM_REQUIRED: "integration_sandbox_claim_required",
603
+ // Tokens
604
+ CLASSIC_TOKEN_REQUIRED: "classic_token_required",
605
+ /** Classic token lacks full user/account scope (e.g. team- or product-scoped token). */
606
+ TOKEN_USER_SCOPE_REQUIRED: "token_user_scope_required",
607
+ // Webhooks
608
+ MISSING_URL: "missing_url",
609
+ MISSING_EVENTS: "missing_events",
610
+ INVALID_URL: "invalid_url",
611
+ INVALID_EVENT: "invalid_event",
612
+ // AI Gateway
613
+ INVALID_BUDGET: "invalid_budget",
614
+ INVALID_REFRESH_PERIOD: "invalid_refresh_period",
615
+ INVALID_EXPIRATION: "invalid_expiration",
616
+ /**
617
+ * Every selected agent needs explicit `--agent`/`--all` consent (see the
618
+ * payload's skipped[]). `--yes` does not grant it, so this is deliberately
619
+ * not `confirmation_required` — re-running with --yes would loop forever.
620
+ */
621
+ REQUIRES_CONSENT: "requires_consent",
622
+ // Redirects
623
+ REDIRECT_NOT_FOUND: "redirect_not_found",
624
+ VERSION_NOT_FOUND: "version_not_found",
625
+ VERSION_ALREADY_LIVE: "version_already_live",
626
+ VERSION_IS_STAGING: "version_is_staging"
627
+ };
628
+ var AGENT_ACTION = {
629
+ MISSING_ARGUMENTS: "missing_arguments",
630
+ CONFIRMATION_REQUIRED: "confirmation_required",
631
+ LOGIN_REQUIRED: "login_required"
632
+ };
633
+
530
634
  export {
531
635
  buildCommandWithYes,
532
636
  omitGlobalFlagsFromArgs,
533
637
  buildIntegrationCommandTailFromArgv,
534
638
  buildCommandWithGlobalFlags,
639
+ withGlobalFlags,
535
640
  getPreservedArgsForEnvAdd,
536
641
  buildEnvAddCommandWithPreservedArgs,
537
642
  getPreservedArgsForEnvPull,
@@ -545,5 +650,8 @@ export {
545
650
  outputAgentError,
546
651
  outputAgentSuccess,
547
652
  exitWithNonInteractiveError,
548
- openUrlInBrowserCommand
653
+ openUrlInBrowserCommand,
654
+ AGENT_STATUS,
655
+ AGENT_REASON,
656
+ AGENT_ACTION
549
657
  };