myagent-ai 1.15.53 → 1.15.55

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.
@@ -650,11 +650,13 @@ class UpdateManager:
650
650
 
651
651
  if is_npm_install:
652
652
  # npm 安装: 通过 start.js (Node.js) 重启,确保 venv 和依赖正确处理
653
- # start.js 会自动创建/更新 venv 并安装依赖
654
- start_js = PROJECT_ROOT / "start.js"
653
+ # [v1.15.54] 关键修复: 必须从 npm 全局安装目录找到新版本的 start.js
654
+ # 因为 PROJECT_ROOT 指向旧版本目录,用旧 start.js 重启等于没更新
655
+ import shutil
656
+ node_cmd = shutil.which("node")
657
+ new_start_js = self._find_npm_start_js()
658
+ start_js = new_start_js if new_start_js else PROJECT_ROOT / "start.js"
655
659
  if start_js.exists():
656
- import shutil
657
- node_cmd = shutil.which("node")
658
660
  if node_cmd:
659
661
  # 提取原始参数 (去掉 main.py,还原 start.js 的参数格式)
660
662
  original_args = []
@@ -681,6 +683,8 @@ class UpdateManager:
681
683
  os.execv(node_cmd, [node_cmd, str(start_js)] + original_args)
682
684
  else:
683
685
  logger.warning("未找到 node 命令,回退到直接 Python 重启")
686
+ else:
687
+ logger.error(f"未找到 start.js (尝试: {new_start_js}, 回退: {PROJECT_ROOT / 'start.js'})")
684
688
 
685
689
  # 回退: 直接用 Python 重启(源码安装或 node 不可用)
686
690
  # 使用绝对路径避免 cwd 变化导致找不到 main.py
@@ -759,6 +763,31 @@ class UpdateManager:
759
763
  logger.debug(f"读取 npm 全局安装版本失败: {e}")
760
764
  return ""
761
765
 
766
+ def _find_npm_start_js(self) -> Optional[Path]:
767
+ """[v1.15.54] 从 npm 全局安装目录找到新版本的 start.js 路径。
768
+
769
+ npm install -g 安装的新版本在 npm root -g/myagent-ai/ 下,
770
+ 但当前进程的 PROJECT_ROOT 可能指向旧的 npx 缓存目录。
771
+ 重启时必须用新版本的 start.js,否则等于没更新。
772
+ """
773
+ try:
774
+ result = subprocess.run(
775
+ ["npm", "root", "-g"],
776
+ capture_output=True, text=True, timeout=5,
777
+ )
778
+ npm_root = result.stdout.strip()
779
+ if not npm_root:
780
+ return None
781
+ start_js = Path(npm_root) / "myagent-ai" / "start.js"
782
+ if start_js.exists():
783
+ logger.info(f"找到 npm 全局目录的新版 start.js: {start_js}")
784
+ return start_js
785
+ else:
786
+ logger.debug(f"npm 全局目录中未找到 start.js: {start_js}")
787
+ except Exception as e:
788
+ logger.debug(f"查找 npm 全局 start.js 失败: {e}")
789
+ return None
790
+
762
791
  def _get_npm_registry(self) -> str:
763
792
  """获取 npm registry 地址,国内用户自动使用镜像"""
764
793
  import locale
@@ -789,8 +818,8 @@ class UpdateManager:
789
818
  last_error = None
790
819
  for reg in registries_to_try:
791
820
  is_official = (reg == "https://registry.npmjs.org")
792
- # 构建 npm install 命令 — 使用 @latest 确保拉取最新版本
793
- npm_cmd = ["npm", "install", "-g", f"{pkg_name}@latest", "--registry", reg]
821
+ # 构建 npm install 命令 — 使用 @latest + --prefer-online 确保拉取最新版本(不走缓存)
822
+ npm_cmd = ["npm", "install", "-g", f"{pkg_name}@latest", "--prefer-online", "--registry", reg]
794
823
  if is_official:
795
824
  logger.info(f"使用 npm 官方源安装最新版本: {reg}")
796
825
  else:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "myagent-ai",
3
- "version": "1.15.53",
3
+ "version": "1.15.55",
4
4
  "description": "本地桌面端执行型AI助手 - Open Interpreter 风格 | Local Desktop Execution-Oriented AI Assistant",
5
5
  "main": "main.py",
6
6
  "bin": {
package/web/ui/index.html CHANGED
@@ -38,7 +38,7 @@ body{font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif;b
38
38
  .sidebar{width:220px;background:var(--surface);border-right:1px solid var(--border);display:flex;flex-direction:column;flex-shrink:0}
39
39
  .sidebar .logo{padding:20px;font-size:18px;font-weight:700;border-bottom:1px solid var(--border);display:flex;align-items:center;gap:8px}
40
40
  .sidebar .logo span{color:var(--primary)}
41
- .nav{flex:1;padding:8px;overflow-y:auto;min-height:0}
41
+ .nav{flex:1;padding:0 8px 8px;overflow-y:auto;min-height:0;display:flex;flex-direction:column}
42
42
  .nav-item{display:flex;align-items:center;gap:10px;padding:10px 12px;border-radius:var(--radius);cursor:pointer;color:var(--text2);font-size:14px;transition:all .15s;margin-bottom:2px}
43
43
  .nav-item:hover{background:var(--surface2);color:var(--text)}
44
44
  .nav-item.active{background:var(--primary);color:#fff}
@@ -226,6 +226,7 @@ tr:hover{background:var(--surface2)}
226
226
  <div class="sidebar-toggle" onclick="toggleSidebar()" id="sidebarToggle">◀</div>
227
227
  <div class="logo"><span>🤖</span> <span class="logo-text">MyAgent</span></div>
228
228
  <div class="nav">
229
+ <div style="flex:1;overflow-y:auto;padding:8px 0;min-height:0">
229
230
  <div class="nav-item active" data-tooltip="仪表盘" onclick="showPage('dashboard')"><span class="icon">📊</span><span class="icon-text">仪表盘</span></div>
230
231
  <div class="nav-item" data-tooltip="Agent 管理" onclick="showPage('agents')"><span class="icon">🧠</span><span class="icon-text">Agent 管理</span></div>
231
232
  <div class="nav-item" data-tooltip="聊天平台" onclick="showPage('platforms')"><span class="icon">💬</span><span class="icon-text">聊天平台</span></div>
@@ -241,12 +242,13 @@ tr:hover{background:var(--surface2)}
241
242
  <div class="nav-item" data-tooltip="工作目录" onclick="showPage('files')"><span class="icon">📁</span><span class="icon-text">工作目录</span></div>
242
243
  <div class="nav-item" data-tooltip="查看日志" onclick="showPage('logs')"><span class="icon">📋</span><span class="icon-text">查看日志</span></div>
243
244
  <div class="nav-item" data-tooltip="任务记录" onclick="showPage('tasks')"><span class="icon">📌</span><span class="icon-text">任务记录</span></div>
244
- </div>
245
- <div style="padding:12px;border-top:1px solid var(--border);font-size:12px;color:var(--text2);flex-shrink:0" class="sidebar-footer-text">
246
- <span id="sidebarVersion">v...</span>
247
- <span id="updateBadge" style="display:none;margin-left:6px;color:var(--danger);font-weight:bold;cursor:pointer" onclick="doUpdate()" title="点击更新">[有新版本]</span>
248
- · <a href="#" onclick="api('/api/status').then(r=>showToast('Running: '+r.running,'success'))" style="color:var(--primary)">状态</a>
249
- · <a href="#" onclick="checkUpdate(true)" style="color:var(--primary)">检查更新</a>
245
+ </div>
246
+ <div style="padding:10px 12px;border-top:1px solid var(--border);margin-top:4px;font-size:12px;color:var(--text2);flex-shrink:0" class="sidebar-footer-text">
247
+ <span id="sidebarVersion">v...</span>
248
+ <span id="updateBadge" style="display:none;margin-left:6px;color:var(--danger);font-weight:bold;cursor:pointer" onclick="doUpdate()" title="点击更新">[有新版本]</span>
249
+ · <a href="#" onclick="checkUpdate(true)" style="color:var(--primary)">检查更新</a>
250
+ · <a href="#" onclick="api('/api/status').then(r=>showToast('Running: '+r.running,'success'))" style="color:var(--primary)">状态</a>
251
+ </div>
250
252
  </div>
251
253
  </div>
252
254
  <div class="mobile-overlay" id="adminMobileOverlay" onclick="closeMobileSidebar()"></div>