@ian2018cs/agenthub 0.1.54 → 0.1.56

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.
package/README.md CHANGED
@@ -1,330 +1,277 @@
1
1
  <div align="center">
2
2
  <img src="public/logo.svg" alt="AgentHub" width="64" height="64">
3
3
  <h1>AgentHub</h1>
4
+ <p>基于 Web 的 AI Agent 管理平台,支持桌面与移动端</p>
4
5
  </div>
5
6
 
6
- A desktop and mobile Web UI for AI Agents. You can use it locally or remotely to manage your AI agent sessions and interact with them from everywhere (mobile or desktop). This gives you a proper interface that works everywhere.
7
-
8
- ## Screenshots
7
+ ---
9
8
 
10
- <div align="center">
11
-
12
- <table>
13
- <tr>
14
- <td align="center">
15
- <h3>Desktop View</h3>
16
- <img src="public/screenshots/desktop-main.png" alt="Desktop Interface" width="400">
17
- <br>
18
- <em>Main interface showing project overview and chat</em>
19
- </td>
20
- <td align="center">
21
- <h3>Mobile Experience</h3>
22
- <img src="public/screenshots/mobile-chat.png" alt="Mobile Interface" width="250">
23
- <br>
24
- <em>Responsive mobile design with touch navigation</em>
25
- </td>
26
- </tr>
27
- </table>
9
+ ## 简介
28
10
 
11
+ AgentHub 是一个全功能的 AI Agent Web UI,可本地或远程部署,让你随时随地(手机、电脑)管理和使用 AI Agent 会话。支持 Claude、Gemini、Codex 多种 AI 引擎,并提供飞书 IM 集成、多用户管理、工具安全守卫等企业级特性。
29
12
 
13
+ ## 功能特性
30
14
 
31
- </div>
15
+ ### 核心对话
16
+ - **Claude Agent 对话** — 基于 `@anthropic-ai/claude-agent-sdk`,支持流式响应、工具调用、会话续接
17
+ - **Gemini Shell** — node-pty 驱动 Gemini CLI,xterm.js 渲染真实终端体验
18
+ - **Codex Shell** — node-pty 驱动 Codex CLI,xterm.js 渲染,独立会话隔离
19
+ - **WebSocket 实时通信** — 前后端通过 WebSocket 双向通信,响应实时推送
32
20
 
33
- ## Features
21
+ ### 项目与文件管理
22
+ - **项目管理** — 自动发现 Agent 会话,按项目分组,支持重命名、删除
23
+ - **文件浏览器** — 交互式文件树,支持展开/折叠导航
24
+ - **代码编辑器** — CodeMirror 6 驱动,多语言语法高亮、实时编辑保存
25
+ - **MCP 服务器支持** — 通过 UI 添加、管理自定义 MCP 服务器,自动同步到 Codex
34
26
 
35
- - **Responsive Design** - Works seamlessly across desktop, tablet, and mobile
36
- - **Interactive Chat Interface** - Built-in chat interface for seamless communication with AI agents
37
- - **Integrated Shell Terminal** - Direct access to AI agents through built-in shell functionality
38
- - **File Explorer** - Interactive file tree with syntax highlighting and live editing
39
- - **Session Management** - Resume conversations, manage multiple sessions, and track history
40
- - **MCP Server Support** - Add your own MCP servers through the UI
41
- - **Model Compatibility** - Works with various AI models
27
+ ### 多用户与权限
28
+ - **多用户系统** 注册/登录,JWT 认证,每用户数据完全隔离(独立 UUID 目录)
29
+ - **三级角色** `super_admin`(首个注册用户)、`admin`(受限管理员)、`user`(普通用户)
30
+ - **限额管理** 按用户设置每日使用限额,管理员面板实时查看用量
31
+ - **邮箱域名白名单** 限制注册邮箱域名范围
42
32
 
33
+ ### 飞书 IM 集成
34
+ - **WebSocket 长连接** — 通过 `@larksuiteoapi/node-sdk` 接收飞书消息
35
+ - **单聊对话** — 在飞书直接与 AI Agent 对话
36
+ - **工具审批卡片** — Agent 执行危险操作时,飞书推送审批卡片
37
+ - **语音转文字** — 支持语音消息(需配置 ffmpeg + Whisper)
38
+ - **文件/图片发送** — Agent 可将生成文件自动发送到飞书聊天
43
39
 
44
- ## Quick Start
40
+ ### 安全
41
+ - **工具安全守卫(Tool Guard)** — 双层检测:正则规则快速拦截 + LLM 兜底审查
42
+ - **路径隔离** — 阻止访问用户目录之外的文件系统路径
43
+ - **危险命令拦截** — 阻止 rm -rf、系统文件修改、全局包安装等高危操作
45
44
 
46
- ### Prerequisites
45
+ ### Agent 商店
46
+ - **系统 Agent 仓库** — 发布、安装、管理预置 Agent
47
+ - **版本管理** — 支持 Agent 版本控制与更新
48
+ - **管理员审核** — Agent 提交需管理员审核后才能上架
47
49
 
48
- - [Node.js](https://nodejs.org/) v20 or higher
49
- - [Claude Code CLI](https://docs.anthropic.com/en/docs/claude-code) installed and configured
50
+ ### 其他
51
+ - **图片持久化** 聊天图片 SHA-256 去重存储,30 天自动清理
52
+ - **计费统计** — 按模型精确计算 token 用量和费用
53
+ - **响应式设计** — 桌面、平板、手机全端适配,支持添加到主屏幕
50
54
 
51
- ### One-click Operation (Recommended)
55
+ ---
52
56
 
53
- No installation required, direct operation:
57
+ ## 快速开始
54
58
 
55
- ```bash
56
- npx agenthub
57
- ```
59
+ ### 环境要求
58
60
 
59
- The server will start and be accessible at `http://localhost:3001` (or your configured PORT).
61
+ - [Node.js](https://nodejs.org/) v20 或更高版本
62
+ - [Claude Code CLI](https://docs.anthropic.com/en/docs/claude-code) 已安装并配置
60
63
 
61
- **To restart**: Simply run the same `npx` command again after stopping the server
62
- ### Global Installation (For Regular Use)
64
+ ### 一键运行(推荐)
63
65
 
64
- For frequent use, install globally once:
66
+ 无需安装,直接运行:
65
67
 
66
68
  ```bash
67
- npm install -g agenthub
69
+ npx agenthub
68
70
  ```
69
71
 
70
- Then start with a simple command:
72
+ 服务启动后访问 `http://localhost:3001`(或你配置的端口)。
73
+
74
+ ### 全局安装
71
75
 
72
76
  ```bash
77
+ npm install -g agenthub
73
78
  agenthub
74
79
  ```
75
80
 
81
+ 更新到最新版本:
76
82
 
77
- **To restart**: Stop with Ctrl+C and run `claude-code-ui` again.
78
-
79
- **To update**:
80
83
  ```bash
81
84
  agenthub update
82
85
  ```
83
86
 
84
- ### CLI Usage
87
+ ### CLI 命令
85
88
 
86
- After global installation, you have access to `agenthub` command:
89
+ | 命令 / 选项 | 简写 | 说明 |
90
+ |------------|------|------|
91
+ | `agenthub` | | 启动服务(默认) |
92
+ | `agenthub start` | | 显式启动服务 |
93
+ | `agenthub status` | | 显示配置和数据目录信息 |
94
+ | `agenthub update` | | 更新到最新版本 |
95
+ | `agenthub help` | | 显示帮助信息 |
96
+ | `agenthub version` | | 显示版本信息 |
97
+ | `--port <port>` | `-p` | 指定端口(默认:3001) |
98
+ | `--database-path <path>` | | 指定数据库存储路径 |
87
99
 
88
- | Command / Option | Short | Description |
89
- |------------------|-------|-------------|
90
- | `agenthub` | | Start the server (default) |
91
- | `agenthub start` | | Start the server explicitly |
92
- | `agenthub status` | | Show configuration and data locations |
93
- | `agenthub update` | | Update to the latest version |
94
- | `agenthub help` | | Show help information |
95
- | `agenthub version` | | Show version information |
96
- | `--port <port>` | `-p` | Set server port (default: 3001) |
97
- | `--database-path <path>` | | Set custom database location |
100
+ 示例:
98
101
 
99
- **Examples:**
100
102
  ```bash
101
- agenthub # Start with defaults
102
- agenthub -p 8080 # Start on custom port
103
- agenthub status # Show current configuration
103
+ agenthub -p 8080 # 8080 端口启动
104
+ agenthub status # 查看当前配置
104
105
  ```
105
106
 
106
- ### Run as Background Service (Recommended for Production)
107
-
108
- For production use, run AgentHub as a background service using PM2 (Process Manager 2):
107
+ ### 后台服务(生产环境推荐)
109
108
 
110
- #### Install PM2
109
+ 使用 PM2 作为进程管理器:
111
110
 
112
111
  ```bash
113
112
  npm install -g pm2
114
- ```
115
-
116
- #### Start as Background Service
117
113
 
118
- ```bash
119
- # Start the server in background
114
+ # 启动后台服务
120
115
  pm2 start agenthub --name "agenthub"
121
116
 
122
- # Or using the shorter alias
123
- pm2 start agenthub --name "agenthub"
124
-
125
- # Start on a custom port
117
+ # 在指定端口启动
126
118
  pm2 start agenthub --name "agenthub" -- --port 8080
127
- ```
128
-
129
119
 
130
- #### Auto-Start on System Boot
131
-
132
- To make AgentHub start automatically when your system boots:
133
-
134
- ```bash
135
- # Generate startup script for your platform
120
+ # 开机自启
136
121
  pm2 startup
137
-
138
- # Save current process list
139
122
  pm2 save
140
123
  ```
141
124
 
125
+ ---
142
126
 
143
- ### Local Development Installation
127
+ ## 本地开发
144
128
 
145
- 1. **Clone the repository:**
146
129
  ```bash
147
- git clone https://github.com/IAn2018cs/claudecodeui.git
148
- cd claudecodeui
149
- ```
130
+ # 克隆仓库
131
+ git clone git@git.amberweather.com:share/agenthub.git
132
+ cd agenthub
150
133
 
151
- 2. **Install dependencies:**
152
- ```bash
134
+ # 安装依赖
153
135
  npm install
154
- ```
155
136
 
156
- 3. **Configure environment:**
157
- ```bash
137
+ # 配置环境变量
158
138
  cp .env.example .env
159
- # Edit .env with your preferred settings
160
- ```
139
+ # 编辑 .env 填写所需配置
161
140
 
162
- 4. **Start the application:**
163
- ```bash
164
- # Development mode (with hot reload)
141
+ # 开发模式(React 热重载 + Node 服务器)
165
142
  npm run dev
166
-
167
143
  ```
168
- The application will start at the port you specified in your .env
169
-
170
- 5. **Open your browser:**
171
- - Development: `http://localhost:3001`
172
144
 
173
- ## Security & Tools Configuration
145
+ 其他开发命令:
174
146
 
175
- **🔒 Important Notice**: All agent tools are **disabled by default**. This prevents potentially harmful operations from running automatically.
147
+ ```bash
148
+ npm run build # 生产构建
149
+ npm run start # 构建 + 启动服务器
150
+ npm run server # 仅启动 Node 服务器
151
+ npm run client # 仅启动 Vite dev 服务器
152
+ ```
176
153
 
177
- ### Enabling Tools
154
+ ---
178
155
 
179
- To use full functionality, you'll need to manually enable tools:
156
+ ## 环境变量配置
180
157
 
181
- 1. **Open Tools Settings** - Click the gear icon in the sidebar
182
- 3. **Enable Selectively** - Turn on only the tools you need
183
- 4. **Apply Settings** - Your preferences are saved locally
158
+ `.env` 文件中配置以下变量:
184
159
 
185
- <div align="center">
160
+ ### 基础配置
186
161
 
187
- ![Tools Settings Modal](public/screenshots/tools-modal.png)
188
- *Tools Settings interface - enable only what you need*
162
+ | 变量 | 说明 |
163
+ |------|------|
164
+ | `PORT` | 服务端口,默认 `3001` |
165
+ | `JWT_SECRET` | JWT 签名密钥(必填) |
166
+ | `ANTHROPIC_API_KEY` | Anthropic API Key |
189
167
 
190
- </div>
168
+ ### 飞书集成(可选)
191
169
 
192
- **Recommended approach**: Start with basic tools enabled and add more as needed. You can always adjust these settings later.
170
+ | 变量 | 说明 |
171
+ |------|------|
172
+ | `FEISHU_APP_ID` | 飞书应用 App ID |
173
+ | `FEISHU_APP_SECRET` | 飞书应用 App Secret |
174
+ | `FEISHU_MENU_KEY_MAP` | JSON 格式,event_key → 斜杠命令映射 |
175
+ | `FEISHU_CARD_*_ID` | 各类消息卡片模板 ID |
193
176
 
194
- ## Usage Guide
177
+ 设置 `FEISHU_APP_ID` 和 `FEISHU_APP_SECRET` 即可自动启用飞书集成。
195
178
 
196
- ### Core Features
179
+ ### 语音转文字(可选,需飞书集成)
197
180
 
198
- #### Project Management
199
- It automatically discovers agent sessions and groups them together into projects
200
- session counts
201
- - **Project Actions** - Rename, delete, and organize projects
202
- - **Smart Navigation** - Quick access to recent projects and sessions
203
- - **MCP support** - Add your own MCP servers through the UI
181
+ | 变量 | 说明 |
182
+ |------|------|
183
+ | `WHISPER_*` | Whisper 语音识别相关配置 |
204
184
 
205
- #### Chat Interface
206
- - **Use responsive chat or CLI** - You can either use the adapted chat interface or use the shell button to connect to CLI.
207
- - **Real-time Communication** - Stream responses from AI agents with WebSocket connection
208
- - **Session Management** - Resume previous conversations or start fresh sessions
209
- - **Message History** - Complete conversation history with timestamps and metadata
210
- - **Multi-format Support** - Text, code blocks, and file references
185
+ ### 工具安全守卫(可选)
211
186
 
212
- #### File Explorer & Editor
213
- - **Interactive File Tree** - Browse project structure with expand/collapse navigation
214
- - **Live File Editing** - Read, modify, and save files directly in the interface
215
- - **Syntax Highlighting** - Support for multiple programming languages
216
- - **File Operations** - Create, rename, delete files and directories
187
+ | 变量 | 说明 | 默认值 |
188
+ |------|------|--------|
189
+ | `TOOL_GUARD_ENABLED` | 总开关 | `false` |
190
+ | `TOOL_GUARD_LLM_ENABLED` | LLM 审查开关 | `false` |
191
+ | `TOOL_GUARD_LLM_MODEL` | LLM 审查模型 | `gemini-3.1-flash-lite-preview` |
192
+ | `TOOL_GUARD_LLM_TIMEOUT_MS` | LLM 超时时间(毫秒) | `5000` |
193
+ | `TOOL_GUARD_VERBOSE` | 详细日志 | `false` |
217
194
 
218
- #### Session Management
219
- - **Session Persistence** - All conversations automatically saved
220
- - **Session Organization** - Group sessions by project and timestamp
221
- - **Session Actions** - Rename, delete, and export conversation history
222
- - **Cross-device Sync** - Access sessions from any device
195
+ ### LLM 通用配置(Tool Guard LLM 审查用)
223
196
 
224
- ### Mobile App
225
- - **Responsive Design** - Optimized for all screen sizes
226
- - **Touch-friendly Interface** - Swipe gestures and touch navigation
227
- - **Mobile Navigation** - Bottom tab bar for easy thumb navigation
228
- - **Adaptive Layout** - Collapsible sidebar and smart content prioritization
229
- - **Add shortcut to Home Screen** - Add a shortcut to your home screen and the app will behave like a PWA
197
+ | 变量 | 说明 |
198
+ |------|------|
199
+ | `OPENAI_API_KEY` | OpenAI 兼容 API Key |
200
+ | `OPENAI_BASE_URL` | OpenAI 兼容 API Base URL |
230
201
 
231
- ## Architecture
202
+ ---
232
203
 
233
- ### System Overview
204
+ ## 架构概览
234
205
 
235
206
  ```
236
- ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
237
- Frontend │ │ Backend │ │ Agent
238
- (React/Vite) │◄──►│ (Express/WS) │◄──►│ Integration
239
- │ │ │ │
240
- └─────────────────┘ └─────────────────┘ └─────────────────┘
207
+ ┌──────────────────────┐ ┌──────────────────────┐ ┌──────────────────────┐
208
+ 前端 (React + Vite) │◄──►│ 后端 (Express + WS) │◄──►│ AI 引擎集成
209
+ │ │ │ │ Claude / Gemini
210
+ - ChatInterface │ │ - claude-sdk.js │ │ / Codex
211
+ │ - GeminiShell │ │ - WebSocket 路由 │ │ │
212
+ │ - CodexShell │ │ - REST API │ └──────────────────────┘
213
+ │ - CodeEditor │ │ - SQLite (DB) │
214
+ │ - AdminPanel │ │ - Tool Guard │ ┌──────────────────────┐
215
+ └──────────────────────┘ │ - 飞书 IM 服务 │◄──►│ 飞书 IM │
216
+ └──────────────────────┘ │ (长连接 WS) │
217
+ └──────────────────────┘
241
218
  ```
242
219
 
243
- ### Backend (Node.js + Express)
244
- - **Express Server** - RESTful API with static file serving
245
- - **WebSocket Server** - Communication for chats and project refresh
246
- - **Agent Integration** - Process spawning and management
247
- - **File System API** - Exposing file browser for projects
220
+ ### 技术栈
221
+
222
+ | 层级 | 技术 |
223
+ |------|------|
224
+ | 前端框架 | React 18 + Vite 7 |
225
+ | 样式 | Tailwind CSS 3.4 |
226
+ | 代码编辑器 | CodeMirror 6 |
227
+ | 终端 | xterm.js |
228
+ | 后端框架 | Node.js 20+ + Express 4 |
229
+ | 实时通信 | WebSocket (`ws`) |
230
+ | 数据库 | better-sqlite3 |
231
+ | 终端进程 | node-pty |
232
+ | AI SDK | `@anthropic-ai/claude-agent-sdk` |
233
+ | 飞书 SDK | `@larksuiteoapi/node-sdk` |
248
234
 
249
- ### Frontend (React + Vite)
250
- - **React 18** - Modern component architecture with hooks
251
- - **CodeMirror** - Advanced code editor with syntax highlighting
252
-
253
-
254
-
255
-
256
-
257
- ### Contributing
258
-
259
- We welcome contributions! Please follow these guidelines:
260
-
261
- #### Getting Started
262
- 1. **Fork** the repository
263
- 2. **Clone** your fork: `git clone <your-fork-url>`
264
- 3. **Install** dependencies: `npm install`
265
- 4. **Create** a feature branch: `git checkout -b feature/amazing-feature`
266
-
267
- #### Development Process
268
- 1. **Make your changes** following the existing code style
269
- 2. **Test thoroughly** - ensure all features work correctly
270
- 3. **Run quality checks**: `npm run lint && npm run format`
271
- 4. **Commit** with descriptive messages following [Conventional Commits](https://conventionalcommits.org/)
272
- 5. **Push** to your branch: `git push origin feature/amazing-feature`
273
- 6. **Submit** a Pull Request with:
274
- - Clear description of changes
275
- - Screenshots for UI changes
276
- - Test results if applicable
277
-
278
- #### What to Contribute
279
- - **Bug fixes** - Help us improve stability
280
- - **New features** - Enhance functionality (discuss in issues first)
281
- - **Documentation** - Improve guides and API docs
282
- - **UI/UX improvements** - Better user experience
283
- - **Performance optimizations** - Make it faster
284
-
285
- ## Troubleshooting
235
+ ---
286
236
 
287
- ### Common Issues & Solutions
237
+ ## 工具设置
288
238
 
239
+ > **注意**:所有 Agent 工具默认关闭,防止自动执行高风险操作。
289
240
 
290
- #### "No projects found"
291
- **Problem**: The UI shows no projects or empty project list
292
- **Solutions**:
293
- - Ensure you have initialized at least one project
294
- - Verify `~/.claude/projects/` directory exists and has proper permissions
241
+ 开启工具步骤:
242
+ 1. 点击侧边栏齿轮图标打开设置
243
+ 2. 进入"工具设置"
244
+ 3. 按需开启所需工具
245
+ 4. 设置会自动保存
295
246
 
296
- #### File Explorer Issues
297
- **Problem**: Files not loading, permission errors, empty directories
298
- **Solutions**:
299
- - Check project directory permissions (`ls -la` in terminal)
300
- - Verify the project path exists and is accessible
301
- - Review server console logs for detailed error messages
302
- - Ensure you're not trying to access system directories outside project scope
247
+ 建议从基础工具开始,按需逐步开启。
303
248
 
249
+ ---
304
250
 
305
- ## License
251
+ ## 常见问题
306
252
 
307
- GNU General Public License v3.0 - see [LICENSE](LICENSE) file for details.
253
+ **无项目显示**
254
+ - 确认至少初始化了一个项目
255
+ - 检查 `~/.claude/projects/` 目录是否存在且有读取权限
308
256
 
309
- This project is open source and free to use, modify, and distribute under the GPL v3 license.
257
+ **文件浏览器无法加载**
258
+ - 检查项目目录权限(`ls -la`)
259
+ - 确认项目路径存在且可访问
260
+ - 查看服务器控制台日志获取详细错误信息
310
261
 
311
- ## Acknowledgments
262
+ **飞书集成不工作**
263
+ - 确认 `FEISHU_APP_ID` 和 `FEISHU_APP_SECRET` 已正确设置
264
+ - 检查飞书应用是否已开启事件订阅
265
+ - 确认机器人已被添加到对应群/单聊
312
266
 
313
- ### Built With
314
- - **[React](https://react.dev/)** - User interface library
315
- - **[Vite](https://vitejs.dev/)** - Fast build tool and dev server
316
- - **[Tailwind CSS](https://tailwindcss.com/)** - Utility-first CSS framework
317
- - **[CodeMirror](https://codemirror.net/)** - Advanced code editor
267
+ ---
318
268
 
319
- ## Support & Community
269
+ ## 许可证
320
270
 
321
- ### Stay Updated
322
- - **Star** this repository to show support
323
- - **Watch** for updates and new releases
324
- - **Follow** the project for announcements
271
+ MIT License — 详见 [LICENSE](LICENSE) 文件。
325
272
 
326
273
  ---
327
274
 
328
275
  <div align="center">
329
- <strong>Made with care for the AI community.</strong>
276
+ <strong>为 AI 开发者打造的一站式 Agent 管理平台</strong>
330
277
  </div>