yymaxapi 1.0.9 → 1.0.10
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 +64 -8
- package/package.json +1 -1
package/bin/yymaxapi.js
CHANGED
|
@@ -2200,19 +2200,28 @@ async function testConnection(paths, args = {}) {
|
|
|
2200
2200
|
|
|
2201
2201
|
const allowAutoDaemon = !(args['no-daemon'] || args.noDaemon);
|
|
2202
2202
|
|
|
2203
|
-
// 步骤0:
|
|
2203
|
+
// 步骤0: 清理所有挂死的 agent 进程(不限于 yymaxapi-test)
|
|
2204
2204
|
try {
|
|
2205
2205
|
const { execSync } = require('child_process');
|
|
2206
2206
|
const platform = process.platform;
|
|
2207
2207
|
if (platform === 'win32') {
|
|
2208
|
-
|
|
2208
|
+
// Windows: 用 wmic 精确匹配 agent 子进程(排除 gateway)
|
|
2209
|
+
for (const name of ['openclaw', 'clawdbot', 'moltbot']) {
|
|
2210
|
+
try {
|
|
2211
|
+
execSync(`wmic process where "commandline like '%${name}%agent%' and not commandline like '%gateway%'" call terminate 2>nul`, { stdio: 'ignore', timeout: 10000 });
|
|
2212
|
+
} catch { /* ignore */ }
|
|
2213
|
+
}
|
|
2214
|
+
// fallback: 杀掉所有 Not Responding 的 node 进程
|
|
2215
|
+
try {
|
|
2216
|
+
execSync('taskkill /F /FI "IMAGENAME eq node.exe" /FI "STATUS eq Not Responding" 2>nul', { stdio: 'ignore' });
|
|
2217
|
+
} catch { /* ignore */ }
|
|
2209
2218
|
} else {
|
|
2210
|
-
//
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2219
|
+
// Unix: 杀掉所有 openclaw/clawdbot/moltbot agent 子进程(排除 gateway)
|
|
2220
|
+
for (const name of ['openclaw', 'clawdbot', 'moltbot']) {
|
|
2221
|
+
execSync(`pkill -f '${name}.*agent' 2>/dev/null || true`, { stdio: 'ignore' });
|
|
2222
|
+
}
|
|
2214
2223
|
}
|
|
2215
|
-
console.log(chalk.gray('
|
|
2224
|
+
console.log(chalk.gray('已清理残留 agent 进程'));
|
|
2216
2225
|
} catch { /* ignore */ }
|
|
2217
2226
|
|
|
2218
2227
|
// 步骤1: 先重启 Gateway 使配置生效
|
|
@@ -2952,10 +2961,57 @@ async function installOrUpdateOpenClaw() {
|
|
|
2952
2961
|
spinner.succeed(`OpenClaw ${actionLabel}完成`);
|
|
2953
2962
|
|
|
2954
2963
|
// 显示新版本
|
|
2955
|
-
const
|
|
2964
|
+
const cliBin = cliBinary || (process.platform === 'win32' ? 'openclaw.cmd' : 'openclaw');
|
|
2965
|
+
const newV = safeExec(`"${cliBin}" --version`);
|
|
2956
2966
|
if (newV.ok) {
|
|
2957
2967
|
console.log(chalk.green(` 版本: ${newV.output.trim()}`));
|
|
2958
2968
|
}
|
|
2969
|
+
|
|
2970
|
+
// 安装后自动 onboard — 初始化数据目录和配置
|
|
2971
|
+
const homeDir = os.homedir();
|
|
2972
|
+
const configFile = path.join(homeDir, '.openclaw', 'openclaw.json');
|
|
2973
|
+
|
|
2974
|
+
// 如果配置文件存在但内容无效,先备份移除
|
|
2975
|
+
if (fs.existsSync(configFile)) {
|
|
2976
|
+
try {
|
|
2977
|
+
const raw = fs.readFileSync(configFile, 'utf8').trim();
|
|
2978
|
+
if (raw && !raw.startsWith('{') && !raw.startsWith('[')) {
|
|
2979
|
+
const badBak = configFile + '.bad.' + Date.now();
|
|
2980
|
+
fs.renameSync(configFile, badBak);
|
|
2981
|
+
console.log(chalk.yellow(`\n⚠ 配置文件格式异常,已备份到: ${path.basename(badBak)}`));
|
|
2982
|
+
} else if (raw) {
|
|
2983
|
+
JSON5.parse(raw); // 验证 JSON 合法性
|
|
2984
|
+
}
|
|
2985
|
+
} catch {
|
|
2986
|
+
const badBak = configFile + '.bad.' + Date.now();
|
|
2987
|
+
try { fs.renameSync(configFile, badBak); } catch { /* ignore */ }
|
|
2988
|
+
console.log(chalk.yellow(`\n⚠ 配置文件解析失败,已备份移除`));
|
|
2989
|
+
}
|
|
2990
|
+
}
|
|
2991
|
+
|
|
2992
|
+
// 运行 onboard 初始化
|
|
2993
|
+
console.log(chalk.cyan('\n正在初始化 OpenClaw...'));
|
|
2994
|
+
const onboardCmd = process.platform === 'win32'
|
|
2995
|
+
? `"${cliBin}" onboard --non-interactive --accept-risk`
|
|
2996
|
+
: `"${cliBin}" onboard --non-interactive --accept-risk 2>/dev/null || true`;
|
|
2997
|
+
const onboardResult = safeExec(onboardCmd, { timeout: 60000 });
|
|
2998
|
+
if (onboardResult.ok) {
|
|
2999
|
+
console.log(chalk.green('✅ OpenClaw 初始化完成'));
|
|
3000
|
+
// 显示数据目录位置
|
|
3001
|
+
const dataDirs = [
|
|
3002
|
+
path.join(homeDir, '.openclaw'),
|
|
3003
|
+
path.join(homeDir, '.clawdbot'),
|
|
3004
|
+
path.join(homeDir, '.moltbot'),
|
|
3005
|
+
].filter(d => fs.existsSync(d));
|
|
3006
|
+
if (dataDirs.length > 0) {
|
|
3007
|
+
console.log(chalk.gray(` 数据目录: ${dataDirs[0]}`));
|
|
3008
|
+
}
|
|
3009
|
+
} else {
|
|
3010
|
+
console.log(chalk.yellow('⚠ 自动初始化未成功,请手动运行: openclaw onboard'));
|
|
3011
|
+
if (onboardResult.output) {
|
|
3012
|
+
console.log(chalk.gray(` ${onboardResult.output.split('\n')[0]}`));
|
|
3013
|
+
}
|
|
3014
|
+
}
|
|
2959
3015
|
} catch (error) {
|
|
2960
3016
|
spinner.fail(`${actionLabel}失败`);
|
|
2961
3017
|
console.log(chalk.red(` 错误: ${error.message}`));
|