yymaxapi 1.0.19 → 1.0.21
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/bin/yymaxapi.js +37 -0
- package/package.json +1 -1
package/bin/yymaxapi.js
CHANGED
|
@@ -490,6 +490,34 @@ function getConfigPath() {
|
|
|
490
490
|
);
|
|
491
491
|
}
|
|
492
492
|
|
|
493
|
+
// Windows + WSL: 尝试读取 WSL 内的配置文件
|
|
494
|
+
if (process.platform === 'win32' && isWslAvailable()) {
|
|
495
|
+
try {
|
|
496
|
+
const wslHome = getWslHome() || '/root';
|
|
497
|
+
const wslPaths = [
|
|
498
|
+
`${wslHome}/.openclaw/openclaw.json`,
|
|
499
|
+
`${wslHome}/.openclaw/moltbot.json`,
|
|
500
|
+
`${wslHome}/.clawdbot/openclaw.json`,
|
|
501
|
+
'/root/.openclaw/openclaw.json',
|
|
502
|
+
'/root/.openclaw/moltbot.json',
|
|
503
|
+
];
|
|
504
|
+
for (const wp of wslPaths) {
|
|
505
|
+
const check = safeExec(`wsl -- bash -c "test -f '${wp}' && echo yes"`, { timeout: 5000 });
|
|
506
|
+
if (check.ok && check.output.trim() === 'yes') {
|
|
507
|
+
// 将 WSL 配置复制到 Windows 侧,保持同步
|
|
508
|
+
const winDest = path.join(openclawStateDir, path.basename(wp));
|
|
509
|
+
try {
|
|
510
|
+
const content = execFileSync('wsl', ['bash', '-c', `cat '${wp}'`], { encoding: 'utf8', timeout: 10000 });
|
|
511
|
+
if (!fs.existsSync(openclawStateDir)) fs.mkdirSync(openclawStateDir, { recursive: true });
|
|
512
|
+
fs.writeFileSync(winDest, content, 'utf8');
|
|
513
|
+
if (!candidates.includes(winDest)) candidates.unshift(winDest);
|
|
514
|
+
} catch {}
|
|
515
|
+
break;
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
} catch {}
|
|
519
|
+
}
|
|
520
|
+
|
|
493
521
|
const defaultConfig = preferMoltbot
|
|
494
522
|
? path.join(moltbotPrimaryDir, 'moltbot.json')
|
|
495
523
|
: path.join(openclawStateDir, 'openclaw.json');
|
|
@@ -636,6 +664,15 @@ function detectGatewayEnv(port = 18789) {
|
|
|
636
664
|
}
|
|
637
665
|
}
|
|
638
666
|
} catch {}
|
|
667
|
+
// Fallback: Windows 没有原生 OpenClaw CLI,但 WSL 里有 → 判定为 WSL
|
|
668
|
+
const nativeCli = resolveCliBinary();
|
|
669
|
+
if (!nativeCli) {
|
|
670
|
+
const wslCli = getWslCliBinary();
|
|
671
|
+
if (wslCli) {
|
|
672
|
+
_gwEnvCache = 'wsl';
|
|
673
|
+
return 'wsl';
|
|
674
|
+
}
|
|
675
|
+
}
|
|
639
676
|
_gwEnvCache = 'native';
|
|
640
677
|
return 'native';
|
|
641
678
|
}
|