@chatroomcp/chatroom 0.1.6 → 0.2.0
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/dist/app/application.d.ts +1 -0
- package/dist/app/application.js +4 -0
- package/dist/app/event-bus.d.ts +4 -0
- package/dist/auth/ingress-policy.d.ts +2 -0
- package/dist/auth/ingress-policy.js +7 -1
- package/dist/infrastructure/database/app-database.js +7 -0
- package/dist/infrastructure/http/http-server.js +5 -1
- package/dist/mcp/server/plugin-mcp-registrar.d.ts +6 -1
- package/dist/mcp/server/plugin-mcp-registrar.js +4 -4
- package/dist/mcp/server/request-context.d.ts +3 -0
- package/dist/mcp/server/request-context.js +8 -0
- package/dist/mcp/server/tool-support.d.ts +1 -1
- package/dist/mcp/server/tool-support.js +3 -1
- package/dist/native/macos/ChatRoomComputerHelper.app/Contents/Info.plist +14 -0
- package/dist/native/macos/ChatRoomComputerHelper.app/Contents/MacOS/chatroom-computer-helper +0 -0
- package/dist/native/macos/ChatRoomComputerHelper.app/Contents/_CodeSignature/CodeResources +115 -0
- package/dist/native/windows/chatroom-computer-helper.exe +0 -0
- package/dist/plugins/cloud/tunnel-client.d.ts +15 -1
- package/dist/plugins/cloud/tunnel-client.js +69 -3
- package/dist/plugins/computer/audit.d.ts +34 -0
- package/dist/plugins/computer/audit.js +42 -0
- package/dist/plugins/computer/computer-native-backend.d.ts +11 -0
- package/dist/plugins/computer/computer-native-backend.js +58 -0
- package/dist/plugins/computer/computer-native-host.d.ts +26 -0
- package/dist/plugins/computer/computer-native-host.js +245 -0
- package/dist/plugins/computer/computer-protocol.d.ts +21 -0
- package/dist/plugins/computer/computer-protocol.js +72 -0
- package/dist/plugins/computer/computer-schemas.d.ts +317 -0
- package/dist/plugins/computer/computer-schemas.js +152 -0
- package/dist/plugins/computer/computer-service.d.ts +27 -0
- package/dist/plugins/computer/computer-service.js +108 -0
- package/dist/plugins/computer/computer-settings-repository.d.ts +8 -0
- package/dist/plugins/computer/computer-settings-repository.js +41 -0
- package/dist/plugins/computer/mcp.d.ts +3 -0
- package/dist/plugins/computer/mcp.js +126 -0
- package/dist/plugins/computer/plugin.d.ts +4 -0
- package/dist/plugins/computer/plugin.js +29 -0
- package/dist/plugins/computer/types.d.ts +174 -0
- package/dist/plugins/computer/types.js +1 -0
- package/dist/plugins/web/api-types.d.ts +15 -1
- package/dist/plugins/web/http/api-router.js +2 -0
- package/dist/plugins/web/http/computer-api-router.d.ts +5 -0
- package/dist/plugins/web/http/computer-api-router.js +68 -0
- package/dist/plugins/web/plugin.js +3 -1
- package/dist/plugins/web/runtime.d.ts +3 -1
- package/dist/plugins/web/runtime.js +3 -1
- package/dist/web/assets/index-BXlxEk8f.css +1 -0
- package/dist/web/assets/index-DUM6zVHS.js +26 -0
- package/dist/web/index.html +2 -2
- package/package.json +6 -3
- package/dist/web/assets/index-B7jL3mhD.css +0 -1
- package/dist/web/assets/index-L4-YdZVN.js +0 -26
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const computerPermissionStateSchema: z.ZodEnum<{
|
|
3
|
+
granted: "granted";
|
|
4
|
+
denied: "denied";
|
|
5
|
+
unknown: "unknown";
|
|
6
|
+
"not-required": "not-required";
|
|
7
|
+
}>;
|
|
8
|
+
export declare const computerDisplaySchema: z.ZodObject<{
|
|
9
|
+
id: z.ZodString;
|
|
10
|
+
name: z.ZodString;
|
|
11
|
+
width: z.ZodNumber;
|
|
12
|
+
height: z.ZodNumber;
|
|
13
|
+
scale: z.ZodNumber;
|
|
14
|
+
primary: z.ZodBoolean;
|
|
15
|
+
}, z.core.$strip>;
|
|
16
|
+
export declare const computerElementSchema: z.ZodObject<{
|
|
17
|
+
id: z.ZodNumber;
|
|
18
|
+
role: z.ZodString;
|
|
19
|
+
name: z.ZodNullable<z.ZodString>;
|
|
20
|
+
value: z.ZodNullable<z.ZodString>;
|
|
21
|
+
enabled: z.ZodBoolean;
|
|
22
|
+
focused: z.ZodBoolean;
|
|
23
|
+
selected: z.ZodBoolean;
|
|
24
|
+
sensitive: z.ZodBoolean;
|
|
25
|
+
bounds: z.ZodNullable<z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber, z.ZodNumber], null>>;
|
|
26
|
+
actions: z.ZodArray<z.ZodString>;
|
|
27
|
+
}, z.core.$strip>;
|
|
28
|
+
export declare const computerScreenshotSchema: z.ZodObject<{
|
|
29
|
+
mimeType: z.ZodEnum<{
|
|
30
|
+
"image/jpeg": "image/jpeg";
|
|
31
|
+
"image/png": "image/png";
|
|
32
|
+
}>;
|
|
33
|
+
data: z.ZodString;
|
|
34
|
+
}, z.core.$strip>;
|
|
35
|
+
export declare const computerNativeStatusSchema: z.ZodObject<{
|
|
36
|
+
platform: z.ZodEnum<{
|
|
37
|
+
macos: "macos";
|
|
38
|
+
windows: "windows";
|
|
39
|
+
unsupported: "unsupported";
|
|
40
|
+
}>;
|
|
41
|
+
helper: z.ZodEnum<{
|
|
42
|
+
running: "running";
|
|
43
|
+
stopped: "stopped";
|
|
44
|
+
unavailable: "unavailable";
|
|
45
|
+
}>;
|
|
46
|
+
permissions: z.ZodObject<{
|
|
47
|
+
accessibility: z.ZodEnum<{
|
|
48
|
+
granted: "granted";
|
|
49
|
+
denied: "denied";
|
|
50
|
+
unknown: "unknown";
|
|
51
|
+
"not-required": "not-required";
|
|
52
|
+
}>;
|
|
53
|
+
screenRecording: z.ZodEnum<{
|
|
54
|
+
granted: "granted";
|
|
55
|
+
denied: "denied";
|
|
56
|
+
unknown: "unknown";
|
|
57
|
+
"not-required": "not-required";
|
|
58
|
+
}>;
|
|
59
|
+
}, z.core.$strip>;
|
|
60
|
+
displays: z.ZodArray<z.ZodObject<{
|
|
61
|
+
id: z.ZodString;
|
|
62
|
+
name: z.ZodString;
|
|
63
|
+
width: z.ZodNumber;
|
|
64
|
+
height: z.ZodNumber;
|
|
65
|
+
scale: z.ZodNumber;
|
|
66
|
+
primary: z.ZodBoolean;
|
|
67
|
+
}, z.core.$strip>>;
|
|
68
|
+
}, z.core.$strip>;
|
|
69
|
+
export declare const computerSnapshotSchema: z.ZodObject<{
|
|
70
|
+
snapshotId: z.ZodString;
|
|
71
|
+
revision: z.ZodNumber;
|
|
72
|
+
display: z.ZodNullable<z.ZodObject<{
|
|
73
|
+
id: z.ZodString;
|
|
74
|
+
name: z.ZodString;
|
|
75
|
+
width: z.ZodNumber;
|
|
76
|
+
height: z.ZodNumber;
|
|
77
|
+
scale: z.ZodNumber;
|
|
78
|
+
primary: z.ZodBoolean;
|
|
79
|
+
}, z.core.$strip>>;
|
|
80
|
+
activeApp: z.ZodNullable<z.ZodString>;
|
|
81
|
+
activeWindow: z.ZodNullable<z.ZodString>;
|
|
82
|
+
cursor: z.ZodNullable<z.ZodObject<{
|
|
83
|
+
x: z.ZodNumber;
|
|
84
|
+
y: z.ZodNumber;
|
|
85
|
+
}, z.core.$strip>>;
|
|
86
|
+
elements: z.ZodArray<z.ZodObject<{
|
|
87
|
+
id: z.ZodNumber;
|
|
88
|
+
role: z.ZodString;
|
|
89
|
+
name: z.ZodNullable<z.ZodString>;
|
|
90
|
+
value: z.ZodNullable<z.ZodString>;
|
|
91
|
+
enabled: z.ZodBoolean;
|
|
92
|
+
focused: z.ZodBoolean;
|
|
93
|
+
selected: z.ZodBoolean;
|
|
94
|
+
sensitive: z.ZodBoolean;
|
|
95
|
+
bounds: z.ZodNullable<z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber, z.ZodNumber], null>>;
|
|
96
|
+
actions: z.ZodArray<z.ZodString>;
|
|
97
|
+
}, z.core.$strip>>;
|
|
98
|
+
screenshot: z.ZodOptional<z.ZodObject<{
|
|
99
|
+
mimeType: z.ZodEnum<{
|
|
100
|
+
"image/jpeg": "image/jpeg";
|
|
101
|
+
"image/png": "image/png";
|
|
102
|
+
}>;
|
|
103
|
+
data: z.ZodString;
|
|
104
|
+
}, z.core.$strip>>;
|
|
105
|
+
}, z.core.$strip>;
|
|
106
|
+
export declare const computerSnapshotMetadataSchema: z.ZodObject<{
|
|
107
|
+
display: z.ZodNullable<z.ZodObject<{
|
|
108
|
+
id: z.ZodString;
|
|
109
|
+
name: z.ZodString;
|
|
110
|
+
width: z.ZodNumber;
|
|
111
|
+
height: z.ZodNumber;
|
|
112
|
+
scale: z.ZodNumber;
|
|
113
|
+
primary: z.ZodBoolean;
|
|
114
|
+
}, z.core.$strip>>;
|
|
115
|
+
snapshotId: z.ZodString;
|
|
116
|
+
revision: z.ZodNumber;
|
|
117
|
+
activeApp: z.ZodNullable<z.ZodString>;
|
|
118
|
+
activeWindow: z.ZodNullable<z.ZodString>;
|
|
119
|
+
cursor: z.ZodNullable<z.ZodObject<{
|
|
120
|
+
x: z.ZodNumber;
|
|
121
|
+
y: z.ZodNumber;
|
|
122
|
+
}, z.core.$strip>>;
|
|
123
|
+
elements: z.ZodArray<z.ZodObject<{
|
|
124
|
+
id: z.ZodNumber;
|
|
125
|
+
role: z.ZodString;
|
|
126
|
+
name: z.ZodNullable<z.ZodString>;
|
|
127
|
+
value: z.ZodNullable<z.ZodString>;
|
|
128
|
+
enabled: z.ZodBoolean;
|
|
129
|
+
focused: z.ZodBoolean;
|
|
130
|
+
selected: z.ZodBoolean;
|
|
131
|
+
sensitive: z.ZodBoolean;
|
|
132
|
+
bounds: z.ZodNullable<z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber, z.ZodNumber], null>>;
|
|
133
|
+
actions: z.ZodArray<z.ZodString>;
|
|
134
|
+
}, z.core.$strip>>;
|
|
135
|
+
}, z.core.$strip>;
|
|
136
|
+
export declare const computerActionSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
137
|
+
type: z.ZodLiteral<"move">;
|
|
138
|
+
x: z.ZodNumber;
|
|
139
|
+
y: z.ZodNumber;
|
|
140
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
141
|
+
type: z.ZodLiteral<"click">;
|
|
142
|
+
x: z.ZodOptional<z.ZodNumber>;
|
|
143
|
+
y: z.ZodOptional<z.ZodNumber>;
|
|
144
|
+
elementId: z.ZodOptional<z.ZodNumber>;
|
|
145
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
146
|
+
type: z.ZodLiteral<"double_click">;
|
|
147
|
+
x: z.ZodOptional<z.ZodNumber>;
|
|
148
|
+
y: z.ZodOptional<z.ZodNumber>;
|
|
149
|
+
elementId: z.ZodOptional<z.ZodNumber>;
|
|
150
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
151
|
+
type: z.ZodLiteral<"right_click">;
|
|
152
|
+
x: z.ZodOptional<z.ZodNumber>;
|
|
153
|
+
y: z.ZodOptional<z.ZodNumber>;
|
|
154
|
+
elementId: z.ZodOptional<z.ZodNumber>;
|
|
155
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
156
|
+
type: z.ZodLiteral<"drag">;
|
|
157
|
+
from: z.ZodObject<{
|
|
158
|
+
x: z.ZodNumber;
|
|
159
|
+
y: z.ZodNumber;
|
|
160
|
+
}, z.core.$strip>;
|
|
161
|
+
to: z.ZodObject<{
|
|
162
|
+
x: z.ZodNumber;
|
|
163
|
+
y: z.ZodNumber;
|
|
164
|
+
}, z.core.$strip>;
|
|
165
|
+
durationMs: z.ZodOptional<z.ZodNumber>;
|
|
166
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
167
|
+
type: z.ZodLiteral<"scroll">;
|
|
168
|
+
deltaX: z.ZodOptional<z.ZodNumber>;
|
|
169
|
+
deltaY: z.ZodNumber;
|
|
170
|
+
elementId: z.ZodOptional<z.ZodNumber>;
|
|
171
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
172
|
+
type: z.ZodLiteral<"keypress">;
|
|
173
|
+
keys: z.ZodArray<z.ZodString>;
|
|
174
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
175
|
+
type: z.ZodLiteral<"type_text">;
|
|
176
|
+
text: z.ZodString;
|
|
177
|
+
elementId: z.ZodOptional<z.ZodNumber>;
|
|
178
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
179
|
+
type: z.ZodLiteral<"invoke">;
|
|
180
|
+
elementId: z.ZodNumber;
|
|
181
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
182
|
+
type: z.ZodLiteral<"set_value">;
|
|
183
|
+
elementId: z.ZodNumber;
|
|
184
|
+
value: z.ZodString;
|
|
185
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
186
|
+
type: z.ZodLiteral<"select_text">;
|
|
187
|
+
elementId: z.ZodNumber;
|
|
188
|
+
start: z.ZodNumber;
|
|
189
|
+
length: z.ZodNumber;
|
|
190
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
191
|
+
type: z.ZodLiteral<"activate_app">;
|
|
192
|
+
app: z.ZodString;
|
|
193
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
194
|
+
type: z.ZodLiteral<"activate_window">;
|
|
195
|
+
elementId: z.ZodNumber;
|
|
196
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
197
|
+
type: z.ZodLiteral<"move_window">;
|
|
198
|
+
elementId: z.ZodNumber;
|
|
199
|
+
x: z.ZodNumber;
|
|
200
|
+
y: z.ZodNumber;
|
|
201
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
202
|
+
type: z.ZodLiteral<"resize_window">;
|
|
203
|
+
elementId: z.ZodNumber;
|
|
204
|
+
width: z.ZodNumber;
|
|
205
|
+
height: z.ZodNumber;
|
|
206
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
207
|
+
type: z.ZodLiteral<"wait">;
|
|
208
|
+
ms: z.ZodNumber;
|
|
209
|
+
}, z.core.$strip>], "type">;
|
|
210
|
+
export declare const computerActionResultSchema: z.ZodObject<{
|
|
211
|
+
success: z.ZodLiteral<true>;
|
|
212
|
+
revision: z.ZodNumber;
|
|
213
|
+
snapshot: z.ZodOptional<z.ZodObject<{
|
|
214
|
+
snapshotId: z.ZodString;
|
|
215
|
+
revision: z.ZodNumber;
|
|
216
|
+
display: z.ZodNullable<z.ZodObject<{
|
|
217
|
+
id: z.ZodString;
|
|
218
|
+
name: z.ZodString;
|
|
219
|
+
width: z.ZodNumber;
|
|
220
|
+
height: z.ZodNumber;
|
|
221
|
+
scale: z.ZodNumber;
|
|
222
|
+
primary: z.ZodBoolean;
|
|
223
|
+
}, z.core.$strip>>;
|
|
224
|
+
activeApp: z.ZodNullable<z.ZodString>;
|
|
225
|
+
activeWindow: z.ZodNullable<z.ZodString>;
|
|
226
|
+
cursor: z.ZodNullable<z.ZodObject<{
|
|
227
|
+
x: z.ZodNumber;
|
|
228
|
+
y: z.ZodNumber;
|
|
229
|
+
}, z.core.$strip>>;
|
|
230
|
+
elements: z.ZodArray<z.ZodObject<{
|
|
231
|
+
id: z.ZodNumber;
|
|
232
|
+
role: z.ZodString;
|
|
233
|
+
name: z.ZodNullable<z.ZodString>;
|
|
234
|
+
value: z.ZodNullable<z.ZodString>;
|
|
235
|
+
enabled: z.ZodBoolean;
|
|
236
|
+
focused: z.ZodBoolean;
|
|
237
|
+
selected: z.ZodBoolean;
|
|
238
|
+
sensitive: z.ZodBoolean;
|
|
239
|
+
bounds: z.ZodNullable<z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber, z.ZodNumber], null>>;
|
|
240
|
+
actions: z.ZodArray<z.ZodString>;
|
|
241
|
+
}, z.core.$strip>>;
|
|
242
|
+
screenshot: z.ZodOptional<z.ZodObject<{
|
|
243
|
+
mimeType: z.ZodEnum<{
|
|
244
|
+
"image/jpeg": "image/jpeg";
|
|
245
|
+
"image/png": "image/png";
|
|
246
|
+
}>;
|
|
247
|
+
data: z.ZodString;
|
|
248
|
+
}, z.core.$strip>>;
|
|
249
|
+
}, z.core.$strip>>;
|
|
250
|
+
executionMode: z.ZodEnum<{
|
|
251
|
+
semantic: "semantic";
|
|
252
|
+
background: "background";
|
|
253
|
+
foreground: "foreground";
|
|
254
|
+
mixed: "mixed";
|
|
255
|
+
}>;
|
|
256
|
+
focusChanged: z.ZodBoolean;
|
|
257
|
+
}, z.core.$strip>;
|
|
258
|
+
export declare const computerActionMetadataSchema: z.ZodObject<{
|
|
259
|
+
success: z.ZodLiteral<true>;
|
|
260
|
+
revision: z.ZodNumber;
|
|
261
|
+
executionMode: z.ZodEnum<{
|
|
262
|
+
semantic: "semantic";
|
|
263
|
+
background: "background";
|
|
264
|
+
foreground: "foreground";
|
|
265
|
+
mixed: "mixed";
|
|
266
|
+
}>;
|
|
267
|
+
focusChanged: z.ZodBoolean;
|
|
268
|
+
snapshot: z.ZodOptional<z.ZodObject<{
|
|
269
|
+
display: z.ZodNullable<z.ZodObject<{
|
|
270
|
+
id: z.ZodString;
|
|
271
|
+
name: z.ZodString;
|
|
272
|
+
width: z.ZodNumber;
|
|
273
|
+
height: z.ZodNumber;
|
|
274
|
+
scale: z.ZodNumber;
|
|
275
|
+
primary: z.ZodBoolean;
|
|
276
|
+
}, z.core.$strip>>;
|
|
277
|
+
snapshotId: z.ZodString;
|
|
278
|
+
revision: z.ZodNumber;
|
|
279
|
+
activeApp: z.ZodNullable<z.ZodString>;
|
|
280
|
+
activeWindow: z.ZodNullable<z.ZodString>;
|
|
281
|
+
cursor: z.ZodNullable<z.ZodObject<{
|
|
282
|
+
x: z.ZodNumber;
|
|
283
|
+
y: z.ZodNumber;
|
|
284
|
+
}, z.core.$strip>>;
|
|
285
|
+
elements: z.ZodArray<z.ZodObject<{
|
|
286
|
+
id: z.ZodNumber;
|
|
287
|
+
role: z.ZodString;
|
|
288
|
+
name: z.ZodNullable<z.ZodString>;
|
|
289
|
+
value: z.ZodNullable<z.ZodString>;
|
|
290
|
+
enabled: z.ZodBoolean;
|
|
291
|
+
focused: z.ZodBoolean;
|
|
292
|
+
selected: z.ZodBoolean;
|
|
293
|
+
sensitive: z.ZodBoolean;
|
|
294
|
+
bounds: z.ZodNullable<z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber, z.ZodNumber], null>>;
|
|
295
|
+
actions: z.ZodArray<z.ZodString>;
|
|
296
|
+
}, z.core.$strip>>;
|
|
297
|
+
}, z.core.$strip>>;
|
|
298
|
+
}, z.core.$strip>;
|
|
299
|
+
export declare const computerSnapshotTargetSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
300
|
+
type: z.ZodLiteral<"desktop">;
|
|
301
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
302
|
+
type: z.ZodLiteral<"display">;
|
|
303
|
+
displayId: z.ZodOptional<z.ZodString>;
|
|
304
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
305
|
+
type: z.ZodLiteral<"app">;
|
|
306
|
+
app: z.ZodString;
|
|
307
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
308
|
+
type: z.ZodLiteral<"window">;
|
|
309
|
+
elementId: z.ZodNumber;
|
|
310
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
311
|
+
type: z.ZodLiteral<"region">;
|
|
312
|
+
displayId: z.ZodOptional<z.ZodString>;
|
|
313
|
+
x: z.ZodNumber;
|
|
314
|
+
y: z.ZodNumber;
|
|
315
|
+
width: z.ZodNumber;
|
|
316
|
+
height: z.ZodNumber;
|
|
317
|
+
}, z.core.$strip>], "type">;
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export const computerPermissionStateSchema = z.enum([
|
|
3
|
+
"granted",
|
|
4
|
+
"denied",
|
|
5
|
+
"unknown",
|
|
6
|
+
"not-required",
|
|
7
|
+
]);
|
|
8
|
+
export const computerDisplaySchema = z.object({
|
|
9
|
+
id: z.string(),
|
|
10
|
+
name: z.string(),
|
|
11
|
+
width: z.number(),
|
|
12
|
+
height: z.number(),
|
|
13
|
+
scale: z.number(),
|
|
14
|
+
primary: z.boolean(),
|
|
15
|
+
});
|
|
16
|
+
export const computerElementSchema = z.object({
|
|
17
|
+
id: z.number().int(),
|
|
18
|
+
role: z.string(),
|
|
19
|
+
name: z.string().nullable(),
|
|
20
|
+
value: z.string().nullable(),
|
|
21
|
+
enabled: z.boolean(),
|
|
22
|
+
focused: z.boolean(),
|
|
23
|
+
selected: z.boolean(),
|
|
24
|
+
sensitive: z.boolean(),
|
|
25
|
+
bounds: z.tuple([z.number(), z.number(), z.number(), z.number()]).nullable(),
|
|
26
|
+
actions: z.array(z.string()),
|
|
27
|
+
});
|
|
28
|
+
export const computerScreenshotSchema = z.object({
|
|
29
|
+
mimeType: z.enum(["image/jpeg", "image/png"]),
|
|
30
|
+
data: z.string(),
|
|
31
|
+
});
|
|
32
|
+
export const computerNativeStatusSchema = z.object({
|
|
33
|
+
platform: z.enum(["macos", "windows", "unsupported"]),
|
|
34
|
+
helper: z.enum(["running", "stopped", "unavailable"]),
|
|
35
|
+
permissions: z.object({
|
|
36
|
+
accessibility: computerPermissionStateSchema,
|
|
37
|
+
screenRecording: computerPermissionStateSchema,
|
|
38
|
+
}),
|
|
39
|
+
displays: z.array(computerDisplaySchema),
|
|
40
|
+
});
|
|
41
|
+
export const computerSnapshotSchema = z.object({
|
|
42
|
+
snapshotId: z.string().min(1),
|
|
43
|
+
revision: z.number().int(),
|
|
44
|
+
display: computerDisplaySchema.nullable(),
|
|
45
|
+
activeApp: z.string().nullable(),
|
|
46
|
+
activeWindow: z.string().nullable(),
|
|
47
|
+
cursor: z.object({ x: z.number(), y: z.number() }).nullable(),
|
|
48
|
+
elements: z.array(computerElementSchema),
|
|
49
|
+
screenshot: computerScreenshotSchema.optional(),
|
|
50
|
+
});
|
|
51
|
+
export const computerSnapshotMetadataSchema = computerSnapshotSchema.omit({
|
|
52
|
+
screenshot: true,
|
|
53
|
+
});
|
|
54
|
+
export const computerActionSchema = z.discriminatedUnion("type", [
|
|
55
|
+
z.object({ type: z.literal("move"), x: z.number(), y: z.number() }),
|
|
56
|
+
z.object({
|
|
57
|
+
type: z.literal("click"),
|
|
58
|
+
x: z.number().optional(),
|
|
59
|
+
y: z.number().optional(),
|
|
60
|
+
elementId: z.number().int().optional(),
|
|
61
|
+
}),
|
|
62
|
+
z.object({
|
|
63
|
+
type: z.literal("double_click"),
|
|
64
|
+
x: z.number().optional(),
|
|
65
|
+
y: z.number().optional(),
|
|
66
|
+
elementId: z.number().int().optional(),
|
|
67
|
+
}),
|
|
68
|
+
z.object({
|
|
69
|
+
type: z.literal("right_click"),
|
|
70
|
+
x: z.number().optional(),
|
|
71
|
+
y: z.number().optional(),
|
|
72
|
+
elementId: z.number().int().optional(),
|
|
73
|
+
}),
|
|
74
|
+
z.object({
|
|
75
|
+
type: z.literal("drag"),
|
|
76
|
+
from: z.object({ x: z.number(), y: z.number() }),
|
|
77
|
+
to: z.object({ x: z.number(), y: z.number() }),
|
|
78
|
+
durationMs: z.number().int().min(0).max(10_000).optional(),
|
|
79
|
+
}),
|
|
80
|
+
z.object({
|
|
81
|
+
type: z.literal("scroll"),
|
|
82
|
+
deltaX: z.number().optional(),
|
|
83
|
+
deltaY: z.number(),
|
|
84
|
+
elementId: z.number().int().optional(),
|
|
85
|
+
}),
|
|
86
|
+
z.object({
|
|
87
|
+
type: z.literal("keypress"),
|
|
88
|
+
keys: z.array(z.string().min(1)).min(1).max(8),
|
|
89
|
+
}),
|
|
90
|
+
z.object({
|
|
91
|
+
type: z.literal("type_text"),
|
|
92
|
+
text: z.string().max(100_000),
|
|
93
|
+
elementId: z.number().int().optional(),
|
|
94
|
+
}),
|
|
95
|
+
z.object({ type: z.literal("invoke"), elementId: z.number().int() }),
|
|
96
|
+
z.object({
|
|
97
|
+
type: z.literal("set_value"),
|
|
98
|
+
elementId: z.number().int(),
|
|
99
|
+
value: z.string().max(100_000),
|
|
100
|
+
}),
|
|
101
|
+
z.object({
|
|
102
|
+
type: z.literal("select_text"),
|
|
103
|
+
elementId: z.number().int(),
|
|
104
|
+
start: z.number().int().min(0),
|
|
105
|
+
length: z.number().int().min(0),
|
|
106
|
+
}),
|
|
107
|
+
z.object({ type: z.literal("activate_app"), app: z.string().min(1) }),
|
|
108
|
+
z.object({ type: z.literal("activate_window"), elementId: z.number().int() }),
|
|
109
|
+
z.object({
|
|
110
|
+
type: z.literal("move_window"),
|
|
111
|
+
elementId: z.number().int(),
|
|
112
|
+
x: z.number(),
|
|
113
|
+
y: z.number(),
|
|
114
|
+
}),
|
|
115
|
+
z.object({
|
|
116
|
+
type: z.literal("resize_window"),
|
|
117
|
+
elementId: z.number().int(),
|
|
118
|
+
width: z.number().positive(),
|
|
119
|
+
height: z.number().positive(),
|
|
120
|
+
}),
|
|
121
|
+
z.object({
|
|
122
|
+
type: z.literal("wait"),
|
|
123
|
+
ms: z.number().int().min(0).max(30_000),
|
|
124
|
+
}),
|
|
125
|
+
]);
|
|
126
|
+
export const computerActionResultSchema = z.object({
|
|
127
|
+
success: z.literal(true),
|
|
128
|
+
revision: z.number().int(),
|
|
129
|
+
snapshot: computerSnapshotSchema.optional(),
|
|
130
|
+
executionMode: z.enum(["semantic", "background", "foreground", "mixed"]),
|
|
131
|
+
focusChanged: z.boolean(),
|
|
132
|
+
});
|
|
133
|
+
export const computerActionMetadataSchema = computerActionResultSchema.extend({
|
|
134
|
+
snapshot: computerSnapshotMetadataSchema.optional(),
|
|
135
|
+
});
|
|
136
|
+
export const computerSnapshotTargetSchema = z.discriminatedUnion("type", [
|
|
137
|
+
z.object({ type: z.literal("desktop") }),
|
|
138
|
+
z.object({
|
|
139
|
+
type: z.literal("display"),
|
|
140
|
+
displayId: z.string().optional(),
|
|
141
|
+
}),
|
|
142
|
+
z.object({ type: z.literal("app"), app: z.string().min(1) }),
|
|
143
|
+
z.object({ type: z.literal("window"), elementId: z.number().int() }),
|
|
144
|
+
z.object({
|
|
145
|
+
type: z.literal("region"),
|
|
146
|
+
displayId: z.string().optional(),
|
|
147
|
+
x: z.number(),
|
|
148
|
+
y: z.number(),
|
|
149
|
+
width: z.number().positive(),
|
|
150
|
+
height: z.number().positive(),
|
|
151
|
+
}),
|
|
152
|
+
]);
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { RuntimeEventBus } from "../../app/event-bus.js";
|
|
2
|
+
import type { ComputerSettingsRepository } from "./computer-settings-repository.js";
|
|
3
|
+
import type { ComputerAccessScope, ComputerActionRequest, ComputerActionResult, ComputerBackend, ComputerPermission, ComputerSettings, ComputerSnapshot, ComputerSnapshotRequest, ComputerStatus } from "./types.js";
|
|
4
|
+
type ComputerSettingsStore = Pick<ComputerSettingsRepository, "get" | "set">;
|
|
5
|
+
export declare class ComputerService {
|
|
6
|
+
private readonly backend;
|
|
7
|
+
private readonly settingsRepository;
|
|
8
|
+
private readonly events;
|
|
9
|
+
private revision;
|
|
10
|
+
private currentSnapshotId;
|
|
11
|
+
private latestSnapshotValue;
|
|
12
|
+
private queue;
|
|
13
|
+
constructor(backend: ComputerBackend, settingsRepository: ComputerSettingsStore, events: RuntimeEventBus);
|
|
14
|
+
settings(): ComputerSettings;
|
|
15
|
+
latestSnapshot(scope: ComputerAccessScope): ComputerSnapshot | null;
|
|
16
|
+
requestPermission(permission: ComputerPermission): Promise<ComputerStatus>;
|
|
17
|
+
status(): Promise<ComputerStatus>;
|
|
18
|
+
setSettings(patch: Partial<Pick<ComputerSettings, "enabled" | "remoteAccess">>): ComputerSettings;
|
|
19
|
+
snapshot(scope: ComputerAccessScope, request: ComputerSnapshotRequest): Promise<ComputerSnapshot>;
|
|
20
|
+
action(scope: ComputerAccessScope, request: ComputerActionRequest): Promise<ComputerActionResult>;
|
|
21
|
+
shutdown(): Promise<void>;
|
|
22
|
+
private assertActionBudget;
|
|
23
|
+
private assertAllowed;
|
|
24
|
+
private assertScopeAllowed;
|
|
25
|
+
private serial;
|
|
26
|
+
}
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { ChatRoomError } from "../../core/errors/chatroom-error.js";
|
|
3
|
+
export class ComputerService {
|
|
4
|
+
backend;
|
|
5
|
+
settingsRepository;
|
|
6
|
+
events;
|
|
7
|
+
revision = 0;
|
|
8
|
+
currentSnapshotId = null;
|
|
9
|
+
latestSnapshotValue = null;
|
|
10
|
+
queue = Promise.resolve();
|
|
11
|
+
constructor(backend, settingsRepository, events) {
|
|
12
|
+
this.backend = backend;
|
|
13
|
+
this.settingsRepository = settingsRepository;
|
|
14
|
+
this.events = events;
|
|
15
|
+
}
|
|
16
|
+
settings() {
|
|
17
|
+
return this.settingsRepository.get();
|
|
18
|
+
}
|
|
19
|
+
latestSnapshot(scope) {
|
|
20
|
+
const settings = this.settings();
|
|
21
|
+
if (!settings.enabled)
|
|
22
|
+
return null;
|
|
23
|
+
this.assertScopeAllowed(scope, settings);
|
|
24
|
+
return this.latestSnapshotValue;
|
|
25
|
+
}
|
|
26
|
+
requestPermission(permission) {
|
|
27
|
+
return this.serial(async () => {
|
|
28
|
+
const base = await this.backend.requestPermission(permission);
|
|
29
|
+
return { ...base, settings: this.settings() };
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
async status() {
|
|
33
|
+
const base = await this.backend.status();
|
|
34
|
+
return { ...base, settings: this.settings() };
|
|
35
|
+
}
|
|
36
|
+
setSettings(patch) {
|
|
37
|
+
const next = this.settingsRepository.set({ ...this.settings(), ...patch });
|
|
38
|
+
if (!next.enabled) {
|
|
39
|
+
this.currentSnapshotId = null;
|
|
40
|
+
this.latestSnapshotValue = null;
|
|
41
|
+
void this.backend.dispose().catch(() => undefined);
|
|
42
|
+
}
|
|
43
|
+
this.events.emit({ type: "computer-settings", settings: next });
|
|
44
|
+
return next;
|
|
45
|
+
}
|
|
46
|
+
snapshot(scope, request) {
|
|
47
|
+
return this.serial(async () => {
|
|
48
|
+
this.assertAllowed(scope);
|
|
49
|
+
this.currentSnapshotId = null;
|
|
50
|
+
const value = await this.backend.snapshot(request, this.revision);
|
|
51
|
+
this.currentSnapshotId = value.snapshotId || `snap_${randomUUID()}`;
|
|
52
|
+
value.snapshotId = this.currentSnapshotId;
|
|
53
|
+
value.revision = this.revision;
|
|
54
|
+
this.latestSnapshotValue = value;
|
|
55
|
+
return value;
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
action(scope, request) {
|
|
59
|
+
return this.serial(async () => {
|
|
60
|
+
this.assertAllowed(scope);
|
|
61
|
+
this.assertActionBudget(request);
|
|
62
|
+
const referencesElements = request.actions.some((action) => "elementId" in action && action.elementId !== undefined);
|
|
63
|
+
if (referencesElements && !request.snapshotId)
|
|
64
|
+
throw new ChatRoomError("CONFLICT", "Actions using elementId require the latest snapshotId");
|
|
65
|
+
if (request.snapshotId && request.snapshotId !== this.currentSnapshotId)
|
|
66
|
+
throw new ChatRoomError("CONFLICT", "Computer snapshot is stale; take a new snapshot before acting");
|
|
67
|
+
this.currentSnapshotId = null;
|
|
68
|
+
const result = await this.backend.action(request, ++this.revision);
|
|
69
|
+
this.currentSnapshotId = result.snapshot?.snapshotId ?? null;
|
|
70
|
+
if (result.snapshot)
|
|
71
|
+
this.latestSnapshotValue = result.snapshot;
|
|
72
|
+
return result;
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
async shutdown() {
|
|
76
|
+
this.currentSnapshotId = null;
|
|
77
|
+
this.latestSnapshotValue = null;
|
|
78
|
+
await this.backend.dispose();
|
|
79
|
+
}
|
|
80
|
+
assertActionBudget(request) {
|
|
81
|
+
const durationMs = request.actions.reduce((total, action) => {
|
|
82
|
+
if (action.type === "wait")
|
|
83
|
+
return total + action.ms;
|
|
84
|
+
if (action.type === "drag")
|
|
85
|
+
return total + (action.durationMs ?? 0);
|
|
86
|
+
return total;
|
|
87
|
+
}, 0);
|
|
88
|
+
if (durationMs > 30_000)
|
|
89
|
+
throw new ChatRoomError("INVALID_INPUT", "Computer action batch exceeds the 30 second execution budget");
|
|
90
|
+
}
|
|
91
|
+
assertAllowed(scope) {
|
|
92
|
+
const settings = this.settings();
|
|
93
|
+
if (!settings.enabled)
|
|
94
|
+
throw new ChatRoomError("FORBIDDEN", "Computer Use is disabled");
|
|
95
|
+
this.assertScopeAllowed(scope, settings);
|
|
96
|
+
}
|
|
97
|
+
assertScopeAllowed(scope, settings) {
|
|
98
|
+
if (scope === "remote" && !settings.remoteAccess)
|
|
99
|
+
throw new ChatRoomError("FORBIDDEN", "Remote Computer Use is disabled", {
|
|
100
|
+
reason: "remote_computer_disabled",
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
serial(action) {
|
|
104
|
+
const next = this.queue.then(action, action);
|
|
105
|
+
this.queue = next.then(() => undefined, () => undefined);
|
|
106
|
+
return next;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { AppDatabase } from "../../infrastructure/database/app-database.js";
|
|
2
|
+
import type { ComputerSettings } from "./types.js";
|
|
3
|
+
export declare class ComputerSettingsRepository {
|
|
4
|
+
private readonly database;
|
|
5
|
+
constructor(database: AppDatabase);
|
|
6
|
+
get(): ComputerSettings;
|
|
7
|
+
set(value: Omit<ComputerSettings, "updatedAt"> | ComputerSettings): ComputerSettings;
|
|
8
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export class ComputerSettingsRepository {
|
|
2
|
+
database;
|
|
3
|
+
constructor(database) {
|
|
4
|
+
this.database = database;
|
|
5
|
+
}
|
|
6
|
+
get() {
|
|
7
|
+
const row = this.database.raw
|
|
8
|
+
.prepare("SELECT enabled, remote_access, updated_at FROM computer_settings WHERE id = 1")
|
|
9
|
+
.get();
|
|
10
|
+
if (row)
|
|
11
|
+
return fromRow(row);
|
|
12
|
+
const value = {
|
|
13
|
+
enabled: false,
|
|
14
|
+
remoteAccess: true,
|
|
15
|
+
updatedAt: new Date().toISOString(),
|
|
16
|
+
};
|
|
17
|
+
this.set(value);
|
|
18
|
+
return value;
|
|
19
|
+
}
|
|
20
|
+
set(value) {
|
|
21
|
+
const updatedAt = new Date().toISOString();
|
|
22
|
+
this.database.raw
|
|
23
|
+
.prepare(`
|
|
24
|
+
INSERT INTO computer_settings(id, enabled, remote_access, updated_at)
|
|
25
|
+
VALUES(1, ?, ?, ?)
|
|
26
|
+
ON CONFLICT(id) DO UPDATE SET
|
|
27
|
+
enabled = excluded.enabled,
|
|
28
|
+
remote_access = excluded.remote_access,
|
|
29
|
+
updated_at = excluded.updated_at
|
|
30
|
+
`)
|
|
31
|
+
.run(value.enabled ? 1 : 0, value.remoteAccess ? 1 : 0, updatedAt);
|
|
32
|
+
return { ...value, updatedAt };
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function fromRow(row) {
|
|
36
|
+
return {
|
|
37
|
+
enabled: Boolean(row.enabled),
|
|
38
|
+
remoteAccess: Boolean(row.remote_access),
|
|
39
|
+
updatedAt: String(row.updated_at),
|
|
40
|
+
};
|
|
41
|
+
}
|