SMA AutoUI
智能移动自动化 UI 框架 —— 面向社交媒体平台的 Android 设备自动化,融合 ADB 直达、视觉识别与 LLM 认知自愈能力。
📦 PyPI:https://pypi.org/project/sma-autoui/
🚀 快速开始
# 从 PyPI 安装
pip install sma-autoui
# 或从源码安装
pip install .
🌟 核心特性
| 特性 | 说明 |
|---|---|
| ✅ 多平台适配 | 10 个社交平台业务抽象(TikTok / 抖音 / 小红书 / 微博 / X / Threads / Instagram / Facebook / WhatsApp / 酷安) |
| ✅ Session 复用 | 跨任务会话持久化与保活架构 |
| ✅ 视觉匹配 | 模板匹配下沉 Appium images-plugin(服务端 OpenCV + 自动缩放)+ OCR 文字定位,文字优先、图标兜底 |
| ✅ ADB 直达 | 困难页面(直播间 / SurfaceView)直接注入事件,绕开 W3C 限制 |
| ✅ 拟人化行为 | 点击抖动(jitter)、连点、随机等待、概率化交互 |
| ✅ AI 驱动 | 基于 pydantic-ai 的 Agent 编排 + 结构化输出 + 双通道模型(生成 / 判定) |
| ✅ 自愈能力 | UI 异常自动诊断与恢复,规则注册 / 淘汰闭环 |
| ✅ 离线诊断回放 | 回放夹具(ReplayHarness)复现线上 AI 调用 + 调用轨迹汇总(telemetry) |
完整项目结构与各层模块职责,详见 🏗️ 系统架构。
📖 文档
文档按 sma_autoui 的包结构组织,入口见 docs/index.md。
| 文档 | 描述 |
|---|---|
| 文档首页 | 阅读路径与包索引 |
| 快速开始 | 安装与最小任务 |
| 环境搭建 | Appium + ADB 完整环境搭建与验证 |
| 架构总览 | 模块边界、调用链与自愈机制 |
| driver 驱动层 | 设备、会话、动作、定位、页面检查 |
| ai 能力层 | Agent、模型兼容、Skill 与 Scope |
| healing 自愈 | 诊断、规则回放、执行与反馈 |
| common 基建 | 上报通道、通知域、TaskReport / SharedLedger |
| 运维与排障 | 运行、日志与常见坑点 |
| 变更记录 | 2026-11 重构与版本日志 |
本地预览文档站:
pip install -r requirements-docs.txt
python -m mkdocs serve
快速导航
- 新入门 → 环境搭建 → 架构总览
- 写业务脚本 → driver 驱动层 → engine 执行引擎
- 定位 / 自愈 → 定位入口(locating) → 自愈体系
- AI 能力 → Agent 体系 → Skill 与 Scope
- 遇到问题 → 常见坑点
- 看版本改了什么 → 变更记录
💻 使用示例
from appium.webdriver.common.appiumby import AppiumBy
from sma_autoui.driver import Device, Driver
from sma_autoui.engine import TaskRunner
# 1. 初始化设备(ADB 连接 + 环境准备)
device = Device(device_name="172.25.2.20:5555", adb_port=5002)
device.initialize_env()
# 2. 创建驱动实例(门面,聚合 actions / ElementLocator / inspector / vision / browser)
driver = Driver(
device=device,
appium_url="http://localhost:4723",
job_id="example_job",
desired_caps={...},
app_name="xhs",
app_version="1.0.0",
task_name="example_task",
)
# 3. 定位(四种方式各有专用入口,统一返回 FindResult)
result = driver.find_element(
locators=[(AppiumBy.ANDROID_UIAUTOMATOR, 'new UiSelector().text("Follow")')],
timeout=10,
ai_recovery=True, # 元素定位失败时触发 AI 诊断自愈
)
# driver.find_ocr(texts=["Follow"]) # OCR 文字定位
# driver.find_image(templates=["btn_follow"]) # 图片模板定位
# driver.find_semantic("点关注按钮") # 语义定位(XML + 截图 → 模型给候选 → 屏上复检)
element = result.element # 取活元素;坐标点击用 result.point
driver.tap_by_adb(x=500, y=800, jitter=8) # ADB 直达 + 坐标抖动
driver.smart_swipe(direction="UP", degree="MIDDLE")
# 4. 任务重试、异常自愈与保活由 TaskRunner 统一处理
TaskRunner(driver=driver).run(task_func=my_flow, task_name="example_task")
🔧 从源码安装
git clone https://github.com/Fun-Fox/sma_autoui.git
cd sma_autoui
pip install -r requirements.txt
pip install -e .
📄 开源协议
MIT License
Built with ❤️ by FunFox
Metadata
Release files for sma-autoui 1.1.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| sma_autoui-1.1.5.tar.gz | 3.4 MB | Without provenance | Details for sma_autoui-1.1.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sma_autoui-1.1.5-py3-none-any.whl | Python 3 | none | any | Details for sma_autoui-1.1.5-py3-none-any.whl |
Total release size: 6.9 MB
Release files / sma_autoui-1.1.5.tar.gz
| Download URL | sma_autoui-1.1.5.tar.gz |
|---|---|
| Size | 3.4 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7be173c30b1d08f05564924ae0d3196515ec076591fb5203cc4fe53d3da52240
|
|
BLAKE2b-256 checksum How to use checksums |
545af08872fcb56e50c7a9bc83d3faf8dec5fd4831bdb3ca3b55e44c2487e982
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.9
|
Release files / sma_autoui-1.1.5-py3-none-any.whl
| Download URL | sma_autoui-1.1.5-py3-none-any.whl |
|---|---|
| Size | 3.5 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
05efcabe3fd3552d2178f1bda1f3f27b71f7c6432fff8e493ae78a06a0315f4a
|
|
BLAKE2b-256 checksum How to use checksums |
1e8183628f6b1ae0876d3153f9c06f477bdecc1e507f2d2d28269756f0b78a34
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.9
|
Security for sma-autoui 1.1.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.