@blockrun/clawrouter 0.9.1 → 0.9.3
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 +2 -0
- package/dist/cli.js.map +1 -1
- package/dist/index.js +23 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3391,6 +3391,8 @@ var FALLBACK_STATUS_CODES = [
|
|
|
3391
3391
|
// Payment required - but from upstream, not x402
|
|
3392
3392
|
403,
|
|
3393
3393
|
// Forbidden - provider restrictions
|
|
3394
|
+
413,
|
|
3395
|
+
// Payload too large - request exceeds model's context limit
|
|
3394
3396
|
429,
|
|
3395
3397
|
// Rate limited
|
|
3396
3398
|
500,
|
|
@@ -4562,7 +4564,15 @@ async function resolveOrGenerateWalletKey() {
|
|
|
4562
4564
|
}
|
|
4563
4565
|
|
|
4564
4566
|
// src/index.ts
|
|
4565
|
-
import {
|
|
4567
|
+
import {
|
|
4568
|
+
readFileSync,
|
|
4569
|
+
writeFileSync,
|
|
4570
|
+
existsSync,
|
|
4571
|
+
readdirSync,
|
|
4572
|
+
mkdirSync,
|
|
4573
|
+
copyFileSync,
|
|
4574
|
+
renameSync
|
|
4575
|
+
} from "fs";
|
|
4566
4576
|
import { homedir as homedir4 } from "os";
|
|
4567
4577
|
import { join as join5 } from "path";
|
|
4568
4578
|
import { privateKeyToAccount as privateKeyToAccount4 } from "viem/accounts";
|
|
@@ -4670,11 +4680,17 @@ function injectModelsConfig(logger) {
|
|
|
4670
4680
|
needsWrite = true;
|
|
4671
4681
|
}
|
|
4672
4682
|
} catch (err) {
|
|
4683
|
+
const backupPath = `${configPath}.backup.${Date.now()}`;
|
|
4684
|
+
try {
|
|
4685
|
+
copyFileSync(configPath, backupPath);
|
|
4686
|
+
logger.info(`Config parse failed, backed up to ${backupPath}`);
|
|
4687
|
+
} catch {
|
|
4688
|
+
logger.info("Config parse failed, could not create backup");
|
|
4689
|
+
}
|
|
4673
4690
|
logger.info(
|
|
4674
|
-
`
|
|
4691
|
+
`Skipping config injection (corrupt file): ${err instanceof Error ? err.message : String(err)}`
|
|
4675
4692
|
);
|
|
4676
|
-
|
|
4677
|
-
needsWrite = true;
|
|
4693
|
+
return;
|
|
4678
4694
|
}
|
|
4679
4695
|
} else {
|
|
4680
4696
|
logger.info("OpenClaw config not found, creating");
|
|
@@ -4788,7 +4804,9 @@ function injectModelsConfig(logger) {
|
|
|
4788
4804
|
}
|
|
4789
4805
|
if (needsWrite) {
|
|
4790
4806
|
try {
|
|
4791
|
-
|
|
4807
|
+
const tmpPath = `${configPath}.tmp.${process.pid}`;
|
|
4808
|
+
writeFileSync(tmpPath, JSON.stringify(config, null, 2));
|
|
4809
|
+
renameSync(tmpPath, configPath);
|
|
4792
4810
|
logger.info("Smart routing enabled (blockrun/auto)");
|
|
4793
4811
|
} catch (err) {
|
|
4794
4812
|
logger.info(`Failed to write config: ${err instanceof Error ? err.message : String(err)}`);
|