cicy-desktop 1.0.8
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/.github/workflows/build.yml +85 -0
- package/.kiro/steering/dev-workflow.md +166 -0
- package/AGENTS.md +247 -0
- package/CLAUDE.md +162 -0
- package/DOCKER.md +85 -0
- package/Dockerfile +46 -0
- package/README.md +720 -0
- package/TODO-anti-detection.md +326 -0
- package/bin/cicy +176 -0
- package/bin/preinstall.sh +32 -0
- package/copy-to-desktop.sh +26 -0
- package/docs/AUTOMATION-API.md +342 -0
- package/docs/REQUEST_MONITORING.md +435 -0
- package/docs/REST-API-FEATURE.md +155 -0
- package/docs/REST-API.md +319 -0
- package/docs/feature-distributed-multi-agent.md +555 -0
- package/docs/yaml.md +255 -0
- package/electron-mcp-fixed.command +134 -0
- package/electron-mcp-simple.command +135 -0
- package/electron-mcp.command +92 -0
- package/generate-openapi.js +158 -0
- package/jest.config.js +10 -0
- package/jest.setup.global.js +13 -0
- package/jest.teardown.global.js +7 -0
- package/package.json +75 -0
- package/service.sh +164 -0
- package/src/config.js +8 -0
- package/src/extension/inject.js +135 -0
- package/src/main-old.js +837 -0
- package/src/main.js +403 -0
- package/src/preload-rpc.js +4 -0
- package/src/server/args-parser.js +37 -0
- package/src/server/electron-setup.js +33 -0
- package/src/server/express-app.js +166 -0
- package/src/server/logging.js +58 -0
- package/src/server/mcp-server.js +53 -0
- package/src/server/tool-registry.js +77 -0
- package/src/server/ui-routes.js +81 -0
- package/src/swagger-ui.html +41 -0
- package/src/tools/account-tools.js +194 -0
- package/src/tools/automation-tools.js +297 -0
- package/src/tools/cdp-tools.js +444 -0
- package/src/tools/clipboard-tools.js +180 -0
- package/src/tools/download-tools.js +57 -0
- package/src/tools/exec-js.js +297 -0
- package/src/tools/exec-tools.js +139 -0
- package/src/tools/file-tools.js +212 -0
- package/src/tools/hook-chatgpt.js +489 -0
- package/src/tools/hook-gemini.js +454 -0
- package/src/tools/index.js +19 -0
- package/src/tools/ipc-bridge.js +31 -0
- package/src/tools/ping.js +60 -0
- package/src/tools/r-reset.js +28 -0
- package/src/tools/screenshot-tools.js +28 -0
- package/src/tools/system-tools.js +531 -0
- package/src/tools/window-tools.js +882 -0
- package/src/ui.html +914 -0
- package/src/utils/auth.js +81 -0
- package/src/utils/cdp-utils.js +8 -0
- package/src/utils/download-manager.js +41 -0
- package/src/utils/process-utils.js +185 -0
- package/src/utils/snapshot-utils.js +56 -0
- package/src/utils/window-monitor.js +605 -0
- package/src/utils/window-state.js +137 -0
- package/src/utils/window-utils.js +336 -0
- package/update-desktop.sh +33 -0
package/docs/REST-API.md
ADDED
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
# REST API Documentation
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
Electron MCP now provides REST API endpoints for each tool. Each tool can be called via:
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
POST /rpc/{toolName}
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Swagger UI
|
|
12
|
+
|
|
13
|
+
Interactive API documentation available at:
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
http://localhost:8101/api-docs
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Authentication
|
|
20
|
+
|
|
21
|
+
All endpoints (except `/ping`) require Bearer token authentication:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
Authorization: Bearer <your-token>
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Token location: `~/data/electron/token.txt`
|
|
28
|
+
|
|
29
|
+
## Available Endpoints
|
|
30
|
+
|
|
31
|
+
### List All Tools
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
GET /rpc/tools
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
**Example:**
|
|
38
|
+
```bash
|
|
39
|
+
curl -H "Authorization: Bearer $(cat ~/data/electron/token.txt)" \
|
|
40
|
+
http://localhost:8101/rpc/tools
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Call a Tool
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
POST /rpc/{toolName}
|
|
47
|
+
Content-Type: application/json
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Examples
|
|
51
|
+
|
|
52
|
+
### 1. Ping
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
curl -X POST http://localhost:8101/rpc/ping \
|
|
56
|
+
-H "Content-Type: application/json" \
|
|
57
|
+
-H "Authorization: Bearer $(cat ~/data/electron/token.txt)" \
|
|
58
|
+
-d '{}'
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
**Response:**
|
|
62
|
+
```json
|
|
63
|
+
{
|
|
64
|
+
"content": [
|
|
65
|
+
{
|
|
66
|
+
"type": "text",
|
|
67
|
+
"text": "Pong"
|
|
68
|
+
}
|
|
69
|
+
]
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### 2. Get Windows
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
curl -X POST http://localhost:8101/rpc/get_windows \
|
|
77
|
+
-H "Content-Type: application/json" \
|
|
78
|
+
-H "Authorization: Bearer $(cat ~/data/electron/token.txt)" \
|
|
79
|
+
-d '{}'
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
**Response:**
|
|
83
|
+
```json
|
|
84
|
+
{
|
|
85
|
+
"content": [
|
|
86
|
+
{
|
|
87
|
+
"type": "text",
|
|
88
|
+
"text": "[{\"id\":1,\"url\":\"https://example.com\"}]"
|
|
89
|
+
}
|
|
90
|
+
]
|
|
91
|
+
}
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### 3. Open Window
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
curl -X POST http://localhost:8101/rpc/open_window \
|
|
98
|
+
-H "Content-Type: application/json" \
|
|
99
|
+
-H "Authorization: Bearer $(cat ~/data/electron/token.txt)" \
|
|
100
|
+
-d '{
|
|
101
|
+
"url": "https://example.com",
|
|
102
|
+
"accountIdx": 0
|
|
103
|
+
}'
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
**Response:**
|
|
107
|
+
```json
|
|
108
|
+
{
|
|
109
|
+
"content": [
|
|
110
|
+
{
|
|
111
|
+
"type": "text",
|
|
112
|
+
"text": "Opened window with ID: 1, use tool: get_window_info and wait window webContents dom-ready"
|
|
113
|
+
}
|
|
114
|
+
]
|
|
115
|
+
}
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### 4. Close Window
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
curl -X POST http://localhost:8101/rpc/close_window \
|
|
122
|
+
-H "Content-Type: application/json" \
|
|
123
|
+
-H "Authorization: Bearer $(cat ~/data/electron/token.txt)" \
|
|
124
|
+
-d '{
|
|
125
|
+
"win_id": 1
|
|
126
|
+
}'
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
**Response:**
|
|
130
|
+
```json
|
|
131
|
+
{
|
|
132
|
+
"content": [
|
|
133
|
+
{
|
|
134
|
+
"type": "text",
|
|
135
|
+
"text": "Closed window 1"
|
|
136
|
+
}
|
|
137
|
+
]
|
|
138
|
+
}
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### 5. Execute JavaScript
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
curl -X POST http://localhost:8101/rpc/exec_js \
|
|
145
|
+
-H "Content-Type: application/json" \
|
|
146
|
+
-H "Authorization: Bearer $(cat ~/data/electron/token.txt)" \
|
|
147
|
+
-d '{
|
|
148
|
+
"win_id": 1,
|
|
149
|
+
"code": "document.title"
|
|
150
|
+
}'
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### 6. CDP Click
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
curl -X POST http://localhost:8101/rpc/cdp_click \
|
|
157
|
+
-H "Content-Type: application/json" \
|
|
158
|
+
-H "Authorization: Bearer $(cat ~/data/electron/token.txt)" \
|
|
159
|
+
-d '{
|
|
160
|
+
"win_id": 1,
|
|
161
|
+
"selector": "button.submit"
|
|
162
|
+
}'
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
### 7. Take Screenshot
|
|
166
|
+
|
|
167
|
+
```bash
|
|
168
|
+
curl -X POST http://localhost:8101/rpc/cdp_screenshot \
|
|
169
|
+
-H "Content-Type: application/json" \
|
|
170
|
+
-H "Authorization: Bearer $(cat ~/data/electron/token.txt)" \
|
|
171
|
+
-d '{
|
|
172
|
+
"win_id": 1
|
|
173
|
+
}'
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
## Error Handling
|
|
177
|
+
|
|
178
|
+
### Tool Not Found (404)
|
|
179
|
+
|
|
180
|
+
```json
|
|
181
|
+
{
|
|
182
|
+
"error": "Tool not found: unknown_tool",
|
|
183
|
+
"available": ["ping", "open_window", "get_windows", ...]
|
|
184
|
+
}
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
### Execution Error (500)
|
|
188
|
+
|
|
189
|
+
```json
|
|
190
|
+
{
|
|
191
|
+
"error": "Window not found: 999"
|
|
192
|
+
}
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
### Unauthorized (401)
|
|
196
|
+
|
|
197
|
+
```json
|
|
198
|
+
{
|
|
199
|
+
"error": "Unauthorized"
|
|
200
|
+
}
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
## Comparison: RPC vs REST
|
|
204
|
+
|
|
205
|
+
### JSON-RPC Style (Original)
|
|
206
|
+
|
|
207
|
+
```bash
|
|
208
|
+
POST /rpc
|
|
209
|
+
{
|
|
210
|
+
"jsonrpc": "2.0",
|
|
211
|
+
"id": 1,
|
|
212
|
+
"method": "tools/call",
|
|
213
|
+
"params": {
|
|
214
|
+
"name": "open_window",
|
|
215
|
+
"arguments": {"url": "https://example.com", "accountIdx": 0}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
### REST Style (New)
|
|
221
|
+
|
|
222
|
+
```bash
|
|
223
|
+
POST /rpc/open_window
|
|
224
|
+
{
|
|
225
|
+
"url": "https://example.com",
|
|
226
|
+
"accountIdx": 0
|
|
227
|
+
}
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
**Benefits:**
|
|
231
|
+
- ✅ Simpler URL structure
|
|
232
|
+
- ✅ Direct tool invocation
|
|
233
|
+
- ✅ Swagger documentation
|
|
234
|
+
- ✅ Standard HTTP semantics
|
|
235
|
+
- ✅ Easier to test with curl
|
|
236
|
+
|
|
237
|
+
## Testing
|
|
238
|
+
|
|
239
|
+
Run REST API tests:
|
|
240
|
+
|
|
241
|
+
```bash
|
|
242
|
+
cd tests/rpc
|
|
243
|
+
npm test rest-api.test.js
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
## Integration
|
|
247
|
+
|
|
248
|
+
### JavaScript/Node.js
|
|
249
|
+
|
|
250
|
+
```javascript
|
|
251
|
+
const axios = require('axios');
|
|
252
|
+
const fs = require('fs');
|
|
253
|
+
|
|
254
|
+
const token = fs.readFileSync(process.env.HOME + '/data/electron/token.txt', 'utf8').trim();
|
|
255
|
+
|
|
256
|
+
async function callTool(toolName, args) {
|
|
257
|
+
const response = await axios.post(
|
|
258
|
+
`http://localhost:8101/rpc/${toolName}`,
|
|
259
|
+
args,
|
|
260
|
+
{
|
|
261
|
+
headers: {
|
|
262
|
+
'Authorization': `Bearer ${token}`,
|
|
263
|
+
'Content-Type': 'application/json'
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
);
|
|
267
|
+
return response.data;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
// Usage
|
|
271
|
+
const result = await callTool('ping', {});
|
|
272
|
+
console.log(result);
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
### Python
|
|
276
|
+
|
|
277
|
+
```python
|
|
278
|
+
import requests
|
|
279
|
+
import os
|
|
280
|
+
|
|
281
|
+
token = open(os.path.expanduser('~/data/electron/token.txt')).read().strip()
|
|
282
|
+
|
|
283
|
+
def call_tool(tool_name, args={}):
|
|
284
|
+
response = requests.post(
|
|
285
|
+
f'http://localhost:8101/rpc/{tool_name}',
|
|
286
|
+
json=args,
|
|
287
|
+
headers={
|
|
288
|
+
'Authorization': f'Bearer {token}',
|
|
289
|
+
'Content-Type': 'application/json'
|
|
290
|
+
}
|
|
291
|
+
)
|
|
292
|
+
return response.json()
|
|
293
|
+
|
|
294
|
+
# Usage
|
|
295
|
+
result = call_tool('ping')
|
|
296
|
+
print(result)
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
## Available Tools
|
|
300
|
+
|
|
301
|
+
Get the full list dynamically:
|
|
302
|
+
|
|
303
|
+
```bash
|
|
304
|
+
curl -H "Authorization: Bearer $(cat ~/data/electron/token.txt)" \
|
|
305
|
+
http://localhost:8101/rpc/tools | jq '.tools[].name'
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
Common tools:
|
|
309
|
+
- `ping` - Health check
|
|
310
|
+
- `get_windows` - List all windows
|
|
311
|
+
- `open_window` - Open new window
|
|
312
|
+
- `close_window` - Close window
|
|
313
|
+
- `get_window_info` - Get window details
|
|
314
|
+
- `exec_js` - Execute JavaScript
|
|
315
|
+
- `cdp_click` - Click element
|
|
316
|
+
- `cdp_screenshot` - Take screenshot
|
|
317
|
+
- `cdp_get_page_snapshot` - Get page HTML
|
|
318
|
+
|
|
319
|
+
See Swagger UI for complete list and schemas.
|