@openclaw/discord 2026.9.8 → 2026.10.1-beta.2

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 (147) hide show
  1. package/README.md +7 -0
  2. package/dist/.setup/{account-inspect-De8hOUxG.mjs → account-inspect-CjKqkDnH.mjs} +2 -2
  3. package/dist/.setup/{accounts-ChaMcixG.mjs → accounts-DXHCL8Zm.mjs} +9 -32
  4. package/dist/.setup/{active-turn-thread-route-fmHl1HNd.mjs → active-turn-thread-route-C4tp9noA.mjs} +5 -9
  5. package/dist/.setup/{activities-api-tvbsU2e3.mjs → activities-api-BL_hJ0JQ.mjs} +15 -18
  6. package/dist/.setup/{api-DVbJwZVt.mjs → api-_oznjffB.mjs} +1 -1
  7. package/dist/.setup/{approval-handler.runtime-DxCK2Rux.mjs → approval-handler.runtime-BilYSrRF.mjs} +22 -61
  8. package/dist/.setup/{approval-message-updates-BKFqavHZ.mjs → approval-message-updates-CgRwc2_Q.mjs} +2 -2
  9. package/dist/.setup/{audit-CLg9I71N.mjs → audit-DtvzxONM.mjs} +4 -4
  10. package/dist/.setup/{channel-access-C12aDZ0p.mjs → channel-access-BRp3Y-rF.mjs} +4 -17
  11. package/dist/.setup/{channel-type-DRCrEMss.mjs → channel-type-D1_b5UhU.mjs} +12 -16
  12. package/dist/.setup/{channel-DxlUVU9t.mjs → channel-z5lQMS_9.mjs} +79 -75
  13. package/dist/.setup/{channel.setup-CRo1GjV7.mjs → channel.setup-DBJtugJO.mjs} +14 -34
  14. package/dist/.setup/{components-Cq1PvIpN.mjs → components-CzXLR3QH.mjs} +56 -72
  15. package/dist/.setup/{config-schema-oxELUSDx.mjs → config-schema-CsemBDpS.mjs} +6 -17
  16. package/dist/.setup/{conversation-binding-route-Caz_XuFH.mjs → conversation-binding-route-Bi62ApSt.mjs} +1 -1
  17. package/dist/.setup/{directory-config-esqNn0Eo.mjs → directory-config-BH1LA-gi.mjs} +1 -1
  18. package/dist/.setup/{directory-live-DtKRHuGV.mjs → directory-live-C9xz7IPm.mjs} +10 -13
  19. package/dist/.setup/{discord-0xJYfdDD.mjs → discord-J7aRzq2Q.mjs} +101 -381
  20. package/dist/.setup/{doctor-BCl1H5tl.mjs → doctor-DxSAngJq.mjs} +31 -70
  21. package/dist/.setup/doctor-contract-Bg3NPAMw.mjs +137 -0
  22. package/dist/.setup/{handle-action-CUvQWnE7.mjs → handle-action-DlmFX-_G.mjs} +10 -11
  23. package/dist/.setup/{handle-action.guild-admin-Df-8gVle.mjs → handle-action.guild-admin-BnyqTczR.mjs} +67 -129
  24. package/dist/.setup/{live-policy-config-8Pv20CHc.mjs → live-policy-config-emmPNyh4.mjs} +1 -1
  25. package/dist/.setup/{message-handler-B-Jk4oDk.mjs → message-handler-BNToPZrx.mjs} +7 -6
  26. package/dist/.setup/{message-handler.preflight-v-__NSDq.mjs → message-handler.preflight-D0BcCyI7.mjs} +13 -23
  27. package/dist/.setup/{message-handler.preflight-pluralkit-CWLUBVcx.mjs → message-handler.preflight-pluralkit-D1g3eq0B.mjs} +5 -8
  28. package/dist/.setup/{message-handler.process-BNFFuChn.mjs → message-handler.process-CThRmCWK.mjs} +57 -96
  29. package/dist/.setup/{outbound-adapter-BobT-kse.mjs → outbound-adapter-BPq0c2wY.mjs} +11 -17
  30. package/dist/.setup/{outbound-session-route-zVGxxceg.mjs → outbound-session-route-DGPPKA0z.mjs} +21 -46
  31. package/dist/.setup/{presence-cache-Di3H3DIU.mjs → presence-cache-Dg3_dADn.mjs} +2 -4
  32. package/dist/.setup/{probe-LYrIHlBF.mjs → probe-DIRY8vh7.mjs} +17 -27
  33. package/dist/.setup/{provider-B_G5hASF.mjs → provider-D2OKMo0f.mjs} +273 -446
  34. package/dist/.setup/{provider-session.runtime-BYlTBFD2.mjs → provider-session.runtime-BupCTZQv.mjs} +3 -3
  35. package/dist/.setup/provider.runtime-BaW_JnfU.mjs +2 -0
  36. package/dist/.setup/{realtime-session.runtime-oUd9DOcz.mjs → realtime-session.runtime-D5RSC8Mm.mjs} +6 -8
  37. package/dist/.setup/{receive-recovery-CHPOsnLc.mjs → receive-recovery-GqF2PUN_.mjs} +1 -4
  38. package/dist/.setup/{resolve-allowlist-common-DPdRggu5.mjs → resolve-allowlist-common-DUYRrrVB.mjs} +5 -9
  39. package/dist/.setup/{resolve-channels-BFPNRmVv.mjs → resolve-channels--MUatisx.mjs} +3 -3
  40. package/dist/.setup/{resolve-users-0-aBuCy3.mjs → resolve-users-CxLcDmM0.mjs} +6 -9
  41. package/dist/.setup/{retry-pz_cSha2.mjs → retry-BKzO25k4.mjs} +27 -51
  42. package/dist/.setup/{runtime-sUksZ--Q.mjs → runtime-CerRBfaa.mjs} +2 -2
  43. package/dist/.setup/{runtime-FN000lxA.mjs → runtime-CwUA0RLr.mjs} +228 -255
  44. package/dist/.setup/{runtime-doctor-migrations-CshUGl36.mjs → runtime-doctor-migrations-BPV-R4G9.mjs} +6 -0
  45. package/dist/.setup/{security-audit-Cdaegq7C.mjs → security-audit-D42cp5N7.mjs} +21 -48
  46. package/dist/.setup/{send-CrfEI6Bs.mjs → send-2X7m2Zmw.mjs} +45 -58
  47. package/dist/.setup/{send.components-DxQAMfES.mjs → send.components-RqvgmCs3.mjs} +44 -90
  48. package/dist/.setup/{send.outbound-BISKnb-a.mjs → send.outbound-B4QHSEzm.mjs} +60 -98
  49. package/dist/.setup/{send.shared-DGFkbkQR.mjs → send.shared-BQIUh6Vn.mjs} +13 -20
  50. package/dist/.setup/{sender-identity-B9X5Vb9R.mjs → sender-identity-CooeYfAn.mjs} +1 -1
  51. package/dist/.setup/{session-key-normalization-wJgsKPNF.mjs → session-key-normalization-CCHGNSQw.mjs} +3 -9
  52. package/dist/.setup/setup-plugin-api-nn_giXvZ.mjs +3 -0
  53. package/dist/.setup/{shared-B3wZ4hN-.mjs → shared-CIJn6AEC.mjs} +7 -7
  54. package/dist/.setup/{subagent-hooks-nlUE9ow7.mjs → subagent-hooks-BYlVnxzy.mjs} +4 -9
  55. package/dist/.setup/{system-events-CdeZnvPV.mjs → system-events-CQ3if_pS.mjs} +2 -2
  56. package/dist/.setup/{target-resolver-BuLapkhy.mjs → target-resolver-Dzxf80Y3.mjs} +5 -13
  57. package/dist/.setup/targets-Lf8D55w-.mjs +3 -0
  58. package/dist/.setup/{thread-bindings-D7TfgjR_.mjs → thread-bindings-yNNlcUWE.mjs} +5 -6
  59. package/dist/.setup/{thread-bindings.manager-DN-NissX.mjs → thread-bindings.manager-plk0zJAW.mjs} +14 -20
  60. package/dist/.setup/{thread-bindings.session-updates-CshfKghV.mjs → thread-bindings.session-updates-C9aKtVs6.mjs} +295 -5
  61. package/dist/.setup/{timeouts-D86uWLt_.mjs → timeouts-pun7VJ02.mjs} +2 -15
  62. package/dist/.setup/{transcripts-source-p8EV179h.mjs → transcripts-source-CNWswry-.mjs} +31 -79
  63. package/dist/.setup/typing-CNlSKY5S.mjs +11 -0
  64. package/dist/.setup/{voice-runtime-B46rcwrG.mjs → voice-runtime-Bc75quiH.mjs} +62 -110
  65. package/dist/account-inspect-api.js +1 -1
  66. package/dist/action-runtime-api.js +1 -1
  67. package/dist/activities-api.js +1 -1
  68. package/dist/api.js +18 -18
  69. package/dist/channel-config-api.js +1 -1
  70. package/dist/channel-plugin-api.js +1 -1
  71. package/dist/control-ui/2afbdab1d3aa65a789d8a3eba666f4b1ec5df07073538fe30d6cf32093a1fb2d/index.js +1 -0
  72. package/dist/directory-contract-api.js +1 -1
  73. package/dist/doctor-contract-api.js +19 -128
  74. package/dist/index.js +1 -1
  75. package/dist/runtime-api.js +20 -21
  76. package/dist/security-audit-contract-api.js +1 -1
  77. package/dist/session-key-api.js +1 -1
  78. package/dist/setup-entry.js +1 -1
  79. package/dist/setup-plugin-api.js +1 -1
  80. package/dist/src/voice/audio-worker.runtime.js +6 -8
  81. package/dist/subagent-hooks-api.js +1 -1
  82. package/dist/transcripts-source-api.js +1 -1
  83. package/node_modules/libopus-wasm/CHANGELOG.md +8 -0
  84. package/node_modules/libopus-wasm/dist/discordjs.d.ts.map +1 -1
  85. package/node_modules/libopus-wasm/dist/discordjs.js +14 -2
  86. package/node_modules/libopus-wasm/dist/generated/libopus.generated.mjs +0 -0
  87. package/node_modules/libopus-wasm/dist/index.d.ts.map +1 -1
  88. package/node_modules/libopus-wasm/dist/index.js +55 -100
  89. package/node_modules/libopus-wasm/package.json +5 -5
  90. package/node_modules/undici/README.md +10 -1
  91. package/node_modules/undici/docs/docs/api/Agent.md +8 -8
  92. package/node_modules/undici/docs/docs/api/DiagnosticsChannel.md +9 -6
  93. package/node_modules/undici/docs/docs/api/Dispatcher.md +9 -0
  94. package/node_modules/undici/docs/docs/api/Errors.md +25 -0
  95. package/node_modules/undici/docs/docs/api/Fetch.md +10 -0
  96. package/node_modules/undici/docs/docs/api/Interceptors.md +4 -3
  97. package/node_modules/undici/docs/docs/api/Pool.md +5 -6
  98. package/node_modules/undici/docs/docs/index.md +10 -1
  99. package/node_modules/undici/lib/api/readable.js +1 -2
  100. package/node_modules/undici/lib/core/request.js +23 -2
  101. package/node_modules/undici/lib/core/util.js +0 -39
  102. package/node_modules/undici/lib/dispatcher/client-h1.js +11 -4
  103. package/node_modules/undici/lib/dispatcher/client-h2.js +52 -8
  104. package/node_modules/undici/lib/dispatcher/client.js +6 -1
  105. package/node_modules/undici/lib/dispatcher/env-http-proxy-agent.js +21 -6
  106. package/node_modules/undici/lib/dispatcher/pool-base.js +63 -2
  107. package/node_modules/undici/lib/dispatcher/pool.js +90 -7
  108. package/node_modules/undici/lib/dispatcher/proxy-agent.js +16 -3
  109. package/node_modules/undici/lib/handler/deduplication-handler.js +24 -11
  110. package/node_modules/undici/lib/handler/redirect-handler.js +5 -0
  111. package/node_modules/undici/lib/handler/retry-handler.js +72 -13
  112. package/node_modules/undici/lib/interceptor/cache.js +4 -1
  113. package/node_modules/undici/lib/interceptor/decompress.js +236 -69
  114. package/node_modules/undici/lib/web/cache/cache.js +17 -8
  115. package/node_modules/undici/lib/web/cache/cachestorage.js +11 -5
  116. package/node_modules/undici/lib/web/cookies/index.js +19 -7
  117. package/node_modules/undici/lib/web/cookies/util.js +3 -1
  118. package/node_modules/undici/lib/web/eventsource/eventsource.js +25 -1
  119. package/node_modules/undici/lib/web/fetch/body.js +22 -15
  120. package/node_modules/undici/lib/web/fetch/data-url.js +6 -6
  121. package/node_modules/undici/lib/web/fetch/formdata.js +30 -36
  122. package/node_modules/undici/lib/web/fetch/headers.js +34 -31
  123. package/node_modules/undici/lib/web/fetch/index.js +46 -25
  124. package/node_modules/undici/lib/web/fetch/request.js +74 -79
  125. package/node_modules/undici/lib/web/fetch/response.js +43 -44
  126. package/node_modules/undici/lib/web/fetch/util.js +7 -7
  127. package/node_modules/undici/lib/web/infra/index.js +16 -1
  128. package/node_modules/undici/lib/web/webidl/index.js +2 -14
  129. package/node_modules/undici/lib/web/websocket/connection.js +33 -12
  130. package/node_modules/undici/lib/web/websocket/events.js +43 -26
  131. package/node_modules/undici/lib/web/websocket/receiver.js +2 -0
  132. package/node_modules/undici/lib/web/websocket/stream/websocketerror.js +13 -10
  133. package/node_modules/undici/lib/web/websocket/stream/websocketstream.js +19 -4
  134. package/node_modules/undici/lib/web/websocket/websocket.js +44 -41
  135. package/node_modules/undici/package.json +1 -1
  136. package/node_modules/undici/types/diagnostics-channel.d.ts +2 -1
  137. package/node_modules/undici/types/interceptors.d.ts +1 -1
  138. package/node_modules/undici/types/webidl.d.ts +13 -7
  139. package/openclaw.plugin.json +6 -0
  140. package/package.json +12 -7
  141. package/dist/.setup/doctor-contract-CvvgwrrG.mjs +0 -409
  142. package/dist/.setup/model-picker-preference-primitives-BHT1LkR_.mjs +0 -37
  143. package/dist/.setup/provider.runtime-CUE3UxER.mjs +0 -2
  144. package/dist/.setup/setup-plugin-api-BQUBxbhe.mjs +0 -3
  145. package/dist/.setup/targets-0KUcEIYx.mjs +0 -3
  146. package/dist/.setup/thread-bindings.state-g6v9zAym.mjs +0 -331
  147. package/dist/.setup/typing-BiHCzBRu.mjs +0 -15
@@ -423,6 +423,8 @@ class HeadersList {
423
423
  }
424
424
  }
425
425
 
426
+ let getHeadersGuard, setHeadersGuard, getHeadersList, setHeadersList
427
+
426
428
  // https://fetch.spec.whatwg.org/#headers-class
427
429
  class Headers {
428
430
  #guard
@@ -458,7 +460,7 @@ class Headers {
458
460
 
459
461
  // https://fetch.spec.whatwg.org/#dom-headers-append
460
462
  append (name, value) {
461
- webidl.brandCheck(this, Headers)
463
+ webidl.brandCheck(this, webidl.is.Headers)
462
464
 
463
465
  webidl.argumentLengthCheck(arguments, 2, 'Headers.append')
464
466
 
@@ -471,7 +473,7 @@ class Headers {
471
473
 
472
474
  // https://fetch.spec.whatwg.org/#dom-headers-delete
473
475
  delete (name) {
474
- webidl.brandCheck(this, Headers)
476
+ webidl.brandCheck(this, webidl.is.Headers)
475
477
 
476
478
  webidl.argumentLengthCheck(arguments, 1, 'Headers.delete')
477
479
 
@@ -515,7 +517,7 @@ class Headers {
515
517
 
516
518
  // https://fetch.spec.whatwg.org/#dom-headers-get
517
519
  get (name) {
518
- webidl.brandCheck(this, Headers)
520
+ webidl.brandCheck(this, webidl.is.Headers)
519
521
 
520
522
  webidl.argumentLengthCheck(arguments, 1, 'Headers.get')
521
523
 
@@ -538,7 +540,7 @@ class Headers {
538
540
 
539
541
  // https://fetch.spec.whatwg.org/#dom-headers-has
540
542
  has (name) {
541
- webidl.brandCheck(this, Headers)
543
+ webidl.brandCheck(this, webidl.is.Headers)
542
544
 
543
545
  webidl.argumentLengthCheck(arguments, 1, 'Headers.has')
544
546
 
@@ -561,7 +563,7 @@ class Headers {
561
563
 
562
564
  // https://fetch.spec.whatwg.org/#dom-headers-set
563
565
  set (name, value) {
564
- webidl.brandCheck(this, Headers)
566
+ webidl.brandCheck(this, webidl.is.Headers)
565
567
 
566
568
  webidl.argumentLengthCheck(arguments, 2, 'Headers.set')
567
569
 
@@ -609,7 +611,7 @@ class Headers {
609
611
 
610
612
  // https://fetch.spec.whatwg.org/#dom-headers-getsetcookie
611
613
  getSetCookie () {
612
- webidl.brandCheck(this, Headers)
614
+ webidl.brandCheck(this, webidl.is.Headers)
613
615
 
614
616
  // 1. If this’s header list does not contain `Set-Cookie`, then return « ».
615
617
  // 2. Return the values of all headers in this’s header list whose name is
@@ -630,37 +632,38 @@ class Headers {
630
632
  return `Headers ${util.formatWithOptions(options, this.#headersList.entries)}`
631
633
  }
632
634
 
633
- static getHeadersGuard (o) {
634
- return o.#guard
635
- }
635
+ static {
636
+ /** @param {Headers} headers */
637
+ getHeadersGuard = (headers) => headers.#guard
636
638
 
637
- static setHeadersGuard (o, guard) {
638
- o.#guard = guard
639
- }
639
+ /**
640
+ * @param {Headers} headers
641
+ * @param {string} guard
642
+ */
643
+ setHeadersGuard = (headers, guard) => {
644
+ headers.#guard = guard
645
+ }
640
646
 
641
- /**
642
- * @param {Headers} o
643
- */
644
- static getHeadersList (o) {
645
- return o.#headersList
646
- }
647
+ /**
648
+ * @param {Headers} headers
649
+ */
650
+ getHeadersList = (headers) => headers.#headersList
651
+
652
+ /**
653
+ * @param {Headers} target
654
+ * @param {HeadersList} list
655
+ */
656
+ setHeadersList = (target, list) => {
657
+ target.#headersList = list
658
+ }
647
659
 
648
- /**
649
- * @param {Headers} target
650
- * @param {HeadersList} list
651
- */
652
- static setHeadersList (target, list) {
653
- target.#headersList = list
660
+ webidl.is.Headers = (arg) => {
661
+ return arg != null && typeof arg === 'object' && #guard in arg
662
+ }
654
663
  }
655
664
  }
656
665
 
657
- const { getHeadersGuard, setHeadersGuard, getHeadersList, setHeadersList } = Headers
658
- Reflect.deleteProperty(Headers, 'getHeadersGuard')
659
- Reflect.deleteProperty(Headers, 'setHeadersGuard')
660
- Reflect.deleteProperty(Headers, 'getHeadersList')
661
- Reflect.deleteProperty(Headers, 'setHeadersList')
662
-
663
- iteratorMixin('Headers', Headers, headersListSortAndCombine, 0, 1)
666
+ iteratorMixin('Headers', Headers, headersListSortAndCombine, 0, 1, webidl.is.Headers)
664
667
 
665
668
  Object.defineProperties(Headers.prototype, {
666
669
  append: kEnumerableProperty,
@@ -812,11 +812,8 @@ async function mainFetch (fetchParams, recursive) {
812
812
  // https://fetch.spec.whatwg.org/#concept-scheme-fetch
813
813
  // given a fetch params fetchParams
814
814
  function schemeFetch (fetchParams) {
815
- // Note: since the connection is destroyed on redirect, which sets fetchParams to a
816
- // cancelled state, we do not want this condition to trigger *unless* there have been
817
- // no redirects. See https://github.com/nodejs/undici/issues/1776
818
815
  // 1. If fetchParams is canceled, then return the appropriate network error for fetchParams.
819
- if (isCancelled(fetchParams) && fetchParams.request.redirectCount === 0) {
816
+ if (isCancelled(fetchParams)) {
820
817
  return Promise.resolve(makeAppropriateNetworkError(fetchParams))
821
818
  }
822
819
 
@@ -1030,18 +1027,18 @@ function fetchFinale (fetchParams, response) {
1030
1027
  // `Server-Timing` from response’s internal response’s header list.
1031
1028
  // TODO
1032
1029
 
1033
- // 3. Let processResponseEndOfBody be the following steps:
1030
+ // 3. If fetchParams’s request’s destination is "document", then set fetchParams’s controller’s
1031
+ // full timing info to fetchParams’s timing info.
1032
+ if (fetchParams.request.destination === 'document') {
1033
+ fetchParams.controller.fullTimingInfo = timingInfo
1034
+ }
1035
+
1036
+ // 4. Let processResponseEndOfBody be the following steps:
1034
1037
  const processResponseEndOfBody = () => {
1035
1038
  // 1. Let unsafeEndTime be the unsafe shared current time.
1036
1039
  const unsafeEndTime = Date.now() // ?
1037
1040
 
1038
- // 2. If fetchParams’s request’s destination is "document", then set fetchParams’s controller’s
1039
- // full timing info to fetchParams’s timing info.
1040
- if (fetchParams.request.destination === 'document') {
1041
- fetchParams.controller.fullTimingInfo = timingInfo
1042
- }
1043
-
1044
- // 3. Set fetchParams’s controller’s report timing steps to the following steps given a global object global:
1041
+ // 2. Set fetchParams’s controller’s report timing steps to the following steps given a global object global:
1045
1042
  fetchParams.controller.reportTimingSteps = () => {
1046
1043
  // 1. If fetchParams’s request’s URL’s scheme is not an HTTP(S) scheme, then return.
1047
1044
  if (!urlIsHttpHttpsScheme(fetchParams.request.url)) {
@@ -1090,7 +1087,7 @@ function fetchFinale (fetchParams, response) {
1090
1087
  }
1091
1088
  }
1092
1089
 
1093
- // 4. Let processResponseEndOfBodyTask be the following steps:
1090
+ // 3. Let processResponseEndOfBodyTask be the following steps:
1094
1091
  const processResponseEndOfBodyTask = () => {
1095
1092
  // 1. Set fetchParams’s request’s done flag.
1096
1093
  fetchParams.request.done = true
@@ -1109,11 +1106,11 @@ function fetchFinale (fetchParams, response) {
1109
1106
  }
1110
1107
  }
1111
1108
 
1112
- // 5. Queue a fetch task to run processResponseEndOfBodyTask with fetchParams’s task destination
1109
+ // 4. Queue a fetch task to run processResponseEndOfBodyTask with fetchParams’s task destination
1113
1110
  queueMicrotask(() => processResponseEndOfBodyTask())
1114
1111
  }
1115
1112
 
1116
- // 4. If fetchParams’s process response is non-null, then queue a fetch task to run fetchParams’s
1113
+ // 5. If fetchParams’s process response is non-null, then queue a fetch task to run fetchParams’s
1117
1114
  // process response given response, with fetchParams’s task destination.
1118
1115
  if (fetchParams.processResponse != null) {
1119
1116
  queueMicrotask(() => {
@@ -1122,11 +1119,14 @@ function fetchFinale (fetchParams, response) {
1122
1119
  })
1123
1120
  }
1124
1121
 
1125
- // 5. Let internalResponse be response, if response is a network error; otherwise response’s internal response.
1122
+ // 6. Let internalResponse be response, if response is a network error; otherwise response’s internal response.
1126
1123
  const internalResponse = response.type === 'error' ? response : (response.internalResponse ?? response)
1127
1124
 
1128
- // 6. If internalResponse’s body is null, then run processResponseEndOfBody.
1129
- // 7. Otherwise:
1125
+ // 7. If response is a network error, then run the WebDriver BiDi fetch error steps with request.
1126
+ // Otherwise, run the WebDriver BiDi response completed steps with request and response.
1127
+
1128
+ // 8. If internalResponse’s body is null, then run processResponseEndOfBody.
1129
+ // 9. Otherwise:
1130
1130
  if (internalResponse.body == null) {
1131
1131
  processResponseEndOfBody()
1132
1132
  } else {
@@ -1144,6 +1144,27 @@ function fetchFinale (fetchParams, response) {
1144
1144
  processResponseEndOfBody()
1145
1145
  })
1146
1146
  }
1147
+
1148
+ // 10. If fetchParams’s process response consume body is non-null, then:
1149
+ if (fetchParams.processResponseConsumeBody != null) {
1150
+ // 1. Let processBody given nullOrBytes be this step: run fetchParams’s
1151
+ // process response consume body given response and nullOrBytes.
1152
+ const processBody = (nullOrBytes) => fetchParams.processResponseConsumeBody(response, nullOrBytes)
1153
+
1154
+ // 2. Let processBodyError be this step: run fetchParams’s process
1155
+ // response consume body given response and failure.
1156
+ const processBodyError = () => fetchParams.processResponseConsumeBody(response, 'failure')
1157
+
1158
+ // 3. If internalResponse’s body is null, then queue a fetch task to run
1159
+ // processBody given null, with fetchParams’s task destination.
1160
+ if (internalResponse.body == null) {
1161
+ queueMicrotask(() => processBody(null))
1162
+ } else {
1163
+ // 4. Otherwise, fully read internalResponse’s body given processBody,
1164
+ // processBodyError, and fetchParams’s task destination.
1165
+ fullyReadBody(internalResponse.body, processBody, processBodyError)
1166
+ }
1167
+ }
1147
1168
  }
1148
1169
 
1149
1170
  // https://fetch.spec.whatwg.org/#http-fetch
@@ -1219,7 +1240,7 @@ async function httpFetch (fetchParams) {
1219
1240
  // encouraged to, transmit an RST_STREAM frame.
1220
1241
  // See, https://github.com/whatwg/fetch/issues/1288
1221
1242
  if (request.redirect !== 'manual') {
1222
- fetchParams.controller.connection.destroy(undefined, false)
1243
+ fetchParams.controller.connection.destroy()
1223
1244
  }
1224
1245
 
1225
1246
  // 2. Switch on request’s redirect mode:
@@ -1828,12 +1849,10 @@ async function httpNetworkFetch (
1828
1849
  fetchParams.controller.connection = {
1829
1850
  abort: null,
1830
1851
  destroyed: false,
1831
- destroy (err, abort = true) {
1852
+ destroy (err) {
1832
1853
  if (!this.destroyed) {
1833
1854
  this.destroyed = true
1834
- if (abort) {
1835
- this.abort?.(err ?? new DOMException('The operation was aborted.', 'AbortError'))
1836
- }
1855
+ this.abort?.(err ?? new DOMException('The operation was aborted.', 'AbortError'))
1837
1856
  }
1838
1857
  }
1839
1858
  }
@@ -2369,7 +2388,7 @@ async function httpNetworkFetch (
2369
2388
  this.body?.push(null)
2370
2389
  },
2371
2390
 
2372
- onResponseError (_controller, error) {
2391
+ onResponseError (controller, error) {
2373
2392
  if (this.abort) {
2374
2393
  fetchParams.controller.off('terminated', this.abort)
2375
2394
  }
@@ -2388,7 +2407,9 @@ async function httpNetworkFetch (
2388
2407
 
2389
2408
  this.body?.destroy(error)
2390
2409
 
2391
- fetchParams.controller.terminate(error)
2410
+ if (!controller?.aborted) {
2411
+ fetchParams.controller.terminate(error)
2412
+ }
2392
2413
 
2393
2414
  reject(error)
2394
2415
  },
@@ -83,6 +83,7 @@ function buildAbort (acRef) {
83
83
  }
84
84
 
85
85
  let patchMethodWarning = false
86
+ let setRequestSignal, getRequestDispatcher, setRequestDispatcher, setRequestHeaders, getRequestState, setRequestState, removeRequestAbortListener
86
87
 
87
88
  // https://fetch.spec.whatwg.org/#request-class
88
89
  class Request {
@@ -600,7 +601,7 @@ class Request {
600
601
 
601
602
  // Returns request’s HTTP method, which is "GET" by default.
602
603
  get method () {
603
- webidl.brandCheck(this, Request)
604
+ webidl.brandCheck(this, webidl.is.Request)
604
605
 
605
606
  // The method getter steps are to return this’s request’s method.
606
607
  return this.#state.method
@@ -608,7 +609,7 @@ class Request {
608
609
 
609
610
  // Returns the URL of request as a string.
610
611
  get url () {
611
- webidl.brandCheck(this, Request)
612
+ webidl.brandCheck(this, webidl.is.Request)
612
613
 
613
614
  // The url getter steps are to return this’s request’s URL, serialized.
614
615
  return URLSerializer(this.#state.url)
@@ -618,7 +619,7 @@ class Request {
618
619
  // Note that headers added in the network layer by the user agent will not
619
620
  // be accounted for in this object, e.g., the "Host" header.
620
621
  get headers () {
621
- webidl.brandCheck(this, Request)
622
+ webidl.brandCheck(this, webidl.is.Request)
622
623
 
623
624
  // The headers getter steps are to return this’s headers.
624
625
  return this.#headers
@@ -627,7 +628,7 @@ class Request {
627
628
  // Returns the kind of resource requested by request, e.g., "document"
628
629
  // or "script".
629
630
  get destination () {
630
- webidl.brandCheck(this, Request)
631
+ webidl.brandCheck(this, webidl.is.Request)
631
632
 
632
633
  // The destination getter are to return this’s request’s destination.
633
634
  return this.#state.destination
@@ -639,7 +640,7 @@ class Request {
639
640
  // during fetching to determine the value of the `Referer` header of the
640
641
  // request being made.
641
642
  get referrer () {
642
- webidl.brandCheck(this, Request)
643
+ webidl.brandCheck(this, webidl.is.Request)
643
644
 
644
645
  // 1. If this’s request’s referrer is "no-referrer", then return the
645
646
  // empty string.
@@ -661,7 +662,7 @@ class Request {
661
662
  // This is used during fetching to compute the value of the request’s
662
663
  // referrer.
663
664
  get referrerPolicy () {
664
- webidl.brandCheck(this, Request)
665
+ webidl.brandCheck(this, webidl.is.Request)
665
666
 
666
667
  // The referrerPolicy getter steps are to return this’s request’s referrer policy.
667
668
  return this.#state.referrerPolicy
@@ -671,7 +672,7 @@ class Request {
671
672
  // whether the request will use CORS, or will be restricted to same-origin
672
673
  // URLs.
673
674
  get mode () {
674
- webidl.brandCheck(this, Request)
675
+ webidl.brandCheck(this, webidl.is.Request)
675
676
 
676
677
  // The mode getter steps are to return this’s request’s mode.
677
678
  return this.#state.mode
@@ -681,7 +682,7 @@ class Request {
681
682
  // which is a string indicating whether credentials will be sent with the
682
683
  // request always, never, or only when sent to a same-origin URL.
683
684
  get credentials () {
684
- webidl.brandCheck(this, Request)
685
+ webidl.brandCheck(this, webidl.is.Request)
685
686
 
686
687
  // The credentials getter steps are to return this’s request’s credentials mode.
687
688
  return this.#state.credentials
@@ -691,7 +692,7 @@ class Request {
691
692
  // which is a string indicating how the request will
692
693
  // interact with the browser’s cache when fetching.
693
694
  get cache () {
694
- webidl.brandCheck(this, Request)
695
+ webidl.brandCheck(this, webidl.is.Request)
695
696
 
696
697
  // The cache getter steps are to return this’s request’s cache mode.
697
698
  return this.#state.cache
@@ -702,7 +703,7 @@ class Request {
702
703
  // request will be handled during fetching. A request
703
704
  // will follow redirects by default.
704
705
  get redirect () {
705
- webidl.brandCheck(this, Request)
706
+ webidl.brandCheck(this, webidl.is.Request)
706
707
 
707
708
  // The redirect getter steps are to return this’s request’s redirect mode.
708
709
  return this.#state.redirect
@@ -712,7 +713,7 @@ class Request {
712
713
  // cryptographic hash of the resource being fetched. Its value
713
714
  // consists of multiple hashes separated by whitespace. [SRI]
714
715
  get integrity () {
715
- webidl.brandCheck(this, Request)
716
+ webidl.brandCheck(this, webidl.is.Request)
716
717
 
717
718
  // The integrity getter steps are to return this’s request’s integrity
718
719
  // metadata.
@@ -722,7 +723,7 @@ class Request {
722
723
  // Returns a boolean indicating whether or not request can outlive the
723
724
  // global in which it was created.
724
725
  get keepalive () {
725
- webidl.brandCheck(this, Request)
726
+ webidl.brandCheck(this, webidl.is.Request)
726
727
 
727
728
  // The keepalive getter steps are to return this’s request’s keepalive.
728
729
  return this.#state.keepalive
@@ -731,7 +732,7 @@ class Request {
731
732
  // Returns a boolean indicating whether or not request is for a reload
732
733
  // navigation.
733
734
  get isReloadNavigation () {
734
- webidl.brandCheck(this, Request)
735
+ webidl.brandCheck(this, webidl.is.Request)
735
736
 
736
737
  // The isReloadNavigation getter steps are to return true if this’s
737
738
  // request’s reload-navigation flag is set; otherwise false.
@@ -741,7 +742,7 @@ class Request {
741
742
  // Returns a boolean indicating whether or not request is for a history
742
743
  // navigation (a.k.a. back-forward navigation).
743
744
  get isHistoryNavigation () {
744
- webidl.brandCheck(this, Request)
745
+ webidl.brandCheck(this, webidl.is.Request)
745
746
 
746
747
  // The isHistoryNavigation getter steps are to return true if this’s request’s
747
748
  // history-navigation flag is set; otherwise false.
@@ -752,33 +753,33 @@ class Request {
752
753
  // object indicating whether or not request has been aborted, and its
753
754
  // abort event handler.
754
755
  get signal () {
755
- webidl.brandCheck(this, Request)
756
+ webidl.brandCheck(this, webidl.is.Request)
756
757
 
757
758
  // The signal getter steps are to return this’s signal.
758
759
  return this.#signal
759
760
  }
760
761
 
761
762
  get body () {
762
- webidl.brandCheck(this, Request)
763
+ webidl.brandCheck(this, webidl.is.Request)
763
764
 
764
765
  return this.#state.body ? this.#state.body.stream : null
765
766
  }
766
767
 
767
768
  get bodyUsed () {
768
- webidl.brandCheck(this, Request)
769
+ webidl.brandCheck(this, webidl.is.Request)
769
770
 
770
771
  return !!this.#state.body && util.isDisturbed(this.#state.body.stream)
771
772
  }
772
773
 
773
774
  get duplex () {
774
- webidl.brandCheck(this, Request)
775
+ webidl.brandCheck(this, webidl.is.Request)
775
776
 
776
777
  return 'half'
777
778
  }
778
779
 
779
780
  // Returns a clone of request.
780
781
  clone () {
781
- webidl.brandCheck(this, Request)
782
+ webidl.brandCheck(this, webidl.is.Request)
782
783
 
783
784
  // 1. If this is unusable, then throw a TypeError.
784
785
  if (bodyUnusable(this.#state)) {
@@ -840,73 +841,69 @@ class Request {
840
841
  return `Request ${nodeUtil.formatWithOptions(options, properties)}`
841
842
  }
842
843
 
843
- /**
844
- * @param {Request} request
845
- * @param {AbortSignal} newSignal
846
- */
847
- static setRequestSignal (request, newSignal) {
848
- request.#signal = newSignal
849
- return request
850
- }
844
+ static {
845
+ /**
846
+ * @param {Request} request
847
+ * @param {AbortSignal} newSignal
848
+ */
849
+ setRequestSignal = (request, newSignal) => {
850
+ request.#signal = newSignal
851
+ }
851
852
 
852
- /**
853
- * @param {Request} request
854
- */
855
- static getRequestDispatcher (request) {
856
- return request.#dispatcher
857
- }
853
+ /**
854
+ * @param {Request} request
855
+ */
856
+ getRequestDispatcher = (request) => {
857
+ return request.#dispatcher
858
+ }
858
859
 
859
- /**
860
- * @param {Request} request
861
- * @param {import('../../dispatcher/dispatcher')} newDispatcher
862
- */
863
- static setRequestDispatcher (request, newDispatcher) {
864
- request.#dispatcher = newDispatcher
865
- }
860
+ /**
861
+ * @param {Request} request
862
+ * @param {import('../../dispatcher/dispatcher')} newDispatcher
863
+ */
864
+ setRequestDispatcher = (request, newDispatcher) => {
865
+ request.#dispatcher = newDispatcher
866
+ }
866
867
 
867
- /**
868
- * @param {Request} request
869
- * @param {Headers} newHeaders
870
- */
871
- static setRequestHeaders (request, newHeaders) {
872
- request.#headers = newHeaders
873
- }
868
+ /**
869
+ * @param {Request} request
870
+ * @param {Headers} newHeaders
871
+ */
872
+ setRequestHeaders = (request, newHeaders) => {
873
+ request.#headers = newHeaders
874
+ }
874
875
 
875
- /**
876
- * @param {Request} request
877
- */
878
- static getRequestState (request) {
879
- return request.#state
880
- }
876
+ /**
877
+ * @param {Request} request
878
+ */
879
+ getRequestState = (request) => {
880
+ return request.#state
881
+ }
881
882
 
882
- /**
883
- * @param {Request} request
884
- * @param {any} newState
885
- */
886
- static setRequestState (request, newState) {
887
- request.#state = newState
888
- }
883
+ /**
884
+ * @param {Request} request
885
+ * @param {any} newState
886
+ */
887
+ setRequestState = (request, newState) => {
888
+ request.#state = newState
889
+ }
889
890
 
890
- /**
891
- * Removes the `abort` listener that makes this request's signal follow the
892
- * signal passed to its constructor, if any. Idempotent.
893
- * @param {Request} request
894
- */
895
- static removeRequestAbortListener (request) {
896
- request.#abortCleanup?.()
891
+ /**
892
+ * Removes the `abort` listener that makes this request's signal follow the
893
+ * signal passed to its constructor, if any. Idempotent.
894
+ * @param {Request} request
895
+ */
896
+ removeRequestAbortListener = (request) => {
897
+ request.#abortCleanup?.()
898
+ }
899
+
900
+ webidl.is.Request = (arg) => {
901
+ return arg != null && typeof arg === 'object' && #state in arg
902
+ }
897
903
  }
898
904
  }
899
905
 
900
- const { setRequestSignal, getRequestDispatcher, setRequestDispatcher, setRequestHeaders, getRequestState, setRequestState, removeRequestAbortListener } = Request
901
- Reflect.deleteProperty(Request, 'setRequestSignal')
902
- Reflect.deleteProperty(Request, 'getRequestDispatcher')
903
- Reflect.deleteProperty(Request, 'setRequestDispatcher')
904
- Reflect.deleteProperty(Request, 'setRequestHeaders')
905
- Reflect.deleteProperty(Request, 'getRequestState')
906
- Reflect.deleteProperty(Request, 'setRequestState')
907
- Reflect.deleteProperty(Request, 'removeRequestAbortListener')
908
-
909
- mixinBody(Request, getRequestState)
906
+ mixinBody(Request, getRequestState, webidl.is.Request)
910
907
 
911
908
  // https://fetch.spec.whatwg.org/#requests
912
909
  function makeRequest (init) {
@@ -1021,8 +1018,6 @@ Object.defineProperties(Request.prototype, {
1021
1018
  }
1022
1019
  })
1023
1020
 
1024
- webidl.is.Request = webidl.util.MakeTypeAssertion(Request)
1025
-
1026
1021
  /**
1027
1022
  * @param {*} V
1028
1023
  * @returns {import('../../../types/fetch').Request|string}