@stim-cli/server 1.10.1 → 1.12.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/README.md +247 -27
- package/dist/protocol-BElQc2vm.mjs +808 -0
- package/dist/protocol.d.mts +286 -11
- package/dist/protocol.mjs +2 -2
- package/dist/protocol.schema.json +1004 -148
- package/dist/stim-frames/EmulatorDiscovery.swift +49 -0
- package/dist/stim-frames/EmulatorInput.swift +141 -0
- package/dist/stim-frames/EmulatorPosture.swift +73 -0
- package/dist/stim-frames/EmulatorRotation.swift +59 -0
- package/dist/stim-frames/GrpcFraming.swift +85 -0
- package/dist/stim-frames/InputMessages.swift +123 -0
- package/dist/stim-frames/ScreenshotMessages.swift +152 -0
- package/dist/stim-frames/ScreenshotStream.swift +130 -0
- package/dist/stim-frames/SimulatorDisplay.swift +116 -0
- package/dist/stim-frames/SimulatorHID.swift +336 -0
- package/dist/stim-frames/SimulatorRotation.swift +64 -0
- package/dist/stim-frames/VideoEncoder.swift +282 -0
- package/dist/stim-frames/main.swift +623 -0
- package/dist/stim-frames/sim-fold.entitlements +8 -0
- package/dist/stim-frames/sim-fold.m +47 -0
- package/dist/stim-server.mjs +2135 -208
- package/package.json +4 -4
- package/dist/protocol-B3k9Ykuu.mjs +0 -407
|
@@ -0,0 +1,808 @@
|
|
|
1
|
+
//#region src/protocol.ts
|
|
2
|
+
const PROTOCOL_VERSION = 1;
|
|
3
|
+
const PROTOCOL_SCHEMA_FILE = "protocol.schema.json";
|
|
4
|
+
/** `read` serves state. `control` also runs {@link ACTIONS}; only the Mac grants it. */
|
|
5
|
+
const CAPABILITIES = ["read", "control"];
|
|
6
|
+
const METHODS = [
|
|
7
|
+
"hello",
|
|
8
|
+
"status.subscribe",
|
|
9
|
+
"logs.query",
|
|
10
|
+
"logs.subscribe",
|
|
11
|
+
"stats.get",
|
|
12
|
+
"settings.get",
|
|
13
|
+
"frames.subscribe",
|
|
14
|
+
"frames.keyframe",
|
|
15
|
+
"build.plan",
|
|
16
|
+
"machine.get",
|
|
17
|
+
"machine.history",
|
|
18
|
+
"unsubscribe",
|
|
19
|
+
"action",
|
|
20
|
+
"control.begin",
|
|
21
|
+
"control.end",
|
|
22
|
+
"input.touch",
|
|
23
|
+
"input.text",
|
|
24
|
+
"input.button",
|
|
25
|
+
"input.rotate",
|
|
26
|
+
"input.posture"
|
|
27
|
+
];
|
|
28
|
+
/**
|
|
29
|
+
* `unauthorized`, `pairing-expired` and `protocol-unsupported` refuse the client until it pairs again or
|
|
30
|
+
* updates; clients retry the others.
|
|
31
|
+
*/
|
|
32
|
+
const ERROR_CODES = [
|
|
33
|
+
"unauthorized",
|
|
34
|
+
"pairing-expired",
|
|
35
|
+
"protocol-unsupported",
|
|
36
|
+
"identity-unavailable",
|
|
37
|
+
"bad-request",
|
|
38
|
+
"unknown-method",
|
|
39
|
+
"already-authenticated",
|
|
40
|
+
"unknown-subscription",
|
|
41
|
+
"unknown-workspace",
|
|
42
|
+
"limit-exceeded",
|
|
43
|
+
"slow-client",
|
|
44
|
+
"status-failed",
|
|
45
|
+
"logs-failed",
|
|
46
|
+
"stim-failed",
|
|
47
|
+
"frames-failed",
|
|
48
|
+
"forbidden",
|
|
49
|
+
"unknown-action",
|
|
50
|
+
"action-busy",
|
|
51
|
+
"action-failed",
|
|
52
|
+
"device-busy",
|
|
53
|
+
"unknown-session"
|
|
54
|
+
];
|
|
55
|
+
const LOG_SOURCES = [
|
|
56
|
+
"metro",
|
|
57
|
+
"client",
|
|
58
|
+
"device",
|
|
59
|
+
"build",
|
|
60
|
+
"agent"
|
|
61
|
+
];
|
|
62
|
+
const LOG_LEVELS = [
|
|
63
|
+
"debug",
|
|
64
|
+
"info",
|
|
65
|
+
"warn",
|
|
66
|
+
"error",
|
|
67
|
+
"fatal"
|
|
68
|
+
];
|
|
69
|
+
const MAX_LOG_TAIL = 5e3;
|
|
70
|
+
const FRAME_FPS = {
|
|
71
|
+
default: 5,
|
|
72
|
+
max: 30,
|
|
73
|
+
video: 60
|
|
74
|
+
};
|
|
75
|
+
const FRAME_EDGE = {
|
|
76
|
+
min: 240,
|
|
77
|
+
default: 1280,
|
|
78
|
+
max: 2048
|
|
79
|
+
};
|
|
80
|
+
const VIDEO_CODECS = ["h264"];
|
|
81
|
+
const VIDEO_HEADER_VERSION = 1;
|
|
82
|
+
/** The keyframe bit of a {@link VideoPacket}'s flags. */
|
|
83
|
+
const VIDEO_KEYFRAME = 1;
|
|
84
|
+
/** Each action runs one fixed `stim` command in the workspace. */
|
|
85
|
+
const ACTIONS = ["reload", "stop"];
|
|
86
|
+
const TOUCH_PHASES = [
|
|
87
|
+
"down",
|
|
88
|
+
"move",
|
|
89
|
+
"up"
|
|
90
|
+
];
|
|
91
|
+
const MAX_INPUT_TEXT = 256;
|
|
92
|
+
/** `home` and `lock` on both platforms; `back` and `app-switch` on Android only. */
|
|
93
|
+
const INPUT_BUTTONS = [
|
|
94
|
+
"home",
|
|
95
|
+
"lock",
|
|
96
|
+
"back",
|
|
97
|
+
"app-switch"
|
|
98
|
+
];
|
|
99
|
+
/** `left` turns the device a quarter turn counterclockwise, `right` clockwise. */
|
|
100
|
+
const ROTATE_DIRECTIONS = ["left", "right"];
|
|
101
|
+
const DEVICE_POSTURES = [
|
|
102
|
+
"folded",
|
|
103
|
+
"half-open",
|
|
104
|
+
"unfolded"
|
|
105
|
+
];
|
|
106
|
+
const CONTROL_END_REASONS = [
|
|
107
|
+
"idle",
|
|
108
|
+
"taken-over",
|
|
109
|
+
"device-gone",
|
|
110
|
+
"forbidden",
|
|
111
|
+
"failed"
|
|
112
|
+
];
|
|
113
|
+
const requestId = { type: ["integer", "string"] };
|
|
114
|
+
const protocolError = {
|
|
115
|
+
type: "object",
|
|
116
|
+
required: ["code", "message"],
|
|
117
|
+
additionalProperties: false,
|
|
118
|
+
properties: {
|
|
119
|
+
code: { enum: [...ERROR_CODES] },
|
|
120
|
+
message: { type: "string" }
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
function request(method, params) {
|
|
124
|
+
return {
|
|
125
|
+
type: "object",
|
|
126
|
+
required: params ? [
|
|
127
|
+
"id",
|
|
128
|
+
"method",
|
|
129
|
+
"params"
|
|
130
|
+
] : ["id", "method"],
|
|
131
|
+
additionalProperties: false,
|
|
132
|
+
properties: {
|
|
133
|
+
id: requestId,
|
|
134
|
+
method: { const: method },
|
|
135
|
+
params: params ?? {
|
|
136
|
+
type: "object",
|
|
137
|
+
maxProperties: 0
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
function session(properties, required = []) {
|
|
143
|
+
return {
|
|
144
|
+
type: "object",
|
|
145
|
+
required: ["session", ...required],
|
|
146
|
+
additionalProperties: false,
|
|
147
|
+
properties: {
|
|
148
|
+
session: { type: "string" },
|
|
149
|
+
...properties
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
function optionalParams(method, params) {
|
|
154
|
+
return {
|
|
155
|
+
type: "object",
|
|
156
|
+
required: ["id", "method"],
|
|
157
|
+
additionalProperties: false,
|
|
158
|
+
properties: {
|
|
159
|
+
id: requestId,
|
|
160
|
+
method: { const: method },
|
|
161
|
+
params
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
/** The JSON Schema of every message on the wire, written to `dist/protocol.schema.json` at build time. */
|
|
166
|
+
function protocolJsonSchema() {
|
|
167
|
+
return {
|
|
168
|
+
$schema: "https://json-schema.org/draft/2020-12/schema",
|
|
169
|
+
title: "Stim server protocol",
|
|
170
|
+
description: `Messages exchanged over the stim-server WebSocket, protocol version 1.`,
|
|
171
|
+
"x-stim-protocol": 1,
|
|
172
|
+
$defs: {
|
|
173
|
+
ProtocolError: protocolError,
|
|
174
|
+
HelloParams: {
|
|
175
|
+
type: "object",
|
|
176
|
+
required: [
|
|
177
|
+
"protocol",
|
|
178
|
+
"client",
|
|
179
|
+
"auth"
|
|
180
|
+
],
|
|
181
|
+
additionalProperties: false,
|
|
182
|
+
properties: {
|
|
183
|
+
protocol: { type: "integer" },
|
|
184
|
+
client: {
|
|
185
|
+
type: "object",
|
|
186
|
+
required: ["name", "version"],
|
|
187
|
+
properties: {
|
|
188
|
+
name: { type: "string" },
|
|
189
|
+
version: { type: "string" }
|
|
190
|
+
}
|
|
191
|
+
},
|
|
192
|
+
auth: { oneOf: [{
|
|
193
|
+
type: "object",
|
|
194
|
+
required: ["pairingToken", "deviceName"],
|
|
195
|
+
additionalProperties: false,
|
|
196
|
+
properties: {
|
|
197
|
+
pairingToken: { type: "string" },
|
|
198
|
+
deviceName: {
|
|
199
|
+
type: "string",
|
|
200
|
+
minLength: 1
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}, {
|
|
204
|
+
type: "object",
|
|
205
|
+
required: ["deviceToken"],
|
|
206
|
+
additionalProperties: false,
|
|
207
|
+
properties: { deviceToken: { type: "string" } }
|
|
208
|
+
}] }
|
|
209
|
+
}
|
|
210
|
+
},
|
|
211
|
+
HelloResult: {
|
|
212
|
+
type: "object",
|
|
213
|
+
required: [
|
|
214
|
+
"protocol",
|
|
215
|
+
"server",
|
|
216
|
+
"capabilities",
|
|
217
|
+
"actions",
|
|
218
|
+
"device"
|
|
219
|
+
],
|
|
220
|
+
additionalProperties: false,
|
|
221
|
+
properties: {
|
|
222
|
+
protocol: { type: "integer" },
|
|
223
|
+
server: {
|
|
224
|
+
type: "object",
|
|
225
|
+
required: [
|
|
226
|
+
"name",
|
|
227
|
+
"version",
|
|
228
|
+
"stim",
|
|
229
|
+
"home"
|
|
230
|
+
],
|
|
231
|
+
additionalProperties: false,
|
|
232
|
+
properties: {
|
|
233
|
+
name: { type: "string" },
|
|
234
|
+
version: { type: "string" },
|
|
235
|
+
stim: { type: "string" },
|
|
236
|
+
home: { type: "string" }
|
|
237
|
+
}
|
|
238
|
+
},
|
|
239
|
+
capabilities: {
|
|
240
|
+
type: "array",
|
|
241
|
+
items: { enum: [...CAPABILITIES] }
|
|
242
|
+
},
|
|
243
|
+
actions: {
|
|
244
|
+
type: "array",
|
|
245
|
+
items: { enum: [...ACTIONS] }
|
|
246
|
+
},
|
|
247
|
+
device: {
|
|
248
|
+
type: "object",
|
|
249
|
+
required: ["id", "name"],
|
|
250
|
+
additionalProperties: false,
|
|
251
|
+
properties: {
|
|
252
|
+
id: { type: "string" },
|
|
253
|
+
name: { type: "string" }
|
|
254
|
+
}
|
|
255
|
+
},
|
|
256
|
+
deviceToken: { type: "string" }
|
|
257
|
+
}
|
|
258
|
+
},
|
|
259
|
+
LogRecord: {
|
|
260
|
+
type: "object",
|
|
261
|
+
description: "One record as `stim logs --json` prints it.",
|
|
262
|
+
properties: {
|
|
263
|
+
ts: { type: "number" },
|
|
264
|
+
src: { type: "string" },
|
|
265
|
+
level: { type: "string" },
|
|
266
|
+
msg: { type: "string" }
|
|
267
|
+
}
|
|
268
|
+
},
|
|
269
|
+
LogFilter: {
|
|
270
|
+
type: "object",
|
|
271
|
+
required: ["workspace"],
|
|
272
|
+
additionalProperties: false,
|
|
273
|
+
properties: {
|
|
274
|
+
workspace: {
|
|
275
|
+
type: "string",
|
|
276
|
+
description: "An environment path from a status payload."
|
|
277
|
+
},
|
|
278
|
+
sources: {
|
|
279
|
+
type: "array",
|
|
280
|
+
minItems: 1,
|
|
281
|
+
items: { enum: [...LOG_SOURCES] }
|
|
282
|
+
},
|
|
283
|
+
level: { enum: [...LOG_LEVELS] },
|
|
284
|
+
slot: {
|
|
285
|
+
type: "string",
|
|
286
|
+
pattern: "^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$"
|
|
287
|
+
},
|
|
288
|
+
grep: {
|
|
289
|
+
type: "string",
|
|
290
|
+
pattern: "^[^\\u0000]*$",
|
|
291
|
+
description: "A regular expression matched against each message."
|
|
292
|
+
},
|
|
293
|
+
errors: { type: "boolean" },
|
|
294
|
+
tail: {
|
|
295
|
+
type: "integer",
|
|
296
|
+
minimum: 1,
|
|
297
|
+
maximum: MAX_LOG_TAIL,
|
|
298
|
+
default: MAX_LOG_TAIL
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
},
|
|
302
|
+
FrameTarget: {
|
|
303
|
+
type: "object",
|
|
304
|
+
required: ["workspace", "platform"],
|
|
305
|
+
additionalProperties: false,
|
|
306
|
+
properties: {
|
|
307
|
+
workspace: {
|
|
308
|
+
type: "string",
|
|
309
|
+
description: "An environment path from a status payload."
|
|
310
|
+
},
|
|
311
|
+
platform: { enum: ["ios", "android"] },
|
|
312
|
+
slot: {
|
|
313
|
+
type: "string",
|
|
314
|
+
minLength: 1,
|
|
315
|
+
default: "default"
|
|
316
|
+
},
|
|
317
|
+
fps: {
|
|
318
|
+
type: "integer",
|
|
319
|
+
minimum: 1,
|
|
320
|
+
maximum: FRAME_FPS.video,
|
|
321
|
+
default: FRAME_FPS.default,
|
|
322
|
+
description: `At most ${FRAME_FPS.max} unless the result offers video.`
|
|
323
|
+
},
|
|
324
|
+
maxEdge: {
|
|
325
|
+
type: "integer",
|
|
326
|
+
minimum: FRAME_EDGE.min,
|
|
327
|
+
maximum: FRAME_EDGE.max,
|
|
328
|
+
default: FRAME_EDGE.default
|
|
329
|
+
},
|
|
330
|
+
video: {
|
|
331
|
+
type: "array",
|
|
332
|
+
items: { enum: [...VIDEO_CODECS] }
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
},
|
|
336
|
+
ActionParams: { oneOf: [{
|
|
337
|
+
type: "object",
|
|
338
|
+
required: ["action", "workspace"],
|
|
339
|
+
additionalProperties: false,
|
|
340
|
+
properties: {
|
|
341
|
+
action: { const: "reload" },
|
|
342
|
+
workspace: {
|
|
343
|
+
type: "string",
|
|
344
|
+
description: "An environment path from a status payload."
|
|
345
|
+
},
|
|
346
|
+
platform: { enum: ["ios", "android"] }
|
|
347
|
+
}
|
|
348
|
+
}, {
|
|
349
|
+
type: "object",
|
|
350
|
+
required: ["action", "workspace"],
|
|
351
|
+
additionalProperties: false,
|
|
352
|
+
properties: {
|
|
353
|
+
action: { const: "stop" },
|
|
354
|
+
workspace: {
|
|
355
|
+
type: "string",
|
|
356
|
+
description: "An environment path from a status payload."
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
}] },
|
|
360
|
+
ActionResult: {
|
|
361
|
+
type: "object",
|
|
362
|
+
required: [
|
|
363
|
+
"action",
|
|
364
|
+
"workspace",
|
|
365
|
+
"output"
|
|
366
|
+
],
|
|
367
|
+
additionalProperties: false,
|
|
368
|
+
properties: {
|
|
369
|
+
action: { enum: [...ACTIONS] },
|
|
370
|
+
workspace: { type: "string" },
|
|
371
|
+
output: {
|
|
372
|
+
type: "object",
|
|
373
|
+
description: "The JSON the command printed."
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
},
|
|
377
|
+
ControlBeginParams: {
|
|
378
|
+
type: "object",
|
|
379
|
+
required: ["workspace", "platform"],
|
|
380
|
+
additionalProperties: false,
|
|
381
|
+
properties: {
|
|
382
|
+
workspace: {
|
|
383
|
+
type: "string",
|
|
384
|
+
description: "An environment path from a status payload."
|
|
385
|
+
},
|
|
386
|
+
platform: { enum: ["ios", "android"] },
|
|
387
|
+
slot: {
|
|
388
|
+
type: "string",
|
|
389
|
+
minLength: 1,
|
|
390
|
+
default: "default"
|
|
391
|
+
},
|
|
392
|
+
takeOver: {
|
|
393
|
+
type: "boolean",
|
|
394
|
+
default: false
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
},
|
|
398
|
+
ControlBeginResult: {
|
|
399
|
+
type: "object",
|
|
400
|
+
required: [
|
|
401
|
+
"session",
|
|
402
|
+
"platform",
|
|
403
|
+
"lease",
|
|
404
|
+
"postures"
|
|
405
|
+
],
|
|
406
|
+
additionalProperties: false,
|
|
407
|
+
properties: {
|
|
408
|
+
session: { type: "string" },
|
|
409
|
+
platform: { enum: ["ios", "android"] },
|
|
410
|
+
lease: { oneOf: [{ type: "null" }, {
|
|
411
|
+
type: "object",
|
|
412
|
+
required: ["grantedAt", "expiresAt"],
|
|
413
|
+
additionalProperties: false,
|
|
414
|
+
properties: {
|
|
415
|
+
grantedAt: {
|
|
416
|
+
type: ["string", "null"],
|
|
417
|
+
format: "date-time"
|
|
418
|
+
},
|
|
419
|
+
expiresAt: {
|
|
420
|
+
type: "string",
|
|
421
|
+
format: "date-time"
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
}] },
|
|
425
|
+
postures: {
|
|
426
|
+
type: "array",
|
|
427
|
+
items: { enum: [...DEVICE_POSTURES] },
|
|
428
|
+
uniqueItems: true
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
},
|
|
432
|
+
BuildPlanParams: {
|
|
433
|
+
type: "object",
|
|
434
|
+
required: ["workspace", "platform"],
|
|
435
|
+
additionalProperties: false,
|
|
436
|
+
properties: {
|
|
437
|
+
workspace: {
|
|
438
|
+
type: "string",
|
|
439
|
+
description: "An environment path from a status payload."
|
|
440
|
+
},
|
|
441
|
+
platform: { enum: ["ios", "android"] },
|
|
442
|
+
slot: {
|
|
443
|
+
type: "string",
|
|
444
|
+
pattern: "^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$",
|
|
445
|
+
default: "default"
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
},
|
|
449
|
+
WorkspaceParams: {
|
|
450
|
+
type: "object",
|
|
451
|
+
additionalProperties: false,
|
|
452
|
+
properties: { workspace: {
|
|
453
|
+
type: "string",
|
|
454
|
+
description: "An environment path from a status payload."
|
|
455
|
+
} }
|
|
456
|
+
},
|
|
457
|
+
MachineHistory: {
|
|
458
|
+
type: "object",
|
|
459
|
+
required: ["intervalMs", "samples"],
|
|
460
|
+
additionalProperties: false,
|
|
461
|
+
properties: {
|
|
462
|
+
intervalMs: { type: "integer" },
|
|
463
|
+
samples: {
|
|
464
|
+
type: "array",
|
|
465
|
+
items: {
|
|
466
|
+
type: "object",
|
|
467
|
+
required: [
|
|
468
|
+
"at",
|
|
469
|
+
"cpu",
|
|
470
|
+
"memoryUsedBytes",
|
|
471
|
+
"memoryPressure",
|
|
472
|
+
"diskFreeBytes"
|
|
473
|
+
],
|
|
474
|
+
additionalProperties: false,
|
|
475
|
+
properties: {
|
|
476
|
+
at: { type: "integer" },
|
|
477
|
+
cpu: { type: ["number", "null"] },
|
|
478
|
+
memoryUsedBytes: { type: ["number", "null"] },
|
|
479
|
+
memoryPressure: { enum: [
|
|
480
|
+
0,
|
|
481
|
+
1,
|
|
482
|
+
2,
|
|
483
|
+
null
|
|
484
|
+
] },
|
|
485
|
+
diskFreeBytes: { type: ["number", "null"] }
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
},
|
|
491
|
+
MachineUsage: {
|
|
492
|
+
type: "object",
|
|
493
|
+
required: [
|
|
494
|
+
"volumes",
|
|
495
|
+
"memory",
|
|
496
|
+
"load",
|
|
497
|
+
"cpu",
|
|
498
|
+
"sampledAt"
|
|
499
|
+
],
|
|
500
|
+
additionalProperties: false,
|
|
501
|
+
properties: {
|
|
502
|
+
volumes: {
|
|
503
|
+
type: "array",
|
|
504
|
+
items: {
|
|
505
|
+
type: "object",
|
|
506
|
+
required: [
|
|
507
|
+
"mount",
|
|
508
|
+
"holds",
|
|
509
|
+
"freeBytes",
|
|
510
|
+
"totalBytes"
|
|
511
|
+
],
|
|
512
|
+
additionalProperties: false,
|
|
513
|
+
properties: {
|
|
514
|
+
mount: { type: "string" },
|
|
515
|
+
holds: {
|
|
516
|
+
type: "array",
|
|
517
|
+
items: { type: "string" }
|
|
518
|
+
},
|
|
519
|
+
freeBytes: { type: "number" },
|
|
520
|
+
totalBytes: { type: "number" }
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
},
|
|
524
|
+
memory: {
|
|
525
|
+
type: "object",
|
|
526
|
+
required: [
|
|
527
|
+
"totalBytes",
|
|
528
|
+
"usedBytes",
|
|
529
|
+
"pressure"
|
|
530
|
+
],
|
|
531
|
+
additionalProperties: false,
|
|
532
|
+
properties: {
|
|
533
|
+
totalBytes: { type: "number" },
|
|
534
|
+
usedBytes: { type: ["number", "null"] },
|
|
535
|
+
pressure: { enum: [
|
|
536
|
+
"normal",
|
|
537
|
+
"warning",
|
|
538
|
+
"critical",
|
|
539
|
+
null
|
|
540
|
+
] }
|
|
541
|
+
}
|
|
542
|
+
},
|
|
543
|
+
load: {
|
|
544
|
+
type: "object",
|
|
545
|
+
required: [
|
|
546
|
+
"avg1",
|
|
547
|
+
"avg5",
|
|
548
|
+
"avg15",
|
|
549
|
+
"cpus"
|
|
550
|
+
],
|
|
551
|
+
additionalProperties: false,
|
|
552
|
+
properties: {
|
|
553
|
+
avg1: { type: "number" },
|
|
554
|
+
avg5: { type: "number" },
|
|
555
|
+
avg15: { type: "number" },
|
|
556
|
+
cpus: { type: "integer" }
|
|
557
|
+
}
|
|
558
|
+
},
|
|
559
|
+
cpu: {
|
|
560
|
+
type: "object",
|
|
561
|
+
required: ["usage", "cores"],
|
|
562
|
+
additionalProperties: false,
|
|
563
|
+
properties: {
|
|
564
|
+
usage: { type: ["number", "null"] },
|
|
565
|
+
cores: { type: "integer" }
|
|
566
|
+
}
|
|
567
|
+
},
|
|
568
|
+
sampledAt: {
|
|
569
|
+
type: "string",
|
|
570
|
+
format: "date-time"
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
},
|
|
574
|
+
ClientRequest: { oneOf: [
|
|
575
|
+
request("hello", { $ref: "#/$defs/HelloParams" }),
|
|
576
|
+
request("status.subscribe"),
|
|
577
|
+
request("logs.query", { $ref: "#/$defs/LogFilter" }),
|
|
578
|
+
request("logs.subscribe", { $ref: "#/$defs/LogFilter" }),
|
|
579
|
+
request("frames.subscribe", { $ref: "#/$defs/FrameTarget" }),
|
|
580
|
+
request("frames.keyframe", {
|
|
581
|
+
type: "object",
|
|
582
|
+
required: ["subscription"],
|
|
583
|
+
additionalProperties: false,
|
|
584
|
+
properties: { subscription: { type: "string" } }
|
|
585
|
+
}),
|
|
586
|
+
request("build.plan", { $ref: "#/$defs/BuildPlanParams" }),
|
|
587
|
+
request("machine.get"),
|
|
588
|
+
optionalParams("machine.history", {
|
|
589
|
+
type: "object",
|
|
590
|
+
additionalProperties: false,
|
|
591
|
+
properties: { sinceMs: { type: "number" } }
|
|
592
|
+
}),
|
|
593
|
+
optionalParams("stats.get", { $ref: "#/$defs/WorkspaceParams" }),
|
|
594
|
+
optionalParams("settings.get", { $ref: "#/$defs/WorkspaceParams" }),
|
|
595
|
+
request("unsubscribe", {
|
|
596
|
+
type: "object",
|
|
597
|
+
required: ["subscription"],
|
|
598
|
+
additionalProperties: false,
|
|
599
|
+
properties: { subscription: { type: "string" } }
|
|
600
|
+
}),
|
|
601
|
+
request("action", { $ref: "#/$defs/ActionParams" }),
|
|
602
|
+
request("control.begin", { $ref: "#/$defs/ControlBeginParams" }),
|
|
603
|
+
request("control.end", session({})),
|
|
604
|
+
request("input.touch", session({
|
|
605
|
+
phase: { enum: [...TOUCH_PHASES] },
|
|
606
|
+
x: {
|
|
607
|
+
type: "number",
|
|
608
|
+
minimum: 0,
|
|
609
|
+
maximum: 1
|
|
610
|
+
},
|
|
611
|
+
y: {
|
|
612
|
+
type: "number",
|
|
613
|
+
minimum: 0,
|
|
614
|
+
maximum: 1
|
|
615
|
+
},
|
|
616
|
+
display: {
|
|
617
|
+
type: "integer",
|
|
618
|
+
minimum: 0,
|
|
619
|
+
maximum: 3,
|
|
620
|
+
default: 0
|
|
621
|
+
}
|
|
622
|
+
}, [
|
|
623
|
+
"phase",
|
|
624
|
+
"x",
|
|
625
|
+
"y"
|
|
626
|
+
])),
|
|
627
|
+
request("input.text", session({ text: {
|
|
628
|
+
type: "string",
|
|
629
|
+
minLength: 1,
|
|
630
|
+
maxLength: 256,
|
|
631
|
+
pattern: "^[\\x20-\\x7e\\n\\t\\b]+$"
|
|
632
|
+
} }, ["text"])),
|
|
633
|
+
request("input.button", session({ button: { enum: [...INPUT_BUTTONS] } }, ["button"])),
|
|
634
|
+
request("input.rotate", session({ direction: { enum: [...ROTATE_DIRECTIONS] } }, ["direction"])),
|
|
635
|
+
request("input.posture", session({ posture: { enum: [...DEVICE_POSTURES] } }, ["posture"]))
|
|
636
|
+
] },
|
|
637
|
+
ServerResponse: { oneOf: [{
|
|
638
|
+
type: "object",
|
|
639
|
+
required: ["id", "result"],
|
|
640
|
+
additionalProperties: false,
|
|
641
|
+
properties: {
|
|
642
|
+
id: requestId,
|
|
643
|
+
result: { anyOf: [
|
|
644
|
+
{ $ref: "#/$defs/HelloResult" },
|
|
645
|
+
{ $ref: "#/$defs/ControlBeginResult" },
|
|
646
|
+
{ $ref: "#/$defs/ActionResult" },
|
|
647
|
+
{ $ref: "#/$defs/MachineUsage" },
|
|
648
|
+
{ $ref: "#/$defs/MachineHistory" },
|
|
649
|
+
{
|
|
650
|
+
type: "object",
|
|
651
|
+
required: ["subscription"],
|
|
652
|
+
additionalProperties: false,
|
|
653
|
+
properties: {
|
|
654
|
+
subscription: { type: "string" },
|
|
655
|
+
video: { enum: [...VIDEO_CODECS] }
|
|
656
|
+
}
|
|
657
|
+
},
|
|
658
|
+
{
|
|
659
|
+
type: "object",
|
|
660
|
+
required: ["records"],
|
|
661
|
+
additionalProperties: false,
|
|
662
|
+
properties: { records: {
|
|
663
|
+
type: "array",
|
|
664
|
+
items: { $ref: "#/$defs/LogRecord" }
|
|
665
|
+
} }
|
|
666
|
+
},
|
|
667
|
+
{
|
|
668
|
+
type: "object",
|
|
669
|
+
description: "The payload of `stim stats --json`, `stim settings --json` or `stim ios|android --plan --json`, or {} for unsubscribe."
|
|
670
|
+
}
|
|
671
|
+
] }
|
|
672
|
+
}
|
|
673
|
+
}, {
|
|
674
|
+
type: "object",
|
|
675
|
+
required: ["id", "error"],
|
|
676
|
+
additionalProperties: false,
|
|
677
|
+
properties: {
|
|
678
|
+
id: { type: [
|
|
679
|
+
"integer",
|
|
680
|
+
"string",
|
|
681
|
+
"null"
|
|
682
|
+
] },
|
|
683
|
+
error: { $ref: "#/$defs/ProtocolError" }
|
|
684
|
+
}
|
|
685
|
+
}] },
|
|
686
|
+
ServerEvent: { oneOf: [
|
|
687
|
+
{
|
|
688
|
+
type: "object",
|
|
689
|
+
required: [
|
|
690
|
+
"event",
|
|
691
|
+
"subscription",
|
|
692
|
+
"payload"
|
|
693
|
+
],
|
|
694
|
+
additionalProperties: false,
|
|
695
|
+
properties: {
|
|
696
|
+
event: { const: "status" },
|
|
697
|
+
subscription: { type: "string" },
|
|
698
|
+
payload: {
|
|
699
|
+
type: "object",
|
|
700
|
+
description: "A full payload, as `stim status --watch --json` prints it."
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
},
|
|
704
|
+
{
|
|
705
|
+
type: "object",
|
|
706
|
+
required: [
|
|
707
|
+
"event",
|
|
708
|
+
"subscription",
|
|
709
|
+
"records"
|
|
710
|
+
],
|
|
711
|
+
additionalProperties: false,
|
|
712
|
+
properties: {
|
|
713
|
+
event: { const: "logs" },
|
|
714
|
+
subscription: { type: "string" },
|
|
715
|
+
records: {
|
|
716
|
+
type: "array",
|
|
717
|
+
items: { $ref: "#/$defs/LogRecord" }
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
},
|
|
721
|
+
{
|
|
722
|
+
type: "object",
|
|
723
|
+
required: [
|
|
724
|
+
"event",
|
|
725
|
+
"subscription",
|
|
726
|
+
"platform",
|
|
727
|
+
"slot",
|
|
728
|
+
"mime",
|
|
729
|
+
"width",
|
|
730
|
+
"height",
|
|
731
|
+
"capturedAt",
|
|
732
|
+
"data"
|
|
733
|
+
],
|
|
734
|
+
additionalProperties: false,
|
|
735
|
+
properties: {
|
|
736
|
+
event: { const: "frame" },
|
|
737
|
+
subscription: { type: "string" },
|
|
738
|
+
platform: { enum: ["ios", "android"] },
|
|
739
|
+
slot: { type: "string" },
|
|
740
|
+
mime: { const: "image/jpeg" },
|
|
741
|
+
width: { type: "integer" },
|
|
742
|
+
height: { type: "integer" },
|
|
743
|
+
capturedAt: {
|
|
744
|
+
type: "string",
|
|
745
|
+
format: "date-time"
|
|
746
|
+
},
|
|
747
|
+
data: {
|
|
748
|
+
type: "string",
|
|
749
|
+
contentEncoding: "base64"
|
|
750
|
+
},
|
|
751
|
+
posture: { enum: ["folded", "unfolded"] }
|
|
752
|
+
}
|
|
753
|
+
},
|
|
754
|
+
{
|
|
755
|
+
type: "object",
|
|
756
|
+
required: [
|
|
757
|
+
"event",
|
|
758
|
+
"subscription",
|
|
759
|
+
"delayed"
|
|
760
|
+
],
|
|
761
|
+
additionalProperties: false,
|
|
762
|
+
properties: {
|
|
763
|
+
event: { const: "frame-delayed" },
|
|
764
|
+
subscription: { type: "string" },
|
|
765
|
+
delayed: { type: "boolean" }
|
|
766
|
+
}
|
|
767
|
+
},
|
|
768
|
+
{
|
|
769
|
+
type: "object",
|
|
770
|
+
required: [
|
|
771
|
+
"event",
|
|
772
|
+
"session",
|
|
773
|
+
"reason",
|
|
774
|
+
"message"
|
|
775
|
+
],
|
|
776
|
+
additionalProperties: false,
|
|
777
|
+
properties: {
|
|
778
|
+
event: { const: "control-ended" },
|
|
779
|
+
session: { type: "string" },
|
|
780
|
+
reason: { enum: [...CONTROL_END_REASONS] },
|
|
781
|
+
message: { type: "string" }
|
|
782
|
+
}
|
|
783
|
+
},
|
|
784
|
+
{
|
|
785
|
+
type: "object",
|
|
786
|
+
required: [
|
|
787
|
+
"event",
|
|
788
|
+
"subscription",
|
|
789
|
+
"error"
|
|
790
|
+
],
|
|
791
|
+
additionalProperties: false,
|
|
792
|
+
properties: {
|
|
793
|
+
event: { const: "error" },
|
|
794
|
+
subscription: { type: "string" },
|
|
795
|
+
error: { $ref: "#/$defs/ProtocolError" }
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
] }
|
|
799
|
+
},
|
|
800
|
+
oneOf: [
|
|
801
|
+
{ $ref: "#/$defs/ClientRequest" },
|
|
802
|
+
{ $ref: "#/$defs/ServerResponse" },
|
|
803
|
+
{ $ref: "#/$defs/ServerEvent" }
|
|
804
|
+
]
|
|
805
|
+
};
|
|
806
|
+
}
|
|
807
|
+
//#endregion
|
|
808
|
+
export { TOUCH_PHASES as _, ERROR_CODES as a, VIDEO_KEYFRAME as b, INPUT_BUTTONS as c, MAX_INPUT_TEXT as d, MAX_LOG_TAIL as f, ROTATE_DIRECTIONS as g, PROTOCOL_VERSION as h, DEVICE_POSTURES as i, LOG_LEVELS as l, PROTOCOL_SCHEMA_FILE as m, CAPABILITIES as n, FRAME_EDGE as o, METHODS as p, CONTROL_END_REASONS as r, FRAME_FPS as s, ACTIONS as t, LOG_SOURCES as u, VIDEO_CODECS as v, protocolJsonSchema as x, VIDEO_HEADER_VERSION as y };
|