vps-work 2.2.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/vps-work.cjs CHANGED
@@ -3337,11 +3337,11 @@ var require_yoctocolors_cjs = __commonJS({
3337
3337
  "use strict";
3338
3338
  var tty = require("tty");
3339
3339
  var hasColors = tty?.WriteStream?.prototype?.hasColors?.() ?? false;
3340
- var format = (open, close) => {
3340
+ var format = (open3, close) => {
3341
3341
  if (!hasColors) {
3342
3342
  return (input) => input;
3343
3343
  }
3344
- const openCode = `\x1B[${open}m`;
3344
+ const openCode = `\x1B[${open3}m`;
3345
3345
  const closeCode = `\x1B[${close}m`;
3346
3346
  return (input) => {
3347
3347
  const string = input + "";
@@ -4420,7 +4420,7 @@ var require_route = __commonJS({
4420
4420
  }
4421
4421
  return graph;
4422
4422
  }
4423
- function link(from, to) {
4423
+ function link2(from, to) {
4424
4424
  return function(args) {
4425
4425
  return to(from(args));
4426
4426
  };
@@ -4431,7 +4431,7 @@ var require_route = __commonJS({
4431
4431
  let cur = graph[toModel].parent;
4432
4432
  while (graph[cur].parent) {
4433
4433
  path3.unshift(graph[cur].parent);
4434
- fn = link(conversions[graph[cur].parent][cur], fn);
4434
+ fn = link2(conversions[graph[cur].parent][cur], fn);
4435
4435
  cur = graph[cur].parent;
4436
4436
  }
4437
4437
  fn.conversion = path3;
@@ -10930,7 +10930,7 @@ var require_lib2 = __commonJS({
10930
10930
  return matches;
10931
10931
  };
10932
10932
  exports2.analyse = analyse;
10933
- var detectFile = (filepath, opts = {}) => new Promise((resolve9, reject) => {
10933
+ var detectFile = (filepath, opts = {}) => new Promise((resolve11, reject) => {
10934
10934
  let fd;
10935
10935
  const fs = (0, node_1.default)();
10936
10936
  const handler = (err, buffer) => {
@@ -10940,7 +10940,7 @@ var require_lib2 = __commonJS({
10940
10940
  if (err) {
10941
10941
  reject(err);
10942
10942
  } else if (buffer) {
10943
- resolve9((0, exports2.detect)(buffer));
10943
+ resolve11((0, exports2.detect)(buffer));
10944
10944
  } else {
10945
10945
  reject(new Error("No error and no buffer received"));
10946
10946
  }
@@ -15013,11 +15013,11 @@ var require_timers = __commonJS({
15013
15013
  *
15014
15014
  * @param {NodeJS.Timeout|FastTimer} timeout
15015
15015
  */
15016
- clearTimeout(timeout) {
15017
- if (timeout[kFastTimer]) {
15018
- timeout.clear();
15016
+ clearTimeout(timeout2) {
15017
+ if (timeout2[kFastTimer]) {
15018
+ timeout2.clear();
15019
15019
  } else {
15020
- clearTimeout(timeout);
15020
+ clearTimeout(timeout2);
15021
15021
  }
15022
15022
  },
15023
15023
  /**
@@ -15040,8 +15040,8 @@ var require_timers = __commonJS({
15040
15040
  *
15041
15041
  * @param {FastTimer} timeout
15042
15042
  */
15043
- clearFastTimeout(timeout) {
15044
- timeout.clear();
15043
+ clearFastTimeout(timeout2) {
15044
+ timeout2.clear();
15045
15045
  },
15046
15046
  /**
15047
15047
  * The now method returns the value of the internal fast timer clock.
@@ -16447,10 +16447,10 @@ var require_util = __commonJS({
16447
16447
  }
16448
16448
  return obj;
16449
16449
  }
16450
- function errorRequest(client, request12, err) {
16450
+ function errorRequest(client, request13, err) {
16451
16451
  try {
16452
- request12.onError(err);
16453
- assert(request12.aborted);
16452
+ request13.onError(err);
16453
+ assert(request13.aborted);
16454
16454
  } catch (err2) {
16455
16455
  client.emit("error", err2);
16456
16456
  }
@@ -17124,7 +17124,7 @@ var require_request = __commonJS({
17124
17124
  return this;
17125
17125
  }
17126
17126
  };
17127
- function processHeader(request12, key, val) {
17127
+ function processHeader(request13, key, val) {
17128
17128
  if (val && (typeof val === "object" && !Array.isArray(val))) {
17129
17129
  throw new InvalidArgumentError2(`invalid ${key} header`);
17130
17130
  } else if (val === void 0) {
@@ -17171,24 +17171,24 @@ var require_request = __commonJS({
17171
17171
  }
17172
17172
  }
17173
17173
  if (headerName === "host") {
17174
- if (request12.host !== null) {
17174
+ if (request13.host !== null) {
17175
17175
  throw new InvalidArgumentError2("duplicate host header");
17176
17176
  }
17177
17177
  if (typeof val !== "string") {
17178
17178
  throw new InvalidArgumentError2("invalid host header");
17179
17179
  }
17180
- request12.host = val;
17180
+ request13.host = val;
17181
17181
  } else if (headerName === "content-length") {
17182
- if (request12.contentLength !== null) {
17182
+ if (request13.contentLength !== null) {
17183
17183
  throw new InvalidArgumentError2("duplicate content-length header");
17184
17184
  }
17185
17185
  if (!isValidContentLengthHeaderValue(val)) {
17186
17186
  throw new InvalidArgumentError2("invalid content-length header");
17187
17187
  }
17188
- request12.contentLength = parseInt(val, 10);
17189
- } else if (request12.contentType === null && headerName === "content-type") {
17190
- request12.contentType = val;
17191
- request12.headers.push(key, val);
17188
+ request13.contentLength = parseInt(val, 10);
17189
+ } else if (request13.contentType === null && headerName === "content-type") {
17190
+ request13.contentType = val;
17191
+ request13.headers.push(key, val);
17192
17192
  } else if (headerName === "transfer-encoding" || headerName === "keep-alive" || headerName === "upgrade") {
17193
17193
  throw new InvalidArgumentError2(`invalid ${headerName} header`);
17194
17194
  } else if (headerName === "connection") {
@@ -17202,13 +17202,13 @@ var require_request = __commonJS({
17202
17202
  throw new InvalidArgumentError2("invalid connection header");
17203
17203
  }
17204
17204
  if (trimmed === "close") {
17205
- request12.reset = true;
17205
+ request13.reset = true;
17206
17206
  }
17207
17207
  }
17208
17208
  } else if (headerName === "expect") {
17209
17209
  throw new NotSupportedError("expect header not supported");
17210
17210
  } else {
17211
- request12.headers.push(key, val);
17211
+ request13.headers.push(key, val);
17212
17212
  }
17213
17213
  }
17214
17214
  module2.exports = Request;
@@ -17479,9 +17479,9 @@ var require_dispatcher_base = __commonJS({
17479
17479
  }
17480
17480
  close(callback) {
17481
17481
  if (callback === void 0) {
17482
- return new Promise((resolve9, reject) => {
17482
+ return new Promise((resolve11, reject) => {
17483
17483
  this.close((err, data) => {
17484
- return err ? reject(err) : resolve9(data);
17484
+ return err ? reject(err) : resolve11(data);
17485
17485
  });
17486
17486
  });
17487
17487
  }
@@ -17519,9 +17519,9 @@ var require_dispatcher_base = __commonJS({
17519
17519
  err = null;
17520
17520
  }
17521
17521
  if (callback === void 0) {
17522
- return new Promise((resolve9, reject) => {
17522
+ return new Promise((resolve11, reject) => {
17523
17523
  this.destroy(err, (err2, data) => {
17524
- return err2 ? reject(err2) : resolve9(data);
17524
+ return err2 ? reject(err2) : resolve11(data);
17525
17525
  });
17526
17526
  });
17527
17527
  }
@@ -17629,13 +17629,13 @@ var require_connect = __commonJS({
17629
17629
  this._sessionRegistry.register(session, sessionKey);
17630
17630
  }
17631
17631
  };
17632
- function buildConnector({ allowH2, useH2c, maxCachedSessions, socketPath, timeout, session: customSession, ...opts }) {
17632
+ function buildConnector({ allowH2, useH2c, maxCachedSessions, socketPath, timeout: timeout2, session: customSession, ...opts }) {
17633
17633
  if (maxCachedSessions != null && (!Number.isInteger(maxCachedSessions) || maxCachedSessions < 0)) {
17634
17634
  throw new InvalidArgumentError2("maxCachedSessions must be a positive integer or zero");
17635
17635
  }
17636
17636
  const options = { path: socketPath, ...opts };
17637
17637
  const sessionCache = new SessionCache(maxCachedSessions == null ? 100 : maxCachedSessions);
17638
- timeout = timeout == null ? 1e4 : timeout;
17638
+ timeout2 = timeout2 == null ? 1e4 : timeout2;
17639
17639
  allowH2 = allowH2 != null ? allowH2 : false;
17640
17640
  return function connect({ hostname, host, protocol, port, servername, localAddress, httpSocket }, callback) {
17641
17641
  let socket;
@@ -17683,7 +17683,7 @@ var require_connect = __commonJS({
17683
17683
  const keepAliveInitialDelay = options.keepAliveInitialDelay === void 0 ? 6e4 : options.keepAliveInitialDelay;
17684
17684
  socket.setKeepAlive(true, keepAliveInitialDelay);
17685
17685
  }
17686
- const clearConnectTimeout = util2.setupConnectTimeout(new WeakRef(socket), { timeout, hostname, port });
17686
+ const clearConnectTimeout = util2.setupConnectTimeout(new WeakRef(socket), { timeout: timeout2, hostname, port });
17687
17687
  socket.setNoDelay(true).once(protocol === "https:" ? "secureConnect" : "connect", function() {
17688
17688
  queueMicrotask(clearConnectTimeout);
17689
17689
  if (callback) {
@@ -19801,11 +19801,11 @@ var require_util2 = __commonJS({
19801
19801
  function normalizeBinaryStringToUtf8(value) {
19802
19802
  return Buffer.from(value, "binary").toString("utf8");
19803
19803
  }
19804
- function requestCurrentURL(request12) {
19805
- return request12.urlList[request12.urlList.length - 1];
19804
+ function requestCurrentURL(request13) {
19805
+ return request13.urlList[request13.urlList.length - 1];
19806
19806
  }
19807
- function requestBadPort(request12) {
19808
- const url = requestCurrentURL(request12);
19807
+ function requestBadPort(request13) {
19808
+ const url = requestCurrentURL(request13);
19809
19809
  if (urlIsHttpHttpsScheme(url) && badPortsSet.has(url.port)) {
19810
19810
  return "blocked";
19811
19811
  }
@@ -19843,10 +19843,10 @@ var require_util2 = __commonJS({
19843
19843
  }
19844
19844
  return policy;
19845
19845
  }
19846
- function setRequestReferrerPolicyOnRedirect(request12, actualResponse) {
19846
+ function setRequestReferrerPolicyOnRedirect(request13, actualResponse) {
19847
19847
  const policy = parseReferrerPolicy(actualResponse);
19848
19848
  if (policy !== "") {
19849
- request12.referrerPolicy = policy;
19849
+ request13.referrerPolicy = policy;
19850
19850
  }
19851
19851
  }
19852
19852
  function crossOriginResourcePolicyCheck() {
@@ -19863,33 +19863,33 @@ var require_util2 = __commonJS({
19863
19863
  header = httpRequest.mode;
19864
19864
  httpRequest.headersList.set("sec-fetch-mode", header, true);
19865
19865
  }
19866
- function appendRequestOriginHeader(request12) {
19867
- let serializedOrigin = request12.origin;
19866
+ function appendRequestOriginHeader(request13) {
19867
+ let serializedOrigin = request13.origin;
19868
19868
  if (serializedOrigin === "client" || serializedOrigin === void 0) {
19869
19869
  return;
19870
19870
  }
19871
- if (request12.responseTainting === "cors" || request12.mode === "websocket") {
19872
- request12.headersList.append("origin", serializedOrigin, true);
19873
- } else if (request12.method !== "GET" && request12.method !== "HEAD") {
19874
- switch (request12.referrerPolicy) {
19871
+ if (request13.responseTainting === "cors" || request13.mode === "websocket") {
19872
+ request13.headersList.append("origin", serializedOrigin, true);
19873
+ } else if (request13.method !== "GET" && request13.method !== "HEAD") {
19874
+ switch (request13.referrerPolicy) {
19875
19875
  case "no-referrer":
19876
19876
  serializedOrigin = null;
19877
19877
  break;
19878
19878
  case "no-referrer-when-downgrade":
19879
19879
  case "strict-origin":
19880
19880
  case "strict-origin-when-cross-origin":
19881
- if (request12.origin && urlHasHttpsScheme(request12.origin) && !urlHasHttpsScheme(requestCurrentURL(request12))) {
19881
+ if (request13.origin && urlHasHttpsScheme(request13.origin) && !urlHasHttpsScheme(requestCurrentURL(request13))) {
19882
19882
  serializedOrigin = null;
19883
19883
  }
19884
19884
  break;
19885
19885
  case "same-origin":
19886
- if (!sameOrigin(request12, requestCurrentURL(request12))) {
19886
+ if (!sameOrigin(request13, requestCurrentURL(request13))) {
19887
19887
  serializedOrigin = null;
19888
19888
  }
19889
19889
  break;
19890
19890
  default:
19891
19891
  }
19892
- request12.headersList.append("origin", serializedOrigin, true);
19892
+ request13.headersList.append("origin", serializedOrigin, true);
19893
19893
  }
19894
19894
  }
19895
19895
  function coarsenTime(timestamp, crossOriginIsolatedCapability) {
@@ -19943,18 +19943,18 @@ var require_util2 = __commonJS({
19943
19943
  referrerPolicy: policyContainer.referrerPolicy
19944
19944
  };
19945
19945
  }
19946
- function determineRequestsReferrer(request12) {
19947
- const policy = request12.referrerPolicy;
19946
+ function determineRequestsReferrer(request13) {
19947
+ const policy = request13.referrerPolicy;
19948
19948
  assert(policy);
19949
19949
  let referrerSource = null;
19950
- if (request12.referrer === "client") {
19950
+ if (request13.referrer === "client") {
19951
19951
  const globalOrigin = getGlobalOrigin();
19952
19952
  if (!globalOrigin || globalOrigin.origin === "null") {
19953
19953
  return "no-referrer";
19954
19954
  }
19955
19955
  referrerSource = new URL(globalOrigin);
19956
- } else if (webidl.is.URL(request12.referrer)) {
19957
- referrerSource = request12.referrer;
19956
+ } else if (webidl.is.URL(request13.referrer)) {
19957
+ referrerSource = request13.referrer;
19958
19958
  }
19959
19959
  let referrerURL = stripURLForReferrer(referrerSource);
19960
19960
  const referrerOrigin = stripURLForReferrer(referrerSource, true);
@@ -19972,14 +19972,14 @@ var require_util2 = __commonJS({
19972
19972
  case "unsafe-url":
19973
19973
  return referrerURL;
19974
19974
  case "strict-origin": {
19975
- const currentURL = requestCurrentURL(request12);
19975
+ const currentURL = requestCurrentURL(request13);
19976
19976
  if (isURLPotentiallyTrustworthy(referrerURL) && !isURLPotentiallyTrustworthy(currentURL)) {
19977
19977
  return "no-referrer";
19978
19978
  }
19979
19979
  return referrerOrigin;
19980
19980
  }
19981
19981
  case "strict-origin-when-cross-origin": {
19982
- const currentURL = requestCurrentURL(request12);
19982
+ const currentURL = requestCurrentURL(request13);
19983
19983
  if (sameOrigin(referrerURL, currentURL)) {
19984
19984
  return referrerURL;
19985
19985
  }
@@ -19989,17 +19989,17 @@ var require_util2 = __commonJS({
19989
19989
  return referrerOrigin;
19990
19990
  }
19991
19991
  case "same-origin":
19992
- if (sameOrigin(request12, referrerURL)) {
19992
+ if (sameOrigin(request13, referrerURL)) {
19993
19993
  return referrerURL;
19994
19994
  }
19995
19995
  return "no-referrer";
19996
19996
  case "origin-when-cross-origin":
19997
- if (sameOrigin(request12, referrerURL)) {
19997
+ if (sameOrigin(request13, referrerURL)) {
19998
19998
  return referrerURL;
19999
19999
  }
20000
20000
  return referrerOrigin;
20001
20001
  case "no-referrer-when-downgrade": {
20002
- const currentURL = requestCurrentURL(request12);
20002
+ const currentURL = requestCurrentURL(request13);
20003
20003
  if (isURLPotentiallyTrustworthy(referrerURL) && !isURLPotentiallyTrustworthy(currentURL)) {
20004
20004
  return "no-referrer";
20005
20005
  }
@@ -20066,7 +20066,7 @@ var require_util2 = __commonJS({
20066
20066
  if (url.protocol === "blob:") return true;
20067
20067
  return isOriginPotentiallyTrustworthy(url.origin);
20068
20068
  }
20069
- function tryUpgradeRequestToAPotentiallyTrustworthyURL(request12) {
20069
+ function tryUpgradeRequestToAPotentiallyTrustworthyURL(request13) {
20070
20070
  }
20071
20071
  function sameOrigin(A, B) {
20072
20072
  if (A.origin === B.origin && A.origin === "null") {
@@ -20445,7 +20445,7 @@ var require_util2 = __commonJS({
20445
20445
  }
20446
20446
  return gettingDecodingSplitting(value);
20447
20447
  }
20448
- function hasAuthenticationEntry(request12) {
20448
+ function hasAuthenticationEntry(request13) {
20449
20449
  return false;
20450
20450
  }
20451
20451
  function includesCredentials(url) {
@@ -20527,7 +20527,7 @@ var require_formdata = __commonJS({
20527
20527
  var { kEnumerableProperty } = require_util();
20528
20528
  var { webidl } = require_webidl();
20529
20529
  var nodeUtil = require("util");
20530
- var FormData2 = class _FormData {
20530
+ var FormData3 = class _FormData {
20531
20531
  #state = [];
20532
20532
  constructor(form = void 0) {
20533
20533
  webidl.util.markAsUncloneable(this);
@@ -20644,11 +20644,11 @@ var require_formdata = __commonJS({
20644
20644
  formData.#state = newState;
20645
20645
  }
20646
20646
  };
20647
- var { getFormDataState, setFormDataState } = FormData2;
20648
- Reflect.deleteProperty(FormData2, "getFormDataState");
20649
- Reflect.deleteProperty(FormData2, "setFormDataState");
20650
- iteratorMixin("FormData", FormData2, getFormDataState, "name", "value");
20651
- Object.defineProperties(FormData2.prototype, {
20647
+ var { getFormDataState, setFormDataState } = FormData3;
20648
+ Reflect.deleteProperty(FormData3, "getFormDataState");
20649
+ Reflect.deleteProperty(FormData3, "setFormDataState");
20650
+ iteratorMixin("FormData", FormData3, getFormDataState, "name", "value");
20651
+ Object.defineProperties(FormData3.prototype, {
20652
20652
  append: kEnumerableProperty,
20653
20653
  delete: kEnumerableProperty,
20654
20654
  get: kEnumerableProperty,
@@ -20676,8 +20676,8 @@ var require_formdata = __commonJS({
20676
20676
  }
20677
20677
  return { name, value };
20678
20678
  }
20679
- webidl.is.FormData = webidl.util.MakeTypeAssertion(FormData2);
20680
- module2.exports = { FormData: FormData2, makeEntry, setFormDataState };
20679
+ webidl.is.FormData = webidl.util.MakeTypeAssertion(FormData3);
20680
+ module2.exports = { FormData: FormData3, makeEntry, setFormDataState };
20681
20681
  }
20682
20682
  });
20683
20683
 
@@ -21018,8 +21018,8 @@ var require_promise = __commonJS({
21018
21018
  function createDeferredPromise() {
21019
21019
  let res;
21020
21020
  let rej;
21021
- const promise = new Promise((resolve9, reject) => {
21022
- res = resolve9;
21021
+ const promise = new Promise((resolve11, reject) => {
21022
+ res = resolve11;
21023
21023
  rej = reject;
21024
21024
  });
21025
21025
  return { promise, resolve: res, reject: rej };
@@ -21041,7 +21041,7 @@ var require_body = __commonJS({
21041
21041
  fullyReadBody,
21042
21042
  extractMimeType
21043
21043
  } = require_util2();
21044
- var { FormData: FormData2, setFormDataState } = require_formdata();
21044
+ var { FormData: FormData3, setFormDataState } = require_formdata();
21045
21045
  var { webidl } = require_webidl();
21046
21046
  var assert = require("assert");
21047
21047
  var { isErrored, isDisturbed } = require("stream");
@@ -21234,13 +21234,13 @@ Content-Type: ${value.type || "application/octet-stream"}\r
21234
21234
  switch (mimeType3.essence) {
21235
21235
  case "multipart/form-data": {
21236
21236
  const parsed = multipartFormDataParser(value, mimeType3);
21237
- const fd = new FormData2();
21237
+ const fd = new FormData3();
21238
21238
  setFormDataState(fd, parsed);
21239
21239
  return fd;
21240
21240
  }
21241
21241
  case "application/x-www-form-urlencoded": {
21242
21242
  const entries = new URLSearchParams(value.toString());
21243
- const fd = new FormData2();
21243
+ const fd = new FormData3();
21244
21244
  for (const [name, value2] of entries) {
21245
21245
  fd.append(name, value2);
21246
21246
  }
@@ -21673,11 +21673,11 @@ var require_client_h1 = __commonJS({
21673
21673
  util2.destroy(socket, new SocketError("bad response", util2.getSocketInfo(socket)));
21674
21674
  return -1;
21675
21675
  }
21676
- const request12 = client[kQueue][client[kRunningIdx]];
21677
- if (!request12) {
21676
+ const request13 = client[kQueue][client[kRunningIdx]];
21677
+ if (!request13) {
21678
21678
  return -1;
21679
21679
  }
21680
- request12.onResponseStarted();
21680
+ request13.onResponseStarted();
21681
21681
  return 0;
21682
21682
  }
21683
21683
  /**
@@ -21739,9 +21739,9 @@ var require_client_h1 = __commonJS({
21739
21739
  assert(!socket.destroyed);
21740
21740
  assert(!this.paused);
21741
21741
  assert((headers3.length & 1) === 0);
21742
- const request12 = client[kQueue][client[kRunningIdx]];
21743
- assert(request12);
21744
- assert(request12.upgrade || request12.method === "CONNECT");
21742
+ const request13 = client[kQueue][client[kRunningIdx]];
21743
+ assert(request13);
21744
+ assert(request13.upgrade || request13.method === "CONNECT");
21745
21745
  this.statusCode = 0;
21746
21746
  this.statusText = "";
21747
21747
  this.shouldKeepAlive = false;
@@ -21758,7 +21758,7 @@ var require_client_h1 = __commonJS({
21758
21758
  client[kQueue][client[kRunningIdx]++] = null;
21759
21759
  client.emit("disconnect", client[kUrl], [client], new InformationalError("upgrade"));
21760
21760
  try {
21761
- request12.onUpgrade(statusCode, headers3, socket);
21761
+ request13.onUpgrade(statusCode, headers3, socket);
21762
21762
  } catch (err) {
21763
21763
  util2.destroy(socket, err);
21764
21764
  }
@@ -21779,8 +21779,8 @@ var require_client_h1 = __commonJS({
21779
21779
  util2.destroy(socket, new SocketError("bad response", util2.getSocketInfo(socket)));
21780
21780
  return -1;
21781
21781
  }
21782
- const request12 = client[kQueue][client[kRunningIdx]];
21783
- if (!request12) {
21782
+ const request13 = client[kQueue][client[kRunningIdx]];
21783
+ if (!request13) {
21784
21784
  return -1;
21785
21785
  }
21786
21786
  assert(!this.upgrade);
@@ -21789,23 +21789,23 @@ var require_client_h1 = __commonJS({
21789
21789
  util2.destroy(socket, new SocketError("bad response", util2.getSocketInfo(socket)));
21790
21790
  return -1;
21791
21791
  }
21792
- if (upgrade && !request12.upgrade) {
21792
+ if (upgrade && !request13.upgrade) {
21793
21793
  util2.destroy(socket, new SocketError("bad upgrade", util2.getSocketInfo(socket)));
21794
21794
  return -1;
21795
21795
  }
21796
21796
  assert(this.timeoutType === TIMEOUT_HEADERS);
21797
21797
  this.statusCode = statusCode;
21798
21798
  this.shouldKeepAlive = shouldKeepAlive || // Override llhttp value which does not allow keepAlive for HEAD.
21799
- request12.method === "HEAD" && !socket[kReset] && this.connection.toLowerCase() === "keep-alive";
21799
+ request13.method === "HEAD" && !socket[kReset] && this.connection.toLowerCase() === "keep-alive";
21800
21800
  if (this.statusCode >= 200) {
21801
- const bodyTimeout = request12.bodyTimeout != null ? request12.bodyTimeout : client[kBodyTimeout];
21801
+ const bodyTimeout = request13.bodyTimeout != null ? request13.bodyTimeout : client[kBodyTimeout];
21802
21802
  this.setTimeout(bodyTimeout, TIMEOUT_BODY);
21803
21803
  } else if (this.timeout) {
21804
21804
  if (this.timeout.refresh) {
21805
21805
  this.timeout.refresh();
21806
21806
  }
21807
21807
  }
21808
- if (request12.method === "CONNECT") {
21808
+ if (request13.method === "CONNECT") {
21809
21809
  assert(client[kRunning] === 1);
21810
21810
  this.upgrade = true;
21811
21811
  return 2;
@@ -21821,14 +21821,14 @@ var require_client_h1 = __commonJS({
21821
21821
  if (this.shouldKeepAlive && client[kPipelining]) {
21822
21822
  const keepAliveTimeout = this.keepAlive ? util2.parseKeepAliveTimeout(this.keepAlive) : null;
21823
21823
  if (keepAliveTimeout != null) {
21824
- const timeout = Math.min(
21824
+ const timeout2 = Math.min(
21825
21825
  keepAliveTimeout - client[kKeepAliveTimeoutThreshold],
21826
21826
  client[kKeepAliveMaxTimeout]
21827
21827
  );
21828
- if (timeout <= 0) {
21828
+ if (timeout2 <= 0) {
21829
21829
  socket[kReset] = true;
21830
21830
  } else {
21831
- client[kKeepAliveTimeoutValue] = timeout;
21831
+ client[kKeepAliveTimeoutValue] = timeout2;
21832
21832
  }
21833
21833
  } else {
21834
21834
  client[kKeepAliveTimeoutValue] = client[kKeepAliveDefaultTimeout];
@@ -21836,11 +21836,11 @@ var require_client_h1 = __commonJS({
21836
21836
  } else {
21837
21837
  socket[kReset] = true;
21838
21838
  }
21839
- const pause = request12.onHeaders(statusCode, headers3, this.resume, statusText) === false;
21840
- if (request12.aborted) {
21839
+ const pause = request13.onHeaders(statusCode, headers3, this.resume, statusText) === false;
21840
+ if (request13.aborted) {
21841
21841
  return -1;
21842
21842
  }
21843
- if (request12.method === "HEAD") {
21843
+ if (request13.method === "HEAD") {
21844
21844
  return 1;
21845
21845
  }
21846
21846
  if (statusCode < 200) {
@@ -21861,8 +21861,8 @@ var require_client_h1 = __commonJS({
21861
21861
  if (socket.destroyed) {
21862
21862
  return -1;
21863
21863
  }
21864
- const request12 = client[kQueue][client[kRunningIdx]];
21865
- assert(request12);
21864
+ const request13 = client[kQueue][client[kRunningIdx]];
21865
+ assert(request13);
21866
21866
  assert(this.timeoutType === TIMEOUT_BODY);
21867
21867
  if (this.timeout) {
21868
21868
  if (this.timeout.refresh) {
@@ -21875,7 +21875,7 @@ var require_client_h1 = __commonJS({
21875
21875
  return -1;
21876
21876
  }
21877
21877
  this.bytesRead += buf.length;
21878
- if (request12.onData(buf) === false) {
21878
+ if (request13.onData(buf) === false) {
21879
21879
  return constants.ERROR.PAUSED;
21880
21880
  }
21881
21881
  return 0;
@@ -21893,8 +21893,8 @@ var require_client_h1 = __commonJS({
21893
21893
  }
21894
21894
  assert(statusCode >= 100);
21895
21895
  assert((this.headers.length & 1) === 0);
21896
- const request12 = client[kQueue][client[kRunningIdx]];
21897
- assert(request12);
21896
+ const request13 = client[kQueue][client[kRunningIdx]];
21897
+ assert(request13);
21898
21898
  this.statusCode = 0;
21899
21899
  this.statusText = "";
21900
21900
  this.bytesRead = 0;
@@ -21906,11 +21906,11 @@ var require_client_h1 = __commonJS({
21906
21906
  if (statusCode < 200) {
21907
21907
  return 0;
21908
21908
  }
21909
- if (request12.method !== "HEAD" && contentLength && bytesRead !== parseInt(contentLength, 10)) {
21909
+ if (request13.method !== "HEAD" && contentLength && bytesRead !== parseInt(contentLength, 10)) {
21910
21910
  util2.destroy(socket, new ResponseContentLengthMismatchError());
21911
21911
  return -1;
21912
21912
  }
21913
- request12.onComplete(headers3);
21913
+ request13.onComplete(headers3);
21914
21914
  client[kQueue][client[kRunningIdx]++] = null;
21915
21915
  socket[kSocketUsed] = client[kPending] === 0;
21916
21916
  if (socket[kWriting]) {
@@ -21979,8 +21979,8 @@ var require_client_h1 = __commonJS({
21979
21979
  return {
21980
21980
  version: "h1",
21981
21981
  defaultPipelining: 1,
21982
- write(request12) {
21983
- return writeH1(client, request12);
21982
+ write(request13) {
21983
+ return writeH1(client, request13);
21984
21984
  },
21985
21985
  resume() {
21986
21986
  resumeH1(client);
@@ -22007,18 +22007,18 @@ var require_client_h1 = __commonJS({
22007
22007
  * @param {import('../core/request.js')} request
22008
22008
  * @returns {boolean}
22009
22009
  */
22010
- busy(request12) {
22010
+ busy(request13) {
22011
22011
  if (socket[kWriting] || socket[kReset] || socket[kBlocking] || socket[kIdleSocketValidation] === 1) {
22012
22012
  return true;
22013
22013
  }
22014
- if (request12) {
22015
- if (client[kRunning] > 0 && !request12.idempotent) {
22014
+ if (request13) {
22015
+ if (client[kRunning] > 0 && !request13.idempotent) {
22016
22016
  return true;
22017
22017
  }
22018
- if (client[kRunning] > 0 && (request12.upgrade || request12.method === "CONNECT")) {
22018
+ if (client[kRunning] > 0 && (request13.upgrade || request13.method === "CONNECT")) {
22019
22019
  return true;
22020
22020
  }
22021
- if (client[kRunning] > 0 && util2.bodyLength(request12.body) !== 0 && (util2.isStream(request12.body) || util2.isAsyncIterable(request12.body) || util2.isFormDataLike(request12.body))) {
22021
+ if (client[kRunning] > 0 && util2.bodyLength(request13.body) !== 0 && (util2.isStream(request13.body) || util2.isAsyncIterable(request13.body) || util2.isFormDataLike(request13.body))) {
22022
22022
  return true;
22023
22023
  }
22024
22024
  }
@@ -22072,13 +22072,13 @@ var require_client_h1 = __commonJS({
22072
22072
  assert(client[kPending] === 0);
22073
22073
  const requests = client[kQueue].splice(client[kRunningIdx]);
22074
22074
  for (let i = 0; i < requests.length; i++) {
22075
- const request12 = requests[i];
22076
- util2.errorRequest(client, request12, err);
22075
+ const request13 = requests[i];
22076
+ util2.errorRequest(client, request13, err);
22077
22077
  }
22078
22078
  } else if (client[kRunning] > 0 && err.code !== "UND_ERR_INFO") {
22079
- const request12 = client[kQueue][client[kRunningIdx]];
22079
+ const request13 = client[kQueue][client[kRunningIdx]];
22080
22080
  client[kQueue][client[kRunningIdx]++] = null;
22081
- util2.errorRequest(client, request12, err);
22081
+ util2.errorRequest(client, request13, err);
22082
22082
  }
22083
22083
  client[kPendingIdx] = client[kRunningIdx];
22084
22084
  assert(client[kRunning] === 0);
@@ -22146,8 +22146,8 @@ var require_client_h1 = __commonJS({
22146
22146
  }
22147
22147
  } else if (client[kRunning] > 0 && socket[kParser].statusCode < 200) {
22148
22148
  if (socket[kParser].timeoutType !== TIMEOUT_HEADERS) {
22149
- const request12 = client[kQueue][client[kRunningIdx]];
22150
- const headersTimeout = request12.headersTimeout != null ? request12.headersTimeout : client[kHeadersTimeout];
22149
+ const request13 = client[kQueue][client[kRunningIdx]];
22150
+ const headersTimeout = request13.headersTimeout != null ? request13.headersTimeout : client[kHeadersTimeout];
22151
22151
  socket[kParser].setTimeout(headersTimeout, TIMEOUT_HEADERS);
22152
22152
  }
22153
22153
  }
@@ -22156,26 +22156,26 @@ var require_client_h1 = __commonJS({
22156
22156
  function shouldSendContentLength(method) {
22157
22157
  return method !== "GET" && method !== "HEAD" && method !== "OPTIONS" && method !== "TRACE" && method !== "CONNECT";
22158
22158
  }
22159
- function writeH1(client, request12) {
22160
- const { method, path: path3, host, upgrade, blocking, reset } = request12;
22161
- let { body, headers: headers3, contentLength } = request12;
22159
+ function writeH1(client, request13) {
22160
+ const { method, path: path3, host, upgrade, blocking, reset } = request13;
22161
+ let { body, headers: headers3, contentLength } = request13;
22162
22162
  const expectsPayload = method === "PUT" || method === "POST" || method === "PATCH" || method === "QUERY" || method === "PROPFIND" || method === "PROPPATCH";
22163
22163
  if (util2.isFormDataLike(body)) {
22164
22164
  if (!extractBody) {
22165
22165
  extractBody = require_body().extractBody;
22166
22166
  }
22167
22167
  const [bodyStream, contentType] = extractBody(body);
22168
- if (request12.contentType == null) {
22168
+ if (request13.contentType == null) {
22169
22169
  headers3.push("content-type", contentType);
22170
22170
  }
22171
22171
  body = bodyStream.stream;
22172
22172
  contentLength = bodyStream.length;
22173
- } else if (util2.isBlobLike(body) && request12.contentType == null) {
22173
+ } else if (util2.isBlobLike(body) && request13.contentType == null) {
22174
22174
  const contentType = body.type;
22175
22175
  if (contentType) {
22176
22176
  const contentTypeValue = `${contentType}`;
22177
22177
  if (!util2.isValidHeaderValue(contentTypeValue)) {
22178
- util2.errorRequest(client, request12, new InvalidArgumentError2("invalid content-type header"));
22178
+ util2.errorRequest(client, request13, new InvalidArgumentError2("invalid content-type header"));
22179
22179
  return false;
22180
22180
  }
22181
22181
  headers3.push("content-type", contentTypeValue);
@@ -22187,14 +22187,14 @@ var require_client_h1 = __commonJS({
22187
22187
  const bodyLength = util2.bodyLength(body);
22188
22188
  contentLength = bodyLength ?? contentLength;
22189
22189
  if (contentLength === null) {
22190
- contentLength = request12.contentLength;
22190
+ contentLength = request13.contentLength;
22191
22191
  }
22192
22192
  if (contentLength === 0 && !expectsPayload) {
22193
22193
  contentLength = null;
22194
22194
  }
22195
- if (shouldSendContentLength(method) && contentLength > 0 && request12.contentLength !== null && request12.contentLength !== contentLength) {
22195
+ if (shouldSendContentLength(method) && contentLength > 0 && request13.contentLength !== null && request13.contentLength !== contentLength) {
22196
22196
  if (client[kStrictContentLength]) {
22197
- util2.errorRequest(client, request12, new RequestContentLengthMismatchError());
22197
+ util2.errorRequest(client, request13, new RequestContentLengthMismatchError());
22198
22198
  return false;
22199
22199
  }
22200
22200
  process.emitWarning(new RequestContentLengthMismatchError());
@@ -22202,19 +22202,19 @@ var require_client_h1 = __commonJS({
22202
22202
  const socket = client[kSocket];
22203
22203
  clearIdleSocketValidation(socket);
22204
22204
  const abort = (err) => {
22205
- if (request12.aborted || request12.completed) {
22205
+ if (request13.aborted || request13.completed) {
22206
22206
  return;
22207
22207
  }
22208
- util2.errorRequest(client, request12, err || new RequestAbortedError());
22208
+ util2.errorRequest(client, request13, err || new RequestAbortedError());
22209
22209
  util2.destroy(body);
22210
22210
  util2.destroy(socket, new InformationalError("aborted"));
22211
22211
  };
22212
22212
  try {
22213
- request12.onConnect(abort);
22213
+ request13.onConnect(abort);
22214
22214
  } catch (err) {
22215
- util2.errorRequest(client, request12, err);
22215
+ util2.errorRequest(client, request13, err);
22216
22216
  }
22217
- if (request12.aborted) {
22217
+ if (request13.aborted) {
22218
22218
  return false;
22219
22219
  }
22220
22220
  if (method === "HEAD") {
@@ -22233,7 +22233,7 @@ var require_client_h1 = __commonJS({
22233
22233
  socket[kBlocking] = true;
22234
22234
  }
22235
22235
  if (socket.setTypeOfService) {
22236
- socket.setTypeOfService(request12.typeOfService);
22236
+ socket.setTypeOfService(request13.typeOfService);
22237
22237
  }
22238
22238
  let header = `${method} ${path3} HTTP/1.1\r
22239
22239
  `;
@@ -22268,31 +22268,31 @@ upgrade: ${upgrade}\r
22268
22268
  }
22269
22269
  }
22270
22270
  if (channels.sendHeaders.hasSubscribers) {
22271
- channels.sendHeaders.publish({ request: request12, headers: header, socket });
22271
+ channels.sendHeaders.publish({ request: request13, headers: header, socket });
22272
22272
  }
22273
22273
  if (!body || bodyLength === 0) {
22274
- writeBuffer(abort, null, client, request12, socket, contentLength, header, expectsPayload);
22274
+ writeBuffer(abort, null, client, request13, socket, contentLength, header, expectsPayload);
22275
22275
  } else if (util2.isBuffer(body)) {
22276
- writeBuffer(abort, body, client, request12, socket, contentLength, header, expectsPayload);
22276
+ writeBuffer(abort, body, client, request13, socket, contentLength, header, expectsPayload);
22277
22277
  } else if (util2.isBlobLike(body)) {
22278
22278
  if (typeof body.stream === "function") {
22279
- writeIterable(abort, body.stream(), client, request12, socket, contentLength, header, expectsPayload);
22279
+ writeIterable(abort, body.stream(), client, request13, socket, contentLength, header, expectsPayload);
22280
22280
  } else {
22281
- writeBlob(abort, body, client, request12, socket, contentLength, header, expectsPayload);
22281
+ writeBlob(abort, body, client, request13, socket, contentLength, header, expectsPayload);
22282
22282
  }
22283
22283
  } else if (util2.isStream(body)) {
22284
- writeStream(abort, body, client, request12, socket, contentLength, header, expectsPayload);
22284
+ writeStream(abort, body, client, request13, socket, contentLength, header, expectsPayload);
22285
22285
  } else if (util2.isIterable(body)) {
22286
- writeIterable(abort, body, client, request12, socket, contentLength, header, expectsPayload);
22286
+ writeIterable(abort, body, client, request13, socket, contentLength, header, expectsPayload);
22287
22287
  } else {
22288
22288
  assert(false);
22289
22289
  }
22290
22290
  return true;
22291
22291
  }
22292
- function writeStream(abort, body, client, request12, socket, contentLength, header, expectsPayload) {
22292
+ function writeStream(abort, body, client, request13, socket, contentLength, header, expectsPayload) {
22293
22293
  assert(contentLength !== 0 || client[kRunning] === 0, "stream body cannot be pipelined");
22294
22294
  let finished = false;
22295
- const writer = new AsyncWriter({ abort, socket, request: request12, contentLength, client, expectsPayload, header });
22295
+ const writer = new AsyncWriter({ abort, socket, request: request13, contentLength, client, expectsPayload, header });
22296
22296
  const onData = function(chunk) {
22297
22297
  if (finished) {
22298
22298
  return;
@@ -22358,7 +22358,7 @@ upgrade: ${upgrade}\r
22358
22358
  setImmediate(onClose);
22359
22359
  }
22360
22360
  }
22361
- function writeBuffer(abort, body, client, request12, socket, contentLength, header, expectsPayload) {
22361
+ function writeBuffer(abort, body, client, request13, socket, contentLength, header, expectsPayload) {
22362
22362
  try {
22363
22363
  if (!body) {
22364
22364
  if (contentLength === 0) {
@@ -22378,18 +22378,18 @@ upgrade: ${upgrade}\r
22378
22378
  `, "latin1");
22379
22379
  socket.write(body);
22380
22380
  socket.uncork();
22381
- request12.onBodySent(body);
22382
- if (!expectsPayload && request12.reset !== false) {
22381
+ request13.onBodySent(body);
22382
+ if (!expectsPayload && request13.reset !== false) {
22383
22383
  socket[kReset] = true;
22384
22384
  }
22385
22385
  }
22386
- request12.onRequestSent();
22386
+ request13.onRequestSent();
22387
22387
  client[kResume]();
22388
22388
  } catch (err) {
22389
22389
  abort(err);
22390
22390
  }
22391
22391
  }
22392
- async function writeBlob(abort, body, client, request12, socket, contentLength, header, expectsPayload) {
22392
+ async function writeBlob(abort, body, client, request13, socket, contentLength, header, expectsPayload) {
22393
22393
  assert(contentLength === body.size, "blob body must have content length");
22394
22394
  try {
22395
22395
  if (contentLength != null && contentLength !== body.size) {
@@ -22402,9 +22402,9 @@ upgrade: ${upgrade}\r
22402
22402
  `, "latin1");
22403
22403
  socket.write(buffer);
22404
22404
  socket.uncork();
22405
- request12.onBodySent(buffer);
22406
- request12.onRequestSent();
22407
- if (!expectsPayload && request12.reset !== false) {
22405
+ request13.onBodySent(buffer);
22406
+ request13.onRequestSent();
22407
+ if (!expectsPayload && request13.reset !== false) {
22408
22408
  socket[kReset] = true;
22409
22409
  }
22410
22410
  client[kResume]();
@@ -22412,7 +22412,7 @@ upgrade: ${upgrade}\r
22412
22412
  abort(err);
22413
22413
  }
22414
22414
  }
22415
- async function writeIterable(abort, body, client, request12, socket, contentLength, header, expectsPayload) {
22415
+ async function writeIterable(abort, body, client, request13, socket, contentLength, header, expectsPayload) {
22416
22416
  assert(contentLength !== 0 || client[kRunning] === 0, "iterator body cannot be pipelined");
22417
22417
  let callback = null;
22418
22418
  function onDrain() {
@@ -22422,16 +22422,16 @@ upgrade: ${upgrade}\r
22422
22422
  cb();
22423
22423
  }
22424
22424
  }
22425
- const waitForDrain = () => new Promise((resolve9, reject) => {
22425
+ const waitForDrain = () => new Promise((resolve11, reject) => {
22426
22426
  assert(callback === null);
22427
22427
  if (socket[kError]) {
22428
22428
  reject(socket[kError]);
22429
22429
  } else {
22430
- callback = resolve9;
22430
+ callback = resolve11;
22431
22431
  }
22432
22432
  });
22433
22433
  socket.on("close", onDrain).on("drain", onDrain);
22434
- const writer = new AsyncWriter({ abort, socket, request: request12, contentLength, client, expectsPayload, header });
22434
+ const writer = new AsyncWriter({ abort, socket, request: request13, contentLength, client, expectsPayload, header });
22435
22435
  try {
22436
22436
  for await (const chunk of body) {
22437
22437
  if (socket[kError]) {
@@ -22460,9 +22460,9 @@ upgrade: ${upgrade}\r
22460
22460
  * @param {boolean} arg.expectsPayload
22461
22461
  * @param {string} arg.header
22462
22462
  */
22463
- constructor({ abort, socket, request: request12, contentLength, client, expectsPayload, header }) {
22463
+ constructor({ abort, socket, request: request13, contentLength, client, expectsPayload, header }) {
22464
22464
  this.socket = socket;
22465
- this.request = request12;
22465
+ this.request = request13;
22466
22466
  this.contentLength = contentLength;
22467
22467
  this.client = client;
22468
22468
  this.bytesWritten = 0;
@@ -22476,7 +22476,7 @@ upgrade: ${upgrade}\r
22476
22476
  * @returns
22477
22477
  */
22478
22478
  write(chunk) {
22479
- const { socket, request: request12, contentLength, client, bytesWritten, expectsPayload, header } = this;
22479
+ const { socket, request: request13, contentLength, client, bytesWritten, expectsPayload, header } = this;
22480
22480
  if (socket[kError]) {
22481
22481
  throw socket[kError];
22482
22482
  }
@@ -22495,7 +22495,7 @@ upgrade: ${upgrade}\r
22495
22495
  }
22496
22496
  socket.cork();
22497
22497
  if (bytesWritten === 0) {
22498
- if (!expectsPayload && request12.reset !== false) {
22498
+ if (!expectsPayload && request13.reset !== false) {
22499
22499
  socket[kReset] = true;
22500
22500
  }
22501
22501
  if (contentLength === null) {
@@ -22515,7 +22515,7 @@ ${len.toString(16)}\r
22515
22515
  this.bytesWritten += len;
22516
22516
  const ret = socket.write(chunk);
22517
22517
  socket.uncork();
22518
- request12.onBodySent(chunk);
22518
+ request13.onBodySent(chunk);
22519
22519
  if (!ret) {
22520
22520
  if (socket[kParser].timeout && socket[kParser].timeoutType === TIMEOUT_HEADERS) {
22521
22521
  if (socket[kParser].timeout.refresh) {
@@ -22529,8 +22529,8 @@ ${len.toString(16)}\r
22529
22529
  * @returns {void}
22530
22530
  */
22531
22531
  end() {
22532
- const { socket, contentLength, client, bytesWritten, expectsPayload, header, request: request12 } = this;
22533
- request12.onRequestSent();
22532
+ const { socket, contentLength, client, bytesWritten, expectsPayload, header, request: request13 } = this;
22533
+ request13.onRequestSent();
22534
22534
  socket[kWriting] = false;
22535
22535
  if (socket[kError]) {
22536
22536
  throw socket[kError];
@@ -22586,7 +22586,7 @@ var require_client_h2 = __commonJS({
22586
22586
  "node_modules/.pnpm/undici@7.29.1/node_modules/undici/lib/dispatcher/client-h2.js"(exports2, module2) {
22587
22587
  "use strict";
22588
22588
  var assert = require("assert");
22589
- var { pipeline: pipeline3 } = require("stream");
22589
+ var { pipeline: pipeline4 } = require("stream");
22590
22590
  var util2 = require_util();
22591
22591
  var {
22592
22592
  RequestContentLengthMismatchError,
@@ -22710,8 +22710,8 @@ var require_client_h2 = __commonJS({
22710
22710
  * @param {import('../core/request.js')} request
22711
22711
  * @returns {boolean}
22712
22712
  */
22713
- write(request12) {
22714
- return writeH2(client, request12);
22713
+ write(request13) {
22714
+ return writeH2(client, request13);
22715
22715
  },
22716
22716
  /**
22717
22717
  * @returns {void}
@@ -22740,14 +22740,14 @@ var require_client_h2 = __commonJS({
22740
22740
  * @param {import('../core/request.js')} request
22741
22741
  * @returns {boolean}
22742
22742
  */
22743
- busy(request12) {
22744
- if (request12 != null) {
22743
+ busy(request13) {
22744
+ if (request13 != null) {
22745
22745
  if (client[kRunning] > 0) {
22746
- if (request12.idempotent === false) return true;
22747
- if ((request12.upgrade === "websocket" || request12.method === "CONNECT") && session[kRemoteSettings] === false) return true;
22748
- if (util2.bodyLength(request12.body) !== 0 && (util2.isStream(request12.body) || util2.isAsyncIterable(request12.body) || util2.isFormDataLike(request12.body))) return true;
22746
+ if (request13.idempotent === false) return true;
22747
+ if ((request13.upgrade === "websocket" || request13.method === "CONNECT") && session[kRemoteSettings] === false) return true;
22748
+ if (util2.bodyLength(request13.body) !== 0 && (util2.isStream(request13.body) || util2.isAsyncIterable(request13.body) || util2.isFormDataLike(request13.body))) return true;
22749
22749
  } else {
22750
- return (request12.upgrade === "websocket" || request12.method === "CONNECT") && session[kRemoteSettings] === false;
22750
+ return (request13.upgrade === "websocket" || request13.method === "CONNECT") && session[kRemoteSettings] === false;
22751
22751
  }
22752
22752
  }
22753
22753
  return false;
@@ -22823,15 +22823,15 @@ var require_client_h2 = __commonJS({
22823
22823
  this.destroy(err);
22824
22824
  util2.destroy(this[kSocket], err);
22825
22825
  }
22826
- function completeRequest(client, request12, resetPendingIdx = false) {
22826
+ function completeRequest(client, request13, resetPendingIdx = false) {
22827
22827
  const queue = client[kQueue];
22828
22828
  const runningIdx = client[kRunningIdx];
22829
- if (runningIdx < client[kPendingIdx] && queue[runningIdx] === request12) {
22829
+ if (runningIdx < client[kPendingIdx] && queue[runningIdx] === request13) {
22830
22830
  queue[runningIdx] = null;
22831
22831
  client[kRunningIdx] = runningIdx + 1;
22832
22832
  return;
22833
22833
  }
22834
- const index = queue.indexOf(request12, runningIdx);
22834
+ const index = queue.indexOf(request13, runningIdx);
22835
22835
  if (index === -1 || index >= client[kPendingIdx]) {
22836
22836
  return;
22837
22837
  }
@@ -22850,10 +22850,10 @@ var require_client_h2 = __commonJS({
22850
22850
  this[kHTTP2Session] = null;
22851
22851
  util2.destroy(this[kSocket], err);
22852
22852
  if (client[kRunningIdx] < client[kQueue].length) {
22853
- const request12 = client[kQueue][client[kRunningIdx]];
22853
+ const request13 = client[kQueue][client[kRunningIdx]];
22854
22854
  client[kQueue][client[kRunningIdx]++] = null;
22855
- if (request12 != null) {
22856
- util2.errorRequest(client, request12, err);
22855
+ if (request13 != null) {
22856
+ util2.errorRequest(client, request13, err);
22857
22857
  }
22858
22858
  client[kPendingIdx] = client[kRunningIdx];
22859
22859
  }
@@ -22876,9 +22876,9 @@ var require_client_h2 = __commonJS({
22876
22876
  assert(client[kPending] === 0);
22877
22877
  const requests = client[kQueue].splice(client[kRunningIdx]);
22878
22878
  for (let i = 0; i < requests.length; i++) {
22879
- const request12 = requests[i];
22880
- if (request12 != null) {
22881
- util2.errorRequest(client, request12, err);
22879
+ const request13 = requests[i];
22880
+ if (request13 != null) {
22881
+ util2.errorRequest(client, request13, err);
22882
22882
  }
22883
22883
  }
22884
22884
  }
@@ -22910,14 +22910,14 @@ var require_client_h2 = __commonJS({
22910
22910
  function shouldSendContentLength(method) {
22911
22911
  return method !== "GET" && method !== "HEAD" && method !== "OPTIONS" && method !== "TRACE" && method !== "CONNECT";
22912
22912
  }
22913
- function writeH2(client, request12) {
22914
- const headersTimeout = request12.headersTimeout ?? client[kHeadersTimeout];
22915
- const bodyTimeout = request12.bodyTimeout ?? client[kBodyTimeout];
22913
+ function writeH2(client, request13) {
22914
+ const headersTimeout = request13.headersTimeout ?? client[kHeadersTimeout];
22915
+ const bodyTimeout = request13.bodyTimeout ?? client[kBodyTimeout];
22916
22916
  const session = client[kHTTP2Session];
22917
- const { method, path: path3, host, upgrade, expectContinue, signal, protocol, headers: reqHeaders } = request12;
22918
- let { body } = request12;
22917
+ const { method, path: path3, host, upgrade, expectContinue, signal, protocol, headers: reqHeaders } = request13;
22918
+ let { body } = request13;
22919
22919
  if (upgrade != null && upgrade !== "websocket") {
22920
- util2.errorRequest(client, request12, new InvalidArgumentError2(`Custom upgrade "${upgrade}" not supported over HTTP/2`));
22920
+ util2.errorRequest(client, request13, new InvalidArgumentError2(`Custom upgrade "${upgrade}" not supported over HTTP/2`));
22921
22921
  return false;
22922
22922
  }
22923
22923
  const headers3 = {};
@@ -22951,33 +22951,33 @@ var require_client_h2 = __commonJS({
22951
22951
  headers3[HTTP2_HEADER_AUTHORITY] = host || `${hostname}${port ? `:${port}` : ""}`;
22952
22952
  headers3[HTTP2_HEADER_METHOD] = method;
22953
22953
  const abort = (err) => {
22954
- if (request12.aborted || request12.completed) {
22954
+ if (request13.aborted || request13.completed) {
22955
22955
  return;
22956
22956
  }
22957
22957
  err = err || new RequestAbortedError();
22958
- util2.errorRequest(client, request12, err);
22958
+ util2.errorRequest(client, request13, err);
22959
22959
  if (stream != null) {
22960
22960
  stream.removeAllListeners("data");
22961
22961
  stream.close();
22962
22962
  client[kOnError](err);
22963
- completeRequest(client, request12);
22963
+ completeRequest(client, request13);
22964
22964
  client[kResume]();
22965
22965
  }
22966
22966
  util2.destroy(body, err);
22967
22967
  };
22968
22968
  try {
22969
- request12.onConnect(abort);
22969
+ request13.onConnect(abort);
22970
22970
  } catch (err) {
22971
- util2.errorRequest(client, request12, err);
22971
+ util2.errorRequest(client, request13, err);
22972
22972
  }
22973
- if (request12.aborted) {
22973
+ if (request13.aborted) {
22974
22974
  return false;
22975
22975
  }
22976
22976
  if (upgrade || method === "CONNECT") {
22977
22977
  session.ref();
22978
22978
  if (upgrade === "websocket") {
22979
22979
  if (session[kEnableConnectProtocol] === false) {
22980
- util2.errorRequest(client, request12, new InformationalError("HTTP/2: Extended CONNECT protocol not supported by server"));
22980
+ util2.errorRequest(client, request13, new InformationalError("HTTP/2: Extended CONNECT protocol not supported by server"));
22981
22981
  session.unref();
22982
22982
  return false;
22983
22983
  }
@@ -22993,9 +22993,9 @@ var require_client_h2 = __commonJS({
22993
22993
  stream[kHTTP2Stream] = true;
22994
22994
  stream.once("response", (headers4, _flags) => {
22995
22995
  const { [HTTP2_HEADER_STATUS]: statusCode, ...realHeaders } = headers4;
22996
- request12.onUpgrade(statusCode, parseH2Headers(realHeaders), stream);
22996
+ request13.onUpgrade(statusCode, parseH2Headers(realHeaders), stream);
22997
22997
  ++session[kOpenStreams];
22998
- completeRequest(client, request12);
22998
+ completeRequest(client, request13);
22999
22999
  });
23000
23000
  stream.on("error", () => {
23001
23001
  if (stream.rstCode === NGHTTP2_REFUSED_STREAM || stream.rstCode === NGHTTP2_CANCEL) {
@@ -23013,9 +23013,9 @@ var require_client_h2 = __commonJS({
23013
23013
  stream[kHTTP2Stream] = true;
23014
23014
  stream.on("response", (headers4) => {
23015
23015
  const { [HTTP2_HEADER_STATUS]: statusCode, ...realHeaders } = headers4;
23016
- request12.onUpgrade(statusCode, parseH2Headers(realHeaders), stream);
23016
+ request13.onUpgrade(statusCode, parseH2Headers(realHeaders), stream);
23017
23017
  ++session[kOpenStreams];
23018
- completeRequest(client, request12);
23018
+ completeRequest(client, request13);
23019
23019
  });
23020
23020
  stream.on("error", abort);
23021
23021
  stream.once("close", () => {
@@ -23040,14 +23040,14 @@ var require_client_h2 = __commonJS({
23040
23040
  contentLength = bodyStream.length;
23041
23041
  }
23042
23042
  if (contentLength == null) {
23043
- contentLength = request12.contentLength;
23043
+ contentLength = request13.contentLength;
23044
23044
  }
23045
23045
  if (!expectsPayload) {
23046
23046
  contentLength = null;
23047
23047
  }
23048
- if (shouldSendContentLength(method) && contentLength > 0 && request12.contentLength != null && request12.contentLength !== contentLength) {
23048
+ if (shouldSendContentLength(method) && contentLength > 0 && request13.contentLength != null && request13.contentLength !== contentLength) {
23049
23049
  if (client[kStrictContentLength]) {
23050
- util2.errorRequest(client, request12, new RequestContentLengthMismatchError());
23050
+ util2.errorRequest(client, request13, new RequestContentLengthMismatchError());
23051
23051
  return false;
23052
23052
  }
23053
23053
  process.emitWarning(new RequestContentLengthMismatchError());
@@ -23063,7 +23063,7 @@ var require_client_h2 = __commonJS({
23063
23063
  header += `${key}: ${headers3[key]}\r
23064
23064
  `;
23065
23065
  }
23066
- channels.sendHeaders.publish({ request: request12, headers: header, socket: session[kSocket] });
23066
+ channels.sendHeaders.publish({ request: request13, headers: header, socket: session[kSocket] });
23067
23067
  }
23068
23068
  const shouldEndStream = method === "GET" || method === "HEAD" || body === null;
23069
23069
  if (expectContinue) {
@@ -23084,21 +23084,21 @@ var require_client_h2 = __commonJS({
23084
23084
  let responseReceived = false;
23085
23085
  stream.once("response", (headers4) => {
23086
23086
  const { [HTTP2_HEADER_STATUS]: statusCode, ...realHeaders } = headers4;
23087
- request12.onResponseStarted();
23087
+ request13.onResponseStarted();
23088
23088
  responseReceived = true;
23089
23089
  stream.setTimeout(bodyTimeout);
23090
- if (request12.aborted) {
23090
+ if (request13.aborted) {
23091
23091
  stream.removeAllListeners("data");
23092
23092
  return;
23093
23093
  }
23094
- if (request12.onHeaders(Number(statusCode), parseH2Headers(realHeaders), stream.resume.bind(stream), "") === false) {
23094
+ if (request13.onHeaders(Number(statusCode), parseH2Headers(realHeaders), stream.resume.bind(stream), "") === false) {
23095
23095
  stream.pause();
23096
23096
  }
23097
23097
  stream.on("data", (chunk) => {
23098
- if (request12.aborted || request12.completed) {
23098
+ if (request13.aborted || request13.completed) {
23099
23099
  return;
23100
23100
  }
23101
- if (request12.onData(chunk) === false) {
23101
+ if (request13.onData(chunk) === false) {
23102
23102
  stream.pause();
23103
23103
  }
23104
23104
  });
@@ -23106,14 +23106,14 @@ var require_client_h2 = __commonJS({
23106
23106
  stream.once("end", () => {
23107
23107
  stream.removeAllListeners("data");
23108
23108
  if (responseReceived) {
23109
- if (!request12.aborted && !request12.completed) {
23110
- request12.onComplete({});
23109
+ if (!request13.aborted && !request13.completed) {
23110
+ request13.onComplete({});
23111
23111
  }
23112
- completeRequest(client, request12);
23112
+ completeRequest(client, request13);
23113
23113
  client[kResume]();
23114
23114
  } else {
23115
23115
  abort(new InformationalError("HTTP/2: stream half-closed (remote)"));
23116
- completeRequest(client, request12, true);
23116
+ completeRequest(client, request13, true);
23117
23117
  client[kResume]();
23118
23118
  }
23119
23119
  });
@@ -23123,7 +23123,7 @@ var require_client_h2 = __commonJS({
23123
23123
  if (session[kOpenStreams] === 0) {
23124
23124
  session.unref();
23125
23125
  }
23126
- if (!request12.aborted && !request12.completed) {
23126
+ if (!request13.aborted && !request13.completed) {
23127
23127
  abort(new InformationalError("HTTP/2: stream closed before the response was complete"));
23128
23128
  }
23129
23129
  });
@@ -23148,11 +23148,11 @@ var require_client_h2 = __commonJS({
23148
23148
  abort(err);
23149
23149
  });
23150
23150
  stream.once("trailers", (trailers) => {
23151
- if (request12.aborted || request12.completed) {
23151
+ if (request13.aborted || request13.completed) {
23152
23152
  return;
23153
23153
  }
23154
23154
  stream.removeAllListeners("data");
23155
- request12.onComplete(trailers);
23155
+ request13.onComplete(trailers);
23156
23156
  });
23157
23157
  return true;
23158
23158
  function writeBodyH2() {
@@ -23162,7 +23162,7 @@ var require_client_h2 = __commonJS({
23162
23162
  stream,
23163
23163
  null,
23164
23164
  client,
23165
- request12,
23165
+ request13,
23166
23166
  client[kSocket],
23167
23167
  contentLength,
23168
23168
  expectsPayload
@@ -23173,7 +23173,7 @@ var require_client_h2 = __commonJS({
23173
23173
  stream,
23174
23174
  body,
23175
23175
  client,
23176
- request12,
23176
+ request13,
23177
23177
  client[kSocket],
23178
23178
  contentLength,
23179
23179
  expectsPayload
@@ -23185,7 +23185,7 @@ var require_client_h2 = __commonJS({
23185
23185
  stream,
23186
23186
  body.stream(),
23187
23187
  client,
23188
- request12,
23188
+ request13,
23189
23189
  client[kSocket],
23190
23190
  contentLength,
23191
23191
  expectsPayload
@@ -23196,7 +23196,7 @@ var require_client_h2 = __commonJS({
23196
23196
  stream,
23197
23197
  body,
23198
23198
  client,
23199
- request12,
23199
+ request13,
23200
23200
  client[kSocket],
23201
23201
  contentLength,
23202
23202
  expectsPayload
@@ -23210,7 +23210,7 @@ var require_client_h2 = __commonJS({
23210
23210
  stream,
23211
23211
  body,
23212
23212
  client,
23213
- request12,
23213
+ request13,
23214
23214
  contentLength
23215
23215
  );
23216
23216
  } else if (util2.isIterable(body)) {
@@ -23219,7 +23219,7 @@ var require_client_h2 = __commonJS({
23219
23219
  stream,
23220
23220
  body,
23221
23221
  client,
23222
- request12,
23222
+ request13,
23223
23223
  client[kSocket],
23224
23224
  contentLength,
23225
23225
  expectsPayload
@@ -23229,7 +23229,7 @@ var require_client_h2 = __commonJS({
23229
23229
  }
23230
23230
  }
23231
23231
  }
23232
- function writeBuffer(abort, h2stream, body, client, request12, socket, contentLength, expectsPayload) {
23232
+ function writeBuffer(abort, h2stream, body, client, request13, socket, contentLength, expectsPayload) {
23233
23233
  try {
23234
23234
  if (body != null && util2.isBuffer(body)) {
23235
23235
  assert(contentLength === body.byteLength, "buffer body must have content length");
@@ -23237,20 +23237,20 @@ var require_client_h2 = __commonJS({
23237
23237
  h2stream.write(body);
23238
23238
  h2stream.uncork();
23239
23239
  h2stream.end();
23240
- request12.onBodySent(body);
23240
+ request13.onBodySent(body);
23241
23241
  }
23242
23242
  if (!expectsPayload) {
23243
23243
  socket[kReset] = true;
23244
23244
  }
23245
- request12.onRequestSent();
23245
+ request13.onRequestSent();
23246
23246
  client[kResume]();
23247
23247
  } catch (error) {
23248
23248
  abort(error);
23249
23249
  }
23250
23250
  }
23251
- function writeStream(abort, socket, expectsPayload, h2stream, body, client, request12, contentLength) {
23251
+ function writeStream(abort, socket, expectsPayload, h2stream, body, client, request13, contentLength) {
23252
23252
  assert(contentLength !== 0 || client[kRunning] === 0, "stream body cannot be pipelined");
23253
- const pipe = pipeline3(
23253
+ const pipe = pipeline4(
23254
23254
  body,
23255
23255
  h2stream,
23256
23256
  (err) => {
@@ -23259,7 +23259,7 @@ var require_client_h2 = __commonJS({
23259
23259
  abort(err);
23260
23260
  } else {
23261
23261
  util2.removeAllListeners(pipe);
23262
- request12.onRequestSent();
23262
+ request13.onRequestSent();
23263
23263
  if (!expectsPayload) {
23264
23264
  socket[kReset] = true;
23265
23265
  }
@@ -23269,10 +23269,10 @@ var require_client_h2 = __commonJS({
23269
23269
  );
23270
23270
  util2.addListener(pipe, "data", onPipeData);
23271
23271
  function onPipeData(chunk) {
23272
- request12.onBodySent(chunk);
23272
+ request13.onBodySent(chunk);
23273
23273
  }
23274
23274
  }
23275
- async function writeBlob(abort, h2stream, body, client, request12, socket, contentLength, expectsPayload) {
23275
+ async function writeBlob(abort, h2stream, body, client, request13, socket, contentLength, expectsPayload) {
23276
23276
  assert(contentLength === body.size, "blob body must have content length");
23277
23277
  try {
23278
23278
  if (contentLength != null && contentLength !== body.size) {
@@ -23283,8 +23283,8 @@ var require_client_h2 = __commonJS({
23283
23283
  h2stream.write(buffer);
23284
23284
  h2stream.uncork();
23285
23285
  h2stream.end();
23286
- request12.onBodySent(buffer);
23287
- request12.onRequestSent();
23286
+ request13.onBodySent(buffer);
23287
+ request13.onRequestSent();
23288
23288
  if (!expectsPayload) {
23289
23289
  socket[kReset] = true;
23290
23290
  }
@@ -23293,7 +23293,7 @@ var require_client_h2 = __commonJS({
23293
23293
  abort(err);
23294
23294
  }
23295
23295
  }
23296
- async function writeIterable(abort, h2stream, body, client, request12, socket, contentLength, expectsPayload) {
23296
+ async function writeIterable(abort, h2stream, body, client, request13, socket, contentLength, expectsPayload) {
23297
23297
  assert(contentLength !== 0 || client[kRunning] === 0, "iterator body cannot be pipelined");
23298
23298
  let callback = null;
23299
23299
  function onDrain() {
@@ -23303,12 +23303,12 @@ var require_client_h2 = __commonJS({
23303
23303
  cb();
23304
23304
  }
23305
23305
  }
23306
- const waitForDrain = () => new Promise((resolve9, reject) => {
23306
+ const waitForDrain = () => new Promise((resolve11, reject) => {
23307
23307
  assert(callback === null);
23308
23308
  if (socket[kError]) {
23309
23309
  reject(socket[kError]);
23310
23310
  } else {
23311
- callback = resolve9;
23311
+ callback = resolve11;
23312
23312
  }
23313
23313
  });
23314
23314
  h2stream.on("close", onDrain).on("drain", onDrain);
@@ -23318,13 +23318,13 @@ var require_client_h2 = __commonJS({
23318
23318
  throw socket[kError];
23319
23319
  }
23320
23320
  const res = h2stream.write(chunk);
23321
- request12.onBodySent(chunk);
23321
+ request13.onBodySent(chunk);
23322
23322
  if (!res) {
23323
23323
  await waitForDrain();
23324
23324
  }
23325
23325
  }
23326
23326
  h2stream.end();
23327
- request12.onRequestSent();
23327
+ request13.onRequestSent();
23328
23328
  if (!expectsPayload) {
23329
23329
  socket[kReset] = true;
23330
23330
  }
@@ -23609,10 +23609,10 @@ var require_client = __commonJS({
23609
23609
  this.once("connect", cb);
23610
23610
  }
23611
23611
  [kDispatch](opts, handler) {
23612
- const request12 = new Request(this[kUrl].origin, opts, handler);
23613
- this[kQueue].push(request12);
23612
+ const request13 = new Request(this[kUrl].origin, opts, handler);
23613
+ this[kQueue].push(request13);
23614
23614
  if (this[kResuming]) {
23615
- } else if (util2.bodyLength(request12.body) == null && util2.isIterable(request12.body)) {
23615
+ } else if (util2.bodyLength(request13.body) == null && util2.isIterable(request13.body)) {
23616
23616
  this[kResuming] = 1;
23617
23617
  queueMicrotask(() => resume(this));
23618
23618
  } else {
@@ -23624,21 +23624,21 @@ var require_client = __commonJS({
23624
23624
  return this[kNeedDrain] < 2;
23625
23625
  }
23626
23626
  [kClose]() {
23627
- return new Promise((resolve9) => {
23627
+ return new Promise((resolve11) => {
23628
23628
  if (this[kSize]) {
23629
- this[kClosedResolve] = resolve9;
23629
+ this[kClosedResolve] = resolve11;
23630
23630
  } else {
23631
- resolve9(null);
23631
+ resolve11(null);
23632
23632
  }
23633
23633
  });
23634
23634
  }
23635
23635
  [kDestroy](err) {
23636
- return new Promise((resolve9) => {
23636
+ return new Promise((resolve11) => {
23637
23637
  const requests = this[kQueue].splice(this[kPendingIdx]);
23638
23638
  for (let i = 0; i < requests.length; i++) {
23639
- const request12 = requests[i];
23640
- if (request12 != null) {
23641
- util2.errorRequest(this, request12, err);
23639
+ const request13 = requests[i];
23640
+ if (request13 != null) {
23641
+ util2.errorRequest(this, request13, err);
23642
23642
  }
23643
23643
  }
23644
23644
  const callback = () => {
@@ -23646,7 +23646,7 @@ var require_client = __commonJS({
23646
23646
  this[kClosedResolve]();
23647
23647
  this[kClosedResolve] = null;
23648
23648
  }
23649
- resolve9(null);
23649
+ resolve11(null);
23650
23650
  };
23651
23651
  if (this[kHTTPContext]) {
23652
23652
  this[kHTTPContext].destroy(err, callback);
@@ -23663,9 +23663,9 @@ var require_client = __commonJS({
23663
23663
  assert(client[kPendingIdx] === client[kRunningIdx]);
23664
23664
  const requests = client[kQueue].splice(client[kRunningIdx]);
23665
23665
  for (let i = 0; i < requests.length; i++) {
23666
- const request12 = requests[i];
23667
- if (request12 != null) {
23668
- util2.errorRequest(client, request12, err);
23666
+ const request13 = requests[i];
23667
+ if (request13 != null) {
23668
+ util2.errorRequest(client, request13, err);
23669
23669
  }
23670
23670
  }
23671
23671
  assert(client[kSize] === 0);
@@ -23776,8 +23776,8 @@ var require_client = __commonJS({
23776
23776
  if (err.code === "ERR_TLS_CERT_ALTNAME_INVALID") {
23777
23777
  assert(client[kRunning] === 0);
23778
23778
  while (client[kPending] > 0 && client[kQueue][client[kPendingIdx]].servername === client[kServerName]) {
23779
- const request12 = client[kQueue][client[kPendingIdx]++];
23780
- util2.errorRequest(client, request12, err);
23779
+ const request13 = client[kQueue][client[kPendingIdx]++];
23780
+ util2.errorRequest(client, request13, err);
23781
23781
  }
23782
23782
  } else {
23783
23783
  onError(client, err);
@@ -23832,15 +23832,15 @@ var require_client = __commonJS({
23832
23832
  if (client[kRunning] >= (getPipelining(client) || 1)) {
23833
23833
  return;
23834
23834
  }
23835
- const request12 = client[kQueue][client[kPendingIdx]];
23836
- if (request12 === null) {
23835
+ const request13 = client[kQueue][client[kPendingIdx]];
23836
+ if (request13 === null) {
23837
23837
  return;
23838
23838
  }
23839
- if (client[kUrl].protocol === "https:" && client[kServerName] !== request12.servername) {
23839
+ if (client[kUrl].protocol === "https:" && client[kServerName] !== request13.servername) {
23840
23840
  if (client[kRunning] > 0) {
23841
23841
  return;
23842
23842
  }
23843
- client[kServerName] = request12.servername;
23843
+ client[kServerName] = request13.servername;
23844
23844
  client[kHTTPContext]?.destroy(new InformationalError("servername changed"), () => {
23845
23845
  client[kHTTPContext] = null;
23846
23846
  resume(client);
@@ -23856,10 +23856,10 @@ var require_client = __commonJS({
23856
23856
  if (client[kHTTPContext].destroyed) {
23857
23857
  return;
23858
23858
  }
23859
- if (client[kHTTPContext].busy(request12)) {
23859
+ if (client[kHTTPContext].busy(request13)) {
23860
23860
  return;
23861
23861
  }
23862
- if (!request12.aborted && client[kHTTPContext].write(request12)) {
23862
+ if (!request13.aborted && client[kHTTPContext].write(request13)) {
23863
23863
  client[kPendingIdx]++;
23864
23864
  } else {
23865
23865
  client[kQueue].splice(client[kPendingIdx], 1);
@@ -24053,8 +24053,8 @@ var require_pool_base = __commonJS({
24053
24053
  }
24054
24054
  return Promise.all(closeAll);
24055
24055
  } else {
24056
- return new Promise((resolve9) => {
24057
- this[kClosedResolve] = resolve9;
24056
+ return new Promise((resolve11) => {
24057
+ this[kClosedResolve] = resolve11;
24058
24058
  });
24059
24059
  }
24060
24060
  }
@@ -24911,13 +24911,13 @@ var require_socks5_client = __commonJS({
24911
24911
  }
24912
24912
  debug("starting handshake with", this.authMethods.length, "auth methods");
24913
24913
  this.state = STATES.HANDSHAKING;
24914
- const request12 = Buffer2.alloc(2 + this.authMethods.length);
24915
- request12[0] = SOCKS_VERSION;
24916
- request12[1] = this.authMethods.length;
24914
+ const request13 = Buffer2.alloc(2 + this.authMethods.length);
24915
+ request13[0] = SOCKS_VERSION;
24916
+ request13[1] = this.authMethods.length;
24917
24917
  this.authMethods.forEach((method, i) => {
24918
- request12[2 + i] = method;
24918
+ request13[2 + i] = method;
24919
24919
  });
24920
- this.socket.write(request12);
24920
+ this.socket.write(request13);
24921
24921
  }
24922
24922
  /**
24923
24923
  * Handle handshake response from server
@@ -24959,13 +24959,13 @@ var require_socks5_client = __commonJS({
24959
24959
  if (usernameBuffer.length > 255 || passwordBuffer.length > 255) {
24960
24960
  throw new InvalidArgumentError2("Username or password too long");
24961
24961
  }
24962
- const request12 = Buffer2.alloc(3 + usernameBuffer.length + passwordBuffer.length);
24963
- request12[0] = 1;
24964
- request12[1] = usernameBuffer.length;
24965
- usernameBuffer.copy(request12, 2);
24966
- request12[2 + usernameBuffer.length] = passwordBuffer.length;
24967
- passwordBuffer.copy(request12, 3 + usernameBuffer.length);
24968
- this.socket.write(request12);
24962
+ const request13 = Buffer2.alloc(3 + usernameBuffer.length + passwordBuffer.length);
24963
+ request13[0] = 1;
24964
+ request13[1] = usernameBuffer.length;
24965
+ usernameBuffer.copy(request13, 2);
24966
+ request13[2 + usernameBuffer.length] = passwordBuffer.length;
24967
+ passwordBuffer.copy(request13, 3 + usernameBuffer.length);
24968
+ this.socket.write(request13);
24969
24969
  }
24970
24970
  /**
24971
24971
  * Handle authentication response
@@ -25000,22 +25000,22 @@ var require_socks5_client = __commonJS({
25000
25000
  }
25001
25001
  debug("connecting to", address, port);
25002
25002
  this.state = STATES.CONNECTING;
25003
- const request12 = this.buildConnectRequest(COMMANDS.CONNECT, address, port);
25004
- this.socket.write(request12);
25003
+ const request13 = this.buildConnectRequest(COMMANDS.CONNECT, address, port);
25004
+ this.socket.write(request13);
25005
25005
  }
25006
25006
  /**
25007
25007
  * Build a SOCKS5 request
25008
25008
  */
25009
25009
  buildConnectRequest(command, address, port) {
25010
25010
  const { type: addressType, buffer: addressBuffer } = parseAddress(address);
25011
- const request12 = Buffer2.alloc(4 + addressBuffer.length + 2);
25012
- request12[0] = SOCKS_VERSION;
25013
- request12[1] = command;
25014
- request12[2] = 0;
25015
- request12[3] = addressType;
25016
- addressBuffer.copy(request12, 4);
25017
- request12.writeUInt16BE(port, 4 + addressBuffer.length);
25018
- return request12;
25011
+ const request13 = Buffer2.alloc(4 + addressBuffer.length + 2);
25012
+ request13[0] = SOCKS_VERSION;
25013
+ request13[1] = command;
25014
+ request13[2] = 0;
25015
+ request13[3] = addressType;
25016
+ addressBuffer.copy(request13, 4);
25017
+ request13.writeUInt16BE(port, 4 + addressBuffer.length);
25018
+ return request13;
25019
25019
  }
25020
25020
  /**
25021
25021
  * Handle CONNECT response
@@ -25173,7 +25173,7 @@ var require_socks5_proxy_agent = __commonJS({
25173
25173
  const proxyHost = this[kProxyUrl].hostname;
25174
25174
  const proxyPort = parseInt(this[kProxyUrl].port) || 1080;
25175
25175
  debug("creating SOCKS5 connection to", proxyHost, proxyPort);
25176
- const socket = await new Promise((resolve9, reject) => {
25176
+ const socket = await new Promise((resolve11, reject) => {
25177
25177
  this[kConnector]({
25178
25178
  hostname: proxyHost,
25179
25179
  host: proxyHost,
@@ -25183,7 +25183,7 @@ var require_socks5_proxy_agent = __commonJS({
25183
25183
  if (err) {
25184
25184
  reject(err);
25185
25185
  } else {
25186
- resolve9(socket2);
25186
+ resolve11(socket2);
25187
25187
  }
25188
25188
  });
25189
25189
  });
@@ -25193,41 +25193,41 @@ var require_socks5_proxy_agent = __commonJS({
25193
25193
  socket.destroy();
25194
25194
  });
25195
25195
  await socks5Client.handshake();
25196
- await new Promise((resolve9, reject) => {
25197
- const timeout = setTimeout(() => {
25196
+ await new Promise((resolve11, reject) => {
25197
+ const timeout2 = setTimeout(() => {
25198
25198
  reject(new Error("SOCKS5 authentication timeout"));
25199
25199
  }, 5e3);
25200
25200
  const onAuthenticated = () => {
25201
- clearTimeout(timeout);
25201
+ clearTimeout(timeout2);
25202
25202
  socks5Client.removeListener("error", onError);
25203
- resolve9();
25203
+ resolve11();
25204
25204
  };
25205
25205
  const onError = (err) => {
25206
- clearTimeout(timeout);
25206
+ clearTimeout(timeout2);
25207
25207
  socks5Client.removeListener("authenticated", onAuthenticated);
25208
25208
  reject(err);
25209
25209
  };
25210
25210
  if (socks5Client.state === STATES.AUTHENTICATED) {
25211
- clearTimeout(timeout);
25212
- resolve9();
25211
+ clearTimeout(timeout2);
25212
+ resolve11();
25213
25213
  } else {
25214
25214
  socks5Client.once("authenticated", onAuthenticated);
25215
25215
  socks5Client.once("error", onError);
25216
25216
  }
25217
25217
  });
25218
25218
  await socks5Client.connect(targetHost, targetPort);
25219
- await new Promise((resolve9, reject) => {
25220
- const timeout = setTimeout(() => {
25219
+ await new Promise((resolve11, reject) => {
25220
+ const timeout2 = setTimeout(() => {
25221
25221
  reject(new Error("SOCKS5 connection timeout"));
25222
25222
  }, 5e3);
25223
25223
  const onConnected = (info) => {
25224
25224
  debug("SOCKS5 tunnel established to", targetHost, targetPort, "via", info);
25225
- clearTimeout(timeout);
25225
+ clearTimeout(timeout2);
25226
25226
  socks5Client.removeListener("error", onError);
25227
- resolve9();
25227
+ resolve11();
25228
25228
  };
25229
25229
  const onError = (err) => {
25230
- clearTimeout(timeout);
25230
+ clearTimeout(timeout2);
25231
25231
  socks5Client.removeListener("connected", onConnected);
25232
25232
  reject(err);
25233
25233
  };
@@ -25267,8 +25267,8 @@ var require_socks5_proxy_agent = __commonJS({
25267
25267
  socket,
25268
25268
  servername: this[kRequestTls]?.servername || targetHost
25269
25269
  });
25270
- await new Promise((resolve9, reject) => {
25271
- finalSocket.once("secureConnect", resolve9);
25270
+ await new Promise((resolve11, reject) => {
25271
+ finalSocket.once("secureConnect", resolve11);
25272
25272
  finalSocket.once("error", reject);
25273
25273
  });
25274
25274
  }
@@ -26350,7 +26350,7 @@ var require_readable = __commonJS({
26350
26350
  if (this._readableState.closeEmitted) {
26351
26351
  return Promise.resolve(null);
26352
26352
  }
26353
- return new Promise((resolve9, reject) => {
26353
+ return new Promise((resolve11, reject) => {
26354
26354
  if (this[kContentLength] && this[kContentLength] > limit || this[kBytesRead] > limit) {
26355
26355
  this.destroy(new AbortError());
26356
26356
  }
@@ -26364,11 +26364,11 @@ var require_readable = __commonJS({
26364
26364
  if (signal.aborted) {
26365
26365
  reject(signal.reason ?? new AbortError());
26366
26366
  } else {
26367
- resolve9(null);
26367
+ resolve11(null);
26368
26368
  }
26369
26369
  });
26370
26370
  } else {
26371
- this.on("close", resolve9);
26371
+ this.on("close", resolve11);
26372
26372
  }
26373
26373
  this.on("error", noop).on("data", () => {
26374
26374
  if (this[kBytesRead] > limit) {
@@ -26396,7 +26396,7 @@ var require_readable = __commonJS({
26396
26396
  }
26397
26397
  function consume(stream, type) {
26398
26398
  assert(!stream[kConsume]);
26399
- return new Promise((resolve9, reject) => {
26399
+ return new Promise((resolve11, reject) => {
26400
26400
  if (isUnusable(stream)) {
26401
26401
  const rState = stream._readableState;
26402
26402
  if (rState.destroyed && rState.closeEmitted === false) {
@@ -26411,7 +26411,7 @@ var require_readable = __commonJS({
26411
26411
  stream[kConsume] = {
26412
26412
  type,
26413
26413
  stream,
26414
- resolve: resolve9,
26414
+ resolve: resolve11,
26415
26415
  reject,
26416
26416
  length: 0,
26417
26417
  body: []
@@ -26485,18 +26485,18 @@ var require_readable = __commonJS({
26485
26485
  return buffer;
26486
26486
  }
26487
26487
  function consumeEnd(consume2, encoding) {
26488
- const { type, body, resolve: resolve9, stream, length } = consume2;
26488
+ const { type, body, resolve: resolve11, stream, length } = consume2;
26489
26489
  try {
26490
26490
  if (type === "text") {
26491
- resolve9(chunksDecode(body, length, encoding));
26491
+ resolve11(chunksDecode(body, length, encoding));
26492
26492
  } else if (type === "json") {
26493
- resolve9(JSON.parse(chunksDecode(body, length, encoding)));
26493
+ resolve11(JSON.parse(chunksDecode(body, length, encoding)));
26494
26494
  } else if (type === "arrayBuffer") {
26495
- resolve9(chunksConcat(body, length).buffer);
26495
+ resolve11(chunksConcat(body, length).buffer);
26496
26496
  } else if (type === "blob") {
26497
- resolve9(new Blob(body, { type: stream[kContentType] }));
26497
+ resolve11(new Blob(body, { type: stream[kContentType] }));
26498
26498
  } else if (type === "bytes") {
26499
- resolve9(chunksConcat(body, length));
26499
+ resolve11(chunksConcat(body, length));
26500
26500
  }
26501
26501
  consumeFinish(consume2);
26502
26502
  } catch (err) {
@@ -26684,11 +26684,11 @@ var require_api_request = __commonJS({
26684
26684
  }
26685
26685
  }
26686
26686
  };
26687
- function request12(opts, callback) {
26687
+ function request13(opts, callback) {
26688
26688
  if (callback === void 0) {
26689
- return new Promise((resolve9, reject) => {
26690
- request12.call(this, opts, (err, data) => {
26691
- return err ? reject(err) : resolve9(data);
26689
+ return new Promise((resolve11, reject) => {
26690
+ request13.call(this, opts, (err, data) => {
26691
+ return err ? reject(err) : resolve11(data);
26692
26692
  });
26693
26693
  });
26694
26694
  }
@@ -26703,7 +26703,7 @@ var require_api_request = __commonJS({
26703
26703
  queueMicrotask(() => callback(err, { opaque }));
26704
26704
  }
26705
26705
  }
26706
- module2.exports = request12;
26706
+ module2.exports = request13;
26707
26707
  module2.exports.RequestHandler = RequestHandler;
26708
26708
  }
26709
26709
  });
@@ -26900,9 +26900,9 @@ var require_api_stream = __commonJS({
26900
26900
  };
26901
26901
  function stream(opts, factory, callback) {
26902
26902
  if (callback === void 0) {
26903
- return new Promise((resolve9, reject) => {
26903
+ return new Promise((resolve11, reject) => {
26904
26904
  stream.call(this, opts, factory, (err, data) => {
26905
- return err ? reject(err) : resolve9(data);
26905
+ return err ? reject(err) : resolve11(data);
26906
26906
  });
26907
26907
  });
26908
26908
  }
@@ -27109,7 +27109,7 @@ var require_api_pipeline = __commonJS({
27109
27109
  util2.destroy(ret, err);
27110
27110
  }
27111
27111
  };
27112
- function pipeline3(opts, handler) {
27112
+ function pipeline4(opts, handler) {
27113
27113
  try {
27114
27114
  const pipelineHandler = new PipelineHandler(opts, handler);
27115
27115
  this.dispatch({ ...opts, body: pipelineHandler.req }, pipelineHandler);
@@ -27118,7 +27118,7 @@ var require_api_pipeline = __commonJS({
27118
27118
  return new PassThrough().destroy(err);
27119
27119
  }
27120
27120
  }
27121
- module2.exports = pipeline3;
27121
+ module2.exports = pipeline4;
27122
27122
  }
27123
27123
  });
27124
27124
 
@@ -27190,9 +27190,9 @@ var require_api_upgrade = __commonJS({
27190
27190
  };
27191
27191
  function upgrade(opts, callback) {
27192
27192
  if (callback === void 0) {
27193
- return new Promise((resolve9, reject) => {
27193
+ return new Promise((resolve11, reject) => {
27194
27194
  upgrade.call(this, opts, (err, data) => {
27195
- return err ? reject(err) : resolve9(data);
27195
+ return err ? reject(err) : resolve11(data);
27196
27196
  });
27197
27197
  });
27198
27198
  }
@@ -27285,9 +27285,9 @@ var require_api_connect = __commonJS({
27285
27285
  };
27286
27286
  function connect(opts, callback) {
27287
27287
  if (callback === void 0) {
27288
- return new Promise((resolve9, reject) => {
27288
+ return new Promise((resolve11, reject) => {
27289
27289
  connect.call(this, opts, (err, data) => {
27290
- return err ? reject(err) : resolve9(data);
27290
+ return err ? reject(err) : resolve11(data);
27291
27291
  });
27292
27292
  });
27293
27293
  }
@@ -28560,8 +28560,8 @@ var require_snapshot_utils = __commonJS({
28560
28560
  var require_snapshot_recorder = __commonJS({
28561
28561
  "node_modules/.pnpm/undici@7.29.1/node_modules/undici/lib/mock/snapshot-recorder.js"(exports2, module2) {
28562
28562
  "use strict";
28563
- var { writeFile: writeFile5, readFile: readFile5, mkdir: mkdir6 } = require("fs/promises");
28564
- var { dirname: dirname7, resolve: resolve9 } = require("path");
28563
+ var { writeFile: writeFile5, readFile: readFile8, mkdir: mkdir6 } = require("fs/promises");
28564
+ var { dirname: dirname8, resolve: resolve11 } = require("path");
28565
28565
  var { setTimeout: setTimeout2, clearTimeout: clearTimeout2 } = require("timers");
28566
28566
  var { InvalidArgumentError: InvalidArgumentError2, UndiciError } = require_errors();
28567
28567
  var { hashId, isUrlExcludedFactory, normalizeHeaders, createHeaderFilters } = require_snapshot_utils();
@@ -28686,8 +28686,8 @@ var require_snapshot_recorder = __commonJS({
28686
28686
  if (this.isUrlExcluded(requestOpts)) {
28687
28687
  return;
28688
28688
  }
28689
- const request12 = formatRequestKey(requestOpts, this.#headerFilters, this.matchOptions);
28690
- const hash = createRequestHash(request12);
28689
+ const request13 = formatRequestKey(requestOpts, this.#headerFilters, this.matchOptions);
28690
+ const hash = createRequestHash(request13);
28691
28691
  const normalizedHeaders = normalizeHeaders(response.headers);
28692
28692
  const responseData = {
28693
28693
  statusCode: response.statusCode,
@@ -28705,7 +28705,7 @@ var require_snapshot_recorder = __commonJS({
28705
28705
  existingSnapshot.timestamp = (/* @__PURE__ */ new Date()).toISOString();
28706
28706
  } else {
28707
28707
  this.#snapshots.set(hash, {
28708
- request: request12,
28708
+ request: request13,
28709
28709
  responses: [responseData],
28710
28710
  // Always store as array for consistency
28711
28711
  callCount: 0,
@@ -28739,8 +28739,8 @@ var require_snapshot_recorder = __commonJS({
28739
28739
  if (this.isUrlExcluded(requestOpts)) {
28740
28740
  return void 0;
28741
28741
  }
28742
- const request12 = formatRequestKey(requestOpts, this.#headerFilters, this.matchOptions);
28743
- const hash = createRequestHash(request12);
28742
+ const request13 = formatRequestKey(requestOpts, this.#headerFilters, this.matchOptions);
28743
+ const hash = createRequestHash(request13);
28744
28744
  const snapshot = this.#snapshots.get(hash);
28745
28745
  if (!snapshot) return void 0;
28746
28746
  const currentCallCount = snapshot.callCount || 0;
@@ -28762,7 +28762,7 @@ var require_snapshot_recorder = __commonJS({
28762
28762
  throw new InvalidArgumentError2("Snapshot path is required");
28763
28763
  }
28764
28764
  try {
28765
- const data = await readFile5(resolve9(path3), "utf8");
28765
+ const data = await readFile8(resolve11(path3), "utf8");
28766
28766
  const parsed = JSON.parse(data);
28767
28767
  if (Array.isArray(parsed)) {
28768
28768
  this.#snapshots.clear();
@@ -28791,8 +28791,8 @@ var require_snapshot_recorder = __commonJS({
28791
28791
  if (!path3) {
28792
28792
  throw new InvalidArgumentError2("Snapshot path is required");
28793
28793
  }
28794
- const resolvedPath = resolve9(path3);
28795
- await mkdir6(dirname7(resolvedPath), { recursive: true });
28794
+ const resolvedPath = resolve11(path3);
28795
+ await mkdir6(dirname8(resolvedPath), { recursive: true });
28796
28796
  const data = Array.from(this.#snapshots.entries()).map(([hash, snapshot]) => ({
28797
28797
  hash,
28798
28798
  snapshot
@@ -28835,8 +28835,8 @@ var require_snapshot_recorder = __commonJS({
28835
28835
  * @returns {boolean} - True if snapshot was deleted, false if not found
28836
28836
  */
28837
28837
  deleteSnapshot(requestOpts) {
28838
- const request12 = formatRequestKey(requestOpts, this.#headerFilters, this.matchOptions);
28839
- const hash = createRequestHash(request12);
28838
+ const request13 = formatRequestKey(requestOpts, this.#headerFilters, this.matchOptions);
28839
+ const hash = createRequestHash(request13);
28840
28840
  return this.#snapshots.delete(hash);
28841
28841
  }
28842
28842
  /**
@@ -28845,8 +28845,8 @@ var require_snapshot_recorder = __commonJS({
28845
28845
  * @returns {SnapshotInfo|null} - Snapshot information or null if not found
28846
28846
  */
28847
28847
  getSnapshotInfo(requestOpts) {
28848
- const request12 = formatRequestKey(requestOpts, this.#headerFilters, this.matchOptions);
28849
- const hash = createRequestHash(request12);
28848
+ const request13 = formatRequestKey(requestOpts, this.#headerFilters, this.matchOptions);
28849
+ const hash = createRequestHash(request13);
28850
28850
  const snapshot = this.#snapshots.get(hash);
28851
28851
  if (!snapshot) return null;
28852
28852
  return {
@@ -29137,16 +29137,16 @@ var require_snapshot_agent = __commonJS({
29137
29137
  */
29138
29138
  #setupMockInterceptors() {
29139
29139
  for (const snapshot of this[kSnapshotRecorder].getSnapshots()) {
29140
- const { request: request12, responses, response } = snapshot;
29141
- const url = new URL(request12.url);
29140
+ const { request: request13, responses, response } = snapshot;
29141
+ const url = new URL(request13.url);
29142
29142
  const mockPool = this.get(url.origin);
29143
29143
  const responseData = responses ? responses[0] : response;
29144
29144
  if (!responseData) continue;
29145
29145
  mockPool.intercept({
29146
29146
  path: url.pathname + url.search,
29147
- method: request12.method,
29148
- headers: request12.headers,
29149
- body: request12.body
29147
+ method: request13.method,
29148
+ headers: request13.headers,
29149
+ body: request13.body
29150
29150
  }).reply(responseData.statusCode, responseData.body, {
29151
29151
  headers: responseData.headers,
29152
29152
  trailers: responseData.trailers
@@ -29838,12 +29838,12 @@ var require_dns = __commonJS({
29838
29838
  maxItems: this.#maxItems
29839
29839
  };
29840
29840
  if (ips == null) {
29841
- this.lookup(origin, newOpts, (err, addresses) => {
29842
- if (err || addresses == null || addresses.length === 0) {
29841
+ this.lookup(origin, newOpts, (err, addresses2) => {
29842
+ if (err || addresses2 == null || addresses2.length === 0) {
29843
29843
  cb(err ?? new InformationalError("No DNS entries found"));
29844
29844
  return;
29845
29845
  }
29846
- this.setRecords(origin, addresses);
29846
+ this.setRecords(origin, addresses2);
29847
29847
  const records2 = this.storage.get(origin.hostname);
29848
29848
  const ip = this.pick(
29849
29849
  origin,
@@ -29896,12 +29896,12 @@ var require_dns = __commonJS({
29896
29896
  family: this.dualStack === false ? this.affinity : 0,
29897
29897
  order: "ipv4first"
29898
29898
  },
29899
- (err, addresses) => {
29899
+ (err, addresses2) => {
29900
29900
  if (err) {
29901
29901
  return cb(err);
29902
29902
  }
29903
29903
  const results = /* @__PURE__ */ new Map();
29904
- for (const addr of addresses) {
29904
+ for (const addr of addresses2) {
29905
29905
  results.set(`${addr.address}:${addr.family}`, addr);
29906
29906
  }
29907
29907
  cb(null, results.values());
@@ -29973,11 +29973,11 @@ var require_dns = __commonJS({
29973
29973
  }
29974
29974
  return ip;
29975
29975
  }
29976
- setRecords(origin, addresses) {
29976
+ setRecords(origin, addresses2) {
29977
29977
  const timestamp = Date.now();
29978
29978
  const records2 = { records: { 4: null, 6: null } };
29979
29979
  let minTTL = this.#maxTTL;
29980
- for (const record3 of addresses) {
29980
+ for (const record3 of addresses2) {
29981
29981
  record3.timestamp = timestamp;
29982
29982
  if (typeof record3.ttl === "number") {
29983
29983
  record3.ttl = Math.min(record3.ttl, this.#maxTTL);
@@ -32359,7 +32359,7 @@ var require_decompress = __commonJS({
32359
32359
  "node_modules/.pnpm/undici@7.29.1/node_modules/undici/lib/interceptor/decompress.js"(exports2, module2) {
32360
32360
  "use strict";
32361
32361
  var { createInflate, createGunzip, createBrotliDecompress, createZstdDecompress } = require("zlib");
32362
- var { pipeline: pipeline3, Transform: TransformStream2 } = require("stream");
32362
+ var { pipeline: pipeline4, Transform: TransformStream2 } = require("stream");
32363
32363
  var { InvalidArgumentError: InvalidArgumentError2, ResponseExceededMaxSizeError } = require_errors();
32364
32364
  var DecoratorHandler = require_decorator_handler();
32365
32365
  var { runtimeFeatures } = require_runtime_features();
@@ -32542,7 +32542,7 @@ var require_decompress = __commonJS({
32542
32542
  #setupMultipleDecompressors(controller) {
32543
32543
  const lastDecompressor = this.#decompressors[this.#decompressors.length - 1];
32544
32544
  this.#setupDecompressorEvents(lastDecompressor, controller);
32545
- pipeline3(this.#decompressors, (err) => {
32545
+ pipeline4(this.#decompressors, (err) => {
32546
32546
  if (this.#terminated) {
32547
32547
  return;
32548
32548
  }
@@ -34447,7 +34447,7 @@ var require_request2 = __commonJS({
34447
34447
  webidl.argumentLengthCheck(arguments, 1, prefix);
34448
34448
  input = webidl.converters.RequestInfo(input);
34449
34449
  init = webidl.converters.RequestInit(init);
34450
- let request12 = null;
34450
+ let request13 = null;
34451
34451
  let fallbackMode = null;
34452
34452
  const baseUrl4 = environmentSettingsObject.settingsObject.baseUrl;
34453
34453
  let signal = null;
@@ -34464,18 +34464,18 @@ var require_request2 = __commonJS({
34464
34464
  "Request cannot be constructed from a URL that includes credentials: " + input
34465
34465
  );
34466
34466
  }
34467
- request12 = makeRequest({ urlList: [parsedURL] });
34467
+ request13 = makeRequest({ urlList: [parsedURL] });
34468
34468
  fallbackMode = "cors";
34469
34469
  } else {
34470
34470
  assert(webidl.is.Request(input));
34471
- request12 = input.#state;
34471
+ request13 = input.#state;
34472
34472
  signal = input.#signal;
34473
34473
  this.#dispatcher = init.dispatcher || input.#dispatcher;
34474
34474
  }
34475
34475
  const origin = environmentSettingsObject.settingsObject.origin;
34476
34476
  let window = "client";
34477
- if (request12.window?.constructor?.name === "EnvironmentSettingsObject" && sameOrigin(request12.window, origin)) {
34478
- window = request12.window;
34477
+ if (request13.window?.constructor?.name === "EnvironmentSettingsObject" && sameOrigin(request13.window, origin)) {
34478
+ window = request13.window;
34479
34479
  }
34480
34480
  if (init.window != null) {
34481
34481
  throw new TypeError(`'window' option '${window}' must be null`);
@@ -34483,66 +34483,66 @@ var require_request2 = __commonJS({
34483
34483
  if ("window" in init) {
34484
34484
  window = "no-window";
34485
34485
  }
34486
- request12 = makeRequest({
34486
+ request13 = makeRequest({
34487
34487
  // URL request’s URL.
34488
34488
  // undici implementation note: this is set as the first item in request's urlList in makeRequest
34489
34489
  // method request’s method.
34490
- method: request12.method,
34490
+ method: request13.method,
34491
34491
  // header list A copy of request’s header list.
34492
34492
  // undici implementation note: headersList is cloned in makeRequest
34493
- headersList: request12.headersList,
34493
+ headersList: request13.headersList,
34494
34494
  // unsafe-request flag Set.
34495
- unsafeRequest: request12.unsafeRequest,
34495
+ unsafeRequest: request13.unsafeRequest,
34496
34496
  // client This’s relevant settings object.
34497
34497
  client: environmentSettingsObject.settingsObject,
34498
34498
  // window window.
34499
34499
  window,
34500
34500
  // priority request’s priority.
34501
- priority: request12.priority,
34501
+ priority: request13.priority,
34502
34502
  // origin request’s origin. The propagation of the origin is only significant for navigation requests
34503
34503
  // being handled by a service worker. In this scenario a request can have an origin that is different
34504
34504
  // from the current client.
34505
- origin: request12.origin,
34505
+ origin: request13.origin,
34506
34506
  // referrer request’s referrer.
34507
- referrer: request12.referrer,
34507
+ referrer: request13.referrer,
34508
34508
  // referrer policy request’s referrer policy.
34509
- referrerPolicy: request12.referrerPolicy,
34509
+ referrerPolicy: request13.referrerPolicy,
34510
34510
  // mode request’s mode.
34511
- mode: request12.mode,
34511
+ mode: request13.mode,
34512
34512
  // credentials mode request’s credentials mode.
34513
- credentials: request12.credentials,
34513
+ credentials: request13.credentials,
34514
34514
  // cache mode request’s cache mode.
34515
- cache: request12.cache,
34515
+ cache: request13.cache,
34516
34516
  // redirect mode request’s redirect mode.
34517
- redirect: request12.redirect,
34517
+ redirect: request13.redirect,
34518
34518
  // integrity metadata request’s integrity metadata.
34519
- integrity: request12.integrity,
34519
+ integrity: request13.integrity,
34520
34520
  // keepalive request’s keepalive.
34521
- keepalive: request12.keepalive,
34521
+ keepalive: request13.keepalive,
34522
34522
  // reload-navigation flag request’s reload-navigation flag.
34523
- reloadNavigation: request12.reloadNavigation,
34523
+ reloadNavigation: request13.reloadNavigation,
34524
34524
  // history-navigation flag request’s history-navigation flag.
34525
- historyNavigation: request12.historyNavigation,
34525
+ historyNavigation: request13.historyNavigation,
34526
34526
  // URL list A clone of request’s URL list.
34527
- urlList: [...request12.urlList]
34527
+ urlList: [...request13.urlList]
34528
34528
  });
34529
34529
  const initHasKey = Object.keys(init).length !== 0;
34530
34530
  if (initHasKey) {
34531
- if (request12.mode === "navigate") {
34532
- request12.mode = "same-origin";
34531
+ if (request13.mode === "navigate") {
34532
+ request13.mode = "same-origin";
34533
34533
  }
34534
- request12.reloadNavigation = false;
34535
- request12.historyNavigation = false;
34536
- request12.origin = "client";
34537
- request12.referrer = "client";
34538
- request12.referrerPolicy = "";
34539
- request12.url = request12.urlList[request12.urlList.length - 1];
34540
- request12.urlList = [request12.url];
34534
+ request13.reloadNavigation = false;
34535
+ request13.historyNavigation = false;
34536
+ request13.origin = "client";
34537
+ request13.referrer = "client";
34538
+ request13.referrerPolicy = "";
34539
+ request13.url = request13.urlList[request13.urlList.length - 1];
34540
+ request13.urlList = [request13.url];
34541
34541
  }
34542
34542
  if (init.referrer !== void 0) {
34543
34543
  const referrer = init.referrer;
34544
34544
  if (referrer === "") {
34545
- request12.referrer = "no-referrer";
34545
+ request13.referrer = "no-referrer";
34546
34546
  } else {
34547
34547
  let parsedReferrer;
34548
34548
  try {
@@ -34551,14 +34551,14 @@ var require_request2 = __commonJS({
34551
34551
  throw new TypeError(`Referrer "${referrer}" is not a valid URL.`, { cause: err });
34552
34552
  }
34553
34553
  if (parsedReferrer.protocol === "about:" && parsedReferrer.hostname === "client" || origin && !sameOrigin(parsedReferrer, environmentSettingsObject.settingsObject.baseUrl)) {
34554
- request12.referrer = "client";
34554
+ request13.referrer = "client";
34555
34555
  } else {
34556
- request12.referrer = parsedReferrer;
34556
+ request13.referrer = parsedReferrer;
34557
34557
  }
34558
34558
  }
34559
34559
  }
34560
34560
  if (init.referrerPolicy !== void 0) {
34561
- request12.referrerPolicy = init.referrerPolicy;
34561
+ request13.referrerPolicy = init.referrerPolicy;
34562
34562
  }
34563
34563
  let mode;
34564
34564
  if (init.mode !== void 0) {
@@ -34573,33 +34573,33 @@ var require_request2 = __commonJS({
34573
34573
  });
34574
34574
  }
34575
34575
  if (mode != null) {
34576
- request12.mode = mode;
34576
+ request13.mode = mode;
34577
34577
  }
34578
34578
  if (init.credentials !== void 0) {
34579
- request12.credentials = init.credentials;
34579
+ request13.credentials = init.credentials;
34580
34580
  }
34581
34581
  if (init.cache !== void 0) {
34582
- request12.cache = init.cache;
34582
+ request13.cache = init.cache;
34583
34583
  }
34584
- if (request12.cache === "only-if-cached" && request12.mode !== "same-origin") {
34584
+ if (request13.cache === "only-if-cached" && request13.mode !== "same-origin") {
34585
34585
  throw new TypeError(
34586
34586
  "'only-if-cached' can be set only with 'same-origin' mode"
34587
34587
  );
34588
34588
  }
34589
34589
  if (init.redirect !== void 0) {
34590
- request12.redirect = init.redirect;
34590
+ request13.redirect = init.redirect;
34591
34591
  }
34592
34592
  if (init.integrity != null) {
34593
- request12.integrity = String(init.integrity);
34593
+ request13.integrity = String(init.integrity);
34594
34594
  }
34595
34595
  if (init.keepalive !== void 0) {
34596
- request12.keepalive = Boolean(init.keepalive);
34596
+ request13.keepalive = Boolean(init.keepalive);
34597
34597
  }
34598
34598
  if (init.method !== void 0) {
34599
34599
  let method = init.method;
34600
34600
  const mayBeNormalized = normalizedMethodRecords[method];
34601
34601
  if (mayBeNormalized !== void 0) {
34602
- request12.method = mayBeNormalized;
34602
+ request13.method = mayBeNormalized;
34603
34603
  } else {
34604
34604
  if (!isValidHTTPToken(method)) {
34605
34605
  throw new TypeError(`'${method}' is not a valid HTTP method.`);
@@ -34609,9 +34609,9 @@ var require_request2 = __commonJS({
34609
34609
  throw new TypeError(`'${method}' HTTP method is unsupported.`);
34610
34610
  }
34611
34611
  method = normalizedMethodRecordsBase[upperCase] ?? method;
34612
- request12.method = method;
34612
+ request13.method = method;
34613
34613
  }
34614
- if (!patchMethodWarning && request12.method === "patch") {
34614
+ if (!patchMethodWarning && request13.method === "patch") {
34615
34615
  process.emitWarning("Using `patch` is highly likely to result in a `405 Method Not Allowed`. `PATCH` is much more likely to succeed.", {
34616
34616
  code: "UNDICI-FETCH-patch"
34617
34617
  });
@@ -34621,7 +34621,7 @@ var require_request2 = __commonJS({
34621
34621
  if (init.signal !== void 0) {
34622
34622
  signal = init.signal;
34623
34623
  }
34624
- this.#state = request12;
34624
+ this.#state = request13;
34625
34625
  const ac = new AbortController();
34626
34626
  this.#signal = ac.signal;
34627
34627
  if (signal != null) {
@@ -34639,12 +34639,12 @@ var require_request2 = __commonJS({
34639
34639
  }
34640
34640
  }
34641
34641
  this.#headers = new Headers(kConstruct);
34642
- setHeadersList(this.#headers, request12.headersList);
34642
+ setHeadersList(this.#headers, request13.headersList);
34643
34643
  setHeadersGuard(this.#headers, "request");
34644
34644
  if (mode === "no-cors") {
34645
- if (!corsSafeListedMethodsSet.has(request12.method)) {
34645
+ if (!corsSafeListedMethodsSet.has(request13.method)) {
34646
34646
  throw new TypeError(
34647
- `'${request12.method} is unsupported in no-cors mode.`
34647
+ `'${request13.method} is unsupported in no-cors mode.`
34648
34648
  );
34649
34649
  }
34650
34650
  setHeadersGuard(this.#headers, "request-no-cors");
@@ -34663,14 +34663,14 @@ var require_request2 = __commonJS({
34663
34663
  }
34664
34664
  }
34665
34665
  const inputBody = webidl.is.Request(input) ? input.#state.body : null;
34666
- if ((init.body != null || inputBody != null) && (request12.method === "GET" || request12.method === "HEAD")) {
34666
+ if ((init.body != null || inputBody != null) && (request13.method === "GET" || request13.method === "HEAD")) {
34667
34667
  throw new TypeError("Request with GET/HEAD method cannot have body.");
34668
34668
  }
34669
34669
  let initBody = null;
34670
34670
  if (init.body != null) {
34671
34671
  const [extractedBody, contentType] = extractBody(
34672
34672
  init.body,
34673
- request12.keepalive
34673
+ request13.keepalive
34674
34674
  );
34675
34675
  initBody = extractedBody;
34676
34676
  if (contentType && !getHeadersList(this.#headers).contains("content-type", true)) {
@@ -34682,12 +34682,12 @@ var require_request2 = __commonJS({
34682
34682
  if (initBody != null && init.duplex == null) {
34683
34683
  throw new TypeError("RequestInit: duplex option is required when sending a body.");
34684
34684
  }
34685
- if (request12.mode !== "same-origin" && request12.mode !== "cors") {
34685
+ if (request13.mode !== "same-origin" && request13.mode !== "cors") {
34686
34686
  throw new TypeError(
34687
34687
  'If request is made from ReadableStream, mode should be "same-origin" or "cors"'
34688
34688
  );
34689
34689
  }
34690
- request12.useCORSPreflightFlag = true;
34690
+ request13.useCORSPreflightFlag = true;
34691
34691
  }
34692
34692
  let finalBody = inputOrInitBody;
34693
34693
  if (initBody == null && inputBody != null) {
@@ -34877,42 +34877,42 @@ var require_request2 = __commonJS({
34877
34877
  * @param {Request} request
34878
34878
  * @param {AbortSignal} newSignal
34879
34879
  */
34880
- static setRequestSignal(request12, newSignal) {
34881
- request12.#signal = newSignal;
34882
- return request12;
34880
+ static setRequestSignal(request13, newSignal) {
34881
+ request13.#signal = newSignal;
34882
+ return request13;
34883
34883
  }
34884
34884
  /**
34885
34885
  * @param {Request} request
34886
34886
  */
34887
- static getRequestDispatcher(request12) {
34888
- return request12.#dispatcher;
34887
+ static getRequestDispatcher(request13) {
34888
+ return request13.#dispatcher;
34889
34889
  }
34890
34890
  /**
34891
34891
  * @param {Request} request
34892
34892
  * @param {import('../../dispatcher/dispatcher')} newDispatcher
34893
34893
  */
34894
- static setRequestDispatcher(request12, newDispatcher) {
34895
- request12.#dispatcher = newDispatcher;
34894
+ static setRequestDispatcher(request13, newDispatcher) {
34895
+ request13.#dispatcher = newDispatcher;
34896
34896
  }
34897
34897
  /**
34898
34898
  * @param {Request} request
34899
34899
  * @param {Headers} newHeaders
34900
34900
  */
34901
- static setRequestHeaders(request12, newHeaders) {
34902
- request12.#headers = newHeaders;
34901
+ static setRequestHeaders(request13, newHeaders) {
34902
+ request13.#headers = newHeaders;
34903
34903
  }
34904
34904
  /**
34905
34905
  * @param {Request} request
34906
34906
  */
34907
- static getRequestState(request12) {
34908
- return request12.#state;
34907
+ static getRequestState(request13) {
34908
+ return request13.#state;
34909
34909
  }
34910
34910
  /**
34911
34911
  * @param {Request} request
34912
34912
  * @param {any} newState
34913
34913
  */
34914
- static setRequestState(request12, newState) {
34915
- request12.#state = newState;
34914
+ static setRequestState(request13, newState) {
34915
+ request13.#state = newState;
34916
34916
  }
34917
34917
  };
34918
34918
  var { setRequestSignal, getRequestDispatcher, setRequestDispatcher, setRequestHeaders, getRequestState, setRequestState } = Request;
@@ -34967,23 +34967,23 @@ var require_request2 = __commonJS({
34967
34967
  headersList: init.headersList ? new HeadersList(init.headersList) : new HeadersList()
34968
34968
  };
34969
34969
  }
34970
- function cloneRequest(request12) {
34971
- const newRequest = makeRequest({ ...request12, body: null });
34972
- if (request12.body != null) {
34973
- newRequest.body = cloneBody(request12.body);
34970
+ function cloneRequest(request13) {
34971
+ const newRequest = makeRequest({ ...request13, body: null });
34972
+ if (request13.body != null) {
34973
+ newRequest.body = cloneBody(request13.body);
34974
34974
  }
34975
34975
  return newRequest;
34976
34976
  }
34977
34977
  function fromInnerRequest(innerRequest, dispatcher, signal, guard) {
34978
- const request12 = new Request(kConstruct);
34979
- setRequestState(request12, innerRequest);
34980
- setRequestDispatcher(request12, dispatcher);
34981
- setRequestSignal(request12, signal);
34978
+ const request13 = new Request(kConstruct);
34979
+ setRequestState(request13, innerRequest);
34980
+ setRequestDispatcher(request13, dispatcher);
34981
+ setRequestSignal(request13, signal);
34982
34982
  const headers3 = new Headers(kConstruct);
34983
- setRequestHeaders(request12, headers3);
34983
+ setRequestHeaders(request13, headers3);
34984
34984
  setHeadersList(headers3, innerRequest.headersList);
34985
34985
  setHeadersGuard(headers3, guard);
34986
- return request12;
34986
+ return request13;
34987
34987
  }
34988
34988
  Object.defineProperties(Request.prototype, {
34989
34989
  method: kEnumerableProperty,
@@ -35318,7 +35318,7 @@ var require_fetch = __commonJS({
35318
35318
  subresourceSet
35319
35319
  } = require_constants3();
35320
35320
  var EE = require("events");
35321
- var { Readable, pipeline: pipeline3, finished, isErrored, isReadable } = require("stream");
35321
+ var { Readable, pipeline: pipeline4, finished, isErrored, isReadable } = require("stream");
35322
35322
  var { addAbortListener, bufferToLowerCasedHeaderName } = require_util();
35323
35323
  var { dataURLProcessor, serializeAMimeType, minimizeSupportedMimeType } = require_data_url();
35324
35324
  var { getGlobalDispatcher } = require_global2();
@@ -35365,7 +35365,7 @@ var require_fetch = __commonJS({
35365
35365
  function handleFetchDone(response) {
35366
35366
  finalizeAndReportTiming(response, "fetch");
35367
35367
  }
35368
- function fetch(input, init = void 0) {
35368
+ function fetch2(input, init = void 0) {
35369
35369
  webidl.argumentLengthCheck(arguments, 1, "globalThis.fetch");
35370
35370
  let p = createDeferredPromise();
35371
35371
  let requestObject;
@@ -35375,14 +35375,14 @@ var require_fetch = __commonJS({
35375
35375
  p.reject(e);
35376
35376
  return p.promise;
35377
35377
  }
35378
- const request12 = getRequestState(requestObject);
35378
+ const request13 = getRequestState(requestObject);
35379
35379
  if (requestObject.signal.aborted) {
35380
- abortFetch(p, request12, null, requestObject.signal.reason, null);
35380
+ abortFetch(p, request13, null, requestObject.signal.reason, null);
35381
35381
  return p.promise;
35382
35382
  }
35383
- const globalObject = request12.client.globalObject;
35383
+ const globalObject = request13.client.globalObject;
35384
35384
  if (globalObject?.constructor?.name === "ServiceWorkerGlobalScope") {
35385
- request12.serviceWorkers = "none";
35385
+ request13.serviceWorkers = "none";
35386
35386
  }
35387
35387
  let responseObject = null;
35388
35388
  let locallyAborted = false;
@@ -35394,7 +35394,7 @@ var require_fetch = __commonJS({
35394
35394
  assert(controller != null);
35395
35395
  controller.abort(requestObject.signal.reason);
35396
35396
  const realResponse = responseObject?.deref();
35397
- abortFetch(p, request12, realResponse, requestObject.signal.reason, controller.controller);
35397
+ abortFetch(p, request13, realResponse, requestObject.signal.reason, controller.controller);
35398
35398
  }
35399
35399
  );
35400
35400
  const processResponse = (response) => {
@@ -35402,7 +35402,7 @@ var require_fetch = __commonJS({
35402
35402
  return;
35403
35403
  }
35404
35404
  if (response.aborted) {
35405
- abortFetch(p, request12, responseObject, controller.serializedAbortReason, controller.controller);
35405
+ abortFetch(p, request13, responseObject, controller.serializedAbortReason, controller.controller);
35406
35406
  return;
35407
35407
  }
35408
35408
  if (response.type === "error") {
@@ -35414,7 +35414,7 @@ var require_fetch = __commonJS({
35414
35414
  p = null;
35415
35415
  };
35416
35416
  controller = fetching({
35417
- request: request12,
35417
+ request: request13,
35418
35418
  processResponseEndOfBody: handleFetchDone,
35419
35419
  processResponse,
35420
35420
  dispatcher: getRequestDispatcher(requestObject),
@@ -35461,12 +35461,12 @@ var require_fetch = __commonJS({
35461
35461
  );
35462
35462
  }
35463
35463
  var markResourceTiming = performance.markResourceTiming;
35464
- function abortFetch(p, request12, responseObject, error, controller) {
35464
+ function abortFetch(p, request13, responseObject, error, controller) {
35465
35465
  if (p) {
35466
35466
  p.reject(error);
35467
35467
  }
35468
- if (request12.body?.stream != null && isReadable(request12.body.stream)) {
35469
- request12.body.stream.cancel(error).catch((err) => {
35468
+ if (request13.body?.stream != null && isReadable(request13.body.stream)) {
35469
+ request13.body.stream.cancel(error).catch((err) => {
35470
35470
  if (err.code === "ERR_INVALID_STATE") {
35471
35471
  return;
35472
35472
  }
@@ -35482,7 +35482,7 @@ var require_fetch = __commonJS({
35482
35482
  }
35483
35483
  }
35484
35484
  function fetching({
35485
- request: request12,
35485
+ request: request13,
35486
35486
  processRequestBodyChunkLength,
35487
35487
  processRequestEndOfBody,
35488
35488
  processResponse,
@@ -35497,9 +35497,9 @@ var require_fetch = __commonJS({
35497
35497
  assert(dispatcher);
35498
35498
  let taskDestination = null;
35499
35499
  let crossOriginIsolatedCapability = false;
35500
- if (request12.client != null) {
35501
- taskDestination = request12.client.globalObject;
35502
- crossOriginIsolatedCapability = request12.client.crossOriginIsolatedCapability;
35500
+ if (request13.client != null) {
35501
+ taskDestination = request13.client.globalObject;
35502
+ crossOriginIsolatedCapability = request13.client.crossOriginIsolatedCapability;
35503
35503
  }
35504
35504
  const currentTime = coarsenedSharedCurrentTime(crossOriginIsolatedCapability);
35505
35505
  const timingInfo = createOpaqueTimingInfo({
@@ -35507,7 +35507,7 @@ var require_fetch = __commonJS({
35507
35507
  });
35508
35508
  const fetchParams = {
35509
35509
  controller: new Fetch(dispatcher),
35510
- request: request12,
35510
+ request: request13,
35511
35511
  timingInfo,
35512
35512
  processRequestBodyChunkLength,
35513
35513
  processRequestEndOfBody,
@@ -35519,79 +35519,79 @@ var require_fetch = __commonJS({
35519
35519
  // Keep requestObject alive to prevent its AbortController from being GC'd
35520
35520
  requestObject
35521
35521
  };
35522
- assert(!request12.body || request12.body.stream);
35523
- if (request12.window === "client") {
35524
- request12.window = request12.client?.globalObject?.constructor?.name === "Window" ? request12.client : "no-window";
35522
+ assert(!request13.body || request13.body.stream);
35523
+ if (request13.window === "client") {
35524
+ request13.window = request13.client?.globalObject?.constructor?.name === "Window" ? request13.client : "no-window";
35525
35525
  }
35526
- if (request12.origin === "client") {
35527
- request12.origin = request12.client.origin;
35526
+ if (request13.origin === "client") {
35527
+ request13.origin = request13.client.origin;
35528
35528
  }
35529
- if (request12.policyContainer === "client") {
35530
- if (request12.client != null) {
35531
- request12.policyContainer = clonePolicyContainer(
35532
- request12.client.policyContainer
35529
+ if (request13.policyContainer === "client") {
35530
+ if (request13.client != null) {
35531
+ request13.policyContainer = clonePolicyContainer(
35532
+ request13.client.policyContainer
35533
35533
  );
35534
35534
  } else {
35535
- request12.policyContainer = makePolicyContainer();
35535
+ request13.policyContainer = makePolicyContainer();
35536
35536
  }
35537
35537
  }
35538
- if (!request12.headersList.contains("accept", true)) {
35538
+ if (!request13.headersList.contains("accept", true)) {
35539
35539
  const value = "*/*";
35540
- request12.headersList.append("accept", value, true);
35540
+ request13.headersList.append("accept", value, true);
35541
35541
  }
35542
- if (!request12.headersList.contains("accept-language", true)) {
35543
- request12.headersList.append("accept-language", "*", true);
35542
+ if (!request13.headersList.contains("accept-language", true)) {
35543
+ request13.headersList.append("accept-language", "*", true);
35544
35544
  }
35545
- if (request12.priority === null) {
35545
+ if (request13.priority === null) {
35546
35546
  }
35547
- if (subresourceSet.has(request12.destination)) {
35547
+ if (subresourceSet.has(request13.destination)) {
35548
35548
  }
35549
35549
  mainFetch(fetchParams, false);
35550
35550
  return fetchParams.controller;
35551
35551
  }
35552
35552
  async function mainFetch(fetchParams, recursive) {
35553
35553
  try {
35554
- const request12 = fetchParams.request;
35554
+ const request13 = fetchParams.request;
35555
35555
  let response = null;
35556
- if (request12.localURLsOnly && !urlIsLocal(requestCurrentURL(request12))) {
35556
+ if (request13.localURLsOnly && !urlIsLocal(requestCurrentURL(request13))) {
35557
35557
  response = makeNetworkError("local URLs only");
35558
35558
  }
35559
- tryUpgradeRequestToAPotentiallyTrustworthyURL(request12);
35560
- if (requestBadPort(request12) === "blocked") {
35559
+ tryUpgradeRequestToAPotentiallyTrustworthyURL(request13);
35560
+ if (requestBadPort(request13) === "blocked") {
35561
35561
  response = makeNetworkError("bad port");
35562
35562
  }
35563
- if (request12.referrerPolicy === "") {
35564
- request12.referrerPolicy = request12.policyContainer.referrerPolicy;
35563
+ if (request13.referrerPolicy === "") {
35564
+ request13.referrerPolicy = request13.policyContainer.referrerPolicy;
35565
35565
  }
35566
- if (request12.referrer !== "no-referrer") {
35567
- request12.referrer = determineRequestsReferrer(request12);
35566
+ if (request13.referrer !== "no-referrer") {
35567
+ request13.referrer = determineRequestsReferrer(request13);
35568
35568
  }
35569
35569
  if (response === null) {
35570
- const currentURL = requestCurrentURL(request12);
35570
+ const currentURL = requestCurrentURL(request13);
35571
35571
  if (
35572
35572
  // - request’s current URL’s origin is same origin with request’s origin,
35573
35573
  // and request’s response tainting is "basic"
35574
- sameOrigin(currentURL, request12.url) && request12.responseTainting === "basic" || // request’s current URL’s scheme is "data"
35574
+ sameOrigin(currentURL, request13.url) && request13.responseTainting === "basic" || // request’s current URL’s scheme is "data"
35575
35575
  currentURL.protocol === "data:" || // - request’s mode is "navigate" or "websocket"
35576
- (request12.mode === "navigate" || request12.mode === "websocket")
35576
+ (request13.mode === "navigate" || request13.mode === "websocket")
35577
35577
  ) {
35578
- request12.responseTainting = "basic";
35578
+ request13.responseTainting = "basic";
35579
35579
  response = await schemeFetch(fetchParams);
35580
- } else if (request12.mode === "same-origin") {
35580
+ } else if (request13.mode === "same-origin") {
35581
35581
  response = makeNetworkError('request mode cannot be "same-origin"');
35582
- } else if (request12.mode === "no-cors") {
35583
- if (request12.redirect !== "follow") {
35582
+ } else if (request13.mode === "no-cors") {
35583
+ if (request13.redirect !== "follow") {
35584
35584
  response = makeNetworkError(
35585
35585
  'redirect mode cannot be "follow" for "no-cors" request'
35586
35586
  );
35587
35587
  } else {
35588
- request12.responseTainting = "opaque";
35588
+ request13.responseTainting = "opaque";
35589
35589
  response = await schemeFetch(fetchParams);
35590
35590
  }
35591
- } else if (!urlIsHttpHttpsScheme(requestCurrentURL(request12))) {
35591
+ } else if (!urlIsHttpHttpsScheme(requestCurrentURL(request13))) {
35592
35592
  response = makeNetworkError("URL scheme must be a HTTP(S) scheme");
35593
35593
  } else {
35594
- request12.responseTainting = "cors";
35594
+ request13.responseTainting = "cors";
35595
35595
  response = await httpFetch(fetchParams);
35596
35596
  }
35597
35597
  }
@@ -35599,13 +35599,13 @@ var require_fetch = __commonJS({
35599
35599
  return response;
35600
35600
  }
35601
35601
  if (response.status !== 0 && !response.internalResponse) {
35602
- if (request12.responseTainting === "cors") {
35602
+ if (request13.responseTainting === "cors") {
35603
35603
  }
35604
- if (request12.responseTainting === "basic") {
35604
+ if (request13.responseTainting === "basic") {
35605
35605
  response = filterResponse(response, "basic");
35606
- } else if (request12.responseTainting === "cors") {
35606
+ } else if (request13.responseTainting === "cors") {
35607
35607
  response = filterResponse(response, "cors");
35608
- } else if (request12.responseTainting === "opaque") {
35608
+ } else if (request13.responseTainting === "opaque") {
35609
35609
  response = filterResponse(response, "opaque");
35610
35610
  } else {
35611
35611
  assert(false);
@@ -35613,26 +35613,26 @@ var require_fetch = __commonJS({
35613
35613
  }
35614
35614
  let internalResponse = response.status === 0 ? response : response.internalResponse;
35615
35615
  if (internalResponse.urlList.length === 0) {
35616
- internalResponse.urlList.push(...request12.urlList);
35616
+ internalResponse.urlList.push(...request13.urlList);
35617
35617
  }
35618
- if (!request12.timingAllowFailed) {
35618
+ if (!request13.timingAllowFailed) {
35619
35619
  response.timingAllowPassed = true;
35620
35620
  }
35621
- if (response.type === "opaque" && internalResponse.status === 206 && internalResponse.rangeRequested && !request12.headers.contains("range", true)) {
35621
+ if (response.type === "opaque" && internalResponse.status === 206 && internalResponse.rangeRequested && !request13.headers.contains("range", true)) {
35622
35622
  response = internalResponse = makeNetworkError();
35623
35623
  }
35624
- if (response.status !== 0 && (request12.method === "HEAD" || request12.method === "CONNECT" || nullBodyStatus.includes(internalResponse.status))) {
35624
+ if (response.status !== 0 && (request13.method === "HEAD" || request13.method === "CONNECT" || nullBodyStatus.includes(internalResponse.status))) {
35625
35625
  internalResponse.body = null;
35626
35626
  fetchParams.controller.dump = true;
35627
35627
  }
35628
- if (request12.integrity) {
35628
+ if (request13.integrity) {
35629
35629
  const processBodyError = (reason) => fetchFinale(fetchParams, makeNetworkError(reason));
35630
- if (request12.responseTainting === "opaque" || response.body == null) {
35630
+ if (request13.responseTainting === "opaque" || response.body == null) {
35631
35631
  processBodyError(response.error);
35632
35632
  return;
35633
35633
  }
35634
35634
  const processBody = (bytes) => {
35635
- if (!bytesMatch(bytes, request12.integrity)) {
35635
+ if (!bytesMatch(bytes, request13.integrity)) {
35636
35636
  processBodyError("integrity mismatch");
35637
35637
  return;
35638
35638
  }
@@ -35651,8 +35651,8 @@ var require_fetch = __commonJS({
35651
35651
  if (isCancelled(fetchParams) && fetchParams.request.redirectCount === 0) {
35652
35652
  return Promise.resolve(makeAppropriateNetworkError(fetchParams));
35653
35653
  }
35654
- const { request: request12 } = fetchParams;
35655
- const { protocol: scheme } = requestCurrentURL(request12);
35654
+ const { request: request13 } = fetchParams;
35655
+ const { protocol: scheme } = requestCurrentURL(request13);
35656
35656
  switch (scheme) {
35657
35657
  case "about:": {
35658
35658
  return Promise.resolve(makeNetworkError("about scheme is not supported"));
@@ -35661,19 +35661,19 @@ var require_fetch = __commonJS({
35661
35661
  if (!resolveObjectURL) {
35662
35662
  resolveObjectURL = require("buffer").resolveObjectURL;
35663
35663
  }
35664
- const blobURLEntry = requestCurrentURL(request12);
35664
+ const blobURLEntry = requestCurrentURL(request13);
35665
35665
  if (blobURLEntry.search.length !== 0) {
35666
35666
  return Promise.resolve(makeNetworkError("NetworkError when attempting to fetch resource."));
35667
35667
  }
35668
35668
  const blob = resolveObjectURL(blobURLEntry.toString());
35669
- if (request12.method !== "GET" || !webidl.is.Blob(blob)) {
35669
+ if (request13.method !== "GET" || !webidl.is.Blob(blob)) {
35670
35670
  return Promise.resolve(makeNetworkError("invalid method"));
35671
35671
  }
35672
35672
  const response = makeResponse();
35673
35673
  const fullLength = blob.size;
35674
35674
  const serializedFullLength = isomorphicEncode(`${fullLength}`);
35675
35675
  const type = blob.type;
35676
- if (!request12.headersList.contains("range", true)) {
35676
+ if (!request13.headersList.contains("range", true)) {
35677
35677
  const bodyWithType = extractBody(blob);
35678
35678
  response.statusText = "OK";
35679
35679
  response.body = bodyWithType[0];
@@ -35681,7 +35681,7 @@ var require_fetch = __commonJS({
35681
35681
  response.headersList.set("content-type", type, true);
35682
35682
  } else {
35683
35683
  response.rangeRequested = true;
35684
- const rangeHeader = request12.headersList.get("range", true);
35684
+ const rangeHeader = request13.headersList.get("range", true);
35685
35685
  const rangeValue = simpleRangeHeaderValue(rangeHeader, true);
35686
35686
  if (rangeValue === "failure") {
35687
35687
  return Promise.resolve(makeNetworkError("failed to fetch the data URL"));
@@ -35712,7 +35712,7 @@ var require_fetch = __commonJS({
35712
35712
  return Promise.resolve(response);
35713
35713
  }
35714
35714
  case "data:": {
35715
- const currentURL = requestCurrentURL(request12);
35715
+ const currentURL = requestCurrentURL(request13);
35716
35716
  const dataURLStruct = dataURLProcessor(currentURL);
35717
35717
  if (dataURLStruct === "failure") {
35718
35718
  return Promise.resolve(makeNetworkError("failed to fetch the data URL"));
@@ -35801,41 +35801,41 @@ var require_fetch = __commonJS({
35801
35801
  }
35802
35802
  }
35803
35803
  async function httpFetch(fetchParams) {
35804
- const request12 = fetchParams.request;
35804
+ const request13 = fetchParams.request;
35805
35805
  let response = null;
35806
35806
  let actualResponse = null;
35807
35807
  const timingInfo = fetchParams.timingInfo;
35808
- if (request12.serviceWorkers === "all") {
35808
+ if (request13.serviceWorkers === "all") {
35809
35809
  }
35810
35810
  if (response === null) {
35811
- if (request12.redirect === "follow") {
35812
- request12.serviceWorkers = "none";
35811
+ if (request13.redirect === "follow") {
35812
+ request13.serviceWorkers = "none";
35813
35813
  }
35814
35814
  actualResponse = response = await httpNetworkOrCacheFetch(fetchParams);
35815
- if (request12.responseTainting === "cors" && corsCheck(request12, response) === "failure") {
35815
+ if (request13.responseTainting === "cors" && corsCheck(request13, response) === "failure") {
35816
35816
  return makeNetworkError("cors failure");
35817
35817
  }
35818
- if (TAOCheck(request12, response) === "failure") {
35819
- request12.timingAllowFailed = true;
35818
+ if (TAOCheck(request13, response) === "failure") {
35819
+ request13.timingAllowFailed = true;
35820
35820
  }
35821
35821
  }
35822
- if ((request12.responseTainting === "opaque" || response.type === "opaque") && crossOriginResourcePolicyCheck(
35823
- request12.origin,
35824
- request12.client,
35825
- request12.destination,
35822
+ if ((request13.responseTainting === "opaque" || response.type === "opaque") && crossOriginResourcePolicyCheck(
35823
+ request13.origin,
35824
+ request13.client,
35825
+ request13.destination,
35826
35826
  actualResponse
35827
35827
  ) === "blocked") {
35828
35828
  return makeNetworkError("blocked");
35829
35829
  }
35830
35830
  if (redirectStatusSet.has(actualResponse.status)) {
35831
- if (request12.redirect !== "manual") {
35831
+ if (request13.redirect !== "manual") {
35832
35832
  fetchParams.controller.connection.destroy(void 0, false);
35833
35833
  }
35834
- if (request12.redirect === "error") {
35834
+ if (request13.redirect === "error") {
35835
35835
  response = makeNetworkError("unexpected redirect");
35836
- } else if (request12.redirect === "manual") {
35836
+ } else if (request13.redirect === "manual") {
35837
35837
  response = actualResponse;
35838
- } else if (request12.redirect === "follow") {
35838
+ } else if (request13.redirect === "follow") {
35839
35839
  response = await httpRedirectFetch(fetchParams, response);
35840
35840
  } else {
35841
35841
  assert(false);
@@ -35845,13 +35845,13 @@ var require_fetch = __commonJS({
35845
35845
  return response;
35846
35846
  }
35847
35847
  function httpRedirectFetch(fetchParams, response) {
35848
- const request12 = fetchParams.request;
35848
+ const request13 = fetchParams.request;
35849
35849
  const actualResponse = response.internalResponse ? response.internalResponse : response;
35850
35850
  let locationURL;
35851
35851
  try {
35852
35852
  locationURL = responseLocationURL(
35853
35853
  actualResponse,
35854
- requestCurrentURL(request12).hash
35854
+ requestCurrentURL(request13).hash
35855
35855
  );
35856
35856
  if (locationURL == null) {
35857
35857
  return response;
@@ -35862,63 +35862,63 @@ var require_fetch = __commonJS({
35862
35862
  if (!urlIsHttpHttpsScheme(locationURL)) {
35863
35863
  return Promise.resolve(makeNetworkError("URL scheme must be a HTTP(S) scheme"));
35864
35864
  }
35865
- if (request12.redirectCount === 20) {
35865
+ if (request13.redirectCount === 20) {
35866
35866
  return Promise.resolve(makeNetworkError("redirect count exceeded"));
35867
35867
  }
35868
- request12.redirectCount += 1;
35869
- if (request12.mode === "cors" && (locationURL.username || locationURL.password) && !sameOrigin(request12, locationURL)) {
35868
+ request13.redirectCount += 1;
35869
+ if (request13.mode === "cors" && (locationURL.username || locationURL.password) && !sameOrigin(request13, locationURL)) {
35870
35870
  return Promise.resolve(makeNetworkError('cross origin not allowed for request mode "cors"'));
35871
35871
  }
35872
- if (request12.responseTainting === "cors" && (locationURL.username || locationURL.password)) {
35872
+ if (request13.responseTainting === "cors" && (locationURL.username || locationURL.password)) {
35873
35873
  return Promise.resolve(makeNetworkError(
35874
35874
  'URL cannot contain credentials for request mode "cors"'
35875
35875
  ));
35876
35876
  }
35877
- if (actualResponse.status !== 303 && request12.body != null && request12.body.source == null) {
35877
+ if (actualResponse.status !== 303 && request13.body != null && request13.body.source == null) {
35878
35878
  return Promise.resolve(makeNetworkError());
35879
35879
  }
35880
- if ([301, 302].includes(actualResponse.status) && request12.method === "POST" || actualResponse.status === 303 && !GET_OR_HEAD.includes(request12.method)) {
35881
- request12.method = "GET";
35882
- request12.body = null;
35880
+ if ([301, 302].includes(actualResponse.status) && request13.method === "POST" || actualResponse.status === 303 && !GET_OR_HEAD.includes(request13.method)) {
35881
+ request13.method = "GET";
35882
+ request13.body = null;
35883
35883
  for (const headerName of requestBodyHeader) {
35884
- request12.headersList.delete(headerName);
35884
+ request13.headersList.delete(headerName);
35885
35885
  }
35886
35886
  }
35887
- if (!sameOrigin(requestCurrentURL(request12), locationURL)) {
35888
- request12.headersList.delete("authorization", true);
35889
- request12.headersList.delete("proxy-authorization", true);
35890
- request12.headersList.delete("cookie", true);
35891
- request12.headersList.delete("host", true);
35887
+ if (!sameOrigin(requestCurrentURL(request13), locationURL)) {
35888
+ request13.headersList.delete("authorization", true);
35889
+ request13.headersList.delete("proxy-authorization", true);
35890
+ request13.headersList.delete("cookie", true);
35891
+ request13.headersList.delete("host", true);
35892
35892
  }
35893
- if (request12.body != null) {
35894
- assert(request12.body.source != null);
35895
- request12.body = safelyExtractBody(request12.body.source)[0];
35893
+ if (request13.body != null) {
35894
+ assert(request13.body.source != null);
35895
+ request13.body = safelyExtractBody(request13.body.source)[0];
35896
35896
  }
35897
35897
  const timingInfo = fetchParams.timingInfo;
35898
35898
  timingInfo.redirectEndTime = timingInfo.postRedirectStartTime = coarsenedSharedCurrentTime(fetchParams.crossOriginIsolatedCapability);
35899
35899
  if (timingInfo.redirectStartTime === 0) {
35900
35900
  timingInfo.redirectStartTime = timingInfo.startTime;
35901
35901
  }
35902
- request12.urlList.push(locationURL);
35903
- setRequestReferrerPolicyOnRedirect(request12, actualResponse);
35902
+ request13.urlList.push(locationURL);
35903
+ setRequestReferrerPolicyOnRedirect(request13, actualResponse);
35904
35904
  return mainFetch(fetchParams, true);
35905
35905
  }
35906
35906
  async function httpNetworkOrCacheFetch(fetchParams, isAuthenticationFetch = false, isNewConnectionFetch = false) {
35907
- const request12 = fetchParams.request;
35907
+ const request13 = fetchParams.request;
35908
35908
  let httpFetchParams = null;
35909
35909
  let httpRequest = null;
35910
35910
  let response = null;
35911
35911
  const httpCache = null;
35912
35912
  const revalidatingFlag = false;
35913
- if (request12.window === "no-window" && request12.redirect === "error") {
35913
+ if (request13.window === "no-window" && request13.redirect === "error") {
35914
35914
  httpFetchParams = fetchParams;
35915
- httpRequest = request12;
35915
+ httpRequest = request13;
35916
35916
  } else {
35917
- httpRequest = cloneRequest(request12);
35917
+ httpRequest = cloneRequest(request13);
35918
35918
  httpFetchParams = { ...fetchParams };
35919
35919
  httpFetchParams.request = httpRequest;
35920
35920
  }
35921
- const includeCredentials = request12.credentials === "include" || request12.credentials === "same-origin" && request12.responseTainting === "basic";
35921
+ const includeCredentials = request13.credentials === "include" || request13.credentials === "same-origin" && request13.responseTainting === "basic";
35922
35922
  const contentLength = httpRequest.body ? httpRequest.body.length : null;
35923
35923
  let contentLengthHeaderValue = null;
35924
35924
  if (httpRequest.body == null && ["POST", "PUT"].includes(httpRequest.method)) {
@@ -36005,14 +36005,14 @@ var require_fetch = __commonJS({
36005
36005
  response.rangeRequested = true;
36006
36006
  }
36007
36007
  response.requestIncludesCredentials = includeCredentials;
36008
- if (response.status === 401 && httpRequest.responseTainting !== "cors" && includeCredentials && (request12.useURLCredentials !== void 0 || isTraversableNavigable(request12.traversableForUserPrompts))) {
36009
- if (request12.body != null) {
36010
- if (request12.body.source == null) {
36008
+ if (response.status === 401 && httpRequest.responseTainting !== "cors" && includeCredentials && (request13.useURLCredentials !== void 0 || isTraversableNavigable(request13.traversableForUserPrompts))) {
36009
+ if (request13.body != null) {
36010
+ if (request13.body.source == null) {
36011
36011
  return response;
36012
36012
  }
36013
- request12.body = safelyExtractBody(request12.body.source)[0];
36013
+ request13.body = safelyExtractBody(request13.body.source)[0];
36014
36014
  }
36015
- if (request12.useURLCredentials === void 0 || isAuthenticationFetch) {
36015
+ if (request13.useURLCredentials === void 0 || isAuthenticationFetch) {
36016
36016
  if (isCancelled(fetchParams)) {
36017
36017
  return makeAppropriateNetworkError(fetchParams);
36018
36018
  }
@@ -36022,7 +36022,7 @@ var require_fetch = __commonJS({
36022
36022
  response = await httpNetworkOrCacheFetch(fetchParams, true);
36023
36023
  }
36024
36024
  if (response.status === 407) {
36025
- if (request12.window === "no-window") {
36025
+ if (request13.window === "no-window") {
36026
36026
  return makeNetworkError();
36027
36027
  }
36028
36028
  if (isCancelled(fetchParams)) {
@@ -36034,7 +36034,7 @@ var require_fetch = __commonJS({
36034
36034
  // response’s status is 421
36035
36035
  response.status === 421 && // isNewConnectionFetch is false
36036
36036
  !isNewConnectionFetch && // request’s body is null, or request’s body is non-null and request’s body’s source is non-null
36037
- (request12.body == null || request12.body.source != null)
36037
+ (request13.body == null || request13.body.source != null)
36038
36038
  ) {
36039
36039
  if (isCancelled(fetchParams)) {
36040
36040
  return makeAppropriateNetworkError(fetchParams);
@@ -36064,21 +36064,21 @@ var require_fetch = __commonJS({
36064
36064
  }
36065
36065
  }
36066
36066
  };
36067
- const request12 = fetchParams.request;
36067
+ const request13 = fetchParams.request;
36068
36068
  let response = null;
36069
36069
  const timingInfo = fetchParams.timingInfo;
36070
36070
  const httpCache = null;
36071
36071
  if (httpCache == null) {
36072
- request12.cache = "no-store";
36072
+ request13.cache = "no-store";
36073
36073
  }
36074
36074
  const newConnection = forceNewConnection ? "yes" : "no";
36075
- if (request12.mode === "websocket") {
36075
+ if (request13.mode === "websocket") {
36076
36076
  } else {
36077
36077
  }
36078
36078
  let requestBody = null;
36079
- if (request12.body == null && fetchParams.processRequestEndOfBody) {
36079
+ if (request13.body == null && fetchParams.processRequestEndOfBody) {
36080
36080
  queueMicrotask(() => fetchParams.processRequestEndOfBody());
36081
- } else if (request12.body != null) {
36081
+ } else if (request13.body != null) {
36082
36082
  const processBodyChunk = async function* (bytes) {
36083
36083
  if (isCancelled(fetchParams)) {
36084
36084
  return;
@@ -36106,7 +36106,7 @@ var require_fetch = __commonJS({
36106
36106
  };
36107
36107
  requestBody = (async function* () {
36108
36108
  try {
36109
- for await (const bytes of request12.body.stream) {
36109
+ for await (const bytes of request13.body.stream) {
36110
36110
  yield* processBodyChunk(bytes);
36111
36111
  }
36112
36112
  processEndOfBody();
@@ -36213,19 +36213,19 @@ var require_fetch = __commonJS({
36213
36213
  }
36214
36214
  return response;
36215
36215
  function dispatch({ body }) {
36216
- const url = requestCurrentURL(request12);
36216
+ const url = requestCurrentURL(request13);
36217
36217
  const agent = fetchParams.controller.dispatcher;
36218
36218
  const path3 = url.pathname + url.search;
36219
36219
  const hasTrailingQuestionMark = url.search.length === 0 && url.href[url.href.length - url.hash.length - 1] === "?";
36220
- return new Promise((resolve9, reject) => agent.dispatch(
36220
+ return new Promise((resolve11, reject) => agent.dispatch(
36221
36221
  {
36222
36222
  path: hasTrailingQuestionMark ? `${path3}?` : path3,
36223
36223
  origin: url.origin,
36224
- method: request12.method,
36225
- body: agent.isMockActive ? request12.body && (request12.body.source || request12.body.stream) : body,
36226
- headers: request12.headersList.entries,
36224
+ method: request13.method,
36225
+ body: agent.isMockActive ? request13.body && (request13.body.source || request13.body.stream) : body,
36226
+ headers: request13.headersList.entries,
36227
36227
  maxRedirections: 0,
36228
- upgrade: request12.mode === "websocket" ? "websocket" : void 0
36228
+ upgrade: request13.mode === "websocket" ? "websocket" : void 0
36229
36229
  },
36230
36230
  {
36231
36231
  body: null,
@@ -36262,9 +36262,9 @@ var require_fetch = __commonJS({
36262
36262
  }
36263
36263
  const location = headersList.get("location", true);
36264
36264
  this.body = new Readable({ read: resume });
36265
- const willFollow = location && request12.redirect === "follow" && redirectStatusSet.has(status);
36265
+ const willFollow = location && request13.redirect === "follow" && redirectStatusSet.has(status);
36266
36266
  const decoders = [];
36267
- if (request12.method !== "HEAD" && request12.method !== "CONNECT" && !nullBodyStatus.includes(status) && !willFollow) {
36267
+ if (request13.method !== "HEAD" && request13.method !== "CONNECT" && !nullBodyStatus.includes(status) && !willFollow) {
36268
36268
  const contentEncoding = headersList.get("content-encoding", true);
36269
36269
  const codings = contentEncoding ? contentEncoding.toLowerCase().split(",") : [];
36270
36270
  const maxContentEncodings = 5;
@@ -36305,11 +36305,11 @@ var require_fetch = __commonJS({
36305
36305
  }
36306
36306
  }
36307
36307
  const onError = this.onError.bind(this);
36308
- resolve9({
36308
+ resolve11({
36309
36309
  status,
36310
36310
  statusText,
36311
36311
  headersList,
36312
- body: decoders.length ? pipeline3(this.body, ...decoders, (err) => {
36312
+ body: decoders.length ? pipeline4(this.body, ...decoders, (err) => {
36313
36313
  if (err) {
36314
36314
  this.onError(err);
36315
36315
  }
@@ -36358,7 +36358,7 @@ var require_fetch = __commonJS({
36358
36358
  headersList.append(headerName, String(value), true);
36359
36359
  }
36360
36360
  }
36361
- resolve9({
36361
+ resolve11({
36362
36362
  status,
36363
36363
  statusText: STATUS_CODES[status],
36364
36364
  headersList,
@@ -36382,7 +36382,7 @@ var require_fetch = __commonJS({
36382
36382
  headersList.append(nameStr, value.toString("latin1"), true);
36383
36383
  }
36384
36384
  }
36385
- resolve9({
36385
+ resolve11({
36386
36386
  status,
36387
36387
  statusText: STATUS_CODES[status],
36388
36388
  headersList,
@@ -36395,7 +36395,7 @@ var require_fetch = __commonJS({
36395
36395
  }
36396
36396
  }
36397
36397
  module2.exports = {
36398
- fetch,
36398
+ fetch: fetch2,
36399
36399
  Fetch,
36400
36400
  fetching,
36401
36401
  finalizeAndReportTiming
@@ -36460,31 +36460,31 @@ var require_cache3 = __commonJS({
36460
36460
  webidl.util.markAsUncloneable(this);
36461
36461
  this.#relevantRequestResponseList = arguments[1];
36462
36462
  }
36463
- async match(request12, options = {}) {
36463
+ async match(request13, options = {}) {
36464
36464
  webidl.brandCheck(this, _Cache);
36465
36465
  const prefix = "Cache.match";
36466
36466
  webidl.argumentLengthCheck(arguments, 1, prefix);
36467
- request12 = webidl.converters.RequestInfo(request12);
36467
+ request13 = webidl.converters.RequestInfo(request13);
36468
36468
  options = webidl.converters.CacheQueryOptions(options, prefix, "options");
36469
- const p = this.#internalMatchAll(request12, options, 1);
36469
+ const p = this.#internalMatchAll(request13, options, 1);
36470
36470
  if (p.length === 0) {
36471
36471
  return;
36472
36472
  }
36473
36473
  return p[0];
36474
36474
  }
36475
- async matchAll(request12 = void 0, options = {}) {
36475
+ async matchAll(request13 = void 0, options = {}) {
36476
36476
  webidl.brandCheck(this, _Cache);
36477
36477
  const prefix = "Cache.matchAll";
36478
- if (request12 !== void 0) request12 = webidl.converters.RequestInfo(request12);
36478
+ if (request13 !== void 0) request13 = webidl.converters.RequestInfo(request13);
36479
36479
  options = webidl.converters.CacheQueryOptions(options, prefix, "options");
36480
- return this.#internalMatchAll(request12, options);
36480
+ return this.#internalMatchAll(request13, options);
36481
36481
  }
36482
- async add(request12) {
36482
+ async add(request13) {
36483
36483
  webidl.brandCheck(this, _Cache);
36484
36484
  const prefix = "Cache.add";
36485
36485
  webidl.argumentLengthCheck(arguments, 1, prefix);
36486
- request12 = webidl.converters.RequestInfo(request12);
36487
- const requests = [request12];
36486
+ request13 = webidl.converters.RequestInfo(request13);
36487
+ const requests = [request13];
36488
36488
  const responseArrayPromise = this.addAll(requests);
36489
36489
  return await responseArrayPromise;
36490
36490
  }
@@ -36494,19 +36494,19 @@ var require_cache3 = __commonJS({
36494
36494
  webidl.argumentLengthCheck(arguments, 1, prefix);
36495
36495
  const responsePromises = [];
36496
36496
  const requestList = [];
36497
- for (let request12 of requests) {
36498
- if (request12 === void 0) {
36497
+ for (let request13 of requests) {
36498
+ if (request13 === void 0) {
36499
36499
  throw webidl.errors.conversionFailed({
36500
36500
  prefix,
36501
36501
  argument: "Argument 1",
36502
36502
  types: ["undefined is not allowed"]
36503
36503
  });
36504
36504
  }
36505
- request12 = webidl.converters.RequestInfo(request12);
36506
- if (typeof request12 === "string") {
36505
+ request13 = webidl.converters.RequestInfo(request13);
36506
+ if (typeof request13 === "string") {
36507
36507
  continue;
36508
36508
  }
36509
- const r = getRequestState(request12);
36509
+ const r = getRequestState(request13);
36510
36510
  if (!urlIsHttpHttpsScheme(r.url) || r.method !== "GET") {
36511
36511
  throw webidl.errors.exception({
36512
36512
  header: prefix,
@@ -36515,8 +36515,8 @@ var require_cache3 = __commonJS({
36515
36515
  }
36516
36516
  }
36517
36517
  const fetchControllers = [];
36518
- for (const request12 of requests) {
36519
- const r = getRequestState(new Request(request12));
36518
+ for (const request13 of requests) {
36519
+ const r = getRequestState(new Request(request13));
36520
36520
  if (!urlIsHttpHttpsScheme(r.url)) {
36521
36521
  throw webidl.errors.exception({
36522
36522
  header: prefix,
@@ -36593,17 +36593,17 @@ var require_cache3 = __commonJS({
36593
36593
  });
36594
36594
  return cacheJobPromise.promise;
36595
36595
  }
36596
- async put(request12, response) {
36596
+ async put(request13, response) {
36597
36597
  webidl.brandCheck(this, _Cache);
36598
36598
  const prefix = "Cache.put";
36599
36599
  webidl.argumentLengthCheck(arguments, 2, prefix);
36600
- request12 = webidl.converters.RequestInfo(request12);
36600
+ request13 = webidl.converters.RequestInfo(request13);
36601
36601
  response = webidl.converters.Response(response, prefix, "response");
36602
36602
  let innerRequest = null;
36603
- if (webidl.is.Request(request12)) {
36604
- innerRequest = getRequestState(request12);
36603
+ if (webidl.is.Request(request13)) {
36604
+ innerRequest = getRequestState(request13);
36605
36605
  } else {
36606
- innerRequest = getRequestState(new Request(request12));
36606
+ innerRequest = getRequestState(new Request(request13));
36607
36607
  }
36608
36608
  if (!urlIsHttpHttpsScheme(innerRequest.url) || innerRequest.method !== "GET") {
36609
36609
  throw webidl.errors.exception({
@@ -36674,21 +36674,21 @@ var require_cache3 = __commonJS({
36674
36674
  });
36675
36675
  return cacheJobPromise.promise;
36676
36676
  }
36677
- async delete(request12, options = {}) {
36677
+ async delete(request13, options = {}) {
36678
36678
  webidl.brandCheck(this, _Cache);
36679
36679
  const prefix = "Cache.delete";
36680
36680
  webidl.argumentLengthCheck(arguments, 1, prefix);
36681
- request12 = webidl.converters.RequestInfo(request12);
36681
+ request13 = webidl.converters.RequestInfo(request13);
36682
36682
  options = webidl.converters.CacheQueryOptions(options, prefix, "options");
36683
36683
  let r = null;
36684
- if (webidl.is.Request(request12)) {
36685
- r = getRequestState(request12);
36684
+ if (webidl.is.Request(request13)) {
36685
+ r = getRequestState(request13);
36686
36686
  if (r.method !== "GET" && !options.ignoreMethod) {
36687
36687
  return false;
36688
36688
  }
36689
36689
  } else {
36690
- assert(typeof request12 === "string");
36691
- r = getRequestState(new Request(request12));
36690
+ assert(typeof request13 === "string");
36691
+ r = getRequestState(new Request(request13));
36692
36692
  }
36693
36693
  const operations = [];
36694
36694
  const operation = {
@@ -36720,25 +36720,25 @@ var require_cache3 = __commonJS({
36720
36720
  * @param {import('../../../types/cache').CacheQueryOptions} options
36721
36721
  * @returns {Promise<readonly Request[]>}
36722
36722
  */
36723
- async keys(request12 = void 0, options = {}) {
36723
+ async keys(request13 = void 0, options = {}) {
36724
36724
  webidl.brandCheck(this, _Cache);
36725
36725
  const prefix = "Cache.keys";
36726
- if (request12 !== void 0) request12 = webidl.converters.RequestInfo(request12);
36726
+ if (request13 !== void 0) request13 = webidl.converters.RequestInfo(request13);
36727
36727
  options = webidl.converters.CacheQueryOptions(options, prefix, "options");
36728
36728
  let r = null;
36729
- if (request12 !== void 0) {
36730
- if (webidl.is.Request(request12)) {
36731
- r = getRequestState(request12);
36729
+ if (request13 !== void 0) {
36730
+ if (webidl.is.Request(request13)) {
36731
+ r = getRequestState(request13);
36732
36732
  if (r.method !== "GET" && !options.ignoreMethod) {
36733
36733
  return [];
36734
36734
  }
36735
- } else if (typeof request12 === "string") {
36736
- r = getRequestState(new Request(request12));
36735
+ } else if (typeof request13 === "string") {
36736
+ r = getRequestState(new Request(request13));
36737
36737
  }
36738
36738
  }
36739
36739
  const promise = createDeferredPromise();
36740
36740
  const requests = [];
36741
- if (request12 === void 0) {
36741
+ if (request13 === void 0) {
36742
36742
  for (const requestResponse of this.#relevantRequestResponseList) {
36743
36743
  requests.push(requestResponse[0]);
36744
36744
  }
@@ -36750,9 +36750,9 @@ var require_cache3 = __commonJS({
36750
36750
  }
36751
36751
  queueMicrotask(() => {
36752
36752
  const requestList = [];
36753
- for (const request13 of requests) {
36753
+ for (const request14 of requests) {
36754
36754
  const requestObject = fromInnerRequest(
36755
- request13,
36755
+ request14,
36756
36756
  void 0,
36757
36757
  new AbortController().signal,
36758
36758
  "immutable"
@@ -36871,9 +36871,9 @@ var require_cache3 = __commonJS({
36871
36871
  * @param {import('../../../types/cache').CacheQueryOptions | undefined} options
36872
36872
  * @returns {boolean}
36873
36873
  */
36874
- #requestMatchesCachedItem(requestQuery, request12, response = null, options) {
36874
+ #requestMatchesCachedItem(requestQuery, request13, response = null, options) {
36875
36875
  const queryURL = new URL(requestQuery.url);
36876
- const cachedURL = new URL(request12.url);
36876
+ const cachedURL = new URL(request13.url);
36877
36877
  if (options?.ignoreSearch) {
36878
36878
  cachedURL.search = "";
36879
36879
  queryURL.search = "";
@@ -36889,7 +36889,7 @@ var require_cache3 = __commonJS({
36889
36889
  if (fieldValue === "*") {
36890
36890
  return false;
36891
36891
  }
36892
- const requestValue = request12.headersList.get(fieldValue);
36892
+ const requestValue = request13.headersList.get(fieldValue);
36893
36893
  const queryValue = requestQuery.headersList.get(fieldValue);
36894
36894
  if (requestValue !== queryValue) {
36895
36895
  return false;
@@ -36897,20 +36897,20 @@ var require_cache3 = __commonJS({
36897
36897
  }
36898
36898
  return true;
36899
36899
  }
36900
- #internalMatchAll(request12, options, maxResponses = Infinity) {
36900
+ #internalMatchAll(request13, options, maxResponses = Infinity) {
36901
36901
  let r = null;
36902
- if (request12 !== void 0) {
36903
- if (webidl.is.Request(request12)) {
36904
- r = getRequestState(request12);
36902
+ if (request13 !== void 0) {
36903
+ if (webidl.is.Request(request13)) {
36904
+ r = getRequestState(request13);
36905
36905
  if (r.method !== "GET" && !options.ignoreMethod) {
36906
36906
  return [];
36907
36907
  }
36908
- } else if (typeof request12 === "string") {
36909
- r = getRequestState(new Request(request12));
36908
+ } else if (typeof request13 === "string") {
36909
+ r = getRequestState(new Request(request13));
36910
36910
  }
36911
36911
  }
36912
36912
  const responses = [];
36913
- if (request12 === void 0) {
36913
+ if (request13 === void 0) {
36914
36914
  for (const requestResponse of this.#relevantRequestResponseList) {
36915
36915
  responses.push(requestResponse[1]);
36916
36916
  }
@@ -37002,21 +37002,21 @@ var require_cachestorage = __commonJS({
37002
37002
  }
37003
37003
  webidl.util.markAsUncloneable(this);
37004
37004
  }
37005
- async match(request12, options = {}) {
37005
+ async match(request13, options = {}) {
37006
37006
  webidl.brandCheck(this, _CacheStorage);
37007
37007
  webidl.argumentLengthCheck(arguments, 1, "CacheStorage.match");
37008
- request12 = webidl.converters.RequestInfo(request12);
37008
+ request13 = webidl.converters.RequestInfo(request13);
37009
37009
  options = webidl.converters.MultiCacheQueryOptions(options);
37010
37010
  if (options.cacheName != null) {
37011
37011
  if (this.#caches.has(options.cacheName)) {
37012
37012
  const cacheList = this.#caches.get(options.cacheName);
37013
37013
  const cache = new Cache(kConstruct, cacheList);
37014
- return await cache.match(request12, options);
37014
+ return await cache.match(request13, options);
37015
37015
  }
37016
37016
  } else {
37017
37017
  for (const cacheList of this.#caches.values()) {
37018
37018
  const cache = new Cache(kConstruct, cacheList);
37019
- const response = await cache.match(request12, options);
37019
+ const response = await cache.match(request13, options);
37020
37020
  if (response !== void 0) {
37021
37021
  return response;
37022
37022
  }
@@ -38208,7 +38208,7 @@ var require_connection = __commonJS({
38208
38208
  function establishWebSocketConnection(url, protocols, client, handler, options) {
38209
38209
  const requestURL = url;
38210
38210
  requestURL.protocol = url.protocol === "ws:" ? "http:" : "https:";
38211
- const request12 = makeRequest({
38211
+ const request13 = makeRequest({
38212
38212
  urlList: [requestURL],
38213
38213
  client,
38214
38214
  serviceWorkers: "none",
@@ -38221,18 +38221,18 @@ var require_connection = __commonJS({
38221
38221
  });
38222
38222
  if (options.headers) {
38223
38223
  const headersList = getHeadersList(new Headers(options.headers));
38224
- request12.headersList = headersList;
38224
+ request13.headersList = headersList;
38225
38225
  }
38226
38226
  const keyValue = crypto.randomBytes(16).toString("base64");
38227
- request12.headersList.append("sec-websocket-key", keyValue, true);
38228
- request12.headersList.append("sec-websocket-version", "13", true);
38227
+ request13.headersList.append("sec-websocket-key", keyValue, true);
38228
+ request13.headersList.append("sec-websocket-version", "13", true);
38229
38229
  for (const protocol of protocols) {
38230
- request12.headersList.append("sec-websocket-protocol", protocol, true);
38230
+ request13.headersList.append("sec-websocket-protocol", protocol, true);
38231
38231
  }
38232
38232
  const permessageDeflate = "permessage-deflate; client_max_window_bits";
38233
- request12.headersList.append("sec-websocket-extensions", permessageDeflate, true);
38233
+ request13.headersList.append("sec-websocket-extensions", permessageDeflate, true);
38234
38234
  const controller = fetching({
38235
- request: request12,
38235
+ request: request13,
38236
38236
  useParallelQueue: true,
38237
38237
  dispatcher: options.dispatcher,
38238
38238
  processResponse(response) {
@@ -38279,7 +38279,7 @@ var require_connection = __commonJS({
38279
38279
  }
38280
38280
  const secProtocol = response.headersList.get("Sec-WebSocket-Protocol");
38281
38281
  if (secProtocol !== null) {
38282
- const requestProtocols = getDecodeSplit("sec-websocket-protocol", request12.headersList);
38282
+ const requestProtocols = getDecodeSplit("sec-websocket-protocol", request13.headersList);
38283
38283
  if (requestProtocols === null || !requestProtocols.includes(secProtocol)) {
38284
38284
  failWebsocketConnection(handler, 1002, "Protocol was not set in the opening handshake.");
38285
38285
  return;
@@ -40121,7 +40121,7 @@ ${value}`;
40121
40121
  var require_eventsource = __commonJS({
40122
40122
  "node_modules/.pnpm/undici@7.29.1/node_modules/undici/lib/web/eventsource/eventsource.js"(exports2, module2) {
40123
40123
  "use strict";
40124
- var { pipeline: pipeline3 } = require("stream");
40124
+ var { pipeline: pipeline4 } = require("stream");
40125
40125
  var { fetching } = require_fetch();
40126
40126
  var { makeRequest } = require_request2();
40127
40127
  var { webidl } = require_webidl();
@@ -40279,7 +40279,7 @@ var require_eventsource = __commonJS({
40279
40279
  ));
40280
40280
  }
40281
40281
  });
40282
- pipeline3(
40282
+ pipeline4(
40283
40283
  response.body.stream,
40284
40284
  eventSourceStream,
40285
40285
  (error) => {
@@ -40561,7 +40561,7 @@ var require_undici = __commonJS({
40561
40561
  err.stack = stack ? `${stack}
40562
40562
  ${captureLines}` : capture.stack;
40563
40563
  }
40564
- module2.exports.fetch = function fetch(init, options = void 0) {
40564
+ module2.exports.fetch = function fetch2(init, options = void 0) {
40565
40565
  return fetchImpl(init, options).catch((err) => {
40566
40566
  if (currentFilename) {
40567
40567
  appendFetchStackTrace(err, currentFilename);
@@ -47983,6 +47983,44 @@ var {
47983
47983
  Help
47984
47984
  } = import_index.default;
47985
47985
 
47986
+ // src/core/public-result.ts
47987
+ function publicBusinessResult(value) {
47988
+ if (Array.isArray(value)) return value.map(publicBusinessResult);
47989
+ if (!value || typeof value !== "object") return value;
47990
+ const out = {};
47991
+ for (const [key, item] of Object.entries(value)) {
47992
+ if (key === "odoo_user_id") {
47993
+ out.user_id ??= publicBusinessResult(item);
47994
+ continue;
47995
+ }
47996
+ if ((key === "database" || key === "db") && typeof item === "string" && /^odoo$/i.test(item)) continue;
47997
+ if (key === "source" && typeof item === "string" && /^odoo(?:\b|[_-])/i.test(item)) {
47998
+ out.source = "vps";
47999
+ continue;
48000
+ }
48001
+ if (key === "source" && item && typeof item === "object" && !Array.isArray(item)) {
48002
+ const { db: _db, database: _database, login: _login, base_url: _baseUrl, ...source } = item;
48003
+ out.source = publicBusinessResult(source);
48004
+ continue;
48005
+ }
48006
+ out[key] = publicBusinessResult(item);
48007
+ }
48008
+ return out;
48009
+ }
48010
+ function publicBusinessErrorMessage(value) {
48011
+ const message = String(value ?? "");
48012
+ if (!/odoo/i.test(message)) return message;
48013
+ const status = /HTTP\s+(\d{3})\b/i.exec(message)?.[0];
48014
+ const detail = status ? `\uFF08${status}\uFF09` : "";
48015
+ if (/AccessDenied|forbidden|权限|HTTP\s+403\b/i.test(message)) return `\u65E0\u6743\u8BBF\u95EE\u8BE5\u4E1A\u52A1\u6570\u636E${detail}`;
48016
+ if (/session|not authenticated|unauthorized|登录|会话|HTTP\s+401\b/i.test(message)) return `VPS \u767B\u5F55\u51ED\u8BC1\u5DF2\u5931\u6548\uFF0C\u8BF7\u901A\u8FC7\u5BBF\u4E3B\u5237\u65B0${detail}`;
48017
+ if (/RATE_LIMITED|rate.?limit|限流/i.test(message)) {
48018
+ const fields = message.match(/(?:limit_type|retry_after_seconds)=[\w]+/g) ?? [];
48019
+ return `\u4E1A\u52A1\u67E5\u8BE2\u89E6\u53D1\u9650\u6D41${detail}${fields.length ? `\uFF1A${fields.join(" ")}` : ""}`;
48020
+ }
48021
+ return `\u4E1A\u52A1\u6570\u636E\u670D\u52A1\u6682\u4E0D\u53EF\u7528${detail}`;
48022
+ }
48023
+
47986
48024
  // src/core/errors.ts
47987
48025
  var VertuError = class extends Error {
47988
48026
  exitCode;
@@ -48024,7 +48062,7 @@ var RateLimitError = class extends RemoteError {
48024
48062
  };
48025
48063
  function formatErrorForCli(err) {
48026
48064
  if (err instanceof RateLimitError) {
48027
- const lines = [err.message];
48065
+ const lines = [publicBusinessErrorMessage(err.message)];
48028
48066
  if (err.limitType) lines.push(` limit_type: ${err.limitType}`);
48029
48067
  if (err.retryAfterSeconds != null) {
48030
48068
  lines.push(` retry_after_seconds: ${err.retryAfterSeconds}`);
@@ -48035,13 +48073,14 @@ function formatErrorForCli(err) {
48035
48073
  return lines.join("\n");
48036
48074
  }
48037
48075
  if (err instanceof VertuError) {
48038
- return err.hint ? `${err.message}
48039
- hint: ${err.hint}` : err.message;
48076
+ const message = publicBusinessErrorMessage(err.message);
48077
+ return err.hint ? `${message}
48078
+ hint: ${publicBusinessErrorMessage(err.hint)}` : message;
48040
48079
  }
48041
48080
  if (err instanceof Error) {
48042
- return err.stack ?? err.message;
48081
+ return /odoo/i.test(err.message) ? publicBusinessErrorMessage(err.message) : err.stack ?? err.message;
48043
48082
  }
48044
- return String(err);
48083
+ return publicBusinessErrorMessage(err);
48045
48084
  }
48046
48085
 
48047
48086
  // node_modules/.pnpm/@inquirer+core@10.3.2_@types+node@22.20.3/node_modules/@inquirer/core/dist/esm/lib/key.js
@@ -49076,13 +49115,13 @@ var PromisePolyfill = class extends Promise {
49076
49115
  // Available starting from Node 22
49077
49116
  // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/withResolvers
49078
49117
  static withResolver() {
49079
- let resolve9;
49118
+ let resolve11;
49080
49119
  let reject;
49081
49120
  const promise = new Promise((res, rej) => {
49082
- resolve9 = res;
49121
+ resolve11 = res;
49083
49122
  reject = rej;
49084
49123
  });
49085
- return { promise, resolve: resolve9, reject };
49124
+ return { promise, resolve: resolve11, reject };
49086
49125
  }
49087
49126
  };
49088
49127
 
@@ -49116,7 +49155,7 @@ function createPrompt(view) {
49116
49155
  output
49117
49156
  });
49118
49157
  const screen = new ScreenManager(rl);
49119
- const { promise, resolve: resolve9, reject } = PromisePolyfill.withResolver();
49158
+ const { promise, resolve: resolve11, reject } = PromisePolyfill.withResolver();
49120
49159
  const cancel = () => reject(new CancelPromptError());
49121
49160
  if (signal) {
49122
49161
  const abort = () => reject(new AbortPromptError({ cause: signal.reason }));
@@ -49143,7 +49182,7 @@ function createPrompt(view) {
49143
49182
  cycle(() => {
49144
49183
  try {
49145
49184
  const nextView = view(config, (value) => {
49146
- setImmediate(() => resolve9(value));
49185
+ setImmediate(() => resolve11(value));
49147
49186
  });
49148
49187
  if (nextView === void 0) {
49149
49188
  const callerFilename = callSites[1]?.getFileName();
@@ -50795,33 +50834,6 @@ function vpsServiceAuthHeaders(serviceBaseUrl) {
50795
50834
  return headers3;
50796
50835
  }
50797
50836
 
50798
- // src/core/public-result.ts
50799
- function publicBusinessResult(value) {
50800
- if (Array.isArray(value)) return value.map(publicBusinessResult);
50801
- if (!value || typeof value !== "object") {
50802
- return typeof value === "string" && /^odoo(?:\b|[_-])/i.test(value) ? "vps" : value;
50803
- }
50804
- const out = {};
50805
- for (const [key, item] of Object.entries(value)) {
50806
- if (key === "odoo_user_id") {
50807
- out.user_id ??= publicBusinessResult(item);
50808
- continue;
50809
- }
50810
- if (key === "database" && typeof item === "string" && /^odoo$/i.test(item)) continue;
50811
- if (key === "source" && item && typeof item === "object" && !Array.isArray(item)) {
50812
- const { db: _db, database: _database, login: _login, base_url: _baseUrl, ...source } = item;
50813
- out.source = publicBusinessResult(source);
50814
- continue;
50815
- }
50816
- out[key] = publicBusinessResult(item);
50817
- }
50818
- return out;
50819
- }
50820
- function publicBusinessErrorMessage(value) {
50821
- const message = String(value ?? "");
50822
- return /odoo/i.test(message) ? "\u4E1A\u52A1\u6570\u636E\u670D\u52A1\u6682\u4E0D\u53EF\u7528" : message;
50823
- }
50824
-
50825
50837
  // src/core/sales-query-client.ts
50826
50838
  var DAILY_SALES_LOCAL = "vps-daily-sales-report";
50827
50839
  var DAILY_SALES_SERVER = "odoo-daily-sales-report";
@@ -51006,8 +51018,8 @@ async function parseJsonBody(res, requestLabel) {
51006
51018
  try {
51007
51019
  return JSON.parse(text3);
51008
51020
  } catch {
51009
- const preview2 = text3.replace(/\s+/g, " ").trim().slice(0, 240);
51010
- const detail = preview2 ? `\uFF1A${preview2}` : "";
51021
+ const preview3 = text3.replace(/\s+/g, " ").trim().slice(0, 240);
51022
+ const detail = preview3 ? `\uFF1A${preview3}` : "";
51011
51023
  throw new VertuError(`${requestLabel} \u8FD4\u56DE\u975E JSON\uFF08HTTP ${res.statusCode}\uFF09${detail}`);
51012
51024
  }
51013
51025
  }
@@ -55928,7 +55940,7 @@ function buildAuthStatusCommand() {
55928
55940
  try {
55929
55941
  me = await fetchVpsServiceMe(effectiveBaseUrl, state.token);
55930
55942
  } catch (error) {
55931
- credentialError = error instanceof Error ? error.message : String(error);
55943
+ credentialError = publicBusinessErrorMessage(error instanceof Error ? error.message : String(error));
55932
55944
  }
55933
55945
  }
55934
55946
  const credentialRejected = credentialError ? /HTTP (401|403)\b/.test(credentialError) : false;
@@ -58328,6 +58340,185 @@ function buildImCommand() {
58328
58340
  return im;
58329
58341
  }
58330
58342
 
58343
+ // src/commands/mail/email.ts
58344
+ var import_promises10 = require("fs/promises");
58345
+
58346
+ // src/core/mail-client.ts
58347
+ var import_node_fs5 = require("fs");
58348
+ var import_promises8 = require("fs/promises");
58349
+ var import_node_path7 = require("path");
58350
+ var import_promises9 = require("stream/promises");
58351
+ var import_undici7 = __toESM(require_undici(), 1);
58352
+ var timeout = 30 * 6e4;
58353
+ function mailUrl(path3, scope, query2 = {}) {
58354
+ const url = new URL(`${resolveVpsServiceUrl(scope.baseUrl).replace(/\/$/, "")}/v1/mail${path3}`);
58355
+ for (const [key, value] of Object.entries(query2)) {
58356
+ if (value !== void 0 && value !== "") url.searchParams.set(key, String(value));
58357
+ }
58358
+ if (scope.mailboxId) url.searchParams.set("mailbox_id", scope.mailboxId);
58359
+ return url.toString();
58360
+ }
58361
+ async function jsonResponse(res) {
58362
+ const text3 = await res.body.text();
58363
+ let data;
58364
+ try {
58365
+ data = text3 ? JSON.parse(text3) : {};
58366
+ } catch {
58367
+ throw new VertuError(`\u90AE\u7BB1\u670D\u52A1\u8FD4\u56DE\u975E JSON\uFF08HTTP ${res.statusCode}\uFF09`);
58368
+ }
58369
+ if (res.statusCode >= 300) {
58370
+ const value = data;
58371
+ const reason = typeof value?.error === "string" ? value.error : value?.error?.message;
58372
+ throw new VertuError(`\u90AE\u7BB1\u670D\u52A1\u5931\u8D25\uFF08HTTP ${res.statusCode}\uFF09\uFF1A${value?.message || reason || "\u8BF7\u6C42\u5931\u8D25"}`);
58373
+ }
58374
+ return data;
58375
+ }
58376
+ async function mailRequest(method, path3, scope, body, query2) {
58377
+ const url = mailUrl(path3, scope, query2);
58378
+ return jsonResponse(await (0, import_undici7.request)(url, {
58379
+ method,
58380
+ headersTimeout: timeout,
58381
+ bodyTimeout: timeout,
58382
+ headers: { ...vpsServiceAuthHeaders(resolveVpsServiceUrl(scope.baseUrl)), accept: "application/json", "content-type": "application/json" },
58383
+ body: body === void 0 ? void 0 : JSON.stringify(body)
58384
+ }));
58385
+ }
58386
+ async function inspectMailFile(file) {
58387
+ const info = await (0, import_promises8.stat)(file);
58388
+ if (!info.isFile() || info.size > 1073741824) throw new VertuError("\u9644\u4EF6\u5FC5\u987B\u662F\u666E\u901A\u6587\u4EF6\u4E14\u4E0D\u8D85\u8FC7 1 GiB\u3002");
58389
+ return { name: (0, import_node_path7.basename)(file), size: info.size };
58390
+ }
58391
+ async function uploadMailFile(file, scope) {
58392
+ const info = await inspectMailFile(file);
58393
+ const form = new import_undici7.FormData();
58394
+ form.set("file", await (0, import_node_fs5.openAsBlob)(file), info.name);
58395
+ return jsonResponse(await (0, import_undici7.request)(mailUrl("/attachments", scope), {
58396
+ method: "POST",
58397
+ headersTimeout: timeout,
58398
+ bodyTimeout: timeout,
58399
+ headers: vpsServiceAuthHeaders(resolveVpsServiceUrl(scope.baseUrl)),
58400
+ body: form
58401
+ }));
58402
+ }
58403
+ async function downloadMailFile(blobId, output, scope) {
58404
+ const file = await (0, import_promises8.open)(output, "wx", 384);
58405
+ try {
58406
+ const res = await (0, import_undici7.request)(mailUrl(`/attachments/${encodeURIComponent(blobId)}`, scope), {
58407
+ method: "GET",
58408
+ headersTimeout: timeout,
58409
+ bodyTimeout: timeout,
58410
+ headers: vpsServiceAuthHeaders(resolveVpsServiceUrl(scope.baseUrl))
58411
+ });
58412
+ if (res.statusCode !== 200) {
58413
+ await jsonResponse(res);
58414
+ throw new VertuError("\u9644\u4EF6\u4E0B\u8F7D\u672A\u8FD4\u56DE\u5B8C\u6574\u6587\u4EF6\u3002");
58415
+ }
58416
+ await (0, import_promises9.pipeline)(res.body, file.createWriteStream());
58417
+ return { output, size: (await (0, import_promises8.stat)(output)).size };
58418
+ } catch (error) {
58419
+ await file.close();
58420
+ await (0, import_promises8.unlink)(output);
58421
+ throw error;
58422
+ } finally {
58423
+ await file.close();
58424
+ }
58425
+ }
58426
+
58427
+ // src/commands/mail/email.ts
58428
+ var collect = (value, previous) => [...previous, value];
58429
+ function addresses(values = []) {
58430
+ return values.flatMap((value) => value.split(",")).map((value) => {
58431
+ const email = value.trim();
58432
+ if (!/^[^\s<>@,]+@[^\s<>@,]+\.[^\s<>@,]+$/.test(email)) throw new VertuError(`\u90AE\u7BB1\u5730\u5740\u65E0\u6548\uFF1A${email}`);
58433
+ return { email };
58434
+ });
58435
+ }
58436
+ function preview(opts, method, path3, body, query2) {
58437
+ if (!opts.dryRun && !opts.validateOnly) return false;
58438
+ printImResult(opts.json, { validateOnly: true, method, endpoint: mailUrl(path3, opts, query2), ...body ? { body } : {} });
58439
+ return true;
58440
+ }
58441
+ function attachEmailCommands(parent) {
58442
+ const command = (name, description) => parent.command(name).description(description).option("--mailbox-id <uuid>", "\u90E8\u95E8\u90AE\u7BB1 UUID\uFF1B\u7701\u7565\u65F6\u4F7F\u7528\u672C\u4EBA\u4E2A\u4EBA\u90AE\u7BB1").option("--base-url <url>", "VPS \u670D\u52A1\u5730\u5740").option("--dry-run", "\u4EC5\u9884\u89C8\uFF0C\u4E0D\u53D1\u8D77\u8BF7\u6C42").option("--validate-only", "\u540C --dry-run").option("--no-json", "\u7D27\u51D1 JSON \u8F93\u51FA");
58443
+ const options = (cmd) => {
58444
+ const opts = cmd.optsWithGlobals();
58445
+ if (opts.mailboxId && !/^[\da-f]{8}(-[\da-f]{4}){3}-[\da-f]{12}$/i.test(opts.mailboxId)) {
58446
+ throw new VertuError("--mailbox-id \u5FC5\u987B\u662F\u90E8\u95E8\u90AE\u7BB1 UUID\u3002");
58447
+ }
58448
+ return opts;
58449
+ };
58450
+ for (const [name, path3, description] of [
58451
+ ["+account", "/account", "\u67E5\u770B\u5F53\u524D\u90AE\u7BB1\u53CA\u6743\u9650"],
58452
+ ["+mailboxes", "/shared-mailboxes", "\u5217\u51FA\u53EF\u89C1\u7684\u90E8\u95E8\u90AE\u7BB1\u53CA\u6210\u5458\u89D2\u8272"],
58453
+ ["+folders", "/folders", "\u5217\u51FA\u6587\u4EF6\u5939\u3001\u90AE\u4EF6\u6570\u4E0E\u672A\u8BFB\u6570"],
58454
+ ["+identities", "/identities", "\u5217\u51FA\u5F53\u524D\u90AE\u7BB1\u5141\u8BB8\u4F7F\u7528\u7684\u53D1\u4EF6\u8EAB\u4EFD"]
58455
+ ]) {
58456
+ command(name, description).action(async (_, cmd) => {
58457
+ const opts = options(cmd);
58458
+ if (preview(opts, "GET", path3)) return;
58459
+ printImResult(opts.json, await mailRequest("GET", path3, opts));
58460
+ });
58461
+ }
58462
+ command("+messages", "\u67E5\u8BE2\u5DF2\u6536\u53D6\u7684\u90AE\u4EF6\uFF0C\u652F\u6301\u641C\u7D22\u3001\u6587\u4EF6\u5939\u4E0E\u6E38\u6807\u7FFB\u9875").option("--folder-id <id>", "\u6587\u4EF6\u5939 ID\uFF08\u89C1 +folders\uFF09").option("--search <text>", "\u641C\u7D22\u6587\u5B57").option("--limit <n>", "\u6BCF\u9875\u6570\u91CF\uFF0C1\u2013100", "50").option("--cursor <cursor>", "\u4E0A\u4E00\u9875 next_cursor").option("--unread-only", "\u53EA\u67E5\u8BE2\u672A\u8BFB\u90AE\u4EF6").action(async (_, cmd) => {
58463
+ const opts = options(cmd), limit = Number(opts.limit);
58464
+ if (!Number.isInteger(limit) || limit < 1 || limit > 100) throw new VertuError("--limit \u5FC5\u987B\u662F 1\u2013100 \u7684\u6574\u6570\u3002");
58465
+ const query2 = { folder_id: opts.folderId, search: opts.search, limit, cursor: opts.cursor, unread: opts.unreadOnly ? true : void 0 };
58466
+ if (preview(opts, "GET", "/messages", void 0, query2)) return;
58467
+ printImResult(opts.json, await mailRequest("GET", "/messages", opts, void 0, query2));
58468
+ });
58469
+ for (const [name, resource, description] of [
58470
+ ["+read", "messages", "\u8BFB\u53D6\u90AE\u4EF6\u6B63\u6587\u4E0E\u9644\u4EF6\u4FE1\u606F\uFF08\u4E0D\u81EA\u52A8\u6807\u8BB0\u5DF2\u8BFB\uFF09"],
58471
+ ["+submission", "submissions", "\u67E5\u8BE2\u53D1\u9001\u63D0\u4EA4\u72B6\u6001"]
58472
+ ]) {
58473
+ command(name, description).requiredOption("--id <id>", "\u90AE\u4EF6\u6216\u53D1\u9001\u63D0\u4EA4 ID").action(async (_, cmd) => {
58474
+ const opts = options(cmd), path3 = `/${resource}/${encodeURIComponent(opts.id)}`;
58475
+ if (preview(opts, "GET", path3)) return;
58476
+ printImResult(opts.json, await mailRequest("GET", path3, opts));
58477
+ });
58478
+ }
58479
+ command("+mark-read", "\u6807\u8BB0\u90AE\u4EF6\u5DF2\u8BFB\uFF08\u53EA\u8BFB\u6210\u5458\u4E0D\u53EF\u7528\uFF09").requiredOption("--id <id>", "\u90AE\u4EF6 ID").action(async (_, cmd) => {
58480
+ const opts = options(cmd), path3 = `/messages/${encodeURIComponent(opts.id)}`;
58481
+ if (preview(opts, "PATCH", path3, { unread: false })) return;
58482
+ printImResult(opts.json, await mailRequest("PATCH", path3, opts, { unread: false }));
58483
+ });
58484
+ for (const draft of [false, true]) {
58485
+ const c = command(draft ? "+draft" : "+send-email", draft ? "\u4FDD\u5B58\u90AE\u4EF6\u8349\u7A3F\uFF0C\u4E0D\u53D1\u9001" : "\u53D1\u9001\u771F\u5B9E\u7535\u5B50\u90AE\u4EF6\uFF08\u4FDD\u7559 +send \u7684 IM \u79C1\u4FE1\u517C\u5BB9\u884C\u4E3A\uFF09").requiredOption("--to <email>", "\u6536\u4EF6\u5730\u5740\uFF0C\u53EF\u91CD\u590D\u6216\u9017\u53F7\u5206\u9694", collect, []).option("--cc <email>", "\u6284\u9001\u5730\u5740\uFF0C\u53EF\u91CD\u590D", collect, []).option("--bcc <email>", "\u5BC6\u9001\u5730\u5740\uFF0C\u53EF\u91CD\u590D", collect, []).requiredOption("--subject <text>", "\u90AE\u4EF6\u4E3B\u9898").option("--body <text>", "\u7EAF\u6587\u672C\u6B63\u6587").option("--body-file <path>", "\u4ECE UTF-8 \u6587\u4EF6\u8BFB\u53D6\u6B63\u6587\uFF08\u4E0E --body \u4E92\u65A5\uFF09").option("--attachment-id <id>", "+upload \u8FD4\u56DE\u7684\u9644\u4EF6 ID\uFF0C\u53EF\u91CD\u590D\uFF1B\u987B\u5C5E\u4E8E\u540C\u4E00\u90AE\u7BB1", collect, []);
58486
+ if (!draft) c.requiredOption("--request-id <id>", "8\u2013128 \u5B57\u7B26\u7684\u53D1\u9001\u8BF7\u6C42\u7F16\u53F7\uFF1B\u4E2D\u65AD\u91CD\u8BD5\u5FC5\u987B\u590D\u7528\u540C\u4E00\u7F16\u53F7\u548C\u5185\u5BB9").option("--identity-id <id>", "+identities \u8FD4\u56DE\u7684\u53D1\u4EF6\u8EAB\u4EFD ID").option("--reply-to <message-id>", "\u56DE\u590D\u539F\u90AE\u4EF6 ID\uFF0C\u4FDD\u7559\u90AE\u4EF6\u4F1A\u8BDD\u5F15\u7528");
58487
+ c.action(async (_, cmd) => {
58488
+ const opts = options(cmd);
58489
+ if (opts.body !== void 0 && opts.bodyFile) throw new VertuError("--body \u4E0E --body-file \u4E0D\u80FD\u540C\u65F6\u4F7F\u7528\u3002");
58490
+ if (opts.body === void 0 && !opts.bodyFile) throw new VertuError("\u8BF7\u63D0\u4F9B --body \u6216 --body-file\u3002");
58491
+ if (!draft && (!opts.requestId || opts.requestId.length < 8 || opts.requestId.length > 128)) throw new VertuError("--request-id \u957F\u5EA6\u5FC5\u987B\u4E3A 8\u2013128\u3002");
58492
+ const body = {
58493
+ to: addresses(opts.to),
58494
+ cc: addresses(opts.cc),
58495
+ bcc: addresses(opts.bcc),
58496
+ subject: opts.subject,
58497
+ body_text: opts.bodyFile ? await (0, import_promises10.readFile)(opts.bodyFile, "utf8") : opts.body,
58498
+ attachment_ids: opts.attachmentId,
58499
+ ...!draft ? { client_request_id: opts.requestId, identity_id: opts.identityId, reply_to_message_id: opts.replyTo } : {}
58500
+ };
58501
+ const path3 = draft ? "/drafts" : "/messages/send";
58502
+ if (preview(opts, "POST", path3, body)) return;
58503
+ try {
58504
+ printImResult(opts.json, await mailRequest("POST", path3, opts, body));
58505
+ } catch (e) {
58506
+ throw new VertuError(`${e instanceof Error ? e.message : String(e)}${draft ? "" : `\uFF1B\u53D1\u9001\u7ED3\u679C\u53EF\u80FD\u5F85\u786E\u8BA4\uFF0C\u8BF7\u4F7F\u7528\u539F request-id ${opts.requestId} \u548C\u76F8\u540C\u5185\u5BB9\u91CD\u8BD5\uFF0C\u4E0D\u8981\u6539\u7528\u65B0\u7F16\u53F7\u3002`}`);
58507
+ }
58508
+ });
58509
+ }
58510
+ command("+upload", "\u6D41\u5F0F\u4E0A\u4F20\u90AE\u4EF6\u9644\u4EF6\uFF0C\u8FD4\u56DE\u4F9B\u8349\u7A3F/\u53D1\u9001\u4F7F\u7528\u7684\u9644\u4EF6 ID").requiredOption("--file <path>", "\u672C\u5730\u9644\u4EF6\u8DEF\u5F84\uFF0C\u6700\u5927 1 GiB").action(async (_, cmd) => {
58511
+ const opts = options(cmd), info = await inspectMailFile(opts.file);
58512
+ if (preview(opts, "POST", "/attachments", info)) return;
58513
+ printImResult(opts.json, await uploadMailFile(opts.file, opts));
58514
+ });
58515
+ command("+download", "\u6D41\u5F0F\u4E0B\u8F7D\u90AE\u4EF6\u9644\u4EF6\uFF1B\u76EE\u6807\u6587\u4EF6\u5DF2\u5B58\u5728\u65F6\u62D2\u7EDD\u8986\u76D6").requiredOption("--id <blob-id>", "+read \u8FD4\u56DE\u7684\u9644\u4EF6 blob_id").requiredOption("--output <path>", "\u672C\u5730\u8F93\u51FA\u8DEF\u5F84").action(async (_, cmd) => {
58516
+ const opts = options(cmd), path3 = `/attachments/${encodeURIComponent(opts.id)}`;
58517
+ if (preview(opts, "GET", path3, { output: opts.output })) return;
58518
+ printImResult(opts.json, await downloadMailFile(opts.id, opts.output, opts));
58519
+ });
58520
+ }
58521
+
58331
58522
  // src/commands/mail/shortcuts.ts
58332
58523
  function collectAttach2(value, previous) {
58333
58524
  return [...previous, value];
@@ -58371,9 +58562,10 @@ function attachMailShortcuts(parent) {
58371
58562
  // src/commands/mail/index.ts
58372
58563
  function buildMailCommand() {
58373
58564
  const mail = new Command("mail").description(
58374
- "Mail shortcuts: direct message send/read helpers."
58565
+ "\u4F01\u4E1A\u90AE\u7BB1\u6536\u53D1\u3001\u9644\u4EF6\u4E0E\u90E8\u95E8\u90AE\u7BB1\uFF1B+send \u4FDD\u7559\u65E7 IM \u79C1\u4FE1\u517C\u5BB9\u3002"
58375
58566
  );
58376
58567
  attachMailShortcuts(mail);
58568
+ attachEmailCommands(mail);
58377
58569
  return mail;
58378
58570
  }
58379
58571
 
@@ -58806,7 +58998,7 @@ async function basePlan(opts) {
58806
58998
  function baseURL(opts, cmd) {
58807
58999
  return opts.baseUrl ?? cmd.optsWithGlobals().baseUrl;
58808
59000
  }
58809
- function preview(opts, cmd, method, path3, payload) {
59001
+ function preview2(opts, cmd, method, path3, payload) {
58810
59002
  if (opts.validateOnly !== true && opts.dryRun !== true) return false;
58811
59003
  printImResult(opts.json, { validateOnly: true, method, endpoint: `${resolveVpsServiceUrl(baseURL(opts, cmd))}${path3}`, ...payload });
58812
59004
  return true;
@@ -58814,7 +59006,7 @@ function preview(opts, cmd, method, path3, payload) {
58814
59006
  function attachAttendanceSchedulingShortcuts(parent) {
58815
59007
  attachSharedShortcutOptions(parent.command("+schedule-rules").description("\u67E5\u8BE2\u5F53\u524D\u7528\u6237\u53EF\u6267\u884C\u6392\u73ED\u7684\u8003\u52E4\u89C4\u5219")).action(async (opts, cmd) => {
58816
59008
  const path3 = "/v1/attendance/scheduling/rules";
58817
- if (preview(opts, cmd, "GET", path3, {})) return;
59009
+ if (preview2(opts, cmd, "GET", path3, {})) return;
58818
59010
  printImResult(opts.json, await imRequest("GET", path3, { baseUrl: baseURL(opts, cmd) }));
58819
59011
  });
58820
59012
  attachSharedShortcutOptions(parent.command("+schedule-shifts").description("\u67E5\u8BE2\u89C4\u5219\u4E0B\u53EF\u7528\u548C\u4E0D\u53EF\u7528\u73ED\u6B21").requiredOption("--rule-id <id>").option("--availability <value>", "all|available|unavailable", "all")).action(async (opts, cmd) => {
@@ -58824,7 +59016,7 @@ function attachAttendanceSchedulingShortcuts(parent) {
58824
59016
  if (!["all", "available", "unavailable"].includes(availability)) throw new VertuError("availability must be all, available, or unavailable.");
58825
59017
  const path3 = `/v1/attendance/scheduling/rules/${encodeURIComponent(ruleID)}/shifts`;
58826
59018
  const query2 = { availability };
58827
- if (preview(opts, cmd, "GET", path3, { query: query2 })) return;
59019
+ if (preview2(opts, cmd, "GET", path3, { query: query2 })) return;
58828
59020
  printImResult(opts.json, await imRequest("GET", path3, { baseUrl: baseURL(opts, cmd), query: query2 }));
58829
59021
  });
58830
59022
  for (const [name, description] of [["+schedule-members", "\u67E5\u8BE2\u89C4\u5219\u4E0B\u4EBA\u5458\u53CA\u6392\u73ED\u4E8B\u5B9E"], ["+schedules", "\u67E5\u8BE2\u89C4\u5219\u4E0B\u6392\u73ED\u8BE6\u60C5"]]) {
@@ -58836,7 +59028,7 @@ function attachAttendanceSchedulingShortcuts(parent) {
58836
59028
  const query2 = normalizeRange(merged);
58837
59029
  const segment = name === "+schedules" ? "schedules" : "members";
58838
59030
  const path3 = `/v1/attendance/scheduling/rules/${encodeURIComponent(ruleID)}/${segment}`;
58839
- if (preview(opts, cmd, "GET", path3, { query: query2 })) return;
59031
+ if (preview2(opts, cmd, "GET", path3, { query: query2 })) return;
58840
59032
  printImResult(opts.json, await imRequest("GET", path3, { baseUrl: baseURL(opts, cmd), query: query2 }));
58841
59033
  });
58842
59034
  }
@@ -58846,7 +59038,7 @@ function attachAttendanceSchedulingShortcuts(parent) {
58846
59038
  attachSharedShortcutOptions(command).action(async (opts, cmd) => {
58847
59039
  const body = normalizePlan(await mergeShortcutParams(await basePlan(opts), opts), action2 === "apply");
58848
59040
  const path3 = `/v1/attendance/scheduling/plans/${action2}`;
58849
- if (preview(opts, cmd, "POST", path3, { body })) return;
59041
+ if (preview2(opts, cmd, "POST", path3, { body })) return;
58850
59042
  printImResult(opts.json, await imRequest("POST", path3, { baseUrl: baseURL(opts, cmd), body }));
58851
59043
  });
58852
59044
  }
@@ -59481,17 +59673,17 @@ function buildTaskCommand() {
59481
59673
  }
59482
59674
 
59483
59675
  // src/commands/tools/index.ts
59484
- var import_promises8 = require("fs/promises");
59485
- var import_node_path7 = require("path");
59486
- var import_undici7 = __toESM(require_undici(), 1);
59676
+ var import_promises11 = require("fs/promises");
59677
+ var import_node_path8 = require("path");
59678
+ var import_undici8 = __toESM(require_undici(), 1);
59487
59679
  var MAX_OSS_UPLOAD_BYTES = 50 * 1024 * 1024;
59488
59680
  function buildToolsCommand() {
59489
59681
  const command = new Command("tools").description("\u5E73\u53F0\u516C\u5171\u5DE5\u5177\uFF1AOSS \u4E0A\u4F20\u3001\u5730\u5740\u7B7E\u540D\u7B49\u8DE8\u4E1A\u52A1\u80FD\u529B\u3002");
59490
59682
  attachSharedShortcutOptions(
59491
59683
  command.command("+oss-upload").description("\u4E0A\u4F20\u6587\u4EF6\u5230 OSS\uFF0C\u8FD4\u56DE\u516C\u5F00\u5730\u5740\u6216\u9650\u65F6\u7B7E\u540D\u5730\u5740").requiredOption("--file <path>", "\u672C\u5730\u6587\u4EF6\u8DEF\u5F84").option("--visibility <private|public>", "\u8BBF\u95EE\u65B9\u5F0F\uFF1B\u9ED8\u8BA4 private", "private").option("--object-name <path>", "\u8EAB\u4EFD\u9694\u79BB\u76EE\u5F55\u5185\u7684\u76F8\u5BF9\u5BF9\u8C61\u540D").option("--content-type <mime>", "\u663E\u5F0F MIME\uFF1B\u9ED8\u8BA4\u6309\u6269\u5C55\u540D\u63A8\u65AD").option("--signed-url-expires <seconds>", "\u7B7E\u540D URL \u6709\u6548\u79D2\u6570\uFF0860\uFF5E604800\uFF09", "3600")
59492
59684
  ).action(async (opts, parent) => {
59493
- const filePath = (0, import_node_path7.resolve)(opts.file?.trim() ?? "");
59494
- const fileStat = await (0, import_promises8.stat)(filePath).catch(() => null);
59685
+ const filePath = (0, import_node_path8.resolve)(opts.file?.trim() ?? "");
59686
+ const fileStat = await (0, import_promises11.stat)(filePath).catch(() => null);
59495
59687
  if (!fileStat?.isFile()) throw new VertuError(`\u6587\u4EF6\u4E0D\u5B58\u5728\u6216\u4E0D\u662F\u666E\u901A\u6587\u4EF6\uFF1A${filePath}`);
59496
59688
  if (fileStat.size <= 0) throw new VertuError("\u6587\u4EF6\u5185\u5BB9\u4E3A\u7A7A\u3002");
59497
59689
  if (fileStat.size > MAX_OSS_UPLOAD_BYTES) throw new VertuError("\u6587\u4EF6\u8D85\u8FC7 50 MiB \u4E0A\u9650\u3002");
@@ -59515,8 +59707,8 @@ function buildToolsCommand() {
59515
59707
  });
59516
59708
  return;
59517
59709
  }
59518
- const form = new import_undici7.FormData();
59519
- form.append("file", new Blob([await (0, import_promises8.readFile)(filePath)], { type: contentType }), (0, import_node_path7.basename)(filePath));
59710
+ const form = new import_undici8.FormData();
59711
+ form.append("file", new Blob([await (0, import_promises11.readFile)(filePath)], { type: contentType }), (0, import_node_path8.basename)(filePath));
59520
59712
  form.append("visibility", visibility);
59521
59713
  form.append("signed_url_expires", String(expires));
59522
59714
  if (opts.objectName?.trim()) form.append("object_name", opts.objectName.trim());
@@ -59534,16 +59726,16 @@ function buildToolsCommand() {
59534
59726
  ).action(async (opts, parent) => {
59535
59727
  const documentId = opts.documentId?.trim() || "";
59536
59728
  if (!/^[0-9a-f-]{36}$/i.test(documentId)) throw new VertuError("--document-id \u5FC5\u987B\u662F UUID\u3002");
59537
- const timeout = parseOptionalInt(opts.timeout, "--timeout") ?? 600;
59729
+ const timeout2 = parseOptionalInt(opts.timeout, "--timeout") ?? 600;
59538
59730
  const pollInterval = parseOptionalInt(opts.pollInterval, "--poll-interval") ?? 2;
59539
- if (timeout < 1 || timeout > 600) throw new VertuError("--timeout \u5FC5\u987B\u5728 1 \u5230 600 \u79D2\u4E4B\u95F4\u3002");
59731
+ if (timeout2 < 1 || timeout2 > 600) throw new VertuError("--timeout \u5FC5\u987B\u5728 1 \u5230 600 \u79D2\u4E4B\u95F4\u3002");
59540
59732
  if (pollInterval < 1 || pollInterval > 30) throw new VertuError("--poll-interval \u5FC5\u987B\u5728 1 \u5230 30 \u79D2\u4E4B\u95F4\u3002");
59541
59733
  const baseUrl4 = resolveShortcutVpsServiceUrl(opts, parent);
59542
59734
  if (opts.validateOnly === true || opts.dryRun === true) {
59543
59735
  print2(opts, { document_id: documentId, endpoint: `${baseUrl4}/v1/im/agents/documents/${documentId}`, wait: opts.wait !== false, validateOnly: true });
59544
59736
  return;
59545
59737
  }
59546
- const deadline = Date.now() + timeout * 1e3;
59738
+ const deadline = Date.now() + timeout2 * 1e3;
59547
59739
  while (true) {
59548
59740
  const result = await vpsServiceGet(
59549
59741
  `/v1/im/agents/documents/${encodeURIComponent(documentId)}`,
@@ -59558,7 +59750,7 @@ function buildToolsCommand() {
59558
59750
  }
59559
59751
  if (status === "failed") throw new VertuError(result.document?.error_message || "\u9644\u4EF6\u89E3\u6790\u5931\u8D25\u3002");
59560
59752
  if (opts.wait === false || Date.now() >= deadline) {
59561
- if (opts.wait !== false) throw new VertuError(`\u9644\u4EF6\u89E3\u6790\u7B49\u5F85\u8D85\u8FC7 ${timeout} \u79D2\u3002`);
59753
+ if (opts.wait !== false) throw new VertuError(`\u9644\u4EF6\u89E3\u6790\u7B49\u5F85\u8D85\u8FC7 ${timeout2} \u79D2\u3002`);
59562
59754
  print2(opts, result);
59563
59755
  return;
59564
59756
  }
@@ -59603,7 +59795,7 @@ function mimeType(name) {
59603
59795
  ".xlsx": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
59604
59796
  ".zip": "application/zip"
59605
59797
  };
59606
- return types[(0, import_node_path7.extname)(name).toLowerCase()] ?? "application/octet-stream";
59798
+ return types[(0, import_node_path8.extname)(name).toLowerCase()] ?? "application/octet-stream";
59607
59799
  }
59608
59800
 
59609
59801
  // src/commands/hr/data-view-shortcuts.ts
@@ -60148,6 +60340,7 @@ async function fetchPayslip(opts) {
60148
60340
 
60149
60341
  // src/commands/hr/shortcuts.ts
60150
60342
  function printShortcutJson(opts, out) {
60343
+ out = publicBusinessResult(out);
60151
60344
  if (opts.json !== false) {
60152
60345
  console.log(JSON.stringify(out, null, 2));
60153
60346
  } else {
@@ -60288,8 +60481,8 @@ function attachHrShortcuts(parent) {
60288
60481
  }
60289
60482
 
60290
60483
  // src/commands/hr/job-responsibilities.ts
60291
- var import_promises9 = require("fs/promises");
60292
- var import_node_path8 = require("path");
60484
+ var import_promises12 = require("fs/promises");
60485
+ var import_node_path9 = require("path");
60293
60486
  var POSITION_DOCS_PATH = "/v1/workbench/position-docs";
60294
60487
  var summarySchema = external_exports.object({
60295
60488
  id: external_exports.number().int().positive(),
@@ -60514,9 +60707,9 @@ function attachJobResponsibilitiesShortcut(parent) {
60514
60707
  const content = opts.json === false ? plainResult(result) : JSON.stringify(result, null, 2);
60515
60708
  if (opts.output !== void 0) {
60516
60709
  if (!opts.output.trim()) throw new VertuError("--output \u4E0D\u80FD\u4E3A\u7A7A\u8DEF\u5F84\u3002");
60517
- const output = (0, import_node_path8.resolve)(opts.output);
60518
- await (0, import_promises9.mkdir)((0, import_node_path8.dirname)(output), { recursive: true });
60519
- await (0, import_promises9.writeFile)(output, `${content}
60710
+ const output = (0, import_node_path9.resolve)(opts.output);
60711
+ await (0, import_promises12.mkdir)((0, import_node_path9.dirname)(output), { recursive: true });
60712
+ await (0, import_promises12.writeFile)(output, `${content}
60520
60713
  `, "utf8");
60521
60714
  }
60522
60715
  console.log(content);
@@ -60532,9 +60725,12 @@ function attachHrBusinessShortcuts(parent) {
60532
60725
  ["+onboarding", "\u53D1\u8D77\u5165\u804C\u529E\u7406", "onboarding"],
60533
60726
  ["+confirm-onboarding", "\u786E\u8BA4\u5458\u5DE5\u5165\u804C", "confirm_onboarding"],
60534
60727
  ["+transfer", "\u529E\u7406\u8C03\u5C97\u3001\u664B\u5347\u6216\u964D\u7EA7", "transfer"],
60535
- ["+resignation", "\u53D1\u8D77\u79BB\u804C\u529E\u7406", "resignation"],
60728
+ ["+resignation", "\u521B\u5EFA\u79BB\u804C\u7533\u8BF7\u8349\u7A3F\uFF08\u672C\u4EBA\u6216HR\u4EE3\u529E\uFF09", "resignation"],
60729
+ ["+resignations", "\u67E5\u770B\u79BB\u804C\u7533\u8BF7\u548C\u6838\u5BF9\u6E05\u5355", "resignations"],
60730
+ ["+resignation-action", "\u8865\u8D44\u6599\u3001\u6838\u9A8C\u3001\u63D0\u4EA4\u6216\u64A4\u56DE\u79BB\u804C\u7533\u8BF7", "resignation_action"],
60731
+ ["+resignation-file", "\u7BA1\u7406\u79BB\u804C\u7533\u8BF7\u9644\u4EF6", "resignation_file"],
60536
60732
  ["+confirm-regular", "\u786E\u8BA4\u5458\u5DE5\u8F6C\u6B63", "confirm_regular"],
60537
- ["+confirm-resignation", "\u786E\u8BA4\u5458\u5DE5\u79BB\u804C", "confirm_resignation"],
60733
+ ["+confirm-resignation", "\u590D\u6838\u5E76\u751F\u6548\u5DF2\u6279\u51C6\u7684\u79BB\u804C\u7533\u8BF7", "confirm_resignation"],
60538
60734
  ["+business-action", "\u6267\u884C catalog \u516C\u5E03\u7684\u65B0\u4EBA\u4E8B\u52A8\u4F5C", "mutate"]
60539
60735
  ];
60540
60736
  for (const [name, description, script] of entries) {
@@ -61158,9 +61354,9 @@ function attachSalesPersonnelShortcuts(parent) {
61158
61354
  }
61159
61355
 
61160
61356
  // src/core/sales-invoice-attachments-client.ts
61161
- var import_promises10 = require("fs/promises");
61162
- var import_node_path9 = require("path");
61163
- var import_undici8 = __toESM(require_undici(), 1);
61357
+ var import_promises13 = require("fs/promises");
61358
+ var import_node_path10 = require("path");
61359
+ var import_undici9 = __toESM(require_undici(), 1);
61164
61360
  async function errorMessage(status, text3) {
61165
61361
  try {
61166
61362
  const payload = JSON.parse(text3);
@@ -61182,7 +61378,7 @@ function serviceHeaders2(extra) {
61182
61378
  }
61183
61379
  async function listSalesInvoiceAttachments(baseUrl4, orderNo) {
61184
61380
  const query2 = new URLSearchParams({ order_no: orderNo });
61185
- const response = await (0, import_undici8.request)(`${baseUrl4}/v1/sales/invoice-attachments?${query2}`, {
61381
+ const response = await (0, import_undici9.request)(`${baseUrl4}/v1/sales/invoice-attachments?${query2}`, {
61186
61382
  method: "GET",
61187
61383
  headers: serviceHeaders2({ accept: "application/json" })
61188
61384
  });
@@ -61197,21 +61393,21 @@ async function listSalesInvoiceAttachments(baseUrl4, orderNo) {
61197
61393
  }
61198
61394
  }
61199
61395
  async function downloadSalesInvoiceAttachments(baseUrl4, items, outputDir) {
61200
- const directory = (0, import_node_path9.resolve)(outputDir);
61201
- await (0, import_promises10.mkdir)(directory, { recursive: true });
61396
+ const directory = (0, import_node_path10.resolve)(outputDir);
61397
+ await (0, import_promises13.mkdir)(directory, { recursive: true });
61202
61398
  const outputs = [];
61203
61399
  for (const item of items) {
61204
61400
  const fallback = `${item.order_no}_${item.move_id}_${item.index + 1}.${item.file_type || "bin"}`;
61205
61401
  const prefix = `${safeFileName(item.order_no)}_${item.move_id}_${item.index + 1}_`;
61206
- const output = (0, import_node_path9.join)(directory, `${prefix}${safeFileName(item.name || fallback)}`);
61207
- const response = await (0, import_undici8.request)(`${baseUrl4}/v1/sales/invoice-attachments/download`, {
61402
+ const output = (0, import_node_path10.join)(directory, `${prefix}${safeFileName(item.name || fallback)}`);
61403
+ const response = await (0, import_undici9.request)(`${baseUrl4}/v1/sales/invoice-attachments/download`, {
61208
61404
  method: "POST",
61209
61405
  headers: serviceHeaders2({ "content-type": "application/json" }),
61210
61406
  body: JSON.stringify({ order_no: item.order_no, move_id: item.move_id, index: item.index })
61211
61407
  });
61212
61408
  const bytes = Buffer.from(await response.body.arrayBuffer());
61213
61409
  if (response.statusCode >= 400) throw await errorMessage(response.statusCode, bytes.toString("utf8"));
61214
- await (0, import_promises10.writeFile)(output, bytes, { flag: "wx" }).catch((error) => {
61410
+ await (0, import_promises13.writeFile)(output, bytes, { flag: "wx" }).catch((error) => {
61215
61411
  if (error.code === "EEXIST") throw new VertuError(`Output already exists: ${output}`);
61216
61412
  throw error;
61217
61413
  });
@@ -61905,7 +62101,7 @@ function buildSalesCommand() {
61905
62101
  // src/commands/store/index.ts
61906
62102
  var STORE_MANAGEMENT_SKILL = "vps-store-management";
61907
62103
  function buildStoreCommand() {
61908
- const store = new Command("store").description("\u95E8\u5E97\u7BA1\u7406\uFF1A\u95E8\u5E97\u63A5\u5F85\u3001\u8FDB\u5E97\u8F6C\u5316\u4E0E\u5BA2\u6237\u8FC7\u7A0B\u6570\u636E\u3002");
62104
+ const store = new Command("store").description("\u95E8\u5E97\u7BA1\u7406\uFF1AWalk-in \u5BA2\u6D41\u3001\u95E8\u5E97\u63A5\u5F85\u548C\u5E93\u5B58\u67E5\u8BE2\u3002");
61909
62105
  attachSharedShortcutOptions(
61910
62106
  store.command("+reception").alias("+store-reception").description("\u95E8\u5E97\u63A5\u5F85\u60C5\u51B5\uFF1A\u8FDB\u5E97\u3001\u52A0\u5FAE\u3001\u6709\u6548\u5BA2\u6237\u3001\u89E6\u6478\u3001\u8BD5\u7528\u4E0E\u6210\u4EA4\uFF08\u9ED8\u8BA4\u672C\u6708\uFF09").option("--period <name>", "today | this_week | last_week | this_month | last_month | last_n_days | YYYY-MM-DD").option("--start-date <date>", "YYYY-MM-DD\uFF1B\u81EA\u5B9A\u4E49\u5F00\u59CB\u65E5\u671F").option("--end-date <date>", "YYYY-MM-DD\uFF1B\u81EA\u5B9A\u4E49\u7ED3\u675F\u65E5\u671F").option("--days <n>", "period=last_n_days \u65F6\u7684\u5929\u6570").option("--region <name>", "\u533A\u57DF\uFF1A\u4E1C\u533A/\u897F\u533A/\u5317\u533A/\u5357\u533A").option("--store <name>", "\u95E8\u5E97\u540D\u79F0\uFF0C\u7CBE\u786E\u5339\u914D").option("--department-id <id>", "\u771F\u5B9E\u90E8\u95E8 ID").option("--employee <name>", "\u63A5\u5F85\u5458\u5DE5\u59D3\u540D\uFF0C\u6A21\u7CCA\u5339\u914D").option("--source <scope>", "\u6570\u636E\u6765\u6E90\uFF1Astore\uFF08\u9ED8\u8BA4\uFF09| dealer | all")
61911
62107
  ).action(async (opts, cmd) => {
@@ -61924,6 +62120,32 @@ function buildStoreCommand() {
61924
62120
  cmd
61925
62121
  );
61926
62122
  });
62123
+ attachSharedShortcutOptions(
62124
+ store.command("+walk-in").alias("+walkin").description("Walk-in \u5BA2\u6D41\uFF1A\u6309\u90E8\u95E8\u3001\u63A5\u5F85\u65E5\u671F\u7B5B\u9009\u548C\u5206\u7EC4\uFF08\u9ED8\u8BA4\u672C\u6708\uFF09").option("--period <name>", "today | this_week | this_month | last_month | YYYY-MM-DD").option("--start-date <date>", "YYYY-MM-DD").option("--end-date <date>", "YYYY-MM-DD").option("--days <n>", "last_n_days \u5929\u6570").option("--department <name>", "\u63A5\u5F85\u90E8\u95E8\u540D\u79F0\uFF0C\u7CBE\u786E\u5339\u914D").option("--department-id <id>", "ERP \u63A5\u5F85\u90E8\u95E8 ID").option("--store <name>", "\u8868\u5355\u95E8\u5E97\u540D\u79F0\uFF0C\u7CBE\u786E\u5339\u914D").option("--source <scope>", "store\uFF08\u9ED8\u8BA4\uFF09| dealer | all").option("--group-by <dimensions>", "department,date,store \u7684\u9017\u53F7\u7EC4\u5408\uFF0C\u6216 all").option("--date-grain <grain>", "day\uFF08\u9ED8\u8BA4\uFF09| week | month").option("--limit <n>", "\u6BCF\u9875\u5206\u7EC4\u6570\uFF0C\u9ED8\u8BA4 100\uFF0C\u6700\u591A 1000").option("--offset <n>", "\u5206\u7EC4\u504F\u79FB\u91CF\uFF0C\u9ED8\u8BA4 0")
62125
+ ).action(async (opts, cmd) => {
62126
+ const params = buildSalesPeriodParams(opts, "this_month");
62127
+ for (const key of ["department", "store", "source"]) if (opts[key] !== void 0) params[key] = opts[key];
62128
+ if (opts.groupBy !== void 0) params.group_by = opts.groupBy;
62129
+ if (opts.dateGrain !== void 0) params.date_grain = opts.dateGrain;
62130
+ for (const [flag, key] of [["departmentId", "department_id"], ["limit", "limit"], ["offset", "offset"]]) {
62131
+ const value = parseOptionalInt(opts[flag], `--${key.replaceAll("_", "-")}`);
62132
+ if (value !== void 0) params[key] = value;
62133
+ }
62134
+ await runSkillShortcutExecute(STORE_MANAGEMENT_SKILL, "store_walkin_summary", params, opts, cmd);
62135
+ });
62136
+ attachSharedShortcutOptions(
62137
+ store.command("+inventory").description("\u5F53\u524D\u95E8\u5E97\u5E93\u5B58\uFF1A\u6309\u5E93\u5B58\u62A5\u8868\u90E8\u95E8\u3001\u95E8\u5E97\u3001\u5546\u54C1\u7B5B\u9009\u548C\u5206\u7EC4").option("--department <name>", "\u5E93\u5B58\u62A5\u8868\u90E8\u95E8\u540D\u79F0\uFF0C\u7CBE\u786E\u5339\u914D").option("--store <name>", "\u5E93\u4F4D\u8DEF\u5F84\u9996\u6BB5\u95E8\u5E97\uFF0C\u7CBE\u786E\u5339\u914D").option("--product <name>", "\u5546\u54C1\u540D\u79F0\u6216\u7F16\u7801\u5305\u542B\u5339\u914D").option("--product-code <code>", "\u5546\u54C1\u7F16\u7801\u7CBE\u786E\u5339\u914D").option("--group-by <dimensions>", "department,store,product \u7684\u9017\u53F7\u7EC4\u5408\uFF0C\u6216 all").option("--limit <n>", "\u6BCF\u9875\u5206\u7EC4\u6570\uFF0C\u9ED8\u8BA4 100\uFF0C\u6700\u591A 1000").option("--offset <n>", "\u5206\u7EC4\u504F\u79FB\u91CF\uFF0C\u9ED8\u8BA4 0")
62138
+ ).action(async (opts, cmd) => {
62139
+ const params = {};
62140
+ for (const key of ["department", "store", "product"]) if (opts[key] !== void 0) params[key] = opts[key];
62141
+ if (opts.groupBy !== void 0) params.group_by = opts.groupBy;
62142
+ if (opts.productCode !== void 0) params.product_code = opts.productCode;
62143
+ for (const key of ["limit", "offset"]) {
62144
+ const value = parseOptionalInt(opts[key], `--${key}`);
62145
+ if (value !== void 0) params[key] = value;
62146
+ }
62147
+ await runSkillShortcutExecute(STORE_MANAGEMENT_SKILL, "store_inventory_summary", params, opts, cmd);
62148
+ });
61927
62149
  return store;
61928
62150
  }
61929
62151
 
@@ -62814,7 +63036,7 @@ async function pollVideoTask(opts, baseUrl4, model, taskId) {
62814
63036
  `\u751F\u89C6\u9891\u4EFB\u52A1 ${taskId} \u5728 ${timeoutSec}s \u5185\u672A\u5B8C\u6210\uFF0C\u53EF\u7528 creative +video-status --model ${model} --task-id ${taskId} \u7EE7\u7EED\u67E5\u8BE2`
62815
63037
  );
62816
63038
  }
62817
- await new Promise((resolve9) => setTimeout(resolve9, intervalSec * 1e3));
63039
+ await new Promise((resolve11) => setTimeout(resolve11, intervalSec * 1e3));
62818
63040
  }
62819
63041
  }
62820
63042
  function attachCreativeShortcuts(parent) {
@@ -62947,8 +63169,8 @@ function attachCreativeShortcuts(parent) {
62947
63169
  }
62948
63170
 
62949
63171
  // src/core/corporate-client.ts
62950
- var import_promises11 = require("fs/promises");
62951
- var import_undici9 = __toESM(require_undici(), 1);
63172
+ var import_promises14 = require("fs/promises");
63173
+ var import_undici10 = __toESM(require_undici(), 1);
62952
63174
  async function errorMessage2(status, text3) {
62953
63175
  try {
62954
63176
  const payload = JSON.parse(text3);
@@ -62958,7 +63180,7 @@ async function errorMessage2(status, text3) {
62958
63180
  }
62959
63181
  }
62960
63182
  async function runCorporateQuery(baseUrl4, payload) {
62961
- const response = await (0, import_undici9.request)(`${baseUrl4}/v1/corporate/query`, {
63183
+ const response = await (0, import_undici10.request)(`${baseUrl4}/v1/corporate/query`, {
62962
63184
  method: "POST",
62963
63185
  headers: {
62964
63186
  "content-type": "application/json",
@@ -62976,14 +63198,14 @@ async function runCorporateQuery(baseUrl4, payload) {
62976
63198
  }
62977
63199
  }
62978
63200
  async function downloadCorporateAttachment(baseUrl4, selector, output) {
62979
- const response = await (0, import_undici9.request)(`${baseUrl4}/v1/corporate/attachment`, {
63201
+ const response = await (0, import_undici10.request)(`${baseUrl4}/v1/corporate/attachment`, {
62980
63202
  method: "POST",
62981
63203
  headers: { "content-type": "application/json", ...vpsServiceAuthHeaders() },
62982
63204
  body: JSON.stringify(selector)
62983
63205
  });
62984
63206
  const bytes = Buffer.from(await response.body.arrayBuffer());
62985
63207
  if (response.statusCode >= 400) throw await errorMessage2(response.statusCode, bytes.toString("utf8"));
62986
- await (0, import_promises11.writeFile)(output, bytes, { flag: "wx" }).catch((error) => {
63208
+ await (0, import_promises14.writeFile)(output, bytes, { flag: "wx" }).catch((error) => {
62987
63209
  if (error.code === "EEXIST") throw new VertuError(`Output already exists: ${output}`);
62988
63210
  throw error;
62989
63211
  });
@@ -63195,7 +63417,7 @@ function buildCorporateCommand() {
63195
63417
  var import_node_crypto6 = require("crypto");
63196
63418
 
63197
63419
  // src/core/documents-client.ts
63198
- var import_undici10 = __toESM(require_undici(), 1);
63420
+ var import_undici11 = __toESM(require_undici(), 1);
63199
63421
  function buildPath2(path3, query2) {
63200
63422
  const search = new URLSearchParams();
63201
63423
  for (const [key, value] of Object.entries(query2 ?? {})) {
@@ -63220,7 +63442,7 @@ function errorMessage3(payload, statusCode) {
63220
63442
  }
63221
63443
  async function documentsRequest(method, path3, opts = {}) {
63222
63444
  const baseUrl4 = resolveVpsServiceUrl(opts.baseUrl);
63223
- const response = await (0, import_undici10.request)(`${baseUrl4}${buildPath2(path3, opts.query)}`, {
63445
+ const response = await (0, import_undici11.request)(`${baseUrl4}${buildPath2(path3, opts.query)}`, {
63224
63446
  method,
63225
63447
  headers: {
63226
63448
  accept: "application/json",
@@ -64337,6 +64559,150 @@ Agent block-format workflow:
64337
64559
  return documents;
64338
64560
  }
64339
64561
 
64562
+ // src/commands/office/index.ts
64563
+ var import_node_path13 = require("path");
64564
+
64565
+ // src/core/office-files.ts
64566
+ var import_node_crypto7 = require("crypto");
64567
+ var import_promises15 = require("fs/promises");
64568
+ var import_node_module = require("module");
64569
+ var import_node_path11 = require("path");
64570
+ function officeRuntime() {
64571
+ const path3 = (0, import_node_path11.join)(packageRootDir(), "dist/office-runtime.cjs");
64572
+ try {
64573
+ return (0, import_node_module.createRequire)(path3)(path3);
64574
+ } catch (error) {
64575
+ throw new Error(`Office runtime \u65E0\u6CD5\u52A0\u8F7D\uFF0C\u8BF7\u91CD\u65B0\u5B89\u88C5\u5B8C\u6574 vps-work \u5305\uFF08\u6E90\u7801\u5F00\u53D1\u5148 npm run build\uFF09\u3002${String(error)}`);
64576
+ }
64577
+ }
64578
+ function officeFormat(path3) {
64579
+ const format = (0, import_node_path11.extname)(path3).slice(1).toLowerCase();
64580
+ if (!["docx", "xlsx", "pptx", "md"].includes(format)) throw new Error("\u652F\u6301 .docx / .xlsx / .pptx / .md\u3002");
64581
+ return format;
64582
+ }
64583
+ function officeVersion(bytes) {
64584
+ return (0, import_node_crypto7.createHash)("sha256").update(bytes).digest("hex");
64585
+ }
64586
+ async function readOfficeFile(path3) {
64587
+ const file = await (0, import_promises15.realpath)(path3);
64588
+ const bytes = await (0, import_promises15.readFile)(file);
64589
+ const format = officeFormat(file);
64590
+ return { file, format, version: officeVersion(bytes), content: await officeRuntime().readDocument(format, bytes) };
64591
+ }
64592
+ async function writeAtomic(path3, bytes, expected) {
64593
+ const file = expected === void 0 ? (0, import_node_path11.resolve)(path3) : await (0, import_promises15.realpath)(path3);
64594
+ const lock = `${file}.vps-office.lock`;
64595
+ const handle = await (0, import_promises15.open)(lock, "wx", 384).catch(() => {
64596
+ throw new Error(`\u6587\u4EF6\u6B63\u5728\u4FEE\u6539\u6216\u5B58\u5728\u672A\u6E05\u7406\u9501\uFF1A${lock}`);
64597
+ });
64598
+ const temp = (0, import_node_path11.join)((0, import_node_path11.dirname)(file), `.${(0, import_node_crypto7.randomUUID)()}.office.tmp`);
64599
+ try {
64600
+ const mode = expected === void 0 ? 384 : (await (0, import_promises15.stat)(file)).mode;
64601
+ const output = await (0, import_promises15.open)(temp, "wx", mode);
64602
+ try {
64603
+ await output.writeFile(bytes);
64604
+ await output.sync();
64605
+ } finally {
64606
+ await output.close();
64607
+ }
64608
+ if (expected !== void 0) {
64609
+ if (officeVersion(await (0, import_promises15.readFile)(file)) !== expected) throw new Error("\u6587\u4EF6\u7248\u672C\u51B2\u7A81\uFF0C\u8BF7\u91CD\u65B0\u8BFB\u53D6\u540E\u4FEE\u6539\u3002");
64610
+ await (0, import_promises15.rename)(temp, file);
64611
+ } else {
64612
+ await (0, import_promises15.link)(temp, file);
64613
+ }
64614
+ } finally {
64615
+ await (0, import_promises15.rm)(temp, { force: true });
64616
+ await handle.close();
64617
+ await (0, import_promises15.rm)(lock, { force: true });
64618
+ }
64619
+ }
64620
+ async function createOfficeFile(path3, spec) {
64621
+ const format = officeFormat(path3);
64622
+ const bytes = await officeRuntime().createDocument(format, spec);
64623
+ await officeRuntime().readDocument(format, bytes);
64624
+ await writeAtomic(path3, bytes);
64625
+ return { file: (0, import_node_path11.resolve)(path3), format, version: officeVersion(bytes), size: bytes.length };
64626
+ }
64627
+ async function applyOfficeFile(path3, changes, expected, output, dryRun = false) {
64628
+ const file = await (0, import_promises15.realpath)(path3);
64629
+ const format = officeFormat(file);
64630
+ if (output && officeFormat(output) !== format) throw new Error("\u8F93\u51FA\u6587\u4EF6\u6269\u5C55\u540D\u5FC5\u987B\u4E0E\u6E90\u6587\u4EF6\u76F8\u540C\u3002");
64631
+ const original = await (0, import_promises15.readFile)(file);
64632
+ if (officeVersion(original) !== expected) throw new Error("\u6587\u4EF6\u7248\u672C\u51B2\u7A81\uFF0C\u8BF7\u91CD\u65B0\u8BFB\u53D6\u540E\u4FEE\u6539\u3002");
64633
+ const bytes = await officeRuntime().applyDocument(format, original, changes);
64634
+ const content = await officeRuntime().readDocument(format, bytes);
64635
+ if (!dryRun) await writeAtomic(output ?? file, bytes, output && (0, import_node_path11.resolve)(output) !== file ? void 0 : expected);
64636
+ return { file: (0, import_node_path11.resolve)(output ?? file), format, version: officeVersion(bytes), previousVersion: expected, dryRun, content };
64637
+ }
64638
+
64639
+ // src/core/office-client.ts
64640
+ var import_promises16 = require("fs/promises");
64641
+ var import_node_path12 = require("path");
64642
+ async function officeRequest(action2, body = {}, connectionFile) {
64643
+ const path3 = connectionFile ?? process.env.VPS_OFFICE_CONNECTION_FILE ?? (0, import_node_path12.join)(homeDir(), "office.json");
64644
+ let config;
64645
+ try {
64646
+ config = JSON.parse(await (0, import_promises16.readFile)(path3, "utf8"));
64647
+ } catch {
64648
+ throw new Error("\u672A\u53D1\u73B0\u672C\u673A VPS Office\u3002\u8BF7\u542F\u52A8\u65B0\u7248 VPS \u684C\u9762\u7AEF\uFF0C\u6216\u8BBE\u7F6E VPS_OFFICE_CONNECTION_FILE\u3002");
64649
+ }
64650
+ const url = new URL(config.url);
64651
+ if (url.protocol !== "http:" || url.hostname !== "127.0.0.1" || url.username || url.password || !config.token || config.protocolVersion !== 1) throw new Error("Office \u8FDE\u63A5\u914D\u7F6E\u65E0\u6548\u3002");
64652
+ const response = await fetch(new URL(`/office/${action2}`, url), {
64653
+ method: "POST",
64654
+ redirect: "error",
64655
+ signal: AbortSignal.timeout(12e4),
64656
+ headers: { "Content-Type": "application/json", Authorization: `Bearer ${config.token}` },
64657
+ body: JSON.stringify(body)
64658
+ });
64659
+ const result = await response.json();
64660
+ if (!response.ok) throw new Error(result.error ?? `Office HTTP ${response.status}`);
64661
+ return result;
64662
+ }
64663
+
64664
+ // src/commands/office/index.ts
64665
+ var print4 = (value) => console.log(JSON.stringify(value, null, 2));
64666
+ async function jsonFile(path3) {
64667
+ return JSON.parse(path3 === "-" ? await readStdinText() : await readUtf8File(path3));
64668
+ }
64669
+ function buildOfficeCommand() {
64670
+ const office = new Command("office").description("VPS Office\uFF1A\u672C\u5730\u6587\u4EF6\u751F\u6210\u3001\u7ED3\u6784\u5316\u8BFB\u5199\u548C\u684C\u9762\u7F16\u8F91\u4F1A\u8BDD");
64671
+ office.command("+schema").description("\u83B7\u53D6\u683C\u5F0F\u80FD\u529B\u3001\u64CD\u4F5C\u8BF4\u660E\u548C\u751F\u6210\u793A\u4F8B").action(() => print4(officeRuntime().capabilities()));
64672
+ office.command("+create").description("\u751F\u6210 Office \u6587\u4EF6\uFF08\u76EE\u6807\u5FC5\u987B\u4E0D\u5B58\u5728\uFF09").requiredOption("--output <path>").requiredOption("--spec-file <path>", "JSON \u6587\u4EF6\uFF1B- \u8868\u793A stdin").action(async (opts) => print4(await createOfficeFile(opts.output, await jsonFile(opts.specFile))));
64673
+ office.command("+read").description("\u8BFB\u53D6\u6587\u4EF6\u7ED3\u6784\u548C SHA-256 \u7248\u672C").requiredOption("--file <path>").action(async (opts) => print4(await readOfficeFile(opts.file)));
64674
+ office.command("+apply").description("\u6821\u9A8C\u7248\u672C\u5E76\u6574\u6279\u4FEE\u6539\u6587\u4EF6\uFF1B\u5931\u8D25\u4E0D\u5199\u5165").requiredOption("--file <path>").requiredOption("--ops-file <path>").requiredOption("--expected-version <sha256>").option("--output <path>", "\u53E6\u5B58\u4E3A\u65B0\u6587\u4EF6").option("--dry-run", "\u8BA1\u7B97\u4FEE\u6539\u7ED3\u679C\u4F46\u4E0D\u5199\u5165").action(async (opts) => print4(await applyOfficeFile(opts.file, await jsonFile(opts.opsFile), opts.expectedVersion, opts.output, opts.dryRun)));
64675
+ const connected = (command) => command.option("--connection-file <path>", "\u684C\u9762\u7AEF\u751F\u6210\u7684\u8FDE\u63A5\u51ED\u636E\u6587\u4EF6");
64676
+ connected(office.command("+new").description("\u5728 VPS Office \u684C\u9762\u7AEF\u65B0\u5EFA\u7A7A\u767D\u6587\u6863").requiredOption("--type <type>", "docx / xlsx / pptx / md / pdf")).action(async (opts) => {
64677
+ if (!["docx", "xlsx", "pptx", "md", "pdf"].includes(opts.type)) throw new Error("--type \u652F\u6301 docx / xlsx / pptx / md / pdf");
64678
+ print4(await officeRequest("open", { kind: opts.type }, opts.connectionFile));
64679
+ });
64680
+ connected(office.command("+status").description("\u68C0\u67E5\u684C\u9762 Office \u6865\u63A5\u72B6\u6001")).action(async (opts) => print4(await officeRequest("status", {}, opts.connectionFile)));
64681
+ connected(office.command("+open").description("\u5728 VPS Office \u4E2D\u6253\u5F00\u672C\u5730\u6587\u4EF6\u6216 V\u76D8\u9879\u76EE").option("--file <path>").option("--item-id <id>")).action(async (opts) => {
64682
+ if (Boolean(opts.file) === Boolean(opts.itemId)) throw new Error("\u8BF7\u53EA\u6307\u5B9A --file \u6216 --item-id\u3002");
64683
+ print4(await officeRequest("open", opts.file ? { filePath: (0, import_node_path13.resolve)(opts.file) } : { itemId: opts.itemId }, opts.connectionFile));
64684
+ });
64685
+ connected(office.command("+sessions").description("\u5217\u51FA\u6B63\u5728\u7F16\u8F91\u7684 Office \u6587\u6863")).action(async (opts) => print4(await officeRequest("sessions", {}, opts.connectionFile)));
64686
+ connected(office.command("+tools").description("\u53D1\u73B0\u5F53\u524D\u7F16\u8F91\u5668\u7684\u539F\u751F\u5DE5\u5177\u548C\u53C2\u6570 schema").requiredOption("--session-id <id>")).action(async (opts) => print4(await officeRequest("session-tools", { sessionId: opts.sessionId }, opts.connectionFile)));
64687
+ connected(office.command("+call").description("\u8C03\u7528\u684C\u9762\u7F16\u8F91\u5668\u539F\u751F\u5DE5\u5177\uFF1B\u5148\u7528 +tools \u53D1\u73B0\u53C2\u6570").requiredOption("--session-id <id>").requiredOption("--tool <name>").requiredOption("--args-file <path>").requiredOption("--expected-version <version>")).action(async (opts) => {
64688
+ const result = await officeRequest("session-apply", {
64689
+ sessionId: opts.sessionId,
64690
+ expectedVersion: opts.expectedVersion,
64691
+ changes: { tool: opts.tool, arguments: await jsonFile(opts.argsFile) }
64692
+ }, opts.connectionFile);
64693
+ print4(result);
64694
+ if (result.result?.isError) process.exitCode = 1;
64695
+ });
64696
+ connected(office.command("+session-read").description("\u8BFB\u53D6\u6B63\u5728\u7F16\u8F91\u7684\u6587\u6863\uFF0C\u5305\u62EC\u672A\u4FDD\u5B58\u5185\u5BB9\u4E0E\u4F1A\u8BDD\u7248\u672C").requiredOption("--session-id <id>")).action(async (opts) => print4(await officeRequest("session-read", { sessionId: opts.sessionId }, opts.connectionFile)));
64697
+ connected(office.command("+session-apply").description("\u6267\u884C JSON {tool,arguments} \u539F\u751F\u5DE5\u5177\u8C03\u7528").requiredOption("--session-id <id>").requiredOption("--expected-version <version>").requiredOption("--ops-file <path>")).action(async (opts) => {
64698
+ const result = await officeRequest("session-apply", { sessionId: opts.sessionId, expectedVersion: opts.expectedVersion, changes: await jsonFile(opts.opsFile) }, opts.connectionFile);
64699
+ print4(result);
64700
+ if (result.result?.isError) process.exitCode = 1;
64701
+ });
64702
+ connected(office.command("+session-save").description("\u901A\u8FC7\u684C\u9762\u7F16\u8F91\u5668\u4FDD\u5B58\u5F53\u524D\u6587\u6863").requiredOption("--session-id <id>").requiredOption("--expected-version <version>")).action(async (opts) => print4(await officeRequest("session-save", { sessionId: opts.sessionId, expectedVersion: opts.expectedVersion }, opts.connectionFile)));
64703
+ return office;
64704
+ }
64705
+
64340
64706
  // src/commands/knowledge/index.ts
64341
64707
  var SKILL3 = "vps-knowledge";
64342
64708
  function action(parent, name, description, script, configure) {
@@ -64373,24 +64739,24 @@ function buildKnowledgeCommand() {
64373
64739
  }
64374
64740
 
64375
64741
  // src/commands/drive/index.ts
64376
- var import_node_fs6 = require("fs");
64377
- var import_promises12 = require("fs/promises");
64378
- var import_node_path11 = require("path");
64379
- var import_promises13 = require("stream/promises");
64380
- var import_undici11 = __toESM(require_undici(), 1);
64742
+ var import_node_fs7 = require("fs");
64743
+ var import_promises17 = require("fs/promises");
64744
+ var import_node_path15 = require("path");
64745
+ var import_promises18 = require("stream/promises");
64746
+ var import_undici12 = __toESM(require_undici(), 1);
64381
64747
 
64382
64748
  // src/core/v-drive-store.ts
64383
- var import_node_crypto7 = require("crypto");
64384
- var import_node_fs5 = require("fs");
64749
+ var import_node_crypto8 = require("crypto");
64750
+ var import_node_fs6 = require("fs");
64385
64751
  var import_node_os3 = require("os");
64386
- var import_node_path10 = require("path");
64752
+ var import_node_path14 = require("path");
64387
64753
  var EMPTY_DATABASE = { items: [], spaces: [], transfers: [] };
64388
64754
  function cleanName(value, fallback) {
64389
64755
  const name = String(value ?? "").trim().replaceAll("/", "-").replaceAll("\\", "-");
64390
64756
  return name.slice(0, 160) || fallback;
64391
64757
  }
64392
64758
  function mimeFromName(name) {
64393
- const extension = (0, import_node_path10.extname)(name).toLowerCase();
64759
+ const extension = (0, import_node_path14.extname)(name).toLowerCase();
64394
64760
  const types = {
64395
64761
  ".csv": "text/csv",
64396
64762
  ".doc": "application/msword",
@@ -64425,25 +64791,25 @@ function mimeFromName(name) {
64425
64791
  }
64426
64792
  function defaultVDriveRoot() {
64427
64793
  const override = process.env.VERTU_V_DRIVE_ROOT?.trim();
64428
- if (override) return (0, import_node_path10.resolve)(override);
64794
+ if (override) return (0, import_node_path14.resolve)(override);
64429
64795
  if (process.platform === "darwin") {
64430
- return (0, import_node_path10.join)((0, import_node_os3.homedir)(), "Library", "Application Support", "vertu-im-desktop", "v-drive");
64796
+ return (0, import_node_path14.join)((0, import_node_os3.homedir)(), "Library", "Application Support", "vertu-im-desktop", "v-drive");
64431
64797
  }
64432
64798
  if (process.platform === "win32") {
64433
- const appData = process.env.APPDATA?.trim() || (0, import_node_path10.join)((0, import_node_os3.homedir)(), "AppData", "Roaming");
64434
- return (0, import_node_path10.join)(appData, "vertu-im-desktop", "v-drive");
64799
+ const appData = process.env.APPDATA?.trim() || (0, import_node_path14.join)((0, import_node_os3.homedir)(), "AppData", "Roaming");
64800
+ return (0, import_node_path14.join)(appData, "vertu-im-desktop", "v-drive");
64435
64801
  }
64436
- const configRoot = process.env.XDG_CONFIG_HOME?.trim() || (0, import_node_path10.join)((0, import_node_os3.homedir)(), ".config");
64437
- return (0, import_node_path10.join)(configRoot, "vertu-im-desktop", "v-drive");
64802
+ const configRoot = process.env.XDG_CONFIG_HOME?.trim() || (0, import_node_path14.join)((0, import_node_os3.homedir)(), ".config");
64803
+ return (0, import_node_path14.join)(configRoot, "vertu-im-desktop", "v-drive");
64438
64804
  }
64439
64805
  var VDriveStore = class {
64440
64806
  root;
64441
64807
  filesDir;
64442
64808
  databasePath;
64443
64809
  constructor(root = defaultVDriveRoot()) {
64444
- this.root = (0, import_node_path10.resolve)(root);
64445
- this.filesDir = (0, import_node_path10.join)(this.root, "files");
64446
- this.databasePath = (0, import_node_path10.join)(this.root, "index.json");
64810
+ this.root = (0, import_node_path14.resolve)(root);
64811
+ this.filesDir = (0, import_node_path14.join)(this.root, "files");
64812
+ this.databasePath = (0, import_node_path14.join)(this.root, "index.json");
64447
64813
  }
64448
64814
  list(parentId2, recursive, query2) {
64449
64815
  const database = this.read();
@@ -64479,7 +64845,7 @@ var VDriveStore = class {
64479
64845
  this.assertFolder(database, parentId2);
64480
64846
  const now = (/* @__PURE__ */ new Date()).toISOString();
64481
64847
  const item = {
64482
- id: (0, import_node_crypto7.randomUUID)(),
64848
+ id: (0, import_node_crypto8.randomUUID)(),
64483
64849
  name: cleanName(name, "\u65B0\u5EFA\u6587\u4EF6\u5939"),
64484
64850
  kind: "folder",
64485
64851
  parentId: parentId2,
@@ -64498,12 +64864,12 @@ var VDriveStore = class {
64498
64864
  createTextFile(parentId2, name, content, actor) {
64499
64865
  const database = this.read();
64500
64866
  this.assertFolder(database, parentId2);
64501
- const id = (0, import_node_crypto7.randomUUID)();
64867
+ const id = (0, import_node_crypto8.randomUUID)();
64502
64868
  const now = (/* @__PURE__ */ new Date()).toISOString();
64503
64869
  const fileName = cleanName(name, "\u65B0\u5EFA\u6587\u672C.txt");
64504
- const storedName = `${id}${(0, import_node_path10.extname)(fileName) || ".txt"}`;
64870
+ const storedName = `${id}${(0, import_node_path14.extname)(fileName) || ".txt"}`;
64505
64871
  this.ensureRoot();
64506
- (0, import_node_fs5.writeFileSync)((0, import_node_path10.join)(this.filesDir, storedName), content, "utf8");
64872
+ (0, import_node_fs6.writeFileSync)((0, import_node_path14.join)(this.filesDir, storedName), content, "utf8");
64507
64873
  const item = {
64508
64874
  id,
64509
64875
  name: fileName,
@@ -64525,21 +64891,21 @@ var VDriveStore = class {
64525
64891
  const database = this.read();
64526
64892
  this.assertFolder(database, parentId2);
64527
64893
  const sourcePaths = paths.map((rawPath) => {
64528
- const sourcePath = (0, import_node_path10.resolve)(rawPath);
64529
- if (!(0, import_node_fs5.existsSync)(sourcePath) || !(0, import_node_fs5.statSync)(sourcePath).isFile()) {
64894
+ const sourcePath = (0, import_node_path14.resolve)(rawPath);
64895
+ if (!(0, import_node_fs6.existsSync)(sourcePath) || !(0, import_node_fs6.statSync)(sourcePath).isFile()) {
64530
64896
  throw new VertuError(`\u4E0A\u4F20\u6E90\u6587\u4EF6\u4E0D\u5B58\u5728\u6216\u4E0D\u662F\u666E\u901A\u6587\u4EF6\uFF1A${rawPath}`);
64531
64897
  }
64532
64898
  return sourcePath;
64533
64899
  });
64534
64900
  const imported = [];
64535
64901
  for (const sourcePath of sourcePaths) {
64536
- const id = (0, import_node_crypto7.randomUUID)();
64902
+ const id = (0, import_node_crypto8.randomUUID)();
64537
64903
  const now = (/* @__PURE__ */ new Date()).toISOString();
64538
- const name = cleanName((0, import_node_path10.basename)(sourcePath), "\u672A\u547D\u540D\u6587\u4EF6");
64539
- const storedName = `${id}${(0, import_node_path10.extname)(name)}`;
64904
+ const name = cleanName((0, import_node_path14.basename)(sourcePath), "\u672A\u547D\u540D\u6587\u4EF6");
64905
+ const storedName = `${id}${(0, import_node_path14.extname)(name)}`;
64540
64906
  this.ensureRoot();
64541
- (0, import_node_fs5.copyFileSync)(sourcePath, (0, import_node_path10.join)(this.filesDir, storedName));
64542
- const sizeBytes = (0, import_node_fs5.statSync)(sourcePath).size;
64907
+ (0, import_node_fs6.copyFileSync)(sourcePath, (0, import_node_path14.join)(this.filesDir, storedName));
64908
+ const sizeBytes = (0, import_node_fs6.statSync)(sourcePath).size;
64543
64909
  const item = {
64544
64910
  id,
64545
64911
  name,
@@ -64556,7 +64922,7 @@ var VDriveStore = class {
64556
64922
  database.items.push(item);
64557
64923
  imported.push(item);
64558
64924
  database.transfers.unshift({
64559
- id: (0, import_node_crypto7.randomUUID)(),
64925
+ id: (0, import_node_crypto8.randomUUID)(),
64560
64926
  direction: "upload",
64561
64927
  name,
64562
64928
  sizeBytes,
@@ -64571,12 +64937,12 @@ var VDriveStore = class {
64571
64937
  readFile(itemId) {
64572
64938
  const database = this.read();
64573
64939
  const item = this.requireFile(database, itemId);
64574
- return { item: this.publicItem(item), bytes: (0, import_node_fs5.readFileSync)(this.filePathFor(item)) };
64940
+ return { item: this.publicItem(item), bytes: (0, import_node_fs6.readFileSync)(this.filePathFor(item)) };
64575
64941
  }
64576
64942
  writeText(itemId, content, actor) {
64577
64943
  const database = this.read();
64578
64944
  const item = this.requireFile(database, itemId);
64579
- (0, import_node_fs5.writeFileSync)(this.filePathFor(item), content, "utf8");
64945
+ (0, import_node_fs6.writeFileSync)(this.filePathFor(item), content, "utf8");
64580
64946
  item.sizeBytes = Buffer.byteLength(content);
64581
64947
  item.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
64582
64948
  item.updatedBy = actor;
@@ -64586,15 +64952,15 @@ var VDriveStore = class {
64586
64952
  download(itemId, outputPath, overwrite) {
64587
64953
  const database = this.read();
64588
64954
  const item = this.requireFile(database, itemId);
64589
- const requested = (0, import_node_path10.resolve)(outputPath);
64590
- const target = (0, import_node_fs5.existsSync)(requested) && (0, import_node_fs5.statSync)(requested).isDirectory() ? (0, import_node_path10.join)(requested, item.name) : requested;
64591
- if ((0, import_node_fs5.existsSync)(target) && !overwrite) {
64955
+ const requested = (0, import_node_path14.resolve)(outputPath);
64956
+ const target = (0, import_node_fs6.existsSync)(requested) && (0, import_node_fs6.statSync)(requested).isDirectory() ? (0, import_node_path14.join)(requested, item.name) : requested;
64957
+ if ((0, import_node_fs6.existsSync)(target) && !overwrite) {
64592
64958
  throw new VertuError(`\u76EE\u6807\u6587\u4EF6\u5DF2\u5B58\u5728\uFF1A${target}\uFF1B\u5982\u9700\u8986\u76D6\u8BF7\u663E\u5F0F\u4F20 --overwrite\u3002`);
64593
64959
  }
64594
- (0, import_node_fs5.mkdirSync)((0, import_node_path10.dirname)(target), { recursive: true });
64595
- (0, import_node_fs5.copyFileSync)(this.filePathFor(item), target);
64960
+ (0, import_node_fs6.mkdirSync)((0, import_node_path14.dirname)(target), { recursive: true });
64961
+ (0, import_node_fs6.copyFileSync)(this.filePathFor(item), target);
64596
64962
  database.transfers.unshift({
64597
- id: (0, import_node_crypto7.randomUUID)(),
64963
+ id: (0, import_node_crypto8.randomUUID)(),
64598
64964
  direction: "download",
64599
64965
  name: item.name,
64600
64966
  sizeBytes: item.sizeBytes,
@@ -64669,7 +65035,7 @@ var VDriveStore = class {
64669
65035
  };
64670
65036
  for (const item of database.items) {
64671
65037
  if (item.trashRootId === itemId && item.storedName) {
64672
- (0, import_node_fs5.rmSync)((0, import_node_path10.join)(this.filesDir, item.storedName), { force: true });
65038
+ (0, import_node_fs6.rmSync)((0, import_node_path14.join)(this.filesDir, item.storedName), { force: true });
64673
65039
  }
64674
65040
  }
64675
65041
  database.items = database.items.filter((item) => item.trashRootId !== itemId);
@@ -64681,7 +65047,7 @@ var VDriveStore = class {
64681
65047
  const purgedItems = database.items.filter((item) => item.deletedAt).length;
64682
65048
  for (const item of database.items) {
64683
65049
  if (item.deletedAt && item.storedName) {
64684
- (0, import_node_fs5.rmSync)((0, import_node_path10.join)(this.filesDir, item.storedName), { force: true });
65050
+ (0, import_node_fs6.rmSync)((0, import_node_path14.join)(this.filesDir, item.storedName), { force: true });
64685
65051
  }
64686
65052
  }
64687
65053
  database.items = database.items.filter((item) => !item.deletedAt);
@@ -64689,15 +65055,15 @@ var VDriveStore = class {
64689
65055
  return { purgedItems };
64690
65056
  }
64691
65057
  ensureRoot() {
64692
- (0, import_node_fs5.mkdirSync)(this.filesDir, { recursive: true });
65058
+ (0, import_node_fs6.mkdirSync)(this.filesDir, { recursive: true });
64693
65059
  }
64694
65060
  read() {
64695
65061
  this.ensureRoot();
64696
- if (!(0, import_node_fs5.existsSync)(this.databasePath)) {
65062
+ if (!(0, import_node_fs6.existsSync)(this.databasePath)) {
64697
65063
  return { ...EMPTY_DATABASE, items: [], spaces: [], transfers: [] };
64698
65064
  }
64699
65065
  try {
64700
- const parsed = JSON.parse((0, import_node_fs5.readFileSync)(this.databasePath, "utf8"));
65066
+ const parsed = JSON.parse((0, import_node_fs6.readFileSync)(this.databasePath, "utf8"));
64701
65067
  return {
64702
65068
  items: Array.isArray(parsed.items) ? parsed.items : [],
64703
65069
  spaces: Array.isArray(parsed.spaces) ? parsed.spaces : [],
@@ -64709,7 +65075,7 @@ var VDriveStore = class {
64709
65075
  }
64710
65076
  write(database) {
64711
65077
  this.ensureRoot();
64712
- (0, import_node_fs5.writeFileSync)(this.databasePath, JSON.stringify(database, null, 2), "utf8");
65078
+ (0, import_node_fs6.writeFileSync)(this.databasePath, JSON.stringify(database, null, 2), "utf8");
64713
65079
  }
64714
65080
  publicItem(item) {
64715
65081
  const {
@@ -64739,8 +65105,8 @@ var VDriveStore = class {
64739
65105
  }
64740
65106
  filePathFor(item) {
64741
65107
  if (!item.storedName) throw new VertuError("\u6587\u4EF6\u5185\u5BB9\u4E0D\u5B58\u5728\u3002");
64742
- const filePath = (0, import_node_path10.join)(this.filesDir, item.storedName);
64743
- if (!(0, import_node_fs5.existsSync)(filePath)) throw new VertuError("\u6587\u4EF6\u5185\u5BB9\u4E0D\u5B58\u5728\u3002");
65108
+ const filePath = (0, import_node_path14.join)(this.filesDir, item.storedName);
65109
+ if (!(0, import_node_fs6.existsSync)(filePath)) throw new VertuError("\u6587\u4EF6\u5185\u5BB9\u4E0D\u5B58\u5728\u3002");
64744
65110
  return filePath;
64745
65111
  }
64746
65112
  descendantIds(database, itemId) {
@@ -64779,13 +65145,13 @@ function records(value) {
64779
65145
  function itemFrom(value) {
64780
65146
  return record2(record2(value).item, "V\u76D8\u670D\u52A1\u672A\u8FD4\u56DE\u9879\u76EE\u3002");
64781
65147
  }
64782
- function print4(payload) {
65148
+ function print5(payload) {
64783
65149
  console.log(JSON.stringify(payload, null, 2));
64784
65150
  }
64785
65151
  function attachBaseOption(command) {
64786
65152
  return command.option("--base-url <url>", "Override Vertu service URL");
64787
65153
  }
64788
- function collect(value, previous) {
65154
+ function collect2(value, previous) {
64789
65155
  return [...previous, value];
64790
65156
  }
64791
65157
  function positiveInteger2(value, flag) {
@@ -64827,7 +65193,7 @@ function mimeType2(name) {
64827
65193
  ".xlsx": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
64828
65194
  ".zip": "application/zip"
64829
65195
  };
64830
- return types[(0, import_node_path11.extname)(name).toLowerCase()] ?? "application/octet-stream";
65196
+ return types[(0, import_node_path15.extname)(name).toLowerCase()] ?? "application/octet-stream";
64831
65197
  }
64832
65198
  async function driveGet(opts, view) {
64833
65199
  return record2(await imRequest("GET", "/v1/v-drive", {
@@ -64841,13 +65207,15 @@ async function driveAction(opts, action2, body = {}) {
64841
65207
  body: { action: action2, ...body }
64842
65208
  }));
64843
65209
  }
64844
- async function putOss(uploadUrl, body, size, type) {
64845
- const response = await (0, import_undici11.request)(uploadUrl, {
65210
+ async function putOss(uploadUrl, body, size, type, signedHeaders = {}) {
65211
+ const response = await (0, import_undici12.request)(uploadUrl, {
64846
65212
  method: "PUT",
64847
- headers: { "content-type": type, "content-length": String(size) },
65213
+ headers: { "content-type": type, "content-length": String(size), ...Object.fromEntries(
65214
+ Object.entries(signedHeaders).map(([key, value]) => [key, String(value)])
65215
+ ) },
64848
65216
  body
64849
65217
  });
64850
- if (response.statusCode >= 400) {
65218
+ if (response.statusCode < 200 || response.statusCode >= 300) {
64851
65219
  const message = await response.body.text();
64852
65220
  throw new VertuError(`OSS \u4E0A\u4F20\u5931\u8D25\uFF1AHTTP ${response.statusCode}${message ? ` ${message.slice(0, 200)}` : ""}`);
64853
65221
  }
@@ -64862,8 +65230,40 @@ async function uploadContent(opts, input) {
64862
65230
  });
64863
65231
  const uploadUrl = String(initialized.upload_url ?? "");
64864
65232
  const storageKey = String(initialized.storage_key ?? "");
64865
- if (!uploadUrl || !storageKey) throw new VertuError("V\u76D8\u670D\u52A1\u672A\u8FD4\u56DE OSS \u4E0A\u4F20\u5730\u5740\u3002");
64866
- await putOss(uploadUrl, input.body, input.size, input.type);
65233
+ if (!storageKey) throw new VertuError("V\u76D8\u670D\u52A1\u672A\u8FD4\u56DE OSS \u5B58\u50A8\u8DEF\u5F84\u3002");
65234
+ try {
65235
+ if (initialized.upload_type === "multipart") {
65236
+ const partSize = Number(initialized.part_size);
65237
+ const urls = initialized.part_urls;
65238
+ if (!Number.isSafeInteger(partSize) || partSize <= 0 || !Array.isArray(urls) || urls.length !== Math.ceil(input.size / partSize) || urls.some((url) => typeof url !== "string" || !url)) {
65239
+ throw new VertuError("V\u76D8\u670D\u52A1\u8FD4\u56DE\u7684 OSS \u5206\u7247\u4E0A\u4F20\u53C2\u6570\u65E0\u6548\u3002");
65240
+ }
65241
+ for (let index = 0; index < urls.length; index += 1) {
65242
+ const start = index * partSize;
65243
+ const size = Math.min(partSize, input.size - start);
65244
+ const body = Buffer.isBuffer(input.body) ? input.body.subarray(start, start + size) : (0, import_node_fs7.createReadStream)(input.body, { start, end: start + size - 1 });
65245
+ await putOss(
65246
+ String(urls[index]),
65247
+ body,
65248
+ size,
65249
+ "application/octet-stream",
65250
+ initialized.part_headers ? record2(initialized.part_headers) : {}
65251
+ );
65252
+ }
65253
+ } else {
65254
+ if (!uploadUrl) throw new VertuError("V\u76D8\u670D\u52A1\u672A\u8FD4\u56DE OSS \u4E0A\u4F20\u5730\u5740\u3002");
65255
+ await putOss(
65256
+ uploadUrl,
65257
+ Buffer.isBuffer(input.body) ? input.body : (0, import_node_fs7.createReadStream)(input.body),
65258
+ input.size,
65259
+ input.type,
65260
+ initialized.headers ? record2(initialized.headers) : {}
65261
+ );
65262
+ }
65263
+ } catch (error) {
65264
+ await driveAction(opts, "upload-abort", { storage_key: storageKey }).catch(() => void 0);
65265
+ throw error;
65266
+ }
64867
65267
  return driveAction(opts, input.itemId ? "replace-complete" : "upload-complete", {
64868
65268
  ...input.itemId ? { item_id: input.itemId } : { name: input.name, parent_id: input.parentId ?? null },
64869
65269
  mime_type: input.type,
@@ -64872,10 +65272,10 @@ async function uploadContent(opts, input) {
64872
65272
  });
64873
65273
  }
64874
65274
  async function uploadFile(opts, path3, targetParentId) {
64875
- const source = (0, import_node_path11.resolve)(path3);
64876
- if (!(0, import_node_fs6.existsSync)(source) || !(0, import_node_fs6.statSync)(source).isFile()) throw new VertuError(`\u6E90\u6587\u4EF6\u4E0D\u5B58\u5728\uFF1A${path3}`);
64877
- const size = (0, import_node_fs6.statSync)(source).size;
64878
- const name = (0, import_node_path11.basename)(source);
65275
+ const source = (0, import_node_path15.resolve)(path3);
65276
+ if (!(0, import_node_fs7.existsSync)(source) || !(0, import_node_fs7.statSync)(source).isFile()) throw new VertuError(`\u6E90\u6587\u4EF6\u4E0D\u5B58\u5728\uFF1A${path3}`);
65277
+ const size = (0, import_node_fs7.statSync)(source).size;
65278
+ const name = (0, import_node_path15.basename)(source);
64879
65279
  if (size === 0) {
64880
65280
  return driveAction(opts, "create-file", { name, parent_id: targetParentId });
64881
65281
  }
@@ -64884,7 +65284,7 @@ async function uploadFile(opts, path3, targetParentId) {
64884
65284
  parentId: targetParentId,
64885
65285
  type: mimeType2(name),
64886
65286
  size,
64887
- body: (0, import_node_fs6.createReadStream)(source)
65287
+ body: source
64888
65288
  });
64889
65289
  }
64890
65290
  async function downloadResponse(opts, id) {
@@ -64893,7 +65293,7 @@ async function downloadResponse(opts, id) {
64893
65293
  if (result.empty_text_file === true) return { item, response: null };
64894
65294
  const url = String(result.download_url ?? "");
64895
65295
  if (!url) throw new VertuError("V\u76D8\u670D\u52A1\u672A\u8FD4\u56DE OSS \u4E0B\u8F7D\u5730\u5740\u3002");
64896
- const response = await (0, import_undici11.request)(url);
65296
+ const response = await (0, import_undici12.request)(url);
64897
65297
  if (response.statusCode >= 400) {
64898
65298
  await response.body.dump();
64899
65299
  throw new VertuError(`OSS \u4E0B\u8F7D\u5931\u8D25\uFF1AHTTP ${response.statusCode}`);
@@ -64923,9 +65323,9 @@ function scopedItems(items, parent, recursive, query2) {
64923
65323
  });
64924
65324
  }
64925
65325
  function migrationState(path3) {
64926
- if (!(0, import_node_fs6.existsSync)(path3)) return { items: {}, spaces: {} };
65326
+ if (!(0, import_node_fs7.existsSync)(path3)) return { items: {}, spaces: {} };
64927
65327
  try {
64928
- const parsed = JSON.parse((0, import_node_fs6.readFileSync)(path3, "utf8"));
65328
+ const parsed = JSON.parse((0, import_node_fs7.readFileSync)(path3, "utf8"));
64929
65329
  return { items: parsed.items ?? {}, spaces: parsed.spaces ?? {} };
64930
65330
  } catch {
64931
65331
  throw new VertuError(`\u8FC1\u79FB\u72B6\u6001\u6587\u4EF6\u65E0\u6CD5\u89E3\u6790\uFF1A${path3}`);
@@ -64935,9 +65335,9 @@ async function migrateLocalVDrive(opts) {
64935
65335
  const local = new VDriveStore(opts.root?.trim() || void 0);
64936
65336
  const items = local.list(null, true);
64937
65337
  let spaces = [];
64938
- const legacyIndexPath = (0, import_node_path11.join)(local.root, "index.json");
64939
- if ((0, import_node_fs6.existsSync)(legacyIndexPath)) {
64940
- const parsed = record2(JSON.parse((0, import_node_fs6.readFileSync)(legacyIndexPath, "utf8")), "\u65E7 V\u76D8\u7D22\u5F15\u65E0\u6CD5\u89E3\u6790\u3002");
65338
+ const legacyIndexPath = (0, import_node_path15.join)(local.root, "index.json");
65339
+ if ((0, import_node_fs7.existsSync)(legacyIndexPath)) {
65340
+ const parsed = record2(JSON.parse((0, import_node_fs7.readFileSync)(legacyIndexPath, "utf8")), "\u65E7 V\u76D8\u7D22\u5F15\u65E0\u6CD5\u89E3\u6790\u3002");
64941
65341
  spaces = records(parsed.spaces).map((space) => ({
64942
65342
  id: String(space.id ?? ""),
64943
65343
  name: String(space.name ?? "\u56E2\u961F\u5171\u4EAB\u7A7A\u95F4"),
@@ -64946,9 +65346,9 @@ async function migrateLocalVDrive(opts) {
64946
65346
  deletedAt: typeof space.deletedAt === "string" ? space.deletedAt : null
64947
65347
  })).filter((space) => space.id && !space.deletedAt);
64948
65348
  }
64949
- const statePath = (0, import_node_path11.join)(local.root, "oss-migration-v1.json");
65349
+ const statePath = (0, import_node_path15.join)(local.root, "oss-migration-v1.json");
64950
65350
  const state = migrationState(statePath);
64951
- const save = () => (0, import_node_fs6.writeFileSync)(statePath, JSON.stringify(state, null, 2), "utf8");
65351
+ const save = () => (0, import_node_fs7.writeFileSync)(statePath, JSON.stringify(state, null, 2), "utf8");
64952
65352
  let migratedItems = 0;
64953
65353
  let migratedSpaces = 0;
64954
65354
  const pendingFolders = items.filter((item) => item.kind === "folder" && !state.items[item.id]);
@@ -65015,7 +65415,7 @@ function buildDriveCommand() {
65015
65415
  attachBaseOption(drive.command("+list").description("\u5217\u51FA V\u76D8\u6587\u4EF6\u548C\u6587\u4EF6\u5939").option("--parent-id <id>", "\u7236\u6587\u4EF6\u5939 ID\uFF1B\u7701\u7565\u6216 root \u8868\u793A\u6839\u76EE\u5F55").option("--recursive", "\u9012\u5F52\u5217\u51FA\u5168\u90E8\u540E\u4EE3").option("--query <text>", "\u6309\u540D\u79F0\u8FC7\u6EE4")).action(async (opts) => {
65016
65416
  const snapshot = await driveGet(opts);
65017
65417
  const parent = parentId(opts.parentId);
65018
- print4({
65418
+ print5({
65019
65419
  storage_provider: "aliyun-oss",
65020
65420
  parent_id: parent,
65021
65421
  recursive: opts.recursive === true,
@@ -65024,23 +65424,23 @@ function buildDriveCommand() {
65024
65424
  });
65025
65425
  });
65026
65426
  attachBaseOption(drive.command("+info").description("\u8BFB\u53D6\u5355\u4E2A\u9879\u76EE\u5143\u6570\u636E").requiredOption("--item-id <id>")).action(async (opts) => {
65027
- print4(await driveAction(opts, "info", { item_id: required2(opts.itemId, "--item-id") }));
65427
+ print5(await driveAction(opts, "info", { item_id: required2(opts.itemId, "--item-id") }));
65028
65428
  });
65029
65429
  attachBaseOption(drive.command("+mkdir").description("\u65B0\u5EFA\u6587\u4EF6\u5939").requiredOption("--name <name>").option("--parent-id <id>")).action(async (opts) => {
65030
- print4(await driveAction(opts, "create-folder", { name: required2(opts.name, "--name"), parent_id: parentId(opts.parentId) }));
65430
+ print5(await driveAction(opts, "create-folder", { name: required2(opts.name, "--name"), parent_id: parentId(opts.parentId) }));
65031
65431
  });
65032
65432
  attachBaseOption(drive.command("+create-file").description("\u65B0\u5EFA UTF-8 \u6587\u672C\u6587\u4EF6").requiredOption("--name <name>").option("--parent-id <id>").option("--content <text>").option("--content-file <path>")).action(async (opts) => {
65033
65433
  const name = required2(opts.name, "--name");
65034
65434
  const content = Buffer.from(await resolveContent2(opts));
65035
65435
  const result = content.length === 0 ? await driveAction(opts, "create-file", { name, parent_id: parentId(opts.parentId) }) : await uploadContent(opts, { name, parentId: parentId(opts.parentId), type: mimeType2(name), size: content.length, body: content });
65036
- print4(result);
65436
+ print5(result);
65037
65437
  });
65038
- attachBaseOption(drive.command("+upload").description("\u628A\u672C\u5730\u6587\u4EF6\u4E0A\u4F20\u5230 OSS V\u76D8").requiredOption("--source <path>", "\u6E90\u6587\u4EF6\u8DEF\u5F84\uFF1B\u53EF\u91CD\u590D\u4F20\u5165", collect, []).option("--parent-id <id>")).action(async (opts) => {
65438
+ attachBaseOption(drive.command("+upload").description("\u628A\u672C\u5730\u6587\u4EF6\u4E0A\u4F20\u5230 OSS V\u76D8").requiredOption("--source <path>", "\u6E90\u6587\u4EF6\u8DEF\u5F84\uFF1B\u53EF\u91CD\u590D\u4F20\u5165", collect2, []).option("--parent-id <id>")).action(async (opts) => {
65039
65439
  const sources = opts.source ?? [];
65040
65440
  if (!sources.length) throw new VertuError("--source \u81F3\u5C11\u4F20\u4E00\u6B21\u3002");
65041
65441
  const items = [];
65042
65442
  for (const source of sources) items.push(itemFrom(await uploadFile(opts, source, parentId(opts.parentId))));
65043
- print4({ storage_provider: "aliyun-oss", items });
65443
+ print5({ storage_provider: "aliyun-oss", items });
65044
65444
  });
65045
65445
  attachBaseOption(drive.command("+read").description("\u8BFB\u53D6 OSS V\u76D8\u6587\u4EF6\u5185\u5BB9").requiredOption("--item-id <id>").option("--encoding <encoding>", "utf8 \u6216 base64", "utf8").option("--max-bytes <number>", "", "1048576")).action(async (opts) => {
65046
65446
  const encoding = opts.encoding?.trim().toLowerCase();
@@ -65053,11 +65453,28 @@ function buildDriveCommand() {
65053
65453
  }
65054
65454
  const bytes = response ? Buffer.from(await response.body.arrayBuffer()) : Buffer.alloc(0);
65055
65455
  if (bytes.length > maxBytes) throw new VertuError(`\u6587\u4EF6\u8D85\u8FC7 --max-bytes=${maxBytes}\uFF1B\u8BF7\u7528 +download\u3002`);
65056
- print4({ item, encoding, content: bytes.toString(encoding) });
65456
+ print5({ item, encoding, content: bytes.toString(encoding) });
65057
65457
  });
65058
- attachBaseOption(drive.command("+write").description("\u8986\u76D6 OSS V\u76D8\u6587\u4EF6\u5185\u5BB9").requiredOption("--item-id <id>").option("--content <text>").option("--content-file <path>")).action(async (opts) => {
65458
+ attachBaseOption(drive.command("+write").description("\u8986\u76D6 OSS V\u76D8\u6587\u4EF6\u5185\u5BB9").requiredOption("--item-id <id>").option("--content <text>").option("--content-file <path>").option("--source <path>", "\u4EE5\u4E8C\u8FDB\u5236\u6587\u4EF6\u66FF\u6362\u539F\u9879\u76EE\uFF0C\u4FDD\u7559\u9879\u76EE ID")).action(async (opts) => {
65459
+ if ([opts.content, opts.contentFile, opts.source].filter((value) => value !== void 0).length !== 1) {
65460
+ throw new VertuError("--content / --content-file / --source \u5FC5\u987B\u4E14\u53EA\u80FD\u6307\u5B9A\u4E00\u4E2A\u3002");
65461
+ }
65059
65462
  const id = required2(opts.itemId, "--item-id");
65060
65463
  const current = itemFrom(await driveAction(opts, "info", { item_id: id }));
65464
+ if (opts.source) {
65465
+ const source = (0, import_node_path15.resolve)(opts.source);
65466
+ const info = (0, import_node_fs7.statSync)(source);
65467
+ if (!info.isFile()) throw new VertuError("--source \u5FC5\u987B\u662F\u6587\u4EF6\u3002");
65468
+ const result2 = info.size === 0 ? await driveAction(opts, "replace-empty", { item_id: id, mime_type: current.mimeType ?? mimeType2(source) }) : await uploadContent(opts, {
65469
+ name: String(current.name ?? (0, import_node_path15.basename)(source)),
65470
+ itemId: id,
65471
+ type: String(current.mimeType ?? mimeType2(source)),
65472
+ size: info.size,
65473
+ body: source
65474
+ });
65475
+ print5(result2);
65476
+ return;
65477
+ }
65061
65478
  const content = Buffer.from(await resolveContent2(opts, true));
65062
65479
  const result = content.length === 0 ? await driveAction(opts, "replace-empty", { item_id: id, mime_type: current.mimeType ?? "text/plain" }) : await uploadContent(opts, {
65063
65480
  name: String(current.name ?? "file"),
@@ -65066,49 +65483,49 @@ function buildDriveCommand() {
65066
65483
  size: content.length,
65067
65484
  body: content
65068
65485
  });
65069
- print4(result);
65486
+ print5(result);
65070
65487
  });
65071
65488
  attachBaseOption(drive.command("+download").description("\u4E0B\u8F7D OSS V\u76D8\u6587\u4EF6").requiredOption("--item-id <id>").requiredOption("--output <path>").option("--overwrite")).action(async (opts) => {
65072
65489
  const { item, response } = await downloadResponse(opts, required2(opts.itemId, "--item-id"));
65073
- const requested = (0, import_node_path11.resolve)(required2(opts.output, "--output"));
65074
- const target = (0, import_node_fs6.existsSync)(requested) && (0, import_node_fs6.statSync)(requested).isDirectory() ? (0, import_node_path11.join)(requested, (0, import_node_path11.basename)(String(item.name ?? "file"))) : requested;
65075
- if ((0, import_node_fs6.existsSync)(target) && !opts.overwrite) {
65490
+ const requested = (0, import_node_path15.resolve)(required2(opts.output, "--output"));
65491
+ const target = (0, import_node_fs7.existsSync)(requested) && (0, import_node_fs7.statSync)(requested).isDirectory() ? (0, import_node_path15.join)(requested, (0, import_node_path15.basename)(String(item.name ?? "file"))) : requested;
65492
+ if ((0, import_node_fs7.existsSync)(target) && !opts.overwrite) {
65076
65493
  if (response) await response.body.dump();
65077
65494
  throw new VertuError("\u76EE\u6807\u6587\u4EF6\u5DF2\u5B58\u5728\uFF1B\u5982\u9700\u8986\u76D6\u8BF7\u663E\u5F0F\u4F20 --overwrite\u3002");
65078
65495
  }
65079
- await (0, import_promises12.mkdir)((0, import_node_path11.dirname)(target), { recursive: true });
65080
- if (response) await (0, import_promises13.pipeline)(response.body, (0, import_node_fs6.createWriteStream)(target));
65081
- else (0, import_node_fs6.writeFileSync)(target, Buffer.alloc(0));
65082
- print4({ item, file_path: target });
65496
+ await (0, import_promises17.mkdir)((0, import_node_path15.dirname)(target), { recursive: true });
65497
+ if (response) await (0, import_promises18.pipeline)(response.body, (0, import_node_fs7.createWriteStream)(target));
65498
+ else (0, import_node_fs7.writeFileSync)(target, Buffer.alloc(0));
65499
+ print5({ item, file_path: target });
65083
65500
  });
65084
65501
  attachBaseOption(drive.command("+rename").description("\u91CD\u547D\u540D\u9879\u76EE").requiredOption("--item-id <id>").requiredOption("--name <name>")).action(async (opts) => {
65085
65502
  const id = required2(opts.itemId, "--item-id");
65086
65503
  await driveAction(opts, "rename", { item_id: id, name: required2(opts.name, "--name") });
65087
- print4(await driveAction(opts, "info", { item_id: id }));
65504
+ print5(await driveAction(opts, "info", { item_id: id }));
65088
65505
  });
65089
65506
  attachBaseOption(drive.command("+move").description("\u79FB\u52A8\u9879\u76EE").requiredOption("--item-id <id>").requiredOption("--parent-id <id>")).action(async (opts) => {
65090
65507
  const id = required2(opts.itemId, "--item-id");
65091
65508
  await driveAction(opts, "move", { item_id: id, parent_id: parentId(required2(opts.parentId, "--parent-id")) });
65092
- print4(await driveAction(opts, "info", { item_id: id }));
65509
+ print5(await driveAction(opts, "info", { item_id: id }));
65093
65510
  });
65094
65511
  attachBaseOption(drive.command("+remove").description("\u79FB\u5165\u56DE\u6536\u7AD9").requiredOption("--item-id <id>")).action(async (opts) => {
65095
65512
  const id = required2(opts.itemId, "--item-id");
65096
65513
  const item = itemFrom(await driveAction(opts, "info", { item_id: id }));
65097
65514
  await driveAction(opts, "remove", { item_id: id });
65098
- print4({ trashed_item: item });
65515
+ print5({ trashed_item: item });
65099
65516
  });
65100
- attachBaseOption(drive.command("+trash").description("\u5217\u51FA\u56DE\u6536\u7AD9")).action(async (opts) => print4(await driveGet(opts, "trash")));
65517
+ attachBaseOption(drive.command("+trash").description("\u5217\u51FA\u56DE\u6536\u7AD9")).action(async (opts) => print5(await driveGet(opts, "trash")));
65101
65518
  attachBaseOption(drive.command("+restore").description("\u6062\u590D\u56DE\u6536\u7AD9\u9879\u76EE").requiredOption("--item-id <id>")).action(async (opts) => {
65102
65519
  const id = required2(opts.itemId, "--item-id");
65103
65520
  await driveAction(opts, "restore", { item_id: id });
65104
- print4(await driveAction(opts, "info", { item_id: id }));
65521
+ print5(await driveAction(opts, "info", { item_id: id }));
65105
65522
  });
65106
65523
  attachBaseOption(drive.command("+purge").description("\u6C38\u4E45\u5220\u9664\u56DE\u6536\u7AD9\u9879\u76EE").requiredOption("--item-id <id>")).action(async (opts) => {
65107
- print4(await driveAction(opts, "purge", { item_id: required2(opts.itemId, "--item-id") }));
65524
+ print5(await driveAction(opts, "purge", { item_id: required2(opts.itemId, "--item-id") }));
65108
65525
  });
65109
- attachBaseOption(drive.command("+empty-trash").description("\u6C38\u4E45\u6E05\u7A7A\u56DE\u6536\u7AD9")).action(async (opts) => print4(await driveAction(opts, "empty-trash")));
65110
- attachBaseOption(drive.command("+transfers").description("\u5217\u51FA\u4F20\u8F93\u8BB0\u5F55")).action(async (opts) => print4(await driveGet(opts, "transfers")));
65111
- attachBaseOption(drive.command("+migrate-local").description("\u628A\u65E7\u7248\u672C\u5730 V\u76D8\u8FC1\u79FB\u5230 OSS\uFF0C\u4FDD\u7559\u672C\u5730\u6E90\u6587\u4EF6").option("--root <path>", "\u65E7\u7248 v-drive \u76EE\u5F55\uFF1B\u9ED8\u8BA4\u81EA\u52A8\u5B9A\u4F4D")).action(async (opts) => print4(await migrateLocalVDrive(opts)));
65526
+ attachBaseOption(drive.command("+empty-trash").description("\u6C38\u4E45\u6E05\u7A7A\u56DE\u6536\u7AD9")).action(async (opts) => print5(await driveAction(opts, "empty-trash")));
65527
+ attachBaseOption(drive.command("+transfers").description("\u5217\u51FA\u4F20\u8F93\u8BB0\u5F55")).action(async (opts) => print5(await driveGet(opts, "transfers")));
65528
+ attachBaseOption(drive.command("+migrate-local").description("\u628A\u65E7\u7248\u672C\u5730 V\u76D8\u8FC1\u79FB\u5230 OSS\uFF0C\u4FDD\u7559\u672C\u5730\u6E90\u6587\u4EF6").option("--root <path>", "\u65E7\u7248 v-drive \u76EE\u5F55\uFF1B\u9ED8\u8BA4\u81EA\u52A8\u5B9A\u4F4D")).action(async (opts) => print5(await migrateLocalVDrive(opts)));
65112
65529
  return drive;
65113
65530
  }
65114
65531
 
@@ -65242,9 +65659,9 @@ function buildPopupCommand() {
65242
65659
  }
65243
65660
 
65244
65661
  // src/core/skill-catalog.ts
65245
- var import_promises14 = require("fs/promises");
65662
+ var import_promises19 = require("fs/promises");
65246
65663
  var import_node_os4 = require("os");
65247
- var import_node_path12 = require("path");
65664
+ var import_node_path16 = require("path");
65248
65665
  var AGENT_TARGETS = [
65249
65666
  { id: "cursor", rootName: ".cursor", aliases: [] },
65250
65667
  { id: "claude-code", rootName: ".claude", aliases: ["claude"] },
@@ -65274,7 +65691,7 @@ async function loadPublicSkills() {
65274
65691
  const root = packageSkillsDir();
65275
65692
  let entries;
65276
65693
  try {
65277
- entries = await (0, import_promises14.readdir)(root);
65694
+ entries = await (0, import_promises19.readdir)(root);
65278
65695
  } catch (err) {
65279
65696
  if (err.code === "ENOENT") {
65280
65697
  throw new VertuError(`\u672A\u627E\u5230\u5305\u5185 skills \u76EE\u5F55\uFF1A${root}\uFF08\u5305\u5B89\u88C5\u53EF\u80FD\u4E0D\u5B8C\u6574\uFF09\u3002`);
@@ -65283,17 +65700,17 @@ async function loadPublicSkills() {
65283
65700
  }
65284
65701
  const skills = [];
65285
65702
  for (const name of entries.sort()) {
65286
- const sourceDir = (0, import_node_path12.join)(root, name);
65287
- const skillFile = (0, import_node_path12.join)(sourceDir, "SKILL.md");
65703
+ const sourceDir = (0, import_node_path16.join)(root, name);
65704
+ const skillFile = (0, import_node_path16.join)(sourceDir, "SKILL.md");
65288
65705
  try {
65289
- const info = await (0, import_promises14.stat)(skillFile);
65706
+ const info = await (0, import_promises19.stat)(skillFile);
65290
65707
  if (!info.isFile()) {
65291
65708
  continue;
65292
65709
  }
65293
65710
  } catch {
65294
65711
  continue;
65295
65712
  }
65296
- const md = await (0, import_promises14.readFile)(skillFile, "utf8");
65713
+ const md = await (0, import_promises19.readFile)(skillFile, "utf8");
65297
65714
  skills.push({ key: name, description: parseFrontmatterDescription(md), sourceDir });
65298
65715
  }
65299
65716
  return skills;
@@ -65323,13 +65740,13 @@ function resolveAgentTargets(input) {
65323
65740
  return resolved;
65324
65741
  }
65325
65742
  function agentSkillsRoot(target) {
65326
- return (0, import_node_path12.join)((0, import_node_os4.homedir)(), target.rootName, "skills");
65743
+ return (0, import_node_path16.join)((0, import_node_os4.homedir)(), target.rootName, "skills");
65327
65744
  }
65328
65745
  async function detectInstalledAgents() {
65329
65746
  const found = [];
65330
65747
  for (const target of AGENT_TARGETS) {
65331
65748
  try {
65332
- const info = await (0, import_promises14.stat)((0, import_node_path12.join)((0, import_node_os4.homedir)(), target.rootName));
65749
+ const info = await (0, import_promises19.stat)((0, import_node_path16.join)((0, import_node_os4.homedir)(), target.rootName));
65333
65750
  if (info.isDirectory()) {
65334
65751
  found.push(target);
65335
65752
  }
@@ -65352,7 +65769,7 @@ function resolveDestinations(targets, dirs) {
65352
65769
  push(target.id, agentSkillsRoot(target));
65353
65770
  }
65354
65771
  for (const raw of dirs) {
65355
- const expanded = raw.trim().startsWith("~") ? (0, import_node_path12.join)((0, import_node_os4.homedir)(), raw.trim().slice(1).replace(/^[\\/]/, "")) : raw.trim();
65772
+ const expanded = raw.trim().startsWith("~") ? (0, import_node_path16.join)((0, import_node_os4.homedir)(), raw.trim().slice(1).replace(/^[\\/]/, "")) : raw.trim();
65356
65773
  if (expanded) {
65357
65774
  push(`dir:${expanded}`, expanded);
65358
65775
  }
@@ -65360,19 +65777,19 @@ function resolveDestinations(targets, dirs) {
65360
65777
  return dests;
65361
65778
  }
65362
65779
  async function copySkillTo(skill, skillsRoot) {
65363
- const dest = (0, import_node_path12.join)(skillsRoot, skill.key);
65364
- await (0, import_promises14.rm)(dest, { recursive: true, force: true });
65365
- await (0, import_promises14.cp)(skill.sourceDir, dest, { recursive: true });
65780
+ const dest = (0, import_node_path16.join)(skillsRoot, skill.key);
65781
+ await (0, import_promises19.rm)(dest, { recursive: true, force: true });
65782
+ await (0, import_promises19.cp)(skill.sourceDir, dest, { recursive: true });
65366
65783
  return dest;
65367
65784
  }
65368
65785
  async function removeSkillFrom(key, skillsRoot) {
65369
- const dest = (0, import_node_path12.join)(skillsRoot, key);
65786
+ const dest = (0, import_node_path16.join)(skillsRoot, key);
65370
65787
  try {
65371
- await (0, import_promises14.stat)(dest);
65788
+ await (0, import_promises19.stat)(dest);
65372
65789
  } catch {
65373
65790
  return false;
65374
65791
  }
65375
- await (0, import_promises14.rm)(dest, { recursive: true, force: true });
65792
+ await (0, import_promises19.rm)(dest, { recursive: true, force: true });
65376
65793
  return true;
65377
65794
  }
65378
65795
 
@@ -65424,7 +65841,7 @@ function ensurePersonalSkillFrontmatter(markdown, input) {
65424
65841
  return `${stringifyFrontmatter({ ...parsed.data, name: slug, description }, body).trim()}
65425
65842
  `;
65426
65843
  }
65427
- function print5(value) {
65844
+ function print6(value) {
65428
65845
  console.log(JSON.stringify(value, null, 2));
65429
65846
  }
65430
65847
  function asRecord6(value) {
@@ -65472,7 +65889,7 @@ ${instructions.trim()}` : "");
65472
65889
  note: opts.note?.trim() || "\u7531 vps-work Agent \u547D\u4EE4\u65B0\u5EFA"
65473
65890
  }
65474
65891
  });
65475
- print5(result);
65892
+ print6(result);
65476
65893
  }
65477
65894
  async function updatePersonalSkill(opts) {
65478
65895
  const slug = normalizePersonalSkillSlug(opts.slug);
@@ -65513,7 +65930,7 @@ ${instructions?.trim() || ""}`;
65513
65930
  note: opts.note?.trim() || "\u7531 vps-work Agent \u547D\u4EE4\u66F4\u65B0"
65514
65931
  }
65515
65932
  });
65516
- print5(result);
65933
+ print6(result);
65517
65934
  }
65518
65935
  function addHermesBaseUrl(command) {
65519
65936
  return command.option(
@@ -65532,7 +65949,7 @@ function addPersonalSkillCommands(skill) {
65532
65949
  skill.command("+request-publication").description("\u7533\u8BF7\u5C06\u81EA\u5DF1\u521B\u5EFA\u7684\u4E2A\u4EBA\u6280\u80FD\u516C\u5F00\u5230\u4F01\u4E1A\u6280\u80FD\u5E93").requiredOption("--slug <slug>", "\u81EA\u5DF1\u7684\u4E2A\u4EBA\u6280\u80FD\u673A\u5668\u540D").option("--note <text>", "\u63D0\u4EA4\u5BA1\u6838\u8BF4\u660E")
65533
65950
  ).action(async (opts) => {
65534
65951
  const slug = normalizePersonalSkillSlug(opts.slug);
65535
- print5(await hermesRequest("POST", "/hermes-console/api/skills/publish", {
65952
+ print6(await hermesRequest("POST", "/hermes-console/api/skills/publish", {
65536
65953
  baseUrl: opts.hermesBaseUrl,
65537
65954
  body: { skill_slug: slug, submit_note: opts.note?.trim() || "" }
65538
65955
  }));
@@ -65542,7 +65959,7 @@ function addPersonalSkillCommands(skill) {
65542
65959
  ).action(async (opts) => {
65543
65960
  const slug = normalizePersonalSkillSlug(opts.slug);
65544
65961
  const userId = await currentUserId(opts.hermesBaseUrl);
65545
- print5(await hermesRequest(
65962
+ print6(await hermesRequest(
65546
65963
  "DELETE",
65547
65964
  `/hermes-console/api/skills/${encodeURIComponent(slug)}?odoo_user_id=${userId}`,
65548
65965
  { baseUrl: opts.hermesBaseUrl }
@@ -65552,7 +65969,7 @@ function addPersonalSkillCommands(skill) {
65552
65969
  skill.command("+change-category").description("\u4FEE\u6539\u81EA\u5DF1\u521B\u5EFA\u7684\u4E2A\u4EBA\u6280\u80FD\u5206\u7C7B").requiredOption("--slug <slug>", "\u81EA\u5DF1\u7684\u4E2A\u4EBA\u6280\u80FD\u673A\u5668\u540D").requiredOption("--category <key>", "\u76EE\u6807\u5206\u7C7B key").option("--category-name <text>", "\u76EE\u6807\u5206\u7C7B\u663E\u793A\u540D\u79F0\uFF1B\u7701\u7565\u65F6\u7531\u670D\u52A1\u7AEF\u67E5\u8BE2")
65553
65970
  ).action(async (opts) => {
65554
65971
  const slug = normalizePersonalSkillSlug(opts.slug);
65555
- print5(await hermesRequest("POST", "/hermes-console/api/skills/category", {
65972
+ print6(await hermesRequest("POST", "/hermes-console/api/skills/category", {
65556
65973
  baseUrl: opts.hermesBaseUrl,
65557
65974
  body: {
65558
65975
  skill_slug: slug,
@@ -65691,11 +66108,11 @@ function buildSkillCommand() {
65691
66108
  }
65692
66109
 
65693
66110
  // src/core/execute-catalog-client.ts
65694
- var import_undici12 = __toESM(require_undici(), 1);
66111
+ var import_undici13 = __toESM(require_undici(), 1);
65695
66112
  async function fetchExecuteCatalog(serviceBaseUrl, domain) {
65696
66113
  const base = resolveVpsServiceUrl(serviceBaseUrl);
65697
66114
  const query2 = domain?.trim() ? `?domain=${encodeURIComponent(domain.trim())}` : "";
65698
- const res = await (0, import_undici12.request)(`${base}/v1/execute/catalog${query2}`, {
66115
+ const res = await (0, import_undici13.request)(`${base}/v1/execute/catalog${query2}`, {
65699
66116
  method: "GET",
65700
66117
  headers: {
65701
66118
  accept: "application/json",
@@ -65893,6 +66310,11 @@ function buildCliRootHelpAfter() {
65893
66310
  ` ${b} auth status`,
65894
66311
  ` ${b} auth scopes`,
65895
66312
  "",
66313
+ " # Email (legacy mail +send is IM direct messaging)",
66314
+ ` ${b} mail +messages --unread-only`,
66315
+ ` ${b} mail +mailboxes`,
66316
+ ` ${b} mail +send-email --help`,
66317
+ "",
65896
66318
  " # Sales KPI",
65897
66319
  ` ${b} sales +headline-kpi`,
65898
66320
  ` ${b} sales +headline-kpi --period this_month --dry-run`,
@@ -65900,8 +66322,15 @@ function buildCliRootHelpAfter() {
65900
66322
  ` ${b} sales +order-logistics --logistics-no SF123`,
65901
66323
  ` ${b} sales +dept-breakdown --period this_month --group-by salesperson`,
65902
66324
  "",
66325
+ ` # Desktop Office: discover sessions and native editor tools`,
66326
+ ` ${b} office +status`,
66327
+ ` ${b} office +sessions`,
66328
+ ` ${b} office +tools --session-id <id>`,
66329
+ "",
65903
66330
  " # Store management",
65904
66331
  ` ${b} store +reception --period this_month`,
66332
+ ` ${b} store +walk-in --period this_month --group-by department,date`,
66333
+ ` ${b} store +inventory --group-by store,product`,
65905
66334
  ` ${b} store +reception --start-date 2026-08-01 --end-date 2026-08-18 --region \u4E1C\u533A`,
65906
66335
  "",
65907
66336
  " # HR identity, organization, personnel, and contracts",
@@ -66071,7 +66500,7 @@ function rewriteLongFlag(tok) {
66071
66500
  }
66072
66501
 
66073
66502
  // src/bin/vps-work.ts
66074
- var PKG_VERSION = "2.2.0" ? "2.2.0" : "0.0.0-dev";
66503
+ var PKG_VERSION = "2.3.0" ? "2.3.0" : "0.0.0-dev";
66075
66504
  function smartFlagSuggest(flag, candidates) {
66076
66505
  if (!flag.startsWith("--") || flag.length < 4) return "";
66077
66506
  const word = flag.slice(2);
@@ -66193,6 +66622,7 @@ async function main() {
66193
66622
  program2.addCommand(buildCreativeCommand());
66194
66623
  program2.addCommand(buildCorporateCommand());
66195
66624
  program2.addCommand(buildDocumentsCommand());
66625
+ program2.addCommand(buildOfficeCommand());
66196
66626
  program2.addCommand(buildKnowledgeCommand());
66197
66627
  program2.addCommand(buildDriveCommand());
66198
66628
  program2.addCommand(buildPopupCommand());