@stim-cli/core 1.13.0 → 1.15.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 +15 -0
- package/dist/{core-CmZJEFj_.mjs → core-BwaxUjLX.mjs} +133 -5
- package/dist/index-DgLuTAvh.d.mts +1826 -0
- package/dist/index.d.mts +41 -1
- package/dist/index.mjs +2 -2
- package/dist/oversight.d.mts +308 -0
- package/dist/oversight.mjs +666 -0
- package/dist/ownership-claim-Xxxr9MPp.d.mts +152 -0
- package/dist/ownership-claim.d.mts +1 -151
- package/dist/phone-protocol.d.mts +434 -0
- package/dist/phone-protocol.mjs +2 -0
- package/dist/process-identity-BTyww2Xj.d.mts +37 -0
- package/dist/process-identity.d.mts +2 -30
- package/dist/process-identity.mjs +10 -2
- package/dist/protocol-BjnE921M.d.mts +1442 -0
- package/dist/protocol.d.mts +2 -0
- package/dist/protocol.mjs +372 -0
- package/dist/receive-protocol.d.mts +12 -0
- package/dist/receive-protocol.mjs +16563 -0
- package/dist/state.d.mts +2 -737
- package/dist/state.mjs +2738 -680
- package/package.json +21 -1
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { $ as FrameDelayedEvent, $n as VIDEO_CODECS, $t as NotificationSuppression, A as Capability, An as SERVER_UPDATE_METHODS, At as LogRecord, B as DeviceFrameArtwork, Bn as SettingsResult, Bt as MachineUpdateStatus, C as BuildRequestAuth, Cn as ReplayKeyframeParams, Ct as KeyframeParams, D as BuildToolchain, Dn as ReplayTarget, Dt as LegacyPushEvent, E as BuildSyncResult, En as ReplaySpan, Et as LOG_SOURCES, F as ControlEndedEvent, Fn as ServerUpdateOutcome, Ft as MAX_LOG_TAIL, G as DuoFramePose, Gn as SubscribeResult, Gt as MemoryPressure, H as DeviceHostRequestAuth, Hn as SimulatorOptions, Ht as MachineVolume, I as ControlPlatform, In as ServerUpdatePackage, It as METHODS, J as ErrorEvent, Jn as UnsubscribeParams, Jt as NOTIFICATION_LEVELS, K as ERROR_CODES, Kn as TOUCH_PHASES, Kt as Method, L as DEVICE_HOST_METHODS, Ln as ServerUpdateProgress, Lt as MachineDetails, M as ControlBeginParams, Mn as ServerEvent, Mt as LogsEvent, N as ControlBeginResult, Nn as ServerMessage, Nt as LogsQueryResult, O as CAPABILITIES, On as RequestId, Ot as LogFilter, P as ControlEndParams, Pn as ServerResponse, Pt as MAX_INPUT_TEXT, Q as Feature, Qn as VIDEO_ARTWORK, Qt as NotificationLevel, R as DEVICE_POSTURES, Rn as ServerUpdateStartParams, Rt as MachineHistory, S as BuildProgressEvent, Sn as ReplayKeyframe, St as KeyModifier, T as BuildSyncParams, Tn as ReplayRange, Tt as LOG_LEVELS, U as DevicePosture, Un as StatsResult, Ut as MacosWindow, V as DeviceFrameEvent, Vn as SimulatorCommand, Vt as MachineUsage, W as DeviceUsageSeries, Wn as StatusEvent, Wt as MacosWindowsEvent, X as FRAME_EDGE, Xn as UsageSample, Xt as NotificationEntry, Y as FEATURES, Yn as UsageHistory, Yt as NOTIFICATION_SUPPRESSIONS, Z as FRAME_FPS, Zn as UsageSeries, Zt as NotificationEvent, _ as BuildOfferParams, _n as ROTATE_DIRECTIONS, _t as InputSimulatorParams, a as BUILD_METHODS, an as PROTOCOL_VERSION, ar as VideoPacket, at as FramesSubscribeResult, b as BuildPlanResult, bn as ReloadPlatform, bt as InputWindowParams, c as BuildArtifactResult, cn as PairingAuth, cr as WorkspaceFiles, ct as INPUT_BUTTONS, d as BuildClientSummary, dn as PushEvent, dt as InputButtonParams, en as NotificationTarget, er as VIDEO_FOLDED, et as FrameEvent, f as BuildFile, fn as PushRegisterParams, ft as InputKey, g as BuildMachineReport, gn as REPLAY_RATES, gt as InputScrollParams, h as BuildMachineCapacity, hn as REPLAY_MARKER_KINDS, ht as InputRotateParams, i as ActionResult, in as PROTOCOL_SCHEMA_FILE, ir as VideoCodec, it as FramesSeekResult, j as ClientRequest, jn as ServeRoute, jt as LogSource, k as CONTROL_END_REASONS, kn as RotateDirection, kt as LogLevel, l as BuildAttachResult, ln as Platform, lr as WorkspaceParams, lt as INPUT_KEYS, m as BuildJobParams, mn as RELOAD_PLATFORMS, mt as InputPostureParams, n as ActionName, nn as NotificationsListResult, nr as VIDEO_KEYFRAME, nt as FramesLiveParams, o as BUILD_REPO_PATTERN, on as PUSH_EVENTS, or as WorkspaceDiff, ot as HelloParams, p as BuildJobOutcome, pn as QuietHours, pt as InputKeyParams, q as ErrorCode, qn as TouchPhase, qt as Methods, r as ActionParams, rn as PLATFORMS, rr as VIDEO_UNFOLDED, rt as FramesSeekParams, s as BuildAndroidOptions, sn as PUSH_TOKEN_PATTERN, sr as WorkspaceFile, st as HelloResult, t as ACTIONS, tn as NotificationsListParams, tr as VIDEO_HEADER_VERSION, tt as FrameTarget, u as BuildCapacity, un as ProtocolError, ur as WorkspacePatch, ut as InputButton, v as BuildOfferResult, vn as RecordingSetParams, vt as InputTextParams, w as BuildStartParams, wn as ReplayMarker, wt as LEGACY_PUSH_EVENTS, x as BuildPlatform, xn as ReplayEndedEvent, xt as KEY_MODIFIERS, y as BuildPlanParams, yn as RecordingSetResult, yt as InputTouchParams, z as DeviceAuth, zn as ServerUpdateStatus, zt as MachineHistoryParams } from "./protocol-BjnE921M.mjs";
|
|
2
|
+
export { ACTIONS, ActionName, ActionParams, ActionResult, BUILD_METHODS, BUILD_REPO_PATTERN, BuildAndroidOptions, BuildArtifactResult, BuildAttachResult, BuildCapacity, BuildClientSummary, BuildFile, BuildJobOutcome, BuildJobParams, BuildMachineCapacity, BuildMachineReport, BuildOfferParams, BuildOfferResult, BuildPlanParams, BuildPlanResult, BuildPlatform, BuildProgressEvent, BuildRequestAuth, BuildStartParams, BuildSyncParams, BuildSyncResult, BuildToolchain, CAPABILITIES, CONTROL_END_REASONS, Capability, ClientRequest, ControlBeginParams, ControlBeginResult, ControlEndParams, ControlEndedEvent, ControlPlatform, DEVICE_HOST_METHODS, DEVICE_POSTURES, DeviceAuth, DeviceFrameArtwork, DeviceFrameEvent, DeviceHostRequestAuth, DevicePosture, DeviceUsageSeries, DuoFramePose, ERROR_CODES, ErrorCode, ErrorEvent, FEATURES, FRAME_EDGE, FRAME_FPS, Feature, FrameDelayedEvent, FrameEvent, FrameTarget, FramesLiveParams, FramesSeekParams, FramesSeekResult, FramesSubscribeResult, HelloParams, HelloResult, INPUT_BUTTONS, INPUT_KEYS, InputButton, InputButtonParams, InputKey, InputKeyParams, InputPostureParams, InputRotateParams, InputScrollParams, InputSimulatorParams, InputTextParams, InputTouchParams, InputWindowParams, KEY_MODIFIERS, KeyModifier, KeyframeParams, LEGACY_PUSH_EVENTS, LOG_LEVELS, LOG_SOURCES, LegacyPushEvent, LogFilter, LogLevel, LogRecord, LogSource, LogsEvent, LogsQueryResult, MAX_INPUT_TEXT, MAX_LOG_TAIL, METHODS, MachineDetails, MachineHistory, MachineHistoryParams, MachineUpdateStatus, MachineUsage, MachineVolume, MacosWindow, MacosWindowsEvent, MemoryPressure, Method, Methods, NOTIFICATION_LEVELS, NOTIFICATION_SUPPRESSIONS, NotificationEntry, NotificationEvent, NotificationLevel, NotificationSuppression, NotificationTarget, NotificationsListParams, NotificationsListResult, PLATFORMS, PROTOCOL_SCHEMA_FILE, PROTOCOL_VERSION, PUSH_EVENTS, PUSH_TOKEN_PATTERN, PairingAuth, Platform, ProtocolError, PushEvent, PushRegisterParams, QuietHours, RELOAD_PLATFORMS, REPLAY_MARKER_KINDS, REPLAY_RATES, ROTATE_DIRECTIONS, RecordingSetParams, RecordingSetResult, ReloadPlatform, ReplayEndedEvent, ReplayKeyframe, ReplayKeyframeParams, ReplayMarker, ReplayRange, ReplaySpan, ReplayTarget, RequestId, RotateDirection, SERVER_UPDATE_METHODS, ServeRoute, ServerEvent, ServerMessage, ServerResponse, ServerUpdateOutcome, ServerUpdatePackage, ServerUpdateProgress, ServerUpdateStartParams, ServerUpdateStatus, SettingsResult, SimulatorCommand, SimulatorOptions, StatsResult, StatusEvent, SubscribeResult, TOUCH_PHASES, TouchPhase, UnsubscribeParams, UsageHistory, UsageSample, UsageSeries, VIDEO_ARTWORK, VIDEO_CODECS, VIDEO_FOLDED, VIDEO_HEADER_VERSION, VIDEO_KEYFRAME, VIDEO_UNFOLDED, VideoCodec, VideoPacket, WorkspaceDiff, WorkspaceFile, WorkspaceFiles, WorkspaceParams, WorkspacePatch };
|
|
@@ -0,0 +1,372 @@
|
|
|
1
|
+
//#region protocol.ts
|
|
2
|
+
const PROTOCOL_VERSION = 1;
|
|
3
|
+
const PROTOCOL_SCHEMA_FILE = "protocol.schema.json";
|
|
4
|
+
/**
|
|
5
|
+
* `read` serves state. `control` also runs {@link ACTIONS}; only the Mac grants it. `build` lets another Mac run
|
|
6
|
+
* project code here to build for it; it never comes with `read` or `control`, and only the Mac approves it.
|
|
7
|
+
* `device-host` permits a client's native app code in its own hosted sessions, and grants no other capability.
|
|
8
|
+
*/
|
|
9
|
+
const CAPABILITIES = [
|
|
10
|
+
"read",
|
|
11
|
+
"control",
|
|
12
|
+
"build",
|
|
13
|
+
"device-host"
|
|
14
|
+
];
|
|
15
|
+
/**
|
|
16
|
+
* What this server serves beyond protocol version 1's base, so a client can tell before it asks. `physical-ios` and
|
|
17
|
+
* `physical-android` are `physical: true` on `frames.subscribe` for that platform's leased device, and for an
|
|
18
|
+
* Android phone also on `control.begin`. An older server ignores `physical` on `frames.subscribe` and would stream
|
|
19
|
+
* the slot's Stim-owned device instead. `notifications` is `notifications.list` and the `notification` event.
|
|
20
|
+
* `macos-hosted` relays `frames.subscribe` and control for a workspace whose macOS app
|
|
21
|
+
* `stim macos --remote` placed on another Mac.
|
|
22
|
+
* `macos-windows` is the `macos-windows` event on a macOS `frames.subscribe`, naming the window capture follows
|
|
23
|
+
* and the app's other windows.
|
|
24
|
+
* `hosted-congestion` is `device-host.frames.congested`, which lowers the bitrate of a hosted video subscription
|
|
25
|
+
* whose client is behind.
|
|
26
|
+
* `macos-window-select` is `input.window`, which pins the view to a macOS app window named by `macos-windows`,
|
|
27
|
+
* bringing it to the front, or with null resumes following the front window.
|
|
28
|
+
* `server-update` is `server.update.status`, `server.update.start` and `server.update.chunk`.
|
|
29
|
+
*/
|
|
30
|
+
const FEATURES = [
|
|
31
|
+
"physical-ios",
|
|
32
|
+
"physical-android",
|
|
33
|
+
"notifications",
|
|
34
|
+
"macos-window",
|
|
35
|
+
"macos-windows",
|
|
36
|
+
"macos-window-select",
|
|
37
|
+
"macos-window-control",
|
|
38
|
+
"macos-keyboard-extended",
|
|
39
|
+
"device-frames",
|
|
40
|
+
"macos-hosted",
|
|
41
|
+
"duo-frames",
|
|
42
|
+
"workspace-diff",
|
|
43
|
+
"hosted-congestion",
|
|
44
|
+
"server-update"
|
|
45
|
+
];
|
|
46
|
+
const METHODS = [
|
|
47
|
+
"hello",
|
|
48
|
+
"route.setup",
|
|
49
|
+
"status.subscribe",
|
|
50
|
+
"logs.query",
|
|
51
|
+
"logs.subscribe",
|
|
52
|
+
"stats.get",
|
|
53
|
+
"settings.get",
|
|
54
|
+
"workspace.files",
|
|
55
|
+
"workspace.diff",
|
|
56
|
+
"frames.subscribe",
|
|
57
|
+
"frames.keyframe",
|
|
58
|
+
"frames.seek",
|
|
59
|
+
"frames.live",
|
|
60
|
+
"replay.range",
|
|
61
|
+
"replay.keyframe",
|
|
62
|
+
"recording.set",
|
|
63
|
+
"build.plan",
|
|
64
|
+
"machine.get",
|
|
65
|
+
"machine.history",
|
|
66
|
+
"machine.details",
|
|
67
|
+
"unsubscribe",
|
|
68
|
+
"action",
|
|
69
|
+
"control.begin",
|
|
70
|
+
"control.end",
|
|
71
|
+
"input.touch",
|
|
72
|
+
"input.text",
|
|
73
|
+
"input.button",
|
|
74
|
+
"input.rotate",
|
|
75
|
+
"input.posture",
|
|
76
|
+
"input.simulator",
|
|
77
|
+
"input.scroll",
|
|
78
|
+
"input.key",
|
|
79
|
+
"input.window",
|
|
80
|
+
"push.register",
|
|
81
|
+
"push.unregister",
|
|
82
|
+
"notifications.list",
|
|
83
|
+
"build.offer",
|
|
84
|
+
"build.sync",
|
|
85
|
+
"build.start",
|
|
86
|
+
"build.cancel",
|
|
87
|
+
"build.artifact",
|
|
88
|
+
"build.attach",
|
|
89
|
+
"device-host.offer",
|
|
90
|
+
"device-host.reserve",
|
|
91
|
+
"device-host.attach",
|
|
92
|
+
"device-host.stop",
|
|
93
|
+
"device-host.app.offer",
|
|
94
|
+
"device-host.app.chunk",
|
|
95
|
+
"device-host.app.handoff",
|
|
96
|
+
"device-host.app.launch",
|
|
97
|
+
"device-host.app.attach",
|
|
98
|
+
"device-host.logs.query",
|
|
99
|
+
"device-host.metro.open",
|
|
100
|
+
"device-host.metro.close",
|
|
101
|
+
"device-host.frames.subscribe",
|
|
102
|
+
"device-host.frames.keyframe",
|
|
103
|
+
"device-host.frames.congested",
|
|
104
|
+
"device-host.unsubscribe",
|
|
105
|
+
"device-host.control.begin",
|
|
106
|
+
"device-host.control.end",
|
|
107
|
+
"device-host.input.touch",
|
|
108
|
+
"device-host.input.text",
|
|
109
|
+
"device-host.input.scroll",
|
|
110
|
+
"device-host.input.key",
|
|
111
|
+
"device-host.input.button",
|
|
112
|
+
"device-host.input.rotate",
|
|
113
|
+
"device-host.input.posture",
|
|
114
|
+
"device-host.input.window",
|
|
115
|
+
"server.update.status",
|
|
116
|
+
"server.update.start",
|
|
117
|
+
"server.update.chunk",
|
|
118
|
+
"machines.update.start",
|
|
119
|
+
"machines.update.status"
|
|
120
|
+
];
|
|
121
|
+
/**
|
|
122
|
+
* The methods that update this server's `stim-server service`. A Mac this one approved for `build` or
|
|
123
|
+
* `device-host` may call them; they need neither `read` nor `control`.
|
|
124
|
+
*/
|
|
125
|
+
const SERVER_UPDATE_METHODS = [
|
|
126
|
+
"server.update.status",
|
|
127
|
+
"server.update.start",
|
|
128
|
+
"server.update.chunk"
|
|
129
|
+
];
|
|
130
|
+
/** The methods a connection with the `build` capability may call; they need `build`, not `read`. */
|
|
131
|
+
const BUILD_METHODS = [
|
|
132
|
+
"build.offer",
|
|
133
|
+
"build.sync",
|
|
134
|
+
"build.start",
|
|
135
|
+
"build.cancel",
|
|
136
|
+
"build.artifact",
|
|
137
|
+
"build.attach"
|
|
138
|
+
];
|
|
139
|
+
/** Methods restricted to explicitly approved device-host clients. */
|
|
140
|
+
const DEVICE_HOST_METHODS = [
|
|
141
|
+
"device-host.offer",
|
|
142
|
+
"device-host.reserve",
|
|
143
|
+
"device-host.attach",
|
|
144
|
+
"device-host.stop",
|
|
145
|
+
"device-host.app.offer",
|
|
146
|
+
"device-host.app.chunk",
|
|
147
|
+
"device-host.app.handoff",
|
|
148
|
+
"device-host.app.launch",
|
|
149
|
+
"device-host.app.attach",
|
|
150
|
+
"device-host.logs.query",
|
|
151
|
+
"device-host.metro.open",
|
|
152
|
+
"device-host.metro.close",
|
|
153
|
+
"device-host.frames.subscribe",
|
|
154
|
+
"device-host.frames.keyframe",
|
|
155
|
+
"device-host.frames.congested",
|
|
156
|
+
"device-host.unsubscribe",
|
|
157
|
+
"device-host.control.begin",
|
|
158
|
+
"device-host.control.end",
|
|
159
|
+
"device-host.input.touch",
|
|
160
|
+
"device-host.input.text",
|
|
161
|
+
"device-host.input.scroll",
|
|
162
|
+
"device-host.input.key",
|
|
163
|
+
"device-host.input.button",
|
|
164
|
+
"device-host.input.rotate",
|
|
165
|
+
"device-host.input.posture",
|
|
166
|
+
"device-host.input.window"
|
|
167
|
+
];
|
|
168
|
+
const PUSH_TOKEN_PATTERN = "^(Expo|Exponent)PushToken\\[[^\\]\\s]{1,256}\\]$";
|
|
169
|
+
/**
|
|
170
|
+
* `unauthorized`, `pairing-expired` and `protocol-unsupported` refuse the client until it pairs again or
|
|
171
|
+
* updates; `approval-pending` refuses a build client until the Mac approves it; clients retry the others.
|
|
172
|
+
*/
|
|
173
|
+
const ERROR_CODES = [
|
|
174
|
+
"unauthorized",
|
|
175
|
+
"pairing-expired",
|
|
176
|
+
"protocol-unsupported",
|
|
177
|
+
"approval-pending",
|
|
178
|
+
"identity-unavailable",
|
|
179
|
+
"bad-request",
|
|
180
|
+
"unknown-method",
|
|
181
|
+
"already-authenticated",
|
|
182
|
+
"unknown-subscription",
|
|
183
|
+
"unknown-workspace",
|
|
184
|
+
"limit-exceeded",
|
|
185
|
+
"slow-client",
|
|
186
|
+
"status-failed",
|
|
187
|
+
"logs-failed",
|
|
188
|
+
"stim-failed",
|
|
189
|
+
"frames-failed",
|
|
190
|
+
"forbidden",
|
|
191
|
+
"unknown-action",
|
|
192
|
+
"action-busy",
|
|
193
|
+
"action-failed",
|
|
194
|
+
"device-busy",
|
|
195
|
+
"unknown-session",
|
|
196
|
+
"no-recording",
|
|
197
|
+
"build-refused",
|
|
198
|
+
"build-busy"
|
|
199
|
+
];
|
|
200
|
+
const LOG_SOURCES = [
|
|
201
|
+
"metro",
|
|
202
|
+
"client",
|
|
203
|
+
"device",
|
|
204
|
+
"build",
|
|
205
|
+
"agent"
|
|
206
|
+
];
|
|
207
|
+
const LOG_LEVELS = [
|
|
208
|
+
"debug",
|
|
209
|
+
"info",
|
|
210
|
+
"warn",
|
|
211
|
+
"error",
|
|
212
|
+
"fatal"
|
|
213
|
+
];
|
|
214
|
+
const MAX_LOG_TAIL = 5e3;
|
|
215
|
+
/** `web` is the workspace's Stim-owned Chrome page, from `stim web`; it has only the default slot. */
|
|
216
|
+
const PLATFORMS = [
|
|
217
|
+
"ios",
|
|
218
|
+
"android",
|
|
219
|
+
"web",
|
|
220
|
+
"macos"
|
|
221
|
+
];
|
|
222
|
+
/** `reload` also reaches the workspace's Stim-owned Chrome page. */
|
|
223
|
+
const RELOAD_PLATFORMS = [
|
|
224
|
+
"ios",
|
|
225
|
+
"android",
|
|
226
|
+
"web"
|
|
227
|
+
];
|
|
228
|
+
const FRAME_FPS = {
|
|
229
|
+
default: 5,
|
|
230
|
+
max: 30,
|
|
231
|
+
video: 60
|
|
232
|
+
};
|
|
233
|
+
const FRAME_EDGE = {
|
|
234
|
+
min: 240,
|
|
235
|
+
default: 1280,
|
|
236
|
+
max: 2048
|
|
237
|
+
};
|
|
238
|
+
const VIDEO_CODECS = ["h264"];
|
|
239
|
+
const REPLAY_RATES = [
|
|
240
|
+
0,
|
|
241
|
+
1,
|
|
242
|
+
2
|
|
243
|
+
];
|
|
244
|
+
/** Kinds of timeline marker: an agent `action` on the device, an app or build `error`, and a `crash`. */
|
|
245
|
+
const REPLAY_MARKER_KINDS = [
|
|
246
|
+
"action",
|
|
247
|
+
"error",
|
|
248
|
+
"crash"
|
|
249
|
+
];
|
|
250
|
+
const VIDEO_HEADER_VERSION = 1;
|
|
251
|
+
/** The keyframe bit of a {@link VideoPacket}'s flags. */
|
|
252
|
+
const VIDEO_KEYFRAME = 1;
|
|
253
|
+
/** The flag bits of a {@link VideoPacket} that carry an iPhone Duo's posture, as `posture` on a `frame` event. */
|
|
254
|
+
const VIDEO_FOLDED = 2;
|
|
255
|
+
const VIDEO_UNFOLDED = 4;
|
|
256
|
+
/** Bit 5 marks clockwise artwork quarter-turns in bits 3-4; absent on recordings and unsupported sources. */
|
|
257
|
+
const VIDEO_ARTWORK = 32;
|
|
258
|
+
/** Each action runs one fixed `stim` command in the workspace. */
|
|
259
|
+
const ACTIONS = ["reload", "stop"];
|
|
260
|
+
const TOUCH_PHASES = [
|
|
261
|
+
"down",
|
|
262
|
+
"move",
|
|
263
|
+
"up"
|
|
264
|
+
];
|
|
265
|
+
const INPUT_KEYS = [
|
|
266
|
+
"escape",
|
|
267
|
+
"tab",
|
|
268
|
+
"return",
|
|
269
|
+
"backspace",
|
|
270
|
+
"left",
|
|
271
|
+
"right",
|
|
272
|
+
"up",
|
|
273
|
+
"down",
|
|
274
|
+
"a",
|
|
275
|
+
"b",
|
|
276
|
+
"c",
|
|
277
|
+
"d",
|
|
278
|
+
"e",
|
|
279
|
+
"f",
|
|
280
|
+
"g",
|
|
281
|
+
"h",
|
|
282
|
+
"i",
|
|
283
|
+
"j",
|
|
284
|
+
"k",
|
|
285
|
+
"l",
|
|
286
|
+
"m",
|
|
287
|
+
"n",
|
|
288
|
+
"o",
|
|
289
|
+
"p",
|
|
290
|
+
"q",
|
|
291
|
+
"r",
|
|
292
|
+
"s",
|
|
293
|
+
"t",
|
|
294
|
+
"u",
|
|
295
|
+
"v",
|
|
296
|
+
"w",
|
|
297
|
+
"x",
|
|
298
|
+
"y",
|
|
299
|
+
"z",
|
|
300
|
+
"0",
|
|
301
|
+
"1",
|
|
302
|
+
"2",
|
|
303
|
+
"3",
|
|
304
|
+
"4",
|
|
305
|
+
"5",
|
|
306
|
+
"6",
|
|
307
|
+
"7",
|
|
308
|
+
"8",
|
|
309
|
+
"9"
|
|
310
|
+
];
|
|
311
|
+
const KEY_MODIFIERS = [
|
|
312
|
+
"command",
|
|
313
|
+
"shift",
|
|
314
|
+
"option",
|
|
315
|
+
"control"
|
|
316
|
+
];
|
|
317
|
+
const MAX_INPUT_TEXT = 256;
|
|
318
|
+
/** `home` and `lock` on iOS and Android; `back` on Android and web, where it goes back in the page's history; `app-switch` on Android only. */
|
|
319
|
+
const INPUT_BUTTONS = [
|
|
320
|
+
"home",
|
|
321
|
+
"lock",
|
|
322
|
+
"back",
|
|
323
|
+
"app-switch"
|
|
324
|
+
];
|
|
325
|
+
/** `left` turns the device a quarter turn counterclockwise, `right` clockwise. */
|
|
326
|
+
const ROTATE_DIRECTIONS = ["left", "right"];
|
|
327
|
+
const DEVICE_POSTURES = [
|
|
328
|
+
"folded",
|
|
329
|
+
"half-open",
|
|
330
|
+
"unfolded"
|
|
331
|
+
];
|
|
332
|
+
/** A client's repository on a build machine: letters, digits, `.`, `_` and `-`, at most 80. */
|
|
333
|
+
const BUILD_REPO_PATTERN = "^[A-Za-z0-9][A-Za-z0-9._-]{0,79}$";
|
|
334
|
+
/**
|
|
335
|
+
* What stim-server can push, named like the phone's notification settings: work `started` (a workspace began
|
|
336
|
+
* warming or an agent first drove its device), an agent that looks `stuck`, one that is `looping` on the same
|
|
337
|
+
* failure, work `finished` (the agent stopped after a green build, or the workspace's pull request became ready for
|
|
338
|
+
* review or merged), a `machine` in trouble, and a `control` conflict over a device this phone controls.
|
|
339
|
+
*/
|
|
340
|
+
const PUSH_EVENTS = [
|
|
341
|
+
"started",
|
|
342
|
+
"stuck",
|
|
343
|
+
"looping",
|
|
344
|
+
"finished",
|
|
345
|
+
"machine",
|
|
346
|
+
"control",
|
|
347
|
+
"attention"
|
|
348
|
+
];
|
|
349
|
+
/** Events phones registered before `PUSH_EVENTS`: `disk` stands for `machine`, and the others no longer push. */
|
|
350
|
+
const LEGACY_PUSH_EVENTS = [
|
|
351
|
+
"build-failed",
|
|
352
|
+
"log-errors",
|
|
353
|
+
"disk",
|
|
354
|
+
"app-stopped",
|
|
355
|
+
"slow-build"
|
|
356
|
+
];
|
|
357
|
+
/**
|
|
358
|
+
* How a pushed event is delivered: `alert` with a banner and sound, `silent` to the notification list only (iOS
|
|
359
|
+
* `interruptionLevel` `passive`, the Android `updates` channel). An event the device leaves out of `events` is off.
|
|
360
|
+
*/
|
|
361
|
+
const NOTIFICATION_LEVELS = ["alert", "silent"];
|
|
362
|
+
/** Why the registered phones did not get a logged notification when it happened. */
|
|
363
|
+
const NOTIFICATION_SUPPRESSIONS = ["muted", "quiet-hours"];
|
|
364
|
+
const CONTROL_END_REASONS = [
|
|
365
|
+
"idle",
|
|
366
|
+
"taken-over",
|
|
367
|
+
"device-gone",
|
|
368
|
+
"forbidden",
|
|
369
|
+
"failed"
|
|
370
|
+
];
|
|
371
|
+
//#endregion
|
|
372
|
+
export { ACTIONS, BUILD_METHODS, BUILD_REPO_PATTERN, CAPABILITIES, CONTROL_END_REASONS, DEVICE_HOST_METHODS, DEVICE_POSTURES, ERROR_CODES, FEATURES, FRAME_EDGE, FRAME_FPS, INPUT_BUTTONS, INPUT_KEYS, KEY_MODIFIERS, LEGACY_PUSH_EVENTS, LOG_LEVELS, LOG_SOURCES, MAX_INPUT_TEXT, MAX_LOG_TAIL, METHODS, NOTIFICATION_LEVELS, NOTIFICATION_SUPPRESSIONS, PLATFORMS, PROTOCOL_SCHEMA_FILE, PROTOCOL_VERSION, PUSH_EVENTS, PUSH_TOKEN_PATTERN, RELOAD_PLATFORMS, REPLAY_MARKER_KINDS, REPLAY_RATES, ROTATE_DIRECTIONS, SERVER_UPDATE_METHODS, TOUCH_PHASES, VIDEO_ARTWORK, VIDEO_CODECS, VIDEO_FOLDED, VIDEO_HEADER_VERSION, VIDEO_KEYFRAME, VIDEO_UNFOLDED };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Method as PhoneMethod, Methods as PhoneMethods, PhoneProtocolError, PhoneServerEvent } from "./phone-protocol.mjs";
|
|
2
|
+
//#region receive-protocol.d.ts
|
|
3
|
+
/** Validates a result against the method of its pending request without changing the payload. */
|
|
4
|
+
declare function isRpcResult<M extends PhoneMethod>(method: M, value: unknown): value is PhoneMethods[M]["result"];
|
|
5
|
+
/** Validates a known phone event, including its nested payload. */
|
|
6
|
+
declare function isRpcEvent(value: unknown): value is PhoneServerEvent;
|
|
7
|
+
/** Accepts future error codes while requiring a usable code and message. */
|
|
8
|
+
declare function isRpcError(value: unknown): value is PhoneProtocolError;
|
|
9
|
+
/** Unknown future events can be ignored without reconnecting to a newer server. */
|
|
10
|
+
declare function isRpcEventName(value: string): boolean;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { isRpcError, isRpcEvent, isRpcEventName, isRpcResult };
|