@blockrun/clawrouter 0.9.1 → 0.9.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.
- package/dist/index.js +21 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4562,7 +4562,15 @@ async function resolveOrGenerateWalletKey() {
|
|
|
4562
4562
|
}
|
|
4563
4563
|
|
|
4564
4564
|
// src/index.ts
|
|
4565
|
-
import {
|
|
4565
|
+
import {
|
|
4566
|
+
readFileSync,
|
|
4567
|
+
writeFileSync,
|
|
4568
|
+
existsSync,
|
|
4569
|
+
readdirSync,
|
|
4570
|
+
mkdirSync,
|
|
4571
|
+
copyFileSync,
|
|
4572
|
+
renameSync
|
|
4573
|
+
} from "fs";
|
|
4566
4574
|
import { homedir as homedir4 } from "os";
|
|
4567
4575
|
import { join as join5 } from "path";
|
|
4568
4576
|
import { privateKeyToAccount as privateKeyToAccount4 } from "viem/accounts";
|
|
@@ -4670,11 +4678,17 @@ function injectModelsConfig(logger) {
|
|
|
4670
4678
|
needsWrite = true;
|
|
4671
4679
|
}
|
|
4672
4680
|
} catch (err) {
|
|
4681
|
+
const backupPath = `${configPath}.backup.${Date.now()}`;
|
|
4682
|
+
try {
|
|
4683
|
+
copyFileSync(configPath, backupPath);
|
|
4684
|
+
logger.info(`Config parse failed, backed up to ${backupPath}`);
|
|
4685
|
+
} catch {
|
|
4686
|
+
logger.info("Config parse failed, could not create backup");
|
|
4687
|
+
}
|
|
4673
4688
|
logger.info(
|
|
4674
|
-
`
|
|
4689
|
+
`Skipping config injection (corrupt file): ${err instanceof Error ? err.message : String(err)}`
|
|
4675
4690
|
);
|
|
4676
|
-
|
|
4677
|
-
needsWrite = true;
|
|
4691
|
+
return;
|
|
4678
4692
|
}
|
|
4679
4693
|
} else {
|
|
4680
4694
|
logger.info("OpenClaw config not found, creating");
|
|
@@ -4788,7 +4802,9 @@ function injectModelsConfig(logger) {
|
|
|
4788
4802
|
}
|
|
4789
4803
|
if (needsWrite) {
|
|
4790
4804
|
try {
|
|
4791
|
-
|
|
4805
|
+
const tmpPath = `${configPath}.tmp.${process.pid}`;
|
|
4806
|
+
writeFileSync(tmpPath, JSON.stringify(config, null, 2));
|
|
4807
|
+
renameSync(tmpPath, configPath);
|
|
4792
4808
|
logger.info("Smart routing enabled (blockrun/auto)");
|
|
4793
4809
|
} catch (err) {
|
|
4794
4810
|
logger.info(`Failed to write config: ${err instanceof Error ? err.message : String(err)}`);
|