@telepath-computer/television 0.1.103 → 0.1.105

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/cli.cjs CHANGED
@@ -6173,9 +6173,8 @@ var require_side_channel_list = __commonJS({
6173
6173
  }
6174
6174
  },
6175
6175
  "delete": function(key) {
6176
- var root = $o && $o.next;
6177
6176
  var deletedNode = listDelete($o, key);
6178
- if (deletedNode && root && root === deletedNode) {
6177
+ if (deletedNode && $o && !$o.next) {
6179
6178
  $o = void 0;
6180
6179
  }
6181
6180
  return !!deletedNode;
@@ -21706,10 +21705,7 @@ var require_json = __commonJS({
21706
21705
  var index = str.indexOf(char);
21707
21706
  var partial2 = "";
21708
21707
  if (index !== -1) {
21709
- partial2 = str.substring(0, index) + JSON_SYNTAX_CHAR;
21710
- for (var i = index + 1; i < str.length; i++) {
21711
- partial2 += JSON_SYNTAX_CHAR;
21712
- }
21708
+ partial2 = str.substring(0, index) + new Array(str.length - index + 1).join(JSON_SYNTAX_CHAR);
21713
21709
  }
21714
21710
  try {
21715
21711
  JSON.parse(partial2);
@@ -21876,9 +21872,9 @@ var require_text = __commonJS({
21876
21872
  }
21877
21873
  });
21878
21874
 
21879
- // ../../node_modules/qs/lib/formats.js
21875
+ // ../../node_modules/body-parser/node_modules/qs/lib/formats.js
21880
21876
  var require_formats = __commonJS({
21881
- "../../node_modules/qs/lib/formats.js"(exports2, module2) {
21877
+ "../../node_modules/body-parser/node_modules/qs/lib/formats.js"(exports2, module2) {
21882
21878
  "use strict";
21883
21879
  var replace = String.prototype.replace;
21884
21880
  var percentTwenties = /%20/g;
@@ -21902,9 +21898,9 @@ var require_formats = __commonJS({
21902
21898
  }
21903
21899
  });
21904
21900
 
21905
- // ../../node_modules/qs/lib/utils.js
21901
+ // ../../node_modules/body-parser/node_modules/qs/lib/utils.js
21906
21902
  var require_utils = __commonJS({
21907
- "../../node_modules/qs/lib/utils.js"(exports2, module2) {
21903
+ "../../node_modules/body-parser/node_modules/qs/lib/utils.js"(exports2, module2) {
21908
21904
  "use strict";
21909
21905
  var formats = require_formats();
21910
21906
  var getSideChannel = require_side_channel();
@@ -21971,6 +21967,8 @@ var require_utils = __commonJS({
21971
21967
  var newIndex = getMaxIndex(target) + 1;
21972
21968
  target[newIndex] = source;
21973
21969
  setMaxIndex(target, newIndex);
21970
+ } else if (options && options.strictMerge) {
21971
+ return [target, source];
21974
21972
  } else if (options && (options.plainObjects || options.allowPrototypes) || !has.call(Object.prototype, source)) {
21975
21973
  target[source] = true;
21976
21974
  }
@@ -22164,9 +22162,9 @@ var require_utils = __commonJS({
22164
22162
  }
22165
22163
  });
22166
22164
 
22167
- // ../../node_modules/qs/lib/stringify.js
22165
+ // ../../node_modules/body-parser/node_modules/qs/lib/stringify.js
22168
22166
  var require_stringify = __commonJS({
22169
- "../../node_modules/qs/lib/stringify.js"(exports2, module2) {
22167
+ "../../node_modules/body-parser/node_modules/qs/lib/stringify.js"(exports2, module2) {
22170
22168
  "use strict";
22171
22169
  var getSideChannel = require_side_channel();
22172
22170
  var utils = require_utils();
@@ -22447,9 +22445,9 @@ var require_stringify = __commonJS({
22447
22445
  }
22448
22446
  });
22449
22447
 
22450
- // ../../node_modules/qs/lib/parse.js
22448
+ // ../../node_modules/body-parser/node_modules/qs/lib/parse.js
22451
22449
  var require_parse = __commonJS({
22452
- "../../node_modules/qs/lib/parse.js"(exports2, module2) {
22450
+ "../../node_modules/body-parser/node_modules/qs/lib/parse.js"(exports2, module2) {
22453
22451
  "use strict";
22454
22452
  var utils = require_utils();
22455
22453
  var has = Object.prototype.hasOwnProperty;
@@ -22474,6 +22472,7 @@ var require_parse = __commonJS({
22474
22472
  parseArrays: true,
22475
22473
  plainObjects: false,
22476
22474
  strictDepth: false,
22475
+ strictMerge: true,
22477
22476
  strictNullHandling: false,
22478
22477
  throwOnLimitExceeded: false
22479
22478
  };
@@ -22500,9 +22499,9 @@ var require_parse = __commonJS({
22500
22499
  var limit = options.parameterLimit === Infinity ? void 0 : options.parameterLimit;
22501
22500
  var parts = cleanStr.split(
22502
22501
  options.delimiter,
22503
- options.throwOnLimitExceeded ? limit + 1 : limit
22502
+ options.throwOnLimitExceeded && typeof limit !== "undefined" ? limit + 1 : limit
22504
22503
  );
22505
- if (options.throwOnLimitExceeded && parts.length > limit) {
22504
+ if (options.throwOnLimitExceeded && typeof limit !== "undefined" && parts.length > limit) {
22506
22505
  throw new RangeError("Parameter limit exceeded. Only " + limit + " parameter" + (limit === 1 ? "" : "s") + " allowed.");
22507
22506
  }
22508
22507
  var skipIndex = -1;
@@ -22562,7 +22561,7 @@ var require_parse = __commonJS({
22562
22561
  }
22563
22562
  if (key !== null) {
22564
22563
  var existing = has.call(obj, key);
22565
- if (existing && options.duplicates === "combine") {
22564
+ if (existing && (options.duplicates === "combine" || part.indexOf("[]=") > -1)) {
22566
22565
  obj[key] = utils.combine(
22567
22566
  obj[key],
22568
22567
  val,
@@ -22719,6 +22718,7 @@ var require_parse = __commonJS({
22719
22718
  parseArrays: opts.parseArrays !== false,
22720
22719
  plainObjects: typeof opts.plainObjects === "boolean" ? opts.plainObjects : defaults.plainObjects,
22721
22720
  strictDepth: typeof opts.strictDepth === "boolean" ? !!opts.strictDepth : defaults.strictDepth,
22721
+ strictMerge: typeof opts.strictMerge === "boolean" ? !!opts.strictMerge : defaults.strictMerge,
22722
22722
  strictNullHandling: typeof opts.strictNullHandling === "boolean" ? opts.strictNullHandling : defaults.strictNullHandling,
22723
22723
  throwOnLimitExceeded: typeof opts.throwOnLimitExceeded === "boolean" ? opts.throwOnLimitExceeded : false
22724
22724
  };
@@ -22744,9 +22744,9 @@ var require_parse = __commonJS({
22744
22744
  }
22745
22745
  });
22746
22746
 
22747
- // ../../node_modules/qs/lib/index.js
22747
+ // ../../node_modules/body-parser/node_modules/qs/lib/index.js
22748
22748
  var require_lib2 = __commonJS({
22749
- "../../node_modules/qs/lib/index.js"(exports2, module2) {
22749
+ "../../node_modules/body-parser/node_modules/qs/lib/index.js"(exports2, module2) {
22750
22750
  "use strict";
22751
22751
  var stringify = require_stringify();
22752
22752
  var parse3 = require_parse();
@@ -22877,14 +22877,14 @@ var require_urlencoded = __commonJS({
22877
22877
  }
22878
22878
  function parameterCount(body, limit) {
22879
22879
  var count = 0;
22880
- var index = 0;
22881
- while ((index = body.indexOf("&", index)) !== -1) {
22880
+ var index = -1;
22881
+ do {
22882
22882
  count++;
22883
- index++;
22884
- if (count === limit) {
22883
+ if (count > limit) {
22885
22884
  return void 0;
22886
22885
  }
22887
- }
22886
+ index = body.indexOf("&", index + 1);
22887
+ } while (index !== -1);
22888
22888
  return count;
22889
22889
  }
22890
22890
  function parser(name) {
@@ -24993,13 +24993,896 @@ var require_init = __commonJS({
24993
24993
  }
24994
24994
  });
24995
24995
 
24996
+ // ../../node_modules/qs/lib/formats.js
24997
+ var require_formats2 = __commonJS({
24998
+ "../../node_modules/qs/lib/formats.js"(exports2, module2) {
24999
+ "use strict";
25000
+ var replace = String.prototype.replace;
25001
+ var percentTwenties = /%20/g;
25002
+ var Format = {
25003
+ RFC1738: "RFC1738",
25004
+ RFC3986: "RFC3986"
25005
+ };
25006
+ module2.exports = {
25007
+ "default": Format.RFC3986,
25008
+ formatters: {
25009
+ RFC1738: function(value) {
25010
+ return replace.call(value, percentTwenties, "+");
25011
+ },
25012
+ RFC3986: function(value) {
25013
+ return String(value);
25014
+ }
25015
+ },
25016
+ RFC1738: Format.RFC1738,
25017
+ RFC3986: Format.RFC3986
25018
+ };
25019
+ }
25020
+ });
25021
+
25022
+ // ../../node_modules/qs/lib/utils.js
25023
+ var require_utils2 = __commonJS({
25024
+ "../../node_modules/qs/lib/utils.js"(exports2, module2) {
25025
+ "use strict";
25026
+ var formats = require_formats2();
25027
+ var getSideChannel = require_side_channel();
25028
+ var has = Object.prototype.hasOwnProperty;
25029
+ var isArray = Array.isArray;
25030
+ var overflowChannel = getSideChannel();
25031
+ var markOverflow = function markOverflow2(obj, maxIndex) {
25032
+ overflowChannel.set(obj, maxIndex);
25033
+ return obj;
25034
+ };
25035
+ var isOverflow = function isOverflow2(obj) {
25036
+ return overflowChannel.has(obj);
25037
+ };
25038
+ var getMaxIndex = function getMaxIndex2(obj) {
25039
+ return overflowChannel.get(obj);
25040
+ };
25041
+ var setMaxIndex = function setMaxIndex2(obj, maxIndex) {
25042
+ overflowChannel.set(obj, maxIndex);
25043
+ };
25044
+ var hexTable = function() {
25045
+ var array2 = [];
25046
+ for (var i = 0; i < 256; ++i) {
25047
+ array2[array2.length] = "%" + ((i < 16 ? "0" : "") + i.toString(16)).toUpperCase();
25048
+ }
25049
+ return array2;
25050
+ }();
25051
+ var compactQueue = function compactQueue2(queue) {
25052
+ while (queue.length > 1) {
25053
+ var item = queue.pop();
25054
+ var obj = item.obj[item.prop];
25055
+ if (isArray(obj)) {
25056
+ var compacted = [];
25057
+ for (var j = 0; j < obj.length; ++j) {
25058
+ if (typeof obj[j] !== "undefined") {
25059
+ compacted[compacted.length] = obj[j];
25060
+ }
25061
+ }
25062
+ item.obj[item.prop] = compacted;
25063
+ }
25064
+ }
25065
+ };
25066
+ var arrayToObject = function arrayToObject2(source, options) {
25067
+ var obj = options && options.plainObjects ? { __proto__: null } : {};
25068
+ for (var i = 0; i < source.length; ++i) {
25069
+ if (typeof source[i] !== "undefined") {
25070
+ obj[i] = source[i];
25071
+ }
25072
+ }
25073
+ return obj;
25074
+ };
25075
+ var merge2 = function merge3(target, source, options) {
25076
+ if (!source) {
25077
+ return target;
25078
+ }
25079
+ if (typeof source !== "object" && typeof source !== "function") {
25080
+ if (isArray(target)) {
25081
+ var nextIndex = target.length;
25082
+ if (options && typeof options.arrayLimit === "number" && nextIndex > options.arrayLimit) {
25083
+ return markOverflow(arrayToObject(target.concat(source), options), nextIndex);
25084
+ }
25085
+ target[nextIndex] = source;
25086
+ } else if (target && typeof target === "object") {
25087
+ if (isOverflow(target)) {
25088
+ var newIndex = getMaxIndex(target) + 1;
25089
+ target[newIndex] = source;
25090
+ setMaxIndex(target, newIndex);
25091
+ } else if (options && (options.plainObjects || options.allowPrototypes) || !has.call(Object.prototype, source)) {
25092
+ target[source] = true;
25093
+ }
25094
+ } else {
25095
+ return [target, source];
25096
+ }
25097
+ return target;
25098
+ }
25099
+ if (!target || typeof target !== "object") {
25100
+ if (isOverflow(source)) {
25101
+ var sourceKeys = Object.keys(source);
25102
+ var result = options && options.plainObjects ? { __proto__: null, 0: target } : { 0: target };
25103
+ for (var m = 0; m < sourceKeys.length; m++) {
25104
+ var oldKey = parseInt(sourceKeys[m], 10);
25105
+ result[oldKey + 1] = source[sourceKeys[m]];
25106
+ }
25107
+ return markOverflow(result, getMaxIndex(source) + 1);
25108
+ }
25109
+ var combined = [target].concat(source);
25110
+ if (options && typeof options.arrayLimit === "number" && combined.length > options.arrayLimit) {
25111
+ return markOverflow(arrayToObject(combined, options), combined.length - 1);
25112
+ }
25113
+ return combined;
25114
+ }
25115
+ var mergeTarget = target;
25116
+ if (isArray(target) && !isArray(source)) {
25117
+ mergeTarget = arrayToObject(target, options);
25118
+ }
25119
+ if (isArray(target) && isArray(source)) {
25120
+ source.forEach(function(item, i) {
25121
+ if (has.call(target, i)) {
25122
+ var targetItem = target[i];
25123
+ if (targetItem && typeof targetItem === "object" && item && typeof item === "object") {
25124
+ target[i] = merge3(targetItem, item, options);
25125
+ } else {
25126
+ target[target.length] = item;
25127
+ }
25128
+ } else {
25129
+ target[i] = item;
25130
+ }
25131
+ });
25132
+ return target;
25133
+ }
25134
+ return Object.keys(source).reduce(function(acc, key) {
25135
+ var value = source[key];
25136
+ if (has.call(acc, key)) {
25137
+ acc[key] = merge3(acc[key], value, options);
25138
+ } else {
25139
+ acc[key] = value;
25140
+ }
25141
+ if (isOverflow(source) && !isOverflow(acc)) {
25142
+ markOverflow(acc, getMaxIndex(source));
25143
+ }
25144
+ if (isOverflow(acc)) {
25145
+ var keyNum = parseInt(key, 10);
25146
+ if (String(keyNum) === key && keyNum >= 0 && keyNum > getMaxIndex(acc)) {
25147
+ setMaxIndex(acc, keyNum);
25148
+ }
25149
+ }
25150
+ return acc;
25151
+ }, mergeTarget);
25152
+ };
25153
+ var assign = function assignSingleSource(target, source) {
25154
+ return Object.keys(source).reduce(function(acc, key) {
25155
+ acc[key] = source[key];
25156
+ return acc;
25157
+ }, target);
25158
+ };
25159
+ var decode3 = function(str, defaultDecoder, charset) {
25160
+ var strWithoutPlus = str.replace(/\+/g, " ");
25161
+ if (charset === "iso-8859-1") {
25162
+ return strWithoutPlus.replace(/%[0-9a-f]{2}/gi, unescape);
25163
+ }
25164
+ try {
25165
+ return decodeURIComponent(strWithoutPlus);
25166
+ } catch (e) {
25167
+ return strWithoutPlus;
25168
+ }
25169
+ };
25170
+ var limit = 1024;
25171
+ var encode3 = function encode4(str, defaultEncoder, charset, kind, format) {
25172
+ if (str.length === 0) {
25173
+ return str;
25174
+ }
25175
+ var string4 = str;
25176
+ if (typeof str === "symbol") {
25177
+ string4 = Symbol.prototype.toString.call(str);
25178
+ } else if (typeof str !== "string") {
25179
+ string4 = String(str);
25180
+ }
25181
+ if (charset === "iso-8859-1") {
25182
+ return escape(string4).replace(/%u[0-9a-f]{4}/gi, function($0) {
25183
+ return "%26%23" + parseInt($0.slice(2), 16) + "%3B";
25184
+ });
25185
+ }
25186
+ var out = "";
25187
+ for (var j = 0; j < string4.length; j += limit) {
25188
+ var segment = string4.length >= limit ? string4.slice(j, j + limit) : string4;
25189
+ var arr = [];
25190
+ for (var i = 0; i < segment.length; ++i) {
25191
+ var c = segment.charCodeAt(i);
25192
+ if (c === 45 || c === 46 || c === 95 || c === 126 || c >= 48 && c <= 57 || c >= 65 && c <= 90 || c >= 97 && c <= 122 || format === formats.RFC1738 && (c === 40 || c === 41)) {
25193
+ arr[arr.length] = segment.charAt(i);
25194
+ continue;
25195
+ }
25196
+ if (c < 128) {
25197
+ arr[arr.length] = hexTable[c];
25198
+ continue;
25199
+ }
25200
+ if (c < 2048) {
25201
+ arr[arr.length] = hexTable[192 | c >> 6] + hexTable[128 | c & 63];
25202
+ continue;
25203
+ }
25204
+ if (c < 55296 || c >= 57344) {
25205
+ arr[arr.length] = hexTable[224 | c >> 12] + hexTable[128 | c >> 6 & 63] + hexTable[128 | c & 63];
25206
+ continue;
25207
+ }
25208
+ i += 1;
25209
+ c = 65536 + ((c & 1023) << 10 | segment.charCodeAt(i) & 1023);
25210
+ arr[arr.length] = hexTable[240 | c >> 18] + hexTable[128 | c >> 12 & 63] + hexTable[128 | c >> 6 & 63] + hexTable[128 | c & 63];
25211
+ }
25212
+ out += arr.join("");
25213
+ }
25214
+ return out;
25215
+ };
25216
+ var compact = function compact2(value) {
25217
+ var queue = [{ obj: { o: value }, prop: "o" }];
25218
+ var refs = [];
25219
+ for (var i = 0; i < queue.length; ++i) {
25220
+ var item = queue[i];
25221
+ var obj = item.obj[item.prop];
25222
+ var keys = Object.keys(obj);
25223
+ for (var j = 0; j < keys.length; ++j) {
25224
+ var key = keys[j];
25225
+ var val = obj[key];
25226
+ if (typeof val === "object" && val !== null && refs.indexOf(val) === -1) {
25227
+ queue[queue.length] = { obj, prop: key };
25228
+ refs[refs.length] = val;
25229
+ }
25230
+ }
25231
+ }
25232
+ compactQueue(queue);
25233
+ return value;
25234
+ };
25235
+ var isRegExp = function isRegExp2(obj) {
25236
+ return Object.prototype.toString.call(obj) === "[object RegExp]";
25237
+ };
25238
+ var isBuffer = function isBuffer2(obj) {
25239
+ if (!obj || typeof obj !== "object") {
25240
+ return false;
25241
+ }
25242
+ return !!(obj.constructor && obj.constructor.isBuffer && obj.constructor.isBuffer(obj));
25243
+ };
25244
+ var combine = function combine2(a, b, arrayLimit, plainObjects) {
25245
+ if (isOverflow(a)) {
25246
+ var newIndex = getMaxIndex(a) + 1;
25247
+ a[newIndex] = b;
25248
+ setMaxIndex(a, newIndex);
25249
+ return a;
25250
+ }
25251
+ var result = [].concat(a, b);
25252
+ if (result.length > arrayLimit) {
25253
+ return markOverflow(arrayToObject(result, { plainObjects }), result.length - 1);
25254
+ }
25255
+ return result;
25256
+ };
25257
+ var maybeMap = function maybeMap2(val, fn) {
25258
+ if (isArray(val)) {
25259
+ var mapped = [];
25260
+ for (var i = 0; i < val.length; i += 1) {
25261
+ mapped[mapped.length] = fn(val[i]);
25262
+ }
25263
+ return mapped;
25264
+ }
25265
+ return fn(val);
25266
+ };
25267
+ module2.exports = {
25268
+ arrayToObject,
25269
+ assign,
25270
+ combine,
25271
+ compact,
25272
+ decode: decode3,
25273
+ encode: encode3,
25274
+ isBuffer,
25275
+ isOverflow,
25276
+ isRegExp,
25277
+ markOverflow,
25278
+ maybeMap,
25279
+ merge: merge2
25280
+ };
25281
+ }
25282
+ });
25283
+
25284
+ // ../../node_modules/qs/lib/stringify.js
25285
+ var require_stringify2 = __commonJS({
25286
+ "../../node_modules/qs/lib/stringify.js"(exports2, module2) {
25287
+ "use strict";
25288
+ var getSideChannel = require_side_channel();
25289
+ var utils = require_utils2();
25290
+ var formats = require_formats2();
25291
+ var has = Object.prototype.hasOwnProperty;
25292
+ var arrayPrefixGenerators = {
25293
+ brackets: function brackets(prefix) {
25294
+ return prefix + "[]";
25295
+ },
25296
+ comma: "comma",
25297
+ indices: function indices(prefix, key) {
25298
+ return prefix + "[" + key + "]";
25299
+ },
25300
+ repeat: function repeat(prefix) {
25301
+ return prefix;
25302
+ }
25303
+ };
25304
+ var isArray = Array.isArray;
25305
+ var push = Array.prototype.push;
25306
+ var pushToArray = function(arr, valueOrArray) {
25307
+ push.apply(arr, isArray(valueOrArray) ? valueOrArray : [valueOrArray]);
25308
+ };
25309
+ var toISO = Date.prototype.toISOString;
25310
+ var defaultFormat = formats["default"];
25311
+ var defaults = {
25312
+ addQueryPrefix: false,
25313
+ allowDots: false,
25314
+ allowEmptyArrays: false,
25315
+ arrayFormat: "indices",
25316
+ charset: "utf-8",
25317
+ charsetSentinel: false,
25318
+ commaRoundTrip: false,
25319
+ delimiter: "&",
25320
+ encode: true,
25321
+ encodeDotInKeys: false,
25322
+ encoder: utils.encode,
25323
+ encodeValuesOnly: false,
25324
+ filter: void 0,
25325
+ format: defaultFormat,
25326
+ formatter: formats.formatters[defaultFormat],
25327
+ // deprecated
25328
+ indices: false,
25329
+ serializeDate: function serializeDate(date5) {
25330
+ return toISO.call(date5);
25331
+ },
25332
+ skipNulls: false,
25333
+ strictNullHandling: false
25334
+ };
25335
+ var isNonNullishPrimitive = function isNonNullishPrimitive2(v) {
25336
+ return typeof v === "string" || typeof v === "number" || typeof v === "boolean" || typeof v === "symbol" || typeof v === "bigint";
25337
+ };
25338
+ var sentinel = {};
25339
+ var stringify = function stringify2(object2, prefix, generateArrayPrefix, commaRoundTrip, allowEmptyArrays, strictNullHandling, skipNulls, encodeDotInKeys, encoder, filter, sort, allowDots, serializeDate, format, formatter, encodeValuesOnly, charset, sideChannel) {
25340
+ var obj = object2;
25341
+ var tmpSc = sideChannel;
25342
+ var step = 0;
25343
+ var findFlag = false;
25344
+ while ((tmpSc = tmpSc.get(sentinel)) !== void 0 && !findFlag) {
25345
+ var pos = tmpSc.get(object2);
25346
+ step += 1;
25347
+ if (typeof pos !== "undefined") {
25348
+ if (pos === step) {
25349
+ throw new RangeError("Cyclic object value");
25350
+ } else {
25351
+ findFlag = true;
25352
+ }
25353
+ }
25354
+ if (typeof tmpSc.get(sentinel) === "undefined") {
25355
+ step = 0;
25356
+ }
25357
+ }
25358
+ if (typeof filter === "function") {
25359
+ obj = filter(prefix, obj);
25360
+ } else if (obj instanceof Date) {
25361
+ obj = serializeDate(obj);
25362
+ } else if (generateArrayPrefix === "comma" && isArray(obj)) {
25363
+ obj = utils.maybeMap(obj, function(value2) {
25364
+ if (value2 instanceof Date) {
25365
+ return serializeDate(value2);
25366
+ }
25367
+ return value2;
25368
+ });
25369
+ }
25370
+ if (obj === null) {
25371
+ if (strictNullHandling) {
25372
+ return encoder && !encodeValuesOnly ? encoder(prefix, defaults.encoder, charset, "key", format) : prefix;
25373
+ }
25374
+ obj = "";
25375
+ }
25376
+ if (isNonNullishPrimitive(obj) || utils.isBuffer(obj)) {
25377
+ if (encoder) {
25378
+ var keyValue = encodeValuesOnly ? prefix : encoder(prefix, defaults.encoder, charset, "key", format);
25379
+ return [formatter(keyValue) + "=" + formatter(encoder(obj, defaults.encoder, charset, "value", format))];
25380
+ }
25381
+ return [formatter(prefix) + "=" + formatter(String(obj))];
25382
+ }
25383
+ var values = [];
25384
+ if (typeof obj === "undefined") {
25385
+ return values;
25386
+ }
25387
+ var objKeys;
25388
+ if (generateArrayPrefix === "comma" && isArray(obj)) {
25389
+ if (encodeValuesOnly && encoder) {
25390
+ obj = utils.maybeMap(obj, encoder);
25391
+ }
25392
+ objKeys = [{ value: obj.length > 0 ? obj.join(",") || null : void 0 }];
25393
+ } else if (isArray(filter)) {
25394
+ objKeys = filter;
25395
+ } else {
25396
+ var keys = Object.keys(obj);
25397
+ objKeys = sort ? keys.sort(sort) : keys;
25398
+ }
25399
+ var encodedPrefix = encodeDotInKeys ? String(prefix).replace(/\./g, "%2E") : String(prefix);
25400
+ var adjustedPrefix = commaRoundTrip && isArray(obj) && obj.length === 1 ? encodedPrefix + "[]" : encodedPrefix;
25401
+ if (allowEmptyArrays && isArray(obj) && obj.length === 0) {
25402
+ return adjustedPrefix + "[]";
25403
+ }
25404
+ for (var j = 0; j < objKeys.length; ++j) {
25405
+ var key = objKeys[j];
25406
+ var value = typeof key === "object" && key && typeof key.value !== "undefined" ? key.value : obj[key];
25407
+ if (skipNulls && value === null) {
25408
+ continue;
25409
+ }
25410
+ var encodedKey = allowDots && encodeDotInKeys ? String(key).replace(/\./g, "%2E") : String(key);
25411
+ var keyPrefix = isArray(obj) ? typeof generateArrayPrefix === "function" ? generateArrayPrefix(adjustedPrefix, encodedKey) : adjustedPrefix : adjustedPrefix + (allowDots ? "." + encodedKey : "[" + encodedKey + "]");
25412
+ sideChannel.set(object2, step);
25413
+ var valueSideChannel = getSideChannel();
25414
+ valueSideChannel.set(sentinel, sideChannel);
25415
+ pushToArray(values, stringify2(
25416
+ value,
25417
+ keyPrefix,
25418
+ generateArrayPrefix,
25419
+ commaRoundTrip,
25420
+ allowEmptyArrays,
25421
+ strictNullHandling,
25422
+ skipNulls,
25423
+ encodeDotInKeys,
25424
+ generateArrayPrefix === "comma" && encodeValuesOnly && isArray(obj) ? null : encoder,
25425
+ filter,
25426
+ sort,
25427
+ allowDots,
25428
+ serializeDate,
25429
+ format,
25430
+ formatter,
25431
+ encodeValuesOnly,
25432
+ charset,
25433
+ valueSideChannel
25434
+ ));
25435
+ }
25436
+ return values;
25437
+ };
25438
+ var normalizeStringifyOptions = function normalizeStringifyOptions2(opts) {
25439
+ if (!opts) {
25440
+ return defaults;
25441
+ }
25442
+ if (typeof opts.allowEmptyArrays !== "undefined" && typeof opts.allowEmptyArrays !== "boolean") {
25443
+ throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");
25444
+ }
25445
+ if (typeof opts.encodeDotInKeys !== "undefined" && typeof opts.encodeDotInKeys !== "boolean") {
25446
+ throw new TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided");
25447
+ }
25448
+ if (opts.encoder !== null && typeof opts.encoder !== "undefined" && typeof opts.encoder !== "function") {
25449
+ throw new TypeError("Encoder has to be a function.");
25450
+ }
25451
+ var charset = opts.charset || defaults.charset;
25452
+ if (typeof opts.charset !== "undefined" && opts.charset !== "utf-8" && opts.charset !== "iso-8859-1") {
25453
+ throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");
25454
+ }
25455
+ var format = formats["default"];
25456
+ if (typeof opts.format !== "undefined") {
25457
+ if (!has.call(formats.formatters, opts.format)) {
25458
+ throw new TypeError("Unknown format option provided.");
25459
+ }
25460
+ format = opts.format;
25461
+ }
25462
+ var formatter = formats.formatters[format];
25463
+ var filter = defaults.filter;
25464
+ if (typeof opts.filter === "function" || isArray(opts.filter)) {
25465
+ filter = opts.filter;
25466
+ }
25467
+ var arrayFormat;
25468
+ if (opts.arrayFormat in arrayPrefixGenerators) {
25469
+ arrayFormat = opts.arrayFormat;
25470
+ } else if ("indices" in opts) {
25471
+ arrayFormat = opts.indices ? "indices" : "repeat";
25472
+ } else {
25473
+ arrayFormat = defaults.arrayFormat;
25474
+ }
25475
+ if ("commaRoundTrip" in opts && typeof opts.commaRoundTrip !== "boolean") {
25476
+ throw new TypeError("`commaRoundTrip` must be a boolean, or absent");
25477
+ }
25478
+ var allowDots = typeof opts.allowDots === "undefined" ? opts.encodeDotInKeys === true ? true : defaults.allowDots : !!opts.allowDots;
25479
+ return {
25480
+ addQueryPrefix: typeof opts.addQueryPrefix === "boolean" ? opts.addQueryPrefix : defaults.addQueryPrefix,
25481
+ allowDots,
25482
+ allowEmptyArrays: typeof opts.allowEmptyArrays === "boolean" ? !!opts.allowEmptyArrays : defaults.allowEmptyArrays,
25483
+ arrayFormat,
25484
+ charset,
25485
+ charsetSentinel: typeof opts.charsetSentinel === "boolean" ? opts.charsetSentinel : defaults.charsetSentinel,
25486
+ commaRoundTrip: !!opts.commaRoundTrip,
25487
+ delimiter: typeof opts.delimiter === "undefined" ? defaults.delimiter : opts.delimiter,
25488
+ encode: typeof opts.encode === "boolean" ? opts.encode : defaults.encode,
25489
+ encodeDotInKeys: typeof opts.encodeDotInKeys === "boolean" ? opts.encodeDotInKeys : defaults.encodeDotInKeys,
25490
+ encoder: typeof opts.encoder === "function" ? opts.encoder : defaults.encoder,
25491
+ encodeValuesOnly: typeof opts.encodeValuesOnly === "boolean" ? opts.encodeValuesOnly : defaults.encodeValuesOnly,
25492
+ filter,
25493
+ format,
25494
+ formatter,
25495
+ serializeDate: typeof opts.serializeDate === "function" ? opts.serializeDate : defaults.serializeDate,
25496
+ skipNulls: typeof opts.skipNulls === "boolean" ? opts.skipNulls : defaults.skipNulls,
25497
+ sort: typeof opts.sort === "function" ? opts.sort : null,
25498
+ strictNullHandling: typeof opts.strictNullHandling === "boolean" ? opts.strictNullHandling : defaults.strictNullHandling
25499
+ };
25500
+ };
25501
+ module2.exports = function(object2, opts) {
25502
+ var obj = object2;
25503
+ var options = normalizeStringifyOptions(opts);
25504
+ var objKeys;
25505
+ var filter;
25506
+ if (typeof options.filter === "function") {
25507
+ filter = options.filter;
25508
+ obj = filter("", obj);
25509
+ } else if (isArray(options.filter)) {
25510
+ filter = options.filter;
25511
+ objKeys = filter;
25512
+ }
25513
+ var keys = [];
25514
+ if (typeof obj !== "object" || obj === null) {
25515
+ return "";
25516
+ }
25517
+ var generateArrayPrefix = arrayPrefixGenerators[options.arrayFormat];
25518
+ var commaRoundTrip = generateArrayPrefix === "comma" && options.commaRoundTrip;
25519
+ if (!objKeys) {
25520
+ objKeys = Object.keys(obj);
25521
+ }
25522
+ if (options.sort) {
25523
+ objKeys.sort(options.sort);
25524
+ }
25525
+ var sideChannel = getSideChannel();
25526
+ for (var i = 0; i < objKeys.length; ++i) {
25527
+ var key = objKeys[i];
25528
+ var value = obj[key];
25529
+ if (options.skipNulls && value === null) {
25530
+ continue;
25531
+ }
25532
+ pushToArray(keys, stringify(
25533
+ value,
25534
+ key,
25535
+ generateArrayPrefix,
25536
+ commaRoundTrip,
25537
+ options.allowEmptyArrays,
25538
+ options.strictNullHandling,
25539
+ options.skipNulls,
25540
+ options.encodeDotInKeys,
25541
+ options.encode ? options.encoder : null,
25542
+ options.filter,
25543
+ options.sort,
25544
+ options.allowDots,
25545
+ options.serializeDate,
25546
+ options.format,
25547
+ options.formatter,
25548
+ options.encodeValuesOnly,
25549
+ options.charset,
25550
+ sideChannel
25551
+ ));
25552
+ }
25553
+ var joined = keys.join(options.delimiter);
25554
+ var prefix = options.addQueryPrefix === true ? "?" : "";
25555
+ if (options.charsetSentinel) {
25556
+ if (options.charset === "iso-8859-1") {
25557
+ prefix += "utf8=%26%2310003%3B&";
25558
+ } else {
25559
+ prefix += "utf8=%E2%9C%93&";
25560
+ }
25561
+ }
25562
+ return joined.length > 0 ? prefix + joined : "";
25563
+ };
25564
+ }
25565
+ });
25566
+
25567
+ // ../../node_modules/qs/lib/parse.js
25568
+ var require_parse2 = __commonJS({
25569
+ "../../node_modules/qs/lib/parse.js"(exports2, module2) {
25570
+ "use strict";
25571
+ var utils = require_utils2();
25572
+ var has = Object.prototype.hasOwnProperty;
25573
+ var isArray = Array.isArray;
25574
+ var defaults = {
25575
+ allowDots: false,
25576
+ allowEmptyArrays: false,
25577
+ allowPrototypes: false,
25578
+ allowSparse: false,
25579
+ arrayLimit: 20,
25580
+ charset: "utf-8",
25581
+ charsetSentinel: false,
25582
+ comma: false,
25583
+ decodeDotInKeys: false,
25584
+ decoder: utils.decode,
25585
+ delimiter: "&",
25586
+ depth: 5,
25587
+ duplicates: "combine",
25588
+ ignoreQueryPrefix: false,
25589
+ interpretNumericEntities: false,
25590
+ parameterLimit: 1e3,
25591
+ parseArrays: true,
25592
+ plainObjects: false,
25593
+ strictDepth: false,
25594
+ strictNullHandling: false,
25595
+ throwOnLimitExceeded: false
25596
+ };
25597
+ var interpretNumericEntities = function(str) {
25598
+ return str.replace(/&#(\d+);/g, function($0, numberStr) {
25599
+ return String.fromCharCode(parseInt(numberStr, 10));
25600
+ });
25601
+ };
25602
+ var parseArrayValue = function(val, options, currentArrayLength) {
25603
+ if (val && typeof val === "string" && options.comma && val.indexOf(",") > -1) {
25604
+ return val.split(",");
25605
+ }
25606
+ if (options.throwOnLimitExceeded && currentArrayLength >= options.arrayLimit) {
25607
+ throw new RangeError("Array limit exceeded. Only " + options.arrayLimit + " element" + (options.arrayLimit === 1 ? "" : "s") + " allowed in an array.");
25608
+ }
25609
+ return val;
25610
+ };
25611
+ var isoSentinel = "utf8=%26%2310003%3B";
25612
+ var charsetSentinel = "utf8=%E2%9C%93";
25613
+ var parseValues = function parseQueryStringValues(str, options) {
25614
+ var obj = { __proto__: null };
25615
+ var cleanStr = options.ignoreQueryPrefix ? str.replace(/^\?/, "") : str;
25616
+ cleanStr = cleanStr.replace(/%5B/gi, "[").replace(/%5D/gi, "]");
25617
+ var limit = options.parameterLimit === Infinity ? void 0 : options.parameterLimit;
25618
+ var parts = cleanStr.split(
25619
+ options.delimiter,
25620
+ options.throwOnLimitExceeded ? limit + 1 : limit
25621
+ );
25622
+ if (options.throwOnLimitExceeded && parts.length > limit) {
25623
+ throw new RangeError("Parameter limit exceeded. Only " + limit + " parameter" + (limit === 1 ? "" : "s") + " allowed.");
25624
+ }
25625
+ var skipIndex = -1;
25626
+ var i;
25627
+ var charset = options.charset;
25628
+ if (options.charsetSentinel) {
25629
+ for (i = 0; i < parts.length; ++i) {
25630
+ if (parts[i].indexOf("utf8=") === 0) {
25631
+ if (parts[i] === charsetSentinel) {
25632
+ charset = "utf-8";
25633
+ } else if (parts[i] === isoSentinel) {
25634
+ charset = "iso-8859-1";
25635
+ }
25636
+ skipIndex = i;
25637
+ i = parts.length;
25638
+ }
25639
+ }
25640
+ }
25641
+ for (i = 0; i < parts.length; ++i) {
25642
+ if (i === skipIndex) {
25643
+ continue;
25644
+ }
25645
+ var part = parts[i];
25646
+ var bracketEqualsPos = part.indexOf("]=");
25647
+ var pos = bracketEqualsPos === -1 ? part.indexOf("=") : bracketEqualsPos + 1;
25648
+ var key;
25649
+ var val;
25650
+ if (pos === -1) {
25651
+ key = options.decoder(part, defaults.decoder, charset, "key");
25652
+ val = options.strictNullHandling ? null : "";
25653
+ } else {
25654
+ key = options.decoder(part.slice(0, pos), defaults.decoder, charset, "key");
25655
+ if (key !== null) {
25656
+ val = utils.maybeMap(
25657
+ parseArrayValue(
25658
+ part.slice(pos + 1),
25659
+ options,
25660
+ isArray(obj[key]) ? obj[key].length : 0
25661
+ ),
25662
+ function(encodedVal) {
25663
+ return options.decoder(encodedVal, defaults.decoder, charset, "value");
25664
+ }
25665
+ );
25666
+ }
25667
+ }
25668
+ if (val && options.interpretNumericEntities && charset === "iso-8859-1") {
25669
+ val = interpretNumericEntities(String(val));
25670
+ }
25671
+ if (part.indexOf("[]=") > -1) {
25672
+ val = isArray(val) ? [val] : val;
25673
+ }
25674
+ if (options.comma && isArray(val) && val.length > options.arrayLimit) {
25675
+ if (options.throwOnLimitExceeded) {
25676
+ throw new RangeError("Array limit exceeded. Only " + options.arrayLimit + " element" + (options.arrayLimit === 1 ? "" : "s") + " allowed in an array.");
25677
+ }
25678
+ val = utils.combine([], val, options.arrayLimit, options.plainObjects);
25679
+ }
25680
+ if (key !== null) {
25681
+ var existing = has.call(obj, key);
25682
+ if (existing && options.duplicates === "combine") {
25683
+ obj[key] = utils.combine(
25684
+ obj[key],
25685
+ val,
25686
+ options.arrayLimit,
25687
+ options.plainObjects
25688
+ );
25689
+ } else if (!existing || options.duplicates === "last") {
25690
+ obj[key] = val;
25691
+ }
25692
+ }
25693
+ }
25694
+ return obj;
25695
+ };
25696
+ var parseObject = function(chain, val, options, valuesParsed) {
25697
+ var currentArrayLength = 0;
25698
+ if (chain.length > 0 && chain[chain.length - 1] === "[]") {
25699
+ var parentKey = chain.slice(0, -1).join("");
25700
+ currentArrayLength = Array.isArray(val) && val[parentKey] ? val[parentKey].length : 0;
25701
+ }
25702
+ var leaf = valuesParsed ? val : parseArrayValue(val, options, currentArrayLength);
25703
+ for (var i = chain.length - 1; i >= 0; --i) {
25704
+ var obj;
25705
+ var root = chain[i];
25706
+ if (root === "[]" && options.parseArrays) {
25707
+ if (utils.isOverflow(leaf)) {
25708
+ obj = leaf;
25709
+ } else {
25710
+ obj = options.allowEmptyArrays && (leaf === "" || options.strictNullHandling && leaf === null) ? [] : utils.combine(
25711
+ [],
25712
+ leaf,
25713
+ options.arrayLimit,
25714
+ options.plainObjects
25715
+ );
25716
+ }
25717
+ } else {
25718
+ obj = options.plainObjects ? { __proto__: null } : {};
25719
+ var cleanRoot = root.charAt(0) === "[" && root.charAt(root.length - 1) === "]" ? root.slice(1, -1) : root;
25720
+ var decodedRoot = options.decodeDotInKeys ? cleanRoot.replace(/%2E/g, ".") : cleanRoot;
25721
+ var index = parseInt(decodedRoot, 10);
25722
+ var isValidArrayIndex = !isNaN(index) && root !== decodedRoot && String(index) === decodedRoot && index >= 0 && options.parseArrays;
25723
+ if (!options.parseArrays && decodedRoot === "") {
25724
+ obj = { 0: leaf };
25725
+ } else if (isValidArrayIndex && index < options.arrayLimit) {
25726
+ obj = [];
25727
+ obj[index] = leaf;
25728
+ } else if (isValidArrayIndex && options.throwOnLimitExceeded) {
25729
+ throw new RangeError("Array limit exceeded. Only " + options.arrayLimit + " element" + (options.arrayLimit === 1 ? "" : "s") + " allowed in an array.");
25730
+ } else if (isValidArrayIndex) {
25731
+ obj[index] = leaf;
25732
+ utils.markOverflow(obj, index);
25733
+ } else if (decodedRoot !== "__proto__") {
25734
+ obj[decodedRoot] = leaf;
25735
+ }
25736
+ }
25737
+ leaf = obj;
25738
+ }
25739
+ return leaf;
25740
+ };
25741
+ var splitKeyIntoSegments = function splitKeyIntoSegments2(givenKey, options) {
25742
+ var key = options.allowDots ? givenKey.replace(/\.([^.[]+)/g, "[$1]") : givenKey;
25743
+ if (options.depth <= 0) {
25744
+ if (!options.plainObjects && has.call(Object.prototype, key)) {
25745
+ if (!options.allowPrototypes) {
25746
+ return;
25747
+ }
25748
+ }
25749
+ return [key];
25750
+ }
25751
+ var brackets = /(\[[^[\]]*])/;
25752
+ var child = /(\[[^[\]]*])/g;
25753
+ var segment = brackets.exec(key);
25754
+ var parent = segment ? key.slice(0, segment.index) : key;
25755
+ var keys = [];
25756
+ if (parent) {
25757
+ if (!options.plainObjects && has.call(Object.prototype, parent)) {
25758
+ if (!options.allowPrototypes) {
25759
+ return;
25760
+ }
25761
+ }
25762
+ keys[keys.length] = parent;
25763
+ }
25764
+ var i = 0;
25765
+ while ((segment = child.exec(key)) !== null && i < options.depth) {
25766
+ i += 1;
25767
+ var segmentContent = segment[1].slice(1, -1);
25768
+ if (!options.plainObjects && has.call(Object.prototype, segmentContent)) {
25769
+ if (!options.allowPrototypes) {
25770
+ return;
25771
+ }
25772
+ }
25773
+ keys[keys.length] = segment[1];
25774
+ }
25775
+ if (segment) {
25776
+ if (options.strictDepth === true) {
25777
+ throw new RangeError("Input depth exceeded depth option of " + options.depth + " and strictDepth is true");
25778
+ }
25779
+ keys[keys.length] = "[" + key.slice(segment.index) + "]";
25780
+ }
25781
+ return keys;
25782
+ };
25783
+ var parseKeys = function parseQueryStringKeys(givenKey, val, options, valuesParsed) {
25784
+ if (!givenKey) {
25785
+ return;
25786
+ }
25787
+ var keys = splitKeyIntoSegments(givenKey, options);
25788
+ if (!keys) {
25789
+ return;
25790
+ }
25791
+ return parseObject(keys, val, options, valuesParsed);
25792
+ };
25793
+ var normalizeParseOptions = function normalizeParseOptions2(opts) {
25794
+ if (!opts) {
25795
+ return defaults;
25796
+ }
25797
+ if (typeof opts.allowEmptyArrays !== "undefined" && typeof opts.allowEmptyArrays !== "boolean") {
25798
+ throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");
25799
+ }
25800
+ if (typeof opts.decodeDotInKeys !== "undefined" && typeof opts.decodeDotInKeys !== "boolean") {
25801
+ throw new TypeError("`decodeDotInKeys` option can only be `true` or `false`, when provided");
25802
+ }
25803
+ if (opts.decoder !== null && typeof opts.decoder !== "undefined" && typeof opts.decoder !== "function") {
25804
+ throw new TypeError("Decoder has to be a function.");
25805
+ }
25806
+ if (typeof opts.charset !== "undefined" && opts.charset !== "utf-8" && opts.charset !== "iso-8859-1") {
25807
+ throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");
25808
+ }
25809
+ if (typeof opts.throwOnLimitExceeded !== "undefined" && typeof opts.throwOnLimitExceeded !== "boolean") {
25810
+ throw new TypeError("`throwOnLimitExceeded` option must be a boolean");
25811
+ }
25812
+ var charset = typeof opts.charset === "undefined" ? defaults.charset : opts.charset;
25813
+ var duplicates = typeof opts.duplicates === "undefined" ? defaults.duplicates : opts.duplicates;
25814
+ if (duplicates !== "combine" && duplicates !== "first" && duplicates !== "last") {
25815
+ throw new TypeError("The duplicates option must be either combine, first, or last");
25816
+ }
25817
+ var allowDots = typeof opts.allowDots === "undefined" ? opts.decodeDotInKeys === true ? true : defaults.allowDots : !!opts.allowDots;
25818
+ return {
25819
+ allowDots,
25820
+ allowEmptyArrays: typeof opts.allowEmptyArrays === "boolean" ? !!opts.allowEmptyArrays : defaults.allowEmptyArrays,
25821
+ allowPrototypes: typeof opts.allowPrototypes === "boolean" ? opts.allowPrototypes : defaults.allowPrototypes,
25822
+ allowSparse: typeof opts.allowSparse === "boolean" ? opts.allowSparse : defaults.allowSparse,
25823
+ arrayLimit: typeof opts.arrayLimit === "number" ? opts.arrayLimit : defaults.arrayLimit,
25824
+ charset,
25825
+ charsetSentinel: typeof opts.charsetSentinel === "boolean" ? opts.charsetSentinel : defaults.charsetSentinel,
25826
+ comma: typeof opts.comma === "boolean" ? opts.comma : defaults.comma,
25827
+ decodeDotInKeys: typeof opts.decodeDotInKeys === "boolean" ? opts.decodeDotInKeys : defaults.decodeDotInKeys,
25828
+ decoder: typeof opts.decoder === "function" ? opts.decoder : defaults.decoder,
25829
+ delimiter: typeof opts.delimiter === "string" || utils.isRegExp(opts.delimiter) ? opts.delimiter : defaults.delimiter,
25830
+ // eslint-disable-next-line no-implicit-coercion, no-extra-parens
25831
+ depth: typeof opts.depth === "number" || opts.depth === false ? +opts.depth : defaults.depth,
25832
+ duplicates,
25833
+ ignoreQueryPrefix: opts.ignoreQueryPrefix === true,
25834
+ interpretNumericEntities: typeof opts.interpretNumericEntities === "boolean" ? opts.interpretNumericEntities : defaults.interpretNumericEntities,
25835
+ parameterLimit: typeof opts.parameterLimit === "number" ? opts.parameterLimit : defaults.parameterLimit,
25836
+ parseArrays: opts.parseArrays !== false,
25837
+ plainObjects: typeof opts.plainObjects === "boolean" ? opts.plainObjects : defaults.plainObjects,
25838
+ strictDepth: typeof opts.strictDepth === "boolean" ? !!opts.strictDepth : defaults.strictDepth,
25839
+ strictNullHandling: typeof opts.strictNullHandling === "boolean" ? opts.strictNullHandling : defaults.strictNullHandling,
25840
+ throwOnLimitExceeded: typeof opts.throwOnLimitExceeded === "boolean" ? opts.throwOnLimitExceeded : false
25841
+ };
25842
+ };
25843
+ module2.exports = function(str, opts) {
25844
+ var options = normalizeParseOptions(opts);
25845
+ if (str === "" || str === null || typeof str === "undefined") {
25846
+ return options.plainObjects ? { __proto__: null } : {};
25847
+ }
25848
+ var tempObj = typeof str === "string" ? parseValues(str, options) : str;
25849
+ var obj = options.plainObjects ? { __proto__: null } : {};
25850
+ var keys = Object.keys(tempObj);
25851
+ for (var i = 0; i < keys.length; ++i) {
25852
+ var key = keys[i];
25853
+ var newObj = parseKeys(key, tempObj[key], options, typeof str === "string");
25854
+ obj = utils.merge(obj, newObj, options);
25855
+ }
25856
+ if (options.allowSparse === true) {
25857
+ return obj;
25858
+ }
25859
+ return utils.compact(obj);
25860
+ };
25861
+ }
25862
+ });
25863
+
25864
+ // ../../node_modules/qs/lib/index.js
25865
+ var require_lib3 = __commonJS({
25866
+ "../../node_modules/qs/lib/index.js"(exports2, module2) {
25867
+ "use strict";
25868
+ var stringify = require_stringify2();
25869
+ var parse3 = require_parse2();
25870
+ var formats = require_formats2();
25871
+ module2.exports = {
25872
+ formats,
25873
+ parse: parse3,
25874
+ stringify
25875
+ };
25876
+ }
25877
+ });
25878
+
24996
25879
  // ../../node_modules/express/lib/middleware/query.js
24997
25880
  var require_query = __commonJS({
24998
25881
  "../../node_modules/express/lib/middleware/query.js"(exports2, module2) {
24999
25882
  "use strict";
25000
25883
  var merge2 = require_utils_merge();
25001
25884
  var parseUrl = require_parseurl();
25002
- var qs = require_lib2();
25885
+ var qs = require_lib3();
25003
25886
  module2.exports = function query(options) {
25004
25887
  var opts = merge2({}, options);
25005
25888
  var queryparse = qs.parse;
@@ -27493,7 +28376,7 @@ var require_proxy_addr = __commonJS({
27493
28376
  });
27494
28377
 
27495
28378
  // ../../node_modules/express/lib/utils.js
27496
- var require_utils2 = __commonJS({
28379
+ var require_utils3 = __commonJS({
27497
28380
  "../../node_modules/express/lib/utils.js"(exports2) {
27498
28381
  "use strict";
27499
28382
  var Buffer2 = require_safe_buffer().Buffer;
@@ -27504,7 +28387,7 @@ var require_utils2 = __commonJS({
27504
28387
  var mime = require_send().mime;
27505
28388
  var etag = require_etag();
27506
28389
  var proxyaddr = require_proxy_addr();
27507
- var qs = require_lib2();
28390
+ var qs = require_lib3();
27508
28391
  var querystring = require("querystring");
27509
28392
  exports2.etag = createETagGenerator({ weak: false });
27510
28393
  exports2.wetag = createETagGenerator({ weak: true });
@@ -27641,9 +28524,9 @@ var require_application = __commonJS({
27641
28524
  var debug = require_src3()("express:application");
27642
28525
  var View = require_view();
27643
28526
  var http2 = require("http");
27644
- var compileETag = require_utils2().compileETag;
27645
- var compileQueryParser = require_utils2().compileQueryParser;
27646
- var compileTrust = require_utils2().compileTrust;
28527
+ var compileETag = require_utils3().compileETag;
28528
+ var compileQueryParser = require_utils3().compileQueryParser;
28529
+ var compileTrust = require_utils3().compileTrust;
27647
28530
  var deprecate = require_depd()("express");
27648
28531
  var flatten = require_array_flatten();
27649
28532
  var merge2 = require_utils_merge();
@@ -28918,15 +29801,15 @@ var require_response = __commonJS({
28918
29801
  var encodeUrl = require_encodeurl();
28919
29802
  var escapeHtml = require_escape_html();
28920
29803
  var http2 = require("http");
28921
- var isAbsolute = require_utils2().isAbsolute;
29804
+ var isAbsolute = require_utils3().isAbsolute;
28922
29805
  var onFinished = require_on_finished();
28923
29806
  var path10 = require("path");
28924
29807
  var statuses = require_statuses();
28925
29808
  var merge2 = require_utils_merge();
28926
29809
  var sign = require_cookie_signature().sign;
28927
- var normalizeType = require_utils2().normalizeType;
28928
- var normalizeTypes = require_utils2().normalizeTypes;
28929
- var setCharset = require_utils2().setCharset;
29810
+ var normalizeType = require_utils3().normalizeType;
29811
+ var normalizeTypes = require_utils3().normalizeTypes;
29812
+ var setCharset = require_utils3().setCharset;
28930
29813
  var cookie = require_cookie();
28931
29814
  var send = require_send();
28932
29815
  var extname = path10.extname;
@@ -33259,7 +34142,7 @@ __export(index_exports, {
33259
34142
  });
33260
34143
  module.exports = __toCommonJS(index_exports);
33261
34144
  var import_node_child_process3 = require("node:child_process");
33262
- var import_node_fs6 = require("node:fs");
34145
+ var import_node_fs7 = require("node:fs");
33263
34146
  var import_node_os4 = __toESM(require("node:os"), 1);
33264
34147
  var import_node_path10 = __toESM(require("node:path"), 1);
33265
34148
  var import_node_module = require("node:module");
@@ -33296,12 +34179,45 @@ function plistPath(home, name) {
33296
34179
  function unitPath(home, name) {
33297
34180
  return (0, import_node_path.join)(home, ".config", "systemd", "user", `${name}.service`);
33298
34181
  }
34182
+ var invalidXmlCharPattern = /[\u0000-\u0008\u000B\u000C\u000E-\u001F]/;
34183
+ var envKeyPattern = /^[A-Za-z_][A-Za-z0-9_]*$/;
34184
+ var safeSystemdEnvValuePattern = /^[A-Za-z0-9_./:@,=+-]*$/;
34185
+ function xmlEscape(s) {
34186
+ return s.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;");
34187
+ }
34188
+ function validateXmlString(s) {
34189
+ if (invalidXmlCharPattern.test(s)) {
34190
+ throw new Error("string contains characters that are not allowed in XML 1.0");
34191
+ }
34192
+ }
34193
+ function validateEnvKey(k) {
34194
+ if (!envKeyPattern.test(k)) {
34195
+ throw new Error(`invalid environment variable key: ${k}`);
34196
+ }
34197
+ }
34198
+ function formatSystemdEnvValue(v) {
34199
+ if (v.includes("\0") || v.includes("\n")) {
34200
+ throw new Error("systemd environment values cannot contain NUL or newline characters");
34201
+ }
34202
+ if (safeSystemdEnvValuePattern.test(v))
34203
+ return v;
34204
+ return `"${v.replaceAll("\\", "\\\\").replaceAll('"', '\\"')}"`;
34205
+ }
33299
34206
  function renderPlist(name, programArgs, env) {
33300
- const entries = programArgs.map((arg) => ` <string>${arg}</string>`).join("\n");
34207
+ validateXmlString(name);
34208
+ const entries = programArgs.map((arg) => {
34209
+ validateXmlString(arg);
34210
+ return ` <string>${xmlEscape(arg)}</string>`;
34211
+ }).join("\n");
33301
34212
  let envBlock = "";
33302
34213
  if (env && Object.keys(env).length > 0) {
33303
- const envEntries = Object.entries(env).map(([k, v]) => ` <key>${k}</key>
33304
- <string>${v}</string>`).join("\n");
34214
+ const envEntries = Object.entries(env).map(([k, v]) => {
34215
+ validateXmlString(k);
34216
+ validateEnvKey(k);
34217
+ validateXmlString(v);
34218
+ return ` <key>${xmlEscape(k)}</key>
34219
+ <string>${xmlEscape(v)}</string>`;
34220
+ }).join("\n");
33305
34221
  envBlock = `
33306
34222
  <key>EnvironmentVariables</key>
33307
34223
  <dict>
@@ -33313,7 +34229,7 @@ ${envEntries}
33313
34229
  <plist version="1.0">
33314
34230
  <dict>
33315
34231
  <key>Label</key>
33316
- <string>${name}</string>
34232
+ <string>${xmlEscape(name)}</string>
33317
34233
  <key>ProgramArguments</key>
33318
34234
  <array>
33319
34235
  ${entries}
@@ -33321,7 +34237,9 @@ ${entries}
33321
34237
  <key>RunAtLoad</key>
33322
34238
  <true/>
33323
34239
  <key>KeepAlive</key>
33324
- <true/>${envBlock}
34240
+ <true/>
34241
+ <key>ProcessType</key>
34242
+ <string>Background</string>${envBlock}
33325
34243
  </dict>
33326
34244
  </plist>
33327
34245
  `;
@@ -33333,7 +34251,10 @@ function quoteSystemdArg(arg) {
33333
34251
  }
33334
34252
  function renderUnit(description, programArgs, env) {
33335
34253
  const execStart = programArgs.map(quoteSystemdArg).join(" ");
33336
- const envLines = env ? Object.entries(env).map(([k, v]) => `Environment=${k}=${v}`).join("\n") : "";
34254
+ const envLines = env ? Object.entries(env).map(([k, v]) => {
34255
+ validateEnvKey(k);
34256
+ return `Environment=${k}=${formatSystemdEnvValue(v)}`;
34257
+ }).join("\n") : "";
33337
34258
  return `[Unit]
33338
34259
  Description=${description}
33339
34260
 
@@ -34130,6 +35051,7 @@ var import_express2 = __toESM(require_express2(), 1);
34130
35051
  var import_node_http = __toESM(require("node:http"), 1);
34131
35052
 
34132
35053
  // ../server/src/config.ts
35054
+ var import_node_fs2 = require("node:fs");
34133
35055
  var import_node_os2 = __toESM(require("node:os"), 1);
34134
35056
  var import_node_path2 = __toESM(require("node:path"), 1);
34135
35057
  var TRUE_ENV_VALUE = "true";
@@ -34141,12 +35063,14 @@ var ACP_AGENT_PROFILES = {
34141
35063
  agent: "openclaw",
34142
35064
  command: "openclaw",
34143
35065
  args: ["acp"],
35066
+ envPrefix: "OPENCLAW_",
34144
35067
  sessionIdStrategy: "deterministic"
34145
35068
  },
34146
35069
  hermes: {
34147
35070
  agent: "hermes",
34148
35071
  command: "hermes",
34149
35072
  args: ["acp"],
35073
+ envPrefix: "HERMES_",
34150
35074
  sessionIdStrategy: "mapped"
34151
35075
  }
34152
35076
  };
@@ -34174,13 +35098,47 @@ function resolveACPAgentProfile(env = process.env) {
34174
35098
  `Unsupported TELEVISION_ACP_AGENT "${rawAgent}". Supported values: openclaw, hermes.`
34175
35099
  );
34176
35100
  }
35101
+ function buildPersistedACPEnvironment(env) {
35102
+ const profile = resolveACPAgentProfile(env);
35103
+ const pathValue = env.PATH;
35104
+ if (pathValue === void 0) {
35105
+ throw new Error("PATH is required to build the persisted ACP environment.");
35106
+ }
35107
+ const snapshot = {
35108
+ PATH: pathValue,
35109
+ [TELEVISION_ACP_AGENT_ENV]: profile.agent
35110
+ };
35111
+ for (const [key, value] of Object.entries(env)) {
35112
+ if (key.startsWith(profile.envPrefix) && value !== void 0) {
35113
+ snapshot[key] = value;
35114
+ }
35115
+ }
35116
+ return snapshot;
35117
+ }
35118
+ function canExecuteFile(filePath) {
35119
+ try {
35120
+ return (0, import_node_fs2.statSync)(filePath).isFile() && (0, import_node_fs2.accessSync)(filePath, import_node_fs2.constants.X_OK) === void 0;
35121
+ } catch {
35122
+ return false;
35123
+ }
35124
+ }
35125
+ function isACPCommandResolvable(command, envSnapshot) {
35126
+ if (command.includes(import_node_path2.default.sep)) {
35127
+ return canExecuteFile(command);
35128
+ }
35129
+ const pathValue = envSnapshot.PATH;
35130
+ if (!pathValue) {
35131
+ return false;
35132
+ }
35133
+ return pathValue.split(import_node_path2.default.delimiter).filter((entry) => entry.length > 0).some((entry) => canExecuteFile(import_node_path2.default.join(entry, command)));
35134
+ }
34177
35135
  function isVitestRuntime() {
34178
35136
  return process.env.VITEST === TRUE_ENV_VALUE;
34179
35137
  }
34180
35138
 
34181
35139
  // ../server/src/routes.ts
34182
35140
  var import_express = __toESM(require_express2(), 1);
34183
- var import_node_fs3 = require("node:fs");
35141
+ var import_node_fs4 = require("node:fs");
34184
35142
  var import_node_path5 = __toESM(require("node:path"), 1);
34185
35143
 
34186
35144
  // ../../node_modules/zod/v4/classic/external.js
@@ -48109,7 +49067,7 @@ function getArtifactEntryFilePath(storagePath, artifactID, kind, state) {
48109
49067
  }
48110
49068
 
48111
49069
  // ../server/src/themes.ts
48112
- var import_node_fs2 = require("node:fs");
49070
+ var import_node_fs3 = require("node:fs");
48113
49071
  var import_node_path4 = __toESM(require("node:path"), 1);
48114
49072
  var HTTP_NOT_FOUND_STATUS = 404;
48115
49073
  var THEME_NAME_PATTERN = /^[a-z0-9][a-z0-9-]*$/;
@@ -48138,7 +49096,7 @@ function themeExists(storagePath, name) {
48138
49096
  return false;
48139
49097
  }
48140
49098
  try {
48141
- return (0, import_node_fs2.statSync)(getThemeEntryPath(storagePath, name)).isFile();
49099
+ return (0, import_node_fs3.statSync)(getThemeEntryPath(storagePath, name)).isFile();
48142
49100
  } catch {
48143
49101
  return false;
48144
49102
  }
@@ -48160,7 +49118,7 @@ function serveThemeCSS(storagePath) {
48160
49118
  return;
48161
49119
  }
48162
49120
  try {
48163
- const css = (0, import_node_fs2.readFileSync)(getThemeEntryPath(storagePath, name), "utf8");
49121
+ const css = (0, import_node_fs3.readFileSync)(getThemeEntryPath(storagePath, name), "utf8");
48164
49122
  res.type("text/css").setHeader("Cache-Control", "no-cache").send(rewriteThemeURLs(css, name));
48165
49123
  } catch (error48) {
48166
49124
  if (error48.code === "ENOENT") {
@@ -48562,8 +49520,8 @@ function registerRoutes(app, store, options) {
48562
49520
  let realPublicDir;
48563
49521
  let realRequestedPath;
48564
49522
  try {
48565
- realPublicDir = (0, import_node_fs3.realpathSync)(publicDir);
48566
- realRequestedPath = (0, import_node_fs3.realpathSync)(requestedPath);
49523
+ realPublicDir = (0, import_node_fs4.realpathSync)(publicDir);
49524
+ realRequestedPath = (0, import_node_fs4.realpathSync)(requestedPath);
48567
49525
  } catch {
48568
49526
  sendError(res, HTTP_NOT_FOUND, "Not found");
48569
49527
  return;
@@ -49041,7 +49999,7 @@ var ACPServer = class extends withDisposable(class {
49041
49999
  super();
49042
50000
  this.authToken = options.authToken;
49043
50001
  this.publicServer = options.publicServer;
49044
- this.profile = options.profile ?? resolveACPAgentProfile();
50002
+ this.profile = options.profile;
49045
50003
  this.wsServer = new import_websocket_server.default({ noServer: true });
49046
50004
  this.wsServer.on("connection", (socket, request) => {
49047
50005
  if (!this.publicServer && !isAuthorizedQueryToken(request.url, this.authToken)) {
@@ -49100,7 +50058,7 @@ var ACPServer = class extends withDisposable(class {
49100
50058
 
49101
50059
  // ../server/src/canonical.ts
49102
50060
  var import_node_crypto3 = require("node:crypto");
49103
- var import_node_fs4 = require("node:fs");
50061
+ var import_node_fs5 = require("node:fs");
49104
50062
  var import_node_path7 = __toESM(require("node:path"), 1);
49105
50063
  var CACHE_CONTROL_NO_CACHE = "no-cache";
49106
50064
  var HTTP_NOT_MODIFIED_STATUS = 304;
@@ -49126,7 +50084,7 @@ function serveCanonicalStyles(options) {
49126
50084
  };
49127
50085
  }
49128
50086
  function loadCanonicalBundle(canonicalDir) {
49129
- const css = (0, import_node_fs4.readFileSync)(import_node_path7.default.join(canonicalDir, CANONICAL_STYLESHEET), "utf8");
50087
+ const css = (0, import_node_fs5.readFileSync)(import_node_path7.default.join(canonicalDir, CANONICAL_STYLESHEET), "utf8");
49130
50088
  return { css, hash: hashContent(css) };
49131
50089
  }
49132
50090
  function buildCanonicalResponse(bundle, store) {
@@ -49139,7 +50097,7 @@ function buildCanonicalResponse(bundle, store) {
49139
50097
  return { body: bundle.css, etag: buildETag(bundle.hash, NO_THEME_HASH) };
49140
50098
  }
49141
50099
  try {
49142
- const themeCSS = (0, import_node_fs4.readFileSync)(getThemeEntryPath(store.storagePath, activeThemeName), "utf8");
50100
+ const themeCSS = (0, import_node_fs5.readFileSync)(getThemeEntryPath(store.storagePath, activeThemeName), "utf8");
49143
50101
  return {
49144
50102
  body: `${bundle.css}
49145
50103
 
@@ -49291,7 +50249,7 @@ var Server = class {
49291
50249
  };
49292
50250
 
49293
50251
  // ../server/src/server-store.ts
49294
- var import_node_fs5 = require("node:fs");
50252
+ var import_node_fs6 = require("node:fs");
49295
50253
  var import_node_path9 = __toESM(require("node:path"), 1);
49296
50254
 
49297
50255
  // ../server/src/file-watcher.ts
@@ -49331,7 +50289,7 @@ var ServerStore = class extends EventTarget {
49331
50289
  super();
49332
50290
  this.storagePath = options.storagePath;
49333
50291
  this.watchContentFile = options.watchContentFile ?? defaultWatchContentFile;
49334
- this.bundledViewsPath = options.bundledViewsPath && (0, import_node_fs5.existsSync)(options.bundledViewsPath) ? options.bundledViewsPath : null;
50292
+ this.bundledViewsPath = options.bundledViewsPath && (0, import_node_fs6.existsSync)(options.bundledViewsPath) ? options.bundledViewsPath : null;
49335
50293
  this.ensureDirectories();
49336
50294
  this.views = this.scanViewRegistry();
49337
50295
  this.authToken = this.loadOrCreateAuthToken();
@@ -49386,7 +50344,7 @@ var ServerStore = class extends EventTarget {
49386
50344
  return this._artifacts.get(id);
49387
50345
  }
49388
50346
  hasTrashedArtifact(id) {
49389
- return (0, import_node_fs5.existsSync)(getArtifactTrashMetadataPath(this.storagePath, id));
50347
+ return (0, import_node_fs6.existsSync)(getArtifactTrashMetadataPath(this.storagePath, id));
49390
50348
  }
49391
50349
  /**
49392
50350
  * Resolve the absolute filesystem path where an artifact's primary content
@@ -49425,11 +50383,11 @@ var ServerStore = class extends EventTarget {
49425
50383
  throw new NotFoundError(`Artifact not found: ${id}`, { entityType: "artifact", entityID: id });
49426
50384
  }
49427
50385
  try {
49428
- (0, import_node_fs5.accessSync)(contentPath, import_node_fs5.constants.R_OK);
50386
+ (0, import_node_fs6.accessSync)(contentPath, import_node_fs6.constants.R_OK);
49429
50387
  } catch {
49430
50388
  throw new NotFoundError(`Artifact content not readable: ${id}`, { entityType: "artifact content", entityID: id });
49431
50389
  }
49432
- return (0, import_node_fs5.readFileSync)(contentPath);
50390
+ return (0, import_node_fs6.readFileSync)(contentPath);
49433
50391
  }
49434
50392
  /**
49435
50393
  * Replace an artifact's content at the resolved content path.
@@ -49455,10 +50413,10 @@ var ServerStore = class extends EventTarget {
49455
50413
  `Artifact ${id} has no committed content yet. Use commit or abandon after writing the pending bundle`
49456
50414
  );
49457
50415
  }
49458
- if (!(0, import_node_fs5.existsSync)(import_node_path9.default.dirname(contentPath))) {
50416
+ if (!(0, import_node_fs6.existsSync)(import_node_path9.default.dirname(contentPath))) {
49459
50417
  throw new NotFoundError(`Artifact content not readable: ${id}`, { entityType: "artifact content", entityID: id });
49460
50418
  }
49461
- (0, import_node_fs5.writeFileSync)(contentPath, content);
50419
+ (0, import_node_fs6.writeFileSync)(contentPath, content);
49462
50420
  }
49463
50421
  listScreens() {
49464
50422
  return [...this.screens.values()];
@@ -49525,8 +50483,8 @@ var ServerStore = class extends EventTarget {
49525
50483
  throw new InvalidRequestError(`Artifact ${artifactID} already has pending work. Use commit or abandon before editing again`);
49526
50484
  }
49527
50485
  const pendingPath = getArtifactPendingBundlePath(this.storagePath, artifactID);
49528
- (0, import_node_fs5.rmSync)(pendingPath, { recursive: true, force: true });
49529
- (0, import_node_fs5.cpSync)(
50486
+ (0, import_node_fs6.rmSync)(pendingPath, { recursive: true, force: true });
50487
+ (0, import_node_fs6.cpSync)(
49530
50488
  getArtifactCommittedBundlePath(this.storagePath, artifactID),
49531
50489
  pendingPath,
49532
50490
  { recursive: true }
@@ -49550,8 +50508,8 @@ var ServerStore = class extends EventTarget {
49550
50508
  const pendingPath = getArtifactPendingBundlePath(this.storagePath, artifactID);
49551
50509
  const committedPath = getArtifactCommittedBundlePath(this.storagePath, artifactID);
49552
50510
  this.stopWatchingArtifactContent(artifactID);
49553
- (0, import_node_fs5.rmSync)(committedPath, { recursive: true, force: true });
49554
- (0, import_node_fs5.renameSync)(pendingPath, committedPath);
50511
+ (0, import_node_fs6.rmSync)(committedPath, { recursive: true, force: true });
50512
+ (0, import_node_fs6.renameSync)(pendingPath, committedPath);
49555
50513
  artifact.status = "committed";
49556
50514
  this.writeArtifact(artifact);
49557
50515
  this._artifacts.set(artifactID, artifact);
@@ -49571,7 +50529,7 @@ var ServerStore = class extends EventTarget {
49571
50529
  if (artifact.status !== "pending") {
49572
50530
  throw new InvalidRequestError(`Artifact ${artifactID} has no pending work to abandon`);
49573
50531
  }
49574
- (0, import_node_fs5.rmSync)(getArtifactPendingBundlePath(this.storagePath, artifactID), { recursive: true, force: true });
50532
+ (0, import_node_fs6.rmSync)(getArtifactPendingBundlePath(this.storagePath, artifactID), { recursive: true, force: true });
49575
50533
  if (!this.hasCommittedBundle(artifactID)) {
49576
50534
  this.cascadeArtifactRemoval(artifactID);
49577
50535
  return;
@@ -49847,13 +50805,13 @@ var ServerStore = class extends EventTarget {
49847
50805
  this.dispose();
49848
50806
  }
49849
50807
  load() {
49850
- if ((0, import_node_fs5.existsSync)(this.screensDir)) {
49851
- for (const file2 of (0, import_node_fs5.readdirSync)(this.screensDir)) {
50808
+ if ((0, import_node_fs6.existsSync)(this.screensDir)) {
50809
+ for (const file2 of (0, import_node_fs6.readdirSync)(this.screensDir)) {
49852
50810
  if (!file2.endsWith(JSON_FILE_SUFFIX)) continue;
49853
50811
  const filePath = import_node_path9.default.join(this.screensDir, file2);
49854
50812
  let raw;
49855
50813
  try {
49856
- raw = JSON.parse((0, import_node_fs5.readFileSync)(filePath, "utf8"));
50814
+ raw = JSON.parse((0, import_node_fs6.readFileSync)(filePath, "utf8"));
49857
50815
  } catch (error48) {
49858
50816
  console.warn(`Skipping malformed JSON file: ${filePath}`, error48);
49859
50817
  continue;
@@ -49869,10 +50827,10 @@ var ServerStore = class extends EventTarget {
49869
50827
  });
49870
50828
  }
49871
50829
  }
49872
- if (!(0, import_node_fs5.existsSync)(this.artifactsDir)) {
50830
+ if (!(0, import_node_fs6.existsSync)(this.artifactsDir)) {
49873
50831
  return;
49874
50832
  }
49875
- for (const file2 of (0, import_node_fs5.readdirSync)(this.artifactsDir)) {
50833
+ for (const file2 of (0, import_node_fs6.readdirSync)(this.artifactsDir)) {
49876
50834
  if (!file2.endsWith(JSON_FILE_SUFFIX)) {
49877
50835
  continue;
49878
50836
  }
@@ -49905,7 +50863,7 @@ var ServerStore = class extends EventTarget {
49905
50863
  return;
49906
50864
  }
49907
50865
  try {
49908
- (0, import_node_fs5.accessSync)(contentPath, import_node_fs5.constants.R_OK);
50866
+ (0, import_node_fs6.accessSync)(contentPath, import_node_fs6.constants.R_OK);
49909
50867
  const watcher = this.watchContentFile(contentPath, () => {
49910
50868
  this.scheduleArtifactContentChangedEvent(artifactID);
49911
50869
  });
@@ -50024,7 +50982,7 @@ var ServerStore = class extends EventTarget {
50024
50982
  * metadata field.
50025
50983
  */
50026
50984
  hasCommittedBundle(artifactID) {
50027
- return (0, import_node_fs5.existsSync)(getArtifactCommittedBundlePath(this.storagePath, artifactID));
50985
+ return (0, import_node_fs6.existsSync)(getArtifactCommittedBundlePath(this.storagePath, artifactID));
50028
50986
  }
50029
50987
  createKindArtifact(input) {
50030
50988
  const kind = input.kind;
@@ -50094,9 +51052,9 @@ var ServerStore = class extends EventTarget {
50094
51052
  this.persistDisplayState();
50095
51053
  }
50096
51054
  ensureDirectories() {
50097
- (0, import_node_fs5.mkdirSync)(this.screensDir, { recursive: true });
50098
- (0, import_node_fs5.mkdirSync)(this.artifactsDir, { recursive: true });
50099
- (0, import_node_fs5.mkdirSync)(getThemesDir(this.storagePath), { recursive: true });
51055
+ (0, import_node_fs6.mkdirSync)(this.screensDir, { recursive: true });
51056
+ (0, import_node_fs6.mkdirSync)(this.artifactsDir, { recursive: true });
51057
+ (0, import_node_fs6.mkdirSync)(getThemesDir(this.storagePath), { recursive: true });
50100
51058
  }
50101
51059
  /**
50102
51060
  * Cascade the last-reference removal of `artifactID`: move the bundle to
@@ -50113,12 +51071,12 @@ var ServerStore = class extends EventTarget {
50113
51071
  }
50114
51072
  const affectedScreenIDs = this.collectReferencingScreenIDs(artifactID);
50115
51073
  if (artifact.kind === "web-bundle") {
50116
- (0, import_node_fs5.rmSync)(getArtifactPendingBundlePath(this.storagePath, artifactID), { recursive: true, force: true });
51074
+ (0, import_node_fs6.rmSync)(getArtifactPendingBundlePath(this.storagePath, artifactID), { recursive: true, force: true });
50117
51075
  }
50118
51076
  this.stopWatchingArtifactContent(artifactID);
50119
51077
  if (artifact.kind === "web-bundle" && artifact.status === "pending" && !this.hasCommittedBundle(artifactID)) {
50120
51078
  this._artifacts.delete(artifactID);
50121
- (0, import_node_fs5.rmSync)(getArtifactLiveMetadataPath(this.storagePath, artifactID), { force: true });
51079
+ (0, import_node_fs6.rmSync)(getArtifactLiveMetadataPath(this.storagePath, artifactID), { force: true });
50122
51080
  this.stripArtifactFromScreens(artifactID, affectedScreenIDs);
50123
51081
  this.emitArtifactRemovedEvents(artifactID, affectedScreenIDs);
50124
51082
  return {
@@ -50132,7 +51090,7 @@ var ServerStore = class extends EventTarget {
50132
51090
  status: "committed"
50133
51091
  });
50134
51092
  this._artifacts.delete(artifactID);
50135
- (0, import_node_fs5.rmSync)(getArtifactLiveMetadataPath(this.storagePath, artifactID), { force: true });
51093
+ (0, import_node_fs6.rmSync)(getArtifactLiveMetadataPath(this.storagePath, artifactID), { force: true });
50136
51094
  this.stripArtifactFromScreens(artifactID, affectedScreenIDs);
50137
51095
  this.emitArtifactRemovedEvents(artifactID, affectedScreenIDs);
50138
51096
  return result;
@@ -50157,8 +51115,8 @@ var ServerStore = class extends EventTarget {
50157
51115
  }
50158
51116
  trashArtifact(artifact) {
50159
51117
  const metadataPath = getArtifactTrashMetadataPath(this.storagePath, artifact.id);
50160
- (0, import_node_fs5.mkdirSync)(import_node_path9.default.dirname(metadataPath), { recursive: true });
50161
- (0, import_node_fs5.writeFileSync)(metadataPath, JSON.stringify(artifact, null, JSON_INDENT_SPACES));
51118
+ (0, import_node_fs6.mkdirSync)(import_node_path9.default.dirname(metadataPath), { recursive: true });
51119
+ (0, import_node_fs6.writeFileSync)(metadataPath, JSON.stringify(artifact, null, JSON_INDENT_SPACES));
50162
51120
  switch (artifact.kind) {
50163
51121
  case "url": {
50164
51122
  const externalURL = artifact.externalURL;
@@ -50189,9 +51147,9 @@ var ServerStore = class extends EventTarget {
50189
51147
  case "web-bundle": {
50190
51148
  const committedBundlePath = getArtifactCommittedBundlePath(this.storagePath, artifact.id);
50191
51149
  const bundlePath = getArtifactTrashBundlePath(this.storagePath, artifact.id);
50192
- (0, import_node_fs5.rmSync)(bundlePath, { recursive: true, force: true });
50193
- if ((0, import_node_fs5.existsSync)(committedBundlePath)) {
50194
- (0, import_node_fs5.renameSync)(committedBundlePath, bundlePath);
51150
+ (0, import_node_fs6.rmSync)(bundlePath, { recursive: true, force: true });
51151
+ if ((0, import_node_fs6.existsSync)(committedBundlePath)) {
51152
+ (0, import_node_fs6.renameSync)(committedBundlePath, bundlePath);
50195
51153
  }
50196
51154
  return {
50197
51155
  outcome: "trashed",
@@ -50205,9 +51163,9 @@ var ServerStore = class extends EventTarget {
50205
51163
  }
50206
51164
  trashScreen(screen) {
50207
51165
  const metadataPath = getTrashedScreenMetadataPath(this.storagePath, screen.id);
50208
- (0, import_node_fs5.mkdirSync)(import_node_path9.default.dirname(metadataPath), { recursive: true });
50209
- (0, import_node_fs5.writeFileSync)(metadataPath, JSON.stringify(screen, null, JSON_INDENT_SPACES));
50210
- (0, import_node_fs5.rmSync)(import_node_path9.default.join(this.screensDir, `${screen.id}.json`), { force: true });
51166
+ (0, import_node_fs6.mkdirSync)(import_node_path9.default.dirname(metadataPath), { recursive: true });
51167
+ (0, import_node_fs6.writeFileSync)(metadataPath, JSON.stringify(screen, null, JSON_INDENT_SPACES));
51168
+ (0, import_node_fs6.rmSync)(import_node_path9.default.join(this.screensDir, `${screen.id}.json`), { force: true });
50211
51169
  this.screens.delete(screen.id);
50212
51170
  return metadataPath;
50213
51171
  }
@@ -50225,7 +51183,7 @@ var ServerStore = class extends EventTarget {
50225
51183
  }
50226
51184
  let entries;
50227
51185
  try {
50228
- entries = (0, import_node_fs5.readdirSync)(this.bundledViewsPath);
51186
+ entries = (0, import_node_fs6.readdirSync)(this.bundledViewsPath);
50229
51187
  } catch (error48) {
50230
51188
  console.warn(`Failed to read bundled views directory: ${this.bundledViewsPath}`, error48);
50231
51189
  return [];
@@ -50234,7 +51192,7 @@ var ServerStore = class extends EventTarget {
50234
51192
  for (const id of entries) {
50235
51193
  const viewDir = import_node_path9.default.join(this.bundledViewsPath, id);
50236
51194
  try {
50237
- if (!(0, import_node_fs5.statSync)(viewDir).isDirectory()) {
51195
+ if (!(0, import_node_fs6.statSync)(viewDir).isDirectory()) {
50238
51196
  continue;
50239
51197
  }
50240
51198
  } catch {
@@ -50243,7 +51201,7 @@ var ServerStore = class extends EventTarget {
50243
51201
  const manifestPath = import_node_path9.default.join(viewDir, "manifest.json");
50244
51202
  let raw;
50245
51203
  try {
50246
- raw = (0, import_node_fs5.readFileSync)(manifestPath, "utf8");
51204
+ raw = (0, import_node_fs6.readFileSync)(manifestPath, "utf8");
50247
51205
  } catch {
50248
51206
  console.warn(`Skipping view "${id}": cannot read manifest at ${manifestPath}`);
50249
51207
  continue;
@@ -50266,12 +51224,12 @@ var ServerStore = class extends EventTarget {
50266
51224
  return registry2;
50267
51225
  }
50268
51226
  loadDisplayState() {
50269
- if (!(0, import_node_fs5.existsSync)(this.displayStatePath)) {
51227
+ if (!(0, import_node_fs6.existsSync)(this.displayStatePath)) {
50270
51228
  return false;
50271
51229
  }
50272
51230
  let raw;
50273
51231
  try {
50274
- raw = (0, import_node_fs5.readFileSync)(this.displayStatePath, "utf8");
51232
+ raw = (0, import_node_fs6.readFileSync)(this.displayStatePath, "utf8");
50275
51233
  } catch {
50276
51234
  return false;
50277
51235
  }
@@ -50289,7 +51247,7 @@ var ServerStore = class extends EventTarget {
50289
51247
  return false;
50290
51248
  }
50291
51249
  persistDisplayState() {
50292
- (0, import_node_fs5.writeFileSync)(
51250
+ (0, import_node_fs6.writeFileSync)(
50293
51251
  this.displayStatePath,
50294
51252
  JSON.stringify(this.getDisplayState(), null, JSON_INDENT_SPACES)
50295
51253
  );
@@ -50311,11 +51269,11 @@ var ServerStore = class extends EventTarget {
50311
51269
  return firstScreen.id;
50312
51270
  }
50313
51271
  loadOrCreateAuthToken() {
50314
- if ((0, import_node_fs5.existsSync)(this.tokenPath)) {
50315
- return (0, import_node_fs5.readFileSync)(this.tokenPath, "utf8").trim();
51272
+ if ((0, import_node_fs6.existsSync)(this.tokenPath)) {
51273
+ return (0, import_node_fs6.readFileSync)(this.tokenPath, "utf8").trim();
50316
51274
  }
50317
51275
  const token = createToken();
50318
- (0, import_node_fs5.writeFileSync)(this.tokenPath, `${token}
51276
+ (0, import_node_fs6.writeFileSync)(this.tokenPath, `${token}
50319
51277
  `);
50320
51278
  return token;
50321
51279
  }
@@ -50323,12 +51281,12 @@ var ServerStore = class extends EventTarget {
50323
51281
  if (!this.screens.has(screen.id)) {
50324
51282
  throw new Error(`Cannot persist screen ${screen.id}: not in live map`);
50325
51283
  }
50326
- (0, import_node_fs5.writeFileSync)(import_node_path9.default.join(this.screensDir, `${screen.id}.json`), JSON.stringify(screen, null, JSON_INDENT_SPACES));
51284
+ (0, import_node_fs6.writeFileSync)(import_node_path9.default.join(this.screensDir, `${screen.id}.json`), JSON.stringify(screen, null, JSON_INDENT_SPACES));
50327
51285
  }
50328
51286
  readArtifactFile(filePath, expectedID) {
50329
51287
  let raw;
50330
51288
  try {
50331
- raw = (0, import_node_fs5.readFileSync)(filePath, "utf8");
51289
+ raw = (0, import_node_fs6.readFileSync)(filePath, "utf8");
50332
51290
  } catch (error48) {
50333
51291
  throw this.invalidMetadataFile(filePath, "unreadable", error48);
50334
51292
  }
@@ -50367,16 +51325,16 @@ Review docs/storage.md for the current schema, and either update the file to mat
50367
51325
  return cause !== void 0 ? new Error(message, { cause }) : new Error(message);
50368
51326
  }
50369
51327
  writeArtifact(artifact) {
50370
- (0, import_node_fs5.writeFileSync)(getArtifactLiveMetadataPath(this.storagePath, artifact.id), JSON.stringify(artifact, null, JSON_INDENT_SPACES));
51328
+ (0, import_node_fs6.writeFileSync)(getArtifactLiveMetadataPath(this.storagePath, artifact.id), JSON.stringify(artifact, null, JSON_INDENT_SPACES));
50371
51329
  }
50372
51330
  scaffoldPendingBundle(artifactID) {
50373
51331
  const publicDir = getArtifactPublicDirPath(this.storagePath, artifactID, "pending");
50374
- (0, import_node_fs5.mkdirSync)(publicDir, { recursive: true });
51332
+ (0, import_node_fs6.mkdirSync)(publicDir, { recursive: true });
50375
51333
  }
50376
51334
  scaffoldCommittedBundle(artifactID) {
50377
51335
  const publicDir = getArtifactPublicDirPath(this.storagePath, artifactID, "committed");
50378
- (0, import_node_fs5.mkdirSync)(publicDir, { recursive: true });
50379
- (0, import_node_fs5.writeFileSync)(getArtifactEntryFilePath(this.storagePath, artifactID, "web-bundle", "committed"), "");
51336
+ (0, import_node_fs6.mkdirSync)(publicDir, { recursive: true });
51337
+ (0, import_node_fs6.writeFileSync)(getArtifactEntryFilePath(this.storagePath, artifactID, "web-bundle", "committed"), "");
50380
51338
  }
50381
51339
  get screensDir() {
50382
51340
  return import_node_path9.default.join(this.storagePath, "screens");
@@ -50397,7 +51355,7 @@ Review docs/storage.md for the current schema, and either update the file to mat
50397
51355
  throw new InvalidRequestError("externalFilePath must be normalized and must not contain traversal segments");
50398
51356
  }
50399
51357
  try {
50400
- (0, import_node_fs5.accessSync)(sourcePath, import_node_fs5.constants.R_OK);
51358
+ (0, import_node_fs6.accessSync)(sourcePath, import_node_fs6.constants.R_OK);
50401
51359
  } catch {
50402
51360
  throw new InvalidRequestError(`externalFilePath does not exist or is not readable: ${sourcePath}`);
50403
51361
  }
@@ -50476,14 +51434,14 @@ function resolveVercelSkillsInstallerBin() {
50476
51434
  return localRequire.resolve("skills/bin/cli.mjs");
50477
51435
  }
50478
51436
  function readCLIVersion() {
50479
- if ("0.1.103".length > 0) {
50480
- return "0.1.103";
51437
+ if ("0.1.105".length > 0) {
51438
+ return "0.1.105";
50481
51439
  }
50482
51440
  const devPackageJsonPath = import_node_path10.default.join(getDevPackageDir(), "package.json");
50483
- if (!(0, import_node_fs6.existsSync)(devPackageJsonPath)) {
51441
+ if (!(0, import_node_fs7.existsSync)(devPackageJsonPath)) {
50484
51442
  throw new Error("Could not resolve package.json for repo-local CLI version.");
50485
51443
  }
50486
- return JSON.parse((0, import_node_fs6.readFileSync)(devPackageJsonPath, "utf8")).version;
51444
+ return JSON.parse((0, import_node_fs7.readFileSync)(devPackageJsonPath, "utf8")).version;
50487
51445
  }
50488
51446
  var FRONTMATTER_DELIMITER = "---\n";
50489
51447
  var FRONTMATTER_DELIMITER_LENGTH = FRONTMATTER_DELIMITER.length;
@@ -50540,59 +51498,59 @@ function resolveStaticDir() {
50540
51498
  if (!process.argv[1]) {
50541
51499
  return void 0;
50542
51500
  }
50543
- const entryDir = import_node_path10.default.dirname((0, import_node_fs6.realpathSync)(process.argv[1]));
51501
+ const entryDir = import_node_path10.default.dirname((0, import_node_fs7.realpathSync)(process.argv[1]));
50544
51502
  const resolved = import_node_path10.default.resolve(entryDir, "./web");
50545
- return (0, import_node_fs6.existsSync)(import_node_path10.default.join(resolved, "index.html")) ? resolved : void 0;
51503
+ return (0, import_node_fs7.existsSync)(import_node_path10.default.join(resolved, "index.html")) ? resolved : void 0;
50546
51504
  }
50547
51505
  function resolveBundledViewsPath() {
50548
51506
  if (process.argv[1]) {
50549
- const entryDir = import_node_path10.default.dirname((0, import_node_fs6.realpathSync)(process.argv[1]));
51507
+ const entryDir = import_node_path10.default.dirname((0, import_node_fs7.realpathSync)(process.argv[1]));
50550
51508
  const resolved = import_node_path10.default.resolve(entryDir, "./views");
50551
- return (0, import_node_fs6.existsSync)(resolved) ? resolved : void 0;
51509
+ return (0, import_node_fs7.existsSync)(resolved) ? resolved : void 0;
50552
51510
  }
50553
51511
  const devViewsPath = import_node_path10.default.join(getDevPackageDir(), "dist/views");
50554
- return (0, import_node_fs6.existsSync)(devViewsPath) ? devViewsPath : void 0;
51512
+ return (0, import_node_fs7.existsSync)(devViewsPath) ? devViewsPath : void 0;
50555
51513
  }
50556
51514
  function resolveCanonicalDir() {
50557
51515
  if (process.argv[1]) {
50558
- const entryDir = import_node_path10.default.dirname((0, import_node_fs6.realpathSync)(process.argv[1]));
51516
+ const entryDir = import_node_path10.default.dirname((0, import_node_fs7.realpathSync)(process.argv[1]));
50559
51517
  const resolved = import_node_path10.default.resolve(entryDir, "./canonical/v1");
50560
- return (0, import_node_fs6.existsSync)(resolved) ? resolved : void 0;
51518
+ return (0, import_node_fs7.existsSync)(resolved) ? resolved : void 0;
50561
51519
  }
50562
51520
  const devCanonicalPath = import_node_path10.default.resolve(
50563
51521
  getDevPackageDir(),
50564
51522
  "../server/dist/canonical/v1"
50565
51523
  );
50566
- return (0, import_node_fs6.existsSync)(devCanonicalPath) ? devCanonicalPath : void 0;
51524
+ return (0, import_node_fs7.existsSync)(devCanonicalPath) ? devCanonicalPath : void 0;
50567
51525
  }
50568
51526
  function resolveBundledSkillsRoot() {
50569
- const builtPath = typeof process.argv[1] === "string" ? import_node_path10.default.resolve(import_node_path10.default.dirname((0, import_node_fs6.realpathSync)(process.argv[1])), "./skills") : void 0;
50570
- if (builtPath && (0, import_node_fs6.existsSync)(builtPath)) {
51527
+ const builtPath = typeof process.argv[1] === "string" ? import_node_path10.default.resolve(import_node_path10.default.dirname((0, import_node_fs7.realpathSync)(process.argv[1])), "./skills") : void 0;
51528
+ if (builtPath && (0, import_node_fs7.existsSync)(builtPath)) {
50571
51529
  return builtPath;
50572
51530
  }
50573
51531
  const devPath = import_node_path10.default.resolve(getDevPackageDir(), "../skills/dist");
50574
- return (0, import_node_fs6.existsSync)(devPath) ? devPath : void 0;
51532
+ return (0, import_node_fs7.existsSync)(devPath) ? devPath : void 0;
50575
51533
  }
50576
51534
  function copyBundledSkillsToDestination(bundledSkillsRoot, destinationRoot) {
50577
- if ((0, import_node_fs6.existsSync)(destinationRoot) && !(0, import_node_fs6.statSync)(destinationRoot).isDirectory()) {
51535
+ if ((0, import_node_fs7.existsSync)(destinationRoot) && !(0, import_node_fs7.statSync)(destinationRoot).isDirectory()) {
50578
51536
  throw new Error(`Skills destination is not a directory: ${destinationRoot}`);
50579
51537
  }
50580
- (0, import_node_fs6.mkdirSync)(destinationRoot, { recursive: true });
51538
+ (0, import_node_fs7.mkdirSync)(destinationRoot, { recursive: true });
50581
51539
  const copied = [];
50582
- const entries = (0, import_node_fs6.readdirSync)(bundledSkillsRoot, { withFileTypes: true }).filter((entry) => entry.isDirectory()).sort((a, b) => a.name.localeCompare(b.name));
51540
+ const entries = (0, import_node_fs7.readdirSync)(bundledSkillsRoot, { withFileTypes: true }).filter((entry) => entry.isDirectory()).sort((a, b) => a.name.localeCompare(b.name));
50583
51541
  for (const entry of entries) {
50584
51542
  const sourcePath = import_node_path10.default.join(bundledSkillsRoot, entry.name);
50585
51543
  const destinationPath = import_node_path10.default.join(destinationRoot, entry.name);
50586
- (0, import_node_fs6.rmSync)(destinationPath, { recursive: true, force: true });
50587
- (0, import_node_fs6.cpSync)(sourcePath, destinationPath, { recursive: true });
51544
+ (0, import_node_fs7.rmSync)(destinationPath, { recursive: true, force: true });
51545
+ (0, import_node_fs7.cpSync)(sourcePath, destinationPath, { recursive: true });
50588
51546
  copied.push({ name: entry.name, sourcePath, destinationPath });
50589
51547
  }
50590
51548
  return copied;
50591
51549
  }
50592
51550
  function isInTempDirectory(inputPath) {
50593
51551
  try {
50594
- const realTmp = (0, import_node_fs6.realpathSync)(import_node_os4.default.tmpdir());
50595
- const realInput = (0, import_node_fs6.existsSync)(inputPath) ? (0, import_node_fs6.realpathSync)(inputPath) : import_node_path10.default.resolve(inputPath);
51552
+ const realTmp = (0, import_node_fs7.realpathSync)(import_node_os4.default.tmpdir());
51553
+ const realInput = (0, import_node_fs7.existsSync)(inputPath) ? (0, import_node_fs7.realpathSync)(inputPath) : import_node_path10.default.resolve(inputPath);
50596
51554
  const relative = import_node_path10.default.relative(realTmp, realInput);
50597
51555
  return relative !== "" && !relative.startsWith("..") && !import_node_path10.default.isAbsolute(relative);
50598
51556
  } catch {
@@ -50604,7 +51562,7 @@ function validateExternalArtifactPath(commandName, inputPath) {
50604
51562
  throw createDirectiveError(`tv ${commandName} requires --path to be an absolute path.`);
50605
51563
  }
50606
51564
  try {
50607
- (0, import_node_fs6.accessSync)(inputPath, import_node_fs6.constants.R_OK);
51565
+ (0, import_node_fs7.accessSync)(inputPath, import_node_fs7.constants.R_OK);
50608
51566
  } catch {
50609
51567
  throw createDirectiveError(`tv ${commandName} could not read --path ${inputPath}.`);
50610
51568
  }
@@ -50736,10 +51694,10 @@ function formatCommanderError(argv, error48) {
50736
51694
  }
50737
51695
  function readAuthToken(storagePath) {
50738
51696
  const tokenPath = import_node_path10.default.join(storagePath, "token");
50739
- if (!(0, import_node_fs6.existsSync)(tokenPath)) {
51697
+ if (!(0, import_node_fs7.existsSync)(tokenPath)) {
50740
51698
  return void 0;
50741
51699
  }
50742
- const token = (0, import_node_fs6.readFileSync)(tokenPath, "utf8").trim();
51700
+ const token = (0, import_node_fs7.readFileSync)(tokenPath, "utf8").trim();
50743
51701
  return token.length > 0 ? token : void 0;
50744
51702
  }
50745
51703
  function readOrCreateAuthToken(storagePath) {
@@ -50750,7 +51708,7 @@ function createEnvironment(environment) {
50750
51708
  stdout: environment.stdout ?? process.stdout,
50751
51709
  stderr: environment.stderr ?? process.stderr,
50752
51710
  createClient: environment.createClient ?? ((serverURL, token) => new TelevisionClient(serverURL, { token })),
50753
- createServer: environment.createServer ?? ((options = {}) => new Server({
51711
+ createServer: environment.createServer ?? ((options) => new Server({
50754
51712
  store: new ServerStore({
50755
51713
  storagePath: options.storagePath ?? getTelevisionStoragePath(),
50756
51714
  ...options.bundledViewsPath ? { bundledViewsPath: options.bundledViewsPath } : {}
@@ -50760,7 +51718,7 @@ function createEnvironment(environment) {
50760
51718
  staticDir: options.staticDir,
50761
51719
  canonicalDir: options.canonicalDir,
50762
51720
  public: options.public,
50763
- acpProfile: resolveACPAgentProfile(process.env)
51721
+ acpProfile: options.acpProfile
50764
51722
  })),
50765
51723
  createDaemon: environment.createDaemon ?? ((options = {}) => {
50766
51724
  const args = [process.argv[1], "serve"];
@@ -50772,7 +51730,8 @@ function createEnvironment(environment) {
50772
51730
  name: DAEMON_NAME,
50773
51731
  description: "Television server \u2014 virtual display for agents",
50774
51732
  command: process.execPath,
50775
- args
51733
+ args,
51734
+ env: options.env
50776
51735
  });
50777
51736
  }),
50778
51737
  resolveStaticDir: environment.resolveStaticDir ?? (() => resolveStaticDir()),
@@ -50794,21 +51753,45 @@ function createProgram(env, argv = []) {
50794
51753
  const createAuthenticatedClient = (serverURL) => {
50795
51754
  return env.createClient(serverURL, readAuthToken(getTelevisionStoragePath()));
50796
51755
  };
51756
+ const uninstallPersistedService = async () => {
51757
+ const daemon = env.createDaemon();
51758
+ await daemon.uninstall();
51759
+ writeJSON(env.stdout, { status: "stopped" });
51760
+ };
50797
51761
  program2.name("tv").description("Television \u2014 virtual display for agents").version(readCLIVersion()).showSuggestionAfterError(false).addHelpText("after", buildAgentHelpNote()).configureOutput({
50798
51762
  writeOut: (str) => env.stdout.write(str),
50799
51763
  writeErr: (str) => env.stderr.write(str),
50800
51764
  outputError: () => {
50801
51765
  }
50802
51766
  }).exitOverride();
50803
- program2.command("serve").description("Start the Television server").option("--host <address>", "Address to bind to").option("--port <number>", "Port to listen on", parsePortOption).option("--storage-path <path>", "Directory for persisted screen data").option("--public", "Serve without auth").option("--persist", "Install as a persistent system service").action(async (opts) => {
51767
+ program2.command("serve").description("Start the Television server").option("--host <address>", "Address to bind to").option("--port <number>", "Port to listen on", parsePortOption).option("--storage-path <path>", "Directory for persisted screen data").option("--public", "Serve without auth").option("--persist", "Install as a persistent system service").option("--persist-uninstall", "Uninstall the persistent system service").action(async (opts) => {
51768
+ if (opts.persist && opts.persistUninstall) {
51769
+ throw createDirectiveError("Use either `--persist` or `--persist-uninstall`, not both.");
51770
+ }
51771
+ if (opts.persistUninstall) {
51772
+ await uninstallPersistedService();
51773
+ return;
51774
+ }
50804
51775
  if (opts.persist) {
50805
51776
  const storagePath = opts.storagePath ?? getTelevisionStoragePath();
51777
+ const profile2 = resolveACPAgentProfile(process.env);
51778
+ const daemonEnv = buildPersistedACPEnvironment(process.env);
51779
+ if (!isACPCommandResolvable(profile2.command, daemonEnv)) {
51780
+ throw createDirectiveError(
51781
+ `Could not find ACP agent command \`${profile2.command}\` for \`TELEVISION_ACP_AGENT=${profile2.agent}\` on the persisted PATH. Set TELEVISION_ACP_AGENT to \`openclaw\` or \`hermes\`, and ensure the selected agent binary is available on PATH before running \`tv serve --persist\`.`
51782
+ );
51783
+ }
50806
51784
  const daemon = env.createDaemon({
50807
51785
  host: opts.host,
50808
51786
  port: opts.port,
50809
51787
  storagePath,
50810
- public: opts.public
51788
+ public: opts.public,
51789
+ env: daemonEnv
50811
51790
  });
51791
+ const daemonStatus = await daemon.status();
51792
+ if (daemonStatus.installed || daemonStatus.running) {
51793
+ await daemon.uninstall();
51794
+ }
50812
51795
  await daemon.install();
50813
51796
  writeJSON(
50814
51797
  env.stdout,
@@ -50820,6 +51803,12 @@ function createProgram(env, argv = []) {
50820
51803
  );
50821
51804
  return;
50822
51805
  }
51806
+ const profile = resolveACPAgentProfile(process.env);
51807
+ if (!isACPCommandResolvable(profile.command, process.env)) {
51808
+ throw createDirectiveError(
51809
+ `Could not find ACP agent command \`${profile.command}\` for \`TELEVISION_ACP_AGENT=${profile.agent}\` on PATH. Set TELEVISION_ACP_AGENT to \`openclaw\` or \`hermes\`, and ensure the selected agent binary is available on PATH before running \`tv serve\`.`
51810
+ );
51811
+ }
50823
51812
  const server = env.createServer({
50824
51813
  host: opts.host,
50825
51814
  port: opts.port,
@@ -50827,7 +51816,8 @@ function createProgram(env, argv = []) {
50827
51816
  staticDir: env.resolveStaticDir(),
50828
51817
  canonicalDir: env.resolveCanonicalDir(),
50829
51818
  bundledViewsPath: env.resolveBundledViewsPath(),
50830
- public: opts.public
51819
+ public: opts.public,
51820
+ acpProfile: profile
50831
51821
  });
50832
51822
  await server.start();
50833
51823
  writeJSON(env.stdout, opts.public ? { serverURL: server.getBaseURL() } : { serverURL: server.getBaseURL(), token: server.getAuthToken() });
@@ -51104,9 +52094,7 @@ If you wish to display temporary content to the user, use a web bundle artifact
51104
52094
  }
51105
52095
  });
51106
52096
  program2.command("stop").description("Stop the Television system service").action(async () => {
51107
- const daemon = env.createDaemon();
51108
- await daemon.uninstall();
51109
- writeJSON(env.stdout, { status: "stopped" });
52097
+ await uninstallPersistedService();
51110
52098
  });
51111
52099
  program2.command("status").description("Check Television server and service status").option("--server <url>", "Server URL", DEFAULT_SERVER_URL).action(async (opts) => {
51112
52100
  const result = {