cicy-desktop 2.1.237 → 2.1.238
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/package.json +4 -11
- package/src/tabbrowser/tab-shell.html +5 -1
- package/.kiro/steering/dev-workflow.md +0 -166
- package/AGENTS.md +0 -275
- package/CLAUDE_HANDOFF.md +0 -168
- package/DESIGN.md +0 -66
- package/DOCKER.md +0 -85
- package/Dockerfile +0 -46
- package/TODO-anti-detection.md +0 -326
- package/copy-to-desktop.sh +0 -26
- package/docs/AUTOMATION-API.md +0 -342
- package/docs/REQUEST_MONITORING.md +0 -435
- package/docs/REST-API-FEATURE.md +0 -155
- package/docs/REST-API.md +0 -276
- package/docs/backend-selector-design.md +0 -204
- package/docs/chrome-proxy.md +0 -142
- package/docs/cicy-desktop-current-execution-bridge.md +0 -509
- package/docs/feature-distributed-multi-agent.md +0 -555
- package/docs/worklog-2026-03-27.md +0 -108
- package/docs/yaml.md +0 -255
- package/generate-openapi.js +0 -162
- package/jest.config.js +0 -13
- package/jest.setup.global.js +0 -16
- package/jest.teardown.global.js +0 -10
- package/service.sh +0 -164
- package/update-desktop.sh +0 -33
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cicy-desktop",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.238",
|
|
4
4
|
"description": "CiCy - AI-powered operating system browser",
|
|
5
5
|
"main": "src/main.js",
|
|
6
6
|
"bin": {
|
|
@@ -9,10 +9,8 @@
|
|
|
9
9
|
"scripts": {
|
|
10
10
|
"start": "node ./bin/cicy-desktop",
|
|
11
11
|
"start:master": "node src/master/master-main.js",
|
|
12
|
-
"format": "prettier --write \"src/**/*.js\"
|
|
13
|
-
"format:check": "prettier --check \"src/**/*.js\"
|
|
14
|
-
"test": "jest",
|
|
15
|
-
"test:ls": "node tests/test-ls.js",
|
|
12
|
+
"format": "prettier --write \"src/**/*.js\"",
|
|
13
|
+
"format:check": "prettier --check \"src/**/*.js\"",
|
|
16
14
|
"build": "electron-builder --publish never",
|
|
17
15
|
"build:homepage": "node scripts/build-homepage.cjs",
|
|
18
16
|
"prebuild:win": "node scripts/build-homepage.cjs",
|
|
@@ -154,13 +152,8 @@
|
|
|
154
152
|
"cicy-mihomo-windows-arm64": "1.10.4"
|
|
155
153
|
},
|
|
156
154
|
"devDependencies": {
|
|
157
|
-
"@babel/core": "^7.29.0",
|
|
158
|
-
"@babel/preset-env": "^7.29.0",
|
|
159
|
-
"axios": "^1.13.5",
|
|
160
155
|
"electron": "41.0.3",
|
|
161
156
|
"electron-builder": "^26.7.0",
|
|
162
|
-
"
|
|
163
|
-
"prettier": "^3.8.1",
|
|
164
|
-
"supertest": "^6.3.3"
|
|
157
|
+
"prettier": "^3.8.1"
|
|
165
158
|
}
|
|
166
159
|
}
|
|
@@ -244,7 +244,10 @@
|
|
|
244
244
|
const d = document.createElement('div');
|
|
245
245
|
d.className = 'tab' + (t.home ? ' home' : '') + (t.active ? ' active' : '');
|
|
246
246
|
d.title = t.home ? T('tabShell.myTeam', '我的团队') : (t.url || '');
|
|
247
|
-
|
|
247
|
+
// 按下即切(pointerdown),不用 click:render() 在切换/加载/标题更新时会 innerHTML=''
|
|
248
|
+
// 整条重建,若发生在用户 mousedown 与 mouseup 之间,click 就丢了(要点好几下才切)。
|
|
249
|
+
// pointerdown 在按下瞬间就激活,之后的重建不影响这次激活。
|
|
250
|
+
d.onpointerdown = () => window.tabAPI.activate(t.id);
|
|
248
251
|
// resident start-page tab: pinned first, user icon only, no title, no close
|
|
249
252
|
if (t.home) {
|
|
250
253
|
const ic = document.createElement('span');
|
|
@@ -266,6 +269,7 @@
|
|
|
266
269
|
const cls = document.createElement('span');
|
|
267
270
|
cls.className = 'cls';
|
|
268
271
|
cls.innerHTML = '<svg width="11" height="11" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round"><line x1="5" y1="5" x2="19" y2="19"/><line x1="19" y1="5" x2="5" y2="19"/></svg>';
|
|
272
|
+
cls.onpointerdown = (e) => e.stopPropagation(); // 别让「关闭」的按下冒泡成 tab 激活
|
|
269
273
|
cls.onclick = (e) => { e.stopPropagation(); window.tabAPI.close(t.id); };
|
|
270
274
|
d.appendChild(cls);
|
|
271
275
|
}
|
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
inclusion: always
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
# Git 开发工作流程 - Git Development Workflow
|
|
6
|
-
|
|
7
|
-
## ⚠️ 开发前必读
|
|
8
|
-
|
|
9
|
-
**在开始任何开发任务前,必须完整阅读本文档并严格遵循所有规范。**
|
|
10
|
-
|
|
11
|
-
违反规范将导致:
|
|
12
|
-
- ❌ 代码被拒绝合并
|
|
13
|
-
- ❌ 浪费时间重做
|
|
14
|
-
- ❌ 影响项目质量
|
|
15
|
-
|
|
16
|
-
## 🚨 核心原则(必须遵守)
|
|
17
|
-
|
|
18
|
-
1. **开发前必读本文档** - 不要凭记忆或猜测
|
|
19
|
-
2. **严格遵循每个阶段** - 不要跳过任何步骤
|
|
20
|
-
3. **遇到问题先分析** - 不要盲目重试
|
|
21
|
-
4. **测试驱动开发** - 一功能一测试
|
|
22
|
-
5. **全部测试通过才提交** - npm test 必须 100% 通过
|
|
23
|
-
|
|
24
|
-
## 新功能/Bug修复标准流程
|
|
25
|
-
|
|
26
|
-
当收到开发新功能或修复bug的请求时,严格遵循以下流程:
|
|
27
|
-
|
|
28
|
-
### 阶段1:需求分析
|
|
29
|
-
1. **用户提出需求**
|
|
30
|
-
2. **AI 制定可行方案**
|
|
31
|
-
- 分析技术实现路径
|
|
32
|
-
- 评估工作量和风险
|
|
33
|
-
- 提出具体实现方案
|
|
34
|
-
3. **询问用户是否有补充**
|
|
35
|
-
4. **等待用户确认"开始"**
|
|
36
|
-
|
|
37
|
-
### 阶段2:环境准备(用户说"开始"后执行)
|
|
38
|
-
```bash
|
|
39
|
-
# 分支命名规范:
|
|
40
|
-
# - 新功能:feat-MMDD-功能简述
|
|
41
|
-
# - Bug修复:fix-MMDD-问题简述
|
|
42
|
-
|
|
43
|
-
# 1. 直接在工作目录克隆并创建分支
|
|
44
|
-
mkdir -p ~/projects/cicy-desktop/branches/
|
|
45
|
-
git clone -b origin/main git@github.com:cicy-ai/cicy-desktop.git ~/projects/cicy-desktop/branches/<branch-name>
|
|
46
|
-
sudo ln -s /<branch-name> ~/projects/cicy-desktop/branches/<branch-name>
|
|
47
|
-
cd /<branch-name>
|
|
48
|
-
git fetch origin
|
|
49
|
-
git checkout -b <branch-name> origin/main
|
|
50
|
-
|
|
51
|
-
# 2. 安装依赖
|
|
52
|
-
npm install
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
### 阶段3:需求文档化
|
|
56
|
-
在工作目录创建 `task/task-<branch-name>.md` 文档,包含:
|
|
57
|
-
|
|
58
|
-
```markdown
|
|
59
|
-
# 任务:[功能/Bug简述]
|
|
60
|
-
|
|
61
|
-
## 需求描述
|
|
62
|
-
[用户原始需求]
|
|
63
|
-
|
|
64
|
-
## 实现方案
|
|
65
|
-
[技术方案详细说明]
|
|
66
|
-
|
|
67
|
-
## TODO 清单
|
|
68
|
-
- [ ] 任务1
|
|
69
|
-
- [ ] 任务2
|
|
70
|
-
- [ ] 任务3
|
|
71
|
-
|
|
72
|
-
## 验收标准
|
|
73
|
-
- [ ] 功能正常工作
|
|
74
|
-
- [ ] 所有测试通过
|
|
75
|
-
- [ ] 代码符合规范
|
|
76
|
-
- [ ] 文档已更新
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
### 阶段4:开发实现
|
|
80
|
-
```bash
|
|
81
|
-
# 在工作目录进行开发
|
|
82
|
-
cd /<branch-name>
|
|
83
|
-
|
|
84
|
-
# ⚠️ 必须遵循:一功能一测试
|
|
85
|
-
# ❌ 禁止:写完所有代码再测试
|
|
86
|
-
# ✅ 正确:每完成一个功能立即测试
|
|
87
|
-
|
|
88
|
-
# 实时更新 TASK.md 中的完成状态
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
**核心原则:增量开发,持续验证**
|
|
92
|
-
|
|
93
|
-
### 阶段5:本地测试(❗强制要求)
|
|
94
|
-
```bash
|
|
95
|
-
# ⚠️ 必须运行完整测试套件
|
|
96
|
-
npm test
|
|
97
|
-
|
|
98
|
-
# ❌ 如果测试失败,绝对不能提交
|
|
99
|
-
# ✅ 必须所有测试通过才能进入下一阶段
|
|
100
|
-
# ✅ 验证所有验收标准
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
**⚠️ 警告:如果跳过此步骤直接提交,视为严重违规!**
|
|
104
|
-
|
|
105
|
-
**遇到测试失败时:**
|
|
106
|
-
1. ❌ 不要盲目重试
|
|
107
|
-
2. ✅ 仔细阅读错误信息
|
|
108
|
-
3. ✅ 分析失败原因(依赖缺失?代码错误?环境问题?)
|
|
109
|
-
4. ✅ 总结问题根源
|
|
110
|
-
5. ✅ 制定修复方案
|
|
111
|
-
6. ✅ 修复后再次测试
|
|
112
|
-
|
|
113
|
-
### 阶段6:提交和推送
|
|
114
|
-
```bash
|
|
115
|
-
# 提交更改
|
|
116
|
-
git add .
|
|
117
|
-
git commit -m "feat/fix: 简要描述更改内容"
|
|
118
|
-
|
|
119
|
-
# 推送到远程
|
|
120
|
-
git push origin <branch-name>
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
### 阶段7:创建 Pull Request
|
|
124
|
-
```bash
|
|
125
|
-
# 使用 GitHub CLI 创建 PR
|
|
126
|
-
gh pr create --base main --head <branch-name> --title "标题" --body "详细描述"
|
|
127
|
-
|
|
128
|
-
# 或手动在 GitHub 网页创建 PR
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
## 分支命名示例
|
|
132
|
-
|
|
133
|
-
### 新功能
|
|
134
|
-
- `feat-0206-add-cdp-scroll`
|
|
135
|
-
- `feat-0206-multi-account-support`
|
|
136
|
-
- `feat-0206-network-monitor`
|
|
137
|
-
|
|
138
|
-
### Bug修复
|
|
139
|
-
- `fix-0206-window-close-crash`
|
|
140
|
-
- `fix-0206-screenshot-memory-leak`
|
|
141
|
-
- `fix-0206-test-timeout`
|
|
142
|
-
|
|
143
|
-
## 工作目录结构
|
|
144
|
-
```
|
|
145
|
-
~/
|
|
146
|
-
├── projects/
|
|
147
|
-
│ └── cicy-desktop/main # 主仓库
|
|
148
|
-
└── projects/cicy-desktop/branches/
|
|
149
|
-
├── feat-0206-feature1/
|
|
150
|
-
├── fix-0206-bug1/
|
|
151
|
-
└── feat-0206-feature2/
|
|
152
|
-
```
|
|
153
|
-
|
|
154
|
-
## 核心原则
|
|
155
|
-
- ✅ 始终基于 `origin/main` 创建新分支
|
|
156
|
-
- ✅ 使用独立工作目录避免污染主仓库
|
|
157
|
-
- ✅ **本地测试必须全部通过才能提交(npm test)**
|
|
158
|
-
- ✅ **一功能一测试,不要全写完再测试**
|
|
159
|
-
- ✅ 分支名称包含日期和清晰的功能/问题描述
|
|
160
|
-
- ✅ 提交信息遵循 conventional commits 规范
|
|
161
|
-
- ❌ **禁止跳过测试直接提交代码**
|
|
162
|
-
- ❌ **禁止一次性写完所有代码**
|
|
163
|
-
|
|
164
|
-
---
|
|
165
|
-
**制定时间:2026-02-06**
|
|
166
|
-
**适用项目:cicy-desktop**
|
package/AGENTS.md
DELETED
|
@@ -1,275 +0,0 @@
|
|
|
1
|
-
# AGENTS.md
|
|
2
|
-
|
|
3
|
-
This file provides guidelines for AI agents working on this codebase.
|
|
4
|
-
|
|
5
|
-
## Build, Lint, and Test Commands
|
|
6
|
-
|
|
7
|
-
### Core Commands
|
|
8
|
-
|
|
9
|
-
```bash
|
|
10
|
-
# Start the MCP server (runs Electron app with MCP endpoint)
|
|
11
|
-
npm start
|
|
12
|
-
|
|
13
|
-
# Start with specific port
|
|
14
|
-
npm start -- --port=8102
|
|
15
|
-
|
|
16
|
-
# Start with URL and single window mode
|
|
17
|
-
npm start -- --url=http://example.com --one-window
|
|
18
|
-
|
|
19
|
-
# Run all tests (Jest with forceExit to handle Electron processes)
|
|
20
|
-
npm test
|
|
21
|
-
|
|
22
|
-
# Run a single test file
|
|
23
|
-
npm test -- api.ping.test.js
|
|
24
|
-
|
|
25
|
-
# Run tests matching a pattern
|
|
26
|
-
npm test -- --testNamePattern="ping"
|
|
27
|
-
|
|
28
|
-
# Format code with Prettier
|
|
29
|
-
npm run format
|
|
30
|
-
|
|
31
|
-
# Check formatting
|
|
32
|
-
npm run format:check
|
|
33
|
-
|
|
34
|
-
# Build distributables
|
|
35
|
-
npm run build
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
### Test Configuration
|
|
39
|
-
|
|
40
|
-
- Tests are in `tests/` directory with pattern `*.test.js`
|
|
41
|
-
- Jest runs with `--runInBand` (serial execution) due to Electron's single-process nature
|
|
42
|
-
- Tests use supertest for HTTP API testing
|
|
43
|
-
- Tests spawn actual Electron processes on dynamic ports
|
|
44
|
-
- Auth token loaded from `~/global.json`
|
|
45
|
-
- Test utilities in `tests/test-utils.js`
|
|
46
|
-
|
|
47
|
-
## Code Style Guidelines
|
|
48
|
-
|
|
49
|
-
### Language
|
|
50
|
-
|
|
51
|
-
- **CommonJS** only - use `require()` not ES modules
|
|
52
|
-
- Plain JavaScript - no TypeScript
|
|
53
|
-
- ES6+ features: async/await, arrow functions, template literals
|
|
54
|
-
|
|
55
|
-
### File Organization
|
|
56
|
-
|
|
57
|
-
```
|
|
58
|
-
src/
|
|
59
|
-
main.js # Main entry: Electron + Express + MCP server
|
|
60
|
-
config.js # Configuration constants
|
|
61
|
-
tools/ # MCP tool implementations
|
|
62
|
-
ping.js
|
|
63
|
-
window-tools.js
|
|
64
|
-
cdp-tools.js
|
|
65
|
-
exec-js.js
|
|
66
|
-
utils/ # Utility modules
|
|
67
|
-
window-utils.js
|
|
68
|
-
window-monitor.js
|
|
69
|
-
cdp-utils.js
|
|
70
|
-
snapshot-utils.js
|
|
71
|
-
auth.js
|
|
72
|
-
tests/ # Test files
|
|
73
|
-
test-utils.js # Shared test utilities
|
|
74
|
-
*.test.js # Individual test files
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
### Imports Order
|
|
78
|
-
|
|
79
|
-
```javascript
|
|
80
|
-
// 1. Built-in Node modules
|
|
81
|
-
const fs = require("fs");
|
|
82
|
-
const path = require("path");
|
|
83
|
-
|
|
84
|
-
// 2. External dependencies
|
|
85
|
-
const { BrowserWindow } = require("electron");
|
|
86
|
-
const { z } = require("zod");
|
|
87
|
-
const express = require("express");
|
|
88
|
-
|
|
89
|
-
// 3. Internal modules
|
|
90
|
-
const { config } = require("../config");
|
|
91
|
-
const { createWindow } = require("../utils/window-utils");
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
### Naming Conventions
|
|
95
|
-
|
|
96
|
-
- **Classes**: PascalCase (`AuthManager`, `BrowserWindow`)
|
|
97
|
-
- **Functions/variables**: camelCase (`getWindows`, `registerTool`)
|
|
98
|
-
- **Constants**: SCREAMING_SNAKE_CASE (`PORT`, `LOGS_DIR`)
|
|
99
|
-
- **Tool names**: snake_case (`open_window`, `get_windows`)
|
|
100
|
-
- **File names**: kebab-case for tests (`api.ping.test.js`)
|
|
101
|
-
|
|
102
|
-
### Error Handling
|
|
103
|
-
|
|
104
|
-
All tool handlers must return structured MCP responses:
|
|
105
|
-
|
|
106
|
-
```javascript
|
|
107
|
-
try {
|
|
108
|
-
// ... operation
|
|
109
|
-
return {
|
|
110
|
-
content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
|
|
111
|
-
};
|
|
112
|
-
} catch (error) {
|
|
113
|
-
return {
|
|
114
|
-
content: [{ type: "text", text: `Error: ${error.message}` }],
|
|
115
|
-
isError: true,
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
### Tool Registration Pattern
|
|
121
|
-
|
|
122
|
-
```javascript
|
|
123
|
-
const { z } = require("zod");
|
|
124
|
-
|
|
125
|
-
function registerTools(registerTool) {
|
|
126
|
-
registerTool(
|
|
127
|
-
"tool_name",
|
|
128
|
-
"Description of what the tool does",
|
|
129
|
-
z.object({
|
|
130
|
-
win_id: z.number().optional().default(1).describe("Window ID"),
|
|
131
|
-
param: z.string().describe("Required parameter"),
|
|
132
|
-
}),
|
|
133
|
-
async ({ win_id, param }) => {
|
|
134
|
-
try {
|
|
135
|
-
// Implementation
|
|
136
|
-
return { content: [{ type: "text", text: "result" }] };
|
|
137
|
-
} catch (error) {
|
|
138
|
-
return { content: [{ type: "text", text: `Error: ${error.message}` }], isError: true };
|
|
139
|
-
}
|
|
140
|
-
},
|
|
141
|
-
{ tag: "Category" } // OpenAPI grouping tag
|
|
142
|
-
);
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
module.exports = registerTools;
|
|
146
|
-
```
|
|
147
|
-
|
|
148
|
-
### Response Formats
|
|
149
|
-
|
|
150
|
-
```javascript
|
|
151
|
-
// Text response
|
|
152
|
-
return { content: [{ type: "text", text: "message" }] };
|
|
153
|
-
|
|
154
|
-
// JSON response
|
|
155
|
-
return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] };
|
|
156
|
-
|
|
157
|
-
// Image response (NativeImage from Electron)
|
|
158
|
-
return {
|
|
159
|
-
content: [
|
|
160
|
-
{ type: "text", text: `Image: ${width}x${height}` },
|
|
161
|
-
{ type: "image", data: base64String, mimeType: "image/png" },
|
|
162
|
-
],
|
|
163
|
-
};
|
|
164
|
-
|
|
165
|
-
// Error response
|
|
166
|
-
return { content: [{ type: "text", text: "error message" }], isError: true };
|
|
167
|
-
```
|
|
168
|
-
|
|
169
|
-
### Common Patterns
|
|
170
|
-
|
|
171
|
-
#### Window Lookup
|
|
172
|
-
|
|
173
|
-
```javascript
|
|
174
|
-
const win = BrowserWindow.fromId(win_id);
|
|
175
|
-
if (!win) throw new Error(`Window ${win_id} not found`);
|
|
176
|
-
```
|
|
177
|
-
|
|
178
|
-
#### JSON Serialization with BigInt
|
|
179
|
-
|
|
180
|
-
```javascript
|
|
181
|
-
JSON.stringify(result, (key, value) => (typeof value === "bigint" ? value.toString() : value), 2);
|
|
182
|
-
```
|
|
183
|
-
|
|
184
|
-
#### NativeImage Handling
|
|
185
|
-
|
|
186
|
-
```javascript
|
|
187
|
-
if (result?.constructor.name === "NativeImage") {
|
|
188
|
-
const size = result.getSize();
|
|
189
|
-
const base64 = result.toPNG().toString("base64");
|
|
190
|
-
return {
|
|
191
|
-
content: [
|
|
192
|
-
{ type: "text", text: `Image: ${size.width}x${size.height}` },
|
|
193
|
-
{ type: "image", data: base64, mimeType: "image/png" },
|
|
194
|
-
],
|
|
195
|
-
};
|
|
196
|
-
}
|
|
197
|
-
```
|
|
198
|
-
|
|
199
|
-
### Testing Patterns
|
|
200
|
-
|
|
201
|
-
```javascript
|
|
202
|
-
const { setPort, setupTest, teardownTest, sendRequest } = require("./test-utils");
|
|
203
|
-
|
|
204
|
-
describe("Feature Test Suite", () => {
|
|
205
|
-
beforeAll(async () => {
|
|
206
|
-
setPort(8102); // Set test port
|
|
207
|
-
await setupTest(); // Start Electron + establish SSE
|
|
208
|
-
}, 30000);
|
|
209
|
-
|
|
210
|
-
afterAll(async () => {
|
|
211
|
-
await teardownTest(); // Cleanup
|
|
212
|
-
});
|
|
213
|
-
|
|
214
|
-
test("should do something", async () => {
|
|
215
|
-
const response = await sendRequest("tools/call", {
|
|
216
|
-
name: "tool_name",
|
|
217
|
-
arguments: { param: "value" },
|
|
218
|
-
});
|
|
219
|
-
expect(response.result).toBeDefined();
|
|
220
|
-
});
|
|
221
|
-
});
|
|
222
|
-
```
|
|
223
|
-
|
|
224
|
-
### Logging
|
|
225
|
-
|
|
226
|
-
Use electron-log with consistent format:
|
|
227
|
-
|
|
228
|
-
```javascript
|
|
229
|
-
const log = require("electron-log");
|
|
230
|
-
log.info("[MCP] Server starting");
|
|
231
|
-
log.error("[MCP] Error:", error);
|
|
232
|
-
```
|
|
233
|
-
|
|
234
|
-
### Security
|
|
235
|
-
|
|
236
|
-
- Never log secrets or API keys
|
|
237
|
-
- Validate all inputs with Zod schemas
|
|
238
|
-
- Return structured errors without internal details
|
|
239
|
-
- Auth token loaded from `~/global.json`
|
|
240
|
-
|
|
241
|
-
### Electron Best Practices
|
|
242
|
-
|
|
243
|
-
- Use `electronApp.whenReady()` for initialization
|
|
244
|
-
- Handle `window-all-closed` event properly
|
|
245
|
-
- Enable remote debugging with `--remote-debugging-port`
|
|
246
|
-
- Use `nodeIntegration: false` and `contextIsolation: true`
|
|
247
|
-
- Multi-account support via `partition: persist:sandbox-{accountIdx}`
|
|
248
|
-
|
|
249
|
-
## Master/Worker Cluster Commands
|
|
250
|
-
|
|
251
|
-
```bash
|
|
252
|
-
# Start Master server (port 8100)
|
|
253
|
-
npm run start:master
|
|
254
|
-
|
|
255
|
-
# Start Worker registered to Master
|
|
256
|
-
MASTER_TOKEN=$(jq -r '.api_token' ~/global.json)
|
|
257
|
-
PORT=8101 CICY_MASTER_URL="http://127.0.0.1:8100" CICY_MASTER_TOKEN="$MASTER_TOKEN" npm start
|
|
258
|
-
|
|
259
|
-
# Master API endpoints
|
|
260
|
-
curl http://127.0.0.1:8100/api/ping
|
|
261
|
-
curl http://127.0.0.1:8100/api/workers
|
|
262
|
-
curl http://127.0.0.1:8100/api/agents
|
|
263
|
-
|
|
264
|
-
# Worker direct API (requires auth token from ~/global.json)
|
|
265
|
-
curl -H "Authorization: Bearer $TOKEN" http://127.0.0.1:8101/rpc/tools
|
|
266
|
-
curl -H "Authorization: Bearer $TOKEN" -X POST http://127.0.0.1:8101/rpc/tools/call \
|
|
267
|
-
-H "Content-Type: application/json" \
|
|
268
|
-
-d '{"name":"ping","arguments":{}}'
|
|
269
|
-
```
|
|
270
|
-
|
|
271
|
-
### Master Token
|
|
272
|
-
|
|
273
|
-
- Token stored in `~/global.json` as `api_token`
|
|
274
|
-
- Token file created automatically on first startup if missing
|
|
275
|
-
- Token passed to workers via `CICY_MASTER_TOKEN` env var
|
package/CLAUDE_HANDOFF.md
DELETED
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
# Claude Code Handoff
|
|
2
|
-
|
|
3
|
-
Please read this file first, then read `AGENTS.md`, and then inspect the codebase.
|
|
4
|
-
|
|
5
|
-
## Project Summary
|
|
6
|
-
|
|
7
|
-
`cicy-desktop` is an Electron-based desktop automation host. It is not just a normal desktop app; it acts as a:
|
|
8
|
-
|
|
9
|
-
- Electron runtime
|
|
10
|
-
- browser/desktop automation host
|
|
11
|
-
- MCP + HTTP RPC + admin UI control plane
|
|
12
|
-
- evolving master/worker distributed desktop platform
|
|
13
|
-
|
|
14
|
-
## Read These Files First
|
|
15
|
-
|
|
16
|
-
Start with these files in this order:
|
|
17
|
-
|
|
18
|
-
1. `AGENTS.md`
|
|
19
|
-
2. `src/main.js`
|
|
20
|
-
3. `src/master/master-main.js`
|
|
21
|
-
4. `src/master/master-routes.js`
|
|
22
|
-
5. `src/cluster/worker-client.js`
|
|
23
|
-
6. `src/cluster/worker-identity.js`
|
|
24
|
-
7. `src/server/tool-registry.js`
|
|
25
|
-
8. `src/utils/window-utils.js`
|
|
26
|
-
9. `src/utils/window-monitor.js`
|
|
27
|
-
10. `src/tools/window-tools.js`
|
|
28
|
-
11. `docs/feature-distributed-multi-agent.md`
|
|
29
|
-
|
|
30
|
-
## Architecture Overview
|
|
31
|
-
|
|
32
|
-
### Worker Runtime
|
|
33
|
-
- Main worker entry: `src/main.js`
|
|
34
|
-
- Exposes:
|
|
35
|
-
- MCP SSE endpoints
|
|
36
|
-
- HTTP RPC endpoints
|
|
37
|
-
- admin/UI routes
|
|
38
|
-
- Electron IPC bridge
|
|
39
|
-
- Registers tools from `src/tools/*`
|
|
40
|
-
- Manages BrowserWindow lifecycle
|
|
41
|
-
- Supports automation, screenshots, CDP, DOM actions, downloads, requests, logs, and system window operations
|
|
42
|
-
|
|
43
|
-
### Master Runtime
|
|
44
|
-
- Main master entry: `src/master/master-main.js`
|
|
45
|
-
- API routes in `src/master/master-routes.js`
|
|
46
|
-
- Tracks workers, agents, tasks, and session affinity
|
|
47
|
-
- Exposes worker/task/agent APIs and RPC forwarding
|
|
48
|
-
|
|
49
|
-
### Tool Registry
|
|
50
|
-
- Central registration point: `src/server/tool-registry.js`
|
|
51
|
-
- Tool modules live in `src/tools/*`
|
|
52
|
-
- Tool handlers are reused across protocols
|
|
53
|
-
|
|
54
|
-
### Window/Agent Foundation
|
|
55
|
-
- Window lifecycle core: `src/utils/window-utils.js`
|
|
56
|
-
- Monitoring/telemetry core: `src/utils/window-monitor.js`
|
|
57
|
-
- A BrowserWindow is effectively the current agent runtime unit
|
|
58
|
-
- Multi-account/session isolation uses Electron partitioning
|
|
59
|
-
|
|
60
|
-
## Current Distributed State
|
|
61
|
-
|
|
62
|
-
The repository already contains early master/worker support.
|
|
63
|
-
|
|
64
|
-
### Already Implemented
|
|
65
|
-
- Worker identity generation
|
|
66
|
-
- Worker client registration flow
|
|
67
|
-
- Worker heartbeat flow
|
|
68
|
-
- Master worker registry
|
|
69
|
-
- Agent index
|
|
70
|
-
- Task store
|
|
71
|
-
- Session affinity store
|
|
72
|
-
- Master RPC forwarding to workers
|
|
73
|
-
- Master admin HTML/UI routes
|
|
74
|
-
|
|
75
|
-
### Main Endpoints
|
|
76
|
-
|
|
77
|
-
#### Master
|
|
78
|
-
- `GET /api/ping`
|
|
79
|
-
- `POST /api/workers/register`
|
|
80
|
-
- `POST /api/workers/heartbeat`
|
|
81
|
-
- `GET /api/workers`
|
|
82
|
-
- `GET /api/agents`
|
|
83
|
-
- `GET /api/tasks`
|
|
84
|
-
- `POST /api/rpc/:toolName`
|
|
85
|
-
- `GET /master`
|
|
86
|
-
|
|
87
|
-
#### Worker
|
|
88
|
-
- `GET /rpc/tools`
|
|
89
|
-
- `POST /rpc/tools/call`
|
|
90
|
-
- `POST /rpc/:toolName`
|
|
91
|
-
- `GET /ui`
|
|
92
|
-
- `GET /docs`
|
|
93
|
-
|
|
94
|
-
## Known Operational Facts
|
|
95
|
-
|
|
96
|
-
### Master Start
|
|
97
|
-
```bash
|
|
98
|
-
cd /Users/ton/projects/cicy-desktop
|
|
99
|
-
npm run start:master
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
### Worker Start
|
|
103
|
-
```bash
|
|
104
|
-
MASTER_TOKEN=$(jq -r '.api_token' ~/global.json)
|
|
105
|
-
PORT=8101 CICY_MASTER_URL="http://127.0.0.1:8100" CICY_MASTER_TOKEN="$MASTER_TOKEN" npm start
|
|
106
|
-
```
|
|
107
|
-
|
|
108
|
-
### Important Runtime Requirements
|
|
109
|
-
Worker registration to master fails if any of the following are wrong:
|
|
110
|
-
|
|
111
|
-
1. `CICY_MASTER_URL` is missing
|
|
112
|
-
2. `CICY_MASTER_TOKEN` is missing
|
|
113
|
-
3. worker port (for example `8101`) is already occupied
|
|
114
|
-
4. wrong Node runtime is used
|
|
115
|
-
|
|
116
|
-
### Node Version Note
|
|
117
|
-
This project runs better with Node 22 in this environment. Node 19 caused startup/runtime issues.
|
|
118
|
-
|
|
119
|
-
## Recently Confirmed Issue
|
|
120
|
-
|
|
121
|
-
A worker previously failed to appear in master because:
|
|
122
|
-
- port `8101` was already in use by another Electron process
|
|
123
|
-
- worker startup environment was not consistently correct
|
|
124
|
-
|
|
125
|
-
After killing the conflicting process and starting the worker with:
|
|
126
|
-
- Node 22
|
|
127
|
-
- `CICY_MASTER_URL`
|
|
128
|
-
- `CICY_MASTER_TOKEN`
|
|
129
|
-
|
|
130
|
-
registration succeeded.
|
|
131
|
-
|
|
132
|
-
## What This Project Is Right Now
|
|
133
|
-
|
|
134
|
-
Best current description:
|
|
135
|
-
|
|
136
|
-
> A mature single-node Electron automation worker runtime with early but working master/worker distributed plumbing.
|
|
137
|
-
|
|
138
|
-
It is **not yet** a fully mature distributed desktop cluster, but it already has the first working pieces.
|
|
139
|
-
|
|
140
|
-
## What Is Still Missing / Incomplete
|
|
141
|
-
|
|
142
|
-
Likely gaps still needing work:
|
|
143
|
-
- richer agent abstraction beyond raw BrowserWindow
|
|
144
|
-
- stronger task lifecycle orchestration
|
|
145
|
-
- worker health/resource reporting polish
|
|
146
|
-
- clearer worker startup/desktop launch flow
|
|
147
|
-
- better master UI observability for workers/agents/tasks
|
|
148
|
-
- more robust retry/error handling in master-to-worker forwarding
|
|
149
|
-
|
|
150
|
-
## What To Do First
|
|
151
|
-
|
|
152
|
-
Before changing code:
|
|
153
|
-
1. Read the files listed above
|
|
154
|
-
2. Summarize current architecture in your own words
|
|
155
|
-
3. Explain what master/worker currently implements
|
|
156
|
-
4. Identify the most important missing pieces
|
|
157
|
-
5. Propose the next incremental step before editing code
|
|
158
|
-
|
|
159
|
-
## Expected First Response
|
|
160
|
-
|
|
161
|
-
Please start by answering:
|
|
162
|
-
|
|
163
|
-
1. What is the current architecture?
|
|
164
|
-
2. What exactly is already implemented for master/worker?
|
|
165
|
-
3. What is missing or fragile?
|
|
166
|
-
4. What should be the next priority?
|
|
167
|
-
|
|
168
|
-
Do not start editing immediately. Read first, then propose a plan.
|