@blockrun/clawrouter 0.9.38 → 0.9.39
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 +24 -20
- package/dist/cli.js.map +1 -1
- package/dist/index.js +37 -24
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1798,20 +1798,12 @@ var DEFAULT_ROUTING_CONFIG = {
|
|
|
1798
1798
|
SIMPLE: {
|
|
1799
1799
|
primary: "moonshot/kimi-k2.5",
|
|
1800
1800
|
// Cheaper than Haiku ($0.5/$2.4 vs $1/$5), larger context
|
|
1801
|
-
fallback: [
|
|
1802
|
-
"claude-haiku-4.5",
|
|
1803
|
-
"xai/grok-4-1-fast-non-reasoning",
|
|
1804
|
-
"openai/gpt-4o-mini"
|
|
1805
|
-
]
|
|
1801
|
+
fallback: ["claude-haiku-4.5", "xai/grok-4-1-fast-non-reasoning", "openai/gpt-4o-mini"]
|
|
1806
1802
|
},
|
|
1807
1803
|
MEDIUM: {
|
|
1808
1804
|
primary: "xai/grok-code-fast-1",
|
|
1809
1805
|
// Code specialist for agentic coding
|
|
1810
|
-
fallback: [
|
|
1811
|
-
"moonshot/kimi-k2.5",
|
|
1812
|
-
"claude-haiku-4.5",
|
|
1813
|
-
"claude-sonnet-4"
|
|
1814
|
-
]
|
|
1806
|
+
fallback: ["moonshot/kimi-k2.5", "claude-haiku-4.5", "claude-sonnet-4"]
|
|
1815
1807
|
},
|
|
1816
1808
|
COMPLEX: {
|
|
1817
1809
|
primary: "claude-sonnet-4",
|
|
@@ -1826,11 +1818,7 @@ var DEFAULT_ROUTING_CONFIG = {
|
|
|
1826
1818
|
REASONING: {
|
|
1827
1819
|
primary: "claude-sonnet-4",
|
|
1828
1820
|
// Strong tool use + reasoning for agentic tasks
|
|
1829
|
-
fallback: [
|
|
1830
|
-
"claude-opus-4",
|
|
1831
|
-
"xai/grok-4-1-fast-reasoning",
|
|
1832
|
-
"deepseek/deepseek-reasoner"
|
|
1833
|
-
]
|
|
1821
|
+
fallback: ["claude-opus-4", "xai/grok-4-1-fast-reasoning", "deepseek/deepseek-reasoner"]
|
|
1834
1822
|
}
|
|
1835
1823
|
},
|
|
1836
1824
|
overrides: {
|
|
@@ -1934,7 +1922,33 @@ async function logUsage(entry) {
|
|
|
1934
1922
|
}
|
|
1935
1923
|
|
|
1936
1924
|
// src/stats.ts
|
|
1937
|
-
import {
|
|
1925
|
+
import { readdir } from "fs/promises";
|
|
1926
|
+
|
|
1927
|
+
// src/fs-read.ts
|
|
1928
|
+
import { open } from "fs/promises";
|
|
1929
|
+
import { openSync, readSync, closeSync, fstatSync } from "fs";
|
|
1930
|
+
async function readTextFile(filePath) {
|
|
1931
|
+
const fh = await open(filePath, "r");
|
|
1932
|
+
try {
|
|
1933
|
+
const buf = Buffer.alloc((await fh.stat()).size);
|
|
1934
|
+
await fh.read(buf, 0, buf.length, 0);
|
|
1935
|
+
return buf.toString("utf-8");
|
|
1936
|
+
} finally {
|
|
1937
|
+
await fh.close();
|
|
1938
|
+
}
|
|
1939
|
+
}
|
|
1940
|
+
function readTextFileSync(filePath) {
|
|
1941
|
+
const fd = openSync(filePath, "r");
|
|
1942
|
+
try {
|
|
1943
|
+
const buf = Buffer.alloc(fstatSync(fd).size);
|
|
1944
|
+
readSync(fd, buf);
|
|
1945
|
+
return buf.toString("utf-8");
|
|
1946
|
+
} finally {
|
|
1947
|
+
closeSync(fd);
|
|
1948
|
+
}
|
|
1949
|
+
}
|
|
1950
|
+
|
|
1951
|
+
// src/stats.ts
|
|
1938
1952
|
import { join as join3 } from "path";
|
|
1939
1953
|
import { homedir as homedir2 } from "os";
|
|
1940
1954
|
|
|
@@ -1953,7 +1967,7 @@ var USER_AGENT = `clawrouter/${VERSION}`;
|
|
|
1953
1967
|
var LOG_DIR2 = join3(homedir2(), ".openclaw", "blockrun", "logs");
|
|
1954
1968
|
async function parseLogFile(filePath) {
|
|
1955
1969
|
try {
|
|
1956
|
-
const content = await
|
|
1970
|
+
const content = await readTextFile(filePath);
|
|
1957
1971
|
const lines = content.trim().split("\n").filter(Boolean);
|
|
1958
1972
|
return lines.map((line) => {
|
|
1959
1973
|
const entry = JSON.parse(line);
|
|
@@ -5204,7 +5218,7 @@ async function proxyRequest(req, res, apiBase, payFetch, options, routerOpts, de
|
|
|
5204
5218
|
}
|
|
5205
5219
|
|
|
5206
5220
|
// src/auth.ts
|
|
5207
|
-
import { writeFile,
|
|
5221
|
+
import { writeFile, mkdir as mkdir2 } from "fs/promises";
|
|
5208
5222
|
import { join as join4 } from "path";
|
|
5209
5223
|
import { homedir as homedir3 } from "os";
|
|
5210
5224
|
import { generatePrivateKey, privateKeyToAccount as privateKeyToAccount3 } from "viem/accounts";
|
|
@@ -5212,7 +5226,7 @@ var WALLET_DIR = join4(homedir3(), ".openclaw", "blockrun");
|
|
|
5212
5226
|
var WALLET_FILE = join4(WALLET_DIR, "wallet.key");
|
|
5213
5227
|
async function loadSavedWallet() {
|
|
5214
5228
|
try {
|
|
5215
|
-
const key = (await
|
|
5229
|
+
const key = (await readTextFile(WALLET_FILE)).trim();
|
|
5216
5230
|
if (key.startsWith("0x") && key.length === 66) {
|
|
5217
5231
|
console.log(`[ClawRouter] \u2713 Loaded existing wallet from ${WALLET_FILE}`);
|
|
5218
5232
|
return key;
|
|
@@ -5233,7 +5247,7 @@ async function generateAndSaveWallet() {
|
|
|
5233
5247
|
await mkdir2(WALLET_DIR, { recursive: true });
|
|
5234
5248
|
await writeFile(WALLET_FILE, key + "\n", { mode: 384 });
|
|
5235
5249
|
try {
|
|
5236
|
-
const verification = (await
|
|
5250
|
+
const verification = (await readTextFile(WALLET_FILE)).trim();
|
|
5237
5251
|
if (verification !== key) {
|
|
5238
5252
|
throw new Error("Wallet file verification failed - content mismatch");
|
|
5239
5253
|
}
|
|
@@ -5262,7 +5276,6 @@ async function resolveOrGenerateWalletKey() {
|
|
|
5262
5276
|
|
|
5263
5277
|
// src/index.ts
|
|
5264
5278
|
import {
|
|
5265
|
-
readFileSync,
|
|
5266
5279
|
writeFileSync,
|
|
5267
5280
|
existsSync,
|
|
5268
5281
|
readdirSync,
|
|
@@ -5369,7 +5382,7 @@ function injectModelsConfig(logger) {
|
|
|
5369
5382
|
}
|
|
5370
5383
|
if (existsSync(configPath)) {
|
|
5371
5384
|
try {
|
|
5372
|
-
const content =
|
|
5385
|
+
const content = readTextFileSync(configPath).trim();
|
|
5373
5386
|
if (content) {
|
|
5374
5387
|
config = JSON.parse(content);
|
|
5375
5388
|
} else {
|
|
@@ -5561,7 +5574,7 @@ function injectAuthProfile(logger) {
|
|
|
5561
5574
|
};
|
|
5562
5575
|
if (existsSync(authPath)) {
|
|
5563
5576
|
try {
|
|
5564
|
-
const existing = JSON.parse(
|
|
5577
|
+
const existing = JSON.parse(readTextFileSync(authPath));
|
|
5565
5578
|
if (existing.version && existing.profiles) {
|
|
5566
5579
|
store = existing;
|
|
5567
5580
|
}
|
|
@@ -5680,7 +5693,7 @@ async function createWalletCommand() {
|
|
|
5680
5693
|
let address;
|
|
5681
5694
|
try {
|
|
5682
5695
|
if (existsSync(WALLET_FILE)) {
|
|
5683
|
-
walletKey =
|
|
5696
|
+
walletKey = readTextFileSync(WALLET_FILE).trim();
|
|
5684
5697
|
if (walletKey.startsWith("0x") && walletKey.length === 66) {
|
|
5685
5698
|
const account = privateKeyToAccount4(walletKey);
|
|
5686
5699
|
address = account.address;
|