agent-device 0.18.3 → 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 (215) hide show
  1. package/android-multitouch-helper/dist/{agent-device-android-multitouch-helper-0.18.3.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.3.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.3.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.3.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 +58 -37
  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 -1786
  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/android-multitouch-helper/dist/agent-device-android-multitouch-helper-0.18.3.apk.sha256 +0 -1
  149. package/android-snapshot-helper/dist/agent-device-android-snapshot-helper-0.18.3.apk.sha256 +0 -1
  150. package/apple-runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+CommandJournal.swift +0 -443
  151. package/apple-runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+FlatSnapshotFiltering.swift +0 -169
  152. package/apple-runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+ScrollGesture.swift +0 -220
  153. package/dist/src/1404.js +0 -1
  154. package/dist/src/1986.js +0 -1
  155. package/dist/src/2748.js +0 -1
  156. package/dist/src/2948.js +0 -30
  157. package/dist/src/3006.js +0 -1
  158. package/dist/src/314.js +0 -1
  159. package/dist/src/3340.js +0 -8
  160. package/dist/src/4418.js +0 -1
  161. package/dist/src/4428.js +0 -3
  162. package/dist/src/485.js +0 -1
  163. package/dist/src/4917.js +0 -1
  164. package/dist/src/495.js +0 -5
  165. package/dist/src/5448.js +0 -3
  166. package/dist/src/5484.js +0 -1
  167. package/dist/src/5643.js +0 -1
  168. package/dist/src/587.js +0 -1
  169. package/dist/src/5913.js +0 -4
  170. package/dist/src/6849.js +0 -1
  171. package/dist/src/6918.js +0 -1
  172. package/dist/src/6967.js +0 -1
  173. package/dist/src/760.js +0 -1
  174. package/dist/src/7871.js +0 -1
  175. package/dist/src/8184.js +0 -1
  176. package/dist/src/8225.js +0 -1
  177. package/dist/src/8391.js +0 -1
  178. package/dist/src/8404.js +0 -2
  179. package/dist/src/8414.js +0 -2
  180. package/dist/src/8875.js +0 -4
  181. package/dist/src/893.js +0 -1
  182. package/dist/src/8936.js +0 -1
  183. package/dist/src/9414.js +0 -1
  184. package/dist/src/9581.js +0 -22
  185. package/dist/src/9612.js +0 -1
  186. package/dist/src/9624.js +0 -1
  187. package/dist/src/9722.js +0 -39
  188. package/dist/src/devices~1.js +0 -1
  189. package/dist/src/devices~2.js +0 -1
  190. package/dist/src/input-actions~1.js +0 -1
  191. package/dist/src/rslib-runtime.js +0 -1
  192. /package/{apple-runner → dist/apple-runner}/AgentDeviceRunner/AgentDeviceRunner/AgentDeviceRunnerApp.m +0 -0
  193. /package/{apple-runner → dist/apple-runner}/AgentDeviceRunner/AgentDeviceRunner.xcodeproj/project.pbxproj +0 -0
  194. /package/{apple-runner → dist/apple-runner}/AgentDeviceRunner/AgentDeviceRunner.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -0
  195. /package/{apple-runner → dist/apple-runner}/AgentDeviceRunner/AgentDeviceRunner.xcodeproj/xcshareddata/xcschemes/AgentDeviceRunner.xcscheme +0 -0
  196. /package/{apple-runner → dist/apple-runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/AgentDeviceRunnerUITests-Bridging-Header.h +0 -0
  197. /package/{apple-runner → dist/apple-runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/AgentDeviceRunnerUITests.entitlements +0 -0
  198. /package/{apple-runner → dist/apple-runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerAXSnapshotBridge.h +0 -0
  199. /package/{apple-runner → dist/apple-runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerAXSnapshotBridge.m +0 -0
  200. /package/{apple-runner → dist/apple-runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerObjCExceptionCatcher.h +0 -0
  201. /package/{apple-runner → dist/apple-runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerObjCExceptionCatcher.m +0 -0
  202. /package/{apple-runner → dist/apple-runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerSynthesizedGesture.h +0 -0
  203. /package/{apple-runner → dist/apple-runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerSynthesizedGesture.m +0 -0
  204. /package/{apple-runner → dist/apple-runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Alert.swift +0 -0
  205. /package/{apple-runner → dist/apple-runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Environment.swift +0 -0
  206. /package/{apple-runner → dist/apple-runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Exceptions.swift +0 -0
  207. /package/{apple-runner → dist/apple-runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Lifecycle.swift +0 -0
  208. /package/{apple-runner → dist/apple-runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Models.swift +0 -0
  209. /package/{apple-runner → dist/apple-runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+ScreenRecorder.swift +0 -0
  210. /package/{apple-runner → dist/apple-runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SystemModal.swift +0 -0
  211. /package/{apple-runner → dist/apple-runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TvRemote.swift +0 -0
  212. /package/{apple-runner → dist/apple-runner}/AgentDeviceRunner/AgentDeviceRunnerUITests.xctestplan +0 -0
  213. /package/{apple-runner → dist/apple-runner}/AgentDeviceRunner/RecordingScripts/recording-overlay.swift +0 -0
  214. /package/{apple-runner → dist/apple-runner}/AgentDeviceRunner/RecordingScripts/recording-resize.swift +0 -0
  215. /package/{apple-runner → dist/apple-runner}/AgentDeviceRunner/RecordingScripts/recording-trim.swift +0 -0
package/dist/src/apps.js CHANGED
@@ -1,11 +1,5 @@
1
- let e;import{promises as t}from"node:fs";import i from"node:os";import a from"node:path";import{fileURLToPath as r}from"node:url";import{AppError as n}from"./485.js";import{runXcrun as o,resolveIosDevicectlHint as s,LAUNCH_CONSOLE_DIRECT_APP_ONLY_MESSAGE as l,resolveAppleToolProvider as d,runSimctlForDevice as u,IOS_DEVICECTL_DEFAULT_HINT as c,readInfoPlistString as p,buildSimctlArgsForDevice as f,runAppleRunnerCommand as w,runMacOsPermissionAction as m,runIosDevicectl as h,filterAppleAppsByBundlePrefix as y,runAppleToolCommand as A,listIosDeviceApps as I,quitMacOsApp as _,LAUNCH_CONSOLE_IOS_SIMULATOR_ONLY_MESSAGE as g,IOS_RUNNER_CONTAINER_BUNDLE_IDS as C}from"./9722.js";import{emitDiagnostic as v,runCmd as b}from"./8875.js";import{materializeInstallablePath as N,isTrustedInstallSourceUrl as S}from"./5484.js";import{parseAppearanceAction as L,summarizeCommandAttemptFailures as D,parseSettingState as M,parsePermissionTarget as O,parsePermissionAction as P}from"./8225.js";import{isWebUrl as R,createAppResolutionCache as F,isDeepLinkTarget as x,resolveIosSimulatorDeviceSetPath as $,resolveIosDeviceDeepLinkBundleId as k,retryWithPolicy as E,Deadline as T}from"./3340.js";import{isIosFamily as U,isMacOs as B}from"./6849.js";import{requireSimulatorDevice as G,ensureBootedSimulator as V,getSimulatorState as j}from"./simulator.js";import{getUnsupportedMacOsSettingMessage as W,requireLocationCoordinates as K}from"./2948.js";function H(e){if(!(e instanceof n)||"COMMAND_FAILED"!==e.code)return!1;let t=e.details??{};if(4!==t.exitCode)return!1;let i=String(t.stderr??"").toLowerCase();return i.includes("fbsopenapplicationserviceerrordomain")&&i.includes("the request to open")}async function z(e,t){let i=await o(f(e,["get_app_container",e.id,t]),{allowFailure:!0});if(0!==i.exitCode)return{installed:!1};let a=i.stdout.trim();if(!a)return{installed:!1};let r=await A("plutil",["-extract","CFBundleExecutable","raw","-o","-",`${a}/Info.plist`],{allowFailure:!0});if(0!==r.exitCode||!r.stdout.trim())return{installed:!0};let n=r.stdout.trim(),s=`${a}/${n}`,l=await A("otool",["-l",s],{allowFailure:!0});if(0!==l.exitCode)return{installed:!0};let d=l.stdout.toLowerCase();return{installed:!0,simulatorCompatible:d.includes("iossimulator")||d.includes("platform 7")}}async function q(e,t){let i;if("url"===e.kind&&!S(e.url))throw new n("INVALID_ARGS","iOS install_from_source URL sources are only supported for trusted artifact services such as GitHub Actions and EAS. Use a path source for other hosts.");let a=await N({source:e,isInstallablePath:(e,t)=>t.isDirectory()&&e.toLowerCase().endsWith(".app")||t.isFile()&&e.toLowerCase().endsWith(".ipa"),installableLabel:"iOS installable (.app or .ipa)",allowArchiveExtraction:"url"!==e.kind||S(e.url),signal:t?.signal});try{let e=i=await Z(a.installablePath,t),r=await J(e.installPath);return{archivePath:a.archivePath??(a.installablePath.toLowerCase().endsWith(".ipa")?a.installablePath:void 0),installablePath:e.installPath,bundleId:r.bundleId,appName:r.appName,cleanup:async()=>{await e.cleanup(),await a.cleanup()}}}catch(e){try{await i?.cleanup()}finally{await a.cleanup()}throw e}}async function J(e){let t=a.join(e,"Info.plist"),[i,r,n]=await Promise.all([p(t,"CFBundleIdentifier"),p(t,"CFBundleDisplayName"),p(t,"CFBundleName")]);return{bundleId:i,appName:r??n}}async function Z(e,r){if(!e.toLowerCase().endsWith(".ipa"))return{installPath:e,cleanup:async()=>{}};let o=await t.mkdtemp(a.join(i.tmpdir(),"agent-device-ios-ipa-")),s=async()=>{await t.rm(o,{recursive:!0,force:!0})};try{await b("unzip",["-q",e,"-d",o]);let i=a.join(o,"Payload"),l=(await t.readdir(i,{withFileTypes:!0}).catch(()=>{throw new n("INVALID_ARGS","Invalid IPA: missing Payload directory")})).filter(e=>e.isDirectory()&&e.name.toLowerCase().endsWith(".app")).map(e=>({installPath:a.join(i,e.name),bundleName:e.name.replace(/\.app$/i,"")})),d=l[0];if(void 0!==d&&1===l.length)return{installPath:d.installPath,cleanup:s};if(0===l.length)throw new n("INVALID_ARGS","Invalid IPA: expected at least one .app under Payload, found 0");await Q(l);let u=r?.appIdentifierHint?.trim();if(u){let e=function(e,t){let i=t.toLowerCase(),a=e.filter(e=>e.bundleName.toLowerCase()===i);if(1===a.length)return a[0];if(a.length>1)throw new n("INVALID_ARGS",`Invalid IPA: multiple app bundles matched "${t}" by name. Use a bundle id hint instead.`);if(t.includes(".")){let t=e.filter(e=>e.bundleId?.toLowerCase()===i);if(1===t.length)return t[0]}}(l,u);if(e)return{installPath:e.installPath,cleanup:s};throw new n("INVALID_ARGS",`Invalid IPA: found ${l.length} .app bundles under Payload and none matched "${u}". Available bundles: ${l.map(X).join(", ")}`)}throw new n("INVALID_ARGS",`Invalid IPA: found ${l.length} .app bundles under Payload. Pass an app identifier or bundle name matching one of: ${l.map(X).join(", ")}`)}catch(e){throw await s(),e}}async function Q(e){await Promise.all(e.map(async e=>{if(e.bundleId&&e.appName)return;let t=await J(e.installPath);e.bundleId=e.bundleId??t.bundleId,e.appName=e.appName??t.appName}))}function X(e){let t=e.bundleId??e.appName;return t?`${e.bundleName}.app (${t})`:`${e.bundleName}.app`}let Y={settings:"com.apple.systempreferences"},ee=/^[a-z0-9-]+(?:\.[a-z0-9-]+)+$/,et={platform:"macos",deviceId:"host",variant:"all"},ei=F();async function ea(e){let t=e.trim(),i=Y[t.toLowerCase()];if(i)return i;if(ee.test(t))return t;let a=ei.get(et,t);if(a)return a;let r=(await eu("all")).filter(e=>e.name.toLowerCase()===t.toLowerCase()),o=r[0];if(void 0!==o&&1===r.length)return ei.set(et,t,o.bundleId);if(r.length>1)throw new n("INVALID_ARGS",`Multiple apps matched "${e}"`,{matches:r});throw new n("APP_NOT_INSTALLED",`No app found matching "${e}"`)}async function er(e,t,i){let a=i?.url?.trim();if(a){if(!x(a))throw new n("INVALID_ARGS","open <app> <url> requires a valid URL target");let e=i?.appBundleId??await ea(t);await ec().openBundle(e,a);return}let r=t.trim();if(x(r))return void await ec().openTarget(r);let o=i?.appBundleId??await ea(r);await ec().openBundle(o)}async function en(e,t){let i=await ea(t),a=await _(i);if(a.running&&!a.terminated&&!a.forceTerminated)throw new n("COMMAND_FAILED",`Failed to close macOS app ${t}`,{bundleId:i,running:a.running,terminated:a.terminated,forceTerminated:a.forceTerminated})}async function eo(){return await ec().readClipboard()}async function es(e){await ec().writeClipboard(e)}async function el(){return await ec().readDarkMode()}async function ed(e){let t=L(e),i="toggle"===t?!await el():"dark"===t;await ec().setDarkMode(i)}async function eu(e){return await ec().listApps(e)}function ec(){let e=d().macosHost;if(!e)throw new n("UNSUPPORTED_OPERATION","macOS host provider is not available");return e}function ep(e){if(!(e instanceof n))return{reason:e instanceof Error?e.message:String(e)};let t=e.details??{},i=Array.isArray(t.args)?t.args.filter(e=>"string"==typeof e).join(" "):void 0;return{errorCode:e.code,reason:e.message,timeoutMs:"number"==typeof t.timeoutMs?t.timeoutMs:void 0,exitCode:"number"==typeof t.exitCode?t.exitCode:void 0,stderr:"string"==typeof t.stderr&&t.stderr.trim()?t.stderr:void 0,stdout:"string"==typeof t.stdout&&t.stdout.trim()?t.stdout:void 0,commandArgs:i}}let ef=["--time","9:41","--dataNetwork","wifi","--wifiMode","active","--wifiBars","3","--batteryState","charged","--batteryLevel","100"],ew={0:"hide",1:"wifi",6:"3g",7:"4g",8:"lte",9:"lte-a",10:"lte+",11:"5g",12:"5g+",13:"5g-uwb",14:"5g-uc"},em={1:"searching",2:"failed",3:"active"},eh={0:"notSupported",1:"searching",2:"failed",3:"active"},ey=new Set;async function eA(e){var t;let i=null,a=!1;if(t=e,ey.has(eg(t)))a=!0;else try{i=await eC(e),a=!0}catch(t){eN(e,"snapshot_failed",t)}try{(!a||i)&&await ev(e),await eb(e,ef)}catch(t){eN(e,"prepare_failed",t)}return async()=>{await eI(e,a?i:null)}}async function eI(e,t){var i,a,r;let n;(await ev(e),t)?(await eb(e,(n=[],(i=t).dataNetwork&&n.push("--dataNetwork",i.dataNetwork),i.wifiMode&&n.push("--wifiMode",i.wifiMode),void 0!==i.wifiBars&&("wifi"===i.dataNetwork||i.wifiMode)&&n.push("--wifiBars",i.wifiBars),i.cellularMode&&n.push("--cellularMode",i.cellularMode),void 0!==i.cellularBars&&(i.cellularMode||(a=i.dataNetwork)&&"hide"!==a&&"wifi"!==a||void 0!==i.operatorName)&&n.push("--cellularBars",i.cellularBars),void 0!==i.operatorName&&n.push("--operatorName",i.operatorName),n)),e_(e)):(r=e,ey.add(eg(r)))}function e_(e){ey.delete(eg(e))}function eg(e){return`${e.platform}:${e.kind}:${e.id}`}async function eC(e){var t;let i=await (t=["status_bar",e.id,"list"],u(e,t,{allowFailure:!0}));if(0!==i.exitCode)throw new n("COMMAND_FAILED","Failed to read simulator status bar overrides",{exitCode:i.exitCode,stdout:i.stdout,stderr:i.stderr});return function(e){let t={};for(let i of e.split("\n").map(e=>e.trim()).filter(e=>e.length>0&&"Current Status Bar Overrides:"!==e&&!/^=+$/.test(e))){let e=/^DataNetworkType:\s+(\d+)$/.exec(i);if(e){let i=Number(e[1]),a=ew[i];if(!a)throw new n("COMMAND_FAILED",`Unsupported simulator data network type: ${i}`);t.dataNetwork=a;continue}let a=/^WiFi Mode:\s+(\d+),\s+WiFi Bars:\s+(\d+)$/.exec(i);if(a){let e=em[Number(a[1])];e&&(t.wifiMode=e),t.wifiBars=a[2];continue}let r=/^Cell Mode:\s+(\d+),\s+Cell Bars:\s+(\d+)$/.exec(i);if(r){let e=Number(r[1]),i=eh[e];if(!i)throw new n("COMMAND_FAILED",`Unsupported simulator cellular mode: ${e}`);t.cellularMode=i,t.cellularBars=r[2];continue}let o=/^Operator Name:\s*(.*)$/.exec(i);if(o){t.operatorName=o[1]??"";continue}}return 0===Object.keys(t).length?null:t}(i.stdout)}async function ev(e){await u(e,["status_bar",e.id,"clear"],void 0)}async function eb(e,t){0!==t.length&&await u(e,["status_bar",e.id,"override",...t],void 0)}function eN(e,t,i){v({level:"warn",phase:`ios_screenshot_status_bar_${t}`,data:{platform:e.platform,deviceKind:e.kind,deviceId:e.id,...ep(i)}})}let eS={ensureBooted:V,prepareStatusBarForScreenshot:eA,captureWithRetry:eM,captureWithRunner:eO,shouldFallbackToRunner:ek};async function eL(e,t,i={}){if(B(e))return void await eO(e,t,i.appBundleId,i.fullscreen,i.runnerOptions);if("simulator"===e.kind)return void await eD(e,t,i);try{await h(["device","screenshot","--device",e.id,t],{action:"capture iOS screenshot",deviceId:e.id});return}catch(t){if(!function(e){if(!(e instanceof n)||"COMMAND_FAILED"!==e.code)return!1;let t=eE(e);return t.includes("unknown option '--device'")||t.includes("unknown subcommand")&&t.includes("screenshot")||t.includes("unrecognized subcommand")&&t.includes("screenshot")}(t))throw t;ex(e,"devicectl_screenshot",t)}await eO(e,t,i.appBundleId,i.fullscreen,i.runnerOptions)}async function eD(e,t,i={}){if("simulator"!==e.kind)throw new n("UNSUPPORTED_OPERATION","Simulator screenshot fallback flow supports only iOS simulators");let a=i.deps??eS;i.skipIosSimulatorBootCheck||await a.ensureBooted(e);let r=async()=>{};if(!0===i.normalizeStatusBar)try{r=await a.prepareStatusBarForScreenshot(e)}catch(t){e$(e,"prepare_failed",t)}try{try{await a.captureWithRetry(e,t);return}catch(o){let r=o;if(i.skipIosSimulatorBootCheck&&function(e){if(!(e instanceof n)||"COMMAND_FAILED"!==e.code)return!1;let t=eE(e);return t.includes("not booted")||t.includes("current state: shutdown")||t.includes("current state is shutdown")||t.includes("current state=shutdown")||t.includes("state: shutdown")||t.includes("state=shutdown")}(o)){await a.ensureBooted(e);try{await a.captureWithRetry(e,t);return}catch(e){r=e}}if(!a.shouldFallbackToRunner(r))throw r;ex(e,"simctl_screenshot",r)}await a.captureWithRunner(e,t,i.appBundleId,i.fullscreen,i.runnerOptions)}finally{await r().catch(t=>e$(e,"restore_failed",t))}}async function eM(e,t){let i=T.fromTimeoutMs(2e4);await E(async({deadline:i})=>{var a;await (a=["io",e.id,"screenshot",t],u(e,a,{timeoutMs:Math.max(1e3,i?.remainingMs()??2e4)}))},{maxAttempts:5,baseDelayMs:1e3,maxDelayMs:5e3,jitter:.2,shouldRetry:e=>ek(e)},{deadline:i,phase:"ios_simulator_screenshot"})}async function eO(e,i,a,r,o){let s=(await w(e,{command:"screenshot",appBundleId:a,fullscreen:r},o)).message;if(!s)throw new n("COMMAND_FAILED","Failed to capture iOS screenshot: runner returned no file path");B(e)?await t.copyFile(s,i):"simulator"===e.kind?await eR(e,s,i):await eP(e,s,i)}async function eP(e,t,i){let a=T.fromTimeoutMs(2e4),r={exitCode:1,stdout:"",stderr:""};for(let n of C)if(0===(r=await o(["devicectl","device","copy","from","--device",e.id,"--source",t,"--destination",i,"--domain-type","appDataContainer","--domain-identifier",n],{allowFailure:!0,timeoutMs:eF(a,2e4,"runner screenshot copy")})).exitCode)return;let s=r.stderr.trim()||r.stdout.trim()||`devicectl exited with code ${r.exitCode}`;throw new n("COMMAND_FAILED",`Failed to capture iOS screenshot: ${s}`)}async function eR(e,i,r){let o=T.fromTimeoutMs(2e4),s="Unable to locate runner container for simulator screenshot";for(let n of C){var l;let d=await (l=["get_app_container",e.id,n,"data"],u(e,l,{allowFailure:!0,timeoutMs:eF(o,2e4,"runner screenshot container lookup")}));if(0!==d.exitCode){let e=d.stderr.trim();e&&(s=e);continue}let c=d.stdout.trim();if(!c){s="simctl get_app_container returned empty output";continue}for(let e of function(e,t){let i=a.resolve(e),r=t.trim();if(!r)return[];let n=[],o=new Set,s=e=>{let t=a.normalize(e);o.has(t)||(o.add(t),n.push(t))},l=r.replace(/^\/+/,""),d=l.replace(/\\/g,"/");if(l&&s(a.join(i,l)),a.isAbsolute(r)&&s(a.normalize(r)),d.startsWith("tmp/"))s(a.join(i,d));else{let e=d.lastIndexOf("/tmp/");if(e>=0){let t=d.slice(e+1);s(a.join(i,t))}}let u=a.basename(r);return u&&s(a.join(i,"tmp",u)),n}(c,i))try{await t.copyFile(e,r);return}catch(e){s=e instanceof Error?e.message:String(e)}}throw new n("COMMAND_FAILED",`Failed to capture iOS screenshot: ${s}`)}function eF(e,t,i){let a=e.remainingMs();if(a>0)return a;throw new n("COMMAND_FAILED",`iOS ${i} timed out after ${t}ms`,{timeoutMs:t,step:i})}function ex(e,t,i){let a=ep(i);v({level:"warn",phase:"ios_screenshot_fallback",data:{platform:e.platform,deviceKind:e.kind,deviceId:e.id,from:t,to:"runner",...a}})}function e$(e,t,i){v({level:"warn",phase:`ios_screenshot_status_bar_${t}`,data:{platform:e.platform,deviceKind:e.kind,deviceId:e.id,...ep(i)}})}function ek(e){if(!(e instanceof n)||"COMMAND_FAILED"!==e.code)return!1;let t=eE(e);return t.includes("timeout waiting for screen surfaces")||t.includes("nsposixerrordomain")&&t.includes("code=60")&&t.includes("screenshot")||t.includes("timed out")&&t.includes("screenshot")}function eE(e){let t=e.details??{},i="string"==typeof t.stdout?t.stdout:"",a="string"==typeof t.stderr?t.stderr:"",r=Array.isArray(t.args)?t.args.filter(e=>"string"==typeof e).join(" "):"";return`${e.message}
2
- ${i}
3
- ${a}
4
- ${r}`.toLowerCase()}let eT={settings:"com.apple.Preferences"},eU=F(),eB=null;function eG(e){return{platform:"ios",deviceId:e.id,variant:e.kind}}function eV(e,t,i){return o(f(e,t),i)}function ej(e){return e.includes("not installed")||e.includes("not found")||e.includes("no such file")}async function eW(e,t){if(B(e))return await ea(t);let i=t.trim();if(i.includes("."))return i;let a=eT[i.toLowerCase()];if(a)return a;let r=eG(e),o=eU.get(r,i);if(o)return o;let s=("simulator"===e.kind?await e8(e):await I(e,"all")).filter(e=>e.name.toLowerCase()===i.toLowerCase()),l=s[0];if(void 0!==l&&1===s.length)return eU.set(r,i,l.bundleId);if(s.length>1)throw new n("INVALID_ARGS",`Multiple apps matched "${t}"`,{matches:s});throw new n("APP_NOT_INSTALLED",`No app found matching "${t}"`)}async function eK(e,t){var i;let r;if(!U(e)||"simulator"!==e.kind)return;let n=(i=t,r=/^([A-Za-z][A-Za-z0-9+.-]*):/.exec(i.trim()),r?.[1]?.toLowerCase());if(!n)return;let o=await e9(e),s=[];for(let e of o)!e.bundleId.startsWith("com.callstack.agentdevice.runner")&&e.path&&(await e6(a.join(e.path,"Info.plist"))).has(n)&&s.push(e);let l=s.filter(e=>"User"===e.applicationType);return 1===l.length?l[0]?.bundleId:l.length>1?void 0:1===s.length?s[0]?.bundleId:void 0}async function eH(e,t,i){let a=i?.launchConsole?.trim(),r=i?.launchArgs;if(a&&(!U(e)||"simulator"!==e.kind))throw new n("UNSUPPORTED_OPERATION",g);if(B(e)){if(r&&r.length>0)throw new n("UNSUPPORTED_OPERATION","--launch-args is not supported on macOS; launch arguments are currently iOS-only.");await er(e,t,i);return}let o=i?.url?.trim();if(o){if(a)throw new n("INVALID_ARGS",l);if(!x(o))throw new n("INVALID_ARGS","open <app> <url> requires a valid URL target");if("simulator"===e.kind){if(r||R(o)){let a=i?.appBundleId??await eW(e,t);await tn(e,a,{...r?{launchArgs:r}:{}})}await ez(e,o,void 0);return}let s=k(i?.appBundleId??await eW(e,t),o);if(!s)throw new n("INVALID_ARGS","Deep link open on iOS devices requires an active app bundle ID. Open the app first, then open the URL.");await tl(e,s,{payloadUrl:o,launchArgs:r});return}let s=t.trim();if(x(s)){if(a)throw new n("INVALID_ARGS",l);if("simulator"===e.kind)return void await ez(e,s,r);let t=k(i?.appBundleId,s);if(!t)throw new n("INVALID_ARGS","Deep link open on iOS devices requires an active app bundle ID. Open the app first, then open the URL.");return void await tl(e,t,{payloadUrl:s,launchArgs:r})}let d=i?.appBundleId??await eW(e,t);"simulator"===e.kind?await tn(e,d,{...a?{launchConsole:a}:{},...r?{launchArgs:r}:{},...i?.terminateRunningApp?{terminateRunningApp:!0}:{}}):await tl(e,d,{launchArgs:r})}async function ez(e,t,i){if(i&&i.length>0)throw new n("INVALID_ARGS","--launch-args is not supported with iOS simulator URL opens (simctl openurl ignores launch args). Launch the app first with --launch-args, then issue the URL open in a separate call.");await V(e),await eV(e,["openurl",e.id,t])}async function eq(e){B(e)||"simulator"!==e.kind||"Booted"!==await j(e)&&await V(e)}async function eJ(e,t){if(B(e))return void await en(e,t);let i=await eW(e,t);if("simulator"===e.kind){await V(e);let t=f(e,["terminate",e.id,i]),a=await o(t,{allowFailure:!0,timeoutMs:15e3});if(0!==a.exitCode){if(a.stderr.toLowerCase().includes("found nothing to terminate"))return;throw new n("COMMAND_FAILED",`xcrun exited with code ${a.exitCode}`,{cmd:"xcrun",args:t,stdout:a.stdout,stderr:a.stderr,exitCode:a.exitCode})}return}await h(["device","process","terminate","--device",e.id,i],{action:"terminate iOS app",deviceId:e.id})}async function eZ(e,i){if(!U(e)||"simulator"!==e.kind)throw new n("UNSUPPORTED_OPERATION","Clearing app state is currently supported only on iOS simulators.");let r=await eW(e,i);await V(e),await eJ(e,r);let o=await eV(e,["get_app_container",e.id,r,"data"],{allowFailure:!0});if(0!==o.exitCode)throw new n("COMMAND_FAILED",`simctl get_app_container failed for ${r}`,{stdout:o.stdout,stderr:o.stderr,exitCode:o.exitCode});let s=o.stdout.trim();if(!s)throw new n("COMMAND_FAILED",`simctl get_app_container returned an empty data container path for ${r}`);let l=await t.readdir(s);return await Promise.all(l.map(e=>t.rm(a.join(s,e),{recursive:!0,force:!0}))),{bundleId:r,containerPath:s}}async function eQ(e,t){return await eU.invalidateWhile(eG(e),async()=>{let i=await eW(e,t);if("simulator"!==e.kind){let t=["devicectl","device","uninstall","app","--device",e.id,i],a=await o(t,{allowFailure:!0,timeoutMs:2e4});if(0!==a.exitCode){let r=String(a.stdout??""),o=String(a.stderr??"");if(!ej(`${r}
5
- ${o}`.toLowerCase()))throw new n("COMMAND_FAILED",`Failed to uninstall iOS app ${i}`,{cmd:"xcrun",args:t,exitCode:a.exitCode,stdout:r,stderr:o,deviceId:e.id,hint:s(r,o)??c})}return{bundleId:i}}await V(e);let a=await eV(e,["uninstall",e.id,i],{allowFailure:!0});if(0!==a.exitCode&&!ej(`${a.stdout}
6
- ${a.stderr}`.toLowerCase()))throw new n("COMMAND_FAILED",`simctl uninstall failed for ${i}`,{stdout:a.stdout,stderr:a.stderr,exitCode:a.exitCode});return{bundleId:i}})}async function eX(e,t,i){let a=await q({kind:"path",path:t},i);try{return await e0(e,a.installablePath),{archivePath:a.archivePath,installablePath:a.installablePath,bundleId:a.bundleId,appName:a.appName,launchTarget:a.bundleId}}finally{await a.cleanup()}}async function eY(e,t,i){return await eU.invalidateWhile(eG(e),async()=>{let{bundleId:a}=await eQ(e,t);return await eX(e,i,{appIdentifierHint:t}),{bundleId:a}})}async function e0(e,t){await eU.invalidateWhile(eG(e),async()=>{"simulator"!==e.kind?await h(["device","install","app","--device",e.id,t],{action:"install iOS app",deviceId:e.id},{timeoutMs:12e4}):(await V(e),await eV(e,["install",e.id,t]))})}async function e1(e){if(B(e))return await eo();G(e,"clipboard"),await V(e);let t=await eV(e,["pbpaste",e.id],{allowFailure:!0});if(0!==t.exitCode)throw new n("COMMAND_FAILED","Failed to read iOS simulator clipboard",{stdout:t.stdout,stderr:t.stderr,exitCode:t.exitCode});return t.stdout.replace(/\r\n/g,"\n").replace(/\n$/,"")}async function e2(e,t){if(B(e))return void await es(t);G(e,"clipboard"),await V(e);let i=await eV(e,["pbcopy",e.id],{allowFailure:!0,stdin:t});if(0!==i.exitCode)throw new n("COMMAND_FAILED","Failed to write iOS simulator clipboard",{stdout:i.stdout,stderr:i.stderr,exitCode:i.exitCode})}async function e4(e,r,n){G(e,"push"),await V(e);let o=await t.mkdtemp(a.join(i.tmpdir(),"agent-device-ios-push-")),s=a.join(o,"payload.apns");try{await t.writeFile(s,`${JSON.stringify(n)}
7
- `,"utf8"),await eV(e,["push",e.id,r,s])}finally{await t.rm(o,{recursive:!0,force:!0})}}async function e3(e,t,i,a,r){if(B(e)){let e=t.toLowerCase();if("appearance"===e)return void await ed(i);if("permission"===e){let e=P(i);if("deny"===e)throw new n("INVALID_ARGS",W("permission"));let t=function(e){let t=e?.trim().toLowerCase();if("accessibility"===t||"screen-recording"===t||"input-monitoring"===t)return t;throw new n("INVALID_ARGS","Unsupported macOS permission target. Use accessibility|screen-recording|input-monitoring.")}(r?.permissionTarget);return await m(e,t)}throw new n("INVALID_ARGS",W(t))}G(e,"settings"),await V(e);let o=t.toLowerCase();switch(o){case"clear-app-state":{if("clear"!==i.toLowerCase())throw new n("INVALID_ARGS","settings clear-app-state only supports clear.");if(!a)throw new n("INVALID_ARGS","settings clear-app-state requires an app id or an active app session.");let t=await eZ(e,a);return{bundleId:t.bundleId,containerPath:t.containerPath,cleared:!0}}case"wifi":{let t=M(i);await eV(e,["status_bar",e.id,"override","--wifiMode",t?"active":"failed"]),e_(e);return}case"airplane":if(M(i))await eV(e,["status_bar",e.id,"override","--dataNetwork","hide","--wifiMode","failed","--wifiBars","0","--cellularMode","failed","--cellularBars","0","--operatorName",""]),e_(e);else await eV(e,["status_bar",e.id,"clear"]),ey.add(eg(e));return;case"location":{if("set"===i.toLowerCase()){let{latitude:t,longitude:i}=K(r);return await eV(e,["location",e.id,"set",`${t},${i}`]),{latitude:t,longitude:i}}let t=M(i);if(!a)throw new n("INVALID_ARGS","location setting requires an active app in session");await eV(e,["privacy",e.id,t?"grant":"revoke","location",a]);return}case"faceid":case"touchid":{let t=te[o],a=function(e,t){let i=e.trim().toLowerCase();if("match"===i)return"match";if("nonmatch"===i)return"nonmatch";if("enroll"===i)return"enroll";if("unenroll"===i)return"unenroll";throw new n("INVALID_ARGS",`Invalid ${t} state: ${e}. Use match|nonmatch|enroll|unenroll.`)}(i,o);await tr(e,a,{settingName:o,label:t.label,modalityAliases:t.modalityAliases});return}case"appearance":{let t=await e7(e,i);await eV(e,["ui",e.id,"appearance",t]);return}case"permission":{var s;if(!a)throw new n("INVALID_ARGS","permission setting requires an active app in session");let t="deny"===(s=P(i))?"revoke":s,o=function(e,t){let i=O(e);if("photos"!==i&&t?.trim())throw new n("INVALID_ARGS",`Permission mode is only supported for photos. Received: ${t}.`);if("camera"===i)return"camera";if("microphone"===i)return"microphone";if("contacts"===i)return"contacts";if("contacts-limited"===i)return"contacts-limited";if("notifications"===i)return"notifications";if("calendar"===i)return"calendar";if("location"===i)return"location";if("location-always"===i)return"location-always";if("media-library"===i)return"media-library";if("motion"===i)return"motion";if("reminders"===i)return"reminders";if("siri"===i)return"siri";if("photos"===i){let e=t?.trim().toLowerCase();if(!e||"full"===e)return"photos";if("limited"===e)return"photos-add";throw new n("INVALID_ARGS",`Invalid photos mode: ${t}. Use full|limited.`)}throw new n("INVALID_ARGS",`Unsupported permission target: ${e}. Use camera|microphone|photos|contacts|contacts-limited|notifications|calendar|location|location-always|media-library|motion|reminders|siri.`)}(r?.permissionTarget,r?.permissionMode);await tt(e,t,o,a);return}default:throw new n("INVALID_ARGS",`Unsupported setting: ${t}`)}}async function e5(e,t){return B(e)?await eu(t):"simulator"===e.kind?y(await e8(e),t):await I(e,t)}async function e8(e){return(await e9(e)).map(e=>({bundleId:e.bundleId,name:e.name}))}async function e9(e){let t=(await eV(e,["listapps",e.id],{allowFailure:!0})).stdout.trim();if(!t)return[];let i=null;if(t.startsWith("{"))try{i=JSON.parse(t)}catch{i=null}if(!i&&t.startsWith("{"))try{let e=await A("plutil",["-convert","json","-o","-","-"],{allowFailure:!0,stdin:t});0===e.exitCode&&e.stdout.trim().startsWith("{")&&(i=JSON.parse(e.stdout))}catch{i=null}return i?Object.entries(i).map(([e,t])=>{let i=function(e){if(e.Path)return e.Path;if(e.Bundle)try{return r(e.Bundle)}catch{return}}(t);return{bundleId:e,name:t.CFBundleDisplayName??t.CFBundleName??e,...i?{path:i}:{},...t.ApplicationType?{applicationType:t.ApplicationType}:{}}}):[]}async function e6(e){let t=await A("plutil",["-convert","json","-o","-",e],{allowFailure:!0});if(0!==t.exitCode)return new Set;try{let e=JSON.parse(t.stdout),i=new Set;for(let t of e.CFBundleURLTypes??[])if(Array.isArray(t.CFBundleURLSchemes))for(let e of t.CFBundleURLSchemes)"string"==typeof e&&e.trim()&&i.add(e.trim().toLowerCase());return i}catch{return new Set}}async function e7(e,t){let i=L(t);if("toggle"!==i)return i;let a=await eV(e,["ui",e.id,"appearance"],{allowFailure:!0});if(0!==a.exitCode)throw new n("COMMAND_FAILED","Failed to read current iOS appearance",{stdout:a.stdout,stderr:a.stderr,exitCode:a.exitCode});let r=function(e,t){let i=/\b(light|dark|unsupported|unknown)\b/i.exec(`${e}
8
- ${t}`);if(!i)return null;let a=i[1]?.toLowerCase();return"dark"===a?"dark":"light"===a?"light":null}(a.stdout,a.stderr);if(!r)throw new n("COMMAND_FAILED","Unable to determine current iOS appearance for toggle",{stdout:a.stdout,stderr:a.stderr});return"dark"===r?"light":"dark"}let te={faceid:{label:"Face ID",modalityAliases:["face"]},touchid:{label:"Touch ID",modalityAliases:["finger","touch"]}};async function tt(e,t,i,a){let r=await ta(e);if(!r.has(i))throw new n("UNSUPPORTED_OPERATION",`iOS simctl privacy does not support service "${i}" on this runtime.`,{deviceId:e.id,appBundleId:a,hint:`Supported services: ${Array.from(r).sort().join(", ")}`});let o=["privacy",e.id,t,i,a],s="notifications"===i;if(!("reset"===t&&s))try{await eV(e,o);return}catch(t){if(!(s&&ti(t)))throw t;throw new n("UNSUPPORTED_OPERATION","iOS simulator does not support setting notifications permission via simctl privacy on this runtime.",{deviceId:e.id,appBundleId:a,hint:"Use reset notifications for reprompt behavior, or toggle notifications manually in Settings."})}try{await eV(e,o);return}catch(e){if(!ti(e))throw e}try{await eV(e,["privacy",e.id,"reset","all",a])}catch(t){throw new n("COMMAND_FAILED","iOS simulator blocked direct notifications reset. Fallback reset-all also failed.",{deviceId:e.id,appBundleId:a,hint:"Use reinstall to force a fresh notifications prompt, or reset simulator content and settings."},t instanceof Error?t:void 0)}}function ti(e){if(!(e instanceof n)||"COMMAND_FAILED"!==e.code)return!1;let t=String(e.details?.stderr??"").toLowerCase();return(t.includes("failed to grant access")||t.includes("failed to revoke access")||t.includes("failed to reset access"))&&t.includes("operation not permitted")}async function ta(t){let i=$(t.simulatorSetPath),a=`${process.env.PATH??""}::${i??""}`;if(eB&&e===a)return eB;let r=await eV(t,["privacy","help"],{allowFailure:!0}),o=function(e){let t=new Set,i=!1;for(let a of e.split("\n")){let e=a.trim();if(!e)continue;if("service"===e){i=!0;continue}if(!i)continue;if(e.startsWith("bundle identifier"))break;let r=/^([a-z-]+)\s+-\s+/.exec(e),n=r?.[1];void 0!==n&&t.add(n)}return t}(`${r.stdout}
9
- ${r.stderr}`);if(0===o.size)throw new n("COMMAND_FAILED","Unable to determine supported simctl privacy services",{stdout:r.stdout,stderr:r.stderr,exitCode:r.exitCode,hint:"Run `xcrun simctl privacy help` manually to verify available services for this runtime."});return eB=o,e=a,o}async function tr(e,t,i){let a=function(e,t,i){let a=i.length>0?i:["face"];switch(t){case"match":return a.flatMap(t=>[["biometric",e,"match",t],["biometric","match",e,t]]);case"nonmatch":return a.flatMap(t=>[["biometric",e,"nonmatch",t],["biometric",e,"nomatch",t],["biometric","nonmatch",e,t],["biometric","nomatch",e,t]]);case"enroll":return[["biometric",e,"enroll","yes"],["biometric",e,"enroll","1"],["biometric","enroll",e,"yes"],["biometric","enroll",e,"1"]];case"unenroll":return[["biometric",e,"enroll","no"],["biometric",e,"enroll","0"],["biometric","enroll",e,"no"],["biometric","enroll",e,"0"]]}}(e.id,t,i.modalityAliases),r=[];for(let t of a){let i=f(e,t),a=await o(i,{allowFailure:!0});if(0===a.exitCode)return;r.push({args:i,stderr:a.stderr,stdout:a.stdout,exitCode:a.exitCode})}let s=D(r);if(r.length>0&&r.every(e=>{var t,i;let a;return t=e.stdout,i=e.stderr,(a=`${t}
10
- ${i}`.toLowerCase()).includes("unrecognized subcommand")||a.includes("unknown subcommand")||a.includes("not supported")||a.includes("unavailable")||a.includes("biometric")&&a.includes("invalid")}))throw new n("UNSUPPORTED_OPERATION",`${i.label} simulation is not supported on this simulator runtime.`,{deviceId:e.id,action:t,setting:i.settingName,attempts:s});throw new n("COMMAND_FAILED",`Failed to simulate ${i.settingName}.`,{deviceId:e.id,action:t,setting:i.settingName,attempts:s})}async function tn(e,t,i){await V(e);let a=0,r=T.fromTimeoutMs(6e4);try{await E(async({deadline:a})=>{var r,s,l,d;let u;if(a?.isExpired())throw new n("COMMAND_FAILED","App launch deadline exceeded",{timeoutMs:6e4});let c=(s=e.id,l=t,d=i,u=["launch"],d?.launchConsole&&u.push("--console-pty"),d?.terminateRunningApp&&u.push("--terminate-running-process"),u.push(s,l),d?.launchArgs&&d.launchArgs.length>0&&u.push(...d.launchArgs),r=u,f(e,r)),p=i?.launchConsole?await to(c,i.launchConsole):await o(c,{allowFailure:!0});if(0!==p.exitCode)throw new n("COMMAND_FAILED",`xcrun exited with code ${p.exitCode}`,{cmd:"xcrun",args:c,stdout:p.stdout,stderr:p.stderr,exitCode:p.exitCode})},{maxAttempts:10,baseDelayMs:1e3,maxDelayMs:5e3,jitter:.2,shouldRetry:e=>!!H(e)&&(a+=1)<3},{deadline:r})}catch(i){if(H(i)){var s;let a=(s=await z(e,t)).installed?!1===s.simulatorCompatible?"ARCH_MISMATCH":"PERSISTENT_LAUNCH_FAIL":"APP_NOT_INSTALLED";i.details={...i.details,hint:function(e){switch(e){case"ARCH_MISMATCH":return"The app binary was not built for the simulator platform. Rebuild with a simulator destination or use a physical device.";case"APP_NOT_INSTALLED":return"The app bundle is not installed on this simulator. Run install before open.";case"PERSISTENT_LAUNCH_FAIL":return"The simulator repeatedly refused to launch the app. Inspect crash logs in Console.app or ~/Library/Logs/DiagnosticReports/ and consider reinstalling the app.";default:return"The simulator failed to launch the app. Retry with --debug and inspect diagnostics log for details."}}(a)}}throw i}}async function to(e,i){await t.mkdir(a.dirname(i),{recursive:!0});try{let t=await o(e,{allowFailure:!0,timeoutMs:25e3});return await ts(i,t.stdout,t.stderr),t}catch(t){let e=(t instanceof n?t:void 0)?.details;if(e?.timeoutMs===25e3){let t="string"==typeof e.stdout?e.stdout:"",a="string"==typeof e.stderr?e.stderr:"";return await ts(i,t,a),v({level:"warn",phase:"ios_simulator_launch_console_capture_timeout",data:{timeoutMs:25e3,logPath:i,stdoutBytes:Buffer.byteLength(t),stderrBytes:Buffer.byteLength(a)}}),{stdout:t,stderr:a,exitCode:0}}throw t}}async function ts(e,i,a){var r,n;await t.writeFile(e,(r=i,n=a,!r||!n||r.endsWith("\n")||r.endsWith("\r")?`${r}${n}`:`${r}
11
- ${n}`),"utf8")}async function tl(e,t,i){let a=["device","process","launch","--device",e.id,t];i?.payloadUrl&&a.push("--payload-url",i.payloadUrl),i?.launchArgs&&i.launchArgs.length>0&&a.push("--",...i.launchArgs),await h(a,{action:"launch iOS app",deviceId:e.id})}export{eJ as closeIosApp,eX as installIosApp,e0 as installIosInstallablePath,e5 as listIosApps,eH as openIosApp,eq as openIosDevice,q as prepareIosInstallArtifact,e4 as pushIosNotification,e1 as readIosClipboardText,eY as reinstallIosApp,eW as resolveIosApp,eK as resolveIosSimulatorDeepLinkBundleId,eL as screenshotIos,e3 as setIosSetting,e2 as writeIosClipboardText};
1
+ import{t as e}from"./rolldown-runtime.js";import{F as t,m as n,p as r}from"./sdk-contracts.js";import{h as i,j as a,p as o,v as s}from"./sdk-android-adb.js";import{St as c,yt as l}from"./device-rotation.js";import{n as u,t as ee}from"./install-source2.js";import{C as te,S as ne,b as d,g as f,h as re,v as ie,x as p}from"./logcat.js";import{d as ae,i as oe}from"./runner-client.js";import{a as m,i as se,l as ce,o as h}from"./tool-provider.js";import{a as le,n as ue}from"./helper.js";import{n as g,r as de}from"./simctl.js";import{$ as fe,G as _,Gt as v,J as pe,K as y,Kt as me,Q as he,U as ge,V as b,Y as x,et as _e,tt as ve}from"./internal/daemon.js";import{a as ye,i as be,n as S,r as C,t as w}from"./setting-state.js";import{i as T,n as xe,t as E}from"./simulator.js";import{promises as D}from"node:fs";import Se from"node:os";import O from"node:path";import{fileURLToPath as Ce}from"node:url";function k(e){if(!(e instanceof t))return{reason:e instanceof Error?e.message:String(e)};let n=e.details??{},r=Array.isArray(n.args)?n.args.filter(e=>typeof e==`string`).join(` `):void 0;return{errorCode:e.code,reason:e.message,timeoutMs:typeof n.timeoutMs==`number`?n.timeoutMs:void 0,exitCode:typeof n.exitCode==`number`?n.exitCode:void 0,stderr:typeof n.stderr==`string`&&n.stderr.trim()?n.stderr:void 0,stdout:typeof n.stdout==`string`&&n.stdout.trim()?n.stdout:void 0,commandArgs:r}}const we=[`--time`,`9:41`,`--dataNetwork`,`wifi`,`--wifiMode`,`active`,`--wifiBars`,`3`,`--batteryState`,`charged`,`--batteryLevel`,`100`],Te={0:`hide`,1:`wifi`,6:`3g`,7:`4g`,8:`lte`,9:`lte-a`,10:`lte+`,11:`5g`,12:`5g+`,13:`5g-uwb`,14:`5g-uc`},Ee={1:`searching`,2:`failed`,3:`active`},De={0:`notSupported`,1:`searching`,2:`failed`,3:`active`};function A(e,t,n){return de(e,t,n)}const j=new Set;async function Oe(e){let t=null,n=!1;if(Ae(e))n=!0;else try{t=await je(e),n=!0}catch(t){L(e,`snapshot_failed`,t)}try{(!n||t)&&await F(e),await I(e,we)}catch(t){L(e,`prepare_failed`,t)}return async()=>{await ke(e,n?t:null)}}async function ke(e,t){if(await F(e),!t){N(e);return}await I(e,Ne(t)),M(e)}function M(e){j.delete(P(e))}function N(e){j.add(P(e))}function Ae(e){return j.has(P(e))}function P(e){return`${e.platform}:${e.kind}:${e.id}`}async function je(e){return Me(i(await A(e,[`status_bar`,e.id,`list`],{allowFailure:!0}),`Failed to read simulator status bar overrides`).stdout)}async function F(e){await A(e,[`status_bar`,e.id,`clear`])}async function I(e,t){t.length!==0&&await A(e,[`status_bar`,e.id,`override`,...t])}function Me(e){let n={},r=e.split(`
2
+ `).map(e=>e.trim()).filter(e=>e.length>0&&e!==`Current Status Bar Overrides:`&&!/^=+$/.test(e));for(let e of r){let r=/^DataNetworkType:\s+(\d+)$/.exec(e);if(r){let e=Number(r[1]),i=Te[e];if(!i)throw new t(`COMMAND_FAILED`,`Unsupported simulator data network type: ${e}`);n.dataNetwork=i;continue}let i=/^WiFi Mode:\s+(\d+),\s+WiFi Bars:\s+(\d+)$/.exec(e);if(i){let e=Ee[Number(i[1])];e&&(n.wifiMode=e),n.wifiBars=i[2];continue}let a=/^Cell Mode:\s+(\d+),\s+Cell Bars:\s+(\d+)$/.exec(e);if(a){let e=Number(a[1]),r=De[e];if(!r)throw new t(`COMMAND_FAILED`,`Unsupported simulator cellular mode: ${e}`);n.cellularMode=r,n.cellularBars=a[2];continue}let o=/^Operator Name:\s*(.*)$/.exec(e);if(o){n.operatorName=o[1]??``;continue}}return Object.keys(n).length===0?null:n}function Ne(e){let t=[];return e.dataNetwork&&t.push(`--dataNetwork`,e.dataNetwork),e.wifiMode&&t.push(`--wifiMode`,e.wifiMode),e.wifiBars!==void 0&&(e.dataNetwork===`wifi`||e.wifiMode)&&t.push(`--wifiBars`,e.wifiBars),e.cellularMode&&t.push(`--cellularMode`,e.cellularMode),e.cellularBars!==void 0&&(e.cellularMode||Pe(e.dataNetwork)||e.operatorName!==void 0)&&t.push(`--cellularBars`,e.cellularBars),e.operatorName!==void 0&&t.push(`--operatorName`,e.operatorName),t}function Pe(e){return!!(e&&e!==`hide`&&e!==`wifi`)}function L(e,t,n){a({level:`warn`,phase:`ios_screenshot_status_bar_${t}`,data:{platform:e.platform,deviceKind:e.kind,deviceId:e.id,...k(n)}})}function R(e,t,n){return de(e,t,n)}const Fe={ensureBooted:E,prepareStatusBarForScreenshot:Oe,captureWithRetry:Re,captureWithRunner:z,shouldFallbackToRunner:Ue};async function Ie(e,t,r={}){if(n(e)){await z(e,t,r.appBundleId,r.fullscreen,r.runnerOptions);return}if(e.kind===`simulator`){await Le(e,t,r);return}try{await _([`device`,`screenshot`,`--device`,e.id,t],{action:`capture iOS screenshot`,deviceId:e.id});return}catch(t){if(!He(t))throw t;V(e,`devicectl_screenshot`,t)}await z(e,t,r.appBundleId,r.fullscreen,r.runnerOptions)}async function Le(e,n,r={}){if(e.kind!==`simulator`)throw new t(`UNSUPPORTED_OPERATION`,`Simulator screenshot fallback flow supports only iOS simulators`);let i=r.deps??Fe;r.skipIosSimulatorBootCheck||await i.ensureBooted(e);let a=async()=>{};if(r.normalizeStatusBar===!0)try{a=await i.prepareStatusBarForScreenshot(e)}catch(t){H(e,`prepare_failed`,t)}try{try{await i.captureWithRetry(e,n);return}catch(t){let a=t;if(r.skipIosSimulatorBootCheck&&We(t)){await i.ensureBooted(e);try{await i.captureWithRetry(e,n);return}catch(e){a=e}}if(!i.shouldFallbackToRunner(a))throw a;V(e,`simctl_screenshot`,a)}await i.captureWithRunner(e,n,r.appBundleId,r.fullscreen,r.runnerOptions)}finally{await a().catch(t=>H(e,`restore_failed`,t))}}async function Re(e,t){let n=f.fromTimeoutMs(_e);await ie(async({deadline:n})=>{await R(e,[`io`,e.id,`screenshot`,t],{timeoutMs:Math.max(1e3,n?.remainingMs()??2e4)})},{maxAttempts:5,baseDelayMs:he,maxDelayMs:fe,jitter:.2,shouldRetry:e=>Ue(e)},{deadline:n,phase:`ios_simulator_screenshot`})}async function z(e,r,i,a,o){let s=(await oe(e,{command:`screenshot`,appBundleId:i,fullscreen:a},o)).message;if(!s)throw new t(`COMMAND_FAILED`,`Failed to capture iOS screenshot: runner returned no file path`);if(n(e)){await D.copyFile(s,r);return}if(e.kind===`simulator`){await Be(e,s,r);return}await ze(e,s,r)}async function ze(e,n,r){let i=f.fromTimeoutMs(x),a={exitCode:1,stdout:``,stderr:``};for(let t of ae)if(a=await h([`devicectl`,`device`,`copy`,`from`,`--device`,e.id,`--source`,n,`--destination`,r,`--domain-type`,`appDataContainer`,`--domain-identifier`,t],{allowFailure:!0,timeoutMs:B(i,x,`runner screenshot copy`)}),a.exitCode===0)return;throw new t(`COMMAND_FAILED`,`Failed to capture iOS screenshot: ${a.stderr.trim()||a.stdout.trim()||`devicectl exited with code ${a.exitCode}`}`)}async function Be(e,n,r){let i=f.fromTimeoutMs(x),a=`Unable to locate runner container for simulator screenshot`;for(let t of ae){let o=await R(e,[`get_app_container`,e.id,t,`data`],{allowFailure:!0,timeoutMs:B(i,x,`runner screenshot container lookup`)});if(o.exitCode!==0){let e=o.stderr.trim();e&&(a=e);continue}let s=o.stdout.trim();if(!s){a=`simctl get_app_container returned empty output`;continue}let c=Ve(s,n);for(let e of c)try{await D.copyFile(e,r);return}catch(e){a=e instanceof Error?e.message:String(e)}}throw new t(`COMMAND_FAILED`,`Failed to capture iOS screenshot: ${a}`)}function B(e,n,r){let i=e.remainingMs();if(i>0)return i;throw new t(`COMMAND_FAILED`,`iOS ${r} timed out after ${n}ms`,{timeoutMs:n,step:r})}function V(e,t,n){let r=k(n);a({level:`warn`,phase:`ios_screenshot_fallback`,data:{platform:e.platform,deviceKind:e.kind,deviceId:e.id,from:t,to:`runner`,...r}})}function H(e,t,n){a({level:`warn`,phase:`ios_screenshot_status_bar_${t}`,data:{platform:e.platform,deviceKind:e.kind,deviceId:e.id,...k(n)}})}function Ve(e,t){let n=O.resolve(e),r=t.trim();if(!r)return[];let i=[],a=new Set,o=e=>{let t=O.normalize(e);a.has(t)||(a.add(t),i.push(t))},s=r.replace(/^\/+/,``),c=s.replace(/\\/g,`/`);if(s&&o(O.join(n,s)),O.isAbsolute(r)&&o(O.normalize(r)),c.startsWith(`tmp/`))o(O.join(n,c));else{let e=c.lastIndexOf(`/tmp/`);if(e>=0){let t=c.slice(e+1);o(O.join(n,t))}}let l=O.basename(r);return l&&o(O.join(n,`tmp`,l)),i}function He(e){if(!(e instanceof t)||e.code!==`COMMAND_FAILED`)return!1;let n=U(e);return n.includes(`unknown option '--device'`)||n.includes(`unknown subcommand`)&&n.includes(`screenshot`)||n.includes(`unrecognized subcommand`)&&n.includes(`screenshot`)}function Ue(e){if(!(e instanceof t)||e.code!==`COMMAND_FAILED`)return!1;let n=U(e);return n.includes(`timeout waiting for screen surfaces`)||n.includes(`nsposixerrordomain`)&&n.includes(`code=60`)&&n.includes(`screenshot`)||n.includes(`timed out`)&&n.includes(`screenshot`)}function We(e){if(!(e instanceof t)||e.code!==`COMMAND_FAILED`)return!1;let n=U(e);return n.includes(`not booted`)||n.includes(`current state: shutdown`)||n.includes(`current state is shutdown`)||n.includes(`current state=shutdown`)||n.includes(`state: shutdown`)||n.includes(`state=shutdown`)}function U(e){let t=e.details??{},n=typeof t.stdout==`string`?t.stdout:``,r=typeof t.stderr==`string`?t.stderr:``,i=Array.isArray(t.args)?t.args.filter(e=>typeof e==`string`).join(` `):``;return`${e.message}\n${n}\n${r}\n${i}`.toLowerCase()}const Ge={settings:`com.apple.systempreferences`},Ke=/^[a-z0-9-]+(?:\.[a-z0-9-]+)+$/,qe={platform:`macos`,deviceId:`host`,variant:`all`},Je=d();function Ye(e){return Ke.test(e)}async function W(e){let n=e.trim(),r=Ge[n.toLowerCase()];if(r)return r;if(Ye(n))return n;let i=Je.get(qe,n);if(i)return i;let a=(await nt(`all`)).filter(e=>e.name.toLowerCase()===n.toLowerCase()),o=a[0];if(o!==void 0&&a.length===1)return Je.set(qe,n,o.bundleId);throw a.length>1?new t(`INVALID_ARGS`,`Multiple apps matched "${e}"`,{matches:a}):new t(`APP_NOT_INSTALLED`,`No app found matching "${e}"`)}async function Xe(e,n,r){let i=r?.url?.trim();if(i){if(!p(i))throw new t(`INVALID_ARGS`,`open <app> <url> requires a valid URL target`);let e=r?.appBundleId??await W(n);await G().openBundle(e,i);return}let a=n.trim();if(p(a)){await G().openTarget(a);return}let o=r?.appBundleId??await W(a);await G().openBundle(o)}async function Ze(e,n){let r=await W(n),i=await ue(r);if(!(!i.running||i.terminated||i.forceTerminated))throw new t(`COMMAND_FAILED`,`Failed to close macOS app ${n}`,{bundleId:r,running:i.running,terminated:i.terminated,forceTerminated:i.forceTerminated})}async function Qe(){return await G().readClipboard()}async function $e(e){await G().writeClipboard(e)}async function et(){return await G().readDarkMode()}async function tt(e){let t=S(e),n=t===`toggle`?!await et():t===`dark`;await G().setDarkMode(n)}async function nt(e){return await G().listApps(e)}function G(){let e=se().macosHost;if(!e)throw new t(`UNSUPPORTED_OPERATION`,`macOS host provider is not available`);return e}function K(e,t){return g(e,t)}function q(e,t,n){return h(K(e,t),n)}function rt(e){return e.includes(`not installed`)||e.includes(`not found`)||e.includes(`no such file`)}const it={settings:`com.apple.Preferences`},J=d();function at(e){return{platform:`ios`,deviceId:e.id,variant:e.kind}}async function Y(e,t){return await J.invalidateWhile(at(e),t)}async function X(e,r){if(n(e))return await W(r);let i=r.trim();if(i.includes(`.`))return i;let a=it[i.toLowerCase()];if(a)return a;let o=at(e),s=J.get(o,i);if(s)return s;let c=(e.kind===`simulator`?await lt(e):await ge(e,`all`)).filter(e=>e.name.toLowerCase()===i.toLowerCase()),l=c[0];if(l!==void 0&&c.length===1)return J.set(o,i,l.bundleId);throw c.length>1?new t(`INVALID_ARGS`,`Multiple apps matched "${r}"`,{matches:c}):new t(`APP_NOT_INSTALLED`,`No app found matching "${r}"`)}async function ot(e,t){if(!r(e)||e.kind!==`simulator`)return;let n=st(t);if(!n)return;let i=await ut(e),a=[];for(let e of i)e.bundleId.startsWith(`com.callstack.agentdevice.runner`)||e.path&&(await ft(O.join(e.path,`Info.plist`))).has(n)&&a.push(e);let o=a.filter(e=>e.applicationType===`User`);if(o.length===1)return o[0]?.bundleId;if(!(o.length>1))return a.length===1?a[0]?.bundleId:void 0}function st(e){return/^([A-Za-z][A-Za-z0-9+.-]*):/.exec(e.trim())?.[1]?.toLowerCase()}async function ct(e,t){return n(e)?await nt(t):e.kind===`simulator`?ce(await lt(e),t):await ge(e,t)}async function lt(e){return(await ut(e)).map(e=>({bundleId:e.bundleId,name:e.name}))}async function ut(e){let t=(await q(e,[`listapps`,e.id],{allowFailure:!0})).stdout.trim();if(!t)return[];let n=null;if(t.startsWith(`{`))try{n=JSON.parse(t)}catch{n=null}if(!n&&t.startsWith(`{`))try{let e=await m(`plutil`,[`-convert`,`json`,`-o`,`-`,`-`],{allowFailure:!0,stdin:t});e.exitCode===0&&e.stdout.trim().startsWith(`{`)&&(n=JSON.parse(e.stdout))}catch{n=null}return n?Object.entries(n).map(([e,t])=>{let n=dt(t);return{bundleId:e,name:t.CFBundleDisplayName??t.CFBundleName??e,...n?{path:n}:{},...t.ApplicationType?{applicationType:t.ApplicationType}:{}}}):[]}function dt(e){if(e.Path)return e.Path;if(e.Bundle)try{return Ce(e.Bundle)}catch{return}}async function ft(e){let t=await m(`plutil`,[`-convert`,`json`,`-o`,`-`,e],{allowFailure:!0});if(t.exitCode!==0)return new Set;try{let e=JSON.parse(t.stdout),n=new Set;for(let t of e.CFBundleURLTypes??[])if(Array.isArray(t.CFBundleURLSchemes))for(let e of t.CFBundleURLSchemes)typeof e==`string`&&e.trim()&&n.add(e.trim().toLowerCase());return n}catch{return new Set}}function pt(e){if(!(e instanceof t)||e.code!==`COMMAND_FAILED`)return!1;let n=e.details??{};if(n.exitCode!==4)return!1;let r=String(n.stderr??``).toLowerCase();return r.includes(`fbsopenapplicationserviceerrordomain`)&&r.includes(`the request to open`)}async function mt(e,t){let n=await h(g(e,[`get_app_container`,e.id,t]),{allowFailure:!0});if(n.exitCode!==0)return{installed:!1};let r=n.stdout.trim();if(!r)return{installed:!1};let i=await m(`plutil`,[`-extract`,`CFBundleExecutable`,`raw`,`-o`,`-`,`${r}/Info.plist`],{allowFailure:!0});if(i.exitCode!==0||!i.stdout.trim())return{installed:!0};let a=await m(`otool`,[`-l`,`${r}/${i.stdout.trim()}`],{allowFailure:!0});if(a.exitCode!==0)return{installed:!0};let o=a.stdout.toLowerCase();return{installed:!0,simulatorCompatible:o.includes(`iossimulator`)||o.includes(`platform 7`)}}function ht(e){return e.installed?e.simulatorCompatible===!1?`ARCH_MISMATCH`:`PERSISTENT_LAUNCH_FAIL`:`APP_NOT_INSTALLED`}function gt(e){switch(e){case`ARCH_MISMATCH`:return`The app binary was not built for the simulator platform. Rebuild with a simulator destination or use a physical device.`;case`APP_NOT_INSTALLED`:return`The app bundle is not installed on this simulator. Run install before open.`;case`PERSISTENT_LAUNCH_FAIL`:return`The simulator repeatedly refused to launch the app. Inspect crash logs in Console.app or ~/Library/Logs/DiagnosticReports/ and consider reinstalling the app.`;default:return`The simulator failed to launch the app. Retry with --debug and inspect diagnostics log for details.`}}const Z=25e3;async function _t(e,i,a){let o=a?.launchConsole?.trim(),s=a?.launchArgs;if(o&&(!r(e)||e.kind!==`simulator`))throw new t(`UNSUPPORTED_OPERATION`,me);if(n(e)){if(s&&s.length>0)throw new t(`UNSUPPORTED_OPERATION`,`--launch-args is not supported on macOS; launch arguments are currently iOS-only.`);await Xe(e,i,a);return}let c=a?.url?.trim();if(c){if(o)throw new t(`INVALID_ARGS`,v);if(!p(c))throw new t(`INVALID_ARGS`,`open <app> <url> requires a valid URL target`);if(e.kind===`simulator`){(s||ne(c))&&await xt(e,a?.appBundleId??await X(e,i),{...s?{launchArgs:s}:{}}),await vt(e,c,void 0);return}let n=te(a?.appBundleId??await X(e,i),c);if(!n)throw new t(`INVALID_ARGS`,`Deep link open on iOS devices requires an active app bundle ID. Open the app first, then open the URL.`);await Q(e,n,{payloadUrl:c,launchArgs:s});return}let l=i.trim();if(p(l)){if(o)throw new t(`INVALID_ARGS`,v);if(e.kind===`simulator`){await vt(e,l,s);return}let n=te(a?.appBundleId,l);if(!n)throw new t(`INVALID_ARGS`,`Deep link open on iOS devices requires an active app bundle ID. Open the app first, then open the URL.`);await Q(e,n,{payloadUrl:l,launchArgs:s});return}let u=a?.appBundleId??await X(e,i);if(e.kind===`simulator`){await xt(e,u,{...o?{launchConsole:o}:{},...s?{launchArgs:s}:{},...a?.terminateRunningApp?{terminateRunningApp:!0}:{}});return}await Q(e,u,{launchArgs:s})}async function vt(e,n,r){if(r&&r.length>0)throw new t(`INVALID_ARGS`,`--launch-args is not supported with iOS simulator URL opens (simctl openurl ignores launch args). Launch the app first with --launch-args, then issue the URL open in a separate call.`);await E(e),await q(e,[`openurl`,e.id,n])}async function yt(e){n(e)||e.kind===`simulator`&&await xe(e)!==`Booted`&&await E(e)}async function bt(e,r){if(n(e)){await Ze(e,r);return}let i=await X(e,r);if(e.kind===`simulator`){await E(e);let n=K(e,[`terminate`,e.id,i]),r=await h(n,{allowFailure:!0,timeoutMs:ve});if(r.exitCode!==0){if(r.stderr.toLowerCase().includes(`found nothing to terminate`))return;throw new t(`COMMAND_FAILED`,`xcrun exited with code ${r.exitCode}`,o(r,{cmd:`xcrun`,args:n}))}return}await _([`device`,`process`,`terminate`,`--device`,e.id,i],{action:`terminate iOS app`,deviceId:e.id})}async function xt(e,n,r){await E(e);let i=0,a=f.fromTimeoutMs(y);try{await ie(async({deadline:i})=>{if(i?.isExpired())throw new t(`COMMAND_FAILED`,`App launch deadline exceeded`,{timeoutMs:y});let a=K(e,St(e.id,n,r)),s=r?.launchConsole?await Ct(a,r.launchConsole):await h(a,{allowFailure:!0});if(s.exitCode!==0)throw new t(`COMMAND_FAILED`,`xcrun exited with code ${s.exitCode}`,o(s,{cmd:`xcrun`,args:a}))},{maxAttempts:10,baseDelayMs:1e3,maxDelayMs:5e3,jitter:.2,shouldRetry(e){return pt(e)?(i+=1,i<3):!1}},{deadline:a})}catch(t){if(pt(t)){let r=t,i=ht(await mt(e,n));r.details={...r.details,hint:gt(i)}}throw t}}function St(e,t,n){let r=[`launch`];return n?.launchConsole&&r.push(`--console-pty`),n?.terminateRunningApp&&r.push(`--terminate-running-process`),r.push(e,t),n?.launchArgs&&n.launchArgs.length>0&&r.push(...n.launchArgs),r}async function Ct(e,n){await D.mkdir(O.dirname(n),{recursive:!0});try{let t=await h(e,{allowFailure:!0,timeoutMs:Z});return await wt(n,t.stdout,t.stderr),t}catch(e){let r=(e instanceof t?e:void 0)?.details;if(r?.timeoutMs===Z){let e=typeof r.stdout==`string`?r.stdout:``,t=typeof r.stderr==`string`?r.stderr:``;return await wt(n,e,t),a({level:`warn`,phase:`ios_simulator_launch_console_capture_timeout`,data:{timeoutMs:Z,logPath:n,stdoutBytes:Buffer.byteLength(e),stderrBytes:Buffer.byteLength(t)}}),{stdout:e,stderr:t,exitCode:0}}throw e}}async function wt(e,t,n){await D.writeFile(e,Tt(t,n),`utf8`)}function Tt(e,t){return!e||!t||e.endsWith(`
3
+ `)||e.endsWith(`\r`)?`${e}${t}`:`${e}\n${t}`}async function Q(e,t,n){let r=[`device`,`process`,`launch`,`--device`,e.id,t];n?.payloadUrl&&r.push(`--payload-url`,n.payloadUrl),n?.launchArgs&&n.launchArgs.length>0&&r.push(`--`,...n.launchArgs),await _(r,{action:`launch iOS app`,deviceId:e.id})}var Et=e({prepareIosInstallArtifact:()=>Dt});async function Dt(e,n){if(e.kind===`url`&&!ee(e.url))throw new t(`INVALID_ARGS`,`iOS install_from_source URL sources are only supported for trusted artifact services such as GitHub Actions and EAS. Use a path source for other hosts.`);let r=await u({source:e,isInstallablePath:(e,t)=>t.isDirectory()&&e.toLowerCase().endsWith(`.app`)||t.isFile()&&e.toLowerCase().endsWith(`.ipa`),installableLabel:`iOS installable (.app or .ipa)`,allowArchiveExtraction:e.kind!==`url`||ee(e.url),signal:n?.signal}),i;try{i=await kt(r.installablePath,n);let e=i,t=await Ot(e.installPath);return{archivePath:r.archivePath??(r.installablePath.toLowerCase().endsWith(`.ipa`)?r.installablePath:void 0),installablePath:e.installPath,bundleId:t.bundleId,appName:t.appName,cleanup:async()=>{await e.cleanup(),await r.cleanup()}}}catch(e){try{await i?.cleanup()}finally{await r.cleanup()}throw e}}async function Ot(e){let t=O.join(e,`Info.plist`),[n,r,i]=await Promise.all([b(t,`CFBundleIdentifier`),b(t,`CFBundleDisplayName`),b(t,`CFBundleName`)]);return{bundleId:n,appName:r??i}}async function kt(e,n){if(!e.toLowerCase().endsWith(`.ipa`))return{installPath:e,cleanup:async()=>{}};let r=await D.mkdtemp(O.join(Se.tmpdir(),`agent-device-ios-ipa-`)),i=async()=>{await D.rm(r,{recursive:!0,force:!0})};try{await s(`unzip`,[`-q`,e,`-d`,r]);let a=O.join(r,`Payload`),o=(await D.readdir(a,{withFileTypes:!0}).catch(()=>{throw new t(`INVALID_ARGS`,`Invalid IPA: missing Payload directory`)})).filter(e=>e.isDirectory()&&e.name.toLowerCase().endsWith(`.app`)).map(e=>({installPath:O.join(a,e.name),bundleName:e.name.replace(/\.app$/i,``)})),c=o[0];if(c!==void 0&&o.length===1)return{installPath:c.installPath,cleanup:i};if(o.length===0)throw new t(`INVALID_ARGS`,`Invalid IPA: expected at least one .app under Payload, found 0`);await At(o);let l=n?.appIdentifierHint?.trim();if(l){let e=jt(o,l);if(e)return{installPath:e.installPath,cleanup:i};throw new t(`INVALID_ARGS`,`Invalid IPA: found ${o.length} .app bundles under Payload and none matched "${l}". Available bundles: ${o.map(Mt).join(`, `)}`)}throw new t(`INVALID_ARGS`,`Invalid IPA: found ${o.length} .app bundles under Payload. Pass an app identifier or bundle name matching one of: ${o.map(Mt).join(`, `)}`)}catch(e){throw await i(),e}}async function At(e){await Promise.all(e.map(async e=>{if(e.bundleId&&e.appName)return;let t=await Ot(e.installPath);e.bundleId=e.bundleId??t.bundleId,e.appName=e.appName??t.appName}))}function jt(e,n){let r=n.toLowerCase(),i=e.filter(e=>e.bundleName.toLowerCase()===r);if(i.length===1)return i[0];if(i.length>1)throw new t(`INVALID_ARGS`,`Invalid IPA: multiple app bundles matched "${n}" by name. Use a bundle id hint instead.`);if(n.includes(`.`)){let t=e.filter(e=>e.bundleId?.toLowerCase()===r);if(t.length===1)return t[0]}}function Mt(e){let t=e.bundleId??e.appName;return t?`${e.bundleName}.app (${t})`:`${e.bundleName}.app`}async function Nt(e,n){return await Y(e,async()=>{let r=await X(e,n);if(e.kind!==`simulator`)return await _([`device`,`uninstall`,`app`,`--device`,e.id,r],{action:`uninstall iOS app ${r}`,deviceId:e.id},{tolerateOutput:(e,t)=>rt(`${e}\n${t}`.toLowerCase())}),{bundleId:r};await E(e);let i=await q(e,[`uninstall`,e.id,r],{allowFailure:!0});if(i.exitCode!==0&&!rt(`${i.stdout}\n${i.stderr}`.toLowerCase()))throw new t(`COMMAND_FAILED`,`simctl uninstall failed for ${r}`,o(i));return{bundleId:r}})}async function Pt(e,t,n){let r=await Dt({kind:`path`,path:t},n);try{return await It(e,r.installablePath),{archivePath:r.archivePath,installablePath:r.installablePath,bundleId:r.bundleId,appName:r.appName,launchTarget:r.bundleId}}finally{await r.cleanup()}}async function Ft(e,t,n){return await Y(e,async()=>{let{bundleId:r}=await Nt(e,t);return await Pt(e,n,{appIdentifierHint:t}),{bundleId:r}})}async function It(e,t){await Y(e,async()=>{if(e.kind!==`simulator`){await _([`device`,`install`,`app`,`--device`,e.id,t],{action:`install iOS app`,deviceId:e.id},{timeoutMs:pe});return}await E(e),await q(e,[`install`,e.id,t])})}async function Lt(e){return n(e)?await Qe():(T(e,`clipboard`),await E(e),i(await q(e,[`pbpaste`,e.id],{allowFailure:!0}),`Failed to read iOS simulator clipboard`).stdout.replace(/\r\n/g,`
4
+ `).replace(/\n$/,``))}async function Rt(e,t){if(n(e)){await $e(t);return}T(e,`clipboard`),await E(e),i(await q(e,[`pbcopy`,e.id],{allowFailure:!0,stdin:t}),`Failed to write iOS simulator clipboard`)}async function zt(e,t,n){T(e,`push`),await E(e);let r=await D.mkdtemp(O.join(Se.tmpdir(),`agent-device-ios-push-`)),i=O.join(r,`payload.apns`);try{await D.writeFile(i,`${JSON.stringify(n)}\n`,`utf8`),await q(e,[`push`,e.id,t,i])}finally{await D.rm(r,{recursive:!0,force:!0})}}let $=null,Bt;async function Vt(e,r,i,a,o){if(n(e)){let e=r.toLowerCase();if(e===`appearance`){await tt(i);return}if(e===`permission`){let e=C(i);if(e===`deny`)throw new t(`INVALID_ARGS`,c(`permission`));return await le(e,Ut(o?.permissionTarget))}throw new t(`INVALID_ARGS`,c(r))}T(e,`settings`),await E(e);let s=r.toLowerCase();switch(s){case`clear-app-state`:{if(i.toLowerCase()!==`clear`)throw new t(`INVALID_ARGS`,`settings clear-app-state only supports clear.`);if(!a)throw new t(`INVALID_ARGS`,`settings clear-app-state requires an app id or an active app session.`);let n=await Ht(e,a);return{bundleId:n.bundleId,containerPath:n.containerPath,cleared:!0}}case`wifi`:{let t=w(i)?`active`:`failed`;await q(e,[`status_bar`,e.id,`override`,`--wifiMode`,t]),M(e);return}case`airplane`:w(i)?(await q(e,[`status_bar`,e.id,`override`,`--dataNetwork`,`hide`,`--wifiMode`,`failed`,`--wifiBars`,`0`,`--cellularMode`,`failed`,`--cellularBars`,`0`,`--operatorName`,``]),M(e)):(await q(e,[`status_bar`,e.id,`clear`]),N(e));return;case`location`:{if(i.toLowerCase()===`set`){let{latitude:t,longitude:n}=l(o);return await q(e,[`location`,e.id,`set`,`${t},${n}`]),{latitude:t,longitude:n}}let n=w(i);if(!a)throw new t(`INVALID_ARGS`,`location setting requires an active app in session`);let r=n?`grant`:`revoke`;await q(e,[`privacy`,e.id,r,`location`,a]);return}case`faceid`:case`touchid`:{let t=s,n=Kt[t];await en(e,$t(i,t),{settingName:t,label:n.label,modalityAliases:n.modalityAliases});return}case`appearance`:{let t=await Wt(e,i);await q(e,[`ui`,e.id,`appearance`,t]);return}case`permission`:if(!a)throw new t(`INVALID_ARGS`,`permission setting requires an active app in session`);await Jt(e,qt(C(i)),Qt(o?.permissionTarget,o?.permissionMode),a);return;default:throw new t(`INVALID_ARGS`,`Unsupported setting: ${r}`)}}async function Ht(e,n){if(!r(e)||e.kind!==`simulator`)throw new t(`UNSUPPORTED_OPERATION`,`Clearing app state is currently supported only on iOS simulators.`);let a=await X(e,n);await E(e),await bt(e,a);let o=i(await q(e,[`get_app_container`,e.id,a,`data`],{allowFailure:!0}),`simctl get_app_container failed for ${a}`).stdout.trim();if(!o)throw new t(`COMMAND_FAILED`,`simctl get_app_container returned an empty data container path for ${a}`);let s=await D.readdir(o);return await Promise.all(s.map(e=>D.rm(O.join(o,e),{recursive:!0,force:!0}))),{bundleId:a,containerPath:o}}function Ut(e){let n=e?.trim().toLowerCase();if(n===`accessibility`||n===`screen-recording`||n===`input-monitoring`)return n;throw new t(`INVALID_ARGS`,`Unsupported macOS permission target. Use accessibility|screen-recording|input-monitoring.`)}async function Wt(e,n){let r=S(n);if(r!==`toggle`)return r;let a=i(await q(e,[`ui`,e.id,`appearance`],{allowFailure:!0}),`Failed to read current iOS appearance`),o=Gt(a.stdout,a.stderr);if(!o)throw new t(`COMMAND_FAILED`,`Unable to determine current iOS appearance for toggle`,{stdout:a.stdout,stderr:a.stderr});return o===`dark`?`light`:`dark`}function Gt(e,t){let n=/\b(light|dark|unsupported|unknown)\b/i.exec(`${e}\n${t}`);if(!n)return null;let r=n[1]?.toLowerCase();return r===`dark`?`dark`:r===`light`?`light`:null}const Kt={faceid:{label:`Face ID`,modalityAliases:[`face`]},touchid:{label:`Touch ID`,modalityAliases:[`finger`,`touch`]}};function qt(e){return e===`deny`?`revoke`:e}async function Jt(e,n,r,i){let a=await Xt(e);if(!a.has(r))throw new t(`UNSUPPORTED_OPERATION`,`iOS simctl privacy does not support service "${r}" on this runtime.`,{deviceId:e.id,appBundleId:i,hint:`Supported services: ${Array.from(a).sort().join(`, `)}`});let o=[`privacy`,e.id,n,r,i],s=r===`notifications`;if(!(n===`reset`&&s))try{await q(e,o);return}catch(n){throw s&&Yt(n)?new t(`UNSUPPORTED_OPERATION`,`iOS simulator does not support setting notifications permission via simctl privacy on this runtime.`,{deviceId:e.id,appBundleId:i,hint:`Use reset notifications for reprompt behavior, or toggle notifications manually in Settings.`}):n}try{await q(e,o);return}catch(e){if(!Yt(e))throw e}try{await q(e,[`privacy`,e.id,`reset`,`all`,i])}catch(n){throw new t(`COMMAND_FAILED`,`iOS simulator blocked direct notifications reset. Fallback reset-all also failed.`,{deviceId:e.id,appBundleId:i,hint:`Use reinstall to force a fresh notifications prompt, or reset simulator content and settings.`},n instanceof Error?n:void 0)}}function Yt(e){if(!(e instanceof t)||e.code!==`COMMAND_FAILED`)return!1;let n=String(e.details?.stderr??``).toLowerCase();return(n.includes(`failed to grant access`)||n.includes(`failed to revoke access`)||n.includes(`failed to reset access`))&&n.includes(`operation not permitted`)}async function Xt(e){let n=re(e.simulatorSetPath),r=`${process.env.PATH??``}::${n??``}`;if($&&Bt===r)return $;let i=await q(e,[`privacy`,`help`],{allowFailure:!0}),a=Zt(`${i.stdout}\n${i.stderr}`);if(a.size===0)throw new t(`COMMAND_FAILED`,`Unable to determine supported simctl privacy services`,{stdout:i.stdout,stderr:i.stderr,exitCode:i.exitCode,hint:"Run `xcrun simctl privacy help` manually to verify available services for this runtime."});return $=a,Bt=r,a}function Zt(e){let t=new Set,n=!1;for(let r of e.split(`
5
+ `)){let e=r.trim();if(!e)continue;if(e===`service`){n=!0;continue}if(!n)continue;if(e.startsWith(`bundle identifier`))break;let i=/^([a-z-]+)\s+-\s+/.exec(e)?.[1];i!==void 0&&t.add(i)}return t}function Qt(e,n){let r=be(e);if(r!==`photos`&&n?.trim())throw new t(`INVALID_ARGS`,`Permission mode is only supported for photos. Received: ${n}.`);if(r===`camera`)return`camera`;if(r===`microphone`)return`microphone`;if(r===`contacts`)return`contacts`;if(r===`contacts-limited`)return`contacts-limited`;if(r===`notifications`)return`notifications`;if(r===`calendar`)return`calendar`;if(r===`location`)return`location`;if(r===`location-always`)return`location-always`;if(r===`media-library`)return`media-library`;if(r===`motion`)return`motion`;if(r===`reminders`)return`reminders`;if(r===`siri`)return`siri`;if(r===`photos`){let e=n?.trim().toLowerCase();if(!e||e===`full`)return`photos`;if(e===`limited`)return`photos-add`;throw new t(`INVALID_ARGS`,`Invalid photos mode: ${n}. Use full|limited.`)}throw new t(`INVALID_ARGS`,`Unsupported permission target: ${e}. Use camera|microphone|photos|contacts|contacts-limited|notifications|calendar|location|location-always|media-library|motion|reminders|siri.`)}function $t(e,n){let r=e.trim().toLowerCase();if(r===`match`)return`match`;if(r===`nonmatch`)return`nonmatch`;if(r===`enroll`)return`enroll`;if(r===`unenroll`)return`unenroll`;throw new t(`INVALID_ARGS`,`Invalid ${n} state: ${e}. Use match|nonmatch|enroll|unenroll.`)}async function en(e,n,r){let i=tn(e.id,n,r.modalityAliases),a=[];for(let t of i){let n=K(e,t),r=await h(n,{allowFailure:!0});if(r.exitCode===0)return;a.push({args:n,stderr:r.stderr,stdout:r.stdout,exitCode:r.exitCode})}let o=ye(a);throw a.length>0&&a.every(e=>nn(e.stdout,e.stderr))?new t(`UNSUPPORTED_OPERATION`,`${r.label} simulation is not supported on this simulator runtime.`,{deviceId:e.id,action:n,setting:r.settingName,attempts:o}):new t(`COMMAND_FAILED`,`Failed to simulate ${r.settingName}.`,{deviceId:e.id,action:n,setting:r.settingName,attempts:o})}function tn(e,t,n){let r=n.length>0?n:[`face`];switch(t){case`match`:return r.flatMap(t=>[[`biometric`,e,`match`,t],[`biometric`,`match`,e,t]]);case`nonmatch`:return r.flatMap(t=>[[`biometric`,e,`nonmatch`,t],[`biometric`,e,`nomatch`,t],[`biometric`,`nonmatch`,e,t],[`biometric`,`nomatch`,e,t]]);case`enroll`:return[[`biometric`,e,`enroll`,`yes`],[`biometric`,e,`enroll`,`1`],[`biometric`,`enroll`,e,`yes`],[`biometric`,`enroll`,e,`1`]];case`unenroll`:return[[`biometric`,e,`enroll`,`no`],[`biometric`,e,`enroll`,`0`],[`biometric`,`enroll`,e,`no`],[`biometric`,`enroll`,e,`0`]]}}function nn(e,t){let n=`${e}\n${t}`.toLowerCase();return n.includes(`unrecognized subcommand`)||n.includes(`unknown subcommand`)||n.includes(`not supported`)||n.includes(`unavailable`)||n.includes(`biometric`)&&n.includes(`invalid`)}var rn=e({installIosApp:()=>Pt,installIosInstallablePath:()=>It,listIosApps:()=>ct,pushIosNotification:()=>zt,reinstallIosApp:()=>Ft,resolveIosApp:()=>X,resolveIosSimulatorDeepLinkBundleId:()=>ot});export{Et as a,yt as c,Rt as i,ct as l,Vt as n,bt as o,Lt as r,_t as s,rn as t,Ie as u};
@@ -1,3 +1,4 @@
1
- export declare function resolveAndroidArchivePackageName(archivePath: string): Promise<string | undefined>;
2
-
3
- export { }
1
+ //#region src/platforms/android/manifest.d.ts
2
+ declare function resolveAndroidArchivePackageName(archivePath: string): Promise<string | undefined>;
3
+ //#endregion
4
+ export { resolveAndroidArchivePackageName };
@@ -1 +1 @@
1
- export{resolveAndroidArchivePackageName}from"./3006.js";
1
+ import{t as e}from"./manifest.js";export{e as resolveAndroidArchivePackageName};
@@ -1 +1 @@
1
- import{isIosFamily as e}from"./6849.js";import{startMacOsAudioProbeProcess as t}from"./9722.js";let o={platform:"host-system-audio",source:"system-audio",backend:"macos-screencapturekit",sourceCount:1,start:t,notes:function(t){let o=e(t)?"iOS simulator":"android"===t.platform?"Android emulator":"macOS session";return[`Audio probe samples host system audio through ScreenCaptureKit for this ${o}; it is not app-instrumented audio.`,"Screen Recording permission is required for host system audio capture.","Other audible host apps can contribute to the measured buckets."]}};export{o as macOsScreenCaptureKitAudioProbeBackend};
1
+ import{p as e}from"./sdk-contracts.js";import{c as t}from"./helper.js";const n={platform:`host-system-audio`,source:`system-audio`,backend:`macos-screencapturekit`,sourceCount:1,start:t,notes:r};function r(t){return[`Audio probe samples host system audio through ScreenCaptureKit for this ${e(t)?`iOS simulator`:t.platform===`android`?`Android emulator`:`macOS session`}; it is not app-instrumented audio.`,`Screen Recording permission is required for host system audio capture.`,`Other audible host apps can contribute to the measured buckets.`]}export{n as macOsScreenCaptureKitAudioProbeBackend};
@@ -1,177 +1,2 @@
1
- declare type BatchFlags = Record<string, unknown> & {
2
- batchOnError?: 'stop';
3
- batchMaxSteps?: number;
4
- batchSteps?: DaemonBatchStep[];
5
- };
6
-
7
- declare type BatchInvoke = (req: BatchRequest) => Promise<DaemonResponse>;
8
-
9
- declare type BatchRequest = Omit<DaemonRequest, 'flags'> & {
10
- flags?: BatchFlags | Record<string, unknown>;
11
- };
12
-
13
- declare type BatchRunResponse = {
14
- ok: true;
15
- data: BatchRunResult;
16
- } | Extract<DaemonResponse, {
17
- ok: false;
18
- }>;
19
-
20
- declare type BatchRunResult = Record<string, unknown> & {
21
- total: number;
22
- executed: number;
23
- totalDurationMs: number;
24
- results: BatchStepResult[];
25
- };
26
-
27
- declare type BatchStepResult = {
28
- step: number;
29
- command: string;
30
- ok: true;
31
- data: Record<string, unknown>;
32
- durationMs: number;
33
- };
34
-
35
- declare const DAEMON_LOCK_POLICIES: readonly ['reject', 'strip'];
36
-
37
- declare type DaemonArtifact = {
38
- field: string;
39
- artifactId?: string;
40
- fileName?: string;
41
- localPath?: string;
42
- path?: string;
43
- };
44
-
45
- declare type DaemonBatchStep = {
46
- command: string;
47
- positionals?: string[];
48
- flags?: Record<string, unknown>;
49
- runtime?: DaemonRequest['runtime'];
50
- };
51
-
52
- declare type DaemonError = {
53
- code: string;
54
- message: string;
55
- hint?: string;
56
- diagnosticId?: string;
57
- logPath?: string;
58
- details?: Record<string, unknown>;
59
- /**
60
- * Machine-readable typed-error signals (Phase 2). Additive: present only when
61
- * derivable, so the default error wire shape is unchanged.
62
- *
63
- * `retriable` flags a transient failure an agent should retry (vs. a
64
- * deterministic one where a retry is wasted). `supportedOn` lists the platform
65
- * families that DO support the command (derived from the capability matrix),
66
- * surfaced on platform-mismatch errors so an agent self-corrects without a
67
- * wasted round-trip.
68
- */
69
- retriable?: boolean;
70
- supportedOn?: string;
71
- };
72
-
73
- declare type DaemonInstallSource = {
74
- kind: 'url';
75
- url: string;
76
- headers?: Record<string, string>;
77
- } | {
78
- kind: 'path';
79
- path: string;
80
- } | ({
81
- kind: 'github-actions-artifact';
82
- owner: string;
83
- repo: string;
84
- } & ({
85
- artifactId: number;
86
- } | {
87
- runId: number;
88
- artifactName: string;
89
- } | {
90
- artifactName: string;
91
- }));
92
-
93
- declare type DaemonLockPolicy = (typeof DAEMON_LOCK_POLICIES)[number];
94
-
95
- declare type DaemonRequest = {
96
- token?: string;
97
- session?: string;
98
- command: string;
99
- positionals: string[];
100
- flags?: Record<string, unknown>;
101
- runtime?: SessionRuntimeHints;
102
- meta?: DaemonRequestMeta;
103
- };
104
-
105
- declare type DaemonRequestMeta = {
106
- requestId?: string;
107
- debug?: boolean;
108
- includeCost?: boolean;
109
- responseLevel?: ResponseLevel;
110
- cwd?: string;
111
- sessionExplicit?: boolean;
112
- tenantId?: string;
113
- runId?: string;
114
- leaseId?: string;
115
- leaseTtlMs?: number;
116
- leaseBackend?: LeaseBackend;
117
- leaseProvider?: string;
118
- deviceKey?: string;
119
- clientId?: string;
120
- sessionIsolation?: SessionIsolationMode;
121
- uploadedArtifactId?: string;
122
- clientArtifactPaths?: Record<string, string>;
123
- installSource?: DaemonInstallSource;
124
- retainMaterializedPaths?: boolean;
125
- materializedPathRetentionMs?: number;
126
- materializationId?: string;
127
- lockPolicy?: DaemonLockPolicy;
128
- lockPlatform?: PlatformSelector;
129
- requestProgress?: 'replay-test' | 'command';
130
- };
131
-
132
- declare type DaemonResponse = {
133
- ok: true;
134
- data?: DaemonResponseData;
135
- } | {
136
- ok: false;
137
- error: DaemonError;
138
- };
139
-
140
- declare type DaemonResponseData = Record<string, unknown> & {
141
- artifacts?: DaemonArtifact[];
142
- cost?: ResponseCost;
143
- };
144
-
145
- declare const LEASE_BACKENDS: readonly ['ios-simulator', 'ios-instance', 'android-instance'];
146
-
147
- declare type LeaseBackend = (typeof LEASE_BACKENDS)[number];
148
-
149
- declare const PLATFORM_SELECTORS: readonly ["apple", "android", "linux", "web", "ios", "macos"];
150
-
151
- declare type PlatformSelector = (typeof PLATFORM_SELECTORS)[number];
152
-
153
- declare const RESPONSE_LEVELS: readonly ['digest', 'default', 'full'];
154
-
155
- declare type ResponseCost = {
156
- wallClockMs: number;
157
- runnerRoundTrips: number;
158
- nodeCount?: number;
159
- };
160
-
161
- declare type ResponseLevel = (typeof RESPONSE_LEVELS)[number];
162
-
163
- export declare function runBatch(req: BatchRequest, sessionName: string, invoke: BatchInvoke): Promise<BatchRunResponse>;
164
-
165
- declare const SESSION_ISOLATION_MODES: readonly ['none', 'tenant'];
166
-
167
- declare type SessionIsolationMode = (typeof SESSION_ISOLATION_MODES)[number];
168
-
169
- declare type SessionRuntimeHints = {
170
- platform?: 'ios' | 'android';
171
- metroHost?: string;
172
- metroPort?: number;
173
- bundleUrl?: string;
174
- launchUrl?: string;
175
- };
176
-
177
- export { }
1
+ import { n as runBatch } from "./sdk-batch-runner.js";
2
+ export { runBatch };
package/dist/src/batch.js CHANGED
@@ -1 +1 @@
1
- export{runBatch}from"./6918.js";
1
+ import{n as e}from"./sdk-batch-runner.js";export{e as runBatch};