rnxsim 0.1.314 → 0.1.316

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 (158) hide show
  1. package/cli/commands/control.ts +20 -3
  2. package/cli/commands/flow.ts +23 -11
  3. package/cli/commands/inspect.ts +51 -3
  4. package/dist-cli/bin.js +5 -5
  5. package/dist-cli/chunks/{agent-7YBDCYMA.js → agent-ILQPZETA.js} +2 -2
  6. package/dist-cli/chunks/{agent-wrapper-2GHFBHCR.js → agent-wrapper-FBWOEHCY.js} +2 -2
  7. package/dist-cli/chunks/{app-fonts-RSNVPQSU.js → app-fonts-6UBVGCEO.js} +2 -2
  8. package/dist-cli/chunks/{assert-XCMX3XJX.js → assert-KYLN3EAI.js} +2 -2
  9. package/dist-cli/chunks/{auth-B442HRAX.js → auth-5AUZXTFY.js} +2 -2
  10. package/dist-cli/chunks/{beta-XJ55JK3M.js → beta-J63PH5OY.js} +2 -2
  11. package/dist-cli/chunks/{camera-UGYSSLIK.js → camera-INL3BDHS.js} +2 -2
  12. package/dist-cli/chunks/{chunk-X6H76EKP.js → chunk-2BJVDP7R.js} +2 -2
  13. package/dist-cli/chunks/{chunk-JZS3Q37N.js → chunk-3S3NDSH4.js} +2 -2
  14. package/dist-cli/chunks/{chunk-AMG5E6CC.js → chunk-4CYHLDEM.js} +1 -1
  15. package/dist-cli/chunks/{chunk-J62KM5TB.js → chunk-4EZXTMIO.js} +2 -2
  16. package/dist-cli/chunks/{chunk-TAX4UT2N.js → chunk-5W4XMFMD.js} +1 -1
  17. package/dist-cli/chunks/{chunk-7ZC35MOU.js → chunk-6I4A7AIN.js} +1 -1
  18. package/dist-cli/chunks/{chunk-7OOPFSQS.js → chunk-6KBBHTEX.js} +2 -2
  19. package/dist-cli/chunks/{chunk-MCWPL644.js → chunk-ABWLCBHL.js} +2 -2
  20. package/dist-cli/chunks/{chunk-RZKU2K3J.js → chunk-AK3GDHDT.js} +2 -2
  21. package/dist-cli/chunks/{chunk-277AEQZX.js → chunk-AKHNXYSL.js} +2 -2
  22. package/dist-cli/chunks/{chunk-ZBSJO4NB.js → chunk-B34FLQCQ.js} +1 -1
  23. package/dist-cli/chunks/{chunk-IZAHPAN6.js → chunk-BFVPTBI4.js} +1 -1
  24. package/dist-cli/chunks/{chunk-32WOTSTR.js → chunk-BJW2TLIK.js} +3 -3
  25. package/dist-cli/chunks/{chunk-5L7ELDQL.js → chunk-BPBFNFGG.js} +2 -2
  26. package/dist-cli/chunks/{chunk-FXUAC6D5.js → chunk-BZAED6TK.js} +1 -1
  27. package/dist-cli/chunks/{chunk-EG32ML36.js → chunk-CBTHKMXT.js} +2 -2
  28. package/dist-cli/chunks/{chunk-WGGRJDRE.js → chunk-CUN5GSJM.js} +1 -1
  29. package/dist-cli/chunks/{chunk-QGRI2Z4M.js → chunk-D4ECXYED.js} +2 -2
  30. package/dist-cli/chunks/{chunk-KR4JON7D.js → chunk-D5U7M6CS.js} +1 -1
  31. package/dist-cli/chunks/{chunk-TUOFAWXT.js → chunk-FBUYTMEM.js} +1 -1
  32. package/dist-cli/chunks/{chunk-46ZOLOYA.js → chunk-HKD3XX6U.js} +2 -2
  33. package/dist-cli/chunks/{chunk-RWZY5427.js → chunk-HOGMZTXK.js} +2 -2
  34. package/dist-cli/chunks/{chunk-XULEACM4.js → chunk-J57S6THQ.js} +2 -2
  35. package/dist-cli/chunks/{chunk-MJYK3N2I.js → chunk-J6ZW2E5Q.js} +2 -2
  36. package/dist-cli/chunks/{chunk-VUKKYPZN.js → chunk-K7A3VZKE.js} +2 -2
  37. package/dist-cli/chunks/{chunk-VC7V76U3.js → chunk-KHDXKC7O.js} +1 -1
  38. package/dist-cli/chunks/{chunk-KWCYKQIQ.js → chunk-NOYR57HW.js} +1 -1
  39. package/dist-cli/chunks/{chunk-QLXXE7GE.js → chunk-OAUWIZ7B.js} +1 -1
  40. package/dist-cli/chunks/{chunk-GQSL4USA.js → chunk-OSDNJBHO.js} +2 -2
  41. package/dist-cli/chunks/{chunk-UHZLOHGP.js → chunk-P2EIPQFW.js} +1 -1
  42. package/dist-cli/chunks/{chunk-3S753SNQ.js → chunk-PMBPC32N.js} +2 -2
  43. package/dist-cli/chunks/{chunk-HAXW27SS.js → chunk-PVL6TOGJ.js} +2 -2
  44. package/dist-cli/chunks/{chunk-XLZ5FNRT.js → chunk-QXZUTSYV.js} +2 -2
  45. package/dist-cli/chunks/{chunk-O6TRIZNS.js → chunk-RWDPBV6A.js} +2 -2
  46. package/dist-cli/chunks/{chunk-JEMCD5E4.js → chunk-SWJXWDAF.js} +1 -1
  47. package/dist-cli/chunks/{chunk-B57XUKY3.js → chunk-T4BAXNNP.js} +2 -2
  48. package/dist-cli/chunks/{chunk-PG5RZCTN.js → chunk-U523FCYZ.js} +2 -2
  49. package/dist-cli/chunks/{chunk-EAC34EQS.js → chunk-UIGPENDJ.js} +1 -1
  50. package/dist-cli/chunks/{chunk-7SV3RPRW.js → chunk-UJD4QTX3.js} +2 -2
  51. package/dist-cli/chunks/{chunk-SBV4IK4H.js → chunk-UWWINDYC.js} +1 -1
  52. package/dist-cli/chunks/{chunk-SGMVFFMK.js → chunk-V3DA77A6.js} +1 -1
  53. package/dist-cli/chunks/{chunk-YFSDM7AX.js → chunk-VQXFEXNH.js} +2 -2
  54. package/dist-cli/chunks/{chunk-QOJJJWJE.js → chunk-VSBUWTVL.js} +131 -131
  55. package/dist-cli/chunks/{chunk-2JNSK774.js → chunk-VV4TEHX7.js} +2 -2
  56. package/dist-cli/chunks/{chunk-PFQTUKQ4.js → chunk-WGW2A62I.js} +23 -23
  57. package/dist-cli/chunks/{chunk-D2FNUWAB.js → chunk-WO4W67CV.js} +5 -5
  58. package/dist-cli/chunks/{chunk-E5T4XSJ3.js → chunk-XADARHFI.js} +2 -2
  59. package/dist-cli/chunks/{chunk-P7XL2E73.js → chunk-XYZYRG4O.js} +3 -3
  60. package/dist-cli/chunks/{chunk-APWNH3A4.js → chunk-Y3FEGWJ6.js} +1 -1
  61. package/dist-cli/chunks/{chunk-C2NL26TD.js → chunk-YGZJWH2Q.js} +1 -1
  62. package/dist-cli/chunks/{chunk-VQVMLW4U.js → chunk-ZRFG75QL.js} +1 -1
  63. package/dist-cli/chunks/{chunk-YWI3UEVX.js → chunk-ZTWOF243.js} +2 -2
  64. package/dist-cli/chunks/{cleanup-EYLGCA6Z.js → cleanup-X6FK675T.js} +2 -2
  65. package/dist-cli/chunks/cli-version-6B4DYWVM.js +4 -0
  66. package/dist-cli/chunks/{compat-TLJYHB4E.js → compat-LBTG3Z3H.js} +2 -2
  67. package/dist-cli/chunks/{config-4JWUOEXK.js → config-QI7SSUP5.js} +2 -2
  68. package/dist-cli/chunks/{control-HPAOYF4N.js → control-RLBAGXOX.js} +2 -2
  69. package/dist-cli/chunks/daemon-B6KKISRP.js +4 -0
  70. package/dist-cli/chunks/{debug-4BKXF6KI.js → debug-6TAEJ7GA.js} +3 -3
  71. package/dist-cli/chunks/{desktop-ZQ6ZD2S6.js → desktop-3M7KSOFZ.js} +3 -3
  72. package/dist-cli/chunks/{detox-WNPASSS3.js → detox-433UDKEA.js} +2 -2
  73. package/dist-cli/chunks/{device-BXLXVG3V.js → device-ULYQASXP.js} +2 -2
  74. package/dist-cli/chunks/{diagnose-3QX7W5RW.js → diagnose-JAR7WZOI.js} +2 -2
  75. package/dist-cli/chunks/{disk-cleanup-KSWKI7WB.js → disk-cleanup-S2JSTRYU.js} +2 -2
  76. package/dist-cli/chunks/drivers-PGUH2YO6.js +4 -0
  77. package/dist-cli/chunks/{film-GDMR33VO.js → film-RT5C6JLU.js} +3 -3
  78. package/dist-cli/chunks/flow-RZKTARAU.js +4 -0
  79. package/dist-cli/chunks/help-SNFCDNKB.js +4 -0
  80. package/dist-cli/chunks/{hidden-runtime-alias-S2GTDX3T.js → hidden-runtime-alias-VF4CWKWJ.js} +2 -2
  81. package/dist-cli/chunks/{home-paths-QRCDLTTV.js → home-paths-WIUCKYP5.js} +2 -2
  82. package/dist-cli/chunks/inspect-NZQBU45Y.js +4 -0
  83. package/dist-cli/chunks/install-desktop-NEDPFLVG.js +4 -0
  84. package/dist-cli/chunks/{login-IJAPUZHI.js → login-VSEVRTEC.js} +4 -4
  85. package/dist-cli/chunks/{logout-QMXDFU2X.js → logout-R3P3CCBX.js} +2 -2
  86. package/dist-cli/chunks/{maestro-ZXU3YCVX.js → maestro-4QTHFBIU.js} +3 -3
  87. package/dist-cli/chunks/{maestro-generate-PYB5QY7K.js → maestro-generate-WKVRX6UW.js} +3 -3
  88. package/dist-cli/chunks/{mode-WGUCL5FZ.js → mode-OS77UC5H.js} +2 -2
  89. package/dist-cli/chunks/{optional-demo-registry-WH2O6H36.js → optional-demo-registry-KGQBFKET.js} +2 -2
  90. package/dist-cli/chunks/{perf-TOD3UFAH.js → perf-GZCPKCVI.js} +2 -2
  91. package/dist-cli/chunks/{permissions-I5BRJGTB.js → permissions-FISUG42S.js} +2 -2
  92. package/dist-cli/chunks/{record-ZYL2FYSK.js → record-QQ2OUWC6.js} +3 -3
  93. package/dist-cli/chunks/{report-issue-TAI6DYZO.js → report-issue-7NJ73U63.js} +2 -2
  94. package/dist-cli/chunks/reset-A5QZVHYZ.js +4 -0
  95. package/dist-cli/chunks/runtime-5VU3DJPZ.js +4 -0
  96. package/dist-cli/chunks/{screenshot-command-7ANLODZY.js → screenshot-command-Q62EW4KN.js} +3 -3
  97. package/dist-cli/chunks/{screenshot-layers-A7FYXSVU.js → screenshot-layers-3BEAAGYL.js} +2 -2
  98. package/dist-cli/chunks/{screenshots-capture-WT2ZY6CB.js → screenshots-capture-JV6F6HUN.js} +2 -2
  99. package/dist-cli/chunks/{serve-TG5WKA4V.js → serve-XAWQZ6WL.js} +2 -2
  100. package/dist-cli/chunks/{setup-PCWLD22V.js → setup-RKFNOXC4.js} +2 -2
  101. package/dist-cli/chunks/{skills-27ZHWCQS.js → skills-VW3AZ3GF.js} +2 -2
  102. package/dist-cli/chunks/{state-ZQVY46ZO.js → state-5PSQAXT5.js} +2 -2
  103. package/dist-cli/chunks/{storage-OYC57C4X.js → storage-ERGWLRMH.js} +2 -2
  104. package/dist-cli/chunks/store-HMXFP3QX.js +4 -0
  105. package/dist-cli/chunks/telemetry-WG3FVU67.js +4 -0
  106. package/dist-cli/chunks/{timeline-RAJJFQT6.js → timeline-2QK6DQPO.js} +2 -2
  107. package/dist-cli/chunks/{upgrade-OEFNZRIP.js → upgrade-R4ZYLZF3.js} +2 -2
  108. package/dist-cli/chunks/upload-BLDJ2HNG.js +4 -0
  109. package/dist-cli/chunks/{version-NIXTY6PL.js → version-R5B2AL7G.js} +2 -2
  110. package/dist-cli/chunks/{web-XBUTBVGR.js → web-TIUDT34D.js} +2 -2
  111. package/dist-cli/chunks/{what-happened-YNHRFUDX.js → what-happened-PTEBTEQM.js} +2 -2
  112. package/dist-lib/agent-daemon-client.cjs +1 -1
  113. package/dist-lib/agent-events.cjs +1 -1
  114. package/dist-lib/agent-identity.cjs +1 -1
  115. package/dist-lib/agent-sessions.cjs +1 -1
  116. package/dist-lib/attached-projects.cjs +1 -1
  117. package/dist-lib/auth/shared-session.cjs +1 -1
  118. package/dist-lib/backend-origin.cjs +1 -1
  119. package/dist-lib/beta.cjs +1 -1
  120. package/dist-lib/beta.mjs +1 -1
  121. package/dist-lib/bridge-constants.cjs +1 -1
  122. package/dist-lib/bridge-contract.cjs +1 -1
  123. package/dist-lib/cli-constants.cjs +1 -1
  124. package/dist-lib/config.cjs +1 -1
  125. package/dist-lib/detox/index.cjs +1 -1
  126. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  127. package/dist-lib/home-paths.cjs +1 -1
  128. package/dist-lib/host/bridge-host.cjs +1 -1
  129. package/dist-lib/host/fetch-proxy-handler.cjs +1 -1
  130. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  131. package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
  132. package/dist-lib/host/websocket-proxy.cjs +1 -1
  133. package/dist-lib/index.cjs +1 -1
  134. package/dist-lib/jump-to-source-babel.cjs +1 -1
  135. package/dist-lib/menu.cjs +1 -1
  136. package/dist-lib/menu.mjs +1 -1
  137. package/dist-lib/metro.cjs +1 -1
  138. package/dist-lib/profiles.cjs +1 -1
  139. package/dist-lib/public-brand.cjs +1 -1
  140. package/dist-lib/render-mode.cjs +1 -1
  141. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  142. package/dist-lib/sdk.cjs +1 -1
  143. package/dist-lib/sdk.mjs +1 -1
  144. package/dist-lib/skills.cjs +21 -4
  145. package/dist-lib/vite.cjs +1 -1
  146. package/package.json +1 -1
  147. package/dist-cli/chunks/cli-version-LL2UGIHE.js +0 -4
  148. package/dist-cli/chunks/daemon-OYLASXLE.js +0 -4
  149. package/dist-cli/chunks/drivers-EPIEFF7P.js +0 -4
  150. package/dist-cli/chunks/flow-NKMPBYCJ.js +0 -4
  151. package/dist-cli/chunks/help-OGCBHOKA.js +0 -4
  152. package/dist-cli/chunks/inspect-FUYMOZPY.js +0 -4
  153. package/dist-cli/chunks/install-desktop-FR6YKW7Y.js +0 -4
  154. package/dist-cli/chunks/reset-7YGYKQPQ.js +0 -4
  155. package/dist-cli/chunks/runtime-B4JO6QRI.js +0 -4
  156. package/dist-cli/chunks/store-32HSPZHI.js +0 -4
  157. package/dist-cli/chunks/telemetry-PBJR7XHR.js +0 -4
  158. package/dist-cli/chunks/upload-LQJITLKK.js +0 -4
@@ -1,5 +1,5 @@
1
- /*! rnx v0.1.314 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
1
+ /*! rnx v0.1.316 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
2
  import { createRequire as __sootsimCreateRequire } from 'node:module'
3
3
  var require = __sootsimCreateRequire(import.meta.url)
4
4
  function i(t,o,a,c){return{width:3,ringToggle:{side:"left",top:t[0],height:t[1]},volumeUp:{side:"left",top:o[0],height:o[1]},volumeDown:{side:"left",top:a[0],height:a[1]},lock:{side:"right",top:c[0],height:c[1]}}}var E={width:2.5,lock:{side:"right",top:188.7,height:68.1},ringToggle:{side:"left",top:113.2,height:36},volumeUp:{side:"left",top:188.2,height:68.1},volumeDown:{side:"left",top:269,height:68.1}},y={width:3,lock:{side:"right",top:671/2.625,height:163/2.625},ringToggle:{side:"left",top:-1e3,height:0},volumeUp:{side:"right",top:971/2.625,height:165/2.625},volumeDown:{side:"right",top:1136/2.625,height:166/2.625}},A={width:3,lock:{side:"right",top:248,height:72},ringToggle:{side:"left",top:-1e3,height:0},volumeUp:{side:"right",top:144,height:62},volumeDown:{side:"right",top:216,height:62}},s=24,d="17",u=37,T=1080/2.625,O=2400/2.625,h=132/2.625;function r(t){return{top:t,right:t,bottom:t,left:t}}function N(t){let o=(t.frameInsets.top+t.frameInsets.right+t.frameInsets.bottom+t.frameInsets.left)/4,a=Math.max(Math.abs(t.frameInsets.top-o),Math.abs(t.frameInsets.right-o),Math.abs(t.frameInsets.bottom-o),Math.abs(t.frameInsets.left-o));return{frameRadius:t.cornerRadius+o,frameRadiusApproximationError:a,screenRadius:t.cornerRadius}}function _(t){return{...N(t),frameHeight:t.frameInsets.top+t.height+t.frameInsets.bottom,frameWidth:t.frameInsets.left+t.width+t.frameInsets.right,screenBottomInset:t.frameInsets.bottom,screenLeft:t.frameInsets.left,screenRightInset:t.frameInsets.right,screenTop:t.frameInsets.top}}function n(t){return{...t,platform:"ios",navigationBarHeight:0,navigationBarMode:t.homeIndicatorHeight>0?"gesture":"none",displayCutout:{top:t.dynamicIsland?t.statusBarHeight:0,bottom:0,left:0,right:0},cameraCutout:null,osVersion:t.iosVersion,androidApiLevel:null,systemName:"iOS",manufacturer:"Apple",brand:"Apple",modelName:t.name}}var C={"canvas-workspace":n({name:"Canvas Workspace",width:1440,height:900,scale:1,statusBarHeight:0,homeIndicatorHeight:0,cornerRadius:0,continuousCornerRadius:0,frameInsets:r(16),dynamicIsland:null,safeAreaInsets:{top:0,bottom:0,left:0,right:0},iosVersion:"26.4",physicalPPI:110,hardwareButtons:i([185.8,41.7],[258.2,67.6],[344,67.6],[281.5,106.9]),experimental:!0}),"iphone-se":n({name:"iPhone SE",width:375,height:667,scale:2,statusBarHeight:20,homeIndicatorHeight:0,cornerRadius:0,continuousCornerRadius:0,frameInsets:r(28.7),dynamicIsland:null,safeAreaInsets:{top:20,bottom:0,left:0,right:0},iosVersion:"15.8",physicalPPI:326,hardwareButtons:E}),"iphone-14":n({name:"iPhone 14",width:390,height:844,scale:3,statusBarHeight:47,homeIndicatorHeight:34,cornerRadius:46.2,continuousCornerRadius:67.462,frameInsets:r(19.5),dynamicIsland:null,safeAreaInsets:{top:47,bottom:34,left:0,right:0},iosVersion:"17.6",physicalPPI:460,hardwareButtons:i([141.7,29.7],[205.9,69.6],[289.5,69.6],[228.9,114.5])}),"iphone-15":n({name:"iPhone 15",width:393,height:852,scale:3,statusBarHeight:59,homeIndicatorHeight:34,cornerRadius:53.9,continuousCornerRadius:73.402,frameInsets:r(18.2),dynamicIsland:{width:126,height:37.3,top:14.1},safeAreaInsets:{top:59,bottom:34,left:0,right:0},iosVersion:"17.6",physicalPPI:460,hardwareButtons:i([171.7,32],[235.8,65.3],[320.5,65.3],[280.6,105.2])}),"iphone-15-plus":n({name:"iPhone 15 Plus",width:430,height:932,scale:3,statusBarHeight:59,homeIndicatorHeight:34,cornerRadius:53.9,continuousCornerRadius:74.654,frameInsets:r(17.3),dynamicIsland:{width:126,height:37.3,top:11.4},safeAreaInsets:{top:59,bottom:34,left:0,right:0},iosVersion:"17.6",physicalPPI:460,hardwareButtons:i([172.1,33],[236.1,66.6],[321.2,66.6],[281,106.8])}),"iphone-15-pro":n({name:"iPhone 15 Pro",width:393,height:852,scale:3,statusBarHeight:59,homeIndicatorHeight:34,cornerRadius:53.9,continuousCornerRadius:73.402,frameInsets:r(15.3),dynamicIsland:{width:126,height:38,top:13.4},safeAreaInsets:{top:59,bottom:34,left:0,right:0},iosVersion:"18.2",physicalPPI:460,hardwareButtons:i([159.1,31.5],[220.1,61.9],[299,61.9],[260.8,98.9])}),"iphone-15-pro-max":n({name:"iPhone 15 Pro Max",width:430,height:932,scale:3,statusBarHeight:59,homeIndicatorHeight:34,cornerRadius:53.9,continuousCornerRadius:74.654,frameInsets:r(15.3),dynamicIsland:{width:126,height:38,top:13.3},safeAreaInsets:{top:59,bottom:34,left:0,right:0},iosVersion:"18.2",physicalPPI:460,hardwareButtons:i([173.3,32.2],[253.4,61.7],[343.3,61.7],[268.5,98.5])}),"iphone-16":n({name:"iPhone 16",width:393,height:852,scale:3,statusBarHeight:59,homeIndicatorHeight:34,cornerRadius:53.9,continuousCornerRadius:73.402,frameInsets:r(15.3),dynamicIsland:{width:126,height:37.3,top:11},safeAreaInsets:{top:59,bottom:34,left:0,right:0},iosVersion:"26.4",physicalPPI:460,hardwareButtons:i([159.1,31.5],[220.1,61.9],[299,61.9],[260.8,98.9])}),"iphone-16-plus":n({name:"iPhone 16 Plus",width:430,height:932,scale:3,statusBarHeight:59,homeIndicatorHeight:34,cornerRadius:53.9,continuousCornerRadius:74.654,frameInsets:r(15.3),dynamicIsland:{width:126,height:37.3,top:11.4},safeAreaInsets:{top:59,bottom:34,left:0,right:0},iosVersion:"26.4",physicalPPI:460,hardwareButtons:i([173.3,32.2],[253.4,61.7],[343.3,61.7],[268.5,98.5])}),"iphone-16-pro":n({name:"iPhone 16 Pro",width:402,height:874,scale:3,statusBarHeight:62,homeIndicatorHeight:34,cornerRadius:61,continuousCornerRadius:84.661,frameInsets:r(15.3),dynamicIsland:{width:126,height:38,top:13.5},safeAreaInsets:{top:62,bottom:34,left:0,right:0},iosVersion:"26.4",physicalPPI:460,hardwareButtons:i([159.1,31.5],[220.1,61.9],[299,61.9],[260.8,98.9])}),"iphone-16-pro-max":n({name:"iPhone 16 Pro Max",width:440,height:956,scale:3,statusBarHeight:62,homeIndicatorHeight:34,cornerRadius:61.3,continuousCornerRadius:85.163,frameInsets:r(15.4),dynamicIsland:{width:126,height:38,top:14},safeAreaInsets:{top:62,bottom:34,left:0,right:0},iosVersion:"26.4",physicalPPI:460,hardwareButtons:i([178.8,32.2],[266.8,61.8],[352.7,61.8],[292.2,98.3])}),"iphone-17":n({name:"iPhone 17",width:402,height:874,scale:3,statusBarHeight:59,homeIndicatorHeight:34,cornerRadius:61,continuousCornerRadius:84.661,frameInsets:r(15.3),dynamicIsland:{width:126,height:37.3,top:14},safeAreaInsets:{top:59,bottom:34,left:0,right:0},iosVersion:"26.4",physicalPPI:460,hardwareButtons:i([159.1,31.5],[220.1,61.9],[299,61.9],[260.8,98.9])}),"iphone-17-air":n({name:"iPhone Air",width:420,height:912,scale:3,statusBarHeight:59,homeIndicatorHeight:34,cornerRadius:64.6,continuousCornerRadius:88.313,frameInsets:r(10.7),dynamicIsland:{width:126,height:38,top:20},safeAreaInsets:{top:59,bottom:34,left:0,right:0},iosVersion:"26.4",physicalPPI:460,hardwareButtons:i([178.8,32.2],[266.8,61.8],[352.7,61.8],[292.2,98.3])}),"iphone-17-pro":n({name:"iPhone 17 Pro",width:402,height:874,scale:3,statusBarHeight:59,homeIndicatorHeight:34,cornerRadius:61,continuousCornerRadius:84.661,frameInsets:r(15.3),dynamicIsland:{width:126,height:38,top:14},safeAreaInsets:{top:59,bottom:34,left:0,right:0},iosVersion:"26.4",physicalPPI:460,hardwareButtons:i([159.1,31.5],[220.1,61.9],[299,61.9],[260.8,98.9])}),"iphone-17-pro-max":n({name:"iPhone 17 Pro Max",width:440,height:956,scale:3,statusBarHeight:62,homeIndicatorHeight:34,cornerRadius:61.3,continuousCornerRadius:85.163,frameInsets:r(15.4),dynamicIsland:{width:126,height:38,top:14},safeAreaInsets:{top:62,bottom:34,left:0,right:0},iosVersion:"26.4",physicalPPI:460,hardwareButtons:i([178.8,32.2],[266.8,61.8],[352.7,61.8],[292.2,98.3])}),"pixel-8":{platform:"android",name:"Pixel 8",width:T,height:O,scale:2.625,statusBarHeight:h,homeIndicatorHeight:0,navigationBarHeight:s,navigationBarMode:"gesture",displayCutout:{top:h,bottom:0,left:0,right:0},cornerRadius:39,continuousCornerRadius:39,frameInsets:{top:55/2.625,right:50/2.625,bottom:58/2.625,left:49/2.625},dynamicIsland:null,cameraCutout:{diameter:72.5/2.625},safeAreaInsets:{top:h,bottom:s,left:0,right:0},osVersion:d,iosVersion:"",androidApiLevel:u,systemName:"Android",manufacturer:"Google",brand:"google",modelName:"Pixel 8",physicalPPI:428,hardwareButtons:y},"pixel-8-three-button":{platform:"android",name:"Pixel 8 (3-button)",width:T,height:O,scale:2.625,statusBarHeight:h,homeIndicatorHeight:0,navigationBarHeight:48,navigationBarMode:"three-button",displayCutout:{top:h,bottom:0,left:0,right:0},cornerRadius:39,continuousCornerRadius:39,frameInsets:{top:55/2.625,right:50/2.625,bottom:58/2.625,left:49/2.625},dynamicIsland:null,cameraCutout:{diameter:72.5/2.625},safeAreaInsets:{top:h,bottom:48,left:0,right:0},osVersion:d,iosVersion:"",androidApiLevel:u,systemName:"Android",manufacturer:"Google",brand:"google",modelName:"Pixel 8",physicalPPI:428,hardwareButtons:y},"pixel-9-pro-xl":{platform:"android",name:"Pixel 9 Pro XL",width:448,height:997,scale:3,statusBarHeight:40,homeIndicatorHeight:0,navigationBarHeight:s,navigationBarMode:"gesture",displayCutout:{top:40,bottom:0,left:0,right:0},cornerRadius:41,continuousCornerRadius:41,frameInsets:r(12),dynamicIsland:null,cameraCutout:{diameter:24},safeAreaInsets:{top:40,bottom:s,left:0,right:0},osVersion:d,iosVersion:"",androidApiLevel:u,systemName:"Android",manufacturer:"Google",brand:"google",modelName:"Pixel 9 Pro XL",physicalPPI:486,hardwareButtons:y},"pixel-10":{platform:"android",name:"Pixel 10",width:360,height:808,scale:3,statusBarHeight:40,homeIndicatorHeight:0,navigationBarHeight:s,navigationBarMode:"gesture",displayCutout:{top:40,bottom:0,left:0,right:0},cornerRadius:40,continuousCornerRadius:40,frameInsets:r(18),dynamicIsland:null,cameraCutout:{diameter:26},safeAreaInsets:{top:40,bottom:s,left:0,right:0},osVersion:d,iosVersion:"",androidApiLevel:u,systemName:"Android",manufacturer:"Google",brand:"google",modelName:"Pixel 10",physicalPPI:422,hardwareButtons:y},"galaxy-s24":{platform:"android",name:"Galaxy S24",width:360,height:780,scale:3,statusBarHeight:36,homeIndicatorHeight:0,navigationBarHeight:s,navigationBarMode:"gesture",displayCutout:{top:36,bottom:0,left:0,right:0},cornerRadius:36,continuousCornerRadius:36,frameInsets:r(8),dynamicIsland:null,cameraCutout:{diameter:18},safeAreaInsets:{top:36,bottom:s,left:0,right:0},osVersion:d,iosVersion:"",androidApiLevel:u,systemName:"Android",manufacturer:"Samsung",brand:"samsung",modelName:"SM-S921B",physicalPPI:416,hardwareButtons:A},"galaxy-s24-ultra":{platform:"android",name:"Galaxy S24 Ultra",width:384,height:832,scale:3.75,statusBarHeight:36,homeIndicatorHeight:0,navigationBarHeight:s,navigationBarMode:"gesture",displayCutout:{top:36,bottom:0,left:0,right:0},cornerRadius:24,continuousCornerRadius:24,frameInsets:r(9),dynamicIsland:null,cameraCutout:{diameter:18},safeAreaInsets:{top:36,bottom:s,left:0,right:0},osVersion:d,iosVersion:"",androidApiLevel:u,systemName:"Android",manufacturer:"Samsung",brand:"samsung",modelName:"SM-S928B",physicalPPI:505,hardwareButtons:A}},R="iphone-17-pro";function G(t){return C[t]}function v(){return Object.keys(C)}function U(){return v().filter(t=>!C[t].experimental)}var H="rnx",W=Object.freeze({name:H,packageName:"rnxsim",commandName:"rnxsim",domain:"rnxsim.com",origin:"https://rnxsim.com"});var D=["off","soft","full"];function k(t){return t==="off"||t==="soft"||t==="full"}var S={"iphone-6-9":{name:"iphone-6-9",label:'iPhone 6.7"',width:1284,height:2778,store:"apple"},"iphone-6-1":{name:"iphone-6-1",label:'iPhone 6.5"',width:1242,height:2688,store:"apple"},"android-phone":{name:"android-phone",label:"Google Play phone",width:1080,height:1920,store:"google"},"android-tablet-7":{name:"android-tablet-7",label:'Google Play 7" tablet',width:1200,height:1920,store:"google"},"android-tablet-10":{name:"android-tablet-10",label:'Google Play 10" tablet',width:1600,height:2560,store:"google"}},w={dark:{type:"gradient",direction:180,glow:"#4caeff",stops:[{offset:0,color:"#111827"},{offset:40,color:"#101725"},{offset:100,color:"#06080d"}]},cyan:{type:"gradient",direction:180,glow:"#25c3ec",stops:[{offset:0,color:"#1b465c"},{offset:32,color:"#122336"},{offset:100,color:"#05070b"}]},gold:{type:"gradient",direction:180,glow:"#ffc25a",stops:[{offset:0,color:"#3b2f1a"},{offset:34,color:"#18140d"},{offset:100,color:"#050505"}]},red:{type:"gradient",direction:180,glow:"#ff6178",stops:[{offset:0,color:"#3e1018"},{offset:35,color:"#17080c"},{offset:100,color:"#050405"}]}},$={color:"#25c3ec",blur:120,spread:52,opacity:.34},X="iphone-17-pro";var L=[{name:"white",value:"#ffffff"},{name:"gray-light",value:"#d1d5db"},{name:"gray",value:"#6b7280"},{name:"gray-dark",value:"#3b4350"},{name:"slate",value:"#2a3644"},{name:"black",value:"#000000"},{name:"cyan",value:"#25c3ec"},{name:"blue",value:"#3f7cff"},{name:"teal",value:"#1fc7b4"},{name:"green",value:"#42c95d"},{name:"lime",value:"#92d21b"},{name:"gold",value:"#f5c518"},{name:"orange",value:"#ff912e"},{name:"coral",value:"#ff6f5b"},{name:"red",value:"#ff4f6f"},{name:"berry",value:"#d054ff"},{name:"magenta",value:"#ff4eb8"}],B=Object.fromEntries(L.map(t=>[t.name,t.value]));function q(t){return B[t]??B.gray}function Z(t){return Object.prototype.hasOwnProperty.call(S,t)?S[t]:null}function z(t){return{type:t.type,color:t.color,direction:t.direction,glow:t.glow,stops:t.stops?.map(o=>({...o}))}}function Q(t){return Object.prototype.hasOwnProperty.call(w,t)?z(w[t]):null}var F=[.823,.882,.941,1,1.118,1.235,1.353,1.786,2.143,2.643,3.143,3.571];function e(t,o){return Object.freeze({fontSize:t,lineHeight:o})}var ee=Object.freeze({xs:Object.freeze({largeTitle:e(31,44.408775),title1:e(25,37.128102),title2:e(19,27.816685),title3:e(17,23.807109),headline:e(14,20.161577),body:e(14,20.161577),callout:e(13,18.942243),subheadline:e(12,16.720313),footnote:e(12,16.986979),caption1:e(11,15.564453),caption2:e(11,16.126953)}),s:Object.freeze({largeTitle:e(32,45.797256),title1:e(26,38.556756),title2:e(20,29.22433),title3:e(18,25.160469),headline:e(15,21.536754),body:e(15,21.536754),callout:e(14,20.326079),subheadline:e(13,18.213672),footnote:e(12,16.986979),caption1:e(11,15.564453),caption2:e(11,16.126953)}),m:Object.freeze({largeTitle:e(33,47.185737),title1:e(27,39.985409),title2:e(21,30.631975),title3:e(19,26.513828),headline:e(16,22.911932),body:e(16,22.911932),callout:e(15,21.709914),subheadline:e(14,19.557031),footnote:e(12,16.986979),caption1:e(11,15.564453),caption2:e(11,16.126953)}),l:Object.freeze({largeTitle:e(34,48.574219),title1:e(28,41.414063),title2:e(22,32.253906),title3:e(20,27.867187),headline:e(17,24.287109),body:e(17,24.287109),callout:e(16,23.09375),subheadline:e(15,20.900391),footnote:e(13,18.513672),caption1:e(12,17.320313),caption2:e(11,16.126953)}),xl:Object.freeze({largeTitle:e(36,51.351181),title1:e(30,44.271369),title2:e(24,35.069196),title3:e(22,30.733906),headline:e(19,27.037464),body:e(19,27.037464),callout:e(18,25.861421),subheadline:e(17,23.587109),footnote:e(15,21.233724),caption1:e(14,20.269531),caption2:e(13,19.667518)}),xxl:Object.freeze({largeTitle:e(38,54.323266),title1:e(32,47.128676),title2:e(26,37.884487),title3:e(24,33.440625),headline:e(21,29.78782),body:e(21,29.78782),callout:e(20,28.629092),subheadline:e(19,26.273828),footnote:e(17,23.953776),caption1:e(16,23.03125),caption2:e(15,22.515775)}),xxxl:Object.freeze({largeTitle:e(40,57.100229),title1:e(34,50.221278),title2:e(28,40.699777),title3:e(26,36.147344),headline:e(23,32.719993),body:e(23,32.719993),callout:e(22,31.58724),subheadline:e(21,28.960547),footnote:e(19,26.673828),caption1:e(18,25.792969),caption2:e(17,25.364032)}),ax1:Object.freeze({largeTitle:e(44,62.654154),title1:e(38,56.171186),title2:e(34,49.359933),title3:e(31,43.074141),headline:e(28,39.595881),body:e(28,39.595881),callout:e(26,37.122582),subheadline:e(25,34.483984),footnote:e(23,32.280599),caption1:e(22,31.316406),caption2:e(20,29.636418)}),ax2:Object.freeze({largeTitle:e(48,68.403201),title1:e(43,63.314453),title2:e(39,56.612444),title3:e(37,51.194297),headline:e(33,46.653587),body:e(33,46.653587),callout:e(32,45.616071),subheadline:e(30,41.200781),footnote:e(27,37.720703),caption1:e(26,37.027344),caption2:e(24,35.332933)}),ax3:Object.freeze({largeTitle:e(52,73.957127),title1:e(48,70.693015),title2:e(44,63.65067),title3:e(43,59.474453),headline:e(40,56.461648),body:e(40,56.461648),callout:e(38,54.109561),subheadline:e(36,49.410937),footnote:e(33,46.047526),caption1:e(32,45.5),caption2:e(29,42.684345)}),ax4:Object.freeze({largeTitle:e(56,79.706174),title1:e(53,77.600988),title2:e(50,72.310826),title3:e(49,67.754609),headline:e(47,65.360618),body:e(47,66.269709),callout:e(44,62.412574),subheadline:e(42,57.621094),footnote:e(38,53.014323),caption1:e(37,52.404297),caption2:e(34,50.035757)}),ax5:Object.freeze({largeTitle:e(60,85.260099),title1:e(58,85.214844),title2:e(56,80.970982),title3:e(55,76.034766),headline:e(53,74.520774),body:e(53,74.520774),callout:e(51,72.2899),subheadline:e(49,67.174609),footnote:e(44,61.174479),caption1:e(43,60.876953),caption2:e(40,58.811298)})});function M(t){return F.some(o=>Object.is(o,t))}var ae=["colorScheme","reduceMotion","boldText","fontSize","largerAccessibilitySizes"],l={deviceModel:{type:"enum",default:R,description:"device model to simulate",cliFlag:"device",cliFlagShort:"d",options:v(),group:"device"},orientation:{type:"enum",default:"portrait",description:"screen orientation",cliFlag:"orientation",options:["portrait","landscape"],group:"device"},colorScheme:{type:"enum",default:"auto",description:"color scheme (auto follows system preference)",cliFlag:"theme",cliFlagShort:"t",options:["light","dark","auto"],group:"appearance"},reduceMotion:{type:"boolean",default:!1,description:"reduce motion",group:"appearance"},boldText:{type:"boolean",default:!1,description:"bold text",group:"appearance"},fontSize:{type:"number",default:1,description:"font size multiplier (1.0 = default)",group:"appearance",validate:t=>t>=.5&&t<=4},largerAccessibilitySizes:{type:"boolean",default:!1,description:"show accessibility categories in the dynamic type size picker",group:"appearance"},networkCondition:{type:"enum",default:"wifi",description:"simulated network condition",cliFlag:"network",options:["wifi","lte","fast-3g","slow-3g","offline"],group:"network"},language:{type:"string",default:"en",description:"language code (ISO 639-1)",cliFlag:"language",group:"locale"},region:{type:"string",default:"US",description:"region code (ISO 3166-1)",cliFlag:"region",group:"locale"},renderDensity:{type:"number",default:0,description:"render density override in device pixels per point for high-resolution capture (0 = device native)",group:"simulator",validate:t=>t===0||t>=1&&t<=9},showTouches:{type:"boolean",default:!1,description:"show touch indicators",group:"simulator"},showFrame:{type:"boolean",default:!0,description:"show device frame",cliFlag:"frame",group:"simulator"},showMenuBar:{type:"boolean",default:!0,description:"keep the menu bar visible instead of revealing it at the top edge",group:"simulator"},showRail:{type:"boolean",default:!0,description:"keep the rail visible instead of revealing it on hover",group:"simulator"},solidWindow:{type:"boolean",default:!1,description:"desktop app: always use the solid, freely-resizable window instead of the device-shaped transparent one (3d mode uses it regardless)",group:"simulator"},ambientGlow:{type:"enum",default:"off",description:"bleed the app's own edge colors outward behind the device, like bias lighting behind a TV (off, soft, full)",options:D,cliFlag:"ambient-glow",group:"simulator"},screenshotMode:{type:"boolean",default:!1,description:"show screenshot composition mode in the browser shell",group:"simulator"},screenshotCanvasEditing:{type:"boolean",default:!1,description:"experimental figma-style slide editing: draggable copy block, drop-in image layers (owner review pending)",group:"simulator"},threeMode:{type:"boolean",default:!1,description:"show the experimental 3d device stage in the browser shell",group:"simulator"},threeRecordingEditor:{type:"boolean",default:!1,description:"dock the 3d recording editor in the 3d stage (toggled from its rail)",group:"simulator"},screenshotCanvas:{type:"enum",default:"iphone-6-9",description:"target app-store canvas preset for screenshot mode",options:Object.keys(S),group:"simulator"},screenshotBackground:{type:"enum",default:"dark",description:"background preset rendered inside the screenshot canvas",options:Object.keys(w),group:"simulator"},screenshotText:{type:"enum",default:"bold-top",description:"text layout preset for the screenshot canvas",options:["bold-top","editorial-left","minimal-bottom","none"],group:"simulator"},screenshotPose:{type:"enum",default:"straight",description:"device pose preset inside the screenshot canvas",options:["straight","tilted-left","tilted-right","cut-bottom","cut-top"],group:"simulator"},screenshotDynamicSize:{type:"boolean",default:!1,description:"let the screenshot canvas rect fit available space (off = pin to exact preset pixels)",group:"simulator"},showStatusBar:{type:"boolean",default:!0,description:"show status bar",group:"simulator"},showHomeIndicator:{type:"boolean",default:!0,description:"show home indicator",group:"simulator"},alwaysShowLiveWebViews:{type:"boolean",default:!1,description:"always render WebViews as live browser views",group:"simulator"},a11yMode:{type:"enum",default:"delayed",description:"accessibility tree sync mode (off, delayed=100ms, active=30ms)",options:["off","delayed","active"],group:"simulator"},a11yDepth:{type:"enum",default:"deep",description:"accessibility tree structure depth (shallow or deep)",options:["shallow","deep"],group:"simulator"},inspectMode:{type:"boolean",default:!1,description:"inspect mode",group:"simulator"},productAnalytics:{type:"boolean",default:!0,description:"send bounded product usage analytics",group:"privacy"},crashReports:{type:"boolean",default:!0,description:"send anonymous crash reports",group:"privacy"},agentProvider:{type:"enum",default:"codex",description:"ai agent used by the sootsim agent prompt bar",options:["codex","claude"],group:"agent"}},se={colorScheme:l.colorScheme.default,reduceMotion:l.reduceMotion.default,boldText:l.boldText.default,fontSize:l.fontSize.default,largerAccessibilitySizes:l.largerAccessibilitySizes.default};function V(){if(typeof window>"u")return{};let t={};try{let o=new URLSearchParams(window.location.search),a=o.get("device");a&&l.deviceModel.options?.includes(a)&&(t.deviceModel=a),o.get("ssMode")==="1"&&(t.screenshotMode=!0),o.get("filmStage")==="1"&&(t.threeMode=!0,a||(t.deviceModel="iphone-17-air"));let c=Number(o.get("renderDensity"));Number.isFinite(c)&&c>=1&&c<=9&&(t.renderDensity=c),o.get("ssEdit")==="1"&&(t.screenshotCanvasEditing=!0);let I=o.get("colorScheme")??o.get("theme");I&&l.colorScheme.options?.includes(I)&&(t.colorScheme=I);let p=o.get("reduceMotion");p==="1"||p==="true"?t.reduceMotion=!0:(p==="0"||p==="false")&&(t.reduceMotion=!1);let m=o.get("boldText");m==="1"||m==="true"?t.boldText=!0:(m==="0"||m==="false")&&(t.boldText=!1);let x=Number(o.get("fontSize"));Number.isFinite(x)&&M(x)&&(t.fontSize=x);let g=o.get("largerAccessibilitySizes");g==="1"||g==="true"?t.largerAccessibilitySizes=!0:(g==="0"||g==="false")&&(t.largerAccessibilitySizes=!1);let f=o.get("alwaysShowLiveWebViews");f==="1"||f==="true"?t.alwaysShowLiveWebViews=!0:(f==="0"||f==="false")&&(t.alwaysShowLiveWebViews=!1);let b=o.get("showFrame");b==="1"||b==="true"?t.showFrame=!0:(b==="0"||b==="false")&&(t.showFrame=!1);let P=o.get("ambientGlow");k(P)&&(t.ambientGlow=P)}catch{}return t}function le(){let t={};for(let[o,a]of Object.entries(l))t[o]=a.default;return Object.assign(t,V()),t}export{_ as a,C as b,G as c,U as d,$ as e,X as f,q as g,Z as h,z as i,Q as j,ae as k,l,se as m,V as n,le as o};
5
- /*! rnx v0.1.314 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
5
+ /*! rnx v0.1.316 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
@@ -1,7 +1,7 @@
1
- /*! rnx v0.1.314 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
1
+ /*! rnx v0.1.316 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
2
  import { createRequire as __sootsimCreateRequire } from 'node:module'
3
3
  var require = __sootsimCreateRequire(import.meta.url)
4
- import{a as st}from"./chunk-KR4JON7D.js";import{a as lt}from"./chunk-RWZY5427.js";import{a as Ke,b as me,c as ge,d as Ye,e as we,f as ye,g as ze,h as be,i as ot}from"./chunk-QOJJJWJE.js";import{a as qe}from"./chunk-PG5RZCTN.js";import{g as et,h as tt,p as rt,r as it,v as nt}from"./chunk-D2FNUWAB.js";import{a as Qe}from"./chunk-TUOFAWXT.js";import{e as at}from"./chunk-EG32ML36.js";import{g as Ze}from"./chunk-7OOPFSQS.js";import{h as Je,m as Ge}from"./chunk-YFSDM7AX.js";import{J as fe,m as He,n as Ue,o as We,p as je,q as Ve}from"./chunk-ZBSJO4NB.js";import{b as Xe}from"./chunk-SGMVFFMK.js";import{c as _e,d as ce}from"./chunk-46ZOLOYA.js";import{a as De,b as Be,c as Le}from"./chunk-2JNSK774.js";import{g as ue,h as Ne,q as pe,r as he,s as Ce}from"./chunk-XLZ5FNRT.js";import*as P from"fs";import{createHash as Yt,randomUUID as zt}from"node:crypto";import{tmpdir as Y}from"os";import*as w from"path";import*as x from"fs";import*as S from"path";var At="inset 0 0 0 0.5px #000, inset 0 0 0 2px #757575, inset 0 0 0 5px #212121",ct=1;function Rt(n){let e=Le(n),t=e.scale,r=e.statusBarHeight>0&&!e.dynamicIsland&&e.homeIndicatorHeight===0&&e.cornerRadius===0,i=e.width,o=e.height,a=De(e),s=r?e.width+58:a.frameWidth,l=r?e.height+111+111:a.frameHeight,p=9.5,u=ct,g=s+p*2,b=l+ct*2,m=p+(r?29:a.screenLeft),k=r?111:a.screenTop,$=r?52:a.frameRadius,H=[{side:e.hardwareButtons.lock.side,top:e.hardwareButtons.lock.top,height:e.hardwareButtons.lock.height,width:e.hardwareButtons.width},{side:e.hardwareButtons.ringToggle.side,top:e.hardwareButtons.ringToggle.top,height:e.hardwareButtons.ringToggle.height,width:e.hardwareButtons.width},{side:e.hardwareButtons.volumeUp.side,top:e.hardwareButtons.volumeUp.top,height:e.hardwareButtons.volumeUp.height,width:e.hardwareButtons.width},{side:e.hardwareButtons.volumeDown.side,top:e.hardwareButtons.volumeDown.top,height:e.hardwareButtons.volumeDown.height,width:e.hardwareButtons.width}];return{model:n,renderScale:t,outerWidth:Math.round(g*t),outerHeight:Math.round(b*t),logicalOuterWidth:g,logicalOuterHeight:b,logicalFrameWidth:s,logicalFrameHeight:l,logicalFrameLeft:p,logicalFrameTop:u,logicalScreenWidth:i,logicalScreenHeight:o,logicalScreenLeft:m,logicalScreenTop:k,logicalScreenRadius:r?0:a.screenRadius,logicalFrameRadius:$,frameBackground:r?"linear-gradient(180deg, #1b1c20 0%, #0f1012 42%, #050608 100%)":"#000000",frameOutline:r?"0 0 0 1px #1f2125":"0 0 0 1px #333",metallicRingShadow:r?null:At,buttons:H,legacyHomeButton:r?{top:111+e.height+47/2,left:e.width/2-64/2+29,size:64,ring:1.5}:null,showHomeIndicator:e.homeIndicatorHeight>0,logicalHomeIndicatorStripHeight:e.homeIndicatorHeight}}function Mt(n){let e=n.side==="right",t=e?"inset(-3px -3px -3px 0)":"inset(-3px 0 -3px -3px)";return`
4
+ import{a as at}from"./chunk-D5U7M6CS.js";import{a as dt}from"./chunk-HOGMZTXK.js";import{a as qe,b as me,c as ge,d as ze,e as we,f as ye,g as Xe,h as be,i as st}from"./chunk-VSBUWTVL.js";import{a as Ye}from"./chunk-U523FCYZ.js";import{g as tt,h as rt,p as it,r as nt,v as ot}from"./chunk-WO4W67CV.js";import{a as et}from"./chunk-FBUYTMEM.js";import{e as lt}from"./chunk-CBTHKMXT.js";import{g as Qe}from"./chunk-6KBBHTEX.js";import{h as Ge,m as Ke}from"./chunk-VQXFEXNH.js";import{J as fe,m as Ue,n as We,o as je,p as Ve,q as Je}from"./chunk-B34FLQCQ.js";import{b as Ze}from"./chunk-V3DA77A6.js";import{c as De,d as ce}from"./chunk-HKD3XX6U.js";import{a as Be,b as Le,c as Ce}from"./chunk-VV4TEHX7.js";import{g as ue,h as Ne,q as pe,r as he,s as He}from"./chunk-QXZUTSYV.js";import*as P from"fs";import{createHash as zt,randomUUID as Xt}from"node:crypto";import{tmpdir as Y}from"os";import*as w from"path";import*as x from"fs";import*as S from"path";var Rt="inset 0 0 0 0.5px #000, inset 0 0 0 2px #757575, inset 0 0 0 5px #212121",ut=1;function Mt(n){let e=Ce(n),t=e.scale,r=e.statusBarHeight>0&&!e.dynamicIsland&&e.homeIndicatorHeight===0&&e.cornerRadius===0,i=e.width,o=e.height,a=Be(e),s=r?e.width+58:a.frameWidth,l=r?e.height+111+111:a.frameHeight,p=9.5,u=ut,g=s+p*2,b=l+ut*2,m=p+(r?29:a.screenLeft),k=r?111:a.screenTop,$=r?52:a.frameRadius,H=[{side:e.hardwareButtons.lock.side,top:e.hardwareButtons.lock.top,height:e.hardwareButtons.lock.height,width:e.hardwareButtons.width},{side:e.hardwareButtons.ringToggle.side,top:e.hardwareButtons.ringToggle.top,height:e.hardwareButtons.ringToggle.height,width:e.hardwareButtons.width},{side:e.hardwareButtons.volumeUp.side,top:e.hardwareButtons.volumeUp.top,height:e.hardwareButtons.volumeUp.height,width:e.hardwareButtons.width},{side:e.hardwareButtons.volumeDown.side,top:e.hardwareButtons.volumeDown.top,height:e.hardwareButtons.volumeDown.height,width:e.hardwareButtons.width}];return{model:n,renderScale:t,outerWidth:Math.round(g*t),outerHeight:Math.round(b*t),logicalOuterWidth:g,logicalOuterHeight:b,logicalFrameWidth:s,logicalFrameHeight:l,logicalFrameLeft:p,logicalFrameTop:u,logicalScreenWidth:i,logicalScreenHeight:o,logicalScreenLeft:m,logicalScreenTop:k,logicalScreenRadius:r?0:a.screenRadius,logicalFrameRadius:$,frameBackground:r?"linear-gradient(180deg, #1b1c20 0%, #0f1012 42%, #050608 100%)":"#000000",frameOutline:r?"0 0 0 1px #1f2125":"0 0 0 1px #333",metallicRingShadow:r?null:Rt,buttons:H,legacyHomeButton:r?{top:111+e.height+47/2,left:e.width/2-64/2+29,size:64,ring:1.5}:null,showHomeIndicator:e.homeIndicatorHeight>0,logicalHomeIndicatorStripHeight:e.homeIndicatorHeight}}function Ot(n){let e=n.side==="right",t=e?"inset(-3px -3px -3px 0)":"inset(-3px 0 -3px -3px)";return`
5
5
  <div
6
6
  aria-hidden="true"
7
7
  style="
@@ -26,7 +26,7 @@ import{a as st}from"./chunk-KR4JON7D.js";import{a as lt}from"./chunk-RWZY5427.js
26
26
  z-index:2;
27
27
  "
28
28
  ></div>
29
- `}function Ot(n,e){let t=n.buttons.map(Mt).join(""),r=n.metallicRingShadow?`
29
+ `}function _t(n,e){let t=n.buttons.map(Ot).join(""),r=n.metallicRingShadow?`
30
30
  <div
31
31
  aria-hidden="true"
32
32
  style="
@@ -179,7 +179,7 @@ import{a as st}from"./chunk-KR4JON7D.js";import{a as lt}from"./chunk-RWZY5427.js
179
179
  </div>
180
180
  </div>
181
181
  </body>
182
- </html>`}async function ut(n,e){let{chromium:t}=await import("playwright"),r=await st(i=>t.launch(i),{headless:!0});try{let i=await _t(r);try{return await i.compose(n,e)}finally{await i.close()}}finally{await r.close()}}async function _t(n){let e=new Map;async function t(r){let i=e.get(r);if(i)return i;let o=Rt(r),a=await n.newContext({viewport:{width:o.outerWidth,height:o.outerHeight},deviceScaleFactor:1}),s=await a.newPage(),l={layout:o,context:a,page:s};return e.set(r,l),l}return{async compose(r,i){let o=await t(i),a=`data:image/png;base64,${r.toString("base64")}`;return await o.page.setContent(Ot(o.layout,a),{waitUntil:"load"}),await o.page.waitForTimeout(20),await o.page.screenshot({type:"png",clip:{x:0,y:0,width:o.layout.outerWidth,height:o.layout.outerHeight},omitBackground:!0})},async close(){for(let r of e.values())await r.context.close();e.clear()}}}import{spawnSync as Dt}from"child_process";import*as N from"vm";var Bt=3e5,Lt=`
182
+ </html>`}async function pt(n,e){let{chromium:t}=await import("playwright"),r=await at(i=>t.launch(i),{headless:!0});try{let i=await Dt(r);try{return await i.compose(n,e)}finally{await i.close()}}finally{await r.close()}}async function Dt(n){let e=new Map;async function t(r){let i=e.get(r);if(i)return i;let o=Mt(r),a=await n.newContext({viewport:{width:o.outerWidth,height:o.outerHeight},deviceScaleFactor:1}),s=await a.newPage(),l={layout:o,context:a,page:s};return e.set(r,l),l}return{async compose(r,i){let o=await t(i),a=`data:image/png;base64,${r.toString("base64")}`;return await o.page.setContent(_t(o.layout,a),{waitUntil:"load"}),await o.page.waitForTimeout(20),await o.page.screenshot({type:"png",clip:{x:0,y:0,width:o.layout.outerWidth,height:o.layout.outerHeight},omitBackground:!0})},async close(){for(let r of e.values())await r.context.close();e.clear()}}}import{spawnSync as Bt}from"child_process";import*as C from"vm";var Lt=3e5,Ct=`
183
183
  let input = '';
184
184
  process.stdin.on('data', (c) => { input += c });
185
185
  process.stdin.on('end', async () => {
@@ -201,7 +201,7 @@ process.stdin.on('end', async () => {
201
201
  process.exitCode = 1;
202
202
  }
203
203
  });
204
- `;function G(n,e,t){if(t?.multipartForm)throw new Error("http: multipartForm is not supported by rnx yet");let r={...process.env};for(let s of Object.keys(r))(s.startsWith("BUN_INSPECT")||s==="NODE_OPTIONS")&&delete r[s];let i=Dt(process.execPath,["-e",Lt],{input:JSON.stringify({url:n,method:e,headers:t?.headers,body:t?.body}),encoding:"utf8",timeout:Bt,maxBuffer:64*1024*1024,env:r});if(i.error)throw new Error(`http ${e} ${n} failed: ${i.error.message}`);let o;try{o=JSON.parse(i.stdout||"")}catch{throw new Error(`http ${e} ${n} failed: no response (${(i.stderr||"").trim().slice(0,200)})`)}let a=o;if(a.__error)throw new Error(`http ${e} ${n} failed: ${a.__error}`);return a}var Nt=/(?<!\\)\$\{([^$]*)\}/g,Ct=/\\(\$\{[^$]*\})/g,Ht=/^[A-Za-z_$][A-Za-z0-9_$]*$/,Q=class{context;envBinding=new Map;envScopeStack=[];syncedEnvKeys=new Set;output={};maestro;constructor(e={}){this.maestro={copiedText:null,platform:e.platform??"ios"};let t=e.onLog??(i=>console.log(`[flow] js: ${i}`)),r={output:this.output,maestro:this.maestro,http:{get:(i,o)=>G(i,"GET",o),post:(i,o)=>G(i,"POST",o),put:(i,o)=>G(i,"PUT",o),delete:(i,o)=>G(i,"DELETE",o),request:(i,o)=>G(i,(o?.method??"GET").toUpperCase(),o)},console:{log:(...i)=>t(i.map(o=>typeof o=="string"?o:pt(o)).join(" "))}};this.context=N.createContext(r),N.runInContext(`
204
+ `;function G(n,e,t){if(t?.multipartForm)throw new Error("http: multipartForm is not supported by rnx yet");let r={...process.env};for(let s of Object.keys(r))(s.startsWith("BUN_INSPECT")||s==="NODE_OPTIONS")&&delete r[s];let i=Bt(process.execPath,["-e",Ct],{input:JSON.stringify({url:n,method:e,headers:t?.headers,body:t?.body}),encoding:"utf8",timeout:Lt,maxBuffer:64*1024*1024,env:r});if(i.error)throw new Error(`http ${e} ${n} failed: ${i.error.message}`);let o;try{o=JSON.parse(i.stdout||"")}catch{throw new Error(`http ${e} ${n} failed: no response (${(i.stderr||"").trim().slice(0,200)})`)}let a=o;if(a.__error)throw new Error(`http ${e} ${n} failed: ${a.__error}`);return a}var Nt=/(?<!\\)\$\{([^$]*)\}/g,Ht=/\\(\$\{[^$]*\})/g,Ut=/^[A-Za-z_$][A-Za-z0-9_$]*$/,Q=class{context;envBinding=new Map;envScopeStack=[];syncedEnvKeys=new Set;output={};maestro;constructor(e={}){this.maestro={copiedText:null,platform:e.platform??"ios"};let t=e.onLog??(i=>console.log(`[flow] js: ${i}`)),r={output:this.output,maestro:this.maestro,http:{get:(i,o)=>G(i,"GET",o),post:(i,o)=>G(i,"POST",o),put:(i,o)=>G(i,"PUT",o),delete:(i,o)=>G(i,"DELETE",o),request:(i,o)=>G(i,(o?.method??"GET").toUpperCase(),o)},console:{log:(...i)=>t(i.map(o=>typeof o=="string"?o:ht(o)).join(" "))}};this.context=C.createContext(r),C.runInContext(`
205
205
  globalThis.__maestroScope = new Proxy(globalThis, {
206
206
  has() { return true },
207
207
  get(target, key) { return target[key] },
@@ -212,7 +212,7 @@ process.stdin.on('end', async () => {
212
212
  var yPercent = Math.ceil(y * 100) + '%'
213
213
  return xPercent + ',' + yPercent
214
214
  }
215
- `,this.context);for(let[i,o]of Object.entries(process.env))o!==void 0&&this.envBinding.set(i,o)}putEnv(e,t){this.envBinding.set(e,t)}setCopiedText(e){this.maestro.copiedText=e}enterEnvScope(){this.envScopeStack.push(new Map(this.envBinding))}leaveEnvScope(){let e=this.envScopeStack.pop();if(e){this.envBinding.clear();for(let[t,r]of e)this.envBinding.set(t,r)}}evaluate(e,t={}){let r=t.env;if(r&&Object.keys(r).length>0){this.enterEnvScope();try{for(let[i,o]of Object.entries(r))this.envBinding.set(i,o);return this.evalRaw(e)}finally{this.leaveEnvScope()}}return this.evalRaw(e)}evalRaw(e){this.syncEnvToContext();let t=e.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\$\{/g,"\\${");return N.runInContext(`(function(){ with(__maestroScope){ return eval(\`${t}\`) } })()`,this.context)}syncEnvToContext(){let e=N.runInContext("globalThis",this.context);for(let t of this.syncedEnvKeys)this.envBinding.has(t)||delete e[t];this.syncedEnvKeys=new Set;for(let[t,r]of this.envBinding)try{e[t]=r,this.syncedEnvKeys.add(t)}catch{}}evaluateStringTemplate(e){return e.replace(Nt,(r,i)=>{if(i.trim().length===0)return"";let o=this.evaluate(i);if(o===void 0&&Ht.test(i.trim()))throw new Error(`missing variable for flow placeholder: ${i.trim()}`);return pt(o)}).replace(Ct,(r,i)=>i)}interpolateStep(e){return this.interpolateValue(e,null)}interpolateValue(e,t){return typeof e=="string"?t==="evalScript"?e:this.evaluateStringTemplate(e):Array.isArray(e)?t==="commands"||t==="onFlowStart"||t==="onFlowComplete"?e:e.map(r=>this.interpolateValue(r,t)):e&&typeof e=="object"?Object.fromEntries(Object.entries(e).map(([r,i])=>[r,this.interpolateValue(i,r)])):e}};function pt(n){if(n===void 0)return"undefined";if(n===null)return"null";if(typeof n=="object")try{return JSON.stringify(n)}catch{return String(n)}return String(n)}function ht(n){if(n==null)return!1;if(typeof n=="boolean")return n;let e=String(n);if(e.trim().length===0||e.toLowerCase()==="false"||e==="undefined"||e==="null")return!1;let t=Number(e);return!(!Number.isNaN(t)&&t===0)}var ee=1e4,Ut=Math.min(10,Math.max(1,Number(process.env.SOOTSIM_FLOW_TIMEOUT_SCALE)||1)),K=n=>Math.round(n*Ut),re=393,C=852;function f(n){return new Promise(e=>setTimeout(e,n))}function Te(n){return!!(n&&typeof n=="object"&&!Array.isArray(n))}function q(n,e){if(!Te(n))return null;let t=n[e];return typeof t=="string"&&t.length>0?t:null}function Wt(n,e){return Te(n)?n[e]===!0:!1}function jt(n){if(!n)return null;let e=n.recentApps;if(Array.isArray(e))for(let r of e){let i=q(r,"id");if(i)return i}let t=n.surfaceBindings;return q(t,"app:one")||q(t,"app:two")||null}function Vt(n){return n?S.basename(n)===".maestro"?S.dirname(n):n:process.cwd()}function Jt(n,e,t){let r=e.endsWith(".png")?e:`${e}.png`;if(S.isAbsolute(r))return r;if(t.mode==="flow"&&/[\\/]/.test(r)){let i=r.startsWith("./")||r.startsWith("../")?t.flowDir??process.cwd():Vt(t.flowDir);return S.resolve(i,r)}return S.join(n,r)}function Gt(n){if(typeof n=="string")return{path:n,withFrame:!1};let e=n.path?.trim()||n.name?.trim();if(!e)throw new Error("takeScreenshot object form requires path or name");return{path:e,withFrame:n.withFrame===!0,layers:n.layers}}function te(n,e){let[t,r]=n.split(",").map(s=>s.trim()),i=(s,l)=>s.endsWith("%")?Number.parseFloat(s)/100*l:Number.parseFloat(s),o=e?.x??0,a=e?.y??0;return{x:o+i(t,e?.width??re),y:a+i(r,e?.height??C)}}function ft(n){switch(n){case"back":return{back:!0};case"hideKeyboard":return{hideKeyboard:!0};case"waitForAnimationToEnd":return{waitForAnimationToEnd:!0};case"stopApp":return{stopApp:!0};case"clearState":return{clearState:!0};case"clearKeychain":return{clearKeychain:!0};case"eraseText":return{eraseText:50};case"scroll":case"scrollDown":return{scroll:{direction:"DOWN"}};case"scrollUp":return{scroll:{direction:"UP"}};default:return{[n]:!0}}}function Kt(n){let e=n.split(/^---$/m),t=e.length>1?e[e.length-1]:n,r=qe.parse(t);return Array.isArray(r)?r:[]}var ie=class{constructor(e,t){this.bridge=e;this.opts=t}stepDelay=0;js=new Q({platform:"ios",onLog:e=>console.log(`[flow] js: ${e}`)});firstLaunchDone=!1;profilingEnabled=!1;recordingEnabled=!1;recordingAccessChecked=!1;recordingStartedAtMs=null;lastRecordingStartedAtMs=null;lastRecordingDurationMs=null;lastRecordingFrameStats=null;flowTraceSteps=[];lastVisualSettledAtMs=0;simRouteHint=null;lastFailedStep=null;get simId(){return this.opts.simId}setSimRouteHint(e){this.simRouteHint=this.normalizeSimRoute(e)}normalizeSimRoute(e){if(!e)return null;try{let t=new URL(e);t.searchParams.delete("inspectOpen");let r=t.searchParams.toString();return`${t.origin}${t.pathname}${r?`?${r}`:""}`}catch{return e}}async refreshSimId(){if(this.opts.simId)try{let e=await this.bridge.listSims(),t=e.find(l=>l.id===this.opts.simId);if(t&&(this.simRouteHint=this.normalizeSimRoute(t.url||t.origin)),e.find(l=>l.id===this.opts.simId&&l.readyState==="open")||!this.simRouteHint)return;let i=this.simRouteHint&&e.find(l=>l.readyState==="open"&&this.normalizeSimRoute(l.url||l.origin)===this.simRouteHint);if(!i)return;let o=e.find(l=>l.isPrimary&&l.readyState==="open"),a=e.find(l=>l.readyState==="open"),s=i??o??a;s&&(this.opts.simId=s.id,console.log(` [flow] sim rotated to ${s.id}`))}catch{}}async evaluate(e,t){return this.bridge.send({type:"evaluate",simId:this.opts.simId,code:e},t?{timeoutMs:t}:void 0)}async callTest(e,...t){return this.bridge.send({type:"call",simId:this.opts.simId,path:`__sootsimTest.${e}`,args:t})}async perform(e){return this.bridge.send({type:"perform",simId:this.opts.simId,steps:e})}async waitForTree(e=ee){let t=Date.now()+K(e),r=Date.now(),i=null,o=0,a=0,s=-1,l=r;for(;Date.now()<t;){try{let u=await this.evaluate(He,8e3);if(o=0,u?.externalError)throw new Error(`app failed to load: ${u.externalError}`);if(u){let g=Date.now();u.nodes!==s&&(s=u.nodes,l=g);let b=u.flag===!0&&je(u),m=u.flag!==!0&&Ve(u);if((b||m)&&u.externalReady!==!1&&!u.externalError&&!u.loadingText&&g-l>=Ue)return}}catch(u){if(i=u instanceof Error?u:new Error(String(u)),i.message.startsWith("app failed to load:"))throw i;if(o++,o>=4)throw new Error(`target sim is not responding to the bridge (${i.message}). it is likely a stale orphan \u2014 run \`rnxsim list\`, then close it with \`rnxsim close <id>\` or start a fresh one with \`rnxsim open --new <port>\`.`);await this.refreshSimId()}let p=Date.now()-r;p-a>=5e3&&(a=p,console.log(` [flow] waiting for app to be ready\u2026 (${Math.round(p/1e3)}s)`)),await f(We)}throw i?.message.startsWith("app failed to load:")?i:new Error(`app not ready after ${e}ms`)}async ensureRecordingStarted(){if(!this.opts.recordingOutputDir)throw new Error("recording output directory not configured");this.recordingAccessChecked||(this.opts.requireRecordingEntitlement&&await lt("flow --video",{originOverride:this.opts.billingOriginOverride,allowGitHubAuth:this.opts.allowGitHubRecording}),this.recordingAccessChecked=!0);let e=Date.now(),t=await this.evaluate(`(() => {
215
+ `,this.context);for(let[i,o]of Object.entries(process.env))o!==void 0&&this.envBinding.set(i,o)}putEnv(e,t){this.envBinding.set(e,t)}setCopiedText(e){this.maestro.copiedText=e}enterEnvScope(){this.envScopeStack.push(new Map(this.envBinding))}leaveEnvScope(){let e=this.envScopeStack.pop();if(e){this.envBinding.clear();for(let[t,r]of e)this.envBinding.set(t,r)}}evaluate(e,t={}){let r=t.env;if(r&&Object.keys(r).length>0){this.enterEnvScope();try{for(let[i,o]of Object.entries(r))this.envBinding.set(i,o);return this.evalRaw(e)}finally{this.leaveEnvScope()}}return this.evalRaw(e)}evalRaw(e){this.syncEnvToContext();let t=e.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\$\{/g,"\\${");return C.runInContext(`(function(){ with(__maestroScope){ return eval(\`${t}\`) } })()`,this.context)}syncEnvToContext(){let e=C.runInContext("globalThis",this.context);for(let t of this.syncedEnvKeys)this.envBinding.has(t)||delete e[t];this.syncedEnvKeys=new Set;for(let[t,r]of this.envBinding)try{e[t]=r,this.syncedEnvKeys.add(t)}catch{}}evaluateStringTemplate(e){return e.replace(Nt,(r,i)=>{if(i.trim().length===0)return"";let o=this.evaluate(i);if(o===void 0&&Ut.test(i.trim()))throw new Error(`missing variable for flow placeholder: ${i.trim()}`);return ht(o)}).replace(Ht,(r,i)=>i)}interpolateStep(e){return this.interpolateValue(e,null)}interpolateValue(e,t){return typeof e=="string"?t==="evalScript"?e:this.evaluateStringTemplate(e):Array.isArray(e)?t==="commands"||t==="onFlowStart"||t==="onFlowComplete"?e:e.map(r=>this.interpolateValue(r,t)):e&&typeof e=="object"?Object.fromEntries(Object.entries(e).map(([r,i])=>[r,this.interpolateValue(i,r)])):e}};function ht(n){if(n===void 0)return"undefined";if(n===null)return"null";if(typeof n=="object")try{return JSON.stringify(n)}catch{return String(n)}return String(n)}function ft(n){if(n==null)return!1;if(typeof n=="boolean")return n;let e=String(n);if(e.trim().length===0||e.toLowerCase()==="false"||e==="undefined"||e==="null")return!1;let t=Number(e);return!(!Number.isNaN(t)&&t===0)}var ee=1e4,Wt=Math.min(10,Math.max(1,Number(process.env.SOOTSIM_FLOW_TIMEOUT_SCALE)||1)),K=n=>Math.round(n*Wt),re=393,N=852;function f(n){return new Promise(e=>setTimeout(e,n))}function Te(n){return!!(n&&typeof n=="object"&&!Array.isArray(n))}function q(n,e){if(!Te(n))return null;let t=n[e];return typeof t=="string"&&t.length>0?t:null}function jt(n,e){return Te(n)?n[e]===!0:!1}function Vt(n){if(!n)return null;let e=n.recentApps;if(Array.isArray(e))for(let r of e){let i=q(r,"id");if(i)return i}let t=n.surfaceBindings;return q(t,"app:one")||q(t,"app:two")||null}function Jt(n){return n?S.basename(n)===".maestro"?S.dirname(n):n:process.cwd()}function Gt(n,e,t){let r=e.endsWith(".png")?e:`${e}.png`;if(S.isAbsolute(r))return r;if(t.mode==="flow"&&/[\\/]/.test(r)){let i=r.startsWith("./")||r.startsWith("../")?t.flowDir??process.cwd():Jt(t.flowDir);return S.resolve(i,r)}return S.join(n,r)}function Kt(n){if(typeof n=="string")return{path:n,withFrame:!1};let e=n.path?.trim()||n.name?.trim();if(!e)throw new Error("takeScreenshot object form requires path or name");return{path:e,withFrame:n.withFrame===!0,layers:n.layers}}function te(n,e){let[t,r]=n.split(",").map(s=>s.trim()),i=(s,l)=>s.endsWith("%")?Number.parseFloat(s)/100*l:Number.parseFloat(s),o=e?.x??0,a=e?.y??0;return{x:o+i(t,e?.width??re),y:a+i(r,e?.height??N)}}function mt(n){switch(n){case"back":return{back:!0};case"hideKeyboard":return{hideKeyboard:!0};case"waitForAnimationToEnd":return{waitForAnimationToEnd:!0};case"stopApp":return{stopApp:!0};case"clearState":return{clearState:!0};case"clearKeychain":return{clearKeychain:!0};case"eraseText":return{eraseText:50};case"scroll":case"scrollDown":return{scroll:{direction:"DOWN"}};case"scrollUp":return{scroll:{direction:"UP"}};default:return{[n]:!0}}}function qt(n){let e=n.split(/^---$/m),t=e.length>1?e[e.length-1]:n,r=Ye.parse(t);return Array.isArray(r)?r:[]}var ie=class{constructor(e,t){this.bridge=e;this.opts=t}stepDelay=0;js=new Q({platform:"ios",onLog:e=>console.log(`[flow] js: ${e}`)});firstLaunchDone=!1;profilingEnabled=!1;recordingEnabled=!1;recordingAccessChecked=!1;recordingStartedAtMs=null;lastRecordingStartedAtMs=null;lastRecordingDurationMs=null;lastRecordingFrameStats=null;flowTraceSteps=[];lastVisualSettledAtMs=0;simRouteHint=null;lastFailedStep=null;get simId(){return this.opts.simId}setSimRouteHint(e){this.simRouteHint=this.normalizeSimRoute(e)}normalizeSimRoute(e){if(!e)return null;try{let t=new URL(e);t.searchParams.delete("inspectOpen");let r=t.searchParams.toString();return`${t.origin}${t.pathname}${r?`?${r}`:""}`}catch{return e}}async refreshSimId(){if(this.opts.simId)try{let e=await this.bridge.listSims(),t=e.find(l=>l.id===this.opts.simId);if(t&&(this.simRouteHint=this.normalizeSimRoute(t.url||t.origin)),e.find(l=>l.id===this.opts.simId&&l.readyState==="open")||!this.simRouteHint)return;let i=this.simRouteHint&&e.find(l=>l.readyState==="open"&&this.normalizeSimRoute(l.url||l.origin)===this.simRouteHint);if(!i)return;let o=e.find(l=>l.isPrimary&&l.readyState==="open"),a=e.find(l=>l.readyState==="open"),s=i??o??a;s&&(this.opts.simId=s.id,console.log(` [flow] sim rotated to ${s.id}`))}catch{}}async evaluate(e,t){return this.bridge.send({type:"evaluate",simId:this.opts.simId,code:e},t?{timeoutMs:t}:void 0)}async callTest(e,...t){return this.bridge.send({type:"call",simId:this.opts.simId,path:`__sootsimTest.${e}`,args:t})}async perform(e){return this.bridge.send({type:"perform",simId:this.opts.simId,steps:e})}async waitForTree(e=ee){let t=Date.now()+K(e),r=Date.now(),i=null,o=0,a=0,s=-1,l=r;for(;Date.now()<t;){try{let u=await this.evaluate(Ue,8e3);if(o=0,u?.externalError)throw new Error(`app failed to load: ${u.externalError}`);if(u){let g=Date.now();u.nodes!==s&&(s=u.nodes,l=g);let b=u.flag===!0&&Ve(u),m=u.flag!==!0&&Je(u);if((b||m)&&u.externalReady!==!1&&!u.externalError&&!u.loadingText&&g-l>=We)return}}catch(u){if(i=u instanceof Error?u:new Error(String(u)),i.message.startsWith("app failed to load:"))throw i;if(o++,o>=4)throw new Error(`target sim is not responding to the bridge (${i.message}). it is likely a stale orphan \u2014 run \`rnxsim list\`, then close it with \`rnxsim close <id>\` or start a fresh one with \`rnxsim open --new <port>\`.`);await this.refreshSimId()}let p=Date.now()-r;p-a>=5e3&&(a=p,console.log(` [flow] waiting for app to be ready\u2026 (${Math.round(p/1e3)}s)`)),await f(je)}throw i?.message.startsWith("app failed to load:")?i:new Error(`app not ready after ${e}ms`)}async ensureRecordingStarted(){if(!this.opts.recordingOutputDir)throw new Error("recording output directory not configured");this.recordingAccessChecked||(this.opts.requireRecordingEntitlement&&await dt("flow --video",{originOverride:this.opts.billingOriginOverride,allowGitHubAuth:this.opts.allowGitHubRecording}),this.recordingAccessChecked=!0);let e=Date.now(),t=await this.evaluate(`(() => {
216
216
  const rec = window.__sootsimRecorder
217
217
  if (!rec) return { ok: false, error: 'recorder unavailable on this page' }
218
218
  const format = ${JSON.stringify(this.opts.recordingFormat??"webm")}
@@ -295,7 +295,7 @@ process.stdin.on('end', async () => {
295
295
  // resolves a target that needs scrolling into view.
296
296
  const onScreen = candidates.filter((n) => {
297
297
  const cy = n.absolutePosition.y + n.layout.height / 2
298
- return cy > 0 && cy < ${C}
298
+ return cy > 0 && cy < ${N}
299
299
  })
300
300
  if (onScreen.length > 0) candidates = onScreen
301
301
  ${e.childOf?`
@@ -367,7 +367,7 @@ process.stdin.on('end', async () => {
367
367
  )
368
368
  }
369
369
  return direct
370
- })()`)}async tap(e,t,r){return await this.bridge.send({type:"tap",simId:this.opts.simId,x:e,y:t,target:r})}async longPress(e,t,r,i){return await this.bridge.send({type:"longPress",simId:this.opts.simId,x:e,y:t,durationMs:r,target:i})}async waitForElement(e,t=5e3){let r=Date.now()+t,i=await this.findElement(e);for(;!i&&Date.now()<r;)await f(150),i=await this.findElement(e);if(!i)return i;let o=Date.now()+1200,a=i;for(;Date.now()<o;){await f(120);let s=await this.findElement(e);if(!s)break;let l=Math.abs(s.absolutePosition.x-a.absolutePosition.x)>.5||Math.abs(s.absolutePosition.y-a.absolutePosition.y)>.5||Math.abs(s.layout.width-a.layout.width)>.5||Math.abs(s.layout.height-a.layout.height)>.5;if(i=s,!l)return i;a=s}return i}replayTargetForElement(e,t,r){return{id:e.id??r?.target?.id??t.id??null,testID:e.id??r?.target?.testID??t.testID??null,text:e.text??r?.target?.text??r?.target?.accessibilityLabel??t.text??t.accessibilityLabel??null,type:r?.target?.type??t.type??null}}async resolveInteractionPoint(e){if(e.point&&!e.id&&!e.text&&e.index===void 0&&!e.childOf)return{...te(e.point),element:null,target:void 0};let t=await this.waitForElement(e);if(!t)return null;let r=typeof t.nodeId=="number"?await this.resolveTapTarget(t.nodeId):null,i=this.replayTargetForElement(e,t,r);return e.point?{...te(e.point,{x:t.absolutePosition.x,y:t.absolutePosition.y,width:t.layout.width,height:t.layout.height}),element:t,target:i}:{x:r?.cx??t.absolutePosition.x+t.layout.width/2,y:r?.cy??t.absolutePosition.y+t.layout.height/2,element:t,target:i}}async tapOn(e){let t=typeof e=="string"?{text:e}:e;if(t.point){let o=await this.resolveInteractionPoint(t);if(!o)throw new Error(`tapOn: element not found: ${JSON.stringify(t)}`);(await this.activatePressAt(o.x,o.y))?.ok||await this.tap(o.x,o.y,o.target),await f(300);return}let r=await this.waitForElement(t);if(r){let o=r.isTextInput?4:1;for(let a=0;a<o;a++){let s=a===0?r:await this.findElement({text:t.text,id:t.id});if(!s)break;let l=typeof s.nodeId=="number"?await this.resolveTapTarget(s.nodeId):null,p=l?.cx??s.absolutePosition.x+s.layout.width/2,u=l?.cy??s.absolutePosition.y+s.layout.height/2;if((await this.tap(p,u,this.replayTargetForElement(t,s,l)))?.hit===!0){if(await f(300),!s.isTextInput||await this.waitForFocusedTextInput(600,s))return;continue}break}}if((await this.activatePressTarget(t))?.ok){await f(300);return}throw new Error(`tapOn: element not found: ${JSON.stringify(t)}`)}async longPressOn(e){let t=typeof e=="string"?{text:e}:e,r=await this.resolveInteractionPoint(t);if(!r)throw new Error(`longPressOn: element not found: ${JSON.stringify(t)}`);let i=await this.longPress(r.x,r.y,3e3,r.target);if(i?.ok===!1||i?.value===!1)throw new Error(`longPressOn: long press missed: ${JSON.stringify(t)}`);await f(300)}async tapAtCoords(e,t){await this.tap(e,t),await f(300)}async doubleTapAtCoords(e,t,r=80){let i=await this.perform([{type:"doubleTap",x:e,y:t,gapMs:Math.max(0,Math.round(r))}]);if(!i?.ok)throw new Error(`doubleTapAtCoords failed at (${e}, ${t}): ${i?.error??"double tap missed"}`);await f(300)}async assertVisible(e){let t=typeof e=="string"?{text:e}:e;for(let o=0;o<15;o++){if(await this.isElementVisible(t))return;await f(200)}let r=await this.findElement(t),i=r?` (matched node at y=${Math.round(r.absolutePosition.y)} h=${Math.round(r.layout.height)} \u2014 off-screen)`:" (no matching node in tree)";throw new Error(`assertVisible: ${JSON.stringify(t)} not visible${i}`)}async assertNotVisible(e){let t=typeof e=="string"?{text:e}:e;if(await this.isElementVisible(t)){let r=await this.findElement(t),i=r?` at (${Math.round(r.absolutePosition.x)},${Math.round(r.absolutePosition.y)})`:"";throw new Error(`assertNotVisible: ${JSON.stringify(t)} IS visible${i}`)}}async isElementVisible(e){let t=await this.findElement(e);return!!(t&&t.absolutePosition.y+t.layout.height>0&&t.absolutePosition.y<C)}async inputText(e){if(!await this.waitForFocusedTextInput())throw new Error("inputText: no focused TextInput; tap the input and wait for focus before typing");await this.bridge.send({type:"keyboard",simId:this.opts.simId,action:"type",text:e}),await f(200)}focusedTextInputMatches(e,t){if(!t||typeof t.nodeId=="number"&&typeof e.nodeId=="number"&&t.nodeId===e.nodeId)return!0;let r=t.testID??null,i=e.testID??null;if(r&&i&&r===i)return!0;let o=t.id??null,a=e.id??null;return!!(o&&a&&o===a)}async waitForFocusedTextInput(e=1500,t){let r=Date.now()+e;for(;Date.now()<r;){try{let i=await this.callTest("getFocusedNode");if(i&&this.focusedTextInputMatches(i,t))return!0}catch{}await f(50)}return!1}async pressKey(e){await this.bridge.send({type:"keyboard",simId:this.opts.simId,action:"press",text:e}),await f(120)}async dispatchKey(e){await this.bridge.send({type:"keyboard",simId:this.opts.simId,action:"dispatchKey",text:e}),await f(120)}async hideKeyboard(){try{await this.callTest("blurFocusedTextInput")}catch{}await this.bridge.send({type:"keyboard",simId:this.opts.simId,action:"dismiss"});let e=Date.now()+3e3;for(;Date.now()<e;){let t=await this.evaluate(`(() => {
370
+ })()`)}async tap(e,t,r){return await this.bridge.send({type:"tap",simId:this.opts.simId,x:e,y:t,target:r})}async longPress(e,t,r,i){return await this.bridge.send({type:"longPress",simId:this.opts.simId,x:e,y:t,durationMs:r,target:i})}async waitForElement(e,t=5e3){let r=Date.now()+t,i=await this.findElement(e);for(;!i&&Date.now()<r;)await f(150),i=await this.findElement(e);if(!i)return i;let o=Date.now()+1200,a=i;for(;Date.now()<o;){await f(120);let s=await this.findElement(e);if(!s)break;let l=Math.abs(s.absolutePosition.x-a.absolutePosition.x)>.5||Math.abs(s.absolutePosition.y-a.absolutePosition.y)>.5||Math.abs(s.layout.width-a.layout.width)>.5||Math.abs(s.layout.height-a.layout.height)>.5;if(i=s,!l)return i;a=s}return i}replayTargetForElement(e,t,r){return{id:e.id??r?.target?.id??t.id??null,testID:e.id??r?.target?.testID??t.testID??null,text:e.text??r?.target?.text??r?.target?.accessibilityLabel??t.text??t.accessibilityLabel??null,type:r?.target?.type??t.type??null}}async resolveInteractionPoint(e){if(e.point&&!e.id&&!e.text&&e.index===void 0&&!e.childOf)return{...te(e.point),element:null,target:void 0};let t=await this.waitForElement(e);if(!t)return null;let r=typeof t.nodeId=="number"?await this.resolveTapTarget(t.nodeId):null,i=this.replayTargetForElement(e,t,r);return e.point?{...te(e.point,{x:t.absolutePosition.x,y:t.absolutePosition.y,width:t.layout.width,height:t.layout.height}),element:t,target:i}:{x:r?.cx??t.absolutePosition.x+t.layout.width/2,y:r?.cy??t.absolutePosition.y+t.layout.height/2,element:t,target:i}}async tapOn(e){let t=typeof e=="string"?{text:e}:e;if(t.point){let o=await this.resolveInteractionPoint(t);if(!o)throw new Error(`tapOn: element not found: ${JSON.stringify(t)}`);(await this.activatePressAt(o.x,o.y))?.ok||await this.tap(o.x,o.y,o.target),await f(300);return}let r=await this.waitForElement(t);if(r){let o=r.isTextInput?4:1;for(let a=0;a<o;a++){let s=a===0?r:await this.findElement({text:t.text,id:t.id});if(!s)break;let l=typeof s.nodeId=="number"?await this.resolveTapTarget(s.nodeId):null,p=l?.cx??s.absolutePosition.x+s.layout.width/2,u=l?.cy??s.absolutePosition.y+s.layout.height/2;if((await this.tap(p,u,this.replayTargetForElement(t,s,l)))?.hit===!0){if(await f(300),!s.isTextInput||await this.waitForFocusedTextInput(600,s))return;continue}break}}if((await this.activatePressTarget(t))?.ok){await f(300);return}throw new Error(`tapOn: element not found: ${JSON.stringify(t)}`)}async longPressOn(e){let t=typeof e=="string"?{text:e}:e,r=await this.resolveInteractionPoint(t);if(!r)throw new Error(`longPressOn: element not found: ${JSON.stringify(t)}`);let i=await this.longPress(r.x,r.y,3e3,r.target);if(i?.ok===!1||i?.value===!1)throw new Error(`longPressOn: long press missed: ${JSON.stringify(t)}`);await f(300)}async tapAtCoords(e,t){await this.tap(e,t),await f(300)}async doubleTapAtCoords(e,t,r=80){let i=await this.perform([{type:"doubleTap",x:e,y:t,gapMs:Math.max(0,Math.round(r))}]);if(!i?.ok)throw new Error(`doubleTapAtCoords failed at (${e}, ${t}): ${i?.error??"double tap missed"}`);await f(300)}async assertVisible(e){let t=typeof e=="string"?{text:e}:e;for(let o=0;o<15;o++){if(await this.isElementVisible(t))return;await f(200)}let r=await this.findElement(t),i=r?` (matched node at y=${Math.round(r.absolutePosition.y)} h=${Math.round(r.layout.height)} \u2014 off-screen)`:" (no matching node in tree)";throw new Error(`assertVisible: ${JSON.stringify(t)} not visible${i}`)}async assertNotVisible(e){let t=typeof e=="string"?{text:e}:e;if(await this.isElementVisible(t)){let r=await this.findElement(t),i=r?` at (${Math.round(r.absolutePosition.x)},${Math.round(r.absolutePosition.y)})`:"";throw new Error(`assertNotVisible: ${JSON.stringify(t)} IS visible${i}`)}}async isElementVisible(e){let t=await this.findElement(e);return!!(t&&t.absolutePosition.y+t.layout.height>0&&t.absolutePosition.y<N)}async inputText(e){if(!await this.waitForFocusedTextInput())throw new Error("inputText: no focused TextInput; tap the input and wait for focus before typing");await this.bridge.send({type:"keyboard",simId:this.opts.simId,action:"type",text:e}),await f(200)}focusedTextInputMatches(e,t){if(!t||typeof t.nodeId=="number"&&typeof e.nodeId=="number"&&t.nodeId===e.nodeId)return!0;let r=t.testID??null,i=e.testID??null;if(r&&i&&r===i)return!0;let o=t.id??null,a=e.id??null;return!!(o&&a&&o===a)}async waitForFocusedTextInput(e=1500,t){let r=Date.now()+e;for(;Date.now()<r;){try{let i=await this.callTest("getFocusedNode");if(i&&this.focusedTextInputMatches(i,t))return!0}catch{}await f(50)}return!1}async pressKey(e){await this.bridge.send({type:"keyboard",simId:this.opts.simId,action:"press",text:e}),await f(120)}async dispatchKey(e){await this.bridge.send({type:"keyboard",simId:this.opts.simId,action:"dispatchKey",text:e}),await f(120)}async hideKeyboard(){try{await this.callTest("blurFocusedTextInput")}catch{}await this.bridge.send({type:"keyboard",simId:this.opts.simId,action:"dismiss"});let e=Date.now()+3e3;for(;Date.now()<e;){let t=await this.evaluate(`(() => {
371
371
  const keyboard =
372
372
  window.__sootsimKeyboard ??
373
373
  window.SootSim?.bridges?.keyboard ??
@@ -377,7 +377,7 @@ process.stdin.on('end', async () => {
377
377
  visible: !!keyboard?.isVisible?.(),
378
378
  focused: !!test?.isTextInputFocused?.(),
379
379
  }
380
- })()`);if(!t?.visible&&!t?.focused){await f(80);return}await f(80)}}async eraseText(e){for(let t=0;t<e;t++)await this.bridge.send({type:"keyboard",simId:this.opts.simId,action:"dispatchKey",text:"Backspace"});await f(100)}async waitFor(e){let t=Date.now()+K(e.timeout||ee);for(;Date.now()<t;){if(await this.findElement(e))return;await f(200)}let r=await this.findElement(e),i=r?` (matched node y=${Math.round(r.absolutePosition.y)} \u2014 still off-screen at deadline)`:"";throw new Error(`waitFor: ${JSON.stringify(e)} not found after ${e.timeout||ee}ms${i}`)}async takeScreenshot(e){if(!this.hasFreshVisualSettle())try{await this.waitForVisualSettle(),await f(250)}catch{}let t=Gt(e),r=Jt(this.opts.screenshotDir,t.path,{mode:this.opts.screenshotPathMode??"dir",flowDir:this.opts.flowDir});x.mkdirSync(S.dirname(r),{recursive:!0});let i=t.layers??this.opts.screenshotLayers,o={type:"screenshot",simId:this.opts.simId};i&&i!=="full"&&(o.layers=i);let s=(await this.bridge.send(o)).replace(/^data:image\/png;base64,/,""),l=Buffer.from(s,"base64");if(t.withFrame){let p=await this.readCurrentDeviceModel();if(!p)throw new Error("could not read current device model for framed screenshot");let u=await ut(l,p);return x.writeFileSync(r,u),console.log(`[flow] screenshot: ${r} (frame: ${p})`),r}return x.writeFileSync(r,l),console.log(`[flow] screenshot: ${r}`),r}async readCurrentDeviceModel(){let e=await this.bridge.send({type:"call",simId:this.opts.simId,path:"SootSim.bridges.settings.get",args:[]}),t=e&&typeof e.deviceModel=="string"?e.deviceModel:null;return!t||!(t in Be)?null:t}async captureScreenshot(e){x.mkdirSync(S.dirname(e),{recursive:!0});let r=(await this.bridge.send({type:"screenshot",simId:this.opts.simId})).replace(/^data:image\/png;base64,/,"");x.writeFileSync(e,Buffer.from(r,"base64"))}async captureFailureBundle(e,t){x.mkdirSync(e,{recursive:!0});let r=(u,g)=>{try{x.writeFileSync(S.join(e,u),g)}catch{}},i=async u=>{try{return await this.bridge.send({type:"evaluate",simId:this.opts.simId,code:u})}catch{return null}},o=await i(`(async () => {
380
+ })()`);if(!t?.visible&&!t?.focused){await f(80);return}await f(80)}}async eraseText(e){for(let t=0;t<e;t++)await this.bridge.send({type:"keyboard",simId:this.opts.simId,action:"dispatchKey",text:"Backspace"});await f(100)}async waitFor(e){let t=Date.now()+K(e.timeout||ee);for(;Date.now()<t;){if(await this.findElement(e))return;await f(200)}let r=await this.findElement(e),i=r?` (matched node y=${Math.round(r.absolutePosition.y)} \u2014 still off-screen at deadline)`:"";throw new Error(`waitFor: ${JSON.stringify(e)} not found after ${e.timeout||ee}ms${i}`)}async takeScreenshot(e){if(!this.hasFreshVisualSettle())try{await this.waitForVisualSettle(),await f(250)}catch{}let t=Kt(e),r=Gt(this.opts.screenshotDir,t.path,{mode:this.opts.screenshotPathMode??"dir",flowDir:this.opts.flowDir});x.mkdirSync(S.dirname(r),{recursive:!0});let i=t.layers??this.opts.screenshotLayers,o={type:"screenshot",simId:this.opts.simId};i&&i!=="full"&&(o.layers=i);let s=(await this.bridge.send(o)).replace(/^data:image\/png;base64,/,""),l=Buffer.from(s,"base64");if(t.withFrame){let p=await this.readCurrentDeviceModel();if(!p)throw new Error("could not read current device model for framed screenshot");let u=await pt(l,p);return x.writeFileSync(r,u),console.log(`[flow] screenshot: ${r} (frame: ${p})`),r}return x.writeFileSync(r,l),console.log(`[flow] screenshot: ${r}`),r}async readCurrentDeviceModel(){let e=await this.bridge.send({type:"call",simId:this.opts.simId,path:"SootSim.bridges.settings.get",args:[]}),t=e&&typeof e.deviceModel=="string"?e.deviceModel:null;return!t||!(t in Le)?null:t}async captureScreenshot(e){x.mkdirSync(S.dirname(e),{recursive:!0});let r=(await this.bridge.send({type:"screenshot",simId:this.opts.simId})).replace(/^data:image\/png;base64,/,"");x.writeFileSync(e,Buffer.from(r,"base64"))}async captureFailureBundle(e,t){x.mkdirSync(e,{recursive:!0});let r=(u,g)=>{try{x.writeFileSync(S.join(e,u),g)}catch{}},i=async u=>{try{return await this.bridge.send({type:"evaluate",simId:this.opts.simId,code:u})}catch{return null}},o=await i(`(async () => {
381
381
  const out = {
382
382
  simId: window.__sootsimBridge?.id ?? window.SootSim?.state?.simId ?? null,
383
383
  url: location.href,
@@ -418,7 +418,7 @@ process.stdin.on('end', async () => {
418
418
  warnings: c?.getWarnings?.() ?? [],
419
419
  requests: (window.__sootsimGetFailedRequests?.() ?? []),
420
420
  }
421
- })()`);return p&&r("console.json",JSON.stringify(p,null,2)),e}async swipe(e="UP",t=300){let r=re/2,i=C/2,o=200,a=r,s=i,l=r,p=i;switch(e.toUpperCase()){case"UP":s+=o,p-=o;break;case"DOWN":s-=o,p+=o;break;case"LEFT":a+=o,l-=o;break;case"RIGHT":a-=o,l+=o;break}let u=Math.max(10,Math.round(t/16));await this.drag(a,s,l,p,u,16)}async drag(e,t,r,i,o=12,a=16){let s=await this.perform([{type:"drag",fromX:e,fromY:t,toX:r,toY:i,steps:Math.max(1,Math.round(o)),stepMs:Math.max(0,Math.round(a))}]);if(!s?.ok)throw new Error(`drag failed: ${s?.error??"drag missed"}`);await f(300)}async swipeCoords(e,t,r=300){let i=te(e),o=te(t),a=Math.max(10,Math.round(r/16));await this.drag(i.x,i.y,o.x,o.y,a,16)}async swipeFrom(e,t="UP",r=300){let i=await this.findElement(e);if(!i)throw new Error(`swipeFrom: element not found: ${JSON.stringify(e)}`);let o=i.absolutePosition.x+i.layout.width/2,a=i.absolutePosition.y+i.layout.height/2,s=180,l=o,p=a;switch(t.toUpperCase()){case"UP":p-=s;break;case"DOWN":p+=s;break;case"LEFT":l-=s;break;case"RIGHT":l+=s;break}let u=Math.max(10,Math.round(r/16));await this.drag(o,a,l,p,u,16)}async scrollTo(e,t,r){let i=await this.callTest("scrollTo",e,t,r,!1);if(!i?.ok)throw new Error(`scrollTo failed: ${i?.reason||"unknown error"}`);await f(250)}async pinch(e){let t=await this.perform([{type:"pinch",fromX1:e.from[0],fromY1:e.from[1],fromX2:e.from[2],fromY2:e.from[3],toX1:e.to[0],toY1:e.to[1],toX2:e.to[2],toY2:e.to[3],steps:e.steps||12,stepMs:e.stepMs||16}]);if(!t?.ok)throw new Error(`pinch failed: ${t?.error||"unknown error"}`);await f(250)}async dumpTree(e=6){let t=await this.bridge.send({type:"tree",simId:this.opts.simId,depth:e});return console.log("[flow] tree:"),console.log(typeof t=="string"?t:JSON.stringify(t,null,2)),typeof t=="string"?t:JSON.stringify(t)}async assertTreeContains(e){if(!(await this.dumpTree(8)).includes(e))throw new Error(`assertTreeContains: "${e}" not in tree`)}async waitForAnimationToEnd(e=2e3){let t=Math.max(0,Math.round(e));if(t<=0)return;(await be({bridge:this.bridge,simId:this.opts.simId,maxMs:t,pollMs:32,stablePolls:2,strict:!0})).settled&&this.markVisualSettled()}async back(){try{await this.tapOn("\u2039")}catch{await this.tapOn("<")}}async scrollUntilVisible(e){let t=Date.now()+(e.timeout||15e3),r=e.direction?.toUpperCase()||"DOWN",i=r==="DOWN"?"UP":r==="UP"?"DOWN":r;for(;Date.now()<t;){let o=await this.findElement({text:e.element});if(o&&o.absolutePosition.y>=0&&o.absolutePosition.y+o.layout.height>0&&o.absolutePosition.y<C-50){if(e.centerElement){let a=C/2,s=o.absolutePosition.y-a;if(Math.abs(s)>100){let l=Math.min(150,Math.abs(s)*.5),p=s>0?a-l:a+l;await this.drag(re/2,a,re/2,p,10,16)}}return}await this.swipe(i,250),await f(500)}throw new Error(`scrollUntilVisible: "${e.element}" not found`)}async extendedWaitUntil(e){let t=Date.now()+K(e.timeout||ee);for(;Date.now()<t;){let r=e.visible?await this.isElementVisible(typeof e.visible=="string"?{text:e.visible}:e.visible):!0,i=e.notVisible?!await this.isElementVisible(typeof e.notVisible=="string"?{text:e.notVisible}:e.notVisible):!0;if(r&&i)return;await f(200)}throw new Error("extendedWaitUntil timed out")}async reloadGuestApp(){await this.evaluate("window.location.reload()").catch(()=>{}),await f(500),await this.refreshSimId()}async resetGuestAppData(){let e=await this.bridge.send({type:"reset",simId:this.opts.simId,resetOptions:{strategy:"data"}},{timeoutMs:12e4});if(!e.ok)throw new Error(e.error??"guest app data reset failed");if(!e.relaunched)throw new Error("guest app data reset did not relaunch the app");if(e.workerReloaded!==!0)throw new Error("guest app data reset did not replace the tenant worker")}async softReloadGuestApp(e){if(!await this.evaluate(Ke(e),12e4))throw new Error("guest app soft reload bridge unavailable")}async rearmCaptureAfterRuntimeReload(){if(!this.recordingEnabled&&!this.profilingEnabled)return;let e=Date.now()+1e4,t=null;for(;Date.now()<e;){await this.refreshSimId();try{this.recordingEnabled&&await this.ensureRecordingStarted(),this.profilingEnabled&&await this.startProfile();return}catch(r){t=r,await f(250)}}throw new Error(`capture re-arm failed after app reload: ${t instanceof Error?t.message:String(t)}`)}async launchApp(e){await this.refreshSimId(),e&&typeof e=="object"&&e.arguments&&console.log("[flow] launchApp.arguments ignored (rnx has no native process)");let t=!!(e&&typeof e=="object"&&e.clearState),r=Wt(e,"resetRuntime");if(!this.firstLaunchDone&&!t)this.firstLaunchDone=!0,r?(await this.launchShellAppFromHomeIfNeeded(e)&&await this.waitForTree(12e4),await this.softReloadGuestApp(!1),await this.waitForTree(12e4)):await this.launchShellAppFromHomeIfNeeded(e),await this.waitForTree(3e4);else if(this.firstLaunchDone=!0,t?await this.resetGuestAppData():await this.reloadGuestApp(),await this.waitForTree(12e4),this.opts.onAfterLaunch)try{await this.opts.onAfterLaunch()}catch(i){console.warn(` warn: onAfterLaunch hook threw: ${i instanceof Error?i.message:i}`)}this.profilingEnabled&&await this.startProfile(),this.recordingEnabled&&(await this.waitForVisualSettle(),await this.ensureRecordingStarted())}async waitForVisualSettle(){try{await this.evaluate(`new Promise((resolve) => {
421
+ })()`);return p&&r("console.json",JSON.stringify(p,null,2)),e}async swipe(e="UP",t=300){let r=re/2,i=N/2,o=200,a=r,s=i,l=r,p=i;switch(e.toUpperCase()){case"UP":s+=o,p-=o;break;case"DOWN":s-=o,p+=o;break;case"LEFT":a+=o,l-=o;break;case"RIGHT":a-=o,l+=o;break}let u=Math.max(10,Math.round(t/16));await this.drag(a,s,l,p,u,16)}async drag(e,t,r,i,o=12,a=16){let s=await this.perform([{type:"drag",fromX:e,fromY:t,toX:r,toY:i,steps:Math.max(1,Math.round(o)),stepMs:Math.max(0,Math.round(a))}]);if(!s?.ok)throw new Error(`drag failed: ${s?.error??"drag missed"}`);await f(300)}async swipeCoords(e,t,r=300){let i=te(e),o=te(t),a=Math.max(10,Math.round(r/16));await this.drag(i.x,i.y,o.x,o.y,a,16)}async swipeFrom(e,t="UP",r=300){let i=await this.findElement(e);if(!i)throw new Error(`swipeFrom: element not found: ${JSON.stringify(e)}`);let o=i.absolutePosition.x+i.layout.width/2,a=i.absolutePosition.y+i.layout.height/2,s=180,l=o,p=a;switch(t.toUpperCase()){case"UP":p-=s;break;case"DOWN":p+=s;break;case"LEFT":l-=s;break;case"RIGHT":l+=s;break}let u=Math.max(10,Math.round(r/16));await this.drag(o,a,l,p,u,16)}async scrollTo(e,t,r){let i=await this.callTest("scrollTo",e,t,r,!1);if(!i?.ok)throw new Error(`scrollTo failed: ${i?.reason||"unknown error"}`);await f(250)}async pinch(e){let t=await this.perform([{type:"pinch",fromX1:e.from[0],fromY1:e.from[1],fromX2:e.from[2],fromY2:e.from[3],toX1:e.to[0],toY1:e.to[1],toX2:e.to[2],toY2:e.to[3],steps:e.steps||12,stepMs:e.stepMs||16}]);if(!t?.ok)throw new Error(`pinch failed: ${t?.error||"unknown error"}`);await f(250)}async dumpTree(e=6){let t=await this.bridge.send({type:"tree",simId:this.opts.simId,depth:e});return console.log("[flow] tree:"),console.log(typeof t=="string"?t:JSON.stringify(t,null,2)),typeof t=="string"?t:JSON.stringify(t)}async assertTreeContains(e){if(!(await this.dumpTree(8)).includes(e))throw new Error(`assertTreeContains: "${e}" not in tree`)}async waitForAnimationToEnd(e=2e3){let t=Math.max(0,Math.round(e));if(t<=0)return;(await be({bridge:this.bridge,simId:this.opts.simId,maxMs:t,pollMs:32,stablePolls:2,strict:!0})).settled&&this.markVisualSettled()}async back(){try{await this.tapOn("\u2039")}catch{await this.tapOn("<")}}async scrollUntilVisible(e){let t=Date.now()+(e.timeout||15e3),r=e.direction?.toUpperCase()||"DOWN",i=r==="DOWN"?"UP":r==="UP"?"DOWN":r;for(;Date.now()<t;){let o=await this.findElement({text:e.element});if(o&&o.absolutePosition.y>=0&&o.absolutePosition.y+o.layout.height>0&&o.absolutePosition.y<N-50){if(e.centerElement){let a=N/2,s=o.absolutePosition.y-a;if(Math.abs(s)>100){let l=Math.min(150,Math.abs(s)*.5),p=s>0?a-l:a+l;await this.drag(re/2,a,re/2,p,10,16)}}return}await this.swipe(i,250),await f(500)}throw new Error(`scrollUntilVisible: "${e.element}" not found`)}async extendedWaitUntil(e){let t=Date.now()+K(e.timeout||ee);for(;Date.now()<t;){let r=e.visible?await this.isElementVisible(typeof e.visible=="string"?{text:e.visible}:e.visible):!0,i=e.notVisible?!await this.isElementVisible(typeof e.notVisible=="string"?{text:e.notVisible}:e.notVisible):!0;if(r&&i)return;await f(200)}throw new Error("extendedWaitUntil timed out")}async reloadGuestApp(){await this.evaluate("window.location.reload()").catch(()=>{}),await f(500),await this.refreshSimId()}async resetGuestAppData(){let e=await this.bridge.send({type:"reset",simId:this.opts.simId,resetOptions:{strategy:"data"}},{timeoutMs:12e4});if(!e.ok)throw new Error(e.error??"guest app data reset failed");if(!e.relaunched)throw new Error("guest app data reset did not relaunch the app");if(e.workerReloaded!==!0)throw new Error("guest app data reset did not replace the tenant worker")}async softReloadGuestApp(e){if(!await this.evaluate(qe(e),12e4))throw new Error("guest app soft reload bridge unavailable")}async rearmCaptureAfterRuntimeReload(){if(!this.recordingEnabled&&!this.profilingEnabled)return;let e=Date.now()+1e4,t=null;for(;Date.now()<e;){await this.refreshSimId();try{this.recordingEnabled&&await this.ensureRecordingStarted(),this.profilingEnabled&&await this.startProfile();return}catch(r){t=r,await f(250)}}throw new Error(`capture re-arm failed after app reload: ${t instanceof Error?t.message:String(t)}`)}async launchApp(e){await this.refreshSimId(),e&&typeof e=="object"&&e.arguments&&console.log("[flow] launchApp.arguments ignored (rnx has no native process)");let t=!!(e&&typeof e=="object"&&e.clearState),r=jt(e,"resetRuntime");if(!this.firstLaunchDone&&!t)this.firstLaunchDone=!0,r?(await this.launchShellAppFromHomeIfNeeded(e)&&await this.waitForTree(12e4),await this.softReloadGuestApp(!1),await this.waitForTree(12e4)):await this.launchShellAppFromHomeIfNeeded(e),await this.waitForTree(3e4);else if(this.firstLaunchDone=!0,t?await this.resetGuestAppData():await this.reloadGuestApp(),await this.waitForTree(12e4),this.opts.onAfterLaunch)try{await this.opts.onAfterLaunch()}catch(i){console.warn(` warn: onAfterLaunch hook threw: ${i instanceof Error?i.message:i}`)}this.profilingEnabled&&await this.startProfile(),this.recordingEnabled&&(await this.waitForVisualSettle(),await this.ensureRecordingStarted())}async waitForVisualSettle(){try{await this.evaluate(`new Promise((resolve) => {
422
422
  requestAnimationFrame(() => {
423
423
  requestAnimationFrame(() => {
424
424
  requestAnimationFrame(() => {
@@ -426,7 +426,7 @@ process.stdin.on('end', async () => {
426
426
  })
427
427
  })
428
428
  })
429
- })`),this.markVisualSettled()}catch{await f(180),this.markVisualSettled()}}markVisualSettled(){this.lastVisualSettledAtMs=Date.now()}hasFreshVisualSettle(){return Date.now()-this.lastVisualSettledAtMs<750}resolveShellLaunchAppId(e,t){if(typeof e=="string"&&e.length>0)return e;if(Te(e)){let r=q(e,"appId")||q(e,"id");if(r)return r}return jt(t)||"connect"}async waitForShellAppLaunched(e,t){let r=Date.now()+t,i=null;for(;Date.now()<r;){try{i=await fe(this.bridge)}catch{i=null}if(i?.state==="app"&&i.activeApp===e&&i.showSwitcher===!1&&typeof i.launchProgress=="number"&&i.launchProgress>=.98)return;await f(16)}}async launchShellAppFromHomeIfNeeded(e){let t=null;try{t=await fe(this.bridge)}catch{return!1}if(t?.state!=="home"||t.activeApp!=null)return!1;let r=this.resolveShellLaunchAppId(e,t);return this.recordingEnabled&&await this.ensureRecordingStarted(),await Je(this.bridge,"launchApp",1e3,r),await this.waitForShellAppLaunched(r,1e3),!0}async startProfile(){let e=await this.evaluate(`(() => {
429
+ })`),this.markVisualSettled()}catch{await f(180),this.markVisualSettled()}}markVisualSettled(){this.lastVisualSettledAtMs=Date.now()}hasFreshVisualSettle(){return Date.now()-this.lastVisualSettledAtMs<750}resolveShellLaunchAppId(e,t){if(typeof e=="string"&&e.length>0)return e;if(Te(e)){let r=q(e,"appId")||q(e,"id");if(r)return r}return Vt(t)||"connect"}async waitForShellAppLaunched(e,t){let r=Date.now()+t,i=null;for(;Date.now()<r;){try{i=await fe(this.bridge)}catch{i=null}if(i?.state==="app"&&i.activeApp===e&&i.showSwitcher===!1&&typeof i.launchProgress=="number"&&i.launchProgress>=.98)return;await f(16)}}async launchShellAppFromHomeIfNeeded(e){let t=null;try{t=await fe(this.bridge)}catch{return!1}if(t?.state!=="home"||t.activeApp!=null)return!1;let r=this.resolveShellLaunchAppId(e,t);return this.recordingEnabled&&await this.ensureRecordingStarted(),await Ge(this.bridge,"launchApp",1e3,r),await this.waitForShellAppLaunched(r,1e3),!0}async startProfile(){let e=await this.evaluate(`(() => {
430
430
  if (!window.__sootsimShellPerf) {
431
431
  return { error: "shell frame profile unavailable (__sootsimShellPerf missing on the page)" }
432
432
  }
@@ -437,7 +437,7 @@ process.stdin.on('end', async () => {
437
437
  return { error: "shell frame profile unavailable (__sootsimShellPerf missing on the page)" }
438
438
  }
439
439
  return await window.__sootsimShellPerf.stop()
440
- })()`);if(this.profilingEnabled=!1,e?.error)throw new Error(e.error);return e}async stopApp(){await this.reloadGuestApp(),await this.rearmCaptureAfterRuntimeReload()}async clearState(){await this.resetGuestAppData(),await this.rearmCaptureAfterRuntimeReload()}clearKeychain(){console.warn("[flow] clearKeychain: rnx has no keychain surface \u2014 no-op (warning)")}async copyTextFrom(e){let t=typeof e=="string"?{id:e}:e,r=await this.findElement(t);if(!r)throw new Error(`copyTextFrom: element not found: ${JSON.stringify(t)}`);let i=r.text??r.testID??"";this.js.setCopiedText(i),this.js.putEnv("maestroCopiedText",i),console.log(`[flow] copied text: ${JSON.stringify(i)}`)}evalScript(e){let r=/(?<!\\)\$\{[^$]*\}/.test(e)?this.js.evaluateStringTemplate(e):this.js.evaluate(e);r!==void 0&&r!==""&&console.log("[flow] evalScript ->",r)}runScript(e){let t=typeof e=="string"?{file:e}:e;if(!t.file)throw new Error("runScript requires a file");let r=S.resolve(this.opts.flowDir,t.file),i=x.readFileSync(r,"utf8");this.js.evaluate(i,{env:t.env}),console.log(`[flow] runScript: ${t.file} done`)}async openLink(e){let t=typeof e=="string"?e:e.link;if(!t)throw new Error("openLink: missing link");let r=await this.callTest("openDeepLink",t);if(!r?.ok)throw new Error(`openLink failed: ${r?.error||"no test bridge"}`);await f(300)}async evaluateWhen(e){if(e.visible!==void 0){let t=typeof e.visible=="string"?{text:e.visible}:e.visible;return!!await this.findElement(t)}if(e.notVisible!==void 0){let t=typeof e.notVisible=="string"?{text:e.notVisible}:e.notVisible;return!await this.findElement(t)}return e.platform!==void 0?e.platform.toLowerCase()===this.js.maestro.platform.toLowerCase():e.true!==void 0?ht(e.true):!0}isOptional(e){if(e.optional===!0)return!0;let r=Object.entries(e).find(([o])=>o!=="when"&&o!=="optional"),i=r?r[1]:void 0;return!!(i&&typeof i=="object"&&"optional"in i&&i.optional)}async runStep(e,t){let r=typeof e=="string"?ft(e):e,i=Object.keys(r).find(l=>l!=="when")||Object.keys(r)[0];console.log(`[flow] step ${t+1}: ${i}`);let o=Date.now(),a=this.flowStepTargetLabel(r,i),s;try{s=this.js.interpolateStep(r),a=this.flowStepTargetLabel(s,i)??a}catch(l){if(this.isOptional(r)){console.log(`[flow] (optional, skipped: ${l.message.slice(0,80)})`),this.recordFlowTraceStep({stepIndex:t,stepName:i,targetLabel:a,startedAtMs:o,status:"skipped",error:l});return}throw this.lastFailedStep={index:t,kind:i,target:r[i]},this.recordFlowTraceStep({stepIndex:t,stepName:i,targetLabel:a,startedAtMs:o,status:"failure",error:l}),l}if(s.when&&!await this.evaluateWhen(s.when)){console.log("[flow] (when: predicate false, skipped)"),this.recordFlowTraceStep({stepIndex:t,stepName:i,targetLabel:a,startedAtMs:o,status:"skipped"});return}try{let l=!!(s.extendedWaitUntil||s.waitFor||s.scrollUntilVisible||s.launchApp||s.runFlow||s.runScript),p=1e4,u=this.runStepInner(s),g;if(l){let m=await u;typeof m=="string"&&(g=m)}else{let m=null,k=new Promise(($,H)=>{m=setTimeout(()=>{H(new Error(`step watchdog: ${i} made no progress in ${p}ms \u2014 bridge or bundle probably hung`))},p)});try{let $=await Promise.race([u,k]);typeof $=="string"&&(g=$)}finally{m&&clearTimeout(m)}}let b=!!(s.assertVisible||s.assertNotVisible||s.extendedWaitUntil||s.waitFor);this.stepDelay>0&&!b&&await f(this.stepDelay),this.recordFlowTraceStep({stepIndex:t,stepName:i,targetLabel:a,startedAtMs:o,status:"success",screenshotPath:g})}catch(l){if(this.isOptional(s)){console.log(`[flow] (optional, skipped: ${l.message.slice(0,80)})`),this.recordFlowTraceStep({stepIndex:t,stepName:i,targetLabel:a,startedAtMs:o,status:"skipped",error:l});return}throw this.lastFailedStep={index:t,kind:i,target:s[i]},this.recordFlowTraceStep({stepIndex:t,stepName:i,targetLabel:a,startedAtMs:o,status:"failure",error:l}),l}}async runStepInner(e){if(e.tapOn)await this.tapOn(e.tapOn);else if(e.longPressOn)await this.longPressOn(e.longPressOn);else if(e.scrollUntilVisible)await this.scrollUntilVisible(e.scrollUntilVisible);else if(e.extendedWaitUntil)await this.extendedWaitUntil(e.extendedWaitUntil);else if(e.assertVisible)await this.assertVisible(e.assertVisible);else if(e.assertNotVisible)await this.assertNotVisible(e.assertNotVisible);else if(e.inputText)await this.inputText(e.inputText);else if(e.pressKey)await this.pressKey(e.pressKey);else if(e.dispatchKey)await this.dispatchKey(e.dispatchKey);else if(e.waitFor)await this.waitFor(e.waitFor);else{if(e.takeScreenshot)return this.takeScreenshot(e.takeScreenshot);if(e.swipe)e.swipe.start&&e.swipe.end?await this.swipeCoords(e.swipe.start,e.swipe.end,e.swipe.duration):e.swipe.from?await this.swipeFrom(e.swipe.from,e.swipe.direction,e.swipe.duration):await this.swipe(e.swipe.direction,e.swipe.duration);else if(e.scroll)await this.swipe(e.scroll.direction==="DOWN"?"UP":"DOWN");else if(e.scrollTo){let t=typeof e.scrollTo.nodeId=="number"?{nodeId:e.scrollTo.nodeId}:e.scrollTo.id;if(!t)throw new Error("scrollTo requires id or nodeId");await this.scrollTo(t,e.scrollTo.x,e.scrollTo.y)}else if(e.pinch)await this.pinch(e.pinch);else if(e.waitForAnimationToEnd){let t=e.waitForAnimationToEnd;await this.waitForAnimationToEnd(typeof t=="number"?t:typeof t=="object"&&typeof t.timeout=="number"?t.timeout:2e3)}else if(e.back)await this.back();else if(e.hideKeyboard)await this.hideKeyboard();else if(e.launchApp)await this.launchApp(e.launchApp);else if(typeof e.wait=="number")await f(e.wait);else if(e.dumpTree)await this.dumpTree(e.dumpTree);else if(e.tapAtCoords)await this.tapAtCoords(e.tapAtCoords.x,e.tapAtCoords.y);else if(e.doubleTapAtCoords)await this.doubleTapAtCoords(e.doubleTapAtCoords.x,e.doubleTapAtCoords.y,e.doubleTapAtCoords.gapMs);else if(e.assertTreeContains)await this.assertTreeContains(e.assertTreeContains);else if(typeof e.eraseText=="number")await this.eraseText(e.eraseText);else if(e.repeat&&Array.isArray(e.repeat.commands)){let t=e.repeat.times,r=t==null||t===""?Number.MAX_SAFE_INTEGER:Number(t);if(!Number.isFinite(r))throw new Error(`repeat.times is not a number: ${t}`);let i=e.repeat.when??e.repeat.condition,o=async()=>i?this.evaluateWhen(i):!0,a=i?r:Math.min(r,1e3),s=0;for(;s<a&&await o();){for(let l=0;l<e.repeat.commands.length;l++)await this.runStep(e.repeat.commands[l],l);s++}}else if(e.stopApp!==void 0)await this.stopApp();else if(e.clearState!==void 0)await this.clearState();else if(e.clearKeychain!==void 0)this.clearKeychain();else if(e.copyTextFrom!==void 0)await this.copyTextFrom(e.copyTextFrom);else if(typeof e.evalScript=="string")this.evalScript(e.evalScript);else if(e.runScript){let t=e.runScript,r=typeof t=="string"?void 0:t.when;if(r&&!await this.evaluateWhen(r)){console.log("[flow] runScript skipped (when predicate false)");return}this.runScript(t)}else if(e.openLink!==void 0)await this.openLink(e.openLink);else if(e.runFlow){let t=e.runFlow,r=typeof t=="string"?t:t.file,i=typeof t=="string"?void 0:t.commands,o=typeof t=="string"?void 0:t.env,a=typeof t=="string"?void 0:t.when;if(a&&!await this.evaluateWhen(a)){console.log(`[flow] runFlow skipped (when predicate false): ${r??"inline commands"}`);return}if(!r&&!i)throw new Error("runFlow requires either file or commands");this.js.enterEnvScope();try{if(o)for(let[s,l]of Object.entries(o))this.js.putEnv(s,l);if(r){let s=S.resolve(this.opts.flowDir,r),l=x.readFileSync(s,"utf8"),p=this.opts.flowDir;this.opts.flowDir=S.dirname(s);try{await this.runFlow(Kt(l))}finally{this.opts.flowDir=p}}else if(i)for(let s=0;s<i.length;s++)await this.runStep(i[s],s)}finally{this.js.leaveEnvScope()}}else throw new Error(`unsupported flow step: ${JSON.stringify(e)}`)}}liveStatus=null;async runFlow(e){let t=[],r=[],i=[];for(let a of e){let s=Object.keys(a);if(s.length===1&&s[0]==="onFlowStart"&&Array.isArray(a.onFlowStart)){t.push(...a.onFlowStart);continue}if(s.length===1&&s[0]==="onFlowComplete"&&Array.isArray(a.onFlowComplete)){r.push(...a.onFlowComplete);continue}i.push(a)}if(this.liveStatus&&await this.liveStatus.plan(i.map((a,s)=>{let l=typeof a=="string"?ft(a):a,p=Object.keys(l).find(u=>u!=="when")??Object.keys(l)[0];return{index:s,name:p,target:this.flowStepTargetLabel(l,p)}})),t.length>0){console.log(`[flow] onFlowStart (${t.length} steps)`);for(let a=0;a<t.length;a++)await this.runStep(t[a],a)}let o=null;try{await this.runFlowBody(i)}catch(a){o=a instanceof Error?a:new Error(String(a))}if(r.length>0){console.log(`[flow] onFlowComplete (${r.length} steps)`);for(let a=0;a<r.length;a++)try{await this.runStep(r[a],a)}catch(s){console.warn(`[flow] onFlowComplete step ${a+1} failed: ${s instanceof Error?s.message:s}`)}}if(o)throw o}async runFlowBody(e){for(let t=0;t<e.length;t++){let r=e[t],i=typeof r.wait=="number"?r.wait:0,o=typeof r.waitFor?.timeout=="number"?r.waitFor.timeout:0,a=typeof r.extendedWaitUntil?.timeout=="number"?r.extendedWaitUntil.timeout:0,s=Math.max(6e4,i+15e3,K(o)+15e3,K(a)+15e3);this.liveStatus&&(await this.liveStatus.waitWhilePaused(),await this.liveStatus.step(t,"running"));let l=Date.now(),p=async(u,g)=>{if(!this.liveStatus)return;let b=this.flowTraceSteps[this.flowTraceSteps.length-1],m=b&&b.stepIndex===t&&b.startedAtMs>=l;await this.liveStatus.step(t,u?"failure":m&&b.status==="skipped"?"skipped":"success",{durationMs:Date.now()-l,error:u?g instanceof Error?g.message.slice(0,300):String(g).slice(0,300):m&&b.error||void 0})};try{r.runFlow||r.launchApp?await this.runStep(r,t):await Promise.race([this.runStep(r,t),new Promise((u,g)=>setTimeout(()=>g(new Error(`step ${t+1} (${Object.keys(r)[0]}) exceeded ${s}ms deadline`)),s))])}catch(u){let g=this.flowTraceSteps[this.flowTraceSteps.length-1];if(!(g&&g.stepIndex===t&&g.startedAtMs>=l)){let b=Object.keys(r)[0];this.lastFailedStep={index:t,kind:b,target:r[b]},this.recordFlowTraceStep({stepIndex:t,stepName:b,targetLabel:this.flowStepTargetLabel(r,b),startedAtMs:l,status:"failure",error:u})}throw await p(!0,u),u}await p(!1)}}};function qt(n){if(typeof n!="object"||n==null||!("control"in n))return!1;let e=n.control;return typeof e=="object"&&e!=null&&"paused"in e&&e.paused===!0}var ne=class{constructor(e,t,r){this.bridge=e;this.flowName=t;this.getSimId=r}disabled=!1;paused=!1;lastSimId;plannedSteps=null;completedSteps=new Map;runId=`flr_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,8)}`;async send(e,t){let r=await this.bridge.send({type:"flowStatus",simId:t,status:{runId:this.runId,flowName:this.flowName,...e}});this.paused=qt(r)}async push(e){if(!this.disabled)try{let t=this.getSimId?.();if(t!==this.lastSimId&&this.lastSimId!=null&&this.plannedSteps&&e.phase!=="plan"){await this.send({phase:"plan",state:"running",steps:this.plannedSteps},t);for(let r of this.completedSteps.values())await this.send({phase:"step",state:"running",step:r},t)}this.lastSimId=t,await this.send(e,t)}catch(t){this.disabled=!0,console.log(`[flow] live status unavailable (${t instanceof Error?t.message.slice(0,120):t}) \u2014 continuing without the devtools rail`)}}async plan(e){this.plannedSteps=e.map(t=>({...t})),this.completedSteps.clear(),await this.push({phase:"plan",state:"running",steps:e})}async step(e,t,r){let i={index:e,status:t,...r};await this.push({phase:"step",state:"running",step:i}),this.completedSteps.set(e,i)}async end(e){await this.push({phase:"end",state:e})}async waitWhilePaused(){if(!this.disabled)for(;this.paused;){for(console.log("[flow] paused from devtools \u2014 waiting\u2026");this.paused&&!this.disabled;)await new Promise(e=>setTimeout(e,400)),await this.push({phase:"heartbeat",state:"paused"});this.disabled||console.log("[flow] resumed")}}};var Ee=null;function Wr(){return Ee}var Fe=[];function jr(){return Fe}async function Xt(n){if(!n)return"";let e=n.trim();if(!e)return"";if(/^\d+$/.test(e)||e.startsWith("http://")||e.startsWith("https://"))return e;let r=(await Xe()).find(i=>i.name.toLowerCase()===e.toLowerCase());return r?String(r.preferredPort):e}async function Zt(){let n=await Ze(),e=n.find(r=>r.patched);if(e)return`http://localhost:${e.port}/__soot/`;let t=n[0];return t?`http://localhost:${t.port}/__soot/`:null}async function gt(n){Ee=null,Fe=[],(n.length===0||n.includes("--help")||n.includes("-h"))&&(console.log(`
440
+ })()`);if(this.profilingEnabled=!1,e?.error)throw new Error(e.error);return e}async stopApp(){await this.reloadGuestApp(),await this.rearmCaptureAfterRuntimeReload()}async clearState(){await this.resetGuestAppData(),await this.rearmCaptureAfterRuntimeReload()}clearKeychain(){console.warn("[flow] clearKeychain: rnx has no keychain surface \u2014 no-op (warning)")}async copyTextFrom(e){let t=typeof e=="string"?{id:e}:e,r=await this.findElement(t);if(!r)throw new Error(`copyTextFrom: element not found: ${JSON.stringify(t)}`);let i=r.text??r.testID??"";this.js.setCopiedText(i),this.js.putEnv("maestroCopiedText",i),console.log(`[flow] copied text: ${JSON.stringify(i)}`)}evalScript(e){let r=/(?<!\\)\$\{[^$]*\}/.test(e)?this.js.evaluateStringTemplate(e):this.js.evaluate(e);r!==void 0&&r!==""&&console.log("[flow] evalScript ->",r)}runScript(e){let t=typeof e=="string"?{file:e}:e;if(!t.file)throw new Error("runScript requires a file");let r=S.resolve(this.opts.flowDir,t.file),i=x.readFileSync(r,"utf8");this.js.evaluate(i,{env:t.env}),console.log(`[flow] runScript: ${t.file} done`)}async openLink(e){let t=typeof e=="string"?e:e.link;if(!t)throw new Error("openLink: missing link");let r=await this.callTest("openDeepLink",t);if(!r?.ok)throw new Error(`openLink failed: ${r?.error||"no test bridge"}`);await f(300)}async evaluateWhen(e){if(e.visible!==void 0){let t=typeof e.visible=="string"?{text:e.visible}:e.visible;return!!await this.findElement(t)}if(e.notVisible!==void 0){let t=typeof e.notVisible=="string"?{text:e.notVisible}:e.notVisible;return!await this.findElement(t)}return e.platform!==void 0?e.platform.toLowerCase()===this.js.maestro.platform.toLowerCase():e.true!==void 0?ft(e.true):!0}isOptional(e){if(e.optional===!0)return!0;let r=Object.entries(e).find(([o])=>o!=="when"&&o!=="optional"),i=r?r[1]:void 0;return!!(i&&typeof i=="object"&&"optional"in i&&i.optional)}async runStep(e,t){let r=typeof e=="string"?mt(e):e,i=Object.keys(r).find(l=>l!=="when")||Object.keys(r)[0];console.log(`[flow] step ${t+1}: ${i}`);let o=Date.now(),a=this.flowStepTargetLabel(r,i),s;try{s=this.js.interpolateStep(r),a=this.flowStepTargetLabel(s,i)??a}catch(l){if(this.isOptional(r)){console.log(`[flow] (optional, skipped: ${l.message.slice(0,80)})`),this.recordFlowTraceStep({stepIndex:t,stepName:i,targetLabel:a,startedAtMs:o,status:"skipped",error:l});return}throw this.lastFailedStep={index:t,kind:i,target:r[i]},this.recordFlowTraceStep({stepIndex:t,stepName:i,targetLabel:a,startedAtMs:o,status:"failure",error:l}),l}if(s.when&&!await this.evaluateWhen(s.when)){console.log("[flow] (when: predicate false, skipped)"),this.recordFlowTraceStep({stepIndex:t,stepName:i,targetLabel:a,startedAtMs:o,status:"skipped"});return}try{let l=!!(s.extendedWaitUntil||s.waitFor||s.scrollUntilVisible||s.launchApp||s.runFlow||s.runScript),p=1e4,u=this.runStepInner(s),g;if(l){let m=await u;typeof m=="string"&&(g=m)}else{let m=null,k=new Promise(($,H)=>{m=setTimeout(()=>{H(new Error(`step watchdog: ${i} made no progress in ${p}ms \u2014 bridge or bundle probably hung`))},p)});try{let $=await Promise.race([u,k]);typeof $=="string"&&(g=$)}finally{m&&clearTimeout(m)}}let b=!!(s.assertVisible||s.assertNotVisible||s.extendedWaitUntil||s.waitFor);this.stepDelay>0&&!b&&await f(this.stepDelay),this.recordFlowTraceStep({stepIndex:t,stepName:i,targetLabel:a,startedAtMs:o,status:"success",screenshotPath:g})}catch(l){if(this.isOptional(s)){console.log(`[flow] (optional, skipped: ${l.message.slice(0,80)})`),this.recordFlowTraceStep({stepIndex:t,stepName:i,targetLabel:a,startedAtMs:o,status:"skipped",error:l});return}throw this.lastFailedStep={index:t,kind:i,target:s[i]},this.recordFlowTraceStep({stepIndex:t,stepName:i,targetLabel:a,startedAtMs:o,status:"failure",error:l}),l}}async runStepInner(e){if(e.tapOn)await this.tapOn(e.tapOn);else if(e.longPressOn)await this.longPressOn(e.longPressOn);else if(e.scrollUntilVisible)await this.scrollUntilVisible(e.scrollUntilVisible);else if(e.extendedWaitUntil)await this.extendedWaitUntil(e.extendedWaitUntil);else if(e.assertVisible)await this.assertVisible(e.assertVisible);else if(e.assertNotVisible)await this.assertNotVisible(e.assertNotVisible);else if(e.inputText)await this.inputText(e.inputText);else if(e.pressKey)await this.pressKey(e.pressKey);else if(e.dispatchKey)await this.dispatchKey(e.dispatchKey);else if(e.waitFor)await this.waitFor(e.waitFor);else{if(e.takeScreenshot)return this.takeScreenshot(e.takeScreenshot);if(e.swipe)e.swipe.start&&e.swipe.end?await this.swipeCoords(e.swipe.start,e.swipe.end,e.swipe.duration):e.swipe.from?await this.swipeFrom(e.swipe.from,e.swipe.direction,e.swipe.duration):await this.swipe(e.swipe.direction,e.swipe.duration);else if(e.scroll)await this.swipe(e.scroll.direction==="DOWN"?"UP":"DOWN");else if(e.scrollTo){let t=typeof e.scrollTo.nodeId=="number"?{nodeId:e.scrollTo.nodeId}:e.scrollTo.id;if(!t)throw new Error("scrollTo requires id or nodeId");await this.scrollTo(t,e.scrollTo.x,e.scrollTo.y)}else if(e.pinch)await this.pinch(e.pinch);else if(e.waitForAnimationToEnd){let t=e.waitForAnimationToEnd;await this.waitForAnimationToEnd(typeof t=="number"?t:typeof t=="object"&&typeof t.timeout=="number"?t.timeout:2e3)}else if(e.back)await this.back();else if(e.hideKeyboard)await this.hideKeyboard();else if(e.launchApp)await this.launchApp(e.launchApp);else if(typeof e.wait=="number")await f(e.wait);else if(e.dumpTree)await this.dumpTree(e.dumpTree);else if(e.tapAtCoords)await this.tapAtCoords(e.tapAtCoords.x,e.tapAtCoords.y);else if(e.doubleTapAtCoords)await this.doubleTapAtCoords(e.doubleTapAtCoords.x,e.doubleTapAtCoords.y,e.doubleTapAtCoords.gapMs);else if(e.assertTreeContains)await this.assertTreeContains(e.assertTreeContains);else if(typeof e.eraseText=="number")await this.eraseText(e.eraseText);else if(e.repeat&&Array.isArray(e.repeat.commands)){let t=e.repeat.times,r=t==null||t===""?Number.MAX_SAFE_INTEGER:Number(t);if(!Number.isFinite(r))throw new Error(`repeat.times is not a number: ${t}`);let i=e.repeat.when??e.repeat.condition,o=async()=>i?this.evaluateWhen(i):!0,a=i?r:Math.min(r,1e3),s=0;for(;s<a&&await o();){for(let l=0;l<e.repeat.commands.length;l++)await this.runStep(e.repeat.commands[l],l);s++}}else if(e.stopApp!==void 0)await this.stopApp();else if(e.clearState!==void 0)await this.clearState();else if(e.clearKeychain!==void 0)this.clearKeychain();else if(e.copyTextFrom!==void 0)await this.copyTextFrom(e.copyTextFrom);else if(typeof e.evalScript=="string")this.evalScript(e.evalScript);else if(e.runScript){let t=e.runScript,r=typeof t=="string"?void 0:t.when;if(r&&!await this.evaluateWhen(r)){console.log("[flow] runScript skipped (when predicate false)");return}this.runScript(t)}else if(e.openLink!==void 0)await this.openLink(e.openLink);else if(e.runFlow){let t=e.runFlow,r=typeof t=="string"?t:t.file,i=typeof t=="string"?void 0:t.commands,o=typeof t=="string"?void 0:t.env,a=typeof t=="string"?void 0:t.when;if(a&&!await this.evaluateWhen(a)){console.log(`[flow] runFlow skipped (when predicate false): ${r??"inline commands"}`);return}if(!r&&!i)throw new Error("runFlow requires either file or commands");this.js.enterEnvScope();try{if(o)for(let[s,l]of Object.entries(o))this.js.putEnv(s,l);if(r){let s=S.resolve(this.opts.flowDir,r),l=x.readFileSync(s,"utf8"),p=this.opts.flowDir;this.opts.flowDir=S.dirname(s);try{await this.runFlow(qt(l))}finally{this.opts.flowDir=p}}else if(i)for(let s=0;s<i.length;s++)await this.runStep(i[s],s)}finally{this.js.leaveEnvScope()}}else throw new Error(`unsupported flow step: ${JSON.stringify(e)}`)}}liveStatus=null;async runFlow(e){let t=[],r=[],i=[];for(let a of e){let s=Object.keys(a);if(s.length===1&&s[0]==="onFlowStart"&&Array.isArray(a.onFlowStart)){t.push(...a.onFlowStart);continue}if(s.length===1&&s[0]==="onFlowComplete"&&Array.isArray(a.onFlowComplete)){r.push(...a.onFlowComplete);continue}i.push(a)}if(this.liveStatus&&await this.liveStatus.plan(i.map((a,s)=>{let l=typeof a=="string"?mt(a):a,p=Object.keys(l).find(u=>u!=="when")??Object.keys(l)[0];return{index:s,name:p,target:this.flowStepTargetLabel(l,p)}})),t.length>0){console.log(`[flow] onFlowStart (${t.length} steps)`);for(let a=0;a<t.length;a++)await this.runStep(t[a],a)}let o=null;try{await this.runFlowBody(i)}catch(a){o=a instanceof Error?a:new Error(String(a))}if(r.length>0){console.log(`[flow] onFlowComplete (${r.length} steps)`);for(let a=0;a<r.length;a++)try{await this.runStep(r[a],a)}catch(s){console.warn(`[flow] onFlowComplete step ${a+1} failed: ${s instanceof Error?s.message:s}`)}}if(o)throw o}async runFlowBody(e){for(let t=0;t<e.length;t++){let r=e[t],i=typeof r.wait=="number"?r.wait:0,o=typeof r.waitFor?.timeout=="number"?r.waitFor.timeout:0,a=typeof r.extendedWaitUntil?.timeout=="number"?r.extendedWaitUntil.timeout:0,s=Math.max(6e4,i+15e3,K(o)+15e3,K(a)+15e3);this.liveStatus&&(await this.liveStatus.waitWhilePaused(),await this.liveStatus.step(t,"running"));let l=Date.now(),p=async(u,g)=>{if(!this.liveStatus)return;let b=this.flowTraceSteps[this.flowTraceSteps.length-1],m=b&&b.stepIndex===t&&b.startedAtMs>=l;await this.liveStatus.step(t,u?"failure":m&&b.status==="skipped"?"skipped":"success",{durationMs:Date.now()-l,error:u?g instanceof Error?g.message.slice(0,300):String(g).slice(0,300):m&&b.error||void 0})};try{r.runFlow||r.launchApp?await this.runStep(r,t):await Promise.race([this.runStep(r,t),new Promise((u,g)=>setTimeout(()=>g(new Error(`step ${t+1} (${Object.keys(r)[0]}) exceeded ${s}ms deadline`)),s))])}catch(u){let g=this.flowTraceSteps[this.flowTraceSteps.length-1];if(!(g&&g.stepIndex===t&&g.startedAtMs>=l)){let b=Object.keys(r)[0];this.lastFailedStep={index:t,kind:b,target:r[b]},this.recordFlowTraceStep({stepIndex:t,stepName:b,targetLabel:this.flowStepTargetLabel(r,b),startedAtMs:l,status:"failure",error:u})}throw await p(!0,u),u}await p(!1)}}};function Yt(n){if(typeof n!="object"||n==null||!("control"in n))return!1;let e=n.control;return typeof e=="object"&&e!=null&&"paused"in e&&e.paused===!0}var ne=class{constructor(e,t,r){this.bridge=e;this.flowName=t;this.getSimId=r}disabled=!1;paused=!1;lastSimId;plannedSteps=null;completedSteps=new Map;runId=`flr_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,8)}`;async send(e,t){let r=await this.bridge.send({type:"flowStatus",simId:t,status:{runId:this.runId,flowName:this.flowName,...e}});this.paused=Yt(r)}async push(e){if(!this.disabled)try{let t=this.getSimId?.();if(t!==this.lastSimId&&this.lastSimId!=null&&this.plannedSteps&&e.phase!=="plan"){await this.send({phase:"plan",state:"running",steps:this.plannedSteps},t);for(let r of this.completedSteps.values())await this.send({phase:"step",state:"running",step:r},t)}this.lastSimId=t,await this.send(e,t)}catch(t){this.disabled=!0,console.log(`[flow] live status unavailable (${t instanceof Error?t.message.slice(0,120):t}) \u2014 continuing without the devtools rail`)}}async plan(e){this.plannedSteps=e.map(t=>({...t})),this.completedSteps.clear(),await this.push({phase:"plan",state:"running",steps:e})}async step(e,t,r){let i={index:e,status:t,...r};await this.push({phase:"step",state:"running",step:i}),this.completedSteps.set(e,i)}async end(e){await this.push({phase:"end",state:e})}async waitWhilePaused(){if(!this.disabled)for(;this.paused;){for(console.log("[flow] paused from devtools \u2014 waiting\u2026");this.paused&&!this.disabled;)await new Promise(e=>setTimeout(e,400)),await this.push({phase:"heartbeat",state:"paused"});this.disabled||console.log("[flow] resumed")}}};var Ee=null;function jr(){return Ee}var Fe=[];function Vr(){return Fe}async function Zt(n){if(!n)return{target:""};let e=n.trim();if(!e)return{target:""};if(/^\d+$/.test(e))return{target:e};if(e.startsWith("http://")||e.startsWith("https://"))return{target:e};let r=(await Ze()).find(i=>i.name.toLowerCase()===e.toLowerCase());return r?{target:String(r.preferredPort),runtimeConfig:r.runtimeConfig}:{target:e}}async function Qt(){let n=await Qe(),e=n.find(r=>r.patched);if(e)return`http://localhost:${e.port}/__soot/`;let t=n[0];return t?`http://localhost:${t.port}/__soot/`:null}async function wt(n){Ee=null,Fe=[],(n.length===0||n.includes("--help")||n.includes("-h"))&&(console.log(`
441
441
  sootsim maestro \u2014 author and run Maestro YAML flows
442
442
 
443
443
  usage:
@@ -516,28 +516,28 @@ flow extension:
516
516
  takeScreenshot:
517
517
  path: marketing/hero
518
518
  withFrame: true
519
- `),process.exit(0));let e=n[0];P.existsSync(e)||(console.error(` error: ${e} not found`),process.exit(1));let t=h=>n.find((d,y)=>n[y-1]===h),r=n.includes("--profile"),i=n.includes("--headed"),o=n.includes("--new")||i,a=t("--out")||"/tmp/sootsim-recordings",s=t("--screenshots")||(t("--out")?a:"/tmp/sootsim-flow"),l=t("--screenshot-paths")==="flow"?"flow":"dir",p=n.includes("--no-shell")?"tenant":n.includes("--shell-only")?"shell":void 0,u=t("--device")?.trim()||"",g=n.includes("--slow")?+(t("--slow")||"500"):0,b=n.includes("--electron"),m=n.includes("--preview"),k=m?await at(t("--preview-origin")):"",$=t("--preview-public-origin"),H=n.includes("--preview-open"),Ie=t("--owner")?.trim()||"",Pe=t("--repo")?.trim()||"",U=t("--billing-kind")?.trim()||"",wt=m?`maestro:${process.env.GITHUB_RUN_ID?`github:${process.env.GITHUB_RUN_ID}:attempt:${process.env.GITHUB_RUN_ATTEMPT||"1"}:job:${process.env.GITHUB_JOB||"preview"}`:`local:${zt()}`}:flow:${Yt("sha256").update(w.relative(process.cwd(),w.resolve(e))).digest("hex").slice(0,16)}`:"";U&&U!=="test_run"&&(console.error(` error: invalid --billing-kind: ${U}`),process.exit(1));let yt=n.flatMap((h,d)=>n[d-1]==="--replace"?["--replace",h]:[]),bt=n.flatMap((h,d)=>n[d-1]==="--remap"?["--remap",h]:[]),R=n.includes("--record")||m,St=n.includes("--tail-wait")?Math.max(0,+(t("--tail-wait")||"2000")):R?m?6e3:2e3:0,vt=P.readFileSync(e,"utf8"),{frontmatter:T,steps:M}=me(vt);M.length===0&&(console.error(" error: flow file must contain a YAML array of steps"),process.exit(1));let W=u||T.device||"",ke=T.theme||"",z=b||T.electron===!0,xt=T.app===void 0||T.app===null?"":typeof T.app=="number"?String(T.app):T.app,oe=await Xt(xt),$e={stripBooleanFlags:["--record","--profile","--electron","--new","--preview","--preview-open","--headless","--headed"],stripValueFlags:["--out","--device","--slow","--tail-wait","--url","--replace","--remap","--screenshots","--screenshot-paths","--preview-origin","--preview-public-origin","--driver","--billing-kind","--owner","--repo"]},v=pe(n,$e),Tt=t("--url")||"";z&&!Qe()&&(console.error(" error: desktop companion not found. install or build it first with `bun run build:electron`"),process.exit(1));let Ae=z?"desktop companion":"bridge",Et=oe?` | target: ${oe}`:"";console.log(`
519
+ `),process.exit(0));let e=n[0];P.existsSync(e)||(console.error(` error: ${e} not found`),process.exit(1));let t=h=>n.find((d,y)=>n[y-1]===h),r=n.includes("--profile"),i=n.includes("--headed"),o=n.includes("--new")||i,a=t("--out")||"/tmp/sootsim-recordings",s=t("--screenshots")||(t("--out")?a:"/tmp/sootsim-flow"),l=t("--screenshot-paths")==="flow"?"flow":"dir",p=n.includes("--no-shell")?"tenant":n.includes("--shell-only")?"shell":void 0,u=t("--device")?.trim()||"",g=n.includes("--slow")?+(t("--slow")||"500"):0,b=n.includes("--electron"),m=n.includes("--preview"),k=m?await lt(t("--preview-origin")):"",$=t("--preview-public-origin"),H=n.includes("--preview-open"),Ie=t("--owner")?.trim()||"",Pe=t("--repo")?.trim()||"",U=t("--billing-kind")?.trim()||"",yt=m?`maestro:${process.env.GITHUB_RUN_ID?`github:${process.env.GITHUB_RUN_ID}:attempt:${process.env.GITHUB_RUN_ATTEMPT||"1"}:job:${process.env.GITHUB_JOB||"preview"}`:`local:${Xt()}`}:flow:${zt("sha256").update(w.relative(process.cwd(),w.resolve(e))).digest("hex").slice(0,16)}`:"";U&&U!=="test_run"&&(console.error(` error: invalid --billing-kind: ${U}`),process.exit(1));let bt=n.flatMap((h,d)=>n[d-1]==="--replace"?["--replace",h]:[]),St=n.flatMap((h,d)=>n[d-1]==="--remap"?["--remap",h]:[]),R=n.includes("--record")||m,vt=n.includes("--tail-wait")?Math.max(0,+(t("--tail-wait")||"2000")):R?m?6e3:2e3:0,xt=P.readFileSync(e,"utf8"),{frontmatter:T,steps:M}=me(xt);M.length===0&&(console.error(" error: flow file must contain a YAML array of steps"),process.exit(1));let W=u||T.device||"",ke=T.theme||"",z=b||T.electron===!0,Tt=T.app===void 0||T.app===null?"":typeof T.app=="number"?String(T.app):T.app,$e=await Zt(Tt),oe=$e.target,Ae={stripBooleanFlags:["--record","--profile","--electron","--new","--preview","--preview-open","--headless","--headed"],stripValueFlags:["--out","--device","--slow","--tail-wait","--url","--replace","--remap","--screenshots","--screenshot-paths","--preview-origin","--preview-public-origin","--driver","--billing-kind","--owner","--repo"]},v=pe(n,Ae),Et=t("--url")||"";z&&!et()&&(console.error(" error: desktop companion not found. install or build it first with `bun run build:electron`"),process.exit(1));let Re=z?"desktop companion":"bridge",Ft=oe?` | target: ${oe}`:"";console.log(`
520
520
  sootsim maestro \u2014 ${w.basename(e)}
521
- ${M.length} steps | ${Ae}${Et}${R?" | recording":""}${r?" | profiling":""}${g?` | ${g}ms delay`:""}
522
- `),m&&_e({event:"preview_flow_started",properties:{flowName:w.basename(e),stepCount:M.length,mode:Ae,electron:z,record:R,profile:r,previewOrigin:k}});let A=Tt||oe||"",se=o||z&&v.simIdSource!=="flag",Re=t("--driver")||"",ae=!1,le=new Set,Me=!1;if(!A&&!se&&v.simIdSource==="none"){let h=Ce(v);try{let d=await h.listSims(),y=d.find(D=>D.isPrimary&&D.readyState==="open"),I=d.find(D=>D.readyState==="open"),J=y??I;J&&(Me=!0,console.log(` reusing active sim: ${J.id}`))}catch{}finally{h.close()}}if(!A&&!Me&&(se||v.simIdSource==="none")){let h=await Zt();h||(console.error(" error: no current sim and no sootsim target found"),await ce(),process.exit(1)),A=h}if(A&&W){let h=new URL(await tt(A,et(v.wsPort)));h.searchParams.set("device",W),A=h.toString()}if(A){let h=[A];if(h.push(...yt),h.push(...bt),se&&h.push("--new"),h.push("--no-describe"),v.simIdSource==="flag"&&v.simId&&h.push("--sim",v.simId),Re&&(h.push("--driver",Re),ae=!0),n.includes("--headless")&&!i&&h.push("--headless"),await it(h,{port:v.wsPort,timeoutMs:v.commandTimeoutMs}),ae){let d=ue();d&&le.add(d)}}let B=pe(n,$e),X=B.simIdSource==="flag"?B.simId:ue()||B.simId,Ft=B.simIdSource==="flag"?"flag":X?"saved":"none",E=he(B.wsPort,{commandTimeoutMs:B.commandTimeoutMs,simId:X,simIdSource:Ft}),c,Oe=async()=>{let h=T.env?.SOOTSIM_STATUS_BAR_TIME;if(h){if(!/^(?:[1-9]|1[0-2]):[0-5][0-9]$/.test(h))throw new Error("SOOTSIM_STATUS_BAR_TIME must be a 12-hour time such as 9:41");await E.send({type:"evaluate",simId:c.simId,code:`window.dispatchEvent(new CustomEvent('sootsim:statusBarOverride', { detail: { time: ${JSON.stringify(h)} } }))`})}if(ke&&await E.send({type:"call",simId:c.simId,path:"SootSim.bridges.settings.set",args:["colorScheme",ke]}),!W)return!1;let d=await E.send({type:"evaluate",simId:c.simId,code:"window.location.href"});if(typeof d=="string"&&d.length>0){let y=new URL(d);y.searchParams.set("device",W),c.setSimRouteHint(y.toString())}return!!await E.send({type:"call",simId:c.simId,path:"SootSim.bridges.settings.set",args:["deviceModel",W]})};if(c=new ie(E,{screenshotDir:s,flowDir:w.dirname(w.resolve(e)),screenshotPathMode:l,screenshotLayers:p,simId:X,recordingOutputDir:R?a:void 0,recordingFormat:m?"mp4":"webm",billingOriginOverride:m?k:void 0,allowGitHubRecording:m,requireRecordingEntitlement:m,onAfterLaunch:async()=>{await Oe()&&await c.waitForTree(12e4),m&&await E.send({type:"evaluate",simId:c.simId,code:`(() => {
521
+ ${M.length} steps | ${Re}${Ft}${R?" | recording":""}${r?" | profiling":""}${g?` | ${g}ms delay`:""}
522
+ `),m&&De({event:"preview_flow_started",properties:{flowName:w.basename(e),stepCount:M.length,mode:Re,electron:z,record:R,profile:r,previewOrigin:k}});let A=Et||oe||"",se=o||z&&v.simIdSource!=="flag",Me=t("--driver")||"",ae=!1,le=new Set,Oe=!1;if(!A&&!se&&v.simIdSource==="none"){let h=He(v);try{let d=await h.listSims(),y=d.find(D=>D.isPrimary&&D.readyState==="open"),I=d.find(D=>D.readyState==="open"),J=y??I;J&&(Oe=!0,console.log(` reusing active sim: ${J.id}`))}catch{}finally{h.close()}}if(!A&&!Oe&&(se||v.simIdSource==="none")){let h=await Qt();h||(console.error(" error: no current sim and no sootsim target found"),await ce(),process.exit(1)),A=h}if(A&&W){let h=new URL(await rt(A,tt(v.wsPort)));h.searchParams.set("device",W),A=h.toString()}if(A){let h=[A];if(h.push(...bt),h.push(...St),se&&h.push("--new"),h.push("--no-describe"),v.simIdSource==="flag"&&v.simId&&h.push("--sim",v.simId),Me&&(h.push("--driver",Me),ae=!0),n.includes("--headless")&&!i&&h.push("--headless"),await nt(h,{port:v.wsPort,timeoutMs:v.commandTimeoutMs,runtimeConfig:$e.runtimeConfig}),ae){let d=ue();d&&le.add(d)}}let B=pe(n,Ae),X=B.simIdSource==="flag"?B.simId:ue()||B.simId,It=B.simIdSource==="flag"?"flag":X?"saved":"none",E=he(B.wsPort,{commandTimeoutMs:B.commandTimeoutMs,simId:X,simIdSource:It}),c,_e=async()=>{let h=T.env?.SOOTSIM_STATUS_BAR_TIME;if(h){if(!/^(?:[1-9]|1[0-2]):[0-5][0-9]$/.test(h))throw new Error("SOOTSIM_STATUS_BAR_TIME must be a 12-hour time such as 9:41");await E.send({type:"evaluate",simId:c.simId,code:`window.dispatchEvent(new CustomEvent('sootsim:statusBarOverride', { detail: { time: ${JSON.stringify(h)} } }))`})}if(ke&&await E.send({type:"call",simId:c.simId,path:"SootSim.bridges.settings.set",args:["colorScheme",ke]}),!W)return!1;let d=await E.send({type:"evaluate",simId:c.simId,code:"window.location.href"});if(typeof d=="string"&&d.length>0){let y=new URL(d);y.searchParams.set("device",W),c.setSimRouteHint(y.toString())}return!!await E.send({type:"call",simId:c.simId,path:"SootSim.bridges.settings.set",args:["deviceModel",W]})};if(c=new ie(E,{screenshotDir:s,flowDir:w.dirname(w.resolve(e)),screenshotPathMode:l,screenshotLayers:p,simId:X,recordingOutputDir:R?a:void 0,recordingFormat:m?"mp4":"webm",billingOriginOverride:m?k:void 0,allowGitHubRecording:m,requireRecordingEntitlement:m,onAfterLaunch:async()=>{await _e()&&await c.waitForTree(12e4),m&&await E.send({type:"evaluate",simId:c.simId,code:`(() => {
523
523
  const r = window.SootSim?.bridges?.eventRecorder ?? window.__sootsimEventRecorder
524
524
  return r?.start?.() ?? false
525
- })()`})}}),g&&(c.stepDelay=g),c.liveStatus=new ne(E,w.basename(e),()=>c.simId),c.js.putEnv("MAESTRO_FILENAME",w.basename(e,w.extname(e))),T.env&&typeof T.env=="object")for(let[h,d]of Object.entries(T.env))c.js.putEnv(h,d);let O=null,F=null,L=null,_=null,j=null,de=null,V=0,Z=!!M[0]?.launchApp;try{Z||await c.waitForTree(12e4),await Oe()&&!Z&&await c.waitForTree(12e4),m&&!Z&&!process.env.SOOTSIM_PREVIEW_RESET_DONE&&await c.launchApp({clearState:!0}),R&&(Z?c.prepareRecording():await c.startRecording()),r&&await c.startProfile(),m&&(await E.send({type:"evaluate",simId:c.simId,code:`(() => {
525
+ })()`})}}),g&&(c.stepDelay=g),c.liveStatus=new ne(E,w.basename(e),()=>c.simId),c.js.putEnv("MAESTRO_FILENAME",w.basename(e,w.extname(e))),T.env&&typeof T.env=="object")for(let[h,d]of Object.entries(T.env))c.js.putEnv(h,d);let O=null,F=null,L=null,_=null,j=null,de=null,V=0,Z=!!M[0]?.launchApp;try{Z||await c.waitForTree(12e4),await _e()&&!Z&&await c.waitForTree(12e4),m&&!Z&&!process.env.SOOTSIM_PREVIEW_RESET_DONE&&await c.launchApp({clearState:!0}),R&&(Z?c.prepareRecording():await c.startRecording()),r&&await c.startProfile(),m&&(await E.send({type:"evaluate",simId:c.simId,code:`(() => {
526
526
  const r = window.SootSim?.bridges?.eventRecorder ?? window.__sootsimEventRecorder
527
527
  return r?.start?.() ?? false
528
- })()`})||console.warn(" warn: eventRecorder.start() returned false \u2014 preview will upload bundle without replay events")),await c.runFlow(M),r&&(O=await c.stopProfile()),await c.waitForRecordingTail({maxMs:St,smart:m}),R&&(F=await c.stopRecording(),L=c.getLastRecordingDurationMs()),m&&(_=await E.send({type:"evaluate",simId:c.simId,code:`(() => {
528
+ })()`})||console.warn(" warn: eventRecorder.start() returned false \u2014 preview will upload bundle without replay events")),await c.runFlow(M),r&&(O=await c.stopProfile()),await c.waitForRecordingTail({maxMs:vt,smart:m}),R&&(F=await c.stopRecording(),L=c.getLastRecordingDurationMs()),m&&(_=await E.send({type:"evaluate",simId:c.simId,code:`(() => {
529
529
  const r = window.SootSim?.bridges?.eventRecorder ?? window.__sootsimEventRecorder
530
530
  return r?.stop?.() ?? []
531
531
  })()`}),console.log(` captured ${_.length} replay events`),j=w.join(s,"preview-final.png"),await c.captureScreenshot(j),console.log(` final screenshot: ${j}`));let d=M.filter(y=>y&&typeof y=="object"&&"takeScreenshot"in y).length;console.log(`
532
- + completed (${M.length} steps)`),d>0&&console.log(` screenshots: ${d} \u2192 ${s}`),O&&mt(O),F&&console.log(` video: ${F}`),console.log()}catch(h){if(r&&!O)try{O=await c.stopProfile()}catch{}if(R&&!F)try{F=await c.stopRecording(),L=c.getLastRecordingDurationMs()}catch(d){console.warn(` recording stop failed: ${d?.message||String(d)}`)}if(m&&!_)try{_=await E.send({type:"evaluate",simId:c.simId,code:`(() => {
532
+ + completed (${M.length} steps)`),d>0&&console.log(` screenshots: ${d} \u2192 ${s}`),O&&gt(O),F&&console.log(` video: ${F}`),console.log()}catch(h){if(r&&!O)try{O=await c.stopProfile()}catch{}if(R&&!F)try{F=await c.stopRecording(),L=c.getLastRecordingDurationMs()}catch(d){console.warn(` recording stop failed: ${d?.message||String(d)}`)}if(m&&!_)try{_=await E.send({type:"evaluate",simId:c.simId,code:`(() => {
533
533
  const r = window.SootSim?.bridges?.eventRecorder ?? window.__sootsimEventRecorder
534
534
  return r?.stop?.() ?? []
535
535
  })()`}),console.log(` captured ${_.length} partial replay events`)}catch(d){console.warn(` event recorder stop failed: ${d?.message||String(d)}`)}console.error(`
536
536
  x failed: ${h.message}
537
- `),O&&(console.log(" partial profile:"),mt(O)),F&&console.log(` partial video: ${F}`);try{let d=c.lastFailedStep,y=d?`step-${String(d.index+1).padStart(2,"0")}-${d.kind}`:"unstaged",I=w.join(s,y);await c.captureFailureBundle(I,{error:h,stepIndex:d?.index,stepKind:d?.kind,stepTarget:d?.target}),de=I,console.log(` failure bundle: ${I}`),console.log(" (contents: screenshot.png, describe.json, a11y.txt, tree.txt, console.json, error.json)")}catch(d){try{let y=w.join(s,"error.png");await c.captureScreenshot(y),console.log(` error screenshot: ${y}`)}catch{}console.log(` (failure bundle capture failed: ${d instanceof Error?d.message:String(d)})`)}await Ge(E,{errorsCommand:`sootsim get errors 5${c.simId?` --sim ${c.simId}`:""}`,warningsCommand:`sootsim get warnings 5${c.simId?` --sim ${c.simId}`:""}`,requestsCommand:`sootsim get requests 5${c.simId?` --sim ${c.simId}`:""}`}),V=1}if(await c.liveStatus?.end(V===0?"passed":"failed"),m&&(V===0||F||_))try{let h=await er(_??[]),d=["--origin",k,"--events",h];$&&d.push("--public-origin",$),F&&d.push("--video",F),j&&d.push("--screenshot",j),F&&L&&Number.isFinite(L)&&(d.push("--video-duration-ms",String(Math.round(L))),d.push("--recorded-duration-ms",String(Math.round(L))));let y=c.getLastRecordingStartedAtMs();y&&Number.isFinite(y)&&d.push("--recording-started-at-ms",String(Math.round(y))),v.wsPort&&d.push("--port",String(v.wsPort)),c.simId&&d.push("--sim",c.simId),H&&d.push("--open"),Ie&&d.push("--owner",Ie),Pe&&d.push("--repo",Pe),d.push("--run-scope",wt),U&&d.push("--billing-kind",U),console.log(`
538
- preparing preview upload\u2026`);let I=c.getFlowTraceSteps();I.length>0&&d.push("--timeline-events",await tr(I));let J=await rr(I,y);J&&d.push("--snapshot-manifest",J),de&&d.push("--failure-bundle",de);let D=c.getLastRecordingFrameStats();D&&d.push("--trace-frame-stats",await ir(D));let{runUpload:It}=await import("./upload-LQJITLKK.js");Ee=await It(d,{})}catch(h){console.error(` preview upload failed: ${h?.message||h}`),V=1}return Fe=c.getFlowTraceSteps(),E.close(),ae?(c.simId&&le.add(c.simId),await Qt(v.wsPort,v.commandTimeoutMs,[...le])):c.simId&&c.simId!==X&&Ne(c.simId),await ce(),V}async function Qt(n,e,t){let r=[...new Set(t.filter(Boolean))];if(r.length===0)return;let i=he(n,{commandTimeoutMs:e});try{let o=await i.listSims(),a=r.filter(l=>o.some(p=>p.id===l&&p.readyState==="open"));if(a.length===0)return;let s=await nt(i,n,e,a);await rt(o,a),s.closed.length>0&&console.log(` closed flow sim(s): ${s.closed.join(", ")}`),s.remaining.length>0&&console.warn(` warn: flow sim(s) still connected after close: ${s.remaining.join(", ")}`)}catch(o){console.warn(` warn: failed to close flow sim(s): ${o instanceof Error?o.message:String(o)}`)}finally{i.close()}}async function er(n){let{gzipSync:e}=await import("zlib"),t=n.map(o=>JSON.stringify(o)).join(`
537
+ `),O&&(console.log(" partial profile:"),gt(O)),F&&console.log(` partial video: ${F}`);try{let d=c.lastFailedStep,y=d?`step-${String(d.index+1).padStart(2,"0")}-${d.kind}`:"unstaged",I=w.join(s,y);await c.captureFailureBundle(I,{error:h,stepIndex:d?.index,stepKind:d?.kind,stepTarget:d?.target}),de=I,console.log(` failure bundle: ${I}`),console.log(" (contents: screenshot.png, describe.json, a11y.txt, tree.txt, console.json, error.json)")}catch(d){try{let y=w.join(s,"error.png");await c.captureScreenshot(y),console.log(` error screenshot: ${y}`)}catch{}console.log(` (failure bundle capture failed: ${d instanceof Error?d.message:String(d)})`)}await Ke(E,{errorsCommand:`sootsim get errors 5${c.simId?` --sim ${c.simId}`:""}`,warningsCommand:`sootsim get warnings 5${c.simId?` --sim ${c.simId}`:""}`,requestsCommand:`sootsim get requests 5${c.simId?` --sim ${c.simId}`:""}`}),V=1}if(await c.liveStatus?.end(V===0?"passed":"failed"),m&&(V===0||F||_))try{let h=await tr(_??[]),d=["--origin",k,"--events",h];$&&d.push("--public-origin",$),F&&d.push("--video",F),j&&d.push("--screenshot",j),F&&L&&Number.isFinite(L)&&(d.push("--video-duration-ms",String(Math.round(L))),d.push("--recorded-duration-ms",String(Math.round(L))));let y=c.getLastRecordingStartedAtMs();y&&Number.isFinite(y)&&d.push("--recording-started-at-ms",String(Math.round(y))),v.wsPort&&d.push("--port",String(v.wsPort)),c.simId&&d.push("--sim",c.simId),H&&d.push("--open"),Ie&&d.push("--owner",Ie),Pe&&d.push("--repo",Pe),d.push("--run-scope",yt),U&&d.push("--billing-kind",U),console.log(`
538
+ preparing preview upload\u2026`);let I=c.getFlowTraceSteps();I.length>0&&d.push("--timeline-events",await rr(I));let J=await ir(I,y);J&&d.push("--snapshot-manifest",J),de&&d.push("--failure-bundle",de);let D=c.getLastRecordingFrameStats();D&&d.push("--trace-frame-stats",await nr(D));let{runUpload:Pt}=await import("./upload-BLDJ2HNG.js");Ee=await Pt(d,{})}catch(h){console.error(` preview upload failed: ${h?.message||h}`),V=1}return Fe=c.getFlowTraceSteps(),E.close(),ae?(c.simId&&le.add(c.simId),await er(v.wsPort,v.commandTimeoutMs,[...le])):c.simId&&c.simId!==X&&Ne(c.simId),await ce(),V}async function er(n,e,t){let r=[...new Set(t.filter(Boolean))];if(r.length===0)return;let i=he(n,{commandTimeoutMs:e});try{let o=await i.listSims(),a=r.filter(l=>o.some(p=>p.id===l&&p.readyState==="open"));if(a.length===0)return;let s=await ot(i,n,e,a);await it(o,a),s.closed.length>0&&console.log(` closed flow sim(s): ${s.closed.join(", ")}`),s.remaining.length>0&&console.warn(` warn: flow sim(s) still connected after close: ${s.remaining.join(", ")}`)}catch(o){console.warn(` warn: failed to close flow sim(s): ${o instanceof Error?o.message:String(o)}`)}finally{i.close()}}async function tr(n){let{gzipSync:e}=await import("zlib"),t=n.map(o=>JSON.stringify(o)).join(`
539
539
  `)+(n.length?`
540
- `:""),r=e(Buffer.from(t,"utf8")),i=w.join(Y(),`sootsim-events-${Date.now()}.jsonl.gz`);return P.writeFileSync(i,r),console.log(` events: ${n.length} written to ${i} (${r.length} bytes gz)`),i}async function tr(n){let{gzipSync:e}=await import("zlib"),t=n.map((a,s)=>({schemaVersion:1,t:a.endedAtMs,seq:1e6+s,context:"host",kind:"flow-step",id:`flow-step-${a.stepIndex}`,data:{stepIndex:a.stepIndex,stepNumber:a.stepIndex+1,stepName:a.stepName,...a.targetLabel?{targetLabel:a.targetLabel}:{},status:a.status,durationMs:a.durationMs,startedAtMs:a.startedAtMs,endedAtMs:a.endedAtMs,...a.error?{error:a.error}:{}}})),r=t.map(a=>JSON.stringify(a)).join(`
540
+ `:""),r=e(Buffer.from(t,"utf8")),i=w.join(Y(),`sootsim-events-${Date.now()}.jsonl.gz`);return P.writeFileSync(i,r),console.log(` events: ${n.length} written to ${i} (${r.length} bytes gz)`),i}async function rr(n){let{gzipSync:e}=await import("zlib"),t=n.map((a,s)=>({schemaVersion:1,t:a.endedAtMs,seq:1e6+s,context:"host",kind:"flow-step",id:`flow-step-${a.stepIndex}`,data:{stepIndex:a.stepIndex,stepNumber:a.stepIndex+1,stepName:a.stepName,...a.targetLabel?{targetLabel:a.targetLabel}:{},status:a.status,durationMs:a.durationMs,startedAtMs:a.startedAtMs,endedAtMs:a.endedAtMs,...a.error?{error:a.error}:{}}})),r=t.map(a=>JSON.stringify(a)).join(`
541
541
  `)+`
542
- `,i=e(Buffer.from(r,"utf8")),o=w.join(Y(),`sootsim-flow-steps-${Date.now()}.jsonl.gz`);return P.writeFileSync(o,i),console.log(` flow trace: ${t.length} step events written to ${o} (${i.length} bytes gz)`),o}async function rr(n,e){if(!e)return null;let t=n.flatMap(i=>i.screenshotPath?[{id:`flow-step-${i.stepIndex}`,label:i.targetLabel??`Step ${i.stepIndex+1}`,kind:"interaction",t:Math.max(0,i.endedAtMs-e),path:i.screenshotPath}]:[]);if(t.length===0)return null;let r=w.join(Y(),`sootsim-flow-snapshots-${Date.now()}.json`);return P.writeFileSync(r,JSON.stringify(t)),console.log(` flow snapshots: ${t.length} written to ${r}`),r}async function ir(n){let e=w.join(Y(),`sootsim-frame-stats-${Date.now()}.json`);return P.writeFileSync(e,JSON.stringify(n)),console.log(` frame stats: written to ${e}`),e}async function nr(n){let e=n[0],t=r=>n.find((i,o)=>n[o-1]===r);switch(e){case"start":{let{path:r,state:i}=Ye();console.log(" flow draft started"),console.log(` session: ${r}`),console.log(` steps: ${i.steps.length}`);return}case"keep":case"good":{let r=ye();if(r.active||(console.error(" no active flow draft \u2014 run `sootsim maestro start` first"),process.exit(1)),!r.kept){console.log(" no pending action to keep");return}console.log(` kept: ${r.candidate.summary}`),console.log(` steps: ${r.stepCount}`);return}case"end":{let r=t("--output")||(n[1]&&!n[1].startsWith("-")?n[1]:void 0),i=n.includes("--validate")||n.includes("--video"),o=n.includes("--video"),a=ye();a.active&&a.kept&&console.log(` auto-kept trailing action: ${a.candidate.summary}`);let s=ze(r||(i?sr():void 0));if(s.active||(console.error(" no active flow draft \u2014 run `sootsim maestro start` first"),process.exit(1)),!s.valid){console.error(" flow draft is not valid:");for(let l of s.issues)console.error(` - ${l}`);console.error(" draft preserved \u2014 keep at least one real interaction or run `sootsim maestro start` to reset"),process.exit(1)}if(i){let l=ar(n,s.outputPath),p=await gt(l);if(p!==0){console.error(`
543
- validation failed \u2014 draft preserved so you can keep iterating`),process.exitCode=p;return}we(),console.log(` flow draft validated (${s.stepCount} step${s.stepCount===1?"":"s"})`),s.outputPath&&console.log(` saved: ${s.outputPath}`),o&&console.log(" video: recorded during validation run");return}if(we(),console.log(` flow draft ended (${s.stepCount} step${s.stepCount===1?"":"s"})`),s.outputPath){console.log(` saved: ${s.outputPath}`),console.log(` next: sootsim maestro test ${s.outputPath} --record`);return}console.log(""),process.stdout.write(s.yaml);return}case"validate":{let r=n[1];(!r||r.startsWith("-"))&&(console.error(" usage: sootsim maestro validate <path>"),process.exit(1));let i=ge(r);if(i.length>0){console.error(` x ${r} failed validation:`);for(let o of i)console.error(` - ${o}`);process.exit(1)}console.log(` + ${r} looks valid`);return}}}function or(n){return n[0]==="--sim"&&n.length>=2?[...n.slice(2),"--sim",n[1]]:n}async function Vr(n){let e=or(n),t=e[0];if(t==="start"||t==="keep"||t==="good"||t==="end"||t==="validate")return await nr(e),0;let r=await gt(e);return r!==0&&(process.exitCode=r),r}function mt(n){console.log(""),ot(n)}function sr(){return w.join(Y(),`sootsim-flow-draft-${Date.now()}.yaml`)}function ar(n,e){if(!e)throw new Error("validated flow draft requires an output path");let t=[e];for(let r=1;r<n.length;r++){let i=n[r];if(!(i==="--validate"||i==="--video")){if(i==="--output"){r+=1;continue}r===1&&!i.startsWith("-")||t.push(i)}}return!t.includes("--record")&&n.includes("--video")&&t.push("--record"),t}export{ut as a,_t as b,Wr as c,jr as d,Zt as e,gt as f,or as g,Vr as h};
542
+ `,i=e(Buffer.from(r,"utf8")),o=w.join(Y(),`sootsim-flow-steps-${Date.now()}.jsonl.gz`);return P.writeFileSync(o,i),console.log(` flow trace: ${t.length} step events written to ${o} (${i.length} bytes gz)`),o}async function ir(n,e){if(!e)return null;let t=n.flatMap(i=>i.screenshotPath?[{id:`flow-step-${i.stepIndex}`,label:i.targetLabel??`Step ${i.stepIndex+1}`,kind:"interaction",t:Math.max(0,i.endedAtMs-e),path:i.screenshotPath}]:[]);if(t.length===0)return null;let r=w.join(Y(),`sootsim-flow-snapshots-${Date.now()}.json`);return P.writeFileSync(r,JSON.stringify(t)),console.log(` flow snapshots: ${t.length} written to ${r}`),r}async function nr(n){let e=w.join(Y(),`sootsim-frame-stats-${Date.now()}.json`);return P.writeFileSync(e,JSON.stringify(n)),console.log(` frame stats: written to ${e}`),e}async function or(n){let e=n[0],t=r=>n.find((i,o)=>n[o-1]===r);switch(e){case"start":{let{path:r,state:i}=ze();console.log(" flow draft started"),console.log(` session: ${r}`),console.log(` steps: ${i.steps.length}`);return}case"keep":case"good":{let r=ye();if(r.active||(console.error(" no active flow draft \u2014 run `sootsim maestro start` first"),process.exit(1)),!r.kept){console.log(" no pending action to keep");return}console.log(` kept: ${r.candidate.summary}`),console.log(` steps: ${r.stepCount}`);return}case"end":{let r=t("--output")||(n[1]&&!n[1].startsWith("-")?n[1]:void 0),i=n.includes("--validate")||n.includes("--video"),o=n.includes("--video"),a=ye();a.active&&a.kept&&console.log(` auto-kept trailing action: ${a.candidate.summary}`);let s=Xe(r||(i?ar():void 0));if(s.active||(console.error(" no active flow draft \u2014 run `sootsim maestro start` first"),process.exit(1)),!s.valid){console.error(" flow draft is not valid:");for(let l of s.issues)console.error(` - ${l}`);console.error(" draft preserved \u2014 keep at least one real interaction or run `sootsim maestro start` to reset"),process.exit(1)}if(i){let l=lr(n,s.outputPath),p=await wt(l);if(p!==0){console.error(`
543
+ validation failed \u2014 draft preserved so you can keep iterating`),process.exitCode=p;return}we(),console.log(` flow draft validated (${s.stepCount} step${s.stepCount===1?"":"s"})`),s.outputPath&&console.log(` saved: ${s.outputPath}`),o&&console.log(" video: recorded during validation run");return}if(we(),console.log(` flow draft ended (${s.stepCount} step${s.stepCount===1?"":"s"})`),s.outputPath){console.log(` saved: ${s.outputPath}`),console.log(` next: sootsim maestro test ${s.outputPath} --record`);return}console.log(""),process.stdout.write(s.yaml);return}case"validate":{let r=n[1];(!r||r.startsWith("-"))&&(console.error(" usage: sootsim maestro validate <path>"),process.exit(1));let i=ge(r);if(i.length>0){console.error(` x ${r} failed validation:`);for(let o of i)console.error(` - ${o}`);process.exit(1)}console.log(` + ${r} looks valid`);return}}}function sr(n){return n[0]==="--sim"&&n.length>=2?[...n.slice(2),"--sim",n[1]]:n}async function Jr(n){let e=sr(n),t=e[0];if(t==="start"||t==="keep"||t==="good"||t==="end"||t==="validate")return await or(e),0;let r=await wt(e);return r!==0&&(process.exitCode=r),r}function gt(n){console.log(""),st(n)}function ar(){return w.join(Y(),`sootsim-flow-draft-${Date.now()}.yaml`)}function lr(n,e){if(!e)throw new Error("validated flow draft requires an output path");let t=[e];for(let r=1;r<n.length;r++){let i=n[r];if(!(i==="--validate"||i==="--video")){if(i==="--output"){r+=1;continue}r===1&&!i.startsWith("-")||t.push(i)}}return!t.includes("--record")&&n.includes("--video")&&t.push("--record"),t}export{pt as a,Dt as b,jr as c,Vr as d,Zt as e,Qt as f,wt as g,sr as h,Jr as i};