@aiyiran/myclaw 1.1.23 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiyiran/myclaw",
3
- "version": "1.1.23",
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()