Metadata-Version: 2.4
Name: teambot-ai
Version: 1.50.0
Summary: 团队协作型AI助手 - Team Collaboration AI Assistant
Home-page: https://github.com/ctz168/teambot
Author: ctz168
Author-email: ctz168 <ctz168@users.noreply.github.com>
License: MIT
Project-URL: Homepage, https://teambot.samai.cc
Project-URL: Repository, https://github.com/ctz168/teambot
Project-URL: Issues, https://github.com/ctz168/teambot/issues
Keywords: ai-assistant,agent,team,collaboration,desktop,open-interpreter,llm,chatbot,multi-agent,memory
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Operating System :: OS Independent
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Requires-Dist: openai>=1.12.0
Requires-Dist: aiohttp>=3.9.0
Requires-Dist: requests>=2.31.0
Requires-Dist: duckduckgo-search>=6.0.0
Requires-Dist: beautifulsoup4>=4.12.0
Requires-Dist: lxml>=5.0.0
Requires-Dist: psutil>=5.9.0
Requires-Dist: Pillow>=10.0.0
Requires-Dist: edge-tts>=6.1.0
Requires-Dist: pynput>=1.7.6
Requires-Dist: pynacl>=1.5.0
Provides-Extra: telegram
Requires-Dist: python-telegram-bot>=21.0; extra == "telegram"
Provides-Extra: discord
Requires-Dist: discord.py>=2.3.0; extra == "discord"
Provides-Extra: anthropic
Requires-Dist: anthropic>=0.18.0; extra == "anthropic"
Provides-Extra: communication
Requires-Dist: cryptography>=41.0.0; extra == "communication"
Requires-Dist: websockets>=12.0; extra == "communication"
Provides-Extra: voice
Requires-Dist: funasr>=1.1.0; extra == "voice"
Requires-Dist: torch>=2.0.0; extra == "voice"
Requires-Dist: torchaudio>=2.0.0; extra == "voice"
Provides-Extra: all
Requires-Dist: python-telegram-bot>=21.0; extra == "all"
Requires-Dist: discord.py>=2.3.0; extra == "all"
Requires-Dist: anthropic>=0.18.0; extra == "all"
Requires-Dist: cryptography>=41.0.0; extra == "all"
Requires-Dist: websockets>=12.0; extra == "all"
Requires-Dist: funasr>=1.1.0; extra == "all"
Requires-Dist: torch>=2.0.0; extra == "all"
Requires-Dist: torchaudio>=2.0.0; extra == "all"
Dynamic: author
Dynamic: home-page
Dynamic: requires-python

# TeamBot - 团队协作型AI助手

> 🤖 一个面向团队协作的执行力强、记忆力极强、运行稳定的本地桌面端AI助手。
> 支持 Windows / macOS / Linux，系统托盘后台运行。
> Open Interpreter 风格执行引擎 + 三层记忆系统 + 多Agent架构 + 多平台接入。

---

## 🌟 核心特性

### 🚀 执行引擎
- **多语言执行**: Python / Shell (Bash) / PowerShell / CMD
- **安全控制**: 危险命令拦截、超时控制、输出截断
- **结构化结果**: 执行结果标准化，LLM 稳定理解

### 🧠 三层记忆系统
- **短期记忆**: 对话上下文，自动淘汰旧消息
- **工作记忆**: 任务进度、执行步骤、中间结果
- **长期记忆**: 用户偏好、技能经验、错误模式
- **SQLite 持久化**: 本地存储，支持跨会话检索

### 🤝 多Agent架构
- **主Agent**: 任务规划、Agent调度、结果汇总
- **工具Agent**: 代码执行、技能调用、文件操作
- **记忆Agent**: 记忆读写、经验总结、错误记录
- **计划-执行-反思循环**: 自动迭代直到完成

### 👥 团队协作
- **多角色协同**: 支持团队成员间的Agent任务分配与协作
- **知识共享**: 团队记忆库，共享技能与经验
- **AICQ加密通信**: 端到端加密的团队消息通道
- **部门管理**: 按部门组织Agent，权限隔离

### 💬 多聊天平台接入
- **Telegram**: 官方 Bot API
- **Discord**: discord.py
- **飞书**: Webhook 长连接
- **QQ**: OneBot v11 协议
- **微信**: WxPusher / HTTP 桥接
- 纯 Python 实现，无需 Node.js

### 🛠️ 技能系统 (OpenClaw 兼容)
- **文件操作**: 读写、搜索、移动、删除
- **网络搜索**: DuckDuckGo 免API搜索
- **系统操作**: 信息查询、进程管理、环境变量
- **浏览器自动化**: Playwright 驱动
- JSON Schema 定义，支持 LLM Function Calling

### 🛡️ 稳定性保障
- 任务队列机制 (优先级调度)
- 执行超时控制
- 异常捕获与自动恢复
- LLM 输出 JSON 格式强校验
- 无 HTTP 网关、单机原生运行

### 📱 系统托盘
- 后台静默运行
- 开机自启支持
- 日志目录快捷访问
- 可打包为 exe / dmg

---

## 🚀 一键安装

> 💡 **无需手动安装 Python、Node.js 等依赖**，脚本会自动检测并安装所有前置条件。仅复制一行命令即可完成安装。

### pip 安装 (推荐)

```bash
pip install teambot-ai
```

### Windows（PowerShell）

```powershell
powershell -c "irm https://raw.githubusercontent.com/ctz168/teambot/main/install/install.ps1 | iex"
```

> 首次运行时如果 PowerShell 提示执行策略限制，先执行：`Set-ExecutionPolicy RemoteSigned -Scope CurrentUser`

### macOS / Linux

```bash
curl -fsSL https://raw.githubusercontent.com/ctz168/teambot/main/install/install.sh | bash
```

### 快速升级

> 已安装过 TeamBot 的环境下，一行命令更新到最新版：

```bash
teambot-ai update
```

该命令会自动完成：npm 升级全局包 → 检查新增依赖 → 自动启动。

---

## 📋 系统要求

| 项目 | 最低要求 | 推荐配置 |
|------|----------|----------|
| **操作系统** | Windows 10 / macOS 12 / Ubuntu 20.04 | Windows 11 / macOS 14 / Ubuntu 24.04 |
| **Python** | 3.13+ | 3.13+ |
| **Node.js** | 18+ (LTS) | 20+ (LTS) |
| **内存** | 512 MB | 2 GB+ |
| **磁盘空间** | 200 MB | 500 MB+ |

> 安装脚本会自动检测并安装 Python 3.13 和 Node.js 20 LTS，你不需要提前准备任何环境。

---

## ⚙️ 安装后配置

安装完成后，运行 `teambot-ai` 即可启动。首次运行会自动创建配置文件 `~/.teambot/config.json`。

### 1. 配置 LLM

**方式一: 环境变量 (推荐)**
```bash
export TEAMBOT_LLM_API_KEY="sk-your-openai-key"
export TEAMBOT_LLM_MODEL="gpt-4"
```

**方式二: 配置文件**
```bash
# 首次运行会自动创建 ~/.teambot/config.json
teambot-ai
```

**方式三: 使用 Ollama 本地模型 (免费)**
```bash
# 安装 Ollama
curl -fsSL https://ollama.ai/install.sh | sh
ollama pull llama3

# 配置
export TEAMBOT_LLM_PROVIDER="ollama"
export TEAMBOT_OLLAMA_MODEL="llama3"
```

**方式四: 使用 Anthropic Claude**
```bash
export TEAMBOT_LLM_PROVIDER="anthropic"
export TEAMBOT_ANTHROPIC_API_KEY="sk-ant-..."
```

### 2. 运行

```bash
# 更新到最新版（推荐）
teambot-ai update

# Web 管理后台（推荐）
teambot-ai web

# CLI 交互模式
teambot-ai cli

# 系统托盘后台运行
teambot-ai tray

# API 服务模式
teambot-ai server

# 安装/更新依赖
teambot-ai install

# 重装依赖（删除 venv 重建）
teambot-ai reinstall

# 卸载（清除所有数据）
teambot-ai uninstall

# 卸载但保留数据（配置、记忆等）
teambot-ai uninstall --keep-data
```

> 首次运行会自动安装所有依赖，后续启动秒开。

### 3. 配置聊天平台 (可选)

编辑 `~/.teambot/config.json`:

```json
{
  "llm": {
    "provider": "openai",
    "api_key": "sk-...",
    "model": "gpt-4"
  },
  "chat_platforms": [
    {
      "platform": "telegram",
      "enabled": true,
      "token": "YOUR_BOT_TOKEN"
    },
    {
      "platform": "discord",
      "enabled": true,
      "token": "YOUR_DISCORD_BOT_TOKEN"
    }
  ]
}
```

或使用环境变量:
```bash
export TEAMBOT_TELEGRAM_TOKEN="your-telegram-bot-token"
export TEAMBOT_DISCORD_TOKEN="your-discord-bot-token"
```

---

## 💡 使用示例

### CLI 交互
```
👤 你: 帮我在桌面创建一个 hello.py 文件
🤖 助手: ✅ 已在桌面创建 hello.py

👤 你: 搜索最新的Python 3.12新特性
🤖 助手: [搜索结果...]

👤 你: 查看系统信息
🤖 助手: 系统: macOS 14.0 | CPU: 8核 | 内存: 12.3GB可用
```

### CLI 内置命令
| 命令 | 说明 |
|------|------|
| `help` | 显示帮助 |
| `status` | 查看系统状态 |
| `skills` | 列出所有技能 |
| `memory` | 查看记忆统计 |
| `sessions` | 查看会话列表 |
| `session <id>` | 切换会话 |
| `clear` | 清除当前对话历史 |
| `quit` | 退出 |

### 技能调用
```
# 直接调用技能
👤 你: !system_info
👤 你: !file_read path=/tmp/test.txt
👤 你: !web_search query=AI news
```

---

## 🏗️ 扩展开发

### 添加自定义技能
```python
# aiskills/my_skill.py
from aiskills.base import Skill, SkillResult, SkillParameter

class MyCustomSkill(Skill):
    name = "my_skill"
    description = "我的自定义技能"
    category = "custom"
    parameters = [
        SkillParameter("input", "string", "输入参数", required=True),
    ]

    async def execute(self, input: str = "", **kwargs) -> SkillResult:
        # 你的逻辑
        return SkillResult(
            success=True,
            data={"result": input.upper()},
            message=f"处理完成: {input}",
        )
```

技能会自动被发现和注册 (命名规则: `*_skill.py`)。

### 添加自定义聊天平台
```python
# chatbot/my_platform_bot.py
from chatbot.base import BaseChatBot, ChatMessage, ChatResponse

class MyPlatformBot(BaseChatBot):
    platform_name = "my_platform"

    async def start(self):
        # 实现启动逻辑
        pass

    async def stop(self):
        pass

    async def send_message(self, response: ChatResponse) -> bool:
        pass
```

然后在 `chatbot/manager.py` 中注册即可。

---

## 📦 打包

### Windows (exe)
```bash
pip install pyinstaller
pyinstaller --onefile --windowed --icon=icon.ico \
    --add-data "aiskills:aiskills" \
    --add-data "chatbot:chatbot" \
    --name TeamBot main.py
```

### macOS (dmg)
```bash
pyinstaller --onefile --windowed --icon=icon.icns \
    --add-data "aiskills:aiskills" \
    --name TeamBot main.py
# 然后使用 hdiutil 创建 dmg
```

---

## ⚙️ 环境变量参考

| 变量 | 说明 | 默认值 |
|------|------|--------|
| `TEAMBOT_LLM_PROVIDER` | LLM 提供商 | openai |
| `TEAMBOT_LLM_API_KEY` | API Key | - |
| `TEAMBOT_LLM_BASE_URL` | API 地址 | OpenAI 官方 |
| `TEAMBOT_LLM_MODEL` | 模型名称 | gpt-4 |
| `TEAMBOT_LLM_TEMPERATURE` | 温度 | 0.1 |
| `TEAMBOT_TELEGRAM_TOKEN` | Telegram Bot Token | - |
| `TEAMBOT_DISCORD_TOKEN` | Discord Bot Token | - |
| `TEAMBOT_FEISHU_APP_ID` | 飞书 App ID | - |
| `TEAMBOT_FEISHU_APP_SECRET` | 飞书 App Secret | - |
| `TEAMBOT_LOG_LEVEL` | 日志级别 | INFO |

---

## 🔗 相关链接

- **官方网站**: [https://teambot.samai.cc](https://teambot.samai.cc)
- **GitHub**: [https://github.com/ctz168/teambot](https://github.com/ctz168/teambot)
- **PyPI**: [https://pypi.org/project/teambot-ai](https://pypi.org/project/teambot-ai)

---

## 📄 License

MIT
