@openclaw/discord 2026.8.1-beta.3 → 2026.8.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 (290) hide show
  1. package/dist/account-inspect-BY-ve3yH.js +45 -0
  2. package/dist/account-inspect-api.js +1 -1
  3. package/dist/{accounts-DNl-oCEw.js → accounts-CwJQoLjM.js} +87 -162
  4. package/dist/action-runtime-api.js +1 -1
  5. package/dist/{activities-api-KCBAmWxD.js → activities-api-CkKcHUB6.js} +14 -12
  6. package/dist/activities-api.js +1 -1
  7. package/dist/{allow-list-BDMimASD.js → allow-list-C2JuH-R0.js} +10 -6
  8. package/dist/{api-DNVbJyEy.js → api-BfmEP6wp.js} +6 -5
  9. package/dist/api.js +18 -18
  10. package/dist/{approval-handler.runtime-B12RCYr8.js → approval-handler.runtime-DZM6Kt1Z.js} +30 -106
  11. package/dist/{audit-Yc7eZDd6.js → audit-DIbQA4VT.js} +8 -7
  12. package/dist/{channel-cXYzGc4L.js → channel-CarzU3bg.js} +25 -25
  13. package/dist/{channel-actions.runtime-CODTvo7c.js → channel-actions.runtime-B2wMqeVK.js} +60 -57
  14. package/dist/channel-config-api.js +1 -1
  15. package/dist/channel-plugin-api.js +1 -1
  16. package/dist/channel-type-CVLZyGYS.js +7 -0
  17. package/dist/{channel.setup-CSiwnMgs.js → channel.setup-z_ewMVa9.js} +18 -18
  18. package/dist/{components-ezGKo_Yh.js → components-gvRA0oaI.js} +33 -29
  19. package/dist/{config-schema-DC5kDtQ5.js → config-schema-B797-Spt.js} +21 -14
  20. package/dist/{conversation-binding-route-D6rCQ5S0.js → conversation-binding-route-DPpBRpYI.js} +1 -1
  21. package/dist/{directory-config-XyCfoqLg.js → directory-config-AA8wQx0D.js} +2 -2
  22. package/dist/directory-contract-api.js +1 -1
  23. package/dist/{directory-live-Df0NbFJB.js → directory-live-D_kFz_Fj.js} +4 -4
  24. package/dist/{doctor-DYY31GrO.js → doctor-QQTOkBfW.js} +5 -5
  25. package/dist/{doctor-contract-DsWvKIXF.js → doctor-contract-Co5vRCZ6.js} +9 -6
  26. package/dist/doctor-contract-api.js +4 -3
  27. package/dist/{handle-action.guild-admin-6Tvvinsa.js → handle-action.guild-admin-Cc88ZGon.js} +9 -5
  28. package/dist/index.js +1 -1
  29. package/dist/ingress-identity-BCzfPPYM.js +60 -0
  30. package/dist/{message-handler-B61q5MOF.js → message-handler-CAeEpqWo.js} +14 -10
  31. package/dist/{message-handler.preflight-Bzg_Hawz.js → message-handler.preflight-CoKoE3dY.js} +32 -91
  32. package/dist/{message-handler.process--4_712Ec.js → message-handler.process-cdIJ_fDT.js} +99 -123
  33. package/dist/{message-utils-BXLLnFl6.js → message-text-C0K4-fkg.js} +41 -34
  34. package/dist/{outbound-adapter-DxHTOqiN.js → outbound-adapter-Ch0At5Ra.js} +85 -78
  35. package/dist/{outbound-components-B2PL0ooH.js → outbound-components-Bnt_7x7r.js} +5 -4
  36. package/dist/outbound-session-route-CzzerX2K.js +668 -0
  37. package/dist/{owner-access-Bg41VzAf.js → owner-access-yc1sX7Gx.js} +7 -6
  38. package/dist/{pluralkit-dUl4v1X3.js → pluralkit-B3cUVI7i.js} +2 -2
  39. package/dist/{probe-BTdtVRwU.js → probe-3ovFAp3b.js} +3 -3
  40. package/dist/{probe.runtime-Dq5-PRKT.js → probe.runtime-BckHn3cJ.js} +1 -1
  41. package/dist/{provider-DlK_ynqt.js → provider-CjI8BSzS.js} +511 -342
  42. package/dist/{provider-session.runtime-CvvphHvs.js → provider-session.runtime-DdKRMcE9.js} +3 -3
  43. package/dist/provider.runtime-Bo1WbLLr.js +2 -0
  44. package/dist/{realtime-session.runtime-ysbMG8v7.js → realtime-session.runtime-37IC-p5K.js} +110 -126
  45. package/dist/{resolve-allowlist-common-DIVXbD1P.js → resolve-allowlist-common-BJ5UZNNT.js} +3 -3
  46. package/dist/{resolve-channels-CGeUoIqb.js → resolve-channels-BexR2eUn.js} +6 -5
  47. package/dist/{resolve-users-BtKxLUZv.js → resolve-users-BtXBCH5W.js} +5 -4
  48. package/dist/{retry-after-DdLPmPoa.js → retry-after-BrLjLUJi.js} +2 -1
  49. package/dist/{retry-DNsVTeTo.js → retry-t5RcEsPk.js} +237 -15
  50. package/dist/{runtime-CQovMsH3.js → runtime-BNlDfLwS.js} +2 -2
  51. package/dist/{runtime-D71_VFLr.js → runtime-DydyfxST.js} +182 -131
  52. package/dist/runtime-api.js +19 -26
  53. package/dist/{secret-config-contract-B3i6WxV5.js → secret-config-contract-DFu9hfU8.js} +14 -6
  54. package/dist/secret-contract-api.js +1 -1
  55. package/dist/{security-audit-BfJhAXZp.js → security-audit-DKfK-iPY.js} +10 -11
  56. package/dist/security-audit-contract-api.js +1 -1
  57. package/dist/{security-audit.runtime-BVKF9VtY.js → security-audit.runtime-sKZyKgpx.js} +1 -1
  58. package/dist/{send-rQIffSYu.js → send-mTKSBdmZ.js} +149 -58
  59. package/dist/{send.components-ChK1wS7w.js → send.components-nsPnc7kK.js} +29 -30
  60. package/dist/{send.outbound-HIkgji_7.js → send.outbound-CaOs9Zy1.js} +87 -84
  61. package/dist/{send.shared-B3fpaLWJ.js → send.shared-BJHt0Vyf.js} +55 -33
  62. package/dist/{sender-identity-BJtfyise.js → sender-identity-Dt0imZyY.js} +1 -1
  63. package/dist/setup-plugin-api.js +1 -1
  64. package/dist/{shared-CaAaoksy.js → shared-BNesVA4P.js} +43 -18
  65. package/dist/{subagent-hooks-CNT2ZJTJ.js → subagent-hooks-IeZVPLGj.js} +2 -2
  66. package/dist/subagent-hooks-api.js +1 -6
  67. package/dist/{system-events-Nuwoq_au.js → system-events-Be5EJI3b.js} +2 -2
  68. package/dist/{target-resolver-DIXShHaZ.js → target-resolver-C0MnwEki.js} +6 -5
  69. package/dist/targets-DQSye1Rv.js +3 -0
  70. package/dist/{thread-bindings-VlymUnbz.js → thread-bindings-wECUSIIG.js} +6 -6
  71. package/dist/{thread-bindings.manager-CngsgErq.js → thread-bindings.manager-B-3UHCc1.js} +31 -32
  72. package/dist/{thread-bindings.session-updates-CJb-BpPL.js → thread-bindings.session-updates-CC7HoQvt.js} +2 -1
  73. package/dist/{threading-DU6pgeGm.js → threading-te5ADPQI.js} +51 -27
  74. package/dist/{timeouts-B9cy6RvQ.js → timeouts-D86uWLt_.js} +1 -1
  75. package/dist/{transcripts-source-DeIMNbRh.js → transcripts-source-DkUhR7YK.js} +9 -4
  76. package/dist/transcripts-source-api.js +1 -1
  77. package/dist/{typing-oLiS5Z13.js → typing-DAwJF5VT.js} +2 -2
  78. package/dist/{voice-runtime-CjNFaynA.js → voice-runtime-COyYYTDD.js} +418 -74
  79. package/node_modules/@discord/embedded-app-sdk/node_modules/@types/lodash/README.md +1 -1
  80. package/node_modules/@discord/embedded-app-sdk/node_modules/@types/lodash/conforms.d.ts +2 -0
  81. package/node_modules/@discord/embedded-app-sdk/node_modules/@types/lodash/package.json +3 -3
  82. package/node_modules/@discord/embedded-app-sdk/node_modules/@types/lodash/stubArray.d.ts +2 -0
  83. package/node_modules/@discord/embedded-app-sdk/node_modules/@types/lodash/stubObject.d.ts +2 -0
  84. package/node_modules/@discord/embedded-app-sdk/node_modules/@types/lodash/stubString.d.ts +2 -0
  85. package/node_modules/@discord/embedded-app-sdk/node_modules/uuid/README.md +19 -19
  86. package/node_modules/@discord/embedded-app-sdk/node_modules/uuid/dist/v1.js +7 -3
  87. package/node_modules/@discord/embedded-app-sdk/node_modules/uuid/dist/v7.js +5 -2
  88. package/node_modules/@discord/embedded-app-sdk/node_modules/uuid/dist-node/v1.js +7 -3
  89. package/node_modules/@discord/embedded-app-sdk/node_modules/uuid/dist-node/v7.js +5 -2
  90. package/node_modules/@discord/embedded-app-sdk/node_modules/uuid/package.json +4 -3
  91. package/node_modules/@discordjs/voice/node_modules/@types/node/README.md +1 -1
  92. package/node_modules/@discordjs/voice/node_modules/@types/node/child_process.d.ts +0 -1
  93. package/node_modules/@discordjs/voice/node_modules/@types/node/crypto.d.ts +6 -6
  94. package/node_modules/@discordjs/voice/node_modules/@types/node/dns/promises.d.ts +5 -5
  95. package/node_modules/@discordjs/voice/node_modules/@types/node/dns.d.ts +5 -5
  96. package/node_modules/@discordjs/voice/node_modules/@types/node/fs.d.ts +7 -0
  97. package/node_modules/@discordjs/voice/node_modules/@types/node/http.d.ts +30 -0
  98. package/node_modules/@discordjs/voice/node_modules/@types/node/http2.d.ts +4 -4
  99. package/node_modules/@discordjs/voice/node_modules/@types/node/os.d.ts +30 -30
  100. package/node_modules/@discordjs/voice/node_modules/@types/node/package.json +2 -2
  101. package/node_modules/@discordjs/voice/node_modules/@types/node/perf_hooks.d.ts +2 -1
  102. package/node_modules/@discordjs/voice/node_modules/@types/node/process.d.ts +42 -43
  103. package/node_modules/@discordjs/voice/node_modules/@types/node/quic.d.ts +1049 -84
  104. package/node_modules/@discordjs/voice/node_modules/@types/node/sqlite.d.ts +14 -1
  105. package/node_modules/@discordjs/voice/node_modules/@types/node/stream/iter.d.ts +3 -2
  106. package/node_modules/@discordjs/voice/node_modules/@types/node/test.d.ts +61 -0
  107. package/node_modules/@discordjs/voice/node_modules/@types/node/v8.d.ts +20 -23
  108. package/node_modules/discord-api-types/CHANGELOG.md +8 -0
  109. package/node_modules/discord-api-types/package.json +4 -4
  110. package/node_modules/discord-api-types/payloads/v10/channel.d.ts +2 -2
  111. package/node_modules/discord-api-types/payloads/v10/channel.d.ts.map +1 -1
  112. package/node_modules/discord-api-types/payloads/v10/gateway.d.ts +4 -0
  113. package/node_modules/discord-api-types/payloads/v10/gateway.d.ts.map +1 -1
  114. package/node_modules/discord-api-types/payloads/v10/gateway.js.map +1 -1
  115. package/node_modules/discord-api-types/payloads/v10/message.d.ts +4 -1
  116. package/node_modules/discord-api-types/payloads/v10/message.d.ts.map +1 -1
  117. package/node_modules/discord-api-types/payloads/v10/message.js +1 -0
  118. package/node_modules/discord-api-types/payloads/v10/message.js.map +1 -1
  119. package/node_modules/discord-api-types/payloads/v9/channel.d.ts +2 -2
  120. package/node_modules/discord-api-types/payloads/v9/channel.d.ts.map +1 -1
  121. package/node_modules/discord-api-types/payloads/v9/gateway.d.ts +4 -0
  122. package/node_modules/discord-api-types/payloads/v9/gateway.d.ts.map +1 -1
  123. package/node_modules/discord-api-types/payloads/v9/gateway.js.map +1 -1
  124. package/node_modules/discord-api-types/payloads/v9/message.d.ts +4 -1
  125. package/node_modules/discord-api-types/payloads/v9/message.d.ts.map +1 -1
  126. package/node_modules/discord-api-types/payloads/v9/message.js +1 -0
  127. package/node_modules/discord-api-types/payloads/v9/message.js.map +1 -1
  128. package/node_modules/typebox/build/format/date.d.mts +1 -1
  129. package/node_modules/typebox/build/format/date.mjs +1 -1
  130. package/node_modules/typebox/build/format/date_time.d.mts +2 -2
  131. package/node_modules/typebox/build/format/date_time.mjs +3 -3
  132. package/node_modules/typebox/build/format/email.d.mts +1 -1
  133. package/node_modules/typebox/build/format/email.mjs +2 -2
  134. package/node_modules/typebox/build/format/hostname.mjs +2 -10
  135. package/node_modules/typebox/build/format/idn_email.d.mts +1 -1
  136. package/node_modules/typebox/build/format/idn_email.mjs +3 -3
  137. package/node_modules/typebox/build/format/idn_hostname.d.mts +1 -0
  138. package/node_modules/typebox/build/format/idn_hostname.mjs +3 -11
  139. package/node_modules/typebox/build/format/idna/format/bidi.d.mts +3 -0
  140. package/node_modules/typebox/build/format/idna/format/bidi.mjs +98 -0
  141. package/node_modules/typebox/build/format/idna/format/puny.d.mts +3 -0
  142. package/node_modules/typebox/build/format/idna/format/puny.mjs +144 -0
  143. package/node_modules/typebox/build/format/idna/hostname.d.mts +1 -0
  144. package/node_modules/typebox/build/format/idna/hostname.mjs +16 -0
  145. package/node_modules/typebox/build/format/idna/idn-hostname.d.mts +1 -0
  146. package/node_modules/typebox/build/format/idna/idn-hostname.mjs +41 -0
  147. package/node_modules/typebox/build/format/idna/index.d.mts +2 -0
  148. package/node_modules/typebox/build/format/idna/index.mjs +2 -0
  149. package/node_modules/typebox/build/format/idna/label/ascii.d.mts +1 -0
  150. package/node_modules/typebox/build/format/idna/label/ascii.mjs +9 -0
  151. package/node_modules/typebox/build/format/idna/label/puny.d.mts +1 -0
  152. package/node_modules/typebox/build/format/idna/label/puny.mjs +28 -0
  153. package/node_modules/typebox/build/format/idna/label/unicode.d.mts +1 -0
  154. package/node_modules/typebox/build/format/idna/label/unicode.mjs +106 -0
  155. package/node_modules/typebox/build/format/idna/pattern/pattern.d.mts +30 -0
  156. package/node_modules/typebox/build/format/idna/pattern/pattern.mjs +70 -0
  157. package/node_modules/typebox/build/format/ipv4.d.mts +0 -1
  158. package/node_modules/typebox/build/format/ipv4.mjs +2 -32
  159. package/node_modules/typebox/build/format/ipv6.mjs +2 -61
  160. package/node_modules/typebox/build/format/iri.d.mts +2 -2
  161. package/node_modules/typebox/build/format/iri.mjs +26 -8
  162. package/node_modules/typebox/build/format/iri_reference.d.mts +2 -2
  163. package/node_modules/typebox/build/format/iri_reference.mjs +9 -55
  164. package/node_modules/typebox/build/format/regex.d.mts +1 -2
  165. package/node_modules/typebox/build/format/regex.mjs +2 -6
  166. package/node_modules/typebox/build/format/time.d.mts +2 -2
  167. package/node_modules/typebox/build/format/time.mjs +19 -14
  168. package/node_modules/typebox/build/format/uri.d.mts +1 -1
  169. package/node_modules/typebox/build/format/uri.mjs +3 -130
  170. package/node_modules/typebox/build/format/uri_reference.d.mts +1 -1
  171. package/node_modules/typebox/build/format/uri_reference.mjs +2 -3
  172. package/node_modules/typebox/build/format/uri_template.d.mts +2 -3
  173. package/node_modules/typebox/build/format/uri_template.mjs +4 -5
  174. package/node_modules/typebox/build/format/url.d.mts +3 -3
  175. package/node_modules/typebox/build/format/url.mjs +4 -5
  176. package/node_modules/typebox/build/guard/emit.d.mts +3 -1
  177. package/node_modules/typebox/build/guard/emit.mjs +12 -5
  178. package/node_modules/typebox/build/guard/guard.d.mts +8 -2
  179. package/node_modules/typebox/build/guard/guard.mjs +25 -4
  180. package/node_modules/typebox/build/guard/string.d.mts +2 -2
  181. package/node_modules/typebox/build/guard/string.mjs +7 -7
  182. package/node_modules/typebox/build/schema/engine/_context.mjs +3 -3
  183. package/node_modules/typebox/build/schema/engine/_functions.mjs +1 -2
  184. package/node_modules/typebox/build/schema/engine/_regexp.d.mts +2 -0
  185. package/node_modules/typebox/build/schema/engine/_regexp.mjs +4 -0
  186. package/node_modules/typebox/build/schema/engine/_stack.mjs +12 -13
  187. package/node_modules/typebox/build/schema/engine/additionalItems.mjs +17 -7
  188. package/node_modules/typebox/build/schema/engine/additionalProperties.mjs +4 -3
  189. package/node_modules/typebox/build/schema/engine/contains.mjs +18 -6
  190. package/node_modules/typebox/build/schema/engine/enum.mjs +1 -1
  191. package/node_modules/typebox/build/schema/engine/items.mjs +26 -6
  192. package/node_modules/typebox/build/schema/engine/maxContains.mjs +3 -3
  193. package/node_modules/typebox/build/schema/engine/minContains.mjs +14 -4
  194. package/node_modules/typebox/build/schema/engine/not.mjs +4 -2
  195. package/node_modules/typebox/build/schema/engine/oneOf.mjs +7 -6
  196. package/node_modules/typebox/build/schema/engine/pattern.mjs +3 -2
  197. package/node_modules/typebox/build/schema/engine/patternProperties.mjs +4 -3
  198. package/node_modules/typebox/build/schema/engine/ref.mjs +1 -7
  199. package/node_modules/typebox/build/schema/engine/schema.mjs +13 -4
  200. package/node_modules/typebox/build/schema/engine/type.mjs +1 -1
  201. package/node_modules/typebox/build/schema/resolve/resolve.d.mts +4 -1
  202. package/node_modules/typebox/build/schema/resolve/resolve.mjs +202 -1
  203. package/node_modules/typebox/build/schema/static/propertyNames.d.mts +5 -0
  204. package/node_modules/typebox/build/schema/static/propertyNames.mjs +3 -0
  205. package/node_modules/typebox/build/schema/static/schema.d.mts +3 -0
  206. package/node_modules/typebox/build/schema/types/index.d.mts +0 -2
  207. package/node_modules/typebox/build/schema/types/index.mjs +0 -2
  208. package/node_modules/typebox/build/system/memory/clone.mjs +14 -11
  209. package/node_modules/typebox/build/system/memory/discard.mjs +6 -5
  210. package/node_modules/typebox/build/system/settings/settings.d.mts +9 -0
  211. package/node_modules/typebox/build/system/settings/settings.mjs +2 -0
  212. package/node_modules/typebox/build/type/engine/call/distribute_arguments.d.mts +6 -1
  213. package/node_modules/typebox/build/type/engine/call/distribute_arguments.mjs +16 -3
  214. package/node_modules/typebox/build/type/engine/call/instantiate.mjs +34 -4
  215. package/node_modules/typebox/build/type/engine/evaluate/broaden.d.mts +5 -5
  216. package/node_modules/typebox/build/type/engine/evaluate/broaden.mjs +20 -26
  217. package/node_modules/typebox/build/type/engine/evaluate/compare.d.mts +6 -10
  218. package/node_modules/typebox/build/type/engine/evaluate/compare.mjs +9 -13
  219. package/node_modules/typebox/build/type/engine/evaluate/composite.d.mts +7 -4
  220. package/node_modules/typebox/build/type/engine/evaluate/composite.mjs +12 -19
  221. package/node_modules/typebox/build/type/engine/evaluate/distribute.d.mts +4 -20
  222. package/node_modules/typebox/build/type/engine/evaluate/distribute.mjs +8 -20
  223. package/node_modules/typebox/build/type/engine/evaluate/evaluate.d.mts +4 -4
  224. package/node_modules/typebox/build/type/engine/evaluate/evaluate.mjs +11 -8
  225. package/node_modules/typebox/build/type/engine/evaluate/flatten.d.mts +1 -1
  226. package/node_modules/typebox/build/type/engine/evaluate/flatten.mjs +3 -4
  227. package/node_modules/typebox/build/type/engine/evaluate/narrow.d.mts +17 -2
  228. package/node_modules/typebox/build/type/engine/evaluate/narrow.mjs +26 -6
  229. package/node_modules/typebox/build/type/engine/exclude/operation.mjs +3 -4
  230. package/node_modules/typebox/build/type/engine/extract/operation.d.mts +1 -1
  231. package/node_modules/typebox/build/type/engine/extract/operation.mjs +3 -4
  232. package/node_modules/typebox/build/type/engine/priority/priority.d.mts +2 -2
  233. package/node_modules/typebox/build/type/engine/priority/priority.mjs +3 -4
  234. package/node_modules/typebox/build/type/script/mapping.d.mts +32 -29
  235. package/node_modules/typebox/build/type/script/mapping.mjs +18 -25
  236. package/node_modules/typebox/build/type/script/parser.d.mts +19 -25
  237. package/node_modules/typebox/build/type/script/parser.mjs +27 -23
  238. package/node_modules/typebox/build/value/errors/errors.d.mts +2 -2
  239. package/node_modules/typebox/build/value/errors/errors.mjs +1 -1
  240. package/node_modules/typebox/package.json +27 -27
  241. package/node_modules/typebox/readme.md +79 -82
  242. package/node_modules/undici/docs/docs/api/Client.md +21 -8
  243. package/node_modules/undici/lib/api/readable.js +33 -43
  244. package/node_modules/undici/lib/core/connect.js +16 -2
  245. package/node_modules/undici/lib/core/symbols.js +1 -0
  246. package/node_modules/undici/lib/dispatcher/client-h1.js +3 -3
  247. package/node_modules/undici/lib/dispatcher/client-h2.js +179 -10
  248. package/node_modules/undici/lib/dispatcher/client.js +74 -29
  249. package/node_modules/undici/lib/dispatcher/env-http-proxy-agent.js +28 -6
  250. package/node_modules/undici/lib/dispatcher/socks5-proxy-agent.js +15 -1
  251. package/node_modules/undici/lib/handler/retry-handler.js +7 -2
  252. package/node_modules/undici/lib/interceptor/cache.js +5 -2
  253. package/node_modules/undici/lib/interceptor/deduplicate.js +1 -1
  254. package/node_modules/undici/lib/mock/mock-utils.js +213 -24
  255. package/node_modules/undici/lib/util/cache.js +2 -4
  256. package/node_modules/undici/lib/web/websocket/websocket.js +22 -0
  257. package/node_modules/undici/package.json +1 -1
  258. package/node_modules/undici/types/client.d.ts +40 -0
  259. package/node_modules/ws/lib/permessage-deflate.js +3 -1
  260. package/node_modules/ws/package.json +1 -1
  261. package/openclaw.plugin.json +14 -6
  262. package/package.json +8 -8
  263. package/skills/discord/SKILL.md +1 -1
  264. package/dist/account-inspect-D5xmUpnj.js +0 -89
  265. package/dist/approval-message-safety-XGFPbDoI.js +0 -226
  266. package/dist/audit-core-BCX8UeFH.js +0 -105
  267. package/dist/channel-actions-Dr2QI8Bf.js +0 -212
  268. package/dist/inbound-event-delivery-De2qxTrP.js +0 -39
  269. package/dist/provider.runtime-CzKGRiAF.js +0 -2
  270. package/dist/runtime-api.actions.js +0 -3
  271. package/dist/runtime-api.lookup.js +0 -7
  272. package/dist/runtime-api.monitor-CzeTYF32.js +0 -6
  273. package/dist/runtime-api.monitor.js +0 -9
  274. package/dist/runtime-api.send.js +0 -7
  275. package/dist/runtime-api.threads.js +0 -5
  276. package/dist/sdk-runtime-37OU6_Yh.js +0 -369
  277. package/dist/send.reactions-gmJ6yFPo.js +0 -78
  278. package/dist/send.receipt-Cnhoautb.js +0 -76
  279. package/dist/subagent-progress-FPLqBY1s.js +0 -110
  280. package/dist/targets-B2pf49zc.js +0 -3
  281. package/node_modules/typebox/build/format/_idna.d.mts +0 -2
  282. package/node_modules/typebox/build/format/_idna.mjs +0 -246
  283. package/node_modules/typebox/build/format/_puny.d.mts +0 -1
  284. package/node_modules/typebox/build/format/_puny.mjs +0 -77
  285. package/node_modules/typebox/build/schema/resolve/ref.d.mts +0 -3
  286. package/node_modules/typebox/build/schema/resolve/ref.mjs +0 -146
  287. package/node_modules/typebox/build/schema/types/contentEncoding.d.mts +0 -9
  288. package/node_modules/typebox/build/schema/types/contentEncoding.mjs +0 -13
  289. package/node_modules/typebox/build/schema/types/contentMediaType.d.mts +0 -9
  290. package/node_modules/typebox/build/schema/types/contentMediaType.mjs +0 -13
@@ -26,10 +26,7 @@ const {
26
26
  kStrictContentLength,
27
27
  kOnError,
28
28
  kMaxConcurrentStreams,
29
- kPingInterval,
30
29
  kHTTP2Session,
31
- kHTTP2InitialWindowSize,
32
- kHTTP2ConnectionWindowSize,
33
30
  kHostAuthority,
34
31
  kResume,
35
32
  kSize,
@@ -41,7 +38,8 @@ const {
41
38
  kEnableConnectProtocol,
42
39
  kRemoteSettings,
43
40
  kHTTP2Stream,
44
- kHTTP2SessionState
41
+ kHTTP2SessionState,
42
+ kHTTP2Options
45
43
  } = require('../core/symbols.js')
46
44
  const { channels } = require('../core/diagnostics.js')
47
45
 
@@ -51,6 +49,14 @@ const kRequestStream = Symbol('request stream')
51
49
  const kRequestStreamCleanup = Symbol('request stream cleanup')
52
50
  const kRequestStreamState = Symbol('request stream state')
53
51
  const kReceivedGoAway = Symbol('received goaway')
52
+ const kGoAwayReplayAttempts = Symbol('goaway replay attempts')
53
+ const kRefusedStreamRetry = Symbol('refused stream retry')
54
+
55
+ // RFC 9113 section 8.7: a client SHOULD NOT automatically retry a request more
56
+ // than once. Without a budget a peer that keeps refusing turns one request into
57
+ // an unbounded connect/refuse/reconnect loop that never settles and starves the
58
+ // event loop.
59
+ const MAX_GOAWAY_REPLAY_ATTEMPTS = 1
54
60
 
55
61
  let extractBody
56
62
 
@@ -179,12 +185,24 @@ function completeRequest (client, request, resetPendingIdx = false) {
179
185
  }
180
186
  }
181
187
 
182
- function canRetryRequestAfterGoAway (request) {
188
+ function canReplayRequest (request) {
183
189
  const { body } = request
184
190
 
185
191
  return body == null || util.isBuffer(body) || util.isBlobLike(body)
186
192
  }
187
193
 
194
+ // Count a GOAWAY refusal against the request's replay budget. A peer that
195
+ // refuses every connection must eventually surface an error to the caller
196
+ // rather than being retried forever. Kept separate from canReplayRequest so
197
+ // that the REFUSED_STREAM retry, which has its own single-attempt limit, does
198
+ // not consume this budget just by asking whether the body can be replayed.
199
+ function registerGoAwayRefusal (request) {
200
+ const attempts = (request[kGoAwayReplayAttempts] ?? 0) + 1
201
+ request[kGoAwayReplayAttempts] = attempts
202
+
203
+ return attempts <= MAX_GOAWAY_REPLAY_ATTEMPTS
204
+ }
205
+
188
206
  function closeStream (stream, code = NGHTTP2_REFUSED_STREAM) {
189
207
  if (stream != null && !stream.destroyed && !stream.closed) {
190
208
  try {
@@ -197,19 +215,44 @@ function detachRequestStreamForClose (request) {
197
215
  const stream = request[kRequestStream]
198
216
 
199
217
  clearRequestStream(request)
218
+ severRequestStream(stream)
200
219
 
201
220
  return stream
202
221
  }
203
222
 
223
+ // Unbind a stream from its request for good. releaseRequestStream() alone
224
+ // leaves the 'close' listener attached and kRequestStreamState populated, so a
225
+ // stream abandoned here would still run completeRequestStream() later — and
226
+ // splice out the request that has since been requeued onto another session.
227
+ function severRequestStream (stream) {
228
+ if (stream == null || stream[kRequestStreamState] == null) {
229
+ return
230
+ }
231
+
232
+ stream[kRequestStreamState] = null
233
+ stream.off('close', completeRequestStream)
234
+ // Upgrade streams use their own close cleanup, which would otherwise release
235
+ // the session a second time after the stream has been severed for GOAWAY.
236
+ stream.off('close', onUpgradeStreamClose)
237
+
238
+ if (stream[kHTTP2Session] != null) {
239
+ closeStreamSession(stream)
240
+ }
241
+
242
+ if (!stream.destroyed && !stream.closed) {
243
+ stream.once('error', noop)
244
+ }
245
+ }
246
+
204
247
  function connectH2 (client, socket) {
205
248
  client[kSocket] = socket
206
249
 
207
- const http2InitialWindowSize = client[kHTTP2InitialWindowSize]
208
- const http2ConnectionWindowSize = client[kHTTP2ConnectionWindowSize]
250
+ const http2InitialWindowSize = client[kHTTP2Options].sessionOptions?.initialWindowSize
251
+ const http2ConnectionWindowSize = client[kHTTP2Options].connectionWindowSize
209
252
 
210
253
  const session = http2.connect(client[kUrl], {
211
254
  createConnection: () => socket,
212
- peerMaxConcurrentStreams: client[kMaxConcurrentStreams],
255
+ peerMaxConcurrentStreams: client[kHTTP2Options].maxConcurrentStreams,
213
256
  settings: {
214
257
  // TODO(metcoder95): add support for PUSH
215
258
  enablePush: false,
@@ -223,13 +266,16 @@ function connectH2 (client, socket) {
223
266
  session[kSocket] = socket
224
267
  session[kHTTP2SessionState] = {
225
268
  idleTimeout: null,
269
+ // Armed while the peer advertises MAX_CONCURRENT_STREAMS = 0 and we have
270
+ // work that cannot start. See setNoStreamsTimeout.
271
+ noStreamsTimeout: null,
226
272
  // Sockets start out ref'd. Session ref/unref proxies to the socket, so a
227
273
  // single cached flag lets us skip redundant uv ref/unref calls, provided
228
274
  // every ref/unref of the session or its socket goes through
229
275
  // refH2Session/unrefH2Session.
230
276
  refed: true,
231
277
  ping: {
232
- interval: client[kPingInterval] === 0 ? null : setInterval(onHttp2SendPing, client[kPingInterval], session).unref()
278
+ interval: client[kHTTP2Options].pingInterval === 0 ? null : setInterval(onHttp2SendPing, client[kHTTP2Options].pingInterval, session).unref()
233
279
  }
234
280
  }
235
281
  session[kReceivedGoAway] = false
@@ -369,7 +415,74 @@ function resumeH2 (client) {
369
415
  } else {
370
416
  clearHttp2IdleTimeout(session)
371
417
  }
418
+
419
+ if (client[kMaxConcurrentStreams] === 0 && client[kRunning] === 0 && client[kPending] > 0) {
420
+ setNoStreamsTimeout(session)
421
+ } else {
422
+ clearNoStreamsTimeout(session)
423
+ }
424
+ }
425
+ }
426
+
427
+ function clearNoStreamsTimeout (session) {
428
+ const state = session[kHTTP2SessionState]
429
+
430
+ if (state?.noStreamsTimeout != null) {
431
+ clearTimeout(state.noStreamsTimeout)
432
+ state.noStreamsTimeout = null
433
+ }
434
+ }
435
+
436
+ // A peer is allowed to advertise SETTINGS_MAX_CONCURRENT_STREAMS = 0 to refuse
437
+ // new streams (RFC 9113 §6.5.2), and is expected to raise it again later. Until
438
+ // it does, busy() reports the client as permanently busy and queued requests
439
+ // cannot open a stream — which means no per-stream timeout covers them, and no
440
+ // reconnect can happen either, so the SETTINGS frame that would lift the limit
441
+ // can never arrive. Give the peer headersTimeout to start honouring requests
442
+ // before failing them; a request that cannot even be sent has missed the same
443
+ // deadline as one whose headers never arrive.
444
+ function setNoStreamsTimeout (session) {
445
+ const client = session[kClient]
446
+ const state = session[kHTTP2SessionState]
447
+ const timeout = client[kHeadersTimeout]
448
+
449
+ if (!timeout || state.noStreamsTimeout != null) {
450
+ return
451
+ }
452
+
453
+ state.noStreamsTimeout = setTimeout(onNoStreamsTimeout, timeout, session).unref()
454
+ }
455
+
456
+ function onNoStreamsTimeout (session) {
457
+ const client = session[kClient]
458
+ const state = session[kHTTP2SessionState]
459
+
460
+ state.noStreamsTimeout = null
461
+
462
+ if (
463
+ client[kHTTP2Session] !== session ||
464
+ client[kMaxConcurrentStreams] !== 0 ||
465
+ client[kRunning] !== 0 ||
466
+ client[kPending] === 0
467
+ ) {
468
+ return
469
+ }
470
+
471
+ const err = new HeadersTimeoutError(
472
+ `HTTP/2: server did not accept a new stream within ${client[kHeadersTimeout]}`
473
+ )
474
+
475
+ const requests = client[kQueue].splice(client[kPendingIdx])
476
+ for (let i = 0; i < requests.length; i++) {
477
+ if (requests[i] != null) {
478
+ util.errorRequest(client, requests[i], err)
479
+ }
372
480
  }
481
+
482
+ // Drop the unusable session so the next request gets a fresh connection,
483
+ // whose SETTINGS may well allow streams again.
484
+ session[kError] = err
485
+ resetHttp2Session(session, err)
373
486
  }
374
487
 
375
488
  function clearHttp2IdleTimeout (session) {
@@ -527,7 +640,7 @@ function onHttp2SessionGoAway (errorCode, lastStreamID) {
527
640
  if (request != null) {
528
641
  streamsToClose.push(detachRequestStreamForClose(request))
529
642
 
530
- if (canRetryRequestAfterGoAway(request)) {
643
+ if (canReplayRequest(request) && registerGoAwayRefusal(request)) {
531
644
  retriableRequests.push(request)
532
645
  } else {
533
646
  util.errorRequest(client, request, err)
@@ -552,6 +665,7 @@ function onHttp2SessionGoAway (errorCode, lastStreamID) {
552
665
  }
553
666
 
554
667
  clearHttp2IdleTimeout(this)
668
+ clearNoStreamsTimeout(this)
555
669
 
556
670
  if (!this.closed && !this.destroyed) {
557
671
  this.close()
@@ -576,6 +690,7 @@ function onHttp2SessionClose () {
576
690
  }
577
691
 
578
692
  clearHttp2IdleTimeout(this)
693
+ clearNoStreamsTimeout(this)
579
694
 
580
695
  if (state.ping.interval != null) {
581
696
  clearInterval(state.ping.interval)
@@ -687,6 +802,16 @@ function completeRequestStream () {
687
802
 
688
803
  if (state.pendingEnd && !state.request.aborted && !state.request.completed) {
689
804
  state.request.onResponseEnd(state.trailers || {})
805
+ } else if (!state.request.aborted && !state.request.completed) {
806
+ // The stream closed without a complete response and without reporting an
807
+ // error. finalizeRequest() below frees the queue slot either way, so
808
+ // without this the request would simply vanish and its caller would never
809
+ // hear back.
810
+ util.errorRequest(
811
+ state.client,
812
+ state.request,
813
+ new InformationalError('HTTP/2: stream closed before the response was complete')
814
+ )
690
815
  }
691
816
 
692
817
  finalizeRequest(state)
@@ -1286,6 +1411,38 @@ function onEnd () {
1286
1411
  }
1287
1412
  }
1288
1413
 
1414
+ function retryRefusedStream (stream, state) {
1415
+ const { client, request } = state
1416
+
1417
+ if (
1418
+ state.responseReceived ||
1419
+ request.aborted ||
1420
+ request.completed ||
1421
+ request[kRefusedStreamRetry] ||
1422
+ !canReplayRequest(request)
1423
+ ) {
1424
+ return false
1425
+ }
1426
+
1427
+ // RFC 9113 section 8.7 permits retrying REFUSED_STREAM, but says clients
1428
+ // SHOULD NOT automatically retry the same request more than once.
1429
+ request[kRefusedStreamRetry] = true
1430
+
1431
+ // Detach the failed attempt before moving the request back to the pending
1432
+ // queue. The peer only reset this stream, so the HTTP/2 session remains
1433
+ // usable for the retry. Severing also drops the 'close' listener, so the
1434
+ // abandoned stream cannot later complete the retried request.
1435
+ detachRequestStreamForClose(request)
1436
+ state.stream = null
1437
+ state.requestFinalized = true
1438
+
1439
+ completeRequest(client, request)
1440
+ client[kQueue].splice(client[kPendingIdx], 0, request)
1441
+ client[kResume]()
1442
+
1443
+ return true
1444
+ }
1445
+
1289
1446
  function onError (err) {
1290
1447
  const stream = this
1291
1448
  const state = stream[kRequestStreamState]
@@ -1295,6 +1452,18 @@ function onError (err) {
1295
1452
  }
1296
1453
 
1297
1454
  stream.off('error', onError)
1455
+
1456
+ if (typeof stream.rstCode === 'number' && stream.rstCode !== NGHTTP2_NO_ERROR) {
1457
+ err.http2ErrorCode = stream.rstCode
1458
+ }
1459
+
1460
+ if (
1461
+ stream.rstCode === NGHTTP2_REFUSED_STREAM &&
1462
+ retryRefusedStream(stream, state)
1463
+ ) {
1464
+ return
1465
+ }
1466
+
1298
1467
  state.abort(err)
1299
1468
  }
1300
1469
 
@@ -53,10 +53,8 @@ const {
53
53
  kHTTPContext,
54
54
  kMaxConcurrentStreams,
55
55
  kHostAuthority,
56
- kHTTP2InitialWindowSize,
57
- kHTTP2ConnectionWindowSize,
58
56
  kResume,
59
- kPingInterval
57
+ kHTTP2Options
60
58
  } = require('../core/symbols.js')
61
59
  const connectH1 = require('./client-h1.js')
62
60
  const connectH2 = require('./client-h2.js')
@@ -76,6 +74,16 @@ function getPipelining (client) {
76
74
  return client[kPipelining] ?? client[kHTTPContext]?.defaultPipelining ?? 1
77
75
  }
78
76
 
77
+ let h2NamespaceOptsWarning = false
78
+ function emitH2OptionsNamespaceWarning (optName) {
79
+ if (h2NamespaceOptsWarning === true) return
80
+
81
+ process.emitWarning(`Use h2Options.${optName} instead. ${optName} for H2 will be deprecated in future major.`, {
82
+ code: 'UNDICI-H2-OPTIONS'
83
+ })
84
+ h2NamespaceOptsWarning = true
85
+ }
86
+
79
87
  // Protocol-aware dispatch ceiling. h1 RFC7230 pipelining is unrelated to h2
80
88
  // stream multiplexing — over h2 the ceiling is the (server-confirmed)
81
89
  // maxConcurrentStreams. Before a context is attached we use the h1
@@ -128,7 +136,8 @@ class Client extends DispatcherBase {
128
136
  initialWindowSize,
129
137
  connectionWindowSize,
130
138
  pingInterval,
131
- webSocket
139
+ webSocket,
140
+ h2Options
132
141
  } = {}) {
133
142
  if (keepAlive !== undefined) {
134
143
  throw new InvalidArgumentError('unsupported keepAlive, use pipelining=0 instead')
@@ -216,24 +225,55 @@ class Client extends DispatcherBase {
216
225
  throw new InvalidArgumentError('allowH2 must be a valid boolean value')
217
226
  }
218
227
 
219
- if (maxConcurrentStreams != null && (typeof maxConcurrentStreams !== 'number' || maxConcurrentStreams < 1)) {
220
- throw new InvalidArgumentError('maxConcurrentStreams must be a positive integer, greater than 0')
221
- }
228
+ // We validate only if allowH2 is enabled or null (enabled by default)
229
+ if (allowH2 !== false) {
230
+ // Prioritise new h2Options object, otherwise fallback to prior configuration options
231
+ if (h2Options != null) {
232
+ if (h2Options.useH2c != null && typeof h2Options.useH2c !== 'boolean') {
233
+ throw new InvalidArgumentError('h2Options.useH2c must be a valid boolean value')
234
+ }
222
235
 
223
- if (useH2c != null && typeof useH2c !== 'boolean') {
224
- throw new InvalidArgumentError('useH2c must be a valid boolean value')
225
- }
236
+ if (h2Options.settings?.initialWindowSize != null && (!Number.isInteger(h2Options.settings.initialWindowSize) || h2Options.settings.initialWindowSize < 1)) {
237
+ throw new InvalidArgumentError('h2Options.settings.initialWindowSize must be a positive integer, greater than 0')
238
+ }
226
239
 
227
- if (initialWindowSize != null && (!Number.isInteger(initialWindowSize) || initialWindowSize < 1)) {
228
- throw new InvalidArgumentError('initialWindowSize must be a positive integer, greater than 0')
229
- }
240
+ if (h2Options.maxConcurrentStreams != null && (!Number.isInteger(h2Options.connectionWindowSize) || h2Options.maxConcurrentStreams < 1)) {
241
+ throw new InvalidArgumentError('h2Options.maxConcurrentStreams must be a positive integer, greater than 0')
242
+ }
230
243
 
231
- if (connectionWindowSize != null && (!Number.isInteger(connectionWindowSize) || connectionWindowSize < 1)) {
232
- throw new InvalidArgumentError('connectionWindowSize must be a positive integer, greater than 0')
233
- }
244
+ if (h2Options.connectionWindowSize != null && (!Number.isInteger(h2Options.connectionWindowSize) || h2Options.connectionWindowSize < 1)) {
245
+ throw new InvalidArgumentError('h2Options.connectionWindowSize must be a positive integer, greater than 0')
246
+ }
247
+
248
+ if (h2Options.pingInterval != null && (typeof h2Options.pingInterval !== 'number' || !Number.isInteger(h2Options.pingInterval) || h2Options.pingInterval < 0)) {
249
+ throw new InvalidArgumentError('h2Options.pingInterval must be a positive integer, greater or equal to 0')
250
+ }
251
+ } else {
252
+ if (useH2c != null && typeof useH2c !== 'boolean') {
253
+ emitH2OptionsNamespaceWarning('useH2c')
254
+ throw new InvalidArgumentError('useH2c must be a valid boolean value')
255
+ }
256
+
257
+ if (maxConcurrentStreams != null && (typeof maxConcurrentStreams !== 'number' || maxConcurrentStreams < 1)) {
258
+ emitH2OptionsNamespaceWarning('maxConcurrentStreams')
259
+ throw new InvalidArgumentError('maxConcurrentStreams must be a positive integer, greater than 0')
260
+ }
234
261
 
235
- if (pingInterval != null && (typeof pingInterval !== 'number' || !Number.isInteger(pingInterval) || pingInterval < 0)) {
236
- throw new InvalidArgumentError('pingInterval must be a positive integer, greater or equal to 0')
262
+ if (initialWindowSize != null && (!Number.isInteger(initialWindowSize) || initialWindowSize < 1)) {
263
+ emitH2OptionsNamespaceWarning('initialWindowSize')
264
+ throw new InvalidArgumentError('initialWindowSize must be a positive integer, greater than 0')
265
+ }
266
+
267
+ if (connectionWindowSize != null && (!Number.isInteger(connectionWindowSize) || connectionWindowSize < 1)) {
268
+ emitH2OptionsNamespaceWarning('connectionWindowSize')
269
+ throw new InvalidArgumentError('connectionWindowSize must be a positive integer, greater than 0')
270
+ }
271
+
272
+ if (pingInterval != null && (typeof pingInterval !== 'number' || !Number.isInteger(pingInterval) || pingInterval < 0)) {
273
+ emitH2OptionsNamespaceWarning('pingInterval')
274
+ throw new InvalidArgumentError('pingInterval must be a positive integer, greater or equal to 0')
275
+ }
276
+ }
237
277
  }
238
278
 
239
279
  super({ webSocket })
@@ -243,8 +283,8 @@ class Client extends DispatcherBase {
243
283
  ...tls,
244
284
  maxCachedSessions,
245
285
  allowH2,
246
- useH2c,
247
286
  socketPath,
287
+ useH2c: h2Options?.useH2c ?? useH2c,
248
288
  timeout: connectTimeout,
249
289
  ...(typeof autoSelectFamily === 'boolean' ? { autoSelectFamily, autoSelectFamilyAttemptTimeout } : undefined),
250
290
  ...connect
@@ -280,16 +320,20 @@ class Client extends DispatcherBase {
280
320
  this[kMaxResponseSize] = maxResponseSize > -1 ? maxResponseSize : -1
281
321
  this[kHTTPContext] = null
282
322
  // h2
283
- this[kMaxConcurrentStreams] = maxConcurrentStreams != null ? maxConcurrentStreams : 100 // Max peerConcurrentStreams for a Node h2 server
284
- // HTTP/2 window sizes are set to higher defaults than Node.js core for better performance:
285
- // - initialWindowSize: 262144 (256KB) vs Node.js default 65535 (64KB - 1)
286
- // Allows more data to be sent before requiring acknowledgment, improving throughput
287
- // especially on high-latency networks. This matches common production HTTP/2 servers.
288
- // - connectionWindowSize: 524288 (512KB) vs Node.js default (none set)
289
- // Provides better flow control for the entire connection across multiple streams.
290
- this[kHTTP2InitialWindowSize] = initialWindowSize != null ? initialWindowSize : 262144
291
- this[kHTTP2ConnectionWindowSize] = connectionWindowSize != null ? connectionWindowSize : 524288
292
- this[kPingInterval] = pingInterval != null ? pingInterval : 60e3 // Default ping interval for h2 - 1 minute
323
+ this[kHTTP2Options] = {
324
+ pingInterval: h2Options?.pingInterval ?? pingInterval ?? 60e3,
325
+ connectionWindowSize: h2Options?.connectionWindowSize ?? connectionWindowSize ?? 524288,
326
+ maxConcurrentStreams: h2Options?.maxConcurrentStreams ?? maxConcurrentStreams ?? 100, // Max peerConcurrentStreams for a Node h2 server
327
+ sessionOptions: {
328
+ // HTTP/2 window sizes are set to higher defaults than Node.js core for better performance:
329
+ // - initialWindowSize: 262144 (256KB) vs Node.js default 65535 (64KB - 1)
330
+ // Allows more data to be sent before requiring acknowledgment, improving throughput
331
+ // especially on high-latency networks. This matches common production HTTP/2 servers.
332
+ // - connectionWindowSize: 524288 (512KB) vs Node.js default (none set)
333
+ // Provides better flow control for the entire connection across multiple streams.
334
+ initialWindowSize: h2Options?.initialWindowSize ?? initialWindowSize ?? 262144
335
+ }
336
+ }
293
337
 
294
338
  // kQueue is built up of 3 sections separated by
295
339
  // the kRunningIdx and kPendingIdx indices.
@@ -672,6 +716,7 @@ function _resume (client, sync) {
672
716
  }
673
717
 
674
718
  if (!client[kHTTPContext]) {
719
+ client[kServerName] = request.servername
675
720
  connect(client)
676
721
  return
677
722
  }
@@ -65,9 +65,10 @@ class EnvHttpProxyAgent extends DispatcherBase {
65
65
  #getProxyAgentForUrl (url) {
66
66
  let { protocol, host: hostname, port } = url
67
67
 
68
- // Stripping ports in this way instead of using parsedUrl.hostname to make
69
- // sure that the brackets around IPv6 addresses are kept.
70
- hostname = hostname.replace(/:\d*$/, '').toLowerCase()
68
+ // Remove the port suffix (e.g. ":8080") and then strip surrounding
69
+ // brackets from IPv6 literals (e.g. "[::1]" -> "::1") so that the
70
+ // result matches the unbracketed form stored by #parseNoProxy.
71
+ hostname = hostname.replace(/:\d*$/, '').replace(/^\[(.+)\]$/, '$1').toLowerCase()
71
72
  port = Number.parseInt(port, 10) || DEFAULT_PORTS[protocol] || 0
72
73
  if (!this.#shouldProxy(hostname, port)) {
73
74
  return this[kNoProxyAgent]
@@ -119,11 +120,32 @@ class EnvHttpProxyAgent extends DispatcherBase {
119
120
  if (!entry) {
120
121
  continue
121
122
  }
122
- const parsed = entry.match(/^(.+):(\d+)$/)
123
+
124
+ // An IPv6 entry with a port must be bracketed: [::1]:443.
125
+ // A bare IPv6 address like ::1 contains colons that must not be
126
+ // confused with a host:port separator, so we handle it separately.
127
+ let hostname, port
128
+ const ipv6WithPort = entry.match(/^\[(.+)\]:(\d+)$/)
129
+ if (ipv6WithPort) {
130
+ hostname = ipv6WithPort[1]
131
+ port = Number.parseInt(ipv6WithPort[2], 10)
132
+ } else {
133
+ // Bracketed IPv6 without port, or plain hostname[:port], or bare IPv6.
134
+ // Strip optional brackets first.
135
+ const unbracketed = entry.replace(/^\[(.+)\]$/, '$1')
136
+ // A bare IPv6 address contains multiple colons; a hostname:port entry
137
+ // has exactly one colon followed by digits. Only attempt host:port
138
+ // splitting when that is unambiguously the case.
139
+ const colonCount = (unbracketed.match(/:/g) || []).length
140
+ const parsed = colonCount === 1 && unbracketed.match(/^(.+):(\d+)$/)
141
+ hostname = parsed ? parsed[1] : unbracketed
142
+ port = parsed ? Number.parseInt(parsed[2], 10) : 0
143
+ }
144
+
123
145
  noProxyEntries.push({
124
146
  // strip leading dot or asterisk with dot
125
- hostname: (parsed ? parsed[1] : entry).replace(/^\*?\./, '').toLowerCase(),
126
- port: parsed ? Number.parseInt(parsed[2], 10) : 0
147
+ hostname: hostname.replace(/^\*?\./, '').toLowerCase(),
148
+ port
127
149
  })
128
150
  }
129
151
 
@@ -6,7 +6,7 @@ let tls // include tls conditionally since it is not always available
6
6
  const DispatcherBase = require('./dispatcher-base')
7
7
  const { InvalidArgumentError } = require('../core/errors')
8
8
  const { Socks5Client, STATES } = require('../core/socks5-client')
9
- const { kDispatch, kClose, kDestroy } = require('../core/symbols')
9
+ const { kBusy, kConnected, kDispatch, kClose, kDestroy } = require('../core/symbols')
10
10
  const Pool = require('./pool')
11
11
  const buildConnector = require('../core/connect')
12
12
  const { debuglog } = require('node:util')
@@ -226,6 +226,20 @@ class Socks5ProxyAgent extends DispatcherBase {
226
226
  }
227
227
  })
228
228
  this[kPools].set(originKey, pool)
229
+
230
+ const closePoolIfUnused = () => {
231
+ if (this[kPools].get(originKey) !== pool || pool[kConnected] > 0 || pool[kBusy]) {
232
+ return
233
+ }
234
+
235
+ this[kPools].delete(originKey)
236
+ if (!pool.destroyed) {
237
+ pool.close()
238
+ }
239
+ }
240
+
241
+ pool.on('disconnect', closePoolIfUnused)
242
+ pool.on('connectionError', closePoolIfUnused)
229
243
  }
230
244
 
231
245
  // Dispatch the request through the per-origin pool
@@ -241,6 +241,11 @@ class RetryHandler {
241
241
  }
242
242
 
243
243
  onResponseStart (controller, statusCode, headers, statusMessage) {
244
+ if (statusCode < 200) {
245
+ this.handler.onResponseStart?.(this.controllerProxy, statusCode, headers, statusMessage)
246
+ return
247
+ }
248
+
244
249
  this.error = null
245
250
  this.retryCount += 1
246
251
  this.statusCode = statusCode
@@ -305,7 +310,7 @@ class RetryHandler {
305
310
  // First time we receive 206
306
311
  const range = parseRangeHeader(headers['content-range'])
307
312
 
308
- if (range == null) {
313
+ if (range == null || range.end == null) {
309
314
  this.headersSent = true
310
315
  this.handler.onResponseStart?.(
311
316
  this.controllerProxy,
@@ -330,7 +335,7 @@ class RetryHandler {
330
335
  }
331
336
 
332
337
  // We make our best to checkpoint the body for further range headers
333
- if (this.end == null) {
338
+ if (this.end == null && this.opts.method !== 'HEAD') {
334
339
  const contentLength = headers['content-length']
335
340
  this.end = contentLength != null ? Number(contentLength) - 1 : null
336
341
  }
@@ -540,13 +540,16 @@ module.exports = (opts = {}) => {
540
540
 
541
541
  return dispatch => {
542
542
  return (opts, handler) => {
543
- if (!opts.origin || arrayIncludes(safeMethodsToNotCache, opts.method)) {
544
- // Not a method we want to cache or we don't have the origin, skip
543
+ if (arrayIncludes(safeMethodsToNotCache, opts.method)) {
544
+ // Not a method we want to cache, skip
545
545
  return dispatch(opts, handler)
546
546
  }
547
547
 
548
548
  // Check if origin is in whitelist
549
549
  if (origins !== undefined) {
550
+ if (!opts.origin) {
551
+ return dispatch(opts, handler)
552
+ }
550
553
  const requestOrigin = opts.origin.toString().toLowerCase()
551
554
  let isAllowed = false
552
555
 
@@ -59,7 +59,7 @@ module.exports = (opts = {}) => {
59
59
 
60
60
  return dispatch => {
61
61
  return (opts, handler) => {
62
- if (!opts.origin || methods.includes(opts.method) === false) {
62
+ if (opts.upgrade || methods.includes(opts.method) === false) {
63
63
  return dispatch(opts, handler)
64
64
  }
65
65