agent-device 0.18.2 → 0.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (216) hide show
  1. package/android-multitouch-helper/dist/{agent-device-android-multitouch-helper-0.18.2.apk → agent-device-android-multitouch-helper-0.19.0.apk} +0 -0
  2. package/android-multitouch-helper/dist/agent-device-android-multitouch-helper-0.19.0.apk.sha256 +1 -0
  3. package/android-multitouch-helper/dist/{agent-device-android-multitouch-helper-0.18.2.manifest.json → agent-device-android-multitouch-helper-0.19.0.manifest.json} +4 -4
  4. package/android-snapshot-helper/dist/{agent-device-android-snapshot-helper-0.18.2.apk → agent-device-android-snapshot-helper-0.19.0.apk} +0 -0
  5. package/android-snapshot-helper/dist/agent-device-android-snapshot-helper-0.19.0.apk.sha256 +1 -0
  6. package/android-snapshot-helper/dist/{agent-device-android-snapshot-helper-0.18.2.manifest.json → agent-device-android-snapshot-helper-0.19.0.manifest.json} +6 -6
  7. package/dist/apple-runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTapPointPolicy.swift +28 -0
  8. package/{apple-runner → dist/apple-runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+AXSnapshotFallback.swift +9 -120
  9. package/{apple-runner → dist/apple-runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+CommandExecution.swift +132 -66
  10. package/dist/apple-runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+CommandJournal.swift +155 -0
  11. package/dist/apple-runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+FlatSnapshotFiltering.swift +67 -0
  12. package/{apple-runner → dist/apple-runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Interaction.swift +20 -74
  13. package/dist/apple-runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+ScrollGesture.swift +64 -0
  14. package/{apple-runner → dist/apple-runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SequenceExecution.swift +0 -177
  15. package/{apple-runner → dist/apple-runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Snapshot.swift +81 -48
  16. package/{apple-runner → dist/apple-runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SnapshotCapturePlan.swift +102 -129
  17. package/{apple-runner → dist/apple-runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextEntry.swift +208 -46
  18. package/{apple-runner → dist/apple-runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Transport.swift +82 -11
  19. package/{apple-runner → dist/apple-runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests.swift +72 -0
  20. package/dist/src/agent-browser-tool.js +1 -0
  21. package/dist/src/android-adb.d.ts +64 -234
  22. package/dist/src/android-adb.js +1 -1
  23. package/dist/src/android.js +1 -5
  24. package/dist/src/app-lifecycle.js +7 -0
  25. package/dist/src/apple-runner-options.js +1 -0
  26. package/dist/src/apps.js +5 -11
  27. package/dist/src/artifacts.d.ts +4 -3
  28. package/dist/src/artifacts.js +1 -1
  29. package/dist/src/audio-probe.js +1 -1
  30. package/dist/src/batch.d.ts +2 -177
  31. package/dist/src/batch.js +1 -1
  32. package/dist/src/cli-help.js +64 -38
  33. package/dist/src/cli-output.js +1 -1
  34. package/dist/src/cli-runner.js +2 -0
  35. package/dist/src/cli.js +12 -41
  36. package/dist/src/client-metro-companion.js +1 -0
  37. package/dist/src/client.js +3 -0
  38. package/dist/src/command-metadata.js +1 -0
  39. package/dist/src/command-schema.js +22 -0
  40. package/dist/src/command-surface.js +1 -1
  41. package/dist/src/contracts.d.ts +2 -213
  42. package/dist/src/contracts.js +1 -1
  43. package/dist/src/debug-symbols.js +5 -3
  44. package/dist/src/device-input-state.js +2 -0
  45. package/dist/src/device-rotation.js +14 -0
  46. package/dist/src/devices.js +1 -1
  47. package/dist/src/devices2.js +1 -0
  48. package/dist/src/devices3.js +1 -0
  49. package/dist/src/find.js +1 -1
  50. package/dist/src/finders.d.ts +2 -81
  51. package/dist/src/finders.js +1 -1
  52. package/dist/src/generic.js +1 -1
  53. package/dist/src/handler-utils.js +1 -1
  54. package/dist/src/helper.js +2 -0
  55. package/dist/src/host-process.js +2 -0
  56. package/dist/src/index.d.ts +1265 -1768
  57. package/dist/src/index.js +1 -1
  58. package/dist/src/input-actions.js +3 -1
  59. package/dist/src/input-actions2.js +1 -0
  60. package/dist/src/install-source.d.ts +13 -14
  61. package/dist/src/install-source.js +1 -1
  62. package/dist/src/install-source2.js +1 -0
  63. package/dist/src/interaction-snapshot.js +1 -0
  64. package/dist/src/interaction.js +1 -1
  65. package/dist/src/interactor.js +2 -1
  66. package/dist/src/internal/bin.d.ts +1 -1
  67. package/dist/src/internal/bin.js +2 -5
  68. package/dist/src/internal/companion-tunnel.d.ts +1 -1
  69. package/dist/src/internal/companion-tunnel.js +1 -1
  70. package/dist/src/internal/daemon.d.ts +1 -1
  71. package/dist/src/internal/daemon.js +16 -1
  72. package/dist/src/internal/png-worker.d.ts +29 -26
  73. package/dist/src/internal/png-worker.js +1 -1
  74. package/dist/src/internal/update-check-entry.d.ts +1 -1
  75. package/dist/src/internal/update-check-entry.js +1 -1
  76. package/dist/src/io.d.ts +2 -85
  77. package/dist/src/io.js +1 -1
  78. package/dist/src/lease.js +1 -1
  79. package/dist/src/linux.js +1 -1
  80. package/dist/src/logcat.js +6 -0
  81. package/dist/src/manifest.js +1 -0
  82. package/dist/src/metro.d.ts +70 -113
  83. package/dist/src/metro.js +1 -1
  84. package/dist/src/metro2.js +1 -0
  85. package/dist/src/notifications.js +1 -1
  86. package/dist/src/output-path.js +1 -0
  87. package/dist/src/path-resolution.js +1 -0
  88. package/dist/src/png-worker-contract.js +1 -0
  89. package/dist/src/points.js +4 -0
  90. package/dist/src/project-runtime.js +1 -0
  91. package/dist/src/provider.js +1 -1
  92. package/dist/src/providers.js +1 -0
  93. package/dist/src/react-native.js +1 -1
  94. package/dist/src/record-trace-recording.js +2 -5
  95. package/dist/src/record-trace.js +1 -1
  96. package/dist/src/recording-provider.js +1 -1
  97. package/dist/src/registry.js +37 -0
  98. package/dist/src/remote-config.d.ts +2 -83
  99. package/dist/src/reporting.js +9 -0
  100. package/dist/src/rolldown-runtime.js +1 -0
  101. package/dist/src/runner-client.js +1 -0
  102. package/dist/src/runner-provider.js +1 -0
  103. package/dist/src/runner-sequence.js +1 -1
  104. package/dist/src/runtime-transport.js +1 -0
  105. package/dist/src/runtime.js +3 -0
  106. package/dist/src/scoped-provider.js +1 -0
  107. package/dist/src/sdk-android-adb.d.ts +144 -0
  108. package/dist/src/sdk-android-adb.js +4 -0
  109. package/dist/src/sdk-app-inventory.d.ts +4 -0
  110. package/dist/src/sdk-app-inventory.js +1 -0
  111. package/dist/src/sdk-batch-runner.d.ts +40 -0
  112. package/dist/src/sdk-batch-runner.js +2 -0
  113. package/dist/src/sdk-batch.js +2 -0
  114. package/dist/src/sdk-contracts.d.ts +386 -0
  115. package/dist/src/sdk-contracts.js +2 -0
  116. package/dist/src/sdk-finders.d.ts +61 -0
  117. package/dist/src/sdk-finders.js +1 -0
  118. package/dist/src/sdk-io.d.ts +79 -0
  119. package/dist/src/sdk-io.js +1 -0
  120. package/dist/src/sdk-remote-config.d.ts +140 -0
  121. package/dist/src/sdk-remote-config.js +1 -0
  122. package/dist/src/sdk-selectors.js +1 -0
  123. package/dist/src/selector-runtime.js +1 -1
  124. package/dist/src/selectors.d.ts +39 -137
  125. package/dist/src/selectors.js +1 -1
  126. package/dist/src/selectors2.js +1 -0
  127. package/dist/src/server.js +3 -2
  128. package/dist/src/session.js +10 -11
  129. package/dist/src/setting-state.js +1 -0
  130. package/dist/src/simctl.js +1 -0
  131. package/dist/src/simulator.js +1 -2
  132. package/dist/src/snapshot-diagnostics.js +3 -0
  133. package/dist/src/snapshot-helper.js +5 -0
  134. package/dist/src/snapshot-quality.js +1 -0
  135. package/dist/src/snapshot.js +1 -2
  136. package/dist/src/snapshot2.js +2 -0
  137. package/dist/src/{5560.js → timeouts.js} +1 -1
  138. package/dist/src/tool-provider.js +3 -0
  139. package/dist/src/tool-provider2.js +1 -0
  140. package/dist/src/ttl-memo.js +1 -0
  141. package/dist/src/update-check.js +1 -0
  142. package/dist/src/url.js +1 -0
  143. package/dist/src/version.js +1 -0
  144. package/dist/src/web.js +1 -1
  145. package/dist/src/xml.js +2 -0
  146. package/package.json +12 -19
  147. package/server.json +2 -2
  148. package/skills/agent-device/SKILL.md +2 -0
  149. package/android-multitouch-helper/dist/agent-device-android-multitouch-helper-0.18.2.apk.sha256 +0 -1
  150. package/android-snapshot-helper/dist/agent-device-android-snapshot-helper-0.18.2.apk.sha256 +0 -1
  151. package/apple-runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+CommandJournal.swift +0 -443
  152. package/apple-runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+FlatSnapshotFiltering.swift +0 -169
  153. package/apple-runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+ScrollGesture.swift +0 -220
  154. package/dist/src/1404.js +0 -1
  155. package/dist/src/1986.js +0 -1
  156. package/dist/src/2748.js +0 -1
  157. package/dist/src/2948.js +0 -30
  158. package/dist/src/3006.js +0 -1
  159. package/dist/src/314.js +0 -1
  160. package/dist/src/3340.js +0 -8
  161. package/dist/src/4418.js +0 -1
  162. package/dist/src/4428.js +0 -3
  163. package/dist/src/485.js +0 -1
  164. package/dist/src/4917.js +0 -1
  165. package/dist/src/495.js +0 -5
  166. package/dist/src/5448.js +0 -3
  167. package/dist/src/5484.js +0 -1
  168. package/dist/src/5643.js +0 -1
  169. package/dist/src/587.js +0 -1
  170. package/dist/src/5913.js +0 -4
  171. package/dist/src/6849.js +0 -1
  172. package/dist/src/6918.js +0 -1
  173. package/dist/src/6967.js +0 -1
  174. package/dist/src/760.js +0 -1
  175. package/dist/src/7871.js +0 -1
  176. package/dist/src/8184.js +0 -1
  177. package/dist/src/8225.js +0 -1
  178. package/dist/src/8391.js +0 -1
  179. package/dist/src/8404.js +0 -2
  180. package/dist/src/8414.js +0 -2
  181. package/dist/src/8875.js +0 -4
  182. package/dist/src/893.js +0 -1
  183. package/dist/src/8936.js +0 -1
  184. package/dist/src/9414.js +0 -1
  185. package/dist/src/9581.js +0 -22
  186. package/dist/src/9612.js +0 -1
  187. package/dist/src/9624.js +0 -1
  188. package/dist/src/9722.js +0 -38
  189. package/dist/src/devices~1.js +0 -1
  190. package/dist/src/devices~2.js +0 -1
  191. package/dist/src/input-actions~1.js +0 -1
  192. package/dist/src/rslib-runtime.js +0 -1
  193. /package/{apple-runner → dist/apple-runner}/AgentDeviceRunner/AgentDeviceRunner/AgentDeviceRunnerApp.m +0 -0
  194. /package/{apple-runner → dist/apple-runner}/AgentDeviceRunner/AgentDeviceRunner.xcodeproj/project.pbxproj +0 -0
  195. /package/{apple-runner → dist/apple-runner}/AgentDeviceRunner/AgentDeviceRunner.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -0
  196. /package/{apple-runner → dist/apple-runner}/AgentDeviceRunner/AgentDeviceRunner.xcodeproj/xcshareddata/xcschemes/AgentDeviceRunner.xcscheme +0 -0
  197. /package/{apple-runner → dist/apple-runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/AgentDeviceRunnerUITests-Bridging-Header.h +0 -0
  198. /package/{apple-runner → dist/apple-runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/AgentDeviceRunnerUITests.entitlements +0 -0
  199. /package/{apple-runner → dist/apple-runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerAXSnapshotBridge.h +0 -0
  200. /package/{apple-runner → dist/apple-runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerAXSnapshotBridge.m +0 -0
  201. /package/{apple-runner → dist/apple-runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerObjCExceptionCatcher.h +0 -0
  202. /package/{apple-runner → dist/apple-runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerObjCExceptionCatcher.m +0 -0
  203. /package/{apple-runner → dist/apple-runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerSynthesizedGesture.h +0 -0
  204. /package/{apple-runner → dist/apple-runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerSynthesizedGesture.m +0 -0
  205. /package/{apple-runner → dist/apple-runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Alert.swift +0 -0
  206. /package/{apple-runner → dist/apple-runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Environment.swift +0 -0
  207. /package/{apple-runner → dist/apple-runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Exceptions.swift +0 -0
  208. /package/{apple-runner → dist/apple-runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Lifecycle.swift +0 -0
  209. /package/{apple-runner → dist/apple-runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Models.swift +0 -0
  210. /package/{apple-runner → dist/apple-runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+ScreenRecorder.swift +0 -0
  211. /package/{apple-runner → dist/apple-runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SystemModal.swift +0 -0
  212. /package/{apple-runner → dist/apple-runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TvRemote.swift +0 -0
  213. /package/{apple-runner → dist/apple-runner}/AgentDeviceRunner/AgentDeviceRunnerUITests.xctestplan +0 -0
  214. /package/{apple-runner → dist/apple-runner}/AgentDeviceRunner/RecordingScripts/recording-overlay.swift +0 -0
  215. /package/{apple-runner → dist/apple-runner}/AgentDeviceRunner/RecordingScripts/recording-resize.swift +0 -0
  216. /package/{apple-runner → dist/apple-runner}/AgentDeviceRunner/RecordingScripts/recording-trim.swift +0 -0
@@ -0,0 +1,144 @@
1
+ import { Readable, Writable } from "node:stream";
2
+ import { StdioOptions, spawn } from "node:child_process";
3
+
4
+ //#region src/utils/exec.d.ts
5
+ type ExecResult = {
6
+ stdout: string;
7
+ stderr: string;
8
+ exitCode: number;
9
+ stdoutBuffer?: Buffer;
10
+ };
11
+ type ExecOptions = {
12
+ cwd?: string;
13
+ env?: NodeJS.ProcessEnv;
14
+ allowFailure?: boolean;
15
+ binaryStdout?: boolean;
16
+ stdin?: string | Buffer;
17
+ timeoutMs?: number;
18
+ detached?: boolean;
19
+ signal?: AbortSignal; /** Max stdout/stderr bytes for synchronous runs (default Node ~1MB). */
20
+ maxBuffer?: number;
21
+ };
22
+ type ExecBackgroundOptions = ExecOptions & {
23
+ /**
24
+ * Capture stdout/stderr into the wait result when the child has piped stdio.
25
+ * Set false when the caller owns, ignores, or forwards the streams.
26
+ */
27
+ captureOutput?: boolean;
28
+ stdio?: StdioOptions;
29
+ };
30
+ //#endregion
31
+ //#region src/platforms/android/adb-executor.d.ts
32
+ type AndroidAdbExecutorOptions = Pick<ExecOptions, 'allowFailure' | 'timeoutMs' | 'binaryStdout' | 'stdin' | 'signal'>;
33
+ type AndroidAdbExecutorResult = Pick<ExecResult, 'exitCode' | 'stdout' | 'stderr' | 'stdoutBuffer'>;
34
+ type AndroidAdbProcess = {
35
+ pid?: number;
36
+ stdin: Writable | null;
37
+ stdout: Readable | null;
38
+ stderr: Readable | null;
39
+ killed: boolean;
40
+ kill(signal?: NodeJS.Signals | number): boolean;
41
+ once(event: 'exit' | 'close', listener: (code: number | null, signal: NodeJS.Signals | null) => void): unknown;
42
+ on(event: 'error', listener: (error: Error) => void): unknown;
43
+ on(event: 'exit' | 'close', listener: (code: number | null, signal: NodeJS.Signals | null) => void): unknown;
44
+ };
45
+ /**
46
+ * Runs device-scoped adb arguments after the device serial has already been selected.
47
+ * Implementations must be safe to call concurrently for one request.
48
+ */
49
+ type AndroidAdbExecutor = (args: string[], options?: AndroidAdbExecutorOptions) => Promise<AndroidAdbExecutorResult>;
50
+ type AndroidAdbSpawner = (args: string[], options?: ExecBackgroundOptions) => AndroidAdbProcess;
51
+ type AndroidPortReverseEndpoint = `tcp:${number}` | `localabstract:${string}`;
52
+ type AndroidPortReverseMapping = {
53
+ local: AndroidPortReverseEndpoint;
54
+ remote: AndroidPortReverseEndpoint;
55
+ ownerId?: string;
56
+ };
57
+ type AndroidPortReverseOptions = {
58
+ signal?: AbortSignal;
59
+ timeoutMs?: number;
60
+ };
61
+ type AndroidPortReverseProvider = {
62
+ ensure(mapping: AndroidPortReverseMapping, options?: AndroidPortReverseOptions): Promise<void>;
63
+ remove(local: AndroidPortReverseEndpoint, options?: AndroidPortReverseOptions): Promise<void>;
64
+ removeAllOwned(ownerId: string, options?: AndroidPortReverseOptions): Promise<void>;
65
+ list?(options?: AndroidPortReverseOptions): Promise<AndroidPortReverseMapping[]>;
66
+ };
67
+ type AndroidAdbTransferOptions = AndroidAdbExecutorOptions;
68
+ type AndroidAdbInstallOptions = AndroidAdbTransferOptions & {
69
+ replace?: boolean;
70
+ allowTestPackages?: boolean;
71
+ allowDowngrade?: boolean;
72
+ grantPermissions?: boolean;
73
+ };
74
+ type AndroidAdbPuller = (remotePath: string, localPath: string, options?: AndroidAdbTransferOptions) => Promise<AndroidAdbExecutorResult>;
75
+ /**
76
+ * Installs an APK path. Implementations are responsible for honoring semantic
77
+ * install options such as replace/test/downgrade/grant-permissions.
78
+ */
79
+ type AndroidAdbInstaller = (apkPath: string, options?: AndroidAdbInstallOptions) => Promise<AndroidAdbExecutorResult>;
80
+ type AndroidBundleInstaller = (bundlePath: string, options: {
81
+ mode: string;
82
+ }) => Promise<void>;
83
+ type AndroidTextInputAction = 'type' | 'fill';
84
+ type AndroidTextInjectionRequest = {
85
+ action: AndroidTextInputAction;
86
+ text: string;
87
+ delayMs?: number;
88
+ /**
89
+ * Present only for fill. Providers must make this target the focused/replaced
90
+ * input for the request, not inject into an unrelated currently focused field.
91
+ */
92
+ target?: {
93
+ x: number;
94
+ y: number;
95
+ };
96
+ };
97
+ type AndroidTextInjector = (request: AndroidTextInjectionRequest) => Promise<void>;
98
+ type AndroidTouchGestureRequest = {
99
+ kind: 'swipe';
100
+ x1: number;
101
+ y1: number;
102
+ x2: number;
103
+ y2: number;
104
+ durationMs?: number;
105
+ } | {
106
+ kind: 'pinch';
107
+ x: number;
108
+ y: number;
109
+ scale: number;
110
+ durationMs?: number;
111
+ } | {
112
+ kind: 'rotate';
113
+ x: number;
114
+ y: number;
115
+ degrees: number;
116
+ durationMs?: number;
117
+ } | {
118
+ kind: 'transform';
119
+ x: number;
120
+ y: number;
121
+ dx: number;
122
+ dy: number;
123
+ scale: number;
124
+ degrees: number;
125
+ durationMs?: number;
126
+ };
127
+ type AndroidTouchInjector = (request: AndroidTouchGestureRequest) => Promise<Record<string, unknown> | void>;
128
+ type AndroidAdbProvider = {
129
+ /**
130
+ * Fallback executor for device-scoped adb arguments. Providers may omit explicit
131
+ * methods to keep the legacy exec-shaped pull/install fallback.
132
+ */
133
+ exec: AndroidAdbExecutor;
134
+ spawn?: AndroidAdbSpawner;
135
+ reverse?: AndroidPortReverseProvider;
136
+ pull?: AndroidAdbPuller;
137
+ install?: AndroidAdbInstaller;
138
+ installBundle?: AndroidBundleInstaller;
139
+ text?: AndroidTextInjector;
140
+ touch?: AndroidTouchInjector;
141
+ };
142
+ declare function createAndroidPortReverseManager(provider: AndroidAdbProvider | AndroidAdbExecutor): AndroidPortReverseProvider;
143
+ //#endregion
144
+ export { createAndroidPortReverseManager as i, AndroidAdbExecutorOptions as n, AndroidPortReverseEndpoint as r, AndroidAdbExecutor as t };
@@ -0,0 +1,4 @@
1
+ import{t as e}from"./rolldown-runtime.js";import{F as t,U as n}from"./sdk-contracts.js";import{AsyncLocalStorage as r}from"node:async_hooks";import i from"node:crypto";import a,{constants as o}from"node:fs";import s from"node:os";import c from"node:path";import{pipeline as l}from"node:stream/promises";import{Readable as u}from"node:stream";import{access as d,stat as f}from"node:fs/promises";import{spawn as p,spawnSync as m}from"node:child_process";const h=new r;function g(){return i.randomBytes(8).toString(`hex`)}function ee(){return`${Date.now().toString(36)}-${i.randomBytes(4).toString(`hex`)}`}async function te(e,t){let n={...e,diagnosticId:ee(),events:[],liveWrittenEventCount:0,phaseCounts:new Map};return await h.run(n,t)}function ne(e){let t=h.getStore();t&&Object.assign(t,e)}function re(){let e=h.getStore();return e?{diagnosticId:e.diagnosticId,requestId:e.requestId,session:e.session,command:e.command,debug:e.debug,flushOnSuccess:e.flushOnSuccess}:{}}function ie(e){let t=h.getStore();if(!t)return 0;let n=0;for(let r of e)n+=t.phaseCounts.get(r)??0;return n}function _(e){let t=h.getStore();if(!t)return;let r={ts:new Date().toISOString(),level:e.level??`info`,phase:e.phase,session:t.session,requestId:t.requestId,command:t.command,durationMs:e.durationMs,data:e.data?n(e.data):void 0};if(t.events.push(r),t.phaseCounts.set(e.phase,(t.phaseCounts.get(e.phase)??0)+1),!t.debug)return;let i=`${JSON.stringify(r)}\n`;try{t.logPath&&(v(t.logPath,i),t.liveWrittenEventCount=t.events.length),t.traceLogPath&&v(t.traceLogPath,i),!t.logPath&&!t.traceLogPath&&process.stderr.write(`[agent-device][diag] ${i}`)}catch{}}async function ae(e,t,n){let r=Date.now();try{let i=await t();return _({level:`info`,phase:e,durationMs:Date.now()-r,data:n}),i}catch(t){throw _({level:`error`,phase:e,durationMs:Date.now()-r,data:{...n??{},error:t instanceof Error?t.message:String(t)}}),t}}function oe(e={}){let t=h.getStore();if(!t||!e.force&&!t.debug&&!t.flushOnSuccess||t.events.length===0)return null;try{if(t.logPath){let e=t.events.slice(t.liveWrittenEventCount);if(e.length>0){let r=e.map(e=>JSON.stringify(n(e)));v(t.logPath,`${r.join(`
2
+ `)}\n`)}let r=t.logPath;return t.events=[],t.liveWrittenEventCount=0,r}let e=se(t.session??`default`),r=new Date().toISOString().slice(0,10),i=c.join(s.homedir(),`.agent-device`,`logs`,e,r);a.mkdirSync(i,{recursive:!0});let o=new Date().toISOString().replace(/[:.]/g,`-`),l=c.join(i,`${o}-${t.diagnosticId}.ndjson`),u=t.events.map(e=>JSON.stringify(n(e)));return a.writeFileSync(l,`${u.join(`
3
+ `)}\n`),t.events=[],l}catch{return null}}function se(e){return e.replace(/[^a-zA-Z0-9._-]/g,`_`)}function v(e,t){a.mkdirSync(c.dirname(e),{recursive:!0}),a.appendFileSync(e,t,`utf8`)}const ce=new Set([`1`,`true`,`yes`,`on`]),le=new Set([`0`,`false`,`no`,`off`]);function ue(e){return`AGENT_DEVICE_${e.replace(/([A-Z])/g,`_$1`).replace(/[^A-Za-z0-9_]/g,`_`).toUpperCase()}`}function de(e,n,r,i){if(e.multiple)return(Array.isArray(n)?n:[n]).map(t=>de({...e,multiple:!1},t,r,i));if(e.type===`boolean`)return fe(n,r,i);if(e.type===`booleanOrString`){if(typeof n==`boolean`)return n;if(typeof n==`string`&&y(n)!==void 0)return y(n);if(typeof n==`string`&&n.trim().length>0)return n;throw new t(`INVALID_ARGS`,`Invalid value for "${i}" in ${r}. Expected boolean or non-empty string.`)}if(e.type===`string`){if(typeof n==`string`&&n.trim().length>0)return n;throw new t(`INVALID_ARGS`,`Invalid value for "${i}" in ${r}. Expected non-empty string.`)}if(e.type===`enum`){if(e.setValue!==void 0)return pe(e,n,r,i);if(typeof n!=`string`||!e.enumValues?.includes(n))throw new t(`INVALID_ARGS`,`Invalid value for "${i}" in ${r}. Expected one of: ${e.enumValues?.join(`, `)}.`);return n}let a=typeof n==`number`?n:typeof n==`string`?Number(n):NaN;if(!Number.isFinite(a)||!Number.isInteger(a))throw new t(`INVALID_ARGS`,`Invalid value for "${i}" in ${r}. Expected integer.`);if(typeof e.min==`number`&&a<e.min)throw new t(`INVALID_ARGS`,`Invalid value for "${i}" in ${r}. Must be >= ${e.min}.`);if(typeof e.max==`number`&&a>e.max)throw new t(`INVALID_ARGS`,`Invalid value for "${i}" in ${r}. Must be <= ${e.max}.`);return a}function fe(e,n,r){if(typeof e==`boolean`)return e;if(typeof e==`string`){let t=y(e);if(t!==void 0)return t}throw new t(`INVALID_ARGS`,`Invalid value for "${r}" in ${n}. Expected boolean.`)}function y(e){let t=e.trim().toLowerCase();if(ce.has(t))return!0;if(le.has(t))return!1}function pe(e,n,r,i){let a=e.setValue;if(n===a)return a;if(typeof n==`string`){let e=n.trim();if(e===``||e===`true`||e===`1`)return a;if(e===`false`||e===`0`)return}if(n===!0)return a;if(n!==!1)throw new t(`INVALID_ARGS`,`Invalid value for "${i}" in ${r}. Expected boolean-like value for enum flag.`)}const me=/^[A-Za-z0-9][A-Za-z0-9._+-]*$/,he=[`.com`,`.exe`,`.bat`,`.cmd`],b=new r;async function ge(e,t){return e?await b.run(e,t):await t()}async function x(e){return await b.run(void 0,e)}async function _e(e,t,n={}){let r=b.getStore()?.(e,t,n);return r?S(await r):await C(e,t,n)}async function ve(e,t,n={}){let r=b.getStore()?.(e,t,n);return r?S(await r):await C(e,t,n)}function S(e){let t=typeof e.stdout==`string`?e.stdout:String(e.stdout??``),n=typeof e.stderr==`string`?e.stderr:String(e.stderr??``),r=typeof e.exitCode==`number`?e.exitCode:1;return t===e.stdout&&n===e.stderr&&r===e.exitCode?e:{...e,stdout:t,stderr:n,exitCode:r}}function C(e,t,n={}){let r=O(e),i=E();return new Promise((a,o)=>{let s=p(r,t,{cwd:n.cwd,env:n.env,stdio:[`pipe`,`pipe`,`pipe`],detached:n.detached,windowsHide:!0,shell:!1});n.onSpawn?.(s);let c=``,l=n.binaryStdout?[]:void 0,u=``,d=!1,f=B(n.timeoutMs),m=f?setTimeout(()=>{d=!0,H(s,n.detached)},f):null,h=V(s,n);n.binaryStdout||s.stdout.setEncoding(`utf8`),s.stderr.setEncoding(`utf8`),je(s,n.stdin).catch(i=>{h.didAbort||d||Me(i)||(o(Ee(r,e,t,i)),H(s,n.detached))}),s.stdout.on(`data`,e=>{if(n.binaryStdout){l?.push(Buffer.isBuffer(e)?e:Buffer.from(e));return}let t=String(e);c+=t,n.onStdoutChunk?.(t)}),s.stderr.on(`data`,e=>{let t=String(e);u+=t,n.onStderrChunk?.(t)}),s.on(`error`,n=>{m&&clearTimeout(m),h.dispose(),i.emitForegroundCompletion(e,t),o(P(h,r,e,t,n))}),s.on(`close`,s=>{m&&clearTimeout(m),h.dispose(),i.emitForegroundCompletion(e,t);let p=s??1;if(!h.didAbort&&d&&f){o(De(r,e,t,f,p,c,u));return}let g=F(h,r,e,t,p,n.allowFailure,c,u);if(g){o(g);return}a({stdout:c,stderr:u,exitCode:p,stdoutBuffer:l?Buffer.concat(l):void 0})})})}async function ye(e){let t=L(e);if(!t)return!1;if(c.isAbsolute(t))return R(t);let n=process.env.PATH;if(!n)return!1;let r=ke();for(let e of n.split(c.delimiter)){let n=e.trim();if(n){for(let e of Ae(t,r))if(await R(c.join(n,e)))return!0}}return!1}async function be(e,n){let r=I(e,n,`executable`);if(r){if(!await R(r))throw new t(`TOOL_MISSING`,`${n} points to a missing or non-executable file: ${r}`,{envName:n,path:r});return r}}async function xe(e,n){let r=I(e,n,`file`);if(r){if(!await z(r))throw new t(`TOOL_MISSING`,`${n} points to a missing or non-file path: ${r}`,{envName:n,path:r});return r}}function Se(e,n,r={}){let i=O(e),a=m(i,n,{cwd:r.cwd,env:r.env,stdio:[`pipe`,`pipe`,`pipe`],encoding:r.binaryStdout?void 0:`utf8`,input:r.stdin,timeout:B(r.timeoutMs),windowsHide:!0,shell:!1,...r.maxBuffer===void 0?{}:{maxBuffer:r.maxBuffer}});if(a.error){let o=a.error.code;throw o===`ETIMEDOUT`?new t(`COMMAND_FAILED`,`${i} timed out after ${B(r.timeoutMs)}ms`,{cmd:e,args:n,timeoutMs:B(r.timeoutMs)},a.error):o===`ENOENT`?k(i,e,a.error):A(i,e,n,a.error)}let o=r.binaryStdout?Buffer.isBuffer(a.stdout)?a.stdout:Buffer.from(a.stdout??``):void 0,s=r.binaryStdout?``:typeof a.stdout==`string`?a.stdout:(a.stdout??``).toString(),c=typeof a.stderr==`string`?a.stderr:(a.stderr??``).toString(),l=a.status??1;if(l!==0&&!r.allowFailure)throw M(i,e,n,l,s,c);return{stdout:s,stderr:c,exitCode:l,stdoutBuffer:o}}function Ce(e,t,n={}){return w(e,t,n).pid}function w(e,t,n={}){let r=p(O(e),t,{cwd:n.cwd,env:n.env,stdio:n.stdio??`ignore`,detached:!0,windowsHide:!0,shell:!1}),i=r.pid??0,a=new Promise(e=>{r.once(`error`,t=>{e({pid:i,error:t.message})}),r.once(`exit`,(t,n)=>{e({pid:i,...typeof t==`number`?{exitCode:t}:{},...n?{signal:n}:{}})})});return r.unref(),{pid:i,exited:a}}function T(e,t,n={}){let r=O(e),i=E(),a=p(r,t,{cwd:n.cwd,env:n.env,stdio:n.stdio??[`ignore`,`pipe`,`pipe`],detached:n.detached,windowsHide:!0,shell:!1});i.emitBackgroundSpawn(e,t);let o=``,s=``,c=n.captureOutput??!0,l=V(a,n);return c&&(a.stdout?.setEncoding(`utf8`),a.stderr?.setEncoding(`utf8`),a.stdout?.on(`data`,e=>{o+=e}),a.stderr?.on(`data`,e=>{s+=e})),{child:a,wait:new Promise((c,u)=>{a.on(`error`,n=>{l.dispose(),i.emitBackgroundCompletion(e,t,`error`),u(P(l,r,e,t,n))}),a.on(`close`,a=>{l.dispose(),i.emitBackgroundCompletion(e,t,`exit`);let d=a??1,f=F(l,r,e,t,d,n.allowFailure,o,s);if(f){u(f);return}c({stdout:o,stderr:s,exitCode:d})})})}}function E(){let e=re(),t=e.debug===!0,n=y(process.env.AGENT_DEVICE_EXEC_TRACE??``)===!0;if(!t&&!n)return we();n&&e.flushOnSuccess!==!0&&ne({flushOnSuccess:!0});let r=Date.now(),i=!1;return{emitForegroundCompletion:(e,t)=>{i||(i=!0,D({cmd:e,args:t,startedAtMs:r}))},emitBackgroundSpawn:(e,t)=>{D({cmd:e,args:t,data:{event:`spawn`}})},emitBackgroundCompletion:(e,t,n)=>{i||(i=!0,D({cmd:e,args:t,startedAtMs:r,data:{event:n}}))}}}function we(){return{emitForegroundCompletion:()=>{},emitBackgroundSpawn:()=>{},emitBackgroundCompletion:()=>{}}}function D(e){let t=e.args.slice(0,6);_({level:`debug`,phase:`exec_command`,durationMs:e.startedAtMs===void 0?void 0:Math.max(0,Date.now()-e.startedAtMs),data:{command:e.cmd,argsPrefix:t,...e.args.length>t.length?{omittedArgCount:e.args.length-t.length}:{},...e.data??{}}})}function O(e){let n=L(e);if(!n)throw new t(`INVALID_ARGS`,`Invalid executable command: ${JSON.stringify(e)}`,{cmd:e,hint:`Use a bare command name from PATH or an absolute executable path.`});return n}function Te(e,t,n,r){return r.code===`ENOENT`?k(e,t,r):A(e,t,n,r)}function k(e,n,r){return new t(`TOOL_MISSING`,`${e} not found in PATH`,{cmd:n},r)}function A(e,n,r,i){return new t(`COMMAND_FAILED`,`Failed to run ${e}`,{cmd:n,args:r},i)}function Ee(e,n,r,i){return new t(`COMMAND_FAILED`,`Failed to write stdin for ${e}`,{cmd:n,args:r},i instanceof Error?i:void 0)}function j(e,n,r){return new t(`COMMAND_FAILED`,`request canceled`,{cmd:n,args:r,executable:e,reason:`request_canceled`})}function De(e,n,r,i,a,o,s){return new t(`COMMAND_FAILED`,`${e} timed out after ${i}ms`,{cmd:n,args:r,stdout:o,stderr:s,exitCode:a,timeoutMs:i})}function M(e,n,r,i,a,o){return new t(`COMMAND_FAILED`,`${e} exited with code ${i}`,N({stdout:a,stderr:o,exitCode:i},{cmd:n,args:r}))}function Oe(e,n,r){if(e.exitCode===0)return e;throw new t(`COMMAND_FAILED`,n,N(e,typeof r==`function`?r(e):r))}function N(e,t){return{stdout:e.stdout,stderr:e.stderr,exitCode:e.exitCode,processExitError:!0,...t}}function P(e,t,n,r,i){return e.didAbort?j(t,n,r):Te(t,n,r,i)}function F(e,t,n,r,i,a,o,s){return e.didAbort?j(t,n,r):i!==0&&!a?M(t,n,r,i,o,s):null}function I(e,n,r){let i=e?.trim();if(i){if(!c.isAbsolute(i)||i.includes(`\0`))throw new t(`INVALID_ARGS`,`${n} must be an absolute ${r} path, not ${JSON.stringify(e)}`,{envName:n,path:e});return i}}function L(e){let t=e.trim();return!t||t.includes(`\0`)?null:c.isAbsolute(t)?t:t.includes(`/`)||t.includes(`\\`)?null:me.test(t)?t:null}function ke(){if(process.platform!==`win32`)return[``];let e=process.env.PATHEXT;if(!e)return he;let t=e.split(`;`).map(e=>e.trim().toLowerCase()).filter(e=>e.length>0);return t.length>0?t:he}function Ae(e,t){if(process.platform!==`win32`)return[e];let n=e.toLowerCase();return t.some(e=>n.endsWith(e))?[e]:t.map(t=>`${e}${t}`)}async function R(e){try{return await z(e)?(await d(e,process.platform===`win32`?o.F_OK:o.X_OK),!0):!1}catch{return!1}}async function z(e){try{return(await f(e)).isFile()}catch{return!1}}function B(e){if(!Number.isFinite(e))return;let t=Math.floor(e);if(!(t<=0))return t}function V(e,t){let n=!1,r=()=>{n=!0,H(e,t.detached)};return t.signal?.aborted?r():t.signal?.addEventListener(`abort`,r,{once:!0}),{get didAbort(){return n},dispose:()=>{t.signal?.removeEventListener(`abort`,r)}}}function H(e,t){if(t&&e.pid&&process.platform!==`win32`)try{process.kill(-e.pid,`SIGKILL`);return}catch{}e.kill(`SIGKILL`)}async function je(e,t){if(e.stdin){if(t===void 0){e.stdin?.end();return}await l(u.from([t]),e.stdin)}}function Me(e){return e instanceof Error&&`code`in e&&e.code===`EPIPE`}var Ne=e({androidAdbResultError:()=>K,attachAdbFailureHint:()=>G,classifyAdbFailure:()=>W,createAndroidPortReverseManager:()=>We,createDeviceAdbExecutor:()=>Y,createLocalAndroidAdbProvider:()=>Ve,installAndroidAdbPackage:()=>Ke,pullAndroidAdbFile:()=>Ge,resolveAndroidAdbExecutor:()=>He,resolveAndroidAdbProvider:()=>X,resolveAndroidTextInjector:()=>Ue,resolveAndroidTouchInjector:()=>Z,withAndroidAdbProvider:()=>Je});const U=new r,Pe=[{reason:`device_unauthorized`,pattern:/device unauthorized|device still authorizing/,hint:`USB debugging is not authorized — accept the authorization prompt on the device screen (re-plug the cable if none appears), then retry.`},{reason:`device_offline`,pattern:/device offline/,hint:`The device is connected but offline — wait for it to finish booting or run adb reconnect, then retry.`,retriable:!0},{reason:`multiple_devices`,pattern:/more than one (?:device\/emulator|device and emulator)/,hint:`Multiple Android devices are connected — pass --serial <serial> (see adb devices) to select one.`},{reason:`no_devices`,pattern:/no devices\/emulators found|no devices found/,hint:`No Android devices detected — boot an emulator or connect a device and verify it appears in adb devices.`},{reason:`device_not_found`,pattern:/device (?:'[^']*' )?not found/,hint:`The device disconnected or is restarting — verify it is listed in adb devices, then retry.`,retriable:!0},{reason:`server_version_mismatch`,pattern:/adb server version \(\d+\) doesn't match this client/,hint:`Multiple adb installs conflict — adb restarts its server automatically, so retry; align PATH to a single adb to stop recurrences.`,retriable:!0},{reason:`connection_dropped`,pattern:/transport error|connection reset|broken pipe|protocol fault/,hint:`The adb connection dropped — retry; if it persists, run adb kill-server and reconnect the device.`,retriable:!0},{reason:`install_insufficient_storage`,pattern:/install_failed_insufficient_storage/,hint:`The device is out of storage — free up space or uninstall unused apps, then retry the install.`,matchStdout:!0},{reason:`install_update_incompatible`,pattern:/install_failed_update_incompatible/,hint:`The installed app has an incompatible signature — uninstall the existing app first, then retry the install.`,matchStdout:!0},{reason:`install_version_downgrade`,pattern:/install_failed_version_downgrade/,hint:`The APK is older than the installed app — uninstall the app first (or install with downgrade allowed), then retry.`,matchStdout:!0},{reason:`install_failed`,pattern:/install_failed_\w+|install_parse_failed_\w+/,hint:`The Android package installer rejected the APK — see the INSTALL_FAILED code in the error output for the exact cause.`,matchStdout:!0}],Fe={reason:`timeout`,hint:`adb timed out — the adb server may be wedged. Run adb kill-server && adb start-server, check adb devices, then retry.`};function W(e,t=``){let n=e.toLowerCase(),r=t.toLowerCase();for(let{pattern:e,matchStdout:t,...i}of Pe)if(e.test(n)||t&&e.test(r))return i}function G(e){if(!(e instanceof t)||e.code!==`COMMAND_FAILED`)return e;let n=Ie(e);return n&&(e.details={...e.details,adbFailure:n.reason,...typeof e.details?.hint==`string`?{}:{hint:n.hint},...n.retriable!==void 0&&e.details?.retriable===void 0?{retriable:n.retriable}:{}}),e}function Ie(e){return typeof e.details?.timeoutMs==`number`?Fe:W(typeof e.details?.stderr==`string`?e.details.stderr:``,typeof e.details?.stdout==`string`?e.details.stdout:``)}function K(e,n,r){return G(new t(`COMMAND_FAILED`,e,n.exitCode===0?{stdout:n.stdout,stderr:n.stderr,exitCode:n.exitCode,...r}:N(n,r)))}function q(e){return async(...t)=>{try{return await e(...t)}catch(e){throw G(e)}}}const Le=new WeakSet;function Re(e){if(Le.has(e))return e;let t={...e,exec:q(J(e.exec)),...e.pull?{pull:q(J(e.pull))}:{},...e.install?{install:q(J(e.install))}:{},...e.installBundle?{installBundle:q(e.installBundle)}:{}};return Le.add(t),t}function J(e){return async(...t)=>S(await e(...t))}function Y(e){return ze(e.id)}function ze(e){return q(async(t,n)=>await x(async()=>await _e(`adb`,[`-s`,e,...t],{...n,detached:process.platform!==`win32`})))}function Be(e){return(t,n)=>{let r=T(`adb`,[`-s`,e,...t],{...n,allowFailure:!0,captureOutput:!1});return r.wait.catch(()=>{}),r.child}}function Ve(e){let t=Y(e);return{exec:t,spawn:Be(e.id),reverse:Ze(t),pull:async(e,n,r)=>await t([`pull`,e,n],r),install:async(e,n)=>{let{installArgs:r,execOptions:i}=$(n);return await t([`install`,...r,e],i)}}}function He(e,t){let n=U.getStore();return t||(n?.serial===e.id?n.provider.exec:Y(e))}function X(e,t){if(t)return Q(t);let n=U.getStore();return n?.serial===e.id?Q(n.provider):Ve(e)}function Ue(e){let t=U.getStore();return t?.serial===e.id?t.provider.text:void 0}function Z(e){let t=U.getStore();return t?.serial===e.id?t.provider.touch:void 0}function We(e){let n=Q(e),r=n.reverse??Ze(n.exec),i=new Map;return{async ensure(e,n){let a=i.get(e.local);if(a&&a.ownerId!==e.ownerId)throw new t(`COMMAND_FAILED`,`Android port reverse ${e.local} is already owned by ${a.ownerId??`another session`}`,{current:a,requested:e});a?.remote!==e.remote&&(await r.ensure(e,n),i.set(e.local,{...e}))},async remove(e,t){if(!i.has(e)){await r.remove(e,t);return}await r.remove(e,t),i.delete(e)},async removeAllOwned(e,t){let n=[...i.values()].filter(t=>t.ownerId===e).map(e=>e.local);if(n.length===0){await r.removeAllOwned(e,t);return}for(let e of n)await r.remove(e,t),i.delete(e)},async list(e){return r.list?await r.list(e):[...i.values()]}}}function Q(e){return Re(typeof e==`function`?{exec:e}:e)}async function Ge(e,n,r){let{device:i,provider:a,...o}=r??{},s=qe(i,a),c=s?.pull;if(c)return await x(async()=>await c(e,n,o));let l=s?.exec;if(!l)throw new t(`COMMAND_FAILED`,`Android adb pull requires an adb provider`);return await x(async()=>await l([`pull`,e,n],o))}async function Ke(e,n){let{device:r,provider:i,...a}=n??{},o=qe(r,i),s=o?.install;if(s)return await x(async()=>await s(e,a));let c=o?.exec;if(!c)throw new t(`COMMAND_FAILED`,`Android adb install requires an adb provider`);let{installArgs:l,execOptions:u}=$(a);return await x(async()=>await c([`install`,...l,e],u))}function qe(e,t){if(t)return Q(t);if(e)return X(e);let n=U.getStore();if(n)return Q(n.provider)}async function Je(e,t,n){if(!e)return await n();let r={provider:Q(e),serial:t.serial},i=Ye(r);return await U.run(r,async()=>await ge(i,n))}function Ye(e){return(t,n,r)=>{if(t!==`adb`)return;let i=Xe(n,e.serial);if(i)return x(async()=>await e.provider.exec(i,r))}}function Xe(e,t){if(!(e[0]!==`-s`||!e[1])&&e[1]===t)return e.slice(2)}function Ze(e){let t=new Map;return{async ensure(n,r){if(await e([`reverse`,n.local,n.remote],{allowFailure:!1,signal:r?.signal,timeoutMs:r?.timeoutMs}),n.ownerId){let e=t.get(n.ownerId)??new Set;e.add(n.local),t.set(n.ownerId,e)}},async remove(n,r){let i=await e([`reverse`,`--remove`,n],{allowFailure:!0,signal:r?.signal,timeoutMs:r?.timeoutMs});if(i.exitCode!==0&&!$e(i.stdout,i.stderr))throw K(`Failed to remove Android port reverse ${n}`,i,{local:n});for(let e of t.values())e.delete(n)},async removeAllOwned(e,n){let r=[...t.get(e)??[]];for(let e of r)await this.remove(e,n);t.delete(e)},async list(n){let r=await e([`reverse`,`--list`],{allowFailure:!0,signal:n?.signal,timeoutMs:n?.timeoutMs});return r.exitCode===0?Qe(r.stdout,t):[]}}}function Qe(e,t){let n=new Map;for(let[e,r]of t)for(let t of r)n.set(t,e);return e.split(`
4
+ `).map(e=>e.trim().split(/\s+/)).filter(e=>e.length>=3).map(([,e,t])=>{let r=e;return{local:r,remote:t,ownerId:n.get(r)}})}function $e(e,t){let n=`${e}\n${t}`.toLowerCase();return n.includes(`listener`)&&n.includes(`not found`)}function $(e){let{replace:t,allowTestPackages:n,allowDowngrade:r,grantPermissions:i,...a}=e??{},o=[];return t&&o.push(`-r`),n&&o.push(`-t`),r&&o.push(`-d`),i&&o.push(`-g`),{installArgs:o,execOptions:a}}export{g as A,Se as C,y as D,ue as E,ae as F,te as I,oe as M,re as N,de as O,ne as P,ve as S,x as T,xe as _,We as a,Ce as b,He as c,Z as d,S as f,be as g,Oe as h,W as i,_ as j,ie as k,X as l,R as m,K as n,Ke as o,N as p,G as r,Ge as s,Ne as t,Ue as u,_e as v,ye as w,w as x,T as y};
@@ -0,0 +1,4 @@
1
+ //#region src/contracts/app-inventory.d.ts
2
+ type AppsFilter = 'user-installed' | 'all';
3
+ //#endregion
4
+ export { AppsFilter as t };
@@ -0,0 +1 @@
1
+ import{F as e}from"./sdk-contracts.js";const t=`user-installed`;function n(e){return e??`user-installed`}function r(t){if(t===void 0)throw new e(`INVALID_ARGS`,`appsFilter must be resolved before executing the apps command`);return t}export{r as n,n as r,t};
@@ -0,0 +1,40 @@
1
+ import { a as DaemonRequest, o as DaemonResponse } from "./sdk-contracts.js";
2
+
3
+ //#region src/core/batch.d.ts
4
+ type DaemonBatchStep = {
5
+ command: string;
6
+ positionals?: string[];
7
+ flags?: Record<string, unknown>;
8
+ runtime?: DaemonRequest['runtime'];
9
+ };
10
+ type BatchFlags = Record<string, unknown> & {
11
+ batchOnError?: 'stop';
12
+ batchMaxSteps?: number;
13
+ batchSteps?: DaemonBatchStep[];
14
+ };
15
+ type BatchRequest = Omit<DaemonRequest, 'flags'> & {
16
+ flags?: BatchFlags | Record<string, unknown>;
17
+ };
18
+ type BatchInvoke = (req: BatchRequest) => Promise<DaemonResponse>;
19
+ type BatchStepResult = {
20
+ step: number;
21
+ command: string;
22
+ ok: true;
23
+ data: Record<string, unknown>;
24
+ durationMs: number;
25
+ };
26
+ type BatchRunResult = Record<string, unknown> & {
27
+ total: number;
28
+ executed: number;
29
+ totalDurationMs: number;
30
+ results: BatchStepResult[];
31
+ };
32
+ type BatchRunResponse = {
33
+ ok: true;
34
+ data: BatchRunResult;
35
+ } | Extract<DaemonResponse, {
36
+ ok: false;
37
+ }>;
38
+ declare function runBatch(req: BatchRequest, sessionName: string, invoke: BatchInvoke): Promise<BatchRunResponse>;
39
+ //#endregion
40
+ export { runBatch as n, BatchRunResult as t };
@@ -0,0 +1,2 @@
1
+ import{F as e,I as t,a as n,i as r}from"./sdk-contracts.js";import{a as i,i as a,n as o,t as s}from"./sdk-batch.js";function c(t,n,r,i){let a=r(t[n]);if(a===void 0)throw new e(`COMMAND_FAILED`,i,{response:t});return a}function l(e,t,n){return n(e[t])}function u(e,t,n){let r=e[t];return r===null?null:n(r)}function d(e,t){return c(e,t,x,`Daemon response is missing "${t}".`)}function f(e,t){return l(e,t,x)}function p(e,t){return u(e,t,x)}function m(e,t){return c(e,t,S,`Daemon response is missing numeric "${t}".`)}function h(e,t){return c(e,t,C,`Daemon response has invalid "${t}".`)}function g(e,t){return c(e,t,w,`Daemon response has invalid "${t}".`)}function _(e,t){return l(e,t,T)??`mobile`}function v(e){if(!D(e))return;let t=b(e,`x`),n=b(e,`y`),r=b(e,`width`),i=b(e,`height`);if(!(t===void 0||n===void 0||r===void 0||i===void 0))return{x:t,y:n,width:r,height:i}}function y(e){if(!D(e))return;let t=b(e,`x`),n=b(e,`y`);if(!(t===void 0||n===void 0))return{x:t,y:n}}function b(e,t){let n=e[t];return typeof n==`number`?n:void 0}function x(e){return typeof e==`string`&&e.length>0?e:void 0}function S(e){return typeof e==`number`&&Number.isFinite(e)?e:void 0}function C(e){return e===`apple`?`ios`:e===`ios`||e===`macos`||e===`android`||e===`linux`||e===`web`?e:void 0}function w(e){return e===`simulator`||e===`emulator`||e===`device`?e:void 0}function T(e){return e===`tv`||e===`mobile`||e===`desktop`?e:void 0}function E(t){if(!D(t))throw new e(`COMMAND_FAILED`,`Daemon returned an unexpected response shape.`,{value:t});return t}function D(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function O(e){let t={};for(let[n,r]of Object.entries(e))r!==void 0&&(t[n]=r);return t}function k(e){return e.split(`
2
+ `).map(e=>e.trim()).filter(e=>e.length>0)}function A(e){return Number.isInteger(e)&&e>=1&&e<=1e3}function j(t,n){if(t>n)throw new e(`INVALID_ARGS`,`batch has ${t} steps; max allowed is ${n}.`)}function M(t,n){if(!D(t))throw new e(`INVALID_ARGS`,`Invalid batch step ${n}.`);return t}function N(t,n){let r=t.input;if(!D(r))throw new e(`INVALID_ARGS`,`Batch step ${n} input must be an object.`);return r}function P(t,n){if(t!==void 0)try{return r.parse(t)}catch(t){throw new e(`INVALID_ARGS`,`Batch step ${n} runtime is invalid: ${t instanceof Error?t.message:String(t)}`)}}const F=new Set(s);async function I(e,n,r){let i=U(e.flags),a=i?.batchOnError??`stop`;if(a!==`stop`)return W(`INVALID_ARGS`,`Unsupported batch on-error mode: ${a}.`);let o=i?.batchMaxSteps??100;if(!A(o))return W(`INVALID_ARGS`,`Invalid batch max-steps: ${String(i?.batchMaxSteps)}`);try{let t=L(i?.batchSteps,o),a=Date.now(),s=[];for(let[i,a]of t.entries()){let o=await H(e,n,a,r,i+1,i===t.length-1);if(!o.ok)return{ok:!1,error:{code:o.error.code,message:`Batch failed at step ${o.step} (${a.command}): ${o.error.message}`,hint:o.error.hint,diagnosticId:o.error.diagnosticId,logPath:o.error.logPath,details:{...o.error.details??{},step:o.step,command:a.command,positionals:a.positionals,executed:i,total:t.length,partialResults:s}}};s.push(o.result)}return{ok:!0,data:{total:t.length,executed:t.length,totalDurationMs:Date.now()-a,results:s}}}catch(e){let n=t(e);return W(n.code,n.message,n.details)}}function L(t,n){if(!Array.isArray(t)||t.length===0)throw new e(`INVALID_ARGS`,`batch requires a non-empty batchSteps array.`);j(t.length,n);let r=[];for(let n=0;n<t.length;n+=1){let o=t[n];if(!D(o))throw new e(`INVALID_ARGS`,`Invalid batch step at index ${n}.`);let s=Object.keys(o).filter(e=>!F.has(e));if(s.length>0){let t=s.map(e=>`"${e}"`).join(`, `);throw new e(`INVALID_ARGS`,`Batch step ${n+1} has unknown field(s): ${t}. Allowed fields: command, positionals, flags, runtime.`)}let c=i(o.command);if(!c)throw new e(`INVALID_ARGS`,`Batch step ${n+1} requires command.`);if(a(c,n+1),o.positionals!==void 0&&!Array.isArray(o.positionals))throw new e(`INVALID_ARGS`,`Batch step ${n+1} positionals must be an array.`);let l=o.positionals??[];if(l.some(e=>typeof e!=`string`))throw new e(`INVALID_ARGS`,`Batch step ${n+1} positionals must contain only strings.`);if(o.flags!==void 0&&!D(o.flags))throw new e(`INVALID_ARGS`,`Batch step ${n+1} flags must be an object.`);r.push({command:c,positionals:l,flags:o.flags??{},runtime:P(o.runtime,n+1)})}return r}function R(e,t){let{batchSteps:n,batchOnError:r,batchMaxSteps:i,...a}=t??{};return z(U(e),a)}function z(e,t){let n=U(e)??{},r=t;for(let e of o)r[e]===void 0&&n[e]!==void 0&&(r[e]=n[e]);return t}function B(e,t){return n(e)?t?e:`digest`:e}function V(e,t){let n=e?.responseLevel,r=B(n,t);return r===n?e:{...e,responseLevel:r}}async function H(e,t,n,r,i,a){let o=Date.now(),s=R(e.flags,n.flags);s.session===void 0&&(s.session=t);let c=await r({token:e.token,session:t,command:n.command,positionals:n.positionals,flags:s,runtime:n.runtime===void 0?e.runtime:n.runtime,meta:V(e.meta,a)}),l=Date.now()-o;return c.ok?{ok:!0,step:i,result:{step:i,command:n.command,ok:!0,data:c.data??{},durationMs:l}}:{ok:!1,step:i,error:c.error}}function U(e){return e}function W(e,t,n){return{ok:!1,error:{code:e,message:t,...n?{details:n}:{}}}}export{h as _,P as a,O as b,E as c,v as d,_ as f,m as g,g as h,A as i,D as l,f as m,I as n,N as o,p,j as r,M as s,z as t,y as u,d as v,k as y};
@@ -0,0 +1,2 @@
1
+ import{F as e}from"./sdk-contracts.js";const t={alert:`alert`,audio:`audio`,appState:`appstate`,appSwitcher:`app-switcher`,artifacts:`artifacts`,apps:`apps`,back:`back`,batch:`batch`,boot:`boot`,capabilities:`capabilities`,click:`click`,close:`close`,clipboard:`clipboard`,devices:`devices`,doctor:`doctor`,diff:`diff`,fill:`fill`,find:`find`,focus:`focus`,gesture:`gesture`,get:`get`,home:`home`,install:`install`,installFromSource:`install-from-source`,is:`is`,keyboard:`keyboard`,logs:`logs`,longPress:`longpress`,network:`network`,open:`open`,perf:`perf`,prepare:`prepare`,press:`press`,push:`push`,record:`record`,reactNative:`react-native`,reinstall:`reinstall`,replay:`replay`,rotate:`rotate`,scroll:`scroll`,screenshot:`screenshot`,settings:`settings`,shutdown:`shutdown`,snapshot:`snapshot`,swipe:`swipe`,test:`test`,trace:`trace`,triggerAppEvent:`trigger-app-event`,type:`type`,viewport:`viewport`,wait:`wait`},n={installSource:`install_source`,leaseAllocate:`lease_allocate`,leaseHeartbeat:`lease_heartbeat`,leaseRelease:`lease_release`,releaseMaterializedPaths:`release_materialized_paths`,runtime:`runtime`,sessionList:`session_list`},r={cdp:`cdp`,auth:`auth`,connect:`connect`,connection:`connection`,debug:`debug`,disconnect:`disconnect`,mcp:`mcp`,metro:`metro`,proxy:`proxy`,reactDevtools:`react-devtools`,session:`session`,web:`web`},i={help:`help`},a=[`pan`,`fling`,`swipe`,`pinch`,`rotate`,`transform`],o=`gesture requires one of: ${a.join(`, `)}`;function s(){return[...Object.values(t),...Object.values(r)].sort()}function ee(e){return Object.values(i).includes(e)||Object.values(n).includes(e)?!0:s().includes(e)}function te(e){return Object.values(t).includes(e)||e===r.debug||e===r.metro||e===r.session}function c(e){if(!e)return null;let t=Number(e);return Number.isFinite(t)?t:null}const l=new Set([`id`,`role`,`text`,`label`,`value`,`appname`,`windowtitle`]),u=new Set([`visible`,`hidden`,`editable`,`selected`,`enabled`,`hittable`]),d=new Set([...l,...u]),f=new Map([[`"`,`"`],[`'`,`'`],[`\\`,`\\`],[`/`,`/`],[`b`,`\b`],[`f`,`\f`],[`n`,`
2
+ `],[`r`,`\r`],[`t`,` `]]);function p(t){let n=t.trim();if(!n)throw new e(`INVALID_ARGS`,`Selector expression cannot be empty`);let r=_(n);if(r.length===0)throw new e(`INVALID_ARGS`,`Selector expression cannot be empty`);return{raw:n,selectors:r.map(e=>ne(e))}}function m(e){try{return p(e)}catch{return null}}function h(e){let t=e.trim();if(!t)return!1;if(t===`||`)return!0;let n=t.indexOf(`=`);if(n!==-1){let e=t.slice(0,n).trim().toLowerCase();return d.has(e)}return d.has(t.toLowerCase())}function g(e,t={}){if(e.length===0)return null;let n=t.preferTrailingValue??!1,r=0,i=[];for(;r<e.length;){let t=e[r];if(t===void 0||!h(t))break;r+=1;let n=e.slice(0,r).join(` `).trim();n&&m(n)&&i.push(r)}if(i.length===0)return null;let a=i.at(-1);if(a===void 0)return null;let o=a;if(n)for(let t=i.length-1;t>=0;--t){let n=i[t];if(n!==void 0&&n<e.length){o=n;break}}let s=e.slice(0,o).join(` `).trim();return s?{selectorExpression:s,rest:e.slice(o)}:null}function ne(t){let n=t.trim();if(!n)throw new e(`INVALID_ARGS`,`Selector segment cannot be empty`);let r=v(n);if(r.length===0)throw new e(`INVALID_ARGS`,`Invalid selector segment: ${t}`);return{raw:n,terms:r.map(re)}}function re(t){let n=t.trim();if(!n)throw new e(`INVALID_ARGS`,`Empty selector term`);let r=n.indexOf(`=`);if(r===-1){let r=n.toLowerCase();if(!u.has(r))throw new e(`INVALID_ARGS`,`Invalid selector term "${t}", expected key=value`);return{key:r,value:!0}}let i=n.slice(0,r).trim().toLowerCase(),a=n.slice(r+1).trim();if(!d.has(i))throw new e(`INVALID_ARGS`,`Unknown selector key: ${i}`);if(!a)throw new e(`INVALID_ARGS`,`Missing selector value for key: ${i}`);if(u.has(i)){let t=ie(a);if(t===null)throw new e(`INVALID_ARGS`,`Invalid boolean value for ${i}: ${a}`);return{key:i,value:t}}return{key:i,value:b(a)}}function _(t){let n=[],r=``,i=null;for(let a=0;a<t.length;a+=1){let o=t[a];if((o===`"`||o===`'`)&&!C(t,a)){i=y(i,o),r+=o;continue}if(!i&&o===`|`&&t[a+1]===`|`){let i=r.trim();if(!i)throw new e(`INVALID_ARGS`,`Invalid selector fallback expression: ${t}`);n.push(i),r=``,a+=1;continue}r+=o}let a=r.trim();if(!a)throw new e(`INVALID_ARGS`,`Invalid selector fallback expression: ${t}`);return n.push(a),n}function v(t){let n=[],r=``,i=null;for(let e=0;e<t.length;e+=1){let a=t.charAt(e);if((a===`"`||a===`'`)&&!C(t,e)){i=y(i,a),r+=a;continue}if(!i&&/\s/.test(a)){r.trim()&&n.push(r.trim()),r=``;continue}r+=a}if(i)throw new e(`INVALID_ARGS`,`Unclosed quote in selector: ${t}`);return r.trim()&&n.push(r.trim()),n}function y(e,t){return e?e===t?null:e:t}function b(e){let t=e.trim();return t.startsWith(`"`)&&t.endsWith(`"`)||t.startsWith(`'`)&&t.endsWith(`'`)?x(t.slice(1,-1)):t}function x(e){let t=``,n=0;for(;n<e.length;){let r=e.charAt(n);if(r!==`\\`){t+=r,n+=1;continue}let i=e.charAt(n+1);if(!i){t+=r,n+=1;continue}let a=S(i);if(a!==null){t+=a,n+=2;continue}if(i===`u`){let r=e.slice(n+2,n+6);if(/^[0-9a-fA-F]{4}$/.test(r)){t+=String.fromCharCode(Number.parseInt(r,16)),n+=6;continue}}t+=r,n+=1}return t}function S(e){return f.get(e)??null}function ie(e){let t=b(e).toLowerCase();return t===`true`?!0:t===`false`?!1:null}function C(e,t){let n=0;for(let r=t-1;r>=0&&e[r]===`\\`;--r)n+=1;return n%2==1}function w(e){let t=e[0];if(t===void 0)return null;let n=c(t);if(n!==null)return{kind:`sleep`,durationMs:n};let r=c(e[e.length-1]);if(t===`text`)return{kind:`text`,text:(r===null?e.slice(1).join(` `):e.slice(1,-1).join(` `)).trim(),timeoutMs:r};if(t===`stable`){let t=e.slice(1),n=t.length>1?c(t[1]):null;return{kind:`stable`,quietMs:t.length>0?c(t[0]):null,timeoutMs:n}}if(t.startsWith(`@`))return{kind:`ref`,rawRef:t,timeoutMs:r};let i=g(r===null?e.slice():e.slice(0,-1));return i&&i.rest.length===0&&m(i.selectorExpression)?{kind:`selector`,selectorExpression:i.selectorExpression,timeoutMs:r}:{kind:`text`,text:(r===null?e.join(` `):e.slice(0,-1).join(` `)).trim(),timeoutMs:r}}function T(e){let t=w(e);return t?t.kind===`sleep`?t.durationMs:t.timeoutMs:null}const E=24e4,D={budget:{source:`none`},envelopeMs:9e4,onTimeout:`reset-daemon`},O={[t.click]:`settle-and-verify`,[t.press]:`settle-and-verify`,[t.fill]:`settle-and-verify`,[t.longPress]:`settle`};function k(e){if(e!==void 0)return O[e]}const A={leaseAdmissionExempt:!0,sessionExecutionLockExempt:!0},j={leaseAdmissionExempt:!0,sessionExecutionLockExempt:!0,selectorValidationExempt:!0},M=()=>!0,N=e=>(e.positionals?.[0]??``).toLowerCase()===`start`,P=e=>e.command===t.test&&(typeof e.flags?.shardAll==`number`||typeof e.flags?.shardSplit==`number`),F={simulator:!0,device:!0},I={emulator:!0,device:!0,unknown:!0},L={device:!0},R={},z={apple:F,android:I,linux:L},B=z,V={apple:F,android:I,linux:R},H={apple:F,android:I,linux:R},U={...D,onTimeout:`preserve-daemon`},W={...D,envelopeMs:18e4},G={...D,budget:{source:`flag`,envelope:`widen`,defaultBudgetMs:1e4},onTimeout:`preserve-daemon`};function K(e){return k(e)===void 0?U:G}function q(e){let t=k(e);if(t===void 0)throw Error(`Missing post-action observation descriptor support for ${e}`);return t}const J=[{name:n.leaseAllocate,daemon:{route:`lease`,...A},timeoutPolicy:D,batchable:!1},{name:n.leaseHeartbeat,daemon:{route:`lease`,...A},timeoutPolicy:D,batchable:!1},{name:n.leaseRelease,daemon:{route:`lease`,...A},timeoutPolicy:D,batchable:!1},{name:t.artifacts,daemon:{route:`lease`,...A},timeoutPolicy:D,batchable:!1},{name:n.sessionList,daemon:{route:`session`,sessionKind:`inventory`,...j},timeoutPolicy:D,batchable:!1},{name:t.devices,daemon:{route:`session`,sessionKind:`inventory`,lockPolicySelectorOverride:!0,...j},timeoutPolicy:D,batchable:!0},{name:t.capabilities,daemon:{route:`session`,sessionKind:`inventory`,lockPolicySelectorOverride:!0,preferExplicitDeviceOverExistingSession:!0,...j},timeoutPolicy:D,batchable:!0},{name:t.doctor,daemon:{route:`session`,sessionKind:`inventory`,lockPolicySelectorOverride:!0,allowSessionlessDefaultDevice:M,...j},timeoutPolicy:D,batchable:!0},{name:t.apps,daemon:{route:`session`,sessionKind:`inventory`,lockPolicySelectorOverride:!0,preferExplicitDeviceOverExistingSession:!0},capability:V,timeoutPolicy:D,batchable:!0},{name:t.boot,daemon:{route:`session`,sessionKind:`state`},capability:{apple:F,android:I,linux:R},timeoutPolicy:D,batchable:!0},{name:t.shutdown,daemon:{route:`session`,sessionKind:`state`},capability:{apple:{simulator:!0},android:{emulator:!0},linux:R},timeoutPolicy:D,batchable:!0},{name:t.appState,daemon:{route:`session`,sessionKind:`state`},timeoutPolicy:D,batchable:!0},{name:t.perf,daemon:{route:`session`,sessionKind:`observability`},capability:{apple:F,android:I,linux:R},timeoutPolicy:D,batchable:!0},{name:t.logs,daemon:{route:`session`,sessionKind:`observability`},capability:{apple:F,android:I,linux:R},timeoutPolicy:D,batchable:!0},{name:t.network,daemon:{route:`session`,sessionKind:`observability`},capability:{apple:F,android:I,linux:R},timeoutPolicy:D,batchable:!0},{name:t.audio,daemon:{route:`session`,sessionKind:`observability`},capability:{apple:F,android:{emulator:!0},linux:R},timeoutPolicy:D,batchable:!0},{name:t.replay,daemon:{route:`session`,sessionKind:`replay`,skipSessionlessProviderDevice:P},timeoutPolicy:{...D,budget:{source:`flag`}},batchable:!1},{name:t.test,daemon:{route:`session`,sessionKind:`replay`,skipSessionlessProviderDevice:P},timeoutPolicy:{...D,envelopeMs:`unbounded`},batchable:!0},{name:n.runtime,daemon:{route:`session`},timeoutPolicy:D,batchable:!1},{name:t.clipboard,daemon:{route:`session`,replayScopedAction:!0},capability:{apple:F,android:I,linux:L},timeoutPolicy:D,batchable:!0},{name:t.keyboard,daemon:{route:`session`,replayScopedAction:!0,androidBlockingDialogGuard:!0},capability:{apple:F,android:I,linux:R},timeoutPolicy:D,batchable:!0},{name:t.install,daemon:{route:`session`},capability:H,timeoutPolicy:W,batchable:!0},{name:t.reinstall,daemon:{route:`session`},capability:H,timeoutPolicy:W,batchable:!0},{name:n.installSource,daemon:{route:`session`},timeoutPolicy:W,batchable:!1},{name:n.releaseMaterializedPaths,daemon:{route:`session`,...j},timeoutPolicy:D,batchable:!1},{name:t.push,daemon:{route:`session`},capability:{apple:{simulator:!0},android:I,linux:R},timeoutPolicy:D,batchable:!0},{name:t.triggerAppEvent,daemon:{route:`session`},capability:{apple:F,android:I,linux:R},timeoutPolicy:D,batchable:!0},{name:t.open,daemon:{route:`session`,allowSessionlessDefaultDevice:M},capability:B,timeoutPolicy:D,batchable:!0},{name:t.prepare,daemon:{route:`session`},timeoutPolicy:{budget:{source:`flag`},envelopeMs:E,onTimeout:`reset-daemon`},batchable:!1,mcpExposed:!1},{name:t.batch,daemon:{route:`session`},timeoutPolicy:D,batchable:!1},{name:t.close,daemon:{route:`session`,allowInvalidRecording:!0},capability:B,timeoutPolicy:D,batchable:!0},{name:t.snapshot,daemon:{route:`snapshot`,replayScopedAction:!0},capability:z,timeoutPolicy:{...U,budget:{source:`flag`}},batchable:!0},{name:t.diff,daemon:{route:`snapshot`,replayScopedAction:!0},capability:z,timeoutPolicy:D,batchable:!0},{name:t.wait,daemon:{route:`snapshot`,replayScopedAction:!0},capability:z,timeoutPolicy:{...U,budget:{source:`positional-parser`,parser:T}},batchable:!0},{name:t.alert,daemon:{route:`snapshot`,replayScopedAction:!0},capability:{apple:F,android:I,linux:R},timeoutPolicy:D,batchable:!0},{name:t.settings,daemon:{route:`snapshot`,replayScopedAction:!0},capability:{apple:F,android:I,linux:R},timeoutPolicy:D,batchable:!0},{name:t.reactNative,daemon:{route:`reactNative`,replayScopedAction:!0},capability:{apple:F,android:I,linux:R},timeoutPolicy:D,batchable:!0},{name:t.record,daemon:{route:`recordTrace`,replayScopedAction:!0,allowInvalidRecording:!0,allowSessionlessDefaultDevice:N},capability:{apple:F,android:I,linux:R},timeoutPolicy:D,batchable:!0},{name:t.trace,daemon:{route:`recordTrace`},timeoutPolicy:D,batchable:!0},{name:t.find,daemon:{route:`find`,replayScopedAction:!0},capability:z,timeoutPolicy:U,batchable:!0},{name:t.click,daemon:{route:`interaction`,replayScopedAction:!0,androidBlockingDialogGuard:!0},capability:{apple:F,android:I,linux:L},timeoutPolicy:K(t.click),postActionObservation:q(t.click),batchable:!0},{name:t.fill,daemon:{route:`interaction`,replayScopedAction:!0,androidBlockingDialogGuard:!0},capability:{apple:F,android:I,linux:L},timeoutPolicy:K(t.fill),postActionObservation:q(t.fill),batchable:!0},{name:t.longPress,daemon:{route:`interaction`,replayScopedAction:!0,androidBlockingDialogGuard:!0},capability:{apple:F,android:I,linux:L},timeoutPolicy:K(t.longPress),postActionObservation:q(t.longPress),batchable:!0},{name:t.press,daemon:{route:`interaction`,replayScopedAction:!0,androidBlockingDialogGuard:!0},capability:{apple:F,android:I,linux:L},timeoutPolicy:K(t.press),postActionObservation:q(t.press),batchable:!0},{name:t.type,daemon:{route:`interaction`,replayScopedAction:!0,androidBlockingDialogGuard:!0},capability:z,timeoutPolicy:K(t.type),batchable:!0},{name:t.get,daemon:{route:`interaction`,replayScopedAction:!0},capability:z,timeoutPolicy:K(t.get),batchable:!0},{name:t.is,daemon:{route:`interaction`,replayScopedAction:!0},capability:z,timeoutPolicy:K(t.is),batchable:!0},{name:t.back,daemon:{route:`generic`,replayScopedAction:!0,androidBlockingDialogGuard:!0},capability:{apple:F,android:I,linux:L},timeoutPolicy:D,batchable:!0},{name:t.gesture,daemon:{route:`generic`,replayScopedAction:!0,androidBlockingDialogGuard:!0},timeoutPolicy:D,batchable:!0},{name:t.home,daemon:{route:`generic`,replayScopedAction:!0,androidBlockingDialogGuard:!0},capability:{apple:F,android:I,linux:L},timeoutPolicy:D,batchable:!0},{name:t.rotate,daemon:{route:`generic`,replayScopedAction:!0,androidBlockingDialogGuard:!0},capability:{apple:F,android:I,linux:R},timeoutPolicy:D,batchable:!0},{name:t.scroll,daemon:{route:`generic`,replayScopedAction:!0,androidBlockingDialogGuard:!0},capability:{apple:F,android:I,linux:L},timeoutPolicy:D,batchable:!0},{name:t.swipe,daemon:{route:`generic`,replayScopedAction:!0,androidBlockingDialogGuard:!0},capability:{apple:F,android:I,linux:L},timeoutPolicy:D,batchable:!0},{name:`pinch`,daemon:{route:`generic`,replayScopedAction:!0,androidBlockingDialogGuard:!0},capability:{apple:F,android:I,linux:R},timeoutPolicy:D,batchable:!1},{name:t.focus,daemon:{route:`generic`,androidBlockingDialogGuard:!0},capability:{apple:F,android:I,linux:L},timeoutPolicy:D,batchable:!0},{name:t.screenshot,daemon:{route:`generic`,replayScopedAction:!0},capability:z,timeoutPolicy:D,batchable:!0},{name:t.viewport,daemon:{route:`generic`,replayScopedAction:!0},capability:{apple:F,android:I,linux:R},timeoutPolicy:D,batchable:!1},{name:`pan`,daemon:{route:`generic`,androidBlockingDialogGuard:!0},capability:{apple:F,android:I,linux:L},timeoutPolicy:D,batchable:!1},{name:`fling`,daemon:{route:`generic`,androidBlockingDialogGuard:!0},capability:{apple:F,android:I,linux:R},timeoutPolicy:D,batchable:!1},{name:`rotate-gesture`,daemon:{route:`generic`,androidBlockingDialogGuard:!0},capability:{apple:F,android:I,linux:R},timeoutPolicy:D,batchable:!1},{name:`transform-gesture`,daemon:{route:`generic`,androidBlockingDialogGuard:!0},capability:{apple:F,android:I,linux:R},timeoutPolicy:D,batchable:!1},{name:t.appSwitcher,capability:{apple:F,android:I,linux:R},timeoutPolicy:D,batchable:!0},{name:t.installFromSource,capability:H,timeoutPolicy:D,batchable:!0},{name:`debug`,timeoutPolicy:D,batchable:!1},{name:`metro`,timeoutPolicy:D,batchable:!1},{name:`session`,timeoutPolicy:D,batchable:!1}],Y=new Set(s()),X=J.map(e=>({...e,mcpExposed:ce(e)}));function ae(){return X.filter(e=>le(e)).map(e=>e.name).sort()}const oe=new Map(X.map(e=>[e.name,e]));function se(e){return Y.has(e)}function ce(e){return e.mcpExposed??Y.has(e.name)}function le(e){return e.mcpExposed&&se(e.name)}const ue=new Map(X.map(e=>[e.name,e.timeoutPolicy]));function Z(e){if(e!==void 0)return oe.get(e)?.postActionObservation}function de(e){return Z(e)!==void 0}function fe(e){return Z(e)===`settle-and-verify`}function pe(e){return e===void 0?D:ue.get(e)??D}function me(e){let t=[];for(let n of e)n.daemon&&t.push({command:n.name,...n.daemon});return t}function he(e){let t={};for(let n of e)n.capability&&(t[n.name]=n.capability);return t}function ge(e){return e.filter(e=>e.batchable).map(e=>e.name)}const Q=ge(X),_e=new Set([`batch`,`replay`]),ve=[`command`,`positionals`,`flags`,`runtime`],ye=[`platform`,`target`,`device`,`udid`,`serial`,`verbose`,`out`],be=new Set(Q);function xe(e){return be.has(e)}function $(e){return typeof e==`string`?e.trim().toLowerCase():``}function Se(t,n){let r=$(t);if(xe(r))return r;throw new e(`INVALID_ARGS`,`Batch step ${n} command is not available through command batch: ${String(t)}`)}function Ce(t,n){if(_e.has(t))throw new e(`INVALID_ARGS`,`Batch step ${n} cannot run ${t}.`)}export{n as C,s as D,ee as E,o as S,te as T,p as _,$ as a,c as b,me as c,fe as d,ae as f,h as g,w as h,Ce as i,X as l,E as m,ye as n,Se as o,pe as p,Q as r,he as s,ve as t,de as u,g as v,t as w,a as x,m as y};