yymaxapi 1.0.13 → 1.0.15

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.
Files changed (2) hide show
  1. package/bin/yymaxapi.js +18 -8
  2. package/package.json +1 -1
package/bin/yymaxapi.js CHANGED
@@ -614,11 +614,11 @@ function detectGatewayEnv(port = 18789) {
614
614
  return 'native';
615
615
  }
616
616
 
617
- // 在 Gateway 环境中执行命令(WSL 自动包裹 wsl -- bash -c
617
+ // 在 Gateway 环境中执行命令(WSL 自动包裹 wsl -- bash -lc
618
618
  function execInGatewayEnv(cmd, options = {}) {
619
619
  if (detectGatewayEnv() === 'wsl') {
620
620
  const escaped = cmd.replace(/'/g, "'\\''");
621
- return safeExec(`wsl -- bash -c '${escaped}'`, options);
621
+ return safeExec(`wsl -- bash -lc '${escaped}'`, options);
622
622
  }
623
623
  return safeExec(cmd, options);
624
624
  }
@@ -627,7 +627,7 @@ function execInGatewayEnv(cmd, options = {}) {
627
627
  function execAsyncInGatewayEnv(cmd, options = {}) {
628
628
  if (detectGatewayEnv() === 'wsl') {
629
629
  const escaped = cmd.replace(/'/g, "'\\''");
630
- return { cmd: `wsl -- bash -c '${escaped}'`, options };
630
+ return { cmd: `wsl -- bash -lc '${escaped}'`, options };
631
631
  }
632
632
  return { cmd, options };
633
633
  }
@@ -662,7 +662,7 @@ function cleanupAgentProcesses() {
662
662
  // WSL 内的 agent 也要清理
663
663
  if (detectGatewayEnv() === 'wsl') {
664
664
  try {
665
- execSync('wsl -- bash -c "pkill -f \'openclaw.*agent\' 2>/dev/null; pkill -f \'clawdbot.*agent\' 2>/dev/null; pkill -f \'moltbot.*agent\' 2>/dev/null; true"', { stdio: 'ignore', timeout: 10000 });
665
+ execSync('wsl -- bash -lc "pkill -f \'openclaw.*agent\' 2>/dev/null; pkill -f \'clawdbot.*agent\' 2>/dev/null; pkill -f \'moltbot.*agent\' 2>/dev/null; true"', { stdio: 'ignore', timeout: 10000 });
666
666
  } catch { /* ignore */ }
667
667
  }
668
668
  } else {
@@ -980,8 +980,16 @@ function resolveCliBinary() {
980
980
  // Validate that a found binary is a real gateway CLI, not yymaxapi itself
981
981
  function isRealCli(filePath) {
982
982
  try {
983
+ // Windows 上跳过 Linux 路径(WSL 路径在 Windows cmd.exe 下无法执行)
984
+ if (process.platform === 'win32' && filePath.startsWith('/')) {
985
+ return false;
986
+ }
983
987
  // Resolve symlinks to get the real target
984
988
  const realPath = fs.realpathSync(filePath);
989
+ // Windows 上再次检查解析后的路径
990
+ if (process.platform === 'win32' && realPath.startsWith('/')) {
991
+ return false;
992
+ }
985
993
  const baseName = path.basename(realPath).toLowerCase();
986
994
  // Skip if it points to yymaxapi/openclawapi (our own config tool, not the gateway CLI)
987
995
  if (baseName === 'yymaxapi' || baseName === 'yymaxapi.js' || realPath.includes('yymaxapi') || baseName === 'openclawapi' || baseName === 'openclawapi.js' || realPath.includes('openclawapi')) {
@@ -1139,6 +1147,8 @@ function findCompatibleNode(minMajor = 22) {
1139
1147
  const seen = new Set();
1140
1148
  for (const candidate of candidates) {
1141
1149
  if (!candidate || seen.has(candidate)) continue;
1150
+ // Windows 上跳过 Linux 路径(WSL 路径无法直接执行)
1151
+ if (process.platform === 'win32' && candidate.startsWith('/')) continue;
1142
1152
  seen.add(candidate);
1143
1153
  try {
1144
1154
  if (!fs.existsSync(candidate)) continue;
@@ -2481,9 +2491,9 @@ async function restartGateway() {
2481
2491
  console.log(chalk.gray(' [检测] Gateway 运行在 WSL 中'));
2482
2492
  return new Promise((resolve) => {
2483
2493
  const wslCmds = [
2484
- 'wsl -- bash -c "openclaw gateway restart"',
2485
- 'wsl -- bash -c "clawdbot gateway restart"',
2486
- 'wsl -- bash -c "moltbot gateway restart"',
2494
+ 'wsl -- bash -lc "openclaw gateway restart"',
2495
+ 'wsl -- bash -lc "clawdbot gateway restart"',
2496
+ 'wsl -- bash -lc "moltbot gateway restart"',
2487
2497
  ];
2488
2498
  let tried = 0;
2489
2499
  const tryNext = () => {
@@ -2661,7 +2671,7 @@ function testGatewayViaAgent(model) {
2661
2671
  if (gwEnv === 'wsl') {
2662
2672
  // Gateway 在 WSL 中,agent 也要在 WSL 中执行
2663
2673
  const agentCmd = `openclaw agent --session-id ${sessionId} --message "请回复你的模型名称" --json --timeout 120 2>/dev/null || clawdbot agent --session-id ${sessionId} --message "请回复你的模型名称" --json --timeout 120 2>/dev/null || moltbot agent --session-id ${sessionId} --message "请回复你的模型名称" --json --timeout 120`;
2664
- cmd = `wsl -- bash -c '${agentCmd.replace(/'/g, "'\\''")}'`;
2674
+ cmd = `wsl -- bash -lc '${agentCmd.replace(/'/g, "'\\''")}'`;
2665
2675
  execOpts = { timeout: 120000 };
2666
2676
  } else {
2667
2677
  const { cliBinary, nodeMajor } = getCliMeta();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yymaxapi",
3
- "version": "1.0.13",
3
+ "version": "1.0.15",
4
4
  "description": "跨平台 OpenClaw/Clawdbot 配置管理工具 - 管理中转地址、模型切换、API Keys、测速优化",
5
5
  "main": "bin/yymaxapi.js",
6
6
  "bin": {