maka-agent 0.2.0-dev.64.20260929 → 0.2.0-dev.67.20261002

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 (94) hide show
  1. package/LICENSE +1 -1
  2. package/THIRD_PARTY_NOTICES.txt +3 -3
  3. package/dist/pi-tui-runner.js +26 -29
  4. package/dist/tui-copy-catalog.js +9 -9
  5. package/native/runtime-host-peer/prebuilds/darwin-arm64/maka_runtime_host_peer.node +0 -0
  6. package/native/runtime-host-peer/prebuilds/linux-arm64/maka_runtime_host_peer.node +0 -0
  7. package/native/runtime-host-peer/prebuilds/linux-x64/maka_runtime_host_peer.node +0 -0
  8. package/native/runtime-host-peer/prebuilds/win32-x64/maka_runtime_host_peer.node +0 -0
  9. package/native/runtime-host-windows-task-launcher/prebuilds/win32-x64/maka-runtime-host-task-launcher.exe +0 -0
  10. package/node_modules/@maka/core/dist/settings.js +2 -2
  11. package/node_modules/@maka/core/dist/tool-ledger-scanner.js +53 -150
  12. package/node_modules/@maka/runtime/dist/ai-sdk-compaction.js +8 -1
  13. package/node_modules/@maka/runtime/dist/conversation-copy.js +6 -0
  14. package/node_modules/@maka/runtime/dist/runtime-event-read-model.js +17 -0
  15. package/node_modules/@maka/runtime/dist/session-manager.js +25 -40
  16. package/node_modules/@maka/runtime/dist/stream-graph-coordinator.js +79 -13
  17. package/node_modules/@maka/runtime/dist/stream-graph-projection.js +64 -0
  18. package/node_modules/@maka/runtime/dist/stream-graph-read-model.js +138 -20
  19. package/node_modules/@maka/runtime/dist/tool-availability.js +10 -3
  20. package/node_modules/@maka/runtime-host/dist/candidate-entry.js +15 -0
  21. package/node_modules/@maka/runtime-host/dist/candidate-startup-failure.js +5 -0
  22. package/node_modules/@maka/runtime-host/dist/client/session-catalog-summary.js +1 -0
  23. package/node_modules/@maka/runtime-host/dist/client/startup-error.js +5 -0
  24. package/node_modules/@maka/runtime-host/dist/protocol/agent-graph.js +46 -1
  25. package/node_modules/@maka/runtime-host/dist/protocol/index.js +14 -1
  26. package/node_modules/@maka/runtime-host/dist/protocol/operations.js +5 -1
  27. package/node_modules/@maka/runtime-host/dist/protocol/session-catalog.js +12 -0
  28. package/node_modules/@maka/runtime-host/dist/protocol/session-retirement.js +46 -10
  29. package/node_modules/@maka/runtime-host/dist/protocol/storage-usage.js +155 -0
  30. package/node_modules/@maka/runtime-host/dist/server/agent-graph-coordinator.js +23 -0
  31. package/node_modules/@maka/runtime-host/dist/server/canonical-turn-snapshot.js +5 -0
  32. package/node_modules/@maka/runtime-host/dist/server/execution-composition.js +27 -6
  33. package/node_modules/@maka/runtime-host/dist/server/hosted-execution-tool-profile.js +2 -0
  34. package/node_modules/@maka/runtime-host/dist/server/session-catalog-coordinator.js +6 -0
  35. package/node_modules/@maka/runtime-host/dist/server/session-retirement-coordinator.js +112 -36
  36. package/node_modules/@maka/runtime-host/dist/server/session-revision-coordinator.js +27 -1
  37. package/node_modules/@maka/runtime-host/dist/server/storage-usage-coordinator.js +67 -0
  38. package/node_modules/@maka/runtime-host/dist/server/workhub-inspection-tool.js +208 -0
  39. package/node_modules/@maka/storage/dist/git-worktree-child-executor.js +3 -1
  40. package/node_modules/@maka/storage/dist/operational-state-store.js +0 -13
  41. package/node_modules/@maka/storage/dist/session-store.js +9 -6
  42. package/node_modules/@maka/storage/dist/sqlite-file-set.js +22 -0
  43. package/node_modules/@maka/storage/dist/sqlite-long-term-memory-store.js +1 -3
  44. package/node_modules/@maka/storage/dist/sqlite-runtime-store.js +10 -260
  45. package/node_modules/@maka/storage/dist/sqlite-session-catalog-query.js +1 -0
  46. package/node_modules/@maka/storage/dist/sqlite-session-metadata-schema.js +18 -6
  47. package/node_modules/@maka/storage/dist/sqlite-session-metadata-store.js +28 -6
  48. package/node_modules/@maka/storage/dist/storage-footprint.js +239 -0
  49. package/node_modules/@maka/storage/dist/storage-writer-composition.js +10 -1
  50. package/node_modules/axios/CHANGELOG.md +62 -0
  51. package/node_modules/axios/README.md +297 -5
  52. package/node_modules/axios/dist/axios.js +728 -170
  53. package/node_modules/axios/dist/axios.min.js +3 -3
  54. package/node_modules/axios/dist/browser/axios.cjs +871 -188
  55. package/node_modules/axios/dist/esm/axios.js +871 -188
  56. package/node_modules/axios/dist/esm/axios.min.js +2 -2
  57. package/node_modules/axios/dist/node/axios.cjs +1037 -225
  58. package/node_modules/axios/lib/adapters/fetch.js +64 -11
  59. package/node_modules/axios/lib/adapters/http.js +140 -67
  60. package/node_modules/axios/lib/adapters/xhr.js +52 -3
  61. package/node_modules/axios/lib/core/Axios.js +43 -20
  62. package/node_modules/axios/lib/core/AxiosError.js +33 -2
  63. package/node_modules/axios/lib/core/AxiosHeaders.js +124 -1
  64. package/node_modules/axios/lib/core/InterceptorManager.js +107 -8
  65. package/node_modules/axios/lib/core/buildFullPath.js +41 -15
  66. package/node_modules/axios/lib/core/dispatchRequest.js +8 -2
  67. package/node_modules/axios/lib/core/mergeConfig.js +19 -4
  68. package/node_modules/axios/lib/core/methodList.js +17 -0
  69. package/node_modules/axios/lib/core/setFormDataHeaders.js +27 -0
  70. package/node_modules/axios/lib/defaults/index.js +2 -1
  71. package/node_modules/axios/lib/env/data.js +1 -1
  72. package/node_modules/axios/lib/helpers/Http2Sessions.js +2 -0
  73. package/node_modules/axios/lib/helpers/HttpStatusCode.js +12 -1
  74. package/node_modules/axios/lib/helpers/combineURLs.js +11 -3
  75. package/node_modules/axios/lib/helpers/composeSignals.js +12 -1
  76. package/node_modules/axios/lib/helpers/estimateDataURLDecodedBytes.js +115 -54
  77. package/node_modules/axios/lib/helpers/formDataToJSON.js +11 -5
  78. package/node_modules/axios/lib/helpers/fromDataURI.js +5 -4
  79. package/node_modules/axios/lib/helpers/normalizeURLForProtocolCheck.js +24 -0
  80. package/node_modules/axios/lib/helpers/parseHeaders.js +5 -3
  81. package/node_modules/axios/lib/helpers/progressEventReducer.js +4 -4
  82. package/node_modules/axios/lib/helpers/resolveConfig.js +5 -17
  83. package/node_modules/axios/lib/helpers/shouldBypassProxy.js +300 -5
  84. package/node_modules/axios/lib/helpers/throttle.js +3 -2
  85. package/node_modules/axios/lib/helpers/toFormData.js +17 -23
  86. package/node_modules/axios/lib/platform/node/classes/Buffer.js +11 -0
  87. package/node_modules/axios/lib/utils.js +151 -18
  88. package/node_modules/axios/package.json +21 -19
  89. package/node_modules/brace-expansion/dist/commonjs/index.js +69 -25
  90. package/node_modules/brace-expansion/dist/esm/index.js +68 -24
  91. package/node_modules/brace-expansion/package.json +2 -1
  92. package/node_modules/fast-uri/index.js +10 -6
  93. package/node_modules/fast-uri/package.json +1 -1
  94. package/package.json +1 -1
@@ -15,6 +15,7 @@ class Http2Sessions {
15
15
 
16
16
  getSession(authority, options) {
17
17
  options = Object.assign(
18
+ Object.create(null),
18
19
  {
19
20
  sessionTimeout: 1000,
20
21
  },
@@ -105,6 +106,7 @@ class Http2Sessions {
105
106
  }
106
107
 
107
108
  session.once('close', removeSession);
109
+ session.once('error', removeSession);
108
110
 
109
111
  let entry = [session, options];
110
112
 
@@ -35,14 +35,22 @@ const HttpStatusCode = {
35
35
  Gone: 410,
36
36
  LengthRequired: 411,
37
37
  PreconditionFailed: 412,
38
+ /**
39
+ * @deprecated Use `ContentTooLarge` instead.
40
+ */
38
41
  PayloadTooLarge: 413,
42
+ ContentTooLarge: 413,
39
43
  UriTooLong: 414,
40
44
  UnsupportedMediaType: 415,
41
45
  RangeNotSatisfiable: 416,
42
46
  ExpectationFailed: 417,
43
47
  ImATeapot: 418,
44
48
  MisdirectedRequest: 421,
49
+ /**
50
+ * @deprecated Use `UnprocessableContent` instead.
51
+ */
45
52
  UnprocessableEntity: 422,
53
+ UnprocessableContent: 422,
46
54
  Locked: 423,
47
55
  FailedDependency: 424,
48
56
  TooEarly: 425,
@@ -62,6 +70,7 @@ const HttpStatusCode = {
62
70
  LoopDetected: 508,
63
71
  NotExtended: 510,
64
72
  NetworkAuthenticationRequired: 511,
73
+ WebServerReturnsAnUnknownError: 520,
65
74
  WebServerIsDown: 521,
66
75
  ConnectionTimedOut: 522,
67
76
  OriginIsUnreachable: 523,
@@ -71,7 +80,9 @@ const HttpStatusCode = {
71
80
  };
72
81
 
73
82
  Object.entries(HttpStatusCode).forEach(([key, value]) => {
74
- HttpStatusCode[value] = key;
83
+ if (HttpStatusCode[value] === undefined) {
84
+ HttpStatusCode[value] = key;
85
+ }
75
86
  });
76
87
 
77
88
  export default HttpStatusCode;
@@ -9,7 +9,15 @@
9
9
  * @returns {string} The combined URL
10
10
  */
11
11
  export default function combineURLs(baseURL, relativeURL) {
12
- return relativeURL
13
- ? baseURL.replace(/\/?\/$/, '') + '/' + relativeURL.replace(/^\/+/, '')
14
- : baseURL;
12
+ if (!relativeURL) {
13
+ return baseURL;
14
+ }
15
+
16
+ let end = baseURL.length;
17
+
18
+ while (end > 0 && baseURL.charCodeAt(end - 1) === 47) {
19
+ end--;
20
+ }
21
+
22
+ return baseURL.slice(0, end) + '/' + relativeURL.replace(/^\/+/, '');
15
23
  }
@@ -45,7 +45,18 @@ const composeSignals = (signals, timeout) => {
45
45
  signals = null;
46
46
  };
47
47
 
48
- signals.forEach((signal) => signal.addEventListener('abort', onabort, { once: true }));
48
+ signals.forEach((signal) => {
49
+ if (aborted) {
50
+ return;
51
+ }
52
+
53
+ if (signal.aborted) {
54
+ onabort.call(signal);
55
+ return;
56
+ }
57
+
58
+ signal.addEventListener('abort', onabort, { once: true });
59
+ });
49
60
 
50
61
  const { signal } = controller;
51
62
 
@@ -1,11 +1,9 @@
1
1
  /**
2
- * Estimate decoded byte length of a data:// URL *without* allocating large buffers.
3
- * - For base64: compute exact decoded size using length and padding;
4
- * handle %XX at the character-count level (no string allocation).
5
- * - For non-base64: compute the exact percent-decoded UTF-8 byte length.
6
- *
7
- * @param {string} url
8
- * @returns {number}
2
+ * Estimate data: URL byte lengths *without* allocating large buffers.
3
+ * - Fetch percent-decodes a base64 body before decoding it.
4
+ * - Node's Buffer.from(body, 'base64') sizes its backing allocation from the
5
+ * raw body, including ignored characters and content after padding.
6
+ * - Non-base64 data is percent-decoded and then encoded as UTF-8.
9
7
  */
10
8
  const isHexDigit = (charCode) =>
11
9
  (charCode >= 48 && charCode <= 57) ||
@@ -15,7 +13,89 @@ const isHexDigit = (charCode) =>
15
13
  const isPercentEncodedByte = (str, i, len) =>
16
14
  i + 2 < len && isHexDigit(str.charCodeAt(i + 1)) && isHexDigit(str.charCodeAt(i + 2));
17
15
 
18
- export default function estimateDataURLDecodedBytes(url) {
16
+ const hexValue = (charCode) => (charCode <= 57 ? charCode - 48 : (charCode & 0xdf) - 55);
17
+
18
+ const isBase64Char = (charCode) =>
19
+ (charCode >= 65 && charCode <= 90) || // A-Z
20
+ (charCode >= 97 && charCode <= 122) || // a-z
21
+ (charCode >= 48 && charCode <= 57) || // 0-9
22
+ charCode === 43 || // +
23
+ charCode === 47 || // /
24
+ charCode === 45 || // - (base64url)
25
+ charCode === 95; // _ (base64url)
26
+
27
+ const isBase64Whitespace = (charCode) =>
28
+ charCode === 9 || charCode === 10 || charCode === 12 || charCode === 13 || charCode === 32;
29
+
30
+ const base64Bytes = (significant) => {
31
+ const groups = Math.floor(significant / 4);
32
+ const remainder = significant % 4;
33
+ return groups * 3 + (remainder === 2 ? 1 : remainder === 3 ? 2 : 0);
34
+ };
35
+
36
+ // Buffer.byteLength(body, 'base64') uses the raw string length as an allocation
37
+ // upper bound even when Buffer.from later ignores characters or stops at '='.
38
+ const estimateBase64BufferAllocation = (body) => {
39
+ const len = body.length;
40
+ let padding = 0;
41
+
42
+ if (len > 0 && body.charCodeAt(len - 1) === 61 /* '=' */) {
43
+ padding++;
44
+
45
+ if (len > 1 && body.charCodeAt(len - 2) === 61 /* '=' */) {
46
+ padding++;
47
+ }
48
+ }
49
+
50
+ return Math.floor(((len - padding) * 3) / 4);
51
+ };
52
+
53
+ const estimatePercentDecodedBase64Bytes = (body) => {
54
+ const len = body.length;
55
+ let significant = 0;
56
+ let padding = 0;
57
+ let invalid = false;
58
+
59
+ for (let i = 0; i < len; i++) {
60
+ let code = body.charCodeAt(i);
61
+
62
+ if (code === 37 /* '%' */ && isPercentEncodedByte(body, i, len)) {
63
+ code = hexValue(body.charCodeAt(i + 1)) * 16 + hexValue(body.charCodeAt(i + 2));
64
+ i += 2;
65
+ }
66
+
67
+ if (isBase64Whitespace(code)) {
68
+ continue;
69
+ }
70
+
71
+ if (code === 61 /* '=' */) {
72
+ padding++;
73
+ continue;
74
+ }
75
+
76
+ if (!isBase64Char(code) || padding > 0) {
77
+ invalid = true;
78
+ continue;
79
+ }
80
+
81
+ significant++;
82
+ }
83
+
84
+ // Fetch rejects malformed forgiving-base64 input. Returning the raw-size
85
+ // allocation bound keeps that invalid input from becoming a pre-check bypass.
86
+ if (
87
+ invalid ||
88
+ padding > 2 ||
89
+ (padding > 0 && (significant + padding) % 4 !== 0) ||
90
+ significant % 4 === 1
91
+ ) {
92
+ return estimateBase64BufferAllocation(body);
93
+ }
94
+
95
+ return base64Bytes(significant);
96
+ };
97
+
98
+ const estimateDataURLBytes = (url, estimateBase64) => {
19
99
  if (!url || typeof url !== 'string') return 0;
20
100
  if (!url.startsWith('data:')) return 0;
21
101
 
@@ -27,52 +107,7 @@ export default function estimateDataURLDecodedBytes(url) {
27
107
  const isBase64 = /;base64/i.test(meta);
28
108
 
29
109
  if (isBase64) {
30
- let effectiveLen = body.length;
31
- const len = body.length; // cache length
32
-
33
- for (let i = 0; i < len; i++) {
34
- if (body.charCodeAt(i) === 37 /* '%' */ && i + 2 < len) {
35
- const a = body.charCodeAt(i + 1);
36
- const b = body.charCodeAt(i + 2);
37
- const isHex = isHexDigit(a) && isHexDigit(b);
38
-
39
- if (isHex) {
40
- effectiveLen -= 2;
41
- i += 2;
42
- }
43
- }
44
- }
45
-
46
- let pad = 0;
47
- let idx = len - 1;
48
-
49
- const tailIsPct3D = (j) =>
50
- j >= 2 &&
51
- body.charCodeAt(j - 2) === 37 && // '%'
52
- body.charCodeAt(j - 1) === 51 && // '3'
53
- (body.charCodeAt(j) === 68 || body.charCodeAt(j) === 100); // 'D' or 'd'
54
-
55
- if (idx >= 0) {
56
- if (body.charCodeAt(idx) === 61 /* '=' */) {
57
- pad++;
58
- idx--;
59
- } else if (tailIsPct3D(idx)) {
60
- pad++;
61
- idx -= 3;
62
- }
63
- }
64
-
65
- if (pad === 1 && idx >= 0) {
66
- if (body.charCodeAt(idx) === 61 /* '=' */) {
67
- pad++;
68
- } else if (tailIsPct3D(idx)) {
69
- pad++;
70
- }
71
- }
72
-
73
- const groups = Math.floor(effectiveLen / 4);
74
- const bytes = groups * 3 - (pad || 0);
75
- return bytes > 0 ? bytes : 0;
110
+ return estimateBase64(body);
76
111
  }
77
112
 
78
113
  // Compute UTF-8 byte length directly from UTF-16 code units without allocating
@@ -102,4 +137,30 @@ export default function estimateDataURLDecodedBytes(url) {
102
137
  }
103
138
  }
104
139
  return bytes;
140
+ };
141
+
142
+ /**
143
+ * Estimate the percent-decoded payload size used by Fetch data: URLs.
144
+ *
145
+ * @param {string} url
146
+ * @returns {number}
147
+ */
148
+ export default function estimateDataURLDecodedBytes(url) {
149
+ // Fetch removes URL fragments before processing a data: URL.
150
+ const fragmentIndex = typeof url === 'string' ? url.indexOf('#') : -1;
151
+
152
+ return estimateDataURLBytes(
153
+ fragmentIndex === -1 ? url : url.slice(0, fragmentIndex),
154
+ estimatePercentDecodedBase64Bytes
155
+ );
156
+ }
157
+
158
+ /**
159
+ * Estimate the Buffer backing allocation used by Node's raw base64 decoder.
160
+ *
161
+ * @param {string} url
162
+ * @returns {number}
163
+ */
164
+ export function estimateDataURLBufferAllocation(url) {
165
+ return estimateDataURLBytes(url, estimateBase64BufferAllocation);
105
166
  }
@@ -23,12 +23,18 @@ function throwIfDepthExceeded(index) {
23
23
  * @returns An array of strings.
24
24
  */
25
25
  function parsePropPath(name) {
26
- // foo[x][y][z]
27
- // foo.x.y.z
28
- // foo-x-y-z
29
- // foo x y z
26
+ // foo[x][y][z] -> ['foo', 'x', 'y', 'z']
27
+ // foo.x.y.z -> ['foo', 'x', 'y', 'z']
28
+ // A path is split on `.` and on `[...]` groups. A segment — whether written
29
+ // in dot notation or captured inside brackets — may contain any character
30
+ // except `.`, `[` and `]`, so a key like `user-name` or `user name` is kept
31
+ // literal instead of being split (#5402). `.`, `[` and `]` keep their existing
32
+ // meaning, e.g. `foo[bar.baz]` -> ['foo', 'bar', 'baz'] and `[]` is an array push.
33
+ // Excluding `[` from the bracket group also makes the match fail fast at the
34
+ // next `[`, so a malformed name cannot rescan to the end of the string from
35
+ // every unmatched `[` — parsing stays linear in the length of the name.
30
36
  const path = [];
31
- const pattern = /\w+|\[(\w*)]/g;
37
+ const pattern = /[^.[\]]+|\[([^.[\]]*)]/g;
32
38
  let match;
33
39
 
34
40
  while ((match = pattern.exec(name)) !== null) {
@@ -6,7 +6,7 @@ import platform from '../platform/index.js';
6
6
 
7
7
  // RFC 2397: data:[<mediatype>][;base64],<data>
8
8
  // mediatype = type/subtype followed by optional ;name=value parameters
9
- const DATA_URL_PATTERN = /^([^,;]+\/[^,;]+)?((?:;[^,;=]+=[^,;]+)*)(;base64)?,([\s\S]*)$/;
9
+ const DATA_URL_PATTERN = /^([^,;/]+\/[^,;/]+)?((?:;[^,;=]+=[^,;]+)*)(;base64)?,([\s\S]*)$/;
10
10
 
11
11
  /**
12
12
  * Parse data uri to a Buffer or Blob
@@ -49,9 +49,10 @@ export default function fromDataURI(uri, asBlob, options) {
49
49
  mime = 'text/plain' + params;
50
50
  }
51
51
 
52
- const buffer = encoding === 'base64'
53
- ? Buffer.from(body, 'base64')
54
- : Buffer.from(decodeURIComponent(body), encoding);
52
+ const buffer =
53
+ encoding === 'base64'
54
+ ? Buffer.from(body, 'base64')
55
+ : Buffer.from(decodeURIComponent(body), encoding);
55
56
 
56
57
  if (asBlob) {
57
58
  if (!_Blob) {
@@ -0,0 +1,24 @@
1
+ 'use strict';
2
+
3
+ const urlParserControlCharacters = /[\t\n\r]/g;
4
+
5
+ /**
6
+ * Match WHATWG URL preprocessing before checking a URL's protocol.
7
+ *
8
+ * @param {string} url
9
+ *
10
+ * @returns {string}
11
+ */
12
+ export default function normalizeURLForProtocolCheck(url) {
13
+ if (typeof url !== 'string') {
14
+ return url;
15
+ }
16
+
17
+ let start = 0;
18
+
19
+ while (start < url.length && url.charCodeAt(start) <= 0x20) {
20
+ start++;
21
+ }
22
+
23
+ return url.slice(start).replace(urlParserControlCharacters, '');
24
+ }
@@ -50,18 +50,20 @@ export default (rawHeaders) => {
50
50
  key = line.substring(0, i).trim().toLowerCase();
51
51
  val = line.substring(i + 1).trim();
52
52
 
53
- if (!key || (parsed[key] && ignoreDuplicateOf[key])) {
53
+ const hasKey = utils.hasOwnProp(parsed, key);
54
+
55
+ if (!key || (hasKey && utils.hasOwnProp(ignoreDuplicateOf, key))) {
54
56
  return;
55
57
  }
56
58
 
57
59
  if (key === 'set-cookie') {
58
- if (parsed[key]) {
60
+ if (hasKey) {
59
61
  parsed[key].push(val);
60
62
  } else {
61
63
  parsed[key] = [val];
62
64
  }
63
65
  } else {
64
- parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
66
+ parsed[key] = hasKey ? parsed[key] + ', ' + val : val;
65
67
  }
66
68
  });
67
69
 
@@ -7,12 +7,12 @@ export const progressEventReducer = (listener, isDownloadStream, freq = 3) => {
7
7
  const _speedometer = speedometer(50, 250);
8
8
 
9
9
  return throttle((e) => {
10
- if (!e || typeof e.loaded !== 'number') {
10
+ if (!e || !utils.isNumber(e.loaded)) {
11
11
  return;
12
12
  }
13
13
  const rawLoaded = e.loaded;
14
14
  const total = e.lengthComputable ? e.total : undefined;
15
- const loaded = total != null ? Math.min(rawLoaded, total) : rawLoaded;
15
+ const loaded = Math.max(0, total != null ? Math.min(rawLoaded, total) : rawLoaded);
16
16
  const progressBytes = Math.max(0, loaded - bytesNotified);
17
17
  const rate = _speedometer(progressBytes);
18
18
 
@@ -49,6 +49,6 @@ export const progressEventDecorator = (total, throttled) => {
49
49
  };
50
50
 
51
51
  export const asyncDecorator =
52
- (fn) =>
52
+ (fn, scheduler = utils.asap) =>
53
53
  (...args) =>
54
- utils.asap(() => fn(...args));
54
+ scheduler(() => fn(...args));
@@ -6,23 +6,9 @@ import cookies from './cookies.js';
6
6
  import buildFullPath from '../core/buildFullPath.js';
7
7
  import mergeConfig from '../core/mergeConfig.js';
8
8
  import AxiosHeaders from '../core/AxiosHeaders.js';
9
+ import setFormDataHeaders from '../core/setFormDataHeaders.js';
9
10
  import buildURL from './buildURL.js';
10
11
 
11
- const FORM_DATA_CONTENT_HEADERS = ['content-type', 'content-length'];
12
-
13
- function setFormDataHeaders(headers, formHeaders, policy) {
14
- if (policy !== 'content-only') {
15
- headers.set(formHeaders);
16
- return;
17
- }
18
-
19
- Object.entries(formHeaders || {}).forEach(([key, val]) => {
20
- if (FORM_DATA_CONTENT_HEADERS.includes(key.toLowerCase())) {
21
- headers.set(key, val);
22
- }
23
- });
24
- }
25
-
26
12
  /**
27
13
  * Encode a UTF-8 string to a Latin-1 byte string for use with btoa().
28
14
  * This is a modern replacement for the deprecated unescape(encodeURIComponent(str)) pattern.
@@ -77,15 +63,17 @@ function resolveConfig(config) {
77
63
  }
78
64
 
79
65
  if (utils.isFormData(data)) {
66
+ const getHeaders = utils.getSafeProp(data, 'getHeaders');
67
+
80
68
  if (
81
69
  platform.hasStandardBrowserEnv ||
82
70
  platform.hasStandardBrowserWebWorkerEnv ||
83
71
  utils.isReactNative(data)
84
72
  ) {
85
73
  headers.setContentType(undefined); // browser/web worker/RN handles it
86
- } else if (utils.isFunction(data.getHeaders)) {
74
+ } else if (utils.isFunction(getHeaders)) {
87
75
  // Node.js FormData (like form-data package)
88
- setFormDataHeaders(headers, data.getHeaders(), own('formDataHeaderPolicy'));
76
+ setFormDataHeaders(headers, getHeaders.call(data), own('formDataHeaderPolicy'));
89
77
  }
90
78
  }
91
79