@blockrun/clawrouter 0.12.239 → 0.12.241

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.
package/dist/cli.js CHANGED
@@ -34773,8 +34773,8 @@ var init_config = __esm({
34773
34773
  // FREE — smaller, faster
34774
34774
  "free/deepseek-v4-flash",
34775
34775
  // FREE — 1M ctx; slow (~10 tok/s, 07-28 probe) but completes
34776
- "free/seed-oss-36b",
34777
- // FREE — live coder (qwen3.5-122b + qwen3-next died 2026-07; mistral-large-3-675b EOL'd 07-28)
34776
+ // seed-oss-36b sat here as the free coder until it EOL'd 2026-08-03 (HTTP 410).
34777
+ // gpt-oss-120b/20b already head this chain, so the rung is dropped, not retargeted.
34778
34778
  "google/gemini-3.1-flash-lite",
34779
34779
  // $0.25/$1.50 — newest flash-lite
34780
34780
  "openai/gpt-5.4-nano",
@@ -34891,8 +34891,8 @@ var init_config = __esm({
34891
34891
  "openai/gpt-5.3-codex",
34892
34892
  "deepseek/deepseek-chat",
34893
34893
  // Cheap, reliable
34894
- "free/seed-oss-36b"
34895
- // NVIDIA free ultimate backstop (qwen3-coder-480b retired)
34894
+ "free/gpt-oss-120b"
34895
+ // NVIDIA free ultimate backstop (was seed-oss-36b; EOL'd 2026-08-03)
34896
34896
  ]
34897
34897
  },
34898
34898
  REASONING: {
@@ -34981,8 +34981,8 @@ var init_config = __esm({
34981
34981
  // Previous flagship — 6,213ms, reliable
34982
34982
  "deepseek/deepseek-chat",
34983
34983
  // 1,431ms — cheap, reliable
34984
- "free/seed-oss-36b"
34985
- // NVIDIA free ultimate backstop (qwen3-coder-480b retired)
34984
+ "free/gpt-oss-120b"
34985
+ // NVIDIA free ultimate backstop (was seed-oss-36b; EOL'd 2026-08-03)
34986
34986
  ]
34987
34987
  },
34988
34988
  REASONING: {
@@ -35090,7 +35090,6 @@ var init_top_models = __esm({
35090
35090
  "deepseek/deepseek-chat",
35091
35091
  "deepseek/deepseek-reasoner",
35092
35092
  "free/deepseek-v4-flash",
35093
- "free/seed-oss-36b",
35094
35093
  "free/nemotron-3-nano-omni-30b-a3b-reasoning",
35095
35094
  "free/mistral-nemotron",
35096
35095
  "free/step-3.7-flash",
@@ -35400,9 +35399,10 @@ var init_models = __esm({
35400
35399
  "free/deepseek-v4-pro": "free/deepseek-v4-flash",
35401
35400
  "nvidia/deepseek-v4-flash": "free/deepseek-v4-flash",
35402
35401
  "nvidia/nemotron-3-nano-omni-30b-a3b-reasoning": "free/nemotron-3-nano-omni-30b-a3b-reasoning",
35403
- // qwen3-coder-480b retired (NVIDIA EOL 2026-06-14) → redirects to seed-oss-36b
35404
- // server-side; keep the explicit id mappings for pinned callers (BlockRun still
35405
- // resolves them), but point the generic coding shorthands at the live successor.
35402
+ // qwen3-coder-480b retired (NVIDIA EOL 2026-06-14). Its server-side redirect used
35403
+ // to be seed-oss-36b, but that EOL'd too on 2026-08-03, so blockrun re-pointed it
35404
+ // at gpt-oss-120b. Keep the explicit id mappings for pinned callers (BlockRun still
35405
+ // resolves them); the generic coding shorthands follow the gateway to gpt-oss-120b.
35406
35406
  "nvidia/qwen3-coder-480b": "free/qwen3-coder-480b",
35407
35407
  "qwen/qwen3-coder-480b-a35b-instruct": "free/qwen3-coder-480b",
35408
35408
  // glm-4.7 pin keeps the real id — blockrun redirects it server-side (→ gpt-oss-120b).
@@ -35448,13 +35448,14 @@ var init_models = __esm({
35448
35448
  "v4-flash": "free/deepseek-v4-flash",
35449
35449
  "mistral-free": "free/mistral-nemotron",
35450
35450
  // mistral-large-3-675b EOL'd 2026-07-28 → last live free Mistral (blockrun demoted its /free-mistral primary the same way)
35451
- "glm-free": "free/seed-oss-36b",
35452
- // qwen3-coder retired → live coder successor
35451
+ "glm-free": "free/gpt-oss-120b",
35452
+ // seed-oss-36b (the prior target) EOL'd 2026-08-03
35453
35453
  "llama-free": "free/gpt-oss-120b",
35454
35454
  // no live free Llama left (maverick died 2026-07)
35455
- "qwen-coder": "free/seed-oss-36b",
35456
- // qwen3-coder-480b retired → seed-oss-36b
35457
- "qwen-coder-free": "free/seed-oss-36b",
35455
+ // qwen3-coder-480b retired 2026-06-14 → seed-oss-36b, which then EOL'd 2026-08-03.
35456
+ // Follow the gateway's own retarget rather than chaining to a second dead model.
35457
+ "qwen-coder": "free/gpt-oss-120b",
35458
+ "qwen-coder-free": "free/gpt-oss-120b",
35458
35459
  "qwen-thinking": "free/gpt-oss-120b",
35459
35460
  // qwen3-next died 2026-07-17; no live free Qwen left
35460
35461
  "qwen3-next": "free/qwen3-next-80b-a3b-instruct",
@@ -35463,9 +35464,11 @@ var init_models = __esm({
35463
35464
  "mistral-small": "free/mistral-nemotron",
35464
35465
  // closest live Mistral-family free model
35465
35466
  // New live free models (2026-06-14 BlockRun free-tier refresh)
35467
+ // seed-oss pins name the model itself — kept routable, the gateway redirects them.
35466
35468
  "seed-oss": "free/seed-oss-36b",
35467
35469
  "seed-oss-36b": "free/seed-oss-36b",
35468
- "coder-free": "free/seed-oss-36b",
35470
+ "coder-free": "free/gpt-oss-120b",
35471
+ // generic "a free coder" → follows the gateway retarget
35469
35472
  "mistral-nemotron": "free/mistral-nemotron",
35470
35473
  "step-flash": "free/step-3.7-flash",
35471
35474
  "step-3.7-flash": "free/step-3.7-flash",
@@ -35486,8 +35489,9 @@ var init_models = __esm({
35486
35489
  "nemotron-super": "free/gpt-oss-120b",
35487
35490
  "nemotron-49b": "free/gpt-oss-120b",
35488
35491
  "nemotron-120b": "free/gpt-oss-120b",
35489
- devstral: "free/seed-oss-36b",
35490
- "devstral-2": "free/seed-oss-36b",
35492
+ devstral: "free/gpt-oss-120b",
35493
+ // seed-oss-36b EOL'd 2026-08-03; matches blockrun's own retarget
35494
+ "devstral-2": "free/gpt-oss-120b",
35491
35495
  maverick: "free/llama-4-maverick",
35492
35496
  // explicit-ish pin — gateway redirects
35493
35497
  free: "free/gpt-oss-120b",
@@ -36610,8 +36614,13 @@ var init_models = __esm({
36610
36614
  reasoning: true
36611
36615
  },
36612
36616
  {
36613
- // ByteDance Seed-OSS 36B: strong open-source coder, 131K context. Successor
36614
- // to the retired qwen3-coder-480b (BlockRun redirects qwen3-coder → seed-oss).
36617
+ // ByteDance Seed-OSS 36B: was the free coder, and the redirect target for the
36618
+ // retired qwen3-coder-480b. EOL'd 2026-08-03 — blockrun's probe got HTTP 410
36619
+ // Gone from NVIDIA on both passes and the prod health gate fired
36620
+ // [ALERT][free-model-dead] kind=gone the same day; upstream now hides it and
36621
+ // re-pointed its own dependents (qwen3-coder-480b, devstral-2) at gpt-oss-120b.
36622
+ // Entry kept so explicit pins stay routable; off the picker, the FREE_MODELS
36623
+ // cascade, and the router fallback chains.
36615
36624
  id: "free/seed-oss-36b",
36616
36625
  name: "[Free] Seed-OSS 36B",
36617
36626
  version: "oss-36b",
@@ -57038,6 +57047,7 @@ var require_symbols = __commonJS({
57038
57047
  kCounter: /* @__PURE__ */ Symbol("socket request counter"),
57039
57048
  kMaxResponseSize: /* @__PURE__ */ Symbol("max response size"),
57040
57049
  kHTTP2Session: /* @__PURE__ */ Symbol("http2Session"),
57050
+ kHTTP2Options: /* @__PURE__ */ Symbol("http2 options"),
57041
57051
  kHTTP2SessionState: /* @__PURE__ */ Symbol("http2Session state"),
57042
57052
  kRetryHandlerDefaultRetry: /* @__PURE__ */ Symbol("retry agent default retry"),
57043
57053
  kConstruct: /* @__PURE__ */ Symbol("constructable"),
@@ -59806,14 +59816,26 @@ var require_connect = __commonJS({
59806
59816
  } else {
59807
59817
  assert10(!httpSocket, "httpSocket can only be sent on TLS update");
59808
59818
  port = port || 80;
59809
- socket = net3.connect({
59819
+ const connectOptions = {
59810
59820
  highWaterMark: 64 * 1024,
59811
59821
  // Same as nodejs fs streams.
59812
59822
  ...options,
59813
59823
  localAddress,
59814
59824
  port,
59815
59825
  host: hostname
59816
- });
59826
+ };
59827
+ const family = net3.isIP(hostname);
59828
+ if (family !== 0 && servername && servername !== hostname) {
59829
+ connectOptions.host = servername;
59830
+ connectOptions.lookup = (_hostname, lookupOptions, cb) => {
59831
+ if (lookupOptions.all) {
59832
+ cb(null, [{ address: hostname, family }]);
59833
+ } else {
59834
+ cb(null, hostname, family);
59835
+ }
59836
+ };
59837
+ }
59838
+ socket = net3.connect(connectOptions);
59817
59839
  if (useH2c === true) {
59818
59840
  socket.alpnProtocol = "h2";
59819
59841
  }
@@ -64253,20 +64275,20 @@ var require_client_h1 = __commonJS({
64253
64275
  }
64254
64276
  function clearIdleSocketValidation(socket) {
64255
64277
  if (socket[kIdleSocketValidationTimeout]) {
64256
- clearImmediate(socket[kIdleSocketValidationTimeout]);
64278
+ clearTimeout(socket[kIdleSocketValidationTimeout]);
64257
64279
  socket[kIdleSocketValidationTimeout] = null;
64258
64280
  }
64259
64281
  socket[kIdleSocketValidation] = 0;
64260
64282
  }
64261
64283
  function scheduleIdleSocketValidation(client, socket) {
64262
64284
  socket[kIdleSocketValidation] = 1;
64263
- socket[kIdleSocketValidationTimeout] = setImmediate(() => {
64285
+ socket[kIdleSocketValidationTimeout] = setTimeout(() => {
64264
64286
  socket[kIdleSocketValidationTimeout] = null;
64265
64287
  socket[kIdleSocketValidation] = 2;
64266
64288
  if (client[kSocket] === socket && !socket.destroyed) {
64267
64289
  client[kResume]();
64268
64290
  }
64269
- });
64291
+ }, 0);
64270
64292
  socket[kIdleSocketValidationTimeout].unref?.();
64271
64293
  }
64272
64294
  function resumeH1(client) {
@@ -64790,10 +64812,7 @@ var require_client_h2 = __commonJS({
64790
64812
  kStrictContentLength,
64791
64813
  kOnError,
64792
64814
  kMaxConcurrentStreams,
64793
- kPingInterval,
64794
64815
  kHTTP2Session,
64795
- kHTTP2InitialWindowSize,
64796
- kHTTP2ConnectionWindowSize,
64797
64816
  kHostAuthority,
64798
64817
  kResume,
64799
64818
  kSize,
@@ -64805,7 +64824,8 @@ var require_client_h2 = __commonJS({
64805
64824
  kEnableConnectProtocol,
64806
64825
  kRemoteSettings,
64807
64826
  kHTTP2Stream,
64808
- kHTTP2SessionState
64827
+ kHTTP2SessionState,
64828
+ kHTTP2Options
64809
64829
  } = require_symbols();
64810
64830
  var { channels } = require_diagnostics();
64811
64831
  var kOpenStreams = /* @__PURE__ */ Symbol("open streams");
@@ -64814,6 +64834,9 @@ var require_client_h2 = __commonJS({
64814
64834
  var kRequestStreamCleanup = /* @__PURE__ */ Symbol("request stream cleanup");
64815
64835
  var kRequestStreamState = /* @__PURE__ */ Symbol("request stream state");
64816
64836
  var kReceivedGoAway = /* @__PURE__ */ Symbol("received goaway");
64837
+ var kGoAwayReplayAttempts = /* @__PURE__ */ Symbol("goaway replay attempts");
64838
+ var kRefusedStreamRetry = /* @__PURE__ */ Symbol("refused stream retry");
64839
+ var MAX_GOAWAY_REPLAY_ATTEMPTS = 1;
64817
64840
  var extractBody;
64818
64841
  var http23;
64819
64842
  try {
@@ -64911,10 +64934,15 @@ var require_client_h2 = __commonJS({
64911
64934
  client[kPendingIdx] = client[kRunningIdx];
64912
64935
  }
64913
64936
  }
64914
- function canRetryRequestAfterGoAway(request2) {
64937
+ function canReplayRequest(request2) {
64915
64938
  const { body } = request2;
64916
64939
  return body == null || util5.isBuffer(body) || util5.isBlobLike(body);
64917
64940
  }
64941
+ function registerGoAwayRefusal(request2) {
64942
+ const attempts = (request2[kGoAwayReplayAttempts] ?? 0) + 1;
64943
+ request2[kGoAwayReplayAttempts] = attempts;
64944
+ return attempts <= MAX_GOAWAY_REPLAY_ATTEMPTS;
64945
+ }
64918
64946
  function closeStream(stream4, code = NGHTTP2_REFUSED_STREAM) {
64919
64947
  if (stream4 != null && !stream4.destroyed && !stream4.closed) {
64920
64948
  try {
@@ -64926,15 +64954,30 @@ var require_client_h2 = __commonJS({
64926
64954
  function detachRequestStreamForClose(request2) {
64927
64955
  const stream4 = request2[kRequestStream];
64928
64956
  clearRequestStream(request2);
64957
+ severRequestStream(stream4);
64929
64958
  return stream4;
64930
64959
  }
64960
+ function severRequestStream(stream4) {
64961
+ if (stream4 == null || stream4[kRequestStreamState] == null) {
64962
+ return;
64963
+ }
64964
+ stream4[kRequestStreamState] = null;
64965
+ stream4.off("close", completeRequestStream);
64966
+ stream4.off("close", onUpgradeStreamClose);
64967
+ if (stream4[kHTTP2Session] != null) {
64968
+ closeStreamSession(stream4);
64969
+ }
64970
+ if (!stream4.destroyed && !stream4.closed) {
64971
+ stream4.once("error", noop2);
64972
+ }
64973
+ }
64931
64974
  function connectH2(client, socket) {
64932
64975
  client[kSocket] = socket;
64933
- const http2InitialWindowSize = client[kHTTP2InitialWindowSize];
64934
- const http2ConnectionWindowSize = client[kHTTP2ConnectionWindowSize];
64976
+ const http2InitialWindowSize = client[kHTTP2Options].sessionOptions?.initialWindowSize;
64977
+ const http2ConnectionWindowSize = client[kHTTP2Options].connectionWindowSize;
64935
64978
  const session = http23.connect(client[kUrl], {
64936
64979
  createConnection: () => socket,
64937
- peerMaxConcurrentStreams: client[kMaxConcurrentStreams],
64980
+ peerMaxConcurrentStreams: client[kHTTP2Options].maxConcurrentStreams,
64938
64981
  settings: {
64939
64982
  // TODO(metcoder95): add support for PUSH
64940
64983
  enablePush: false,
@@ -64947,13 +64990,16 @@ var require_client_h2 = __commonJS({
64947
64990
  session[kSocket] = socket;
64948
64991
  session[kHTTP2SessionState] = {
64949
64992
  idleTimeout: null,
64993
+ // Armed while the peer advertises MAX_CONCURRENT_STREAMS = 0 and we have
64994
+ // work that cannot start. See setNoStreamsTimeout.
64995
+ noStreamsTimeout: null,
64950
64996
  // Sockets start out ref'd. Session ref/unref proxies to the socket, so a
64951
64997
  // single cached flag lets us skip redundant uv ref/unref calls, provided
64952
64998
  // every ref/unref of the session or its socket goes through
64953
64999
  // refH2Session/unrefH2Session.
64954
65000
  refed: true,
64955
65001
  ping: {
64956
- interval: client[kPingInterval] === 0 ? null : setInterval(onHttp2SendPing, client[kPingInterval], session).unref()
65002
+ interval: client[kHTTP2Options].pingInterval === 0 ? null : setInterval(onHttp2SendPing, client[kHTTP2Options].pingInterval, session).unref()
64957
65003
  }
64958
65004
  };
64959
65005
  session[kReceivedGoAway] = false;
@@ -65058,8 +65104,48 @@ var require_client_h2 = __commonJS({
65058
65104
  } else {
65059
65105
  clearHttp2IdleTimeout(session);
65060
65106
  }
65107
+ if (client[kMaxConcurrentStreams] === 0 && client[kRunning] === 0 && client[kPending] > 0) {
65108
+ setNoStreamsTimeout(session);
65109
+ } else {
65110
+ clearNoStreamsTimeout(session);
65111
+ }
65112
+ }
65113
+ }
65114
+ function clearNoStreamsTimeout(session) {
65115
+ const state = session[kHTTP2SessionState];
65116
+ if (state?.noStreamsTimeout != null) {
65117
+ clearTimeout(state.noStreamsTimeout);
65118
+ state.noStreamsTimeout = null;
65061
65119
  }
65062
65120
  }
65121
+ function setNoStreamsTimeout(session) {
65122
+ const client = session[kClient];
65123
+ const state = session[kHTTP2SessionState];
65124
+ const timeout = client[kHeadersTimeout];
65125
+ if (!timeout || state.noStreamsTimeout != null) {
65126
+ return;
65127
+ }
65128
+ state.noStreamsTimeout = setTimeout(onNoStreamsTimeout, timeout, session).unref();
65129
+ }
65130
+ function onNoStreamsTimeout(session) {
65131
+ const client = session[kClient];
65132
+ const state = session[kHTTP2SessionState];
65133
+ state.noStreamsTimeout = null;
65134
+ if (client[kHTTP2Session] !== session || client[kMaxConcurrentStreams] !== 0 || client[kRunning] !== 0 || client[kPending] === 0) {
65135
+ return;
65136
+ }
65137
+ const err = new HeadersTimeoutError(
65138
+ `HTTP/2: server did not accept a new stream within ${client[kHeadersTimeout]}`
65139
+ );
65140
+ const requests = client[kQueue].splice(client[kPendingIdx]);
65141
+ for (let i = 0; i < requests.length; i++) {
65142
+ if (requests[i] != null) {
65143
+ util5.errorRequest(client, requests[i], err);
65144
+ }
65145
+ }
65146
+ session[kError] = err;
65147
+ resetHttp2Session(session, err);
65148
+ }
65063
65149
  function clearHttp2IdleTimeout(session) {
65064
65150
  const state = session[kHTTP2SessionState];
65065
65151
  if (state?.idleTimeout != null) {
@@ -65166,7 +65252,7 @@ var require_client_h2 = __commonJS({
65166
65252
  const request2 = client[kQueue][i];
65167
65253
  if (request2 != null) {
65168
65254
  streamsToClose.push(detachRequestStreamForClose(request2));
65169
- if (canRetryRequestAfterGoAway(request2)) {
65255
+ if (canReplayRequest(request2) && registerGoAwayRefusal(request2)) {
65170
65256
  retriableRequests.push(request2);
65171
65257
  } else {
65172
65258
  util5.errorRequest(client, request2, err);
@@ -65187,6 +65273,7 @@ var require_client_h2 = __commonJS({
65187
65273
  client[kHTTP2Session] = null;
65188
65274
  }
65189
65275
  clearHttp2IdleTimeout(this);
65276
+ clearNoStreamsTimeout(this);
65190
65277
  if (!this.closed && !this.destroyed) {
65191
65278
  this.close();
65192
65279
  }
@@ -65203,6 +65290,7 @@ var require_client_h2 = __commonJS({
65203
65290
  client[kHTTP2Session] = null;
65204
65291
  }
65205
65292
  clearHttp2IdleTimeout(this);
65293
+ clearNoStreamsTimeout(this);
65206
65294
  if (state.ping.interval != null) {
65207
65295
  clearInterval(state.ping.interval);
65208
65296
  state.ping.interval = null;
@@ -65278,6 +65366,12 @@ var require_client_h2 = __commonJS({
65278
65366
  releaseRequestStream(this);
65279
65367
  if (state.pendingEnd && !state.request.aborted && !state.request.completed) {
65280
65368
  state.request.onResponseEnd(state.trailers || {});
65369
+ } else if (!state.request.aborted && !state.request.completed) {
65370
+ util5.errorRequest(
65371
+ state.client,
65372
+ state.request,
65373
+ new InformationalError("HTTP/2: stream closed before the response was complete")
65374
+ );
65281
65375
  }
65282
65376
  finalizeRequest(state);
65283
65377
  closeStreamSession(this);
@@ -65677,6 +65771,20 @@ var require_client_h2 = __commonJS({
65677
65771
  state.abort(new InformationalError("HTTP/2: stream half-closed (remote)"), true);
65678
65772
  }
65679
65773
  }
65774
+ function retryRefusedStream(stream4, state) {
65775
+ const { client, request: request2 } = state;
65776
+ if (state.responseReceived || request2.aborted || request2.completed || request2[kRefusedStreamRetry] || !canReplayRequest(request2)) {
65777
+ return false;
65778
+ }
65779
+ request2[kRefusedStreamRetry] = true;
65780
+ detachRequestStreamForClose(request2);
65781
+ state.stream = null;
65782
+ state.requestFinalized = true;
65783
+ completeRequest(client, request2);
65784
+ client[kQueue].splice(client[kPendingIdx], 0, request2);
65785
+ client[kResume]();
65786
+ return true;
65787
+ }
65680
65788
  function onError(err) {
65681
65789
  const stream4 = this;
65682
65790
  const state = stream4[kRequestStreamState];
@@ -65684,6 +65792,12 @@ var require_client_h2 = __commonJS({
65684
65792
  return;
65685
65793
  }
65686
65794
  stream4.off("error", onError);
65795
+ if (typeof stream4.rstCode === "number" && stream4.rstCode !== NGHTTP2_NO_ERROR) {
65796
+ err.http2ErrorCode = stream4.rstCode;
65797
+ }
65798
+ if (stream4.rstCode === NGHTTP2_REFUSED_STREAM && retryRefusedStream(stream4, state)) {
65799
+ return;
65800
+ }
65687
65801
  state.abort(err);
65688
65802
  }
65689
65803
  function onFrameError(type, code) {
@@ -65965,10 +66079,8 @@ var require_client = __commonJS({
65965
66079
  kHTTPContext,
65966
66080
  kMaxConcurrentStreams,
65967
66081
  kHostAuthority,
65968
- kHTTP2InitialWindowSize,
65969
- kHTTP2ConnectionWindowSize,
65970
66082
  kResume,
65971
- kPingInterval
66083
+ kHTTP2Options
65972
66084
  } = require_symbols();
65973
66085
  var connectH1 = require_client_h1();
65974
66086
  var connectH2 = require_client_h2();
@@ -65981,6 +66093,14 @@ var require_client = __commonJS({
65981
66093
  function getPipelining(client) {
65982
66094
  return client[kPipelining] ?? client[kHTTPContext]?.defaultPipelining ?? 1;
65983
66095
  }
66096
+ var h2NamespaceOptsWarning = false;
66097
+ function emitH2OptionsNamespaceWarning(optName) {
66098
+ if (h2NamespaceOptsWarning === true) return;
66099
+ process.emitWarning(`Use h2Options.${optName} instead. ${optName} for H2 will be deprecated in future major.`, {
66100
+ code: "UNDICI-H2-OPTIONS"
66101
+ });
66102
+ h2NamespaceOptsWarning = true;
66103
+ }
65984
66104
  function getMaxConcurrent(client) {
65985
66105
  if (client[kHTTPContext]?.version === "h2") {
65986
66106
  return client[kMaxConcurrentStreams];
@@ -66024,7 +66144,8 @@ var require_client = __commonJS({
66024
66144
  initialWindowSize,
66025
66145
  connectionWindowSize,
66026
66146
  pingInterval,
66027
- webSocket
66147
+ webSocket,
66148
+ h2Options
66028
66149
  } = {}) {
66029
66150
  if (keepAlive !== void 0) {
66030
66151
  throw new InvalidArgumentError("unsupported keepAlive, use pipelining=0 instead");
@@ -66087,20 +66208,45 @@ var require_client = __commonJS({
66087
66208
  if (allowH2 != null && typeof allowH2 !== "boolean") {
66088
66209
  throw new InvalidArgumentError("allowH2 must be a valid boolean value");
66089
66210
  }
66090
- if (maxConcurrentStreams != null && (typeof maxConcurrentStreams !== "number" || maxConcurrentStreams < 1)) {
66091
- throw new InvalidArgumentError("maxConcurrentStreams must be a positive integer, greater than 0");
66092
- }
66093
- if (useH2c != null && typeof useH2c !== "boolean") {
66094
- throw new InvalidArgumentError("useH2c must be a valid boolean value");
66095
- }
66096
- if (initialWindowSize != null && (!Number.isInteger(initialWindowSize) || initialWindowSize < 1)) {
66097
- throw new InvalidArgumentError("initialWindowSize must be a positive integer, greater than 0");
66098
- }
66099
- if (connectionWindowSize != null && (!Number.isInteger(connectionWindowSize) || connectionWindowSize < 1)) {
66100
- throw new InvalidArgumentError("connectionWindowSize must be a positive integer, greater than 0");
66101
- }
66102
- if (pingInterval != null && (typeof pingInterval !== "number" || !Number.isInteger(pingInterval) || pingInterval < 0)) {
66103
- throw new InvalidArgumentError("pingInterval must be a positive integer, greater or equal to 0");
66211
+ if (allowH2 !== false) {
66212
+ if (h2Options != null) {
66213
+ if (h2Options.useH2c != null && typeof h2Options.useH2c !== "boolean") {
66214
+ throw new InvalidArgumentError("h2Options.useH2c must be a valid boolean value");
66215
+ }
66216
+ if (h2Options.settings?.initialWindowSize != null && (!Number.isInteger(h2Options.settings.initialWindowSize) || h2Options.settings.initialWindowSize < 1)) {
66217
+ throw new InvalidArgumentError("h2Options.settings.initialWindowSize must be a positive integer, greater than 0");
66218
+ }
66219
+ if (h2Options.maxConcurrentStreams != null && (!Number.isInteger(h2Options.connectionWindowSize) || h2Options.maxConcurrentStreams < 1)) {
66220
+ throw new InvalidArgumentError("h2Options.maxConcurrentStreams must be a positive integer, greater than 0");
66221
+ }
66222
+ if (h2Options.connectionWindowSize != null && (!Number.isInteger(h2Options.connectionWindowSize) || h2Options.connectionWindowSize < 1)) {
66223
+ throw new InvalidArgumentError("h2Options.connectionWindowSize must be a positive integer, greater than 0");
66224
+ }
66225
+ if (h2Options.pingInterval != null && (typeof h2Options.pingInterval !== "number" || !Number.isInteger(h2Options.pingInterval) || h2Options.pingInterval < 0)) {
66226
+ throw new InvalidArgumentError("h2Options.pingInterval must be a positive integer, greater or equal to 0");
66227
+ }
66228
+ } else {
66229
+ if (useH2c != null && typeof useH2c !== "boolean") {
66230
+ emitH2OptionsNamespaceWarning("useH2c");
66231
+ throw new InvalidArgumentError("useH2c must be a valid boolean value");
66232
+ }
66233
+ if (maxConcurrentStreams != null && (typeof maxConcurrentStreams !== "number" || maxConcurrentStreams < 1)) {
66234
+ emitH2OptionsNamespaceWarning("maxConcurrentStreams");
66235
+ throw new InvalidArgumentError("maxConcurrentStreams must be a positive integer, greater than 0");
66236
+ }
66237
+ if (initialWindowSize != null && (!Number.isInteger(initialWindowSize) || initialWindowSize < 1)) {
66238
+ emitH2OptionsNamespaceWarning("initialWindowSize");
66239
+ throw new InvalidArgumentError("initialWindowSize must be a positive integer, greater than 0");
66240
+ }
66241
+ if (connectionWindowSize != null && (!Number.isInteger(connectionWindowSize) || connectionWindowSize < 1)) {
66242
+ emitH2OptionsNamespaceWarning("connectionWindowSize");
66243
+ throw new InvalidArgumentError("connectionWindowSize must be a positive integer, greater than 0");
66244
+ }
66245
+ if (pingInterval != null && (typeof pingInterval !== "number" || !Number.isInteger(pingInterval) || pingInterval < 0)) {
66246
+ emitH2OptionsNamespaceWarning("pingInterval");
66247
+ throw new InvalidArgumentError("pingInterval must be a positive integer, greater or equal to 0");
66248
+ }
66249
+ }
66104
66250
  }
66105
66251
  super({ webSocket });
66106
66252
  if (typeof connect4 !== "function") {
@@ -66108,8 +66254,8 @@ var require_client = __commonJS({
66108
66254
  ...tls2,
66109
66255
  maxCachedSessions,
66110
66256
  allowH2,
66111
- useH2c,
66112
66257
  socketPath,
66258
+ useH2c: h2Options?.useH2c ?? useH2c,
66113
66259
  timeout: connectTimeout,
66114
66260
  ...typeof autoSelectFamily === "boolean" ? { autoSelectFamily, autoSelectFamilyAttemptTimeout } : void 0,
66115
66261
  ...connect4
@@ -66144,10 +66290,21 @@ var require_client = __commonJS({
66144
66290
  this[kClosedResolve] = null;
66145
66291
  this[kMaxResponseSize] = maxResponseSize > -1 ? maxResponseSize : -1;
66146
66292
  this[kHTTPContext] = null;
66147
- this[kMaxConcurrentStreams] = maxConcurrentStreams != null ? maxConcurrentStreams : 100;
66148
- this[kHTTP2InitialWindowSize] = initialWindowSize != null ? initialWindowSize : 262144;
66149
- this[kHTTP2ConnectionWindowSize] = connectionWindowSize != null ? connectionWindowSize : 524288;
66150
- this[kPingInterval] = pingInterval != null ? pingInterval : 6e4;
66293
+ this[kHTTP2Options] = {
66294
+ pingInterval: h2Options?.pingInterval ?? pingInterval ?? 6e4,
66295
+ connectionWindowSize: h2Options?.connectionWindowSize ?? connectionWindowSize ?? 524288,
66296
+ maxConcurrentStreams: h2Options?.maxConcurrentStreams ?? maxConcurrentStreams ?? 100,
66297
+ // Max peerConcurrentStreams for a Node h2 server
66298
+ sessionOptions: {
66299
+ // HTTP/2 window sizes are set to higher defaults than Node.js core for better performance:
66300
+ // - initialWindowSize: 262144 (256KB) vs Node.js default 65535 (64KB - 1)
66301
+ // Allows more data to be sent before requiring acknowledgment, improving throughput
66302
+ // especially on high-latency networks. This matches common production HTTP/2 servers.
66303
+ // - connectionWindowSize: 524288 (512KB) vs Node.js default (none set)
66304
+ // Provides better flow control for the entire connection across multiple streams.
66305
+ initialWindowSize: h2Options?.initialWindowSize ?? initialWindowSize ?? 262144
66306
+ }
66307
+ };
66151
66308
  this[kQueue] = [];
66152
66309
  this[kRunningIdx] = 0;
66153
66310
  this[kPendingIdx] = 0;
@@ -66432,6 +66589,7 @@ var require_client = __commonJS({
66432
66589
  return;
66433
66590
  }
66434
66591
  if (!client[kHTTPContext]) {
66592
+ client[kServerName] = request2.servername;
66435
66593
  connect3(client);
66436
66594
  return;
66437
66595
  }
@@ -67842,7 +68000,7 @@ var require_socks5_proxy_agent = __commonJS({
67842
68000
  var DispatcherBase = require_dispatcher_base();
67843
68001
  var { InvalidArgumentError } = require_errors();
67844
68002
  var { Socks5Client, STATES } = require_socks5_client();
67845
- var { kDispatch, kClose, kDestroy } = require_symbols();
68003
+ var { kBusy, kConnected, kDispatch, kClose, kDestroy } = require_symbols();
67846
68004
  var Pool = require_pool();
67847
68005
  var buildConnector = require_connect();
67848
68006
  var { debuglog } = __require("util");
@@ -68000,6 +68158,17 @@ var require_socks5_proxy_agent = __commonJS({
68000
68158
  }
68001
68159
  });
68002
68160
  this[kPools].set(originKey, pool);
68161
+ const closePoolIfUnused = () => {
68162
+ if (this[kPools].get(originKey) !== pool || pool[kConnected] > 0 || pool[kBusy]) {
68163
+ return;
68164
+ }
68165
+ this[kPools].delete(originKey);
68166
+ if (!pool.destroyed) {
68167
+ pool.close();
68168
+ }
68169
+ };
68170
+ pool.on("disconnect", closePoolIfUnused);
68171
+ pool.on("connectionError", closePoolIfUnused);
68003
68172
  }
68004
68173
  return pool[kDispatch](opts, handler);
68005
68174
  } catch (err) {
@@ -68384,7 +68553,7 @@ var require_env_http_proxy_agent = __commonJS({
68384
68553
  }
68385
68554
  #getProxyAgentForUrl(url2) {
68386
68555
  let { protocol, host: hostname, port } = url2;
68387
- hostname = hostname.replace(/:\d*$/, "").toLowerCase();
68556
+ hostname = hostname.replace(/:\d*$/, "").replace(/^\[(.+)\]$/, "$1").toLowerCase();
68388
68557
  port = Number.parseInt(port, 10) || DEFAULT_PORTS3[protocol] || 0;
68389
68558
  if (!this.#shouldProxy(hostname, port)) {
68390
68559
  return this[kNoProxyAgent];
@@ -68427,11 +68596,22 @@ var require_env_http_proxy_agent = __commonJS({
68427
68596
  if (!entry) {
68428
68597
  continue;
68429
68598
  }
68430
- const parsed = entry.match(/^(.+):(\d+)$/);
68599
+ let hostname, port;
68600
+ const ipv6WithPort = entry.match(/^\[(.+)\]:(\d+)$/);
68601
+ if (ipv6WithPort) {
68602
+ hostname = ipv6WithPort[1];
68603
+ port = Number.parseInt(ipv6WithPort[2], 10);
68604
+ } else {
68605
+ const unbracketed = entry.replace(/^\[(.+)\]$/, "$1");
68606
+ const colonCount = (unbracketed.match(/:/g) || []).length;
68607
+ const parsed = colonCount === 1 && unbracketed.match(/^(.+):(\d+)$/);
68608
+ hostname = parsed ? parsed[1] : unbracketed;
68609
+ port = parsed ? Number.parseInt(parsed[2], 10) : 0;
68610
+ }
68431
68611
  noProxyEntries.push({
68432
68612
  // strip leading dot or asterisk with dot
68433
- hostname: (parsed ? parsed[1] : entry).replace(/^\*?\./, "").toLowerCase(),
68434
- port: parsed ? Number.parseInt(parsed[2], 10) : 0
68613
+ hostname: hostname.replace(/^\*?\./, "").toLowerCase(),
68614
+ port
68435
68615
  });
68436
68616
  }
68437
68617
  this.#noProxyValue = noProxyValue;
@@ -68653,6 +68833,10 @@ var require_retry_handler = __commonJS({
68653
68833
  setTimeout(() => cb(null), retryTimeout);
68654
68834
  }
68655
68835
  onResponseStart(controller, statusCode, headers, statusMessage) {
68836
+ if (statusCode < 200) {
68837
+ this.handler.onResponseStart?.(this.controllerProxy, statusCode, headers, statusMessage);
68838
+ return;
68839
+ }
68656
68840
  this.error = null;
68657
68841
  this.retryCount += 1;
68658
68842
  this.statusCode = statusCode;
@@ -68696,7 +68880,7 @@ var require_retry_handler = __commonJS({
68696
68880
  if (this.end == null) {
68697
68881
  if (statusCode === 206) {
68698
68882
  const range = parseRangeHeader(headers["content-range"]);
68699
- if (range == null) {
68883
+ if (range == null || range.end == null) {
68700
68884
  this.headersSent = true;
68701
68885
  this.handler.onResponseStart?.(
68702
68886
  this.controllerProxy,
@@ -68716,7 +68900,7 @@ var require_retry_handler = __commonJS({
68716
68900
  this.start = start;
68717
68901
  this.end = end;
68718
68902
  }
68719
- if (this.end == null) {
68903
+ if (this.end == null && this.opts.method !== "HEAD") {
68720
68904
  const contentLength = headers["content-length"];
68721
68905
  this.end = contentLength != null ? Number(contentLength) - 1 : null;
68722
68906
  }
@@ -68917,7 +69101,6 @@ var require_readable = __commonJS({
68917
69101
  var kContentLength = /* @__PURE__ */ Symbol("kContentLength");
68918
69102
  var kUsed = /* @__PURE__ */ Symbol("kUsed");
68919
69103
  var kBytesRead = /* @__PURE__ */ Symbol("kBytesRead");
68920
- var kPreservedBuffer = /* @__PURE__ */ Symbol("kPreservedBuffer");
68921
69104
  var noop2 = () => {
68922
69105
  };
68923
69106
  var BodyReadable = class extends Readable2 {
@@ -69156,21 +69339,6 @@ var require_readable = __commonJS({
69156
69339
  */
69157
69340
  setEncoding(encoding) {
69158
69341
  if (Buffer.isEncoding(encoding)) {
69159
- const state = this._readableState;
69160
- const buffer2 = state.buffer;
69161
- if (buffer2 && state.length > 0) {
69162
- const bufferIndex = state.bufferIndex ?? 0;
69163
- const preserved = [];
69164
- const source = typeof buffer2.slice === "function" ? buffer2.slice(bufferIndex) : buffer2;
69165
- for (const data of source) {
69166
- if (Buffer.isBuffer(data)) {
69167
- preserved.push(data);
69168
- }
69169
- }
69170
- if (preserved.length > 0) {
69171
- this[kPreservedBuffer] = (this[kPreservedBuffer] || []).concat(preserved);
69172
- }
69173
- }
69174
69342
  super.setEncoding(encoding);
69175
69343
  }
69176
69344
  return this;
@@ -69221,13 +69389,7 @@ var require_readable = __commonJS({
69221
69389
  return;
69222
69390
  }
69223
69391
  const { _readableState: state } = consume2.stream;
69224
- const preserved = consume2.stream[kPreservedBuffer];
69225
- if (preserved && preserved.length > 0) {
69226
- for (const chunk of preserved) {
69227
- consumePush(consume2, chunk);
69228
- }
69229
- consume2.stream[kPreservedBuffer] = null;
69230
- } else if (state.bufferIndex) {
69392
+ if (state.bufferIndex) {
69231
69393
  const start = state.bufferIndex;
69232
69394
  const end = state.buffer.length;
69233
69395
  for (let n = start; n < end; n++) {
@@ -69238,13 +69400,17 @@ var require_readable = __commonJS({
69238
69400
  consumePush(consume2, chunk);
69239
69401
  }
69240
69402
  }
69403
+ const decoder2 = state.decoder;
69404
+ if (decoder2 != null && decoder2.lastNeed > 0) {
69405
+ consumePush(consume2, Buffer.from(decoder2.lastChar.subarray(0, decoder2.lastTotal - decoder2.lastNeed)));
69406
+ }
69241
69407
  if (state.endEmitted) {
69242
- consumeEnd(this[kConsume], this._readableState.encoding);
69243
- } else {
69244
- consume2.stream.on("end", function() {
69245
- consumeEnd(this[kConsume], this._readableState.encoding);
69246
- });
69408
+ consumeEnd(consume2, state.encoding);
69409
+ return;
69247
69410
  }
69411
+ consume2.stream.on("end", function() {
69412
+ consumeEnd(this[kConsume], this._readableState.encoding);
69413
+ });
69248
69414
  consume2.stream.resume();
69249
69415
  while (consume2.stream.read() != null) {
69250
69416
  }
@@ -69301,6 +69467,9 @@ var require_readable = __commonJS({
69301
69467
  if (consume2.body === null) {
69302
69468
  return;
69303
69469
  }
69470
+ if (typeof chunk === "string") {
69471
+ chunk = Buffer.from(chunk, consume2.stream._readableState.encoding);
69472
+ }
69304
69473
  consume2.length += chunk.length;
69305
69474
  consume2.body.push(chunk);
69306
69475
  }
@@ -70285,6 +70454,7 @@ var require_mock_utils = __commonJS({
70285
70454
  }
70286
70455
  } = __require("util");
70287
70456
  var { InvalidArgumentError } = require_errors();
70457
+ var requestAborted = /* @__PURE__ */ Symbol("request aborted");
70288
70458
  function matchValue(match, value) {
70289
70459
  if (typeof match === "string") {
70290
70460
  return match === value;
@@ -70397,6 +70567,8 @@ var require_mock_utils = __commonJS({
70397
70567
  return data;
70398
70568
  } else if (data instanceof ArrayBuffer) {
70399
70569
  return data;
70570
+ } else if (ArrayBuffer.isView(data)) {
70571
+ return new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
70400
70572
  } else if (typeof data === "object") {
70401
70573
  return JSON.stringify(data);
70402
70574
  } else if (data) {
@@ -70450,6 +70622,9 @@ var require_mock_utils = __commonJS({
70450
70622
  }
70451
70623
  }
70452
70624
  function removeTrailingSlash(path6) {
70625
+ if (typeof path6 !== "string") {
70626
+ return path6;
70627
+ }
70453
70628
  while (path6.endsWith("/")) {
70454
70629
  path6 = path6.slice(0, -1);
70455
70630
  }
@@ -70503,30 +70678,38 @@ var require_mock_utils = __commonJS({
70503
70678
  const { timesInvoked, times } = mockDispatch2;
70504
70679
  mockDispatch2.consumed = !mockDispatch2.persist && timesInvoked >= times;
70505
70680
  mockDispatch2.pending = timesInvoked < times;
70506
- if (mockDispatch2.data.callback) {
70507
- const callbackResult = mockDispatch2.data.callback(opts);
70681
+ const hasBodyHooks = typeof handler.onBodySent === "function" || typeof handler.onRequestSent === "function";
70682
+ if (mockDispatch2.data.callback && (!hasBodyHooks || opts.body == null)) {
70683
+ const { callback, ...responseDefaults } = mockDispatch2.data;
70684
+ const callbackResult = callback(opts);
70508
70685
  if (isPromise(callbackResult)) {
70509
70686
  callbackResult.then(
70510
70687
  (resolvedData) => {
70511
- mockDispatch2.data = { ...mockDispatch2.data, ...resolvedData };
70688
+ if (resolvedData == null || typeof resolvedData !== "object") {
70689
+ handler.onResponseError(null, new InvalidArgumentError("reply options callback must return an object"));
70690
+ return;
70691
+ }
70692
+ mockDispatch2.data = { ...responseDefaults, ...resolvedData };
70512
70693
  dispatchMockReply(mockDispatches, mockDispatch2, key2, opts, handler);
70513
70694
  },
70514
70695
  (error) => {
70515
- deleteMockDispatch(mockDispatches, key2);
70516
70696
  handler.onResponseError(null, error);
70517
70697
  }
70518
70698
  );
70519
70699
  return true;
70520
70700
  }
70521
- mockDispatch2.data = { ...mockDispatch2.data, ...callbackResult };
70701
+ if (callbackResult == null || typeof callbackResult !== "object") {
70702
+ throw new InvalidArgumentError("reply options callback must return an object");
70703
+ }
70704
+ mockDispatch2.data = { ...responseDefaults, ...callbackResult };
70522
70705
  }
70523
70706
  return dispatchMockReply(mockDispatches, mockDispatch2, key2, opts, handler);
70524
70707
  }
70525
70708
  function dispatchMockReply(mockDispatches, mockDispatch2, key2, opts, handler) {
70526
- const { data: { statusCode, data, headers, trailers, error }, delay } = mockDispatch2;
70527
- if (error !== null) {
70709
+ const { data: response, delay } = mockDispatch2;
70710
+ if (response.error !== null) {
70528
70711
  deleteMockDispatch(mockDispatches, key2);
70529
- handler.onResponseError(null, error);
70712
+ handler.onResponseError(null, response.error);
70530
70713
  return true;
70531
70714
  }
70532
70715
  let aborted = false;
@@ -70553,30 +70736,91 @@ var require_mock_utils = __commonJS({
70553
70736
  handler.onResponseError?.(controller, reason);
70554
70737
  }
70555
70738
  };
70739
+ let replyOpts = opts;
70740
+ const dispatches = mockDispatches;
70556
70741
  handler.onRequestStart?.(controller, null);
70557
- if (typeof delay === "number" && delay > 0) {
70558
- timer2 = setTimeout(() => {
70559
- timer2 = null;
70560
- handleReply(mockDispatches);
70561
- }, delay);
70562
- } else {
70563
- handleReply(mockDispatches);
70742
+ if (aborted) {
70743
+ return true;
70744
+ }
70745
+ const requestBody = dispatchRequestBody(opts.body, handler, controller, () => aborted);
70746
+ if (isPromise(requestBody)) {
70747
+ requestBody.then((body) => {
70748
+ if (body === requestAborted) {
70749
+ return;
70750
+ }
70751
+ if (body !== opts.body) {
70752
+ replyOpts = { ...opts, body };
70753
+ }
70754
+ sendReply();
70755
+ }, (error) => controller.abort(error));
70756
+ return true;
70757
+ }
70758
+ if (requestBody === requestAborted) {
70759
+ return true;
70760
+ }
70761
+ if (requestBody !== opts.body) {
70762
+ replyOpts = { ...opts, body: requestBody };
70763
+ }
70764
+ sendReply();
70765
+ function sendReply() {
70766
+ if (response.callback) {
70767
+ const { callback, ...responseDefaults } = response;
70768
+ let callbackResult;
70769
+ try {
70770
+ callbackResult = callback(replyOpts);
70771
+ } catch (err) {
70772
+ deleteMockDispatch(mockDispatches, key2);
70773
+ handler.onResponseError(null, err);
70774
+ return;
70775
+ }
70776
+ if (isPromise(callbackResult)) {
70777
+ callbackResult.then(
70778
+ (resolvedData) => {
70779
+ if (resolvedData == null || typeof resolvedData !== "object") {
70780
+ handler.onResponseError(null, new InvalidArgumentError("reply options callback must return an object"));
70781
+ return;
70782
+ }
70783
+ mockDispatch2.data = { ...responseDefaults, ...resolvedData };
70784
+ handleReply(dispatches, mockDispatch2.data);
70785
+ },
70786
+ (err) => {
70787
+ handler.onResponseError(null, err);
70788
+ }
70789
+ );
70790
+ return;
70791
+ }
70792
+ if (callbackResult == null || typeof callbackResult !== "object") {
70793
+ throw new InvalidArgumentError("reply options callback must return an object");
70794
+ }
70795
+ mockDispatch2.data = { ...responseDefaults, ...callbackResult };
70796
+ handleReply(dispatches, mockDispatch2.data);
70797
+ return;
70798
+ }
70799
+ if (typeof delay === "number" && delay > 0) {
70800
+ timer2 = setTimeout(() => {
70801
+ timer2 = null;
70802
+ handleReply(dispatches);
70803
+ }, delay);
70804
+ } else {
70805
+ handleReply(dispatches);
70806
+ }
70564
70807
  }
70565
- function handleReply(mockDispatches2, _data = data) {
70808
+ function handleReply(mockDispatches2, _response = response) {
70566
70809
  if (aborted) {
70567
70810
  return;
70568
70811
  }
70812
+ const { statusCode, data, headers, trailers } = _response;
70569
70813
  const optsHeaders = Array.isArray(opts.headers) ? buildHeadersFromArray(opts.headers) : opts.headers;
70570
- const body = typeof _data === "function" ? _data({ ...opts, headers: optsHeaders }) : _data;
70814
+ const body = typeof data === "function" ? data({ ...replyOpts, headers: optsHeaders }) : data;
70571
70815
  if (isPromise(body)) {
70572
- return body.then((newData) => handleReply(mockDispatches2, newData));
70816
+ return body.then((newData) => handleReply(mockDispatches2, { ..._response, data: newData }));
70573
70817
  }
70574
70818
  if (aborted) {
70575
70819
  return;
70576
70820
  }
70577
70821
  const responseData = getResponseData(body);
70578
- const responseHeaders = generateKeyValues(headers);
70579
- const responseTrailers = generateKeyValues(trailers);
70822
+ const responseHeaders = generateKeyValues(headers ?? {});
70823
+ const responseTrailers = generateKeyValues(trailers ?? {});
70580
70824
  controller.rawHeaders = responseHeaders;
70581
70825
  controller.rawTrailers = responseTrailers;
70582
70826
  handler.onResponseStart?.(controller, statusCode, parseHeaders(responseHeaders), getStatusText(statusCode));
@@ -70586,6 +70830,78 @@ var require_mock_utils = __commonJS({
70586
70830
  }
70587
70831
  return true;
70588
70832
  }
70833
+ function dispatchRequestBody(body, handler, controller, isAborted2) {
70834
+ if (typeof handler.onBodySent !== "function" && typeof handler.onRequestSent !== "function") {
70835
+ return body;
70836
+ }
70837
+ if (body == null) {
70838
+ return callOnRequestSent(handler, controller, isAborted2) ? body : requestAborted;
70839
+ }
70840
+ if (body && typeof body[Symbol.asyncIterator] === "function") {
70841
+ return dispatchAsyncIterableBody(body, handler, controller, isAborted2);
70842
+ }
70843
+ if (isIterableBody(body)) {
70844
+ const chunks = [];
70845
+ for (const chunk of body) {
70846
+ if (isAborted2()) {
70847
+ return requestAborted;
70848
+ }
70849
+ chunks.push(chunk);
70850
+ if (!callOnBodySent(handler, controller, chunk) || isAborted2()) {
70851
+ return requestAborted;
70852
+ }
70853
+ }
70854
+ return callOnRequestSent(handler, controller, isAborted2) ? chunks : requestAborted;
70855
+ }
70856
+ if (isAborted2()) {
70857
+ return requestAborted;
70858
+ }
70859
+ if (!callOnBodySent(handler, controller, body)) {
70860
+ return requestAborted;
70861
+ }
70862
+ return callOnRequestSent(handler, controller, isAborted2) ? body : requestAborted;
70863
+ }
70864
+ async function dispatchAsyncIterableBody(body, handler, controller, isAborted2) {
70865
+ const chunks = [];
70866
+ for await (const chunk of body) {
70867
+ if (isAborted2()) {
70868
+ return requestAborted;
70869
+ }
70870
+ chunks.push(chunk);
70871
+ if (!callOnBodySent(handler, controller, chunk) || isAborted2()) {
70872
+ return requestAborted;
70873
+ }
70874
+ }
70875
+ if (!callOnRequestSent(handler, controller, isAborted2)) {
70876
+ return requestAborted;
70877
+ }
70878
+ return {
70879
+ async *[Symbol.asyncIterator]() {
70880
+ yield* chunks;
70881
+ }
70882
+ };
70883
+ }
70884
+ function callOnBodySent(handler, controller, chunk) {
70885
+ try {
70886
+ handler.onBodySent?.(chunk);
70887
+ return true;
70888
+ } catch (error) {
70889
+ controller.abort(error);
70890
+ return false;
70891
+ }
70892
+ }
70893
+ function callOnRequestSent(handler, controller, isAborted2) {
70894
+ try {
70895
+ handler.onRequestSent?.();
70896
+ return !isAborted2();
70897
+ } catch (error) {
70898
+ controller.abort(error);
70899
+ return false;
70900
+ }
70901
+ }
70902
+ function isIterableBody(body) {
70903
+ return typeof body !== "string" && !Buffer.isBuffer(body) && !ArrayBuffer.isView(body) && typeof body[Symbol.iterator] === "function";
70904
+ }
70589
70905
  function buildMockDispatch() {
70590
70906
  const agent = this[kMockAgent];
70591
70907
  const origin2 = this[kOrigin];
@@ -73229,15 +73545,13 @@ var require_cache = __commonJS({
73229
73545
  }
73230
73546
  }
73231
73547
  function makeCacheKey(opts) {
73232
- if (!opts.origin) {
73233
- throw new Error("opts.origin is undefined");
73234
- }
73548
+ const origin2 = opts.origin ? opts.origin.toString() : "";
73235
73549
  let fullPath = opts.path || "/";
73236
73550
  if (opts.query && !pathHasQueryOrFragment(fullPath)) {
73237
73551
  fullPath = serializePathWithQuery(fullPath, opts.query);
73238
73552
  }
73239
73553
  return {
73240
- origin: opts.origin.toString(),
73554
+ origin: origin2,
73241
73555
  method: opts.method,
73242
73556
  path: fullPath,
73243
73557
  headers: opts.headers
@@ -75320,10 +75634,13 @@ var require_cache2 = __commonJS({
75320
75634
  }
75321
75635
  return (dispatch) => {
75322
75636
  return (opts2, handler) => {
75323
- if (!opts2.origin || arrayIncludes(safeMethodsToNotCache, opts2.method)) {
75637
+ if (arrayIncludes(safeMethodsToNotCache, opts2.method)) {
75324
75638
  return dispatch(opts2, handler);
75325
75639
  }
75326
75640
  if (origins !== void 0) {
75641
+ if (!opts2.origin) {
75642
+ return dispatch(opts2, handler);
75643
+ }
75327
75644
  const requestOrigin = opts2.origin.toString().toLowerCase();
75328
75645
  let isAllowed = false;
75329
75646
  for (let i = 0; i < origins.length; i++) {
@@ -76021,7 +76338,7 @@ var require_deduplicate = __commonJS({
76021
76338
  const pendingRequests = /* @__PURE__ */ new Map();
76022
76339
  return (dispatch) => {
76023
76340
  return (opts2, handler) => {
76024
- if (!opts2.origin || methods.includes(opts2.method) === false) {
76341
+ if (opts2.upgrade || methods.includes(opts2.method) === false) {
76025
76342
  return dispatch(opts2, handler);
76026
76343
  }
76027
76344
  opts2 = {
@@ -81871,6 +82188,8 @@ var require_websocket2 = __commonJS({
81871
82188
  var { SendQueue } = require_sender2();
81872
82189
  var { WebsocketFrameSend } = require_frame();
81873
82190
  var { channels } = require_diagnostics();
82191
+ var kRef = /* @__PURE__ */ Symbol.for("nodejs.ref");
82192
+ var kUnref = /* @__PURE__ */ Symbol.for("nodejs.unref");
81874
82193
  function getSocketAddress(socket) {
81875
82194
  if (typeof socket?.address === "function") {
81876
82195
  return socket.address();
@@ -81890,6 +82209,7 @@ var require_websocket2 = __commonJS({
81890
82209
  #bufferedAmount = 0;
81891
82210
  #protocol = "";
81892
82211
  #extensions = "";
82212
+ #refed = true;
81893
82213
  /** @type {SendQueue} */
81894
82214
  #sendQueue;
81895
82215
  /** @type {Handler} */
@@ -81972,6 +82292,16 @@ var require_websocket2 = __commonJS({
81972
82292
  this.#handler.readyState = _WebSocket.CONNECTING;
81973
82293
  this.#binaryType = "blob";
81974
82294
  }
82295
+ [kRef]() {
82296
+ webidl.brandCheck(this, _WebSocket);
82297
+ this.#refed = true;
82298
+ this.#handler.socket?.ref?.();
82299
+ }
82300
+ [kUnref]() {
82301
+ webidl.brandCheck(this, _WebSocket);
82302
+ this.#refed = false;
82303
+ this.#handler.socket?.unref?.();
82304
+ }
81975
82305
  /**
81976
82306
  * @see https://websockets.spec.whatwg.org/#dom-websocket-close
81977
82307
  * @param {number|undefined} code
@@ -82133,6 +82463,9 @@ var require_websocket2 = __commonJS({
82133
82463
  */
82134
82464
  #onConnectionEstablished(response, parsedExtensions) {
82135
82465
  this.#handler.socket = response.socket;
82466
+ if (!this.#refed) {
82467
+ this.#handler.socket.unref?.();
82468
+ }
82136
82469
  const maxFragments = this.#handler.controller.dispatcher?.webSocketOptions?.maxFragments;
82137
82470
  const maxPayloadSize = this.#handler.controller.dispatcher?.webSocketOptions?.maxPayloadSize;
82138
82471
  const parser = new ByteParser(this.#handler, parsedExtensions, {
@@ -89892,8 +90225,6 @@ var init_proxy = __esm({
89892
90225
  "free/gpt-oss-20b",
89893
90226
  "free/deepseek-v4-flash",
89894
90227
  // 1M ctx; slow (~10 tok/s, 07-28 probe) but completes
89895
- "free/seed-oss-36b",
89896
- // live coder (successor to retired qwen3-coder-480b)
89897
90228
  "free/mistral-nemotron",
89898
90229
  // strong instruction following
89899
90230
  "free/step-3.7-flash",