diff --git a/cloud_knowledge.py b/cloud_knowledge.py index 2f4b862..d9160e7 100644 --- a/cloud_knowledge.py +++ b/cloud_knowledge.py @@ -13,15 +13,19 @@ import urllib.request import urllib.error from pathlib import Path +_TERMUX_HOME = Path("/data/data/com.termux/files/home") +_HERMES_BASE = (_TERMUX_HOME if _TERMUX_HOME.exists() + else Path(os.environ.get("HOME", str(_TERMUX_HOME)))) / ".hermes" + CLOUD_API = os.environ.get("HERMES_CLOUD_API", "https://api.hermes-agent.ai/v1") CLOUD_KEY = os.environ.get("HERMES_CLOUD_KEY", "") LOCAL_CACHE = Path(os.environ.get( "CLOUD_CACHE_DIR", - str(Path(os.environ.get("HOME", "/data/data/com.termux/files/home")) / ".hermes" / "cloud_cache") + str(_HERMES_BASE / "cloud_cache") )) UPLOAD_LOG = Path(os.environ.get( "UPLOAD_LOG", - str(Path(os.environ.get("HOME", "/data/data/com.termux/files/home")) / ".hermes" / "cloud_uploads.jsonl") + str(_HERMES_BASE / "cloud_uploads.jsonl") )) # Schema version for knowledge entries diff --git a/connectors.py b/connectors.py index 4914fdb..f48cb8c 100644 --- a/connectors.py +++ b/connectors.py @@ -21,17 +21,21 @@ import time from pathlib import Path from typing import Any +_TERMUX_HOME = Path("/data/data/com.termux/files/home") +_HERMES_BASE = (_TERMUX_HOME if _TERMUX_HOME.exists() + else Path(os.environ.get("HOME", str(_TERMUX_HOME)))) / ".hermes" + CONNECTORS_DIR = Path(os.environ.get( "CONNECTORS_DIR", - str(Path.home() / ".hermes" / "connectors") + str(_HERMES_BASE / "connectors") )) EVENT_BUS_DIR = Path(os.environ.get( "EVENT_BUS_DIR", - str(Path.home() / ".hermes" / "event_bus") + str(_HERMES_BASE / "event_bus") )) KNOWLEDGE_LOG = Path(os.environ.get( "KNOWLEDGE_LOG", - str(Path.home() / ".hermes" / "knowledge_log.jsonl") + str(_HERMES_BASE / "knowledge_log.jsonl") )) diff --git a/test_scenarios.md b/test_scenarios.md new file mode 100644 index 0000000..f361352 --- /dev/null +++ b/test_scenarios.md @@ -0,0 +1,66 @@ +# Phoneuse 端到端测试场景 + +## 场景 1:WeChat 消息发送(核心功能) +**目标**:验证 send_wechat_message 真发送 + DB 验证 +``` +1. 给 filehelper 发送一条测试消息 +2. 验证返回 status="sent" 且 msgId 不为空 +3. 用 query_wechat 独立查询确认 isSend=1 +``` + +## 场景 2:WeChat 数据查询(修复验证) +**目标**:验证 S2-02/03/04 修复生效 +``` +1. get_wechat_contacts(query="张") — 应返回匹配联系人,无 imgFlag 错误 +2. get_wechat_messages(contact="filehelper", limit=5) — 应返回消息列表,无 LIMIT ? 错误 +3. get_wechat_chatrooms(limit=5) — 应返回群聊,无 chatroomowner 错误 +``` + +## 场景 3:Memory Graph 搜索(知识库) +**目标**:验证 search_memory + semantic_search_memory +``` +1. search_memory("吃饭") — 应返回相关微信消息 +2. semantic_search_memory("项目") — 应返回语义相关消息(带 score) +3. embed_memory_messages(3) — 应成功向量化 +``` + +## 场景 4:电话/短信工具(新模块) +**目标**:验证 telephony_tools 已注册可用 +``` +1. get_device_info() — 应返回设备信息 +2. list_call_log(limit=5) — 应返回通话记录(或空列表) +3. get_system_contacts(limit=5) — 应返回系统通讯录 +``` + +## 场景 5:Connector 层(修复验证) +**目标**:验证 EVENT_BUS_DIR 修复后 connector/persona/cloud 工具 +``` +1. get_connector_kb("wechat") — 应返回 wechat.yaml 内容 +2. connector_read_wechat_contacts(limit=3) — 应返回联系人 +3. get_persona() — 应返回 persona 数据(或空但无 NameError) +4. run_discovery_agent("wechat") — 应返回 WeChat DB 表列表 +``` + +## 场景 6:部署工具(自举能力) +**目标**:验证 deploy_phoneuse_code 工具 +``` +1. 在 Mac 上修改一个 .py 文件(加一行注释) +2. 通过 MCP 调用 deploy_phoneuse_code(restart=true) +3. 验证 Pixel 上文件已更新、MCP 已重启 +``` + +## 场景 7:MITM 流量分析(Alipay) +**目标**:验证 Alipay 流量可被拦截 +``` +1. 确认 mitm_proxy 在运行(port 8082) +2. 打开 Alipay App +3. 检查 event_server 是否有 mitm 类型事件(source='mitm', app='alipay') +``` + +## 场景 8:UI 控制工具(新模块) +**目标**:验证 ui_control_tools 可用 +``` +1. screenshot() — 应返回截图路径 +2. get_foreground_app() — 应返回当前前台应用 +3. tap(x=500, y=1000) — 应执行点击(在已知安全界面测试) +```