yymaxapi 1.0.18 → 1.0.20
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 +62 -18
- 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');
|
|
@@ -3040,28 +3068,44 @@ async function autoInstallGitWindows() {
|
|
|
3040
3068
|
}
|
|
3041
3069
|
}
|
|
3042
3070
|
|
|
3043
|
-
// 方式2: 下载 Git
|
|
3071
|
+
// 方式2: 下载 Git 安装包(优先国内镜像,fallback GitHub)
|
|
3044
3072
|
const spinner = ora({ text: '正在获取 Git 最新版本...', spinner: 'dots' }).start();
|
|
3045
3073
|
const installerPath = path.join(os.tmpdir(), 'git-installer.exe');
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
|
|
3051
|
-
|
|
3052
|
-
|
|
3053
|
-
|
|
3054
|
-
|
|
3055
|
-
|
|
3056
|
-
|
|
3074
|
+
const GIT_VER = '2.48.1';
|
|
3075
|
+
const fileName = `Git-${GIT_VER}-64-bit.exe`;
|
|
3076
|
+
const mirrors = [
|
|
3077
|
+
`https://registry.npmmirror.com/-/binary/git-for-windows/v${GIT_VER}.windows.1/${fileName}`,
|
|
3078
|
+
`https://github.com/git-for-windows/git/releases/download/v${GIT_VER}.windows.1/${fileName}`,
|
|
3079
|
+
];
|
|
3080
|
+
let downloadUrl = mirrors[0];
|
|
3081
|
+
spinner.text = `正在下载 Git ${GIT_VER}(国内镜像)...`;
|
|
3082
|
+
|
|
3083
|
+
let downloaded = false;
|
|
3084
|
+
for (let i = 0; i < mirrors.length; i++) {
|
|
3085
|
+
downloadUrl = mirrors[i];
|
|
3086
|
+
if (i > 0) spinner.text = `正在下载 Git ${GIT_VER}(GitHub)...`;
|
|
3087
|
+
try {
|
|
3088
|
+
execSync(`powershell -Command "Invoke-WebRequest -Uri '${downloadUrl}' -OutFile '${installerPath}'"`, {
|
|
3089
|
+
stdio: 'pipe', timeout: 300000
|
|
3090
|
+
});
|
|
3091
|
+
downloaded = true;
|
|
3092
|
+
break;
|
|
3093
|
+
} catch (e) {
|
|
3094
|
+
if (i < mirrors.length - 1) {
|
|
3095
|
+
spinner.text = '国内镜像下载失败,切换 GitHub...';
|
|
3096
|
+
}
|
|
3097
|
+
}
|
|
3057
3098
|
}
|
|
3058
3099
|
|
|
3059
|
-
|
|
3060
|
-
|
|
3061
|
-
|
|
3062
|
-
|
|
3063
|
-
|
|
3100
|
+
if (!downloaded) {
|
|
3101
|
+
spinner.fail('Git 下载失败(所有镜像均不可达)');
|
|
3102
|
+
console.log(chalk.cyan(' 请手动安装: https://git-scm.com/download/win'));
|
|
3103
|
+
return false;
|
|
3104
|
+
}
|
|
3105
|
+
|
|
3106
|
+
spinner.succeed('Git 安装包下载完成');
|
|
3064
3107
|
|
|
3108
|
+
try {
|
|
3065
3109
|
const installSpinner = ora({ text: '正在静默安装 Git...', spinner: 'dots' }).start();
|
|
3066
3110
|
execSync(`"${installerPath}" /VERYSILENT /NORESTART /NOCANCEL /SP- /CLOSEAPPLICATIONS /RESTARTAPPLICATIONS /COMPONENTS="icons,ext\\reg\\shellhere,assoc,assoc_sh"`, {
|
|
3067
3111
|
stdio: 'pipe', timeout: 300000
|
|
@@ -3070,7 +3114,7 @@ async function autoInstallGitWindows() {
|
|
|
3070
3114
|
console.log(chalk.yellow(' 请关闭当前终端,重新打开后再运行此工具'));
|
|
3071
3115
|
return false;
|
|
3072
3116
|
} catch (e) {
|
|
3073
|
-
spinner.fail('Git
|
|
3117
|
+
spinner.fail('Git 安装失败');
|
|
3074
3118
|
console.log(chalk.cyan(' 请手动安装: https://git-scm.com/download/win'));
|
|
3075
3119
|
return false;
|
|
3076
3120
|
}
|