@blockrun/clawrouter 0.11.5 → 0.11.6

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 CHANGED
@@ -89,13 +89,13 @@ Generate images directly from chat with `/imagegen`:
89
89
  /imagegen --model banana-pro --size 2048x2048 mountain landscape
90
90
  ```
91
91
 
92
- | Model | Provider | Price | Max Size |
93
- | ------------- | ---------------------- | ----------- | --------- |
94
- | `nano-banana` | Google Gemini Flash | $0.05/image | 1024x1024 |
95
- | `banana-pro` | Google Gemini Pro | $0.10/image | 4096x4096 |
96
- | `dall-e-3` | OpenAI DALL-E 3 | $0.04/image | 1792x1024 |
97
- | `gpt-image` | OpenAI GPT Image 1 | $0.02/image | 1536x1024 |
98
- | `flux` | Black Forest Flux 1.1 | $0.04/image | 1024x1024 |
92
+ | Model | Provider | Price | Max Size |
93
+ | ------------- | --------------------- | ----------- | --------- |
94
+ | `nano-banana` | Google Gemini Flash | $0.05/image | 1024x1024 |
95
+ | `banana-pro` | Google Gemini Pro | $0.10/image | 4096x4096 |
96
+ | `dall-e-3` | OpenAI DALL-E 3 | $0.04/image | 1792x1024 |
97
+ | `gpt-image` | OpenAI GPT Image 1 | $0.02/image | 1536x1024 |
98
+ | `flux` | Black Forest Flux 1.1 | $0.04/image | 1024x1024 |
99
99
 
100
100
  Default model: `nano-banana`. Images are returned as hosted URLs for compatibility with Telegram, Discord, and other clients.
101
101
 
@@ -211,6 +211,7 @@ USDC stays in your wallet until spent — non-custodial. Price is visible in the
211
211
  - **Coinbase:** Buy USDC, send to Base
212
212
  - **Bridge:** Move USDC from any chain to Base
213
213
  - **CEX:** Withdraw USDC to Base network
214
+ - **Credit card:** Don't have USDC? Reach out to [@bc1max on Telegram](https://t.me/bc1max) — we accept credit card payments
214
215
 
215
216
  ---
216
217
 
package/dist/cli.js CHANGED
@@ -5331,13 +5331,13 @@ async function proxyRequest(req, res, apiBase, payFetch, options, routerOpts, de
5331
5331
  const raw = modelMatch[1];
5332
5332
  const IMAGE_MODEL_ALIASES = {
5333
5333
  "dall-e-3": "openai/dall-e-3",
5334
- "dalle3": "openai/dall-e-3",
5335
- "dalle": "openai/dall-e-3",
5334
+ dalle3: "openai/dall-e-3",
5335
+ dalle: "openai/dall-e-3",
5336
5336
  "gpt-image": "openai/gpt-image-1",
5337
5337
  "gpt-image-1": "openai/gpt-image-1",
5338
- "flux": "black-forest/flux-1.1-pro",
5338
+ flux: "black-forest/flux-1.1-pro",
5339
5339
  "flux-pro": "black-forest/flux-1.1-pro",
5340
- "banana": "google/nano-banana",
5340
+ banana: "google/nano-banana",
5341
5341
  "nano-banana": "google/nano-banana",
5342
5342
  "banana-pro": "google/nano-banana-pro",
5343
5343
  "nano-banana-pro": "google/nano-banana-pro"
@@ -5378,32 +5378,51 @@ async function proxyRequest(req, res, apiBase, payFetch, options, routerOpts, de
5378
5378
  "Cache-Control": "no-cache",
5379
5379
  Connection: "keep-alive"
5380
5380
  });
5381
- res.write(`data: ${JSON.stringify({ id: completionId, object: "chat.completion.chunk", created: timestamp, model: "clawrouter/image", choices: [{ index: 0, delta: { role: "assistant", content: errorText }, finish_reason: null }] })}
5381
+ res.write(
5382
+ `data: ${JSON.stringify({ id: completionId, object: "chat.completion.chunk", created: timestamp, model: "clawrouter/image", choices: [{ index: 0, delta: { role: "assistant", content: errorText }, finish_reason: null }] })}
5382
5383
 
5383
- `);
5384
- res.write(`data: ${JSON.stringify({ id: completionId, object: "chat.completion.chunk", created: timestamp, model: "clawrouter/image", choices: [{ index: 0, delta: {}, finish_reason: "stop" }] })}
5384
+ `
5385
+ );
5386
+ res.write(
5387
+ `data: ${JSON.stringify({ id: completionId, object: "chat.completion.chunk", created: timestamp, model: "clawrouter/image", choices: [{ index: 0, delta: {}, finish_reason: "stop" }] })}
5385
5388
 
5386
- `);
5389
+ `
5390
+ );
5387
5391
  res.write("data: [DONE]\n\n");
5388
5392
  res.end();
5389
5393
  } else {
5390
5394
  res.writeHead(200, { "Content-Type": "application/json" });
5391
- res.end(JSON.stringify({
5392
- id: completionId,
5393
- object: "chat.completion",
5394
- created: timestamp,
5395
- model: "clawrouter/image",
5396
- choices: [{ index: 0, message: { role: "assistant", content: errorText }, finish_reason: "stop" }],
5397
- usage: { prompt_tokens: 0, completion_tokens: 0, total_tokens: 0 }
5398
- }));
5395
+ res.end(
5396
+ JSON.stringify({
5397
+ id: completionId,
5398
+ object: "chat.completion",
5399
+ created: timestamp,
5400
+ model: "clawrouter/image",
5401
+ choices: [
5402
+ {
5403
+ index: 0,
5404
+ message: { role: "assistant", content: errorText },
5405
+ finish_reason: "stop"
5406
+ }
5407
+ ],
5408
+ usage: { prompt_tokens: 0, completion_tokens: 0, total_tokens: 0 }
5409
+ })
5410
+ );
5399
5411
  }
5400
5412
  console.log(`[ClawRouter] /imagegen command \u2192 showing usage help`);
5401
5413
  return;
5402
5414
  }
5403
- console.log(`[ClawRouter] /imagegen command \u2192 ${imageModel} (${imageSize}): ${imagePrompt.slice(0, 80)}...`);
5415
+ console.log(
5416
+ `[ClawRouter] /imagegen command \u2192 ${imageModel} (${imageSize}): ${imagePrompt.slice(0, 80)}...`
5417
+ );
5404
5418
  try {
5405
5419
  const imageUpstreamUrl = `${apiBase}/v1/images/generations`;
5406
- const imageBody = JSON.stringify({ model: imageModel, prompt: imagePrompt, size: imageSize, n: 1 });
5420
+ const imageBody = JSON.stringify({
5421
+ model: imageModel,
5422
+ prompt: imagePrompt,
5423
+ size: imageSize,
5424
+ n: 1
5425
+ });
5407
5426
  const imageResponse = await payFetch(imageUpstreamUrl, {
5408
5427
  method: "POST",
5409
5428
  headers: { "content-type": "application/json", "user-agent": USER_AGENT },
@@ -5428,8 +5447,12 @@ async function proxyRequest(req, res, apiBase, payFetch, options, routerOpts, de
5428
5447
  const hostedUrl = await uploadDataUriToHost(img.url);
5429
5448
  lines.push(hostedUrl);
5430
5449
  } catch (uploadErr) {
5431
- console.error(`[ClawRouter] /imagegen: failed to upload data URI: ${uploadErr instanceof Error ? uploadErr.message : String(uploadErr)}`);
5432
- lines.push("Image generated but upload failed. Try again or use --model dall-e-3.");
5450
+ console.error(
5451
+ `[ClawRouter] /imagegen: failed to upload data URI: ${uploadErr instanceof Error ? uploadErr.message : String(uploadErr)}`
5452
+ );
5453
+ lines.push(
5454
+ "Image generated but upload failed. Try again or use --model dall-e-3."
5455
+ );
5433
5456
  }
5434
5457
  } else {
5435
5458
  lines.push(img.url);
@@ -5450,33 +5473,47 @@ async function proxyRequest(req, res, apiBase, payFetch, options, routerOpts, de
5450
5473
  "Cache-Control": "no-cache",
5451
5474
  Connection: "keep-alive"
5452
5475
  });
5453
- res.write(`data: ${JSON.stringify({ id: completionId, object: "chat.completion.chunk", created: timestamp, model: "clawrouter/image", choices: [{ index: 0, delta: { role: "assistant", content: responseText }, finish_reason: null }] })}
5476
+ res.write(
5477
+ `data: ${JSON.stringify({ id: completionId, object: "chat.completion.chunk", created: timestamp, model: "clawrouter/image", choices: [{ index: 0, delta: { role: "assistant", content: responseText }, finish_reason: null }] })}
5454
5478
 
5455
- `);
5456
- res.write(`data: ${JSON.stringify({ id: completionId, object: "chat.completion.chunk", created: timestamp, model: "clawrouter/image", choices: [{ index: 0, delta: {}, finish_reason: "stop" }] })}
5479
+ `
5480
+ );
5481
+ res.write(
5482
+ `data: ${JSON.stringify({ id: completionId, object: "chat.completion.chunk", created: timestamp, model: "clawrouter/image", choices: [{ index: 0, delta: {}, finish_reason: "stop" }] })}
5457
5483
 
5458
- `);
5484
+ `
5485
+ );
5459
5486
  res.write("data: [DONE]\n\n");
5460
5487
  res.end();
5461
5488
  } else {
5462
5489
  res.writeHead(200, { "Content-Type": "application/json" });
5463
- res.end(JSON.stringify({
5464
- id: completionId,
5465
- object: "chat.completion",
5466
- created: timestamp,
5467
- model: "clawrouter/image",
5468
- choices: [{ index: 0, message: { role: "assistant", content: responseText }, finish_reason: "stop" }],
5469
- usage: { prompt_tokens: 0, completion_tokens: 0, total_tokens: 0 }
5470
- }));
5490
+ res.end(
5491
+ JSON.stringify({
5492
+ id: completionId,
5493
+ object: "chat.completion",
5494
+ created: timestamp,
5495
+ model: "clawrouter/image",
5496
+ choices: [
5497
+ {
5498
+ index: 0,
5499
+ message: { role: "assistant", content: responseText },
5500
+ finish_reason: "stop"
5501
+ }
5502
+ ],
5503
+ usage: { prompt_tokens: 0, completion_tokens: 0, total_tokens: 0 }
5504
+ })
5505
+ );
5471
5506
  }
5472
5507
  } catch (err) {
5473
5508
  const errMsg = err instanceof Error ? err.message : String(err);
5474
5509
  console.error(`[ClawRouter] /imagegen error: ${errMsg}`);
5475
5510
  if (!res.headersSent) {
5476
5511
  res.writeHead(500, { "Content-Type": "application/json" });
5477
- res.end(JSON.stringify({
5478
- error: { message: `Image generation failed: ${errMsg}`, type: "image_error" }
5479
- }));
5512
+ res.end(
5513
+ JSON.stringify({
5514
+ error: { message: `Image generation failed: ${errMsg}`, type: "image_error" }
5515
+ })
5516
+ );
5480
5517
  }
5481
5518
  }
5482
5519
  return;
@@ -5585,10 +5622,7 @@ async function proxyRequest(req, res, apiBase, payFetch, options, routerOpts, de
5585
5622
  const lastAssistantMsg = [...parsedMessages].reverse().find((m) => m.role === "assistant");
5586
5623
  const toolCallNames = Array.isArray(lastAssistantMsg?.tool_calls) ? lastAssistantMsg.tool_calls.map((tc) => tc.function?.name).filter(Boolean) : void 0;
5587
5624
  const contentHash = hashRequestContent(prompt, toolCallNames);
5588
- const shouldEscalate = sessionStore.recordRequestHash(
5589
- effectiveSessionId,
5590
- contentHash
5591
- );
5625
+ const shouldEscalate = sessionStore.recordRequestHash(effectiveSessionId, contentHash);
5592
5626
  if (shouldEscalate) {
5593
5627
  const activeTierConfigs = (() => {
5594
5628
  if (routingDecision.reasoning?.includes("agentic") && routerOpts.config.agenticTiers) {