@aiyiran/myclaw 1.1.22 → 1.1.24

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.
@@ -31,8 +31,14 @@
31
31
  var cachedData = null;
32
32
  var pollTimer = null;
33
33
  var lastKnownClawName = null; // 本地环境下从 API 获取,remote 环境每次从 hostname 实时派生
34
- var MYCLAW_API_PORT = 18800;
35
- var MYCLAW_API_BASE = 'http://127.0.0.1:' + MYCLAW_API_PORT;
34
+ var MYCLAW_API_PORT = 8080;
35
+ // 远程环境(公网域名):nginx 已将 /sync 反代到 127.0.0.1:8080,直接同域访问
36
+ // 本地环境:直接访问 127.0.0.1:8080
37
+ var MYCLAW_API_BASE = (function () {
38
+ var h = window.location.hostname;
39
+ var isRemote = h === 'claw.yiranlaoshi.com' || h.endsWith('.kekouen.cn');
40
+ return isRemote ? window.location.origin + '/sync' : 'http://127.0.0.1:' + MYCLAW_API_PORT;
41
+ })();
36
42
 
37
43
  // ═══ 工具:从 URL 解析 agent 名称 ═══
38
44
  function getAgentName() {
package/index.js CHANGED
@@ -1837,23 +1837,6 @@ async function runServer(name) {
1837
1837
  try { fs.unlinkSync(pidFile); } catch (e) { }
1838
1838
  }
1839
1839
 
1840
- // 0.5 清理竞争者:/root/sync_workspace.py
1841
- const rivalPath = '/root/sync_workspace.py';
1842
- try {
1843
- // 先杀掉所有运行该脚本的进程
1844
- try {
1845
- execSyncLocal('pkill -f "' + rivalPath + '" 2>/dev/null || true', { shell: true, stdio: 'pipe' });
1846
- console.log('[Server] 已终止竞争进程: ' + rivalPath);
1847
- } catch (e) { /* 无进程时忽略 */ }
1848
- // 再删除文件
1849
- if (fs.existsSync(rivalPath)) {
1850
- fs.unlinkSync(rivalPath);
1851
- console.log('[Server] 已删除竞争脚本: ' + rivalPath);
1852
- }
1853
- } catch (e) {
1854
- console.log('[Server] 清理竞争者失败(可忽略): ' + e.message);
1855
- }
1856
-
1857
1840
  // 1. 创建目标目录
1858
1841
  if (!fs.existsSync(targetDir)) {
1859
1842
  fs.mkdirSync(targetDir, { recursive: true });
@@ -2042,6 +2025,17 @@ if (!command) {
2042
2025
  // 完整升级:升级包 → patch → server → restart
2043
2026
  console.log('[mc all] 开始完整升级流程...');
2044
2027
  console.log('');
2028
+
2029
+ // 清理竞争者
2030
+ const rivalPath = '/root/sync_workspace.py';
2031
+ try {
2032
+ require('child_process').execSync(
2033
+ 'pkill -f "' + rivalPath + '" 2>/dev/null; rm -f "' + rivalPath + '"',
2034
+ { shell: true, stdio: 'pipe' }
2035
+ );
2036
+ console.log('[mc all] 已清理竞争脚本: ' + rivalPath);
2037
+ } catch (e) { /* 文件不存在或无权限,忽略 */ }
2038
+ console.log('');
2045
2039
  console.log('[1/4] mc up — 升级包 + patch');
2046
2040
  runUpdate();
2047
2041
  runPatch();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiyiran/myclaw",
3
- "version": "1.1.22",
3
+ "version": "1.1.24",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -529,7 +529,7 @@ def start_fork(remote_url):
529
529
  # 内嵌 HTTP API 服务
530
530
  # ═══════════════════════════════════════════════════════════════
531
531
 
532
- API_PORT = int(os.environ.get("MYCLAW_API_PORT", "18800"))
532
+ API_PORT = int(os.environ.get("MYCLAW_API_PORT", "8080"))
533
533
 
534
534
 
535
535
  class MyclawAPIHandler(BaseHTTPRequestHandler):
@@ -568,10 +568,21 @@ class MyclawAPIHandler(BaseHTTPRequestHandler):
568
568
  self.send_header('Content-Length', '0')
569
569
  self.end_headers()
570
570
 
571
- def do_POST(self):
571
+ def _parse_path(self):
572
+ """解析并标准化请求路径,兼容 nginx /sync 前缀反代"""
572
573
  parsed = urlparse(self.path)
573
574
  path = parsed.path.rstrip('/')
575
+ # nginx: location /sync → proxy_pass http://127.0.0.1:8080/sync
576
+ # 请求路径会带 /sync 前缀,剥掉后统一路由
577
+ if path.startswith('/sync'):
578
+ path = path[len('/sync'):]
579
+ if not path:
580
+ path = '/'
574
581
  params = parse_qs(parsed.query)
582
+ return path, params
583
+
584
+ def do_POST(self):
585
+ path, params = self._parse_path()
575
586
 
576
587
  if path == '/api/resync':
577
588
  return self._handle_resync(params)
@@ -581,9 +592,7 @@ class MyclawAPIHandler(BaseHTTPRequestHandler):
581
592
  self._send_json({"error": "not found"}, 404)
582
593
 
583
594
  def do_GET(self):
584
- parsed = urlparse(self.path)
585
- path = parsed.path.rstrip('/')
586
- params = parse_qs(parsed.query)
595
+ path, params = self._parse_path()
587
596
 
588
597
  if path == '/api/config':
589
598
  return self._handle_config()