@kognai/clawrouter-x402 0.1.1 → 0.1.2

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.
@@ -723,6 +723,32 @@ async function routeCall(req) {
723
723
  output_tokens = result.output_tokens;
724
724
  cost_usd = 0; // local = free
725
725
  }
726
+ else if (route.tier === 'T2.5') {
727
+ // TICKET-350 honest routing: routine cloud work (the 'exec' tier) runs a
728
+ // CHEAP+FAST model DIRECTLY — bypassing the OpenClaw gateway, which flattened
729
+ // EVERY model to openclaw/main=opus AND had a cold ~12min first call. So
730
+ // routine code is now genuinely cheap + fast (and the cost_usd recorded is
731
+ // the REAL model price, not the gateway's). Hard/escalated tasks (T3/apex)
732
+ // still go through the gateway → opus. Falls back to the gateway if the
733
+ // direct call errors (e.g. missing key) so routing never hard-fails.
734
+ const cheapModel = process.env.KOGNAI_EXEC_MODEL || 'claude-haiku-4-5-20251001';
735
+ try {
736
+ const result = await callAnthropicDirect(cheapModel, messages, payload.max_tokens || 4096);
737
+ content = result.content;
738
+ input_tokens = result.input_tokens;
739
+ output_tokens = result.output_tokens;
740
+ cost_usd = result.cost_usd;
741
+ route = { tier: 'T2.5-EXEC', model: cheapModel, local: false };
742
+ }
743
+ catch (e) {
744
+ console.warn(`[ClawRouter] direct exec call failed (${e?.message || e}) — falling back to gateway`);
745
+ const result = await callCloudGateway(route.model, messages, payload.max_tokens || 4096);
746
+ content = result.content;
747
+ input_tokens = result.input_tokens;
748
+ output_tokens = result.output_tokens;
749
+ cost_usd = result.cost_usd;
750
+ }
751
+ }
726
752
  else {
727
753
  const result = await callCloudGateway(route.model, messages, payload.max_tokens || 4096);
728
754
  content = result.content;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kognai/clawrouter-x402",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "private": false,
5
5
  "description": "ClawRouter v2 — Kognai's viem-backed x402 ModelRouter implementation. Injected into @kognai/orchestrator-core's router seam at startup, so core never depends on viem; products that don't route on-chain simply don't install this package.",
6
6
  "main": "dist/index.js",