myagent-ai 1.16.2 → 1.16.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "myagent-ai",
3
- "version": "1.16.2",
3
+ "version": "1.16.3",
4
4
  "description": "本地桌面端执行型AI助手 - Open Interpreter 风格 | Local Desktop Execution-Oriented AI Assistant",
5
5
  "main": "main.py",
6
6
  "bin": {
@@ -124,6 +124,16 @@ class MCPClient:
124
124
  if self._slim:
125
125
  args.append("--slim")
126
126
 
127
+ # [v1.16.2] 自动检测可用的浏览器,支持 chromium 等替代方案
128
+ browser_path = self._detect_browser()
129
+ env = {**os.environ, "NO_COLOR": "1"}
130
+ if browser_path:
131
+ # 优先使用 CHROME_PATH 环境变量传递给 chrome-devtools-mcp
132
+ env["CHROME_PATH"] = browser_path
133
+ logger.info(f"使用浏览器: {browser_path}")
134
+ else:
135
+ logger.warning("未找到 Chrome/Chromium 浏览器,尝试使用默认路径")
136
+
127
137
  logger.info(f"启动 chrome-devtools-mcp: {' '.join(args)}")
128
138
 
129
139
  try:
@@ -135,7 +145,7 @@ class MCPClient:
135
145
  stdin=subprocess.PIPE,
136
146
  stdout=subprocess.PIPE,
137
147
  stderr=subprocess.DEVNULL,
138
- env={**os.environ, "NO_COLOR": "1"},
148
+ env=env,
139
149
  )
140
150
 
141
151
  # 启动读取线程
@@ -157,6 +167,50 @@ class MCPClient:
157
167
  self._cleanup()
158
168
  return False
159
169
 
170
+ @staticmethod
171
+ def _detect_browser() -> Optional[str]:
172
+ """[v1.16.2] 自动检测可用的浏览器(Chrome/Chromium/Brave 等)。
173
+
174
+ 检测顺序:
175
+ 1. 环境变量 CHROME_PATH / BROWSER_PATH
176
+ 2. PATH 中的常见浏览器命令
177
+ 3. Linux 常见安装路径
178
+ """
179
+ # 1. 环境变量
180
+ for env_key in ("CHROME_PATH", "BROWSER_PATH"):
181
+ env_val = os.environ.get(env_key, "").strip()
182
+ if env_val and os.path.isfile(env_val):
183
+ return env_val
184
+
185
+ # 2. PATH 中的浏览器命令
186
+ path_candidates = [
187
+ "google-chrome", "google-chrome-stable", "google-chrome-beta",
188
+ "chromium-browser", "chromium",
189
+ "brave-browser", "microsoft-edge",
190
+ ]
191
+ for cmd in path_candidates:
192
+ found = shutil.which(cmd)
193
+ if found:
194
+ return found
195
+
196
+ # 3. Linux 常见安装路径
197
+ linux_paths = [
198
+ "/usr/bin/google-chrome",
199
+ "/usr/bin/google-chrome-stable",
200
+ "/usr/bin/chromium-browser",
201
+ "/usr/bin/chromium",
202
+ "/snap/bin/chromium",
203
+ "/usr/bin/brave-browser",
204
+ "/usr/bin/microsoft-edge",
205
+ "/opt/google/chrome/chrome",
206
+ "/opt/microsoft/msedge/msedge",
207
+ ]
208
+ for p in linux_paths:
209
+ if os.path.isfile(p) and os.access(p, os.X_OK):
210
+ return p
211
+
212
+ return None
213
+
160
214
  def _read_stdout(self):
161
215
  """持续读取 MCP Server 的 stdout"""
162
216
  if not self._process or not self._process.stdout:
@@ -47,7 +47,7 @@ button{font:inherit;cursor:pointer;border:none;background:none;color:inherit}
47
47
  input,textarea,select{font:inherit}
48
48
 
49
49
  /* ── Layout ── */
50
- .app{position:fixed;top:0;left:0;width:100vw;height:100vh;display:flex;overflow:hidden;background:var(--bg)}
50
+ .app{position:fixed;top:0;left:0;width:100vw;height:100vh;height:100dvh;display:flex;overflow:hidden;background:var(--bg)}
51
51
 
52
52
  /* Layout panels */
53
53
  .sidebar,
@@ -2145,7 +2145,7 @@ body.popout-mode #popoutBtn{display:none !important}
2145
2145
  /* ── Input Area ── */
2146
2146
  .input-area{
2147
2147
  padding:10px 12px;
2148
- padding-bottom: max(10px, env(safe-area-inset-bottom));
2148
+ padding-bottom: max(12px, env(safe-area-inset-bottom));
2149
2149
  }
2150
2150
  .input-wrapper{
2151
2151
  max-width:100%;
@@ -25,25 +25,26 @@
25
25
  })();
26
26
 
27
27
  // ── Mobile keyboard / visualViewport handling ──
28
+ // [v1.16.2] CSS 已使用 100dvh 动态视口高度,浏览器会自动处理键盘弹出时的视口收缩。
29
+ // 此处仅作为兼容性补充:对不支持 100dvh 的旧浏览器,使用 visualViewport API 调整。
28
30
  function onAllScriptsLoaded() {
29
31
  if (!window.visualViewport) return;
30
32
 
31
- var inputArea = document.getElementById('inputBox');
32
- if (!inputArea) return;
33
+ // 检测是否支持 dvh(现代浏览器都支持)
34
+ var testEl = document.createElement('div');
35
+ var supportsDvh = CSS.supports && CSS.supports('height', '100dvh');
36
+
37
+ // 如果支持 dvh,CSS 已经处理了,不需要 JS 干预
38
+ if (supportsDvh) return;
39
+
40
+ var app = document.querySelector('.app');
41
+ if (!app) return;
33
42
 
34
43
  var vv = window.visualViewport;
35
44
 
36
- // When the virtual keyboard appears (viewport shrinks), the input area
37
- // needs extra bottom padding so the send button stays above the keyboard.
38
45
  function onViewportResize() {
39
- var diff = window.innerHeight - vv.height;
40
- if (diff > 100) {
41
- // Keyboard is open — add padding equal to keyboard height
42
- inputArea.style.marginBottom = diff + 'px';
43
- } else {
44
- // Keyboard is closed
45
- inputArea.style.marginBottom = '0px';
46
- }
46
+ // 对不支持 dvh 的浏览器,用 visualViewport.height 手动设置高度
47
+ app.style.height = vv.height + 'px';
47
48
  }
48
49
 
49
50
  vv.addEventListener('resize', onViewportResize);
@@ -4,7 +4,7 @@
4
4
  <meta charset="UTF-8">
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover">
6
6
  <title>MyAgent - AI 助手</title>
7
- <link rel="stylesheet" href="chat.css?v=7">
7
+ <link rel="stylesheet" href="chat.css?v=8">
8
8
  </head>
9
9
  <body>
10
10
  <div class="app">
@@ -275,6 +275,6 @@
275
275
  <div id="groupModalContainer"></div>
276
276
 
277
277
  <!-- Load JS scripts (no HTML fragments to fetch) -->
278
- <script src="chat.js?v=8"></script>
278
+ <script src="chat.js?v=9"></script>
279
279
  </body>
280
280
  </html>