@xenon-device-management/xenon 2.13.1 → 2.14.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 +11 -5
- package/lib/package.json +1 -1
- package/lib/public/assets/{AnnotationOverlay-Cvpkk4r9.js → AnnotationOverlay-B_VNtKBH.js} +1 -1
- package/lib/public/assets/{ApiKeyGate-Bhn5ZtVM.js → ApiKeyGate-BwuaMjkX.js} +1 -1
- package/lib/public/assets/{BugReportButton-BA6aEjTC.js → BugReportButton-BAt0_pzq.js} +1 -1
- package/lib/public/assets/DeviceMosaicView-BYaQHhTf.js +2 -0
- package/lib/public/assets/{EmptyState-CgzbuUvO.js → EmptyState-BSjhk_IV.js} +1 -1
- package/lib/public/assets/{FieldGroup-BHc_5qNc.js → FieldGroup-Cb5QZsE1.js} +1 -1
- package/lib/public/assets/{FilterMenu-D7OMGuRc.js → FilterMenu-BAaSlWbW.js} +1 -1
- package/lib/public/assets/{Menu-C173JJ0l.js → Menu-JGGYrSQQ.js} +1 -1
- package/lib/public/assets/{Modal-ChvVUI3B.js → Modal-CFCp3n9d.js} +1 -1
- package/lib/public/assets/{RecordingPage-Dhw4d_O6.js → RecordingPage-CbJj_EBT.js} +1 -1
- package/lib/public/assets/{RecordingsPage-z97ftGK-.js → RecordingsPage-BJeYnygR.js} +2 -2
- package/lib/public/assets/{SegmentedControl-DbXhBGZC.js → SegmentedControl-Bg42Atjy.js} +1 -1
- package/lib/public/assets/{SettingCard-C908GgiI.js → SettingCard-Njz1pUIJ.js} +1 -1
- package/lib/public/assets/{Table-B1DB_ZN-.js → Table-BcTm5xV2.js} +1 -1
- package/lib/public/assets/{activity-Css0xNvp.js → activity-DOVdsfMQ.js} +1 -1
- package/lib/public/assets/{ai-settings-BMQK3-yN.js → ai-settings-CsuJroRf.js} +2 -2
- package/lib/public/assets/{api-keys-CbJ42eDQ.js → api-keys-BKnNSTw9.js} +1 -1
- package/lib/public/assets/{apps-DW1pw2re.js → apps-D0SC6uw6.js} +2 -2
- package/lib/public/assets/{arrow-left-Dpog9L0F.js → arrow-left-MMbTmgoE.js} +1 -1
- package/lib/public/assets/{arrow-right-CsBIlSIw.js → arrow-right-BMfnGmxW.js} +1 -1
- package/lib/public/assets/{arrow-up-right-z1tRQE4R.js → arrow-up-right-DuAftMWB.js} +1 -1
- package/lib/public/assets/{auth-shell-mXiX5vNk.js → auth-shell-nZC2JNDO.js} +2 -2
- package/lib/public/assets/{builds-page-BcFn23bE.js → builds-page-hDCgTwkS.js} +1 -1
- package/lib/public/assets/{button-Cq_zHETv.js → button-Dda4irn_.js} +1 -1
- package/lib/public/assets/{calendar-CKxABX9q.js → calendar-BMr0Q62v.js} +1 -1
- package/lib/public/assets/{check-C7xu-hGU.js → check-CZ9iw9-e.js} +1 -1
- package/lib/public/assets/{chevron-right-BiqfdCGA.js → chevron-right-BRYJJVC9.js} +1 -1
- package/lib/public/assets/{circle-check-CyBjjPxR.js → circle-check-CqAJjQ5O.js} +1 -1
- package/lib/public/assets/{circle-x-6gMRcx6z.js → circle-x-DlDJtnVz.js} +1 -1
- package/lib/public/assets/{clock-U1rDTT1h.js → clock-CpuDKysU.js} +1 -1
- package/lib/public/assets/{copy-BIM0ZX0L.js → copy-CAQydNFe.js} +1 -1
- package/lib/public/assets/device-explorer-CdO6_nrn.js +282 -0
- package/lib/public/assets/{download-DDBRXnAZ.js → download-C9XG6lLv.js} +1 -1
- package/lib/public/assets/{forgot-password-Dpg7yxM8.js → forgot-password-CGnkRgE9.js} +1 -1
- package/lib/public/assets/h264Stream-VQBphYhg.js +26 -0
- package/lib/public/assets/{index-BGBqohfQ.js → index-BbKEXUFH.js} +5 -5
- package/lib/public/assets/{index-BTYMAqNW.css → index-Bxoxt9sV.css} +1 -1
- package/lib/public/assets/{index-BQ2luT7L.js → index-DJGc1M2f.js} +1 -1
- package/lib/public/assets/{input-BvB1cjHE.js → input-Cm0tmSoc.js} +1 -1
- package/lib/public/assets/{line-chart-m78VggnW.js → line-chart-D2DyJCml.js} +1 -1
- package/lib/public/assets/{list-checks-cY7o1QTL.js → list-checks-UWf1GY99.js} +1 -1
- package/lib/public/assets/{lock-loz8txQm.js → lock-CCJv9m_I.js} +1 -1
- package/lib/public/assets/{login-BYOvz4lx.js → login-f8vOVW-U.js} +1 -1
- package/lib/public/assets/maintenance-settings-C1PrkuAH.js +6 -0
- package/lib/public/assets/{monitor-C4HPHb6s.js → monitor-B2jDgwm7.js} +1 -1
- package/lib/public/assets/{mouse-pointer-2-BkdKtCzi.js → mouse-pointer-2-DLI1RtzU.js} +1 -1
- package/lib/public/assets/{network-C5e0MIWo.js → network-ebT86qoi.js} +1 -1
- package/lib/public/assets/{overview-tlu8ijGd.js → overview-C0aykVrd.js} +1 -1
- package/lib/public/assets/{page-header-FXPlo6az.js → page-header-BjzgWz-T.js} +1 -1
- package/lib/public/assets/{play-CWdk0_Sy.js → play-DLG9t8FU.js} +1 -1
- package/lib/public/assets/{plus-B2xCnntV.js → plus-nBFSMu_X.js} +1 -1
- package/lib/public/assets/{profile-page-D080qzr4.js → profile-page-CSl0UYlv.js} +1 -1
- package/lib/public/assets/{reset-password-D3u4Mbvn.js → reset-password-LeOuHqmB.js} +1 -1
- package/lib/public/assets/{runbook-page-hPRZMy7s.js → runbook-page-CMMeQml9.js} +1 -1
- package/lib/public/assets/{select-12RThAXc.js → select-88jHcl-Z.js} +1 -1
- package/lib/public/assets/{selector-detail-redirect-uQwvV7EQ.js → selector-detail-redirect-BbXKJjZM.js} +1 -1
- package/lib/public/assets/{selector-health-page-CThoxDFO.js → selector-health-page-B4rA1Xkv.js} +2 -2
- package/lib/public/assets/session-detail-page-COL_RZxw.js +4 -0
- package/lib/public/assets/settings-GF6ZMSQ6.js +6 -0
- package/lib/public/assets/{stat-tile-B02WEte8.js → stat-tile-BV98e_Sv.js} +1 -1
- package/lib/public/assets/{tablet-Dj30VGZl.js → tablet-BiAsnFDj.js} +1 -1
- package/lib/public/assets/{teams-uL4fjTDR.js → teams-B4-jrr-1.js} +1 -1
- package/lib/public/assets/{trash-2-B54e-TfY.js → trash-2-C5RSuX0e.js} +1 -1
- package/lib/public/assets/{upload-B3k8WCSP.js → upload-BG7_rMXK.js} +1 -1
- package/lib/public/assets/{use-builds-data-BFn90NH3.js → use-builds-data-J-riQYyC.js} +1 -1
- package/lib/public/assets/{use-password-reset-mode-DL2TmWZ0.js → use-password-reset-mode-C8-eH-UG.js} +1 -1
- package/lib/public/assets/{users-CqBuxMlX.js → users-CFba5TSy.js} +1 -1
- package/lib/public/assets/{users-DjQSucKb.js → users-Cp0beJm3.js} +1 -1
- package/lib/public/assets/{video-off-T0rlt0GA.js → video-off-DDsEISjV.js} +1 -1
- package/lib/public/assets/webhook-settings-BGu32vSB.js +1 -0
- package/lib/public/assets/{zap-gBHqutZV.js → zap-l4VaXzq8.js} +1 -1
- package/lib/public/index.html +2 -2
- package/lib/schema.json +19 -46
- package/lib/src/XenonCapabilityManager.js +22 -5
- package/lib/src/app/openapi/control.yaml +71 -20
- package/lib/src/app/openapi/grid.yaml +23 -5
- package/lib/src/app/openapi/platform.yaml +136 -28
- package/lib/src/app/routers/control.js +30 -5
- package/lib/src/app/routers/dashboard.js +29 -1
- package/lib/src/app/routers/grid.js +32 -10
- package/lib/src/app/routers/streamStartConflict.js +3 -0
- package/lib/src/app/routers/streamType.js +7 -2
- package/lib/src/app/routers/webhook.js +8 -4
- package/lib/src/config.js +50 -5
- package/lib/src/dashboard/commands.js +185 -141
- package/lib/src/dashboard/event-manager.js +39 -6
- package/lib/src/data-service/appleFamily.js +43 -0
- package/lib/src/data-service/db.js +11 -0
- package/lib/src/data-service/device-service.js +46 -1
- package/lib/src/data-service/device-store.js +66 -3
- package/lib/src/data-service/deviceClaims.js +37 -0
- package/lib/src/data-service/deviceFieldOwners.js +25 -11
- package/lib/src/data-service/deviceSettings.js +79 -0
- package/lib/src/data-service/prisma-store.js +152 -9
- package/lib/src/data-service/web-config-service.js +43 -92
- package/lib/src/device-managers/AndroidDeviceManager.js +9 -31
- package/lib/src/device-managers/ios/WDAClient.js +44 -43
- package/lib/src/device-managers/shellCommands.js +96 -0
- package/lib/src/device-utils.js +143 -37
- package/lib/src/generated/client/edge.js +17 -3
- package/lib/src/generated/client/index-browser.js +14 -0
- package/lib/src/generated/client/index.d.ts +2054 -379
- package/lib/src/generated/client/index.js +17 -3
- package/lib/src/generated/client/package.json +1 -1
- package/lib/src/generated/client/schema.prisma +35 -7
- package/lib/src/generated/client/wasm.js +14 -0
- package/lib/src/interceptors/CommandInterceptor.js +29 -8
- package/lib/src/interceptors/xenonScripts.js +55 -0
- package/lib/src/interfaces/IPluginArgs.js +1 -2
- package/lib/src/middleware/deviceAccessGuard.js +63 -9
- package/lib/src/plugin.js +15 -1
- package/lib/src/prisma.js +1 -1
- package/lib/src/scripts/database-check.js +124 -0
- package/lib/src/services/AIService.js +99 -0
- package/lib/src/services/CleanupService.js +6 -1
- package/lib/src/services/InterceptorService.js +70 -13
- package/lib/src/services/NetworkConditioningService.js +85 -88
- package/lib/src/services/NotificationService.js +36 -29
- package/lib/src/services/OrphanSweeper.js +5 -0
- package/lib/src/services/PortAllocator.js +5 -0
- package/lib/src/services/ServerManager.js +97 -8
- package/lib/src/services/SessionLifecycleService.js +63 -53
- package/lib/src/services/ShutdownCoordinator.js +33 -0
- package/lib/src/services/TeamService.js +20 -3
- package/lib/src/services/device-access/SessionOwnerResolver.js +26 -0
- package/lib/src/services/device-access/deviceAccessPolicy.js +38 -6
- package/lib/src/services/device-access/leaseHold.js +26 -0
- package/lib/src/services/device-access/ticketActorAccess.js +6 -0
- package/lib/src/services/healing/HealingOrchestrator.js +32 -1
- package/lib/src/services/interceptor/AndroidProxyAdapter.js +18 -0
- package/lib/src/services/interceptor/interceptorOptions.js +44 -0
- package/lib/src/services/lease/activeLeases.js +37 -0
- package/lib/src/services/network/AndroidRadios.js +71 -0
- package/lib/src/services/network/PhoneNetworkLedger.js +184 -0
- package/lib/src/services/network/PhoneNetworkRestore.js +330 -0
- package/lib/src/services/network/adbForPhone.js +60 -0
- package/lib/src/services/network/phoneNetworkLock.js +20 -0
- package/lib/src/services/network/xenonProxy.js +107 -0
- package/lib/src/services/omni-vision/OmniVisionService.js +53 -43
- package/lib/src/services/omni-vision/VisionAssertionService.js +28 -25
- package/lib/src/services/omni-vision/ocrTextMatch.js +105 -0
- package/lib/src/services/omni-vision/screenScale.js +68 -0
- package/lib/src/services/recording/busy-precheck.js +24 -3
- package/lib/src/services/recording/concurrency-gate.js +12 -3
- package/lib/src/services/settings/SelfHealingSwitch.js +70 -0
- package/lib/src/services/settings/labSettings.js +149 -0
- package/lib/src/services/webhookEvents.js +173 -0
- package/lib/test/helpers/fake-adb.js +58 -0
- package/lib/test/helpers/fake-device-table.js +63 -24
- package/lib/test/helpers/scratch-database.js +1 -0
- package/lib/test/unit/TeamService.test.js +3 -0
- package/lib/test/unit/XenonCapabilityManager.spec.js +4 -2
- package/lib/test/unit/apple-family.spec.js +36 -0
- package/lib/test/unit/cleanup-settings-db.spec.js +103 -0
- package/lib/test/unit/cleanup-settings.spec.js +244 -0
- package/lib/test/unit/dashboard-api-paths.spec.js +101 -0
- package/lib/test/unit/dashboard-commands.spec.js +249 -0
- package/lib/test/unit/dashboard-events-team-scope.spec.js +9 -6
- package/lib/test/unit/database-check.spec.js +108 -0
- package/lib/test/unit/default-plugin-args.spec.js +33 -0
- package/lib/test/unit/device-access-lease.spec.js +270 -0
- package/lib/test/unit/device-offline-webhook.spec.js +81 -0
- package/lib/test/unit/device-setting-columns.spec.js +66 -0
- package/lib/test/unit/device-settings-loki.spec.js +87 -0
- package/lib/test/unit/device-settings-survive.spec.js +555 -0
- package/lib/test/unit/device-sync-lost-update.spec.js +5 -0
- package/lib/test/unit/emulator-boot.spec.js +91 -0
- package/lib/test/unit/hub-node-gateway-appium-server.spec.js +48 -0
- package/lib/test/unit/hub-node-same-host.spec.js +5 -0
- package/lib/test/unit/iphone-ipad-only.spec.js +132 -0
- package/lib/test/unit/json-logging-option.spec.js +74 -0
- package/lib/test/unit/lab-settings.spec.js +218 -0
- package/lib/test/unit/lease/allocate-lease-branch.spec.js +22 -0
- package/lib/test/unit/lease/session-lease-proof.spec.js +59 -0
- package/lib/test/unit/lease-held-phone.spec.js +196 -0
- package/lib/test/unit/max-sessions.spec.js +240 -0
- package/lib/test/unit/ocr-text-match.spec.js +44 -0
- package/lib/test/unit/omni-vision-analyze-screen.spec.js +72 -0
- package/lib/test/unit/omni-vision-ios-points.spec.js +161 -0
- package/lib/test/unit/omni-vision-tap-text.spec.js +129 -0
- package/lib/test/unit/omni-vision.spec.js +1 -1
- package/lib/test/unit/partial-config-file.spec.js +114 -0
- package/lib/test/unit/phone-network/boot-clean-up.spec.js +64 -0
- package/lib/test/unit/phone-network/interceptor-options.spec.js +77 -0
- package/lib/test/unit/phone-network/interceptor-proxy-restore.spec.js +145 -0
- package/lib/test/unit/phone-network/network-conditioning.spec.js +145 -0
- package/lib/test/unit/phone-network/phone-network-restore.spec.js +246 -0
- package/lib/test/unit/phone-network/session-end-paths.spec.js +182 -0
- package/lib/test/unit/phone-network/session-start.spec.js +110 -0
- package/lib/test/unit/phone-network/xenon-proxy.spec.js +69 -0
- package/lib/test/unit/plugin.spec.js +3 -3
- package/lib/test/unit/recording-options.spec.js +181 -0
- package/lib/test/unit/schema-required-args.spec.js +21 -16
- package/lib/test/unit/self-healing-boot.spec.js +75 -0
- package/lib/test/unit/self-healing-setting.spec.js +272 -0
- package/lib/test/unit/session-failed-webhook.spec.js +170 -0
- package/lib/test/unit/shell-commands.spec.js +133 -0
- package/lib/test/unit/socketServer.scopedEmit.spec.js +2 -0
- package/lib/test/unit/stream-start-pipelines.spec.js +210 -0
- package/lib/test/unit/stream-status-type.spec.js +4 -0
- package/lib/test/unit/vision-assertion.spec.js +118 -0
- package/lib/test/unit/wda-client-shell.spec.js +133 -0
- package/lib/test/unit/web-config-service.spec.js +79 -0
- package/lib/test/unit/webhook-delivery.spec.js +24 -0
- package/lib/test/unit/webhook-payloads.spec.js +273 -0
- package/lib/test/unit/xenon-execute-scripts.spec.js +138 -0
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/web/src/components/webhook-settings/webhookEventVariables.json +30 -0
- package/package.json +1 -1
- package/prisma/migrations/20261004140000_keep_device_settings/migration.sql +19 -0
- package/prisma/schema.prisma +35 -7
- package/schema.json +19 -46
- package/scripts/generate-types-from-schema.js +7 -2
- package/scripts/lib/always-present-plugin-args.js +42 -0
- package/lib/public/assets/DeviceMosaicView-ChhHnpFQ.js +0 -2
- package/lib/public/assets/device-explorer-DSpAA_t9.js +0 -279
- package/lib/public/assets/maintenance-settings-BxbA7SkB.js +0 -6
- package/lib/public/assets/recording-group-store-B75435xR.js +0 -26
- package/lib/public/assets/session-detail-page-Bc02YjMm.js +0 -4
- package/lib/public/assets/settings-C1VIluuT.js +0 -6
- package/lib/public/assets/webhook-settings-DAHgnJyZ.js +0 -1
|
@@ -187,11 +187,17 @@ paths:
|
|
|
187
187
|
operationId: getLabSettings
|
|
188
188
|
summary: Read the lab's settings and AI provider
|
|
189
189
|
description: |
|
|
190
|
-
The lab-wide settings
|
|
191
|
-
with the AI settings currently in effect.
|
|
192
|
-
|
|
193
|
-
is
|
|
194
|
-
|
|
190
|
+
The lab-wide settings in effect (health checks, build cleanup and the AI self-healing
|
|
191
|
+
switch), merged with the AI settings currently in effect. Each setting is the value saved
|
|
192
|
+
in the dashboard, else the plugin option the server was started with, else the default,
|
|
193
|
+
which is also what the server runs with. `defaults` holds the defaults themselves, which
|
|
194
|
+
is what "restore defaults" goes back to. Only `healthCheckSchedule` can be absent: no
|
|
195
|
+
schedule is set. Through 2.13 `enableSelfHealing` was neither stored nor sent, so the
|
|
196
|
+
Settings page always showed it on.
|
|
197
|
+
API keys are never returned: `geminiSet`, `openaiSet` and `anthropicSet` say only
|
|
198
|
+
whether one is configured. Needs the `ADMIN` role or above, as the dashboard's settings
|
|
199
|
+
pages do; through 2.12 any signed-in user could read it. Through 2.13 a setting never
|
|
200
|
+
saved was absent, and `defaults` was not sent.
|
|
195
201
|
tags:
|
|
196
202
|
- Configuration
|
|
197
203
|
responses:
|
|
@@ -202,8 +208,19 @@ paths:
|
|
|
202
208
|
schema:
|
|
203
209
|
$ref: '#/components/schemas/PlatformSettings'
|
|
204
210
|
example:
|
|
211
|
+
enableSelfHealing: true
|
|
205
212
|
healthCheckIntervalMs: 300000
|
|
206
213
|
buildCleanupDays: 30
|
|
214
|
+
buildCleanupMaxCount: 100
|
|
215
|
+
buildCleanupSchedule: 0 0 * * *
|
|
216
|
+
deleteBuildAssets: true
|
|
217
|
+
defaults:
|
|
218
|
+
enableSelfHealing: true
|
|
219
|
+
healthCheckIntervalMs: 300000
|
|
220
|
+
buildCleanupDays: 30
|
|
221
|
+
buildCleanupMaxCount: 100
|
|
222
|
+
buildCleanupSchedule: 0 0 * * *
|
|
223
|
+
deleteBuildAssets: true
|
|
207
224
|
aiProvider: gemini
|
|
208
225
|
aiModel: gemini-3-flash-preview
|
|
209
226
|
geminiModel: gemini-3-flash-preview
|
|
@@ -233,7 +250,22 @@ paths:
|
|
|
233
250
|
Saves the lab-wide settings and changes the AI provider settings. Every field is
|
|
234
251
|
optional; fields not sent are left as they are, and unknown fields are ignored.
|
|
235
252
|
|
|
236
|
-
- Health-check and build-cleanup fields are stored in the database.
|
|
253
|
+
- Health-check and build-cleanup fields are stored in the database. A stored value
|
|
254
|
+
replaces the plugin option the server was started with, and applies without a
|
|
255
|
+
restart: the health check within a minute, the retention values at the next cleanup
|
|
256
|
+
run, and a new `buildCleanupSchedule` at once. The cleanup fields are checked first
|
|
257
|
+
and refused with `400` when they could not work: `buildCleanupDays` and
|
|
258
|
+
`buildCleanupMaxCount` must be whole numbers of at least 1, `buildCleanupSchedule` a
|
|
259
|
+
cron expression of five or six fields, `deleteBuildAssets` true or false. Nothing is
|
|
260
|
+
saved then. Send only the fields to change: a field sent is saved as the lab's own.
|
|
261
|
+
Through 2.13 only one setting could be saved: saving a second failed with a `500`.
|
|
262
|
+
- `enableSelfHealing` (true or false; anything else is refused with `400`) is the AI
|
|
263
|
+
self-healing switch. A stored value replaces the plugin option the server was started
|
|
264
|
+
with, and applies to the next command this server runs, with no restart. A session's
|
|
265
|
+
own `xe:options.healingTiers` still limits the tiers it may use. Through 2.13 the
|
|
266
|
+
switch was accepted and ignored. The value belongs to the server it is saved on:
|
|
267
|
+
saving it on a hub changes the hub's own sessions, not those on a node's phones,
|
|
268
|
+
which the node's own setting decides.
|
|
237
269
|
- AI fields (`aiProvider`, `aiModel`, `aiBaseUrl` and the per-provider models) change the
|
|
238
270
|
running server only. They are not stored, so a restart returns to the values the
|
|
239
271
|
server was started with. API keys can't be set here; they come from the server's
|
|
@@ -254,6 +286,7 @@ paths:
|
|
|
254
286
|
healthCheckIntervalMs: 300000
|
|
255
287
|
buildCleanupDays: 14
|
|
256
288
|
deleteBuildAssets: true
|
|
289
|
+
enableSelfHealing: false
|
|
257
290
|
aiProvider: anthropic
|
|
258
291
|
anthropicModel: claude-sonnet-4-6
|
|
259
292
|
responses:
|
|
@@ -265,6 +298,16 @@ paths:
|
|
|
265
298
|
$ref: '#/components/schemas/Success'
|
|
266
299
|
example:
|
|
267
300
|
success: true
|
|
301
|
+
'400':
|
|
302
|
+
description: A build-cleanup field or the self-healing switch has a value that could not work. Nothing was saved.
|
|
303
|
+
content:
|
|
304
|
+
application/json:
|
|
305
|
+
schema:
|
|
306
|
+
$ref: '#/components/schemas/Error'
|
|
307
|
+
example:
|
|
308
|
+
error: invalid_setting
|
|
309
|
+
field: buildCleanupDays
|
|
310
|
+
message: buildCleanupDays must be a whole number of at least 1.
|
|
268
311
|
'401':
|
|
269
312
|
$ref: '#/components/responses/Unauthorized'
|
|
270
313
|
'403':
|
|
@@ -279,7 +322,7 @@ paths:
|
|
|
279
322
|
$ref: '#/components/schemas/Error'
|
|
280
323
|
example:
|
|
281
324
|
error: true
|
|
282
|
-
message:
|
|
325
|
+
message: Can't reach database server
|
|
283
326
|
/api/config/reset-metrics:
|
|
284
327
|
post:
|
|
285
328
|
operationId: resetDeviceHealCounts
|
|
@@ -415,21 +458,39 @@ paths:
|
|
|
415
458
|
description: |
|
|
416
459
|
Adds a webhook, active at once. When one of its `events` happens Xenon POSTs to `url`:
|
|
417
460
|
|
|
418
|
-
- with `payloadTemplate`: the template, with each `{{
|
|
419
|
-
the event (`eventType` plus the event's fields
|
|
420
|
-
JSON,
|
|
461
|
+
- with `payloadTemplate`: the template, with each `{{name}}` (or `{{a.b}}`, `{{list.0.b}}`)
|
|
462
|
+
replaced from the event (`eventType` plus the event's fields, below). A template that
|
|
463
|
+
is JSON as written is filled in string by string, so a value holding a quote or a line
|
|
464
|
+
break can't break it, and is sent as that JSON. Any other template is filled in as
|
|
465
|
+
text and sent as JSON if the result parses, otherwise as `{ "text": "<result>" }`. A
|
|
466
|
+
`{{name}}` the event doesn't have is left as written;
|
|
421
467
|
- otherwise, `type: slack`: a Slack message with an attachment;
|
|
422
468
|
- otherwise: `{ "event": "<event>", "payload": { ... } }`.
|
|
423
469
|
|
|
424
|
-
Each delivery is one POST, never retried. A
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
470
|
+
Each delivery is one POST, never retried. A webhook that refuses an event or can't be
|
|
471
|
+
reached doesn't fail the event: the failure is logged on the server and the other
|
|
472
|
+
webhooks still get it. Use `POST /api/webhook/test` to see whether a webhook accepts
|
|
473
|
+
deliveries.
|
|
428
474
|
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
475
|
+
What each event carries (a device event also has the device's other fields, which may
|
|
476
|
+
change; only the names listed are promised):
|
|
477
|
+
|
|
478
|
+
- `device_offline`, `device_new`: `udid`, `name`, `host`, `platform`.
|
|
479
|
+
Sent when a device stops being reported, or is first detected.
|
|
480
|
+
|
|
481
|
+
- `session_failed`: `sessionId`, `sessionName`, `failureReason`, `udid`, `deviceName`,
|
|
482
|
+
`platform`, `osVersion`, `startTime`, `endTime` (ISO 8601; unknown values are empty
|
|
483
|
+
text). Sent once per session when it ends as failed: the test marked it failed, a command
|
|
484
|
+
failed, it timed out for inactivity, its driver crashed, or its heartbeat stopped. Not
|
|
485
|
+
when the server itself shuts down, not for a session already failed when the server
|
|
486
|
+
started, and not when the dashboard is off, since the session's record is what it is
|
|
487
|
+
built from.
|
|
488
|
+
|
|
489
|
+
- `selector_health_digest`: `windowDays`, `totalHeals`, `distinctSelectors` and
|
|
490
|
+
`hotspots`, a list of `healCount`, `originalSelector` and `suggestedRewrite`.
|
|
491
|
+
|
|
492
|
+
Neither `url` nor the event names are checked. Needs the `ADMIN` role and the `admin`
|
|
493
|
+
scope. With the dashboard cookie the request must come from the same host.
|
|
433
494
|
tags:
|
|
434
495
|
- Webhooks
|
|
435
496
|
requestBody:
|
|
@@ -536,11 +597,12 @@ paths:
|
|
|
536
597
|
operationId: testWebhook
|
|
537
598
|
summary: Send a test message to a URL
|
|
538
599
|
description: |
|
|
539
|
-
Sends a sample `device_new`
|
|
540
|
-
`test-device-udid`, host `127.0.0.1
|
|
541
|
-
`payloadTemplate` gets its real events (see
|
|
542
|
-
|
|
543
|
-
|
|
600
|
+
Sends a sample of `event` (`device_new` unless named; a device named `Test Device`, udid
|
|
601
|
+
`test-device-udid`, host `127.0.0.1`, or for `session_failed` a failed session on it) to
|
|
602
|
+
`url` the way a webhook with this `type` and `payloadTemplate` gets its real events (see
|
|
603
|
+
`POST /api/webhook`, which lists what each event carries): the filled-in template if
|
|
604
|
+
there is one, else a Slack message for `type: slack` (the default), else
|
|
605
|
+
`{ "event": "<event>", "payload": { ... } }`. No stored webhook is involved.
|
|
544
606
|
|
|
545
607
|
Answers `200` when `url` accepted the delivery (a 2xx), and `502 delivery_failed`, with
|
|
546
608
|
the reason, when it refused it or couldn't be reached. Needs the `ADMIN` role and the
|
|
@@ -575,6 +637,16 @@ paths:
|
|
|
575
637
|
The webhook's template, filled in from the sample event as a real event's
|
|
576
638
|
would be.
|
|
577
639
|
example: '{"text": "{{eventType}}: {{name}} ({{udid}})"}'
|
|
640
|
+
event:
|
|
641
|
+
type: string
|
|
642
|
+
default: device_new
|
|
643
|
+
enum:
|
|
644
|
+
- device_offline
|
|
645
|
+
- session_failed
|
|
646
|
+
- device_new
|
|
647
|
+
- selector_health_digest
|
|
648
|
+
description: Which event to send a sample of.
|
|
649
|
+
example: session_failed
|
|
578
650
|
example:
|
|
579
651
|
url: https://hooks.slack.com/services/T000/B000/XXXXXXXX
|
|
580
652
|
type: slack
|
|
@@ -588,13 +660,18 @@ paths:
|
|
|
588
660
|
example:
|
|
589
661
|
success: true
|
|
590
662
|
'400':
|
|
591
|
-
description: '`url` is missing or not a string.'
|
|
663
|
+
description: '`url` is missing or not a string, or `event` is not one of the four.'
|
|
592
664
|
content:
|
|
593
665
|
application/json:
|
|
594
666
|
schema:
|
|
595
667
|
$ref: '#/components/schemas/Error'
|
|
596
|
-
|
|
597
|
-
|
|
668
|
+
examples:
|
|
669
|
+
noUrl:
|
|
670
|
+
value:
|
|
671
|
+
error: url is required
|
|
672
|
+
badEvent:
|
|
673
|
+
value:
|
|
674
|
+
error: 'event must be one of: device_offline, session_failed, device_new, selector_health_digest'
|
|
598
675
|
'401':
|
|
599
676
|
$ref: '#/components/responses/Unauthorized'
|
|
600
677
|
'403':
|
|
@@ -2264,8 +2341,12 @@ components:
|
|
|
2264
2341
|
example: 734120
|
|
2265
2342
|
PlatformSettings:
|
|
2266
2343
|
type: object
|
|
2267
|
-
description: The lab's
|
|
2344
|
+
description: The lab's settings in effect (saved, else the startup option, else the default), merged with the AI settings in effect. Only `healthCheckSchedule` can be absent.
|
|
2268
2345
|
properties:
|
|
2346
|
+
enableSelfHealing:
|
|
2347
|
+
type: boolean
|
|
2348
|
+
description: Whether a failed findElement goes on to the self-healing tiers.
|
|
2349
|
+
example: true
|
|
2269
2350
|
healthCheckIntervalMs:
|
|
2270
2351
|
type: integer
|
|
2271
2352
|
example: 300000
|
|
@@ -2283,6 +2364,27 @@ components:
|
|
|
2283
2364
|
example: 0 3 * * *
|
|
2284
2365
|
deleteBuildAssets:
|
|
2285
2366
|
type: boolean
|
|
2367
|
+
defaults:
|
|
2368
|
+
type: object
|
|
2369
|
+
description: The server's own defaults for the settings above, which is what "restore defaults" goes back to.
|
|
2370
|
+
properties:
|
|
2371
|
+
enableSelfHealing:
|
|
2372
|
+
type: boolean
|
|
2373
|
+
example: true
|
|
2374
|
+
healthCheckIntervalMs:
|
|
2375
|
+
type: integer
|
|
2376
|
+
example: 300000
|
|
2377
|
+
buildCleanupDays:
|
|
2378
|
+
type: integer
|
|
2379
|
+
example: 30
|
|
2380
|
+
buildCleanupMaxCount:
|
|
2381
|
+
type: integer
|
|
2382
|
+
example: 100
|
|
2383
|
+
buildCleanupSchedule:
|
|
2384
|
+
type: string
|
|
2385
|
+
example: 0 0 * * *
|
|
2386
|
+
deleteBuildAssets:
|
|
2387
|
+
type: boolean
|
|
2286
2388
|
aiProvider:
|
|
2287
2389
|
type: string
|
|
2288
2390
|
example: gemini
|
|
@@ -2311,6 +2413,10 @@ components:
|
|
|
2311
2413
|
type: object
|
|
2312
2414
|
description: Any subset. Unknown fields are ignored.
|
|
2313
2415
|
properties:
|
|
2416
|
+
enableSelfHealing:
|
|
2417
|
+
type: boolean
|
|
2418
|
+
description: The AI self-healing switch. Takes effect at the next command, with no restart.
|
|
2419
|
+
example: false
|
|
2314
2420
|
healthCheckIntervalMs:
|
|
2315
2421
|
type: integer
|
|
2316
2422
|
example: 300000
|
|
@@ -2448,7 +2554,9 @@ components:
|
|
|
2448
2554
|
example: slack
|
|
2449
2555
|
payloadTemplate:
|
|
2450
2556
|
type: string
|
|
2451
|
-
description:
|
|
2557
|
+
description: >-
|
|
2558
|
+
A body template with `{{name}}` placeholders, used in place of the default body (see
|
|
2559
|
+
`POST /api/webhook` for the names each event has).
|
|
2452
2560
|
example: '{"text":"{{eventType}} on {{udid}}"}'
|
|
2453
2561
|
PlatformApp:
|
|
2454
2562
|
type: object
|
|
@@ -88,6 +88,8 @@ const streamLeave_1 = require("./streamLeave");
|
|
|
88
88
|
const SessionOwnerResolver_1 = require("../../services/device-access/SessionOwnerResolver");
|
|
89
89
|
const actor_1 = require("../../services/device-access/actor");
|
|
90
90
|
const deviceAccessPolicy_1 = require("../../services/device-access/deviceAccessPolicy");
|
|
91
|
+
const leaseHold_1 = require("../../services/device-access/leaseHold");
|
|
92
|
+
const activeLeases_1 = require("../../services/lease/activeLeases");
|
|
91
93
|
/**
|
|
92
94
|
* The answer for an unknown udid, and for another team's phone (see
|
|
93
95
|
* deviceTeamGuard): the same JSON on every route. Most routes used to send
|
|
@@ -623,7 +625,7 @@ const MJPEG_PROXY_CACHE = new Map();
|
|
|
623
625
|
* Start stream endpoint - Initiates WDA and MJPEG streaming for iOS devices
|
|
624
626
|
*/
|
|
625
627
|
router.post('/:udid/stream/start', (req, res) => __awaiter(void 0, void 0, void 0, function* () {
|
|
626
|
-
var _a, _b, _c, _d;
|
|
628
|
+
var _a, _b, _c, _d, _e, _f;
|
|
627
629
|
const { udid } = req.params;
|
|
628
630
|
// Someone is about to watch: a page that just left (a reload, or another tab
|
|
629
631
|
// closing) must not stop the stream this page is starting.
|
|
@@ -654,6 +656,18 @@ router.post('/:udid/stream/start', (req, res) => __awaiter(void 0, void 0, void
|
|
|
654
656
|
return res.status(503).json((0, deviceAccessPolicy_1.ownershipUnavailableBody)());
|
|
655
657
|
}
|
|
656
658
|
}
|
|
659
|
+
// Busy with nothing in session_id is a lease's lock: is it the caller's?
|
|
660
|
+
let leaseHolder = false;
|
|
661
|
+
if (device.busy && !device.session_id && !actor.isAdmin) {
|
|
662
|
+
try {
|
|
663
|
+
const held = yield (0, leaseHold_1.leaseHoldFor)({ udid, host: device.host }, (u, h) => (0, activeLeases_1.activeLeaseOn)(u, h), (id) => ownerResolver.leaseHolderOf(id));
|
|
664
|
+
leaseHolder = (0, deviceAccessPolicy_1.isLeaseHolder)(held, actorUserId, actor.apiKeyId);
|
|
665
|
+
}
|
|
666
|
+
catch (e) {
|
|
667
|
+
logger_1.default.error(`stream/start: lease lookup failed for ${udid}: ${(_b = e === null || e === void 0 ? void 0 : e.message) !== null && _b !== void 0 ? _b : e}`);
|
|
668
|
+
return res.status(503).json((0, deviceAccessPolicy_1.ownershipUnavailableBody)());
|
|
669
|
+
}
|
|
670
|
+
}
|
|
657
671
|
const conflict = (0, streamStartConflict_1.decideStreamStartConflict)({
|
|
658
672
|
udid,
|
|
659
673
|
busy: !!device.busy,
|
|
@@ -663,6 +677,7 @@ router.post('/:udid/stream/start', (req, res) => __awaiter(void 0, void 0, void
|
|
|
663
677
|
actorUserId,
|
|
664
678
|
actorApiKeyId: actor.apiKeyId,
|
|
665
679
|
isAdmin: actor.isAdmin,
|
|
680
|
+
leaseHolder,
|
|
666
681
|
});
|
|
667
682
|
if (conflict.action === 'deny') {
|
|
668
683
|
// holderName lookup is cosmetic — a failure here must still deny (never
|
|
@@ -673,7 +688,7 @@ router.post('/:udid/stream/start', (req, res) => __awaiter(void 0, void 0, void
|
|
|
673
688
|
holderName = yield ownerResolver.displayName(conflict.holderId);
|
|
674
689
|
}
|
|
675
690
|
catch (e) {
|
|
676
|
-
logger_1.default.warn(`stream/start: holder name lookup failed for ${conflict.holderId}: ${(
|
|
691
|
+
logger_1.default.warn(`stream/start: holder name lookup failed for ${conflict.holderId}: ${(_c = e === null || e === void 0 ? void 0 : e.message) !== null && _c !== void 0 ? _c : e}`);
|
|
677
692
|
}
|
|
678
693
|
}
|
|
679
694
|
logger_1.default.warn(`Manual Control refused for ${udid}: ${conflict.code} (holder=${conflict.holderId || 'unknown'})`);
|
|
@@ -685,16 +700,20 @@ router.post('/:udid/stream/start', (req, res) => __awaiter(void 0, void 0, void
|
|
|
685
700
|
yield (0, device_service_1.unblockDevice)(udid, device.host);
|
|
686
701
|
}
|
|
687
702
|
catch (e) {
|
|
688
|
-
logger_1.default.warn(`Failed to clear orphaned lock on ${udid}: ${(
|
|
703
|
+
logger_1.default.warn(`Failed to clear orphaned lock on ${udid}: ${(_d = e === null || e === void 0 ? void 0 : e.message) !== null && _d !== void 0 ? _d : e}`);
|
|
689
704
|
}
|
|
690
705
|
}
|
|
691
706
|
try {
|
|
692
|
-
const h264Cfg = (0, androidH264Config_1.resolveAndroidH264)((
|
|
707
|
+
const h264Cfg = (0, androidH264Config_1.resolveAndroidH264)((_e = typedi_1.Container.get(PluginContext_1.PluginContext).pluginArgs.streaming) === null || _e === void 0 ? void 0 : _e.androidH264);
|
|
693
708
|
const flagOn = h264Cfg.enabled;
|
|
694
709
|
// A recording device keeps MJPEG preview so we never run screenrecord and
|
|
695
710
|
// the recording's screencap pipeline against the same device at once.
|
|
696
711
|
const recording = yield typedi_1.Container.get(recording_store_1.RecordingStore).isRecording(udid);
|
|
697
|
-
|
|
712
|
+
// A page that shows MJPEG says so (`player: 'mjpeg'`): device control, a
|
|
713
|
+
// browser with no WebCodecs, or a page whose H.264 player just failed.
|
|
714
|
+
// Anything else is the server's choice.
|
|
715
|
+
const clientShowsMjpeg = ((_f = req.body) === null || _f === void 0 ? void 0 : _f.player) === 'mjpeg';
|
|
716
|
+
const streamType = (0, streamType_1.resolveStreamType)(device.platform, flagOn, recording, !clientShowsMjpeg);
|
|
698
717
|
let mjpegPort;
|
|
699
718
|
if (device.platform === 'ios' || device.platform === 'tvos') {
|
|
700
719
|
mjpegPort = (yield typedi_1.Container.get(IOSStreamService_1.default).startStream(udid)).mjpegPort;
|
|
@@ -705,6 +724,12 @@ router.post('/:udid/stream/start', (req, res) => __awaiter(void 0, void 0, void
|
|
|
705
724
|
yield typedi_1.Container.get(AndroidH264StreamService_1.default).start(udid, { source: h264Cfg.source });
|
|
706
725
|
}
|
|
707
726
|
else {
|
|
727
|
+
// One capture pipeline per device: an H.264 capture still running for it
|
|
728
|
+
// (a tile's, or this page's own before its player failed) ends before the
|
|
729
|
+
// screencap loop starts.
|
|
730
|
+
const h264 = typedi_1.Container.get(AndroidH264StreamService_1.default);
|
|
731
|
+
if (h264.getMultiplexer(udid))
|
|
732
|
+
yield h264.stop(udid);
|
|
708
733
|
mjpegPort = (yield typedi_1.Container.get(AndroidStreamService_1.default).startStream(udid)).mjpegPort;
|
|
709
734
|
}
|
|
710
735
|
// Lazy-load the screen size if missing: tiles need it to accept taps.
|
|
@@ -56,6 +56,9 @@ const prisma_1 = require("../../prisma");
|
|
|
56
56
|
const SessionManager_1 = require("../../sessions/SessionManager");
|
|
57
57
|
const UniversalMjpegProxy_1 = require("../../helpers/UniversalMjpegProxy");
|
|
58
58
|
const web_config_service_1 = require("../../data-service/web-config-service");
|
|
59
|
+
const PluginContext_1 = require("../../PluginContext");
|
|
60
|
+
const labSettings_1 = require("../../services/settings/labSettings");
|
|
61
|
+
const SelfHealingSwitch_1 = require("../../services/settings/SelfHealingSwitch");
|
|
59
62
|
const typedi_1 = require("typedi");
|
|
60
63
|
const scopeGuard_1 = require("../../middleware/scopeGuard");
|
|
61
64
|
const roleGuard_1 = require("../../middleware/roleGuard");
|
|
@@ -1103,6 +1106,10 @@ function getGlobalConfig(request, response) {
|
|
|
1103
1106
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1104
1107
|
try {
|
|
1105
1108
|
const dbConfig = yield typedi_1.Container.get(web_config_service_1.WebConfigService).getConfig();
|
|
1109
|
+
// What the server runs with: a saved value, else the startup option, else
|
|
1110
|
+
// the default. The pages show this (a saved value alone left them to guess
|
|
1111
|
+
// at what a setting never saved was), and `defaults` for "restore defaults".
|
|
1112
|
+
const effective = (0, labSettings_1.effectiveSettings)(typedi_1.Container.get(PluginContext_1.PluginContext).pluginArgs, dbConfig);
|
|
1106
1113
|
// Merge with Environment Config (AI Settings)
|
|
1107
1114
|
const { config } = yield Promise.resolve().then(() => __importStar(require('../../config')));
|
|
1108
1115
|
// Sanitize keys - return boolean existence only
|
|
@@ -1118,7 +1125,9 @@ function getGlobalConfig(request, response) {
|
|
|
1118
1125
|
openaiSet: !!config.openaiApiKey,
|
|
1119
1126
|
anthropicSet: !!config.anthropicApiKey,
|
|
1120
1127
|
};
|
|
1121
|
-
return response
|
|
1128
|
+
return response
|
|
1129
|
+
.status(200)
|
|
1130
|
+
.json(Object.assign(Object.assign(Object.assign(Object.assign({}, dbConfig), effective), { defaults: (0, labSettings_1.settingsDefaults)() }), aiConfig));
|
|
1122
1131
|
}
|
|
1123
1132
|
catch (err) {
|
|
1124
1133
|
return response.status(500).json({ error: true, message: err.message });
|
|
@@ -1129,6 +1138,14 @@ function updateGlobalConfig(request, response) {
|
|
|
1129
1138
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1130
1139
|
try {
|
|
1131
1140
|
const payload = request.body;
|
|
1141
|
+
// Before anything is saved: a value the cleanup job would act on, such as a
|
|
1142
|
+
// retention window of 0, is refused rather than stored.
|
|
1143
|
+
const problem = (0, labSettings_1.validateSettingsUpdate)(payload !== null && payload !== void 0 ? payload : {});
|
|
1144
|
+
if (problem) {
|
|
1145
|
+
return response
|
|
1146
|
+
.status(400)
|
|
1147
|
+
.json({ error: 'invalid_setting', field: problem.field, message: problem.message });
|
|
1148
|
+
}
|
|
1132
1149
|
// Handle Runtime AI Config Overrides (Memory only)
|
|
1133
1150
|
// Only pass defined values to avoid overwriting env vars (e.g. aiBaseUrl, ollamaModel) with undefined
|
|
1134
1151
|
const runtimeOverrides = {};
|
|
@@ -1152,6 +1169,17 @@ function updateGlobalConfig(request, response) {
|
|
|
1152
1169
|
}
|
|
1153
1170
|
// Persist Web Configs to DB
|
|
1154
1171
|
yield typedi_1.Container.get(web_config_service_1.WebConfigService).setConfig(payload);
|
|
1172
|
+
// The command interceptor asks at every command and never reads the
|
|
1173
|
+
// database: hand it the saved value, in force from the next command.
|
|
1174
|
+
if (payload.enableSelfHealing !== undefined) {
|
|
1175
|
+
typedi_1.Container.get(SelfHealingSwitch_1.SelfHealingSwitch).set(payload.enableSelfHealing);
|
|
1176
|
+
}
|
|
1177
|
+
// The retention values are read at each cleanup run, so they apply by
|
|
1178
|
+
// themselves. A schedule is a timer: replace it now, not at the next restart.
|
|
1179
|
+
if (payload.buildCleanupSchedule !== undefined) {
|
|
1180
|
+
const { rescheduleCleanupBuilds } = yield Promise.resolve().then(() => __importStar(require('../../device-utils')));
|
|
1181
|
+
yield rescheduleCleanupBuilds(typedi_1.Container.get(PluginContext_1.PluginContext).pluginArgs);
|
|
1182
|
+
}
|
|
1155
1183
|
return response.status(200).json({ success: true });
|
|
1156
1184
|
}
|
|
1157
1185
|
catch (err) {
|
|
@@ -402,10 +402,33 @@ function updateTags(request, response) {
|
|
|
402
402
|
if (!udid || !host || !Array.isArray(tags)) {
|
|
403
403
|
return response.status(400).json({ error: 'Missing udid, host, or tags array' });
|
|
404
404
|
}
|
|
405
|
+
// The tags are saved for the phone (deviceSettings.ts): only for one that
|
|
406
|
+
// is here. Through 2.13 any udid and host answered 200 and wrote nothing.
|
|
407
|
+
if (!(yield device_store_1.DeviceStoreFactory.getStore().findDevice({ udid, host }))) {
|
|
408
|
+
return response.status(404).json({ error: 'Device not found' });
|
|
409
|
+
}
|
|
405
410
|
yield (0, device_service_1.updateDeviceTags)(udid, host, tags);
|
|
406
411
|
response.status(200).json({ success: true });
|
|
407
412
|
});
|
|
408
413
|
}
|
|
414
|
+
/**
|
|
415
|
+
* Every phone of this udid that this server knows: those connected now, and
|
|
416
|
+
* those whose settings are saved while they are away (deviceSettings.ts), so
|
|
417
|
+
* a phone that is not connected can still be moved, and its team deleted.
|
|
418
|
+
*/
|
|
419
|
+
function phonesOfUdid(udid) {
|
|
420
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
421
|
+
const store = device_store_1.DeviceStoreFactory.getStore();
|
|
422
|
+
const phones = new Map();
|
|
423
|
+
for (const phone of [
|
|
424
|
+
...(yield store.findDevices({ udid })),
|
|
425
|
+
...(yield store.findSavedPhones(udid)),
|
|
426
|
+
]) {
|
|
427
|
+
phones.set(`${phone.udid}\u0000${phone.host}`, { udid: phone.udid, host: phone.host });
|
|
428
|
+
}
|
|
429
|
+
return [...phones.values()];
|
|
430
|
+
});
|
|
431
|
+
}
|
|
409
432
|
function assignDeviceToTeam(request, response) {
|
|
410
433
|
return __awaiter(this, void 0, void 0, function* () {
|
|
411
434
|
const { udid } = request.params;
|
|
@@ -415,20 +438,19 @@ function assignDeviceToTeam(request, response) {
|
|
|
415
438
|
if (!team)
|
|
416
439
|
return response.status(404).json({ error: 'team not found' });
|
|
417
440
|
}
|
|
418
|
-
const
|
|
419
|
-
|
|
420
|
-
data: { teamId: teamId || null },
|
|
421
|
-
});
|
|
422
|
-
if (result.count === 0)
|
|
441
|
+
const phones = yield phonesOfUdid(udid);
|
|
442
|
+
if (phones.length === 0)
|
|
423
443
|
return response.status(404).json({ error: 'device not found' });
|
|
424
|
-
//
|
|
425
|
-
|
|
426
|
-
for (const
|
|
427
|
-
yield
|
|
444
|
+
// Through the store, which saves the team for the phone as it writes the
|
|
445
|
+
// row: a phone keeps it when it disconnects and comes back.
|
|
446
|
+
for (const phone of phones) {
|
|
447
|
+
yield device_store_1.DeviceStoreFactory.getStore().updateDevice(phone.udid, phone.host, {
|
|
448
|
+
teamId: teamId || null,
|
|
449
|
+
});
|
|
428
450
|
}
|
|
429
451
|
// The live dashboard events follow the new team now, not after the cache's TTL.
|
|
430
452
|
typedi_1.Container.get(DeviceTeamResolver_1.DeviceTeamResolver).note(udid, teamId || null);
|
|
431
|
-
response.json({ ok: true, updated:
|
|
453
|
+
response.json({ ok: true, updated: phones.length });
|
|
432
454
|
});
|
|
433
455
|
}
|
|
434
456
|
/**
|
|
@@ -21,6 +21,9 @@ function decideStreamStartConflict(i) {
|
|
|
21
21
|
var _a, _b;
|
|
22
22
|
if (!i.busy)
|
|
23
23
|
return PROCEED;
|
|
24
|
+
// Busy only by the caller's own lease: their phone to preview.
|
|
25
|
+
if (i.leaseHolder && !i.sessionId)
|
|
26
|
+
return PROCEED;
|
|
24
27
|
if ((0, manualLock_1.isManualLock)(i.sessionId)) {
|
|
25
28
|
// Orphan: lock persisted but nothing is serving (server restart, crashed
|
|
26
29
|
// stop, H.264 stop that skipped unlock). Any caller may reclaim it.
|
|
@@ -9,10 +9,15 @@ exports.resolveStreamType = resolveStreamType;
|
|
|
9
9
|
* MJPEG path so the recording pipeline (which reads the MJPEG server) is
|
|
10
10
|
* unaffected (spec phase-1 rule). iOS/tvOS always use MJPEG (WDA emits it
|
|
11
11
|
* directly).
|
|
12
|
+
*
|
|
13
|
+
* `clientCanPlayH264` is false when the page that starts the stream shows
|
|
14
|
+
* MJPEG: device control, or a browser without WebCodecs (exposed only on
|
|
15
|
+
* https and localhost). Starting an H.264 capture for it would run a second
|
|
16
|
+
* capture beside the screencap loop its `<img>` starts.
|
|
12
17
|
*/
|
|
13
|
-
function resolveStreamType(platform, flagOn, recording) {
|
|
18
|
+
function resolveStreamType(platform, flagOn, recording, clientCanPlayH264 = true) {
|
|
14
19
|
const isAndroid = platform === 'android' || platform === 'androidtv' || platform === 'android-tv';
|
|
15
|
-
if (!isAndroid || !flagOn || recording)
|
|
20
|
+
if (!isAndroid || !flagOn || recording || !clientCanPlayH264)
|
|
16
21
|
return 'mjpeg';
|
|
17
22
|
return 'h264';
|
|
18
23
|
}
|
|
@@ -14,6 +14,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
const express_1 = require("express");
|
|
16
16
|
const NotificationService_1 = require("../../services/NotificationService");
|
|
17
|
+
const webhookEvents_1 = require("../../services/webhookEvents");
|
|
17
18
|
const typedi_1 = require("typedi");
|
|
18
19
|
const logger_1 = __importDefault(require("../../logger"));
|
|
19
20
|
const scopeGuard_1 = require("../../middleware/scopeGuard");
|
|
@@ -63,17 +64,20 @@ function deleteConfig(req, res) {
|
|
|
63
64
|
}
|
|
64
65
|
});
|
|
65
66
|
}
|
|
66
|
-
// Sends a sample event the way the webhook's real events go out (its
|
|
67
|
-
// and template), and says whether it was delivered.
|
|
67
|
+
// Sends a sample of an event the way the webhook's real events go out (its
|
|
68
|
+
// type and template), and says whether it was delivered.
|
|
68
69
|
function testWebhook(req, res) {
|
|
69
70
|
return __awaiter(this, void 0, void 0, function* () {
|
|
70
71
|
var _a, _b;
|
|
71
|
-
const { url, type, payloadTemplate } = (_a = req.body) !== null && _a !== void 0 ? _a : {};
|
|
72
|
+
const { url, type, payloadTemplate, event } = (_a = req.body) !== null && _a !== void 0 ? _a : {};
|
|
72
73
|
if (!url || typeof url !== 'string') {
|
|
73
74
|
return res.status(400).json({ error: 'url is required' });
|
|
74
75
|
}
|
|
76
|
+
if (event !== undefined && !(0, webhookEvents_1.isEventType)(event)) {
|
|
77
|
+
return res.status(400).json({ error: `event must be one of: ${webhookEvents_1.EVENT_TYPES.join(', ')}` });
|
|
78
|
+
}
|
|
75
79
|
try {
|
|
76
|
-
yield typedi_1.Container.get(NotificationService_1.NotificationService).sendTest(url, type || 'slack', payloadTemplate);
|
|
80
|
+
yield typedi_1.Container.get(NotificationService_1.NotificationService).sendTest(url, type || 'slack', payloadTemplate, event);
|
|
77
81
|
res.json({ success: true });
|
|
78
82
|
}
|
|
79
83
|
catch (err) {
|
package/lib/src/config.js
CHANGED
|
@@ -32,14 +32,20 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
32
32
|
return result;
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
|
-
var _a;
|
|
36
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
-
exports.config = void 0;
|
|
36
|
+
exports.config = exports.DEFAULT_MAX_CONCURRENT_RECORDINGS = void 0;
|
|
38
37
|
exports.updateConfig = updateConfig;
|
|
39
38
|
exports.resolveAuthDisabled = resolveAuthDisabled;
|
|
39
|
+
exports.resolveMaxConcurrentRecordings = resolveMaxConcurrentRecordings;
|
|
40
|
+
exports.resolveRecordingsAssetsPath = resolveRecordingsAssetsPath;
|
|
41
|
+
exports.recordingConfigFrom = recordingConfigFrom;
|
|
40
42
|
const os = __importStar(require("os"));
|
|
41
43
|
const path = __importStar(require("path"));
|
|
42
44
|
const basePath = path.join(os.homedir(), '.cache', 'xenon');
|
|
45
|
+
/** Where free-form recordings go unless the option or the environment says otherwise. */
|
|
46
|
+
const DEFAULT_RECORDINGS_ASSETS_PATH = path.join(basePath, 'assets', 'sessions', 'recordings');
|
|
47
|
+
/** The server-wide cap on simultaneous free-form recordings, unless set. */
|
|
48
|
+
exports.DEFAULT_MAX_CONCURRENT_RECORDINGS = 4;
|
|
43
49
|
exports.config = {
|
|
44
50
|
cacheDir: basePath,
|
|
45
51
|
databaseProvider: process.env.XENON_DB_PROVIDER || 'sqlite',
|
|
@@ -87,9 +93,8 @@ exports.config = {
|
|
|
87
93
|
passwordResetLogFallback: process.env.XENON_PASSWORD_RESET_LOG_FALLBACK === 'true',
|
|
88
94
|
resetRateLimitAttempts: Number(process.env.XENON_RESET_RATE_LIMIT_ATTEMPTS) || 3,
|
|
89
95
|
resetRateLimitWindowMs: Number(process.env.XENON_RESET_RATE_LIMIT_WINDOW_MS) || 15 * 60 * 1000,
|
|
90
|
-
recordingsAssetsPath: process.env.XENON_RECORDINGS_ASSETS_PATH
|
|
91
|
-
|
|
92
|
-
maxConcurrentRecordings: Number((_a = process.env.XENON_MAX_CONCURRENT_RECORDINGS) !== null && _a !== void 0 ? _a : 4),
|
|
96
|
+
recordingsAssetsPath: resolveRecordingsAssetsPath(undefined, process.env.XENON_RECORDINGS_ASSETS_PATH),
|
|
97
|
+
maxConcurrentRecordings: resolveMaxConcurrentRecordings(undefined, process.env.XENON_MAX_CONCURRENT_RECORDINGS),
|
|
93
98
|
};
|
|
94
99
|
function updateConfig(newConfig) {
|
|
95
100
|
Object.assign(exports.config, newConfig);
|
|
@@ -113,3 +118,43 @@ function updateConfig(newConfig) {
|
|
|
113
118
|
function resolveAuthDisabled(pluginArgValue, envDisabled) {
|
|
114
119
|
return pluginArgValue === true || envDisabled === true;
|
|
115
120
|
}
|
|
121
|
+
function wholeNumberAtLeastOne(value) {
|
|
122
|
+
return typeof value === 'number' && Number.isInteger(value) && value >= 1 ? value : undefined;
|
|
123
|
+
}
|
|
124
|
+
function nonBlankString(value) {
|
|
125
|
+
return typeof value === 'string' && value.trim() !== '' ? value.trim() : undefined;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* The cap on simultaneous free-form recordings: the `maxConcurrentRecordings`
|
|
129
|
+
* plugin option when it is set, else XENON_MAX_CONCURRENT_RECORDINGS, else 4.
|
|
130
|
+
* Both options are `schema.json` options Appium accepts, but only the variable
|
|
131
|
+
* was ever read. A value that is not a whole number of at least 1 is ignored,
|
|
132
|
+
* so the next source answers: the variable used to be taken as `Number(env)`,
|
|
133
|
+
* and `many` made that NaN, which no recording count exceeds (no cap at all).
|
|
134
|
+
* Pure, so the precedence is testable without booting a server.
|
|
135
|
+
*/
|
|
136
|
+
function resolveMaxConcurrentRecordings(optionValue, envValue) {
|
|
137
|
+
var _a, _b;
|
|
138
|
+
const fromEnv = (envValue === null || envValue === void 0 ? void 0 : envValue.trim()) ? Number(envValue) : undefined;
|
|
139
|
+
return ((_b = (_a = wholeNumberAtLeastOne(optionValue)) !== null && _a !== void 0 ? _a : wholeNumberAtLeastOne(fromEnv)) !== null && _b !== void 0 ? _b : exports.DEFAULT_MAX_CONCURRENT_RECORDINGS);
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Where free-form recordings are stored: the `recordingsAssetsPath` plugin
|
|
143
|
+
* option when it is set, else XENON_RECORDINGS_ASSETS_PATH, else
|
|
144
|
+
* `~/.cache/xenon/assets/sessions/recordings`. A blank value counts as unset.
|
|
145
|
+
*/
|
|
146
|
+
function resolveRecordingsAssetsPath(optionValue, envValue) {
|
|
147
|
+
var _a, _b;
|
|
148
|
+
return (_b = (_a = nonBlankString(optionValue)) !== null && _a !== void 0 ? _a : nonBlankString(envValue)) !== null && _b !== void 0 ? _b : DEFAULT_RECORDINGS_ASSETS_PATH;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* The part of `config` the recording plugin options set, from the options the
|
|
152
|
+
* server started with and the environment as it is now. Applied at boot,
|
|
153
|
+
* before the artifact store and the concurrency gate read them.
|
|
154
|
+
*/
|
|
155
|
+
function recordingConfigFrom(pluginArgs, env = process.env) {
|
|
156
|
+
return {
|
|
157
|
+
maxConcurrentRecordings: resolveMaxConcurrentRecordings(pluginArgs.maxConcurrentRecordings, env.XENON_MAX_CONCURRENT_RECORDINGS),
|
|
158
|
+
recordingsAssetsPath: resolveRecordingsAssetsPath(pluginArgs.recordingsAssetsPath, env.XENON_RECORDINGS_ASSETS_PATH),
|
|
159
|
+
};
|
|
160
|
+
}
|