@blockrun/clawrouter 0.12.20 → 0.12.22
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 +26 -2
- package/dist/cli.js.map +1 -1
- package/dist/index.js +9 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -3867,6 +3867,10 @@ async function recoverWalletFromMnemonic() {
|
|
|
3867
3867
|
console.log(`[ClawRouter] Run: npx @blockrun/clawrouter`);
|
|
3868
3868
|
console.log(`[ClawRouter]`);
|
|
3869
3869
|
}
|
|
3870
|
+
async function savePaymentChain(chain) {
|
|
3871
|
+
await mkdir2(WALLET_DIR, { recursive: true });
|
|
3872
|
+
await writeFile(CHAIN_FILE, chain + "\n", { mode: 384 });
|
|
3873
|
+
}
|
|
3870
3874
|
async function loadPaymentChain() {
|
|
3871
3875
|
try {
|
|
3872
3876
|
const content = (await readTextFile(CHAIN_FILE)).trim();
|
|
@@ -5632,8 +5636,12 @@ async function startProxy(options) {
|
|
|
5632
5636
|
const apiBase = options.apiBase ?? (paymentChain === "solana" && solanaPrivateKeyBytes ? BLOCKRUN_SOLANA_API : BLOCKRUN_API);
|
|
5633
5637
|
if (paymentChain === "solana" && !solanaPrivateKeyBytes) {
|
|
5634
5638
|
console.warn(
|
|
5635
|
-
`[ClawRouter] Payment chain is Solana but no
|
|
5639
|
+
`[ClawRouter] \u26A0 Payment chain is Solana but no mnemonic found \u2014 falling back to Base (EVM).`
|
|
5640
|
+
);
|
|
5641
|
+
console.warn(
|
|
5642
|
+
`[ClawRouter] To fix: run "npx @blockrun/clawrouter wallet recover" if your mnemonic exists,`
|
|
5636
5643
|
);
|
|
5644
|
+
console.warn(`[ClawRouter] or run "npx @blockrun/clawrouter chain base" to switch to EVM.`);
|
|
5637
5645
|
} else if (paymentChain === "solana") {
|
|
5638
5646
|
console.log(`[ClawRouter] Payment chain: Solana (${BLOCKRUN_SOLANA_API})`);
|
|
5639
5647
|
}
|
|
@@ -6038,7 +6046,10 @@ async function tryModelRequest(upstreamUrl, method, headers, body, modelId, maxT
|
|
|
6038
6046
|
const contentType = response.headers.get("content-type") || "";
|
|
6039
6047
|
if (contentType.includes("json") || contentType.includes("text")) {
|
|
6040
6048
|
try {
|
|
6041
|
-
const clonedChunks = await readBodyWithTimeout(
|
|
6049
|
+
const clonedChunks = await readBodyWithTimeout(
|
|
6050
|
+
response.clone().body,
|
|
6051
|
+
ERROR_BODY_READ_TIMEOUT_MS
|
|
6052
|
+
);
|
|
6042
6053
|
const responseBody = Buffer.concat(clonedChunks).toString();
|
|
6043
6054
|
const degradedReason = detectDegradedSuccessResponse(responseBody);
|
|
6044
6055
|
if (degradedReason) {
|
|
@@ -7612,6 +7623,8 @@ Commands:
|
|
|
7612
7623
|
partners List available partner APIs with pricing
|
|
7613
7624
|
partners test Test partner API endpoints (expect 402 = alive)
|
|
7614
7625
|
wallet recover Restore wallet.key from mnemonic (if generated by ClawRouter)
|
|
7626
|
+
chain solana Switch payment chain to Solana (persists across restarts)
|
|
7627
|
+
chain base Switch payment chain to Base EVM (persists across restarts)
|
|
7615
7628
|
|
|
7616
7629
|
Examples:
|
|
7617
7630
|
# Start standalone proxy
|
|
@@ -7647,6 +7660,7 @@ function parseArgs(args) {
|
|
|
7647
7660
|
reportPeriod: "daily",
|
|
7648
7661
|
reportJson: false,
|
|
7649
7662
|
walletRecover: false,
|
|
7663
|
+
chain: void 0,
|
|
7650
7664
|
port: void 0
|
|
7651
7665
|
};
|
|
7652
7666
|
for (let i = 0; i < args.length; i++) {
|
|
@@ -7680,6 +7694,9 @@ function parseArgs(args) {
|
|
|
7680
7694
|
} else if (arg === "wallet" && args[i + 1] === "recover") {
|
|
7681
7695
|
result.walletRecover = true;
|
|
7682
7696
|
i++;
|
|
7697
|
+
} else if (arg === "chain" && (args[i + 1] === "solana" || args[i + 1] === "base")) {
|
|
7698
|
+
result.chain = args[i + 1];
|
|
7699
|
+
i++;
|
|
7683
7700
|
} else if (arg === "--port" && args[i + 1]) {
|
|
7684
7701
|
result.port = parseInt(args[i + 1], 10);
|
|
7685
7702
|
i++;
|
|
@@ -7754,6 +7771,13 @@ ClawRouter Partner APIs (v${VERSION})
|
|
|
7754
7771
|
await recoverWalletFromMnemonic();
|
|
7755
7772
|
process.exit(0);
|
|
7756
7773
|
}
|
|
7774
|
+
if (args.chain) {
|
|
7775
|
+
await savePaymentChain(args.chain);
|
|
7776
|
+
console.log(`[ClawRouter] Payment chain set to: ${args.chain}`);
|
|
7777
|
+
console.log(`[ClawRouter] This persists across restarts.`);
|
|
7778
|
+
console.log(`[ClawRouter] Run: npx @blockrun/clawrouter`);
|
|
7779
|
+
process.exit(0);
|
|
7780
|
+
}
|
|
7757
7781
|
if (args.report) {
|
|
7758
7782
|
const report = await generateReport(args.reportPeriod, args.reportJson);
|
|
7759
7783
|
console.log(report);
|