agent-relay 4.0.30 → 4.0.32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (158) hide show
  1. package/README.md +88 -48
  2. package/bin/agent-relay-broker-darwin-arm64 +0 -0
  3. package/bin/agent-relay-broker-darwin-x64 +0 -0
  4. package/bin/agent-relay-broker-linux-arm64 +0 -0
  5. package/bin/agent-relay-broker-linux-x64 +0 -0
  6. package/dist/index.cjs +309 -129
  7. package/dist/src/cli/bootstrap.d.ts +2 -1
  8. package/dist/src/cli/bootstrap.d.ts.map +1 -1
  9. package/dist/src/cli/bootstrap.js +223 -17
  10. package/dist/src/cli/bootstrap.js.map +1 -1
  11. package/dist/src/cli/commands/agent-management.d.ts.map +1 -1
  12. package/dist/src/cli/commands/agent-management.js +1 -3
  13. package/dist/src/cli/commands/agent-management.js.map +1 -1
  14. package/dist/src/cli/commands/auth.d.ts.map +1 -1
  15. package/dist/src/cli/commands/auth.js +32 -3
  16. package/dist/src/cli/commands/auth.js.map +1 -1
  17. package/dist/src/cli/commands/cloud.d.ts.map +1 -1
  18. package/dist/src/cli/commands/cloud.js +242 -144
  19. package/dist/src/cli/commands/cloud.js.map +1 -1
  20. package/dist/src/cli/commands/core.d.ts.map +1 -1
  21. package/dist/src/cli/commands/core.js +11 -6
  22. package/dist/src/cli/commands/core.js.map +1 -1
  23. package/dist/src/cli/commands/messaging.d.ts.map +1 -1
  24. package/dist/src/cli/commands/messaging.js +1 -3
  25. package/dist/src/cli/commands/messaging.js.map +1 -1
  26. package/dist/src/cli/commands/monitoring.d.ts.map +1 -1
  27. package/dist/src/cli/commands/monitoring.js +5 -4
  28. package/dist/src/cli/commands/monitoring.js.map +1 -1
  29. package/dist/src/cli/commands/on.d.ts.map +1 -1
  30. package/dist/src/cli/commands/on.js +1 -3
  31. package/dist/src/cli/commands/on.js.map +1 -1
  32. package/dist/src/cli/commands/setup.d.ts.map +1 -1
  33. package/dist/src/cli/commands/setup.js +62 -7
  34. package/dist/src/cli/commands/setup.js.map +1 -1
  35. package/dist/src/cli/commands/swarm.d.ts.map +1 -1
  36. package/dist/src/cli/commands/swarm.js +34 -4
  37. package/dist/src/cli/commands/swarm.js.map +1 -1
  38. package/dist/src/cli/index.js +9 -1
  39. package/dist/src/cli/index.js.map +1 -1
  40. package/dist/src/cli/lib/exit.d.ts +49 -0
  41. package/dist/src/cli/lib/exit.d.ts.map +1 -0
  42. package/dist/src/cli/lib/exit.js +73 -0
  43. package/dist/src/cli/lib/exit.js.map +1 -0
  44. package/dist/src/cli/lib/telemetry-helpers.d.ts +20 -0
  45. package/dist/src/cli/lib/telemetry-helpers.d.ts.map +1 -0
  46. package/dist/src/cli/lib/telemetry-helpers.js +31 -0
  47. package/dist/src/cli/lib/telemetry-helpers.js.map +1 -0
  48. package/node_modules/@agent-relay/cloud/package.json +2 -2
  49. package/node_modules/@agent-relay/config/package.json +1 -1
  50. package/node_modules/@agent-relay/hooks/package.json +4 -4
  51. package/node_modules/@agent-relay/sdk/README.md +3 -0
  52. package/node_modules/@agent-relay/sdk/dist/relay.d.ts +16 -0
  53. package/node_modules/@agent-relay/sdk/dist/relay.d.ts.map +1 -1
  54. package/node_modules/@agent-relay/sdk/dist/relay.js +83 -0
  55. package/node_modules/@agent-relay/sdk/dist/relay.js.map +1 -1
  56. package/node_modules/@agent-relay/sdk/dist/workflows/file-db.d.ts +62 -12
  57. package/node_modules/@agent-relay/sdk/dist/workflows/file-db.d.ts.map +1 -1
  58. package/node_modules/@agent-relay/sdk/dist/workflows/file-db.js +137 -47
  59. package/node_modules/@agent-relay/sdk/dist/workflows/file-db.js.map +1 -1
  60. package/node_modules/@agent-relay/sdk/package.json +2 -2
  61. package/node_modules/@agent-relay/telemetry/dist/client.d.ts +14 -2
  62. package/node_modules/@agent-relay/telemetry/dist/client.d.ts.map +1 -1
  63. package/node_modules/@agent-relay/telemetry/dist/client.js +22 -4
  64. package/node_modules/@agent-relay/telemetry/dist/client.js.map +1 -1
  65. package/node_modules/@agent-relay/telemetry/dist/events.d.ts +217 -10
  66. package/node_modules/@agent-relay/telemetry/dist/events.d.ts.map +1 -1
  67. package/node_modules/@agent-relay/telemetry/dist/events.js +11 -0
  68. package/node_modules/@agent-relay/telemetry/dist/events.js.map +1 -1
  69. package/node_modules/@agent-relay/telemetry/dist/index.d.ts +2 -2
  70. package/node_modules/@agent-relay/telemetry/dist/index.d.ts.map +1 -1
  71. package/node_modules/@agent-relay/telemetry/dist/index.js.map +1 -1
  72. package/node_modules/@agent-relay/telemetry/package.json +2 -2
  73. package/node_modules/@agent-relay/trajectory/package.json +2 -2
  74. package/node_modules/@agent-relay/user-directory/package.json +2 -2
  75. package/node_modules/@agent-relay/utils/package.json +2 -2
  76. package/node_modules/@relaycast/sdk/dist/version.d.ts +1 -1
  77. package/node_modules/@relaycast/sdk/dist/version.js +1 -1
  78. package/node_modules/@relaycast/sdk/node_modules/@relaycast/types/package.json +1 -1
  79. package/node_modules/@relaycast/sdk/package.json +2 -2
  80. package/node_modules/agent-trajectories/dist/{chunk-2XT3DOJC.js → chunk-27AQPWHK.js} +136 -72
  81. package/node_modules/agent-trajectories/dist/chunk-27AQPWHK.js.map +1 -0
  82. package/node_modules/agent-trajectories/dist/cli/index.js +135 -71
  83. package/node_modules/agent-trajectories/dist/cli/index.js.map +1 -1
  84. package/node_modules/agent-trajectories/dist/{index-thTh5iI8.d.ts → index-C7XhwsoN.d.ts} +24 -0
  85. package/node_modules/agent-trajectories/dist/index.d.ts +2 -2
  86. package/node_modules/agent-trajectories/dist/index.js +1 -1
  87. package/node_modules/agent-trajectories/dist/sdk/index.d.ts +1 -1
  88. package/node_modules/agent-trajectories/dist/sdk/index.js +1 -1
  89. package/node_modules/agent-trajectories/package.json +1 -1
  90. package/node_modules/axios/CHANGELOG.md +166 -0
  91. package/node_modules/axios/README.md +210 -204
  92. package/node_modules/axios/dist/axios.js +92 -63
  93. package/node_modules/axios/dist/axios.js.map +1 -1
  94. package/node_modules/axios/dist/axios.min.js +2 -2
  95. package/node_modules/axios/dist/axios.min.js.map +1 -1
  96. package/node_modules/axios/dist/browser/axios.cjs +140 -101
  97. package/node_modules/axios/dist/browser/axios.cjs.map +1 -1
  98. package/node_modules/axios/dist/esm/axios.js +140 -101
  99. package/node_modules/axios/dist/esm/axios.js.map +1 -1
  100. package/node_modules/axios/dist/esm/axios.min.js +2 -2
  101. package/node_modules/axios/dist/esm/axios.min.js.map +1 -1
  102. package/node_modules/axios/dist/node/axios.cjs +199 -75
  103. package/node_modules/axios/dist/node/axios.cjs.map +1 -1
  104. package/node_modules/axios/index.d.cts +14 -28
  105. package/node_modules/axios/index.d.ts +132 -226
  106. package/node_modules/axios/lib/adapters/fetch.js +21 -6
  107. package/node_modules/axios/lib/adapters/http.js +88 -6
  108. package/node_modules/axios/lib/core/AxiosError.js +34 -33
  109. package/node_modules/axios/lib/core/AxiosHeaders.js +24 -25
  110. package/node_modules/axios/lib/core/buildFullPath.js +1 -1
  111. package/node_modules/axios/lib/core/mergeConfig.js +5 -3
  112. package/node_modules/axios/lib/defaults/index.js +13 -8
  113. package/node_modules/axios/lib/env/data.js +1 -1
  114. package/node_modules/axios/lib/helpers/AxiosURLSearchParams.js +1 -2
  115. package/node_modules/axios/lib/helpers/formDataToJSON.js +3 -1
  116. package/node_modules/axios/lib/helpers/formDataToStream.js +2 -1
  117. package/node_modules/axios/lib/helpers/progressEventReducer.js +5 -5
  118. package/node_modules/axios/lib/helpers/resolveConfig.js +11 -3
  119. package/node_modules/axios/lib/helpers/shouldBypassProxy.js +48 -1
  120. package/node_modules/axios/lib/helpers/toFormData.js +10 -2
  121. package/node_modules/axios/lib/utils.js +10 -10
  122. package/node_modules/axios/package.json +4 -4
  123. package/package.json +9 -9
  124. package/packages/cloud/package.json +2 -2
  125. package/packages/config/package.json +1 -1
  126. package/packages/hooks/package.json +4 -4
  127. package/packages/sdk/README.md +3 -0
  128. package/packages/sdk/dist/relay.d.ts +16 -0
  129. package/packages/sdk/dist/relay.d.ts.map +1 -1
  130. package/packages/sdk/dist/relay.js +83 -0
  131. package/packages/sdk/dist/relay.js.map +1 -1
  132. package/packages/sdk/dist/workflows/file-db.d.ts +62 -12
  133. package/packages/sdk/dist/workflows/file-db.d.ts.map +1 -1
  134. package/packages/sdk/dist/workflows/file-db.js +137 -47
  135. package/packages/sdk/dist/workflows/file-db.js.map +1 -1
  136. package/packages/sdk/package.json +2 -2
  137. package/packages/telemetry/dist/client.d.ts +14 -2
  138. package/packages/telemetry/dist/client.d.ts.map +1 -1
  139. package/packages/telemetry/dist/client.js +22 -4
  140. package/packages/telemetry/dist/client.js.map +1 -1
  141. package/packages/telemetry/dist/events.d.ts +217 -10
  142. package/packages/telemetry/dist/events.d.ts.map +1 -1
  143. package/packages/telemetry/dist/events.js +11 -0
  144. package/packages/telemetry/dist/events.js.map +1 -1
  145. package/packages/telemetry/dist/index.d.ts +2 -2
  146. package/packages/telemetry/dist/index.d.ts.map +1 -1
  147. package/packages/telemetry/dist/index.js.map +1 -1
  148. package/packages/telemetry/package.json +2 -2
  149. package/packages/trajectory/package.json +2 -2
  150. package/packages/user-directory/package.json +2 -2
  151. package/packages/utils/package.json +2 -2
  152. package/node_modules/@clack/prompts/node_modules/is-unicode-supported/index.d.ts +0 -12
  153. package/node_modules/@clack/prompts/node_modules/is-unicode-supported/index.js +0 -17
  154. package/node_modules/@clack/prompts/node_modules/is-unicode-supported/license +0 -9
  155. package/node_modules/@clack/prompts/node_modules/is-unicode-supported/package.json +0 -43
  156. package/node_modules/@clack/prompts/node_modules/is-unicode-supported/readme.md +0 -35
  157. package/node_modules/agent-trajectories/dist/chunk-2XT3DOJC.js.map +0 -1
  158. package/node_modules/color-convert/CHANGELOG.md +0 -54
@@ -1,4 +1,4 @@
1
- /*! Axios v1.15.0 Copyright (c) 2026 Matt Zabriskie and contributors */
1
+ /*! Axios v1.15.1 Copyright (c) 2026 Matt Zabriskie and contributors */
2
2
  'use strict';
3
3
 
4
4
  var FormData$1 = require('form-data');
@@ -270,10 +270,16 @@ function getGlobal() {
270
270
  const G = getGlobal();
271
271
  const FormDataCtor = typeof G.FormData !== 'undefined' ? G.FormData : undefined;
272
272
  const isFormData = thing => {
273
- let kind;
274
- return thing && (FormDataCtor && thing instanceof FormDataCtor || isFunction$1(thing.append) && ((kind = kindOf(thing)) === 'formdata' ||
273
+ if (!thing) return false;
274
+ if (FormDataCtor && thing instanceof FormDataCtor) return true;
275
+ // Reject plain objects inheriting directly from Object.prototype so prototype-pollution gadgets can't spoof FormData (GHSA-6chq-wfr3-2hj9).
276
+ const proto = getPrototypeOf(thing);
277
+ if (!proto || proto === Object.prototype) return false;
278
+ if (!isFunction$1(thing.append)) return false;
279
+ const kind = kindOf(thing);
280
+ return kind === 'formdata' ||
275
281
  // detect form-data instance
276
- kind === 'object' && isFunction$1(thing.toString) && thing.toString() === '[object FormData]'));
282
+ kind === 'object' && isFunction$1(thing.toString) && thing.toString() === '[object FormData]';
277
283
  };
278
284
 
279
285
  /**
@@ -950,6 +956,7 @@ AxiosError.ERR_BAD_REQUEST = 'ERR_BAD_REQUEST';
950
956
  AxiosError.ERR_CANCELED = 'ERR_CANCELED';
951
957
  AxiosError.ERR_NOT_SUPPORT = 'ERR_NOT_SUPPORT';
952
958
  AxiosError.ERR_INVALID_URL = 'ERR_INVALID_URL';
959
+ AxiosError.ERR_FORM_DATA_DEPTH_EXCEEDED = 'ERR_FORM_DATA_DEPTH_EXCEEDED';
953
960
 
954
961
  /**
955
962
  * Determines if the given thing is a array or js object.
@@ -1051,6 +1058,7 @@ function toFormData(obj, formData, options) {
1051
1058
  const dots = options.dots;
1052
1059
  const indexes = options.indexes;
1053
1060
  const _Blob = options.Blob || typeof Blob !== 'undefined' && Blob;
1061
+ const maxDepth = options.maxDepth === undefined ? 100 : options.maxDepth;
1054
1062
  const useBlob = _Blob && utils$1.isSpecCompliantForm(formData);
1055
1063
  if (!utils$1.isFunction(visitor)) {
1056
1064
  throw new TypeError('visitor must be a function');
@@ -1117,8 +1125,11 @@ function toFormData(obj, formData, options) {
1117
1125
  convertValue,
1118
1126
  isVisitable
1119
1127
  });
1120
- function build(value, path) {
1128
+ function build(value, path, depth = 0) {
1121
1129
  if (utils$1.isUndefined(value)) return;
1130
+ if (depth > maxDepth) {
1131
+ throw new AxiosError('Object is too deeply nested (' + depth + ' levels). Max depth: ' + maxDepth, AxiosError.ERR_FORM_DATA_DEPTH_EXCEEDED);
1132
+ }
1122
1133
  if (stack.indexOf(value) !== -1) {
1123
1134
  throw Error('Circular reference detected in ' + path.join('.'));
1124
1135
  }
@@ -1126,7 +1137,7 @@ function toFormData(obj, formData, options) {
1126
1137
  utils$1.forEach(value, function each(el, key) {
1127
1138
  const result = !(utils$1.isUndefined(el) || el === null) && visitor.call(formData, el, utils$1.isString(key) ? key.trim() : key, path, exposedHelpers);
1128
1139
  if (result === true) {
1129
- build(el, path ? path.concat(key) : [key]);
1140
+ build(el, path ? path.concat(key) : [key], depth + 1);
1130
1141
  }
1131
1142
  });
1132
1143
  stack.pop();
@@ -1153,10 +1164,9 @@ function encode$1(str) {
1153
1164
  '(': '%28',
1154
1165
  ')': '%29',
1155
1166
  '~': '%7E',
1156
- '%20': '+',
1157
- '%00': '\x00'
1167
+ '%20': '+'
1158
1168
  };
1159
- return encodeURIComponent(str).replace(/[!'()~]|%20|%00/g, function replacer(match) {
1169
+ return encodeURIComponent(str).replace(/[!'()~]|%20/g, function replacer(match) {
1160
1170
  return charMap[match];
1161
1171
  });
1162
1172
  }
@@ -1457,7 +1467,7 @@ function formDataToJSON(formData) {
1457
1467
  name = !name && utils$1.isArray(target) ? target.length : name;
1458
1468
  if (isLast) {
1459
1469
  if (utils$1.hasOwnProp(target, name)) {
1460
- target[name] = [target[name], value];
1470
+ target[name] = utils$1.isArray(target[name]) ? target[name].concat(value) : [target[name], value];
1461
1471
  } else {
1462
1472
  target[name] = value;
1463
1473
  }
@@ -1482,6 +1492,8 @@ function formDataToJSON(formData) {
1482
1492
  return null;
1483
1493
  }
1484
1494
 
1495
+ const own = (obj, key) => obj != null && utils$1.hasOwnProp(obj, key) ? obj[key] : undefined;
1496
+
1485
1497
  /**
1486
1498
  * It takes a string, tries to parse it, and if it fails, it returns the stringified version
1487
1499
  * of the input
@@ -1531,14 +1543,16 @@ const defaults = {
1531
1543
  }
1532
1544
  let isFileList;
1533
1545
  if (isObjectPayload) {
1546
+ const formSerializer = own(this, 'formSerializer');
1534
1547
  if (contentType.indexOf('application/x-www-form-urlencoded') > -1) {
1535
- return toURLEncodedForm(data, this.formSerializer).toString();
1548
+ return toURLEncodedForm(data, formSerializer).toString();
1536
1549
  }
1537
1550
  if ((isFileList = utils$1.isFileList(data)) || contentType.indexOf('multipart/form-data') > -1) {
1538
- const _FormData = this.env && this.env.FormData;
1551
+ const env = own(this, 'env');
1552
+ const _FormData = env && env.FormData;
1539
1553
  return toFormData(isFileList ? {
1540
1554
  'files[]': data
1541
- } : data, _FormData && new _FormData(), this.formSerializer);
1555
+ } : data, _FormData && new _FormData(), formSerializer);
1542
1556
  }
1543
1557
  }
1544
1558
  if (isObjectPayload || hasJSONContentType) {
@@ -1548,21 +1562,22 @@ const defaults = {
1548
1562
  return data;
1549
1563
  }],
1550
1564
  transformResponse: [function transformResponse(data) {
1551
- const transitional = this.transitional || defaults.transitional;
1565
+ const transitional = own(this, 'transitional') || defaults.transitional;
1552
1566
  const forcedJSONParsing = transitional && transitional.forcedJSONParsing;
1553
- const JSONRequested = this.responseType === 'json';
1567
+ const responseType = own(this, 'responseType');
1568
+ const JSONRequested = responseType === 'json';
1554
1569
  if (utils$1.isResponse(data) || utils$1.isReadableStream(data)) {
1555
1570
  return data;
1556
1571
  }
1557
- if (data && utils$1.isString(data) && (forcedJSONParsing && !this.responseType || JSONRequested)) {
1572
+ if (data && utils$1.isString(data) && (forcedJSONParsing && !responseType || JSONRequested)) {
1558
1573
  const silentJSONParsing = transitional && transitional.silentJSONParsing;
1559
1574
  const strictJSONParsing = !silentJSONParsing && JSONRequested;
1560
1575
  try {
1561
- return JSON.parse(data, this.parseReviver);
1576
+ return JSON.parse(data, own(this, 'parseReviver'));
1562
1577
  } catch (e) {
1563
1578
  if (strictJSONParsing) {
1564
1579
  if (e.name === 'SyntaxError') {
1565
- throw AxiosError.from(e, AxiosError.ERR_BAD_RESPONSE, this, null, this.response);
1580
+ throw AxiosError.from(e, AxiosError.ERR_BAD_RESPONSE, this, null, own(this, 'response'));
1566
1581
  }
1567
1582
  throw e;
1568
1583
  }
@@ -1641,38 +1656,37 @@ var parseHeaders = rawHeaders => {
1641
1656
  };
1642
1657
 
1643
1658
  const $internals = Symbol('internals');
1644
- const isValidHeaderValue = value => !/[\r\n]/.test(value);
1645
- function assertValidHeaderValue(value, header) {
1646
- if (value === false || value == null) {
1647
- return;
1648
- }
1649
- if (utils$1.isArray(value)) {
1650
- value.forEach(v => assertValidHeaderValue(v, header));
1651
- return;
1659
+ const INVALID_HEADER_VALUE_CHARS_RE = /[^\x09\x20-\x7E\x80-\xFF]/g;
1660
+ function trimSPorHTAB(str) {
1661
+ let start = 0;
1662
+ let end = str.length;
1663
+ while (start < end) {
1664
+ const code = str.charCodeAt(start);
1665
+ if (code !== 0x09 && code !== 0x20) {
1666
+ break;
1667
+ }
1668
+ start += 1;
1652
1669
  }
1653
- if (!isValidHeaderValue(String(value))) {
1654
- throw new Error(`Invalid character in header content ["${header}"]`);
1670
+ while (end > start) {
1671
+ const code = str.charCodeAt(end - 1);
1672
+ if (code !== 0x09 && code !== 0x20) {
1673
+ break;
1674
+ }
1675
+ end -= 1;
1655
1676
  }
1677
+ return start === 0 && end === str.length ? str : str.slice(start, end);
1656
1678
  }
1657
1679
  function normalizeHeader(header) {
1658
1680
  return header && String(header).trim().toLowerCase();
1659
1681
  }
1660
- function stripTrailingCRLF(str) {
1661
- let end = str.length;
1662
- while (end > 0) {
1663
- const charCode = str.charCodeAt(end - 1);
1664
- if (charCode !== 10 && charCode !== 13) {
1665
- break;
1666
- }
1667
- end -= 1;
1668
- }
1669
- return end === str.length ? str : str.slice(0, end);
1682
+ function sanitizeHeaderValue(str) {
1683
+ return trimSPorHTAB(str.replace(INVALID_HEADER_VALUE_CHARS_RE, ''));
1670
1684
  }
1671
1685
  function normalizeValue(value) {
1672
1686
  if (value === false || value == null) {
1673
1687
  return value;
1674
1688
  }
1675
- return utils$1.isArray(value) ? value.map(normalizeValue) : stripTrailingCRLF(String(value));
1689
+ return utils$1.isArray(value) ? value.map(normalizeValue) : sanitizeHeaderValue(String(value));
1676
1690
  }
1677
1691
  function parseTokens(str) {
1678
1692
  const tokens = Object.create(null);
@@ -1728,7 +1742,6 @@ class AxiosHeaders {
1728
1742
  }
1729
1743
  const key = utils$1.findKey(self, lHeader);
1730
1744
  if (!key || self[key] === undefined || _rewrite === true || _rewrite === undefined && self[key] !== false) {
1731
- assertValidHeaderValue(_value, _header);
1732
1745
  self[key || _header] = normalizeValue(_value);
1733
1746
  }
1734
1747
  }
@@ -1998,7 +2011,7 @@ function combineURLs(baseURL, relativeURL) {
1998
2011
  */
1999
2012
  function buildFullPath(baseURL, requestedURL, allowAbsoluteUrls) {
2000
2013
  let isRelativeUrl = !isAbsoluteURL(requestedURL);
2001
- if (baseURL && (isRelativeUrl || allowAbsoluteUrls == false)) {
2014
+ if (baseURL && (isRelativeUrl || allowAbsoluteUrls === false)) {
2002
2015
  return combineURLs(baseURL, requestedURL);
2003
2016
  }
2004
2017
  return requestedURL;
@@ -2100,7 +2113,7 @@ function getEnv(key) {
2100
2113
  return process.env[key.toLowerCase()] || process.env[key.toUpperCase()] || '';
2101
2114
  }
2102
2115
 
2103
- const VERSION = "1.15.0";
2116
+ const VERSION = "1.15.1";
2104
2117
 
2105
2118
  function parseProtocol(url) {
2106
2119
  const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
@@ -2291,7 +2304,8 @@ class FormDataPart {
2291
2304
  if (isStringValue) {
2292
2305
  value = textEncoder.encode(String(value).replace(/\r?\n|\r\n?/g, CRLF));
2293
2306
  } else {
2294
- headers += `Content-Type: ${value.type || 'application/octet-stream'}${CRLF}`;
2307
+ const safeType = String(value.type || 'application/octet-stream').replace(/[\r\n]/g, '');
2308
+ headers += `Content-Type: ${safeType}${CRLF}`;
2295
2309
  }
2296
2310
  this.headers = textEncoder.encode(headers + CRLF);
2297
2311
  this.contentLength = isStringValue ? value.byteLength : value.size;
@@ -2392,6 +2406,47 @@ const callbackify = (fn, reducer) => {
2392
2406
  } : fn;
2393
2407
  };
2394
2408
 
2409
+ const LOOPBACK_HOSTNAMES = new Set(['localhost']);
2410
+ const isIPv4Loopback = host => {
2411
+ const parts = host.split('.');
2412
+ if (parts.length !== 4) return false;
2413
+ if (parts[0] !== '127') return false;
2414
+ return parts.every(p => /^\d+$/.test(p) && Number(p) >= 0 && Number(p) <= 255);
2415
+ };
2416
+ const isIPv6Loopback = host => {
2417
+ // Collapse all-zero groups: any form of ::1 / 0:0:...:0:1
2418
+ // First, strip any leading "::" by normalising with Set lookup of common forms,
2419
+ // then fall back to structural check.
2420
+ if (host === '::1') return true;
2421
+
2422
+ // Check IPv4-mapped IPv6 loopback: ::ffff:<v4-loopback> or ::ffff:<hex-v4-loopback>
2423
+ // Node's URL parser normalises ::ffff:127.0.0.1 → ::ffff:7f00:1
2424
+ const v4MappedDotted = host.match(/^::ffff:(\d+\.\d+\.\d+\.\d+)$/i);
2425
+ if (v4MappedDotted) return isIPv4Loopback(v4MappedDotted[1]);
2426
+ const v4MappedHex = host.match(/^::ffff:([0-9a-f]{1,4}):([0-9a-f]{1,4})$/i);
2427
+ if (v4MappedHex) {
2428
+ const high = parseInt(v4MappedHex[1], 16);
2429
+ // High 16 bits must start with 127 (0x7f) — i.e. 0x7f00..0x7fff
2430
+ return high >= 0x7f00 && high <= 0x7fff;
2431
+ }
2432
+
2433
+ // Full-form ::1 variants: any number of zero groups followed by trailing 1
2434
+ // e.g. 0:0:0:0:0:0:0:1, 0000:...:0001
2435
+ const groups = host.split(':');
2436
+ if (groups.length === 8) {
2437
+ for (let i = 0; i < 7; i++) {
2438
+ if (!/^0+$/.test(groups[i])) return false;
2439
+ }
2440
+ return /^0*1$/.test(groups[7]);
2441
+ }
2442
+ return false;
2443
+ };
2444
+ const isLoopback = host => {
2445
+ if (!host) return false;
2446
+ if (LOOPBACK_HOSTNAMES.has(host)) return true;
2447
+ if (isIPv4Loopback(host)) return true;
2448
+ return isIPv6Loopback(host);
2449
+ };
2395
2450
  const DEFAULT_PORTS = {
2396
2451
  http: 80,
2397
2452
  https: 443,
@@ -2464,7 +2519,7 @@ function shouldBypassProxy(location) {
2464
2519
  if (entryHost.charAt(0) === '.') {
2465
2520
  return hostname.endsWith(entryHost);
2466
2521
  }
2467
- return hostname === entryHost;
2522
+ return hostname === entryHost || isLoopback(hostname) && isLoopback(entryHost);
2468
2523
  });
2469
2524
  }
2470
2525
 
@@ -2551,19 +2606,19 @@ const progressEventReducer = (listener, isDownloadStream, freq = 3) => {
2551
2606
  let bytesNotified = 0;
2552
2607
  const _speedometer = speedometer(50, 250);
2553
2608
  return throttle(e => {
2554
- const loaded = e.loaded;
2609
+ const rawLoaded = e.loaded;
2555
2610
  const total = e.lengthComputable ? e.total : undefined;
2556
- const progressBytes = loaded - bytesNotified;
2611
+ const loaded = total != null ? Math.min(rawLoaded, total) : rawLoaded;
2612
+ const progressBytes = Math.max(0, loaded - bytesNotified);
2557
2613
  const rate = _speedometer(progressBytes);
2558
- const inRange = loaded <= total;
2559
- bytesNotified = loaded;
2614
+ bytesNotified = Math.max(bytesNotified, loaded);
2560
2615
  const data = {
2561
2616
  loaded,
2562
2617
  total,
2563
2618
  progress: total ? loaded / total : undefined,
2564
2619
  bytes: progressBytes,
2565
2620
  rate: rate ? rate : undefined,
2566
- estimated: rate && total && inRange ? (total - loaded) / rate : undefined,
2621
+ estimated: rate && total ? (total - loaded) / rate : undefined,
2567
2622
  event: e,
2568
2623
  lengthComputable: total != null,
2569
2624
  [isDownloadStream ? 'download' : 'upload']: true
@@ -2891,17 +2946,15 @@ const http2Transport = {
2891
2946
  /*eslint consistent-return:0*/
2892
2947
  var httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
2893
2948
  return wrapAsync(async function dispatchHttpRequest(resolve, reject, onDone) {
2894
- let {
2895
- data,
2896
- lookup,
2897
- family,
2898
- httpVersion = 1,
2899
- http2Options
2900
- } = config;
2901
- const {
2902
- responseType,
2903
- responseEncoding
2904
- } = config;
2949
+ const own = key => utils$1.hasOwnProp(config, key) ? config[key] : undefined;
2950
+ let data = own('data');
2951
+ let lookup = own('lookup');
2952
+ let family = own('family');
2953
+ let httpVersion = own('httpVersion');
2954
+ if (httpVersion === undefined) httpVersion = 1;
2955
+ let http2Options = own('http2Options');
2956
+ const responseType = own('responseType');
2957
+ const responseEncoding = own('responseEncoding');
2905
2958
  const method = config.method.toUpperCase();
2906
2959
  let isDone;
2907
2960
  let rejected = false;
@@ -3045,7 +3098,7 @@ var httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
3045
3098
  boundary: userBoundary && userBoundary[1] || undefined
3046
3099
  });
3047
3100
  // support for https://www.npmjs.com/package/form-data api
3048
- } else if (utils$1.isFormData(data) && utils$1.isFunction(data.getHeaders)) {
3101
+ } else if (utils$1.isFormData(data) && utils$1.isFunction(data.getHeaders) && data.getHeaders !== Object.prototype.getHeaders) {
3049
3102
  headers.set(data.getHeaders());
3050
3103
  if (!headers.hasContentLength()) {
3051
3104
  try {
@@ -3147,8 +3200,9 @@ var httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
3147
3200
  if (isHttp2) {
3148
3201
  transport = http2Transport;
3149
3202
  } else {
3150
- if (config.transport) {
3151
- transport = config.transport;
3203
+ const configTransport = own('transport');
3204
+ if (configTransport) {
3205
+ transport = configTransport;
3152
3206
  } else if (config.maxRedirects === 0) {
3153
3207
  transport = isHttpsRequest ? https : http;
3154
3208
  } else {
@@ -3234,6 +3288,25 @@ var httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
3234
3288
  request: lastRequest
3235
3289
  };
3236
3290
  if (responseType === 'stream') {
3291
+ // Enforce maxContentLength on streamed responses; previously this
3292
+ // was applied only to buffered responses. See GHSA-vf2m-468p-8v99.
3293
+ if (config.maxContentLength > -1) {
3294
+ const limit = config.maxContentLength;
3295
+ const source = responseStream;
3296
+ async function* enforceMaxContentLength() {
3297
+ let totalResponseBytes = 0;
3298
+ for await (const chunk of source) {
3299
+ totalResponseBytes += chunk.length;
3300
+ if (totalResponseBytes > limit) {
3301
+ throw new AxiosError('maxContentLength size of ' + limit + ' exceeded', AxiosError.ERR_BAD_RESPONSE, config, lastRequest);
3302
+ }
3303
+ yield chunk;
3304
+ }
3305
+ }
3306
+ responseStream = stream.Readable.from(enforceMaxContentLength(), {
3307
+ objectMode: false
3308
+ });
3309
+ }
3237
3310
  response.data = responseStream;
3238
3311
  settle(resolve, reject, response);
3239
3312
  } else {
@@ -3303,6 +3376,17 @@ var httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
3303
3376
  req.on('socket', function handleRequestSocket(socket) {
3304
3377
  // default interval of sending ack packet is 1 minute
3305
3378
  socket.setKeepAlive(true, 1000 * 60);
3379
+ const removeSocketErrorListener = () => {
3380
+ socket.removeListener('error', handleRequestSocketError);
3381
+ };
3382
+ function handleRequestSocketError(err) {
3383
+ removeSocketErrorListener();
3384
+ if (!req.destroyed) {
3385
+ req.destroy(err);
3386
+ }
3387
+ }
3388
+ socket.on('error', handleRequestSocketError);
3389
+ req.once('close', removeSocketErrorListener);
3306
3390
  });
3307
3391
 
3308
3392
  // Handle request timeout
@@ -3349,7 +3433,28 @@ var httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
3349
3433
  abort(new CanceledError('Request stream has been aborted', config, req));
3350
3434
  }
3351
3435
  });
3352
- data.pipe(req);
3436
+
3437
+ // Enforce maxBodyLength for streamed uploads on the native http/https
3438
+ // transport (maxRedirects === 0); follow-redirects enforces it on the
3439
+ // other path. See GHSA-5c9x-8gcm-mpgx.
3440
+ let uploadStream = data;
3441
+ if (config.maxBodyLength > -1 && config.maxRedirects === 0) {
3442
+ const limit = config.maxBodyLength;
3443
+ let bytesSent = 0;
3444
+ uploadStream = stream.pipeline([data, new stream.Transform({
3445
+ transform(chunk, _enc, cb) {
3446
+ bytesSent += chunk.length;
3447
+ if (bytesSent > limit) {
3448
+ return cb(new AxiosError('Request body larger than maxBodyLength limit', AxiosError.ERR_BAD_REQUEST, config, req));
3449
+ }
3450
+ cb(null, chunk);
3451
+ }
3452
+ })], utils$1.noop);
3453
+ uploadStream.on('error', err => {
3454
+ if (!req.destroyed) req.destroy(err);
3455
+ });
3456
+ }
3457
+ uploadStream.pipe(req);
3353
3458
  } else {
3354
3459
  data && req.write(data);
3355
3460
  req.end();
@@ -3458,9 +3563,9 @@ function mergeConfig(config1, config2) {
3458
3563
 
3459
3564
  // eslint-disable-next-line consistent-return
3460
3565
  function mergeDirectKeys(a, b, prop) {
3461
- if (prop in config2) {
3566
+ if (utils$1.hasOwnProp(config2, prop)) {
3462
3567
  return getMergedValue(a, b);
3463
- } else if (prop in config1) {
3568
+ } else if (utils$1.hasOwnProp(config1, prop)) {
3464
3569
  return getMergedValue(undefined, a);
3465
3570
  }
3466
3571
  }
@@ -3501,7 +3606,9 @@ function mergeConfig(config1, config2) {
3501
3606
  }), function computeConfigValue(prop) {
3502
3607
  if (prop === '__proto__' || prop === 'constructor' || prop === 'prototype') return;
3503
3608
  const merge = utils$1.hasOwnProp(mergeMap, prop) ? mergeMap[prop] : mergeDeepProperties;
3504
- const configValue = merge(config1[prop], config2[prop], prop);
3609
+ const a = utils$1.hasOwnProp(config1, prop) ? config1[prop] : undefined;
3610
+ const b = utils$1.hasOwnProp(config2, prop) ? config2[prop] : undefined;
3611
+ const configValue = merge(a, b, prop);
3505
3612
  utils$1.isUndefined(configValue) && merge !== mergeDirectKeys || (config[prop] = configValue);
3506
3613
  });
3507
3614
  return config;
@@ -3545,9 +3652,15 @@ var resolveConfig = config => {
3545
3652
  // Specifically not if we're in a web worker, or react-native.
3546
3653
 
3547
3654
  if (platform.hasStandardBrowserEnv) {
3548
- withXSRFToken && utils$1.isFunction(withXSRFToken) && (withXSRFToken = withXSRFToken(newConfig));
3549
- if (withXSRFToken || withXSRFToken !== false && isURLSameOrigin(newConfig.url)) {
3550
- // Add xsrf header
3655
+ if (utils$1.isFunction(withXSRFToken)) {
3656
+ withXSRFToken = withXSRFToken(newConfig);
3657
+ }
3658
+
3659
+ // Strict boolean check — prevents proto-pollution gadgets (e.g. Object.prototype.withXSRFToken = 1)
3660
+ // and misconfigurations (e.g. "false") from short-circuiting the same-origin check and leaking
3661
+ // the XSRF token cross-origin. See GHSA-xx6v-rp6x-q39c.
3662
+ const shouldSendXSRF = withXSRFToken === true || withXSRFToken == null && isURLSameOrigin(newConfig.url);
3663
+ if (shouldSendXSRF) {
3551
3664
  const xsrfValue = xsrfHeaderName && xsrfCookieName && cookies.read(xsrfCookieName);
3552
3665
  if (xsrfValue) {
3553
3666
  headers.set(xsrfHeaderName, xsrfValue);
@@ -3889,16 +4002,18 @@ const factory = env => {
3889
4002
  const encodeText = isFetchSupported && (typeof TextEncoder$1 === 'function' ? (encoder => str => encoder.encode(str))(new TextEncoder$1()) : async str => new Uint8Array(await new Request(str).arrayBuffer()));
3890
4003
  const supportsRequestStream = isRequestSupported && isReadableStreamSupported && test(() => {
3891
4004
  let duplexAccessed = false;
3892
- const body = new ReadableStream$1();
3893
- const hasContentType = new Request(platform.origin, {
3894
- body,
4005
+ const request = new Request(platform.origin, {
4006
+ body: new ReadableStream$1(),
3895
4007
  method: 'POST',
3896
4008
  get duplex() {
3897
4009
  duplexAccessed = true;
3898
4010
  return 'half';
3899
4011
  }
3900
- }).headers.has('Content-Type');
3901
- body.cancel();
4012
+ });
4013
+ const hasContentType = request.headers.has('Content-Type');
4014
+ if (request.body != null) {
4015
+ request.body.cancel();
4016
+ }
3902
4017
  return duplexAccessed && !hasContentType;
3903
4018
  });
3904
4019
  const supportsResponseStream = isResponseSupported && isReadableStreamSupported && test(() => utils$1.isReadableStream(new Response('').body));
@@ -3990,6 +4105,15 @@ const factory = env => {
3990
4105
  // Cloudflare Workers throws when credentials are defined
3991
4106
  // see https://github.com/cloudflare/workerd/issues/902
3992
4107
  const isCredentialsSupported = isRequestSupported && 'credentials' in Request.prototype;
4108
+
4109
+ // If data is FormData and Content-Type is multipart/form-data without boundary,
4110
+ // delete it so fetch can set it correctly with the boundary
4111
+ if (utils$1.isFormData(data)) {
4112
+ const contentType = headers.getContentType();
4113
+ if (contentType && /^multipart\/form-data/i.test(contentType) && !/boundary=/i.test(contentType)) {
4114
+ headers.delete('content-type');
4115
+ }
4116
+ }
3993
4117
  const resolvedOptions = {
3994
4118
  ...fetchOptions,
3995
4119
  signal: composedSignal,