@openclaw/discord 2026.6.33 → 2026.6.34

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 (103) hide show
  1. package/dist/api.js +1 -1
  2. package/dist/{channel-Ddnonoy4.js → channel-DU4jnQgl.js} +1 -1
  3. package/dist/channel-plugin-api.js +1 -1
  4. package/dist/{manager.runtime-BK6cf2Zu.js → manager.runtime-NxCd-PVt.js} +1 -1
  5. package/dist/{message-handler-BqpJIavO.js → message-handler-cizxbaDc.js} +3 -2
  6. package/dist/{message-handler.preflight-C90MxCcv.js → message-handler.preflight-CbD0u7U7.js} +2 -2
  7. package/dist/{message-handler.process-CeQ7Bd_3.js → message-handler.process-Do4EM591.js} +2 -2
  8. package/dist/{provider-C7376XFH.js → provider-B-s93q9s.js} +31 -6
  9. package/dist/{provider-session.runtime-CCdqogGf.js → provider-session.runtime-BKMOqHpd.js} +1 -1
  10. package/dist/provider.runtime-CaTJrpnl.js +2 -0
  11. package/dist/runtime-api.js +3 -3
  12. package/dist/{runtime-api.monitor-4oc58TSk.js → runtime-api.monitor-CRiBIQEI.js} +2 -2
  13. package/dist/runtime-api.monitor.js +3 -3
  14. package/node_modules/undici/README.md +8 -2
  15. package/node_modules/undici/docs/docs/api/Agent.md +248 -44
  16. package/node_modules/undici/docs/docs/api/BalancedPool.md +246 -48
  17. package/node_modules/undici/docs/docs/api/CacheStorage.md +171 -13
  18. package/node_modules/undici/docs/docs/api/CacheStore.md +294 -98
  19. package/node_modules/undici/docs/docs/api/Client.md +369 -179
  20. package/node_modules/undici/docs/docs/api/ClientStats.md +80 -14
  21. package/node_modules/undici/docs/docs/api/Connector.md +118 -36
  22. package/node_modules/undici/docs/docs/api/ContentType.md +65 -25
  23. package/node_modules/undici/docs/docs/api/Cookies.md +122 -71
  24. package/node_modules/undici/docs/docs/api/Debug.md +34 -18
  25. package/node_modules/undici/docs/docs/api/DiagnosticsChannel.md +364 -164
  26. package/node_modules/undici/docs/docs/api/Dispatcher.md +485 -1102
  27. package/node_modules/undici/docs/docs/api/EnvHttpProxyAgent.md +101 -87
  28. package/node_modules/undici/docs/docs/api/Errors.md +503 -40
  29. package/node_modules/undici/docs/docs/api/EventSource.md +294 -32
  30. package/node_modules/undici/docs/docs/api/Fetch.md +680 -31
  31. package/node_modules/undici/docs/docs/api/GlobalInstallation.md +78 -98
  32. package/node_modules/undici/docs/docs/api/H2CClient.md +298 -176
  33. package/node_modules/undici/docs/docs/api/Interceptors.md +414 -0
  34. package/node_modules/undici/docs/docs/api/MockAgent.md +333 -314
  35. package/node_modules/undici/docs/docs/api/MockCallHistory.md +272 -98
  36. package/node_modules/undici/docs/docs/api/MockCallHistoryLog.md +189 -26
  37. package/node_modules/undici/docs/docs/api/MockClient.md +151 -33
  38. package/node_modules/undici/docs/docs/api/MockErrors.md +56 -5
  39. package/node_modules/undici/docs/docs/api/MockPool.md +321 -258
  40. package/node_modules/undici/docs/docs/api/Pool.md +235 -43
  41. package/node_modules/undici/docs/docs/api/PoolStats.md +119 -13
  42. package/node_modules/undici/docs/docs/api/ProxyAgent.md +179 -160
  43. package/node_modules/undici/docs/docs/api/RedirectHandler.md +238 -63
  44. package/node_modules/undici/docs/docs/api/RetryAgent.md +113 -26
  45. package/node_modules/undici/docs/docs/api/RetryHandler.md +161 -77
  46. package/node_modules/undici/docs/docs/api/RoundRobinPool.md +166 -72
  47. package/node_modules/undici/docs/docs/api/SnapshotAgent.md +264 -542
  48. package/node_modules/undici/docs/docs/api/Socks5ProxyAgent.md +162 -187
  49. package/node_modules/undici/docs/docs/api/Util.md +68 -11
  50. package/node_modules/undici/docs/docs/api/WebSocket.md +475 -80
  51. package/node_modules/undici/docs/docs/api/api-lifecycle.md +100 -32
  52. package/node_modules/undici/docs/docs/best-practices/client-certificate.md +2 -0
  53. package/node_modules/undici/docs/docs/best-practices/crawling.md +3 -1
  54. package/node_modules/undici/docs/docs/best-practices/migrating-from-v7-to-v8.md +6 -4
  55. package/node_modules/undici/docs/docs/best-practices/mocking-request.md +9 -7
  56. package/node_modules/undici/docs/docs/best-practices/proxy.md +3 -1
  57. package/node_modules/undici/docs/docs/best-practices/undici-vs-builtin-fetch.md +10 -8
  58. package/node_modules/undici/docs/docs/best-practices/writing-tests.md +2 -0
  59. package/node_modules/undici/docs/docs/{GettingStarted.md → getting-started.md} +22 -19
  60. package/node_modules/undici/docs/docs/index.md +784 -0
  61. package/node_modules/undici/docs/docs/site.json +125 -0
  62. package/node_modules/undici/docs/docs/type-map.json +79 -0
  63. package/node_modules/undici/lib/api/api-request.js +7 -1
  64. package/node_modules/undici/lib/api/readable.js +47 -2
  65. package/node_modules/undici/lib/cache/memory-cache-store.js +54 -9
  66. package/node_modules/undici/lib/cache/sqlite-cache-store.js +7 -1
  67. package/node_modules/undici/lib/core/errors.js +20 -0
  68. package/node_modules/undici/lib/core/request.js +14 -3
  69. package/node_modules/undici/lib/core/util.js +30 -2
  70. package/node_modules/undici/lib/dispatcher/agent.js +3 -3
  71. package/node_modules/undici/lib/dispatcher/client-h1.js +65 -8
  72. package/node_modules/undici/lib/dispatcher/client-h2.js +265 -142
  73. package/node_modules/undici/lib/dispatcher/proxy-agent.js +40 -6
  74. package/node_modules/undici/lib/global.js +36 -16
  75. package/node_modules/undici/lib/handler/cache-handler.js +269 -61
  76. package/node_modules/undici/lib/handler/cache-revalidation-handler.js +13 -3
  77. package/node_modules/undici/lib/handler/redirect-handler.js +6 -2
  78. package/node_modules/undici/lib/handler/retry-handler.js +87 -23
  79. package/node_modules/undici/lib/interceptor/cache.js +159 -52
  80. package/node_modules/undici/lib/interceptor/decompress.js +9 -2
  81. package/node_modules/undici/lib/mock/mock-interceptor.js +25 -7
  82. package/node_modules/undici/lib/mock/mock-utils.js +39 -10
  83. package/node_modules/undici/lib/util/cache.js +372 -68
  84. package/node_modules/undici/lib/util/date.js +23 -6
  85. package/node_modules/undici/lib/web/cookies/parse.js +3 -2
  86. package/node_modules/undici/lib/web/cookies/util.js +79 -9
  87. package/node_modules/undici/lib/web/eventsource/util.js +1 -1
  88. package/node_modules/undici/lib/web/fetch/body.js +2 -1
  89. package/node_modules/undici/lib/web/fetch/constants.js +1 -1
  90. package/node_modules/undici/lib/web/fetch/index.js +11 -2
  91. package/node_modules/undici/lib/web/fetch/response.js +1 -3
  92. package/node_modules/undici/lib/web/fetch/util.js +4 -1
  93. package/node_modules/undici/package.json +2 -2
  94. package/node_modules/undici/types/client.d.ts +3 -3
  95. package/node_modules/undici/types/cookies.d.ts +1 -1
  96. package/node_modules/undici/types/dispatcher.d.ts +3 -3
  97. package/node_modules/undici/types/errors.d.ts +10 -0
  98. package/node_modules/undici/types/handlers.d.ts +2 -0
  99. package/node_modules/undici/types/mock-interceptor.d.ts +5 -1
  100. package/node_modules/undici/types/proxy-agent.d.ts +7 -0
  101. package/npm-shrinkwrap.json +7 -7
  102. package/package.json +5 -5
  103. package/dist/provider.runtime-D1m66kDS.js +0 -2
package/dist/api.js CHANGED
@@ -6,7 +6,7 @@ import { n as fetchDiscord, r as requestDiscord, t as DiscordApiError } from "./
6
6
  import { i as parseDiscordSendTarget, n as resolveDiscordTarget } from "./target-resolver-CDi1gI90.js";
7
7
  import "./targets-C6yd3y8R.js";
8
8
  import { a as getDiscordExecApprovalApprovers, c as shouldSuppressLocalDiscordExecApprovalPrompt, o as isDiscordExecApprovalApprover, s as isDiscordExecApprovalClientEnabled } from "./conversation-identity-36FFBwm5.js";
9
- import { i as resolveDiscordGroupToolPolicy, n as collectDiscordStatusIssues, r as resolveDiscordGroupRequireMention, t as discordPlugin } from "./channel-Ddnonoy4.js";
9
+ import { i as resolveDiscordGroupToolPolicy, n as collectDiscordStatusIssues, r as resolveDiscordGroupRequireMention, t as discordPlugin } from "./channel-DU4jnQgl.js";
10
10
  import { i as DISCORD_DEFAULT_LISTENER_TIMEOUT_MS, n as DISCORD_ATTACHMENT_TOTAL_TIMEOUT_MS, o as mergeAbortSignals, r as DISCORD_DEFAULT_INBOUND_WORKER_TIMEOUT_MS, t as DISCORD_ATTACHMENT_IDLE_TIMEOUT_MS } from "./timeouts-C5TBc_9x.js";
11
11
  import { t as normalizeExplicitDiscordSessionKey } from "./session-key-normalization-wJgsKPNF.js";
12
12
  import { t as discordSetupPlugin } from "./channel.setup-glZ5Y98a.js";
@@ -132,7 +132,7 @@ const loadDiscordResolveUsersModule = createLazyRuntimeModule(() => import("./re
132
132
  const loadDiscordThreadBindingsManagerModule = createLazyRuntimeModule(() => import("./thread-bindings.manager-BqWs1UE2.js").then((n) => n.a));
133
133
  const loadDiscordTargetResolverModule = createLazyRuntimeModule(() => import("./target-resolver-CDi1gI90.js").then((n) => n.r));
134
134
  async function loadDiscordProviderRuntime() {
135
- discordProviderRuntimePromise ??= import("./provider.runtime-D1m66kDS.js");
135
+ discordProviderRuntimePromise ??= import("./provider.runtime-CaTJrpnl.js");
136
136
  return await discordProviderRuntimePromise;
137
137
  }
138
138
  async function loadDiscordProbeRuntime() {
@@ -1,2 +1,2 @@
1
- import { t as discordPlugin } from "./channel-Ddnonoy4.js";
1
+ import { t as discordPlugin } from "./channel-DU4jnQgl.js";
2
2
  export { discordPlugin };
@@ -3,7 +3,7 @@ import { c as resolveDiscordAccountAllowFrom } from "./accounts-P19jm1lf.js";
3
3
  import { a as normalizeDiscordSlug, b as formatDiscordUserTag, m as resolveDiscordOwnerAccess } from "./allow-list-C-MqM-B_.js";
4
4
  import { o as formatMention } from "./send.outbound-B-cA1Esv.js";
5
5
  import { t as getDiscordRuntime } from "./runtime-DgnVQ7zW.js";
6
- import { d as resolveDiscordVoiceEnabled, p as buildDiscordGroupSystemPrompt, s as authorizeDiscordVoiceIngress } from "./provider-C7376XFH.js";
6
+ import { d as resolveDiscordVoiceEnabled, p as buildDiscordGroupSystemPrompt, s as authorizeDiscordVoiceIngress } from "./provider-B-s93q9s.js";
7
7
  import { createRequire } from "node:module";
8
8
  import { asBoolean, normalizeOptionalString, uniqueStrings } from "openclaw/plugin-sdk/string-coerce-runtime";
9
9
  import { resolveAgentRoute } from "openclaw/plugin-sdk/routing";
@@ -178,7 +178,7 @@ function resolveDiscordAcceptedTypingPrestart(ctx) {
178
178
  //#region extensions/discord/src/monitor/message-run-queue.ts
179
179
  let messageProcessRuntimePromise;
180
180
  async function loadMessageProcessRuntime() {
181
- messageProcessRuntimePromise ??= import("./message-handler.process-CeQ7Bd_3.js");
181
+ messageProcessRuntimePromise ??= import("./message-handler.process-Do4EM591.js");
182
182
  return await messageProcessRuntimePromise;
183
183
  }
184
184
  async function processDiscordQueuedMessage(params) {
@@ -226,6 +226,7 @@ function createDiscordMessageRunQueue(params) {
226
226
  });
227
227
  let lifecycleActive = !params.abortSignal?.aborted;
228
228
  const cleanupSkippedQueuedMessages = () => {
229
+ params.abortSignal?.removeEventListener("abort", cleanupSkippedQueuedMessages);
229
230
  if (!lifecycleActive && skippedCleanup.size === 0) return;
230
231
  lifecycleActive = false;
231
232
  const cleanups = [...skippedCleanup];
@@ -307,7 +308,7 @@ function createDiscordReplyTypingFeedback(params) {
307
308
  //#region extensions/discord/src/monitor/message-handler.ts
308
309
  let messagePreflightRuntimePromise;
309
310
  async function loadMessagePreflightRuntime() {
310
- messagePreflightRuntimePromise ??= import("./message-handler.preflight-C90MxCcv.js");
311
+ messagePreflightRuntimePromise ??= import("./message-handler.preflight-CbD0u7U7.js");
311
312
  return await messagePreflightRuntimePromise;
312
313
  }
313
314
  function isNonEmptyString(value) {
@@ -5,7 +5,7 @@ import { t as resolveDiscordConversationIdentity } from "./conversation-identity
5
5
  import { d as isRecentlyUnboundThreadWebhookMessage } from "./thread-bindings.state-iSWjCYjB.js";
6
6
  import { d as resolveDiscordChannelNameSafe, u as resolveDiscordChannelInfoSafe } from "./thread-bindings.discord-api-CYkr-3Gj.js";
7
7
  import "./thread-bindings-DU4T6nDo.js";
8
- import { D as resolveDiscordDmCommandAccess, O as resolveDiscordTextCommandAccess, _ as resolveDiscordConversationRoute, b as handleDiscordDmCommandDecision, g as buildDiscordRoutePeer, v as resolveDiscordEffectiveRoute, y as shouldIgnoreStaleDiscordRouteBinding } from "./provider-C7376XFH.js";
8
+ import { D as resolveDiscordDmCommandAccess, O as resolveDiscordTextCommandAccess, _ as resolveDiscordConversationRoute, b as handleDiscordDmCommandDecision, g as buildDiscordRoutePeer, v as resolveDiscordEffectiveRoute, y as shouldIgnoreStaleDiscordRouteBinding } from "./provider-B-s93q9s.js";
9
9
  import { d as resolveDiscordMessageChannelId, l as resolveDiscordMessageStickers, o as resolveMediaList, r as resolveDiscordMessageText, u as resolveDiscordChannelInfo } from "./message-utils-CJeAoISH.js";
10
10
  import { n as resolveDiscordWebhookId, t as resolveDiscordSenderIdentity } from "./sender-identity-CEsfDF0L.js";
11
11
  import { normalizeOptionalString, readStringValue } from "openclaw/plugin-sdk/string-coerce-runtime";
@@ -447,7 +447,7 @@ async function loadSystemEventsRuntime() {
447
447
  return await systemEventsRuntimePromise;
448
448
  }
449
449
  async function loadDiscordThreadingRuntime() {
450
- discordThreadingRuntimePromise ??= import("./provider-C7376XFH.js").then((n) => n.S);
450
+ discordThreadingRuntimePromise ??= import("./provider-B-s93q9s.js").then((n) => n.S);
451
451
  return await discordThreadingRuntimePromise;
452
452
  }
453
453
  function isPreflightAborted(abortSignal) {
@@ -10,9 +10,9 @@ import { t as beginDiscordInboundEventDeliveryCorrelation } from "./inbound-even
10
10
  import { n as DISCORD_ATTACHMENT_TOTAL_TIMEOUT_MS, t as DISCORD_ATTACHMENT_IDLE_TIMEOUT_MS } from "./timeouts-C5TBc_9x.js";
11
11
  import { t as DISCORD_TEXT_CHUNK_LIMIT } from "./outbound-adapter-Dxs6iKEq.js";
12
12
  import { t as resolveDiscordPreviewStreamMode } from "./preview-streaming-DXT8oJdo.js";
13
- import { C as resolveDiscordAutoThreadReplyPlan, T as resolveDiscordThreadStarter, a as buildGuildLabel, h as createDiscordSupplementalContextAccessChecker, i as buildDirectLabel, m as buildDiscordInboundAccessContext, n as deliverDiscordReply, o as resolveReplyContext, r as sanitizeDiscordFrontChannelReplyPayloads } from "./provider-C7376XFH.js";
13
+ import { C as resolveDiscordAutoThreadReplyPlan, T as resolveDiscordThreadStarter, a as buildGuildLabel, h as createDiscordSupplementalContextAccessChecker, i as buildDirectLabel, m as buildDiscordInboundAccessContext, n as deliverDiscordReply, o as resolveReplyContext, r as sanitizeDiscordFrontChannelReplyPayloads } from "./provider-B-s93q9s.js";
14
14
  import { a as resolveForwardedMediaList, o as resolveMediaList, r as resolveDiscordMessageText, s as resolveReferencedReplyMediaList } from "./message-utils-CJeAoISH.js";
15
- import { n as createDiscordReplyTypingFeedback } from "./message-handler-BqpJIavO.js";
15
+ import { n as createDiscordReplyTypingFeedback } from "./message-handler-cizxbaDc.js";
16
16
  import { buildAgentSessionKey, resolveThreadSessionKeys } from "openclaw/plugin-sdk/routing";
17
17
  import { MessageFlags } from "discord-api-types/v10";
18
18
  import { evaluateSupplementalContextVisibility } from "openclaw/plugin-sdk/security-runtime";
@@ -4920,19 +4920,38 @@ var GatewayReconnectTimer = class {
4920
4920
  //#region extensions/discord/src/internal/gateway-rate-limit.ts
4921
4921
  const GATEWAY_SEND_LIMIT = 120;
4922
4922
  const GATEWAY_SEND_WINDOW_MS = 6e4;
4923
+ const GATEWAY_SEND_QUEUE_LIMIT = GATEWAY_SEND_LIMIT;
4923
4924
  var GatewaySendLimiter = class {
4924
- constructor(sendNow, emitError) {
4925
+ constructor(sendNow, emitError, emitOverflowWarning) {
4925
4926
  this.sendNow = sendNow;
4926
4927
  this.emitError = emitError;
4928
+ this.emitOverflowWarning = emitOverflowWarning;
4927
4929
  this.outboundSendTimestamps = [];
4928
4930
  this.outboundQueue = [];
4931
+ this.droppedEvents = 0;
4932
+ this.overflowWarningEmitted = false;
4929
4933
  }
4930
4934
  send(serialized, options) {
4931
4935
  if (options?.critical || this.canSend(Date.now())) {
4932
4936
  this.sendSerialized(serialized);
4933
4937
  return;
4934
4938
  }
4939
+ let shouldEmitOverflowWarning = false;
4940
+ if (this.outboundQueue.length >= GATEWAY_SEND_QUEUE_LIMIT) {
4941
+ this.outboundQueue.shift();
4942
+ this.droppedEvents += 1;
4943
+ if (!this.overflowWarningEmitted) {
4944
+ this.overflowWarningEmitted = true;
4945
+ shouldEmitOverflowWarning = true;
4946
+ }
4947
+ }
4935
4948
  this.outboundQueue.push({ payload: serialized });
4949
+ if (shouldEmitOverflowWarning) this.emitOverflowWarning({
4950
+ droppedEvents: this.droppedEvents,
4951
+ maxQueuedEvents: GATEWAY_SEND_QUEUE_LIMIT,
4952
+ policy: "drop-oldest",
4953
+ queuedEvents: this.outboundQueue.length
4954
+ });
4936
4955
  this.scheduleFlush();
4937
4956
  }
4938
4957
  clear() {
@@ -4941,6 +4960,8 @@ var GatewaySendLimiter = class {
4941
4960
  this.outboundFlushTimer = void 0;
4942
4961
  }
4943
4962
  this.outboundQueue = [];
4963
+ this.droppedEvents = 0;
4964
+ this.overflowWarningEmitted = false;
4944
4965
  }
4945
4966
  getStatus() {
4946
4967
  const now = Date.now();
@@ -4950,7 +4971,8 @@ var GatewaySendLimiter = class {
4950
4971
  remainingEvents: Math.max(0, GATEWAY_SEND_LIMIT - this.outboundSendTimestamps.length),
4951
4972
  resetTime: this.outboundSendTimestamps.length > 0 ? oldest + GATEWAY_SEND_WINDOW_MS : now + GATEWAY_SEND_WINDOW_MS,
4952
4973
  currentEventCount: this.outboundSendTimestamps.length,
4953
- queuedEvents: this.outboundQueue.length
4974
+ queuedEvents: this.outboundQueue.length,
4975
+ droppedEvents: this.droppedEvents
4954
4976
  };
4955
4977
  }
4956
4978
  pruneWindow(now) {
@@ -4989,6 +5011,7 @@ var GatewaySendLimiter = class {
4989
5011
  return;
4990
5012
  }
4991
5013
  }
5014
+ if (this.outboundQueue.length < GATEWAY_SEND_QUEUE_LIMIT) this.overflowWarningEmitted = false;
4992
5015
  this.scheduleFlush();
4993
5016
  }
4994
5017
  };
@@ -5030,7 +5053,7 @@ var GatewayPlugin = class extends Plugin {
5030
5053
  this.isConnecting = false;
5031
5054
  this.heartbeatTimers = new GatewayHeartbeatTimers();
5032
5055
  this.reconnectTimer = new GatewayReconnectTimer();
5033
- this.outboundLimiter = new GatewaySendLimiter((payload) => this.sendSerializedGatewayEvent(payload), (error) => this.emitter.emit("error", error));
5056
+ this.outboundLimiter = new GatewaySendLimiter((payload) => this.sendSerializedGatewayEvent(payload), (error) => this.emitter.emit("error", error), (warning) => this.emitter.emit("warning", `Gateway outbound queue overflow policy=${warning.policy} droppedEvents=${warning.droppedEvents} queuedEvents=${warning.queuedEvents} maxQueuedEvents=${warning.maxQueuedEvents}`));
5034
5057
  this.options = {
5035
5058
  ...options,
5036
5059
  reconnect: {
@@ -9182,7 +9205,9 @@ function attachDiscordGatewayLogging(params) {
9182
9205
  if (shouldPromoteGatewayDebug(message)) runtime.log?.(`discord gateway: ${message}`);
9183
9206
  };
9184
9207
  const onGatewayWarning = (warning) => {
9185
- logVerbose(`discord gateway warning: ${String(warning)}`);
9208
+ const message = `discord gateway warning: ${String(warning)}`;
9209
+ logVerbose(message);
9210
+ runtime.log?.(warn(message));
9186
9211
  };
9187
9212
  const onGatewayMetrics = (metrics) => {
9188
9213
  logVerbose(`discord gateway metrics: ${formatGatewayMetrics(metrics)}`);
@@ -9895,7 +9920,7 @@ function logDiscordStartupPhase(params) {
9895
9920
  });
9896
9921
  }
9897
9922
  async function loadDiscordVoiceRuntime() {
9898
- const promise = discordVoiceRuntimePromise ?? import("./manager.runtime-BK6cf2Zu.js");
9923
+ const promise = discordVoiceRuntimePromise ?? import("./manager.runtime-NxCd-PVt.js");
9899
9924
  discordVoiceRuntimePromise = promise;
9900
9925
  try {
9901
9926
  return await promise;
@@ -9905,7 +9930,7 @@ async function loadDiscordVoiceRuntime() {
9905
9930
  }
9906
9931
  }
9907
9932
  async function loadDiscordProviderSessionRuntime() {
9908
- const promise = discordProviderSessionRuntimePromise ?? import("./provider-session.runtime-CCdqogGf.js");
9933
+ const promise = discordProviderSessionRuntimePromise ?? import("./provider-session.runtime-BKMOqHpd.js");
9909
9934
  discordProviderSessionRuntimePromise = promise;
9910
9935
  try {
9911
9936
  return await promise;
@@ -1,6 +1,6 @@
1
1
  import { a as reconcileAcpThreadBindingsOnStartup } from "./thread-bindings-DU4T6nDo.js";
2
2
  import { n as createThreadBindingManager, t as createNoopThreadBindingManager } from "./thread-bindings.manager-BqWs1UE2.js";
3
- import { t as createDiscordMessageHandler } from "./message-handler-BqpJIavO.js";
3
+ import { t as createDiscordMessageHandler } from "./message-handler-cizxbaDc.js";
4
4
  import { resolveThreadBindingIdleTimeoutMs, resolveThreadBindingMaxAgeMs, resolveThreadBindingsEnabled } from "openclaw/plugin-sdk/conversation-runtime";
5
5
  import { getAcpSessionManager, isAcpRuntimeError } from "openclaw/plugin-sdk/acp-runtime";
6
6
  export { createDiscordMessageHandler, createNoopThreadBindingManager, createThreadBindingManager, getAcpSessionManager, isAcpRuntimeError, reconcileAcpThreadBindingsOnStartup, resolveThreadBindingIdleTimeoutMs, resolveThreadBindingMaxAgeMs, resolveThreadBindingsEnabled };
@@ -0,0 +1,2 @@
1
+ import { t as monitorDiscordProvider } from "./provider-B-s93q9s.js";
2
+ export { monitorDiscordProvider };
@@ -21,10 +21,10 @@ import { a as resolveDiscordPrivilegedIntentsFromFlags, i as probeDiscord, n as
21
21
  import "./runtime-api.actions.js";
22
22
  import { r as collectDiscordAuditChannelIds, t as auditDiscordChannelPermissions } from "./audit-BwJ_2OjL.js";
23
23
  import "./runtime-api.lookup.js";
24
- import { E as sanitizeDiscordThreadName, c as createDiscordGatewayPlugin, f as createDiscordNativeCommand, l as resolveDiscordGatewayIntents, t as monitorDiscordProvider, u as waitForDiscordGatewayPluginRegistration, w as resolveDiscordReplyTarget, x as registerDiscordListener } from "./provider-C7376XFH.js";
24
+ import { E as sanitizeDiscordThreadName, c as createDiscordGatewayPlugin, f as createDiscordNativeCommand, l as resolveDiscordGatewayIntents, t as monitorDiscordProvider, u as waitForDiscordGatewayPluginRegistration, w as resolveDiscordReplyTarget, x as registerDiscordListener } from "./provider-B-s93q9s.js";
25
25
  import { i as buildDiscordMediaPayload } from "./message-utils-CJeAoISH.js";
26
- import { t as createDiscordMessageHandler } from "./message-handler-BqpJIavO.js";
27
- import "./runtime-api.monitor-4oc58TSk.js";
26
+ import { t as createDiscordMessageHandler } from "./message-handler-cizxbaDc.js";
27
+ import "./runtime-api.monitor-CRiBIQEI.js";
28
28
  import "./runtime-api.send.js";
29
29
  import "./runtime-api.threads.js";
30
30
  export { DISCORD_ATTACHMENT_IDLE_TIMEOUT_MS, DISCORD_ATTACHMENT_TOTAL_TIMEOUT_MS, DISCORD_DEFAULT_INBOUND_WORKER_TIMEOUT_MS, DISCORD_DEFAULT_LISTENER_TIMEOUT_MS, DiscordSendError, testing as __testing, testing, addRoleDiscord, allowListMatches, auditDiscordChannelPermissions, autoBindSpawnedDiscordSubagent, banMemberDiscord, buildDiscordMediaPayload, clearGateways, clearPresences, collectDiscordAuditChannelIds, createChannelDiscord, createDiscordGatewayPlugin, createDiscordMessageHandler, createDiscordNativeCommand, createNoopThreadBindingManager, createScheduledEventDiscord, createThreadBindingManager, createThreadDiscord, deleteChannelDiscord, deleteMessageDiscord, discordMessageActions, editChannelDiscord, editDiscordComponentMessage, editMessageDiscord, fetchChannelInfoDiscord, fetchChannelPermissionsDiscord, fetchDiscordApplicationId, fetchDiscordApplicationSummary, fetchMemberGuildPermissionsDiscord, fetchMemberInfoDiscord, fetchMessageDiscord, fetchReactionsDiscord, fetchRoleInfoDiscord, fetchVoiceStatusDiscord, formatThreadBindingDurationLabel, getGateway, getPresence, getThreadBindingManager, handleDiscordAction, hasAllGuildPermissionsDiscord, hasAnyGuildPermissionDiscord, isAbortError, isDiscordGroupAllowedByPolicy, isDiscordModerationAction, isRecentlyUnboundThreadWebhookMessage, kickMemberDiscord, listDiscordDirectoryGroupsLive, listDiscordDirectoryPeersLive, listGuildChannelsDiscord, listGuildEmojisDiscord, listPinsDiscord, listScheduledEventsDiscord, listThreadBindingsBySessionKey, listThreadBindingsForAccount, listThreadsDiscord, mergeAbortSignals, monitorDiscordProvider, moveChannelDiscord, normalizeDiscordAllowList, normalizeDiscordInboundWorkerTimeoutMs, normalizeDiscordListenerTimeoutMs, normalizeDiscordSlug, parseApplicationIdFromToken, pinMessageDiscord, presenceCacheSize, probeDiscord, reactMessageDiscord, readDiscordChannelCreateParams, readDiscordChannelEditParams, readDiscordChannelMoveParams, readDiscordModerationCommand, readDiscordParentIdParam, readMessagesDiscord, reconcileAcpThreadBindingsOnStartup, registerBuiltDiscordComponentMessage, registerDiscordListener, registerGateway, removeChannelPermissionDiscord, removeOwnReactionsDiscord, removeReactionDiscord, removeRoleDiscord, requiredGuildPermissionForModerationAction, resolveDiscordChannelAllowlist, resolveDiscordChannelConfig, resolveDiscordChannelConfigWithFallback, resolveDiscordCommandAuthorized, resolveDiscordGatewayIntents, resolveDiscordGuildEntry, resolveDiscordOutboundSessionRoute, resolveDiscordPrivilegedIntentsFromFlags, resolveDiscordReplyTarget, resolveDiscordShouldRequireMention, resolveDiscordThreadBindingIdleTimeoutMs, resolveDiscordThreadBindingMaxAgeMs, resolveDiscordUserAllowlist, resolveEventCoverImage, resolveGroupDmAllow, resolveThreadBindingIdleTimeoutMs, resolveThreadBindingInactivityExpiresAt, resolveThreadBindingIntroText, resolveThreadBindingMaxAgeExpiresAt, resolveThreadBindingMaxAgeMs, resolveThreadBindingPersona, resolveThreadBindingPersonaFromRecord, resolveThreadBindingThreadName, resolveThreadBindingsEnabled, runDiscordTaskWithTimeout, sanitizeDiscordThreadName, searchMessagesDiscord, sendDiscordComponentMessage, sendMessageDiscord, sendPollDiscord, sendStickerDiscord, sendTypingDiscord, sendVoiceMessageDiscord, sendWebhookMessageDiscord, setChannelPermissionDiscord, setDiscordRuntime, setPresence, setThreadBindingIdleTimeoutBySessionKey, setThreadBindingMaxAgeBySessionKey, shouldEmitDiscordReactionNotification, timeoutMemberDiscord, unbindThreadBindingsBySessionKey, unpinMessageDiscord, unregisterGateway, uploadEmojiDiscord, uploadStickerDiscord, waitForDiscordGatewayPluginRegistration };
@@ -1,6 +1,6 @@
1
1
  import "./allow-list-C-MqM-B_.js";
2
2
  import "./timeouts-C5TBc_9x.js";
3
- import "./provider-C7376XFH.js";
3
+ import "./provider-B-s93q9s.js";
4
4
  import "./message-utils-CJeAoISH.js";
5
- import "./message-handler-BqpJIavO.js";
5
+ import "./message-handler-cizxbaDc.js";
6
6
  export {};
@@ -2,8 +2,8 @@ import { i as setPresence, n as getPresence, r as presenceCacheSize, t as clearP
2
2
  import { G as getGateway, K as registerGateway, W as clearGateways, q as unregisterGateway } from "./send.shared-vcbfThdy.js";
3
3
  import { _ as resolveGroupDmAllow, a as normalizeDiscordSlug, c as resolveDiscordChannelConfigWithFallback, d as resolveDiscordGuildEntry, g as resolveDiscordShouldRequireMention, n as isDiscordGroupAllowedByPolicy, r as normalizeDiscordAllowList, s as resolveDiscordChannelConfig, t as allowListMatches, u as resolveDiscordCommandAuthorized, v as shouldEmitDiscordReactionNotification } from "./allow-list-C-MqM-B_.js";
4
4
  import { a as isAbortError, c as normalizeDiscordListenerTimeoutMs, i as DISCORD_DEFAULT_LISTENER_TIMEOUT_MS, n as DISCORD_ATTACHMENT_TOTAL_TIMEOUT_MS, o as mergeAbortSignals, r as DISCORD_DEFAULT_INBOUND_WORKER_TIMEOUT_MS, s as normalizeDiscordInboundWorkerTimeoutMs, t as DISCORD_ATTACHMENT_IDLE_TIMEOUT_MS, u as runDiscordTaskWithTimeout } from "./timeouts-C5TBc_9x.js";
5
- import { E as sanitizeDiscordThreadName, c as createDiscordGatewayPlugin, f as createDiscordNativeCommand, l as resolveDiscordGatewayIntents, t as monitorDiscordProvider, u as waitForDiscordGatewayPluginRegistration, w as resolveDiscordReplyTarget, x as registerDiscordListener } from "./provider-C7376XFH.js";
5
+ import { E as sanitizeDiscordThreadName, c as createDiscordGatewayPlugin, f as createDiscordNativeCommand, l as resolveDiscordGatewayIntents, t as monitorDiscordProvider, u as waitForDiscordGatewayPluginRegistration, w as resolveDiscordReplyTarget, x as registerDiscordListener } from "./provider-B-s93q9s.js";
6
6
  import { i as buildDiscordMediaPayload } from "./message-utils-CJeAoISH.js";
7
- import { t as createDiscordMessageHandler } from "./message-handler-BqpJIavO.js";
8
- import "./runtime-api.monitor-4oc58TSk.js";
7
+ import { t as createDiscordMessageHandler } from "./message-handler-cizxbaDc.js";
8
+ import "./runtime-api.monitor-CRiBIQEI.js";
9
9
  export { DISCORD_ATTACHMENT_IDLE_TIMEOUT_MS, DISCORD_ATTACHMENT_TOTAL_TIMEOUT_MS, DISCORD_DEFAULT_INBOUND_WORKER_TIMEOUT_MS, DISCORD_DEFAULT_LISTENER_TIMEOUT_MS, allowListMatches, buildDiscordMediaPayload, clearGateways, clearPresences, createDiscordGatewayPlugin, createDiscordMessageHandler, createDiscordNativeCommand, getGateway, getPresence, isAbortError, isDiscordGroupAllowedByPolicy, mergeAbortSignals, monitorDiscordProvider, normalizeDiscordAllowList, normalizeDiscordInboundWorkerTimeoutMs, normalizeDiscordListenerTimeoutMs, normalizeDiscordSlug, presenceCacheSize, registerDiscordListener, registerGateway, resolveDiscordChannelConfig, resolveDiscordChannelConfigWithFallback, resolveDiscordCommandAuthorized, resolveDiscordGatewayIntents, resolveDiscordGuildEntry, resolveDiscordReplyTarget, resolveDiscordShouldRequireMention, resolveGroupDmAllow, runDiscordTaskWithTimeout, sanitizeDiscordThreadName, setPresence, shouldEmitDiscordReactionNotification, unregisterGateway, waitForDiscordGatewayPluginRegistration };
@@ -408,6 +408,11 @@ For more information about their behavior, please reference the body mixin from
408
408
 
409
409
  This section documents our most commonly used API methods. Additional APIs are documented in their own files within the [docs](./docs/) folder and are accessible via the navigation list on the left side of the docs site.
410
410
 
411
+ For the top-level APIs below, the `url` argument supplies the request origin and
412
+ path. Do not pass `origin` or `path` in the second `options` argument. The linked
413
+ `Dispatcher` option types include those fields because dispatcher methods are
414
+ lower-level APIs that do not receive a separate `url` argument.
415
+
411
416
  ### `undici.request([url, options]): Promise`
412
417
 
413
418
  Arguments:
@@ -717,8 +722,9 @@ Refs: https://tools.ietf.org/html/rfc7231#section-5.1.1
717
722
  #### Pipelining
718
723
 
719
724
  Undici will only use pipelining if configured with a `pipelining` factor
720
- greater than `1`. Also it is important to pass `blocking: false` to the
721
- request options to properly pipeline requests.
725
+ greater than `1`. Only enable pipelining when the remote server is trusted.
726
+ Also it is important to pass `blocking: false` to the request options to
727
+ properly pipeline requests.
722
728
 
723
729
  Undici always assumes that connections are persistent and will immediately
724
730
  pipeline requests, without checking whether the connection is persistent.
@@ -1,87 +1,291 @@
1
1
  # Agent
2
2
 
3
- Extends: `undici.Dispatcher`
3
+ <!--introduced_in=v3.2.0-->
4
+ <!--type=module-->
5
+ <!-- source_link=lib/dispatcher/agent.js -->
6
+
7
+ > Stability: 2 - Stable
8
+
9
+ An `Agent` dispatches requests against multiple different origins, creating and
10
+ reusing a per-origin [`Pool`][] (or [`Client`][]) on demand. It is the default
11
+ dispatcher used by [`request`][], [`stream`][], and [`fetch`][] when no explicit
12
+ dispatcher is supplied.
13
+
14
+ Requests are not guaranteed to be dispatched in their order of invocation.
15
+
16
+ ```mjs
17
+ import { Agent, setGlobalDispatcher } from 'undici'
18
+
19
+ const agent = new Agent({ connections: 10 })
20
+ setGlobalDispatcher(agent)
21
+ ```
22
+
23
+ ## Class: `Agent`
24
+
25
+ <!-- YAML
26
+ added: v3.2.0
27
+ -->
28
+
29
+ * Extends: {Dispatcher}
30
+
31
+ `Agent` keeps an internal map of origins to dispatchers. The first request to a
32
+ given origin lazily creates a dispatcher through the configured `factory`, and
33
+ subsequent requests to the same origin reuse it. Idle dispatchers are closed
34
+ automatically once they have no open connections and are no longer busy.
35
+
36
+ ### `new Agent([options])`
37
+
38
+ <!-- YAML
39
+ added: v3.2.0
40
+ changes:
41
+ - version: v7.16.0
42
+ pr-url: https://github.com/nodejs/undici/pull/4365
43
+ description: Added the `maxOrigins` option to cap the number of origins.
44
+ -->
45
+
46
+ * `options` {AgentOptions} (optional) Extends {PoolOptions}.
47
+ * `factory` {Function} Builds the dispatcher used for a given origin. When the
48
+ resolved options contain `connections: 1`, the default factory creates a
49
+ {Client}; otherwise it creates a {Pool}. **Default:** `(origin, opts) => new Pool(origin, opts)`.
50
+ * `origin` {URL|string} The origin to create a dispatcher for.
51
+ * `opts` {Object} The resolved options for the new dispatcher.
52
+ * Returns: {Dispatcher}
53
+ * `maxOrigins` {number} Limits the total number of distinct origins that may
54
+ receive requests at the same time. A {MaxOriginsReachedError} is thrown when
55
+ a request targets a new origin once the limit is reached. When set to
56
+ `Infinity`, no limit is enforced. Must be a number greater than `0`.
57
+ **Default:** `Infinity`.
58
+
59
+ `Agent` inherits all {PoolOptions} (and therefore all {ClientOptions}). The
60
+ per-origin {Pool} it creates uses the default unlimited `connections`, so
61
+ concurrent requests to the same origin are spread across separate {Client}
62
+ instances on separate sockets.
4
63
 
5
- Agent allows dispatching requests against multiple different origins.
64
+ > [!NOTE]
65
+ > Because each concurrent request to an origin may use a different {Client},
66
+ > HTTP/2 multiplexing on a shared session does not apply unless `connections` is
67
+ > set to a small value (for example `connections: 1`). See {PoolOptions} and
68
+ > {ClientOptions} for the full set of inherited options such as `allowH2`
69
+ > (default `true`) and `maxConcurrentStreams` (default `100`).
6
70
 
7
- Requests are not guaranteed to be dispatched in order of invocation.
71
+ ### `agent.closed`
8
72
 
9
- ## `new undici.Agent([options])`
73
+ <!-- YAML
74
+ added: v3.2.0
75
+ -->
10
76
 
11
- Arguments:
77
+ * Type: {boolean}
12
78
 
13
- * **options** `AgentOptions` (optional)
79
+ `true` after [`agent.close()`][] has been called.
14
80
 
15
- Returns: `Agent`
81
+ ### `agent.destroyed`
16
82
 
17
- ### Parameter: `AgentOptions`
83
+ <!-- YAML
84
+ added: v3.2.0
85
+ -->
18
86
 
19
- Extends: [`PoolOptions`](/docs/docs/api/Pool.md#parameter-pooloptions)
87
+ * Type: {boolean}
20
88
 
21
- * **factory** `(origin: URL, opts: Object) => Dispatcher` - Default: `(origin, opts) => new Pool(origin, opts)`
22
- * **maxOrigins** `number` (optional) - Default: `Infinity` - Limits the total number of origins that can receive requests at a time, throwing an `MaxOriginsReachedError` error when attempting to dispatch when the max is reached. If `Infinity`, no limit is enforced.
89
+ `true` after [`agent.destroy()`][] has been called, or after [`agent.close()`][]
90
+ has been called and the shutdown has completed.
23
91
 
24
- > [!NOTE]
25
- > Like `Pool`, `Agent` inherits all [`ClientOptions`](/docs/docs/api/Client.md#parameter-clientoptions). `allowH2` defaults to `true` and `maxConcurrentStreams` to `100`. The per-origin `Pool` it creates uses the default unlimited `connections`, so concurrent requests to the same origin land on separate `Client` instances and separate TCP/TLS sockets — HTTP/2 multiplexing on a shared session does not apply unless `connections` is set to a small value. See [`PoolOptions`](/docs/docs/api/Pool.md#parameter-pooloptions).
92
+ ### `agent.stats`
93
+
94
+ <!-- YAML
95
+ added: v7.9.0
96
+ -->
97
+
98
+ * Type: {Record<string, ClientStats|PoolStats>}
99
+
100
+ Aggregate statistics for the agent, keyed by origin. Each value is the
101
+ [`ClientStats`][] or [`PoolStats`][] object reported by the dispatcher currently
102
+ serving that origin. Origins whose dispatcher does not expose `stats` are
103
+ omitted.
104
+
105
+ ```mjs
106
+ import { Agent } from 'undici'
107
+
108
+ const agent = new Agent()
109
+ await agent.request({ origin: 'http://localhost:3000', path: '/', method: 'GET' })
110
+ console.log(agent.stats)
111
+ // { 'http://localhost:3000': PoolStats { ... } }
112
+ ```
113
+
114
+ ### `agent.dispatch(options, handler)`
115
+
116
+ <!-- YAML
117
+ added: v3.2.0
118
+ -->
119
+
120
+ * `options` {AgentDispatchOptions} Extends {DispatchOptions}.
121
+ * `origin` {string|URL} The origin to dispatch the request against. Required.
122
+ * `handler` {DispatchHandler}
123
+ * Returns: {boolean} `false` if the dispatcher is busy and the caller should
124
+ wait for the [`'drain'`][] event before dispatching again.
125
+
126
+ Routes the request to the dispatcher for `options.origin`, creating one through
127
+ the `factory` if needed. Throws an {InvalidArgumentError} when `options.origin`
128
+ is not a non-empty string or {URL}, and a {MaxOriginsReachedError} when a new
129
+ origin would exceed `maxOrigins`. Implements [`Dispatcher.dispatch()`][].
130
+
131
+ ### `agent.close([callback])`
132
+
133
+ <!-- YAML
134
+ added: v3.2.0
135
+ -->
136
+
137
+ * `callback` {Function} (optional) Invoked once every per-origin dispatcher has
138
+ closed. When omitted, a {Promise} is returned.
139
+ * Returns: {Promise|void}
140
+
141
+ Gracefully closes the agent and every dispatcher it owns, waiting for in-flight
142
+ requests to complete. Implements [`Dispatcher.close()`][].
143
+
144
+ ### `agent.destroy([error[, callback]])`
145
+
146
+ <!-- YAML
147
+ added: v3.2.0
148
+ -->
149
+
150
+ * `error` {Error} (optional) The error to abort pending requests with.
151
+ * `callback` {Function} (optional) Invoked once every per-origin dispatcher has
152
+ been destroyed. When omitted, a {Promise} is returned.
153
+ * Returns: {Promise|void}
154
+
155
+ Forcefully destroys the agent and every dispatcher it owns, aborting all pending
156
+ requests. Implements [`Dispatcher.destroy()`][].
157
+
158
+ ### `agent.connect(options[, callback])`
159
+
160
+ <!-- YAML
161
+ added: v3.2.0
162
+ -->
163
+
164
+ See [`Dispatcher.connect()`][]. The request is routed to the dispatcher for
165
+ `options.origin`.
166
+
167
+ ### `agent.pipeline(options, handler)`
26
168
 
27
- ## Instance Properties
169
+ <!-- YAML
170
+ added: v3.2.0
171
+ -->
28
172
 
29
- ### `Agent.closed`
173
+ See [`Dispatcher.pipeline()`][]. The request is routed to the dispatcher for
174
+ `options.origin`.
30
175
 
31
- Implements [Client.closed](/docs/docs/api/Client.md#clientclosed)
176
+ ### `agent.request(options[, callback])`
32
177
 
33
- ### `Agent.destroyed`
178
+ <!-- YAML
179
+ added: v3.2.0
180
+ -->
34
181
 
35
- Implements [Client.destroyed](/docs/docs/api/Client.md#clientdestroyed)
182
+ See [`Dispatcher.request()`][]. The request is routed to the dispatcher for
183
+ `options.origin`.
36
184
 
37
- ## Instance Methods
185
+ ```mjs
186
+ import { Agent } from 'undici'
38
187
 
39
- ### `Agent.close([callback])`
188
+ const agent = new Agent()
189
+ const { statusCode, body } = await agent.request({
190
+ origin: 'http://localhost:3000',
191
+ path: '/',
192
+ method: 'GET',
193
+ })
40
194
 
41
- Implements [`Dispatcher.close([callback])`](/docs/docs/api/Dispatcher.md#dispatcherclosecallback-promise).
195
+ console.log('response received', statusCode)
196
+ console.log('data', await body.text())
197
+ ```
42
198
 
43
- ### `Agent.destroy([error, callback])`
199
+ ### `agent.stream(options, factory[, callback])`
44
200
 
45
- Implements [`Dispatcher.destroy([error, callback])`](/docs/docs/api/Dispatcher.md#dispatcherdestroyerror-callback-promise).
201
+ <!-- YAML
202
+ added: v3.2.0
203
+ -->
46
204
 
47
- ### `Agent.dispatch(options, handler: AgentDispatchOptions)`
205
+ See [`Dispatcher.stream()`][]. The request is routed to the dispatcher for
206
+ `options.origin`.
48
207
 
49
- Implements [`Dispatcher.dispatch(options, handler)`](/docs/docs/api/Dispatcher.md#dispatcherdispatchoptions-handler).
208
+ ### `agent.upgrade(options[, callback])`
50
209
 
51
- #### Parameter: `AgentDispatchOptions`
210
+ <!-- YAML
211
+ added: v3.2.0
212
+ -->
52
213
 
53
- Extends: [`DispatchOptions`](/docs/docs/api/Dispatcher.md#parameter-dispatchoptions)
214
+ See [`Dispatcher.upgrade()`][]. The request is routed to the dispatcher for
215
+ `options.origin`.
54
216
 
55
- * **origin** `string | URL`
217
+ ### Event: `'connect'`
56
218
 
57
- Implements [`Dispatcher.destroy([error, callback])`](/docs/docs/api/Dispatcher.md#dispatcherdestroyerror-callback-promise).
219
+ <!-- YAML
220
+ added: v6.6.0
221
+ -->
58
222
 
59
- ### `Agent.connect(options[, callback])`
223
+ * `origin` {URL}
224
+ * `targets` {Array<Dispatcher>} The dispatchers involved, starting with this
225
+ `Agent` followed by the per-origin dispatcher chain.
60
226
 
61
- See [`Dispatcher.connect(options[, callback])`](/docs/docs/api/Dispatcher.md#dispatcherconnectoptions-callback).
227
+ Emitted when a socket has been created for an origin and is ready to receive
228
+ requests. Forwarded from the underlying dispatcher's [`'connect'`][] event.
62
229
 
63
- ### `Agent.dispatch(options, handler)`
230
+ ### Event: `'disconnect'`
64
231
 
65
- Implements [`Dispatcher.dispatch(options, handler)`](/docs/docs/api/Dispatcher.md#dispatcherdispatchoptions-handler).
232
+ <!-- YAML
233
+ added: v6.6.0
234
+ -->
66
235
 
67
- ### `Agent.pipeline(options, handler)`
236
+ * `origin` {URL}
237
+ * `targets` {Array<Dispatcher>} The dispatchers involved, starting with this
238
+ `Agent`.
239
+ * `error` {Error}
68
240
 
69
- See [`Dispatcher.pipeline(options, handler)`](/docs/docs/api/Dispatcher.md#dispatcherpipelineoptions-handler).
241
+ Emitted when a socket for an origin has disconnected. Forwarded from the
242
+ underlying dispatcher's [`'disconnect'`][] event.
70
243
 
71
- ### `Agent.request(options[, callback])`
244
+ ### Event: `'connectionError'`
72
245
 
73
- See [`Dispatcher.request(options [, callback])`](/docs/docs/api/Dispatcher.md#dispatcherrequestoptions-callback).
246
+ <!-- YAML
247
+ added: v6.6.0
248
+ -->
74
249
 
75
- ### `Agent.stream(options, factory[, callback])`
250
+ * `origin` {URL}
251
+ * `targets` {Array<Dispatcher>} The dispatchers involved, starting with this
252
+ `Agent`.
253
+ * `error` {Error}
76
254
 
77
- See [`Dispatcher.stream(options, factory[, callback])`](/docs/docs/api/Dispatcher.md#dispatcherstreamoptions-factory-callback).
255
+ Emitted when a connection attempt for an origin fails. Forwarded from the
256
+ underlying dispatcher's [`'connectionError'`][] event.
78
257
 
79
- ### `Agent.upgrade(options[, callback])`
258
+ ### Event: `'drain'`
80
259
 
81
- See [`Dispatcher.upgrade(options[, callback])`](/docs/docs/api/Dispatcher.md#dispatcherupgradeoptions-callback).
260
+ <!-- YAML
261
+ added: v6.6.0
262
+ -->
82
263
 
83
- ### `Agent.stats()`
264
+ * `origin` {URL}
265
+ * `targets` {Array<Dispatcher>} The dispatchers involved, starting with this
266
+ `Agent`.
84
267
 
85
- Returns an object of stats by origin in the format of `Record<string, TClientStats | TPoolStats>`
268
+ Emitted when an origin's dispatcher is no longer busy and can accept more
269
+ requests. Forwarded from the underlying dispatcher's [`'drain'`][] event.
86
270
 
87
- See [`PoolStats`](/docs/docs/api/PoolStats.md) and [`ClientStats`](/docs/docs/api/ClientStats.md).
271
+ [`'connect'`]: Dispatcher.md#event-connect
272
+ [`'connectionError'`]: Dispatcher.md#event-connectionerror
273
+ [`'disconnect'`]: Dispatcher.md#event-disconnect
274
+ [`'drain'`]: Dispatcher.md#event-drain
275
+ [`Client`]: Client.md#class-client
276
+ [`ClientStats`]: ClientStats.md
277
+ [`Dispatcher.close()`]: Dispatcher.md#dispatcherclosecallback-promise
278
+ [`Dispatcher.connect()`]: Dispatcher.md#dispatcherconnectoptions-callback
279
+ [`Dispatcher.destroy()`]: Dispatcher.md#dispatcherdestroyerror-callback-promise
280
+ [`Dispatcher.dispatch()`]: Dispatcher.md#dispatcherdispatchoptions-handler
281
+ [`Dispatcher.pipeline()`]: Dispatcher.md#dispatcherpipelineoptions-handler
282
+ [`Dispatcher.request()`]: Dispatcher.md#dispatcherrequestoptions-callback
283
+ [`Dispatcher.stream()`]: Dispatcher.md#dispatcherstreamoptions-factory-callback
284
+ [`Dispatcher.upgrade()`]: Dispatcher.md#dispatcherupgradeoptions-callback
285
+ [`Pool`]: Pool.md#class-pool
286
+ [`PoolStats`]: PoolStats.md
287
+ [`agent.close()`]: #agentclosecallback
288
+ [`agent.destroy()`]: #agentdestroyerror-callback
289
+ [`fetch`]: Fetch.md
290
+ [`request`]: Dispatcher.md#dispatcherrequestoptions-callback
291
+ [`stream`]: Dispatcher.md#dispatcherstreamoptions-factory-callback