|
1 | 1 | # VirtuaMate |
2 | 2 |
|
3 | | -VirtuaMate (DuckyClaw) is a hardware-oriented AI agent built on the [TuyaOpen](https://github.com/tuya/TuyaOpen) C SDK. It runs on edge devices — Raspberry Pi, Tuya T5AI, ESP32-S3, or any Linux desktop — and lets users chat with the device through IM channels (Telegram, Discord, Feishu). The on-device agent loop receives natural language instructions, invokes MCP-style tools to perform real actions, and replies through the same channel. |
| 3 | +不是“会动的模型”,是能陪你、能办事、能进化的 3D AI 生命体。 |
| 4 | +一个把 **OpenClaw 式 Agent 灵魂**、**DuckyClaw 硬件路线** 和 **实时 VRM 数字人** 真正融合在一起的开源项目。 |
4 | 5 |
|
5 | | -## Features |
| 6 | +> [!WARNING] |
| 7 | +> 项目仍在持续迭代中,接口和行为可能变化。欢迎提 Issue 或 PR 一起完善。 |
6 | 8 |
|
7 | | -- **Multi-channel IM** — Telegram, Discord, Feishu, WebSocket, and serial CLI all feed into a single agent loop. |
8 | | -- **Tool loop** — Each user message can trigger up to 10 LLM ↔ tool iterations before a final reply is produced. |
9 | | -- **MCP Tools** — File operations, cron scheduling, remote command execution (Linux), and OpenClaw gateway control. |
10 | | -- **Persistent memory** — Long-term memory (`MEMORY.md`), daily notes, personality (`SOUL.md`), and user profile (`USER.md`) stored on flash/SD. |
11 | | -- **3D avatar** — Real-time VRM/PMX/GLB model rendering with emotion-driven facial expressions, spring-bone physics, lip sync, and skybox scenes (Raspberry Pi / Linux with OpenGL). |
12 | | -- **Cross-platform** — One codebase compiles for Raspberry Pi, Tuya T5AI, ESP32-S3, and Linux via Kconfig conditional compilation. |
| 9 | +--- |
13 | 10 |
|
14 | | -## Architecture |
| 11 | +## 为什么是 VirtuaMate |
15 | 12 |
|
16 | | -``` |
17 | | -IM Channels (Telegram / Discord / Feishu / WS / CLI) |
18 | | - │ |
19 | | - Message Bus |
20 | | - │ |
21 | | - Agent Loop ←→ Cloud AI (streaming) |
22 | | - │ |
23 | | - MCP Tools Layer |
24 | | - ┌────┬────┬─────┬──────────┐ |
25 | | - files cron exec openclaw avatar |
26 | | - │ │ |
27 | | - Memory / Session VRM 3D Renderer |
28 | | -``` |
| 13 | +过去最火的是 OpenClaw 这类“能执行任务”的 AI Agent, |
| 14 | +但大多数项目缺少“可感知、可表达、可陪伴”的实体化体验。 |
29 | 15 |
|
30 | | -## Prerequisites |
| 16 | +VirtuaMate 的目标很直接: |
| 17 | +**把最强执行力的 Claw 思路,变成你桌面上会呼吸、会回应、会记住你的数字伴侣。** |
31 | 18 |
|
32 | | -| Item | Notes | |
33 | | -|------|-------| |
34 | | -| **TuyaOpen SDK** | Cloned as a git submodule under `TuyaOpen/` | |
35 | | -| **Python 3** | Required by `tos.py` build system | |
36 | | -| **CMake ≥ 3.16** | Build generator | |
37 | | -| **Tuya cloud credentials** | Product ID, UUID, AuthKey from [Tuya IoT Platform](https://platform.tuya.com) | |
38 | | -| **IM bot token** | At least one of: Telegram bot token, Discord bot token, or Feishu app credentials | |
39 | | -| **(Linux/RPi only)** SDL2, GLEW, Assimp | For the VRM 3D avatar renderer: `sudo apt install libsdl2-dev libglew-dev libassimp-dev` | |
| 19 | +很多“数字人”只停留在展示层:会动但不会做事;很多“Agent”只停留在终端层:会做事但没有存在感。 |
| 20 | +VirtuaMate 直接把 **3D Avatar** 和 **可执行 Agent** 合在一起,做到“有灵魂,也有手脚”: |
40 | 21 |
|
41 | | -## Getting Started |
| 22 | +- **她是 3D 的**:VRM 模型 + VRMA 动画 + 天空盒场景,运行在本地设备。 |
| 23 | +- **她是有情绪的**:对话流式输出过程中,实时文本情绪分析驱动表情变化。 |
| 24 | +- **她是能行动的**:通过 MCP 工具完成提醒、文件操作、PC 协作等任务。 |
| 25 | +- **她是有记忆的**:长期记忆和日记存本地,不是一次性聊天窗口。 |
42 | 26 |
|
43 | | -### 1. Clone the repository |
| 27 | +--- |
44 | 28 |
|
45 | | -```bash |
46 | | -git clone --recurse-submodules https://github.com/<your-org>/VirtuaMate.git |
47 | | -cd VirtuaMate |
48 | | -``` |
| 29 | +## VirtuaMate × DuckyClaw × OpenClaw |
49 | 30 |
|
50 | | -If you already cloned without submodules: |
| 31 | +如果说 OpenClaw 打开了“个人 AI Agent 能直接行动”的认知, |
| 32 | +DuckyClaw 把它推进到了“硬件设备可落地”的现实世界, |
| 33 | +那 VirtuaMate 就是在这条线上继续往前一步: |
51 | 34 |
|
52 | | -```bash |
53 | | -git submodule update --init --recursive |
54 | | -``` |
| 35 | +- **继承 Claw 系执行范式**:保留多轮 tool loop、MCP 工具调用、任务闭环。 |
| 36 | +- **复用 DuckyClaw 的设备与消息架构**:统一消息总线、多通道接入、本地工具侧执行。 |
| 37 | +- **补齐 3D 伴侣层**:VRM 形象、实时情绪、动作编排、口型同步、场景沉浸感。 |
| 38 | +- **从“会做事”升级为“有陪伴感地做事”**:不仅完成任务,还用表情、动作、语气把反馈“演”给你看。 |
55 | 39 |
|
56 | | -### 2. Initialize the TuyaOpen environment |
| 40 | +一句话: |
| 41 | +**OpenClaw 让 Agent 能干活,DuckyClaw 让 Agent 上硬件,VirtuaMate 让 Agent 有了“人”的存在感。** |
57 | 42 |
|
58 | | -```bash |
59 | | -cd TuyaOpen |
60 | | -source ./export.sh |
61 | | -cd .. |
62 | | -``` |
| 43 | +--- |
63 | 44 |
|
64 | | -This creates a Python virtual environment and exports `OPEN_SDK_ROOT`. |
| 45 | +## 功能亮点 |
65 | 46 |
|
66 | | -### 3. Configure secrets |
| 47 | +### 1) 3D Avatar 渲染与表现 |
67 | 48 |
|
68 | | -```bash |
69 | | -cp include/tuya_app_config_secrets.h.example include/tuya_app_config_secrets.h |
70 | | -``` |
| 49 | +- **VRM 实时渲染**:`SDL2 + OpenGL + Assimp` 渲染链路,支持骨骼动画与材质。 |
| 50 | +- **动作系统**:支持 `resources/animations` 中的 `.vrma` 动画,支持 idle/one-shot 切换。 |
| 51 | +- **表情系统**:内置多种 Emotion(如 happy/sad/thinking/loving 等)。 |
| 52 | +- **口型同步**:TTS 播放音频时驱动嘴型变化,提升“说话感”。 |
| 53 | +- **天空盒场景**:支持运行时加载场景目录,6 面贴图即可切换世界观。 |
| 54 | + |
| 55 | +### 2) AI Agent 与多轮工具循环 |
| 56 | + |
| 57 | +- **Claw-style Agent Loop**:单轮消息内支持多次 “LLM -> tool -> LLM” 迭代,不是一问一答玩具。 |
| 58 | +- **流式响应联动**:AI 流式文本回调中实时刷新字幕、情绪和对话历史。 |
| 59 | +- **消息通道统一接入**:Telegram / Discord / Feishu / 本地 CLI 统一走 message bus,一套核心跑多入口。 |
| 60 | + |
| 61 | +### 3) MCP 工具能力(设备侧) |
| 62 | + |
| 63 | +- **文件工具**:`read_file` / `write_file` / `edit_file` / `list_dir` / `find_path` |
| 64 | +- **时间与提醒**:`get_current_time` / `cron_add` / `cron_list` / `cron_remove` |
| 65 | +- **Linux 执行工具**:`tool_exec`(Linux 平台可用) |
| 66 | +- **PC 协作工具**:`openclaw_ctrl` / `pc_ctrl` / `openclaw.ctrl` |
| 67 | +- **3D Avatar 工具**:`avatar_play_animation` / `avatar_set_emotion` / `avatar_composite_action` |
71 | 68 |
|
72 | | -Edit `include/tuya_app_config_secrets.h` and fill in your credentials: |
| 69 | +### 4) 本地记忆与可塑人格 |
73 | 70 |
|
74 | | -| Define | Description | |
75 | | -|--------|-------------| |
76 | | -| `TUYA_PRODUCT_ID` | Tuya product ID | |
77 | | -| `TUYA_OPENSDK_UUID` | Tuya OpenSDK UUID | |
78 | | -| `TUYA_OPENSDK_AUTHKEY` | Tuya OpenSDK AuthKey | |
79 | | -| `IM_SECRET_CHANNEL_MODE` | `"feishu"`, `"telegram"`, or `"discord"` | |
80 | | -| `IM_SECRET_TG_TOKEN` | Telegram bot token (if using Telegram) | |
81 | | -| `IM_SECRET_DC_TOKEN` / `IM_SECRET_DC_CHANNEL_ID` | Discord bot token and channel ID (if using Discord) | |
82 | | -| `IM_SECRET_FS_APP_ID` / `IM_SECRET_FS_APP_SECRET` | Feishu app credentials (if using Feishu) | |
83 | | -| `CLAW_WS_AUTH_TOKEN` | WebSocket auth token (optional) | |
84 | | -| `OPENCLAW_GATEWAY_*` | OpenClaw gateway host, port, token (optional) | |
| 71 | +- 长期记忆:`/memory/MEMORY.md` |
| 72 | +- 每日笔记:`/memory/daily/YYYY-MM-DD.md` |
| 73 | +- 人设和用户画像:通过 `SOUL.md`、`USER.md` 与上下文构建模块注入系统提示词 |
| 74 | +- 技能系统:`skills/*.md` 自动汇总并注入 prompt |
85 | 75 |
|
86 | | -> **Note:** `tuya_app_config_secrets.h` is gitignored — never commit real credentials. |
| 76 | +--- |
87 | 77 |
|
88 | | -### 4. Select a board configuration |
| 78 | +## 部署平台 |
89 | 79 |
|
90 | | -Copy one of the pre-built configs from `config/` to the project root: |
| 80 | +| 类别 | 当前状态 | |
| 81 | +|---|---| |
| 82 | +| Raspberry Pi / Linux ARM | 推荐,仓库内已提供 `config/RaspberryPi.config` | |
| 83 | +| Linux x64 | 可运行(同样走 Linux 构建链路) | |
| 84 | +| 其他 TuyaOpen 板卡 | 可按 TuyaOpen 方式迁移配置(当前仓库未内置对应 config 快照) | |
| 85 | + |
| 86 | +--- |
| 87 | + |
| 88 | +## 快速开始 |
| 89 | + |
| 90 | +### 1) 拉取项目与子模块 |
91 | 91 |
|
92 | 92 | ```bash |
93 | | -# Raspberry Pi |
94 | | -cp config/RaspberryPi.config app_default.config |
| 93 | +git clone <your-fork-or-repo-url> VirtuaMate |
| 94 | +cd VirtuaMate |
| 95 | +git submodule update --init --recursive |
95 | 96 | ``` |
96 | 97 |
|
97 | | -Or create your own via `menuconfig`: |
| 98 | +### 2) 安装 Linux 渲染依赖(Raspberry Pi / Ubuntu) |
| 99 | + |
| 100 | +`CMakeLists.txt` 中 Linux 平台依赖为 `sdl2 glew assimp`: |
98 | 101 |
|
99 | 102 | ```bash |
100 | | -cd TuyaOpen |
101 | | -python3 tos.py menuconfig |
102 | | -cd .. |
| 103 | +sudo apt update |
| 104 | +sudo apt install -y libsdl2-dev libglew-dev libassimp-dev |
103 | 105 | ``` |
104 | 106 |
|
105 | | -### 5. Build |
| 107 | +### 3) 选择板级配置 |
106 | 108 |
|
107 | 109 | ```bash |
108 | | -# Skip interactive platform prompts (optional, one-time) |
109 | | -mkdir -p .cache && touch .cache/.dont_prompt_update_platform |
| 110 | +cp config/RaspberryPi.config app_default.config |
| 111 | +或 |
| 112 | +tos.py config choice |
| 113 | +``` |
| 114 | + |
| 115 | +### 4) 准备 TuyaOpen 环境并构建 |
110 | 116 |
|
| 117 | +```bash |
111 | 118 | cd TuyaOpen |
112 | | -python3 tos.py build |
| 119 | +. ./export.sh |
| 120 | +cd VirtuaMate |
| 121 | +tos.py build |
113 | 122 | ``` |
114 | 123 |
|
115 | | -Build output goes to the `dist/` directory. On Linux targets this produces a native ELF binary. |
| 124 | +构建产物在 `VirtuaMate/dist/`。 |
116 | 125 |
|
117 | | -### 6. Install VRM dependencies (Linux / Raspberry Pi only) |
| 126 | +--- |
118 | 127 |
|
119 | | -If you are building on Linux or Raspberry Pi and want the 3D avatar renderer: |
| 128 | +## 资源准备(让她“活起来”) |
120 | 129 |
|
121 | | -```bash |
122 | | -sudo apt install libsdl2-dev libglew-dev libassimp-dev |
123 | | -``` |
| 130 | +`RaspberryPi.config` 默认资源路径: |
124 | 131 |
|
125 | | -Configure model paths in `menuconfig` or directly in `app_default.config`: |
| 132 | +- 模型:`resources/models/avatar.vrm` |
| 133 | +- 动作目录:`resources/animations` |
| 134 | +- 场景父目录:`resources/scenes` |
126 | 135 |
|
127 | | -``` |
128 | | -CONFIG_VRM_MODEL_PATH="/path/to/your/avatar.vrm" |
129 | | -CONFIG_VRM_ANIM_DIR="/path/to/vrma/animations" |
130 | | -CONFIG_VRM_WINDOW_WIDTH=1024 |
131 | | -CONFIG_VRM_WINDOW_HEIGHT=768 |
132 | | -``` |
| 136 | +### 场景天空盒命名规则 |
133 | 137 |
|
134 | | -### 7. Run |
| 138 | +每个场景目录需提供 6 张贴图,支持以下任一命名体系: |
135 | 139 |
|
136 | | -```bash |
137 | | -# Linux |
138 | | -./dist/VirtuaMate |
139 | | -``` |
| 140 | +- `right/left/top/bottom/front/back` |
| 141 | +- `px/nx/py/ny/pz/nz` |
| 142 | +- `posx/negx/posy/negy/posz/negz` |
140 | 143 |
|
141 | | -On Raspberry Pi, flash or copy the binary and run it. The agent will connect to Tuya cloud, initialize the configured IM channel, and start listening for messages. |
| 144 | +扩展名支持 `.jpg/.jpeg/.png/.bmp/.tga`。 |
142 | 145 |
|
143 | | -## Project Structure |
| 146 | +--- |
144 | 147 |
|
145 | | -``` |
| 148 | +## 目录结构(核心) |
| 149 | + |
| 150 | +```text |
146 | 151 | VirtuaMate/ |
147 | | -├── agent/ # Core agent loop and context builder |
148 | | -├── IM/ # IM abstraction: message bus, channel bots, proxy, CLI |
149 | | -├── tools/ # MCP tool implementations (files, cron, exec, openclaw) |
150 | | -├── memory/ # Persistent memory and session management |
151 | | -├── gateway/ # WebSocket server and ACP client |
152 | | -├── cron_service/ # Background scheduled-task service |
153 | | -├── heartbeat/ # Heartbeat service |
154 | | -├── skills/ # Skill loader for .md skill files |
155 | | -├── src/ # App glue: main entry, AI chat handler, IM dispatch |
156 | | -│ └── vrm/ # VRM 3D avatar renderer (OpenGL) |
157 | | -├── include/ # Global headers and config |
158 | | -├── ai_components/ # TuyaOpen AI component adapters |
159 | | -├── config/ # Board-level Kconfig presets |
160 | | -├── TuyaOpen/ # TuyaOpen SDK (git submodule) |
161 | | -├── CMakeLists.txt # Application-level build script |
162 | | -└── Kconfig # Top-level Kconfig menu |
| 152 | +├── agent/ # Agent loop + context builder |
| 153 | +├── IM/ # Telegram/Discord/Feishu/CLI + message bus |
| 154 | +├── tools/ # MCP tools (files/cron/exec/openclaw) |
| 155 | +├── memory/ # MEMORY.md + daily notes + session |
| 156 | +├── gateway/ # WebSocket / ACP gateway |
| 157 | +├── skills/ # Markdown skills |
| 158 | +├── src/ |
| 159 | +│ ├── tuya_app_main.c # 应用入口与初始化 |
| 160 | +│ ├── ducky_claw_chat.c # AI流事件处理与对话桥接 |
| 161 | +│ ├── app_avatar_mcp.c # 3D Avatar MCP工具注册 |
| 162 | +│ └── vrm/ # VRM渲染、情绪、口型、天空盒 |
| 163 | +├── config/RaspberryPi.config |
| 164 | +└── TuyaOpen/ # TuyaOpen SDK 子模块 |
163 | 165 | ``` |
164 | 166 |
|
165 | | -## License |
| 167 | +--- |
| 168 | + |
| 169 | +## 高级玩法 |
| 170 | + |
| 171 | +- **改人设**:调整 `SOUL.md`、`USER.md`,并结合 `agent/context_builder.c` 注入策略。 |
| 172 | +- **加动作**:把 `.vrma` 放进 `resources/animations`,在 `src/app_avatar_mcp.c` 中补充可调用动作名。 |
| 173 | +- **加场景**:在 `resources/scenes/<scene_name>/` 放入 6 面贴图,运行时切换。 |
| 174 | +- **扩工具**:在 `tools/` 新增 MCP 工具并在 `tools/tools_register.c` 注册。 |
| 175 | +- **扩能力**:想接摄像头、传感器、IoT 控制链路,可复用 TuyaOpen + MCP 工具模式扩展。 |
| 176 | + |
| 177 | +--- |
| 178 | + |
| 179 | +## 项目定位 |
| 180 | + |
| 181 | +VirtuaMate 不是“AI 套个皮肤”,而是一套可定制、可运行、可执行、可持续进化的 3D AI 伴侣系统。 |
| 182 | +它既有 OpenClaw 系的执行锋芒,也有数字伴侣该有的温度和存在感。 |
166 | 183 |
|
167 | | -Copyright (c) Tuya Inc. All Rights Reserved. |
| 184 | +给她一张脸、一个名字、一段性格,然后见证她从“能聊”变成“懂你、帮你、陪你”。 |
0 commit comments