@blockrun/clawrouter 0.12.254 → 0.12.255

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
@@ -90441,7 +90441,7 @@ async function startProxy(options) {
90441
90441
  console.log(`[ClawRouter] Image saved \u2192 ${img.url}`);
90442
90442
  } else if (img.url?.startsWith("https://") || img.url?.startsWith("http://")) {
90443
90443
  try {
90444
- const imgResp = await fetch(img.url);
90444
+ const imgResp = await fetch(img.url, { signal: clientAbort.signal });
90445
90445
  if (imgResp.ok) {
90446
90446
  const contentType = imgResp.headers.get("content-type") ?? "image/png";
90447
90447
  const ext = contentType.includes("jpeg") || contentType.includes("jpg") ? "jpg" : contentType.includes("webp") ? "webp" : "png";
@@ -90523,6 +90523,7 @@ async function startProxy(options) {
90523
90523
  img2imgCost = estimateImageCost(img2imgModel, parsed.size, parsed.n || 1);
90524
90524
  reqBody = JSON.stringify(parsed);
90525
90525
  } catch (parseErr) {
90526
+ if (clientAbort.signal.aborted) return;
90526
90527
  const msg = parseErr instanceof Error ? parseErr.message : String(parseErr);
90527
90528
  res.writeHead(400, { "Content-Type": "application/json" });
90528
90529
  res.end(JSON.stringify({ error: "Invalid request", details: msg }));
@@ -90563,7 +90564,7 @@ async function startProxy(options) {
90563
90564
  console.log(`[ClawRouter] Image saved \u2192 ${img.url}`);
90564
90565
  } else if (img.url?.startsWith("https://") || img.url?.startsWith("http://")) {
90565
90566
  try {
90566
- const imgResp = await fetch(img.url);
90567
+ const imgResp = await fetch(img.url, { signal: clientAbort.signal });
90567
90568
  if (imgResp.ok) {
90568
90569
  const contentType = imgResp.headers.get("content-type") ?? "image/png";
90569
90570
  const ext = contentType.includes("jpeg") || contentType.includes("jpg") ? "jpg" : contentType.includes("webp") ? "webp" : "png";
@@ -90809,7 +90810,7 @@ async function startProxy(options) {
90809
90810
  for (const clip of finalResult.data) {
90810
90811
  if (clip.url?.startsWith("https://") || clip.url?.startsWith("http://")) {
90811
90812
  try {
90812
- const videoResp = await fetch(clip.url);
90813
+ const videoResp = await fetch(clip.url, { signal: clientAbort.signal });
90813
90814
  if (videoResp.ok) {
90814
90815
  const contentType = videoResp.headers.get("content-type") ?? "video/mp4";
90815
90816
  const ext = contentType.includes("webm") ? "webm" : contentType.includes("quicktime") ? "mov" : "mp4";
@@ -91428,6 +91429,10 @@ async function proxyRequest(req, res, apiBase, payFetch, options, routerOpts, de
91428
91429
  console.log(
91429
91430
  `[ClawRouter] /imagegen command \u2192 ${imageModel} (${imageSize}): ${imagePrompt.slice(0, 80)}...`
91430
91431
  );
91432
+ const imagegenAbort = new AbortController();
91433
+ res.on("close", () => {
91434
+ if (!res.writableEnded) imagegenAbort.abort();
91435
+ });
91431
91436
  try {
91432
91437
  const imageUpstreamUrl = `${apiBase}/v1/images/generations`;
91433
91438
  const imageBody = JSON.stringify({
@@ -91436,10 +91441,6 @@ async function proxyRequest(req, res, apiBase, payFetch, options, routerOpts, de
91436
91441
  size: imageSize,
91437
91442
  n: 1
91438
91443
  });
91439
- const imagegenAbort = new AbortController();
91440
- res.on("close", () => {
91441
- if (!res.writableEnded) imagegenAbort.abort();
91442
- });
91443
91444
  const imageResponse = await payFetch(imageUpstreamUrl, {
91444
91445
  method: "POST",
91445
91446
  headers: { "content-type": "application/json", "user-agent": USER_AGENT },
@@ -91581,6 +91582,7 @@ async function proxyRequest(req, res, apiBase, payFetch, options, routerOpts, de
91581
91582
  );
91582
91583
  }
91583
91584
  } catch (err) {
91585
+ if (imagegenAbort.signal.aborted) return;
91584
91586
  const errMsg = err instanceof Error ? err.message : String(err);
91585
91587
  console.error(`[ClawRouter] /imagegen error: ${errMsg}`);
91586
91588
  if (!res.headersSent) {
package/dist/index.js CHANGED
@@ -90261,7 +90261,7 @@ async function startProxy(options) {
90261
90261
  console.log(`[ClawRouter] Image saved \u2192 ${img.url}`);
90262
90262
  } else if (img.url?.startsWith("https://") || img.url?.startsWith("http://")) {
90263
90263
  try {
90264
- const imgResp = await fetch(img.url);
90264
+ const imgResp = await fetch(img.url, { signal: clientAbort.signal });
90265
90265
  if (imgResp.ok) {
90266
90266
  const contentType = imgResp.headers.get("content-type") ?? "image/png";
90267
90267
  const ext = contentType.includes("jpeg") || contentType.includes("jpg") ? "jpg" : contentType.includes("webp") ? "webp" : "png";
@@ -90343,6 +90343,7 @@ async function startProxy(options) {
90343
90343
  img2imgCost = estimateImageCost(img2imgModel, parsed.size, parsed.n || 1);
90344
90344
  reqBody = JSON.stringify(parsed);
90345
90345
  } catch (parseErr) {
90346
+ if (clientAbort.signal.aborted) return;
90346
90347
  const msg = parseErr instanceof Error ? parseErr.message : String(parseErr);
90347
90348
  res.writeHead(400, { "Content-Type": "application/json" });
90348
90349
  res.end(JSON.stringify({ error: "Invalid request", details: msg }));
@@ -90383,7 +90384,7 @@ async function startProxy(options) {
90383
90384
  console.log(`[ClawRouter] Image saved \u2192 ${img.url}`);
90384
90385
  } else if (img.url?.startsWith("https://") || img.url?.startsWith("http://")) {
90385
90386
  try {
90386
- const imgResp = await fetch(img.url);
90387
+ const imgResp = await fetch(img.url, { signal: clientAbort.signal });
90387
90388
  if (imgResp.ok) {
90388
90389
  const contentType = imgResp.headers.get("content-type") ?? "image/png";
90389
90390
  const ext = contentType.includes("jpeg") || contentType.includes("jpg") ? "jpg" : contentType.includes("webp") ? "webp" : "png";
@@ -90629,7 +90630,7 @@ async function startProxy(options) {
90629
90630
  for (const clip of finalResult.data) {
90630
90631
  if (clip.url?.startsWith("https://") || clip.url?.startsWith("http://")) {
90631
90632
  try {
90632
- const videoResp = await fetch(clip.url);
90633
+ const videoResp = await fetch(clip.url, { signal: clientAbort.signal });
90633
90634
  if (videoResp.ok) {
90634
90635
  const contentType = videoResp.headers.get("content-type") ?? "video/mp4";
90635
90636
  const ext = contentType.includes("webm") ? "webm" : contentType.includes("quicktime") ? "mov" : "mp4";
@@ -91248,6 +91249,10 @@ async function proxyRequest(req, res, apiBase, payFetch, options, routerOpts, de
91248
91249
  console.log(
91249
91250
  `[ClawRouter] /imagegen command \u2192 ${imageModel} (${imageSize}): ${imagePrompt.slice(0, 80)}...`
91250
91251
  );
91252
+ const imagegenAbort = new AbortController();
91253
+ res.on("close", () => {
91254
+ if (!res.writableEnded) imagegenAbort.abort();
91255
+ });
91251
91256
  try {
91252
91257
  const imageUpstreamUrl = `${apiBase}/v1/images/generations`;
91253
91258
  const imageBody = JSON.stringify({
@@ -91256,10 +91261,6 @@ async function proxyRequest(req, res, apiBase, payFetch, options, routerOpts, de
91256
91261
  size: imageSize,
91257
91262
  n: 1
91258
91263
  });
91259
- const imagegenAbort = new AbortController();
91260
- res.on("close", () => {
91261
- if (!res.writableEnded) imagegenAbort.abort();
91262
- });
91263
91264
  const imageResponse = await payFetch(imageUpstreamUrl, {
91264
91265
  method: "POST",
91265
91266
  headers: { "content-type": "application/json", "user-agent": USER_AGENT },
@@ -91401,6 +91402,7 @@ async function proxyRequest(req, res, apiBase, payFetch, options, routerOpts, de
91401
91402
  );
91402
91403
  }
91403
91404
  } catch (err) {
91405
+ if (imagegenAbort.signal.aborted) return;
91404
91406
  const errMsg = err instanceof Error ? err.message : String(err);
91405
91407
  console.error(`[ClawRouter] /imagegen error: ${errMsg}`);
91406
91408
  if (!res.headersSent) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blockrun/clawrouter",
3
- "version": "0.12.254",
3
+ "version": "0.12.255",
4
4
  "description": "Smart LLM router — save 88% on inference costs. 71 models (5 free), one wallet, x402 micropayments.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",