@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/README.md +16 -17
- package/dist/cli.js +452 -121
- package/dist/index.js +452 -121
- package/docs/anthropic-cost-savings.md +1 -1
- package/docs/anthropic-third-party-harness-changes.md +2 -2
- package/docs/clawrouter-cuts-llm-api-costs-500x.md +1 -1
- package/docs/clawrouter-vs-openrouter-llm-routing-comparison.md +3 -3
- package/package.json +13 -10
- package/skills/clawrouter/SKILL.md +3 -3
- package/src/top-models.json +0 -1
package/dist/index.js
CHANGED
|
@@ -93,7 +93,6 @@ var init_top_models = __esm({
|
|
|
93
93
|
"deepseek/deepseek-chat",
|
|
94
94
|
"deepseek/deepseek-reasoner",
|
|
95
95
|
"free/deepseek-v4-flash",
|
|
96
|
-
"free/seed-oss-36b",
|
|
97
96
|
"free/nemotron-3-nano-omni-30b-a3b-reasoning",
|
|
98
97
|
"free/mistral-nemotron",
|
|
99
98
|
"free/step-3.7-flash",
|
|
@@ -403,9 +402,10 @@ var init_models = __esm({
|
|
|
403
402
|
"free/deepseek-v4-pro": "free/deepseek-v4-flash",
|
|
404
403
|
"nvidia/deepseek-v4-flash": "free/deepseek-v4-flash",
|
|
405
404
|
"nvidia/nemotron-3-nano-omni-30b-a3b-reasoning": "free/nemotron-3-nano-omni-30b-a3b-reasoning",
|
|
406
|
-
// qwen3-coder-480b retired (NVIDIA EOL 2026-06-14)
|
|
407
|
-
//
|
|
408
|
-
//
|
|
405
|
+
// qwen3-coder-480b retired (NVIDIA EOL 2026-06-14). Its server-side redirect used
|
|
406
|
+
// to be seed-oss-36b, but that EOL'd too on 2026-08-03, so blockrun re-pointed it
|
|
407
|
+
// at gpt-oss-120b. Keep the explicit id mappings for pinned callers (BlockRun still
|
|
408
|
+
// resolves them); the generic coding shorthands follow the gateway to gpt-oss-120b.
|
|
409
409
|
"nvidia/qwen3-coder-480b": "free/qwen3-coder-480b",
|
|
410
410
|
"qwen/qwen3-coder-480b-a35b-instruct": "free/qwen3-coder-480b",
|
|
411
411
|
// glm-4.7 pin keeps the real id — blockrun redirects it server-side (→ gpt-oss-120b).
|
|
@@ -451,13 +451,14 @@ var init_models = __esm({
|
|
|
451
451
|
"v4-flash": "free/deepseek-v4-flash",
|
|
452
452
|
"mistral-free": "free/mistral-nemotron",
|
|
453
453
|
// mistral-large-3-675b EOL'd 2026-07-28 → last live free Mistral (blockrun demoted its /free-mistral primary the same way)
|
|
454
|
-
"glm-free": "free/
|
|
455
|
-
//
|
|
454
|
+
"glm-free": "free/gpt-oss-120b",
|
|
455
|
+
// seed-oss-36b (the prior target) EOL'd 2026-08-03
|
|
456
456
|
"llama-free": "free/gpt-oss-120b",
|
|
457
457
|
// no live free Llama left (maverick died 2026-07)
|
|
458
|
-
|
|
459
|
-
//
|
|
460
|
-
"qwen-coder
|
|
458
|
+
// qwen3-coder-480b retired 2026-06-14 → seed-oss-36b, which then EOL'd 2026-08-03.
|
|
459
|
+
// Follow the gateway's own retarget rather than chaining to a second dead model.
|
|
460
|
+
"qwen-coder": "free/gpt-oss-120b",
|
|
461
|
+
"qwen-coder-free": "free/gpt-oss-120b",
|
|
461
462
|
"qwen-thinking": "free/gpt-oss-120b",
|
|
462
463
|
// qwen3-next died 2026-07-17; no live free Qwen left
|
|
463
464
|
"qwen3-next": "free/qwen3-next-80b-a3b-instruct",
|
|
@@ -466,9 +467,11 @@ var init_models = __esm({
|
|
|
466
467
|
"mistral-small": "free/mistral-nemotron",
|
|
467
468
|
// closest live Mistral-family free model
|
|
468
469
|
// New live free models (2026-06-14 BlockRun free-tier refresh)
|
|
470
|
+
// seed-oss pins name the model itself — kept routable, the gateway redirects them.
|
|
469
471
|
"seed-oss": "free/seed-oss-36b",
|
|
470
472
|
"seed-oss-36b": "free/seed-oss-36b",
|
|
471
|
-
"coder-free": "free/
|
|
473
|
+
"coder-free": "free/gpt-oss-120b",
|
|
474
|
+
// generic "a free coder" → follows the gateway retarget
|
|
472
475
|
"mistral-nemotron": "free/mistral-nemotron",
|
|
473
476
|
"step-flash": "free/step-3.7-flash",
|
|
474
477
|
"step-3.7-flash": "free/step-3.7-flash",
|
|
@@ -489,8 +492,9 @@ var init_models = __esm({
|
|
|
489
492
|
"nemotron-super": "free/gpt-oss-120b",
|
|
490
493
|
"nemotron-49b": "free/gpt-oss-120b",
|
|
491
494
|
"nemotron-120b": "free/gpt-oss-120b",
|
|
492
|
-
devstral: "free/
|
|
493
|
-
|
|
495
|
+
devstral: "free/gpt-oss-120b",
|
|
496
|
+
// seed-oss-36b EOL'd 2026-08-03; matches blockrun's own retarget
|
|
497
|
+
"devstral-2": "free/gpt-oss-120b",
|
|
494
498
|
maverick: "free/llama-4-maverick",
|
|
495
499
|
// explicit-ish pin — gateway redirects
|
|
496
500
|
free: "free/gpt-oss-120b",
|
|
@@ -1613,8 +1617,13 @@ var init_models = __esm({
|
|
|
1613
1617
|
reasoning: true
|
|
1614
1618
|
},
|
|
1615
1619
|
{
|
|
1616
|
-
// ByteDance Seed-OSS 36B:
|
|
1617
|
-
//
|
|
1620
|
+
// ByteDance Seed-OSS 36B: was the free coder, and the redirect target for the
|
|
1621
|
+
// retired qwen3-coder-480b. EOL'd 2026-08-03 — blockrun's probe got HTTP 410
|
|
1622
|
+
// Gone from NVIDIA on both passes and the prod health gate fired
|
|
1623
|
+
// [ALERT][free-model-dead] kind=gone the same day; upstream now hides it and
|
|
1624
|
+
// re-pointed its own dependents (qwen3-coder-480b, devstral-2) at gpt-oss-120b.
|
|
1625
|
+
// Entry kept so explicit pins stay routable; off the picker, the FREE_MODELS
|
|
1626
|
+
// cascade, and the router fallback chains.
|
|
1618
1627
|
id: "free/seed-oss-36b",
|
|
1619
1628
|
name: "[Free] Seed-OSS 36B",
|
|
1620
1629
|
version: "oss-36b",
|
|
@@ -36378,8 +36387,8 @@ var init_config = __esm({
|
|
|
36378
36387
|
// FREE — smaller, faster
|
|
36379
36388
|
"free/deepseek-v4-flash",
|
|
36380
36389
|
// FREE — 1M ctx; slow (~10 tok/s, 07-28 probe) but completes
|
|
36381
|
-
|
|
36382
|
-
//
|
|
36390
|
+
// seed-oss-36b sat here as the free coder until it EOL'd 2026-08-03 (HTTP 410).
|
|
36391
|
+
// gpt-oss-120b/20b already head this chain, so the rung is dropped, not retargeted.
|
|
36383
36392
|
"google/gemini-3.1-flash-lite",
|
|
36384
36393
|
// $0.25/$1.50 — newest flash-lite
|
|
36385
36394
|
"openai/gpt-5.4-nano",
|
|
@@ -36496,8 +36505,8 @@ var init_config = __esm({
|
|
|
36496
36505
|
"openai/gpt-5.3-codex",
|
|
36497
36506
|
"deepseek/deepseek-chat",
|
|
36498
36507
|
// Cheap, reliable
|
|
36499
|
-
"free/
|
|
36500
|
-
// NVIDIA free ultimate backstop (
|
|
36508
|
+
"free/gpt-oss-120b"
|
|
36509
|
+
// NVIDIA free ultimate backstop (was seed-oss-36b; EOL'd 2026-08-03)
|
|
36501
36510
|
]
|
|
36502
36511
|
},
|
|
36503
36512
|
REASONING: {
|
|
@@ -36586,8 +36595,8 @@ var init_config = __esm({
|
|
|
36586
36595
|
// Previous flagship — 6,213ms, reliable
|
|
36587
36596
|
"deepseek/deepseek-chat",
|
|
36588
36597
|
// 1,431ms — cheap, reliable
|
|
36589
|
-
"free/
|
|
36590
|
-
// NVIDIA free ultimate backstop (
|
|
36598
|
+
"free/gpt-oss-120b"
|
|
36599
|
+
// NVIDIA free ultimate backstop (was seed-oss-36b; EOL'd 2026-08-03)
|
|
36591
36600
|
]
|
|
36592
36601
|
},
|
|
36593
36602
|
REASONING: {
|
|
@@ -56858,6 +56867,7 @@ var require_symbols = __commonJS({
|
|
|
56858
56867
|
kCounter: /* @__PURE__ */ Symbol("socket request counter"),
|
|
56859
56868
|
kMaxResponseSize: /* @__PURE__ */ Symbol("max response size"),
|
|
56860
56869
|
kHTTP2Session: /* @__PURE__ */ Symbol("http2Session"),
|
|
56870
|
+
kHTTP2Options: /* @__PURE__ */ Symbol("http2 options"),
|
|
56861
56871
|
kHTTP2SessionState: /* @__PURE__ */ Symbol("http2Session state"),
|
|
56862
56872
|
kRetryHandlerDefaultRetry: /* @__PURE__ */ Symbol("retry agent default retry"),
|
|
56863
56873
|
kConstruct: /* @__PURE__ */ Symbol("constructable"),
|
|
@@ -59626,14 +59636,26 @@ var require_connect = __commonJS({
|
|
|
59626
59636
|
} else {
|
|
59627
59637
|
assert10(!httpSocket, "httpSocket can only be sent on TLS update");
|
|
59628
59638
|
port = port || 80;
|
|
59629
|
-
|
|
59639
|
+
const connectOptions = {
|
|
59630
59640
|
highWaterMark: 64 * 1024,
|
|
59631
59641
|
// Same as nodejs fs streams.
|
|
59632
59642
|
...options,
|
|
59633
59643
|
localAddress,
|
|
59634
59644
|
port,
|
|
59635
59645
|
host: hostname
|
|
59636
|
-
}
|
|
59646
|
+
};
|
|
59647
|
+
const family = net3.isIP(hostname);
|
|
59648
|
+
if (family !== 0 && servername && servername !== hostname) {
|
|
59649
|
+
connectOptions.host = servername;
|
|
59650
|
+
connectOptions.lookup = (_hostname, lookupOptions, cb) => {
|
|
59651
|
+
if (lookupOptions.all) {
|
|
59652
|
+
cb(null, [{ address: hostname, family }]);
|
|
59653
|
+
} else {
|
|
59654
|
+
cb(null, hostname, family);
|
|
59655
|
+
}
|
|
59656
|
+
};
|
|
59657
|
+
}
|
|
59658
|
+
socket = net3.connect(connectOptions);
|
|
59637
59659
|
if (useH2c === true) {
|
|
59638
59660
|
socket.alpnProtocol = "h2";
|
|
59639
59661
|
}
|
|
@@ -64073,20 +64095,20 @@ var require_client_h1 = __commonJS({
|
|
|
64073
64095
|
}
|
|
64074
64096
|
function clearIdleSocketValidation(socket) {
|
|
64075
64097
|
if (socket[kIdleSocketValidationTimeout]) {
|
|
64076
|
-
|
|
64098
|
+
clearTimeout(socket[kIdleSocketValidationTimeout]);
|
|
64077
64099
|
socket[kIdleSocketValidationTimeout] = null;
|
|
64078
64100
|
}
|
|
64079
64101
|
socket[kIdleSocketValidation] = 0;
|
|
64080
64102
|
}
|
|
64081
64103
|
function scheduleIdleSocketValidation(client, socket) {
|
|
64082
64104
|
socket[kIdleSocketValidation] = 1;
|
|
64083
|
-
socket[kIdleSocketValidationTimeout] =
|
|
64105
|
+
socket[kIdleSocketValidationTimeout] = setTimeout(() => {
|
|
64084
64106
|
socket[kIdleSocketValidationTimeout] = null;
|
|
64085
64107
|
socket[kIdleSocketValidation] = 2;
|
|
64086
64108
|
if (client[kSocket] === socket && !socket.destroyed) {
|
|
64087
64109
|
client[kResume]();
|
|
64088
64110
|
}
|
|
64089
|
-
});
|
|
64111
|
+
}, 0);
|
|
64090
64112
|
socket[kIdleSocketValidationTimeout].unref?.();
|
|
64091
64113
|
}
|
|
64092
64114
|
function resumeH1(client) {
|
|
@@ -64610,10 +64632,7 @@ var require_client_h2 = __commonJS({
|
|
|
64610
64632
|
kStrictContentLength,
|
|
64611
64633
|
kOnError,
|
|
64612
64634
|
kMaxConcurrentStreams,
|
|
64613
|
-
kPingInterval,
|
|
64614
64635
|
kHTTP2Session,
|
|
64615
|
-
kHTTP2InitialWindowSize,
|
|
64616
|
-
kHTTP2ConnectionWindowSize,
|
|
64617
64636
|
kHostAuthority,
|
|
64618
64637
|
kResume,
|
|
64619
64638
|
kSize,
|
|
@@ -64625,7 +64644,8 @@ var require_client_h2 = __commonJS({
|
|
|
64625
64644
|
kEnableConnectProtocol,
|
|
64626
64645
|
kRemoteSettings,
|
|
64627
64646
|
kHTTP2Stream,
|
|
64628
|
-
kHTTP2SessionState
|
|
64647
|
+
kHTTP2SessionState,
|
|
64648
|
+
kHTTP2Options
|
|
64629
64649
|
} = require_symbols();
|
|
64630
64650
|
var { channels } = require_diagnostics();
|
|
64631
64651
|
var kOpenStreams = /* @__PURE__ */ Symbol("open streams");
|
|
@@ -64634,6 +64654,9 @@ var require_client_h2 = __commonJS({
|
|
|
64634
64654
|
var kRequestStreamCleanup = /* @__PURE__ */ Symbol("request stream cleanup");
|
|
64635
64655
|
var kRequestStreamState = /* @__PURE__ */ Symbol("request stream state");
|
|
64636
64656
|
var kReceivedGoAway = /* @__PURE__ */ Symbol("received goaway");
|
|
64657
|
+
var kGoAwayReplayAttempts = /* @__PURE__ */ Symbol("goaway replay attempts");
|
|
64658
|
+
var kRefusedStreamRetry = /* @__PURE__ */ Symbol("refused stream retry");
|
|
64659
|
+
var MAX_GOAWAY_REPLAY_ATTEMPTS = 1;
|
|
64637
64660
|
var extractBody;
|
|
64638
64661
|
var http23;
|
|
64639
64662
|
try {
|
|
@@ -64731,10 +64754,15 @@ var require_client_h2 = __commonJS({
|
|
|
64731
64754
|
client[kPendingIdx] = client[kRunningIdx];
|
|
64732
64755
|
}
|
|
64733
64756
|
}
|
|
64734
|
-
function
|
|
64757
|
+
function canReplayRequest(request2) {
|
|
64735
64758
|
const { body } = request2;
|
|
64736
64759
|
return body == null || util5.isBuffer(body) || util5.isBlobLike(body);
|
|
64737
64760
|
}
|
|
64761
|
+
function registerGoAwayRefusal(request2) {
|
|
64762
|
+
const attempts = (request2[kGoAwayReplayAttempts] ?? 0) + 1;
|
|
64763
|
+
request2[kGoAwayReplayAttempts] = attempts;
|
|
64764
|
+
return attempts <= MAX_GOAWAY_REPLAY_ATTEMPTS;
|
|
64765
|
+
}
|
|
64738
64766
|
function closeStream(stream4, code = NGHTTP2_REFUSED_STREAM) {
|
|
64739
64767
|
if (stream4 != null && !stream4.destroyed && !stream4.closed) {
|
|
64740
64768
|
try {
|
|
@@ -64746,15 +64774,30 @@ var require_client_h2 = __commonJS({
|
|
|
64746
64774
|
function detachRequestStreamForClose(request2) {
|
|
64747
64775
|
const stream4 = request2[kRequestStream];
|
|
64748
64776
|
clearRequestStream(request2);
|
|
64777
|
+
severRequestStream(stream4);
|
|
64749
64778
|
return stream4;
|
|
64750
64779
|
}
|
|
64780
|
+
function severRequestStream(stream4) {
|
|
64781
|
+
if (stream4 == null || stream4[kRequestStreamState] == null) {
|
|
64782
|
+
return;
|
|
64783
|
+
}
|
|
64784
|
+
stream4[kRequestStreamState] = null;
|
|
64785
|
+
stream4.off("close", completeRequestStream);
|
|
64786
|
+
stream4.off("close", onUpgradeStreamClose);
|
|
64787
|
+
if (stream4[kHTTP2Session] != null) {
|
|
64788
|
+
closeStreamSession(stream4);
|
|
64789
|
+
}
|
|
64790
|
+
if (!stream4.destroyed && !stream4.closed) {
|
|
64791
|
+
stream4.once("error", noop2);
|
|
64792
|
+
}
|
|
64793
|
+
}
|
|
64751
64794
|
function connectH2(client, socket) {
|
|
64752
64795
|
client[kSocket] = socket;
|
|
64753
|
-
const http2InitialWindowSize = client[
|
|
64754
|
-
const http2ConnectionWindowSize = client[
|
|
64796
|
+
const http2InitialWindowSize = client[kHTTP2Options].sessionOptions?.initialWindowSize;
|
|
64797
|
+
const http2ConnectionWindowSize = client[kHTTP2Options].connectionWindowSize;
|
|
64755
64798
|
const session = http23.connect(client[kUrl], {
|
|
64756
64799
|
createConnection: () => socket,
|
|
64757
|
-
peerMaxConcurrentStreams: client[
|
|
64800
|
+
peerMaxConcurrentStreams: client[kHTTP2Options].maxConcurrentStreams,
|
|
64758
64801
|
settings: {
|
|
64759
64802
|
// TODO(metcoder95): add support for PUSH
|
|
64760
64803
|
enablePush: false,
|
|
@@ -64767,13 +64810,16 @@ var require_client_h2 = __commonJS({
|
|
|
64767
64810
|
session[kSocket] = socket;
|
|
64768
64811
|
session[kHTTP2SessionState] = {
|
|
64769
64812
|
idleTimeout: null,
|
|
64813
|
+
// Armed while the peer advertises MAX_CONCURRENT_STREAMS = 0 and we have
|
|
64814
|
+
// work that cannot start. See setNoStreamsTimeout.
|
|
64815
|
+
noStreamsTimeout: null,
|
|
64770
64816
|
// Sockets start out ref'd. Session ref/unref proxies to the socket, so a
|
|
64771
64817
|
// single cached flag lets us skip redundant uv ref/unref calls, provided
|
|
64772
64818
|
// every ref/unref of the session or its socket goes through
|
|
64773
64819
|
// refH2Session/unrefH2Session.
|
|
64774
64820
|
refed: true,
|
|
64775
64821
|
ping: {
|
|
64776
|
-
interval: client[
|
|
64822
|
+
interval: client[kHTTP2Options].pingInterval === 0 ? null : setInterval(onHttp2SendPing, client[kHTTP2Options].pingInterval, session).unref()
|
|
64777
64823
|
}
|
|
64778
64824
|
};
|
|
64779
64825
|
session[kReceivedGoAway] = false;
|
|
@@ -64878,8 +64924,48 @@ var require_client_h2 = __commonJS({
|
|
|
64878
64924
|
} else {
|
|
64879
64925
|
clearHttp2IdleTimeout(session);
|
|
64880
64926
|
}
|
|
64927
|
+
if (client[kMaxConcurrentStreams] === 0 && client[kRunning] === 0 && client[kPending] > 0) {
|
|
64928
|
+
setNoStreamsTimeout(session);
|
|
64929
|
+
} else {
|
|
64930
|
+
clearNoStreamsTimeout(session);
|
|
64931
|
+
}
|
|
64932
|
+
}
|
|
64933
|
+
}
|
|
64934
|
+
function clearNoStreamsTimeout(session) {
|
|
64935
|
+
const state = session[kHTTP2SessionState];
|
|
64936
|
+
if (state?.noStreamsTimeout != null) {
|
|
64937
|
+
clearTimeout(state.noStreamsTimeout);
|
|
64938
|
+
state.noStreamsTimeout = null;
|
|
64881
64939
|
}
|
|
64882
64940
|
}
|
|
64941
|
+
function setNoStreamsTimeout(session) {
|
|
64942
|
+
const client = session[kClient];
|
|
64943
|
+
const state = session[kHTTP2SessionState];
|
|
64944
|
+
const timeout = client[kHeadersTimeout];
|
|
64945
|
+
if (!timeout || state.noStreamsTimeout != null) {
|
|
64946
|
+
return;
|
|
64947
|
+
}
|
|
64948
|
+
state.noStreamsTimeout = setTimeout(onNoStreamsTimeout, timeout, session).unref();
|
|
64949
|
+
}
|
|
64950
|
+
function onNoStreamsTimeout(session) {
|
|
64951
|
+
const client = session[kClient];
|
|
64952
|
+
const state = session[kHTTP2SessionState];
|
|
64953
|
+
state.noStreamsTimeout = null;
|
|
64954
|
+
if (client[kHTTP2Session] !== session || client[kMaxConcurrentStreams] !== 0 || client[kRunning] !== 0 || client[kPending] === 0) {
|
|
64955
|
+
return;
|
|
64956
|
+
}
|
|
64957
|
+
const err = new HeadersTimeoutError(
|
|
64958
|
+
`HTTP/2: server did not accept a new stream within ${client[kHeadersTimeout]}`
|
|
64959
|
+
);
|
|
64960
|
+
const requests = client[kQueue].splice(client[kPendingIdx]);
|
|
64961
|
+
for (let i = 0; i < requests.length; i++) {
|
|
64962
|
+
if (requests[i] != null) {
|
|
64963
|
+
util5.errorRequest(client, requests[i], err);
|
|
64964
|
+
}
|
|
64965
|
+
}
|
|
64966
|
+
session[kError] = err;
|
|
64967
|
+
resetHttp2Session(session, err);
|
|
64968
|
+
}
|
|
64883
64969
|
function clearHttp2IdleTimeout(session) {
|
|
64884
64970
|
const state = session[kHTTP2SessionState];
|
|
64885
64971
|
if (state?.idleTimeout != null) {
|
|
@@ -64986,7 +65072,7 @@ var require_client_h2 = __commonJS({
|
|
|
64986
65072
|
const request2 = client[kQueue][i];
|
|
64987
65073
|
if (request2 != null) {
|
|
64988
65074
|
streamsToClose.push(detachRequestStreamForClose(request2));
|
|
64989
|
-
if (
|
|
65075
|
+
if (canReplayRequest(request2) && registerGoAwayRefusal(request2)) {
|
|
64990
65076
|
retriableRequests.push(request2);
|
|
64991
65077
|
} else {
|
|
64992
65078
|
util5.errorRequest(client, request2, err);
|
|
@@ -65007,6 +65093,7 @@ var require_client_h2 = __commonJS({
|
|
|
65007
65093
|
client[kHTTP2Session] = null;
|
|
65008
65094
|
}
|
|
65009
65095
|
clearHttp2IdleTimeout(this);
|
|
65096
|
+
clearNoStreamsTimeout(this);
|
|
65010
65097
|
if (!this.closed && !this.destroyed) {
|
|
65011
65098
|
this.close();
|
|
65012
65099
|
}
|
|
@@ -65023,6 +65110,7 @@ var require_client_h2 = __commonJS({
|
|
|
65023
65110
|
client[kHTTP2Session] = null;
|
|
65024
65111
|
}
|
|
65025
65112
|
clearHttp2IdleTimeout(this);
|
|
65113
|
+
clearNoStreamsTimeout(this);
|
|
65026
65114
|
if (state.ping.interval != null) {
|
|
65027
65115
|
clearInterval(state.ping.interval);
|
|
65028
65116
|
state.ping.interval = null;
|
|
@@ -65098,6 +65186,12 @@ var require_client_h2 = __commonJS({
|
|
|
65098
65186
|
releaseRequestStream(this);
|
|
65099
65187
|
if (state.pendingEnd && !state.request.aborted && !state.request.completed) {
|
|
65100
65188
|
state.request.onResponseEnd(state.trailers || {});
|
|
65189
|
+
} else if (!state.request.aborted && !state.request.completed) {
|
|
65190
|
+
util5.errorRequest(
|
|
65191
|
+
state.client,
|
|
65192
|
+
state.request,
|
|
65193
|
+
new InformationalError("HTTP/2: stream closed before the response was complete")
|
|
65194
|
+
);
|
|
65101
65195
|
}
|
|
65102
65196
|
finalizeRequest(state);
|
|
65103
65197
|
closeStreamSession(this);
|
|
@@ -65497,6 +65591,20 @@ var require_client_h2 = __commonJS({
|
|
|
65497
65591
|
state.abort(new InformationalError("HTTP/2: stream half-closed (remote)"), true);
|
|
65498
65592
|
}
|
|
65499
65593
|
}
|
|
65594
|
+
function retryRefusedStream(stream4, state) {
|
|
65595
|
+
const { client, request: request2 } = state;
|
|
65596
|
+
if (state.responseReceived || request2.aborted || request2.completed || request2[kRefusedStreamRetry] || !canReplayRequest(request2)) {
|
|
65597
|
+
return false;
|
|
65598
|
+
}
|
|
65599
|
+
request2[kRefusedStreamRetry] = true;
|
|
65600
|
+
detachRequestStreamForClose(request2);
|
|
65601
|
+
state.stream = null;
|
|
65602
|
+
state.requestFinalized = true;
|
|
65603
|
+
completeRequest(client, request2);
|
|
65604
|
+
client[kQueue].splice(client[kPendingIdx], 0, request2);
|
|
65605
|
+
client[kResume]();
|
|
65606
|
+
return true;
|
|
65607
|
+
}
|
|
65500
65608
|
function onError(err) {
|
|
65501
65609
|
const stream4 = this;
|
|
65502
65610
|
const state = stream4[kRequestStreamState];
|
|
@@ -65504,6 +65612,12 @@ var require_client_h2 = __commonJS({
|
|
|
65504
65612
|
return;
|
|
65505
65613
|
}
|
|
65506
65614
|
stream4.off("error", onError);
|
|
65615
|
+
if (typeof stream4.rstCode === "number" && stream4.rstCode !== NGHTTP2_NO_ERROR) {
|
|
65616
|
+
err.http2ErrorCode = stream4.rstCode;
|
|
65617
|
+
}
|
|
65618
|
+
if (stream4.rstCode === NGHTTP2_REFUSED_STREAM && retryRefusedStream(stream4, state)) {
|
|
65619
|
+
return;
|
|
65620
|
+
}
|
|
65507
65621
|
state.abort(err);
|
|
65508
65622
|
}
|
|
65509
65623
|
function onFrameError(type, code) {
|
|
@@ -65785,10 +65899,8 @@ var require_client = __commonJS({
|
|
|
65785
65899
|
kHTTPContext,
|
|
65786
65900
|
kMaxConcurrentStreams,
|
|
65787
65901
|
kHostAuthority,
|
|
65788
|
-
kHTTP2InitialWindowSize,
|
|
65789
|
-
kHTTP2ConnectionWindowSize,
|
|
65790
65902
|
kResume,
|
|
65791
|
-
|
|
65903
|
+
kHTTP2Options
|
|
65792
65904
|
} = require_symbols();
|
|
65793
65905
|
var connectH1 = require_client_h1();
|
|
65794
65906
|
var connectH2 = require_client_h2();
|
|
@@ -65801,6 +65913,14 @@ var require_client = __commonJS({
|
|
|
65801
65913
|
function getPipelining(client) {
|
|
65802
65914
|
return client[kPipelining] ?? client[kHTTPContext]?.defaultPipelining ?? 1;
|
|
65803
65915
|
}
|
|
65916
|
+
var h2NamespaceOptsWarning = false;
|
|
65917
|
+
function emitH2OptionsNamespaceWarning(optName) {
|
|
65918
|
+
if (h2NamespaceOptsWarning === true) return;
|
|
65919
|
+
process.emitWarning(`Use h2Options.${optName} instead. ${optName} for H2 will be deprecated in future major.`, {
|
|
65920
|
+
code: "UNDICI-H2-OPTIONS"
|
|
65921
|
+
});
|
|
65922
|
+
h2NamespaceOptsWarning = true;
|
|
65923
|
+
}
|
|
65804
65924
|
function getMaxConcurrent(client) {
|
|
65805
65925
|
if (client[kHTTPContext]?.version === "h2") {
|
|
65806
65926
|
return client[kMaxConcurrentStreams];
|
|
@@ -65844,7 +65964,8 @@ var require_client = __commonJS({
|
|
|
65844
65964
|
initialWindowSize,
|
|
65845
65965
|
connectionWindowSize,
|
|
65846
65966
|
pingInterval,
|
|
65847
|
-
webSocket
|
|
65967
|
+
webSocket,
|
|
65968
|
+
h2Options
|
|
65848
65969
|
} = {}) {
|
|
65849
65970
|
if (keepAlive !== void 0) {
|
|
65850
65971
|
throw new InvalidArgumentError("unsupported keepAlive, use pipelining=0 instead");
|
|
@@ -65907,20 +66028,45 @@ var require_client = __commonJS({
|
|
|
65907
66028
|
if (allowH2 != null && typeof allowH2 !== "boolean") {
|
|
65908
66029
|
throw new InvalidArgumentError("allowH2 must be a valid boolean value");
|
|
65909
66030
|
}
|
|
65910
|
-
if (
|
|
65911
|
-
|
|
65912
|
-
|
|
65913
|
-
|
|
65914
|
-
|
|
65915
|
-
|
|
65916
|
-
|
|
65917
|
-
|
|
65918
|
-
|
|
65919
|
-
|
|
65920
|
-
|
|
65921
|
-
|
|
65922
|
-
|
|
65923
|
-
|
|
66031
|
+
if (allowH2 !== false) {
|
|
66032
|
+
if (h2Options != null) {
|
|
66033
|
+
if (h2Options.useH2c != null && typeof h2Options.useH2c !== "boolean") {
|
|
66034
|
+
throw new InvalidArgumentError("h2Options.useH2c must be a valid boolean value");
|
|
66035
|
+
}
|
|
66036
|
+
if (h2Options.settings?.initialWindowSize != null && (!Number.isInteger(h2Options.settings.initialWindowSize) || h2Options.settings.initialWindowSize < 1)) {
|
|
66037
|
+
throw new InvalidArgumentError("h2Options.settings.initialWindowSize must be a positive integer, greater than 0");
|
|
66038
|
+
}
|
|
66039
|
+
if (h2Options.maxConcurrentStreams != null && (!Number.isInteger(h2Options.connectionWindowSize) || h2Options.maxConcurrentStreams < 1)) {
|
|
66040
|
+
throw new InvalidArgumentError("h2Options.maxConcurrentStreams must be a positive integer, greater than 0");
|
|
66041
|
+
}
|
|
66042
|
+
if (h2Options.connectionWindowSize != null && (!Number.isInteger(h2Options.connectionWindowSize) || h2Options.connectionWindowSize < 1)) {
|
|
66043
|
+
throw new InvalidArgumentError("h2Options.connectionWindowSize must be a positive integer, greater than 0");
|
|
66044
|
+
}
|
|
66045
|
+
if (h2Options.pingInterval != null && (typeof h2Options.pingInterval !== "number" || !Number.isInteger(h2Options.pingInterval) || h2Options.pingInterval < 0)) {
|
|
66046
|
+
throw new InvalidArgumentError("h2Options.pingInterval must be a positive integer, greater or equal to 0");
|
|
66047
|
+
}
|
|
66048
|
+
} else {
|
|
66049
|
+
if (useH2c != null && typeof useH2c !== "boolean") {
|
|
66050
|
+
emitH2OptionsNamespaceWarning("useH2c");
|
|
66051
|
+
throw new InvalidArgumentError("useH2c must be a valid boolean value");
|
|
66052
|
+
}
|
|
66053
|
+
if (maxConcurrentStreams != null && (typeof maxConcurrentStreams !== "number" || maxConcurrentStreams < 1)) {
|
|
66054
|
+
emitH2OptionsNamespaceWarning("maxConcurrentStreams");
|
|
66055
|
+
throw new InvalidArgumentError("maxConcurrentStreams must be a positive integer, greater than 0");
|
|
66056
|
+
}
|
|
66057
|
+
if (initialWindowSize != null && (!Number.isInteger(initialWindowSize) || initialWindowSize < 1)) {
|
|
66058
|
+
emitH2OptionsNamespaceWarning("initialWindowSize");
|
|
66059
|
+
throw new InvalidArgumentError("initialWindowSize must be a positive integer, greater than 0");
|
|
66060
|
+
}
|
|
66061
|
+
if (connectionWindowSize != null && (!Number.isInteger(connectionWindowSize) || connectionWindowSize < 1)) {
|
|
66062
|
+
emitH2OptionsNamespaceWarning("connectionWindowSize");
|
|
66063
|
+
throw new InvalidArgumentError("connectionWindowSize must be a positive integer, greater than 0");
|
|
66064
|
+
}
|
|
66065
|
+
if (pingInterval != null && (typeof pingInterval !== "number" || !Number.isInteger(pingInterval) || pingInterval < 0)) {
|
|
66066
|
+
emitH2OptionsNamespaceWarning("pingInterval");
|
|
66067
|
+
throw new InvalidArgumentError("pingInterval must be a positive integer, greater or equal to 0");
|
|
66068
|
+
}
|
|
66069
|
+
}
|
|
65924
66070
|
}
|
|
65925
66071
|
super({ webSocket });
|
|
65926
66072
|
if (typeof connect4 !== "function") {
|
|
@@ -65928,8 +66074,8 @@ var require_client = __commonJS({
|
|
|
65928
66074
|
...tls2,
|
|
65929
66075
|
maxCachedSessions,
|
|
65930
66076
|
allowH2,
|
|
65931
|
-
useH2c,
|
|
65932
66077
|
socketPath,
|
|
66078
|
+
useH2c: h2Options?.useH2c ?? useH2c,
|
|
65933
66079
|
timeout: connectTimeout,
|
|
65934
66080
|
...typeof autoSelectFamily === "boolean" ? { autoSelectFamily, autoSelectFamilyAttemptTimeout } : void 0,
|
|
65935
66081
|
...connect4
|
|
@@ -65964,10 +66110,21 @@ var require_client = __commonJS({
|
|
|
65964
66110
|
this[kClosedResolve] = null;
|
|
65965
66111
|
this[kMaxResponseSize] = maxResponseSize > -1 ? maxResponseSize : -1;
|
|
65966
66112
|
this[kHTTPContext] = null;
|
|
65967
|
-
this[
|
|
65968
|
-
|
|
65969
|
-
|
|
65970
|
-
|
|
66113
|
+
this[kHTTP2Options] = {
|
|
66114
|
+
pingInterval: h2Options?.pingInterval ?? pingInterval ?? 6e4,
|
|
66115
|
+
connectionWindowSize: h2Options?.connectionWindowSize ?? connectionWindowSize ?? 524288,
|
|
66116
|
+
maxConcurrentStreams: h2Options?.maxConcurrentStreams ?? maxConcurrentStreams ?? 100,
|
|
66117
|
+
// Max peerConcurrentStreams for a Node h2 server
|
|
66118
|
+
sessionOptions: {
|
|
66119
|
+
// HTTP/2 window sizes are set to higher defaults than Node.js core for better performance:
|
|
66120
|
+
// - initialWindowSize: 262144 (256KB) vs Node.js default 65535 (64KB - 1)
|
|
66121
|
+
// Allows more data to be sent before requiring acknowledgment, improving throughput
|
|
66122
|
+
// especially on high-latency networks. This matches common production HTTP/2 servers.
|
|
66123
|
+
// - connectionWindowSize: 524288 (512KB) vs Node.js default (none set)
|
|
66124
|
+
// Provides better flow control for the entire connection across multiple streams.
|
|
66125
|
+
initialWindowSize: h2Options?.initialWindowSize ?? initialWindowSize ?? 262144
|
|
66126
|
+
}
|
|
66127
|
+
};
|
|
65971
66128
|
this[kQueue] = [];
|
|
65972
66129
|
this[kRunningIdx] = 0;
|
|
65973
66130
|
this[kPendingIdx] = 0;
|
|
@@ -66252,6 +66409,7 @@ var require_client = __commonJS({
|
|
|
66252
66409
|
return;
|
|
66253
66410
|
}
|
|
66254
66411
|
if (!client[kHTTPContext]) {
|
|
66412
|
+
client[kServerName] = request2.servername;
|
|
66255
66413
|
connect3(client);
|
|
66256
66414
|
return;
|
|
66257
66415
|
}
|
|
@@ -67662,7 +67820,7 @@ var require_socks5_proxy_agent = __commonJS({
|
|
|
67662
67820
|
var DispatcherBase = require_dispatcher_base();
|
|
67663
67821
|
var { InvalidArgumentError } = require_errors();
|
|
67664
67822
|
var { Socks5Client, STATES } = require_socks5_client();
|
|
67665
|
-
var { kDispatch, kClose, kDestroy } = require_symbols();
|
|
67823
|
+
var { kBusy, kConnected, kDispatch, kClose, kDestroy } = require_symbols();
|
|
67666
67824
|
var Pool = require_pool();
|
|
67667
67825
|
var buildConnector = require_connect();
|
|
67668
67826
|
var { debuglog } = __require("util");
|
|
@@ -67820,6 +67978,17 @@ var require_socks5_proxy_agent = __commonJS({
|
|
|
67820
67978
|
}
|
|
67821
67979
|
});
|
|
67822
67980
|
this[kPools].set(originKey, pool);
|
|
67981
|
+
const closePoolIfUnused = () => {
|
|
67982
|
+
if (this[kPools].get(originKey) !== pool || pool[kConnected] > 0 || pool[kBusy]) {
|
|
67983
|
+
return;
|
|
67984
|
+
}
|
|
67985
|
+
this[kPools].delete(originKey);
|
|
67986
|
+
if (!pool.destroyed) {
|
|
67987
|
+
pool.close();
|
|
67988
|
+
}
|
|
67989
|
+
};
|
|
67990
|
+
pool.on("disconnect", closePoolIfUnused);
|
|
67991
|
+
pool.on("connectionError", closePoolIfUnused);
|
|
67823
67992
|
}
|
|
67824
67993
|
return pool[kDispatch](opts, handler);
|
|
67825
67994
|
} catch (err) {
|
|
@@ -68204,7 +68373,7 @@ var require_env_http_proxy_agent = __commonJS({
|
|
|
68204
68373
|
}
|
|
68205
68374
|
#getProxyAgentForUrl(url2) {
|
|
68206
68375
|
let { protocol, host: hostname, port } = url2;
|
|
68207
|
-
hostname = hostname.replace(/:\d*$/, "").toLowerCase();
|
|
68376
|
+
hostname = hostname.replace(/:\d*$/, "").replace(/^\[(.+)\]$/, "$1").toLowerCase();
|
|
68208
68377
|
port = Number.parseInt(port, 10) || DEFAULT_PORTS3[protocol] || 0;
|
|
68209
68378
|
if (!this.#shouldProxy(hostname, port)) {
|
|
68210
68379
|
return this[kNoProxyAgent];
|
|
@@ -68247,11 +68416,22 @@ var require_env_http_proxy_agent = __commonJS({
|
|
|
68247
68416
|
if (!entry) {
|
|
68248
68417
|
continue;
|
|
68249
68418
|
}
|
|
68250
|
-
|
|
68419
|
+
let hostname, port;
|
|
68420
|
+
const ipv6WithPort = entry.match(/^\[(.+)\]:(\d+)$/);
|
|
68421
|
+
if (ipv6WithPort) {
|
|
68422
|
+
hostname = ipv6WithPort[1];
|
|
68423
|
+
port = Number.parseInt(ipv6WithPort[2], 10);
|
|
68424
|
+
} else {
|
|
68425
|
+
const unbracketed = entry.replace(/^\[(.+)\]$/, "$1");
|
|
68426
|
+
const colonCount = (unbracketed.match(/:/g) || []).length;
|
|
68427
|
+
const parsed = colonCount === 1 && unbracketed.match(/^(.+):(\d+)$/);
|
|
68428
|
+
hostname = parsed ? parsed[1] : unbracketed;
|
|
68429
|
+
port = parsed ? Number.parseInt(parsed[2], 10) : 0;
|
|
68430
|
+
}
|
|
68251
68431
|
noProxyEntries.push({
|
|
68252
68432
|
// strip leading dot or asterisk with dot
|
|
68253
|
-
hostname:
|
|
68254
|
-
port
|
|
68433
|
+
hostname: hostname.replace(/^\*?\./, "").toLowerCase(),
|
|
68434
|
+
port
|
|
68255
68435
|
});
|
|
68256
68436
|
}
|
|
68257
68437
|
this.#noProxyValue = noProxyValue;
|
|
@@ -68473,6 +68653,10 @@ var require_retry_handler = __commonJS({
|
|
|
68473
68653
|
setTimeout(() => cb(null), retryTimeout);
|
|
68474
68654
|
}
|
|
68475
68655
|
onResponseStart(controller, statusCode, headers, statusMessage) {
|
|
68656
|
+
if (statusCode < 200) {
|
|
68657
|
+
this.handler.onResponseStart?.(this.controllerProxy, statusCode, headers, statusMessage);
|
|
68658
|
+
return;
|
|
68659
|
+
}
|
|
68476
68660
|
this.error = null;
|
|
68477
68661
|
this.retryCount += 1;
|
|
68478
68662
|
this.statusCode = statusCode;
|
|
@@ -68516,7 +68700,7 @@ var require_retry_handler = __commonJS({
|
|
|
68516
68700
|
if (this.end == null) {
|
|
68517
68701
|
if (statusCode === 206) {
|
|
68518
68702
|
const range = parseRangeHeader(headers["content-range"]);
|
|
68519
|
-
if (range == null) {
|
|
68703
|
+
if (range == null || range.end == null) {
|
|
68520
68704
|
this.headersSent = true;
|
|
68521
68705
|
this.handler.onResponseStart?.(
|
|
68522
68706
|
this.controllerProxy,
|
|
@@ -68536,7 +68720,7 @@ var require_retry_handler = __commonJS({
|
|
|
68536
68720
|
this.start = start;
|
|
68537
68721
|
this.end = end;
|
|
68538
68722
|
}
|
|
68539
|
-
if (this.end == null) {
|
|
68723
|
+
if (this.end == null && this.opts.method !== "HEAD") {
|
|
68540
68724
|
const contentLength = headers["content-length"];
|
|
68541
68725
|
this.end = contentLength != null ? Number(contentLength) - 1 : null;
|
|
68542
68726
|
}
|
|
@@ -68737,7 +68921,6 @@ var require_readable = __commonJS({
|
|
|
68737
68921
|
var kContentLength = /* @__PURE__ */ Symbol("kContentLength");
|
|
68738
68922
|
var kUsed = /* @__PURE__ */ Symbol("kUsed");
|
|
68739
68923
|
var kBytesRead = /* @__PURE__ */ Symbol("kBytesRead");
|
|
68740
|
-
var kPreservedBuffer = /* @__PURE__ */ Symbol("kPreservedBuffer");
|
|
68741
68924
|
var noop2 = () => {
|
|
68742
68925
|
};
|
|
68743
68926
|
var BodyReadable = class extends Readable2 {
|
|
@@ -68976,21 +69159,6 @@ var require_readable = __commonJS({
|
|
|
68976
69159
|
*/
|
|
68977
69160
|
setEncoding(encoding) {
|
|
68978
69161
|
if (Buffer.isEncoding(encoding)) {
|
|
68979
|
-
const state = this._readableState;
|
|
68980
|
-
const buffer2 = state.buffer;
|
|
68981
|
-
if (buffer2 && state.length > 0) {
|
|
68982
|
-
const bufferIndex = state.bufferIndex ?? 0;
|
|
68983
|
-
const preserved = [];
|
|
68984
|
-
const source = typeof buffer2.slice === "function" ? buffer2.slice(bufferIndex) : buffer2;
|
|
68985
|
-
for (const data of source) {
|
|
68986
|
-
if (Buffer.isBuffer(data)) {
|
|
68987
|
-
preserved.push(data);
|
|
68988
|
-
}
|
|
68989
|
-
}
|
|
68990
|
-
if (preserved.length > 0) {
|
|
68991
|
-
this[kPreservedBuffer] = (this[kPreservedBuffer] || []).concat(preserved);
|
|
68992
|
-
}
|
|
68993
|
-
}
|
|
68994
69162
|
super.setEncoding(encoding);
|
|
68995
69163
|
}
|
|
68996
69164
|
return this;
|
|
@@ -69041,13 +69209,7 @@ var require_readable = __commonJS({
|
|
|
69041
69209
|
return;
|
|
69042
69210
|
}
|
|
69043
69211
|
const { _readableState: state } = consume2.stream;
|
|
69044
|
-
|
|
69045
|
-
if (preserved && preserved.length > 0) {
|
|
69046
|
-
for (const chunk of preserved) {
|
|
69047
|
-
consumePush(consume2, chunk);
|
|
69048
|
-
}
|
|
69049
|
-
consume2.stream[kPreservedBuffer] = null;
|
|
69050
|
-
} else if (state.bufferIndex) {
|
|
69212
|
+
if (state.bufferIndex) {
|
|
69051
69213
|
const start = state.bufferIndex;
|
|
69052
69214
|
const end = state.buffer.length;
|
|
69053
69215
|
for (let n = start; n < end; n++) {
|
|
@@ -69058,13 +69220,17 @@ var require_readable = __commonJS({
|
|
|
69058
69220
|
consumePush(consume2, chunk);
|
|
69059
69221
|
}
|
|
69060
69222
|
}
|
|
69223
|
+
const decoder2 = state.decoder;
|
|
69224
|
+
if (decoder2 != null && decoder2.lastNeed > 0) {
|
|
69225
|
+
consumePush(consume2, Buffer.from(decoder2.lastChar.subarray(0, decoder2.lastTotal - decoder2.lastNeed)));
|
|
69226
|
+
}
|
|
69061
69227
|
if (state.endEmitted) {
|
|
69062
|
-
consumeEnd(
|
|
69063
|
-
|
|
69064
|
-
consume2.stream.on("end", function() {
|
|
69065
|
-
consumeEnd(this[kConsume], this._readableState.encoding);
|
|
69066
|
-
});
|
|
69228
|
+
consumeEnd(consume2, state.encoding);
|
|
69229
|
+
return;
|
|
69067
69230
|
}
|
|
69231
|
+
consume2.stream.on("end", function() {
|
|
69232
|
+
consumeEnd(this[kConsume], this._readableState.encoding);
|
|
69233
|
+
});
|
|
69068
69234
|
consume2.stream.resume();
|
|
69069
69235
|
while (consume2.stream.read() != null) {
|
|
69070
69236
|
}
|
|
@@ -69121,6 +69287,9 @@ var require_readable = __commonJS({
|
|
|
69121
69287
|
if (consume2.body === null) {
|
|
69122
69288
|
return;
|
|
69123
69289
|
}
|
|
69290
|
+
if (typeof chunk === "string") {
|
|
69291
|
+
chunk = Buffer.from(chunk, consume2.stream._readableState.encoding);
|
|
69292
|
+
}
|
|
69124
69293
|
consume2.length += chunk.length;
|
|
69125
69294
|
consume2.body.push(chunk);
|
|
69126
69295
|
}
|
|
@@ -70105,6 +70274,7 @@ var require_mock_utils = __commonJS({
|
|
|
70105
70274
|
}
|
|
70106
70275
|
} = __require("util");
|
|
70107
70276
|
var { InvalidArgumentError } = require_errors();
|
|
70277
|
+
var requestAborted = /* @__PURE__ */ Symbol("request aborted");
|
|
70108
70278
|
function matchValue(match, value) {
|
|
70109
70279
|
if (typeof match === "string") {
|
|
70110
70280
|
return match === value;
|
|
@@ -70217,6 +70387,8 @@ var require_mock_utils = __commonJS({
|
|
|
70217
70387
|
return data;
|
|
70218
70388
|
} else if (data instanceof ArrayBuffer) {
|
|
70219
70389
|
return data;
|
|
70390
|
+
} else if (ArrayBuffer.isView(data)) {
|
|
70391
|
+
return new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
|
|
70220
70392
|
} else if (typeof data === "object") {
|
|
70221
70393
|
return JSON.stringify(data);
|
|
70222
70394
|
} else if (data) {
|
|
@@ -70270,6 +70442,9 @@ var require_mock_utils = __commonJS({
|
|
|
70270
70442
|
}
|
|
70271
70443
|
}
|
|
70272
70444
|
function removeTrailingSlash(path6) {
|
|
70445
|
+
if (typeof path6 !== "string") {
|
|
70446
|
+
return path6;
|
|
70447
|
+
}
|
|
70273
70448
|
while (path6.endsWith("/")) {
|
|
70274
70449
|
path6 = path6.slice(0, -1);
|
|
70275
70450
|
}
|
|
@@ -70323,30 +70498,38 @@ var require_mock_utils = __commonJS({
|
|
|
70323
70498
|
const { timesInvoked, times } = mockDispatch2;
|
|
70324
70499
|
mockDispatch2.consumed = !mockDispatch2.persist && timesInvoked >= times;
|
|
70325
70500
|
mockDispatch2.pending = timesInvoked < times;
|
|
70326
|
-
|
|
70327
|
-
|
|
70501
|
+
const hasBodyHooks = typeof handler.onBodySent === "function" || typeof handler.onRequestSent === "function";
|
|
70502
|
+
if (mockDispatch2.data.callback && (!hasBodyHooks || opts.body == null)) {
|
|
70503
|
+
const { callback, ...responseDefaults } = mockDispatch2.data;
|
|
70504
|
+
const callbackResult = callback(opts);
|
|
70328
70505
|
if (isPromise(callbackResult)) {
|
|
70329
70506
|
callbackResult.then(
|
|
70330
70507
|
(resolvedData) => {
|
|
70331
|
-
|
|
70508
|
+
if (resolvedData == null || typeof resolvedData !== "object") {
|
|
70509
|
+
handler.onResponseError(null, new InvalidArgumentError("reply options callback must return an object"));
|
|
70510
|
+
return;
|
|
70511
|
+
}
|
|
70512
|
+
mockDispatch2.data = { ...responseDefaults, ...resolvedData };
|
|
70332
70513
|
dispatchMockReply(mockDispatches, mockDispatch2, key2, opts, handler);
|
|
70333
70514
|
},
|
|
70334
70515
|
(error) => {
|
|
70335
|
-
deleteMockDispatch(mockDispatches, key2);
|
|
70336
70516
|
handler.onResponseError(null, error);
|
|
70337
70517
|
}
|
|
70338
70518
|
);
|
|
70339
70519
|
return true;
|
|
70340
70520
|
}
|
|
70341
|
-
|
|
70521
|
+
if (callbackResult == null || typeof callbackResult !== "object") {
|
|
70522
|
+
throw new InvalidArgumentError("reply options callback must return an object");
|
|
70523
|
+
}
|
|
70524
|
+
mockDispatch2.data = { ...responseDefaults, ...callbackResult };
|
|
70342
70525
|
}
|
|
70343
70526
|
return dispatchMockReply(mockDispatches, mockDispatch2, key2, opts, handler);
|
|
70344
70527
|
}
|
|
70345
70528
|
function dispatchMockReply(mockDispatches, mockDispatch2, key2, opts, handler) {
|
|
70346
|
-
const { data:
|
|
70347
|
-
if (error !== null) {
|
|
70529
|
+
const { data: response, delay } = mockDispatch2;
|
|
70530
|
+
if (response.error !== null) {
|
|
70348
70531
|
deleteMockDispatch(mockDispatches, key2);
|
|
70349
|
-
handler.onResponseError(null, error);
|
|
70532
|
+
handler.onResponseError(null, response.error);
|
|
70350
70533
|
return true;
|
|
70351
70534
|
}
|
|
70352
70535
|
let aborted = false;
|
|
@@ -70373,30 +70556,91 @@ var require_mock_utils = __commonJS({
|
|
|
70373
70556
|
handler.onResponseError?.(controller, reason);
|
|
70374
70557
|
}
|
|
70375
70558
|
};
|
|
70559
|
+
let replyOpts = opts;
|
|
70560
|
+
const dispatches = mockDispatches;
|
|
70376
70561
|
handler.onRequestStart?.(controller, null);
|
|
70377
|
-
if (
|
|
70378
|
-
|
|
70379
|
-
|
|
70380
|
-
|
|
70381
|
-
|
|
70382
|
-
|
|
70383
|
-
|
|
70562
|
+
if (aborted) {
|
|
70563
|
+
return true;
|
|
70564
|
+
}
|
|
70565
|
+
const requestBody = dispatchRequestBody(opts.body, handler, controller, () => aborted);
|
|
70566
|
+
if (isPromise(requestBody)) {
|
|
70567
|
+
requestBody.then((body) => {
|
|
70568
|
+
if (body === requestAborted) {
|
|
70569
|
+
return;
|
|
70570
|
+
}
|
|
70571
|
+
if (body !== opts.body) {
|
|
70572
|
+
replyOpts = { ...opts, body };
|
|
70573
|
+
}
|
|
70574
|
+
sendReply();
|
|
70575
|
+
}, (error) => controller.abort(error));
|
|
70576
|
+
return true;
|
|
70577
|
+
}
|
|
70578
|
+
if (requestBody === requestAborted) {
|
|
70579
|
+
return true;
|
|
70580
|
+
}
|
|
70581
|
+
if (requestBody !== opts.body) {
|
|
70582
|
+
replyOpts = { ...opts, body: requestBody };
|
|
70583
|
+
}
|
|
70584
|
+
sendReply();
|
|
70585
|
+
function sendReply() {
|
|
70586
|
+
if (response.callback) {
|
|
70587
|
+
const { callback, ...responseDefaults } = response;
|
|
70588
|
+
let callbackResult;
|
|
70589
|
+
try {
|
|
70590
|
+
callbackResult = callback(replyOpts);
|
|
70591
|
+
} catch (err) {
|
|
70592
|
+
deleteMockDispatch(mockDispatches, key2);
|
|
70593
|
+
handler.onResponseError(null, err);
|
|
70594
|
+
return;
|
|
70595
|
+
}
|
|
70596
|
+
if (isPromise(callbackResult)) {
|
|
70597
|
+
callbackResult.then(
|
|
70598
|
+
(resolvedData) => {
|
|
70599
|
+
if (resolvedData == null || typeof resolvedData !== "object") {
|
|
70600
|
+
handler.onResponseError(null, new InvalidArgumentError("reply options callback must return an object"));
|
|
70601
|
+
return;
|
|
70602
|
+
}
|
|
70603
|
+
mockDispatch2.data = { ...responseDefaults, ...resolvedData };
|
|
70604
|
+
handleReply(dispatches, mockDispatch2.data);
|
|
70605
|
+
},
|
|
70606
|
+
(err) => {
|
|
70607
|
+
handler.onResponseError(null, err);
|
|
70608
|
+
}
|
|
70609
|
+
);
|
|
70610
|
+
return;
|
|
70611
|
+
}
|
|
70612
|
+
if (callbackResult == null || typeof callbackResult !== "object") {
|
|
70613
|
+
throw new InvalidArgumentError("reply options callback must return an object");
|
|
70614
|
+
}
|
|
70615
|
+
mockDispatch2.data = { ...responseDefaults, ...callbackResult };
|
|
70616
|
+
handleReply(dispatches, mockDispatch2.data);
|
|
70617
|
+
return;
|
|
70618
|
+
}
|
|
70619
|
+
if (typeof delay === "number" && delay > 0) {
|
|
70620
|
+
timer2 = setTimeout(() => {
|
|
70621
|
+
timer2 = null;
|
|
70622
|
+
handleReply(dispatches);
|
|
70623
|
+
}, delay);
|
|
70624
|
+
} else {
|
|
70625
|
+
handleReply(dispatches);
|
|
70626
|
+
}
|
|
70384
70627
|
}
|
|
70385
|
-
function handleReply(mockDispatches2,
|
|
70628
|
+
function handleReply(mockDispatches2, _response = response) {
|
|
70386
70629
|
if (aborted) {
|
|
70387
70630
|
return;
|
|
70388
70631
|
}
|
|
70632
|
+
const { statusCode, data, headers, trailers } = _response;
|
|
70389
70633
|
const optsHeaders = Array.isArray(opts.headers) ? buildHeadersFromArray(opts.headers) : opts.headers;
|
|
70390
|
-
const body = typeof
|
|
70634
|
+
const body = typeof data === "function" ? data({ ...replyOpts, headers: optsHeaders }) : data;
|
|
70391
70635
|
if (isPromise(body)) {
|
|
70392
|
-
return body.then((newData) => handleReply(mockDispatches2, newData));
|
|
70636
|
+
return body.then((newData) => handleReply(mockDispatches2, { ..._response, data: newData }));
|
|
70393
70637
|
}
|
|
70394
70638
|
if (aborted) {
|
|
70395
70639
|
return;
|
|
70396
70640
|
}
|
|
70397
70641
|
const responseData = getResponseData(body);
|
|
70398
|
-
const responseHeaders = generateKeyValues(headers);
|
|
70399
|
-
const responseTrailers = generateKeyValues(trailers);
|
|
70642
|
+
const responseHeaders = generateKeyValues(headers ?? {});
|
|
70643
|
+
const responseTrailers = generateKeyValues(trailers ?? {});
|
|
70400
70644
|
controller.rawHeaders = responseHeaders;
|
|
70401
70645
|
controller.rawTrailers = responseTrailers;
|
|
70402
70646
|
handler.onResponseStart?.(controller, statusCode, parseHeaders(responseHeaders), getStatusText(statusCode));
|
|
@@ -70406,6 +70650,78 @@ var require_mock_utils = __commonJS({
|
|
|
70406
70650
|
}
|
|
70407
70651
|
return true;
|
|
70408
70652
|
}
|
|
70653
|
+
function dispatchRequestBody(body, handler, controller, isAborted2) {
|
|
70654
|
+
if (typeof handler.onBodySent !== "function" && typeof handler.onRequestSent !== "function") {
|
|
70655
|
+
return body;
|
|
70656
|
+
}
|
|
70657
|
+
if (body == null) {
|
|
70658
|
+
return callOnRequestSent(handler, controller, isAborted2) ? body : requestAborted;
|
|
70659
|
+
}
|
|
70660
|
+
if (body && typeof body[Symbol.asyncIterator] === "function") {
|
|
70661
|
+
return dispatchAsyncIterableBody(body, handler, controller, isAborted2);
|
|
70662
|
+
}
|
|
70663
|
+
if (isIterableBody(body)) {
|
|
70664
|
+
const chunks = [];
|
|
70665
|
+
for (const chunk of body) {
|
|
70666
|
+
if (isAborted2()) {
|
|
70667
|
+
return requestAborted;
|
|
70668
|
+
}
|
|
70669
|
+
chunks.push(chunk);
|
|
70670
|
+
if (!callOnBodySent(handler, controller, chunk) || isAborted2()) {
|
|
70671
|
+
return requestAborted;
|
|
70672
|
+
}
|
|
70673
|
+
}
|
|
70674
|
+
return callOnRequestSent(handler, controller, isAborted2) ? chunks : requestAborted;
|
|
70675
|
+
}
|
|
70676
|
+
if (isAborted2()) {
|
|
70677
|
+
return requestAborted;
|
|
70678
|
+
}
|
|
70679
|
+
if (!callOnBodySent(handler, controller, body)) {
|
|
70680
|
+
return requestAborted;
|
|
70681
|
+
}
|
|
70682
|
+
return callOnRequestSent(handler, controller, isAborted2) ? body : requestAborted;
|
|
70683
|
+
}
|
|
70684
|
+
async function dispatchAsyncIterableBody(body, handler, controller, isAborted2) {
|
|
70685
|
+
const chunks = [];
|
|
70686
|
+
for await (const chunk of body) {
|
|
70687
|
+
if (isAborted2()) {
|
|
70688
|
+
return requestAborted;
|
|
70689
|
+
}
|
|
70690
|
+
chunks.push(chunk);
|
|
70691
|
+
if (!callOnBodySent(handler, controller, chunk) || isAborted2()) {
|
|
70692
|
+
return requestAborted;
|
|
70693
|
+
}
|
|
70694
|
+
}
|
|
70695
|
+
if (!callOnRequestSent(handler, controller, isAborted2)) {
|
|
70696
|
+
return requestAborted;
|
|
70697
|
+
}
|
|
70698
|
+
return {
|
|
70699
|
+
async *[Symbol.asyncIterator]() {
|
|
70700
|
+
yield* chunks;
|
|
70701
|
+
}
|
|
70702
|
+
};
|
|
70703
|
+
}
|
|
70704
|
+
function callOnBodySent(handler, controller, chunk) {
|
|
70705
|
+
try {
|
|
70706
|
+
handler.onBodySent?.(chunk);
|
|
70707
|
+
return true;
|
|
70708
|
+
} catch (error) {
|
|
70709
|
+
controller.abort(error);
|
|
70710
|
+
return false;
|
|
70711
|
+
}
|
|
70712
|
+
}
|
|
70713
|
+
function callOnRequestSent(handler, controller, isAborted2) {
|
|
70714
|
+
try {
|
|
70715
|
+
handler.onRequestSent?.();
|
|
70716
|
+
return !isAborted2();
|
|
70717
|
+
} catch (error) {
|
|
70718
|
+
controller.abort(error);
|
|
70719
|
+
return false;
|
|
70720
|
+
}
|
|
70721
|
+
}
|
|
70722
|
+
function isIterableBody(body) {
|
|
70723
|
+
return typeof body !== "string" && !Buffer.isBuffer(body) && !ArrayBuffer.isView(body) && typeof body[Symbol.iterator] === "function";
|
|
70724
|
+
}
|
|
70409
70725
|
function buildMockDispatch() {
|
|
70410
70726
|
const agent = this[kMockAgent];
|
|
70411
70727
|
const origin2 = this[kOrigin];
|
|
@@ -73049,15 +73365,13 @@ var require_cache = __commonJS({
|
|
|
73049
73365
|
}
|
|
73050
73366
|
}
|
|
73051
73367
|
function makeCacheKey(opts) {
|
|
73052
|
-
|
|
73053
|
-
throw new Error("opts.origin is undefined");
|
|
73054
|
-
}
|
|
73368
|
+
const origin2 = opts.origin ? opts.origin.toString() : "";
|
|
73055
73369
|
let fullPath = opts.path || "/";
|
|
73056
73370
|
if (opts.query && !pathHasQueryOrFragment(fullPath)) {
|
|
73057
73371
|
fullPath = serializePathWithQuery(fullPath, opts.query);
|
|
73058
73372
|
}
|
|
73059
73373
|
return {
|
|
73060
|
-
origin:
|
|
73374
|
+
origin: origin2,
|
|
73061
73375
|
method: opts.method,
|
|
73062
73376
|
path: fullPath,
|
|
73063
73377
|
headers: opts.headers
|
|
@@ -75140,10 +75454,13 @@ var require_cache2 = __commonJS({
|
|
|
75140
75454
|
}
|
|
75141
75455
|
return (dispatch) => {
|
|
75142
75456
|
return (opts2, handler) => {
|
|
75143
|
-
if (
|
|
75457
|
+
if (arrayIncludes(safeMethodsToNotCache, opts2.method)) {
|
|
75144
75458
|
return dispatch(opts2, handler);
|
|
75145
75459
|
}
|
|
75146
75460
|
if (origins !== void 0) {
|
|
75461
|
+
if (!opts2.origin) {
|
|
75462
|
+
return dispatch(opts2, handler);
|
|
75463
|
+
}
|
|
75147
75464
|
const requestOrigin = opts2.origin.toString().toLowerCase();
|
|
75148
75465
|
let isAllowed = false;
|
|
75149
75466
|
for (let i = 0; i < origins.length; i++) {
|
|
@@ -75841,7 +76158,7 @@ var require_deduplicate = __commonJS({
|
|
|
75841
76158
|
const pendingRequests = /* @__PURE__ */ new Map();
|
|
75842
76159
|
return (dispatch) => {
|
|
75843
76160
|
return (opts2, handler) => {
|
|
75844
|
-
if (
|
|
76161
|
+
if (opts2.upgrade || methods.includes(opts2.method) === false) {
|
|
75845
76162
|
return dispatch(opts2, handler);
|
|
75846
76163
|
}
|
|
75847
76164
|
opts2 = {
|
|
@@ -81691,6 +82008,8 @@ var require_websocket2 = __commonJS({
|
|
|
81691
82008
|
var { SendQueue } = require_sender2();
|
|
81692
82009
|
var { WebsocketFrameSend } = require_frame();
|
|
81693
82010
|
var { channels } = require_diagnostics();
|
|
82011
|
+
var kRef = /* @__PURE__ */ Symbol.for("nodejs.ref");
|
|
82012
|
+
var kUnref = /* @__PURE__ */ Symbol.for("nodejs.unref");
|
|
81694
82013
|
function getSocketAddress(socket) {
|
|
81695
82014
|
if (typeof socket?.address === "function") {
|
|
81696
82015
|
return socket.address();
|
|
@@ -81710,6 +82029,7 @@ var require_websocket2 = __commonJS({
|
|
|
81710
82029
|
#bufferedAmount = 0;
|
|
81711
82030
|
#protocol = "";
|
|
81712
82031
|
#extensions = "";
|
|
82032
|
+
#refed = true;
|
|
81713
82033
|
/** @type {SendQueue} */
|
|
81714
82034
|
#sendQueue;
|
|
81715
82035
|
/** @type {Handler} */
|
|
@@ -81792,6 +82112,16 @@ var require_websocket2 = __commonJS({
|
|
|
81792
82112
|
this.#handler.readyState = _WebSocket.CONNECTING;
|
|
81793
82113
|
this.#binaryType = "blob";
|
|
81794
82114
|
}
|
|
82115
|
+
[kRef]() {
|
|
82116
|
+
webidl.brandCheck(this, _WebSocket);
|
|
82117
|
+
this.#refed = true;
|
|
82118
|
+
this.#handler.socket?.ref?.();
|
|
82119
|
+
}
|
|
82120
|
+
[kUnref]() {
|
|
82121
|
+
webidl.brandCheck(this, _WebSocket);
|
|
82122
|
+
this.#refed = false;
|
|
82123
|
+
this.#handler.socket?.unref?.();
|
|
82124
|
+
}
|
|
81795
82125
|
/**
|
|
81796
82126
|
* @see https://websockets.spec.whatwg.org/#dom-websocket-close
|
|
81797
82127
|
* @param {number|undefined} code
|
|
@@ -81953,6 +82283,9 @@ var require_websocket2 = __commonJS({
|
|
|
81953
82283
|
*/
|
|
81954
82284
|
#onConnectionEstablished(response, parsedExtensions) {
|
|
81955
82285
|
this.#handler.socket = response.socket;
|
|
82286
|
+
if (!this.#refed) {
|
|
82287
|
+
this.#handler.socket.unref?.();
|
|
82288
|
+
}
|
|
81956
82289
|
const maxFragments = this.#handler.controller.dispatcher?.webSocketOptions?.maxFragments;
|
|
81957
82290
|
const maxPayloadSize = this.#handler.controller.dispatcher?.webSocketOptions?.maxPayloadSize;
|
|
81958
82291
|
const parser = new ByteParser(this.#handler, parsedExtensions, {
|
|
@@ -89712,8 +90045,6 @@ var init_proxy = __esm({
|
|
|
89712
90045
|
"free/gpt-oss-20b",
|
|
89713
90046
|
"free/deepseek-v4-flash",
|
|
89714
90047
|
// 1M ctx; slow (~10 tok/s, 07-28 probe) but completes
|
|
89715
|
-
"free/seed-oss-36b",
|
|
89716
|
-
// live coder (successor to retired qwen3-coder-480b)
|
|
89717
90048
|
"free/mistral-nemotron",
|
|
89718
90049
|
// strong instruction following
|
|
89719
90050
|
"free/step-3.7-flash",
|