sootsim 0.1.214 → 0.1.216

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 (149) hide show
  1. package/detox/index.ts +30 -16
  2. package/dist-cli/bin.js +4 -4
  3. package/dist-cli/chunks/{agent-QE4ZAHV2.js → agent-RMGUE35J.js} +2 -2
  4. package/dist-cli/chunks/{agent-wrapper-E5HCJNYH.js → agent-wrapper-PNKMWDVX.js} +2 -2
  5. package/dist-cli/chunks/{app-fonts-4ADYMRQO.js → app-fonts-Z6SGSVKJ.js} +2 -2
  6. package/dist-cli/chunks/{assert-QZSX66RW.js → assert-ELIDRXY7.js} +2 -2
  7. package/dist-cli/chunks/{auth-LW224VBS.js → auth-2NJA7QI6.js} +2 -2
  8. package/dist-cli/chunks/beta-MTYUL7U7.js +2 -0
  9. package/dist-cli/chunks/{camera-MPIQ3JAA.js → camera-XICNRGGO.js} +2 -2
  10. package/dist-cli/chunks/{chunk-3CNHHY7U.js → chunk-2FNN7T63.js} +1 -1
  11. package/dist-cli/chunks/{chunk-USSUXBPG.js → chunk-4BUASWNE.js} +1 -1
  12. package/dist-cli/chunks/{chunk-I4UH6RI5.js → chunk-4XCGYTBN.js} +2 -2
  13. package/dist-cli/chunks/chunk-5LT4NR6Y.js +1 -0
  14. package/dist-cli/chunks/chunk-6KRC622O.js +1 -0
  15. package/dist-cli/chunks/{chunk-Z6X2QRA3.js → chunk-6TZMBHQ5.js} +3 -3
  16. package/dist-cli/chunks/{chunk-4RHFQCED.js → chunk-7SPHDLSB.js} +2 -2
  17. package/dist-cli/chunks/{chunk-6QMGV5H7.js → chunk-AWSL2LAA.js} +2 -2
  18. package/dist-cli/chunks/{chunk-L3CQVAWX.js → chunk-BGDEZZWT.js} +2 -2
  19. package/dist-cli/chunks/{chunk-DUGNFSB5.js → chunk-CCFLATUR.js} +2 -2
  20. package/dist-cli/chunks/{chunk-USW3U45B.js → chunk-CQSIRKJ2.js} +2 -2
  21. package/dist-cli/chunks/{chunk-KHIKG5LO.js → chunk-CRU7UL5Q.js} +1 -1
  22. package/dist-cli/chunks/{chunk-CZZZC3BU.js → chunk-CU3LQUJD.js} +2 -2
  23. package/dist-cli/chunks/chunk-DA7KPSMF.js +2 -0
  24. package/dist-cli/chunks/{chunk-SLX3HZPR.js → chunk-DRFWZ74H.js} +1 -1
  25. package/dist-cli/chunks/{chunk-XJEIT5CH.js → chunk-G6VHJWGQ.js} +1 -1
  26. package/dist-cli/chunks/{chunk-RRFWPEQ6.js → chunk-GIZDZKHC.js} +1 -1
  27. package/dist-cli/chunks/{chunk-IUTSWOUM.js → chunk-GPLW7IL5.js} +2 -2
  28. package/dist-cli/chunks/{chunk-QPZW76ZB.js → chunk-HBCEGJQH.js} +2 -2
  29. package/dist-cli/chunks/chunk-HIDDRHAN.js +99 -0
  30. package/dist-cli/chunks/chunk-HKKKZRKS.js +89 -0
  31. package/dist-cli/chunks/{chunk-DABWOLOT.js → chunk-HZCW6RRE.js} +2 -2
  32. package/dist-cli/chunks/{chunk-2344ZBLD.js → chunk-J4GDWHXE.js} +2 -2
  33. package/dist-cli/chunks/{chunk-TI2ZOHON.js → chunk-J74AW22R.js} +1 -1
  34. package/dist-cli/chunks/{chunk-6LJUMA3J.js → chunk-LWECTC6A.js} +2 -2
  35. package/dist-cli/chunks/{chunk-6EP67RW7.js → chunk-M2DYRSIS.js} +2 -2
  36. package/dist-cli/chunks/chunk-P5JY275Q.js +119 -0
  37. package/dist-cli/chunks/{chunk-XQP4TU6P.js → chunk-P735P65P.js} +93 -65
  38. package/dist-cli/chunks/{chunk-R35AOOU4.js → chunk-QNRORBZE.js} +2 -2
  39. package/dist-cli/chunks/{chunk-TX53NA5W.js → chunk-RESHDGBU.js} +1 -1
  40. package/dist-cli/chunks/{chunk-Y3T4POUK.js → chunk-S3C2S27B.js} +2 -2
  41. package/dist-cli/chunks/{chunk-AYY7JBXA.js → chunk-SBP46OOV.js} +1 -1
  42. package/dist-cli/chunks/{chunk-5LD4QHER.js → chunk-SPKRGAWR.js} +6 -6
  43. package/dist-cli/chunks/{chunk-YVIUYF5U.js → chunk-SSLFXUZQ.js} +1 -1
  44. package/dist-cli/chunks/chunk-TNPHXSMV.js +2 -0
  45. package/dist-cli/chunks/{chunk-AXXJSIT3.js → chunk-U7UICUB4.js} +2 -2
  46. package/dist-cli/chunks/{chunk-LRIZ5ACL.js → chunk-UGNYHNBN.js} +3 -3
  47. package/dist-cli/chunks/{chunk-GTRGDGRK.js → chunk-UPLXEL4D.js} +1 -1
  48. package/dist-cli/chunks/{chunk-2HCVCJB7.js → chunk-URGNAE7V.js} +31 -31
  49. package/dist-cli/chunks/{chunk-5P6QAHAI.js → chunk-VDONTXCB.js} +1 -1
  50. package/dist-cli/chunks/{chunk-L5XB3GRM.js → chunk-VSGSEQE7.js} +2 -2
  51. package/dist-cli/chunks/{chunk-BNUZWRON.js → chunk-VURHG6DO.js} +1 -1
  52. package/dist-cli/chunks/{chunk-KPRSDBWU.js → chunk-YN44PKW5.js} +1 -1
  53. package/dist-cli/chunks/cli-version-BP5GKAZ6.js +2 -0
  54. package/dist-cli/chunks/{compat-IZXTAA6Q.js → compat-MF7YZPCS.js} +3 -3
  55. package/dist-cli/chunks/{config-KV7J63HM.js → config-WJSCJ622.js} +2 -2
  56. package/dist-cli/chunks/{control-CRJA7SXC.js → control-AZFQJXJ5.js} +2 -2
  57. package/dist-cli/chunks/daemon-MU77JEAP.js +2 -0
  58. package/dist-cli/chunks/{debug-ZCPDU23K.js → debug-LIXGHFHV.js} +3 -3
  59. package/dist-cli/chunks/{desktop-HKTZX7OT.js → desktop-T7GTXHL4.js} +3 -3
  60. package/dist-cli/chunks/{detox-LNWHCNFM.js → detox-WV5FD4G6.js} +2 -2
  61. package/dist-cli/chunks/{device-AV34WOXK.js → device-GPHUF3BL.js} +2 -2
  62. package/dist-cli/chunks/{diagnose-7INR3HKD.js → diagnose-OAXHSPXW.js} +2 -2
  63. package/dist-cli/chunks/drivers-LJAA7XSZ.js +2 -0
  64. package/dist-cli/chunks/film-ZBYERRWW.js +69 -0
  65. package/dist-cli/chunks/flow-TXG46ARF.js +2 -0
  66. package/dist-cli/chunks/help-BVVLN5KL.js +2 -0
  67. package/dist-cli/chunks/{home-paths-ML5HT67C.js → home-paths-T3SY5QGR.js} +2 -2
  68. package/dist-cli/chunks/inspect-7SHQVCCL.js +2 -0
  69. package/dist-cli/chunks/install-desktop-RFGXCZRS.js +2 -0
  70. package/dist-cli/chunks/{login-IND3C7NP.js → login-QS2GVTJJ.js} +4 -4
  71. package/dist-cli/chunks/{logout-H6R4RQK7.js → logout-I752SSKU.js} +2 -2
  72. package/dist-cli/chunks/{maestro-IVTBNNF6.js → maestro-RDBKRP4O.js} +3 -3
  73. package/dist-cli/chunks/{maestro-generate-WCFBU5JM.js → maestro-generate-JOTQKAEH.js} +3 -3
  74. package/dist-cli/chunks/mode-Z4W3XXXU.js +24 -0
  75. package/dist-cli/chunks/optional-demo-registry-JTRVZB45.js +2 -0
  76. package/dist-cli/chunks/{perf-TNLPQUZI.js → perf-RXXW5GRA.js} +2 -2
  77. package/dist-cli/chunks/{record-MBJMHM23.js → record-527ZYKHE.js} +3 -3
  78. package/dist-cli/chunks/runtime-DOAHJLEK.js +2 -0
  79. package/dist-cli/chunks/{screenshot-command-Q5TFWB2R.js → screenshot-command-OBPEZJLR.js} +3 -3
  80. package/dist-cli/chunks/{screenshots-capture-AW5VYVOF.js → screenshots-capture-VC752Q3V.js} +2 -2
  81. package/dist-cli/chunks/{serve-L5XOVSCM.js → serve-NU6WWN2K.js} +2 -2
  82. package/dist-cli/chunks/{setup-TKXVNVBX.js → setup-6BJWI3PC.js} +3 -3
  83. package/dist-cli/chunks/{skills-GFZ5Z46I.js → skills-L7JPAJEZ.js} +2 -2
  84. package/dist-cli/chunks/{storage-SW3CLSLM.js → storage-XIZZSPC3.js} +2 -2
  85. package/dist-cli/chunks/store-3UAGOXD4.js +2 -0
  86. package/dist-cli/chunks/telemetry-IXCWQVEB.js +2 -0
  87. package/dist-cli/chunks/{timeline-LVV6HPFG.js → timeline-3MAGSV2V.js} +2 -2
  88. package/dist-cli/chunks/{upgrade-B22ZDON2.js → upgrade-YDHOHVYZ.js} +2 -2
  89. package/dist-cli/chunks/upload-YQVEPIO7.js +2 -0
  90. package/dist-cli/chunks/{version-G2X5AZHL.js → version-QDGDS5P2.js} +2 -2
  91. package/dist-cli/chunks/web-BK6VHH5W.js +2 -0
  92. package/dist-cli/chunks/{what-happened-2DEQUI25.js → what-happened-4GGACNI4.js} +2 -2
  93. package/dist-lib/agent-daemon-client.cjs +1 -1
  94. package/dist-lib/agent-events.cjs +1 -1
  95. package/dist-lib/agent-identity.cjs +1 -1
  96. package/dist-lib/agent-sessions.cjs +1 -1
  97. package/dist-lib/attached-projects.cjs +1 -1
  98. package/dist-lib/auth/shared-session.cjs +1 -1
  99. package/dist-lib/backend-origin.cjs +1 -1
  100. package/dist-lib/beta.cjs +1 -1
  101. package/dist-lib/beta.mjs +1 -1
  102. package/dist-lib/bridge-constants.cjs +1 -1
  103. package/dist-lib/cli-constants.cjs +1 -1
  104. package/dist-lib/config.cjs +1 -1
  105. package/dist-lib/detox/index.cjs +108 -12
  106. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  107. package/dist-lib/home-paths.cjs +1 -1
  108. package/dist-lib/host/bridge-host.cjs +1 -1
  109. package/dist-lib/host/fetch-proxy-handler.cjs +1 -1
  110. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  111. package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
  112. package/dist-lib/host/websocket-proxy.cjs +1 -1
  113. package/dist-lib/index.cjs +1 -1
  114. package/dist-lib/jump-to-source-babel.cjs +1 -1
  115. package/dist-lib/menu.cjs +1 -1
  116. package/dist-lib/menu.mjs +1 -1
  117. package/dist-lib/metro.cjs +1 -1
  118. package/dist-lib/profiles.cjs +1 -1
  119. package/dist-lib/render-mode.cjs +1 -1
  120. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  121. package/dist-lib/sdk.cjs +57 -9
  122. package/dist-lib/sdk.mjs +57 -9
  123. package/dist-lib/skills.cjs +41 -15
  124. package/dist-lib/vite.cjs +1 -1
  125. package/package.json +1 -1
  126. package/skills/soot/SKILL.md +1 -0
  127. package/skills/sootsim-debug/SKILL.md +6 -8
  128. package/skills/sootsim-perf/SKILL.md +4 -4
  129. package/dist-cli/chunks/beta-VXRR4GRU.js +0 -2
  130. package/dist-cli/chunks/chunk-FZPRFSTA.js +0 -2
  131. package/dist-cli/chunks/chunk-NQDDEWYD.js +0 -1
  132. package/dist-cli/chunks/chunk-T7CWPTU7.js +0 -2
  133. package/dist-cli/chunks/chunk-TQ7WAA2M.js +0 -119
  134. package/dist-cli/chunks/chunk-WEBUMXLD.js +0 -97
  135. package/dist-cli/chunks/chunk-WF6AY4K4.js +0 -1
  136. package/dist-cli/chunks/cli-version-5DZ5FKJC.js +0 -2
  137. package/dist-cli/chunks/daemon-LOYTWGGF.js +0 -2
  138. package/dist-cli/chunks/drivers-Z2TX4DMF.js +0 -2
  139. package/dist-cli/chunks/flow-7XFQKTBU.js +0 -2
  140. package/dist-cli/chunks/help-ODEIEVZ6.js +0 -2
  141. package/dist-cli/chunks/inspect-KFGNZ2E3.js +0 -2
  142. package/dist-cli/chunks/install-desktop-GTMDR7D5.js +0 -2
  143. package/dist-cli/chunks/mode-OXPEBMF2.js +0 -111
  144. package/dist-cli/chunks/optional-demo-registry-CHOUOWFF.js +0 -2
  145. package/dist-cli/chunks/runtime-NCWCN66Y.js +0 -2
  146. package/dist-cli/chunks/store-5AQQ6HKE.js +0 -2
  147. package/dist-cli/chunks/telemetry-L2M7NRKA.js +0 -2
  148. package/dist-cli/chunks/upload-UQRYTSL2.js +0 -2
  149. package/dist-cli/chunks/web-YCDMLF4V.js +0 -2
@@ -1,5 +1,5 @@
1
- /*! sootsim v0.1.214 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
- import{a as fe,c as me,d as ge,e as Ze,f as we,g as ye,h as Xe,i as be,j as Qe}from"./chunk-XQP4TU6P.js";import{a as Ye}from"./chunk-QPZW76ZB.js";import{a as tt}from"./chunk-CZZZC3BU.js";import{a as et}from"./chunk-WEBUMXLD.js";import{h as Ge,p as ze,r as Ke,v as qe}from"./chunk-4RHFQCED.js";import{f as Ce}from"./chunk-USW3U45B.js";import{a as Le}from"./chunk-AYY7JBXA.js";import{h as he,m as Ve}from"./chunk-IUTSWOUM.js";import{I as J,m as Ne,n as He,o as Ue,p as We}from"./chunk-XJEIT5CH.js";import{g as ue,h as pe,i as je}from"./chunk-5LD4QHER.js";import{a as Je}from"./chunk-RRFWPEQ6.js";import{a as Oe,b as ce}from"./chunk-6LJUMA3J.js";import{d as de,e as Be}from"./chunk-KPRSDBWU.js";import{g as _e,h as De}from"./chunk-T7CWPTU7.js";import*as k from"fs";import{createHash as Ht,randomUUID as Ut}from"node:crypto";import{tmpdir as ie}from"os";import*as g from"path";import*as S from"fs";import*as b from"path";var Tt="inset 0 0 0 0.5px #000, inset 0 0 0 2px #757575, inset 0 0 0 5px #212121",it=1;function Et(n){let e=De(n),t=e.scale,r=e.statusBarHeight>0&&!e.dynamicIsland&&e.homeIndicatorHeight===0&&e.cornerRadius===0,i=e.width,o=e.height,a=r?e.width+58:e.width+e.bezelWidth*2,s=r?e.height+111+111:e.height+e.bezelWidth*2,l=9.5,u=it,p=a+l*2,m=s+it*2,x=l+(r?29:e.bezelWidth),w=r?111:e.bezelWidth,P=r?52:e.cornerRadius+e.bezelWidth,_=[{side:"right",top:e.hardwareButtons.lock.top,height:e.hardwareButtons.lock.height,width:e.hardwareButtons.width},{side:"left",top:e.hardwareButtons.ringToggle.top,height:e.hardwareButtons.ringToggle.height,width:e.hardwareButtons.width},{side:"left",top:e.hardwareButtons.volumeUp.top,height:e.hardwareButtons.volumeUp.height,width:e.hardwareButtons.width},{side:"left",top:e.hardwareButtons.volumeDown.top,height:e.hardwareButtons.volumeDown.height,width:e.hardwareButtons.width}];return{model:n,renderScale:t,outerWidth:Math.round(p*t),outerHeight:Math.round(m*t),logicalOuterWidth:p,logicalOuterHeight:m,logicalFrameWidth:a,logicalFrameHeight:s,logicalFrameLeft:l,logicalFrameTop:u,logicalScreenWidth:i,logicalScreenHeight:o,logicalScreenLeft:x,logicalScreenTop:w,logicalScreenRadius:r?0:e.cornerRadius,logicalFrameRadius:P,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:Tt,buttons:_,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 Ft(n){let e=n.side==="right",t=e?"inset(-3px -3px -3px 0)":"inset(-3px 0 -3px -3px)";return`
1
+ /*! sootsim v0.1.216 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
+ import{a as me,c as ge,d as we,e as Xe,f as ye,g as be,h as Qe,i as Se,j as et}from"./chunk-P735P65P.js";import{a as Ze}from"./chunk-HBCEGJQH.js";import{a as rt}from"./chunk-CU3LQUJD.js";import{a as tt}from"./chunk-HIDDRHAN.js";import{h as ze,p as Ke,r as qe,v as Ye}from"./chunk-7SPHDLSB.js";import{f as Ce}from"./chunk-CQSIRKJ2.js";import{a as Ne}from"./chunk-SBP46OOV.js";import{h as fe,m as Je}from"./chunk-GPLW7IL5.js";import{I as J,m as He,n as Ue,o as We,p as je}from"./chunk-G6VHJWGQ.js";import{g as pe,h as he,i as Ve}from"./chunk-SPKRGAWR.js";import{a as Ge}from"./chunk-GIZDZKHC.js";import{a as _e,b as de}from"./chunk-LWECTC6A.js";import{d as ue,e as Le}from"./chunk-YN44PKW5.js";import{g as De,h as Be}from"./chunk-DA7KPSMF.js";import*as $ from"fs";import{createHash as Ut,randomUUID as Wt}from"node:crypto";import{tmpdir as K}from"os";import*as w from"path";import*as S from"fs";import*as b from"path";var Et="inset 0 0 0 0.5px #000, inset 0 0 0 2px #757575, inset 0 0 0 5px #212121",nt=1;function Ft(n){let e=Be(n),t=e.scale,r=e.statusBarHeight>0&&!e.dynamicIsland&&e.homeIndicatorHeight===0&&e.cornerRadius===0,i=e.width,o=e.height,a=r?e.width+58:e.width+e.bezelWidth*2,s=r?e.height+111+111:e.height+e.bezelWidth*2,l=9.5,u=nt,p=a+l*2,g=s+nt*2,T=l+(r?29:e.bezelWidth),m=r?111:e.bezelWidth,P=r?52:e.cornerRadius+e.bezelWidth,k=[{side:"right",top:e.hardwareButtons.lock.top,height:e.hardwareButtons.lock.height,width:e.hardwareButtons.width},{side:"left",top:e.hardwareButtons.ringToggle.top,height:e.hardwareButtons.ringToggle.height,width:e.hardwareButtons.width},{side:"left",top:e.hardwareButtons.volumeUp.top,height:e.hardwareButtons.volumeUp.height,width:e.hardwareButtons.width},{side:"left",top:e.hardwareButtons.volumeDown.top,height:e.hardwareButtons.volumeDown.height,width:e.hardwareButtons.width}];return{model:n,renderScale:t,outerWidth:Math.round(p*t),outerHeight:Math.round(g*t),logicalOuterWidth:p,logicalOuterHeight:g,logicalFrameWidth:a,logicalFrameHeight:s,logicalFrameLeft:l,logicalFrameTop:u,logicalScreenWidth:i,logicalScreenHeight:o,logicalScreenLeft:T,logicalScreenTop:m,logicalScreenRadius:r?0:e.cornerRadius,logicalFrameRadius:P,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:Et,buttons:k,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 It(n){let e=n.side==="right",t=e?"inset(-3px -3px -3px 0)":"inset(-3px 0 -3px -3px)";return`
3
3
  <div
4
4
  aria-hidden="true"
5
5
  style="
@@ -24,7 +24,7 @@ import{a as fe,c as me,d as ge,e as Ze,f as we,g as ye,h as Xe,i as be,j as Qe}f
24
24
  z-index:2;
25
25
  "
26
26
  ></div>
27
- `}function It(n,e){let t=n.buttons.map(Ft).join(""),r=n.metallicRingShadow?`
27
+ `}function $t(n,e){let t=n.buttons.map(It).join(""),r=n.metallicRingShadow?`
28
28
  <div
29
29
  aria-hidden="true"
30
30
  style="
@@ -177,7 +177,7 @@ import{a as fe,c as me,d as ge,e as Ze,f as we,g as ye,h as Xe,i as be,j as Qe}f
177
177
  </div>
178
178
  </div>
179
179
  </body>
180
- </html>`}async function nt(n,e){let{chromium:t}=await import("playwright"),r=await t.launch({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=Et(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(It(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 kt}from"child_process";import*as C from"vm";var Pt=3e5,At=`
180
+ </html>`}async function ot(n,e){let{chromium:t}=await import("playwright"),r=await t.launch({headless:!0});try{let i=await Pt(r);try{return await i.compose(n,e)}finally{await i.close()}}finally{await r.close()}}async function Pt(n){let e=new Map;async function t(r){let i=e.get(r);if(i)return i;let o=Ft(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 kt}from"child_process";import*as N from"vm";var At=3e5,Mt=`
181
181
  let input = '';
182
182
  process.stdin.on('data', (c) => { input += c });
183
183
  process.stdin.on('end', async () => {
@@ -199,7 +199,7 @@ process.stdin.on('end', async () => {
199
199
  process.exitCode = 1;
200
200
  }
201
201
  });
202
- `;function G(n,e,t){if(t?.multipartForm)throw new Error("http: multipartForm is not supported by sootsim yet");let r={...process.env};for(let s of Object.keys(r))(s.startsWith("BUN_INSPECT")||s==="NODE_OPTIONS")&&delete r[s];let i=kt(process.execPath,["-e",At],{input:JSON.stringify({url:n,method:e,headers:t?.headers,body:t?.body}),encoding:"utf8",timeout:Pt,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 Rt=/(?<!\\)\$\{([^$]*)\}/g,Mt=/\\(\$\{[^$]*\})/g,Ot=/^[A-Za-z_$][A-Za-z0-9_$]*$/,Z=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:ot(o)).join(" "))}};this.context=C.createContext(r),C.runInContext(`
202
+ `;function G(n,e,t){if(t?.multipartForm)throw new Error("http: multipartForm is not supported by sootsim yet");let r={...process.env};for(let s of Object.keys(r))(s.startsWith("BUN_INSPECT")||s==="NODE_OPTIONS")&&delete r[s];let i=kt(process.execPath,["-e",Mt],{input:JSON.stringify({url:n,method:e,headers:t?.headers,body:t?.body}),encoding:"utf8",timeout:At,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 Rt=/(?<!\\)\$\{([^$]*)\}/g,Ot=/\\(\$\{[^$]*\})/g,_t=/^[A-Za-z_$][A-Za-z0-9_$]*$/,X=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:st(o)).join(" "))}};this.context=N.createContext(r),N.runInContext(`
203
203
  globalThis.__maestroScope = new Proxy(globalThis, {
204
204
  has() { return true },
205
205
  get(target, key) { return target[key] },
@@ -210,13 +210,13 @@ process.stdin.on('end', async () => {
210
210
  var yPercent = Math.ceil(y * 100) + '%'
211
211
  return xPercent + ',' + yPercent
212
212
  }
213
- `,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(Rt,(r,i)=>{if(i.trim().length===0)return"";let o=this.evaluate(i);if(o===void 0&&Ot.test(i.trim()))throw new Error(`missing variable for flow placeholder: ${i.trim()}`);return ot(o)}).replace(Mt,(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 ot(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 st(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 X=1e4,ee=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 z(n,e){if(!Te(n))return null;let t=n[e];return typeof t=="string"&&t.length>0?t:null}function _t(n,e){return Te(n)?n[e]===!0:!1}function Dt(n){if(!n)return null;let e=n.recentApps;if(Array.isArray(e))for(let r of e){let i=z(r,"id");if(i)return i}let t=n.surfaceBindings;return z(t,"app:one")||z(t,"app:two")||null}function Bt(n){return n?b.basename(n)===".maestro"?b.dirname(n):n:process.cwd()}function Lt(n,e,t){let r=e.endsWith(".png")?e:`${e}.png`;if(b.isAbsolute(r))return r;if(t.mode==="flow"&&/[\\/]/.test(r)){let i=r.startsWith("./")||r.startsWith("../")?t.flowDir??process.cwd():Bt(t.flowDir);return b.resolve(i,r)}return b.join(n,r)}function Ct(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 Q(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??ee),y:a+i(r,e?.height??N)}}function at(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 Nt(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 te=class{constructor(e,t){this.bridge=e;this.opts=t}stepDelay=0;js=new Z({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 waitForTree(e=X){let t=Date.now()+e,r=Date.now(),i=null,o=0,a=0,s=-1,l=r;for(;Date.now()<t;){try{let p=await this.evaluate(Ne,8e3);if(o=0,p?.externalError)throw new Error(`app failed to load: ${p.externalError}`);if(p){let m=Date.now();p.nodes!==s&&(s=p.nodes,l=m);let x=p.flag===!0&&Ue(p),w=p.flag!==!0&&We(p);if((x||w)&&p.externalReady!==!1&&!p.externalError&&!p.loadingText&&m-l>=He)return}}catch(p){if(i=p instanceof Error?p:new Error(String(p)),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 \`sootsim list\`, then close it with \`sootsim close <id>\` or start a fresh one with \`sootsim open --new <port>\`.`);await this.refreshSimId()}let u=Date.now()-r;u-a>=5e3&&(a=u,console.log(` [flow] waiting for app to be ready\u2026 (${Math.round(u/1e3)}s)`)),await f(500)}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 tt("flow --video",{originOverride:this.opts.billingOriginOverride,allowGitHubAuth:this.opts.allowGitHubRecording}),this.recordingAccessChecked=!0);let e=Date.now(),t=await this.evaluate(`(() => {
213
+ `,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(Rt,(r,i)=>{if(i.trim().length===0)return"";let o=this.evaluate(i);if(o===void 0&&_t.test(i.trim()))throw new Error(`missing variable for flow placeholder: ${i.trim()}`);return st(o)}).replace(Ot,(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 st(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 at(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 Q=1e4,te=393,C=852;function f(n){return new Promise(e=>setTimeout(e,n))}function Ee(n){return!!(n&&typeof n=="object"&&!Array.isArray(n))}function z(n,e){if(!Ee(n))return null;let t=n[e];return typeof t=="string"&&t.length>0?t:null}function Dt(n,e){return Ee(n)?n[e]===!0:!1}function Bt(n){if(!n)return null;let e=n.recentApps;if(Array.isArray(e))for(let r of e){let i=z(r,"id");if(i)return i}let t=n.surfaceBindings;return z(t,"app:one")||z(t,"app:two")||null}function Lt(n){return n?b.basename(n)===".maestro"?b.dirname(n):n:process.cwd()}function Nt(n,e,t){let r=e.endsWith(".png")?e:`${e}.png`;if(b.isAbsolute(r))return r;if(t.mode==="flow"&&/[\\/]/.test(r)){let i=r.startsWith("./")||r.startsWith("../")?t.flowDir??process.cwd():Lt(t.flowDir);return b.resolve(i,r)}return b.join(n,r)}function Ct(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 ee(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??te),y:a+i(r,e?.height??C)}}function lt(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 Ht(n){let e=n.split(/^---$/m),t=e.length>1?e[e.length-1]:n,r=Ze.parse(t);return Array.isArray(r)?r:[]}var re=class{constructor(e,t){this.bridge=e;this.opts=t}stepDelay=0;js=new X({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 waitForTree(e=Q){let t=Date.now()+e,r=Date.now(),i=null,o=0,a=0,s=-1,l=r;for(;Date.now()<t;){try{let p=await this.evaluate(He,8e3);if(o=0,p?.externalError)throw new Error(`app failed to load: ${p.externalError}`);if(p){let g=Date.now();p.nodes!==s&&(s=p.nodes,l=g);let T=p.flag===!0&&We(p),m=p.flag!==!0&&je(p);if((T||m)&&p.externalReady!==!1&&!p.externalError&&!p.loadingText&&g-l>=Ue)return}}catch(p){if(i=p instanceof Error?p:new Error(String(p)),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 \`sootsim list\`, then close it with \`sootsim close <id>\` or start a fresh one with \`sootsim open --new <port>\`.`);await this.refreshSimId()}let u=Date.now()-r;u-a>=5e3&&(a=u,console.log(` [flow] waiting for app to be ready\u2026 (${Math.round(u/1e3)}s)`)),await f(500)}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 rt("flow --video",{originOverride:this.opts.billingOriginOverride,allowGitHubAuth:this.opts.allowGitHubRecording}),this.recordingAccessChecked=!0);let e=Date.now(),t=await this.evaluate(`(() => {
214
214
  const rec = window.__sootsimRecorder
215
215
  if (!rec) return { ok: false, error: 'recorder unavailable on this page' }
216
216
  const format = ${JSON.stringify(this.opts.recordingFormat??"webm")}
217
217
  if (rec.state() === 'recording') return { ok: true, format }
218
218
  return rec.start({ format, fps: 24 })
219
- })()`);if(!t?.ok)throw new Error(t?.error||"recording unavailable on this page");this.recordingStartedAtMs||(this.recordingStartedAtMs=typeof t.startedAtMs=="number"&&Number.isFinite(t.startedAtMs)?t.startedAtMs:e)}async startRecording(){this.recordingEnabled=!0,await this.ensureRecordingStarted()}prepareRecording(){this.recordingEnabled=!0}getLastRecordingDurationMs(){return this.lastRecordingDurationMs}getLastRecordingStartedAtMs(){return this.lastRecordingStartedAtMs}getLastRecordingFrameStats(){return this.lastRecordingFrameStats}getFlowTraceSteps(){return[...this.flowTraceSteps]}flowStepTargetLabel(e,t){if(t==="inputText"||t==="runScript"||t==="evalScript")return;let r=e[t];if(typeof r=="string")return r.slice(0,80);if(typeof r=="number"||typeof r=="boolean")return String(r);if(!r||typeof r!="object")return;let i=r,o=i.id??i.text??i.name??i.path;if(typeof o=="string"&&o)return o.slice(0,80);if(i.point&&typeof i.point=="string")return i.point.slice(0,80);if(typeof i.x=="number"&&typeof i.y=="number")return`${Math.round(i.x)}, ${Math.round(i.y)}`}recordFlowTraceStep(e){let t=Date.now(),r={stepIndex:e.stepIndex,stepName:e.stepName,...e.targetLabel?{targetLabel:e.targetLabel}:{},startedAtMs:e.startedAtMs,endedAtMs:t,durationMs:Math.max(0,t-e.startedAtMs),status:e.status};e.error!=null&&(r.error=e.error instanceof Error?e.error.message:String(e.error)),this.flowTraceSteps.push(r)}async stopRecording(){if(!this.recordingEnabled||!this.opts.recordingOutputDir)return null;this.recordingEnabled=!1;let e=Date.now(),t=await this.evaluate("window.__sootsimRecorder.stop()");if(!t?.ok)throw this.recordingStartedAtMs=null,this.lastRecordingFrameStats=null,new Error(t?.error||"recording stop failed");this.lastRecordingStartedAtMs=this.recordingStartedAtMs,this.lastRecordingDurationMs=this.recordingStartedAtMs?Math.max(1,e-this.recordingStartedAtMs):null,this.lastRecordingFrameStats=t.frameStats??null,this.recordingStartedAtMs=null;let r=[],i=0;for(;;){let l=await this.evaluate(`window.__sootsimRecorder.getBlobBase64({ offset: ${i}, chunk: 2097152 })`);if(!l||(r.push(Buffer.from(l.data,"base64")),i=l.offset,l.done))break}if(r.length===0)throw new Error("recording requested but no video buffer was produced");S.mkdirSync(this.opts.recordingOutputDir,{recursive:!0});let a=(t.mime||this.opts.recordingFormat||"video/webm").includes("mp4")?"mp4":"webm",s=b.join(this.opts.recordingOutputDir,`sootsim-${Date.now()}.${a}`);return S.writeFileSync(s,Buffer.concat(r)),s}async waitForRecordingTail(e){if(!this.recordingEnabled)return;let t=Math.max(0,Math.round(e.maxMs));if(t<=0)return;if(!e.smart){await f(t);return}let r=await be({bridge:this.bridge,simId:this.opts.simId,maxMs:t,pollMs:80,stablePolls:6,strict:!0});await this.waitForVisualSettle(),console.log(r.settled?` [flow] recording tail settled in ${r.elapsed}ms`:` [flow] recording tail reached ${r.elapsed}ms budget`)}async findElement(e){if(e.childOf!=null||typeof e.index=="number")return this.findElementScoped(e);let t=!!e.text&&/[.*+?^$()[\]{}|\\]/.test(e.text);return this.evaluate(`(async () => {
219
+ })()`);if(!t?.ok)throw new Error(t?.error||"recording unavailable on this page");this.recordingStartedAtMs||(this.recordingStartedAtMs=typeof t.startedAtMs=="number"&&Number.isFinite(t.startedAtMs)?t.startedAtMs:e)}async startRecording(){this.recordingEnabled=!0,await this.ensureRecordingStarted()}prepareRecording(){this.recordingEnabled=!0}getLastRecordingDurationMs(){return this.lastRecordingDurationMs}getLastRecordingStartedAtMs(){return this.lastRecordingStartedAtMs}getLastRecordingFrameStats(){return this.lastRecordingFrameStats}getFlowTraceSteps(){return[...this.flowTraceSteps]}flowStepTargetLabel(e,t){if(t==="inputText"||t==="runScript"||t==="evalScript")return;let r=e[t];if(typeof r=="string")return r.slice(0,80);if(typeof r=="number"||typeof r=="boolean")return String(r);if(!r||typeof r!="object")return;let i=r,o=i.id??i.text??i.name??i.path;if(typeof o=="string"&&o)return o.slice(0,80);if(i.point&&typeof i.point=="string")return i.point.slice(0,80);if(typeof i.x=="number"&&typeof i.y=="number")return`${Math.round(i.x)}, ${Math.round(i.y)}`}recordFlowTraceStep(e){let t=Date.now(),r={stepIndex:e.stepIndex,stepName:e.stepName,...e.targetLabel?{targetLabel:e.targetLabel}:{},startedAtMs:e.startedAtMs,endedAtMs:t,durationMs:Math.max(0,t-e.startedAtMs),status:e.status};e.error!=null&&(r.error=e.error instanceof Error?e.error.message:String(e.error)),e.screenshotPath&&(r.screenshotPath=e.screenshotPath),this.flowTraceSteps.push(r)}async stopRecording(){if(!this.recordingEnabled||!this.opts.recordingOutputDir)return null;this.recordingEnabled=!1;let e=Date.now(),t=await this.evaluate("window.__sootsimRecorder.stop()");if(!t?.ok)throw this.recordingStartedAtMs=null,this.lastRecordingFrameStats=null,new Error(t?.error||"recording stop failed");this.lastRecordingStartedAtMs=this.recordingStartedAtMs,this.lastRecordingDurationMs=this.recordingStartedAtMs?Math.max(1,e-this.recordingStartedAtMs):null,this.lastRecordingFrameStats=t.frameStats??null,this.recordingStartedAtMs=null;let r=[],i=0;for(;;){let l=await this.evaluate(`window.__sootsimRecorder.getBlobBase64({ offset: ${i}, chunk: 2097152 })`);if(!l||(r.push(Buffer.from(l.data,"base64")),i=l.offset,l.done))break}if(r.length===0)throw new Error("recording requested but no video buffer was produced");S.mkdirSync(this.opts.recordingOutputDir,{recursive:!0});let a=(t.mime||this.opts.recordingFormat||"video/webm").includes("mp4")?"mp4":"webm",s=b.join(this.opts.recordingOutputDir,`sootsim-${Date.now()}.${a}`);return S.writeFileSync(s,Buffer.concat(r)),s}async waitForRecordingTail(e){if(!this.recordingEnabled)return;let t=Math.max(0,Math.round(e.maxMs));if(t<=0)return;if(!e.smart){await f(t);return}let r=await Se({bridge:this.bridge,simId:this.opts.simId,maxMs:t,pollMs:80,stablePolls:6,strict:!0});await this.waitForVisualSettle(),console.log(r.settled?` [flow] recording tail settled in ${r.elapsed}ms`:` [flow] recording tail reached ${r.elapsed}ms budget`)}async findElement(e){if(e.childOf!=null||typeof e.index=="number")return this.findElementScoped(e);let t=!!e.text&&/[.*+?^$()[\]{}|\\]/.test(e.text);return this.evaluate(`(async () => {
220
220
  const test = window.__sootsimTest
221
221
  if (!test) return null
222
222
  let node = null
@@ -293,7 +293,7 @@ process.stdin.on('end', async () => {
293
293
  // resolves a target that needs scrolling into view.
294
294
  const onScreen = candidates.filter((n) => {
295
295
  const cy = n.absolutePosition.y + n.layout.height / 2
296
- return cy > 0 && cy < ${N}
296
+ return cy > 0 && cy < ${C}
297
297
  })
298
298
  if (onScreen.length > 0) candidates = onScreen
299
299
  ${e.childOf?`
@@ -365,7 +365,7 @@ process.stdin.on('end', async () => {
365
365
  )
366
366
  }
367
367
  return direct
368
- })()`)}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);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{...Q(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?{...Q(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,u=l?.cx??s.absolutePosition.x+s.layout.width/2,p=l?.cy??s.absolutePosition.y+s.layout.height/2;if((await this.tap(u,p,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=Math.max(0,Math.round(r));if(!await this.evaluate(`(async () => {
368
+ })()`)}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{...ee(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?{...ee(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,u=l?.cx??s.absolutePosition.x+s.layout.width/2,p=l?.cy??s.absolutePosition.y+s.layout.height/2;if((await this.tap(u,p,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=Math.max(0,Math.round(r));if(!await this.evaluate(`(async () => {
369
369
  const interact = window.__sootsimInteract
370
370
  if (interact?.doubleTap) {
371
371
  return !!(await interact.doubleTap(${e}, ${t}, ${i}))
@@ -376,7 +376,7 @@ process.stdin.on('end', async () => {
376
376
  await new Promise((resolve) => setTimeout(resolve, ${i}))
377
377
  const second = await interact.tap(${e}, ${t})
378
378
  return !!second && second.hit !== false
379
- })()`))throw new Error(`doubleTapAtCoords failed at (${e}, ${t})`);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(`(() => {
379
+ })()`))throw new Error(`doubleTapAtCoords failed at (${e}, ${t})`);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(`(() => {
380
380
  const keyboard =
381
381
  window.__sootsimKeyboard ??
382
382
  window.SootSim?.bridges?.keyboard ??
@@ -386,7 +386,7 @@ process.stdin.on('end', async () => {
386
386
  visible: !!keyboard?.isVisible?.(),
387
387
  focused: !!test?.isTextInputFocused?.(),
388
388
  }
389
- })()`);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()+(e.timeout||X);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||X}ms${i}`)}async takeScreenshot(e){if(!this.hasFreshVisualSettle())try{await this.waitForVisualSettle(),await f(250)}catch{}let t=Ct(e),r=Lt(this.opts.screenshotDir,t.path,{mode:this.opts.screenshotPathMode??"dir",flowDir:this.opts.flowDir});S.mkdirSync(b.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 u=await this.readCurrentDeviceModel();if(!u)throw new Error("could not read current device model for framed screenshot");let p=await nt(l,u);S.writeFileSync(r,p),console.log(`[flow] screenshot: ${r} (frame: ${u})`);return}S.writeFileSync(r,l),console.log(`[flow] screenshot: ${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 _e)?null:t}async captureScreenshot(e){S.mkdirSync(b.dirname(e),{recursive:!0});let r=(await this.bridge.send({type:"screenshot",simId:this.opts.simId})).replace(/^data:image\/png;base64,/,"");S.writeFileSync(e,Buffer.from(r,"base64"))}async captureFailureBundle(e,t){S.mkdirSync(e,{recursive:!0});let r=(p,m)=>{try{S.writeFileSync(b.join(e,p),m)}catch{}},i=async p=>{try{return await this.bridge.send({type:"evaluate",simId:this.opts.simId,code:p})}catch{return null}},o=await i(`(async () => {
389
+ })()`);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()+(e.timeout||Q);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||Q}ms${i}`)}async takeScreenshot(e){if(!this.hasFreshVisualSettle())try{await this.waitForVisualSettle(),await f(250)}catch{}let t=Ct(e),r=Nt(this.opts.screenshotDir,t.path,{mode:this.opts.screenshotPathMode??"dir",flowDir:this.opts.flowDir});S.mkdirSync(b.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 u=await this.readCurrentDeviceModel();if(!u)throw new Error("could not read current device model for framed screenshot");let p=await ot(l,u);return S.writeFileSync(r,p),console.log(`[flow] screenshot: ${r} (frame: ${u})`),r}return S.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 De)?null:t}async captureScreenshot(e){S.mkdirSync(b.dirname(e),{recursive:!0});let r=(await this.bridge.send({type:"screenshot",simId:this.opts.simId})).replace(/^data:image\/png;base64,/,"");S.writeFileSync(e,Buffer.from(r,"base64"))}async captureFailureBundle(e,t){S.mkdirSync(e,{recursive:!0});let r=(p,g)=>{try{S.writeFileSync(b.join(e,p),g)}catch{}},i=async p=>{try{return await this.bridge.send({type:"evaluate",simId:this.opts.simId,code:p})}catch{return null}},o=await i(`(async () => {
390
390
  const out = {
391
391
  simId: window.__sootsimBridge?.id ?? window.SootSim?.state?.simId ?? null,
392
392
  url: location.href,
@@ -410,7 +410,7 @@ process.stdin.on('end', async () => {
410
410
  }
411
411
  } catch {}
412
412
  return out
413
- })()`);r("error.json",JSON.stringify({message:t.error.message,stack:t.error.stack,stepIndex:t.stepIndex,stepKind:t.stepKind,stepTarget:t.stepTarget,capturedAt:new Date().toISOString(),sim:o??null},null,2));try{let m=(await this.bridge.send({type:"screenshot",simId:this.opts.simId})).replace(/^data:image\/png;base64,/,"");r("screenshot.png",Buffer.from(m,"base64"))}catch{}let a=await i(`(async () => {
413
+ })()`);r("error.json",JSON.stringify({message:t.error.message,stack:t.error.stack,stepIndex:t.stepIndex,stepKind:t.stepKind,stepTarget:t.stepTarget,capturedAt:new Date().toISOString(),sim:o??null},null,2));try{let g=(await this.bridge.send({type:"screenshot",simId:this.opts.simId})).replace(/^data:image\/png;base64,/,"");r("screenshot.png",Buffer.from(g,"base64"))}catch{}let a=await i(`(async () => {
414
414
  const t = window.__sootsimTest
415
415
  const mainShell = window.SootSim?.bridges?.mainShell
416
416
  if (!t) return { error: 'no test bridge' }
@@ -427,12 +427,12 @@ process.stdin.on('end', async () => {
427
427
  warnings: c?.getWarnings?.() ?? [],
428
428
  requests: (window.__sootsimGetFailedRequests?.() ?? []),
429
429
  }
430
- })()`);return u&&r("console.json",JSON.stringify(u,null,2)),e}async swipe(e="UP",t=300){let r=ee/2,i=N/2,o=200,a=r,s=i,l=r,u=i;switch(e.toUpperCase()){case"UP":s+=o,u-=o;break;case"DOWN":s-=o,u+=o;break;case"LEFT":a+=o,l-=o;break;case"RIGHT":a-=o,l+=o;break}let p=Math.max(10,Math.round(t/16));await this.drag(a,s,l,u,p,16)}async drag(e,t,r,i,o=12,a=16){if(!(await this.evaluate(`(async () => {
430
+ })()`);return u&&r("console.json",JSON.stringify(u,null,2)),e}async swipe(e="UP",t=300){let r=te/2,i=C/2,o=200,a=r,s=i,l=r,u=i;switch(e.toUpperCase()){case"UP":s+=o,u-=o;break;case"DOWN":s-=o,u+=o;break;case"LEFT":a+=o,l-=o;break;case"RIGHT":a-=o,l+=o;break}let p=Math.max(10,Math.round(t/16));await this.drag(a,s,l,u,p,16)}async drag(e,t,r,i,o=12,a=16){if(!(await this.evaluate(`(async () => {
431
431
  const interact = window.__sootsimInteract
432
432
  if (!interact?.drag) return { ok: false }
433
433
  const value = await interact.drag(${e}, ${t}, ${r}, ${i}, ${Math.max(1,Math.round(o))}, ${Math.max(0,Math.round(a))})
434
434
  return { ok: !!value, value }
435
- })()`))?.ok)throw new Error("drag failed");await f(300)}async swipeCoords(e,t,r=300){let i=Q(e),o=Q(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,u=a;switch(t.toUpperCase()){case"UP":u-=s;break;case"DOWN":u+=s;break;case"LEFT":l-=s;break;case"RIGHT":l+=s;break}let p=Math.max(10,Math.round(r/16));await this.drag(o,a,l,u,p,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.evaluate(`(async () => {
435
+ })()`))?.ok)throw new Error("drag failed");await f(300)}async swipeCoords(e,t,r=300){let i=ee(e),o=ee(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,u=a;switch(t.toUpperCase()){case"UP":u-=s;break;case"DOWN":u+=s;break;case"LEFT":l-=s;break;case"RIGHT":l+=s;break}let p=Math.max(10,Math.round(r/16));await this.drag(o,a,l,u,p,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.evaluate(`(async () => {
436
436
  const interact = window.__sootsimInteract
437
437
  if (!interact?.pinch) return { ok: false, reason: 'no interact.pinch' }
438
438
  const ok = await interact.pinch(
@@ -441,7 +441,7 @@ process.stdin.on('end', async () => {
441
441
  ${e.steps||12}, ${e.stepMs||16}
442
442
  )
443
443
  return { ok: !!ok, reason: ok ? null : 'pinch returned false' }
444
- })()`);if(!t?.ok)throw new Error(`pinch failed: ${t?.reason||"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),u=s>0?a-l:a+l;await this.drag(ee/2,a,ee/2,u,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()+(e.timeout||X);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(e){if(e){let i=!1;for(let o=0;o<3&&!i;o++)try{i=await this.evaluate(fe(!0),2e4)}catch{await f(1e3)}i||console.warn(" warn: tenant storage clear did not ack \u2014 hard-reloading anyway (worker reset follows)")}await this.evaluate("window.location.reload()").catch(()=>{}),await f(500),await this.refreshSimId()}async softReloadGuestApp(e){if(!await this.evaluate(fe(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 (sootsim has no native process)");let t=!!(e&&typeof e=="object"&&e.clearState),r=_t(e,"resetRuntime");if(!this.firstLaunchDone&&!t){if(this.firstLaunchDone=!0,r){let i=await J(this.bridge).catch(()=>null),o=i?.state==="home"&&i.activeApp==null;await this.softReloadGuestApp(!1),await this.waitForTree(12e4),o&&(await he(this.bridge,"goHome",1e3),await this.waitForShellHome(1e3)),await this.launchShellAppFromHomeIfNeeded(e,o?{...i??{},state:"home",activeApp:null}:null)}else await this.launchShellAppFromHomeIfNeeded(e);await this.waitForTree(3e4)}else if(this.firstLaunchDone=!0,await this.reloadGuestApp(t),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) => {
444
+ })()`);if(!t?.ok)throw new Error(`pinch failed: ${t?.reason||"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 Se({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),u=s>0?a-l:a+l;await this.drag(te/2,a,te/2,u,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()+(e.timeout||Q);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(e){if(e){let i=!1;for(let o=0;o<3&&!i;o++)try{i=await this.evaluate(me(!0),2e4)}catch{await f(1e3)}i||console.warn(" warn: tenant storage clear did not ack \u2014 hard-reloading anyway (worker reset follows)")}await this.evaluate("window.location.reload()").catch(()=>{}),await f(500),await this.refreshSimId()}async softReloadGuestApp(e){if(!await this.evaluate(me(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 (sootsim has no native process)");let t=!!(e&&typeof e=="object"&&e.clearState),r=Dt(e,"resetRuntime");if(!this.firstLaunchDone&&!t){if(this.firstLaunchDone=!0,r){let i=await J(this.bridge).catch(()=>null),o=i?.state==="home"&&i.activeApp==null;await this.softReloadGuestApp(!1),await this.waitForTree(12e4),o&&(await fe(this.bridge,"goHome",1e3),await this.waitForShellHome(1e3)),await this.launchShellAppFromHomeIfNeeded(e,o?{...i??{},state:"home",activeApp:null}:null)}else await this.launchShellAppFromHomeIfNeeded(e);await this.waitForTree(3e4)}else if(this.firstLaunchDone=!0,await this.reloadGuestApp(t),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) => {
445
445
  requestAnimationFrame(() => {
446
446
  requestAnimationFrame(() => {
447
447
  requestAnimationFrame(() => {
@@ -449,7 +449,7 @@ process.stdin.on('end', async () => {
449
449
  })
450
450
  })
451
451
  })
452
- })`),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=z(e,"appId")||z(e,"id");if(r)return r}return Dt(t)||"connect"}async waitForShellAppLaunched(e,t){let r=Date.now()+t,i=null;for(;Date.now()<r;){try{i=await J(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 waitForShellHome(e){let t=Date.now()+e;for(;Date.now()<t;){let r=await J(this.bridge).catch(()=>null);if(r?.state==="home"&&r.activeApp==null&&r.showSwitcher===!1)return;await f(16)}}async launchShellAppFromHomeIfNeeded(e,t){let r=null;if(t)r=t;else try{r=await J(this.bridge)}catch{return!1}if(r?.state!=="home"||r.activeApp!=null)return!1;let i=this.resolveShellLaunchAppId(e,r);return this.recordingEnabled&&await this.ensureRecordingStarted(),await he(this.bridge,"launchApp",1e3,i),await this.waitForShellAppLaunched(i,1e3),!0}async startProfile(){let e=await this.evaluate(`(() => {
452
+ })`),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(Ee(e)){let r=z(e,"appId")||z(e,"id");if(r)return r}return Bt(t)||"connect"}async waitForShellAppLaunched(e,t){let r=Date.now()+t,i=null;for(;Date.now()<r;){try{i=await J(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 waitForShellHome(e){let t=Date.now()+e;for(;Date.now()<t;){let r=await J(this.bridge).catch(()=>null);if(r?.state==="home"&&r.activeApp==null&&r.showSwitcher===!1)return;await f(16)}}async launchShellAppFromHomeIfNeeded(e,t){let r=null;if(t)r=t;else try{r=await J(this.bridge)}catch{return!1}if(r?.state!=="home"||r.activeApp!=null)return!1;let i=this.resolveShellLaunchAppId(e,r);return this.recordingEnabled&&await this.ensureRecordingStarted(),await fe(this.bridge,"launchApp",1e3,i),await this.waitForShellAppLaunched(i,1e3),!0}async startProfile(){let e=await this.evaluate(`(() => {
453
453
  if (!window.__sootsimShellPerf) {
454
454
  return { error: "shell frame profile unavailable (__sootsimShellPerf missing on the page)" }
455
455
  }
@@ -460,7 +460,7 @@ process.stdin.on('end', async () => {
460
460
  return { error: "shell frame profile unavailable (__sootsimShellPerf missing on the page)" }
461
461
  }
462
462
  return await window.__sootsimShellPerf.stop()
463
- })()`);if(this.profilingEnabled=!1,e?.error)throw new Error(e.error);return e}async stopApp(){await this.reloadGuestApp(!1),await this.rearmCaptureAfterRuntimeReload()}async clearState(){await this.reloadGuestApp(!0),await this.rearmCaptureAfterRuntimeReload()}clearKeychain(){console.warn("[flow] clearKeychain: sootsim 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=b.resolve(this.opts.flowDir,t.file),i=S.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?st(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"?at(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),u=1e4,p=this.runStepInner(s);if(l)await p;else{let x=null,w=new Promise((P,_)=>{x=setTimeout(()=>{_(new Error(`step watchdog: ${i} made no progress in ${u}ms \u2014 bridge or bundle probably hung`))},u)});try{await Promise.race([p,w])}finally{x&&clearTimeout(x)}}let m=!!(s.assertVisible||s.assertNotVisible||s.extendedWaitUntil||s.waitFor);this.stepDelay>0&&!m&&await f(this.stepDelay),this.recordFlowTraceStep({stepIndex:t,stepName:i,targetLabel:a,startedAtMs:o,status:"success"})}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)await this.takeScreenshot(e.takeScreenshot);else 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=b.resolve(this.opts.flowDir,r),l=S.readFileSync(s,"utf8"),u=this.opts.flowDir;this.opts.flowDir=b.dirname(s);try{await this.runFlow(Nt(l))}finally{this.opts.flowDir=u}}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"?at(a):a,u=Object.keys(l).find(p=>p!=="when")??Object.keys(l)[0];return{index:s,name:u,target:this.flowStepTargetLabel(l,u)}})),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=Math.max(6e4,i+15e3,o+15e3);this.liveStatus&&(await this.liveStatus.waitWhilePaused(),await this.liveStatus.step(t,"running"));let s=Date.now(),l=async(u,p)=>{if(!this.liveStatus)return;let m=this.flowTraceSteps[this.flowTraceSteps.length-1],x=m&&m.stepIndex===t&&m.startedAtMs>=s;await this.liveStatus.step(t,u?"failure":x&&m.status==="skipped"?"skipped":"success",{durationMs:Date.now()-s,error:u?p instanceof Error?p.message.slice(0,300):String(p).slice(0,300):x&&m.error||void 0})};try{r.runFlow||r.launchApp?await this.runStep(r,t):await Promise.race([this.runStep(r,t),new Promise((u,p)=>setTimeout(()=>p(new Error(`step ${t+1} (${Object.keys(r)[0]}) exceeded ${a}ms deadline`)),a))])}catch(u){throw await l(!0,u),u}await l(!1)}}};var re=class{constructor(e,t){this.bridge=e;this.flowName=t}disabled=!1;paused=!1;runId=`flr_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,8)}`;async push(e){if(!this.disabled)try{let t=await this.bridge.send({type:"flowStatus",status:{runId:this.runId,flowName:this.flowName,...e}});this.paused=t?.control?.paused===!0}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){await this.push({phase:"plan",state:"running",steps:e})}async step(e,t,r){await this.push({phase:"step",state:"running",step:{index:e,status:t,...r}})}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 Rr(){return Ee}var Fe=[];function Mr(){return Fe}async function Wt(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 Le()).find(i=>i.name.toLowerCase()===e.toLowerCase());return r?String(r.preferredPort):e}async function jt(){let n=await Ce(),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 ct(n){Ee=null,Fe=[],(n.length===0||n.includes("--help")||n.includes("-h"))&&(console.log(`
463
+ })()`);if(this.profilingEnabled=!1,e?.error)throw new Error(e.error);return e}async stopApp(){await this.reloadGuestApp(!1),await this.rearmCaptureAfterRuntimeReload()}async clearState(){await this.reloadGuestApp(!0),await this.rearmCaptureAfterRuntimeReload()}clearKeychain(){console.warn("[flow] clearKeychain: sootsim 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=b.resolve(this.opts.flowDir,t.file),i=S.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?at(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"?lt(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),u=1e4,p=this.runStepInner(s),g;if(l){let m=await p;typeof m=="string"&&(g=m)}else{let m=null,P=new Promise((k,ne)=>{m=setTimeout(()=>{ne(new Error(`step watchdog: ${i} made no progress in ${u}ms \u2014 bridge or bundle probably hung`))},u)});try{let k=await Promise.race([p,P]);typeof k=="string"&&(g=k)}finally{m&&clearTimeout(m)}}let T=!!(s.assertVisible||s.assertNotVisible||s.extendedWaitUntil||s.waitFor);this.stepDelay>0&&!T&&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=b.resolve(this.opts.flowDir,r),l=S.readFileSync(s,"utf8"),u=this.opts.flowDir;this.opts.flowDir=b.dirname(s);try{await this.runFlow(Ht(l))}finally{this.opts.flowDir=u}}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"?lt(a):a,u=Object.keys(l).find(p=>p!=="when")??Object.keys(l)[0];return{index:s,name:u,target:this.flowStepTargetLabel(l,u)}})),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=Math.max(6e4,i+15e3,o+15e3);this.liveStatus&&(await this.liveStatus.waitWhilePaused(),await this.liveStatus.step(t,"running"));let s=Date.now(),l=async(u,p)=>{if(!this.liveStatus)return;let g=this.flowTraceSteps[this.flowTraceSteps.length-1],T=g&&g.stepIndex===t&&g.startedAtMs>=s;await this.liveStatus.step(t,u?"failure":T&&g.status==="skipped"?"skipped":"success",{durationMs:Date.now()-s,error:u?p instanceof Error?p.message.slice(0,300):String(p).slice(0,300):T&&g.error||void 0})};try{r.runFlow||r.launchApp?await this.runStep(r,t):await Promise.race([this.runStep(r,t),new Promise((u,p)=>setTimeout(()=>p(new Error(`step ${t+1} (${Object.keys(r)[0]}) exceeded ${a}ms deadline`)),a))])}catch(u){throw await l(!0,u),u}await l(!1)}}};var ie=class{constructor(e,t){this.bridge=e;this.flowName=t}disabled=!1;paused=!1;runId=`flr_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,8)}`;async push(e){if(!this.disabled)try{let t=await this.bridge.send({type:"flowStatus",status:{runId:this.runId,flowName:this.flowName,...e}});this.paused=t?.control?.paused===!0}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){await this.push({phase:"plan",state:"running",steps:e})}async step(e,t,r){await this.push({phase:"step",state:"running",step:{index:e,status:t,...r}})}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 Fe=null;function Or(){return Fe}var Ie=[];function _r(){return Ie}async function jt(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 Ne()).find(i=>i.name.toLowerCase()===e.toLowerCase());return r?String(r.preferredPort):e}async function Vt(){let n=await Ce(),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 dt(n){Fe=null,Ie=[],(n.length===0||n.includes("--help")||n.includes("-h"))&&(console.log(`
464
464
  sootsim maestro \u2014 author and run Maestro YAML flows
465
465
 
466
466
  usage:
@@ -540,28 +540,28 @@ flow extension:
540
540
  takeScreenshot:
541
541
  path: marketing/hero
542
542
  withFrame: true
543
- `),process.exit(0));let e=n[0];k.existsSync(e)||(console.error(` error: ${e} not found`),process.exit(1));let t=h=>n.find((c,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",u=n.includes("--no-shell")?"tenant":n.includes("--shell-only")?"shell":void 0,p=t("--device")?.trim()||"",m=n.includes("--slow")?+(t("--slow")||"500"):0,x=n.includes("--electron"),w=n.includes("--preview"),P=await et(t("--preview-origin")),_=t("--preview-public-origin"),dt=n.includes("--preview-open"),Ie=t("--owner")?.trim()||"",$e=t("--repo")?.trim()||"",H=t("--billing-kind")?.trim()||"",ut=w?`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:${Ut()}`}:flow:${Ht("sha256").update(g.relative(process.cwd(),g.resolve(e))).digest("hex").slice(0,16)}`:"";H&&H!=="test_run"&&(console.error(` error: invalid --billing-kind: ${H}`),process.exit(1));let pt=n.flatMap((h,c)=>n[c-1]==="--replace"?["--replace",h]:[]),ht=n.flatMap((h,c)=>n[c-1]==="--remap"?["--remap",h]:[]),A=n.includes("--record")||w,ft=n.includes("--tail-wait")?Math.max(0,+(t("--tail-wait")||"2000")):A?w?6e3:2e3:0,mt=k.readFileSync(e,"utf8"),{frontmatter:E,steps:R}=me(mt);R.length===0&&(console.error(" error: flow file must contain a YAML array of steps"),process.exit(1));let U=p||E.device||"",K=x||E.electron===!0,gt=E.app===void 0||E.app===null?"":typeof E.app=="number"?String(E.app):E.app,ne=await Wt(gt),ke={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=ue(n,ke),wt=t("--url")||"";K&&!Je()&&(console.error(" error: desktop companion not found. install or build it first with `bun run build:electron`"),process.exit(1));let Pe=K?"desktop companion":"bridge",yt=ne?` | target: ${ne}`:"";console.log(`
544
- sootsim maestro \u2014 ${g.basename(e)}
545
- ${R.length} steps | ${Pe}${yt}${A?" | recording":""}${r?" | profiling":""}${m?` | ${m}ms delay`:""}
546
- `),w&&Oe({event:"preview_flow_started",properties:{flowName:g.basename(e),stepCount:R.length,mode:Pe,electron:K,record:A,profile:r,previewOrigin:P}});let I=wt||ne||"",oe=o||K&&v.simIdSource!=="flag",Ae=t("--driver")||"",se=!1,ae=new Set,Re=!1;if(!I&&!oe&&v.simIdSource==="none"){let h=je(v);try{let c=await h.listSims(),y=c.find(L=>L.isPrimary&&L.readyState==="open"),$=c.find(L=>L.readyState==="open"),V=y??$;V&&(Re=!0,console.log(` reusing active sim: ${V.id}`))}catch{}finally{h.close()}}if(!I&&!Re&&(oe||v.simIdSource==="none")){let h=await jt();h||(console.error(" error: no current sim and no sootsim target found"),await ce(),process.exit(1)),I=h}if(I&&U){let h=new URL(await Ge(I));h.searchParams.set("device",U),I=h.toString()}if(I){let h=[I];if(h.push(...pt),h.push(...ht),oe&&h.push("--new"),h.push("--no-describe"),v.simIdSource==="flag"&&v.simId&&h.push("--sim",v.simId),Ae&&(h.push("--driver",Ae),se=!0),n.includes("--headless")&&!i&&h.push("--headless"),await Ke(h,{port:v.wsPort,timeoutMs:v.commandTimeoutMs}),se){let c=de();c&&ae.add(c)}}let D=ue(n,ke),q=D.simIdSource==="flag"?D.simId:de()||D.simId,bt=D.simIdSource==="flag"?"flag":q?"saved":"none",F=pe(D.wsPort,{commandTimeoutMs:D.commandTimeoutMs,simId:q,simIdSource:bt}),d,Me=async()=>{if(!U)return!1;let h=await F.send({type:"evaluate",simId:d.simId,code:"window.location.href"});if(typeof h=="string"&&h.length>0){let c=new URL(h);c.searchParams.set("device",U),d.setSimRouteHint(c.toString())}return!!await F.send({type:"call",simId:d.simId,path:"SootSim.bridges.settings.set",args:["deviceModel",U]})};if(d=new te(F,{screenshotDir:s,flowDir:g.dirname(g.resolve(e)),screenshotPathMode:l,screenshotLayers:u,simId:q,recordingOutputDir:A?a:void 0,recordingFormat:w?"mp4":"webm",billingOriginOverride:w?P:void 0,allowGitHubRecording:w,requireRecordingEntitlement:w,onAfterLaunch:async()=>{await Me()&&await d.waitForTree(12e4),w&&await F.send({type:"evaluate",simId:d.simId,code:`(() => {
543
+ `),process.exit(0));let e=n[0];$.existsSync(e)||(console.error(` error: ${e} not found`),process.exit(1));let t=h=>n.find((c,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",u=n.includes("--no-shell")?"tenant":n.includes("--shell-only")?"shell":void 0,p=t("--device")?.trim()||"",g=n.includes("--slow")?+(t("--slow")||"500"):0,T=n.includes("--electron"),m=n.includes("--preview"),P=await tt(t("--preview-origin")),k=t("--preview-public-origin"),ne=n.includes("--preview-open"),$e=t("--owner")?.trim()||"",Pe=t("--repo")?.trim()||"",H=t("--billing-kind")?.trim()||"",ut=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:${Wt()}`}:flow:${Ut("sha256").update(w.relative(process.cwd(),w.resolve(e))).digest("hex").slice(0,16)}`:"";H&&H!=="test_run"&&(console.error(` error: invalid --billing-kind: ${H}`),process.exit(1));let pt=n.flatMap((h,c)=>n[c-1]==="--replace"?["--replace",h]:[]),ht=n.flatMap((h,c)=>n[c-1]==="--remap"?["--remap",h]:[]),M=n.includes("--record")||m,ft=n.includes("--tail-wait")?Math.max(0,+(t("--tail-wait")||"2000")):M?m?6e3:2e3:0,mt=$.readFileSync(e,"utf8"),{frontmatter:E,steps:R}=ge(mt);R.length===0&&(console.error(" error: flow file must contain a YAML array of steps"),process.exit(1));let U=p||E.device||"",q=T||E.electron===!0,gt=E.app===void 0||E.app===null?"":typeof E.app=="number"?String(E.app):E.app,oe=await jt(gt),ke={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,ke),wt=t("--url")||"";q&&!Ge()&&(console.error(" error: desktop companion not found. install or build it first with `bun run build:electron`"),process.exit(1));let Ae=q?"desktop companion":"bridge",yt=oe?` | target: ${oe}`:"";console.log(`
544
+ sootsim maestro \u2014 ${w.basename(e)}
545
+ ${R.length} steps | ${Ae}${yt}${M?" | recording":""}${r?" | profiling":""}${g?` | ${g}ms delay`:""}
546
+ `),m&&_e({event:"preview_flow_started",properties:{flowName:w.basename(e),stepCount:R.length,mode:Ae,electron:q,record:M,profile:r,previewOrigin:P}});let A=wt||oe||"",se=o||q&&v.simIdSource!=="flag",Me=t("--driver")||"",ae=!1,le=new Set,Re=!1;if(!A&&!se&&v.simIdSource==="none"){let h=Ve(v);try{let c=await h.listSims(),y=c.find(D=>D.isPrimary&&D.readyState==="open"),I=c.find(D=>D.readyState==="open"),V=y??I;V&&(Re=!0,console.log(` reusing active sim: ${V.id}`))}catch{}finally{h.close()}}if(!A&&!Re&&(se||v.simIdSource==="none")){let h=await Vt();h||(console.error(" error: no current sim and no sootsim target found"),await de(),process.exit(1)),A=h}if(A&&U){let h=new URL(await ze(A));h.searchParams.set("device",U),A=h.toString()}if(A){let h=[A];if(h.push(...pt),h.push(...ht),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 qe(h,{port:v.wsPort,timeoutMs:v.commandTimeoutMs}),ae){let c=ue();c&&le.add(c)}}let B=pe(n,ke),Y=B.simIdSource==="flag"?B.simId:ue()||B.simId,bt=B.simIdSource==="flag"?"flag":Y?"saved":"none",F=he(B.wsPort,{commandTimeoutMs:B.commandTimeoutMs,simId:Y,simIdSource:bt}),d,Oe=async()=>{if(!U)return!1;let h=await F.send({type:"evaluate",simId:d.simId,code:"window.location.href"});if(typeof h=="string"&&h.length>0){let c=new URL(h);c.searchParams.set("device",U),d.setSimRouteHint(c.toString())}return!!await F.send({type:"call",simId:d.simId,path:"SootSim.bridges.settings.set",args:["deviceModel",U]})};if(d=new re(F,{screenshotDir:s,flowDir:w.dirname(w.resolve(e)),screenshotPathMode:l,screenshotLayers:u,simId:Y,recordingOutputDir:M?a:void 0,recordingFormat:m?"mp4":"webm",billingOriginOverride:m?P:void 0,allowGitHubRecording:m,requireRecordingEntitlement:m,onAfterLaunch:async()=>{await Oe()&&await d.waitForTree(12e4),m&&await F.send({type:"evaluate",simId:d.simId,code:`(() => {
547
547
  const r = window.SootSim?.bridges?.eventRecorder ?? window.__sootsimEventRecorder
548
548
  return r?.start?.() ?? false
549
- })()`})}}),m&&(d.stepDelay=m),d.liveStatus=new re(F,g.basename(e)),d.js.putEnv("MAESTRO_FILENAME",g.basename(e,g.extname(e))),E.env&&typeof E.env=="object")for(let[h,c]of Object.entries(E.env))d.js.putEnv(h,c);let M=null,T=null,B=null,O=null,W=null,le=null,j=0,Y=!!R[0]?.launchApp;try{Y||await d.waitForTree(12e4),await Me()&&!Y&&await d.waitForTree(12e4),w&&!Y&&!process.env.SOOTSIM_PREVIEW_RESET_DONE&&await d.launchApp({clearState:!0}),A&&(Y?d.prepareRecording():await d.startRecording()),r&&await d.startProfile(),w&&(await F.send({type:"evaluate",simId:d.simId,code:`(() => {
549
+ })()`})}}),g&&(d.stepDelay=g),d.liveStatus=new ie(F,w.basename(e)),d.js.putEnv("MAESTRO_FILENAME",w.basename(e,w.extname(e))),E.env&&typeof E.env=="object")for(let[h,c]of Object.entries(E.env))d.js.putEnv(h,c);let O=null,x=null,L=null,_=null,W=null,ce=null,j=0,Z=!!R[0]?.launchApp;try{Z||await d.waitForTree(12e4),await Oe()&&!Z&&await d.waitForTree(12e4),m&&!Z&&!process.env.SOOTSIM_PREVIEW_RESET_DONE&&await d.launchApp({clearState:!0}),M&&(Z?d.prepareRecording():await d.startRecording()),r&&await d.startProfile(),m&&(await F.send({type:"evaluate",simId:d.simId,code:`(() => {
550
550
  const r = window.SootSim?.bridges?.eventRecorder ?? window.__sootsimEventRecorder
551
551
  return r?.start?.() ?? false
552
- })()`})||console.warn(" warn: eventRecorder.start() returned false \u2014 preview will upload bundle without replay events")),await d.runFlow(R),r&&(M=await d.stopProfile()),await d.waitForRecordingTail({maxMs:ft,smart:w}),A&&(T=await d.stopRecording(),B=d.getLastRecordingDurationMs()),w&&(O=await F.send({type:"evaluate",simId:d.simId,code:`(() => {
552
+ })()`})||console.warn(" warn: eventRecorder.start() returned false \u2014 preview will upload bundle without replay events")),await d.runFlow(R),r&&(O=await d.stopProfile()),await d.waitForRecordingTail({maxMs:ft,smart:m}),M&&(x=await d.stopRecording(),L=d.getLastRecordingDurationMs()),m&&(_=await F.send({type:"evaluate",simId:d.simId,code:`(() => {
553
553
  const r = window.SootSim?.bridges?.eventRecorder ?? window.__sootsimEventRecorder
554
554
  return r?.stop?.() ?? []
555
- })()`}),console.log(` captured ${O.length} replay events`),W=g.join(s,"preview-final.png"),await d.captureScreenshot(W),console.log(` final screenshot: ${W}`));let c=R.filter(y=>y&&typeof y=="object"&&"takeScreenshot"in y).length;console.log(`
556
- + completed (${R.length} steps)`),c>0&&console.log(` screenshots: ${c} \u2192 ${s}`),M&&lt(M),T&&console.log(` video: ${T}`),console.log()}catch(h){if(r&&!M)try{M=await d.stopProfile()}catch{}if(A&&!T)try{T=await d.stopRecording(),B=d.getLastRecordingDurationMs()}catch(c){console.warn(` recording stop failed: ${c?.message||String(c)}`)}if(w&&!O)try{O=await F.send({type:"evaluate",simId:d.simId,code:`(() => {
555
+ })()`}),console.log(` captured ${_.length} replay events`),W=w.join(s,"preview-final.png"),await d.captureScreenshot(W),console.log(` final screenshot: ${W}`));let c=R.filter(y=>y&&typeof y=="object"&&"takeScreenshot"in y).length;console.log(`
556
+ + completed (${R.length} steps)`),c>0&&console.log(` screenshots: ${c} \u2192 ${s}`),O&&ct(O),x&&console.log(` video: ${x}`),console.log()}catch(h){if(r&&!O)try{O=await d.stopProfile()}catch{}if(M&&!x)try{x=await d.stopRecording(),L=d.getLastRecordingDurationMs()}catch(c){console.warn(` recording stop failed: ${c?.message||String(c)}`)}if(m&&!_)try{_=await F.send({type:"evaluate",simId:d.simId,code:`(() => {
557
557
  const r = window.SootSim?.bridges?.eventRecorder ?? window.__sootsimEventRecorder
558
558
  return r?.stop?.() ?? []
559
- })()`}),console.log(` captured ${O.length} partial replay events`)}catch(c){console.warn(` event recorder stop failed: ${c?.message||String(c)}`)}console.error(`
559
+ })()`}),console.log(` captured ${_.length} partial replay events`)}catch(c){console.warn(` event recorder stop failed: ${c?.message||String(c)}`)}console.error(`
560
560
  x failed: ${h.message}
561
- `),M&&(console.log(" partial profile:"),lt(M)),T&&console.log(` partial video: ${T}`);try{let c=d.lastFailedStep,y=c?`step-${String(c.index+1).padStart(2,"0")}-${c.kind}`:"unstaged",$=g.join(s,y);await d.captureFailureBundle($,{error:h,stepIndex:c?.index,stepKind:c?.kind,stepTarget:c?.target}),le=$,console.log(` failure bundle: ${$}`),console.log(" (contents: screenshot.png, describe.json, a11y.txt, tree.txt, console.json, error.json)")}catch(c){try{let y=g.join(s,"error.png");await d.captureScreenshot(y),console.log(` error screenshot: ${y}`)}catch{}console.log(` (failure bundle capture failed: ${c instanceof Error?c.message:String(c)})`)}await Ve(F,{errorsCommand:`sootsim get errors 5${d.simId?` --sim ${d.simId}`:""}`,warningsCommand:`sootsim get warnings 5${d.simId?` --sim ${d.simId}`:""}`,requestsCommand:`sootsim get requests 5${d.simId?` --sim ${d.simId}`:""}`}),j=1}if(await d.liveStatus?.end(j===0?"passed":"failed"),w&&(j===0||T||O))try{let h=await Jt(O??[]),c=["--origin",P,"--events",h];_&&c.push("--public-origin",_),T&&c.push("--video",T),W&&c.push("--screenshot",W),T&&B&&Number.isFinite(B)&&(c.push("--video-duration-ms",String(Math.round(B))),c.push("--recorded-duration-ms",String(Math.round(B))));let y=d.getLastRecordingStartedAtMs();y&&Number.isFinite(y)&&c.push("--recording-started-at-ms",String(Math.round(y))),v.wsPort&&c.push("--port",String(v.wsPort)),d.simId&&c.push("--sim",d.simId),dt&&c.push("--open"),Ie&&c.push("--owner",Ie),$e&&c.push("--repo",$e),c.push("--run-scope",ut),H&&c.push("--billing-kind",H),console.log(`
562
- preparing preview upload\u2026`);let $=d.getFlowTraceSteps();$.length>0&&c.push("--timeline-events",await Gt($)),le&&c.push("--failure-bundle",le);let V=d.getLastRecordingFrameStats();V&&c.push("--trace-frame-stats",await zt(V));let{runUpload:L}=await import("./upload-UQRYTSL2.js");Ee=await L(c,{})}catch(h){console.error(` preview upload failed: ${h?.message||h}`),j=1}return Fe=d.getFlowTraceSteps(),F.close(),se?(d.simId&&ae.add(d.simId),await Vt(v.wsPort,v.commandTimeoutMs,[...ae])):d.simId&&d.simId!==q&&Be(d.simId),await ce(),j}async function Vt(n,e,t){let r=[...new Set(t.filter(Boolean))];if(r.length===0)return;let i=pe(n,{commandTimeoutMs:e});try{let o=await i.listSims(),a=r.filter(l=>o.some(u=>u.id===l&&u.readyState==="open"));if(a.length===0)return;let s=await qe(i,n,e,a);await ze(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 Jt(n){let{gzipSync:e}=await import("zlib"),t=n.map(o=>JSON.stringify(o)).join(`
561
+ `),O&&(console.log(" partial profile:"),ct(O)),x&&console.log(` partial video: ${x}`);try{let c=d.lastFailedStep,y=c?`step-${String(c.index+1).padStart(2,"0")}-${c.kind}`:"unstaged",I=w.join(s,y);await d.captureFailureBundle(I,{error:h,stepIndex:c?.index,stepKind:c?.kind,stepTarget:c?.target}),ce=I,console.log(` failure bundle: ${I}`),console.log(" (contents: screenshot.png, describe.json, a11y.txt, tree.txt, console.json, error.json)")}catch(c){try{let y=w.join(s,"error.png");await d.captureScreenshot(y),console.log(` error screenshot: ${y}`)}catch{}console.log(` (failure bundle capture failed: ${c instanceof Error?c.message:String(c)})`)}await Je(F,{errorsCommand:`sootsim get errors 5${d.simId?` --sim ${d.simId}`:""}`,warningsCommand:`sootsim get warnings 5${d.simId?` --sim ${d.simId}`:""}`,requestsCommand:`sootsim get requests 5${d.simId?` --sim ${d.simId}`:""}`}),j=1}if(await d.liveStatus?.end(j===0?"passed":"failed"),m&&(j===0||x||_))try{let h=await Gt(_??[]),c=["--origin",P,"--events",h];k&&c.push("--public-origin",k),x&&c.push("--video",x),W&&c.push("--screenshot",W),x&&L&&Number.isFinite(L)&&(c.push("--video-duration-ms",String(Math.round(L))),c.push("--recorded-duration-ms",String(Math.round(L))));let y=d.getLastRecordingStartedAtMs();y&&Number.isFinite(y)&&c.push("--recording-started-at-ms",String(Math.round(y))),v.wsPort&&c.push("--port",String(v.wsPort)),d.simId&&c.push("--sim",d.simId),ne&&c.push("--open"),$e&&c.push("--owner",$e),Pe&&c.push("--repo",Pe),c.push("--run-scope",ut),H&&c.push("--billing-kind",H),console.log(`
562
+ preparing preview upload\u2026`);let I=d.getFlowTraceSteps();I.length>0&&c.push("--timeline-events",await zt(I));let V=await Kt(I,y);V&&c.push("--snapshot-manifest",V),ce&&c.push("--failure-bundle",ce);let D=d.getLastRecordingFrameStats();D&&c.push("--trace-frame-stats",await qt(D));let{runUpload:St}=await import("./upload-YQVEPIO7.js");Fe=await St(c,{})}catch(h){console.error(` preview upload failed: ${h?.message||h}`),j=1}return Ie=d.getFlowTraceSteps(),F.close(),ae?(d.simId&&le.add(d.simId),await Jt(v.wsPort,v.commandTimeoutMs,[...le])):d.simId&&d.simId!==Y&&Le(d.simId),await de(),j}async function Jt(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(u=>u.id===l&&u.readyState==="open"));if(a.length===0)return;let s=await Ye(i,n,e,a);await Ke(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 Gt(n){let{gzipSync:e}=await import("zlib"),t=n.map(o=>JSON.stringify(o)).join(`
563
563
  `)+(n.length?`
564
- `:""),r=e(Buffer.from(t,"utf8")),i=g.join(ie(),`sootsim-events-${Date.now()}.jsonl.gz`);return k.writeFileSync(i,r),console.log(` events: ${n.length} written to ${i} (${r.length} bytes gz)`),i}async function Gt(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(`
564
+ `:""),r=e(Buffer.from(t,"utf8")),i=w.join(K(),`sootsim-events-${Date.now()}.jsonl.gz`);return $.writeFileSync(i,r),console.log(` events: ${n.length} written to ${i} (${r.length} bytes gz)`),i}async function zt(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(`
565
565
  `)+`
566
- `,i=e(Buffer.from(r,"utf8")),o=g.join(ie(),`sootsim-flow-steps-${Date.now()}.jsonl.gz`);return k.writeFileSync(o,i),console.log(` flow trace: ${t.length} step events written to ${o} (${i.length} bytes gz)`),o}async function zt(n){let e=g.join(ie(),`sootsim-frame-stats-${Date.now()}.json`);return k.writeFileSync(e,JSON.stringify(n)),console.log(` frame stats: written to ${e}`),e}async function Kt(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?Yt():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=Zt(n,s.outputPath),u=await ct(l);if(u!==0){console.error(`
567
- validation failed \u2014 draft preserved so you can keep iterating`),process.exitCode=u;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 qt(n){return n[0]==="--sim"&&n.length>=2?[...n.slice(2),"--sim",n[1]]:n}async function Or(n){let e=qt(n),t=e[0];if(t==="start"||t==="keep"||t==="good"||t==="end"||t==="validate")return await Kt(e),0;let r=await ct(e);return r!==0&&(process.exitCode=r),r}function lt(n){console.log(""),Qe(n)}function Yt(){return g.join(ie(),`sootsim-flow-draft-${Date.now()}.yaml`)}function Zt(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{nt as a,$t as b,Rr as c,Mr as d,jt as e,ct as f,qt as g,Or as h};
566
+ `,i=e(Buffer.from(r,"utf8")),o=w.join(K(),`sootsim-flow-steps-${Date.now()}.jsonl.gz`);return $.writeFileSync(o,i),console.log(` flow trace: ${t.length} step events written to ${o} (${i.length} bytes gz)`),o}async function Kt(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(K(),`sootsim-flow-snapshots-${Date.now()}.json`);return $.writeFileSync(r,JSON.stringify(t)),console.log(` flow snapshots: ${t.length} written to ${r}`),r}async function qt(n){let e=w.join(K(),`sootsim-frame-stats-${Date.now()}.json`);return $.writeFileSync(e,JSON.stringify(n)),console.log(` frame stats: written to ${e}`),e}async function Yt(n){let e=n[0],t=r=>n.find((i,o)=>n[o-1]===r);switch(e){case"start":{let{path:r,state:i}=Xe();console.log(" flow draft started"),console.log(` session: ${r}`),console.log(` steps: ${i.steps.length}`);return}case"keep":case"good":{let r=be();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=be();a.active&&a.kept&&console.log(` auto-kept trailing action: ${a.candidate.summary}`);let s=Qe(r||(i?Xt():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=Qt(n,s.outputPath),u=await dt(l);if(u!==0){console.error(`
567
+ validation failed \u2014 draft preserved so you can keep iterating`),process.exitCode=u;return}ye(),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(ye(),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=we(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 Zt(n){return n[0]==="--sim"&&n.length>=2?[...n.slice(2),"--sim",n[1]]:n}async function Dr(n){let e=Zt(n),t=e[0];if(t==="start"||t==="keep"||t==="good"||t==="end"||t==="validate")return await Yt(e),0;let r=await dt(e);return r!==0&&(process.exitCode=r),r}function ct(n){console.log(""),et(n)}function Xt(){return w.join(K(),`sootsim-flow-draft-${Date.now()}.yaml`)}function Qt(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{ot as a,Pt as b,Or as c,_r as d,Vt as e,dt as f,Zt as g,Dr as h};
@@ -1,2 +1,2 @@
1
- /*! sootsim v0.1.214 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
1
+ /*! sootsim v0.1.216 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
2
  import{createHash as b}from"node:crypto";import g from"node:fs";import{createRequire as S}from"node:module";import u from"node:path";var y=/\.(ttf|otf|woff|woff2)$/i;function P(t,n,r){if(!t||typeof t!="object")return;let o=t.fonts;if(Array.isArray(o))for(let i of o)typeof i=="string"&&r.push(i);let e=t[n];if(!e||typeof e!="object")return;let s=e.fonts;if(Array.isArray(s))for(let i of s){if(typeof i=="string"){r.push(i);continue}if(!i||typeof i!="object")continue;let c=i.fontDefinitions;if(Array.isArray(c))for(let a of c){if(!a||typeof a!="object")continue;let p=a.path;typeof p=="string"&&r.push(p)}}}function m(t,n){if(!Array.isArray(t))return[];let r=[];for(let o of t){let e=Array.isArray(o)?o[0]:o;if(typeof e!="string"||!/(^|\/)expo-font$/.test(e))continue;let s=Array.isArray(o)?o[1]??{}:{};P(s,n,r)}return r}function C(t){return t.slice(t.lastIndexOf("/")+1).replace(y,"")}function h(t,n){let r=n.replace(/\/+$/,""),o=new Set,e=[];for(let s of t){let i=s.replace(/^\.\//,"").replace(/^\/+/,"");!i||o.has(i)||(o.add(i),y.test(i)&&e.push({family:C(i),url:`${r}/assets/${i}`}))}return e}var d=S(import.meta.url);function x(t){try{let n=new URL(t),r=n.hostname.replace(/^\[|\]$/g,"").toLowerCase();if(r==="localhost"||r.endsWith(".localhost")||r==="0.0.0.0"||r==="::1"||/^127(?:\.\d{1,3}){3}$/.test(r))return n.origin}catch{}return null}var R=["app.config.js","app.config.ts","app.config.cjs","app.config.mjs","app.json"];function w(t){for(let n of R)try{if(g.statSync(u.join(t,n)).isFile())return!0}catch{}return!1}var j=new Set(["node_modules","artifacts","dist","build","out","coverage","tmp","public","ios","android","macos","windows","__fixtures__","__tests__","examples","example"]);function F(t,n){w(t)&&n.push(t);let r;try{r=g.readdirSync(t,{withFileTypes:!0})}catch{return}for(let o of r)o.isDirectory()&&(o.name.startsWith(".")||j.has(o.name)||F(u.join(t,o.name),n))}function _(t){try{return g.statSync(u.join(t,"package.json")).isFile()}catch{return!1}}function I(t){let n=x(t.bundleUrl);if(!n)return[];let r=t.repoDir||process.env.SOOT_REPO_DIR,o=r?u.resolve(r):process.cwd();if(!r&&!_(o))return[];let e=[];if(r)F(o,e),e.includes(o)||e.push(o);else{if(!w(o))return[];e.push(o)}if(e.length===0)return[];let s=(t.platform||process.env.SOOT_PLATFORM||"ios").toLowerCase(),i=null;try{let l=d.resolve("@expo/config",{paths:[...e,o]}),f=d(l);typeof f.getConfig=="function"&&(i=f.getConfig)}catch{}if(!i)return[];let c;for(let l of e)try{let f=i(l,{skipSDKVersionRequirement:!0});if(f?.exp&&typeof f.exp=="object"){let A=f.exp.plugins;if(Array.isArray(A)){c=f.exp;break}}}catch{}if(!c||typeof c!="object")return[];let a=c.plugins;if(!Array.isArray(a))return[];let p=m(a,s==="android"?"android":"ios");return h(p,n)}async function L(t,n){let r=x(t);if(!r)return null;let o=new AbortController,e=setTimeout(()=>o.abort(),n?.timeoutMs??1500);try{let s=await fetch(`${r}/`,{headers:{"expo-platform":"ios",Accept:"application/json"},signal:o.signal});if(!s.ok)return null;let c=(await s.json())?.extra?.expoClient?._internal?.projectRoot;return typeof c=="string"&&c.length>0?c:null}catch{return null}finally{clearTimeout(e)}}function M(t){return t.map(n=>`${encodeURIComponent(n.url)}::${encodeURIComponent(n.family)}`).join(",")}function k(t){let n=[];for(let r of t.split(",")){let o=r.trim();if(!o)continue;let e=o.indexOf("::"),s=e===-1?o:o.slice(0,e);try{n.push(decodeURIComponent(s))}catch{n.push(s)}}return n.filter(Boolean)}function D(t){let n=(t.split("?")[0].split(".").pop()||"").toLowerCase();return n==="ttf"?"font/ttf":n==="otf"?"font/otf":n==="woff"?"font/woff":n==="woff2"?"font/woff2":"application/octet-stream"}async function G(t,n){let r=[],o=new Set;for(let e of k(t)){let s=b("sha256").update(e).digest("hex");if(!o.has(s)){o.add(s);try{let i=await fetch(e);if(!i.ok){n?.onError?.(e,new Error(`${i.status} ${i.statusText}`));continue}let c=new Uint8Array(await i.arrayBuffer());r.push({url:e,urlhash:s,contentType:D(e),bytes:c}),n?.onStaged?.({url:e,byteLength:c.byteLength})}catch(i){n?.onError?.(e,i)}}}return r}export{I as a,L as b,M as c,G as d};
@@ -1,2 +1,2 @@
1
- /*! sootsim v0.1.214 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
- import{a as d,b as p}from"./chunk-2344ZBLD.js";import{execSync as c}from"child_process";function s(e){try{return c(e,{stdio:["ignore","pipe","ignore"],timeout:3e3,encoding:"utf8"}).trim()||null}catch{return null}}function o(e){let n=e?.trim();return!n||!/^\d+$/.test(n)?null:Number(n)}function m(){let e=s("git remote get-url origin");if(!e)return null;let n=e.match(/github\.com[/:]([^/\s]+)\/([^/\s]+?)(?:\.git)?\/?$/i);return n?{owner:n[1],repo:n[2]}:null}function f(){let e=process.env.GITHUB_ACTIONS==="true",n=(process.env.SOOT_REPO||process.env.GITHUB_REPOSITORY||"").trim(),[r,i]=n.includes("/")?n.split("/",2):[null,null];if(e){let u=process.env.GITHUB_REF?.match(/^refs\/pull\/(\d+)\//)?.[1];return{owner:r,repo:i,branch:process.env.GITHUB_HEAD_REF?.trim()||process.env.GITHUB_REF_NAME?.trim()||null,commitSha:process.env.GITHUB_SHA?.trim()||null,githubUsername:process.env.GITHUB_ACTOR?.trim()||null,pullRequestNumber:o(process.env.SOOT_PR_NUMBER)??o(u),githubRunId:process.env.GITHUB_RUN_ID?.trim()||null,source:"ci"}}let l=s("git rev-parse --abbrev-ref HEAD"),t=r?null:m();return{owner:r??t?.owner??null,repo:i??t?.repo??null,branch:l==="HEAD"?null:l,commitSha:s("git rev-parse HEAD"),githubUsername:null,pullRequestNumber:o(process.env.SOOT_PR_NUMBER),githubRunId:null,source:"cli"}}function R(e){if(e.length===0)return{stepCount:null,failedStepIndex:null};let n=e.find(r=>r.status==="failure");return{stepCount:e.length,failedStepIndex:n?n.stepIndex:null}}function b(e){return e.auth?e.uploadedShare?!0:e.auth.kind==="github"||process.env.GITHUB_ACTIONS==="true":!1}async function S(e){let n=e.auth??d();if(!n)return null;let r=f(),i=e.owner??(n.kind==="github"?n.owner:null)??r.owner,l=e.repo??(n.kind==="github"?n.repo:null)??r.repo;try{let t=await fetch(`${e.origin.replace(/\/$/,"")}/api/sootsim/test-runs`,{method:"POST",headers:{"content-type":"application/json",authorization:p(n)},body:JSON.stringify({kind:e.kind,source:r.source,name:e.name??void 0,prompt:e.prompt??void 0,summary:e.summary??void 0,status:e.status,failureMessage:e.failureMessage??void 0,previewShareId:e.previewShareId??void 0,owner:i??void 0,repo:l??void 0,branch:r.branch??void 0,commitSha:r.commitSha??void 0,githubUsername:r.githubUsername??void 0,pullRequestNumber:r.pullRequestNumber??void 0,githubRunId:r.githubRunId??void 0,stepCount:e.stepCount??void 0,failedStepIndex:e.failedStepIndex??void 0,durationMs:e.durationMs??void 0,flowYamlSizeBytes:e.flowYamlSizeBytes??void 0})});if(!t.ok){let a=await t.text().catch(()=>"");return console.warn(` warn: run registration failed: /api/sootsim/test-runs ${t.status}${a?`: ${a.slice(0,200)}`:""}`),null}let u=await t.json();return u.run?.id?{id:u.run.id,previewUrl:u.run.previewUrl??null,traceUrl:u.run.traceUrl??null}:(console.warn(" warn: run registration returned no id"),null)}catch(t){return console.warn(` warn: run registration failed: ${t instanceof Error?t.message:String(t)}`),null}}export{R as a,b,S as c};
1
+ /*! sootsim v0.1.216 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
+ import{a as d,b as p}from"./chunk-J4GDWHXE.js";import{execSync as c}from"child_process";function s(e){try{return c(e,{stdio:["ignore","pipe","ignore"],timeout:3e3,encoding:"utf8"}).trim()||null}catch{return null}}function o(e){let n=e?.trim();return!n||!/^\d+$/.test(n)?null:Number(n)}function m(){let e=s("git remote get-url origin");if(!e)return null;let n=e.match(/github\.com[/:]([^/\s]+)\/([^/\s]+?)(?:\.git)?\/?$/i);return n?{owner:n[1],repo:n[2]}:null}function f(){let e=process.env.GITHUB_ACTIONS==="true",n=(process.env.SOOT_REPO||process.env.GITHUB_REPOSITORY||"").trim(),[r,i]=n.includes("/")?n.split("/",2):[null,null];if(e){let u=process.env.GITHUB_REF?.match(/^refs\/pull\/(\d+)\//)?.[1];return{owner:r,repo:i,branch:process.env.GITHUB_HEAD_REF?.trim()||process.env.GITHUB_REF_NAME?.trim()||null,commitSha:process.env.GITHUB_SHA?.trim()||null,githubUsername:process.env.GITHUB_ACTOR?.trim()||null,pullRequestNumber:o(process.env.SOOT_PR_NUMBER)??o(u),githubRunId:process.env.GITHUB_RUN_ID?.trim()||null,source:"ci"}}let l=s("git rev-parse --abbrev-ref HEAD"),t=r?null:m();return{owner:r??t?.owner??null,repo:i??t?.repo??null,branch:l==="HEAD"?null:l,commitSha:s("git rev-parse HEAD"),githubUsername:null,pullRequestNumber:o(process.env.SOOT_PR_NUMBER),githubRunId:null,source:"cli"}}function R(e){if(e.length===0)return{stepCount:null,failedStepIndex:null};let n=e.find(r=>r.status==="failure");return{stepCount:e.length,failedStepIndex:n?n.stepIndex:null}}function b(e){return e.auth?e.uploadedShare?!0:e.auth.kind==="github"||process.env.GITHUB_ACTIONS==="true":!1}async function S(e){let n=e.auth??d();if(!n)return null;let r=f(),i=e.owner??(n.kind==="github"?n.owner:null)??r.owner,l=e.repo??(n.kind==="github"?n.repo:null)??r.repo;try{let t=await fetch(`${e.origin.replace(/\/$/,"")}/api/sootsim/test-runs`,{method:"POST",headers:{"content-type":"application/json",authorization:p(n)},body:JSON.stringify({kind:e.kind,source:r.source,name:e.name??void 0,prompt:e.prompt??void 0,summary:e.summary??void 0,status:e.status,failureMessage:e.failureMessage??void 0,previewShareId:e.previewShareId??void 0,owner:i??void 0,repo:l??void 0,branch:r.branch??void 0,commitSha:r.commitSha??void 0,githubUsername:r.githubUsername??void 0,pullRequestNumber:r.pullRequestNumber??void 0,githubRunId:r.githubRunId??void 0,stepCount:e.stepCount??void 0,failedStepIndex:e.failedStepIndex??void 0,durationMs:e.durationMs??void 0,flowYamlSizeBytes:e.flowYamlSizeBytes??void 0})});if(!t.ok){let a=await t.text().catch(()=>"");return console.warn(` warn: run registration failed: /api/sootsim/test-runs ${t.status}${a?`: ${a.slice(0,200)}`:""}`),null}let u=await t.json();return u.run?.id?{id:u.run.id,previewUrl:u.run.previewUrl??null,traceUrl:u.run.traceUrl??null}:(console.warn(" warn: run registration returned no id"),null)}catch(t){return console.warn(` warn: run registration failed: ${t instanceof Error?t.message:String(t)}`),null}}export{R as a,b,S as c};
@@ -1,2 +1,2 @@
1
- /*! sootsim v0.1.214 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
1
+ /*! sootsim v0.1.216 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
2
  var t=4001,r="sootsim close";var o="http://localhost:5173/";export{t as a,r as b,o as c};
@@ -1,4 +1,4 @@
1
- /*! sootsim v0.1.214 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
1
+ /*! sootsim v0.1.216 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
2
  import{existsSync as A,mkdirSync as v,readFileSync as M,rmSync as f,writeFileSync as h}from"fs";import{tmpdir as w}from"os";import{dirname as B,join as U,resolve as V}from"path";import{execFileSync as b}from"child_process";import{readFileSync as _}from"fs";import{createRequire as y}from"module";var c=null,p=null;function m(r){c||(c=O());try{return c(r)}catch{return null}}function C(r){p||(p=T());try{return p(r)}catch{return null}}function T(){if(process.platform==="linux")return r=>{try{return _(`/proc/${r}/comm`,"utf8").trim()||null}catch{return null}};if(process.platform==="darwin"){let r=x();return r||F()}return()=>null}function O(){let r=Number(process.env.PPID);if(Number.isFinite(r)&&r>1&&r!==process.ppid)return()=>r;if(process.platform==="linux")return D();if(process.platform==="darwin"){let n=R();return n||k()}return()=>null}function D(){return r=>{try{let n=_(`/proc/${r}/stat`,"utf8"),t=n.lastIndexOf(")");if(t<0)return null;let e=n.slice(t+1).trim().split(/\s+/),i=Number(e[1]);return Number.isFinite(i)&&i>0?i:null}catch{return null}}}var E=3,l=216,P=16,S=48,L=16;function R(){if(!process.versions?.bun)return null;try{let r=y(import.meta.url),{dlopen:n,FFIType:t}=r("bun:ffi"),e=n("/usr/lib/libproc.dylib",{proc_pidinfo:{args:[t.i32,t.i32,t.u64,t.ptr,t.i32],returns:t.i32}}),i=Buffer.alloc(l);return o=>{if(Number(e.symbols.proc_pidinfo(o,E,0n,i,l))<=0)return null;let u=i.readUInt32LE(P);return u>0?u:null}}catch{return null}}function x(){if(!process.versions?.bun)return null;try{let r=y(import.meta.url),{dlopen:n,FFIType:t}=r("bun:ffi"),e=n("/usr/lib/libproc.dylib",{proc_pidinfo:{args:[t.i32,t.i32,t.u64,t.ptr,t.i32],returns:t.i32}}),i=Buffer.alloc(l);return o=>{if(Number(e.symbols.proc_pidinfo(o,E,0n,i,l))<=0)return null;let u=i.subarray(S,S+L),I=u.indexOf(0);return u.subarray(0,I<0?u.length:I).toString("utf8")||null}}catch{return null}}function F(){return r=>{try{let t=b("lsof",["-R","-p",String(r),"-d","cwd","-a"],{encoding:"utf8",timeout:2e3,stdio:["ignore","pipe","ignore"]}).split(`
3
3
  `)[1];return t&&t.trim().split(/\s+/)[0]||null}catch{return null}}}function k(){return r=>{try{let t=b("lsof",["-R","-p",String(r),"-d","cwd","-a"],{encoding:"utf8",timeout:2e3,stdio:["ignore","pipe","ignore"]}).split(`
4
4
  `)[1];if(!t)return null;let e=t.trim().split(/\s+/),i=Number(e[2]);return Number.isFinite(i)&&i>1?i:null}catch{return null}}}var d=1,N="SOOTSIM_CLI_CURRENT_SIM_PATH",W=["SOOTSIM_CLI_IDENTITY","AGENTBUS_SESSION","CLAUDE_CODE_SESSION_ID","CODEX_THREAD_ID","TERM_SESSION_ID","ITERM_SESSION_ID","TMUX_PANE","STY","KITTY_WINDOW_ID","WEZTERM_PANE","ALACRITTY_WINDOW_ID","WINDOWID","VSCODE_INJECTION"],$=/^(tmux|screen)/i;function g(r,n=20){let t=r,e=m(r);if(!e||e<=1)return null;for(let i=0;i<n;i++){let o=C(e);if(o&&$.test(o))return t;let s=m(e);if(!s||s<=1)return e;t=e,e=s}return e}function Y(){for(let n of W){let t=process.env[n];if(t&&t.trim())return{key:`${n}:${t.trim()}`,source:n,stable:!0}}let r=g(process.ppid);return r&&r>1?{key:`gppid-${r}`,source:"grand-ppid",stable:!0}:{key:`pid-${process.ppid}`,source:"ppid",stable:!1}}function H(){return Y().key}function tr(){return g(process.ppid)}function a(){if(process.env[N])return V(process.env[N]);let r=H();return U(w(),`sootsim-current-sim-${r}.json`)}function J(){let r=a();if(!A(r))return null;try{let n=JSON.parse(M(r,"utf8"));return n.version!==d||typeof n.simId!="string"||!n.simId.trim()||typeof n.updatedAt!="string"?(f(r,{force:!0}),null):{version:d,simId:n.simId.trim(),updatedAt:n.updatedAt}}catch{return f(r,{force:!0}),null}}function nr(){return J()?.simId||null}function er(r){let n=r.trim();if(!n)return;let t=a();v(B(t),{recursive:!0}),h(t,JSON.stringify({version:d,simId:n,updatedAt:new Date().toISOString()},null,2)+`
@@ -0,0 +1,2 @@
1
+ /*! sootsim v0.1.216 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
+ import{a}from"./chunk-DRFWZ74H.js";import"./chunk-J74AW22R.js";export{a as getCliVersion};
@@ -1,5 +1,5 @@
1
- /*! sootsim v0.1.214 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
- import"./chunk-TI2ZOHON.js";import{existsSync as x,readFileSync as j}from"fs";import{resolve as g}from"path";async function P(s){(s.includes("--help")||s.includes("-h"))&&(console.log(`
1
+ /*! sootsim v0.1.216 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
+ import"./chunk-J74AW22R.js";import{existsSync as x,readFileSync as j}from"fs";import{resolve as g}from"path";async function P(s){(s.includes("--help")||s.includes("-h"))&&(console.log(`
3
3
  sootsim compat \u2014 check package compatibility
4
4
 
5
5
  usage:
@@ -20,7 +20,7 @@ examples:
20
20
  sootsim compat react-native-reanimated
21
21
  sootsim compat --json
22
22
  sootsim compat --brief
23
- `),process.exit(0));let c=s.includes("--json"),e=s.includes("--brief"),l=s.indexOf("--app"),n=l!==-1&&s[l+1]?g(s[l+1]):process.cwd(),k=s.filter((o,a)=>!o.startsWith("-")&&(l===-1||a!==l+1))[0];if(c||e){let{scanDeps:o}=await import("./web-YCDMLF4V.js"),a=g(n,"package.json");x(a)||(console.error(" no package.json found in",n),process.exit(1));let u=JSON.parse(j(a,"utf8")),r=o(u);if(c){console.log(JSON.stringify(r,null,2));return}if(r.packages.length===0){console.log(" no RN ecosystem packages detected");return}let T=Math.round(r.overallScore*100),v=r.packages.filter(i=>i.status==="full").length,$=r.packages.filter(i=>i.status==="partial"||i.status==="auto-stub").length,w=r.packages.filter(i=>i.status==="unsupported").length,p=[];v&&p.push(`${v} fully supported`),$&&p.push(`${$} partial`),w&&p.push(`${w} unsupported`),console.log(` ${p.join(", ")} \u2014 ${T}% compatible`);return}let{POLYFILL_REGISTRY:d}=await import("./web-YCDMLF4V.js");if(k){W(k,d);return}let b=g(n,"package.json");x(b)||(console.error(" no package.json found in",n),process.exit(1));let m=JSON.parse(j(b,"utf8")),S={...m.dependencies,...m.devDependencies},t={full:[],partial:[],autoStub:[],unsupported:[],justWorks:[],unknown:[]};for(let o of Object.keys(S)){let a=d[o];if(a){let u=a.stubType==="native"?"full":a.stubType==="works"?"not-relevant":a.stubType;if(a.stubType!=="native"&&a.versions?.length){let r=Math.max(...a.versions.map(y=>y.coverage||0));u=r>=.8?"full":r>=.3?"partial":"auto-stub"}switch(u){case"full":t.full.push(o);break;case"partial":t.partial.push(o);break;case"auto-stub":t.autoStub.push(o);break;case"unsupported":t.unsupported.push(o);break;case"not-relevant":t.justWorks.push(o);break;default:f(o)&&t.unknown.push(o)}}else f(o)&&t.unknown.push(o)}console.log(`
23
+ `),process.exit(0));let c=s.includes("--json"),e=s.includes("--brief"),l=s.indexOf("--app"),n=l!==-1&&s[l+1]?g(s[l+1]):process.cwd(),k=s.filter((o,a)=>!o.startsWith("-")&&(l===-1||a!==l+1))[0];if(c||e){let{scanDeps:o}=await import("./web-BK6VHH5W.js"),a=g(n,"package.json");x(a)||(console.error(" no package.json found in",n),process.exit(1));let u=JSON.parse(j(a,"utf8")),r=o(u);if(c){console.log(JSON.stringify(r,null,2));return}if(r.packages.length===0){console.log(" no RN ecosystem packages detected");return}let T=Math.round(r.overallScore*100),v=r.packages.filter(i=>i.status==="full").length,$=r.packages.filter(i=>i.status==="partial"||i.status==="auto-stub").length,w=r.packages.filter(i=>i.status==="unsupported").length,p=[];v&&p.push(`${v} fully supported`),$&&p.push(`${$} partial`),w&&p.push(`${w} unsupported`),console.log(` ${p.join(", ")} \u2014 ${T}% compatible`);return}let{POLYFILL_REGISTRY:d}=await import("./web-BK6VHH5W.js");if(k){W(k,d);return}let b=g(n,"package.json");x(b)||(console.error(" no package.json found in",n),process.exit(1));let m=JSON.parse(j(b,"utf8")),S={...m.dependencies,...m.devDependencies},t={full:[],partial:[],autoStub:[],unsupported:[],justWorks:[],unknown:[]};for(let o of Object.keys(S)){let a=d[o];if(a){let u=a.stubType==="native"?"full":a.stubType==="works"?"not-relevant":a.stubType;if(a.stubType!=="native"&&a.versions?.length){let r=Math.max(...a.versions.map(y=>y.coverage||0));u=r>=.8?"full":r>=.3?"partial":"auto-stub"}switch(u){case"full":t.full.push(o);break;case"partial":t.partial.push(o);break;case"auto-stub":t.autoStub.push(o);break;case"unsupported":t.unsupported.push(o);break;case"not-relevant":t.justWorks.push(o);break;default:f(o)&&t.unknown.push(o)}}else f(o)&&t.unknown.push(o)}console.log(`
24
24
  sootsim compatibility report
25
25
  \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
26
26
 
@@ -1,5 +1,5 @@
1
- /*! sootsim v0.1.214 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
- import{A as i,C as s,x as t}from"./chunk-TX53NA5W.js";import"./chunk-TI2ZOHON.js";function l(){let e=i();console.log(` telemetry is ${e?"ON":"OFF"}`),console.log(` config: ${t()}`);let o=process.env.DO_NOT_TRACK;(o==="1"||o==="true")&&console.log(` note: DO_NOT_TRACK=${o} is set \u2014 telemetry is off for this run`)}async function r(e){let o=e.find(n=>!n.startsWith("-"))?.toLowerCase();switch(o){case void 0:case"status":l();return;case"on":case"enable":s(!0),console.log(" telemetry ON"),console.log(` config: ${t()}`);return;case"off":case"disable":s(!1),console.log(" telemetry OFF"),console.log(` config: ${t()}`);return;default:console.error(` unknown telemetry action: ${o}`),console.error(" usage: sootsim config telemetry [on|off|status]"),process.exit(1)}}function c(){console.log(`
1
+ /*! sootsim v0.1.216 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
+ import{A as i,C as s,x as t}from"./chunk-RESHDGBU.js";import"./chunk-J74AW22R.js";function l(){let e=i();console.log(` telemetry is ${e?"ON":"OFF"}`),console.log(` config: ${t()}`);let o=process.env.DO_NOT_TRACK;(o==="1"||o==="true")&&console.log(` note: DO_NOT_TRACK=${o} is set \u2014 telemetry is off for this run`)}async function r(e){let o=e.find(n=>!n.startsWith("-"))?.toLowerCase();switch(o){case void 0:case"status":l();return;case"on":case"enable":s(!0),console.log(" telemetry ON"),console.log(` config: ${t()}`);return;case"off":case"disable":s(!1),console.log(" telemetry OFF"),console.log(` config: ${t()}`);return;default:console.error(` unknown telemetry action: ${o}`),console.error(" usage: sootsim config telemetry [on|off|status]"),process.exit(1)}}function c(){console.log(`
3
3
  sootsim config \u2014 manage local CLI preferences
4
4
 
5
5
  usage:
@@ -1,2 +1,2 @@
1
- /*! sootsim v0.1.214 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
- import{d as a,e as b,f as c,g as d,h as e,i as f,j as g,k as h,l as i,m as j,n as k,o as l,p as m,q as n,r as o,s as p,t as q,u as r,v as s,w as t,x as u}from"./chunk-4RHFQCED.js";import"./chunk-USW3U45B.js";import"./chunk-NQDDEWYD.js";import"./chunk-USSUXBPG.js";import"./chunk-5P6QAHAI.js";import"./chunk-AYY7JBXA.js";import"./chunk-IUTSWOUM.js";import"./chunk-XJEIT5CH.js";import"./chunk-5LD4QHER.js";import"./chunk-L3CQVAWX.js";import"./chunk-RRFWPEQ6.js";import"./chunk-GTRGDGRK.js";import"./chunk-AXXJSIT3.js";import"./chunk-R35AOOU4.js";import"./chunk-BNUZWRON.js";import"./chunk-KPRSDBWU.js";import"./chunk-TX53NA5W.js";import"./chunk-T7CWPTU7.js";import"./chunk-TI2ZOHON.js";export{f as buildOpenUrl,e as buildShellUrl,s as closeSimsBulk,b as normalizeDeepLinkTarget,t as planBulkCloseTargets,k as playwrightHostPidForSim,h as printConnectedSims,c as resolveBundleTarget,d as resolveDefaultShellBaseUrl,a as resolveDriverConnectWaitOptions,r as runClaimCommand,u as runCloseCommand,q as runFocusCommand,n as runLinkCommand,o as runOpenCommand,p as runUseCommand,l as signalDriverLaunchConnected,g as summarizeSimUrl,m as terminatePlaywrightHostsForSims,i as waitForSimMatch,j as waitForSimMatchOrHostExit};
1
+ /*! sootsim v0.1.216 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
+ import{d as a,e as b,f as c,g as d,h as e,i as f,j as g,k as h,l as i,m as j,n as k,o as l,p as m,q as n,r as o,s as p,t as q,u as r,v as s,w as t,x as u}from"./chunk-7SPHDLSB.js";import"./chunk-CQSIRKJ2.js";import"./chunk-5LT4NR6Y.js";import"./chunk-4BUASWNE.js";import"./chunk-VDONTXCB.js";import"./chunk-SBP46OOV.js";import"./chunk-GPLW7IL5.js";import"./chunk-G6VHJWGQ.js";import"./chunk-SPKRGAWR.js";import"./chunk-BGDEZZWT.js";import"./chunk-GIZDZKHC.js";import"./chunk-UPLXEL4D.js";import"./chunk-U7UICUB4.js";import"./chunk-QNRORBZE.js";import"./chunk-VURHG6DO.js";import"./chunk-YN44PKW5.js";import"./chunk-RESHDGBU.js";import"./chunk-DA7KPSMF.js";import"./chunk-J74AW22R.js";export{f as buildOpenUrl,e as buildShellUrl,s as closeSimsBulk,b as normalizeDeepLinkTarget,t as planBulkCloseTargets,k as playwrightHostPidForSim,h as printConnectedSims,c as resolveBundleTarget,d as resolveDefaultShellBaseUrl,a as resolveDriverConnectWaitOptions,r as runClaimCommand,u as runCloseCommand,q as runFocusCommand,n as runLinkCommand,o as runOpenCommand,p as runUseCommand,l as signalDriverLaunchConnected,g as summarizeSimUrl,m as terminatePlaywrightHostsForSims,i as waitForSimMatch,j as waitForSimMatchOrHostExit};
@@ -0,0 +1,2 @@
1
+ /*! sootsim v0.1.216 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
+ import{a,b,c,d,e}from"./chunk-S3C2S27B.js";import"./chunk-LWECTC6A.js";import"./chunk-AWSL2LAA.js";import"./chunk-M2DYRSIS.js";import"./chunk-CCFLATUR.js";import"./chunk-P5JY275Q.js";import"./chunk-QNRORBZE.js";import"./chunk-VURHG6DO.js";import"./chunk-YN44PKW5.js";import"./chunk-RESHDGBU.js";import"./chunk-DRFWZ74H.js";import"./chunk-CRU7UL5Q.js";import"./chunk-DA7KPSMF.js";import"./chunk-J74AW22R.js";export{c as daemonInstall,b as getDaemonServiceStatus,a as runDaemon,d as teardownDaemonService,e as teardownSootsimHome};
@@ -1,5 +1,5 @@
1
- /*! sootsim v0.1.214 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
- import{f,m as T}from"./chunk-IUTSWOUM.js";import{K as S,L as $,M as N,N as A,O as v}from"./chunk-XJEIT5CH.js";import{g as D,i as O,k as x}from"./chunk-5LD4QHER.js";import"./chunk-BNUZWRON.js";import"./chunk-KPRSDBWU.js";import"./chunk-TX53NA5W.js";import"./chunk-TI2ZOHON.js";var H=["portals","sheets","layout","onlayout","animated","render","touch","yoga","all"],R="__sootsimShellAnimationTrace",q="__sootsimDebugAnimation";function L(){console.log(`
1
+ /*! sootsim v0.1.216 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
+ import{f,m as T}from"./chunk-GPLW7IL5.js";import{K as S,L as $,M as N,N as A,O as v}from"./chunk-G6VHJWGQ.js";import{g as D,i as O,k as x}from"./chunk-SPKRGAWR.js";import"./chunk-VURHG6DO.js";import"./chunk-YN44PKW5.js";import"./chunk-RESHDGBU.js";import"./chunk-J74AW22R.js";var H=["portals","sheets","layout","onlayout","animated","render","touch","yoga","all"],R="__sootsimShellAnimationTrace",q="__sootsimDebugAnimation";function L(){console.log(`
3
3
  sootsim debug \u2014 drive __sootsimDebug from the terminal
4
4
 
5
5
  usage:
@@ -170,7 +170,7 @@ examples:
170
170
  } : null,
171
171
  samples,
172
172
  }
173
- })()`}async function c(i,l){return x(i,l)}async function Y(i,l){let g=D(i,{port:l.port,stripBooleanFlags:["--pretty","--json","--help","-h"]}),u=g.positional;(!u[0]||i.includes("--help")||i.includes("-h"))&&(L(),process.exit(0));let P=g.wsPort,_=g.simId,n=!i.includes("--json"),y=_?` --sim ${_}`:"",k=u[0],r=u.slice(1);if(new Set(["state","js","eval","perf","memory","sample-color"]).has(k)){let{runInspect:e}=await import("./inspect-KFGNZ2E3.js");await e(["debug",...i],{port:l.port,verbose:l.verbose});return}let t=O(g);try{switch(k){case"enable":{let e=B(r[0]);e.length===0&&(console.error(` usage: sootsim debug enable <channel[,channel,...]>
173
+ })()`}async function c(i,l){return x(i,l)}async function Y(i,l){let g=D(i,{port:l.port,stripBooleanFlags:["--pretty","--json","--help","-h"]}),u=g.positional;(!u[0]||i.includes("--help")||i.includes("-h"))&&(L(),process.exit(0));let P=g.wsPort,_=g.simId,n=!i.includes("--json"),y=_?` --sim ${_}`:"",k=u[0],r=u.slice(1);if(new Set(["state","js","eval","perf","memory","sample-color"]).has(k)){let{runInspect:e}=await import("./inspect-7SHQVCCL.js");await e(["debug",...i],{port:l.port,verbose:l.verbose});return}let t=O(g);try{switch(k){case"enable":{let e=B(r[0]);e.length===0&&(console.error(` usage: sootsim debug enable <channel[,channel,...]>
174
174
  known: ${H.join(", ")}`),process.exit(1));let o=await v(t,"enable",e);console.log(a({active:o},n));break}case"disable":{let e=B(r[0]),o=await v(t,"disable",e);console.log(a({active:o},n));break}case"toggle":{let e=r[0];e||(console.error(" usage: sootsim debug toggle <channel>"),process.exit(1));let o=await c(t,`window.__sootsimDebug.toggle(${JSON.stringify(e)})`);console.log(a({[e]:o},n));break}case"status":{let e=await S(t);console.log(a(e,n));break}case"channels":{let e=await c(t,"window.__sootsimDebug.channels()");console.log(a(e,n));break}case"flags":{let e=await $(t);console.log(a(e,n));break}case"snapshot":{let e=r[0],o=e?`window.__sootsimDebug.snapshot(${JSON.stringify(e)})`:"window.__sootsimDebug.snapshot()",s=await c(t,`(() => { const s = ${o}; if (!s) return null; return { label: s.label, at: s.at, size: s.nodes.size }; })()`);console.log(a(s,n));break}case"snapshots":{let e=await c(t,"window.__sootsimDebug.snapshots()");console.log(a(e,n));break}case"diff":{let e=r[0],o=r[1];(!e||!o)&&(console.error(" usage: sootsim debug diff <labelA> <labelB>"),process.exit(1));let s=`(() => {
175
175
  const d = window.__sootsimDebug.diff(${JSON.stringify(e)}, ${JSON.stringify(o)});
176
176
  if (!d) return null;