@inworld/cli 2.1.0 → 2.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.
package/dist/index.js CHANGED
@@ -590,14 +590,14 @@ var require_help = __commonJS({
590
590
  * @return {string}
591
591
  *
592
592
  */
593
- wrap(str, width, indent, minColumnWidth = 40) {
593
+ wrap(str2, width, indent, minColumnWidth = 40) {
594
594
  const indents = " \\f\\t\\v\xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF";
595
595
  const manualIndent = new RegExp(`[\\n][${indents}]+`);
596
- if (str.match(manualIndent)) return str;
596
+ if (str2.match(manualIndent)) return str2;
597
597
  const columnWidth = width - indent;
598
- if (columnWidth < minColumnWidth) return str;
599
- const leadingStr = str.slice(0, indent);
600
- const columnText = str.slice(indent).replace("\r\n", "\n");
598
+ if (columnWidth < minColumnWidth) return str2;
599
+ const leadingStr = str2.slice(0, indent);
600
+ const columnText = str2.slice(indent).replace("\r\n", "\n");
601
601
  const indentString = " ".repeat(indent);
602
602
  const zeroWidthSpace = "\u200B";
603
603
  const breaks = `\\s${zeroWidthSpace}`;
@@ -866,9 +866,9 @@ var require_option = __commonJS({
866
866
  return option.negate === (negativeValue === value);
867
867
  }
868
868
  };
869
- function camelcase(str) {
870
- return str.split("-").reduce((str2, word) => {
871
- return str2 + word[0].toUpperCase() + word.slice(1);
869
+ function camelcase(str2) {
870
+ return str2.split("-").reduce((str3, word) => {
871
+ return str3 + word[0].toUpperCase() + word.slice(1);
872
872
  });
873
873
  }
874
874
  function splitOptionFlags(flags) {
@@ -1022,11 +1022,11 @@ var require_command = __commonJS({
1022
1022
  this._showHelpAfterError = false;
1023
1023
  this._showSuggestionAfterError = true;
1024
1024
  this._outputConfiguration = {
1025
- writeOut: (str) => process18.stdout.write(str),
1026
- writeErr: (str) => process18.stderr.write(str),
1025
+ writeOut: (str2) => process18.stdout.write(str2),
1026
+ writeErr: (str2) => process18.stderr.write(str2),
1027
1027
  getOutHelpWidth: () => process18.stdout.isTTY ? process18.stdout.columns : void 0,
1028
1028
  getErrHelpWidth: () => process18.stderr.isTTY ? process18.stderr.columns : void 0,
1029
- outputError: (str, write) => write(str)
1029
+ outputError: (str2, write) => write(str2)
1030
1030
  };
1031
1031
  this._hidden = false;
1032
1032
  this._helpOption = void 0;
@@ -2662,18 +2662,18 @@ Expecting one of '${allowedValues.join("', '")}'`);
2662
2662
  * @param {string} [description]
2663
2663
  * @return {(this | string | undefined)} `this` command for chaining, or version string if no arguments
2664
2664
  */
2665
- version(str, flags, description) {
2666
- if (str === void 0) return this._version;
2667
- this._version = str;
2665
+ version(str2, flags, description) {
2666
+ if (str2 === void 0) return this._version;
2667
+ this._version = str2;
2668
2668
  flags = flags || "-V, --version";
2669
2669
  description = description || "output the version number";
2670
2670
  const versionOption = this.createOption(flags, description);
2671
2671
  this._versionOptionName = versionOption.attributeName();
2672
2672
  this._registerOption(versionOption);
2673
2673
  this.on("option:" + versionOption.name(), () => {
2674
- this._outputConfiguration.writeOut(`${str}
2674
+ this._outputConfiguration.writeOut(`${str2}
2675
2675
  `);
2676
- this._exit(0, "commander.version", str);
2676
+ this._exit(0, "commander.version", str2);
2677
2677
  });
2678
2678
  return this;
2679
2679
  }
@@ -2684,10 +2684,10 @@ Expecting one of '${allowedValues.join("', '")}'`);
2684
2684
  * @param {object} [argsDescription]
2685
2685
  * @return {(string|Command)}
2686
2686
  */
2687
- description(str, argsDescription) {
2688
- if (str === void 0 && argsDescription === void 0)
2687
+ description(str2, argsDescription) {
2688
+ if (str2 === void 0 && argsDescription === void 0)
2689
2689
  return this._description;
2690
- this._description = str;
2690
+ this._description = str2;
2691
2691
  if (argsDescription) {
2692
2692
  this._argsDescription = argsDescription;
2693
2693
  }
@@ -2699,9 +2699,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
2699
2699
  * @param {string} [str]
2700
2700
  * @return {(string|Command)}
2701
2701
  */
2702
- summary(str) {
2703
- if (str === void 0) return this._summary;
2704
- this._summary = str;
2702
+ summary(str2) {
2703
+ if (str2 === void 0) return this._summary;
2704
+ this._summary = str2;
2705
2705
  return this;
2706
2706
  }
2707
2707
  /**
@@ -2749,8 +2749,8 @@ Expecting one of '${allowedValues.join("', '")}'`);
2749
2749
  * @param {string} [str]
2750
2750
  * @return {(string|Command)}
2751
2751
  */
2752
- usage(str) {
2753
- if (str === void 0) {
2752
+ usage(str2) {
2753
+ if (str2 === void 0) {
2754
2754
  if (this._usage) return this._usage;
2755
2755
  const args = this.registeredArguments.map((arg) => {
2756
2756
  return humanReadableArgName(arg);
@@ -2761,7 +2761,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
2761
2761
  this.registeredArguments.length ? args : []
2762
2762
  ).join(" ");
2763
2763
  }
2764
- this._usage = str;
2764
+ this._usage = str2;
2765
2765
  return this;
2766
2766
  }
2767
2767
  /**
@@ -2770,9 +2770,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
2770
2770
  * @param {string} [str]
2771
2771
  * @return {(string|Command)}
2772
2772
  */
2773
- name(str) {
2774
- if (str === void 0) return this._name;
2775
- this._name = str;
2773
+ name(str2) {
2774
+ if (str2 === void 0) return this._name;
2775
+ this._name = str2;
2776
2776
  return this;
2777
2777
  }
2778
2778
  /**
@@ -3883,7 +3883,7 @@ var require_code = __commonJS({
3883
3883
  }
3884
3884
  exports._ = _;
3885
3885
  var plus = new _Code("+");
3886
- function str(strs, ...args) {
3886
+ function str2(strs, ...args) {
3887
3887
  const expr = [safeStringify(strs[0])];
3888
3888
  let i2 = 0;
3889
3889
  while (i2 < args.length) {
@@ -3894,7 +3894,7 @@ var require_code = __commonJS({
3894
3894
  optimize(expr);
3895
3895
  return new _Code(expr);
3896
3896
  }
3897
- exports.str = str;
3897
+ exports.str = str2;
3898
3898
  function addCodeArg(code, arg) {
3899
3899
  if (arg instanceof _Code)
3900
3900
  code.push(...arg._items);
@@ -3937,7 +3937,7 @@ var require_code = __commonJS({
3937
3937
  return;
3938
3938
  }
3939
3939
  function strConcat(c1, c22) {
3940
- return c22.emptyStr() ? c1 : c1.emptyStr() ? c22 : str`${c1}${c22}`;
3940
+ return c22.emptyStr() ? c1 : c1.emptyStr() ? c22 : str2`${c1}${c22}`;
3941
3941
  }
3942
3942
  exports.strConcat = strConcat;
3943
3943
  function interpolate(x) {
@@ -4899,22 +4899,22 @@ var require_util = __commonJS({
4899
4899
  return (0, codegen_1._)`${topSchemaRef}${schemaPath}${(0, codegen_1.getProperty)(keyword)}`;
4900
4900
  }
4901
4901
  exports.schemaRefOrVal = schemaRefOrVal;
4902
- function unescapeFragment(str) {
4903
- return unescapeJsonPointer(decodeURIComponent(str));
4902
+ function unescapeFragment(str2) {
4903
+ return unescapeJsonPointer(decodeURIComponent(str2));
4904
4904
  }
4905
4905
  exports.unescapeFragment = unescapeFragment;
4906
- function escapeFragment(str) {
4907
- return encodeURIComponent(escapeJsonPointer(str));
4906
+ function escapeFragment(str2) {
4907
+ return encodeURIComponent(escapeJsonPointer(str2));
4908
4908
  }
4909
4909
  exports.escapeFragment = escapeFragment;
4910
- function escapeJsonPointer(str) {
4911
- if (typeof str == "number")
4912
- return `${str}`;
4913
- return str.replace(/~/g, "~0").replace(/\//g, "~1");
4910
+ function escapeJsonPointer(str2) {
4911
+ if (typeof str2 == "number")
4912
+ return `${str2}`;
4913
+ return str2.replace(/~/g, "~0").replace(/\//g, "~1");
4914
4914
  }
4915
4915
  exports.escapeJsonPointer = escapeJsonPointer;
4916
- function unescapeJsonPointer(str) {
4917
- return str.replace(/~1/g, "/").replace(/~0/g, "~");
4916
+ function unescapeJsonPointer(str2) {
4917
+ return str2.replace(/~1/g, "/").replace(/~0/g, "~");
4918
4918
  }
4919
4919
  exports.unescapeJsonPointer = unescapeJsonPointer;
4920
4920
  function eachItem(xs, f) {
@@ -5939,8 +5939,8 @@ var require_json_schema_traverse = __commonJS({
5939
5939
  post(schema, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex);
5940
5940
  }
5941
5941
  }
5942
- function escapeJsonPtr(str) {
5943
- return str.replace(/~/g, "~0").replace(/\//g, "~1");
5942
+ function escapeJsonPtr(str2) {
5943
+ return str2.replace(/~/g, "~0").replace(/\//g, "~1");
5944
5944
  }
5945
5945
  }
5946
5946
  });
@@ -7001,10 +7001,10 @@ var require_utils = __commonJS({
7001
7001
  return { host, isIPV6: false };
7002
7002
  }
7003
7003
  }
7004
- function findToken(str, token) {
7004
+ function findToken(str2, token) {
7005
7005
  let ind = 0;
7006
- for (let i2 = 0; i2 < str.length; i2++) {
7007
- if (str[i2] === token) ind++;
7006
+ for (let i2 = 0; i2 < str2.length; i2++) {
7007
+ if (str2[i2] === token) ind++;
7008
7008
  }
7009
7009
  return ind;
7010
7010
  }
@@ -7268,7 +7268,7 @@ var require_schemes = __commonJS({
7268
7268
  urnComponent.nss = (uuidComponent.uuid || "").toLowerCase();
7269
7269
  return urnComponent;
7270
7270
  }
7271
- var http2 = (
7271
+ var http = (
7272
7272
  /** @type {SchemeHandler} */
7273
7273
  {
7274
7274
  scheme: "http",
@@ -7281,7 +7281,7 @@ var require_schemes = __commonJS({
7281
7281
  /** @type {SchemeHandler} */
7282
7282
  {
7283
7283
  scheme: "https",
7284
- domainHost: http2.domainHost,
7284
+ domainHost: http.domainHost,
7285
7285
  parse: httpParse,
7286
7286
  serialize: httpSerialize
7287
7287
  }
@@ -7325,7 +7325,7 @@ var require_schemes = __commonJS({
7325
7325
  var SCHEMES = (
7326
7326
  /** @type {Record<SchemeName, SchemeHandler>} */
7327
7327
  {
7328
- http: http2,
7328
+ http,
7329
7329
  https,
7330
7330
  ws,
7331
7331
  wss,
@@ -7657,7 +7657,7 @@ var require_core = __commonJS({
7657
7657
  var util_1 = require_util();
7658
7658
  var $dataRefSchema = require_data();
7659
7659
  var uri_1 = require_uri();
7660
- var defaultRegExp = (str, flags) => new RegExp(str, flags);
7660
+ var defaultRegExp = (str2, flags) => new RegExp(str2, flags);
7661
7661
  defaultRegExp.code = "new RegExp";
7662
7662
  var META_IGNORE_OPTIONS = ["removeAdditional", "useDefaults", "coerceTypes"];
7663
7663
  var EXT_SCOPE_NAMES = /* @__PURE__ */ new Set([
@@ -8452,16 +8452,16 @@ var require_ucs2length = __commonJS({
8452
8452
  "../../node_modules/conf/node_modules/ajv/dist/runtime/ucs2length.js"(exports) {
8453
8453
  "use strict";
8454
8454
  Object.defineProperty(exports, "__esModule", { value: true });
8455
- function ucs2length(str) {
8456
- const len = str.length;
8455
+ function ucs2length(str2) {
8456
+ const len = str2.length;
8457
8457
  let length = 0;
8458
8458
  let pos = 0;
8459
8459
  let value;
8460
8460
  while (pos < len) {
8461
8461
  length++;
8462
- value = str.charCodeAt(pos++);
8462
+ value = str2.charCodeAt(pos++);
8463
8463
  if (value >= 55296 && value <= 56319 && pos < len) {
8464
- value = str.charCodeAt(pos);
8464
+ value = str2.charCodeAt(pos);
8465
8465
  if ((value & 64512) === 56320)
8466
8466
  pos++;
8467
8467
  }
@@ -10919,8 +10919,8 @@ var require_formats = __commonJS({
10919
10919
  }
10920
10920
  var DATE = /^(\d\d\d\d)-(\d\d)-(\d\d)$/;
10921
10921
  var DAYS = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
10922
- function date3(str) {
10923
- const matches = DATE.exec(str);
10922
+ function date3(str2) {
10923
+ const matches = DATE.exec(str2);
10924
10924
  if (!matches)
10925
10925
  return false;
10926
10926
  const year = +matches[1];
@@ -10939,8 +10939,8 @@ var require_formats = __commonJS({
10939
10939
  }
10940
10940
  var TIME = /^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;
10941
10941
  function getTime(strictTimeZone) {
10942
- return function time3(str) {
10943
- const matches = TIME.exec(str);
10942
+ return function time3(str2) {
10943
+ const matches = TIME.exec(str2);
10944
10944
  if (!matches)
10945
10945
  return false;
10946
10946
  const hr = +matches[1];
@@ -10986,8 +10986,8 @@ var require_formats = __commonJS({
10986
10986
  var DATE_TIME_SEPARATOR = /t|\s/i;
10987
10987
  function getDateTime(strictTimeZone) {
10988
10988
  const time3 = getTime(strictTimeZone);
10989
- return function date_time(str) {
10990
- const dateTime = str.split(DATE_TIME_SEPARATOR);
10989
+ return function date_time(str2) {
10990
+ const dateTime = str2.split(DATE_TIME_SEPARATOR);
10991
10991
  return dateTime.length === 2 && date3(dateTime[0]) && time3(dateTime[1]);
10992
10992
  };
10993
10993
  }
@@ -11012,13 +11012,13 @@ var require_formats = __commonJS({
11012
11012
  }
11013
11013
  var NOT_URI_FRAGMENT = /\/|:/;
11014
11014
  var URI = /^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;
11015
- function uri(str) {
11016
- return NOT_URI_FRAGMENT.test(str) && URI.test(str);
11015
+ function uri(str2) {
11016
+ return NOT_URI_FRAGMENT.test(str2) && URI.test(str2);
11017
11017
  }
11018
11018
  var BYTE = /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;
11019
- function byte(str) {
11019
+ function byte(str2) {
11020
11020
  BYTE.lastIndex = 0;
11021
- return BYTE.test(str);
11021
+ return BYTE.test(str2);
11022
11022
  }
11023
11023
  var MIN_INT32 = -(2 ** 31);
11024
11024
  var MAX_INT32 = 2 ** 31 - 1;
@@ -11032,11 +11032,11 @@ var require_formats = __commonJS({
11032
11032
  return true;
11033
11033
  }
11034
11034
  var Z_ANCHOR = /[^\\]\\Z/;
11035
- function regex(str) {
11036
- if (Z_ANCHOR.test(str))
11035
+ function regex(str2) {
11036
+ if (Z_ANCHOR.test(str2))
11037
11037
  return false;
11038
11038
  try {
11039
- new RegExp(str);
11039
+ new RegExp(str2);
11040
11040
  return true;
11041
11041
  } catch (e) {
11042
11042
  return false;
@@ -11113,7 +11113,7 @@ var require_code3 = __commonJS({
11113
11113
  }
11114
11114
  exports._ = _;
11115
11115
  var plus = new _Code("+");
11116
- function str(strs, ...args) {
11116
+ function str2(strs, ...args) {
11117
11117
  const expr = [safeStringify(strs[0])];
11118
11118
  let i2 = 0;
11119
11119
  while (i2 < args.length) {
@@ -11124,7 +11124,7 @@ var require_code3 = __commonJS({
11124
11124
  optimize(expr);
11125
11125
  return new _Code(expr);
11126
11126
  }
11127
- exports.str = str;
11127
+ exports.str = str2;
11128
11128
  function addCodeArg(code, arg) {
11129
11129
  if (arg instanceof _Code)
11130
11130
  code.push(...arg._items);
@@ -11167,7 +11167,7 @@ var require_code3 = __commonJS({
11167
11167
  return;
11168
11168
  }
11169
11169
  function strConcat(c1, c22) {
11170
- return c22.emptyStr() ? c1 : c1.emptyStr() ? c22 : str`${c1}${c22}`;
11170
+ return c22.emptyStr() ? c1 : c1.emptyStr() ? c22 : str2`${c1}${c22}`;
11171
11171
  }
11172
11172
  exports.strConcat = strConcat;
11173
11173
  function interpolate(x) {
@@ -12129,22 +12129,22 @@ var require_util2 = __commonJS({
12129
12129
  return (0, codegen_1._)`${topSchemaRef}${schemaPath}${(0, codegen_1.getProperty)(keyword)}`;
12130
12130
  }
12131
12131
  exports.schemaRefOrVal = schemaRefOrVal;
12132
- function unescapeFragment(str) {
12133
- return unescapeJsonPointer(decodeURIComponent(str));
12132
+ function unescapeFragment(str2) {
12133
+ return unescapeJsonPointer(decodeURIComponent(str2));
12134
12134
  }
12135
12135
  exports.unescapeFragment = unescapeFragment;
12136
- function escapeFragment(str) {
12137
- return encodeURIComponent(escapeJsonPointer(str));
12136
+ function escapeFragment(str2) {
12137
+ return encodeURIComponent(escapeJsonPointer(str2));
12138
12138
  }
12139
12139
  exports.escapeFragment = escapeFragment;
12140
- function escapeJsonPointer(str) {
12141
- if (typeof str == "number")
12142
- return `${str}`;
12143
- return str.replace(/~/g, "~0").replace(/\//g, "~1");
12140
+ function escapeJsonPointer(str2) {
12141
+ if (typeof str2 == "number")
12142
+ return `${str2}`;
12143
+ return str2.replace(/~/g, "~0").replace(/\//g, "~1");
12144
12144
  }
12145
12145
  exports.escapeJsonPointer = escapeJsonPointer;
12146
- function unescapeJsonPointer(str) {
12147
- return str.replace(/~1/g, "/").replace(/~0/g, "~");
12146
+ function unescapeJsonPointer(str2) {
12147
+ return str2.replace(/~1/g, "/").replace(/~0/g, "~");
12148
12148
  }
12149
12149
  exports.unescapeJsonPointer = unescapeJsonPointer;
12150
12150
  function eachItem(xs, f) {
@@ -13134,8 +13134,8 @@ var require_json_schema_traverse2 = __commonJS({
13134
13134
  post(schema, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex);
13135
13135
  }
13136
13136
  }
13137
- function escapeJsonPtr(str) {
13138
- return str.replace(/~/g, "~0").replace(/\//g, "~1");
13137
+ function escapeJsonPtr(str2) {
13138
+ return str2.replace(/~/g, "~0").replace(/\//g, "~1");
13139
13139
  }
13140
13140
  }
13141
13141
  });
@@ -14130,7 +14130,7 @@ var require_core4 = __commonJS({
14130
14130
  var util_1 = require_util2();
14131
14131
  var $dataRefSchema = require_data2();
14132
14132
  var uri_1 = require_uri2();
14133
- var defaultRegExp = (str, flags) => new RegExp(str, flags);
14133
+ var defaultRegExp = (str2, flags) => new RegExp(str2, flags);
14134
14134
  defaultRegExp.code = "new RegExp";
14135
14135
  var META_IGNORE_OPTIONS = ["removeAdditional", "useDefaults", "coerceTypes"];
14136
14136
  var EXT_SCOPE_NAMES = /* @__PURE__ */ new Set([
@@ -14925,16 +14925,16 @@ var require_ucs2length2 = __commonJS({
14925
14925
  "../../node_modules/ajv-formats/node_modules/ajv/dist/runtime/ucs2length.js"(exports) {
14926
14926
  "use strict";
14927
14927
  Object.defineProperty(exports, "__esModule", { value: true });
14928
- function ucs2length(str) {
14929
- const len = str.length;
14928
+ function ucs2length(str2) {
14929
+ const len = str2.length;
14930
14930
  let length = 0;
14931
14931
  let pos = 0;
14932
14932
  let value;
14933
14933
  while (pos < len) {
14934
14934
  length++;
14935
- value = str.charCodeAt(pos++);
14935
+ value = str2.charCodeAt(pos++);
14936
14936
  if (value >= 55296 && value <= 56319 && pos < len) {
14937
- value = str.charCodeAt(pos);
14937
+ value = str2.charCodeAt(pos);
14938
14938
  if ((value & 64512) === 56320)
14939
14939
  pos++;
14940
14940
  }
@@ -19443,7 +19443,8 @@ async function getConf() {
19443
19443
  workspace: { type: "string" },
19444
19444
  env: { type: "string" },
19445
19445
  authProvider: { type: "string" },
19446
- authUrl: { type: "string" }
19446
+ authUrl: { type: "string" },
19447
+ authClientId: { type: "string" }
19447
19448
  }
19448
19449
  }
19449
19450
  }
@@ -19724,7 +19725,7 @@ var init_package = __esm({
19724
19725
  "package.json"() {
19725
19726
  package_default = {
19726
19727
  name: "@inworld/cli",
19727
- version: "2.1.0",
19728
+ version: "2.3.0",
19728
19729
  type: "module",
19729
19730
  main: "dist/index.js",
19730
19731
  bin: {
@@ -19732,7 +19733,7 @@ var init_package = __esm({
19732
19733
  "inworld-mcp": "dist/cli/inworld-mcp.js"
19733
19734
  },
19734
19735
  scripts: {
19735
- postversion: "npm install && git add ../../package-lock.json",
19736
+ postversion: "npm install --package-lock-only --ignore-scripts && git add ../../package-lock.json",
19736
19737
  "copy:release-it-config": "node ../../scripts/copy-release-it-config.js",
19737
19738
  clean: "shx rm -rf dist",
19738
19739
  build: "npm run clean && node esbuild.config.js && npm run copy:release-it-config",
@@ -19803,33 +19804,45 @@ var init_package = __esm({
19803
19804
  }
19804
19805
  });
19805
19806
 
19806
- // src/constants.ts
19807
- var DEFAULT_PLATFORM_ENDPOINT, resolvePlatformUrl, INWORLD_ENV, WORKSPACES_LIST_SIZE, PLATFORM_URL, INWORLD_CLI_AUTH_URL, MIXPANEL_TOKEN, CLI_VERSION;
19807
+ // src/mcp/auth/constants.ts
19808
+ function resolveDeployment(environment) {
19809
+ const deployment = environment?.toUpperCase();
19810
+ return deployment === "DEV" || deployment === "STAGE" ? deployment : "PROD";
19811
+ }
19812
+ function getMcpHttpAuthMode() {
19813
+ const v = (process.env.INWORLD_MCP_HTTP_AUTH || "session").toLowerCase();
19814
+ if (v === "bearer") return "bearer";
19815
+ return "session";
19816
+ }
19817
+ var INWORLD_ENV, PLATFORM_ENDPOINTS, PLATFORM_URL, CLIENT_ID_PLACEHOLDER, CLI_CLIENT_IDS, INWORLD_CLI_CLIENT_ID;
19808
19818
  var init_constants5 = __esm({
19819
+ "src/mcp/auth/constants.ts"() {
19820
+ "use strict";
19821
+ INWORLD_ENV = resolveDeployment(process.env.INWORLD_ENV);
19822
+ PLATFORM_ENDPOINTS = {
19823
+ DEV: "https://platform.dev.inworld.ai",
19824
+ STAGE: "https://platform.stage.inworld.ai",
19825
+ PROD: "https://platform.inworld.ai"
19826
+ };
19827
+ PLATFORM_URL = process.env.INWORLD_PLATFORM_URL || PLATFORM_ENDPOINTS[INWORLD_ENV];
19828
+ CLIENT_ID_PLACEHOLDER = "TODO_REGISTER_CLIENT";
19829
+ CLI_CLIENT_IDS = {
19830
+ DEV: "d278a440-a58a-4002-bc0d-e589d594b053",
19831
+ STAGE: CLIENT_ID_PLACEHOLDER,
19832
+ PROD: "af94ff96-cd1e-4024-a284-cc7ba3de04c4"
19833
+ };
19834
+ INWORLD_CLI_CLIENT_ID = process.env.INWORLD_CLI_CLIENT_ID?.trim() || (process.env.INWORLD_PLATFORM_URL || process.env.INWORLD_AUTH_URL?.trim() ? "" : CLI_CLIENT_IDS[INWORLD_ENV]);
19835
+ }
19836
+ });
19837
+
19838
+ // src/constants.ts
19839
+ var WORKSPACES_LIST_SIZE, MIXPANEL_TOKEN, CLI_VERSION;
19840
+ var init_constants6 = __esm({
19809
19841
  "src/constants.ts"() {
19810
19842
  "use strict";
19811
19843
  init_package();
19812
- DEFAULT_PLATFORM_ENDPOINT = "https://platform.inworld.ai";
19813
- resolvePlatformUrl = () => {
19814
- if (process.env.INWORLD_PLATFORM_URL) {
19815
- return process.env.INWORLD_PLATFORM_URL;
19816
- }
19817
- const env3 = (process.env.INWORLD_ENV || "").toUpperCase();
19818
- switch (env3) {
19819
- case "DEV":
19820
- return "https://platform.dev.inworld.ai";
19821
- case "STAGE":
19822
- return "https://platform.stage.inworld.ai";
19823
- case "PROD":
19824
- return "https://platform.inworld.ai";
19825
- default:
19826
- return DEFAULT_PLATFORM_ENDPOINT;
19827
- }
19828
- };
19829
- INWORLD_ENV = process.env.INWORLD_ENV || "PROD";
19844
+ init_constants5();
19830
19845
  WORKSPACES_LIST_SIZE = 100;
19831
- PLATFORM_URL = resolvePlatformUrl();
19832
- INWORLD_CLI_AUTH_URL = process.env.INWORLD_CLI_AUTH_URL || `${PLATFORM_URL.replace(/\/$/, "")}/cli-auth/login`;
19833
19846
  MIXPANEL_TOKEN = process.env.INWORLD_MIXPANEL_TOKEN || "2cf13116e9701343ac27ddc452adfbbc";
19834
19847
  CLI_VERSION = package_default.version;
19835
19848
  }
@@ -19840,7 +19853,7 @@ var CLIENT_INFO_HEADER, CLI_APP, OS_NAMES, safeToken, buildClientInfo, CLIENT_IN
19840
19853
  var init_client_info = __esm({
19841
19854
  "src/utils/client_info.ts"() {
19842
19855
  "use strict";
19843
- init_constants5();
19856
+ init_constants6();
19844
19857
  CLIENT_INFO_HEADER = "x-user-agent";
19845
19858
  CLI_APP = "inworld-cli";
19846
19859
  OS_NAMES = {
@@ -19872,42 +19885,7 @@ var init_client_info = __esm({
19872
19885
  }
19873
19886
  });
19874
19887
 
19875
- // src/mcp/auth/constants.ts
19876
- function getMcpHttpAuthMode() {
19877
- const v = (process.env.INWORLD_MCP_HTTP_AUTH || "session").toLowerCase();
19878
- if (v === "bearer") return "bearer";
19879
- return "session";
19880
- }
19881
- var DEFAULT_PLATFORM_ENDPOINT2, resolvePlatformUrl2, INWORLD_ENV2, PLATFORM_URL2, INWORLD_CLI_AUTH_URL2;
19882
- var init_constants6 = __esm({
19883
- "src/mcp/auth/constants.ts"() {
19884
- "use strict";
19885
- DEFAULT_PLATFORM_ENDPOINT2 = "https://platform.inworld.ai";
19886
- resolvePlatformUrl2 = () => {
19887
- if (process.env.INWORLD_PLATFORM_URL) {
19888
- return process.env.INWORLD_PLATFORM_URL;
19889
- }
19890
- const env3 = (process.env.INWORLD_ENV || "").toUpperCase();
19891
- switch (env3) {
19892
- case "DEV":
19893
- return "https://platform.dev.inworld.ai";
19894
- case "STAGE":
19895
- return "https://platform.stage.inworld.ai";
19896
- case "PROD":
19897
- return "https://platform.inworld.ai";
19898
- default:
19899
- return DEFAULT_PLATFORM_ENDPOINT2;
19900
- }
19901
- };
19902
- INWORLD_ENV2 = process.env.INWORLD_ENV || "PROD";
19903
- PLATFORM_URL2 = resolvePlatformUrl2();
19904
- INWORLD_CLI_AUTH_URL2 = process.env.INWORLD_CLI_AUTH_URL || `${PLATFORM_URL2.replace(/\/$/, "")}/cli-auth/login`;
19905
- }
19906
- });
19907
-
19908
19888
  // src/mcp/auth/identity.ts
19909
- import { createHash as createHash2, randomBytes, timingSafeEqual } from "node:crypto";
19910
- import * as http from "node:http";
19911
19889
  function decodeJwtPayload(jwt) {
19912
19890
  const parts = jwt.split(".");
19913
19891
  if (parts.length < 2) return null;
@@ -19927,7 +19905,8 @@ function isIssuedBy(idToken, source) {
19927
19905
  return tokenIssuer(idToken) === source.authUrl;
19928
19906
  }
19929
19907
  function identitySourceOfStore(stored) {
19930
- return stored.authProvider === "supabase" && stored.authUrl ? { authUrl: stored.authUrl } : null;
19908
+ if (stored.authProvider !== "supabase" || !stored.authUrl) return null;
19909
+ return stored.authClientId ? { authUrl: stored.authUrl, clientId: stored.authClientId } : { authUrl: stored.authUrl };
19931
19910
  }
19932
19911
  function parseConfigJs(text) {
19933
19912
  const pick2 = (key) => new RegExp(`["']?${key}["']?\\s*:\\s*["']([^"']+)["']`).exec(text)?.[1];
@@ -19957,46 +19936,77 @@ function gotrueErrorMessage(data, fallback) {
19957
19936
  }
19958
19937
  return fallback;
19959
19938
  }
19960
- async function gotrueToken(authUrl, grantType, body, signal) {
19961
- const url = `${authUrl}/token?grant_type=${grantType}`;
19962
- const res = await fetch(url, {
19939
+ function postForm(url, fields, signal) {
19940
+ return fetch(url, {
19963
19941
  method: "POST",
19964
19942
  headers: {
19965
- "Content-Type": "application/json",
19943
+ "Content-Type": "application/x-www-form-urlencoded",
19966
19944
  [CLIENT_INFO_HEADER]: CLIENT_INFO
19967
19945
  },
19968
- body: JSON.stringify(body),
19946
+ body: new URLSearchParams(fields).toString(),
19969
19947
  signal
19970
19948
  });
19949
+ }
19950
+ async function readJsonBody(res) {
19971
19951
  const text = await res.text();
19972
- let data = {};
19973
19952
  try {
19974
- data = text ? JSON.parse(text) : {};
19953
+ return { data: text ? JSON.parse(text) : {}, text };
19975
19954
  } catch {
19976
- throw new Error(
19977
- `Supabase token (${grantType}): expected JSON (${res.status}): ${text.slice(0, 200)}`
19978
- );
19955
+ return { data: null, text };
19979
19956
  }
19980
- if (!res.ok) {
19957
+ }
19958
+ function identityTokensOf(data, label) {
19959
+ const session = data ?? {};
19960
+ if (!session.access_token || !session.refresh_token) {
19961
+ throw new Error(`${label}: response missing access or refresh token`);
19962
+ }
19963
+ const claim2 = decodeJwtPayload(session.access_token)?.email;
19964
+ return {
19965
+ idToken: session.access_token,
19966
+ refreshToken: session.refresh_token,
19967
+ // `/oauth/token` responses carry no `user`; the access token names it.
19968
+ email: session.user?.email ?? (typeof claim2 === "string" ? claim2 : void 0)
19969
+ };
19970
+ }
19971
+ async function refreshIdentityToken(source, refreshToken) {
19972
+ const label = "Supabase token (refresh_token)";
19973
+ let res;
19974
+ if (source.clientId) {
19975
+ const url = `${source.authUrl}/oauth/token`;
19976
+ const fields = {
19977
+ grant_type: "refresh_token",
19978
+ refresh_token: refreshToken,
19979
+ client_id: source.clientId
19980
+ };
19981
+ res = await postForm(url, fields);
19982
+ for (const delayMs of [1e3, 2e3, 4e3]) {
19983
+ if (res.status !== 429) break;
19984
+ void res.body?.cancel().catch(() => void 0);
19985
+ await new Promise((resolve6) => setTimeout(resolve6, delayMs));
19986
+ res = await postForm(url, fields);
19987
+ }
19988
+ } else {
19989
+ res = await fetch(`${source.authUrl}/token?grant_type=refresh_token`, {
19990
+ method: "POST",
19991
+ headers: {
19992
+ "Content-Type": "application/json",
19993
+ [CLIENT_INFO_HEADER]: CLIENT_INFO
19994
+ },
19995
+ body: JSON.stringify({ refresh_token: refreshToken })
19996
+ });
19997
+ }
19998
+ const { data, text } = await readJsonBody(res);
19999
+ if (data === null) {
19981
20000
  throw new Error(
19982
- `Supabase token (${grantType}) failed: ${gotrueErrorMessage(data, `HTTP ${res.status}`)}`
20001
+ `${label}: expected JSON (${res.status}): ${text.slice(0, 200)}`
19983
20002
  );
19984
20003
  }
19985
- if (!data.access_token || !data.refresh_token) {
20004
+ if (!res.ok) {
19986
20005
  throw new Error(
19987
- `Supabase token (${grantType}): response missing access or refresh token`
20006
+ `${label} failed: ${gotrueErrorMessage(data, `HTTP ${res.status}`)}`
19988
20007
  );
19989
20008
  }
19990
- return {
19991
- idToken: data.access_token,
19992
- refreshToken: data.refresh_token,
19993
- email: data.user?.email
19994
- };
19995
- }
19996
- async function refreshIdentityToken(source, refreshToken) {
19997
- return gotrueToken(source.authUrl, "refresh_token", {
19998
- refresh_token: refreshToken
19999
- });
20009
+ return identityTokensOf(data, label);
20000
20010
  }
20001
20011
  async function revokeSession(source, refreshToken) {
20002
20012
  const { idToken } = await refreshIdentityToken(source, refreshToken);
@@ -20019,258 +20029,7 @@ async function revokeSession(source, refreshToken) {
20019
20029
  );
20020
20030
  }
20021
20031
  }
20022
- function createPkcePair() {
20023
- const verifier = base64url(randomBytes(32));
20024
- const challenge = base64url(createHash2("sha256").update(verifier).digest());
20025
- return { verifier, challenge };
20026
- }
20027
- function gotrueAuthorizeUrl(authUrl, oauthProvider, redirectTo, challenge) {
20028
- const u2 = new URL(`${authUrl}/authorize`);
20029
- u2.searchParams.set("provider", oauthProvider);
20030
- u2.searchParams.set("redirect_to", redirectTo);
20031
- u2.searchParams.set("code_challenge", challenge);
20032
- u2.searchParams.set("code_challenge_method", "s256");
20033
- return u2.toString();
20034
- }
20035
- function gotrueCallbackPort() {
20036
- const fixed = process.env.INWORLD_CLI_AUTH_CALLBACK_PORT?.trim();
20037
- return fixed ? parseInt(fixed, 10) : 0;
20038
- }
20039
- function sameSecret(a2, b) {
20040
- if (!a2) return false;
20041
- const x = Buffer.from(a2);
20042
- const y = Buffer.from(b);
20043
- return x.length === y.length && timingSafeEqual(x, y);
20044
- }
20045
- function readForm(req) {
20046
- return new Promise((resolve6, reject) => {
20047
- let size = 0;
20048
- const chunks = [];
20049
- req.on("data", (chunk) => {
20050
- size += chunk.length;
20051
- if (size > MAX_FORM_BYTES) {
20052
- reject(new Error("Form body too large"));
20053
- req.destroy();
20054
- return;
20055
- }
20056
- chunks.push(chunk);
20057
- });
20058
- req.on(
20059
- "end",
20060
- () => resolve6(new URLSearchParams(Buffer.concat(chunks).toString("utf8")))
20061
- );
20062
- req.on("error", reject);
20063
- });
20064
- }
20065
- function signInResultUrl(pageUrl, error2) {
20066
- const u2 = new URL(pageUrl);
20067
- u2.search = "";
20068
- if (error2) {
20069
- u2.searchParams.set("result", "error");
20070
- u2.searchParams.set("message", error2.slice(0, 300));
20071
- } else {
20072
- u2.searchParams.set("result", "success");
20073
- }
20074
- return u2.toString();
20075
- }
20076
- async function startLoopbackReceiver(options) {
20077
- const state = base64url(randomBytes(32));
20078
- const pageOrigin = new URL(options.pageUrl).origin;
20079
- let settle;
20080
- const done = new Promise((resolve6, reject) => {
20081
- settle = { resolve: resolve6, reject };
20082
- });
20083
- let claimed = false;
20084
- let ended = false;
20085
- let failure;
20086
- const redemption = new AbortController();
20087
- const end = (outcome) => {
20088
- if (ended) return false;
20089
- ended = true;
20090
- claimed = true;
20091
- if (outcome instanceof Error) {
20092
- failure = outcome;
20093
- redemption.abort();
20094
- settle.reject(outcome);
20095
- } else {
20096
- settle.resolve(outcome);
20097
- }
20098
- return true;
20099
- };
20100
- const finish = (redeem, answer = () => {
20101
- }) => {
20102
- claimed = true;
20103
- redeem(redemption.signal).then(
20104
- // A result after cancel or the timeout is dropped. Ending closes the
20105
- // listener first, so a browser still waiting gets no result page: its
20106
- // connection is reset, and `answer` finds it gone.
20107
- (tokens) => {
20108
- end(tokens);
20109
- answer(signInResultUrl(options.pageUrl, failure?.message));
20110
- },
20111
- (error2) => {
20112
- end(error2);
20113
- answer(signInResultUrl(options.pageUrl, failure?.message));
20114
- }
20115
- );
20116
- };
20117
- const answerWith = (res, status) => {
20118
- return (location) => {
20119
- if (res.headersSent || res.destroyed) return;
20120
- res.writeHead(status, { Location: location });
20121
- res.end();
20122
- };
20123
- };
20124
- const redeemRedirect = (params) => {
20125
- const error2 = params.get("error_description") ?? params.get("error");
20126
- const code = params.get("code");
20127
- if (error2 || !code) {
20128
- const msg = error2 ?? "No authorization code in the redirect.";
20129
- return () => Promise.reject(new Error(msg));
20130
- }
20131
- return (signal) => options.redeemCode(code, signal);
20132
- };
20133
- const handler = (req, res) => {
20134
- const url = new URL(req.url ?? "/", "http://127.0.0.1");
20135
- if (url.pathname !== "/") {
20136
- res.writeHead(404).end();
20137
- return;
20138
- }
20139
- if (claimed) {
20140
- res.writeHead(409).end("Sign-in already completed.");
20141
- return;
20142
- }
20143
- if (req.method === "GET") {
20144
- if (!sameSecret(url.searchParams.get("state"), state)) {
20145
- res.writeHead(400).end("Unknown sign-in.");
20146
- return;
20147
- }
20148
- finish(redeemRedirect(url.searchParams), answerWith(res, 302));
20149
- return;
20150
- }
20151
- if (req.method === "POST") {
20152
- if (req.headers.origin !== pageOrigin) {
20153
- res.writeHead(403).end("Unknown origin.");
20154
- return;
20155
- }
20156
- readForm(req).then(
20157
- (form) => {
20158
- if (claimed) {
20159
- res.writeHead(409).end("Sign-in already completed.");
20160
- return;
20161
- }
20162
- if (!sameSecret(form.get("state"), state)) {
20163
- res.writeHead(400).end("Unknown sign-in.");
20164
- return;
20165
- }
20166
- const refreshToken = form.get("refresh_token");
20167
- if (!refreshToken) {
20168
- res.writeHead(400).end("Missing refresh_token.");
20169
- return;
20170
- }
20171
- finish(
20172
- (signal) => options.redeemRefreshToken(refreshToken, signal),
20173
- answerWith(res, 303)
20174
- );
20175
- },
20176
- () => {
20177
- if (!res.headersSent) res.writeHead(413).end();
20178
- }
20179
- );
20180
- return;
20181
- }
20182
- res.writeHead(405).end();
20183
- };
20184
- const server = http.createServer({ keepAlive: false }, handler);
20185
- await new Promise((resolve6, reject) => {
20186
- server.once("error", reject);
20187
- server.listen(options.port, "127.0.0.1", () => resolve6());
20188
- });
20189
- const { port } = server.address();
20190
- const timer = setTimeout(() => {
20191
- end(
20192
- new Error(
20193
- `Sign-in timed out after ${OAUTH_SIGN_IN_TIMEOUT_MS / 6e4} minutes. Run the login again.`
20194
- )
20195
- );
20196
- }, OAUTH_SIGN_IN_TIMEOUT_MS);
20197
- timer.unref();
20198
- const loopback = new URL(`http://127.0.0.1:${port}/`);
20199
- loopback.searchParams.set("state", state);
20200
- const pasteRedirect = (address) => {
20201
- if (claimed) return false;
20202
- let url;
20203
- try {
20204
- url = new URL(address.trim());
20205
- } catch {
20206
- return false;
20207
- }
20208
- if (url.origin !== loopback.origin || url.pathname !== loopback.pathname || !sameSecret(url.searchParams.get("state"), state) || !(url.searchParams.get("code") || url.searchParams.get("error") || url.searchParams.get("error_description"))) {
20209
- return false;
20210
- }
20211
- finish(redeemRedirect(url.searchParams));
20212
- return true;
20213
- };
20214
- const cancel = () => {
20215
- end(new Error("Sign-in cancelled."));
20216
- };
20217
- return {
20218
- state,
20219
- port,
20220
- redirectTo: loopback.toString(),
20221
- done,
20222
- pasteRedirect,
20223
- cancel,
20224
- close: () => {
20225
- claimed = true;
20226
- clearTimeout(timer);
20227
- server.close();
20228
- server.closeAllConnections?.();
20229
- }
20230
- };
20231
- }
20232
- async function startBrowserSignIn(options) {
20233
- const { verifier, challenge } = createPkcePair();
20234
- const receiver = await startLoopbackReceiver({
20235
- port: options.port ?? gotrueCallbackPort(),
20236
- pageUrl: options.pageUrl,
20237
- redeemCode: (code, signal) => gotrueToken(
20238
- options.authUrl,
20239
- "pkce",
20240
- { auth_code: code, code_verifier: verifier },
20241
- signal
20242
- ),
20243
- redeemRefreshToken: (refreshToken, signal) => gotrueToken(
20244
- options.authUrl,
20245
- "refresh_token",
20246
- { refresh_token: refreshToken },
20247
- signal
20248
- )
20249
- });
20250
- let url;
20251
- if (options.oauthProvider) {
20252
- url = gotrueAuthorizeUrl(
20253
- options.authUrl,
20254
- options.oauthProvider,
20255
- receiver.redirectTo,
20256
- challenge
20257
- );
20258
- } else {
20259
- const page = new URL(options.pageUrl);
20260
- page.searchParams.set("version", options.version);
20261
- page.searchParams.set("port", String(receiver.port));
20262
- page.searchParams.set("code_challenge", challenge);
20263
- page.searchParams.set("state", receiver.state);
20264
- url = page.toString();
20265
- }
20266
- return {
20267
- url,
20268
- done: receiver.done.finally(receiver.close),
20269
- pasteRedirect: receiver.pasteRedirect,
20270
- cancel: receiver.cancel
20271
- };
20272
- }
20273
- var BEARER_TYPE_HEADER, IDENTITY_BEARER_TYPE, IDENTITY_AUTH_TYPE, GOTRUE_OAUTH_PROVIDERS, LEGACY_SIGN_IN_MESSAGE, base64url, OAUTH_SIGN_IN_TIMEOUT_MS, MAX_FORM_BYTES;
20032
+ var BEARER_TYPE_HEADER, IDENTITY_BEARER_TYPE, IDENTITY_AUTH_TYPE, LEGACY_SIGN_IN_MESSAGE;
20274
20033
  var init_identity = __esm({
20275
20034
  "src/mcp/auth/identity.ts"() {
20276
20035
  "use strict";
@@ -20278,11 +20037,7 @@ var init_identity = __esm({
20278
20037
  BEARER_TYPE_HEADER = "Grpc-Metadata-X-Authorization-Bearer-Type";
20279
20038
  IDENTITY_BEARER_TYPE = "supabase";
20280
20039
  IDENTITY_AUTH_TYPE = "AUTH_TYPE_SUPABASE";
20281
- GOTRUE_OAUTH_PROVIDERS = ["google", "github", "azure"];
20282
20040
  LEGACY_SIGN_IN_MESSAGE = "Your saved sign-in comes from an older Inworld CLI and no longer works. Run `inworld login` to sign in again.";
20283
- base64url = (buf) => buf.toString("base64").replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
20284
- OAUTH_SIGN_IN_TIMEOUT_MS = 5 * 60 * 1e3;
20285
- MAX_FORM_BYTES = 16 * 1024;
20286
20041
  }
20287
20042
  });
20288
20043
 
@@ -20312,7 +20067,7 @@ function extractGatewayErrorMessage(data, fallback) {
20312
20067
  return fallback;
20313
20068
  }
20314
20069
  async function exchangeIdentityToken(identityToken) {
20315
- const base = PLATFORM_URL2.replace(/\/$/, "");
20070
+ const base = PLATFORM_URL.replace(/\/$/, "");
20316
20071
  const url = `${base}/v1alpha/users:generateTokenUser`;
20317
20072
  const body = JSON.stringify({
20318
20073
  type: IDENTITY_AUTH_TYPE,
@@ -20361,7 +20116,7 @@ var init_exchange = __esm({
20361
20116
  "src/mcp/auth/exchange.ts"() {
20362
20117
  "use strict";
20363
20118
  init_client_info();
20364
- init_constants6();
20119
+ init_constants5();
20365
20120
  init_identity();
20366
20121
  }
20367
20122
  });
@@ -20498,6 +20253,7 @@ async function hydrateMcpSessionFromCliStore() {
20498
20253
  identityRefreshToken: rt.refreshToken,
20499
20254
  authProvider: "supabase",
20500
20255
  authUrl: source.authUrl,
20256
+ ...source.clientId ? { authClientId: source.clientId } : {},
20501
20257
  email: c3.email ?? exchanged.email
20502
20258
  };
20503
20259
  return await saveSessionUnlessLoggedOut(merged) ? merged : null;
@@ -20764,7 +20520,7 @@ var init_runtime_credential = __esm({
20764
20520
  "src/auth/runtime_credential.ts"() {
20765
20521
  "use strict";
20766
20522
  init_dist4();
20767
- init_constants5();
20523
+ init_constants6();
20768
20524
  init_client_info();
20769
20525
  init_tokens_pb();
20770
20526
  RuntimeCredentialError = class extends Error {
@@ -23077,9 +22833,9 @@ var require_adm_zip = __commonJS({
23077
22833
  }
23078
22834
  zipPath = zipPath ? fixPath(zipPath) : "";
23079
22835
  if (namefix == "latin1") {
23080
- namefix = (str) => str.normalize("NFD").replace(/[\u0300-\u036f]/g, "").replace(/[^\x20-\x7E]/g, "");
22836
+ namefix = (str2) => str2.normalize("NFD").replace(/[\u0300-\u036f]/g, "").replace(/[^\x20-\x7E]/g, "");
23081
22837
  }
23082
- if (typeof namefix !== "function") namefix = (str) => str;
22838
+ if (typeof namefix !== "function") namefix = (str2) => str2;
23083
22839
  const relPathFix = (entry) => pth.join(zipPath, namefix(relativePath(localPath, entry)));
23084
22840
  const fileNameFix = (entry) => pth.win32.basename(pth.win32.normalize(namefix(entry)));
23085
22841
  filetools.fs.open(localPath, "r", function(err) {
@@ -23961,6 +23717,11 @@ async function openInBrowser(url) {
23961
23717
  await execFileAsync("xdg-open", [url]);
23962
23718
  }
23963
23719
  }
23720
+ function hasLocalBrowser(env3 = process.env, platform2 = process.platform) {
23721
+ if (env3.SSH_CONNECTION || env3.SSH_CLIENT || env3.SSH_TTY) return false;
23722
+ if (platform2 === "linux") return Boolean(env3.DISPLAY || env3.WAYLAND_DISPLAY);
23723
+ return true;
23724
+ }
23964
23725
  var execFileAsync;
23965
23726
  var init_browser = __esm({
23966
23727
  "src/mcp/auth/browser.ts"() {
@@ -23971,17 +23732,8 @@ var init_browser = __esm({
23971
23732
 
23972
23733
  // src/mcp/auth/sign_in_prompt.ts
23973
23734
  import * as readline2 from "node:readline";
23974
- async function promptForSignIn(signIn2, out) {
23975
- const { url, done, pasteRedirect, cancel } = signIn2;
23976
- const printLink2 = out.printLink ?? out.print;
23977
- const printError2 = out.printError ?? out.print;
23978
- out.print("Please visit the following URL to authenticate:");
23979
- printLink2(url);
23980
- out.print("");
23981
- out.print(
23982
- "Browser on another machine? Sign in there with Google, GitHub, Microsoft or SSO. It then fails to load an http://127.0.0.1 address: copy that address and paste it here. Email sign-in needs a browser on this machine."
23983
- );
23984
- out.print("");
23735
+ function promptToOpenBrowser(options) {
23736
+ const { url, out, onCancel } = options;
23985
23737
  const terminal = readline2.createInterface({
23986
23738
  input: process.stdin,
23987
23739
  output: out.output
@@ -23992,47 +23744,34 @@ async function promptForSignIn(signIn2, out) {
23992
23744
  closed = true;
23993
23745
  });
23994
23746
  terminal.on("SIGINT", () => {
23995
- cancel();
23747
+ onCancel();
23996
23748
  terminal.close();
23997
23749
  });
23998
- const ask = (prompt) => {
23750
+ const ask = () => {
23999
23751
  if (closed) return;
24000
- terminal.setPrompt(prompt);
23752
+ terminal.setPrompt("Press Enter to open the link in your browser: ");
24001
23753
  terminal.prompt();
24002
23754
  };
24003
23755
  terminal.on("line", async (line) => {
24004
- const address = line.trim();
24005
- if (!address) {
24006
- if (!opened) {
24007
- opened = true;
24008
- try {
24009
- await openInBrowser(url);
24010
- out.print("\u2713 Browser opened");
24011
- } catch {
24012
- out.print(
24013
- "\u26A0 Could not open browser automatically. Please open the URL manually."
24014
- );
24015
- }
24016
- out.print("");
24017
- out.print("Waiting for authentication...");
24018
- }
24019
- ask("Paste the address here if the browser could not load it: ");
24020
- return;
23756
+ if (line.trim()) return ask();
23757
+ if (opened) return;
23758
+ opened = true;
23759
+ try {
23760
+ await openInBrowser(url);
23761
+ out.print("\u2713 Browser opened");
23762
+ } catch {
23763
+ out.print(
23764
+ "\u26A0 Could not open browser automatically. Please open the link manually."
23765
+ );
24021
23766
  }
24022
- if (pasteRedirect(address)) {
24023
- out.print("Finishing sign-in...");
23767
+ out.print("Waiting for you to approve the sign-in...");
23768
+ });
23769
+ ask();
23770
+ return {
23771
+ close: () => {
24024
23772
  terminal.close();
24025
- return;
24026
23773
  }
24027
- printError2(
24028
- "That is not this sign-in's address. Paste the whole address from the browser's address bar; it starts with http://127.0.0.1:"
24029
- );
24030
- ask("Paste the address: ");
24031
- });
24032
- ask("Press Enter to open your browser, or paste the address: ");
24033
- await done.catch(() => {
24034
- });
24035
- terminal.close();
23774
+ };
24036
23775
  }
24037
23776
  var init_sign_in_prompt = __esm({
24038
23777
  "src/mcp/auth/sign_in_prompt.ts"() {
@@ -24041,6 +23780,255 @@ var init_sign_in_prompt = __esm({
24041
23780
  }
24042
23781
  });
24043
23782
 
23783
+ // src/mcp/auth/device_flow.ts
23784
+ function validateVerificationUri(value, expected, allowHttpLoopback) {
23785
+ const address = str(value);
23786
+ const invalid = () => new Error("Device authorization returned an invalid verification address.");
23787
+ if (!address || !/^https?:\/\//i.test(address)) throw invalid();
23788
+ let url;
23789
+ try {
23790
+ url = new URL(address);
23791
+ } catch {
23792
+ throw invalid();
23793
+ }
23794
+ const loopback = url.hostname === "localhost" || url.hostname === "[::1]" || /^127(?:\.\d{1,3}){3}$/.test(url.hostname);
23795
+ if (url.username || url.password || url.href !== expected.href || url.protocol !== "https:" && !(allowHttpLoopback && loopback)) {
23796
+ throw invalid();
23797
+ }
23798
+ return url.href;
23799
+ }
23800
+ async function postFormJson(url, form, signal) {
23801
+ signal.throwIfAborted();
23802
+ const own = new AbortController();
23803
+ const abort = () => own.abort();
23804
+ const timer = setTimeout(abort, REQUEST_TIMEOUT_MS);
23805
+ signal.addEventListener("abort", abort, { once: true });
23806
+ try {
23807
+ const res = await postForm(url, form, own.signal);
23808
+ const { data } = await readJsonBody(res);
23809
+ return { res, data };
23810
+ } finally {
23811
+ clearTimeout(timer);
23812
+ signal.removeEventListener("abort", abort);
23813
+ }
23814
+ }
23815
+ function sleep(ms, signal) {
23816
+ return new Promise((resolve6, reject) => {
23817
+ if (signal.aborted) return reject(new Error(CANCELLED));
23818
+ const done = () => {
23819
+ signal.removeEventListener("abort", cancel);
23820
+ resolve6();
23821
+ };
23822
+ const cancel = () => {
23823
+ clearTimeout(timer);
23824
+ reject(new Error(CANCELLED));
23825
+ };
23826
+ const timer = setTimeout(done, ms);
23827
+ signal.addEventListener("abort", cancel, { once: true });
23828
+ });
23829
+ }
23830
+ async function requestDeviceAuthorization(source, platformUrl, clientId, allowHttpLoopback, signal) {
23831
+ let res;
23832
+ let data;
23833
+ try {
23834
+ ({ res, data } = await postFormJson(
23835
+ `${source.authUrl}/oauth/device_authorization`,
23836
+ { client_id: clientId, scope: "offline_access" },
23837
+ signal
23838
+ ));
23839
+ } catch (error2) {
23840
+ if (signal.aborted) throw new Error(CANCELLED);
23841
+ const message = error2 instanceof Error ? error2.message : String(error2);
23842
+ const cause = error2 instanceof Error ? error2.cause : void 0;
23843
+ let detail = "";
23844
+ if (cause instanceof Error) {
23845
+ const { code } = cause;
23846
+ detail = (typeof code === "string" && code ? code : cause.message).replace(/\s+/g, " ").trim();
23847
+ }
23848
+ throw new Error(
23849
+ `Could not reach the sign-in server: ${message.replace(/\s+/g, " ")}${detail ? ` (${detail})` : ""}`
23850
+ );
23851
+ }
23852
+ if (!res.ok) {
23853
+ throw new Error(
23854
+ `Device authorization failed: ${gotrueErrorMessage(data, `HTTP ${res.status}`)}`
23855
+ );
23856
+ }
23857
+ const o2 = data ?? {};
23858
+ const deviceCode = str(o2.device_code);
23859
+ const userCode = str(o2.user_code);
23860
+ if (!deviceCode || !userCode || !str(o2.verification_uri)) {
23861
+ throw new Error(
23862
+ "Device authorization response is missing the device code, user code or verification address."
23863
+ );
23864
+ }
23865
+ const expectedUri = new URL("/cli/activate", platformUrl);
23866
+ const expectedCompleteUri = new URL(expectedUri);
23867
+ expectedCompleteUri.searchParams.set("user_code", userCode);
23868
+ const verificationUriComplete = o2.verification_uri_complete;
23869
+ return {
23870
+ deviceCode,
23871
+ userCode,
23872
+ verificationUri: validateVerificationUri(
23873
+ o2.verification_uri,
23874
+ expectedUri,
23875
+ allowHttpLoopback
23876
+ ),
23877
+ verificationUriComplete: verificationUriComplete == null || verificationUriComplete === "" ? void 0 : validateVerificationUri(
23878
+ verificationUriComplete,
23879
+ expectedCompleteUri,
23880
+ allowHttpLoopback
23881
+ ),
23882
+ expiresIn: positive(o2.expires_in) ?? DEFAULT_EXPIRES_IN_S,
23883
+ interval: positive(o2.interval) ?? DEFAULT_INTERVAL_S
23884
+ };
23885
+ }
23886
+ function expiryText(seconds) {
23887
+ if (seconds < 60) {
23888
+ const n3 = Math.round(seconds);
23889
+ return `${n3} second${n3 === 1 ? "" : "s"}`;
23890
+ }
23891
+ const n2 = Math.round(seconds / 60);
23892
+ return `${n2} minute${n2 === 1 ? "" : "s"}`;
23893
+ }
23894
+ function showDeviceCode(auth, out) {
23895
+ const printLink2 = out.printLink ?? out.print;
23896
+ out.print(
23897
+ `To sign in, open ${auth.verificationUri} and enter the code ${auth.userCode}`
23898
+ );
23899
+ if (auth.verificationUriComplete) {
23900
+ out.print("Or open this link, which already has the code in it:");
23901
+ printLink2(auth.verificationUriComplete);
23902
+ }
23903
+ out.print("");
23904
+ out.print(`The code expires in ${expiryText(auth.expiresIn)}.`);
23905
+ out.print("No browser here? Open the link on any device.");
23906
+ out.print("");
23907
+ }
23908
+ async function pollForTokens(source, clientId, auth, signal) {
23909
+ const deadline = Date.now() + auth.expiresIn * 1e3;
23910
+ let intervalS = auth.interval;
23911
+ let failures = 0;
23912
+ let replyMayBeLost = false;
23913
+ for (; ; ) {
23914
+ const backoffMs = failures ? Math.min(2 ** failures * 1e3, MAX_BACKOFF_MS) : 0;
23915
+ const waitMs = intervalS * 1e3 + backoffMs;
23916
+ await sleep(Math.min(waitMs, Math.max(0, deadline - Date.now())), signal);
23917
+ if (Date.now() >= deadline) throw new Error(EXPIRED);
23918
+ let res;
23919
+ let data;
23920
+ try {
23921
+ ({ res, data } = await postFormJson(
23922
+ `${source.authUrl}/oauth/token`,
23923
+ {
23924
+ grant_type: DEVICE_GRANT,
23925
+ device_code: auth.deviceCode,
23926
+ client_id: clientId
23927
+ },
23928
+ signal
23929
+ ));
23930
+ } catch {
23931
+ if (signal.aborted) throw new Error(CANCELLED);
23932
+ replyMayBeLost = true;
23933
+ failures++;
23934
+ continue;
23935
+ }
23936
+ if (res.ok) return identityTokensOf(data, "Sign-in");
23937
+ if (res.status >= 500 || res.status === 429) {
23938
+ replyMayBeLost ||= res.status >= 500;
23939
+ failures++;
23940
+ continue;
23941
+ }
23942
+ failures = 0;
23943
+ const error2 = str(data?.error);
23944
+ if (error2 === "invalid_grant" && replyMayBeLost) {
23945
+ throw new Error(
23946
+ "The sign-in may have completed but its reply was lost. Run `inworld login` again."
23947
+ );
23948
+ }
23949
+ switch (error2) {
23950
+ case "authorization_pending":
23951
+ replyMayBeLost = false;
23952
+ break;
23953
+ case "slow_down":
23954
+ replyMayBeLost = false;
23955
+ intervalS += SLOW_DOWN_STEP_S;
23956
+ break;
23957
+ case "access_denied":
23958
+ throw new Error("Sign-in was denied in the browser.");
23959
+ case "expired_token":
23960
+ throw new Error(EXPIRED);
23961
+ default:
23962
+ throw new Error(
23963
+ gotrueErrorMessage(data, `Sign-in failed (HTTP ${res.status}).`)
23964
+ );
23965
+ }
23966
+ }
23967
+ }
23968
+ async function signInWithDeviceCode(options) {
23969
+ const { source, platformUrl, clientId, env: env3, out } = options;
23970
+ if (!clientId) {
23971
+ throw new Error(
23972
+ "Set INWORLD_CLI_CLIENT_ID to the deployment's OAuth client id when overriding INWORLD_PLATFORM_URL or INWORLD_AUTH_URL."
23973
+ );
23974
+ }
23975
+ if (clientId === CLIENT_ID_PLACEHOLDER) {
23976
+ throw new Error(
23977
+ `Sign-in is not available yet: no OAuth client id is registered for ${env3}. Set INWORLD_CLI_CLIENT_ID to the CLI's client id for this deployment.`
23978
+ );
23979
+ }
23980
+ const cancel = new AbortController();
23981
+ const onSigint = () => cancel.abort();
23982
+ process.on("SIGINT", onSigint);
23983
+ const onCallerAbort = () => cancel.abort();
23984
+ options.signal?.addEventListener("abort", onCallerAbort, { once: true });
23985
+ if (options.signal?.aborted) cancel.abort();
23986
+ let prompt;
23987
+ try {
23988
+ const auth = await requestDeviceAuthorization(
23989
+ source,
23990
+ platformUrl,
23991
+ clientId,
23992
+ env3.toUpperCase() === "DEV",
23993
+ cancel.signal
23994
+ );
23995
+ showDeviceCode(auth, out);
23996
+ const interactive = options.interactive ?? Boolean(process.stdin.isTTY && process.stdout.isTTY);
23997
+ if (interactive && hasLocalBrowser()) {
23998
+ prompt = promptToOpenBrowser({
23999
+ url: auth.verificationUriComplete ?? auth.verificationUri,
24000
+ out,
24001
+ onCancel: () => cancel.abort()
24002
+ });
24003
+ }
24004
+ return await pollForTokens(source, clientId, auth, cancel.signal);
24005
+ } finally {
24006
+ prompt?.close();
24007
+ process.off("SIGINT", onSigint);
24008
+ options.signal?.removeEventListener("abort", onCallerAbort);
24009
+ }
24010
+ }
24011
+ var DEVICE_GRANT, DEFAULT_INTERVAL_S, SLOW_DOWN_STEP_S, DEFAULT_EXPIRES_IN_S, REQUEST_TIMEOUT_MS, MAX_BACKOFF_MS, CANCELLED, EXPIRED, str, positive;
24012
+ var init_device_flow = __esm({
24013
+ "src/mcp/auth/device_flow.ts"() {
24014
+ "use strict";
24015
+ init_browser();
24016
+ init_constants5();
24017
+ init_identity();
24018
+ init_sign_in_prompt();
24019
+ DEVICE_GRANT = "urn:ietf:params:oauth:grant-type:device_code";
24020
+ DEFAULT_INTERVAL_S = 5;
24021
+ SLOW_DOWN_STEP_S = 5;
24022
+ DEFAULT_EXPIRES_IN_S = 900;
24023
+ REQUEST_TIMEOUT_MS = 15e3;
24024
+ MAX_BACKOFF_MS = 3e4;
24025
+ CANCELLED = "Sign-in cancelled.";
24026
+ EXPIRED = "The code expired. Run `inworld login` again.";
24027
+ str = (v) => typeof v === "string" && v ? v : void 0;
24028
+ positive = (v) => typeof v === "number" && Number.isFinite(v) && v > 0 ? v : void 0;
24029
+ }
24030
+ });
24031
+
24044
24032
  // ../../node_modules/ms/index.js
24045
24033
  var require_ms = __commonJS({
24046
24034
  "../../node_modules/ms/index.js"(exports, module) {
@@ -24062,13 +24050,13 @@ var require_ms = __commonJS({
24062
24050
  "val is not a non-empty string or a valid number. val=" + JSON.stringify(val)
24063
24051
  );
24064
24052
  };
24065
- function parse3(str) {
24066
- str = String(str);
24067
- if (str.length > 100) {
24053
+ function parse3(str2) {
24054
+ str2 = String(str2);
24055
+ if (str2.length > 100) {
24068
24056
  return;
24069
24057
  }
24070
24058
  var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(
24071
- str
24059
+ str2
24072
24060
  );
24073
24061
  if (!match) {
24074
24062
  return;
@@ -24784,7 +24772,7 @@ var require_node = __commonJS({
24784
24772
  var { formatters } = module.exports;
24785
24773
  formatters.o = function(v) {
24786
24774
  this.inspectOpts.colors = this.useColors;
24787
- return util2.inspect(v, this.inspectOpts).split("\n").map((str) => str.trim()).join(" ");
24775
+ return util2.inspect(v, this.inspectOpts).split("\n").map((str2) => str2.trim()).join(" ");
24788
24776
  };
24789
24777
  formatters.O = function(v) {
24790
24778
  this.inspectOpts.colors = this.useColors;
@@ -25960,7 +25948,7 @@ var require_mixpanel_node = __commonJS({
25960
25948
  "../../node_modules/mixpanel/lib/mixpanel-node.js"(exports, module) {
25961
25949
  var querystring = __require("querystring");
25962
25950
  var Buffer5 = __require("buffer").Buffer;
25963
- var http2 = __require("http");
25951
+ var http = __require("http");
25964
25952
  var https = __require("https");
25965
25953
  var HttpsProxyAgent = require_dist2();
25966
25954
  var url = __require("url");
@@ -25991,9 +25979,9 @@ var require_mixpanel_node = __commonJS({
25991
25979
  };
25992
25980
  const { keepAlive } = metrics.config;
25993
25981
  const MAX_BATCH_SIZE = 50;
25994
- const REQUEST_LIBS = { http: http2, https };
25982
+ const REQUEST_LIBS = { http, https };
25995
25983
  const REQUEST_AGENTS = {
25996
- http: new http2.Agent({ keepAlive }),
25984
+ http: new http.Agent({ keepAlive }),
25997
25985
  https: new https.Agent({ keepAlive })
25998
25986
  };
25999
25987
  const proxyPath = process.env.HTTPS_PROXY || process.env.HTTP_PROXY;
@@ -26219,8 +26207,8 @@ var require_depd = __commonJS({
26219
26207
  var relative = __require("path").relative;
26220
26208
  module.exports = depd;
26221
26209
  var basePath = process.cwd();
26222
- function containsNamespace(str, namespace) {
26223
- var vals = str.split(/[ ,]+/);
26210
+ function containsNamespace(str2, namespace) {
26211
+ var vals = str2.split(/[ ,]+/);
26224
26212
  var ns = String(namespace).toLowerCase();
26225
26213
  for (var i2 = 0; i2 < vals.length; i2++) {
26226
26214
  var val = vals[i2];
@@ -26247,21 +26235,21 @@ var require_depd = __commonJS({
26247
26235
  return descriptor;
26248
26236
  }
26249
26237
  function createArgumentsString(arity) {
26250
- var str = "";
26238
+ var str2 = "";
26251
26239
  for (var i2 = 0; i2 < arity; i2++) {
26252
- str += ", arg" + i2;
26240
+ str2 += ", arg" + i2;
26253
26241
  }
26254
- return str.substr(2);
26242
+ return str2.substr(2);
26255
26243
  }
26256
26244
  function createStackString(stack) {
26257
- var str = this.name + ": " + this.namespace;
26245
+ var str2 = this.name + ": " + this.namespace;
26258
26246
  if (this.message) {
26259
- str += " deprecated " + this.message;
26247
+ str2 += " deprecated " + this.message;
26260
26248
  }
26261
26249
  for (var i2 = 0; i2 < stack.length; i2++) {
26262
- str += "\n at " + stack[i2].toString();
26250
+ str2 += "\n at " + stack[i2].toString();
26263
26251
  }
26264
- return str;
26252
+ return str2;
26265
26253
  }
26266
26254
  function depd(namespace) {
26267
26255
  if (!namespace) {
@@ -26290,15 +26278,15 @@ var require_depd = __commonJS({
26290
26278
  if (process.noDeprecation) {
26291
26279
  return true;
26292
26280
  }
26293
- var str = process.env.NO_DEPRECATION || "";
26294
- return containsNamespace(str, namespace);
26281
+ var str2 = process.env.NO_DEPRECATION || "";
26282
+ return containsNamespace(str2, namespace);
26295
26283
  }
26296
26284
  function istraced(namespace) {
26297
26285
  if (process.traceDeprecation) {
26298
26286
  return true;
26299
26287
  }
26300
- var str = process.env.TRACE_DEPRECATION || "";
26301
- return containsNamespace(str, namespace);
26288
+ var str2 = process.env.TRACE_DEPRECATION || "";
26289
+ return containsNamespace(str2, namespace);
26302
26290
  }
26303
26291
  function log(message, site) {
26304
26292
  var haslisteners = eehaslisteners(process, "deprecation");
@@ -26732,8 +26720,8 @@ var require_toidentifier = __commonJS({
26732
26720
  "../../node_modules/toidentifier/index.js"(exports, module) {
26733
26721
  "use strict";
26734
26722
  module.exports = toIdentifier;
26735
- function toIdentifier(str) {
26736
- return str.split(" ").map(function(token) {
26723
+ function toIdentifier(str2) {
26724
+ return str2.split(" ").map(function(token) {
26737
26725
  return token.slice(0, 1).toUpperCase() + token.slice(1);
26738
26726
  }).join("").replace(/[^ _0-9a-z]/gi, "");
26739
26727
  }
@@ -26957,16 +26945,16 @@ var require_bytes = __commonJS({
26957
26945
  }
26958
26946
  }
26959
26947
  var val = value / map[unit.toLowerCase()];
26960
- var str = val.toFixed(decimalPlaces);
26948
+ var str2 = val.toFixed(decimalPlaces);
26961
26949
  if (!fixedDecimals) {
26962
- str = str.replace(formatDecimalsRegExp, "$1");
26950
+ str2 = str2.replace(formatDecimalsRegExp, "$1");
26963
26951
  }
26964
26952
  if (thousandsSeparator) {
26965
- str = str.split(".").map(function(s, i2) {
26953
+ str2 = str2.split(".").map(function(s, i2) {
26966
26954
  return i2 === 0 ? s.replace(formatThousandsRegExp, thousandsSeparator) : s;
26967
26955
  }).join(".");
26968
26956
  }
26969
- return str + unitSeparator + unit;
26957
+ return str2 + unitSeparator + unit;
26970
26958
  }
26971
26959
  function parse3(val) {
26972
26960
  if (typeof val === "number" && !isNaN(val)) {
@@ -27071,12 +27059,12 @@ var require_bom_handling = __commonJS({
27071
27059
  this.encoder = encoder;
27072
27060
  this.addBOM = true;
27073
27061
  }
27074
- PrependBOMWrapper.prototype.write = function(str) {
27062
+ PrependBOMWrapper.prototype.write = function(str2) {
27075
27063
  if (this.addBOM) {
27076
- str = BOMChar + str;
27064
+ str2 = BOMChar + str2;
27077
27065
  this.addBOM = false;
27078
27066
  }
27079
- return this.encoder.write(str);
27067
+ return this.encoder.write(str2);
27080
27068
  };
27081
27069
  PrependBOMWrapper.prototype.end = function() {
27082
27070
  return this.encoder.end();
@@ -27175,31 +27163,31 @@ var require_internal = __commonJS({
27175
27163
  function InternalEncoder(options, codec) {
27176
27164
  this.enc = codec.enc;
27177
27165
  }
27178
- InternalEncoder.prototype.write = function(str) {
27179
- return Buffer5.from(str, this.enc);
27166
+ InternalEncoder.prototype.write = function(str2) {
27167
+ return Buffer5.from(str2, this.enc);
27180
27168
  };
27181
27169
  InternalEncoder.prototype.end = function() {
27182
27170
  };
27183
27171
  function InternalEncoderBase64(options, codec) {
27184
27172
  this.prevStr = "";
27185
27173
  }
27186
- InternalEncoderBase64.prototype.write = function(str) {
27187
- str = this.prevStr + str;
27188
- var completeQuads = str.length - str.length % 4;
27189
- this.prevStr = str.slice(completeQuads);
27190
- str = str.slice(0, completeQuads);
27191
- return Buffer5.from(str, "base64");
27174
+ InternalEncoderBase64.prototype.write = function(str2) {
27175
+ str2 = this.prevStr + str2;
27176
+ var completeQuads = str2.length - str2.length % 4;
27177
+ this.prevStr = str2.slice(completeQuads);
27178
+ str2 = str2.slice(0, completeQuads);
27179
+ return Buffer5.from(str2, "base64");
27192
27180
  };
27193
27181
  InternalEncoderBase64.prototype.end = function() {
27194
27182
  return Buffer5.from(this.prevStr, "base64");
27195
27183
  };
27196
27184
  function InternalEncoderCesu8(options, codec) {
27197
27185
  }
27198
- InternalEncoderCesu8.prototype.write = function(str) {
27199
- var buf = Buffer5.alloc(str.length * 3);
27186
+ InternalEncoderCesu8.prototype.write = function(str2) {
27187
+ var buf = Buffer5.alloc(str2.length * 3);
27200
27188
  var bufIdx = 0;
27201
- for (var i2 = 0; i2 < str.length; i2++) {
27202
- var charCode = str.charCodeAt(i2);
27189
+ for (var i2 = 0; i2 < str2.length; i2++) {
27190
+ var charCode = str2.charCodeAt(i2);
27203
27191
  if (charCode < 128) {
27204
27192
  buf[bufIdx++] = charCode;
27205
27193
  } else if (charCode < 2048) {
@@ -27280,25 +27268,25 @@ var require_internal = __commonJS({
27280
27268
  function InternalEncoderUtf8(options, codec) {
27281
27269
  this.highSurrogate = "";
27282
27270
  }
27283
- InternalEncoderUtf8.prototype.write = function(str) {
27271
+ InternalEncoderUtf8.prototype.write = function(str2) {
27284
27272
  if (this.highSurrogate) {
27285
- str = this.highSurrogate + str;
27273
+ str2 = this.highSurrogate + str2;
27286
27274
  this.highSurrogate = "";
27287
27275
  }
27288
- if (str.length > 0) {
27289
- var charCode = str.charCodeAt(str.length - 1);
27276
+ if (str2.length > 0) {
27277
+ var charCode = str2.charCodeAt(str2.length - 1);
27290
27278
  if (charCode >= 55296 && charCode < 56320) {
27291
- this.highSurrogate = str[str.length - 1];
27292
- str = str.slice(0, str.length - 1);
27279
+ this.highSurrogate = str2[str2.length - 1];
27280
+ str2 = str2.slice(0, str2.length - 1);
27293
27281
  }
27294
27282
  }
27295
- return Buffer5.from(str, this.enc);
27283
+ return Buffer5.from(str2, this.enc);
27296
27284
  };
27297
27285
  InternalEncoderUtf8.prototype.end = function() {
27298
27286
  if (this.highSurrogate) {
27299
- var str = this.highSurrogate;
27287
+ var str2 = this.highSurrogate;
27300
27288
  this.highSurrogate = "";
27301
- return Buffer5.from(str, this.enc);
27289
+ return Buffer5.from(str2, this.enc);
27302
27290
  }
27303
27291
  };
27304
27292
  }
@@ -27325,8 +27313,8 @@ var require_utf32 = __commonJS({
27325
27313
  this.isLE = codec.isLE;
27326
27314
  this.highSurrogate = 0;
27327
27315
  }
27328
- Utf32Encoder.prototype.write = function(str) {
27329
- var src = Buffer5.from(str, "ucs2");
27316
+ Utf32Encoder.prototype.write = function(str2) {
27317
+ var src = Buffer5.from(str2, "ucs2");
27330
27318
  var dst = Buffer5.alloc(src.length * 2);
27331
27319
  var write32 = this.isLE ? dst.writeUInt32LE : dst.writeUInt32BE;
27332
27320
  var offset = 0;
@@ -27447,8 +27435,8 @@ var require_utf32 = __commonJS({
27447
27435
  }
27448
27436
  this.encoder = codec.iconv.getEncoder(options.defaultEncoding || "utf-32le", options);
27449
27437
  }
27450
- Utf32AutoEncoder.prototype.write = function(str) {
27451
- return this.encoder.write(str);
27438
+ Utf32AutoEncoder.prototype.write = function(str2) {
27439
+ return this.encoder.write(str2);
27452
27440
  };
27453
27441
  Utf32AutoEncoder.prototype.end = function() {
27454
27442
  return this.encoder.end();
@@ -27548,8 +27536,8 @@ var require_utf16 = __commonJS({
27548
27536
  Utf16BECodec.prototype.bomAware = true;
27549
27537
  function Utf16BEEncoder() {
27550
27538
  }
27551
- Utf16BEEncoder.prototype.write = function(str) {
27552
- var buf = Buffer5.from(str, "ucs2");
27539
+ Utf16BEEncoder.prototype.write = function(str2) {
27540
+ var buf = Buffer5.from(str2, "ucs2");
27553
27541
  for (var i2 = 0; i2 < buf.length; i2 += 2) {
27554
27542
  var tmp = buf[i2];
27555
27543
  buf[i2] = buf[i2 + 1];
@@ -27598,8 +27586,8 @@ var require_utf16 = __commonJS({
27598
27586
  }
27599
27587
  this.encoder = codec.iconv.getEncoder("utf-16le", options);
27600
27588
  }
27601
- Utf16Encoder.prototype.write = function(str) {
27602
- return this.encoder.write(str);
27589
+ Utf16Encoder.prototype.write = function(str2) {
27590
+ return this.encoder.write(str2);
27603
27591
  };
27604
27592
  Utf16Encoder.prototype.end = function() {
27605
27593
  return this.encoder.end();
@@ -27695,8 +27683,8 @@ var require_utf7 = __commonJS({
27695
27683
  function Utf7Encoder(options, codec) {
27696
27684
  this.iconv = codec.iconv;
27697
27685
  }
27698
- Utf7Encoder.prototype.write = function(str) {
27699
- return Buffer5.from(str.replace(nonDirectChars, function(chunk) {
27686
+ Utf7Encoder.prototype.write = function(str2) {
27687
+ return Buffer5.from(str2.replace(nonDirectChars, function(chunk) {
27700
27688
  return "+" + (chunk === "+" ? "" : this.iconv.encode(chunk, "utf16-be").toString("base64").replace(/=+$/, "")) + "-";
27701
27689
  }.bind(this)));
27702
27690
  };
@@ -27780,14 +27768,14 @@ var require_utf7 = __commonJS({
27780
27768
  this.base64Accum = Buffer5.alloc(6);
27781
27769
  this.base64AccumIdx = 0;
27782
27770
  }
27783
- Utf7IMAPEncoder.prototype.write = function(str) {
27771
+ Utf7IMAPEncoder.prototype.write = function(str2) {
27784
27772
  var inBase64 = this.inBase64;
27785
27773
  var base64Accum = this.base64Accum;
27786
27774
  var base64AccumIdx = this.base64AccumIdx;
27787
- var buf = Buffer5.alloc(str.length * 5 + 10);
27775
+ var buf = Buffer5.alloc(str2.length * 5 + 10);
27788
27776
  var bufIdx = 0;
27789
- for (var i3 = 0; i3 < str.length; i3++) {
27790
- var uChar = str.charCodeAt(i3);
27777
+ for (var i3 = 0; i3 < str2.length; i3++) {
27778
+ var uChar = str2.charCodeAt(i3);
27791
27779
  if (uChar >= 32 && uChar <= 126) {
27792
27780
  if (inBase64) {
27793
27781
  if (base64AccumIdx > 0) {
@@ -27928,10 +27916,10 @@ var require_sbcs_codec = __commonJS({
27928
27916
  function SBCSEncoder(options, codec) {
27929
27917
  this.encodeBuf = codec.encodeBuf;
27930
27918
  }
27931
- SBCSEncoder.prototype.write = function(str) {
27932
- var buf = Buffer5.alloc(str.length);
27933
- for (var i2 = 0; i2 < str.length; i2++) {
27934
- buf[i2] = this.encodeBuf[str.charCodeAt(i2)];
27919
+ SBCSEncoder.prototype.write = function(str2) {
27920
+ var buf = Buffer5.alloc(str2.length);
27921
+ for (var i2 = 0; i2 < str2.length; i2++) {
27922
+ buf[i2] = this.encodeBuf[str2.charCodeAt(i2)];
27935
27923
  }
27936
27924
  return buf;
27937
27925
  };
@@ -28805,8 +28793,8 @@ var require_dbcs_codec = __commonJS({
28805
28793
  this.defaultCharSingleByte = codec.defCharSB;
28806
28794
  this.gb18030 = codec.gb18030;
28807
28795
  }
28808
- DBCSEncoder.prototype.write = function(str) {
28809
- var newBuf = Buffer5.alloc(str.length * (this.gb18030 ? 4 : 3));
28796
+ DBCSEncoder.prototype.write = function(str2) {
28797
+ var newBuf = Buffer5.alloc(str2.length * (this.gb18030 ? 4 : 3));
28810
28798
  var leadSurrogate = this.leadSurrogate;
28811
28799
  var seqObj = this.seqObj;
28812
28800
  var nextChar = -1;
@@ -28814,8 +28802,8 @@ var require_dbcs_codec = __commonJS({
28814
28802
  var j = 0;
28815
28803
  while (true) {
28816
28804
  if (nextChar === -1) {
28817
- if (i3 == str.length) break;
28818
- var uCode = str.charCodeAt(i3++);
28805
+ if (i3 == str2.length) break;
28806
+ var uCode = str2.charCodeAt(i3++);
28819
28807
  } else {
28820
28808
  var uCode = nextChar;
28821
28809
  nextChar = -1;
@@ -30653,10 +30641,10 @@ var require_lib = __commonJS({
30653
30641
  module.exports.encodings = null;
30654
30642
  module.exports.defaultCharUnicode = "\uFFFD";
30655
30643
  module.exports.defaultCharSingleByte = "?";
30656
- module.exports.encode = function encode(str, encoding, options) {
30657
- str = "" + (str || "");
30644
+ module.exports.encode = function encode(str2, encoding, options) {
30645
+ str2 = "" + (str2 || "");
30658
30646
  var encoder = module.exports.getEncoder(encoding, options);
30659
- var res = encoder.write(str);
30647
+ var res = encoder.write(str2);
30660
30648
  var trail = encoder.end();
30661
30649
  return trail && trail.length > 0 ? Buffer5.concat([res, trail]) : res;
30662
30650
  };
@@ -31250,14 +31238,14 @@ var require_content_type = __commonJS({
31250
31238
  return header;
31251
31239
  }
31252
31240
  function qstring(val) {
31253
- var str = String(val);
31254
- if (TOKEN_REGEXP.test(str)) {
31255
- return str;
31241
+ var str2 = String(val);
31242
+ if (TOKEN_REGEXP.test(str2)) {
31243
+ return str2;
31256
31244
  }
31257
- if (str.length > 0 && !TEXT_REGEXP.test(str)) {
31245
+ if (str2.length > 0 && !TEXT_REGEXP.test(str2)) {
31258
31246
  throw new TypeError("invalid parameter value");
31259
31247
  }
31260
- return '"' + str.replace(QUOTE_REGEXP, "\\$1") + '"';
31248
+ return '"' + str2.replace(QUOTE_REGEXP, "\\$1") + '"';
31261
31249
  }
31262
31250
  function ContentType(type) {
31263
31251
  this.parameters = /* @__PURE__ */ Object.create(null);
@@ -40697,11 +40685,11 @@ var require_mime_types = __commonJS({
40697
40685
  }
40698
40686
  return false;
40699
40687
  }
40700
- function contentType(str) {
40701
- if (!str || typeof str !== "string") {
40688
+ function contentType(str2) {
40689
+ if (!str2 || typeof str2 !== "string") {
40702
40690
  return false;
40703
40691
  }
40704
- var mime = str.indexOf("/") === -1 ? exports.lookup(str) : str;
40692
+ var mime = str2.indexOf("/") === -1 ? exports.lookup(str2) : str2;
40705
40693
  if (!mime) {
40706
40694
  return false;
40707
40695
  }
@@ -41082,14 +41070,14 @@ var require_read = __commonJS({
41082
41070
  return;
41083
41071
  }
41084
41072
  }
41085
- var str = body;
41073
+ var str2 = body;
41086
41074
  try {
41087
41075
  debug("parse body");
41088
- str = typeof body !== "string" && encoding !== null ? iconv.decode(body, encoding) : body;
41089
- req.body = parse3(str, encoding);
41076
+ str2 = typeof body !== "string" && encoding !== null ? iconv.decode(body, encoding) : body;
41077
+ req.body = parse3(str2, encoding);
41090
41078
  } catch (err) {
41091
41079
  next(createError(400, err, {
41092
- body: str,
41080
+ body: str2,
41093
41081
  type: err.type || "entity.parse.failed"
41094
41082
  }));
41095
41083
  return;
@@ -41189,11 +41177,11 @@ var require_json = __commonJS({
41189
41177
  read(req, res, next, parse3, debug, readOptions);
41190
41178
  };
41191
41179
  }
41192
- function createStrictSyntaxError(str, char) {
41193
- var index = str.indexOf(char);
41180
+ function createStrictSyntaxError(str2, char) {
41181
+ var index = str2.indexOf(char);
41194
41182
  var partial2 = "";
41195
41183
  if (index !== -1) {
41196
- partial2 = str.substring(0, index) + JSON_SYNTAX_CHAR.repeat(str.length - index);
41184
+ partial2 = str2.substring(0, index) + JSON_SYNTAX_CHAR.repeat(str2.length - index);
41197
41185
  }
41198
41186
  try {
41199
41187
  JSON.parse(partial2);
@@ -41201,14 +41189,14 @@ var require_json = __commonJS({
41201
41189
  } catch (e) {
41202
41190
  return normalizeJsonSyntaxError(e, {
41203
41191
  message: e.message.replace(JSON_SYNTAX_REGEXP, function(placeholder) {
41204
- return str.substring(index, index + placeholder.length);
41192
+ return str2.substring(index, index + placeholder.length);
41205
41193
  }),
41206
41194
  stack: e.stack
41207
41195
  });
41208
41196
  }
41209
41197
  }
41210
- function firstchar(str) {
41211
- var match = FIRST_CHAR_REGEXP.exec(str);
41198
+ function firstchar(str2) {
41199
+ var match = FIRST_CHAR_REGEXP.exec(str2);
41212
41200
  return match ? match[1] : void 0;
41213
41201
  }
41214
41202
  function normalizeJsonSyntaxError(error2, obj) {
@@ -41319,20 +41307,20 @@ var require_object_inspect = __commonJS({
41319
41307
  var gPO = (typeof Reflect === "function" ? Reflect.getPrototypeOf : Object.getPrototypeOf) || ([].__proto__ === Array.prototype ? function(O) {
41320
41308
  return O.__proto__;
41321
41309
  } : null);
41322
- function addNumericSeparator(num, str) {
41323
- if (num === Infinity || num === -Infinity || num !== num || num && num > -1e3 && num < 1e3 || $test.call(/e/, str)) {
41324
- return str;
41310
+ function addNumericSeparator(num, str2) {
41311
+ if (num === Infinity || num === -Infinity || num !== num || num && num > -1e3 && num < 1e3 || $test.call(/e/, str2)) {
41312
+ return str2;
41325
41313
  }
41326
41314
  var sepRegex = /[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;
41327
41315
  if (typeof num === "number") {
41328
41316
  var int2 = num < 0 ? -$floor(-num) : $floor(num);
41329
41317
  if (int2 !== num) {
41330
41318
  var intStr = String(int2);
41331
- var dec = $slice.call(str, intStr.length + 1);
41319
+ var dec = $slice.call(str2, intStr.length + 1);
41332
41320
  return $replace.call(intStr, sepRegex, "$&_") + "." + $replace.call($replace.call(dec, /([0-9]{3})/g, "$&_"), /_$/, "");
41333
41321
  }
41334
41322
  }
41335
- return $replace.call(str, sepRegex, "$&_");
41323
+ return $replace.call(str2, sepRegex, "$&_");
41336
41324
  }
41337
41325
  var utilInspect = require_util_inspect();
41338
41326
  var inspectCustom = utilInspect.custom;
@@ -41382,8 +41370,8 @@ var require_object_inspect = __commonJS({
41382
41370
  if (obj === 0) {
41383
41371
  return Infinity / obj > 0 ? "0" : "-0";
41384
41372
  }
41385
- var str = String(obj);
41386
- return numericSeparator ? addNumericSeparator(obj, str) : str;
41373
+ var str2 = String(obj);
41374
+ return numericSeparator ? addNumericSeparator(obj, str2) : str2;
41387
41375
  }
41388
41376
  if (typeof obj === "bigint") {
41389
41377
  var bigIntStr = String(obj) + "n";
@@ -41703,15 +41691,15 @@ var require_object_inspect = __commonJS({
41703
41691
  }
41704
41692
  return typeof x.nodeName === "string" && typeof x.getAttribute === "function";
41705
41693
  }
41706
- function inspectString(str, opts) {
41707
- if (str.length > opts.maxStringLength) {
41708
- var remaining = str.length - opts.maxStringLength;
41694
+ function inspectString(str2, opts) {
41695
+ if (str2.length > opts.maxStringLength) {
41696
+ var remaining = str2.length - opts.maxStringLength;
41709
41697
  var trailer = "... " + remaining + " more character" + (remaining > 1 ? "s" : "");
41710
- return inspectString($slice.call(str, 0, opts.maxStringLength), opts) + trailer;
41698
+ return inspectString($slice.call(str2, 0, opts.maxStringLength), opts) + trailer;
41711
41699
  }
41712
41700
  var quoteRE = quoteREs[opts.quoteStyle || "single"];
41713
41701
  quoteRE.lastIndex = 0;
41714
- var s = $replace.call($replace.call(str, quoteRE, "\\$1"), /[\x00-\x1f]/g, lowbyte);
41702
+ var s = $replace.call($replace.call(str2, quoteRE, "\\$1"), /[\x00-\x1f]/g, lowbyte);
41715
41703
  return wrapQuotes(s, "single", opts);
41716
41704
  }
41717
41705
  function lowbyte(c3) {
@@ -41728,8 +41716,8 @@ var require_object_inspect = __commonJS({
41728
41716
  }
41729
41717
  return "\\x" + (n2 < 16 ? "0" : "") + $toUpperCase.call(n2.toString(16));
41730
41718
  }
41731
- function markBoxed(str) {
41732
- return "Object(" + str + ")";
41719
+ function markBoxed(str2) {
41720
+ return "Object(" + str2 + ")";
41733
41721
  }
41734
41722
  function weakCollectionOf(type) {
41735
41723
  return type + " { ? }";
@@ -42194,14 +42182,14 @@ var require_implementation = __commonJS({
42194
42182
  return arr;
42195
42183
  };
42196
42184
  var joiny = function(arr, joiner) {
42197
- var str = "";
42185
+ var str2 = "";
42198
42186
  for (var i2 = 0; i2 < arr.length; i2 += 1) {
42199
- str += arr[i2];
42187
+ str2 += arr[i2];
42200
42188
  if (i2 + 1 < arr.length) {
42201
- str += joiner;
42189
+ str2 += joiner;
42202
42190
  }
42203
42191
  }
42204
- return str;
42192
+ return str2;
42205
42193
  };
42206
42194
  module.exports = function bind(that) {
42207
42195
  var target = this;
@@ -43055,8 +43043,8 @@ var require_utils5 = __commonJS({
43055
43043
  return acc;
43056
43044
  }, target);
43057
43045
  };
43058
- var decode = function(str, defaultDecoder, charset) {
43059
- var strWithoutPlus = str.replace(/\+/g, " ");
43046
+ var decode = function(str2, defaultDecoder, charset) {
43047
+ var strWithoutPlus = str2.replace(/\+/g, " ");
43060
43048
  if (charset === "iso-8859-1") {
43061
43049
  return strWithoutPlus.replace(/%[0-9a-f]{2}/gi, unescape);
43062
43050
  }
@@ -43067,15 +43055,15 @@ var require_utils5 = __commonJS({
43067
43055
  }
43068
43056
  };
43069
43057
  var limit = 1024;
43070
- var encode = function encode2(str, defaultEncoder, charset, kind, format2) {
43071
- if (str.length === 0) {
43072
- return str;
43058
+ var encode = function encode2(str2, defaultEncoder, charset, kind, format2) {
43059
+ if (str2.length === 0) {
43060
+ return str2;
43073
43061
  }
43074
- var string3 = str;
43075
- if (typeof str === "symbol") {
43076
- string3 = Symbol.prototype.toString.call(str);
43077
- } else if (typeof str !== "string") {
43078
- string3 = String(str);
43062
+ var string3 = str2;
43063
+ if (typeof str2 === "symbol") {
43064
+ string3 = Symbol.prototype.toString.call(str2);
43065
+ } else if (typeof str2 !== "string") {
43066
+ string3 = String(str2);
43079
43067
  }
43080
43068
  if (charset === "iso-8859-1") {
43081
43069
  return escape(string3).replace(/%u[0-9a-f]{4}/gi, function($0) {
@@ -43494,8 +43482,8 @@ var require_parse3 = __commonJS({
43494
43482
  strictNullHandling: false,
43495
43483
  throwOnLimitExceeded: false
43496
43484
  };
43497
- var interpretNumericEntities = function(str) {
43498
- return str.replace(/&#(\d+);/g, function($0, numberStr) {
43485
+ var interpretNumericEntities = function(str2) {
43486
+ return str2.replace(/&#(\d+);/g, function($0, numberStr) {
43499
43487
  return String.fromCharCode(parseInt(numberStr, 10));
43500
43488
  });
43501
43489
  };
@@ -43510,9 +43498,9 @@ var require_parse3 = __commonJS({
43510
43498
  };
43511
43499
  var isoSentinel = "utf8=%26%2310003%3B";
43512
43500
  var charsetSentinel = "utf8=%E2%9C%93";
43513
- var parseValues = function parseQueryStringValues(str, options) {
43501
+ var parseValues = function parseQueryStringValues(str2, options) {
43514
43502
  var obj = { __proto__: null };
43515
- var cleanStr = options.ignoreQueryPrefix ? str.replace(/^\?/, "") : str;
43503
+ var cleanStr = options.ignoreQueryPrefix ? str2.replace(/^\?/, "") : str2;
43516
43504
  cleanStr = cleanStr.replace(/%5B/gi, "[").replace(/%5D/gi, "]");
43517
43505
  var limit = options.parameterLimit === Infinity ? void 0 : options.parameterLimit;
43518
43506
  var parts = cleanStr.split(
@@ -43741,17 +43729,17 @@ var require_parse3 = __commonJS({
43741
43729
  throwOnLimitExceeded: typeof opts.throwOnLimitExceeded === "boolean" ? opts.throwOnLimitExceeded : false
43742
43730
  };
43743
43731
  };
43744
- module.exports = function(str, opts) {
43732
+ module.exports = function(str2, opts) {
43745
43733
  var options = normalizeParseOptions(opts);
43746
- if (str === "" || str === null || typeof str === "undefined") {
43734
+ if (str2 === "" || str2 === null || typeof str2 === "undefined") {
43747
43735
  return options.plainObjects ? { __proto__: null } : {};
43748
43736
  }
43749
- var tempObj = typeof str === "string" ? parseValues(str, options) : str;
43737
+ var tempObj = typeof str2 === "string" ? parseValues(str2, options) : str2;
43750
43738
  var obj = options.plainObjects ? { __proto__: null } : {};
43751
43739
  var keys = Object.keys(tempObj);
43752
43740
  for (var i2 = 0; i2 < keys.length; ++i2) {
43753
43741
  var key = keys[i2];
43754
- var newObj = parseKeys(key, tempObj[key], options, typeof str === "string");
43742
+ var newObj = parseKeys(key, tempObj[key], options, typeof str2 === "string");
43755
43743
  obj = utils.merge(obj, newObj, options);
43756
43744
  }
43757
43745
  if (options.allowSparse === true) {
@@ -43941,17 +43929,17 @@ var require_escape_html = __commonJS({
43941
43929
  var matchHtmlRegExp = /["'&<>]/;
43942
43930
  module.exports = escapeHtml;
43943
43931
  function escapeHtml(string3) {
43944
- var str = "" + string3;
43945
- var match = matchHtmlRegExp.exec(str);
43932
+ var str2 = "" + string3;
43933
+ var match = matchHtmlRegExp.exec(str2);
43946
43934
  if (!match) {
43947
- return str;
43935
+ return str2;
43948
43936
  }
43949
43937
  var escape2;
43950
43938
  var html = "";
43951
43939
  var index = 0;
43952
43940
  var lastIndex = 0;
43953
- for (index = match.index; index < str.length; index++) {
43954
- switch (str.charCodeAt(index)) {
43941
+ for (index = match.index; index < str2.length; index++) {
43942
+ switch (str2.charCodeAt(index)) {
43955
43943
  case 34:
43956
43944
  escape2 = "&quot;";
43957
43945
  break;
@@ -43971,12 +43959,12 @@ var require_escape_html = __commonJS({
43971
43959
  continue;
43972
43960
  }
43973
43961
  if (lastIndex !== index) {
43974
- html += str.substring(lastIndex, index);
43962
+ html += str2.substring(lastIndex, index);
43975
43963
  }
43976
43964
  lastIndex = index + 1;
43977
43965
  html += escape2;
43978
43966
  }
43979
- return lastIndex !== index ? html + str.substring(lastIndex, index) : html;
43967
+ return lastIndex !== index ? html + str2.substring(lastIndex, index) : html;
43980
43968
  }
43981
43969
  }
43982
43970
  });
@@ -44016,20 +44004,20 @@ var require_parseurl = __commonJS({
44016
44004
  parsed._raw = url2;
44017
44005
  return req._parsedOriginalUrl = parsed;
44018
44006
  }
44019
- function fastparse(str) {
44020
- if (typeof str !== "string" || str.charCodeAt(0) !== 47) {
44021
- return parse3(str);
44007
+ function fastparse(str2) {
44008
+ if (typeof str2 !== "string" || str2.charCodeAt(0) !== 47) {
44009
+ return parse3(str2);
44022
44010
  }
44023
- var pathname = str;
44011
+ var pathname = str2;
44024
44012
  var query = null;
44025
44013
  var search = null;
44026
- for (var i2 = 1; i2 < str.length; i2++) {
44027
- switch (str.charCodeAt(i2)) {
44014
+ for (var i2 = 1; i2 < str2.length; i2++) {
44015
+ switch (str2.charCodeAt(i2)) {
44028
44016
  case 63:
44029
44017
  if (search === null) {
44030
- pathname = str.substring(0, i2);
44031
- query = str.substring(i2 + 1);
44032
- search = str.substring(i2);
44018
+ pathname = str2.substring(0, i2);
44019
+ query = str2.substring(i2 + 1);
44020
+ search = str2.substring(i2);
44033
44021
  }
44034
44022
  break;
44035
44023
  case 9:
@@ -44046,12 +44034,12 @@ var require_parseurl = __commonJS({
44046
44034
  /* # */
44047
44035
  case 160:
44048
44036
  case 65279:
44049
- return parse3(str);
44037
+ return parse3(str2);
44050
44038
  }
44051
44039
  }
44052
44040
  var url2 = Url !== void 0 ? new Url() : {};
44053
- url2.path = str;
44054
- url2.href = str;
44041
+ url2.path = str2;
44042
+ url2.href = str2;
44055
44043
  url2.pathname = pathname;
44056
44044
  if (search !== null) {
44057
44045
  url2.query = query;
@@ -45064,11 +45052,11 @@ var require_proxy_addr = __commonJS({
45064
45052
  }
45065
45053
  function parseipNotation(note) {
45066
45054
  var pos = note.lastIndexOf("/");
45067
- var str = pos !== -1 ? note.substring(0, pos) : note;
45068
- if (!isip(str)) {
45069
- throw new TypeError("invalid IP address: " + str);
45055
+ var str2 = pos !== -1 ? note.substring(0, pos) : note;
45056
+ if (!isip(str2)) {
45057
+ throw new TypeError("invalid IP address: " + str2);
45070
45058
  }
45071
- var ip = parseip(str);
45059
+ var ip = parseip(str2);
45072
45060
  if (pos === -1 && ip.kind() === "ipv6" && ip.isIPv4MappedAddress()) {
45073
45061
  ip = ip.toIPv4Address();
45074
45062
  }
@@ -45177,22 +45165,22 @@ var require_utils6 = __commonJS({
45177
45165
  exports.normalizeTypes = function(types) {
45178
45166
  return types.map(exports.normalizeType);
45179
45167
  };
45180
- function acceptParams(str) {
45181
- var length = str.length;
45182
- var colonIndex = str.indexOf(";");
45168
+ function acceptParams(str2) {
45169
+ var length = str2.length;
45170
+ var colonIndex = str2.indexOf(";");
45183
45171
  var index = colonIndex === -1 ? length : colonIndex;
45184
- var ret = { value: str.slice(0, index).trim(), quality: 1, params: {} };
45172
+ var ret = { value: str2.slice(0, index).trim(), quality: 1, params: {} };
45185
45173
  while (index < length) {
45186
- var splitIndex = str.indexOf("=", index);
45174
+ var splitIndex = str2.indexOf("=", index);
45187
45175
  if (splitIndex === -1) break;
45188
- var colonIndex = str.indexOf(";", index);
45176
+ var colonIndex = str2.indexOf(";", index);
45189
45177
  var endIndex = colonIndex === -1 ? length : colonIndex;
45190
45178
  if (splitIndex > endIndex) {
45191
- index = str.lastIndexOf(";", splitIndex - 1) + 1;
45179
+ index = str2.lastIndexOf(";", splitIndex - 1) + 1;
45192
45180
  continue;
45193
45181
  }
45194
- var key = str.slice(index, splitIndex).trim();
45195
- var value = str.slice(splitIndex + 1, endIndex).trim();
45182
+ var key = str2.slice(index, splitIndex).trim();
45183
+ var value = str2.slice(splitIndex + 1, endIndex).trim();
45196
45184
  if (key === "q") {
45197
45185
  ret.quality = parseFloat(value);
45198
45186
  } else {
@@ -45275,8 +45263,8 @@ var require_utils6 = __commonJS({
45275
45263
  return etag(buf, options);
45276
45264
  };
45277
45265
  }
45278
- function parseExtendedQueryString(str) {
45279
- return qs.parse(str, {
45266
+ function parseExtendedQueryString(str2) {
45267
+ return qs.parse(str2, {
45280
45268
  allowPrototypes: true
45281
45269
  });
45282
45270
  }
@@ -45384,11 +45372,11 @@ var require_dist3 = __commonJS({
45384
45372
  var ID_START = /^[$_\p{ID_Start}]$/u;
45385
45373
  var ID_CONTINUE = /^[$\u200c\u200d\p{ID_Continue}]$/u;
45386
45374
  var ID = /^[$_\p{ID_Start}][$\u200c\u200d\p{ID_Continue}]*$/u;
45387
- function escapeText(str) {
45388
- return str.replace(/[{}()\[\]+?!:*\\]/g, "\\$&");
45375
+ function escapeText(str2) {
45376
+ return str2.replace(/[{}()\[\]+?!:*\\]/g, "\\$&");
45389
45377
  }
45390
- function escape2(str) {
45391
- return str.replace(/[.+*?^${}()[\]|/\\]/g, "\\$&");
45378
+ function escape2(str2) {
45379
+ return str2.replace(/[.+*?^${}()[\]|/\\]/g, "\\$&");
45392
45380
  }
45393
45381
  var TokenData = class {
45394
45382
  constructor(tokens, originalPath) {
@@ -45408,9 +45396,9 @@ var require_dist3 = __commonJS({
45408
45396
  }
45409
45397
  };
45410
45398
  exports.PathError = PathError;
45411
- function parse3(str, options = {}) {
45399
+ function parse3(str2, options = {}) {
45412
45400
  const { encodePath = NOOP_VALUE } = options;
45413
- const chars = [...str];
45401
+ const chars = [...str2];
45414
45402
  let index = 0;
45415
45403
  function consumeUntil(end) {
45416
45404
  const output = [];
@@ -45432,7 +45420,7 @@ var require_dist3 = __commonJS({
45432
45420
  }
45433
45421
  if (value === "\\") {
45434
45422
  if (index === chars.length) {
45435
- throw new PathError(`Unexpected end after \\ at index ${index}`, str);
45423
+ throw new PathError(`Unexpected end after \\ at index ${index}`, str2);
45436
45424
  }
45437
45425
  path13 += chars[index++];
45438
45426
  continue;
@@ -45457,11 +45445,11 @@ var require_dist3 = __commonJS({
45457
45445
  name += chars[index];
45458
45446
  }
45459
45447
  if (quoteStart) {
45460
- throw new PathError(`Unterminated quote at index ${quoteStart}`, str);
45448
+ throw new PathError(`Unterminated quote at index ${quoteStart}`, str2);
45461
45449
  }
45462
45450
  }
45463
45451
  if (!name) {
45464
- throw new PathError(`Missing parameter name at index ${index}`, str);
45452
+ throw new PathError(`Missing parameter name at index ${index}`, str2);
45465
45453
  }
45466
45454
  writePath();
45467
45455
  output.push({ type, name });
@@ -45476,17 +45464,17 @@ var require_dist3 = __commonJS({
45476
45464
  continue;
45477
45465
  }
45478
45466
  if (value === "}" || value === "(" || value === ")" || value === "[" || value === "]" || value === "+" || value === "?" || value === "!") {
45479
- throw new PathError(`Unexpected ${value} at index ${index - 1}`, str);
45467
+ throw new PathError(`Unexpected ${value} at index ${index - 1}`, str2);
45480
45468
  }
45481
45469
  path13 += value;
45482
45470
  }
45483
45471
  if (end) {
45484
- throw new PathError(`Unexpected end at index ${index}, expected ${end}`, str);
45472
+ throw new PathError(`Unexpected end at index ${index}, expected ${end}`, str2);
45485
45473
  }
45486
45474
  writePath();
45487
45475
  return output;
45488
45476
  }
45489
- return new TokenData(consumeUntil(""), str);
45477
+ return new TokenData(consumeUntil(""), str2);
45490
45478
  }
45491
45479
  function compile(path13, options = {}) {
45492
45480
  const { encode = encodeURIComponent, delimiter = DEFAULT_DELIMITER } = options;
@@ -46412,7 +46400,7 @@ var require_application = __commonJS({
46412
46400
  var finalhandler = require_finalhandler();
46413
46401
  var debug = require_src()("express:application");
46414
46402
  var View = require_view();
46415
- var http2 = __require("node:http");
46403
+ var http = __require("node:http");
46416
46404
  var methods = require_utils6().methods;
46417
46405
  var compileETag = require_utils6().compileETag;
46418
46406
  var compileQueryParser = require_utils6().compileQueryParser;
@@ -46645,7 +46633,7 @@ var require_application = __commonJS({
46645
46633
  tryRender(view, renderOptions, done);
46646
46634
  };
46647
46635
  app.listen = function listen() {
46648
- var server = http2.createServer(this);
46636
+ var server = http.createServer(this);
46649
46637
  var args = slice.call(arguments);
46650
46638
  if (typeof args[args.length - 1] === "function") {
46651
46639
  var done = args[args.length - 1] = once9(args[args.length - 1]);
@@ -46684,8 +46672,8 @@ var require_charset = __commonJS({
46684
46672
  accepts.length = j;
46685
46673
  return accepts;
46686
46674
  }
46687
- function parseCharset(str, i2) {
46688
- var match = simpleCharsetRegExp.exec(str);
46675
+ function parseCharset(str2, i2) {
46676
+ var match = simpleCharsetRegExp.exec(str2);
46689
46677
  if (!match) return null;
46690
46678
  var charset = match[1];
46691
46679
  var q = 1;
@@ -46782,8 +46770,8 @@ var require_encoding = __commonJS({
46782
46770
  accepts.length = j;
46783
46771
  return accepts;
46784
46772
  }
46785
- function parseEncoding(str, i2) {
46786
- var match = simpleEncodingRegExp.exec(str);
46773
+ function parseEncoding(str2, i2) {
46774
+ var match = simpleEncodingRegExp.exec(str2);
46787
46775
  if (!match) return null;
46788
46776
  var encoding = match[1];
46789
46777
  var q = 1;
@@ -46884,8 +46872,8 @@ var require_language = __commonJS({
46884
46872
  accepts.length = j;
46885
46873
  return accepts;
46886
46874
  }
46887
- function parseLanguage(str, i2) {
46888
- var match = simpleLanguageRegExp.exec(str);
46875
+ function parseLanguage(str2, i2) {
46876
+ var match = simpleLanguageRegExp.exec(str2);
46889
46877
  if (!match) return null;
46890
46878
  var prefix = match[1];
46891
46879
  var suffix = match[2];
@@ -46979,8 +46967,8 @@ var require_mediaType = __commonJS({
46979
46967
  accepts.length = j;
46980
46968
  return accepts;
46981
46969
  }
46982
- function parseMediaType(str, i2) {
46983
- var match = simpleMediaTypeRegExp.exec(str);
46970
+ function parseMediaType(str2, i2) {
46971
+ var match = simpleMediaTypeRegExp.exec(str2);
46984
46972
  if (!match) return null;
46985
46973
  var params = /* @__PURE__ */ Object.create(null);
46986
46974
  var q = 1;
@@ -47081,15 +47069,15 @@ var require_mediaType = __commonJS({
47081
47069
  }
47082
47070
  return count2;
47083
47071
  }
47084
- function splitKeyValuePair(str) {
47085
- var index = str.indexOf("=");
47072
+ function splitKeyValuePair(str2) {
47073
+ var index = str2.indexOf("=");
47086
47074
  var key;
47087
47075
  var val;
47088
47076
  if (index === -1) {
47089
- key = str;
47077
+ key = str2;
47090
47078
  } else {
47091
- key = str.slice(0, index);
47092
- val = str.slice(index + 1);
47079
+ key = str2.slice(0, index);
47080
+ val = str2.slice(index + 1);
47093
47081
  }
47094
47082
  return [key, val];
47095
47083
  }
@@ -47105,8 +47093,8 @@ var require_mediaType = __commonJS({
47105
47093
  accepts.length = j + 1;
47106
47094
  return accepts;
47107
47095
  }
47108
- function splitParameters(str) {
47109
- var parameters = str.split(";");
47096
+ function splitParameters(str2) {
47097
+ var parameters = str2.split(";");
47110
47098
  for (var i2 = 1, j = 0; i2 < parameters.length; i2++) {
47111
47099
  if (quoteCount(parameters[j]) % 2 == 0) {
47112
47100
  parameters[++j] = parameters[i2];
@@ -47306,19 +47294,19 @@ var require_fresh = __commonJS({
47306
47294
  var timestamp = date3 && Date.parse(date3);
47307
47295
  return typeof timestamp === "number" ? timestamp : NaN;
47308
47296
  }
47309
- function parseTokenList(str) {
47297
+ function parseTokenList(str2) {
47310
47298
  var end = 0;
47311
47299
  var list = [];
47312
47300
  var start = 0;
47313
- for (var i2 = 0, len = str.length; i2 < len; i2++) {
47314
- switch (str.charCodeAt(i2)) {
47301
+ for (var i2 = 0, len = str2.length; i2 < len; i2++) {
47302
+ switch (str2.charCodeAt(i2)) {
47315
47303
  case 32:
47316
47304
  if (start === end) {
47317
47305
  start = end = i2 + 1;
47318
47306
  }
47319
47307
  break;
47320
47308
  case 44:
47321
- list.push(str.substring(start, end));
47309
+ list.push(str2.substring(start, end));
47322
47310
  start = end = i2 + 1;
47323
47311
  break;
47324
47312
  default:
@@ -47326,7 +47314,7 @@ var require_fresh = __commonJS({
47326
47314
  break;
47327
47315
  }
47328
47316
  }
47329
- list.push(str.substring(start, end));
47317
+ list.push(str2.substring(start, end));
47330
47318
  return list;
47331
47319
  }
47332
47320
  }
@@ -47337,17 +47325,17 @@ var require_range_parser = __commonJS({
47337
47325
  "../../node_modules/range-parser/index.js"(exports, module) {
47338
47326
  "use strict";
47339
47327
  module.exports = rangeParser;
47340
- function rangeParser(size, str, options) {
47341
- if (typeof str !== "string") {
47328
+ function rangeParser(size, str2, options) {
47329
+ if (typeof str2 !== "string") {
47342
47330
  throw new TypeError("argument str must be a string");
47343
47331
  }
47344
- var index = str.indexOf("=");
47332
+ var index = str2.indexOf("=");
47345
47333
  if (index === -1) {
47346
47334
  return -2;
47347
47335
  }
47348
- var arr = str.slice(index + 1).split(",");
47336
+ var arr = str2.slice(index + 1).split(",");
47349
47337
  var ranges = [];
47350
- ranges.type = str.slice(0, index);
47338
+ ranges.type = str2.slice(0, index);
47351
47339
  for (var i2 = 0; i2 < arr.length; i2++) {
47352
47340
  var range = arr[i2].split("-");
47353
47341
  var start = parseInt(range[0], 10);
@@ -47420,12 +47408,12 @@ var require_request = __commonJS({
47420
47408
  var accepts = require_accepts();
47421
47409
  var isIP = __require("node:net").isIP;
47422
47410
  var typeis = require_type_is();
47423
- var http2 = __require("node:http");
47411
+ var http = __require("node:http");
47424
47412
  var fresh = require_fresh();
47425
47413
  var parseRange = require_range_parser();
47426
47414
  var parse3 = require_parseurl();
47427
47415
  var proxyaddr = require_proxy_addr();
47428
- var req = Object.create(http2.IncomingMessage.prototype);
47416
+ var req = Object.create(http.IncomingMessage.prototype);
47429
47417
  module.exports = req;
47430
47418
  req.get = req.header = function header(name) {
47431
47419
  if (!name) {
@@ -47630,8 +47618,8 @@ var require_content_disposition = __commonJS({
47630
47618
  }
47631
47619
  return string3;
47632
47620
  }
47633
- function decodefield(str) {
47634
- const match = EXT_VALUE_REGEXP.exec(str);
47621
+ function decodefield(str2) {
47622
+ const match = EXT_VALUE_REGEXP.exec(str2);
47635
47623
  if (!match) {
47636
47624
  throw new TypeError("invalid extended field value");
47637
47625
  }
@@ -47710,12 +47698,12 @@ var require_content_disposition = __commonJS({
47710
47698
  return "%" + String(char).charCodeAt(0).toString(16).toUpperCase();
47711
47699
  }
47712
47700
  function qstring(val) {
47713
- var str = String(val);
47714
- return '"' + str.replace(QUOTE_REGEXP, "\\$1") + '"';
47701
+ var str2 = String(val);
47702
+ return '"' + str2.replace(QUOTE_REGEXP, "\\$1") + '"';
47715
47703
  }
47716
47704
  function ustring(val) {
47717
- var str = String(val);
47718
- var encoded = encodeURIComponent(str).replace(ENCODE_URL_ATTR_CHAR_REGEXP, pencode);
47705
+ var str2 = String(val);
47706
+ var encoded = encodeURIComponent(str2).replace(ENCODE_URL_ATTR_CHAR_REGEXP, pencode);
47719
47707
  return "UTF-8''" + encoded;
47720
47708
  }
47721
47709
  function ContentDisposition(type, parameters) {
@@ -47743,26 +47731,26 @@ var require_content_disposition = __commonJS({
47743
47731
  code >= 65 && code <= 70 || // A-F
47744
47732
  code >= 97 && code <= 102;
47745
47733
  }
47746
- function hasHexEscape(str) {
47747
- const maxIndex = str.length - 3;
47734
+ function hasHexEscape(str2) {
47735
+ const maxIndex = str2.length - 3;
47748
47736
  let lastIndex = -1;
47749
- while ((lastIndex = str.indexOf("%", lastIndex + 1)) !== -1 && lastIndex <= maxIndex) {
47750
- if (isHexDigit(str[lastIndex + 1]) && isHexDigit(str[lastIndex + 2])) {
47737
+ while ((lastIndex = str2.indexOf("%", lastIndex + 1)) !== -1 && lastIndex <= maxIndex) {
47738
+ if (isHexDigit(str2[lastIndex + 1]) && isHexDigit(str2[lastIndex + 2])) {
47751
47739
  return true;
47752
47740
  }
47753
47741
  }
47754
47742
  return false;
47755
47743
  }
47756
- function decodeHexEscapes(str) {
47757
- const firstEscape = str.indexOf("%");
47758
- if (firstEscape === -1) return str;
47759
- let result = str.slice(0, firstEscape);
47760
- for (let idx = firstEscape; idx < str.length; idx++) {
47761
- if (str[idx] === "%" && idx + 2 < str.length && isHexDigit(str[idx + 1]) && isHexDigit(str[idx + 2])) {
47762
- result += String.fromCharCode(Number.parseInt(str[idx + 1] + str[idx + 2], 16));
47744
+ function decodeHexEscapes(str2) {
47745
+ const firstEscape = str2.indexOf("%");
47746
+ if (firstEscape === -1) return str2;
47747
+ let result = str2.slice(0, firstEscape);
47748
+ for (let idx = firstEscape; idx < str2.length; idx++) {
47749
+ if (str2[idx] === "%" && idx + 2 < str2.length && isHexDigit(str2[idx + 1]) && isHexDigit(str2[idx + 2])) {
47750
+ result += String.fromCharCode(Number.parseInt(str2[idx + 1] + str2[idx + 2], 16));
47763
47751
  idx += 2;
47764
47752
  } else {
47765
- result += str[idx];
47753
+ result += str2[idx];
47766
47754
  }
47767
47755
  }
47768
47756
  return result;
@@ -47800,54 +47788,54 @@ var require_cookie = __commonJS({
47800
47788
  var cookieValueRegExp = /^("?)[\u0021\u0023-\u002B\u002D-\u003A\u003C-\u005B\u005D-\u007E]*\1$/;
47801
47789
  var domainValueRegExp = /^([.]?[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)([.][a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)*$/i;
47802
47790
  var pathValueRegExp = /^[\u0020-\u003A\u003D-\u007E]*$/;
47803
- function parse3(str, opt) {
47804
- if (typeof str !== "string") {
47791
+ function parse3(str2, opt) {
47792
+ if (typeof str2 !== "string") {
47805
47793
  throw new TypeError("argument str must be a string");
47806
47794
  }
47807
47795
  var obj = {};
47808
- var len = str.length;
47796
+ var len = str2.length;
47809
47797
  if (len < 2) return obj;
47810
47798
  var dec = opt && opt.decode || decode;
47811
47799
  var index = 0;
47812
47800
  var eqIdx = 0;
47813
47801
  var endIdx = 0;
47814
47802
  do {
47815
- eqIdx = str.indexOf("=", index);
47803
+ eqIdx = str2.indexOf("=", index);
47816
47804
  if (eqIdx === -1) break;
47817
- endIdx = str.indexOf(";", index);
47805
+ endIdx = str2.indexOf(";", index);
47818
47806
  if (endIdx === -1) {
47819
47807
  endIdx = len;
47820
47808
  } else if (eqIdx > endIdx) {
47821
- index = str.lastIndexOf(";", eqIdx - 1) + 1;
47809
+ index = str2.lastIndexOf(";", eqIdx - 1) + 1;
47822
47810
  continue;
47823
47811
  }
47824
- var keyStartIdx = startIndex(str, index, eqIdx);
47825
- var keyEndIdx = endIndex(str, eqIdx, keyStartIdx);
47826
- var key = str.slice(keyStartIdx, keyEndIdx);
47812
+ var keyStartIdx = startIndex(str2, index, eqIdx);
47813
+ var keyEndIdx = endIndex(str2, eqIdx, keyStartIdx);
47814
+ var key = str2.slice(keyStartIdx, keyEndIdx);
47827
47815
  if (!__hasOwnProperty.call(obj, key)) {
47828
- var valStartIdx = startIndex(str, eqIdx + 1, endIdx);
47829
- var valEndIdx = endIndex(str, endIdx, valStartIdx);
47830
- if (str.charCodeAt(valStartIdx) === 34 && str.charCodeAt(valEndIdx - 1) === 34) {
47816
+ var valStartIdx = startIndex(str2, eqIdx + 1, endIdx);
47817
+ var valEndIdx = endIndex(str2, endIdx, valStartIdx);
47818
+ if (str2.charCodeAt(valStartIdx) === 34 && str2.charCodeAt(valEndIdx - 1) === 34) {
47831
47819
  valStartIdx++;
47832
47820
  valEndIdx--;
47833
47821
  }
47834
- var val = str.slice(valStartIdx, valEndIdx);
47822
+ var val = str2.slice(valStartIdx, valEndIdx);
47835
47823
  obj[key] = tryDecode(val, dec);
47836
47824
  }
47837
47825
  index = endIdx + 1;
47838
47826
  } while (index < len);
47839
47827
  return obj;
47840
47828
  }
47841
- function startIndex(str, index, max) {
47829
+ function startIndex(str2, index, max) {
47842
47830
  do {
47843
- var code = str.charCodeAt(index);
47831
+ var code = str2.charCodeAt(index);
47844
47832
  if (code !== 32 && code !== 9) return index;
47845
47833
  } while (++index < max);
47846
47834
  return max;
47847
47835
  }
47848
- function endIndex(str, index, min) {
47836
+ function endIndex(str2, index, min) {
47849
47837
  while (index > min) {
47850
- var code = str.charCodeAt(--index);
47838
+ var code = str2.charCodeAt(--index);
47851
47839
  if (code !== 32 && code !== 9) return index + 1;
47852
47840
  }
47853
47841
  return min;
@@ -47864,54 +47852,54 @@ var require_cookie = __commonJS({
47864
47852
  if (!cookieValueRegExp.test(value)) {
47865
47853
  throw new TypeError("argument val is invalid");
47866
47854
  }
47867
- var str = name + "=" + value;
47868
- if (!opt) return str;
47855
+ var str2 = name + "=" + value;
47856
+ if (!opt) return str2;
47869
47857
  if (null != opt.maxAge) {
47870
47858
  var maxAge = Math.floor(opt.maxAge);
47871
47859
  if (!isFinite(maxAge)) {
47872
47860
  throw new TypeError("option maxAge is invalid");
47873
47861
  }
47874
- str += "; Max-Age=" + maxAge;
47862
+ str2 += "; Max-Age=" + maxAge;
47875
47863
  }
47876
47864
  if (opt.domain) {
47877
47865
  if (!domainValueRegExp.test(opt.domain)) {
47878
47866
  throw new TypeError("option domain is invalid");
47879
47867
  }
47880
- str += "; Domain=" + opt.domain;
47868
+ str2 += "; Domain=" + opt.domain;
47881
47869
  }
47882
47870
  if (opt.path) {
47883
47871
  if (!pathValueRegExp.test(opt.path)) {
47884
47872
  throw new TypeError("option path is invalid");
47885
47873
  }
47886
- str += "; Path=" + opt.path;
47874
+ str2 += "; Path=" + opt.path;
47887
47875
  }
47888
47876
  if (opt.expires) {
47889
47877
  var expires = opt.expires;
47890
47878
  if (!isDate(expires) || isNaN(expires.valueOf())) {
47891
47879
  throw new TypeError("option expires is invalid");
47892
47880
  }
47893
- str += "; Expires=" + expires.toUTCString();
47881
+ str2 += "; Expires=" + expires.toUTCString();
47894
47882
  }
47895
47883
  if (opt.httpOnly) {
47896
- str += "; HttpOnly";
47884
+ str2 += "; HttpOnly";
47897
47885
  }
47898
47886
  if (opt.secure) {
47899
- str += "; Secure";
47887
+ str2 += "; Secure";
47900
47888
  }
47901
47889
  if (opt.partitioned) {
47902
- str += "; Partitioned";
47890
+ str2 += "; Partitioned";
47903
47891
  }
47904
47892
  if (opt.priority) {
47905
47893
  var priority = typeof opt.priority === "string" ? opt.priority.toLowerCase() : opt.priority;
47906
47894
  switch (priority) {
47907
47895
  case "low":
47908
- str += "; Priority=Low";
47896
+ str2 += "; Priority=Low";
47909
47897
  break;
47910
47898
  case "medium":
47911
- str += "; Priority=Medium";
47899
+ str2 += "; Priority=Medium";
47912
47900
  break;
47913
47901
  case "high":
47914
- str += "; Priority=High";
47902
+ str2 += "; Priority=High";
47915
47903
  break;
47916
47904
  default:
47917
47905
  throw new TypeError("option priority is invalid");
@@ -47921,34 +47909,34 @@ var require_cookie = __commonJS({
47921
47909
  var sameSite = typeof opt.sameSite === "string" ? opt.sameSite.toLowerCase() : opt.sameSite;
47922
47910
  switch (sameSite) {
47923
47911
  case true:
47924
- str += "; SameSite=Strict";
47912
+ str2 += "; SameSite=Strict";
47925
47913
  break;
47926
47914
  case "lax":
47927
- str += "; SameSite=Lax";
47915
+ str2 += "; SameSite=Lax";
47928
47916
  break;
47929
47917
  case "strict":
47930
- str += "; SameSite=Strict";
47918
+ str2 += "; SameSite=Strict";
47931
47919
  break;
47932
47920
  case "none":
47933
- str += "; SameSite=None";
47921
+ str2 += "; SameSite=None";
47934
47922
  break;
47935
47923
  default:
47936
47924
  throw new TypeError("option sameSite is invalid");
47937
47925
  }
47938
47926
  }
47939
- return str;
47927
+ return str2;
47940
47928
  }
47941
- function decode(str) {
47942
- return str.indexOf("%") !== -1 ? decodeURIComponent(str) : str;
47929
+ function decode(str2) {
47930
+ return str2.indexOf("%") !== -1 ? decodeURIComponent(str2) : str2;
47943
47931
  }
47944
47932
  function isDate(val) {
47945
47933
  return __toString.call(val) === "[object Date]";
47946
47934
  }
47947
- function tryDecode(str, decode2) {
47935
+ function tryDecode(str2, decode2) {
47948
47936
  try {
47949
- return decode2(str);
47937
+ return decode2(str2);
47950
47938
  } catch (e) {
47951
- return str;
47939
+ return str2;
47952
47940
  }
47953
47941
  }
47954
47942
  }
@@ -48347,13 +48335,13 @@ var require_send = __commonJS({
48347
48335
  res.removeHeader(header);
48348
48336
  }
48349
48337
  }
48350
- function collapseLeadingSlashes(str) {
48351
- for (var i2 = 0; i2 < str.length; i2++) {
48352
- if (str[i2] !== "/") {
48338
+ function collapseLeadingSlashes(str2) {
48339
+ for (var i2 = 0; i2 < str2.length; i2++) {
48340
+ if (str2[i2] !== "/") {
48353
48341
  break;
48354
48342
  }
48355
48343
  }
48356
- return i2 > 1 ? "/" + str.substr(i2) : str;
48344
+ return i2 > 1 ? "/" + str2.substr(i2) : str2;
48357
48345
  }
48358
48346
  function containsDotFile(parts) {
48359
48347
  for (var i2 = 0; i2 < parts.length; i2++) {
@@ -48400,12 +48388,12 @@ var require_send = __commonJS({
48400
48388
  var timestamp = date3 && Date.parse(date3);
48401
48389
  return typeof timestamp === "number" ? timestamp : NaN;
48402
48390
  }
48403
- function parseTokenList(str) {
48391
+ function parseTokenList(str2) {
48404
48392
  var end = 0;
48405
48393
  var list = [];
48406
48394
  var start = 0;
48407
- for (var i2 = 0, len = str.length; i2 < len; i2++) {
48408
- switch (str.charCodeAt(i2)) {
48395
+ for (var i2 = 0, len = str2.length; i2 < len; i2++) {
48396
+ switch (str2.charCodeAt(i2)) {
48409
48397
  case 32:
48410
48398
  if (start === end) {
48411
48399
  start = end = i2 + 1;
@@ -48413,7 +48401,7 @@ var require_send = __commonJS({
48413
48401
  break;
48414
48402
  case 44:
48415
48403
  if (start !== end) {
48416
- list.push(str.substring(start, end));
48404
+ list.push(str2.substring(start, end));
48417
48405
  }
48418
48406
  start = end = i2 + 1;
48419
48407
  break;
@@ -48423,7 +48411,7 @@ var require_send = __commonJS({
48423
48411
  }
48424
48412
  }
48425
48413
  if (start !== end) {
48426
- list.push(str.substring(start, end));
48414
+ list.push(str2.substring(start, end));
48427
48415
  }
48428
48416
  return list;
48429
48417
  }
@@ -48519,7 +48507,7 @@ var require_response = __commonJS({
48519
48507
  var deprecate = require_depd()("express");
48520
48508
  var encodeUrl = require_encodeurl();
48521
48509
  var escapeHtml = require_escape_html();
48522
- var http2 = __require("node:http");
48510
+ var http = __require("node:http");
48523
48511
  var onFinished = require_on_finished();
48524
48512
  var mime = require_mime_types();
48525
48513
  var path13 = __require("node:path");
@@ -48535,7 +48523,7 @@ var require_response = __commonJS({
48535
48523
  var resolve6 = path13.resolve;
48536
48524
  var vary = require_vary();
48537
48525
  var { Buffer: Buffer5 } = __require("node:buffer");
48538
- var res = Object.create(http2.ServerResponse.prototype);
48526
+ var res = Object.create(http.ServerResponse.prototype);
48539
48527
  module.exports = res;
48540
48528
  res.status = function status(code) {
48541
48529
  if (!Number.isInteger(code)) {
@@ -48887,9 +48875,9 @@ var require_response = __commonJS({
48887
48875
  opts = {};
48888
48876
  }
48889
48877
  opts._locals = self.locals;
48890
- done = done || function(err, str) {
48878
+ done = done || function(err, str2) {
48891
48879
  if (err) return req.next(err);
48892
- self.send(str);
48880
+ self.send(str2);
48893
48881
  };
48894
48882
  app.render(view, opts, done);
48895
48883
  };
@@ -49045,13 +49033,13 @@ var require_serve_static = __commonJS({
49045
49033
  stream.pipe(res);
49046
49034
  };
49047
49035
  }
49048
- function collapseLeadingSlashes(str) {
49049
- for (var i2 = 0; i2 < str.length; i2++) {
49050
- if (str.charCodeAt(i2) !== 47) {
49036
+ function collapseLeadingSlashes(str2) {
49037
+ for (var i2 = 0; i2 < str2.length; i2++) {
49038
+ if (str2.charCodeAt(i2) !== 47) {
49051
49039
  break;
49052
49040
  }
49053
49041
  }
49054
- return i2 > 1 ? "/" + str.substr(i2) : str;
49042
+ return i2 > 1 ? "/" + str2.substr(i2) : str2;
49055
49043
  }
49056
49044
  function createHtmlDocument(title, body) {
49057
49045
  return '<!DOCTYPE html>\n<html lang="en">\n<head>\n<meta charset="utf-8">\n<title>' + title + "</title>\n</head>\n<body>\n<pre>" + body + "</pre>\n</body>\n</html>\n";
@@ -53532,14 +53520,14 @@ function promiseAllObject(promisesObj) {
53532
53520
  }
53533
53521
  function randomString(length = 10) {
53534
53522
  const chars = "abcdefghijklmnopqrstuvwxyz";
53535
- let str = "";
53523
+ let str2 = "";
53536
53524
  for (let i2 = 0; i2 < length; i2++) {
53537
- str += chars[Math.floor(Math.random() * chars.length)];
53525
+ str2 += chars[Math.floor(Math.random() * chars.length)];
53538
53526
  }
53539
- return str;
53527
+ return str2;
53540
53528
  }
53541
- function esc(str) {
53542
- return JSON.stringify(str);
53529
+ function esc(str2) {
53530
+ return JSON.stringify(str2);
53543
53531
  }
53544
53532
  function isObject3(data) {
53545
53533
  return typeof data === "object" && data !== null && !Array.isArray(data);
@@ -53567,8 +53555,8 @@ function numKeys(data) {
53567
53555
  }
53568
53556
  return keyCount;
53569
53557
  }
53570
- function escapeRegex(str) {
53571
- return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
53558
+ function escapeRegex(str2) {
53559
+ return str2.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
53572
53560
  }
53573
53561
  function clone(inst, def, params) {
53574
53562
  const cl = new inst._zod.constr(def ?? inst._zod.def);
@@ -54068,7 +54056,7 @@ function datetime(args) {
54068
54056
  const timeRegex2 = `${time3}(?:${opts.join("|")})`;
54069
54057
  return new RegExp(`^${dateSource}T(?:${timeRegex2})$`);
54070
54058
  }
54071
- var cuid, cuid2, ulid, xid, ksuid, nanoid, duration, guid, uuid, email, _emoji, ipv4, ipv6, cidrv4, cidrv6, base64, base64url2, hostname, e164, dateSource, date, string, integer, number, boolean, _null, lowercase, uppercase;
54059
+ var cuid, cuid2, ulid, xid, ksuid, nanoid, duration, guid, uuid, email, _emoji, ipv4, ipv6, cidrv4, cidrv6, base64, base64url, hostname, e164, dateSource, date, string, integer, number, boolean, _null, lowercase, uppercase;
54072
54060
  var init_regexes = __esm({
54073
54061
  "../../node_modules/zod/v4/core/regexes.js"() {
54074
54062
  cuid = /^[cC][^\s-]{8,}$/;
@@ -54091,7 +54079,7 @@ var init_regexes = __esm({
54091
54079
  cidrv4 = /^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/;
54092
54080
  cidrv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/;
54093
54081
  base64 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/;
54094
- base64url2 = /^[A-Za-z0-9_-]*$/;
54082
+ base64url = /^[A-Za-z0-9_-]*$/;
54095
54083
  hostname = /^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/;
54096
54084
  e164 = /^\+(?:[0-9]){6,14}[0-9]$/;
54097
54085
  dateSource = `(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`;
@@ -54569,7 +54557,7 @@ function isValidBase64(data) {
54569
54557
  }
54570
54558
  }
54571
54559
  function isValidBase64URL(data) {
54572
- if (!base64url2.test(data))
54560
+ if (!base64url.test(data))
54573
54561
  return false;
54574
54562
  const base642 = data.replace(/[-_]/g, (c3) => c3 === "-" ? "+" : "/");
54575
54563
  const padded = base642.padEnd(Math.ceil(base642.length / 4) * 4, "=");
@@ -55064,7 +55052,7 @@ var init_schemas = __esm({
55064
55052
  };
55065
55053
  });
55066
55054
  $ZodBase64URL = /* @__PURE__ */ $constructor("$ZodBase64URL", (inst, def) => {
55067
- def.pattern ?? (def.pattern = base64url2);
55055
+ def.pattern ?? (def.pattern = base64url);
55068
55056
  $ZodStringFormat.init(inst, def);
55069
55057
  inst._zod.onattach.push((inst2) => {
55070
55058
  inst2._zod.bag.contentEncoding = "base64url";
@@ -62474,7 +62462,7 @@ var require_code5 = __commonJS({
62474
62462
  }
62475
62463
  exports._ = _;
62476
62464
  var plus = new _Code("+");
62477
- function str(strs, ...args) {
62465
+ function str2(strs, ...args) {
62478
62466
  const expr = [safeStringify(strs[0])];
62479
62467
  let i2 = 0;
62480
62468
  while (i2 < args.length) {
@@ -62485,7 +62473,7 @@ var require_code5 = __commonJS({
62485
62473
  optimize(expr);
62486
62474
  return new _Code(expr);
62487
62475
  }
62488
- exports.str = str;
62476
+ exports.str = str2;
62489
62477
  function addCodeArg(code, arg) {
62490
62478
  if (arg instanceof _Code)
62491
62479
  code.push(...arg._items);
@@ -62528,7 +62516,7 @@ var require_code5 = __commonJS({
62528
62516
  return;
62529
62517
  }
62530
62518
  function strConcat(c1, c22) {
62531
- return c22.emptyStr() ? c1 : c1.emptyStr() ? c22 : str`${c1}${c22}`;
62519
+ return c22.emptyStr() ? c1 : c1.emptyStr() ? c22 : str2`${c1}${c22}`;
62532
62520
  }
62533
62521
  exports.strConcat = strConcat;
62534
62522
  function interpolate(x) {
@@ -63490,22 +63478,22 @@ var require_util4 = __commonJS({
63490
63478
  return (0, codegen_1._)`${topSchemaRef}${schemaPath}${(0, codegen_1.getProperty)(keyword)}`;
63491
63479
  }
63492
63480
  exports.schemaRefOrVal = schemaRefOrVal;
63493
- function unescapeFragment(str) {
63494
- return unescapeJsonPointer(decodeURIComponent(str));
63481
+ function unescapeFragment(str2) {
63482
+ return unescapeJsonPointer(decodeURIComponent(str2));
63495
63483
  }
63496
63484
  exports.unescapeFragment = unescapeFragment;
63497
- function escapeFragment(str) {
63498
- return encodeURIComponent(escapeJsonPointer(str));
63485
+ function escapeFragment(str2) {
63486
+ return encodeURIComponent(escapeJsonPointer(str2));
63499
63487
  }
63500
63488
  exports.escapeFragment = escapeFragment;
63501
- function escapeJsonPointer(str) {
63502
- if (typeof str == "number")
63503
- return `${str}`;
63504
- return str.replace(/~/g, "~0").replace(/\//g, "~1");
63489
+ function escapeJsonPointer(str2) {
63490
+ if (typeof str2 == "number")
63491
+ return `${str2}`;
63492
+ return str2.replace(/~/g, "~0").replace(/\//g, "~1");
63505
63493
  }
63506
63494
  exports.escapeJsonPointer = escapeJsonPointer;
63507
- function unescapeJsonPointer(str) {
63508
- return str.replace(/~1/g, "/").replace(/~0/g, "~");
63495
+ function unescapeJsonPointer(str2) {
63496
+ return str2.replace(/~1/g, "/").replace(/~0/g, "~");
63509
63497
  }
63510
63498
  exports.unescapeJsonPointer = unescapeJsonPointer;
63511
63499
  function eachItem(xs, f) {
@@ -64495,8 +64483,8 @@ var require_json_schema_traverse3 = __commonJS({
64495
64483
  post(schema, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex);
64496
64484
  }
64497
64485
  }
64498
- function escapeJsonPtr(str) {
64499
- return str.replace(/~/g, "~0").replace(/\//g, "~1");
64486
+ function escapeJsonPtr(str2) {
64487
+ return str2.replace(/~/g, "~0").replace(/\//g, "~1");
64500
64488
  }
64501
64489
  }
64502
64490
  });
@@ -65491,7 +65479,7 @@ var require_core6 = __commonJS({
65491
65479
  var util_1 = require_util4();
65492
65480
  var $dataRefSchema = require_data3();
65493
65481
  var uri_1 = require_uri4();
65494
- var defaultRegExp = (str, flags) => new RegExp(str, flags);
65482
+ var defaultRegExp = (str2, flags) => new RegExp(str2, flags);
65495
65483
  defaultRegExp.code = "new RegExp";
65496
65484
  var META_IGNORE_OPTIONS = ["removeAdditional", "useDefaults", "coerceTypes"];
65497
65485
  var EXT_SCOPE_NAMES = /* @__PURE__ */ new Set([
@@ -66286,16 +66274,16 @@ var require_ucs2length3 = __commonJS({
66286
66274
  "../../node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/runtime/ucs2length.js"(exports) {
66287
66275
  "use strict";
66288
66276
  Object.defineProperty(exports, "__esModule", { value: true });
66289
- function ucs2length(str) {
66290
- const len = str.length;
66277
+ function ucs2length(str2) {
66278
+ const len = str2.length;
66291
66279
  let length = 0;
66292
66280
  let pos = 0;
66293
66281
  let value;
66294
66282
  while (pos < len) {
66295
66283
  length++;
66296
- value = str.charCodeAt(pos++);
66284
+ value = str2.charCodeAt(pos++);
66297
66285
  if (value >= 55296 && value <= 56319 && pos < len) {
66298
- value = str.charCodeAt(pos);
66286
+ value = str2.charCodeAt(pos);
66299
66287
  if ((value & 64512) === 56320)
66300
66288
  pos++;
66301
66289
  }
@@ -71247,12 +71235,12 @@ async function currentRefreshToken(s, source) {
71247
71235
  const c3 = await readStoredCredentials();
71248
71236
  const stored = c3 ? identitySourceOfStore(c3) : null;
71249
71237
  if (c3?.refreshToken && stored?.authUrl === source.authUrl) {
71250
- return { token: c3.refreshToken.trim(), email: c3.email };
71238
+ return { token: c3.refreshToken.trim(), email: c3.email, source: stored };
71251
71239
  }
71252
71240
  } catch {
71253
71241
  }
71254
71242
  const own = s.identityRefreshToken?.trim();
71255
- return own ? { token: own, email: s.email } : void 0;
71243
+ return own ? { token: own, email: s.email, source } : void 0;
71256
71244
  }
71257
71245
  async function getValidSession() {
71258
71246
  const fromReq = getRequestSession();
@@ -71276,7 +71264,7 @@ async function getValidSession() {
71276
71264
  return isSessionActive(s) ? s : null;
71277
71265
  }
71278
71266
  try {
71279
- const rt = await refreshIdentityToken(source, refresh.token);
71267
+ const rt = await refreshIdentityToken(refresh.source, refresh.token);
71280
71268
  if (!await persistRotatedRefreshToken(refresh.token, rt.refreshToken)) {
71281
71269
  return null;
71282
71270
  }
@@ -71286,7 +71274,8 @@ async function getValidSession() {
71286
71274
  identityToken: rt.idToken,
71287
71275
  identityRefreshToken: rt.refreshToken,
71288
71276
  authProvider: "supabase",
71289
- authUrl: source.authUrl,
71277
+ authUrl: refresh.source.authUrl,
71278
+ ...refresh.source.clientId ? { authClientId: refresh.source.clientId } : {},
71290
71279
  // Whose the redeemed refresh token was, which is not always the user of
71291
71280
  // the session being replaced.
71292
71281
  email: refresh.email || rt.email
@@ -71355,7 +71344,7 @@ function extractErrorMessage(data, fallback) {
71355
71344
  return fallback;
71356
71345
  }
71357
71346
  function platformBase() {
71358
- return PLATFORM_URL2.replace(/\/$/, "");
71347
+ return PLATFORM_URL.replace(/\/$/, "");
71359
71348
  }
71360
71349
  async function requireSession() {
71361
71350
  const session = await getValidSession();
@@ -71443,7 +71432,7 @@ async function inworldGatewayPostJson(path13, body) {
71443
71432
  var init_gateway_http = __esm({
71444
71433
  "src/mcp/inworld/gateway-http.ts"() {
71445
71434
  "use strict";
71446
- init_constants6();
71435
+ init_constants5();
71447
71436
  init_inworld_headers();
71448
71437
  init_session_refresh();
71449
71438
  }
@@ -71577,25 +71566,25 @@ var init_credential = __esm({
71577
71566
  throw new RuntimeCredentialError(PER_REQUEST_SIGN_IN);
71578
71567
  }
71579
71568
  const stored = await readStoredCredentials().catch(() => null);
71580
- const signIn2 = stored ? identitySourceOfStore(stored) : null;
71581
- if (!stored?.refreshToken?.trim() || !signIn2) return null;
71569
+ const signIn = stored ? identitySourceOfStore(stored) : null;
71570
+ if (!stored?.refreshToken?.trim() || !signIn) return null;
71582
71571
  return {
71583
71572
  user: accountOf(stored.inworldToken),
71584
- deployment: signIn2.authUrl,
71573
+ deployment: signIn.authUrl,
71585
71574
  workspace: stored.workspace ?? null
71586
71575
  };
71587
71576
  },
71588
71577
  async platformAuth() {
71589
71578
  const stored = await readStoredCredentials().catch(() => null);
71590
- const signIn2 = stored ? identitySourceOfStore(stored) : null;
71591
- if (!stored || !signIn2) return null;
71579
+ const signIn = stored ? identitySourceOfStore(stored) : null;
71580
+ if (!stored || !signIn) return null;
71592
71581
  const onDisk = loadSession();
71593
- if (onDisk && identitySourceOfStore(onDisk)?.authUrl !== signIn2.authUrl) {
71582
+ if (onDisk && identitySourceOfStore(onDisk)?.authUrl !== signIn.authUrl) {
71594
71583
  throw new RuntimeCredentialError(DIFFERENT_DEPLOYMENTS);
71595
71584
  }
71596
71585
  let session = await getValidSession();
71597
71586
  if (!session) return null;
71598
- if (identitySourceOfStore(session)?.authUrl !== signIn2.authUrl) {
71587
+ if (identitySourceOfStore(session)?.authUrl !== signIn.authUrl) {
71599
71588
  throw new RuntimeCredentialError(DIFFERENT_DEPLOYMENTS);
71600
71589
  }
71601
71590
  const signedInAccount = accountOf(stored.inworldToken);
@@ -71606,7 +71595,7 @@ var init_credential = __esm({
71606
71595
  }
71607
71596
  return {
71608
71597
  user: accountOf(session.token),
71609
- deployment: signIn2.authUrl,
71598
+ deployment: signIn.authUrl,
71610
71599
  headers: headersForInworldSession(session)
71611
71600
  };
71612
71601
  }
@@ -71815,7 +71804,7 @@ async function fetchWorkspaceEngineSession(workspaceId) {
71815
71804
  "Session has no identity token (needed for workspace engine session). Run `inworld-mcp login` again, or use session-file auth instead of bearer-only HTTP."
71816
71805
  );
71817
71806
  }
71818
- const base = PLATFORM_URL2.replace(/\/$/, "");
71807
+ const base = PLATFORM_URL.replace(/\/$/, "");
71819
71808
  const parent = workspaceResourceName(workspaceId);
71820
71809
  const id = workspaceId.trim();
71821
71810
  const path13 = `/v1alpha/workspaces/${encodeURIComponent(id)}/token:generate`;
@@ -71849,7 +71838,7 @@ async function fetchWorkspaceEngineSession(workspaceId) {
71849
71838
  var init_engine_session = __esm({
71850
71839
  "src/mcp/voice/engine-session.ts"() {
71851
71840
  "use strict";
71852
- init_constants6();
71841
+ init_constants5();
71853
71842
  init_inworld_headers();
71854
71843
  init_session_refresh();
71855
71844
  init_gateway();
@@ -73034,24 +73023,22 @@ var init_schemas4 = __esm({
73034
73023
 
73035
73024
  // src/mcp/cli/login.ts
73036
73025
  async function runLogin() {
73037
- const source = await resolveIdentitySource(PLATFORM_URL2);
73038
- const oauthProvider = process.env.INWORLD_AUTH_OAUTH_PROVIDER || void 0;
73039
- if (oauthProvider && !GOTRUE_OAUTH_PROVIDERS.includes(oauthProvider)) {
73040
- throw new Error(
73041
- `INWORLD_AUTH_OAUTH_PROVIDER=${oauthProvider} is not supported by inworld-mcp login (use ${GOTRUE_OAUTH_PROVIDERS.join(", ")}, or unset it to choose on the sign-in page).`
73026
+ const source = await resolveIdentitySource(PLATFORM_URL);
73027
+ if (process.env.INWORLD_AUTH_OAUTH_PROVIDER) {
73028
+ console.error(
73029
+ "Note: INWORLD_AUTH_OAUTH_PROVIDER is ignored. Choose the sign-in method in the browser."
73042
73030
  );
73043
73031
  }
73044
- const signIn2 = await startBrowserSignIn({
73045
- authUrl: source.authUrl,
73046
- pageUrl: INWORLD_CLI_AUTH_URL2,
73047
- version: CLI_VERSION,
73048
- oauthProvider
73049
- });
73050
- await promptForSignIn(signIn2, {
73051
- print: (line) => console.error(line),
73052
- output: process.stdout
73032
+ const tokens = await signInWithDeviceCode({
73033
+ source,
73034
+ platformUrl: PLATFORM_URL,
73035
+ clientId: INWORLD_CLI_CLIENT_ID,
73036
+ env: INWORLD_ENV,
73037
+ out: {
73038
+ print: (line) => console.error(line),
73039
+ output: process.stdout
73040
+ }
73053
73041
  });
73054
- const tokens = await signIn2.done;
73055
73042
  console.error();
73056
73043
  console.error("Exchanging for Inworld session...");
73057
73044
  const exchanged = await exchangeIdentityToken(tokens.idToken);
@@ -73061,6 +73048,7 @@ async function runLogin() {
73061
73048
  identityRefreshToken: tokens.refreshToken,
73062
73049
  authProvider: "supabase",
73063
73050
  authUrl: source.authUrl,
73051
+ authClientId: INWORLD_CLI_CLIENT_ID,
73064
73052
  email: tokens.email
73065
73053
  };
73066
73054
  saveSession(merged);
@@ -73070,9 +73058,10 @@ async function runLogin() {
73070
73058
  email: tokens.email ?? "",
73071
73059
  inworldToken: merged.token ?? "",
73072
73060
  expiresAt,
73073
- env: INWORLD_ENV2,
73061
+ env: INWORLD_ENV,
73074
73062
  authProvider: "supabase",
73075
- authUrl: source.authUrl
73063
+ authUrl: source.authUrl,
73064
+ authClientId: INWORLD_CLI_CLIENT_ID
73076
73065
  });
73077
73066
  await clearStoredRuntimeToken();
73078
73067
  console.error();
@@ -73088,12 +73077,11 @@ var init_login = __esm({
73088
73077
  "use strict";
73089
73078
  init_dist4();
73090
73079
  init_constants5();
73091
- init_constants6();
73080
+ init_device_flow();
73092
73081
  init_exchange();
73093
73082
  init_identity();
73094
73083
  init_paths();
73095
73084
  init_session();
73096
- init_sign_in_prompt();
73097
73085
  }
73098
73086
  });
73099
73087
 
@@ -74115,7 +74103,7 @@ var init_mcp2 = __esm({
74115
74103
  init_streamableHttp();
74116
74104
  init_zod();
74117
74105
  init_bearer();
74118
- init_constants6();
74106
+ init_constants5();
74119
74107
  init_gate();
74120
74108
  init_request_session();
74121
74109
  init_session();
@@ -75020,12 +75008,13 @@ import { join as join4, resolve } from "path";
75020
75008
 
75021
75009
  // src/auth/manager.ts
75022
75010
  init_dist4();
75023
- init_constants5();
75011
+ init_constants6();
75024
75012
  init_cli_store_bridge();
75013
+ init_constants5();
75025
75014
  init_identity();
75026
75015
 
75027
75016
  // src/utils/ui.ts
75028
- init_constants5();
75017
+ init_constants6();
75029
75018
  function printHeader(message) {
75030
75019
  console.log(source_default.bold(message));
75031
75020
  }
@@ -75065,7 +75054,7 @@ function link(message) {
75065
75054
  function printBox(lines, options) {
75066
75055
  const color = options?.color || "yellow";
75067
75056
  const padding = options?.padding ?? 2;
75068
- const stripAnsi = (str) => str.replace(/\x1b\[[0-9;]*m/g, "");
75057
+ const stripAnsi = (str2) => str2.replace(/\x1b\[[0-9;]*m/g, "");
75069
75058
  const maxContentWidth = Math.max(
75070
75059
  ...lines.map((line) => stripAnsi(line).length)
75071
75060
  );
@@ -75359,7 +75348,8 @@ var AuthManager = class {
75359
75348
  expiresAt,
75360
75349
  env: env3,
75361
75350
  authProvider: "supabase",
75362
- authUrl: source.authUrl
75351
+ authUrl: source.authUrl,
75352
+ ...source.clientId ? { authClientId: source.clientId } : {}
75363
75353
  };
75364
75354
  await clearStoredRuntimeToken();
75365
75355
  await this.saveCredentials(credentials);
@@ -75390,12 +75380,13 @@ var AuthManager = class {
75390
75380
  print(LEGACY_SIGN_IN_MESSAGE);
75391
75381
  return false;
75392
75382
  }
75393
- if (credentials?.env && credentials?.env !== INWORLD_ENV) {
75383
+ const storedEnvironment = credentials?.env ? resolveDeployment(credentials.env) : void 0;
75384
+ if (storedEnvironment && storedEnvironment !== INWORLD_ENV) {
75394
75385
  print(
75395
75386
  `Warning: Currently saved credentials might not match current Inworld CLI environment.
75396
75387
 
75397
75388
  Current Inworld CLI environment is ${INWORLD_ENV}
75398
- Environment of current credentials is ${credentials?.env}
75389
+ Environment of current credentials is ${storedEnvironment}
75399
75390
 
75400
75391
  You can run "inworld login --force" to login with the correct environment.`
75401
75392
  );
@@ -75407,7 +75398,7 @@ var authManager = new AuthManager();
75407
75398
 
75408
75399
  // src/auth/utils.ts
75409
75400
  init_runtime_credential();
75410
- init_constants5();
75401
+ init_constants6();
75411
75402
  init_client_info();
75412
75403
  async function requireAuth() {
75413
75404
  const isAuthenticated = await authManager.isAuthenticated();
@@ -75444,10 +75435,10 @@ var cliSession = {
75444
75435
  const token = await authManager.getValidToken();
75445
75436
  if (!token) return null;
75446
75437
  const credentials = await authManager.getCredentials();
75447
- const signIn2 = credentials?.inworldToken === token ? credentials : null;
75438
+ const signIn = credentials?.inworldToken === token ? credentials : null;
75448
75439
  return {
75449
75440
  user: accountOf(token),
75450
- deployment: signIn2 ? signIn2.authUrl ?? "" : null,
75441
+ deployment: signIn ? signIn.authUrl ?? "" : null,
75451
75442
  headers: {
75452
75443
  Authorization: `Bearer ${token}`,
75453
75444
  "Grpc-Metadata-X-Authorization-Bearer-Type": "inworld"
@@ -75487,7 +75478,7 @@ var authenticatedInworldRequest = async (pb, req, inworldToken, signal) => {
75487
75478
  };
75488
75479
 
75489
75480
  // src/services/tts_service.ts
75490
- init_constants5();
75481
+ init_constants6();
75491
75482
  init_client_info();
75492
75483
 
75493
75484
  // src/utils/resource_name_helper.ts
@@ -75806,7 +75797,7 @@ var ttsService = new TTSService();
75806
75797
  // src/services/tts_websocket.ts
75807
75798
  init_runtime_credential();
75808
75799
  import WebSocket from "ws";
75809
- init_constants5();
75800
+ init_constants6();
75810
75801
  init_client_info();
75811
75802
 
75812
75803
  // src/utils/wav.ts
@@ -83753,14 +83744,14 @@ async function writeChapterPcm(path13, segments, synthesize, chapterIndex, attem
83753
83744
  }
83754
83745
 
83755
83746
  // src/commands/audiobook/state_file.ts
83756
- import { createHash as createHash3 } from "crypto";
83747
+ import { createHash as createHash2 } from "crypto";
83757
83748
  import { rename, writeFile as writeFile3 } from "fs/promises";
83758
83749
  import { readFile as readFile2 } from "fs/promises";
83759
83750
  import { join as join3 } from "path";
83760
83751
  var STATE_FILE_NAME = "state.json";
83761
83752
  var STATE_FILE_VERSION = 1;
83762
83753
  function sha256(buffer) {
83763
- return createHash3("sha256").update(buffer).digest("hex");
83754
+ return createHash2("sha256").update(buffer).digest("hex");
83764
83755
  }
83765
83756
  function statePath(workDir) {
83766
83757
  return join3(workDir, STATE_FILE_NAME);
@@ -84234,14 +84225,14 @@ var audiobookCommand = new Command("audiobook").description("Audiobook generatio
84234
84225
  });
84235
84226
 
84236
84227
  // src/commands/auth/login_command.ts
84237
- init_constants5();
84228
+ init_constants6();
84229
+ init_device_flow();
84238
84230
  init_identity();
84239
- init_sign_in_prompt();
84240
84231
 
84241
84232
  // src/services/workspace_service.ts
84242
84233
  import { open as open2, unlink } from "node:fs/promises";
84243
84234
  import { resolve as resolve2 } from "node:path";
84244
- init_constants5();
84235
+ init_constants6();
84245
84236
 
84246
84237
  // proto/generated/portal/ai/inworld/studio/v1alpha/apikeys.pb.ts
84247
84238
  init_fetch_pb();
@@ -84639,21 +84630,6 @@ async function createKeyFile(path13) {
84639
84630
  }
84640
84631
 
84641
84632
  // src/commands/auth/login_command.ts
84642
- var signIn = async (source, provider) => {
84643
- const browserSignIn = await startBrowserSignIn({
84644
- authUrl: source.authUrl,
84645
- pageUrl: INWORLD_CLI_AUTH_URL,
84646
- version: CLI_VERSION,
84647
- oauthProvider: provider === "email" ? void 0 : provider
84648
- });
84649
- await promptForSignIn(browserSignIn, {
84650
- print,
84651
- printLink,
84652
- printError,
84653
- output: process.stdout
84654
- });
84655
- return browserSignIn.done;
84656
- };
84657
84633
  var loginAction = async (options) => {
84658
84634
  try {
84659
84635
  if (!options.force && await authManager.isAuthenticated()) {
@@ -84686,8 +84662,26 @@ var loginAction = async (options) => {
84686
84662
  print("Let's get you authenticated.");
84687
84663
  console.log();
84688
84664
  }
84665
+ const ignored = options.provider ? "--provider is deprecated and" : process.env.INWORLD_AUTH_OAUTH_PROVIDER ? "INWORLD_AUTH_OAUTH_PROVIDER is" : void 0;
84666
+ if (ignored) {
84667
+ print(
84668
+ `Note: ${ignored} ignored. Choose the sign-in method in the browser.`
84669
+ );
84670
+ console.log();
84671
+ }
84689
84672
  const source = await resolveIdentitySource(PLATFORM_URL);
84690
- const tokens = await signIn(source, options.provider);
84673
+ const tokens = await signInWithDeviceCode({
84674
+ source,
84675
+ platformUrl: PLATFORM_URL,
84676
+ clientId: INWORLD_CLI_CLIENT_ID,
84677
+ env: INWORLD_ENV,
84678
+ out: {
84679
+ print,
84680
+ printLink,
84681
+ printError,
84682
+ output: process.stdout
84683
+ }
84684
+ });
84691
84685
  console.log();
84692
84686
  success("\u2713 Authentication successful!");
84693
84687
  console.log();
@@ -84698,7 +84692,9 @@ var loginAction = async (options) => {
84698
84692
  tokens.idToken,
84699
84693
  tokens.refreshToken,
84700
84694
  tokens.email ?? "",
84701
- source,
84695
+ // The client id is stored with the session, so it refreshes through
84696
+ // `/oauth/token` as it signed in.
84697
+ { ...source, clientId: INWORLD_CLI_CLIENT_ID },
84702
84698
  /* workspace */
84703
84699
  void 0,
84704
84700
  INWORLD_ENV
@@ -84721,8 +84717,8 @@ var loginAction = async (options) => {
84721
84717
  process.exit(0);
84722
84718
  } catch (error2) {
84723
84719
  console.log();
84724
- printError("Authentication failed:");
84725
- console.error(error2);
84720
+ const message = error2 instanceof Error ? error2.message : String(error2);
84721
+ printError(`Authentication failed. ${message}`);
84726
84722
  process.exit(1);
84727
84723
  }
84728
84724
  };
@@ -84730,8 +84726,8 @@ var makeLoginCommand = (description) => {
84730
84726
  return new Command("login").description(description).option("-f, --force", "Force re-authentication even if already logged in").addOption(
84731
84727
  new Option(
84732
84728
  "-p, --provider <provider>",
84733
- "Open an OAuth provider directly, or use email-link sign-in in the browser"
84734
- ).choices([...GOTRUE_OAUTH_PROVIDERS, "email"]).default(process.env.INWORLD_AUTH_OAUTH_PROVIDER || void 0)
84729
+ "Deprecated and ignored: choose the sign-in method in the browser"
84730
+ ).hideHelp()
84735
84731
  ).action(loginAction);
84736
84732
  };
84737
84733
  var loginCommand = makeLoginCommand(
@@ -84855,6 +84851,7 @@ var logoutCommand = makeLogoutCommand(
84855
84851
 
84856
84852
  // src/commands/auth/status_command.ts
84857
84853
  init_runtime_credential();
84854
+ init_constants5();
84858
84855
  var statusAction = async () => {
84859
84856
  try {
84860
84857
  const credentials = await authManager.getCredentials();
@@ -84873,8 +84870,9 @@ INWORLD_API_KEY environment variable: ${trimBase64Key(apiKey)} (active)`
84873
84870
  }
84874
84871
  printBright("Authentication:");
84875
84872
  print(` Email: ${credentials.email}`);
84876
- if (credentials.env !== "PROD") {
84877
- print(` Environment: ${credentials.env}`);
84873
+ const environment = resolveDeployment(credentials.env);
84874
+ if (environment !== "PROD") {
84875
+ print(` Environment: ${environment}`);
84878
84876
  }
84879
84877
  if (credentials.inworldToken) {
84880
84878
  const isExpired = credentials.expiresAt && Date.now() > credentials.expiresAt;
@@ -84930,7 +84928,7 @@ var statusCommandAlias = makeStatusCommand(
84930
84928
  // src/services/analytics.ts
84931
84929
  init_source();
84932
84930
  var import_mixpanel = __toESM(require_mixpanel_node(), 1);
84933
- init_constants5();
84931
+ init_constants6();
84934
84932
  var Analytics = class _Analytics {
84935
84933
  static CONF_ENTRY_NAME = "analytics";
84936
84934
  conf;
@@ -85087,7 +85085,7 @@ var enableTelemetryAction = async () => {
85087
85085
  var enableTelemetryCommand = new Command("enable_cli_telemetry").description("Enable anonymous CLI usage analytics").action(enableTelemetryAction);
85088
85086
 
85089
85087
  // src/commands/auth/login_ci_command.ts
85090
- init_constants5();
85088
+ init_constants6();
85091
85089
  init_identity();
85092
85090
  var loginCiAction = async (options) => {
85093
85091
  try {
@@ -85158,7 +85156,7 @@ var authCommand = new Command("auth").description("Manage Inworld authentication
85158
85156
  });
85159
85157
 
85160
85158
  // src/services/llm_service.ts
85161
- init_constants5();
85159
+ init_constants6();
85162
85160
  init_client_info();
85163
85161
  var LLMService = class {
85164
85162
  get apiBaseUrl() {
@@ -85401,7 +85399,7 @@ var mcpCommand = new Command("mcp").description(
85401
85399
  import { readFile as readFile5 } from "fs/promises";
85402
85400
 
85403
85401
  // src/services/stt_service.ts
85404
- init_constants5();
85402
+ init_constants6();
85405
85403
  init_client_info();
85406
85404
  var STT_MODELS = {
85407
85405
  INWORLD_STT_1: "inworld/inworld-stt-1",
@@ -86397,12 +86395,12 @@ var workspaceCommand = new Command("workspace").description("Manage Inworld work
86397
86395
  });
86398
86396
 
86399
86397
  // src/index.ts
86400
- init_constants5();
86398
+ init_constants6();
86401
86399
 
86402
86400
  // src/services/update_checker.ts
86403
86401
  init_source();
86404
86402
  var semver2 = __toESM(require_semver2(), 1);
86405
- init_constants5();
86403
+ init_constants6();
86406
86404
  var UpdateChecker = class _UpdateChecker {
86407
86405
  static PACKAGE_NAME = "@inworld/cli";
86408
86406
  static CHECK_INTERVAL = 24 * 60 * 60 * 1e3;
@@ -86551,8 +86549,8 @@ var InworldCLI = class {
86551
86549
  }
86552
86550
  setupProgram() {
86553
86551
  this.program.name("inworld").description("Inworld CLI").version(version2, "--version").configureOutput({
86554
- writeOut: (str) => process.stdout.write(str),
86555
- writeErr: (str) => process.stderr.write(str),
86552
+ writeOut: (str2) => process.stdout.write(str2),
86553
+ writeErr: (str2) => process.stderr.write(str2),
86556
86554
  getOutHelpWidth: () => process.stdout.columns || 80,
86557
86555
  getErrHelpWidth: () => process.stderr.columns || 80
86558
86556
  }).hook("preAction", (_thisCommand, actionCommand) => {