agent-window 1.0.0 → 1.0.2
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 +21 -8
- package/README.zh-CN.md +151 -0
- package/bin/cli.js +45 -0
- package/docs/WEB_UI_GUIDE.md +249 -0
- package/package.json +15 -3
- package/scripts/test-platform.js +109 -0
- package/src/api/routes/index.js +25 -0
- package/src/api/routes/instances.js +252 -0
- package/src/api/routes/operations.js +118 -0
- package/src/api/routes/system.js +42 -0
- package/src/api/server.js +147 -0
- package/src/api/websocket/index.js +16 -0
- package/src/api/websocket/logs.js +127 -0
- package/src/cli/commands/add.js +80 -0
- package/src/cli/commands/config.js +192 -0
- package/src/cli/commands/index.js +89 -0
- package/src/cli/commands/info.js +94 -0
- package/src/cli/commands/list.js +72 -0
- package/src/cli/commands/logs.js +67 -0
- package/src/cli/commands/remove.js +97 -0
- package/src/cli/commands/restart.js +67 -0
- package/src/cli/commands/start.js +101 -0
- package/src/cli/commands/status.js +95 -0
- package/src/cli/commands/stop.js +53 -0
- package/src/cli/commands/ui.js +51 -0
- package/src/cli/index.js +110 -0
- package/src/core/config.js +5 -10
- package/src/core/instance/backup-manager.js +172 -0
- package/src/core/instance/config-manager.js +279 -0
- package/src/core/instance/index.js +62 -0
- package/src/core/instance/manager.js +220 -0
- package/src/core/instance/pm2-bridge.js +205 -0
- package/src/core/instance/validator.js +161 -0
- package/src/core/platform/detector.js +142 -0
- package/src/core/platform/docker-bridge.js +372 -0
- package/src/core/platform/index.js +27 -0
- package/src/core/platform/paths.js +112 -0
- package/src/core/platform/pm2-bridge.js +314 -0
- package/web/dist/assets/Dashboard-C1smB9Nj.js +1 -0
- package/web/dist/assets/Dashboard-ezbZMSpZ.css +1 -0
- package/web/dist/assets/InstanceDetail-CRPMV7rg.css +1 -0
- package/web/dist/assets/InstanceDetail-C_Ddtrog.js +3 -0
- package/web/dist/assets/Instances-CvnH8iDv.css +1 -0
- package/web/dist/assets/Instances-_u2__M83.js +1 -0
- package/web/dist/assets/Settings-CAu3R9RW.css +1 -0
- package/web/dist/assets/Settings-CIa9MX7m.js +1 -0
- package/web/dist/assets/_plugin-vue_export-helper-DlAUqK2U.js +1 -0
- package/web/dist/assets/element-plus-Jr6qTeY5.js +37 -0
- package/web/dist/assets/main-CalRvcyG.css +1 -0
- package/web/dist/assets/main-D3cdXAiV.js +7 -0
- package/web/dist/assets/vue-vendor-CGSlMM3Y.js +29 -0
- package/web/dist/index.html +16 -0
- package/SECURITY.md +0 -31
- package/docs/legacy/DEVELOPMENT.md +0 -174
- package/docs/legacy/HANDOVER.md +0 -149
package/README.md
CHANGED
|
@@ -5,19 +5,32 @@
|
|
|
5
5
|
</p>
|
|
6
6
|
|
|
7
7
|
<p align="center">
|
|
8
|
-
|
|
8
|
+
<i>A simple yet powerful interface to interact with AI agents through familiar chat platforms</i>
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
<p align="center">
|
|
12
|
+
<a href="README.zh-CN.md">中文版</a> | <a href="README.md">English</a>
|
|
9
13
|
</p>
|
|
10
14
|
|
|
11
15
|
---
|
|
12
16
|
|
|
13
|
-
##
|
|
17
|
+
## Why AgentWindow?
|
|
18
|
+
|
|
19
|
+
**AgentWindow = Your Chat App + Powerful AI Backend**
|
|
20
|
+
|
|
21
|
+
- **Dead Simple Interaction** - Chat naturally in Discord/Slack/Telegram, no new UI to learn
|
|
22
|
+
- **Unified Window** - All AI agent capabilities presented through one familiar interface
|
|
23
|
+
- **Multi-Platform Ready** - Discord today, seamlessly switch to Slack or Telegram tomorrow
|
|
24
|
+
- **Secure Isolation** - Docker sandboxed environment keeps AI operations separate from your system
|
|
25
|
+
- **Permission Control** - Approve sensitive operations via chat buttons, stay in control
|
|
26
|
+
- **Multi-Bot Management** - One codebase, multiple projects, unified management
|
|
27
|
+
|
|
28
|
+
### Use Cases
|
|
14
29
|
|
|
15
|
-
- **
|
|
16
|
-
- **
|
|
17
|
-
- **
|
|
18
|
-
- **
|
|
19
|
-
- **Session Management** - Resume conversations, channel binding
|
|
20
|
-
- **Multi-Bot Ready** - Unified management for multiple instances
|
|
30
|
+
- **Code Collaboration** - Have an AI team work directly in your development channels
|
|
31
|
+
- **Document Processing** - Feed documents to AI, get structured outputs
|
|
32
|
+
- **Data Analysis** - Describe requirements, AI processes and returns results
|
|
33
|
+
- **Task Automation** - Trigger scripts and scheduled tasks via chat
|
|
21
34
|
|
|
22
35
|
---
|
|
23
36
|
|
package/README.zh-CN.md
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
# AgentWindow
|
|
2
|
+
|
|
3
|
+
<p align="center">
|
|
4
|
+
<strong>简单而强大的 AI 代理交互窗口</strong>
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
<i>通过熟悉的聊天平台,轻松驾驭后端 AI 能力</i>
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
<p align="center">
|
|
12
|
+
<a href="README.zh-CN.md">🇨🇳 中文版</a> | <a href="README.md">🇺🇸 English</a>
|
|
13
|
+
</p>
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## 为什么选择 AgentWindow?
|
|
18
|
+
|
|
19
|
+
**AgentWindow = 你的聊天软件 + 强大 AI 后端**
|
|
20
|
+
|
|
21
|
+
- **极简交互** - 在 Discord/Slack/Telegram 中自然对话,无需学习新界面
|
|
22
|
+
- **统一窗口** - 所有 AI 代理能力通过一个"窗口"呈现,像使用同事一样简单
|
|
23
|
+
- **多平台支持** - 今天用 Discord,明天无缝切换到 Slack 或 Telegram
|
|
24
|
+
- **安全隔离** - Docker 沙箱环境,AI 操作与你的系统安全隔离
|
|
25
|
+
- **权限可控** - 通过聊天按钮批准敏感操作,完全掌控 AI 行为
|
|
26
|
+
- **多实例管理** - 一套代码,多个项目,统一管理
|
|
27
|
+
|
|
28
|
+
### 适用场景
|
|
29
|
+
|
|
30
|
+
- **代码协作** - 让 AI 团队直接在你的开发频道中工作
|
|
31
|
+
- **文档处理** - 扔给 AI 文档,获得结构化输出
|
|
32
|
+
- **数据分析** - 描述需求,AI 处理后返回结果
|
|
33
|
+
- **自动化任务** - 通过聊天触发脚本和定时任务
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## 快速开始
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
# 全局安装
|
|
41
|
+
npm install -g agent-window
|
|
42
|
+
|
|
43
|
+
# 初始化多机器人目录
|
|
44
|
+
agent-window init
|
|
45
|
+
|
|
46
|
+
# 添加一个机器人实例
|
|
47
|
+
agent-window add-bot myproject
|
|
48
|
+
|
|
49
|
+
# 启动所有机器人
|
|
50
|
+
pm2 start ~/bots/ecosystem.config.cjs
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## CLI 命令
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
# 单机器人命令
|
|
59
|
+
agent-window setup # 交互式设置向导
|
|
60
|
+
agent-window start # 启动网关
|
|
61
|
+
agent-window stop # 停止网关
|
|
62
|
+
agent-window restart # 重启网关
|
|
63
|
+
agent-window status # 显示状态
|
|
64
|
+
agent-window logs # 查看日志(实时)
|
|
65
|
+
agent-window update # 更新到最新版本
|
|
66
|
+
agent-window config # 显示配置位置
|
|
67
|
+
|
|
68
|
+
# 多机器人命令
|
|
69
|
+
agent-window init # 初始化 ~/bots 目录
|
|
70
|
+
agent-window add-bot <name> # 添加新的机器人实例
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
## 配置
|
|
76
|
+
|
|
77
|
+
每个机器人实例都有自己的 `config.json`:
|
|
78
|
+
|
|
79
|
+
```json
|
|
80
|
+
{
|
|
81
|
+
"BOT_TOKEN": "你的 Discord 机器人令牌",
|
|
82
|
+
"CLAUDE_CODE_OAUTH_TOKEN": "你的 Claude Code OAuth 令牌",
|
|
83
|
+
"PROJECT_DIR": "/你的/项目/路径",
|
|
84
|
+
"ALLOWED_CHANNELS": "频道ID-1,频道ID-2"
|
|
85
|
+
}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### 必填项
|
|
89
|
+
|
|
90
|
+
| 键 | 说明 |
|
|
91
|
+
|-----|------|
|
|
92
|
+
| `BOT_TOKEN` | Discord 机器人令牌 |
|
|
93
|
+
| `CLAUDE_CODE_OAUTH_TOKEN` | Claude Code OAuth 令牌 |
|
|
94
|
+
| `PROJECT_DIR` | 要工作的项目目录 |
|
|
95
|
+
| `ALLOWED_CHANNELS` | 逗号分隔的频道 ID |
|
|
96
|
+
|
|
97
|
+
### 可选项
|
|
98
|
+
|
|
99
|
+
查看 `config/config.example.json` 了解所有选项。
|
|
100
|
+
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
## 聊天命令
|
|
104
|
+
|
|
105
|
+
在 Discord 中,提及机器人:
|
|
106
|
+
|
|
107
|
+
```
|
|
108
|
+
@bot <消息> # 发送消息(继续上次会话)
|
|
109
|
+
@bot -n <消息> # 开始新会话
|
|
110
|
+
@bot -r <会话ID> <消息> # 恢复指定会话
|
|
111
|
+
@bot /pick # 选择会话(按钮界面)
|
|
112
|
+
@bot /sessions # 列出最近的会话
|
|
113
|
+
@bot /status # 显示机器人状态
|
|
114
|
+
@bot /help # 显示帮助
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
---
|
|
118
|
+
|
|
119
|
+
## 多机器人管理
|
|
120
|
+
|
|
121
|
+
在一个目录中组织多个机器人实例:
|
|
122
|
+
|
|
123
|
+
```
|
|
124
|
+
~/bots/
|
|
125
|
+
├── agent-window/ # 共享代码(链接到全局安装)
|
|
126
|
+
├── project1/config.json # 机器人1 配置
|
|
127
|
+
├── project2/config.json # 机器人2 配置
|
|
128
|
+
└── ecosystem.config.cjs # PM2 统一管理
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
**统一命令:**
|
|
132
|
+
```bash
|
|
133
|
+
pm2 start ~/bots/ecosystem.config.cjs # 启动所有
|
|
134
|
+
pm2 stop all # 停止所有
|
|
135
|
+
pm2 restart all # 重启所有
|
|
136
|
+
pm2 logs # 查看所有日志
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
## 更新
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
agent-window update
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
---
|
|
148
|
+
|
|
149
|
+
## 许可证
|
|
150
|
+
|
|
151
|
+
MIT
|
package/bin/cli.js
CHANGED
|
@@ -662,6 +662,44 @@ async function addBot() {
|
|
|
662
662
|
log(' pm2 start ' + ecosystemFile + ' --only bot-' + botName);
|
|
663
663
|
}
|
|
664
664
|
|
|
665
|
+
// UI - Launch Web Interface
|
|
666
|
+
async function ui() {
|
|
667
|
+
log('🌐 Starting AgentWindow Web UI...\n', colors.cyan);
|
|
668
|
+
|
|
669
|
+
// Check if frontend is built
|
|
670
|
+
const distPath = join(PROJECT_ROOT, 'web', 'dist');
|
|
671
|
+
if (!existsSync(distPath)) {
|
|
672
|
+
logError('Frontend not built. Run: npm run ui:build');
|
|
673
|
+
process.exit(1);
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
// Parse arguments
|
|
677
|
+
const args = process.argv.slice(3);
|
|
678
|
+
let port = 3721;
|
|
679
|
+
let openBrowser = true;
|
|
680
|
+
|
|
681
|
+
for (let i = 0; i < args.length; i++) {
|
|
682
|
+
if (args[i] === '--port' || args[i] === '-p') {
|
|
683
|
+
port = parseInt(args[++i]) || 3721;
|
|
684
|
+
} else if (args[i] === '--no-open') {
|
|
685
|
+
openBrowser = false;
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
// Start server
|
|
690
|
+
try {
|
|
691
|
+
const { startServer } = await import('../src/api/server.js');
|
|
692
|
+
await startServer({
|
|
693
|
+
port,
|
|
694
|
+
logger: true,
|
|
695
|
+
open: openBrowser
|
|
696
|
+
});
|
|
697
|
+
} catch (e) {
|
|
698
|
+
logError('Failed to start server: ' + e.message);
|
|
699
|
+
process.exit(1);
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
|
|
665
703
|
// Help
|
|
666
704
|
function showHelp() {
|
|
667
705
|
showBanner();
|
|
@@ -682,6 +720,9 @@ ${colors.cyan}Multi-Bot Commands:${colors.reset}
|
|
|
682
720
|
init Initialize multi-bot management directory
|
|
683
721
|
add-bot Add a new bot instance
|
|
684
722
|
|
|
723
|
+
${colors.cyan}Web UI:${colors.reset}
|
|
724
|
+
ui Launch web management interface
|
|
725
|
+
|
|
685
726
|
${colors.cyan}General:${colors.reset}
|
|
686
727
|
help Show this help
|
|
687
728
|
|
|
@@ -689,6 +730,7 @@ ${colors.cyan}Examples:${colors.reset}
|
|
|
689
730
|
agent-bridge setup ${colors.dim}# First time setup${colors.reset}
|
|
690
731
|
agent-bridge init ${colors.dim}# Initialize ~/bots directory${colors.reset}
|
|
691
732
|
agent-bridge add-bot myproject ${colors.dim}# Add a new bot${colors.reset}
|
|
733
|
+
agent-bridge ui ${colors.dim}# Launch web UI${colors.reset}
|
|
692
734
|
pm2 start ~/bots/ecosystem.config.cjs ${colors.dim}# Start all bots${colors.reset}
|
|
693
735
|
|
|
694
736
|
${colors.cyan}Documentation:${colors.reset}
|
|
@@ -730,6 +772,9 @@ switch (command) {
|
|
|
730
772
|
case 'add-bot':
|
|
731
773
|
addBot();
|
|
732
774
|
break;
|
|
775
|
+
case 'ui':
|
|
776
|
+
await ui();
|
|
777
|
+
break;
|
|
733
778
|
case 'help':
|
|
734
779
|
case '--help':
|
|
735
780
|
case '-h':
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
# AgentWindow Web UI 用户指南
|
|
2
|
+
|
|
3
|
+
## 简介
|
|
4
|
+
|
|
5
|
+
AgentWindow Web UI 是一个基于浏览器的管理界面,用于管理你的 AI Bot 实例。采用 Apple 风格设计,提供简洁优雅的用户体验。
|
|
6
|
+
|
|
7
|
+
## 快速开始
|
|
8
|
+
|
|
9
|
+
### 启动 Web UI
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
agent-window ui
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
服务器将在 `http://127.0.0.1:3721` 启动,浏览器会自动打开。
|
|
16
|
+
|
|
17
|
+
### 命令选项
|
|
18
|
+
|
|
19
|
+
| 选项 | 说明 |
|
|
20
|
+
|------|------|
|
|
21
|
+
| `--port, -p <port>` | 指定端口号(默认:3721) |
|
|
22
|
+
| `--no-open` | 不自动打开浏览器 |
|
|
23
|
+
| `--dev` | 开发模式 |
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## 功能说明
|
|
28
|
+
|
|
29
|
+
### 1. Dashboard(仪表板)
|
|
30
|
+
|
|
31
|
+
主页显示所有 Bot 实例的状态概览:
|
|
32
|
+
|
|
33
|
+
- **统计卡片**:显示总数、运行中、已停止、错误数量
|
|
34
|
+
- **实例卡片**:每个实例显示:
|
|
35
|
+
- 名称和显示名称
|
|
36
|
+
- 运行状态(运行中/已停止/错误)
|
|
37
|
+
- 内存使用量
|
|
38
|
+
- CPU 使用率
|
|
39
|
+
- 运行时间
|
|
40
|
+
- 快捷操作按钮(启动/停止/重启)
|
|
41
|
+
|
|
42
|
+
### 2. 实例管理
|
|
43
|
+
|
|
44
|
+
#### 添加实例
|
|
45
|
+
|
|
46
|
+
1. 点击右上角 **"Add Instance"** 按钮
|
|
47
|
+
2. 填写表单:
|
|
48
|
+
- **Name**: 实例标识符(小写字母、数字、连字符)
|
|
49
|
+
- **Display Name**: 显示名称
|
|
50
|
+
- **Project Path**: Bot 项目路径
|
|
51
|
+
- **Tags**: 标签(可选,逗号分隔)
|
|
52
|
+
|
|
53
|
+
3. 点击 **"Add Instance"** 完成
|
|
54
|
+
|
|
55
|
+
#### 删除实例
|
|
56
|
+
|
|
57
|
+
1. 进入 **Instances** 页面
|
|
58
|
+
2. 找到要删除的实例
|
|
59
|
+
3. 点击 **"Delete"** 按钮
|
|
60
|
+
4. 确认删除
|
|
61
|
+
|
|
62
|
+
#### 实例操作
|
|
63
|
+
|
|
64
|
+
每个实例卡片有三个操作按钮:
|
|
65
|
+
|
|
66
|
+
| 按钮 | 功能 | 说明 |
|
|
67
|
+
|------|------|------|
|
|
68
|
+
| ▶ | 启动 | 启动已停止的实例 |
|
|
69
|
+
| ⏸ | 停止 | 停止运行中的实例 |
|
|
70
|
+
| 🔄 | 重启 | 重启实例 |
|
|
71
|
+
|
|
72
|
+
### 3. 实例详情
|
|
73
|
+
|
|
74
|
+
点击实例卡片上的 **"Details"** 按钮进入详情页面,查看:
|
|
75
|
+
|
|
76
|
+
- **状态面板**:PID、内存、CPU、重启次数
|
|
77
|
+
- **信息面板**:路径、配置、添加时间、标签
|
|
78
|
+
- **实时日志**:最近的日志输出
|
|
79
|
+
|
|
80
|
+
### 4. 实时日志
|
|
81
|
+
|
|
82
|
+
日志查看器功能:
|
|
83
|
+
|
|
84
|
+
- **Live 开关**:启用/禁用实时日志流
|
|
85
|
+
- **类型过滤**:All / Stdout / Stderr
|
|
86
|
+
- **搜索**:搜索日志内容
|
|
87
|
+
- **导出**:下载日志为文本文件
|
|
88
|
+
- **清空**:清空当前日志显示
|
|
89
|
+
- **全屏**:全屏查看日志
|
|
90
|
+
|
|
91
|
+
### 5. 设置
|
|
92
|
+
|
|
93
|
+
设置页面显示:
|
|
94
|
+
|
|
95
|
+
- 系统信息(平台、Node 版本、版本号)
|
|
96
|
+
- 外观设置(深色模式切换)
|
|
97
|
+
- 关于信息
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
## 支持的 Bot 类型
|
|
102
|
+
|
|
103
|
+
### 类型 1: 独立 Bot
|
|
104
|
+
|
|
105
|
+
普通的 Discord/Slack Bot,具有基本结构:
|
|
106
|
+
|
|
107
|
+
```
|
|
108
|
+
my-bot/
|
|
109
|
+
├── config.json
|
|
110
|
+
├── package.json (含 discord.js)
|
|
111
|
+
└── src/
|
|
112
|
+
└── bot.js
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### 类型 2: BMAD 插件
|
|
116
|
+
|
|
117
|
+
集成 BMAD 框架的高级 Bot:
|
|
118
|
+
|
|
119
|
+
```
|
|
120
|
+
my-bmad-bot/
|
|
121
|
+
├── _bmad/ # BMAD 框架
|
|
122
|
+
│ ├── core/ # 核心模块
|
|
123
|
+
│ ├── bmm/ # BMAD 业务模块
|
|
124
|
+
│ └── _config/ # 配置文件
|
|
125
|
+
├── _agent-bridge/ # 插件目录
|
|
126
|
+
│ └── src/
|
|
127
|
+
│ └── bot.js # Bot 入口
|
|
128
|
+
└── package.json # 依赖 discord.js
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
## 实例添加示例
|
|
134
|
+
|
|
135
|
+
### 示例 1: 添加独立 Bot
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
# 假设你有一个简单 Bot 在 ~/bots/my-bot
|
|
139
|
+
agent-window instance add my-bot ~/bots/my-bot
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
或在 Web UI 中:
|
|
143
|
+
- Name: `my-bot`
|
|
144
|
+
- Display Name: `My Bot`
|
|
145
|
+
- Project Path: `/Users/yourname/bots/my-bot`
|
|
146
|
+
|
|
147
|
+
### 示例 2: 添加 BMAD Bot
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
# 添加 BMAD 企业 Bot
|
|
151
|
+
agent-window instance add corp-office ~/projects/corp-office --tags prod,bmad
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
或在 Web UI 中:
|
|
155
|
+
- Name: `corp-office`
|
|
156
|
+
- Display Name: `Corporate Office Bot`
|
|
157
|
+
- Project Path: `/Users/yourname/projects/corp-office`
|
|
158
|
+
- Tags: `prod, bmad`
|
|
159
|
+
|
|
160
|
+
---
|
|
161
|
+
|
|
162
|
+
## CLI 命令参考
|
|
163
|
+
|
|
164
|
+
### 实例管理
|
|
165
|
+
|
|
166
|
+
```bash
|
|
167
|
+
# 列出所有实例
|
|
168
|
+
agent-window instance list
|
|
169
|
+
|
|
170
|
+
# 添加实例
|
|
171
|
+
agent-window instance add <name> <project-path> [options]
|
|
172
|
+
|
|
173
|
+
# 删除实例
|
|
174
|
+
agent-window instance remove <name>
|
|
175
|
+
|
|
176
|
+
# 查看实例详情
|
|
177
|
+
agent-window instance info <name>
|
|
178
|
+
|
|
179
|
+
# 实例配置
|
|
180
|
+
agent-window instance config <name> get <key>
|
|
181
|
+
agent-window instance config <name> set <key> <value>
|
|
182
|
+
agent-window instance config <name> list
|
|
183
|
+
agent-window instance config <name> backup
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
### 实例操作
|
|
187
|
+
|
|
188
|
+
```bash
|
|
189
|
+
# 启动实例
|
|
190
|
+
agent-window instance start <name>
|
|
191
|
+
|
|
192
|
+
# 停止实例
|
|
193
|
+
agent-window instance stop <name>
|
|
194
|
+
|
|
195
|
+
# 重启实例
|
|
196
|
+
agent-window instance restart <name>
|
|
197
|
+
|
|
198
|
+
# 查看状态
|
|
199
|
+
agent-window instance status <name>
|
|
200
|
+
|
|
201
|
+
# 查看日志
|
|
202
|
+
agent-window instance logs <name>
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
---
|
|
206
|
+
|
|
207
|
+
## 常见问题
|
|
208
|
+
|
|
209
|
+
### Q: Web UI 无法启动?
|
|
210
|
+
|
|
211
|
+
A: 检查:
|
|
212
|
+
1. 端口 3721 是否被占用
|
|
213
|
+
2. 前端是否已构建 (`npm run ui:build`)
|
|
214
|
+
3. 依赖是否已安装
|
|
215
|
+
|
|
216
|
+
### Q: 添加实例失败?
|
|
217
|
+
|
|
218
|
+
A: 确保项目:
|
|
219
|
+
1. 路径存在且可访问
|
|
220
|
+
2. 包含 `package.json` 和 `src/bot.js`
|
|
221
|
+
3. BMAD 项目需要 `_bmad` 目录
|
|
222
|
+
|
|
223
|
+
### Q: 实例状态显示 Unknown?
|
|
224
|
+
|
|
225
|
+
A: 这表示实例未在 PM2 中运行,使用 `start` 按钮启动。
|
|
226
|
+
|
|
227
|
+
### Q: 日志不显示?
|
|
228
|
+
|
|
229
|
+
A: 检查:
|
|
230
|
+
1. 实例是否已启动
|
|
231
|
+
2. Live 开关是否已启用
|
|
232
|
+
3. 浏览器控制台是否有错误
|
|
233
|
+
|
|
234
|
+
---
|
|
235
|
+
|
|
236
|
+
## 键盘快捷键
|
|
237
|
+
|
|
238
|
+
| 快捷键 | 功能 |
|
|
239
|
+
|--------|------|
|
|
240
|
+
| `Cmd/Ctrl + K` | 聚焦搜索框 |
|
|
241
|
+
| `Esc` | 关闭模态框 |
|
|
242
|
+
| `Cmd/Ctrl + /` | 切换深色模式 |
|
|
243
|
+
|
|
244
|
+
---
|
|
245
|
+
|
|
246
|
+
## 技术支持
|
|
247
|
+
|
|
248
|
+
- 项目地址:https://github.com/Observer-GGboy/AgentWindow
|
|
249
|
+
- 问题反馈:GitHub Issues
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agent-window",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "A window to interact with AI agents through chat interfaces. Simplified interaction, powerful backend capabilities.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/bot.js",
|
|
@@ -11,6 +11,9 @@
|
|
|
11
11
|
"start": "node src/bot.js",
|
|
12
12
|
"dev": "node --watch src/bot.js",
|
|
13
13
|
"setup": "node bin/cli.js setup",
|
|
14
|
+
"ui": "node bin/cli.js ui",
|
|
15
|
+
"ui:dev": "cd web && npm run dev",
|
|
16
|
+
"ui:build": "cd web && npm run build",
|
|
14
17
|
"pm2:start": "pm2 start ecosystem.config.cjs",
|
|
15
18
|
"pm2:stop": "pm2 stop agent-window",
|
|
16
19
|
"pm2:restart": "pm2 restart agent-window",
|
|
@@ -36,10 +39,19 @@
|
|
|
36
39
|
"node": ">=18.0.0"
|
|
37
40
|
},
|
|
38
41
|
"dependencies": {
|
|
39
|
-
"
|
|
42
|
+
"@fastify/static": "^6.0.0",
|
|
43
|
+
"@fastify/websocket": "^10.0.0",
|
|
44
|
+
"cli-table3": "^0.6.5",
|
|
45
|
+
"discord.js": "^14.14.1",
|
|
46
|
+
"fastify": "^4.25.0",
|
|
47
|
+
"open": "^10.0.0",
|
|
48
|
+
"pino-pretty": "^10.0.0"
|
|
49
|
+
},
|
|
50
|
+
"overrides": {
|
|
51
|
+
"undici": "^7.19.0"
|
|
40
52
|
},
|
|
41
53
|
"repository": {
|
|
42
54
|
"type": "git",
|
|
43
|
-
"url": "https://github.com/
|
|
55
|
+
"url": "https://github.com/Observer-GGboy/AgentWindow"
|
|
44
56
|
}
|
|
45
57
|
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Platform Compatibility Test Script
|
|
4
|
+
*
|
|
5
|
+
* Tests the platform abstraction layer to ensure cross-platform compatibility.
|
|
6
|
+
* Run this script on different platforms to verify functionality.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import {
|
|
10
|
+
Platform,
|
|
11
|
+
currentPlatform,
|
|
12
|
+
isWindows,
|
|
13
|
+
isWSLAvailable,
|
|
14
|
+
getShell,
|
|
15
|
+
paths,
|
|
16
|
+
docker,
|
|
17
|
+
pm2
|
|
18
|
+
} from '../src/core/platform/index.js';
|
|
19
|
+
|
|
20
|
+
console.log('\n=== Platform Compatibility Test ===\n');
|
|
21
|
+
|
|
22
|
+
// Test 1: Platform Detection
|
|
23
|
+
console.log('1. Platform Detection');
|
|
24
|
+
console.log(` Current Platform: ${currentPlatform}`);
|
|
25
|
+
console.log(` Is Windows: ${isWindows()}`);
|
|
26
|
+
console.log(` Platform Enum: ${Platform.WINDOWS}, ${Platform.LINUX}, ${Platform.MACOS}\n`);
|
|
27
|
+
|
|
28
|
+
// Test 2: Shell Detection
|
|
29
|
+
console.log('2. Shell Detection');
|
|
30
|
+
const shell = getShell();
|
|
31
|
+
console.log(` Shell Command: ${shell.command}`);
|
|
32
|
+
console.log(` Shell Type: ${shell.type}\n`);
|
|
33
|
+
|
|
34
|
+
// Test 3: Path Utilities
|
|
35
|
+
console.log('3. Path Utilities');
|
|
36
|
+
console.log(` Home Dir: ${paths.getHomeDir()}`);
|
|
37
|
+
console.log(` AgentWindow Home: ${paths.getAgentWindowHome()}`);
|
|
38
|
+
console.log(` Bots Dir: ${paths.getBotsDir()}`);
|
|
39
|
+
console.log(` Claude Config: ${paths.getClaudeConfigDir()}`);
|
|
40
|
+
console.log(` Expanded ~: ${paths.expandTilde('~/test')}`);
|
|
41
|
+
console.log(` Config Dir: ${paths.getConfigDir()}`);
|
|
42
|
+
console.log(` Data Dir: ${paths.getDataDir()}\n`);
|
|
43
|
+
|
|
44
|
+
// Test 4: WSL Detection (Windows only)
|
|
45
|
+
if (isWindows()) {
|
|
46
|
+
console.log('4. WSL Detection (Windows)');
|
|
47
|
+
isWSLAvailable().then(available => {
|
|
48
|
+
console.log(` WSL Available: ${available}\n`);
|
|
49
|
+
}).catch(() => {
|
|
50
|
+
console.log(' WSL Detection failed\n');
|
|
51
|
+
});
|
|
52
|
+
} else {
|
|
53
|
+
console.log('4. WSL Detection: Skipped (not Windows)\n');
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Test 5: PM2 Availability
|
|
57
|
+
console.log('5. PM2 Availability');
|
|
58
|
+
pm2.isAvailable().then(available => {
|
|
59
|
+
console.log(` PM2 Available: ${available}`);
|
|
60
|
+
if (available) {
|
|
61
|
+
pm2.version().then(version => {
|
|
62
|
+
console.log(` PM2 Version: ${version}`);
|
|
63
|
+
runDockerTests();
|
|
64
|
+
}).catch(() => {
|
|
65
|
+
console.log(' PM2 Version: unknown');
|
|
66
|
+
runDockerTests();
|
|
67
|
+
});
|
|
68
|
+
} else {
|
|
69
|
+
console.log(' PM2 not installed - skipping PM2 tests');
|
|
70
|
+
runDockerTests();
|
|
71
|
+
}
|
|
72
|
+
}).catch(() => {
|
|
73
|
+
console.log(' PM2 detection failed');
|
|
74
|
+
runDockerTests();
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
// Test 6: Docker Availability
|
|
78
|
+
function runDockerTests() {
|
|
79
|
+
console.log('\n6. Docker Availability');
|
|
80
|
+
docker.isAvailable().then(available => {
|
|
81
|
+
console.log(` Docker Available: ${available}`);
|
|
82
|
+
if (available) {
|
|
83
|
+
docker.version().then(version => {
|
|
84
|
+
console.log(` Docker Version: ${version.Server?.Version || 'unknown'}`);
|
|
85
|
+
finishTests();
|
|
86
|
+
}).catch(() => {
|
|
87
|
+
console.log(' Docker Version: unknown');
|
|
88
|
+
finishTests();
|
|
89
|
+
});
|
|
90
|
+
} else {
|
|
91
|
+
console.log(' Docker not installed - skipping Docker tests');
|
|
92
|
+
finishTests();
|
|
93
|
+
}
|
|
94
|
+
}).catch(() => {
|
|
95
|
+
console.log(' Docker detection failed');
|
|
96
|
+
finishTests();
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function finishTests() {
|
|
101
|
+
console.log('\n=== Test Complete ===\n');
|
|
102
|
+
console.log('Platform abstraction layer is working correctly.');
|
|
103
|
+
console.log('Next steps:');
|
|
104
|
+
console.log(' - Test actual PM2 process management');
|
|
105
|
+
console.log(' - Test Docker container operations');
|
|
106
|
+
console.log(' - Test on Windows with WSL2');
|
|
107
|
+
console.log(' - Test on Windows with Docker Desktop');
|
|
108
|
+
console.log('');
|
|
109
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* API Routes Registry
|
|
3
|
+
*
|
|
4
|
+
* Registers all REST API routes.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { registerInstanceRoutes } from './instances.js';
|
|
8
|
+
import { registerOperationRoutes } from './operations.js';
|
|
9
|
+
import { registerSystemRoutes } from './system.js';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Register all API routes
|
|
13
|
+
*/
|
|
14
|
+
export async function registerRoutes(fastify) {
|
|
15
|
+
// Instance management routes
|
|
16
|
+
await registerInstanceRoutes(fastify);
|
|
17
|
+
|
|
18
|
+
// Operation routes (start/stop/restart)
|
|
19
|
+
await registerOperationRoutes(fastify);
|
|
20
|
+
|
|
21
|
+
// System routes (health, info)
|
|
22
|
+
await registerSystemRoutes(fastify);
|
|
23
|
+
|
|
24
|
+
fastify.log.info('All API routes registered');
|
|
25
|
+
}
|