agent-device 0.20.6 → 0.20.7

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.
Files changed (175) hide show
  1. package/README.md +3 -3
  2. package/android/ime-helper/dist/{agent-device-android-ime-helper-0.20.6.apk → agent-device-android-ime-helper-0.20.7.apk} +0 -0
  3. package/android/ime-helper/dist/agent-device-android-ime-helper-0.20.7.apk.sha256 +1 -0
  4. package/android/ime-helper/dist/{agent-device-android-ime-helper-0.20.6.manifest.json → agent-device-android-ime-helper-0.20.7.manifest.json} +4 -4
  5. package/android/snapshot-helper/dist/{agent-device-android-snapshot-helper-0.20.6.apk → agent-device-android-snapshot-helper-0.20.7.apk} +0 -0
  6. package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.20.7.apk.sha256 +1 -0
  7. package/android/snapshot-helper/dist/{agent-device-android-snapshot-helper-0.20.6.manifest.json → agent-device-android-snapshot-helper-0.20.7.manifest.json} +6 -6
  8. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunner/AgentDeviceRunnerApp.m +20 -0
  9. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerAXSnapshotBridge.h +67 -0
  10. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerAXSnapshotBridge.m +339 -4
  11. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerSelectorMatchPolicy.swift +78 -0
  12. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+AXSnapshotFallback.swift +31 -2
  13. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+CommandExecution.swift +29 -7
  14. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+CoordinateTextEntryTests.swift +4 -0
  15. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Interaction.swift +36 -28
  16. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Models.swift +7 -0
  17. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SelectorMatchPolicyTests.swift +4 -0
  18. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Snapshot.swift +2 -1
  19. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SnapshotCapturePlan.swift +100 -12
  20. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedGesturePolicy.swift +4 -0
  21. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedTextEntry.swift +57 -0
  22. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextEntry.swift +1 -0
  23. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextTyping.swift +18 -3
  24. package/dist/src/agent-browser-tool.js +1 -1
  25. package/dist/src/agent-device-client.js +2 -2
  26. package/dist/src/android-adb.js +1 -1
  27. package/dist/src/android.js +1 -1
  28. package/dist/src/app-helpers.js +1 -1
  29. package/dist/src/app-lifecycle.js +7 -7
  30. package/dist/src/app-lifecycle2.js +2 -0
  31. package/dist/src/app-log-files.js +1 -0
  32. package/dist/src/app-log-reconnect.js +1 -0
  33. package/dist/src/app-log-runtime.js +4 -0
  34. package/dist/src/app-resolution.js +2 -1
  35. package/dist/src/apps.js +5 -5
  36. package/dist/src/audio-probe.js +1 -1
  37. package/dist/src/auth-session.js +1 -0
  38. package/dist/src/auth.js +2 -0
  39. package/dist/src/boot-diagnostics.js +2 -2
  40. package/dist/src/cli-config.js +1 -1
  41. package/dist/src/cli-grammar.js +1 -0
  42. package/dist/src/cli-help.js +199 -259
  43. package/dist/src/cli-output.js +1 -0
  44. package/dist/src/cli-runner.js +1 -2
  45. package/dist/src/cli.js +6 -16
  46. package/dist/src/client-metro.js +1 -1
  47. package/dist/src/cloud-artifacts.d.ts +2 -137
  48. package/dist/src/command-schema.js +3 -3
  49. package/dist/src/connection-runtime.js +1 -0
  50. package/dist/src/connection.js +5 -0
  51. package/dist/src/context.js +1 -1
  52. package/dist/src/daemon-shutdown-report.js +1 -0
  53. package/dist/src/daemon.js +2 -0
  54. package/dist/src/debug-symbols.js +3 -3
  55. package/dist/src/device-claim-inspection.js +1 -0
  56. package/dist/src/device-input-state.js +2 -2
  57. package/dist/src/device.js +1 -1
  58. package/dist/src/device2.js +2 -0
  59. package/dist/src/find.js +1 -1
  60. package/dist/src/finders.js +1 -1
  61. package/dist/src/generic-settle.js +1 -1
  62. package/dist/src/generic.js +1 -1
  63. package/dist/src/harmonyos.js +1 -0
  64. package/dist/src/helper.js +1 -1
  65. package/dist/src/host-process.js +2 -2
  66. package/dist/src/ime-lifecycle.js +7 -7
  67. package/dist/src/index.d.ts +43 -12
  68. package/dist/src/input-actions.js +4 -4
  69. package/dist/src/input-actions2.js +1 -1
  70. package/dist/src/input-actions3.js +1 -0
  71. package/dist/src/install-artifact.js +1 -5
  72. package/dist/src/install-artifact2.js +1 -1
  73. package/dist/src/install-source2.js +1 -1
  74. package/dist/src/interaction-runtime.js +1 -1
  75. package/dist/src/interaction-snapshot.js +1 -1
  76. package/dist/src/interaction-touch-reference-frame.js +1 -1
  77. package/dist/src/interaction.js +1 -1
  78. package/dist/src/interactor.js +2 -2
  79. package/dist/src/interactor2.js +1 -1
  80. package/dist/src/internal/bin.js +2 -2
  81. package/dist/src/internal/daemon.js +8 -15
  82. package/dist/src/inventory.js +5 -0
  83. package/dist/src/inventory2.js +1 -0
  84. package/dist/src/inventory3.js +2 -0
  85. package/dist/src/inventory4.js +1 -0
  86. package/dist/src/inventory5.js +1 -0
  87. package/dist/src/inventory6.js +1 -0
  88. package/dist/src/lease-context.js +1 -1
  89. package/dist/src/lease.js +1 -1
  90. package/dist/src/limrun-runtime-dependencies.js +1 -0
  91. package/dist/src/limrun.d.ts +10 -125
  92. package/dist/src/limrun.js +1 -1
  93. package/dist/src/linux.js +1 -1
  94. package/dist/src/logcat.js +1 -1
  95. package/dist/src/manifest.js +1 -1
  96. package/dist/src/owner-identity.js +1 -0
  97. package/dist/src/physical-device-control.js +1 -1
  98. package/dist/src/platform-runtime-app-log-android-transport.js +1 -0
  99. package/dist/src/platform-runtime-app-log-process.js +1 -0
  100. package/dist/src/platform-runtime-host.js +1 -0
  101. package/dist/src/platform-runtime-network-web-transport.js +1 -0
  102. package/dist/src/platform-runtime-operation-host.js +5 -0
  103. package/dist/src/platform-runtime-toolchain-host.js +1 -0
  104. package/dist/src/platform-runtime.js +1 -0
  105. package/dist/src/prepare-kind.js +15 -0
  106. package/dist/src/process-entry.js +1 -0
  107. package/dist/src/process-lock.js +1 -1
  108. package/dist/src/provider-webdriver.js +1 -0
  109. package/dist/src/provider.js +1 -0
  110. package/dist/src/proxy.js +2 -0
  111. package/dist/src/react-native.js +1 -1
  112. package/dist/src/record-trace.js +1 -1
  113. package/dist/src/registry.js +24 -24
  114. package/dist/src/remote-config2.js +1 -1
  115. package/dist/src/replay.js +3 -0
  116. package/dist/src/reporting.js +3 -3
  117. package/dist/src/runner-client.js +1 -1
  118. package/dist/src/runner-disposal.js +1 -1
  119. package/dist/src/runner-lease.js +1 -1
  120. package/dist/src/runtime.js +2 -2
  121. package/dist/src/runtime2.js +4 -0
  122. package/dist/src/runtime3.js +3 -0
  123. package/dist/src/runtime4.js +1 -0
  124. package/dist/src/runtime5.js +1 -0
  125. package/dist/src/runtime6.js +1 -0
  126. package/dist/src/runtime7.js +1 -0
  127. package/dist/src/screenshot-result.js +4 -4
  128. package/dist/src/screenshot.js +1 -0
  129. package/dist/src/sdk-android-adb.js +2 -2
  130. package/dist/src/sdk-batch-runner.js +3 -3
  131. package/dist/src/sdk-contracts.d.ts +31 -5
  132. package/dist/src/sdk-contracts.js +1 -1
  133. package/dist/src/sdk-device.js +1 -1
  134. package/dist/src/sdk-finders.js +1 -1
  135. package/dist/src/sdk-remote-config.js +1 -1
  136. package/dist/src/sdk-selectors.d.ts +280 -4
  137. package/dist/src/sdk-selectors.js +1 -1
  138. package/dist/src/selector-runtime.js +1 -1
  139. package/dist/src/selector-vocabulary.js +1 -1
  140. package/dist/src/selectors.js +1 -1
  141. package/dist/src/server.js +3 -3
  142. package/dist/src/session-target-evidence.js +1 -1
  143. package/dist/src/session.js +10 -9
  144. package/dist/src/shared.js +2 -0
  145. package/dist/src/shell-quote.js +1 -0
  146. package/dist/src/simulator.js +1 -1
  147. package/dist/src/snapshot-runtime.js +1 -0
  148. package/dist/src/snapshot-session.js +1 -0
  149. package/dist/src/snapshot.js +1 -1
  150. package/dist/src/snapshot2.js +1 -1
  151. package/dist/src/src.js +1 -1
  152. package/dist/src/src2.js +2 -0
  153. package/dist/src/src3.js +1 -0
  154. package/dist/src/text-surface.js +1 -1
  155. package/dist/src/timing-safe-equal.js +1 -0
  156. package/dist/src/tool-provider.js +3 -3
  157. package/dist/src/tool-provider2.js +1 -1
  158. package/dist/src/tool-provider3.js +1 -1
  159. package/dist/src/update-check.js +1 -1
  160. package/dist/src/version.js +1 -1
  161. package/dist/src/web.js +1 -1
  162. package/package.json +36 -20
  163. package/server.json +2 -2
  164. package/skills/agent-device/SKILL.md +6 -31
  165. package/android/ime-helper/dist/agent-device-android-ime-helper-0.20.6.apk.sha256 +0 -1
  166. package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.20.6.apk.sha256 +0 -1
  167. package/dist/src/app-log-request-scope.js +0 -1
  168. package/dist/src/devices.js +0 -1
  169. package/dist/src/devices2.js +0 -1
  170. package/dist/src/devices3.js +0 -1
  171. package/dist/src/devices4.js +0 -1
  172. package/dist/src/provider-limrun-runtime.js +0 -1
  173. package/dist/src/register-builtins.js +0 -1
  174. package/dist/src/screenshot-geometry.js +0 -1
  175. package/dist/src/viewport-dimension.js +0 -15
@@ -1,11 +1,281 @@
1
- import { A as SnapshotNode, N as SnapshotState, U as PublicPlatform, V as Platform, m as ResponseCost } from "./sdk-contracts.js";
1
+ import { A as SnapshotNode, D as Rect, E as RawSnapshotNode, M as SnapshotQualityVerdict, N as SnapshotState, O as ScreenshotOverlayRef, T as Point, U as PublicPlatform, V as Platform, j as SnapshotOptions$1, k as SnapshotBackend, m as ResponseCost } from "./sdk-contracts.js";
2
+ import { c as ScrollDirection, o as GesturePlan } from "./sdk-android-adb.js";
3
+ //#region packages/contracts/src/back-mode.d.ts
4
+ declare const BACK_MODES: readonly ['in-app', 'system'];
5
+ type BackMode = (typeof BACK_MODES)[number];
6
+ //#endregion
2
7
  //#region packages/contracts/src/click-button.d.ts
3
8
  declare const CLICK_BUTTONS: readonly ['primary', 'secondary', 'middle'];
4
9
  type ClickButton = (typeof CLICK_BUTTONS)[number];
5
10
  //#endregion
11
+ //#region packages/contracts/src/device-rotation.d.ts
12
+ declare const DEVICE_ROTATIONS: readonly ['portrait', 'portrait-upside-down', 'landscape-left', 'landscape-right'];
13
+ type DeviceRotation = (typeof DEVICE_ROTATIONS)[number];
14
+ //#endregion
15
+ //#region packages/contracts/src/tv-remote.d.ts
16
+ declare const TV_REMOTE_BUTTON_DEFINITIONS: {
17
+ readonly up: {
18
+ readonly aliases: readonly [];
19
+ readonly androidKeyevent: 'KEYCODE_DPAD_UP';
20
+ readonly appleRemoteButton: 'up';
21
+ readonly vegaKey: 'KEY_UP';
22
+ };
23
+ readonly down: {
24
+ readonly aliases: readonly [];
25
+ readonly androidKeyevent: 'KEYCODE_DPAD_DOWN';
26
+ readonly appleRemoteButton: 'down';
27
+ readonly vegaKey: 'KEY_DOWN';
28
+ };
29
+ readonly left: {
30
+ readonly aliases: readonly [];
31
+ readonly androidKeyevent: 'KEYCODE_DPAD_LEFT';
32
+ readonly appleRemoteButton: 'left';
33
+ readonly vegaKey: 'KEY_LEFT';
34
+ };
35
+ readonly right: {
36
+ readonly aliases: readonly [];
37
+ readonly androidKeyevent: 'KEYCODE_DPAD_RIGHT';
38
+ readonly appleRemoteButton: 'right';
39
+ readonly vegaKey: 'KEY_RIGHT';
40
+ };
41
+ readonly select: {
42
+ readonly aliases: readonly ["ok", "center", "enter"];
43
+ readonly androidKeyevent: 'KEYCODE_DPAD_CENTER';
44
+ readonly appleRemoteButton: 'select';
45
+ readonly vegaKey: 'KEY_ENTER';
46
+ };
47
+ readonly menu: {
48
+ readonly aliases: readonly [];
49
+ readonly androidKeyevent: 'KEYCODE_MENU';
50
+ readonly appleRemoteButton: 'menu';
51
+ readonly vegaKey: 'KEY_MENU';
52
+ };
53
+ readonly home: {
54
+ readonly aliases: readonly [];
55
+ readonly androidKeyevent: 'KEYCODE_HOME';
56
+ readonly appleRemoteButton: 'home';
57
+ readonly vegaKey: 'KEY_HOMEPAGE';
58
+ };
59
+ readonly back: {
60
+ readonly aliases: readonly [];
61
+ readonly androidKeyevent: 'KEYCODE_BACK';
62
+ readonly appleRemoteButton: 'menu';
63
+ readonly vegaKey: 'KEY_BACK';
64
+ };
65
+ };
66
+ declare const TV_REMOTE_BUTTONS: (keyof typeof TV_REMOTE_BUTTON_DEFINITIONS)[];
67
+ type TvRemoteButton = (typeof TV_REMOTE_BUTTONS)[number];
68
+ //#endregion
69
+ //#region packages/contracts/src/settings.d.ts
70
+ type SettingOptions = {
71
+ permissionTarget?: string;
72
+ permissionMode?: string;
73
+ latitude?: number;
74
+ longitude?: number;
75
+ };
76
+ //#endregion
77
+ //#region packages/contracts/src/session-surface.d.ts
78
+ declare const SESSION_SURFACES: readonly ['app', 'frontmost-app', 'desktop', 'menubar'];
79
+ type SessionSurface = (typeof SESSION_SURFACES)[number];
80
+ //#endregion
81
+ //#region packages/contracts/src/snapshot-diagnostics.d.ts
82
+ type SnapshotTimingStats = {
83
+ count: number;
84
+ p50Ms: number;
85
+ p95Ms: number;
86
+ maxMs: number;
87
+ slowThresholdMs: number;
88
+ platform?: PublicPlatform;
89
+ backends?: Record<string, number>;
90
+ };
91
+ type SnapshotDiagnosticsSummary = {
92
+ stats: SnapshotTimingStats;
93
+ warning?: string;
94
+ };
95
+ //#endregion
96
+ //#region packages/contracts/src/snapshot-types.d.ts
97
+ type ScreenshotResultData = {
98
+ path?: string;
99
+ width?: number;
100
+ height?: number;
101
+ logicalWidth?: number;
102
+ logicalHeight?: number;
103
+ pixelDensity?: number;
104
+ overlayRefs?: ScreenshotOverlayRef[];
105
+ };
106
+ type BackendSnapshotResult = {
107
+ nodes?: SnapshotNode[];
108
+ truncated?: boolean;
109
+ backend?: string;
110
+ snapshot?: SnapshotState;
111
+ appName?: string;
112
+ appBundleId?: string;
113
+ snapshotDiagnostics?: SnapshotDiagnosticsSummary;
114
+ analysis?: {
115
+ rawNodeCount: number;
116
+ maxDepth: number;
117
+ };
118
+ androidSnapshot?: AndroidSnapshotBackendMetadata;
119
+ freshness?: {
120
+ action: string;
121
+ retryCount: number;
122
+ staleAfterRetries: boolean;
123
+ reason?: 'empty-interactive' | 'sharp-drop' | 'stuck-route';
124
+ };
125
+ quality?: SnapshotQualityVerdict;
126
+ warnings?: string[];
127
+ };
128
+ type AndroidSnapshotBackendMetadata = {
129
+ backend: 'android-helper';
130
+ helperVersion?: string;
131
+ helperApiVersion?: string;
132
+ helperTransport?: string;
133
+ helperSessionReused?: boolean;
134
+ installReason?: string;
135
+ waitForIdleTimeoutMs?: number;
136
+ waitForIdleQuietMs?: number;
137
+ timeoutMs?: number;
138
+ maxDepth?: number;
139
+ maxNodes?: number;
140
+ rootPresent?: boolean;
141
+ captureMode?: string;
142
+ systemSurfaceOnly?: boolean;
143
+ windowCount?: number;
144
+ nodeCount?: number;
145
+ helperTruncated?: boolean;
146
+ elapsedMs?: number;
147
+ };
148
+ type FindLocator = 'any' | 'text' | 'label' | 'value' | 'role' | 'id';
149
+ //#endregion
150
+ //#region packages/contracts/src/runner-lease-context.d.ts
151
+ type RunnerLogicalLeaseContext = {
152
+ leaseId?: string;
153
+ clientId?: string;
154
+ tenantId?: string;
155
+ runId?: string;
156
+ leaseProvider?: string;
157
+ deviceKey?: string;
158
+ };
159
+ //#endregion
160
+ //#region packages/contracts/src/interactor-types.d.ts
161
+ type RunnerContext = {
162
+ requestId?: string;
163
+ signal?: AbortSignal;
164
+ appBundleId?: string;
165
+ verbose?: boolean;
166
+ logPath?: string;
167
+ traceLogPath?: string;
168
+ iosXctestrunFile?: string;
169
+ iosXctestDerivedDataPath?: string;
170
+ iosXctestEnvDir?: string;
171
+ runnerLeaseContext?: RunnerLogicalLeaseContext;
172
+ };
173
+ type ScreenshotOptions = {
174
+ appBundleId?: string;
175
+ pixelDensity?: number;
176
+ fullscreen?: boolean;
177
+ normalizeStatusBar?: boolean;
178
+ stabilize?: boolean;
179
+ surface?: SessionSurface;
180
+ skipIosSimulatorBootCheck?: boolean;
181
+ captureBackend?: 'runner';
182
+ };
183
+ type ElementSelectorKey = 'id' | 'label' | 'text' | 'value';
184
+ type ElementSelectorTapOptions = {
185
+ key: ElementSelectorKey;
186
+ value: string;
187
+ allowNonHittableCoordinateFallback?: boolean;
188
+ expectedPoint?: Point;
189
+ };
190
+ /**
191
+ * The channel the XCTest runner actually entered text through — the Swift
192
+ * `TextEntryResult.textEntryRoute` (RunnerTests+TextTyping.swift,
193
+ * RunnerTests+SynthesizedTextEntry.swift). Closed set, because the runner is
194
+ * its only producer and the boundary that narrows it
195
+ * (readTypeTextBackendResult, src/platforms/apple/interactions.ts) drops a
196
+ * route it cannot name — so a Swift-side addition would silently vanish. The
197
+ * route-parity test in src/platforms/apple/core/__tests__/interactions.test.ts
198
+ * reads the Swift sources and fails instead.
199
+ */
200
+ declare const TEXT_ENTRY_ROUTES: readonly ['xctest-element', 'synthesized-first-responder', 'synthesized-first-responder-replacement', 'xctest-application-fallback'];
201
+ type TextEntryRoute = (typeof TEXT_ENTRY_ROUTES)[number];
202
+ /**
203
+ * What `Interactor.type` reports back about the entry it performed. Only the
204
+ * Apple runner populates it; every other platform types blind and returns void.
205
+ */
206
+ type TypeTextBackendResult = {
207
+ textEntryRoute?: TextEntryRoute;
208
+ };
209
+ type FillVerificationTarget = {
210
+ resourceId: string | null;
211
+ className: string | null;
212
+ packageName: string | null;
213
+ rect: Rect;
214
+ };
215
+ type FillUnconfirmedVerification = {
216
+ verification: 'unconfirmed';
217
+ requested: string;
218
+ before: string | null;
219
+ after: string | null;
220
+ target: FillVerificationTarget;
221
+ };
222
+ type SnapshotOptions = SnapshotOptions$1 & {
223
+ appBundleId?: string;
224
+ signal?: AbortSignal;
225
+ includeRects?: boolean;
226
+ includeHiddenContentHints?: boolean;
227
+ surface?: SessionSurface;
228
+ };
229
+ type SnapshotResult = Omit<BackendSnapshotResult, 'backend' | 'nodes'> & {
230
+ nodes?: RawSnapshotNode[];
231
+ backend: Extract<SnapshotBackend, 'android' | 'harmonyos-arkui' | 'xctest' | 'linux-atspi' | 'web'>;
232
+ };
233
+ type Interactor = {
234
+ open(app: string, options?: {
235
+ activity?: string;
236
+ appBundleId?: string;
237
+ launchConsole?: string;
238
+ launchArgs?: string[];
239
+ terminateRunningApp?: boolean;
240
+ url?: string;
241
+ }): Promise<void>;
242
+ openDevice(): Promise<void>;
243
+ close(app: string): Promise<void>;
244
+ tap(x: number, y: number): Promise<Record<string, unknown> | void>;
245
+ tapElementSelector?(selector: ElementSelectorTapOptions): Promise<Record<string, unknown> | void>;
246
+ doubleTap(x: number, y: number): Promise<Record<string, unknown> | void>;
247
+ longPress(x: number, y: number, durationMs?: number): Promise<Record<string, unknown> | void>;
248
+ focus(x: number, y: number): Promise<Record<string, unknown> | void>;
249
+ type(text: string, delayMs?: number): Promise<TypeTextBackendResult | void>;
250
+ fillElementSelector?(selector: ElementSelectorTapOptions, text: string, delayMs?: number): Promise<Record<string, unknown> | void>;
251
+ fill(x: number, y: number, text: string, delayMs?: number, options?: {
252
+ allowNonHittableCoordinateFallback?: boolean;
253
+ }): Promise<Record<string, unknown> | void>;
254
+ scroll(direction: ScrollDirection, options?: {
255
+ amount?: number;
256
+ pixels?: number;
257
+ durationMs?: number;
258
+ }): Promise<Record<string, unknown> | void>;
259
+ screenshot(outPath: string, options?: ScreenshotOptions): Promise<void>;
260
+ setViewport?(width: number, height: number): Promise<Record<string, unknown> | void>;
261
+ snapshot(options?: SnapshotOptions): Promise<SnapshotResult>;
262
+ gestureViewport?(): Promise<Rect>;
263
+ back(mode?: BackMode): Promise<void>;
264
+ home(): Promise<void>;
265
+ setOrientation(orientation: DeviceRotation): Promise<{
266
+ orientation?: DeviceRotation;
267
+ } | void>;
268
+ performGesture?(plan: GesturePlan): Promise<Record<string, unknown> | void>;
269
+ appSwitcher(): Promise<void>;
270
+ tvRemote(button: TvRemoteButton, durationMs?: number): Promise<void>;
271
+ readClipboard(): Promise<string>;
272
+ writeClipboard(text: string): Promise<void>;
273
+ setSetting(setting: string, state: string, appId?: string, options?: SettingOptions): Promise<Record<string, unknown> | void>;
274
+ };
275
+ //#endregion
6
276
  //#region packages/contracts/src/interaction.d.ts
7
277
  /** The decisive criterion separating a resolveSelectorChain winner from its strongest runner-up (ADR 0012). */
8
- type DisambiguationTiebreak = 'visible' | 'deepest' | 'smallest-area';
278
+ type DisambiguationTiebreak = 'visible' | 'deepest' | 'smallest-area' | 'structural-equivalence';
9
279
  /**
10
280
  * A disambiguation winner or losing alternative. `diagnosticRef` is an opaque,
11
281
  * non-`@` token — never a snapshot ref, never issued via `refsGeneration`,
@@ -196,7 +466,13 @@ type ClickCommandResponseData = PressCommandResponseData;
196
466
  type TouchFillExtras = {
197
467
  text: string;
198
468
  delayMs?: number;
199
- };
469
+ } & ({
470
+ verification?: never;
471
+ requested?: never;
472
+ before?: never;
473
+ after?: never;
474
+ target?: never;
475
+ } | FillUnconfirmedVerification);
200
476
  type FillCommandResponseData = (TouchResponsePoint & TouchFillExtras) | (TouchResponseRef & TouchFillExtras) | (TouchResponseSelector & TouchFillExtras);
201
477
  type TouchLongPressExtras = {
202
478
  durationMs?: number;
@@ -322,4 +598,4 @@ declare function formatSelectorFailure(chain: SelectorChain | string, diagnostic
322
598
  unique?: boolean;
323
599
  }): string;
324
600
  //#endregion
325
- export { ClickButton as _, resolveSelectorChain as a, parseSelectorChain as c, ClickCommandResponseData as d, FillCommandResponseData as f, SettleObservation as g, PressCommandResponseData as h, findSelectorChainMatch as i, tryParseSelectorChain as l, LongPressCommandResponseData as m, isNodeEditable as n, SelectorChain as o, FindCommandResponseData as p, isNodeVisible as r, isSelectorToken as s, formatSelectorFailure as t, SelectorDiagnostics as u };
601
+ export { SessionSurface as C, BackMode as D, ClickButton as E, SnapshotDiagnosticsSummary as S, DeviceRotation as T, Interactor as _, resolveSelectorChain as a, FindLocator as b, parseSelectorChain as c, ClickCommandResponseData as d, FillCommandResponseData as f, SettleObservation as g, PressCommandResponseData as h, findSelectorChainMatch as i, tryParseSelectorChain as l, LongPressCommandResponseData as m, isNodeEditable as n, SelectorChain as o, FindCommandResponseData as p, isNodeVisible as r, isSelectorToken as s, formatSelectorFailure as t, SelectorDiagnostics as u, RunnerContext as v, TvRemoteButton as w, ScreenshotResultData as x, AndroidSnapshotBackendMetadata as y };
@@ -1 +1 @@
1
- import{wt as e}from"./sdk-batch-runner.js";function t(t,n,r){return e(typeof t==`string`?t:t.raw,n,r)}export{t};
1
+ import{tn as e}from"./sdk-batch-runner.js";function t(t,n,r){return e(typeof t==`string`?t:t.raw,n,r)}export{t};
@@ -1 +1 @@
1
- import{S as e,_ as t,h as n,l as r,m as i,s as a,v as o}from"./sdk-contracts.js";import{y as s}from"./screenshot-geometry.js";import{At as c,D as l,Mt as u,P as d,_t as f,bt as p,en as m,gt as ee,ht as te,vt as ne}from"./sdk-batch-runner.js";import{c as re,h as ie,o as ae,s as h}from"./sdk-device.js";import{G as oe,I as se,a as g,q as ce,tt as le}from"./viewport-dimension.js";import{N as ue}from"./screenshot-result.js";import{i as de}from"./session-target-evidence.js";import{i as fe}from"./text-surface.js";import{S as _}from"./device.js";import{a as pe,n as me,t as he}from"./runtime.js";import{j as v}from"./sdk-android-adb.js";import{r as ge}from"./app-lifecycle.js";import{h as y}from"./ime-lifecycle.js";import{N as _e}from"./runner-disposal.js";import{S as b,c as ve,g as x,l as S,n as ye,s as C,t as be}from"./context.js";import{C as xe}from"./physical-device-control.js";import{a as Se,l as Ce}from"./runner-client.js";import{Bt as we,Ht as Te,Rt as Ee,Vt as De,Xt as Oe,en as ke,h as Ae,rn as je,u as Me}from"./internal/daemon.js";import{a as Ne}from"./apps.js";const Pe=[[`snapshotDepth`,`--depth`],[`snapshotScope`,`--scope`],[`snapshotRaw`,`--raw`]];function Fe(e,t){let n=Ie(t);return n.length===0?null:C(`INVALID_ARGS`,`${e} @ref does not support ${n.join(`, `)}.`)}function Ie(e){if(!e)return[];let t=[];for(let[n,r]of Pe)e[n]!==void 0&&t.push(r);return t}function Le(e,t){if(!t||t.settle===!0)return null;let n=[];return t.settleQuietMs!==void 0&&n.push(`--settle-quiet`),n.length===0?null:C(`INVALID_ARGS`,`${e}: ${n.join(`, `)} require${n.length===1?`s`:``} --settle.`)}function Re(e){if(e?.settle===!0)return{...e.settleQuietMs===void 0?{}:{quietMs:e.settleQuietMs},...e.timeoutMs===void 0?{}:{timeoutMs:e.timeoutMs}}}function ze(e,n={}){let r=n.plural===!0?`do`:`does`;return{resolveInput:async()=>{throw new t(`UNSUPPORTED_OPERATION`,`${e} ${r} not resolve input artifacts`)},reserveOutput:async()=>{throw new t(`UNSUPPORTED_OPERATION`,`${e} ${r} not reserve output artifacts`)},createTempFile:async()=>{throw new t(`UNSUPPORTED_OPERATION`,`${e} ${r} not create temporary files`)}}}function Be(e,t={}){return{artifacts:ze(e,t),policy:me()}}function w(e){if(e.length<2)return null;let t=Number(e[0]),n=Number(e[1]);return!Number.isFinite(t)||!Number.isFinite(n)?null:{x:t,y:n}}function T(e){let t=n(e);return t?{ok:!0,ref:t.base,generation:t.generation}:{ok:!1,response:C(`INVALID_ARGS`,`Invalid ref "${e}" — malformed generation suffix.`,{hint:a})}}function E(e,t){let n=w(e);if(n)return{ok:!0,target:{kind:`point`,x:n.x,y:n.y}};let r=e[0]??``;if(r.startsWith(`@`)){let t=T(r);return t.ok?{ok:!0,target:{kind:`ref`,ref:t.ref,fallbackLabel:e.slice(1).join(` `).trim()},refGeneration:t.generation}:{ok:!1,response:t.response}}let i=e.join(` `).trim();return i?{ok:!0,target:{kind:`selector`,selector:i}}:{ok:!1,response:C(`INVALID_ARGS`,`${t} requires @ref, selector expression, or x y coordinates`)}}function Ve(e){let t=w(e);if(t)return{ok:!0,target:{kind:`point`,x:t.x,y:t.y},...Je(e[2])};let n=qe(e),r=E(n.targetPositionals,`longpress`);return r.ok?{ok:!0,target:r.target,refGeneration:r.refGeneration,...n.duration}:r}function He(e){let t=e[0]??``;if(t.startsWith(`@`)){let n=T(t);if(!n.ok)return{ok:!1,response:n.response};let r=g(e).text;return r?{ok:!0,target:{kind:`ref`,ref:n.ref,fallbackLabel:Ke(e)},refGeneration:n.generation,text:r}:{ok:!1,response:C(`INVALID_ARGS`,`fill requires text after ref`)}}let n=w(e);if(n){let t=e.slice(2).join(` `);return t?{ok:!0,target:{kind:`point`,x:n.x,y:n.y},text:t}:{ok:!1,response:C(`INVALID_ARGS`,`fill requires text after coordinates`)}}let r=Ue(e);return!r||r.kind!==`selector`?{ok:!1,response:C(`INVALID_ARGS`,`fill requires x y text, @ref text, or selector text`)}:r.text.trim()?{ok:!0,target:{kind:`selector`,selector:r.target.selector},text:r.text}:{ok:!1,response:C(`INVALID_ARGS`,`fill requires text after selector`)}}function Ue(e){try{return g(e)}catch{return null}}function We(e){let t=`evidence`in e?e.evidence:void 0,n=e.settle;return e.kind===`ref`?{ref:D(e.target?.kind===`ref`?e.target.ref:void 0),refLabel:e.refLabel,selectorChain:e.selectorChain,targetHittable:e.targetHittable,hint:e.hint,evidence:t,settle:n,resolution:e.resolution}:e.kind===`selector`?{selector:e.target?.kind===`selector`?e.target.selector:void 0,selectorChain:e.selectorChain,refLabel:e.refLabel,targetHittable:e.targetHittable,hint:e.hint,evidence:t,settle:n,resolution:e.resolution}:{evidence:t,settle:n}}function Ge(e,t){return e.kind===`point`?`coordinate tap`:t.kind===`ref`&&t.target?.kind===`ref`?t.target.ref:t.kind===`selector`&&t.target?.kind===`selector`?t.target.selector:`target`}function D(e){return e?.startsWith(`@`)?e.slice(1):e}function Ke(e){return e.length>=3&&e[1]?.trim()||``}function qe(e){let t=e.at(-1);return e.length>1&&Ye(t)?{targetPositionals:e.slice(0,-1),duration:{durationMs:Number(t)}}:{targetPositionals:e,duration:{}}}function Je(e){return e===void 0?{}:{durationMs:Number(e)}}function Ye(e){return e===void 0||e.trim()===``?!1:Number.isFinite(Number(e))}function O(e,t){return!(!e||!h(e.device)||b(e.device)||t.skipPendingPostGestureStabilization&&ke(e))}function k(e){let{session:t,selectorExpression:n}=e;return O(t,{skipPendingPostGestureStabilization:!0})?d(n):null}function Xe(e){let t=e.identifier?.trim();if(t)return{key:`id`,value:t};let n=e.label?.trim();return n?{key:`label`,value:n}:null}function A(e,t={}){let n=o(e);if(n.code===`ELEMENT_NOT_FOUND`)return t.delegateSemanticFailures===!0||t.allowElementNotFound===!0;if(n.code===`AMBIGUOUS_MATCH`)return t.delegateSemanticFailures===!0;if(n.code===`ELEMENT_OFFSCREEN`)return t.delegateSemanticFailures!==!1;if(n.code!==`COMMAND_FAILED`)return!1;let r=n.message.toLowerCase();return r.includes(`fetch failed`)||r.includes(`timed out`)||r.includes(`timeout`)||r.includes(`runner did not accept connection`)||r.includes(`invalid runner response`)}async function j(e,t,n){let r=e.get(t),i=r?.device??await x(n??{});return r||await Ae(i),{session:r,device:i}}async function M(e,t,n){let r=!e&&h(t);try{return await n()}finally{r&&(await Ce(t.id),await Ze(t))}}async function Ze(e){let t=xe();await Ne(e,t).catch(n=>{v({level:`debug`,phase:`ios_sessionless_runner_host_close_failed`,data:{deviceId:e.id,bundleId:t,error:n instanceof Error?n.message:String(n)}})})}function Qe(e,t,n,r){t&&e.recordAction(t,{command:n.command,positionals:n.positionals??[],flags:n.flags??{},result:r})}function $e(e){let{session:t,sessionName:n,device:r,snapshot:i,appBundleId:a}=e;return t?{...t,snapshot:i,lastComparisonSafeSnapshot:i?.comparisonSafe===!0?i:t.lastComparisonSafeSnapshot}:{name:n,device:r,createdAt:Date.now(),appBundleId:a,snapshot:i,...i?.comparisonSafe===!0?{lastComparisonSafeSnapshot:i}:{},actions:[]}}async function et(e,n){let r=await N(e);if(r){if(y(r.foregroundPackage))return`press ${n} opened an Android permission dialog (${r.foregroundPackage}) over ${r.expectedPackage}. ${r.hint}`;throw new t(`COMMAND_FAILED`,`press ${n} left ${e.appBundleId} and foregrounded ${r.foregroundPackage}. The tap likely escaped the app.`,r)}}async function N(e){if(e.device.platform!==`android`||!e.appBundleId)return null;let t=await ge(e.device),n=t.package?.trim();return!n||n===e.appBundleId||!it(n)?null:{expectedPackage:e.appBundleId,foregroundPackage:n,activity:t.activity,hint:rt(n)}}function tt(e){return y(e.foregroundPackage)?`Android permission dialog is blocking ${e.expectedPackage}`:`${e.foregroundPackage} is foreground instead of ${e.expectedPackage}`}function nt(e){return e.code===`COMMAND_FAILED`&&typeof e.details?.expectedPackage==`string`&&typeof e.details?.foregroundPackage==`string`}function rt(e){return y(e)?`Use "alert get" to inspect it, then "alert accept" or "alert dismiss" to respond.`:`Use screenshot as visual truth, then take a fresh snapshot -i before retrying.`}function it(e){return e===`com.android.settings`||e===`com.android.systemui`||y(e)||e.includes(`launcher`)}function at(e,t){if(t===`exists`)return{found:!0};if(t===`wait`)return{found:!0,waitedMs:e.waitedMs};if(t===`list`)return{action:`list`,matches:Array.isArray(e.matches)?e.matches.length:0};let n=typeof e.ref==`string`?e.ref:void 0;return t===`get_attrs`?{ref:n,action:`get attrs`}:{ref:n,action:`get text`,text:typeof e.text==`string`?e.text:``}}function ot(e){return e.kind===`found`?{found:!0,...typeof e.waitedMs==`number`?{waitedMs:e.waitedMs}:{}}:e.kind===`list`?{matches:e.matches.map(e=>({ref:e.ref,node:_(e.node)}))}:{ref:e.ref,...e.kind===`text`?{text:e.text}:{},node:_(e.node)}}function P(e,t){let n=Array.isArray(e.selectorChain)?e.selectorChain:void 0,r=lt(e),i=r?.kind===`ref`?z(r.ref):void 0,a=r?.kind===`selector`?r.selector:void 0,o={...i?{ref:i}:{},...a?{selector:a}:{},...n?{selectorChain:n}:{}};if(t===`attrs`)return o;let s=typeof e.text==`string`?e.text:``;return{...o,text:s,refLabel:ct(s)}}function F(e){let{target:t}=e;return{...t.kind===`ref`?{ref:z(t.ref)}:{},...t.kind===`selector`?{selector:t.selector}:{},...typeof e.text==`string`?{text:e.text}:{},node:_(e.node)}}function I(e){let{node:t,preActionNodes:n,...r}=e;return r}function st(e){return{waitedMs:e.waitedMs,...typeof e.text==`string`?{text:e.text}:{},...typeof e.selector==`string`?{selector:e.selector}:{},...typeof e.captures==`number`?{captures:e.captures}:{},...typeof e.nodeCount==`number`?{nodeCount:e.nodeCount}:{},...typeof e.hint==`string`?{hint:e.hint}:{}}}function L(e){let{selectorChain:t,...n}=e;return n}function R(e,t,n,r,i,a){let o=e.get(t);if(!o)return;let s=o.recordSession&&i?de(i,{mode:a}):void 0;e.recordAction(o,{command:n.command,positionals:n.positionals??[],flags:n.flags??{},result:r,interactiveObservation:ue(n),...s?{targetEvidence:s}:{}})}function ct(e){let t=e.trim();if(!(!t||t.length>80||/[\r\n]/.test(t)))return t}function lt(e){let t=e.target;if(!t||typeof t!=`object`)return;let n=t;if(n.kind===`ref`&&typeof n.ref==`string`)return{kind:`ref`,ref:n.ref};if(n.kind===`selector`&&typeof n.selector==`string`)return{kind:`selector`,selector:n.selector}}function z(e){return e.startsWith(`@`)?e.slice(1):e}const ut=[`application`,`window`,`tabbar`,`scrollbar`,`image`],dt=new Set([`tab bar`]);async function B(e,t){if(t.ok||!ft(t.error.details?.reason)||t.error.details?.captureStalled===!0||t.error.details?.captureTruncated===!0)return t;let n=await pt(e).catch(()=>null);return n?C(t.error.code,`${t.error.message}. Current surface: ${n.summary}.`,{...t.error.details??{},currentSurface:n.details}):t}function ft(e){return e===s.targetAbsent||e===s.stableTimeout}async function pt(e){let t=[...(await Oe({device:e.device,session:e.session,flags:{...e.req.flags,snapshotInteractiveOnly:!0},logPath:e.logPath??``})).snapshot.nodes].sort(mt),n=V(t,6,{includeIdentifiers:!0});if(n.length===0)return null;let r=V(t.filter(e=>!W(e)),4,{includeIdentifiers:!1}),i=V(t.filter(gt),4,{includeIdentifiers:!0});return{summary:(r.length>0?r:n.slice(0,4)).join(`, `),details:{labels:n,...i.length>0?{buttons:i}:{}}}}function V(e,t,n){let r=new Set,i=[];for(let a of e){let e=U(a,n);if(!(!e||r.has(e))&&(r.add(e),i.push(e),i.length>=t))break}return i}function mt(e,t){return H(e)-H(t)||ht(e,t)}function H(e){let t=!!U(e,{includeIdentifiers:!1});return(W(e)?2:0)+ +!t}function ht(e,t){return e.rect&&t.rect?e.rect.y-t.rect.y||e.rect.x-t.rect.x:e.rect?-1:t.rect?1:(e.depth??0)-(t.depth??0)||e.index-t.index}function U(e,t){let n=(t.includeIdentifiers?[e.label,e.value,e.identifier]:[e.label,e.value]).map(e=>typeof e==`string`?e.trim():``).find(e=>e.length>0);return n?n.replace(/\s+/g,` `).slice(0,80):``}function W(e){let t=m(`${e.type??``} ${e.role??``} ${e.subrole??``}`),n=`${e.label??``} ${e.value??``}`.trim().toLowerCase();return ut.some(e=>t.includes(e))||dt.has(n)||n.endsWith(`.fill`)}function gt(e){return m(`${e.type??``} ${e.role??``} ${e.subrole??``}`).includes(`button`)}function G(e,t){let n=pe(t);if(!n)return e;if(e.ok){let t=_t(e.data?.warning,n);return{...e,data:{...e.data,warning:t}}}let r=e.error.details??{};return{...e,error:{...e.error,details:{...r,hint:_t(r.hint,n)}}}}function _t(e,t){return typeof e==`string`&&e.trim()!==``?`${e}\n${t}`:t}async function vt(e){let{device:t,node:n,flags:r,appBundleId:i,traceOutPath:a,surface:o,contextFromFlags:s}=e,c=oe(n),l=le(n.rect);if(!l||h(t)&&c&&!fe(n.type??``))return c;try{let e=await ye(t,`read`,[String(l.x),String(l.y)],void 0,{...s(r,i,a),surface:o}),u=e&&typeof e==`object`?e:void 0,d=typeof u?.text==`string`?u.text:``;return d.trim()?d:(v({level:`warn`,phase:`interaction_read_fallback`,data:{reason:`empty_backend_text`,nodeRef:n.ref,surface:o,platform:t.platform}}),c)}catch(e){return v({level:`warn`,phase:`interaction_read_fallback`,data:{reason:`backend_read_failed`,nodeRef:n.ref,surface:o,platform:t.platform,error:e instanceof Error?e.message:String(e)}}),c}}function K(e){let{session:t,sessionStore:n,sessionName:r}=e,i=0,a,o,s=t=>(e.consumedSnapshot&&(e.consumedSnapshot.state=t.snapshot),t);return{capture:async c=>{let l=Date.now(),u=Ot(c,e.req.flags?.out),d=St({timestamp:l,lastSnapshotAt:i,lastSnapshotResult:a,lastSnapshotCacheKey:o,session:t,request:c,cacheKey:u});if(d)return s(d);let f=Ct({session:t,timestamp:l,request:c});if(f)return i=f.createdAt,a={snapshot:f},o=u,s(a);let p=await yt({params:e,request:c});c.signal?.throwIfAborted();let m={snapshot:p};return At({session:t,sessionStore:n,sessionName:r,snapshot:p}),i=l,a=m,o=u,s(m)}}}async function yt(e){let{params:t,request:n}=e,r=await q(t,n,n.snapshotScope);return n.recovery?.legacyIosSparse&&jt(r)?await bt({runtimeParams:t,request:n,policy:n.recovery.legacyIosSparse}):n.recovery?.sparseVerdictQueryScope?.shouldScope&&se(r.snapshotQuality)?await xt({runtimeParams:t,request:n,policy:n.recovery.sparseVerdictQueryScope,snapshot:r}):r}async function bt(e){let{runtimeParams:t,request:n,policy:r}=e;try{return await q(t,n,void 0,!1)}catch(e){if(!r.shouldScope)throw e;return await q(t,n,r.query,!1)}}async function xt(e){let{runtimeParams:t,request:n,policy:r,snapshot:i}=e;try{return await q(t,n,r.query,!1)}catch{return i}}async function q(e,t,n,r=t.flags?.snapshotInteractiveOnly){return(await Oe({device:e.device,session:e.session,flags:{...t.flags,snapshotInteractiveOnly:r},outPath:t.outPath??e.req.flags?.out,logPath:e.logPath??``,snapshotScope:n,includeRects:t.includeRects,signal:t.signal})).snapshot}function St(e){let{timestamp:t,lastSnapshotAt:n,lastSnapshotResult:r,lastSnapshotCacheKey:i,session:a,request:o,cacheKey:s}=e;if(o.cache?.forceFresh!==!0&&r&&i===s&&!(t-n>=750)&&!je(a)&&!Et(a,o))return r}function Ct(e){let{session:t,timestamp:n,request:r}=e,i=t?.snapshot;if(i&&wt(t,r)&&Tt(i,n)&&i.presentationKey===Dt(r))return i}function wt(e,t){return!(t.cache?.forceFresh===!0||t.cache?.useSessionSnapshot!==!0||je(e)||Et(e,t))}function Tt(e,t){return t-e.createdAt<750}function Et(e,t){return t.cache?.bypassForPostGestureStabilization===!0&&ke(e)}function Dt(e){return r(i(kt(e)))}function Ot(e,t){return JSON.stringify({presentationKey:Dt(e),includeRects:e.includeRects===!0,outPath:e.outPath??t??null})}function kt(e){return e.snapshotScope===void 0?e.flags:{...e.flags,snapshotScope:e.snapshotScope}}function At(e){let{session:t,sessionStore:n,sessionName:r,snapshot:i}=e;!t||se(i.snapshotQuality)||(Te(t,i),n.set(r,t))}function jt(e){return e.snapshotQuality||e.backend!==`xctest`||e.nodes.length!==1?!1:e.nodes[0]?.type===`Application`}function Mt(e){return he({backend:Nt(e),...Be(`selector commands`,{plural:!0}),sessions:Ee({sessionName:e.sessionName,getSession:()=>e.session,recordOptions:{includeSnapshot:!0},setRecord:t=>{!e.session||!t.snapshot||(Te(e.session,t.snapshot),e.sessionStore.set(e.sessionName,e.session))}}),signal:e.signal??_e(e.req.meta?.requestId)})}async function J(e,t){e.consumedSnapshot??={};let n=e.sessionStore.get(e.sessionName);if(!n&&t.requireSession)return{ok:!1,response:ve()};let r=n?.device??await x(e.req.flags??{});n||await Ae(r);let i=S(t.capability,r);return i?{ok:!1,response:i}:{ok:!0,runtime:Mt({...e,session:n,device:r})}}function Nt(e){let{req:t,session:n,device:r,logPath:i,sessionName:a,sessionStore:o}=e,s=K({device:r,session:n,sessionStore:o,sessionName:a,req:t,consumedSnapshot:e.consumedSnapshot,logPath:i});return{platform:ie(r),captureSnapshot:async(e,n)=>{let i={...t.flags,...Pt(n)},a=n?.includeRects===!0,o=n?.scope??t.flags?.snapshotScope,c=t.command===`wait`||t.command===`find`||a&&r.platform===`web`;return await s.capture({flags:i,signal:e.signal,snapshotScope:o,includeRects:a,cache:{forceFresh:c,useSessionSnapshot:!0,bypassForPostGestureStabilization:!0}})},readText:async(a,o)=>({text:await vt({device:r,node:o,flags:t.flags,appBundleId:n?.appBundleId,traceOutPath:n?.trace?.outPath,surface:n?.surface,contextFromFlags:e.contextFromFlags??((e,t,n)=>be(i??``,e,t,n))})}),findText:async(t,n)=>({found:await Ft(e,n,t.signal)})}}function Pt(e){let{interactiveOnly:t,scope:n,depth:r,raw:i,includeHiddenContentHints:a}=e??{},o={};return t!==void 0&&(o.snapshotInteractiveOnly=t),n!==void 0&&(o.snapshotScope=n),r!==void 0&&(o.snapshotDepth=r),i!==void 0&&(o.snapshotRaw=i),a!==void 0&&(o.snapshotIncludeHiddenContentHints=a),o}async function Ft(e,t,n){let r=await It(e,t,n);return r===null?await Lt(e,t,n)===!0?!0:await Bt(e,t,n):r}async function It(e,t,n){return!re(e.device)||!e.session?.surface||e.session.surface===`app`?null:await Bt(e,t,n)}async function Lt(e,t,n){let r=Rt(e);return r?(await Se(r.device,{command:`findText`,text:t,appBundleId:r.appBundleId},{...zt(e,r),signal:n}))?.found===!0:null}function Rt(e){return!ae(e.device.platform)||b(e.device)||!e.session?.appBundleId?null:{device:e.device,appBundleId:e.session.appBundleId,traceLogPath:e.session.trace?.outPath}}function zt(e,t){return Me({req:e.req,logPath:e.logPath,traceLogPath:t.traceLogPath})}async function Bt(e,t,n){return!!ce((await Vt(e,n)).nodes,t)}async function Vt(e,t){let{snapshot:n}=await K({device:e.device,session:e.session,sessionStore:e.sessionStore,sessionName:e.sessionName,req:e.req,logPath:e.logPath,consumedSnapshot:e.consumedSnapshot}).capture({flags:{...e.req.flags,snapshotInteractiveOnly:!1,snapshotIncludeHiddenContentHints:!1},signal:t,cache:{forceFresh:!0,bypassForPostGestureStabilization:!0}});return n}async function Ht(e){let{req:t}=e;if(t.command!==`find`)return null;let n=c(t.positionals??[],t.flags);if(!n.ok)return C(n.code,n.message);let r=n.parsed,i=r.action;if(!u(i))return null;let a=await J(e,{requireSession:!1,capability:`find`});return a.ok?G(await $(async()=>{let n=await a.runtime.selectors.find({session:e.sessionName,requestId:t.meta?.requestId,locator:r.locator,query:r.query,action:i,timeoutMs:r.timeoutMs});R(e.sessionStore,e.sessionName,t,at(n,i));let o=ot(n),s=typeof o.ref==`string`?[o.ref]:Array.isArray(o.matches)?o.matches.map(e=>e.ref).filter(e=>typeof e==`string`):[];if(s.length>0){let t=e.sessionStore.get(e.sessionName);if(t&&(we(t,s),e.sessionStore.set(e.sessionName,t),t.snapshotGeneration!==void 0))return{...o,refsGeneration:t.snapshotGeneration}}return o}),Y(e)):a.response}function Y(e){return e.consumedSnapshot?.state??e.sessionStore.get(e.sessionName)?.snapshot}async function Ut(e){let{req:t}=e;if(t.command!==`get`)return null;let n=ee(t.positionals?.[0]);if(!n.ok)return C(n.code,n.message);let r=n.format,i=tn(t);if(!i.ok)return i.response;if(i.target.kind===`ref`){let e=Fe(`get`,t.flags);if(e)return e}let a=t.internal?.replayTargetGuard;if(i.target.kind===`selector`&&!a){let t=await Jt(e,r,i.target.selector);if(t)return t}let o=await J(e,{requireSession:!0,capability:`get`});if(!o.ok)return o.response;let s=i.target.kind===`ref`?De({session:e.sessionStore.get(e.sessionName),ref:i.target.ref,mintedGeneration:i.refGeneration}):void 0;return G(await $(async()=>{let n=await o.runtime.selectors.get({session:e.sessionName,requestId:t.meta?.requestId,property:r,target:i.target,expectedResolvedTarget:a});R(e.sessionStore,e.sessionName,t,P(n,r),{node:n.node,preActionNodes:n.preActionNodes});let c=F(n);return s?{...c,warning:s}:c}),Y(e))}async function Wt(e){let{req:t}=e;if(t.command!==`is`)return null;let n=f(t.positionals??[]);if(!n.ok)return C(n.code,n.message,n.hint?{hint:n.hint}:void 0);let{predicate:r,expectedText:i}=n,a={selectorExpression:n.selectorExpression},o=t.internal?.replayTargetGuard,s=e.sessionStore.get(e.sessionName)?.recordSession===!0;if(!o&&!s){let t=await Yt(e,r,a.selectorExpression,i);if(t)return t}let c=await J(e,{requireSession:!0,capability:`is`});return c.ok?G(await rn(e,await $(async()=>{let n=await c.runtime.selectors.is({session:e.sessionName,requestId:t.meta?.requestId,predicate:r,selector:a.selectorExpression,expectedText:i,expectedResolvedTarget:o}),s=Kt(n),l=I(n);return R(e.sessionStore,e.sessionName,t,l,s),L(l)}),`is ${r}`),Y(e)):c.response}async function Gt(e){let{req:t,sessionName:n,sessionStore:r}=e,i=l(t.positionals??[]);if(!i)return C(`INVALID_ARGS`,`wait requires a duration or text`);let{session:a,device:o}=await j(r,n,t.flags);if(i.kind!==`sleep`){let e=S(`wait`,o);if(e)return e}let s=t.internal?.replayLandmarkGuard;if(i.kind===`selector`&&!s&&!a?.recordSession){let t=await Xt({...e,session:a,device:o,selectorExpression:i.selectorExpression,timeoutMs:i.timeoutMs});if(t)return t}let c=i,u;if(i.kind===`ref`){let e=T(i.rawRef);if(!e.ok)return e.response;c={...i,rawRef:e.ref},u=De({session:a,ref:e.ref,mintedGeneration:e.generation})}e.consumedSnapshot??={};let d=async()=>{let i=Mt({...e,session:a,device:o}),l=await $(async()=>{let e=await i.selectors.wait({session:n,requestId:t.meta?.requestId,target:nn(c,a,s)}),o=Kt(e);R(r,n,t,I(e),o,`landmark`);let l=st(e);return u?{...l,warning:u}:l});return await rn(e,await B({req:t,logPath:e.logPath,session:a,device:o},l),`wait`)};return i.kind===`sleep`?await d():G(await M(a,o,d),Y(e))}function Kt(e){let t=e.node,n=e.preActionNodes;if(!(!t||typeof t!=`object`||!Array.isArray(n)))return{node:t,preActionNodes:n}}function qt(e,t,n){if(!e||e.recordSession)return null;let r=k({session:e,selectorExpression:n});return t===`text`&&r?.key!==`id`?null:r}async function Jt(e,t,n){let r=e.sessionStore.get(e.sessionName),i=qt(r,t,n);if(!r||!i)return null;let a=await Z(e,r,i);if(Q(a))return a.response;if(!a)return null;let o=Qt(t,i.raw,a);return o?(R(e.sessionStore,e.sessionName,e.req,P(o,t)),{ok:!0,data:F(o)}):null}async function Yt(e,t,n,r){if(t===`hidden`)return null;let i=await Zt(e,n);if(Q(i))return i.response;if(!i?.result.found||!i.result.node)return null;let a=t===`exists`?{predicate:t,pass:!0,selector:i.selector.raw,matches:1,selectorChain:[i.selector.raw]}:$t(t,r,i.selector.raw,i.session,i.result.node);return a?(R(e.sessionStore,e.sessionName,e.req,a),{ok:!0,data:L(a)}):null}async function Xt(e){let t=k({session:e.session,selectorExpression:e.selectorExpression});if(!e.session||!t)return null;let n=Date.now(),r=await Z(e,e.session,t);if(Q(r))return r.response;if(!r?.found)return null;let i={kind:`selector`,selector:t.raw,waitedMs:Date.now()-n,selectorChain:[t.raw]};R(e.sessionStore,e.sessionName,e.req,i);let a={ok:!0,data:L(i)};return await B({req:e.req,logPath:e.logPath,session:e.session,device:e.device},a)}async function Zt(e,t){let n=e.sessionStore.get(e.sessionName),r=k({session:n,selectorExpression:t});if(!n||!r)return null;let i=await Z(e,n,r);return Q(i)?i:i?{session:n,selector:r,result:i}:null}async function X(e,t,n){let r=await Se(e.device,{command:`querySelector`,selectorKey:t.key,selectorValue:t.value,appBundleId:e.appBundleId},n),i=r.found===!0,a=en(r);return{found:i,...typeof r.text==`string`?{text:r.text}:{},...a?{node:a}:{}}}async function Z(t,n,r){try{return await X(n,r,Me({req:t.req,logPath:t.logPath,traceLogPath:n.trace?.outPath}))}catch(t){return A(t,{allowElementNotFound:!0})?null:{kind:`error`,response:{ok:!1,error:e(t)}}}}function Q(e){return e!==null&&`kind`in e&&e.kind===`error`}function Qt(e,t,n){if(!n.found||!n.node)return null;let r={target:{kind:`selector`,selector:t},node:n.node,selectorChain:[t]};return e===`attrs`?{kind:`attrs`,...r}:typeof n.text==`string`?{kind:`text`,...r,text:n.text}:null}function $t(e,t,n,r,i){let a=p({predicate:e,node:i,nodes:[i],expectedText:t,platform:r.device.platform});return{predicate:e,pass:a.pass,selector:n,...e===`text`?{text:a.actualText}:{},selectorChain:[n]}}function en(e){let t=e.nodes;if(!Array.isArray(t))return;let n=t[0];if(!(!n||typeof n!=`object`))return n}function tn(e){let t=e.positionals?.[1]??``;if(t.startsWith(`@`)){let n=T(t);return n.ok?{ok:!0,target:{kind:`ref`,ref:n.ref,fallbackLabel:e.positionals.length>2?e.positionals.slice(2).join(` `).trim():``},refGeneration:n.generation}:{ok:!1,response:n.response}}let n=te(e.positionals?.slice(1)??[]);return n.ok?{ok:!0,target:{kind:`selector`,selector:`selector`in n?n.selector:``}}:{ok:!1,response:C(n.code,n.message)}}function nn(e,n,r){if(e.kind===`sleep`)return{kind:`sleep`,durationMs:e.durationMs};if(e.kind===`selector`)return{kind:`selector`,selector:e.selectorExpression,timeoutMs:e.timeoutMs,...r?{recordedLandmark:r}:{}};if(e.kind===`ref`){if(!n?.snapshot)throw new t(`INVALID_ARGS`,`Ref wait requires an existing snapshot in session.`);return{kind:`ref`,ref:e.rawRef,timeoutMs:e.timeoutMs}}if(e.kind===`stable`)return{kind:`stable`,quietMs:e.quietMs,timeoutMs:e.timeoutMs};let i=ne(e.text);if(!i.ok)throw new t(i.code,i.message);return{kind:`text`,text:i.text,timeoutMs:e.timeoutMs}}async function $(e){try{return{ok:!0,data:await e()}}catch(e){let t=o(e);return C(t.code,t.message,t.details)}}async function rn(e,t,n){if(t.ok)return t;let r=e.sessionStore.get(e.sessionName);if(!r)return t;let i;try{i=await N(r)}catch{return t}return i?C(t.error.code,`${n} failed because ${tt(i)}.`,{...t.error.details??{},...i,blockedBy:`android_foreground_surface`,originalMessage:t.error.message}):t}export{D as C,Le as D,Fe as E,E as S,Re as T,k as _,X as a,He as b,et as c,Qe as d,j as f,O as g,A as h,Gt as i,nt as l,Xe as m,Ut as n,K as o,M as p,Wt as r,G as s,Ht as t,$e as u,Ge as v,Be as w,Ve as x,We as y};
1
+ import{S as e,_ as t,h as n,l as r,m as i,s as a,v as o}from"./sdk-contracts.js";import{x as s}from"./version.js";import{Jt as c,Kt as l,X as u,Yt as d,Zt as f,dt as p,it as m,jn as h,ln as ee,qt as te,sn as ne}from"./sdk-batch-runner.js";import{_ as re,c as ie,l as ae,s as oe}from"./sdk-device.js";import{J as se,X as ce,c as g,it as le,z as _}from"./prepare-kind.js";import{j as ue}from"./screenshot-result.js";import{i as de}from"./session-target-evidence.js";import{i as fe}from"./text-surface.js";import{a as pe,t as me}from"./runtime.js";import{A as v}from"./sdk-android-adb.js";import{r as he}from"./app-lifecycle.js";import{h as y}from"./ime-lifecycle.js";import{N as ge}from"./runner-disposal.js";import{D as _e,_ as ve,c as ye,l as be,n as xe,s as b,t as Se}from"./context.js";import{a as x}from"./runner-client.js";import{Gt as S,Ht as Ce,Kt as C,O as we,Wt as Te,en as w,in as T,sn as Ee,x as De}from"./internal/daemon.js";import{a as Oe,i as ke,r as Ae}from"./snapshot-session.js";const je=[[`snapshotDepth`,`--depth`],[`snapshotScope`,`--scope`],[`snapshotRaw`,`--raw`]];function Me(e,t){let n=Ne(t);return n.length===0?null:b(`INVALID_ARGS`,`${e} @ref does not support ${n.join(`, `)}.`)}function Ne(e){if(!e)return[];let t=[];for(let[n,r]of je)e[n]!==void 0&&t.push(r);return t}function Pe(e,t){if(!t||t.settle===!0)return null;let n=[];return t.settleQuietMs!==void 0&&n.push(`--settle-quiet`),n.length===0?null:b(`INVALID_ARGS`,`${e}: ${n.join(`, `)} require${n.length===1?`s`:``} --settle.`)}function Fe(e){if(e?.settle===!0)return{...e.settleQuietMs===void 0?{}:{quietMs:e.settleQuietMs},...e.timeoutMs===void 0?{}:{timeoutMs:e.timeoutMs}}}function E(e){if(e.length<2)return null;let t=Number(e[0]),n=Number(e[1]);return!Number.isFinite(t)||!Number.isFinite(n)?null:{x:t,y:n}}function D(e){let t=n(e);return t?{ok:!0,ref:t.base,generation:t.generation}:{ok:!1,response:b(`INVALID_ARGS`,`Invalid ref "${e}" — malformed generation suffix.`,{hint:a})}}function O(e,t){let n=E(e);if(n)return{ok:!0,target:{kind:`point`,x:n.x,y:n.y}};let r=e[0]??``;if(r.startsWith(`@`)){let t=D(r);return t.ok?{ok:!0,target:{kind:`ref`,ref:t.ref,fallbackLabel:e.slice(1).join(` `).trim()},refGeneration:t.generation}:{ok:!1,response:t.response}}let i=e.join(` `).trim();return i?{ok:!0,target:{kind:`selector`,selector:i}}:{ok:!1,response:b(`INVALID_ARGS`,`${t} requires @ref, selector expression, or x y coordinates`)}}function Ie(e){let t=E(e);if(t)return{ok:!0,target:{kind:`point`,x:t.x,y:t.y},...Ue(e[2])};let n=He(e),r=O(n.targetPositionals,`longpress`);return r.ok?{ok:!0,target:r.target,refGeneration:r.refGeneration,...n.duration}:r}function Le(e){let t=e[0]??``;if(t.startsWith(`@`)){let n=D(t);if(!n.ok)return{ok:!1,response:n.response};let r=g(e).text;return r?{ok:!0,target:{kind:`ref`,ref:n.ref,fallbackLabel:Ve(e)},refGeneration:n.generation,text:r}:{ok:!1,response:b(`INVALID_ARGS`,`fill requires text after ref`)}}let n=E(e);if(n){let t=e.slice(2).join(` `);return t?{ok:!0,target:{kind:`point`,x:n.x,y:n.y},text:t}:{ok:!1,response:b(`INVALID_ARGS`,`fill requires text after coordinates`)}}let r=Re(e);return!r||r.kind!==`selector`?{ok:!1,response:b(`INVALID_ARGS`,`fill requires x y text, @ref text, or selector text`)}:r.text.trim()?{ok:!0,target:{kind:`selector`,selector:r.target.selector},text:r.text}:{ok:!1,response:b(`INVALID_ARGS`,`fill requires text after selector`)}}function Re(e){try{return g(e)}catch{return null}}function ze(e){let t=`evidence`in e?e.evidence:void 0,n=e.settle;return e.kind===`ref`?{ref:k(e.target?.kind===`ref`?e.target.ref:void 0),refLabel:e.refLabel,selectorChain:e.selectorChain,targetHittable:e.targetHittable,hint:e.hint,evidence:t,settle:n,resolution:e.resolution}:e.kind===`selector`?{selector:e.target?.kind===`selector`?e.target.selector:void 0,selectorChain:e.selectorChain,refLabel:e.refLabel,targetHittable:e.targetHittable,hint:e.hint,evidence:t,settle:n,resolution:e.resolution}:{evidence:t,settle:n}}function Be(e,t){return e.kind===`point`?`coordinate tap`:t.kind===`ref`&&t.target?.kind===`ref`?t.target.ref:t.kind===`selector`&&t.target?.kind===`selector`?t.target.selector:`target`}function k(e){return e?.startsWith(`@`)?e.slice(1):e}function Ve(e){return e.length>=3&&e[1]?.trim()||``}function He(e){let t=e.at(-1);return e.length>1&&We(t)?{targetPositionals:e.slice(0,-1),duration:{durationMs:Number(t)}}:{targetPositionals:e,duration:{}}}function Ue(e){return e===void 0?{}:{durationMs:Number(e)}}function We(e){return e===void 0||e.trim()===``?!1:Number.isFinite(Number(e))}function A(e,t){return!(!e||!ie(e.device)||_e(e.device)||t.skipPendingPostGestureStabilization&&T(e))}function j(e){let{session:t,selectorExpression:n}=e;return A(t,{skipPendingPostGestureStabilization:!0})?p(n):null}function Ge(e){let t=e.identifier?.trim();if(t)return{key:`id`,value:t};let n=e.label?.trim();return n?{key:`label`,value:n}:null}function M(e,t={}){let n=o(e);if(n.code===`ELEMENT_NOT_FOUND`)return t.delegateSemanticFailures===!0||t.allowElementNotFound===!0;if(n.code===`AMBIGUOUS_MATCH`)return t.delegateSemanticFailures===!0;if(n.code===`ELEMENT_OFFSCREEN`)return t.delegateSemanticFailures!==!1;if(n.code!==`COMMAND_FAILED`)return!1;let r=n.message.toLowerCase();return r.includes(`fetch failed`)||r.includes(`timed out`)||r.includes(`timeout`)||r.includes(`runner did not accept connection`)||r.includes(`invalid runner response`)}async function Ke(e,n){let r=await N(e);if(r){if(y(r.foregroundPackage))return`press ${n} opened an Android permission dialog (${r.foregroundPackage}) over ${r.expectedPackage}. ${r.hint}`;throw new t(`COMMAND_FAILED`,`press ${n} left ${e.appBundleId} and foregrounded ${r.foregroundPackage}. The tap likely escaped the app.`,r)}}async function N(e){if(e.device.platform!==`android`||!e.appBundleId)return null;let t=await he(e.device),n=t.package?.trim();return!n||n===e.appBundleId||!Xe(n)?null:{expectedPackage:e.appBundleId,foregroundPackage:n,activity:t.activity,hint:Ye(n)}}function qe(e){return y(e.foregroundPackage)?`Android permission dialog is blocking ${e.expectedPackage}`:`${e.foregroundPackage} is foreground instead of ${e.expectedPackage}`}function Je(e){return e.code===`COMMAND_FAILED`&&typeof e.details?.expectedPackage==`string`&&typeof e.details?.foregroundPackage==`string`}function Ye(e){return y(e)?`Use "alert get" to inspect it, then "alert accept" or "alert dismiss" to respond.`:`Use screenshot as visual truth, then take a fresh snapshot -i before retrying.`}function Xe(e){return e===`com.android.settings`||e===`com.android.systemui`||y(e)||e.includes(`launcher`)}function Ze(e,t){if(t===`exists`)return{found:!0};if(t===`wait`)return{found:!0,waitedMs:e.waitedMs};if(t===`list`)return{action:`list`,matches:Array.isArray(e.matches)?e.matches.length:0};let n=typeof e.ref==`string`?e.ref:void 0;return t===`get_attrs`?{ref:n,action:`get attrs`}:{ref:n,action:`get text`,text:typeof e.text==`string`?e.text:``}}function Qe(e){return e.kind===`found`?{found:!0,...typeof e.waitedMs==`number`?{waitedMs:e.waitedMs}:{}}:e.kind===`list`?{matches:e.matches.map(e=>({ref:e.ref,node:u(e.node)}))}:{ref:e.ref,...e.kind===`text`?{text:e.text}:{},node:u(e.node)}}function P(e,t){let n=Array.isArray(e.selectorChain)?e.selectorChain:void 0,r=tt(e),i=r?.kind===`ref`?z(r.ref):void 0,a=r?.kind===`selector`?r.selector:void 0,o={...i?{ref:i}:{},...a?{selector:a}:{},...n?{selectorChain:n}:{}};if(t===`attrs`)return o;let s=typeof e.text==`string`?e.text:``;return{...o,text:s,refLabel:et(s)}}function F(e){let{target:t}=e;return{...t.kind===`ref`?{ref:z(t.ref)}:{},...t.kind===`selector`?{selector:t.selector}:{},...typeof e.text==`string`?{text:e.text}:{},node:u(e.node)}}function I(e){let{node:t,preActionNodes:n,...r}=e;return r}function $e(e){return{waitedMs:e.waitedMs,...typeof e.text==`string`?{text:e.text}:{},...typeof e.selector==`string`?{selector:e.selector}:{},...typeof e.captures==`number`?{captures:e.captures}:{},...typeof e.nodeCount==`number`?{nodeCount:e.nodeCount}:{},...typeof e.hint==`string`?{hint:e.hint}:{}}}function L(e){let{selectorChain:t,...n}=e;return n}function R(e,t,n,r,i,a){let o=e.get(t);if(!o)return;let s=o.recordSession&&i?de(i,{mode:a}):void 0;e.recordAction(o,{command:n.command,positionals:n.positionals??[],flags:n.flags??{},result:r,interactiveObservation:ue(n),...s?{targetEvidence:s}:{}})}function et(e){let t=e.trim();if(!(!t||t.length>80||/[\r\n]/.test(t)))return t}function tt(e){let t=e.target;if(!t||typeof t!=`object`)return;let n=t;if(n.kind===`ref`&&typeof n.ref==`string`)return{kind:`ref`,ref:n.ref};if(n.kind===`selector`&&typeof n.selector==`string`)return{kind:`selector`,selector:n.selector}}function z(e){return e.startsWith(`@`)?e.slice(1):e}const nt=[`application`,`window`,`tabbar`,`scrollbar`,`image`],rt=new Set([`tab bar`]);async function B(e,t){if(t.ok||!it(t.error.details?.reason)||t.error.details?.captureStalled===!0||t.error.details?.captureTruncated===!0)return t;let n=await at(e).catch(()=>null);return n?b(t.error.code,`${t.error.message}. Current surface: ${n.summary}.`,{...t.error.details??{},currentSurface:n.details}):t}function it(e){return e===s.targetAbsent||e===s.stableTimeout}async function at(e){let t=[...(await w({device:e.device,session:e.session,flags:{...e.req.flags,snapshotInteractiveOnly:!0},logPath:e.logPath??``})).snapshot.nodes].sort(ot),n=V(t,6,{includeIdentifiers:!0});if(n.length===0)return null;let r=V(t.filter(e=>!U(e)),4,{includeIdentifiers:!1}),i=V(t.filter(lt),4,{includeIdentifiers:!0});return{summary:(r.length>0?r:n.slice(0,4)).join(`, `),details:{labels:n,...i.length>0?{buttons:i}:{}}}}function V(e,t,n){let r=new Set,i=[];for(let a of e){let e=ct(a,n);if(!(!e||r.has(e))&&(r.add(e),i.push(e),i.length>=t))break}return i}function ot(e,t){return H(e)-H(t)||st(e,t)}function H(e){let t=!!ct(e,{includeIdentifiers:!1});return(U(e)?2:0)+ +!t}function st(e,t){return e.rect&&t.rect?e.rect.y-t.rect.y||e.rect.x-t.rect.x:e.rect?-1:t.rect?1:(e.depth??0)-(t.depth??0)||e.index-t.index}function ct(e,t){let n=(t.includeIdentifiers?[e.label,e.value,e.identifier]:[e.label,e.value]).map(e=>typeof e==`string`?e.trim():``).find(e=>e.length>0);return n?n.replace(/\s+/g,` `).slice(0,80):``}function U(e){let t=h(`${e.type??``} ${e.role??``} ${e.subrole??``}`),n=`${e.label??``} ${e.value??``}`.trim().toLowerCase();return nt.some(e=>t.includes(e))||rt.has(n)||n.endsWith(`.fill`)}function lt(e){return h(`${e.type??``} ${e.role??``} ${e.subrole??``}`).includes(`button`)}function W(e,t){let n=pe(t);if(!n)return e;if(e.ok){let t=G(e.data?.warning,n);return{...e,data:{...e.data,warning:t}}}let r=e.error.details??{};return{...e,error:{...e.error,details:{...r,hint:G(r.hint,n)}}}}function G(e,t){return typeof e==`string`&&e.trim()!==``?`${e}\n${t}`:t}async function ut(e){let{device:t,node:n,flags:r,appBundleId:i,traceOutPath:a,surface:o,contextFromFlags:s}=e,c=se(n),l=le(n.rect);if(!l||ie(t)&&c&&!fe(n.type??``))return c;try{let e=await xe(t,`read`,[String(l.x),String(l.y)],void 0,{...s(r,i,a),surface:o}),u=e&&typeof e==`object`?e:void 0,d=typeof u?.text==`string`?u.text:``;return d.trim()?d:(v({level:`warn`,phase:`interaction_read_fallback`,data:{reason:`empty_backend_text`,nodeRef:n.ref,surface:o,platform:t.platform}}),c)}catch(e){return v({level:`warn`,phase:`interaction_read_fallback`,data:{reason:`backend_read_failed`,nodeRef:n.ref,surface:o,platform:t.platform,error:e instanceof Error?e.message:String(e)}}),c}}function K(e){let{session:t,sessionStore:n,sessionName:r}=e,i=0,a,o,s=t=>(e.consumedSnapshot&&(e.consumedSnapshot.state=t.snapshot),t);return{capture:async c=>{let l=Date.now(),u=yt(c,e.req.flags?.out),d=mt({timestamp:l,lastSnapshotAt:i,lastSnapshotResult:a,lastSnapshotCacheKey:o,session:t,request:c,cacheKey:u});if(d)return s(d);let f=ht({session:t,timestamp:l,request:c});if(f)return i=f.createdAt,a={snapshot:f},o=u,s(a);let p=await dt({params:e,request:c});c.signal?.throwIfAborted();let m={snapshot:p};return xt({session:t,sessionStore:n,sessionName:r,snapshot:p}),i=l,a=m,o=u,s(m)}}}async function dt(e){let{params:t,request:n}=e,r=await q(t,n,n.snapshotScope);return n.recovery?.legacyIosSparse&&St(r)?await ft({runtimeParams:t,request:n,policy:n.recovery.legacyIosSparse}):n.recovery?.sparseVerdictQueryScope?.shouldScope&&_(r.snapshotQuality)?await pt({runtimeParams:t,request:n,policy:n.recovery.sparseVerdictQueryScope,snapshot:r}):r}async function ft(e){let{runtimeParams:t,request:n,policy:r}=e;try{return await q(t,n,void 0,!1)}catch(e){if(!r.shouldScope)throw e;return await q(t,n,r.query,!1)}}async function pt(e){let{runtimeParams:t,request:n,policy:r,snapshot:i}=e;try{return await q(t,n,r.query,!1)}catch{return i}}async function q(e,t,n,r=t.flags?.snapshotInteractiveOnly){return(await w({device:e.device,session:e.session,flags:{...t.flags,snapshotInteractiveOnly:r},outPath:t.outPath??e.req.flags?.out,logPath:e.logPath??``,snapshotScope:n,includeRects:t.includeRects,signal:t.signal})).snapshot}function mt(e){let{timestamp:t,lastSnapshotAt:n,lastSnapshotResult:r,lastSnapshotCacheKey:i,session:a,request:o,cacheKey:s}=e;if(o.cache?.forceFresh!==!0&&r&&i===s&&!(t-n>=750)&&!Ee(a)&&!J(a,o))return r}function ht(e){let{session:t,timestamp:n,request:r}=e,i=t?.snapshot;if(i&&gt(t,r)&&_t(i,n)&&i.presentationKey===vt(r))return i}function gt(e,t){return!(t.cache?.forceFresh===!0||t.cache?.useSessionSnapshot!==!0||Ee(e)||J(e,t))}function _t(e,t){return t-e.createdAt<750}function J(e,t){return t.cache?.bypassForPostGestureStabilization===!0&&T(e)}function vt(e){return r(i(bt(e)))}function yt(e,t){return JSON.stringify({presentationKey:vt(e),includeRects:e.includeRects===!0,outPath:e.outPath??t??null})}function bt(e){return e.snapshotScope===void 0?e.flags:{...e.flags,snapshotScope:e.snapshotScope}}function xt(e){let{session:t,sessionStore:n,sessionName:r,snapshot:i}=e;!t||_(i.snapshotQuality)||(C(t,i),n.set(r,t))}function St(e){return e.snapshotQuality||e.backend!==`xctest`||e.nodes.length!==1?!1:e.nodes[0]?.type===`Application`}function Ct(e){return me({backend:wt(e),...Oe(`selector commands`,{plural:!0}),sessions:Ce({sessionName:e.sessionName,getSession:()=>e.session,recordOptions:{includeSnapshot:!0},setRecord:t=>{!e.session||!t.snapshot||(C(e.session,t.snapshot),e.sessionStore.set(e.sessionName,e.session))}}),signal:e.signal??ge(e.req.meta?.requestId)})}async function Y(e,t){e.consumedSnapshot??={};let n=e.sessionStore.get(e.sessionName);if(!n&&t.requireSession)return{ok:!1,response:ye()};let r=n?.device??await ve(e.req.flags??{});n||await we(r);let i=be(t.capability,r);return i?{ok:!1,response:i}:{ok:!0,runtime:Ct({...e,session:n,device:r})}}function wt(e){let{req:t,session:n,device:r,logPath:i,sessionName:a,sessionStore:o}=e,s=K({device:r,session:n,sessionStore:o,sessionName:a,req:t,consumedSnapshot:e.consumedSnapshot,logPath:i});return{platform:re(r),captureSnapshot:async(e,n)=>{let i={...t.flags,...Tt(n)},a=n?.includeRects===!0,o=n?.scope??t.flags?.snapshotScope,c=t.command===`wait`||t.command===`find`||a&&r.platform===`web`;return await s.capture({flags:i,signal:e.signal,snapshotScope:o,includeRects:a,cache:{forceFresh:c,useSessionSnapshot:!0,bypassForPostGestureStabilization:!0}})},readText:async(a,o)=>({text:await ut({device:r,node:o,flags:t.flags,appBundleId:n?.appBundleId,traceOutPath:n?.trace?.outPath,surface:n?.surface,contextFromFlags:e.contextFromFlags??((e,t,n)=>Se(i??``,e,t,n))})}),findText:async(t,n)=>({found:await Et(e,n,t.signal)})}}function Tt(e){let{interactiveOnly:t,scope:n,depth:r,raw:i,includeHiddenContentHints:a}=e??{},o={};return t!==void 0&&(o.snapshotInteractiveOnly=t),n!==void 0&&(o.snapshotScope=n),r!==void 0&&(o.snapshotDepth=r),i!==void 0&&(o.snapshotRaw=i),a!==void 0&&(o.snapshotIncludeHiddenContentHints=a),o}async function Et(e,t,n){let r=await Dt(e,t,n);return r===null?await Ot(e,t,n)===!0?!0:await jt(e,t,n):r}async function Dt(e,t,n){return!ae(e.device)||!e.session?.surface||e.session.surface===`app`?null:await jt(e,t,n)}async function Ot(e,t,n){let r=kt(e);return r?(await x(r.device,{command:`findText`,text:t,appBundleId:r.appBundleId},{...At(e,r),signal:n}))?.found===!0:null}function kt(e){return!oe(e.device.platform)||_e(e.device)||!e.session?.appBundleId?null:{device:e.device,appBundleId:e.session.appBundleId,traceLogPath:e.session.trace?.outPath}}function At(e,t){return De({req:e.req,logPath:e.logPath,traceLogPath:t.traceLogPath})}async function jt(e,t,n){return!!ce((await Mt(e,n)).nodes,t)}async function Mt(e,t){let{snapshot:n}=await K({device:e.device,session:e.session,sessionStore:e.sessionStore,sessionName:e.sessionName,req:e.req,logPath:e.logPath,consumedSnapshot:e.consumedSnapshot}).capture({flags:{...e.req.flags,snapshotInteractiveOnly:!1,snapshotIncludeHiddenContentHints:!1},signal:t,cache:{forceFresh:!0,bypassForPostGestureStabilization:!0}});return n}async function Nt(e){let{req:t}=e;if(t.command!==`find`)return null;let n=ne(t.positionals??[],t.flags);if(!n.ok)return b(n.code,n.message);let r=n.parsed,i=r.action;if(!ee(i))return null;let a=await Y(e,{requireSession:!1,capability:`find`});return a.ok?W(await $(async()=>{let n=await a.runtime.selectors.find({session:e.sessionName,requestId:t.meta?.requestId,locator:r.locator,query:r.query,action:i,timeoutMs:r.timeoutMs});R(e.sessionStore,e.sessionName,t,Ze(n,i));let o=Qe(n),s=typeof o.ref==`string`?[o.ref]:Array.isArray(o.matches)?o.matches.map(e=>e.ref).filter(e=>typeof e==`string`):[];if(s.length>0){let t=e.sessionStore.get(e.sessionName);if(t&&(Te(t,s),e.sessionStore.set(e.sessionName,t),t.snapshotGeneration!==void 0))return{...o,refsGeneration:t.snapshotGeneration}}return o}),X(e)):a.response}function X(e){return e.consumedSnapshot?.state??e.sessionStore.get(e.sessionName)?.snapshot}async function Pt(e){let{req:t}=e;if(t.command!==`get`)return null;let n=te(t.positionals?.[0]);if(!n.ok)return b(n.code,n.message);let r=n.format,i=qt(t);if(!i.ok)return i.response;if(i.target.kind===`ref`){let e=Me(`get`,t.flags);if(e)return e}let a=t.internal?.replayTargetGuard;if(i.target.kind===`selector`&&!a){let t=await zt(e,r,i.target.selector);if(t)return t}let o=await Y(e,{requireSession:!0,capability:`get`});if(!o.ok)return o.response;let s=i.target.kind===`ref`?S({session:e.sessionStore.get(e.sessionName),ref:i.target.ref,mintedGeneration:i.refGeneration}):void 0;return W(await $(async()=>{let n=await o.runtime.selectors.get({session:e.sessionName,requestId:t.meta?.requestId,property:r,target:i.target,expectedResolvedTarget:a});R(e.sessionStore,e.sessionName,t,P(n,r),{node:n.node,preActionNodes:n.preActionNodes});let c=F(n);return s?{...c,warning:s}:c}),X(e))}async function Ft(e){let{req:t}=e;if(t.command!==`is`)return null;let n=c(t.positionals??[]);if(!n.ok)return b(n.code,n.message,n.hint?{hint:n.hint}:void 0);let{predicate:r,expectedText:i}=n,a={selectorExpression:n.selectorExpression},o=t.internal?.replayTargetGuard,s=e.sessionStore.get(e.sessionName)?.recordSession===!0;if(!o&&!s){let t=await Bt(e,r,a.selectorExpression,i);if(t)return t}let l=await Y(e,{requireSession:!0,capability:`is`});return l.ok?W(await Yt(e,await $(async()=>{let n=await l.runtime.selectors.is({session:e.sessionName,requestId:t.meta?.requestId,predicate:r,selector:a.selectorExpression,expectedText:i,expectedResolvedTarget:o}),s=Lt(n),c=I(n);return R(e.sessionStore,e.sessionName,t,c,s),L(c)}),`is ${r}`),X(e)):l.response}async function It(e){let{req:t,sessionName:n,sessionStore:r}=e,i=m(t.positionals??[]);if(!i)return b(`INVALID_ARGS`,`wait requires a duration or text`);let{session:a,device:o}=await Ae(r,n,t.flags);if(i.kind!==`sleep`){let e=be(`wait`,o);if(e)return e}let s=t.internal?.replayLandmarkGuard;if(i.kind===`selector`&&!s&&!a?.recordSession){let t=await Vt({...e,session:a,device:o,selectorExpression:i.selectorExpression,timeoutMs:i.timeoutMs});if(t)return t}let c=i,l;if(i.kind===`ref`){let e=D(i.rawRef);if(!e.ok)return e.response;c={...i,rawRef:e.ref},l=S({session:a,ref:e.ref,mintedGeneration:e.generation})}e.consumedSnapshot??={};let u=async()=>{let i=Ct({...e,session:a,device:o}),u=await $(async()=>{let e=await i.selectors.wait({session:n,requestId:t.meta?.requestId,target:Jt(c,a,s)}),o=Lt(e);R(r,n,t,I(e),o,`landmark`);let u=$e(e);return l?{...u,warning:l}:u});return await Yt(e,await B({req:t,logPath:e.logPath,session:a,device:o},u),`wait`)};return i.kind===`sleep`?await u():W(await ke(a,o,u),X(e))}function Lt(e){let t=e.node,n=e.preActionNodes;if(!(!t||typeof t!=`object`||!Array.isArray(n)))return{node:t,preActionNodes:n}}function Rt(e,t,n){if(!e||e.recordSession)return null;let r=j({session:e,selectorExpression:n});return t===`text`&&r?.key!==`id`?null:r}async function zt(e,t,n){let r=e.sessionStore.get(e.sessionName),i=Rt(r,t,n);if(!r||!i)return null;let a=await Z(e,r,i);if(Q(a))return a.response;if(!a)return null;let o=Wt(t,i.raw,a);return o?(R(e.sessionStore,e.sessionName,e.req,P(o,t)),{ok:!0,data:F(o)}):null}async function Bt(e,t,n,r){if(t===`hidden`)return null;let i=await Ht(e,n);if(Q(i))return i.response;if(!i?.result.found||!i.result.node)return null;let a=t===`exists`?{predicate:t,pass:!0,selector:i.selector.raw,matches:1,selectorChain:[i.selector.raw]}:Gt(t,r,i.selector.raw,i.session,i.result.node);return a?(R(e.sessionStore,e.sessionName,e.req,a),{ok:!0,data:L(a)}):null}async function Vt(e){let t=j({session:e.session,selectorExpression:e.selectorExpression});if(!e.session||!t)return null;let n=Date.now(),r=await Z(e,e.session,t);if(Q(r))return r.response;if(!r?.found)return null;let i={kind:`selector`,selector:t.raw,waitedMs:Date.now()-n,selectorChain:[t.raw]};R(e.sessionStore,e.sessionName,e.req,i);let a={ok:!0,data:L(i)};return await B({req:e.req,logPath:e.logPath,session:e.session,device:e.device},a)}async function Ht(e,t){let n=e.sessionStore.get(e.sessionName),r=j({session:n,selectorExpression:t});if(!n||!r)return null;let i=await Z(e,n,r);return Q(i)?i:i?{session:n,selector:r,result:i}:null}async function Ut(e,t,n){let r=await x(e.device,{command:`querySelector`,selectorKey:t.key,selectorValue:t.value,appBundleId:e.appBundleId},n),i=r.found===!0,a=Kt(r);return{found:i,...typeof r.text==`string`?{text:r.text}:{},...a?{node:a}:{}}}async function Z(t,n,r){try{return await Ut(n,r,De({req:t.req,logPath:t.logPath,traceLogPath:n.trace?.outPath}))}catch(t){return M(t,{allowElementNotFound:!0})?null:{kind:`error`,response:{ok:!1,error:e(t)}}}}function Q(e){return e!==null&&`kind`in e&&e.kind===`error`}function Wt(e,t,n){if(!n.found||!n.node)return null;let r={target:{kind:`selector`,selector:t},node:n.node,selectorChain:[t]};return e===`attrs`?{kind:`attrs`,...r}:typeof n.text==`string`?{kind:`text`,...r,text:n.text}:null}function Gt(e,t,n,r,i){let a=f({predicate:e,node:i,nodes:[i],expectedText:t,platform:r.device.platform});return{predicate:e,pass:a.pass,selector:n,...e===`text`?{text:a.actualText}:{},selectorChain:[n]}}function Kt(e){let t=e.nodes;if(!Array.isArray(t))return;let n=t[0];if(!(!n||typeof n!=`object`))return n}function qt(e){let t=e.positionals?.[1]??``;if(t.startsWith(`@`)){let n=D(t);return n.ok?{ok:!0,target:{kind:`ref`,ref:n.ref,fallbackLabel:e.positionals.length>2?e.positionals.slice(2).join(` `).trim():``},refGeneration:n.generation}:{ok:!1,response:n.response}}let n=l(e.positionals?.slice(1)??[]);return n.ok?{ok:!0,target:{kind:`selector`,selector:`selector`in n?n.selector:``}}:{ok:!1,response:b(n.code,n.message)}}function Jt(e,n,r){if(e.kind===`sleep`)return{kind:`sleep`,durationMs:e.durationMs};if(e.kind===`selector`)return{kind:`selector`,selector:e.selectorExpression,timeoutMs:e.timeoutMs,...r?{recordedLandmark:r}:{}};if(e.kind===`ref`){if(!n?.snapshot)throw new t(`INVALID_ARGS`,`Ref wait requires an existing snapshot in session.`);return{kind:`ref`,ref:e.rawRef,timeoutMs:e.timeoutMs}}if(e.kind===`stable`)return{kind:`stable`,quietMs:e.quietMs,timeoutMs:e.timeoutMs};let i=d(e.text);if(!i.ok)throw new t(i.code,i.message);return{kind:`text`,text:i.text,timeoutMs:e.timeoutMs}}async function $(e){try{return{ok:!0,data:await e()}}catch(e){let t=o(e);return b(t.code,t.message,t.details)}}async function Yt(e,t,n){if(t.ok)return t;let r=e.sessionStore.get(e.sessionName);if(!r)return t;let i;try{i=await N(r)}catch{return t}return i?b(t.error.code,`${n} failed because ${qe(i)}.`,{...t.error.details??{},...i,blockedBy:`android_foreground_surface`,originalMessage:t.error.message}):t}export{Pe as S,Ie as _,Ut as a,Fe as b,Ke as c,M as d,A as f,Le as g,ze as h,It as i,Je as l,Be as m,Pt as n,K as o,j as p,Ft as r,W as s,Nt as t,Ge as u,O as v,Me as x,k as y};
@@ -1 +1 @@
1
- import{_ as e}from"./sdk-contracts.js";import{nt as t}from"./screenshot-geometry.js";import{h as n,i as r,m as i}from"./sdk-device.js";import{a}from"./sdk-remote-config.js";import{i as o,r as s}from"./device.js";import{v as c}from"./sdk-android-adb.js";import{n as l}from"./version.js";import{n as u,o as d}from"./host-process.js";import{r as ee}from"./entities.js";import{t as te}from"./parser.js";import f from"node:path";import p from"node:crypto";import m from"node:fs";import ne from"node:os";import h from"node:fs/promises";import{setTimeout as g}from"node:timers/promises";function re(e,t){let n=p.createHash(`sha256`).update(e).digest(),r=p.createHash(`sha256`).update(t).digest();return p.timingSafeEqual(n,r)}const _={support:`supported`},v={support:`unsupported`},ie={lease:_,inventory:{support:`partial`,note:`Inventory exposes only the leased cloud device, not the provider catalog.`},install:{support:`partial`,note:`Requires provider-specific upload or a path visible to the remote Appium server.`},open:_,close:_,snapshot:{support:`partial`,note:`Uses Appium page source XML, not agent-device native snapshot backends.`},screenshot:_,tap:_,doubleTap:_,longPress:_,swipe:_,scroll:{support:`partial`,note:`Implemented as viewport-relative W3C pointer gestures.`},fill:_,type:_,back:_,home:{support:`partial`,note:`Uses provider/Appium mobile pressButton support where available.`},orientation:{support:`partial`,note:`Uses the WebDriver rotation/orientation endpoints; four-way rotation collapses to portrait/landscape on drivers that only accept the two-way endpoint. Rotates the current display, so an activity that does not pin its orientation may need rotating again once it is foreground.`},appSwitcher:{support:`partial`,note:`Uses provider/Appium mobile pressButton support where available.`},tvRemote:v,"clipboard.read":{support:`partial`,note:`Uses provider/Appium clipboard extension support where available.`},"clipboard.write":{support:`partial`,note:`Uses provider/Appium clipboard extension support where available.`},settings:v,pinch:v,rotateGesture:v,transformGesture:v,logs:v,record:v,artifacts:v,portReverse:v,nativeSnapshotBackend:{support:`unsupported`,note:`Cloud WebDriver cannot upload or run agent-device native runner/helper backends.`}};function ae(e){return{provider:e.provider,platform:e.platform,snapshotBackend:e.platform===`ios`?`xctest`:`android`,snapshotSource:`appium-page-source`,operations:se(ie,e.overrides)}}function oe(e,t){return e.operations[t].support!==`unsupported`}function y(e,t){let n=e.operations[t],r=n.note?` ${n.note}`:``;return`${e.provider} WebDriver runtime does not support ${t}.${r}`}function se(e,t){let n={...e};for(let[r,i]of Object.entries(t??{}))n[r]=typeof i==`string`?{...e[r],support:i}:{...e[r],...i};return n}function b(e){return{provider:e.provider,providerSessionId:e.providerSessionId,status:e.artifacts.length>0?`ready`:`pending`,cloudArtifacts:e.artifacts,...e.artifacts.length>0?{}:{message:e.pendingMessage}}}function ce(e){return{provider:e.provider,providerSessionId:e.providerSessionId,status:`unavailable`,cloudArtifacts:[],message:e.error instanceof Error?e.error.message:String(e.error)}}function le(e,t){let n=e?.bundleId??t?.appIdentifierHint,r=e?.packageName??t?.packageNameHint;return{bundleId:n,packageName:r,appName:e?.appName,launchTarget:de(e?.launchTarget,n,r)}}function ue(e){return e===`ios`?`xctest`:`android`}function de(...e){return e.find(e=>e!==void 0)}function x(e){return{"x-agent-device-client":`agent-device-cli`,"x-agent-device-version":e}}function fe(e,t){return typeof e==`function`?e(t):e}function S(e){return`Basic ${Buffer.from(`${e.username}:${e.accessKey}`).toString(`base64`)}`}function pe(e){let t=0;for(;t<e.length&&e.charCodeAt(t)===47;)t+=1;return t===0?e:e.slice(t)}function me(e){let t=e.length-1;for(;t>=0&&e.charCodeAt(t)===47;)--t;return t===e.length-1?e:e.slice(0,t+1)}function he(e){if(e.pathname.endsWith(`/`))return e;let t=new URL(e);return t.pathname=`${t.pathname}/`,t}var ge=class{endpoint;headers;requestPolicy;sessionId;constructor(e){this.endpoint=he(new URL(e.endpoint)),this.headers={...x(e.clientVersion),...e.auth?{Authorization:S(e.auth)}:{},...e.headers},this.requestPolicy={timeoutMs:e.requestPolicy?.timeoutMs??3e4,retryAttempts:e.requestPolicy?.retryAttempts??1,retryDelayMs:e.requestPolicy?.retryDelayMs??250}}async createSession(e){let t=ye(await this.requestValue(`POST`,`/session`,{capabilities:ve(e)}));return this.sessionId=t.sessionId,t}async deleteSession(){let e=this.requireSessionId();await this.requestValue(`DELETE`,`/session/${e}`),this.sessionId=void 0}async installApp(e){await this.sessionRequest(`POST`,`/appium/device/install_app`,{appPath:e})}async activateApp(e){try{await this.sessionRequest(`POST`,`/appium/device/activate_app`,{appId:e})}catch{await this.executeScript(`mobile: activateApp`,[{appId:e,bundleId:e}])}}async terminateApp(e){try{await this.sessionRequest(`POST`,`/appium/device/terminate_app`,{appId:e})}catch{await this.executeScript(`mobile: terminateApp`,[{appId:e,bundleId:e}])}}async performActions(e){await this.sessionRequest(`POST`,`/actions`,{actions:e})}async releaseActions(){await this.sessionRequest(`DELETE`,`/actions`,void 0,{retryAttempts:0})}async sendKeys(e){await this.sessionRequest(`POST`,`/keys`,{value:Array.from(e)})}async hideKeyboard(){await this.sessionRequest(`POST`,`/appium/device/hide_keyboard`,void 0,{retryAttempts:0})}async back(){await this.sessionRequest(`POST`,`/back`)}async setRotation(e){await this.sessionRequest(`POST`,`/rotation`,{x:0,y:0,z:e})}async setOrientation(e){await this.sessionRequest(`POST`,`/orientation`,{orientation:e})}async source(){let t=await this.sessionRequest(`GET`,`/source`);if(typeof t!=`string`)throw new e(`COMMAND_FAILED`,`WebDriver source response was not a string`,{valueType:typeof t});return t}async screenshot(t){let n=await this.sessionRequest(`GET`,`/screenshot`);if(typeof n!=`string`)throw new e(`COMMAND_FAILED`,`WebDriver screenshot response was not base64 text`,{valueType:typeof n});await h.writeFile(t,Buffer.from(n,`base64`))}async windowRect(){return _e(await this.sessionRequest(`GET`,`/window/rect`))}async executeScript(e,t=[]){return await this.sessionRequest(`POST`,`/execute/sync`,{script:e,args:t})}async sessionRequest(e,t,n,r){let i=this.requireSessionId();return await this.requestValue(e,`/session/${i}${t}`,n,r)}requireSessionId(){if(!this.sessionId)throw new e(`SESSION_NOT_FOUND`,`WebDriver session has not been created yet.`);return this.sessionId}async requestValue(e,t,n,r){let i,a=r?.retryAttempts??this.requestPolicy.retryAttempts;for(let r=0;r<=a;r+=1)try{return await this.requestValueOnce(e,t,n)}catch(e){if(i=e,!Ce(e)||r>=a)throw e;await g(this.requestPolicy.retryDelayMs)}throw i}async requestValueOnce(e,t,n){let r=await fetch(new URL(pe(t),this.endpoint),{method:e,headers:{Accept:`application/json`,...n===void 0?{}:{"Content-Type":`application/json`},...this.headers},body:n===void 0?void 0:JSON.stringify(n),signal:AbortSignal.timeout(this.requestPolicy.timeoutMs)}),i=await r.text(),a=i?xe(i):{};if(!r.ok)throw Se(r.status,a);return be(a)}};function _e(t){if(!t||typeof t!=`object`)throw new e(`COMMAND_FAILED`,`WebDriver window rect response was empty.`);let n=t,r={x:C(n,`x`),y:C(n,`y`),width:C(n,`width`),height:C(n,`height`)};if(r.x===void 0||r.y===void 0||r.width===void 0||r.height===void 0)throw new e(`COMMAND_FAILED`,`WebDriver window rect response was invalid.`,{response:n});return r}function C(e,t){let n=e[t];return typeof n==`number`&&Number.isFinite(n)?n:void 0}function ve(e){return`alwaysMatch`in e||`firstMatch`in e?e:{alwaysMatch:e}}function ye(t){if(!t||typeof t!=`object`)throw new e(`COMMAND_FAILED`,`WebDriver create-session response was empty.`);let n=t,r=typeof n.sessionId==`string`?n.sessionId:typeof n.session_id==`string`?n.session_id:void 0;if(!r)throw new e(`COMMAND_FAILED`,`WebDriver create-session response missed sessionId.`,{response:n});return{sessionId:r,capabilities:n.capabilities&&typeof n.capabilities==`object`?n.capabilities:{}}}function be(e){if(!e||typeof e!=`object`)return e;let t=e;return`value`in t?t.value:e}function xe(t){try{return JSON.parse(t)}catch(n){throw new e(`COMMAND_FAILED`,`WebDriver response was not valid JSON.`,{text:t},n)}}function Se(t,n){let r=n&&typeof n==`object`&&`value`in n?n.value:n;return new e(`COMMAND_FAILED`,r&&typeof r==`object`&&typeof r.message==`string`?r.message:`WebDriver request failed with HTTP ${t}.`,{status:t,response:n})}function Ce(t){if(t instanceof e){let e=t.details?.status;return typeof e==`number`&&e>=500}return t instanceof TypeError||t instanceof Error&&t.name===`TimeoutError`}function we(e,t){return{type:`pointer`,id:e,parameters:{pointerType:`touch`},actions:t}}function Te(t){let n;try{n=te(t)}catch(t){throw new e(`COMMAND_FAILED`,`Failed to parse WebDriver page source XML: ${t instanceof Error?t.message:String(t)}`,void 0,t)}let r=[];for(let e of n)Ee(r,e);return r}function Ee(e,t,n,r=0){let i=Object.keys(t.attributes).length===0?n:De(e,t,n,r),a=i===n?r:r+1;for(let n of t.children)Ee(e,n,i,a)}function De(e,t,n,r){let i=e.length;return e.push(Oe(i,t.name,t.attributes,n,r)),i}function Oe(e,t,n,r,i){let a=ke(n),o=E(n.enabled,!0),s=E(n.displayed??n.visible,!0);return{index:e,type:t,role:Ae(t,n),label:w(n,[`content-desc`,`label`,`text`,`name`]),value:T(n.value),identifier:w(n,[`resource-id`,`id`,`accessibility-id`,`name`]),rect:a,enabled:o,selected:E(n.selected),focused:E(n.focused),visibleToUser:s,hittable:s&&o&&a!==void 0&&a.width>0&&a.height>0,depth:i,parentIndex:r}}function ke(e){let t=ee(e.bounds??null);if(t)return t;let n=D(e.x),r=D(e.y),i=D(e.width),a=D(e.height);if(!(n===void 0||r===void 0||i===void 0||a===void 0))return{x:n,y:r,width:i,height:a}}function w(e,t){for(let n of t){let t=T(e[n]);if(t!==void 0)return t}}function T(e){return e||void 0}function E(e,t=!1){return e===void 0?t:e===`true`||e===`1`}function D(e){if(e===void 0||e===``)return;let t=Number(e);return Number.isFinite(t)?t:void 0}function Ae(e,t){return T(t.class)??T(e.replace(/^XCUIElementType/,``).toLowerCase())}function je(e){let t=Te(e).flatMap(e=>Me(e)&&Ne(e.rect)?[e.rect]:[]).sort((e,t)=>t.width*t.height-e.width*e.height)[0];return t?{x:t.x,y:t.y,width:t.width,height:t.height}:void 0}function Me(e){let t=e.type?.toLowerCase()??``;return e.visibleToUser!==!1&&(t.includes(`scrollview`)||t.includes(`listview`)||t.includes(`recyclerview`))}function Ne(e){return!!e&&e.width>=50&&e.height>=50}async function Pe(t,n,r){let i=[];for(let e of n===`android`?[`rotation`,`orientation`]:[`orientation`,`rotation`])try{await ze(t,e,r);return}catch(t){if(!Le(t))throw t;i.push({transport:e,error:t instanceof Error?t.message:String(t)})}throw new e(`COMMAND_FAILED`,`Could not set device orientation to ${r} on the hosted WebDriver session.`,{hint:`The provider driver rejected both orientation endpoints. Set the orientation as a session capability instead, for example connect --provider-device-orientation portrait.`,rotation:r,attempts:i})}const Fe=new Set([`unknown command`,`unknown method`]),Ie=new Set([404,405]);function Le(t){if(!(t instanceof e)||t.code===`SESSION_NOT_FOUND`)return!1;let n=Re(t.details?.response);if(n)return Fe.has(n);let r=t.details?.status;return typeof r==`number`&&Ie.has(r)}function Re(e){if(!e||typeof e!=`object`)return``;let t=e.value;if(!t||typeof t!=`object`)return``;let n=t.error;return typeof n==`string`?n:``}async function ze(e,t,n){if(t===`rotation`){await e.setRotation(o(n));return}await e.setOrientation(s(n))}function Be(e){return new Ve(e.client,e.backend,e.capabilities)}var Ve=class{client;backend;capabilities;constructor(e,t,n){this.client=e,this.backend=t,this.capabilities=n}async open(e,t){if(this.requireSupport(`open`),t?.url){await this.client.executeScript(`mobile: deepLink`,[{url:t.url,package:e}]);return}let n=t?.appBundleId??e;n&&await this.client.activateApp(n)}async openDevice(){this.requireSupport(`open`),await this.client.executeScript(`mobile: activateApp`,[{}])}async close(e){this.requireSupport(`close`),e&&await this.client.terminateApp(e)}async tap(e,t){return this.requireSupport(`tap`),await this.pointerGesture(`tap`,[{type:`pointerMove`,duration:0,x:e,y:t},{type:`pointerDown`,button:0},{type:`pointerUp`,button:0}]),{backend:`webdriver`,x:e,y:t}}async doubleTap(e,t){return this.requireSupport(`doubleTap`),await this.pointerGesture(`doubleTap`,[{type:`pointerMove`,duration:0,x:e,y:t},{type:`pointerDown`,button:0},{type:`pointerUp`,button:0},{type:`pause`,duration:80},{type:`pointerDown`,button:0},{type:`pointerUp`,button:0}]),{backend:`webdriver`,x:e,y:t}}async swipe(e,t,n,r,i=400){return this.requireSupport(`swipe`),await this.pointerGesture(`swipe`,[{type:`pointerMove`,duration:0,x:e,y:t},{type:`pointerDown`,button:0},{type:`pointerMove`,duration:i,x:n,y:r},{type:`pointerUp`,button:0}]),{backend:`webdriver`,x1:e,y1:t,x2:n,y2:r,durationMs:i}}async longPress(e,t,n=600){return this.requireSupport(`longPress`),await this.pointerGesture(`longPress`,[{type:`pointerMove`,duration:0,x:e,y:t},{type:`pointerDown`,button:0},{type:`pause`,duration:n},{type:`pointerUp`,button:0}]),{backend:`webdriver`,x:e,y:t,durationMs:n}}async focus(e,t){return await this.tap(e,t)}async type(e){this.requireSupport(`type`),await this.client.sendKeys(e)}async fill(e,t,n,r){return this.requireSupport(`fill`),await this.tap(e,t),await this.type(n),{backend:`webdriver`,x:e,y:t,text:n}}async scroll(e,n){this.requireSupport(`scroll`);let r=n?.durationMs??350;await this.client.hideKeyboard().catch(()=>void 0);let i=await this.scrollGestureFrame(),a=t({direction:e,amount:n?.amount,pixels:n?.pixels,referenceWidth:i.width,referenceHeight:i.height}),o={...a,x1:a.x1+i.x,y1:a.y1+i.y,x2:a.x2+i.x,y2:a.y2+i.y};return await this.swipe(o.x1,o.y1,o.x2,o.y2,r),{backend:`webdriver`,...o,distance:a.pixels,durationMs:r}}async gestureViewport(){return await this.scrollGestureFrame()}async performGesture(e){return this.requireSupport(Ue(e)),await this.client.performActions(e.pointers.map(e=>we(`gesture-pointer-${e.pointerId}`,He(e.samples)))),await this.client.releaseActions().catch(()=>void 0),{backend:`webdriver-w3c-actions`}}async screenshot(e,t){this.requireSupport(`screenshot`),await this.client.screenshot(e)}async snapshot(e){return this.requireSupport(`snapshot`),{backend:this.backend,nodes:Te(await this.client.source())}}async back(e){this.requireSupport(`back`),await this.client.back()}async home(){this.requireSupport(`home`),await this.client.executeScript(`mobile: pressButton`,[{name:`home`}])}async setOrientation(e){this.requireSupport(`orientation`),await Pe(this.client,this.backend,e)}async appSwitcher(){this.requireSupport(`appSwitcher`),await this.client.executeScript(`mobile: pressButton`,[{name:`appSwitch`}])}async tvRemote(e,t){this.unsupported(`tvRemote`)}async readClipboard(){this.requireSupport(`clipboard.read`);let e=await this.client.executeScript(`mobile: getClipboard`,[{}]);return typeof e==`string`?e:``}async writeClipboard(e){this.requireSupport(`clipboard.write`),await this.client.executeScript(`mobile: setClipboard`,[{content:e}])}async setSetting(e,t,n,r){this.unsupported(`settings`)}async pointerGesture(e,t){await this.client.performActions([we(e,t)]),await this.client.releaseActions().catch(()=>void 0)}async scrollGestureFrame(){return await this.client.source().then(e=>je(e)).catch(()=>void 0)||await this.client.windowRect()}requireSupport(e){oe(this.capabilities,e)||this.unsupported(e)}unsupported(t){throw new e(`UNSUPPORTED_OPERATION`,y(this.capabilities,t),{provider:this.capabilities.provider,platform:this.capabilities.platform,operation:t})}};function He(t){let n=t[0];if(!n)throw new e(`INVALID_ARGS`,`WebDriver gesture pointer requires samples`);let r=[{type:`pointerMove`,duration:0,x:n.point.x,y:n.point.y},{type:`pointerDown`,button:0}];for(let e=1;e<t.length;e+=1){let n=t[e-1],i=t[e];r.push({type:`pointerMove`,duration:i.offsetMs-n.offsetMs,x:i.point.x,y:i.point.y})}return r.push({type:`pointerUp`,button:0}),r}function Ue(e){if(e.topology===`single`)return`swipe`;switch(e.intent){case`pan`:case`transform`:return`transformGesture`;case`pinch`:return`pinch`;case`rotate`:return`rotateGesture`}}function O(e){return new We(e)}function k(e,t,n={}){return{platformName:e===`ios`?`iOS`:`Android`,"appium:deviceName":t,...n}}var We=class{provider;leaseLifecycle;cloudArtifacts;deviceInventoryProvider;capabilities;sessionsByLeaseId=new Map;releasedProviderSessionIdsByLeaseId=new Map;options;constructor(e){this.options=e,this.provider=e.provider,this.capabilities=ae({provider:e.provider,platform:e.platform,overrides:e.capabilityOverrides}),this.leaseLifecycle={allocate:async(e,t)=>await this.allocate(e,t),heartbeat:async e=>this.heartbeat(e),release:async e=>await this.release(e)},this.cloudArtifacts={listCloudArtifacts:async e=>await this.listCloudArtifacts(e)},this.deviceInventoryProvider=async e=>{if(e.leaseProvider!==this.provider)return null;if(!e.leaseId)return[];let t=this.sessionsByLeaseId.get(e.leaseId);return t?[t.device]:[]}}ownsDevice(e){return[...this.sessionsByLeaseId.values()].some(t=>t.device.id===e.id)}getInteractor(e){return[...this.sessionsByLeaseId.values()].find(t=>t.device.id===e.id)?.interactor}async installApp(e,t,n,r){let i=this.findSessionForDevice(e);if(!i)return;let a=await this.uploadAppIfNeeded(i,e,t,n,r);return await i.client.installApp(a?.appReference??n),le(a,r)}async installInstallablePath(e,t,n){return await this.installApp(e,``,t,n)}async shutdown(){await Promise.allSettled([...this.sessionsByLeaseId.values()].map(async e=>await this.closeSession(e))),this.sessionsByLeaseId.clear()}async allocate(e,t){if(e.leaseProvider!==this.provider)return;if(this.sessionsByLeaseId.has(e.leaseId))return this.heartbeat(e);let n=await this.prepareSession(e,t),r=new ge({clientVersion:this.options.clientVersion,endpoint:n.endpoint,auth:n.auth,headers:n.headers,requestPolicy:this.options.requestPolicy}),i=await this.createSessionWithPreparedCleanup(r,n),a=this.deviceForLease(e,n),o=n.providerSessionId??i.sessionId,s=this.capabilitiesForPlatform(n.platform);return this.sessionsByLeaseId.set(e.leaseId,{lease:e,device:a,client:r,prepared:n,capabilities:s,webDriverSessionId:i.sessionId,providerSessionId:o,interactor:Be({client:r,backend:ue(n.platform),capabilities:s})}),{provider:this.provider,deviceId:a.id,sessionId:i.sessionId,providerSessionId:o,capabilities:s,...n.providerData}}async createSessionWithPreparedCleanup(e,t){try{return await e.createSession(t.webdriverCapabilities)}catch(e){throw await Ge(t,e),e}}heartbeat(e){if(e.leaseProvider===this.provider&&this.sessionsByLeaseId.has(e.leaseId))return{provider:this.provider}}async release(e){if(e.leaseProvider!==this.provider)return;let t=this.sessionsByLeaseId.get(e.leaseId);if(!t)return;this.sessionsByLeaseId.delete(e.leaseId),this.releasedProviderSessionIdsByLeaseId.set(e.leaseId,t.providerSessionId);let n=await this.closeSession(t),r=await this.safeListArtifacts(t);return{provider:this.provider,providerSessionId:t.providerSessionId,...n.cleanup,...n.warnings.length>0?{warnings:n.warnings}:{},...r?{cloudArtifacts:r}:{}}}async listCloudArtifacts(e){if(e.provider!==this.provider)return;let t=e.leaseId?this.sessionsByLeaseId.get(e.leaseId):void 0;if(t)return await this.safeListArtifacts(t);let n=e.providerSessionId??(e.leaseId?this.releasedProviderSessionIdsByLeaseId.get(e.leaseId):void 0);if(!(!n||!this.options.listArtifacts))return await this.options.listArtifacts({provider:this.provider,providerSessionId:n})}async prepareSession(e,t){let n=this.baseSessionForLease(e);return this.options.prepareSession?await this.options.prepareSession({lease:e,req:t,base:n}):n}capabilitiesForPlatform(e){return ae({provider:this.provider,platform:e,overrides:this.options.capabilityOverrides})}baseSessionForLease(e){let t=typeof this.options.webdriverCapabilities==`function`?this.options.webdriverCapabilities(e):this.options.webdriverCapabilities??{};return{provider:this.provider,endpoint:this.options.endpoint,platform:this.options.platform,deviceName:this.options.deviceName,auth:this.options.auth,headers:this.options.headers,webdriverCapabilities:k(this.options.platform,this.options.deviceName,t)}}deviceForLease(e,t){return{...r(t.platform),id:t.deviceId??this.options.deviceId?.(e)??`${this.provider}:${t.platform}:${e.leaseId}`,name:t.deviceName,kind:`device`,target:`mobile`,booted:!0}}findSessionForDevice(e){return[...this.sessionsByLeaseId.values()].find(t=>t.device.id===e.id)}async uploadAppIfNeeded(t,r,i,a,o){if(!oe(t.capabilities,`install`))throw new e(`UNSUPPORTED_OPERATION`,y(t.capabilities,`install`),{provider:this.provider,deviceId:r.id,platform:n(r)});let s=t.prepared.uploadApp??this.options.uploadApp;if(s)return await s({provider:this.provider,lease:t.lease,device:r,app:i,appPath:a,options:o})}async closeSession(e){let t=[],n;try{await e.client.deleteSession()}catch(e){t.push({code:`WEBDRIVER_SESSION_DELETE_FAILED`,message:A(e)})}try{n=await e.prepared.cleanup?.()}catch(e){t.push({code:`PROVIDER_CLEANUP_FAILED`,message:A(e)})}return{cleanup:n,warnings:t}}async safeListArtifacts(e){let t=e.prepared.listArtifacts??this.options.listArtifacts;if(t)try{return await t({provider:this.provider,lease:e.lease,device:e.device,webDriverSessionId:e.webDriverSessionId,providerSessionId:e.providerSessionId})}catch(t){return ce({provider:this.provider,providerSessionId:e.providerSessionId,error:t})}}};function A(e){return e instanceof Error?e.message:String(e)}async function Ge(t,n){try{await t.cleanup?.()}catch(t){n instanceof e&&(n.details={...n.details,cleanupError:A(t)})}}async function j(e,t,n){if(t)return b({provider:e,providerSessionId:t,artifacts:(await Promise.all([n.listArtifacts(t,`FILE`),n.listArtifacts(t,`LOG`)])).flat().flatMap(n=>qe(e,t,n)),pendingMessage:`AWS Device Farm artifacts are not ready yet.`})}function Ke(e){if(!e||typeof e!=`object`)return[];let t=e.artifacts;return Array.isArray(t)?t:[]}function qe(e,t,n){let r=n.url;return typeof r!=`string`||r.length===0?[]:[{provider:e,providerSessionId:t,kind:Je(n.type),name:n.name??n.type??`AWS Device Farm artifact`,url:r,providerArtifactId:n.arn,extension:n.extension,availability:`ready`,metadata:{awsType:n.type,...n.metadata?{awsMetadata:n.metadata}:{}}}]}function Je(e){switch(e){case`VIDEO`:return`video`;case`APPIUM_SERVER_OUTPUT`:return`appium-log`;case`DEVICE_LOG`:return`device-log`;case`MESSAGE_LOG`:case`UNKNOWN`:return`automation-log`;default:return`raw`}}const M={browserStack:`browserstack`,awsDeviceFarm:`aws-device-farm`},Ye=new Set(Object.values(M));function Xe(e){return e!==void 0&&Ye.has(e)}M.awsDeviceFarm;const Ze={install:{support:`unsupported`,note:`Pass appArn when creating the remote access session; local artifact upload/install is not implemented.`},portReverse:{support:`unsupported`,note:`AWS Device Farm remote access does not expose agent-device port reverse.`},artifacts:{support:`supported`,note:`AWS Device Farm remote access exposes provider-hosted video, Appium logs, and device logs after session completion.`}};function N(e){let t=P(e);return{createRemoteAccessSession:async e=>F(await t(`create-remote-access-session`,[`--project-arn`,e.projectArn,`--device-arn`,e.deviceArn,`--name`,e.name,...e.appArn?[`--app-arn`,e.appArn]:[],...e.interactionMode?[`--interaction-mode`,e.interactionMode]:[],...e.configuration?[`--configuration`,JSON.stringify(e.configuration)]:[]])),getRemoteAccessSession:async e=>F(await t(`get-remote-access-session`,[`--arn`,e])),stopRemoteAccessSession:async e=>F(await t(`stop-remote-access-session`,[`--arn`,e])),listArtifacts:async(e,n)=>Ke(await t(`list-artifacts`,[`--arn`,e,`--type`,n]))}}function Qe(t){return async({lease:n,base:r})=>{let i=await tt((await t.client.createRemoteAccessSession({projectArn:t.projectArn,deviceArn:t.deviceArn,appArn:t.appArn,name:fe(t.sessionName,n)??`agent-device-${n.leaseId}`,interactionMode:t.interactionMode,configuration:t.configuration})).arn,t),a=$e(i);if(!a)throw new e(`COMMAND_FAILED`,`AWS Device Farm did not expose a WebDriver endpoint.`,{sessionArn:i.arn,status:i.status});let o=i.device?.name??t.deviceName,s=typeof t.webdriverCapabilities==`function`?t.webdriverCapabilities(n):t.webdriverCapabilities??{};return{...r,endpoint:a,platform:t.platform,deviceName:o,webdriverCapabilities:k(t.platform,o,s),cleanup:async()=>(await t.client.stopRemoteAccessSession(i.arn),{awsDeviceFarmSessionArn:i.arn}),providerSessionId:i.arn,providerData:{awsDeviceFarmSessionArn:i.arn}}}}function $e(e){let t=e.endpoints&&typeof e.endpoints==`object`?Object.values(e.endpoints):[],n=[e.remoteDriverEndpoint,e.endpoint,...t,e.remoteDebugUrl,e.remoteRecordAppUrl].filter(e=>typeof e==`string`&&e.length>0).find(e=>!/^wss?:\/\//i.test(e));return n?et(n):void 0}function et(e){return/^https?:\/\//i.test(e)?e:`http://${e}`}async function tt(t,n){let r=n.startupTimeoutMs??12e4,i=n.pollIntervalMs??5e3,a=Date.now(),o=await n.client.getRemoteAccessSession(t);for(;Date.now()-a<r;){if(o.status===`RUNNING`)return o;if(o.status===`ERRORED`||o.status===`STOPPED`||o.status===`COMPLETED`)throw new e(`COMMAND_FAILED`,`AWS Device Farm remote access session did not start.`,{sessionArn:t,status:o.status,result:o.result});await g(i),o=await n.client.getRemoteAccessSession(t)}throw new e(`COMMAND_FAILED`,`Timed out waiting for AWS Device Farm remote access.`,{sessionArn:t,status:o.status,result:o.result,timeoutMs:r})}async function nt(t,n,r){let i=await t(n,r);try{return JSON.parse(i.stdout)}catch(t){throw new e(`COMMAND_FAILED`,`AWS Device Farm returned invalid JSON.`,void 0,t)}}function P(e){let t=e.region?[`--region`,e.region]:[],n=e.awsCommand??`aws`;return async(r,i)=>await nt(e.runHostCommand,n,[`devicefarm`,r,...t,...i,`--output`,`json`])}function F(t){if(!t||typeof t!=`object`)throw new e(`COMMAND_FAILED`,`AWS Device Farm response was not an object.`,{response:t});let n=t.remoteAccessSession;if(!n||typeof n!=`object`)throw new e(`COMMAND_FAILED`,`AWS Device Farm response missed remoteAccessSession.`,{response:t});return n}const I=[{field:`providerDeviceOrientation`,capability:`deviceOrientation`,flag:`--provider-device-orientation`,type:`enum`,enumValues:a},{field:`providerGeoLocation`,capability:`geoLocation`,flag:`--provider-geo-location`,type:`string`},{field:`providerTimezone`,capability:`timezone`,flag:`--provider-timezone`,type:`string`},{field:`providerLanguage`,capability:`language`,flag:`--provider-language`,type:`string`},{field:`providerLocale`,capability:`locale`,flag:`--provider-locale`,type:`string`},{field:`providerNetworkProfile`,capability:`networkProfile`,flag:`--provider-network-profile`,type:`string`},{field:`providerCustomNetwork`,capability:`customNetwork`,flag:`--provider-custom-network`,type:`string`},{field:`providerNoResignApp`,capability:`resignApp`,flag:`--provider-no-resign-app`,type:`negated-boolean`,platform:`ios`}];function rt(e,t){lt(e);let n={};for(let r of I){let i=e[r.field];i===void 0||i===!1||i===``||(ct(r,t),n[r.capability]=r.type===`negated-boolean`?!1:i)}return n}function it(e){return I.filter(t=>{let n=e?.[t.field];return n!==void 0&&n!==!1&&n!==``}).map(e=>e.flag)}function L(t,n){let r=it(t);if(r.length===0)return;let i=r.length!==1;throw new e(`INVALID_ARGS`,`${r.join(`, `)} ${i?`are`:`is`} only supported by BrowserStack, not ${n}.`,{hint:`Drop ${i?`those flags`:`the flag`} or use the browserstack provider.`,provider:n,flags:r})}function at(e){let t={};for(let n of I){let r=e?.[n.field];if(n.type===`negated-boolean`){r===!0&&(t.providerNoResignApp=!0);continue}typeof r!=`string`||r.length===0||ot(t,n,r)}return t}function ot(e,t,n){if(t.field===`providerDeviceOrientation`){e.providerDeviceOrientation=st(t,n);return}t.field!==`providerNoResignApp`&&(e[t.field]=n)}function st(t,n){let r=a.find(e=>e===n);if(r)return r;throw new e(`INVALID_ARGS`,`Invalid ${t.flag} value: ${n}.`,{hint:`Use ${a.join(`|`)}.`,flag:t.flag,capability:t.capability})}function ct(t,n){if(!(!t.platform||t.platform===n))throw new e(`INVALID_ARGS`,`${t.flag} applies to ${t.platform} sessions only, but the session platform is ${n}.`,{hint:`Drop ${t.flag} or connect with --platform ${t.platform}.`,flag:t.flag,capability:t.capability,platform:n})}function lt(t){if(!(!t.providerNetworkProfile||!t.providerCustomNetwork))throw new e(`INVALID_ARGS`,`BrowserStack accepts either a named network profile or a custom network shape, not both.`,{hint:`Pass only one of --provider-network-profile or --provider-custom-network.`,networkProfile:t.providerNetworkProfile,customNetwork:t.providerCustomNetwork})}M.browserStack;const ut={install:{support:`partial`,note:`Local app artifacts are uploaded to BrowserStack App Automate, then installed with Appium.`},portReverse:{support:`unsupported`,note:`Use BrowserStack Local for network tunneling; agent-device port reverse is not available.`},artifacts:{support:`supported`,note:`BrowserStack session details expose provider-hosted video, Appium logs, device logs, and dashboard links.`}};async function R(e,t,n){if(t)return b({provider:e,providerSessionId:t,artifacts:ht(e,t,await mt(t,n)),pendingMessage:`BrowserStack artifacts are not ready yet.`})}async function z(t,n){let r=await h.readFile(t),i=new FormData;i.set(`file`,new Blob([r]),f.basename(t));let a=await fetch(n.endpoint??`https://api-cloud.browserstack.com/app-automate/upload`,{method:`POST`,headers:{...x(n.clientVersion),Authorization:S(n)},body:i}),o=await a.json(),s=gt(o);if(!a.ok||!s)throw new e(`COMMAND_FAILED`,`BrowserStack app upload failed.`,{status:a.status,response:o});return s}function dt(e){return async({appPath:t,options:n})=>({appReference:await z(t,e),bundleId:n?.appIdentifierHint,packageName:n?.packageNameHint,launchTarget:n?.appIdentifierHint??n?.packageNameHint})}function ft(e){let{"bstack:options":t,...n}=e.configured??{};return{device:e.deviceName,os_version:e.osVersion,...e.app?{app:e.app}:{},...n,"bstack:options":{...e.projectName?{projectName:e.projectName}:{},buildName:e.buildName,sessionName:e.sessionName,...e.deviceFeatures??{},...pt(t)}}}function pt(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:{}}async function mt(t,n){let r=new URL(`${me(String(n.endpoint??`https://api-cloud.browserstack.com/app-automate/sessions`))}/${t}.json`),i=await fetch(r,{headers:{...x(n.clientVersion),Authorization:S(n)}}),a=await i.json();if(!i.ok||!a||typeof a!=`object`)throw new e(`COMMAND_FAILED`,`BrowserStack session details lookup failed.`,{status:i.status,response:a});let o=a.automation_session??a;return o&&typeof o==`object`?o:{}}function ht(e,t,n){return[B(e,t,n,`video_url`,`video`,`Session video`),B(e,t,n,`appium_logs_url`,`appium-log`,`Appium logs`),B(e,t,n,`device_logs_url`,`device-log`,`Device logs`),B(e,t,n,`browser_url`,`provider-session`,`BrowserStack dashboard`),B(e,t,n,`public_url`,`provider-session`,`Public session link`)].filter(e=>e!==void 0)}function B(e,t,n,r,i,a){let o=n[r];if(!(typeof o!=`string`||o.length===0))return{provider:e,providerSessionId:t,kind:i,name:a,url:o,availability:`ready`}}function gt(e){if(!e||typeof e!=`object`)return;let t=e.app_url;return typeof t==`string`?t:void 0}function V(e){return/^arn:[^:]+:devicefarm:([^:]+):/.exec(e)?.[1]}async function _t(t,n){let r=P({runHostCommand:n,region:t.region}),[i,a,o]=await Promise.all([r(`get-project`,[`--arn`,t.projectArn]),r(`get-device`,[`--arn`,t.deviceArn]),t.appArn?r(`get-upload`,[`--arn`,t.appArn]):void 0]),s=H(i,`project`),c=H(a,`device`),l=yt(c.platform);if(l!==t.platform)throw new e(`INVALID_ARGS`,`AWS Device Farm device "${U(c.name)??t.deviceArn}" is ${l}, not ${t.platform}.`);let u=t.appArn?vt(H(o,`upload`),t):{status:`missing`,message:`No app upload is attached; AWS Device Farm does not support install after allocation. Reconnect with --aws-app-arn <arn>.`};return{provider:`aws-device-farm`,service:`AWS Device Farm`,verificationMessage:t.appArn?`Credentials, project, device, and app upload verified.`:`Credentials, project, and device verified.`,project:{name:U(s.name),reference:t.projectArn},device:{status:`verified`,name:U(c.name)??t.deviceArn,reference:t.deviceArn,platform:l,osVersion:U(c.os),availability:U(c.availability)},app:u}}function vt(t,n){let r=U(t.status);if(r!==`SUCCEEDED`)throw new e(`COMMAND_FAILED`,`AWS Device Farm app upload is not ready (${r??`unknown status`}).`,{status:r,hint:`Wait for the upload to succeed or reconnect with a different --aws-app-arn.`});let i=n.platform===`android`?`ANDROID_APP`:`IOS_APP`,a=U(t.type);if(a!==i)throw new e(`INVALID_ARGS`,`AWS Device Farm app upload type is ${a??`unknown`}, expected ${i}.`);return{status:`verified`,name:U(t.name),reference:n.appArn}}function H(t,n){if(!t||typeof t!=`object`)throw new e(`COMMAND_FAILED`,`AWS Device Farm ${n} response was not an object.`);let r=t[n];if(!r||typeof r!=`object`||Array.isArray(r))throw new e(`COMMAND_FAILED`,`AWS Device Farm response missed ${n}.`);return r}function yt(t){if(t===`ANDROID`)return`android`;if(t===`IOS`)return`ios`;throw new e(`UNSUPPORTED_PLATFORM`,`AWS Device Farm device platform is ${String(t)}.`)}function U(e){return typeof e==`string`&&e.length>0?e:void 0}async function bt(t,n){let r={username:t.username,accessKey:t.accessKey},i=Ct(await W(t.devicesEndpoint??`https://api-cloud.browserstack.com/app-automate/devices.json`,r,n)).find(e=>e.device===t.deviceName&&e.os.toLowerCase()===t.platform&&St(e.osVersion,t.osVersion));if(!i)throw new e(`INVALID_ARGS`,`BrowserStack device "${t.deviceName}" with ${t.platform} ${t.osVersion} is not available.`,{hint:`Choose an exact device and OS version from the BrowserStack App Automate device list.`});let a=await xt(t,r,n);return{provider:`browserstack`,service:`BrowserStack`,verificationMessage:a.status===`verified`?`Credentials, device, and uploaded app verified.`:`Credentials and device access verified; app availability is checked when the session is created.`,device:{status:`verified`,name:i.device,platform:t.platform,osVersion:i.osVersion},app:a}}async function xt(e,t,n){let{app:r}=e;if(r.startsWith(`bs://`)){let i=wt(await W(e.appsEndpoint??`https://api-cloud.browserstack.com/app-automate/recent_apps?limit=100`,t,n)).find(e=>e.reference===r);return i?{status:`verified`,...i}:{status:`configured`,reference:r,message:`App reference was not found in the 100 most recent uploads; BrowserStack validates it when creating the session.`}}return/^https?:\/\//i.test(r)?{status:`configured`,reference:r,message:`Public app URL configured; BrowserStack validates it when creating the session.`}:{status:`configured`,name:f.basename(r),reference:r,message:`Local app artifact is ready and will be uploaded when creating the session.`}}async function W(t,n,r){try{let i=await fetch(t,{headers:{...x(r),Authorization:S(n)},signal:AbortSignal.timeout(15e3)});if(!i.ok){let t=i.status===401||i.status===403;throw new e(t?`UNAUTHORIZED`:`COMMAND_FAILED`,`BrowserStack rejected connection verification.`,{status:i.status,hint:t?`Check BROWSERSTACK_USERNAME and BROWSERSTACK_ACCESS_KEY.`:`Retry connect or check the BrowserStack service status.`})}return await i.json()}catch(t){throw t instanceof e?t:new e(`COMMAND_FAILED`,`BrowserStack connection verification failed.`,{hint:`Check network access to api-cloud.browserstack.com and retry connect.`},t)}}function St(e,t){let n=e=>e.replace(/(?:\.0)+$/,``);return n(e)===n(t)}function Ct(t){if(!Array.isArray(t))throw new e(`COMMAND_FAILED`,`BrowserStack device verification response was not a list.`);return t.flatMap(e=>{let t=G(e),n=t?.os_version;return t&&typeof t.device==`string`&&typeof t.os==`string`&&(typeof n==`string`||typeof n==`number`)?[{device:t.device,os:t.os,osVersion:String(n)}]:[]})}function wt(t){let n=G(t);if(n&&Object.keys(n).length===0)return[];if(!Array.isArray(t))throw new e(`COMMAND_FAILED`,`BrowserStack app verification response was not a list.`);return t.flatMap(e=>{let t=G(e);return!t||typeof t.app_url!=`string`?[]:[{reference:t.app_url,...typeof t.app_name==`string`?{name:t.app_name}:{},...typeof t.app_version==`string`?{version:t.app_version}:{}}]})}function G(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:void 0}async function Tt(e,t){return e.provider===`browserstack`?await bt(e,t.clientVersion):await _t(e,t.runHostCommand)}function Et(e){return[{provider:M.browserStack,createRuntime:t=>O({clientVersion:e.clientVersion,provider:M.browserStack,platform:`android`,deviceName:`BrowserStack device`,endpoint:t.BROWSERSTACK_WEBDRIVER_ENDPOINT??`https://hub-cloud.browserstack.com/wd/hub/`,capabilityOverrides:ut,listArtifacts:async({provider:n,providerSessionId:r})=>{let i=X(t,`BROWSERSTACK_USERNAME`,`BrowserStack artifact lookup`),a=X(t,`BROWSERSTACK_ACCESS_KEY`,`BrowserStack artifact lookup`);return await R(n,r,{clientVersion:e.clientVersion,username:i,accessKey:a,endpoint:t.BROWSERSTACK_SESSION_DETAILS_ENDPOINT})},prepareSession:async({req:n,lease:r,base:i})=>{let a=K(n,`BrowserStack`),o=X(t,`BROWSERSTACK_USERNAME`,`BrowserStack`),s=X(t,`BROWSERSTACK_ACCESS_KEY`,`BrowserStack`),c=q(a,`BrowserStack`),l=J(a,`device`,`BrowserStack requires --device <name>.`),u=J(a,`providerOsVersion`,`BrowserStack requires --provider-os-version <version>.`),d=await Dt({clientVersion:e.clientVersion,app:J(a,`providerApp`,`BrowserStack requires --provider-app <bs://app-id-or-local-path>.`),cwd:a.cwd,username:o,accessKey:s,uploadEndpoint:t.BROWSERSTACK_APP_UPLOAD_ENDPOINT});return{...i,platform:c,deviceName:l,auth:{username:o,accessKey:s},uploadApp:dt({clientVersion:e.clientVersion,username:o,accessKey:s,endpoint:t.BROWSERSTACK_APP_UPLOAD_ENDPOINT??`https://api-cloud.browserstack.com/app-automate/upload`}),webdriverCapabilities:ft({deviceName:l,osVersion:u,app:d,projectName:Y(a,`providerProject`),buildName:Y(a,`providerBuild`)??r.runId,sessionName:Y(a,`providerSessionName`)??r.leaseId,deviceFeatures:rt(at(a.flags),c),configured:k(c,l)})}}}),listArtifactsFromEnv:async(t,n)=>{let r=X(n,`BROWSERSTACK_USERNAME`,`BrowserStack artifact lookup`),i=X(n,`BROWSERSTACK_ACCESS_KEY`,`BrowserStack artifact lookup`);return await R(M.browserStack,t,{clientVersion:e.clientVersion,username:r,accessKey:i,endpoint:n.BROWSERSTACK_SESSION_DETAILS_ENDPOINT})}},{provider:M.awsDeviceFarm,createRuntime:t=>O({clientVersion:e.clientVersion,provider:M.awsDeviceFarm,endpoint:`http://127.0.0.1/`,platform:`android`,deviceName:`AWS Device Farm device`,capabilityOverrides:Ze,listArtifacts:async({provider:n,providerSessionId:r})=>await j(n,r,N({runHostCommand:e.runHostCommand,region:t.AWS_REGION??t.AWS_DEFAULT_REGION??V(r??``)})),prepareSession:async({req:n,lease:r,base:i})=>{let a=K(n,`AWS Device Farm`);L(a.flags,M.awsDeviceFarm);let o=q(a,`AWS Device Farm`);return await Qe({client:N({runHostCommand:e.runHostCommand,region:Y(a,`awsRegion`)??t.AWS_REGION??t.AWS_DEFAULT_REGION}),projectArn:kt(a,t,`awsProjectArn`,`AGENT_DEVICE_AWS_DEVICE_FARM_PROJECT_ARN`,`AWS_DEVICE_FARM_PROJECT_ARN`),deviceArn:kt(a,t,`awsDeviceArn`,`AGENT_DEVICE_AWS_DEVICE_FARM_DEVICE_ARN`,`AWS_DEVICE_FARM_DEVICE_ARN`),appArn:Y(a,`awsAppArn`)??t.AGENT_DEVICE_AWS_DEVICE_FARM_APP_ARN??t.AWS_DEVICE_FARM_APP_ARN,platform:o,deviceName:Y(a,`device`)??`AWS Device Farm device`,sessionName:Y(a,`providerSessionName`)??r.leaseId,interactionMode:At(a)})({lease:r,req:n,base:i})}}),listArtifactsFromEnv:async(t,n)=>{let r=N({runHostCommand:e.runHostCommand,region:n.AWS_REGION??n.AWS_DEFAULT_REGION??V(t)});return await j(M.awsDeviceFarm,t,r)}}]}async function Dt(t){if(Ot(t.app))return t.app;let n=f.resolve(t.cwd??process.cwd(),t.app);if(!m.existsSync(n))throw new e(`INVALID_ARGS`,`BrowserStack --provider-app must be a bs:// app id, URL, or existing local app path.`,{providerApp:t.app});return await z(n,{clientVersion:t.clientVersion,username:t.username,accessKey:t.accessKey,endpoint:t.uploadEndpoint})}function Ot(e){return e.startsWith(`bs://`)||/^https?:\/\//.test(e)}function K(t,n){if(t)return t;throw new e(`INVALID_ARGS`,`${n} lease allocation requires provider profile flags on the request.`)}function q(t,n){let r=t.flags?.platform;if(r===`android`||r===`ios`)return r;throw new e(`INVALID_ARGS`,`${n} requires --platform ios|android.`)}function J(t,n,r){let i=Y(t,n);if(i)return i;throw new e(`INVALID_ARGS`,r)}function Y(e,t){let n=e.flags?.[t];return typeof n==`string`&&n.length>0?n:void 0}function X(t,n,r){let i=t[n];if(i)return i;throw new e(`INVALID_ARGS`,`${r} requires ${n} in the environment.`)}function kt(t,n,r,i,a){let o=Y(t,r)??n[i]??n[a];if(o)return o;throw new e(`INVALID_ARGS`,`AWS Device Farm requires --${jt(String(r))} or ${a}.`)}function At(e){let t=Y(e,`awsInteractionMode`);if(t===`INTERACTIVE`||t===`NO_VIDEO`||t===`VIDEO_ONLY`)return t}function jt(e){return e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}function Mt(e){let t=Et(e);return{providerIds:t.map(e=>e.provider),createDefaultRuntimes:(e=process.env)=>t.map(t=>t.createRuntime(e)),listArtifactsFromEnv:async(e,n)=>{if(e.providerSessionId)return await t.find(t=>t.provider===e.provider)?.listArtifactsFromEnv(e.providerSessionId,n)},verifyConnection:async t=>await Tt(t,e)}}const Nt=Mt({clientVersion:l(),runHostCommand:async(e,t)=>({stdout:(await c(e,[...t],{maxBuffer:10*1024*1024,timeoutMs:3e4})).stdout})});function Pt(){return{pid:process.pid,startTime:d(process.pid)}}function Ft(e,t){return e.pid===t.pid&&e.startTime===t.startTime}function It(e){let{owner:t,stateDir:n}=e;if(!u(t.pid)||t.startTime&&d(t.pid)!==t.startTime)return`owner-process-dead`;if(!n)return`live`;try{return m.statSync(n),`live`}catch(e){let t=e?.code;return t===`ENOENT`||t===`ENOTDIR`?`owner-state-dir-gone`:`unknown`}}function Z(){let e=process.env.AGENT_DEVICE_CLAIMS_DIR?.trim();return e?f.resolve(e):f.join(ne.homedir(),`.agent-device`,`device-claims`)}function Lt(e){let t=p.createHash(`sha256`).update(e).digest(`hex`);return f.join(Z(),`${t}.json`)}function Rt(e){let t=Z(),n=zt(t);return`claims`in n?n.claims:n.entries.filter(e=>e.isFile()&&e.name.endsWith(`.json`)).map(e=>Wt(f.join(t,e.name))).filter(e=>e!==null).filter(t=>Bt(t.claim,e))}function zt(e){try{return{entries:m.readdirSync(e,{withFileTypes:!0})}}catch(t){let n=t.code;return n===`ENOENT`||n===`ENOTDIR`?{claims:[]}:{claims:[{fileName:f.basename(e),classification:`unknown`,error:String(t)}]}}}function Bt(e,t){return e?[Vt(e,t.udid??t.serial),Ht(e,t.device),Ut(e,t.platform)].every(Boolean):!0}function Vt(e,t){return!t||e.device.id===t}function Ht(e,t){return!t||e.device.name===t||e.device.id===t}function Ut(e,t){return i({...r(e.device.platform),appleOs:e.device.appleOs},t)}function Wt(e){let t=f.basename(e);try{return Gt(t,m.readFileSync(e,`utf8`))}catch(e){let n=e.code;return n===`ENOENT`||n===`ENOTDIR`?null:{fileName:t,classification:`unknown`,error:String(e)}}}function Gt(e,t){try{let n=Kt(JSON.parse(t));return n?{fileName:e,deviceKey:n.deviceKey,claim:n,classification:It({owner:{pid:n.ownerPid,startTime:n.ownerStartTime},stateDir:n.stateDir})}:{fileName:e,classification:`inconsistent`}}catch(t){return{fileName:e,classification:`inconsistent`,error:String(t)}}}function Kt(e){if(!qt(e))return null;let t=e;return Jt(t)?t:null}function qt(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function Jt(e){return e.schemaVersion===1&&Yt(e.device)&&[e.deviceKey,e.session,e.workspace,e.stateDir,e.ownerToken].every(Xt)&&Zt(e.ownerPid)&&Qt(e.createdAtMs)&&Qt(e.updatedAtMs)}function Yt(e){if(!qt(e))return!1;let t=e;return[t.id,t.name,t.platform,t.kind].every(Xt)}function Xt(e){return typeof e==`string`&&e.length>0}function Zt(e){return typeof e==`number`&&Number.isInteger(e)&&e>0}function Qt(e){return typeof e==`number`&&Number.isFinite(e)}function $t(e,t){let n={providerReleases:{released:t.released.map(nn),pending:t.pending.map(nn)}},r=Q(e),i=`${r}.${process.pid}.${Date.now()}.tmp`;try{m.writeFileSync(i,`${JSON.stringify(n)}\n`,{mode:384}),m.renameSync(i,r),m.chmodSync(r,384)}catch{try{m.rmSync(i,{force:!0})}catch{}}}function en(e){try{let t=JSON.parse(m.readFileSync(Q(e),`utf8`));return rn(t)?t:null}catch{return null}}function tn(e){try{m.rmSync(Q(e),{force:!0})}catch{}}function Q(e){return f.join(e,`daemon-shutdown.json`)}function nn(e){return{leaseId:e.leaseId,...e.leaseProvider?{provider:e.leaseProvider}:{}}}function rn(e){if(!e||typeof e!=`object`)return!1;let t=e.providerReleases;if(!t||typeof t!=`object`)return!1;let n=t;return Array.isArray(n.released)&&Array.isArray(n.pending)&&n.released.every(an)&&n.pending.every(an)}function an(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.leaseId==`string`&&t.leaseId.trim().length>0&&(t.provider===void 0||typeof t.provider==`string`)}const $={control:{retryMaxRetries:3},command:{retryTapMaxAttempts:2,targetLookupTimeoutMs:17e3,optionalTargetLookupTimeoutMs:7e3,scrollUntilVisibleTimeoutMs:2e4,waitForAnimationToEndTimeoutMs:15e3,waitForAnimationToEndDifferencePercent:.005,longPressDurationMs:3e3,swipeDurationMs:400,repeatDelayMs:100,scrollUntilVisibleSpeed:40,scrollUntilVisiblePercentage:100,eraseTextMaxCharacters:50},observation:{pollIntervalMs:200,defaultSettleAttempts:10},targetSwipe:{nearEdgeFraction:.1,farEdgeFraction:.9},screenSwipe:{nearEdgeFraction:.1,farEdgeFraction:.9,centerFraction:.5,downStartFraction:.2,upStartFraction:{android:.5,ios:.9}},scrollUntilVisibleSwipe:{nearEdgeFraction:.1,farEdgeFraction:.9}};function on(e){return Math.trunc(1e3*(100-e)/100)+1}const sn={assertVisibleTimeoutMs:$.command.targetLookupTimeoutMs,assertNotVisibleTimeoutMs:$.command.targetLookupTimeoutMs,extendedWaitUntilTimeoutMs:$.command.targetLookupTimeoutMs,runFlowConditionTimeoutMs:$.command.optionalTargetLookupTimeoutMs},cn=$.observation.pollIntervalMs*$.observation.defaultSettleAttempts,ln=[`id`,`text`,`enabled`,`selected`],un=[...ln,`label`],dn={textKeys:[`id`,`text`,`label`],booleanKeys:[`enabled`,`selected`]};export{re as C,Xe as S,Pt as _,$ as a,L as b,tn as c,Wt as d,Rt as f,Ft as g,It as h,sn as i,en as l,Z as m,dn as n,cn as o,Lt as p,un as r,on as s,ln as t,$t as u,Nt as v,M as x,V as y};
1
+ const e={control:{retryMaxRetries:3},command:{retryTapMaxAttempts:2,targetLookupTimeoutMs:17e3,optionalTargetLookupTimeoutMs:7e3,scrollUntilVisibleTimeoutMs:2e4,waitForAnimationToEndTimeoutMs:15e3,waitForAnimationToEndDifferencePercent:.005,longPressDurationMs:3e3,swipeDurationMs:400,repeatDelayMs:100,scrollUntilVisibleSpeed:40,scrollUntilVisiblePercentage:100,eraseTextMaxCharacters:50},observation:{pollIntervalMs:200,defaultSettleAttempts:10},targetSwipe:{nearEdgeFraction:.1,farEdgeFraction:.9},screenSwipe:{nearEdgeFraction:.1,farEdgeFraction:.9,centerFraction:.5,downStartFraction:.2,upStartFraction:{android:.5,ios:.9}},scrollUntilVisibleSwipe:{nearEdgeFraction:.1,farEdgeFraction:.9}};function t(e){return Math.trunc(1e3*(100-e)/100)+1}const n={assertVisibleTimeoutMs:e.command.targetLookupTimeoutMs,assertNotVisibleTimeoutMs:e.command.targetLookupTimeoutMs,extendedWaitUntilTimeoutMs:e.command.targetLookupTimeoutMs,runFlowConditionTimeoutMs:e.command.optionalTargetLookupTimeoutMs},r=e.observation.pollIntervalMs*e.observation.defaultSettleAttempts,i=[`id`,`text`,`enabled`,`selected`],a=[...i,`label`],o={textKeys:[`id`,`text`,`label`],booleanKeys:[`enabled`,`selected`]};export{e as a,n as i,o as n,r as o,a as r,t as s,i as t};
@@ -1 +1 @@
1
- import{Bt as e,Ct as t,Ht as n,Tt as r,Ut as i,Wt as a,zt as o}from"./sdk-batch-runner.js";import{t as s}from"./sdk-selectors.js";export{t as findSelectorChainMatch,s as formatSelectorFailure,i as isNodeEditable,a as isNodeVisible,o as isSelectorToken,e as parseSelectorChain,r as resolveSelectorChain,n as tryParseSelectorChain};
1
+ import{_n as e,bn as t,en as n,gn as r,nn as i,xn as a,yn as o}from"./sdk-batch-runner.js";import{t as s}from"./sdk-selectors.js";export{n as findSelectorChainMatch,s as formatSelectorFailure,t as isNodeEditable,a as isNodeVisible,r as isSelectorToken,e as parseSelectorChain,i as resolveSelectorChain,o as tryParseSelectorChain};