@parcha/agentrun-kernel 0.1.0-beta.35 → 0.1.0-beta.37
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/CHANGELOG.md +45 -0
- package/README.md +0 -7
- package/dist/host/box.d.ts +0 -14
- package/dist/host/index.d.ts +1 -1
- package/dist/host/proxy.d.ts +20 -4
- package/dist/host/proxy.js +67 -5
- package/dist/index.d.ts +1 -3
- package/dist/index.js +0 -1
- package/dist/kernel/cap/index.d.ts +3 -3
- package/dist/kernel/cap/index.js +3 -3
- package/dist/kernel/cap/port.js +6 -3
- package/dist/kernel/cap/price.d.ts +6 -0
- package/dist/kernel/cap/price.js +14 -0
- package/dist/kernel/cap/rule.d.ts +8 -0
- package/dist/kernel/cap/rule.js +9 -0
- package/dist/kernel/cap/types.d.ts +2 -0
- package/dist/kernel/cap/words.d.ts +3 -0
- package/dist/kernel/cap/words.js +4 -1
- package/dist/kernel/index.d.ts +0 -2
- package/dist/kernel/index.js +0 -1
- package/dist/kernel/registry/computer-surface.generated.d.ts +9 -0
- package/dist/kernel/registry/computer-surface.generated.js +611 -0
- package/dist/kernel/registry/computer.d.ts +14 -0
- package/dist/kernel/registry/computer.js +67 -0
- package/dist/kernel/registry/defs.d.ts +1 -4
- package/dist/kernel/registry/defs.js +1 -13
- package/dist/kernel/registry/handoff.js +4 -4
- package/dist/kernel/registry/hands.d.ts +22 -115
- package/dist/kernel/registry/hands.js +0 -2
- package/dist/kernel/registry/index.d.ts +5 -5
- package/dist/kernel/registry/index.js +6 -6
- package/dist/kernel/registry/limits.d.ts +0 -1
- package/dist/kernel/registry/limits.js +0 -1
- package/dist/kernel/registry/registry.d.ts +4 -5
- package/dist/kernel/registry/registry.js +27 -29
- package/dist/kernel/types.d.ts +2 -1
- package/dist/process/records.d.ts +0 -16
- package/dist/process/records.js +0 -41
- package/dist/process/settle.d.ts +1 -1
- package/dist/process/settle.js +2 -2
- package/dist/process/tools.d.ts +3 -1
- package/dist/process/tools.js +3 -3
- package/dist/process/zod.d.ts +0 -2
- package/dist/process/zod.js +0 -4
- package/dist/run-booking.d.ts +3 -0
- package/dist/run-booking.js +7 -0
- package/dist/runner.d.ts +21 -2
- package/dist/runner.js +27 -10
- package/dist/testing.d.ts +9 -4
- package/dist/testing.js +22 -16
- package/dist/types.d.ts +18 -4
- package/package.json +2 -2
- package/dist/delegate.d.ts +0 -87
- package/dist/delegate.js +0 -143
- package/dist/kernel/follow-up.d.ts +0 -67
- package/dist/kernel/follow-up.js +0 -146
- package/dist/kernel/registry/desktop.d.ts +0 -11
- package/dist/kernel/registry/desktop.js +0 -90
- package/dist/kernel/registry/phone.d.ts +0 -15
- package/dist/kernel/registry/phone.js +0 -135
|
@@ -0,0 +1,611 @@
|
|
|
1
|
+
// Generated by scripts/generate-computer-surface.mjs from packages/computer/src/surface/api.ts and protocol.ts. Do not edit.
|
|
2
|
+
// The computer's per-step tools' schemas and the `computer` object's declarations, split by group.
|
|
3
|
+
/** Each per-step tool's parameters, as JSON Schema. */
|
|
4
|
+
export const COMPUTER_TOOL_SCHEMAS = {
|
|
5
|
+
"computer_observe": {
|
|
6
|
+
"type": "object",
|
|
7
|
+
"properties": {
|
|
8
|
+
"app": {
|
|
9
|
+
"description": "Default: the app in front.",
|
|
10
|
+
"type": "string"
|
|
11
|
+
},
|
|
12
|
+
"image": {
|
|
13
|
+
"description": "Add the window's picture (always, with no ui group).",
|
|
14
|
+
"type": "boolean"
|
|
15
|
+
},
|
|
16
|
+
"full": {
|
|
17
|
+
"description": "Every element, not only named or actionable ones.",
|
|
18
|
+
"type": "boolean"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"additionalProperties": false
|
|
22
|
+
},
|
|
23
|
+
"computer_act": {
|
|
24
|
+
"type": "object",
|
|
25
|
+
"properties": {
|
|
26
|
+
"app": {
|
|
27
|
+
"description": "Default: the state's app, else the app in front.",
|
|
28
|
+
"type": "string"
|
|
29
|
+
},
|
|
30
|
+
"state": {
|
|
31
|
+
"description": "The state a step's point was read from. Default: the last observed.",
|
|
32
|
+
"type": "string"
|
|
33
|
+
},
|
|
34
|
+
"steps": {
|
|
35
|
+
"description": "Run in order. Empty with an expect: only wait.",
|
|
36
|
+
"maxItems": 100,
|
|
37
|
+
"type": "array",
|
|
38
|
+
"items": {
|
|
39
|
+
"anyOf": [
|
|
40
|
+
{
|
|
41
|
+
"type": "object",
|
|
42
|
+
"properties": {
|
|
43
|
+
"press": {
|
|
44
|
+
"type": "string"
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
"additionalProperties": false,
|
|
48
|
+
"required": [
|
|
49
|
+
"press"
|
|
50
|
+
]
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
"type": "object",
|
|
54
|
+
"properties": {
|
|
55
|
+
"set": {
|
|
56
|
+
"type": "string"
|
|
57
|
+
},
|
|
58
|
+
"value": {
|
|
59
|
+
"type": "string"
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
"additionalProperties": false,
|
|
63
|
+
"required": [
|
|
64
|
+
"set",
|
|
65
|
+
"value"
|
|
66
|
+
]
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
"type": "object",
|
|
70
|
+
"properties": {
|
|
71
|
+
"perform": {
|
|
72
|
+
"type": "string"
|
|
73
|
+
},
|
|
74
|
+
"action": {
|
|
75
|
+
"type": "string"
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
"additionalProperties": false,
|
|
79
|
+
"required": [
|
|
80
|
+
"action",
|
|
81
|
+
"perform"
|
|
82
|
+
]
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
"type": "object",
|
|
86
|
+
"properties": {
|
|
87
|
+
"click": {
|
|
88
|
+
"anyOf": [
|
|
89
|
+
{
|
|
90
|
+
"type": "array",
|
|
91
|
+
"minItems": 2,
|
|
92
|
+
"maxItems": 2,
|
|
93
|
+
"items": {
|
|
94
|
+
"type": "number"
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
"type": "string"
|
|
99
|
+
}
|
|
100
|
+
]
|
|
101
|
+
},
|
|
102
|
+
"button": {
|
|
103
|
+
"enum": [
|
|
104
|
+
"left",
|
|
105
|
+
"right"
|
|
106
|
+
],
|
|
107
|
+
"type": "string"
|
|
108
|
+
},
|
|
109
|
+
"count": {
|
|
110
|
+
"enum": [
|
|
111
|
+
1,
|
|
112
|
+
2,
|
|
113
|
+
3
|
|
114
|
+
],
|
|
115
|
+
"type": "number"
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
"additionalProperties": false,
|
|
119
|
+
"required": [
|
|
120
|
+
"click"
|
|
121
|
+
]
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
"type": "object",
|
|
125
|
+
"properties": {
|
|
126
|
+
"type": {
|
|
127
|
+
"type": "string"
|
|
128
|
+
},
|
|
129
|
+
"into": {
|
|
130
|
+
"type": "string"
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
"additionalProperties": false,
|
|
134
|
+
"required": [
|
|
135
|
+
"type"
|
|
136
|
+
]
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
"type": "object",
|
|
140
|
+
"properties": {
|
|
141
|
+
"key": {
|
|
142
|
+
"type": "string"
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
"additionalProperties": false,
|
|
146
|
+
"required": [
|
|
147
|
+
"key"
|
|
148
|
+
]
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
"type": "object",
|
|
152
|
+
"properties": {
|
|
153
|
+
"nav": {
|
|
154
|
+
"enum": [
|
|
155
|
+
"app_switch",
|
|
156
|
+
"back",
|
|
157
|
+
"home"
|
|
158
|
+
],
|
|
159
|
+
"type": "string"
|
|
160
|
+
}
|
|
161
|
+
},
|
|
162
|
+
"additionalProperties": false,
|
|
163
|
+
"required": [
|
|
164
|
+
"nav"
|
|
165
|
+
]
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
"type": "object",
|
|
169
|
+
"properties": {
|
|
170
|
+
"scroll": {
|
|
171
|
+
"anyOf": [
|
|
172
|
+
{
|
|
173
|
+
"type": "array",
|
|
174
|
+
"minItems": 2,
|
|
175
|
+
"maxItems": 2,
|
|
176
|
+
"items": {
|
|
177
|
+
"type": "number"
|
|
178
|
+
}
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
"type": "string"
|
|
182
|
+
}
|
|
183
|
+
]
|
|
184
|
+
},
|
|
185
|
+
"dx": {
|
|
186
|
+
"type": "number"
|
|
187
|
+
},
|
|
188
|
+
"dy": {
|
|
189
|
+
"type": "number"
|
|
190
|
+
}
|
|
191
|
+
},
|
|
192
|
+
"additionalProperties": false,
|
|
193
|
+
"required": [
|
|
194
|
+
"scroll"
|
|
195
|
+
]
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
"type": "object",
|
|
199
|
+
"properties": {
|
|
200
|
+
"drag": {
|
|
201
|
+
"type": "array",
|
|
202
|
+
"items": {
|
|
203
|
+
"type": "array",
|
|
204
|
+
"minItems": 2,
|
|
205
|
+
"maxItems": 2,
|
|
206
|
+
"items": {
|
|
207
|
+
"type": "number"
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
},
|
|
211
|
+
"ms": {
|
|
212
|
+
"type": "number"
|
|
213
|
+
}
|
|
214
|
+
},
|
|
215
|
+
"additionalProperties": false,
|
|
216
|
+
"required": [
|
|
217
|
+
"drag"
|
|
218
|
+
]
|
|
219
|
+
}
|
|
220
|
+
]
|
|
221
|
+
}
|
|
222
|
+
},
|
|
223
|
+
"expect": {
|
|
224
|
+
"description": "Wait after the steps until a text shows (with ref: in that element; gone: until it is gone), at most timeoutMs.",
|
|
225
|
+
"type": "object",
|
|
226
|
+
"properties": {
|
|
227
|
+
"text": {
|
|
228
|
+
"type": "string"
|
|
229
|
+
},
|
|
230
|
+
"ref": {
|
|
231
|
+
"type": "string"
|
|
232
|
+
},
|
|
233
|
+
"window": {
|
|
234
|
+
"type": "object",
|
|
235
|
+
"properties": {
|
|
236
|
+
"title": {
|
|
237
|
+
"type": "string"
|
|
238
|
+
},
|
|
239
|
+
"role": {
|
|
240
|
+
"enum": [
|
|
241
|
+
"button",
|
|
242
|
+
"cell",
|
|
243
|
+
"checkbox",
|
|
244
|
+
"combobox",
|
|
245
|
+
"dialog",
|
|
246
|
+
"generic",
|
|
247
|
+
"group",
|
|
248
|
+
"heading",
|
|
249
|
+
"image",
|
|
250
|
+
"link",
|
|
251
|
+
"list",
|
|
252
|
+
"listitem",
|
|
253
|
+
"menu",
|
|
254
|
+
"menuitem",
|
|
255
|
+
"progressbar",
|
|
256
|
+
"radio",
|
|
257
|
+
"row",
|
|
258
|
+
"scrollarea",
|
|
259
|
+
"searchbox",
|
|
260
|
+
"slider",
|
|
261
|
+
"switch",
|
|
262
|
+
"tab",
|
|
263
|
+
"table",
|
|
264
|
+
"text",
|
|
265
|
+
"textbox",
|
|
266
|
+
"toolbar",
|
|
267
|
+
"window"
|
|
268
|
+
],
|
|
269
|
+
"type": "string"
|
|
270
|
+
}
|
|
271
|
+
},
|
|
272
|
+
"additionalProperties": false
|
|
273
|
+
},
|
|
274
|
+
"gone": {
|
|
275
|
+
"type": "boolean"
|
|
276
|
+
},
|
|
277
|
+
"timeoutMs": {
|
|
278
|
+
"type": "number"
|
|
279
|
+
}
|
|
280
|
+
},
|
|
281
|
+
"additionalProperties": false
|
|
282
|
+
},
|
|
283
|
+
"foreground": {
|
|
284
|
+
"description": "Allow moving the person's pointer and focus.",
|
|
285
|
+
"type": "boolean"
|
|
286
|
+
},
|
|
287
|
+
"observe": {
|
|
288
|
+
"description": "Return the new outline.",
|
|
289
|
+
"type": "boolean"
|
|
290
|
+
}
|
|
291
|
+
},
|
|
292
|
+
"additionalProperties": false,
|
|
293
|
+
"required": [
|
|
294
|
+
"steps"
|
|
295
|
+
]
|
|
296
|
+
},
|
|
297
|
+
"computer_screenshot": {
|
|
298
|
+
"type": "object",
|
|
299
|
+
"properties": {
|
|
300
|
+
"region": {
|
|
301
|
+
"description": "[x, y, w, h] in screen pixels.",
|
|
302
|
+
"type": "array",
|
|
303
|
+
"minItems": 4,
|
|
304
|
+
"maxItems": 4,
|
|
305
|
+
"items": {
|
|
306
|
+
"type": "number"
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
},
|
|
310
|
+
"additionalProperties": false
|
|
311
|
+
},
|
|
312
|
+
"computer_script": {
|
|
313
|
+
"type": "object",
|
|
314
|
+
"properties": {
|
|
315
|
+
"code": {
|
|
316
|
+
"description": "An async function's body; `return` what you need.",
|
|
317
|
+
"type": "string"
|
|
318
|
+
},
|
|
319
|
+
"title": {
|
|
320
|
+
"description": "For the run's timeline.",
|
|
321
|
+
"type": "string"
|
|
322
|
+
},
|
|
323
|
+
"timeoutMs": {
|
|
324
|
+
"description": "Default 120000, at most 600000.",
|
|
325
|
+
"type": "number"
|
|
326
|
+
}
|
|
327
|
+
},
|
|
328
|
+
"additionalProperties": false,
|
|
329
|
+
"required": [
|
|
330
|
+
"code"
|
|
331
|
+
]
|
|
332
|
+
}
|
|
333
|
+
};
|
|
334
|
+
/** computer_act's steps as TypeScript, for its description: its schema types them, with no words. */
|
|
335
|
+
export const ACT_STEPS = "type UiStep = { press: UiRef; } | { set: UiRef; value: string; } | { perform: UiRef; action: string; } | { click: UiRef | Point; button?: \"left\" | \"right\"; count?: 1 | 2 | 3; } | { type: string; into?: UiRef; } | { key: string; } | { nav: \"back\" | \"home\" | \"app_switch\"; } | { scroll: UiRef | Point; dx?: number; dy?: number; } | { drag: Point[]; ms?: number; }; type UiRef = string; type Point = [ x: number, y: number ];";
|
|
336
|
+
/** The types `computer` names, in order, each with the types it names, in the compact form a model reads: one line,
|
|
337
|
+
* no comments (spec/computer/computer.d.ts has them). */
|
|
338
|
+
const TYPES = [
|
|
339
|
+
{
|
|
340
|
+
"name": "ComputerKind",
|
|
341
|
+
"uses": [],
|
|
342
|
+
"text": "type ComputerKind = string;"
|
|
343
|
+
},
|
|
344
|
+
{
|
|
345
|
+
"name": "ComputerOs",
|
|
346
|
+
"uses": [],
|
|
347
|
+
"text": "type ComputerOs = string;"
|
|
348
|
+
},
|
|
349
|
+
{
|
|
350
|
+
"name": "ScreenSize",
|
|
351
|
+
"uses": [],
|
|
352
|
+
"text": "interface ScreenSize { width: number; height: number; scale: number; }"
|
|
353
|
+
},
|
|
354
|
+
{
|
|
355
|
+
"name": "FileType",
|
|
356
|
+
"uses": [],
|
|
357
|
+
"text": "type FileType = \"file\" | \"dir\" | \"symlink\" | \"other\";"
|
|
358
|
+
},
|
|
359
|
+
{
|
|
360
|
+
"name": "Point",
|
|
361
|
+
"uses": [],
|
|
362
|
+
"text": "type Point = [ x: number, y: number ];"
|
|
363
|
+
},
|
|
364
|
+
{
|
|
365
|
+
"name": "Rect",
|
|
366
|
+
"uses": [],
|
|
367
|
+
"text": "type Rect = [ x: number, y: number, w: number, h: number ];"
|
|
368
|
+
},
|
|
369
|
+
{
|
|
370
|
+
"name": "Button",
|
|
371
|
+
"uses": [],
|
|
372
|
+
"text": "type Button = \"left\" | \"right\" | \"middle\";"
|
|
373
|
+
},
|
|
374
|
+
{
|
|
375
|
+
"name": "Key",
|
|
376
|
+
"uses": [],
|
|
377
|
+
"text": "type Key = string;"
|
|
378
|
+
},
|
|
379
|
+
{
|
|
380
|
+
"name": "InputAction",
|
|
381
|
+
"uses": [
|
|
382
|
+
"Point",
|
|
383
|
+
"Button",
|
|
384
|
+
"Key"
|
|
385
|
+
],
|
|
386
|
+
"text": "type InputAction = { type: \"move\"; at: Point; } | { type: \"down\" | \"up\"; button?: Button; } | { type: \"click\"; at?: Point; button?: Button; count?: 1 | 2 | 3; keys?: Key[]; } | { type: \"drag\"; path: Point[]; button?: Button; keys?: Key[]; } | { type: \"scroll\"; at?: Point; dx?: number; dy?: number; unit: \"clicks\" | \"px\"; keys?: Key[]; } | { type: \"key\"; keys: Key[]; repeat?: number; } | { type: \"hold\"; keys: Key[]; ms: number; } | { type: \"type\"; text: string; } | { type: \"tap\"; at: Point; count?: 1 | 2; } | { type: \"long_press\"; at: Point; ms?: number; } | { type: \"swipe\"; path: Point[]; ms?: number; } | { type: \"pinch\"; at: Point; scale: number; ms?: number; } | { type: \"button\"; name: \"back\" | \"home\" | \"app_switch\"; } | { type: \"wait\"; ms: number; };"
|
|
387
|
+
},
|
|
388
|
+
{
|
|
389
|
+
"name": "UiRole",
|
|
390
|
+
"uses": [],
|
|
391
|
+
"text": "type UiRole = string;"
|
|
392
|
+
},
|
|
393
|
+
{
|
|
394
|
+
"name": "UiRef",
|
|
395
|
+
"uses": [],
|
|
396
|
+
"text": "type UiRef = string;"
|
|
397
|
+
},
|
|
398
|
+
{
|
|
399
|
+
"name": "UiFlag",
|
|
400
|
+
"uses": [],
|
|
401
|
+
"text": "type UiFlag = \"focused\" | \"disabled\" | \"selected\" | \"checked\" | \"secure\" | \"offscreen\";"
|
|
402
|
+
},
|
|
403
|
+
{
|
|
404
|
+
"name": "UiNode",
|
|
405
|
+
"uses": [
|
|
406
|
+
"UiRef",
|
|
407
|
+
"Rect",
|
|
408
|
+
"UiFlag"
|
|
409
|
+
],
|
|
410
|
+
"text": "interface UiNode { ref: UiRef; role: string; name?: string; value?: string; desc?: string; id?: string; bounds: Rect; parent?: UiRef; flags?: UiFlag[]; actions?: string[]; }"
|
|
411
|
+
},
|
|
412
|
+
{
|
|
413
|
+
"name": "UiRoute",
|
|
414
|
+
"uses": [],
|
|
415
|
+
"text": "type UiRoute = \"semantic\" | \"page\" | \"background\" | \"foreground\";"
|
|
416
|
+
},
|
|
417
|
+
{
|
|
418
|
+
"name": "UiStep",
|
|
419
|
+
"uses": [],
|
|
420
|
+
"text": "type UiStep = object; // computer_act's steps"
|
|
421
|
+
},
|
|
422
|
+
{
|
|
423
|
+
"name": "UiExpect",
|
|
424
|
+
"uses": [],
|
|
425
|
+
"text": "type UiExpect = object; // computer_act's expect"
|
|
426
|
+
},
|
|
427
|
+
{
|
|
428
|
+
"name": "Image",
|
|
429
|
+
"uses": [],
|
|
430
|
+
"text": "interface Image { type: \"image\"; mimeType: \"image/png\" | \"image/jpeg\"; data: string; width: number; height: number; }"
|
|
431
|
+
},
|
|
432
|
+
{
|
|
433
|
+
"name": "Card",
|
|
434
|
+
"uses": [
|
|
435
|
+
"ScreenSize"
|
|
436
|
+
],
|
|
437
|
+
"text": "interface Card { kind: string; os: string; osVersion?: string; arch: string; screen?: ScreenSize; groups: string[]; features: Record<string, true | { off: string; }>; }"
|
|
438
|
+
},
|
|
439
|
+
{
|
|
440
|
+
"name": "State",
|
|
441
|
+
"uses": [
|
|
442
|
+
"Rect",
|
|
443
|
+
"UiNode",
|
|
444
|
+
"Image"
|
|
445
|
+
],
|
|
446
|
+
"text": "interface State { id: string; app: { id: string; name: string; }; window: { id: string; title?: string; bounds: Rect; }; elements: UiNode[]; truncated: boolean; outline: string; image?: Image; }"
|
|
447
|
+
},
|
|
448
|
+
{
|
|
449
|
+
"name": "Route",
|
|
450
|
+
"uses": [
|
|
451
|
+
"UiRoute"
|
|
452
|
+
],
|
|
453
|
+
"text": "type Route = UiRoute | \"input\";"
|
|
454
|
+
},
|
|
455
|
+
{
|
|
456
|
+
"name": "StepResult",
|
|
457
|
+
"uses": [
|
|
458
|
+
"Route"
|
|
459
|
+
],
|
|
460
|
+
"text": "type StepResult = { route: Route; verified: boolean; } | { error: { kind: string; message: string; }; };"
|
|
461
|
+
},
|
|
462
|
+
{
|
|
463
|
+
"name": "ActResult",
|
|
464
|
+
"uses": [
|
|
465
|
+
"StepResult",
|
|
466
|
+
"State"
|
|
467
|
+
],
|
|
468
|
+
"text": "interface ActResult { steps: StepResult[]; expect?: \"met\" | \"unmet\"; changed?: boolean; state?: string; after?: State; }"
|
|
469
|
+
},
|
|
470
|
+
{
|
|
471
|
+
"name": "InputResult",
|
|
472
|
+
"uses": [
|
|
473
|
+
"StepResult"
|
|
474
|
+
],
|
|
475
|
+
"text": "interface InputResult { steps: StepResult[]; }"
|
|
476
|
+
},
|
|
477
|
+
{
|
|
478
|
+
"name": "ObserveOptions",
|
|
479
|
+
"uses": [],
|
|
480
|
+
"text": "interface ObserveOptions { image?: boolean; full?: boolean; }"
|
|
481
|
+
},
|
|
482
|
+
{
|
|
483
|
+
"name": "ActOptions",
|
|
484
|
+
"uses": [
|
|
485
|
+
"UiExpect",
|
|
486
|
+
"ObserveOptions"
|
|
487
|
+
],
|
|
488
|
+
"text": "interface ActOptions { state?: string; expect?: UiExpect; foreground?: boolean; observe?: boolean | ObserveOptions; }"
|
|
489
|
+
},
|
|
490
|
+
{
|
|
491
|
+
"name": "App",
|
|
492
|
+
"uses": [
|
|
493
|
+
"ObserveOptions",
|
|
494
|
+
"State",
|
|
495
|
+
"UiNode",
|
|
496
|
+
"UiStep",
|
|
497
|
+
"ActOptions",
|
|
498
|
+
"ActResult",
|
|
499
|
+
"UiRef",
|
|
500
|
+
"Point",
|
|
501
|
+
"UiExpect"
|
|
502
|
+
],
|
|
503
|
+
"text": "interface App { readonly id: string; observe(options?: ObserveOptions): Promise<State>; find(query: { role?: string; id?: string; text?: string | RegExp; }): UiNode[]; act(steps: UiStep[], options?: ActOptions): Promise<ActResult>; press(ref: UiRef, options?: ActOptions): Promise<ActResult>; set(ref: UiRef, value: string, options?: ActOptions): Promise<ActResult>; click(at: UiRef | Point, options?: ActOptions & { button?: \"left\" | \"right\"; count?: 1 | 2 | 3; }): Promise<ActResult>; type(text: string, options?: ActOptions & { into?: UiRef; }): Promise<ActResult>; key(chord: string, options?: ActOptions): Promise<ActResult>; scroll(at: UiRef | Point, delta: { dx?: number; dy?: number; }, options?: ActOptions): Promise<ActResult>; waitFor(expect: UiExpect): Promise<ActResult>; }"
|
|
504
|
+
},
|
|
505
|
+
{
|
|
506
|
+
"name": "AppInfo",
|
|
507
|
+
"uses": [],
|
|
508
|
+
"text": "interface AppInfo { id: string; name?: string; }"
|
|
509
|
+
},
|
|
510
|
+
{
|
|
511
|
+
"name": "RunResult",
|
|
512
|
+
"uses": [],
|
|
513
|
+
"text": "interface RunResult { stdout: string; stderr: string; exitCode: number | null; timedOut: boolean; truncated: boolean; }"
|
|
514
|
+
},
|
|
515
|
+
{
|
|
516
|
+
"name": "FileInfo",
|
|
517
|
+
"uses": [
|
|
518
|
+
"FileType"
|
|
519
|
+
],
|
|
520
|
+
"text": "interface FileInfo { path: string; type: FileType; size: number; mtimeMs: number; }"
|
|
521
|
+
}
|
|
522
|
+
];
|
|
523
|
+
/** Computer's members, each with the groups it needs one of and the types it names. */
|
|
524
|
+
const MEMBERS = [
|
|
525
|
+
{
|
|
526
|
+
"uses": [
|
|
527
|
+
"Card"
|
|
528
|
+
],
|
|
529
|
+
"text": "readonly card: Card;"
|
|
530
|
+
},
|
|
531
|
+
{
|
|
532
|
+
"groups": [
|
|
533
|
+
"apps"
|
|
534
|
+
],
|
|
535
|
+
"uses": [
|
|
536
|
+
"AppInfo"
|
|
537
|
+
],
|
|
538
|
+
"text": "readonly apps: { list(): Promise<{ apps: AppInfo[]; foreground: string | null; }>; open(id: string, options?: { url?: string; background?: boolean; }): Promise<void>; };"
|
|
539
|
+
},
|
|
540
|
+
{
|
|
541
|
+
"groups": [
|
|
542
|
+
"ui"
|
|
543
|
+
],
|
|
544
|
+
"uses": [
|
|
545
|
+
"App"
|
|
546
|
+
],
|
|
547
|
+
"text": "app(id?: string): App;"
|
|
548
|
+
},
|
|
549
|
+
{
|
|
550
|
+
"groups": [
|
|
551
|
+
"screen"
|
|
552
|
+
],
|
|
553
|
+
"uses": [
|
|
554
|
+
"Rect",
|
|
555
|
+
"Image"
|
|
556
|
+
],
|
|
557
|
+
"text": "readonly screen: { shot(options?: { region?: Rect; }): Promise<Image>; };"
|
|
558
|
+
},
|
|
559
|
+
{
|
|
560
|
+
"groups": [
|
|
561
|
+
"input.pointer",
|
|
562
|
+
"input.touch",
|
|
563
|
+
"input.keys"
|
|
564
|
+
],
|
|
565
|
+
"uses": [
|
|
566
|
+
"InputAction",
|
|
567
|
+
"InputResult"
|
|
568
|
+
],
|
|
569
|
+
"text": "readonly input: { act(actions: InputAction[]): Promise<InputResult>; };"
|
|
570
|
+
},
|
|
571
|
+
{
|
|
572
|
+
"groups": [
|
|
573
|
+
"exec"
|
|
574
|
+
],
|
|
575
|
+
"uses": [
|
|
576
|
+
"RunResult"
|
|
577
|
+
],
|
|
578
|
+
"text": "readonly shell: { run(command: string | string[], options?: { cwd?: string; timeoutMs?: number; env?: Record<string, string>; }): Promise<RunResult>; };"
|
|
579
|
+
},
|
|
580
|
+
{
|
|
581
|
+
"groups": [
|
|
582
|
+
"files"
|
|
583
|
+
],
|
|
584
|
+
"uses": [
|
|
585
|
+
"FileInfo"
|
|
586
|
+
],
|
|
587
|
+
"text": "readonly files: { read(path: string, options?: { encoding?: \"utf8\" | \"base64\"; }): Promise<string>; write(path: string, data: string, options?: { encoding?: \"utf8\" | \"base64\"; }): Promise<void>; list(path: string): Promise<FileInfo[]>; stat(path: string): Promise<FileInfo>; };"
|
|
588
|
+
}
|
|
589
|
+
];
|
|
590
|
+
/** The declarations a script on a computer with these groups reads: the types its members reach, Computer with only
|
|
591
|
+
* the members its groups offer, and `declare const computer`, one line each. */
|
|
592
|
+
export function computerDeclarations(groups) {
|
|
593
|
+
const members = MEMBERS.filter((member) => member.groups === undefined || member.groups.some((group) => groups.includes(group)));
|
|
594
|
+
const uses = new Map(TYPES.map((type) => [type.name, type.uses]));
|
|
595
|
+
const reached = new Set();
|
|
596
|
+
const visit = (name) => {
|
|
597
|
+
if (reached.has(name))
|
|
598
|
+
return;
|
|
599
|
+
reached.add(name);
|
|
600
|
+
for (const used of uses.get(name) ?? [])
|
|
601
|
+
visit(used);
|
|
602
|
+
};
|
|
603
|
+
for (const member of members)
|
|
604
|
+
for (const used of member.uses)
|
|
605
|
+
visit(used);
|
|
606
|
+
return [
|
|
607
|
+
...TYPES.filter((type) => reached.has(type.name)).map((type) => type.text),
|
|
608
|
+
`interface Computer { ${members.map((member) => member.text).join(" ")} }`,
|
|
609
|
+
"declare const computer: Computer;",
|
|
610
|
+
].join("\n");
|
|
611
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ToolDef } from "./defs.js";
|
|
2
|
+
import { type CapabilityKind, type Executor } from "./hands.js";
|
|
3
|
+
/** The computer's tools, in the order a run lists them (the hand-over last). */
|
|
4
|
+
export declare const COMPUTER_TOOLS: readonly ["computer_observe", "computer_act", "computer_screenshot", "computer_script", "computer_request_handoff"];
|
|
5
|
+
/** The tool a host runs itself: a script runs in the host's isolate, over the same port. */
|
|
6
|
+
export declare const SCRIPT_TOOL = "computer_script";
|
|
7
|
+
/** The tools a computer with `groups` offers: observe and act with the ui group, or a screen (observe) and input (act)
|
|
8
|
+
* without it; the screenshot with a screen; the script with any of them. */
|
|
9
|
+
export declare function computerToolsFor(groups: readonly string[]): readonly string[];
|
|
10
|
+
/** The computer's tools in `kind`, under its settings key, for a computer with `groups` (the script's declarations
|
|
11
|
+
* hold only what they offer). A script and an act change the computer: never replayed. */
|
|
12
|
+
export declare function computerToolDefs(kind: CapabilityKind, groups: readonly string[]): readonly ToolDef[];
|
|
13
|
+
/** The kernel's own executors of the computer's tools in `kind`: all but the script, which the host runs. */
|
|
14
|
+
export declare const computerExecutors: (kind: CapabilityKind) => Readonly<Record<string, Executor>>;
|