mobile-mcp-ai 2.3.0__py3-none-any.whl → 2.3.2__py3-none-any.whl

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.
@@ -113,7 +113,18 @@ class BasicMobileToolsLite:
113
113
  ratio = max_width / img.width
114
114
  new_w = max_width
115
115
  new_h = int(img.height * ratio)
116
- img = img.resize((new_w, new_h), Image.LANCZOS)
116
+ # 兼容不同版本的 Pillow
117
+ try:
118
+ # Pillow 10.0.0+
119
+ resample = Image.Resampling.LANCZOS
120
+ except AttributeError:
121
+ try:
122
+ # Pillow 9.x
123
+ resample = Image.LANCZOS
124
+ except AttributeError:
125
+ # Pillow 旧版本
126
+ resample = Image.ANTIALIAS
127
+ img = img.resize((new_w, new_h), resample)
117
128
 
118
129
  # 第4步:生成最终文件名(JPEG 格式)
119
130
  if description:
@@ -125,7 +136,17 @@ class BasicMobileToolsLite:
125
136
  final_path = self.screenshot_dir / filename
126
137
 
127
138
  # 第5步:保存为 JPEG(PNG 可能有透明通道,需转 RGB)
128
- img = img.convert("RGB")
139
+ # 先转换为 RGB 模式,处理可能的 RGBA 或 P 模式
140
+ if img.mode in ('RGBA', 'LA', 'P'):
141
+ # 创建白色背景
142
+ background = Image.new('RGB', img.size, (255, 255, 255))
143
+ if img.mode == 'P':
144
+ img = img.convert('RGBA')
145
+ background.paste(img, mask=img.split()[-1] if img.mode == 'RGBA' else None)
146
+ img = background
147
+ elif img.mode != 'RGB':
148
+ img = img.convert("RGB")
149
+
129
150
  img.save(str(final_path), "JPEG", quality=quality)
130
151
 
131
152
  # 第6步:删除临时 PNG
@@ -547,3 +547,5 @@ class IOSClientWDA:
547
547
 
548
548
 
549
549
 
550
+
551
+
@@ -380,10 +380,12 @@ class MobileClient:
380
380
  break
381
381
 
382
382
  if not found:
383
- # 🎯 定位失败,自动使用Cursor AI视觉识别(截图分析)
384
- print(f" ⚠️ 元素'{ref}'未找到,自动使用Cursor AI视觉识别(截图分析)...", file=sys.stderr)
383
+ # 🎯 定位失败,提示用户
384
+ # 注意:CursorVisionHelper 是实验性功能,当前版本建议使用 MCP 方式
385
+ print(f" ⚠️ 元素'{ref}'未找到", file=sys.stderr)
385
386
  try:
386
387
  from .locator.cursor_vision_helper import CursorVisionHelper
388
+ print(f" 🔍 尝试使用Cursor AI视觉识别...", file=sys.stderr)
387
389
  cursor_helper = CursorVisionHelper(self)
388
390
  # 🎯 传递 auto_analyze=True,自动创建请求文件并等待结果
389
391
  cursor_result = await cursor_helper.analyze_with_cursor(element, auto_analyze=True)
@@ -415,12 +417,17 @@ class MobileClient:
415
417
  # 其他情况,抛出异常
416
418
  screenshot_path = cursor_result.get('screenshot_path', 'unknown') if cursor_result else 'unknown'
417
419
  raise ValueError(f"Cursor AI分析失败: {screenshot_path}")
420
+ except ImportError:
421
+ # CursorVisionHelper 模块不存在,跳过视觉识别
422
+ print(f" 💡 提示:建议使用 MCP 方式调用,Cursor AI 会自动进行视觉识别", file=sys.stderr)
418
423
  except ValueError as ve:
419
424
  if "Cursor AI" in str(ve):
420
425
  raise ve
421
426
  print(f" ⚠️ Cursor视觉识别失败: {ve}", file=sys.stderr)
427
+ except Exception as e:
428
+ print(f" ⚠️ 视觉识别异常: {e}", file=sys.stderr)
422
429
 
423
- raise ValueError(f"无法找到元素: {ref}(已等待3秒,并尝试Cursor视觉识别,可能元素不存在)")
430
+ raise ValueError(f"无法找到元素: {ref}(建议使用 MCP 方式,Cursor AI 会自动进行视觉识别)")
424
431
 
425
432
  # 验证点击(可选)
426
433
  page_changed = False
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mobile-mcp-ai
3
- Version: 2.3.0
3
+ Version: 2.3.2
4
4
  Summary: 移动端自动化 MCP Server - 支持 Android/iOS,AI 功能可选(基础工具不需要 AI)
5
5
  Home-page: https://github.com/test111ddff-hash/mobile-mcp-ai
6
6
  Author: douzi
@@ -1,12 +1,12 @@
1
1
  mobile_mcp/__init__.py,sha256=sQJZTL_sxQFzmcS7jOtS2AHCfUySz40vhX96N6u1qy4,816
2
2
  mobile_mcp/config.py,sha256=yaFLAV4bc2wX0GQPtZDo7OYF9E88tXV-av41fQsJwK4,4480
3
3
  mobile_mcp/core/__init__.py,sha256=ndMy-cLAIsQDG5op7gM_AIplycqZSZPWEkec1pEhvEY,170
4
- mobile_mcp/core/basic_tools_lite.py,sha256=cxoQXEfnZBV_xdhVbeaCnl8W1IXONzLGpIJx0JpLDc0,46875
4
+ mobile_mcp/core/basic_tools_lite.py,sha256=_D8QmVO3UAYHvQ50C4vyd_N7LubEjt6zwUhLXfZffLE,47894
5
5
  mobile_mcp/core/device_manager.py,sha256=PX3-B5bJFnKNt6C8fT7FSY8JwD-ngZ3toF88bcOV9qA,8766
6
6
  mobile_mcp/core/dynamic_config.py,sha256=Ja1n1pfb0HspGByqk2_A472mYVniKmGtNEWyjUjmgK8,9811
7
- mobile_mcp/core/ios_client_wda.py,sha256=rMlInjHrHtlTHqhUqezT257aJMLXEUy072kT3ATvhhQ,18750
7
+ mobile_mcp/core/ios_client_wda.py,sha256=St6nOeXW0wiolLm6iQ2Etuwr1cvzwnlnYwGUxA3-JD4,18752
8
8
  mobile_mcp/core/ios_device_manager_wda.py,sha256=A44glqI-24un7qST-E3w6BQD8mV92YVUbxy4rLlTScY,11264
9
- mobile_mcp/core/mobile_client.py,sha256=o8DMIspGhyo8U3HRb5C8I9i3tlh7M4NAe281I0oPc0M,61969
9
+ mobile_mcp/core/mobile_client.py,sha256=bno3HvU-QSAC3G4TnoFngTxqXeu-ZP5rGlEWdWh8jOo,62570
10
10
  mobile_mcp/core/utils/__init__.py,sha256=RhMMsPszmEn8Q8GoNufypVSHJxyM9lio9U6jjpnuoPI,378
11
11
  mobile_mcp/core/utils/logger.py,sha256=XXQAHUwT1jc70pq_tYFmL6f_nKrFlYm3hcgl-5RYRg0,3402
12
12
  mobile_mcp/core/utils/operation_history_manager.py,sha256=gi8S8HJAMqvkUrY7_-kVbko3Xt7c4GAUziEujRd-N-Y,4792
@@ -17,9 +17,9 @@ mobile_mcp/utils/__init__.py,sha256=8EH0i7UGtx1y_j_GEgdN-cZdWn2sRtZSEOLlNF9HRnY,
17
17
  mobile_mcp/utils/logger.py,sha256=Sqq2Nr0Y4p03erqcrbYKVPCGiFaNGHMcE_JwCkeOfU4,3626
18
18
  mobile_mcp/utils/xml_formatter.py,sha256=uwTRb3vLbqhT8O-udzWT7s7LsV-DyDUz2DkofD3hXOE,4556
19
19
  mobile_mcp/utils/xml_parser.py,sha256=QhL8CWbdmNDzmBLjtx6mEnjHgMFZzJeHpCL15qfXSpI,3926
20
- mobile_mcp_ai-2.3.0.dist-info/licenses/LICENSE,sha256=HrhfyXIkWY2tGFK11kg7vPCqhgh5DcxleloqdhrpyMY,11558
21
- mobile_mcp_ai-2.3.0.dist-info/METADATA,sha256=M7_hDWjip4d1Kowax85u_2_fBqzcqO3umzNYSysPZok,9705
22
- mobile_mcp_ai-2.3.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
23
- mobile_mcp_ai-2.3.0.dist-info/entry_points.txt,sha256=KB_FglozgPHBprSM1vFbIzGyheFuHFmGanscRdMJ_8A,68
24
- mobile_mcp_ai-2.3.0.dist-info/top_level.txt,sha256=lLm6YpbTv855Lbh8BIA0rPxhybIrvYUzMEk9OErHT94,11
25
- mobile_mcp_ai-2.3.0.dist-info/RECORD,,
20
+ mobile_mcp_ai-2.3.2.dist-info/licenses/LICENSE,sha256=HrhfyXIkWY2tGFK11kg7vPCqhgh5DcxleloqdhrpyMY,11558
21
+ mobile_mcp_ai-2.3.2.dist-info/METADATA,sha256=sLS23VdaUzteKD34PElPyDyhKt7LHA8_hAdgnhDTI2o,9705
22
+ mobile_mcp_ai-2.3.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
23
+ mobile_mcp_ai-2.3.2.dist-info/entry_points.txt,sha256=KB_FglozgPHBprSM1vFbIzGyheFuHFmGanscRdMJ_8A,68
24
+ mobile_mcp_ai-2.3.2.dist-info/top_level.txt,sha256=lLm6YpbTv855Lbh8BIA0rPxhybIrvYUzMEk9OErHT94,11
25
+ mobile_mcp_ai-2.3.2.dist-info/RECORD,,