@blockrun/clawrouter 0.12.252 → 0.12.253
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 +15 -3
- package/dist/index.js +15 -3
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -90607,6 +90607,10 @@ async function startProxy(options) {
|
|
|
90607
90607
|
}
|
|
90608
90608
|
if (req.url === "/v1/audio/generations" && req.method === "POST") {
|
|
90609
90609
|
const audioStartTime = Date.now();
|
|
90610
|
+
const clientAbort = new AbortController();
|
|
90611
|
+
res.on("close", () => {
|
|
90612
|
+
if (!res.writableEnded) clientAbort.abort();
|
|
90613
|
+
});
|
|
90610
90614
|
const chunks = [];
|
|
90611
90615
|
for await (const chunk of req) {
|
|
90612
90616
|
chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
|
|
@@ -90622,7 +90626,8 @@ async function startProxy(options) {
|
|
|
90622
90626
|
const upstream = await payFetch(`${apiBase}/v1/audio/generations`, {
|
|
90623
90627
|
method: "POST",
|
|
90624
90628
|
headers: { "content-type": "application/json", "user-agent": USER_AGENT },
|
|
90625
|
-
body: reqBody
|
|
90629
|
+
body: reqBody,
|
|
90630
|
+
signal: clientAbort.signal
|
|
90626
90631
|
});
|
|
90627
90632
|
const text = await upstream.text();
|
|
90628
90633
|
if (!upstream.ok) {
|
|
@@ -90644,7 +90649,7 @@ async function startProxy(options) {
|
|
|
90644
90649
|
for (const track of result.data) {
|
|
90645
90650
|
if (track.url?.startsWith("https://") || track.url?.startsWith("http://")) {
|
|
90646
90651
|
try {
|
|
90647
|
-
const audioResp = await fetch(track.url);
|
|
90652
|
+
const audioResp = await fetch(track.url, { signal: clientAbort.signal });
|
|
90648
90653
|
if (audioResp.ok) {
|
|
90649
90654
|
const contentType = audioResp.headers.get("content-type") ?? "audio/mpeg";
|
|
90650
90655
|
const ext = contentType.includes("wav") ? "wav" : "mp3";
|
|
@@ -90676,6 +90681,7 @@ async function startProxy(options) {
|
|
|
90676
90681
|
res.writeHead(200, { "Content-Type": "application/json" });
|
|
90677
90682
|
res.end(JSON.stringify(result));
|
|
90678
90683
|
} catch (err) {
|
|
90684
|
+
if (clientAbort.signal.aborted) return;
|
|
90679
90685
|
const msg = err instanceof Error ? err.message : String(err);
|
|
90680
90686
|
console.error(`[ClawRouter] Audio generation error: ${msg}`);
|
|
90681
90687
|
if (!res.headersSent) {
|
|
@@ -91695,6 +91701,10 @@ async function proxyRequest(req, res, apiBase, payFetch, options, routerOpts, de
|
|
|
91695
91701
|
console.log(
|
|
91696
91702
|
`[ClawRouter] /img2img \u2192 ${img2imgModel} (${img2imgSize}): ${img2imgPrompt.slice(0, 80)}`
|
|
91697
91703
|
);
|
|
91704
|
+
const img2imgAbort = new AbortController();
|
|
91705
|
+
res.on("close", () => {
|
|
91706
|
+
if (!res.writableEnded) img2imgAbort.abort();
|
|
91707
|
+
});
|
|
91698
91708
|
try {
|
|
91699
91709
|
const img2imgBody = JSON.stringify({
|
|
91700
91710
|
model: img2imgModel,
|
|
@@ -91707,7 +91717,8 @@ async function proxyRequest(req, res, apiBase, payFetch, options, routerOpts, de
|
|
|
91707
91717
|
const img2imgResponse = await payFetch(`${apiBase}/v1/images/image2image`, {
|
|
91708
91718
|
method: "POST",
|
|
91709
91719
|
headers: { "content-type": "application/json", "user-agent": USER_AGENT },
|
|
91710
|
-
body: img2imgBody
|
|
91720
|
+
body: img2imgBody,
|
|
91721
|
+
signal: img2imgAbort.signal
|
|
91711
91722
|
});
|
|
91712
91723
|
const img2imgResult = await img2imgResponse.json();
|
|
91713
91724
|
let responseText;
|
|
@@ -91757,6 +91768,7 @@ async function proxyRequest(req, res, apiBase, payFetch, options, routerOpts, de
|
|
|
91757
91768
|
}
|
|
91758
91769
|
sendImg2ImgText(responseText);
|
|
91759
91770
|
} catch (err) {
|
|
91771
|
+
if (img2imgAbort.signal.aborted) return;
|
|
91760
91772
|
const errMsg = err instanceof Error ? err.message : String(err);
|
|
91761
91773
|
console.error(`[ClawRouter] /img2img error: ${errMsg}`);
|
|
91762
91774
|
if (!res.headersSent) {
|
package/dist/index.js
CHANGED
|
@@ -90427,6 +90427,10 @@ async function startProxy(options) {
|
|
|
90427
90427
|
}
|
|
90428
90428
|
if (req.url === "/v1/audio/generations" && req.method === "POST") {
|
|
90429
90429
|
const audioStartTime = Date.now();
|
|
90430
|
+
const clientAbort = new AbortController();
|
|
90431
|
+
res.on("close", () => {
|
|
90432
|
+
if (!res.writableEnded) clientAbort.abort();
|
|
90433
|
+
});
|
|
90430
90434
|
const chunks = [];
|
|
90431
90435
|
for await (const chunk of req) {
|
|
90432
90436
|
chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
|
|
@@ -90442,7 +90446,8 @@ async function startProxy(options) {
|
|
|
90442
90446
|
const upstream = await payFetch(`${apiBase}/v1/audio/generations`, {
|
|
90443
90447
|
method: "POST",
|
|
90444
90448
|
headers: { "content-type": "application/json", "user-agent": USER_AGENT },
|
|
90445
|
-
body: reqBody
|
|
90449
|
+
body: reqBody,
|
|
90450
|
+
signal: clientAbort.signal
|
|
90446
90451
|
});
|
|
90447
90452
|
const text = await upstream.text();
|
|
90448
90453
|
if (!upstream.ok) {
|
|
@@ -90464,7 +90469,7 @@ async function startProxy(options) {
|
|
|
90464
90469
|
for (const track of result.data) {
|
|
90465
90470
|
if (track.url?.startsWith("https://") || track.url?.startsWith("http://")) {
|
|
90466
90471
|
try {
|
|
90467
|
-
const audioResp = await fetch(track.url);
|
|
90472
|
+
const audioResp = await fetch(track.url, { signal: clientAbort.signal });
|
|
90468
90473
|
if (audioResp.ok) {
|
|
90469
90474
|
const contentType = audioResp.headers.get("content-type") ?? "audio/mpeg";
|
|
90470
90475
|
const ext = contentType.includes("wav") ? "wav" : "mp3";
|
|
@@ -90496,6 +90501,7 @@ async function startProxy(options) {
|
|
|
90496
90501
|
res.writeHead(200, { "Content-Type": "application/json" });
|
|
90497
90502
|
res.end(JSON.stringify(result));
|
|
90498
90503
|
} catch (err) {
|
|
90504
|
+
if (clientAbort.signal.aborted) return;
|
|
90499
90505
|
const msg = err instanceof Error ? err.message : String(err);
|
|
90500
90506
|
console.error(`[ClawRouter] Audio generation error: ${msg}`);
|
|
90501
90507
|
if (!res.headersSent) {
|
|
@@ -91515,6 +91521,10 @@ async function proxyRequest(req, res, apiBase, payFetch, options, routerOpts, de
|
|
|
91515
91521
|
console.log(
|
|
91516
91522
|
`[ClawRouter] /img2img \u2192 ${img2imgModel} (${img2imgSize}): ${img2imgPrompt.slice(0, 80)}`
|
|
91517
91523
|
);
|
|
91524
|
+
const img2imgAbort = new AbortController();
|
|
91525
|
+
res.on("close", () => {
|
|
91526
|
+
if (!res.writableEnded) img2imgAbort.abort();
|
|
91527
|
+
});
|
|
91518
91528
|
try {
|
|
91519
91529
|
const img2imgBody = JSON.stringify({
|
|
91520
91530
|
model: img2imgModel,
|
|
@@ -91527,7 +91537,8 @@ async function proxyRequest(req, res, apiBase, payFetch, options, routerOpts, de
|
|
|
91527
91537
|
const img2imgResponse = await payFetch(`${apiBase}/v1/images/image2image`, {
|
|
91528
91538
|
method: "POST",
|
|
91529
91539
|
headers: { "content-type": "application/json", "user-agent": USER_AGENT },
|
|
91530
|
-
body: img2imgBody
|
|
91540
|
+
body: img2imgBody,
|
|
91541
|
+
signal: img2imgAbort.signal
|
|
91531
91542
|
});
|
|
91532
91543
|
const img2imgResult = await img2imgResponse.json();
|
|
91533
91544
|
let responseText;
|
|
@@ -91577,6 +91588,7 @@ async function proxyRequest(req, res, apiBase, payFetch, options, routerOpts, de
|
|
|
91577
91588
|
}
|
|
91578
91589
|
sendImg2ImgText(responseText);
|
|
91579
91590
|
} catch (err) {
|
|
91591
|
+
if (img2imgAbort.signal.aborted) return;
|
|
91580
91592
|
const errMsg = err instanceof Error ? err.message : String(err);
|
|
91581
91593
|
console.error(`[ClawRouter] /img2img error: ${errMsg}`);
|
|
91582
91594
|
if (!res.headersSent) {
|
package/package.json
CHANGED